summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@nexenta.com>2011-04-15 09:13:23 -0700
committerGarrett D'Amore <garrett@nexenta.com>2011-04-15 09:13:23 -0700
commit7dac2cd84b59ec865d350aeb91b90cd1469527e1 (patch)
tree8397f1f18b659cd7d41ee89f827c174ea6e96b7b /usr/src/uts
parent542e9fda333dd4a22b4c450409aef403e221c4b3 (diff)
downloadillumos-joyent-7dac2cd84b59ec865d350aeb91b90cd1469527e1.tar.gz
896 sata module can panic on smartctl issued in vbox
Reviewed by: Albert Lee <trisk@nexenta.com> Reviewed by: Gordon Ross <gwr@nexenta.com> Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/io/sata/impl/sata.c367
1 files changed, 183 insertions, 184 deletions
diff --git a/usr/src/uts/common/io/sata/impl/sata.c b/usr/src/uts/common/io/sata/impl/sata.c
index 38012b0813..d6229aa9c5 100644
--- a/usr/src/uts/common/io/sata/impl/sata.c
+++ b/usr/src/uts/common/io/sata/impl/sata.c
@@ -22,7 +22,9 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-
+/*
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ */
/*
* SATA Framework
@@ -3508,15 +3510,16 @@ sata_txlt_nodata_cmd_immediate(sata_pkt_txlate_t *spx)
{
int rval;
int reason;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
spx->txlt_scsi_pkt->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
STATE_SENT_CMD | STATE_GOT_STATUS;
@@ -3584,12 +3587,13 @@ sata_txlt_inquiry(sata_pkt_txlate_t *spx)
uint8_t page_buf[1024]; /* Max length */
int rval, reason;
ushort_t rate;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -3847,7 +3851,7 @@ sata_txlt_inquiry(sata_pkt_txlate_t *spx)
scsipkt->pkt_cdbp[4] - count : 0;
}
done:
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"Scsi_pkt completion reason %x\n",
@@ -3894,12 +3898,14 @@ sata_txlt_request_sense(sata_pkt_txlate_t *spx)
sata_drive_info_t *sdinfo;
sata_cmd_t *scmd = &spx->txlt_sata_pkt->satapkt_cmd;
int rval, reason, power_state = 0;
+ kmutex_t *cport_mutex;
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -3913,7 +3919,7 @@ sata_txlt_request_sense(sata_pkt_txlate_t *spx)
* return ILLEGAL_REQUEST
*/
if (scsipkt->pkt_cdbp[5] & CTL_BYTE_NACA_MASK) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx, KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_CMD_SEQUENCE_ERR));
}
@@ -3928,14 +3934,13 @@ sata_txlt_request_sense(sata_pkt_txlate_t *spx)
scmd->satacmd_flags.sata_copy_out_sec_count_lsb = B_TRUE;
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
- return (sata_txlt_check_condition(spx, KEY_NO_SENSE,
- SD_SCSI_ASC_NO_ADD_SENSE));
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ mutex_exit(cport_mutex);
+ return (sata_txlt_check_condition(spx, KEY_NO_SENSE,
+ SD_SCSI_ASC_NO_ADD_SENSE));
}
switch (scmd->satacmd_sec_count_lsb) {
@@ -3962,7 +3967,7 @@ sata_txlt_request_sense(sata_pkt_txlate_t *spx)
break;
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
if (bp != NULL && bp->b_un.b_addr && bp->b_bcount) {
/*
@@ -4037,12 +4042,13 @@ sata_txlt_test_unit_ready(sata_pkt_txlate_t *spx)
sata_drive_info_t *sdinfo;
int power_state;
int rval, reason;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -4057,14 +4063,14 @@ sata_txlt_test_unit_ready(sata_pkt_txlate_t *spx)
scmd->satacmd_flags.sata_copy_out_sec_count_lsb = B_TRUE;
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
- return (sata_txlt_check_condition(spx, KEY_NOT_READY,
- SD_SCSI_ASC_LU_NOT_RESPONSE));
- }
+ }
+
+ if (scmd->satacmd_error_reg != 0) {
+ mutex_exit(cport_mutex);
+ return (sata_txlt_check_condition(spx, KEY_NOT_READY,
+ SD_SCSI_ASC_LU_NOT_RESPONSE));
}
power_state = scmd->satacmd_sec_count_lsb;
@@ -4089,7 +4095,7 @@ sata_txlt_test_unit_ready(sata_pkt_txlate_t *spx)
scsipkt->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
STATE_SENT_CMD | STATE_GOT_STATUS;
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"Scsi_pkt completion reason %x\n", scsipkt->pkt_reason);
@@ -4143,26 +4149,25 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
{
struct scsi_pkt *scsipkt = spx->txlt_scsi_pkt;
sata_cmd_t *scmd = &spx->txlt_sata_pkt->satapkt_cmd;
- sata_hba_inst_t *shi = SATA_TXLT_HBA_INST(spx);
- int cport = SATA_TXLT_CPORT(spx);
int rval, reason;
sata_drive_info_t *sdinfo;
sata_id_t *sata_id;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_start_stop_unit: %d\n", scsipkt->pkt_scbp[4] & 1);
- mutex_enter(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
if (scsipkt->pkt_cdbp[1] & START_STOP_IMMED_MASK) {
/* IMMED bit - not supported */
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx, KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB));
}
@@ -4188,12 +4193,11 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
sdinfo->satadrv_power_level = SATA_POWER_ACTIVE;
} else {
@@ -4201,7 +4205,7 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
sata_build_generic_cmd(scmd, SATAC_FLUSH_CACHE);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
} else {
if (scmd->satacmd_error_reg != 0) {
@@ -4212,12 +4216,11 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
sata_build_generic_cmd(scmd, SATAC_STANDBY_IM);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
sdinfo->satadrv_power_level = SATA_POWER_STOPPED;
}
@@ -4226,19 +4229,18 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
sata_build_generic_cmd(scmd, SATAC_IDLE);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
sata_build_read_verify_cmd(scmd, 1, 5);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
} else {
if (scmd->satacmd_error_reg != 0) {
@@ -4252,23 +4254,21 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (!(scsipkt->pkt_cdbp[4] & START_STOP_NOFLUSH_MASK)) {
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
}
sata_build_generic_cmd(scmd, SATAC_IDLE);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
if ((scsipkt->pkt_cdbp[3] & START_STOP_MODIFIER_MASK)) {
/*
@@ -4288,12 +4288,11 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
scmd->satacmd_lba_high_lsb = 0x55;
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
}
sdinfo->satadrv_power_level = SATA_POWER_IDLE;
@@ -4303,23 +4302,21 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (!(scsipkt->pkt_cdbp[4] & START_STOP_NOFLUSH_MASK)) {
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
}
sata_build_generic_cmd(scmd, SATAC_STANDBY);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
sdinfo->satadrv_power_level = SATA_POWER_STANDBY;
break;
@@ -4328,12 +4325,11 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
scmd->satacmd_flags.sata_copy_out_sec_count_lsb = B_TRUE;
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
switch (scmd->satacmd_sec_count_lsb) {
case SATA_PWRMODE_STANDBY:
@@ -4342,7 +4338,7 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
sdinfo->satadrv_standby_timer);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
} else {
if (scmd->satacmd_error_reg != 0) {
@@ -4356,7 +4352,7 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
sdinfo->satadrv_standby_timer);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
} else {
if (scmd->satacmd_error_reg != 0) {
@@ -4372,22 +4368,20 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
sdinfo->satadrv_standby_timer);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
sata_build_read_verify_cmd(scmd, 1, 5);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
break;
default:
@@ -4397,7 +4391,7 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
case 0xb:
if ((sata_get_standby_timer(sdinfo->satadrv_standby_timer) ==
0) || (!(sata_id->ai_cap & SATA_STANDBYTIMER))) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx,
KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB));
@@ -4406,29 +4400,27 @@ sata_txlt_start_stop_unit(sata_pkt_txlate_t *spx)
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (!(scsipkt->pkt_cdbp[4] & START_STOP_NOFLUSH_MASK)) {
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
sata_build_generic_cmd(scmd, SATAC_STANDBY_IM);
scmd->satacmd_flags.sata_copy_out_error_reg = B_TRUE;
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
- } else {
- if (scmd->satacmd_error_reg != 0) {
- goto err_out;
- }
+ }
+ if (scmd->satacmd_error_reg != 0) {
+ goto err_out;
}
}
bzero(sdinfo->satadrv_standby_timer, sizeof (uchar_t) * 4);
break;
default:
err_out:
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx, KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB));
}
@@ -4437,7 +4429,7 @@ err_out:
* Since it was a synchronous command,
* a callback function will be called directly.
*/
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"synchronous execution status %x\n",
spx->txlt_sata_pkt->satapkt_reason);
@@ -4485,15 +4477,16 @@ sata_txlt_read_capacity(sata_pkt_txlate_t *spx)
uint64_t val;
uchar_t *rbuf;
int rval, reason;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_read_capacity: ", NULL);
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -4537,7 +4530,7 @@ sata_txlt_read_capacity(sata_pkt_txlate_t *spx)
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst, "%d\n",
sdinfo->satadrv_capacity -1);
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
/*
* If a callback was requested, do it now.
*/
@@ -4584,15 +4577,16 @@ sata_txlt_read_capacity16(sata_pkt_txlate_t *spx)
int rval, reason;
#define TPE 0x80
#define TPRZ 0x40
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_read_capacity: ", NULL);
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -4611,7 +4605,7 @@ sata_txlt_read_capacity16(sata_pkt_txlate_t *spx)
/* Check SERVICE ACTION field */
if ((scsipkt->pkt_cdbp[1] & 0x1f) !=
SSVC_ACTION_READ_CAPACITY_G4) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx,
KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB));
@@ -4626,7 +4620,7 @@ sata_txlt_read_capacity16(sata_pkt_txlate_t *spx)
(scsipkt->pkt_cdbp[7] != 0) ||
(scsipkt->pkt_cdbp[8] != 0) ||
(scsipkt->pkt_cdbp[9] != 0)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx,
KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB));
@@ -4634,7 +4628,7 @@ sata_txlt_read_capacity16(sata_pkt_txlate_t *spx)
/* Check PMI bit */
if (scsipkt->pkt_cdbp[14] & 0x1) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_check_condition(spx,
KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB));
@@ -4710,7 +4704,7 @@ sata_txlt_read_capacity16(sata_pkt_txlate_t *spx)
sdinfo->satadrv_capacity -1);
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
/*
* If a callback was requested, do it now.
@@ -4758,12 +4752,13 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
int paramlen = 8;
uint8_t *data, *tmpbd;
sata_drive_info_t *sdinfo;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
#define TRIM 0x1
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_unmap: ", NULL);
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
sdinfo = sata_get_device_info(spx->txlt_sata_hba_inst,
&spx->txlt_sata_pkt->satapkt_device);
@@ -4776,7 +4771,7 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
rval = sata_txlt_generic_pkt_info(spx, &reason, 1);
if ((rval != TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -4792,7 +4787,7 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
(bdlen > (bp->b_bcount - paramlen))) {
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_unmap: invalid block descriptor length", NULL);
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return ((sata_txlt_check_condition(spx, KEY_ILLEGAL_REQUEST,
SD_SCSI_ASC_INVALID_FIELD_IN_CDB)));
}
@@ -4806,7 +4801,7 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_unmap: no parameter data or block descriptors",
NULL);
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_unmap_nodata_cmd(spx));
}
tmpbd = (uint8_t *)bp->b_un.b_addr + paramlen;
@@ -4847,7 +4842,7 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
count = (ranges + 63)/64;
/* Allocate a buffer that is a multiple of 512 bytes. */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
bp = sata_alloc_local_buffer(spx, count * 512);
if (bp == NULL) {
SATADBG1(SATA_DBG_ATAPI, spx->txlt_sata_hba_inst,
@@ -4857,7 +4852,7 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
return (TRAN_BUSY);
}
bp_mapin(bp); /* make data buffer accessible */
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
bzero(bp->b_un.b_addr, bp->b_bcount);
bcopy(data, bp->b_un.b_addr, x);
@@ -4886,11 +4881,11 @@ sata_txlt_unmap(sata_pkt_txlate_t *spx)
}
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
if (synch) {
sata_txlt_unmap_completion(spx->txlt_sata_pkt);
@@ -4923,6 +4918,7 @@ sata_txlt_mode_sense(sata_pkt_txlate_t *spx)
int pc; /* Page Control code */
uint8_t *buf; /* mode sense buffer */
int rval, reason;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
SATADBG2(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_mode_sense, pc %x page code 0x%02x\n",
@@ -4938,11 +4934,11 @@ sata_txlt_mode_sense(sata_pkt_txlate_t *spx)
buf = kmem_zalloc(1024, KM_SLEEP);
}
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
kmem_free(buf, 1024);
return (rval);
}
@@ -5159,7 +5155,7 @@ sata_txlt_mode_sense(sata_pkt_txlate_t *spx)
}
*scsipkt->pkt_scbp = STATUS_GOOD;
done:
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
(void) kmem_free(buf, 1024);
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
@@ -5222,17 +5218,18 @@ sata_txlt_mode_select(sata_pkt_txlate_t *spx)
int rval, stat, reason;
uint_t nointr_flag;
int dmod = 0;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
SATADBG2(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_mode_select, pc %x page code 0x%02x\n",
spx->txlt_scsi_pkt->pkt_cdbp[2] >> 6,
spx->txlt_scsi_pkt->pkt_cdbp[2] & 0x3f);
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -5427,7 +5424,7 @@ sata_txlt_mode_select(sata_pkt_txlate_t *spx)
}
}
done:
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
/*
* If device parameters were modified, fetch and store the new
* Identify Device data. Since port mutex could have been released
@@ -5448,7 +5445,7 @@ done:
rv = sata_fetch_device_identify_data(spx->txlt_sata_hba_inst,
&new_sdinfo);
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
/*
* Since port mutex could have been released when
* accessing HBA driver, we need to re-check that the
@@ -5484,7 +5481,7 @@ done:
scsipkt->pkt_reason = CMD_INCOMPLETE;
rval = TRAN_ACCEPT;
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
}
/* Restore the scsi pkt flags */
scsipkt->pkt_flags &= ~FLAG_NOINTR;
@@ -5532,12 +5529,13 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
uint16_t feature, sec_count;
int t_len, synch;
int rval, reason;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
rval = sata_txlt_generic_pkt_info(spx, &reason, 1);
if ((rval != TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -5549,13 +5547,13 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
/* MULTIPLE_COUNT field. If non-zero, invalid command (for now). */
if (((scsipkt->pkt_cdbp[1] >> 5) & 0x7) != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
}
/* OFFLINE field. If non-zero, invalid command (for now). */
if (((scsipkt->pkt_cdbp[2] >> 6) & 0x3) != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
}
@@ -5573,7 +5571,7 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
case SATL_APT_P_RET_RESP:
/* Not yet implemented */
default:
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
case SATL_APT_P_NON_DATA:
@@ -5583,7 +5581,7 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
case SATL_APT_P_PIO_DATA_IN:
/* If PROTOCOL disagrees with T_DIR, invalid command */
if (scmd->satacmd_flags.sata_data_direction == SATA_DIR_WRITE) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
}
@@ -5592,7 +5590,7 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
sata_scsi_dmafree(NULL, scsipkt);
} else {
/* if there is no buffer, how do you PIO in? */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
}
@@ -5601,7 +5599,7 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
case SATL_APT_P_PIO_DATA_OUT:
/* If PROTOCOL disagrees with T_DIR, invalid command */
if (scmd->satacmd_flags.sata_data_direction == SATA_DIR_READ) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
}
@@ -5610,7 +5608,7 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
sata_scsi_dmafree(NULL, scsipkt);
} else {
/* if there is no buffer, how do you PIO out? */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_ata_pass_thru_illegal_cmd(spx));
}
@@ -5739,11 +5737,11 @@ sata_txlt_ata_pass_thru(sata_pkt_txlate_t *spx)
}
if (sata_hba_start(spx, &rval) != 0) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
if (synch) {
sata_txlt_apt_completion(spx->txlt_sata_pkt);
@@ -5768,6 +5766,7 @@ sata_txlt_log_sense(sata_pkt_txlate_t *spx)
uint8_t *buf; /* log sense buffer */
int rval, reason;
#define MAX_LOG_SENSE_PAGE_SIZE 512
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
SATADBG2(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_log_sense, pc 0x%x, page code 0x%x\n",
@@ -5783,11 +5782,11 @@ sata_txlt_log_sense(sata_pkt_txlate_t *spx)
buf = kmem_zalloc(MAX_LOG_SENSE_PAGE_SIZE, KM_SLEEP);
}
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
kmem_free(buf, MAX_LOG_SENSE_PAGE_SIZE);
return (rval);
}
@@ -5987,7 +5986,7 @@ no_header:
}
*scsipkt->pkt_scbp = STATUS_GOOD;
done:
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
(void) kmem_free(buf, MAX_LOG_SENSE_PAGE_SIZE);
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
@@ -6061,17 +6060,17 @@ sata_txlt_read(sata_pkt_txlate_t *spx)
sata_cmd_t *scmd = &spx->txlt_sata_pkt->satapkt_cmd;
sata_drive_info_t *sdinfo;
sata_hba_inst_t *shi = SATA_TXLT_HBA_INST(spx);
- int cport = SATA_TXLT_CPORT(spx);
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
uint16_t sec_count;
uint64_t lba;
int rval, reason;
int synch;
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -6128,7 +6127,7 @@ sata_txlt_read(sata_pkt_txlate_t *spx)
break;
default:
/* Unsupported command */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_invalid_command(spx));
}
@@ -6138,7 +6137,7 @@ sata_txlt_read(sata_pkt_txlate_t *spx)
if ((lba >= sdinfo->satadrv_capacity) ||
((lba + sec_count) > sdinfo->satadrv_capacity)) {
/* LBA out of range */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_lba_out_of_range(spx));
}
@@ -6148,7 +6147,7 @@ sata_txlt_read(sata_pkt_txlate_t *spx)
* No DMA resources were allocated.
*/
if (spx->txlt_dma_cookie_list == NULL) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_emul_rw_completion(spx));
}
@@ -6275,10 +6274,10 @@ sata_txlt_read(sata_pkt_txlate_t *spx)
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
/*
* If execution is non-synchronous,
* a callback function will handle potential errors, translate
@@ -6330,17 +6329,17 @@ sata_txlt_write(sata_pkt_txlate_t *spx)
sata_cmd_t *scmd = &spx->txlt_sata_pkt->satapkt_cmd;
sata_drive_info_t *sdinfo;
sata_hba_inst_t *shi = SATA_TXLT_HBA_INST(spx);
- int cport = SATA_TXLT_CPORT(spx);
uint16_t sec_count;
uint64_t lba;
int rval, reason;
int synch;
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -6397,7 +6396,7 @@ sata_txlt_write(sata_pkt_txlate_t *spx)
break;
default:
/* Unsupported command */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_invalid_command(spx));
}
@@ -6407,7 +6406,7 @@ sata_txlt_write(sata_pkt_txlate_t *spx)
if ((lba >= sdinfo->satadrv_capacity) ||
((lba + sec_count) > sdinfo->satadrv_capacity)) {
/* LBA out of range */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_txlt_lba_out_of_range(spx));
}
@@ -6417,7 +6416,7 @@ sata_txlt_write(sata_pkt_txlate_t *spx)
* No DMA resources were allocated.
*/
if (spx->txlt_dma_cookie_list == NULL) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (sata_emul_rw_completion(spx));
}
@@ -6539,10 +6538,10 @@ sata_txlt_write(sata_pkt_txlate_t *spx)
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
/*
* If execution is non-synchronous,
@@ -6570,7 +6569,6 @@ sata_txlt_write_buffer(sata_pkt_txlate_t *spx)
#define WB_DOWNLOAD_MICROCODE_AND_REVERT_MODE 4
#define WB_DOWNLOAD_MICROCODE_AND_SAVE_MODE 5
- sata_hba_inst_t *sata_hba_inst = SATA_TXLT_HBA_INST(spx);
struct scsi_pkt *scsipkt = spx->txlt_scsi_pkt;
struct sata_pkt *sata_pkt = spx->txlt_sata_pkt;
sata_cmd_t *scmd = &spx->txlt_sata_pkt->satapkt_cmd;
@@ -6578,18 +6576,18 @@ sata_txlt_write_buffer(sata_pkt_txlate_t *spx)
struct buf *bp = spx->txlt_sata_pkt->satapkt_cmd.satacmd_bp;
struct scsi_extended_sense *sense;
int rval, mode, sector_count, reason;
- int cport = SATA_TXLT_CPORT(spx);
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
mode = scsipkt->pkt_cdbp[1] & 0x1f;
SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
"sata_txlt_write_buffer, mode 0x%x\n", mode);
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if ((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -6645,11 +6643,11 @@ sata_txlt_write_buffer(sata_pkt_txlate_t *spx)
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(sata_hba_inst, cport));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&SATA_CPORT_MUTEX(sata_hba_inst, cport));
+ mutex_exit(cport_mutex);
/* Then we need synchronous check the status of the disk */
scsipkt->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
@@ -6723,7 +6721,7 @@ sata_txlt_write_buffer(sata_pkt_txlate_t *spx)
return (TRAN_ACCEPT);
bad_param:
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
*scsipkt->pkt_scbp = STATUS_CHECK;
sense = sata_arq_sense(spx);
sense->es_key = KEY_ILLEGAL_REQUEST;
@@ -6827,16 +6825,15 @@ static int
sata_txlt_synchronize_cache(sata_pkt_txlate_t *spx)
{
sata_cmd_t *scmd = &spx->txlt_sata_pkt->satapkt_cmd;
- sata_hba_inst_t *shi = SATA_TXLT_HBA_INST(spx);
- int cport = SATA_TXLT_CPORT(spx);
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
int rval, reason;
int synch;
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 1)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -6865,10 +6862,10 @@ sata_txlt_synchronize_cache(sata_pkt_txlate_t *spx)
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&SATA_CPORT_MUTEX(shi, cport));
+ mutex_exit(cport_mutex);
/*
* If execution non-synchronous, it had to be completed
@@ -9331,17 +9328,17 @@ sata_txlt_atapi(sata_pkt_txlate_t *spx)
sata_hba_inst_t *sata_hba = SATA_TXLT_HBA_INST(spx);
sata_drive_info_t *sdinfo = sata_get_device_info(sata_hba,
&spx->txlt_sata_pkt->satapkt_device);
- int cport = SATA_TXLT_CPORT(spx);
+ kmutex_t *cport_mutex = &(SATA_TXLT_CPORT_MUTEX(spx));
int cdblen;
int rval, reason;
int synch;
union scsi_cdb *cdbp = (union scsi_cdb *)scsipkt->pkt_cdbp;
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_enter(cport_mutex);
if (((rval = sata_txlt_generic_pkt_info(spx, &reason, 0)) !=
TRAN_ACCEPT) || (reason == CMD_DEV_GONE)) {
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (rval);
}
@@ -9366,7 +9363,7 @@ sata_txlt_atapi(sata_pkt_txlate_t *spx)
* opcodes 0x7e and 0x7f identify variable-length CDBs and
* therefore require special handling. Return failure, for now.
*/
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (TRAN_BADPKT);
case CDB_GROUPID_6: /* Vendor-specific, per SPC-4 */
@@ -9385,7 +9382,7 @@ sata_txlt_atapi(sata_pkt_txlate_t *spx)
sata_log(NULL, CE_WARN,
"sata: invalid ATAPI cdb length %d",
cdblen);
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
return (TRAN_BADPKT);
}
@@ -9478,10 +9475,10 @@ sata_txlt_atapi(sata_pkt_txlate_t *spx)
/* Transfer command to HBA */
if (sata_hba_start(spx, &rval) != 0) {
/* Pkt not accepted for execution */
- mutex_exit(&SATA_CPORT_MUTEX(sata_hba, cport));
+ mutex_exit(cport_mutex);
return (rval);
}
- mutex_exit(&SATA_CPORT_MUTEX(sata_hba, cport));
+ mutex_exit(cport_mutex);
/*
* If execution is non-synchronous,
* a callback function will handle potential errors, translate
@@ -9885,6 +9882,7 @@ sata_get_atapi_inquiry_data(sata_hba_inst_t *sata_hba,
#ifdef SATA_DEBUG
char msg_buf[MAXPATHLEN];
#endif
+ kmutex_t *cport_mutex;
ASSERT(sata_hba != NULL);
@@ -9925,12 +9923,13 @@ sata_get_atapi_inquiry_data(sata_hba_inst_t *sata_hba,
scmd->satacmd_flags.sata_data_direction = SATA_DIR_READ;
scmd->satacmd_flags.sata_ignore_dev_reset = B_TRUE;
- mutex_enter(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ cport_mutex = &(SATA_CPORT_MUTEX(sata_hba, saddr->cport));
+ mutex_enter(cport_mutex);
sdinfo = sata_get_device_info(sata_hba,
&spx->txlt_sata_pkt->satapkt_device);
if (sdinfo == NULL) {
/* we have to be carefull about the disapearing device */
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
rval = SATA_FAILURE;
goto cleanup;
}
@@ -9957,11 +9956,11 @@ sata_get_atapi_inquiry_data(sata_hba_inst_t *sata_hba,
SATADBG1(SATA_DBG_ATAPI, sata_hba,
"sata_get_atapi_inquiry_data: "
"Packet not accepted for execution - ret: %02x", rval);
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
rval = SATA_FAILURE;
goto cleanup;
}
- mutex_exit(&(SATA_TXLT_CPORT_MUTEX(spx)));
+ mutex_exit(cport_mutex);
if (spkt->satapkt_reason == SATA_PKT_COMPLETED) {
SATADBG1(SATA_DBG_ATAPI, sata_hba,