linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] imx: Provide correct number of resources when registering gpio devices
@ 2020-07-01  3:26 Guenter Roeck
  2020-07-01 15:24 ` Bjorn Helgaas
  2020-07-13  3:02 ` Shawn Guo
  0 siblings, 2 replies; 5+ messages in thread
From: Guenter Roeck @ 2020-07-01  3:26 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Sascha Hauer, Guenter Roeck, Russell King, linux-kernel,
	NXP Linux Team, Pengutronix Kernel Team, Bjorn Helgaas,
	Fabio Estevam, linux-arm-kernel

Since commit a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is
invalid"), the kernel is a bit touchy when it encounters interrupt 0.
As a result, there are lots of warnings such as the following when booting
systems such as 'kzm'.

WARNING: CPU: 0 PID: 1 at drivers/base/platform.c:224 platform_get_irq_optional+0x118/0x128
0 is an invalid IRQ number
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc3 #1
Hardware name: Kyoto Microcomputer Co., Ltd. KZM-ARM11-01
[<c01127d4>] (unwind_backtrace) from [<c010c620>] (show_stack+0x10/0x14)
[<c010c620>] (show_stack) from [<c06f5f54>] (dump_stack+0xe8/0x120)
[<c06f5f54>] (dump_stack) from [<c0128878>] (__warn+0xe4/0x108)
[<c0128878>] (__warn) from [<c0128910>] (warn_slowpath_fmt+0x74/0xbc)
[<c0128910>] (warn_slowpath_fmt) from [<c08b8e84>] (platform_get_irq_optional+0x118/0x128)
[<c08b8e84>] (platform_get_irq_optional) from [<c08b8eb4>] (platform_irq_count+0x20/0x3c)
[<c08b8eb4>] (platform_irq_count) from [<c0728660>] (mxc_gpio_probe+0x8c/0x494)
[<c0728660>] (mxc_gpio_probe) from [<c08b93cc>] (platform_drv_probe+0x48/0x98)
[<c08b93cc>] (platform_drv_probe) from [<c08b703c>] (really_probe+0x214/0x344)
[<c08b703c>] (really_probe) from [<c08b7274>] (driver_probe_device+0x58/0xb4)
[<c08b7274>] (driver_probe_device) from [<c08b7478>] (device_driver_attach+0x58/0x60)
[<c08b7478>] (device_driver_attach) from [<c08b7504>] (__driver_attach+0x84/0xc0)
[<c08b7504>] (__driver_attach) from [<c08b50f8>] (bus_for_each_dev+0x78/0xb8)
[<c08b50f8>] (bus_for_each_dev) from [<c08b62cc>] (bus_add_driver+0x154/0x1e0)
[<c08b62cc>] (bus_add_driver) from [<c08b82b8>] (driver_register+0x74/0x108)
[<c08b82b8>] (driver_register) from [<c0102320>] (do_one_initcall+0x80/0x3b4)
[<c0102320>] (do_one_initcall) from [<c1501008>] (kernel_init_freeable+0x170/0x208)
[<c1501008>] (kernel_init_freeable) from [<c0e178d4>] (kernel_init+0x8/0x11c)
[<c0e178d4>] (kernel_init) from [<c0100134>] (ret_from_fork+0x14/0x20)

As it turns out, mxc_register_gpio() is a bit lax when setting the
number of resources: it registers a resource with interrupt 0 when in
reality there is no such interrupt. Fix the problem by not declaring
the second interrupt resource if there is no second interrupt.

Fixes: a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is invalid")
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 arch/arm/mach-imx/devices/platform-gpio-mxc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/devices/platform-gpio-mxc.c b/arch/arm/mach-imx/devices/platform-gpio-mxc.c
index 78628ef12672..355de845224c 100644
--- a/arch/arm/mach-imx/devices/platform-gpio-mxc.c
+++ b/arch/arm/mach-imx/devices/platform-gpio-mxc.c
@@ -24,7 +24,8 @@ struct platform_device *__init mxc_register_gpio(char *name, int id,
 			.flags = IORESOURCE_IRQ,
 		},
 	};
+	unsigned int nres;
 
-	return platform_device_register_resndata(&mxc_aips_bus,
-			name, id, res, ARRAY_SIZE(res), NULL, 0);
+	nres = irq_high ? ARRAY_SIZE(res) : ARRAY_SIZE(res) - 1;
+	return platform_device_register_resndata(&mxc_aips_bus, name, id, res, nres, NULL, 0);
 }
-- 
2.17.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] 5+ messages in thread

* Re: [PATCH] imx: Provide correct number of resources when registering gpio devices
  2020-07-01  3:26 [PATCH] imx: Provide correct number of resources when registering gpio devices Guenter Roeck
@ 2020-07-01 15:24 ` Bjorn Helgaas
  2020-07-01 15:32   ` Fabio Estevam
  2020-07-01 16:16   ` Guenter Roeck
  2020-07-13  3:02 ` Shawn Guo
  1 sibling, 2 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2020-07-01 15:24 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Shawn Guo, Sascha Hauer, Russell King, linux-kernel,
	NXP Linux Team, Pengutronix Kernel Team, Bjorn Helgaas,
	Fabio Estevam, linux-arm-kernel

On Tue, Jun 30, 2020 at 08:26:51PM -0700, Guenter Roeck wrote:
> Since commit a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is
> invalid"), the kernel is a bit touchy when it encounters interrupt 0.
> As a result, there are lots of warnings such as the following when booting
> systems such as 'kzm'.

Thanks for the fix.  If there are others like this, I'd be glad to
help fix them since I made the kernel grumpier about this.  Just point
me at the info.

I looked at other callers of platform_device_register_resndata().  It
looks like imx_add_imx_dma() and vm_cmdline_set() have the same
problem.  I'll fix those unless you're already doing it.

> WARNING: CPU: 0 PID: 1 at drivers/base/platform.c:224 platform_get_irq_optional+0x118/0x128
> 0 is an invalid IRQ number
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc3 #1
> Hardware name: Kyoto Microcomputer Co., Ltd. KZM-ARM11-01
> [<c01127d4>] (unwind_backtrace) from [<c010c620>] (show_stack+0x10/0x14)
> [<c010c620>] (show_stack) from [<c06f5f54>] (dump_stack+0xe8/0x120)
> [<c06f5f54>] (dump_stack) from [<c0128878>] (__warn+0xe4/0x108)
> [<c0128878>] (__warn) from [<c0128910>] (warn_slowpath_fmt+0x74/0xbc)
> [<c0128910>] (warn_slowpath_fmt) from [<c08b8e84>] (platform_get_irq_optional+0x118/0x128)
> [<c08b8e84>] (platform_get_irq_optional) from [<c08b8eb4>] (platform_irq_count+0x20/0x3c)
> [<c08b8eb4>] (platform_irq_count) from [<c0728660>] (mxc_gpio_probe+0x8c/0x494)
> [<c0728660>] (mxc_gpio_probe) from [<c08b93cc>] (platform_drv_probe+0x48/0x98)
> [<c08b93cc>] (platform_drv_probe) from [<c08b703c>] (really_probe+0x214/0x344)
> [<c08b703c>] (really_probe) from [<c08b7274>] (driver_probe_device+0x58/0xb4)
> [<c08b7274>] (driver_probe_device) from [<c08b7478>] (device_driver_attach+0x58/0x60)
> [<c08b7478>] (device_driver_attach) from [<c08b7504>] (__driver_attach+0x84/0xc0)
> [<c08b7504>] (__driver_attach) from [<c08b50f8>] (bus_for_each_dev+0x78/0xb8)
> [<c08b50f8>] (bus_for_each_dev) from [<c08b62cc>] (bus_add_driver+0x154/0x1e0)
> [<c08b62cc>] (bus_add_driver) from [<c08b82b8>] (driver_register+0x74/0x108)
> [<c08b82b8>] (driver_register) from [<c0102320>] (do_one_initcall+0x80/0x3b4)
> [<c0102320>] (do_one_initcall) from [<c1501008>] (kernel_init_freeable+0x170/0x208)
> [<c1501008>] (kernel_init_freeable) from [<c0e178d4>] (kernel_init+0x8/0x11c)
> [<c0e178d4>] (kernel_init) from [<c0100134>] (ret_from_fork+0x14/0x20)
> 
> As it turns out, mxc_register_gpio() is a bit lax when setting the
> number of resources: it registers a resource with interrupt 0 when in
> reality there is no such interrupt. Fix the problem by not declaring
> the second interrupt resource if there is no second interrupt.
> 
> Fixes: a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is invalid")
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  arch/arm/mach-imx/devices/platform-gpio-mxc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/devices/platform-gpio-mxc.c b/arch/arm/mach-imx/devices/platform-gpio-mxc.c
> index 78628ef12672..355de845224c 100644
> --- a/arch/arm/mach-imx/devices/platform-gpio-mxc.c
> +++ b/arch/arm/mach-imx/devices/platform-gpio-mxc.c
> @@ -24,7 +24,8 @@ struct platform_device *__init mxc_register_gpio(char *name, int id,
>  			.flags = IORESOURCE_IRQ,
>  		},
>  	};
> +	unsigned int nres;
>  
> -	return platform_device_register_resndata(&mxc_aips_bus,
> -			name, id, res, ARRAY_SIZE(res), NULL, 0);
> +	nres = irq_high ? ARRAY_SIZE(res) : ARRAY_SIZE(res) - 1;
> +	return platform_device_register_resndata(&mxc_aips_bus, name, id, res, nres, NULL, 0);
>  }
> -- 
> 2.17.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] 5+ messages in thread

* Re: [PATCH] imx: Provide correct number of resources when registering gpio devices
  2020-07-01 15:24 ` Bjorn Helgaas
@ 2020-07-01 15:32   ` Fabio Estevam
  2020-07-01 16:16   ` Guenter Roeck
  1 sibling, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2020-07-01 15:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Sascha Hauer, Russell King, linux-kernel, NXP Linux Team,
	Pengutronix Kernel Team, Bjorn Helgaas, Shawn Guo, Guenter Roeck

Hi Bjorn,

On Wed, Jul 1, 2020 at 12:24 PM Bjorn Helgaas <helgaas@kernel.org> wrote:

> Thanks for the fix.  If there are others like this, I'd be glad to
> help fix them since I made the kernel grumpier about this.  Just point
> me at the info.

I am seeing the same warning on drivers/input/touchscreen/mxs-lradc-ts.c

Will Cc you on that discussion.

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

* Re: [PATCH] imx: Provide correct number of resources when registering gpio devices
  2020-07-01 15:24 ` Bjorn Helgaas
  2020-07-01 15:32   ` Fabio Estevam
@ 2020-07-01 16:16   ` Guenter Roeck
  1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2020-07-01 16:16 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Shawn Guo, Sascha Hauer, Russell King, linux-kernel,
	NXP Linux Team, Pengutronix Kernel Team, Bjorn Helgaas,
	Fabio Estevam, linux-arm-kernel

On Wed, Jul 01, 2020 at 10:24:42AM -0500, Bjorn Helgaas wrote:
> On Tue, Jun 30, 2020 at 08:26:51PM -0700, Guenter Roeck wrote:
> > Since commit a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is
> > invalid"), the kernel is a bit touchy when it encounters interrupt 0.
> > As a result, there are lots of warnings such as the following when booting
> > systems such as 'kzm'.
> 
> Thanks for the fix.  If there are others like this, I'd be glad to
> help fix them since I made the kernel grumpier about this.  Just point
> me at the info.
> 
> I looked at other callers of platform_device_register_resndata().  It
> looks like imx_add_imx_dma() and vm_cmdline_set() have the same
> problem.  I'll fix those unless you're already doing it.

The traceback below is the only one I have seen in my test system.
Qemu doesn't support any of the architectures calling imx_add_imx_dma.

I have not looked at or searched for any others.

Guenter

