From patchwork Fri Aug 31 04:34:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10583113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3472920 for ; Fri, 31 Aug 2018 04:35:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B46F62C18F for ; Fri, 31 Aug 2018 04:35:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8F5E2C1D8; Fri, 31 Aug 2018 04:35:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47AD62C18F for ; Fri, 31 Aug 2018 04:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727234AbeHaIkz (ORCPT ); Fri, 31 Aug 2018 04:40:55 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52326 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726660AbeHaIkz (ORCPT ); Fri, 31 Aug 2018 04:40:55 -0400 Received: by mail-wm0-f65.google.com with SMTP id y139-v6so3853332wmc.2 for ; Thu, 30 Aug 2018 21:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ohzi7KpBFCyiWNATnJhkmbRSw0M3V5klQnjk6KxZQkw=; b=DNWums5qigBUlgqiu0MyfI3DClz4VC54MQlHYp9XQkPxoD9KDalR0Yk7Xpt2KzakDg 0AxI84Crn79YJB1e5An8c6aF5qIa5aHp6Gk+kDWj1pMS1dYbcnHcKOTAGcL8oHnzQvQc xrAhytlCwxdWg6+mrhjKU1AfeM0A2DgxYYeYE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ohzi7KpBFCyiWNATnJhkmbRSw0M3V5klQnjk6KxZQkw=; b=mRUid+2mkEqle4qKch4fgytoFOxGMiCRCvwdUdqgGkwshF4u3r/WYCaIh1aeh8D1DE /pV14MS6wKcQAjUkZJHZ0lCrmFuoISIlhXEsZtTPL3GXSN6XL+pK0qYR/3QJWn7MxH3I mfnExa+iM3x4pMu0auPmK+pLvYfqDUN6n5CA7Aa1WU7tW6q4I7L+Joe6SMgg/tJIe/XE kACj9pWEovp/IKi5NiATsJwvOztJnIL3xj9viuH0bzGQBobQ6Px/rlk/MN4QPgiIX/9K 2dYw7LMXDVUJClhmTSI8m5v44x63SapnJmxA1aKZoLCxUG98ErPj893fTVhiN0v2Jsxr xpDA== X-Gm-Message-State: APzg51AGdQxG/mujZOS1BKNB+1yG8ALjtkHZAgBb9irhP7LbXjbg5CVe R0FJ2Ef5uD7MgSV1iGpcp1AC371yzLM= X-Google-Smtp-Source: ANB0Vdb9wT23EmqhjkwMjliS98BEjlTHHKMc6qy1w0JApjcFtp0oABTzOvubfLOu7La2uHkQMTc/4g== X-Received: by 2002:a1c:398b:: with SMTP id g133-v6mr3318207wma.5.1535690119588; Thu, 30 Aug 2018 21:35:19 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id h15-v6sm2261735wmb.21.2018.08.30.21.35.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 21:35:19 -0700 (PDT) From: Suganath Prabu S To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu S Subject: [Patch v1 5/7] mpt3sas: Fix Sync cache command failure during driver unload. Date: Fri, 31 Aug 2018 00:34:39 -0400 Message-Id: <1535690081-16116-6-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535690081-16116-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1535690081-16116-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is to fix Sync cache and start stop command failures with DID_NO_CONNECT during driver unload. 1) Release drives first from SML, then remove internally in driver. 2) And allow sync cache and Start stop commands to firmware, even when remove_host flag is set Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 41 ++++++++++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_transport.c | 7 ++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 2c7f44c..f796808 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3806,6 +3806,43 @@ _scsih_tm_tr_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, return _scsih_check_for_pending_tm(ioc, smid); } +/** _scsih_allow_scmd_to_device - check whether scmd needs to + * issue to IOC or not. + * @ioc: per adapter object + * @scmd: pointer to scsi command object + * + * Returns true if scmd can be issued to IOC otherwise returns false. + */ +inline bool _scsih_allow_scmd_to_device(struct MPT3SAS_ADAPTER *ioc, + struct scsi_cmnd *scmd) +{ + + if (ioc->pci_error_recovery) + return false; + + if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { + if (ioc->remove_host) + return false; + + return true; + } + + + if (ioc->remove_host) { + if (mpt3sas_base_pci_device_is_unplugged(ioc)) + return false; + + switch (scmd->cmnd[0]) { + case SYNCHRONIZE_CACHE: + case START_STOP: + return true; + default: + return false; + } + } + + return true; +} /** * _scsih_sas_control_complete - completion routine @@ -4640,7 +4677,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) return 0; } - if (ioc->pci_error_recovery || ioc->remove_host) { + if (!(_scsih_allow_scmd_to_device(ioc, scmd))) { scmd->result = DID_NO_CONNECT << 16; scmd->scsi_done(scmd); return 0; @@ -9876,6 +9913,7 @@ static void scsih_remove(struct pci_dev *pdev) /* release all the volumes */ _scsih_ir_shutdown(ioc); + sas_remove_host(shost); list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, list) { if (raid_device->starget) { @@ -9918,7 +9956,6 @@ static void scsih_remove(struct pci_dev *pdev) ioc->sas_hba.num_phys = 0; } - sas_remove_host(shost); mpt3sas_base_detach(ioc); spin_lock(&gioc_lock); list_del(&ioc->list); diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index b10d73e..742da74 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -817,10 +817,13 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address, mpt3sas_port->remote_identify.sas_address, mpt3sas_phy->phy_id); mpt3sas_phy->phy_belongs_to_port = 0; - sas_port_delete_phy(mpt3sas_port->port, mpt3sas_phy->phy); + if (!ioc->remove_host) + sas_port_delete_phy(mpt3sas_port->port, + mpt3sas_phy->phy); list_del(&mpt3sas_phy->port_siblings); } - sas_port_delete(mpt3sas_port->port); + if (!ioc->remove_host) + sas_port_delete(mpt3sas_port->port); kfree(mpt3sas_port); }