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
This commit is contained in:
Warner Losh 2021-09-01 13:37:27 -06:00
parent f3fd885074
commit c62aa65b2a
3 changed files with 15 additions and 2 deletions

View file

@ -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)
{

View file

@ -259,6 +259,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);

View file

@ -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);