> 
> > WARNING: CPU: 0 PID: 1 at drivers/base/platform.c:224 platform_get_irq_optional+0x118/0x128
> > 0 is an invalid IRQ number
> > Modules linked in:
> > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc3 #1
> > Hardware name: Kyoto Microcomputer Co., Ltd. KZM-ARM11-01
> > [<c01127d4>] (unwind_backtrace) from [<c010c620>] (show_stack+0x10/0x14)
> > [<c010c620>] (show_stack) from [<c06f5f54>] (dump_stack+0xe8/0x120)
> > [<c06f5f54>] (dump_stack) from [<c0128878>] (__warn+0xe4/0x108)
> > [<c0128878>] (__warn) from [<c0128910>] (warn_slowpath_fmt+0x74/0xbc)
> > [<c0128910>] (warn_slowpath_fmt) from [<c08b8e84>] (platform_get_irq_optional+0x118/0x128)
> > [<c08b8e84>] (platform_get_irq_optional) from [<c08b8eb4>] (platform_irq_count+0x20/0x3c)
> > [<c08b8eb4>] (platform_irq_count) from [<c0728660>] (mxc_gpio_probe+0x8c/0x494)
> > [<c0728660>] (mxc_gpio_probe) from [<c08b93cc>] (platform_drv_probe+0x48/0x98)
> > [<c08b93cc>] (platform_drv_probe) from [<c08b703c>] (really_probe+0x214/0x344)
> > [<c08b703c>] (really_probe) from [<c08b7274>] (driver_probe_device+0x58/0xb4)
> > [<c08b7274>] (driver_probe_device) from [<c08b7478>] (device_driver_attach+0x58/0x60)
> > [<c08b7478>] (device_driver_attach) from [<c08b7504>] (__driver_attach+0x84/0xc0)
> > [<c08b7504>] (__driver_attach) from [<c08b50f8>] (bus_for_each_dev+0x78/0xb8)
> > [<c08b50f8>] (bus_for_each_dev) from [<c08b62cc>] (bus_add_driver+0x154/0x1e0)
> > [<c08b62cc>] (bus_add_driver) from [<c08b82b8>] (driver_register+0x74/0x108)
> > [<c08b82b8>] (driver_register) from [<c0102320>] (do_one_initcall+0x80/0x3b4)
> > [<c0102320>] (do_one_initcall) from [<c1501008>] (kernel_init_freeable+0x170/0x208)
> > [<c1501008>] (kernel_init_freeable) from [<c0e178d4>] (kernel_init+0x8/0x11c)
> > [<c0e178d4>] (kernel_init) from [<c0100134>] (ret_from_fork+0x14/0x20)
> > 
> > As it turns out, mxc_register_gpio() is a bit lax when setting the
> > number of resources: it registers a resource with interrupt 0 when in
> > reality there is no such interrupt. Fix the problem by not declaring
> > the second interrupt resource if there is no second interrupt.
> > 
> > Fixes: a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is invalid")
> > Cc: Bjorn Helgaas <bhelgaas@google.com>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> >  arch/arm/mach-imx/devices/platform-gpio-mxc.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/mach-imx/devices/platform-gpio-mxc.c b/arch/arm/mach-imx/devices/platform-gpio-mxc.c
> > index 78628ef12672..355de845224c 100644
> > --- a/arch/arm/mach-imx/devices/platform-gpio-mxc.c
> > +++ b/arch/arm/mach-imx/devices/platform-gpio-mxc.c
> > @@ -24,7 +24,8 @@ struct platform_device *__init mxc_register_gpio(char *name, int id,
> >  			.flags = IORESOURCE_IRQ,
> >  		},
> >  	};
> > +	unsigned int nres;
> >  
> > -	return platform_device_register_resndata(&mxc_aips_bus,
> > -			name, id, res, ARRAY_SIZE(res), NULL, 0);
> > +	nres = irq_high ? ARRAY_SIZE(res) : ARRAY_SIZE(res) - 1;
> > +	return platform_device_register_resndata(&mxc_aips_bus, name, id, res, nres, NULL, 0);
> >  }
> > -- 
> > 2.17.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] 5+ messages in thread

* Re: [PATCH] imx: Provide correct number of resources when registering gpio devices
  2020-07-01  3:26 [PATCH] imx: Provide correct number of resources when registering gpio devices Guenter Roeck
  2020-07-01 15:24 ` Bjorn Helgaas
@ 2020-07-13  3:02 ` Shawn Guo
  1 sibling, 0 replies; 5+ messages in thread
