Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eliav Farber" <farbere@amazon.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 2/2] pps: clients: gpio: release pins to an inactive state on remove and shutdown
Date: Wed, 16 Sep 2026 18:43:25 +0000	[thread overview]
Message-ID: <20260916184326.4C6661F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916182641.9768-3-farbere@amazon.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] pps-gpio: unconditional probe failure for boards without pinctrl bindings
- [Medium] pps-gpio: pins left in 'default' state on probe failure
--

commit 8a9e09ee4e79423b318933ea7fb883c1d285a638
Author: Eliav Farber <farbere@amazon.com>

pps: clients: gpio: release pins to an inactive state on remove and shutdown

This patch looks up an optional "inactive" pinctrl state in probe and
selects it on remove and shutdown to release the pins. The goal is to
prevent pins from staying stuck in the GPIO function for subsequent
executions like kexec or after the driver is unbound.

> diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
> index 73ec2c7335e51..e619c7bb2f78a 100644
> --- a/drivers/pps/clients/pps-gpio.c
> +++ b/drivers/pps/clients/pps-gpio.c

[ ... ]

> @@ -96,6 +99,51 @@ static void pps_gpio_echo_timer_callback(struct timer_list *t)
>  	gpiod_set_value(info->echo_pin, 0);
>  }
>  
> +/*
> + * Look up the optional "inactive" pinctrl state: the mux to restore when
> + * pps-gpio is unbound or the system is shut down. It is only meaningful
> + * paired with a "default" state, which the driver core applies before probe
> + * to mux the pins for PPS use. A board that describes neither is unaffected;
> + * one that describes "inactive" without "default" is rejected, since
> + * releasing pins that were never put into a defined PPS state is incoherent.
> + */
> +static int pps_gpio_get_pins(struct device *dev)
> +{
> +	struct pps_gpio_device_data *data = dev_get_drvdata(dev);
> +	struct pinctrl_state *pins_default;
> +
> +	data->pinctrl = devm_pinctrl_get(dev);
> +	if (IS_ERR(data->pinctrl))
> +		return dev_err_probe(dev, PTR_ERR(data->pinctrl),
> +				     "failed to get pinctrl\n");

[Severity: High]
If a board doesn't have explicit pinctrl bindings, won't devm_pinctrl_get()
return -ENODEV?

The driver core typically ignores -ENODEV to support devices without explicit
pinmuxes. Would treating it as a fatal error here cause the probe to fail
unconditionally on those boards and break existing setups?

> +
> +	/* The "inactive" state is optional; without it there is nothing to do. */
> +	data->pins_inactive = pinctrl_lookup_state(data->pinctrl, "inactive");
> +	if (IS_ERR(data->pins_inactive)) {
> +		data->pins_inactive = NULL;
> +		return 0;
> +	}

[ ... ]

> @@ -161,6 +209,11 @@ static int pps_gpio_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> +	/* pinctrl setup (optional states) */
> +	ret = pps_gpio_get_pins(dev);
> +	if (ret)
> +		return ret;
> +
>  	/* IRQ setup */
>  	ret = gpiod_to_irq(data->gpio_pin);
>  	if (ret < 0) {

[Severity: Medium]
If an error occurs later in the probe function, for example in gpiod_to_irq()
or pps_register_source(), the function returns early:

pps_gpio_probe() {
	...
	ret = gpiod_to_irq(data->gpio_pin);
	if (ret < 0) {
		dev_err(dev, "failed to map GPIO to IRQ: %d\n", ret);
		return -EINVAL;
	}
	...
}

Since the driver core applies the 'default' pinctrl state before probe begins,
and these error paths exit without calling pps_gpio_release_pins(), would
the pins be left stuck in the 'default' state if probe fails?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916182641.9768-1-farbere@amazon.com?part=2

  reply	other threads:[~2026-09-16 18:43 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 13:47 [PATCH 0/2] pps-gpio: restore pin mux on unbind and shutdown Eliav Farber
2026-09-16 13:47 ` [PATCH 1/2] dt-bindings: pps: pps-gpio: document optional idle pinctrl state Eliav Farber
2026-09-16 13:47 ` [PATCH 2/2] pps: clients: gpio: release pins to idle state on remove and shutdown Eliav Farber
2026-09-16 13:57   ` sashiko-bot
2026-09-16 16:48 ` [PATCH 0/2] pps-gpio: restore pin mux on unbind " Rodolfo Giometti
2026-09-16 18:25   ` Farber, Eliav
2026-09-16 18:26 ` [PATCH v2 " Eliav Farber
2026-09-16 18:26   ` [PATCH v2 1/2] dt-bindings: pps: pps-gpio: document optional pinctrl states Eliav Farber
2026-09-17  7:13     ` Rodolfo Giometti
2026-09-17  7:48       ` Farber, Eliav
2026-09-16 18:26   ` [PATCH v2 2/2] pps: clients: gpio: release pins to an inactive state on remove and shutdown Eliav Farber
2026-09-16 18:43     ` sashiko-bot [this message]
2026-09-17  7:14     ` Rodolfo Giometti
2026-09-17  7:52       ` Farber, Eliav
2026-09-17  7:56   ` [PATCH v3 0/3] pps-gpio: restore pin mux on unbind " Eliav Farber
2026-09-17  7:56     ` [PATCH v3 1/3] pps: clients: gpio: propagate probe error codes Eliav Farber
2026-09-17  8:04       ` sashiko-bot
2026-09-17  9:58       ` Bartosz Golaszewski
2026-09-18  7:50       ` Rodolfo Giometti
2026-09-17  7:56     ` [PATCH v3 2/3] dt-bindings: pps: pps-gpio: document optional pinctrl states Eliav Farber
2026-09-17 15:35       ` Rob Herring (Arm)
2026-09-17 16:13       ` Rob Herring
2026-09-18  7:50       ` Rodolfo Giometti
2026-09-18 15:43         ` Rob Herring
2026-09-17  7:56     ` [PATCH v3 3/3] pps: clients: gpio: release pins to an inactive state on remove and shutdown Eliav Farber
2026-09-17  8:10       ` sashiko-bot
2026-09-19 17:11     ` [PATCH v4 0/3] pps-gpio: restore pin mux on unbind " Eliav Farber
2026-09-22  7:40       ` Rodolfo Giometti
2026-09-22 10:08         ` Farber, Eliav
2026-09-22 10:30       ` [PATCH v5 0/4] " Eliav Farber
2026-09-22 10:30         ` [PATCH v5 1/4] pps: clients: gpio: propagate probe error codes Eliav Farber
2026-09-22 10:30         ` [PATCH v5 2/4] pps: clients: gpio: only tear down the echo timer when it exists Eliav Farber
2026-09-22 10:30         ` [PATCH v5 3/4] dt-bindings: pps: pps-gpio: document optional pinctrl states Eliav Farber
2026-09-22 12:46           ` Rodolfo Giometti
2026-09-23 12:36             ` Rob Herring
2026-09-23 13:13               ` Farber, Eliav
2026-09-23 18:04                 ` Rob Herring
2026-09-22 10:30         ` [PATCH v5 4/4] pps: clients: gpio: release pins to an inactive state on remove and shutdown Eliav Farber
2026-09-22 10:39           ` sashiko-bot
2026-09-22 12:46           ` Rodolfo Giometti
2026-09-22 14:55             ` Farber, Eliav
2026-09-23  7:50               ` Rodolfo Giometti
2026-09-23 18:22         ` [PATCH v6 0/4] pps-gpio: restore pin mux on unbind " Eliav Farber
2026-09-23 18:22           ` [PATCH v6 1/4] pps: clients: gpio: propagate probe error codes Eliav Farber
2026-09-24 12:58             ` Rodolfo Giometti
2026-09-24 14:46             ` Bartosz Golaszewski
2026-09-23 18:22           ` [PATCH v6 2/4] pps: clients: gpio: only tear down the echo timer when it exists Eliav Farber
2026-09-24 12:59             ` Rodolfo Giometti
2026-09-24 14:47             ` Bartosz Golaszewski
2026-09-23 18:22           ` [PATCH v6 3/4] dt-bindings: pps: pps-gpio: document optional pinctrl states Eliav Farber
2026-09-23 18:41             ` Rob Herring
2026-09-24 12:59             ` Rodolfo Giometti
2026-09-23 18:22           ` [PATCH v6 4/4] pps: clients: gpio: release pins to an inactive state on remove and shutdown Eliav Farber
2026-09-24 12:59             ` Rodolfo Giometti
2026-10-01  7:53             ` Linus Walleij
2026-09-24 12:58           ` [PATCH v6 0/4] pps-gpio: restore pin mux on unbind " Rodolfo Giometti
2026-09-19 17:11     ` [PATCH v4 1/3] pps: clients: gpio: propagate probe error codes Eliav Farber
2026-09-22  7:40       ` Rodolfo Giometti
2026-09-22  8:08         ` Farber, Eliav
2026-09-22  8:22           ` Rodolfo Giometti
2026-09-22 10:06             ` Farber, Eliav
2026-09-19 17:11     ` [PATCH v4 2/3] dt-bindings: pps: pps-gpio: document optional pinctrl states Eliav Farber
2026-09-22  7:40       ` Rodolfo Giometti
2026-09-22 10:11         ` Farber, Eliav
2026-09-19 17:11     ` [PATCH v4 3/3] pps: clients: gpio: release pins to an inactive state on remove and shutdown Eliav Farber
2026-09-22  7:40       ` Rodolfo Giometti
2026-09-22 10:13         ` Farber, Eliav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260916184326.4C6661F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=farbere@amazon.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox