linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: imx: Register SoC device only on i.MX boards
@ 2021-12-06 11:38 Stephan Gerhold
  2021-12-06 11:58 ` Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephan Gerhold @ 2021-12-06 11:38 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Jonathan Neuschäfer, Sebastian Reichel,
	linux-arm-kernel, linux-kernel, Stephan Gerhold, Peng Fan,
	Arnd Bergmann

At the moment, using the ARM32 multi_v7_defconfig always results in two
SoCs being exposed in sysfs. This is wrong, as far as I'm aware the
Qualcomm DragonBoard 410c does not actually make use of a i.MX SoC. :)

  qcom-db410c:/sys/devices/soc0$ grep . *
  family:Freescale i.MX
  machine:Qualcomm Technologies, Inc. APQ 8016 SBC
  revision:0.0
  serial_number:0000000000000000
  soc_id:Unknown

  qcom-db410c:/sys/devices/soc1$ grep . *
  family:Snapdragon
  machine:APQ8016
  ...

This happens because imx_soc_device_init() registers the soc device
unconditionally, even when running on devices that do not make use of i.MX.
Arnd already reported this more than a year ago and even suggested a fix
similar to this commit, but for some reason it was never submitted.

Fix it by checking if the "__mxc_cpu_type" variable was actually
initialized by earlier platform code. On devices without i.MX it will
simply stay 0.

Cc: Peng Fan <peng.fan@nxp.com>
Fixes: d2199b34871b ("ARM: imx: use device_initcall for imx_soc_device_init")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/CAK8P3a0hxO1TmK6oOMQ70AHSWJnP_CAq57YMOutrxkSYNjFeuw@mail.gmail.com/
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
 drivers/soc/imx/soc-imx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/soc/imx/soc-imx.c b/drivers/soc/imx/soc-imx.c
index ac6d856ba228..77bc12039c3d 100644
--- a/drivers/soc/imx/soc-imx.c
+++ b/drivers/soc/imx/soc-imx.c
@@ -36,6 +36,10 @@ static int __init imx_soc_device_init(void)
 	int ret;
 	int i;
 
+	/* Return early if this is running on devices with different SoCs */
+	if (!__mxc_cpu_type)
+		return 0;
+
 	if (of_machine_is_compatible("fsl,ls1021a"))
 		return 0;
 
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] soc: imx: Register SoC device only on i.MX boards
  2021-12-06 11:38 [PATCH] soc: imx: Register SoC device only on i.MX boards Stephan Gerhold
@ 2021-12-06 11:58 ` Fabio Estevam
  2021-12-06 12:23 ` Peng Fan
  2021-12-08 12:30 ` Shawn Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2021-12-06 11:58 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, NXP Linux Team,
	Jonathan Neuschäfer, Sebastian Reichel,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-kernel, Peng Fan, Arnd Bergmann

