* [PATCH] drm/msm: use orig_nents to iterate over scatterlist with per-process tables
@ 2022-03-28 12:55 ` Jonathan Marek
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Marek @ 2022-03-28 12:55 UTC (permalink / raw)
To: freedreno
Cc: dpiliaiev, Rob Clark, Sean Paul, Abhinav Kumar, David Airlie,
Daniel Vetter, Bjorn Andersson, Jordan Crouse,
open list:DRM DRIVER FOR MSM ADRENO GPU,
open list:DRM DRIVER FOR MSM ADRENO GPU, open list
This matches the implementation of iommu_map_sgtable() used for the
non-per-process page tables path.
This works around the dma_map_sgtable() call (used to invalidate cache)
overwriting sgt->nents with 1 (which is probably a separate issue).
Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
drivers/gpu/drm/msm/msm_iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index bcaddbba564df..22935ef26a3a1 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 iova,
u64 addr = iova;
unsigned int i;
- for_each_sg(sgt->sgl, sg, sgt->nents, i) {
+ for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {
size_t size = sg->length;
phys_addr_t phys = sg_phys(sg);
--
2.26.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] drm/msm: use orig_nents to iterate over scatterlist with per-process tables
@ 2022-03-28 12:55 ` Jonathan Marek
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Marek @ 2022-03-28 12:55 UTC (permalink / raw)
To: freedreno
Cc: David Airlie, open list:DRM DRIVER FOR MSM ADRENO GPU,
Jordan Crouse, dpiliaiev,
open list:DRM DRIVER FOR MSM ADRENO GPU, Abhinav Kumar,
Bjorn Andersson, Sean Paul, open list
This matches the implementation of iommu_map_sgtable() used for the
non-per-process page tables path.
This works around the dma_map_sgtable() call (used to invalidate cache)
overwriting sgt->nents with 1 (which is probably a separate issue).
Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
drivers/gpu/drm/msm/msm_iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index bcaddbba564df..22935ef26a3a1 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 iova,
u64 addr = iova;
unsigned int i;
- for_each_sg(sgt->sgl, sg, sgt->nents, i) {
+ for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {
size_t size = sg->length;
phys_addr_t phys = sg_phys(sg);
--
2.26.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/msm: use orig_nents to iterate over scatterlist with per-process tables
2022-03-28 12:55 ` Jonathan Marek
@ 2022-04-05 10:18 ` Robin Murphy
-1 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2022-04-05 10:18 UTC (permalink / raw)
To: Jonathan Marek, freedreno
Cc: David Airlie, open list:DRM DRIVER FOR MSM ADRENO GPU,
Abhinav Kumar, open list:DRM DRIVER FOR MSM ADRENO GPU,
dpiliaiev, Bjorn Andersson, Jordan Crouse, Sean Paul, open list
On 2022-03-28 13:55, Jonathan Marek wrote:
> This matches the implementation of iommu_map_sgtable() used for the
> non-per-process page tables path.
>
> This works around the dma_map_sgtable() call (used to invalidate cache)
> overwriting sgt->nents with 1 (which is probably a separate issue).
FWIW that's expected behaviour. The sgtable APIs use nents to keep track
of the number of DMA segments, while orig_nents represents the physical
segments. IIUC you're not actually using the DMA mapping, just relying
on its side-effects, so it's still the physical segments that you care
about for your private IOMMU mapping here.
> Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> ---
> drivers/gpu/drm/msm/msm_iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
> index bcaddbba564df..22935ef26a3a1 100644
> --- a/drivers/gpu/drm/msm/msm_iommu.c
> +++ b/drivers/gpu/drm/msm/msm_iommu.c
> @@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 iova,
> u64 addr = iova;
> unsigned int i;
>
> - for_each_sg(sgt->sgl, sg, sgt->nents, i) {
> + for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {
Even better would be to use for_each_sgtable_sg(), which exists
primarily for the sake of avoiding this exact confusion.
Robin.
> size_t size = sg->length;
> phys_addr_t phys = sg_phys(sg);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/msm: use orig_nents to iterate over scatterlist with per-process tables
@ 2022-04-05 10:18 ` Robin Murphy
0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2022-04-05 10:18 UTC (permalink / raw)
To: Jonathan Marek, freedreno
Cc: David Airlie, open list:DRM DRIVER FOR MSM ADRENO GPU,
Jordan Crouse, dpiliaiev,
open list:DRM DRIVER FOR MSM ADRENO GPU, Abhinav Kumar,
Bjorn Andersson, Sean Paul, open list
On 2022-03-28 13:55, Jonathan Marek wrote:
> This matches the implementation of iommu_map_sgtable() used for the
> non-per-process page tables path.
>
> This works around the dma_map_sgtable() call (used to invalidate cache)
> overwriting sgt->nents with 1 (which is probably a separate issue).
FWIW that's expected behaviour. The sgtable APIs use nents to keep track
of the number of DMA segments, while orig_nents represents the physical
segments. IIUC you're not actually using the DMA mapping, just relying
on its side-effects, so it's still the physical segments that you care
about for your private IOMMU mapping here.
> Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> ---
> drivers/gpu/drm/msm/msm_iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
> index bcaddbba564df..22935ef26a3a1 100644
> --- a/drivers/gpu/drm/msm/msm_iommu.c
> +++ b/drivers/gpu/drm/msm/msm_iommu.c
> @@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 iova,
> u64 addr = iova;
> unsigned int i;
>
> - for_each_sg(sgt->sgl, sg, sgt->nents, i) {
> + for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {
Even better would be to use for_each_sgtable_sg(), which exists
primarily for the sake of avoiding this exact confusion.
Robin.
> size_t size = sg->length;
> phys_addr_t phys = sg_phys(sg);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-05 10:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 12:55 [PATCH] drm/msm: use orig_nents to iterate over scatterlist with per-process tables Jonathan Marek
2022-03-28 12:55 ` Jonathan Marek
2022-04-05 10:18 ` Robin Murphy
2022-04-05 10:18 ` Robin Murphy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.