From f8d33b7a490ff48889b5e7ccc92863726b876b2d Mon Sep 17 00:00:00 2001 From: hselasky Date: Sat, 7 Mar 2015 18:23:32 +0000 Subject: [PATCH] Add mutex support to the pps_ioctl() API in the kernel. Bump kernel version to reflect structure change. PR: 196897 MFC after: 1 week --- sys/kern/kern_tc.c | 7 ++++--- sys/sys/param.h | 2 +- sys/sys/timepps.h | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 1c29041b1f29..a631662fe41a 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -23,10 +23,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef FFCLOCK #include #include -#endif #include #include #include @@ -1498,7 +1496,10 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps) cseq = pps->ppsinfo.clear_sequence; while (aseq == pps->ppsinfo.assert_sequence && cseq == pps->ppsinfo.clear_sequence) { - err = tsleep(pps, PCATCH, "ppsfch", timo); + if (pps->mtx != NULL) + err = msleep(pps, pps->mtx, PCATCH, "ppsfch", timo); + else + err = tsleep(pps, PCATCH, "ppsfch", timo); if (err == EWOULDBLOCK && fapi->timeout.tv_sec == -1) { continue; } else if (err != 0) { diff --git a/sys/sys/param.h b/sys/sys/param.h index 582a52d321d2..ec339d5abbe7 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100062 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100063 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/timepps.h b/sys/sys/timepps.h index 8083f33a160d..ae4b84d17d77 100644 --- a/sys/sys/timepps.h +++ b/sys/sys/timepps.h @@ -133,6 +133,8 @@ struct pps_kcbind_args { #ifdef _KERNEL +struct mtx; + struct pps_state { /* Capture information. */ struct timehands *capth; @@ -140,6 +142,9 @@ struct pps_state { unsigned capgen; unsigned capcount; + /* pointer to mutex protecting this state, if any */ + struct mtx *mtx; + /* State information. */ pps_params_t ppsparam; pps_info_t ppsinfo;