Skip to content

Commit b499b45

Browse files
committed
rockchip/64: import mainline patch to fix gpio can_sleep issue
1 parent 956b703 commit b499b45

4 files changed

Lines changed: 326 additions & 38 deletions

File tree

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,88 @@
1-
From 3cb7c8fb18e76cb9d02935871b531b4cfd22bfb8 Mon Sep 17 00:00:00 2001
2-
From: Paolo Sabatino <paolo.sabatino@gmail.com>
3-
Date: Fri, 30 Jan 2026 22:58:25 +0100
4-
Subject: [PATCH] rockchip: declare back rockchip gpio non-sleeping
1+
From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001
2+
From: Robin Murphy <robin.murphy@arm.com>
3+
Date: Mon, 26 Jan 2026 12:12:26 +0000
4+
Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction
55

6-
* linux kernel commit 20cf2aed89ac6d78a0122e31c875228e15247194
7-
declared rockchip GPIO driver as sleeping because some
8-
helpers use mutexes in shared GPIO context. We declare
9-
gpio driver non-sleeping as it was before because 32 bit
10-
rockchip platforms should not use shared gpios so far.
11-
This fixes at least huge number of warnings about
12-
gpiod_get_value() call when gpio-ir-recv remote controller
13-
driver receives input
6+
Marking the whole controller as sleeping due to the pinctrl calls in the
7+
.direction_{input,output} callbacks has the unfortunate side effect that
8+
legitimate invocations of .get and .set, which cannot themselves sleep,
9+
in atomic context now spew WARN()s from gpiolib.
10+
11+
However, as Heiko points out, the driver doing this is a bit silly to
12+
begin with, as the pinctrl .gpio_set_direction hook doesn't even care
13+
about the direction, the hook is only used to claim the mux. And sure
14+
enough, the .gpio_request_enable hook exists to serve this very purpose,
15+
so switch to that and remove the problematic business entirely.
16+
17+
Cc: stable@vger.kernel.org
18+
Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping")
19+
Suggested-by: Heiko Stuebner <heiko@sntech.de>
20+
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
21+
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
22+
Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com
23+
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1424
---
15-
drivers/gpio/gpio-rockchip.c | 1 -
16-
1 file changed, 1 deletion(-)
25+
drivers/gpio/gpio-rockchip.c | 8 --------
26+
drivers/pinctrl/pinctrl-rockchip.c | 9 ++++-----
27+
2 files changed, 4 insertions(+), 13 deletions(-)
1728

1829
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
19-
index bae2061f15fc..47174eb3ba76 100644
30+
index bae2061f15fc47..0fff4a699f12d1 100644
2031
--- a/drivers/gpio/gpio-rockchip.c
2132
+++ b/drivers/gpio/gpio-rockchip.c
22-
@@ -593,7 +593,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
33+
@@ -18,7 +18,6 @@
34+
#include <linux/of.h>
35+
#include <linux/of_address.h>
36+
#include <linux/of_irq.h>
37+
-#include <linux/pinctrl/consumer.h>
38+
#include <linux/pinctrl/pinconf-generic.h>
39+
#include <linux/platform_device.h>
40+
#include <linux/regmap.h>
41+
@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
42+
unsigned long flags;
43+
u32 data = input ? 0 : 1;
44+
45+
-
46+
- if (input)
47+
- pinctrl_gpio_direction_input(chip, offset);
48+
- else
49+
- pinctrl_gpio_direction_output(chip, offset);
50+
-
51+
raw_spin_lock_irqsave(&bank->slock, flags);
52+
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
53+
raw_spin_unlock_irqrestore(&bank->slock, flags);
54+
@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
2355
gc->ngpio = bank->nr_pins;
2456
gc->label = bank->name;
2557
gc->parent = bank->dev;
2658
- gc->can_sleep = true;
2759

