summaryrefslogtreecommitdiffstats
path: root/sys/pci
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2001-02-09 06:11:45 +0000
committerbmilekic <bmilekic@FreeBSD.org>2001-02-09 06:11:45 +0000
commitf364d4ac3621ae2689a3cc1b82c73eb491475a24 (patch)
tree84444d0341ce519800ed7913d826f5f38c622d6d /sys/pci
parent363bdddf694863339f6629340cfb324771b8ffe7 (diff)
downloadFreeBSD-src-f364d4ac3621ae2689a3cc1b82c73eb491475a24.zip
FreeBSD-src-f364d4ac3621ae2689a3cc1b82c73eb491475a24.tar.gz
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
Diffstat (limited to 'sys/pci')
-rw-r--r--sys/pci/if_dcreg.h4
-rw-r--r--sys/pci/if_fxpvar.h4
-rw-r--r--sys/pci/if_pcnreg.h4
-rw-r--r--sys/pci/if_rlreg.h4
-rw-r--r--sys/pci/if_sfreg.h4
-rw-r--r--sys/pci/if_sisreg.h4
-rw-r--r--sys/pci/if_skreg.h8
-rw-r--r--sys/pci/if_stereg.h4
-rw-r--r--sys/pci/if_tireg.h4
-rw-r--r--sys/pci/if_tlreg.h4
-rw-r--r--sys/pci/if_vrreg.h4
-rw-r--r--sys/pci/if_wbreg.h4
-rw-r--r--sys/pci/if_wxvar.h8
-rw-r--r--sys/pci/if_xlreg.h4
14 files changed, 32 insertions, 32 deletions
diff --git a/sys/pci/if_dcreg.h b/sys/pci/if_dcreg.h
index 2327fa6..56f441f 100644
--- a/sys/pci/if_dcreg.h
+++ b/sys/pci/if_dcreg.h
@@ -702,8 +702,8 @@ struct dc_softc {
};
-#define DC_LOCK(_sc) mtx_enter(&(_sc)->dc_mtx, MTX_DEF)
-#define DC_UNLOCK(_sc) mtx_exit(&(_sc)->dc_mtx, MTX_DEF)
+#define DC_LOCK(_sc) mtx_lock(&(_sc)->dc_mtx)
+#define DC_UNLOCK(_sc) mtx_unlock(&(_sc)->dc_mtx)
#define DC_TX_POLL 0x00000001
#define DC_TX_COALESCE 0x00000002
diff --git a/sys/pci/if_fxpvar.h b/sys/pci/if_fxpvar.h
index aee009c..7a9eb8d 100644
--- a/sys/pci/if_fxpvar.h
+++ b/sys/pci/if_fxpvar.h
@@ -86,5 +86,5 @@ struct fxp_softc {
#define sc_if arpcom.ac_if
#define FXP_UNIT(_sc) (_sc)->arpcom.ac_if.if_unit
-#define FXP_LOCK(_sc) mtx_enter(&(_sc)->sc_mtx, MTX_DEF)
-#define FXP_UNLOCK(_sc) mtx_exit(&(_sc)->sc_mtx, MTX_DEF)
+#define FXP_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#define FXP_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
diff --git a/sys/pci/if_pcnreg.h b/sys/pci/if_pcnreg.h
index db7c1a3..79ef531 100644
--- a/sys/pci/if_pcnreg.h
+++ b/sys/pci/if_pcnreg.h
@@ -451,8 +451,8 @@ struct pcn_softc {
struct mtx pcn_mtx;
};
-#define PCN_LOCK(_sc) mtx_enter(&(_sc)->pcn_mtx, MTX_DEF)
-#define PCN_UNLOCK(_sc) mtx_exit(&(_sc)->pcn_mtx, MTX_DEF)
+#define PCN_LOCK(_sc) mtx_lock(&(_sc)->pcn_mtx)
+#define PCN_UNLOCK(_sc) mtx_unlock(&(_sc)->pcn_mtx)
/*
* register space access macros
diff --git a/sys/pci/if_rlreg.h b/sys/pci/if_rlreg.h
index a023301..1f3fc88 100644
--- a/sys/pci/if_rlreg.h
+++ b/sys/pci/if_rlreg.h
@@ -373,8 +373,8 @@ struct rl_softc {
struct mtx rl_mtx;
};
-#define RL_LOCK(_sc) mtx_enter(&(_sc)->rl_mtx, MTX_DEF)
-#define RL_UNLOCK(_sc) mtx_exit(&(_sc)->rl_mtx, MTX_DEF)
+#define RL_LOCK(_sc) mtx_lock(&(_sc)->rl_mtx)
+#define RL_UNLOCK(_sc) mtx_unlock(&(_sc)->rl_mtx)
/*
* register space access macros
diff --git a/sys/pci/if_sfreg.h b/sys/pci/if_sfreg.h
index c2dc20e..fd2107f 100644
--- a/sys/pci/if_sfreg.h
+++ b/sys/pci/if_sfreg.h
@@ -1048,8 +1048,8 @@ struct sf_softc {
};
-#define SF_LOCK(_sc) mtx_enter(&(_sc)->sf_mtx, MTX_DEF)
-#define SF_UNLOCK(_sc) mtx_exit(&(_sc)->sf_mtx, MTX_DEF)
+#define SF_LOCK(_sc) mtx_lock(&(_sc)->sf_mtx)
+#define SF_UNLOCK(_sc) mtx_unlock(&(_sc)->sf_mtx)
#define SF_TIMEOUT 1000
diff --git a/sys/pci/if_sisreg.h b/sys/pci/if_sisreg.h
index 96bbd6d..9e1c44c 100644
--- a/sys/pci/if_sisreg.h
+++ b/sys/pci/if_sisreg.h
@@ -399,8 +399,8 @@ struct sis_softc {
struct mtx sis_mtx;
};
-#define SIS_LOCK(_sc) mtx_enter(&(_sc)->sis_mtx, MTX_DEF)
-#define SIS_UNLOCK(_sc) mtx_exit(&(_sc)->sis_mtx, MTX_DEF)
+#define SIS_LOCK(_sc) mtx_lock(&(_sc)->sis_mtx)
+#define SIS_UNLOCK(_sc) mtx_unlock(&(_sc)->sis_mtx)
/*
* register space access macros
diff --git a/sys/pci/if_skreg.h b/sys/pci/if_skreg.h
index 6f31d1d..061707c 100644
--- a/sys/pci/if_skreg.h
+++ b/sys/pci/if_skreg.h
@@ -1182,10 +1182,10 @@ struct sk_softc {
struct mtx sk_mtx;
};
-#define SK_LOCK(_sc) mtx_enter(&(_sc)->sk_mtx, MTX_DEF)
-#define SK_UNLOCK(_sc) mtx_exit(&(_sc)->sk_mtx, MTX_DEF)
-#define SK_IF_LOCK(_sc) mtx_enter(&(_sc)->sk_softc->sk_mtx, MTX_DEF)
-#define SK_IF_UNLOCK(_sc) mtx_exit(&(_sc)->sk_softc->sk_mtx, MTX_DEF)
+#define SK_LOCK(_sc) mtx_lock(&(_sc)->sk_mtx)
+#define SK_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_mtx)
+#define SK_IF_LOCK(_sc) mtx_lock(&(_sc)->sk_softc->sk_mtx)
+#define SK_IF_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_softc->sk_mtx)
/* Softc for each logical interface */
struct sk_if_softc {
diff --git a/sys/pci/if_stereg.h b/sys/pci/if_stereg.h
index 7a5ad7a..6081ec0 100644
--- a/sys/pci/if_stereg.h
+++ b/sys/pci/if_stereg.h
@@ -517,8 +517,8 @@ struct ste_softc {
struct mtx ste_mtx;
};
-#define STE_LOCK(_sc) mtx_enter(&(_sc)->ste_mtx, MTX_DEF)
-#define STE_UNLOCK(_sc) mtx_exit(&(_sc)->ste_mtx, MTX_DEF)
+#define STE_LOCK(_sc) mtx_lock(&(_sc)->ste_mtx)
+#define STE_UNLOCK(_sc) mtx_unlock(&(_sc)->ste_mtx)
struct ste_mii_frame {
u_int8_t mii_stdelim;
diff --git a/sys/pci/if_tireg.h b/sys/pci/if_tireg.h
index 0eaff14..df399be 100644
--- a/sys/pci/if_tireg.h
+++ b/sys/pci/if_tireg.h
@@ -1147,8 +1147,8 @@ struct ti_softc {
struct mtx ti_mtx;
};
-#define TI_LOCK(_sc) mtx_enter(&(_sc)->ti_mtx, MTX_DEF)
-#define TI_UNLOCK(_sc) mtx_exit(&(_sc)->ti_mtx, MTX_DEF)
+#define TI_LOCK(_sc) mtx_lock(&(_sc)->ti_mtx)
+#define TI_UNLOCK(_sc) mtx_unlock(&(_sc)->ti_mtx)
/*
* Microchip Technology 24Cxx EEPROM control bytes
diff --git a/sys/pci/if_tlreg.h b/sys/pci/if_tlreg.h
index eb57a2c..bd7ea5b 100644
--- a/sys/pci/if_tlreg.h
+++ b/sys/pci/if_tlreg.h
@@ -129,8 +129,8 @@ struct tl_softc {
struct mtx tl_mtx;
};
-#define TL_LOCK(_sc) mtx_enter(&(_sc)->tl_mtx, MTX_DEF)
-#define TL_UNLOCK(_sc) mtx_exit(&(_sc)->tl_mtx, MTX_DEF)
+#define TL_LOCK(_sc) mtx_lock(&(_sc)->tl_mtx)
+#define TL_UNLOCK(_sc) mtx_unlock(&(_sc)->tl_mtx)
/*
* Transmit interrupt threshold.
diff --git a/sys/pci/if_vrreg.h b/sys/pci/if_vrreg.h
index 8217a8c..235962d 100644
--- a/sys/pci/if_vrreg.h
+++ b/sys/pci/if_vrreg.h
@@ -414,8 +414,8 @@ struct vr_softc {
struct mtx vr_mtx;
};
-#define VR_LOCK(_sc) mtx_enter(&(_sc)->vr_mtx, MTX_DEF)
-#define VR_UNLOCK(_sc) mtx_exit(&(_sc)->vr_mtx, MTX_DEF)
+#define VR_LOCK(_sc) mtx_lock(&(_sc)->vr_mtx)
+#define VR_UNLOCK(_sc) mtx_unlock(&(_sc)->vr_mtx)
/*
* register space access macros
diff --git a/sys/pci/if_wbreg.h b/sys/pci/if_wbreg.h
index 6f58514..983886b 100644
--- a/sys/pci/if_wbreg.h
+++ b/sys/pci/if_wbreg.h
@@ -381,8 +381,8 @@ struct wb_softc {
struct mtx wb_mtx;
};
-#define WB_LOCK(_sc) mtx_enter(&(_sc)->wb_mtx, MTX_DEF)
-#define WB_UNLOCK(_sc) mtx_exit(&(_sc)->wb_mtx, MTX_DEF)
+#define WB_LOCK(_sc) mtx_lock(&(_sc)->wb_mtx)
+#define WB_UNLOCK(_sc) mtx_unlock(&(_sc)->wb_mtx)
/*
* register space access macros
diff --git a/sys/pci/if_wxvar.h b/sys/pci/if_wxvar.h
index 09e6594..af5be8c 100644
--- a/sys/pci/if_wxvar.h
+++ b/sys/pci/if_wxvar.h
@@ -214,10 +214,10 @@ struct wxmdvar {
#define UNTIMEOUT(f, arg, sc) untimeout(f, arg, (sc)->w.sch)
#define INLINE __inline
#ifdef SMPNG
-#define WX_LOCK(_sc) mtx_enter(&(_sc)->wx_mtx, MTX_DEF)
-#define WX_UNLOCK(_sc) mtx_exit(&(_sc)->wx_mtx, MTX_DEF)
-#define WX_ILOCK(_sc) mtx_enter(&(_sc)->wx_mtx, MTX_DEF)
-#define WX_IUNLK(_sc) mtx_exit(&(_sc)->wx_mtx, MTX_DEF)
+#define WX_LOCK(_sc) mtx_lock(&(_sc)->wx_mtx)
+#define WX_UNLOCK(_sc) mtx_unlock(&(_sc)->wx_mtx)
+#define WX_ILOCK(_sc) mtx_lock(&(_sc)->wx_mtx)
+#define WX_IUNLK(_sc) mtx_unlock(&(_sc)->wx_mtx)
#else
#define WX_LOCK(_sc) _sc->w.spl = splimp()
#define WX_UNLOCK(_sc) splx(_sc->w.spl)
diff --git a/sys/pci/if_xlreg.h b/sys/pci/if_xlreg.h
index 376db04..8e1248e 100644
--- a/sys/pci/if_xlreg.h
+++ b/sys/pci/if_xlreg.h
@@ -588,8 +588,8 @@ struct xl_softc {
struct mtx xl_mtx;
};
-#define XL_LOCK(_sc) mtx_enter(&(_sc)->xl_mtx, MTX_DEF)
-#define XL_UNLOCK(_sc) mtx_exit(&(_sc)->xl_mtx, MTX_DEF)
+#define XL_LOCK(_sc) mtx_lock(&(_sc)->xl_mtx)
+#define XL_UNLOCK(_sc) mtx_unlock(&(_sc)->xl_mtx)
#define xl_rx_goodframes(x) \
((x.xl_upper_frames_ok & 0x03) << 8) | x.xl_rx_frames_ok
OpenPOWER on IntegriCloud