diff mbox series

[PATCH/RFC,01/09] iommu/ipmmu-vmsa: Disable IPMMU when address expansion is not needed

Message ID 155067455863.15971.400236990712480655.sendpatchset@octo (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series IPMMU address translation enablement prototype | expand

Commit Message

Magnus Damm Feb. 20, 2019, 2:55 p.m. UTC
From: Magnus Damm <damm+renesas@opensource.se>

Add a memory bank location check to the whitelist handling.

Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
---

 drivers/iommu/ipmmu-vmsa.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Geert Uytterhoeven Feb. 20, 2019, 4:09 p.m. UTC | #1
Hi Magnus,

On Wed, Feb 20, 2019 at 3:55 PM Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm+renesas@opensource.se>
>
> Add a memory bank location check to the whitelist handling.
>
> Signed-off-by: Magnus Damm <damm+renesas@opensource.se>

Thanks for your patch!

> --- 0001/drivers/iommu/ipmmu-vmsa.c
> +++ work/drivers/iommu/ipmmu-vmsa.c     2019-02-20 22:59:28.589893396 +0900

> @@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(struct
>         if (!soc_device_match(soc_rcar_gen3_whitelist))
>                 return false;
>
> +       /* In case all system memory fits within 32 bits of physical space
> +        * then assume the IPMMU will not be needed for address expansion.
> +        */
> +       if (memblock_end_of_DRAM() <= SZ_4G)

Can this give a compiler warning on arm32 when CONFIG_ARM_LPAE=n?

> +               return false;
> +
>         /* Check whether this slave device can work with the IPMMU */
>         for (i = 0; i < ARRAY_SIZE(rcar_gen3_slave_whitelist); i++) {
>                 if (!strcmp(dev_name(dev), rcar_gen3_slave_whitelist[i]))

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
Magnus Damm March 19, 2019, 1:45 p.m. UTC | #2
Hi Geert,
On Thu, Feb 21, 2019 at 1:10 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Magnus,
>
> On Wed, Feb 20, 2019 at 3:55 PM Magnus Damm <magnus.damm@gmail.com> wrote:
> > From: Magnus Damm <damm+renesas@opensource.se>
> >
> > Add a memory bank location check to the whitelist handling.
> >
> > Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
>
> Thanks for your patch!

Thanks for feedback!

> > --- 0001/drivers/iommu/ipmmu-vmsa.c
> > +++ work/drivers/iommu/ipmmu-vmsa.c     2019-02-20 22:59:28.589893396 +0900
>
> > @@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(struct
> >         if (!soc_device_match(soc_rcar_gen3_whitelist))
> >                 return false;
> >
> > +       /* In case all system memory fits within 32 bits of physical space
> > +        * then assume the IPMMU will not be needed for address expansion.
> > +        */
> > +       if (memblock_end_of_DRAM() <= SZ_4G)
>
> Can this give a compiler warning on arm32 when CONFIG_ARM_LPAE=n?

Not sure how, can you elaborate?

To test this I actually installed a new arm32 compiler but I failed to
trigger any warnings.

Thanks,

/ magnus
Geert Uytterhoeven March 19, 2019, 2:07 p.m. UTC | #3
Hi Magnus,

On Tue, Mar 19, 2019 at 2:45 PM Magnus Damm <magnus.damm@gmail.com> wrote:
> On Thu, Feb 21, 2019 at 1:10 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Wed, Feb 20, 2019 at 3:55 PM Magnus Damm <magnus.damm@gmail.com> wrote:
> > > --- 0001/drivers/iommu/ipmmu-vmsa.c
> > > +++ work/drivers/iommu/ipmmu-vmsa.c     2019-02-20 22:59:28.589893396 +0900
> >
> > > @@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(struct
> > >         if (!soc_device_match(soc_rcar_gen3_whitelist))
> > >                 return false;
> > >
> > > +       /* In case all system memory fits within 32 bits of physical space
> > > +        * then assume the IPMMU will not be needed for address expansion.
> > > +        */
> > > +       if (memblock_end_of_DRAM() <= SZ_4G)
> >
> > Can this give a compiler warning on arm32 when CONFIG_ARM_LPAE=n?
>
> Not sure how, can you elaborate?

SZ_4G is 0x100000000ULL, which is always 64-bit.
memblock_end_of_DRAM() returns a physaddr_t, which is 32-bit if
CONFIG_ARM_LPAE=n, in which case the comparison is always true.

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

--- 0001/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c	2019-02-20 22:59:28.589893396 +0900
@@ -17,6 +17,7 @@ 
 #include <linux/io.h>
 #include <linux/io-pgtable.h>
 #include <linux/iommu.h>
+#include <linux/memblock.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_iommu.h>
@@ -797,6 +798,12 @@  static bool ipmmu_slave_whitelist(struct
 	if (!soc_device_match(soc_rcar_gen3_whitelist))
 		return false;
 
+	/* In case all system memory fits within 32 bits of physical space
+	 * then assume the IPMMU will not be needed for address expansion.
+	 */
+	if (memblock_end_of_DRAM() <= SZ_4G)
+		return false;
+	
 	/* Check whether this slave device can work with the IPMMU */
 	for (i = 0; i < ARRAY_SIZE(rcar_gen3_slave_whitelist); i++) {
 		if (!strcmp(dev_name(dev), rcar_gen3_slave_whitelist[i]))