* [PATCH 07/13] drm/msm: Use sychronized interface of the IOMMU-API [not found] <1502974596-23835-1-git-send-email-joro@8bytes.org> @ 2017-08-17 12:56 ` Joerg Roedel 2017-08-19 15:39 ` Rob Clark 2017-08-17 12:56 ` [PATCH 09/13] drm/rockchip: " Joerg Roedel [not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2 siblings, 1 reply; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 12:56 UTC (permalink / raw) To: iommu Cc: linux-kernel, Suravee Suthikulpanit, Joerg Roedel, Rob Clark, David Airlie, linux-arm-msm, dri-devel, freedreno From: Joerg Roedel <jroedel@suse.de> The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Rob Clark <robdclark@gmail.com> Cc: David Airlie <airlied@linux.ie> Cc: linux-arm-msm@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org Signed-off-by: Joerg Roedel <jroedel@suse.de> --- drivers/gpu/drm/msm/msm_iommu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c index b23d336..b3525b7 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -64,7 +64,8 @@ static int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova, size_t ret; // pm_runtime_get_sync(mmu->dev); - ret = iommu_map_sg(iommu->domain, iova, sgt->sgl, sgt->nents, prot); + ret = iommu_map_sg_sync(iommu->domain, iova, sgt->sgl, + sgt->nents, prot); // pm_runtime_put_sync(mmu->dev); WARN_ON(ret < 0); @@ -77,7 +78,7 @@ static int msm_iommu_unmap(struct msm_mmu *mmu, uint64_t iova, struct msm_iommu *iommu = to_msm_iommu(mmu); pm_runtime_get_sync(mmu->dev); - iommu_unmap(iommu->domain, iova, len); + iommu_unmap_sync(iommu->domain, iova, len); pm_runtime_put_sync(mmu->dev); return 0; -- 2.7.4 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 07/13] drm/msm: Use sychronized interface of the IOMMU-API 2017-08-17 12:56 ` [PATCH 07/13] drm/msm: Use sychronized interface of the IOMMU-API Joerg Roedel @ 2017-08-19 15:39 ` Rob Clark 0 siblings, 0 replies; 15+ messages in thread From: Rob Clark @ 2017-08-19 15:39 UTC (permalink / raw) To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, Linux Kernel Mailing List, Suravee Suthikulpanit, Joerg Roedel, David Airlie, linux-arm-msm, dri-devel@lists.freedesktop.org, freedreno On Thu, Aug 17, 2017 at 8:56 AM, Joerg Roedel <joro@8bytes.org> wrote: > From: Joerg Roedel <jroedel@suse.de> > > The map and unmap functions of the IOMMU-API changed their > semantics: They do no longer guarantee that the hardware > TLBs are synchronized with the page-table updates they made. > > To make conversion easier, new synchronized functions have > been introduced which give these guarantees again until the > code is converted to use the new TLB-flush interface of the > IOMMU-API, which allows certain optimizations. > > But for now, just convert this code to use the synchronized > functions so that it will behave as before. I like the idea of decoupling tlb inv with map (well that doesn't really effect any recent hw) and unmap (which does need tlb flush).. and for a gpu driver it should be pretty easy to back up unmaps. I did slightly prefer adding a new iommu_{map,unmap}_async() rather than changing semantics of existing API, but either way: Acked-by: Rob Clark <robdclark@gmail.com> > Cc: Rob Clark <robdclark@gmail.com> > Cc: David Airlie <airlied@linux.ie> > Cc: linux-arm-msm@vger.kernel.org > Cc: dri-devel@lists.freedesktop.org > Cc: freedreno@lists.freedesktop.org > Signed-off-by: Joerg Roedel <jroedel@suse.de> > --- > drivers/gpu/drm/msm/msm_iommu.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c > index b23d336..b3525b7 100644 > --- a/drivers/gpu/drm/msm/msm_iommu.c > +++ b/drivers/gpu/drm/msm/msm_iommu.c > @@ -64,7 +64,8 @@ static int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova, > size_t ret; > > // pm_runtime_get_sync(mmu->dev); > - ret = iommu_map_sg(iommu->domain, iova, sgt->sgl, sgt->nents, prot); > + ret = iommu_map_sg_sync(iommu->domain, iova, sgt->sgl, > + sgt->nents, prot); > // pm_runtime_put_sync(mmu->dev); > WARN_ON(ret < 0); > > @@ -77,7 +78,7 @@ static int msm_iommu_unmap(struct msm_mmu *mmu, uint64_t iova, > struct msm_iommu *iommu = to_msm_iommu(mmu); > > pm_runtime_get_sync(mmu->dev); > - iommu_unmap(iommu->domain, iova, len); > + iommu_unmap_sync(iommu->domain, iova, len); > pm_runtime_put_sync(mmu->dev); > > return 0; > -- > 2.7.4 > ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 09/13] drm/rockchip: Use sychronized interface of the IOMMU-API [not found] <1502974596-23835-1-git-send-email-joro@8bytes.org> 2017-08-17 12:56 ` [PATCH 07/13] drm/msm: Use sychronized interface of the IOMMU-API Joerg Roedel @ 2017-08-17 12:56 ` Joerg Roedel [not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2 siblings, 0 replies; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 12:56 UTC (permalink / raw) To: iommu Cc: linux-kernel, Suravee Suthikulpanit, Joerg Roedel, Mark Yao, David Airlie, Heiko Stuebner, dri-devel, linux-arm-kernel, linux-rockchip From: Joerg Roedel <jroedel@suse.de> The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Mark Yao <mark.yao@rock-chips.com> Cc: David Airlie <airlied@linux.ie> Cc: Heiko Stuebner <heiko@sntech.de> Cc: dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rockchip@lists.infradead.org Signed-off-by: Joerg Roedel <jroedel@suse.de> --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index b74ac71..6d28224 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -41,8 +41,8 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj) rk_obj->dma_addr = rk_obj->mm.start; - ret = iommu_map_sg(private->domain, rk_obj->dma_addr, rk_obj->sgt->sgl, - rk_obj->sgt->nents, prot); + ret = iommu_map_sg_sync(private->domain, rk_obj->dma_addr, + rk_obj->sgt->sgl, rk_obj->sgt->nents, prot); if (ret < rk_obj->base.size) { DRM_ERROR("failed to map buffer: size=%zd request_size=%zd\n", ret, rk_obj->base.size); @@ -67,7 +67,7 @@ static int rockchip_gem_iommu_unmap(struct rockchip_gem_object *rk_obj) struct drm_device *drm = rk_obj->base.dev; struct rockchip_drm_private *private = drm->dev_private; - iommu_unmap(private->domain, rk_obj->dma_addr, rk_obj->size); + iommu_unmap_sync(private->domain, rk_obj->dma_addr, rk_obj->size); mutex_lock(&private->mm_lock); -- 2.7.4 ^ permalink raw reply related [flat|nested] 15+ messages in thread
[parent not found: <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API [not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-08-17 12:56 ` Joerg Roedel [not found] ` <1502974596-23835-7-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-08-17 12:56 ` [PATCH 08/13] drm/nouveau/imem/gk20a: " Joerg Roedel ` (2 subsequent siblings) 3 siblings, 1 reply; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 12:56 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, David Airlie, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Christian Gmeiner, Russell King, Lucas Stach From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Lucas Stach <l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Cc: Russell King <linux+etnaviv-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org> Cc: Christian Gmeiner <christian.gmeiner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org> Cc: etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c index f103e78..ae0247c 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c @@ -47,7 +47,7 @@ int etnaviv_iommu_map(struct etnaviv_iommu *iommu, u32 iova, VERB("map[%d]: %08x %08x(%zx)", i, iova, pa, bytes); - ret = iommu_map(domain, da, pa, bytes, prot); + ret = iommu_map_sync(domain, da, pa, bytes, prot); if (ret) goto fail; @@ -62,7 +62,7 @@ int etnaviv_iommu_map(struct etnaviv_iommu *iommu, u32 iova, for_each_sg(sgt->sgl, sg, i, j) { size_t bytes = sg_dma_len(sg) + sg->offset; - iommu_unmap(domain, da, bytes); + iommu_unmap_sync(domain, da, bytes); da += bytes; } return ret; @@ -80,7 +80,7 @@ int etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova, size_t bytes = sg_dma_len(sg) + sg->offset; size_t unmapped; - unmapped = iommu_unmap(domain, da, bytes); + unmapped = iommu_unmap_sync(domain, da, bytes); if (unmapped < bytes) return unmapped; @@ -338,7 +338,7 @@ int etnaviv_iommu_get_suballoc_va(struct etnaviv_gpu *gpu, dma_addr_t paddr, mutex_unlock(&mmu->lock); return ret; } - ret = iommu_map(mmu->domain, vram_node->start, paddr, size, + ret = iommu_map_sync(mmu->domain, vram_node->start, paddr, size, IOMMU_READ); if (ret < 0) { drm_mm_remove_node(vram_node); @@ -362,7 +362,7 @@ void etnaviv_iommu_put_suballoc_va(struct etnaviv_gpu *gpu, if (mmu->version == ETNAVIV_IOMMU_V2) { mutex_lock(&mmu->lock); - iommu_unmap(mmu->domain,iova, size); + iommu_unmap_sync(mmu->domain,iova, size); drm_mm_remove_node(vram_node); mutex_unlock(&mmu->lock); } -- 2.7.4 ^ permalink raw reply related [flat|nested] 15+ messages in thread
[parent not found: <1502974596-23835-7-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API [not found] ` <1502974596-23835-7-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-08-17 13:32 ` Lucas Stach [not found] ` <1502976758.19806.25.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 0 siblings, 1 reply; 15+ messages in thread From: Lucas Stach @ 2017-08-17 13:32 UTC (permalink / raw) To: Joerg Roedel Cc: Joerg Roedel, David Airlie, Christian Gmeiner, etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-kernel-u79uwXL29TY76Z2rM5mHXA, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Russell King Hi Joerg, Am Donnerstag, den 17.08.2017, 14:56 +0200 schrieb Joerg Roedel: > From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > > The map and unmap functions of the IOMMU-API changed their > semantics: They do no longer guarantee that the hardware > TLBs are synchronized with the page-table updates they made. > > To make conversion easier, new synchronized functions have > been introduced which give these guarantees again until the > code is converted to use the new TLB-flush interface of the > IOMMU-API, which allows certain optimizations. > > But for now, just convert this code to use the synchronized > functions so that it will behave as before. I don't think this is necessary. Etnaviv has managed and batched up TLB flushes from day 1, as they don't happen through the MMU MMIO interface, but through the GPU command stream. So if my understanding of this series is correct, Etnaviv is just fine with the changed semantics of the unsynchronized map/unmap calls. Regards, Lucas > > Cc: Lucas Stach <l.stach-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> > Cc: Russell King <linux+etnaviv-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org> > Cc: Christian Gmeiner <christian.gmeiner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org> > Cc: etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > --- > drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c > index f103e78..ae0247c 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c > @@ -47,7 +47,7 @@ int etnaviv_iommu_map(struct etnaviv_iommu *iommu, u32 iova, > > VERB("map[%d]: %08x %08x(%zx)", i, iova, pa, bytes); > > - ret = iommu_map(domain, da, pa, bytes, prot); > + ret = iommu_map_sync(domain, da, pa, bytes, prot); > if (ret) > goto fail; > > @@ -62,7 +62,7 @@ int etnaviv_iommu_map(struct etnaviv_iommu *iommu, u32 iova, > for_each_sg(sgt->sgl, sg, i, j) { > size_t bytes = sg_dma_len(sg) + sg->offset; > > - iommu_unmap(domain, da, bytes); > + iommu_unmap_sync(domain, da, bytes); > da += bytes; > } > return ret; > @@ -80,7 +80,7 @@ int etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova, > size_t bytes = sg_dma_len(sg) + sg->offset; > size_t unmapped; > > - unmapped = iommu_unmap(domain, da, bytes); > + unmapped = iommu_unmap_sync(domain, da, bytes); > if (unmapped < bytes) > return unmapped; > > @@ -338,7 +338,7 @@ int etnaviv_iommu_get_suballoc_va(struct etnaviv_gpu *gpu, dma_addr_t paddr, > mutex_unlock(&mmu->lock); > return ret; > } > - ret = iommu_map(mmu->domain, vram_node->start, paddr, size, > + ret = iommu_map_sync(mmu->domain, vram_node->start, paddr, size, > IOMMU_READ); > if (ret < 0) { > drm_mm_remove_node(vram_node); > @@ -362,7 +362,7 @@ void etnaviv_iommu_put_suballoc_va(struct etnaviv_gpu *gpu, > > if (mmu->version == ETNAVIV_IOMMU_V2) { > mutex_lock(&mmu->lock); > - iommu_unmap(mmu->domain,iova, size); > + iommu_unmap_sync(mmu->domain,iova, size); > drm_mm_remove_node(vram_node); > mutex_unlock(&mmu->lock); > } ^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <1502976758.19806.25.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API [not found] ` <1502976758.19806.25.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> @ 2017-08-17 13:45 ` Joerg Roedel 2017-08-17 14:03 ` Lucas Stach 0 siblings, 1 reply; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 13:45 UTC (permalink / raw) To: Lucas Stach Cc: David Airlie, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Christian Gmeiner, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Russell King Hi Lucas, On Thu, Aug 17, 2017 at 03:32:38PM +0200, Lucas Stach wrote: > I don't think this is necessary. Etnaviv has managed and batched up TLB > flushes from day 1, as they don't happen through the MMU MMIO interface, > but through the GPU command stream. > > So if my understanding of this series is correct, Etnaviv is just fine > with the changed semantics of the unsynchronized map/unmap calls. This is not about any TLB on the GPU that could be flushed through the GPU command stream, but about the TLB in the IOMMU device. Or is this actually the same on this hardware? Which IOMMU-driver is use there? Regards, Joerg ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API 2017-08-17 13:45 ` Joerg Roedel @ 2017-08-17 14:03 ` Lucas Stach [not found] ` <1502978634.19806.27.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 0 siblings, 1 reply; 15+ messages in thread From: Lucas Stach @ 2017-08-17 14:03 UTC (permalink / raw) To: Joerg Roedel Cc: Joerg Roedel, iommu, linux-kernel, Suravee Suthikulpanit, Russell King, Christian Gmeiner, David Airlie, etnaviv, dri-devel Am Donnerstag, den 17.08.2017, 15:45 +0200 schrieb Joerg Roedel: > Hi Lucas, > > On Thu, Aug 17, 2017 at 03:32:38PM +0200, Lucas Stach wrote: > > I don't think this is necessary. Etnaviv has managed and batched up TLB > > flushes from day 1, as they don't happen through the MMU MMIO interface, > > but through the GPU command stream. > > > > So if my understanding of this series is correct, Etnaviv is just fine > > with the changed semantics of the unsynchronized map/unmap calls. > > This is not about any TLB on the GPU that could be flushed through the > GPU command stream, but about the TLB in the IOMMU device. Or is this > actually the same on this hardware? Which IOMMU-driver is use there? There is no IOMMU driver in use. Etnaviv just uses part of the IOMMU API to manage the GPU internal MMU, see drivers/gpu/drm/etnaviv/etnaviv_iommu.c Regards, Lucas ^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <1502978634.19806.27.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API [not found] ` <1502978634.19806.27.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> @ 2017-08-17 14:18 ` Joerg Roedel [not found] ` <20170817141858.GG16908-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 14:18 UTC (permalink / raw) To: Lucas Stach Cc: Joerg Roedel, David Airlie, Christian Gmeiner, etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-kernel-u79uwXL29TY76Z2rM5mHXA, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Russell King On Thu, Aug 17, 2017 at 04:03:54PM +0200, Lucas Stach wrote: > There is no IOMMU driver in use. Etnaviv just uses part of the IOMMU API > to manage the GPU internal MMU, see > drivers/gpu/drm/etnaviv/etnaviv_iommu.c That looks like a very fragile construct, because it relies on internal behavior of the iommu code that can change in the future. I strongly suggest to either make etnaviv_iommu.c a real iommu driver an move it to drivers/iommu, or (prefered by me) just call directly into the map/unmap functions of this driver from the rest of the etnaviv_iommu.c. I don't really see a reason why the IOMMU-API needs to be used there as another layer of indirection. Regards, Joerg ^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <20170817141858.GG16908-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API [not found] ` <20170817141858.GG16908-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-08-17 14:30 ` Lucas Stach 2017-08-17 14:35 ` Joerg Roedel 0 siblings, 1 reply; 15+ messages in thread From: Lucas Stach @ 2017-08-17 14:30 UTC (permalink / raw) To: Joerg Roedel Cc: Joerg Roedel, David Airlie, Christian Gmeiner, etnaviv-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-kernel-u79uwXL29TY76Z2rM5mHXA, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Russell King Am Donnerstag, den 17.08.2017, 16:18 +0200 schrieb Joerg Roedel: > On Thu, Aug 17, 2017 at 04:03:54PM +0200, Lucas Stach wrote: > > There is no IOMMU driver in use. Etnaviv just uses part of the IOMMU API > > to manage the GPU internal MMU, see > > drivers/gpu/drm/etnaviv/etnaviv_iommu.c > > That looks like a very fragile construct, because it relies on internal > behavior of the iommu code that can change in the future. > > I strongly suggest to either make etnaviv_iommu.c a real iommu driver an > move it to drivers/iommu, or (prefered by me) just call directly into > the map/unmap functions of this driver from the rest of the > etnaviv_iommu.c. I don't really see a reason why the IOMMU-API needs to > be used there as another layer of indirection. Yeah, the IOMMU API being used internally is a historical accident, that we didn't get around to rectify yet. It's on my things-we-need-to-do list to prune the usage of the IOMMU API in etnaviv. Regards, Lucas ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 06/13] drm/etnaviv: Use sychronized interface of the IOMMU-API 2017-08-17 14:30 ` Lucas Stach @ 2017-08-17 14:35 ` Joerg Roedel 0 siblings, 0 replies; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 14:35 UTC (permalink / raw) To: Lucas Stach Cc: Joerg Roedel, iommu, linux-kernel, Suravee Suthikulpanit, Russell King, Christian Gmeiner, David Airlie, etnaviv, dri-devel On Thu, Aug 17, 2017 at 04:30:48PM +0200, Lucas Stach wrote: > Yeah, the IOMMU API being used internally is a historical accident, that > we didn't get around to rectify yet. It's on my things-we-need-to-do > list to prune the usage of the IOMMU API in etnaviv. Okay, so for the time being, I drop the etnaviv patch from this series. Thanks, Joerg ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 08/13] drm/nouveau/imem/gk20a: Use sychronized interface of the IOMMU-API [not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-08-17 12:56 ` [PATCH 06/13] drm/etnaviv: " Joerg Roedel @ 2017-08-17 12:56 ` Joerg Roedel 2017-08-17 12:56 ` [PATCH 10/13] drm/tegra: " Joerg Roedel 2017-08-17 12:56 ` [PATCH 11/13] gpu: host1x: " Joerg Roedel 3 siblings, 0 replies; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 12:56 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, David Airlie, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Ben Skeggs From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org> Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c index cd5adbe..3f0de47 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c @@ -322,8 +322,9 @@ gk20a_instobj_dtor_iommu(struct nvkm_memory *memory) /* Unmap pages from GPU address space and free them */ for (i = 0; i < node->base.mem.size; i++) { - iommu_unmap(imem->domain, - (r->offset + i) << imem->iommu_pgshift, PAGE_SIZE); + iommu_unmap_sync(imem->domain, + (r->offset + i) << imem->iommu_pgshift, + PAGE_SIZE); dma_unmap_page(dev, node->dma_addrs[i], PAGE_SIZE, DMA_BIDIRECTIONAL); __free_page(node->pages[i]); @@ -458,14 +459,15 @@ gk20a_instobj_ctor_iommu(struct gk20a_instmem *imem, u32 npages, u32 align, for (i = 0; i < npages; i++) { u32 offset = (r->offset + i) << imem->iommu_pgshift; - ret = iommu_map(imem->domain, offset, node->dma_addrs[i], - PAGE_SIZE, IOMMU_READ | IOMMU_WRITE); + ret = iommu_map_sync(imem->domain, offset, node->dma_addrs[i], + PAGE_SIZE, IOMMU_READ | IOMMU_WRITE); if (ret < 0) { nvkm_error(subdev, "IOMMU mapping failure: %d\n", ret); while (i-- > 0) { offset -= PAGE_SIZE; - iommu_unmap(imem->domain, offset, PAGE_SIZE); + iommu_unmap_sync(imem->domain, offset, + PAGE_SIZE); } goto release_area; } -- 2.7.4 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/13] drm/tegra: Use sychronized interface of the IOMMU-API [not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-08-17 12:56 ` [PATCH 06/13] drm/etnaviv: " Joerg Roedel 2017-08-17 12:56 ` [PATCH 08/13] drm/nouveau/imem/gk20a: " Joerg Roedel @ 2017-08-17 12:56 ` Joerg Roedel 2017-08-17 13:28 ` Thierry Reding 2017-08-17 12:56 ` [PATCH 11/13] gpu: host1x: " Joerg Roedel 3 siblings, 1 reply; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 12:56 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, David Airlie, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Jonathan Hunter, Thierry Reding, linux-tegra-u79uwXL29TY76Z2rM5mHXA From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org> Cc: Jonathan Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/gpu/drm/tegra/drm.c | 6 +++--- drivers/gpu/drm/tegra/gem.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 518f4b6..bc4528ee 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1156,8 +1156,8 @@ void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, } *dma = iova_dma_addr(&tegra->carveout.domain, alloc); - err = iommu_map(tegra->domain, *dma, virt_to_phys(virt), - size, IOMMU_READ | IOMMU_WRITE); + err = iommu_map_sync(tegra->domain, *dma, virt_to_phys(virt), + size, IOMMU_READ | IOMMU_WRITE); if (err < 0) goto free_iova; @@ -1180,7 +1180,7 @@ void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt, size = PAGE_ALIGN(size); if (tegra->domain) { - iommu_unmap(tegra->domain, dma, size); + iommu_unmap_sync(tegra->domain, dma, size); free_iova(&tegra->carveout.domain, iova_pfn(&tegra->carveout.domain, dma)); } diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 7a39a35..639bc75 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -135,8 +135,8 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo) bo->paddr = bo->mm->start; - err = iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl, - bo->sgt->nents, prot); + err = iommu_map_sg_sync(tegra->domain, bo->paddr, bo->sgt->sgl, + bo->sgt->nents, prot); if (err < 0) { dev_err(tegra->drm->dev, "failed to map buffer: %zd\n", err); goto remove; @@ -162,7 +162,7 @@ static int tegra_bo_iommu_unmap(struct tegra_drm *tegra, struct tegra_bo *bo) return 0; mutex_lock(&tegra->mm_lock); - iommu_unmap(tegra->domain, bo->paddr, bo->size); + iommu_unmap_sync(tegra->domain, bo->paddr, bo->size); drm_mm_remove_node(bo->mm); mutex_unlock(&tegra->mm_lock); -- 2.7.4 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 10/13] drm/tegra: Use sychronized interface of the IOMMU-API 2017-08-17 12:56 ` [PATCH 10/13] drm/tegra: " Joerg Roedel @ 2017-08-17 13:28 ` Thierry Reding 0 siblings, 0 replies; 15+ messages in thread From: Thierry Reding @ 2017-08-17 13:28 UTC (permalink / raw) To: Joerg Roedel Cc: iommu, linux-kernel, Suravee Suthikulpanit, Joerg Roedel, David Airlie, Jonathan Hunter, dri-devel, linux-tegra [-- Attachment #1: Type: text/plain, Size: 1105 bytes --] On Thu, Aug 17, 2017 at 02:56:33PM +0200, Joerg Roedel wrote: > From: Joerg Roedel <jroedel@suse.de> > > The map and unmap functions of the IOMMU-API changed their > semantics: They do no longer guarantee that the hardware > TLBs are synchronized with the page-table updates they made. > > To make conversion easier, new synchronized functions have > been introduced which give these guarantees again until the > code is converted to use the new TLB-flush interface of the > IOMMU-API, which allows certain optimizations. > > But for now, just convert this code to use the synchronized > functions so that it will behave as before. > > Cc: Thierry Reding <thierry.reding@gmail.com> > Cc: David Airlie <airlied@linux.ie> > Cc: Jonathan Hunter <jonathanh@nvidia.com> > Cc: dri-devel@lists.freedesktop.org > Cc: linux-tegra@vger.kernel.org > Signed-off-by: Joerg Roedel <jroedel@suse.de> > --- > drivers/gpu/drm/tegra/drm.c | 6 +++--- > drivers/gpu/drm/tegra/gem.c | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-) Acked-by: Thierry Reding <treding@nvidia.com> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 11/13] gpu: host1x: Use sychronized interface of the IOMMU-API [not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> ` (2 preceding siblings ...) 2017-08-17 12:56 ` [PATCH 10/13] drm/tegra: " Joerg Roedel @ 2017-08-17 12:56 ` Joerg Roedel [not found] ` <1502974596-23835-12-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 3 siblings, 1 reply; 15+ messages in thread From: Joerg Roedel @ 2017-08-17 12:56 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Thierry Reding, linux-tegra-u79uwXL29TY76Z2rM5mHXA From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/job.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c index 28541b2..bdf557e 100644 --- a/drivers/gpu/host1x/cdma.c +++ b/drivers/gpu/host1x/cdma.c @@ -55,7 +55,7 @@ static void host1x_pushbuffer_destroy(struct push_buffer *pb) return; if (host1x->domain) { - iommu_unmap(host1x->domain, pb->dma, pb->alloc_size); + iommu_unmap_sync(host1x->domain, pb->dma, pb->alloc_size); free_iova(&host1x->iova, iova_pfn(&host1x->iova, pb->dma)); } @@ -105,8 +105,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb) } pb->dma = iova_dma_addr(&host1x->iova, alloc); - err = iommu_map(host1x->domain, pb->dma, pb->phys, size, - IOMMU_READ); + err = iommu_map_sync(host1x->domain, pb->dma, pb->phys, size, + IOMMU_READ); if (err) goto iommu_free_iova; } else { diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c index bee5044..70a029c 100644 --- a/drivers/gpu/host1x/job.c +++ b/drivers/gpu/host1x/job.c @@ -243,7 +243,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job) goto unpin; } - err = iommu_map_sg(host->domain, + err = iommu_map_sg_sync(host->domain, iova_dma_addr(&host->iova, alloc), sgt->sgl, sgt->nents, IOMMU_READ); if (err == 0) { @@ -695,8 +695,8 @@ void host1x_job_unpin(struct host1x_job *job) struct host1x_job_unpin_data *unpin = &job->unpins[i]; if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) { - iommu_unmap(host->domain, job->addr_phys[i], - unpin->size); + iommu_unmap_sync(host->domain, job->addr_phys[i], + unpin->size); free_iova(&host->iova, iova_pfn(&host->iova, job->addr_phys[i])); } -- 2.7.4 ^ permalink raw reply related [flat|nested] 15+ messages in thread
[parent not found: <1502974596-23835-12-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 11/13] gpu: host1x: Use sychronized interface of the IOMMU-API [not found] ` <1502974596-23835-12-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-08-17 13:29 ` Thierry Reding 0 siblings, 0 replies; 15+ messages in thread From: Thierry Reding @ 2017-08-17 13:29 UTC (permalink / raw) To: Joerg Roedel Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Suravee Suthikulpanit, Joerg Roedel, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-tegra-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1169 bytes --] On Thu, Aug 17, 2017 at 02:56:34PM +0200, Joerg Roedel wrote: > From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > > The map and unmap functions of the IOMMU-API changed their > semantics: They do no longer guarantee that the hardware > TLBs are synchronized with the page-table updates they made. > > To make conversion easier, new synchronized functions have > been introduced which give these guarantees again until the > code is converted to use the new TLB-flush interface of the > IOMMU-API, which allows certain optimizations. > > But for now, just convert this code to use the synchronized > functions so that it will behave as before. > > Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > --- > drivers/gpu/host1x/cdma.c | 6 +++--- > drivers/gpu/host1x/job.c | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-) Acked-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-08-19 15:39 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1502974596-23835-1-git-send-email-joro@8bytes.org>
2017-08-17 12:56 ` [PATCH 07/13] drm/msm: Use sychronized interface of the IOMMU-API Joerg Roedel
2017-08-19 15:39 ` Rob Clark
2017-08-17 12:56 ` [PATCH 09/13] drm/rockchip: " Joerg Roedel
[not found] ` <1502974596-23835-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-17 12:56 ` [PATCH 06/13] drm/etnaviv: " Joerg Roedel
[not found] ` <1502974596-23835-7-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-17 13:32 ` Lucas Stach
[not found] ` <1502976758.19806.25.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-08-17 13:45 ` Joerg Roedel
2017-08-17 14:03 ` Lucas Stach
[not found] ` <1502978634.19806.27.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-08-17 14:18 ` Joerg Roedel
[not found] ` <20170817141858.GG16908-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-17 14:30 ` Lucas Stach
2017-08-17 14:35 ` Joerg Roedel
2017-08-17 12:56 ` [PATCH 08/13] drm/nouveau/imem/gk20a: " Joerg Roedel
2017-08-17 12:56 ` [PATCH 10/13] drm/tegra: " Joerg Roedel
2017-08-17 13:28 ` Thierry Reding
2017-08-17 12:56 ` [PATCH 11/13] gpu: host1x: " Joerg Roedel
[not found] ` <1502974596-23835-12-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-17 13:29 ` Thierry Reding
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox