Date: Sun, 11 Aug 2013 08:08:23 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r254209 - projects/camlock/sys/cam Message-ID: <201308110808.r7B88NJV032990@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sun Aug 11 08:08:23 2013 New Revision: 254209 URL: http://svnweb.freebsd.org/changeset/base/254209 Log: In addition to r254143 allow cam_sim_hold/release() to be called unrelated to holding SIM lock. If lock is not held, just take it inside. Modified: projects/camlock/sys/cam/cam_sim.c Modified: projects/camlock/sys/cam/cam_sim.c ============================================================================== --- projects/camlock/sys/cam/cam_sim.c Sun Aug 11 07:00:43 2013 (r254208) +++ projects/camlock/sys/cam/cam_sim.c Sun Aug 11 08:08:23 2013 (r254209) @@ -124,21 +124,31 @@ cam_sim_free(struct cam_sim *sim, int fr void cam_sim_release(struct cam_sim *sim) { - KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); - mtx_assert(sim->mtx, MA_OWNED); + int lock; + lock = (mtx_owned(sim->mtx) == 0); + if (lock) + CAM_SIM_LOCK(sim); + KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); sim->refcount--; if (sim->refcount == 0) wakeup(sim); + if (lock) + CAM_SIM_UNLOCK(sim); } void cam_sim_hold(struct cam_sim *sim) { - KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); - mtx_assert(sim->mtx, MA_OWNED); + int lock; + lock = (mtx_owned(sim->mtx) == 0); + if (lock) + CAM_SIM_LOCK(sim); + KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); sim->refcount++; + if (lock) + CAM_SIM_UNLOCK(sim); } void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308110808.r7B88NJV032990>