From patchwork Mon May 2 21:54:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0896BC433EF for ; Mon, 2 May 2022 21:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387775AbiEBV6f (ORCPT ); Mon, 2 May 2022 17:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346047AbiEBV5w (ORCPT ); Mon, 2 May 2022 17:57:52 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E1A630B for ; Mon, 2 May 2022 14:54:21 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 85CC4210E4; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=grGOyvjqtNuoSpgbKAnaztGM3uA0gTsCWUxiXlhAWEc=; b=W6Isxpaj+e7pUZrzN5sHygAQ0UGIefiXcePGzqTVWhVfgylCs8jffB+IyB/61Mns/YWrCD oSV+vih/aKdDu1+nWt3KdY1LCJdUkSxFt6mpqEYzQgheZbXRuWGAdeCgAM/0vujBMMM858 0gWlE2kd3zXCd5U+uuZcCRiOBOK3aPc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=grGOyvjqtNuoSpgbKAnaztGM3uA0gTsCWUxiXlhAWEc=; b=8oXzb4kFhaw4SaXTzqecJ/TFNySjNyVyvnV77tWyXGQElxX3Q14jeJ0mW1l+xQ0Toqi74D K5akL4H6wIC0JkCA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 7D1652C142; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 6DB775194128; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Date: Mon, 2 May 2022 23:54:06 +0200 Message-Id: <20220502215416.5351-2-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The reset code requires a device to be selected, but we shouldn't rely on the command to provide a device for us. So select the first device on the bus when sending down a bus reset. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/pmcraid.c | 46 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 3d5cd337a2a6..d508e81a03db 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -2691,7 +2691,7 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd) * SUCCESS / FAILED */ static int pmcraid_reset_device( - struct scsi_cmnd *scsi_cmd, + struct scsi_device *scsi_dev, unsigned long timeout, u8 modifier) { @@ -2703,11 +2703,11 @@ static int pmcraid_reset_device( u32 ioasc; pinstance = - (struct pmcraid_instance *)scsi_cmd->device->host->hostdata; - res = scsi_cmd->device->hostdata; + (struct pmcraid_instance *)scsi_dev->host->hostdata; + res = scsi_dev->hostdata; if (!res) { - sdev_printk(KERN_ERR, scsi_cmd->device, + sdev_printk(KERN_ERR, scsi_dev, "reset_device: NULL resource pointer\n"); return FAILED; } @@ -3018,16 +3018,46 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd) { scmd_printk(KERN_INFO, scmd, "resetting device due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd, + return pmcraid_reset_device(scmd->device, PMCRAID_INTERNAL_TIMEOUT, RESET_DEVICE_LUN); } static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd) { - scmd_printk(KERN_INFO, scmd, + struct Scsi_Host *host = scmd->device->host; + struct pmcraid_instance *pinstance = + (struct pmcraid_instance *)host->hostdata; + struct pmcraid_resource_entry *res = NULL; + struct pmcraid_resource_entry *temp; + struct scsi_device *sdev = NULL; + unsigned long lock_flags; + + /* + * The reset device code insists on us passing down + * a device, so grab the first device on the bus. + */ + spin_lock_irqsave(&pinstance->resource_lock, lock_flags); + list_for_each_entry(temp, &pinstance->used_res_q, queue) { + if (scmd->device->channel == PMCRAID_VSET_BUS_ID && + RES_IS_VSET(temp->cfg_entry)) { + res = temp; + break; + } else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID && + RES_IS_GSCSI(temp->cfg_entry)) { + res = temp; + break; + } + } + if (res) + sdev = res->scsi_dev; + spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags); + if (!sdev) + return FAILED; + + sdev_printk(KERN_INFO, sdev, "Doing bus reset due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd, + return pmcraid_reset_device(sdev, PMCRAID_RESET_BUS_TIMEOUT, RESET_DEVICE_BUS); } @@ -3036,7 +3066,7 @@ static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) { scmd_printk(KERN_INFO, scmd, "Doing target reset due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd, + return pmcraid_reset_device(scmd->device, PMCRAID_INTERNAL_TIMEOUT, RESET_DEVICE_TARGET); } From patchwork Mon May 2 21:54:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B9F1C433FE for ; Mon, 2 May 2022 21:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387797AbiEBV6Y (ORCPT ); Mon, 2 May 2022 17:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380519AbiEBV5w (ORCPT ); Mon, 2 May 2022 17:57:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D607D6310 for ; Mon, 2 May 2022 14:54:21 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8A63F1F749; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UouVL6NHMD7jslsWPvTjzgbNmTH0cJ9J/Qvv7QZUAfQ=; b=GmLCKlkW3SUEA8xlGDrA2yaPElHlrf1sGyoj063iz2mqtmm/hlXL02v86mjkH42tph4IiT krRZdkmEEux4HxieZpbC4a8UZbiDtc08f6jVJeYjjlSncK2g96tEuutJB+me00l0uU0vgG vf6h7agMEeOKckip6sdADf5JExrT9GU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UouVL6NHMD7jslsWPvTjzgbNmTH0cJ9J/Qvv7QZUAfQ=; b=spTb0QbSBDQvBvLX66ITBQuptSXZj9RWurqVEdXadFet1uYRlrwz1rYMgQACu2rTOvNx00 4K34a2OAB8PQEPBA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 81A4E2C143; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 7224F519412A; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 02/11] sym53c8xx_2: rework reset handling Date: Mon, 2 May 2022 23:54:07 +0200 Message-Id: <20220502215416.5351-3-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Split off the combined abort and device reset handling into distinct functions. And the current device reset handler really is a target reset, so rename it. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/sym53c8xx_2/sym_glue.c | 82 +++++++++++++++++++---------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 9166af69bbb4..cb8885eb5a5b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -564,7 +564,10 @@ static void sym53c8xx_timer(struct timer_list *t) * Generic method for our eh processing. * The 'op' argument tells what we have to do. */ -static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) +/* + * Error handlers called from the eh thread (one thread per HBA). + */ +static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd) { struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); struct Scsi_Host *shost = cmd->device->host; @@ -576,7 +579,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) int sts = -1; struct completion eh_done; - scmd_printk(KERN_WARNING, cmd, "%s operation started\n", opname); + scmd_printk(KERN_WARNING, cmd, "ABORT operation started\n"); /* * Escalate to host reset if the PCI bus went down @@ -594,19 +597,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) } } - /* Try to proceed the operation we have been asked for */ - sts = -1; - switch(op) { - case SYM_EH_ABORT: - sts = sym_abort_scsiio(np, cmd, 1); - break; - case SYM_EH_DEVICE_RESET: - sts = sym_reset_scsi_target(np, cmd->device->id); - break; - default: - break; - } - + sts = sym_abort_scsiio(np, cmd, 1); /* On error, restore everything and cross fingers :) */ if (sts) cmd_queued = 0; @@ -623,23 +614,60 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) spin_unlock_irq(shost->host_lock); } - dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname, + dev_warn(&cmd->device->sdev_gendev, "ABORT operation %s.\n", sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); return sts ? SCSI_FAILED : SCSI_SUCCESS; } - -/* - * Error handlers called from the eh thread (one thread per HBA). - */ -static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd) +static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd) { - return sym_eh_handler(SYM_EH_ABORT, "ABORT", cmd); -} + struct scsi_target *starget = scsi_target(cmd->device); + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; + SYM_QUEHEAD *qp; + int sts; + struct completion eh_done; -static int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd) -{ - return sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd); + starget_printk(KERN_WARNING, starget, + "TARGET RESET operation started\n"); + + /* + * Escalate to host reset if the PCI bus went down + */ + if (pci_channel_offline(pdev)) + return SCSI_FAILED; + + spin_lock_irq(shost->host_lock); + sts = sym_reset_scsi_target(np, starget->id); + if (!sts) { + FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { + struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, + link_ccbq); + struct scsi_cmnd *cmd = cp->cmd; + struct sym_ucmd *ucmd; + + if (!cmd || cmd->device->channel != starget->channel || + cmd->device->id != starget->id) + continue; + + ucmd = SYM_UCMD_PTR(cmd); + init_completion(&eh_done); + ucmd->eh_done = &eh_done; + spin_unlock_irq(shost->host_lock); + if (!wait_for_completion_timeout(&eh_done, 5*HZ)) { + ucmd->eh_done = NULL; + sts = -2; + } + spin_lock_irq(shost->host_lock); + } + } + spin_unlock_irq(shost->host_lock); + + starget_printk(KERN_WARNING, starget, "TARGET RESET operation %s.\n", + sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); + return SCSI_SUCCESS; } static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd) @@ -1660,7 +1688,7 @@ static struct scsi_host_template sym2_template = { .slave_configure = sym53c8xx_slave_configure, .slave_destroy = sym53c8xx_slave_destroy, .eh_abort_handler = sym53c8xx_eh_abort_handler, - .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, + .eh_target_reset_handler = sym53c8xx_eh_target_reset_handler, .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, .eh_host_reset_handler = sym53c8xx_eh_host_reset_handler, .this_id = 7, From patchwork Mon May 2 21:54:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 057CFC433EF for ; Mon, 2 May 2022 21:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381151AbiEBV63 (ORCPT ); Mon, 2 May 2022 17:58:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387787AbiEBV5w (ORCPT ); Mon, 2 May 2022 17:57:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01564640B for ; Mon, 2 May 2022 14:54:22 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8B7411F74A; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gp1sTnpdEMPcdbQQrGqi+QDdXS8aROeziBusgCgr98c=; b=fnCdGiQeSSkpbIbLMmL6X2xgXd7Y4zp1J2CvBIouxh8YnxfMGfgZUOTliRAJnon7vCDfup kYnIJqYj+M/iEzx51ESt8/I3oxGv/PedtLkqROmJzTe7zqlsERvXdUo0ZySlI8gUchkxr9 ZwF9NkLnbYsC5hRDbbJBJMRfnEtnecs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gp1sTnpdEMPcdbQQrGqi+QDdXS8aROeziBusgCgr98c=; b=BhDPnIYMgmHN5SgOB8T5O6/rGMe0uGppak54r/revMmu1t0u7b4Z8DdzFLzXiIszgePYiD cRhoh2v2MxCW+iBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 81DAD2C145; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 77820519412C; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset Date: Mon, 2 May 2022 23:54:08 +0200 Message-Id: <20220502215416.5351-4-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org iscsi_eh_target_reset() and iscsi_eh_session_reset() only depend on the cls_session, so use that as an argument. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/be2iscsi/be_main.c | 10 +++++++++- drivers/scsi/libiscsi.c | 21 +++++++++------------ include/scsi/libiscsi.h | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 3bb0adefbe06..55addd7f5c81 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -370,6 +370,14 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) return rc; } +static int beiscsi_eh_session_reset(struct scsi_cmnd *sc) +{ + struct iscsi_cls_session *cls_session; + + cls_session = starget_to_session(scsi_target(sc->device)); + return iscsi_eh_session_reset(cls_session); +} + /*------------------- PCI Driver operations and data ----------------- */ static const struct pci_device_id beiscsi_pci_id_table[] = { { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, @@ -393,7 +401,7 @@ static struct scsi_host_template beiscsi_sht = { .eh_timed_out = iscsi_eh_cmd_timed_out, .eh_abort_handler = beiscsi_eh_abort, .eh_device_reset_handler = beiscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_session_reset, + .eh_target_reset_handler = beiscsi_eh_session_reset, .shost_groups = beiscsi_groups, .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, .can_queue = BE2_IO_DEPTH, diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 797abf4f5399..30f7737928bb 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2494,13 +2494,11 @@ EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout); * This function will wait for a relogin, session termination from * userspace, or a recovery/replacement timeout. */ -int iscsi_eh_session_reset(struct scsi_cmnd *sc) +int iscsi_eh_session_reset(struct iscsi_cls_session *cls_session) { - struct iscsi_cls_session *cls_session; struct iscsi_session *session; struct iscsi_conn *conn; - cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; mutex_lock(&session->eh_mutex); @@ -2547,7 +2545,7 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) } EXPORT_SYMBOL_GPL(iscsi_eh_session_reset); -static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr) +static void iscsi_prep_tgt_reset_pdu(struct iscsi_tm *hdr) { memset(hdr, 0, sizeof(*hdr)); hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE; @@ -2562,19 +2560,16 @@ static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr) * * This will attempt to send a warm target reset. */ -static int iscsi_eh_target_reset(struct scsi_cmnd *sc) +static int iscsi_eh_target_reset(struct iscsi_cls_session *cls_session) { - struct iscsi_cls_session *cls_session; struct iscsi_session *session; struct iscsi_conn *conn; struct iscsi_tm *hdr; int rc = FAILED; - cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; - ISCSI_DBG_EH(session, "tgt Reset [sc %p tgt %s]\n", sc, - session->targetname); + ISCSI_DBG_EH(session, "tgt Reset [tgt %s]\n", session->targetname); mutex_lock(&session->eh_mutex); spin_lock_bh(&session->frwd_lock); @@ -2592,7 +2587,7 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc) session->tmf_state = TMF_QUEUED; hdr = &session->tmhdr; - iscsi_prep_tgt_reset_pdu(sc, hdr); + iscsi_prep_tgt_reset_pdu(hdr); if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, session->tgt_reset_timeout)) { @@ -2644,11 +2639,13 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc) */ int iscsi_eh_recover_target(struct scsi_cmnd *sc) { + struct iscsi_cls_session *cls_session; int rc; - rc = iscsi_eh_target_reset(sc); + cls_session = starget_to_session(scsi_target(sc->device)); + rc = iscsi_eh_target_reset(cls_session); if (rc == FAILED) - rc = iscsi_eh_session_reset(sc); + rc = iscsi_eh_session_reset(cls_session); return rc; } EXPORT_SYMBOL_GPL(iscsi_eh_recover_target); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index d0a24779c52d..ce8d5b5dc0d3 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -391,7 +391,7 @@ struct iscsi_host { */ extern int iscsi_eh_abort(struct scsi_cmnd *sc); extern int iscsi_eh_recover_target(struct scsi_cmnd *sc); -extern int iscsi_eh_session_reset(struct scsi_cmnd *sc); +extern int iscsi_eh_session_reset(struct iscsi_cls_session *cls_session); extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc); extern enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc); From patchwork Mon May 2 21:54:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE344C433EF for ; Mon, 2 May 2022 21:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383542AbiEBV6k (ORCPT ); Mon, 2 May 2022 17:58:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387740AbiEBV5w (ORCPT ); Mon, 2 May 2022 17:57:52 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 006A1640A for ; Mon, 2 May 2022 14:54:21 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8EC05210ED; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eV3bVFMcfcndAL+wJ/F3x57k0w2HiqDO+IfUA2JvRMU=; b=ujMUZ9Ulrh+Gav/+zHYNneNZrn4kbrwW6G5Wy0z9HsIJz9fwhb1ExdaRByiM7JbIzG0rKb Sm/oLhPsZJ2fX7oLhr+muCSCqKXSsEo0iAFNfDu6sG5GURwHzftgNDBOaBC0hzaTcShYNR ovktP+00zDHxXyy7vQGErJ+w//RnoBM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eV3bVFMcfcndAL+wJ/F3x57k0w2HiqDO+IfUA2JvRMU=; b=ETsBH7VTnyCQZTAufwyCbK2yGf+vOxdqrPunVaVYiFGDvU9gwmNiVurwUTMsIVy74ceM2a kwL+VVy76gaaH0CQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 8579D2C146; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 7E1D4519412E; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Date: Mon, 2 May 2022 23:54:09 +0200 Message-Id: <20220502215416.5351-5-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We should be passing in the session directly instead of deriving it from the scsi command. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/qla4xxx/ql4_os.c | 34 ++++++++++++++++++----------- drivers/scsi/scsi_transport_iscsi.c | 6 ++--- include/scsi/scsi_transport_iscsi.h | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 3f6cb2a5c2c2..f4969b99c07f 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -9262,15 +9262,18 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd) **/ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) { - struct scsi_qla_host *ha = to_qla_host(cmd->device->host); - struct ddb_entry *ddb_entry = cmd->device->hostdata; + struct scsi_device *sdev = cmd->device; + struct scsi_qla_host *ha = to_qla_host(sdev->host); + struct iscsi_cls_session *session; + struct ddb_entry *ddb_entry = sdev->hostdata; int ret = FAILED, stat; int rval; if (!ddb_entry) return ret; - ret = iscsi_block_scsi_eh(cmd); + session = starget_to_session(scsi_target(sdev)); + ret = iscsi_block_scsi_eh(session); if (ret) return ret; ret = FAILED; @@ -9331,19 +9334,25 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) **/ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) { - struct scsi_qla_host *ha = to_qla_host(cmd->device->host); - struct ddb_entry *ddb_entry = cmd->device->hostdata; + struct scsi_target *starget = scsi_target(cmd->device); + struct iscsi_cls_session *cls_session = starget_to_session(starget); + struct iscsi_session *sess; + struct scsi_qla_host *ha; + struct ddb_entry *ddb_entry; int stat, ret; int rval; + sess = cls_session->dd_data; + ddb_entry = sess->dd_data; if (!ddb_entry) return FAILED; + ha = ddb_entry->ha; - ret = iscsi_block_scsi_eh(cmd); + ret = iscsi_block_scsi_eh(cls_session); if (ret) return ret; - starget_printk(KERN_INFO, scsi_target(cmd->device), + starget_printk(KERN_INFO, starget, "WARM TARGET RESET ISSUED.\n"); DEBUG2(printk(KERN_INFO @@ -9360,14 +9369,13 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) stat = qla4xxx_reset_target(ha, ddb_entry); if (stat != QLA_SUCCESS) { - starget_printk(KERN_INFO, scsi_target(cmd->device), + starget_printk(KERN_INFO, starget, "WARM TARGET RESET FAILED.\n"); return FAILED; } - if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device), - NULL)) { - starget_printk(KERN_INFO, scsi_target(cmd->device), + if (qla4xxx_eh_wait_for_commands(ha, starget, NULL)) { + starget_printk(KERN_INFO, starget, "WARM TARGET DEVICE RESET FAILED - " "waiting for commands.\n"); return FAILED; @@ -9376,13 +9384,13 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) /* Send marker. */ if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun, MM_TGT_WARM_RESET) != QLA_SUCCESS) { - starget_printk(KERN_INFO, scsi_target(cmd->device), + starget_printk(KERN_INFO, starget, "WARM TARGET DEVICE RESET FAILED - " "marker iocb failed.\n"); return FAILED; } - starget_printk(KERN_INFO, scsi_target(cmd->device), + starget_printk(KERN_INFO, starget, "WARM TARGET RESET SUCCEEDED.\n"); return SUCCESS; } diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2c0dd64159b0..bdc9ef29fe9c 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1821,17 +1821,15 @@ static void iscsi_scan_session(struct work_struct *work) /** * iscsi_block_scsi_eh - block scsi eh until session state has transistioned - * @cmd: scsi cmd passed to scsi eh handler + * @session: iscsi session derived from scsi eh handler argument * * If the session is down this function will wait for the recovery * timer to fire or for the session to be logged back in. If the * recovery timer fires then FAST_IO_FAIL is returned. The caller * should pass this error value to the scsi eh. */ -int iscsi_block_scsi_eh(struct scsi_cmnd *cmd) +int iscsi_block_scsi_eh(struct iscsi_cls_session *session) { - struct iscsi_cls_session *session = - starget_to_session(scsi_target(cmd->device)); unsigned long flags; int ret = 0; diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 9acb8422f680..5771275f8bf3 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -456,7 +456,7 @@ extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size); extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep); extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle); extern void iscsi_put_endpoint(struct iscsi_endpoint *ep); -extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd); +extern int iscsi_block_scsi_eh(struct iscsi_cls_session *session); extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *t, uint32_t iface_type, From patchwork Mon May 2 21:54:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EABFBC433FE for ; Mon, 2 May 2022 21:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387805AbiEBV6y (ORCPT ); Mon, 2 May 2022 17:58:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387758AbiEBV5w (ORCPT ); Mon, 2 May 2022 17:57:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59627646E for ; Mon, 2 May 2022 14:54:22 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 90F551F74B; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YrVm8k2hvraGXYxcRYNzlvlDUmeoz5pQ/UhJRgs3+10=; b=LNOlFV2EpzN2IFr1rMCu6Q0fzrn7HmbYIRiwMT71pp/UGnnbrfwtZ6JVnJPEZKvlmpRx2n a11vWbgehcUQ68BTw6MvEbsiszlTQl4h+8JWIojnuviR0DwtIj1mOOIz4s79nw2oICKAnj PJ25+NLpLOLw7J5GqQQZQUZbtgpoXH0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YrVm8k2hvraGXYxcRYNzlvlDUmeoz5pQ/UhJRgs3+10=; b=Bni8bsDQI1nrnjZW9Z8QWZJaDa/GI34a9acDrCpJK0si8rTenVHWoDjfcqPFq3iwaBbjFT C9qmx4ijZ7V0f0BA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 8883B2C149; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 842755194130; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 05/11] pmcraid: select first available device for target reset Date: Mon, 2 May 2022 23:54:10 +0200 Message-Id: <20220502215416.5351-6-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org As we're moving away from using a scsi command as argument for eh_XX callbacks we should be selecting the first available device for sending a target reset to. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/pmcraid.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index d508e81a03db..62b9de87ff05 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3064,9 +3064,21 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd) static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) { - scmd_printk(KERN_INFO, scmd, + struct Scsi_Host *shost = scmd->device->host; + struct scsi_device *scsi_dev = NULL, *tmp; + + shost_for_each_device(tmp, shost) { + if ((tmp->channel == scmd->device->channel) && + (tmp->id == scmd->device->id)) { + scsi_dev = tmp; + break; + } + } + if (!scsi_dev) + return FAILED; + sdev_printk(KERN_INFO, scsi_dev, "Doing target reset due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd->device, + return pmcraid_reset_device(scsi_dev, PMCRAID_INTERNAL_TIMEOUT, RESET_DEVICE_TARGET); } From patchwork Mon May 2 21:54:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB8C6C433F5 for ; Mon, 2 May 2022 21:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387796AbiEBV6P (ORCPT ); Mon, 2 May 2022 17:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387805AbiEBV5y (ORCPT ); Mon, 2 May 2022 17:57:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F218DDEE6 for ; Mon, 2 May 2022 14:54:23 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9504D1F74C; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UNLD8Dcg2QZ4NNoC2EZZguFhtqAeT2JdbTnVL+TobZk=; b=iWfauWAZUr42FaQ5zaLGKB8IY/b4eozISGP5wUx8SPe7fZTNEODJ+kuliE9FFaxUuvPvMu cQMgWXiGqiYaMfOyZMCNcd2c8edKFVm9OB5EAWhUeluRbRTPuaqHm+8tb1al4pOC8SNfkY C7rfVvOYJ2deKRbUGsQBmFNsOx+7bwg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UNLD8Dcg2QZ4NNoC2EZZguFhtqAeT2JdbTnVL+TobZk=; b=M+6nC8MKwFyI4/bAvl2lEWtNqcKfqxx0DQULSLiCgraRVJclRw1eEi+vKzgADHQdpSpwsd JFb4P1+ZSi3FZGDQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 8DC4F2C14B; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 8B4765194132; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 06/11] bfa: Do not use scsi command to signal TMF status Date: Mon, 2 May 2022 23:54:11 +0200 Message-Id: <20220502215416.5351-7-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The bfa driver hijacks the scsi command to signal the TMF status, which will no longer work if the TMF handler will be converted. So rework TMF handling to not use a scsi command but rather add new TMF fields to the per-device structure. Signed-off-by: Hannes Reinecke --- drivers/scsi/bfa/bfad_im.c | 112 ++++++++++++++++++++----------------- drivers/scsi/bfa/bfad_im.h | 2 + 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 8419a1a89485..a446aa2d6b9a 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -147,13 +147,13 @@ void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk, enum bfi_tskim_status tsk_status) { - struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk; + struct bfad_itnim_data_s *itnim_data = + (struct bfad_itnim_data_s *)dtsk; wait_queue_head_t *wq; - bfad_priv(cmnd)->status |= tsk_status << 1; - set_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status); - wq = bfad_priv(cmnd)->wq; - bfad_priv(cmnd)->wq = NULL; + itnim_data->tmf_status |= tsk_status << 1; + set_bit(IO_DONE_BIT, &itnim_data->tmf_status); + wq = itnim_data->tmf_wq; if (wq) wake_up(wq); @@ -238,15 +238,16 @@ bfad_im_abort_handler(struct scsi_cmnd *cmnd) } static bfa_status_t -bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd, - struct bfad_itnim_s *itnim) +bfad_im_target_reset_send(struct bfad_s *bfad, + struct bfad_itnim_data_s *itnim_data) { + struct bfad_itnim_s *itnim = itnim_data->itnim; struct bfa_tskim_s *tskim; struct bfa_itnim_s *bfa_itnim; bfa_status_t rc = BFA_STATUS_OK; struct scsi_lun scsilun; - tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd); + tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) itnim_data); if (!tskim) { BFA_LOG(KERN_ERR, bfad, bfa_log_level, "target reset, fail to allocate tskim\n"); @@ -254,12 +255,6 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd, goto out; } - /* - * Set host_scribble to NULL to avoid aborting a task command if - * happens. - */ - cmnd->host_scribble = NULL; - bfad_priv(cmnd)->status = 0; bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); /* * bfa_itnim can be NULL if the port gets disconnected and the bfa @@ -290,10 +285,11 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd, static int bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) { - struct Scsi_Host *shost = cmnd->device->host; + struct scsi_device *sdev = cmnd->device; + struct Scsi_Host *shost = sdev->host; struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; - struct bfad_itnim_data_s *itnim_data = cmnd->device->hostdata; + struct bfad_itnim_data_s *itnim_data = sdev->hostdata; struct bfad_s *bfad = im_port->bfad; struct bfa_tskim_s *tskim; struct bfad_itnim_s *itnim; @@ -305,14 +301,20 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) struct scsi_lun scsilun; spin_lock_irqsave(&bfad->bfad_lock, flags); + if (itnim_data->tmf_wq) { + BFA_LOG(KERN_ERR, bfad, bfa_log_level, + "LUN reset, TMF already active"); + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + rc = FAILED; + goto out; + } itnim = itnim_data->itnim; if (!itnim) { spin_unlock_irqrestore(&bfad->bfad_lock, flags); rc = FAILED; goto out; } - - tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd); + tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) itnim_data); if (!tskim) { BFA_LOG(KERN_ERR, bfad, bfa_log_level, "LUN reset, fail to allocate tskim"); @@ -321,13 +323,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) goto out; } - /* - * Set host_scribble to NULL to avoid aborting a task command - * if happens. - */ - cmnd->host_scribble = NULL; - bfad_priv(cmnd)->wq = &wq; - bfad_priv(cmnd)->status = 0; + itnim_data->tmf_wq = &wq; + itnim_data->tmf_status = 0; bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); /* * bfa_itnim can be NULL if the port gets disconnected and the bfa @@ -342,14 +339,15 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) rc = FAILED; goto out; } - int_to_scsilun(cmnd->device->lun, &scsilun); + int_to_scsilun(sdev->lun, &scsilun); bfa_tskim_start(tskim, bfa_itnim, scsilun, FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO); spin_unlock_irqrestore(&bfad->bfad_lock, flags); - wait_event(wq, test_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status)); + wait_event(wq, test_bit(IO_DONE_BIT, &itnim_data->tmf_status)); - task_status = bfad_priv(cmnd)->status >> 1; + itnim_data->tmf_wq = NULL; + task_status = itnim_data->tmf_status >> 1; if (task_status != BFI_TSKIM_STS_OK) { BFA_LOG(KERN_ERR, bfad, bfa_log_level, "LUN reset failure, status: %d\n", task_status); @@ -368,35 +366,47 @@ bfad_im_reset_target_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; struct scsi_target *starget = scsi_target(cmnd->device); + struct fc_rport *rport = starget_to_rport(starget); struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; - struct bfad_s *bfad = im_port->bfad; - struct bfad_itnim_s *itnim; - unsigned long flags; - u32 rc, rtn = FAILED; + struct bfad_s *bfad = im_port->bfad; + struct bfad_itnim_data_s *itnim_data; + struct bfad_itnim_s *itnim; + unsigned long flags; + u32 rc, rtn = FAILED; DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); enum bfi_tskim_status task_status; spin_lock_irqsave(&bfad->bfad_lock, flags); - itnim = bfad_get_itnim(im_port, starget->id); - if (itnim) { - bfad_priv(cmnd)->wq = &wq; - rc = bfad_im_target_reset_send(bfad, cmnd, itnim); - if (rc == BFA_STATUS_OK) { - /* wait target reset to complete */ - spin_unlock_irqrestore(&bfad->bfad_lock, flags); - wait_event(wq, test_bit(IO_DONE_BIT, - &bfad_priv(cmnd)->status)); - spin_lock_irqsave(&bfad->bfad_lock, flags); - - task_status = bfad_priv(cmnd)->status >> 1; - if (task_status != BFI_TSKIM_STS_OK) - BFA_LOG(KERN_ERR, bfad, bfa_log_level, - "target reset failure," - " status: %d\n", task_status); - else - rtn = SUCCESS; - } + if (!rport->dd_data) { + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + return rtn; + } + itnim_data = rport->dd_data; + if (itnim_data->tmf_wq) { + BFA_LOG(KERN_ERR, bfad, bfa_log_level, + "target reset failed, TMF already active"); + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + return rtn; + } + itnim = itnim_data->itnim; + itnim_data->tmf_wq = &wq; + itnim_data->tmf_status = 0; + rc = bfad_im_target_reset_send(bfad, itnim_data); + if (rc == BFA_STATUS_OK) { + /* wait target reset to complete */ + spin_unlock_irqrestore(&bfad->bfad_lock, flags); + wait_event(wq, test_bit(IO_DONE_BIT, + &itnim_data->tmf_status)); + spin_lock_irqsave(&bfad->bfad_lock, flags); + + task_status = itnim_data->tmf_status >> 1; + if (task_status != BFI_TSKIM_STS_OK) + BFA_LOG(KERN_ERR, bfad, bfa_log_level, + "target reset failure," + " status: %d\n", task_status); + else + rtn = SUCCESS; } spin_unlock_irqrestore(&bfad->bfad_lock, flags); diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h index c03b225ea1ba..c9ead4217a7d 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -61,6 +61,8 @@ static inline struct bfad_cmd_priv *bfad_priv(struct scsi_cmnd *cmd) struct bfad_itnim_data_s { struct bfad_itnim_s *itnim; + wait_queue_head_t *tmf_wq; + unsigned long tmf_status; }; struct bfad_im_port_s { From patchwork Mon May 2 21:54:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B13FC433F5 for ; Mon, 2 May 2022 21:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348244AbiEBV6u (ORCPT ); Mon, 2 May 2022 17:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387742AbiEBV5w (ORCPT ); Mon, 2 May 2022 17:57:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 593E3646D for ; Mon, 2 May 2022 14:54:22 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 96B891F74D; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qg8pe/ZT6UuzTw+xkQ7k5SEqWlac313RiBRByvf/Hwk=; b=l4t2N5WGuy+htVJHxTPUg46b31tcKeKEmu9RRK5iJcW+R9jTK0WzTNpBlM/RxeF1yY+HqK jJPR0jYYfKvquf4cp9jZIwrdk17V/zUlH5o3BzIftEgiM0p8SC/GwIOqLI3JdSqKSwWwjL 4nO3J/4xjo2ZlI3wha8tflph6+xKcIo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qg8pe/ZT6UuzTw+xkQ7k5SEqWlac313RiBRByvf/Hwk=; b=4P/C5p8hfYEevzd1BDzTOXXqQ5WZwwLbLkxKliXCQXCtXzN/vKlGOVl/fEdd/OmoYrVOMe XrUSW0P087zYCFDg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 925052C14E; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 909A55194134; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 07/11] aha152x: look for stuck command when resetting device Date: Mon, 2 May 2022 23:54:12 +0200 Message-Id: <20220502215416.5351-8-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke The LLDD needs a command to send the reset with, so look at the list of outstanding commands to get one. Signed-off-by: Hannes Reinecke --- drivers/scsi/aha152x.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index caeebfb67149..7e58f25c599b 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1070,24 +1070,28 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt) */ static int aha152x_device_reset(struct scsi_cmnd * SCpnt) { - struct Scsi_Host *shpnt = SCpnt->device->host; + struct scsi_device *sdev = SCpnt->device; + struct Scsi_Host *shpnt = sdev->host; DECLARE_COMPLETION(done); int ret, issued, disconnected; - unsigned char old_cmd_len = SCpnt->cmd_len; + unsigned char old_cmd_len; unsigned long flags; unsigned long timeleft; - if(CURRENT_SC==SCpnt) { - scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n"); - return FAILED; - } - DO_LOCK(flags); - issued = remove_SC(&ISSUE_SC, SCpnt) == NULL; - disconnected = issued && remove_SC(&DISCONNECTED_SC, SCpnt); + /* Look for the stuck command */ + SCpnt = remove_lun_SC(&ISSUE_SC, sdev->id, sdev->lun); + if (SCpnt) + issued = 1; + else + SCpnt = remove_lun_SC(&DISCONNECTED_SC, sdev->id, sdev->lun); + if (!issued && SCpnt) + disconnected = 1; DO_UNLOCK(flags); - - SCpnt->cmd_len = 0; + if (!SCpnt) + return FAILED; + old_cmd_len = SCpnt->cmd_len; + SCpnt->cmd_len = 0; aha152x_internal_queue(SCpnt, &done, resetting); From patchwork Mon May 2 21:54:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9BD3C433EF for ; Mon, 2 May 2022 21:54:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387757AbiEBV6T (ORCPT ); Mon, 2 May 2022 17:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387654AbiEBV5y (ORCPT ); Mon, 2 May 2022 17:57:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D67DEEA for ; Mon, 2 May 2022 14:54:23 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9F9311F750; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aj2EtAL2IJennjLUXkv4ywvVNru5/pzTbiWRfsuK4LI=; b=nk1ks6KCxwvaagB49BWrKUq4Tnp0rUlO+ah50IFS+QyhEx8aBdVk1u8wnyBKpvi8tEXjqH /JSfyurFeDL+5LB0yv5a7zA1TJ5DbeHH1qQ/nkKKhKfPq+s3XH/VuKhNVMoA3QT0iV5cSW YE9BdTjpZ9wWRg/nJE5A021QFuy0Yf4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aj2EtAL2IJennjLUXkv4ywvVNru5/pzTbiWRfsuK4LI=; b=q+N0xACIl4PAcUFq+WXZgqi3bKZiNMZHGdmKaTgI95MSBxT6/8LTLLLMQijzo6ofKQy2kJ PFtYEhFxJbC/oGCg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 9950B2C14F; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 964895194136; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 08/11] a1000u2w: do not rely on the command for inia100_device_reset() Date: Mon, 2 May 2022 23:54:13 +0200 Message-Id: <20220502215416.5351-9-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use the scsi device as argument to orc_device_reset() instead of relying on the passed in scsi command. Signed-off-by: Hannes Reinecke --- drivers/scsi/a100u2w.c | 43 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index d02eb5b213d0..bf552c818958 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c @@ -592,39 +592,20 @@ static int orc_reset_scsi_bus(struct orc_host * host) * commands for target w/o soft reset */ -static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsigned int target) +static int orc_device_reset(struct orc_host * host, struct scsi_device *sdev) { /* I need Host Control Block Information */ struct orc_scb *scb; struct orc_extended_scb *escb; - struct orc_scb *host_scb; - u8 i; unsigned long flags; spin_lock_irqsave(&(host->allocation_lock), flags); scb = (struct orc_scb *) NULL; escb = (struct orc_extended_scb *) NULL; - /* setup scatter list address with one buffer */ - host_scb = host->scb_virt; - /* FIXME: is this safe if we then fail to issue the reset or race a completion ? */ init_alloc_map(host); - /* Find the scb corresponding to the command */ - for (i = 0; i < ORC_MAXQUEUE; i++) { - escb = host_scb->escb; - if (host_scb->status && escb->srb == cmd) - break; - host_scb++; - } - - if (i == ORC_MAXQUEUE) { - printk(KERN_ERR "Unable to Reset - No SCB Found\n"); - spin_unlock_irqrestore(&(host->allocation_lock), flags); - return FAILED; - } - /* Allocate a new SCB for the reset command to the firmware */ if ((scb = __orc_alloc_scb(host)) == NULL) { /* Can't happen.. */ @@ -635,7 +616,7 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig /* Reset device is handled by the firmware, we fill in an SCB and fire it at the controller, it does the rest */ scb->opcode = ORC_BUSDEVRST; - scb->target = target; + scb->target = sdev->id; scb->hastat = 0; scb->tastat = 0; scb->status = 0x0; @@ -645,8 +626,8 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig scb->xferlen = cpu_to_le32(0); scb->sg_len = cpu_to_le32(0); + escb = scb->escb; escb->srb = NULL; - escb->srb = cmd; orc_exec_scb(host, scb); /* Start execute SCB */ spin_unlock_irqrestore(&host->allocation_lock, flags); return SUCCESS; @@ -971,7 +952,7 @@ static int inia100_device_reset(struct scsi_cmnd * cmd) { /* I need Host Control Block Information */ struct orc_host *host; host = (struct orc_host *) cmd->device->host->hostdata; - return orc_device_reset(host, cmd, scmd_id(cmd)); + return orc_device_reset(host, cmd->device); } @@ -991,11 +972,7 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb) struct orc_extended_scb *escb; escb = scb->escb; - if ((cmd = (struct scsi_cmnd *) escb->srb) == NULL) { - printk(KERN_ERR "inia100_scb_handler: SRB pointer is empty\n"); - orc_release_scb(host, scb); /* Release SCB for current channel */ - return; - } + cmd = (struct scsi_cmnd *)escb->srb; escb->srb = NULL; switch (scb->hastat) { @@ -1033,13 +1010,15 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb) break; } - if (scb->tastat == 2) { /* Check condition */ + if (cmd && scb->tastat == 2) { /* Check condition */ memcpy((unsigned char *) &cmd->sense_buffer[0], (unsigned char *) &escb->sglist[0], SENSE_SIZE); } - cmd->result = scb->tastat | (scb->hastat << 16); - scsi_dma_unmap(cmd); - scsi_done(cmd); /* Notify system DONE */ + if (cmd) { + cmd->result = scb->tastat | (scb->hastat << 16); + scsi_dma_unmap(cmd); + scsi_done(cmd); /* Notify system DONE */ + } orc_release_scb(host, scb); /* Release SCB for current channel */ } From patchwork Mon May 2 21:54:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95212C433F5 for ; Mon, 2 May 2022 21:54:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343556AbiEBV6D (ORCPT ); Mon, 2 May 2022 17:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387806AbiEBV5y (ORCPT ); Mon, 2 May 2022 17:57:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CFC8FD23 for ; Mon, 2 May 2022 14:54:24 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A2BB91F896; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ry5H6cMidPWYUAqkFmsNUYphLy8pO7JStnwRsjeJSZ0=; b=1wAa3xXqqEe7K4AFNY4p/wLtIOuGIiQPpp/OMRbafIYqgnFfrGokpRmq78rvVnsSGnRMS7 sIxLLEdX4WlCulTaShe+kFvHkccWh1Tws80zp/bJJqU8U2QO3IEaMD3tT4f979AHLIBe2W 0hlxOVpiKrap++GSnsoNV6usi1G9BMY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ry5H6cMidPWYUAqkFmsNUYphLy8pO7JStnwRsjeJSZ0=; b=ByAKZiXXjtp3LC4RPRNzarv+44AwoVXEO0EY1+gPYQ2w0Zlmip/zaMxx/NOdiQdKfwPXzw SYOvSvmsAb7H7IDg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 9D6B92C14E; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 9B67D5194138; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request() Date: Mon, 2 May 2022 23:54:14 +0200 Message-Id: <20220502215416.5351-10-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add scsi device as argument to scsifront_do_request() so that it will be possible to call it with a NULL command pointer. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/xen-scsifront.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 12109e4c73d4..9de099532f8b 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -175,7 +175,8 @@ static void scsifront_put_rqid(struct vscsifrnt_info *info, uint32_t id) scsifront_wake_up(info); } -static int scsifront_do_request(struct vscsifrnt_info *info, +static int scsifront_do_request(struct scsi_device *sdev, + struct vscsifrnt_info *info, struct vscsifrnt_shadow *shadow) { struct vscsiif_front_ring *ring = &(info->ring); @@ -202,17 +203,25 @@ static int scsifront_do_request(struct vscsifrnt_info *info, ring_req->ref_rqid = shadow->ref_rqid; ring_req->nr_segments = shadow->nr_segments; - ring_req->id = sc->device->id; - ring_req->lun = sc->device->lun; - ring_req->channel = sc->device->channel; - ring_req->cmd_len = sc->cmd_len; + ring_req->id = sdev->id; + ring_req->lun = sdev->lun; + ring_req->channel = sdev->channel; - BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE); + if (sc) { + ring_req->cmd_len = sc->cmd_len; - memcpy(ring_req->cmnd, sc->cmnd, sc->cmd_len); + BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE); - ring_req->sc_data_direction = (uint8_t)sc->sc_data_direction; - ring_req->timeout_per_command = scsi_cmd_to_rq(sc)->timeout / HZ; + memcpy(ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t)sc->sc_data_direction; + ring_req->timeout_per_command = + scsi_cmd_to_rq(sc)->timeout / HZ; + } else { + ring_req->cmd_len = VSCSIIF_MAX_COMMAND_SIZE; + memset(ring_req->cmnd, 0, VSCSIIF_MAX_COMMAND_SIZE); + ring_req->sc_data_direction = DMA_NONE; + } for (i = 0; i < (shadow->nr_segments & ~VSCSIIF_SG_GRANT); i++) ring_req->seg[i] = shadow->seg[i]; @@ -561,7 +570,7 @@ static int scsifront_queuecommand(struct Scsi_Host *shost, return 0; } - if (scsifront_do_request(info, shadow)) { + if (scsifront_do_request(sc->device, info, shadow)) { scsifront_gnttab_done(info, shadow); goto busy; } @@ -606,7 +615,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) if (scsifront_enter(info)) goto fail; - if (!scsifront_do_request(info, shadow)) + if (!scsifront_do_request(sc->device, info, shadow)) break; scsifront_return(info); From patchwork Mon May 2 21:54:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD084C433EF for ; Mon, 2 May 2022 21:54:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387778AbiEBV6M (ORCPT ); Mon, 2 May 2022 17:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387807AbiEBV5y (ORCPT ); Mon, 2 May 2022 17:57:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD8AFD1E for ; Mon, 2 May 2022 14:54:24 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B31011F898; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p2d8LJL3Vp30/OmWmdxHDLXE94qU4q5I/myWf8eq0bM=; b=ABULQIuFctWdQXSQTZ3ug3gYSlaMxgTaEdZ/FLNBHxH/uX3rZ4+5+zaFKUCTD6p5ht5Dbf UR6QNcw+rhPbBRxks4iw4UnqbnXkUj2WevDFveZJhnxcH8Lbe4YjM/QXh0Urdyd0DfuW4z AdFhY1bsvLXsQh/jswWZPmJmeHZistY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p2d8LJL3Vp30/OmWmdxHDLXE94qU4q5I/myWf8eq0bM=; b=zQ8mJYB6FIbyFH/12zNhykiMGFpfaKa7WSFyeStxLBCEmokCqvJKwhEgJwFV6T4Ihuy78J 1RHmv7Q0+5ZrflBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id A8CE92C152; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A1A7E519413A; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer Date: Mon, 2 May 2022 23:54:15 +0200 Message-Id: <20220502215416.5351-11-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The device reset code should not rely on the SCSI command pointer; it will be going away with the device reset handler rework. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/arm/fas216.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 4ce0b2d73614..e6289c6af5ef 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -1985,7 +1985,6 @@ static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, { fas216_log(info, LOG_ERROR, "fas216 device reset complete"); - info->rstSCpnt = NULL; info->rst_dev_status = 1; wake_up(&info->eh_wait); } @@ -2143,12 +2142,12 @@ static void fas216_done(FAS216_Info *info, unsigned int result) fas216_checkmagic(info); - if (!info->SCpnt) + if (!info->SCpnt && info->rst_dev_status) goto no_command; SCpnt = info->SCpnt; info->SCpnt = NULL; - info->scsi.phase = PHASE_IDLE; + info->scsi.phase = PHASE_IDLE; if (info->scsi.aborting) { fas216_log(info, 0, "uncaught abort - returning DID_ABORT"); @@ -2160,7 +2159,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result) * Sanity check the completion - if we have zero bytes left * to transfer, we should not have a valid pointer. */ - if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) { + if (SCpnt && info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) { scmd_printk(KERN_INFO, SCpnt, "zero bytes left to transfer, but buffer pointer still valid: ptr=%p len=%08x\n", info->scsi.SCp.ptr, info->scsi.SCp.this_residual); @@ -2173,12 +2172,18 @@ static void fas216_done(FAS216_Info *info, unsigned int result) * the sense information, fas216_kick will re-assert the busy * status. */ - info->device[SCpnt->device->id].parity_check = 0; - clear_bit(SCpnt->device->id * 8 + - (u8)(SCpnt->device->lun & 0x7), info->busyluns); - - fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble; - fn(info, SCpnt, result); + if (SCpnt) { + info->device[SCpnt->device->id].parity_check = 0; + clear_bit(SCpnt->device->id * 8 + + (u8)(SCpnt->device->lun & 0x7), info->busyluns); + } + if (!info->rst_dev_status) { + info->rst_dev_status = 1; + wake_up(&info->eh_wait); + } else { + fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble; + fn(info, SCpnt, result); + } if (info->scsi.irq) { spin_lock_irqsave(&info->host_lock, flags); @@ -2478,9 +2483,10 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt) */ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) { - FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; + struct scsi_device *sdev = SCpnt->device; + FAS216_Info *info = (FAS216_Info *)sdev->host->hostdata; unsigned long flags; - int i, res = FAILED, target = SCpnt->device->id; + int i, res = FAILED, target = sdev->id; fas216_log(info, LOG_ERROR, "device reset for target %d", target); @@ -2494,7 +2500,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) * and we need a bus reset. */ if (info->SCpnt && !info->scsi.disconnectable && - info->SCpnt->device->id == SCpnt->device->id) + info->SCpnt->device->id == sdev->id) break; /* @@ -2512,14 +2518,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) for (i = 0; i < 8; i++) clear_bit(target * 8 + i, info->busyluns); - /* - * Hijack this SCSI command structure to send - * a bus device reset message to this device. - */ - SCpnt->host_scribble = (void *)fas216_devicereset_done; - info->rst_dev_status = 0; - info->rstSCpnt = SCpnt; if (info->scsi.phase == PHASE_IDLE) fas216_kick(info); From patchwork Mon May 2 21:54:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10534C433F5 for ; Mon, 2 May 2022 21:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241907AbiEBV6G (ORCPT ); Mon, 2 May 2022 17:58:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387808AbiEBV5z (ORCPT ); Mon, 2 May 2022 17:57:55 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86C06FD24 for ; Mon, 2 May 2022 14:54:24 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B3A1F1F899; Mon, 2 May 2022 21:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fU2eeqadf72NQOyzHys2QmG3XVR0slnd0zlUuAkSDiI=; b=hMXkPKs5rgn+K7fEYBtSvaTYcKWn1+UwT6t8xA+M8KU/ZJo+C4kz20g5DOG/4IvbIvaR0A R/woE772zFGFIewRJGIjtpK0x17QsJIGQmDmlvu0IWbLyym5wOAeG8zJuLyLKsHTw2Gv05 jTAS7D3UzFRjUrDUMrLvJRh+qXk2618= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fU2eeqadf72NQOyzHys2QmG3XVR0slnd0zlUuAkSDiI=; b=SkS/FyuhcdVN3CT9DMfvVFmavm5WXRhS+H/hX1V3Zu7GLwnGONPTixpkx9tnn6PUpGSry9 qLSCsGYrtGLEdoDw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id AC0EF2C153; Mon, 2 May 2022 21:54:20 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A78AE519413C; Mon, 2 May 2022 23:54:20 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 11/11] csiostor: use separate TMF command Date: Mon, 2 May 2022 23:54:16 +0200 Message-Id: <20220502215416.5351-12-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215416.5351-1-hare@suse.de> References: <20220502215416.5351-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set one command aside as a TMF command, and use this command to send the TMF. This avoids having to rely on the passed-in scsi command when resetting the device. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/csiostor/csio_hw.h | 2 ++ drivers/scsi/csiostor/csio_init.c | 2 +- drivers/scsi/csiostor/csio_scsi.c | 48 +++++++++++++++++++------------ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/csiostor/csio_hw.h b/drivers/scsi/csiostor/csio_hw.h index e351af6e7c81..8e22dccd6d88 100644 --- a/drivers/scsi/csiostor/csio_hw.h +++ b/drivers/scsi/csiostor/csio_hw.h @@ -68,6 +68,8 @@ #define CSIO_MAX_LUN 0xFFFF #define CSIO_MAX_QUEUE 2048 +#define CSIO_TMF_TAG (CSIO_MAX_QUEUE - 1) + #define CSIO_MAX_CMD_PER_LUN 32 #define CSIO_MAX_DDP_BUF_SIZE (1024 * 1024) #define CSIO_MAX_SECTOR_SIZE 128 diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c index ccbded3353bd..6a5529d6440f 100644 --- a/drivers/scsi/csiostor/csio_init.c +++ b/drivers/scsi/csiostor/csio_init.c @@ -621,7 +621,7 @@ csio_shost_init(struct csio_hw *hw, struct device *dev, /* Link common lnode to this lnode */ ln->dev_num = (shost->host_no << 16); - shost->can_queue = CSIO_MAX_QUEUE; + shost->can_queue = CSIO_MAX_QUEUE - 1; shost->this_id = -1; shost->unique_id = shost->host_no; shost->max_cmd_len = 16; /* Max CDB length supported */ diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index c1c410a1cfe0..b21aa2c43051 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -2056,17 +2056,20 @@ csio_tm_cbfn(struct csio_hw *hw, struct csio_ioreq *req) /* Wake up the TM handler thread */ csio_scsi_cmnd(req) = NULL; + cmnd->host_scribble = NULL; } static int csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) { - struct csio_lnode *ln = shost_priv(cmnd->device->host); + struct scsi_device *sdev = cmnd->device; + struct csio_lnode *ln = shost_priv(sdev->host); struct csio_hw *hw = csio_lnode_to_hw(ln); struct csio_scsim *scsim = csio_hw_to_scsim(hw); - struct csio_rnode *rn = (struct csio_rnode *)(cmnd->device->hostdata); + struct csio_rnode *rn = (struct csio_rnode *)(sdev->hostdata); struct csio_ioreq *ioreq = NULL; struct csio_scsi_qset *sqset; + struct scsi_cmnd *tmf_cmnd; unsigned long flags; int retval; int count, ret; @@ -2077,13 +2080,13 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) goto fail; csio_dbg(hw, "Request to reset LUN:%llu (ssni:0x%x tgtid:%d)\n", - cmnd->device->lun, rn->flowid, rn->scsi_id); + sdev->lun, rn->flowid, rn->scsi_id); if (!csio_is_lnode_ready(ln)) { csio_err(hw, "LUN reset cannot be issued on non-ready" " local node vnpi:0x%x (LUN:%llu)\n", - ln->vnp_flowid, cmnd->device->lun); + ln->vnp_flowid, sdev->lun); goto fail; } @@ -2103,7 +2106,15 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) csio_err(hw, "LUN reset cannot be issued on non-ready" " remote node ssni:0x%x (LUN:%llu)\n", - rn->flowid, cmnd->device->lun); + rn->flowid, sdev->lun); + goto fail; + } + + tmf_cmnd = scsi_host_find_tag(sdev->host, CSIO_TMF_TAG); + if (!tmf_cmnd || tmf_cmnd->host_scribble) { + csio_err(hw, + "LUN reset TMF already busy (LUN:%llu)\n", + sdev->lun); goto fail; } @@ -2123,11 +2134,11 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) ioreq->iq_idx = sqset->iq_idx; ioreq->eq_idx = sqset->eq_idx; - csio_scsi_cmnd(ioreq) = cmnd; - cmnd->host_scribble = (unsigned char *)ioreq; - csio_priv(cmnd)->wr_status = 0; + csio_scsi_cmnd(ioreq) = tmf_cmnd; + tmf_cmnd->host_scribble = (unsigned char *)ioreq; + csio_priv(tmf_cmnd)->wr_status = 0; - csio_priv(cmnd)->fc_tm_flags = FCP_TMF_LUN_RESET; + csio_priv(tmf_cmnd)->fc_tm_flags = FCP_TMF_LUN_RESET; ioreq->tmo = CSIO_SCSI_LUNRST_TMO_MS / 1000; /* @@ -2144,7 +2155,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) sld.level = CSIO_LEV_LUN; sld.lnode = ioreq->lnode; sld.rnode = ioreq->rnode; - sld.oslun = cmnd->device->lun; + sld.oslun = sdev->lun; spin_lock_irqsave(&hw->lock, flags); /* Kick off TM SM on the ioreq */ @@ -2154,20 +2165,21 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) if (retval != 0) { csio_err(hw, "Failed to issue LUN reset, req:%p, status:%d\n", ioreq, retval); + tmf_cmnd->host_scribble = NULL; goto fail_ret_ioreq; } csio_dbg(hw, "Waiting max %d secs for LUN reset completion\n", count * (CSIO_SCSI_TM_POLL_MS / 1000)); /* Wait for completion */ - while ((((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == cmnd) + while ((((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == tmf_cmnd) && count--) msleep(CSIO_SCSI_TM_POLL_MS); /* LUN reset timed-out */ - if (((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == cmnd) { + if (((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == tmf_cmnd) { csio_err(hw, "LUN reset (%d:%llu) timed out\n", - cmnd->device->id, cmnd->device->lun); + sdev->id, sdev->lun); spin_lock_irq(&hw->lock); csio_scsi_drvcleanup(ioreq); @@ -2178,10 +2190,10 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) } /* LUN reset returned, check cached status */ - if (csio_priv(cmnd)->wr_status != FW_SUCCESS) { + if (csio_priv(tmf_cmnd)->wr_status != FW_SUCCESS) { csio_err(hw, "LUN reset failed (%d:%llu), status: %d\n", - cmnd->device->id, cmnd->device->lun, - csio_priv(cmnd)->wr_status); + sdev->id, sdev->lun, + csio_priv(tmf_cmnd)->wr_status); goto fail; } @@ -2201,7 +2213,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) if (retval != 0) { csio_err(hw, "Attempt to abort I/Os during LUN reset of %llu" - " returned %d\n", cmnd->device->lun, retval); + " returned %d\n", sdev->lun, retval); /* Return I/Os back to active_q */ spin_lock_irq(&hw->lock); list_splice_tail_init(&local_q, &scsim->active_q); @@ -2212,7 +2224,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) CSIO_INC_STATS(rn, n_lun_rst); csio_info(hw, "LUN reset occurred (%d:%llu)\n", - cmnd->device->id, cmnd->device->lun); + sdev->id, sdev->lun); return SUCCESS;