[PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver

Wolfram Sang posted 2 patches 2 months ago
[PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Wolfram Sang 2 months ago
Optional GPIOs mean they can be omitted. If they are described, a
failure in acquiring them still needs to be reported. When the
RESET_GPIO is not enabled (so the reset core cannot provide its assumed
fallback), the user should be informed about it. So, not only bail out
but also give a hint how to fix the situation. This means the check has
to be moved after ensuring the GPIO is really described.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Changes since RFC v1:
* moved the code after second phandle check
* switched to pr_err
* updated commit message
* moved Reported-by to patch 2

 drivers/reset/core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 22f67fc77ae5..c1909074f715 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -1028,9 +1028,6 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
 	if (ret == -EINVAL)
 		return ERR_PTR(ret);
 	if (ret) {
-		if (!IS_ENABLED(CONFIG_RESET_GPIO))
-			return optional ? NULL : ERR_PTR(ret);
-
 		/*
 		 * There can be only one reset-gpio for regular devices, so
 		 * don't bother with the "reset-gpios" phandle index.
@@ -1040,6 +1037,11 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
 		if (ret)
 			return optional ? NULL : ERR_PTR(ret);
 
+		if (!IS_ENABLED(CONFIG_RESET_GPIO)) {
+			pr_err("%s(): RESET_GPIO driver not enabled, cannot fall back\n", __func__);
+			return ERR_PTR(-ENOEXEC);
+		}
+
 		gpio_fallback = true;
 
 		ret = __reset_add_reset_gpio_device(&args);
-- 
2.47.2
Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Wolfram Sang 1 month, 2 weeks ago
On Wed, Oct 15, 2025 at 10:59:21PM +0200, Wolfram Sang wrote:
> Optional GPIOs mean they can be omitted. If they are described, a
> failure in acquiring them still needs to be reported. When the
> RESET_GPIO is not enabled (so the reset core cannot provide its assumed
> fallback), the user should be informed about it. So, not only bail out
> but also give a hint how to fix the situation. This means the check has
> to be moved after ensuring the GPIO is really described.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Philipp, I reverted the offending commit in i2c-mux. You can revert this
one as well.

Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Philipp Zabel 1 month, 2 weeks ago
On Mi, 2025-10-15 at 22:59 +0200, Wolfram Sang wrote:
> Optional GPIOs mean they can be omitted. If they are described, a
> failure in acquiring them still needs to be reported. When the
> RESET_GPIO is not enabled (so the reset core cannot provide its assumed
> fallback), the user should be informed about it. So, not only bail out
> but also give a hint how to fix the situation. This means the check has
> to be moved after ensuring the GPIO is really described.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Patch 1 applied to reset/next, thanks!

[1/2] reset: always bail out on missing RESET_GPIO driver
      https://git.pengutronix.de/cgit/pza/linux/commit/?id=25d4d4604d01

regards
Philipp
Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On 30/10/2025 13:54, Philipp Zabel wrote:
> On Mi, 2025-10-15 at 22:59 +0200, Wolfram Sang wrote:
>> Optional GPIOs mean they can be omitted. If they are described, a
>> failure in acquiring them still needs to be reported. When the
>> RESET_GPIO is not enabled (so the reset core cannot provide its assumed
>> fallback), the user should be informed about it. So, not only bail out
>> but also give a hint how to fix the situation. This means the check has
>> to be moved after ensuring the GPIO is really described.
>>
>> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> 
> Patch 1 applied to reset/next, thanks!
> 
> [1/2] reset: always bail out on missing RESET_GPIO driver
>       https://git.pengutronix.de/cgit/pza/linux/commit/?id=25d4d4604d01


Why? This wasn't tested and wasn't reviewed... there were objections to
this patchset and long discussion.

Best regards,
Krzysztof
Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Wolfram Sang 1 month, 2 weeks ago
> > [1/2] reset: always bail out on missing RESET_GPIO driver
> >       https://git.pengutronix.de/cgit/pza/linux/commit/?id=25d4d4604d01
> 
> 
> Why? This wasn't tested and wasn't reviewed... there were objections to
> this patchset and long discussion.

Only to patch 2? AFAIR there was no discussion regarding patch 1.

Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
On 03/11/2025 16:12, Wolfram Sang wrote:
> 
>>> [1/2] reset: always bail out on missing RESET_GPIO driver
>>>       https://git.pengutronix.de/cgit/pza/linux/commit/?id=25d4d4604d01
>>
>>
>> Why? This wasn't tested and wasn't reviewed... there were objections to
>> this patchset and long discussion.
> 
> Only to patch 2? AFAIR there was no discussion regarding patch 1.
> 

This patch alone is broken. Breaks all users. The true problem for your
systems is of course your I2C driver commit 690de2902dca...

Best regards,
Krzysztof
Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Philipp Zabel 1 month, 2 weeks ago
On Mi, 2025-10-15 at 22:59 +0200, Wolfram Sang wrote:
> Optional GPIOs mean they can be omitted. If they are described, a
> failure in acquiring them still needs to be reported. When the
> RESET_GPIO is not enabled (so the reset core cannot provide its assumed
> fallback), the user should be informed about it. So, not only bail out
> but also give a hint how to fix the situation. This means the check has
> to be moved after ensuring the GPIO is really described.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp
Re: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Posted by Philipp Zabel 2 months ago
On Mi, 2025-10-15 at 22:59 +0200, Wolfram Sang wrote:
> Optional GPIOs mean they can be omitted. If they are described, a
> failure in acquiring them still needs to be reported. When the
> RESET_GPIO is not enabled (so the reset core cannot provide its assumed
> fallback), the user should be informed about it. So, not only bail out
> but also give a hint how to fix the situation. This means the check has
> to be moved after ensuring the GPIO is really described.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp