diff options
author | trasz <trasz@FreeBSD.org> | 2008-12-19 14:31:40 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2008-12-19 14:31:40 +0000 |
commit | d19b8615b7a3619d21808b172b2dc9739498d198 (patch) | |
tree | 0ae0b45dbb43168f6187ca1cf6276178ef6f4e08 /sys | |
parent | af71eefd2cdcc1021dd1f6c646b9de43bab7691d (diff) | |
download | FreeBSD-src-d19b8615b7a3619d21808b172b2dc9739498d198.zip FreeBSD-src-d19b8615b7a3619d21808b172b2dc9739498d198.tar.gz |
Periph driver fixes, second try.
Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Diffstat (limited to 'sys')
-rw-r--r-- | sys/cam/cam_periph.c | 20 | ||||
-rw-r--r-- | sys/cam/cam_periph.h | 1 | ||||
-rw-r--r-- | sys/cam/cam_xpt.c | 2 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 2 |
4 files changed, 20 insertions, 5 deletions
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 7f15d80..3abeed8 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -290,7 +290,7 @@ cam_periph_acquire(struct cam_periph *periph) } void -cam_periph_release(struct cam_periph *periph) +cam_periph_release_locked(struct cam_periph *periph) { if (periph == NULL) @@ -302,7 +302,21 @@ cam_periph_release(struct cam_periph *periph) camperiphfree(periph); } xpt_unlock_buses(); +} + +void +cam_periph_release(struct cam_periph *periph) +{ + struct cam_sim *sim; + if (periph == NULL) + return; + + sim = periph->sim; + mtx_assert(sim->mtx, MA_NOTOWNED); + mtx_lock(sim->mtx); + cam_periph_release_locked(periph); + mtx_unlock(sim->mtx); } int @@ -329,7 +343,7 @@ cam_periph_hold(struct cam_periph *periph, int priority) while ((periph->flags & CAM_PERIPH_LOCKED) != 0) { periph->flags |= CAM_PERIPH_LOCK_WANTED; if ((error = msleep(periph, mtx, priority, "caplck", 0)) != 0) { - cam_periph_release(periph); + cam_periph_release_locked(periph); return (error); } } @@ -350,7 +364,7 @@ cam_periph_unhold(struct cam_periph *periph) wakeup(periph); } - cam_periph_release(periph); + cam_periph_release_locked(periph); } /* diff --git a/sys/cam/cam_periph.h b/sys/cam/cam_periph.h index e6073d9..8a45806 100644 --- a/sys/cam/cam_periph.h +++ b/sys/cam/cam_periph.h @@ -141,6 +141,7 @@ cam_status cam_periph_alloc(periph_ctor_t *periph_ctor, struct cam_periph *cam_periph_find(struct cam_path *path, char *name); cam_status cam_periph_acquire(struct cam_periph *periph); void cam_periph_release(struct cam_periph *periph); +void cam_periph_release_locked(struct cam_periph *periph); int cam_periph_hold(struct cam_periph *periph, int priority); void cam_periph_unhold(struct cam_periph *periph); void cam_periph_invalidate(struct cam_periph *periph); diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index cf3fa2c..f2a2d9d 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -6314,7 +6314,7 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) xpt_done(done_ccb); if (TAILQ_FIRST(&softc->request_ccbs) == NULL) { cam_periph_invalidate(periph); - cam_periph_release(periph); + cam_periph_release_locked(periph); } else { probeschedule(periph); } diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index f63a9b0..8797a08 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -772,8 +772,8 @@ daclose(struct disk *dp) softc->flags &= ~DA_FLAG_OPEN; cam_periph_unhold(periph); - cam_periph_release(periph); cam_periph_unlock(periph); + cam_periph_release(periph); return (0); } |