Skip to contentSkip to conversation

scsi: megaraid_sas: some bug fixes and cod cleanup

PATCH Applied Guixin Liu 3 participants 14 messages Sep 14, 2022 – Oct 1, 2022

Subsystems (2)
lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

cover scsi: megaraid_sas: some bug fixes and cod cleanup

*** BLURB HERE ***

Hi guys,

This series has bug fix and a few simple cleanups, please review.

Guixin Liu (5):
scsi: megaraid_sas: correct the parameter of scsi_device_lookup
scsi: megaraid_sas: correct an error message
scsi: megaraid_sas: simplify the megasas_update_device_list
scsi: megaraid_sas: remove unnecessary memset
scsi: megaraid_sas: move megasas_dbg_lvl init to megasas_init

 drivers/scsi/megaraid/megaraid_sas_base.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/5 scsi: megaraid_sas: correct the parameter of scsi_device_lookup

When a delete event is received, find the scsi_device and remove it, the scsi_device_lookup`s parameter id should be "ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL".

Fixes ae6874ba4b43 ("scsi: megaraid_sas: Early detection of VD deletion through RaidMap update")
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
index 7f8632c..44d5e93 100644
@@ -8922,7 +8922,7 @@ void megasas_add_remove_devices(struct megasas_instance *instance,
 			sdev1 = scsi_device_lookup(instance->host,
 						   MEGASAS_MAX_PD_CHANNELS +
 						   (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
-						   (ld_target_id - MEGASAS_MAX_DEV_PER_CHANNEL),
+						   (ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL),
 						   0);
 			dev_info(&instance->pdev->dev, "Debug_lgx: ld_target_id:%u, sdev1:%p.\n",
                                ld_target_id, sdev1);
Signature · 1 line
1.8.3.1
maintainer Acked-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] scsi: megaraid_sas: correct the parameter of scsi_device_lookup

Quoted 7 lines · Guixin Liu

When a delete event is received, find the scsi_device and remove it, the scsi_device_lookup`s parameter id should be "ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL".

Fixes ae6874ba4b43 ("scsi: megaraid_sas: Early detection of VD deletion through RaidMap update")

Looks good to me.

author
#3 lore raw

PATCH 2/5 scsi: megaraid_sas: correct an error message

In reply to Guixin Liu

Correct the error message when alloc init request fail.

---
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
index 44d5e93..4973c9c 100644
@@ -7224,7 +7224,7 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance)
 
 		if (!fusion->ioc_init_request) {
 			dev_err(&pdev->dev,
-				"Failed to allocate PD list buffer\n");
+				"Failed to allocate ioc init request\n");
 			return -ENOMEM;
 		}
 
Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH 3/5 scsi: megaraid_sas: simplify the megasas_update_device_list

In reply to Guixin Liu

Remove unnecessary dcmd_ret check and go to statements.

---
 drivers/scsi/megaraid/megaraid_sas_base.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +5 -12
