linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, albertcc@tw.ibm.com,
	linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 5/7] libata: implement ata_down_xfermask_limit()
Date: Sun, 2 Apr 2006 17:54:46 +0900	[thread overview]
Message-ID: <11439680864033-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11439680863256-git-send-email-htejun@gmail.com>

Implement ata_down_xfermask_limit().  This function manipulates
@dev->pio/mwdma/udma_mask such that the next lower transfer mode is
selected.  This will be used to improve ata_bus_probe() failure
handling and later by EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   52 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

be65a1d4949d11d333866d10f79e6ef2165dd3cb
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index dfa2b36..42a3147 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -65,6 +65,8 @@ static unsigned int ata_dev_init_params(
 					struct ata_device *dev,
 					u16 heads,
 					u16 sectors);
+static int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
+				   int force_pio0);
 static int ata_down_sata_spd_limit(struct ata_port *ap);
 static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
 static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
@@ -1859,6 +1861,56 @@ int ata_timing_compute(struct ata_device
 	return 0;
 }
 
+/**
+ *	ata_down_xfermask_limit - adjust dev xfer masks downward
+ *	@ap: Port associated with device @dev
+ *	@dev: Device to adjust xfer masks
+ *	@force_pio0: Force PIO0
+ *
+ *	Adjust xfer masks of @dev downward.  Note that this function
+ *	does not apply the change.  Invoking ata_set_mode() afterwards
+ *	will apply the limit.
+ *
+ *	LOCKING:
+ *	Inherited from caller.
+ *
+ *	RETURNS:
+ *	0 on success, negative errno on failure
+ */
+static int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
+				   int force_pio0)
+{
+	unsigned long xfer_mask;
+	int highbit;
+
+	xfer_mask = ata_pack_xfermask(dev->pio_mask, dev->mwdma_mask,
+				      dev->udma_mask);
+
+	if (!xfer_mask)
+		goto fail;
+	/* don't gear down to MWDMA from UDMA, go directly to PIO */
+	if (xfer_mask & ATA_MASK_UDMA)
+		xfer_mask &= ~ATA_MASK_MWDMA;
+
+	highbit = fls(xfer_mask) - 1;
+	xfer_mask &= ~(1 << highbit);
+	if (force_pio0)
+		xfer_mask &= 1 << ATA_SHIFT_PIO;
+	if (!xfer_mask)
+		goto fail;
+
+	ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask,
+			    &dev->udma_mask);
+
+	printk(KERN_WARNING "ata%u: dev %u limiting speed to %s\n",
+	       ap->id, dev->devno, ata_mode_string(xfer_mask));
+
+	return 0;
+
+ fail:
+	return -EINVAL;
+}
+
 static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
 {
 	unsigned int err_mask;
-- 
1.2.4



  parent reply	other threads:[~2006-04-02  8:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-02  8:54 [PATCHSET] libata: improve ata_bus_probe failure handling, take 2 Tejun Heo
2006-04-02  8:54 ` [PATCH 4/7] libata: add 5s sleep between resets Tejun Heo
2006-04-02 11:55   ` Tejun Heo
2006-04-02  8:54 ` [PATCH 6/7] libata: improve ata_bus_probe() Tejun Heo
2006-04-02 10:47   ` Jeff Garzik
2006-04-02  8:54 ` [PATCH 3/7] libata: use SATA speed down in ata_drive_probe_reset() Tejun Heo
2006-04-02  8:54 ` Tejun Heo [this message]
2006-04-02  8:54 ` [PATCH 2/7] libata: implement ap->sata_spd_limit and helpers Tejun Heo
2006-04-02 10:43   ` Jeff Garzik
2006-04-02 11:04     ` Tejun Heo
2006-04-02 11:18       ` Jeff Garzik
2006-04-02 11:53         ` Tejun Heo
2006-04-02  8:54 ` [PATCH 1/7] libata: implement ata_dev_absent() Tejun Heo
2006-04-02  8:54 ` [PATCH 7/7] libata: consider disabled devices in ata_dev_xfermask() Tejun Heo
2006-04-02 14:35 ` [PATCHSET] libata: improve ata_bus_probe failure handling, take 2 Jeff Garzik
2006-04-03  9:37   ` Albert Lee
2006-04-03 10:38     ` Jeff Garzik
2006-04-03 14:37       ` Greg Freemyer
2006-04-03 16:20         ` Jeff Garzik
2006-04-04 13:02           ` Greg Freemyer
2006-04-04 13:11             ` Jeff Garzik
2006-04-04  5:02       ` Albert Lee
2006-04-03  9:43   ` [PATCH] libata-dev: irq-pio minor fix Albert Lee
2006-04-04 12:42     ` Jeff Garzik
2006-04-03 10:31   ` [PATCH] libata-dev: irq-pio minor fix 2 Albert Lee

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=11439680864033-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=albertcc@tw.ibm.com \
    --cc=jgarzik@pobox.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).