Skip to content

Commit cd13575

Browse files
Deepak Ukeymartinkpetersen
authored andcommitted
scsi: pm80xx: Fix for phy enable/disable functionality
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> Acked-by: Jack Wang <jinpu.wang@profitbricks.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 0b1b1d8 commit cd13575

7 files changed

Lines changed: 49 additions & 17 deletions

File tree

‎drivers/scsi/pm8001/pm8001_defs.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,12 @@ enum pm8001_hba_info_flags {
132132
PM8001F_RUN_TIME = (1U << 1),
133133
};
134134

135+
/**
136+
* Phy Status
137+
*/
138+
#define PHY_LINK_DISABLE 0x00
139+
#define PHY_LINK_DOWN 0x01
140+
#define PHY_STATE_LINK_UP_SPCV 0x2
141+
#define PHY_STATE_LINK_UP_SPC 0x1
142+
135143
#endif

‎drivers/scsi/pm8001/pm8001_hwi.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3810,7 +3810,8 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb)
38103810
" status = %x\n", status));
38113811
if (status == 0) {
38123812
phy->phy_state = 1;
3813-
if (pm8001_ha->flags == PM8001F_RUN_TIME)
3813+
if (pm8001_ha->flags == PM8001F_RUN_TIME &&
3814+
phy->enable_completion != NULL)
38143815
complete(phy->enable_completion);
38153816
}
38163817
break;

‎drivers/scsi/pm8001/pm8001_hwi.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@
131131
#define LINKRATE_30 (0x02 << 8)
132132
#define LINKRATE_60 (0x04 << 8)
133133

134-
/* for phy state */
135-
136-
#define PHY_STATE_LINK_UP_SPC 0x1
137-
138134
/* for new SPC controllers MEMBASE III is shared between BIOS and DATA */
139135
#define GSM_SM_BASE 0x4F0000
140136
struct mpi_msg_hdr{

‎drivers/scsi/pm8001/pm8001_init.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static void pm8001_phy_init(struct pm8001_hba_info *pm8001_ha, int phy_id)
121121
{
122122
struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
123123
struct asd_sas_phy *sas_phy = &phy->sas_phy;
124-
phy->phy_state = 0;
124+
phy->phy_state = PHY_LINK_DISABLE;
125125
phy->pm8001_ha = pm8001_ha;
126126
sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0;
127127
sas_phy->class = SAS;
@@ -1067,6 +1067,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
10671067
if (rc)
10681068
goto err_out_shost;
10691069
scsi_scan_host(pm8001_ha->shost);
1070+
pm8001_ha->flags = PM8001F_RUN_TIME;
10701071
return 0;
10711072

10721073
err_out_shost:

‎drivers/scsi/pm8001/pm8001_sas.c‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,12 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
157157
int rc = 0, phy_id = sas_phy->id;
158158
struct pm8001_hba_info *pm8001_ha = NULL;
159159
struct sas_phy_linkrates *rates;
160+
struct sas_ha_struct *sas_ha;
161+
struct pm8001_phy *phy;
160162
DECLARE_COMPLETION_ONSTACK(completion);
161163
unsigned long flags;
162164
pm8001_ha = sas_phy->ha->lldd_ha;
165+
phy = &pm8001_ha->phy[phy_id];
163166
pm8001_ha->phy[phy_id].enable_completion = &completion;
164167
switch (func) {
165168
case PHY_FUNC_SET_LINK_RATE:
@@ -172,23 +175,23 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
172175
pm8001_ha->phy[phy_id].maximum_linkrate =
173176
rates->maximum_linkrate;
174177
}
175-
if (pm8001_ha->phy[phy_id].phy_state == 0) {
178+
if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
176179
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
177180
wait_for_completion(&completion);
178181
}
179182
PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
180183
PHY_LINK_RESET);
181184
break;
182185
case PHY_FUNC_HARD_RESET:
183-
if (pm8001_ha->phy[phy_id].phy_state == 0) {
186+
if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
184187
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
185188
wait_for_completion(&completion);
186189
}
187190
PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
188191
PHY_HARD_RESET);
189192
break;
190193
case PHY_FUNC_LINK_RESET:
191-
if (pm8001_ha->phy[phy_id].phy_state == 0) {
194+
if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
192195
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
193196
wait_for_completion(&completion);
194197
}
@@ -200,6 +203,25 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
200203
PHY_LINK_RESET);
201204
break;
202205
case PHY_FUNC_DISABLE:
206+
if (pm8001_ha->chip_id != chip_8001) {
207+
if (pm8001_ha->phy[phy_id].phy_state ==
208+
PHY_STATE_LINK_UP_SPCV) {
209+
sas_ha = pm8001_ha->sas;
210+
sas_phy_disconnected(&phy->sas_phy);
211+
sas_ha->notify_phy_event(&phy->sas_phy,
212+
PHYE_LOSS_OF_SIGNAL);
213+
phy->phy_attached = 0;
214+
}
215+
} else {
216+
if (pm8001_ha->phy[phy_id].phy_state ==
217+
PHY_STATE_LINK_UP_SPC) {
218+
sas_ha = pm8001_ha->sas;
219+
sas_phy_disconnected(&phy->sas_phy);
220+
sas_ha->notify_phy_event(&phy->sas_phy,
221+
PHYE_LOSS_OF_SIGNAL);
222+
phy->phy_attached = 0;
223+
}
224+
}
203225
PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id);
204226
break;
205227
case PHY_FUNC_GET_EVENTS:

