From b499b4536896b756114206edf64fd26f136177cb Mon Sep 17 00:00:00 2001 From: Paolo Sabatino Date: Sun, 1 Feb 2026 14:32:16 +0100 Subject: [PATCH] rockchip/64: import mainline patch to fix gpio can_sleep issue --- .../general-gpio-driver-no-sleep.patch | 94 +++++++++++++++---- .../general-gpio-driver-no-sleep.patch | 94 +++++++++++++++---- .../general-gpio-driver-no-sleep.patch | 88 +++++++++++++++++ .../general-gpio-driver-no-sleep.patch | 88 +++++++++++++++++ 4 files changed, 326 insertions(+), 38 deletions(-) create mode 100644 patch/kernel/archive/rockchip64-6.18/general-gpio-driver-no-sleep.patch create mode 100644 patch/kernel/archive/rockchip64-6.19/general-gpio-driver-no-sleep.patch diff --git a/patch/kernel/archive/rockchip-6.18/patches.armbian/general-gpio-driver-no-sleep.patch b/patch/kernel/archive/rockchip-6.18/patches.armbian/general-gpio-driver-no-sleep.patch index 1140776ac0..1cf71a2152 100644 --- a/patch/kernel/archive/rockchip-6.18/patches.armbian/general-gpio-driver-no-sleep.patch +++ b/patch/kernel/archive/rockchip-6.18/patches.armbian/general-gpio-driver-no-sleep.patch @@ -1,25 +1,57 @@ -From 3cb7c8fb18e76cb9d02935871b531b4cfd22bfb8 Mon Sep 17 00:00:00 2001 -From: Paolo Sabatino -Date: Fri, 30 Jan 2026 22:58:25 +0100 -Subject: [PATCH] rockchip: declare back rockchip gpio non-sleeping +From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Mon, 26 Jan 2026 12:12:26 +0000 +Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction - * linux kernel commit 20cf2aed89ac6d78a0122e31c875228e15247194 - declared rockchip GPIO driver as sleeping because some - helpers use mutexes in shared GPIO context. We declare - gpio driver non-sleeping as it was before because 32 bit - rockchip platforms should not use shared gpios so far. - This fixes at least huge number of warnings about - gpiod_get_value() call when gpio-ir-recv remote controller - driver receives input +Marking the whole controller as sleeping due to the pinctrl calls in the +.direction_{input,output} callbacks has the unfortunate side effect that +legitimate invocations of .get and .set, which cannot themselves sleep, +in atomic context now spew WARN()s from gpiolib. + +However, as Heiko points out, the driver doing this is a bit silly to +begin with, as the pinctrl .gpio_set_direction hook doesn't even care +about the direction, the hook is only used to claim the mux. And sure +enough, the .gpio_request_enable hook exists to serve this very purpose, +so switch to that and remove the problematic business entirely. + +Cc: stable@vger.kernel.org +Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping") +Suggested-by: Heiko Stuebner +Signed-off-by: Robin Murphy +Reviewed-by: Heiko Stuebner +Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com +Signed-off-by: Bartosz Golaszewski --- - drivers/gpio/gpio-rockchip.c | 1 - - 1 file changed, 1 deletion(-) + drivers/gpio/gpio-rockchip.c | 8 -------- + drivers/pinctrl/pinctrl-rockchip.c | 9 ++++----- + 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c -index bae2061f15fc..47174eb3ba76 100644 +index bae2061f15fc47..0fff4a699f12d1 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c -@@ -593,7 +593,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) +@@ -18,7 +18,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip, + unsigned long flags; + u32 data = input ? 0 : 1; + +- +- if (input) +- pinctrl_gpio_direction_input(chip, offset); +- else +- pinctrl_gpio_direction_output(chip, offset); +- + raw_spin_lock_irqsave(&bank->slock, flags); + rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr); + raw_spin_unlock_irqrestore(&bank->slock, flags); +@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) gc->ngpio = bank->nr_pins; gc->label = bank->name; gc->parent = bank->dev; @@ -27,6 +59,30 @@ index bae2061f15fc..47174eb3ba76 100644 ret = gpiochip_add_data(gc, bank); if (ret) { --- -2.43.0 - +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index e44ef262beec6e..2fc67aeafdb39e 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, + return 0; + } + +-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, +- struct pinctrl_gpio_range *range, +- unsigned offset, +- bool input) ++static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, ++ struct pinctrl_gpio_range *range, ++ unsigned int offset) + { + struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); + struct rockchip_pin_bank *bank; +@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = { + .get_function_name = rockchip_pmx_get_func_name, + .get_function_groups = rockchip_pmx_get_groups, + .set_mux = rockchip_pmx_set, +- .gpio_set_direction = rockchip_pmx_gpio_set_direction, ++ .gpio_request_enable = rockchip_pmx_gpio_request_enable, + }; + + /* diff --git a/patch/kernel/archive/rockchip-6.19/patches.armbian/general-gpio-driver-no-sleep.patch b/patch/kernel/archive/rockchip-6.19/patches.armbian/general-gpio-driver-no-sleep.patch index 1140776ac0..1cf71a2152 100644 --- a/patch/kernel/archive/rockchip-6.19/patches.armbian/general-gpio-driver-no-sleep.patch +++ b/patch/kernel/archive/rockchip-6.19/patches.armbian/general-gpio-driver-no-sleep.patch @@ -1,25 +1,57 @@ -From 3cb7c8fb18e76cb9d02935871b531b4cfd22bfb8 Mon Sep 17 00:00:00 2001 -From: Paolo Sabatino -Date: Fri, 30 Jan 2026 22:58:25 +0100 -Subject: [PATCH] rockchip: declare back rockchip gpio non-sleeping +From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Mon, 26 Jan 2026 12:12:26 +0000 +Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction - * linux kernel commit 20cf2aed89ac6d78a0122e31c875228e15247194 - declared rockchip GPIO driver as sleeping because some - helpers use mutexes in shared GPIO context. We declare - gpio driver non-sleeping as it was before because 32 bit - rockchip platforms should not use shared gpios so far. - This fixes at least huge number of warnings about - gpiod_get_value() call when gpio-ir-recv remote controller - driver receives input +Marking the whole controller as sleeping due to the pinctrl calls in the +.direction_{input,output} callbacks has the unfortunate side effect that +legitimate invocations of .get and .set, which cannot themselves sleep, +in atomic context now spew WARN()s from gpiolib. + +However, as Heiko points out, the driver doing this is a bit silly to +begin with, as the pinctrl .gpio_set_direction hook doesn't even care +about the direction, the hook is only used to claim the mux. And sure +enough, the .gpio_request_enable hook exists to serve this very purpose, +so switch to that and remove the problematic business entirely. + +Cc: stable@vger.kernel.org +Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping") +Suggested-by: Heiko Stuebner +Signed-off-by: Robin Murphy +Reviewed-by: Heiko Stuebner +Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com +Signed-off-by: Bartosz Golaszewski --- - drivers/gpio/gpio-rockchip.c | 1 - - 1 file changed, 1 deletion(-) + drivers/gpio/gpio-rockchip.c | 8 -------- + drivers/pinctrl/pinctrl-rockchip.c | 9 ++++----- + 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c -index bae2061f15fc..47174eb3ba76 100644 +index bae2061f15fc47..0fff4a699f12d1 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c -@@ -593,7 +593,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) +@@ -18,7 +18,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip, + unsigned long flags; + u32 data = input ? 0 : 1; + +- +- if (input) +- pinctrl_gpio_direction_input(chip, offset); +- else +- pinctrl_gpio_direction_output(chip, offset); +- + raw_spin_lock_irqsave(&bank->slock, flags); + rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr); + raw_spin_unlock_irqrestore(&bank->slock, flags); +@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) gc->ngpio = bank->nr_pins; gc->label = bank->name; gc->parent = bank->dev; @@ -27,6 +59,30 @@ index bae2061f15fc..47174eb3ba76 100644 ret = gpiochip_add_data(gc, bank); if (ret) { --- -2.43.0 - +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index e44ef262beec6e..2fc67aeafdb39e 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, + return 0; + } + +-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, +- struct pinctrl_gpio_range *range, +- unsigned offset, +- bool input) ++static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, ++ struct pinctrl_gpio_range *range, ++ unsigned int offset) + { + struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); + struct rockchip_pin_bank *bank; +@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = { + .get_function_name = rockchip_pmx_get_func_name, + .get_function_groups = rockchip_pmx_get_groups, + .set_mux = rockchip_pmx_set, +- .gpio_set_direction = rockchip_pmx_gpio_set_direction, ++ .gpio_request_enable = rockchip_pmx_gpio_request_enable, + }; + + /* diff --git a/patch/kernel/archive/rockchip64-6.18/general-gpio-driver-no-sleep.patch b/patch/kernel/archive/rockchip64-6.18/general-gpio-driver-no-sleep.patch new file mode 100644 index 0000000000..1cf71a2152 --- /dev/null +++ b/patch/kernel/archive/rockchip64-6.18/general-gpio-driver-no-sleep.patch @@ -0,0 +1,88 @@ +From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Mon, 26 Jan 2026 12:12:26 +0000 +Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction + +Marking the whole controller as sleeping due to the pinctrl calls in the +.direction_{input,output} callbacks has the unfortunate side effect that +legitimate invocations of .get and .set, which cannot themselves sleep, +in atomic context now spew WARN()s from gpiolib. + +However, as Heiko points out, the driver doing this is a bit silly to +begin with, as the pinctrl .gpio_set_direction hook doesn't even care +about the direction, the hook is only used to claim the mux. And sure +enough, the .gpio_request_enable hook exists to serve this very purpose, +so switch to that and remove the problematic business entirely. + +Cc: stable@vger.kernel.org +Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping") +Suggested-by: Heiko Stuebner +Signed-off-by: Robin Murphy +Reviewed-by: Heiko Stuebner +Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com +Signed-off-by: Bartosz Golaszewski +--- + drivers/gpio/gpio-rockchip.c | 8 -------- + drivers/pinctrl/pinctrl-rockchip.c | 9 ++++----- + 2 files changed, 4 insertions(+), 13 deletions(-) + +diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c +index bae2061f15fc47..0fff4a699f12d1 100644 +--- a/drivers/gpio/gpio-rockchip.c ++++ b/drivers/gpio/gpio-rockchip.c +@@ -18,7 +18,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip, + unsigned long flags; + u32 data = input ? 0 : 1; + +- +- if (input) +- pinctrl_gpio_direction_input(chip, offset); +- else +- pinctrl_gpio_direction_output(chip, offset); +- + raw_spin_lock_irqsave(&bank->slock, flags); + rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr); + raw_spin_unlock_irqrestore(&bank->slock, flags); +@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) + gc->ngpio = bank->nr_pins; + gc->label = bank->name; + gc->parent = bank->dev; +- gc->can_sleep = true; + + ret = gpiochip_add_data(gc, bank); + if (ret) { +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index e44ef262beec6e..2fc67aeafdb39e 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, + return 0; + } + +-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, +- struct pinctrl_gpio_range *range, +- unsigned offset, +- bool input) ++static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, ++ struct pinctrl_gpio_range *range, ++ unsigned int offset) + { + struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); + struct rockchip_pin_bank *bank; +@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = { + .get_function_name = rockchip_pmx_get_func_name, + .get_function_groups = rockchip_pmx_get_groups, + .set_mux = rockchip_pmx_set, +- .gpio_set_direction = rockchip_pmx_gpio_set_direction, ++ .gpio_request_enable = rockchip_pmx_gpio_request_enable, + }; + + /* diff --git a/patch/kernel/archive/rockchip64-6.19/general-gpio-driver-no-sleep.patch b/patch/kernel/archive/rockchip64-6.19/general-gpio-driver-no-sleep.patch new file mode 100644 index 0000000000..1cf71a2152 --- /dev/null +++ b/patch/kernel/archive/rockchip64-6.19/general-gpio-driver-no-sleep.patch @@ -0,0 +1,88 @@ +From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Mon, 26 Jan 2026 12:12:26 +0000 +Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction + +Marking the whole controller as sleeping due to the pinctrl calls in the +.direction_{input,output} callbacks has the unfortunate side effect that +legitimate invocations of .get and .set, which cannot themselves sleep, +in atomic context now spew WARN()s from gpiolib. + +However, as Heiko points out, the driver doing this is a bit silly to +begin with, as the pinctrl .gpio_set_direction hook doesn't even care +about the direction, the hook is only used to claim the mux. And sure +enough, the .gpio_request_enable hook exists to serve this very purpose, +so switch to that and remove the problematic business entirely. + +Cc: stable@vger.kernel.org +Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping") +Suggested-by: Heiko Stuebner +Signed-off-by: Robin Murphy +Reviewed-by: Heiko Stuebner +Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com +Signed-off-by: Bartosz Golaszewski +--- + drivers/gpio/gpio-rockchip.c | 8 -------- + drivers/pinctrl/pinctrl-rockchip.c | 9 ++++----- + 2 files changed, 4 insertions(+), 13 deletions(-) + +diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c +index bae2061f15fc47..0fff4a699f12d1 100644 +--- a/drivers/gpio/gpio-rockchip.c ++++ b/drivers/gpio/gpio-rockchip.c +@@ -18,7 +18,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip, + unsigned long flags; + u32 data = input ? 0 : 1; + +- +- if (input) +- pinctrl_gpio_direction_input(chip, offset); +- else +- pinctrl_gpio_direction_output(chip, offset); +- + raw_spin_lock_irqsave(&bank->slock, flags); + rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr); + raw_spin_unlock_irqrestore(&bank->slock, flags); +@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) + gc->ngpio = bank->nr_pins; + gc->label = bank->name; + gc->parent = bank->dev; +- gc->can_sleep = true; + + ret = gpiochip_add_data(gc, bank); + if (ret) { +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index e44ef262beec6e..2fc67aeafdb39e 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, + return 0; + } + +-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, +- struct pinctrl_gpio_range *range, +- unsigned offset, +- bool input) ++static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, ++ struct pinctrl_gpio_range *range, ++ unsigned int offset) + { + struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); + struct rockchip_pin_bank *bank; +@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = { + .get_function_name = rockchip_pmx_get_func_name, + .get_function_groups = rockchip_pmx_get_groups, + .set_mux = rockchip_pmx_set, +- .gpio_set_direction = rockchip_pmx_gpio_set_direction, ++ .gpio_request_enable = rockchip_pmx_gpio_request_enable, + }; + + /*