提交 89011d26 编写于 作者: T Thierry Reding 提交者: Yang Yingliang

gpu: host1x: Allocate gather copy for host1x

[ Upstream commit b78e70c04c149299bd210759d7c7af7c86b89ca8 ]

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: NThierry Reding <treding@nvidia.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 47730340
...@@ -447,7 +447,8 @@ static int validate(struct host1x_firewall *fw, struct host1x_job_gather *g) ...@@ -447,7 +447,8 @@ static int validate(struct host1x_firewall *fw, struct host1x_job_gather *g)
return err; return err;
} }
static inline int copy_gathers(struct host1x_job *job, struct device *dev) static inline int copy_gathers(struct device *host, struct host1x_job *job,
struct device *dev)
{ {
struct host1x_firewall fw; struct host1x_firewall fw;
size_t size = 0; size_t size = 0;
...@@ -470,12 +471,12 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev) ...@@ -470,12 +471,12 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev)
* Try a non-blocking allocation from a higher priority pools first, * Try a non-blocking allocation from a higher priority pools first,
* as awaiting for the allocation here is a major performance hit. * as awaiting for the allocation here is a major performance hit.
*/ */
job->gather_copy_mapped = dma_alloc_wc(dev, size, &job->gather_copy, job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy,
GFP_NOWAIT); GFP_NOWAIT);
/* the higher priority allocation failed, try the generic-blocking */ /* the higher priority allocation failed, try the generic-blocking */
if (!job->gather_copy_mapped) if (!job->gather_copy_mapped)
job->gather_copy_mapped = dma_alloc_wc(dev, size, job->gather_copy_mapped = dma_alloc_wc(host, size,
&job->gather_copy, &job->gather_copy,
GFP_KERNEL); GFP_KERNEL);
if (!job->gather_copy_mapped) if (!job->gather_copy_mapped)
...@@ -523,7 +524,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev) ...@@ -523,7 +524,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev)
goto out; goto out;
if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) { if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) {
err = copy_gathers(job, dev); err = copy_gathers(host->dev, job, dev);
if (err) if (err)
goto out; goto out;
} }
...@@ -584,7 +585,7 @@ void host1x_job_unpin(struct host1x_job *job) ...@@ -584,7 +585,7 @@ void host1x_job_unpin(struct host1x_job *job)
job->num_unpins = 0; job->num_unpins = 0;
if (job->gather_copy_size) if (job->gather_copy_size)
dma_free_wc(job->channel->dev, job->gather_copy_size, dma_free_wc(host->dev, job->gather_copy_size,
job->gather_copy_mapped, job->gather_copy); job->gather_copy_mapped, job->gather_copy);
} }
EXPORT_SYMBOL(host1x_job_unpin); EXPORT_SYMBOL(host1x_job_unpin);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册