From patchwork Mon May 2 21:59:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834818 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 5A890C433F5 for ; Mon, 2 May 2022 22:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387803AbiEBWD4 (ORCPT ); Mon, 2 May 2022 18:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387777AbiEBWDc (ORCPT ); Mon, 2 May 2022 18:03:32 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6FEC113C for ; Mon, 2 May 2022 15:00:01 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 93C271F747; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=K9qfI732aSrfbVh3JIVGFGI01ePT7A46GS0dbx8lu0yBS7gxuEGf/uPZ6/Sysqcey0r2Sr FiPHOdSkmFQnP52O7U185h9zTUFQERzAB8M/F6iPzvF/87uy5LyBs1YVdp8j3N4NUhh+4X yZPEzQ58QVkuLh4mHCyUIBOLFyw9Pjg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=D/O9k3gocanY3EZIDBTCl0a8GcIyQoINjFDRqy3yZnvAAn0PhAy41VSTGhjXme9oGiK2zi q2rW06oh/P4EjJDw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 8CC3C2C143; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 7CEDF5194140; Tue, 3 May 2022 00:00:00 +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:59:36 +0200 Message-Id: <20220502215953.5463-2-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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 --- 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:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834819 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 ED951C433EF for ; Mon, 2 May 2022 22:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387805AbiEBWEl (ORCPT ); Mon, 2 May 2022 18:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387776AbiEBWDc (ORCPT ); Mon, 2 May 2022 18:03:32 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0938F261E for ; Mon, 2 May 2022 15:00:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9D97A1F74A; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=EYyHJ2M05LTHg4Wcj6tAZbsWbJFVfJigtFnD9Px15BNsWcHMuM6fEq6NwFwBp79UMNpHtK GXP9+v9Rhte8/XvfU7um15FaQuHbJkVSOhod+L2gcETnGGDxYRlA108uJs55qYA7o4WYSl ya/XAeo7DrHnFWxEb6pOcGKhNTmb0I8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=/f605gozQl19juDVg8aV8rBRPfJdC5ZwcxhqoVJ29Q1uADgaBm36wyU4k9n+6A4bWcGfcL sq/MCoYF+qEyfcBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 9544F2C149; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 9185F5194148; Tue, 3 May 2022 00:00:00 +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:59:39 +0200 Message-Id: <20220502215953.5463-5-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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 --- 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:59:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834820 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 EEAC6C433FE for ; Mon, 2 May 2022 22:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387808AbiEBWEo (ORCPT ); Mon, 2 May 2022 18:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383542AbiEBWDd (ORCPT ); Mon, 2 May 2022 18:03:33 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546E460E2 for ; Mon, 2 May 2022 15:00:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A0D2D1F74B; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=n6G+739ijUQiKfeHiRI4CrTCM6pNjhIeUX7pdqUzWO3yBivSD3mAJ5Liw193ue0jeGc4x1 K9qi86E/HYtrB3CQkjRkoH0duZcxy54/TiSVElrhn5KvYSFPmF6M6ONXn+OArKM+LaBiyp ewblrIVOTmiOxktZ8+Tj/fGqd650Ifk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=SFqmlUi263zkr5KTQX6Yx5t9q/KKMICDvASkdH0DtYrABbzx+k/BSesAIvLohRajbgL2rz fC/l0IhtnBpSjaDw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 9A7142C14B; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 970F2519414A; Tue, 3 May 2022 00:00:00 +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:59:40 +0200 Message-Id: <20220502215953.5463-6-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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: Mike Christie --- 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:59:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834821 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 3E0F1C433EF for ; Mon, 2 May 2022 22:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385896AbiEBWEq (ORCPT ); Mon, 2 May 2022 18:04:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387706AbiEBWDe (ORCPT ); Mon, 2 May 2022 18:03:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E89262D2 for ; Mon, 2 May 2022 15:00:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B0BF5210EF; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=FcYaJLLju6WMxi5oH0ETjiVdpJPcHLmBhno5X9/NaEMJOElE3PCLyeT0RkdqJeRwGsYK4k 7Cli+5nDbzBU1f9PiyWSdihRwmI5rDbhW3/f08iGMH9BktiPPvwVQnIYH7TSnbtf9Cqo4a 8ZJTMzi4IDVNJaqbATy+LPx9cmXy7Aw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=qcBLq1nQoK89hutYlo86zJkNHILmL+v7vOWpXLKyUrYawuUoIdv+zzT8Cmr/nHcccWfdhn 61kcwC62LwdH9iBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id A817A2C14F; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A4DAE519414E; Tue, 3 May 2022 00:00:00 +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:59:42 +0200 Message-Id: <20220502215953.5463-8-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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: Mike Christie --- 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:59:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834822 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 75D72C433FE for ; Mon, 2 May 2022 22:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236282AbiEBWEu (ORCPT ); Mon, 2 May 2022 18:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387787AbiEBWDe (ORCPT ); Mon, 2 May 2022 18:03:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B27E63E2 for ; Mon, 2 May 2022 15:00:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C3B8821871; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=oaYkaHQDZ8j7a2GaEIivTlEZ1S9GHfFygXTag9RBGJQ=; b=x4Wu0TMFwsuBXO8ojIhj2bNRqHywgXCOOtqfrhsccpWbBFCsVQ68lSfoBcFvPGFa30U/yf FHBmAicuwFYy5GTYVhManvQIVW9g4ND/7P6MLZB4r+K4GQLYfopWdOP4YRS7eZx6Gb24IO e3VoJ2Z/5cJ7CEAXHYQd1wfGSpJtwyI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=oaYkaHQDZ8j7a2GaEIivTlEZ1S9GHfFygXTag9RBGJQ=; b=EASz5C3iJTL8hsxn9lJ3zcSTgbsW/0xlthTXk2nXx7nfjDhksqUpawMW/b4FlniYlP2GlO Gkb0Br8E/sUvMQBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id BD7392C15A; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id BB2E15194154; Tue, 3 May 2022 00:00:00 +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 5/7] scsi: Do not allocate scsi command in scsi_ioctl_reset() Date: Mon, 2 May 2022 23:59:45 +0200 Message-Id: <20220502215953.5463-11-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org As we now have moved the error handler functions to not rely on a scsi command we can drop the out-of-band scsi command allocation from scsi_ioctl_reset(). Signed-off-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 119 +++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 65 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 93f7006982d8..ad68149ab8a1 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -824,16 +824,22 @@ void scsi_eh_done(struct scsi_cmnd *scmd) complete(eh_action); } +static void __scsi_report_device_reset(struct scsi_device *sdev) +{ + sdev->was_reset = 1; + sdev->expecting_cc_ua = 1; +} + /** * scsi_try_host_reset - ask host adapter to reset itself - * @scmd: SCSI cmd to send host reset. + * @host: SCSI host to be reset. */ -static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) +static enum scsi_disposition scsi_try_host_reset(struct Scsi_Host *host) { unsigned long flags; enum scsi_disposition rtn; - struct Scsi_Host *host = scmd->device->host; struct scsi_host_template *hostt = host->hostt; + struct scsi_device *sdev; SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, host, "Snd Host RST\n")); @@ -847,7 +853,8 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) if (!hostt->skip_settle_delay) ssleep(HOST_RESET_SETTLE_TIME); spin_lock_irqsave(host->host_lock, flags); - scsi_report_bus_reset(host, scmd_channel(scmd)); + __shost_for_each_device(sdev, host) + __scsi_report_device_reset(sdev); spin_unlock_irqrestore(host->host_lock, flags); } @@ -856,43 +863,39 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) /** * scsi_try_bus_reset - ask host to perform a bus reset - * @scmd: SCSI cmd to send bus reset. + * @host: SCSI host to send bus reset. + * @channel: Number of the bus to be reset */ -static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd) +static enum scsi_disposition scsi_try_bus_reset(struct Scsi_Host *host, + int channel) { unsigned long flags; enum scsi_disposition rtn; - struct Scsi_Host *host = scmd->device->host; struct scsi_host_template *hostt = host->hostt; - SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, - "%s: Snd Bus RST\n", __func__)); + SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, host, + "%s: Snd Bus RST to bus %d\n", __func__, channel)); if (!hostt->eh_bus_reset_handler) return FAILED; - rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd)); + rtn = hostt->eh_bus_reset_handler(host, channel); if (rtn == SUCCESS) { if (!hostt->skip_settle_delay) ssleep(BUS_RESET_SETTLE_TIME); spin_lock_irqsave(host->host_lock, flags); - scsi_report_bus_reset(host, scmd_channel(scmd)); + scsi_report_bus_reset(host, channel); spin_unlock_irqrestore(host->host_lock, flags); } return rtn; } -static void __scsi_report_device_reset(struct scsi_device *sdev, void *data) -{ - sdev->was_reset = 1; - sdev->expecting_cc_ua = 1; -} - /** * scsi_try_target_reset - Ask host to perform a target reset - * @scmd: SCSI cmd used to send a target reset + * @host: SCSI Host + * @starget: SCSI target to be reset * * Notes: * There is no timeout for this operation. if this operation is @@ -900,13 +903,13 @@ static void __scsi_report_device_reset(struct scsi_device *sdev, void *data) * timer on it, and set the host back to a consistent state prior to * returning. */ -static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) +static enum scsi_disposition scsi_try_target_reset(struct Scsi_Host *host, + struct scsi_target *starget) { unsigned long flags; enum scsi_disposition rtn; - struct Scsi_Host *host = scmd->device->host; + struct scsi_device *sdev; struct scsi_host_template *hostt = host->hostt; - struct scsi_target *starget = scsi_target(scmd->device); if (!hostt->eh_target_reset_handler) return FAILED; @@ -914,8 +917,11 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) rtn = hostt->eh_target_reset_handler(starget); if (rtn == SUCCESS) { spin_lock_irqsave(host->host_lock, flags); - __starget_for_each_device(starget, NULL, - __scsi_report_device_reset); + __shost_for_each_device(sdev, host) { + if ((sdev->channel == starget->channel) && + (sdev->id == starget->id)) + __scsi_report_device_reset(sdev); + } spin_unlock_irqrestore(host->host_lock, flags); } @@ -924,7 +930,7 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) /** * scsi_try_bus_device_reset - Ask host to perform a BDR on a dev - * @scmd: SCSI cmd used to send BDR + * @sdev: SCSI device to perform the BDR on * * Notes: * There is no timeout for this operation. if this operation is @@ -932,17 +938,17 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) * timer on it, and set the host back to a consistent state prior to * returning. */ -static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd) +static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_device *sdev) { enum scsi_disposition rtn; - struct scsi_host_template *hostt = scmd->device->host->hostt; + struct scsi_host_template *hostt = sdev->host->hostt; if (!hostt->eh_device_reset_handler) return FAILED; - rtn = hostt->eh_device_reset_handler(scmd->device); + rtn = hostt->eh_device_reset_handler(sdev); if (rtn == SUCCESS) - __scsi_report_device_reset(scmd->device, NULL); + __scsi_report_device_reset(sdev); return rtn; } @@ -974,11 +980,15 @@ scsi_try_to_abort_cmd(struct scsi_host_template *hostt, struct scsi_cmnd *scmd) static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) { - if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS) - if (scsi_try_bus_device_reset(scmd) != SUCCESS) - if (scsi_try_target_reset(scmd) != SUCCESS) - if (scsi_try_bus_reset(scmd) != SUCCESS) - scsi_try_host_reset(scmd); + struct Scsi_Host *host = scmd->device->host; + struct scsi_target *starget = scsi_target(scmd->device); + int channel = scmd->device->channel; + + if (scsi_try_to_abort_cmd(host->hostt, scmd) != SUCCESS) + if (scsi_try_bus_device_reset(scmd->device) != SUCCESS) + if (scsi_try_target_reset(host, starget) != SUCCESS) + if (scsi_try_bus_reset(host, channel) != SUCCESS) + scsi_try_host_reset(host); } /** @@ -1561,7 +1571,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, SCSI_LOG_ERROR_RECOVERY(3, sdev_printk(KERN_INFO, sdev, "%s: Sending BDR\n", current->comm)); - rtn = scsi_try_bus_device_reset(bdr_scmd); + rtn = scsi_try_bus_device_reset(sdev); if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { if (!scsi_device_online(sdev) || rtn == FAST_IO_FAIL || @@ -1626,7 +1636,7 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost, shost_printk(KERN_INFO, shost, "%s: Sending target reset to target %d\n", current->comm, id)); - rtn = scsi_try_target_reset(scmd); + rtn = scsi_try_target_reset(shost, scsi_target(scmd->device)); if (rtn != SUCCESS && rtn != FAST_IO_FAIL) SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, shost, @@ -1701,7 +1711,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost, shost_printk(KERN_INFO, shost, "%s: Sending BRST chan: %d\n", current->comm, channel)); - rtn = scsi_try_bus_reset(chan_scmd); + rtn = scsi_try_bus_reset(shost, channel); if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { list_for_each_entry_safe(scmd, next, work_q, eh_entry) { if (channel == scmd_channel(scmd)) { @@ -1747,7 +1757,7 @@ static int scsi_eh_host_reset(struct Scsi_Host *shost, "%s: Sending HRST\n", current->comm)); - rtn = scsi_try_host_reset(scmd); + rtn = scsi_try_host_reset(shost); if (rtn == SUCCESS) { list_splice_init(work_q, &check_list); } else if (rtn == FAST_IO_FAIL) { @@ -2342,7 +2352,7 @@ void scsi_report_bus_reset(struct Scsi_Host *shost, int channel) __shost_for_each_device(sdev, shost) { if (channel == sdev_channel(sdev)) - __scsi_report_device_reset(sdev, NULL); + __scsi_report_device_reset(sdev); } } EXPORT_SYMBOL(scsi_report_bus_reset); @@ -2376,7 +2386,7 @@ void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target) __shost_for_each_device(sdev, shost) { if (channel == sdev_channel(sdev) && target == sdev_id(sdev)) - __scsi_report_device_reset(sdev, NULL); + __scsi_report_device_reset(sdev); } } EXPORT_SYMBOL(scsi_report_device_reset); @@ -2389,9 +2399,8 @@ EXPORT_SYMBOL(scsi_report_device_reset); int scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) { - struct scsi_cmnd *scmd; struct Scsi_Host *shost = dev->host; - struct request *rq; + struct scsi_target *starget = scsi_target(dev); unsigned long flags; int error = 0, val; enum scsi_disposition rtn; @@ -2406,23 +2415,6 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) if (scsi_autopm_get_host(shost) < 0) return -EIO; - error = -EIO; - rq = kzalloc(sizeof(struct request) + sizeof(struct scsi_cmnd) + - shost->hostt->cmd_size, GFP_KERNEL); - if (!rq) - goto out_put_autopm_host; - blk_rq_init(NULL, rq); - - scmd = (struct scsi_cmnd *)(rq + 1); - scsi_init_command(dev, scmd); - - scmd->submitter = SUBMITTED_BY_SCSI_RESET_IOCTL; - memset(&scmd->sdb, 0, sizeof(scmd->sdb)); - - scmd->cmd_len = 0; - - scmd->sc_data_direction = DMA_BIDIRECTIONAL; - spin_lock_irqsave(shost->host_lock, flags); shost->tmf_in_progress = 1; spin_unlock_irqrestore(shost->host_lock, flags); @@ -2432,22 +2424,22 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) rtn = SUCCESS; break; case SG_SCSI_RESET_DEVICE: - rtn = scsi_try_bus_device_reset(scmd); + rtn = scsi_try_bus_device_reset(dev); if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE)) break; fallthrough; case SG_SCSI_RESET_TARGET: - rtn = scsi_try_target_reset(scmd); + rtn = scsi_try_target_reset(shost, starget); if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE)) break; fallthrough; case SG_SCSI_RESET_BUS: - rtn = scsi_try_bus_reset(scmd); + rtn = scsi_try_bus_reset(shost, dev->channel); if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE)) break; fallthrough; case SG_SCSI_RESET_HOST: - rtn = scsi_try_host_reset(scmd); + rtn = scsi_try_host_reset(shost); if (rtn == SUCCESS) break; fallthrough; @@ -2473,9 +2465,6 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) wake_up(&shost->host_wait); scsi_run_host_queues(shost); - kfree(rq); - -out_put_autopm_host: scsi_autopm_put_host(shost); return error; } From patchwork Mon May 2 21:59:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834825 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 55591C433F5 for ; Mon, 2 May 2022 22:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387821AbiEBWFJ (ORCPT ); Mon, 2 May 2022 18:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347523AbiEBWDo (ORCPT ); Mon, 2 May 2022 18:03:44 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 528AE6427 for ; Mon, 2 May 2022 15:00:04 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C7FA221872; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=iBit0ICYDSAAawjE+CCwlaOHjSIeNNmfsllZSaTjGC28/XaLrjjcnlri20irdP6GyPNPEk eM1KK31+hVPk1BUFJ86dP94oqoFZT/OWsg59ZunIw57OmjYAsLgUEwwu1S54f2NVyhOroS hd4pB/id2e+s1GeC1AHpouTSUfKqKrw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=c+m17kFig+HbWSLbITOYGoJx41Wa+pCumCAega+3s3bBaz3hBYhRkCyExOzVmPWjT59g8D 815MhybUxNEpY+BA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id C2D5F2C15B; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id BFEC05194156; Tue, 3 May 2022 00:00:00 +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:59:46 +0200 Message-Id: <20220502215953.5463-12-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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:59:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834824 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 ECB05C433F5 for ; Mon, 2 May 2022 22:01:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387816AbiEBWFC (ORCPT ); Mon, 2 May 2022 18:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387758AbiEBWDf (ORCPT ); Mon, 2 May 2022 18:03:35 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527A2640B for ; Mon, 2 May 2022 15:00:04 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D72A021875; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=VcRSk9+B9bVk8pVZlHZAKrjmwD2iT6Wm4p5geMW8EVE=; b=ZBkP7z7rjDpLVVbD+S0yByjtQbBtjRX4Lw/fJZDDs9IOnKW4zBJCfpzcj5RPdpbCEsAQ/e SQuh7hpa6uyBfFTrVBEotBh9NfpE65fNgIi8YbOPRmW5QiCUy8d+DOZRjHNNNChtszxxeD lq7bO4tP3YJtozRsH1s0Y545a33kONA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=VcRSk9+B9bVk8pVZlHZAKrjmwD2iT6Wm4p5geMW8EVE=; b=kMxVtgcIh/yM+XSzsyOxzECrV7Pg202ikaVRKIKRFK0wmX7MIF+RE5YsnAnBVPwvTT0NoX G2WkhFUuSiNSvRAg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id D15B52C161; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id CF387519415C; Tue, 3 May 2022 00:00:00 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 7/7] scsi_error: streamline scsi_eh_bus_device_reset() Date: Mon, 2 May 2022 23:59:49 +0200 Message-Id: <20220502215953.5463-15-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke Streamline to use a similar code flow as the other reset functions. Signed-off-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ad68149ab8a1..b2e70e262095 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1547,6 +1547,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, { struct scsi_cmnd *scmd, *bdr_scmd, *next; struct scsi_device *sdev; + LIST_HEAD(check_list); enum scsi_disposition rtn; shost_for_each_device(sdev, shost) { @@ -1572,27 +1573,22 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, sdev_printk(KERN_INFO, sdev, "%s: Sending BDR\n", current->comm)); rtn = scsi_try_bus_device_reset(sdev); - if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { - if (!scsi_device_online(sdev) || - rtn == FAST_IO_FAIL || - !scsi_eh_tur(bdr_scmd)) { - list_for_each_entry_safe(scmd, next, - work_q, eh_entry) { - if (scmd->device == sdev && - scsi_eh_action(scmd, rtn) != FAILED) - __scsi_eh_finish_cmd(scmd, - done_q, - DID_RESET); - } - } - } else { + if (rtn != SUCCESS && rtn != FAST_IO_FAIL) SCSI_LOG_ERROR_RECOVERY(3, sdev_printk(KERN_INFO, sdev, "%s: BDR failed\n", current->comm)); + list_for_each_entry_safe(scmd, next, work_q, eh_entry) { + if (scmd->device != sdev) + continue; + if (rtn == SUCCESS) + list_move_tail(&scmd->eh_entry, &check_list); + else if (rtn == FAST_IO_FAIL) + __scsi_eh_finish_cmd(scmd, done_q, + DID_TRANSPORT_DISRUPTED); } } - return list_empty(work_q); + return scsi_eh_test_devices(&check_list, work_q, done_q, 0); } /** From patchwork Mon May 2 21:59:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834834 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 42314C433FE for ; Mon, 2 May 2022 22:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387853AbiEBWFs (ORCPT ); Mon, 2 May 2022 18:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387802AbiEBWDx (ORCPT ); Mon, 2 May 2022 18:03:53 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60BCE0AA for ; Mon, 2 May 2022 15:00:05 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id DC10221877; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=NDEoqFFhDZIf6rgjsEJ0VGZcluUwebnGrNF0JKQh36jHiG9wPrawIfKj+JiDM6UCshykp6 zXjSLok4FQUma1FxoSt+yHjZ2EpQHrId1PkymICqeRSN8iC3DqHQ+NM/pX0vMN38SzfhSK wgZG+uBcFMo+aZQ+SrHc+UxfScED23w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=FOIdTrfk3qH5j76DO1wkZA1vZE4hAQxDR0EgpT3nE6szKPbHy90Cy1bupkCiORYi+u1ixn XgaNd9Oo5DQWIrBw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id D7DCC2C15F; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id D4A82519415E; Tue, 3 May 2022 00:00:00 +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:59:50 +0200 Message-Id: <20220502215953.5463-16-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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:59:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834832 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 32237C433F5 for ; Mon, 2 May 2022 22:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387827AbiEBWFe (ORCPT ); Mon, 2 May 2022 18:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387798AbiEBWDw (ORCPT ); Mon, 2 May 2022 18:03:52 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF2922602 for ; Mon, 2 May 2022 15:00:05 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E266621878; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=Q5Lw3i34ThhYAXf4jNqjWSqIN66EwlBvX+Sk1jTg+AYgff3zkvuSaTqxdXUMklPTsal5I3 Xgk1aADl/EinDpa9DqSi3ArU2aVb6VqCu400Q6c2h62g6iggBxmHzTmMTLqtjRVVI1S3S1 REXDMrESWI+K11gZK89l6+WJAHZJcKo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=9KqoUFdmtvv3jI5ESWlBjjw3zpMlq1xQSJHeuGu6h17jrO4UJj/oklRaBvyF71LZX13HZY Da2xLH3jqZxr+/Dg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id DC6AF2C161; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id D9CBB5194160; Tue, 3 May 2022 00:00:00 +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:59:51 +0200 Message-Id: <20220502215953.5463-17-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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 --- 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:59:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834830 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 D9728C433FE for ; Mon, 2 May 2022 22:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387835AbiEBWF2 (ORCPT ); Mon, 2 May 2022 18:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381208AbiEBWDt (ORCPT ); Mon, 2 May 2022 18:03:49 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B27646E for ; Mon, 2 May 2022 15:00:04 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E69E41F898; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=a7M4kPQZgBVA8mhpP3O30oBG3xf+m7kezFJ+ELc58BxpzSN/lNIeR/HWHCVry+3007/zPv 6uu37egmZA23GbQYk7miEwrqOAya4b36SnwCP7hlCwtFanZZ9A4AHZo54QvqHXejw6H32V 1HkcTpy2bB6aQWDfNKexdeDIAD4pO7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=rdedkNJHKD4/ipwxweKkcv3vxUMiUmdYjHN80d8AkpXc9M9w+bLHr4PgNAtG5XXcsjMq/B eunOBfsNQizcPJBA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id E2A5E2C162; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id DF8AF5194162; Tue, 3 May 2022 00:00:00 +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:59:52 +0200 Message-Id: <20220502215953.5463-18-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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 --- 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:59:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12834835 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 1F187C433F5 for ; Mon, 2 May 2022 22:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237468AbiEBWFm (ORCPT ); Mon, 2 May 2022 18:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387800AbiEBWDx (ORCPT ); Mon, 2 May 2022 18:03:53 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EB08DEF0 for ; Mon, 2 May 2022 15:00:05 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id ED28E1F899; Mon, 2 May 2022 22:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651528800; 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=qGRVlZEU5lEYH0mRqjBOVrBAGDNHXRq703O4Kjs6NUk7R8Wg7nabaQX0HddhqXeU/aBEfS VAbt0V/gxMS1tq8uc3RZwU12AaBtEoEiQPNqLQSTg2A/SjqYZAzNH20ee2jL77H+U/vYwR CTDQUCLfWzBjyPbRLdDqGTMG+nxSiIM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651528800; 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=hYpy7CDQKAxSN1jr+x8ata+OSzSgPHfdNUGY1o1neefh6QR5rgeO77UbqFzD7oH/YgQ++G qI9POuHpV+MCdfBA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id E7D8E2C165; Mon, 2 May 2022 22:00:00 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id E4F0F5194164; Tue, 3 May 2022 00:00:00 +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:59:53 +0200 Message-Id: <20220502215953.5463-19-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220502215953.5463-1-hare@suse.de> References: <20220502215953.5463-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 --- 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;