On Mon, Dec 6, 2021 at 8:40 AM Stephan Gerhold <stephan@gerhold.net> wrote:
>
> At the moment, using the ARM32 multi_v7_defconfig always results in two
> SoCs being exposed in sysfs. This is wrong, as far as I'm aware the
> Qualcomm DragonBoard 410c does not actually make use of a i.MX SoC. :)
>
>   qcom-db410c:/sys/devices/soc0$ grep . *
>   family:Freescale i.MX
>   machine:Qualcomm Technologies, Inc. APQ 8016 SBC
>   revision:0.0
>   serial_number:0000000000000000
>   soc_id:Unknown
>
>   qcom-db410c:/sys/devices/soc1$ grep . *
>   family:Snapdragon
>   machine:APQ8016
>   ...
>
> This happens because imx_soc_device_init() registers the soc device
> unconditionally, even when running on devices that do not make use of i.MX.
> Arnd already reported this more than a year ago and even suggested a fix
> similar to this commit, but for some reason it was never submitted.
>
> Fix it by checking if the "__mxc_cpu_type" variable was actually
> initialized by earlier platform code. On devices without i.MX it will
> simply stay 0.
>
> Cc: Peng Fan <peng.fan@nxp.com>
> Fixes: d2199b34871b ("ARM: imx: use device_initcall for imx_soc_device_init")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Link: https://lore.kernel.org/r/CAK8P3a0hxO1TmK6oOMQ70AHSWJnP_CAq57YMOutrxkSYNjFeuw@mail.gmail.com/
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* RE: [PATCH] soc: imx: Register SoC device only on i.MX boards
  2021-12-06 11:38 [PATCH] soc: imx: Register SoC device only on i.MX boards Stephan Gerhold
  2021-12-06 11:58 ` Fabio Estevam
@ 2021-12-06 12:23 ` Peng Fan
  2021-12-08 12:30 ` Shawn Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2021-12-06 12:23 UTC (permalink / raw)
  To: Stephan Gerhold, Shawn Guo
  Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	dl-linux-imx, Jonathan Neuschäfer, Sebastian Reichel,
	linux-arm-kernel, linux-kernel, Arnd Bergmann

> Subject: [PATCH] soc: imx: Register SoC device only on i.MX boards
> 
> At the moment, using the ARM32 multi_v7_defconfig always results in two
> SoCs being exposed in sysfs. This is wrong, as far as I'm aware the Qualcomm
> DragonBoard 410c does not actually make use of a i.MX SoC. :)
> 
>   qcom-db410c:/sys/devices/soc0$ grep . *
>   family:Freescale i.MX
>   machine:Qualcomm Technologies, Inc. APQ 8016 SBC
>   revision:0.0
>   serial_number:0000000000000000
>   soc_id:Unknown
> 
>   qcom-db410c:/sys/devices/soc1$ grep . *
>   family:Snapdragon
>   machine:APQ8016
>   ...
> 
> This happens because imx_soc_device_init() registers the soc device
> unconditionally, even when running on devices that do not make use of i.MX.
> Arnd already reported this more than a year ago and even suggested a fix
> similar to this commit, but for some reason it was never submitted.
> 
> Fix it by checking if the "__mxc_cpu_type" variable was actually initialized by
> earlier platform code. On devices without i.MX it will simply stay 0.
> 
> Cc: Peng Fan <peng.fan@nxp.com>
> Fixes: d2199b34871b ("ARM: imx: use device_initcall for
> imx_soc_device_init")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Link:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.ke
> rnel.org%2Fr%2FCAK8P3a0hxO1TmK6oOMQ70AHSWJnP_CAq57YMOutrxkSY
> NjFeuw%40mail.gmail.com%2F&amp;data=04%7C01%7Cpeng.fan%40nxp.co
> m%7Cba6334562b49404f88b708d9b8ad36b5%7C686ea1d3bc2b4c6fa92cd9
> 9c5c301635%7C0%7C0%7C637743876348146819%7CUnknown%7CTWFpbG
> Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
> Mn0%3D%7C3000&amp;sdata=mAeB%2FvXO4cUbcPPLBH14LkDzxMz2w5SLj
> iNEZhjgFuU%3D&amp;reserved=0
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> ---
>  drivers/soc/imx/soc-imx.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/soc/imx/soc-imx.c b/drivers/soc/imx/soc-imx.c index
> ac6d856ba228..77bc12039c3d 100644
> --- a/drivers/soc/imx/soc-imx.c
> +++ b/drivers/soc/imx/soc-imx.c
> @@ -36,6 +36,10 @@ static int __init imx_soc_device_init(void)
>  	int ret;
>  	int i;
> 
> +	/* Return early if this is running on devices with different SoCs */
> +	if (!__mxc_cpu_type)
> +		return 0;
> +
>  	if (of_machine_is_compatible("fsl,ls1021a"))
>  		return 0;
> 
> --
> 2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] soc: imx: Register SoC device only on i.MX boards
  2021-12-06 11:38 [PATCH] soc: imx: Register SoC device only on i.MX boards Stephan Gerhold
  2021-12-06 11:58 ` Fabio Estevam
  2021-12-06 12:23 ` Peng Fan
@ 2021-12-08 12:30 ` Shawn Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2021-12-08 12:30 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, Jonathan Neuschäfer, Sebastian Reichel,
	linux-arm-kernel, linux-kernel, Peng Fan, Arnd Bergmann

On Mon, Dec 06, 2021 at 12:38:28PM +0100, Stephan Gerhold wrote:
> At the moment, using the ARM32 multi_v7_defconfig always results in two
> SoCs being exposed in sysfs. This is wrong, as far as I'm aware the
> Qualcomm DragonBoard 410c does not actually make use of a i.MX SoC. :)
> 
>   qcom-db410c:/sys/devices/soc0$ grep . *
>   family:Freescale i.MX
>   machine:Qualcomm Technologies, Inc. APQ 8016 SBC
>   revision:0.0
>   serial_number:0000000000000000
>   soc_id:Unknown
> 
>   qcom-db410c:/sys/devices/soc1$ grep . *
>   family:Snapdragon
>   machine:APQ8016
>   ...
> 
> This happens because imx_soc_device_init() registers the soc device
> unconditionally, even when running on devices that do not make use of i.MX.
> Arnd already reported this more than a year ago and even suggested a fix
> similar to this commit, but for some reason it was never submitted.
> 
> Fix it by checking if the "__mxc_cpu_type" variable was actually
> initialized by earlier platform code. On devices without i.MX it will
> simply stay 0.
> 
> Cc: Peng Fan <peng.fan@nxp.com>
> Fixes: d2199b34871b ("ARM: imx: use device_initcall for imx_soc_device_init")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Link: https://lore.kernel.org/r/CAK8P3a0hxO1TmK6oOMQ70AHSWJnP_CAq57YMOutrxkSYNjFeuw@mail.gmail.com/
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Applied, thanks!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-12-08 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 11:38 [PATCH] soc: imx: Register SoC device only on i.MX boards Stephan Gerhold
2021-12-06 11:58 ` Fabio Estevam
2021-12-06 12:23 ` Peng Fan
2021-12-08 12:30 ` Shawn Guo

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