Lines Matching full:job

3  * Tegra host1x Job
21 #include "job.h"
30 struct host1x_job *job = NULL; in host1x_job_alloc() local
51 mem = job = kzalloc(total, GFP_KERNEL); in host1x_job_alloc()
52 if (!job) in host1x_job_alloc()
55 job->enable_firewall = enable_firewall; in host1x_job_alloc()
57 kref_init(&job->ref); in host1x_job_alloc()
58 job->channel = ch; in host1x_job_alloc()
62 job->relocs = num_relocs ? mem : NULL; in host1x_job_alloc()
64 job->unpins = num_unpins ? mem : NULL; in host1x_job_alloc()
66 job->cmds = num_cmdbufs ? mem : NULL; in host1x_job_alloc()
68 job->addr_phys = num_unpins ? mem : NULL; in host1x_job_alloc()
70 job->reloc_addr_phys = job->addr_phys; in host1x_job_alloc()
71 job->gather_addr_phys = &job->addr_phys[num_relocs]; in host1x_job_alloc()
73 return job; in host1x_job_alloc()
77 struct host1x_job *host1x_job_get(struct host1x_job *job) in host1x_job_get() argument
79 kref_get(&job->ref); in host1x_job_get()
80 return job; in host1x_job_get()
86 struct host1x_job *job = container_of(ref, struct host1x_job, ref); in job_free() local
88 if (job->release) in job_free()
89 job->release(job); in job_free()
91 if (job->waiter) in job_free()
92 host1x_intr_put_ref(job->syncpt->host, job->syncpt->id, in job_free()
93 job->waiter, false); in job_free()
95 if (job->syncpt) in job_free()
96 host1x_syncpt_put(job->syncpt); in job_free()
98 kfree(job); in job_free()
101 void host1x_job_put(struct host1x_job *job) in host1x_job_put() argument
103 kref_put(&job->ref, job_free); in host1x_job_put()
107 void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *bo, in host1x_job_add_gather() argument
110 struct host1x_job_gather *gather = &job->cmds[job->num_cmds].gather; in host1x_job_add_gather()
116 job->num_cmds++; in host1x_job_add_gather()
120 void host1x_job_add_wait(struct host1x_job *job, u32 id, u32 thresh, in host1x_job_add_wait() argument
123 struct host1x_job_cmd *cmd = &job->cmds[job->num_cmds]; in host1x_job_add_wait()
131 job->num_cmds++; in host1x_job_add_wait()
135 static unsigned int pin_job(struct host1x *host, struct host1x_job *job) in pin_job() argument
137 struct host1x_client *client = job->client; in pin_job()
146 job->num_unpins = 0; in pin_job()
148 for (i = 0; i < job->num_relocs; i++) { in pin_job()
149 struct host1x_reloc *reloc = &job->relocs[i]; in pin_job()
208 job->unpins[job->num_unpins].dev = dev; in pin_job()
209 job->unpins[job->num_unpins].dir = dir; in pin_job()
213 job->addr_phys[job->num_unpins] = phys_addr; in pin_job()
214 job->unpins[job->num_unpins].bo = reloc->target.bo; in pin_job()
215 job->unpins[job->num_unpins].sgt = sgt; in pin_job()
216 job->num_unpins++; in pin_job()
223 if (job->enable_firewall) in pin_job()
226 for (i = 0; i < job->num_cmds; i++) { in pin_job()
235 if (job->cmds[i].is_wait) in pin_job()
238 g = &job->cmds[i].gather; in pin_job()
284 job->unpins[job->num_unpins].size = gather_size; in pin_job()
291 job->unpins[job->num_unpins].dir = DMA_TO_DEVICE; in pin_job()
292 job->unpins[job->num_unpins].dev = host->dev; in pin_job()
296 job->addr_phys[job->num_unpins] = phys_addr; in pin_job()
297 job->gather_addr_phys[i] = phys_addr; in pin_job()
299 job->unpins[job->num_unpins].bo = g->bo; in pin_job()
300 job->unpins[job->num_unpins].sgt = sgt; in pin_job()
301 job->num_unpins++; in pin_job()
309 host1x_job_unpin(job); in pin_job()
313 static int do_relocs(struct host1x_job *job, struct host1x_job_gather *g) in do_relocs() argument
320 for (i = 0; i < job->num_relocs; i++) { in do_relocs()
321 struct host1x_reloc *reloc = &job->relocs[i]; in do_relocs()
322 u32 reloc_addr = (job->reloc_addr_phys[i] + in do_relocs()
330 if (job->enable_firewall) { in do_relocs()
331 target = (u32 *)job->gather_copy_mapped + in do_relocs()
373 struct host1x_job *job; member
391 if (!fw->job->is_addr_reg) in check_register()
394 if (fw->job->is_addr_reg(fw->dev, fw->class, offset)) { in check_register()
410 if (!fw->job->is_valid_class) { in check_class()
414 if (!fw->job->is_valid_class(fw->class)) in check_class()
492 u32 *cmdbuf_base = (u32 *)fw->job->gather_copy_mapped + in validate()
558 static inline int copy_gathers(struct device *host, struct host1x_job *job, in copy_gathers() argument
566 fw.job = job; in copy_gathers()
568 fw.reloc = job->relocs; in copy_gathers()
569 fw.num_relocs = job->num_relocs; in copy_gathers()
570 fw.class = job->class; in copy_gathers()
572 for (i = 0; i < job->num_cmds; i++) { in copy_gathers()
575 if (job->cmds[i].is_wait) in copy_gathers()
578 g = &job->cmds[i].gather; in copy_gathers()
587 job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy, in copy_gathers()
591 if (!job->gather_copy_mapped) in copy_gathers()
592 job->gather_copy_mapped = dma_alloc_wc(host, size, in copy_gathers()
593 &job->gather_copy, in copy_gathers()
595 if (!job->gather_copy_mapped) in copy_gathers()
598 job->gather_copy_size = size; in copy_gathers()
600 for (i = 0; i < job->num_cmds; i++) { in copy_gathers()
604 if (job->cmds[i].is_wait) in copy_gathers()
606 g = &job->cmds[i].gather; in copy_gathers()
610 memcpy(job->gather_copy_mapped + offset, gather + g->offset, in copy_gathers()
615 g->base = job->gather_copy; in copy_gathers()
618 /* Validate the job */ in copy_gathers()
632 int host1x_job_pin(struct host1x_job *job, struct device *dev) in host1x_job_pin() argument
639 err = pin_job(host, job); in host1x_job_pin()
643 if (job->enable_firewall) { in host1x_job_pin()
644 err = copy_gathers(host->dev, job, dev); in host1x_job_pin()
650 for (i = 0; i < job->num_cmds; i++) { in host1x_job_pin()
653 if (job->cmds[i].is_wait) in host1x_job_pin()
655 g = &job->cmds[i].gather; in host1x_job_pin()
662 if (!job->enable_firewall) in host1x_job_pin()
663 g->base = job->gather_addr_phys[i]; in host1x_job_pin()
665 for (j = i + 1; j < job->num_cmds; j++) { in host1x_job_pin()
666 if (!job->cmds[j].is_wait && in host1x_job_pin()
667 job->cmds[j].gather.bo == g->bo) { in host1x_job_pin()
668 job->cmds[j].gather.handled = true; in host1x_job_pin()
669 job->cmds[j].gather.base = g->base; in host1x_job_pin()
673 err = do_relocs(job, g); in host1x_job_pin()
680 host1x_job_unpin(job); in host1x_job_pin()
687 void host1x_job_unpin(struct host1x_job *job) in host1x_job_unpin() argument
689 struct host1x *host = dev_get_drvdata(job->channel->dev->parent); in host1x_job_unpin()
692 for (i = 0; i < job->num_unpins; i++) { in host1x_job_unpin()
693 struct host1x_job_unpin_data *unpin = &job->unpins[i]; in host1x_job_unpin()
697 if (!job->enable_firewall && unpin->size && host->domain) { in host1x_job_unpin()
698 iommu_unmap(host->domain, job->addr_phys[i], in host1x_job_unpin()
701 iova_pfn(&host->iova, job->addr_phys[i])); in host1x_job_unpin()
711 job->num_unpins = 0; in host1x_job_unpin()
713 if (job->gather_copy_size) in host1x_job_unpin()
714 dma_free_wc(host->dev, job->gather_copy_size, in host1x_job_unpin()
715 job->gather_copy_mapped, job->gather_copy); in host1x_job_unpin()
720 * Debug routine used to dump job entries
722 void host1x_job_dump(struct device *dev, struct host1x_job *job) in host1x_job_dump() argument
724 dev_dbg(dev, " SYNCPT_ID %d\n", job->syncpt->id); in host1x_job_dump()
725 dev_dbg(dev, " SYNCPT_VAL %d\n", job->syncpt_end); in host1x_job_dump()
726 dev_dbg(dev, " FIRST_GET 0x%x\n", job->first_get); in host1x_job_dump()
727 dev_dbg(dev, " TIMEOUT %d\n", job->timeout); in host1x_job_dump()
728 dev_dbg(dev, " NUM_SLOTS %d\n", job->num_slots); in host1x_job_dump()
729 dev_dbg(dev, " NUM_HANDLES %d\n", job->num_unpins); in host1x_job_dump()