diff mbox series

[1/4] pm80xx : Fix for phy enable/disable functionality.

Message ID 20180905054645.19224-2-Viswas.G@microsemi.com (mailing list archive)
State Superseded
Headers show
Series pm0xx : Updates for driver version 0.1.39. | expand

Commit Message

Viswas G Sept. 5, 2018, 5:46 a.m. UTC
From: Deepak Ukey <deepak.ukey@microchip.com>

Added proper mask for phy id in mpi_phy_stop_resp().

Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
---
 drivers/scsi/pm8001/pm8001_defs.h |  7 +++++++
 drivers/scsi/pm8001/pm8001_hwi.c  |  4 ++--
 drivers/scsi/pm8001/pm8001_init.c |  2 +-
 drivers/scsi/pm8001/pm8001_sas.c  | 16 +++++++++++++---
 drivers/scsi/pm8001/pm80xx_hwi.c  |  7 ++++---
 drivers/scsi/pm8001/pm80xx_hwi.h  |  4 ++++
 6 files changed, 31 insertions(+), 9 deletions(-)

Comments

Jinpu Wang Sept. 5, 2018, 8:18 a.m. UTC | #1
On Wed, Sep 5, 2018 at 7:47 AM Viswas G <Viswas.G@microsemi.com> wrote:
>
> From: Deepak Ukey <deepak.ukey@microchip.com>
>
> Added proper mask for phy id in mpi_phy_stop_resp().
>
> Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
> Signed-off-by: Viswas G <Viswas.G@microchip.com>
> ---
>  drivers/scsi/pm8001/pm8001_defs.h |  7 +++++++
>  drivers/scsi/pm8001/pm8001_hwi.c  |  4 ++--
>  drivers/scsi/pm8001/pm8001_init.c |  2 +-
>  drivers/scsi/pm8001/pm8001_sas.c  | 16 +++++++++++++---
>  drivers/scsi/pm8001/pm80xx_hwi.c  |  7 ++++---
>  drivers/scsi/pm8001/pm80xx_hwi.h  |  4 ++++
>  6 files changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_defs.h b/drivers/scsi/pm8001/pm8001_defs.h
> index 199527d..6b8bc66 100644
> --- a/drivers/scsi/pm8001/pm8001_defs.h
> +++ b/drivers/scsi/pm8001/pm8001_defs.h
> @@ -132,4 +132,11 @@ enum pm8001_hba_info_flags {
>         PM8001F_RUN_TIME        = (1U << 1),
>  };
>
> +/**
> + * Phy Status
> + */
> +#define PHY_LINK_DISABLE       0x00
> +#define PHY_LINK_DOWN          0x01
PHY_LINK_DOWN is not used?
> +#define PHY_LINK_UP            0x02
> +
>  #endif
> diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
> index 4dd6cad..fcfb4f7 100644
> --- a/drivers/scsi/pm8001/pm8001_hwi.c
> +++ b/drivers/scsi/pm8001/pm8001_hwi.c
> @@ -3829,7 +3829,7 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb)
>                         pm8001_printk("HW_EVENT_PHY_STOP_STATUS "
>                         "status = %x\n", status));
>                 if (status == 0)
> -                       phy->phy_state = 0;
> +                       phy->phy_state = PHY_LINK_DISABLE;
>                 break;
>         case HW_EVENT_SATA_SPINUP_HOLD:
>                 PM8001_MSG_DBG(pm8001_ha,
> @@ -3841,7 +3841,7 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb)
>                         pm8001_printk("HW_EVENT_PHY_DOWN\n"));
>                 sas_ha->notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL);
>                 phy->phy_attached = 0;
> -               phy->phy_state = 0;
> +               phy->phy_state = PHY_LINK_DISABLE;
>                 hw_event_phy_down(pm8001_ha, piomb);
>                 break;
>         case HW_EVENT_PORT_INVALID:
> diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
> index 7a697ca..3dca1dc 100644
> --- a/drivers/scsi/pm8001/pm8001_init.c
> +++ b/drivers/scsi/pm8001/pm8001_init.c
> @@ -121,7 +121,7 @@ static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id)
>  {
>         struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
>         struct asd_sas_phy *sas_phy = &phy->sas_phy;
> -       phy->phy_state = 0;
> +       phy->phy_state = PHY_LINK_DISABLE;
>         phy->pm8001_ha = pm8001_ha;
>         sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0;
>         sas_phy->class = SAS;
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index 947d601..96b173f 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -157,9 +157,12 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>         int rc = 0, phy_id = sas_phy->id;
>         struct pm8001_hba_info *pm8001_ha = NULL;
>         struct sas_phy_linkrates *rates;
> +       struct sas_ha_struct *sas_ha;
> +       struct pm8001_phy *phy;
>         DECLARE_COMPLETION_ONSTACK(completion);
>         unsigned long flags;
>         pm8001_ha = sas_phy->ha->lldd_ha;
> +       phy = &pm8001_ha->phy[phy_id];
>         pm8001_ha->phy[phy_id].enable_completion = &completion;
>         switch (func) {
>         case PHY_FUNC_SET_LINK_RATE:
> @@ -172,7 +175,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>                         pm8001_ha->phy[phy_id].maximum_linkrate =
>                                 rates->maximum_linkrate;
>                 }
> -               if (pm8001_ha->phy[phy_id].phy_state == 0) {
> +               if (pm8001_ha->phy[phy_id].phy_state ==  PHY_LINK_DISABLE) {
>                         PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
>                         wait_for_completion(&completion);
>                 }
> @@ -180,7 +183,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>                                               PHY_LINK_RESET);
>                 break;
>         case PHY_FUNC_HARD_RESET:
> -               if (pm8001_ha->phy[phy_id].phy_state == 0) {
> +               if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
>                         PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
>                         wait_for_completion(&completion);
>                 }
> @@ -188,7 +191,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>                                               PHY_HARD_RESET);
>                 break;
>         case PHY_FUNC_LINK_RESET:
> -               if (pm8001_ha->phy[phy_id].phy_state == 0) {
> +               if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
>                         PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
>                         wait_for_completion(&completion);
>                 }
> @@ -200,6 +203,13 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
>                                               PHY_LINK_RESET);
>                 break;
>         case PHY_FUNC_DISABLE:
> +               if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_UP) {
> +                       sas_ha = pm8001_ha->sas;
> +                       sas_phy_disconnected(&phy->sas_phy);
> +                       sas_ha->notify_phy_event(&phy->sas_phy,
> +                               PHYE_LOSS_OF_SIGNAL);
> +                       phy->phy_attached = 0;
> +               }
>                 PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id);
>                 break;
>         case PHY_FUNC_GET_EVENTS:
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
> index 42f0405..17e74a3 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.c
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
> @@ -3384,13 +3384,14 @@ static int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
>         u32 status =
>                 le32_to_cpu(pPayload->status);
>         u32 phyid =
> -               le32_to_cpu(pPayload->phyid);
> +               le32_to_cpu(pPayload->phyid) & 0xFF;
>         struct pm8001_phy *phy = &pm8001_ha->phy[phyid];
>         PM8001_MSG_DBG(pm8001_ha,
>                         pm8001_printk("phy:0x%x status:0x%x\n",
>                                         phyid, status));
> -       if (status == 0)
> -               phy->phy_state = 0;
> +       if (status == PHY_STOP_SUCCESS ||
> +               status == PHY_STOP_ERR_DEVICE_ATTACHED)
> +               phy->phy_state = PHY_LINK_DISABLE;
>         return 0;
>  }
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h
> index 889e69c..49fb769 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.h
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.h
> @@ -170,6 +170,10 @@
>  #define LINKRATE_60                    (0x04 << 8)
>  #define LINKRATE_120                   (0x08 << 8)
>
> +/*phy_stop*/
> +#define PHY_STOP_SUCCESS               0x00
> +#define PHY_STOP_ERR_DEVICE_ATTACHED   0x1046
> +
>  /* phy_profile */
>  #define SAS_PHY_ANALOG_SETTINGS_PAGE   0x04
>  #define PHY_DWORD_LENGTH               0xC
> --
> 1.8.3.1
>

