* [PATCH v4] iommu/ipmmu-vmsa: Allow PCIe devices
@ 2023-07-28 1:46 Yoshihiro Shimoda
2023-07-28 7:33 ` Geert Uytterhoeven
2023-08-07 12:38 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Yoshihiro Shimoda @ 2023-07-28 1:46 UTC (permalink / raw)
To: joro, will, robin.murphy; +Cc: iommu, linux-renesas-soc, Yoshihiro Shimoda
IPMMU hardware on R-Car Gen3 and RZ/G2 is simple. Each bus-master
device like eMMC host and PCIe controllers has a micro-TLB of
The IPMMU, and after enabled it, all transactions of the device are
under the IPMMU.
eMMC host ---(micro-TLB of eMMC)--- IPMMU cache --- IPMMU main
PCIe --------(micro-TLB of PCIe)--- IPMMU cache --- IPMMU main
Now this IPMMU driver allows eMMC host, and it is safe to use
the IPMMU. So, we can assume that it is safe to use the IPMMU
from PCIe devices too, because all PCIe devices transactions will
go to the micro-TLB of PCIe. So, add a new condition whether
the device is a PCIe device or not in the ipmmu_device_is_allowed()
which will be called if the PCIe host controller has iommu-map
property.
This can improve CPU load because the PCIe controllers only have
a capability for lower 32-bit memory area so that this can avoid
using swiotlb.
Note that IPMMU on R-Car Gen4 is different than R-Car Gen3 and
RZ/G2's one, especially OS-ID. But, for now, the IPMMU driver
takes care of OS-ID 0 only. In other words, all PCIe devices will
go to the micro-TLB of PCIe.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
Changes from v3:
https://lore.kernel.org/all/20230529063928.1030014-1-yoshihiro.shimoda.uh@renesas.com/
- Rebase the latest iommu/next branch.
Changes from v2:
https://lore.kernel.org/all/20230426082511.3621484-1-yoshihiro.shimoda.uh@renesas.com/
- Add descriptions why it is safe to add PCIe devices and why
this is needed.
drivers/iommu/ipmmu-vmsa.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 9f64c5c9f5b9..6efc99382edb 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -19,6 +19,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
+#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/sizes.h>
#include <linux/slab.h>
@@ -723,6 +724,10 @@ static bool ipmmu_device_is_allowed(struct device *dev)
if (soc_device_match(soc_denylist))
return false;
+ /* Check whether this device is a PCI device */
+ if (dev_is_pci(dev))
+ return true;
+
/* Check whether this device can work with the IPMMU */
for (i = 0; i < ARRAY_SIZE(devices_allowlist); i++) {
if (!strcmp(dev_name(dev), devices_allowlist[i]))
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] iommu/ipmmu-vmsa: Allow PCIe devices
2023-07-28 1:46 [PATCH v4] iommu/ipmmu-vmsa: Allow PCIe devices Yoshihiro Shimoda
@ 2023-07-28 7:33 ` Geert Uytterhoeven
2023-08-07 12:38 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2023-07-28 7:33 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: joro, will, robin.murphy, iommu, linux-renesas-soc
On Fri, Jul 28, 2023 at 4:40 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> IPMMU hardware on R-Car Gen3 and RZ/G2 is simple. Each bus-master
> device like eMMC host and PCIe controllers has a micro-TLB of
> The IPMMU, and after enabled it, all transactions of the device are
> under the IPMMU.
>
> eMMC host ---(micro-TLB of eMMC)--- IPMMU cache --- IPMMU main
> PCIe --------(micro-TLB of PCIe)--- IPMMU cache --- IPMMU main
>
> Now this IPMMU driver allows eMMC host, and it is safe to use
> the IPMMU. So, we can assume that it is safe to use the IPMMU
> from PCIe devices too, because all PCIe devices transactions will
> go to the micro-TLB of PCIe. So, add a new condition whether
> the device is a PCIe device or not in the ipmmu_device_is_allowed()
> which will be called if the PCIe host controller has iommu-map
> property.
>
> This can improve CPU load because the PCIe controllers only have
> a capability for lower 32-bit memory area so that this can avoid
> using swiotlb.
>
> Note that IPMMU on R-Car Gen4 is different than R-Car Gen3 and
> RZ/G2's one, especially OS-ID. But, for now, the IPMMU driver
> takes care of OS-ID 0 only. In other words, all PCIe devices will
> go to the micro-TLB of PCIe.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> Changes from v3:
> https://lore.kernel.org/all/20230529063928.1030014-1-yoshihiro.shimoda.uh@renesas.com/
> - Rebase the latest iommu/next branch.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] iommu/ipmmu-vmsa: Allow PCIe devices
2023-07-28 1:46 [PATCH v4] iommu/ipmmu-vmsa: Allow PCIe devices Yoshihiro Shimoda
2023-07-28 7:33 ` Geert Uytterhoeven
@ 2023-08-07 12:38 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2023-08-07 12:38 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: will, robin.murphy, iommu, linux-renesas-soc
On Fri, Jul 28, 2023 at 10:46:59AM +0900, Yoshihiro Shimoda wrote:
> drivers/iommu/ipmmu-vmsa.c | 5 +++++
> 1 file changed, 5 insertions(+)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-07 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 1:46 [PATCH v4] iommu/ipmmu-vmsa: Allow PCIe devices Yoshihiro Shimoda
2023-07-28 7:33 ` Geert Uytterhoeven
2023-08-07 12:38 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox