Skip to content

Commit f799319

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: aacraid: split off device, target, and bus reset
Split off device, target, and bus reset functionality into individual functions. Signed-off-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 2518842 commit f799319

File tree

1 file changed

+102
-39
lines changed

1 file changed

+102
-39
lines changed

drivers/scsi/aacraid/linit.c

Lines changed: 102 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -861,68 +861,129 @@ static u8 aac_eh_tmf_hard_reset_fib(struct aac_dev *aac, struct fib *fib,
861861
}
862862

863863
/*
864-
* aac_eh_reset - Reset command handling
864+
* aac_eh_dev_reset - Device reset command handling
865865
* @scsi_cmd: SCSI command block causing the reset
866866
*
867867
*/
868-
static int aac_eh_reset(struct scsi_cmnd* cmd)
868+
static int aac_eh_dev_reset(struct scsi_cmnd *cmd)
869869
{
870870
struct scsi_device * dev = cmd->device;
871871
struct Scsi_Host * host = dev->host;
872872
struct aac_dev * aac = (struct aac_dev *)host->hostdata;
873873
int count;
874874
u32 bus, cid;
875+
struct fib *fib;
875876
int ret = FAILED;
876-
int status = 0;
877-
877+
int status;
878+
u8 command;
878879

879880
bus = aac_logical_to_phys(scmd_channel(cmd));
880881
cid = scmd_id(cmd);
881-
if (bus < AAC_MAX_BUSES && cid < AAC_MAX_TARGETS &&
882-
aac->hba_map[bus][cid].devtype == AAC_DEVTYPE_NATIVE_RAW) {
883-
struct fib *fib;
884-
int status;
885-
u8 command;
882+
if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
883+
aac->hba_map[bus][cid].devtype != AAC_DEVTYPE_NATIVE_RAW)
884+
return FAILED;
886885

887-
pr_err("%s: Host adapter reset request. SCSI hang ?\n",
888-
AAC_DRIVERNAME);
886+
pr_err("%s: Host adapter reset request. SCSI hang ?\n",
887+
AAC_DRIVERNAME);
889888

890-
fib = aac_fib_alloc(aac);
891-
if (!fib)
892-
return ret;
889+
fib = aac_fib_alloc(aac);
890+
if (!fib)
891+
return ret;
893892

894893

895-
if (aac->hba_map[bus][cid].reset_state == 0) {
896-
/* start a HBA_TMF_LUN_RESET TMF request */
897-
command = aac_eh_tmf_lun_reset_fib(aac, fib,
898-
bus, cid,
899-
cmd->device->lun);
900-
aac->hba_map[bus][cid].reset_state++;
901-
} else if (aac->hba_map[bus][cid].reset_state >= 1) {
902-
/* already tried, start a hard reset now */
903-
command = aac_eh_tmf_hard_reset_fib(aac, fib, bus, cid);
904-
aac->hba_map[bus][cid].reset_state = 0;
894+
/* start a HBA_TMF_LUN_RESET TMF request */
895+
command = aac_eh_tmf_lun_reset_fib(aac, fib, bus, cid,
896+
cmd->device->lun);
897+
898+
cmd->SCp.sent_command = 0;
899+
900+
status = aac_hba_send(command, fib,
901+
(fib_callback) aac_hba_callback,
902+
(void *) cmd);
903+
904+
/* Wait up to 15 seconds for completion */
905+
for (count = 0; count < 15; ++count) {
906+
if (cmd->SCp.sent_command) {
907+
ret = SUCCESS;
908+
break;
905909
}
906-
cmd->SCp.sent_command = 0;
910+
msleep(1000);
911+
}
907912

908-
status = aac_hba_send(command, fib,
909-
(fib_callback) aac_hba_callback,
910-
(void *) cmd);
913+
return ret;
914+
}
911915

912-
/* Wait up to 15 seconds for completion */
913-
for (count = 0; count < 15; ++count) {
914-
if (cmd->SCp.sent_command) {
915-
ret = SUCCESS;
916-
break;
917-
}
918-
msleep(1000);
916+
/*
917+
* aac_eh_target_reset - Target reset command handling
918+
* @scsi_cmd: SCSI command block causing the reset
919+
*
920+
*/
921+
static int aac_eh_target_reset(struct scsi_cmnd *cmd)
922+
{
923+
struct scsi_device * dev = cmd->device;
924+
struct Scsi_Host * host = dev->host;
925+
struct aac_dev * aac = (struct aac_dev *)host->hostdata;
926+
int count;
927+
u32 bus, cid;
928+
int ret = FAILED;
929+
struct fib *fib;
930+
int status;
931+
u8 command;
932+
933+
bus = aac_logical_to_phys(scmd_channel(cmd));
934+
cid = scmd_id(cmd);
935+
if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
936+
aac->hba_map[bus][cid].devtype != AAC_DEVTYPE_NATIVE_RAW)
937+
return FAILED;
938+
939+
pr_err("%s: Host adapter reset request. SCSI hang ?\n",
940+
AAC_DRIVERNAME);
941+
942+
fib = aac_fib_alloc(aac);
943+
if (!fib)
944+
return ret;
945+
946+
947+
/* already tried, start a hard reset now */
948+
command = aac_eh_tmf_hard_reset_fib(aac, fib, bus, cid);
949+
950+
cmd->SCp.sent_command = 0;
951+
952+
status = aac_hba_send(command, fib,
953+
(fib_callback) aac_hba_callback,
954+
(void *) cmd);
955+
956+
/* Wait up to 15 seconds for completion */
957+
for (count = 0; count < 15; ++count) {
958+
if (cmd->SCp.sent_command) {
959+
ret = SUCCESS;
960+
break;
919961
}
962+
msleep(1000);
963+
}
920964

921-
if (ret == SUCCESS)
922-
return ret;
965+
return ret;
966+
}
967+
968+
/*
969+
* aac_eh_bus_reset - Bus reset command handling
970+
* @scsi_cmd: SCSI command block causing the reset
971+
*
972+
*/
973+
static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
974+
{
975+
struct scsi_device * dev = cmd->device;
976+
struct Scsi_Host * host = dev->host;
977+
struct aac_dev * aac = (struct aac_dev *)host->hostdata;
978+
int count;
979+
u32 bus, cid;
980+
int status = 0;
923981

924-
} else {
925982

983+
bus = aac_logical_to_phys(scmd_channel(cmd));
984+
cid = scmd_id(cmd);
985+
if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
986+
aac->hba_map[bus][cid].devtype != AAC_DEVTYPE_NATIVE_RAW) {
926987
/* Mark the assoc. FIB to not complete, eh handler does this */
927988
for (count = 0;
928989
count < (host->can_queue + AAC_NUM_MGT_FIB);
@@ -1409,7 +1470,9 @@ static struct scsi_host_template aac_driver_template = {
14091470
.change_queue_depth = aac_change_queue_depth,
14101471
.sdev_attrs = aac_dev_attrs,
14111472
.eh_abort_handler = aac_eh_abort,
1412-
.eh_bus_reset_handler = aac_eh_reset,
1473+
.eh_device_reset_handler = aac_eh_dev_reset,
1474+
.eh_target_reset_handler = aac_eh_target_reset,
1475+
.eh_bus_reset_handler = aac_eh_bus_reset,
14131476
.eh_host_reset_handler = aac_eh_host_reset,
14141477
.can_queue = AAC_NUM_IO_FIB,
14151478
.this_id = MAXIMUM_NUM_CONTAINERS,

0 commit comments

Comments
 (0)