Re: [PATCH RESEND] reset: core: honour optional resets when the GPIO fallback is unusable

From: Philipp Zabel

Date: Tue Nov 17 2026 - 04:50:07 EST


On Di, 2026-11-17 at 17:20 +0800, Yang Siyuan wrote:
> __fwnode_reset_control_get() honours RESET_CONTROL_FLAGS_BIT_OPTIONAL for
> every failure source except the reset-gpio fallback: when
> __reset_add_reset_gpio_device() fails, the error is returned even for an
> optional reset.

RESET_CONTROL_FLAGS_BIT_OPTIONAL is only meant to replace -ENOENT with
NULL, not other error codes. See the kerneldoc of
reset_control_get_optional_exclusive():

"If the requested reset is not specified in the device tree, this
function returns NULL instead of an error."

> This is reachable on Allwinner SoCs, whose pinctrl uses three-cell GPIO
> specifiers. The reset-gpio fallback only supports two cells, so it
> returns -ENOENT and a consumer asking for an optional reset fails to
> probe instead of falling back to its own GPIO handling. mmc-pwrseq-simple
> on the Anbernic RG35XX family hits this: its wifi_pwrseq node has
> reset-gpios but no resets, so the SDIO WiFi adapter never probes.
>
> Keep propagating -EPROBE_DEFER, since the GPIO provider may be available
> later, but treat any other failure as "no reset" when the request is
> optional.
>
> Fixes: c721f189e89c ("reset: Instantiate reset GPIO controller for shared reset-gpios")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Yang Siyuan <hsyysy@xxxxxxx>
> ---
> drivers/reset/core.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 38e189d04..f2375dd17 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -1181,7 +1181,17 @@ __fwnode_reset_control_get(struct fwnode_handle *fwnode, const char *id, int ind
> ret = __reset_add_reset_gpio_device(fwnode, &args);
> if (ret) {
> fwnode_handle_put(args.fwnode);
> - return ERR_PTR(ret);
> +
> + /*
> + * The GPIO provider may just not be available yet, so
> + * EPROBE_DEFER must always be propagated. Any other
> + * failure means that the fallback cannot be used,
> + * which is not an error for an optional reset.

No, it is very much an error if an optional reset is specified in the
device tree but can't be used.

The /*TODO*/-marked -ENOENT return in __reset_add_reset_gpio_device()
is already papering over the issue.

> + */
> + if (ret == -EPROBE_DEFER || !optional)
> + return ERR_PTR(ret);
> +
> + return NULL;

I think instead this could be replaced with:

if (ret) {
fwnode_handle_put(args.fwnode);
+ if (ret == -ENOENT && optional)
+ return NULL;
return ERR_PTR(ret);

regards
Philipp