From: Shawn Guo @ 2020-07-13  3:02 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Sascha Hauer, Russell King, linux-kernel, NXP Linux Team,
	Pengutronix Kernel Team, Bjorn Helgaas, Fabio Estevam,
	linux-arm-kernel

On Tue, Jun 30, 2020 at 08:26:51PM -0700, Guenter Roeck wrote:
> Since commit a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is
> invalid"), the kernel is a bit touchy when it encounters interrupt 0.
> As a result, there are lots of warnings such as the following when booting
> systems such as 'kzm'.
> 
> WARNING: CPU: 0 PID: 1 at drivers/base/platform.c:224 platform_get_irq_optional+0x118/0x128
> 0 is an invalid IRQ number
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc3 #1
> Hardware name: Kyoto Microcomputer Co., Ltd. KZM-ARM11-01
> [<c01127d4>] (unwind_backtrace) from [<c010c620>] (show_stack+0x10/0x14)
> [<c010c620>] (show_stack) from [<c06f5f54>] (dump_stack+0xe8/0x120)
> [<c06f5f54>] (dump_stack) from [<c0128878>] (__warn+0xe4/0x108)
> [<c0128878>] (__warn) from [<c0128910>] (warn_slowpath_fmt+0x74/0xbc)
> [<c0128910>] (warn_slowpath_fmt) from [<c08b8e84>] (platform_get_irq_optional+0x118/0x128)
> [<c08b8e84>] (platform_get_irq_optional) from [<c08b8eb4>] (platform_irq_count+0x20/0x3c)
> [<c08b8eb4>] (platform_irq_count) from [<c0728660>] (mxc_gpio_probe+0x8c/0x494)
> [<c0728660>] (mxc_gpio_probe) from [<c08b93cc>] (platform_drv_probe+0x48/0x98)
> [<c08b93cc>] (platform_drv_probe) from [<c08b703c>] (really_probe+0x214/0x344)
> [<c08b703c>] (really_probe) from [<c08b7274>] (driver_probe_device+0x58/0xb4)
> [<c08b7274>] (driver_probe_device) from [<c08b7478>] (device_driver_attach+0x58/0x60)
> [<c08b7478>] (device_driver_attach) from [<c08b7504>] (__driver_attach+0x84/0xc0)
> [<c08b7504>] (__driver_attach) from [<c08b50f8>] (bus_for_each_dev+0x78/0xb8)
> [<c08b50f8>] (bus_for_each_dev) from [<c08b62cc>] (bus_add_driver+0x154/0x1e0)
> [<c08b62cc>] (bus_add_driver) from [<c08b82b8>] (driver_register+0x74/0x108)
> [<c08b82b8>] (driver_register) from [<c0102320>] (do_one_initcall+0x80/0x3b4)
> [<c0102320>] (do_one_initcall) from [<c1501008>] (kernel_init_freeable+0x170/0x208)
> [<c1501008>] (kernel_init_freeable) from [<c0e178d4>] (kernel_init+0x8/0x11c)
> [<c0e178d4>] (kernel_init) from [<c0100134>] (ret_from_fork+0x14/0x20)
> 
> As it turns out, mxc_register_gpio() is a bit lax when setting the
> number of resources: it registers a resource with interrupt 0 when in
> reality there is no such interrupt. Fix the problem by not declaring
> the second interrupt resource if there is no second interrupt.
> 
> Fixes: a85a6c86c25be ("driver core: platform: Clarify that IRQ 0 is invalid")
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

I changed the subject prefix to 'ARM: imx: ...' and applied the patch.

Shawn

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

end of thread, other threads:[~2020-07-13  3:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01  3:26 [PATCH] imx: Provide correct number of resources when registering gpio devices Guenter Roeck
2020-07-01 15:24 ` Bjorn Helgaas
2020-07-01 15:32   ` Fabio Estevam
2020-07-01 16:16   ` Guenter Roeck
2020-07-13  3:02 ` 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).