[1/2] scsi: pm80xx: Add fatal error check for pm8001_phy_control()

Message ID 20230523214127.4006891-2-pranavpp@google.com
State New
Headers
Series scsi: pm80xx: Fatal error checks |

Commit Message

Pranav Prasad May 23, 2023, 9:41 p.m. UTC
  From: Changyuan Lyu <changyuanl@google.com>

This patch adds a fatal error check for the pm8001_phy_control() function.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Signed-off-by: Pranav Prasad <pranavpp@google.com>
---
 drivers/scsi/pm8001/pm8001_sas.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Jinpu Wang May 24, 2023, 6:34 a.m. UTC | #1
On Tue, May 23, 2023 at 11:41 PM Pranav Prasad <pranavpp@google.com> wrote:
>
> From: Changyuan Lyu <changyuanl@google.com>
>
> This patch adds a fatal error check for the pm8001_phy_control() function.
>
> Signed-off-by: Changyuan Lyu <changyuanl@google.com>
> Signed-off-by: Pranav Prasad <pranavpp@google.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
> ---
>  drivers/scsi/pm8001/pm8001_sas.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index e5673c774f66..b153f0966e5d 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -167,6 +167,16 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>         pm8001_ha = sas_phy->ha->lldd_ha;
>         phy = &pm8001_ha->phy[phy_id];
>         pm8001_ha->phy[phy_id].enable_completion = &completion;
> +
> +       if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) {
> +               /* If the controller is in fatal error state,
> +                *  we will not get a response from the controller
> +                */
> +               pm8001_dbg(pm8001_ha, FAIL,
> +                               "Phy control failed due to fatal errors\n");
> +               return -EFAULT;
> +       }
> +
>         switch (func) {
>         case PHY_FUNC_SET_LINK_RATE:
>                 rates = funcdata;
> --
> 2.40.1.698.g37aff9b760-goog
>
  
Damien Le Moal May 24, 2023, 7:53 a.m. UTC | #2
On 5/24/23 06:41, Pranav Prasad wrote:
> From: Changyuan Lyu <changyuanl@google.com>
> 
> This patch adds a fatal error check for the pm8001_phy_control() function.
> 
> Signed-off-by: Changyuan Lyu <changyuanl@google.com>
> Signed-off-by: Pranav Prasad <pranavpp@google.com>
> ---
>  drivers/scsi/pm8001/pm8001_sas.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index e5673c774f66..b153f0966e5d 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -167,6 +167,16 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>  	pm8001_ha = sas_phy->ha->lldd_ha;
>  	phy = &pm8001_ha->phy[phy_id];
>  	pm8001_ha->phy[phy_id].enable_completion = &completion;
> +
> +	if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) {
> +		/* If the controller is in fatal error state,
> +		 *  we will not get a response from the controller
> +		 */

Multi-line comment style: must start with an empty "/*" line.

> +		pm8001_dbg(pm8001_ha, FAIL,
> +				"Phy control failed due to fatal errors\n");

Please align the args together.

> +		return -EFAULT;
> +	}
> +
>  	switch (func) {
>  	case PHY_FUNC_SET_LINK_RATE:
>  		rates = funcdata;
  

Patch

diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index e5673c774f66..b153f0966e5d 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -167,6 +167,16 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 	pm8001_ha = sas_phy->ha->lldd_ha;
 	phy = &pm8001_ha->phy[phy_id];
 	pm8001_ha->phy[phy_id].enable_completion = &completion;
+
+	if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) {
+		/* If the controller is in fatal error state,
+		 *  we will not get a response from the controller
+		 */
+		pm8001_dbg(pm8001_ha, FAIL,
+				"Phy control failed due to fatal errors\n");
+		return -EFAULT;
+	}
+
 	switch (func) {
 	case PHY_FUNC_SET_LINK_RATE:
 		rates = funcdata;