@@ -5481,7 +5481,7 @@ mpt3sas_atto_validate_nvram(struct MPT3SAS_ADAPTER *ioc,
5481
5481
* mpt3sas_atto_get_sas_addr - get the ATTO SAS address from mfg page 1
5482
5482
*
5483
5483
* @ioc : per adapter object
5484
- * @* sas_addr : return sas address
5484
+ * @sas_addr : return sas address
5485
5485
* Return: 0 for success, non-zero for failure.
5486
5486
*/
5487
5487
static int
@@ -7914,26 +7914,22 @@ mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc, u32 *event_type)
7914
7914
}
7915
7915
7916
7916
/**
7917
- * _base_diag_reset - the "big hammer" start of day reset
7918
- * @ioc: per adapter object
7919
- *
7920
- * Return: 0 for success, non-zero for failure.
7921
- */
7922
- static int
7923
- _base_diag_reset (struct MPT3SAS_ADAPTER * ioc )
7924
- {
7925
- u32 host_diagnostic ;
7926
- u32 ioc_state ;
7927
- u32 count ;
7928
- u32 hcb_size ;
7929
-
7930
- ioc_info (ioc , "sending diag reset !!\n" );
7931
-
7932
- pci_cfg_access_lock (ioc -> pdev );
7917
+ * mpt3sas_base_unlock_and_get_host_diagnostic- enable Host Diagnostic Register writes
7918
+ * @ioc: per adapter object
7919
+ * @host_diagnostic: host diagnostic register content
7920
+ *
7921
+ * Return: 0 for success, non-zero for failure.
7922
+ */
7933
7923
7934
- drsprintk (ioc , ioc_info (ioc , "clear interrupts\n" ));
7924
+ int
7925
+ mpt3sas_base_unlock_and_get_host_diagnostic (struct MPT3SAS_ADAPTER * ioc ,
7926
+ u32 * host_diagnostic )
7927
+ {
7935
7928
7929
+ u32 count ;
7930
+ * host_diagnostic = 0 ;
7936
7931
count = 0 ;
7932
+
7937
7933
do {
7938
7934
/* Write magic sequence to WriteSequence register
7939
7935
* Loop until in diagnostic mode
@@ -7952,30 +7948,67 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
7952
7948
7953
7949
if (count ++ > 20 ) {
7954
7950
ioc_info (ioc ,
7955
- "Stop writing magic sequence after 20 retries\n" );
7951
+ "Stop writing magic sequence after 20 retries\n" );
7956
7952
_base_dump_reg_set (ioc );
7957
- goto out ;
7953
+ return - EFAULT ;
7958
7954
}
7959
7955
7960
- host_diagnostic = ioc -> base_readl_ext_retry (& ioc -> chip -> HostDiagnostic );
7956
+ * host_diagnostic = ioc -> base_readl_ext_retry (& ioc -> chip -> HostDiagnostic );
7961
7957
drsprintk (ioc ,
7962
- ioc_info (ioc , "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n" ,
7963
- count , host_diagnostic ));
7958
+ ioc_info (ioc , "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n" ,
7959
+ count , * host_diagnostic ));
7964
7960
7965
- } while ((host_diagnostic & MPI2_DIAG_DIAG_WRITE_ENABLE ) == 0 );
7961
+ } while ((* host_diagnostic & MPI2_DIAG_DIAG_WRITE_ENABLE ) == 0 );
7962
+ return 0 ;
7963
+ }
7966
7964
7967
- hcb_size = ioc -> base_readl (& ioc -> chip -> HCBSize );
7965
+ /**
7966
+ * mpt3sas_base_lock_host_diagnostic: Disable Host Diagnostic Register writes
7967
+ * @ioc: per adapter object
7968
+ */
7968
7969
7970
+ void
7971
+ mpt3sas_base_lock_host_diagnostic (struct MPT3SAS_ADAPTER * ioc )
7972
+ {
7973
+ drsprintk (ioc , ioc_info (ioc , "disable writes to the diagnostic register\n" ));
7974
+ writel (MPI2_WRSEQ_FLUSH_KEY_VALUE , & ioc -> chip -> WriteSequence );
7975
+ }
7976
+
7977
+ /**
7978
+ * _base_diag_reset - the "big hammer" start of day reset
7979
+ * @ioc: per adapter object
7980
+ *
7981
+ * Return: 0 for success, non-zero for failure.
7982
+ */
7983
+ static int
7984
+ _base_diag_reset (struct MPT3SAS_ADAPTER * ioc )
7985
+ {
7986
+ u32 host_diagnostic ;
7987
+ u32 ioc_state ;
7988
+ u32 count ;
7989
+ u32 hcb_size ;
7990
+
7991
+ ioc_info (ioc , "sending diag reset !!\n" );
7992
+
7993
+ pci_cfg_access_lock (ioc -> pdev );
7994
+
7995
+ drsprintk (ioc , ioc_info (ioc , "clear interrupts\n" ));
7996
+
7997
+ mutex_lock (& ioc -> hostdiag_unlock_mutex );
7998
+ if (mpt3sas_base_unlock_and_get_host_diagnostic (ioc , & host_diagnostic ))
7999
+ goto out ;
8000
+
8001
+ hcb_size = ioc -> base_readl (& ioc -> chip -> HCBSize );
7969
8002
drsprintk (ioc , ioc_info (ioc , "diag reset: issued\n" ));
7970
8003
writel (host_diagnostic | MPI2_DIAG_RESET_ADAPTER ,
7971
8004
& ioc -> chip -> HostDiagnostic );
7972
8005
7973
- /*This delay allows the chip PCIe hardware time to finish reset tasks*/
8006
+ /* This delay allows the chip PCIe hardware time to finish reset tasks */
7974
8007
msleep (MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC /1000 );
7975
8008
7976
8009
/* Approximately 300 second max wait */
7977
8010
for (count = 0 ; count < (300000000 /
7978
- MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC ); count ++ ) {
8011
+ MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC ); count ++ ) {
7979
8012
7980
8013
host_diagnostic = ioc -> base_readl_ext_retry (& ioc -> chip -> HostDiagnostic );
7981
8014
@@ -7988,13 +8021,15 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
7988
8021
if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER ))
7989
8022
break ;
7990
8023
7991
- msleep (MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC / 1000 );
8024
+ /* Wait to pass the second read delay window */
8025
+ msleep (MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC /1000 );
7992
8026
}
7993
8027
7994
8028
if (host_diagnostic & MPI2_DIAG_HCB_MODE ) {
7995
8029
7996
8030
drsprintk (ioc ,
7997
- ioc_info (ioc , "restart the adapter assuming the HCB Address points to good F/W\n" ));
8031
+ ioc_info (ioc , "restart the adapter assuming the\n"
8032
+ "HCB Address points to good F/W\n" ));
7998
8033
host_diagnostic &= ~MPI2_DIAG_BOOT_DEVICE_SELECT_MASK ;
7999
8034
host_diagnostic |= MPI2_DIAG_BOOT_DEVICE_SELECT_HCDW ;
8000
8035
writel (host_diagnostic , & ioc -> chip -> HostDiagnostic );
@@ -8008,9 +8043,8 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
8008
8043
writel (host_diagnostic & ~MPI2_DIAG_HOLD_IOC_RESET ,
8009
8044
& ioc -> chip -> HostDiagnostic );
8010
8045
8011
- drsprintk (ioc ,
8012
- ioc_info (ioc , "disable writes to the diagnostic register\n" ));
8013
- writel (MPI2_WRSEQ_FLUSH_KEY_VALUE , & ioc -> chip -> WriteSequence );
8046
+ mpt3sas_base_lock_host_diagnostic (ioc );
8047
+ mutex_unlock (& ioc -> hostdiag_unlock_mutex );
8014
8048
8015
8049
drsprintk (ioc , ioc_info (ioc , "Wait for FW to go to the READY state\n" ));
8016
8050
ioc_state = _base_wait_on_iocstate (ioc , MPI2_IOC_STATE_READY , 20 );
@@ -8028,6 +8062,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
8028
8062
out :
8029
8063
pci_cfg_access_unlock (ioc -> pdev );
8030
8064
ioc_err (ioc , "diag reset: FAILED\n" );
8065
+ mutex_unlock (& ioc -> hostdiag_unlock_mutex );
8031
8066
return - EFAULT ;
8032
8067
}
8033
8068
0 commit comments