Lines Matching refs:job

21 #include "job.h"
29 struct host1x_job *job = NULL;
47 mem = job = kzalloc(total, GFP_KERNEL);
48 if (!job)
51 kref_init(&job->ref);
52 job->channel = ch;
56 job->relocs = num_relocs ? mem : NULL;
58 job->unpins = num_unpins ? mem : NULL;
60 job->gathers = num_cmdbufs ? mem : NULL;
62 job->addr_phys = num_unpins ? mem : NULL;
64 job->reloc_addr_phys = job->addr_phys;
65 job->gather_addr_phys = &job->addr_phys[num_relocs];
67 return job;
71 struct host1x_job *host1x_job_get(struct host1x_job *job)
73 kref_get(&job->ref);
74 return job;
80 struct host1x_job *job = container_of(ref, struct host1x_job, ref);
82 kfree(job);
85 void host1x_job_put(struct host1x_job *job)
87 kref_put(&job->ref, job_free);
91 void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *bo,
94 struct host1x_job_gather *gather = &job->gathers[job->num_gathers];
100 job->num_gathers++;
104 static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
106 struct host1x_client *client = job->client;
114 job->num_unpins = 0;
116 for (i = 0; i < job->num_relocs; i++) {
117 struct host1x_reloc *reloc = &job->relocs[i];
177 job->unpins[job->num_unpins].dev = dev;
178 job->unpins[job->num_unpins].dir = dir;
182 job->addr_phys[job->num_unpins] = phys_addr;
183 job->unpins[job->num_unpins].bo = reloc->target.bo;
184 job->unpins[job->num_unpins].sgt = sgt;
185 job->num_unpins++;
195 for (i = 0; i < job->num_gathers; i++) {
205 g = &job->gathers[i];
250 job->unpins[job->num_unpins].size = gather_size;
257 job->unpins[job->num_unpins].dir = DMA_TO_DEVICE;
258 job->unpins[job->num_unpins].dev = host->dev;
262 job->addr_phys[job->num_unpins] = phys_addr;
263 job->gather_addr_phys[i] = phys_addr;
265 job->unpins[job->num_unpins].bo = g->bo;
266 job->unpins[job->num_unpins].sgt = sgt;
267 job->num_unpins++;
275 host1x_job_unpin(job);
279 static int do_relocs(struct host1x_job *job, struct host1x_job_gather *g)
286 for (i = 0; i < job->num_relocs; i++) {
287 struct host1x_reloc *reloc = &job->relocs[i];
288 u32 reloc_addr = (job->reloc_addr_phys[i] +
297 target = (u32 *)job->gather_copy_mapped +
339 struct host1x_job *job;
357 if (!fw->job->is_addr_reg)
360 if (fw->job->is_addr_reg(fw->dev, fw->class, offset)) {
376 if (!fw->job->is_valid_class) {
380 if (!fw->job->is_valid_class(fw->class))
458 u32 *cmdbuf_base = (u32 *)fw->job->gather_copy_mapped +
524 static inline int copy_gathers(struct device *host, struct host1x_job *job,
532 fw.job = job;
534 fw.reloc = job->relocs;
535 fw.num_relocs = job->num_relocs;
536 fw.class = job->class;
538 for (i = 0; i < job->num_gathers; i++) {
539 struct host1x_job_gather *g = &job->gathers[i];
548 job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy,
552 if (!job->gather_copy_mapped)
553 job->gather_copy_mapped = dma_alloc_wc(host, size,
554 &job->gather_copy,
556 if (!job->gather_copy_mapped)
559 job->gather_copy_size = size;
561 for (i = 0; i < job->num_gathers; i++) {
562 struct host1x_job_gather *g = &job->gathers[i];
567 memcpy(job->gather_copy_mapped + offset, gather + g->offset,
572 g->base = job->gather_copy;
575 /* Validate the job */
589 int host1x_job_pin(struct host1x_job *job, struct device *dev)
596 err = pin_job(host, job);
601 err = copy_gathers(host->dev, job, dev);
607 for (i = 0; i < job->num_gathers; i++) {
608 struct host1x_job_gather *g = &job->gathers[i];
616 g->base = job->gather_addr_phys[i];
618 for (j = i + 1; j < job->num_gathers; j++) {
619 if (job->gathers[j].bo == g->bo) {
620 job->gathers[j].handled = true;
621 job->gathers[j].base = g->base;
625 err = do_relocs(job, g);
632 host1x_job_unpin(job);
639 void host1x_job_unpin(struct host1x_job *job)
641 struct host1x *host = dev_get_drvdata(job->channel->dev->parent);
644 for (i = 0; i < job->num_unpins; i++) {
645 struct host1x_job_unpin_data *unpin = &job->unpins[i];
651 iommu_unmap(host->domain, job->addr_phys[i],
654 iova_pfn(&host->iova, job->addr_phys[i]));
664 job->num_unpins = 0;
666 if (job->gather_copy_size)
667 dma_free_wc(host->dev, job->gather_copy_size,
668 job->gather_copy_mapped, job->gather_copy);
673 * Debug routine used to dump job entries
675 void host1x_job_dump(struct device *dev, struct host1x_job *job)
677 dev_dbg(dev, " SYNCPT_ID %d\n", job->syncpt_id);
678 dev_dbg(dev, " SYNCPT_VAL %d\n", job->syncpt_end);
679 dev_dbg(dev, " FIRST_GET 0x%x\n", job->first_get);
680 dev_dbg(dev, " TIMEOUT %d\n", job->timeout);
681 dev_dbg(dev, " NUM_SLOTS %d\n", job->num_slots);
682 dev_dbg(dev, " NUM_HANDLES %d\n", job->num_unpins);