git: 0c02dd569c72 - stable/12 - ppbus: Set the lock for pps interface, update to latest api
Warner Losh
imp at FreeBSD.org
Sat Oct 2 16:43:48 UTC 2021
The branch stable/12 has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=0c02dd569c72d9a053199385777ea73b21684a13
commit 0c02dd569c72d9a053199385777ea73b21684a13
Author: Warner Losh <imp at FreeBSD.org>
AuthorDate: 2021-09-01 19:37:27 +0000
Commit: Warner Losh <imp at FreeBSD.org>
CommitDate: 2021-10-02 16:43:21 +0000
ppbus: Set the lock for pps interface, update to latest api
Since we take a lock when we enter the ioctl, we need to set driver_mtx
in the pps structure so it can be dropped while sleeping during a call
to timepps_fetch() with a non-zero timeout (PPS_CANWAIT feature).
MFC After: 5 days
Sponsored by: Netflix
Reviewed by: ian
Differential Revision: https://reviews.freebsd.org/D31763
(cherry picked from commit c62aa65b2a7a6492e712a69c58a35347aa441a98)
---
sys/dev/ppbus/ppb_base.c | 8 ++++++++
sys/dev/ppbus/ppbconf.h | 1 +
sys/dev/ppbus/pps.c | 8 ++++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/sys/dev/ppbus/ppb_base.c b/sys/dev/ppbus/ppb_base.c
index 20782385acc0..b399f4cc2d17 100644
--- a/sys/dev/ppbus/ppb_base.c
+++ b/sys/dev/ppbus/ppb_base.c
@@ -220,6 +220,14 @@ ppb_unlock(device_t bus)
mtx_unlock(ppb->ppc_lock);
}
+struct mtx *
+ppb_get_lock(device_t bus)
+{
+ struct ppb_data *ppb = DEVTOSOFTC(bus);
+
+ return (ppb->ppc_lock);
+}
+
void
_ppb_assert_locked(device_t bus, const char *file, int line)
{
diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h
index c026bf4574d0..924200672cb9 100644
--- a/sys/dev/ppbus/ppbconf.h
+++ b/sys/dev/ppbus/ppbconf.h
@@ -261,6 +261,7 @@ extern int ppb_release_bus(device_t, device_t);
/* bus related functions */
extern void ppb_lock(device_t);
extern void ppb_unlock(device_t);
+extern struct mtx *ppb_get_lock(device_t);
extern void _ppb_assert_locked(device_t, const char *, int);
extern void ppb_init_callout(device_t, struct callout *, int);
extern int ppb_sleep(device_t, void *, int, const char *, int);
diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c
index c94d8d4a1ffb..03280a86a3c7 100644
--- a/sys/dev/ppbus/pps.c
+++ b/sys/dev/ppbus/pps.c
@@ -141,9 +141,11 @@ ppsattach(device_t dev)
UID_ROOT, GID_WHEEL, 0600, PPS_NAME "%d", unit);
sc->devs[0] = d;
sc->pps[0].ppscap = PPS_CAPTUREASSERT | PPS_ECHOASSERT;
+ sc->pps[0].driver_abi = PPS_ABI_VERSION;
+ sc->pps[0].driver_mtx = ppb_get_lock(ppbus);
d->si_drv1 = sc;
d->si_drv2 = (void*)0;
- pps_init(&sc->pps[0]);
+ pps_init_abi(&sc->pps[0]);
ppb_lock(ppbus);
if (ppb_request_bus(ppbus, dev, PPB_DONTWAIT)) {
@@ -193,9 +195,11 @@ ppsattach(device_t dev)
UID_ROOT, GID_WHEEL, 0600, PPS_NAME "%db%d", unit, i - 1);
sc->devs[i] = d;
sc->pps[i].ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
+ sc->pps[i].driver_abi = PPS_ABI_VERSION;
+ sc->pps[i].driver_mtx = ppb_get_lock(ppbus);
d->si_drv1 = sc;
d->si_drv2 = (void *)(intptr_t)i;
- pps_init(&sc->pps[i]);
+ pps_init_abi(&sc->pps[i]);
}
ppb_lock(ppbus);
} while (0);
More information about the dev-commits-src-all
mailing list