Other wise, looks good to me!
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_defs.h b/drivers/scsi/pm8001/pm8001_defs.h
index 199527d..6b8bc66 100644
--- a/drivers/scsi/pm8001/pm8001_defs.h
+++ b/drivers/scsi/pm8001/pm8001_defs.h
@@ -132,4 +132,11 @@  enum pm8001_hba_info_flags {
 	PM8001F_RUN_TIME	= (1U << 1),
 };
 
+/**
+ * Phy Status
+ */
+#define PHY_LINK_DISABLE	0x00
+#define PHY_LINK_DOWN		0x01
+#define PHY_LINK_UP		0x02
+
 #endif
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 4dd6cad..fcfb4f7 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -3829,7 +3829,7 @@  static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb)
 			pm8001_printk("HW_EVENT_PHY_STOP_STATUS "
 			"status = %x\n", status));
 		if (status == 0)
-			phy->phy_state = 0;
+			phy->phy_state = PHY_LINK_DISABLE;
 		break;
 	case HW_EVENT_SATA_SPINUP_HOLD:
 		PM8001_MSG_DBG(pm8001_ha,
@@ -3841,7 +3841,7 @@  static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb)
 			pm8001_printk("HW_EVENT_PHY_DOWN\n"));
 		sas_ha->notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL);
 		phy->phy_attached = 0;