2860
ret = gpiochip_add_data(gc, bank);
2961
if (ret) {
30-
--
31-
2.43.0
32-
62+
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
63+
index e44ef262beec6e..2fc67aeafdb39e 100644
64+
--- a/drivers/pinctrl/pinctrl-rockchip.c
65+
+++ b/drivers/pinctrl/pinctrl-rockchip.c
66+
@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
67+
return 0;
68+
}
69+
70+
-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
71+
- struct pinctrl_gpio_range *range,
72+
- unsigned offset,
73+
- bool input)
74+
+static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
75+
+ struct pinctrl_gpio_range *range,
76+
+ unsigned int offset)
77+
{
78+
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
79+
struct rockchip_pin_bank *bank;
80+
@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = {
81+
.get_function_name = rockchip_pmx_get_func_name,
82+
.get_function_groups = rockchip_pmx_get_groups,
83+
.set_mux = rockchip_pmx_set,
84+
- .gpio_set_direction = rockchip_pmx_gpio_set_direction,
85+
+ .gpio_request_enable = rockchip_pmx_gpio_request_enable,
86+
};
87+
88+
/*
Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,88 @@
1-
From 3cb7c8fb18e76cb9d02935871b531b4cfd22bfb8 Mon Sep 17 00:00:00 2001
2-
From: Paolo Sabatino <paolo.sabatino@gmail.com>
3-
Date: Fri, 30 Jan 2026 22:58:25 +0100
4-
Subject: [PATCH] rockchip: declare back rockchip gpio non-sleeping
1+
From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001
2+
From: Robin Murphy <robin.murphy@arm.com>
3+
Date: Mon, 26 Jan 2026 12:12:26 +0000
4+
Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction
55

6-
* linux kernel commit 20cf2aed89ac6d78a0122e31c875228e15247194
7-
declared rockchip GPIO driver as sleeping because some
8-
helpers use mutexes in shared GPIO context. We declare
9-
gpio driver non-sleeping as it was before because 32 bit
10-
rockchip platforms should not use shared gpios so far.
11-
This fixes at least huge number of warnings about
12-
gpiod_get_value() call when gpio-ir-recv remote controller
13-
driver receives input
6+
Marking the whole controller as sleeping due to the pinctrl calls in the
7+
.direction_{input,output} callbacks has the unfortunate side effect that
8+
legitimate invocations of .get and .set, which cannot themselves sleep,
9+
in atomic context now spew WARN()s from gpiolib.
10+
11+
However, as Heiko points out, the driver doing this is a bit silly to
12+
begin with, as the pinctrl .gpio_set_direction hook doesn't even care
13+
about the direction, the hook is only used to claim the mux. And sure
14+
enough, the .gpio_request_enable hook exists to serve this very purpose,
15+
so switch to that and remove the problematic business entirely.
16+
17+
Cc: stable@vger.kernel.org
18+
Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping")
19+
Suggested-by: Heiko Stuebner <heiko@sntech.de>
20+
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
21+
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
22+
Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com
23+
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1424
---
15-
drivers/gpio/gpio-rockchip.c | 1 -
16-
1 file changed, 1 deletion(-)
25+
drivers/gpio/gpio-rockchip.c | 8 --------
26+
drivers/pinctrl/pinctrl-rockchip.c | 9 ++++-----
27+
2 files changed, 4 insertions(+), 13 deletions(-)
1728

1829
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
19-
index bae2061f15fc..47174eb3ba76 100644
30+
index bae2061f15fc47..0fff4a699f12d1 100644
2031
--- a/drivers/gpio/gpio-rockchip.c
2132
+++ b/drivers/gpio/gpio-rockchip.c
22-
@@ -593,7 +593,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
33+
@@ -18,7 +18,6 @@
34+
#include <linux/of.h>
35+
#include <linux/of_address.h>
36+
#include <linux/of_irq.h>
37+
-#include <linux/pinctrl/consumer.h>
38+
#include <linux/pinctrl/pinconf-generic.h>
39+
#include <linux/platform_device.h>
40+
#include <linux/regmap.h>
41+
@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
42+
unsigned long flags;
43+
u32 data = input ? 0 : 1;
44+
45+
-
46+
- if (input)
47+
- pinctrl_gpio_direction_input(chip, offset);
48+
- else
49+
- pinctrl_gpio_direction_output(chip, offset);
50+
-
51+
raw_spin_lock_irqsave(&bank->slock, flags);
52+
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
53+
raw_spin_unlock_irqrestore(&bank->slock, flags);
54+
@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
2355
gc->ngpio = bank->nr_pins;
2456
gc->label = bank->name;
2557
gc->parent = bank->dev;
2658
- gc->can_sleep = true;
2759

2860
ret = gpiochip_add_data(gc, bank);
2961
if (ret) {
30-
--
31-
2.43.0
32-
62+
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
63+
index e44ef262beec6e..2fc67aeafdb39e 100644
64+
--- a/drivers/pinctrl/pinctrl-rockchip.c
65+
+++ b/drivers/pinctrl/pinctrl-rockchip.c
66+
@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
67+
return 0;
68+
}
69+
70+
-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
71+
- struct pinctrl_gpio_range *range,
72+
- unsigned offset,
73+
- bool input)
74+
+static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
75+
+ struct pinctrl_gpio_range *range,
76+
+ unsigned int offset)
77+
{
78+
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
79+
struct rockchip_pin_bank *bank;
80+
@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = {
81+
.get_function_name = rockchip_pmx_get_func_name,
82+
.get_function_groups = rockchip_pmx_get_groups,
83+
.set_mux = rockchip_pmx_set,
84+
- .gpio_set_direction = rockchip_pmx_gpio_set_direction,
85+
+ .gpio_request_enable = rockchip_pmx_gpio_request_enable,
86+
};
87+
88+
/*
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001
2+
From: Robin Murphy <robin.murphy@arm.com>
3+
Date: Mon, 26 Jan 2026 12:12:26 +0000
4+
Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction
5+
6+
Marking the whole controller as sleeping due to the pinctrl calls in the
7+
.direction_{input,output} callbacks has the unfortunate side effect that
8+
legitimate invocations of .get and .set, which cannot themselves sleep,
9+
in atomic context now spew WARN()s from gpiolib.
10+
11+
However, as Heiko points out, the driver doing this is a bit silly to
12+
begin with, as the pinctrl .gpio_set_direction hook doesn't even care
13+
about the direction, the hook is only used to claim the mux. And sure
14+
enough, the .gpio_request_enable hook exists to serve this very purpose,
15+
so switch to that and remove the problematic business entirely.
16+
17+
Cc: stable@vger.kernel.org
18+
Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping")
19+
Suggested-by: Heiko Stuebner <heiko@sntech.de>
20+
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
21+
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
22+
Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com
23+
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
24+
---
25+
drivers/gpio/gpio-rockchip.c | 8 --------
26+
drivers/pinctrl/pinctrl-rockchip.c | 9 ++++-----
27+
2 files changed, 4 insertions(+), 13 deletions(-)
28+
29+
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
30+
index bae2061f15fc47..0fff4a699f12d1 100644
31+
--- a/drivers/gpio/gpio-rockchip.c
32+
+++ b/drivers/gpio/gpio-rockchip.c
33+
@@ -18,7 +18,6 @@
34+
#include <linux/of.h>
35+
#include <linux/of_address.h>
36+
#include <linux/of_irq.h>
37+
-#include <linux/pinctrl/consumer.h>
38+
#include <linux/pinctrl/pinconf-generic.h>
39+
#include <linux/platform_device.h>
40+
#include <linux/regmap.h>
41+
@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
42+
unsigned long flags;
43+
u32 data = input ? 0 : 1;
44+
45+
-
46+
- if (input)
47+
- pinctrl_gpio_direction_input(chip, offset);
48+
- else
49+
- pinctrl_gpio_direction_output(chip, offset);
50+
-
51+
raw_spin_lock_irqsave(&bank->slock, flags);
52+
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
53+
raw_spin_unlock_irqrestore(&bank->slock, flags);
54+
@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
55+
gc->ngpio = bank->nr_pins;
56+
gc->label = bank->name;
57+
gc->parent = bank->dev;
58+
- gc->can_sleep = true;
59+
60+
ret = gpiochip_add_data(gc, bank);
61+
if (ret) {
62+
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
63+
index e44ef262beec6e..2fc67aeafdb39e 100644
64+
--- a/drivers/pinctrl/pinctrl-rockchip.c
65+
+++ b/drivers/pinctrl/pinctrl-rockchip.c
66+
@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
67+
return 0;
68+
}
69+
70+
-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
71+
- struct pinctrl_gpio_range *range,
72+
- unsigned offset,
73+
- bool input)
74+
+static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
75+
+ struct pinctrl_gpio_range *range,
76+
+ unsigned int offset)
77+
{
78+
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
79+
struct rockchip_pin_bank *bank;
80+
@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = {
81+
.get_function_name = rockchip_pmx_get_func_name,
82+
.get_function_groups = rockchip_pmx_get_groups,
83+
.set_mux = rockchip_pmx_set,
84+
- .gpio_set_direction = rockchip_pmx_gpio_set_direction,
85+
+ .gpio_request_enable = rockchip_pmx_gpio_request_enable,
86+
};
87+
88+
/*
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From 7ca497be00163610afb663867db24ac408752f13 Mon Sep 17 00:00:00 2001
2+
From: Robin Murphy <robin.murphy@arm.com>
3+
Date: Mon, 26 Jan 2026 12:12:26 +0000
4+
Subject: [PATCH] gpio: rockchip: Stop calling pinctrl for set_direction
5+
6+
Marking the whole controller as sleeping due to the pinctrl calls in the
7+
.direction_{input,output} callbacks has the unfortunate side effect that
8+
legitimate invocations of .get and .set, which cannot themselves sleep,
9+
in atomic context now spew WARN()s from gpiolib.
10+
11+
However, as Heiko points out, the driver doing this is a bit silly to
12+
begin with, as the pinctrl .gpio_set_direction hook doesn't even care
13+
about the direction, the hook is only used to claim the mux. And sure
14+
enough, the .gpio_request_enable hook exists to serve this very purpose,
15+
so switch to that and remove the problematic business entirely.
16+
17+
Cc: stable@vger.kernel.org
18+
Fixes: 20cf2aed89ac ("gpio: rockchip: mark the GPIO controller as sleeping")
19+
Suggested-by: Heiko Stuebner <heiko@sntech.de>
20+
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
21+
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
22+
Link: https://lore.kernel.org/r/bddc0469f25843ca5ae0cf578ab3671435ae98a7.1769429546.git.robin.murphy@arm.com
23+
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
24+
---
25+
drivers/gpio/gpio-rockchip.c | 8 --------
26+
drivers/pinctrl/pinctrl-rockchip.c | 9 ++++-----
27+
2 files changed, 4 insertions(+), 13 deletions(-)
28+
29+
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
30+
index bae2061f15fc47..0fff4a699f12d1 100644
31+
--- a/drivers/gpio/gpio-rockchip.c
32+
+++ b/drivers/gpio/gpio-rockchip.c
33+
@@ -18,7 +18,6 @@
34+
#include <linux/of.h>
35+
#include <linux/of_address.h>
36+
#include <linux/of_irq.h>
37+
-#include <linux/pinctrl/consumer.h>
38+
#include <linux/pinctrl/pinconf-generic.h>
39+
#include <linux/platform_device.h>
40+
#include <linux/regmap.h>
41+
@@ -164,12 +163,6 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
42+
unsigned long flags;
43+
u32 data = input ? 0 : 1;
44+
45+
-
46+
- if (input)
47+
- pinctrl_gpio_direction_input(chip, offset);
48+
- else
49+
- pinctrl_gpio_direction_output(chip, offset);
50+
-
51+
raw_spin_lock_irqsave(&bank->slock, flags);
52+
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
53+
raw_spin_unlock_irqrestore(&bank->slock, flags);
54+
@@ -593,7 +586,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
55+
gc->ngpio = bank->nr_pins;
56+
gc->label = bank->name;
57+
gc->parent = bank->dev;
58+
- gc->can_sleep = true;
59+
60+
ret = gpiochip_add_data(gc, bank);
61+
if (ret) {
62+
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
63+
index e44ef262beec6e..2fc67aeafdb39e 100644
64+
--- a/drivers/pinctrl/pinctrl-rockchip.c
65+
+++ b/drivers/pinctrl/pinctrl-rockchip.c
66+
@@ -3545,10 +3545,9 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
67+
return 0;
68+
}
69+
70+
-static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
71+
- struct pinctrl_gpio_range *range,
72+
- unsigned offset,
73+
- bool input)
74+
+static int rockchip_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
75+
+ struct pinctrl_gpio_range *range,
76+
+ unsigned int offset)
77+
{
78+
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
79+
struct rockchip_pin_bank *bank;
80+
@@ -3562,7 +3561,7 @@ static const struct pinmux_ops rockchip_pmx_ops = {
81+
.get_function_name = rockchip_pmx_get_func_name,
82+
.get_function_groups = rockchip_pmx_get_groups,
83+
.set_mux = rockchip_pmx_set,
84+
- .gpio_set_direction = rockchip_pmx_gpio_set_direction,
85+
+ .gpio_request_enable = rockchip_pmx_gpio_request_enable,
86+
};
87+
88+
/*

0 commit comments

Comments
 (0)