* [RFC PATCH] iommu: map reserved memory as cacheable if device is coherent
@ 2023-07-25 14:00 laurentiu.tudor
2023-07-26 12:22 ` Jason Gunthorpe
0 siblings, 1 reply; 4+ messages in thread
From: laurentiu.tudor @ 2023-07-25 14:00 UTC (permalink / raw)
To: thierry.reding, robin.murphy, iommu, linux-arm-kernel; +Cc: Laurentiu Tudor
From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Check if the device is marked as DMA coherent in the DT and if so,
map its reserved memory as cacheable in the IOMMU.
Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
---
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 40f57d293a79..ccb912049b88 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] 4+ messages in thread
* Re: [RFC PATCH] iommu: map reserved memory as cacheable if device is coherent
2023-07-25 14:00 [RFC PATCH] iommu: map reserved memory as cacheable if device is coherent laurentiu.tudor
@ 2023-07-26 12:22 ` Jason Gunthorpe
2023-07-26 12:29 ` Laurentiu Tudor
0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2023-07-26 12:22 UTC (permalink / raw)
To: laurentiu.tudor; +Cc: thierry.reding, robin.murphy, iommu, linux-arm-kernel
On Tue, Jul 25, 2023 at 05:00:55PM +0300, laurentiu.tudor@nxp.com wrote:
> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>
> Check if the device is marked as DMA coherent in the DT and if so,
> map its reserved memory as cacheable in the IOMMU.
>
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> ---
> drivers/iommu/of_iommu.c | 3 +++
> 1 file changed, 3 insertions(+)
This only makes sense for IOMMU_RESV_DIRECT - is that your use case?
Maybe mention that in the commit message
And add a fixes for the commit that introduces IOMMU_RESV_DIRECT into
of_iommu.c
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] iommu: map reserved memory as cacheable if device is coherent
2023-07-26 12:22 ` Jason Gunthorpe
@ 2023-07-26 12:29 ` Laurentiu Tudor
2023-07-26 12:32 ` Jason Gunthorpe
0 siblings, 1 reply; 4+ messages in thread
From: Laurentiu Tudor @ 2023-07-26 12:29 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: thierry.reding, robin.murphy, iommu, linux-arm-kernel
On 7/26/2023 3:22 PM, Jason Gunthorpe wrote:
> On Tue, Jul 25, 2023 at 05:00:55PM +0300, laurentiu.tudor@nxp.com wrote:
>> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>>
>> Check if the device is marked as DMA coherent in the DT and if so,
>> map its reserved memory as cacheable in the IOMMU.
>>
>> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>> ---
>> drivers/iommu/of_iommu.c | 3 +++
>> 1 file changed, 3 insertions(+)
>
> This only makes sense for IOMMU_RESV_DIRECT - is that your use case?
> Maybe mention that in the commit message
Yep. Will respin with an improved commit message.
> And add a fixes for the commit that introduces IOMMU_RESV_DIRECT into
> of_iommu.c
Would it make more sense to mention the commit [1] that actually added
this support for mapping reserved memory in IOMMU?
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a5bf3cfce8cb77d9d24613ab52d520896f83dd48
---
Thanks & Best Regards, Laurentiu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] iommu: map reserved memory as cacheable if device is coherent
2023-07-26 12:29 ` Laurentiu Tudor
@ 2023-07-26 12:32 ` Jason Gunthorpe
0 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2023-07-26 12:32 UTC (permalink / raw)
To: Laurentiu Tudor; +Cc: thierry.reding, robin.murphy, iommu, linux-arm-kernel
On Wed, Jul 26, 2023 at 03:29:47PM +0300, Laurentiu Tudor wrote:
>
>
> On 7/26/2023 3:22 PM, Jason Gunthorpe wrote:
> > On Tue, Jul 25, 2023 at 05:00:55PM +0300, laurentiu.tudor@nxp.com wrote:
> > > From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> > >
> > > Check if the device is marked as DMA coherent in the DT and if so,
> > > map its reserved memory as cacheable in the IOMMU.
> > >
> > > Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> > > ---
> > > drivers/iommu/of_iommu.c | 3 +++
> > > 1 file changed, 3 insertions(+)
> >
> > This only makes sense for IOMMU_RESV_DIRECT - is that your use case?
> > Maybe mention that in the commit message
>
> Yep. Will respin with an improved commit message.
>
> > And add a fixes for the commit that introduces IOMMU_RESV_DIRECT into
> > of_iommu.c
>
> Would it make more sense to mention the commit [1] that actually added this
> support for mapping reserved memory in IOMMU?
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a5bf3cfce8cb77d9d24613ab52d520896f83dd48
Yes, that should be marked Fixes: - it added IOMMU_RESV_DIRECT without
forming the PROT properly
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-26 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-25 14:00 [RFC PATCH] iommu: map reserved memory as cacheable if device is coherent laurentiu.tudor
2023-07-26 12:22 ` Jason Gunthorpe
2023-07-26 12:29 ` Laurentiu Tudor
2023-07-26 12:32 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox