linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Sasha Levin <sashal@kernel.org>,
	MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 28/28] scsi: mpt3sas: Fix kernel panic observed on soft HBA unplug
Date: Sat, 18 Apr 2020 10:43:28 -0400	[thread overview]
Message-ID: <20200418144328.10265-28-sashal@kernel.org> (raw)
In-Reply-To: <20200418144328.10265-1-sashal@kernel.org>

From: Sreekanth Reddy <sreekanth.reddy@broadcom.com>

[ Upstream commit cc41f11a21a51d6869d71e525a7264c748d7c0d7 ]

Generic protection fault type kernel panic is observed when user performs
soft (ordered) HBA unplug operation while IOs are running on drives
connected to HBA.

When user performs ordered HBA removal operation, the kernel calls PCI
device's .remove() call back function where driver is flushing out all the
outstanding SCSI IO commands with DID_NO_CONNECT host byte and also unmaps
sg buffers allocated for these IO commands.

However, in the ordered HBA removal case (unlike of real HBA hot removal),
HBA device is still alive and hence HBA hardware is performing the DMA
operations to those buffers on the system memory which are already unmapped
while flushing out the outstanding SCSI IO commands and this leads to
kernel panic.

Don't flush out the outstanding IOs from .remove() path in case of ordered
removal since HBA will be still alive in this case and it can complete the
outstanding IOs. Flush out the outstanding IOs only in case of 'physical
HBA hot unplug' where there won't be any communication with the HBA.

During shutdown also it is possible that HBA hardware can perform DMA
operations on those outstanding IO buffers which are completed with
DID_NO_CONNECT by the driver from .shutdown(). So same above fix is applied
in shutdown path as well.

It is safe to drop the outstanding commands when HBA is inaccessible such
as when permanent PCI failure happens, when HBA is in non-operational
state, or when someone does a real HBA hot unplug operation. Since driver
knows that HBA is inaccessible during these cases, it is safe to drop the
outstanding commands instead of waiting for SCSI error recovery to kick in
and clear these outstanding commands.

Link: https://lore.kernel.org/r/1585302763-23007-1-git-send-email-sreekanth.reddy@broadcom.com
Fixes: c666d3be99c0 ("scsi: mpt3sas: wait for and flush running commands on shutdown/unload")
Cc: stable@vger.kernel.org #v4.14.174+
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 9ef0c6265cd2b..400c055167b0e 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -8280,8 +8280,8 @@ static void scsih_remove(struct pci_dev *pdev)
 
 	ioc->remove_host = 1;
 
-	mpt3sas_wait_for_commands_to_complete(ioc);
-	_scsih_flush_running_cmds(ioc);
+	if (!pci_device_is_present(pdev))
+		_scsih_flush_running_cmds(ioc);
 
 	_scsih_fw_event_cleanup_queue(ioc);
 
@@ -8354,8 +8354,8 @@ scsih_shutdown(struct pci_dev *pdev)
 
 	ioc->remove_host = 1;
 
-	mpt3sas_wait_for_commands_to_complete(ioc);
-	_scsih_flush_running_cmds(ioc);
+	if (!pci_device_is_present(pdev))
+		_scsih_flush_running_cmds(ioc);
 
 	_scsih_fw_event_cleanup_queue(ioc);
 
-- 
2.20.1


      parent reply	other threads:[~2020-04-18 14:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18 14:43 [PATCH AUTOSEL 4.14 01/28] iommu/amd: Fix the configuration of GCR3 table root pointer Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 02/28] watchdog: reset last_hw_keepalive time at start Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 03/28] iommu/vt-d: Fix mm reference leak Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 04/28] scsi: lpfc: Fix kasan slab-out-of-bounds error in lpfc_unreg_login Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 05/28] ceph: return ceph_mdsc_do_request() errors from __get_parent() Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 06/28] ceph: don't skip updating wanted caps when cap is stale Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 07/28] pwm: rcar: Fix late Runtime PM enablement Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 08/28] ASoC: dpcm: allow start or stop during pause for backend Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 09/28] scsi: iscsi: Report unbind session event when the target has been removed Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 10/28] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 11/28] kernel/gcov/fs.c: gcov_seq_next() should increase position index Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 12/28] selftests: kmod: fix handling test numbers above 9 Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 13/28] ipc/util.c: sysvipc_find_ipc() should increase position index Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 14/28] KVM: s390: vsie: Fix possible race when shadowing region 3 tables Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 15/28] s390/cio: avoid duplicated 'ADD' uevents Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 16/28] pwm: pca9685: Fix PWM/GPIO inter-operation Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 17/28] drm/amdkfd: kfree the wrong pointer Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 18/28] pwm: renesas-tpu: Fix late Runtime PM enablement Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 19/28] pwm: bcm2835: Dynamically allocate base Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 20/28] libnvdimm: Out of bounds read in __nd_ioctl() Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 21/28] ocfs2: no need try to truncate file beyond i_size Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 22/28] hfsplus: fix crash and filesystem corruption when deleting files Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 23/28] perf/core: Disable page faults when getting phys address Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 24/28] libata: Return correct status in sata_pmp_eh_recover_pm() when ATA_DFLAG_DETACH is set Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 25/28] ALSA: ice1724: Fix invalid access for enumerated ctl items Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 26/28] ALSA: hda: Fix potential access overflow in beep helper Sasha Levin
2020-04-18 14:43 ` [PATCH AUTOSEL 4.14 27/28] KVM: s390: vsie: Fix delivery of addressing exceptions Sasha Levin
2020-04-18 14:43 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200418144328.10265-28-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).