diff options
author | Alexander Kabaev <kan@FreeBSD.org> | 2009-10-20 02:35:12 +0000 |
---|---|---|
committer | Alexander Kabaev <kan@FreeBSD.org> | 2009-10-20 02:35:12 +0000 |
commit | 363b8ed74f8e07accef6a28fc4f05db661f29a24 (patch) | |
tree | d49d606702e2f1259d311085bf7f5d111fbe45b4 /sys/dev/mpt/mpt.h | |
parent | d5e9eabeadd20b3c8de6d37c2a96d33553c8ab4f (diff) | |
download | src-363b8ed74f8e07accef6a28fc4f05db661f29a24.tar.gz src-363b8ed74f8e07accef6a28fc4f05db661f29a24.zip |
Use callout_init_mtx on FreeBSD versions recent enough. This closes
the race where interrupt thread can complete the request for which
timeout has fired and while mpt_timeout has blocked on mpt_lock.
Do a best effort to keep 4.x ang Giant-locked configurartions
compiling still.
Reported by: ups
Reviewed by: scottl
Notes
Notes:
svn path=/head/; revision=198262
Diffstat (limited to 'sys/dev/mpt/mpt.h')
-rw-r--r-- | sys/dev/mpt/mpt.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index 0a093efabd12..1fa2d1aaded8 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -296,13 +296,6 @@ void mpt_map_rquest(void *, bus_dma_segment_t *, int, int); kthread_exit(status) #endif -/****************************** Timer Facilities ******************************/ -#if __FreeBSD_version > 500000 -#define mpt_callout_init(c) callout_init(c, /*mpsafe*/1); -#else -#define mpt_callout_init(c) callout_init(c); -#endif - /********************************** Endianess *********************************/ #define MPT_2_HOST64(ptr, tag) ptr->tag = le64toh(ptr->tag) #define MPT_2_HOST32(ptr, tag) ptr->tag = le32toh(ptr->tag) @@ -889,6 +882,10 @@ mpt_sleep(struct mpt_softc *mpt, void *ident, int priority, callout_reset(&(req)->callout, (ticks), (func), (arg)); #define mpt_req_untimeout(req, func, arg) \ callout_stop(&(req)->callout) +#define mpt_callout_init(mpt, c) \ + callout_init(c) +#define mpt_callout_drain(mpt, c) \ + callout_stop(c) #else #if 1 @@ -911,9 +908,13 @@ mpt_sleep(struct mpt_softc *mpt, void *ident, int priority, #define mpt_sleep(mpt, ident, priority, wmesg, timo) \ msleep(ident, &(mpt)->mpt_lock, priority, wmesg, timo) #define mpt_req_timeout(req, ticks, func, arg) \ - callout_reset(&(req)->callout, (ticks), (func), (arg)); + callout_reset(&(req)->callout, (ticks), (func), (arg)) #define mpt_req_untimeout(req, func, arg) \ callout_stop(&(req)->callout) +#define mpt_callout_init(mpt, c) \ + callout_init_mtx(c, &(mpt)->mpt_lock, 0) +#define mpt_callout_drain(mpt, c) \ + callout_drain(c) #else @@ -926,18 +927,18 @@ mpt_sleep(struct mpt_softc *mpt, void *ident, int priority, #define MPTLOCK_2_CAMLOCK(mpt) #define CAMLOCK_2_MPTLOCK(mpt) +#define mpt_req_timeout(req, ticks, func, arg) \ + callout_reset(&(req)->callout, (ticks), (func), (arg)) +#define mpt_req_untimeout(req, func, arg) \ + callout_stop(&(req)->callout) +#define mpt_callout_init(mpt, c) \ + callout_init(c, 0) +#define mpt_callout_drain(mpt, c) \ + callout_drain(c) + static __inline int mpt_sleep(struct mpt_softc *, void *, int, const char *, int); -#define mpt_ccb_timeout(ccb, ticks, func, arg) \ - do { \ - (ccb)->ccb_h.timeout_ch = timeout((func), (arg), (ticks)); \ - } while (0) -#define mpt_ccb_untimeout(ccb, func, arg) \ - untimeout((func), (arg), (ccb)->ccb_h.timeout_ch) -#define mpt_ccb_timeout_init(ccb) \ - callout_handle_init(&(ccb)->ccb_h.timeout_ch) - static __inline int mpt_sleep(struct mpt_softc *mpt, void *i, int p, const char *w, int t) { |