Lines Matching refs:job
21 #include "job.h"
30 struct host1x_job *job = NULL;
51 mem = job = kzalloc(total, GFP_KERNEL);
52 if (!job)
55 job->enable_firewall = enable_firewall;
57 kref_init(&job->ref);
58 job->channel = ch;
62 job->relocs = num_relocs ? mem : NULL;
64 job->unpins = num_unpins ? mem : NULL;
66 job->cmds = num_cmdbufs ? mem : NULL;
68 job->addr_phys = num_unpins ? mem : NULL;
70 job->reloc_addr_phys = job->addr_phys;
71 job->gather_addr_phys = &job->addr_phys[num_relocs];
73 return job;
77 struct host1x_job *host1x_job_get(struct host1x_job *job)
79 kref_get(&job->ref);
80 return job;
86 struct host1x_job *job = container_of(ref, struct host1x_job, ref);
88 if (job->release)
89 job->release(job);
91 if (job->fence) {
97 dma_fence_remove_callback(job->fence, &job->fence_cb);
98 dma_fence_put(job->fence);
101 if (job->syncpt)
102 host1x_syncpt_put(job->syncpt);
104 kfree(job);
107 void host1x_job_put(struct host1x_job *job)
109 kref_put(&job->ref, job_free);
113 void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *bo,
116 struct host1x_job_gather *gather = &job->cmds[job->num_cmds].gather;
122 job->num_cmds++;
126 void host1x_job_add_wait(struct host1x_job *job, u32 id, u32 thresh,
129 struct host1x_job_cmd *cmd = &job->cmds[job->num_cmds];
137 job->num_cmds++;
141 static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
144 struct host1x_client *client = job->client;
150 job->num_unpins = 0;
152 for (i = 0; i < job->num_relocs; i++) {
153 struct host1x_reloc *reloc = &job->relocs[i];
200 job->addr_phys[job->num_unpins] = map->phys;
201 job->unpins[job->num_unpins].map = map;
202 job->num_unpins++;
209 if (job->enable_firewall)
212 for (i = 0; i < job->num_cmds; i++) {
220 if (job->cmds[i].is_wait)
223 g = &job->cmds[i].gather;
263 job->addr_phys[job->num_unpins] = map->phys;
264 job->unpins[job->num_unpins].map = map;
265 job->num_unpins++;
267 job->gather_addr_phys[i] = map->phys;
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] +
296 if (job->enable_firewall) {
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_cmds; i++) {
541 if (job->cmds[i].is_wait)
544 g = &job->cmds[i].gather;
553 job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy,
557 if (!job->gather_copy_mapped)
558 job->gather_copy_mapped = dma_alloc_wc(host, size,
559 &job->gather_copy,
561 if (!job->gather_copy_mapped)
564 job->gather_copy_size = size;
566 for (i = 0; i < job->num_cmds; i++) {
570 if (job->cmds[i].is_wait)
572 g = &job->cmds[i].gather;
576 memcpy(job->gather_copy_mapped + offset, gather + g->offset,
581 g->base = job->gather_copy;
584 /* Validate the job */
598 int host1x_job_pin(struct host1x_job *job, struct device *dev)
605 err = pin_job(host, job);
609 if (job->enable_firewall) {
610 err = copy_gathers(host->dev, job, dev);
616 for (i = 0; i < job->num_cmds; i++) {
619 if (job->cmds[i].is_wait)
621 g = &job->cmds[i].gather;
628 if (!job->enable_firewall)
629 g->base = job->gather_addr_phys[i];
631 for (j = i + 1; j < job->num_cmds; j++) {
632 if (!job->cmds[j].is_wait &&
633 job->cmds[j].gather.bo == g->bo) {
634 job->cmds[j].gather.handled = true;
635 job->cmds[j].gather.base = g->base;
639 err = do_relocs(job, g);
646 host1x_job_unpin(job);
653 void host1x_job_unpin(struct host1x_job *job)
655 struct host1x *host = dev_get_drvdata(job->channel->dev->parent);
658 for (i = 0; i < job->num_unpins; i++) {
659 struct host1x_bo_mapping *map = job->unpins[i].map;
662 if (!job->enable_firewall && map->size && host->domain) {
663 iommu_unmap(host->domain, job->addr_phys[i], map->size);
664 free_iova(&host->iova, iova_pfn(&host->iova, job->addr_phys[i]));
671 job->num_unpins = 0;
673 if (job->gather_copy_size)
674 dma_free_wc(host->dev, job->gather_copy_size,
675 job->gather_copy_mapped, job->gather_copy);
680 * Debug routine used to dump job entries
682 void host1x_job_dump(struct device *dev, struct host1x_job *job)
684 dev_dbg(dev, " SYNCPT_ID %d\n", job->syncpt->id);
685 dev_dbg(dev, " SYNCPT_VAL %d\n", job->syncpt_end);
686 dev_dbg(dev, " FIRST_GET 0x%x\n", job->first_get);
687 dev_dbg(dev, " TIMEOUT %d\n", job->timeout);
688 dev_dbg(dev, " NUM_SLOTS %d\n", job->num_slots);
689 dev_dbg(dev, " NUM_HANDLES %d\n", job->num_unpins);