mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
pata_hpt{37x|3x2n}: fix timing register masks (take 2)
These drivers inherited from the older 'hpt366' IDE driver the buggy timing register masks in their set_piomode() metods. As a result, too low command cycle active time is programmed for slow PIO modes. Quite fortunately, it's later "fixed up" by the set_dmamode() methods which also "helpfully" reprogram the command timings, usually to PIO mode 4; unfortunately, setting an UltraDMA mode #N also reprograms already set PIO data timings, usually to MWDMA mode # max(N, 2) timings... However, the drivers added some breakage of their own too: the bit that they set/clear to control the FIFO is sometimes wrong -- it's actually the MSB of the command cycle setup time; also, setting it in DMA mode is wrong as this bit is only for PIO actually and clearing it for PIO modes is not needed as no mode in any timing table has it set... Fix all this, inverting the masks while at it, like in the 'hpt366' and 'pata_hpt366' drivers; bump the drivers' versions, accounting for recent patches that forgot to do it... Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: stable@kernel.org Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
This commit is contained in:
parent
8e182a90f9
commit
5600c70e57
@ -24,7 +24,7 @@
|
|||||||
#include <linux/libata.h>
|
#include <linux/libata.h>
|
||||||
|
|
||||||
#define DRV_NAME "pata_hpt37x"
|
#define DRV_NAME "pata_hpt37x"
|
||||||
#define DRV_VERSION "0.6.12"
|
#define DRV_VERSION "0.6.14"
|
||||||
|
|
||||||
struct hpt_clock {
|
struct hpt_clock {
|
||||||
u8 xfer_speed;
|
u8 xfer_speed;
|
||||||
@ -411,9 +411,8 @@ static void hpt370_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
|
|
||||||
pci_read_config_dword(pdev, addr1, ®);
|
pci_read_config_dword(pdev, addr1, ®);
|
||||||
mode = hpt37x_find_mode(ap, adev->pio_mode);
|
mode = hpt37x_find_mode(ap, adev->pio_mode);
|
||||||
mode &= ~0x8000000; /* No FIFO in PIO */
|
mode &= 0xCFC3FFFF; /* Leave DMA bits alone */
|
||||||
mode &= ~0x30070000; /* Leave config bits alone */
|
reg &= ~0xCFC3FFFF; /* Strip timing bits */
|
||||||
reg &= 0x30070000; /* Strip timing bits */
|
|
||||||
pci_write_config_dword(pdev, addr1, reg | mode);
|
pci_write_config_dword(pdev, addr1, reg | mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,8 +429,7 @@ static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
u32 addr1, addr2;
|
u32 addr1, addr2;
|
||||||
u32 reg;
|
u32 reg, mode, mask;
|
||||||
u32 mode;
|
|
||||||
u8 fast;
|
u8 fast;
|
||||||
|
|
||||||
addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
|
addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
|
||||||
@ -443,11 +441,12 @@ static void hpt370_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
fast |= 0x01;
|
fast |= 0x01;
|
||||||
pci_write_config_byte(pdev, addr2, fast);
|
pci_write_config_byte(pdev, addr2, fast);
|
||||||
|
|
||||||
|
mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
|
||||||
|
|
||||||
pci_read_config_dword(pdev, addr1, ®);
|
pci_read_config_dword(pdev, addr1, ®);
|
||||||
mode = hpt37x_find_mode(ap, adev->dma_mode);
|
mode = hpt37x_find_mode(ap, adev->dma_mode);
|
||||||
mode |= 0x8000000; /* FIFO in MWDMA or UDMA */
|
mode &= mask;
|
||||||
mode &= ~0xC0000000; /* Leave config bits alone */
|
reg &= ~mask;
|
||||||
reg &= 0xC0000000; /* Strip timing bits */
|
|
||||||
pci_write_config_dword(pdev, addr1, reg | mode);
|
pci_write_config_dword(pdev, addr1, reg | mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,9 +514,8 @@ static void hpt372_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
mode = hpt37x_find_mode(ap, adev->pio_mode);
|
mode = hpt37x_find_mode(ap, adev->pio_mode);
|
||||||
|
|
||||||
printk("Find mode for %d reports %X\n", adev->pio_mode, mode);
|
printk("Find mode for %d reports %X\n", adev->pio_mode, mode);
|
||||||
mode &= ~0x80000000; /* No FIFO in PIO */
|
mode &= 0xCFC3FFFF; /* Leave DMA bits alone */
|
||||||
mode &= ~0x30070000; /* Leave config bits alone */
|
reg &= ~0xCFC3FFFF; /* Strip timing bits */
|
||||||
reg &= 0x30070000; /* Strip timing bits */
|
|
||||||
pci_write_config_dword(pdev, addr1, reg | mode);
|
pci_write_config_dword(pdev, addr1, reg | mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,8 +532,7 @@ static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
u32 addr1, addr2;
|
u32 addr1, addr2;
|
||||||
u32 reg;
|
u32 reg, mode, mask;
|
||||||
u32 mode;
|
|
||||||
u8 fast;
|
u8 fast;
|
||||||
|
|
||||||
addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
|
addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
|
||||||
@ -546,12 +543,13 @@ static void hpt372_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
fast &= ~0x07;
|
fast &= ~0x07;
|
||||||
pci_write_config_byte(pdev, addr2, fast);
|
pci_write_config_byte(pdev, addr2, fast);
|
||||||
|
|
||||||
|
mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
|
||||||
|
|
||||||
pci_read_config_dword(pdev, addr1, ®);
|
pci_read_config_dword(pdev, addr1, ®);
|
||||||
mode = hpt37x_find_mode(ap, adev->dma_mode);
|
mode = hpt37x_find_mode(ap, adev->dma_mode);
|
||||||
printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode);
|
printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode);
|
||||||
mode &= ~0xC0000000; /* Leave config bits alone */
|
mode &= mask;
|
||||||
mode |= 0x80000000; /* FIFO in MWDMA or UDMA */
|
reg &= ~mask;
|
||||||
reg &= 0xC0000000; /* Strip timing bits */
|
|
||||||
pci_write_config_dword(pdev, addr1, reg | mode);
|
pci_write_config_dword(pdev, addr1, reg | mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <linux/libata.h>
|
#include <linux/libata.h>
|
||||||
|
|
||||||
#define DRV_NAME "pata_hpt3x2n"
|
#define DRV_NAME "pata_hpt3x2n"
|
||||||
#define DRV_VERSION "0.3.4"
|
#define DRV_VERSION "0.3.7"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
HPT_PCI_FAST = (1 << 31),
|
HPT_PCI_FAST = (1 << 31),
|
||||||
@ -188,9 +188,8 @@ static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
|
|
||||||
pci_read_config_dword(pdev, addr1, ®);
|
pci_read_config_dword(pdev, addr1, ®);
|
||||||
mode = hpt3x2n_find_mode(ap, adev->pio_mode);
|
mode = hpt3x2n_find_mode(ap, adev->pio_mode);
|
||||||
mode &= ~0x8000000; /* No FIFO in PIO */
|
mode &= 0xCFC3FFFF; /* Leave DMA bits alone */
|
||||||
mode &= ~0x30070000; /* Leave config bits alone */
|
reg &= ~0xCFC3FFFF; /* Strip timing bits */
|
||||||
reg &= 0x30070000; /* Strip timing bits */
|
|
||||||
pci_write_config_dword(pdev, addr1, reg | mode);
|
pci_write_config_dword(pdev, addr1, reg | mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +206,7 @@ static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
||||||
u32 addr1, addr2;
|
u32 addr1, addr2;
|
||||||
u32 reg;
|
u32 reg, mode, mask;
|
||||||
u32 mode;
|
|
||||||
u8 fast;
|
u8 fast;
|
||||||
|
|
||||||
addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
|
addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
|
||||||
@ -219,11 +217,12 @@ static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|||||||
fast &= ~0x07;
|
fast &= ~0x07;
|
||||||
pci_write_config_byte(pdev, addr2, fast);
|
pci_write_config_byte(pdev, addr2, fast);
|
||||||
|
|
||||||
|
mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
|
||||||
|
|
||||||
pci_read_config_dword(pdev, addr1, ®);
|
pci_read_config_dword(pdev, addr1, ®);
|
||||||
mode = hpt3x2n_find_mode(ap, adev->dma_mode);
|
mode = hpt3x2n_find_mode(ap, adev->dma_mode);
|
||||||
mode |= 0x8000000; /* FIFO in MWDMA or UDMA */
|
mode &= mask;
|
||||||
mode &= ~0xC0000000; /* Leave config bits alone */
|
reg &= ~mask;
|
||||||
reg &= 0xC0000000; /* Strip timing bits */
|
|
||||||
pci_write_config_dword(pdev, addr1, reg | mode);
|
pci_write_config_dword(pdev, addr1, reg | mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user