Skip to content

Commit b78e70c

Browse files
committed
gpu: host1x: Allocate gather copy for host1x
Currently when the gather buffers are copied, they are copied to a buffer that is allocated for the host1x client that wants to execute the command streams in the buffers. However, the gather buffers will be read by the host1x device, which causes SMMU faults if the DMA API is backed by an IOMMU. Fix this by allocating the gather buffer copy for the host1x device, which makes sure that it will be mapped into the host1x's IOVA space if the DMA API is backed by an IOMMU. Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent ab4f81b commit b78e70c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎drivers/gpu/host1x/job.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ static int validate(struct host1x_firewall *fw, struct host1x_job_gather *g)
445445
return err;
446446
}
447447

448-
static inline int copy_gathers(struct host1x_job *job, struct device *dev)
448+
static inline int copy_gathers(struct device *host, struct host1x_job *job,
449+
struct device *dev)
449450
{
450451
struct host1x_firewall fw;
451452
size_t size = 0;
@@ -468,12 +469,12 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev)
468469
* Try a non-blocking allocation from a higher priority pools first,
469470
* as awaiting for the allocation here is a major performance hit.
470471
*/
471-
job->gather_copy_mapped = dma_alloc_wc(dev, size, &job->gather_copy,
472+
job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy,
472473
GFP_NOWAIT);
473474

474475
/* the higher priority allocation failed, try the generic-blocking */
475476
if (!job->gather_copy_mapped)
476-
job->gather_copy_mapped = dma_alloc_wc(dev, size,
477+
job->gather_copy_mapped = dma_alloc_wc(host, size,
477478
&job->gather_copy,
478479
GFP_KERNEL);
479480
if (!job->gather_copy_mapped)
@@ -521,7 +522,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev)
521522
goto out;
522523

523524
if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) {
524-
err = copy_gathers(job, dev);
525+
err = copy_gathers(host->dev, job, dev);
525526
if (err)
526527
goto out;
527528
}
@@ -582,7 +583,7 @@ void host1x_job_unpin(struct host1x_job *job)
582583
job->num_unpins = 0;
583584

584585
if (job->gather_copy_size)
585-
dma_free_wc(job->channel->dev, job->gather_copy_size,
586+
dma_free_wc(host->dev, job->gather_copy_size,
586587
job->gather_copy_mapped, job->gather_copy);
587588
}
588589
EXPORT_SYMBOL(host1x_job_unpin);

0 commit comments

Comments
 (0)