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