diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-25 15:41:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-25 15:41:55 -0400 |
commit | 50be4917ee70218f59e04dec029121b97fb9cb3d (patch) | |
tree | 0261422c5130ec9f6370c0a55638c657baa00d9e | |
parent | 37b05b17985ecc43a33e2a8cbdaa220115de4703 (diff) | |
parent | f9d42491723dbb77bdc9b9dc7e096ea57d535992 (diff) |
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
pata_bf54x: decrease count first.
sata_mv: re-enable hotplug, update TODO list
sata_mv: leave SError bits untouched in mv_err_intr
sata_mv: more interrupt handling rework
sata_mv: tidy host controller interrupt handling
sata_mv: simplify request/response queue handling
sata_mv: simplify freeze/thaw bit-shift calculations
sata_mv mask all interrupt coalescing bits
sata_mv more cosmetics
ata_piix: add Asus Eee 701 controller to short cable list
libata-eh set tf flags in NCQ EH result_tf
make sata_set_spd_needed() static
make sata_print_link_status() static
libata-acpi.c: remove unneeded #if's
sata_nv: make hardreset return -EAGAIN on success
ahci: retry enabling AHCI a few times before spitting out WARN_ON()
libata: make WARN_ON conditions in ata_sff_hsm_move() more strict
ATA/IDE: fix platform driver hotplug/coldplug
sata_sis: SCR accessors return -EINVAL when requested SCR isn't available
libata: functions with definition should not be extern
-rw-r--r-- | drivers/ata/ahci.c | 15 | ||||
-rw-r--r-- | drivers/ata/ata_piix.c | 1 | ||||
-rw-r--r-- | drivers/ata/libata-acpi.c | 4 | ||||
-rw-r--r-- | drivers/ata/libata-core.c | 7 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 1 | ||||
-rw-r--r-- | drivers/ata/libata-sff.c | 4 | ||||
-rw-r--r-- | drivers/ata/libata.h | 1 | ||||
-rw-r--r-- | drivers/ata/pata_at32.c | 3 | ||||
-rw-r--r-- | drivers/ata/pata_bf54x.c | 3 | ||||
-rw-r--r-- | drivers/ata/pata_ixp4xx_cf.c | 1 | ||||
-rw-r--r-- | drivers/ata/pata_platform.c | 1 | ||||
-rw-r--r-- | drivers/ata/pata_rb500_cf.c | 3 | ||||
-rw-r--r-- | drivers/ata/sata_mv.c | 583 | ||||
-rw-r--r-- | drivers/ata/sata_nv.c | 11 | ||||
-rw-r--r-- | drivers/ata/sata_sis.c | 12 | ||||
-rw-r--r-- | drivers/ide/arm/palm_bk3710.c | 4 | ||||
-rw-r--r-- | drivers/ide/legacy/ide_platform.c | 2 | ||||
-rw-r--r-- | include/linux/libata.h | 1 |
18 files changed, 332 insertions, 325 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 986e3324e302..7c4f886f1f16 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -556,16 +556,27 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap) | |||
556 | 556 | ||
557 | static void ahci_enable_ahci(void __iomem *mmio) | 557 | static void ahci_enable_ahci(void __iomem *mmio) |
558 | { | 558 | { |
559 | int i; | ||
559 | u32 tmp; | 560 | u32 tmp; |
560 | 561 | ||
561 | /* turn on AHCI_EN */ | 562 | /* turn on AHCI_EN */ |
562 | tmp = readl(mmio + HOST_CTL); | 563 | tmp = readl(mmio + HOST_CTL); |
563 | if (!(tmp & HOST_AHCI_EN)) { | 564 | if (tmp & HOST_AHCI_EN) |
565 | return; | ||
566 | |||
567 | /* Some controllers need AHCI_EN to be written multiple times. | ||
568 | * Try a few times before giving up. | ||
569 | */ | ||
570 | for (i = 0; i < 5; i++) { | ||
564 | tmp |= HOST_AHCI_EN; | 571 | tmp |= HOST_AHCI_EN; |
565 | writel(tmp, mmio + HOST_CTL); | 572 | writel(tmp, mmio + HOST_CTL); |
566 | tmp = readl(mmio + HOST_CTL); /* flush && sanity check */ | 573 | tmp = readl(mmio + HOST_CTL); /* flush && sanity check */ |
567 | WARN_ON(!(tmp & HOST_AHCI_EN)); | 574 | if (tmp & HOST_AHCI_EN) |
575 | return; | ||
576 | msleep(10); | ||
568 | } | 577 | } |
578 | |||
579 | WARN_ON(1); | ||
569 | } | 580 | } |
570 | 581 | ||
571 | /** | 582 | /** |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index b7c38eeb498f..ea2c7649d399 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -573,6 +573,7 @@ static const struct ich_laptop ich_laptop[] = { | |||
573 | { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ | 573 | { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ |
574 | { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ | 574 | { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ |
575 | { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */ | 575 | { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on ACER Aspire 2023WLMi */ |
576 | { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */ | ||
576 | /* end marker */ | 577 | /* end marker */ |
577 | { 0, } | 578 | { 0, } |
578 | }; | 579 | }; |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 8c1cfc645c85..70b77e0899a8 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -227,11 +227,9 @@ void ata_acpi_associate(struct ata_host *host) | |||
227 | acpi_install_notify_handler(ap->acpi_handle, | 227 | acpi_install_notify_handler(ap->acpi_handle, |
228 | ACPI_SYSTEM_NOTIFY, | 228 | ACPI_SYSTEM_NOTIFY, |
229 | ata_acpi_ap_notify, ap); | 229 | ata_acpi_ap_notify, ap); |
230 | #if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE) | ||
231 | /* we might be on a docking station */ | 230 | /* we might be on a docking station */ |
232 | register_hotplug_dock_device(ap->acpi_handle, | 231 | register_hotplug_dock_device(ap->acpi_handle, |
233 | ata_acpi_ap_notify, ap); | 232 | ata_acpi_ap_notify, ap); |
234 | #endif | ||
235 | } | 233 | } |
236 | 234 | ||
237 | for (j = 0; j < ata_link_max_devices(&ap->link); j++) { | 235 | for (j = 0; j < ata_link_max_devices(&ap->link); j++) { |
@@ -241,11 +239,9 @@ void ata_acpi_associate(struct ata_host *host) | |||
241 | acpi_install_notify_handler(dev->acpi_handle, | 239 | acpi_install_notify_handler(dev->acpi_handle, |
242 | ACPI_SYSTEM_NOTIFY, | 240 | ACPI_SYSTEM_NOTIFY, |
243 | ata_acpi_dev_notify, dev); | 241 | ata_acpi_dev_notify, dev); |
244 | #if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE) | ||
245 | /* we might be on a docking station */ | 242 | /* we might be on a docking station */ |
246 | register_hotplug_dock_device(dev->acpi_handle, | 243 | register_hotplug_dock_device(dev->acpi_handle, |
247 | ata_acpi_dev_notify, dev); | 244 | ata_acpi_dev_notify, dev); |
248 | #endif | ||
249 | } | 245 | } |
250 | } | 246 | } |
251 | } | 247 | } |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index b0b00af90d0e..51b7d2fad36a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2616,7 +2616,7 @@ void ata_port_probe(struct ata_port *ap) | |||
2616 | * LOCKING: | 2616 | * LOCKING: |
2617 | * None. | 2617 | * None. |
2618 | */ | 2618 | */ |
2619 | void sata_print_link_status(struct ata_link *link) | 2619 | static void sata_print_link_status(struct ata_link *link) |
2620 | { | 2620 | { |
2621 | u32 sstatus, scontrol, tmp; | 2621 | u32 sstatus, scontrol, tmp; |
2622 | 2622 | ||
@@ -2772,7 +2772,7 @@ static int __sata_set_spd_needed(struct ata_link *link, u32 *scontrol) | |||
2772 | * RETURNS: | 2772 | * RETURNS: |
2773 | * 1 if SATA spd configuration is needed, 0 otherwise. | 2773 | * 1 if SATA spd configuration is needed, 0 otherwise. |
2774 | */ | 2774 | */ |
2775 | int sata_set_spd_needed(struct ata_link *link) | 2775 | static int sata_set_spd_needed(struct ata_link *link) |
2776 | { | 2776 | { |
2777 | u32 scontrol; | 2777 | u32 scontrol; |
2778 | 2778 | ||
@@ -3377,7 +3377,7 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline, | |||
3377 | * RETURNS: | 3377 | * RETURNS: |
3378 | * 0 if @linke is ready before @deadline; otherwise, -errno. | 3378 | * 0 if @linke is ready before @deadline; otherwise, -errno. |
3379 | */ | 3379 | */ |
3380 | extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, | 3380 | int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, |
3381 | int (*check_ready)(struct ata_link *link)) | 3381 | int (*check_ready)(struct ata_link *link)) |
3382 | { | 3382 | { |
3383 | msleep(ATA_WAIT_AFTER_RESET_MSECS); | 3383 | msleep(ATA_WAIT_AFTER_RESET_MSECS); |
@@ -6208,7 +6208,6 @@ EXPORT_SYMBOL_GPL(ata_host_detach); | |||
6208 | EXPORT_SYMBOL_GPL(ata_sg_init); | 6208 | EXPORT_SYMBOL_GPL(ata_sg_init); |
6209 | EXPORT_SYMBOL_GPL(ata_qc_complete); | 6209 | EXPORT_SYMBOL_GPL(ata_qc_complete); |
6210 | EXPORT_SYMBOL_GPL(ata_qc_complete_multiple); | 6210 | EXPORT_SYMBOL_GPL(ata_qc_complete_multiple); |
6211 | EXPORT_SYMBOL_GPL(sata_print_link_status); | ||
6212 | EXPORT_SYMBOL_GPL(atapi_cmd_type); | 6211 | EXPORT_SYMBOL_GPL(atapi_cmd_type); |
6213 | EXPORT_SYMBOL_GPL(ata_tf_to_fis); | 6212 | EXPORT_SYMBOL_GPL(ata_tf_to_fis); |
6214 | EXPORT_SYMBOL_GPL(ata_tf_from_fis); | 6213 | EXPORT_SYMBOL_GPL(ata_tf_from_fis); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index d94359a24d41..61dcd0026c64 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1402,6 +1402,7 @@ static void ata_eh_analyze_ncq_error(struct ata_link *link) | |||
1402 | /* we've got the perpetrator, condemn it */ | 1402 | /* we've got the perpetrator, condemn it */ |
1403 | qc = __ata_qc_from_tag(ap, tag); | 1403 | qc = __ata_qc_from_tag(ap, tag); |
1404 | memcpy(&qc->result_tf, &tf, sizeof(tf)); | 1404 | memcpy(&qc->result_tf, &tf, sizeof(tf)); |
1405 | qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48; | ||
1405 | qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ; | 1406 | qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ; |
1406 | ehc->i.err_mask &= ~AC_ERR_DEV; | 1407 | ehc->i.err_mask &= ~AC_ERR_DEV; |
1407 | } | 1408 | } |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 15499522e642..2ec65a8fda79 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -1208,7 +1208,7 @@ fsm_start: | |||
1208 | DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n", | 1208 | DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n", |
1209 | ap->print_id, qc->dev->devno, status); | 1209 | ap->print_id, qc->dev->devno, status); |
1210 | 1210 | ||
1211 | WARN_ON(qc->err_mask); | 1211 | WARN_ON(qc->err_mask & (AC_ERR_DEV | AC_ERR_HSM)); |
1212 | 1212 | ||
1213 | ap->hsm_task_state = HSM_ST_IDLE; | 1213 | ap->hsm_task_state = HSM_ST_IDLE; |
1214 | 1214 | ||
@@ -1222,7 +1222,7 @@ fsm_start: | |||
1222 | /* make sure qc->err_mask is available to | 1222 | /* make sure qc->err_mask is available to |
1223 | * know what's wrong and recover | 1223 | * know what's wrong and recover |
1224 | */ | 1224 | */ |
1225 | WARN_ON(qc->err_mask == 0); | 1225 | WARN_ON(!(qc->err_mask & (AC_ERR_DEV | AC_ERR_HSM))); |
1226 | 1226 | ||
1227 | ap->hsm_task_state = HSM_ST_IDLE; | 1227 | ap->hsm_task_state = HSM_ST_IDLE; |
1228 | 1228 | ||
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 4aeeabb10a47..ae2cfd95d43e 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -101,7 +101,6 @@ extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, | |||
101 | unsigned int readid_flags); | 101 | unsigned int readid_flags); |
102 | extern int ata_dev_configure(struct ata_device *dev); | 102 | extern int ata_dev_configure(struct ata_device *dev); |
103 | extern int sata_down_spd_limit(struct ata_link *link); | 103 | extern int sata_down_spd_limit(struct ata_link *link); |
104 | extern int sata_set_spd_needed(struct ata_link *link); | ||
105 | extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); | 104 | extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); |
106 | extern void ata_sg_clean(struct ata_queued_cmd *qc); | 105 | extern void ata_sg_clean(struct ata_queued_cmd *qc); |
107 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 106 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c index 3e8651d78952..5e104385d6a3 100644 --- a/drivers/ata/pata_at32.c +++ b/drivers/ata/pata_at32.c | |||
@@ -381,6 +381,9 @@ static int __exit pata_at32_remove(struct platform_device *pdev) | |||
381 | return 0; | 381 | return 0; |
382 | } | 382 | } |
383 | 383 | ||
384 | /* work with hotplug and coldplug */ | ||
385 | MODULE_ALIAS("platform:at32_ide"); | ||
386 | |||
384 | static struct platform_driver pata_at32_driver = { | 387 | static struct platform_driver pata_at32_driver = { |
385 | .remove = __exit_p(pata_at32_remove), | 388 | .remove = __exit_p(pata_at32_remove), |
386 | .driver = { | 389 | .driver = { |
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c index 0a5ad98635b1..a75de0684c15 100644 --- a/drivers/ata/pata_bf54x.c +++ b/drivers/ata/pata_bf54x.c | |||
@@ -1417,7 +1417,7 @@ static int bfin_reset_controller(struct ata_host *host) | |||
1417 | count = 10000000; | 1417 | count = 10000000; |
1418 | do { | 1418 | do { |
1419 | status = read_atapi_register(base, ATA_REG_STATUS); | 1419 | status = read_atapi_register(base, ATA_REG_STATUS); |
1420 | } while (count-- && (status & ATA_BUSY)); | 1420 | } while (--count && (status & ATA_BUSY)); |
1421 | 1421 | ||
1422 | /* Enable only ATAPI Device interrupt */ | 1422 | /* Enable only ATAPI Device interrupt */ |
1423 | ATAPI_SET_INT_MASK(base, 1); | 1423 | ATAPI_SET_INT_MASK(base, 1); |
@@ -1601,3 +1601,4 @@ MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>"); | |||
1601 | MODULE_DESCRIPTION("PATA driver for blackfin 54x ATAPI controller"); | 1601 | MODULE_DESCRIPTION("PATA driver for blackfin 54x ATAPI controller"); |
1602 | MODULE_LICENSE("GPL"); | 1602 | MODULE_LICENSE("GPL"); |
1603 | MODULE_VERSION(DRV_VERSION); | 1603 | MODULE_VERSION(DRV_VERSION); |
1604 | MODULE_ALIAS("platform:" DRV_NAME); | ||
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 8a175f23b907..de8d186f5abf 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c | |||
@@ -221,6 +221,7 @@ MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | |||
221 | MODULE_DESCRIPTION("low-level driver for ixp4xx Compact Flash PATA"); | 221 | MODULE_DESCRIPTION("low-level driver for ixp4xx Compact Flash PATA"); |
222 | MODULE_LICENSE("GPL"); | 222 | MODULE_LICENSE("GPL"); |
223 | MODULE_VERSION(DRV_VERSION); | 223 | MODULE_VERSION(DRV_VERSION); |
224 | MODULE_ALIAS("platform:" DRV_NAME); | ||
224 | 225 | ||
225 | module_init(ixp4xx_pata_init); | 226 | module_init(ixp4xx_pata_init); |
226 | module_exit(ixp4xx_pata_exit); | 227 | module_exit(ixp4xx_pata_exit); |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index 6527c56c34a3..8f65ad61b8af 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -277,3 +277,4 @@ MODULE_AUTHOR("Paul Mundt"); | |||
277 | MODULE_DESCRIPTION("low-level driver for platform device ATA"); | 277 | MODULE_DESCRIPTION("low-level driver for platform device ATA"); |
278 | MODULE_LICENSE("GPL"); | 278 | MODULE_LICENSE("GPL"); |
279 | MODULE_VERSION(DRV_VERSION); | 279 | MODULE_VERSION(DRV_VERSION); |
280 | MODULE_ALIAS("platform:" DRV_NAME); | ||
diff --git a/drivers/ata/pata_rb500_cf.c b/drivers/ata/pata_rb500_cf.c index 800ae4601f44..4345174aaeec 100644 --- a/drivers/ata/pata_rb500_cf.c +++ b/drivers/ata/pata_rb500_cf.c | |||
@@ -239,6 +239,9 @@ static __devexit int rb500_pata_driver_remove(struct platform_device *pdev) | |||
239 | return 0; | 239 | return 0; |
240 | } | 240 | } |
241 | 241 | ||
242 | /* work with hotplug and coldplug */ | ||
243 | MODULE_ALIAS("platform:" DRV_NAME); | ||
244 | |||
242 | static struct platform_driver rb500_pata_platform_driver = { | 245 | static struct platform_driver rb500_pata_platform_driver = { |
243 | .probe = rb500_pata_driver_probe, | 246 | .probe = rb500_pata_driver_probe, |
244 | .remove = __devexit_p(rb500_pata_driver_remove), | 247 | .remove = __devexit_p(rb500_pata_driver_remove), |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index d52ce1188327..26a6337195b3 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -23,46 +23,34 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* | 25 | /* |
26 | sata_mv TODO list: | 26 | * sata_mv TODO list: |
27 | 27 | * | |
28 | 1) Needs a full errata audit for all chipsets. I implemented most | 28 | * --> Errata workaround for NCQ device errors. |
29 | of the errata workarounds found in the Marvell vendor driver, but | 29 | * |
30 | I distinctly remember a couple workarounds (one related to PCI-X) | 30 | * --> More errata workarounds for PCI-X. |
31 | are still needed. | 31 | * |
32 | 32 | * --> Complete a full errata audit for all chipsets to identify others. | |
33 | 2) Improve/fix IRQ and error handling sequences. | 33 | * |
34 | 34 | * --> ATAPI support (Marvell claims the 60xx/70xx chips can do it). | |
35 | 3) ATAPI support (Marvell claims the 60xx/70xx chips can do it). | 35 | * |
36 | 36 | * --> Investigate problems with PCI Message Signalled Interrupts (MSI). | |
37 | 4) Think about TCQ support here, and for libata in general | 37 | * |
38 | with controllers that suppport it via host-queuing hardware | 38 | * --> Cache frequently-accessed registers in mv_port_priv to reduce overhead. |
39 | (a software-only implementation could be a nightmare). | 39 | * |
40 | 40 | * --> Develop a low-power-consumption strategy, and implement it. | |
41 | 5) Investigate problems with PCI Message Signalled Interrupts (MSI). | 41 | * |
42 | 42 | * --> [Experiment, low priority] Investigate interrupt coalescing. | |
43 | 6) Cache frequently-accessed registers in mv_port_priv to reduce overhead. | 43 | * Quite often, especially with PCI Message Signalled Interrupts (MSI), |
44 | 44 | * the overhead reduced by interrupt mitigation is quite often not | |
45 | 7) Fix/reenable hot plug/unplug (should happen as a side-effect of (2) above). | 45 | * worth the latency cost. |
46 | 46 | * | |
47 | 8) Develop a low-power-consumption strategy, and implement it. | 47 | * --> [Experiment, Marvell value added] Is it possible to use target |
48 | 48 | * mode to cross-connect two Linux boxes with Marvell cards? If so, | |
49 | 9) [Experiment, low priority] See if ATAPI can be supported using | 49 | * creating LibATA target mode support would be very interesting. |
50 | "unknown FIS" or "vendor-specific FIS" support, or something creative | 50 | * |
51 | like that. | 51 | * Target mode, for those without docs, is the ability to directly |
52 | 52 | * connect two SATA ports. | |
53 | 10) [Experiment, low priority] Investigate interrupt coalescing. | 53 | */ |
54 | Quite often, especially with PCI Message Signalled Interrupts (MSI), | ||
55 | the overhead reduced by interrupt mitigation is quite often not | ||
56 | worth the latency cost. | ||
57 | |||
58 | 11) [Experiment, Marvell value added] Is it possible to use target | ||
59 | mode to cross-connect two Linux boxes with Marvell cards? If so, | ||
60 | creating LibATA target mode support would be very interesting. | ||
61 | |||
62 | Target mode, for those without docs, is the ability to directly | ||
63 | connect two SATA controllers. | ||
64 | |||
65 | */ | ||
66 | 54 | ||
67 | #include <linux/kernel.h> | 55 | #include <linux/kernel.h> |
68 | #include <linux/module.h> | 56 | #include <linux/module.h> |
@@ -124,11 +112,11 @@ enum { | |||
124 | MV_MAX_SG_CT = 256, | 112 | MV_MAX_SG_CT = 256, |
125 | MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT), | 113 | MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT), |
126 | 114 | ||
127 | MV_PORTS_PER_HC = 4, | 115 | /* Determine hc from 0-7 port: hc = port >> MV_PORT_HC_SHIFT */ |
128 | /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */ | ||
129 | MV_PORT_HC_SHIFT = 2, | 116 | MV_PORT_HC_SHIFT = 2, |
130 | /* == (port % MV_PORTS_PER_HC) to determine hard port from 0-7 port */ | 117 | MV_PORTS_PER_HC = (1 << MV_PORT_HC_SHIFT), /* 4 */ |
131 | MV_PORT_MASK = 3, | 118 | /* Determine hc port from 0-7 port: hardport = port & MV_PORT_MASK */ |
119 | MV_PORT_MASK = (MV_PORTS_PER_HC - 1), /* 3 */ | ||
132 | 120 | ||
133 | /* Host Flags */ | 121 | /* Host Flags */ |
134 | MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ | 122 | MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ |
@@ -188,8 +176,8 @@ enum { | |||
188 | HC_MAIN_IRQ_MASK_OFS = 0x1d64, | 176 | HC_MAIN_IRQ_MASK_OFS = 0x1d64, |
189 | HC_SOC_MAIN_IRQ_CAUSE_OFS = 0x20020, | 177 | HC_SOC_MAIN_IRQ_CAUSE_OFS = 0x20020, |
190 | HC_SOC_MAIN_IRQ_MASK_OFS = 0x20024, | 178 | HC_SOC_MAIN_IRQ_MASK_OFS = 0x20024, |
191 | PORT0_ERR = (1 << 0), /* shift by port # */ | 179 | ERR_IRQ = (1 << 0), /* shift by port # */ |
192 | PORT0_DONE = (1 << 1), /* shift by port # */ | 180 | DONE_IRQ = (1 << 1), /* shift by port # */ |
193 | HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */ | 181 | HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */ |
194 | HC_SHIFT = 9, /* bits 9-17 = HC1's ports */ | 182 | HC_SHIFT = 9, /* bits 9-17 = HC1's ports */ |
195 | PCI_ERR = (1 << 18), | 183 | PCI_ERR = (1 << 18), |
@@ -205,6 +193,7 @@ enum { | |||
205 | HC_MAIN_RSVD_5 = (0x1fff << 19), /* bits 31-19 */ | 193 | HC_MAIN_RSVD_5 = (0x1fff << 19), /* bits 31-19 */ |
206 | HC_MAIN_RSVD_SOC = (0x3fffffb << 6), /* bits 31-9, 7-6 */ | 194 | HC_MAIN_RSVD_SOC = (0x3fffffb << 6), /* bits 31-9, 7-6 */ |
207 | HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE | | 195 | HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE | |
196 | PORTS_0_3_COAL_DONE | PORTS_4_7_COAL_DONE | | ||
208 | PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT | | 197 | PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT | |
209 | HC_MAIN_RSVD), | 198 | HC_MAIN_RSVD), |
210 | HC_MAIN_MASKED_IRQS_5 = (PORTS_0_3_COAL_DONE | PORTS_4_7_COAL_DONE | | 199 | HC_MAIN_MASKED_IRQS_5 = (PORTS_0_3_COAL_DONE | PORTS_4_7_COAL_DONE | |
@@ -215,8 +204,8 @@ enum { | |||
215 | HC_CFG_OFS = 0, | 204 | HC_CFG_OFS = 0, |
216 | 205 | ||
217 | HC_IRQ_CAUSE_OFS = 0x14, | 206 | HC_IRQ_CAUSE_OFS = 0x14, |
218 | CRPB_DMA_DONE = (1 << 0), /* shift by port # */ | 207 | DMA_IRQ = (1 << 0), /* shift by port # */ |
219 | HC_IRQ_COAL = (1 << 4), /* IRQ coalescing */ | 208 | HC_COAL_IRQ = (1 << 4), /* IRQ coalescing */ |
220 | DEV_IRQ = (1 << 8), /* shift by port # */ | 209 | DEV_IRQ = (1 << 8), /* shift by port # */ |
221 | 210 | ||
222 | /* Shadow block registers */ | 211 | /* Shadow block registers */ |
@@ -299,9 +288,7 @@ enum { | |||
299 | EDMA_ERR_IRQ_TRANSIENT = EDMA_ERR_LNK_CTRL_RX_0 | | 288 | EDMA_ERR_IRQ_TRANSIENT = EDMA_ERR_LNK_CTRL_RX_0 | |
300 | EDMA_ERR_LNK_CTRL_RX_1 | | 289 | EDMA_ERR_LNK_CTRL_RX_1 | |
301 | EDMA_ERR_LNK_CTRL_RX_3 | | 290 | EDMA_ERR_LNK_CTRL_RX_3 | |
302 | EDMA_ERR_LNK_CTRL_TX | | 291 | EDMA_ERR_LNK_CTRL_TX, |
303 | /* temporary, until we fix hotplug: */ | ||
304 | (EDMA_ERR_DEV_DCON | EDMA_ERR_DEV_CON), | ||
305 | 292 | ||
306 | EDMA_EH_FREEZE = EDMA_ERR_D_PAR | | 293 | EDMA_EH_FREEZE = EDMA_ERR_D_PAR | |
307 | EDMA_ERR_PRD_PAR | | 294 | EDMA_ERR_PRD_PAR | |
@@ -349,6 +336,8 @@ enum { | |||
349 | EDMA_IORDY_TMOUT = 0x34, | 336 | EDMA_IORDY_TMOUT = 0x34, |
350 | EDMA_ARB_CFG = 0x38, | 337 | EDMA_ARB_CFG = 0x38, |
351 | 338 | ||
339 | GEN_II_NCQ_MAX_SECTORS = 256, /* max sects/io on Gen2 w/NCQ */ | ||
340 | |||
352 | /* Host private flags (hp_flags) */ | 341 | /* Host private flags (hp_flags) */ |
353 | MV_HP_FLAG_MSI = (1 << 0), | 342 | MV_HP_FLAG_MSI = (1 << 0), |
354 | MV_HP_ERRATA_50XXB0 = (1 << 1), | 343 | MV_HP_ERRATA_50XXB0 = (1 << 1), |
@@ -722,11 +711,6 @@ static inline void writelfl(unsigned long data, void __iomem *addr) | |||
722 | (void) readl(addr); /* flush to avoid PCI posted write */ | 711 | (void) readl(addr); /* flush to avoid PCI posted write */ |
723 | } | 712 | } |
724 | 713 | ||
725 | static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc) | ||
726 | { | ||
727 | return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ)); | ||
728 | } | ||
729 | |||
730 | static inline unsigned int mv_hc_from_port(unsigned int port) | 714 | static inline unsigned int mv_hc_from_port(unsigned int port) |
731 | { | 715 | { |
732 | return port >> MV_PORT_HC_SHIFT; | 716 | return port >> MV_PORT_HC_SHIFT; |
@@ -737,6 +721,29 @@ static inline unsigned int mv_hardport_from_port(unsigned int port) | |||
737 | return port & MV_PORT_MASK; | 721 | return port & MV_PORT_MASK; |
738 | } | 722 | } |
739 | 723 | ||
724 | /* | ||
725 | * Consolidate some rather tricky bit shift calculations. | ||
726 | * This is hot-path stuff, so not a function. | ||
727 | * Simple code, with two return values, so macro rather than inline. | ||
728 | * | ||
729 | * port is the sole input, in range 0..7. | ||
730 | * shift is one output, for use with the main_cause and main_mask registers. | ||
731 | * hardport is the other output, in range 0..3 | ||
732 | * | ||
733 | * Note that port and hardport may be the same variable in some cases. | ||
734 | */ | ||
735 | #define MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport) \ | ||
736 | { \ | ||
737 | shift = mv_hc_from_port(port) * HC_SHIFT; \ | ||
738 | hardport = mv_hardport_from_port(port); \ | ||
739 | shift += hardport * 2; \ | ||
740 | } | ||
741 | |||
742 | static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc) | ||
743 | { | ||
744 | return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ)); | ||
745 | } | ||
746 | |||
740 | static inline void __iomem *mv_hc_base_from_port(void __iomem *base, | 747 | static inline void __iomem *mv_hc_base_from_port(void __iomem *base, |
741 | unsigned int port) | 748 | unsigned int port) |
742 | { | 749 | { |
@@ -783,7 +790,8 @@ static void mv_set_edma_ptrs(void __iomem *port_mmio, | |||
783 | /* | 790 | /* |
784 | * initialize request queue | 791 | * initialize request queue |
785 | */ | 792 | */ |
786 | index = (pp->req_idx & MV_MAX_Q_DEPTH_MASK) << EDMA_REQ_Q_PTR_SHIFT; | 793 | pp->req_idx &= MV_MAX_Q_DEPTH_MASK; /* paranoia */ |
794 | index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT; | ||
787 | 795 | ||
788 | WARN_ON(pp->crqb_dma & 0x3ff); | 796 | WARN_ON(pp->crqb_dma & 0x3ff); |
789 | writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); | 797 | writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); |
@@ -799,7 +807,8 @@ static void mv_set_edma_ptrs(void __iomem *port_mmio, | |||
799 | /* | 807 | /* |
800 | * initialize response queue | 808 | * initialize response queue |
801 | */ | 809 | */ |
802 | index = (pp->resp_idx & MV_MAX_Q_DEPTH_MASK) << EDMA_RSP_Q_PTR_SHIFT; | 810 | pp->resp_idx &= MV_MAX_Q_DEPTH_MASK; /* paranoia */ |
811 | index = pp->resp_idx << EDMA_RSP_Q_PTR_SHIFT; | ||
803 | 812 | ||
804 | WARN_ON(pp->crpb_dma & 0xff); | 813 | WARN_ON(pp->crpb_dma & 0xff); |
805 | writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); | 814 | writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); |
@@ -837,9 +846,9 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, | |||
837 | } | 846 | } |
838 | if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) { | 847 | if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) { |
839 | struct mv_host_priv *hpriv = ap->host->private_data; | 848 | struct mv_host_priv *hpriv = ap->host->private_data; |
840 | int hard_port = mv_hardport_from_port(ap->port_no); | 849 | int hardport = mv_hardport_from_port(ap->port_no); |
841 | void __iomem *hc_mmio = mv_hc_base_from_port( | 850 | void __iomem *hc_mmio = mv_hc_base_from_port( |
842 | mv_host_base(ap->host), hard_port); | 851 | mv_host_base(ap->host), hardport); |
843 | u32 hc_irq_cause, ipending; | 852 | u32 hc_irq_cause, ipending; |
844 | 853 | ||
845 | /* clear EDMA event indicators, if any */ | 854 | /* clear EDMA event indicators, if any */ |
@@ -847,8 +856,7 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, | |||
847 | 856 | ||
848 | /* clear EDMA interrupt indicator, if any */ | 857 | /* clear EDMA interrupt indicator, if any */ |
849 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); | 858 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); |
850 | ipending = (DEV_IRQ << hard_port) | | 859 | ipending = (DEV_IRQ | DMA_IRQ) << hardport; |
851 | (CRPB_DMA_DONE << hard_port); | ||
852 | if (hc_irq_cause & ipending) { | 860 | if (hc_irq_cause & ipending) { |
853 | writelfl(hc_irq_cause & ~ipending, | 861 | writelfl(hc_irq_cause & ~ipending, |
854 | hc_mmio + HC_IRQ_CAUSE_OFS); | 862 | hc_mmio + HC_IRQ_CAUSE_OFS); |
@@ -864,7 +872,6 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, | |||
864 | writelfl(EDMA_EN, port_mmio + EDMA_CMD_OFS); | 872 | writelfl(EDMA_EN, port_mmio + EDMA_CMD_OFS); |
865 | pp->pp_flags |= MV_PP_FLAG_EDMA_EN; | 873 | pp->pp_flags |= MV_PP_FLAG_EDMA_EN; |
866 | } | 874 | } |
867 | WARN_ON(!(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS))); | ||
868 | } | 875 | } |
869 | 876 | ||
870 | /** | 877 | /** |
@@ -1036,10 +1043,16 @@ static void mv6_dev_config(struct ata_device *adev) | |||
1036 | * See mv_qc_prep() for more info. | 1043 | * See mv_qc_prep() for more info. |
1037 | */ | 1044 | */ |
1038 | if (adev->flags & ATA_DFLAG_NCQ) { | 1045 | if (adev->flags & ATA_DFLAG_NCQ) { |
1039 | if (sata_pmp_attached(adev->link->ap)) | 1046 | if (sata_pmp_attached(adev->link->ap)) { |
1040 | adev->flags &= ~ATA_DFLAG_NCQ; | 1047 | adev->flags &= ~ATA_DFLAG_NCQ; |
1041 | else if (adev->max_sectors > ATA_MAX_SECTORS) | 1048 | ata_dev_printk(adev, KERN_INFO, |
1042 | adev->max_sectors = ATA_MAX_SECTORS; | 1049 | "NCQ disabled for command-based switching\n"); |
1050 | } else if (adev->max_sectors > GEN_II_NCQ_MAX_SECTORS) { | ||
1051 | adev->max_sectors = GEN_II_NCQ_MAX_SECTORS; | ||
1052 | ata_dev_printk(adev, KERN_INFO, | ||
1053 | "max_sectors limited to %u for NCQ\n", | ||
1054 | adev->max_sectors); | ||
1055 | } | ||
1043 | } | 1056 | } |
1044 | } | 1057 | } |
1045 | 1058 | ||
@@ -1287,7 +1300,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1287 | flags |= (qc->dev->link->pmp & 0xf) << CRQB_PMP_SHIFT; | 1300 | flags |= (qc->dev->link->pmp & 0xf) << CRQB_PMP_SHIFT; |
1288 | 1301 | ||
1289 | /* get current queue index from software */ | 1302 | /* get current queue index from software */ |
1290 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; | 1303 | in_index = pp->req_idx; |
1291 | 1304 | ||
1292 | pp->crqb[in_index].sg_addr = | 1305 | pp->crqb[in_index].sg_addr = |
1293 | cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff); | 1306 | cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff); |
@@ -1379,7 +1392,7 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc) | |||
1379 | flags |= (qc->dev->link->pmp & 0xf) << CRQB_PMP_SHIFT; | 1392 | flags |= (qc->dev->link->pmp & 0xf) << CRQB_PMP_SHIFT; |
1380 | 1393 | ||
1381 | /* get current queue index from software */ | 1394 | /* get current queue index from software */ |
1382 | in_index = pp->req_idx & MV_MAX_Q_DEPTH_MASK; | 1395 | in_index = pp->req_idx; |
1383 | 1396 | ||
1384 | crqb = (struct mv_crqb_iie *) &pp->crqb[in_index]; | 1397 | crqb = (struct mv_crqb_iie *) &pp->crqb[in_index]; |
1385 | crqb->addr = cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff); | 1398 | crqb->addr = cpu_to_le32(pp->sg_tbl_dma[qc->tag] & 0xffffffff); |
@@ -1446,9 +1459,8 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1446 | 1459 | ||
1447 | mv_start_dma(ap, port_mmio, pp, qc->tf.protocol); | 1460 | mv_start_dma(ap, port_mmio, pp, qc->tf.protocol); |
1448 | 1461 | ||
1449 | pp->req_idx++; | 1462 | pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK; |
1450 | 1463 | in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT; | |
1451 | in_index = (pp->req_idx & MV_MAX_Q_DEPTH_MASK) << EDMA_REQ_Q_PTR_SHIFT; | ||
1452 | 1464 | ||
1453 | /* and write the request in pointer to kick the EDMA to life */ | 1465 | /* and write the request in pointer to kick the EDMA to life */ |
1454 | writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index, | 1466 | writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index, |
@@ -1457,16 +1469,51 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1457 | return 0; | 1469 | return 0; |
1458 | } | 1470 | } |
1459 | 1471 | ||
1472 | static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap) | ||
1473 | { | ||
1474 | struct mv_port_priv *pp = ap->private_data; | ||
1475 | struct ata_queued_cmd *qc; | ||
1476 | |||
1477 | if (pp->pp_flags & MV_PP_FLAG_NCQ_EN) | ||
1478 | return NULL; | ||
1479 | qc = ata_qc_from_tag(ap, ap->link.active_tag); | ||
1480 | if (qc && (qc->tf.flags & ATA_TFLAG_POLLING)) | ||
1481 | qc = NULL; | ||
1482 | return qc; | ||
1483 | } | ||
1484 | |||
1485 | static void mv_unexpected_intr(struct ata_port *ap) | ||
1486 | { | ||
1487 | struct mv_port_priv *pp = ap->private_data; | ||
1488 | struct ata_eh_info *ehi = &ap->link.eh_info; | ||
1489 | char *when = ""; | ||
1490 | |||
1491 | /* | ||
1492 | * We got a device interrupt from something that | ||
1493 | * was supposed to be using EDMA or polling. | ||
1494 | */ | ||
1495 | ata_ehi_clear_desc(ehi); | ||
1496 | if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) { | ||
1497 | when = " while EDMA enabled"; | ||
1498 | } else { | ||
1499 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag); | ||
1500 | if (qc && (qc->tf.flags & ATA_TFLAG_POLLING)) | ||
1501 | when = " while polling"; | ||
1502 | } | ||
1503 | ata_ehi_push_desc(ehi, "unexpected device interrupt%s", when); | ||
1504 | ehi->err_mask |= AC_ERR_OTHER; | ||
1505 | ehi->action |= ATA_EH_RESET; | ||
1506 | ata_port_freeze(ap); | ||
1507 | } | ||
1508 | |||
1460 | /** | 1509 | /** |
1461 | * mv_err_intr - Handle error interrupts on the port | 1510 | * mv_err_intr - Handle error interrupts on the port |
1462 | * @ap: ATA channel to manipulate | 1511 | * @ap: ATA channel to manipulate |
1463 | * @reset_allowed: bool: 0 == don't trigger from reset here | 1512 | * @qc: affected command (non-NCQ), or NULL |
1464 | * | 1513 | * |
1465 | * In most cases, just clear the interrupt and move on. However, | 1514 | * Most cases require a full reset of the chip's state machine, |
1466 | * some cases require an eDMA reset, which also performs a COMRESET. | 1515 | * which also performs a COMRESET. |
1467 | * The SERR case requires a clear of pending errors in the SATA | 1516 | * Also, if the port disabled DMA, update our cached copy to match. |
1468 | * SERROR register. Finally, if the port disabled DMA, | ||
1469 | * update our cached copy to match. | ||
1470 | * | 1517 | * |
1471 | * LOCKING: | 1518 | * LOCKING: |
1472 | * Inherited from caller. | 1519 | * Inherited from caller. |
@@ -1477,28 +1524,24 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1477 | u32 edma_err_cause, eh_freeze_mask, serr = 0; | 1524 | u32 edma_err_cause, eh_freeze_mask, serr = 0; |
1478 | struct mv_port_priv *pp = ap->private_data; | 1525 | struct mv_port_priv *pp = ap->private_data; |
1479 | struct mv_host_priv *hpriv = ap->host->private_data; | 1526 | struct mv_host_priv *hpriv = ap->host->private_data; |
1480 | unsigned int edma_enabled = (pp->pp_flags & MV_PP_FLAG_EDMA_EN); | ||
1481 | unsigned int action = 0, err_mask = 0; | 1527 | unsigned int action = 0, err_mask = 0; |
1482 | struct ata_eh_info *ehi = &ap->link.eh_info; | 1528 | struct ata_eh_info *ehi = &ap->link.eh_info; |
1483 | 1529 | ||
1484 | ata_ehi_clear_desc(ehi); | 1530 | ata_ehi_clear_desc(ehi); |
1485 | 1531 | ||
1486 | if (!edma_enabled) { | 1532 | /* |
1487 | /* just a guess: do we need to do this? should we | 1533 | * Read and clear the err_cause bits. This won't actually |
1488 | * expand this, and do it in all cases? | 1534 | * clear for some errors (eg. SError), but we will be doing |
1489 | */ | 1535 | * a hard reset in those cases regardless, which *will* clear it. |
1490 | sata_scr_read(&ap->link, SCR_ERROR, &serr); | 1536 | */ |
1491 | sata_scr_write_flush(&ap->link, SCR_ERROR, serr); | ||
1492 | } | ||
1493 | |||
1494 | edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | 1537 | edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); |
1538 | writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | ||
1495 | 1539 | ||
1496 | ata_ehi_push_desc(ehi, "edma_err 0x%08x", edma_err_cause); | 1540 | ata_ehi_push_desc(ehi, "edma_err_cause=%08x", edma_err_cause); |
1497 | 1541 | ||
1498 | /* | 1542 | /* |
1499 | * all generations share these EDMA error cause bits | 1543 | * All generations share these EDMA error cause bits: |
1500 | */ | 1544 | */ |
1501 | |||
1502 | if (edma_err_cause & EDMA_ERR_DEV) | 1545 | if (edma_err_cause & EDMA_ERR_DEV) |
1503 | err_mask |= AC_ERR_DEV; | 1546 | err_mask |= AC_ERR_DEV; |
1504 | if (edma_err_cause & (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR | | 1547 | if (edma_err_cause & (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR | |
@@ -1515,34 +1558,36 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1515 | action |= ATA_EH_RESET; | 1558 | action |= ATA_EH_RESET; |
1516 | } | 1559 | } |
1517 | 1560 | ||
1561 | /* | ||
1562 | * Gen-I has a different SELF_DIS bit, | ||
1563 | * different FREEZE bits, and no SERR bit: | ||
1564 | */ | ||
1518 | if (IS_GEN_I(hpriv)) { | 1565 | if (IS_GEN_I(hpriv)) { |
1519 | eh_freeze_mask = EDMA_EH_FREEZE_5; | 1566 | eh_freeze_mask = EDMA_EH_FREEZE_5; |
1520 | |||
1521 | if (edma_err_cause & EDMA_ERR_SELF_DIS_5) { | 1567 | if (edma_err_cause & EDMA_ERR_SELF_DIS_5) { |
1522 | pp = ap->private_data; | ||
1523 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; | 1568 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; |
1524 | ata_ehi_push_desc(ehi, "EDMA self-disable"); | 1569 | ata_ehi_push_desc(ehi, "EDMA self-disable"); |
1525 | } | 1570 | } |
1526 | } else { | 1571 | } else { |
1527 | eh_freeze_mask = EDMA_EH_FREEZE; | 1572 | eh_freeze_mask = EDMA_EH_FREEZE; |
1528 | |||
1529 | if (edma_err_cause & EDMA_ERR_SELF_DIS) { | 1573 | if (edma_err_cause & EDMA_ERR_SELF_DIS) { |
1530 | pp = ap->private_data; | ||
1531 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; | 1574 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; |
1532 | ata_ehi_push_desc(ehi, "EDMA self-disable"); | 1575 | ata_ehi_push_desc(ehi, "EDMA self-disable"); |
1533 | } | 1576 | } |
1534 | |||
1535 | if (edma_err_cause & EDMA_ERR_SERR) { | 1577 | if (edma_err_cause & EDMA_ERR_SERR) { |
1536 | sata_scr_read(&ap->link, SCR_ERROR, &serr); | 1578 | /* |
1537 | sata_scr_write_flush(&ap->link, SCR_ERROR, serr); | 1579 | * Ensure that we read our own SCR, not a pmp link SCR: |
1538 | err_mask = AC_ERR_ATA_BUS; | 1580 | */ |
1581 | ap->ops->scr_read(ap, SCR_ERROR, &serr); | ||
1582 | /* | ||
1583 | * Don't clear SError here; leave it for libata-eh: | ||
1584 | */ | ||
1585 | ata_ehi_push_desc(ehi, "SError=%08x", serr); | ||
1586 | err_mask |= AC_ERR_ATA_BUS; | ||
1539 | action |= ATA_EH_RESET; | 1587 | action |= ATA_EH_RESET; |
1540 | } | 1588 | } |
1541 | } | 1589 | } |
1542 | 1590 | ||
1543 | /* Clear EDMA now that SERR cleanup done */ | ||
1544 | writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | ||
1545 | |||
1546 | if (!err_mask) { | 1591 | if (!err_mask) { |
1547 | err_mask = AC_ERR_OTHER; | 1592 | err_mask = AC_ERR_OTHER; |
1548 | action |= ATA_EH_RESET; | 1593 | action |= ATA_EH_RESET; |
@@ -1562,178 +1607,151 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
1562 | ata_port_abort(ap); | 1607 | ata_port_abort(ap); |
1563 | } | 1608 | } |
1564 | 1609 | ||
1565 | static void mv_intr_pio(struct ata_port *ap) | 1610 | static void mv_process_crpb_response(struct ata_port *ap, |
1611 | struct mv_crpb *response, unsigned int tag, int ncq_enabled) | ||
1566 | { | 1612 | { |
1567 | struct ata_queued_cmd *qc; | 1613 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); |
1568 | u8 ata_status; | ||
1569 | |||
1570 | /* ignore spurious intr if drive still BUSY */ | ||
1571 | ata_status = readb(ap->ioaddr.status_addr); | ||
1572 | if (unlikely(ata_status & ATA_BUSY)) | ||
1573 | return; | ||
1574 | 1614 | ||
1575 | /* get active ATA command */ | 1615 | if (qc) { |
1576 | qc = ata_qc_from_tag(ap, ap->link.active_tag); | 1616 | u8 ata_status; |
1577 | if (unlikely(!qc)) /* no active tag */ | 1617 | u16 edma_status = le16_to_cpu(response->flags); |
1578 | return; | 1618 | /* |
1579 | if (qc->tf.flags & ATA_TFLAG_POLLING) /* polling; we don't own qc */ | 1619 | * edma_status from a response queue entry: |
1580 | return; | 1620 | * LSB is from EDMA_ERR_IRQ_CAUSE_OFS (non-NCQ only). |
1581 | 1621 | * MSB is saved ATA status from command completion. | |
1582 | /* and finally, complete the ATA command */ | 1622 | */ |
1583 | qc->err_mask |= ac_err_mask(ata_status); | 1623 | if (!ncq_enabled) { |
1584 | ata_qc_complete(qc); | 1624 | u8 err_cause = edma_status & 0xff & ~EDMA_ERR_DEV; |
1625 | if (err_cause) { | ||
1626 | /* | ||
1627 | * Error will be seen/handled by mv_err_intr(). | ||
1628 | * So do nothing at all here. | ||
1629 | */ | ||
1630 | return; | ||
1631 | } | ||
1632 | } | ||
1633 | ata_status = edma_status >> CRPB_FLAG_STATUS_SHIFT; | ||
1634 | qc->err_mask |= ac_err_mask(ata_status); | ||
1635 | ata_qc_complete(qc); | ||
1636 | } else { | ||
1637 | ata_port_printk(ap, KERN_ERR, "%s: no qc for tag=%d\n", | ||
1638 | __func__, tag); | ||
1639 | } | ||
1585 | } | 1640 | } |
1586 | 1641 | ||
1587 | static void mv_intr_edma(struct ata_port *ap) | 1642 | static void mv_process_crpb_entries(struct ata_port *ap, struct mv_port_priv *pp) |
1588 | { | 1643 | { |
1589 | void __iomem *port_mmio = mv_ap_base(ap); | 1644 | void __iomem *port_mmio = mv_ap_base(ap); |
1590 | struct mv_host_priv *hpriv = ap->host->private_data; | 1645 | struct mv_host_priv *hpriv = ap->host->private_data; |
1591 | struct mv_port_priv *pp = ap->private_data; | 1646 | u32 in_index; |
1592 | struct ata_queued_cmd *qc; | ||
1593 | u32 out_index, in_index; | ||
1594 | bool work_done = false; | 1647 | bool work_done = false; |
1648 | int ncq_enabled = (pp->pp_flags & MV_PP_FLAG_NCQ_EN); | ||
1595 | 1649 | ||
1596 | /* get h/w response queue pointer */ | 1650 | /* Get the hardware queue position index */ |
1597 | in_index = (readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) | 1651 | in_index = (readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) |
1598 | >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK; | 1652 | >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK; |
1599 | 1653 | ||
1600 | while (1) { | 1654 | /* Process new responses from since the last time we looked */ |
1601 | u16 status; | 1655 | while (in_index != pp->resp_idx) { |
1602 | unsigned int tag; | 1656 | unsigned int tag; |
1657 | struct mv_crpb *response = &pp->crpb[pp->resp_idx]; | ||
1603 | 1658 | ||
1604 | /* get s/w response queue last-read pointer, and compare */ | 1659 | pp->resp_idx = (pp->resp_idx + 1) & MV_MAX_Q_DEPTH_MASK; |
1605 | out_index = pp->resp_idx & MV_MAX_Q_DEPTH_MASK; | ||
1606 | if (in_index == out_index) | ||
1607 | break; | ||
1608 | 1660 | ||
1609 | /* 50xx: get active ATA command */ | 1661 | if (IS_GEN_I(hpriv)) { |
1610 | if (IS_GEN_I(hpriv)) | 1662 | /* 50xx: no NCQ, only one command active at a time */ |
1611 | tag = ap->link.active_tag; | 1663 | tag = ap->link.active_tag; |
1612 | 1664 | } else { | |
1613 | /* Gen II/IIE: get active ATA command via tag, to enable | 1665 | /* Gen II/IIE: get command tag from CRPB entry */ |
1614 | * support for queueing. this works transparently for | 1666 | tag = le16_to_cpu(response->id) & 0x1f; |
1615 | * queued and non-queued modes. | ||
1616 | */ | ||
1617 | else | ||
1618 | tag = le16_to_cpu(pp->crpb[out_index].id) & 0x1f; | ||
1619 | |||
1620 | qc = ata_qc_from_tag(ap, tag); | ||
1621 | |||
1622 | /* For non-NCQ mode, the lower 8 bits of status | ||
1623 | * are from EDMA_ERR_IRQ_CAUSE_OFS, | ||
1624 | * which should be zero if all went well. | ||
1625 | */ | ||
1626 | status = le16_to_cpu(pp->crpb[out_index].flags); | ||
1627 | if ((status & 0xff) && !(pp->pp_flags & MV_PP_FLAG_NCQ_EN)) { | ||
1628 | mv_err_intr(ap, qc); | ||
1629 | return; | ||
1630 | } | ||
1631 | |||
1632 | /* and finally, complete the ATA command */ | ||
1633 | if (qc) { | ||
1634 | qc->err_mask |= | ||
1635 | ac_err_mask(status >> CRPB_FLAG_STATUS_SHIFT); | ||
1636 | ata_qc_complete(qc); | ||
1637 | } | 1667 | } |
1638 | 1668 | mv_process_crpb_response(ap, response, tag, ncq_enabled); | |
1639 | /* advance software response queue pointer, to | ||
1640 | * indicate (after the loop completes) to hardware | ||
1641 | * that we have consumed a response queue entry. | ||
1642 | */ | ||
1643 | work_done = true; | 1669 | work_done = true; |
1644 | pp->resp_idx++; | ||
1645 | } | 1670 | } |
1646 | 1671 | ||
1672 | /* Update the software queue position index in hardware */ | ||
1647 | if (work_done) | 1673 | if (work_done) |
1648 | writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) | | 1674 | writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) | |
1649 | (out_index << EDMA_RSP_Q_PTR_SHIFT), | 1675 | (pp->resp_idx << EDMA_RSP_Q_PTR_SHIFT), |
1650 | port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); | 1676 | port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); |
1651 | } | 1677 | } |
1652 | 1678 | ||
1653 | /** | 1679 | /** |
1654 | * mv_host_intr - Handle all interrupts on the given host controller | 1680 | * mv_host_intr - Handle all interrupts on the given host controller |
1655 | * @host: host specific structure | 1681 | * @host: host specific structure |
1656 | * @relevant: port error bits relevant to this host controller | 1682 | * @main_cause: Main interrupt cause register for the chip. |
1657 | * @hc: which host controller we're to look at | ||
1658 | * | ||
1659 | * Read then write clear the HC interrupt status then walk each | ||
1660 | * port connected to the HC and see if it needs servicing. Port | ||
1661 | * success ints are reported in the HC interrupt status reg, the | ||
1662 | * port error ints are reported in the higher level main | ||
1663 | * interrupt status register and thus are passed in via the | ||
1664 | * 'relevant' argument. | ||
1665 | * | 1683 | * |
1666 | * LOCKING: | 1684 | * LOCKING: |
1667 | * Inherited from caller. | 1685 | * Inherited from caller. |
1668 | */ | 1686 | */ |
1669 | static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc) | 1687 | static int mv_host_intr(struct ata_host *host, u32 main_cause) |
1670 | { | 1688 | { |
1671 | struct mv_host_priv *hpriv = host->private_data; | 1689 | struct mv_host_priv *hpriv = host->private_data; |
1672 | void __iomem *mmio = hpriv->base; | 1690 | void __iomem *mmio = hpriv->base, *hc_mmio = NULL; |
1673 | void __iomem *hc_mmio = mv_hc_base(mmio, hc); | 1691 | u32 hc_irq_cause = 0; |
1674 | u32 hc_irq_cause; | 1692 | unsigned int handled = 0, port; |
1675 | int port, port0, last_port; | ||
1676 | 1693 | ||
1677 | if (hc == 0) | 1694 | for (port = 0; port < hpriv->n_ports; port++) { |
1678 | port0 = 0; | ||
1679 | else | ||
1680 | port0 = MV_PORTS_PER_HC; | ||
1681 | |||
1682 | if (HAS_PCI(host)) | ||
1683 | last_port = port0 + MV_PORTS_PER_HC; | ||
1684 | else | ||
1685 | last_port = port0 + hpriv->n_ports; | ||
1686 | /* we'll need the HC success int register in most cases */ | ||
1687 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); | ||
1688 | if (!hc_irq_cause) | ||
1689 | return; | ||
1690 | |||
1691 | writelfl(~hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); | ||
1692 | |||
1693 | VPRINTK("ENTER, hc%u relevant=0x%08x HC IRQ cause=0x%08x\n", | ||
1694 | hc, relevant, hc_irq_cause); | ||
1695 | |||
1696 | for (port = port0; port < last_port; port++) { | ||
1697 | struct ata_port *ap = host->ports[port]; | 1695 | struct ata_port *ap = host->ports[port]; |
1698 | struct mv_port_priv *pp; | 1696 | struct mv_port_priv *pp; |
1699 | int have_err_bits, hard_port, shift; | 1697 | unsigned int shift, hardport, port_cause; |
1700 | 1698 | /* | |
1701 | if ((!ap) || (ap->flags & ATA_FLAG_DISABLED)) | 1699 | * When we move to the second hc, flag our cached |
1700 | * copies of hc_mmio (and hc_irq_cause) as invalid again. | ||
1701 | */ | ||
1702 | if (port == MV_PORTS_PER_HC) | ||
1703 | hc_mmio = NULL; | ||
1704 | /* | ||
1705 | * Do nothing if port is not interrupting or is disabled: | ||
1706 | */ | ||
1707 | MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport); | ||
1708 | port_cause = (main_cause >> shift) & (DONE_IRQ | ERR_IRQ); | ||
1709 | if (!port_cause || !ap || (ap->flags & ATA_FLAG_DISABLED)) | ||
1702 | continue; | 1710 | continue; |
1703 | 1711 | /* | |
1712 | * Each hc within the host has its own hc_irq_cause register. | ||
1713 | * We defer reading it until we know we need it, right now: | ||
1714 | * | ||
1715 | * FIXME later: we don't really need to read this register | ||
1716 | * (some logic changes required below if we go that way), | ||
1717 | * because it doesn't tell us anything new. But we do need | ||
1718 | * to write to it, outside the top of this loop, | ||
1719 | * to reset the interrupt triggers for next time. | ||
1720 | */ | ||
1721 | if (!hc_mmio) { | ||
1722 | hc_mmio = mv_hc_base_from_port(mmio, port); | ||
1723 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); | ||
1724 | writelfl(~hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); | ||
1725 | handled = 1; | ||
1726 | } | ||
1727 | /* | ||
1728 | * Process completed CRPB response(s) before other events. | ||
1729 | */ | ||
1704 | pp = ap->private_data; | 1730 | pp = ap->private_data; |
1705 | 1731 | if (hc_irq_cause & (DMA_IRQ << hardport)) { | |
1706 | shift = port << 1; /* (port * 2) */ | 1732 | if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) |
1707 | if (port >= MV_PORTS_PER_HC) | 1733 | mv_process_crpb_entries(ap, pp); |
1708 | shift++; /* skip bit 8 in the HC Main IRQ reg */ | ||
1709 | |||
1710 | have_err_bits = ((PORT0_ERR << shift) & relevant); | ||
1711 | |||
1712 | if (unlikely(have_err_bits)) { | ||
1713 | struct ata_queued_cmd *qc; | ||
1714 | |||
1715 | qc = ata_qc_from_tag(ap, ap->link.active_tag); | ||
1716 | if (qc && (qc->tf.flags & ATA_TFLAG_POLLING)) | ||
1717 | continue; | ||
1718 | |||
1719 | mv_err_intr(ap, qc); | ||
1720 | continue; | ||
1721 | } | 1734 | } |
1722 | 1735 | /* | |
1723 | hard_port = mv_hardport_from_port(port); /* range 0..3 */ | 1736 | * Handle chip-reported errors, or continue on to handle PIO. |
1724 | 1737 | */ | |
1725 | if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) { | 1738 | if (unlikely(port_cause & ERR_IRQ)) { |
1726 | if ((CRPB_DMA_DONE << hard_port) & hc_irq_cause) | 1739 | mv_err_intr(ap, mv_get_active_qc(ap)); |
1727 | mv_intr_edma(ap); | 1740 | } else if (hc_irq_cause & (DEV_IRQ << hardport)) { |
1728 | } else { | 1741 | if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) { |
1729 | if ((DEV_IRQ << hard_port) & hc_irq_cause) | 1742 | struct ata_queued_cmd *qc = mv_get_active_qc(ap); |
1730 | mv_intr_pio(ap); | 1743 | if (qc) { |
1744 | ata_sff_host_intr(ap, qc); | ||
1745 | continue; | ||
1746 | } | ||
1747 | } | ||
1748 | mv_unexpected_intr(ap); | ||
1731 | } | 1749 | } |
1732 | } | 1750 | } |
1733 | VPRINTK("EXIT\n"); | 1751 | return handled; |
1734 | } | 1752 | } |
1735 | 1753 | ||
1736 | static void mv_pci_error(struct ata_host *host, void __iomem *mmio) | 1754 | static int mv_pci_error(struct ata_host *host, void __iomem *mmio) |
1737 | { | 1755 | { |
1738 | struct mv_host_priv *hpriv = host->private_data; | 1756 | struct mv_host_priv *hpriv = host->private_data; |
1739 | struct ata_port *ap; | 1757 | struct ata_port *ap; |
@@ -1771,6 +1789,7 @@ static void mv_pci_error(struct ata_host *host, void __iomem *mmio) | |||
1771 | ata_port_freeze(ap); | 1789 | ata_port_freeze(ap); |
1772 | } | 1790 | } |
1773 | } | 1791 | } |
1792 | return 1; /* handled */ | ||
1774 | } | 1793 | } |
1775 | 1794 | ||
1776 | /** | 1795 | /** |
@@ -1791,41 +1810,23 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance) | |||
1791 | { | 1810 | { |
1792 | struct ata_host *host = dev_instance; | 1811 | struct ata_host *host = dev_instance; |
1793 | struct mv_host_priv *hpriv = host->private_data; | 1812 | struct mv_host_priv *hpriv = host->private_data; |
1794 | unsigned int hc, handled = 0, n_hcs; | 1813 | unsigned int handled = 0; |
1795 | void __iomem *mmio = hpriv->base; | 1814 | u32 main_cause, main_mask; |
1796 | u32 irq_stat, irq_mask; | ||
1797 | 1815 | ||
1798 | /* Note to self: &host->lock == &ap->host->lock == ap->lock */ | ||
1799 | spin_lock(&host->lock); | 1816 | spin_lock(&host->lock); |
1800 | 1817 | main_cause = readl(hpriv->main_cause_reg_addr); | |
1801 | irq_stat = readl(hpriv->main_cause_reg_addr); | 1818 | main_mask = readl(hpriv->main_mask_reg_addr); |
1802 | irq_mask = readl(hpriv->main_mask_reg_addr); | 1819 | /* |
1803 | 1820 | * Deal with cases where we either have nothing pending, or have read | |
1804 | /* check the cases where we either have nothing pending or have read | 1821 | * a bogus register value which can indicate HW removal or PCI fault. |
1805 | * a bogus register value which can indicate HW removal or PCI fault | ||
1806 | */ | 1822 | */ |
1807 | if (!(irq_stat & irq_mask) || (0xffffffffU == irq_stat)) | 1823 | if ((main_cause & main_mask) && (main_cause != 0xffffffffU)) { |
1808 | goto out_unlock; | 1824 | if (unlikely((main_cause & PCI_ERR) && HAS_PCI(host))) |
1809 | 1825 | handled = mv_pci_error(host, hpriv->base); | |
1810 | n_hcs = mv_get_hc_count(host->ports[0]->flags); | 1826 | else |
1811 | 1827 | handled = mv_host_intr(host, main_cause); | |
1812 | if (unlikely((irq_stat & PCI_ERR) && HAS_PCI(host))) { | ||
1813 | mv_pci_error(host, mmio); | ||
1814 | handled = 1; | ||
1815 | goto out_unlock; /* skip all other HC irq handling */ | ||
1816 | } | ||
1817 | |||
1818 | for (hc = 0; hc < n_hcs; hc++) { | ||
1819 | u32 relevant = irq_stat & (HC0_IRQ_PEND << (hc * HC_SHIFT)); | ||
1820 | if (relevant) { | ||
1821 | mv_host_intr(host, relevant, hc); | ||
1822 | handled = 1; | ||
1823 | } | ||
1824 | } | 1828 | } |
1825 | |||
1826 | out_unlock: | ||
1827 | spin_unlock(&host->lock); | 1829 | spin_unlock(&host->lock); |
1828 | |||
1829 | return IRQ_RETVAL(handled); | 1830 | return IRQ_RETVAL(handled); |
1830 | } | 1831 | } |
1831 | 1832 | ||
@@ -2109,13 +2110,6 @@ static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, | |||
2109 | printk(KERN_ERR DRV_NAME ": can't clear global reset\n"); | 2110 | printk(KERN_ERR DRV_NAME ": can't clear global reset\n"); |
2110 | rc = 1; | 2111 | rc = 1; |
2111 | } | 2112 | } |
2112 | /* | ||
2113 | * Temporary: wait 3 seconds before port-probing can happen, | ||
2114 | * so that we don't miss finding sleepy SilXXXX port-multipliers. | ||
2115 | * This can go away once hotplug is fully/correctly implemented. | ||
2116 | */ | ||
2117 | if (rc == 0) | ||
2118 | msleep(3000); | ||
2119 | done: | 2113 | done: |
2120 | return rc; | 2114 | return rc; |
2121 | } | 2115 | } |
@@ -2409,55 +2403,44 @@ static int mv_hardreset(struct ata_link *link, unsigned int *class, | |||
2409 | static void mv_eh_freeze(struct ata_port *ap) | 2403 | static void mv_eh_freeze(struct ata_port *ap) |
2410 | { | 2404 | { |
2411 | struct mv_host_priv *hpriv = ap->host->private_data; | 2405 | struct mv_host_priv *hpriv = ap->host->private_data; |
2412 | unsigned int hc = (ap->port_no > 3) ? 1 : 0; | 2406 | unsigned int shift, hardport, port = ap->port_no; |
2413 | u32 tmp, mask; | 2407 | u32 main_mask; |
2414 | unsigned int shift; | ||
2415 | 2408 | ||
2416 | /* FIXME: handle coalescing completion events properly */ | 2409 | /* FIXME: handle coalescing completion events properly */ |
2417 | 2410 | ||
2418 | shift = ap->port_no * 2; | 2411 | mv_stop_edma(ap); |
2419 | if (hc > 0) | 2412 | MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport); |
2420 | shift++; | ||
2421 | |||
2422 | mask = 0x3 << shift; | ||
2423 | 2413 | ||
2424 | /* disable assertion of portN err, done events */ | 2414 | /* disable assertion of portN err, done events */ |
2425 | tmp = readl(hpriv->main_mask_reg_addr); | 2415 | main_mask = readl(hpriv->main_mask_reg_addr); |
2426 | writelfl(tmp & ~mask, hpriv->main_mask_reg_addr); | 2416 | main_mask &= ~((DONE_IRQ | ERR_IRQ) << shift); |
2417 | writelfl(main_mask, hpriv->main_mask_reg_addr); | ||
2427 | } | 2418 | } |
2428 | 2419 | ||
2429 | static void mv_eh_thaw(struct ata_port *ap) | 2420 | static void mv_eh_thaw(struct ata_port *ap) |
2430 | { | 2421 | { |
2431 | struct mv_host_priv *hpriv = ap->host->private_data; | 2422 | struct mv_host_priv *hpriv = ap->host->private_data; |
2432 | void __iomem *mmio = hpriv->base; | 2423 | unsigned int shift, hardport, port = ap->port_no; |
2433 | unsigned int hc = (ap->port_no > 3) ? 1 : 0; | 2424 | void __iomem *hc_mmio = mv_hc_base_from_port(hpriv->base, port); |
2434 | void __iomem *hc_mmio = mv_hc_base(mmio, hc); | ||
2435 | void __iomem *port_mmio = mv_ap_base(ap); | 2425 | void __iomem *port_mmio = mv_ap_base(ap); |
2436 | u32 tmp, mask, hc_irq_cause; | 2426 | u32 main_mask, hc_irq_cause; |
2437 | unsigned int shift, hc_port_no = ap->port_no; | ||
2438 | 2427 | ||
2439 | /* FIXME: handle coalescing completion events properly */ | 2428 | /* FIXME: handle coalescing completion events properly */ |
2440 | 2429 | ||
2441 | shift = ap->port_no * 2; | 2430 | MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport); |
2442 | if (hc > 0) { | ||
2443 | shift++; | ||
2444 | hc_port_no -= 4; | ||
2445 | } | ||
2446 | |||
2447 | mask = 0x3 << shift; | ||
2448 | 2431 | ||
2449 | /* clear EDMA errors on this port */ | 2432 | /* clear EDMA errors on this port */ |
2450 | writel(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | 2433 | writel(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); |
2451 | 2434 | ||
2452 | /* clear pending irq events */ | 2435 | /* clear pending irq events */ |
2453 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); | 2436 | hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); |
2454 | hc_irq_cause &= ~(1 << hc_port_no); /* clear CRPB-done */ | 2437 | hc_irq_cause &= ~((DEV_IRQ | DMA_IRQ) << hardport); |
2455 | hc_irq_cause &= ~(1 << (hc_port_no + 8)); /* clear Device int */ | 2438 | writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); |
2456 | writel(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); | ||
2457 | 2439 | ||
2458 | /* enable assertion of portN err, done events */ | 2440 | /* enable assertion of portN err, done events */ |
2459 | tmp = readl(hpriv->main_mask_reg_addr); | 2441 | main_mask = readl(hpriv->main_mask_reg_addr); |
2460 | writelfl(tmp | mask, hpriv->main_mask_reg_addr); | 2442 | main_mask |= ((DONE_IRQ | ERR_IRQ) << shift); |
2443 | writelfl(main_mask, hpriv->main_mask_reg_addr); | ||
2461 | } | 2444 | } |
2462 | 2445 | ||
2463 | /** | 2446 | /** |
@@ -2668,19 +2651,17 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx) | |||
2668 | 2651 | ||
2669 | rc = mv_chip_id(host, board_idx); | 2652 | rc = mv_chip_id(host, board_idx); |
2670 | if (rc) | 2653 | if (rc) |
2671 | goto done; | 2654 | goto done; |
2672 | 2655 | ||
2673 | if (HAS_PCI(host)) { | 2656 | if (HAS_PCI(host)) { |
2674 | hpriv->main_cause_reg_addr = hpriv->base + | 2657 | hpriv->main_cause_reg_addr = mmio + HC_MAIN_IRQ_CAUSE_OFS; |
2675 | HC_MAIN_IRQ_CAUSE_OFS; | 2658 | hpriv->main_mask_reg_addr = mmio + HC_MAIN_IRQ_MASK_OFS; |
2676 | hpriv->main_mask_reg_addr = hpriv->base + HC_MAIN_IRQ_MASK_OFS; | ||
2677 | } else { | 2659 | } else { |
2678 | hpriv->main_cause_reg_addr = hpriv->base + | 2660 | hpriv->main_cause_reg_addr = mmio + HC_SOC_MAIN_IRQ_CAUSE_OFS; |
2679 | HC_SOC_MAIN_IRQ_CAUSE_OFS; | 2661 | hpriv->main_mask_reg_addr = mmio + HC_SOC_MAIN_IRQ_MASK_OFS; |
2680 | hpriv->main_mask_reg_addr = hpriv->base + | ||
2681 | HC_SOC_MAIN_IRQ_MASK_OFS; | ||
2682 | } | 2662 | } |
2683 | /* global interrupt mask */ | 2663 | |
2664 | /* global interrupt mask: 0 == mask everything */ | ||
2684 | writel(0, hpriv->main_mask_reg_addr); | 2665 | writel(0, hpriv->main_mask_reg_addr); |
2685 | 2666 | ||
2686 | n_hc = mv_get_hc_count(host->ports[0]->flags); | 2667 | n_hc = mv_get_hc_count(host->ports[0]->flags); |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 109b07495721..858f70610eda 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -1591,13 +1591,16 @@ static void nv_mcp55_thaw(struct ata_port *ap) | |||
1591 | static int nv_hardreset(struct ata_link *link, unsigned int *class, | 1591 | static int nv_hardreset(struct ata_link *link, unsigned int *class, |
1592 | unsigned long deadline) | 1592 | unsigned long deadline) |
1593 | { | 1593 | { |
1594 | unsigned int dummy; | 1594 | int rc; |
1595 | 1595 | ||
1596 | /* SATA hardreset fails to retrieve proper device signature on | 1596 | /* SATA hardreset fails to retrieve proper device signature on |
1597 | * some controllers. Don't classify on hardreset. For more | 1597 | * some controllers. Request follow up SRST. For more info, |
1598 | * info, see http://bugzilla.kernel.org/show_bug.cgi?id=3352 | 1598 | * see http://bugzilla.kernel.org/show_bug.cgi?id=3352 |
1599 | */ | 1599 | */ |
1600 | return sata_sff_hardreset(link, &dummy, deadline); | 1600 | rc = sata_sff_hardreset(link, class, deadline); |
1601 | if (rc) | ||
1602 | return rc; | ||
1603 | return -EAGAIN; | ||
1601 | } | 1604 | } |
1602 | 1605 | ||
1603 | static void nv_adma_error_handler(struct ata_port *ap) | 1606 | static void nv_adma_error_handler(struct ata_port *ap) |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index 6b8e45ba32e8..1010b3069bd5 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -142,7 +142,7 @@ static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
142 | u8 pmr; | 142 | u8 pmr; |
143 | 143 | ||
144 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ | 144 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ |
145 | return 0xffffffff; | 145 | return -EINVAL; |
146 | 146 | ||
147 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 147 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
148 | 148 | ||
@@ -158,14 +158,14 @@ static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | |||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static void sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | 161 | static int sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) |
162 | { | 162 | { |
163 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 163 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
164 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); | 164 | unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); |
165 | u8 pmr; | 165 | u8 pmr; |
166 | 166 | ||
167 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ | 167 | if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ |
168 | return; | 168 | return -EINVAL; |
169 | 169 | ||
170 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 170 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
171 | 171 | ||
@@ -174,6 +174,8 @@ static void sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
174 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || | 174 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || |
175 | (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED)) | 175 | (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED)) |
176 | pci_write_config_dword(pdev, cfg_addr+0x10, val); | 176 | pci_write_config_dword(pdev, cfg_addr+0x10, val); |
177 | |||
178 | return 0; | ||
177 | } | 179 | } |
178 | 180 | ||
179 | static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) | 181 | static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) |
@@ -211,14 +213,14 @@ static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
211 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 213 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
212 | 214 | ||
213 | if (ap->flags & SIS_FLAG_CFGSCR) | 215 | if (ap->flags & SIS_FLAG_CFGSCR) |
214 | sis_scr_cfg_write(ap, sc_reg, val); | 216 | return sis_scr_cfg_write(ap, sc_reg, val); |
215 | else { | 217 | else { |
216 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); | 218 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); |
217 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || | 219 | if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || |
218 | (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED)) | 220 | (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED)) |
219 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10); | 221 | iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10); |
222 | return 0; | ||
220 | } | 223 | } |
221 | return 0; | ||
222 | } | 224 | } |
223 | 225 | ||
224 | static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 226 | static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 474162cdf665..420fcb78a7cd 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -409,9 +409,13 @@ out: | |||
409 | return -ENODEV; | 409 | return -ENODEV; |
410 | } | 410 | } |
411 | 411 | ||
412 | /* work with hotplug and coldplug */ | ||
413 | MODULE_ALIAS("platform:palm_bk3710"); | ||
414 | |||
412 | static struct platform_driver platform_bk_driver = { | 415 | static struct platform_driver platform_bk_driver = { |
413 | .driver = { | 416 | .driver = { |
414 | .name = "palm_bk3710", | 417 | .name = "palm_bk3710", |
418 | .owner = THIS_MODULE, | ||
415 | }, | 419 | }, |
416 | .probe = palm_bk3710_probe, | 420 | .probe = palm_bk3710_probe, |
417 | .remove = NULL, | 421 | .remove = NULL, |
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index 249651e2da42..361b1bb544bf 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -130,6 +130,7 @@ static int __devexit plat_ide_remove(struct platform_device *pdev) | |||
130 | static struct platform_driver platform_ide_driver = { | 130 | static struct platform_driver platform_ide_driver = { |
131 | .driver = { | 131 | .driver = { |
132 | .name = "pata_platform", | 132 | .name = "pata_platform", |
133 | .owner = THIS_MODULE, | ||
133 | }, | 134 | }, |
134 | .probe = plat_ide_probe, | 135 | .probe = plat_ide_probe, |
135 | .remove = __devexit_p(plat_ide_remove), | 136 | .remove = __devexit_p(plat_ide_remove), |
@@ -147,6 +148,7 @@ static void __exit platform_ide_exit(void) | |||
147 | 148 | ||
148 | MODULE_DESCRIPTION("Platform IDE driver"); | 149 | MODULE_DESCRIPTION("Platform IDE driver"); |
149 | MODULE_LICENSE("GPL"); | 150 | MODULE_LICENSE("GPL"); |
151 | MODULE_ALIAS("platform:pata_platform"); | ||
150 | 152 | ||
151 | module_init(platform_ide_init); | 153 | module_init(platform_ide_init); |
152 | module_exit(platform_ide_exit); | 154 | module_exit(platform_ide_exit); |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 07ed56f7a767..395a523d8c30 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -847,7 +847,6 @@ static inline int ata_port_is_dummy(struct ata_port *ap) | |||
847 | return ap->ops == &ata_dummy_port_ops; | 847 | return ap->ops == &ata_dummy_port_ops; |
848 | } | 848 | } |
849 | 849 | ||
850 | extern void sata_print_link_status(struct ata_link *link); | ||
851 | extern void ata_port_probe(struct ata_port *); | 850 | extern void ata_port_probe(struct ata_port *); |
852 | extern int sata_set_spd(struct ata_link *link); | 851 | extern int sata_set_spd(struct ata_link *link); |
853 | extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); | 852 | extern int ata_std_prereset(struct ata_link *link, unsigned long deadline); |