aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-05-18 12:15:07 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-05-19 17:51:47 -0400
commitdc98c32cbe80750ae2d9d9fbdae305d38f005de7 (patch)
tree52bff671e5ed5b39056bb4a5c531476c83e9f708 /drivers/ata
parent932648b007de76badc61c1b13d7282288dbe887e (diff)
libata: move reset freeze/thaw handling into ata_eh_reset()
Previously reset freeze/thaw handling lived outside of ata_eh_reset() mainly because the original PMP reset code needed the port frozen while resetting all the fan-out ports, which is no longer the case. This patch moves freeze/thaw handling into ata_eh_reset(). @prereset() and @postreset() are now called w/o freezing the port although @prereset() an be called frozen if the port is frozen prior to entering ata_eh_reset(). This makes code simpler and will help removing hotplug event related races. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-eh.c46
-rw-r--r--drivers/ata/libata-pmp.c4
2 files changed, 18 insertions, 32 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index a34adc2c85df..06a92c58a49d 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2170,6 +2170,9 @@ int ata_eh_reset(struct ata_link *link, int classify,
2170 /* 2170 /*
2171 * Perform reset 2171 * Perform reset
2172 */ 2172 */
2173 if (ata_is_host_link(link))
2174 ata_eh_freeze_port(ap);
2175
2173 deadline = jiffies + ata_eh_reset_timeouts[try++]; 2176 deadline = jiffies + ata_eh_reset_timeouts[try++];
2174 2177
2175 if (reset) { 2178 if (reset) {
@@ -2238,6 +2241,10 @@ int ata_eh_reset(struct ata_link *link, int classify,
2238 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) 2241 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2239 link->sata_spd = (sstatus >> 4) & 0xf; 2242 link->sata_spd = (sstatus >> 4) & 0xf;
2240 2243
2244 /* thaw the port */
2245 if (ata_is_host_link(link))
2246 ata_eh_thaw_port(ap);
2247
2241 if (postreset) 2248 if (postreset)
2242 postreset(link, classes); 2249 postreset(link, classes);
2243 2250
@@ -2589,7 +2596,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2589 struct ata_link *link; 2596 struct ata_link *link;
2590 struct ata_device *dev; 2597 struct ata_device *dev;
2591 int nr_failed_devs, nr_disabled_devs; 2598 int nr_failed_devs, nr_disabled_devs;
2592 int reset, rc; 2599 int rc;
2593 unsigned long flags; 2600 unsigned long flags;
2594 2601
2595 DPRINTK("ENTER\n"); 2602 DPRINTK("ENTER\n");
@@ -2632,7 +2639,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2632 rc = 0; 2639 rc = 0;
2633 nr_failed_devs = 0; 2640 nr_failed_devs = 0;
2634 nr_disabled_devs = 0; 2641 nr_disabled_devs = 0;
2635 reset = 0;
2636 2642
2637 /* if UNLOADING, finish immediately */ 2643 /* if UNLOADING, finish immediately */
2638 if (ap->pflags & ATA_PFLAG_UNLOADING) 2644 if (ap->pflags & ATA_PFLAG_UNLOADING)
@@ -2646,40 +2652,24 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2646 if (ata_eh_skip_recovery(link)) 2652 if (ata_eh_skip_recovery(link))
2647 ehc->i.action = 0; 2653 ehc->i.action = 0;
2648 2654
2649 /* do we need to reset? */
2650 if (ehc->i.action & ATA_EH_RESET)
2651 reset = 1;
2652
2653 ata_link_for_each_dev(dev, link) 2655 ata_link_for_each_dev(dev, link)
2654 ehc->classes[dev->devno] = ATA_DEV_UNKNOWN; 2656 ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
2655 } 2657 }
2656 2658
2657 /* reset */ 2659 /* reset */
2658 if (reset) { 2660 ata_port_for_each_link(link, ap) {
2659 /* if PMP is attached, this function only deals with 2661 struct ata_eh_context *ehc = &link->eh_context;
2660 * downstream links, port should stay thawed.
2661 */
2662 if (!sata_pmp_attached(ap))
2663 ata_eh_freeze_port(ap);
2664
2665 ata_port_for_each_link(link, ap) {
2666 struct ata_eh_context *ehc = &link->eh_context;
2667 2662
2668 if (!(ehc->i.action & ATA_EH_RESET)) 2663 if (!(ehc->i.action & ATA_EH_RESET))
2669 continue; 2664 continue;
2670 2665
2671 rc = ata_eh_reset(link, ata_link_nr_vacant(link), 2666 rc = ata_eh_reset(link, ata_link_nr_vacant(link),
2672 prereset, softreset, hardreset, 2667 prereset, softreset, hardreset, postreset);
2673 postreset); 2668 if (rc) {
2674 if (rc) { 2669 ata_link_printk(link, KERN_ERR,
2675 ata_link_printk(link, KERN_ERR, 2670 "reset failed, giving up\n");
2676 "reset failed, giving up\n"); 2671 goto out;
2677 goto out;
2678 }
2679 } 2672 }
2680
2681 if (!sata_pmp_attached(ap))
2682 ata_eh_thaw_port(ap);
2683 } 2673 }
2684 2674
2685 /* the rest */ 2675 /* the rest */
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index ff1822a7da38..f3ad024394c2 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -700,8 +700,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
700 if (ehc->i.action & ATA_EH_RESET) { 700 if (ehc->i.action & ATA_EH_RESET) {
701 struct ata_link *tlink; 701 struct ata_link *tlink;
702 702
703 ata_eh_freeze_port(ap);
704
705 /* reset */ 703 /* reset */
706 rc = ata_eh_reset(link, 0, prereset, softreset, hardreset, 704 rc = ata_eh_reset(link, 0, prereset, softreset, hardreset,
707 postreset); 705 postreset);
@@ -711,8 +709,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
711 goto fail; 709 goto fail;
712 } 710 }
713 711
714 ata_eh_thaw_port(ap);
715
716 /* PMP is reset, SErrors cannot be trusted, scan all */ 712 /* PMP is reset, SErrors cannot be trusted, scan all */
717 ata_port_for_each_link(tlink, ap) { 713 ata_port_for_each_link(tlink, ap) {
718 struct ata_eh_context *ehc = &tlink->eh_context; 714 struct ata_eh_context *ehc = &tlink->eh_context;