diff options
author | jh <jh@FreeBSD.org> | 2011-04-16 06:54:41 +0000 |
---|---|---|
committer | jh <jh@FreeBSD.org> | 2011-04-16 06:54:41 +0000 |
commit | 4cd56ff29fbff0da6eef2729ec88f7fda7a1b9f0 (patch) | |
tree | 251744cab78da0e07aa595a0307db1c289506786 /sys/cam | |
parent | 82c088adf3c07fdfaaea9530b4e5864d49514517 (diff) | |
download | FreeBSD-src-4cd56ff29fbff0da6eef2729ec88f7fda7a1b9f0.zip FreeBSD-src-4cd56ff29fbff0da6eef2729ec88f7fda7a1b9f0.tar.gz |
Move TUNABLE_INT_FETCH() out of the SIM lock to avoid sleeping while
holding the lock. The fix is analogous to r220618 for ada(4).
Reviewed by: mav
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 4 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 58 |
2 files changed, 32 insertions, 30 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 6dc836f..3d81800 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -687,6 +687,8 @@ cdregister(struct cam_periph *periph, void *arg) else softc->minimum_command_size = 6; + (void)cam_periph_hold(periph, PRIBIO); + cam_periph_unlock(periph); /* * Load the user's default, if any. */ @@ -712,7 +714,6 @@ cdregister(struct cam_periph *periph, void *arg) * WORM peripheral driver. WORM drives will also have the WORM * driver attached to them. */ - cam_periph_unlock(periph); softc->disk = disk_alloc(); softc->disk->d_devstat = devstat_new_entry("cd", periph->unit_number, 0, @@ -746,6 +747,7 @@ cdregister(struct cam_periph *periph, void *arg) softc->disk->d_hba_subdevice = cpi.hba_subdevice; disk_create(softc->disk, DISK_VERSION); cam_periph_lock(periph); + cam_periph_unhold(periph); /* * Add an async callback so that we get diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 61c7934..33311c5 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1231,35 +1231,6 @@ daregister(struct cam_periph *periph, void *arg) TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph); /* - * RBC devices don't have to support READ(6), only READ(10). - */ - if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC) - softc->minimum_cmd_size = 10; - else - softc->minimum_cmd_size = 6; - - /* - * Load the user's default, if any. - */ - snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size", - periph->unit_number); - TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size); - - /* - * 6, 10, 12 and 16 are the currently permissible values. - */ - if (softc->minimum_cmd_size < 6) - softc->minimum_cmd_size = 6; - else if ((softc->minimum_cmd_size > 6) - && (softc->minimum_cmd_size <= 10)) - softc->minimum_cmd_size = 10; - else if ((softc->minimum_cmd_size > 10) - && (softc->minimum_cmd_size <= 12)) - softc->minimum_cmd_size = 12; - else if (softc->minimum_cmd_size > 12) - softc->minimum_cmd_size = 16; - - /* * Register this media as a disk */ @@ -1291,6 +1262,35 @@ daregister(struct cam_periph *periph, void *arg) dasendorderedtag, softc); mtx_unlock(periph->sim->mtx); + /* + * RBC devices don't have to support READ(6), only READ(10). + */ + if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC) + softc->minimum_cmd_size = 10; + else + softc->minimum_cmd_size = 6; + + /* + * Load the user's default, if any. + */ + snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size", + periph->unit_number); + TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size); + + /* + * 6, 10, 12 and 16 are the currently permissible values. + */ + if (softc->minimum_cmd_size < 6) + softc->minimum_cmd_size = 6; + else if ((softc->minimum_cmd_size > 6) + && (softc->minimum_cmd_size <= 10)) + softc->minimum_cmd_size = 10; + else if ((softc->minimum_cmd_size > 10) + && (softc->minimum_cmd_size <= 12)) + softc->minimum_cmd_size = 12; + else if (softc->minimum_cmd_size > 12) + softc->minimum_cmd_size = 16; + softc->disk = disk_alloc(); softc->disk->d_devstat = devstat_new_entry(periph->periph_name, periph->unit_number, 0, |