index 4973c9c..1ac33b1 100644
@@ -8766,33 +8766,26 @@ static inline void megasas_remove_scsi_device(struct scsi_device *sdev)
 int megasas_update_device_list(struct megasas_instance *instance,
 			       int event_type)
 {
-	int dcmd_ret = DCMD_SUCCESS;
+	int dcmd_ret;
 
 	if (instance->enable_fw_dev_list) {
-		dcmd_ret = megasas_host_device_list_query(instance, false);
-		if (dcmd_ret != DCMD_SUCCESS)
-			goto out;
+		return megasas_host_device_list_query(instance, false);
 	} else {
 		if (event_type & SCAN_PD_CHANNEL) {
 			dcmd_ret = megasas_get_pd_list(instance);
-
 			if (dcmd_ret != DCMD_SUCCESS)
-				goto out;
+				return dcmd_ret;
 		}
 
 		if (event_type & SCAN_VD_CHANNEL) {
 			if (!instance->requestorId ||
 			megasas_get_ld_vf_affiliation(instance, 0)) {
-				dcmd_ret = megasas_ld_list_query(instance,
+				return megasas_ld_list_query(instance,
 						MR_LD_QUERY_TYPE_EXPOSED_TO_HOST);
-				if (dcmd_ret != DCMD_SUCCESS)
-					goto out;
 			}
 		}
 	}
-
-out:
-	return dcmd_ret;
+	return DCMD_SUCCESS;
 }
 
 /**
Signature · 1 line
1.8.3.1
author
#7 lore raw

PATCH 4/5 scsi: megaraid_sas: remove unnecessary memset

In reply to Guixin Liu

Remove memset pd_list and ld_ids in megasas_get_device_list, because they will be memset in megasas_host_device_list_query or megasas_get_pd_list and megasas_ld_list_query.

---
 drivers/scsi/megaraid/megaraid_sas_base.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +0 -4
index 1ac33b1..b5503f9 100644
@@ -5878,10 +5878,6 @@ static void megasas_setup_reply_map(struct megasas_instance *instance)
 static
 int megasas_get_device_list(struct megasas_instance *instance)
 {
-	memset(instance->pd_list, 0,
-	       (MEGASAS_MAX_PD * sizeof(struct megasas_pd_list)));
-	memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
-
 	if (instance->enable_fw_dev_list) {
 		if (megasas_host_device_list_query(instance, true))
 			return FAILED;
Signature · 1 line
1.8.3.1
maintainer Acked-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] scsi: megaraid_sas: remove unnecessary memset

Quoted 6 lines · Guixin Liu

Remove memset pd_list and ld_ids in megasas_get_device_list, because they will be memset in megasas_host_device_list_query or megasas_get_pd_list and megasas_ld_list_query.

author
#9 lore raw

PATCH 5/5 scsi: megaraid_sas: move megasas_dbg_lvl init to megasas_init

In reply to Guixin Liu

The megasas_dbg_lvl is a driver level parameter, dont init in probe path, otherwise we can not see any debug print when bind a device to megaraid driver.

---
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
index b5503f9..66f84b5 100644
@@ -7439,7 +7439,6 @@ static inline void megasas_init_ctrl_params(struct megasas_instance *instance)
 	    (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY))
 		instance->flag_ieee = 1;
 
-	megasas_dbg_lvl = 0;
 	instance->flag = 0;
 	instance->unload = 1;
 	instance->last_time = 0;
@@ -9011,6 +9010,7 @@ static int __init megasas_init(void)
 	 */
 	pr_info("megasas: %s\n", MEGASAS_VERSION);
 
+	megasas_dbg_lvl = 0;
 	support_poll_for_event = 2;
 	support_device_change = 1;
 	support_nvme_encapsulation = true;
Signature · 1 line
1.8.3.1
author
#11 lore raw
In reply to Guixin Liu

Hi,

Gentle ping.

Best regards,

Guixin Liu

Quoted 17 lines · Guixin Liu

*** BLURB HERE ***

Hi guys,

This series has bug fix and a few simple cleanups, please review.

Guixin Liu (5):
scsi: megaraid_sas: correct the parameter of scsi_device_lookup
scsi: megaraid_sas: correct an error message
scsi: megaraid_sas: simplify the megasas_update_device_list
scsi: megaraid_sas: remove unnecessary memset
scsi: megaraid_sas: move megasas_dbg_lvl init to megasas_init

  drivers/scsi/megaraid/megaraid_sas_base.c | 27 ++++++++-------------------
  1 file changed, 8 insertions(+), 19 deletions(-)
author
#12 lore raw

Hi,

Gentle ping...

I think both "scsi: megaraid_sas: correct the parameter of scsi_device_lookup" and

"scsi: megaraid_sas: move megasas_dbg_lvl init to megasas_init " are importent issue.

Best regards,

Guixin Liu

Quoted 27 lines · Guixin Liu

Hi,

Gentle ping.

Best regards,

Guixin Liu

Quoted 18 lines · Guixin Liu

*** BLURB HERE ***

Hi guys,

This series has bug fix and a few simple cleanups, please review.

Guixin Liu (5):
   scsi: megaraid_sas: correct the parameter of scsi_device_lookup
   scsi: megaraid_sas: correct an error message
   scsi: megaraid_sas: simplify the megasas_update_device_list
   scsi: megaraid_sas: remove unnecessary memset
   scsi: megaraid_sas: move megasas_dbg_lvl init to megasas_init

  drivers/scsi/megaraid/megaraid_sas_base.c | 27
++++++++-------------------

  1 file changed, 8 insertions(+), 19 deletions(-)
#13 lore raw
In reply to Guixin Liu

Guixin,

Quoted 6 lines

Guixin Liu (5):
scsi: megaraid_sas: correct the parameter of scsi_device_lookup
scsi: megaraid_sas: correct an error message
scsi: megaraid_sas: simplify the megasas_update_device_list
scsi: megaraid_sas: remove unnecessary memset
scsi: megaraid_sas: move megasas_dbg_lvl init to megasas_init

Applied to 6.1/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering