Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libata: move link onlineness check out of softreset methods

Currently, SATA softresets should do link onlineness check before
actually performing SRST protocol but it doesn't really belong to
softreset.

This patch moves onlineness check in softreset to ata_eh_reset() and
ata_eh_followup_srst_needed() to clean up code and help future sata_mv
changes which need clear separation between SCR and TF accesses.

sata_fsl is peculiar in that its softreset really isn't softreset but
combination of hardreset and softreset. This patch adds dummy private
->prereset to keep the current behavior but the driver really should
implement separate hard and soft resets and return -EAGAIN from
hardreset if it should be follwed by softreset.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by

Tejun Heo and committed by
Jeff Garzik
45db2f6c 2a0c15ca

+15 -32
-6
drivers/ata/ahci.c
··· 1273 1273 1274 1274 DPRINTK("ENTER\n"); 1275 1275 1276 - if (ata_link_offline(link)) { 1277 - DPRINTK("PHY reports no device\n"); 1278 - *class = ATA_DEV_NONE; 1279 - return 0; 1280 - } 1281 - 1282 1276 /* prepare for SRST (AHCI-1.1 10.4.1) */ 1283 1277 rc = ahci_kick_engine(ap, 1); 1284 1278 if (rc && rc != -EOPNOTSUPP)
+4
drivers/ata/libata-core.c
··· 3541 3541 "link for reset (errno=%d)\n", rc); 3542 3542 } 3543 3543 3544 + /* no point in trying softreset on offline link */ 3545 + if (ata_link_offline(link)) 3546 + ehc->i.action &= ~ATA_EH_SOFTRESET; 3547 + 3544 3548 return 0; 3545 3549 } 3546 3550
+1 -1
drivers/ata/libata-eh.c
··· 2065 2065 int rc, int classify, 2066 2066 const unsigned int *classes) 2067 2067 { 2068 - if (link->flags & ATA_LFLAG_NO_SRST) 2068 + if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) 2069 2069 return 0; 2070 2070 if (rc == -EAGAIN) { 2071 2071 if (classify)
-6
drivers/ata/libata-sff.c
··· 1889 1889 1890 1890 DPRINTK("ENTER\n"); 1891 1891 1892 - if (ata_link_offline(link)) { 1893 - classes[0] = ATA_DEV_NONE; 1894 - goto out; 1895 - } 1896 - 1897 1892 /* determine if device 0/1 are present */ 1898 1893 if (ata_devchk(ap, 0)) 1899 1894 devmask |= (1 << 0); ··· 1914 1919 classes[1] = ata_sff_dev_classify(&link->device[1], 1915 1920 devmask & (1 << 1), &err); 1916 1921 1917 - out: 1918 1922 DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); 1919 1923 return 0; 1920 1924 }
-6
drivers/ata/pata_bf54x.c
··· 1103 1103 unsigned int devmask = 0, err_mask; 1104 1104 u8 err; 1105 1105 1106 - if (ata_link_offline(link)) { 1107 - classes[0] = ATA_DEV_NONE; 1108 - goto out; 1109 - } 1110 - 1111 1106 /* determine if device 0/1 are present */ 1112 1107 if (bfin_devchk(ap, 0)) 1113 1108 devmask |= (1 << 0); ··· 1127 1132 classes[1] = ata_sff_dev_classify(&ap->link.device[1], 1128 1133 devmask & (1 << 1), &err); 1129 1134 1130 - out: 1131 1135 return 0; 1132 1136 } 1133 1137
-6
drivers/ata/pata_scc.c
··· 615 615 616 616 DPRINTK("ENTER\n"); 617 617 618 - if (ata_link_offline(link)) { 619 - classes[0] = ATA_DEV_NONE; 620 - goto out; 621 - } 622 - 623 618 /* determine if device 0/1 are present */ 624 619 if (scc_devchk(ap, 0)) 625 620 devmask |= (1 << 0); ··· 640 645 classes[1] = ata_sff_dev_classify(&ap->link.device[1], 641 646 devmask & (1 << 1), &err); 642 647 643 - out: 644 648 DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); 645 649 return 0; 646 650 }
+10
drivers/ata/sata_fsl.c
··· 678 678 return ata_dev_classify(&tf); 679 679 } 680 680 681 + static int sata_fsl_prereset(struct ata_linke *link, unsigned long deadline) 682 + { 683 + /* FIXME: Never skip softreset, sata_fsl_softreset() is 684 + * combination of soft and hard resets. sata_fsl_softreset() 685 + * needs to be splitted into soft and hard resets. 686 + */ 687 + return 0; 688 + } 689 + 681 690 static int sata_fsl_softreset(struct ata_link *link, unsigned int *class, 682 691 unsigned long deadline) 683 692 { ··· 1166 1157 1167 1158 .freeze = sata_fsl_freeze, 1168 1159 .thaw = sata_fsl_thaw, 1160 + .prereset = sata_fsl_prereset, 1169 1161 .softreset = sata_fsl_softreset, 1170 1162 .post_internal_cmd = sata_fsl_post_internal_cmd, 1171 1163
-7
drivers/ata/sata_sil24.c
··· 663 663 664 664 DPRINTK("ENTER\n"); 665 665 666 - if (ata_link_offline(link)) { 667 - DPRINTK("PHY reports no device\n"); 668 - *class = ATA_DEV_NONE; 669 - goto out; 670 - } 671 - 672 666 /* put the port into known state */ 673 667 if (sil24_init_port(ap)) { 674 668 reason = "port not ready"; ··· 687 693 sil24_read_tf(ap, 0, &tf); 688 694 *class = ata_dev_classify(&tf); 689 695 690 - out: 691 696 DPRINTK("EXIT, class=%u\n", *class); 692 697 return 0; 693 698