Re: [RFC v1 PATCH 1/3] drivers: soc: add support for soc_device_match returning -EPROBE_DEFER

2021-04-20 Thread Dan Carpenter
On Mon, Apr 19, 2021 at 10:20:13AM +0200, Geert Uytterhoeven wrote:
> Hi Alice,
> 
> CC Arnd (soc_device_match() author)
> 
> On Mon, Apr 19, 2021 at 6:28 AM Alice Guo (OSS)  wrote:
> > From: Alice Guo 
> >
> > In i.MX8M boards, the registration of SoC device is later than caam
> > driver which needs it. Caam driver needs soc_device_match to provide
> > -EPROBE_DEFER when no SoC device is registered and no
> > early_soc_dev_attr.
> 
> I'm wondering if this is really a good idea: soc_device_match() is a
> last-resort low-level check, and IMHO should be made available early on,
> so there is no need for -EPROBE_DEFER.
> 
> >
> > Signed-off-by: Alice Guo 
> 
> Thanks for your patch!
> 
> > --- a/drivers/base/soc.c
> > +++ b/drivers/base/soc.c
> > @@ -110,6 +110,7 @@ static void soc_release(struct device *dev)
> >  }
> >
> >  static struct soc_device_attribute *early_soc_dev_attr;
> > +static bool soc_dev_attr_init_done = false;
> 
> Do you need this variable?
> 
> >
> >  struct soc_device *soc_device_register(struct soc_device_attribute 
> > *soc_dev_attr)
> >  {
> > @@ -157,6 +158,7 @@ struct soc_device *soc_device_register(struct 
> > soc_device_attribute *soc_dev_attr
> > return ERR_PTR(ret);
> > }
> >
> > +   soc_dev_attr_init_done = true;
> > return soc_dev;
> >
> >  out3:
> > @@ -246,6 +248,9 @@ const struct soc_device_attribute *soc_device_match(
> > if (!matches)
> > return NULL;
> >
> > +   if (!soc_dev_attr_init_done && !early_soc_dev_attr)
> 
> if (!soc_bus_type.p && !early_soc_dev_attr)

There is one place checking this already.  We could wrap it in a helper
function:

static bool device_init_done(void)
{
return soc_bus_type.p ? true : false;
}

regards,
dan carpenter
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [RFC v1 PATCH 1/3] drivers: soc: add support for soc_device_match returning -EPROBE_DEFER

2021-04-19 Thread Geert Uytterhoeven
Hi Alice,

CC Arnd (soc_device_match() author)

On Mon, Apr 19, 2021 at 6:28 AM Alice Guo (OSS)  wrote:
> From: Alice Guo 
>
> In i.MX8M boards, the registration of SoC device is later than caam
> driver which needs it. Caam driver needs soc_device_match to provide
> -EPROBE_DEFER when no SoC device is registered and no
> early_soc_dev_attr.

I'm wondering if this is really a good idea: soc_device_match() is a
last-resort low-level check, and IMHO should be made available early on,
so there is no need for -EPROBE_DEFER.

>
> Signed-off-by: Alice Guo 

Thanks for your patch!

> --- a/drivers/base/soc.c
> +++ b/drivers/base/soc.c
> @@ -110,6 +110,7 @@ static void soc_release(struct device *dev)
>  }
>
>  static struct soc_device_attribute *early_soc_dev_attr;
> +static bool soc_dev_attr_init_done = false;

Do you need this variable?

>
>  struct soc_device *soc_device_register(struct soc_device_attribute 
> *soc_dev_attr)
>  {
> @@ -157,6 +158,7 @@ struct soc_device *soc_device_register(struct 
> soc_device_attribute *soc_dev_attr
> return ERR_PTR(ret);
> }
>
> +   soc_dev_attr_init_done = true;
> return soc_dev;
>
>  out3:
> @@ -246,6 +248,9 @@ const struct soc_device_attribute *soc_device_match(
> if (!matches)
> return NULL;
>
> +   if (!soc_dev_attr_init_done && !early_soc_dev_attr)

if (!soc_bus_type.p && !early_soc_dev_attr)

> +   return ERR_PTR(-EPROBE_DEFER);
> +
> while (!ret) {
> if (!(matches->machine || matches->family ||
>   matches->revision || matches->soc_id))

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[RFC v1 PATCH 1/3] drivers: soc: add support for soc_device_match returning -EPROBE_DEFER

2021-04-19 Thread Alice Guo (OSS)
From: Alice Guo 

In i.MX8M boards, the registration of SoC device is later than caam
driver which needs it. Caam driver needs soc_device_match to provide
-EPROBE_DEFER when no SoC device is registered and no
early_soc_dev_attr.

Signed-off-by: Alice Guo 
---
 drivers/base/soc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 0af5363a582c..12a22f9cf5c8 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -110,6 +110,7 @@ static void soc_release(struct device *dev)
 }
 
 static struct soc_device_attribute *early_soc_dev_attr;
+static bool soc_dev_attr_init_done = false;
 
 struct soc_device *soc_device_register(struct soc_device_attribute 
*soc_dev_attr)
 {
@@ -157,6 +158,7 @@ struct soc_device *soc_device_register(struct 
soc_device_attribute *soc_dev_attr
return ERR_PTR(ret);
}
 
+   soc_dev_attr_init_done = true;
return soc_dev;
 
 out3:
@@ -246,6 +248,9 @@ const struct soc_device_attribute *soc_device_match(
if (!matches)
return NULL;
 
+   if (!soc_dev_attr_init_done && !early_soc_dev_attr)
+   return ERR_PTR(-EPROBE_DEFER);
+
while (!ret) {
if (!(matches->machine || matches->family ||
  matches->revision || matches->soc_id))
-- 
2.17.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


RE: [RFC v1 PATCH 1/3] drivers: soc: add support for soc_device_match returning -EPROBE_DEFER

2021-04-19 Thread Alice Guo (OSS)

> -Original Message-
> From: Dominique MARTINET 
> Sent: 2021年4月19日 12:49
> To: Alice Guo (OSS) 
> Cc: gre...@linuxfoundation.org; raf...@kernel.org; Horia Geanta
> ; Aymen Sghaier ;
> herb...@gondor.apana.org.au; da...@davemloft.net; t...@atomide.com;
> geert+rene...@glider.be; mturque...@baylibre.com; sb...@kernel.org;
> vk...@kernel.org; peter.ujfal...@gmail.com; a.ha...@samsung.com;
> narmstr...@baylibre.com; robert.f...@linaro.org; airl...@linux.ie;
> dan...@ffwll.ch; khil...@baylibre.com; to...@kernel.org; jyri.sa...@iki.fi;
> j...@8bytes.org; w...@kernel.org; mche...@kernel.org;
> ulf.hans...@linaro.org; adrian.hun...@intel.com; kis...@ti.com;
> k...@kernel.org; linus.wall...@linaro.org; Roy Pledge ;
> Leo Li ; ssant...@kernel.org; matthias@gmail.com;
> edubez...@gmail.com; j-keer...@ti.com; ba...@kernel.org;
> li...@prisktech.co.nz; st...@rowland.harvard.edu; w...@linux-watchdog.org;
> li...@roeck-us.net; linux-ker...@vger.kernel.org; 
> linux-cry...@vger.kernel.org;
> linux-o...@vger.kernel.org; linux-renesas-...@vger.kernel.org;
> linux-...@vger.kernel.org; dmaeng...@vger.kernel.org;
> dri-de...@lists.freedesktop.org; linux-amlo...@lists.infradead.org;
> linux-arm-ker...@lists.infradead.org; iommu@lists.linux-foundation.org;
> linux-me...@vger.kernel.org; linux-...@vger.kernel.org;
> net...@vger.kernel.org; linux-...@lists.infradead.org;
> linux-g...@vger.kernel.org; linuxppc-...@lists.ozlabs.org;
> linux-stag...@lists.linux.dev; linux-media...@lists.infradead.org;
> linux...@vger.kernel.org; linux-...@vger.kernel.org;
> linux-watch...@vger.kernel.org
> Subject: Re: [RFC v1 PATCH 1/3] drivers: soc: add support for soc_device_match
> returning -EPROBE_DEFER
> 
> First comment overall for the whole serie:
> Since it is the solution I had suggested when I reported the problem[1] I 
> have no
> qualm on the approach, comments for individual patches follow.
> 
> [1] http://lore.kernel.org/r/YGGZJjAxA1IO+/v...@atmark-techno.com
> 
> 
> Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:20PM +0800:
> > From: Alice Guo 
> >
> > In i.MX8M boards, the registration of SoC device is later than caam
> > driver which needs it. Caam driver needs soc_device_match to provide
> > -EPROBE_DEFER when no SoC device is registered and no
> > early_soc_dev_attr.
> 
> This patch should be last in the set: you can't have soc_device_match return 
> an
> error before its callers handle it.
> 
> > Signed-off-by: Alice Guo 
> 
> As the one who reported the problem I would have been appreciated being at
> least added to Ccs... I only happened to notice you posted this by chance.

Sorry. I will Cc you next time.

> There is also not a single Fixes tag -- I believe this commit should have 
> Fixes:
> 7d981405d0fd ("soc: imx8m: change to use platform driver") but I'm not sure
> how such tags should be handled in case of multiple patches fixing something.

I only mentioned "soc: imx8m: change to use platform driver" in cover letter.
If it is acceptable to make such a modification, I will send non-RFC and add 
Fixes tag.

Best Regards,
Alice

> --
> Dominique
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [RFC v1 PATCH 1/3] drivers: soc: add support for soc_device_match returning -EPROBE_DEFER

2021-04-19 Thread Dominique MARTINET
First comment overall for the whole serie:
Since it is the solution I had suggested when I reported the problem[1]
I have no qualm on the approach, comments for individual patches
follow.

[1] http://lore.kernel.org/r/YGGZJjAxA1IO+/v...@atmark-techno.com


Alice Guo (OSS) wrote on Mon, Apr 19, 2021 at 12:27:20PM +0800:
> From: Alice Guo 
> 
> In i.MX8M boards, the registration of SoC device is later than caam
> driver which needs it. Caam driver needs soc_device_match to provide
> -EPROBE_DEFER when no SoC device is registered and no
> early_soc_dev_attr.

This patch should be last in the set: you can't have soc_device_match
return an error before its callers handle it.

> Signed-off-by: Alice Guo 

As the one who reported the problem I would have been appreciated being
at least added to Ccs... I only happened to notice you posted this by
chance.

There is also not a single Fixes tag -- I believe this commit should
have Fixes: 7d981405d0fd ("soc: imx8m: change to use platform driver")
but I'm not sure how such tags should be handled in case of multiple
patches fixing something.

-- 
Dominique
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu