linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
@ 2019-10-18 13:13 Chuhong Yuan
  2019-10-21 14:32 ` Ulf Hansson
  0 siblings, 1 reply; 8+ messages in thread
From: Chuhong Yuan @ 2019-10-18 13:13 UTC (permalink / raw)
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, linux-kernel, Chuhong Yuan

renesas_sdhi_probe misses checks for pinctrl_lookup_state and may miss
failures.
Add checks for them to fix the problem.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 drivers/mmc/host/renesas_sdhi_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index d4ada5cca2d1..dc5ad6632df3 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -694,8 +694,13 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 	if (!IS_ERR(priv->pinctrl)) {
 		priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
 						PINCTRL_STATE_DEFAULT);
+		if (IS_ERR(priv->pins_default))
+			return PTR_ERR(priv->pins_default);
+
 		priv->pins_uhs = pinctrl_lookup_state(priv->pinctrl,
 						"state_uhs");
+		if (IS_ERR(priv->pins_uhs))
+			return PTR_ERR(priv->pins_uhs);
 	}
 
 	host = tmio_mmc_host_alloc(pdev, mmc_data);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-10-18 13:13 [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state Chuhong Yuan
@ 2019-10-21 14:32 ` Ulf Hansson
  2019-10-21 20:10   ` Wolfram Sang
  2019-10-23 15:33   ` Wolfram Sang
  0 siblings, 2 replies; 8+ messages in thread
From: Ulf Hansson @ 2019-10-21 14:32 UTC (permalink / raw)
  To: Chuhong Yuan, Wolfram Sang; +Cc: linux-mmc, Linux Kernel Mailing List

On Fri, 18 Oct 2019 at 15:13, Chuhong Yuan <hslester96@gmail.com> wrote:
>
> renesas_sdhi_probe misses checks for pinctrl_lookup_state and may miss
> failures.
> Add checks for them to fix the problem.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
>  drivers/mmc/host/renesas_sdhi_core.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> index d4ada5cca2d1..dc5ad6632df3 100644
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -694,8 +694,13 @@ int renesas_sdhi_probe(struct platform_device *pdev,
>         if (!IS_ERR(priv->pinctrl)) {
>                 priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
>                                                 PINCTRL_STATE_DEFAULT);
> +               if (IS_ERR(priv->pins_default))
> +                       return PTR_ERR(priv->pins_default);
> +
>                 priv->pins_uhs = pinctrl_lookup_state(priv->pinctrl,
>                                                 "state_uhs");
> +               if (IS_ERR(priv->pins_uhs))
> +                       return PTR_ERR(priv->pins_uhs);
>         }

This looks correct to me, as I guess if there is a pinctrl specified
for device node of the controller, it means that it should be used!?

I understand that this is only used for those variants that supports
UHS-I via the renesas_sdhi_start_signal_voltage_switch(). Wolfram, is
this fine you think?

>
>         host = tmio_mmc_host_alloc(pdev, mmc_data);
> --
> 2.20.1
>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-10-21 14:32 ` Ulf Hansson
@ 2019-10-21 20:10   ` Wolfram Sang
  2019-10-23 15:33   ` Wolfram Sang
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2019-10-21 20:10 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Chuhong Yuan, Wolfram Sang, linux-mmc, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]


> I understand that this is only used for those variants that supports
> UHS-I via the renesas_sdhi_start_signal_voltage_switch(). Wolfram, is
> this fine you think?

I'll double check tomorrow.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-10-21 14:32 ` Ulf Hansson
  2019-10-21 20:10   ` Wolfram Sang
@ 2019-10-23 15:33   ` Wolfram Sang
  2019-10-30 15:09     ` Ulf Hansson
  1 sibling, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2019-10-23 15:33 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Chuhong Yuan, Wolfram Sang, linux-mmc, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]

On Mon, Oct 21, 2019 at 04:32:49PM +0200, Ulf Hansson wrote:
> On Fri, 18 Oct 2019 at 15:13, Chuhong Yuan <hslester96@gmail.com> wrote:
> >
> > renesas_sdhi_probe misses checks for pinctrl_lookup_state and may miss
> > failures.
> > Add checks for them to fix the problem.
> >
> > Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> > ---
> >  drivers/mmc/host/renesas_sdhi_core.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> > index d4ada5cca2d1..dc5ad6632df3 100644
> > --- a/drivers/mmc/host/renesas_sdhi_core.c
> > +++ b/drivers/mmc/host/renesas_sdhi_core.c
> > @@ -694,8 +694,13 @@ int renesas_sdhi_probe(struct platform_device *pdev,
> >         if (!IS_ERR(priv->pinctrl)) {
> >                 priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
> >                                                 PINCTRL_STATE_DEFAULT);
> > +               if (IS_ERR(priv->pins_default))
> > +                       return PTR_ERR(priv->pins_default);
> > +
> >                 priv->pins_uhs = pinctrl_lookup_state(priv->pinctrl,
> >                                                 "state_uhs");
> > +               if (IS_ERR(priv->pins_uhs))
> > +                       return PTR_ERR(priv->pins_uhs);
> >         }
> 
> This looks correct to me, as I guess if there is a pinctrl specified
> for device node of the controller, it means that it should be used!?
> 
> I understand that this is only used for those variants that supports
> UHS-I via the renesas_sdhi_start_signal_voltage_switch(). Wolfram, is
> this fine you think?

Well, I don't like to bail out because this error is not fatal for basic
operations. How about releasing priv->pinctrl again with an additional
warning that pinctrl settings are broken and will prevent 1.8v modes?

Opinions?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-10-23 15:33   ` Wolfram Sang
@ 2019-10-30 15:09     ` Ulf Hansson
  2019-10-31 22:12       ` Wolfram Sang
  0 siblings, 1 reply; 8+ messages in thread
