Message ID | 1561020610-953-3-git-send-email-yoshihiro.shimoda.uh@renesas.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | treewide: improve R-Car SDHI performance | expand |
Hi, On 2019-06-20 10:50, Yoshihiro Shimoda wrote: > This patch adds a new dma_map_ops of get_merge_boundary() to > expose the DMA merge boundary if the domain type is IOMMU_DOMAIN_DMA. > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> > --- > drivers/iommu/dma-iommu.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 205d694..9950cb5 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -1091,6 +1091,16 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt, > return ret; > } > > +static unsigned long iommu_dma_get_merge_boundary(struct device *dev) > +{ > + struct iommu_domain *domain = iommu_get_dma_domain(dev); > + > + if (domain->type != IOMMU_DOMAIN_DMA) > + return 0; /* can't merge */ > + > + return (1 << __ffs(domain->pgsize_bitmap)) - 1; > +} I really wonder if there is any IOMMU, which doesn't support 4KiB pages. Cannot you simply assume that the merge boundary is 4KiB and avoid adding this new API? > + > static const struct dma_map_ops iommu_dma_ops = { > .alloc = iommu_dma_alloc, > .free = iommu_dma_free, > @@ -1106,6 +1116,7 @@ static const struct dma_map_ops iommu_dma_ops = { > .sync_sg_for_device = iommu_dma_sync_sg_for_device, > .map_resource = iommu_dma_map_resource, > .unmap_resource = iommu_dma_unmap_resource, > + .get_merge_boundary = iommu_dma_get_merge_boundary, > }; > > /* Best regards
On Fri, Jun 21, 2019 at 09:59:21AM +0200, Marek Szyprowski wrote: > Hi, > > On 2019-06-20 10:50, Yoshihiro Shimoda wrote: > > This patch adds a new dma_map_ops of get_merge_boundary() to > > expose the DMA merge boundary if the domain type is IOMMU_DOMAIN_DMA. > > > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> > > --- > > drivers/iommu/dma-iommu.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > > index 205d694..9950cb5 100644 > > --- a/drivers/iommu/dma-iommu.c > > +++ b/drivers/iommu/dma-iommu.c > > @@ -1091,6 +1091,16 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt, > > return ret; > > } > > > > +static unsigned long iommu_dma_get_merge_boundary(struct device *dev) > > +{ > > + struct iommu_domain *domain = iommu_get_dma_domain(dev); > > + > > + if (domain->type != IOMMU_DOMAIN_DMA) > > + return 0; /* can't merge */ > > + > > + return (1 << __ffs(domain->pgsize_bitmap)) - 1; > > +} > > I really wonder if there is any IOMMU, which doesn't support 4KiB pages. > Cannot you simply assume that the merge boundary is 4KiB and avoid > adding this new API? No idea if we have one, but I would not be surprised if one shows up on a system only built to run with 64k pages for example. Either way the abstraction seems light and self-explanatory, so I see now reason not to have it even if we assume it would always return 4k, especially as we'd also still need a flag at the dma_map_ops level to indicate if segement merging is supported at all.
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 205d694..9950cb5 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1091,6 +1091,16 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt, return ret; } +static unsigned long iommu_dma_get_merge_boundary(struct device *dev) +{ + struct iommu_domain *domain = iommu_get_dma_domain(dev); + + if (domain->type != IOMMU_DOMAIN_DMA) + return 0; /* can't merge */ + + return (1 << __ffs(domain->pgsize_bitmap)) - 1; +} + static const struct dma_map_ops iommu_dma_ops = { .alloc = iommu_dma_alloc, .free = iommu_dma_free, @@ -1106,6 +1116,7 @@ static const struct dma_map_ops iommu_dma_ops = { .sync_sg_for_device = iommu_dma_sync_sg_for_device, .map_resource = iommu_dma_map_resource, .unmap_resource = iommu_dma_unmap_resource, + .get_merge_boundary = iommu_dma_get_merge_boundary, }; /*
This patch adds a new dma_map_ops of get_merge_boundary() to expose the DMA merge boundary if the domain type is IOMMU_DOMAIN_DMA. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- drivers/iommu/dma-iommu.c | 11 +++++++++++ 1 file changed, 11 insertions(+)