From: Eliav Farber <farbere@amazon.com>
To: Rodolfo Giometti <giometti@enneenne.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Fabio Estevam <festevam@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>,
Eliav Farber <farbere@amazon.com>, <devicetree@vger.kernel.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v6 0/4] pps-gpio: restore pin mux on unbind and shutdown
Date: Wed, 23 Sep 2026 18:22:39 +0000 [thread overview]
Message-ID: <20260923182243.41060-1-farbere@amazon.com> (raw)
In-Reply-To: <20260922103051.5257-1-farbere@amazon.com>
Some boards route the PPS input GPIO through a pin controller and mux the
pins to a different function when the pps-gpio driver is not active.
The driver core already selects the "default" pinctrl state before probe,
so the pins can be muxed for GPIO/PPS use while the driver is bound without
any driver change. Nothing, however, hands the pins back when the driver
is unbound or the system is shut down (for example before kexec), leaving
them stuck in the GPIO mux for the next kernel.
This series lets pps-gpio select an optional "inactive" pinctrl state in
remove() and shutdown(), so a board can describe the alternate mux there
and have it restored. The state is looked up and selected by the driver
itself (devm_pinctrl_get() + pinctrl_lookup_state() + pinctrl_select_
state()), so its meaning is unambiguous and it does not depend on
CONFIG_PM. It is a no-op for boards that do not describe an "inactive"
state.
Patch 1 is a small preparatory fix to propagate the gpiod_to_irq() and
request_threaded_irq() error codes (rather than a hardcoded -EINVAL) on
the probe error paths that patch 4 then converts to gotos. Patch 2 is a
small preparatory fix restoring the echo-GPIO guard in remove() that a
later cleanup dropped, since patch 4 mirrors remove()'s teardown in the
new shutdown() and would otherwise carry the same latent issue. Patch 3
documents the optional "default"/"inactive" pinctrl-names in the binding;
patch 4 implements the driver side.
Tested on an Amazon AL11 K2V6 JRD10 board: binding/unbinding each pps-gpio
device toggles the corresponding pin-mux register between the GPIO
function and the alternate ec_ptp_trigger_in function as expected, and
re-binding restores the GPIO function via the core-applied "default"
state. Reading the mux register with the device left unbound confirms the
"inactive" mux persists. Also tested with a pps-gpio node that describes
no pinctrl at all, where probe, remove and shutdown behave as before.
For the probe-failure path (see below), a forced-defer test confirmed that
a probe failing after pps_gpio_get_pins() releases the pins to "inactive",
the core re-applies "default" before the next attempt, and the mux settles
back at "default" once probe finally succeeds, with no spurious PPS event
or warning across the cycles.
Changes in v6:
- Patch 4: fold the pps_register_source() failure path into the same
dev_err_probe() + goto err_release_pins style as the other two paths
sharing that label, with a commit-message note that it is a logging
change, not a fix (Rodolfo Giometti)
- Patch 3: unchanged. Rob Herring confirmed the two-entry
["default", "inactive"] items list is fine as-is; the "sleep" state
discussed on the list is not something this binding needs
- No other functional changes
Changes in v5:
- Patch 1: use dev_err_probe() on both error paths instead of a bare
dev_err() + return, so the propagated -EPROBE_DEFER is logged at debug
level rather than spamming the console and the code is emitted
symbolically. Drop Bartosz's Reviewed-by as the patch changed
materially (Rodolfo Giometti)
- New patch 2: restore the data->echo_pin guard around the echo-timer
teardown in remove(), dropped by commit fde046a8c490. timer_delete_sync()
on a never-initialised timer trips debug_assert_init() under
CONFIG_DEBUG_OBJECTS_TIMERS. Split out so patch 4's new shutdown() does
not reintroduce it (Rodolfo Giometti)
- Patch 4: resolve the v4 probe-failure open question by taking option "A
+ keep the NULL guard": look the pinctrl states up first in probe(),
before pps_gpio_setup(), and route the setup() failure through
err_release_pins too, so every path the driver can act on restores
"inactive". Guard the echo-timer teardown in the new shutdown() with
data->echo_pin, matching remove() (Rodolfo Giometti)
Changes in v4:
- Patch 1: add Fixes: 161520451dfa and Bartosz Golaszewski's Reviewed-by.
The hardcoded -EINVAL predates 4461d65176b4, so the tag points at the
original driver rather than the descriptor conversion
- Patch (binding): rework per Rob Herring - drop the prose, use an ordered
"items" list ("default" then "inactive") with minItems: 1, fixing the
"['default', 'inactive'] is too long" dt_binding_check error
Changes in v3 (addressing Sashiko's and Rodolfo Giometti's review):
- New preparatory patch to propagate the gpiod_to_irq() and
request_threaded_irq() error codes instead of overwriting them with
-EINVAL
- Do not constrain pinctrl-names to a fixed ["default", "inactive"] tuple
- Treat -ENODEV from devm_pinctrl_get() as "no pinctrl described" rather
than a probe failure; keep propagating everything else incl.
-EPROBE_DEFER
- Restore the "inactive" mux on probe failure via a new err_release_pins
label
- Warn if applying the "inactive" state fails rather than ignoring the
pinctrl_select_state() return
Changes in v2 (all addressing Rodolfo Giometti's review):
- Rename the released state from "idle" to "inactive" ("idle" is the
runtime-PM state in pinctrl-state.h)
- Look the state up in the driver instead of pinctrl_pm_select_idle_state(),
removing the CONFIG_PM dependency
- Fix shutdown(): tear down (free_irq/timer) before the mux change,
matching remove()
- Require a "default" state whenever "inactive" is present and reject the
mismatch
Link: https://lore.kernel.org/all/20260916134744.46354-1-farbere@amazon.com/ [v1]
Link: https://lore.kernel.org/all/20260916182641.9768-1-farbere@amazon.com/ [v2]
Link: https://lore.kernel.org/all/20260917075611.47881-1-farbere@amazon.com/ [v3]
Link: https://lore.kernel.org/all/20260919171157.5502-1-farbere@amazon.com/ [v4]
Link: https://lore.kernel.org/all/20260922103051.5257-1-farbere@amazon.com/ [v5]
Eliav Farber (4):
pps: clients: gpio: propagate probe error codes
pps: clients: gpio: only tear down the echo timer when it exists
dt-bindings: pps: pps-gpio: document optional pinctrl states
pps: clients: gpio: release pins to an inactive state on remove and
shutdown
.../devicetree/bindings/pps/pps-gpio.yaml | 14 +-
drivers/pps/clients/pps-gpio.c | 127 ++++++++++++++++--
2 files changed, 129 insertions(+), 12 deletions(-)
base-commit: 93f51579e7df248780214094418f205253383cc5
--
2.47.3
next prev parent reply other threads:[~2026-09-23 18:22 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 13:47 [PATCH 0/2] " 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 ` Eliav Farber [this message]
2026-09-23 18:22 ` [PATCH v6 1/4] pps: clients: gpio: propagate probe error codes Eliav Farber
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-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-23 18:22 ` [PATCH v6 4/4] pps: clients: gpio: release pins to an inactive state on remove and shutdown Eliav Farber
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=20260923182243.41060-1-farbere@amazon.com \
--to=farbere@amazon.com \
--cc=akpm@linux-foundation.org \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=giometti@enneenne.com \
--cc=krzk+dt@kernel.org \
--cc=linusw@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®