diff options
author | Len Brown <len.brown@intel.com> | 2008-10-22 23:57:26 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-10-23 00:11:07 -0400 |
commit | 057316cc6a5b521b332a1d7ccc871cd60c904c74 (patch) | |
tree | 4333e608da237c73ff69b10878025cca96dcb4c8 /drivers/ata | |
parent | 3e2dab9a1c2deb03c311eb3f83466009147ed4d3 (diff) | |
parent | 2515ddc6db8eb49a79f0fe5e67ff09ac7c81eab4 (diff) |
Merge branch 'linus' into test
Conflicts:
MAINTAINERS
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/acpi/sleep.c
drivers/acpi/Kconfig
drivers/pnp/Makefile
drivers/pnp/quirks.c
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/Kconfig | 3 | ||||
-rw-r--r-- | drivers/ata/ahci.c | 25 | ||||
-rw-r--r-- | drivers/ata/ata_piix.c | 184 | ||||
-rw-r--r-- | drivers/ata/libata-core.c | 252 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 375 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 114 | ||||
-rw-r--r-- | drivers/ata/libata.h | 5 | ||||
-rw-r--r-- | drivers/ata/pata_bf54x.c | 34 | ||||
-rw-r--r-- | drivers/ata/pata_of_platform.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_pcmcia.c | 168 | ||||
-rw-r--r-- | drivers/ata/pata_sil680.c | 2 | ||||
-rw-r--r-- | drivers/ata/sata_fsl.c | 26 | ||||
-rw-r--r-- | drivers/ata/sata_inic162x.c | 8 | ||||
-rw-r--r-- | drivers/ata/sata_mv.c | 28 | ||||
-rw-r--r-- | drivers/ata/sata_nv.c | 16 | ||||
-rw-r--r-- | drivers/ata/sata_promise.c | 16 | ||||
-rw-r--r-- | drivers/ata/sata_qstor.c | 12 | ||||
-rw-r--r-- | drivers/ata/sata_sil.c | 16 | ||||
-rw-r--r-- | drivers/ata/sata_sil24.c | 12 | ||||
-rw-r--r-- | drivers/ata/sata_sis.c | 28 | ||||
-rw-r--r-- | drivers/ata/sata_svw.c | 10 | ||||
-rw-r--r-- | drivers/ata/sata_uli.c | 24 | ||||
-rw-r--r-- | drivers/ata/sata_via.c | 24 | ||||
-rw-r--r-- | drivers/ata/sata_vsc.c | 10 |
24 files changed, 968 insertions, 426 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 11c8c19f0fb7..78fbec8ceda0 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -7,7 +7,6 @@ menuconfig ATA | |||
7 | depends on HAS_IOMEM | 7 | depends on HAS_IOMEM |
8 | depends on BLOCK | 8 | depends on BLOCK |
9 | depends on !(M32R || M68K) || BROKEN | 9 | depends on !(M32R || M68K) || BROKEN |
10 | depends on !SUN4 || BROKEN | ||
11 | select SCSI | 10 | select SCSI |
12 | ---help--- | 11 | ---help--- |
13 | If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or | 12 | If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or |
@@ -663,7 +662,7 @@ config HAVE_PATA_PLATFORM | |||
663 | 662 | ||
664 | config PATA_PLATFORM | 663 | config PATA_PLATFORM |
665 | tristate "Generic platform device PATA support" | 664 | tristate "Generic platform device PATA support" |
666 | depends on EMBEDDED || ARCH_RPC || PPC || HAVE_PATA_PLATFORM | 665 | depends on EMBEDDED || PPC || HAVE_PATA_PLATFORM |
667 | help | 666 | help |
668 | This option enables support for generic directly connected ATA | 667 | This option enables support for generic directly connected ATA |
669 | devices commonly found on embedded systems. | 668 | devices commonly found on embedded systems. |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 2e1a7cb2ed5f..aeadd00411a1 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -267,8 +267,8 @@ struct ahci_port_priv { | |||
267 | * per PM slot */ | 267 | * per PM slot */ |
268 | }; | 268 | }; |
269 | 269 | ||
270 | static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 270 | static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
271 | static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 271 | static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
272 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 272 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
273 | static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); | 273 | static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); |
274 | static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); | 274 | static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); |
@@ -316,6 +316,7 @@ static struct device_attribute *ahci_shost_attrs[] = { | |||
316 | 316 | ||
317 | static struct device_attribute *ahci_sdev_attrs[] = { | 317 | static struct device_attribute *ahci_sdev_attrs[] = { |
318 | &dev_attr_sw_activity, | 318 | &dev_attr_sw_activity, |
319 | &dev_attr_unload_heads, | ||
319 | NULL | 320 | NULL |
320 | }; | 321 | }; |
321 | 322 | ||
@@ -820,10 +821,10 @@ static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg) | |||
820 | return 0; | 821 | return 0; |
821 | } | 822 | } |
822 | 823 | ||
823 | static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 824 | static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
824 | { | 825 | { |
825 | void __iomem *port_mmio = ahci_port_base(ap); | 826 | void __iomem *port_mmio = ahci_port_base(link->ap); |
826 | int offset = ahci_scr_offset(ap, sc_reg); | 827 | int offset = ahci_scr_offset(link->ap, sc_reg); |
827 | 828 | ||
828 | if (offset) { | 829 | if (offset) { |
829 | *val = readl(port_mmio + offset); | 830 | *val = readl(port_mmio + offset); |
@@ -832,10 +833,10 @@ static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
832 | return -EINVAL; | 833 | return -EINVAL; |
833 | } | 834 | } |
834 | 835 | ||
835 | static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 836 | static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
836 | { | 837 | { |
837 | void __iomem *port_mmio = ahci_port_base(ap); | 838 | void __iomem *port_mmio = ahci_port_base(link->ap); |
838 | int offset = ahci_scr_offset(ap, sc_reg); | 839 | int offset = ahci_scr_offset(link->ap, sc_reg); |
839 | 840 | ||
840 | if (offset) { | 841 | if (offset) { |
841 | writel(val, port_mmio + offset); | 842 | writel(val, port_mmio + offset); |
@@ -973,7 +974,7 @@ static void ahci_disable_alpm(struct ata_port *ap) | |||
973 | writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT); | 974 | writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT); |
974 | 975 | ||
975 | /* go ahead and clean out PhyRdy Change from Serror too */ | 976 | /* go ahead and clean out PhyRdy Change from Serror too */ |
976 | ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); | 977 | ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18))); |
977 | 978 | ||
978 | /* | 979 | /* |
979 | * Clear flag to indicate that we should ignore all PhyRdy | 980 | * Clear flag to indicate that we should ignore all PhyRdy |
@@ -1937,8 +1938,8 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) | |||
1937 | ata_ehi_push_desc(host_ehi, "irq_stat 0x%08x", irq_stat); | 1938 | ata_ehi_push_desc(host_ehi, "irq_stat 0x%08x", irq_stat); |
1938 | 1939 | ||
1939 | /* AHCI needs SError cleared; otherwise, it might lock up */ | 1940 | /* AHCI needs SError cleared; otherwise, it might lock up */ |
1940 | ahci_scr_read(ap, SCR_ERROR, &serror); | 1941 | ahci_scr_read(&ap->link, SCR_ERROR, &serror); |
1941 | ahci_scr_write(ap, SCR_ERROR, serror); | 1942 | ahci_scr_write(&ap->link, SCR_ERROR, serror); |
1942 | host_ehi->serror |= serror; | 1943 | host_ehi->serror |= serror; |
1943 | 1944 | ||
1944 | /* some controllers set IRQ_IF_ERR on device errors, ignore it */ | 1945 | /* some controllers set IRQ_IF_ERR on device errors, ignore it */ |
@@ -2027,7 +2028,7 @@ static void ahci_port_intr(struct ata_port *ap) | |||
2027 | if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) && | 2028 | if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) && |
2028 | (status & PORT_IRQ_PHYRDY)) { | 2029 | (status & PORT_IRQ_PHYRDY)) { |
2029 | status &= ~PORT_IRQ_PHYRDY; | 2030 | status &= ~PORT_IRQ_PHYRDY; |
2030 | ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); | 2031 | ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18))); |
2031 | } | 2032 | } |
2032 | 2033 | ||
2033 | if (unlikely(status & PORT_IRQ_ERROR)) { | 2034 | if (unlikely(status & PORT_IRQ_ERROR)) { |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index e6b4606e36b6..e9e32ed6b1a3 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -165,8 +165,10 @@ static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev); | |||
165 | static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev); | 165 | static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev); |
166 | static int ich_pata_cable_detect(struct ata_port *ap); | 166 | static int ich_pata_cable_detect(struct ata_port *ap); |
167 | static u8 piix_vmw_bmdma_status(struct ata_port *ap); | 167 | static u8 piix_vmw_bmdma_status(struct ata_port *ap); |
168 | static int piix_sidpr_scr_read(struct ata_port *ap, unsigned int reg, u32 *val); | 168 | static int piix_sidpr_scr_read(struct ata_link *link, |
169 | static int piix_sidpr_scr_write(struct ata_port *ap, unsigned int reg, u32 val); | 169 | unsigned int reg, u32 *val); |
170 | static int piix_sidpr_scr_write(struct ata_link *link, | ||
171 | unsigned int reg, u32 val); | ||
170 | #ifdef CONFIG_PM | 172 | #ifdef CONFIG_PM |
171 | static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | 173 | static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); |
172 | static int piix_pci_device_resume(struct pci_dev *pdev); | 174 | static int piix_pci_device_resume(struct pci_dev *pdev); |
@@ -278,12 +280,15 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
278 | /* SATA Controller IDE (PCH) */ | 280 | /* SATA Controller IDE (PCH) */ |
279 | { 0x8086, 0x3b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 281 | { 0x8086, 0x3b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, |
280 | /* SATA Controller IDE (PCH) */ | 282 | /* SATA Controller IDE (PCH) */ |
283 | { 0x8086, 0x3b21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | ||
284 | /* SATA Controller IDE (PCH) */ | ||
281 | { 0x8086, 0x3b26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | 285 | { 0x8086, 0x3b26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
282 | /* SATA Controller IDE (PCH) */ | 286 | /* SATA Controller IDE (PCH) */ |
287 | { 0x8086, 0x3b28, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | ||
288 | /* SATA Controller IDE (PCH) */ | ||
283 | { 0x8086, 0x3b2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, | 289 | { 0x8086, 0x3b2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
284 | /* SATA Controller IDE (PCH) */ | 290 | /* SATA Controller IDE (PCH) */ |
285 | { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, | 291 | { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, |
286 | |||
287 | { } /* terminate list */ | 292 | { } /* terminate list */ |
288 | }; | 293 | }; |
289 | 294 | ||
@@ -582,6 +587,7 @@ static const struct ich_laptop ich_laptop[] = { | |||
582 | { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ | 587 | { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ |
583 | { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ | 588 | { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ |
584 | { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ | 589 | { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ |
590 | { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */ | ||
585 | { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */ | 591 | { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */ |
586 | { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */ | 592 | { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */ |
587 | { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */ | 593 | { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */ |
@@ -885,23 +891,9 @@ static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
885 | * Serial ATA Index/Data Pair Superset Registers access | 891 | * Serial ATA Index/Data Pair Superset Registers access |
886 | * | 892 | * |
887 | * Beginning from ICH8, there's a sane way to access SCRs using index | 893 | * Beginning from ICH8, there's a sane way to access SCRs using index |
888 | * and data register pair located at BAR5. This creates an | 894 | * and data register pair located at BAR5 which means that we have |
889 | * interesting problem of mapping two SCRs to one port. | 895 | * separate SCRs for master and slave. This is handled using libata |
890 | * | 896 | * slave_link facility. |
891 | * Although they have separate SCRs, the master and slave aren't | ||
892 | * independent enough to be treated as separate links - e.g. softreset | ||
893 | * resets both. Also, there's no protocol defined for hard resetting | ||
894 | * singled device sharing the virtual port (no defined way to acquire | ||
895 | * device signature). This is worked around by merging the SCR values | ||
896 | * into one sensible value and requesting follow-up SRST after | ||
897 | * hardreset. | ||
898 | * | ||
899 | * SCR merging is perfomed in nibbles which is the unit contents in | ||
900 | * SCRs are organized. If two values are equal, the value is used. | ||
901 | * When they differ, merge table which lists precedence of possible | ||
902 | * values is consulted and the first match or the last entry when | ||
903 | * nothing matches is used. When there's no merge table for the | ||
904 | * specific nibble, value from the first port is used. | ||
905 | */ | 897 | */ |
906 | static const int piix_sidx_map[] = { | 898 | static const int piix_sidx_map[] = { |
907 | [SCR_STATUS] = 0, | 899 | [SCR_STATUS] = 0, |
@@ -909,120 +901,38 @@ static const int piix_sidx_map[] = { | |||
909 | [SCR_CONTROL] = 1, | 901 | [SCR_CONTROL] = 1, |
910 | }; | 902 | }; |
911 | 903 | ||
912 | static void piix_sidpr_sel(struct ata_device *dev, unsigned int reg) | 904 | static void piix_sidpr_sel(struct ata_link *link, unsigned int reg) |
913 | { | 905 | { |
914 | struct ata_port *ap = dev->link->ap; | 906 | struct ata_port *ap = link->ap; |
915 | struct piix_host_priv *hpriv = ap->host->private_data; | 907 | struct piix_host_priv *hpriv = ap->host->private_data; |
916 | 908 | ||
917 | iowrite32(((ap->port_no * 2 + dev->devno) << 8) | piix_sidx_map[reg], | 909 | iowrite32(((ap->port_no * 2 + link->pmp) << 8) | piix_sidx_map[reg], |
918 | hpriv->sidpr + PIIX_SIDPR_IDX); | 910 | hpriv->sidpr + PIIX_SIDPR_IDX); |
919 | } | 911 | } |
920 | 912 | ||
921 | static int piix_sidpr_read(struct ata_device *dev, unsigned int reg) | 913 | static int piix_sidpr_scr_read(struct ata_link *link, |
922 | { | 914 | unsigned int reg, u32 *val) |
923 | struct piix_host_priv *hpriv = dev->link->ap->host->private_data; | ||
924 | |||
925 | piix_sidpr_sel(dev, reg); | ||
926 | return ioread32(hpriv->sidpr + PIIX_SIDPR_DATA); | ||
927 | } | ||
928 | |||
929 | static void piix_sidpr_write(struct ata_device *dev, unsigned int reg, u32 val) | ||
930 | { | ||
931 | struct piix_host_priv *hpriv = dev->link->ap->host->private_data; | ||
932 | |||
933 | piix_sidpr_sel(dev, reg); | ||
934 | iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); | ||
935 | } | ||
936 | |||
937 | static u32 piix_merge_scr(u32 val0, u32 val1, const int * const *merge_tbl) | ||
938 | { | ||
939 | u32 val = 0; | ||
940 | int i, mi; | ||
941 | |||
942 | for (i = 0, mi = 0; i < 32 / 4; i++) { | ||
943 | u8 c0 = (val0 >> (i * 4)) & 0xf; | ||
944 | u8 c1 = (val1 >> (i * 4)) & 0xf; | ||
945 | u8 merged = c0; | ||
946 | const int *cur; | ||
947 | |||
948 | /* if no merge preference, assume the first value */ | ||
949 | cur = merge_tbl[mi]; | ||
950 | if (!cur) | ||
951 | goto done; | ||
952 | mi++; | ||
953 | |||
954 | /* if two values equal, use it */ | ||
955 | if (c0 == c1) | ||
956 | goto done; | ||
957 | |||
958 | /* choose the first match or the last from the merge table */ | ||
959 | while (*cur != -1) { | ||
960 | if (c0 == *cur || c1 == *cur) | ||
961 | break; | ||
962 | cur++; | ||
963 | } | ||
964 | if (*cur == -1) | ||
965 | cur--; | ||
966 | merged = *cur; | ||
967 | done: | ||
968 | val |= merged << (i * 4); | ||
969 | } | ||
970 | |||
971 | return val; | ||
972 | } | ||
973 | |||
974 | static int piix_sidpr_scr_read(struct ata_port *ap, unsigned int reg, u32 *val) | ||
975 | { | 915 | { |
976 | const int * const sstatus_merge_tbl[] = { | 916 | struct piix_host_priv *hpriv = link->ap->host->private_data; |
977 | /* DET */ (const int []){ 1, 3, 0, 4, 3, -1 }, | ||
978 | /* SPD */ (const int []){ 2, 1, 0, -1 }, | ||
979 | /* IPM */ (const int []){ 6, 2, 1, 0, -1 }, | ||
980 | NULL, | ||
981 | }; | ||
982 | const int * const scontrol_merge_tbl[] = { | ||
983 | /* DET */ (const int []){ 1, 0, 4, 0, -1 }, | ||
984 | /* SPD */ (const int []){ 0, 2, 1, 0, -1 }, | ||
985 | /* IPM */ (const int []){ 0, 1, 2, 3, 0, -1 }, | ||
986 | NULL, | ||
987 | }; | ||
988 | u32 v0, v1; | ||
989 | 917 | ||
990 | if (reg >= ARRAY_SIZE(piix_sidx_map)) | 918 | if (reg >= ARRAY_SIZE(piix_sidx_map)) |
991 | return -EINVAL; | 919 | return -EINVAL; |
992 | 920 | ||
993 | if (!(ap->flags & ATA_FLAG_SLAVE_POSS)) { | 921 | piix_sidpr_sel(link, reg); |
994 | *val = piix_sidpr_read(&ap->link.device[0], reg); | 922 | *val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA); |
995 | return 0; | ||
996 | } | ||
997 | |||
998 | v0 = piix_sidpr_read(&ap->link.device[0], reg); | ||
999 | v1 = piix_sidpr_read(&ap->link.device[1], reg); | ||
1000 | |||
1001 | switch (reg) { | ||
1002 | case SCR_STATUS: | ||
1003 | *val = piix_merge_scr(v0, v1, sstatus_merge_tbl); | ||
1004 | break; | ||
1005 | case SCR_ERROR: | ||
1006 | *val = v0 | v1; | ||
1007 | break; | ||
1008 | case SCR_CONTROL: | ||
1009 | *val = piix_merge_scr(v0, v1, scontrol_merge_tbl); | ||
1010 | break; | ||
1011 | } | ||
1012 | |||
1013 | return 0; | 923 | return 0; |
1014 | } | 924 | } |
1015 | 925 | ||
1016 | static int piix_sidpr_scr_write(struct ata_port *ap, unsigned int reg, u32 val) | 926 | static int piix_sidpr_scr_write(struct ata_link *link, |
927 | unsigned int reg, u32 val) | ||
1017 | { | 928 | { |
929 | struct piix_host_priv *hpriv = link->ap->host->private_data; | ||
930 | |||
1018 | if (reg >= ARRAY_SIZE(piix_sidx_map)) | 931 | if (reg >= ARRAY_SIZE(piix_sidx_map)) |
1019 | return -EINVAL; | 932 | return -EINVAL; |
1020 | 933 | ||
1021 | piix_sidpr_write(&ap->link.device[0], reg, val); | 934 | piix_sidpr_sel(link, reg); |
1022 | 935 | iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); | |
1023 | if (ap->flags & ATA_FLAG_SLAVE_POSS) | ||
1024 | piix_sidpr_write(&ap->link.device[1], reg, val); | ||
1025 | |||
1026 | return 0; | 936 | return 0; |
1027 | } | 937 | } |
1028 | 938 | ||
@@ -1363,28 +1273,28 @@ static const int *__devinit piix_init_sata_map(struct pci_dev *pdev, | |||
1363 | return map; | 1273 | return map; |
1364 | } | 1274 | } |
1365 | 1275 | ||
1366 | static void __devinit piix_init_sidpr(struct ata_host *host) | 1276 | static int __devinit piix_init_sidpr(struct ata_host *host) |
1367 | { | 1277 | { |
1368 | struct pci_dev *pdev = to_pci_dev(host->dev); | 1278 | struct pci_dev *pdev = to_pci_dev(host->dev); |
1369 | struct piix_host_priv *hpriv = host->private_data; | 1279 | struct piix_host_priv *hpriv = host->private_data; |
1370 | struct ata_device *dev0 = &host->ports[0]->link.device[0]; | 1280 | struct ata_link *link0 = &host->ports[0]->link; |
1371 | u32 scontrol; | 1281 | u32 scontrol; |
1372 | int i; | 1282 | int i, rc; |
1373 | 1283 | ||
1374 | /* check for availability */ | 1284 | /* check for availability */ |
1375 | for (i = 0; i < 4; i++) | 1285 | for (i = 0; i < 4; i++) |
1376 | if (hpriv->map[i] == IDE) | 1286 | if (hpriv->map[i] == IDE) |
1377 | return; | 1287 | return 0; |
1378 | 1288 | ||
1379 | if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR)) | 1289 | if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR)) |
1380 | return; | 1290 | return 0; |
1381 | 1291 | ||
1382 | if (pci_resource_start(pdev, PIIX_SIDPR_BAR) == 0 || | 1292 | if (pci_resource_start(pdev, PIIX_SIDPR_BAR) == 0 || |
1383 | pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN) | 1293 | pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN) |
1384 | return; | 1294 | return 0; |
1385 | 1295 | ||
1386 | if (pcim_iomap_regions(pdev, 1 << PIIX_SIDPR_BAR, DRV_NAME)) | 1296 | if (pcim_iomap_regions(pdev, 1 << PIIX_SIDPR_BAR, DRV_NAME)) |
1387 | return; | 1297 | return 0; |
1388 | 1298 | ||
1389 | hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR]; | 1299 | hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR]; |
1390 | 1300 | ||
@@ -1392,7 +1302,7 @@ static void __devinit piix_init_sidpr(struct ata_host *host) | |||
1392 | * Give it a test drive by inhibiting power save modes which | 1302 | * Give it a test drive by inhibiting power save modes which |
1393 | * we'll do anyway. | 1303 | * we'll do anyway. |
1394 | */ | 1304 | */ |
1395 | scontrol = piix_sidpr_read(dev0, SCR_CONTROL); | 1305 | piix_sidpr_scr_read(link0, SCR_CONTROL, &scontrol); |
1396 | 1306 | ||
1397 | /* if IPM is already 3, SCR access is probably working. Don't | 1307 | /* if IPM is already 3, SCR access is probably working. Don't |
1398 | * un-inhibit power save modes as BIOS might have inhibited | 1308 | * un-inhibit power save modes as BIOS might have inhibited |
@@ -1400,18 +1310,30 @@ static void __devinit piix_init_sidpr(struct ata_host *host) | |||
1400 | */ | 1310 | */ |
1401 | if ((scontrol & 0xf00) != 0x300) { | 1311 | if ((scontrol & 0xf00) != 0x300) { |
1402 | scontrol |= 0x300; | 1312 | scontrol |= 0x300; |
1403 | piix_sidpr_write(dev0, SCR_CONTROL, scontrol); | 1313 | piix_sidpr_scr_write(link0, SCR_CONTROL, scontrol); |
1404 | scontrol = piix_sidpr_read(dev0, SCR_CONTROL); | 1314 | piix_sidpr_scr_read(link0, SCR_CONTROL, &scontrol); |
1405 | 1315 | ||
1406 | if ((scontrol & 0xf00) != 0x300) { | 1316 | if ((scontrol & 0xf00) != 0x300) { |
1407 | dev_printk(KERN_INFO, host->dev, "SCR access via " | 1317 | dev_printk(KERN_INFO, host->dev, "SCR access via " |
1408 | "SIDPR is available but doesn't work\n"); | 1318 | "SIDPR is available but doesn't work\n"); |
1409 | return; | 1319 | return 0; |
1410 | } | 1320 | } |
1411 | } | 1321 | } |
1412 | 1322 | ||
1413 | host->ports[0]->ops = &piix_sidpr_sata_ops; | 1323 | /* okay, SCRs available, set ops and ask libata for slave_link */ |
1414 | host->ports[1]->ops = &piix_sidpr_sata_ops; | 1324 | for (i = 0; i < 2; i++) { |
1325 | struct ata_port *ap = host->ports[i]; | ||
1326 | |||
1327 | ap->ops = &piix_sidpr_sata_ops; | ||
1328 | |||
1329 | if (ap->flags & ATA_FLAG_SLAVE_POSS) { | ||
1330 | rc = ata_slave_link_init(ap); | ||
1331 | if (rc) | ||
1332 | return rc; | ||
1333 | } | ||
1334 | } | ||
1335 | |||
1336 | return 0; | ||
1415 | } | 1337 | } |
1416 | 1338 | ||
1417 | static void piix_iocfg_bit18_quirk(struct pci_dev *pdev) | 1339 | static void piix_iocfg_bit18_quirk(struct pci_dev *pdev) |
@@ -1521,7 +1443,9 @@ static int __devinit piix_init_one(struct pci_dev *pdev, | |||
1521 | /* initialize controller */ | 1443 | /* initialize controller */ |
1522 | if (port_flags & ATA_FLAG_SATA) { | 1444 | if (port_flags & ATA_FLAG_SATA) { |
1523 | piix_init_pcs(host, piix_map_db_table[ent->driver_data]); | 1445 | piix_init_pcs(host, piix_map_db_table[ent->driver_data]); |
1524 | piix_init_sidpr(host); | 1446 | rc = piix_init_sidpr(host); |
1447 | if (rc) | ||
1448 | return rc; | ||
1525 | } | 1449 | } |
1526 | 1450 | ||
1527 | /* apply IOCFG bit18 quirk */ | 1451 | /* apply IOCFG bit18 quirk */ |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 79e3a8e7a84a..1ee9499bd343 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -163,6 +163,67 @@ MODULE_LICENSE("GPL"); | |||
163 | MODULE_VERSION(DRV_VERSION); | 163 | MODULE_VERSION(DRV_VERSION); |
164 | 164 | ||
165 | 165 | ||
166 | /* | ||
167 | * Iterator helpers. Don't use directly. | ||
168 | * | ||
169 | * LOCKING: | ||
170 | * Host lock or EH context. | ||
171 | */ | ||
172 | struct ata_link *__ata_port_next_link(struct ata_port *ap, | ||
173 | struct ata_link *link, bool dev_only) | ||
174 | { | ||
175 | /* NULL link indicates start of iteration */ | ||
176 | if (!link) { | ||
177 | if (dev_only && sata_pmp_attached(ap)) | ||
178 | return ap->pmp_link; | ||
179 | return &ap->link; | ||
180 | } | ||
181 | |||
182 | /* we just iterated over the host master link, what's next? */ | ||
183 | if (link == &ap->link) { | ||
184 | if (!sata_pmp_attached(ap)) { | ||
185 | if (unlikely(ap->slave_link) && !dev_only) | ||
186 | return ap->slave_link; | ||
187 | return NULL; | ||
188 | } | ||
189 | return ap->pmp_link; | ||
190 | } | ||
191 | |||
192 | /* slave_link excludes PMP */ | ||
193 | if (unlikely(link == ap->slave_link)) | ||
194 | return NULL; | ||
195 | |||
196 | /* iterate to the next PMP link */ | ||
197 | if (++link < ap->pmp_link + ap->nr_pmp_links) | ||
198 | return link; | ||
199 | return NULL; | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * ata_dev_phys_link - find physical link for a device | ||
204 | * @dev: ATA device to look up physical link for | ||
205 | * | ||
206 | * Look up physical link which @dev is attached to. Note that | ||
207 | * this is different from @dev->link only when @dev is on slave | ||
208 | * link. For all other cases, it's the same as @dev->link. | ||
209 | * | ||
210 | * LOCKING: | ||
211 | * Don't care. | ||
212 | * | ||
213 | * RETURNS: | ||
214 | * Pointer to the found physical link. | ||
215 | */ | ||
216 | struct ata_link *ata_dev_phys_link(struct ata_device *dev) | ||
217 | { | ||
218 | struct ata_port *ap = dev->link->ap; | ||
219 | |||
220 | if (!ap->slave_link) | ||
221 | return dev->link; | ||
222 | if (!dev->devno) | ||
223 | return &ap->link; | ||
224 | return ap->slave_link; | ||
225 | } | ||
226 | |||
166 | /** | 227 | /** |
167 | * ata_force_cbl - force cable type according to libata.force | 228 | * ata_force_cbl - force cable type according to libata.force |
168 | * @ap: ATA port of interest | 229 | * @ap: ATA port of interest |
@@ -206,7 +267,8 @@ void ata_force_cbl(struct ata_port *ap) | |||
206 | * the host link and all fan-out ports connected via PMP. If the | 267 | * the host link and all fan-out ports connected via PMP. If the |
207 | * device part is specified as 0 (e.g. 1.00:), it specifies the | 268 | * device part is specified as 0 (e.g. 1.00:), it specifies the |
208 | * first fan-out link not the host link. Device number 15 always | 269 | * first fan-out link not the host link. Device number 15 always |
209 | * points to the host link whether PMP is attached or not. | 270 | * points to the host link whether PMP is attached or not. If the |
271 | * controller has slave link, device number 16 points to it. | ||
210 | * | 272 | * |
211 | * LOCKING: | 273 | * LOCKING: |
212 | * EH context. | 274 | * EH context. |
@@ -214,12 +276,11 @@ void ata_force_cbl(struct ata_port *ap) | |||
214 | static void ata_force_link_limits(struct ata_link *link) | 276 | static void ata_force_link_limits(struct ata_link *link) |
215 | { | 277 | { |
216 | bool did_spd = false; | 278 | bool did_spd = false; |
217 | int linkno, i; | 279 | int linkno = link->pmp; |
280 | int i; | ||
218 | 281 | ||
219 | if (ata_is_host_link(link)) | 282 | if (ata_is_host_link(link)) |
220 | linkno = 15; | 283 | linkno += 15; |
221 | else | ||
222 | linkno = link->pmp; | ||
223 | 284 | ||
224 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | 285 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { |
225 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | 286 | const struct ata_force_ent *fe = &ata_force_tbl[i]; |
@@ -266,9 +327,9 @@ static void ata_force_xfermask(struct ata_device *dev) | |||
266 | int alt_devno = devno; | 327 | int alt_devno = devno; |
267 | int i; | 328 | int i; |
268 | 329 | ||
269 | /* allow n.15 for the first device attached to host port */ | 330 | /* allow n.15/16 for devices attached to host port */ |
270 | if (ata_is_host_link(dev->link) && devno == 0) | 331 | if (ata_is_host_link(dev->link)) |
271 | alt_devno = 15; | 332 | alt_devno += 15; |
272 | 333 | ||
273 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | 334 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { |
274 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | 335 | const struct ata_force_ent *fe = &ata_force_tbl[i]; |
@@ -320,9 +381,9 @@ static void ata_force_horkage(struct ata_device *dev) | |||
320 | int alt_devno = devno; | 381 | int alt_devno = devno; |
321 | int i; | 382 | int i; |
322 | 383 | ||
323 | /* allow n.15 for the first device attached to host port */ | 384 | /* allow n.15/16 for devices attached to host port */ |
324 | if (ata_is_host_link(dev->link) && devno == 0) | 385 | if (ata_is_host_link(dev->link)) |
325 | alt_devno = 15; | 386 | alt_devno += 15; |
326 | 387 | ||
327 | for (i = 0; i < ata_force_tbl_size; i++) { | 388 | for (i = 0; i < ata_force_tbl_size; i++) { |
328 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | 389 | const struct ata_force_ent *fe = &ata_force_tbl[i]; |
@@ -2681,7 +2742,7 @@ static void sata_print_link_status(struct ata_link *link) | |||
2681 | return; | 2742 | return; |
2682 | sata_scr_read(link, SCR_CONTROL, &scontrol); | 2743 | sata_scr_read(link, SCR_CONTROL, &scontrol); |
2683 | 2744 | ||
2684 | if (ata_link_online(link)) { | 2745 | if (ata_phys_link_online(link)) { |
2685 | tmp = (sstatus >> 4) & 0xf; | 2746 | tmp = (sstatus >> 4) & 0xf; |
2686 | ata_link_printk(link, KERN_INFO, | 2747 | ata_link_printk(link, KERN_INFO, |
2687 | "SATA link up %s (SStatus %X SControl %X)\n", | 2748 | "SATA link up %s (SStatus %X SControl %X)\n", |
@@ -3372,6 +3433,12 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline, | |||
3372 | unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT); | 3433 | unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT); |
3373 | int warned = 0; | 3434 | int warned = 0; |
3374 | 3435 | ||
3436 | /* Slave readiness can't be tested separately from master. On | ||
3437 | * M/S emulation configuration, this function should be called | ||
3438 | * only on the master and it will handle both master and slave. | ||
3439 | */ | ||
3440 | WARN_ON(link == link->ap->slave_link); | ||
3441 | |||
3375 | if (time_after(nodev_deadline, deadline)) | 3442 | if (time_after(nodev_deadline, deadline)) |
3376 | nodev_deadline = deadline; | 3443 | nodev_deadline = deadline; |
3377 | 3444 | ||
@@ -3593,7 +3660,7 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline) | |||
3593 | } | 3660 | } |
3594 | 3661 | ||
3595 | /* no point in trying softreset on offline link */ | 3662 | /* no point in trying softreset on offline link */ |
3596 | if (ata_link_offline(link)) | 3663 | if (ata_phys_link_offline(link)) |
3597 | ehc->i.action &= ~ATA_EH_SOFTRESET; | 3664 | ehc->i.action &= ~ATA_EH_SOFTRESET; |
3598 | 3665 | ||
3599 | return 0; | 3666 | return 0; |
@@ -3671,7 +3738,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, | |||
3671 | if (rc) | 3738 | if (rc) |
3672 | goto out; | 3739 | goto out; |
3673 | /* if link is offline nothing more to do */ | 3740 | /* if link is offline nothing more to do */ |
3674 | if (ata_link_offline(link)) | 3741 | if (ata_phys_link_offline(link)) |
3675 | goto out; | 3742 | goto out; |
3676 | 3743 | ||
3677 | /* Link is online. From this point, -ENODEV too is an error. */ | 3744 | /* Link is online. From this point, -ENODEV too is an error. */ |
@@ -4868,10 +4935,8 @@ int sata_scr_valid(struct ata_link *link) | |||
4868 | int sata_scr_read(struct ata_link *link, int reg, u32 *val) | 4935 | int sata_scr_read(struct ata_link *link, int reg, u32 *val) |
4869 | { | 4936 | { |
4870 | if (ata_is_host_link(link)) { | 4937 | if (ata_is_host_link(link)) { |
4871 | struct ata_port *ap = link->ap; | ||
4872 | |||
4873 | if (sata_scr_valid(link)) | 4938 | if (sata_scr_valid(link)) |
4874 | return ap->ops->scr_read(ap, reg, val); | 4939 | return link->ap->ops->scr_read(link, reg, val); |
4875 | return -EOPNOTSUPP; | 4940 | return -EOPNOTSUPP; |
4876 | } | 4941 | } |
4877 | 4942 | ||
@@ -4897,10 +4962,8 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val) | |||
4897 | int sata_scr_write(struct ata_link *link, int reg, u32 val) | 4962 | int sata_scr_write(struct ata_link *link, int reg, u32 val) |
4898 | { | 4963 | { |
4899 | if (ata_is_host_link(link)) { | 4964 | if (ata_is_host_link(link)) { |
4900 | struct ata_port *ap = link->ap; | ||
4901 | |||
4902 | if (sata_scr_valid(link)) | 4965 | if (sata_scr_valid(link)) |
4903 | return ap->ops->scr_write(ap, reg, val); | 4966 | return link->ap->ops->scr_write(link, reg, val); |
4904 | return -EOPNOTSUPP; | 4967 | return -EOPNOTSUPP; |
4905 | } | 4968 | } |
4906 | 4969 | ||
@@ -4925,13 +4988,12 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val) | |||
4925 | int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) | 4988 | int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) |
4926 | { | 4989 | { |
4927 | if (ata_is_host_link(link)) { | 4990 | if (ata_is_host_link(link)) { |
4928 | struct ata_port *ap = link->ap; | ||
4929 | int rc; | 4991 | int rc; |
4930 | 4992 | ||
4931 | if (sata_scr_valid(link)) { | 4993 | if (sata_scr_valid(link)) { |
4932 | rc = ap->ops->scr_write(ap, reg, val); | 4994 | rc = link->ap->ops->scr_write(link, reg, val); |
4933 | if (rc == 0) | 4995 | if (rc == 0) |
4934 | rc = ap->ops->scr_read(ap, reg, &val); | 4996 | rc = link->ap->ops->scr_read(link, reg, &val); |
4935 | return rc; | 4997 | return rc; |
4936 | } | 4998 | } |
4937 | return -EOPNOTSUPP; | 4999 | return -EOPNOTSUPP; |
@@ -4941,7 +5003,7 @@ int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) | |||
4941 | } | 5003 | } |
4942 | 5004 | ||
4943 | /** | 5005 | /** |
4944 | * ata_link_online - test whether the given link is online | 5006 | * ata_phys_link_online - test whether the given link is online |
4945 | * @link: ATA link to test | 5007 | * @link: ATA link to test |
4946 | * | 5008 | * |
4947 | * Test whether @link is online. Note that this function returns | 5009 | * Test whether @link is online. Note that this function returns |
@@ -4952,20 +5014,20 @@ int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) | |||
4952 | * None. | 5014 | * None. |
4953 | * | 5015 | * |
4954 | * RETURNS: | 5016 | * RETURNS: |
4955 | * 1 if the port online status is available and online. | 5017 | * True if the port online status is available and online. |
4956 | */ | 5018 | */ |
4957 | int ata_link_online(struct ata_link *link) | 5019 | bool ata_phys_link_online(struct ata_link *link) |
4958 | { | 5020 | { |
4959 | u32 sstatus; | 5021 | u32 sstatus; |
4960 | 5022 | ||
4961 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && | 5023 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && |
4962 | (sstatus & 0xf) == 0x3) | 5024 | (sstatus & 0xf) == 0x3) |
4963 | return 1; | 5025 | return true; |
4964 | return 0; | 5026 | return false; |
4965 | } | 5027 | } |
4966 | 5028 | ||
4967 | /** | 5029 | /** |
4968 | * ata_link_offline - test whether the given link is offline | 5030 | * ata_phys_link_offline - test whether the given link is offline |
4969 | * @link: ATA link to test | 5031 | * @link: ATA link to test |
4970 | * | 5032 | * |
4971 | * Test whether @link is offline. Note that this function | 5033 | * Test whether @link is offline. Note that this function |
@@ -4976,16 +5038,68 @@ int ata_link_online(struct ata_link *link) | |||
4976 | * None. | 5038 | * None. |
4977 | * | 5039 | * |
4978 | * RETURNS: | 5040 | * RETURNS: |
4979 | * 1 if the port offline status is available and offline. | 5041 | * True if the port offline status is available and offline. |
4980 | */ | 5042 | */ |
4981 | int ata_link_offline(struct ata_link *link) | 5043 | bool ata_phys_link_offline(struct ata_link *link) |
4982 | { | 5044 | { |
4983 | u32 sstatus; | 5045 | u32 sstatus; |
4984 | 5046 | ||
4985 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && | 5047 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && |
4986 | (sstatus & 0xf) != 0x3) | 5048 | (sstatus & 0xf) != 0x3) |
4987 | return 1; | 5049 | return true; |
4988 | return 0; | 5050 | return false; |
5051 | } | ||
5052 | |||
5053 | /** | ||
5054 | * ata_link_online - test whether the given link is online | ||
5055 | * @link: ATA link to test | ||
5056 | * | ||
5057 | * Test whether @link is online. This is identical to | ||
5058 | * ata_phys_link_online() when there's no slave link. When | ||
5059 | * there's a slave link, this function should only be called on | ||
5060 | * the master link and will return true if any of M/S links is | ||
5061 | * online. | ||
5062 | * | ||
5063 | * LOCKING: | ||
5064 | * None. | ||
5065 | * | ||
5066 | * RETURNS: | ||
5067 | * True if the port online status is available and online. | ||
5068 | */ | ||
5069 | bool ata_link_online(struct ata_link *link) | ||
5070 | { | ||
5071 | struct ata_link *slave = link->ap->slave_link; | ||
5072 | |||
5073 | WARN_ON(link == slave); /* shouldn't be called on slave link */ | ||
5074 | |||
5075 | return ata_phys_link_online(link) || | ||
5076 | (slave && ata_phys_link_online(slave)); | ||
5077 | } | ||
5078 | |||
5079 | /** | ||
5080 | * ata_link_offline - test whether the given link is offline | ||
5081 | * @link: ATA link to test | ||
5082 | * | ||
5083 | * Test whether @link is offline. This is identical to | ||
5084 | * ata_phys_link_offline() when there's no slave link. When | ||
5085 | * there's a slave link, this function should only be called on | ||
5086 | * the master link and will return true if both M/S links are | ||
5087 | * offline. | ||
5088 | * | ||
5089 | * LOCKING: | ||
5090 | * None. | ||
5091 | * | ||
5092 | * RETURNS: | ||
5093 | * True if the port offline status is available and offline. | ||
5094 | */ | ||
5095 | bool ata_link_offline(struct ata_link *link) | ||
5096 | { | ||
5097 | struct ata_link *slave = link->ap->slave_link; | ||
5098 | |||
5099 | WARN_ON(link == slave); /* shouldn't be called on slave link */ | ||
5100 | |||
5101 | return ata_phys_link_offline(link) && | ||
5102 | (!slave || ata_phys_link_offline(slave)); | ||
4989 | } | 5103 | } |
4990 | 5104 | ||
4991 | #ifdef CONFIG_PM | 5105 | #ifdef CONFIG_PM |
@@ -5127,11 +5241,11 @@ int ata_port_start(struct ata_port *ap) | |||
5127 | */ | 5241 | */ |
5128 | void ata_dev_init(struct ata_device *dev) | 5242 | void ata_dev_init(struct ata_device *dev) |
5129 | { | 5243 | { |
5130 | struct ata_link *link = dev->link; | 5244 | struct ata_link *link = ata_dev_phys_link(dev); |
5131 | struct ata_port *ap = link->ap; | 5245 | struct ata_port *ap = link->ap; |
5132 | unsigned long flags; | 5246 | unsigned long flags; |
5133 | 5247 | ||
5134 | /* SATA spd limit is bound to the first device */ | 5248 | /* SATA spd limit is bound to the attached device, reset together */ |
5135 | link->sata_spd_limit = link->hw_sata_spd_limit; | 5249 | link->sata_spd_limit = link->hw_sata_spd_limit; |
5136 | link->sata_spd = 0; | 5250 | link->sata_spd = 0; |
5137 | 5251 | ||
@@ -5264,6 +5378,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
5264 | INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan); | 5378 | INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan); |
5265 | INIT_LIST_HEAD(&ap->eh_done_q); | 5379 | INIT_LIST_HEAD(&ap->eh_done_q); |
5266 | init_waitqueue_head(&ap->eh_wait_q); | 5380 | init_waitqueue_head(&ap->eh_wait_q); |
5381 | init_completion(&ap->park_req_pending); | ||
5267 | init_timer_deferrable(&ap->fastdrain_timer); | 5382 | init_timer_deferrable(&ap->fastdrain_timer); |
5268 | ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn; | 5383 | ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn; |
5269 | ap->fastdrain_timer.data = (unsigned long)ap; | 5384 | ap->fastdrain_timer.data = (unsigned long)ap; |
@@ -5294,6 +5409,7 @@ static void ata_host_release(struct device *gendev, void *res) | |||
5294 | scsi_host_put(ap->scsi_host); | 5409 | scsi_host_put(ap->scsi_host); |
5295 | 5410 | ||
5296 | kfree(ap->pmp_link); | 5411 | kfree(ap->pmp_link); |
5412 | kfree(ap->slave_link); | ||
5297 | kfree(ap); | 5413 | kfree(ap); |
5298 | host->ports[i] = NULL; | 5414 | host->ports[i] = NULL; |
5299 | } | 5415 | } |
@@ -5414,6 +5530,68 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, | |||
5414 | return host; | 5530 | return host; |
5415 | } | 5531 | } |
5416 | 5532 | ||
5533 | /** | ||
5534 | * ata_slave_link_init - initialize slave link | ||
5535 | * @ap: port to initialize slave link for | ||
5536 | * | ||
5537 | * Create and initialize slave link for @ap. This enables slave | ||
5538 | * link handling on the port. | ||
5539 | * | ||
5540 | * In libata, a port contains links and a link contains devices. | ||
5541 | * There is single host link but if a PMP is attached to it, | ||
5542 | * there can be multiple fan-out links. On SATA, there's usually | ||
5543 | * a single device connected to a link but PATA and SATA | ||
5544 | * controllers emulating TF based interface can have two - master | ||
5545 | * and slave. | ||
5546 | * | ||
5547 | * However, there are a few controllers which don't fit into this | ||
5548 | * abstraction too well - SATA controllers which emulate TF | ||
5549 | * interface with both master and slave devices but also have | ||
5550 | * separate SCR register sets for each device. These controllers | ||
5551 | * need separate links for physical link handling | ||
5552 | * (e.g. onlineness, link speed) but should be treated like a | ||
5553 | * traditional M/S controller for everything else (e.g. command | ||
5554 | * issue, softreset). | ||
5555 | * | ||
5556 | * slave_link is libata's way of handling this class of | ||
5557 | * controllers without impacting core layer too much. For | ||
5558 | * anything other than physical link handling, the default host | ||
5559 | * link is used for both master and slave. For physical link | ||
5560 | * handling, separate @ap->slave_link is used. All dirty details | ||
5561 | * are implemented inside libata core layer. From LLD's POV, the | ||
5562 | * only difference is that prereset, hardreset and postreset are | ||
5563 | * called once more for the slave link, so the reset sequence | ||
5564 | * looks like the following. | ||
5565 | * | ||
5566 | * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) -> | ||
5567 | * softreset(M) -> postreset(M) -> postreset(S) | ||
5568 | * | ||
5569 | * Note that softreset is called only for the master. Softreset | ||
5570 | * resets both M/S by definition, so SRST on master should handle | ||
5571 | * both (the standard method will work just fine). | ||
5572 | * | ||
5573 | * LOCKING: | ||
5574 | * Should be called before host is registered. | ||
5575 | * | ||
5576 | * RETURNS: | ||
5577 | * 0 on success, -errno on failure. | ||
5578 | */ | ||
5579 | int ata_slave_link_init(struct ata_port *ap) | ||
5580 | { | ||
5581 | struct ata_link *link; | ||
5582 | |||
5583 | WARN_ON(ap->slave_link); | ||
5584 | WARN_ON(ap->flags & ATA_FLAG_PMP); | ||
5585 | |||
5586 | link = kzalloc(sizeof(*link), GFP_KERNEL); | ||
5587 | if (!link) | ||
5588 | return -ENOMEM; | ||
5589 | |||
5590 | ata_link_init(ap, link, 1); | ||
5591 | ap->slave_link = link; | ||
5592 | return 0; | ||
5593 | } | ||
5594 | |||
5417 | static void ata_host_stop(struct device *gendev, void *res) | 5595 | static void ata_host_stop(struct device *gendev, void *res) |
5418 | { | 5596 | { |
5419 | struct ata_host *host = dev_get_drvdata(gendev); | 5597 | struct ata_host *host = dev_get_drvdata(gendev); |
@@ -5640,6 +5818,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
5640 | 5818 | ||
5641 | /* init sata_spd_limit to the current value */ | 5819 | /* init sata_spd_limit to the current value */ |
5642 | sata_link_init_spd(&ap->link); | 5820 | sata_link_init_spd(&ap->link); |
5821 | if (ap->slave_link) | ||
5822 | sata_link_init_spd(ap->slave_link); | ||
5643 | 5823 | ||
5644 | /* print per-port info to dmesg */ | 5824 | /* print per-port info to dmesg */ |
5645 | xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, | 5825 | xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, |
@@ -6260,10 +6440,12 @@ EXPORT_SYMBOL_GPL(ata_base_port_ops); | |||
6260 | EXPORT_SYMBOL_GPL(sata_port_ops); | 6440 | EXPORT_SYMBOL_GPL(sata_port_ops); |
6261 | EXPORT_SYMBOL_GPL(ata_dummy_port_ops); | 6441 | EXPORT_SYMBOL_GPL(ata_dummy_port_ops); |
6262 | EXPORT_SYMBOL_GPL(ata_dummy_port_info); | 6442 | EXPORT_SYMBOL_GPL(ata_dummy_port_info); |
6443 | EXPORT_SYMBOL_GPL(__ata_port_next_link); | ||
6263 | EXPORT_SYMBOL_GPL(ata_std_bios_param); | 6444 | EXPORT_SYMBOL_GPL(ata_std_bios_param); |
6264 | EXPORT_SYMBOL_GPL(ata_host_init); | 6445 | EXPORT_SYMBOL_GPL(ata_host_init); |
6265 | EXPORT_SYMBOL_GPL(ata_host_alloc); | 6446 | EXPORT_SYMBOL_GPL(ata_host_alloc); |
6266 | EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); | 6447 | EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); |
6448 | EXPORT_SYMBOL_GPL(ata_slave_link_init); | ||
6267 | EXPORT_SYMBOL_GPL(ata_host_start); | 6449 | EXPORT_SYMBOL_GPL(ata_host_start); |
6268 | EXPORT_SYMBOL_GPL(ata_host_register); | 6450 | EXPORT_SYMBOL_GPL(ata_host_register); |
6269 | EXPORT_SYMBOL_GPL(ata_host_activate); | 6451 | EXPORT_SYMBOL_GPL(ata_host_activate); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index c1db2f234d2e..a93247cc395a 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -33,6 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/blkdev.h> | ||
36 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
37 | #include <scsi/scsi.h> | 38 | #include <scsi/scsi.h> |
38 | #include <scsi/scsi_host.h> | 39 | #include <scsi/scsi_host.h> |
@@ -79,6 +80,8 @@ enum { | |||
79 | */ | 80 | */ |
80 | ATA_EH_PRERESET_TIMEOUT = 10000, | 81 | ATA_EH_PRERESET_TIMEOUT = 10000, |
81 | ATA_EH_FASTDRAIN_INTERVAL = 3000, | 82 | ATA_EH_FASTDRAIN_INTERVAL = 3000, |
83 | |||
84 | ATA_EH_UA_TRIES = 5, | ||
82 | }; | 85 | }; |
83 | 86 | ||
84 | /* The following table determines how we sequence resets. Each entry | 87 | /* The following table determines how we sequence resets. Each entry |
@@ -457,29 +460,29 @@ static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev, | |||
457 | * RETURNS: | 460 | * RETURNS: |
458 | * EH_HANDLED or EH_NOT_HANDLED | 461 | * EH_HANDLED or EH_NOT_HANDLED |
459 | */ | 462 | */ |
460 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) | 463 | enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) |
461 | { | 464 | { |
462 | struct Scsi_Host *host = cmd->device->host; | 465 | struct Scsi_Host *host = cmd->device->host; |
463 | struct ata_port *ap = ata_shost_to_port(host); | 466 | struct ata_port *ap = ata_shost_to_port(host); |
464 | unsigned long flags; | 467 | unsigned long flags; |
465 | struct ata_queued_cmd *qc; | 468 | struct ata_queued_cmd *qc; |
466 | enum scsi_eh_timer_return ret; | 469 | enum blk_eh_timer_return ret; |
467 | 470 | ||
468 | DPRINTK("ENTER\n"); | 471 | DPRINTK("ENTER\n"); |
469 | 472 | ||
470 | if (ap->ops->error_handler) { | 473 | if (ap->ops->error_handler) { |
471 | ret = EH_NOT_HANDLED; | 474 | ret = BLK_EH_NOT_HANDLED; |
472 | goto out; | 475 | goto out; |
473 | } | 476 | } |
474 | 477 | ||
475 | ret = EH_HANDLED; | 478 | ret = BLK_EH_HANDLED; |
476 | spin_lock_irqsave(ap->lock, flags); | 479 | spin_lock_irqsave(ap->lock, flags); |
477 | qc = ata_qc_from_tag(ap, ap->link.active_tag); | 480 | qc = ata_qc_from_tag(ap, ap->link.active_tag); |
478 | if (qc) { | 481 | if (qc) { |
479 | WARN_ON(qc->scsicmd != cmd); | 482 | WARN_ON(qc->scsicmd != cmd); |
480 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; | 483 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; |
481 | qc->err_mask |= AC_ERR_TIMEOUT; | 484 | qc->err_mask |= AC_ERR_TIMEOUT; |
482 | ret = EH_NOT_HANDLED; | 485 | ret = BLK_EH_NOT_HANDLED; |
483 | } | 486 | } |
484 | spin_unlock_irqrestore(ap->lock, flags); | 487 | spin_unlock_irqrestore(ap->lock, flags); |
485 | 488 | ||
@@ -831,7 +834,7 @@ void ata_qc_schedule_eh(struct ata_queued_cmd *qc) | |||
831 | * Note that ATA_QCFLAG_FAILED is unconditionally set after | 834 | * Note that ATA_QCFLAG_FAILED is unconditionally set after |
832 | * this function completes. | 835 | * this function completes. |
833 | */ | 836 | */ |
834 | scsi_req_abort_cmd(qc->scsicmd); | 837 | blk_abort_request(qc->scsicmd->request); |
835 | } | 838 | } |
836 | 839 | ||
837 | /** | 840 | /** |
@@ -1357,6 +1360,37 @@ static int ata_eh_read_log_10h(struct ata_device *dev, | |||
1357 | } | 1360 | } |
1358 | 1361 | ||
1359 | /** | 1362 | /** |
1363 | * atapi_eh_tur - perform ATAPI TEST_UNIT_READY | ||
1364 | * @dev: target ATAPI device | ||
1365 | * @r_sense_key: out parameter for sense_key | ||
1366 | * | ||
1367 | * Perform ATAPI TEST_UNIT_READY. | ||
1368 | * | ||
1369 | * LOCKING: | ||
1370 | * EH context (may sleep). | ||
1371 | * | ||
1372 | * RETURNS: | ||
1373 | * 0 on success, AC_ERR_* mask on failure. | ||
1374 | */ | ||
1375 | static unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key) | ||
1376 | { | ||
1377 | u8 cdb[ATAPI_CDB_LEN] = { TEST_UNIT_READY, 0, 0, 0, 0, 0 }; | ||
1378 | struct ata_taskfile tf; | ||
1379 | unsigned int err_mask; | ||
1380 | |||
1381 | ata_tf_init(dev, &tf); | ||
1382 | |||
1383 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
1384 | tf.command = ATA_CMD_PACKET; | ||
1385 | tf.protocol = ATAPI_PROT_NODATA; | ||
1386 | |||
1387 | err_mask = ata_exec_internal(dev, &tf, cdb, DMA_NONE, NULL, 0, 0); | ||
1388 | if (err_mask == AC_ERR_DEV) | ||
1389 | *r_sense_key = tf.feature >> 4; | ||
1390 | return err_mask; | ||
1391 | } | ||
1392 | |||
1393 | /** | ||
1360 | * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE | 1394 | * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE |
1361 | * @dev: device to perform REQUEST_SENSE to | 1395 | * @dev: device to perform REQUEST_SENSE to |
1362 | * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) | 1396 | * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) |
@@ -1756,7 +1790,7 @@ static unsigned int ata_eh_speed_down_verdict(struct ata_device *dev) | |||
1756 | static unsigned int ata_eh_speed_down(struct ata_device *dev, | 1790 | static unsigned int ata_eh_speed_down(struct ata_device *dev, |
1757 | unsigned int eflags, unsigned int err_mask) | 1791 | unsigned int eflags, unsigned int err_mask) |
1758 | { | 1792 | { |
1759 | struct ata_link *link = dev->link; | 1793 | struct ata_link *link = ata_dev_phys_link(dev); |
1760 | int xfer_ok = 0; | 1794 | int xfer_ok = 0; |
1761 | unsigned int verdict; | 1795 | unsigned int verdict; |
1762 | unsigned int action = 0; | 1796 | unsigned int action = 0; |
@@ -1880,7 +1914,8 @@ static void ata_eh_link_autopsy(struct ata_link *link) | |||
1880 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 1914 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { |
1881 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | 1915 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); |
1882 | 1916 | ||
1883 | if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link) | 1917 | if (!(qc->flags & ATA_QCFLAG_FAILED) || |
1918 | ata_dev_phys_link(qc->dev) != link) | ||
1884 | continue; | 1919 | continue; |
1885 | 1920 | ||
1886 | /* inherit upper level err_mask */ | 1921 | /* inherit upper level err_mask */ |
@@ -1967,6 +2002,23 @@ void ata_eh_autopsy(struct ata_port *ap) | |||
1967 | ata_port_for_each_link(link, ap) | 2002 | ata_port_for_each_link(link, ap) |
1968 | ata_eh_link_autopsy(link); | 2003 | ata_eh_link_autopsy(link); |
1969 | 2004 | ||
2005 | /* Handle the frigging slave link. Autopsy is done similarly | ||
2006 | * but actions and flags are transferred over to the master | ||
2007 | * link and handled from there. | ||
2008 | */ | ||
2009 | if (ap->slave_link) { | ||
2010 | struct ata_eh_context *mehc = &ap->link.eh_context; | ||
2011 | struct ata_eh_context *sehc = &ap->slave_link->eh_context; | ||
2012 | |||
2013 | ata_eh_link_autopsy(ap->slave_link); | ||
2014 | |||
2015 | ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); | ||
2016 | mehc->i.action |= sehc->i.action; | ||
2017 | mehc->i.dev_action[1] |= sehc->i.dev_action[1]; | ||
2018 | mehc->i.flags |= sehc->i.flags; | ||
2019 | ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); | ||
2020 | } | ||
2021 | |||
1970 | /* Autopsy of fanout ports can affect host link autopsy. | 2022 | /* Autopsy of fanout ports can affect host link autopsy. |
1971 | * Perform host link autopsy last. | 2023 | * Perform host link autopsy last. |
1972 | */ | 2024 | */ |
@@ -2001,7 +2053,8 @@ static void ata_eh_link_report(struct ata_link *link) | |||
2001 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 2053 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { |
2002 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | 2054 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); |
2003 | 2055 | ||
2004 | if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link || | 2056 | if (!(qc->flags & ATA_QCFLAG_FAILED) || |
2057 | ata_dev_phys_link(qc->dev) != link || | ||
2005 | ((qc->flags & ATA_QCFLAG_QUIET) && | 2058 | ((qc->flags & ATA_QCFLAG_QUIET) && |
2006 | qc->err_mask == AC_ERR_DEV)) | 2059 | qc->err_mask == AC_ERR_DEV)) |
2007 | continue; | 2060 | continue; |
@@ -2068,7 +2121,7 @@ static void ata_eh_link_report(struct ata_link *link) | |||
2068 | char cdb_buf[70] = ""; | 2121 | char cdb_buf[70] = ""; |
2069 | 2122 | ||
2070 | if (!(qc->flags & ATA_QCFLAG_FAILED) || | 2123 | if (!(qc->flags & ATA_QCFLAG_FAILED) || |
2071 | qc->dev->link != link || !qc->err_mask) | 2124 | ata_dev_phys_link(qc->dev) != link || !qc->err_mask) |
2072 | continue; | 2125 | continue; |
2073 | 2126 | ||
2074 | if (qc->dma_dir != DMA_NONE) { | 2127 | if (qc->dma_dir != DMA_NONE) { |
@@ -2160,12 +2213,14 @@ void ata_eh_report(struct ata_port *ap) | |||
2160 | } | 2213 | } |
2161 | 2214 | ||
2162 | static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, | 2215 | static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, |
2163 | unsigned int *classes, unsigned long deadline) | 2216 | unsigned int *classes, unsigned long deadline, |
2217 | bool clear_classes) | ||
2164 | { | 2218 | { |
2165 | struct ata_device *dev; | 2219 | struct ata_device *dev; |
2166 | 2220 | ||
2167 | ata_link_for_each_dev(dev, link) | 2221 | if (clear_classes) |
2168 | classes[dev->devno] = ATA_DEV_UNKNOWN; | 2222 | ata_link_for_each_dev(dev, link) |
2223 | classes[dev->devno] = ATA_DEV_UNKNOWN; | ||
2169 | 2224 | ||
2170 | return reset(link, classes, deadline); | 2225 | return reset(link, classes, deadline); |
2171 | } | 2226 | } |
@@ -2187,17 +2242,20 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2187 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) | 2242 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) |
2188 | { | 2243 | { |
2189 | struct ata_port *ap = link->ap; | 2244 | struct ata_port *ap = link->ap; |
2245 | struct ata_link *slave = ap->slave_link; | ||
2190 | struct ata_eh_context *ehc = &link->eh_context; | 2246 | struct ata_eh_context *ehc = &link->eh_context; |
2247 | struct ata_eh_context *sehc = &slave->eh_context; | ||
2191 | unsigned int *classes = ehc->classes; | 2248 | unsigned int *classes = ehc->classes; |
2192 | unsigned int lflags = link->flags; | 2249 | unsigned int lflags = link->flags; |
2193 | int verbose = !(ehc->i.flags & ATA_EHI_QUIET); | 2250 | int verbose = !(ehc->i.flags & ATA_EHI_QUIET); |
2194 | int max_tries = 0, try = 0; | 2251 | int max_tries = 0, try = 0; |
2252 | struct ata_link *failed_link; | ||
2195 | struct ata_device *dev; | 2253 | struct ata_device *dev; |
2196 | unsigned long deadline, now; | 2254 | unsigned long deadline, now; |
2197 | ata_reset_fn_t reset; | 2255 | ata_reset_fn_t reset; |
2198 | unsigned long flags; | 2256 | unsigned long flags; |
2199 | u32 sstatus; | 2257 | u32 sstatus; |
2200 | int nr_known, rc; | 2258 | int nr_unknown, rc; |
2201 | 2259 | ||
2202 | /* | 2260 | /* |
2203 | * Prepare to reset | 2261 | * Prepare to reset |
@@ -2252,8 +2310,30 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2252 | } | 2310 | } |
2253 | 2311 | ||
2254 | if (prereset) { | 2312 | if (prereset) { |
2255 | rc = prereset(link, | 2313 | unsigned long deadline = ata_deadline(jiffies, |
2256 | ata_deadline(jiffies, ATA_EH_PRERESET_TIMEOUT)); | 2314 | ATA_EH_PRERESET_TIMEOUT); |
2315 | |||
2316 | if (slave) { | ||
2317 | sehc->i.action &= ~ATA_EH_RESET; | ||
2318 | sehc->i.action |= ehc->i.action; | ||
2319 | } | ||
2320 | |||
2321 | rc = prereset(link, deadline); | ||
2322 | |||
2323 | /* If present, do prereset on slave link too. Reset | ||
2324 | * is skipped iff both master and slave links report | ||
2325 | * -ENOENT or clear ATA_EH_RESET. | ||
2326 | */ | ||
2327 | if (slave && (rc == 0 || rc == -ENOENT)) { | ||
2328 | int tmp; | ||
2329 | |||
2330 | tmp = prereset(slave, deadline); | ||
2331 | if (tmp != -ENOENT) | ||
2332 | rc = tmp; | ||
2333 | |||
2334 | ehc->i.action |= sehc->i.action; | ||
2335 | } | ||
2336 | |||
2257 | if (rc) { | 2337 | if (rc) { |
2258 | if (rc == -ENOENT) { | 2338 | if (rc == -ENOENT) { |
2259 | ata_link_printk(link, KERN_DEBUG, | 2339 | ata_link_printk(link, KERN_DEBUG, |
@@ -2302,25 +2382,51 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2302 | else | 2382 | else |
2303 | ehc->i.flags |= ATA_EHI_DID_SOFTRESET; | 2383 | ehc->i.flags |= ATA_EHI_DID_SOFTRESET; |
2304 | 2384 | ||
2305 | rc = ata_do_reset(link, reset, classes, deadline); | 2385 | rc = ata_do_reset(link, reset, classes, deadline, true); |
2306 | if (rc && rc != -EAGAIN) | 2386 | if (rc && rc != -EAGAIN) { |
2387 | failed_link = link; | ||
2307 | goto fail; | 2388 | goto fail; |
2389 | } | ||
2390 | |||
2391 | /* hardreset slave link if existent */ | ||
2392 | if (slave && reset == hardreset) { | ||
2393 | int tmp; | ||
2394 | |||
2395 | if (verbose) | ||
2396 | ata_link_printk(slave, KERN_INFO, | ||
2397 | "hard resetting link\n"); | ||
2308 | 2398 | ||
2399 | ata_eh_about_to_do(slave, NULL, ATA_EH_RESET); | ||
2400 | tmp = ata_do_reset(slave, reset, classes, deadline, | ||
2401 | false); | ||
2402 | switch (tmp) { | ||
2403 | case -EAGAIN: | ||
2404 | rc = -EAGAIN; | ||
2405 | case 0: | ||
2406 | break; | ||
2407 | default: | ||
2408 | failed_link = slave; | ||
2409 | rc = tmp; | ||
2410 | goto fail; | ||
2411 | } | ||
2412 | } | ||
2413 | |||
2414 | /* perform follow-up SRST if necessary */ | ||
2309 | if (reset == hardreset && | 2415 | if (reset == hardreset && |
2310 | ata_eh_followup_srst_needed(link, rc, classes)) { | 2416 | ata_eh_followup_srst_needed(link, rc, classes)) { |
2311 | /* okay, let's do follow-up softreset */ | ||
2312 | reset = softreset; | 2417 | reset = softreset; |
2313 | 2418 | ||
2314 | if (!reset) { | 2419 | if (!reset) { |
2315 | ata_link_printk(link, KERN_ERR, | 2420 | ata_link_printk(link, KERN_ERR, |
2316 | "follow-up softreset required " | 2421 | "follow-up softreset required " |
2317 | "but no softreset avaliable\n"); | 2422 | "but no softreset avaliable\n"); |
2423 | failed_link = link; | ||
2318 | rc = -EINVAL; | 2424 | rc = -EINVAL; |
2319 | goto fail; | 2425 | goto fail; |
2320 | } | 2426 | } |
2321 | 2427 | ||
2322 | ata_eh_about_to_do(link, NULL, ATA_EH_RESET); | 2428 | ata_eh_about_to_do(link, NULL, ATA_EH_RESET); |
2323 | rc = ata_do_reset(link, reset, classes, deadline); | 2429 | rc = ata_do_reset(link, reset, classes, deadline, true); |
2324 | } | 2430 | } |
2325 | } else { | 2431 | } else { |
2326 | if (verbose) | 2432 | if (verbose) |
@@ -2341,7 +2447,7 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2341 | dev->pio_mode = XFER_PIO_0; | 2447 | dev->pio_mode = XFER_PIO_0; |
2342 | dev->flags &= ~ATA_DFLAG_SLEEPING; | 2448 | dev->flags &= ~ATA_DFLAG_SLEEPING; |
2343 | 2449 | ||
2344 | if (ata_link_offline(link)) | 2450 | if (ata_phys_link_offline(ata_dev_phys_link(dev))) |
2345 | continue; | 2451 | continue; |
2346 | 2452 | ||
2347 | /* apply class override */ | 2453 | /* apply class override */ |
@@ -2354,6 +2460,8 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2354 | /* record current link speed */ | 2460 | /* record current link speed */ |
2355 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) | 2461 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) |
2356 | link->sata_spd = (sstatus >> 4) & 0xf; | 2462 | link->sata_spd = (sstatus >> 4) & 0xf; |
2463 | if (slave && sata_scr_read(slave, SCR_STATUS, &sstatus) == 0) | ||
2464 | slave->sata_spd = (sstatus >> 4) & 0xf; | ||
2357 | 2465 | ||
2358 | /* thaw the port */ | 2466 | /* thaw the port */ |
2359 | if (ata_is_host_link(link)) | 2467 | if (ata_is_host_link(link)) |
@@ -2366,12 +2474,17 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2366 | * reset and here. This race is mediated by cross checking | 2474 | * reset and here. This race is mediated by cross checking |
2367 | * link onlineness and classification result later. | 2475 | * link onlineness and classification result later. |
2368 | */ | 2476 | */ |
2369 | if (postreset) | 2477 | if (postreset) { |
2370 | postreset(link, classes); | 2478 | postreset(link, classes); |
2479 | if (slave) | ||
2480 | postreset(slave, classes); | ||
2481 | } | ||
2371 | 2482 | ||
2372 | /* clear cached SError */ | 2483 | /* clear cached SError */ |
2373 | spin_lock_irqsave(link->ap->lock, flags); | 2484 | spin_lock_irqsave(link->ap->lock, flags); |
2374 | link->eh_info.serror = 0; | 2485 | link->eh_info.serror = 0; |
2486 | if (slave) | ||
2487 | slave->eh_info.serror = 0; | ||
2375 | spin_unlock_irqrestore(link->ap->lock, flags); | 2488 | spin_unlock_irqrestore(link->ap->lock, flags); |
2376 | 2489 | ||
2377 | /* Make sure onlineness and classification result correspond. | 2490 | /* Make sure onlineness and classification result correspond. |
@@ -2381,19 +2494,21 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2381 | * link onlineness and classification result, those conditions | 2494 | * link onlineness and classification result, those conditions |
2382 | * can be reliably detected and retried. | 2495 | * can be reliably detected and retried. |
2383 | */ | 2496 | */ |
2384 | nr_known = 0; | 2497 | nr_unknown = 0; |
2385 | ata_link_for_each_dev(dev, link) { | 2498 | ata_link_for_each_dev(dev, link) { |
2386 | /* convert all ATA_DEV_UNKNOWN to ATA_DEV_NONE */ | 2499 | /* convert all ATA_DEV_UNKNOWN to ATA_DEV_NONE */ |
2387 | if (classes[dev->devno] == ATA_DEV_UNKNOWN) | 2500 | if (classes[dev->devno] == ATA_DEV_UNKNOWN) { |
2388 | classes[dev->devno] = ATA_DEV_NONE; | 2501 | classes[dev->devno] = ATA_DEV_NONE; |
2389 | else | 2502 | if (ata_phys_link_online(ata_dev_phys_link(dev))) |
2390 | nr_known++; | 2503 | nr_unknown++; |
2504 | } | ||
2391 | } | 2505 | } |
2392 | 2506 | ||
2393 | if (classify && !nr_known && ata_link_online(link)) { | 2507 | if (classify && nr_unknown) { |
2394 | if (try < max_tries) { | 2508 | if (try < max_tries) { |
2395 | ata_link_printk(link, KERN_WARNING, "link online but " | 2509 | ata_link_printk(link, KERN_WARNING, "link online but " |
2396 | "device misclassified, retrying\n"); | 2510 | "device misclassified, retrying\n"); |
2511 | failed_link = link; | ||
2397 | rc = -EAGAIN; | 2512 | rc = -EAGAIN; |
2398 | goto fail; | 2513 | goto fail; |
2399 | } | 2514 | } |
@@ -2404,6 +2519,8 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2404 | 2519 | ||
2405 | /* reset successful, schedule revalidation */ | 2520 | /* reset successful, schedule revalidation */ |
2406 | ata_eh_done(link, NULL, ATA_EH_RESET); | 2521 | ata_eh_done(link, NULL, ATA_EH_RESET); |
2522 | if (slave) | ||
2523 | ata_eh_done(slave, NULL, ATA_EH_RESET); | ||
2407 | ehc->last_reset = jiffies; | 2524 | ehc->last_reset = jiffies; |
2408 | ehc->i.action |= ATA_EH_REVALIDATE; | 2525 | ehc->i.action |= ATA_EH_REVALIDATE; |
2409 | 2526 | ||
@@ -2411,6 +2528,8 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2411 | out: | 2528 | out: |
2412 | /* clear hotplug flag */ | 2529 | /* clear hotplug flag */ |
2413 | ehc->i.flags &= ~ATA_EHI_HOTPLUGGED; | 2530 | ehc->i.flags &= ~ATA_EHI_HOTPLUGGED; |
2531 | if (slave) | ||
2532 | sehc->i.flags &= ~ATA_EHI_HOTPLUGGED; | ||
2414 | 2533 | ||
2415 | spin_lock_irqsave(ap->lock, flags); | 2534 | spin_lock_irqsave(ap->lock, flags); |
2416 | ap->pflags &= ~ATA_PFLAG_RESETTING; | 2535 | ap->pflags &= ~ATA_PFLAG_RESETTING; |
@@ -2431,7 +2550,7 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2431 | if (time_before(now, deadline)) { | 2550 | if (time_before(now, deadline)) { |
2432 | unsigned long delta = deadline - now; | 2551 | unsigned long delta = deadline - now; |
2433 | 2552 | ||
2434 | ata_link_printk(link, KERN_WARNING, | 2553 | ata_link_printk(failed_link, KERN_WARNING, |
2435 | "reset failed (errno=%d), retrying in %u secs\n", | 2554 | "reset failed (errno=%d), retrying in %u secs\n", |
2436 | rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); | 2555 | rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); |
2437 | 2556 | ||
@@ -2439,13 +2558,92 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2439 | delta = schedule_timeout_uninterruptible(delta); | 2558 | delta = schedule_timeout_uninterruptible(delta); |
2440 | } | 2559 | } |
2441 | 2560 | ||
2442 | if (rc == -EPIPE || try == max_tries - 1) | 2561 | if (try == max_tries - 1) { |
2443 | sata_down_spd_limit(link); | 2562 | sata_down_spd_limit(link); |
2563 | if (slave) | ||
2564 | sata_down_spd_limit(slave); | ||
2565 | } else if (rc == -EPIPE) | ||
2566 | sata_down_spd_limit(failed_link); | ||
2567 | |||
2444 | if (hardreset) | 2568 | if (hardreset) |
2445 | reset = hardreset; | 2569 | reset = hardreset; |
2446 | goto retry; | 2570 | goto retry; |
2447 | } | 2571 | } |
2448 | 2572 | ||
2573 | static inline void ata_eh_pull_park_action(struct ata_port *ap) | ||
2574 | { | ||
2575 | struct ata_link *link; | ||
2576 | struct ata_device *dev; | ||
2577 | unsigned long flags; | ||
2578 | |||
2579 | /* | ||
2580 | * This function can be thought of as an extended version of | ||
2581 | * ata_eh_about_to_do() specially crafted to accommodate the | ||
2582 | * requirements of ATA_EH_PARK handling. Since the EH thread | ||
2583 | * does not leave the do {} while () loop in ata_eh_recover as | ||
2584 | * long as the timeout for a park request to *one* device on | ||
2585 | * the port has not expired, and since we still want to pick | ||
2586 | * up park requests to other devices on the same port or | ||
2587 | * timeout updates for the same device, we have to pull | ||
2588 | * ATA_EH_PARK actions from eh_info into eh_context.i | ||
2589 | * ourselves at the beginning of each pass over the loop. | ||
2590 | * | ||
2591 | * Additionally, all write accesses to &ap->park_req_pending | ||
2592 | * through INIT_COMPLETION() (see below) or complete_all() | ||
2593 | * (see ata_scsi_park_store()) are protected by the host lock. | ||
2594 | * As a result we have that park_req_pending.done is zero on | ||
2595 | * exit from this function, i.e. when ATA_EH_PARK actions for | ||
2596 | * *all* devices on port ap have been pulled into the | ||
2597 | * respective eh_context structs. If, and only if, | ||
2598 | * park_req_pending.done is non-zero by the time we reach | ||
2599 | * wait_for_completion_timeout(), another ATA_EH_PARK action | ||
2600 | * has been scheduled for at least one of the devices on port | ||
2601 | * ap and we have to cycle over the do {} while () loop in | ||
2602 | * ata_eh_recover() again. | ||
2603 | */ | ||
2604 | |||
2605 | spin_lock_irqsave(ap->lock, flags); | ||
2606 | INIT_COMPLETION(ap->park_req_pending); | ||
2607 | ata_port_for_each_link(link, ap) { | ||
2608 | ata_link_for_each_dev(dev, link) { | ||
2609 | struct ata_eh_info *ehi = &link->eh_info; | ||
2610 | |||
2611 | link->eh_context.i.dev_action[dev->devno] |= | ||
2612 | ehi->dev_action[dev->devno] & ATA_EH_PARK; | ||
2613 | ata_eh_clear_action(link, dev, ehi, ATA_EH_PARK); | ||
2614 | } | ||
2615 | } | ||
2616 | spin_unlock_irqrestore(ap->lock, flags); | ||
2617 | } | ||
2618 | |||
2619 | static void ata_eh_park_issue_cmd(struct ata_device *dev, int park) | ||
2620 | { | ||
2621 | struct ata_eh_context *ehc = &dev->link->eh_context; | ||
2622 | struct ata_taskfile tf; | ||
2623 | unsigned int err_mask; | ||
2624 | |||
2625 | ata_tf_init(dev, &tf); | ||
2626 | if (park) { | ||
2627 | ehc->unloaded_mask |= 1 << dev->devno; | ||
2628 | tf.command = ATA_CMD_IDLEIMMEDIATE; | ||
2629 | tf.feature = 0x44; | ||
2630 | tf.lbal = 0x4c; | ||
2631 | tf.lbam = 0x4e; | ||
2632 | tf.lbah = 0x55; | ||
2633 | } else { | ||
2634 | ehc->unloaded_mask &= ~(1 << dev->devno); | ||
2635 | tf.command = ATA_CMD_CHK_POWER; | ||
2636 | } | ||
2637 | |||
2638 | tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; | ||
2639 | tf.protocol |= ATA_PROT_NODATA; | ||
2640 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); | ||
2641 | if (park && (err_mask || tf.lbal != 0xc4)) { | ||
2642 | ata_dev_printk(dev, KERN_ERR, "head unload failed!\n"); | ||
2643 | ehc->unloaded_mask &= ~(1 << dev->devno); | ||
2644 | } | ||
2645 | } | ||
2646 | |||
2449 | static int ata_eh_revalidate_and_attach(struct ata_link *link, | 2647 | static int ata_eh_revalidate_and_attach(struct ata_link *link, |
2450 | struct ata_device **r_failed_dev) | 2648 | struct ata_device **r_failed_dev) |
2451 | { | 2649 | { |
@@ -2472,7 +2670,7 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link, | |||
2472 | if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { | 2670 | if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { |
2473 | WARN_ON(dev->class == ATA_DEV_PMP); | 2671 | WARN_ON(dev->class == ATA_DEV_PMP); |
2474 | 2672 | ||
2475 | if (ata_link_offline(link)) { | 2673 | if (ata_phys_link_offline(ata_dev_phys_link(dev))) { |
2476 | rc = -EIO; | 2674 | rc = -EIO; |
2477 | goto err; | 2675 | goto err; |
2478 | } | 2676 | } |
@@ -2610,6 +2808,53 @@ int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
2610 | return rc; | 2808 | return rc; |
2611 | } | 2809 | } |
2612 | 2810 | ||
2811 | /** | ||
2812 | * atapi_eh_clear_ua - Clear ATAPI UNIT ATTENTION after reset | ||
2813 | * @dev: ATAPI device to clear UA for | ||
2814 | * | ||
2815 | * Resets and other operations can make an ATAPI device raise | ||
2816 | * UNIT ATTENTION which causes the next operation to fail. This | ||
2817 | * function clears UA. | ||
2818 | * | ||
2819 | * LOCKING: | ||
2820 | * EH context (may sleep). | ||
2821 | * | ||
2822 | * RETURNS: | ||
2823 | * 0 on success, -errno on failure. | ||
2824 | */ | ||
2825 | static int atapi_eh_clear_ua(struct ata_device *dev) | ||
2826 | { | ||
2827 | int i; | ||
2828 | |||
2829 | for (i = 0; i < ATA_EH_UA_TRIES; i++) { | ||
2830 | u8 sense_buffer[SCSI_SENSE_BUFFERSIZE]; | ||
2831 | u8 sense_key = 0; | ||
2832 | unsigned int err_mask; | ||
2833 | |||
2834 | err_mask = atapi_eh_tur(dev, &sense_key); | ||
2835 | if (err_mask != 0 && err_mask != AC_ERR_DEV) { | ||
2836 | ata_dev_printk(dev, KERN_WARNING, "TEST_UNIT_READY " | ||
2837 | "failed (err_mask=0x%x)\n", err_mask); | ||
2838 | return -EIO; | ||
2839 | } | ||
2840 | |||
2841 | if (!err_mask || sense_key != UNIT_ATTENTION) | ||
2842 | return 0; | ||
2843 | |||
2844 | err_mask = atapi_eh_request_sense(dev, sense_buffer, sense_key); | ||
2845 | if (err_mask) { | ||
2846 | ata_dev_printk(dev, KERN_WARNING, "failed to clear " | ||
2847 | "UNIT ATTENTION (err_mask=0x%x)\n", err_mask); | ||
2848 | return -EIO; | ||
2849 | } | ||
2850 | } | ||
2851 | |||
2852 | ata_dev_printk(dev, KERN_WARNING, | ||
2853 | "UNIT ATTENTION persists after %d tries\n", ATA_EH_UA_TRIES); | ||
2854 | |||
2855 | return 0; | ||
2856 | } | ||
2857 | |||
2613 | static int ata_link_nr_enabled(struct ata_link *link) | 2858 | static int ata_link_nr_enabled(struct ata_link *link) |
2614 | { | 2859 | { |
2615 | struct ata_device *dev; | 2860 | struct ata_device *dev; |
@@ -2697,7 +2942,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) | |||
2697 | /* This is the last chance, better to slow | 2942 | /* This is the last chance, better to slow |
2698 | * down than lose it. | 2943 | * down than lose it. |
2699 | */ | 2944 | */ |
2700 | sata_down_spd_limit(dev->link); | 2945 | sata_down_spd_limit(ata_dev_phys_link(dev)); |
2701 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); | 2946 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); |
2702 | } | 2947 | } |
2703 | } | 2948 | } |
@@ -2707,7 +2952,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) | |||
2707 | ata_dev_disable(dev); | 2952 | ata_dev_disable(dev); |
2708 | 2953 | ||
2709 | /* detach if offline */ | 2954 | /* detach if offline */ |
2710 | if (ata_link_offline(dev->link)) | 2955 | if (ata_phys_link_offline(ata_dev_phys_link(dev))) |
2711 | ata_eh_detach_dev(dev); | 2956 | ata_eh_detach_dev(dev); |
2712 | 2957 | ||
2713 | /* schedule probe if necessary */ | 2958 | /* schedule probe if necessary */ |
@@ -2755,7 +3000,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2755 | struct ata_device *dev; | 3000 | struct ata_device *dev; |
2756 | int nr_failed_devs; | 3001 | int nr_failed_devs; |
2757 | int rc; | 3002 | int rc; |
2758 | unsigned long flags; | 3003 | unsigned long flags, deadline; |
2759 | 3004 | ||
2760 | DPRINTK("ENTER\n"); | 3005 | DPRINTK("ENTER\n"); |
2761 | 3006 | ||
@@ -2829,6 +3074,56 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2829 | } | 3074 | } |
2830 | } | 3075 | } |
2831 | 3076 | ||
3077 | do { | ||
3078 | unsigned long now; | ||
3079 | |||
3080 | /* | ||
3081 | * clears ATA_EH_PARK in eh_info and resets | ||
3082 | * ap->park_req_pending | ||
3083 | */ | ||
3084 | ata_eh_pull_park_action(ap); | ||
3085 | |||
3086 | deadline = jiffies; | ||
3087 | ata_port_for_each_link(link, ap) { | ||
3088 | ata_link_for_each_dev(dev, link) { | ||
3089 | struct ata_eh_context *ehc = &link->eh_context; | ||
3090 | unsigned long tmp; | ||
3091 | |||
3092 | if (dev->class != ATA_DEV_ATA) | ||
3093 | continue; | ||
3094 | if (!(ehc->i.dev_action[dev->devno] & | ||
3095 | ATA_EH_PARK)) | ||
3096 | continue; | ||
3097 | tmp = dev->unpark_deadline; | ||
3098 | if (time_before(deadline, tmp)) | ||
3099 | deadline = tmp; | ||
3100 | else if (time_before_eq(tmp, jiffies)) | ||
3101 | continue; | ||
3102 | if (ehc->unloaded_mask & (1 << dev->devno)) | ||
3103 | continue; | ||
3104 | |||
3105 | ata_eh_park_issue_cmd(dev, 1); | ||
3106 | } | ||
3107 | } | ||
3108 | |||
3109 | now = jiffies; | ||
3110 | if (time_before_eq(deadline, now)) | ||
3111 | break; | ||
3112 | |||
3113 | deadline = wait_for_completion_timeout(&ap->park_req_pending, | ||
3114 | deadline - now); | ||
3115 | } while (deadline); | ||
3116 | ata_port_for_each_link(link, ap) { | ||
3117 | ata_link_for_each_dev(dev, link) { | ||
3118 | if (!(link->eh_context.unloaded_mask & | ||
3119 | (1 << dev->devno))) | ||
3120 | continue; | ||
3121 | |||
3122 | ata_eh_park_issue_cmd(dev, 0); | ||
3123 | ata_eh_done(link, dev, ATA_EH_PARK); | ||
3124 | } | ||
3125 | } | ||
3126 | |||
2832 | /* the rest */ | 3127 | /* the rest */ |
2833 | ata_port_for_each_link(link, ap) { | 3128 | ata_port_for_each_link(link, ap) { |
2834 | struct ata_eh_context *ehc = &link->eh_context; | 3129 | struct ata_eh_context *ehc = &link->eh_context; |
@@ -2852,6 +3147,20 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2852 | ehc->i.flags &= ~ATA_EHI_SETMODE; | 3147 | ehc->i.flags &= ~ATA_EHI_SETMODE; |
2853 | } | 3148 | } |
2854 | 3149 | ||
3150 | /* If reset has been issued, clear UA to avoid | ||
3151 | * disrupting the current users of the device. | ||
3152 | */ | ||
3153 | if (ehc->i.flags & ATA_EHI_DID_RESET) { | ||
3154 | ata_link_for_each_dev(dev, link) { | ||
3155 | if (dev->class != ATA_DEV_ATAPI) | ||
3156 | continue; | ||
3157 | rc = atapi_eh_clear_ua(dev); | ||
3158 | if (rc) | ||
3159 | goto dev_fail; | ||
3160 | } | ||
3161 | } | ||
3162 | |||
3163 | /* configure link power saving */ | ||
2855 | if (ehc->i.action & ATA_EH_LPM) | 3164 | if (ehc->i.action & ATA_EH_LPM) |
2856 | ata_link_for_each_dev(dev, link) | 3165 | ata_link_for_each_dev(dev, link) |
2857 | ata_dev_enable_pm(dev, ap->pm_policy); | 3166 | ata_dev_enable_pm(dev, ap->pm_policy); |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index b9d3ba423cb2..5d312dc9be9f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -183,6 +183,105 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, | |||
183 | ata_scsi_lpm_show, ata_scsi_lpm_put); | 183 | ata_scsi_lpm_show, ata_scsi_lpm_put); |
184 | EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); | 184 | EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); |
185 | 185 | ||
186 | static ssize_t ata_scsi_park_show(struct device *device, | ||
187 | struct device_attribute *attr, char *buf) | ||
188 | { | ||
189 | struct scsi_device *sdev = to_scsi_device(device); | ||
190 | struct ata_port *ap; | ||
191 | struct ata_link *link; | ||
192 | struct ata_device *dev; | ||
193 | unsigned long flags; | ||
194 | unsigned int uninitialized_var(msecs); | ||
195 | int rc = 0; | ||
196 | |||
197 | ap = ata_shost_to_port(sdev->host); | ||
198 | |||
199 | spin_lock_irqsave(ap->lock, flags); | ||
200 | dev = ata_scsi_find_dev(ap, sdev); | ||
201 | if (!dev) { | ||
202 | rc = -ENODEV; | ||
203 | goto unlock; | ||
204 | } | ||
205 | if (dev->flags & ATA_DFLAG_NO_UNLOAD) { | ||
206 | rc = -EOPNOTSUPP; | ||
207 | goto unlock; | ||
208 | } | ||
209 | |||
210 | link = dev->link; | ||
211 | if (ap->pflags & ATA_PFLAG_EH_IN_PROGRESS && | ||
212 | link->eh_context.unloaded_mask & (1 << dev->devno) && | ||
213 | time_after(dev->unpark_deadline, jiffies)) | ||
214 | msecs = jiffies_to_msecs(dev->unpark_deadline - jiffies); | ||
215 | else | ||
216 | msecs = 0; | ||
217 | |||
218 | unlock: | ||
219 | spin_unlock_irq(ap->lock); | ||
220 | |||
221 | return rc ? rc : snprintf(buf, 20, "%u\n", msecs); | ||
222 | } | ||
223 | |||
224 | static ssize_t ata_scsi_park_store(struct device *device, | ||
225 | struct device_attribute *attr, | ||
226 | const char *buf, size_t len) | ||
227 | { | ||
228 | struct scsi_device *sdev = to_scsi_device(device); | ||
229 | struct ata_port *ap; | ||
230 | struct ata_device *dev; | ||
231 | long int input; | ||
232 | unsigned long flags; | ||
233 | int rc; | ||
234 | |||
235 | rc = strict_strtol(buf, 10, &input); | ||
236 | if (rc || input < -2) | ||
237 | return -EINVAL; | ||
238 | if (input > ATA_TMOUT_MAX_PARK) { | ||
239 | rc = -EOVERFLOW; | ||
240 | input = ATA_TMOUT_MAX_PARK; | ||
241 | } | ||
242 | |||
243 | ap = ata_shost_to_port(sdev->host); | ||
244 | |||
245 | spin_lock_irqsave(ap->lock, flags); | ||
246 | dev = ata_scsi_find_dev(ap, sdev); | ||
247 | if (unlikely(!dev)) { | ||
248 | rc = -ENODEV; | ||
249 | goto unlock; | ||
250 | } | ||
251 | if (dev->class != ATA_DEV_ATA) { | ||
252 | rc = -EOPNOTSUPP; | ||
253 | goto unlock; | ||
254 | } | ||
255 | |||
256 | if (input >= 0) { | ||
257 | if (dev->flags & ATA_DFLAG_NO_UNLOAD) { | ||
258 | rc = -EOPNOTSUPP; | ||
259 | goto unlock; | ||
260 | } | ||
261 | |||
262 | dev->unpark_deadline = ata_deadline(jiffies, input); | ||
263 | dev->link->eh_info.dev_action[dev->devno] |= ATA_EH_PARK; | ||
264 | ata_port_schedule_eh(ap); | ||
265 | complete(&ap->park_req_pending); | ||
266 | } else { | ||
267 | switch (input) { | ||
268 | case -1: | ||
269 | dev->flags &= ~ATA_DFLAG_NO_UNLOAD; | ||
270 | break; | ||
271 | case -2: | ||
272 | dev->flags |= ATA_DFLAG_NO_UNLOAD; | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | unlock: | ||
277 | spin_unlock_irqrestore(ap->lock, flags); | ||
278 | |||
279 | return rc ? rc : len; | ||
280 | } | ||
281 | DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR, | ||
282 | ata_scsi_park_show, ata_scsi_park_store); | ||
283 | EXPORT_SYMBOL_GPL(dev_attr_unload_heads); | ||
284 | |||
186 | static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) | 285 | static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) |
187 | { | 286 | { |
188 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | 287 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; |
@@ -269,6 +368,12 @@ DEVICE_ATTR(sw_activity, S_IWUGO | S_IRUGO, ata_scsi_activity_show, | |||
269 | ata_scsi_activity_store); | 368 | ata_scsi_activity_store); |
270 | EXPORT_SYMBOL_GPL(dev_attr_sw_activity); | 369 | EXPORT_SYMBOL_GPL(dev_attr_sw_activity); |
271 | 370 | ||
371 | struct device_attribute *ata_common_sdev_attrs[] = { | ||
372 | &dev_attr_unload_heads, | ||
373 | NULL | ||
374 | }; | ||
375 | EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); | ||
376 | |||
272 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, | 377 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, |
273 | void (*done)(struct scsi_cmnd *)) | 378 | void (*done)(struct scsi_cmnd *)) |
274 | { | 379 | { |
@@ -398,7 +503,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
398 | scsi_cmd[0] = ATA_16; | 503 | scsi_cmd[0] = ATA_16; |
399 | 504 | ||
400 | scsi_cmd[4] = args[2]; | 505 | scsi_cmd[4] = args[2]; |
401 | if (args[0] == WIN_SMART) { /* hack -- ide driver does this too... */ | 506 | if (args[0] == ATA_CMD_SMART) { /* hack -- ide driver does this too */ |
402 | scsi_cmd[6] = args[3]; | 507 | scsi_cmd[6] = args[3]; |
403 | scsi_cmd[8] = args[1]; | 508 | scsi_cmd[8] = args[1]; |
404 | scsi_cmd[10] = 0x4f; | 509 | scsi_cmd[10] = 0x4f; |
@@ -954,6 +1059,9 @@ static int atapi_drain_needed(struct request *rq) | |||
954 | static int ata_scsi_dev_config(struct scsi_device *sdev, | 1059 | static int ata_scsi_dev_config(struct scsi_device *sdev, |
955 | struct ata_device *dev) | 1060 | struct ata_device *dev) |
956 | { | 1061 | { |
1062 | if (!ata_id_has_unload(dev->id)) | ||
1063 | dev->flags |= ATA_DFLAG_NO_UNLOAD; | ||
1064 | |||
957 | /* configure max sectors */ | 1065 | /* configure max sectors */ |
958 | blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); | 1066 | blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); |
959 | 1067 | ||
@@ -977,6 +1085,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev, | |||
977 | 1085 | ||
978 | blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); | 1086 | blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); |
979 | } else { | 1087 | } else { |
1088 | if (ata_id_is_ssd(dev->id)) | ||
1089 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, | ||
1090 | sdev->request_queue); | ||
1091 | |||
980 | /* ATA devices must be sector aligned */ | 1092 | /* ATA devices must be sector aligned */ |
981 | blk_queue_update_dma_alignment(sdev->request_queue, | 1093 | blk_queue_update_dma_alignment(sdev->request_queue, |
982 | ATA_SECT_SIZE - 1); | 1094 | ATA_SECT_SIZE - 1); |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index ade5c75b6144..fe2839e58774 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -70,6 +70,7 @@ extern int atapi_passthru16; | |||
70 | extern int libata_fua; | 70 | extern int libata_fua; |
71 | extern int libata_noacpi; | 71 | extern int libata_noacpi; |
72 | extern int libata_allow_tpm; | 72 | extern int libata_allow_tpm; |
73 | extern struct ata_link *ata_dev_phys_link(struct ata_device *dev); | ||
73 | extern void ata_force_cbl(struct ata_port *ap); | 74 | extern void ata_force_cbl(struct ata_port *ap); |
74 | extern u64 ata_tf_to_lba(const struct ata_taskfile *tf); | 75 | extern u64 ata_tf_to_lba(const struct ata_taskfile *tf); |
75 | extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf); | 76 | extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf); |
@@ -107,6 +108,8 @@ extern void ata_qc_issue(struct ata_queued_cmd *qc); | |||
107 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 108 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); |
108 | extern int atapi_check_dma(struct ata_queued_cmd *qc); | 109 | extern int atapi_check_dma(struct ata_queued_cmd *qc); |
109 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); | 110 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); |
111 | extern bool ata_phys_link_online(struct ata_link *link); | ||
112 | extern bool ata_phys_link_offline(struct ata_link *link); | ||
110 | extern void ata_dev_init(struct ata_device *dev); | 113 | extern void ata_dev_init(struct ata_device *dev); |
111 | extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp); | 114 | extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp); |
112 | extern int sata_link_init_spd(struct ata_link *link); | 115 | extern int sata_link_init_spd(struct ata_link *link); |
@@ -152,7 +155,7 @@ extern int ata_bus_probe(struct ata_port *ap); | |||
152 | /* libata-eh.c */ | 155 | /* libata-eh.c */ |
153 | extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd); | 156 | extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd); |
154 | extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd); | 157 | extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd); |
155 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | 158 | extern enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); |
156 | extern void ata_scsi_error(struct Scsi_Host *host); | 159 | extern void ata_scsi_error(struct Scsi_Host *host); |
157 | extern void ata_port_wait_eh(struct ata_port *ap); | 160 | extern void ata_port_wait_eh(struct ata_port *ap); |
158 | extern void ata_eh_fastdrain_timerfn(unsigned long arg); | 161 | extern void ata_eh_fastdrain_timerfn(unsigned long arg); |
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c index d3932901a3b3..1266924c11f9 100644 --- a/drivers/ata/pata_bf54x.c +++ b/drivers/ata/pata_bf54x.c | |||
@@ -1632,6 +1632,8 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev) | |||
1632 | return -ENODEV; | 1632 | return -ENODEV; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | dev_set_drvdata(&pdev->dev, host); | ||
1636 | |||
1635 | return 0; | 1637 | return 0; |
1636 | } | 1638 | } |
1637 | 1639 | ||
@@ -1648,6 +1650,7 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev) | |||
1648 | struct ata_host *host = dev_get_drvdata(dev); | 1650 | struct ata_host *host = dev_get_drvdata(dev); |
1649 | 1651 | ||
1650 | ata_host_detach(host); | 1652 | ata_host_detach(host); |
1653 | dev_set_drvdata(&pdev->dev, NULL); | ||
1651 | 1654 | ||
1652 | peripheral_free_list(atapi_io_port); | 1655 | peripheral_free_list(atapi_io_port); |
1653 | 1656 | ||
@@ -1655,27 +1658,44 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev) | |||
1655 | } | 1658 | } |
1656 | 1659 | ||
1657 | #ifdef CONFIG_PM | 1660 | #ifdef CONFIG_PM |
1658 | int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state) | 1661 | static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state) |
1659 | { | 1662 | { |
1660 | return 0; | 1663 | struct ata_host *host = dev_get_drvdata(&pdev->dev); |
1664 | if (host) | ||
1665 | return ata_host_suspend(host, state); | ||
1666 | else | ||
1667 | return 0; | ||
1661 | } | 1668 | } |
1662 | 1669 | ||
1663 | int bfin_atapi_resume(struct platform_device *pdev) | 1670 | static int bfin_atapi_resume(struct platform_device *pdev) |
1664 | { | 1671 | { |
1672 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
1673 | int ret; | ||
1674 | |||
1675 | if (host) { | ||
1676 | ret = bfin_reset_controller(host); | ||
1677 | if (ret) { | ||
1678 | printk(KERN_ERR DRV_NAME ": Error during HW init\n"); | ||
1679 | return ret; | ||
1680 | } | ||
1681 | ata_host_resume(host); | ||
1682 | } | ||
1683 | |||
1665 | return 0; | 1684 | return 0; |
1666 | } | 1685 | } |
1686 | #else | ||
1687 | #define bfin_atapi_suspend NULL | ||
1688 | #define bfin_atapi_resume NULL | ||
1667 | #endif | 1689 | #endif |
1668 | 1690 | ||
1669 | static struct platform_driver bfin_atapi_driver = { | 1691 | static struct platform_driver bfin_atapi_driver = { |
1670 | .probe = bfin_atapi_probe, | 1692 | .probe = bfin_atapi_probe, |
1671 | .remove = __devexit_p(bfin_atapi_remove), | 1693 | .remove = __devexit_p(bfin_atapi_remove), |
1694 | .suspend = bfin_atapi_suspend, | ||
1695 | .resume = bfin_atapi_resume, | ||
1672 | .driver = { | 1696 | .driver = { |
1673 | .name = DRV_NAME, | 1697 | .name = DRV_NAME, |
1674 | .owner = THIS_MODULE, | 1698 | .owner = THIS_MODULE, |
1675 | #ifdef CONFIG_PM | ||
1676 | .suspend = bfin_atapi_suspend, | ||
1677 | .resume = bfin_atapi_resume, | ||
1678 | #endif | ||
1679 | }, | 1699 | }, |
1680 | }; | 1700 | }; |
1681 | 1701 | ||
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c index 408da30594c4..1f18ad9e4fe1 100644 --- a/drivers/ata/pata_of_platform.c +++ b/drivers/ata/pata_of_platform.c | |||
@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev, | |||
52 | 52 | ||
53 | ret = of_irq_to_resource(dn, 0, &irq_res); | 53 | ret = of_irq_to_resource(dn, 0, &irq_res); |
54 | if (ret == NO_IRQ) | 54 | if (ret == NO_IRQ) |
55 | irq_res.start = irq_res.end = -1; | 55 | irq_res.start = irq_res.end = 0; |
56 | else | 56 | else |
57 | irq_res.flags = 0; | 57 | irq_res.flags = 0; |
58 | 58 | ||
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 41b4361bbf6e..02b596b9cf6a 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -148,6 +148,64 @@ static struct ata_port_operations pcmcia_8bit_port_ops = { | |||
148 | #define CS_CHECK(fn, ret) \ | 148 | #define CS_CHECK(fn, ret) \ |
149 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 149 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
150 | 150 | ||
151 | |||
152 | struct pcmcia_config_check { | ||
153 | unsigned long ctl_base; | ||
154 | int skip_vcc; | ||
155 | int is_kme; | ||
156 | }; | ||
157 | |||
158 | static int pcmcia_check_one_config(struct pcmcia_device *pdev, | ||
159 | cistpl_cftable_entry_t *cfg, | ||
160 | cistpl_cftable_entry_t *dflt, | ||
161 | unsigned int vcc, | ||
162 | void *priv_data) | ||
163 | { | ||
164 | struct pcmcia_config_check *stk = priv_data; | ||
165 | |||
166 | /* Check for matching Vcc, unless we're desperate */ | ||
167 | if (!stk->skip_vcc) { | ||
168 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
169 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
170 | return -ENODEV; | ||
171 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
172 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
173 | return -ENODEV; | ||
174 | } | ||
175 | } | ||
176 | |||
177 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
178 | pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
179 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
180 | pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
181 | |||
182 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
183 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
184 | pdev->io.BasePort1 = io->win[0].base; | ||
185 | pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
186 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
187 | pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
188 | if (io->nwin == 2) { | ||
189 | pdev->io.NumPorts1 = 8; | ||
190 | pdev->io.BasePort2 = io->win[1].base; | ||
191 | pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; | ||
192 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
193 | return -ENODEV; | ||
194 | stk->ctl_base = pdev->io.BasePort2; | ||
195 | } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { | ||
196 | pdev->io.NumPorts1 = io->win[0].len; | ||
197 | pdev->io.NumPorts2 = 0; | ||
198 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
199 | return -ENODEV; | ||
200 | stk->ctl_base = pdev->io.BasePort1 + 0x0e; | ||
201 | } else | ||
202 | return -ENODEV; | ||
203 | /* If we've got this far, we're done */ | ||
204 | return 0; | ||
205 | } | ||
206 | return -ENODEV; | ||
207 | } | ||
208 | |||
151 | /** | 209 | /** |
152 | * pcmcia_init_one - attach a PCMCIA interface | 210 | * pcmcia_init_one - attach a PCMCIA interface |
153 | * @pdev: pcmcia device | 211 | * @pdev: pcmcia device |
@@ -161,19 +219,11 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) | |||
161 | struct ata_host *host; | 219 | struct ata_host *host; |
162 | struct ata_port *ap; | 220 | struct ata_port *ap; |
163 | struct ata_pcmcia_info *info; | 221 | struct ata_pcmcia_info *info; |
164 | tuple_t tuple; | 222 | struct pcmcia_config_check *stk = NULL; |
165 | struct { | 223 | int last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p; |
166 | unsigned short buf[128]; | ||
167 | cisparse_t parse; | ||
168 | config_info_t conf; | ||
169 | cistpl_cftable_entry_t dflt; | ||
170 | } *stk = NULL; | ||
171 | cistpl_cftable_entry_t *cfg; | ||
172 | int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p; | ||
173 | unsigned long io_base, ctl_base; | 224 | unsigned long io_base, ctl_base; |
174 | void __iomem *io_addr, *ctl_addr; | 225 | void __iomem *io_addr, *ctl_addr; |
175 | int n_ports = 1; | 226 | int n_ports = 1; |
176 | |||
177 | struct ata_port_operations *ops = &pcmcia_port_ops; | 227 | struct ata_port_operations *ops = &pcmcia_port_ops; |
178 | 228 | ||
179 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 229 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
@@ -193,96 +243,27 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) | |||
193 | pdev->conf.Attributes = CONF_ENABLE_IRQ; | 243 | pdev->conf.Attributes = CONF_ENABLE_IRQ; |
194 | pdev->conf.IntType = INT_MEMORY_AND_IO; | 244 | pdev->conf.IntType = INT_MEMORY_AND_IO; |
195 | 245 | ||
196 | /* Allocate resoure probing structures */ | ||
197 | |||
198 | stk = kzalloc(sizeof(*stk), GFP_KERNEL); | ||
199 | if (!stk) | ||
200 | goto out1; | ||
201 | |||
202 | cfg = &stk->parse.cftable_entry; | ||
203 | |||
204 | /* Tuples we are walking */ | ||
205 | tuple.TupleData = (cisdata_t *)&stk->buf; | ||
206 | tuple.TupleOffset = 0; | ||
207 | tuple.TupleDataMax = 255; | ||
208 | tuple.Attributes = 0; | ||
209 | |||
210 | /* See if we have a manufacturer identifier. Use it to set is_kme for | 246 | /* See if we have a manufacturer identifier. Use it to set is_kme for |
211 | vendor quirks */ | 247 | vendor quirks */ |
212 | is_kme = ((pdev->manf_id == MANFID_KME) && | 248 | is_kme = ((pdev->manf_id == MANFID_KME) && |
213 | ((pdev->card_id == PRODID_KME_KXLC005_A) || | 249 | ((pdev->card_id == PRODID_KME_KXLC005_A) || |
214 | (pdev->card_id == PRODID_KME_KXLC005_B))); | 250 | (pdev->card_id == PRODID_KME_KXLC005_B))); |
215 | 251 | ||
216 | /* Not sure if this is right... look up the current Vcc */ | 252 | /* Allocate resoure probing structures */ |
217 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); | ||
218 | /* link->conf.Vcc = stk->conf.Vcc; */ | ||
219 | |||
220 | pass = io_base = ctl_base = 0; | ||
221 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
222 | tuple.Attributes = 0; | ||
223 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); | ||
224 | |||
225 | /* Now munch the resources looking for a suitable set */ | ||
226 | while (1) { | ||
227 | if (pcmcia_get_tuple_data(pdev, &tuple) != 0) | ||
228 | goto next_entry; | ||
229 | if (pcmcia_parse_tuple(pdev, &tuple, &stk->parse) != 0) | ||
230 | goto next_entry; | ||
231 | /* Check for matching Vcc, unless we're desperate */ | ||
232 | if (!pass) { | ||
233 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
234 | if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
235 | goto next_entry; | ||
236 | } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
237 | if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
238 | goto next_entry; | ||
239 | } | ||
240 | } | ||
241 | 253 | ||
242 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 254 | stk = kzalloc(sizeof(*stk), GFP_KERNEL); |
243 | pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 255 | if (!stk) |
244 | else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | 256 | goto out1; |
245 | pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 257 | stk->is_kme = is_kme; |
246 | 258 | stk->skip_vcc = io_base = ctl_base = 0; | |
247 | if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { | ||
248 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; | ||
249 | pdev->conf.ConfigIndex = cfg->index; | ||
250 | pdev->io.BasePort1 = io->win[0].base; | ||
251 | pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
252 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
253 | pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
254 | if (io->nwin == 2) { | ||
255 | pdev->io.NumPorts1 = 8; | ||
256 | pdev->io.BasePort2 = io->win[1].base; | ||
257 | pdev->io.NumPorts2 = (is_kme) ? 2 : 1; | ||
258 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
259 | goto next_entry; | ||
260 | io_base = pdev->io.BasePort1; | ||
261 | ctl_base = pdev->io.BasePort2; | ||
262 | } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { | ||
263 | pdev->io.NumPorts1 = io->win[0].len; | ||
264 | pdev->io.NumPorts2 = 0; | ||
265 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
266 | goto next_entry; | ||
267 | io_base = pdev->io.BasePort1; | ||
268 | ctl_base = pdev->io.BasePort1 + 0x0e; | ||
269 | } else | ||
270 | goto next_entry; | ||
271 | /* If we've got this far, we're done */ | ||
272 | break; | ||
273 | } | ||
274 | next_entry: | ||
275 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
276 | memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); | ||
277 | if (pass) { | ||
278 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(pdev, &tuple)); | ||
279 | } else if (pcmcia_get_next_tuple(pdev, &tuple) != 0) { | ||
280 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); | ||
281 | memset(&stk->dflt, 0, sizeof(stk->dflt)); | ||
282 | pass++; | ||
283 | } | ||
284 | } | ||
285 | 259 | ||
260 | if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { | ||
261 | stk->skip_vcc = 1; | ||
262 | if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) | ||
263 | goto failed; /* No suitable config found */ | ||
264 | } | ||
265 | io_base = pdev->io.BasePort1; | ||
266 | ctl_base = stk->ctl_base; | ||
286 | CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); | 267 | CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); |
287 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); | 268 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); |
288 | 269 | ||
@@ -384,6 +365,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
384 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), | 365 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), |
385 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), | 366 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), |
386 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ | 367 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ |
368 | PCMCIA_DEVICE_MANF_CARD(0x004f, 0x0000), /* Kingston */ | ||
387 | PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ | 369 | PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ |
388 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ | 370 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ |
389 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), | 371 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), |
@@ -404,9 +386,9 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
404 | PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), | 386 | PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), |
405 | PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), | 387 | PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), |
406 | PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), | 388 | PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), |
407 | PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), | ||
408 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), | 389 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), |
409 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), | 390 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), |
391 | PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), | ||
410 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), | 392 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), |
411 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), | 393 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), |
412 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), | 394 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), |
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index e970b227fbce..a598bb36aafc 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -230,7 +230,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio) | |||
230 | tmpbyte & 1, tmpbyte & 0x30); | 230 | tmpbyte & 1, tmpbyte & 0x30); |
231 | 231 | ||
232 | *try_mmio = 0; | 232 | *try_mmio = 0; |
233 | #ifdef CONFIG_PPC_MERGE | 233 | #ifdef CONFIG_PPC |
234 | if (machine_is(cell)) | 234 | if (machine_is(cell)) |
235 | *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5); | 235 | *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5); |
236 | #endif | 236 | #endif |
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c index 3924e7209a44..1a56db92ff7a 100644 --- a/drivers/ata/sata_fsl.c +++ b/drivers/ata/sata_fsl.c | |||
@@ -469,10 +469,10 @@ static bool sata_fsl_qc_fill_rtf(struct ata_queued_cmd *qc) | |||
469 | return true; | 469 | return true; |
470 | } | 470 | } |
471 | 471 | ||
472 | static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in, | 472 | static int sata_fsl_scr_write(struct ata_link *link, |
473 | u32 val) | 473 | unsigned int sc_reg_in, u32 val) |
474 | { | 474 | { |
475 | struct sata_fsl_host_priv *host_priv = ap->host->private_data; | 475 | struct sata_fsl_host_priv *host_priv = link->ap->host->private_data; |
476 | void __iomem *ssr_base = host_priv->ssr_base; | 476 | void __iomem *ssr_base = host_priv->ssr_base; |
477 | unsigned int sc_reg; | 477 | unsigned int sc_reg; |
478 | 478 | ||
@@ -493,10 +493,10 @@ static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in, | |||
493 | return 0; | 493 | return 0; |
494 | } | 494 | } |
495 | 495 | ||
496 | static int sata_fsl_scr_read(struct ata_port *ap, unsigned int sc_reg_in, | 496 | static int sata_fsl_scr_read(struct ata_link *link, |
497 | u32 *val) | 497 | unsigned int sc_reg_in, u32 *val) |
498 | { | 498 | { |
499 | struct sata_fsl_host_priv *host_priv = ap->host->private_data; | 499 | struct sata_fsl_host_priv *host_priv = link->ap->host->private_data; |
500 | void __iomem *ssr_base = host_priv->ssr_base; | 500 | void __iomem *ssr_base = host_priv->ssr_base; |
501 | unsigned int sc_reg; | 501 | unsigned int sc_reg; |
502 | 502 | ||
@@ -645,12 +645,12 @@ static int sata_fsl_port_start(struct ata_port *ap) | |||
645 | * Workaround for 8315DS board 3gbps link-up issue, | 645 | * Workaround for 8315DS board 3gbps link-up issue, |
646 | * currently limit SATA port to GEN1 speed | 646 | * currently limit SATA port to GEN1 speed |
647 | */ | 647 | */ |
648 | sata_fsl_scr_read(ap, SCR_CONTROL, &temp); | 648 | sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp); |
649 | temp &= ~(0xF << 4); | 649 | temp &= ~(0xF << 4); |
650 | temp |= (0x1 << 4); | 650 | temp |= (0x1 << 4); |
651 | sata_fsl_scr_write(ap, SCR_CONTROL, temp); | 651 | sata_fsl_scr_write(&ap->link, SCR_CONTROL, temp); |
652 | 652 | ||
653 | sata_fsl_scr_read(ap, SCR_CONTROL, &temp); | 653 | sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp); |
654 | dev_printk(KERN_WARNING, dev, "scr_control, speed limited to %x\n", | 654 | dev_printk(KERN_WARNING, dev, "scr_control, speed limited to %x\n", |
655 | temp); | 655 | temp); |
656 | #endif | 656 | #endif |
@@ -868,7 +868,7 @@ issue_srst: | |||
868 | ioread32(CQ + hcr_base), | 868 | ioread32(CQ + hcr_base), |
869 | ioread32(CA + hcr_base), ioread32(CC + hcr_base)); | 869 | ioread32(CA + hcr_base), ioread32(CC + hcr_base)); |
870 | 870 | ||
871 | sata_fsl_scr_read(ap, SCR_ERROR, &Serror); | 871 | sata_fsl_scr_read(&ap->link, SCR_ERROR, &Serror); |
872 | 872 | ||
873 | DPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); | 873 | DPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); |
874 | DPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); | 874 | DPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); |
@@ -972,9 +972,9 @@ static void sata_fsl_error_intr(struct ata_port *ap) | |||
972 | * Handle & Clear SError | 972 | * Handle & Clear SError |
973 | */ | 973 | */ |
974 | 974 | ||
975 | sata_fsl_scr_read(ap, SCR_ERROR, &SError); | 975 | sata_fsl_scr_read(&ap->link, SCR_ERROR, &SError); |
976 | if (unlikely(SError & 0xFFFF0000)) { | 976 | if (unlikely(SError & 0xFFFF0000)) { |
977 | sata_fsl_scr_write(ap, SCR_ERROR, SError); | 977 | sata_fsl_scr_write(&ap->link, SCR_ERROR, SError); |
978 | } | 978 | } |
979 | 979 | ||
980 | DPRINTK("error_intr,hStat=0x%x,CE=0x%x,DE =0x%x,SErr=0x%x\n", | 980 | DPRINTK("error_intr,hStat=0x%x,CE=0x%x,DE =0x%x,SErr=0x%x\n", |
@@ -1091,7 +1091,7 @@ static void sata_fsl_host_intr(struct ata_port *ap) | |||
1091 | 1091 | ||
1092 | hstatus = ioread32(hcr_base + HSTATUS); | 1092 | hstatus = ioread32(hcr_base + HSTATUS); |
1093 | 1093 | ||
1094 | sata_fsl_scr_read(ap, SCR_ERROR, &SError); | 1094 | sata_fsl_scr_read(&ap->link, SCR_ERROR, &SError); |
1095 | 1095 | ||
1096 | if (unlikely(SError & 0xFFFF0000)) { | 1096 | if (unlikely(SError & 0xFFFF0000)) { |
1097 | DPRINTK("serror @host_intr : 0x%x\n", SError); | 1097 | DPRINTK("serror @host_intr : 0x%x\n", SError); |
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index 5032c32fa505..fbbd87c96f10 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -269,9 +269,9 @@ static void inic_reset_port(void __iomem *port_base) | |||
269 | writeb(0xff, port_base + PORT_IRQ_STAT); | 269 | writeb(0xff, port_base + PORT_IRQ_STAT); |
270 | } | 270 | } |
271 | 271 | ||
272 | static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) | 272 | static int inic_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val) |
273 | { | 273 | { |
274 | void __iomem *scr_addr = inic_port_base(ap) + PORT_SCR; | 274 | void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR; |
275 | void __iomem *addr; | 275 | void __iomem *addr; |
276 | 276 | ||
277 | if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) | 277 | if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) |
@@ -286,9 +286,9 @@ static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) | |||
286 | return 0; | 286 | return 0; |
287 | } | 287 | } |
288 | 288 | ||
289 | static int inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) | 289 | static int inic_scr_write(struct ata_link *link, unsigned sc_reg, u32 val) |
290 | { | 290 | { |
291 | void __iomem *scr_addr = inic_port_base(ap) + PORT_SCR; | 291 | void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR; |
292 | 292 | ||
293 | if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) | 293 | if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) |
294 | return -EINVAL; | 294 | return -EINVAL; |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index c815f8ecf6e6..2b24ae58b52e 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -493,10 +493,10 @@ struct mv_hw_ops { | |||
493 | void (*reset_bus)(struct ata_host *host, void __iomem *mmio); | 493 | void (*reset_bus)(struct ata_host *host, void __iomem *mmio); |
494 | }; | 494 | }; |
495 | 495 | ||
496 | static int mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val); | 496 | static int mv_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val); |
497 | static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); | 497 | static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val); |
498 | static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val); | 498 | static int mv5_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val); |
499 | static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); | 499 | static int mv5_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val); |
500 | static int mv_port_start(struct ata_port *ap); | 500 | static int mv_port_start(struct ata_port *ap); |
501 | static void mv_port_stop(struct ata_port *ap); | 501 | static void mv_port_stop(struct ata_port *ap); |
502 | static int mv_qc_defer(struct ata_queued_cmd *qc); | 502 | static int mv_qc_defer(struct ata_queued_cmd *qc); |
@@ -1070,23 +1070,23 @@ static unsigned int mv_scr_offset(unsigned int sc_reg_in) | |||
1070 | return ofs; | 1070 | return ofs; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static int mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val) | 1073 | static int mv_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val) |
1074 | { | 1074 | { |
1075 | unsigned int ofs = mv_scr_offset(sc_reg_in); | 1075 | unsigned int ofs = mv_scr_offset(sc_reg_in); |
1076 | 1076 | ||
1077 | if (ofs != 0xffffffffU) { | 1077 | if (ofs != 0xffffffffU) { |
1078 | *val = readl(mv_ap_base(ap) + ofs); | 1078 | *val = readl(mv_ap_base(link->ap) + ofs); |
1079 | return 0; | 1079 | return 0; |
1080 | } else | 1080 | } else |
1081 | return -EINVAL; | 1081 | return -EINVAL; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | static int mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) | 1084 | static int mv_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val) |
1085 | { | 1085 | { |
1086 | unsigned int ofs = mv_scr_offset(sc_reg_in); | 1086 | unsigned int ofs = mv_scr_offset(sc_reg_in); |
1087 | 1087 | ||
1088 | if (ofs != 0xffffffffU) { | 1088 | if (ofs != 0xffffffffU) { |
1089 | writelfl(val, mv_ap_base(ap) + ofs); | 1089 | writelfl(val, mv_ap_base(link->ap) + ofs); |
1090 | return 0; | 1090 | return 0; |
1091 | } else | 1091 | } else |
1092 | return -EINVAL; | 1092 | return -EINVAL; |
@@ -2251,11 +2251,11 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in) | |||
2251 | return ofs; | 2251 | return ofs; |
2252 | } | 2252 | } |
2253 | 2253 | ||
2254 | static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val) | 2254 | static int mv5_scr_read(struct ata_link *link, unsigned int sc_reg_in, u32 *val) |
2255 | { | 2255 | { |
2256 | struct mv_host_priv *hpriv = ap->host->private_data; | 2256 | struct mv_host_priv *hpriv = link->ap->host->private_data; |
2257 | void __iomem *mmio = hpriv->base; | 2257 | void __iomem *mmio = hpriv->base; |
2258 | void __iomem *addr = mv5_phy_base(mmio, ap->port_no); | 2258 | void __iomem *addr = mv5_phy_base(mmio, link->ap->port_no); |
2259 | unsigned int ofs = mv5_scr_offset(sc_reg_in); | 2259 | unsigned int ofs = mv5_scr_offset(sc_reg_in); |
2260 | 2260 | ||
2261 | if (ofs != 0xffffffffU) { | 2261 | if (ofs != 0xffffffffU) { |
@@ -2265,11 +2265,11 @@ static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val) | |||
2265 | return -EINVAL; | 2265 | return -EINVAL; |
2266 | } | 2266 | } |
2267 | 2267 | ||
2268 | static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) | 2268 | static int mv5_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val) |
2269 | { | 2269 | { |
2270 | struct mv_host_priv *hpriv = ap->host->private_data; | 2270 | struct mv_host_priv *hpriv = link->ap->host->private_data; |
2271 | void __iomem *mmio = hpriv->base; | 2271 | void __iomem *mmio = hpriv->base; |
2272 | void __iomem *addr = mv5_phy_base(mmio, ap->port_no); | 2272 | void __iomem *addr = mv5_phy_base(mmio, link->ap->port_no); |
2273 | unsigned int ofs = mv5_scr_offset(sc_reg_in); | 2273 | unsigned int ofs = mv5_scr_offset(sc_reg_in); |
2274 | 2274 | ||
2275 | if (ofs != 0xffffffffU) { | 2275 | if (ofs != 0xffffffffU) { |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 14601dc05e41..fae3841de0d8 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -302,8 +302,8 @@ static void nv_ck804_host_stop(struct ata_host *host); | |||
302 | static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance); | 302 | static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance); |
303 | static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance); | 303 | static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance); |
304 | static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance); | 304 | static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance); |
305 | static int nv_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 305 | static int nv_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
306 | static int nv_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 306 | static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
307 | 307 | ||
308 | static void nv_nf2_freeze(struct ata_port *ap); | 308 | static void nv_nf2_freeze(struct ata_port *ap); |
309 | static void nv_nf2_thaw(struct ata_port *ap); | 309 | static void nv_nf2_thaw(struct ata_port *ap); |
@@ -1511,21 +1511,21 @@ static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance) | |||
1511 | return ret; | 1511 | return ret; |
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | static int nv_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 1514 | static int nv_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
1515 | { | 1515 | { |
1516 | if (sc_reg > SCR_CONTROL) | 1516 | if (sc_reg > SCR_CONTROL) |
1517 | return -EINVAL; | 1517 | return -EINVAL; |
1518 | 1518 | ||
1519 | *val = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4)); | 1519 | *val = ioread32(link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
1520 | return 0; | 1520 | return 0; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | static int nv_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 1523 | static int nv_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
1524 | { | 1524 | { |
1525 | if (sc_reg > SCR_CONTROL) | 1525 | if (sc_reg > SCR_CONTROL) |
1526 | return -EINVAL; | 1526 | return -EINVAL; |
1527 | 1527 | ||
1528 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); | 1528 | iowrite32(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
1529 | return 0; | 1529 | return 0; |
1530 | } | 1530 | } |
1531 | 1531 | ||
@@ -2218,9 +2218,9 @@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis) | |||
2218 | if (!pp->qc_active) | 2218 | if (!pp->qc_active) |
2219 | return; | 2219 | return; |
2220 | 2220 | ||
2221 | if (ap->ops->scr_read(ap, SCR_ERROR, &serror)) | 2221 | if (ap->ops->scr_read(&ap->link, SCR_ERROR, &serror)) |
2222 | return; | 2222 | return; |
2223 | ap->ops->scr_write(ap, SCR_ERROR, serror); | 2223 | ap->ops->scr_write(&ap->link, SCR_ERROR, serror); |
2224 | 2224 | ||
2225 | if (ata_stat & ATA_ERR) { | 2225 | if (ata_stat & ATA_ERR) { |
2226 | ata_ehi_clear_desc(ehi); | 2226 | ata_ehi_clear_desc(ehi); |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 030665ba76b7..750d8cdc00cd 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -137,8 +137,8 @@ struct pdc_port_priv { | |||
137 | dma_addr_t pkt_dma; | 137 | dma_addr_t pkt_dma; |
138 | }; | 138 | }; |
139 | 139 | ||
140 | static int pdc_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 140 | static int pdc_sata_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
141 | static int pdc_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 141 | static int pdc_sata_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
142 | static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 142 | static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
143 | static int pdc_common_port_start(struct ata_port *ap); | 143 | static int pdc_common_port_start(struct ata_port *ap); |
144 | static int pdc_sata_port_start(struct ata_port *ap); | 144 | static int pdc_sata_port_start(struct ata_port *ap); |
@@ -386,19 +386,21 @@ static int pdc_sata_cable_detect(struct ata_port *ap) | |||
386 | return ATA_CBL_SATA; | 386 | return ATA_CBL_SATA; |
387 | } | 387 | } |
388 | 388 | ||
389 | static int pdc_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 389 | static int pdc_sata_scr_read(struct ata_link *link, |
390 | unsigned int sc_reg, u32 *val) | ||
390 | { | 391 | { |
391 | if (sc_reg > SCR_CONTROL) | 392 | if (sc_reg > SCR_CONTROL) |
392 | return -EINVAL; | 393 | return -EINVAL; |
393 | *val = readl(ap->ioaddr.scr_addr + (sc_reg * 4)); | 394 | *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
394 | return 0; | 395 | return 0; |
395 | } | 396 | } |
396 | 397 | ||
397 | static int pdc_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 398 | static int pdc_sata_scr_write(struct ata_link *link, |
399 | unsigned int sc_reg, u32 val) | ||
398 | { | 400 | { |
399 | if (sc_reg > SCR_CONTROL) | 401 | if (sc_reg > SCR_CONTROL) |
400 | return -EINVAL; | 402 | return -EINVAL; |
401 | writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); | 403 | writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
402 | return 0; | 404 | return 0; |
403 | } | 405 | } |
404 | 406 | ||
@@ -731,7 +733,7 @@ static void pdc_error_intr(struct ata_port *ap, struct ata_queued_cmd *qc, | |||
731 | if (sata_scr_valid(&ap->link)) { | 733 | if (sata_scr_valid(&ap->link)) { |
732 | u32 serror; | 734 | u32 serror; |
733 | 735 | ||
734 | pdc_sata_scr_read(ap, SCR_ERROR, &serror); | 736 | pdc_sata_scr_read(&ap->link, SCR_ERROR, &serror); |
735 | ehi->serror |= serror; | 737 | ehi->serror |= serror; |
736 | } | 738 | } |
737 | 739 | ||
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c index 1600107047cf..a000c86ac859 100644 --- a/drivers/ata/sata_qstor.c +++ b/drivers/ata/sata_qstor.c | |||
@@ -111,8 +111,8 @@ struct qs_port_priv { | |||
111 | qs_state_t state; | 111 | qs_state_t state; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 114 | static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
115 | static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 115 | static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
116 | static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 116 | static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
117 | static int qs_port_start(struct ata_port *ap); | 117 | static int qs_port_start(struct ata_port *ap); |
118 | static void qs_host_stop(struct ata_host *host); | 118 | static void qs_host_stop(struct ata_host *host); |
@@ -242,11 +242,11 @@ static int qs_prereset(struct ata_link *link, unsigned long deadline) | |||
242 | return ata_sff_prereset(link, deadline); | 242 | return ata_sff_prereset(link, deadline); |
243 | } | 243 | } |
244 | 244 | ||
245 | static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 245 | static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
246 | { | 246 | { |
247 | if (sc_reg > SCR_CONTROL) | 247 | if (sc_reg > SCR_CONTROL) |
248 | return -EINVAL; | 248 | return -EINVAL; |
249 | *val = readl(ap->ioaddr.scr_addr + (sc_reg * 8)); | 249 | *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 8)); |
250 | return 0; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||
@@ -256,11 +256,11 @@ static void qs_error_handler(struct ata_port *ap) | |||
256 | ata_std_error_handler(ap); | 256 | ata_std_error_handler(ap); |
257 | } | 257 | } |
258 | 258 | ||
259 | static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 259 | static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
260 | { | 260 | { |
261 | if (sc_reg > SCR_CONTROL) | 261 | if (sc_reg > SCR_CONTROL) |
262 | return -EINVAL; | 262 | return -EINVAL; |
263 | writel(val, ap->ioaddr.scr_addr + (sc_reg * 8)); | 263 | writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 8)); |
264 | return 0; | 264 | return 0; |
265 | } | 265 | } |
266 | 266 | ||
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 88bf4212590f..031d7b7dee34 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -115,8 +115,8 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | |||
115 | static int sil_pci_device_resume(struct pci_dev *pdev); | 115 | static int sil_pci_device_resume(struct pci_dev *pdev); |
116 | #endif | 116 | #endif |
117 | static void sil_dev_config(struct ata_device *dev); | 117 | static void sil_dev_config(struct ata_device *dev); |
118 | static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 118 | static int sil_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
119 | static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 119 | static int sil_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
120 | static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed); | 120 | static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed); |
121 | static void sil_freeze(struct ata_port *ap); | 121 | static void sil_freeze(struct ata_port *ap); |
122 | static void sil_thaw(struct ata_port *ap); | 122 | static void sil_thaw(struct ata_port *ap); |
@@ -317,9 +317,9 @@ static inline void __iomem *sil_scr_addr(struct ata_port *ap, | |||
317 | return NULL; | 317 | return NULL; |
318 | } | 318 | } |
319 | 319 | ||
320 | static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 320 | static int sil_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
321 | { | 321 | { |
322 | void __iomem *mmio = sil_scr_addr(ap, sc_reg); | 322 | void __iomem *mmio = sil_scr_addr(link->ap, sc_reg); |
323 | 323 | ||
324 | if (mmio) { | 324 | if (mmio) { |
325 | *val = readl(mmio); | 325 | *val = readl(mmio); |
@@ -328,9 +328,9 @@ static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
328 | return -EINVAL; | 328 | return -EINVAL; |
329 | } | 329 | } |
330 | 330 | ||
331 | static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 331 | static int sil_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
332 | { | 332 | { |
333 | void __iomem *mmio = sil_scr_addr(ap, sc_reg); | 333 | void __iomem *mmio = sil_scr_addr(link->ap, sc_reg); |
334 | 334 | ||
335 | if (mmio) { | 335 | if (mmio) { |
336 | writel(val, mmio); | 336 | writel(val, mmio); |
@@ -352,8 +352,8 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2) | |||
352 | * controllers continue to assert IRQ as long as | 352 | * controllers continue to assert IRQ as long as |
353 | * SError bits are pending. Clear SError immediately. | 353 | * SError bits are pending. Clear SError immediately. |
354 | */ | 354 | */ |
355 | sil_scr_read(ap, SCR_ERROR, &serror); | 355 | sil_scr_read(&ap->link, SCR_ERROR, &serror); |
356 | sil_scr_write(ap, SCR_ERROR, serror); | 356 | sil_scr_write(&ap->link, SCR_ERROR, serror); |
357 | 357 | ||
358 | /* Sometimes spurious interrupts occur, double check | 358 | /* Sometimes spurious interrupts occur, double check |
359 | * it's PHYRDY CHG. | 359 | * it's PHYRDY CHG. |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index 84ffcc26a74b..4621807a1a6a 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -340,8 +340,8 @@ struct sil24_port_priv { | |||
340 | }; | 340 | }; |
341 | 341 | ||
342 | static void sil24_dev_config(struct ata_device *dev); | 342 | static void sil24_dev_config(struct ata_device *dev); |
343 | static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val); | 343 | static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val); |
344 | static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); | 344 | static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val); |
345 | static int sil24_qc_defer(struct ata_queued_cmd *qc); | 345 | static int sil24_qc_defer(struct ata_queued_cmd *qc); |
346 | static void sil24_qc_prep(struct ata_queued_cmd *qc); | 346 | static void sil24_qc_prep(struct ata_queued_cmd *qc); |
347 | static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); | 347 | static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); |
@@ -504,9 +504,9 @@ static int sil24_scr_map[] = { | |||
504 | [SCR_ACTIVE] = 3, | 504 | [SCR_ACTIVE] = 3, |
505 | }; | 505 | }; |
506 | 506 | ||
507 | static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) | 507 | static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val) |
508 | { | 508 | { |
509 | void __iomem *scr_addr = sil24_port_base(ap) + PORT_SCONTROL; | 509 | void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; |
510 | 510 | ||
511 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { | 511 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { |
512 | void __iomem *addr; | 512 | void __iomem *addr; |
@@ -517,9 +517,9 @@ static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) | |||
517 | return -EINVAL; | 517 | return -EINVAL; |
518 | } | 518 | } |
519 | 519 | ||
520 | static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) | 520 | static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val) |
521 | { | 521 | { |
522 | void __iomem *scr_addr = sil24_port_base(ap) + PORT_SCONTROL; | 522 | void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; |
523 | 523 | ||
524 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { | 524 | if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { |
525 | void __iomem *addr; | 525 | void __iomem *addr; |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index 1010b3069bd5..9c43b4e7c4a6 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -64,8 +64,8 @@ enum { | |||
64 | }; | 64 | }; |
65 | 65 | ||
66 | static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 66 | static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
67 | static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 67 | static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
68 | static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 68 | static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
69 | 69 | ||
70 | static const struct pci_device_id sis_pci_tbl[] = { | 70 | static const struct pci_device_id sis_pci_tbl[] = { |
71 | { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ | 71 | { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ |
@@ -134,10 +134,11 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) | |||
134 | return addr; | 134 | return addr; |
135 | } | 135 | } |
136 | 136 | ||
137 | static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 137 | static u32 sis_scr_cfg_read(struct ata_link *link, |
138 | unsigned int sc_reg, u32 *val) | ||
138 | { | 139 | { |
139 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 140 | struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); |
140 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 141 | unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg); |
141 | u32 val2 = 0; | 142 | u32 val2 = 0; |
142 | u8 pmr; | 143 | u8 pmr; |
143 | 144 | ||
@@ -158,10 +159,11 @@ static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
158 | return 0; | 159 | return 0; |
159 | } | 160 | } |
160 | 161 | ||
161 | static int sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 162 | static int sis_scr_cfg_write(struct ata_link *link, |
163 | unsigned int sc_reg, u32 val) | ||
162 | { | 164 | { |
163 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 165 | struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); |
164 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 166 | unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg); |
165 | u8 pmr; | 167 | u8 pmr; |
166 | 168 | ||
167 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ | 169 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ |
@@ -178,8 +180,9 @@ static int sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
178 | return 0; | 180 | return 0; |
179 | } | 181 | } |
180 | 182 | ||
181 | static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 183 | static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
182 | { | 184 | { |
185 | struct ata_port *ap = link->ap; | ||
183 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 186 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
184 | u8 pmr; | 187 | u8 pmr; |
185 | 188 | ||
@@ -187,7 +190,7 @@ static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
187 | return -EINVAL; | 190 | return -EINVAL; |
188 | 191 | ||
189 | if (ap->flags & SIS_FLAG_CFGSCR) | 192 | if (ap->flags & SIS_FLAG_CFGSCR) |
190 | return sis_scr_cfg_read(ap, sc_reg, val); | 193 | return sis_scr_cfg_read(link, sc_reg, val); |
191 | 194 | ||
192 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 195 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
193 | 196 | ||
@@ -202,8 +205,9 @@ static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
202 | return 0; | 205 | return 0; |
203 | } | 206 | } |
204 | 207 | ||
205 | static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 208 | static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
206 | { | 209 | { |
210 | struct ata_port *ap = link->ap; | ||
207 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 211 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
208 | u8 pmr; | 212 | u8 pmr; |
209 | 213 | ||
@@ -213,7 +217,7 @@ static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
213 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 217 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
214 | 218 | ||
215 | if (ap->flags & SIS_FLAG_CFGSCR) | 219 | if (ap->flags & SIS_FLAG_CFGSCR) |
216 | return sis_scr_cfg_write(ap, sc_reg, val); | 220 | return sis_scr_cfg_write(link, sc_reg, val); |
217 | else { | 221 | else { |
218 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); | 222 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); |
219 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || | 223 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || |
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index fb13b82aacba..609d147813ae 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -123,20 +123,22 @@ static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | static int k2_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 126 | static int k2_sata_scr_read(struct ata_link *link, |
127 | unsigned int sc_reg, u32 *val) | ||
127 | { | 128 | { |
128 | if (sc_reg > SCR_CONTROL) | 129 | if (sc_reg > SCR_CONTROL) |
129 | return -EINVAL; | 130 | return -EINVAL; |
130 | *val = readl(ap->ioaddr.scr_addr + (sc_reg * 4)); | 131 | *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
131 | return 0; | 132 | return 0; |
132 | } | 133 | } |
133 | 134 | ||
134 | 135 | ||
135 | static int k2_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 136 | static int k2_sata_scr_write(struct ata_link *link, |
137 | unsigned int sc_reg, u32 val) | ||
136 | { | 138 | { |
137 | if (sc_reg > SCR_CONTROL) | 139 | if (sc_reg > SCR_CONTROL) |
138 | return -EINVAL; | 140 | return -EINVAL; |
139 | writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); | 141 | writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
140 | return 0; | 142 | return 0; |
141 | } | 143 | } |
142 | 144 | ||
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index db529b849948..019575bb3e08 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -57,8 +57,8 @@ struct uli_priv { | |||
57 | }; | 57 | }; |
58 | 58 | ||
59 | static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 59 | static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
60 | static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 60 | static int uli_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
61 | static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 61 | static int uli_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
62 | 62 | ||
63 | static const struct pci_device_id uli_pci_tbl[] = { | 63 | static const struct pci_device_id uli_pci_tbl[] = { |
64 | { PCI_VDEVICE(AL, 0x5289), uli_5289 }, | 64 | { PCI_VDEVICE(AL, 0x5289), uli_5289 }, |
@@ -107,39 +107,39 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) | |||
107 | return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); | 107 | return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); |
108 | } | 108 | } |
109 | 109 | ||
110 | static u32 uli_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg) | 110 | static u32 uli_scr_cfg_read(struct ata_link *link, unsigned int sc_reg) |
111 | { | 111 | { |
112 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 112 | struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); |
113 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 113 | unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg); |
114 | u32 val; | 114 | u32 val; |
115 | 115 | ||
116 | pci_read_config_dword(pdev, cfg_addr, &val); | 116 | pci_read_config_dword(pdev, cfg_addr, &val); |
117 | return val; | 117 | return val; |
118 | } | 118 | } |
119 | 119 | ||
120 | static void uli_scr_cfg_write(struct ata_port *ap, unsigned int scr, u32 val) | 120 | static void uli_scr_cfg_write(struct ata_link *link, unsigned int scr, u32 val) |
121 | { | 121 | { |
122 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 122 | struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); |
123 | unsigned int cfg_addr = get_scr_cfg_addr(ap, scr); | 123 | unsigned int cfg_addr = get_scr_cfg_addr(link->ap, scr); |
124 | 124 | ||
125 | pci_write_config_dword(pdev, cfg_addr, val); | 125 | pci_write_config_dword(pdev, cfg_addr, val); |
126 | } | 126 | } |
127 | 127 | ||
128 | static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 128 | static int uli_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
129 | { | 129 | { |
130 | if (sc_reg > SCR_CONTROL) | 130 | if (sc_reg > SCR_CONTROL) |
131 | return -EINVAL; | 131 | return -EINVAL; |
132 | 132 | ||
133 | *val = uli_scr_cfg_read(ap, sc_reg); | 133 | *val = uli_scr_cfg_read(link, sc_reg); |
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 137 | static int uli_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
138 | { | 138 | { |
139 | if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 | 139 | if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 |
140 | return -EINVAL; | 140 | return -EINVAL; |
141 | 141 | ||
142 | uli_scr_cfg_write(ap, sc_reg, val); | 142 | uli_scr_cfg_write(link, sc_reg, val); |
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 96deeb354e16..1cfa74535d91 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -68,8 +68,8 @@ enum { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 70 | static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
71 | static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); | 71 | static int svia_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
72 | static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); | 72 | static int svia_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
73 | static void svia_noop_freeze(struct ata_port *ap); | 73 | static void svia_noop_freeze(struct ata_port *ap); |
74 | static int vt6420_prereset(struct ata_link *link, unsigned long deadline); | 74 | static int vt6420_prereset(struct ata_link *link, unsigned long deadline); |
75 | static int vt6421_pata_cable_detect(struct ata_port *ap); | 75 | static int vt6421_pata_cable_detect(struct ata_port *ap); |
@@ -152,19 +152,19 @@ MODULE_LICENSE("GPL"); | |||
152 | MODULE_DEVICE_TABLE(pci, svia_pci_tbl); | 152 | MODULE_DEVICE_TABLE(pci, svia_pci_tbl); |
153 | MODULE_VERSION(DRV_VERSION); | 153 | MODULE_VERSION(DRV_VERSION); |
154 | 154 | ||
155 | static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 155 | static int svia_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) |
156 | { | 156 | { |
157 | if (sc_reg > SCR_CONTROL) | 157 | if (sc_reg > SCR_CONTROL) |
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | *val = ioread32(ap->ioaddr.scr_addr + (4 * sc_reg)); | 159 | *val = ioread32(link->ap->ioaddr.scr_addr + (4 * sc_reg)); |
160 | return 0; | 160 | return 0; |
161 | } | 161 | } |
162 | 162 | ||
163 | static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 163 | static int svia_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) |
164 | { | 164 | { |
165 | if (sc_reg > SCR_CONTROL) | 165 | if (sc_reg > SCR_CONTROL) |
166 | return -EINVAL; | 166 | return -EINVAL; |
167 | iowrite32(val, ap->ioaddr.scr_addr + (4 * sc_reg)); | 167 | iowrite32(val, link->ap->ioaddr.scr_addr + (4 * sc_reg)); |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
@@ -210,20 +210,20 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline) | |||
210 | goto skip_scr; | 210 | goto skip_scr; |
211 | 211 | ||
212 | /* Resume phy. This is the old SATA resume sequence */ | 212 | /* Resume phy. This is the old SATA resume sequence */ |
213 | svia_scr_write(ap, SCR_CONTROL, 0x300); | 213 | svia_scr_write(link, SCR_CONTROL, 0x300); |
214 | svia_scr_read(ap, SCR_CONTROL, &scontrol); /* flush */ | 214 | svia_scr_read(link, SCR_CONTROL, &scontrol); /* flush */ |
215 | 215 | ||
216 | /* wait for phy to become ready, if necessary */ | 216 | /* wait for phy to become ready, if necessary */ |
217 | do { | 217 | do { |
218 | msleep(200); | 218 | msleep(200); |
219 | svia_scr_read(ap, SCR_STATUS, &sstatus); | 219 | svia_scr_read(link, SCR_STATUS, &sstatus); |
220 | if ((sstatus & 0xf) != 1) | 220 | if ((sstatus & 0xf) != 1) |
221 | break; | 221 | break; |
222 | } while (time_before(jiffies, timeout)); | 222 | } while (time_before(jiffies, timeout)); |
223 | 223 | ||
224 | /* open code sata_print_link_status() */ | 224 | /* open code sata_print_link_status() */ |
225 | svia_scr_read(ap, SCR_STATUS, &sstatus); | 225 | svia_scr_read(link, SCR_STATUS, &sstatus); |
226 | svia_scr_read(ap, SCR_CONTROL, &scontrol); | 226 | svia_scr_read(link, SCR_CONTROL, &scontrol); |
227 | 227 | ||
228 | online = (sstatus & 0xf) == 0x3; | 228 | online = (sstatus & 0xf) == 0x3; |
229 | 229 | ||
@@ -232,7 +232,7 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline) | |||
232 | online ? "up" : "down", sstatus, scontrol); | 232 | online ? "up" : "down", sstatus, scontrol); |
233 | 233 | ||
234 | /* SStatus is read one more time */ | 234 | /* SStatus is read one more time */ |
235 | svia_scr_read(ap, SCR_STATUS, &sstatus); | 235 | svia_scr_read(link, SCR_STATUS, &sstatus); |
236 | 236 | ||
237 | if (!online) { | 237 | if (!online) { |
238 | /* tell EH to bail */ | 238 | /* tell EH to bail */ |
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index f3d635c0a2e9..c57cdff9e6bd 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -98,20 +98,22 @@ enum { | |||
98 | VSC_SATA_INT_PHY_CHANGE), | 98 | VSC_SATA_INT_PHY_CHANGE), |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static int vsc_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 101 | static int vsc_sata_scr_read(struct ata_link *link, |
102 | unsigned int sc_reg, u32 *val) | ||
102 | { | 103 | { |
103 | if (sc_reg > SCR_CONTROL) | 104 | if (sc_reg > SCR_CONTROL) |
104 | return -EINVAL; | 105 | return -EINVAL; |
105 | *val = readl(ap->ioaddr.scr_addr + (sc_reg * 4)); | 106 | *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
106 | return 0; | 107 | return 0; |
107 | } | 108 | } |
108 | 109 | ||
109 | 110 | ||
110 | static int vsc_sata_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 111 | static int vsc_sata_scr_write(struct ata_link *link, |
112 | unsigned int sc_reg, u32 val) | ||
111 | { | 113 | { |
112 | if (sc_reg > SCR_CONTROL) | 114 | if (sc_reg > SCR_CONTROL) |
113 | return -EINVAL; | 115 | return -EINVAL; |
114 | writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); | 116 | writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); |
115 | return 0; | 117 | return 0; |
116 | } | 118 | } |
117 | 119 | ||