Lines Matching full:job
2 * Tegra host1x Job
31 #include "job.h"
39 struct host1x_job *job = NULL; in host1x_job_alloc() local
54 mem = job = kzalloc(total, GFP_KERNEL); in host1x_job_alloc()
55 if (!job) in host1x_job_alloc()
58 kref_init(&job->ref); in host1x_job_alloc()
59 job->channel = ch; in host1x_job_alloc()
63 job->relocs = num_relocs ? mem : NULL; in host1x_job_alloc()
65 job->unpins = num_unpins ? mem : NULL; in host1x_job_alloc()
67 job->gathers = num_cmdbufs ? mem : NULL; in host1x_job_alloc()
69 job->addr_phys = num_unpins ? mem : NULL; in host1x_job_alloc()
71 job->reloc_addr_phys = job->addr_phys; in host1x_job_alloc()
72 job->gather_addr_phys = &job->addr_phys[num_relocs]; in host1x_job_alloc()
74 return job; in host1x_job_alloc()
78 struct host1x_job *host1x_job_get(struct host1x_job *job) in host1x_job_get() argument
80 kref_get(&job->ref); in host1x_job_get()
81 return job; in host1x_job_get()
87 struct host1x_job *job = container_of(ref, struct host1x_job, ref); in job_free() local
89 kfree(job); in job_free()
92 void host1x_job_put(struct host1x_job *job) in host1x_job_put() argument
94 kref_put(&job->ref, job_free); in host1x_job_put()
98 void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *bo, in host1x_job_add_gather() argument
101 struct host1x_job_gather *gather = &job->gathers[job->num_gathers]; in host1x_job_add_gather()
107 job->num_gathers++; in host1x_job_add_gather()
111 static unsigned int pin_job(struct host1x *host, struct host1x_job *job) in pin_job() argument
116 job->num_unpins = 0; in pin_job()
118 for (i = 0; i < job->num_relocs; i++) { in pin_job()
119 struct host1x_reloc *reloc = &job->relocs[i]; in pin_job()
131 job->addr_phys[job->num_unpins] = phys_addr; in pin_job()
132 job->unpins[job->num_unpins].bo = reloc->target.bo; in pin_job()
133 job->unpins[job->num_unpins].sgt = sgt; in pin_job()
134 job->num_unpins++; in pin_job()
137 for (i = 0; i < job->num_gathers; i++) { in pin_job()
138 struct host1x_job_gather *g = &job->gathers[i]; in pin_job()
177 job->addr_phys[job->num_unpins] = in pin_job()
179 job->unpins[job->num_unpins].size = gather_size; in pin_job()
181 job->addr_phys[job->num_unpins] = phys_addr; in pin_job()
184 job->gather_addr_phys[i] = job->addr_phys[job->num_unpins]; in pin_job()
186 job->unpins[job->num_unpins].bo = g->bo; in pin_job()
187 job->unpins[job->num_unpins].sgt = sgt; in pin_job()
188 job->num_unpins++; in pin_job()
194 host1x_job_unpin(job); in pin_job()
198 static int do_relocs(struct host1x_job *job, struct host1x_job_gather *g) in do_relocs() argument
206 for (i = 0; i < job->num_relocs; i++) { in do_relocs()
207 struct host1x_reloc *reloc = &job->relocs[i]; in do_relocs()
208 u32 reloc_addr = (job->reloc_addr_phys[i] + in do_relocs()
217 target = (u32 *)job->gather_copy_mapped + in do_relocs()
265 struct host1x_job *job; member
283 if (!fw->job->is_addr_reg) in check_register()
286 if (fw->job->is_addr_reg(fw->dev, fw->class, offset)) { in check_register()
302 if (!fw->job->is_valid_class) { in check_class()
306 if (!fw->job->is_valid_class(fw->class)) in check_class()
384 u32 *cmdbuf_base = (u32 *)fw->job->gather_copy_mapped + in validate()
450 static inline int copy_gathers(struct device *host, struct host1x_job *job, in copy_gathers() argument
458 fw.job = job; in copy_gathers()
460 fw.reloc = job->relocs; in copy_gathers()
461 fw.num_relocs = job->num_relocs; in copy_gathers()
462 fw.class = job->class; in copy_gathers()
464 for (i = 0; i < job->num_gathers; i++) { in copy_gathers()
465 struct host1x_job_gather *g = &job->gathers[i]; in copy_gathers()
474 job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy, in copy_gathers()
478 if (!job->gather_copy_mapped) in copy_gathers()
479 job->gather_copy_mapped = dma_alloc_wc(host, size, in copy_gathers()
480 &job->gather_copy, in copy_gathers()
482 if (!job->gather_copy_mapped) in copy_gathers()
485 job->gather_copy_size = size; in copy_gathers()
487 for (i = 0; i < job->num_gathers; i++) { in copy_gathers()
488 struct host1x_job_gather *g = &job->gathers[i]; in copy_gathers()
493 memcpy(job->gather_copy_mapped + offset, gather + g->offset, in copy_gathers()
498 g->base = job->gather_copy; in copy_gathers()
501 /* Validate the job */ in copy_gathers()
515 int host1x_job_pin(struct host1x_job *job, struct device *dev) in host1x_job_pin() argument
522 err = pin_job(host, job); in host1x_job_pin()
527 err = copy_gathers(host->dev, job, dev); in host1x_job_pin()
533 for (i = 0; i < job->num_gathers; i++) { in host1x_job_pin()
534 struct host1x_job_gather *g = &job->gathers[i]; in host1x_job_pin()
542 g->base = job->gather_addr_phys[i]; in host1x_job_pin()
544 for (j = i + 1; j < job->num_gathers; j++) { in host1x_job_pin()
545 if (job->gathers[j].bo == g->bo) { in host1x_job_pin()
546 job->gathers[j].handled = true; in host1x_job_pin()
547 job->gathers[j].base = g->base; in host1x_job_pin()
551 err = do_relocs(job, g); in host1x_job_pin()
558 host1x_job_unpin(job); in host1x_job_pin()
565 void host1x_job_unpin(struct host1x_job *job) in host1x_job_unpin() argument
567 struct host1x *host = dev_get_drvdata(job->channel->dev->parent); in host1x_job_unpin()
570 for (i = 0; i < job->num_unpins; i++) { in host1x_job_unpin()
571 struct host1x_job_unpin_data *unpin = &job->unpins[i]; in host1x_job_unpin()
575 iommu_unmap(host->domain, job->addr_phys[i], in host1x_job_unpin()
578 iova_pfn(&host->iova, job->addr_phys[i])); in host1x_job_unpin()
585 job->num_unpins = 0; in host1x_job_unpin()
587 if (job->gather_copy_size) in host1x_job_unpin()
588 dma_free_wc(host->dev, job->gather_copy_size, in host1x_job_unpin()
589 job->gather_copy_mapped, job->gather_copy); in host1x_job_unpin()
594 * Debug routine used to dump job entries
596 void host1x_job_dump(struct device *dev, struct host1x_job *job) in host1x_job_dump() argument
598 dev_dbg(dev, " SYNCPT_ID %d\n", job->syncpt_id); in host1x_job_dump()
599 dev_dbg(dev, " SYNCPT_VAL %d\n", job->syncpt_end); in host1x_job_dump()
600 dev_dbg(dev, " FIRST_GET 0x%x\n", job->first_get); in host1x_job_dump()
601 dev_dbg(dev, " TIMEOUT %d\n", job->timeout); in host1x_job_dump()
602 dev_dbg(dev, " NUM_SLOTS %d\n", job->num_slots); in host1x_job_dump()
603 dev_dbg(dev, " NUM_HANDLES %d\n", job->num_unpins); in host1x_job_dump()