From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Alan <alan@lxorguk.ukuu.org.uk>
Cc: linux-ide@vger.kernel.org
Subject: Re: [RFC] libata IORDY handling
Date: Mon, 29 Jan 2007 17:28:19 +0300 [thread overview]
Message-ID: <45BE0483.4070409@ru.mvista.com> (raw)
In-Reply-To: <20070129133423.75aa208e@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 764 bytes --]
Hello.
Alan wrote:
>> It's sad to say but there's another bug in this function (even a
>>regression from drivers/ide/pci/siimage.c) -- the 16-bit IORDY is not enabled
>>when setting PIO mode (there's code that twiddles IORDY enable but that's
>>actually only for *taskfile* accesses, 16-bit IORDY is controlled by the same
>>PCI config. registers 80h/84h that enable DMA/UDMA transfer on SiI 680).
> Fixed - also fixed clearing the bits when going into PIO mode from DMA,
> which fixes a potential DMA changedown bug.
Yeah, this is an issue in siimage.c...
> Also redone the iordy stuff as your emails reminded me that it needed
> finishing off and sorting out.
Atttaching my (already obsolete) patch, just in case...
> Alan
MBR, Sergei
[-- Attachment #2: sil680_iordy-fixes.patch --]
[-- Type: text/x-patch, Size: 1895 bytes --]
Index: linux-2.6/drivers/ata/pata_sil680.c
===================================================================
--- linux-2.6.orig/drivers/ata/pata_sil680.c
+++ linux-2.6/drivers/ata/pata_sil680.c
@@ -139,9 +139,12 @@ static void sil680_set_piomode(struct at
unsigned long tfaddr = sil680_selreg(ap, 0x02);
unsigned long addr = sil680_seldev(ap, adev, 0x04);
+ unsigned long addr_mask = 0x80 + 4 * ap->port_no;
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+ int port_shift = adev->devno * 4;
int pio = adev->pio_mode - XFER_PIO_0;
int lowest_pio = pio;
+ u8 mode;
u16 reg;
struct ata_device *pair = ata_dev_pair(adev);
@@ -152,11 +155,31 @@ static void sil680_set_piomode(struct at
pci_write_config_word(pdev, addr, speed_p[pio]);
pci_write_config_word(pdev, tfaddr, speed_t[lowest_pio]);
- pci_read_config_word(pdev, tfaddr-2, ®);
- reg &= ~0x0200; /* Clear IORDY */
+ /*
+ * Let's see if we need to enable IORDY checking on data transfer...
+ *
+ * NOTE: Selecting any DMA mode also enables IORDY checkign,
+ * so we must first check if not already in DMA mode beforehand
+ * to avoid disabling it...
+ */
+ pci_read_config_byte(pdev, addr_mask, &mode);
+ if (ata_pio_need_iordy(adev) && ((mode >> port_shift) & 0x03) == 0x00)
+ mode |= 0x01 << port_shift;
+ else if (((mode >> port_shift) & 0x03) == 0x01)
+ mode &= ~(0x03 << port_shift);
+ pci_write_config_byte(pdev, addr_mask, mode);
+
+ /*
+ * Let's see if we need to enable IORDY checking on taskfile.
+ *
+ * NOTE: We can only disable IORDY if both drives agree to it.
+ */
+ pci_read_config_word(pdev, tfaddr - 2, ®);
if (ata_pio_need_iordy(adev))
- reg |= 0x0200; /* Enable IORDY */
- pci_write_config_word(pdev, tfaddr-2, reg);
+ reg |= 0x0200;
+ else if (pair == NULL || !ata_pio_need_iordy(pair))
+ reg &= ~0x0200;
+ pci_write_config_word(pdev, tfaddr - 2, reg);
}
/**
next prev parent reply other threads:[~2007-01-29 14:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-28 17:24 [PATCH] pata_sil680: PIO1 taskfile transfers oveclocking fix Sergei Shtylyov
2007-01-28 18:22 ` [RFC] libata IORDY handling Sergei Shtylyov
2007-01-28 19:03 ` Alan
2007-01-28 19:00 ` Sergei Shtylyov
2007-01-29 13:34 ` Alan
2007-01-29 14:28 ` Sergei Shtylyov [this message]
2007-01-29 15:45 ` Alan
2007-01-28 18:41 ` [PATCH] pata_sil680: PIO1 taskfile transfers oveclocking fix Alan
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=45BE0483.4070409@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=alan@lxorguk.ukuu.org.uk \
--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).