* Re: [PATCH] iommu/dma: Document min_align_mask assumption
2024-03-04 12:05 [PATCH] iommu/dma: Document min_align_mask assumption Robin Murphy
@ 2024-03-04 14:39 ` Petr Tesařík
2024-03-04 15:47 ` Michael Kelley
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Petr Tesařík @ 2024-03-04 14:39 UTC (permalink / raw)
To: Robin Murphy; +Cc: joro, iommu, linux-kernel, will, mhklinux, hch
On Mon, 4 Mar 2024 12:05:42 +0000
Robin Murphy <robin.murphy@arm.com> wrote:
> iommu-dma does not explicitly reference min_align_mask since we already
> assume that that will be less than or equal to any typical IOVA granule.
> We wouldn't realistically expect to see the case where it is larger, and
> that would be non-trivial to support, however for the sake of reasoning
> (particularly around the interaction with SWIOTLB), let's clearly
> enforce the assumption.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Looks good to me.
Reviewed-by: Petr Tesarik <petr.tesarik1@huawei-partners.com>
Thank you!
Petr T
> ---
> drivers/iommu/dma-iommu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 50ccc4f1ef81..b58f5a3311c3 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -859,6 +859,11 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
> iommu_deferred_attach(dev, domain))
> return DMA_MAPPING_ERROR;
>
> + /* If anyone ever wants this we'd need support in the IOVA allocator */
> + if (dev_WARN_ONCE(dev, dma_get_min_align_mask(dev) > iova_mask(iovad),
> + "Unsupported alignment constraint\n"))
> + return DMA_MAPPING_ERROR;
> +
> size = iova_align(iovad, size + iova_off);
>
> iova = iommu_dma_alloc_iova(domain, size, dma_mask, dev);
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH] iommu/dma: Document min_align_mask assumption
2024-03-04 12:05 [PATCH] iommu/dma: Document min_align_mask assumption Robin Murphy
2024-03-04 14:39 ` Petr Tesařík
@ 2024-03-04 15:47 ` Michael Kelley
2024-03-05 13:46 ` Christoph Hellwig
2024-03-06 16:40 ` Joerg Roedel
3 siblings, 0 replies; 5+ messages in thread
From: Michael Kelley @ 2024-03-04 15:47 UTC (permalink / raw)
To: Robin Murphy, joro@8bytes.org
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
will@kernel.org, petr@tesarici.cz, hch@lst.de
From: Robin Murphy <robin.murphy@arm.com> Sent: Monday, March 4, 2024 4:06 AM
>
> iommu-dma does not explicitly reference min_align_mask since we already
> assume that that will be less than or equal to any typical IOVA granule.
> We wouldn't realistically expect to see the case where it is larger, and
> that would be non-trivial to support, however for the sake of reasoning
> (particularly around the interaction with SWIOTLB), let's clearly
> enforce the assumption.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/dma-iommu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 50ccc4f1ef81..b58f5a3311c3 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -859,6 +859,11 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
> iommu_deferred_attach(dev, domain))
> return DMA_MAPPING_ERROR;
>
> + /* If anyone ever wants this we'd need support in the IOVA allocator */
> + if (dev_WARN_ONCE(dev, dma_get_min_align_mask(dev) > iova_mask(iovad),
> + "Unsupported alignment constraint\n"))
> + return DMA_MAPPING_ERROR;
> +
> size = iova_align(iovad, size + iova_off);
>
> iova = iommu_dma_alloc_iova(domain, size, dma_mask, dev);
> --
> 2.39.2.101.g768bb238c484.dirty
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/dma: Document min_align_mask assumption
2024-03-04 12:05 [PATCH] iommu/dma: Document min_align_mask assumption Robin Murphy
2024-03-04 14:39 ` Petr Tesařík
2024-03-04 15:47 ` Michael Kelley
@ 2024-03-05 13:46 ` Christoph Hellwig
2024-03-06 16:40 ` Joerg Roedel
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-03-05 13:46 UTC (permalink / raw)
To: Robin Murphy; +Cc: joro, iommu, linux-kernel, will, mhklinux, petr, hch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/dma: Document min_align_mask assumption
2024-03-04 12:05 [PATCH] iommu/dma: Document min_align_mask assumption Robin Murphy
` (2 preceding siblings ...)
2024-03-05 13:46 ` Christoph Hellwig
@ 2024-03-06 16:40 ` Joerg Roedel
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2024-03-06 16:40 UTC (permalink / raw)
To: Robin Murphy; +Cc: iommu, linux-kernel, will, mhklinux, petr, hch
On Mon, Mar 04, 2024 at 12:05:42PM +0000, Robin Murphy wrote:
> iommu-dma does not explicitly reference min_align_mask since we already
> assume that that will be less than or equal to any typical IOVA granule.
> We wouldn't realistically expect to see the case where it is larger, and
> that would be non-trivial to support, however for the sake of reasoning
> (particularly around the interaction with SWIOTLB), let's clearly
> enforce the assumption.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/dma-iommu.c | 5 +++++
> 1 file changed, 5 insertions(+)
Applied, thanks Robin.
^ permalink raw reply [flat|nested] 5+ messages in thread