Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Aug 2013 12:06:46 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r254324 - projects/camlock/sys/cam
Message-ID:  <201308141206.r7EC6kPl031818@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Aug 14 12:06:46 2013
New Revision: 254324
URL: http://svnweb.freebsd.org/changeset/base/254324

Log:
  Turn locking tools into macros to make lock profiling, etc. usable.

Modified:
  projects/camlock/sys/cam/cam_periph.h
  projects/camlock/sys/cam/cam_xpt.c
  projects/camlock/sys/cam/cam_xpt.h

Modified: projects/camlock/sys/cam/cam_periph.h
==============================================================================
--- projects/camlock/sys/cam/cam_periph.h	Wed Aug 14 11:11:49 2013	(r254323)
+++ projects/camlock/sys/cam/cam_periph.h	Wed Aug 14 12:06:46 2013	(r254324)
@@ -186,39 +186,26 @@ void		cam_periph_freeze_after_event(stru
 int		cam_periph_error(union ccb *ccb, cam_flags camflags,
 				 u_int32_t sense_flags, union ccb *save_ccb);
 
-static __inline void
-cam_periph_lock(struct cam_periph *periph)
+static __inline struct mtx *
+cam_periph_mtx(struct cam_periph *periph)
 {
-	xpt_path_lock(periph->path);
+	return (xpt_path_mtx(periph->path));
 }
 
-static __inline void
-cam_periph_unlock(struct cam_periph *periph)
-{
-	xpt_path_unlock(periph->path);
-}
+#define cam_periph_owned(periph)					\
+	mtx_owned(xpt_path_mtx((periph)->path))
 
-static __inline int
-cam_periph_owned(struct cam_periph *periph)
-{
-	return (xpt_path_owned(periph->path));
-}
+#define cam_periph_lock(periph)						\
+	mtx_lock(xpt_path_mtx((periph)->path))
+
+#define cam_periph_unlock(periph)					\
+	mtx_unlock(xpt_path_mtx((periph)->path))
 
 #define cam_periph_assert(periph, what)					\
 	mtx_assert(xpt_path_mtx((periph)->path), (what))
 
-static __inline int
-cam_periph_sleep(struct cam_periph *periph, void *chan, int priority,
-		 const char *wmesg, int timo)
-{
-	return (xpt_path_sleep(periph->path, chan, priority, wmesg, timo));
-}
-
-static __inline struct mtx *
-cam_periph_mtx(struct cam_periph *periph)
-{
-	return (xpt_path_mtx(periph->path));
-}
+#define cam_periph_sleep(periph, chan, priority, wmesg, timo)		\
+	xpt_path_sleep((periph)->path, (chan), (priority), (wmesg), (timo))
 
 static inline struct cam_periph *
 cam_periph_acquire_first(struct periph_driver *driver)

Modified: projects/camlock/sys/cam/cam_xpt.c
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.c	Wed Aug 14 11:11:49 2013	(r254323)
+++ projects/camlock/sys/cam/cam_xpt.c	Wed Aug 14 12:06:46 2013	(r254324)
@@ -5055,35 +5055,6 @@ xpt_unlock_buses(void)
 	mtx_unlock(&xsoftc.xpt_topo_lock);
 }
 
-void
-xpt_path_lock(struct cam_path *path)
-{
-
-	mtx_lock(&path->device->device_mtx);
-}
-
-void
-xpt_path_unlock(struct cam_path *path)
-{
-
-	mtx_unlock(&path->device->device_mtx);
-}
-
-int
-xpt_path_owned(struct cam_path *path)
-{
-
-	return (mtx_owned(&path->device->device_mtx));
-}
-
-int
-xpt_path_sleep(struct cam_path *path, void *chan, int priority,
-    const char *wmesg, int timo)
-{
-
-	return (msleep(chan, &path->device->device_mtx, priority, wmesg, timo));
-}
-
 struct mtx *
 xpt_path_mtx(struct cam_path *path)
 {

Modified: projects/camlock/sys/cam/cam_xpt.h
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.h	Wed Aug 14 11:11:49 2013	(r254323)
+++ projects/camlock/sys/cam/cam_xpt.h	Wed Aug 14 12:06:46 2013	(r254324)
@@ -102,14 +102,13 @@ void			xpt_hold_boot(void);
 void			xpt_release_boot(void);
 void			xpt_lock_buses(void);
 void			xpt_unlock_buses(void);
-void			xpt_path_lock(struct cam_path *path);
-void			xpt_path_unlock(struct cam_path *path);
-#define xpt_path_assert(path, what)	mtx_assert(xpt_path_mtx(path), (what))
-int			xpt_path_owned(struct cam_path *path);
-int			xpt_path_sleep(struct cam_path *path, void *chan,
-				       int priority, const char *wmesg,
-				       int timo);
 struct mtx *		xpt_path_mtx(struct cam_path *path);
+#define xpt_path_lock(path)	mtx_lock(xpt_path_mtx(path))
+#define xpt_path_unlock(path)	mtx_unlock(xpt_path_mtx(path))
+#define xpt_path_assert(path, what)	mtx_assert(xpt_path_mtx(path), (what))
+#define xpt_path_owned(path)	mtx_owned(xpt_path_mtx(path))
+#define xpt_path_sleep(path, chan, priority, wmesg, timo)		\
+    msleep((chan), xpt_path_mtx(path), (priority), (wmesg), (timo))
 cam_status		xpt_register_async(int event, ac_callback_t *cbfunc,
 					   void *cbarg, struct cam_path *path);
 cam_status		xpt_compile_path(struct cam_path *new_path,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308141206.r7EC6kPl031818>