linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Mark Lord <mlord@pobox.com>, Art Haas <ahaas@airmail.net>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-ide@vger.kernel.org, Albert Lee <albertcc@tw.ibm.com>,
	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Subject: Re: [PATCH] ata_piix: fix pio/mwdma programming (for testing, don't apply)
Date: Tue, 06 Feb 2007 18:11:44 +0900	[thread overview]
Message-ID: <45C84650.3030703@gmail.com> (raw)
In-Reply-To: <45C4E6BB.6020307@pobox.com>

[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]

Mark Lord wrote:
> Tejun Heo wrote:
>> ..
>> Then, PACKET_IDENTIFY after configuring transfer mode fails with
>> -ENOENT.  Meaning it saw (status & (ATA_BUSY|ATA_DRQ|ATA_ERR|ATA_DF)) ==
>> 0 in HSM_ST.
> ..
>> So, PATA gurus, can you bless us with enlightenment?  :-)
> 
> Heh.. guaranteeing detection of all the strange implementations out there
> is part black magic.
> 
> But the simple thing to do here is, just for fun, hack the code
> to do the infamous 50 millisecond hard wait before issuing the
> PACKET_IDENTIFY.
> If that fixes it, then it's just a matter of tuning to discover the real
> amount of delay required, and a nicer way of doing the delay.

Okay.

> Also, zero out the features register before issuing PACKET_IDENTIFY,
> if the code isn't already doing that.

Okay.

> After the drive asserts BUSY, and later deasserts BUSY,
> there might be a slight delay before the drive asserts DRQ.
> So, it is possible for the status to read zeros in the important bits.
> 
> My suggestion is to wait up to the infamous 50 milliseconds again here,
> if needed.

Okay, the attached patch does what Mark suggested.  Art, can you please
give it a shot and report dmesg?  My thanks for sticking around till now.

-- 
tejun

[-- Attachment #2: wait-for-drq.patch --]
[-- Type: text/x-patch, Size: 1089 bytes --]

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 667acd2..4c81433 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1478,7 +1478,8 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
 	}
 
 	tf.protocol = ATA_PROT_PIO;
-	tf.flags |= ATA_TFLAG_POLLING; /* for polling presence detection */
+	/* POLLING for polling detection, ISADDR|DEVICE to clear TF */
+	tf.flags |= ATA_TFLAG_POLLING | ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
 
 	err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
 				     id, sizeof(id[0]) * ATA_ID_WORDS);
@@ -4477,6 +4478,18 @@ fsm_start:
 				goto fsm_start;
 
 		} else {
+			unsigned long timeout = jiffies + msecs_to_jiffies(50);
+
+			while (time_before(jiffies, timeout)) {
+				if (status & ATA_DRQ)
+					break;
+				ata_dev_printk(qc->dev, KERN_INFO,
+					"XXX: waiting for DRQ, status=0x%x\n",
+					status);
+				msleep(10);
+				status = ata_chk_status(ap);
+			}
+
 			/* ATA PIO protocol */
 			if (unlikely((status & ATA_DRQ) == 0)) {
 				/* handle BSY=0, DRQ=0 as error */

  reply	other threads:[~2007-02-06  9:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-02 15:18 [PATCH] ata_piix: fix pio/mwdma programming (for testing, don't apply) Tejun Heo
2007-02-02 15:34 ` Sergei Shtylyov
2007-02-02 16:38   ` Jeff Garzik
2007-02-02 16:57     ` Mark Lord
2007-02-02 18:34       ` Sergei Shtylyov
2007-02-02 16:41   ` Tejun Heo
2007-02-02 18:49     ` Alan
2007-02-02 19:04       ` Sergei Shtylyov
2007-02-02 17:42 ` Alan
2007-02-03  1:40   ` Tejun Heo
2007-02-03 20:04     ` Alan
2007-02-04  2:47       ` Tejun Heo
2007-02-02 21:14 ` Art Haas
2007-02-03  2:09   ` Tejun Heo
2007-02-03 14:35     ` Art Haas
2007-02-03 19:47     ` Mark Lord
2007-02-06  9:11       ` Tejun Heo [this message]
2007-02-06 16:33         ` Art Haas
2007-02-07  2:53           ` Tejun Heo
2007-02-07 19:35             ` Art Haas
2007-02-07 19:51               ` Mark Lord
2007-02-07 20:37                 ` [PATCH] libata: clear TF before IDENTIFYing Tejun Heo
2007-02-08 14:56                   ` Mark Lord
2007-02-13 19:38                   ` Art Haas
2007-02-15 23:08                   ` Jeff Garzik
2007-04-30 18:29 ` [PATCH] Fix pio/mwdma programming on ata_piix.c Art Haas
2007-05-01  3:02   ` Tejun Heo
2007-05-24 19:59     ` Art Haas
2007-05-24 20:55       ` Jeff Garzik
2007-05-24 21:03         ` Tejun Heo
2007-05-25 17:16           ` [PATCH] ata_piix: fix pio/mwdma programming Tejun Heo
2007-05-25 18:05             ` Alan Cox
2007-05-28 13:02             ` Jeff Garzik

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=45C84650.3030703@gmail.com \
    --to=htejun@gmail.com \
    --cc=ahaas@airmail.net \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=albertcc@tw.ibm.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=mlord@pobox.com \
    --cc=sshtylyov@ru.mvista.com \
    /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).