@@ -366,7 +366,8 @@ static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
366
366
struct scsi_cmnd * cmd );
367
367
static void ahc_linux_freeze_simq (struct ahc_softc * ahc );
368
368
static void ahc_linux_release_simq (struct ahc_softc * ahc );
369
- static int ahc_linux_queue_recovery_cmd (struct scsi_cmnd * cmd , scb_flag flag );
369
+ static int ahc_linux_queue_recovery_cmd (struct scsi_device * sdev ,
370
+ struct scsi_cmnd * cmd );
370
371
static void ahc_linux_initialize_scsi_bus (struct ahc_softc * ahc );
371
372
static u_int ahc_linux_user_tagdepth (struct ahc_softc * ahc ,
372
373
struct ahc_devinfo * devinfo );
@@ -728,7 +729,7 @@ ahc_linux_abort(struct scsi_cmnd *cmd)
728
729
{
729
730
int error ;
730
731
731
- error = ahc_linux_queue_recovery_cmd (cmd , SCB_ABORT );
732
+ error = ahc_linux_queue_recovery_cmd (cmd -> device , cmd );
732
733
if (error != SUCCESS )
733
734
printk ("aic7xxx_abort returns 0x%x\n" , error );
734
735
return (error );
@@ -742,7 +743,7 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd)
742
743
{
743
744
int error ;
744
745
745
- error = ahc_linux_queue_recovery_cmd (cmd , SCB_DEVICE_RESET );
746
+ error = ahc_linux_queue_recovery_cmd (cmd -> device , NULL );
746
747
if (error != SUCCESS )
747
748
printk ("aic7xxx_dev_reset returns 0x%x\n" , error );
748
749
return (error );
@@ -2036,11 +2037,12 @@ ahc_linux_release_simq(struct ahc_softc *ahc)
2036
2037
}
2037
2038
2038
2039
static int
2039
- ahc_linux_queue_recovery_cmd (struct scsi_cmnd * cmd , scb_flag flag )
2040
+ ahc_linux_queue_recovery_cmd (struct scsi_device * sdev ,
2041
+ struct scsi_cmnd * cmd )
2040
2042
{
2041
2043
struct ahc_softc * ahc ;
2042
2044
struct ahc_linux_device * dev ;
2043
- struct scb * pending_scb ;
2045
+ struct scb * pending_scb = NULL , * scb ;
2044
2046
u_int saved_scbptr ;
2045
2047
u_int active_scb_index ;
2046
2048
u_int last_phase ;
@@ -2053,18 +2055,19 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2053
2055
int disconnected ;
2054
2056
unsigned long flags ;
2055
2057
2056
- pending_scb = NULL ;
2057
2058
paused = FALSE;
2058
2059
wait = FALSE;
2059
- ahc = * (struct ahc_softc * * )cmd -> device -> host -> hostdata ;
2060
+ ahc = * (struct ahc_softc * * )sdev -> host -> hostdata ;
2060
2061
2061
- scmd_printk (KERN_INFO , cmd , "Attempting to queue a%s message\n" ,
2062
- flag == SCB_ABORT ? "n ABORT" : " TARGET RESET" );
2062
+ sdev_printk (KERN_INFO , sdev , "Attempting to queue a%s message\n" ,
2063
+ cmd ? "n ABORT" : " TARGET RESET" );
2063
2064
2064
- printk ("CDB:" );
2065
- for (cdb_byte = 0 ; cdb_byte < cmd -> cmd_len ; cdb_byte ++ )
2066
- printk (" 0x%x" , cmd -> cmnd [cdb_byte ]);
2067
- printk ("\n" );
2065
+ if (cmd ) {
2066
+ printk ("CDB:" );
2067
+ for (cdb_byte = 0 ; cdb_byte < cmd -> cmd_len ; cdb_byte ++ )
2068
+ printk (" 0x%x" , cmd -> cmnd [cdb_byte ]);
2069
+ printk ("\n" );
2070
+ }
2068
2071
2069
2072
ahc_lock (ahc , & flags );
2070
2073
@@ -2075,21 +2078,20 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2075
2078
* at all, and the system wanted us to just abort the
2076
2079
* command, return success.
2077
2080
*/
2078
- dev = scsi_transport_device_data (cmd -> device );
2081
+ dev = scsi_transport_device_data (sdev );
2079
2082
2080
2083
if (dev == NULL ) {
2081
2084
/*
2082
2085
* No target device for this command exists,
2083
2086
* so we must not still own the command.
2084
2087
*/
2085
2088
printk ("%s:%d:%d:%d: Is not an active device\n" ,
2086
- ahc_name (ahc ), cmd -> device -> channel , cmd -> device -> id ,
2087
- (u8 )cmd -> device -> lun );
2089
+ ahc_name (ahc ), sdev -> channel , sdev -> id , (u8 )sdev -> lun );
2088
2090
retval = SUCCESS ;
2089
2091
goto no_cmd ;
2090
2092
}
2091
2093
2092
- if ((dev -> flags & (AHC_DEV_Q_BASIC |AHC_DEV_Q_TAGGED )) == 0
2094
+ if (cmd && (dev -> flags & (AHC_DEV_Q_BASIC |AHC_DEV_Q_TAGGED )) == 0
2093
2095
&& ahc_search_untagged_queues (ahc , cmd , cmd -> device -> id ,
2094
2096
cmd -> device -> channel + 'A' ,
2095
2097
(u8 )cmd -> device -> lun ,
@@ -2104,25 +2106,28 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2104
2106
/*
2105
2107
* See if we can find a matching cmd in the pending list.
2106
2108
*/
2107
- LIST_FOREACH (pending_scb , & ahc -> pending_scbs , pending_links ) {
2108
- if (pending_scb -> io_ctx == cmd )
2109
- break ;
2110
- }
2111
-
2112
- if (pending_scb == NULL && flag == SCB_DEVICE_RESET ) {
2113
-
2109
+ if (cmd ) {
2110
+ LIST_FOREACH (scb , & ahc -> pending_scbs , pending_links ) {
2111
+ if (scb -> io_ctx == cmd ) {
2112
+ pending_scb = scb ;
2113
+ break ;
2114
+ }
2115
+ }
2116
+ } else {
2114
2117
/* Any SCB for this device will do for a target reset */
2115
- LIST_FOREACH (pending_scb , & ahc -> pending_scbs , pending_links ) {
2116
- if (ahc_match_scb (ahc , pending_scb , scmd_id ( cmd ) ,
2117
- scmd_channel ( cmd ) + 'A' ,
2118
+ LIST_FOREACH (scb , & ahc -> pending_scbs , pending_links ) {
2119
+ if (ahc_match_scb (ahc , scb , sdev -> id ,
2120
+ sdev -> channel + 'A' ,
2118
2121
CAM_LUN_WILDCARD ,
2119
- SCB_LIST_NULL , ROLE_INITIATOR ))
2122
+ SCB_LIST_NULL , ROLE_INITIATOR )) {
2123
+ pending_scb = scb ;
2120
2124
break ;
2125
+ }
2121
2126
}
2122
2127
}
2123
2128
2124
2129
if (pending_scb == NULL ) {
2125
- scmd_printk (KERN_INFO , cmd , "Command not found\n" );
2130
+ sdev_printk (KERN_INFO , sdev , "Command not found\n" );
2126
2131
goto no_cmd ;
2127
2132
}
2128
2133
@@ -2153,22 +2158,22 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2153
2158
ahc_dump_card_state (ahc );
2154
2159
2155
2160
disconnected = TRUE;
2156
- if (flag == SCB_ABORT ) {
2157
- if (ahc_search_qinfifo (ahc , cmd -> device -> id ,
2158
- cmd -> device -> channel + 'A' ,
2159
- cmd -> device -> lun ,
2161
+ if (cmd ) {
2162
+ if (ahc_search_qinfifo (ahc , sdev -> id ,
2163
+ sdev -> channel + 'A' ,
2164
+ sdev -> lun ,
2160
2165
pending_scb -> hscb -> tag ,
2161
2166
ROLE_INITIATOR , CAM_REQ_ABORTED ,
2162
2167
SEARCH_COMPLETE ) > 0 ) {
2163
2168
printk ("%s:%d:%d:%d: Cmd aborted from QINFIFO\n" ,
2164
- ahc_name (ahc ), cmd -> device -> channel ,
2165
- cmd -> device -> id , (u8 )cmd -> device -> lun );
2169
+ ahc_name (ahc ), sdev -> channel ,
2170
+ sdev -> id , (u8 )sdev -> lun );
2166
2171
retval = SUCCESS ;
2167
2172
goto done ;
2168
2173
}
2169
- } else if (ahc_search_qinfifo (ahc , cmd -> device -> id ,
2170
- cmd -> device -> channel + 'A' ,
2171
- cmd -> device -> lun ,
2174
+ } else if (ahc_search_qinfifo (ahc , sdev -> id ,
2175
+ sdev -> channel + 'A' ,
2176
+ sdev -> lun ,
2172
2177
pending_scb -> hscb -> tag ,
2173
2178
ROLE_INITIATOR , /*status*/ 0 ,
2174
2179
SEARCH_COUNT ) > 0 ) {
@@ -2181,7 +2186,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2181
2186
bus_scb = ahc_lookup_scb (ahc , ahc_inb (ahc , SCB_TAG ));
2182
2187
if (bus_scb == pending_scb )
2183
2188
disconnected = FALSE;
2184
- else if (flag != SCB_ABORT
2189
+ else if (! cmd
2185
2190
&& ahc_inb (ahc , SAVED_SCSIID ) == pending_scb -> hscb -> scsiid
2186
2191
&& ahc_inb (ahc , SAVED_LUN ) == SCB_GET_LUN (pending_scb ))
2187
2192
disconnected = FALSE;
@@ -2201,18 +2206,18 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2201
2206
saved_scsiid = ahc_inb (ahc , SAVED_SCSIID );
2202
2207
if (last_phase != P_BUSFREE
2203
2208
&& (pending_scb -> hscb -> tag == active_scb_index
2204
- || (flag == SCB_DEVICE_RESET
2205
- && SCSIID_TARGET (ahc , saved_scsiid ) == scmd_id (cmd )))) {
2209
+ || (!cmd && SCSIID_TARGET (ahc , saved_scsiid ) == sdev -> id ))) {
2206
2210
2207
2211
/*
2208
2212
* We're active on the bus, so assert ATN
2209
2213
* and hope that the target responds.
2210
2214
*/
2211
2215
pending_scb = ahc_lookup_scb (ahc , active_scb_index );
2212
- pending_scb -> flags |= SCB_RECOVERY_SCB |flag ;
2216
+ pending_scb -> flags |= SCB_RECOVERY_SCB ;
2217
+ pending_scb -> flags |= cmd ? SCB_ABORT : SCB_DEVICE_RESET ;
2213
2218
ahc_outb (ahc , MSG_OUT , HOST_MSG );
2214
2219
ahc_outb (ahc , SCSISIGO , last_phase |ATNO );
2215
- scmd_printk (KERN_INFO , cmd , "Device is active, asserting ATN\n" );
2220
+ sdev_printk (KERN_INFO , sdev , "Device is active, asserting ATN\n" );
2216
2221
wait = TRUE;
2217
2222
} else if (disconnected ) {
2218
2223
@@ -2233,7 +2238,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2233
2238
* an unsolicited reselection occurred.
2234
2239
*/
2235
2240
pending_scb -> hscb -> control |= MK_MESSAGE |DISCONNECTED ;
2236
- pending_scb -> flags |= SCB_RECOVERY_SCB |flag ;
2241
+ pending_scb -> flags |= SCB_RECOVERY_SCB ;
2242
+ pending_scb -> flags |= cmd ? SCB_ABORT : SCB_DEVICE_RESET ;
2237
2243
2238
2244
/*
2239
2245
* Remove any cached copy of this SCB in the
@@ -2242,9 +2248,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2242
2248
* same element in the SCB, SCB_NEXT, for
2243
2249
* both the qinfifo and the disconnected list.
2244
2250
*/
2245
- ahc_search_disc_list (ahc , cmd -> device -> id ,
2246
- cmd -> device -> channel + 'A' ,
2247
- cmd -> device -> lun , pending_scb -> hscb -> tag ,
2251
+ ahc_search_disc_list (ahc , sdev -> id ,
2252
+ sdev -> channel + 'A' ,
2253
+ sdev -> lun , pending_scb -> hscb -> tag ,
2248
2254
/*stop_on_first*/ TRUE,
2249
2255
/*remove*/ TRUE,
2250
2256
/*save_state*/ FALSE);
@@ -2267,9 +2273,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2267
2273
* so we are the next SCB for this target
2268
2274
* to run.
2269
2275
*/
2270
- ahc_search_qinfifo (ahc , cmd -> device -> id ,
2271
- cmd -> device -> channel + 'A' ,
2272
- cmd -> device -> lun , SCB_LIST_NULL ,
2276
+ ahc_search_qinfifo (ahc , sdev -> id ,
2277
+ sdev -> channel + 'A' ,
2278
+ ( u8 ) sdev -> lun , SCB_LIST_NULL ,
2273
2279
ROLE_INITIATOR , CAM_REQUEUE_REQ ,
2274
2280
SEARCH_COMPLETE );
2275
2281
ahc_qinfifo_requeue_tail (ahc , pending_scb );
@@ -2278,7 +2284,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2278
2284
printk ("Device is disconnected, re-queuing SCB\n" );
2279
2285
wait = TRUE;
2280
2286
} else {
2281
- scmd_printk (KERN_INFO , cmd , "Unable to deliver message\n" );
2287
+ sdev_printk (KERN_INFO , sdev , "Unable to deliver message\n" );
2282
2288
retval = FAILED ;
2283
2289
goto done ;
2284
2290
}
0 commit comments