Skip to content

Commit d1acd81

Browse files
Ajish Koshymartinkpetersen
authored andcommitted
scsi: pm80xx: Fix drives missing during rmmod/insmod loop
When driver is loaded after rmmod some drives are not showing up during discovery. SATA drives are directly attached to the controller connected phys. During device discovery, the IDENTIFY command (qc timeout (cmd 0xec)) is timing out during revalidation. This will trigger abort from host side and controller successfully aborts the command and returns success. Post this successful abort response ATA library decides to mark the disk as NODEV. To overcome this, inside pm8001_scan_start() after phy_start() call, add get start response and wait for few milliseconds to trigger next phy start. This millisecond delay will give sufficient time for the controller state machine to accept next phy start. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ajish Koshy <[email protected]> Signed-off-by: Viswas G <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 5cb289b commit d1acd81

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,11 +3765,13 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
37653765
case HW_EVENT_PHY_START_STATUS:
37663766
pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PHY_START_STATUS status = %x\n",
37673767
status);
3768-
if (status == 0) {
3768+
if (status == 0)
37693769
phy->phy_state = 1;
3770-
if (pm8001_ha->flags == PM8001F_RUN_TIME &&
3771-
phy->enable_completion != NULL)
3772-
complete(phy->enable_completion);
3770+
3771+
if (pm8001_ha->flags == PM8001F_RUN_TIME &&
3772+
phy->enable_completion != NULL) {
3773+
complete(phy->enable_completion);
3774+
phy->enable_completion = NULL;
37733775
}
37743776
break;
37753777
case HW_EVENT_SAS_PHY_UP:

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,8 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
11511151
goto err_out_shost;
11521152
}
11531153
list_add_tail(&pm8001_ha->list, &hba_list);
1154-
scsi_scan_host(pm8001_ha->shost);
11551154
pm8001_ha->flags = PM8001F_RUN_TIME;
1155+
scsi_scan_host(pm8001_ha->shost);
11561156
return 0;
11571157

11581158
err_out_shost:

drivers/scsi/pm8001/pm8001_sas.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,17 @@ void pm8001_scan_start(struct Scsi_Host *shost)
264264
int i;
265265
struct pm8001_hba_info *pm8001_ha;
266266
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
267+
DECLARE_COMPLETION_ONSTACK(completion);
267268
pm8001_ha = sha->lldd_ha;
268269
/* SAS_RE_INITIALIZATION not available in SPCv/ve */
269270
if (pm8001_ha->chip_id == chip_8001)
270271
PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
271-
for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
272+
for (i = 0; i < pm8001_ha->chip->n_phy; ++i) {
273+
pm8001_ha->phy[i].enable_completion = &completion;
272274
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
275+
wait_for_completion(&completion);
276+
msleep(300);
277+
}
273278
}
274279

275280
int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time)

drivers/scsi/pm8001/pm80xx_hwi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3487,13 +3487,13 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
34873487
pm8001_dbg(pm8001_ha, INIT,
34883488
"phy start resp status:0x%x, phyid:0x%x\n",
34893489
status, phy_id);
3490-
if (status == 0) {
3490+
if (status == 0)
34913491
phy->phy_state = PHY_LINK_DOWN;
3492-
if (pm8001_ha->flags == PM8001F_RUN_TIME &&
3493-
phy->enable_completion != NULL) {
3494-
complete(phy->enable_completion);
3495-
phy->enable_completion = NULL;
3496-
}
3492+
3493+
if (pm8001_ha->flags == PM8001F_RUN_TIME &&
3494+
phy->enable_completion != NULL) {
3495+
complete(phy->enable_completion);
3496+
phy->enable_completion = NULL;
34973497
}
34983498
return 0;
34993499

0 commit comments

Comments
 (0)