diff mbox series

[4.19.y,02/29] iommu/ipmmu-vmsa: Modify ipmmu_slave_whitelist() to check SoC revisions

Message ID 1556706143-11898-3-git-send-email-fabrizio.castro@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series Add further support for the RZ/G2M | expand

Commit Message

Fabrizio Castro May 1, 2019, 10:21 a.m. UTC
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

commit b7ee92c6ff0e023a473b2500d771f6bf504fcc1a upstream.

Some R-Car Gen3 SoCs has hardware restrictions on the IPMMU. So,
to check whether this R-Car Gen3 SoC can use the IPMMU correctly,
this patch modifies the ipmmu_slave_whitelist().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
---
 drivers/iommu/ipmmu-vmsa.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

Comments

Pavel Machek May 2, 2019, 9:27 p.m. UTC | #1
Hi!

> commit b7ee92c6ff0e023a473b2500d771f6bf504fcc1a upstream.
> 
> Some R-Car Gen3 SoCs has hardware restrictions on the IPMMU. So,
> to check whether this R-Car Gen3 SoC can use the IPMMU correctly,
> this patch modifies the ipmmu_slave_whitelist().
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
> ---
>  drivers/iommu/ipmmu-vmsa.c | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 

>  static int ipmmu_of_xlate(struct device *dev,
>  			  struct of_phandle_args *spec)
>  {
> -	/* For R-Car Gen3 use a white list to opt-in slave devices */
> -	if (soc_device_match(soc_rcar_gen3) && !ipmmu_slave_whitelist(dev))
> +	if (!ipmmu_slave_whitelist(dev))
>  		return -ENODEV;
>  

I just want to make sure "soc_device_match(soc_rcar_gen3) &&" deletion
is intentional here...
									Pavel
Fabrizio Castro May 3, 2019, 9:34 a.m. UTC | #2
Hello Pavel,

Thank you for your feedback!

> From: Pavel Machek <pavel@denx.de>
> Sent: 02 May 2019 22:28
> Subject: Re: [cip-dev] [PATCH 4.19.y 02/29] iommu/ipmmu-vmsa: Modify ipmmu_slave_whitelist() to check SoC revisions
> 
> Hi!
> 
> > commit b7ee92c6ff0e023a473b2500d771f6bf504fcc1a upstream.
> >
> > Some R-Car Gen3 SoCs has hardware restrictions on the IPMMU. So,
> > to check whether this R-Car Gen3 SoC can use the IPMMU correctly,
> > this patch modifies the ipmmu_slave_whitelist().
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
> > Signed-off-by: Joerg Roedel <jroedel@suse.de>
> > Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
> > ---
> >  drivers/iommu/ipmmu-vmsa.c | 34 ++++++++++++++++++++++++++--------
> >  1 file changed, 26 insertions(+), 8 deletions(-)
> >
> 
> >  static int ipmmu_of_xlate(struct device *dev,
> >  			  struct of_phandle_args *spec)
> >  {
> > -	/* For R-Car Gen3 use a white list to opt-in slave devices */
> > -	if (soc_device_match(soc_rcar_gen3) && !ipmmu_slave_whitelist(dev))
> > +	if (!ipmmu_slave_whitelist(dev))
> >  		return -ENODEV;
> >
> 
> I just want to make sure "soc_device_match(soc_rcar_gen3) &&" deletion
> is intentional here...

It is. I wasn't sure about backporting patch 807596491d33d016e420d217cf1350aef2d2b3f7,
but It didn't seem to add any value, what's your take on that?

Thanks,
Fab

> 									Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Nobuhiro Iwamatsu May 7, 2019, 2:11 a.m. UTC | #3
Hi,

On Fri, 3 May 2019 09:34:56 +0000
Fabrizio Castro <fabrizio.castro@bp.renesas.com> wrote:

> Hello Pavel,
> 
> Thank you for your feedback!
> 
> > From: Pavel Machek <pavel@denx.de>
> > Sent: 02 May 2019 22:28
> > Subject: Re: [cip-dev] [PATCH 4.19.y 02/29] iommu/ipmmu-vmsa:
> > Modify ipmmu_slave_whitelist() to check SoC revisions
> > 
> > Hi!
> >   
> > > commit b7ee92c6ff0e023a473b2500d771f6bf504fcc1a upstream.
> > >
> > > Some R-Car Gen3 SoCs has hardware restrictions on the IPMMU. So,
> > > to check whether this R-Car Gen3 SoC can use the IPMMU correctly,
> > > this patch modifies the ipmmu_slave_whitelist().
> > >
> > > Signed-off-by: Yoshihiro Shimoda
> > > <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Geert
> > > Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Simon Horman
> > > <horms+renesas@verge.net.au> Signed-off-by: Joerg Roedel
> > > <jroedel@suse.de> Signed-off-by: Fabrizio Castro
> > > <fabrizio.castro@bp.renesas.com> ---
> > >  drivers/iommu/ipmmu-vmsa.c | 34
> > > ++++++++++++++++++++++++++-------- 1 file changed, 26
> > > insertions(+), 8 deletions(-) 
> >   
> > >  static int ipmmu_of_xlate(struct device *dev,
> > >  			  struct of_phandle_args *spec)
> > >  {
> > > -	/* For R-Car Gen3 use a white list to opt-in slave
> > > devices */
> > > -	if (soc_device_match(soc_rcar_gen3)
> > > && !ipmmu_slave_whitelist(dev))
> > > +	if (!ipmmu_slave_whitelist(dev))
> > >  		return -ENODEV;
> > >  
> > 
> > I just want to make sure "soc_device_match(soc_rcar_gen3) &&"
> > deletion is intentional here...  
> 
> It is. I wasn't sure about backporting patch
> 807596491d33d016e420d217cf1350aef2d2b3f7, but It didn't seem to add
> any value, what's your take on that?

As you wrote, there are no changes that have an impact.
But these these commits are like a set If I look at the content eatch commit.

Best regards,
  Nobuhiro
diff mbox series

Patch

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index b3bffd7..acb46cc 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -757,12 +757,6 @@  static int ipmmu_init_platform_device(struct device *dev,
 	return 0;
 }
 
-static bool ipmmu_slave_whitelist(struct device *dev)
-{
-	/* By default, do not allow use of IPMMU */
-	return false;
-}
-
 static const struct soc_device_attribute soc_rcar_gen3[] = {
 	{ .soc_id = "r8a774a1", },
 	{ .soc_id = "r8a7795", },
@@ -773,11 +767,35 @@  static const struct soc_device_attribute soc_rcar_gen3[] = {
 	{ /* sentinel */ }
 };
 
+static const struct soc_device_attribute soc_rcar_gen3_whitelist[] = {
+	{ .soc_id = "r8a7795", .revision = "ES3.*" },
+	{ .soc_id = "r8a77965", },
+	{ .soc_id = "r8a77990", },
+	{ .soc_id = "r8a77995", },
+	{ /* sentinel */ }
+};
+
+static bool ipmmu_slave_whitelist(struct device *dev)
+{
+	/*
+	 * For R-Car Gen3 use a white list to opt-in slave devices.
+	 * For Other SoCs, this returns true anyway.
+	 */
+	if (!soc_device_match(soc_rcar_gen3))
+		return true;
+
+	/* Check whether this R-Car Gen3 can use the IPMMU correctly or not */
+	if (!soc_device_match(soc_rcar_gen3_whitelist))
+		return false;
+
+	/* By default, do not allow use of IPMMU */
+	return false;
+}
+
 static int ipmmu_of_xlate(struct device *dev,
 			  struct of_phandle_args *spec)
 {
-	/* For R-Car Gen3 use a white list to opt-in slave devices */
-	if (soc_device_match(soc_rcar_gen3) && !ipmmu_slave_whitelist(dev))
+	if (!ipmmu_slave_whitelist(dev))
 		return -ENODEV;
 
 	iommu_fwspec_add_ids(dev, spec->args, 1);