Skip to content

Commit 354cf82

Browse files
djbwJames Bottomley
authored andcommitted
[SCSI] libsas: let libata recover links that fail to transmit initial sig-fis
libsas fails to discover all sata devices in the domain. If a device fails negotiation and does not transmit a signature fis the link needs recovery. libata already understands how to manage slow to come up links, so treat these conditions as ata device attach events for the purposes of creating an ata_port. This allows libata to manage retrying link bring up. Rediscovery is modified to be careful about checking changes in dev_type. It looks like libsas leaks old devices if the sas address changes, but that's a fix for another patch. Acked-by: Jack Wang <jack_wang@usish.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent a692b0e commit 354cf82

6 files changed

Lines changed: 179 additions & 89 deletions

File tree

‎drivers/scsi/libsas/sas_ata.c‎

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,26 +278,84 @@ static struct sas_internal *dev_to_sas_internal(struct domain_device *dev)
278278
return to_sas_internal(dev->port->ha->core.shost->transportt);
279279
}
280280

281+
static void sas_get_ata_command_set(struct domain_device *dev);
282+
283+
int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
284+
{
285+
if (phy->attached_tproto & SAS_PROTOCOL_STP)
286+
dev->tproto = phy->attached_tproto;
287+
if (phy->attached_sata_dev)
288+
dev->tproto |= SATA_DEV;
289+
290+
if (phy->attached_dev_type == SATA_PENDING)
291+
dev->dev_type = SATA_PENDING;
292+
else {
293+
int res;
294+
295+
dev->dev_type = SATA_DEV;
296+
res = sas_get_report_phy_sata(dev->parent, phy->phy_id,
297+
&dev->sata_dev.rps_resp);
298+
if (res) {
299+
SAS_DPRINTK("report phy sata to %016llx:0x%x returned "
300+
"0x%x\n", SAS_ADDR(dev->parent->sas_addr),
301+
phy->phy_id, res);
302+
return res;
303+
}
304+
memcpy(dev->frame_rcvd, &dev->sata_dev.rps_resp.rps.fis,
305+
sizeof(struct dev_to_host_fis));
306+
/* TODO switch to ata_dev_classify() */
307+
sas_get_ata_command_set(dev);
308+
}
309+
return 0;
310+
}
311+
312+
static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy)
313+
{
314+
int res;
315+
316+
/* we weren't pending, so successfully end the reset sequence now */
317+
if (dev->dev_type != SATA_PENDING)
318+
return 1;
319+
320+
/* hmmm, if this succeeds do we need to repost the domain_device to the
321+
* lldd so it can pick up new parameters?
322+
*/
323+
res = sas_get_ata_info(dev, phy);
324+
if (res)
325+
return 0; /* retry */
326+
else
327+
return 1;
328+
}
329+
281330
static int smp_ata_check_ready(struct ata_link *link)
282331
{
283332
int res;
284-
u8 addr[8];
285333
struct ata_port *ap = link->ap;
286334
struct domain_device *dev = ap->private_data;
287335
struct domain_device *ex_dev = dev->parent;
288336
struct sas_phy *phy = sas_get_local_phy(dev);
337+
struct ex_phy *ex_phy = &ex_dev->ex_dev.ex_phy[phy->number];
289338

290-
res = sas_get_phy_attached_sas_addr(ex_dev, phy->number, addr);
339+
res = sas_ex_phy_discover(ex_dev, phy->number);
291340
sas_put_local_phy(phy);
341+
292342
/* break the wait early if the expander is unreachable,
293343
* otherwise keep polling
294344
*/
295345
if (res == -ECOMM)
296346
return res;
297-
if (res != SMP_RESP_FUNC_ACC || SAS_ADDR(addr) == 0)
347+
if (res != SMP_RESP_FUNC_ACC)
298348
return 0;
299-
else
300-
return 1;
349+
350+
switch (ex_phy->attached_dev_type) {
351+
case SATA_PENDING:
352+
return 0;
353+
case SAS_END_DEV:
354+
if (ex_phy->attached_sata_dev)
355+
return sas_ata_clear_pending(dev, ex_phy);
356+
default:
357+
return -ENODEV;
358+
}
301359
}
302360

303361
static int local_ata_check_ready(struct ata_link *link)
@@ -584,6 +642,9 @@ static void sas_get_ata_command_set(struct domain_device *dev)
584642
struct dev_to_host_fis *fis =
585643
(struct dev_to_host_fis *) dev->frame_rcvd;
586644

645+
if (dev->dev_type == SATA_PENDING)
646+
return;
647+
587648
if ((fis->sector_count == 1 && /* ATA */
588649
fis->lbal == 1 &&
589650
fis->lbam == 0 &&

‎drivers/scsi/libsas/sas_discover.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void sas_init_dev(struct domain_device *dev)
4848
case SATA_DEV:
4949
case SATA_PM:
5050
case SATA_PM_PORT:
51+
case SATA_PENDING:
5152
INIT_LIST_HEAD(&dev->sata_dev.children);
5253
break;
5354
default:

0 commit comments

Comments
 (0)