From: Ulf Hansson @ 2019-10-30 15:09 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Chuhong Yuan, Wolfram Sang, linux-mmc, Linux Kernel Mailing List

On Wed, 23 Oct 2019 at 17:33, Wolfram Sang <wsa@the-dreams.de> wrote:
>
> On Mon, Oct 21, 2019 at 04:32:49PM +0200, Ulf Hansson wrote:
> > On Fri, 18 Oct 2019 at 15:13, Chuhong Yuan <hslester96@gmail.com> wrote:
> > >
> > > renesas_sdhi_probe misses checks for pinctrl_lookup_state and may miss
> > > failures.
> > > Add checks for them to fix the problem.
> > >
> > > Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> > > ---
> > >  drivers/mmc/host/renesas_sdhi_core.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> > > index d4ada5cca2d1..dc5ad6632df3 100644
> > > --- a/drivers/mmc/host/renesas_sdhi_core.c
> > > +++ b/drivers/mmc/host/renesas_sdhi_core.c
> > > @@ -694,8 +694,13 @@ int renesas_sdhi_probe(struct platform_device *pdev,
> > >         if (!IS_ERR(priv->pinctrl)) {
> > >                 priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
> > >                                                 PINCTRL_STATE_DEFAULT);
> > > +               if (IS_ERR(priv->pins_default))
> > > +                       return PTR_ERR(priv->pins_default);
> > > +
> > >                 priv->pins_uhs = pinctrl_lookup_state(priv->pinctrl,
> > >                                                 "state_uhs");
> > > +               if (IS_ERR(priv->pins_uhs))
> > > +                       return PTR_ERR(priv->pins_uhs);
> > >         }
> >
> > This looks correct to me, as I guess if there is a pinctrl specified
> > for device node of the controller, it means that it should be used!?
> >
> > I understand that this is only used for those variants that supports
> > UHS-I via the renesas_sdhi_start_signal_voltage_switch(). Wolfram, is
> > this fine you think?
>
> Well, I don't like to bail out because this error is not fatal for basic
> operations. How about releasing priv->pinctrl again with an additional
> warning that pinctrl settings are broken and will prevent 1.8v modes?
>
> Opinions?

Hmm, from a mmc driver probe point of view, I don't quite share this approach.

I would rather fail as it forces the DTB to be corrected immediately,
rather than trusting some developer to look at a warning in a log. The
point is, in such a case it may never get fixed, if the product is
shipped with the wrong DTB.

My concern at this point is rather to break existing DTBs, but it
seems that should not be an issue, right?

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-10-30 15:09     ` Ulf Hansson
@ 2019-10-31 22:12       ` Wolfram Sang
  2019-11-07  8:30         ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2019-10-31 22:12 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Chuhong Yuan, Wolfram Sang, linux-mmc, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]

HI Ulf,

> > Well, I don't like to bail out because this error is not fatal for basic
> > operations. How about releasing priv->pinctrl again with an additional
> > warning that pinctrl settings are broken and will prevent 1.8v modes?
> >
> > Opinions?
> 
> Hmm, from a mmc driver probe point of view, I don't quite share this approach.
> 
> I would rather fail as it forces the DTB to be corrected immediately,
> rather than trusting some developer to look at a warning in a log. The
> point is, in such a case it may never get fixed, if the product is
> shipped with the wrong DTB.

