From patchwork Tue Aug 17 09:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A379BC4320A for ; Tue, 17 Aug 2021 09:16:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8331F60EE4 for ; Tue, 17 Aug 2021 09:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236014AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33156 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234347AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B70B521D04; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=jasCYoTQSante0B03rZR5hnYIqUY+XQmJp9qACF5208=; b=Y01oivKM5xd8L1Sr3WN6/Ap5eU6FrsORkOzJU7vmOW3yDe2efchIpVjnnwSDSaE0N+jLuy RrEL77mCbg38sww0XOD8HsoX+GKU0A7oLWayxSBJTbItFv5Bqq9E0H9h72n4lhc3K8opfB 2V/b9D2BYSDxm50QRWjf1XmnGDVEtDo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=jasCYoTQSante0B03rZR5hnYIqUY+XQmJp9qACF5208=; b=QgVUfdwQeUXeXEDszDKdEGkSieQuPU9nls1De9PijQ44CXCp6hIr9C8wV3l8SkLzDVioii ouE5G0wVvnoB5sDA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id AC783A3B81; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 9C4DC518CE61; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , James Smart Subject: [PATCH 01/51] lpfc: kill lpfc_bus_reset_handler Date: Tue, 17 Aug 2021 11:14:06 +0200 Message-Id: <20210817091456.73342-2-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org lpfc_bus_reset_handler is really just a loop calling lpfc_target_reset_handler() over all targets, which is what the error handler will be doing anyway. Signed-off-by: Hannes Reinecke Cc: James Smart Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 91 ----------------------------------- 1 file changed, 91 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index ee4ff4855866..56ccc66d3d5f 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6367,95 +6367,6 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) return status; } -/** - * lpfc_bus_reset_handler - scsi_host_template eh_bus_reset_handler entry point - * @cmnd: Pointer to scsi_cmnd data structure. - * - * This routine does target reset to all targets on @cmnd->device->host. - * This emulates Parallel SCSI Bus Reset Semantics. - * - * Return code : - * 0x2003 - Error - * 0x2002 - Success - **/ -static int -lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) -{ - struct Scsi_Host *shost = cmnd->device->host; - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; - struct lpfc_nodelist *ndlp = NULL; - struct lpfc_scsi_event_header scsi_event; - int match; - int ret = SUCCESS, status, i; - u32 logit = LOG_FCP; - - scsi_event.event_type = FC_REG_SCSI_EVENT; - scsi_event.subcategory = LPFC_EVENT_BUSRESET; - scsi_event.lun = 0; - memcpy(scsi_event.wwpn, &vport->fc_portname, sizeof(struct lpfc_name)); - memcpy(scsi_event.wwnn, &vport->fc_nodename, sizeof(struct lpfc_name)); - - fc_host_post_vendor_event(shost, fc_get_event_number(), - sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); - - status = fc_block_scsi_eh(cmnd); - if (status != 0 && status != SUCCESS) - return status; - - /* - * Since the driver manages a single bus device, reset all - * targets known to the driver. Should any target reset - * fail, this routine returns failure to the midlayer. - */ - for (i = 0; i < LPFC_MAX_TARGET; i++) { - /* Search for mapped node by target ID */ - match = 0; - spin_lock_irq(shost->host_lock); - list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { - - if (vport->phba->cfg_fcp2_no_tgt_reset && - (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE)) - continue; - if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && - ndlp->nlp_sid == i && - ndlp->rport && - ndlp->nlp_type & NLP_FCP_TARGET) { - match = 1; - break; - } - } - spin_unlock_irq(shost->host_lock); - if (!match) - continue; - - status = lpfc_send_taskmgmt(vport, cmnd, - i, 0, FCP_TARGET_RESET); - - if (status != SUCCESS) { - lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, - "0700 Bus Reset on target %d failed\n", - i); - ret = FAILED; - } - } - /* - * We have to clean up i/o as : they may be orphaned by the TMFs - * above; or if any of the TMFs failed, they may be in an - * indeterminate state. - * We will report success if all the i/o aborts successfully. - */ - - status = lpfc_reset_flush_io_context(vport, 0, 0, LPFC_CTX_HOST); - if (status != SUCCESS) - ret = FAILED; - if (ret == FAILED) - logit = LOG_TRACE_EVENT; - - lpfc_printf_vlog(vport, KERN_ERR, logit, - "0714 SCSI layer issued Bus Reset Data: x%x\n", ret); - return ret; -} - /** * lpfc_host_reset_handler - scsi_host_template eh_host_reset_handler entry pt * @cmnd: Pointer to scsi_cmnd data structure. @@ -7035,7 +6946,6 @@ struct scsi_host_template lpfc_template_nvme = { .eh_abort_handler = lpfc_no_handler, .eh_device_reset_handler = lpfc_no_handler, .eh_target_reset_handler = lpfc_no_handler, - .eh_bus_reset_handler = lpfc_no_handler, .eh_host_reset_handler = lpfc_no_handler, .slave_alloc = lpfc_no_slave, .slave_configure = lpfc_no_slave, @@ -7060,7 +6970,6 @@ struct scsi_host_template lpfc_template = { .eh_abort_handler = lpfc_abort_handler, .eh_device_reset_handler = lpfc_device_reset_handler, .eh_target_reset_handler = lpfc_target_reset_handler, - .eh_bus_reset_handler = lpfc_bus_reset_handler, .eh_host_reset_handler = lpfc_host_reset_handler, .slave_alloc = lpfc_slave_alloc, .slave_configure = lpfc_slave_configure, From patchwork Tue Aug 17 09:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A5BDC432BE for ; Tue, 17 Aug 2021 09:16:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33F2B60F11 for ; Tue, 17 Aug 2021 09:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239387AbhHQJRS (ORCPT ); Tue, 17 Aug 2021 05:17:18 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47382 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235320AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BF42820010; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=wE+IuMR3maVKhzxjUCj0UsBdatXqeF1DUTIU1dkY5e4=; b=LBdSHUStqdoz+KakDUd3DpQ/x0I5eQ39Nbn9KxOShjx7s/KL6Qi97BZQBnSZXSnm4c49hv 5LdDNqQah4AjF+VtDPZBnovJ+Sf4vcMuNW4Yj4+vUetUp3iXyx/kq6veJ/SL4hEvXhEfh1 rhbmR6WWi/i4gle54xBnGPxpu+EsJv0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=wE+IuMR3maVKhzxjUCj0UsBdatXqeF1DUTIU1dkY5e4=; b=YSGNuGAGn9mY7RGdGC1qAVtwj9I/qy97ysNd8k1+G0bnhq8jMQ2ttjBb1L9iySs9CKQ04B xqxsWjJq/1R1PABw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B34BAA3B93; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A1595518CE63; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , James Smart Subject: [PATCH 02/51] lpfc: drop lpfc_no_handler() Date: Tue, 17 Aug 2021 11:14:07 +0200 Message-Id: <20210817091456.73342-3-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The default SCSI EH action for a non-existing EH callback is to return FAILED, so having a callback just returning FAILED is pointless. Signed-off-by: Hannes Reinecke Cc: James Smart Reviewed-by: Christoph Hellwig Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 56ccc66d3d5f..48b932608ffb 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6925,12 +6925,6 @@ lpfc_no_command(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) return SCSI_MLQUEUE_HOST_BUSY; } -static int -lpfc_no_handler(struct scsi_cmnd *cmnd) -{ - return FAILED; -} - static int lpfc_no_slave(struct scsi_device *sdev) { @@ -6943,10 +6937,6 @@ struct scsi_host_template lpfc_template_nvme = { .proc_name = LPFC_DRIVER_NAME, .info = lpfc_info, .queuecommand = lpfc_no_command, - .eh_abort_handler = lpfc_no_handler, - .eh_device_reset_handler = lpfc_no_handler, - .eh_target_reset_handler = lpfc_no_handler, - .eh_host_reset_handler = lpfc_no_handler, .slave_alloc = lpfc_no_slave, .slave_configure = lpfc_no_slave, .scan_finished = lpfc_scan_finished, From patchwork Tue Aug 17 09:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F839C4320E for ; Tue, 17 Aug 2021 09:16:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82945600CC for ; Tue, 17 Aug 2021 09:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235320AbhHQJRS (ORCPT ); Tue, 17 Aug 2021 05:17:18 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33168 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235578AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id BCE5121D08; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=c47dIEKZmJqzOul7fIkV9q99tYgQbS7A1BMCgn22Rd0=; b=hJtsjV7etjpRi9MDaIZtv1DrFQdZ9/80pRMti5N0M2yodc4EJKXlzl+/ITWFYW1uTm6LN3 kFMy2NPjg4ISggwPICxUxR1mXnHYtqCENm7F4S735+M3tf30KvfmtR62jdYb7vTSZgWVWR 27eziC4lShxG3A5pXlQzAs9r+XQtfeA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=c47dIEKZmJqzOul7fIkV9q99tYgQbS7A1BMCgn22Rd0=; b=Baw2tmfkGJZ3NhPL4oqvCb2CdJTp1bOtnpteHvGbvzcKIGTyqLBRPqHxp+aoJQGxoW1RxO 8fV7GPe40vZlXDDw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B4EBDA3B94; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A6A5F518CE65; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , Matthew Wilcox Subject: [PATCH 03/51] sym53c8xx_2: split off bus reset from host reset Date: Tue, 17 Aug 2021 11:14:08 +0200 Message-Id: <20210817091456.73342-4-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The current handler does both, bus reset and host reset. So split them off into two distinct functions. Signed-off-by: Hannes Reinecke Cc: Matthew Wilcox --- drivers/scsi/sym53c8xx_2/sym_glue.c | 107 +++++++++++++++++----------- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 16b65fc4405c..2042bd132339 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -562,8 +562,6 @@ static void sym53c8xx_timer(struct timer_list *t) */ #define SYM_EH_ABORT 0 #define SYM_EH_DEVICE_RESET 1 -#define SYM_EH_BUS_RESET 2 -#define SYM_EH_HOST_RESET 3 /* * Generic method for our eh processing. @@ -583,35 +581,11 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) scmd_printk(KERN_WARNING, cmd, "%s operation started\n", opname); - /* We may be in an error condition because the PCI bus - * went down. In this case, we need to wait until the - * PCI bus is reset, the card is reset, and only then - * proceed with the scsi error recovery. There's no - * point in hurrying; take a leisurely wait. + /* + * Escalate to host reset if the PCI bus went down */ -#define WAIT_FOR_PCI_RECOVERY 35 - if (pci_channel_offline(pdev)) { - int finished_reset = 0; - init_completion(&eh_done); - spin_lock_irq(shost->host_lock); - /* Make sure we didn't race */ - if (pci_channel_offline(pdev)) { - BUG_ON(sym_data->io_reset); - sym_data->io_reset = &eh_done; - } else { - finished_reset = 1; - } - spin_unlock_irq(shost->host_lock); - if (!finished_reset) - finished_reset = wait_for_completion_timeout - (sym_data->io_reset, - WAIT_FOR_PCI_RECOVERY*HZ); - spin_lock_irq(shost->host_lock); - sym_data->io_reset = NULL; - spin_unlock_irq(shost->host_lock); - if (!finished_reset) - return SCSI_FAILED; - } + if (pci_channel_offline(pdev)) + return SCSI_FAILED; spin_lock_irq(shost->host_lock); /* This one is queued in some place -> to wait for completion */ @@ -632,15 +606,6 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) case SYM_EH_DEVICE_RESET: sts = sym_reset_scsi_target(np, cmd->device->id); break; - case SYM_EH_BUS_RESET: - sym_reset_scsi_bus(np, 1); - sts = 0; - break; - case SYM_EH_HOST_RESET: - sym_reset_scsi_bus(np, 0); - sym_start_up(shost, 1); - sts = 0; - break; default: break; } @@ -682,12 +647,72 @@ static int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd) static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd) { - return sym_eh_handler(SYM_EH_BUS_RESET, "BUS RESET", cmd); + struct Scsi_Host *shost = cmd->device->host; + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; + + scmd_printk(KERN_WARNING, cmd, "BUS 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); + sym_reset_scsi_bus(np, 1); + spin_unlock_irq(shost->host_lock); + + dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n"); + return SCSI_SUCCESS; } static int sym53c8xx_eh_host_reset_handler(struct scsi_cmnd *cmd) { - return sym_eh_handler(SYM_EH_HOST_RESET, "HOST RESET", cmd); + struct Scsi_Host *shost = cmd->device->host; + struct sym_data *sym_data = shost_priv(shost); + struct pci_dev *pdev = sym_data->pdev; + struct sym_hcb *np = sym_data->ncb; + struct completion eh_done; + int finished_reset = 1; + + shost_printk(KERN_WARNING, shost, "HOST RESET operation started\n"); + + /* We may be in an error condition because the PCI bus + * went down. In this case, we need to wait until the + * PCI bus is reset, the card is reset, and only then + * proceed with the scsi error recovery. There's no + * point in hurrying; take a leisurely wait. + */ +#define WAIT_FOR_PCI_RECOVERY 35 + if (pci_channel_offline(pdev)) { + init_completion(&eh_done); + spin_lock_irq(shost->host_lock); + /* Make sure we didn't race */ + if (pci_channel_offline(pdev)) { + BUG_ON(sym_data->io_reset); + sym_data->io_reset = &eh_done; + finished_reset = 0; + } + spin_unlock_irq(shost->host_lock); + if (!finished_reset) + finished_reset = wait_for_completion_timeout + (sym_data->io_reset, + WAIT_FOR_PCI_RECOVERY*HZ); + spin_lock_irq(shost->host_lock); + sym_data->io_reset = NULL; + spin_unlock_irq(shost->host_lock); + } + + if (finished_reset) { + sym_reset_scsi_bus(np, 0); + sym_start_up(shost, 1); + } + + shost_printk(KERN_WARNING, shost, "HOST RESET operation %s.\n", + finished_reset==1 ? "complete" : "failed"); + return finished_reset ? SCSI_SUCCESS : SCSI_FAILED; } /* From patchwork Tue Aug 17 09:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B9F7C432BE for ; Tue, 17 Aug 2021 09:16:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14DBA60EE4 for ; Tue, 17 Aug 2021 09:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239532AbhHQJRX (ORCPT ); Tue, 17 Aug 2021 05:17:23 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47532 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236163AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E217720017; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=Bo6uQ0chpkau1qtFdd+KxWArWfDmM9TOCYqEcMyKxnU=; b=csr5XW9ZK81X6rduIClK9TyLvgh9eVUk88XtabGCgP0O95SWnq09YCHyI3hJeVgT1Qreu4 OtQNXAqeALCH9JfOPmnUmk5CG4iycEIBnzB+Ag2Hkl1ebTtN+XbuHu8/8F4UeOg1bpTsR4 OKsPpFXebxF/b/I2b40lrKj7Rv/k0LY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=Bo6uQ0chpkau1qtFdd+KxWArWfDmM9TOCYqEcMyKxnU=; b=kPppFjHYXX6dsT4oPfZhPMx8WKfu7BGww1uB9+HWLnQyZgYsIzczAj+mQ9vzM560NOnx5x aegDSu3BWzvuVTAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B86A8A3B96; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id AD84D518CE67; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , Adaptec OEM Raid Solutions Subject: [PATCH 04/51] ips: Do not try to abort command from host reset Date: Tue, 17 Aug 2021 11:14:09 +0200 Message-Id: <20210817091456.73342-5-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The code for aborting an outstanding command is a copy of the functionality from command abort. As we already have called this function once we reach host reset there's no point in trying to do so again. Signed-off-by: Hannes Reinecke Cc: Adaptec OEM Raid Solutions --- drivers/scsi/ips.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 8b33c9871484..3760bcfc40d1 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -835,7 +835,6 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) int i; ips_ha_t *ha; ips_scb_t *scb; - ips_copp_wait_item_t *item; METHOD_TRACE("ips_eh_reset", 1); @@ -860,23 +859,6 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) if (!ha->active) return (FAILED); - /* See if the command is on the copp queue */ - item = ha->copp_waitlist.head; - while ((item) && (item->scsi_cmd != SC)) - item = item->next; - - if (item) { - /* Found it */ - ips_removeq_copp(&ha->copp_waitlist, item); - return (SUCCESS); - } - - /* See if the command is on the wait queue */ - if (ips_removeq_wait(&ha->scb_waitlist, SC)) { - /* command not sent yet */ - return (SUCCESS); - } - /* An explanation for the casual observer: */ /* Part of the function of a RAID controller is automatic error */ /* detection and recovery. As such, the only problem that physically */ From patchwork Tue Aug 17 09:14:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05C57C4320A for ; Tue, 17 Aug 2021 09:16:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D72B460EE4 for ; Tue, 17 Aug 2021 09:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235895AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33176 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235849AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C445321D0B; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=Lz2/ar2mBUsC6LhoKQvJV0v1jhYsZtGmKMpp6CS77Fo=; b=NEGmC1KNZOXNAe5d3vR/y3wjXXNFWZbPfvj8zayA62nirJJlSBdx/vrqLYv1gjXc8Mvc24 Ib1X+mBmaVXXDg+fAK/nHnnm+FKzkVYoHLB3cVyVxdn2IF3A8fIOpqN+xuRGhCwbE32EEb E4/5z7PoZ0cAhnKyEg/NhULpvygKoBw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=Lz2/ar2mBUsC6LhoKQvJV0v1jhYsZtGmKMpp6CS77Fo=; b=nNq4/gXsqAWPdwrlWK7w0BqxwYAOr8KfsJOQmo7+4nIrQo0y3dyz5SGEiv0b4QdOTNwP7e e1Zl1SRX5YY+opDg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B8FA7A3B97; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id B3637518CE69; Tue, 17 Aug 2021 11:16:41 +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/51] snic: reserve tag for TMF Date: Tue, 17 Aug 2021 11:14:10 +0200 Message-Id: <20210817091456.73342-6-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Rather than re-using the failed command the snic driver should reserve one command for TMFs. Signed-off-by: Hannes Reinecke --- drivers/scsi/snic/snic.h | 3 ++- drivers/scsi/snic/snic_main.c | 3 +++ drivers/scsi/snic/snic_scsi.c | 51 +++++++++++++++-------------------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h index f4c666285bba..f88ecf73f708 100644 --- a/drivers/scsi/snic/snic.h +++ b/drivers/scsi/snic/snic.h @@ -310,6 +310,7 @@ struct snic { struct list_head spl_cmd_list; unsigned int max_tag_id; + unsigned int tmf_tag_id; atomic_t ios_inflight; /* io in flight counter */ struct vnic_snic_config config; @@ -380,7 +381,7 @@ int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int snic_abort_cmd(struct scsi_cmnd *); int snic_device_reset(struct scsi_cmnd *); int snic_host_reset(struct scsi_cmnd *); -int snic_reset(struct Scsi_Host *, struct scsi_cmnd *); +int snic_reset(struct Scsi_Host *); void snic_shutdown_scsi_cleanup(struct snic *); diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c index 14f4ce665e58..65f50057c66e 100644 --- a/drivers/scsi/snic/snic_main.c +++ b/drivers/scsi/snic/snic_main.c @@ -512,6 +512,9 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) max_t(u32, SNIC_MIN_IO_REQ, max_ios)); snic->max_tag_id = shost->can_queue; + /* Reserve one reset command */ + shost->can_queue--; + snic->tmf_tag_id = shost->can_queue; shost->max_lun = snic->config.luns_per_tgt; shost->max_id = SNIC_MAX_TARGET; diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index 6dd0ff188bb4..1e59d59130d6 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -1021,17 +1021,6 @@ snic_hba_reset_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) "reset_cmpl: type = %x, hdr_stat = %x, cmnd_id = %x, hid = %x, ctx = %lx\n", typ, hdr_stat, cmnd_id, hid, ctx); - /* spl case, host reset issued through ioctl */ - if (cmnd_id == SCSI_NO_TAG) { - rqi = (struct snic_req_info *) ctx; - SNIC_HOST_INFO(snic->shost, - "reset_cmpl:Tag %d ctx %lx cmpl stat %s\n", - cmnd_id, ctx, snic_io_status_to_str(hdr_stat)); - sc = rqi->sc; - - goto ioctl_hba_rst; - } - if (cmnd_id >= snic->max_tag_id) { SNIC_HOST_ERR(snic->shost, "reset_cmpl: Tag 0x%x out of Range,HdrStat %s\n", @@ -1042,7 +1031,6 @@ snic_hba_reset_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) } sc = scsi_host_find_tag(snic->shost, cmnd_id); -ioctl_hba_rst: if (!sc) { atomic64_inc(&snic->s_stats.io.sc_null); SNIC_HOST_ERR(snic->shost, @@ -1728,7 +1716,7 @@ snic_dr_clean_single_req(struct snic *snic, { struct snic_req_info *rqi = NULL; struct snic_tgt *tgt = NULL; - struct scsi_cmnd *sc = NULL; + struct scsi_cmnd *sc; spinlock_t *io_lock = NULL; u32 sv_state = 0, tmf = 0; DECLARE_COMPLETION_ONSTACK(tm_done); @@ -2241,13 +2229,6 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) goto hba_rst_end; } - if (snic_cmd_tag(sc) == SCSI_NO_TAG) { - memset(scsi_cmd_priv(sc), 0, - sizeof(struct snic_internal_io_state)); - SNIC_HOST_INFO(snic->shost, "issu_hr:Host reset thru ioctl.\n"); - rqi->sc = sc; - } - req = rqi_to_req(rqi); io_lock = snic_io_lock_hash(snic, sc); @@ -2322,11 +2303,13 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) } /* end of snic_issue_hba_reset */ int -snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) +snic_reset(struct Scsi_Host *shost) { struct snic *snic = shost_priv(shost); + struct scsi_cmnd *sc = NULL; enum snic_state sv_state; unsigned long flags; + u32 start_time = jiffies; int ret = FAILED; /* Set snic state as SNIC_FWRESET*/ @@ -2351,6 +2334,18 @@ snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) while (atomic_read(&snic->ios_inflight)) schedule_timeout(msecs_to_jiffies(1)); + sc = scsi_host_find_tag(shost, snic->tmf_tag_id); + if (!sc) { + SNIC_HOST_ERR(shost, + "reset:Host Reset Failed to allocate sc.\n"); + spin_lock_irqsave(&snic->snic_lock, flags); + snic_set_state(snic, sv_state); + spin_unlock_irqrestore(&snic->snic_lock, flags); + atomic64_inc(&snic->s_stats.reset.hba_reset_fail); + ret = FAILED; + + goto reset_end; + } ret = snic_issue_hba_reset(snic, sc); if (ret) { SNIC_HOST_ERR(shost, @@ -2368,6 +2363,10 @@ snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) ret = SUCCESS; reset_end: + SNIC_TRC(shost->host_no, sc ? snic_cmd_tag(sc) : SCSI_NO_TAG, + (ulong) sc, jiffies_to_msecs(jiffies - start_time), + 0, 0, 0); + return ret; } /* end of snic_reset */ @@ -2382,21 +2381,13 @@ int snic_host_reset(struct scsi_cmnd *sc) { struct Scsi_Host *shost = sc->device->host; - u32 start_time = jiffies; - int ret = FAILED; SNIC_SCSI_DBG(shost, "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n", sc, sc->cmnd[0], sc->request, snic_cmd_tag(sc), CMD_FLAGS(sc)); - ret = snic_reset(shost, sc); - - SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc, - jiffies_to_msecs(jiffies - start_time), - 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); - - return ret; + return snic_reset(shost); } /* end of snic_host_reset */ /* From patchwork Tue Aug 17 09:14:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8109FC4338F for ; Tue, 17 Aug 2021 09:16:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65C2C600CC for ; Tue, 17 Aug 2021 09:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239467AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47406 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235763AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C3CDF20012; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=SbPNn5B0V1abBkw0dLk1QsNp6q4ID6MbrxsWXBOvtfI=; b=wltYdFeSLXpo9JlOfrXWBvSFlYXpcp/hs3xz78bxmAHG+Li3whiKEun0w8Vu6UGThpOM9F EsT80E2afTW06lk///rotCOh8FL1dMYbgpicDs9oJMcA0j9dNMwxtSvbIb9VSkOpzFFjve k0Cgf+tMpHaP1UgrSr/nIuimCwe5h4w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=SbPNn5B0V1abBkw0dLk1QsNp6q4ID6MbrxsWXBOvtfI=; b=NpYL+t1Eq3xOpVNmfwtJynOEy6Q9UR4+J0+3UihbLamE9OFsdWkuYas2ihh0xMbJKM0Cy7 JBjy7sdUc5W3hiBw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id BCC1DA3B98; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id B997F518CE6B; Tue, 17 Aug 2021 11:16:41 +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/51] qla1280: separate out host reset function from qla1280_error_action() Date: Tue, 17 Aug 2021 11:14:11 +0200 Message-Id: <20210817091456.73342-7-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There's not much in common between host reset and all other error handlers, so use a separate function here. Signed-off-by: Hannes Reinecke --- drivers/scsi/qla1280.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 928da90b79be..3361e24a1b62 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -726,7 +726,6 @@ enum action { ABORT_COMMAND, DEVICE_RESET, BUS_RESET, - ADAPTER_RESET, }; @@ -908,22 +907,9 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) } break; - case ADAPTER_RESET: default: - if (qla1280_verbose) { - printk(KERN_INFO - "scsi(%ld): Issued ADAPTER RESET\n", - ha->host_no); - printk(KERN_INFO "scsi(%ld): I/O processing will " - "continue automatically\n", ha->host_no); - } - ha->flags.reset_active = 1; - - if (qla1280_abort_isp(ha) != 0) { /* it's dead */ - result = FAILED; - } - - ha->flags.reset_active = 0; + dprintk(1, "RESET invalid action %d\n", action); + return FAILED; } /* @@ -1022,10 +1008,26 @@ static int qla1280_eh_adapter_reset(struct scsi_cmnd *cmd) { int rc; + struct Scsi_Host *shost = cmd->device->host; + struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata; - spin_lock_irq(cmd->device->host->host_lock); - rc = qla1280_error_action(cmd, ADAPTER_RESET); - spin_unlock_irq(cmd->device->host->host_lock); + spin_lock_irq(shost->host_lock); + if (qla1280_verbose) { + printk(KERN_INFO + "scsi(%ld): Issued ADAPTER RESET\n", + ha->host_no); + printk(KERN_INFO "scsi(%ld): I/O processing will " + "continue automatically\n", ha->host_no); + } + ha->flags.reset_active = 1; + + if (qla1280_abort_isp(ha) != 0) { /* it's dead */ + rc = FAILED; + } + + ha->flags.reset_active = 0; + + spin_unlock_irq(shost->host_lock); return rc; } From patchwork Tue Aug 17 09:14:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C16C0C432BE for ; Tue, 17 Aug 2021 09:16:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A93AB60EE4 for ; Tue, 17 Aug 2021 09:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239418AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47422 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235947AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C7FE220013; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=DlDhx/qFtGavyP4HP0CZPaT7DeM3oruXXgo9tmPTz2M=; b=L0fZMI8h9McgS7DhANGsLC3BjVxm066Qw3Qxg+Cczt5XzCf4r+7zphfcmQqv6h5oOpbars rMjWzR3bgrlXdD0vM8C6QGut+HOoJLw+XjBUieObjpK+JSQqR7LzD16rKG8G4qemgDkNX+ lZAEZ6wYKD31UCVhGXHiKgF1sC03DC8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=DlDhx/qFtGavyP4HP0CZPaT7DeM3oruXXgo9tmPTz2M=; b=MxHtAau1e/BCuq78S5lP6+Psncl3fzYIiuirin+eEhtkFKYgmO1xd/SI3llGDMCqCwmR3p jqRmEV+bshRLNvAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id C22CAA3B99; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id BF52F518CE6D; Tue, 17 Aug 2021 11:16:41 +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 07/51] megaraid: pass in NULL scb for host reset Date: Tue, 17 Aug 2021 11:14:12 +0200 Message-Id: <20210817091456.73342-8-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When calling a host reset we shouldn't rely on the command triggering the reset, so allow megaraid_abort_and_reset() to be called with a NULL scb. And drop the pointless 'bus_reset' and 'target_reset' handlers, which just call the same function as host_reset. Signed-off-by: Hannes Reinecke --- drivers/scsi/megaraid.c | 42 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 56910e94dbf2..7c53933fb1b4 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1905,7 +1905,7 @@ megaraid_reset(struct scsi_cmnd *cmd) spin_lock_irq(&adapter->lock); - rval = megaraid_abort_and_reset(adapter, cmd, SCB_RESET); + rval = megaraid_abort_and_reset(adapter, NULL, SCB_RESET); /* * This is required here to complete any completed requests @@ -1944,7 +1944,7 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor) scb = list_entry(pos, scb_t, list); - if (scb->cmd == cmd) { /* Found command */ + if (!cmd || scb->cmd == cmd) { /* Found command */ scb->state |= aor; @@ -1963,31 +1963,23 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor) return FAILED; } - else { - - /* - * Not yet issued! Remove from the pending - * list - */ - dev_warn(&adapter->dev->dev, - "%s-[%x], driver owner\n", - (aor==SCB_ABORT) ? "ABORTING":"RESET", - scb->idx); - - mega_free_scb(adapter, scb); - - if( aor == SCB_ABORT ) { - cmd->result = (DID_ABORT << 16); - } - else { - cmd->result = (DID_RESET << 16); - } + /* + * Not yet issued! Remove from the pending + * list + */ + dev_warn(&adapter->dev->dev, + "%s-[%x], driver owner\n", + (cmd) ? "ABORTING":"RESET", + scb->idx); + mega_free_scb(adapter, scb); + if (cmd) { + cmd->result = (DID_ABORT << 16); list_add_tail(SCSI_LIST(cmd), - &adapter->completed_list); - - return SUCCESS; + &adapter->completed_list); } + + return SUCCESS; } } @@ -4135,8 +4127,6 @@ static struct scsi_host_template megaraid_template = { .sg_tablesize = MAX_SGLIST, .cmd_per_lun = DEF_CMD_PER_LUN, .eh_abort_handler = megaraid_abort, - .eh_device_reset_handler = megaraid_reset, - .eh_bus_reset_handler = megaraid_reset, .eh_host_reset_handler = megaraid_reset, .no_write_same = 1, }; From patchwork Tue Aug 17 09:14:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58F32C4338F for ; Tue, 17 Aug 2021 09:16:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41E4D60720 for ; Tue, 17 Aug 2021 09:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239527AbhHQJRW (ORCPT ); Tue, 17 Aug 2021 05:17:22 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47450 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235981AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D6A5620014; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=QM8+N+Fjtm2c/LTrtQP2sO2xn/YHy1e/vJXLx+ti6dY=; b=qIQN5a6Wh/6GU14vlgdsOTO73syHpo220zwQSUrAM+MX2MdeKYtbUCZyzFGSAzhjcE7W9w IiYJGGFvnhf36hosmVMkkeoVNtU2mUJ/YkXF6D1ABTTf5KUjE4exOk+Mbr5QUho7dTgYCc /ZRlyE7E7yiTKuc4Cy8KF4rkv7u7iWs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=QM8+N+Fjtm2c/LTrtQP2sO2xn/YHy1e/vJXLx+ti6dY=; b=VpNbocFnXNj0u1VgNcXi9UJZfZsklCW01+f6knUojr+Rruwgh/Zo+UiD+hz4Gv4ipjuaQo 7KMZRwgEocxp9zBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id C7F61A3B9A; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id C5B54518CE6F; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , Steffen Maier , Benjamin Block Subject: [PATCH 08/51] zfcp: open-code fc_block_scsi_eh() for host reset Date: Tue, 17 Aug 2021 11:14:13 +0200 Message-Id: <20210817091456.73342-9-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When issuing a host reset we should be waiting for all ports to become unblocked; just waiting for one might be resulting in host reset to return too early. Signed-off-by: Hannes Reinecke Cc: Steffen Maier Cc: Benjamin Block --- drivers/s390/scsi/zfcp_scsi.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 9da9b2b2a580..9393f1587e8a 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -373,9 +373,11 @@ static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) { - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device); - struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; - int ret = SUCCESS, fc_ret; + struct Scsi_Host *host = scpnt->device->host; + struct zfcp_adapter *adapter = (struct zfcp_adapter *)host->hostdata[0]; + int ret = SUCCESS; + unsigned long flags; + struct zfcp_port *port; if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE)) { zfcp_erp_port_forced_reopen_all(adapter, 0, "schrh_p"); @@ -383,9 +385,24 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) } zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); zfcp_erp_wait(adapter); - fc_ret = fc_block_scsi_eh(scpnt); - if (fc_ret) - ret = fc_ret; +retry_rport_blocked: + spin_lock_irqsave(host->host_lock, flags); + list_for_each_entry(port, &adapter->port_list, list) { + struct fc_rport *rport = port->rport; + + if (rport->port_state == FC_PORTSTATE_BLOCKED) { + if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT) + ret = FAST_IO_FAIL; + else + ret = NEEDS_RETRY; + break; + } + } + spin_unlock_irqrestore(host->host_lock, flags); + if (ret == NEEDS_RETRY) { + msleep(1000); + goto retry_rport_blocked; + } zfcp_dbf_scsi_eh("schrh_r", adapter, ~0, ret); return ret; From patchwork Tue Aug 17 09:14:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BD06C4338F for ; Tue, 17 Aug 2021 09:16:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 830D6600CC for ; Tue, 17 Aug 2021 09:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239465AbhHQJR0 (ORCPT ); Tue, 17 Aug 2021 05:17:26 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47534 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237391AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DBAC020015; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=V6GrJM0aouw/ZIvxMipA2gaYCMM+Hn6y+AkmstV+ltU=; b=e4JYa0KiJtVr8A3U0l0mUHXHNxceOr7yMvGoCu4p/K5q4jIipxZxAEW85V08GWQRjMcUtY YNFBNwv91tw8M25GxwDQQbgL8bK7ErIEfhcAYTXWzWNeThLa9bNKo7Dhm+FTcKW+jtYAnG HQ3rdnYR2EcQ29cUop1giffXCxLhHlc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=V6GrJM0aouw/ZIvxMipA2gaYCMM+Hn6y+AkmstV+ltU=; b=dyNT5LRwQxF8qF4E+V96p9ehe0t+/Nf23D68vzuHYIxi2RDVBstPxNrQ3+5SkFIxSBmKEA GpSaVWt1X7nWyrAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id CDF91A3B9C; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id CB8CB518CE71; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Kashyap Desai , Sathya Prakash Veerichetty , Sumit Saxena , Sreekanth Reddy Subject: [PATCH 09/51] mpi3mr: split off bus_reset function from host_reset Date: Tue, 17 Aug 2021 11:14:14 +0200 Message-Id: <20210817091456.73342-10-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org SCSI EH host reset is the final callback in the escalation chain; once we reach this we need to reset the controller. As such it defeats the purpose to skip controller reset if no I/Os are pending and the RAID device is to be reset; especially after kexec there might be stale commands pending in firmware for which we have no reference whatsoever. So this patch splits off the check for pending I/O into a 'bus_reset' function, and leaves the actual controller reset to the host reset. Signed-off-by: Hannes Reinecke Cc: Kashyap Desai Cc: Sathya Prakash Veerichetty Cc: Sumit Saxena Cc: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_os.c | 57 +++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 24ac7ddec749..456a24317bb5 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2879,20 +2879,45 @@ void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout) * mpi3mr_eh_host_reset - Host reset error handling callback * @scmd: SCSI command reference * - * Issue controller reset if the scmd is for a Physical Device, - * if the scmd is for RAID volume, then wait for - * MPI3MR_RAID_ERRREC_RESET_TIMEOUT and checke whether any - * pending I/Os prior to issuing reset to the controller. + * Issue controller reset * * Return: SUCCESS of successful reset else FAILED */ static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd) +{ + struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); + int retval = FAILED, ret; + + ret = mpi3mr_soft_reset_handler(mrioc, + MPI3MR_RESET_FROM_EH_HOS, 1); + if (ret) + goto out; + + retval = SUCCESS; +out: + sdev_printk(KERN_INFO, scmd->device, + "Host reset is %s for scmd(%p)\n", + ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + + return retval; +} + +/** + * mpi3mr_eh_bus_reset - Bus reset error handling callback + * @scmd: SCSI command reference + * + * Checks whether pending I/Os are present for the RAID volume; + * if not there's no need to reset the adapter. + * + * Return: SUCCESS of successful reset else FAILED + */ +static int mpi3mr_eh_bus_reset(struct scsi_cmnd *scmd) { struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); struct mpi3mr_stgt_priv_data *stgt_priv_data; struct mpi3mr_sdev_priv_data *sdev_priv_data; u8 dev_type = MPI3_DEVICE_DEVFORM_VD; - int retval = FAILED, ret; + int retval = FAILED; sdev_priv_data = scmd->device->hostdata; if (sdev_priv_data && sdev_priv_data->tgt_priv_data) { @@ -2902,25 +2927,16 @@ static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd) if (dev_type == MPI3_DEVICE_DEVFORM_VD) { mpi3mr_wait_for_host_io(mrioc, - MPI3MR_RAID_ERRREC_RESET_TIMEOUT); - if (!mpi3mr_get_fw_pending_ios(mrioc)) { + MPI3MR_RAID_ERRREC_RESET_TIMEOUT); + if (!mpi3mr_get_fw_pending_ios(mrioc)) retval = SUCCESS; - goto out; - } } + if (retval == FAILED) + mpi3mr_print_pending_host_io(mrioc); - mpi3mr_print_pending_host_io(mrioc); - ret = mpi3mr_soft_reset_handler(mrioc, - MPI3MR_RESET_FROM_EH_HOS, 1); - if (ret) - goto out; - - retval = SUCCESS; -out: sdev_printk(KERN_INFO, scmd->device, - "Host reset is %s for scmd(%p)\n", - ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); - + "Bus reset is %s for scmd(%p)\n", + ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); return retval; } @@ -3575,6 +3591,7 @@ static struct scsi_host_template mpi3mr_driver_template = { .change_queue_depth = mpi3mr_change_queue_depth, .eh_device_reset_handler = mpi3mr_eh_dev_reset, .eh_target_reset_handler = mpi3mr_eh_target_reset, + .eh_bus_reset_handler = mpi3mr_eh_bus_reset, .eh_host_reset_handler = mpi3mr_eh_host_reset, .bios_param = mpi3mr_bios_param, .map_queues = mpi3mr_map_queues, From patchwork Tue Aug 17 09:14:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D4AAC4320A for ; Tue, 17 Aug 2021 09:17:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFAAD60F11 for ; Tue, 17 Aug 2021 09:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239648AbhHQJRf (ORCPT ); Tue, 17 Aug 2021 05:17:35 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47544 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239161AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E00CD20016; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=kMF0Q/n/IeZKwPJ5ABFGRtHMtGJJ0Jn93J/uvSs1Ffo=; b=ePDwJ3hHwArnyRN43ayLNYsV8ALBcDjkvHUSHNzhaV/cU6IKySSiTF3MymWpNp4jtiNwf0 tVowOpSPbCELSPuy4hsc+4UFIerpoHoh1+Bw+Q5ZwrrNBCYeaSdiRF1wo61/DcJMGekU+L 6ineWR/KQRPV57B55OpVZH+Iio76QPo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=kMF0Q/n/IeZKwPJ5ABFGRtHMtGJJ0Jn93J/uvSs1Ffo=; b=yQglHq4hwCfh26P/GJ+ixJUTJL3Kp3VVgImEPqCGU3PsTs1VmvjAMWz/z0YPw18AIZmQeK Eev1mmlw6hArt3Dg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id D8419A3B9E; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id D5342518CE73; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 10/51] scsi: Use Scsi_Host as argument for eh_host_reset_handler Date: Tue, 17 Aug 2021 11:14:15 +0200 Message-Id: <20210817091456.73342-11-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Issuing a host reset should not rely on any commands. So use Scsi_Host as argument for eh_host_reset_handler. Signed-off-by: Hannes Reinecke Reviewed-by: Steffen Maier # for zfcp and common code Acked-by: Steffen Maier # for zfcp Reviewed-by: Bart Van Assche --- Documentation/scsi/scsi_eh.rst | 2 +- Documentation/scsi/scsi_mid_low_api.rst | 4 +- drivers/infiniband/ulp/srp/ib_srp.c | 6 +-- drivers/message/fusion/mptscsih.c | 19 +++++---- drivers/message/fusion/mptscsih.h | 2 +- drivers/s390/scsi/zfcp_scsi.c | 3 +- drivers/scsi/3w-9xxx.c | 11 +++--- drivers/scsi/3w-sas.c | 11 +++--- drivers/scsi/3w-xxxx.c | 11 +++--- drivers/scsi/53c700.c | 39 ++++++++++--------- drivers/scsi/BusLogic.c | 14 ++----- drivers/scsi/NCR5380.c | 3 +- drivers/scsi/aacraid/linit.c | 6 +-- drivers/scsi/advansys.c | 26 +++++++------ drivers/scsi/aha1542.c | 20 +++++----- drivers/scsi/arm/acornscsi.c | 8 ++-- drivers/scsi/arm/fas216.c | 4 +- drivers/scsi/arm/fas216.h | 6 +-- drivers/scsi/atari_scsi.c | 4 +- drivers/scsi/cxlflash/main.c | 5 +-- drivers/scsi/dpt_i2o.c | 14 +++---- drivers/scsi/dpti.h | 2 +- drivers/scsi/esas2r/esas2r.h | 2 +- drivers/scsi/esas2r/esas2r_main.c | 16 ++++---- drivers/scsi/esp_scsi.c | 4 +- drivers/scsi/fdomain.c | 3 +- drivers/scsi/fnic/fnic.h | 2 +- drivers/scsi/fnic/fnic_scsi.c | 3 +- drivers/scsi/hptiop.c | 6 +-- drivers/scsi/ibmvscsi/ibmvfc.c | 4 +- drivers/scsi/ibmvscsi/ibmvscsi.c | 4 +- drivers/scsi/imm.c | 6 +-- drivers/scsi/ipr.c | 4 +- drivers/scsi/ips.c | 22 ++++------- drivers/scsi/libfc/fc_fcp.c | 5 +-- drivers/scsi/lpfc/lpfc_scsi.c | 3 +- drivers/scsi/mac53c94.c | 8 ++-- drivers/scsi/megaraid.c | 4 +- drivers/scsi/megaraid.h | 2 +- drivers/scsi/megaraid/megaraid_mbox.c | 14 ++----- drivers/scsi/megaraid/megaraid_sas_base.c | 34 ++++++++-------- drivers/scsi/mesh.c | 10 ++--- drivers/scsi/mpi3mr/mpi3mr_os.c | 12 +++--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 11 +++--- drivers/scsi/mvumi.c | 7 ++-- drivers/scsi/myrb.c | 3 +- drivers/scsi/myrs.c | 3 +- drivers/scsi/nsp32.c | 12 +++--- drivers/scsi/pcmcia/nsp_cs.c | 4 +- drivers/scsi/pcmcia/nsp_cs.h | 2 +- drivers/scsi/pcmcia/qlogic_stub.c | 4 +- drivers/scsi/pcmcia/sym53c500_cs.c | 8 ++-- drivers/scsi/pmcraid.c | 6 +-- drivers/scsi/ppa.c | 6 +-- drivers/scsi/qedf/qedf_main.c | 4 +- drivers/scsi/qedi/qedi_iscsi.c | 3 +- drivers/scsi/qla1280.c | 3 +- drivers/scsi/qla2xxx/qla_os.c | 18 +++------ drivers/scsi/qla4xxx/ql4_os.c | 18 ++++----- drivers/scsi/qlogicfas408.c | 10 ++--- drivers/scsi/qlogicfas408.h | 2 +- drivers/scsi/qlogicpti.c | 3 +- drivers/scsi/scsi_debug.c | 8 ++-- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/snic/snic.h | 3 +- drivers/scsi/snic/snic_scsi.c | 29 ++++---------- drivers/scsi/stex.c | 7 ++-- drivers/scsi/storvsc_drv.c | 4 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 3 +- drivers/scsi/ufs/ufshcd.c | 6 +-- drivers/scsi/vmw_pvscsi.c | 5 +-- drivers/scsi/wd33c93.c | 5 +-- drivers/scsi/wd33c93.h | 2 +- drivers/scsi/wd719x.c | 4 +- .../staging/unisys/visorhba/visorhba_main.c | 4 +- drivers/usb/image/microtek.c | 4 +- include/scsi/libfc.h | 2 +- include/scsi/scsi_host.h | 2 +- 78 files changed, 271 insertions(+), 334 deletions(-) diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst index 7d78c2475615..1ca451ad57df 100644 --- a/Documentation/scsi/scsi_eh.rst +++ b/Documentation/scsi/scsi_eh.rst @@ -216,7 +216,7 @@ considered to fail always. int (* eh_abort_handler)(struct scsi_cmnd *); int (* eh_device_reset_handler)(struct scsi_cmnd *); int (* eh_bus_reset_handler)(struct scsi_cmnd *); - int (* eh_host_reset_handler)(struct scsi_cmnd *); + int (* eh_host_reset_handler)(struct Scsi_Host *); Higher-severity actions are taken only when lower-severity actions cannot recover some of failed scmds. Also, note that failure of the diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst index 63ddea2b9640..784587ea7eee 100644 --- a/Documentation/scsi/scsi_mid_low_api.rst +++ b/Documentation/scsi/scsi_mid_low_api.rst @@ -777,7 +777,7 @@ Details:: /** * eh_host_reset_handler - reset host (host bus adapter) - * @scp: SCSI host that contains this device should be reset + * @shp: SCSI host that contains this device should be reset * * Returns SUCCESS if command aborted else FAILED * @@ -794,7 +794,7 @@ Details:: * * Optionally defined in: LLD **/ - int eh_host_reset_handler(struct scsi_cmnd * scp) + int eh_host_reset_handler(struct Scsi_Host * shp) /** diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 8d5cf5eb5778..9a822fde6b44 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2834,11 +2834,11 @@ static int srp_reset_device(struct scsi_cmnd *scmnd) return SUCCESS; } -static int srp_reset_host(struct scsi_cmnd *scmnd) +static int srp_reset_host(struct Scsi_Host *shost) { - struct srp_target_port *target = host_to_target(scmnd->device->host); + struct srp_target_port *target = host_to_target(shost); - shost_printk(KERN_ERR, target->scsi_host, PFX "SRP reset_host called\n"); + shost_printk(KERN_ERR, shost, PFX "SRP reset_host called\n"); return srp_reconnect_rport(target->rport) == 0 ? SUCCESS : FAILED; } diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index ce2e5b21978e..4b994cadb51e 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1904,15 +1904,15 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** - * mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant) - * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to + * mptscsih_host_reset - Perform a SCSI host adapter RESET + * @sh: Pointer to Scsi_Host structure, which is reset due to * * (linux scsi_host_template.eh_host_reset_handler routine) * * Returns SUCCESS or FAILED. */ int -mptscsih_host_reset(struct scsi_cmnd *SCpnt) +mptscsih_host_reset(struct Scsi_Host *sh) { MPT_SCSI_HOST * hd; int status = SUCCESS; @@ -1920,9 +1920,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) int retval; /* If we can't locate the host to reset, then we failed. */ - if ((hd = shost_priv(SCpnt->device->host)) == NULL){ - printk(KERN_ERR MYNAM ": host reset: " - "Can't locate host! (sc=%p)\n", SCpnt); + if ((hd = shost_priv(sh)) == NULL){ + printk(KERN_ERR MYNAM ": host reset: Can't locate host!\n"); return FAILED; } @@ -1930,8 +1929,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) mptscsih_flush_running_cmds(hd); ioc = hd->ioc; - printk(MYIOC_s_INFO_FMT "attempting host reset! (sc=%p)\n", - ioc->name, SCpnt); + printk(MYIOC_s_INFO_FMT "attempting host reset!\n", + ioc->name); /* If our attempts to reset the host failed, then return a failed * status. The host will be taken off line by the SCSI mid-layer. @@ -1942,8 +1941,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) else status = SUCCESS; - printk(MYIOC_s_INFO_FMT "host reset: %s (sc=%p)\n", - ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); + printk(MYIOC_s_INFO_FMT "host reset: %s\n", + ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" )); return status; } diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 2baeefd9be7a..6ab82548e49e 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -121,7 +121,7 @@ extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt); extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt); -extern int mptscsih_host_reset(struct scsi_cmnd *SCpnt); +extern int mptscsih_host_reset(struct Scsi_Host *sh); extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]); extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); extern int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 9393f1587e8a..8bfa8ffd9ff6 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -371,9 +371,8 @@ static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) return ret; } -static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) +static int zfcp_scsi_eh_host_reset_handler(struct Scsi_Host *host) { - struct Scsi_Host *host = scpnt->device->host; struct zfcp_adapter *adapter = (struct zfcp_adapter *)host->hostdata[0]; int ret = SUCCESS; unsigned long flags; diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index e41cc354cc8a..2dc7d81afbde 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -1715,18 +1715,19 @@ static int twa_scsi_biosparam(struct scsi_device *sdev, struct block_device *bde } /* End twa_scsi_biosparam() */ /* This is the new scsi eh reset function */ -static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt) +static int twa_scsi_eh_reset(struct Scsi_Host *shost) { TW_Device_Extension *tw_dev = NULL; int retval = FAILED; - tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; + tw_dev = (TW_Device_Extension *)shost->hostdata; tw_dev->num_resets++; - sdev_printk(KERN_WARNING, SCpnt->device, - "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n", - TW_DRIVER, 0x2c, SCpnt->cmnd[0]); + shost_printk(KERN_WARNING, shost, + "WARNING: (0x%02X:0x%04X): " + "Command timed out, resetting card.\n", + TW_DRIVER, 0x2c); /* Make sure we are not issuing an ioctl or resetting from ioctl */ mutex_lock(&tw_dev->ioctl_lock); diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index 4fde39da54e4..54d953fc0c19 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1421,18 +1421,19 @@ static int twl_scsi_biosparam(struct scsi_device *sdev, struct block_device *bde } /* End twl_scsi_biosparam() */ /* This is the new scsi eh reset function */ -static int twl_scsi_eh_reset(struct scsi_cmnd *SCpnt) +static int twl_scsi_eh_reset(struct Scsi_Host *shost) { TW_Device_Extension *tw_dev = NULL; int retval = FAILED; - tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; + tw_dev = (TW_Device_Extension *)shost->hostdata; tw_dev->num_resets++; - sdev_printk(KERN_WARNING, SCpnt->device, - "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n", - TW_DRIVER, 0x2c, SCpnt->cmnd[0]); + shost_printk(KERN_WARNING, shost, + "WARNING: (0x%02X:0x%04X): " + "Command timed out, resetting card.\n", + TW_DRIVER, 0x2c); /* Make sure we are not issuing an ioctl or resetting from ioctl */ mutex_lock(&tw_dev->ioctl_lock); diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 4ee485ab2714..a96375ff8b3d 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -1364,25 +1364,24 @@ static int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev } /* End tw_scsi_biosparam() */ /* This is the new scsi eh reset function */ -static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt) +static int tw_scsi_eh_reset(struct Scsi_Host *shost) { TW_Device_Extension *tw_dev=NULL; int retval = FAILED; - tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; + tw_dev = (TW_Device_Extension *)shost->hostdata; tw_dev->num_resets++; - sdev_printk(KERN_WARNING, SCpnt->device, - "WARNING: Command (0x%x) timed out, resetting card.\n", - SCpnt->cmnd[0]); + shost_printk(KERN_WARNING, shost, + "WARNING: Command timed out, resetting card.\n"); /* Make sure we are not issuing an ioctl or resetting from ioctl */ mutex_lock(&tw_dev->ioctl_lock); /* Now reset the card and some of the device extension data */ if (tw_reset_device_extension(tw_dev)) { - printk(KERN_WARNING "3w-xxxx: scsi%d: Reset failed.\n", tw_dev->host->host_no); + shost_printk(KERN_WARNING, shost, "Reset failed.\n"); goto out; } diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 1c6b4e672687..0cae57350d24 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -155,7 +155,7 @@ MODULE_LICENSE("GPL"); STATIC int NCR_700_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *); STATIC int NCR_700_abort(struct scsi_cmnd * SCpnt); -STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt); +STATIC int NCR_700_host_reset(struct Scsi_Host *host); STATIC void NCR_700_chip_setup(struct Scsi_Host *host); STATIC void NCR_700_chip_reset(struct Scsi_Host *host); STATIC int NCR_700_slave_alloc(struct scsi_device *SDpnt); @@ -1939,40 +1939,41 @@ NCR_700_abort(struct scsi_cmnd * SCp) } STATIC int -NCR_700_host_reset(struct scsi_cmnd * SCp) +NCR_700_host_reset(struct Scsi_Host * host) { DECLARE_COMPLETION_ONSTACK(complete); - struct NCR_700_Host_Parameters *hostdata = - (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; + struct NCR_700_Host_Parameters *hostdata = + (struct NCR_700_Host_Parameters *)host->hostdata[0]; - scmd_printk(KERN_INFO, SCp, - "New error handler wants HOST reset, cmd %p\n\t", SCp); - scsi_print_command(SCp); + shost_printk(KERN_INFO, host, + "New error handler wants HOST reset\n"); /* In theory, eh_complete should always be null because the * eh is single threaded, but just in case we're handling a * reset via sg or something */ - spin_lock_irq(SCp->device->host->host_lock); + spin_lock_irq(host->host_lock); while (hostdata->eh_complete != NULL) { - spin_unlock_irq(SCp->device->host->host_lock); + spin_unlock_irq(host->host_lock); msleep_interruptible(100); - spin_lock_irq(SCp->device->host->host_lock); + spin_lock_irq(host->host_lock); } hostdata->eh_complete = &complete; - NCR_700_internal_bus_reset(SCp->device->host); - NCR_700_chip_reset(SCp->device->host); + NCR_700_internal_bus_reset(host); + NCR_700_chip_reset(host); - spin_unlock_irq(SCp->device->host->host_lock); + spin_unlock_irq(host->host_lock); wait_for_completion(&complete); - spin_lock_irq(SCp->device->host->host_lock); + spin_lock_irq(host->host_lock); hostdata->eh_complete = NULL; - /* Revalidate the transport parameters of the failing device */ - if(hostdata->fast) - spi_schedule_dv_device(SCp->device); - - spin_unlock_irq(SCp->device->host->host_lock); + /* Revalidate the transport parameters for attached devices */ + if(hostdata->fast) { + struct scsi_device *sdev; + __shost_for_each_device(sdev, host) + spi_schedule_dv_device(sdev); + } + spin_unlock_irq(host->host_lock); return SUCCESS; } diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 40088dcb98cd..b3c19da494af 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -2843,21 +2843,15 @@ static bool blogic_write_outbox(struct blogic_adapter *adapter, /* Error Handling (EH) support */ -static int blogic_hostreset(struct scsi_cmnd *SCpnt) +static int blogic_hostreset(struct Scsi_Host *shost) { struct blogic_adapter *adapter = - (struct blogic_adapter *) SCpnt->device->host->hostdata; - - unsigned int id = SCpnt->device->id; - struct blogic_tgt_stats *stats = &adapter->tgt_stats[id]; + (struct blogic_adapter *) shost->hostdata; int rc; - spin_lock_irq(SCpnt->device->host->host_lock); - - blogic_inc_count(&stats->adapter_reset_req); - + spin_lock_irq(shost->host_lock); rc = blogic_resetadapter(adapter, false); - spin_unlock_irq(SCpnt->device->host->host_lock); + spin_unlock_irq(shost->host_lock); return rc; } diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 3baadd068768..57db58f33d3f 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -2381,9 +2381,8 @@ static void bus_reset_cleanup(struct Scsi_Host *instance) * Returns SUCCESS */ -static int NCR5380_host_reset(struct scsi_cmnd *cmd) +static int NCR5380_host_reset(struct Scsi_Host *instance) { - struct Scsi_Host *instance = cmd->device->host; struct NCR5380_hostdata *hostdata = shost_priv(instance); unsigned long flags; struct NCR5380_cmd *ncmd; diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 3168915adaa7..59909a8e4813 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1076,13 +1076,11 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd) /* * aac_eh_host_reset - Host reset command handling - * @scsi_cmd: SCSI command block causing the reset + * @host: SCSI host to be reset * */ -static int aac_eh_host_reset(struct scsi_cmnd *cmd) +static int aac_eh_host_reset(struct Scsi_Host *host) { - struct scsi_device * dev = cmd->device; - struct Scsi_Host * host = dev->host; struct aac_dev * aac = (struct aac_dev *)host->hostdata; int ret = FAILED; __le32 supported_options2 = 0; diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index f3377e2ef5fb..bf781d88bb26 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -7007,9 +7007,8 @@ static int AscISR(ASC_DVC_VAR *asc_dvc) * sleeping is allowed and no locking other than for host structures is * required. Returns SUCCESS or FAILED. */ -static int advansys_reset(struct scsi_cmnd *scp) +static int advansys_reset(struct Scsi_Host *shost) { - struct Scsi_Host *shost = scp->device->host; struct asc_board *boardp = shost_priv(shost); unsigned long flags; int status; @@ -7019,7 +7018,7 @@ static int advansys_reset(struct scsi_cmnd *scp) ASC_STATS(shost, reset); - scmd_printk(KERN_INFO, scp, "SCSI host reset started...\n"); + shost_printk(KERN_INFO, shost, "SCSI host reset started...\n"); if (ASC_NARROW_BOARD(boardp)) { ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var; @@ -7030,16 +7029,18 @@ static int advansys_reset(struct scsi_cmnd *scp) /* Refer to ASC_IERR_* definitions for meaning of 'err_code'. */ if (asc_dvc->err_code || !asc_dvc->overrun_dma) { - scmd_printk(KERN_INFO, scp, "SCSI host reset error: " - "0x%x, status: 0x%x\n", asc_dvc->err_code, + shost_printk(KERN_INFO, shost, + "SCSI host reset error: 0x%x, status: 0x%x\n", + asc_dvc->err_code, status); ret = FAILED; } else if (status) { - scmd_printk(KERN_INFO, scp, "SCSI host reset warning: " - "0x%x\n", status); + shost_printk(KERN_INFO, shost, + "SCSI host reset warning: 0x%x\n", + status); } else { - scmd_printk(KERN_INFO, scp, "SCSI host reset " - "successful\n"); + shost_printk(KERN_INFO, shost, + "SCSI host reset successful\n"); } ASC_DBG(1, "after AscInitAsc1000Driver()\n"); @@ -7056,12 +7057,13 @@ static int advansys_reset(struct scsi_cmnd *scp) ASC_DBG(1, "before AdvResetChipAndSB()\n"); switch (AdvResetChipAndSB(adv_dvc)) { case ASC_TRUE: - scmd_printk(KERN_INFO, scp, "SCSI host reset " - "successful\n"); + shost_printk(KERN_INFO, shost, + "SCSI host reset successful\n"); break; case ASC_FALSE: default: - scmd_printk(KERN_INFO, scp, "SCSI host reset error\n"); + shost_printk(KERN_INFO, shost, + "SCSI host reset error\n"); ret = FAILED; break; } diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 1210e61afb18..f38812a1556e 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -916,15 +916,14 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd) aha1542_outb(sh->io_port, CMD_START_SCSI); spin_unlock_irqrestore(sh->host_lock, flags); - scmd_printk(KERN_WARNING, cmd, + sdev_printk(KERN_WARNING, sdev, "Trying device reset for target\n"); return SUCCESS; } -static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) +static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd) { - struct Scsi_Host *sh = cmd->device->host; struct aha1542_hostdata *aha1542 = shost_priv(sh); unsigned long flags; int i; @@ -936,9 +935,9 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) * we do this? Try this first, and we can add that later * if it turns out to be useful. */ - outb(reset_cmd, CONTROL(cmd->device->host->io_port)); + outb(reset_cmd, CONTROL(sh->io_port)); - if (!wait_mask(STATUS(cmd->device->host->io_port), + if (!wait_mask(STATUS(sh->io_port), STATMASK, IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) { spin_unlock_irqrestore(sh->host_lock, flags); return FAILED; @@ -949,7 +948,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) * us again after host reset. */ if (reset_cmd & HRST) - setup_mailboxes(cmd->device->host); + setup_mailboxes(sh); /* * Now try to pick up the pieces. For all pending commands, @@ -957,7 +956,8 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) * out. We do not try and restart any commands or anything - * the strategy handler takes care of that crap. */ - shost_printk(KERN_WARNING, cmd->device->host, "Sent BUS RESET to scsi host %d\n", cmd->device->host->host_no); + shost_printk(KERN_WARNING, sh, "Sent BUS RESET to scsi host %d\n", + sh->host_no); for (i = 0; i < AHA1542_MAILBOXES; i++) { if (aha1542->int_cmds[i] != NULL) { @@ -985,12 +985,12 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) static int aha1542_bus_reset(struct scsi_cmnd *cmd) { - return aha1542_reset(cmd, SCRST); + return aha1542_reset(cmd->device->host, SCRST); } -static int aha1542_host_reset(struct scsi_cmnd *cmd) +static int aha1542_host_reset(struct Scsi_Host *sh) { - return aha1542_reset(cmd, HRST | SCRST); + return aha1542_reset(sh, HRST | SCRST); } static int aha1542_biosparam(struct scsi_device *sdev, diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 84fc7a0c6ff4..6ac554f144c4 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -2687,13 +2687,13 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt) /* * Prototype: int acornscsi_reset(struct scsi_cmnd *SCpnt) * Purpose : reset a command on this host/reset this host - * Params : SCpnt - command causing reset + * Params : shost - host to be reset * Returns : one of SCSI_RESET_ macros */ -int acornscsi_host_reset(struct scsi_cmnd *SCpnt) +int acornscsi_host_reset(struct Scsi_Host *shost) { - AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; - struct scsi_cmnd *SCptr; + AS_Host *host = (AS_Host *)shost->hostdata; + struct scsi_cmnd *SCptr; host->stats.resets += 1; diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 6baa9b36367d..b23e8caad57b 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2656,9 +2656,9 @@ static void fas216_init_chip(FAS216_Info *info) * Returns: FAILED if unable to reset. * Notes: io_request_lock is taken, and irqs are disabled */ -int fas216_eh_host_reset(struct scsi_cmnd *SCpnt) +int fas216_eh_host_reset(struct Scsi_Host *shost) { - FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; + FAS216_Info *info = (FAS216_Info *)shost->hostdata; spin_lock_irq(info->host->host_lock); diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index 847413ce14cf..50e540f5c214 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h @@ -380,11 +380,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt); */ extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt); -/* Function: int fas216_eh_host_reset(struct scsi_cmnd *SCpnt) +/* Function: int fas216_eh_host_reset(struct Scsi_Host *shost) * Purpose : Reset the host associated with this command - * Params : SCpnt - command specifing host to reset + * Params : shost - host to reset * Returns : FAILED if unable to reset */ -extern int fas216_eh_host_reset(struct scsi_cmnd *SCpnt); +extern int fas216_eh_host_reset(struct Scsi_Host *shost); #endif /* FAS216_H */ diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 95d7a3586083..16d664339c6a 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -667,7 +667,7 @@ static void atari_scsi_falcon_reg_write(unsigned int reg, u8 value) #include "NCR5380.c" -static int atari_scsi_host_reset(struct scsi_cmnd *cmd) +static int atari_scsi_host_reset(struct Scsi_Host *shost) { int rv; unsigned long flags; @@ -684,7 +684,7 @@ static int atari_scsi_host_reset(struct scsi_cmnd *cmd) atari_dma_orig_addr = NULL; } - rv = NCR5380_host_reset(cmd); + rv = NCR5380_host_reset(shost); /* The 5380 raises its IRQ line while _RST is active but the ST DMA * "lock" has been released so this interrupt may end up handled by diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 222593bc2afe..b30b8d30f606 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -2498,7 +2498,7 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) /** * cxlflash_eh_host_reset_handler() - reset the host adapter - * @scp: SCSI command from stack identifying host. + * @host: SCSI host adapter. * * Following a reset, the state is evaluated again in case an EEH occurred * during the reset. In such a scenario, the host reset will either yield @@ -2509,11 +2509,10 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) * SUCCESS as defined in scsi/scsi.h * FAILED as defined in scsi/scsi.h */ -static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp) +static int cxlflash_eh_host_reset_handler(struct Scsi_Host *host) { int rc = SUCCESS; int rcr = 0; - struct Scsi_Host *host = scp->device->host; struct cxlflash_cfg *cfg = shost_priv(host); struct device *dev = &cfg->dev->dev; diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index a18a4a08f049..ef38f964fa32 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -747,15 +747,15 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd) } // This version of reset is called by the eh_error_handler -static int __adpt_reset(struct scsi_cmnd* cmd) +static int __adpt_reset(struct Scsi_Host* shost) { adpt_hba* pHba; int rcode; char name[32]; - pHba = (adpt_hba*)cmd->device->host->hostdata[0]; + pHba = (adpt_hba*)shost->hostdata[0]; strncpy(name, pHba->name, sizeof(name)); - printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->channel[cmd->device->channel].tid); + printk(KERN_WARNING"%s: Hba Reset\n", name); rcode = adpt_hba_reset(pHba); if(rcode == 0){ printk(KERN_WARNING"%s: HBA reset complete\n", name); @@ -766,13 +766,13 @@ static int __adpt_reset(struct scsi_cmnd* cmd) } } -static int adpt_reset(struct scsi_cmnd* cmd) +static int adpt_reset(struct Scsi_Host* shost) { int rc; - spin_lock_irq(cmd->device->host->host_lock); - rc = __adpt_reset(cmd); - spin_unlock_irq(cmd->device->host->host_lock); + spin_lock_irq(shost->host_lock); + rc = __adpt_reset(shost); + spin_unlock_irq(shost->host_lock); return rc; } diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h index 8a079e8d7f65..b77a3625fa6f 100644 --- a/drivers/scsi/dpti.h +++ b/drivers/scsi/dpti.h @@ -28,7 +28,7 @@ static int adpt_detect(struct scsi_host_template * sht); static int adpt_queue(struct Scsi_Host *h, struct scsi_cmnd * cmd); static int adpt_abort(struct scsi_cmnd * cmd); -static int adpt_reset(struct scsi_cmnd* cmd); +static int adpt_reset(struct Scsi_Host * host); static int adpt_slave_configure(struct scsi_device *); static const char *adpt_info(struct Scsi_Host *pSHost); diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index ed63f7a9ea54..a104d1a3a9da 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -976,7 +976,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); /* SCSI error handler (eh) functions */ int esas2r_eh_abort(struct scsi_cmnd *cmd); int esas2r_device_reset(struct scsi_cmnd *cmd); -int esas2r_host_reset(struct scsi_cmnd *cmd); +int esas2r_host_reset(struct Scsi_Host *shost); int esas2r_bus_reset(struct scsi_cmnd *cmd); int esas2r_target_reset(struct scsi_cmnd *cmd); diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 647f82898b6e..167163820457 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1059,10 +1059,10 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd) return SUCCESS; } -static int esas2r_host_bus_reset(struct scsi_cmnd *cmd, bool host_reset) +static int esas2r_host_bus_reset(struct Scsi_Host *shost, bool host_reset) { struct esas2r_adapter *a = - (struct esas2r_adapter *)cmd->device->host->hostdata; + (struct esas2r_adapter *)shost->hostdata; if (test_bit(AF_DEGRADED_MODE, &a->flags)) return FAILED; @@ -1087,18 +1087,20 @@ static int esas2r_host_bus_reset(struct scsi_cmnd *cmd, bool host_reset) return SUCCESS; } -int esas2r_host_reset(struct scsi_cmnd *cmd) +int esas2r_host_reset(struct Scsi_Host *shost) { - esas2r_log(ESAS2R_LOG_INFO, "host_reset (%p)", cmd); + esas2r_log(ESAS2R_LOG_INFO, "host_reset (%p)", shost); - return esas2r_host_bus_reset(cmd, true); + return esas2r_host_bus_reset(shost, true); } int esas2r_bus_reset(struct scsi_cmnd *cmd) { - esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", cmd); + struct Scsi_Host *shost = cmd->device->host; + + esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost); - return esas2r_host_bus_reset(cmd, false); + return esas2r_host_bus_reset(shost, false); } static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset) diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 9a8c037a2f21..45c83e3d887d 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2642,9 +2642,9 @@ static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd) } /* All bets are off, reset the entire device. */ -static int esp_eh_host_reset_handler(struct scsi_cmnd *cmd) +static int esp_eh_host_reset_handler(struct Scsi_Host *shost) { - struct esp *esp = shost_priv(cmd->device->host); + struct esp *esp = shost_priv(shost); unsigned long flags; spin_lock_irqsave(esp->host->host_lock, flags); diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c index eda2be534aa7..f0db0e8d0abe 100644 --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c @@ -449,9 +449,8 @@ static int fdomain_abort(struct scsi_cmnd *cmd) return SUCCESS; } -static int fdomain_host_reset(struct scsi_cmnd *cmd) +static int fdomain_host_reset(struct Scsi_Host *sh) { - struct Scsi_Host *sh = cmd->device->host; struct fdomain *fd = shost_priv(sh); unsigned long flags; diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index 69f373b53132..f0b75ac3443e 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -346,7 +346,7 @@ void fnic_update_mac_locked(struct fnic *, u8 *new); int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int fnic_abort_cmd(struct scsi_cmnd *); int fnic_device_reset(struct scsi_cmnd *); -int fnic_host_reset(struct scsi_cmnd *); +int fnic_host_reset(struct Scsi_Host *); int fnic_reset(struct Scsi_Host *); void fnic_scsi_cleanup(struct fc_lport *); void fnic_scsi_abort_io(struct fc_lport *); diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 762cc8bd2653..60af6c7a1bc4 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -2526,11 +2526,10 @@ int fnic_reset(struct Scsi_Host *shost) * host is offlined by SCSI. * */ -int fnic_host_reset(struct scsi_cmnd *sc) +int fnic_host_reset(struct Scsi_Host *shost) { int ret; unsigned long wait_host_tmo; - struct Scsi_Host *shost = sc->device->host; struct fc_lport *lp = shost_priv(shost); struct fnic *fnic = lport_priv(lp); unsigned long flags; diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index 61cda7b7624f..31e2ff02d981 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -1095,12 +1095,12 @@ static int hptiop_reset_hba(struct hptiop_hba *hba) return 0; } -static int hptiop_reset(struct scsi_cmnd *scp) +static int hptiop_reset(struct Scsi_Host *host) { - struct hptiop_hba * hba = (struct hptiop_hba *)scp->device->host->hostdata; + struct hptiop_hba * hba = (struct hptiop_hba *)host->hostdata; printk(KERN_WARNING "hptiop_reset(%d/%d/%d)\n", - scp->device->host->host_no, -1, -1); + host->host_no, -1, -1); return hptiop_reset_hba(hba)? FAILED : SUCCESS; } diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index bee1bec49c09..0a946aad66e5 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2962,10 +2962,10 @@ static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd) * @cmd: struct scsi_cmnd having problems * **/ -static int ibmvfc_eh_host_reset_handler(struct scsi_cmnd *cmd) +static int ibmvfc_eh_host_reset_handler(struct Scsi_Host *shost) { int rc; - struct ibmvfc_host *vhost = shost_priv(cmd->device->host); + struct ibmvfc_host *vhost = shost_priv(shost); dev_err(vhost->dev, "Resetting connection due to error recovery\n"); rc = ibmvfc_issue_fc_host_lip(vhost->host); diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index e6a3eaaa57d9..cce79ffe4644 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -1734,10 +1734,10 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) * ibmvscsi_eh_host_reset_handler - Reset the connection to the server * @cmd: struct scsi_cmnd having problems */ -static int ibmvscsi_eh_host_reset_handler(struct scsi_cmnd *cmd) +static int ibmvscsi_eh_host_reset_handler(struct Scsi_Host *shost) { unsigned long wait_switch = 0; - struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); + struct ibmvscsi_host_data *hostdata = shost_priv(shost); dev_err(hostdata->dev, "Resetting connection due to error recovery\n"); diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c index 943c9102a7eb..07090ad093ce 100644 --- a/drivers/scsi/imm.c +++ b/drivers/scsi/imm.c @@ -985,11 +985,11 @@ static void imm_reset_pulse(unsigned int base) w_ctr(base, 0x04); } -static int imm_reset(struct scsi_cmnd *cmd) +static int imm_reset(struct Scsi_Host *shost) { - imm_struct *dev = imm_dev(cmd->device->host); + imm_struct *dev = imm_dev(shost); - if (cmd->SCp.phase) + if (dev->cur_cmd->SCp.phase) imm_disconnect(dev); dev->cur_cmd = NULL; /* Forget the problem */ diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 5d78f7e939a3..fd25378616b9 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -5177,14 +5177,14 @@ static int ipr_wait_for_ops(struct ipr_ioa_cfg *ioa_cfg, void *device, return SUCCESS; } -static int ipr_eh_host_reset(struct scsi_cmnd *cmd) +static int ipr_eh_host_reset(struct Scsi_Host *shost) { struct ipr_ioa_cfg *ioa_cfg; unsigned long lock_flags = 0; int rc = SUCCESS; ENTER; - ioa_cfg = (struct ipr_ioa_cfg *) cmd->device->host->hostdata; + ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata; spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); if (!ioa_cfg->in_reset_reload && !ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead) { diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 3760bcfc40d1..b791e1e5126e 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -225,7 +225,7 @@ module_param(ips, charp, 0); * Function prototypes */ static int ips_eh_abort(struct scsi_cmnd *); -static int ips_eh_reset(struct scsi_cmnd *); +static int ips_eh_reset(struct Scsi_Host *); static int ips_queue(struct Scsi_Host *, struct scsi_cmnd *); static const char *ips_info(struct Scsi_Host *); static irqreturn_t do_ipsintr(int, void *); @@ -829,7 +829,7 @@ int ips_eh_abort(struct scsi_cmnd *SC) /* NOTE: this routine is called under the io_request_lock spinlock */ /* */ /****************************************************************************/ -static int __ips_eh_reset(struct scsi_cmnd *SC) +static int __ips_eh_reset(struct Scsi_Host *shost) { int ret; int i; @@ -842,13 +842,7 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) return (FAILED); #else - if (!SC) { - DEBUG(1, "Reset called with NULL scsi command"); - - return (FAILED); - } - - ha = (ips_ha_t *) SC->device->host->hostdata; + ha = (ips_ha_t *) shost->hostdata; if (!ha) { DEBUG(1, "Reset called with NULL ha struct"); @@ -994,13 +988,13 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) } -static int ips_eh_reset(struct scsi_cmnd *SC) +static int ips_eh_reset(struct Scsi_Host *shost) { int rc; - spin_lock_irq(SC->device->host->host_lock); - rc = __ips_eh_reset(SC); - spin_unlock_irq(SC->device->host->host_lock); + spin_lock_irq(shost->host_lock); + rc = __ips_eh_reset(shost); + spin_unlock_irq(shost->host_lock); return rc; } @@ -1079,7 +1073,7 @@ static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *) return (0); } ha->ioctl_reset = 1; /* This reset request is from an IOCTL */ - __ips_eh_reset(SC); + __ips_eh_reset(SC->device->host); SC->result = DID_OK << 16; SC->scsi_done(SC); return (0); diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index 509eacd7893d..81e1882efaf0 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -2199,11 +2199,10 @@ EXPORT_SYMBOL(fc_eh_device_reset); /** * fc_eh_host_reset() - Reset a Scsi_Host. - * @sc_cmd: The SCSI command that identifies the SCSI host to be reset + * @shost: The SCSI host to be reset */ -int fc_eh_host_reset(struct scsi_cmnd *sc_cmd) +int fc_eh_host_reset(struct Scsi_Host *shost) { - struct Scsi_Host *shost = sc_cmd->device->host; struct fc_lport *lport = shost_priv(shost); unsigned long wait_tmo; diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 48b932608ffb..d68c08af5514 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6384,9 +6384,8 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) * 0x2002 - Success **/ static int -lpfc_host_reset_handler(struct scsi_cmnd *cmnd) +lpfc_host_reset_handler(struct Scsi_Host *shost) { - struct Scsi_Host *shost = cmnd->device->host; struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_hba *phba = vport->phba; int rc, ret = SUCCESS; diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index ec9840d322e5..8c6a1beca308 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c @@ -102,14 +102,14 @@ static int mac53c94_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cm static DEF_SCSI_QCMD(mac53c94_queue) -static int mac53c94_host_reset(struct scsi_cmnd *cmd) +static int mac53c94_host_reset(struct Scsi_Host *shost) { - struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata; + struct fsc_state *state = (struct fsc_state *) shost->hostdata; struct mac53c94_regs __iomem *regs = state->regs; struct dbdma_regs __iomem *dma = state->dma; unsigned long flags; - spin_lock_irqsave(cmd->device->host->host_lock, flags); + spin_lock_irqsave(shost->host_lock, flags); writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control); writeb(CMD_SCSI_RESET, ®s->command); /* assert RST */ @@ -119,7 +119,7 @@ static int mac53c94_host_reset(struct scsi_cmnd *cmd) mac53c94_init(state); writeb(CMD_NOP, ®s->command); - spin_unlock_irqrestore(cmd->device->host->host_lock, flags); + spin_unlock_irqrestore(shost->host_lock, flags); return SUCCESS; } diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 7c53933fb1b4..fed27cf03e79 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1883,13 +1883,13 @@ megaraid_abort(struct scsi_cmnd *cmd) static int -megaraid_reset(struct scsi_cmnd *cmd) +megaraid_reset(struct Scsi_Host *shost) { adapter_t *adapter; megacmd_t mc; int rval; - adapter = (adapter_t *)cmd->device->host->hostdata; + adapter = (adapter_t *)shost->hostdata; #if MEGA_HAVE_CLUSTERING mc.cmd = MEGA_CLUSTER_CMD; diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h index cce23a086fbe..3385609f1454 100644 --- a/drivers/scsi/megaraid.h +++ b/drivers/scsi/megaraid.h @@ -952,7 +952,7 @@ static irqreturn_t megaraid_isr_iomapped(int, void *); static void mega_free_scb(adapter_t *, scb_t *); static int megaraid_abort(struct scsi_cmnd *); -static int megaraid_reset(struct scsi_cmnd *); +static int megaraid_reset(struct Scsi_Host *); static int megaraid_abort_and_reset(adapter_t *, struct scsi_cmnd *, int); static int megaraid_biosparam(struct scsi_device *, struct block_device *, sector_t, int []); diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index d20c2e4ee793..ef812d6feaa1 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -92,7 +92,7 @@ static int megaraid_sysfs_alloc_resources(adapter_t *); static void megaraid_sysfs_free_resources(adapter_t *); static int megaraid_abort_handler(struct scsi_cmnd *); -static int megaraid_reset_handler(struct scsi_cmnd *); +static int megaraid_reset_handler(struct Scsi_Host *); static int mbox_post_sync_cmd(adapter_t *, uint8_t []); static int mbox_post_sync_cmd_fast(adapter_t *, uint8_t []); @@ -2511,7 +2511,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp) * host. **/ static int -megaraid_reset_handler(struct scsi_cmnd *scp) +megaraid_reset_handler(struct Scsi_Host *shost) { adapter_t *adapter; scb_t *scb; @@ -2524,7 +2524,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp) int i; uioc_t *kioc; - adapter = SCP2ADAPTER(scp); + adapter = (adapter_t *)SCSIHOST2ADAP(shost); raid_dev = ADAP2RAIDDEV(adapter); // return failure if adapter is not responding @@ -2555,15 +2555,9 @@ megaraid_reset_handler(struct scsi_cmnd *scp) megaraid_mbox_mm_done(adapter, scb); } else { - if (scb->scp == scp) { // Found command - con_log(CL_ANN, (KERN_WARNING - "megaraid: %d[%d:%d], reset from pending list\n", - scb->sno, scb->dev_channel, scb->dev_target)); - } else { - con_log(CL_ANN, (KERN_WARNING + con_log(CL_ANN, (KERN_WARNING "megaraid: IO packet with %d[%d:%d] being reset\n", scb->sno, scb->dev_channel, scb->dev_target)); - } scb->scp->result = (DID_RESET << 16); scb->scp->scsi_done(scb->scp); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index ec10b2497310..618a5488c4d6 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -2889,15 +2889,14 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) * reset requests. Device, bus and host specific reset handlers can use this * function after they do their specific tasks. */ -static int megasas_generic_reset(struct scsi_cmnd *scmd) +static int megasas_generic_reset(struct Scsi_Host *shost) { int ret_val; struct megasas_instance *instance; - instance = (struct megasas_instance *)scmd->device->host->hostdata; + instance = (struct megasas_instance *)shost->hostdata; - scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n", - scmd->cmnd[0], scmd->retries); + shost_printk(KERN_NOTICE, shost, "megasas: RESET\n"); if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n"); @@ -3051,31 +3050,30 @@ megasas_dump_sys_regs(void __iomem *reg_set, char *buf) * megasas_reset_bus_host - Bus & host reset handler entry point * @scmd: Mid-layer SCSI command */ -static int megasas_reset_bus_host(struct scsi_cmnd *scmd) +static int megasas_reset_bus_host(struct Scsi_Host *shost) { int ret; struct megasas_instance *instance; - instance = (struct megasas_instance *)scmd->device->host->hostdata; + instance = (struct megasas_instance *)shost->hostdata; - scmd_printk(KERN_INFO, scmd, + shost_printk(KERN_INFO, shost, "OCR is requested due to IO timeout!!\n"); - scmd_printk(KERN_INFO, scmd, - "SCSI host state: %d SCSI host busy: %d FW outstanding: %d\n", - scmd->device->host->shost_state, - scsi_host_busy(scmd->device->host), + shost_printk(KERN_INFO, shost, + "Controller reset is requested due to IO timeout\n" + "SCSI host state: %d\t" + " SCSI host busy: %d\t FW outstanding: %d\n", + shost->shost_state, + scsi_host_busy(shost), atomic_read(&instance->fw_outstanding)); /* * First wait for all commands to complete */ - if (instance->adapter_type == MFI_SERIES) { - ret = megasas_generic_reset(scmd); - } else { - megasas_dump_fusion_io(scmd); - ret = megasas_reset_fusion(scmd->device->host, - SCSIIO_TIMEOUT_OCR); - } + if (instance->adapter_type == MFI_SERIES) + ret = megasas_generic_reset(shost); + else + ret = megasas_reset_fusion(shost, SCSIIO_TIMEOUT_OCR); return ret; } diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 78b72bcf58fe..838e3f38acd6 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c @@ -1705,9 +1705,9 @@ static int mesh_abort(struct scsi_cmnd *cmd) * The midlayer will wait for devices to come back, we don't need * to do that ourselves */ -static int mesh_host_reset(struct scsi_cmnd *cmd) +static int mesh_host_reset(struct Scsi_Host *shost) { - struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata; + struct mesh_state *ms = (struct mesh_state *) shost->hostdata; volatile struct mesh_regs __iomem *mr = ms->mesh; volatile struct dbdma_regs __iomem *md = ms->dma; unsigned long flags; @@ -1724,7 +1724,7 @@ static int mesh_host_reset(struct scsi_cmnd *cmd) out_8(&mr->exception, 0xff); /* clear all exception bits */ out_8(&mr->error, 0xff); /* clear all error bits */ out_8(&mr->sequence, SEQ_RESETMESH); - mesh_flush_io(mr); + mesh_flush_io(mr); udelay(1); out_8(&mr->intr_mask, INT_ERROR | INT_EXCEPTION | INT_CMDDONE); out_8(&mr->source_id, ms->host->this_id); @@ -1733,13 +1733,13 @@ static int mesh_host_reset(struct scsi_cmnd *cmd) /* Reset the bus */ out_8(&mr->bus_status1, BS1_RST); /* assert RST */ - mesh_flush_io(mr); + mesh_flush_io(mr); udelay(30); /* leave it on for >= 25us */ out_8(&mr->bus_status1, 0); /* negate RST */ /* Complete pending commands */ handle_reset(ms); - + spin_unlock_irqrestore(ms->host->host_lock, flags); return SUCCESS; } diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 456a24317bb5..3720f88ebc68 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2877,15 +2877,15 @@ void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout) /** * mpi3mr_eh_host_reset - Host reset error handling callback - * @scmd: SCSI command reference + * @shost: SCSI host reference * * Issue controller reset * * Return: SUCCESS of successful reset else FAILED */ -static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd) +static int mpi3mr_eh_host_reset(struct Scsi_Host *shost) { - struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); + struct mpi3mr_ioc *mrioc = shost_priv(shost); int retval = FAILED, ret; ret = mpi3mr_soft_reset_handler(mrioc, @@ -2895,9 +2895,9 @@ static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd) retval = SUCCESS; out: - sdev_printk(KERN_INFO, scmd->device, - "Host reset is %s for scmd(%p)\n", - ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + shost_printk(KERN_INFO, shost, + "Host reset is %s\n", + ((retval == SUCCESS) ? "SUCCESS" : "FAILED")); return retval; } diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 866d118f7931..eea67589d787 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3525,13 +3525,12 @@ scsih_target_reset(struct scsi_cmnd *scmd) * Return: SUCCESS if command aborted else FAILED */ static int -scsih_host_reset(struct scsi_cmnd *scmd) +scsih_host_reset(struct Scsi_Host *shost) { - struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); int r, retval; - ioc_info(ioc, "attempting host reset! scmd(0x%p)\n", scmd); - scsi_print_command(scmd); + ioc_info(ioc, "attempting host reset\n"); if (ioc->is_driver_loading || ioc->remove_host) { ioc_info(ioc, "Blocking the host reset\n"); @@ -3542,8 +3541,8 @@ scsih_host_reset(struct scsi_cmnd *scmd) retval = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); r = (retval < 0) ? FAILED : SUCCESS; out: - ioc_info(ioc, "host reset: %s scmd(0x%p)\n", - r == SUCCESS ? "SUCCESS" : "FAILED", scmd); + ioc_info(ioc, "host reset: %s\n", + r == SUCCESS ? "SUCCESS" : "FAILED"); return r; } diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 6bb03d7a254d..c89cfc035500 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -695,14 +695,13 @@ static int mvumi_reset_host_9143(struct mvumi_hba *mhba) return mvumi_wait_for_outstanding(mhba); } -static int mvumi_host_reset(struct scsi_cmnd *scmd) +static int mvumi_host_reset(struct Scsi_Host *shost) { struct mvumi_hba *mhba; - mhba = (struct mvumi_hba *) scmd->device->host->hostdata; + mhba = (struct mvumi_hba *) shost->hostdata; - scmd_printk(KERN_NOTICE, scmd, "RESET -%u cmd=%x retries=%x\n", - scmd->request->tag, scmd->cmnd[0], scmd->retries); + shost_printk(KERN_NOTICE, shost, "RESET\n"); return mhba->instancet->reset_host(mhba); } diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c index 542ed88ef90d..aa893aa5c6ac 100644 --- a/drivers/scsi/myrb.c +++ b/drivers/scsi/myrb.c @@ -1251,9 +1251,8 @@ static void myrb_cleanup(struct myrb_hba *cb) scsi_host_put(cb->host); } -static int myrb_host_reset(struct scsi_cmnd *scmd) +static int myrb_host_reset(struct Scsi_Host *shost) { - struct Scsi_Host *shost = scmd->device->host; struct myrb_hba *cb = shost_priv(shost); cb->reset(cb->io_base); diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c index 26326af23dbc..42aa8b78bc22 100644 --- a/drivers/scsi/myrs.c +++ b/drivers/scsi/myrs.c @@ -1527,9 +1527,8 @@ static struct device_attribute *myrs_shost_attrs[] = { /* * SCSI midlayer interface */ -static int myrs_host_reset(struct scsi_cmnd *scmd) +static int myrs_host_reset(struct Scsi_Host *shost) { - struct Scsi_Host *shost = scmd->device->host; struct myrs_hba *cs = shost_priv(shost); cs->reset(cs->io_base); diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index bc9d29e5fdba..2740f0821bc1 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -191,7 +191,7 @@ static int nsp32_release (struct Scsi_Host *); /* SCSI error handler */ static int nsp32_eh_abort (struct scsi_cmnd *); -static int nsp32_eh_host_reset(struct scsi_cmnd *); +static int nsp32_eh_host_reset(struct Scsi_Host *); /* generate SCSI message */ static void nsp32_build_identify(struct scsi_cmnd *); @@ -2883,23 +2883,21 @@ static void nsp32_do_bus_reset(nsp32_hw_data *data) data->CurrentSC = NULL; } -static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt) +static int nsp32_eh_host_reset(struct Scsi_Host *host) { - struct Scsi_Host *host = SCpnt->device->host; - unsigned int base = SCpnt->device->host->io_port; + unsigned int base = host->io_port; nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; nsp32_msg(KERN_INFO, "Host Reset"); - nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); - spin_lock_irq(SCpnt->device->host->host_lock); + spin_lock_irq(host->host_lock); nsp32hw_init(data); nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); nsp32_do_bus_reset(data); nsp32_write2(base, IRQ_CONTROL, 0); - spin_unlock_irq(SCpnt->device->host->host_lock); + spin_unlock_irq(host->host_lock); return SUCCESS; /* Host reset is succeeded at any time. */ } diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 7c0f931e55e8..04b3d52e3547 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -1482,9 +1482,9 @@ static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt) return nsp_bus_reset(data); } -static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt) +static int nsp_eh_host_reset(struct Scsi_Host *host) { - nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; + nsp_hw_data *data = (nsp_hw_data *)host->hostdata; nsp_dbg(NSP_DEBUG_BUSRESET, "in"); diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 665bf8d0faf7..fe1e598e1746 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -300,7 +300,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt); /*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/ /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/ static int nsp_eh_bus_reset (struct scsi_cmnd *SCpnt); -static int nsp_eh_host_reset (struct scsi_cmnd *SCpnt); +static int nsp_eh_host_reset (struct Scsi_Host *host); static int nsp_bus_reset (nsp_hw_data *data); /* */ diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 828d53faf09a..c03568d4d53d 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -267,8 +267,8 @@ static int qlogic_resume(struct pcmcia_device *link) outb(0x24, link->resource[0]->start + 0x9); outb(0x04, link->resource[0]->start + 0xd); } - /* Ugggglllyyyy!!! */ - qlogicfas408_host_reset(NULL); + + qlogicfas408_host_reset(info->host); return 0; } diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index a366ff1a3959..df58a3d8c83e 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -577,14 +577,14 @@ SYM53C500_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) static DEF_SCSI_QCMD(SYM53C500_queue) static int -SYM53C500_host_reset(struct scsi_cmnd *SCpnt) +SYM53C500_host_reset(struct Scsi_Host *shost) { - int port_base = SCpnt->device->host->io_port; + int port_base = shost->io_port; DEB(printk("SYM53C500_host_reset called\n")); - spin_lock_irq(SCpnt->device->host->host_lock); + spin_lock_irq(shost->host_lock); SYM53C500_int_host_reset(port_base); - spin_unlock_irq(SCpnt->device->host->host_lock); + spin_unlock_irq(shost->host_lock); return SUCCESS; } diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index bffd9a9349e7..f9cd69889fe7 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3044,19 +3044,19 @@ static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) /** * pmcraid_eh_host_reset_handler - adapter reset handler callback * - * @scmd: pointer to scsi_cmd that was sent to a resource of adapter + * @shost: pointer to scsi_host * * Initiates adapter reset to bring it up to operational state * * Return value * SUCCESS or FAILED */ -static int pmcraid_eh_host_reset_handler(struct scsi_cmnd *scmd) +static int pmcraid_eh_host_reset_handler(struct Scsi_Host *shost) { unsigned long interval = 10000; /* 10 seconds interval */ int waits = jiffies_to_msecs(PMCRAID_RESET_HOST_TIMEOUT) / interval; struct pmcraid_instance *pinstance = - (struct pmcraid_instance *)(scmd->device->host->hostdata); + (struct pmcraid_instance *)(shost->hostdata); /* wait for an additional 150 seconds just in case firmware could come diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index 977315fdc254..4eb9ea23b329 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -859,11 +859,11 @@ static void ppa_reset_pulse(unsigned int base) w_ctr(base, 0xc); } -static int ppa_reset(struct scsi_cmnd *cmd) +static int ppa_reset(struct Scsi_Host *shost) { - ppa_struct *dev = ppa_dev(cmd->device->host); + ppa_struct *dev = ppa_dev(shost); - if (cmd->SCp.phase) + if (dev->cur_cmd->SCp.phase) ppa_disconnect(dev); dev->cur_cmd = NULL; /* Forget the problem */ diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 85f41abcb56c..38be2e2274a8 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -951,12 +951,12 @@ void qedf_ctx_soft_reset(struct fc_lport *lport) } /* Reset the host by gracefully logging out and then logging back in */ -static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd) +static int qedf_eh_host_reset(struct Scsi_Host *shost) { struct fc_lport *lport; struct qedf_ctx *qedf; - lport = shost_priv(sc_cmd->device->host); + lport = shost_priv(shost); qedf = lport_priv(lport); if (atomic_read(&qedf->link_state) == QEDF_LINK_DOWN || diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 97f83760da88..29f06252c962 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -30,9 +30,8 @@ int qedi_recover_all_conns(struct qedi_ctx *qedi) return SUCCESS; } -static int qedi_eh_host_reset(struct scsi_cmnd *cmd) +static int qedi_eh_host_reset(struct Scsi_Host *shost) { - struct Scsi_Host *shost = cmd->device->host; struct qedi_ctx *qedi; qedi = iscsi_host_priv(shost); diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 3361e24a1b62..dd69bfa85f04 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1005,10 +1005,9 @@ qla1280_eh_bus_reset(struct scsi_cmnd *cmd) * Reset the specified adapter (both channels) **************************************************************************/ static int -qla1280_eh_adapter_reset(struct scsi_cmnd *cmd) +qla1280_eh_adapter_reset(struct Scsi_Host *shost) { int rc; - struct Scsi_Host *shost = cmd->device->host; struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata; spin_lock_irq(shost->host_lock); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 868037c7d608..97568af82750 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1565,8 +1565,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) * The reset function will reset the Adapter. * * Input: -* cmd = Linux SCSI command packet of the command that cause the -* adapter reset. +* shost = Linux SCSI host to be reset * * Returns: * Either SUCCESS or FAILED. @@ -1574,13 +1573,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) * Note: **************************************************************************/ static int -qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_host_reset(struct Scsi_Host *shost) { - scsi_qla_host_t *vha = shost_priv(cmd->device->host); + scsi_qla_host_t *vha = shost_priv(shost); struct qla_hw_data *ha = vha->hw; int ret = FAILED; - unsigned int id; - uint64_t lun; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); if (qla2x00_isp_reg_stat(ha)) { @@ -1590,11 +1587,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) return SUCCESS; } - id = cmd->device->id; - lun = cmd->device->lun; - ql_log(ql_log_info, vha, 0x8018, - "ADAPTER RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun); + "ADAPTER RESET ISSUED host=%ld.\n", vha->host_no); /* * No point in issuing another reset if one is active. Also do not @@ -1640,8 +1634,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) eh_host_reset_lock: ql_log(ql_log_info, vha, 0x8017, - "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", - (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); + "ADAPTER RESET %s host=%ld.\n", + (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no); return ret; } diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 3f7737386193..f4b046867627 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -159,7 +159,7 @@ static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); static int qla4xxx_eh_abort(struct scsi_cmnd *cmd); static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd); static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd); -static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd); +static int qla4xxx_eh_host_reset(struct Scsi_Host *shost); static int qla4xxx_slave_alloc(struct scsi_device *device); static umode_t qla4_attr_is_visible(int param_type, int param); static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type); @@ -9403,18 +9403,18 @@ static int qla4xxx_is_eh_active(struct Scsi_Host *shost) /** * qla4xxx_eh_host_reset - kernel callback - * @cmd: Pointer to Linux's SCSI command structure + * @host: Pointer to Linux's SCSI host structure * * This routine is invoked by the Linux kernel to perform fatal error * recovery on the specified adapter. **/ -static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd) +static int qla4xxx_eh_host_reset(struct Scsi_Host *host) { int return_status = FAILED; struct scsi_qla_host *ha; int rval; - ha = to_qla_host(cmd->device->host); + ha = to_qla_host(host); rval = qla4xxx_isp_check_reg(ha); if (rval != QLA_SUCCESS) { @@ -9436,20 +9436,18 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd) ha->host_no, __func__)); /* Clear outstanding srb in queues */ - if (qla4xxx_is_eh_active(cmd->device->host)) + if (qla4xxx_is_eh_active(host)) qla4xxx_abort_active_cmds(ha, DID_ABORT << 16); return FAILED; } ql4_printk(KERN_INFO, ha, - "scsi(%ld:%d:%d:%llu): HOST RESET ISSUED.\n", ha->host_no, - cmd->device->channel, cmd->device->id, cmd->device->lun); + "scsi%ld: HOST RESET ISSUED.\n", ha->host_no); if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) { - DEBUG2(printk("scsi%ld:%d: %s: Unable to reset host. Adapter " - "DEAD.\n", ha->host_no, cmd->device->channel, - __func__)); + DEBUG2(printk("scsi%ld: %s: Unable to reset host. Adapter " + "DEAD.\n", ha->host_no, __func__)); return FAILED; } diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index 3bbe0b5545d9..2a9922eb66b7 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -522,20 +522,18 @@ int qlogicfas408_abort(struct scsi_cmnd *cmd) /* * Reset SCSI bus - * FIXME: This function is invoked with cmd = NULL directly by - * the PCMCIA qlogic_stub code. This wants fixing */ -int qlogicfas408_host_reset(struct scsi_cmnd *cmd) +int qlogicfas408_host_reset(struct Scsi_Host *host) { - struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); + struct qlogicfas408_priv *priv = get_priv_by_host(host); unsigned long flags; priv->qabort = 2; - spin_lock_irqsave(cmd->device->host->host_lock, flags); + spin_lock_irqsave(host->host_lock, flags); ql_zap(priv); - spin_unlock_irqrestore(cmd->device->host->host_lock, flags); + spin_unlock_irqrestore(host->host_lock, flags); return SUCCESS; } diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h index a971db11d293..c1b6e9fea9ce 100644 --- a/drivers/scsi/qlogicfas408.h +++ b/drivers/scsi/qlogicfas408.h @@ -109,7 +109,7 @@ int qlogicfas408_biosparam(struct scsi_device * disk, struct block_device *dev, sector_t capacity, int ip[]); int qlogicfas408_abort(struct scsi_cmnd * cmd); -extern int qlogicfas408_host_reset(struct scsi_cmnd *cmd); +extern int qlogicfas408_host_reset(struct Scsi_Host *host); const char *qlogicfas408_info(struct Scsi_Host *host); int qlogicfas408_get_chip_type(int qbase, int int_type); void qlogicfas408_setup(int qbase, int id, int int_type); diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index d84e218d32cb..683762a1510d 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c @@ -1261,10 +1261,9 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd) return return_status; } -static int qlogicpti_reset(struct scsi_cmnd *Cmnd) +static int qlogicpti_reset(struct Scsi_Host *host) { u_short param[6]; - struct Scsi_Host *host = Cmnd->device->host; struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata; int return_status = SUCCESS; diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 25112b15ab14..884bdaf26e10 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5251,15 +5251,15 @@ static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt) return SUCCESS; } -static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt) +static int scsi_debug_host_reset(struct Scsi_Host *shost) { struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *devip; int k = 0; ++num_host_resets; - if ((SCpnt->device) && (SDEBUG_OPT_ALL_NOISE & sdebug_opts)) - sdev_printk(KERN_INFO, SCpnt->device, "%s\n", __func__); + if (SDEBUG_OPT_ALL_NOISE & sdebug_opts) + shost_printk(KERN_INFO, shost, "%s\n", __func__); spin_lock(&sdebug_host_list_lock); list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) { list_for_each_entry(devip, &sdbg_host->dev_info_list, @@ -5271,7 +5271,7 @@ static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt) spin_unlock(&sdebug_host_list_lock); stop_all_queued(); if (SDEBUG_OPT_RESET_NOISE & sdebug_opts) - sdev_printk(KERN_INFO, SCpnt->device, + shost_printk(KERN_INFO, shost, "%s: %d device(s) found\n", __func__, k); return SUCCESS; } diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 58a252c38992..8218e2976482 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -811,7 +811,7 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) if (!hostt->eh_host_reset_handler) return FAILED; - rtn = hostt->eh_host_reset_handler(scmd); + rtn = hostt->eh_host_reset_handler(host); if (rtn == SUCCESS) { if (!hostt->skip_settle_delay) diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h index f88ecf73f708..72734c6f98f4 100644 --- a/drivers/scsi/snic/snic.h +++ b/drivers/scsi/snic/snic.h @@ -380,8 +380,7 @@ extern struct device_attribute *snic_attrs[]; int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int snic_abort_cmd(struct scsi_cmnd *); int snic_device_reset(struct scsi_cmnd *); -int snic_host_reset(struct scsi_cmnd *); -int snic_reset(struct Scsi_Host *); +int snic_host_reset(struct Scsi_Host *); void snic_shutdown_scsi_cleanup(struct snic *); diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index 1e59d59130d6..e87f61d42586 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -2302,8 +2302,15 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) return ret; } /* end of snic_issue_hba_reset */ +/* + * SCSI Error handling calls driver's eh_host_reset if all prior + * error handling levels return FAILED. + * + * Host Reset is the highest level of error recovery. If this fails, then + * host is offlined by SCSI. + */ int -snic_reset(struct Scsi_Host *shost) +snic_host_reset(struct Scsi_Host *shost) { struct snic *snic = shost_priv(shost); struct scsi_cmnd *sc = NULL; @@ -2368,26 +2375,6 @@ snic_reset(struct Scsi_Host *shost) 0, 0, 0); return ret; -} /* end of snic_reset */ - -/* - * SCSI Error handling calls driver's eh_host_reset if all prior - * error handling levels return FAILED. - * - * Host Reset is the highest level of error recovery. If this fails, then - * host is offlined by SCSI. - */ -int -snic_host_reset(struct scsi_cmnd *sc) -{ - struct Scsi_Host *shost = sc->device->host; - - SNIC_SCSI_DBG(shost, - "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n", - sc, sc->cmnd[0], sc->request, - snic_cmd_tag(sc), CMD_FLAGS(sc)); - - return snic_reset(shost); } /* end of snic_host_reset */ /* diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 491b435273a6..911a49820c18 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -1435,14 +1435,13 @@ static int stex_do_reset(struct st_hba *hba) return -1; } -static int stex_reset(struct scsi_cmnd *cmd) +static int stex_reset(struct Scsi_Host *shost) { struct st_hba *hba; - hba = (struct st_hba *) &cmd->device->host->hostdata[0]; + hba = (struct st_hba *) &shost->hostdata[0]; - shost_printk(KERN_INFO, cmd->device->host, - "resetting host\n"); + shost_printk(KERN_INFO, shost, "resetting host\n"); return stex_do_reset(hba) ? FAILED : SUCCESS; } diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 328bb961c281..391044b17214 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1632,9 +1632,9 @@ static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev, return 0; } -static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) +static int storvsc_host_reset_handler(struct Scsi_Host *shost) { - struct hv_host_device *host_dev = shost_priv(scmnd->device->host); + struct hv_host_device *host_dev = shost_priv(shost); struct hv_device *device = host_dev->dev; struct storvsc_device *stor_device; diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 2042bd132339..85b66286b4be 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -668,9 +668,8 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd) return SCSI_SUCCESS; } -static int sym53c8xx_eh_host_reset_handler(struct scsi_cmnd *cmd) +static int sym53c8xx_eh_host_reset_handler(struct Scsi_Host *shost) { - struct Scsi_Host *shost = cmd->device->host; struct sym_data *sym_data = shost_priv(shost); struct pci_dev *pdev = sym_data->pdev; struct sym_hcb *np = sym_data->ncb; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 6c263e94144b..a5c6c9866c1c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -221,7 +221,7 @@ static struct ufs_dev_fix ufs_fixups[] = { static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba); static void ufshcd_async_scan(void *data, async_cookie_t cookie); static int ufshcd_reset_and_restore(struct ufs_hba *hba); -static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); +static int ufshcd_eh_host_reset_handler(struct Scsi_Host *shost); static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); static void ufshcd_hba_exit(struct ufs_hba *hba); static int ufshcd_clear_ua_wluns(struct ufs_hba *hba); @@ -7161,13 +7161,13 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba) * * Returns SUCCESS/FAILED */ -static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd) +static int ufshcd_eh_host_reset_handler(struct Scsi_Host *shost) { int err = SUCCESS; unsigned long flags; struct ufs_hba *hba; - hba = shost_priv(cmd->device->host); + hba = shost_priv(shost); spin_lock_irqsave(hba->host->host_lock, flags); hba->force_reset = true; diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index ce1ba1b93629..05ef6651506b 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -892,14 +892,13 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter) } } -static int pvscsi_host_reset(struct scsi_cmnd *cmd) +static int pvscsi_host_reset(struct Scsi_Host *host) { - struct Scsi_Host *host = cmd->device->host; struct pvscsi_adapter *adapter = shost_priv(host); unsigned long flags; bool use_msg; - scmd_printk(KERN_INFO, cmd, "SCSI Host reset\n"); + shost_printk(KERN_INFO, host, "SCSI Host reset\n"); spin_lock_irqsave(&adapter->hw_lock, flags); diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index 4468bc45aaa4..1f5db54e560a 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c @@ -1565,13 +1565,11 @@ reset_wd33c93(struct Scsi_Host *instance) } int -wd33c93_host_reset(struct scsi_cmnd * SCpnt) +wd33c93_host_reset(struct Scsi_Host * instance) { - struct Scsi_Host *instance; struct WD33C93_hostdata *hostdata; int i; - instance = SCpnt->device->host; spin_lock_irq(instance->host_lock); hostdata = (struct WD33C93_hostdata *) instance->hostdata; @@ -1596,7 +1594,6 @@ wd33c93_host_reset(struct scsi_cmnd * SCpnt) hostdata->outgoing_len = 0; reset_wd33c93(instance); - SCpnt->result = DID_RESET << 16; enable_irq(instance->irq); spin_unlock_irq(instance->host_lock); return SUCCESS; diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h index 2edec34c5a42..839da1833151 100644 --- a/drivers/scsi/wd33c93.h +++ b/drivers/scsi/wd33c93.h @@ -337,6 +337,6 @@ int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd); void wd33c93_intr (struct Scsi_Host *instance); int wd33c93_show_info(struct seq_file *, struct Scsi_Host *); int wd33c93_write_info(struct Scsi_Host *, char *, int); -int wd33c93_host_reset (struct scsi_cmnd *); +int wd33c93_host_reset (struct Scsi_Host *); #endif /* WD33C93_H */ diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index edc8a139a60d..9485cbf5f946 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -518,9 +518,9 @@ static int wd719x_bus_reset(struct scsi_cmnd *cmd) return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0); } -static int wd719x_host_reset(struct scsi_cmnd *cmd) +static int wd719x_host_reset(struct Scsi_Host *host) { - struct wd719x *wd = shost_priv(cmd->device->host); + struct wd719x *wd = shost_priv(host); struct wd719x_scb *scb, *tmp; unsigned long flags; diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 41f8a72a2a95..fdbcb6576fcd 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -390,11 +390,11 @@ static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd) /* * visorhba_host_reset_handler - Not supported - * @scsicmd: The scsicmd that needs to be aborted + * @shost: The scsi host that needs resetting * * Return: Not supported, return SUCCESS */ -static int visorhba_host_reset_handler(struct scsi_cmnd *scsicmd) +static int visorhba_host_reset_handler(struct Scsi_Host *shost) { /* issue TASK_MGMT_TARGET_RESET for each target on each bus for host */ return SUCCESS; diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 59b02a539963..28c64d281ede 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -341,9 +341,9 @@ static int mts_scsi_abort(struct scsi_cmnd *srb) return FAILED; } -static int mts_scsi_host_reset(struct scsi_cmnd *srb) +static int mts_scsi_host_reset(struct Scsi_Host *shost) { - struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); + struct mts_desc* desc = (struct mts_desc*)(shost->hostdata[0]); int result; MTS_DEBUG_GOT_HERE(); diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index eeb8d689ff6b..673ac345d7a6 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -941,7 +941,7 @@ void fc_fcp_destroy(struct fc_lport *); int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int fc_eh_abort(struct scsi_cmnd *); int fc_eh_device_reset(struct scsi_cmnd *); -int fc_eh_host_reset(struct scsi_cmnd *); +int fc_eh_host_reset(struct Scsi_Host *); int fc_slave_alloc(struct scsi_device *); /* diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 75363707b73f..3b1acf91f4d0 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -142,7 +142,7 @@ struct scsi_host_template { int (* eh_device_reset_handler)(struct scsi_cmnd *); int (* eh_target_reset_handler)(struct scsi_cmnd *); int (* eh_bus_reset_handler)(struct scsi_cmnd *); - int (* eh_host_reset_handler)(struct scsi_cmnd *); + int (* eh_host_reset_handler)(struct Scsi_Host *); /* * Before the mid layer attempts to scan for a new device where none From patchwork Tue Aug 17 09:14:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89CB0C43214 for ; Tue, 17 Aug 2021 09:16:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7175360EE4 for ; Tue, 17 Aug 2021 09:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239505AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33212 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235887AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E28DB21D11; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=ujQEbhbEyOFmVSUF/6U/RIkxngD183+JEHZRjHVBNfo=; b=J95KsGMLSuCaGjNBTKLCDJt8p3s+CZZUQAVRihYD0KXMxP5CLbRYnRDTWuoVtarh/mPAAl Ou+eHqK2GBRaSUrXou15tuWggaTV4pdSnpqqaohynNWM9pw7H8iNxHClIuB6HleWQhNJaI LUJtEandhrf15BATXczpoeJFxNohi54= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=ujQEbhbEyOFmVSUF/6U/RIkxngD183+JEHZRjHVBNfo=; b=VC/Tyl8ufA3QJY3MhtxtTJztO3g//8/PHexMUi1lNEClxxQ3CFpd0hxgrJ6nGdJckm6prC myk0YpKc3+bp7qCw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id DCBAEA3B9F; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id DA963518CE75; Tue, 17 Aug 2021 11:16:41 +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/51] mptfc: simplify mpt_fc_block_error_handler() Date: Tue, 17 Aug 2021 11:14:16 +0200 Message-Id: <20210817091456.73342-12-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of passing the a function we can as well return a status and call the function directly afterwards. Signed-off-by: Hannes Reinecke --- drivers/message/fusion/mptfc.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 572333fadd68..b4215aa7c952 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -183,73 +183,98 @@ static struct fc_function_template mptfc_transport_functions = { }; static int -mptfc_block_error_handler(struct scsi_cmnd *SCpnt, - int (*func)(struct scsi_cmnd *SCpnt), - const char *caller) +mptfc_block_error_handler(struct fc_rport *rport) { MPT_SCSI_HOST *hd; - struct scsi_device *sdev = SCpnt->device; - struct Scsi_Host *shost = sdev->host; - struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); + struct Scsi_Host *shost = rport_to_shost(rport); unsigned long flags; int ready; - MPT_ADAPTER *ioc; + MPT_ADAPTER *ioc; int loops = 40; /* seconds */ - hd = shost_priv(SCpnt->device->host); + hd = shost_priv(shost); ioc = hd->ioc; spin_lock_irqsave(shost->host_lock, flags); while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY || (loops > 0 && ioc->active == 0)) { spin_unlock_irqrestore(shost->host_lock, flags); dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT - "mptfc_block_error_handler.%d: %d:%llu, port status is " - "%x, active flag %d, deferring %s recovery.\n", + "mptfc_block_error_handler.%d: %s, port status is " + "%x, active flag %d, deferring recovery.\n", ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun, - ready, ioc->active, caller)); + dev_name(&rport->dev), ready, ioc->active)); msleep(1000); spin_lock_irqsave(shost->host_lock, flags); loops --; } spin_unlock_irqrestore(shost->host_lock, flags); - if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata - || ioc->active == 0) { + if (ready == DID_NO_CONNECT || ioc->active == 0) { dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT - "%s.%d: %d:%llu, failing recovery, " - "port state %x, active %d, vdevice %p.\n", caller, + "mpt_block_error_handler.%d: %s, failing recovery, " + "port state %x, active %d.\n", ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun, ready, - ioc->active, SCpnt->device->hostdata)); + dev_name(&rport->dev), ready, ioc->active)); return FAILED; } - dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT - "%s.%d: %d:%llu, executing recovery.\n", caller, - ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun)); - return (*func)(SCpnt); + return SUCCESS; } static int mptfc_abort(struct scsi_cmnd *SCpnt) { - return - mptfc_block_error_handler(SCpnt, mptscsih_abort, __func__); + struct Scsi_Host *shost = SCpnt->device->host; + struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); + MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost); + int rtn; + + rtn = mptfc_block_error_handler(rport); + if (rtn == SUCCESS) { + dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT + "%s.%d: %d:%llu, executing recovery.\n", __func__, + hd->ioc->name, shost->host_no, + SCpnt->device->id, SCpnt->device->lun)); + rtn = mptscsih_abort(SCpnt); + } + return rtn; } static int mptfc_dev_reset(struct scsi_cmnd *SCpnt) { - return - mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __func__); + struct Scsi_Host *shost = SCpnt->device->host; + struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); + MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost); + int rtn; + + rtn = mptfc_block_error_handler(rport); + if (rtn == SUCCESS) { + dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT + "%s.%d: %d:%llu, executing recovery.\n", __func__, + hd->ioc->name, shost->host_no, + SCpnt->device->id, SCpnt->device->lun)); + rtn = mptscsih_dev_reset(SCpnt); + } + return rtn; } static int mptfc_bus_reset(struct scsi_cmnd *SCpnt) { - return - mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __func__); + struct Scsi_Host *shost = SCpnt->device->host; + struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); + MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost); + int rtn; + + rtn = mptfc_block_error_handler(rport); + if (rtn == SUCCESS) { + dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT + "%s.%d: %d:%llu, executing recovery.\n", __func__, + hd->ioc->name, shost->host_no, + SCpnt->device->id, SCpnt->device->lun)); + rtn = mptscsih_bus_reset(SCpnt); + } + return rtn; } static void From patchwork Tue Aug 17 09:14:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86A84C4320E for ; Tue, 17 Aug 2021 09:16:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F55B60FD7 for ; Tue, 17 Aug 2021 09:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239551AbhHQJR1 (ORCPT ); Tue, 17 Aug 2021 05:17:27 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47546 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239248AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E8FA320018; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=JCMwj80Z35RUcyzd2OH6eR1knBzfRuU3aCTjlPRqgZs=; b=j/JoaWEPGQ78ssTraHV2e90ZdmAubSoTs59Ix+GQfYHIKR3jHSVc6XmSlpw+DfM4GkrxsK Om6C6eDJXffo63Z4e/qns1w5q4kUyL/TWpsnIkPBcyktYQGUQ3rFGDNB21jVhaRZUai8yV ahyl8IPQ1p8gUz91YBaViQCbq3TMptg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=JCMwj80Z35RUcyzd2OH6eR1knBzfRuU3aCTjlPRqgZs=; b=zD2LEXenjzsX8yLN3TH5A+0F032wbsZGSxM6+UFs39v/DuzirZzWjh0pKJ1Ykf0IyxeszH AENAltmUcwNeMBAg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id E3A7BA3BA0; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id E0D58518CE77; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 12/51] mptfusion: correct definitions for mptscsih_dev_reset() Date: Tue, 17 Aug 2021 11:14:17 +0200 Message-Id: <20210817091456.73342-13-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke mptscsih_dev_reset() is _not_ a device reset, but rather a target reset. Nevertheless it's being used for either purpose. This patch adds a correct implementation for mptscsih_dev_reset(), and renames the original function to mptscsih_target_reset(). Signed-off-by: Hannes Reinecke --- drivers/message/fusion/mptscsih.c | 55 ++++++++++++++++++++++++++++++- drivers/message/fusion/mptscsih.h | 1 + 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 4b994cadb51e..3bf06dfcd4f9 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1794,7 +1794,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** - * mptscsih_dev_reset - Perform a SCSI TARGET_RESET! new_eh variant + * mptscsih_dev_reset - Perform a SCSI LOGICAL_UNIT_RESET! * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to * * (linux scsi_host_template.eh_dev_reset_handler routine) @@ -1809,6 +1809,58 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) VirtDevice *vdevice; MPT_ADAPTER *ioc; + /* If we can't locate our host adapter structure, return FAILED status. + */ + if ((hd = shost_priv(SCpnt->device->host)) == NULL){ + printk(KERN_ERR MYNAM ": lun reset: " + "Can't locate host! (sc=%p)\n", SCpnt); + return FAILED; + } + + ioc = hd->ioc; + printk(MYIOC_s_INFO_FMT "attempting lun reset! (sc=%p)\n", + ioc->name, SCpnt); + scsi_print_command(SCpnt); + + vdevice = SCpnt->device->hostdata; + if (!vdevice || !vdevice->vtarget) { + retval = 0; + goto out; + } + + retval = mptscsih_IssueTaskMgmt(hd, + MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, + vdevice->vtarget->channel, + vdevice->vtarget->id, vdevice->lun, 0, + mptscsih_get_tm_timeout(ioc)); + + out: + printk (MYIOC_s_INFO_FMT "lun reset: %s (sc=%p)\n", + ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); + + if (retval == 0) + return SUCCESS; + else + return FAILED; +} + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/** + * mptscsih_target_reset - Perform a SCSI TARGET_RESET! + * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to + * + * (linux scsi_host_template.eh_target_reset_handler routine) + * + * Returns SUCCESS or FAILED. + **/ +int +mptscsih_target_reset(struct scsi_cmnd * SCpnt) +{ + MPT_SCSI_HOST *hd; + int retval; + VirtDevice *vdevice; + MPT_ADAPTER *ioc; + /* If we can't locate our host adapter structure, return FAILED status. */ if ((hd = shost_priv(SCpnt->device->host)) == NULL){ @@ -3248,6 +3300,7 @@ EXPORT_SYMBOL(mptscsih_slave_destroy); EXPORT_SYMBOL(mptscsih_slave_configure); EXPORT_SYMBOL(mptscsih_abort); EXPORT_SYMBOL(mptscsih_dev_reset); +EXPORT_SYMBOL(mptscsih_target_reset); EXPORT_SYMBOL(mptscsih_bus_reset); EXPORT_SYMBOL(mptscsih_host_reset); EXPORT_SYMBOL(mptscsih_bios_param); diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 6ab82548e49e..50af52a81505 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -120,6 +120,7 @@ extern void mptscsih_slave_destroy(struct scsi_device *device); extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt); +extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt); extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt); extern int mptscsih_host_reset(struct Scsi_Host *sh); extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]); From patchwork Tue Aug 17 09:14:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBB45C4338F for ; Tue, 17 Aug 2021 09:16:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C061960F11 for ; Tue, 17 Aug 2021 09:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239557AbhHQJR2 (ORCPT ); Tue, 17 Aug 2021 05:17:28 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47556 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239274AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id EDD6120019; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191801; 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=mMI9WF+HFWXl9jJ2KVj19iBEZzRMpJs8s0NUgiMZq3I=; b=rV4TPRgR6RyCNqVOlTw66Werf8UU/rarf8JowFr7gUFbEQLkzLU9deVYl+dsPCM+WpCQCw XW5OkW/uD4FVjwtnOhjG9mFfhkczLslQXhQ3dyzjxQt36PqAlUUbDZ228oP2M/GPhQy5WM dChWfcSRVddNe1FSOj/v9TePc657/rA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191801; 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=mMI9WF+HFWXl9jJ2KVj19iBEZzRMpJs8s0NUgiMZq3I=; b=VvmE5YEhkI1n5SdqIxG4wqJ8mZHdXtlPG/DqS3QubrNBx0xWdXECJuRqc9m0sdz+UojZ+A GTzIW2n3FBS1XnCQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id E8570A3BA1; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id E6386518CE79; Tue, 17 Aug 2021 11:16:41 +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 13/51] mptfc: open-code mptfc_block_error_handler() for bus reset Date: Tue, 17 Aug 2021 11:14:18 +0200 Message-Id: <20210817091456.73342-14-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When calling bus_reset we have potentially several ports to be reset, so this patch open-codes the existing mptfc_block_error_handler() to wait for all ports attached to this bus. Signed-off-by: Hannes Reinecke --- drivers/message/fusion/mptfc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index b4215aa7c952..578e762da28d 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -262,12 +262,23 @@ static int mptfc_bus_reset(struct scsi_cmnd *SCpnt) { struct Scsi_Host *shost = SCpnt->device->host; - struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost); + int channel = SCpnt->device->channel; + struct mptfc_rport_info *ri; int rtn; - rtn = mptfc_block_error_handler(rport); - if (rtn == SUCCESS) { + list_for_each_entry(ri, &hd->ioc->fc_rports, list) { + if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { + VirtTarget *vtarget = ri->starget->hostdata; + + if (!vtarget || vtarget->channel != channel) + continue; + rtn = fc_block_rport(ri->rport); + if (rtn != 0) + break; + } + } + if (rtn == 0) { dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT "%s.%d: %d:%llu, executing recovery.\n", __func__, hd->ioc->name, shost->host_no, From patchwork Tue Aug 17 09:14:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D311C43214 for ; Tue, 17 Aug 2021 09:16:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66EA360FA0 for ; Tue, 17 Aug 2021 09:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239573AbhHQJRb (ORCPT ); Tue, 17 Aug 2021 05:17:31 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47558 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234347AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 01C9E2001A; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=2AbeA5ShB3lXtR9kF5FC6uyxPwkXQ0MdHy4poxrqhk0=; b=ccx9zG8nS1oK2H96MUksKbv6GUzL6e+eQdSE3A88uo/M6/yiUBF7vVsJbFRvTeFCMt736y wQ3PHt69qaDBjqTtqGgnG9YC4OFzJGJKZSzEVaVUSDVn9fofbArVVOJ2edeRp+bDPnqYO7 HsvTmt7ziRnxhkiXSarJAsDSVLpanM0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=2AbeA5ShB3lXtR9kF5FC6uyxPwkXQ0MdHy4poxrqhk0=; b=KbUK1V0105gEad1UlvP2M8aKyUKySrx87eMAOdm5RaonriJjsdoauDhXde4bCrFpiY8zpT 7YcbUeo2K9BkkoAw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id EE814A3BA0; Tue, 17 Aug 2021 09:16:41 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id EB7C7518CE7B; Tue, 17 Aug 2021 11:16:41 +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 14/51] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Date: Tue, 17 Aug 2021 11:14:19 +0200 Message-Id: <20210817091456.73342-15-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 f9cd69889fe7..f29107536887 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 Tue Aug 17 09:14:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C046C43216 for ; Tue, 17 Aug 2021 09:16:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CA8660720 for ; Tue, 17 Aug 2021 09:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239523AbhHQJRW (ORCPT ); Tue, 17 Aug 2021 05:17:22 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33236 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235988AbhHQJRP (ORCPT ); Tue, 17 Aug 2021 05:17:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0ADF521D1A; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=0twZ8+gpwMBts+TajsUwzMhyCe/gO42X6KQ2yfFXzV0=; b=dpoMU9DCBagQfgcwnrHRYaqL6VWkA/19ggw/+qNg4DN0V0/Uau51fKGegShSXfSlCaDKk5 OIfyDmzM8i51NK4JDMsAigKI5PkRY3EtvpVNGE72FJTL3B1eiVjgJcHUgBC8ywqF1lvVjo dRfUgDJJSNU/dArQujYoRNVXrktr3r8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=0twZ8+gpwMBts+TajsUwzMhyCe/gO42X6KQ2yfFXzV0=; b=84Vn1BCKxdhdfL+MAAfcINPOt1nZ/2BX0dMUVOtYrfYUJaXpn5iNYhrwQlCT2PIuhp5/pb ewVWCXQEPcBs0BAw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 029EDA3BA2; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id F2864518CE7D; Tue, 17 Aug 2021 11:16:41 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , Nilesh Javali Subject: [PATCH 15/51] qla2xxx: open-code qla2xxx_generic_reset() Date: Tue, 17 Aug 2021 11:14:20 +0200 Message-Id: <20210817091456.73342-16-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Device and target reset will be using different calling sequences, so there's not point in trying to combine both. Signed-off-by: Hannes Reinecke Cc: Nilesh Javali --- drivers/scsi/qla2xxx/qla_os.c | 91 +++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 97568af82750..64820a3d34dd 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1388,13 +1388,20 @@ static char *reset_errors[] = { }; static int -__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, - struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, uint64_t, int)) +qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) { scsi_qla_host_t *vha = shost_priv(cmd->device->host); + struct qla_hw_data *ha = vha->hw; fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; int err; + if (qla2x00_isp_reg_stat(ha)) { + ql_log(ql_log_info, vha, 0x803e, + "PCI/Register disconnect, exiting.\n"); + qla_pci_set_eeh_busy(vha); + return FAILED; + } + if (!fcport) { return FAILED; } @@ -1407,8 +1414,8 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, return SUCCESS; ql_log(ql_log_info, vha, 0x8009, - "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no, - cmd->device->id, cmd->device->lun, cmd); + "DEVICE RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", + vha->host_no, cmd->device->id, cmd->device->lun, cmd); err = 0; if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { @@ -1417,29 +1424,29 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, goto eh_reset_failed; } err = 2; - if (do_reset(fcport, cmd->device->lun, 1) + if (ha->isp_ops->lun_reset(fcport, cmd->device->lun, 1) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800c, - "do_reset failed for cmd=%p.\n", cmd); + "lun_reset failed for cmd=%p.\n", cmd); goto eh_reset_failed; } err = 3; if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, - cmd->device->lun, type) != QLA_SUCCESS) { + cmd->device->lun, WAIT_LUN) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800d, "wait for pending cmds failed for cmd=%p.\n", cmd); goto eh_reset_failed; } ql_log(ql_log_info, vha, 0x800e, - "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, + "DEVICE RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", vha->host_no, cmd->device->id, cmd->device->lun, cmd); return SUCCESS; eh_reset_failed: ql_log(ql_log_info, vha, 0x800f, - "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, + "DEVICE RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, cmd); vha->reset_cmd_err_cnt++; @@ -1447,37 +1454,69 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, } static int -qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) { scsi_qla_host_t *vha = shost_priv(cmd->device->host); + fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; struct qla_hw_data *ha = vha->hw; + int err; if (qla2x00_isp_reg_stat(ha)) { - ql_log(ql_log_info, vha, 0x803e, + ql_log(ql_log_info, vha, 0x803f, "PCI/Register disconnect, exiting.\n"); qla_pci_set_eeh_busy(vha); return FAILED; } - return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, - ha->isp_ops->lun_reset); -} + if (!fcport) { + return FAILED; + } -static int -qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) -{ - scsi_qla_host_t *vha = shost_priv(cmd->device->host); - struct qla_hw_data *ha = vha->hw; + err = fc_block_scsi_eh(cmd); + if (err != 0) + return err; - if (qla2x00_isp_reg_stat(ha)) { - ql_log(ql_log_info, vha, 0x803f, - "PCI/Register disconnect, exiting.\n"); - qla_pci_set_eeh_busy(vha); - return FAILED; + if (fcport->deleted) + return SUCCESS; + + ql_log(ql_log_info, vha, 0x8009, + "TARGET RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", vha->host_no, + cmd->device->id, cmd->device->lun, cmd); + + err = 0; + if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x800a, + "Wait for hba online failed for cmd=%p.\n", cmd); + goto eh_reset_failed; + } + err = 2; + if (ha->isp_ops->target_reset(fcport, cmd->device->lun, 1) + != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x800c, + "target_reset failed for cmd=%p.\n", cmd); + goto eh_reset_failed; } + err = 3; + if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, + cmd->device->lun, WAIT_TARGET) != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x800d, + "wait for pending cmds failed for cmd=%p.\n", cmd); + goto eh_reset_failed; + } + + ql_log(ql_log_info, vha, 0x800e, + "TARGET RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", + vha->host_no, cmd->device->id, cmd->device->lun, cmd); - return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, - ha->isp_ops->target_reset); + return SUCCESS; + +eh_reset_failed: + ql_log(ql_log_info, vha, 0x800f, + "TARGET RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", + reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, + cmd); + vha->reset_cmd_err_cnt++; + return FAILED; } /************************************************************************** From patchwork Tue Aug 17 09:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E37C6C4320A for ; Tue, 17 Aug 2021 09:16:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9F7060F11 for ; Tue, 17 Aug 2021 09:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239538AbhHQJRZ (ORCPT ); Tue, 17 Aug 2021 05:17:25 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33302 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239136AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1092721D1C; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=BRQjIvn88nKilpzDQwexcfZLv6sotDCud9QpMCrTNX8=; b=KzWJQ49YunTF46umJTs2luOAF8YCfr0uobd9AE/305B9VvU0O12IoC6mTShruhzjmaig5a tZX8fJfSFrvbtRUXVmYz7oQ9jOdvV4whjttGkHDGtVaF//WJpZpvHVFNiD3Kk5oZVQkLDF 8hnuKNL2N3LPaN3qaGqKSgndG+jo6to= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=BRQjIvn88nKilpzDQwexcfZLv6sotDCud9QpMCrTNX8=; b=WQs13IA47DBr+QCscJzgLDtcD69B3V5Y+SiRsvPmzecqzFYlUhjUqj5eGRrXxyQx1A2lgZ V7tBwF/psSsdZnCQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 06E49A3BA3; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 03E6F518CE7F; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Nilesh Javali Subject: [PATCH 16/51] qla2xxx: Do not call fc_block_scsi_eh() during bus reset Date: Tue, 17 Aug 2021 11:14:21 +0200 Message-Id: <20210817091456.73342-17-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When calling bus reset the driver will be doing a full SAN resync anyway, so there is no need to wait for any pending RSCNs; they'll be re-issued during resync anyway. Signed-off-by: Hannes Reinecke Cc: Nilesh Javali --- drivers/scsi/qla2xxx/qla_os.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 64820a3d34dd..a84a85288c2e 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1538,7 +1538,6 @@ static int qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) { scsi_qla_host_t *vha = shost_priv(cmd->device->host); - fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; int ret = FAILED; unsigned int id; uint64_t lun; @@ -1554,15 +1553,6 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) id = cmd->device->id; lun = cmd->device->lun; - if (!fcport) { - return ret; - } - - ret = fc_block_scsi_eh(cmd); - if (ret != 0) - return ret; - ret = FAILED; - if (qla2x00_chip_is_down(vha)) return ret; From patchwork Tue Aug 17 09:14:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BA11C432BE for ; Tue, 17 Aug 2021 09:16:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12CED60F11 for ; Tue, 17 Aug 2021 09:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239545AbhHQJR1 (ORCPT ); Tue, 17 Aug 2021 05:17:27 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33304 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239151AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1B08D21D26; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=Oiya3yiIsKryh7s1PYvS4XpqSdNu7+s1gDW8melp4j4=; b=Zixd+C5ejuaDyPVkFqCCBqQfvAQ3CNfGBwGszm3glYqzyARA3BLb5pX4UwjG8BswjtgofT OXSlBx9v0nuPo5PZ4W7Cypu4z5ew4zFfF6/RIhdCEdgazv4VkW2X5LW5veD03L0UFz+Sdd /Ra7atE4UBMoPo1TMKTyhA4y6MMbEIM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=Oiya3yiIsKryh7s1PYvS4XpqSdNu7+s1gDW8melp4j4=; b=teQhy/vWyyCxfv5TaY2HhP5e34kCYjWN3LmShXPQmdCpwQWKJyWBxGiybRGxDTU7H0Z9Az M/btEPutaA/bBKCQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 0E3B3A3BA4; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 09F70518CE81; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , David Kershner Subject: [PATCH 17/51] visorhba: select first device on the bus for bus_reset() Date: Tue, 17 Aug 2021 11:14:22 +0200 Message-Id: <20210817091456.73342-18-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 having the scsi command as an argument to bus_reset() we need to select the first device on the bus to send the bus reset to. Signed-off-by: Hannes Reinecke Cc: David Kershner --- .../staging/unisys/visorhba/visorhba_main.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index fdbcb6576fcd..bfb4a70432f3 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -368,23 +368,24 @@ static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd) */ static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd) { - struct scsi_device *scsidev; + struct scsi_device *scsidev = NULL, *tmp; + struct Scsi_Host *scsihost = scsicmd->device->host; struct visordisk_info *vdisk; - int rtn; + int rtn = SUCCESS; - scsidev = scsicmd->device; - shost_for_each_device(scsidev, scsidev->host) { - vdisk = scsidev->hostdata; + shost_for_each_device(tmp, scsihost) { + if (tmp->channel != scsicmd->device->channel) + continue; + vdisk = tmp->hostdata; if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT) atomic_inc(&vdisk->error_count); else atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD); + if (!scsidev) + scsidev = tmp; } - rtn = forward_taskmgmt_command(TASK_MGMT_BUS_RESET, scsidev); - if (rtn == SUCCESS) { - scsicmd->result = DID_RESET << 16; - scsicmd->scsi_done(scsicmd); - } + if (scsidev) + rtn = forward_taskmgmt_command(TASK_MGMT_BUS_RESET, scsidev); return rtn; } From patchwork Tue Aug 17 09:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F20FC4320A for ; Tue, 17 Aug 2021 09:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C2B760FA0 for ; Tue, 17 Aug 2021 09:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239563AbhHQJRa (ORCPT ); Tue, 17 Aug 2021 05:17:30 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33306 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239267AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1E81921D3B; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=nMCpDwdQuHGWQIUjkeyKrf/jcFqbs6U8/UihLkQVXnA=; b=f1NajFg/1uDBJosVsQXF8kHyqK9HhkxXfBs09itbXFSZwFx3nENsXYoDteKIQDnPEf7sM+ lm0nZlws4psJDo01eRQWOkpAtUCML+ChgIjDevynMDK/UcK/qMQsoZHEE7ltT1nJckS/57 EQrf0m/QKA5kohXsUXg0tf6P7rzLFP4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=nMCpDwdQuHGWQIUjkeyKrf/jcFqbs6U8/UihLkQVXnA=; b=H26uADHFx906L5xMsHp4ud0yeC59UPPMz14CgDRVsFGtAiKAoViCupC0QLbft+jii6Jf8/ C8GH02/CTtX5wHAg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 12E6CA3BA5; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 102CB518CE83; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 18/51] ncr53c8xx: remove 'sync_reset' argument from ncr_reset_bus() Date: Tue, 17 Aug 2021 11:14:23 +0200 Message-Id: <20210817091456.73342-19-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke Always '1', so we can remove it. Signed-off-by: Hannes Reinecke --- drivers/scsi/ncr53c8xx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index c76e9f05d042..3d2daaf2368c 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -4553,7 +4553,7 @@ static void ncr_start_reset(struct ncb *np) ** **========================================================== */ -static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd, int sync_reset) +static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd) { /* struct scsi_device *device = cmd->device; */ struct ccb *cp; @@ -4600,11 +4600,10 @@ static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd, int sync_reset) ncr_wakeup(np, HS_RESET); /* * If the involved command was not in a driver queue, and the - * scsi driver told us reset is synchronous, and the command is not - * currently in the waiting list, complete it with DID_RESET status, - * in order to keep it alive. + * command is not currently in the waiting list, complete it + * with DID_RESET status in order to keep it alive. */ - if (!found && sync_reset && !retrieve_from_waiting_list(0, np, cmd)) { + if (!found && !retrieve_from_waiting_list(0, np, cmd)) { set_host_byte(cmd, DID_RESET); ncr_queue_done_cmd(np, cmd); } @@ -8125,7 +8124,7 @@ static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd) */ spin_lock_irqsave(&np->smp_lock, flags); - sts = ncr_reset_bus(np, cmd, 1); + sts = ncr_reset_bus(np, cmd); done_list = np->done_list; np->done_list = NULL; From patchwork Tue Aug 17 09:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A373FC432BE for ; Tue, 17 Aug 2021 09:17:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E29260FA0 for ; Tue, 17 Aug 2021 09:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239660AbhHQJRh (ORCPT ); Tue, 17 Aug 2021 05:17:37 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47560 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239349AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1F06B2001C; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=8NCxU4/1zd+k2/TeWycg5N5FfmmIoUDYnXA4EHkYlAk=; b=QXqiNd7x6hm7AANfPhB7hgF/gQrBoHWmKSjkzfSj5mKZcicrGlJpLuvoXA90EV04MrXfJS Ii5a5tor8jt+cMiig4gXs8RfpDN63CkhTnmplkhXsTvdbvOkMW9FMcSzYm/F4Ke+z7gQt1 bk21iQX9T2FiynnU00cwv7m0NI7IRWU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=8NCxU4/1zd+k2/TeWycg5N5FfmmIoUDYnXA4EHkYlAk=; b=ywj/hCwMpjNTnhgo6B+anfICcSVaTHc+tkkRYghM1w/Nm1hEmIyC6X7fJ4r7fTB7WxDdtz GzVc8kUznmN+tlAg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 1843FA3BA6; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 15B6C518CE85; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 19/51] ncr53c8xx: Complete all commands during bus reset Date: Tue, 17 Aug 2021 11:14:24 +0200 Message-Id: <20210817091456.73342-20-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke ncr_reset_bus() will complete all outstanding commands anyway, so there's no need to single out a specific command. Signed-off-by: Hannes Reinecke --- drivers/scsi/ncr53c8xx.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 3d2daaf2368c..1c1f5df83dca 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -4553,12 +4553,8 @@ static void ncr_start_reset(struct ncb *np) ** **========================================================== */ -static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd) +static int ncr_reset_bus (struct ncb *np) { -/* struct scsi_device *device = cmd->device; */ - struct ccb *cp; - int found; - /* * Return immediately if reset is in progress. */ @@ -4572,24 +4568,6 @@ static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd) * delay of 2 seconds will be completed. */ ncr_start_reset(np); -/* - * First, look in the wakeup list - */ - for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) { - /* - ** look for the ccb of this command. - */ - if (cp->host_status == HS_IDLE) continue; - if (cp->cmd == cmd) { - found = 1; - break; - } - } -/* - * Then, look in the waiting list - */ - if (!found && retrieve_from_waiting_list(0, np, cmd)) - found = 1; /* * Wake-up all awaiting commands with DID_RESET. */ @@ -4598,15 +4576,6 @@ static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd) * Wake-up all pending commands with HS_RESET -> DID_RESET. */ ncr_wakeup(np, HS_RESET); -/* - * If the involved command was not in a driver queue, and the - * command is not currently in the waiting list, complete it - * with DID_RESET status in order to keep it alive. - */ - if (!found && !retrieve_from_waiting_list(0, np, cmd)) { - set_host_byte(cmd, DID_RESET); - ncr_queue_done_cmd(np, cmd); - } return SUCCESS; } @@ -8124,7 +8093,7 @@ static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd) */ spin_lock_irqsave(&np->smp_lock, flags); - sts = ncr_reset_bus(np, cmd); + sts = ncr_reset_bus(np); done_list = np->done_list; np->done_list = NULL; From patchwork Tue Aug 17 09:14:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E0F7C4338F for ; Tue, 17 Aug 2021 09:17:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0535A60720 for ; Tue, 17 Aug 2021 09:17:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239677AbhHQJRi (ORCPT ); Tue, 17 Aug 2021 05:17:38 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47562 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239350AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 26D442001D; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=PDa4b0uMMZpqGGQWu3VRWsZgnZ7b1VfFjaPKU4/hGIY=; b=Ssa7jyl3v0EoLLfXvGomFVo6jFTgbLZaiW2bImcr9jg7XMx/WZvusXfI055+eQR2Vh9miZ O5GELxcAimrQDngNdvdDKT9E1Mz0UIXT+G+7oLbthXHdDMnXOv1OCjCG++AXPLhZ60o3Er /+DvtfWcxsJlIa60R9C0+zQ1m5X/mkg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=PDa4b0uMMZpqGGQWu3VRWsZgnZ7b1VfFjaPKU4/hGIY=; b=1uUok/TqPve1xnzo6I2L4ryDQ54+aejSE3Gi7NztMT2B7e3ysIxJtGx4yqpg3hYueD9Zt1 pqVPhZebKel+YTAg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 1FB45A3BA7; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 1C84C518CE87; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 20/51] ncr53c8xx: Remove unused code Date: Tue, 17 Aug 2021 11:14:25 +0200 Message-Id: <20210817091456.73342-21-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke Signed-off-by: Hannes Reinecke --- drivers/scsi/ncr53c8xx.c | 163 --------------------------------------- 1 file changed, 163 deletions(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 1c1f5df83dca..e7115cba4b28 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -1453,11 +1453,6 @@ struct head { #define xerr_status phys.xerr_st #define nego_status phys.nego_st -#if 0 -#define sync_status phys.sync_st -#define wide_status phys.wide_st -#endif - /*========================================================== ** ** Declaration of structs: Data structure block @@ -1980,9 +1975,6 @@ static inline char *ncr_name (struct ncb *np) #define RELOC_SOFTC 0x40000000 #define RELOC_LABEL 0x50000000 #define RELOC_REGISTER 0x60000000 -#if 0 -#define RELOC_KVAR 0x70000000 -#endif #define RELOC_LABELH 0x80000000 #define RELOC_MASK 0xf0000000 @@ -1991,21 +1983,7 @@ static inline char *ncr_name (struct ncb *np) #define PADDRH(label) (RELOC_LABELH | offsetof(struct scripth, label)) #define RADDR(label) (RELOC_REGISTER | REG(label)) #define FADDR(label,ofs)(RELOC_REGISTER | ((REG(label))+(ofs))) -#if 0 -#define KVAR(which) (RELOC_KVAR | (which)) -#endif -#if 0 -#define SCRIPT_KVAR_JIFFIES (0) -#define SCRIPT_KVAR_FIRST SCRIPT_KVAR_JIFFIES -#define SCRIPT_KVAR_LAST SCRIPT_KVAR_JIFFIES -/* - * Kernel variables referenced in the scripts. - * THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY. - */ -static void *script_kvars[] __initdata = - { (void *)&jiffies }; -#endif static struct script script0 __initdata = { /*--------------------------< START >-----------------------*/ { @@ -2162,11 +2140,6 @@ static struct script script0 __initdata = { SCR_COPY (1), RADDR (scratcha), NADDR (msgout), -#if 0 - SCR_COPY (1), - RADDR (scratcha), - NADDR (msgin), -#endif /* ** Anticipate the COMMAND phase. ** This is the normal case for initial selection. @@ -4378,10 +4351,6 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd) cp->parity_status = 0; cp->xerr_status = XE_OK; -#if 0 - cp->sync_status = tp->sval; - cp->wide_status = tp->wval; -#endif /*---------------------------------------------------- ** @@ -4580,89 +4549,6 @@ static int ncr_reset_bus (struct ncb *np) return SUCCESS; } -#if 0 /* unused and broken.. */ -/*========================================================== -** -** -** Abort an SCSI command. -** This is called from the generic SCSI driver. -** -** -**========================================================== -*/ -static int ncr_abort_command (struct ncb *np, struct scsi_cmnd *cmd) -{ -/* struct scsi_device *device = cmd->device; */ - struct ccb *cp; - int found; - int retv; - -/* - * First, look for the scsi command in the waiting list - */ - if (remove_from_waiting_list(np, cmd)) { - set_host_byte(cmd, DID_ABORT); - ncr_queue_done_cmd(np, cmd); - return SCSI_ABORT_SUCCESS; - } - -/* - * Then, look in the wakeup list - */ - for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) { - /* - ** look for the ccb of this command. - */ - if (cp->host_status == HS_IDLE) continue; - if (cp->cmd == cmd) { - found = 1; - break; - } - } - - if (!found) { - return SCSI_ABORT_NOT_RUNNING; - } - - if (np->settle_time) { - return SCSI_ABORT_SNOOZE; - } - - /* - ** If the CCB is active, patch schedule jumps for the - ** script to abort the command. - */ - - switch(cp->host_status) { - case HS_BUSY: - case HS_NEGOTIATE: - printk ("%s: abort ccb=%p (cancel)\n", ncr_name (np), cp); - cp->start.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, cancel)); - retv = SCSI_ABORT_PENDING; - break; - case HS_DISCONNECT: - cp->restart.schedule.l_paddr = - cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); - retv = SCSI_ABORT_PENDING; - break; - default: - retv = SCSI_ABORT_NOT_RUNNING; - break; - - } - - /* - ** If there are no requests, the script - ** processor will sleep on SEL_WAIT_RESEL. - ** Let's wake it up, since it may have to work. - */ - OUTB (nc_istat, SIGP); - - return retv; -} -#endif - static void ncr_detach(struct ncb *np) { struct ccb *cp; @@ -5421,27 +5307,6 @@ static void ncr_getsync(struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl */ fak = (kpc - 1) / div_10M[div] + 1; -#if 0 /* This optimization does not seem very useful */ - - per = (fak * div_10M[div]) / clk; - - /* - ** Why not to try the immediate lower divisor and to choose - ** the one that allows the fastest output speed ? - ** We don't want input speed too much greater than output speed. - */ - if (div >= 1 && fak < 8) { - u_long fak2, per2; - fak2 = (kpc - 1) / div_10M[div-1] + 1; - per2 = (fak2 * div_10M[div-1]) / clk; - if (per2 < per && fak2 <= 8) { - fak = fak2; - per = per2; - --div; - } - } -#endif - if (fak < 4) fak = 4; /* Should never happen, too bad ... */ /* @@ -5479,10 +5344,6 @@ static void ncr_set_sync_wide_status (struct ncb *np, u_char target) for (cp = np->ccb; cp; cp = cp->link_ccb) { if (!cp->cmd) continue; if (scmd_id(cp->cmd) != target) continue; -#if 0 - cp->sync_status = tp->sval; - cp->wide_status = tp->wval; -#endif cp->phys.select.sel_scntl3 = tp->wval; cp->phys.select.sel_sxfer = tp->sval; } @@ -8104,30 +7965,6 @@ static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd) return sts; } -#if 0 /* unused and broken */ -static int ncr53c8xx_abort(struct scsi_cmnd *cmd) -{ - struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; - int sts; - unsigned long flags; - struct scsi_cmnd *done_list; - - printk("ncr53c8xx_abort\n"); - - NCR_LOCK_NCB(np, flags); - - sts = ncr_abort_command(np, cmd); -out: - done_list = np->done_list; - np->done_list = NULL; - NCR_UNLOCK_NCB(np, flags); - - ncr_flush_done_cmds(done_list); - - return sts; -} -#endif - /* ** Scsi command waiting list management. From patchwork Tue Aug 17 09:14:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61028C4320A for ; Tue, 17 Aug 2021 09:17:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E5DF60F11 for ; Tue, 17 Aug 2021 09:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239719AbhHQJRn (ORCPT ); Tue, 17 Aug 2021 05:17:43 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47568 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239369AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 30E0E2001E; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=UJb1IBWuSk2r7ui782/pWNT3C8FG0uroxhhZllr4sPw=; b=uW18VO8VoS3OpLcOIeXvqvIv8Kfhk7RHpVcEQDC1eRWiF/pR14njMbmzVLDaQmIBVI55xU wl5dtU6gdDmMXTAce4EDGzCO+MWLaUqt9pTHRs2dcT36oziaLn2VFq+w6QAfwaMI4S1/60 E4nIGJaajRpoZ1RWeCBVbfGaAITZa7s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=UJb1IBWuSk2r7ui782/pWNT3C8FG0uroxhhZllr4sPw=; b=jallY+OYiLXLed9a/AVjSQ751Ca3dfsN0mYBltQw6re0LS0VxHJbTtro0rj+kaUQdrtDlU damR+bQHSVbWwXCA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 29B64A3BA5; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 256D5518CE89; Tue, 17 Aug 2021 11:16:42 +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 21/51] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Date: Tue, 17 Aug 2021 11:14:26 +0200 Message-Id: <20210817091456.73342-22-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The bus reset should not depend on any command, but rather only use the SCSI Host and the channel/bus number as argument. Signed-off-by: Hannes Reinecke --- Documentation/scsi/scsi_eh.rst | 2 +- Documentation/scsi/scsi_mid_low_api.rst | 5 ++- drivers/message/fusion/mptfc.c | 13 +++---- drivers/message/fusion/mptscsih.c | 21 ++++------- drivers/message/fusion/mptscsih.h | 2 +- drivers/scsi/a100u2w.c | 4 +- drivers/scsi/aacraid/linit.c | 11 +++--- drivers/scsi/aha152x.c | 4 +- drivers/scsi/aha1542.c | 4 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 10 ++--- drivers/scsi/aic7xxx/aic7xxx_osm.c | 6 +-- drivers/scsi/arcmsr/arcmsr_hba.c | 6 +-- drivers/scsi/arm/fas216.c | 9 +++-- drivers/scsi/arm/fas216.h | 5 ++- drivers/scsi/dc395x.c | 25 ++++++------- drivers/scsi/dpt_i2o.c | 9 +++-- drivers/scsi/dpti.h | 2 +- drivers/scsi/esas2r/esas2r.h | 2 +- drivers/scsi/esas2r/esas2r_main.c | 4 +- drivers/scsi/esp_scsi.c | 4 +- drivers/scsi/initio.c | 11 +++--- drivers/scsi/mpi3mr/mpi3mr_os.c | 37 +++++++++++-------- drivers/scsi/ncr53c8xx.c | 4 +- drivers/scsi/pcmcia/nsp_cs.c | 6 +-- drivers/scsi/pcmcia/nsp_cs.h | 2 +- drivers/scsi/pmcraid.c | 7 ++-- drivers/scsi/qla1280.c | 12 +++--- drivers/scsi/qla2xxx/qla_os.c | 17 +++------ drivers/scsi/scsi_debug.c | 31 ++++++---------- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 7 ++-- drivers/scsi/vmw_pvscsi.c | 5 +-- drivers/scsi/wd719x.c | 11 +++--- .../staging/unisys/visorhba/visorhba_main.c | 5 +-- drivers/usb/storage/scsiglue.c | 4 +- include/scsi/scsi_host.h | 2 +- 36 files changed, 148 insertions(+), 163 deletions(-) diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst index 1ca451ad57df..cf0649e0c3a9 100644 --- a/Documentation/scsi/scsi_eh.rst +++ b/Documentation/scsi/scsi_eh.rst @@ -215,7 +215,7 @@ considered to fail always. int (* eh_abort_handler)(struct scsi_cmnd *); int (* eh_device_reset_handler)(struct scsi_cmnd *); - int (* eh_bus_reset_handler)(struct scsi_cmnd *); + int (* eh_bus_reset_handler)(struct Scsi_Host *, int); int (* eh_host_reset_handler)(struct Scsi_Host *); Higher-severity actions are taken only when lower-severity actions diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst index 784587ea7eee..1b1c37445580 100644 --- a/Documentation/scsi/scsi_mid_low_api.rst +++ b/Documentation/scsi/scsi_mid_low_api.rst @@ -741,7 +741,8 @@ Details:: /** * eh_bus_reset_handler - issue SCSI bus reset - * @scp: SCSI bus that contains this device should be reset + * @host: SCSI Host that contains the channel which should be reset + * @channel: channel to be reset * * Returns SUCCESS if command aborted else FAILED * @@ -754,7 +755,7 @@ Details:: * * Optionally defined in: LLD **/ - int eh_bus_reset_handler(struct scsi_cmnd * scp) + int eh_bus_reset_handler(struct Scsi_Host * host, int channel) /** diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 578e762da28d..0cc8c0b795dc 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -103,7 +103,7 @@ static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); static void mptfc_remove(struct pci_dev *pdev); static int mptfc_abort(struct scsi_cmnd *SCpnt); static int mptfc_dev_reset(struct scsi_cmnd *SCpnt); -static int mptfc_bus_reset(struct scsi_cmnd *SCpnt); +static int mptfc_bus_reset(struct Scsi_Host *shost, int channel); static struct scsi_host_template mptfc_driver_template = { .module = THIS_MODULE, @@ -259,11 +259,9 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt) } static int -mptfc_bus_reset(struct scsi_cmnd *SCpnt) +mptfc_bus_reset(struct Scsi_Host *shost, int channel) { - struct Scsi_Host *shost = SCpnt->device->host; MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost); - int channel = SCpnt->device->channel; struct mptfc_rport_info *ri; int rtn; @@ -280,10 +278,9 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt) } if (rtn == 0) { dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT - "%s.%d: %d:%llu, executing recovery.\n", __func__, - hd->ioc->name, shost->host_no, - SCpnt->device->id, SCpnt->device->lun)); - rtn = mptscsih_bus_reset(SCpnt); + "%s.%d: 0:0, executing recovery.\n", __func__, + hd->ioc->name, shost->host_no)); + rtn = mptscsih_bus_reset(shost, channel); } return rtn; } diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 3bf06dfcd4f9..c1f6aeae514d 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1914,39 +1914,34 @@ mptscsih_target_reset(struct scsi_cmnd * SCpnt) * Returns SUCCESS or FAILED. **/ int -mptscsih_bus_reset(struct scsi_cmnd * SCpnt) +mptscsih_bus_reset(struct Scsi_Host * shost, int channel) { MPT_SCSI_HOST *hd; int retval; - VirtDevice *vdevice; MPT_ADAPTER *ioc; /* If we can't locate our host adapter structure, return FAILED status. */ - if ((hd = shost_priv(SCpnt->device->host)) == NULL){ + if ((hd = shost_priv(shost)) == NULL){ printk(KERN_ERR MYNAM ": bus reset: " - "Can't locate host! (sc=%p)\n", SCpnt); + "Can't locate host!\n"); return FAILED; } ioc = hd->ioc; - printk(MYIOC_s_INFO_FMT "attempting bus reset! (sc=%p)\n", - ioc->name, SCpnt); - scsi_print_command(SCpnt); + printk(MYIOC_s_INFO_FMT "attempting bus reset!\n", + ioc->name); if (ioc->timeouts < -1) ioc->timeouts++; - vdevice = SCpnt->device->hostdata; - if (!vdevice || !vdevice->vtarget) - return SUCCESS; retval = mptscsih_IssueTaskMgmt(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, - vdevice->vtarget->channel, 0, 0, 0, + channel, 0, 0, 0, mptscsih_get_tm_timeout(ioc)); - printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n", - ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); + printk(MYIOC_s_INFO_FMT "bus reset: %s\n", + ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" )); if (retval == 0) return SUCCESS; diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 50af52a81505..54f260482f77 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -121,7 +121,7 @@ extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt); extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt); -extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt); +extern int mptscsih_bus_reset(struct Scsi_Host *, int); extern int mptscsih_host_reset(struct Scsi_Host *sh); extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]); extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index 028af6b1057c..eee119c06b48 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c @@ -956,10 +956,10 @@ static int inia100_abort(struct scsi_cmnd * cmd) Output : None. Return : pSRB - Pointer to SCSI request block. *****************************************************************************/ -static int inia100_bus_reset(struct scsi_cmnd * cmd) +static int inia100_bus_reset(struct Scsi_Host * shost, int channel) { /* I need Host Control Block Information */ struct orc_host *host; - host = (struct orc_host *) cmd->device->host->hostdata; + host = (struct orc_host *) shost->hostdata; return orc_reset_scsi_bus(host); } diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 59909a8e4813..ae3bc94fc571 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1023,20 +1023,18 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd) /* * aac_eh_bus_reset - Bus reset command handling - * @scsi_cmd: SCSI command block causing the reset + * @host: SCSI host causing the reset + * @channel: Number of the bus to be reset * */ -static int aac_eh_bus_reset(struct scsi_cmnd* cmd) +static int aac_eh_bus_reset(struct Scsi_Host *host, int channel) { - struct scsi_device * dev = cmd->device; - struct Scsi_Host * host = dev->host; struct aac_dev * aac = (struct aac_dev *)host->hostdata; int count; u32 cmd_bus; int status = 0; - - cmd_bus = aac_logical_to_phys(scmd_channel(cmd)); + cmd_bus = aac_logical_to_phys(channel); /* Mark the assoc. FIB to not complete, eh handler does this */ for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) { struct fib *fib = &aac->fibs[count]; @@ -1044,6 +1042,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd) if (fib->hw_fib_va->header.XferState && (fib->flags & FIB_CONTEXT_FLAG) && (fib->flags & FIB_CONTEXT_FLAG_SCSI_CMD)) { + struct scsi_cmnd *cmd; struct aac_hba_map_info *info; u32 bus, cid; diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index b13b5c85f3de..6fbdb6f3c996 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1163,9 +1163,9 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt) * Reset the bus * */ -static int aha152x_bus_reset(struct scsi_cmnd *SCpnt) +static int aha152x_bus_reset(struct Scsi_Host *shpnt, int channel) { - return aha152x_bus_reset_host(SCpnt->device->host); + return aha152x_bus_reset_host(shpnt); } /* diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index f38812a1556e..64d427200d8f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -983,9 +983,9 @@ static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd) return SUCCESS; } -static int aha1542_bus_reset(struct scsi_cmnd *cmd) +static int aha1542_bus_reset(struct Scsi_Host *sh, int channel) { - return aha1542_reset(cmd->device->host, SCRST); + return aha1542_reset(sh, SCRST); } static int aha1542_host_reset(struct Scsi_Host *sh) diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 92ea24a075b8..9b2e15c4fe07 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -864,21 +864,21 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) * Reset the SCSI bus. */ static int -ahd_linux_bus_reset(struct scsi_cmnd *cmd) +ahd_linux_bus_reset(struct Scsi_Host *shost, int channel) { struct ahd_softc *ahd; int found; unsigned long flags; - ahd = *(struct ahd_softc **)cmd->device->host->hostdata; + ahd = *(struct ahd_softc **)shost->hostdata; #ifdef AHD_DEBUG if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) - printk("%s: Bus reset called for cmd %p\n", - ahd_name(ahd), cmd); + printk("%s: Bus reset called for channel %d\n", + ahd_name(ahd), channel); #endif ahd_lock(ahd, &flags); - found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A', + found = ahd_reset_channel(ahd, channel + 'A', /*initiate reset*/TRUE); ahd_unlock(ahd, &flags); diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 8b3d472aa3cc..0a487c9a43b8 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -754,16 +754,16 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd) * Reset the SCSI bus. */ static int -ahc_linux_bus_reset(struct scsi_cmnd *cmd) +ahc_linux_bus_reset(struct Scsi_Host *shost, int channel) { struct ahc_softc *ahc; int found; unsigned long flags; - ahc = *(struct ahc_softc **)cmd->device->host->hostdata; + ahc = *(struct ahc_softc **)shost->hostdata; ahc_lock(ahc, &flags); - found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A', + found = ahc_reset_channel(ahc, channel + 'A', /*initiate reset*/TRUE); ahc_unlock(ahc, &flags); diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index ec1a834c922d..25809d9fed7d 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -111,7 +111,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, struct scsi_cmnd *cmd); static int arcmsr_iop_confirm(struct AdapterControlBlock *acb); static int arcmsr_abort(struct scsi_cmnd *); -static int arcmsr_bus_reset(struct scsi_cmnd *); +static int arcmsr_bus_reset(struct Scsi_Host *, int); static int arcmsr_bios_param(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *info); static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd); @@ -4575,12 +4575,12 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb) return rtnval; } -static int arcmsr_bus_reset(struct scsi_cmnd *cmd) +static int arcmsr_bus_reset(struct Scsi_Host *shost, int channel) { struct AdapterControlBlock *acb; int retry_count = 0; int rtn = FAILED; - acb = (struct AdapterControlBlock *) cmd->device->host->hostdata; + acb = (struct AdapterControlBlock *) shost->hostdata; if (acb->acb_flags & ACB_F_ADAPTER_REMOVED) return SUCCESS; pr_notice("arcmsr: executing bus reset eh.....num_resets = %d," diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index b23e8caad57b..4f17b24a291f 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2550,15 +2550,16 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) /** * fas216_eh_bus_reset - Reset the bus associated with the command - * @SCpnt: command specifing bus to reset + * @shost: host to be reset + * @channel: bus number to reset * - * Reset the bus associated with the command. + * Reset the bus. * Returns: FAILED if unable to reset. * Notes: Further commands are blocked. */ -int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt) +int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel) { - FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; + FAS216_Info *info = (FAS216_Info *)shost->hostdata; unsigned long flags; struct scsi_device *SDpnt; diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index 50e540f5c214..0e86c54ca6fe 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h @@ -375,10 +375,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt); /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt) * Purpose : Reset the complete bus associated with this command - * Params : SCpnt - command specifing bus to reset + * Params : shost - host to be reset + * channel - bus to be reset * Returns : FAILED if unable to reset */ -extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt); +extern int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel); /* Function: int fas216_eh_host_reset(struct Scsi_Host *shost) * Purpose : Reset the host associated with this command diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 24c7cefb0b78..673652060d3e 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -1146,19 +1146,18 @@ static void reset_dev_param(struct AdapterCtlBlk *acb) * @cmd - some command for this host (for fetching hooks) * Returns: SUCCESS (0x2002) on success, else FAILED (0x2003). */ -static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd) +static int __dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel) { struct AdapterCtlBlk *acb = - (struct AdapterCtlBlk *)cmd->device->host->hostdata; + (struct AdapterCtlBlk *)shost->hostdata; dprintkl(KERN_INFO, - "eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n", - cmd, cmd->device->id, (u8)cmd->device->lun, cmd); + "eh_bus_reset: bus=<%02i>\n", channel); if (timer_pending(&acb->waiting_timer)) del_timer(&acb->waiting_timer); /* - * disable interrupt + * disable interrupt */ DC395x_write8(acb, TRM_S1040_DMA_INTEN, 0x00); DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x00); @@ -1174,7 +1173,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd) HZ * acb->eeprom.delay_time; /* - * re-enable interrupt + * re-enable interrupt */ /* Clear SCSI FIFO */ DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO); @@ -1184,7 +1183,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd) set_basic_config(acb); reset_dev_param(acb); - doing_srb_done(acb, DID_RESET, cmd, 0); + doing_srb_done(acb, DID_RESET, NULL, 0); acb->active_dcb = NULL; acb->acb_flag = 0; /* RESET_DETECT, RESET_DONE ,RESET_DEV */ waiting_process_next(acb); @@ -1192,13 +1191,13 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd) return SUCCESS; } -static int dc395x_eh_bus_reset(struct scsi_cmnd *cmd) +static int dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel) { int rc; - spin_lock_irq(cmd->device->host->host_lock); - rc = __dc395x_eh_bus_reset(cmd); - spin_unlock_irq(cmd->device->host->host_lock); + spin_lock_irq(shost->host_lock); + rc = __dc395x_eh_bus_reset(shost, channel); + spin_unlock_irq(shost->host_lock); return rc; } @@ -3343,7 +3342,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, /* abort all cmds in our queues */ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag, - struct scsi_cmnd *cmd, u8 force) + struct scsi_cmnd *cmd, u8 force) { struct DeviceCtlBlk *dcb; dprintkl(KERN_INFO, "doing_srb_done: pids "); @@ -3391,7 +3390,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag, set_status_byte(p, SAM_STAT_GOOD); pci_unmap_srb_sense(acb, srb); pci_unmap_srb(acb, srb); - if (force) { + if (force && cmd) { /* For new EH, we normally don't need to give commands back, * as they all complete or all time out */ cmd->scsi_done(cmd); diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index ef38f964fa32..cceb25ada357 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -719,17 +719,18 @@ static int adpt_device_reset(struct scsi_cmnd* cmd) #define I2O_HBA_BUS_RESET 0x87 // This version of bus reset is called by the eh_error handler -static int adpt_bus_reset(struct scsi_cmnd* cmd) +static int adpt_bus_reset(struct Scsi_Host *shost, int channel) { adpt_hba* pHba; u32 msg[4]; u32 rcode; - pHba = (adpt_hba*)cmd->device->host->hostdata[0]; + pHba = (adpt_hba*)shost->hostdata[0]; memset(msg, 0, sizeof(msg)); - printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->device->channel].tid ); + printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n", + pHba->name, channel, pHba->channel[channel].tid ); msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0; - msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid); + msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[channel].tid); msg[2] = 0; msg[3] = 0; if (pHba->host) diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h index b77a3625fa6f..48878e69ab2c 100644 --- a/drivers/scsi/dpti.h +++ b/drivers/scsi/dpti.h @@ -35,7 +35,7 @@ static const char *adpt_info(struct Scsi_Host *pSHost); static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev, sector_t, int geom[]); -static int adpt_bus_reset(struct scsi_cmnd* cmd); +static int adpt_bus_reset(struct Scsi_Host* shost, int channel); static int adpt_device_reset(struct scsi_cmnd* cmd); diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index a104d1a3a9da..5c1eeaffc090 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -977,7 +977,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); int esas2r_eh_abort(struct scsi_cmnd *cmd); int esas2r_device_reset(struct scsi_cmnd *cmd); int esas2r_host_reset(struct Scsi_Host *shost); -int esas2r_bus_reset(struct scsi_cmnd *cmd); +int esas2r_bus_reset(struct Scsi_Host *shost, int channel); int esas2r_target_reset(struct scsi_cmnd *cmd); /* Internal functions */ diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 167163820457..72af1fed419e 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1094,10 +1094,8 @@ int esas2r_host_reset(struct Scsi_Host *shost) return esas2r_host_bus_reset(shost, true); } -int esas2r_bus_reset(struct scsi_cmnd *cmd) +int esas2r_bus_reset(struct Scsi_Host *shost, int channel) { - struct Scsi_Host *shost = cmd->device->host; - esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost); return esas2r_host_bus_reset(shost, false); diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 45c83e3d887d..3d091333bd0b 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2606,9 +2606,9 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd) return FAILED; } -static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd) +static int esp_eh_bus_reset_handler(struct Scsi_Host *shost, int channel) { - struct esp *esp = shost_priv(cmd->device->host); + struct esp *esp = shost_priv(shost); struct completion eh_reset; unsigned long flags; diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 9b75e19a9bab..f4a1dd83e768 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -2630,20 +2630,21 @@ static DEF_SCSI_QCMD(i91u_queuecommand) /** * i91u_bus_reset - reset the SCSI bus - * @cmnd: Command block we want to trigger the reset for + * @shost: SCSI host to be reset + * @channel: Bus number to be reset * * Initiate a SCSI bus reset sequence */ -static int i91u_bus_reset(struct scsi_cmnd * cmnd) +static int i91u_bus_reset(struct Scsi_Host * shost, int channel) { struct initio_host *host; - host = (struct initio_host *) cmnd->device->host->hostdata; + host = (struct initio_host *) shost->hostdata; - spin_lock_irq(cmnd->device->host->host_lock); + spin_lock_irq(shost->host_lock); initio_reset_scsi(host, 0); - spin_unlock_irq(cmnd->device->host->host_lock); + spin_unlock_irq(shost->host_lock); return SUCCESS; } diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 3720f88ebc68..30d8482ddc7f 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2904,39 +2904,46 @@ static int mpi3mr_eh_host_reset(struct Scsi_Host *shost) /** * mpi3mr_eh_bus_reset - Bus reset error handling callback - * @scmd: SCSI command reference + * @shost: SCSI host reference + * @channel: bus number * * Checks whether pending I/Os are present for the RAID volume; * if not there's no need to reset the adapter. * * Return: SUCCESS of successful reset else FAILED */ -static int mpi3mr_eh_bus_reset(struct scsi_cmnd *scmd) +static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel) { - struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + struct mpi3mr_tgt_dev *tgtdev; struct mpi3mr_stgt_priv_data *stgt_priv_data; - struct mpi3mr_sdev_priv_data *sdev_priv_data; - u8 dev_type = MPI3_DEVICE_DEVFORM_VD; int retval = FAILED; - sdev_priv_data = scmd->device->hostdata; - if (sdev_priv_data && sdev_priv_data->tgt_priv_data) { - stgt_priv_data = sdev_priv_data->tgt_priv_data; - dev_type = stgt_priv_data->dev_type; + spin_lock(&mrioc->tgtdev_lock); + list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) { + if (!tgtdev->starget || !tgtdev->starget->hostdata) + continue; + stgt_priv_data = (struct mpi3mr_stgt_priv_data *) + tgtdev->starget->hostdata; + if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_VD) { + retval = SUCCESS; + break; + } } + spin_unlock(&mrioc->tgtdev_lock); - if (dev_type == MPI3_DEVICE_DEVFORM_VD) { + if (retval == SUCCESS) { mpi3mr_wait_for_host_io(mrioc, MPI3MR_RAID_ERRREC_RESET_TIMEOUT); - if (!mpi3mr_get_fw_pending_ios(mrioc)) - retval = SUCCESS; + if (mpi3mr_get_fw_pending_ios(mrioc)) + retval = FAILED; } if (retval == FAILED) mpi3mr_print_pending_host_io(mrioc); - sdev_printk(KERN_INFO, scmd->device, - "Bus reset is %s for scmd(%p)\n", - ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + shost_printk(KERN_INFO, shost, + "Bus reset is %s\n", + ((retval == SUCCESS) ? "SUCCESS" : "FAILED")); return retval; } diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index e7115cba4b28..b80ff27bb78c 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -7939,9 +7939,9 @@ static void ncr53c8xx_timeout(struct timer_list *t) ncr_flush_done_cmds(done_list); } -static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd) +static int ncr53c8xx_bus_reset(struct Scsi_Host *host, int channel) { - struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; + struct ncb *np = ((struct host_data *) host->hostdata)->ncb; int sts; unsigned long flags; struct scsi_cmnd *done_list; diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 04b3d52e3547..1f65033458e3 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -1473,11 +1473,11 @@ static int nsp_bus_reset(nsp_hw_data *data) return SUCCESS; } -static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt) +static int nsp_eh_bus_reset(struct Scsi_Host *host, int channel) { - nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; + nsp_hw_data *data = (nsp_hw_data *)host->hostdata; - nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); + nsp_dbg(NSP_DEBUG_BUSRESET, "channel=0x%d", channel); return nsp_bus_reset(data); } diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index fe1e598e1746..8ccfc410c931 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -299,7 +299,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt); /* Error handler */ /*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/ /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/ -static int nsp_eh_bus_reset (struct scsi_cmnd *SCpnt); +static int nsp_eh_bus_reset (struct Scsi_Host *host, int channel); static int nsp_eh_host_reset (struct Scsi_Host *host); static int nsp_bus_reset (nsp_hw_data *data); diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index f29107536887..9397eaef0bac 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3023,9 +3023,8 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd) RESET_DEVICE_LUN); } -static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd) +static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel) { - struct Scsi_Host *host = scmd->device->host; struct pmcraid_instance *pinstance = (struct pmcraid_instance *)host->hostdata; struct pmcraid_resource_entry *res = NULL; @@ -3039,11 +3038,11 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd) */ 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 && + if (channel == PMCRAID_VSET_BUS_ID && RES_IS_VSET(temp->cfg_entry)) { res = temp; break; - } else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID && + } else if (channel == PMCRAID_PHYS_BUS_ID && RES_IS_GSCSI(temp->cfg_entry)) { res = temp; break; diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index dd69bfa85f04..f478e609d0ba 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -989,13 +989,15 @@ qla1280_eh_device_reset(struct scsi_cmnd *cmd) * Reset the specified bus. **************************************************************************/ static int -qla1280_eh_bus_reset(struct scsi_cmnd *cmd) +qla1280_eh_bus_reset(struct Scsi_Host *shost, int bus) { - int rc; + int rc = FAILED; + struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata; - spin_lock_irq(cmd->device->host->host_lock); - rc = qla1280_error_action(cmd, BUS_RESET); - spin_unlock_irq(cmd->device->host->host_lock); + spin_lock_irq(shost->host_lock); + if (qla1280_bus_reset(ha, bus) == 0) + rc = qla1280_wait_for_pending_commands(ha, 1, 0); + spin_unlock_irq(shost->host_lock); return rc; } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index a84a85288c2e..b9cc7cfb5c21 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1527,7 +1527,7 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) * commands. * * Input: -* cmd = Linux SCSI command packet of the command that cause the +* host = Linux SCSI command packet of the command that cause the * bus reset. * * Returns: @@ -1535,12 +1535,10 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) * **************************************************************************/ static int -qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_bus_reset(struct Scsi_Host *shost, int channel) { - scsi_qla_host_t *vha = shost_priv(cmd->device->host); + scsi_qla_host_t *vha = shost_priv(shost); int ret = FAILED; - unsigned int id; - uint64_t lun; struct qla_hw_data *ha = vha->hw; if (qla2x00_isp_reg_stat(ha)) { @@ -1550,14 +1548,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) return FAILED; } - id = cmd->device->id; - lun = cmd->device->lun; - if (qla2x00_chip_is_down(vha)) return ret; ql_log(ql_log_info, vha, 0x8012, - "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun); + "BUS RESET ISSUED nexus=%ld:%d.\n", vha->host_no, channel); if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { ql_log(ql_log_fatal, vha, 0x8013, @@ -1581,8 +1576,8 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) eh_bus_reset_done: ql_log(ql_log_warn, vha, 0x802b, - "BUS RESET %s nexus=%ld:%d:%llu.\n", - (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); + "BUS RESET %s nexus=%ld:%d.\n", + (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, channel); return ret; } diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 884bdaf26e10..63bbbcc94bbc 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5218,36 +5218,27 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt) return SUCCESS; } -static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt) +static int scsi_debug_bus_reset(struct Scsi_Host * hp, int channel) { - struct sdebug_host_info *sdbg_host; + struct sdebug_host_info *sdbg_host = + *(struct sdebug_host_info **)shost_priv(hp); struct sdebug_dev_info *devip; - struct scsi_device *sdp; - struct Scsi_Host *hp; int k = 0; ++num_bus_resets; - if (!(SCpnt && SCpnt->device)) - goto lie; - sdp = SCpnt->device; if (SDEBUG_OPT_ALL_NOISE & sdebug_opts) - sdev_printk(KERN_INFO, sdp, "%s\n", __func__); - hp = sdp->host; - if (hp) { - sdbg_host = *(struct sdebug_host_info **)shost_priv(hp); - if (sdbg_host) { - list_for_each_entry(devip, - &sdbg_host->dev_info_list, - dev_list) { - set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); - ++k; - } + shost_printk(KERN_INFO, hp, "%s\n", __func__); + if (sdbg_host) { + list_for_each_entry(devip, + &sdbg_host->dev_info_list, + dev_list) { + set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); + ++k; } } if (SDEBUG_OPT_RESET_NOISE & sdebug_opts) - sdev_printk(KERN_INFO, sdp, + shost_printk(KERN_INFO, hp, "%s: %d device(s) found in host\n", __func__, k); -lie: return SUCCESS; } diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 8218e2976482..d5e36488c87b 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -841,7 +841,7 @@ static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd) if (!hostt->eh_bus_reset_handler) return FAILED; - rtn = hostt->eh_bus_reset_handler(scmd); + rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd)); if (rtn == SUCCESS) { if (!hostt->skip_settle_delay) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 85b66286b4be..2e5ab844fe09 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -645,14 +645,13 @@ static int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd) return sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd); } -static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd) +static int sym53c8xx_eh_bus_reset_handler(struct Scsi_Host *shost, int channel) { - struct Scsi_Host *shost = cmd->device->host; struct sym_data *sym_data = shost_priv(shost); struct pci_dev *pdev = sym_data->pdev; struct sym_hcb *np = sym_data->ncb; - scmd_printk(KERN_WARNING, cmd, "BUS RESET operation started\n"); + shost_printk(KERN_WARNING, shost, "BUS RESET operation started\n"); /* * Escalate to host reset if the PCI bus went down @@ -664,7 +663,7 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd) sym_reset_scsi_bus(np, 1); spin_unlock_irq(shost->host_lock); - dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n"); + shost_printk(KERN_WARNING, shost, "BUS RESET operation complete.\n"); return SCSI_SUCCESS; } diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 05ef6651506b..847535fce8eb 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -945,13 +945,12 @@ static int pvscsi_host_reset(struct Scsi_Host *host) return SUCCESS; } -static int pvscsi_bus_reset(struct scsi_cmnd *cmd) +static int pvscsi_bus_reset(struct Scsi_Host *host, int channel) { - struct Scsi_Host *host = cmd->device->host; struct pvscsi_adapter *adapter = shost_priv(host); unsigned long flags; - scmd_printk(KERN_INFO, cmd, "SCSI Bus reset\n"); + shost_printk(KERN_INFO, host, "SCSI Bus reset\n"); /* * We don't want to queue new requests for this bus after diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index 9485cbf5f946..85abbc82e7c8 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -482,11 +482,11 @@ static int wd719x_abort(struct scsi_cmnd *cmd) return SUCCESS; } -static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device) +static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device) { int result; unsigned long flags; - struct wd719x *wd = shost_priv(cmd->device->host); + struct wd719x *wd = shost_priv(shost); struct wd719x_scb *scb, *tmp; dev_info(&wd->pdev->dev, "%s reset requested\n", @@ -510,12 +510,13 @@ static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device) static int wd719x_dev_reset(struct scsi_cmnd *cmd) { - return wd719x_reset(cmd, WD719X_CMD_RESET, cmd->device->id); + return wd719x_reset(cmd->device->host, WD719X_CMD_RESET, + cmd->device->id); } -static int wd719x_bus_reset(struct scsi_cmnd *cmd) +static int wd719x_bus_reset(struct Scsi_Host *host, int channel) { - return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0); + return wd719x_reset(host, WD719X_CMD_BUSRESET, 0); } static int wd719x_host_reset(struct Scsi_Host *host) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index bfb4a70432f3..7277cb5c8108 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -366,15 +366,14 @@ static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd) * * Return: SUCCESS if inserted, FAILED otherwise */ -static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd) +static int visorhba_bus_reset_handler(struct Scsi_Host *scsihost, int channel) { struct scsi_device *scsidev = NULL, *tmp; - struct Scsi_Host *scsihost = scsicmd->device->host; struct visordisk_info *vdisk; int rtn = SUCCESS; shost_for_each_device(tmp, scsihost) { - if (tmp->channel != scsicmd->device->channel) + if (tmp->channel != channel) continue; vdisk = tmp->hostdata; if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT) diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index e5a971b83e3f..33456368ca1e 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -465,9 +465,9 @@ static int device_reset(struct scsi_cmnd *srb) } /* Simulate a SCSI bus reset by resetting the device's USB port. */ -static int bus_reset(struct scsi_cmnd *srb) +static int bus_reset(struct Scsi_Host *shost, int channel) { - struct us_data *us = host_to_us(srb->device->host); + struct us_data *us = host_to_us(shost); int result; usb_stor_dbg(us, "%s called\n", __func__); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 3b1acf91f4d0..e0a102339317 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -141,7 +141,7 @@ struct scsi_host_template { int (* eh_abort_handler)(struct scsi_cmnd *); int (* eh_device_reset_handler)(struct scsi_cmnd *); int (* eh_target_reset_handler)(struct scsi_cmnd *); - int (* eh_bus_reset_handler)(struct scsi_cmnd *); + int (* eh_bus_reset_handler)(struct Scsi_Host *, int); int (* eh_host_reset_handler)(struct Scsi_Host *); /* From patchwork Tue Aug 17 09:14:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2BC9C432BE for ; Tue, 17 Aug 2021 09:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA1BA600CC for ; Tue, 17 Aug 2021 09:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239569AbhHQJRa (ORCPT ); Tue, 17 Aug 2021 05:17:30 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33308 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239294AbhHQJRQ (ORCPT ); Tue, 17 Aug 2021 05:17:16 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 344AE21D3D; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=M021yZTyA7R+S7ex7SM+pePBigXQFhOuMlMB00LdKPQ=; b=WT58ZYf0LDN1RBOI/BpU56bodQdA0l3yjEqslt9x8kqQ//Q6Gbph+0s7zKlzoRIoi9XpXj wZHNAVt4x/Xs+ccA8iGer1ERQPx2ZsIHbW6gYU4th0pKAFl+JmMsDC4B1eUp0Q/Ct1cHlv HUkwHBLfJvaDD1PyuC+AV6HY85an9tk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=M021yZTyA7R+S7ex7SM+pePBigXQFhOuMlMB00LdKPQ=; b=CBp3+dVBQ74GcWSlwhOvhnZqHERbq/FIsPhRrF26QW4qZUrDE7t+lvdYiF/z1XuxAjPDbZ 7TFmT+fSsfotgRBw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 2E6A7A3BA6; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 2B351518CE8B; Tue, 17 Aug 2021 11:16:42 +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 22/51] libiscsi: use cls_session as argument for target and session reset Date: Tue, 17 Aug 2021 11:14:27 +0200 Message-Id: <20210817091456.73342-23-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 --- 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 e70f69f791db..d76902c4128c 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -367,6 +367,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) }, @@ -390,7 +398,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_attrs = beiscsi_attrs, .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, .can_queue = BE2_IO_DEPTH, diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 4683c183e9d4..0006a3692c9a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2488,13 +2488,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); @@ -2541,7 +2539,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; @@ -2556,19 +2554,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); @@ -2586,7 +2581,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)) { @@ -2638,11 +2633,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 4ee233e5a6ff..3401feb088df 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -379,7 +379,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 Tue Aug 17 09:14:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7931C432BE for ; Tue, 17 Aug 2021 09:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF642600CC for ; Tue, 17 Aug 2021 09:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239583AbhHQJRd (ORCPT ); Tue, 17 Aug 2021 05:17:33 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33310 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239300AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3C2CD21D40; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=i/YvAzY2BXyJ6hJ0PjaBkQChsnfEPSrPNrASZHuf2K8=; b=xYbrcoEBeASRP5fx3YdG4+1wE30m1mjYdAXNT1x3c2WacGnfP56i8Pc4DeJIOExK1pH+rO s7ECAq1QgeV0NXOwysqvCyuPk4E0I7LdV/9FYP5xc+XNUO84qW/ZCQimBgFtp806feddw5 6RjYKZhIVvfUHtyfuYAn6U3gLeBnQE8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=i/YvAzY2BXyJ6hJ0PjaBkQChsnfEPSrPNrASZHuf2K8=; b=mJBY4QDWMzhxxes8+Oy4/86GAEA3OYqPuNkjT7wM1MHCvFcwvYfq4otU006WA3LgPTqRKe u9bBErURL5cDlXCQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 35946A3BA7; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 3250E518CE8D; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , Saurav Kashyap Subject: [PATCH 23/51] bnx2fc: Do not rely on a scsi command when issueing lun or target reset Date: Tue, 17 Aug 2021 11:14:28 +0200 Message-Id: <20210817091456.73342-24-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When a LUN or target reset is issued we should not rely on a scsi command to be present; this isn't very reliable and is going away with the next patch anyway. Signed-off-by: Hannes Reinecke Cc: Saurav Kashyap --- drivers/scsi/bnx2fc/bnx2fc.h | 1 + drivers/scsi/bnx2fc/bnx2fc_hwi.c | 14 +++-- drivers/scsi/bnx2fc/bnx2fc_io.c | 91 +++++++++++++++----------------- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index b4cea8b06ea1..4e0434f70092 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -386,6 +386,7 @@ struct bnx2fc_rport { }; struct bnx2fc_mp_req { + u64 tm_lun; u8 tm_flags; u32 req_len; diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c index 0103f811cc25..a08e89dad29d 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c @@ -1709,7 +1709,8 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req, struct fcoe_cached_sge_ctx *cached_sge; struct fcoe_ext_mul_sges_ctx *sgl; int dev_type = tgt->dev_type; - u64 *fcp_cmnd; + struct fcp_cmnd *fcp_cmnd; + u64 *raw_fcp_cmnd; u64 tmp_fcp_cmnd[4]; u32 context_id; int cnt, i; @@ -1778,16 +1779,19 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req, task->txwr_rxrd.union_ctx.tx_seq.ctx.seq_cnt = 1; /* Fill FCP_CMND IU */ - fcp_cmnd = (u64 *) + fcp_cmnd = (struct fcp_cmnd *)&tmp_fcp_cmnd; + bnx2fc_build_fcp_cmnd(io_req, fcp_cmnd); + int_to_scsilun(sc_cmd->device->lun, &fcp_cmnd->fc_lun); + memcpy(fcp_cmnd->fc_cdb, sc_cmd->cmnd, sc_cmd->cmd_len); + raw_fcp_cmnd = (u64 *) task->txwr_rxrd.union_ctx.fcp_cmd.opaque; - bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)&tmp_fcp_cmnd); /* swap fcp_cmnd */ cnt = sizeof(struct fcp_cmnd) / sizeof(u64); for (i = 0; i < cnt; i++) { - *fcp_cmnd = cpu_to_be64(tmp_fcp_cmnd[i]); - fcp_cmnd++; + *raw_fcp_cmnd = cpu_to_be64(tmp_fcp_cmnd[i]); + raw_fcp_cmnd++; } /* Rx Write Tx Read */ diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index f2996a9b2f63..28e858325d38 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -658,10 +658,9 @@ int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req) return SUCCESS; } -static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) +static int bnx2fc_initiate_tmf(struct fc_lport *lport, struct fc_rport *rport, + u64 tm_lun, u8 tm_flags) { - struct fc_lport *lport; - struct fc_rport *rport; struct fc_rport_libfc_priv *rp; struct fcoe_port *port; struct bnx2fc_interface *interface; @@ -670,7 +669,6 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) struct bnx2fc_mp_req *tm_req; struct fcoe_task_ctx_entry *task; struct fcoe_task_ctx_entry *task_page; - struct Scsi_Host *host = sc_cmd->device->host; struct fc_frame_header *fc_hdr; struct fcp_cmnd *fcp_cmnd; int task_idx, index; @@ -679,8 +677,6 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) u32 sid, did; unsigned long start = jiffies; - lport = shost_priv(host); - rport = starget_to_rport(scsi_target(sc_cmd->device)); port = lport_priv(lport); interface = port->priv; @@ -691,7 +687,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) } rp = rport->dd_data; - rc = fc_block_scsi_eh(sc_cmd); + rc = fc_block_rport(rport); if (rc) return rc; @@ -720,7 +716,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) goto retry_tmf; } /* Initialize rest of io_req fields */ - io_req->sc_cmd = sc_cmd; + io_req->sc_cmd = NULL; io_req->port = port; io_req->tgt = tgt; @@ -738,11 +734,13 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) /* Set TM flags */ io_req->io_req_flags = 0; tm_req->tm_flags = tm_flags; + tm_req->tm_lun = tm_lun; /* Fill FCP_CMND */ bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf); fcp_cmnd = (struct fcp_cmnd *)tm_req->req_buf; - memset(fcp_cmnd->fc_cdb, 0, sc_cmd->cmd_len); + int_to_scsilun(tm_lun, &fcp_cmnd->fc_lun); + memset(fcp_cmnd->fc_cdb, 0, BNX2FC_MAX_CMD_LEN); fcp_cmnd->fc_dl = 0; /* Fill FC header */ @@ -765,8 +763,6 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) task = &(task_page[index]); bnx2fc_init_mp_task(io_req, task); - sc_cmd->SCp.ptr = (char *)io_req; - /* Obtain free SQ entry */ spin_lock_bh(&tgt->tgt_lock); bnx2fc_add_2_sq(tgt, xid); @@ -1064,7 +1060,10 @@ int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req) */ int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd) { - return bnx2fc_initiate_tmf(sc_cmd, FCP_TMF_TGT_RESET); + struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + struct fc_lport *lport = shost_priv(rport_to_shost(rport)); + + return bnx2fc_initiate_tmf(lport, rport, 0, FCP_TMF_TGT_RESET); } /** @@ -1077,7 +1076,11 @@ int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd) */ int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd) { - return bnx2fc_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET); + struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + struct fc_lport *lport = shost_priv(rport_to_shost(rport)); + + return bnx2fc_initiate_tmf(lport, rport, sc_cmd->device->lun, + FCP_TMF_LUN_RESET); } static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req) @@ -1452,10 +1455,9 @@ void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req, static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) { - struct scsi_cmnd *sc_cmd = io_req->sc_cmd; struct bnx2fc_rport *tgt = io_req->tgt; struct bnx2fc_cmd *cmd, *tmp; - u64 tm_lun = sc_cmd->device->lun; + struct bnx2fc_mp_req *tm_req = &io_req->mp_req; u64 lun; int rc = 0; @@ -1467,8 +1469,10 @@ static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) */ list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) { BNX2FC_TGT_DBG(tgt, "LUN RST cmpl: scan for pending IOs\n"); + if (!cmd->sc_cmd) + continue; lun = cmd->sc_cmd->device->lun; - if (lun == tm_lun) { + if (lun == tm_req->tm_lun) { /* Initiate ABTS on this cmd */ if (!test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &cmd->req_flags)) { @@ -1572,32 +1576,32 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, printk(KERN_ERR PFX "tmf's fc_hdr r_ctl = 0x%x\n", fc_hdr->fh_r_ctl); } - if (!sc_cmd->SCp.ptr) { - printk(KERN_ERR PFX "tm_compl: SCp.ptr is NULL\n"); - return; - } - switch (io_req->fcp_status) { - case FC_GOOD: - if (io_req->cdb_status == 0) { - /* Good IO completion */ - sc_cmd->result = DID_OK << 16; - } else { - /* Transport status is good, SCSI status not good */ - sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; + if (sc_cmd && sc_cmd->SCp.ptr) { + switch (io_req->fcp_status) { + case FC_GOOD: + if (io_req->cdb_status == 0) { + /* Good IO completion */ + sc_cmd->result = DID_OK << 16; + } else { + /* Transport status is good, SCSI status not good */ + sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; + } + if (io_req->fcp_resid) + scsi_set_resid(sc_cmd, io_req->fcp_resid); + break; + + default: + BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n", + io_req->fcp_status); + break; } - if (io_req->fcp_resid) - scsi_set_resid(sc_cmd, io_req->fcp_resid); - break; - default: - BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n", - io_req->fcp_status); - break; - } - - sc_cmd = io_req->sc_cmd; - io_req->sc_cmd = NULL; + sc_cmd = io_req->sc_cmd; + io_req->sc_cmd = NULL; + sc_cmd->SCp.ptr = NULL; + sc_cmd->scsi_done(sc_cmd); + } /* check if the io_req exists in tgt's tmf_q */ if (io_req->on_tmf_queue) { @@ -1609,9 +1613,6 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, return; } - sc_cmd->SCp.ptr = NULL; - sc_cmd->scsi_done(sc_cmd); - kref_put(&io_req->refcount, bnx2fc_cmd_release); if (io_req->wait_for_abts_comp) { BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n"); @@ -1740,15 +1741,9 @@ static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req) void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, struct fcp_cmnd *fcp_cmnd) { - struct scsi_cmnd *sc_cmd = io_req->sc_cmd; - memset(fcp_cmnd, 0, sizeof(struct fcp_cmnd)); - int_to_scsilun(sc_cmd->device->lun, &fcp_cmnd->fc_lun); - fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); - memcpy(fcp_cmnd->fc_cdb, sc_cmd->cmnd, sc_cmd->cmd_len); - fcp_cmnd->fc_cmdref = 0; fcp_cmnd->fc_pri_ta = 0; fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; From patchwork Tue Aug 17 09:14:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F442C4338F for ; Tue, 17 Aug 2021 09:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8989360FA0 for ; Tue, 17 Aug 2021 09:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239696AbhHQJRk (ORCPT ); Tue, 17 Aug 2021 05:17:40 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47570 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239377AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 410792001F; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=ESQWh2Y2DOmrJhSx6b6KuX/7q2iX56teg3hpJ4YA9pE=; b=u/54hoNIvrHmF0zN8WoU8XvdpaaDPkl5Fuq24QGL3AqzCskQwcqVu1Vj8jpuktrEHtckJI 6P/9FWGJsUItlNcCIFExDT21BP3ETwkQdTxLhWpkxzy/5gl8bDv2JaWl2V2hFNMpEixpk9 DtZ3BCnpRTW0Jz2TSMgRkYt0b45Nbn4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=ESQWh2Y2DOmrJhSx6b6KuX/7q2iX56teg3hpJ4YA9pE=; b=/Ii9VtIbC/Oq2G03pYv9DgjjR3oIF473bU26W0adSBZZL7ygW/YWGaqZmUi900mMRZ3myz Ix3+oqHnTPUGbwBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 3ABF5A3BA8; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 37DCC518CE8F; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Tyrel Datwyler Subject: [PATCH 24/51] ibmvfc: open-code reset loop for target reset Date: Tue, 17 Aug 2021 11:14:29 +0200 Message-Id: <20210817091456.73342-25-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Hannes Reinecke For target reset we need a device to send the target reset to, so open-code the loop in target reset to send the target reset TMF to the correct device. Signed-off-by: Hannes Reinecke Cc: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc.c | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 0a946aad66e5..1a5e2c2cc189 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2909,18 +2909,6 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data) *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_SUPPRESS_ABTS); } -/** - * ibmvfc_dev_cancel_all_reset - Device iterated cancel all function - * @sdev: scsi device struct - * @data: return code - * - **/ -static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data) -{ - unsigned long *rc = data; - *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_TGT_RESET); -} - /** * ibmvfc_eh_target_reset_handler - Reset the target * @cmd: scsi command struct @@ -2930,22 +2918,38 @@ static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data) **/ static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd) { - struct scsi_device *sdev = cmd->device; - struct ibmvfc_host *vhost = shost_priv(sdev->host); - struct scsi_target *starget = scsi_target(sdev); + struct scsi_target *starget = scsi_target(cmd->device); + struct fc_rport *rport = starget_to_rport(starget); + struct Scsi_Host *shost = rport_to_shost(rport); + struct ibmvfc_host *vhost = shost_priv(shost); int block_rc; int reset_rc = 0; int rc = FAILED; unsigned long cancel_rc = 0; + bool tgt_reset = false; ENTER; - block_rc = fc_block_scsi_eh(cmd); + block_rc = fc_block_rport(rport); ibmvfc_wait_while_resetting(vhost); if (block_rc != FAST_IO_FAIL) { - starget_for_each_device(starget, &cancel_rc, ibmvfc_dev_cancel_all_reset); - reset_rc = ibmvfc_reset_device(sdev, IBMVFC_TARGET_RESET, "target"); + struct scsi_device *sdev; + + shost_for_each_device(sdev, shost) { + if ((sdev->channel != starget->channel) || + (sdev->id != starget->id)) + continue; + + cancel_rc |= ibmvfc_cancel_all(sdev, + IBMVFC_TMF_TGT_RESET); + if (!tgt_reset) { + reset_rc = ibmvfc_reset_device(sdev, + IBMVFC_TARGET_RESET, "target"); + tgt_reset = true; + } + } } else - starget_for_each_device(starget, &cancel_rc, ibmvfc_dev_cancel_all_noreset); + starget_for_each_device(starget, &cancel_rc, + ibmvfc_dev_cancel_all_noreset); if (!cancel_rc && !reset_rc) rc = ibmvfc_wait_for_ops(vhost, starget, ibmvfc_match_target); From patchwork Tue Aug 17 09:14:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08406C43216 for ; Tue, 17 Aug 2021 09:17:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E520960720 for ; Tue, 17 Aug 2021 09:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239575AbhHQJRc (ORCPT ); Tue, 17 Aug 2021 05:17:32 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33312 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239310AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 46D8E21D44; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=cMEH0o3KwZ3qPbyOGuvmtd11cUkKiVSaGqOGZExzpkk=; b=FlLufHL+k5Z/Ep+gggiNmkbE2ZN1vohuWlBQDK2m2/DT28IQntG2AG5MdErIcfPt9X3OYX DhVgy8v26gqZAATAA9VOn6jwPQNY99vUF8kG6L+dTMKAy5/2ALTZI6/1NvWXo8p7E3tlUI vdvnmgog4pOXRuA1RW66Yghu5MdjnoE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=cMEH0o3KwZ3qPbyOGuvmtd11cUkKiVSaGqOGZExzpkk=; b=nVhblV1EgEPeYdSfc4/a1+PtsIS6HF39oGsNM5QOHbqw51Raiw52PVFBYgBXOAyCMJ6/2H /Vj9nKRykJTE8yAQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 41548A3BA9; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 3E8C3518CE91; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , James Smart Subject: [PATCH 25/51] lpfc: use fc_block_rport() Date: Tue, 17 Aug 2021 11:14:30 +0200 Message-Id: <20210817091456.73342-26-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command will be removed as argument for SCSI EH functions. Signed-off-by: Hannes Reinecke Cc: James Smart Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index d68c08af5514..0bbf767f7253 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -5727,6 +5727,7 @@ static int lpfc_abort_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; + struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_hba *phba = vport->phba; struct lpfc_iocbq *iocb; @@ -5738,7 +5739,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) unsigned long flags; DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); - status = fc_block_scsi_eh(cmnd); + status = fc_block_rport(rport); if (status != 0 && status != SUCCESS) return status; @@ -6187,6 +6188,7 @@ static int lpfc_device_reset_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; + struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_rport_data *rdata; struct lpfc_nodelist *pnode; @@ -6196,7 +6198,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) int status; u32 logit = LOG_FCP; - rdata = lpfc_rport_data_from_scsi_device(cmnd->device); + rdata = rport->dd_data; if (!rdata || !rdata->pnode) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0798 Device Reset rdata failure: rdata x%px\n", @@ -6204,7 +6206,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) return FAILED; } pnode = rdata->pnode; - status = fc_block_scsi_eh(cmnd); + status = fc_block_rport(rport); if (status != 0 && status != SUCCESS) return status; @@ -6261,6 +6263,7 @@ static int lpfc_target_reset_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; + struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_rport_data *rdata; struct lpfc_nodelist *pnode; @@ -6273,7 +6276,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) unsigned long flags; DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); - rdata = lpfc_rport_data_from_scsi_device(cmnd->device); + rdata = rport->dd_data; if (!rdata || !rdata->pnode) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0799 Target Reset rdata failure: rdata x%px\n", @@ -6281,7 +6284,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) return FAILED; } pnode = rdata->pnode; - status = fc_block_scsi_eh(cmnd); + status = fc_block_rport(rport); if (status != 0 && status != SUCCESS) return status; From patchwork Tue Aug 17 09:14:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3F4DC432BE for ; Tue, 17 Aug 2021 09:17:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A5E460FA0 for ; Tue, 17 Aug 2021 09:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239775AbhHQJRs (ORCPT ); Tue, 17 Aug 2021 05:17:48 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47642 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239421AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4EF8120020; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=rxeY5QszmYMOPruGd/89hd4F/74QafagIg/0WVeAxNY=; b=PDCWZbHpxI6sTGq+FEYWMCpkWz9GEKQyidewHfd9vQfByBvb++3I16YdU5Yo2EO6FpnN6b DOHdKLIHtYzjHE12PfY3PcfTLnLApDt5iPpbNR4XXyJsqaQadcK+0dwgx6bS/on8lxPkZG F1XwFuZQ2Kq/5fc0oIXcMEOytEJ3qNo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=rxeY5QszmYMOPruGd/89hd4F/74QafagIg/0WVeAxNY=; b=x71PTpcJyGBR33sgnznv8UgNG2E9mSMkgpjNnIle0Kc2h5n8wFG3bQL9qZHdJOVQAzPnRG 8/FV4ydNot8QbxDw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 477D0A3BA8; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 4405A518CE93; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , James Smart Subject: [PATCH 26/51] lpfc: use rport as argument for lpfc_send_taskmgmt() Date: Tue, 17 Aug 2021 11:14:31 +0200 Message-Id: <20210817091456.73342-27-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of passing in a scsi device we should be using the rport; we already have the target and lun id as parameters, so there's no need to pass the scsi device, too. Signed-off-by: Hannes Reinecke Cc: James Smart Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 0bbf767f7253..78ca8fa9495f 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -5981,7 +5981,7 @@ lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd) /** * lpfc_send_taskmgmt - Generic SCSI Task Mgmt Handler * @vport: The virtual port for which this call is being executed. - * @cmnd: Pointer to scsi_cmnd data structure. + * @rport: Pointer to remote port * @tgt_id: Target ID of remote device. * @lun_id: Lun number for the TMF * @task_mgmt_cmd: type of TMF to send @@ -5994,7 +5994,7 @@ lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd) * 0x2002 - Success. **/ static int -lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, +lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport, unsigned int tgt_id, uint64_t lun_id, uint8_t task_mgmt_cmd) { @@ -6007,7 +6007,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, int ret; int status; - rdata = lpfc_rport_data_from_scsi_device(cmnd->device); + rdata = rport->dd_data; if (!rdata || !rdata->pnode) return FAILED; pnode = rdata->pnode; @@ -6017,7 +6017,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd, return FAILED; lpfc_cmd->timeout = phba->cfg_task_mgmt_tmo; lpfc_cmd->rdata = rdata; - lpfc_cmd->pCmd = cmnd; + lpfc_cmd->pCmd = NULL; lpfc_cmd->ndlp = pnode; status = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun_id, @@ -6226,7 +6226,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) fc_host_post_vendor_event(shost, fc_get_event_number(), sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); - status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id, + status = lpfc_send_taskmgmt(vport, rport, tgt_id, lun_id, FCP_LUN_RESET); if (status != SUCCESS) logit = LOG_TRACE_EVENT; @@ -6312,7 +6312,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) fc_host_post_vendor_event(shost, fc_get_event_number(), sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); - status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id, + status = lpfc_send_taskmgmt(vport, rport, tgt_id, lun_id, FCP_TARGET_RESET); if (status != SUCCESS) { logit = LOG_TRACE_EVENT; From patchwork Tue Aug 17 09:14:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7028C4338F for ; Tue, 17 Aug 2021 09:17:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D03D360F11 for ; Tue, 17 Aug 2021 09:17:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239576AbhHQJRc (ORCPT ); Tue, 17 Aug 2021 05:17:32 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33314 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239322AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5341F21D59; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=uHukD+fxkR3OwfdNORx0IpX5NUC9llmrrM8RXhfaFzs=; b=CzbRbOMgMvL9Rt1IHuMqrJVd06nunvLIChRXusLG5nmGj5/i/OawKBlUpLqGaSA6t5RKfB oJgE02Mkr+LGeW3IfL4YfHet7XtaQoYi8uzV5ZBqixgm87jW+YZgeUYW7Pc5nmSooTlPJt au8I6L+YJjAEGVcl8ILyZyQ+ASgN4Qc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=uHukD+fxkR3OwfdNORx0IpX5NUC9llmrrM8RXhfaFzs=; b=TxmLxvx0HBI7tDavmmS+kQZARimd/whWUHg8p+Jt+T4fiNpEFrwAX91SwNg5BfUgtSV7+z 7G7SMDFxCjXQIZDQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 4D0C2A3BAA; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 4A819518CE95; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , James Smart Subject: [PATCH 27/51] lpfc: use rport as argument for lpfc_chk_tgt_mapped() Date: Tue, 17 Aug 2021 11:14:32 +0200 Message-Id: <20210817091456.73342-28-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We only need the rport structure for lpfc_chk_tgt_mapped(). Signed-off-by: Hannes Reinecke Cc: James Smart Reviewed-by: James Smart --- drivers/scsi/lpfc/lpfc_scsi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 78ca8fa9495f..925f304166f5 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6083,7 +6083,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport, /** * lpfc_chk_tgt_mapped - * @vport: The virtual port to check on - * @cmnd: Pointer to scsi_cmnd data structure. + * @rport: Pointer to fc_rport data structure. * * This routine delays until the scsi target (aka rport) for the * command exists (is present and logged in) or we declare it non-existent. @@ -6093,19 +6093,20 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport, * 0x2002 - Success **/ static int -lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd) +lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct fc_rport *rport) { struct lpfc_rport_data *rdata; - struct lpfc_nodelist *pnode; + struct lpfc_nodelist *pnode = NULL; unsigned long later; - rdata = lpfc_rport_data_from_scsi_device(cmnd->device); + rdata = rport->dd_data; if (!rdata) { lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, "0797 Tgt Map rport failure: rdata x%px\n", rdata); return FAILED; } pnode = rdata->pnode; + /* * If target is not in a MAPPED state, delay until * target is rediscovered or devloss timeout expires. @@ -6117,7 +6118,7 @@ lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd) if (pnode->nlp_state == NLP_STE_MAPPED_NODE) return SUCCESS; schedule_timeout_uninterruptible(msecs_to_jiffies(500)); - rdata = lpfc_rport_data_from_scsi_device(cmnd->device); + rdata = rport->dd_data; if (!rdata) return FAILED; pnode = rdata->pnode; @@ -6210,7 +6211,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) if (status != 0 && status != SUCCESS) return status; - status = lpfc_chk_tgt_mapped(vport, cmnd); + status = lpfc_chk_tgt_mapped(vport, rport); if (status == FAILED) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0721 Device Reset rport failure: rdata x%px\n", rdata); @@ -6288,7 +6289,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) if (status != 0 && status != SUCCESS) return status; - status = lpfc_chk_tgt_mapped(vport, cmnd); + status = lpfc_chk_tgt_mapped(vport, rport); if (status == FAILED) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0722 Target Reset rport failure: rdata x%px\n", rdata); From patchwork Tue Aug 17 09:14:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4948EC4338F for ; Tue, 17 Aug 2021 09:17:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3244260FD7 for ; Tue, 17 Aug 2021 09:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239749AbhHQJRp (ORCPT ); Tue, 17 Aug 2021 05:17:45 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47532 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235288AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 575E220021; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=nMq7QBXKzgEGxvjDNIbW/aZPUnxVffZjRthph4T4fYg=; b=DN3HLqeV3IU6Ah/q27U7wz/xtdYIdHO/jKYcmio5Ne/SUbCNVWcaftUdtCJRYb1QPoYqC5 oFqZ1J4Gye5Hi/WxaunTHZV7MqTvm30MqgqQVCTR64aYFppwXdJJ0eHZ4ct8eeKwQrj2Pz R/Kwb2+HCvlltA1kpN8y7FGuZ6mTVSo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=nMq7QBXKzgEGxvjDNIbW/aZPUnxVffZjRthph4T4fYg=; b=4VNzhPzpjoRLob/cvQLWT9TTa+BA5EnwQAzSY7LCM5JVn/KDOw11ISF5tQmLztuuEUt3oq S9PRw/xnEGlpg6CQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 52EC9A3BAB; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 5043E518CE97; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 28/51] csiostor: use fc_block_rport() Date: Tue, 17 Aug 2021 11:14:33 +0200 Message-Id: <20210817091456.73342-29-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command will be removed as argument for SCSI EH functions. Signed-off-by: Hannes Reinecke --- drivers/scsi/csiostor/csio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index 56b9ad0a1ca0..c22acfc7caba 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -2084,7 +2084,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) } /* Lnode is ready, now wait on rport node readiness */ - ret = fc_block_scsi_eh(cmnd); + ret = fc_block_rport(rn->rport); if (ret) return ret; From patchwork Tue Aug 17 09:14:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C154C4338F for ; Tue, 17 Aug 2021 09:17:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82A6360F11 for ; Tue, 17 Aug 2021 09:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239833AbhHQJR4 (ORCPT ); Tue, 17 Aug 2021 05:17:56 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47650 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235763AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5E33120022; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=FmUgTeGoK/w4qa27iV0FbkPd6fWcx/tup0fu7NnX8nk=; b=ZoDAEWJje4sAUp6218z7PpZxekw46K0bkrWFvKIzwVCj30K6Uf2xXcrDzNT1KBLexrolOv PmnqRtLFPIlK344AzPz0q8ztBD1t5MzsareRZKUJsNT6namXNZF3nB4qXfPc5EWsnJmCf8 kdKU5hyOhXODd4K2Jie/+Bg1yoMUMo0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=FmUgTeGoK/w4qa27iV0FbkPd6fWcx/tup0fu7NnX8nk=; b=RjNcUVbVFUlVdbvhapjX1buwX+qmJqURyRTOAcAw6hWaeu0luaL/A8sW3TvZvz29qBz+Ut wjt0v0GEqsgQ32Ag== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 58CF7A3BAC; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 55E7B518CE99; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Nilesh Javali Subject: [PATCH 29/51] qla2xxx: use fc_block_rport() Date: Tue, 17 Aug 2021 11:14:34 +0200 Message-Id: <20210817091456.73342-30-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command will be removed as argument for SCSI EH functions. Signed-off-by: Hannes Reinecke Cc: Nilesh Javali --- drivers/scsi/qla2xxx/qla_os.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b9cc7cfb5c21..0f2bf06a01d7 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1390,9 +1390,11 @@ static char *reset_errors[] = { static int qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) { - scsi_qla_host_t *vha = shost_priv(cmd->device->host); + struct scsi_device *sdev = cmd->device; + scsi_qla_host_t *vha = shost_priv(sdev->host); struct qla_hw_data *ha = vha->hw; - fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); + fc_port_t *fcport = (struct fc_port *) sdev->hostdata; int err; if (qla2x00_isp_reg_stat(ha)) { @@ -1406,7 +1408,7 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) return FAILED; } - err = fc_block_scsi_eh(cmd); + err = fc_block_rport(rport); if (err != 0) return err; @@ -1456,8 +1458,10 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) static int qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) { - scsi_qla_host_t *vha = shost_priv(cmd->device->host); - fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; + struct scsi_device *sdev = cmd->device; + scsi_qla_host_t *vha = shost_priv(sdev->host); + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); + fc_port_t *fcport = (struct fc_port *) sdev->hostdata; struct qla_hw_data *ha = vha->hw; int err; @@ -1468,14 +1472,14 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) return FAILED; } + err = fc_block_rport(rport); + if (err != 0) + return err; + if (!fcport) { return FAILED; } - err = fc_block_scsi_eh(cmd); - if (err != 0) - return err; - if (fcport->deleted) return SUCCESS; From patchwork Tue Aug 17 09:14:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5401FC4338F for ; Tue, 17 Aug 2021 09:17:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AA4960720 for ; Tue, 17 Aug 2021 09:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239633AbhHQJRf (ORCPT ); Tue, 17 Aug 2021 05:17:35 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33316 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239336AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 631A821D6D; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=jdXgDB17teJ+wfK+5V/p5SOqdNbm0KGqxgHKBai7F9c=; b=Xi/DPc92iLDj9ej0rSYV7jGuc7DdhUXM0ZuBqc24X2VaSf2LuovzwBy6qkn2jnWLbkgGyz 5zJWvkxHrxIby5ItLg5O/Agvp2+/tqZS5PgyIROHNakmAMdSB+eCzN+5q3oHKcOROvG0xD HHj8HKDpHpOqM+rvQfDRZGQKnEIjZQs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=jdXgDB17teJ+wfK+5V/p5SOqdNbm0KGqxgHKBai7F9c=; b=9QV/s7W64qf8drvZ3Yok8xliCgEQ6O1BfF9+GP0yCzSlxiD07b1FNkKHbOL5RWewpv2Ppw qEg9H7UR1fTzlSDg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 5F0E3A3BAD; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 5C3F4518CE9B; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 30/51] fc_fcp: use fc_block_rport() Date: Tue, 17 Aug 2021 11:14:35 +0200 Message-Id: <20210817091456.73342-31-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command will be removed as argument for SCSI EH functions. Signed-off-by: Hannes Reinecke --- drivers/scsi/libfc/fc_fcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index 81e1882efaf0..e4c998efdb9c 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -2161,7 +2161,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) int rc = FAILED; int rval; - rval = fc_block_scsi_eh(sc_cmd); + rval = fc_block_rport(rport); if (rval) return rval; From patchwork Tue Aug 17 09:14:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B26BC43214 for ; Tue, 17 Aug 2021 09:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 856FD60720 for ; Tue, 17 Aug 2021 09:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235212AbhHQJRt (ORCPT ); Tue, 17 Aug 2021 05:17:49 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47534 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239432AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 6B43520023; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=gwQFFobjGKn1eFNVCznnhG0NDDwrqbaBnG1htLXLF4E=; b=qEPghMSw+xkZ8e04iUE+10xKBD9O4kb2/qHg16Bmy/Xs0XB1VV2lcgg2K5WugtyQ+j652/ KA7kw6kXtYdmVQf/igIUgzVqkJRc+Z2pFkTT9GeKOWyxGJ8pErMff5nRUjnnRqZrzLEhOY WuKzqxG9QYvo7zjXV41zODQ/7rkZC1w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=gwQFFobjGKn1eFNVCznnhG0NDDwrqbaBnG1htLXLF4E=; b=nE/j4Ud3l0u2ZVrbNxywJUGew6G8vODwwlaE2Zr3TmKIYutO9ww8pFFui/sO55qi3wtSqQ fTOaVXVbVZkJpkAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 654CFA3BAF; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 6254B518CE9D; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke , Saurav Kashyap Subject: [PATCH 31/51] qedf: use fc rport as argument for qedf_initiate_tmf() Date: Tue, 17 Aug 2021 11:14:36 +0200 Message-Id: <20210817091456.73342-32-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When sending a TMF we're only concerned with the rport and the LUN ID, so use struct fc_rport as argument for qedf_initiate_tmf(). Signed-off-by: Hannes Reinecke Cc: Saurav Kashyap --- drivers/scsi/qedf/qedf.h | 5 ++- drivers/scsi/qedf/qedf_io.c | 80 ++++++++++------------------------- drivers/scsi/qedf/qedf_main.c | 17 ++++---- 3 files changed, 35 insertions(+), 67 deletions(-) diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h index ba94413fe2ea..631ebb59a2ac 100644 --- a/drivers/scsi/qedf/qedf.h +++ b/drivers/scsi/qedf/qedf.h @@ -113,6 +113,7 @@ struct qedf_ioreq { #define QEDF_CMD_ERR_SCSI_DONE 0x5 u8 io_req_flags; uint8_t tm_flags; + u64 tm_lun; struct qedf_rport *fcport; #define QEDF_CMD_ST_INACTIVE 0 #define QEDFC_CMD_ST_IO_ACTIVE 1 @@ -489,7 +490,7 @@ extern void qedf_process_warning_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); extern void qedf_process_error_detect(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); -extern void qedf_flush_active_ios(struct qedf_rport *fcport, int lun); +extern void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun); extern void qedf_release_cmd(struct kref *ref); extern int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts); @@ -514,7 +515,7 @@ extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts); extern void qedf_process_cleanup_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); -extern int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags); +extern int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags); extern void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); extern void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe); diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index 6b5b6a75ac88..f6883bf6461c 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -546,7 +546,7 @@ static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req) } static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req, - struct fcp_cmnd *fcp_cmnd) + struct fcp_cmnd *fcp_cmnd) { struct scsi_cmnd *sc_cmd = io_req->sc_cmd; @@ -554,8 +554,12 @@ static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req, memset(fcp_cmnd, 0, FCP_CMND_LEN); /* 8 bytes: SCSI LUN info */ - int_to_scsilun(sc_cmd->device->lun, - (struct scsi_lun *)&fcp_cmnd->fc_lun); + if (io_req->cmd_type == QEDF_TASK_MGMT_CMD) + int_to_scsilun(io_req->tm_lun, + (struct scsi_lun *)&fcp_cmnd->fc_lun); + else + int_to_scsilun(sc_cmd->device->lun, + (struct scsi_lun *)&fcp_cmnd->fc_lun); /* 4 bytes: flag info */ fcp_cmnd->fc_pri_ta = 0; @@ -1065,8 +1069,9 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, io_req->fcp_resid = fcp_rsp->fcp_resid; io_req->scsi_comp_flags = rsp_flags; - CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = - fcp_rsp->scsi_status_code; + if (sc_cmd) + CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = + fcp_rsp->scsi_status_code; if (rsp_flags & FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID) @@ -1097,7 +1102,7 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, } /* The sense buffer can be NULL for TMF commands */ - if (sc_cmd->sense_buffer) { + if (sc_cmd && sc_cmd->sense_buffer) { memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); if (fcp_sns_len) memcpy(sc_cmd->sense_buffer, sense_data, @@ -1595,7 +1600,7 @@ static void qedf_flush_els_req(struct qedf_ctx *qedf, /* A value of -1 for lun is a wild card that means flush all * active SCSI I/Os for the target. */ -void qedf_flush_active_ios(struct qedf_rport *fcport, int lun) +void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun) { struct qedf_ioreq *io_req; struct qedf_ctx *qedf; @@ -1783,10 +1788,6 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int lun) kref_put(&io_req->refcount, qedf_release_cmd); continue; } - if (lun > -1) { - if (io_req->lun != lun) - continue; - } /* * Use kref_get_unless_zero in the unlikely case the command @@ -2295,7 +2296,7 @@ void qedf_process_cleanup_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, complete(&io_req->cleanup_done); } -static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, +static int qedf_execute_tmf(struct qedf_rport *fcport, u64 tm_lun, uint8_t tm_flags) { struct qedf_ioreq *io_req; @@ -2305,17 +2306,10 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, int rc = 0; uint16_t xid; int tmo = 0; - int lun = 0; unsigned long flags; struct fcoe_wqe *sqe; u16 sqe_idx; - if (!sc_cmd) { - QEDF_ERR(&qedf->dbg_ctx, "sc_cmd is NULL\n"); - return FAILED; - } - - lun = (int)sc_cmd->device->lun; if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n"); rc = FAILED; @@ -2335,7 +2329,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, qedf->target_resets++; /* Initialize rest of io_req fields */ - io_req->sc_cmd = sc_cmd; + io_req->sc_cmd = NULL; io_req->fcport = fcport; io_req->cmd_type = QEDF_TASK_MGMT_CMD; @@ -2349,6 +2343,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, /* Default is to return a SCSI command when an error occurs */ io_req->return_scsi_cmd_on_abts = false; + io_req->tm_lun = tm_lun; /* Obtain exchange id */ xid = io_req->xid; @@ -2403,7 +2398,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, if (tm_flags == FCP_TMF_LUN_RESET) - qedf_flush_active_ios(fcport, lun); + qedf_flush_active_ios(fcport, tm_lun); else qedf_flush_active_ios(fcport, -1); @@ -2418,23 +2413,18 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, return rc; } -int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) +int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags) { - struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); struct fc_rport_libfc_priv *rp = rport->dd_data; struct qedf_rport *fcport = (struct qedf_rport *)&rp[1]; - struct qedf_ctx *qedf; - struct fc_lport *lport = shost_priv(sc_cmd->device->host); + struct qedf_ctx *qedf = fcport->qedf; + struct fc_lport *lport = rp->local_port; int rc = SUCCESS; - int rval; - struct qedf_ioreq *io_req = NULL; - int ref_cnt = 0; struct fc_rport_priv *rdata = fcport->rdata; QEDF_ERR(NULL, - "tm_flags 0x%x sc_cmd %p op = 0x%02x target_id = 0x%x lun=%d\n", - tm_flags, sc_cmd, sc_cmd->cmd_len ? sc_cmd->cmnd[0] : 0xff, - rport->scsi_target_id, (int)sc_cmd->device->lun); + "tm_flags 0x%x target_id = 0x%x lun=%llu\n", + tm_flags, rport->scsi_target_id, lun); if (!rdata || !kref_get_unless_zero(&rdata->kref)) { QEDF_ERR(NULL, "stale rport\n"); @@ -2445,33 +2435,10 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) (tm_flags == FCP_TMF_TGT_RESET) ? "TARGET RESET" : "LUN RESET"); - if (sc_cmd->SCp.ptr) { - io_req = (struct qedf_ioreq *)sc_cmd->SCp.ptr; - ref_cnt = kref_read(&io_req->refcount); - QEDF_ERR(NULL, - "orig io_req = %p xid = 0x%x ref_cnt = %d.\n", - io_req, io_req->xid, ref_cnt); - } - - rval = fc_remote_port_chkready(rport); - if (rval) { - QEDF_ERR(NULL, "device_reset rport not ready\n"); - rc = FAILED; - goto tmf_err; - } - - rc = fc_block_scsi_eh(sc_cmd); + rc = fc_block_rport(rport); if (rc) goto tmf_err; - if (!fcport) { - QEDF_ERR(NULL, "device_reset: rport is NULL\n"); - rc = FAILED; - goto tmf_err; - } - - qedf = fcport->qedf; - if (!qedf) { QEDF_ERR(NULL, "qedf is NULL.\n"); rc = FAILED; @@ -2508,7 +2475,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) goto tmf_err; } - rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags); + rc = qedf_execute_tmf(fcport, lun, tm_flags); tmf_err: kref_put(&rdata->kref, fc_rport_destroy); @@ -2525,7 +2492,6 @@ void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, fcp_rsp = &cqe->cqe_info.rsp_info; qedf_parse_fcp_rsp(io_req, fcp_rsp); - io_req->sc_cmd = NULL; complete(&io_req->tm_done); } diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 38be2e2274a8..bc211d8101e1 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -857,18 +857,19 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd) { - QEDF_ERR(NULL, "%d:0:%d:%lld: TARGET RESET Issued...", - sc_cmd->device->host->host_no, sc_cmd->device->id, - sc_cmd->device->lun); - return qedf_initiate_tmf(sc_cmd, FCP_TMF_TGT_RESET); + struct scsi_target *starget = scsi_target(sc_cmd->device); + struct fc_rport *rport = starget_to_rport(starget); + + QEDF_ERR(NULL, "TARGET RESET Issued..."); + return qedf_initiate_tmf(rport, 0, FCP_TMF_TGT_RESET); } static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) { - QEDF_ERR(NULL, "%d:0:%d:%lld: LUN RESET Issued... ", - sc_cmd->device->host->host_no, sc_cmd->device->id, - sc_cmd->device->lun); - return qedf_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET); + struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + + QEDF_ERR(NULL, "LUN RESET Issued...\n"); + return qedf_initiate_tmf(rport, sc_cmd->device->lun, FCP_TMF_LUN_RESET); } bool qedf_wait_for_upload(struct qedf_ctx *qedf) From patchwork Tue Aug 17 09:14:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BBDFC4338F for ; Tue, 17 Aug 2021 09:17:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66BE660F11 for ; Tue, 17 Aug 2021 09:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239562AbhHQJRu (ORCPT ); Tue, 17 Aug 2021 05:17:50 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47546 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239474AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 71A3220024; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=Y2BFk28My2JNIp6T2foNXVrxjFcL7k+sAuDlYqrlhjo=; b=RqjbO9eUJ8Tebq7UIOcYoduQLv4GEZ2tJxe347Q5r55Jy+AJxJ//zO5dryxHmaWr6pQtio +fV0QpQ8WzuArV791ZXmtL0oL3IEKg3mwZsGDGsHonGEB1UuS5fIs3aKofBclTxUKiEWGn 5uqZ7hHcjRDrlq5PfajUZoErJcSR9CI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=Y2BFk28My2JNIp6T2foNXVrxjFcL7k+sAuDlYqrlhjo=; b=q9ewdiRoXf9EdKwSWKKG9dtFsxcACRM87kqSaSrcuXtKz+8De5YvHNRrrruGVny1qhEAI7 pmiL6LtGbmb3fWDA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 6B99DA3BB0; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 68965518CE9F; Tue, 17 Aug 2021 11:16:42 +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 32/51] sym53c8xx_2: rework reset handling Date: Tue, 17 Aug 2021 11:14:37 +0200 Message-Id: <20210817091456.73342-33-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 2e5ab844fe09..3d00afd8cbca 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -567,7 +567,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; @@ -579,7 +582,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 @@ -597,19 +600,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; @@ -626,23 +617,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_Host *shost, int channel) @@ -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 Tue Aug 17 09:14:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 171A6C43214 for ; Tue, 17 Aug 2021 09:17:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F35A260720 for ; Tue, 17 Aug 2021 09:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235993AbhHQJRm (ORCPT ); Tue, 17 Aug 2021 05:17:42 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33326 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239383AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 79B1721D71; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=7/qqau6iRJhTarNpzpM+BK4TSRMqSL+XqvwgHs6oQh0=; b=speac0dmF1hsnP1ucTP992OdsscbEhvNqmOCkhkk8/q8cji6sXqBnldKakx+q+suvJuDGa oRVy3mouEjkDgg5D1dLM8V8coRrSYsoKYeUIQzWoJCv1KUjWB/nIQpSCypiugKsoMXoy1L cIDFQhAKX4B23+ARtjvZsvvpB/T+aSc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=7/qqau6iRJhTarNpzpM+BK4TSRMqSL+XqvwgHs6oQh0=; b=4pUcrtCoFo50jbKKvliF+wKq0FCU5bDZKzSdRZ41gDXtFQHufADyL4TZRbfu/RrNb8Y/2e u+CJ1q9iDc3EzfCA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 72D9DA3BB1; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 6F927518CEA1; Tue, 17 Aug 2021 11:16:42 +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 33/51] bfa: Do not use scsi command to signal TMF status Date: Tue, 17 Aug 2021 11:14:38 +0200 Message-Id: <20210817091456.73342-34-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 | 109 ++++++++++++++++++++----------------- drivers/scsi/bfa/bfad_im.h | 2 + 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 6b5841b1c06e..0cd5f5d7cc6b 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -147,13 +147,12 @@ 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; - cmnd->SCp.Status |= tsk_status << 1; - set_bit(IO_DONE_BIT, (unsigned long *)&cmnd->SCp.Status); - wq = (wait_queue_head_t *) cmnd->SCp.ptr; - cmnd->SCp.ptr = 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 +237,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 +254,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; - cmnd->SCp.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 +284,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 +300,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 +322,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; - cmnd->SCp.ptr = (char *)&wq; - cmnd->SCp.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,15 +338,16 @@ 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, - (unsigned long *)&cmnd->SCp.Status)); - - task_status = cmnd->SCp.Status >> 1; + wait_event(wq, test_bit(IO_DONE_BIT, &itnim_data->tmf_status)); + spin_lock_irqsave(&bfad->bfad_lock, flags); + itnim_data->tmf_wq = NULL; + task_status = itnim_data->tmf_status >> 1; + spin_unlock_irqrestore(&bfad->bfad_lock, flags); if (task_status != BFI_TSKIM_STS_OK) { BFA_LOG(KERN_ERR, bfad, bfa_log_level, "LUN reset failure, status: %d\n", task_status); @@ -367,37 +364,49 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) static int 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 Scsi_Host *shost = rport_to_shost(rport); + struct bfad_itnim_data_s *itnim_data; + struct bfad_itnim_s *itnim; 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; 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) { - cmnd->SCp.ptr = (char *)&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, - (unsigned long *)&cmnd->SCp.Status)); - spin_lock_irqsave(&bfad->bfad_lock, flags); + 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; - task_status = cmnd->SCp.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; - } + 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 f16d4b219e44..93fffd4e13bd 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -45,6 +45,8 @@ u32 bfad_im_supported_speeds(struct bfa_s *bfa); 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 Tue Aug 17 09:14:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BC30C432BE for ; Tue, 17 Aug 2021 09:17:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 472E760F11 for ; Tue, 17 Aug 2021 09:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239856AbhHQJSA (ORCPT ); Tue, 17 Aug 2021 05:18:00 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47664 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239488AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 7DC5020025; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=jwU5Uji0VGmmIm0tuyQivcxGQu+jcrA2PzTb90fYs9c=; b=ewpO802Cevls+dsg1YHaHOzCo7q2o1MuN5HtzZVNuwSOHb3jIRgJXd4+bCXPBHZAddGMMf ftKjlZ6UZk8VQs1y4UoDYw2nA5JWDkyJFCsDMbNCeR2Dkiznn6C5JUQUZI8NlvsPCxSsK8 vnn33r+vxlFpnAGyK/5TSHVMl2LlPi0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=jwU5Uji0VGmmIm0tuyQivcxGQu+jcrA2PzTb90fYs9c=; b=JCUQ2JHbwFbOQVnZtmiWBJMzOpF6Bq0F7Zh1OaVIztQLOkd/UPbdA6nxgSk5StWOfVSaL0 4tpnHqPfENIJbVAQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 77FC8A3BB2; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 7594D518CEA3; Tue, 17 Aug 2021 11:16:42 +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 34/51] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Date: Tue, 17 Aug 2021 11:14:39 +0200 Message-Id: <20210817091456.73342-35-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 --- 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 f4b046867627..130bc0c58c2e 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 b07105ae7c91..7eac4a003541 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1868,17 +1868,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 c5d7810fd792..50d714c05440 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -453,7 +453,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 Tue Aug 17 09:14:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A71A2C4338F for ; Tue, 17 Aug 2021 09:17:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FD1760720 for ; Tue, 17 Aug 2021 09:17:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239790AbhHQJRv (ORCPT ); Tue, 17 Aug 2021 05:17:51 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47556 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239475AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 84F7F20026; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=0vwyJBWng0TPVjo41nAhl0juWjGVuG5WfGU5eoZAWu0=; b=n6mO7tNtOuJ2l30izjUJBx8ReE7pXn7ETrYFmxWSdTl9jry6idTAvywsBrPdhWhNFoISXa gQqsmlNQ4TSc4X+y2jNEmXEBHFV/K2mO6APIWw6U5TAYuBAuUQNw6ZBSg59WEYmxW6Qekf pFKJa9YA2sq3u1BA11t+3kJOxRpOcBY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=0vwyJBWng0TPVjo41nAhl0juWjGVuG5WfGU5eoZAWu0=; b=uiZCJ4W5gFsCcsszA5LF4g28BpQEFPDAent4mnTDUuOJdQJgltZodB52w2kj+DOD2hZj4Q o42A/Z5OlFG/AsBA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 7ED43A3BB3; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 7BF86518CEA5; Tue, 17 Aug 2021 11:16:42 +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 35/51] pmcraid: select first available device for target reset Date: Tue, 17 Aug 2021 11:14:40 +0200 Message-Id: <20210817091456.73342-36-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 --- 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 9397eaef0bac..27a625be7618 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3063,9 +3063,21 @@ static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel) 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 Tue Aug 17 09:14:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E7EEC4338F for ; Tue, 17 Aug 2021 09:17:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33EC460F11 for ; Tue, 17 Aug 2021 09:17:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbhHQJSB (ORCPT ); Tue, 17 Aug 2021 05:18:01 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33372 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239473AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 905E521D73; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=dhi9VkKEY7uSLtNEoyTu+Shs487uElmpTehAYr/0ly0=; b=q8IjjmvxodfhBIOYnfIjZM02589+Xtd7jWiojEuD43UXFptjp1DzzM1FG6As3COaA3ckJC P+1e5M+gLD/QhNjeUs1T2FJNHV1Rxex/8vbJdSGt8j2jZJuhNEDyCT7KOC3PAJfj2RwE6J iunUzqSeqhNNipkhXtfMUrA5P1q8CeI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=dhi9VkKEY7uSLtNEoyTu+Shs487uElmpTehAYr/0ly0=; b=giFT3U2F4vR5J5tsoQuT/DMSm57EKQCo0bY8K5dC9DDNwmK/m/Nll6JEL0Xx4xlgnFfQvz Db3E8s+SKhDdGjAQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 88683A3BB4; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 84CFD518CEA7; Tue, 17 Aug 2021 11:16:42 +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 36/51] scsi: Use scsi_target as argument for eh_target_reset_handler() Date: Tue, 17 Aug 2021 11:14:41 +0200 Message-Id: <20210817091456.73342-37-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The target reset function should only depend on the scsi target, not the scsi command. Signed-off-by: Hannes Reinecke Reviewed-by: James Smart --- Documentation/scsi/scsi_eh.rst | 10 ++++ Documentation/scsi/scsi_mid_low_api.rst | 18 +++++++ drivers/message/fusion/mptsas.c | 10 +++- drivers/message/fusion/mptscsih.c | 27 ++++------ drivers/message/fusion/mptscsih.h | 2 +- drivers/message/fusion/mptspi.c | 8 ++- drivers/s390/scsi/zfcp_scsi.c | 7 ++- drivers/scsi/aacraid/linit.c | 9 ++-- drivers/scsi/be2iscsi/be_main.c | 4 +- drivers/scsi/bfa/bfad_im.c | 3 +- drivers/scsi/bnx2fc/bnx2fc.h | 2 +- drivers/scsi/bnx2fc/bnx2fc_io.c | 4 +- drivers/scsi/esas2r/esas2r.h | 2 +- drivers/scsi/esas2r/esas2r_main.c | 38 +++++++------- drivers/scsi/ibmvscsi/ibmvfc.c | 3 +- drivers/scsi/libiscsi.c | 4 +- drivers/scsi/libsas/sas_scsi_host.c | 9 ++-- drivers/scsi/lpfc/lpfc_scsi.c | 10 ++-- drivers/scsi/megaraid/megaraid_sas.h | 3 +- drivers/scsi/megaraid/megaraid_sas_base.c | 10 ++-- drivers/scsi/megaraid/megaraid_sas_fusion.c | 56 +++++++++++++-------- drivers/scsi/mpi3mr/mpi3mr_os.c | 34 +++++-------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 38 +++++++------- drivers/scsi/pmcraid.c | 8 +-- drivers/scsi/qedf/qedf_main.c | 3 +- drivers/scsi/qla2xxx/qla_os.c | 38 +++++++------- drivers/scsi/qla4xxx/ql4_os.c | 14 +++--- drivers/scsi/scsi_debug.c | 21 +++----- drivers/scsi/scsi_error.c | 5 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 3 +- drivers/target/loopback/tcm_loop.c | 9 ++-- include/scsi/libiscsi.h | 2 +- include/scsi/libsas.h | 2 +- include/scsi/scsi_host.h | 2 +- 34 files changed, 226 insertions(+), 192 deletions(-) diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst index cf0649e0c3a9..e09c81a54702 100644 --- a/Documentation/scsi/scsi_eh.rst +++ b/Documentation/scsi/scsi_eh.rst @@ -215,6 +215,7 @@ considered to fail always. int (* eh_abort_handler)(struct scsi_cmnd *); int (* eh_device_reset_handler)(struct scsi_cmnd *); + int (* eh_target_reset_handler)(struct scsi_target *); int (* eh_bus_reset_handler)(struct Scsi_Host *, int); int (* eh_host_reset_handler)(struct Scsi_Host *); @@ -410,6 +411,15 @@ scmd->allowed. resetting clears all scmds on the sdev, there is no need to choose error-completed scmds. + 2. If !list_empty(&eh_work_q), invoke scsi_eh_target_reset(). + + ``scsi_eh_target_reset`` + + hostt->eh_target_reset_handler() is invoked for each target + with failed scmds. If bus reset succeeds, all failed + scmds on all ready or offline sdevs on the target are + EH-finished. + 3. If !list_empty(&eh_work_q), invoke scsi_eh_bus_reset() ``scsi_eh_bus_reset`` diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst index 1b1c37445580..0afc1b4f89af 100644 --- a/Documentation/scsi/scsi_mid_low_api.rst +++ b/Documentation/scsi/scsi_mid_low_api.rst @@ -758,6 +758,24 @@ Details:: int eh_bus_reset_handler(struct Scsi_Host * host, int channel) + /** + * eh_target_reset_handler - issue SCSI target reset + * @starget: identifies SCSI target to be reset + * + * Returns SUCCESS if command aborted else FAILED + * + * Locks: None held + * + * Calling context: kernel thread + * + * Notes: Invoked from scsi_eh thread. No other commands will be + * queued on current host during eh. + * + * Optionally defined in: LLD + **/ + int eh_target_reset_handler(struct scsi_target * starget) + + /** * eh_device_reset_handler - issue SCSI device reset * @scp: identifies SCSI device to be reset diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 85285ba8e817..83ab080681a7 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1997,6 +1997,14 @@ static enum blk_eh_timer_return mptsas_eh_timed_out(struct scsi_cmnd *sc) } +static int mptsas_eh_target_reset(struct scsi_target *starget) +{ + struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent); + MPT_ADAPTER *ioc = rphy_to_ioc(rphy); + + return mptscsih_target_reset(ioc->sh, starget); +} + static struct scsi_host_template mptsas_driver_template = { .module = THIS_MODULE, .proc_name = "mptsas", @@ -2012,7 +2020,7 @@ static struct scsi_host_template mptsas_driver_template = { .change_queue_depth = mptscsih_change_queue_depth, .eh_timed_out = mptsas_eh_timed_out, .eh_abort_handler = mptscsih_abort, - .eh_device_reset_handler = mptscsih_dev_reset, + .eh_target_reset_handler = mptsas_eh_target_reset, .eh_host_reset_handler = mptscsih_host_reset, .bios_param = mptscsih_bios_param, .can_queue = MPT_SAS_CAN_QUEUE, diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index c1f6aeae514d..537eafd3ae3a 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1854,48 +1854,43 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) * Returns SUCCESS or FAILED. **/ int -mptscsih_target_reset(struct scsi_cmnd * SCpnt) +mptscsih_target_reset(struct Scsi_Host *shost, struct scsi_target * starget) { MPT_SCSI_HOST *hd; int retval; - VirtDevice *vdevice; + VirtTarget *vtarget; MPT_ADAPTER *ioc; /* If we can't locate our host adapter structure, return FAILED status. */ - if ((hd = shost_priv(SCpnt->device->host)) == NULL){ - printk(KERN_ERR MYNAM ": target reset: " - "Can't locate host! (sc=%p)\n", SCpnt); + if ((hd = shost_priv(shost)) == NULL){ + printk(KERN_ERR MYNAM ": target reset: Can't locate host!\n"); return FAILED; } ioc = hd->ioc; - printk(MYIOC_s_INFO_FMT "attempting target reset! (sc=%p)\n", - ioc->name, SCpnt); - scsi_print_command(SCpnt); - - vdevice = SCpnt->device->hostdata; - if (!vdevice || !vdevice->vtarget) { + printk(MYIOC_s_INFO_FMT "attempting target reset!\n", ioc->name); + vtarget = starget->hostdata; + if (!vtarget) { retval = 0; goto out; } /* Target reset to hidden raid component is not supported */ - if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { + if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { retval = FAILED; goto out; } retval = mptscsih_IssueTaskMgmt(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, - vdevice->vtarget->channel, - vdevice->vtarget->id, 0, 0, + vtarget->channel, vtarget->id, 0, 0, mptscsih_get_tm_timeout(ioc)); out: - printk (MYIOC_s_INFO_FMT "target reset: %s (sc=%p)\n", - ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); + printk (MYIOC_s_INFO_FMT "target reset: %s\n", + ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" )); if (retval == 0) return SUCCESS; diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 54f260482f77..a5069a84c8ca 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -120,7 +120,7 @@ extern void mptscsih_slave_destroy(struct scsi_device *device); extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt); -extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt); +extern int mptscsih_target_reset(struct Scsi_Host *, struct scsi_target *); extern int mptscsih_bus_reset(struct Scsi_Host *, int); extern int mptscsih_host_reset(struct Scsi_Host *sh); extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]); diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index af0ce5611e4a..0034660bda54 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -820,6 +820,12 @@ static void mptspi_slave_destroy(struct scsi_device *sdev) mptscsih_slave_destroy(sdev); } +static int mptspi_eh_target_reset(struct scsi_target *starget) +{ + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + return mptscsih_target_reset(shost, starget); +} + static struct scsi_host_template mptspi_driver_template = { .module = THIS_MODULE, .proc_name = "mptspi", @@ -834,7 +840,7 @@ static struct scsi_host_template mptspi_driver_template = { .slave_destroy = mptspi_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptscsih_abort, - .eh_device_reset_handler = mptscsih_dev_reset, + .eh_target_reset_handler = mptspi_eh_target_reset, .eh_bus_reset_handler = mptscsih_bus_reset, .eh_host_reset_handler = mptscsih_host_reset, .bios_param = mptscsih_bios_param, diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 8bfa8ffd9ff6..6492c3b1b12f 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -340,9 +340,12 @@ static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) return zfcp_scsi_task_mgmt_function(sdev, FCP_TMF_LUN_RESET); } -static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) +/* + * Note: We need to select a LUN as the storage array doesn't + * necessarily supports LUN 0 and might refuse the target reset. + */ +static int zfcp_scsi_eh_target_reset_handler(struct scsi_target *starget) { - struct scsi_target *starget = scsi_target(scpnt->device); struct fc_rport *rport = starget_to_rport(starget); struct Scsi_Host *shost = rport_to_shost(rport); struct scsi_device *sdev = NULL, *tmp_sdev; diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index ae3bc94fc571..a41caca5f921 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -960,10 +960,9 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd) * @scsi_cmd: SCSI command block causing the reset * */ -static int aac_eh_target_reset(struct scsi_cmnd *cmd) +static int aac_eh_target_reset(struct scsi_target *starget) { - struct scsi_device * dev = cmd->device; - struct Scsi_Host * host = dev->host; + struct Scsi_Host * host = dev_to_shost(&starget->dev); struct aac_dev * aac = (struct aac_dev *)host->hostdata; struct aac_hba_map_info *info; int count; @@ -973,8 +972,8 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd) int status; u8 command; - bus = aac_logical_to_phys(scmd_channel(cmd)); - cid = scmd_id(cmd); + bus = aac_logical_to_phys(starget->channel); + cid = starget->id; if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS) return FAILED; diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index d76902c4128c..8d65061fc15b 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -367,11 +367,11 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) return rc; } -static int beiscsi_eh_session_reset(struct scsi_cmnd *sc) +static int beiscsi_eh_session_reset(struct scsi_target *starget) { struct iscsi_cls_session *cls_session; - cls_session = starget_to_session(scsi_target(sc->device)); + cls_session = starget_to_session(starget); return iscsi_eh_session_reset(cls_session); } diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 0cd5f5d7cc6b..6169cc5d245f 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -362,9 +362,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) * Scsi_Host template entry, resets the target and abort all commands. */ static int -bfad_im_reset_target_handler(struct scsi_cmnd *cmnd) +bfad_im_reset_target_handler(struct scsi_target *starget) { - struct scsi_target *starget = scsi_target(cmnd->device); struct fc_rport *rport = starget_to_rport(starget); struct Scsi_Host *shost = rport_to_shost(rport); struct bfad_itnim_data_s *itnim_data; diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 4e0434f70092..34ee55239947 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -546,7 +546,7 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req, void bnx2fc_add_2_sq(struct bnx2fc_rport *tgt, u16 xid); void bnx2fc_ring_doorbell(struct bnx2fc_rport *tgt); int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd); -int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd); +int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt); int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd); void bnx2fc_rport_event_handler(struct fc_lport *lport, struct fc_rport_priv *rport, diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 28e858325d38..b59673932cf4 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -1058,9 +1058,9 @@ int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req) * Set from SCSI host template to send task mgmt command to the target * and wait for the response */ -int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd) +int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt) { - struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + struct fc_rport *rport = starget_to_rport(sc_tgt); struct fc_lport *lport = shost_priv(rport_to_shost(rport)); return bnx2fc_initiate_tmf(lport, rport, 0, FCP_TMF_TGT_RESET); diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index 5c1eeaffc090..56d8ff63372a 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -978,7 +978,7 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd); int esas2r_device_reset(struct scsi_cmnd *cmd); int esas2r_host_reset(struct Scsi_Host *shost); int esas2r_bus_reset(struct Scsi_Host *shost, int channel); -int esas2r_target_reset(struct scsi_cmnd *cmd); +int esas2r_target_reset(struct scsi_target *starget); /* Internal functions */ int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid, diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 72af1fed419e..9f6ceb2cd554 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1101,10 +1101,11 @@ int esas2r_bus_reset(struct Scsi_Host *shost, int channel) return esas2r_host_bus_reset(shost, false); } -static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset) +static int esas2r_dev_targ_reset(struct Scsi_Host *shost, int id, u64 lun, + bool target_reset) { struct esas2r_adapter *a = - (struct esas2r_adapter *)cmd->device->host->hostdata; + (struct esas2r_adapter *)shost->hostdata; struct esas2r_request *rq; u8 task_management_status = RS_PENDING; bool completed; @@ -1118,34 +1119,30 @@ static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset) if (target_reset) { esas2r_log(ESAS2R_LOG_CRIT, "unable to allocate a request for a " - "target reset (%d)!", - cmd->device->id); + "target reset (%d)!", id); } else { esas2r_log(ESAS2R_LOG_CRIT, "unable to allocate a request for a " - "device reset (%d:%llu)!", - cmd->device->id, - cmd->device->lun); + "device reset (%d:%llu)!", id, lun); } return FAILED; } - rq->target_id = cmd->device->id; - rq->vrq->scsi.flags |= cpu_to_le32(cmd->device->lun); + rq->target_id = id; + rq->vrq->scsi.flags |= cpu_to_le32(lun); rq->req_stat = RS_PENDING; rq->comp_cb = complete_task_management_request; rq->task_management_status_ptr = &task_management_status; if (target_reset) { - esas2r_debug("issuing target reset (%p) to id %d", rq, - cmd->device->id); + esas2r_debug("issuing target reset (%p) to id %d", rq, id); completed = esas2r_send_task_mgmt(a, rq, 0x20); } else { - esas2r_debug("issuing device reset (%p) to id %d lun %d", rq, - cmd->device->id, cmd->device->lun); + esas2r_debug("issuing device reset (%p) to id %d lun %llu", rq, + id, lun); completed = esas2r_send_task_mgmt(a, rq, 0x10); } @@ -1179,17 +1176,22 @@ static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset) int esas2r_device_reset(struct scsi_cmnd *cmd) { - esas2r_log(ESAS2R_LOG_INFO, "device_reset (%p)", cmd); + struct scsi_device *sdev = cmd->device; + struct Scsi_Host *shost = sdev->host; + + esas2r_log(ESAS2R_LOG_INFO, "device_reset"); - return esas2r_dev_targ_reset(cmd, false); + return esas2r_dev_targ_reset(shost, sdev->id, sdev->lun, false); } -int esas2r_target_reset(struct scsi_cmnd *cmd) +int esas2r_target_reset(struct scsi_target *starget) { - esas2r_log(ESAS2R_LOG_INFO, "target_reset (%p)", cmd); + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + + esas2r_log(ESAS2R_LOG_INFO, "target_reset"); - return esas2r_dev_targ_reset(cmd, true); + return esas2r_dev_targ_reset(shost, starget->id, 0, true); } void esas2r_log_request_failure(struct esas2r_adapter *a, diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 1a5e2c2cc189..0d63bc193fee 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2916,9 +2916,8 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data) * Returns: * SUCCESS / FAST_IO_FAIL / FAILED **/ -static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd) +static int ibmvfc_eh_target_reset_handler(struct scsi_target *starget) { - struct scsi_target *starget = scsi_target(cmd->device); struct fc_rport *rport = starget_to_rport(starget); struct Scsi_Host *shost = rport_to_shost(rport); struct ibmvfc_host *vhost = shost_priv(shost); diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 0006a3692c9a..14ecbeb738f2 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2631,12 +2631,12 @@ static int iscsi_eh_target_reset(struct iscsi_cls_session *cls_session) * This will attempt to send a warm target reset. If that fails, * we will escalate to ERL0 session recovery. */ -int iscsi_eh_recover_target(struct scsi_cmnd *sc) +int iscsi_eh_recover_target(struct scsi_target *starget) { struct iscsi_cls_session *cls_session; int rc; - cls_session = starget_to_session(scsi_target(sc->device)); + cls_session = starget_to_session(starget); rc = iscsi_eh_target_reset(cls_session); if (rc == FAILED) rc = iscsi_eh_session_reset(cls_session); diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 5db10248f187..778cd93ee007 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -512,11 +512,12 @@ int sas_eh_device_reset_handler(struct scsi_cmnd *cmd) return FAILED; } -int sas_eh_target_reset_handler(struct scsi_cmnd *cmd) +int sas_eh_target_reset_handler(struct scsi_target *starget) { int res; - struct Scsi_Host *host = cmd->device->host; - struct domain_device *dev = cmd_to_domain_dev(cmd); + struct domain_device *dev = starget_to_domain_dev(starget); + struct sas_rphy *rphy = dev->rphy; + struct Scsi_Host *host = dev_to_shost(rphy->dev.parent); struct sas_internal *i = to_sas_internal(host->transportt); if (current != host->ehandler) @@ -548,7 +549,7 @@ static int try_to_reset_cmd_device(struct scsi_cmnd *cmd) try_target_reset: if (shost->hostt->eh_target_reset_handler) - return shost->hostt->eh_target_reset_handler(cmd); + return shost->hostt->eh_target_reset_handler(scsi_target(cmd->device)); return FAILED; } diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 925f304166f5..1b94fb7e4259 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6261,15 +6261,15 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) * 0x2002 - Success **/ static int -lpfc_target_reset_handler(struct scsi_cmnd *cmnd) +lpfc_target_reset_handler(struct scsi_target *starget) { - struct Scsi_Host *shost = cmnd->device->host; - struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); + struct fc_rport *rport = starget_to_rport(starget); + struct Scsi_Host *shost = rport_to_shost(rport); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_rport_data *rdata; struct lpfc_nodelist *pnode; - unsigned tgt_id = cmnd->device->id; - uint64_t lun_id = cmnd->device->lun; + unsigned tgt_id = starget->id; + uint64_t lun_id = 0; struct lpfc_scsi_event_header scsi_event; int status; u32 logit = LOG_FCP; diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 7af2c23652b0..67ad41725819 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -2708,7 +2708,8 @@ void megasas_setup_jbod_map(struct megasas_instance *instance); void megasas_update_sdev_properties(struct scsi_device *sdev); int megasas_reset_fusion(struct Scsi_Host *shost, int reason); int megasas_task_abort_fusion(struct scsi_cmnd *scmd); -int megasas_reset_target_fusion(struct scsi_cmnd *scmd); +int megasas_reset_target_fusion(struct Scsi_Host *shost, + struct scsi_target *starget); u32 mega_mod64(u64 dividend, u32 divisor); int megasas_alloc_fusion_context(struct megasas_instance *instance); void megasas_free_fusion_context(struct megasas_instance *instance); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 618a5488c4d6..f8c40782d6bc 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3105,17 +3105,19 @@ static int megasas_task_abort(struct scsi_cmnd *scmd) * (supported only for fusion adapters) * @scmd: SCSI command pointer */ -static int megasas_reset_target(struct scsi_cmnd *scmd) +static int megasas_reset_target(struct scsi_target *starget) { + struct Scsi_Host *shost = dev_to_shost(&starget->dev); int ret; struct megasas_instance *instance; - instance = (struct megasas_instance *)scmd->device->host->hostdata; + instance = (struct megasas_instance *)shost->hostdata; if (instance->adapter_type != MFI_SERIES) - ret = megasas_reset_target_fusion(scmd); + ret = megasas_reset_target_fusion(shost, starget); else { - sdev_printk(KERN_NOTICE, scmd->device, "TARGET RESET not supported\n"); + starget_printk(KERN_NOTICE, starget, + "TARGET RESET not supported\n"); ret = FAILED; } diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 06399c026a8d..22f6bf8324c6 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -4764,21 +4764,25 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd) /* * megasas_reset_target_fusion : target reset function for fusion adapters - * scmd: SCSI command pointer + * shost: SCSI host pointer + * starget: SCSI target pointer * * Returns SUCCESS if all commands associated with target aborted else FAILED */ -int megasas_reset_target_fusion(struct scsi_cmnd *scmd) +int megasas_reset_target_fusion(struct Scsi_Host *shost, + struct scsi_target *starget) { struct megasas_instance *instance; + struct scsi_device *sdev; int ret = FAILED; - u16 devhandle; - struct MR_PRIV_DEVICE *mr_device_priv_data; - mr_device_priv_data = scmd->device->hostdata; + u16 devhandle = USHRT_MAX; + struct MR_PRIV_DEVICE *mr_device_priv_data = NULL; - instance = (struct megasas_instance *)scmd->device->host->hostdata; + instance = (struct megasas_instance *)shost->hostdata; + starget_printk(KERN_INFO, starget, + "target reset called\n"); if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," @@ -4787,44 +4791,52 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd) return ret; } + shost_for_each_device(sdev, shost) { + if (!sdev->hostdata) + continue; + mr_device_priv_data = sdev->hostdata; + if (mr_device_priv_data->is_tm_capable) { + devhandle = megasas_get_tm_devhandle(sdev); + break; + } + } + if (!mr_device_priv_data) { - sdev_printk(KERN_INFO, scmd->device, - "device been deleted! scmd: (0x%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; + starget_printk(KERN_INFO, starget, + "all devices have been deleted\n"); ret = SUCCESS; goto out; } if (!mr_device_priv_data->is_tm_capable) { + ret = SUCCESS; + goto out; + } else if (!mr_device_priv_data->is_tm_capable) { ret = FAILED; goto out; } mutex_lock(&instance->reset_mutex); - devhandle = megasas_get_tm_devhandle(scmd->device); - - if (devhandle == (u16)ULONG_MAX) { - ret = SUCCESS; - sdev_printk(KERN_INFO, scmd->device, + if (devhandle == USHRT_MAX) { + starget_printk(KERN_INFO, starget, "target reset issued for invalid devhandle\n"); mutex_unlock(&instance->reset_mutex); - goto out; + return SUCCESS; } - sdev_printk(KERN_INFO, scmd->device, - "attempting target reset! scmd(0x%p) tm_dev_handle: 0x%x\n", - scmd, devhandle); + starget_printk(KERN_INFO, starget, + "attempting target reset! tm_dev_handle: 0x%x\n", + devhandle); mr_device_priv_data->tm_busy = true; ret = megasas_issue_tm(instance, devhandle, - scmd->device->channel, scmd->device->id, 0, + starget->channel, starget->id, 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, mr_device_priv_data); mr_device_priv_data->tm_busy = false; mutex_unlock(&instance->reset_mutex); - scmd_printk(KERN_NOTICE, scmd, "target reset %s!!\n", - (ret == SUCCESS) ? "SUCCESS" : "FAILED"); - out: + starget_printk(KERN_NOTICE, starget, "target reset %s!!\n", + (ret == SUCCESS) ? "SUCCESS" : "FAILED"); return ret; } diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 30d8482ddc7f..768af4d36037 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2949,7 +2949,7 @@ static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel) /** * mpi3mr_eh_target_reset - Target reset error handling callback - * @scmd: SCSI command reference + * @starget: SCSI target reference * * Issue Target reset Task Management and verify the scmd is * terminated successfully and return status accordingly. @@ -2957,36 +2957,28 @@ static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel) * Return: SUCCESS of successful termination of the scmd else * FAILED */ -static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd) +static int mpi3mr_eh_target_reset(struct scsi_target *starget) { - struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); struct mpi3mr_stgt_priv_data *stgt_priv_data; - struct mpi3mr_sdev_priv_data *sdev_priv_data; u16 dev_handle; u8 resp_code = 0; int retval = FAILED, ret = 0; - sdev_printk(KERN_INFO, scmd->device, - "Attempting Target Reset! scmd(%p)\n", scmd); - scsi_print_command(scmd); - - sdev_priv_data = scmd->device->hostdata; - if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { - sdev_printk(KERN_INFO, scmd->device, - "SCSI device is not available\n"); - retval = SUCCESS; - goto out; - } + starget_printk(KERN_INFO, starget, + "Attempting Target Reset!\n"); - stgt_priv_data = sdev_priv_data->tgt_priv_data; + stgt_priv_data = (struct mpi3mr_stgt_priv_data *) + starget->hostdata; dev_handle = stgt_priv_data->dev_handle; - sdev_printk(KERN_INFO, scmd->device, + starget_printk(KERN_INFO, starget, "Target Reset is issued to handle(0x%04x)\n", dev_handle); ret = mpi3mr_issue_tm(mrioc, MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET, dev_handle, - sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS, + /* lun */0, MPI3MR_HOSTTAG_BLK_TMS, MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL); if (ret) @@ -2994,9 +2986,9 @@ static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd) retval = SUCCESS; out: - sdev_printk(KERN_INFO, scmd->device, - "Target reset is %s for scmd(%p)\n", - ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + starget_printk(KERN_INFO, starget, + "Target reset is %s\n", + ((retval == SUCCESS) ? "SUCCESS" : "FAILED")); return retval; } diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index eea67589d787..bf6c924d673a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3446,9 +3446,11 @@ scsih_dev_reset(struct scsi_cmnd *scmd) * Return: SUCCESS if command aborted else FAILED */ static int -scsih_target_reset(struct scsi_cmnd *scmd) +scsih_target_reset(struct scsi_target *starget) { - struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + struct scsi_device *sdev = NULL, *tmp_sdev; + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); struct MPT3SAS_DEVICE *sas_device_priv_data; struct _sas_device *sas_device = NULL; struct _pcie_device *pcie_device = NULL; @@ -3456,20 +3458,21 @@ scsih_target_reset(struct scsi_cmnd *scmd) u8 tr_method = 0; u8 tr_timeout = 30; int r; - struct scsi_target *starget = scmd->device->sdev_target; struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; - starget_printk(KERN_INFO, starget, - "attempting target reset! scmd(0x%p)\n", scmd); - _scsih_tm_display_info(ioc, scmd); + starget_printk(KERN_INFO, starget, "attempting target reset!\n"); - sas_device_priv_data = scmd->device->hostdata; - if (!sas_device_priv_data || !sas_device_priv_data->sas_target || - ioc->remove_host) { - starget_printk(KERN_INFO, starget, - "target been deleted! scmd(0x%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; - scmd->scsi_done(scmd); + shost_for_each_device(tmp_sdev, shost) { + if (scsi_target(tmp_sdev) == starget) { + if (!tmp_sdev->hostdata) + continue; + sdev = tmp_sdev; + break; + } + } + sas_device_priv_data = sdev->hostdata; + if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { + starget_printk(KERN_INFO, starget, "target been deleted!\n"); r = SUCCESS; goto out; } @@ -3486,7 +3489,6 @@ scsih_target_reset(struct scsi_cmnd *scmd) handle = sas_device_priv_data->sas_target->handle; if (!handle) { - scmd->result = DID_RESET << 16; r = FAILED; goto out; } @@ -3499,16 +3501,16 @@ scsih_target_reset(struct scsi_cmnd *scmd) tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE; } else tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET; - r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, - scmd->device->id, 0, + r = mpt3sas_scsih_issue_locked_tm(ioc, handle, starget->channel, + starget->id, 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 0, tr_timeout, tr_method); /* Check for busy commands after reset */ if (r == SUCCESS && atomic_read(&starget->target_busy)) r = FAILED; out: - starget_printk(KERN_INFO, starget, "target reset: %s scmd(0x%p)\n", - ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + starget_printk(KERN_INFO, starget, "target reset: %s\n", + ((r == SUCCESS) ? "SUCCESS" : "FAILED")); if (sas_device) sas_device_put(sas_device); diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 27a625be7618..8a5c49eed94e 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3061,14 +3061,14 @@ static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel) RESET_DEVICE_BUS); } -static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) +static int pmcraid_eh_target_reset_handler(struct scsi_target *starget) { - struct Scsi_Host *shost = scmd->device->host; + struct Scsi_Host *shost = dev_to_shost(&starget->dev); struct scsi_device *scsi_dev = NULL, *tmp; shost_for_each_device(tmp, shost) { - if ((tmp->channel == scmd->device->channel) && - (tmp->id == scmd->device->id)) { + if ((tmp->channel == starget->channel) && + (tmp->id == starget->id)) { scsi_dev = tmp; break; } diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index bc211d8101e1..b3a5d86992cd 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -855,9 +855,8 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) return rc; } -static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd) +static int qedf_eh_target_reset(struct scsi_target *starget) { - struct scsi_target *starget = scsi_target(sc_cmd->device); struct fc_rport *rport = starget_to_rport(starget); QEDF_ERR(NULL, "TARGET RESET Issued..."); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 0f2bf06a01d7..eece94038d13 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1456,13 +1456,12 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) } static int -qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_target_reset(struct scsi_target *starget) { - struct scsi_device *sdev = cmd->device; - scsi_qla_host_t *vha = shost_priv(sdev->host); - struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); - fc_port_t *fcport = (struct fc_port *) sdev->hostdata; + struct fc_rport *rport = starget_to_rport(starget); + scsi_qla_host_t *vha = shost_priv(rport_to_shost(rport)); struct qla_hw_data *ha = vha->hw; + fc_port_t *fcport = *(fc_port_t **)rport->dd_data; int err; if (qla2x00_isp_reg_stat(ha)) { @@ -1484,42 +1483,39 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) return SUCCESS; ql_log(ql_log_info, vha, 0x8009, - "TARGET RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", vha->host_no, - cmd->device->id, cmd->device->lun, cmd); + "TARGET RESET ISSUED nexus=%ld:%d:0.\n", vha->host_no, + starget->id); err = 0; if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800a, - "Wait for hba online failed for cmd=%p.\n", cmd); + "Wait for hba online failed.\n"); goto eh_reset_failed; } err = 2; - if (ha->isp_ops->target_reset(fcport, cmd->device->lun, 1) - != QLA_SUCCESS) { - ql_log(ql_log_warn, vha, 0x800c, - "target_reset failed for cmd=%p.\n", cmd); + if (ha->isp_ops->target_reset(fcport, starget->id, 1) + != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x800c, "do_reset failed.\n"); goto eh_reset_failed; } err = 3; - if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, - cmd->device->lun, WAIT_TARGET) != QLA_SUCCESS) { + if (qla2x00_eh_wait_for_pending_commands(vha, starget->id, + 0, WAIT_TARGET) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800d, - "wait for pending cmds failed for cmd=%p.\n", cmd); + "wait for pending cmds failed.\n"); goto eh_reset_failed; } ql_log(ql_log_info, vha, 0x800e, - "TARGET RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", - vha->host_no, cmd->device->id, cmd->device->lun, cmd); + "TARGET RESET SUCCEEDED nexus:%ld:%d:0.\n", + vha->host_no, starget->id); return SUCCESS; eh_reset_failed: ql_log(ql_log_info, vha, 0x800f, - "TARGET RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", - reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, - cmd); - vha->reset_cmd_err_cnt++; + "TARGET RESET FAILED: %s nexus=%ld:%d:0\n", + reset_errors[err], vha->host_no, starget->id); return FAILED; } diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 130bc0c58c2e..cedc20fac883 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -158,7 +158,7 @@ static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len); static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); static int qla4xxx_eh_abort(struct scsi_cmnd *cmd); static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd); -static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd); +static int qla4xxx_eh_target_reset(struct scsi_target *starget); static int qla4xxx_eh_host_reset(struct Scsi_Host *shost); static int qla4xxx_slave_alloc(struct scsi_device *device); static umode_t qla4_attr_is_visible(int param_type, int param); @@ -9332,9 +9332,8 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) * * This routine is called by the Linux OS to reset the target. **/ -static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) +static int qla4xxx_eh_target_reset(struct scsi_target *starget) { - 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; @@ -9356,10 +9355,9 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) "WARM TARGET RESET ISSUED.\n"); DEBUG2(printk(KERN_INFO - "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, " - "to=%x,dpc_flags=%lx, status=%x allowed=%d\n", - ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, - ha->dpc_flags, cmd->result, cmd->allowed)); + "scsi%ld: TARGET_DEVICE_RESET jiffies = 0x%lx, " + "dpc_flags=%lx\n", + ha->host_no, jiffies, ha->dpc_flags)); rval = qla4xxx_isp_check_reg(ha); if (rval != QLA_SUCCESS) { @@ -9382,7 +9380,7 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) } /* Send marker. */ - if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun, + if (qla4xxx_send_marker_iocb(ha, ddb_entry, 0, MM_TGT_WARM_RESET) != QLA_SUCCESS) { starget_printk(KERN_INFO, starget, "WARM TARGET DEVICE RESET FAILED - " diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 63bbbcc94bbc..c72b7ac1eec6 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5182,39 +5182,30 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt) return SUCCESS; } -static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt) +static int scsi_debug_target_reset(struct scsi_target *starget) { + struct Scsi_Host *hp = dev_to_shost(&starget->dev); struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *devip; - struct scsi_device *sdp; - struct Scsi_Host *hp; int k = 0; ++num_target_resets; - if (!SCpnt) - goto lie; - sdp = SCpnt->device; - if (!sdp) - goto lie; if (SDEBUG_OPT_ALL_NOISE & sdebug_opts) - sdev_printk(KERN_INFO, sdp, "%s\n", __func__); - hp = sdp->host; - if (!hp) - goto lie; + starget_printk(KERN_INFO, starget, "%s\n", __func__); sdbg_host = *(struct sdebug_host_info **)shost_priv(hp); if (sdbg_host) { list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) - if (devip->target == sdp->id) { + if (devip->target == starget->id) { set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); ++k; } } if (SDEBUG_OPT_RESET_NOISE & sdebug_opts) - sdev_printk(KERN_INFO, sdp, + starget_printk(KERN_INFO, starget, "%s: %d device(s) found in target\n", __func__, k); -lie: + return SUCCESS; } diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index d5e36488c87b..1d8e2f655833 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -876,14 +876,15 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) enum scsi_disposition rtn; struct Scsi_Host *host = scmd->device->host; struct scsi_host_template *hostt = host->hostt; + struct scsi_target *starget = scsi_target(scmd->device); if (!hostt->eh_target_reset_handler) return FAILED; - rtn = hostt->eh_target_reset_handler(scmd); + rtn = hostt->eh_target_reset_handler(starget); if (rtn == SUCCESS) { spin_lock_irqsave(host->host_lock, flags); - __starget_for_each_device(scsi_target(scmd->device), NULL, + __starget_for_each_device(starget, NULL, __scsi_report_device_reset); spin_unlock_irqrestore(host->host_lock, flags); } diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 3d00afd8cbca..09cd929f3e6d 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -622,9 +622,8 @@ static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd) return sts ? SCSI_FAILED : SCSI_SUCCESS; } -static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd) +static int sym53c8xx_eh_target_reset_handler(struct scsi_target *starget) { - 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; diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index fdc36274cb39..fa7352a8eab4 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -274,23 +274,24 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED; } -static int tcm_loop_target_reset(struct scsi_cmnd *sc) +static int tcm_loop_target_reset(struct scsi_target *starget) { struct tcm_loop_hba *tl_hba; struct tcm_loop_tpg *tl_tpg; + struct Scsi_Host *shost = dev_to_shost(&starget->dev); /* * Locate the tcm_loop_hba_t pointer */ - tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); + tl_hba = *(struct tcm_loop_hba **)shost_priv(shost); if (!tl_hba) { pr_err("Unable to perform device reset without active I_T Nexus\n"); return FAILED; } /* - * Locate the tl_tpg pointer from TargetID in sc->device->id + * Locate the tl_tpg pointer from TargetID in starget->id */ - tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; + tl_tpg = &tl_hba->tl_hba_tpgs[starget->id]; if (tl_tpg) { tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE; return SUCCESS; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 3401feb088df..a5c088538a5f 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -378,7 +378,7 @@ struct iscsi_host { * scsi host template */ extern int iscsi_eh_abort(struct scsi_cmnd *sc); -extern int iscsi_eh_recover_target(struct scsi_cmnd *sc); +extern int iscsi_eh_recover_target(struct scsi_target *starget); 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); diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 6fe125a71b60..962bce82bc97 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -694,7 +694,7 @@ void sas_init_dev(struct domain_device *); void sas_task_abort(struct sas_task *); int sas_eh_abort_handler(struct scsi_cmnd *cmd); int sas_eh_device_reset_handler(struct scsi_cmnd *cmd); -int sas_eh_target_reset_handler(struct scsi_cmnd *cmd); +int sas_eh_target_reset_handler(struct scsi_target *starget); extern void sas_target_destroy(struct scsi_target *); extern int sas_slave_alloc(struct scsi_device *); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index e0a102339317..8fcced0d98bd 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -140,7 +140,7 @@ struct scsi_host_template { */ int (* eh_abort_handler)(struct scsi_cmnd *); int (* eh_device_reset_handler)(struct scsi_cmnd *); - int (* eh_target_reset_handler)(struct scsi_cmnd *); + int (* eh_target_reset_handler)(struct scsi_target *); int (* eh_bus_reset_handler)(struct Scsi_Host *, int); int (* eh_host_reset_handler)(struct Scsi_Host *); From patchwork Tue Aug 17 09:14:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60F67C4320E for ; Tue, 17 Aug 2021 09:17:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4495160F11 for ; Tue, 17 Aug 2021 09:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239505AbhHQJRm (ORCPT ); Tue, 17 Aug 2021 05:17:42 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33328 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239385AbhHQJRR (ORCPT ); Tue, 17 Aug 2021 05:17:17 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9250A21D79; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=JecH4CfJXhymQm/c1omSTVfsGKipcjuifjDv8CkMsYM=; b=FaUW4qUYGKmO/IDlflL5Y+CX5ubdke8n0UArDJQanwJMqX4J+CcImVsPft8fWkWoU79Gid iFmNAvDs9+iZ1oPL0M/8uqMZ4vZTHwVn4GGVBcNRvffMJMa5HQhVmn/YqYvIos6/sjzIbT ovY3cZguTb8+fwrleVB+betIhBAexT4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=JecH4CfJXhymQm/c1omSTVfsGKipcjuifjDv8CkMsYM=; b=LY39z50nky/O9RivEp3lL+ouYb74TqyGfBJKLqMt7vor6OV/6gZ3Y784TIkCQLXedXQNYH 0Kn0ZAkj7v2L4PCw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 8D1F5A3B91; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 8AC03518CEA9; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 37/51] aha152x: look for stuck command when resetting device Date: Tue, 17 Aug 2021 11:14:42 +0200 Message-Id: <20210817091456.73342-38-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 6fbdb6f3c996..3f96b38b7b56 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1045,24 +1045,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, reset_done); From patchwork Tue Aug 17 09:14:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92340C432BE for ; Tue, 17 Aug 2021 09:17:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BEA160FA0 for ; Tue, 17 Aug 2021 09:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239885AbhHQJSH (ORCPT ); Tue, 17 Aug 2021 05:18:07 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47670 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239493AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9A97B20027; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=uHlO7ZvGSjc7jtOu9AADJUR+y0m7l2Y+9F765qIy0ZQ=; b=GGWZimCuvfzypWAR0XNykxCUYNmoyXQgokZmRkscFq8Iz4Z8ZBs/Vwk9/ruGvOn1b03rNN jGKWXgt2xulUjtskfvskPFH8l1ObLBEZ/tQZ2kGAjBI3huGmBmh059h87hUjvVdcb5oTWA xkHemaJG/d8Lzg2mLlJZbrBE1JTU1UA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=uHlO7ZvGSjc7jtOu9AADJUR+y0m7l2Y+9F765qIy0ZQ=; b=Bo+4XhV8m7ZZJXlpTU2kuTI9DzhJm97bcpG9X3YfZdwwws3DXSlnrzu37pf7m0WuiAI2+E iEdxlf+o2xzpR5DQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 95072A3BB5; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 91E5C518CEAB; Tue, 17 Aug 2021 11:16:42 +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 38/51] fnic: use dedicated device reset command Date: Tue, 17 Aug 2021 11:14:43 +0200 Message-Id: <20210817091456.73342-39-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use a dedicated command to send a device reset instead of relying on using the command which triggered the device failure. Signed-off-by: Hannes Reinecke --- drivers/scsi/fnic/fnic_scsi.c | 127 +++++++++------------------------- 1 file changed, 34 insertions(+), 93 deletions(-) diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 60af6c7a1bc4..b133eb629fa2 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -2014,7 +2014,6 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic, struct fnic_pending_aborts_iter_data { struct fnic *fnic; - struct scsi_cmnd *lr_sc; struct scsi_device *lun_dev; int ret; }; @@ -2033,7 +2032,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, DECLARE_COMPLETION_ONSTACK(tm_done); enum fnic_ioreq_state old_ioreq_state; - if (sc == iter_data->lr_sc || sc->device != lun_dev) + if (abt_tag == (fnic->fnic_max_tag_id - 1) || sc->device != lun_dev) return true; if (reserved) return true; @@ -2138,17 +2137,11 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, return false; } CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; - - /* original sc used for lr is handled by dev reset code */ - if (sc != iter_data->lr_sc) - CMD_SP(sc) = NULL; + CMD_SP(sc) = NULL; spin_unlock_irqrestore(io_lock, flags); - /* original sc used for lr is handled by dev reset code */ - if (sc != iter_data->lr_sc) { - fnic_release_ioreq_buf(fnic, io_req, sc); - mempool_free(io_req, fnic->io_req_pool); - } + fnic_release_ioreq_buf(fnic, io_req, sc); + mempool_free(io_req, fnic->io_req_pool); /* * Any IO is returned during reset, it needs to call scsi_done @@ -2169,8 +2162,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, * successfully aborted, 1 otherwise */ static int fnic_clean_pending_aborts(struct fnic *fnic, - struct scsi_cmnd *lr_sc, - bool new_sc) + struct scsi_cmnd *lr_sc) { int ret = SUCCESS; @@ -2180,9 +2172,6 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, .ret = SUCCESS, }; - if (new_sc) - iter_data.lr_sc = lr_sc; - scsi_host_busy_iter(fnic->lport->host, fnic_pending_aborts_iter, &iter_data); if (iter_data.ret == FAILED) { @@ -2199,38 +2188,6 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, return ret; } -/* - * fnic_scsi_host_start_tag - * Allocates tagid from host's tag list - **/ -static inline int -fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) -{ - struct request_queue *q = sc->request->q; - struct request *dummy; - - dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT); - if (IS_ERR(dummy)) - return SCSI_NO_TAG; - - sc->tag = sc->request->tag = dummy->tag; - sc->host_scribble = (unsigned char *)dummy; - - return dummy->tag; -} - -/* - * fnic_scsi_host_end_tag - * frees tag allocated by fnic_scsi_host_start_tag. - **/ -static inline void -fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) -{ - struct request *dummy = (struct request *)sc->host_scribble; - - blk_mq_free_request(dummy); -} - /* * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN * fail to get aborted. It calls driver's eh_device_reset with a SCSI command @@ -2238,6 +2195,7 @@ fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) */ int fnic_device_reset(struct scsi_cmnd *sc) { + struct scsi_device *sdev = sc->device; struct fc_lport *lp; struct fnic *fnic; struct fnic_io_req *io_req = NULL; @@ -2252,14 +2210,15 @@ int fnic_device_reset(struct scsi_cmnd *sc) struct reset_stats *reset_stats; int tag = 0; DECLARE_COMPLETION_ONSTACK(tm_done); - int tag_gen_flag = 0; /*to track tags allocated by fnic driver*/ - bool new_sc = 0; /* Wait for rport to unblock */ - fc_block_scsi_eh(sc); + rport = starget_to_rport(scsi_target(sdev)); + ret = fc_block_rport(rport); + if (ret) + return ret; /* Get local-port, check ready and link up */ - lp = shost_priv(sc->device->host); + lp = shost_priv(sdev->host); fnic = lport_priv(lp); fnic_stats = &fnic->fnic_stats; @@ -2267,54 +2226,41 @@ int fnic_device_reset(struct scsi_cmnd *sc) atomic64_inc(&reset_stats->device_resets); - rport = starget_to_rport(scsi_target(sc->device)); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, - "Device reset called FCID 0x%x, LUN 0x%llx sc 0x%p\n", - rport->port_id, sc->device->lun, sc); + "Device reset called FCID 0x%x, LUN 0x%llx\n", + rport->port_id, sdev->lun); if (lp->state != LPORT_ST_READY || !(lp->link_up)) goto fnic_device_reset_end; /* Check if remote port up */ - if (fc_remote_port_chkready(rport)) { - atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); + if (rport->port_state != FC_PORTSTATE_ONLINE && + rport->port_state != FC_PORTSTATE_MARGINAL) { goto fnic_device_reset_end; } CMD_FLAGS(sc) = FNIC_DEVICE_RESET; - /* Allocate tag if not present */ - - tag = sc->request->tag; - if (unlikely(tag < 0)) { + /* The last tag is reserved for device reset */ + sc = scsi_host_find_tag(sdev->host, fnic->fnic_max_tag_id - 1); + io_lock = fnic_io_lock_hash(fnic, sc); + spin_lock_irqsave(io_lock, flags); + if (CMD_SP(sc)) { /* - * Really should fix the midlayer to pass in a proper - * request for ioctls... + * Reset tag busy */ - tag = fnic_scsi_host_start_tag(fnic, sc); - if (unlikely(tag == SCSI_NO_TAG)) - goto fnic_device_reset_end; - tag_gen_flag = 1; - new_sc = 1; + spin_unlock_irqrestore(io_lock, flags); + goto fnic_device_reset_end; } - io_lock = fnic_io_lock_hash(fnic, sc); - spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); - - /* - * If there is a io_req attached to this command, then use it, - * else allocate a new one. - */ + io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); if (!io_req) { - io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); - if (!io_req) { - spin_unlock_irqrestore(io_lock, flags); - goto fnic_device_reset_end; - } - memset(io_req, 0, sizeof(*io_req)); - io_req->port_id = rport->port_id; - CMD_SP(sc) = (char *)io_req; + spin_unlock_irqrestore(io_lock, flags); + goto fnic_device_reset_end; } + memset(io_req, 0, sizeof(*io_req)); + io_req->port_id = rport->port_id; + CMD_SP(sc) = (char *)io_req; io_req->dr_done = &tm_done; + CMD_FLAGS(sc) = FNIC_DEVICE_RESET; CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE; spin_unlock_irqrestore(io_lock, flags); @@ -2429,7 +2375,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) * the lun reset cmd. If all cmds get cleaned, the lun reset * succeeds */ - if (fnic_clean_pending_aborts(fnic, sc, new_sc)) { + if (fnic_clean_pending_aborts(fnic, sc)) { spin_lock_irqsave(io_lock, flags); io_req = (struct fnic_io_req *)CMD_SP(sc); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, @@ -2466,10 +2412,6 @@ int fnic_device_reset(struct scsi_cmnd *sc) (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); - /* free tag if it is allocated */ - if (unlikely(tag_gen_flag)) - fnic_scsi_host_end_tag(fnic, sc); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Returning from device reset %s\n", (ret == SUCCESS) ? @@ -2691,6 +2633,7 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data, { struct fnic_pending_aborts_iter_data *iter_data = data; struct fnic *fnic = iter_data->fnic; + int tag = sc->request->tag; int cmd_state; struct fnic_io_req *io_req; spinlock_t *io_lock; @@ -2700,7 +2643,7 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data, * ignore this lun reset cmd or cmds that do not belong to * this lun */ - if (iter_data->lr_sc && sc == iter_data->lr_sc) + if (tag == (fnic->fnic_max_tag_id - 1)) return true; if (iter_data->lun_dev && sc->device != iter_data->lun_dev) return true; @@ -2744,10 +2687,8 @@ int fnic_is_abts_pending(struct fnic *fnic, struct scsi_cmnd *lr_sc) .ret = 0, }; - if (lr_sc) { + if (lr_sc) iter_data.lun_dev = lr_sc->device; - iter_data.lr_sc = lr_sc; - } /* walk again to check, if IOs are still pending in fw */ scsi_host_busy_iter(fnic->lport->host, From patchwork Tue Aug 17 09:14:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62A77C4320A for ; Tue, 17 Aug 2021 09:17:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A7B160F11 for ; Tue, 17 Aug 2021 09:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239878AbhHQJSF (ORCPT ); Tue, 17 Aug 2021 05:18:05 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47558 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239494AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9F80320028; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=/+r/WKnJufi/m5+khXJxCiCzQ+8r/kLygQfMOzIy9Pk=; b=zRPg+2EBAO/J5yu0PSJGrKl0jTPluRyfnWMtf8npAuoIw3xhNNBzw4rB2kxXHVPnKjQUwf hY8tIHBCXbQhg1YGitjl119dTG2QvaJiivl2ycgt5nNrm1daoUQ9kRGc1zsKwlUXRK44hc aUNq4sXR79JybH70jmIrK5jizCUUCKo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=/+r/WKnJufi/m5+khXJxCiCzQ+8r/kLygQfMOzIy9Pk=; b=sRiCzY0rHemisx1W/30SZd/rg7xpgsQ0O4cjXuXpJU3/AIPLN6hbiMHWdEiLCke1jSe/7S XwX6kps32H/pEeAg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 9A657A3B91; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 9774F518CEAD; Tue, 17 Aug 2021 11:16:42 +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 39/51] a1000u2w: do not rely on the command for inia100_device_reset() Date: Tue, 17 Aug 2021 11:14:44 +0200 Message-Id: <20210817091456.73342-40-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 eee119c06b48..b6373dcfe4ea 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; @@ -974,7 +955,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); } @@ -994,11 +975,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) { @@ -1036,13 +1013,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); - cmd->scsi_done(cmd); /* Notify system DONE */ + if (cmd) { + cmd->result = scb->tastat | (scb->hastat << 16); + scsi_dma_unmap(cmd); + cmd->scsi_done(cmd); /* Notify system DONE */ + } orc_release_scb(host, scb); /* Release SCB for current channel */ } From patchwork Tue Aug 17 09:14:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE495C43214 for ; Tue, 17 Aug 2021 09:17:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5AB460F11 for ; Tue, 17 Aug 2021 09:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239888AbhHQJSI (ORCPT ); Tue, 17 Aug 2021 05:18:08 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47702 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239498AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A57F020029; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=1Y0tCO0mLuxX12S9NRpPOQPdiBpIDtSFSFlwRu+ABi8=; b=duUOcDGyAU2pi/GNfDkdOfnj5U4GhzgRVahLsyXVdpP+2SZBjK8nhOt98t643fh4w73MLr ictBFEcbZ/+X5z8zjk3fFwIhfbin1+waSAZpbUnfLlsm05293i3uKEhfeeP2ouBt9cnpRl TbARvgSN7ZRZHDvPQvZ7fb/7ZyT+RMY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=1Y0tCO0mLuxX12S9NRpPOQPdiBpIDtSFSFlwRu+ABi8=; b=fOyPxTo2YQfRKUrUPGaVWMSGQEZdEkVHv1tBIMh1dyi7PkxutIpyd5uy2YtCxm5GAQZoWW Pf7Gc/iYXJczyCBw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id A0014A3BB7; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 9D50F518CEAF; Tue, 17 Aug 2021 11:16:42 +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 40/51] aic7xxx: use scsi device as argument for BUILD_SCSIID() Date: Tue, 17 Aug 2021 11:14:45 +0200 Message-Id: <20210817091456.73342-41-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Hannes Reinecke --- drivers/scsi/aic7xxx/aic7xxx_osm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 0a487c9a43b8..36e58cf0416b 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -801,10 +801,10 @@ struct scsi_host_template aic7xxx_driver_template = { /**************************** Tasklet Handler *********************************/ /******************************** Macros **************************************/ -#define BUILD_SCSIID(ahc, cmd) \ - ((((cmd)->device->id << TID_SHIFT) & TID) \ - | (((cmd)->device->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \ - | (((cmd)->device->channel == 0) ? 0 : TWIN_CHNLB)) +#define BUILD_SCSIID(ahc, sdev) \ + ((((sdev)->id << TID_SHIFT) & TID) \ + | (((sdev)->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \ + | (((sdev)->channel == 0) ? 0 : TWIN_CHNLB)) /******************************** Bus DMA *************************************/ int @@ -1459,7 +1459,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, * Fill out basics of the HSCB. */ hscb->control = 0; - hscb->scsiid = BUILD_SCSIID(ahc, cmd); + hscb->scsiid = BUILD_SCSIID(ahc, cmd->device); hscb->lun = cmd->device->lun; mask = SCB_GET_TARGET_MASK(ahc, scb); tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb), From patchwork Tue Aug 17 09:14:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1684CC43216 for ; Tue, 17 Aug 2021 09:17:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3E0360FA0 for ; Tue, 17 Aug 2021 09:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239890AbhHQJSJ (ORCPT ); Tue, 17 Aug 2021 05:18:09 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47544 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239502AbhHQJRU (ORCPT ); Tue, 17 Aug 2021 05:17:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id AB5172002A; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=xGhqkrhOjPH1rOpPihMfpmtlLERPj1NuC8jl9xVjFCI=; b=FveKZBO0Pcteaq0PlZOflR72IGobvyTcwBHHZTJqgOFcCxwtf0OYOODmOe8WDzf4fmxLJq bzI2Uzw4Ham0zRt0JIKIvTiu7lLA64lD+if4C9zjHlzidLa3uX8aDDAJUXmI5npO9/gxBe FOeMQUQDBlFjv+ZfQUFtdB+RpsraXQw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=xGhqkrhOjPH1rOpPihMfpmtlLERPj1NuC8jl9xVjFCI=; b=FAOWaICmm0bfn/lVymhkhIIgEeKQFqeOfV1gx9QT4zsmne1vZgIJlaDufqlnOV8zDxC5OZ hXs8dNJWrcvz8ECg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id A56DBA3BB8; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A2B05518CEB1; Tue, 17 Aug 2021 11:16:42 +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 41/51] aic79xx: use scsi device as argument for BUILD_SCSIID() Date: Tue, 17 Aug 2021 11:14:46 +0200 Message-Id: <20210817091456.73342-42-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Hannes Reinecke --- drivers/scsi/aic7xxx/aic79xx_osm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 9b2e15c4fe07..ab40f89febea 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -541,8 +541,8 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) } /******************************** Macros **************************************/ -#define BUILD_SCSIID(ahd, cmd) \ - (((scmd_id(cmd) << TID_SHIFT) & TID) | (ahd)->our_id) +#define BUILD_SCSIID(ahd, sdev) \ + (((sdev_id(sdev) << TID_SHIFT) & TID) | (ahd)->our_id) /* * Return a string describing the driver. @@ -824,7 +824,7 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) ahd_set_sense_residual(reset_scb, 0); reset_scb->platform_data->xfer_len = 0; reset_scb->hscb->control = 0; - reset_scb->hscb->scsiid = BUILD_SCSIID(ahd,cmd); + reset_scb->hscb->scsiid = BUILD_SCSIID(ahd, cmd->device); reset_scb->hscb->lun = cmd->device->lun; reset_scb->hscb->cdb_len = 0; reset_scb->hscb->task_management = SIU_TASKMGMT_LUN_RESET; @@ -1583,7 +1583,7 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev, * Fill out basics of the HSCB. */ hscb->control = 0; - hscb->scsiid = BUILD_SCSIID(ahd, cmd); + hscb->scsiid = BUILD_SCSIID(ahd, cmd->device); hscb->lun = cmd->device->lun; scb->hscb->task_management = 0; mask = SCB_GET_TARGET_MASK(ahd, scb); From patchwork Tue Aug 17 09:14:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FE13C4320A for ; Tue, 17 Aug 2021 09:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B89D60720 for ; Tue, 17 Aug 2021 09:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239559AbhHQJRt (ORCPT ); Tue, 17 Aug 2021 05:17:49 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33302 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235578AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B0FD721D82; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=dYeNAqtanRT97Ug5X4+g/Wpej5jaqummjiGA1PAD0wQ=; b=sSkC6a36ZJlzGF8uaWAonO+k9Bgng51PLt7oQAJOBC2gpZ3khHOmxQqBS6ocwvOFaAOzY4 6QSnjn3ta5uhHPWy0yb7QudMf1NA0vMfH4XhwzyZu6jibV13ICEV1ViifBo85avw+9wFLW 8jEVdaqizF5gkbIvcon6kbFQY00wyWU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=dYeNAqtanRT97Ug5X4+g/Wpej5jaqummjiGA1PAD0wQ=; b=t1rrJVoTqpwhjSKVcfCg8fATuE5C0b1Q8QoE/pGJmfSHT2b/IsLlpfHgUjBt1jy7m85E8V 7JR4Fuq1Blkp4wDQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id AC2FBA3B94; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id A9367518CEB3; Tue, 17 Aug 2021 11:16:42 +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 42/51] aic7xxx: do not reference scsi command when resetting device Date: Tue, 17 Aug 2021 11:14:47 +0200 Message-Id: <20210817091456.73342-43-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When sending a device reset we should not take a reference to the scsi command. Signed-off-by: Hannes Reinecke --- drivers/scsi/aic7xxx/aic7xxx_osm.c | 102 +++++++++++++++-------------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 36e58cf0416b..26ca71e2ddd0 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -366,7 +366,8 @@ static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd); static void ahc_linux_freeze_simq(struct ahc_softc *ahc); static void ahc_linux_release_simq(struct ahc_softc *ahc); -static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); +static int ahc_linux_queue_recovery_cmd(struct scsi_device *sdev, + struct scsi_cmnd *cmd); static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, struct ahc_devinfo *devinfo); @@ -730,7 +731,7 @@ ahc_linux_abort(struct scsi_cmnd *cmd) { int error; - error = ahc_linux_queue_recovery_cmd(cmd, SCB_ABORT); + error = ahc_linux_queue_recovery_cmd(cmd->device, cmd); if (error != SUCCESS) printk("aic7xxx_abort returns 0x%x\n", error); return (error); @@ -744,7 +745,7 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd) { int error; - error = ahc_linux_queue_recovery_cmd(cmd, SCB_DEVICE_RESET); + error = ahc_linux_queue_recovery_cmd(cmd->device, NULL); if (error != SUCCESS) printk("aic7xxx_dev_reset returns 0x%x\n", error); return (error); @@ -2031,11 +2032,12 @@ ahc_linux_release_simq(struct ahc_softc *ahc) } static int -ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) +ahc_linux_queue_recovery_cmd(struct scsi_device *sdev, + struct scsi_cmnd *cmd) { struct ahc_softc *ahc; struct ahc_linux_device *dev; - struct scb *pending_scb; + struct scb *pending_scb = NULL, *scb; u_int saved_scbptr; u_int active_scb_index; u_int last_phase; @@ -2048,18 +2050,19 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) int disconnected; unsigned long flags; - pending_scb = NULL; paused = FALSE; wait = FALSE; - ahc = *(struct ahc_softc **)cmd->device->host->hostdata; + ahc = *(struct ahc_softc **)sdev->host->hostdata; - scmd_printk(KERN_INFO, cmd, "Attempting to queue a%s message\n", - flag == SCB_ABORT ? "n ABORT" : " TARGET RESET"); + sdev_printk(KERN_INFO, sdev, "Attempting to queue a%s message\n", + cmd ? "n ABORT" : " TARGET RESET"); - printk("CDB:"); - for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++) - printk(" 0x%x", cmd->cmnd[cdb_byte]); - printk("\n"); + if (cmd) { + printk("CDB:"); + for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++) + printk(" 0x%x", cmd->cmnd[cdb_byte]); + printk("\n"); + } ahc_lock(ahc, &flags); @@ -2070,7 +2073,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) * at all, and the system wanted us to just abort the * command, return success. */ - dev = scsi_transport_device_data(cmd->device); + dev = scsi_transport_device_data(sdev); if (dev == NULL) { /* @@ -2078,13 +2081,12 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) * so we must not still own the command. */ printk("%s:%d:%d:%d: Is not an active device\n", - ahc_name(ahc), cmd->device->channel, cmd->device->id, - (u8)cmd->device->lun); + ahc_name(ahc), sdev->channel, sdev->id, (u8)sdev->lun); retval = SUCCESS; goto no_cmd; } - if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0 + if (cmd && (dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id, cmd->device->channel + 'A', (u8)cmd->device->lun, @@ -2099,25 +2101,28 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) /* * See if we can find a matching cmd in the pending list. */ - LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) { - if (pending_scb->io_ctx == cmd) + LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { + if (cmd && scb->io_ctx == cmd) { + pending_scb = scb; break; + } } - if (pending_scb == NULL && flag == SCB_DEVICE_RESET) { - + if (!cmd) { /* Any SCB for this device will do for a target reset */ - LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) { - if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd), - scmd_channel(cmd) + 'A', + LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { + if (ahc_match_scb(ahc, scb, sdev->id, + sdev->channel + 'A', CAM_LUN_WILDCARD, - SCB_LIST_NULL, ROLE_INITIATOR)) + SCB_LIST_NULL, ROLE_INITIATOR)) { + pending_scb = scb; break; + } } } if (pending_scb == NULL) { - scmd_printk(KERN_INFO, cmd, "Command not found\n"); + sdev_printk(KERN_INFO, sdev, "Command not found\n"); goto no_cmd; } @@ -2148,22 +2153,22 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) ahc_dump_card_state(ahc); disconnected = TRUE; - if (flag == SCB_ABORT) { - if (ahc_search_qinfifo(ahc, cmd->device->id, - cmd->device->channel + 'A', - cmd->device->lun, + if (cmd) { + if (ahc_search_qinfifo(ahc, sdev->id, + sdev->channel + 'A', + sdev->lun, pending_scb->hscb->tag, ROLE_INITIATOR, CAM_REQ_ABORTED, SEARCH_COMPLETE) > 0) { printk("%s:%d:%d:%d: Cmd aborted from QINFIFO\n", - ahc_name(ahc), cmd->device->channel, - cmd->device->id, (u8)cmd->device->lun); + ahc_name(ahc), sdev->channel, + sdev->id, (u8)sdev->lun); retval = SUCCESS; goto done; } - } else if (ahc_search_qinfifo(ahc, cmd->device->id, - cmd->device->channel + 'A', - cmd->device->lun, + } else if (ahc_search_qinfifo(ahc, sdev->id, + sdev->channel + 'A', + sdev->lun, pending_scb->hscb->tag, ROLE_INITIATOR, /*status*/0, SEARCH_COUNT) > 0) { @@ -2176,7 +2181,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) bus_scb = ahc_lookup_scb(ahc, ahc_inb(ahc, SCB_TAG)); if (bus_scb == pending_scb) disconnected = FALSE; - else if (flag != SCB_ABORT + else if (!cmd && ahc_inb(ahc, SAVED_SCSIID) == pending_scb->hscb->scsiid && ahc_inb(ahc, SAVED_LUN) == SCB_GET_LUN(pending_scb)) disconnected = FALSE; @@ -2196,18 +2201,18 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) saved_scsiid = ahc_inb(ahc, SAVED_SCSIID); if (last_phase != P_BUSFREE && (pending_scb->hscb->tag == active_scb_index - || (flag == SCB_DEVICE_RESET - && SCSIID_TARGET(ahc, saved_scsiid) == scmd_id(cmd)))) { + || (!cmd && SCSIID_TARGET(ahc, saved_scsiid) == sdev->id))) { /* * We're active on the bus, so assert ATN * and hope that the target responds. */ pending_scb = ahc_lookup_scb(ahc, active_scb_index); - pending_scb->flags |= SCB_RECOVERY_SCB|flag; + pending_scb->flags |= SCB_RECOVERY_SCB; + pending_scb->flags |= cmd ? SCB_ABORT : SCB_DEVICE_RESET; ahc_outb(ahc, MSG_OUT, HOST_MSG); ahc_outb(ahc, SCSISIGO, last_phase|ATNO); - scmd_printk(KERN_INFO, cmd, "Device is active, asserting ATN\n"); + sdev_printk(KERN_INFO, sdev, "Device is active, asserting ATN\n"); wait = TRUE; } else if (disconnected) { @@ -2228,7 +2233,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) * an unsolicited reselection occurred. */ pending_scb->hscb->control |= MK_MESSAGE|DISCONNECTED; - pending_scb->flags |= SCB_RECOVERY_SCB|flag; + pending_scb->flags |= SCB_RECOVERY_SCB; + pending_scb->flags |= cmd ? SCB_ABORT : SCB_DEVICE_RESET; /* * Remove any cached copy of this SCB in the @@ -2237,9 +2243,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) * same element in the SCB, SCB_NEXT, for * both the qinfifo and the disconnected list. */ - ahc_search_disc_list(ahc, cmd->device->id, - cmd->device->channel + 'A', - cmd->device->lun, pending_scb->hscb->tag, + ahc_search_disc_list(ahc, sdev->id, + sdev->channel + 'A', + sdev->lun, pending_scb->hscb->tag, /*stop_on_first*/TRUE, /*remove*/TRUE, /*save_state*/FALSE); @@ -2262,9 +2268,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) * so we are the next SCB for this target * to run. */ - ahc_search_qinfifo(ahc, cmd->device->id, - cmd->device->channel + 'A', - cmd->device->lun, SCB_LIST_NULL, + ahc_search_qinfifo(ahc, sdev->id, + sdev->channel + 'A', + (u8)sdev->lun, SCB_LIST_NULL, ROLE_INITIATOR, CAM_REQUEUE_REQ, SEARCH_COMPLETE); ahc_qinfifo_requeue_tail(ahc, pending_scb); @@ -2273,7 +2279,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) printk("Device is disconnected, re-queuing SCB\n"); wait = TRUE; } else { - scmd_printk(KERN_INFO, cmd, "Unable to deliver message\n"); + sdev_printk(KERN_INFO, sdev, "Unable to deliver message\n"); retval = FAILED; goto done; } From patchwork Tue Aug 17 09:14:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4206CC4320E for ; Tue, 17 Aug 2021 09:17:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3081E60720 for ; Tue, 17 Aug 2021 09:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239895AbhHQJSK (ORCPT ); Tue, 17 Aug 2021 05:18:10 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47742 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235887AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B6AE32002B; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=Cq3NbcYvVoQCzwLi2ao7Y/cjANlv7n8J6GU36jDz5N4=; b=0PRciFAZajhAAFiTnHbAxcmnxeeFSAVsQ4RlW/T7FuSytk+xKczYGbeRz+U1jjtkUMZFxZ HZ1a58GulzBjiZheBT05+yzZbK1qlrlCR4u6iRdDPXpJKHPzhrXg4GNzoF0FU4i8rX6zb+ Q79CGEGO1wu2j52dIbsEeY1PTti2kMw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=Cq3NbcYvVoQCzwLi2ao7Y/cjANlv7n8J6GU36jDz5N4=; b=bOQhedZXJXsK6YzFroJQOKjC8Kv9xPnDl4ViSINmyc7JJipA8FZc85TZ6yOL4UuMQxIvy5 uJ6oFaxEsmKbNmCQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B2955A3BB9; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id AF789518CEB5; Tue, 17 Aug 2021 11:16:42 +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 43/51] aic79xx: do not reference scsi command when resetting device Date: Tue, 17 Aug 2021 11:14:48 +0200 Message-Id: <20210817091456.73342-44-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When sending a device reset we should not take a reference to the scsi command. Signed-off-by: Hannes Reinecke --- drivers/scsi/aic7xxx/aic79xx_osm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index ab40f89febea..4ffd5c9d78e5 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -536,8 +536,10 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) struct scsi_cmnd *cmd; cmd = scb->io_ctx; - ahd_sync_sglist(ahd, scb, BUS_DMASYNC_POSTWRITE); - scsi_dma_unmap(cmd); + if (cmd) { + ahd_sync_sglist(ahd, scb, BUS_DMASYNC_POSTWRITE); + scsi_dma_unmap(cmd); + } } /******************************** Macros **************************************/ @@ -817,7 +819,7 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, cmd->device->id, &tstate); - reset_scb->io_ctx = cmd; + reset_scb->io_ctx = NULL; reset_scb->platform_data->dev = dev; reset_scb->sg_count = 0; ahd_set_residual(reset_scb, 0); @@ -1772,9 +1774,16 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb) dev = scb->platform_data->dev; dev->active--; dev->openings++; - if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) { - cmd->result &= ~(CAM_DEV_QFRZN << 16); - dev->qfrozen--; + if (cmd) { + if ((cmd->result & (CAM_DEV_QFRZN << 16)) != 0) { + cmd->result &= ~(CAM_DEV_QFRZN << 16); + dev->qfrozen--; + } + } else if (scb->flags & SCB_DEVICE_RESET) { + if (ahd->platform_data->eh_done) + complete(ahd->platform_data->eh_done); + ahd_free_scb(ahd, scb); + return; } ahd_linux_unmap_scb(ahd, scb); From patchwork Tue Aug 17 09:14:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B147CC4338F for ; Tue, 17 Aug 2021 09:17:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A89460F11 for ; Tue, 17 Aug 2021 09:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239891AbhHQJSJ (ORCPT ); Tue, 17 Aug 2021 05:18:09 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47560 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239508AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BB6952002C; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=u3bjgrux7rsHECPmu52svL62wT8iytt2e+OmN1xrx3I=; b=EOc4+uBIQL9zFa+SfSEJeZzVa8xY7uzF2Bm8GZ9Gcv4Wdg6bhYEkMHRB0u4lB8M52qEo4Y cqG8v/B29NsagUtb/OEg1jyy+uoY2YQrJgTz3hfAcdRQJq3gOLdbX2vC56jz0xWwIGGSjg OCZ94IeOoxvJLL9D3VGjo2mLlt7GdVE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=u3bjgrux7rsHECPmu52svL62wT8iytt2e+OmN1xrx3I=; b=R1IyHXeZyLJTqMggq6BuE4AhzxfsUXnLFBdwR0MgMJTLCpy/Z9KP8VzrHW2cfAb9vdVaw1 6Enwruv53AwXZmDg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B728FA3BBA; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id B4760518CEB7; Tue, 17 Aug 2021 11:16:42 +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 44/51] xen-scsifront: add scsi device as argument to scsifront_do_request() Date: Tue, 17 Aug 2021 11:14:49 +0200 Message-Id: <20210817091456.73342-45-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index ec9d399fbbd8..4f08fb4c1333 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,20 @@ 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; - - BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE); - - 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 = sc->request->timeout / HZ; + ring_req->id = sdev->id; + ring_req->lun = sdev->lun; + ring_req->channel = sdev->channel; + if (sc) { + ring_req->cmd_len = sc->cmd_len; + BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE); + 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 = sc->request->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]; @@ -562,7 +566,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; } @@ -607,7 +611,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 Tue Aug 17 09:14:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0219AC4320A for ; Tue, 17 Aug 2021 09:17:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFD3360FA0 for ; Tue, 17 Aug 2021 09:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239855AbhHQJSA (ORCPT ); Tue, 17 Aug 2021 05:18:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33374 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239478AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C448821D94; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=62DbAeL6E9OpiRbBzPXF4p/G/dd/IQPP352bnvG02Os=; b=zKFX+RZJK6QJMRZ60trsMwK/Lbzu3iplwSp4YGy9TTitc7xoBtg23OjR7yRGTCWBoxZGgU W8NaFK94f8TiaGxB05PerECJn4baDf+TKJUd34/T7Abh0++I0gK7fumySwmCid7gHvar7e ybPPiPPkTtrnJqi6BZ3JYyCmMCyvKSc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=62DbAeL6E9OpiRbBzPXF4p/G/dd/IQPP352bnvG02Os=; b=RXfrhkE+rqBQP4GBFcBs6n3DGZSRnomfRz3CusM0d6ra5IEM3fvz1cbaJ63Rdiu1U3wOk6 5z4JKXjC3beLuVDg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id BDE26A3BBB; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id BAD89518CEB9; Tue, 17 Aug 2021 11:16:42 +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 45/51] fas216: Rework device reset to not rely on SCSI command pointer Date: Tue, 17 Aug 2021 11:14:50 +0200 Message-Id: <20210817091456.73342-46-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 4f17b24a291f..e08aa01006ea 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -1990,7 +1990,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); } @@ -2145,12 +2144,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"); @@ -2162,7 +2161,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); @@ -2175,12 +2174,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); @@ -2477,9 +2482,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); @@ -2493,7 +2499,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; /* @@ -2511,14 +2517,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 Tue Aug 17 09:14:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCE21C4320E for ; Tue, 17 Aug 2021 09:17:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A89E7600CC for ; Tue, 17 Aug 2021 09:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239627AbhHQJSO (ORCPT ); Tue, 17 Aug 2021 05:18:14 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47744 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239516AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id CB6A82002D; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=GJLbgBiS7QA2K+oaYrzUl/AREUHVEloGWanz8odi41U=; b=IQF8il/RTemLVdTM6/0a8sgvdvfJcRs46apLOELGwuG8pjxhIByshg3MWSzvYJ5ZRHOW+7 0tL180lIZpgXHwlqmUrVZ9wWrdml/sy8hQAIiUb63OMbFjfh9ErJFH1z2QVgOTZl0XJtyg PJzn1d+YiQjQrkbY7uUwnL3vMk0jdLg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=GJLbgBiS7QA2K+oaYrzUl/AREUHVEloGWanz8odi41U=; b=BLkvs5VrMbnemaUQdRJGpWw1rxIjI4dXh6H3Wq/PicQIBBznLLRYAdEStgauYzl4Gri1PH /gTn401r8/yayOCg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id C4313A3BBC; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id C1224518CEBB; Tue, 17 Aug 2021 11:16:42 +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 46/51] csiostor: use separate TMF command Date: Tue, 17 Aug 2021 11:14:51 +0200 Message-Id: <20210817091456.73342-47-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 | 44 ++++++++++++++++++++----------- 3 files changed, 32 insertions(+), 16 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 390b07bf92b9..7a80e0cf32d7 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 c22acfc7caba..0f3c997618c1 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -2052,17 +2052,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; @@ -2073,13 +2076,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; } @@ -2099,7 +2102,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; } @@ -2119,11 +2130,12 @@ 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; - cmnd->SCp.Status = 0; + csio_scsi_cmnd(ioreq) = tmf_cmnd; + tmf_cmnd->host_scribble = (unsigned char *)ioreq; + tmf_cmnd->SCp.Status = 0; + tmf_cmnd->device = sdev; - cmnd->SCp.Message = FCP_TMF_LUN_RESET; + tmf_cmnd->SCp.Message = FCP_TMF_LUN_RESET; ioreq->tmo = CSIO_SCSI_LUNRST_TMO_MS / 1000; /* @@ -2140,7 +2152,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 */ @@ -2150,6 +2162,7 @@ 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; } @@ -2163,20 +2176,21 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) /* LUN reset timed-out */ if (((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == 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); list_del_init(&ioreq->sm.sm_list); spin_unlock_irq(&hw->lock); + tmf_cmnd->host_scribble = NULL; goto fail_ret_ioreq; } /* LUN reset returned, check cached status */ - if (cmnd->SCp.Status != FW_SUCCESS) { + if (tmf_cmnd->SCp.Status != FW_SUCCESS) { csio_err(hw, "LUN reset failed (%d:%llu), status: %d\n", - cmnd->device->id, cmnd->device->lun, cmnd->SCp.Status); + sdev->id, sdev->lun, tmf_cmnd->SCp.Status); goto fail; } @@ -2196,7 +2210,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); @@ -2207,7 +2221,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; From patchwork Tue Aug 17 09:14:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54028C4320A for ; Tue, 17 Aug 2021 09:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F6B760720 for ; Tue, 17 Aug 2021 09:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239591AbhHQJSL (ORCPT ); Tue, 17 Aug 2021 05:18:11 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47562 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239510AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id CFE002002E; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=uae3GyC9S0tiwabHNIIUKEiBquUo/4QHcQA7ZuHbp8w=; b=dmV41zB2ZOtGLGWhjc17cINTOexLIkUmpgyP0ltWVWhvrIk92HeJGLQDktcQiyrhqfTfyJ OYny1DS4tJNEzA0KUXydcvcYcPIIy2t/O/yzRBs1TegVWiEA9TDmt9D8GQc7Kl5IdrAkU1 cwCV6NMNP2eFqo7xrr9zd/bd2sCx62g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=uae3GyC9S0tiwabHNIIUKEiBquUo/4QHcQA7ZuHbp8w=; b=4kzY2GAVt3pgVs2BlekzQKSAT8Q3rdzOV+XXBdy+nW4Mm8gYY+dTgb9TBKUG3c2OT2Hx8v tKkeDvU3t/KKM0AA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id CA2F6A3BBD; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id C778F518CEBD; Tue, 17 Aug 2021 11:16:42 +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 47/51] snic: use dedicated device reset command Date: Tue, 17 Aug 2021 11:14:52 +0200 Message-Id: <20210817091456.73342-48-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use a dedicated command to send a device reset instead of relying on using the command which triggered the device failure. Signed-off-by: Hannes Reinecke --- drivers/scsi/snic/snic_scsi.c | 52 ++++++++++++++++------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index e87f61d42586..26fbc0141b51 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -2131,57 +2131,53 @@ snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag) int snic_device_reset(struct scsi_cmnd *sc) { - struct Scsi_Host *shost = sc->device->host; + struct scsi_device *sdev = sc->device; + struct Scsi_Host *shost = sdev->host; struct snic *snic = shost_priv(shost); struct snic_req_info *rqi = NULL; - int tag = snic_cmd_tag(sc); int start_time = jiffies; int ret = FAILED; int dr_supp = 0; - SNIC_SCSI_DBG(shost, "dev_reset:sc %p :0x%x :req = %p :tag = %d\n", - sc, sc->cmnd[0], sc->request, - snic_cmd_tag(sc)); - dr_supp = snic_dev_reset_supported(sc->device); + SNIC_SCSI_DBG(shost, "dev_reset\n"); + dr_supp = snic_dev_reset_supported(sdev); if (!dr_supp) { /* device reset op is not supported */ SNIC_HOST_INFO(shost, "LUN Reset Op not supported.\n"); - snic_unlink_and_release_req(snic, sc, SNIC_DEV_RST_NOTSUP); - goto dev_rst_end; } if (unlikely(snic_get_state(snic) != SNIC_ONLINE)) { - snic_unlink_and_release_req(snic, sc, 0); SNIC_HOST_ERR(shost, "Devrst: Parent Devs are not online.\n"); goto dev_rst_end; } - /* There is no tag when lun reset is issue through ioctl. */ - if (unlikely(tag <= SNIC_NO_TAG)) { - SNIC_HOST_INFO(snic->shost, - "Devrst: LUN Reset Recvd thru IOCTL.\n"); - - rqi = snic_req_init(snic, 0); - if (!rqi) - goto dev_rst_end; - - memset(scsi_cmd_priv(sc), 0, - sizeof(struct snic_internal_io_state)); - CMD_SP(sc) = (char *)rqi; - CMD_FLAGS(sc) = SNIC_NO_FLAGS; + rqi = snic_req_init(snic, 0); + if (!rqi) + goto dev_rst_end; - /* Add special tag for dr coming from user spc */ - rqi->tm_tag = SNIC_TAG_IOCTL_DEV_RST; - rqi->sc = sc; + /* The last tag is reserved for device reset */ + sc = scsi_host_find_tag(snic->shost, snic->tmf_tag_id); + if (!sc || CMD_SP(sc)) { + SNIC_HOST_ERR(snic->shost, + "Devrst: TMF busy\n"); + goto dev_rst_end; } + memset(scsi_cmd_priv(sc), 0, + sizeof(struct snic_internal_io_state)); + CMD_SP(sc) = (char *)rqi; + CMD_FLAGS(sc) = SNIC_NO_FLAGS; + + /* Add special tag for dr coming from user spc */ + rqi->tm_tag = SNIC_TAG_IOCTL_DEV_RST; + rqi->sc = sc; ret = snic_send_dr_and_wait(snic, sc); if (ret) { SNIC_HOST_ERR(snic->shost, "Devrst: IO w/ Tag %x Failed w/ err = %d\n", - tag, ret); + snic_cmd_tag(sc), ret); snic_unlink_and_release_req(snic, sc, 0); @@ -2191,7 +2187,7 @@ snic_device_reset(struct scsi_cmnd *sc) ret = snic_dr_finish(snic, sc); dev_rst_end: - SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, + SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc, jiffies_to_msecs(jiffies - start_time), 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); @@ -2342,7 +2338,7 @@ snic_host_reset(struct Scsi_Host *shost) schedule_timeout(msecs_to_jiffies(1)); sc = scsi_host_find_tag(shost, snic->tmf_tag_id); - if (!sc) { + if (!sc || CMD_SP(sc)) { SNIC_HOST_ERR(shost, "reset:Host Reset Failed to allocate sc.\n"); spin_lock_irqsave(&snic->snic_lock, flags); From patchwork Tue Aug 17 09:14:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B963DC4338F for ; Tue, 17 Aug 2021 09:17:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A528760F11 for ; Tue, 17 Aug 2021 09:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239388AbhHQJSM (ORCPT ); Tue, 17 Aug 2021 05:18:12 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47746 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235616AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D6F7A2002F; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=V1Z17M4de88jlLw9XSckKt5y/yB8C98nMZ5kTafWzCo=; b=DPzW/o3AF42oYQsq2eW6ACllFmTNoU1IRiEljgenpvBTZtfZpVEY9TQXgngvDYWqH0uwIT AWoHT3QWiggr4+HmOXtUqt+Syg1My019znO3zIfa+4Do9OlnxyRjSgmXoy1WHoRPUc7TPR QXWQ1PVvUPuMqzWuAVaTkb76ugl4a18= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=V1Z17M4de88jlLw9XSckKt5y/yB8C98nMZ5kTafWzCo=; b=ZWj+TwEaGJSimSzz3uWpxwmqg07nVxFkXTkbePR87lS0AKMCTjeNXQyT9Xn5St0w2zW+mW NOz03Rg8UfbABoBA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id D13CAA3BBE; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id CE4D5518CEBF; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 48/51] snic: Use scsi_host_busy_iter() to traverse commands Date: Tue, 17 Aug 2021 11:14:53 +0200 Message-Id: <20210817091456.73342-49-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_host_busy_iter() to traverse commands instead of hand-crafted routines walking the command list. Signed-off-by: Hannes Reinecke --- drivers/scsi/snic/snic_scsi.c | 207 ++++++++++++++++------------------ 1 file changed, 100 insertions(+), 107 deletions(-) diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index 26fbc0141b51..ca5ec14907cb 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -77,7 +77,7 @@ static const char * const snic_io_status_str[] = { [SNIC_STAT_FATAL_ERROR] = "SNIC_STAT_FATAL_ERROR", }; -static void snic_scsi_cleanup(struct snic *, int); +static void snic_scsi_cleanup(struct snic *); const char * snic_state_to_str(unsigned int state) @@ -980,7 +980,7 @@ snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc) long act_ios = 0, act_fwreqs = 0; SNIC_SCSI_DBG(snic->shost, "HBA Reset scsi cleanup.\n"); - snic_scsi_cleanup(snic, snic_cmd_tag(sc)); + snic_scsi_cleanup(snic); /* Update stats on pending IOs */ act_ios = atomic64_read(&st->io.active); @@ -2402,87 +2402,82 @@ snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc) complete(rqi->abts_done); } -/* - * snic_scsi_cleanup: Walks through tag map and releases the reqs - */ -static void -snic_scsi_cleanup(struct snic *snic, int ex_tag) +static bool snic_scsi_cleanup_iter(struct scsi_cmnd *sc, void *data, + bool reserved) { - struct snic_req_info *rqi = NULL; - struct scsi_cmnd *sc = NULL; + struct snic *snic = data; + u32 tag = sc->request->tag; spinlock_t *io_lock = NULL; - unsigned long flags; - int tag; + struct snic_req_info *rqi = NULL; u64 st_time = 0; + unsigned long flags; - SNIC_SCSI_DBG(snic->shost, "sc_clean: scsi cleanup.\n"); - - for (tag = 0; tag < snic->max_tag_id; tag++) { - /* Skip ex_tag */ - if (tag == ex_tag) - continue; - - io_lock = snic_io_lock_tag(snic, tag); - spin_lock_irqsave(io_lock, flags); - sc = scsi_host_find_tag(snic->shost, tag); - if (!sc) { - spin_unlock_irqrestore(io_lock, flags); - - continue; - } - - if (unlikely(snic_tmreq_pending(sc))) { - /* - * When FW Completes reset w/o sending completions - * for outstanding ios. - */ - snic_cmpl_pending_tmreq(snic, sc); - spin_unlock_irqrestore(io_lock, flags); + io_lock = snic_io_lock_tag(snic, tag); + spin_lock_irqsave(io_lock, flags); + if (unlikely(snic_tmreq_pending(sc))) { + /* + * When FW Completes reset w/o sending completions + * for outstanding ios. + */ + snic_cmpl_pending_tmreq(snic, sc); + spin_unlock_irqrestore(io_lock, flags); - continue; - } + return true; + } - rqi = (struct snic_req_info *) CMD_SP(sc); - if (!rqi) { - spin_unlock_irqrestore(io_lock, flags); + rqi = (struct snic_req_info *) CMD_SP(sc); + if (!rqi) { + spin_unlock_irqrestore(io_lock, flags); - goto cleanup; - } + goto cleanup; + } - SNIC_SCSI_DBG(snic->shost, - "sc_clean: sc %p, rqi %p, tag %d flags 0x%llx\n", - sc, rqi, tag, CMD_FLAGS(sc)); + SNIC_SCSI_DBG(snic->shost, + "sc_clean: sc %p, rqi %p, tag %d flags 0x%llx\n", + sc, rqi, tag, CMD_FLAGS(sc)); - CMD_SP(sc) = NULL; - CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP; - spin_unlock_irqrestore(io_lock, flags); - st_time = rqi->start_time; + CMD_SP(sc) = NULL; + CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP; + spin_unlock_irqrestore(io_lock, flags); + st_time = rqi->start_time; - SNIC_HOST_INFO(snic->shost, - "sc_clean: Releasing rqi %p : flags 0x%llx\n", - rqi, CMD_FLAGS(sc)); + SNIC_HOST_INFO(snic->shost, + "sc_clean: Releasing rqi %p : flags 0x%llx\n", + rqi, CMD_FLAGS(sc)); - snic_release_req_buf(snic, rqi, sc); + snic_release_req_buf(snic, rqi, sc); cleanup: - sc->result = DID_TRANSPORT_DISRUPTED << 16; - SNIC_HOST_INFO(snic->shost, - "sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n", - sc, sc->request->tag, CMD_FLAGS(sc), rqi, - jiffies_to_msecs(jiffies - st_time)); + sc->result = DID_TRANSPORT_DISRUPTED << 16; + SNIC_HOST_INFO(snic->shost, + "sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, " + "Tag %d flags 0x%llx rqi %p duration %u msecs\n", + sc, sc->request->tag, CMD_FLAGS(sc), rqi, + jiffies_to_msecs(jiffies - st_time)); - /* Update IO stats */ - snic_stats_update_io_cmpl(&snic->s_stats); + /* Update IO stats */ + snic_stats_update_io_cmpl(&snic->s_stats); - if (sc->scsi_done) { - SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, - jiffies_to_msecs(jiffies - st_time), 0, - SNIC_TRC_CMD(sc), - SNIC_TRC_CMD_STATE_FLAGS(sc)); + if (sc->scsi_done) { + SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, + jiffies_to_msecs(jiffies - st_time), 0, + SNIC_TRC_CMD(sc), + SNIC_TRC_CMD_STATE_FLAGS(sc)); - sc->scsi_done(sc); - } + sc->scsi_done(sc); } + return true; +} + +/* + * snic_scsi_cleanup: Walks through tag map and releases the reqs + */ +static void +snic_scsi_cleanup(struct snic *snic) +{ + SNIC_SCSI_DBG(snic->shost, "sc_clean: scsi cleanup.\n"); + + scsi_host_busy_iter(snic->shost, snic_scsi_cleanup_iter, snic); } /* end of snic_scsi_cleanup */ void @@ -2490,7 +2485,7 @@ snic_shutdown_scsi_cleanup(struct snic *snic) { SNIC_HOST_INFO(snic->shost, "Shutdown time SCSI Cleanup.\n"); - snic_scsi_cleanup(snic, SCSI_NO_TAG); + snic_scsi_cleanup(snic); } /* end of snic_shutdown_scsi_cleanup */ /* @@ -2504,7 +2499,7 @@ snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf) spinlock_t *io_lock = NULL; unsigned long flags; u32 sv_state = 0; - int ret = 0; + int ret = FAILED; io_lock = snic_io_lock_hash(snic, sc); spin_lock_irqsave(io_lock, flags); @@ -2579,6 +2574,35 @@ snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf) return ret; } /* end of snic_internal_abort_io */ +struct snic_tgt_scsi_abort_io_data { + struct snic *snic; + struct snic_tgt *tgt; + int tmf; + int abt_cnt; +}; + +static bool snic_tgt_scsi_abort_io_iter(struct scsi_cmnd *sc, void *data, + bool reserved) +{ + struct snic_tgt_scsi_abort_io_data *iter_data = data; + struct snic *snic = iter_data->snic; + struct snic_tgt *sc_tgt; + int ret; + + sc_tgt = starget_to_tgt(scsi_target(sc->device)); + if (sc_tgt != iter_data->tgt) + return true; + + ret = snic_internal_abort_io(snic, sc, iter_data->tmf); + if (ret == SUCCESS) + iter_data->abt_cnt++; + else + SNIC_HOST_ERR(snic->shost, + "tgt_abt_io: Tag %x, Failed w err = %d\n", + sc->request->tag, ret); + return true; +} + /* * snic_tgt_scsi_abort_io : called by snic_tgt_del */ @@ -2586,11 +2610,9 @@ int snic_tgt_scsi_abort_io(struct snic_tgt *tgt) { struct snic *snic = NULL; - struct scsi_cmnd *sc = NULL; - struct snic_tgt *sc_tgt = NULL; - spinlock_t *io_lock = NULL; - unsigned long flags; - int ret = 0, tag, abt_cnt = 0, tmf = 0; + struct snic_tgt_scsi_abort_io_data data = { + .abt_cnt = 0, + }; if (!tgt) return -1; @@ -2598,44 +2620,15 @@ snic_tgt_scsi_abort_io(struct snic_tgt *tgt) snic = shost_priv(snic_tgt_to_shost(tgt)); SNIC_SCSI_DBG(snic->shost, "tgt_abt_io: Cleaning Pending IOs.\n"); + data.snic = snic; if (tgt->tdata.typ == SNIC_TGT_DAS) - tmf = SNIC_ITMF_ABTS_TASK; + data.tmf = SNIC_ITMF_ABTS_TASK; else - tmf = SNIC_ITMF_ABTS_TASK_TERM; - - for (tag = 0; tag < snic->max_tag_id; tag++) { - io_lock = snic_io_lock_tag(snic, tag); - - spin_lock_irqsave(io_lock, flags); - sc = scsi_host_find_tag(snic->shost, tag); - if (!sc) { - spin_unlock_irqrestore(io_lock, flags); - - continue; - } - - sc_tgt = starget_to_tgt(scsi_target(sc->device)); - if (sc_tgt != tgt) { - spin_unlock_irqrestore(io_lock, flags); + data.tmf = SNIC_ITMF_ABTS_TASK_TERM; - continue; - } - spin_unlock_irqrestore(io_lock, flags); - - ret = snic_internal_abort_io(snic, sc, tmf); - if (ret < 0) { - SNIC_HOST_ERR(snic->shost, - "tgt_abt_io: Tag %x, Failed w err = %d\n", - tag, ret); - - continue; - } - - if (ret == SUCCESS) - abt_cnt++; - } + scsi_host_busy_iter(snic->shost, snic_tgt_scsi_abort_io_iter, &data); - SNIC_SCSI_DBG(snic->shost, "tgt_abt_io: abt_cnt = %d\n", abt_cnt); + SNIC_SCSI_DBG(snic->shost, "tgt_abt_io: abt_cnt = %d\n", data.abt_cnt); return 0; } /* end of snic_tgt_scsi_abort_io */ From patchwork Tue Aug 17 09:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79F42C432BE for ; Tue, 17 Aug 2021 09:17:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 573D060F11 for ; Tue, 17 Aug 2021 09:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239611AbhHQJSN (ORCPT ); Tue, 17 Aug 2021 05:18:13 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47570 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239515AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E3D8E20030; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=ejZsvULmrX+w1BLFUAZBFdTOC/p965kug1KMv0etRvc=; b=lk/Ph4zrWgn1BKlvVH6aAZevO42bKPVTOZCq5TxXtGJpdIXf5TxsM2LBXna9PJIW+guCbf DI5hEKJLiE9EQj4MZbvRMc4Uldxmv+wjMGofaDydcYK8aA5n4+bxYqNVnwObs7097WqGyF tI/aS4cIjbR6OYfOyjoXbHq3scbDQ1M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=ejZsvULmrX+w1BLFUAZBFdTOC/p965kug1KMv0etRvc=; b=IS7iTdkDzVM4hjlIpsGDW5JxEfpD/OwT2hXUdysTJ8O7uR3qifEEls5BrnK5exj67Z3s07 sfiPlJdBPfQO4fBg== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id DDB5DA3BBF; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id D96AF518CEC1; Tue, 17 Aug 2021 11:16:42 +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 49/51] scsi: Move eh_device_reset_handler() to use scsi_device as argument Date: Tue, 17 Aug 2021 11:14:54 +0200 Message-Id: <20210817091456.73342-50-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When resetting a device we shouldn't depend on an existing SCSI command, as this might be completed at any time. Rather we should use 'struct scsi_device' as argument for eh_device_reset_handler(). Signed-off-by: Hannes Reinecke Acked-by: Steffen Maier # for zfcp --- Documentation/scsi/scsi_eh.rst | 2 +- Documentation/scsi/scsi_mid_low_api.rst | 4 +-- drivers/infiniband/ulp/srp/ib_srp.c | 6 ++-- drivers/message/fusion/mptfc.c | 12 +++---- drivers/message/fusion/mptscsih.c | 19 +++++----- drivers/message/fusion/mptscsih.h | 2 +- drivers/s390/scsi/zfcp_scsi.c | 4 +-- drivers/scsi/a100u2w.c | 7 ++-- drivers/scsi/aacraid/linit.c | 9 +++-- drivers/scsi/aha152x.c | 6 ++-- drivers/scsi/aha1542.c | 8 ++--- drivers/scsi/aic7xxx/aic79xx_osm.c | 27 ++++++-------- drivers/scsi/aic7xxx/aic7xxx_osm.c | 4 +-- drivers/scsi/arm/fas216.c | 5 ++- drivers/scsi/arm/fas216.h | 6 ++-- drivers/scsi/be2iscsi/be_main.c | 8 ++--- drivers/scsi/bfa/bfad_im.c | 3 +- drivers/scsi/bnx2fc/bnx2fc.h | 2 +- drivers/scsi/bnx2fc/bnx2fc_io.c | 6 ++-- drivers/scsi/csiostor/csio_scsi.c | 8 ++--- drivers/scsi/cxlflash/main.c | 5 ++- drivers/scsi/dpt_i2o.c | 20 ++++++----- drivers/scsi/dpti.h | 2 +- drivers/scsi/esas2r/esas2r.h | 2 +- drivers/scsi/esas2r/esas2r_main.c | 3 +- drivers/scsi/fnic/fnic.h | 2 +- drivers/scsi/fnic/fnic_scsi.c | 25 +++++++------ drivers/scsi/hpsa.c | 14 ++++---- drivers/scsi/ibmvscsi/ibmvfc.c | 8 ++--- drivers/scsi/ibmvscsi/ibmvscsi.c | 19 +++++----- drivers/scsi/ipr.c | 31 ++++++++-------- drivers/scsi/libfc/fc_fcp.c | 11 +++--- drivers/scsi/libiscsi.c | 15 ++++---- drivers/scsi/libsas/sas_scsi_host.c | 12 +++---- drivers/scsi/lpfc/lpfc_scsi.c | 10 +++--- drivers/scsi/mpi3mr/mpi3mr_os.c | 28 +++++++-------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 31 +++++++--------- drivers/scsi/pcmcia/nsp_cs.h | 2 -- drivers/scsi/pmcraid.c | 6 ++-- drivers/scsi/qedf/qedf_main.c | 6 ++-- drivers/scsi/qla1280.c | 21 ++++++++--- drivers/scsi/qla2xxx/qla_os.c | 29 ++++++++------- drivers/scsi/qla4xxx/ql4_os.c | 23 +++++------- drivers/scsi/scsi_debug.c | 18 +++++----- drivers/scsi/scsi_error.c | 35 +++++++++++++------ drivers/scsi/smartpqi/smartpqi_init.c | 11 +++--- drivers/scsi/snic/snic.h | 2 +- drivers/scsi/snic/snic_scsi.c | 4 +-- drivers/scsi/ufs/ufshcd.c | 8 ++--- drivers/scsi/virtio_scsi.c | 12 +++---- drivers/scsi/vmw_pvscsi.c | 10 +++--- drivers/scsi/wd719x.c | 6 ++-- drivers/scsi/xen-scsifront.c | 23 +++++++----- drivers/staging/rts5208/rtsx.c | 4 +-- .../staging/unisys/visorhba/visorhba_main.c | 14 ++------ drivers/target/loopback/tcm_loop.c | 8 ++--- drivers/usb/storage/scsiglue.c | 4 +-- drivers/usb/storage/uas.c | 3 +- include/scsi/libfc.h | 2 +- include/scsi/libiscsi.h | 2 +- include/scsi/libsas.h | 2 +- include/scsi/scsi_host.h | 2 +- 62 files changed, 314 insertions(+), 329 deletions(-) diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst index e09c81a54702..23f0d09668d9 100644 --- a/Documentation/scsi/scsi_eh.rst +++ b/Documentation/scsi/scsi_eh.rst @@ -214,7 +214,7 @@ considered to fail always. :: int (* eh_abort_handler)(struct scsi_cmnd *); - int (* eh_device_reset_handler)(struct scsi_cmnd *); + int (* eh_device_reset_handler)(struct scsi_device *); int (* eh_target_reset_handler)(struct scsi_target *); int (* eh_bus_reset_handler)(struct Scsi_Host *, int); int (* eh_host_reset_handler)(struct Scsi_Host *); diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst index 0afc1b4f89af..4650c0c6a22a 100644 --- a/Documentation/scsi/scsi_mid_low_api.rst +++ b/Documentation/scsi/scsi_mid_low_api.rst @@ -778,7 +778,7 @@ Details:: /** * eh_device_reset_handler - issue SCSI device reset - * @scp: identifies SCSI device to be reset + * @sdev: identifies SCSI device to be reset * * Returns SUCCESS if command aborted else FAILED * @@ -791,7 +791,7 @@ Details:: * * Optionally defined in: LLD **/ - int eh_device_reset_handler(struct scsi_cmnd * scp) + int eh_device_reset_handler(struct scsi_device * sdev) /** diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 9a822fde6b44..3faadae750e7 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2816,16 +2816,16 @@ static int srp_abort(struct scsi_cmnd *scmnd) return ret; } -static int srp_reset_device(struct scsi_cmnd *scmnd) +static int srp_reset_device(struct scsi_device *sdev) { - struct srp_target_port *target = host_to_target(scmnd->device->host); + struct srp_target_port *target = host_to_target(sdev->host); struct srp_rdma_ch *ch; u8 status; shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n"); ch = &target->ch[0]; - if (srp_send_tsk_mgmt(ch, SRP_TAG_NO_REQ, scmnd->device->lun, + if (srp_send_tsk_mgmt(ch, SRP_TAG_NO_REQ, sdev->lun, SRP_TSK_LUN_RESET, &status)) return FAILED; if (status) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 0cc8c0b795dc..b1a3f21dfb0e 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -102,7 +102,7 @@ static void mptfc_target_destroy(struct scsi_target *starget); static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); static void mptfc_remove(struct pci_dev *pdev); static int mptfc_abort(struct scsi_cmnd *SCpnt); -static int mptfc_dev_reset(struct scsi_cmnd *SCpnt); +static int mptfc_dev_reset(struct scsi_device *sdev); static int mptfc_bus_reset(struct Scsi_Host *shost, int channel); static struct scsi_host_template mptfc_driver_template = { @@ -240,10 +240,10 @@ mptfc_abort(struct scsi_cmnd *SCpnt) } static int -mptfc_dev_reset(struct scsi_cmnd *SCpnt) +mptfc_dev_reset(struct scsi_device *sdev) { - struct Scsi_Host *shost = SCpnt->device->host; - struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); + struct Scsi_Host *shost = sdev->host; + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost); int rtn; @@ -252,8 +252,8 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt) dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT "%s.%d: %d:%llu, executing recovery.\n", __func__, hd->ioc->name, shost->host_no, - SCpnt->device->id, SCpnt->device->lun)); - rtn = mptscsih_dev_reset(SCpnt); + sdev->id, sdev->lun)); + rtn = mptscsih_dev_reset(sdev); } return rtn; } diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 537eafd3ae3a..87ed7cb9e782 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1795,14 +1795,14 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** * mptscsih_dev_reset - Perform a SCSI LOGICAL_UNIT_RESET! - * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to + * @device: Pointer to scsi_device structure, which reset is due to * * (linux scsi_host_template.eh_dev_reset_handler routine) * * Returns SUCCESS or FAILED. **/ int -mptscsih_dev_reset(struct scsi_cmnd * SCpnt) +mptscsih_dev_reset(struct scsi_device * device) { MPT_SCSI_HOST *hd; int retval; @@ -1811,18 +1811,15 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) /* If we can't locate our host adapter structure, return FAILED status. */ - if ((hd = shost_priv(SCpnt->device->host)) == NULL){ - printk(KERN_ERR MYNAM ": lun reset: " - "Can't locate host! (sc=%p)\n", SCpnt); + if ((hd = shost_priv(device->host)) == NULL){ + printk(KERN_ERR MYNAM ": lun reset: Can't locate host!\n"); return FAILED; } ioc = hd->ioc; - printk(MYIOC_s_INFO_FMT "attempting lun reset! (sc=%p)\n", - ioc->name, SCpnt); - scsi_print_command(SCpnt); + printk(MYIOC_s_INFO_FMT "attempting lun reset!\n", ioc->name); - vdevice = SCpnt->device->hostdata; + vdevice = device->hostdata; if (!vdevice || !vdevice->vtarget) { retval = 0; goto out; @@ -1835,8 +1832,8 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) mptscsih_get_tm_timeout(ioc)); out: - printk (MYIOC_s_INFO_FMT "lun reset: %s (sc=%p)\n", - ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); + printk (MYIOC_s_INFO_FMT "lun reset: %s\n", + ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" )); if (retval == 0) return SUCCESS; diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index a5069a84c8ca..a7eabef9080f 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -119,7 +119,7 @@ extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, extern void mptscsih_slave_destroy(struct scsi_device *device); extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); -extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt); +extern int mptscsih_dev_reset(struct scsi_device *); extern int mptscsih_target_reset(struct Scsi_Host *, struct scsi_target *); extern int mptscsih_bus_reset(struct Scsi_Host *, int); extern int mptscsih_host_reset(struct Scsi_Host *sh); diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 6492c3b1b12f..4fa626763bb6 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -333,10 +333,8 @@ static int zfcp_scsi_task_mgmt_function(struct scsi_device *sdev, u8 tm_flags) return retval; } -static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) +static int zfcp_scsi_eh_device_reset_handler(struct scsi_device *sdev) { - struct scsi_device *sdev = scpnt->device; - return zfcp_scsi_task_mgmt_function(sdev, FCP_TMF_LUN_RESET); } diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index b6373dcfe4ea..cb849be6a449 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c @@ -951,12 +951,11 @@ static int inia100_bus_reset(struct Scsi_Host * shost, int channel) Output : None. Return : pSRB - Pointer to SCSI request block. *****************************************************************************/ -static int inia100_device_reset(struct scsi_cmnd * cmd) +static int inia100_device_reset(struct scsi_device * dev) { /* I need Host Control Block Information */ struct orc_host *host; - host = (struct orc_host *) cmd->device->host->hostdata; - return orc_device_reset(host, cmd->device); - + host = (struct orc_host *) dev->host->hostdata; + return orc_device_reset(host, dev); } /** diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index a41caca5f921..7442d428aa29 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -894,12 +894,11 @@ static void aac_tmf_callback(void *context, struct fib *fibptr) /* * aac_eh_dev_reset - Device reset command handling - * @scsi_cmd: SCSI command block causing the reset + * @dev: SCSI device to be reset * */ -static int aac_eh_dev_reset(struct scsi_cmnd *cmd) +static int aac_eh_dev_reset(struct scsi_device *dev) { - struct scsi_device * dev = cmd->device; struct Scsi_Host * host = dev->host; struct aac_dev * aac = (struct aac_dev *)host->hostdata; struct aac_hba_map_info *info; @@ -910,8 +909,8 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd) int status; u8 command; - bus = aac_logical_to_phys(scmd_channel(cmd)); - cid = scmd_id(cmd); + bus = aac_logical_to_phys(sdev_channel(dev)); + cid = sdev_id(dev); if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS) return FAILED; diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 3f96b38b7b56..d2e6ab39147d 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1043,12 +1043,12 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt) * Reset a device * */ -static int aha152x_device_reset(struct scsi_cmnd * SCpnt) +static int aha152x_device_reset(struct scsi_device * sdev) { - struct scsi_device *sdev = SCpnt->device; struct Scsi_Host *shpnt = sdev->host; + struct scsi_cmnd *SCpnt; DECLARE_COMPLETION(done); - int ret, issued, disconnected; + int ret, issued, disconnected = 0; unsigned char old_cmd_len; unsigned long flags; unsigned long timeleft; diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 64d427200d8f..853ef5a46398 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -863,14 +863,14 @@ static int aha1542_release(struct Scsi_Host *sh) * This is a device reset. This is handled by sending a special command * to the device. */ -static int aha1542_dev_reset(struct scsi_cmnd *cmd) +static int aha1542_dev_reset(struct scsi_device *sdev) { - struct Scsi_Host *sh = cmd->device->host; + struct Scsi_Host *sh = sdev->host; struct aha1542_hostdata *aha1542 = shost_priv(sh); unsigned long flags; struct mailbox *mb = aha1542->mb; - u8 target = cmd->device->id; - u8 lun = cmd->device->lun; + u8 target = sdev->id; + u8 lun = sdev->lun; int mbo; struct ccb *ccb = aha1542->ccb; diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 4ffd5c9d78e5..689227717746 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -770,12 +770,11 @@ ahd_linux_abort(struct scsi_cmnd *cmd) * Attempt to send a target reset message to the device that timed out. */ static int -ahd_linux_dev_reset(struct scsi_cmnd *cmd) +ahd_linux_dev_reset(struct scsi_device *sdev) { struct ahd_softc *ahd; struct ahd_linux_device *dev; struct scb *reset_scb; - u_int cdb_byte; int retval = SUCCESS; struct ahd_initiator_tinfo *tinfo; struct ahd_tmode_tstate *tstate; @@ -784,27 +783,22 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) reset_scb = NULL; - ahd = *(struct ahd_softc **)cmd->device->host->hostdata; + ahd = *(struct ahd_softc **)sdev->host->hostdata; - scmd_printk(KERN_INFO, cmd, + sdev_printk(KERN_INFO, sdev, "Attempting to queue a TARGET RESET message:"); - printk("CDB:"); - for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++) - printk(" 0x%x", cmd->cmnd[cdb_byte]); - printk("\n"); - /* * Determine if we currently own this command. */ - dev = scsi_transport_device_data(cmd->device); + dev = scsi_transport_device_data(sdev); if (dev == NULL) { /* * No target device for this command exists, * so we must not still own the command. */ - scmd_printk(KERN_INFO, cmd, "Is not an active device\n"); + sdev_printk(KERN_INFO, sdev, "Is not an active device\n"); return SUCCESS; } @@ -813,12 +807,12 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) */ reset_scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX); if (!reset_scb) { - scmd_printk(KERN_INFO, cmd, "No SCB available\n"); + sdev_printk(KERN_INFO, sdev, "No SCB available\n"); return FAILED; } tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id, - cmd->device->id, &tstate); + sdev->id, &tstate); reset_scb->io_ctx = NULL; reset_scb->platform_data->dev = dev; reset_scb->sg_count = 0; @@ -826,8 +820,8 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) ahd_set_sense_residual(reset_scb, 0); reset_scb->platform_data->xfer_len = 0; reset_scb->hscb->control = 0; - reset_scb->hscb->scsiid = BUILD_SCSIID(ahd, cmd->device); - reset_scb->hscb->lun = cmd->device->lun; + reset_scb->hscb->scsiid = BUILD_SCSIID(ahd, sdev); + reset_scb->hscb->lun = sdev->lun; reset_scb->hscb->cdb_len = 0; reset_scb->hscb->task_management = SIU_TASKMGMT_LUN_RESET; reset_scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE; @@ -1793,7 +1787,8 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb) * was retrieved anytime the first byte of * the sense buffer looks "sane". */ - cmd->sense_buffer[0] = 0; + if (cmd) + cmd->sense_buffer[0] = 0; if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) { #ifdef AHD_REPORT_UNDERFLOWS uint32_t amount_xferred; diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 26ca71e2ddd0..617a74c82921 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -741,11 +741,11 @@ ahc_linux_abort(struct scsi_cmnd *cmd) * Attempt to send a target reset message to the device that timed out. */ static int -ahc_linux_dev_reset(struct scsi_cmnd *cmd) +ahc_linux_dev_reset(struct scsi_device *sdev) { int error; - error = ahc_linux_queue_recovery_cmd(cmd->device, NULL); + error = ahc_linux_queue_recovery_cmd(sdev, NULL); if (error != SUCCESS) printk("aic7xxx_dev_reset returns 0x%x\n", error); return (error); diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index e08aa01006ea..5795414a255a 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2473,16 +2473,15 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt) /** * fas216_eh_device_reset - Reset the device associated with this command - * @SCpnt: command specifing device to reset + * @sdev: device to reset * * Reset the device associated with this command. * Returns: FAILED if unable to reset. * Notes: We won't be re-entered, so we'll only have one device * reset on the go at one time. */ -int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) +int fas216_eh_device_reset(struct scsi_device *sdev) { - struct scsi_device *sdev = SCpnt->device; FAS216_Info *info = (FAS216_Info *)sdev->host->hostdata; unsigned long flags; int i, res = FAILED, target = sdev->id; diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index 0e86c54ca6fe..70c4781f2bab 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h @@ -366,12 +366,12 @@ extern void fas216_print_devices(FAS216_Info *info, struct seq_file *m); */ extern int fas216_eh_abort(struct scsi_cmnd *SCpnt); -/* Function: int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) +/* Function: int fas216_eh_device_reset(struct scsi_device *sdev) * Purpose : Reset the device associated with this command - * Params : SCpnt - command specifing device to reset + * Params : sdev - device to be reset * Returns : FAILED if unable to reset */ -extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt); +extern int fas216_eh_device_reset(struct scsi_device *sdev); /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt) * Purpose : Reset the complete bus associated with this command diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 8d65061fc15b..fb43768b32e4 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -264,7 +264,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) return iscsi_eh_abort(sc); } -static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) +static int beiscsi_eh_device_reset(struct scsi_device *sdev) { struct beiscsi_invldt_cmd_tbl { struct invldt_cmd_tbl tbl[BE_INVLDT_CMD_TBL_SZ]; @@ -280,7 +280,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) unsigned int i, nents; int rc, more = 0; - cls_session = starget_to_session(scsi_target(sc->device)); + cls_session = starget_to_session(scsi_target(sdev)); session = cls_session->dd_data; spin_lock_bh(&session->frwd_lock); @@ -308,7 +308,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) if (!task->sc) continue; - if (sc->device->lun != task->sc->device->lun) + if (sdev->lun != task->sc->device->lun) continue; /** * Can't fit in more cmds? Normally this won't happen b'coz @@ -363,7 +363,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) kfree(inv_tbl); if (rc == SUCCESS) - rc = iscsi_eh_device_reset(sc); + rc = iscsi_eh_device_reset(sdev); return rc; } diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 6169cc5d245f..2a6ec42df551 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -282,9 +282,8 @@ bfad_im_target_reset_send(struct bfad_s *bfad, * */ static int -bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) +bfad_im_reset_lun_handler(struct scsi_device *sdev) { - 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]; diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 34ee55239947..43813d57d682 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -547,7 +547,7 @@ void bnx2fc_add_2_sq(struct bnx2fc_rport *tgt, u16 xid); void bnx2fc_ring_doorbell(struct bnx2fc_rport *tgt); int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd); int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt); -int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd); +int bnx2fc_eh_device_reset(struct scsi_device *sdev); void bnx2fc_rport_event_handler(struct fc_lport *lport, struct fc_rport_priv *rport, enum fc_rport_event event); diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index b59673932cf4..b46cbd196865 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -1074,12 +1074,12 @@ int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt) * Set from SCSI host template to send task mgmt command to the target * and wait for the response */ -int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd) +int bnx2fc_eh_device_reset(struct scsi_device *sdev) { - struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); struct fc_lport *lport = shost_priv(rport_to_shost(rport)); - return bnx2fc_initiate_tmf(lport, rport, sc_cmd->device->lun, + return bnx2fc_initiate_tmf(lport, rport, sdev->lun, FCP_TMF_LUN_RESET); } diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index 0f3c997618c1..1f0524c150f7 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -2056,13 +2056,13 @@ csio_tm_cbfn(struct csio_hw *hw, struct csio_ioreq *req) } static int -csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) +csio_eh_lun_reset_handler(struct scsi_device *sdev) { - 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 *)(sdev->hostdata); + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); struct csio_ioreq *ioreq = NULL; struct csio_scsi_qset *sqset; struct scsi_cmnd *tmf_cmnd; @@ -2169,12 +2169,12 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) 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", sdev->id, sdev->lun); diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index b30b8d30f606..e9b67574b6a3 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -2460,16 +2460,15 @@ static int cxlflash_eh_abort_handler(struct scsi_cmnd *scp) /** * cxlflash_eh_device_reset_handler() - reset a single LUN - * @scp: SCSI command to send. + * @sdev: SCSI device to be reset. * * Return: * SUCCESS as defined in scsi/scsi.h * FAILED as defined in scsi/scsi.h */ -static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) +static int cxlflash_eh_device_reset_handler(struct scsi_device *sdev) { int rc = SUCCESS; - struct scsi_device *sdev = scp->device; struct Scsi_Host *host = sdev->host; struct cxlflash_cfg *cfg = shost_priv(host); struct device *dev = &cfg->dev->dev; diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index cceb25ada357..cf36c077e968 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -675,18 +675,19 @@ static int adpt_abort(struct scsi_cmnd * cmd) // This is the same for BLK and SCSI devices // NOTE this is wrong in the i2o.h definitions // This is not currently supported by our adapter but we issue it anyway -static int adpt_device_reset(struct scsi_cmnd* cmd) +static int adpt_device_reset(struct scsi_device * sdev) { adpt_hba* pHba; u32 msg[4]; u32 rcode; int old_state; - struct adpt_device* d = cmd->device->hostdata; + struct adpt_device* d = sdev->hostdata; - pHba = (void*) cmd->device->host->hostdata[0]; - printk(KERN_INFO"%s: Trying to reset device\n",pHba->name); + pHba = (void*) sdev->host->hostdata[0]; + printk(KERN_INFO "%s: Trying to reset device\n", pHba->name); if (!d) { - printk(KERN_INFO"%s: Reset Device: Device Not found\n",pHba->name); + printk(KERN_INFO "%s: Reset Device: Device Not found\n", + pHba->name); return FAILED; } memset(msg, 0, sizeof(msg)); @@ -699,19 +700,20 @@ static int adpt_device_reset(struct scsi_cmnd* cmd) spin_lock_irq(pHba->host->host_lock); old_state = d->state; d->state |= DPTI_DEV_RESET; - rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER); + rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER); d->state = old_state; if (pHba->host) spin_unlock_irq(pHba->host->host_lock); if (rcode != 0) { if(rcode == -EOPNOTSUPP ){ - printk(KERN_INFO"%s: Device reset not supported\n",pHba->name); + printk(KERN_INFO "%s: Device reset not supported\n", + pHba->name); return FAILED; } - printk(KERN_INFO"%s: Device reset failed\n",pHba->name); + printk(KERN_INFO "%s: Device reset failed\n", pHba->name); return FAILED; } else { - printk(KERN_INFO"%s: Device reset successful\n",pHba->name); + printk(KERN_INFO "%s: Device reset successful\n", pHba->name); return SUCCESS; } } diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h index 48878e69ab2c..763b4cadb21e 100644 --- a/drivers/scsi/dpti.h +++ b/drivers/scsi/dpti.h @@ -36,7 +36,7 @@ static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev, sector_t, int geom[]); static int adpt_bus_reset(struct Scsi_Host* shost, int channel); -static int adpt_device_reset(struct scsi_cmnd* cmd); +static int adpt_device_reset(struct scsi_device * sdev); /* diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index 56d8ff63372a..eb5d1dc3049d 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -975,7 +975,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); /* SCSI error handler (eh) functions */ int esas2r_eh_abort(struct scsi_cmnd *cmd); -int esas2r_device_reset(struct scsi_cmnd *cmd); +int esas2r_device_reset(struct scsi_device *sdev); int esas2r_host_reset(struct Scsi_Host *shost); int esas2r_bus_reset(struct Scsi_Host *shost, int channel); int esas2r_target_reset(struct scsi_target *starget); diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 9f6ceb2cd554..5b3c119fcc6f 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -1174,9 +1174,8 @@ static int esas2r_dev_targ_reset(struct Scsi_Host *shost, int id, u64 lun, return SUCCESS; } -int esas2r_device_reset(struct scsi_cmnd *cmd) +int esas2r_device_reset(struct scsi_device *sdev) { - struct scsi_device *sdev = cmd->device; struct Scsi_Host *shost = sdev->host; esas2r_log(ESAS2R_LOG_INFO, "device_reset"); diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index f0b75ac3443e..3f2b36adf4fa 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -345,7 +345,7 @@ void fnic_update_mac_locked(struct fnic *, u8 *new); int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int fnic_abort_cmd(struct scsi_cmnd *); -int fnic_device_reset(struct scsi_cmnd *); +int fnic_device_reset(struct scsi_device *); int fnic_host_reset(struct Scsi_Host *); int fnic_reset(struct Scsi_Host *); void fnic_scsi_cleanup(struct fc_lport *); diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index b133eb629fa2..9b53f61d716b 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -2193,9 +2193,8 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, * fail to get aborted. It calls driver's eh_device_reset with a SCSI command * on the LUN. */ -int fnic_device_reset(struct scsi_cmnd *sc) +int fnic_device_reset(struct scsi_device *sdev) { - struct scsi_device *sdev = sc->device; struct fc_lport *lp; struct fnic *fnic; struct fnic_io_req *io_req = NULL; @@ -2209,6 +2208,8 @@ int fnic_device_reset(struct scsi_cmnd *sc) struct fnic_stats *fnic_stats; struct reset_stats *reset_stats; int tag = 0; + u64 sc_state = 0; + struct scsi_cmnd *sc = NULL; DECLARE_COMPLETION_ONSTACK(tm_done); /* Wait for rport to unblock */ @@ -2223,7 +2224,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) fnic = lport_priv(lp); fnic_stats = &fnic->fnic_stats; reset_stats = &fnic->fnic_stats.reset_stats; - + tag = fnic->fnic_max_tag_id - 1; atomic64_inc(&reset_stats->device_resets); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, @@ -2239,12 +2240,11 @@ int fnic_device_reset(struct scsi_cmnd *sc) goto fnic_device_reset_end; } - CMD_FLAGS(sc) = FNIC_DEVICE_RESET; /* The last tag is reserved for device reset */ - sc = scsi_host_find_tag(sdev->host, fnic->fnic_max_tag_id - 1); + sc = scsi_host_find_tag(sdev->host, tag); io_lock = fnic_io_lock_hash(fnic, sc); spin_lock_irqsave(io_lock, flags); - if (CMD_SP(sc)) { + if (!sc || CMD_SP(sc)) { /* * Reset tag busy */ @@ -2404,13 +2404,12 @@ int fnic_device_reset(struct scsi_cmnd *sc) } fnic_device_reset_end: - FNIC_TRACE(fnic_device_reset, sc->device->host->host_no, - sc->request->tag, sc, - jiffies_to_msecs(jiffies - start_time), - 0, ((u64)sc->cmnd[0] << 32 | - (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | - (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + if (sc) + sc_state = ((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc); + FNIC_TRACE(fnic_device_reset, sdev->host->host_no, + tag, sc, + jiffies_to_msecs(jiffies - start_time), + 0, 0, sc_state); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Returning from device reset %s\n", diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index f135a10f582b..3ea29c6911a1 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -282,7 +282,7 @@ static int hpsa_scan_finished(struct Scsi_Host *sh, unsigned long elapsed_time); static int hpsa_change_queue_depth(struct scsi_device *sdev, int qdepth); -static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd); +static int hpsa_eh_device_reset_handler(struct scsi_device *sdev); static int hpsa_slave_alloc(struct scsi_device *sdev); static int hpsa_slave_configure(struct scsi_device *sdev); static void hpsa_slave_destroy(struct scsi_device *sdev); @@ -6019,7 +6019,7 @@ static int wait_for_device_to_become_ready(struct ctlr_info *h, /* Need at least one of these error handlers to keep ../scsi/hosts.c from * complaining. Doing a host- or bus-reset can't do anything good here. */ -static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) +static int hpsa_eh_device_reset_handler(struct scsi_device *sdev) { int rc = SUCCESS; int i; @@ -6030,7 +6030,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) unsigned long flags; /* find the controller to which the command to be aborted was sent */ - h = sdev_to_hba(scsicmd->device); + h = sdev_to_hba(sdev); if (h == NULL) /* paranoia */ return FAILED; @@ -6043,7 +6043,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) goto return_reset_status; } - dev = scsicmd->device->hostdata; + dev = sdev->hostdata; if (!dev) { dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); rc = FAILED; @@ -6058,8 +6058,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) /* if controller locked up, we can guarantee command won't complete */ if (lockup_detected(h)) { snprintf(msg, sizeof(msg), - "cmd %d RESET FAILED, lockup detected", - hpsa_get_cmd_index(scsicmd)); + "RESET FAILED, lockup detected"); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); rc = FAILED; goto return_reset_status; @@ -6068,8 +6067,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) /* this reset request might be the result of a lockup; check */ if (detect_controller_lockup(h)) { snprintf(msg, sizeof(msg), - "cmd %d RESET FAILED, new lockup detected", - hpsa_get_cmd_index(scsicmd)); + "RESET FAILED, new lockup detected"); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); rc = FAILED; goto return_reset_status; diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 0d63bc193fee..dc0965538214 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -2866,20 +2866,20 @@ static int ibmvfc_eh_abort_handler(struct scsi_cmnd *cmd) /** * ibmvfc_eh_device_reset_handler - Reset a single LUN - * @cmd: scsi command struct + * @sdev: scsi device struct * * Returns: * SUCCESS / FAST_IO_FAIL / FAILED **/ -static int ibmvfc_eh_device_reset_handler(struct scsi_cmnd *cmd) +static int ibmvfc_eh_device_reset_handler(struct scsi_device *sdev) { - struct scsi_device *sdev = cmd->device; + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); struct ibmvfc_host *vhost = shost_priv(sdev->host); int cancel_rc, block_rc, reset_rc = 0; int rc = FAILED; ENTER; - block_rc = fc_block_scsi_eh(cmd); + block_rc = fc_block_rport(rport); ibmvfc_wait_while_resetting(vhost); if (block_rc != FAST_IO_FAIL) { cancel_rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_LUN_RESET); diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index cce79ffe4644..175a2605362b 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -1623,16 +1623,16 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) * template send this over to the server and wait synchronously for the * response */ -static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) +static int ibmvscsi_eh_device_reset_handler(struct scsi_device *sdev) { - struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host); + struct ibmvscsi_host_data *hostdata = shost_priv(sdev->host); struct srp_tsk_mgmt *tsk_mgmt; struct srp_event_struct *evt; struct srp_event_struct *tmp_evt, *pos; union viosrp_iu srp_rsp; int rsp_rc; unsigned long flags; - u16 lun = lun_from_dev(cmd->device); + u16 lun = lun_from_dev(sdev); unsigned long wait_switch = 0; spin_lock_irqsave(hostdata->host->host_lock, flags); @@ -1641,7 +1641,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) evt = get_event_struct(&hostdata->pool); if (evt == NULL) { spin_unlock_irqrestore(hostdata->host->host_lock, flags); - sdev_printk(KERN_ERR, cmd->device, + sdev_printk(KERN_ERR, sdev, "failed to allocate reset event\n"); return FAILED; } @@ -1675,12 +1675,12 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) spin_unlock_irqrestore(hostdata->host->host_lock, flags); if (rsp_rc != 0) { - sdev_printk(KERN_ERR, cmd->device, + sdev_printk(KERN_ERR, sdev, "failed to send reset event. rc=%d\n", rsp_rc); return FAILED; } - sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%llx\n", + sdev_printk(KERN_INFO, sdev, "resetting device. lun 0x%llx\n", (((u64) lun) << 48)); wait_for_completion(&evt->comp); @@ -1688,7 +1688,8 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) /* make sure we got a good response */ if (unlikely(srp_rsp.srp.rsp.opcode != SRP_RSP)) { if (printk_ratelimit()) - sdev_printk(KERN_WARNING, cmd->device, "reset bad SRP RSP type %d\n", + sdev_printk(KERN_WARNING, sdev, + "reset bad SRP RSP type %d\n", srp_rsp.srp.rsp.opcode); return FAILED; } @@ -1700,7 +1701,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) if (rsp_rc) { if (printk_ratelimit()) - sdev_printk(KERN_WARNING, cmd->device, + sdev_printk(KERN_WARNING, sdev, "reset code %d for task tag 0x%llx\n", rsp_rc, tsk_mgmt->task_tag); return FAILED; @@ -1711,7 +1712,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) */ spin_lock_irqsave(hostdata->host->host_lock, flags); list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { - if ((tmp_evt->cmnd) && (tmp_evt->cmnd->device == cmd->device)) { + if ((tmp_evt->cmnd) && (tmp_evt->cmnd->device == sdev)) { if (tmp_evt->cmnd) tmp_evt->cmnd->result = (DID_RESET << 16); list_del(&tmp_evt->list); diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index fd25378616b9..be11f77368d5 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -5322,7 +5322,7 @@ static int ipr_sata_reset(struct ata_link *link, unsigned int *classes, /** * __ipr_eh_dev_reset - Reset the device - * @scsi_cmd: scsi command struct + * @scsi_dev: scsi device struct * * This function issues a device reset to the affected device. * A LUN reset will be sent to the device first. If that does @@ -5331,7 +5331,7 @@ static int ipr_sata_reset(struct ata_link *link, unsigned int *classes, * Return value: * SUCCESS / FAILED **/ -static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd) +static int __ipr_eh_dev_reset(struct scsi_device *scsi_dev) { struct ipr_cmnd *ipr_cmd; struct ipr_ioa_cfg *ioa_cfg; @@ -5341,8 +5341,8 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd) struct ipr_hrr_queue *hrrq; ENTER; - ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata; - res = scsi_cmd->device->hostdata; + ioa_cfg = (struct ipr_ioa_cfg *) scsi_dev->host->hostdata; + res = scsi_dev->hostdata; /* * If we are currently going through reset/reload, return failed. This will force the @@ -5359,7 +5359,8 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd) for (i = hrrq->min_cmd_id; i <= hrrq->max_cmd_id; i++) { ipr_cmd = ioa_cfg->ipr_cmnd_list[i]; - if (ipr_cmd->ioarcb.res_handle == res->res_handle) { + if (ipr_cmd->scsi_cmd && + ipr_cmd->scsi_cmd->device == scsi_dev) { if (!ipr_cmd->qc) continue; if (ipr_cmnd_is_free(ipr_cmd)) @@ -5375,13 +5376,13 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd) spin_unlock(&hrrq->_lock); } res->resetting_device = 1; - scmd_printk(KERN_ERR, scsi_cmd, "Resetting device\n"); + sdev_printk(KERN_ERR, scsi_dev, "Resetting device\n"); if (ipr_is_gata(res) && res->sata_port) { ap = res->sata_port->ap; - spin_unlock_irq(scsi_cmd->device->host->host_lock); + spin_unlock_irq(scsi_dev->host->host_lock); ata_std_error_handler(ap); - spin_lock_irq(scsi_cmd->device->host->host_lock); + spin_lock_irq(scsi_dev->host->host_lock); } else rc = ipr_device_reset(ioa_cfg, res); res->resetting_device = 0; @@ -5391,27 +5392,27 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd) return rc ? FAILED : SUCCESS; } -static int ipr_eh_dev_reset(struct scsi_cmnd *cmd) +static int ipr_eh_dev_reset(struct scsi_device *sdev) { int rc; struct ipr_ioa_cfg *ioa_cfg; struct ipr_resource_entry *res; - ioa_cfg = (struct ipr_ioa_cfg *) cmd->device->host->hostdata; - res = cmd->device->hostdata; + ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata; + res = sdev->hostdata; if (!res) return FAILED; - spin_lock_irq(cmd->device->host->host_lock); - rc = __ipr_eh_dev_reset(cmd); - spin_unlock_irq(cmd->device->host->host_lock); + spin_lock_irq(sdev->host->host_lock); + rc = __ipr_eh_dev_reset(sdev); + spin_unlock_irq(sdev->host->host_lock); if (rc == SUCCESS) { if (ipr_is_gata(res) && res->sata_port) rc = ipr_wait_for_ops(ioa_cfg, res, ipr_match_res); else - rc = ipr_wait_for_ops(ioa_cfg, cmd->device, ipr_match_lun); + rc = ipr_wait_for_ops(ioa_cfg, sdev, ipr_match_lun); } return rc; diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index e4c998efdb9c..a0106baf4f93 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -2148,16 +2148,15 @@ EXPORT_SYMBOL(fc_eh_abort); /** * fc_eh_device_reset() - Reset a single LUN - * @sc_cmd: The SCSI command which identifies the device whose - * LUN is to be reset + * @sdev: The SCSI device whose LUN is to be reset * * Set from SCSI host template. */ -int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) +int fc_eh_device_reset(struct scsi_device *sdev) { struct fc_lport *lport; struct fc_fcp_pkt *fsp; - struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); int rc = FAILED; int rval; @@ -2165,7 +2164,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) if (rval) return rval; - lport = shost_priv(sc_cmd->device->host); + lport = shost_priv(sdev->host); if (lport->state != LPORT_ST_READY) return rc; @@ -2188,7 +2187,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) /* * flush outstanding commands */ - rc = fc_lun_reset(lport, fsp, scmd_id(sc_cmd), sc_cmd->device->lun); + rc = fc_lun_reset(lport, fsp, sdev->id, sdev->lun); fsp->state = FC_SRB_FREE; fc_fcp_pkt_release(fsp); diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 14ecbeb738f2..cf1cec86a123 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2384,17 +2384,17 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) } EXPORT_SYMBOL_GPL(iscsi_eh_abort); -static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr) +static void iscsi_prep_lun_reset_pdu(struct scsi_device *sdev, struct iscsi_tm *hdr) { memset(hdr, 0, sizeof(*hdr)); hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE; hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK; hdr->flags |= ISCSI_FLAG_CMD_FINAL; - int_to_scsilun(sc->device->lun, &hdr->lun); + int_to_scsilun(sdev->lun, &hdr->lun); hdr->rtt = RESERVED_ITT; } -int iscsi_eh_device_reset(struct scsi_cmnd *sc) +int iscsi_eh_device_reset(struct scsi_device *sdev) { struct iscsi_cls_session *cls_session; struct iscsi_session *session; @@ -2402,11 +2402,10 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) struct iscsi_tm *hdr; int rc = FAILED; - cls_session = starget_to_session(scsi_target(sc->device)); + cls_session = starget_to_session(scsi_target(sdev)); session = cls_session->dd_data; - ISCSI_DBG_EH(session, "LU Reset [sc %p lun %llu]\n", sc, - sc->device->lun); + ISCSI_DBG_EH(session, "LU Reset [lun %llu]\n", sdev->lun); mutex_lock(&session->eh_mutex); spin_lock_bh(&session->frwd_lock); @@ -2424,7 +2423,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) session->tmf_state = TMF_QUEUED; hdr = &session->tmhdr; - iscsi_prep_lun_reset_pdu(sc, hdr); + iscsi_prep_lun_reset_pdu(sdev, hdr); if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, session->lu_reset_timeout)) { @@ -2451,7 +2450,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) spin_lock_bh(&session->frwd_lock); memset(hdr, 0, sizeof(*hdr)); - fail_scsi_tasks(conn, sc->device->lun, DID_ERROR); + fail_scsi_tasks(conn, sdev->lun, DID_ERROR); session->tmf_state = TMF_INITIAL; spin_unlock_bh(&session->frwd_lock); diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 778cd93ee007..a853d24fbf03 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -489,18 +489,18 @@ int sas_eh_abort_handler(struct scsi_cmnd *cmd) EXPORT_SYMBOL_GPL(sas_eh_abort_handler); /* Attempt to send a LUN reset message to a device */ -int sas_eh_device_reset_handler(struct scsi_cmnd *cmd) +int sas_eh_device_reset_handler(struct scsi_device *sdev) { int res; struct scsi_lun lun; - struct Scsi_Host *host = cmd->device->host; - struct domain_device *dev = cmd_to_domain_dev(cmd); + struct Scsi_Host *host = sdev->host; + struct domain_device *dev = sdev_to_domain_dev(sdev); struct sas_internal *i = to_sas_internal(host->transportt); if (current != host->ehandler) - return sas_queue_reset(dev, SAS_DEV_LU_RESET, cmd->device->lun, 0); + return sas_queue_reset(dev, SAS_DEV_LU_RESET, sdev->lun, 0); - int_to_scsilun(cmd->device->lun, &lun); + int_to_scsilun(sdev->lun, &lun); if (!i->dft->lldd_lu_reset) return FAILED; @@ -543,7 +543,7 @@ static int try_to_reset_cmd_device(struct scsi_cmnd *cmd) if (!shost->hostt->eh_device_reset_handler) goto try_target_reset; - res = shost->hostt->eh_device_reset_handler(cmd); + res = shost->hostt->eh_device_reset_handler(cmd->device); if (res == SUCCESS) return res; diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 1b94fb7e4259..6a3ebb051cb7 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -6186,15 +6186,15 @@ lpfc_reset_flush_io_context(struct lpfc_vport *vport, uint16_t tgt_id, * 0x2002 - Success **/ static int -lpfc_device_reset_handler(struct scsi_cmnd *cmnd) +lpfc_device_reset_handler(struct scsi_device *sdev) { - struct Scsi_Host *shost = cmnd->device->host; - struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); + struct Scsi_Host *shost = sdev->host; + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_rport_data *rdata; struct lpfc_nodelist *pnode; - unsigned tgt_id = cmnd->device->id; - uint64_t lun_id = cmnd->device->lun; + unsigned tgt_id = sdev->id; + uint64_t lun_id = sdev->lun; struct lpfc_scsi_event_header scsi_event; int status; u32 logit = LOG_FCP; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 768af4d36037..ed6ded175601 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2995,30 +2995,28 @@ static int mpi3mr_eh_target_reset(struct scsi_target *starget) /** * mpi3mr_eh_dev_reset- Device reset error handling callback - * @scmd: SCSI command reference + * @sdev: SCSI device reference * - * Issue lun reset Task Management and verify the scmd is - * terminated successfully and return status accordingly. + * Issue lun reset Task Management and return status accordingly. * - * Return: SUCCESS of successful termination of the scmd else + * Return: SUCCESS of successful lun reset else * FAILED */ -static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd) +static int mpi3mr_eh_dev_reset(struct scsi_device *sdev) { - struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host); + struct mpi3mr_ioc *mrioc = shost_priv(sdev->host); struct mpi3mr_stgt_priv_data *stgt_priv_data; struct mpi3mr_sdev_priv_data *sdev_priv_data; u16 dev_handle; u8 resp_code = 0; int retval = FAILED, ret = 0; - sdev_printk(KERN_INFO, scmd->device, - "Attempting Device(lun) Reset! scmd(%p)\n", scmd); - scsi_print_command(scmd); + sdev_printk(KERN_INFO, sdev, + "Attempting Device(lun) Reset!\n"); - sdev_priv_data = scmd->device->hostdata; + sdev_priv_data = sdev->hostdata; if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { - sdev_printk(KERN_INFO, scmd->device, + sdev_printk(KERN_INFO, sdev, "SCSI device is not available\n"); retval = SUCCESS; goto out; @@ -3026,7 +3024,7 @@ static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd) stgt_priv_data = sdev_priv_data->tgt_priv_data; dev_handle = stgt_priv_data->dev_handle; - sdev_printk(KERN_INFO, scmd->device, + sdev_printk(KERN_INFO, sdev, "Device(lun) Reset is issued to handle(0x%04x)\n", dev_handle); ret = mpi3mr_issue_tm(mrioc, @@ -3039,9 +3037,9 @@ static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd) retval = SUCCESS; out: - sdev_printk(KERN_INFO, scmd->device, - "Device(lun) reset is %s for scmd(%p)\n", - ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + sdev_printk(KERN_INFO, sdev, + "Device(lun) reset is %s\n", + ((retval == SUCCESS) ? "SUCCESS" : "FAILED")); return retval; } diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index bf6c924d673a..3d048836f4e6 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3365,9 +3365,9 @@ scsih_abort(struct scsi_cmnd *scmd) * Return: SUCCESS if command aborted else FAILED */ static int -scsih_dev_reset(struct scsi_cmnd *scmd) +scsih_dev_reset(struct scsi_device *sdev) { - struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host); + struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host); struct MPT3SAS_DEVICE *sas_device_priv_data; struct _sas_device *sas_device = NULL; struct _pcie_device *pcie_device = NULL; @@ -3375,21 +3375,17 @@ scsih_dev_reset(struct scsi_cmnd *scmd) u8 tr_method = 0; u8 tr_timeout = 30; int r; - - struct scsi_target *starget = scmd->device->sdev_target; + struct scsi_target *starget = scsi_target(sdev); struct MPT3SAS_TARGET *target_priv_data = starget->hostdata; - sdev_printk(KERN_INFO, scmd->device, - "attempting device reset! scmd(0x%p)\n", scmd); - _scsih_tm_display_info(ioc, scmd); + sdev_printk(KERN_INFO, sdev, + "attempting device reset!\n"); - sas_device_priv_data = scmd->device->hostdata; + sas_device_priv_data = sdev->hostdata; if (!sas_device_priv_data || !sas_device_priv_data->sas_target || ioc->remove_host) { - sdev_printk(KERN_INFO, scmd->device, - "device been deleted! scmd(0x%p)\n", scmd); - scmd->result = DID_NO_CONNECT << 16; - scmd->scsi_done(scmd); + sdev_printk(KERN_INFO, sdev, + "device been deleted!\n"); r = SUCCESS; goto out; } @@ -3406,7 +3402,6 @@ scsih_dev_reset(struct scsi_cmnd *scmd) handle = sas_device_priv_data->sas_target->handle; if (!handle) { - scmd->result = DID_RESET << 16; r = FAILED; goto out; } @@ -3420,16 +3415,16 @@ scsih_dev_reset(struct scsi_cmnd *scmd) } else tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET; - r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel, - scmd->device->id, scmd->device->lun, + r = mpt3sas_scsih_issue_locked_tm(ioc, handle, sdev->channel, + sdev->id, sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0, tr_timeout, tr_method); /* Check for busy commands after reset */ - if (r == SUCCESS && scsi_device_busy(scmd->device)) + if (r == SUCCESS && scsi_device_busy(sdev)) r = FAILED; out: - sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n", - ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); + sdev_printk(KERN_INFO, sdev, "device reset: %s\n", + ((r == SUCCESS) ? "SUCCESS" : "FAILED")); if (sas_device) sas_device_put(sas_device); diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 8ccfc410c931..6482553d8665 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -297,8 +297,6 @@ static int nsp_show_info (struct seq_file *m, static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt); /* Error handler */ -/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/ -/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/ static int nsp_eh_bus_reset (struct Scsi_Host *host, int channel); static int nsp_eh_host_reset (struct Scsi_Host *host); static int nsp_bus_reset (nsp_hw_data *data); diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 8a5c49eed94e..e3e50811b0e3 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3014,11 +3014,11 @@ static int pmcraid_eh_abort_handler(struct scsi_cmnd *scsi_cmd) * Return value * SUCCESS or FAILED */ -static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd) +static int pmcraid_eh_device_reset_handler(struct scsi_device *sdev) { - scmd_printk(KERN_INFO, scmd, + sdev_printk(KERN_INFO, sdev, "resetting device due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd->device, + return pmcraid_reset_device(sdev, PMCRAID_INTERNAL_TIMEOUT, RESET_DEVICE_LUN); } diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index b3a5d86992cd..c252a1aa63bd 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -863,12 +863,12 @@ static int qedf_eh_target_reset(struct scsi_target *starget) return qedf_initiate_tmf(rport, 0, FCP_TMF_TGT_RESET); } -static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) +static int qedf_eh_device_reset(struct scsi_device *sdev) { - struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); + struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); QEDF_ERR(NULL, "LUN RESET Issued...\n"); - return qedf_initiate_tmf(rport, sc_cmd->device->lun, FCP_TMF_LUN_RESET); + return qedf_initiate_tmf(rport, sdev->lun, FCP_TMF_LUN_RESET); } bool qedf_wait_for_upload(struct qedf_ctx *qedf) diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index f478e609d0ba..c526f08f37d9 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -973,13 +973,24 @@ qla1280_eh_abort(struct scsi_cmnd * cmd) * Reset the specified SCSI device **************************************************************************/ static int -qla1280_eh_device_reset(struct scsi_cmnd *cmd) +qla1280_eh_device_reset(struct scsi_device *sdev) { - int rc; + struct Scsi_Host *shost = sdev->host; + struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata; + int rc = FAILED; - spin_lock_irq(cmd->device->host->host_lock); - rc = qla1280_error_action(cmd, DEVICE_RESET); - spin_unlock_irq(cmd->device->host->host_lock); + spin_lock_irq(shost->host_lock); + if (qla1280_verbose) + printk(KERN_INFO + "scsi(%ld:%d:%d:%llu): Queueing device reset " + "command.\n", ha->host_no, sdev->channel, + sdev->id, sdev->lun); + if (qla1280_device_reset(ha, sdev->channel, sdev->id) == 0) { + /* issued device reset, set wait conditions */ + rc = qla1280_wait_for_pending_commands(ha, + sdev->channel, sdev->id); + } + spin_unlock_irq(shost->host_lock); return rc; } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index eece94038d13..d7a6f0900897 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1388,9 +1388,8 @@ static char *reset_errors[] = { }; static int -qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_device_reset(struct scsi_device *sdev) { - struct scsi_device *sdev = cmd->device; scsi_qla_host_t *vha = shost_priv(sdev->host); struct qla_hw_data *ha = vha->hw; struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); @@ -1416,41 +1415,41 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) return SUCCESS; ql_log(ql_log_info, vha, 0x8009, - "DEVICE RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", - vha->host_no, cmd->device->id, cmd->device->lun, cmd); + "DEVICE RESET ISSUED nexus=%ld:%d:%llu.\n", + vha->host_no, sdev->id, sdev->lun); err = 0; if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800a, - "Wait for hba online failed for cmd=%p.\n", cmd); + "Wait for hba online failed.\n"); goto eh_reset_failed; } err = 2; - if (ha->isp_ops->lun_reset(fcport, cmd->device->lun, 1) + if (ha->isp_ops->lun_reset(fcport, sdev->lun, 1) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800c, - "lun_reset failed for cmd=%p.\n", cmd); + "lun_reset failed.\n"); goto eh_reset_failed; } err = 3; - if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, - cmd->device->lun, WAIT_LUN) != QLA_SUCCESS) { + if (qla2x00_eh_wait_for_pending_commands(vha, sdev->id, + sdev->lun, WAIT_LUN) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800d, - "wait for pending cmds failed for cmd=%p.\n", cmd); + "wait for pending cmds failed.\n"); goto eh_reset_failed; } ql_log(ql_log_info, vha, 0x800e, - "DEVICE RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", - vha->host_no, cmd->device->id, cmd->device->lun, cmd); + "DEVICE RESET SUCCEEDED nexus:%ld:%d:%llu.\n", + vha->host_no, sdev->id, sdev->lun); return SUCCESS; eh_reset_failed: ql_log(ql_log_info, vha, 0x800f, - "DEVICE RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", - reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, - cmd); + "DEVICE RESET FAILED: %s nexus=%ld:%d:%llu.\n", + reset_errors[err], vha->host_no, sdev->id, sdev->lun); + vha->reset_cmd_err_cnt++; return FAILED; } diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index cedc20fac883..32464525eed3 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -157,7 +157,7 @@ static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len); */ static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); static int qla4xxx_eh_abort(struct scsi_cmnd *cmd); -static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd); +static int qla4xxx_eh_device_reset(struct scsi_device *sdev); static int qla4xxx_eh_target_reset(struct scsi_target *starget); static int qla4xxx_eh_host_reset(struct Scsi_Host *shost); static int qla4xxx_slave_alloc(struct scsi_device *device); @@ -9260,9 +9260,8 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd) * This routine is called by the Linux OS to reset all luns on the * specified target. **/ -static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) +static int qla4xxx_eh_device_reset(struct scsi_device *sdev) { - 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; @@ -9280,13 +9279,11 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d:%llu: DEVICE RESET ISSUED.\n", ha->host_no, - cmd->device->channel, cmd->device->id, cmd->device->lun); + sdev->channel, sdev->id, sdev->lun); DEBUG2(printk(KERN_INFO - "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x," - "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no, - cmd, jiffies, cmd->request->timeout / HZ, - ha->dpc_flags, cmd->result, cmd->allowed)); + "scsi%ld: DEVICE_RESET dpc_flags=%lx\n", + ha->host_no, ha->dpc_flags)); rval = qla4xxx_isp_check_reg(ha); if (rval != QLA_SUCCESS) { @@ -9295,14 +9292,13 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) } /* FIXME: wait for hba to go online */ - stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); + stat = qla4xxx_reset_lun(ha, ddb_entry, sdev->lun); if (stat != QLA_SUCCESS) { ql4_printk(KERN_INFO, ha, "DEVICE RESET FAILED. %d\n", stat); goto eh_dev_reset_done; } - if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device), - cmd->device)) { + if (qla4xxx_eh_wait_for_commands(ha, scsi_target(sdev), sdev)) { ql4_printk(KERN_INFO, ha, "DEVICE RESET FAILED - waiting for " "commands.\n"); @@ -9310,14 +9306,13 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) } /* Send marker. */ - if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun, + if (qla4xxx_send_marker_iocb(ha, ddb_entry, sdev->lun, MM_LUN_RESET) != QLA_SUCCESS) goto eh_dev_reset_done; ql4_printk(KERN_INFO, ha, "scsi(%ld:%d:%d:%llu): DEVICE RESET SUCCEEDED.\n", - ha->host_no, cmd->device->channel, cmd->device->id, - cmd->device->lun); + ha->host_no, sdev->channel, sdev->id, sdev->lun); ret = SUCCESS; diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index c72b7ac1eec6..c0af7c5930a1 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5166,19 +5166,17 @@ static int scsi_debug_abort(struct scsi_cmnd *SCpnt) return SUCCESS; } -static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt) +static int scsi_debug_device_reset(struct scsi_device * sdp) { + struct sdebug_dev_info *devip = + (struct sdebug_dev_info *)sdp->hostdata; + ++num_dev_resets; - if (SCpnt && SCpnt->device) { - struct scsi_device *sdp = SCpnt->device; - struct sdebug_dev_info *devip = - (struct sdebug_dev_info *)sdp->hostdata; - if (SDEBUG_OPT_ALL_NOISE & sdebug_opts) - sdev_printk(KERN_INFO, sdp, "%s\n", __func__); - if (devip) - set_bit(SDEBUG_UA_POR, devip->uas_bm); - } + if (SDEBUG_OPT_ALL_NOISE & sdebug_opts) + sdev_printk(KERN_INFO, sdp, "%s\n", __func__); + if (devip) + set_bit(SDEBUG_UA_POR, devip->uas_bm); return SUCCESS; } diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 1d8e2f655833..44e29558b068 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -910,7 +910,7 @@ static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd) if (!hostt->eh_device_reset_handler) return FAILED; - rtn = hostt->eh_device_reset_handler(scmd); + rtn = hostt->eh_device_reset_handler(scmd->device); if (rtn == SUCCESS) __scsi_report_device_reset(scmd->device, NULL); return rtn; @@ -1195,6 +1195,7 @@ scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn) * scsi_eh_finish_cmd - Handle a cmd that eh is finished with. * @scmd: Original SCSI cmd that eh has finished. * @done_q: Queue for processed commands. + * @result: Final command status to be set * * Notes: * We don't want to use the normal command completion while we are are @@ -1203,10 +1204,18 @@ scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn) * keep a list of pending commands for final completion, and once we * are ready to leave error handling we handle completion for real. */ -void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) +void __scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q, + int host_byte) { + if (host_byte) + set_host_byte(scmd, host_byte); list_move_tail(&scmd->eh_entry, done_q); } + +void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) +{ + __scsi_eh_finish_cmd(scmd, done_q, 0); +} EXPORT_SYMBOL(scsi_eh_finish_cmd); /** @@ -1381,7 +1390,8 @@ static int scsi_eh_test_devices(struct list_head *cmd_list, if (finish_cmds && (try_stu || scsi_eh_action(scmd, SUCCESS) == SUCCESS)) - scsi_eh_finish_cmd(scmd, done_q); + __scsi_eh_finish_cmd(scmd, done_q, + DID_RESET); else list_move_tail(&scmd->eh_entry, work_q); } @@ -1529,8 +1539,9 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, work_q, eh_entry) { if (scmd->device == sdev && scsi_eh_action(scmd, rtn) != FAILED) - scsi_eh_finish_cmd(scmd, - done_q); + __scsi_eh_finish_cmd(scmd, + done_q, + DID_RESET); } } } else { @@ -1598,7 +1609,8 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost, if (rtn == SUCCESS) list_move_tail(&scmd->eh_entry, &check_list); else if (rtn == FAST_IO_FAIL) - scsi_eh_finish_cmd(scmd, done_q); + __scsi_eh_finish_cmd(scmd, done_q, + DID_TRANSPORT_DISRUPTED); else /* push back on work queue for further processing */ list_move(&scmd->eh_entry, work_q); @@ -1663,8 +1675,9 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost, list_for_each_entry_safe(scmd, next, work_q, eh_entry) { if (channel == scmd_channel(scmd)) { if (rtn == FAST_IO_FAIL) - scsi_eh_finish_cmd(scmd, - done_q); + __scsi_eh_finish_cmd(scmd, + done_q, + DID_TRANSPORT_DISRUPTED); else list_move_tail(&scmd->eh_entry, &check_list); @@ -1707,9 +1720,9 @@ static int scsi_eh_host_reset(struct Scsi_Host *shost, if (rtn == SUCCESS) { list_splice_init(work_q, &check_list); } else if (rtn == FAST_IO_FAIL) { - list_for_each_entry_safe(scmd, next, work_q, eh_entry) { - scsi_eh_finish_cmd(scmd, done_q); - } + list_for_each_entry_safe(scmd, next, work_q, eh_entry) + __scsi_eh_finish_cmd(scmd, done_q, + DID_TRANSPORT_DISRUPTED); } else { SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, shost, diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index c1f0f8da9fe2..2b01affd05e9 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -6019,24 +6019,23 @@ static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info, return rc; } -static int pqi_eh_device_reset_handler(struct scsi_cmnd *scmd) +static int pqi_eh_device_reset_handler(struct scsi_device *sdev) { int rc; struct Scsi_Host *shost; struct pqi_ctrl_info *ctrl_info; struct pqi_scsi_dev *device; - shost = scmd->device->host; + shost = sdev->host; ctrl_info = shost_to_hba(shost); - device = scmd->device->hostdata; + device = sdev->hostdata; mutex_lock(&ctrl_info->lun_reset_mutex); dev_err(&ctrl_info->pci_dev->dev, - "resetting scsi %d:%d:%d:%d due to cmd 0x%02x\n", + "resetting scsi %d:%d:%d:%d\n", shost->host_no, - device->bus, device->target, device->lun, - scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff); + device->bus, device->target, device->lun); pqi_check_ctrl_health(ctrl_info); if (pqi_ctrl_offline(ctrl_info)) diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h index 72734c6f98f4..9bdbf3027f47 100644 --- a/drivers/scsi/snic/snic.h +++ b/drivers/scsi/snic/snic.h @@ -379,7 +379,7 @@ extern struct device_attribute *snic_attrs[]; int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int snic_abort_cmd(struct scsi_cmnd *); -int snic_device_reset(struct scsi_cmnd *); +int snic_device_reset(struct scsi_device *); int snic_host_reset(struct Scsi_Host *); void snic_shutdown_scsi_cleanup(struct snic *); diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index ca5ec14907cb..00df269a46ea 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -2129,15 +2129,15 @@ snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag) * command on the LUN. */ int -snic_device_reset(struct scsi_cmnd *sc) +snic_device_reset(struct scsi_device *sdev) { - struct scsi_device *sdev = sc->device; struct Scsi_Host *shost = sdev->host; struct snic *snic = shost_priv(shost); struct snic_req_info *rqi = NULL; int start_time = jiffies; int ret = FAILED; int dr_supp = 0; + struct scsi_cmnd tmf_sc, *sc = &tmf_sc; SNIC_SCSI_DBG(shost, "dev_reset\n"); dr_supp = snic_dev_reset_supported(sdev); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a5c6c9866c1c..033c890f56ea 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6827,11 +6827,11 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, /** * ufshcd_eh_device_reset_handler - device reset handler registered to * scsi layer. - * @cmd: SCSI command pointer + * @sdev: SCSI device pointer * * Returns SUCCESS/FAILED */ -static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) +static int ufshcd_eh_device_reset_handler(struct scsi_device *sdev) { struct Scsi_Host *host; struct ufs_hba *hba; @@ -6839,10 +6839,10 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) int err; u8 resp = 0xF, lun; - host = cmd->device->host; + host = sdev->host; hba = shost_priv(host); - lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); + lun = ufshcd_scsi_to_upiu_lun(sdev->lun); err = ufshcd_issue_tm_cmd(hba, lun, 0, UFS_LOGICAL_RESET, &resp); if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { if (!err) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index b0deaf4af5a3..b97dab8b9531 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -630,12 +630,12 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd) return ret; } -static int virtscsi_device_reset(struct scsi_cmnd *sc) +static int virtscsi_device_reset(struct scsi_device *sdev) { - struct virtio_scsi *vscsi = shost_priv(sc->device->host); + struct virtio_scsi *vscsi = shost_priv(sdev->host); struct virtio_scsi_cmd *cmd; - sdev_printk(KERN_INFO, sc->device, "device reset\n"); + sdev_printk(KERN_INFO, sdev, "device reset\n"); cmd = mempool_alloc(virtscsi_cmd_pool, GFP_NOIO); if (!cmd) return FAILED; @@ -646,9 +646,9 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc) .subtype = cpu_to_virtio32(vscsi->vdev, VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET), .lun[0] = 1, - .lun[1] = sc->device->id, - .lun[2] = (sc->device->lun >> 8) | 0x40, - .lun[3] = sc->device->lun & 0xff, + .lun[1] = sdev->id, + .lun[2] = (sdev->lun >> 8) | 0x40, + .lun[3] = sdev->lun & 0xff, }; return virtscsi_tmf(vscsi, cmd); } diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 847535fce8eb..338d58de0c27 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -969,14 +969,14 @@ static int pvscsi_bus_reset(struct Scsi_Host *host, int channel) return SUCCESS; } -static int pvscsi_device_reset(struct scsi_cmnd *cmd) +static int pvscsi_device_reset(struct scsi_device *sdev) { - struct Scsi_Host *host = cmd->device->host; + struct Scsi_Host *host = sdev->host; struct pvscsi_adapter *adapter = shost_priv(host); unsigned long flags; - scmd_printk(KERN_INFO, cmd, "SCSI device reset on scsi%u:%u\n", - host->host_no, cmd->device->id); + sdev_printk(KERN_INFO, sdev, "SCSI device reset on scsi%u:%u\n", + host->host_no, sdev->id); /* * We don't want to queue new requests for this device after flushing @@ -986,7 +986,7 @@ static int pvscsi_device_reset(struct scsi_cmnd *cmd) spin_lock_irqsave(&adapter->hw_lock, flags); pvscsi_process_request_ring(adapter); - ll_device_reset(adapter, cmd->device->id); + ll_device_reset(adapter, sdev->id); pvscsi_process_completion_ring(adapter); spin_unlock_irqrestore(&adapter->hw_lock, flags); diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index 85abbc82e7c8..41c47ee4cd9b 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -508,10 +508,10 @@ static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device) return SUCCESS; } -static int wd719x_dev_reset(struct scsi_cmnd *cmd) +static int wd719x_dev_reset(struct scsi_device *sdev) { - return wd719x_reset(cmd->device->host, WD719X_CMD_RESET, - cmd->device->id); + return wd719x_reset(sdev->host, WD719X_CMD_RESET, + sdev->id); } static int wd719x_bus_reset(struct Scsi_Host *host, int channel) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 4f08fb4c1333..3f2384e20b2e 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -588,21 +588,26 @@ static int scsifront_queuecommand(struct Scsi_Host *shost, * We have to wait until an answer is returned. This answer contains the * result to be returned to the requestor. */ -static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) +static int scsifront_action_handler(struct scsi_device *sdev, + struct scsi_cmnd *sc) { - struct Scsi_Host *host = sc->device->host; + struct Scsi_Host *host = sdev->host; struct vscsifrnt_info *info = shost_priv(host); - struct vscsifrnt_shadow *shadow, *s = scsi_cmd_priv(sc); + struct vscsifrnt_shadow *shadow; int err = 0; shadow = kzalloc(sizeof(*shadow), GFP_NOIO); if (!shadow) return FAILED; - shadow->act = act; + shadow->act = sc ? VSCSIIF_ACT_SCSI_ABORT : VSCSIIF_ACT_SCSI_RESET; shadow->rslt_reset = RSLT_RESET_WAITING; shadow->sc = sc; - shadow->ref_rqid = s->rqid; + if (sc) { + struct vscsifrnt_shadow *s = scsi_cmd_priv(sc); + + shadow->ref_rqid = s->rqid; + } init_waitqueue_head(&shadow->wq_reset); spin_lock_irq(host->host_lock); @@ -611,7 +616,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) if (scsifront_enter(info)) goto fail; - if (!scsifront_do_request(sc->device, info, shadow)) + if (!scsifront_do_request(sdev, info, shadow)) break; scsifront_return(info); @@ -652,13 +657,13 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act) static int scsifront_eh_abort_handler(struct scsi_cmnd *sc) { pr_debug("%s\n", __func__); - return scsifront_action_handler(sc, VSCSIIF_ACT_SCSI_ABORT); + return scsifront_action_handler(sc->device, sc); } -static int scsifront_dev_reset_handler(struct scsi_cmnd *sc) +static int scsifront_dev_reset_handler(struct scsi_device *sdev) { pr_debug("%s\n", __func__); - return scsifront_action_handler(sc, VSCSIIF_ACT_SCSI_RESET); + return scsifront_action_handler(sdev, NULL); } static int scsifront_sdev_configure(struct scsi_device *sdev) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 898add4d1fc8..86fa0e086700 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -185,9 +185,9 @@ static int command_abort(struct scsi_cmnd *srb) * This invokes the transport reset mechanism to reset the state of the * device */ -static int device_reset(struct scsi_cmnd *srb) +static int device_reset(struct scsi_device *sdev) { - struct rtsx_dev *dev = host_to_rtsx(srb->device->host); + struct rtsx_dev *dev = host_to_rtsx(sdev->host); dev_info(&dev->pci->dev, "%s called\n", __func__); diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 7277cb5c8108..aea913ca56bc 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -334,29 +334,21 @@ static int visorhba_abort_handler(struct scsi_cmnd *scsicmd) /* * visorhba_device_reset_handler - Send TASK_MGMT_LUN_RESET - * @scsicmd: The scsicmd that needs aborted + * @scsidev: The scsidev to be reset * * Return: SUCCESS if inserted, FAILED otherwise */ -static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd) +static int visorhba_device_reset_handler(struct scsi_device *scsidev) { /* issue TASK_MGMT_LUN_RESET */ - struct scsi_device *scsidev; struct visordisk_info *vdisk; - int rtn; - scsidev = scsicmd->device; vdisk = scsidev->hostdata; if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT) atomic_inc(&vdisk->error_count); else atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD); - rtn = forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsidev); - if (rtn == SUCCESS) { - scsicmd->result = DID_RESET << 16; - scsicmd->scsi_done(scsicmd); - } - return rtn; + return forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsidev); } /* diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index fa7352a8eab4..4bdb398e9b9d 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -257,7 +257,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc) * Called from SCSI EH process context to issue a LUN_RESET TMR * to struct scsi_device */ -static int tcm_loop_device_reset(struct scsi_cmnd *sc) +static int tcm_loop_device_reset(struct scsi_device *sdev) { struct tcm_loop_hba *tl_hba; struct tcm_loop_tpg *tl_tpg; @@ -266,10 +266,10 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) /* * Locate the tcm_loop_hba_t pointer */ - tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); - tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; + tl_hba = *(struct tcm_loop_hba **)shost_priv(sdev->host); + tl_tpg = &tl_hba->tl_hba_tpgs[sdev->id]; - ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun, + ret = tcm_loop_issue_tmr(tl_tpg, sdev->lun, 0, TMR_LUN_RESET); return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED; } diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 33456368ca1e..da6e3baac96a 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -449,9 +449,9 @@ static int command_abort(struct scsi_cmnd *srb) * This invokes the transport reset mechanism to reset the state of the * device */ -static int device_reset(struct scsi_cmnd *srb) +static int device_reset(struct scsi_device *sdev) { - struct us_data *us = host_to_us(srb->device->host); + struct us_data *us = host_to_us(sdev->host); int result; usb_stor_dbg(us, "%s called\n", __func__); diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index bef89c6bd1d7..a7b4b5c0948c 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -769,9 +769,8 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) return FAILED; } -static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd) +static int uas_eh_device_reset_handler(struct scsi_device *sdev) { - struct scsi_device *sdev = cmnd->device; struct uas_dev_info *devinfo = sdev->hostdata; struct usb_device *udev = devinfo->udev; unsigned long flags; diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 673ac345d7a6..ca2c57b77717 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -940,7 +940,7 @@ void fc_fcp_destroy(struct fc_lport *); *****************************/ int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int fc_eh_abort(struct scsi_cmnd *); -int fc_eh_device_reset(struct scsi_cmnd *); +int fc_eh_device_reset(struct scsi_device *); int fc_eh_host_reset(struct Scsi_Host *); int fc_slave_alloc(struct scsi_device *); diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index a5c088538a5f..0dbafae5f0e3 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -380,7 +380,7 @@ struct iscsi_host { extern int iscsi_eh_abort(struct scsi_cmnd *sc); extern int iscsi_eh_recover_target(struct scsi_target *starget); 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_eh_device_reset(struct scsi_device *sdev); 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); diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 962bce82bc97..ead5128c8be2 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -693,7 +693,7 @@ void sas_init_dev(struct domain_device *); void sas_task_abort(struct sas_task *); int sas_eh_abort_handler(struct scsi_cmnd *cmd); -int sas_eh_device_reset_handler(struct scsi_cmnd *cmd); +int sas_eh_device_reset_handler(struct scsi_device *sdev); int sas_eh_target_reset_handler(struct scsi_target *starget); extern void sas_target_destroy(struct scsi_target *); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 8fcced0d98bd..3f016915d87d 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -139,7 +139,7 @@ struct scsi_host_template { * Status: REQUIRED (at least one of them) */ int (* eh_abort_handler)(struct scsi_cmnd *); - int (* eh_device_reset_handler)(struct scsi_cmnd *); + int (* eh_device_reset_handler)(struct scsi_device *); int (* eh_target_reset_handler)(struct scsi_target *); int (* eh_bus_reset_handler)(struct Scsi_Host *, int); int (* eh_host_reset_handler)(struct Scsi_Host *); From patchwork Tue Aug 17 09:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D44B6C432BE for ; Tue, 17 Aug 2021 09:17:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC6CB60F11 for ; Tue, 17 Aug 2021 09:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239777AbhHQJRu (ORCPT ); Tue, 17 Aug 2021 05:17:50 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33304 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239462AbhHQJRT (ORCPT ); Tue, 17 Aug 2021 05:17:19 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id EB5A121DC5; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=9nwWOoPD3q3a6wbCxL50wINPxoZ7bocR/ZA60WGd954=; b=QW9kgopPpQ124+8ksXuiHNsgbmQzjHsPKAAZ2K/SXzwuA062uq0uzdYpxxmWthyMPRGI7k SVqnb3epkUk90LGOXoNnIPjzVq8eprTXBjZ+vwEmKwkCT6m7YWCDsE0kETKWNf+ak21UM4 lVXa2sj8XLuhxNe5bXflPwmYleNhdv8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=9nwWOoPD3q3a6wbCxL50wINPxoZ7bocR/ZA60WGd954=; b=P/mfG4nfR66z1Zgv1y3yu7RMIEsNcjOIGMLQvRhD/FG4iyMaoRm7JBFNdB6H9njFwskJQy FPs9BUo6+zzgP3Bw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id E4DF4A3BC0; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id E1E9D518CEC3; Tue, 17 Aug 2021 11:16:42 +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 50/51] scsi: Do not allocate scsi command in scsi_ioctl_reset() Date: Tue, 17 Aug 2021 11:14:55 +0200 Message-Id: <20210817091456.73342-51-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 | 104 +++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 58 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 44e29558b068..5cfff3fa306c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -796,14 +796,14 @@ static void scsi_eh_done(struct scsi_cmnd *scmd) /** * 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")); @@ -817,7 +817,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); } @@ -826,28 +827,29 @@ 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); } @@ -862,7 +864,8 @@ static void __scsi_report_device_reset(struct scsi_device *sdev, void *data) /** * 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 @@ -870,13 +873,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; @@ -884,8 +887,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); } @@ -894,7 +900,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 @@ -902,17 +908,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, NULL); return rtn; } @@ -944,11 +950,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); } /** @@ -1530,7 +1540,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 || @@ -1595,7 +1605,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, @@ -1670,7 +1680,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)) { @@ -1716,7 +1726,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) { @@ -2364,9 +2374,8 @@ scsi_reset_provider_done_command(struct scsi_cmnd *scmd) 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; @@ -2381,25 +2390,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->request = rq; - scmd->cmnd = scsi_req(rq)->cmd; - - scmd->scsi_done = scsi_reset_provider_done_command; - 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); @@ -2409,22 +2399,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; @@ -2450,8 +2440,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 Tue Aug 17 09:14:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 12441107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B71E9C432BE for ; Tue, 17 Aug 2021 09:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F6EB60F11 for ; Tue, 17 Aug 2021 09:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239336AbhHQJSL (ORCPT ); Tue, 17 Aug 2021 05:18:11 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47748 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239388AbhHQJRV (ORCPT ); Tue, 17 Aug 2021 05:17:21 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id F1D8020031; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629191802; 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=REUvCDjGKDy6I/jUjHfIYSMuy1Fh5JzfD6YjKjh7N1w=; b=d6u53/ASZ4HGf6gRWKhGo7afkG8a5/vBmU26u+w0R+8Qgw2mSQdVMLp5/Z3ABgDdMv8PPN WU3UeE52/lA/ZyAvmbrsvqHI9vQDgrv1xLWcZ+pspX6uZiVHxEZTShv15ydaIREQFzO0vx 8E0088SZ+Ken3TARUZ7k3uZ6W8NQpKQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629191802; 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=REUvCDjGKDy6I/jUjHfIYSMuy1Fh5JzfD6YjKjh7N1w=; b=KyW6h1KM7BuZaSLniUTafke3U3X/nsGMDYstGx3wcvlujL2UBISiJGw1QHatbp7kNnmXE/ oqgR3M3LXeU+t8Cw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id EB8CAA3BC1; Tue, 17 Aug 2021 09:16:42 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id E8A84518CEC5; Tue, 17 Aug 2021 11:16:42 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Hannes Reinecke Subject: [PATCH 51/51] scsi_error: streamline scsi_eh_bus_device_reset() Date: Tue, 17 Aug 2021 11:14:56 +0200 Message-Id: <20210817091456.73342-52-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210817091456.73342-1-hare@suse.de> References: <20210817091456.73342-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 than 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 5cfff3fa306c..d4ab10113648 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1516,6 +1516,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) { @@ -1541,27 +1542,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); } /**