scsi: pm8001: Fix FW crash for maxcpus=1
Subsystems (2)
PATCH 1/1 scsi: pm8001: Fix FW crash for maxcpus=1
According to the comment in check_fw_ready() we should not check the IOP1_READY field in register SCRATCH_PAD_1 for 8008 or 8009 controllers.
However we check this very field in process_oq() for processing the highest index interrupt vector. Change that function to not check IOP1_READY for those mentioned controllers, but do check ILA_READY in both cases.
The reason I assume that this was not hit earlier was because we always allocated 64 MSI(X), and just did not pass the vector index check in process_oq(), i.e. the handler never ran for vector index 63.
drivers/scsi/pm8001/pm80xx_hwi.c +9 -2
@@ -4162,9 +4162,16 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec)u32 regval;if (vec == (pm8001_ha->max_q_num -1 )) { +u32 mipsall_ready; + +if ((pm8001_ha->chip_id == chip_8008) || + (pm8001_ha->chip_id == chip_8009)) + mipsall_ready =SCRATCH_PAD_MIPSALL_READY_8PORT ; +else + mipsall_ready =SCRATCH_PAD_MIPSALL_READY_16PORT ; + regval =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); -if ((regval &SCRATCH_PAD_MIPSALL_READY ) != -SCRATCH_PAD_MIPSALL_READY ) { +if ((regval & mipsall_ready) != mipsall_ready) { pm8001_ha->controller_fatal_error = true; pm8001_dbg(pm8001_ha, FAIL, "Firmware Fatal error! Regval:0x%x\n",
drivers/scsi/pm8001/pm80xx_hwi.h +5 -1
@@ -1405,8 +1405,12 @@ typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t;#define SCRATCH_PAD_BOOT_LOAD_SUCCESS 0x0#define SCRATCH_PAD_IOP0_READY 0xC00#define SCRATCH_PAD_IOP1_READY 0x3000 -#define SCRATCH_PAD_MIPSALL_READY (SCRATCH_PAD_IOP1_READY | \ +#define SCRATCH_PAD_MIPSALL_READY_16PORT (SCRATCH_PAD_IOP1_READY | \ SCRATCH_PAD_IOP0_READY | \ + SCRATCH_PAD_ILA_READY | \ + SCRATCH_PAD_RAAE_READY) +#define SCRATCH_PAD_MIPSALL_READY_8PORT (SCRATCH_PAD_IOP0_READY | \ + SCRATCH_PAD_ILA_READY | \ SCRATCH_PAD_RAAE_READY)/* boot loader state */
Signature · 1 line
2.26.2
Quoted 18 lines · John Garry
According to the comment in
check_fw_ready()we should not check theIOP1_READYfield in registerSCRATCH_PAD_1for 8008 or 8009 controllers.However we check this very field in
process_oq()for processing the highest index interrupt vector. Change that function to not checkIOP1_READYfor those mentioned controllers, but do checkILA_READYin both cases.The reason I assume that this was not hit earlier was because we always allocated 64 MSI(X), and just did not pass the vector index check in
process_oq(), i.e. the handler never ran for vector index 63.Signed-off-by John Garry <[email protected]>drivers/scsi/pm8001/pm80xx_hwi.c +0
-0
drivers/scsi/pm8001/pm80xx_hwi.c static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) · line 4168
Quoted 7 lines
drivers/scsi/pm8001/pm80xx_hwi.c +4
-0@@ -4162,9 +4162,16 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec)u32 regval;if (vec == (pm8001_ha->max_q_num -1 )) { +u32 mipsall_ready; + +if ((pm8001_ha->chip_id == chip_8008) || + (pm8001_ha->chip_id == chip_8009))
nit: no need for the inner brackets here.
Quoted 19 lines
drivers/scsi/pm8001/pm80xx_hwi.c +5
-2+ mipsall_ready =SCRATCH_PAD_MIPSALL_READY_8PORT ; + else + mipsall_ready =SCRATCH_PAD_MIPSALL_READY_16PORT ; + regval =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); -if ((regval &SCRATCH_PAD_MIPSALL_READY ) != -SCRATCH_PAD_MIPSALL_READY ) { +if ((regval & mipsall_ready) != mipsall_ready) { pm8001_ha->controller_fatal_error = true; pm8001_dbg(pm8001_ha, FAIL, "Firmware Fatal error! Regval:0x%x\n",drivers/scsi/pm8001/pm80xx_hwi.h +0
-0@@ -1405,8 +1405,12 @@ typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t;#define SCRATCH_PAD_BOOT_LOAD_SUCCESS 0x0#define SCRATCH_PAD_IOP0_READY 0xC00#define SCRATCH_PAD_IOP1_READY 0x3000
drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t; · line 1416
Quoted 10 lines
drivers/scsi/pm8001/pm80xx_hwi.h +5
-1-#define SCRATCH_PAD_MIPSALL_READY (SCRATCH_PAD_IOP1_READY | \ +#define SCRATCH_PAD_MIPSALL_READY_16PORT (SCRATCH_PAD_IOP1_READY | \ SCRATCH_PAD_IOP0_READY | \ + SCRATCH_PAD_ILA_READY | \ + SCRATCH_PAD_RAAE_READY) +#define SCRATCH_PAD_MIPSALL_READY_8PORT (SCRATCH_PAD_IOP0_READY | \ + SCRATCH_PAD_ILA_READY | \ SCRATCH_PAD_RAAE_READY)/* boot loader state */
Otherwise, looks OK to me.
I tested with and without max_cpus=1 with a ATTO Technology, Inc. ExpressSAS 12Gb/s SAS/SATA HBA (rev 06) adapter and everything is OK. That adapter uses chip_8072 though, not 8008 or 8009.
Feel free to add:
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 21 lines · Damien Le Moal
Quoted 20 lines · John Garry
According to the comment in
check_fw_ready()we should not check theIOP1_READYfield in registerSCRATCH_PAD_1for 8008 or 8009 controllers.However we check this very field in
process_oq()for processing the highest index interrupt vector. Change that function to not checkIOP1_READYfor those mentioned controllers, but do checkILA_READYin both cases.The reason I assume that this was not hit earlier was because we always allocated 64 MSI(X), and just did not pass the vector index check in
process_oq(), i.e. the handler never ran for vector index 63.Signed-off-by John Garry<[email protected]>drivers/scsi/pm8001/pm80xx_hwi.c +0
-0@@ -4162,9 +4162,16 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec)u32 regval;
Quoted 6 lines
drivers/scsi/pm8001/pm80xx_hwi.c static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) · line 4168
Quoted 5 lines
drivers/scsi/pm8001/pm80xx_hwi.c +4
-0if (vec == (pm8001_ha->max_q_num -1 )) { +u32 mipsall_ready; + +if ((pm8001_ha->chip_id == chip_8008) || + (pm8001_ha->chip_id == chip_8009))nit: no need for the inner brackets here.
ok, I can fix that.
But I would also like opinion from microchip guys/maintainer on why this code is here at all. Seems strange in the way we check in this register in the interrupt handler for only a specific vector and, also, why we check at all in an interrupt handler.
Quoted 35 lines
Quoted 20 lines
drivers/scsi/pm8001/pm80xx_hwi.c +5
-2+ mipsall_ready =SCRATCH_PAD_MIPSALL_READY_8PORT ; + else + mipsall_ready =SCRATCH_PAD_MIPSALL_READY_16PORT ; + regval =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); -if ((regval &SCRATCH_PAD_MIPSALL_READY ) != -SCRATCH_PAD_MIPSALL_READY ) { +if ((regval & mipsall_ready) != mipsall_ready) { pm8001_ha->controller_fatal_error = true; pm8001_dbg(pm8001_ha, FAIL, "Firmware Fatal error! Regval:0x%x\n",drivers/scsi/pm8001/pm80xx_hwi.h +0
-0@@ -1405,8 +1405,12 @@ typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t;#define SCRATCH_PAD_BOOT_LOAD_SUCCESS 0x0#define SCRATCH_PAD_IOP0_READY 0xC00#define SCRATCH_PAD_IOP1_READY 0x3000drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t; · line 1416
Quoted 10 lines
drivers/scsi/pm8001/pm80xx_hwi.h +5
-1-#define SCRATCH_PAD_MIPSALL_READY (SCRATCH_PAD_IOP1_READY | \ +#define SCRATCH_PAD_MIPSALL_READY_16PORT (SCRATCH_PAD_IOP1_READY | \ SCRATCH_PAD_IOP0_READY | \ + SCRATCH_PAD_ILA_READY | \ + SCRATCH_PAD_RAAE_READY) +#define SCRATCH_PAD_MIPSALL_READY_8PORT (SCRATCH_PAD_IOP0_READY | \ + SCRATCH_PAD_ILA_READY | \ SCRATCH_PAD_RAAE_READY)/* boot loader state */ Otherwise, looks OK to me.
I tested with and without max_cpus=1 with a ATTO Technology, Inc. ExpressSAS 12Gb/s SAS/SATA HBA (rev 06) adapter and everything is OK. That adapter useschip_8072though, not 8008 or 8009.
Quoted 4 lines
Feel free to add:
Reviewed-by Damien Le Moal<[email protected]>Tested-by Damien Le Moal<[email protected]>
Thanks!
john
Quoted 31 lines · Damien Le Moal
Quoted 3 lines · John Garry
Quoted 2 lines
According to the comment in
check_fw_ready()we should not check theIOP1_READYfield in registerSCRATCH_PAD_1for 8008 or 8009controllers.
Quoted 4 lines
Quoted 4 lines
However we check this very field in
process_oq()for processing the highest index interrupt vector. Change that function to not checkIOP1_READYfor those mentioned controllers, but do checkILA_READYinboth cases.
Quoted 5 lines
Quoted 5 lines
The reason I assume that this was not hit earlier was because we always allocated 64 MSI(X), and just did not pass the vector index check in
process_oq(), i.e. the handler never ran for vector index 63.Quoted 8 lines
drivers/scsi/pm8001/pm80xx_hwi.c static int process_oq(struct pm8001_hba_info
Quoted 8 lines
Signed-off-by John Garry<[email protected]>drivers/scsi/pm8001/pm80xx_hwi.c +0
-0@@ -4162,9 +4162,16 @@ static int process_oq(struct pm8001_hba_info
*pm8001_ha, u8 vec)Quoted 7 lines
Quoted 7 lines
drivers/scsi/pm8001/pm80xx_hwi.c +4
-0u32 regval;if (vec == (pm8001_ha->max_q_num -1 )) { +u32 mipsall_ready; + +if ((pm8001_ha->chip_id == chip_8008) || + (pm8001_ha->chip_id == chip_8009))
Quoted 8 lines
Quoted 1 line
nit: no need for the inner brackets here.
ok, I can fix that.
But I would also like opinion from microchip guys/maintainer on why this code is here at all. Seems strange in the way we check in this register in the interrupt handler for only a specific vector and, also, why we check at all in an interrupt handler.
Here is my initial understanding so far based on the code and data sheet
1. Controller has the capability to communicate to the host about fatal error condition via configured interrupt vector MSI/MSI-X.
2. This capability is achieved by setting two fields a. Enable Controller Fatal error notification
Dowrd 0x1C, Bit[0].
1 - Enable; 0 - Disable
Code: pm8001_ha->main_cfg_tbl.pm80xx_tbl.
fatal_err_interrupt = 0x01; b. Fatal Error Interrupt Vector Dword 0x1C, bit[15:8]
This parameter configures which interrupt vector is used to notify the host of the fatal error.
Code: /* Update Fatal error interrupt vector */ pm8001_ha->main_cfg_tbl.pm80xx_tbl. fatal_err_interrupt |= ((pm8001_ha->max_q_num - 1) << 8);
Probably this will be the reason why we check
the vector in process_oq() for processing
controller fatal error
if (vec == (pm8001_ha->max_q_num - 1)) {
Please do let me know if it helped in clarification.
Quoted 41 lines
Quoted 11 lines
Quoted 11 lines
drivers/scsi/pm8001/pm80xx_hwi.c +6
-2+ mipsall_ready =SCRATCH_PAD_MIPSALL_READY_8PORT ; + else + mipsall_ready = +SCRATCH_PAD_MIPSALL_READY_16PORT ; + regval =pm8001_cr32 (pm8001_ha,0 ,MSGU_SCRATCH_PAD_1 ); -if ((regval &SCRATCH_PAD_MIPSALL_READY ) != -SCRATCH_PAD_MIPSALL_READY ) { +if ((regval & mipsall_ready) != mipsall_ready) { pm8001_ha->controller_fatal_error = true;Quoted 8 lines
drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig
Quoted 8 lines
drivers/scsi/pm8001/pm80xx_hwi.c +0
-0pm8001_dbg(pm8001_ha, FAIL, "Firmware Fatal error!Regval:0x%x\n", diff --git
a/drivers/scsi/pm8001/pm80xx_hwi.hb/drivers/scsi/pm8001/pm80xx_hwi.h
indexc7e5d93bea92..c41ed039c92a100644drivers/scsi/pm8001/pm80xx_hwi.h +0
-0@@ -1405,8 +1405,12 @@ typedef struct SASProtocolTimerConfig
SASProtocolTimerConfig_t;Quoted 4 lines
drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t;
Quoted 4 lines
drivers/scsi/pm8001/pm80xx_hwi.h +0
-1#define SCRATCH_PAD_BOOT_LOAD_SUCCESS 0x0#define SCRATCH_PAD_IOP0_READY 0xC00#define SCRATCH_PAD_IOP1_READY 0x3000 -#define SCRATCH_PAD_MIPSALL_READY (SCRATCH_PAD_IOP1_READY |\
Quoted 1 line
drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig · line 1408
Quoted 1 line
drivers/scsi/pm8001/pm80xx_hwi.h +1
-0+#define SCRATCH_PAD_MIPSALL_READY_16PORT (
SCRATCH_PAD_IOP1_READY| \Quoted 4 lines
drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t;
Quoted 4 lines
drivers/scsi/pm8001/pm80xx_hwi.h +3
-0SCRATCH_PAD_IOP0_READY | \ +SCRATCH_PAD_ILA_READY | \ + SCRATCH_PAD_RAAE_READY) +#define SCRATCH_PAD_MIPSALL_READY_8PORT(
SCRATCH_PAD_IOP0_READY| \Quoted 9 lines
drivers/scsi/pm8001/pm80xx_hwi.h typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t; · line 1416
Quoted 4 lines
drivers/scsi/pm8001/pm80xx_hwi.h +1
-0+SCRATCH_PAD_ILA_READY | \ SCRATCH_PAD_RAAE_READY)/* boot loader state */ Otherwise, looks OK to me.
I tested with and without max_cpus=1 with a ATTO Technology, Inc. ExpressSAS 12Gb/s SAS/SATA HBA (rev 06) adapter and everything is OK. That adapter useschip_8072though, not 8008 or 8009.
Quoted 8 lines
Quoted 4 lines
Feel free to add:
Reviewed-by Damien Le Moal<[email protected]>Tested-by Damien Le Moal<[email protected]>Thanks!
john
Thanks,
Ajish
Quoted 22 lines · On 06/01/2022 13:03, [email protected] wrote:
Quoted 2 lines
only a specific vector and, also, why we check at all in
an interrupt handler.Here is my initial understanding so far based on the code and data sheet
1. Controller has the capability to communicate to the host about fatal error condition via configured interrupt vector MSI/MSI-X.
2. This capability is achieved by setting two fields a. Enable Controller Fatal error notificationDowrd 0x1C, Bit[0]. 1 - Enable; 0 - Disable Code: pm8001_ha->main_cfg_tbl.pm80xx_tbl. fatal_err_interrupt = 0x01;b. Fatal Error Interrupt Vector Dword
0x1C, bit[15:8]
This parameter configures which interrupt vector is used to notify the host of the fatal error.
Code: /* Update Fatal error interrupt vector */pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt|= ((pm8001_ha->max_q_num- 1) << 8);
Quoted 8 lines
Probably this will be the reason why we check
the vector inprocess_oq()for processing
controller fatal errorif (vec == (
pm8001_ha->max_q_num- 1)) {Please do let me know if it helped in clarification.
Sounds reasonable. And we only discover the issue for 8008/8009 now as we have that (pm8001_ha->max_q_num - 1) vector being used for standard IO.
So let me know of any other issue, otherwise I'll send a v2 with the coding style fixup.
Thanks,
John
Quoted 29 lines · John Garry
Quoted 28 lines · On 06/01/2022 13:03, [email protected] wrote:
Quoted 2 lines
only a specific vector and, also, why we check at all in
an interrupt handler.Here is my initial understanding so far based on the code and data sheet
1. Controller has the capability to communicate to the host about fatal error condition via configured interrupt vector MSI/MSI-X.
2. This capability is achieved by setting two fields a. Enable Controller Fatal error notificationDowrd 0x1C, Bit[0]. 1 - Enable; 0 - Disable Code: pm8001_ha->main_cfg_tbl.pm80xx_tbl. fatal_err_interrupt = 0x01;b. Fatal Error Interrupt Vector Dword
0x1C, bit[15:8]
This parameter configures which interrupt vector is used to notify the host of the fatal error.
Code: /* Update Fatal error interrupt vector */pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt|= ((pm8001_ha->max_q_num- 1) << 8);Probably this will be the reason why we check
the vector inprocess_oq()for processing
controller fatal errorif (vec == (
pm8001_ha->max_q_num- 1)) {
Quoted 8 lines
Quoted 2 lines
Please do let me know if it helped in clarification.
Sounds reasonable. And we only discover the issue for 8008/8009 now as we have that (
pm8001_ha->max_q_num- 1) vector being used for standard IO.So let me know of any other issue, otherwise I'll send a v2 with the coding style fixup.
And maybe add comments about the above so that the information does not get lost ?
Quoted 3 lines
Thanks,
John
Signature · 2 lines
Damien Le Moal Western Digital Research
Hi John,
Quoted 27 lines · On 06/01/2022 13:03, [email protected] wrote:
Quoted 26 lines
Quoted 2 lines
only a specific vector and, also, why we check at all in an
interrupt handler.Here is my initial understanding so far based on the code and data sheet
1. Controller has the capability to communicate to the host about fatal error condition via configured interrupt vector MSI/MSI-X.
2. This capability is achieved by setting two fields
a. Enable Controller Fatal error notificationDowrd 0x1C, Bit[0]. 1 - Enable; 0 - Disable Code: pm8001_ha->main_cfg_tbl.pm80xx_tbl. fatal_err_interrupt = 0x01;b. Fatal Error Interrupt Vector Dword
0x1C, bit[15:8]
This parameter configures which interrupt vector is used to notify the host of the fatal error.
Code: /* Update Fatal error interrupt vector */pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt|= ((pm8001_ha->max_q_num- 1) << 8);Probably this will be the reason why we check the vector in
process_oq()for processing controller fatal errorif (vec == (
pm8001_ha->max_q_num- 1)) {
Quoted 8 lines
Quoted 2 lines
Please do let me know if it helped in clarification.
Sounds reasonable. And we only discover the issue for 8008/8009 now as we have that (
pm8001_ha->max_q_num- 1) vector being used for standard IO.So let me know of any other issue, otherwise I'll send a v2 with the coding style fixup.
After going through check_fw_ready(), the change here looks fine.
Quoted 3 lines
Thanks,
John