All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jeff@garzik.org, linux-ide@vger.kernel.org
Cc: liml@rtr.ca, Tejun Heo <htejun@gmail.com>
Subject: [PATCH 03/10] libata: move reset freeze/thaw handling into ata_eh_reset()
Date: Mon, 19 May 2008 01:15:07 +0900	[thread overview]
Message-ID: <1211127315414-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <12111273141039-git-send-email-htejun@gmail.com>

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>
---
 drivers/ata/libata-eh.c  |   46 ++++++++++++++++++----------------------------
 drivers/ata/libata-pmp.c |    4 ----
 2 files changed, 18 insertions(+), 32 deletions(-)

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index a34adc2..06a92c5 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,
 	/*
 	 * Perform reset
 	 */
+	if (ata_is_host_link(link))
+		ata_eh_freeze_port(ap);
+
 	deadline = jiffies + ata_eh_reset_timeouts[try++];
 
 	if (reset) {
@@ -2238,6 +2241,10 @@ int ata_eh_reset(struct ata_link *link, int classify,
 	if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
 		link->sata_spd = (sstatus >> 4) & 0xf;
 
+	/* thaw the port */
+	if (ata_is_host_link(link))
+		ata_eh_thaw_port(ap);
+
 	if (postreset)
 		postreset(link, classes);
 
@@ -2589,7 +2596,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 	struct ata_link *link;
 	struct ata_device *dev;
 	int nr_failed_devs, nr_disabled_devs;
-	int reset, rc;
+	int rc;
 	unsigned long flags;
 
 	DPRINTK("ENTER\n");
@@ -2632,7 +2639,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 	rc = 0;
 	nr_failed_devs = 0;
 	nr_disabled_devs = 0;
-	reset = 0;
 
 	/* if UNLOADING, finish immediately */
 	if (ap->pflags & ATA_PFLAG_UNLOADING)
@@ -2646,40 +2652,24 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 		if (ata_eh_skip_recovery(link))
 			ehc->i.action = 0;
 
-		/* do we need to reset? */
-		if (ehc->i.action & ATA_EH_RESET)
-			reset = 1;
-
 		ata_link_for_each_dev(dev, link)
 			ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
 	}
 
 	/* reset */
-	if (reset) {
-		/* if PMP is attached, this function only deals with
-		 * downstream links, port should stay thawed.
-		 */
-		if (!sata_pmp_attached(ap))
-			ata_eh_freeze_port(ap);
-
-		ata_port_for_each_link(link, ap) {
-			struct ata_eh_context *ehc = &link->eh_context;
+	ata_port_for_each_link(link, ap) {
+		struct ata_eh_context *ehc = &link->eh_context;
 
-			if (!(ehc->i.action & ATA_EH_RESET))
-				continue;
+		if (!(ehc->i.action & ATA_EH_RESET))
+			continue;
 
-			rc = ata_eh_reset(link, ata_link_nr_vacant(link),
-					  prereset, softreset, hardreset,
-					  postreset);
-			if (rc) {
-				ata_link_printk(link, KERN_ERR,
-						"reset failed, giving up\n");
-				goto out;
-			}
+		rc = ata_eh_reset(link, ata_link_nr_vacant(link),
+				  prereset, softreset, hardreset, postreset);
+		if (rc) {
+			ata_link_printk(link, KERN_ERR,
+					"reset failed, giving up\n");
+			goto out;
 		}
-
-		if (!sata_pmp_attached(ap))
-			ata_eh_thaw_port(ap);
 	}
 
 	/* the rest */
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index ff1822a..f3ad024 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,
 	if (ehc->i.action & ATA_EH_RESET) {
 		struct ata_link *tlink;
 
-		ata_eh_freeze_port(ap);
-
 		/* reset */
 		rc = ata_eh_reset(link, 0, prereset, softreset, hardreset,
 				  postreset);
@@ -711,8 +709,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
 			goto fail;
 		}
 
-		ata_eh_thaw_port(ap);
-
 		/* PMP is reset, SErrors cannot be trusted, scan all */
 		ata_port_for_each_link(tlink, ap) {
 			struct ata_eh_context *ehc = &tlink->eh_context;
-- 
1.5.2.4


  parent reply	other threads:[~2008-05-18 16:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-18 16:15 [PATCHSET #upstream-fixes] libata: fix a bunch of PMP related problems Tejun Heo
2008-05-18 16:15 ` [PATCH 01/10] libata: fix sata_link_hardreset() @online out parameter handling Tejun Heo
2008-05-19 21:53   ` Jeff Garzik
2008-05-18 16:15 ` [PATCH 02/10] libata: reorganize ata_eh_reset() no reset method path Tejun Heo
2008-05-18 16:15 ` Tejun Heo [this message]
2008-05-18 16:15 ` [PATCH 04/10] libata: kill hotplug related race condition Tejun Heo
2008-05-18 16:15 ` [PATCH 05/10] libata: ignore recovered PHY errors Tejun Heo
2008-05-19 21:50   ` Jeff Garzik
2008-05-18 16:15 ` [PATCH 06/10] libata: increase PMP register access timeout to 3s Tejun Heo
2008-05-18 16:15 ` [PATCH 07/10] libata: make sure PMP notification is turned off during recovery Tejun Heo
2008-05-18 16:15 ` [PATCH 08/10] libata: don't schedule LPM action seperately during probing Tejun Heo
2008-05-18 16:15 ` [PATCH 09/10] sata_sil24: don't use NCQ if marvell 4140 PMP is attached Tejun Heo
2008-05-18 21:14   ` Mark Lord
2008-05-18 16:15 ` [PATCH 10/10] libata: ignore SIMG4726 config pseudo device Tejun Heo
2008-05-18 16:29 ` [PATCHSET #upstream-fixes] git tree available Tejun Heo
2008-05-20  1:35   ` Brian & Chamaigne Scamman
2008-05-20  2:58     ` Mark Lord
2008-05-20  4:28       ` Tejun Heo
2008-05-20  4:43         ` Tejun Heo
2008-05-21  1:32           ` Brian & Chamaigne Scamman
2008-05-21  4:59             ` Tejun Heo
2008-05-21 11:14               ` Brian & Chamaigne Scamman
2008-05-21 19:42               ` Brian & Chamaigne Scamman
2008-05-22  0:40                 ` Tejun Heo
2008-05-23  0:49                   ` Brian & Chamaigne Scamman
2008-05-23  1:04                     ` Tejun Heo
2008-05-29  3:06                       ` Tejun Heo
2008-05-29  3:11                         ` Brian & Chamaigne Scamman
2008-05-20 12:08         ` Brian & Chamaigne Scamman
2008-05-20 14:50           ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1211127315414-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=jeff@garzik.org \
    --cc=liml@rtr.ca \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.