‎drivers/scsi/pm8001/pm80xx_hwi.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,8 +3118,9 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
31183118
pm8001_printk("phy start resp status:0x%x, phyid:0x%x\n",
31193119
status, phy_id));
31203120
if (status == 0) {
3121-
phy->phy_state = 1;
3122-
if (pm8001_ha->flags == PM8001F_RUN_TIME)
3121+
phy->phy_state = PHY_LINK_DOWN;
3122+
if (pm8001_ha->flags == PM8001F_RUN_TIME &&
3123+
phy->enable_completion != NULL)
31233124
complete(phy->enable_completion);
31243125
}
31253126
return 0;
@@ -3211,7 +3212,7 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
32113212
return 0;
32123213
}
32133214
phy->phy_attached = 0;
3214-
phy->phy_state = 0;
3215+
phy->phy_state = PHY_LINK_DISABLE;
32153216
break;
32163217
case HW_EVENT_PORT_INVALID:
32173218
PM8001_MSG_DBG(pm8001_ha,
@@ -3384,13 +3385,14 @@ static int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
33843385
u32 status =
33853386
le32_to_cpu(pPayload->status);
33863387
u32 phyid =
3387-
le32_to_cpu(pPayload->phyid);
3388+
le32_to_cpu(pPayload->phyid) & 0xFF;
33883389
struct pm8001_phy *phy = &pm8001_ha->phy[phyid];
33893390
PM8001_MSG_DBG(pm8001_ha,
33903391
pm8001_printk("phy:0x%x status:0x%x\n",
33913392
phyid, status));
3392-
if (status == 0)
3393-
phy->phy_state = 0;
3393+
if (status == PHY_STOP_SUCCESS ||
3394+
status == PHY_STOP_ERR_DEVICE_ATTACHED)
3395+
phy->phy_state = PHY_LINK_DISABLE;
33943396
return 0;
33953397
}
33963398

‎drivers/scsi/pm8001/pm80xx_hwi.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@
170170
#define LINKRATE_60 (0x04 << 8)
171171
#define LINKRATE_120 (0x08 << 8)
172172

173+
/*phy_stop*/
174+
#define PHY_STOP_SUCCESS 0x00
175+
#define PHY_STOP_ERR_DEVICE_ATTACHED 0x1046
176+
173177
/* phy_profile */
174178
#define SAS_PHY_ANALOG_SETTINGS_PAGE 0x04
175179
#define PHY_DWORD_LENGTH 0xC
@@ -216,8 +220,6 @@
216220
#define SAS_DOPNRJT_RTRY_TMO 128
217221
#define SAS_COPNRJT_RTRY_TMO 128
218222

219-
/* for phy state */
220-
#define PHY_STATE_LINK_UP_SPCV 0x2
221223
/*
222224
Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
223225
Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128

0 commit comments

Comments
 (0)