-		phy->phy_state = 0;
+		phy->phy_state = PHY_LINK_DISABLE;
 		hw_event_phy_down(pm8001_ha, piomb);
 		break;
 	case HW_EVENT_PORT_INVALID:
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 7a697ca..3dca1dc 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -121,7 +121,7 @@  static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id)
 {
 	struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
 	struct asd_sas_phy *sas_phy = &phy->sas_phy;
-	phy->phy_state = 0;
+	phy->phy_state = PHY_LINK_DISABLE;
 	phy->pm8001_ha = pm8001_ha;
 	sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0;
 	sas_phy->class = SAS;
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 947d601..96b173f 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -157,9 +157,12 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 	int rc = 0, phy_id = sas_phy->id;
 	struct pm8001_hba_info *pm8001_ha = NULL;
 	struct sas_phy_linkrates *rates;
+	struct sas_ha_struct *sas_ha;
+	struct pm8001_phy *phy;
 	DECLARE_COMPLETION_ONSTACK(completion);
 	unsigned long flags;
 	pm8001_ha = sas_phy->ha->lldd_ha;
+	phy = &pm8001_ha->phy[phy_id];
 	pm8001_ha->phy[phy_id].enable_completion = &completion;
 	switch (func) {
 	case PHY_FUNC_SET_LINK_RATE:
@@ -172,7 +175,7 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 			pm8001_ha->phy[phy_id].maximum_linkrate =
 				rates->maximum_linkrate;
 		}
-		if (pm8001_ha->phy[phy_id].phy_state == 0) {
+		if (pm8001_ha->phy[phy_id].phy_state ==  PHY_LINK_DISABLE) {
 			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
 			wait_for_completion(&completion);
 		}
@@ -180,7 +183,7 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 					      PHY_LINK_RESET);
 		break;
 	case PHY_FUNC_HARD_RESET:
-		if (pm8001_ha->phy[phy_id].phy_state == 0) {
+		if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
 			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
 			wait_for_completion(&completion);
 		}
@@ -188,7 +191,7 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 					      PHY_HARD_RESET);
 		break;
 	case PHY_FUNC_LINK_RESET:
-		if (pm8001_ha->phy[phy_id].phy_state == 0) {
+		if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
 			PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
 			wait_for_completion(&completion);
 		}
@@ -200,6 +203,13 @@  int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
 					      PHY_LINK_RESET);
 		break;
 	case PHY_FUNC_DISABLE:
+		if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_UP) {
+			sas_ha = pm8001_ha->sas;
+			sas_phy_disconnected(&phy->sas_phy);
+			sas_ha->notify_phy_event(&phy->sas_phy,
+				PHYE_LOSS_OF_SIGNAL);
+			phy->phy_attached = 0;
+		}
 		PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id);
 		break;
 	case PHY_FUNC_GET_EVENTS:
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 42f0405..17e74a3 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -3384,13 +3384,14 @@  static int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	u32 status =
 		le32_to_cpu(pPayload->status);
 	u32 phyid =
-		le32_to_cpu(pPayload->phyid);
+		le32_to_cpu(pPayload->phyid) & 0xFF;
 	struct pm8001_phy *phy = &pm8001_ha->phy[phyid];
 	PM8001_MSG_DBG(pm8001_ha,
 			pm8001_printk("phy:0x%x status:0x%x\n",
 					phyid, status));
-	if (status == 0)
-		phy->phy_state = 0;
+	if (status == PHY_STOP_SUCCESS ||
+		status == PHY_STOP_ERR_DEVICE_ATTACHED)
+		phy->phy_state = PHY_LINK_DISABLE;
 	return 0;
 }
 
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h
index 889e69c..49fb769 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.h
+++ b/drivers/scsi/pm8001/pm80xx_hwi.h
@@ -170,6 +170,10 @@ 
 #define LINKRATE_60			(0x04 << 8)
 #define LINKRATE_120			(0x08 << 8)
 
+/*phy_stop*/
+#define PHY_STOP_SUCCESS		0x00
+#define PHY_STOP_ERR_DEVICE_ATTACHED	0x1046
+
 /* phy_profile */
 #define SAS_PHY_ANALOG_SETTINGS_PAGE	0x04
 #define PHY_DWORD_LENGTH		0xC