linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-esdhc-imx: validate pinctrl before use it
@ 2021-01-15  3:24 Peng Fan (OSS)
  2021-01-19 13:37 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan (OSS) @ 2021-01-15  3:24 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, linux-mmc,
	linux-arm-kernel, linux-kernel, Peng Fan, Bough Chen, Alice Guo

From: Peng Fan <peng.fan@nxp.com>

When imx_data->pinctrl is not a valid pointer, pinctrl_lookup_state
will trigger kernel panic.

When we boot Dual OS on Jailhouse hypervisor, we let the 1st Linux to
configure pinmux ready for the 2nd OS, so the 2nd OS not have pinctrl
settings.

Similar to this commit b62eee9f804e ("mmc: sdhci-esdhc-imx: no fail when no pinctrl available").

Reviewed-by: Bough Chen <haobo.chen@nxp.com>
Reviewed-by: Alice Guo <alice.guo@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 16ed19f47939..11d3a2244b36 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1488,7 +1488,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 
 	mmc_of_parse_voltage(np, &host->ocr_mask);
 
-	if (esdhc_is_usdhc(imx_data)) {
+	if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
 		imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
 						ESDHC_PINCTRL_STATE_100MHZ);
 		imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
-- 
2.28.0


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

* Re: [PATCH] mmc: sdhci-esdhc-imx: validate pinctrl before use it
  2021-01-15  3:24 [PATCH] mmc: sdhci-esdhc-imx: validate pinctrl before use it Peng Fan (OSS)
@ 2021-01-19 13:37 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2021-01-19 13:37 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Adrian Hunter, Shawn Guo, Sascha Hauer, Sascha Hauer,
	Fabio Estevam, dl-linux-imx, linux-mmc, Linux ARM,
	Linux Kernel Mailing List, Peng Fan, Bough Chen, Alice Guo

On Fri, 15 Jan 2021 at 03:55, Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> When imx_data->pinctrl is not a valid pointer, pinctrl_lookup_state
> will trigger kernel panic.
>
> When we boot Dual OS on Jailhouse hypervisor, we let the 1st Linux to
> configure pinmux ready for the 2nd OS, so the 2nd OS not have pinctrl
> settings.
>
> Similar to this commit b62eee9f804e ("mmc: sdhci-esdhc-imx: no fail when no pinctrl available").
>
> Reviewed-by: Bough Chen <haobo.chen@nxp.com>
> Reviewed-by: Alice Guo <alice.guo@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Looks like the documentation of DT bindings doesn't specify pinctrls
at all. Please add it and explain when they should be used.

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 16ed19f47939..11d3a2244b36 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1488,7 +1488,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
>
>         mmc_of_parse_voltage(np, &host->ocr_mask);
>
> -       if (esdhc_is_usdhc(imx_data)) {
> +       if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
>                 imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
>                                                 ESDHC_PINCTRL_STATE_100MHZ);
>                 imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
> --
> 2.28.0
>

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

end of thread, other threads:[~2021-01-20  0:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15  3:24 [PATCH] mmc: sdhci-esdhc-imx: validate pinctrl before use it Peng Fan (OSS)
2021-01-19 13:37 ` Ulf Hansson

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).