Date: Wed, 1 Sep 2021 10:28:38 -0700 From: Craig Leres <leres@freebsd.org> To: Ian Lepore <ian@freebsd.org>, Warner Losh <imp@bsdimp.com> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: Patched gpsd and /dev/pps0 results in "sleeping thread" kernel panic Message-ID: <24848efe-aee7-8fe2-9437-005a854a3525@freebsd.org> In-Reply-To: <5d812d36e5291af35ecadf910a6d5f76b60f1441.camel@freebsd.org> References: <dc4c4948-738e-c530-d96f-ade5cce5d3d2@freebsd.org> <CANCZdfos2NamQXXcjYyVAcJvUL21kQbjUR4KRTp1xXKsQN3SrA@mail.gmail.com> <5476ea21-9e8a-32f5-08ff-add46c02d910@freebsd.org> <CANCZdfoQTfWC4j=ArTdGQMwDDNsg-LMMYSrtF4BHtHZSuV%2BCkw@mail.gmail.com> <cd29114478b51ca577308dfaacd9df076813a313.camel@freebsd.org> <CANCZdfrkg9dKKoLqpEX285eYPspciNj2eeH8RVZEtAr9Nc1SBQ@mail.gmail.com> <CANCZdfrDsEotO36eE%2BUUvUxAWq=_3pQ9NivGU=_r=%2BikWdUQXw@mail.gmail.com> <5d812d36e5291af35ecadf910a6d5f76b60f1441.camel@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 9/1/21 8:07 AM, Ian Lepore wrote:
> Warner, I pointed out a small change needed to your proposed patch in
> D31763.
I was able to figure out what to change and am happy to report that it
solves the kernel panic; thanks! Now I'm back to only fighting with gpsd.
Are the other calls to pps_init() ok?
steel 183 # find . -name '*.c' | xargs fgrep -w pps_init
./dev/sio/sio.c: pps_init(&com->pps);
./i386/i386/elan-mmcr.c: pps_init(&elan_pps);
./kern/kern_tc.c:pps_init(struct pps_state *pps)
./kern/kern_tc.c: pps_init(pps);
I've attached my working version of the patch.
Craig
[-- Attachment #2 --]
Index: dev/ppbus/ppb_base.c
===================================================================
--- dev/ppbus/ppb_base.c (revision 18)
+++ dev/ppbus/ppb_base.c (working copy)
@@ -220,6 +220,14 @@
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)
{
Index: dev/ppbus/ppbconf.h
===================================================================
--- dev/ppbus/ppbconf.h (revision 18)
+++ dev/ppbus/ppbconf.h (working copy)
@@ -261,6 +261,7 @@
/* 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);
Index: dev/ppbus/pps.c
===================================================================
--- dev/ppbus/pps.c (revision 18)
+++ dev/ppbus/pps.c (working copy)
@@ -141,9 +141,11 @@
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 @@
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?24848efe-aee7-8fe2-9437-005a854a3525>
