Hello all,
Michael is busy, and I have some extra bandwidth, so I've volunteered to
help out with the patch schlepping here. These v6 patches are based on
7.1-rc5.
This is all Michael's work, and Michael's cover letter follows. I added
lore links to the older patch versions next to his change descriptions.
Note that I replaced two emdashes in comment blocks with regular hypens
in patch 1/3, to avoid 8bit encoding.
Thanks,
Calvin
---
From: Michael Byczkowski <by@by-online.de>
This is v6 of the PPS PREEMPT_RT patchset, addressing the review
feedback from Sebastian Andrzej Siewior on v5.
Changes since v5: https://lore.kernel.org/lkml/719A31CE-CA58-45C3-A013-1BFE81F724C5@by-online.de/
- Reordered: the pps_kc_hardpps_lock conversion now precedes the
pps_device.lock conversion. The previous order would have briefly
produced a raw_spinlock holding a sleeping spinlock on PREEMPT_RT
(Sebastian).
- Patch 1/3: commit message reworded to describe the handler split
structurally first, then its PREEMPT_RT benefit (Sebastian).
- Patch 2/3: refactored pps_kc_bind() and pps_kc_remove() to use
guard(raw_spinlock_irq) for scope-based lock release. Eliminates
four duplicated unlock call sites in pps_kc_bind() and the
ambiguous bracket structure that resulted from them (Sebastian).
- Rodolfo's Acked-by on patch 2/3 is preserved from v5; the guard()
refactor is purely stylistic and was suggested by Sebastian, but
please re-ack or NAK if disagreement.
Changes since v4: https://lore.kernel.org/lkml/B24484C5-3117-4C56-9522-1EE9876E64BA@by-online.de/
- Patch 2/3: added Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Changes since v3: https://lore.kernel.org/lkml/83318241-44C3-48BE-829D-5C5F82A78A74@by-online.de/
- Patch 2/3: fixed lost indentation on pps_kc_event() call
(reported by Rodolfo Giometti <giometti@enneenne.com>)
Changes since v2: https://lore.kernel.org/lkml/1BB87C0C-33C1-45C3-B50E-C5F349DA3FDC@by-online.de/
- Patch 2/3: moved wake_up_interruptible_all() and kill_fasync() out
of raw_spinlock section to avoid sleeping-in-atomic on PREEMPT_RT
(reported by Nikolaus Buchwitz <nb@buchwitz.com>)
This patchset addresses three sources of PPS jitter under PREEMPT_RT,
while being fully backward-compatible with non-RT kernels:
1. pps-gpio: The IRQ handler is force-threaded on PREEMPT_RT, so the
PPS timestamp is captured after scheduling delay rather than at
interrupt entry. Fix: split into a hardirq primary handler
(captures timestamp only) and a threaded handler (processes the
event).
2. pps_kc_hardpps_lock: spinlock_t becomes a sleeping mutex on
PREEMPT_RT. Since pps_kc_event() calls hardpps() under this lock
and hardpps() takes the raw_spinlock_t tk_core.lock, the nesting
is invalid. Fix: convert to DEFINE_RAW_SPINLOCK.
3. pps_device.lock: same issue as (2), in the PPS event delivery
path. Fix: convert to raw_spinlock_t and move sleeping calls out
of the critical section.
All three patches are tested on a Raspberry Pi 5 running 7.0.1 and
7.1-rc PREEMPT_RT kernels. On non-RT kernels there is zero behavioral
change.
Michael Byczkowski (3):
pps: pps-gpio: split IRQ handler into hardirq timestamper + threaded
handler
pps: kc: convert pps_kc_hardpps_lock to raw_spinlock_t
pps: convert pps_device.lock to raw_spinlock_t
drivers/pps/clients/pps-gpio.c | 37 +++++++++++++------
drivers/pps/kapi.c | 6 +--
drivers/pps/kc.c | 67 ++++++++++++++++------------------
drivers/pps/pps.c | 16 ++++----
include/linux/pps_kernel.h | 2 +-
5 files changed, 68 insertions(+), 60 deletions(-)
--
2.47.3