gpio: sa1100: defer GPIO chip registration to postcore_initcall
Subsystems (2)
PATCH 1/1 gpio: sa1100: defer GPIO chip registration to postcore_initcall
Registering the software node and the GPIO chip for the SA-1100 GPIO controller during early IRQ initialization causes boot hangs on SA-1100 platforms because the software node subsystem has not yet been initialized. At that early boot stage, attempting to register software nodes dereferences a NULL kset pointer before console or driver model initialization.
Nothing on SA-1100 platforms requests GPIO lines via gpiolib during early boot before initcalls run; only the GPIO IRQ controller and domain must be initialized during init_IRQ(). Defer registering the software node, assigning its firmware node, and registering the GPIO chip with gpiolib to postcore_initcall, running after driver and gpiolib device initialization and before board consumers register.
--- drivers/gpio/gpio-sa1100.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
drivers/gpio/gpio-sa1100.c +27 -5
@@ -8,6 +8,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/io.h> +#include <linux/printk.h> #include <linux/syscore_ops.h> #include <soc/sa1100/pwer.h> #include <mach/hardware.h>
@@ -322,7 +323,6 @@ static const int sa1100_gpio_irqs[] __initconst = {void __init sa1100_init_gpio (void ) {struct sa1100_gpio_chip *sgc = &sa1100_gpio_chip; -struct gpio_chip *gc = &sgc->chip;int i;/* clear all GPIO edge detects */
@@ -330,10 +330,6 @@ void __init sa1100_init_gpio(void)writel_relaxed (0 , sgc->membase +R_GRER );writel_relaxed (-1 , sgc->membase +R_GEDR ); -software_node_register (&sa1100_gpiochip_node); - gc->fwnode =software_node_fwnode (&sa1100_gpiochip_node); -gpiochip_add_data (gc,NULL ); - sa1100_gpio_irqdomain =irq_domain_create_simple (NULL ,28 ,IRQ_GPIO0 , &sa1100_gpio_irqdomain_ops, sgc);
@@ -342,3 +338,29 @@ void __init sa1100_init_gpio(void)irq_set_chained_handler_and_data (sa1100_gpio_irqs[i], sa1100_gpio_handler, sgc); } + +static int __init sa1100_gpio_init_chip (void ) +{ +struct gpio_chip *gc = &sa1100_gpio_chip.chip; +int error; + + error =software_node_register (&sa1100_gpiochip_node); +if (error) { +pr_err ("failed to register sa1100 gpiochip software node: %d\n" , + error); +return error; + } + + gc->fwnode =software_node_fwnode (&sa1100_gpiochip_node); + + error =gpiochip_add_data (gc,NULL ); +if (error) { +pr_err ("failed to add sa1100 gpiochip: %d\n" , error); + gc->fwnode =NULL ; +software_node_unregister (&sa1100_gpiochip_node); +return error; + } + +return 0 ; +} +postcore_initcall (sa1100_gpio_init_chip);
---
base-commit: 6d0933ae9d46674a6ea63a87e9e9ab4e662670c9
change-id: 20261029-sa1100-swnode-fix-11499713eb7a
Thanks.
Signature · 1 line
Dmitry
Quoted 14 lines · Dmitry Torokhov
Registering the software node and the GPIO chip for the SA-1100 GPIO controller during early IRQ initialization causes boot hangs on SA-1100 platforms because the software node subsystem has not yet been initialized. At that early boot stage, attempting to register software nodes dereferences a NULL kset pointer before console or driver model initialization.
Nothing on SA-1100 platforms requests GPIO lines via gpiolib during early boot before initcalls run; only the GPIO IRQ controller and domain must be initialized during
init_IRQ(). Defer registering the software node, assigning its firmware node, and registering the GPIO chip with gpiolib topostcore_initcall, running after driver and gpiolib device initialization and before board consumers register.
Quoted 5 lines
Fixes e4671f292ebb ("gpio: sa1100: register software node for GPIO controller")Reported-by Guenter Roeck <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 72 lines
--- drivers/gpio/gpio-sa1100.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)drivers/gpio/gpio-sa1100.c +27
-6@@ -8,6 +8,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/io.h> +#include <linux/printk.h> #include <linux/syscore_ops.h> #include <soc/sa1100/pwer.h> #include <mach/hardware.h> @@ -322,7 +323,6 @@ static const int sa1100_gpio_irqs[] __initconst = {void __init sa1100_init_gpio (void ) {struct sa1100_gpio_chip *sgc = &sa1100_gpio_chip; -struct gpio_chip *gc = &sgc->chip;int i;/* clear all GPIO edge detects */ @@ -330,10 +330,6 @@ void __init sa1100_init_gpio(void)writel_relaxed (0 , sgc->membase +R_GRER );writel_relaxed (-1 , sgc->membase +R_GEDR ); -software_node_register (&sa1100_gpiochip_node); - gc->fwnode =software_node_fwnode (&sa1100_gpiochip_node); -gpiochip_add_data (gc,NULL ); - sa1100_gpio_irqdomain =irq_domain_create_simple (NULL ,28 ,IRQ_GPIO0 , &sa1100_gpio_irqdomain_ops, sgc);@@ -342,3 +338,29 @@ void __init sa1100_init_gpio(void)irq_set_chained_handler_and_data (sa1100_gpio_irqs[i], sa1100_gpio_handler, sgc); } + +static int __init sa1100_gpio_init_chip (void ) +{ +struct gpio_chip *gc = &sa1100_gpio_chip.chip; +int error; + + error =software_node_register (&sa1100_gpiochip_node); +if (error) { +pr_err ("failed to register sa1100 gpiochip software node: %d\n" , + error); +return error; + } + + gc->fwnode =software_node_fwnode (&sa1100_gpiochip_node); + + error =gpiochip_add_data (gc,NULL ); +if (error) { +pr_err ("failed to add sa1100 gpiochip: %d\n" , error); + gc->fwnode =NULL ; +software_node_unregister (&sa1100_gpiochip_node); +return error; + } + +return 0 ; +} +postcore_initcall (sa1100_gpio_init_chip); ---base-commit:
6d0933ae9d46674a6ea63a87e9e9ab4e662670c9
change-id: 20261029-sa1100-swnode-fix-11499713eb7aThanks.
Bartosz Golaszewski
AppliedQuoted 8 lines · Dmitry Torokhov
Registering the software node and the GPIO chip for the SA-1100 GPIO controller during early IRQ initialization causes boot hangs on SA-1100 platforms because the software node subsystem has not yet been initialized. At that early boot stage, attempting to register software nodes dereferences a NULL kset pointer before console or driver model initialization.
[...]
Applied, thanks!
[1/1] gpio: sa1100: defer GPIO chip registration to postcore_initcall
https://git.kernel.org/brgl/c/32c89e32b3fef2ee0aa5c4d0b0fb089bb20b3223
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>