From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kumar Meiyappan <Kumar.Meiyappan@microchip.com>,
Scott Benesh <scott.benesh@microchip.com>,
Scott Teel <scott.teel@microchip.com>,
Mike Mcgowan <mike.mcgowan@microchip.com>,
Kevin Barnett <kevin.barnett@microchip.com>,
Don Brace <don.brace@microchip.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Sasha Levin <sashal@kernel.org>,
jejb@linux.ibm.com, storagedev@microchip.com,
linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 09/16] scsi: smartpqi: Correct device removal for multi-actuator devices
Date: Mon, 19 Dec 2022 20:20:46 -0500 [thread overview]
Message-ID: <20221220012053.1222101-9-sashal@kernel.org> (raw)
In-Reply-To: <20221220012053.1222101-1-sashal@kernel.org>
From: Kumar Meiyappan <Kumar.Meiyappan@microchip.com>
[ Upstream commit cc9befcbbb5ebce77726f938508700d913530035 ]
Correct device count for multi-actuator drives which can cause kernel
panics.
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Mike Mcgowan <mike.mcgowan@microchip.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Kumar Meiyappan <Kumar.Meiyappan@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
Link: https://lore.kernel.org/r/166793531872.322537.9003385780343419275.stgit@brunhilda
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/smartpqi/smartpqi.h | 2 +-
drivers/scsi/smartpqi/smartpqi_init.c | 33 +++++++++++++++++++--------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index e550b12e525a..c8235f15728b 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -1130,7 +1130,7 @@ struct pqi_scsi_dev {
u8 phy_id;
u8 ncq_prio_enable;
u8 ncq_prio_support;
- u8 multi_lun_device_lun_count;
+ u8 lun_count;
bool raid_bypass_configured; /* RAID bypass configured */
bool raid_bypass_enabled; /* RAID bypass enabled */
u32 next_bypass_group[RAID_MAP_MAX_DATA_DISKS_PER_ROW];
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 78fc743f46e4..9f0f69c1ed66 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -1610,9 +1610,7 @@ static int pqi_get_physical_device_info(struct pqi_ctrl_info *ctrl_info,
&id_phys->alternate_paths_phys_connector,
sizeof(device->phys_connector));
device->bay = id_phys->phys_bay_in_box;
- device->multi_lun_device_lun_count = id_phys->multi_lun_device_lun_count;
- if (!device->multi_lun_device_lun_count)
- device->multi_lun_device_lun_count = 1;
+ device->lun_count = id_phys->multi_lun_device_lun_count;
if ((id_phys->even_more_flags & PQI_DEVICE_PHY_MAP_SUPPORTED) &&
id_phys->phy_count)
device->phy_id =
@@ -1746,7 +1744,7 @@ static bool pqi_keep_device_offline(struct pqi_ctrl_info *ctrl_info,
return offline;
}
-static int pqi_get_device_info(struct pqi_ctrl_info *ctrl_info,
+static int pqi_get_device_info_phys_logical(struct pqi_ctrl_info *ctrl_info,
struct pqi_scsi_dev *device,
struct bmic_identify_physical_device *id_phys)
{
@@ -1763,6 +1761,20 @@ static int pqi_get_device_info(struct pqi_ctrl_info *ctrl_info,
return rc;
}
+static int pqi_get_device_info(struct pqi_ctrl_info *ctrl_info,
+ struct pqi_scsi_dev *device,
+ struct bmic_identify_physical_device *id_phys)
+{
+ int rc;
+
+ rc = pqi_get_device_info_phys_logical(ctrl_info, device, id_phys);
+
+ if (rc == 0 && device->lun_count == 0)
+ device->lun_count = 1;
+
+ return rc;
+}
+
static void pqi_show_volume_status(struct pqi_ctrl_info *ctrl_info,
struct pqi_scsi_dev *device)
{
@@ -1897,7 +1909,7 @@ static inline void pqi_remove_device(struct pqi_ctrl_info *ctrl_info, struct pqi
int rc;
int lun;
- for (lun = 0; lun < device->multi_lun_device_lun_count; lun++) {
+ for (lun = 0; lun < device->lun_count; lun++) {
rc = pqi_device_wait_for_pending_io(ctrl_info, device, lun,
PQI_REMOVE_DEVICE_PENDING_IO_TIMEOUT_MSECS);
if (rc)
@@ -2076,6 +2088,7 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
existing_device->sas_address = new_device->sas_address;
existing_device->queue_depth = new_device->queue_depth;
existing_device->device_offline = false;
+ existing_device->lun_count = new_device->lun_count;
if (pqi_is_logical_device(existing_device)) {
existing_device->is_external_raid_device = new_device->is_external_raid_device;
@@ -2108,10 +2121,6 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
existing_device->phy_connected_dev_type = new_device->phy_connected_dev_type;
memcpy(existing_device->box, new_device->box, sizeof(existing_device->box));
memcpy(existing_device->phys_connector, new_device->phys_connector, sizeof(existing_device->phys_connector));
-
- existing_device->multi_lun_device_lun_count = new_device->multi_lun_device_lun_count;
- if (existing_device->multi_lun_device_lun_count == 0)
- existing_device->multi_lun_device_lun_count = 1;
}
}
@@ -6484,6 +6493,12 @@ static void pqi_slave_destroy(struct scsi_device *sdev)
return;
}
+ device->lun_count--;
+ if (device->lun_count > 0) {
+ mutex_unlock(&ctrl_info->scan_mutex);
+ return;
+ }
+
spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
list_del(&device->scsi_device_list_entry);
spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
--
2.35.1
next prev parent reply other threads:[~2022-12-20 1:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 1:20 [PATCH AUTOSEL 6.1 01/16] crypto: hisilicon/hpre - fix resource leak in remove process Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 02/16] scsi: lpfc: Fix hard lockup when reading the rx_monitor from debugfs Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 03/16] scsi: ufs: Reduce the START STOP UNIT timeout Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 04/16] crypto: hisilicon/qm - increase the memory of local variables Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 05/16] Revert "PCI: Clear PCI_STATUS when setting up device" Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 06/16] scsi: elx: libefc: Fix second parameter type in state callbacks Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 07/16] hugetlbfs: fix null-ptr-deref in hugetlbfs_parse_param() Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 08/16] scsi: smartpqi: Add new controller PCI IDs Sasha Levin
2022-12-20 1:20 ` Sasha Levin [this message]
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 10/16] drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid() Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 11/16] drm/sti: Fix return type of sti_{dvo,hda,hdmi}_connector_mode_valid() Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 12/16] scsi: target: iscsi: Fix a race condition between login_work and the login thread Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 13/16] iomap: write iomap validity checks Sasha Levin
2022-12-20 4:01 ` Dave Chinner
2022-12-21 12:19 ` Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 14/16] orangefs: Fix kmemleak in orangefs_prepare_debugfs_help_string() Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 15/16] orangefs: Fix kmemleak in orangefs_sysfs_init() Sasha Levin
2022-12-20 1:20 ` [PATCH AUTOSEL 6.1 16/16] orangefs: Fix kmemleak in orangefs_{kernel,client}_debug_init() Sasha Levin
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=20221220012053.1222101-9-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Kumar.Meiyappan@microchip.com \
--cc=don.brace@microchip.com \
--cc=jejb@linux.ibm.com \
--cc=kevin.barnett@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mike.mcgowan@microchip.com \
--cc=scott.benesh@microchip.com \
--cc=scott.teel@microchip.com \
--cc=stable@vger.kernel.org \
--cc=storagedev@microchip.com \
/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