Skip to contentSkip to conversation

megaraid_sas : Modify return value of megasas_issue_blocked_cmd() and wait_and_poll() to consider command status returned by firmware

PATCH In review [email protected] 4 participants 5 messages May 6, 2015 – May 29, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 megaraid_sas : Modify return value of megasas_issue_blocked_cmd() and wait_and_poll() to consider command status returned by firmware

This patch is rebased on top of recently sent 18 patches(submitted by me) for megaraid_sas driver.

Change the return value of wait_and_poll() and megsas_issue_blocked_cmd() based on MFI_STAT returned by firmware for that command. Earlier driver always send return type based on command completion (but never check MFI_STAT_OK for that command), so even if command is failed by firmware still driver will return SUCCESS status from these functions wait_and_poll() and megsas_issue_blocked_cmd() and if caller of these functions does not check command status (MFI_STAT), then it may endup using invalid data returned in DMA buffers(one of the example is megasas_ld_list_query DCMD). Best thing to avoid this type of issue is do error handling and set proper return type from caller function wait_and_poll() and megsas_issue_blocked_cmd().

The change proposed in this patch will fix the regression introduced in patch- "90dc9d9 megaraid_sas : MFI MPT linked list corruption fix" inside function megasas_ld_list_query().
Prior to this MFI MPT linked list corruption fix patch, megasas_ld_list_query() function used to check DCMD status(returned by firmware) but with this linked list corruption fix patch, DCMD status will not be checked inside function megasas_ld_list_query() and introduced this issue of wrong data being used by function megasas_ld_list_query().

---
 drivers/scsi/megaraid/megaraid_sas.h        |    2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   |   67 +++++++++++----------------
 drivers/scsi/megaraid/megaraid_sas_fusion.c |    3 +-
 3 files changed, 30 insertions(+), 42 deletions(-)
drivers/scsi/megaraid/megaraid_sas.h +1 -1
index 53a3c3f..20c3754 100644
@@ -1894,7 +1894,7 @@ struct megasas_cmd {
 
 	u32 index;
 	u8 sync_cmd;
-	u8 cmd_status;
+	u8 cmd_status_drv;
 	u8 abort_aen;
 	u8 retry_for_fw_reset;
 
drivers/scsi/megaraid/megaraid_sas_base.c +27 -40

196 lines not on this page · raw message

drivers/scsi/megaraid/megaraid_sas_fusion.c +2 -1
index 826ba1c..99ad5d7 100644
@@ -584,7 +584,8 @@ wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
 	if (frame_hdr->cmd_status == 0xff)
 		return -ETIME;
 
-	return 0;
+	return (frame_hdr->cmd_status == MFI_STAT_OK) ?
+		0 : 1;
 }
 
 /**
Signature · 1 line
1.7.1
#1 lore raw
Quoted 28 lines · On 05/06/2015 03:31 PM, [email protected] wrote:

This patch is rebased on top of recently sent 18 patches(submitted by me) for megaraid_sas driver.

Change the return value of wait_and_poll() and megsas_issue_blocked_cmd() based on MFI_STAT returned by firmware for that command. Earlier driver always send return type based on command completion (but never check MFI_STAT_OK for that command), so even if command is failed by firmware still driver will return SUCCESS status from these functions wait_and_poll() and megsas_issue_blocked_cmd() and if caller of these functions does not check command status (MFI_STAT), then it may endup using invalid data returned in DMA buffers(one of the example is megasas_ld_list_query DCMD). Best thing to avoid this type of issue is do error handling and set proper return type from caller function wait_and_poll() and megsas_issue_blocked_cmd().

The change proposed in this patch will fix the regression introduced in patch- "90dc9d9 megaraid_sas : MFI MPT linked list corruption fix" inside function megasas_ld_list_query().
Prior to this MFI MPT linked list corruption fix patch, megasas_ld_list_query() function used to check DCMD status(returned by firmware) but with this linked list corruption fix patch, DCMD status will not be checked inside function megasas_ld_list_query() and introduced this issue of wrong data being used by function megasas_ld_list_query().

---
 drivers/scsi/megaraid/megaraid_sas.h        |    2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   |   67 +++++++++++----------------
 drivers/scsi/megaraid/megaraid_sas_fusion.c |    3 +-
 3 files changed, 30 insertions(+), 42 deletions(-)
drivers/scsi/megaraid/megaraid_sas.h +0 -0
index 53a3c3f..20c3754 100644

drivers/scsi/megaraid/megaraid_sas.h struct megasas_cmd { · line 1900

Quoted 8 lines
drivers/scsi/megaraid/megaraid_sas.h +1 -1
@@ -1894,7 +1894,7 @@ struct megasas_cmd {
 
 	u32 index;
 	u8 sync_cmd;
-	u8 cmd_status;
+	u8 cmd_status_drv;
 	u8 abort_aen;
 	u8 retry_for_fw_reset;
 

Can you please avoid the renaming here?
It doesn't serve any purpose, and keeping it will make the diff smaller.

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke		               zSeries & Storage
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 11 lines

-----Original Message-----
From: Hannes Reinecke [mailto:[email protected]]
Sent: Friday, May 15, 2015 3:04 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] megaraid_sas : Modify return value of megasas_issue_blocked_cmd() and wait_and_poll() to consider command status returned by firmware

Quoted 2 lines
Quoted 1 line · On 05/06/2015 03:31 PM, [email protected] wrote:

This patch is rebased on top of recently sent 18 patches(submitted by

me)

Quoted 7 lines

for megaraid_sas driver.

Quoted 6 lines

Change the return value of wait_and_poll() and megsas_issue_blocked_cmd() based on MFI_STAT returned by firmware for that command. Earlier driver always send return type based on command completion (but never check MFI_STAT_OK for that command), so even if command is failed by firmware still driver will return SUCCESS status

from

Quoted 2 lines

these functions wait_and_poll() and megsas_issue_blocked_cmd() and if caller of these functions does not check command status (MFI_STAT), then

it

Quoted 1 line

may endup using invalid data returned in DMA buffers(one of the example

is

Quoted 2 lines

megasas_ld_list_query DCMD). Best thing to avoid this type of issue is do error handling and set proper return type from caller function

wait_and_poll()

Quoted 4 lines

and megsas_issue_blocked_cmd().

Quoted 3 lines

The change proposed in this patch will fix the regression introduced in patch- "90dc9d9 megaraid_sas : MFI MPT linked list corruption fix"

inside

Quoted 4 lines

function megasas_ld_list_query().

Quoted 3 lines

Prior to this MFI MPT linked list corruption fix patch, megasas_ld_list_query() function used to check DCMD status(returned by firmware) but with this linked list corruption fix patch, DCMD status

will not

Quoted 1 line

be checked inside function megasas_ld_list_query() and introduced this

issue

Quoted 8 lines

of wrong data being used by function megasas_ld_list_query().

Quoted 7 lines
---
 drivers/scsi/megaraid/megaraid_sas.h        |    2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   |   67

+++++++++++------------

Quoted 11 lines

----

Quoted 10 lines
 drivers/scsi/megaraid/megaraid_sas_fusion.c |    3 +-
 3 files changed, 30 insertions(+), 42 deletions(-)
drivers/scsi/megaraid/megaraid_sas.h +0 -0
index 53a3c3f..20c3754 100644
@@ -1894,7 +1894,7 @@ struct megasas_cmd {
 
Quoted 9 lines

drivers/scsi/megaraid/megaraid_sas.h struct megasas_cmd { · line 1900

Quoted 7 lines
drivers/scsi/megaraid/megaraid_sas.h +1 -1
 	u32 index;
 	u8 sync_cmd;
-	u8 cmd_status;
+	u8 cmd_status_drv;
 	u8 abort_aen;
 	u8 retry_for_fw_reset;
 

Can you please avoid the renaming here?
It doesn't serve any purpose, and keeping it will make the diff smaller.

For readability we make this "cmd_status_drv", since this is driver's internal structure(so drv suffix). Same name "cmd_status "is used in multiple structs(megasas_hdr, megasas_init_frame, megasas_io_frame) which are shared across driver and other components(firmware and applications). Also, keeping it "cmd_status" will not make patch smaller since "ENODATA" is also replaced by "MFI_STAT_INVALID_STATUS" in most of lines, where "cmd_status_drv" is referenced.

Thanks,
Sumit

Quoted 9 lines

Cheers,

Hannes
--
Dr. Hannes Reinecke zSeries & Storage
[email protected] +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB

21284

Quoted 1 line

(AG Nürnberg)

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 1/1
#3 lore raw
In reply to [email protected]
Quoted 14 lines · On 05/06/2015 03:31 PM, [email protected] wrote:

This patch is rebased on top of recently sent 18 patches(submitted by me) for megaraid_sas driver.

Change the return value of wait_and_poll() and megsas_issue_blocked_cmd() based on MFI_STAT returned by firmware for that command. Earlier driver always send return type based on command completion (but never check MFI_STAT_OK for that command), so even if command is failed by firmware still driver will return SUCCESS status from these functions wait_and_poll() and megsas_issue_blocked_cmd() and if caller of these functions does not check command status (MFI_STAT), then it may endup using invalid data returned in DMA buffers(one of the example is megasas_ld_list_query DCMD). Best thing to avoid this type of issue is do error handling and set proper return type from caller function wait_and_poll() and megsas_issue_blocked_cmd().

The change proposed in this patch will fix the regression introduced in patch- "90dc9d9 megaraid_sas : MFI MPT linked list corruption fix" inside function megasas_ld_list_query().
Prior to this MFI MPT linked list corruption fix patch, megasas_ld_list_query() function used to check DCMD status(returned by firmware) but with this linked list corruption fix patch, DCMD status will not be checked inside function megasas_ld_list_query() and introduced this issue of wrong data being used by function megasas_ld_list_query().

Quoted 3 lines

This patch fixes an issue spotted on my test system. Thanks for posting.

Tomas

#4 lore raw

James,

Gentle reminder. Can we consider this patch.

Thanks,
Sumit

Quoted 29 lines · Tomas Henzl
Quoted 14 lines · On 05/06/2015 03:31 PM, [email protected] wrote:

This patch is rebased on top of recently sent 18 patches(submitted by me) for megaraid_sas driver.

Change the return value of wait_and_poll() and megsas_issue_blocked_cmd() based on MFI_STAT returned by firmware for that command. Earlier driver always send return type based on command completion (but never check MFI_STAT_OK for that command), so even if command is failed by firmware still driver will return SUCCESS status from these functions wait_and_poll() and megsas_issue_blocked_cmd() and if caller of these functions does not check command status (MFI_STAT), then it may endup using invalid data returned in DMA buffers(one of the example is megasas_ld_list_query DCMD). Best thing to avoid this type of issue is do error handling and set proper return type from caller function wait_and_poll() and megsas_issue_blocked_cmd().

The change proposed in this patch will fix the regression introduced in patch- "90dc9d9 megaraid_sas : MFI MPT linked list corruption fix" inside function megasas_ld_list_query().
Prior to this MFI MPT linked list corruption fix patch, megasas_ld_list_query() function used to check DCMD status(returned by firmware) but with this linked list corruption fix patch, DCMD status will not be checked inside function megasas_ld_list_query() and introduced this issue of wrong data being used by function megasas_ld_list_query().

Quoted 3 lines

This patch fixes an issue spotted on my test system. Thanks for posting.

Tomas

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Sumit