From: Linus Walleij <linusw@kernel.org>
To: Eliav Farber <farbere@amazon.com>
Cc: Rodolfo Giometti <giometti@enneenne.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Fabio Estevam <festevam@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>,
devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 4/4] pps: clients: gpio: release pins to an inactive state on remove and shutdown
Date: Thu, 1 Oct 2026 09:53:05 +0200 [thread overview]
Message-ID: <CAD++jL=cPZ1vEDgXodbmHAGd2jr+X8DdaH7yxbfN7OJMBojSpA@mail.gmail.com> (raw)
In-Reply-To: <20260923182243.41060-5-farbere@amazon.com>
On Wed, Sep 23, 2026 at 8:23 PM Eliav Farber <farbere@amazon.com> wrote:
> Some boards route the PPS input GPIO through a pin controller and need to
> mux it to another function when pps-gpio is not driving PPS. The driver
> core applies the "default" pinctrl state before probe, so the pins are
> muxed for GPIO/PPS use while the driver is bound. Nothing, however, hands
> the pins back when the driver is unbound or the system is shut down, so
> they stay stuck in the GPIO function for whatever runs next, kexec
> included.
>
> Look up an optional "inactive" pinctrl state in probe via
> devm_pinctrl_get() and pinctrl_lookup_state(), and select it with
> pinctrl_select_state() in remove() and shutdown(). The state is looked up
> and selected by the driver itself rather than reusing the runtime-PM
> "idle"/"sleep" states, so its meaning is unambiguous and it does not
> depend on CONFIG_PM. Boards that do not describe an "inactive" state are
> unaffected.
>
> Since "inactive" is only meaningful as the mux to restore after the
> core-applied "default" state, reject an "inactive" state that is not
> paired with a "default" one rather than releasing pins that were never
> put into a defined PPS state.
>
> Look up the pinctrl states first in probe(), before pps_gpio_setup(), and
> route every subsequent failure through a common err_release_pins label.
> The driver core applies the "default" mux before probe(), so a probe that
> fails after this point would otherwise leave the pins stuck in "default";
> releasing them to "inactive" on the error path is the symmetrical
> counterpart to what the core did on the driver's behalf. A failure in
> pps_gpio_get_pins() itself returns directly, as no state was taken yet;
> pps_gpio_release_pins() is a no-op when no "inactive" state was found.
>
> Convert the pps_register_source() failure path to dev_err_probe() too,
> so all three probe error paths that share err_release_pins log the same
> way. This path already returned PTR_ERR(data->pps), so this is a logging
> change, not a fix.
>
> The mux must not change while something can still drive the pins. On
> shutdown() the requested IRQ and the echo timer would otherwise outlive
> the mux change -- device_shutdown() is not the end of the road, the
> kernel keeps running to load and start the kexec image -- so a timer
> callback or the PPS handler could poke a line that by then belongs to
> another function. Tear down in the same order as remove(): free_irq()
> first, then the echo timer (only when the board has an echo GPIO, as in
> remove()), and the mux change last. shutdown() does not unregister the
> PPS source, which is a remove-time concern.
>
> Signed-off-by: Eliav Farber <farbere@amazon.com>
v6 looks reasonable to me!
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
next prev parent reply other threads:[~2026-10-01 7:53 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 13:47 [PATCH 0/2] pps-gpio: restore pin mux on unbind " 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 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-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 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-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 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 [this message]
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='CAD++jL=cPZ1vEDgXodbmHAGd2jr+X8DdaH7yxbfN7OJMBojSpA@mail.gmail.com' \
--to=linusw@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=farbere@amazon.com \
--cc=festevam@gmail.com \
--cc=giometti@enneenne.com \
--cc=krzk+dt@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®