I could agree to this arguement, iff the only way pinctrl_select fails
is a DT misconfiguration. I am not sure if this is true right now, and
we can't be sure about the future. Or?

> My concern at this point is rather to break existing DTBs, but it
> seems that should not be an issue, right?

AFAIK not for the upstream ones, I don't know the customer ones.

I still prefer to not bail out.

Kind regards,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-10-31 22:12       ` Wolfram Sang
@ 2019-11-07  8:30         ` Geert Uytterhoeven
  2019-11-24  3:20           ` Chuhong Yuan
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2019-11-07  8:30 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Chuhong Yuan, Wolfram Sang, linux-mmc,
	Linux Kernel Mailing List

Hi Wolfram,

On Thu, Oct 31, 2019 at 11:58 PM Wolfram Sang <wsa@the-dreams.de> wrote:
> > > Well, I don't like to bail out because this error is not fatal for basic
> > > operations. How about releasing priv->pinctrl again with an additional
> > > warning that pinctrl settings are broken and will prevent 1.8v modes?
> > >
> > > Opinions?
> >
> > Hmm, from a mmc driver probe point of view, I don't quite share this approach.
> >
> > I would rather fail as it forces the DTB to be corrected immediately,
> > rather than trusting some developer to look at a warning in a log. The
> > point is, in such a case it may never get fixed, if the product is
> > shipped with the wrong DTB.
>
> I could agree to this arguement, iff the only way pinctrl_select fails
> is a DT misconfiguration. I am not sure if this is true right now, and
> we can't be sure about the future. Or?

Isn't "state_uhs" optional? So bailing out if it doesn't exist is wrong.
"default" should be there, if the device node has pinctrl properties.

renesas_sdhi_start_signal_voltage_switch() already handles fallback
to 3v3 operation.

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] 8+ messages in thread

* Re: [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state
  2019-11-07  8:30         ` Geert Uytterhoeven
@ 2019-11-24  3:20           ` Chuhong Yuan
  0 siblings, 0 replies; 8+ messages in thread
From: Chuhong Yuan @ 2019-11-24  3:20 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Wolfram Sang, Ulf Hansson, Wolfram Sang, linux-mmc,
	Linux Kernel Mailing List

On Thu, Nov 7, 2019 at 4:30 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Wolfram,
>
> On Thu, Oct 31, 2019 at 11:58 PM Wolfram Sang <wsa@the-dreams.de> wrote:
> > > > Well, I don't like to bail out because this error is not fatal for basic
> > > > operations. How about releasing priv->pinctrl again with an additional
> > > > warning that pinctrl settings are broken and will prevent 1.8v modes?
> > > >
> > > > Opinions?
> > >
> > > Hmm, from a mmc driver probe point of view, I don't quite share this approach.
> > >
> > > I would rather fail as it forces the DTB to be corrected immediately,
> > > rather than trusting some developer to look at a warning in a log. The
> > > point is, in such a case it may never get fixed, if the product is
> > > shipped with the wrong DTB.
> >
> > I could agree to this arguement, iff the only way pinctrl_select fails
> > is a DT misconfiguration. I am not sure if this is true right now, and
> > we can't be sure about the future. Or?
>
> Isn't "state_uhs" optional? So bailing out if it doesn't exist is wrong.
> "default" should be there, if the device node has pinctrl properties.
>
> renesas_sdhi_start_signal_voltage_switch() already handles fallback
> to 3v3 operation.
>
> Gr{oetje,eeting}s,
>
>                         Geert
>

Just ping this thread.
I am not clear about what is the conclusion of how to deal with the error?
Should I resend a new version of the patch?

Regards,
Chuhong

> --
> 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] 8+ messages in thread

end of thread, other threads:[~2019-11-24  3:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18 13:13 [PATCH] mmc: renesas_sdhi: add checks for pinctrl_lookup_state Chuhong Yuan
2019-10-21 14:32 ` Ulf Hansson
2019-10-21 20:10   ` Wolfram Sang
2019-10-23 15:33   ` Wolfram Sang
2019-10-30 15:09     ` Ulf Hansson
2019-10-31 22:12       ` Wolfram Sang
2019-11-07  8:30         ` Geert Uytterhoeven
2019-11-24  3:20           ` Chuhong Yuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).