From nobody Wed Sep 01 01:26:37 2021 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 89D1B179A1F2 for ; Wed, 1 Sep 2021 01:26:39 +0000 (UTC) (envelope-from leres@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GzmcH1RK2z3vLx for ; Wed, 1 Sep 2021 01:26:39 +0000 (UTC) (envelope-from leres@freebsd.org) Received: from ice.alameda.xse.com (unknown [IPv6:2600:1700:a570:e20:f2ad:4eff:fe0b:a065]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: leres) by smtp.freebsd.org (Postfix) with ESMTPSA id D643221EF4 for ; Wed, 1 Sep 2021 01:26:38 +0000 (UTC) (envelope-from leres@freebsd.org) From: Craig Leres To: freebsd-hackers@freebsd.org Subject: Patched gpsd and /dev/pps0 results in "sleeping thread" kernel panic Message-ID: Date: Tue, 31 Aug 2021 18:26:37 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------65AF694C5EFA2B5FEF707328" Content-Language: en-US X-ThisMailContainsUnwantedMimeParts: N This is a multi-part message in MIME format. --------------65AF694C5EFA2B5FEF707328 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I have many FreeBSD based ntp time servers using half a dozen different kinds of receivers. Now I have a Javad Alpha2 satellite receiver I'd like to use. Since gpsd knows how to talk GREIS to it I'm pretty deep into trying to figure out how to configure that. gpsd appears to know a lot about the RFC 2783 pps api but incorrectly assumes only tty-like devices can support it. It tries to use time_pps_* functions with /dev/gps0 (a symlink to cuau0) which fail and doesn't even open /dev/pps0. My gpsd rc.conf config is: gpsd_enable="YES" gpsd_flags="-D1 -n -s 115200" gpsd_devices="/dev/gps0 /dev/pps0" The relevant part of my ntp.conf is (driver 46 is the GPSD-NG driver): server 127.127.46.0 fudge 127.127.46.0 flag4 1 Running with these two configs, the gpsd tool cgps shows the radio happily is tracking ~20 satellites. ntpd shows "GPSD" running about 10 us fast but because this so far off it eventually discards it (ntpq -p show 'x' before it). I know /dev/pps0 works because if I add pps clock config (driver 22) for it to ntp.conf: server 127.127.22.0 prefer fudge 127.127.22.0 flag3 1 ntpd is then able to poll for data and shows a reasonable offset that is comparable to ntpd running on nearby servers. So I'm pretty close, I just need to get gpsd working with /dev/pps0. To that end, I made a copy of the source and made some changes to ppsthread.c (see attached patch.txt) which basically forces an open() on /dev/pps0. This gets further: gpsd:INFO: KPPS:/dev/pps0 pps_caps 0x1151 gpsd:INFO: KPPS:/dev/pps0 have PPS_CANWAIT gpsd:WARN: KPPS:/dev/pps0 missing PPS_CAPTURECLEAR, pulse may be offset gpsd:INFO: KPPS:/dev/pps0 kernel PPS will be used [New LWP 101408 of process 2046] gpsd:PROG: PPS:/dev/pps0 thread launched gpsd:INFO: PPS:/dev/pps0 ntpshm_link_activate: 0 gpsd:INFO: device /dev/pps0 activated and gpsd starts to talk GREIS protocol to the radio and then the kernel panics with "sleeping thread". Here are more details about my setup. I have 12.2-RELEASE-p10 kernel with these options: device pps options PPS_SYNC options P1003_1B_MQUEUE I'm building the ports version of net/ntp with these options: ATOM DEBUG IPV6 JUPITER NMEA ONCORE PERL_UTILS SHM SSL THREADS I'm building the ports version of astro/gpsd with these options: GPSCLOCK IPV6 NCURSES NMEA0183 NTP NTPSHM ONCORE PPS RECONFIG SHMEXPORT SOCKEXPORT My gpsd source tree is just a copy of patched version of the astro/gpsd port. (Which caused me to have to learn how to use scons...) When testing I start gpsd with: ./gpsd -N -D5 -n -s 115200 -P /var/run/gpsd.pid /dev/gps0 /dev/pps0 The Alpha2 is connected to /dev/cuau0 at 115200 baud, its pps is connected to a parallel printer port. Can anyone help me with gpsd+pps and/or the kernel panic? Craig --------------65AF694C5EFA2B5FEF707328 Content-Type: text/plain; charset=UTF-8; name="patch.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="patch.txt" LS0tIHBwc3RocmVhZC5jCTIwMjEvMDkvMDEgMDA6MTg6MTMJMS4xCisrKyBwcHN0aHJlYWQu YwkyMDIxLzA5LzAxIDAwOjI4OjI3CkBAIC0yMTYsNiArMjE2LDEzIEBACiB9CiAjZW5kaWYg LyogX19saW51eF9fICovCiAKKyNpZmRlZiBfX0ZyZWVCU0RfXworY2hhciAqcHBzX2dldF9m aXJzdCh2b2lkKQoreworICAgIHJldHVybiAiL2Rldi9wcHMwIjsKK30KKyNlbmRpZgorCiBz dGF0aWMgaW50IGluaXRfa2VybmVsX3BwcyhzdHJ1Y3QgaW5uZXJfY29udGV4dF90ICppbm5l cl9jb250ZXh0KQogLyogcmV0dXJuIGhhbmRsZSBmb3Iga2VybmVsIHBwcywgb3IgLTE7IHJl cXVpcmVzIHJvb3QgcHJpdmlsZWdlcyAqLwogewpAQCAtMjMyLDYgKzIzOSwxNSBAQAogICAg IGlubmVyX2NvbnRleHQtPmtlcm5lbHBwc19oYW5kbGUgPSAtMTsKICAgICBpbm5lcl9jb250 ZXh0LT5wcHNfY2Fud2FpdCA9IGZhbHNlOwogCisjaWZkZWYgX19GcmVlQlNEX18KKyAgICBp ZiAoc3RybmNtcChwcHNfdGhyZWFkLT5kZXZpY2VuYW1lLCAiL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ICAgIHBwc190aHJlYWQtPmRldmljZW5hbWUsCisJCQkgICAgZ2V0dWlkKCksIGdldGV1aWQo KSwKKwkJCSAgICBwYXRoLCBlcnJidWYpOworCQlyZXR1cm4gKC0xKTsKKwkgICAgfQorICAg IH0gZWxzZSB7CisJcmV0ICA9IHBwc190aHJlYWQtPmRldmljZWZkOworICAgIH0KICNlbmRp ZgogICAgIC8qIGFzc2VydChyZXQgPj0gMCk7ICovCiAgICAgcHBzX3RocmVhZC0+bG9nX2hv b2socHBzX3RocmVhZCwgVEhSRUFEX0lORiwK --------------65AF694C5EFA2B5FEF707328--