From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
James Bottomley <james.bottomley@hansenpartnership.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Hannes Reinecke <hare@suse.com>
Subject: [PATCH 42/51] aic7xxx: do not reference scsi command when resetting device
Date: Tue, 17 Aug 2021 11:14:47 +0200 [thread overview]
Message-ID: <20210817091456.73342-43-hare@suse.de> (raw)
In-Reply-To: <20210817091456.73342-1-hare@suse.de>
When sending a device reset we should not take a reference to the
scsi command.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/scsi/aic7xxx/aic7xxx_osm.c | 102 +++++++++++++++--------------
1 file changed, 54 insertions(+), 48 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 36e58cf0416b..26ca71e2ddd0 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -366,7 +366,8 @@ static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc,
struct scsi_cmnd *cmd);
static void ahc_linux_freeze_simq(struct ahc_softc *ahc);
static void ahc_linux_release_simq(struct ahc_softc *ahc);
-static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag);
+static int ahc_linux_queue_recovery_cmd(struct scsi_device *sdev,
+ struct scsi_cmnd *cmd);
static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc);
static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc,
struct ahc_devinfo *devinfo);
@@ -730,7 +731,7 @@ ahc_linux_abort(struct scsi_cmnd *cmd)
{
int error;
- error = ahc_linux_queue_recovery_cmd(cmd, SCB_ABORT);
+ error = ahc_linux_queue_recovery_cmd(cmd->device, cmd);
if (error != SUCCESS)
printk("aic7xxx_abort returns 0x%x\n", error);
return (error);
@@ -744,7 +745,7 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd)
{
int error;
- error = ahc_linux_queue_recovery_cmd(cmd, SCB_DEVICE_RESET);
+ error = ahc_linux_queue_recovery_cmd(cmd->device, NULL);
if (error != SUCCESS)
printk("aic7xxx_dev_reset returns 0x%x\n", error);
return (error);
@@ -2031,11 +2032,12 @@ ahc_linux_release_simq(struct ahc_softc *ahc)
}
static int
-ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
+ahc_linux_queue_recovery_cmd(struct scsi_device *sdev,
+ struct scsi_cmnd *cmd)
{
struct ahc_softc *ahc;
struct ahc_linux_device *dev;
- struct scb *pending_scb;
+ struct scb *pending_scb = NULL, *scb;
u_int saved_scbptr;
u_int active_scb_index;
u_int last_phase;
@@ -2048,18 +2050,19 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
int disconnected;
unsigned long flags;
- pending_scb = NULL;
paused = FALSE;
wait = FALSE;
- ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
+ ahc = *(struct ahc_softc **)sdev->host->hostdata;
- scmd_printk(KERN_INFO, cmd, "Attempting to queue a%s message\n",
- flag == SCB_ABORT ? "n ABORT" : " TARGET RESET");
+ sdev_printk(KERN_INFO, sdev, "Attempting to queue a%s message\n",
+ cmd ? "n ABORT" : " TARGET RESET");
- printk("CDB:");
- for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++)
- printk(" 0x%x", cmd->cmnd[cdb_byte]);
- printk("\n");
+ if (cmd) {
+ printk("CDB:");
+ for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++)
+ printk(" 0x%x", cmd->cmnd[cdb_byte]);
+ printk("\n");
+ }
ahc_lock(ahc, &flags);
@@ -2070,7 +2073,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
* at all, and the system wanted us to just abort the
* command, return success.
*/
- dev = scsi_transport_device_data(cmd->device);
+ dev = scsi_transport_device_data(sdev);
if (dev == NULL) {
/*
@@ -2078,13 +2081,12 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
* so we must not still own the command.
*/
printk("%s:%d:%d:%d: Is not an active device\n",
- ahc_name(ahc), cmd->device->channel, cmd->device->id,
- (u8)cmd->device->lun);
+ ahc_name(ahc), sdev->channel, sdev->id, (u8)sdev->lun);
retval = SUCCESS;
goto no_cmd;
}
- if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0
+ if (cmd && (dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0
&& ahc_search_untagged_queues(ahc, cmd, cmd->device->id,
cmd->device->channel + 'A',
(u8)cmd->device->lun,
@@ -2099,25 +2101,28 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
/*
* See if we can find a matching cmd in the pending list.
*/
- LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
- if (pending_scb->io_ctx == cmd)
+ LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) {
+ if (cmd && scb->io_ctx == cmd) {
+ pending_scb = scb;
break;
+ }
}
- if (pending_scb == NULL && flag == SCB_DEVICE_RESET) {
-
+ if (!cmd) {
/* Any SCB for this device will do for a target reset */
- LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
- if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd),
- scmd_channel(cmd) + 'A',
+ LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) {
+ if (ahc_match_scb(ahc, scb, sdev->id,
+ sdev->channel + 'A',
CAM_LUN_WILDCARD,
- SCB_LIST_NULL, ROLE_INITIATOR))
+ SCB_LIST_NULL, ROLE_INITIATOR)) {
+ pending_scb = scb;
break;
+ }
}
}
if (pending_scb == NULL) {
- scmd_printk(KERN_INFO, cmd, "Command not found\n");
+ sdev_printk(KERN_INFO, sdev, "Command not found\n");
goto no_cmd;
}
@@ -2148,22 +2153,22 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
ahc_dump_card_state(ahc);
disconnected = TRUE;
- if (flag == SCB_ABORT) {
- if (ahc_search_qinfifo(ahc, cmd->device->id,
- cmd->device->channel + 'A',
- cmd->device->lun,
+ if (cmd) {
+ if (ahc_search_qinfifo(ahc, sdev->id,
+ sdev->channel + 'A',
+ sdev->lun,
pending_scb->hscb->tag,
ROLE_INITIATOR, CAM_REQ_ABORTED,
SEARCH_COMPLETE) > 0) {
printk("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
- ahc_name(ahc), cmd->device->channel,
- cmd->device->id, (u8)cmd->device->lun);
+ ahc_name(ahc), sdev->channel,
+ sdev->id, (u8)sdev->lun);
retval = SUCCESS;
goto done;
}
- } else if (ahc_search_qinfifo(ahc, cmd->device->id,
- cmd->device->channel + 'A',
- cmd->device->lun,
+ } else if (ahc_search_qinfifo(ahc, sdev->id,
+ sdev->channel + 'A',
+ sdev->lun,
pending_scb->hscb->tag,
ROLE_INITIATOR, /*status*/0,
SEARCH_COUNT) > 0) {
@@ -2176,7 +2181,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
bus_scb = ahc_lookup_scb(ahc, ahc_inb(ahc, SCB_TAG));
if (bus_scb == pending_scb)
disconnected = FALSE;
- else if (flag != SCB_ABORT
+ else if (!cmd
&& ahc_inb(ahc, SAVED_SCSIID) == pending_scb->hscb->scsiid
&& ahc_inb(ahc, SAVED_LUN) == SCB_GET_LUN(pending_scb))
disconnected = FALSE;
@@ -2196,18 +2201,18 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
saved_scsiid = ahc_inb(ahc, SAVED_SCSIID);
if (last_phase != P_BUSFREE
&& (pending_scb->hscb->tag == active_scb_index
- || (flag == SCB_DEVICE_RESET
- && SCSIID_TARGET(ahc, saved_scsiid) == scmd_id(cmd)))) {
+ || (!cmd && SCSIID_TARGET(ahc, saved_scsiid) == sdev->id))) {
/*
* We're active on the bus, so assert ATN
* and hope that the target responds.
*/
pending_scb = ahc_lookup_scb(ahc, active_scb_index);
- pending_scb->flags |= SCB_RECOVERY_SCB|flag;
+ pending_scb->flags |= SCB_RECOVERY_SCB;
+ pending_scb->flags |= cmd ? SCB_ABORT : SCB_DEVICE_RESET;
ahc_outb(ahc, MSG_OUT, HOST_MSG);
ahc_outb(ahc, SCSISIGO, last_phase|ATNO);
- scmd_printk(KERN_INFO, cmd, "Device is active, asserting ATN\n");
+ sdev_printk(KERN_INFO, sdev, "Device is active, asserting ATN\n");
wait = TRUE;
} else if (disconnected) {
@@ -2228,7 +2233,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
* an unsolicited reselection occurred.
*/
pending_scb->hscb->control |= MK_MESSAGE|DISCONNECTED;
- pending_scb->flags |= SCB_RECOVERY_SCB|flag;
+ pending_scb->flags |= SCB_RECOVERY_SCB;
+ pending_scb->flags |= cmd ? SCB_ABORT : SCB_DEVICE_RESET;
/*
* Remove any cached copy of this SCB in the
@@ -2237,9 +2243,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
* same element in the SCB, SCB_NEXT, for
* both the qinfifo and the disconnected list.
*/
- ahc_search_disc_list(ahc, cmd->device->id,
- cmd->device->channel + 'A',
- cmd->device->lun, pending_scb->hscb->tag,
+ ahc_search_disc_list(ahc, sdev->id,
+ sdev->channel + 'A',
+ sdev->lun, pending_scb->hscb->tag,
/*stop_on_first*/TRUE,
/*remove*/TRUE,
/*save_state*/FALSE);
@@ -2262,9 +2268,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
* so we are the next SCB for this target
* to run.
*/
- ahc_search_qinfifo(ahc, cmd->device->id,
- cmd->device->channel + 'A',
- cmd->device->lun, SCB_LIST_NULL,
+ ahc_search_qinfifo(ahc, sdev->id,
+ sdev->channel + 'A',
+ (u8)sdev->lun, SCB_LIST_NULL,
ROLE_INITIATOR, CAM_REQUEUE_REQ,
SEARCH_COMPLETE);
ahc_qinfifo_requeue_tail(ahc, pending_scb);
@@ -2273,7 +2279,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
printk("Device is disconnected, re-queuing SCB\n");
wait = TRUE;
} else {
- scmd_printk(KERN_INFO, cmd, "Unable to deliver message\n");
+ sdev_printk(KERN_INFO, sdev, "Unable to deliver message\n");
retval = FAILED;
goto done;
}
--
2.29.2
next prev parent reply other threads:[~2021-08-17 9:17 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 9:14 [PATCHv2 00/51] SCSI EH argument reshuffle part II Hannes Reinecke
2021-08-17 9:14 ` [PATCH 01/51] lpfc: kill lpfc_bus_reset_handler Hannes Reinecke
2021-08-17 17:37 ` James Smart
2021-08-17 9:14 ` [PATCH 02/51] lpfc: drop lpfc_no_handler() Hannes Reinecke
2021-08-17 12:13 ` Christoph Hellwig
2021-08-17 17:36 ` James Smart
2021-08-17 9:14 ` [PATCH 03/51] sym53c8xx_2: split off bus reset from host reset Hannes Reinecke
2021-08-17 12:18 ` Christoph Hellwig
2021-08-17 9:14 ` [PATCH 04/51] ips: Do not try to abort command " Hannes Reinecke
2021-08-17 9:14 ` [PATCH 05/51] snic: reserve tag for TMF Hannes Reinecke
2021-08-17 12:21 ` Christoph Hellwig
2021-08-17 9:14 ` [PATCH 06/51] qla1280: separate out host reset function from qla1280_error_action() Hannes Reinecke
2021-08-17 12:22 ` Christoph Hellwig
2021-08-17 14:05 ` Hannes Reinecke
2021-08-17 9:14 ` [PATCH 07/51] megaraid: pass in NULL scb for host reset Hannes Reinecke
2021-08-17 12:26 ` Christoph Hellwig
2021-08-17 13:46 ` Hannes Reinecke
2021-08-17 9:14 ` [PATCH 08/51] zfcp: open-code fc_block_scsi_eh() " Hannes Reinecke
2021-08-17 11:53 ` Benjamin Block
2021-08-17 12:54 ` Hannes Reinecke
2021-08-17 14:03 ` Steffen Maier
2021-08-17 14:10 ` Hannes Reinecke
2021-08-18 11:00 ` Steffen Maier
2021-08-18 11:58 ` Hannes Reinecke
2021-08-17 9:14 ` [PATCH 09/51] mpi3mr: split off bus_reset function from host_reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 10/51] scsi: Use Scsi_Host as argument for eh_host_reset_handler Hannes Reinecke
2021-08-17 14:55 ` Steffen Maier
2021-08-19 18:34 ` Bart Van Assche
2021-08-17 9:14 ` [PATCH 11/51] mptfc: simplify mpt_fc_block_error_handler() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 12/51] mptfusion: correct definitions for mptscsih_dev_reset() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 13/51] mptfc: open-code mptfc_block_error_handler() for bus reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 14/51] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 15/51] qla2xxx: open-code qla2xxx_generic_reset() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 16/51] qla2xxx: Do not call fc_block_scsi_eh() during bus reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 17/51] visorhba: select first device on the bus for bus_reset() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 18/51] ncr53c8xx: remove 'sync_reset' argument from ncr_reset_bus() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 19/51] ncr53c8xx: Complete all commands during bus reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 20/51] ncr53c8xx: Remove unused code Hannes Reinecke
2021-08-17 9:14 ` [PATCH 21/51] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 22/51] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 23/51] bnx2fc: Do not rely on a scsi command when issueing lun or target reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 24/51] ibmvfc: open-code reset loop for " Hannes Reinecke
2021-08-17 9:14 ` [PATCH 25/51] lpfc: use fc_block_rport() Hannes Reinecke
2021-08-18 16:35 ` James Smart
2021-08-17 9:14 ` [PATCH 26/51] lpfc: use rport as argument for lpfc_send_taskmgmt() Hannes Reinecke
2021-08-18 16:35 ` James Smart
2021-08-17 9:14 ` [PATCH 27/51] lpfc: use rport as argument for lpfc_chk_tgt_mapped() Hannes Reinecke
2021-08-18 16:36 ` James Smart
2021-08-17 9:14 ` [PATCH 28/51] csiostor: use fc_block_rport() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 29/51] qla2xxx: " Hannes Reinecke
2021-08-17 9:14 ` [PATCH 30/51] fc_fcp: " Hannes Reinecke
2021-08-17 9:14 ` [PATCH 31/51] qedf: use fc rport as argument for qedf_initiate_tmf() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 32/51] sym53c8xx_2: rework reset handling Hannes Reinecke
2021-08-17 9:14 ` [PATCH 33/51] bfa: Do not use scsi command to signal TMF status Hannes Reinecke
2021-08-17 9:14 ` [PATCH 34/51] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 35/51] pmcraid: select first available device for target reset Hannes Reinecke
2021-08-17 9:14 ` [PATCH 36/51] scsi: Use scsi_target as argument for eh_target_reset_handler() Hannes Reinecke
2021-08-17 15:53 ` Steffen Maier
2021-08-18 16:37 ` James Smart
2021-08-19 18:37 ` Bart Van Assche
2021-08-17 9:14 ` [PATCH 37/51] aha152x: look for stuck command when resetting device Hannes Reinecke
2021-08-18 0:43 ` Finn Thain
2021-08-17 9:14 ` [PATCH 38/51] fnic: use dedicated device reset command Hannes Reinecke
2021-08-17 9:14 ` [PATCH 39/51] a1000u2w: do not rely on the command for inia100_device_reset() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 40/51] aic7xxx: use scsi device as argument for BUILD_SCSIID() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 41/51] aic79xx: " Hannes Reinecke
2021-08-17 9:14 ` Hannes Reinecke [this message]
2021-08-17 9:14 ` [PATCH 43/51] aic79xx: do not reference scsi command when resetting device Hannes Reinecke
2021-08-17 9:14 ` [PATCH 44/51] xen-scsifront: add scsi device as argument to scsifront_do_request() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 45/51] fas216: Rework device reset to not rely on SCSI command pointer Hannes Reinecke
2021-08-17 9:14 ` [PATCH 46/51] csiostor: use separate TMF command Hannes Reinecke
2021-08-17 9:14 ` [PATCH 47/51] snic: use dedicated device reset command Hannes Reinecke
2021-08-17 9:14 ` [PATCH 48/51] snic: Use scsi_host_busy_iter() to traverse commands Hannes Reinecke
2021-08-17 9:14 ` [PATCH 49/51] scsi: Move eh_device_reset_handler() to use scsi_device as argument Hannes Reinecke
2021-08-17 16:13 ` Steffen Maier
2021-08-17 18:09 ` Hannes Reinecke
2021-08-17 9:14 ` [PATCH 50/51] scsi: Do not allocate scsi command in scsi_ioctl_reset() Hannes Reinecke
2021-08-17 9:14 ` [PATCH 51/51] scsi_error: streamline scsi_eh_bus_device_reset() Hannes Reinecke
2021-08-17 12:13 ` [PATCHv2 00/51] SCSI EH argument reshuffle part II Christoph Hellwig
2021-08-17 12:55 ` Hannes Reinecke
2022-02-23 12:49 ` Christoph Hellwig
2022-02-23 13:03 ` Hannes Reinecke
2022-02-23 13:05 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210817091456.73342-43-hare@suse.de \
--to=hare@suse.de \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).