* [PATCH v3] iommu: map reserved memory as cacheable if device is coherent
@ 2023-09-26 15:26 Laurentiu Tudor
2023-11-15 11:01 ` Laurentiu Tudor
2023-11-27 9:23 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Laurentiu Tudor @ 2023-09-26 15:26 UTC (permalink / raw)
To: joro, will, robin.murphy, treding, jgg, iommu, linux-kernel
Cc: Laurentiu Tudor
Check if the device is marked as DMA coherent in the DT and if so,
map its reserved memory as cacheable in the IOMMU.
This fixes the recently added IOMMU reserved memory support which
uses IOMMU_RESV_DIRECT without properly building the PROT for the
mapping.
Fixes: a5bf3cfce8cb ("iommu: Implement of_iommu_get_resv_regions()")
Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
---
Changes in v3:
- added Acked-by tag (Thierry)
Changes in v2:
- added Reviewed-by tag (Jason)
drivers/iommu/of_iommu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index 157b286e36bf..5b3631ba5a45 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
phys_addr_t iova;
size_t length;
+ if (of_dma_is_coherent(dev->of_node))
+ prot |= IOMMU_CACHE;
+
maps = of_translate_dma_region(np, maps, &iova, &length);
type = iommu_resv_region_get_type(dev, &phys, iova, length);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] iommu: map reserved memory as cacheable if device is coherent
2023-09-26 15:26 [PATCH v3] iommu: map reserved memory as cacheable if device is coherent Laurentiu Tudor
@ 2023-11-15 11:01 ` Laurentiu Tudor
2023-11-27 9:23 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Laurentiu Tudor @ 2023-11-15 11:01 UTC (permalink / raw)
To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
treding@nvidia.com, jgg@nvidia.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org
Hello,
Any chance of having this picked up? It is the last missing bit to fix
booting vanilla images on some NXP platforms (Layerscape LX2160A,
LS2088A, LS1088A) given that the bootloader side of things [1] was accepted.
Thank you!
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=375154&state=*
---
Best Regards, Laurentiu
On 9/26/2023 6:26 PM, Laurentiu Tudor wrote:
> Check if the device is marked as DMA coherent in the DT and if so,
> map its reserved memory as cacheable in the IOMMU.
> This fixes the recently added IOMMU reserved memory support which
> uses IOMMU_RESV_DIRECT without properly building the PROT for the
> mapping.
>
> Fixes: a5bf3cfce8cb ("iommu: Implement of_iommu_get_resv_regions()")
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Acked-by: Thierry Reding <treding@nvidia.com>
> ---
> Changes in v3:
> - added Acked-by tag (Thierry)
>
> Changes in v2:
> - added Reviewed-by tag (Jason)
>
> drivers/iommu/of_iommu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
> index 157b286e36bf..5b3631ba5a45 100644
> --- a/drivers/iommu/of_iommu.c
> +++ b/drivers/iommu/of_iommu.c
> @@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
> phys_addr_t iova;
> size_t length;
>
> + if (of_dma_is_coherent(dev->of_node))
> + prot |= IOMMU_CACHE;
> +
> maps = of_translate_dma_region(np, maps, &iova, &length);
> type = iommu_resv_region_get_type(dev, &phys, iova, length);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] iommu: map reserved memory as cacheable if device is coherent
2023-09-26 15:26 [PATCH v3] iommu: map reserved memory as cacheable if device is coherent Laurentiu Tudor
2023-11-15 11:01 ` Laurentiu Tudor
@ 2023-11-27 9:23 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2023-11-27 9:23 UTC (permalink / raw)
To: Laurentiu Tudor; +Cc: will, robin.murphy, treding, jgg, iommu, linux-kernel
On Tue, Sep 26, 2023 at 06:26:00PM +0300, Laurentiu Tudor wrote:
> drivers/iommu/of_iommu.c | 3 +++
> 1 file changed, 3 insertions(+)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-27 9:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-26 15:26 [PATCH v3] iommu: map reserved memory as cacheable if device is coherent Laurentiu Tudor
2023-11-15 11:01 ` Laurentiu Tudor
2023-11-27 9:23 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox