* Re: Linux-2.5.18
2002-05-25 2:02 Linux-2.5.18 Linus Torvalds
2002-05-27 9:34 ` [PATCH] 2.5.18 IDE 71 Martin Dalecki
@ 2002-05-28 14:23 ` Martin Dalecki
2002-05-28 15:31 ` [PATCH] airo Martin Dalecki
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Martin Dalecki @ 2002-05-28 14:23 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 549 bytes --]
Mon May 27 12:37:58 CEST 2002 ide-clean-72
- Replace ide_delay_50m with mdelay(50). There is absolutely no reason we
should behave different behaviors whatever IDECS support is enabled or not.
- Kill last parameter of ide_register_hw(). It should return a pointer to the
interface registered later.
- pdc202xx patches by Bartomiej onierkiewicz.
- ServerWorks chi pset support cleanup by Andrej Panin.
- Move temporarily ide_setup_ports to main.c unfold it in ide-pnp.c.
I'm trying again to make the patch chunks a bit more palatable...
[-- Attachment #2: ide-clean-72.diff --]
[-- Type: text/plain, Size: 52417 bytes --]
diff -urN linux-2.5.18/drivers/ide/buddha.c linux/drivers/ide/buddha.c
--- linux-2.5.18/drivers/ide/buddha.c 2002-05-25 03:55:25.000000000 +0200
+++ linux/drivers/ide/buddha.c 2002-05-27 16:06:44.000000000 +0200
@@ -202,9 +202,9 @@
xsurf_offsets, 0,
(ide_ioreg_t)(buddha_board+xsurf_irqports[i]),
xsurf_ack_intr, IRQ_AMIGA_PORTS);
- }
-
- index = ide_register_hw(&hw, NULL);
+ }
+
+ index = ide_register_hw(&hw);
if (index != -1) {
printk("ide%d: ", index);
switch(type) {
diff -urN linux-2.5.18/drivers/ide/falconide.c linux/drivers/ide/falconide.c
--- linux-2.5.18/drivers/ide/falconide.c 2002-05-25 03:55:25.000000000 +0200
+++ linux/drivers/ide/falconide.c 2002-05-27 16:06:54.000000000 +0200
@@ -60,7 +60,7 @@
ide_setup_ports(&hw, (ide_ioreg_t)ATA_HD_BASE, falconide_offsets,
0, 0, NULL, IRQ_MFP_IDE);
- index = ide_register_hw(&hw, NULL);
+ index = ide_register_hw(&hw);
if (index != -1)
printk("ide%d: Falcon IDE interface\n", index);
diff -urN linux-2.5.18/drivers/ide/gayle.c linux/drivers/ide/gayle.c
--- linux-2.5.18/drivers/ide/gayle.c 2002-05-25 03:55:21.000000000 +0200
+++ linux/drivers/ide/gayle.c 2002-05-27 16:06:00.000000000 +0200
@@ -150,7 +150,7 @@
ide_setup_ports(&hw, base, gayle_offsets,
ctrlport, irqport, ack_intr, IRQ_AMIGA_PORTS);
- index = ide_register_hw(&hw, NULL);
+ index = ide_register_hw(&hw);
if (index != -1) {
switch (i) {
case 0:
diff -urN linux-2.5.18/drivers/ide/ide.c linux/drivers/ide/ide.c
--- linux-2.5.18/drivers/ide/ide.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/ide/ide.c 2002-05-28 13:21:53.000000000 +0200
@@ -151,6 +151,12 @@
return ret;
}
+/* This is the default end request function as well */
+int ide_end_request(struct ata_device *drive, struct request *rq, int uptodate)
+{
+ return __ide_end_request(drive, rq, uptodate, 0);
+}
+
/*
* This should get invoked any time we exit the driver to
* wait for an interrupt response from a drive. handler() points
@@ -508,7 +514,7 @@
printk("} ");
}
#else
-#define ata_dump_bits(msgs,nr,bits) do { } while (0)
+# define ata_dump_bits(msgs,nr,bits) do { } while (0)
#endif
/*
@@ -1517,36 +1523,6 @@
return 0;
}
-/*
- * Setup hw_regs_t structure described by parameters. You
- * may set up the hw structure yourself OR use this routine to
- * do it for you.
- */
-void ide_setup_ports(hw_regs_t *hw,
- ide_ioreg_t base, int *offsets,
- ide_ioreg_t ctrl, ide_ioreg_t intr,
- ide_ack_intr_t *ack_intr, int irq)
-{
- int i;
-
- for (i = 0; i < IDE_NR_PORTS; i++) {
- if (offsets[i] != -1)
- hw->io_ports[i] = base + offsets[i];
- else
- hw->io_ports[i] = 0;
- }
- if (offsets[IDE_CONTROL_OFFSET] == -1)
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl;
-/* FIMXE: check if we can remove this ifdef */
-#if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
- if (offsets[IDE_IRQ_OFFSET] == -1)
- hw->io_ports[IDE_IRQ_OFFSET] = intr;
-#endif
- hw->irq = irq;
- hw->dma = NO_DMA;
- hw->ack_intr = ack_intr;
-}
-
int ide_spin_wait_hwgroup(struct ata_device *drive)
{
/* FIXME: Wait on a proper timer. Instead of playing games on the
@@ -1572,24 +1548,6 @@
return 0;
}
-/*
- * Delay for *at least* 50ms. As we don't know how much time is left
- * until the next tick occurs, we wait an extra tick to be safe.
- * This is used only during the probing/polling for drives at boot time.
- *
- * However, its usefullness may be needed in other places, thus we export it now.
- * The future may change this to a millisecond setable delay.
- */
-void ide_delay_50ms (void)
-{
-#ifndef CONFIG_BLK_DEV_IDECS
- mdelay(50);
-#else
- __set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(HZ/20);
-#endif
-}
-
static int ide_check_media_change(kdev_t i_rdev)
{
struct ata_device *drive;
@@ -1638,12 +1596,6 @@
*p++ = '\0';
}
-/* This is the default end request function as well */
-int ide_end_request(struct ata_device *drive, struct request *rq, int uptodate)
-{
- return __ide_end_request(drive, rq, uptodate, 0);
-}
-
struct block_device_operations ide_fops[] = {{
owner: THIS_MODULE,
open: ide_open,
@@ -1669,7 +1621,6 @@
EXPORT_SYMBOL(ide_end_drive_cmd);
EXPORT_SYMBOL(__ide_end_request);
EXPORT_SYMBOL(ide_end_request);
-EXPORT_SYMBOL(ide_delay_50ms);
EXPORT_SYMBOL(ide_stall_queue);
EXPORT_SYMBOL(ide_setup_ports);
diff -urN linux-2.5.18/drivers/ide/ide-cs.c linux/drivers/ide/ide-cs.c
--- linux-2.5.18/drivers/ide/ide-cs.c 2002-05-25 03:55:23.000000000 +0200
+++ linux/drivers/ide/ide-cs.c 2002-05-27 16:06:29.000000000 +0200
@@ -233,7 +233,8 @@
ide_init_hwif_ports(&hw, (ide_ioreg_t) arg1, (ide_ioreg_t) arg2, NULL);
hw.irq = irq;
hw.chipset = ide_pci; /* this enables IRQ sharing w/ PCI irqs */
- return ide_register_hw(&hw, NULL);
+
+ return ide_register_hw(&hw);
}
void ide_config(dev_link_t *link)
diff -urN linux-2.5.18/drivers/ide/ide-features.c linux/drivers/ide/ide-features.c
--- linux-2.5.18/drivers/ide/ide-features.c 2002-05-25 03:55:28.000000000 +0200
+++ linux/drivers/ide/ide-features.c 2002-05-28 13:23:56.000000000 +0200
@@ -189,17 +189,19 @@
SELECT_MASK(drive->channel, drive, 1);
if (IDE_CONTROL_REG)
OUT_BYTE(drive->ctl,IDE_CONTROL_REG);
- ide_delay_50ms();
+ mdelay(50);
OUT_BYTE(WIN_IDENTIFY, IDE_COMMAND_REG);
timeout = jiffies + WAIT_WORSTCASE;
do {
- if (0 < (signed long)(jiffies - timeout)) {
+ if (time_after(jiffies, timeout)) {
SELECT_MASK(drive->channel, drive, 0);
return 0; /* drive timed-out */
}
- ide_delay_50ms(); /* give drive a breather */
+ mdelay(50); /* give drive a breather */
} while (IN_BYTE(IDE_ALTSTATUS_REG) & BUSY_STAT);
- ide_delay_50ms(); /* wait for IRQ and DRQ_STAT */
+
+ mdelay(50); /* wait for IRQ and DRQ_STAT */
+
if (!OK_STAT(GET_STAT(),DRQ_STAT,BAD_R_STAT)) {
SELECT_MASK(drive->channel, drive, 0);
printk("%s: CHECK for good STATUS\n", drive->name);
diff -urN linux-2.5.18/drivers/ide/ide-pci.c linux/drivers/ide/ide-pci.c
--- linux-2.5.18/drivers/ide/ide-pci.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/ide/ide-pci.c 2002-05-28 11:19:39.000000000 +0200
@@ -351,7 +351,7 @@
base = port ? 0x170 : 0x1f0;
if ((ch = lookup_channel(base, d->bootable, dev->name)) == NULL)
- return -ENOMEM; /* no room in ide_hwifs[] */
+ return -ENOMEM; /* no room */
if (ch->io_ports[IDE_DATA_OFFSET] != base) {
ide_init_hwif_ports(&ch->hw, base, (ctl | 2), NULL);
diff -urN linux-2.5.18/drivers/ide/ide-pnp.c linux/drivers/ide/ide-pnp.c
--- linux-2.5.18/drivers/ide/ide-pnp.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/ide/ide-pnp.c 2002-05-28 12:44:00.000000000 +0200
@@ -32,29 +32,6 @@
#define DEV_NAME(dev) (dev->bus->name ? dev->bus->name : "ISA PnP")
-enum {
- GENERIC_HD_DATA,
- GENERIC_HD_ERROR,
- GENERIC_HD_NSECTOR,
- GENERIC_HD_SECTOR,
- GENERIC_HD_LCYL,
- GENERIC_HD_HCYL,
- GENERIC_HD_SELECT,
- GENERIC_HD_STATUS
-};
-
-static int generic_ide_offsets[IDE_NR_PORTS] __initdata = {
- GENERIC_HD_DATA,
- GENERIC_HD_ERROR,
- GENERIC_HD_NSECTOR,
- GENERIC_HD_SECTOR,
- GENERIC_HD_LCYL,
- GENERIC_HD_HCYL,
- GENERIC_HD_SELECT,
- GENERIC_HD_STATUS,
- -1, -1
-};
-
/* ISA PnP device table entry */
struct pnp_dev_t {
unsigned short card_vendor, card_device, vendor, device;
@@ -65,8 +42,8 @@
static int __init pnpide_generic_init(struct pci_dev *dev, int enable)
{
hw_regs_t hw;
- struct ata_channel *hwif;
int index;
+ int i;
if (!enable)
return 0;
@@ -74,15 +51,24 @@
if (!(DEV_IO(dev, 0) && DEV_IO(dev, 1) && DEV_IRQ(dev, 0)))
return 1;
- ide_setup_ports(&hw, (ide_ioreg_t) DEV_IO(dev, 0),
- generic_ide_offsets, (ide_ioreg_t) DEV_IO(dev, 1),
- 0, NULL, DEV_IRQ(dev, 0));
+ /* Initialize register access base values. */
+ for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; ++i)
+ hw.io_ports[i] = DEV_IO(dev, 0) + i;
+ hw.io_ports[IDE_CONTROL_OFFSET] = DEV_IO(dev, 1);
+
+ hw.irq = DEV_IRQ(dev, 0);
+ hw.dma = NO_DMA;
+ hw.ack_intr = NULL;
- index = ide_register_hw(&hw, &hwif);
+ index = ide_register_hw(&hw);
if (index != -1) {
- hwif->pci_dev = dev;
+ struct ata_channel *ch;
+
+ ch = &ide_hwifs[index];
+ ch->pci_dev = dev;
printk(KERN_INFO "ide%d: %s IDE interface\n", index, DEV_NAME(dev));
+
return 0;
}
diff -urN linux-2.5.18/drivers/ide/ide-probe.c linux/drivers/ide/ide-probe.c
--- linux-2.5.18/drivers/ide/ide-probe.c 2002-05-25 03:55:16.000000000 +0200
+++ linux/drivers/ide/ide-probe.c 2002-05-28 13:13:30.000000000 +0200
@@ -68,17 +68,7 @@
* However let's try to get away with this...
*/
-#if 1
ata_read(drive, id, SECTOR_WORDS);
-#else
- {
- unsigned long *ptr = (unsigned long *)id ;
- unsigned long lcount = 256/2 ;
- // printk("IDE_DATA_REG = %#lx",IDE_DATA_REG);
- while( lcount-- )
- *ptr++ = inl(IDE_DATA_REG);
- }
-#endif
ide__sti(); /* local CPU only */
ide_fix_driveid(id);
@@ -248,7 +238,7 @@
rc = 1;
if (IDE_CONTROL_REG) {
/* take a deep breath */
- ide_delay_50ms();
+ mdelay(50);
a = IN_BYTE(IDE_ALTSTATUS_REG);
s = IN_BYTE(IDE_STATUS_REG);
if ((a ^ s) & ~INDEX_STAT) {
@@ -258,7 +248,7 @@
hd_status = IDE_ALTSTATUS_REG; /* use non-intrusive polling */
}
} else {
- ide_delay_50ms();
+ mdelay(50);
hd_status = IDE_STATUS_REG;
}
@@ -281,10 +271,11 @@
do {
if (time_after(jiffies, timeout))
goto out; /* drive timed-out */
- ide_delay_50ms(); /* give drive a breather */
+ mdelay(50); /* give drive a breather */
} while (IN_BYTE(hd_status) & BUSY_STAT);
- ide_delay_50ms(); /* wait for IRQ and DRQ_STAT */
+ mdelay(50); /* wait for IRQ and DRQ_STAT */
+
if (OK_STAT(GET_STAT(),DRQ_STAT,BAD_R_STAT)) {
unsigned long flags;
__save_flags(flags); /* local CPU only */
@@ -345,13 +336,13 @@
drive->name, drive->present, drive->type,
(cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI");
#endif
- ide_delay_50ms(); /* needed for some systems (e.g. crw9624 as drive0 with disk as slave) */
+ mdelay(50); /* needed for some systems (e.g. crw9624 as drive0 with disk as slave) */
SELECT_DRIVE(hwif,drive);
- ide_delay_50ms();
+ mdelay(50);
if (IN_BYTE(IDE_SELECT_REG) != drive->select.all && !drive->present) {
if (drive->select.b.unit != 0) {
SELECT_DRIVE(hwif,&hwif->drives[0]); /* exit with drive0 selected */
- ide_delay_50ms(); /* allow BUSY_STAT to assert & clear */
+ mdelay(50); /* allow BUSY_STAT to assert & clear */
}
return 3; /* no i/f present: mmm.. this should be a 4 -ml */
}
@@ -363,13 +354,13 @@
if (rc == 1 && cmd == WIN_PIDENTIFY && drive->autotune != 2) {
unsigned long timeout;
printk("%s: no response (status = 0x%02x), resetting drive\n", drive->name, GET_STAT());
- ide_delay_50ms();
+ mdelay(50);
OUT_BYTE (drive->select.all, IDE_SELECT_REG);
- ide_delay_50ms();
+ mdelay(50);
OUT_BYTE(WIN_SRST, IDE_COMMAND_REG);
timeout = jiffies;
while ((GET_STAT() & BUSY_STAT) && time_before(jiffies, timeout + WAIT_WORSTCASE))
- ide_delay_50ms();
+ mdelay(50);
rc = identify(drive, cmd);
}
if (rc == 1)
@@ -380,7 +371,7 @@
if (drive->select.b.unit != 0) {
SELECT_DRIVE(hwif,&hwif->drives[0]); /* exit with drive0 selected */
- ide_delay_50ms();
+ mdelay(50);
(void) GET_STAT(); /* ensure drive irq is clear */
}
return rc;
@@ -392,7 +383,7 @@
printk("%s: enabling %s -- ", drive->channel->name, drive->id->model);
SELECT_DRIVE(drive->channel, drive);
- ide_delay_50ms();
+ mdelay(50);
OUT_BYTE(EXABYTE_ENABLE_NEST, IDE_COMMAND_REG);
timeout = jiffies + WAIT_WORSTCASE;
do {
@@ -400,9 +391,9 @@
printk("failed (timeout)\n");
return;
}
- ide_delay_50ms();
+ mdelay(50);
} while (GET_STAT() & BUSY_STAT);
- ide_delay_50ms();
+ mdelay(50);
if (!OK_STAT(GET_STAT(), 0, BAD_STAT))
printk("failed (status = 0x%02x)\n", GET_STAT());
else
@@ -536,7 +527,7 @@
udelay(10);
OUT_BYTE(8, ch->io_ports[IDE_CONTROL_OFFSET]);
do {
- ide_delay_50ms();
+ mdelay(50);
stat = IN_BYTE(ch->io_ports[IDE_STATUS_OFFSET]);
} while ((stat & BUSY_STAT) && time_before(jiffies, timeout));
}
diff -urN linux-2.5.18/drivers/ide/ide-taskfile.c linux/drivers/ide/ide-taskfile.c
--- linux-2.5.18/drivers/ide/ide-taskfile.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/ide/ide-taskfile.c 2002-05-28 11:41:22.000000000 +0200
@@ -353,13 +353,20 @@
OUT_BYTE((args->taskfile.device_head & HIHI) | drive->select.all, IDE_SELECT_REG);
if (args->handler != NULL) {
+
+ /* This is apparently supposed to reset the wait timeout for
+ * the interrupt to accur.
+ */
+
ide_set_handler(drive, args->handler, WAIT_CMD, NULL);
OUT_BYTE(args->taskfile.command, IDE_COMMAND_REG);
+
/*
* Warning check for race between handler and prehandler for
* writing first block of data. however since we are well
* inside the boundaries of the seek, we should be okay.
*/
+
if (args->prehandler != NULL)
return args->prehandler(drive, rq);
} else {
@@ -579,7 +586,8 @@
return ide_started;
}
-/* Called by ioctl to feature out type of command being called */
+/* Called to figure out the type of command being called.
+ */
void ide_cmd_type_parser(struct ata_taskfile *args)
{
struct hd_drive_task_hdr *taskfile = &args->taskfile;
diff -urN linux-2.5.18/drivers/ide/macide.c linux/drivers/ide/macide.c
--- linux-2.5.18/drivers/ide/macide.c 2002-05-25 03:55:19.000000000 +0200
+++ linux/drivers/ide/macide.c 2002-05-27 16:05:38.000000000 +0200
@@ -100,17 +100,17 @@
case MAC_IDE_QUADRA:
ide_setup_ports(&hw, (ide_ioreg_t)IDE_BASE, macide_offsets,
0, 0, macide_ack_intr, IRQ_NUBUS_F);
- index = ide_register_hw(&hw, NULL);
+ index = ide_register_hw(&hw);
break;
case MAC_IDE_PB:
ide_setup_ports(&hw, (ide_ioreg_t)IDE_BASE, macide_offsets,
0, 0, macide_ack_intr, IRQ_NUBUS_C);
- index = ide_register_hw(&hw, NULL);
+ index = ide_register_hw(&hw);
break;
case MAC_IDE_BABOON:
ide_setup_ports(&hw, (ide_ioreg_t)BABOON_BASE, macide_offsets,
0, 0, NULL, IRQ_BABOON_1);
- index = ide_register_hw(&hw, NULL);
+ index = ide_register_hw(&hw);
if (index == -1) break;
if (macintosh_config->ident == MAC_MODEL_PB190) {
diff -urN linux-2.5.18/drivers/ide/main.c linux/drivers/ide/main.c
--- linux-2.5.18/drivers/ide/main.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/ide/main.c 2002-05-28 12:44:05.000000000 +0200
@@ -133,6 +133,43 @@
*/
struct ata_channel ide_hwifs[MAX_HWIFS]; /* master data repository */
+/*
+ * FIXME: This function should be unrolled in the palces where it get's used,
+ * since in reality it's simple architecture specific initialization.
+ *
+ * Setup hw_regs_t structure described by parameters. You may set up the hw
+ * structure yourself OR use this routine to do it for you.
+ */
+void ide_setup_ports(hw_regs_t *hw,
+ ide_ioreg_t base,
+ int *offsets,
+ ide_ioreg_t ctrl,
+ ide_ioreg_t intr,
+ ide_ack_intr_t *ack_intr,
+ int irq)
+{
+ int i;
+
+ for (i = 0; i < IDE_NR_PORTS; i++) {
+ if (offsets[i] != -1)
+ hw->io_ports[i] = base + offsets[i];
+ else
+ hw->io_ports[i] = 0;
+ }
+ if (offsets[IDE_CONTROL_OFFSET] == -1)
+ hw->io_ports[IDE_CONTROL_OFFSET] = ctrl;
+
+ /* FIMXE: check if we can remove this ifdef */
+#if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
+ if (offsets[IDE_IRQ_OFFSET] == -1)
+ hw->io_ports[IDE_IRQ_OFFSET] = intr;
+#endif
+
+ hw->irq = irq;
+ hw->dma = NO_DMA;
+ hw->ack_intr = ack_intr;
+}
+
static void init_hwif_data(struct ata_channel *ch, unsigned int index)
{
static const unsigned int majors[] = {
@@ -148,15 +185,18 @@
memset(&hw, 0, sizeof(hw_regs_t));
/* fill in any non-zero initial values */
- ch->index = index;
+ ch->index = index;
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, &ch->irq);
+
memcpy(&ch->hw, &hw, sizeof(hw));
memcpy(ch->io_ports, hw.io_ports, sizeof(hw.io_ports));
+
ch->noprobe = !ch->io_ports[IDE_DATA_OFFSET];
#ifdef CONFIG_BLK_DEV_HD
if (ch->io_ports[IDE_DATA_OFFSET] == HD_DATA)
ch->noprobe = 1; /* may be overridden by ide_setup() */
#endif
+
ch->major = majors[index];
sprintf(ch->name, "ide%d", index);
ch->bus_state = BUSSTATE_ON;
@@ -576,7 +616,7 @@
* Register an IDE interface, specifing exactly the registers etc
* Set init=1 iff calling before probes have taken place.
*/
-int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
+int ide_register_hw(hw_regs_t *hw)
{
int h;
int retry = 1;
@@ -627,9 +667,6 @@
break;
}
- if (hwifp)
- *hwifp = ch;
-
return (initializing || ch->present) ? h : -1;
}
diff -urN linux-2.5.18/drivers/ide/pdc202xx.c linux/drivers/ide/pdc202xx.c
--- linux-2.5.18/drivers/ide/pdc202xx.c 2002-05-25 03:55:30.000000000 +0200
+++ linux/drivers/ide/pdc202xx.c 2002-05-28 17:03:47.000000000 +0200
@@ -53,10 +53,6 @@
#define PDC202XX_DEBUG_DRIVE_INFO 0
#define PDC202XX_DECODE_REGISTER_INFO 0
-#ifndef SPLIT_BYTE
-#define SPLIT_BYTE(B,H,L) ((H)=(B>>4), (L)=(B-((B>>4)<<4)))
-#endif
-
extern char *ide_xfer_verbose (byte xfer_rate);
/* A Register */
@@ -67,103 +63,62 @@
#define IORDY_EN 0x20 /* PIO: IOREADY */
#define PREFETCH_EN 0x10 /* PIO: PREFETCH */
-#define PA3 0x08 /* PIO"A" timing */
-#define PA2 0x04 /* PIO"A" timing */
-#define PA1 0x02 /* PIO"A" timing */
-#define PA0 0x01 /* PIO"A" timing */
-
-/* B Register */
-
-#define MB2 0x80 /* DMA"B" timing */
-#define MB1 0x40 /* DMA"B" timing */
-#define MB0 0x20 /* DMA"B" timing */
-
-#define PB4 0x10 /* PIO_FORCE 1:0 */
-
-#define PB3 0x08 /* PIO"B" timing */ /* PIO flow Control mode */
-#define PB2 0x04 /* PIO"B" timing */ /* PIO 4 */
-#define PB1 0x02 /* PIO"B" timing */ /* PIO 3 half */
-#define PB0 0x01 /* PIO"B" timing */ /* PIO 3 other half */
-
-/* C Register */
-#define IORDYp_NO_SPEED 0x4F
-#define SPEED_DIS 0x0F
-
-#define DMARQp 0x80
-#define IORDYp 0x40
-#define DMAR_EN 0x20
-#define DMAW_EN 0x10
-
-#define MC3 0x08 /* DMA"C" timing */
-#define MC2 0x04 /* DMA"C" timing */
-#define MC1 0x02 /* DMA"C" timing */
-#define MC0 0x01 /* DMA"C" timing */
-
#if PDC202XX_DECODE_REGISTER_INFO
-#define REG_A 0x01
-#define REG_B 0x02
-#define REG_C 0x04
-#define REG_D 0x08
+struct pdc_bit_messages {
+ u8 mask;
+ const char *msg;
+};
-static void decode_registers (byte registers, byte value)
+static struct pdc_bit_messages pdc_reg_A[] = {
+ { 0x80, "SYNC_IN" },
+ { 0x40, "ERRDY_EN" },
+ { 0x20, "IORDY_EN" },
+ { 0x10, "PREFETCH_EN" },
+ /* PA3-PA0 - PIO "A" timing */
+ { 0x08, "PA3" },
+ { 0x04, "PA2" },
+ { 0x02, "PA1" },
+ { 0x01, "PA0" }
+};
+
+static struct pdc_bit_messages pdc_reg_B[] = {
+ /* MB2-MB0 - DMA "B" timing */
+ { 0x80, "MB2" },
+ { 0x40, "MB1" },
+ { 0x20, "MB0" },
+ { 0x10, "PIO_FORCED/PB4" }, /* PIO_FORCE 1:0 */
+ /* PB3-PB0 - PIO "B" timing */
+ { 0x08, "PB3" }, /* PIO flow Control mode */
+ { 0x04, "PB2" }, /* PIO 4 */
+ { 0x02, "PB1" }, /* PIO 3 half */
+ { 0x01, "PB0" } /* PIO 3 other half */
+};
+
+static struct pdc_bit_messages pdc_reg_C[] = {
+ { 0x80, "DMARQp" },
+ { 0x40, "IORDYp" },
+ { 0x20, "DMAR_EN" },
+ { 0x10, "DMAW_EN" },
+ /* MC3-MC0 - DMA "C" timing */
+ { 0x08, "MC3" },
+ { 0x04, "MC2" },
+ { 0x02, "MC1" },
+ { 0x01, "MC0" }
+};
+
+static void pdc_dump_bits(struct pdc_bit_messages *msgs, byte bits)
{
- byte bit = 0, bit1 = 0, bit2 = 0;
+ int i;
- switch(registers) {
- case REG_A:
- printk("A Register ");
- if (value & 0x80) printk("SYNC_IN ");
- if (value & 0x40) printk("ERRDY_EN ");
- if (value & 0x20) printk("IORDY_EN ");
- if (value & 0x10) printk("PREFETCH_EN ");
- if (value & 0x08) { printk("PA3 ");bit2 |= 0x08; }
- if (value & 0x04) { printk("PA2 ");bit2 |= 0x04; }
- if (value & 0x02) { printk("PA1 ");bit2 |= 0x02; }
- if (value & 0x01) { printk("PA0 ");bit2 |= 0x01; }
- printk("PIO(A) = %d ", bit2);
- break;
- case REG_B:
- printk("B Register ");
- if (value & 0x80) { printk("MB2 ");bit1 |= 0x80; }
- if (value & 0x40) { printk("MB1 ");bit1 |= 0x40; }
- if (value & 0x20) { printk("MB0 ");bit1 |= 0x20; }
- printk("DMA(B) = %d ", bit1 >> 5);
- if (value & 0x10) printk("PIO_FORCED/PB4 ");
- if (value & 0x08) { printk("PB3 ");bit2 |= 0x08; }
- if (value & 0x04) { printk("PB2 ");bit2 |= 0x04; }
- if (value & 0x02) { printk("PB1 ");bit2 |= 0x02; }
- if (value & 0x01) { printk("PB0 ");bit2 |= 0x01; }
- printk("PIO(B) = %d ", bit2);
- break;
- case REG_C:
- printk("C Register ");
- if (value & 0x80) printk("DMARQp ");
- if (value & 0x40) printk("IORDYp ");
- if (value & 0x20) printk("DMAR_EN ");
- if (value & 0x10) printk("DMAW_EN ");
-
- if (value & 0x08) { printk("MC3 ");bit2 |= 0x08; }
- if (value & 0x04) { printk("MC2 ");bit2 |= 0x04; }
- if (value & 0x02) { printk("MC1 ");bit2 |= 0x02; }
- if (value & 0x01) { printk("MC0 ");bit2 |= 0x01; }
- printk("DMA(C) = %d ", bit2);
- break;
- case REG_D:
- printk("D Register ");
- break;
- default:
- return;
- }
- printk("\n %s ", (registers & REG_D) ? "DP" :
- (registers & REG_C) ? "CP" :
- (registers & REG_B) ? "BP" :
- (registers & REG_A) ? "AP" : "ERROR");
- for (bit=128;bit>0;bit/=2)
- printk("%s", (value & bit) ? "1" : "0");
- printk("\n");
-}
+ printk(KERN_DEBUG " { ");
+
+ for (i = 0; i < 8; i++, msgs++)
+ if (bits & msgs->mask)
+ printk(KERN_DEBUG "%s ", msgs->msg);
+ printk(KERN_DEBUG " }\n");
+}
#endif /* PDC202XX_DECODE_REGISTER_INFO */
int check_in_drive_lists(struct ata_device *drive)
@@ -222,13 +177,10 @@
byte drive_pci, AP, BP, CP, DP;
byte TA = 0, TB = 0, TC = 0;
- switch (drive->dn) {
- case 0: drive_pci = 0x60; break;
- case 1: drive_pci = 0x64; break;
- case 2: drive_pci = 0x68; break;
- case 3: drive_pci = 0x6c; break;
- default: return -1;
- }
+ if (drive->dn > 3)
+ return -1;
+
+ drive_pci = 0x60 + (drive->dn << 2);
if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
return -1;
@@ -245,11 +197,8 @@
/* clear DMA modes of upper 842 bits of B Register */
/* clear PIO forced mode upper 1 bit of B Register */
pci_write_config_byte(dev, (drive_pci)|0x01, BP & ~0xF0);
- pci_read_config_byte(dev, (drive_pci)|0x01, &BP);
-
/* clear DMA modes of lower 8421 bits of C Register */
pci_write_config_byte(dev, (drive_pci)|0x02, CP & ~0x0F);
- pci_read_config_byte(dev, (drive_pci)|0x02, &CP);
}
} else {
#else
@@ -258,14 +207,8 @@
if ((AP & 0x0F) || (BP & 0x07)) {
/* clear PIO modes of lower 8421 bits of A Register */
pci_write_config_byte(dev, (drive_pci), AP & ~0x0F);
- pci_read_config_byte(dev, (drive_pci), &AP);
-
/* clear PIO modes of lower 421 bits of B Register */
pci_write_config_byte(dev, (drive_pci)|0x01, BP & ~0x07);
- pci_read_config_byte(dev, (drive_pci)|0x01, &BP);
-
- pci_read_config_byte(dev, (drive_pci), &AP);
- pci_read_config_byte(dev, (drive_pci)|0x01, &BP);
}
}
@@ -277,17 +220,17 @@
#ifdef CONFIG_BLK_DEV_IDEDMA
/* case XFER_UDMA_6: */
case XFER_UDMA_5:
- case XFER_UDMA_4: TB = 0x20; TC = 0x01; break; /* speed 8 == UDMA mode 4 */
- case XFER_UDMA_3: TB = 0x40; TC = 0x02; break; /* speed 7 == UDMA mode 3 */
- case XFER_UDMA_2: TB = 0x20; TC = 0x01; break; /* speed 6 == UDMA mode 2 */
- case XFER_UDMA_1: TB = 0x40; TC = 0x02; break; /* speed 5 == UDMA mode 1 */
- case XFER_UDMA_0: TB = 0x60; TC = 0x03; break; /* speed 4 == UDMA mode 0 */
- case XFER_MW_DMA_2: TB = 0x60; TC = 0x03; break; /* speed 4 == MDMA mode 2 */
- case XFER_MW_DMA_1: TB = 0x60; TC = 0x04; break; /* speed 3 == MDMA mode 1 */
- case XFER_MW_DMA_0: TB = 0x60; TC = 0x05; break; /* speed 2 == MDMA mode 0 */
- case XFER_SW_DMA_2: TB = 0x60; TC = 0x05; break; /* speed 0 == SDMA mode 2 */
- case XFER_SW_DMA_1: TB = 0x80; TC = 0x06; break; /* speed 1 == SDMA mode 1 */
- case XFER_SW_DMA_0: TB = 0xC0; TC = 0x0B; break; /* speed 0 == SDMA mode 0 */
+ case XFER_UDMA_4: TB = 0x20; TC = 0x01; break;
+ case XFER_UDMA_3: TB = 0x40; TC = 0x02; break;
+ case XFER_UDMA_2: TB = 0x20; TC = 0x01; break;
+ case XFER_UDMA_1: TB = 0x40; TC = 0x02; break;
+ case XFER_UDMA_0: TB = 0x60; TC = 0x03; break;
+ case XFER_MW_DMA_2: TB = 0x60; TC = 0x03; break;
+ case XFER_MW_DMA_1: TB = 0x60; TC = 0x04; break;
+ case XFER_MW_DMA_0: TB = 0x60; TC = 0x05; break;
+ case XFER_SW_DMA_2: TB = 0x60; TC = 0x05; break;
+ case XFER_SW_DMA_1: TB = 0x80; TC = 0x06; break;
+ case XFER_SW_DMA_0: TB = 0xC0; TC = 0x0B; break;
#endif /* CONFIG_BLK_DEV_IDEDMA */
case XFER_PIO_4: TA = 0x01; TB = 0x04; break;
case XFER_PIO_3: TA = 0x02; TB = 0x06; break;
@@ -315,11 +258,18 @@
pci_read_config_byte(dev, (drive_pci)|0x02, &CP);
pci_read_config_byte(dev, (drive_pci)|0x03, &DP);
- decode_registers(REG_A, AP);
- decode_registers(REG_B, BP);
- decode_registers(REG_C, CP);
- decode_registers(REG_D, DP);
-#endif /* PDC202XX_DECODE_REGISTER_INFO */
+ printk(KERN_DEBUG "AP(%x): PIO(A) = %d\n", AP, AP & 0x0f);
+ pdc_dump_bits(pdc_reg_A, AP);
+
+ printk(KERN_DEBUG "BP(%x): DMA(B) = %d PIO(B) = %d\n",
+ BP, (BP & 0xe0) >> 5, BP & 0x0f);
+ pdc_dump_bits(pdc_reg_B, BP);
+
+ printk(KERN_DEBUG "CP(%x): DMA(C) = %d\n", CP, CP & 0x0f);
+ pdc_dump_bits(pdc_reg_C, CP);
+
+ printk(KERN_DEBUG "DP(%x)\n", DP);
+#endif
if (!drive->init_speed)
drive->init_speed = speed;
@@ -352,8 +302,7 @@
unsigned long indexreg = (hwif->dma_base + 1);
unsigned long datareg = (hwif->dma_base + 3);
#else
- struct pci_dev *dev = hwif->pci_dev;
- unsigned long high_16 = pci_resource_start(dev, 4);
+ unsigned long high_16 = pci_resource_start(hwif->pci_dev, 4);
unsigned long indexreg = high_16 + (hwif->unit ? 0x09 : 0x01);
unsigned long datareg = (indexreg + 2);
#endif /* CONFIG_BLK_DEV_IDEDMA */
@@ -473,6 +422,7 @@
}
#ifdef CONFIG_BLK_DEV_IDEDMA
+/* FIXME: split this for old & new chipsets (jumpbit) --bkz */
static int config_chipset_for_dma(struct ata_device *drive, byte udma)
{
struct hd_driveid *id = drive->id;
@@ -483,19 +433,13 @@
unsigned long dma_base = hwif->dma_base;
unsigned long indexreg = dma_base + 1;
unsigned long datareg = dma_base + 3;
- byte iordy = 0x13;
byte adj = (drive->dn%2) ? 0x08 : 0x00;
- byte cable = 0;
byte jumpbit = 0;
unsigned int drive_conf;
- byte drive_pci = 0, mate_pci = 0;
- byte test1, test2, mode = -1;
- byte AP;
- unsigned short EP;
+ byte drive_pci = 0, AP, tmp, mode = -1;
byte CLKSPD = 0;
/* primary - second bit, secondary - fourth bit */
byte mask = hwif->unit ? 0x08 : 0x02;
- unsigned short c_mask = hwif->unit ? (1<<11) : (1<<10);
int map;
byte needs_80w = ((id->dma_ultra & 0x0008) ||
@@ -504,24 +448,14 @@
(id->dma_ultra & 0x0040));
switch(dev->device) {
- case PCI_DEVICE_ID_PROMISE_20275:
- case PCI_DEVICE_ID_PROMISE_20276:
- case PCI_DEVICE_ID_PROMISE_20269:
- case PCI_DEVICE_ID_PROMISE_20268R:
- case PCI_DEVICE_ID_PROMISE_20268:
- OUT_BYTE(0x0b, indexreg);
- cable = ((IN_BYTE(datareg) & 0x04));
- jumpbit = 1;
- break;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262:
- pci_read_config_word(dev, 0x50, &EP);
- cable = (EP & c_mask);
+ case PCI_DEVICE_ID_PROMISE_20246:
jumpbit = 0;
break;
- default:
- cable = 1; jumpbit = 0;
+ default: /* chipsets newer then 20268 */
+ jumpbit = 1;
break;
}
@@ -541,7 +475,7 @@
*/
if (needs_80w) {
/* FIXME: this check is wrong for 20246 --bkz */
- if (cable) {
+ if (!hwif->udma_four) {
printk(KERN_WARNING "%s: channel requires an 80-pin cable.\n", hwif->name);
printk(KERN_WARNING "%s: reduced to UDMA(33) mode.\n", drive->name);
if (!jumpbit)
@@ -563,37 +497,30 @@
}
}
- if (jumpbit) {
- if (drive->type != ATA_DISK)
- return 0;
- if (id->capability & 4) { /* IORDY_EN & PREFETCH_EN */
- set_2regs(iordy, (IN_BYTE(datareg)|0x03));
- }
- goto jumpbit_is_set;
- }
+ if (jumpbit)
+ goto chipset_is_set;
- switch(drive->dn) {
- case 0: drive_pci = 0x60;
- case 2: drive_pci = 0x68;
- pci_read_config_dword(dev, drive_pci, &drive_conf);
- if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
- goto chipset_is_set;
- pci_read_config_byte(dev, drive_pci, &test1);
- if (!(test1 & SYNC_ERRDY_EN))
- pci_write_config_byte(dev, drive_pci, test1|SYNC_ERRDY_EN);
- break;
- case 1: drive_pci = 0x64; mate_pci = 0x60;
- case 3: drive_pci = 0x6c; mate_pci = 0x68;
- pci_read_config_dword(dev, drive_pci, &drive_conf);
- if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
- goto chipset_is_set;
- pci_read_config_byte(dev, mate_pci, &test1);
- pci_read_config_byte(dev, drive_pci, &test2);
- if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN))
- pci_write_config_byte(dev, drive_pci, test2|SYNC_ERRDY_EN);
- break;
- default:
- return 0;
+ if (drive->dn > 3) /* FIXME: remove this --bkz */
+ return 0;
+
+ drive_pci = 0x60 + (drive->dn << 2);
+ pci_read_config_dword(dev, drive_pci, &drive_conf);
+ if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
+ goto chipset_is_set;
+
+ /* FIXME: what if SYNC_ERRDY is enabled for slave
+ and disabled for master? --bkz */
+ pci_read_config_byte(dev, drive_pci, &AP);
+ if (!(AP & SYNC_ERRDY_EN)) {
+ if (drive->dn == 0 || drive->dn == 2) {
+ /* enable SYNC_ERRDY for master */
+ pci_write_config_byte(dev, drive_pci, AP|SYNC_ERRDY_EN);
+ } else {
+ /* enable SYNC_ERRDY for slave if enabled for master */
+ pci_read_config_byte(dev, drive_pci - 4, &tmp);
+ if (tmp & SYNC_ERRDY_EN)
+ pci_write_config_byte(dev, drive_pci, AP|SYNC_ERRDY_EN);
+ }
}
chipset_is_set:
@@ -601,14 +528,18 @@
if (drive->type != ATA_DISK)
return 0;
- pci_read_config_byte(dev, (drive_pci), &AP);
- if (id->capability & 4) /* IORDY_EN */
- pci_write_config_byte(dev, (drive_pci), AP|IORDY_EN);
- pci_read_config_byte(dev, (drive_pci), &AP);
- if (drive->type == ATA_DISK) /* PREFETCH_EN */
- pci_write_config_byte(dev, (drive_pci), AP|PREFETCH_EN);
-
-jumpbit_is_set:
+ if (jumpbit) {
+ if (id->capability & 4) { /* IORDY_EN & PREFETCH_EN */
+ set_2regs(0x13, (IN_BYTE(datareg)|0x03));
+ }
+ } else {
+ pci_read_config_byte(dev, drive_pci, &AP);
+ if (id->capability & 4) /* IORDY_EN */
+ pci_write_config_byte(dev, drive_pci, AP|IORDY_EN);
+ pci_read_config_byte(dev, drive_pci, &AP);
+ if (drive->type == ATA_DISK) /* PREFETCH_EN */
+ pci_write_config_byte(dev, drive_pci, AP|PREFETCH_EN);
+ }
if (udma) {
map = pdc202xx_ratemask(drive);
@@ -688,24 +619,13 @@
static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
{
- u8 lba48hack = 0, clock = 0;
struct ata_channel *ch = drive->channel;
- struct pci_dev *dev = ch->pci_dev;
- unsigned long high_16 = pci_resource_start(dev, 4);
- unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
+ unsigned long high_16 = pci_resource_start(ch->pci_dev, 4);
+ unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
- switch (dev->device) {
- case PCI_DEVICE_ID_PROMISE_20267:
- case PCI_DEVICE_ID_PROMISE_20265:
- case PCI_DEVICE_ID_PROMISE_20262:
- lba48hack = 1;
- clock = IN_BYTE(high_16 + 0x11);
- default:
- break;
- }
-
- if (drive->addressing && lba48hack) {
+ if (drive->addressing) {
unsigned long word_count = 0;
+ u8 clock = IN_BYTE(high_16 + 0x11);
outb(clock|(ch->unit ? 0x08 : 0x02), high_16 + 0x11);
word_count = (rq->nr_sectors << 8);
@@ -725,26 +645,13 @@
int pdc202xx_udma_stop(struct ata_device *drive)
{
- u8 lba48hack = 0, clock = 0;
struct ata_channel *ch = drive->channel;
- struct pci_dev *dev = ch->pci_dev;
- unsigned long high_16 = pci_resource_start(dev, 4);
+ unsigned long high_16 = pci_resource_start(ch->pci_dev, 4);
unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
unsigned long dma_base = ch->dma_base;
- u8 dma_stat;
+ u8 dma_stat, clock;
- switch (dev->device) {
- case PCI_DEVICE_ID_PROMISE_20267:
- case PCI_DEVICE_ID_PROMISE_20265:
- case PCI_DEVICE_ID_PROMISE_20262:
- lba48hack = 1;
- /* FIXME: why do we need this here --bkz */
- clock = IN_BYTE(high_16 + 0x11);
- default:
- break;
- }
-
- if (drive->addressing && lba48hack) {
+ if (drive->addressing) {
outl(0, atapi_reg); /* zero out extra */
clock = IN_BYTE(high_16 + 0x11);
OUT_BYTE(clock & ~(ch->unit ? 0x08:0x02), high_16 + 0x11);
@@ -762,34 +669,10 @@
static int pdc202xx_udma_irq_status(struct ata_device *drive)
{
struct ata_channel *ch = drive->channel;
- u8 dma_stat = 0;
- u8 sc1d = 0;
- u8 newchip = 0;
- u8 clock = 0;
- struct pci_dev *dev = ch->pci_dev;
- unsigned long high_16 = pci_resource_start(dev, 4);
- unsigned long dma_base = ch->dma_base;
-
- switch (dev->device) {
- case PCI_DEVICE_ID_PROMISE_20275:
- case PCI_DEVICE_ID_PROMISE_20276:
- case PCI_DEVICE_ID_PROMISE_20269:
- case PCI_DEVICE_ID_PROMISE_20268R:
- case PCI_DEVICE_ID_PROMISE_20268:
- newchip = 1;
- break;
- case PCI_DEVICE_ID_PROMISE_20267:
- case PCI_DEVICE_ID_PROMISE_20265:
- case PCI_DEVICE_ID_PROMISE_20262:
- /* FIXME: why do we need this here --bkz */
- clock = IN_BYTE(high_16 + 0x11);
- default:
- break;
- }
+ unsigned long high_16 = pci_resource_start(ch->pci_dev, 4);
+ u8 dma_stat, sc1d;
- dma_stat = IN_BYTE(dma_base + 2);
- if (newchip)
- return (dma_stat & 4) == 4;
+ dma_stat = IN_BYTE(ch->dma_base + 2);
sc1d = IN_BYTE(high_16 + 0x001d);
if (ch->unit) {
@@ -838,6 +721,7 @@
drive->channel->unit ? "Secondary" : "Primary");
}
+/* FIXME: should be splited for old & new chipsets --bkz */
static unsigned int __init pdc202xx_init_chipset(struct pci_dev *dev)
{
unsigned long high_16 = pci_resource_start(dev, 4);
@@ -877,6 +761,8 @@
set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000); /* 2 seconds ?! */
break;
default:
+ /* FIXME: only checked for 20246 - is this right?,
+ if it is needed it should go to ide-pci --bkz */
if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
byte irq = 0, irq2 = 0;
pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
@@ -949,6 +835,15 @@
case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262:
hwif->resetproc = &pdc202xx_reset;
+#ifdef CONFIG_BLK_DEV_IDEDMA
+ /* we need special functions for lba48 */
+ if (hwif->dma_base) {
+ hwif->udma_start = pdc202xx_udma_start;
+ hwif->udma_stop = pdc202xx_udma_stop;
+ hwif->udma_irq_status = pdc202xx_udma_irq_status;
+ }
+#endif
+ /* FIXME: check whether 20246 works with lba48 --bkz */
case PCI_DEVICE_ID_PROMISE_20246:
hwif->speedproc = &pdc202xx_tune_chipset;
default:
@@ -957,9 +852,6 @@
#ifdef CONFIG_BLK_DEV_IDEDMA
if (hwif->dma_base) {
- hwif->udma_start = pdc202xx_udma_start;
- hwif->udma_stop = pdc202xx_udma_stop;
- hwif->udma_irq_status = pdc202xx_udma_irq_status;
hwif->udma_irq_lost = pdc202xx_bug;
hwif->udma_timeout = pdc202xx_bug;
hwif->XXX_udma = pdc202xx_dmaproc;
diff -urN linux-2.5.18/drivers/ide/pdc4030.c linux/drivers/ide/pdc4030.c
--- linux-2.5.18/drivers/ide/pdc4030.c 2002-05-25 03:55:21.000000000 +0200
+++ linux/drivers/ide/pdc4030.c 2002-05-27 15:03:08.000000000 +0200
@@ -342,7 +342,7 @@
outb(0x14, IDE_SELECT_REG);
outb(PROMISE_EXTENDED_COMMAND, IDE_COMMAND_REG);
- ide_delay_50ms();
+ mdelay(50);
if (inb(IDE_ERROR_REG) == 'P' &&
inb(IDE_NSECTOR_REG) == 'T' &&
diff -urN linux-2.5.18/drivers/ide/q40ide.c linux/drivers/ide/q40ide.c
--- linux-2.5.18/drivers/ide/q40ide.c 2002-05-25 03:55:27.000000000 +0200
+++ linux/drivers/ide/q40ide.c 2002-05-27 16:07:08.000000000 +0200
@@ -82,10 +82,10 @@
for (i = 0; i < Q40IDE_NUM_HWIFS; i++) {
hw_regs_t hw;
- ide_setup_ports(&hw,(ide_ioreg_t) pcide_bases[i], (int *)pcide_offsets,
- pcide_bases[i]+0x206,
+ ide_setup_ports(&hw,(ide_ioreg_t) pcide_bases[i], (int *)pcide_offsets,
+ pcide_bases[i] + 0x206,
0, NULL, q40ide_default_irq(pcide_bases[i]));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
}
diff -urN linux-2.5.18/drivers/ide/rapide.c linux/drivers/ide/rapide.c
--- linux-2.5.18/drivers/ide/rapide.c 2002-05-25 03:55:22.000000000 +0200
+++ linux/drivers/ide/rapide.c 2002-05-27 16:06:08.000000000 +0200
@@ -41,7 +41,7 @@
hw.io_ports[IDE_CONTROL_OFFSET] = port + 0x206;
hw.irq = ec->irq;
- return ide_register_hw(&hw, NULL);
+ return ide_register_hw(&hw);
}
int __init rapide_init(void)
diff -urN linux-2.5.18/drivers/ide/serverworks.c linux/drivers/ide/serverworks.c
--- linux-2.5.18/drivers/ide/serverworks.c 2002-05-25 03:55:27.000000000 +0200
+++ linux/drivers/ide/serverworks.c 2002-05-28 10:28:49.000000000 +0200
@@ -98,7 +98,7 @@
#undef DISPLAY_SVWKS_TIMINGS
#undef SVWKS_DEBUG_DRIVE_INFO
-static u8 svwks_revision = 0;
+static u8 svwks_revision;
#if defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS)
#include <linux/stat.h>
@@ -230,12 +230,13 @@
((reg40&0x005D0000)==0x005D0000)?"0":"?");
return p-buffer; /* => must be less than 4k! */
}
+
+static byte svwks_proc;
+
#endif /* defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS) */
#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */
-byte svwks_proc = 0;
-
extern char *ide_xfer_verbose (byte xfer_rate);
static struct pci_dev *isa_dev;
@@ -262,7 +263,6 @@
static int svwks_tune_chipset(struct ata_device *drive, byte speed)
{
- static u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
static u8 dma_modes[] = { 0x77, 0x21, 0x20 };
static u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
@@ -271,26 +271,23 @@
byte unit = (drive->select.b.unit & 0x01);
byte csb5 = (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0;
- byte drive_pci = 0x00;
- byte drive_pci2 = 0x00;
- byte drive_pci3 = hwif->unit ? 0x57 : 0x56;
-
- byte ultra_enable = 0x00;
- byte ultra_timing = 0x00;
- byte dma_timing = 0x00;
- byte pio_timing = 0x00;
- unsigned short csb5_pio = 0x00;
+ byte drive_pci, drive_pci2;
+ byte drive_pci3 = hwif->unit ? 0x57 : 0x56;
+
+ byte ultra_enable, ultra_timing, dma_timing, pio_timing;
+ unsigned short csb5_pio;
byte pio = ata_timing_mode(drive, XFER_PIO | XFER_EPIO) - XFER_PIO_0;
switch (drive->dn) {
- case 0: drive_pci = 0x41; drive_pci2 = 0x45; break;
- case 1: drive_pci = 0x40; drive_pci2 = 0x44; break;
- case 2: drive_pci = 0x43; drive_pci2 = 0x47; break;
- case 3: drive_pci = 0x42; drive_pci2 = 0x46; break;
+ case 0: drive_pci = 0x41; break;
+ case 1: drive_pci = 0x40; break;
+ case 2: drive_pci = 0x43; break;
+ case 3: drive_pci = 0x42; break;
default:
return -1;
}
+ drive_pci2 = drive_pci + 4;
pci_read_config_byte(dev, drive_pci, &pio_timing);
pci_read_config_byte(dev, drive_pci2, &dma_timing);
@@ -337,7 +334,7 @@
pio_timing |= pio_modes[pio];
csb5_pio |= (pio << (4*drive->dn));
dma_timing |= dma_modes[2];
- ultra_timing |= ((udma_modes[speed - XFER_UDMA_0]) << (4*unit));
+ ultra_timing |= ((speed - XFER_UDMA_0) << (4*unit));
ultra_enable |= (0x01 << drive->dn);
#endif
default:
diff -urN linux-2.5.18/drivers/macintosh/mediabay.c linux/drivers/macintosh/mediabay.c
--- linux-2.5.18/drivers/macintosh/mediabay.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/macintosh/mediabay.c 2002-05-27 16:07:38.000000000 +0200
@@ -569,7 +569,7 @@
pmu_suspend();
ide_init_hwif_ports(&hw, (ide_ioreg_t) bay->cd_base, (ide_ioreg_t) 0, NULL);
hw.irq = bay->cd_irq;
- bay->cd_index = ide_register_hw(&hw, NULL);
+ bay->cd_index = ide_register_hw(&hw);
pmu_resume();
}
if (bay->cd_index == -1) {
diff -urN linux-2.5.18/include/asm-alpha/ide.h linux/include/asm-alpha/ide.h
--- linux-2.5.18/include/asm-alpha/ide.h 2002-05-25 03:55:23.000000000 +0200
+++ linux/include/asm-alpha/ide.h 2002-05-27 16:10:37.000000000 +0200
@@ -77,7 +77,7 @@
for (index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-arm/arch-anakin/ide.h linux/include/asm-arm/arch-anakin/ide.h
--- linux-2.5.18/include/asm-arm/arch-anakin/ide.h 2002-05-25 03:55:17.000000000 +0200
+++ linux/include/asm-arm/arch-anakin/ide.h 2002-05-27 16:09:24.000000000 +0200
@@ -29,9 +29,9 @@
hw->io_ports[i] = reg;
reg += regincr;
}
-
+
hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t) ctrl_port;
-
+
if (irq)
*irq = 0;
}
@@ -46,10 +46,10 @@
{
hw_regs_t hw;
- ide_init_hwif_ports(&hw, IO_BASE + COMPACTFLASH,
- IO_BASE + COMPACTFLASH + IDE_CONTROL_OFFSET, NULL);
+ ide_init_hwif_ports(&hw, IO_BASE + COMPACTFLASH,
+ IO_BASE + COMPACTFLASH + IDE_CONTROL_OFFSET, NULL);
hw.irq = IRQ_COMPACTFLASH;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
diff -urN linux-2.5.18/include/asm-arm/arch-arc/ide.h linux/include/asm-arm/arch-arc/ide.h
--- linux-2.5.18/include/asm-arm/arch-arc/ide.h 2002-05-25 03:55:22.000000000 +0200
+++ linux/include/asm-arm/arch-arc/ide.h 2002-05-27 16:09:47.000000000 +0200
@@ -50,6 +50,6 @@
ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
hw.irq = IRQ_HARDDISK;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
}
diff -urN linux-2.5.18/include/asm-arm/arch-cl7500/ide.h linux/include/asm-arm/arch-cl7500/ide.h
--- linux-2.5.18/include/asm-arm/arch-cl7500/ide.h 2002-05-25 03:55:27.000000000 +0200
+++ linux/include/asm-arm/arch-cl7500/ide.h 2002-05-27 16:10:04.000000000 +0200
@@ -43,8 +43,8 @@
ide_init_default_hwifs(void)
{
hw_regs_t hw;
-
+
ide_init_hwif_ports(&hw, ISASLOT_IO + 0x1f0, ISASLOT_IO + 0x3f6, NULL);
- hw.irq = IRQ_ISA_14;
- ide_register_hw(&hw, NULL);
+ hw.irq = IRQ_ISA_14;
+ ide_register_hw(&hw);
}
diff -urN linux-2.5.18/include/asm-arm/arch-ebsa285/ide.h linux/include/asm-arm/arch-ebsa285/ide.h
--- linux-2.5.18/include/asm-arm/arch-ebsa285/ide.h 2002-05-25 03:55:29.000000000 +0200
+++ linux/include/asm-arm/arch-ebsa285/ide.h 2002-05-27 16:09:38.000000000 +0200
@@ -44,6 +44,6 @@
ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
hw.irq = IRQ_HARDDISK;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
#endif
}
diff -urN linux-2.5.18/include/asm-arm/arch-rpc/ide.h linux/include/asm-arm/arch-rpc/ide.h
--- linux-2.5.18/include/asm-arm/arch-rpc/ide.h 2002-05-25 03:55:25.000000000 +0200
+++ linux/include/asm-arm/arch-rpc/ide.h 2002-05-27 16:09:00.000000000 +0200
@@ -44,5 +44,5 @@
ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
hw.irq = IRQ_HARDDISK;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
diff -urN linux-2.5.18/include/asm-arm/arch-sa1100/ide.h linux/include/asm-arm/arch-sa1100/ide.h
--- linux-2.5.18/include/asm-arm/arch-sa1100/ide.h 2002-05-25 03:55:18.000000000 +0200
+++ linux/include/asm-arm/arch-sa1100/ide.h 2002-05-27 16:08:52.000000000 +0200
@@ -84,10 +84,10 @@
doesn't match the silkscreen however. */
ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x40, PCMCIA_IO_0_BASE + 0x78, NULL);
hw.irq = EMPEG_IRQ_IDE2;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x00, PCMCIA_IO_0_BASE + 0x38, NULL);
hw.irq = ,EMPEG_IRQ_IDE1;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
#endif
}
@@ -104,7 +104,7 @@
ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x1f0, PCMCIA_IO_0_BASE + 0x3f6, NULL);
hw.irq = IRQ_GPIO7;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
#endif
}
else if (machine_is_lart()) {
@@ -114,14 +114,14 @@
/* Enable GPIO as interrupt line */
GPDR &= ~LART_GPIO_IDE;
set_irq_type(LART_IRQ_IDE, IRQT_RISING);
-
+
/* set PCMCIA interface timing */
MECR = 0x00060006;
/* init the interface */
ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x0000, PCMCIA_IO_0_BASE + 0x1000, NULL);
hw.irq = LART_IRQ_IDE;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
#endif
}
}
diff -urN linux-2.5.18/include/asm-arm/arch-shark/ide.h linux/include/asm-arm/arch-shark/ide.h
--- linux-2.5.18/include/asm-arm/arch-shark/ide.h 2002-05-25 03:55:29.000000000 +0200
+++ linux/include/asm-arm/arch-shark/ide.h 2002-05-27 16:10:11.000000000 +0200
@@ -42,6 +42,6 @@
ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
hw.irq = 14;
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
diff -urN linux-2.5.18/include/asm-cris/ide.h linux/include/asm-cris/ide.h
--- linux-2.5.18/include/asm-cris/ide.h 2002-05-25 03:55:20.000000000 +0200
+++ linux/include/asm-cris/ide.h 2002-05-27 16:10:54.000000000 +0200
@@ -84,7 +84,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
}
diff -urN linux-2.5.18/include/asm-i386/ide.h linux/include/asm-i386/ide.h
--- linux-2.5.18/include/asm-i386/ide.h 2002-05-25 03:55:19.000000000 +0200
+++ linux/include/asm-i386/ide.h 2002-05-28 11:29:24.000000000 +0200
@@ -41,16 +41,9 @@
static __inline__ ide_ioreg_t ide_default_io_base(int index)
{
- switch (index) {
- case 0: return 0x1f0;
- case 1: return 0x170;
- case 2: return 0x1e8;
- case 3: return 0x168;
- case 4: return 0x1e0;
- case 5: return 0x160;
- default:
- return 0;
- }
+ static unsigned long ata_io_base[MAX_HWIFS] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
+
+ return ata_io_base[index];
}
static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
@@ -81,7 +74,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-ia64/ide.h linux/include/asm-ia64/ide.h
--- linux-2.5.18/include/asm-ia64/ide.h 2002-05-25 03:55:28.000000000 +0200
+++ linux/include/asm-ia64/ide.h 2002-05-27 16:08:01.000000000 +0200
@@ -87,7 +87,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-mips/ide.h linux/include/asm-mips/ide.h
--- linux-2.5.18/include/asm-mips/ide.h 2002-05-25 03:55:20.000000000 +0200
+++ linux/include/asm-mips/ide.h 2002-05-27 16:10:17.000000000 +0200
@@ -60,7 +60,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-mips64/ide.h linux/include/asm-mips64/ide.h
--- linux-2.5.18/include/asm-mips64/ide.h 2002-05-25 03:55:17.000000000 +0200
+++ linux/include/asm-mips64/ide.h 2002-05-27 16:11:03.000000000 +0200
@@ -63,7 +63,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-parisc/ide.h linux/include/asm-parisc/ide.h
--- linux-2.5.18/include/asm-parisc/ide.h 2002-05-25 03:55:24.000000000 +0200
+++ linux/include/asm-parisc/ide.h 2002-05-27 16:10:23.000000000 +0200
@@ -76,7 +76,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-ppc/ide.h linux/include/asm-ppc/ide.h
--- linux-2.5.18/include/asm-ppc/ide.h 2002-05-25 03:55:24.000000000 +0200
+++ linux/include/asm-ppc/ide.h 2002-05-27 16:08:17.000000000 +0200
@@ -100,7 +100,7 @@
continue;
ide_init_hwif_ports(&hw, base, 0, NULL);
hw.irq = ide_default_irq(base);
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-sh/ide.h linux/include/asm-sh/ide.h
--- linux-2.5.18/include/asm-sh/ide.h 2002-05-25 03:55:22.000000000 +0200
+++ linux/include/asm-sh/ide.h 2002-05-27 16:11:09.000000000 +0200
@@ -102,7 +102,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-sparc/ide.h linux/include/asm-sparc/ide.h
--- linux-2.5.18/include/asm-sparc/ide.h 2002-05-25 03:55:27.000000000 +0200
+++ linux/include/asm-sparc/ide.h 2002-05-27 16:10:48.000000000 +0200
@@ -68,7 +68,7 @@
for (index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-sparc64/ide.h linux/include/asm-sparc64/ide.h
--- linux-2.5.18/include/asm-sparc64/ide.h 2002-05-25 03:55:24.000000000 +0200
+++ linux/include/asm-sparc64/ide.h 2002-05-27 16:10:31.000000000 +0200
@@ -64,7 +64,7 @@
for (index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/asm-x86_64/ide.h linux/include/asm-x86_64/ide.h
--- linux-2.5.18/include/asm-x86_64/ide.h 2002-05-25 03:55:26.000000000 +0200
+++ linux/include/asm-x86_64/ide.h 2002-05-28 11:29:19.000000000 +0200
@@ -41,16 +41,9 @@
static __inline__ ide_ioreg_t ide_default_io_base(int index)
{
- switch (index) {
- case 0: return 0x1f0;
- case 1: return 0x170;
- case 2: return 0x1e8;
- case 3: return 0x168;
- case 4: return 0x1e0;
- case 5: return 0x160;
- default:
- return 0;
- }
+ static unsigned long ata_io_base[MAX_HWIFS] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
+
+ return ata_io_base[index];
}
static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
@@ -81,7 +74,7 @@
for(index = 0; index < MAX_HWIFS; index++) {
ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
+ ide_register_hw(&hw);
}
#endif
}
diff -urN linux-2.5.18/include/linux/ide.h linux/include/linux/ide.h
--- linux-2.5.18/include/linux/ide.h 2002-05-28 17:15:53.000000000 +0200
+++ linux/include/linux/ide.h 2002-05-28 12:44:03.000000000 +0200
@@ -71,18 +71,20 @@
/*
* Definitions for accessing IDE controller registers
*/
-#define IDE_NR_PORTS (10)
-#define IDE_DATA_OFFSET (0)
-#define IDE_ERROR_OFFSET (1)
-#define IDE_NSECTOR_OFFSET (2)
-#define IDE_SECTOR_OFFSET (3)
-#define IDE_LCYL_OFFSET (4)
-#define IDE_HCYL_OFFSET (5)
-#define IDE_SELECT_OFFSET (6)
-#define IDE_STATUS_OFFSET (7)
-#define IDE_CONTROL_OFFSET (8)
-#define IDE_IRQ_OFFSET (9)
+enum {
+ IDE_DATA_OFFSET = 0,
+ IDE_ERROR_OFFSET = 1,
+ IDE_NSECTOR_OFFSET = 2,
+ IDE_SECTOR_OFFSET = 3,
+ IDE_LCYL_OFFSET = 4,
+ IDE_HCYL_OFFSET = 5,
+ IDE_SELECT_OFFSET = 6,
+ IDE_STATUS_OFFSET = 7,
+ IDE_CONTROL_OFFSET = 8,
+ IDE_IRQ_OFFSET = 9,
+ IDE_NR_PORTS = 10
+};
#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
@@ -549,7 +551,7 @@
/*
* Register new hardware with ide
*/
-extern int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp);
+extern int ide_register_hw(hw_regs_t *hw);
extern void ide_unregister(struct ata_channel *hwif);
struct ata_taskfile;
@@ -759,8 +761,6 @@
extern int ide_raw_taskfile(struct ata_device *, struct ata_taskfile *);
extern int ide_cmd_ioctl(struct ata_device *drive, unsigned long arg);
-void ide_delay_50ms(void);
-
extern void ide_fix_driveid(struct hd_driveid *id);
extern int ide_driveid_update(struct ata_device *);
extern int ide_config_drive_speed(struct ata_device *, byte);
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] 2.5.18 QUEUE_EMPTY and the unpleasant friends.
2002-05-25 2:02 Linux-2.5.18 Linus Torvalds
` (2 preceding siblings ...)
2002-05-28 15:31 ` [PATCH] airo Martin Dalecki
@ 2002-05-28 17:35 ` Martin Dalecki
2002-05-29 12:11 ` [PATCH] 2.5.18 IDE 73 Martin Dalecki
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Martin Dalecki @ 2002-05-28 17:35 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
Tue May 28 17:25:29 CEST 2002
- Eliminate all usages of the obscure QUEUE_EMPTY macro.
- Eliminate all unneccessary checks for RQ_INACTIVE, this can't happen during
the time we run the request strategy routine of a single major number block
device. Perhaps the still remaining usage in scsi and i2o_block.c should be
killed as well, since the upper ll_rw_blk layer shouldn't pass inactive
requests down.
Those are all places where we have deeply burried and hidden major number
indexed arrays. Let's deal with them slowly...
[-- Attachment #2: blk-2.5.18.diff --]
[-- Type: text/plain, Size: 35587 bytes --]
diff -ur linux-2.5.18/drivers/acorn/block/fd1772.c linux/drivers/acorn/block/fd1772.c
--- linux-2.5.18/drivers/acorn/block/fd1772.c 2002-05-25 03:55:23.000000000 +0200
+++ linux/drivers/acorn/block/fd1772.c 2002-05-28 20:07:24.000000000 +0200
@@ -591,7 +591,7 @@
{
printk("FDC1772: fd_error\n");
/*panic("fd1772: fd_error"); *//* DAG tmp */
- if (QUEUE_EMPTY)
+ if (blk_queue_empty(QUEUE))
return;
CURRENT->errors++;
if (CURRENT->errors >= MAX_ERRORS) {
@@ -1114,16 +1114,6 @@
static int fd_ref[4];
static int fd_device[4];
-/*
- * Current device number. Taken either from the block header or from the
- * format request descriptor.
- */
-#define CURRENT_DEVICE (CURRENT->rq_dev)
-
-/* Current error count. */
-#define CURRENT_ERRORS (CURRENT->errors)
-
-
/* dummy for blk.h */
static void floppy_off(unsigned int nr)
{
@@ -1145,7 +1135,7 @@
{
unsigned int drive = (dev & 0x03);
- if (MAJOR(dev) != MAJOR_NR) {
+ if (major(dev) != MAJOR_NR) {
printk("floppy_changed: not a floppy\n");
return 0;
}
@@ -1205,7 +1195,7 @@
ReqData = ReqBuffer + 512 * ReqCnt;
#ifdef TRACKBUFFER
- read_track = (ReqCmd == READ && CURRENT_ERRORS == 0);
+ read_track = (ReqCmd == READ && CURRENT->errors == 0);
#endif
DPRINT(("Request params: Si=%d Tr=%d Se=%d Data=%08lx\n", ReqSide,
@@ -1220,24 +1210,21 @@
DPRINT(("redo_fd_request: CURRENT=%08lx CURRENT->rq_dev=%04x CURRENT->sector=%ld\n",
(unsigned long) CURRENT, CURRENT ? CURRENT->rq_dev : 0,
- !QUEUE_EMPTY ? CURRENT->sector : 0));
-
- if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE)
- goto the_end;
+ !blk_queue_empty(QUEUE) ? CURRENT->sector : 0));
repeat:
- if (QUEUE_EMPTY)
+ if (blk_queue_empty(QUEUE))
goto the_end;
- if (MAJOR(CURRENT->rq_dev) != MAJOR_NR)
+ if (major(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
if (CURRENT->bh) {
if (!buffer_locked(CURRENT->bh))
panic(DEVICE_NAME ": block not locked");
}
- device = MINOR(CURRENT_DEVICE);
+ device = minor(CURRENT->rq_dev);
drive = device & 3;
type = device >> 2;
floppy = &unit[drive];
@@ -1343,7 +1330,7 @@
int drive, device;
device = inode->i_rdev;
- drive = MINOR(device);
+ drive = minor(device);
switch (cmd) {
case FDFMTBEG:
return 0;
@@ -1502,8 +1489,8 @@
DPRINT(("Weird, open called with filp=0\n"));
return -EIO;
}
- drive = MINOR(inode->i_rdev) & 3;
- if ((MINOR(inode->i_rdev) >> 2) > NUM_DISK_TYPES)
+ drive = minor(inode->i_rdev) & 3;
+ if ((minor(inode->i_rdev) >> 2) > NUM_DISK_TYPES)
return -ENXIO;
old_dev = fd_device[drive];
@@ -1543,7 +1530,7 @@
static int floppy_release(struct inode *inode, struct file *filp)
{
- int drive = MINOR(inode->i_rdev) & 3;
+ int drive = minor(inode->i_rdev) & 3;
if (fd_ref[drive] < 0)
fd_ref[drive] = 0;
diff -ur linux-2.5.18/drivers/acorn/block/mfmhd.c linux/drivers/acorn/block/mfmhd.c
--- linux-2.5.18/drivers/acorn/block/mfmhd.c 2002-05-25 03:55:21.000000000 +0200
+++ linux/drivers/acorn/block/mfmhd.c 2002-05-28 19:46:42.000000000 +0200
@@ -756,7 +756,7 @@
/* No - its the end of the line */
/* end_request's should have happened at the end of sector DMAs */
/* Turns Drive LEDs off - may slow it down? */
- if (QUEUE_EMPTY)
+ if (blk_queue_empty(QUEUE))
issue_command(CMD_CKV, block, 2);
Busy = 0;
diff -ur linux-2.5.18/drivers/block/acsi.c linux/drivers/block/acsi.c
--- linux-2.5.18/drivers/block/acsi.c 2002-05-25 03:55:26.000000000 +0200
+++ linux/drivers/block/acsi.c 2002-05-28 19:54:16.000000000 +0200
@@ -768,7 +768,7 @@
static void bad_rw_intr( void )
{
- if (QUEUE_EMPTY)
+ if (blk_queue_empty(QUEUE))
return;
if (++CURRENT->errors >= MAX_ERRORS)
@@ -842,7 +842,8 @@
DEVICE_INTR = NULL;
printk( KERN_ERR "ACSI timeout\n" );
- if (QUEUE_EMPTY) return;
+ if (blk_queue_empty(QUEUE))
+ return;
if (++CURRENT->errors >= MAX_ERRORS) {
#ifdef DEBUG
printk( KERN_ERR "ACSI: too many errors.\n" );
@@ -951,40 +952,20 @@
char *buffer;
unsigned long pbuffer;
struct buffer_head *bh;
-
- if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE) {
- if (!DEVICE_INTR) {
- ENABLE_IRQ();
- stdma_release();
- }
- return;
- }
-
- if (DEVICE_INTR)
- return;
repeat:
CLEAR_TIMER();
- /* Another check here: An interrupt or timer event could have
- * happened since the last check!
- */
- if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE) {
- if (!DEVICE_INTR) {
- ENABLE_IRQ();
- stdma_release();
- }
- return;
- }
+
if (DEVICE_INTR)
return;
- if (QUEUE_EMPTY) {
+ if (blk_queue_empty(QUEUE)) {
CLEAR_INTR;
ENABLE_IRQ();
stdma_release();
return;
}
-
+
if (MAJOR(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
if (CURRENT->bh) {
diff -ur linux-2.5.18/drivers/block/amiflop.c linux/drivers/block/amiflop.c
--- linux-2.5.18/drivers/block/amiflop.c 2002-05-25 03:55:26.000000000 +0200
+++ linux/drivers/block/amiflop.c 2002-05-28 20:13:24.000000000 +0200
@@ -209,17 +209,6 @@
static kdev_t fd_device[4] = { NODEV, NODEV, NODEV, NODEV };
/*
- * Current device number. Taken either from the block header or from the
- * format request descriptor.
- */
-#define CURRENT_DEVICE (CURRENT->rq_dev)
-
-/* Current error count. */
-#define CURRENT_ERRORS (CURRENT->errors)
-
-
-
-/*
* Here come the actual hardware access and helper functions.
* They are not reentrant and single threaded because all drives
* share the same hardware and the same trackbuffer.
@@ -1383,12 +1372,8 @@
char *data;
unsigned long flags;
- if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE){
- return;
- }
-
repeat:
- if (QUEUE_EMPTY) {
+ if (blk_queue_empty(QUEUE)) {
/* Nothing left to do */
return;
}
@@ -1396,7 +1381,7 @@
if (major(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
- device = minor(CURRENT_DEVICE);
+ device = minor(CURRENT->rq_dev);
if (device < 8) {
/* manual selection */
drive = device & 3;
diff -ur linux-2.5.18/drivers/block/ataflop.c linux/drivers/block/ataflop.c
--- linux-2.5.18/drivers/block/ataflop.c 2002-05-25 03:55:20.000000000 +0200
+++ linux/drivers/block/ataflop.c 2002-05-28 20:10:29.000000000 +0200
@@ -625,8 +625,10 @@
wake_up( &format_wait );
return;
}
-
- if (QUEUE_EMPTY) return;
+
+ if (blk_queue_empty(QUEUE))
+ return;
+
CURRENT->errors++;
if (CURRENT->errors >= MAX_ERRORS) {
printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive );
@@ -1335,16 +1337,6 @@
static int fd_ref[4] = { 0,0,0,0 };
static int fd_device[4] = { 0,0,0,0 };
-/*
- * Current device number. Taken either from the block header or from the
- * format request descriptor.
- */
-#define CURRENT_DEVICE (CURRENT->rq_dev)
-
-/* Current error count. */
-#define CURRENT_ERRORS (CURRENT->errors)
-
-
/* dummy for blk.h */
static void floppy_off( unsigned int nr) {}
@@ -1437,7 +1429,7 @@
ReqData = ReqBuffer + 512 * ReqCnt;
if (UseTrackbuffer)
- read_track = (ReqCmd == READ && CURRENT_ERRORS == 0);
+ read_track = (ReqCmd == READ && CURRENT->errors == 0);
else
read_track = 0;
@@ -1451,18 +1443,14 @@
int device, drive, type;
DPRINT(("redo_fd_request: CURRENT=%08lx CURRENT->dev=%04x CURRENT->sector=%ld\n",
- (unsigned long)CURRENT, !QUEUE_EMPTY ? CURRENT->rq_dev : 0,
- !QUEUE_EMPTY ? CURRENT->sector : 0 ));
+ (unsigned long)CURRENT, !blk_queue_empty(QUEUE) ? CURRENT->rq_dev : 0,
+ !blk_queue_empty(QUEUE) ? CURRENT->sector : 0 ));
IsFormatting = 0;
- if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE){
- return;
- }
-
repeat:
-
- if (QUEUE_EMPTY)
+
+ if (blk_queue_empty(QUEUE))
goto the_end;
if (major(CURRENT->rq_dev) != MAJOR_NR)
@@ -1471,7 +1459,7 @@
if (CURRENT->bh && !buffer_locked(CURRENT->bh))
panic(DEVICE_NAME ": block not locked");
- device = minor(CURRENT_DEVICE);
+ device = minor(CURRENT->rq_dev);
drive = device & 3;
type = device >> 2;
diff -ur linux-2.5.18/drivers/block/floppy.c linux/drivers/block/floppy.c
--- linux-2.5.18/drivers/block/floppy.c 2002-05-25 03:55:20.000000000 +0200
+++ linux/drivers/block/floppy.c 2002-05-28 19:53:03.000000000 +0200
@@ -2918,14 +2918,8 @@
if (current_drive < N_DRIVE)
floppy_off(current_drive);
- if (!QUEUE_EMPTY && CURRENT->rq_status == RQ_INACTIVE){
- CLEAR_INTR;
- unlock_fdc();
- return;
- }
-
- while(1){
- if (QUEUE_EMPTY) {
+ for (;;) {
+ if (blk_queue_empty(QUEUE)) {
CLEAR_INTR;
unlock_fdc();
return;
diff -ur linux-2.5.18/drivers/block/nbd.c linux/drivers/block/nbd.c
--- linux-2.5.18/drivers/block/nbd.c 2002-05-25 03:55:21.000000000 +0200
+++ linux/drivers/block/nbd.c 2002-05-28 19:38:03.000000000 +0200
@@ -323,7 +323,7 @@
int dev = 0;
struct nbd_device *lo;
- while (!QUEUE_EMPTY) {
+ while (!blk_queue_empty(QUEUE)) {
req = CURRENT;
#ifdef PARANOIA
if (!req)
diff -ur linux-2.5.18/drivers/block/paride/pd.c linux/drivers/block/paride/pd.c
--- linux-2.5.18/drivers/block/paride/pd.c 2002-05-25 03:55:22.000000000 +0200
+++ linux/drivers/block/paride/pd.c 2002-05-28 19:52:15.000000000 +0200
@@ -877,10 +877,9 @@
/* paranoia */
- if (QUEUE_EMPTY ||
+ if (blk_queue_empty(QUEUE) ||
(rq_data_dir(CURRENT) != pd_cmd) ||
(minor(CURRENT->rq_dev) != pd_dev) ||
- (CURRENT->rq_status == RQ_INACTIVE) ||
(CURRENT->sector != pd_block))
printk("%s: OUCH: request list changed unexpectedly\n",
PD.name);
diff -ur linux-2.5.18/drivers/block/paride/pf.c linux/drivers/block/paride/pf.c
--- linux-2.5.18/drivers/block/paride/pf.c 2002-05-25 03:55:19.000000000 +0200
+++ linux/drivers/block/paride/pf.c 2002-05-28 19:52:11.000000000 +0200
@@ -881,10 +881,9 @@
/* paranoia */
- if (QUEUE_EMPTY ||
+ if (blk_queue_empty(QUEUE) ||
(rq_data_dir(CURRENT) != pf_cmd) ||
(DEVICE_NR(CURRENT->rq_dev) != pf_unit) ||
- (CURRENT->rq_status == RQ_INACTIVE) ||
(CURRENT->sector != pf_block))
printk("%s: OUCH: request list changed unexpectedly\n",
PF.name);
diff -ur linux-2.5.18/drivers/block/ps2esdi.c linux/drivers/block/ps2esdi.c
--- linux-2.5.18/drivers/block/ps2esdi.c 2002-05-25 03:55:16.000000000 +0200
+++ linux/drivers/block/ps2esdi.c 2002-05-28 20:09:30.000000000 +0200
@@ -466,7 +466,7 @@
#if 0
printk("%s:got request. device : %d minor : %d command : %d sector : %ld count : %ld, buffer: %p\n",
DEVICE_NAME,
- CURRENT_DEV, minor(CURRENT->rq_dev),
+ DEVICE_NR(CURRENT->rq_dev), minor(CURRENT->rq_dev),
CURRENT->cmd, CURRENT->sector,
CURRENT->current_nr_sectors, CURRENT->buffer);
#endif
@@ -482,14 +482,14 @@
printk("%s: DMA above 16MB not supported\n", DEVICE_NAME);
end_request(FAIL);
} /* check for above 16Mb dmas */
- else if ((CURRENT_DEV < ps2esdi_drives) &&
+ else if ((DEVICE_NR(CURRENT->rq_dev) < ps2esdi_drives) &&
(CURRENT->sector + CURRENT->current_nr_sectors <=
ps2esdi[minor(CURRENT->rq_dev)].nr_sects) &&
CURRENT->flags & REQ_CMD) {
#if 0
printk("%s:got request. device : %d minor : %d command : %d sector : %ld count : %ld\n",
DEVICE_NAME,
- CURRENT_DEV, minor(CURRENT->rq_dev),
+ DEVICE_NR(CURRENT->rq_dev), minor(CURRENT->rq_dev),
CURRENT->cmd, CURRENT->sector,
CURRENT->current_nr_sectors);
#endif
@@ -499,10 +499,10 @@
switch (rq_data_dir(CURRENT)) {
case READ:
- ps2esdi_readwrite(READ, CURRENT_DEV, block, count);
+ ps2esdi_readwrite(READ, DEVICE_NR(CURRENT->rq_dev), block, count);
break;
case WRITE:
- ps2esdi_readwrite(WRITE, CURRENT_DEV, block, count);
+ ps2esdi_readwrite(WRITE, DEVICE_NR(CURRENT->rq_dev), block, count);
break;
default:
printk("%s: Unknown command\n", DEVICE_NAME);
diff -ur linux-2.5.18/drivers/block/swim3.c linux/drivers/block/swim3.c
--- linux-2.5.18/drivers/block/swim3.c 2002-05-25 03:55:24.000000000 +0200
+++ linux/drivers/block/swim3.c 2002-05-28 19:38:44.000000000 +0200
@@ -313,7 +313,7 @@
wake_up(&fs->wait);
return;
}
- while (!QUEUE_EMPTY && fs->state == idle) {
+ while (!blk_queue_empty(QUEUE) && fs->state == idle) {
if (major(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
// if (CURRENT->bh && !buffer_locked(CURRENT->bh))
diff -ur linux-2.5.18/drivers/block/swim_iop.c linux/drivers/block/swim_iop.c
--- linux-2.5.18/drivers/block/swim_iop.c 2002-05-25 03:55:17.000000000 +0200
+++ linux/drivers/block/swim_iop.c 2002-05-28 19:42:12.000000000 +0200
@@ -552,7 +552,7 @@
wake_up(&fs->wait);
return;
}
- while (!QUEUE_EMPTY && fs->state == idle) {
+ while (!blk_queue_empty(QUEUE) && fs->state == idle) {
if (MAJOR(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
if (CURRENT->bh && !buffer_locked(CURRENT->bh))
diff -ur linux-2.5.18/drivers/block/xd.c linux/drivers/block/xd.c
--- linux-2.5.18/drivers/block/xd.c 2002-05-25 03:55:22.000000000 +0200
+++ linux/drivers/block/xd.c 2002-05-28 20:11:32.000000000 +0200
@@ -286,7 +286,7 @@
return;
}
- if (CURRENT_DEV < xd_drives
+ if (DEVICE_NR(CURRENT->rq_dev) < xd_drives
&& (CURRENT->flags & REQ_CMD)
&& CURRENT->sector + CURRENT->nr_sectors
<= xd_struct[minor(CURRENT->rq_dev)].nr_sects) {
@@ -297,7 +297,8 @@
case READ:
case WRITE:
for (retry = 0; (retry < XD_RETRIES) && !code; retry++)
- code = xd_readwrite(rq_data_dir(CURRENT),CURRENT_DEV,CURRENT->buffer,block,count);
+ code = xd_readwrite(rq_data_dir(CURRENT),DEVICE_NR(CURRENT->rq_dev),
+ CURRENT->buffer,block,count);
break;
default:
printk("do_xd_request: unknown request\n");
diff -ur linux-2.5.18/drivers/cdrom/aztcd.c linux/drivers/cdrom/aztcd.c
--- linux-2.5.18/drivers/cdrom/aztcd.c 2002-05-25 03:55:30.000000000 +0200
+++ linux/drivers/cdrom/aztcd.c 2002-05-28 19:34:53.000000000 +0200
@@ -226,9 +226,13 @@
#define AZT_DEBUG_MULTISESSION
#endif
-#define CURRENT_VALID \
- (!QUEUE_EMPTY && major(CURRENT -> rq_dev) == MAJOR_NR && CURRENT -> cmd == READ \
- && CURRENT -> sector != -1)
+static int current_valid(void)
+{
+ return !blk_queue_empty(QUEUE) &&
+ major(CURRENT->rq_dev) == MAJOR_NR &&
+ CURRENT->cmd == READ &&
+ CURRENT->sector != -1;
+}
#define AFL_STATUSorDATA (AFL_STATUS | AFL_DATA)
#define AZT_BUF_SIZ 16
@@ -1554,34 +1558,33 @@
#ifdef AZT_TEST
printk("aztcd: executing azt_transfer Time:%li\n", jiffies);
#endif
- if (CURRENT_VALID) {
- while (CURRENT->nr_sectors) {
- int bn = CURRENT->sector / 4;
- int i;
- for (i = 0; i < AZT_BUF_SIZ && azt_buf_bn[i] != bn;
- ++i);
- if (i < AZT_BUF_SIZ) {
- int offs =
- (i * 4 + (CURRENT->sector & 3)) * 512;
- int nr_sectors = 4 - (CURRENT->sector & 3);
- if (azt_buf_out != i) {
- azt_buf_out = i;
- if (azt_buf_bn[i] != bn) {
- azt_buf_out = -1;
- continue;
- }
- }
- if (nr_sectors > CURRENT->nr_sectors)
- nr_sectors = CURRENT->nr_sectors;
- memcpy(CURRENT->buffer, azt_buf + offs,
- nr_sectors * 512);
- CURRENT->nr_sectors -= nr_sectors;
- CURRENT->sector += nr_sectors;
- CURRENT->buffer += nr_sectors * 512;
- } else {
- azt_buf_out = -1;
- break;
- }
+ if (!current_valid())
+ return;
+
+ while (CURRENT->nr_sectors) {
+ int bn = CURRENT->sector / 4;
+ int i;
+ for (i = 0; i < AZT_BUF_SIZ && azt_buf_bn[i] != bn; ++i);
+ if (i < AZT_BUF_SIZ) {
+ int offs = (i * 4 + (CURRENT->sector & 3)) * 512;
+ int nr_sectors = 4 - (CURRENT->sector & 3);
+ if (azt_buf_out != i) {
+ azt_buf_out = i;
+ if (azt_buf_bn[i] != bn) {
+ azt_buf_out = -1;
+ continue;
+ }
+ }
+ if (nr_sectors > CURRENT->nr_sectors)
+ nr_sectors = CURRENT->nr_sectors;
+ memcpy(CURRENT->buffer, azt_buf + offs,
+ nr_sectors * 512);
+ CURRENT->nr_sectors -= nr_sectors;
+ CURRENT->sector += nr_sectors;
+ CURRENT->buffer += nr_sectors * 512;
+ } else {
+ azt_buf_out = -1;
+ break;
}
}
}
@@ -1598,7 +1601,7 @@
return;
}
azt_transfer_is_active = 1;
- while (CURRENT_VALID) {
+ while (current_valid()) {
azt_transfer();
if (CURRENT->nr_sectors == 0) {
end_request(1);
@@ -1607,7 +1610,7 @@
if (azt_state == AZT_S_IDLE) {
if ((!aztTocUpToDate) || aztDiskChanged) {
if (aztUpdateToc() < 0) {
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
break;
}
@@ -1991,7 +1994,7 @@
AztTries = 0;
loop_ctl = 0;
}
- if (CURRENT_VALID)
+ if (current_valid())
end_request(0);
AztTries = 5;
}
@@ -2065,7 +2068,7 @@
break;
}
azt_state = AZT_S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
return;
}
@@ -2120,12 +2123,12 @@
break;
}
azt_state = AZT_S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
return;
}
- if (CURRENT_VALID) {
+ if (current_valid()) {
struct azt_Play_msf msf;
int i;
azt_next_bn = CURRENT->sector / 4;
@@ -2218,7 +2221,7 @@
AztTries = 0;
break;
}
- if (CURRENT_VALID)
+ if (current_valid())
end_request(0);
AztTries = 5;
}
@@ -2246,8 +2249,7 @@
}
#endif
AztTries = 5;
- if (!CURRENT_VALID
- && azt_buf_in == azt_buf_out) {
+ if (!current_valid() && azt_buf_in == azt_buf_out) {
azt_state = AZT_S_STOP;
loop_ctl = 1;
break;
@@ -2319,7 +2321,7 @@
}
}
if (!azt_transfer_is_active) {
- while (CURRENT_VALID) {
+ while (current_valid()) {
azt_transfer();
if (CURRENT->nr_sectors ==
0)
@@ -2329,7 +2331,7 @@
}
}
- if (CURRENT_VALID
+ if (current_valid()
&& (CURRENT->sector / 4 < azt_next_bn
|| CURRENT->sector / 4 >
azt_next_bn + AZT_BUF_SIZ)) {
@@ -2403,10 +2405,10 @@
#ifdef AZT_TEST3
printk("CURRENT_VALID %d azt_mode %d\n",
- CURRENT_VALID, azt_mode);
+ current_valid(), azt_mode);
#endif
- if (CURRENT_VALID) {
+ if (current_valid()) {
if (st != -1) {
if (azt_mode == 1) {
azt_state = AZT_S_READ;
diff -ur linux-2.5.18/drivers/cdrom/cdu31a.c linux/drivers/cdrom/cdu31a.c
--- linux-2.5.18/drivers/cdrom/cdu31a.c 2002-05-25 03:55:20.000000000 +0200
+++ linux/drivers/cdrom/cdu31a.c 2002-05-28 19:57:22.000000000 +0200
@@ -1563,11 +1563,6 @@
interruptible_sleep_on(&sony_wait);
if (signal_pending(current)) {
restore_flags(flags);
- if (!QUEUE_EMPTY
- && CURRENT->rq_status != RQ_INACTIVE) {
- end_request(0);
- }
- restore_flags(flags);
#if DEBUG
printk("Leaving do_cdu31a_request at %d\n",
__LINE__);
diff -ur linux-2.5.18/drivers/cdrom/gscd.c linux/drivers/cdrom/gscd.c
--- linux-2.5.18/drivers/cdrom/gscd.c 2002-05-25 03:55:17.000000000 +0200
+++ linux/drivers/cdrom/gscd.c 2002-05-28 20:00:25.000000000 +0200
@@ -288,7 +288,7 @@
block = CURRENT->sector;
nsect = CURRENT->nr_sectors;
- if (QUEUE_EMPTY || CURRENT->sector == -1)
+ if (CURRENT->sector == -1)
goto out;
if (CURRENT->cmd != READ) {
diff -ur linux-2.5.18/drivers/cdrom/mcd.c linux/drivers/cdrom/mcd.c
--- linux-2.5.18/drivers/cdrom/mcd.c 2002-05-25 03:55:18.000000000 +0200
+++ linux/drivers/cdrom/mcd.c 2002-05-28 19:24:20.000000000 +0200
@@ -119,9 +119,13 @@
#define QUICK_LOOP_DELAY udelay(45) /* use udelay */
#define QUICK_LOOP_COUNT 20
-#define CURRENT_VALID \
-(!QUEUE_EMPTY && major(CURRENT -> rq_dev) == MAJOR_NR && CURRENT -> cmd == READ \
-&& CURRENT -> sector != -1)
+static int current_valid(void)
+{
+ return !blk_queue_empty(QUEUE) &&
+ major(CURRENT->rq_dev) == MAJOR_NR &&
+ CURRENT->cmd == READ &&
+ CURRENT->sector != -1;
+}
#define MFL_STATUSorDATA (MFL_STATUS | MFL_DATA)
#define MCD_BUF_SIZ 16
@@ -556,33 +560,33 @@
static void mcd_transfer(void)
{
- if (CURRENT_VALID) {
- while (CURRENT->nr_sectors) {
- int bn = CURRENT->sector / 4;
- int i;
- for (i = 0; i < MCD_BUF_SIZ && mcd_buf_bn[i] != bn;
- ++i);
- if (i < MCD_BUF_SIZ) {
- int offs =(i * 4 + (CURRENT->sector & 3)) * 512;
- int nr_sectors = 4 - (CURRENT->sector & 3);
- if (mcd_buf_out != i) {
- mcd_buf_out = i;
- if (mcd_buf_bn[i] != bn) {
- mcd_buf_out = -1;
- continue;
- }
+ if (!current_valid())
+ return;
+
+ while (CURRENT->nr_sectors) {
+ int bn = CURRENT->sector / 4;
+ int i;
+ for (i = 0; i < MCD_BUF_SIZ && mcd_buf_bn[i] != bn; ++i)
+ ;
+ if (i < MCD_BUF_SIZ) {
+ int offs =(i * 4 + (CURRENT->sector & 3)) * 512;
+ int nr_sectors = 4 - (CURRENT->sector & 3);
+ if (mcd_buf_out != i) {
+ mcd_buf_out = i;
+ if (mcd_buf_bn[i] != bn) {
+ mcd_buf_out = -1;
+ continue;
}
- if (nr_sectors > CURRENT->nr_sectors)
- nr_sectors = CURRENT->nr_sectors;
- memcpy(CURRENT->buffer, mcd_buf + offs,
- nr_sectors * 512);
- CURRENT->nr_sectors -= nr_sectors;
- CURRENT->sector += nr_sectors;
- CURRENT->buffer += nr_sectors * 512;
- } else {
- mcd_buf_out = -1;
- break;
}
+ if (nr_sectors > CURRENT->nr_sectors)
+ nr_sectors = CURRENT->nr_sectors;
+ memcpy(CURRENT->buffer, mcd_buf + offs, nr_sectors * 512);
+ CURRENT->nr_sectors -= nr_sectors;
+ CURRENT->sector += nr_sectors;
+ CURRENT->buffer += nr_sectors * 512;
+ } else {
+ mcd_buf_out = -1;
+ break;
}
}
}
@@ -614,7 +618,7 @@
CURRENT->nr_sectors));
mcd_transfer_is_active = 1;
- while (CURRENT_VALID) {
+ while (current_valid()) {
mcd_transfer();
if (CURRENT->nr_sectors == 0) {
end_request(1);
@@ -623,7 +627,7 @@
if (mcd_state == MCD_S_IDLE) {
if (!tocUpToDate) {
if (updateToc() < 0) {
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
break;
}
@@ -688,7 +692,7 @@
McdTries = 0;
goto ret;
}
- if (CURRENT_VALID)
+ if (current_valid())
end_request(0);
McdTries = MCD_RETRY_ATTEMPTS;
}
@@ -745,7 +749,7 @@
"mcd: door open\n" :
"mcd: disk removed\n");
mcd_state = MCD_S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
goto out;
}
@@ -779,12 +783,12 @@
"mcd: door open\n" :
"mcd: disk removed\n");
mcd_state = MCD_S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
goto out;
}
- if (CURRENT_VALID) {
+ if (current_valid()) {
struct mcd_Play_msf msf;
mcd_next_bn = CURRENT->sector / 4;
hsg2msf(mcd_next_bn, &msf.start);
@@ -820,7 +824,7 @@
McdTries = 0;
break;
}
- if (CURRENT_VALID)
+ if (current_valid())
end_request(0);
McdTries = 5;
}
@@ -833,7 +837,7 @@
default:
McdTries = 5;
- if (!CURRENT_VALID && mcd_buf_in == mcd_buf_out) {
+ if (!current_valid() && mcd_buf_in == mcd_buf_out) {
mcd_state = MCD_S_STOP;
goto immediately;
}
@@ -845,7 +849,7 @@
mcd_buf_out = mcd_buf_in;
mcd_buf_in = mcd_buf_in + 1 == MCD_BUF_SIZ ? 0 : mcd_buf_in + 1;
if (!mcd_transfer_is_active) {
- while (CURRENT_VALID) {
+ while (current_valid()) {
mcd_transfer();
if (CURRENT->nr_sectors == 0)
end_request(1);
@@ -854,7 +858,7 @@
}
}
- if (CURRENT_VALID
+ if (current_valid()
&& (CURRENT->sector / 4 < mcd_next_bn ||
CURRENT->sector / 4 > mcd_next_bn + 16)) {
mcd_state = MCD_S_STOP;
@@ -933,8 +937,9 @@
st = -1;
do_not_work_around_mitsumi_bug_93_2:
- test3(printk("CURRENT_VALID %d mcd_mode %d\n", CURRENT_VALID, mcd_mode));
- if (CURRENT_VALID) {
+ test3(printk("CURRENT_VALID %d mcd_mode %d\n", current_valid(),
+ mcd_mode));
+ if (current_valid()) {
if (st != -1) {
if (mcd_mode == 1)
goto read_immediately;
diff -ur linux-2.5.18/drivers/cdrom/optcd.c linux/drivers/cdrom/optcd.c
--- linux-2.5.18/drivers/cdrom/optcd.c 2002-05-25 03:55:21.000000000 +0200
+++ linux/drivers/cdrom/optcd.c 2002-05-28 19:28:07.000000000 +0200
@@ -973,11 +973,13 @@
\f
/* Request handling */
-
-#define CURRENT_VALID \
- (!QUEUE_EMPTY && major(CURRENT -> rq_dev) == MAJOR_NR \
- && CURRENT -> cmd == READ && CURRENT -> sector != -1)
-
+static int current_valid(void)
+{
+ return !blk_queue_empty(QUEUE) &&
+ major(CURRENT->rq_dev) == MAJOR_NR &&
+ CURRENT->cmd == READ &&
+ CURRENT->sector != -1;
+}
/* Buffers for block size conversion. */
#define NOBUF -1
@@ -1006,7 +1008,7 @@
printk(KERN_DEBUG "optcd: executing transfer\n");
#endif
- if (!CURRENT_VALID)
+ if (!current_valid())
return;
while (CURRENT -> nr_sectors) {
int bn = CURRENT -> sector / 4;
@@ -1092,7 +1094,7 @@
" Giving up\n", next_bn);
if (transfer_is_active)
loop_again = 0;
- if (CURRENT_VALID)
+ if (current_valid())
end_request(0);
tries = 5;
}
@@ -1126,7 +1128,7 @@
break;
if (send_cmd(COMDRVST)) {
state = S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
return;
}
@@ -1153,11 +1155,11 @@
? "door open"
: "disk removed");
state = S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
return;
}
- if (!CURRENT_VALID) {
+ if (!current_valid()) {
state = S_STOP;
loop_again = 1;
break;
@@ -1208,7 +1210,7 @@
tries = 0;
break;
}
- if (CURRENT_VALID)
+ if (current_valid())
end_request(0);
tries = 5;
}
@@ -1219,7 +1221,7 @@
break;
default: /* DTEN low */
tries = 5;
- if (!CURRENT_VALID && buf_in == buf_out) {
+ if (!current_valid() && buf_in == buf_out) {
state = S_STOP;
loop_again = 1;
break;
@@ -1272,7 +1274,7 @@
N_BUFS ? 0 : buf_in + 1;
}
if (!transfer_is_active) {
- while (CURRENT_VALID) {
+ while (current_valid()) {
transfer();
if (CURRENT -> nr_sectors == 0)
end_request(1);
@@ -1281,7 +1283,7 @@
}
}
- if (CURRENT_VALID
+ if (current_valid()
&& (CURRENT -> sector / 4 < next_bn ||
CURRENT -> sector / 4 >
next_bn + N_BUFS)) {
@@ -1305,7 +1307,7 @@
flush_data();
if (send_cmd(COMDRVST)) {
state = S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
return;
}
@@ -1320,7 +1322,7 @@
toc_uptodate = 0;
opt_invalidate_buffers();
}
- if (CURRENT_VALID) {
+ if (current_valid()) {
if (status >= 0) {
state = S_READ;
loop_again = 1;
@@ -1346,7 +1348,7 @@
state = S_STOP;
if (exec_cmd(COMSTOP) < 0) {
state = S_IDLE;
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
return;
}
@@ -1368,7 +1370,7 @@
}
transfer_is_active = 1;
- while (CURRENT_VALID) {
+ while (current_valid()) {
transfer(); /* First try to transfer block from buffers */
if (CURRENT -> nr_sectors == 0) {
end_request(1);
@@ -1377,7 +1379,7 @@
if (state == S_IDLE) {
/* %% Should this block the request queue?? */
if (update_toc() < 0) {
- while (CURRENT_VALID)
+ while (current_valid())
end_request(0);
break;
}
diff -ur linux-2.5.18/drivers/cdrom/sbpcd.c linux/drivers/cdrom/sbpcd.c
--- linux-2.5.18/drivers/cdrom/sbpcd.c 2002-05-25 03:55:20.000000000 +0200
+++ linux/drivers/cdrom/sbpcd.c 2002-05-28 19:25:45.000000000 +0200
@@ -4902,7 +4902,7 @@
#ifdef DEBUG_GTL
xnr=++xx_nr;
- if(QUEUE_EMPTY)
+ if(blk_queue_empty(QUEUE))
{
printk( "do_sbpcd_request[%di](NULL), Pid:%d, Time:%li\n",
xnr, current->pid, jiffies);
diff -ur linux-2.5.18/drivers/cdrom/sjcd.c linux/drivers/cdrom/sjcd.c
--- linux-2.5.18/drivers/cdrom/sjcd.c 2002-05-25 03:55:28.000000000 +0200
+++ linux/drivers/cdrom/sjcd.c 2002-05-28 19:30:08.000000000 +0200
@@ -1074,16 +1074,20 @@
* When Linux gets variable block sizes this will probably go away.
*/
-#define CURRENT_IS_VALID \
- ( !QUEUE_EMPTY && major( CURRENT->rq_dev ) == MAJOR_NR && \
- CURRENT->cmd == READ && CURRENT->sector != -1 )
+static int current_valid(void)
+{
+ return !blk_queue_empty(QUEUE) &&
+ major(CURRENT->rq_dev) == MAJOR_NR &&
+ CURRENT->cmd == READ &&
+ CURRENT->sector != -1;
+}
static void sjcd_transfer(void)
{
#if defined( SJCD_TRACE )
printk("SJCD: transfer:\n");
#endif
- if (CURRENT_IS_VALID) {
+ if (current_valid()) {
while (CURRENT->nr_sectors) {
int i, bn = CURRENT->sector / 4;
for (i = 0;
@@ -1239,7 +1243,7 @@
}
}
- if (CURRENT_IS_VALID) {
+ if (current_valid()) {
struct sjcd_play_msf msf;
sjcd_next_bn = CURRENT->sector / 4;
@@ -1307,7 +1311,7 @@
("SJCD: read block %d failed, maybe audio disk? Giving up\n",
sjcd_next_bn);
#endif
- if (CURRENT_IS_VALID)
+ if (current_valid())
end_request(0);
#if defined( SJCD_TRACE )
printk
@@ -1332,7 +1336,7 @@
* Otherwise cdrom hangs up. Check to see if we have something to copy
* to.
*/
- if (!CURRENT_IS_VALID
+ if (!current_valid()
&& sjcd_buf_in == sjcd_buf_out) {
#if defined( SJCD_TRACE )
printk
@@ -1373,7 +1377,7 @@
* OK, request seems to be precessed. Continue transferring...
*/
if (!sjcd_transfer_is_active) {
- while (CURRENT_IS_VALID) {
+ while (current_valid()) {
/*
* Continue transferring.
*/
@@ -1387,7 +1391,7 @@
break;
}
}
- if (CURRENT_IS_VALID &&
+ if (current_valid() &&
(CURRENT->sector / 4 <
sjcd_next_bn
|| CURRENT->sector / 4 >
@@ -1450,7 +1454,7 @@
sjcd_toc_uptodate = 0;
sjcd_invalidate_buffers();
}
- if (CURRENT_IS_VALID) {
+ if (current_valid()) {
if (sjcd_status_valid)
sjcd_transfer_state =
SJCD_S_READ;
@@ -1476,7 +1480,7 @@
if (--sjcd_transfer_timeout == 0) {
printk("SJCD: timeout in state %d\n", sjcd_transfer_state);
- while (CURRENT_IS_VALID)
+ while (current_valid())
end_request(0);
sjcd_send_cmd(SCMD_STOP);
sjcd_transfer_state = SJCD_S_IDLE;
@@ -1497,7 +1501,7 @@
CURRENT->sector, CURRENT->nr_sectors);
#endif
sjcd_transfer_is_active = 1;
- while (CURRENT_IS_VALID) {
+ while (current_valid()) {
sjcd_transfer();
if (CURRENT->nr_sectors == 0)
end_request(1);
@@ -1508,7 +1512,7 @@
if (sjcd_update_toc() < 0) {
printk
("SJCD: transfer: discard\n");
- while (CURRENT_IS_VALID)
+ while (current_valid())
end_request(0);
break;
}
diff -ur linux-2.5.18/drivers/ide/hd.c linux/drivers/ide/hd.c
--- linux-2.5.18/drivers/ide/hd.c 2002-05-25 03:55:20.000000000 +0200
+++ linux/drivers/ide/hd.c 2002-05-28 20:00:11.000000000 +0200
@@ -167,7 +167,7 @@
unsigned long flags;
char devc;
- devc = !QUEUE_EMPTY ? 'a' + DEVICE_NR(CURRENT->rq_dev) : '?';
+ devc = !blk_queue_empty(QUEUE) ? 'a' + DEVICE_NR(CURRENT->rq_dev) : '?';
save_flags (flags);
sti();
#ifdef VERBOSE_ERRORS
@@ -196,7 +196,7 @@
if (hd_error & (BBD_ERR|ECC_ERR|ID_ERR|MARK_ERR)) {
printk(", CHS=%d/%d/%d", (inb(HD_HCYL)<<8) + inb(HD_LCYL),
inb(HD_CURRENT) & 0xf, inb(HD_SECTOR));
- if (!QUEUE_EMPTY)
+ if (!blk_queue_empty(QUEUE))
printk(", sector=%ld", CURRENT->sector);
}
printk("\n");
@@ -373,7 +373,7 @@
{
int dev;
- if (QUEUE_EMPTY)
+ if (blk_queue_empty(QUEUE))
return;
dev = DEVICE_NR(CURRENT->rq_dev);
if (++CURRENT->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) {
@@ -436,7 +436,7 @@
#if (HD_DELAY > 0)
last_req = read_timer();
#endif
- if (!QUEUE_EMPTY)
+ if (!blk_queue_empty(QUEUE))
hd_request();
return;
}
@@ -497,8 +497,10 @@
unsigned int dev;
DEVICE_INTR = NULL;
- if (QUEUE_EMPTY)
+
+ if (blk_queue_empty(QUEUE))
return;
+
disable_irq(HD_IRQ);
sti();
reset = 1;
diff -ur linux-2.5.18/drivers/mtd/mtdblock.c linux/drivers/mtd/mtdblock.c
--- linux-2.5.18/drivers/mtd/mtdblock.c 2002-05-25 03:55:24.000000000 +0200
+++ linux/drivers/mtd/mtdblock.c 2002-05-28 19:44:58.000000000 +0200
@@ -19,15 +19,6 @@
#define DEVICE_NR(device) (device)
#define LOCAL_END_REQUEST
#include <linux/blk.h>
-/* for old kernels... */
-#ifndef QUEUE_EMPTY
-#define QUEUE_EMPTY (!CURRENT)
-#endif
-#if LINUX_VERSION_CODE < 0x20300
-#define QUEUE_PLUGGED (blk_dev[MAJOR_NR].plug_tq.sync)
-#else
-#define QUEUE_PLUGGED (blk_queue_plugged(QUEUE))
-#endif
#ifdef CONFIG_DEVFS_FS
#include <linux/devfs_fs_kernel.h>
@@ -486,7 +477,7 @@
add_wait_queue(&thr_wq, &wait);
set_current_state(TASK_INTERRUPTIBLE);
spin_lock_irq(QUEUE->queue_lock);
- if (QUEUE_EMPTY || QUEUE_PLUGGED) {
+ if (blk_queue_empty(QUEUE) || blk_queue_plugged(QUEUE)) {
spin_unlock_irq(QUEUE->queue_lock);
schedule();
remove_wait_queue(&thr_wq, &wait);
diff -ur linux-2.5.18/drivers/mtd/mtdblock_ro.c linux/drivers/mtd/mtdblock_ro.c
--- linux-2.5.18/drivers/mtd/mtdblock_ro.c 2002-05-25 03:55:26.000000000 +0200
+++ linux/drivers/mtd/mtdblock_ro.c 2002-05-28 20:10:35.000000000 +0200
@@ -132,7 +132,7 @@
mtd = __get_mtd_device(NULL, minor(current_request->rq_dev));
if (!mtd) {
- printk("MTD device %d doesn't appear to exist any more\n", CURRENT_DEV);
+ printk("MTD device %d doesn't appear to exist any more\n", DEVICE_NR(CURRENT->rq_dev));
mtdblock_end_request(current_request, 0);
}
diff -ur linux-2.5.18/include/linux/blk.h linux/include/linux/blk.h
--- linux-2.5.18/include/linux/blk.h 2002-05-25 03:55:22.000000000 +0200
+++ linux/include/linux/blk.h 2002-05-28 20:19:50.000000000 +0200
@@ -293,20 +293,15 @@
#if !defined(IDE_DRIVER)
#ifndef CURRENT
-#define CURRENT elv_next_request(&blk_dev[MAJOR_NR].request_queue)
+# define CURRENT elv_next_request(&blk_dev[MAJOR_NR].request_queue)
#endif
#ifndef QUEUE
-#define QUEUE (&blk_dev[MAJOR_NR].request_queue)
-#endif
-#ifndef QUEUE_EMPTY
-#define QUEUE_EMPTY blk_queue_empty(QUEUE)
+# define QUEUE (&blk_dev[MAJOR_NR].request_queue)
#endif
#ifndef DEVICE_NAME
-#define DEVICE_NAME "unknown"
+# define DEVICE_NAME "unknown"
#endif
-#define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
-
#ifdef DEVICE_INTR
static void (*DEVICE_INTR)(void) = NULL;
#endif
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] 2.5.18 IDE 74
2002-05-25 2:02 Linux-2.5.18 Linus Torvalds
` (4 preceding siblings ...)
2002-05-29 12:11 ` [PATCH] 2.5.18 IDE 73 Martin Dalecki
@ 2002-05-29 12:20 ` Martin Dalecki
2002-05-29 16:03 ` [PATCH] 2.5.18 IDE 75 Martin Dalecki
6 siblings, 0 replies; 10+ messages in thread
From: Martin Dalecki @ 2002-05-29 12:20 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 81 bytes --]
Wed May 29 04:35:14 CEST 2002 ide-clean-74
- Simplify the ide-pci code further.
[-- Attachment #2: ide-clean-74.diff --]
[-- Type: text/plain, Size: 15376 bytes --]
diff -urN linux-2.5.18/drivers/ide/alim15x3.c linux/drivers/ide/alim15x3.c
--- linux-2.5.18/drivers/ide/alim15x3.c 2002-05-25 03:55:28.000000000 +0200
+++ linux/drivers/ide/alim15x3.c 2002-05-29 04:29:02.000000000 +0200
@@ -685,20 +685,35 @@
/* module data table */
-static struct ata_pci_device chipset __initdata = {
- vendor: PCI_VENDOR_ID_AL,
- device: PCI_DEVICE_ID_AL_M5229,
- init_chipset: ali15x3_init_chipset,
- ata66_check: ali15x3_ata66_check,
- init_channel: ali15x3_init_channel,
- init_dma: ali15x3_init_dma,
- enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} },
- bootable: ON_BOARD
+static struct ata_pci_device chipsets[] __initdata = {
+ {
+ vendor: PCI_VENDOR_ID_AL,
+ device: PCI_DEVICE_ID_AL_M5219,
+ /* FIXME: Perhaps we should use the same init routines
+ * as below here. */
+ enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} },
+ bootable: ON_BOARD,
+ flags: ATA_F_SIMPLEX
+ },
+ {
+ vendor: PCI_VENDOR_ID_AL,
+ device: PCI_DEVICE_ID_AL_M5229,
+ init_chipset: ali15x3_init_chipset,
+ ata66_check: ali15x3_ata66_check,
+ init_channel: ali15x3_init_channel,
+ init_dma: ali15x3_init_dma,
+ enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} },
+ bootable: ON_BOARD
+ }
};
int __init init_ali15x3(void)
{
- ata_register_chipset(&chipset);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(chipsets); ++i) {
+ ata_register_chipset(&chipsets[i]);
+ }
return 0;
}
diff -urN linux-2.5.18/drivers/ide/amd74xx.c linux/drivers/ide/amd74xx.c
--- linux-2.5.18/drivers/ide/amd74xx.c 2002-05-25 03:55:28.000000000 +0200
+++ linux/drivers/ide/amd74xx.c 2002-05-29 04:16:52.000000000 +0200
@@ -443,7 +443,8 @@
init_channel: amd74xx_init_channel,
init_dma: amd74xx_init_dma,
enablebits: {{0x40,0x01,0x01}, {0x40,0x02,0x02}},
- bootable: ON_BOARD
+ bootable: ON_BOARD,
+ flags: ATA_F_SIMPLEX
},
{
vendor: PCI_VENDOR_ID_AMD,
diff -urN linux-2.5.18/drivers/ide/cmd64x.c linux/drivers/ide/cmd64x.c
--- linux-2.5.18/drivers/ide/cmd64x.c 2002-05-25 03:55:24.000000000 +0200
+++ linux/drivers/ide/cmd64x.c 2002-05-29 04:14:03.000000000 +0200
@@ -1099,6 +1099,7 @@
init_chipset: cmd64x_init_chipset,
init_channel: cmd64x_init_channel,
bootable: ON_BOARD,
+ flags: ATA_F_SIMPLEX,
},
{
vendor: PCI_VENDOR_ID_CMD,
diff -urN linux-2.5.18/drivers/ide/cs5530.c linux/drivers/ide/cs5530.c
--- linux-2.5.18/drivers/ide/cs5530.c 2002-05-29 02:34:39.000000000 +0200
+++ linux/drivers/ide/cs5530.c 2002-05-29 04:47:26.000000000 +0200
@@ -374,7 +374,7 @@
init_chipset: pci_init_cs5530,
init_channel: ide_init_cs5530,
bootable: ON_BOARD,
- flags: ATA_F_DMA
+ flags: ATA_F_DMA | ATA_F_FDMA
};
int __init init_cs5530(void)
diff -urN linux-2.5.18/drivers/ide/ide-pci.c linux/drivers/ide/ide-pci.c
--- linux-2.5.18/drivers/ide/ide-pci.c 2002-05-28 18:22:15.000000000 +0200
+++ linux/drivers/ide/ide-pci.c 2002-05-29 04:51:47.000000000 +0200
@@ -62,85 +62,68 @@
}
/*
- * This allows off board ide-pci cards the enable a BIOS, verify interrupt
- * settings of split-mirror pci-config space, place chipset into init-mode,
- * and/or preserve an interrupt if the card is not native ide support.
- */
-static unsigned int __init trust_pci_irq(struct ata_pci_device *d, struct pci_dev *dev)
-{
- if (d->flags & ATA_F_IRQ)
- return dev->irq;
-
- return 0;
-}
-
-/*
* Match a PCI IDE port against an entry in ide_hwifs[],
* based on io_base port if possible.
*/
static struct ata_channel __init *lookup_channel(unsigned long io_base, int bootable, const char *name)
{
int h;
- struct ata_channel *hwif;
+ struct ata_channel *ch;
/*
- * Look for a hwif with matching io_base specified using
- * parameters to ide_setup().
+ * Look for a channel with matching io_base default value. If chipset is
+ * "ide_unknown", then claim that channel slot. Otherwise, some other
+ * chipset has already claimed it.. :(
*/
for (h = 0; h < MAX_HWIFS; ++h) {
- hwif = &ide_hwifs[h];
- if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) {
- if (hwif->chipset == ide_generic)
- return hwif; /* a perfect match */
- }
- }
- /*
- * Look for a hwif with matching io_base default value.
- * If chipset is "ide_unknown", then claim that hwif slot.
- * Otherwise, some other chipset has already claimed it.. :(
- */
- for (h = 0; h < MAX_HWIFS; ++h) {
- hwif = &ide_hwifs[h];
- if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) {
- if (hwif->chipset == ide_unknown)
- return hwif; /* match */
- printk("%s: port 0x%04lx already claimed by %s\n", name, io_base, hwif->name);
+ ch = &ide_hwifs[h];
+ if (ch->io_ports[IDE_DATA_OFFSET] == io_base) {
+ if (ch->chipset == ide_generic)
+ return ch; /* a perfect match */
+ if (ch->chipset == ide_unknown)
+ return ch; /* match */
+ printk(KERN_INFO "%s: port 0x%04lx already claimed by %s\n",
+ name, io_base, ch->name);
return NULL; /* already claimed */
}
}
+
/*
- * Okay, there is no hwif matching our io_base,
- * so we'll just claim an unassigned slot.
+ * Okay, there is no ch matching our io_base, so we'll just claim an
+ * unassigned slot.
+ *
* Give preference to claiming other slots before claiming ide0/ide1,
- * just in case there's another interface yet-to-be-scanned
- * which uses ports 1f0/170 (the ide0/ide1 defaults).
+ * just in case there's another interface yet-to-be-scanned which uses
+ * ports 1f0/170 (the ide0/ide1 defaults).
*
- * Unless there is a bootable card that does not use the standard
- * ports 1f0/170 (the ide0/ide1 defaults). The (bootable) flag.
+ * Unless there is a bootable card that does not use the standard ports
+ * 1f0/170 (the ide0/ide1 defaults). The (bootable) flag.
*/
+
if (bootable == ON_BOARD) {
for (h = 0; h < MAX_HWIFS; ++h) {
- hwif = &ide_hwifs[h];
- if (hwif->chipset == ide_unknown)
- return hwif; /* pick an unused entry */
+ ch = &ide_hwifs[h];
+ if (ch->chipset == ide_unknown)
+ return ch; /* pick an unused entry */
}
} else {
for (h = 2; h < MAX_HWIFS; ++h) {
- hwif = ide_hwifs + h;
- if (hwif->chipset == ide_unknown)
- return hwif; /* pick an unused entry */
+ ch = &ide_hwifs[h];
+ if (ch->chipset == ide_unknown)
+ return ch; /* pick an unused entry */
}
}
for (h = 0; h < 2; ++h) {
- hwif = ide_hwifs + h;
- if (hwif->chipset == ide_unknown)
- return hwif; /* pick an unused entry */
+ ch = &ide_hwifs[h];
+ if (ch->chipset == ide_unknown)
+ return ch; /* pick an unused entry */
}
- printk("%s: too many IDE interfaces, no room in table\n", name);
+ printk(KERN_INFO "%s: too many ATA interfaces.\n", name);
+
return NULL;
}
-static int __init setup_pci_baseregs (struct pci_dev *dev, const char *name)
+static int __init setup_pci_baseregs(struct pci_dev *dev, const char *name)
{
u8 reg;
u8 progif = 0;
@@ -175,110 +158,6 @@
return 0;
}
-#ifdef CONFIG_BLK_DEV_IDEDMA
-
-/*
- * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space:
- */
-static unsigned long __init get_dma_base(struct ata_channel *hwif, int extra, const char *name)
-{
- unsigned long dma_base = 0;
- struct pci_dev *dev = hwif->pci_dev;
-
- dma_base = pci_resource_start(dev, 4);
- if (!dma_base)
- return 0;
-
- /* PDC20246, PDC20262, HPT343, & HPT366 */
- if (extra) {
- request_region(dma_base + 16, extra, name);
- hwif->dma_extra = extra;
- }
-
- /* If we are on the second channel, the dma base address will be one
- * entry away from the primary interface.
- */
- if (hwif->unit == ATA_SECONDARY)
- dma_base += 8;
-
- if ((dev->vendor == PCI_VENDOR_ID_AL && dev->device == PCI_DEVICE_ID_AL_M5219) ||
- (dev->vendor == PCI_VENDOR_ID_AMD && dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) ||
- (dev->vendor == PCI_VENDOR_ID_CMD && dev->device == PCI_DEVICE_ID_CMD_643) ||
- (dev->vendor == PCI_VENDOR_ID_SERVERWORKS && dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)) {
- outb(inb(dma_base + 2) & 0x60, dma_base+2);
- if (inb(dma_base + 2) & 0x80)
- printk(KERN_INFO "%s: simplex device: DMA forced\n", name);
- } else {
-
- /* If the device claims "simplex" DMA, this means only one of
- * the two interfaces can be trusted with DMA at any point in
- * time. So we should enable DMA only on one of the two
- * interfaces.
- */
-
- if ((inb(dma_base + 2) & 0x80)) {
- if ((!hwif->drives[0].present && !hwif->drives[1].present) ||
- hwif->unit == ATA_SECONDARY) {
- printk("%s: simplex device: DMA disabled\n", name);
- dma_base = 0;
- }
- }
- }
-
- return dma_base;
-}
-
-/*
- * Setup DMA transfers on a channel.
- */
-static void __init setup_channel_dma(struct ata_channel *ch,
- struct pci_dev *dev,
- struct ata_pci_device *d,
- int port,
- u8 class_rev,
- int pciirq,
- int autodma,
- unsigned short *pcicmd)
-{
- unsigned long dma_base;
-
- if (d->flags & ATA_F_NOADMA)
- autodma = 0;
-
- if (autodma)
- ch->autodma = 1;
-
- if (!((d->flags & ATA_F_DMA) || ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 0x80))))
- return;
-
- dma_base = get_dma_base(ch, ((port == ATA_PRIMARY) && d->extra) ? d->extra : 0, dev->name);
- if (!dma_base) {
- printk("%s: %s Bus-Master DMA was disabled by BIOS\n",
- ch->name, dev->name);
-
- return;
- }
- if (!(*pcicmd & PCI_COMMAND_MASTER)) {
-
- /*
- * Set up BM-DMA capability (PnP BIOS should have done this already)
- */
- if (!(d->vendor == PCI_VENDOR_ID_CYRIX && d->device == PCI_DEVICE_ID_CYRIX_5530_IDE))
- ch->autodma = 0; /* default DMA off if we had to configure it here */
- pci_write_config_word(dev, PCI_COMMAND, *pcicmd | PCI_COMMAND_MASTER);
- if (pci_read_config_word(dev, PCI_COMMAND, pcicmd) || !(*pcicmd & PCI_COMMAND_MASTER)) {
- printk("%s: %s error updating PCICMD\n",
- ch->name, dev->name);
- dma_base = 0;
- }
- }
- if (d->init_dma)
- d->init_dma(ch, dma_base);
- else
- ata_init_dma(ch, dma_base);
-}
-#endif
-
/*
* Setup a particular port on an ATA host controller.
*
@@ -293,6 +172,7 @@
unsigned short *pcicmd)
{
unsigned long base = 0;
+ unsigned long dma_base;
unsigned long ctl = 0;
ide_pci_enablebit_t *e = &(d->enablebits[port]);
struct ata_channel *ch;
@@ -387,7 +267,79 @@
}
#ifdef CONFIG_BLK_DEV_IDEDMA
- setup_channel_dma(ch, dev, d, port, class_rev, pciirq, autodma, pcicmd);
+ /*
+ * Setup DMA transfers on the channel.
+ */
+ if (d->flags & ATA_F_NOADMA)
+ autodma = 0;
+
+ if (autodma)
+ ch->autodma = 1;
+
+ if (!((d->flags & ATA_F_DMA) || ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 0x80))))
+ goto no_dma;
+ /*
+ * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space:
+ */
+ dma_base = pci_resource_start(dev, 4);
+ if (dma_base) {
+ /* PDC20246, PDC20262, HPT343, & HPT366 */
+ if ((ch->unit == ATA_PRIMARY) && d->extra) {
+ request_region(dma_base + 16, d->extra, dev->name);
+ ch->dma_extra = d->extra;
+ }
+
+ /* If we are on the second channel, the dma base address will
+ * be one entry away from the primary interface.
+ */
+ if (ch->unit == ATA_SECONDARY)
+ dma_base += 8;
+
+ if (d->flags & ATA_F_SIMPLEX) {
+ outb(inb(dma_base + 2) & 0x60, dma_base + 2);
+ if (inb(dma_base + 2) & 0x80)
+ printk(KERN_INFO "%s: simplex device: DMA forced\n", dev->name);
+ } else {
+ /* If the device claims "simplex" DMA, this means only
+ * one of the two interfaces can be trusted with DMA at
+ * any point in time. So we should enable DMA only on
+ * one of the two interfaces.
+ */
+ if ((inb(dma_base + 2) & 0x80)) {
+ if ((!ch->drives[0].present && !ch->drives[1].present) ||
+ ch->unit == ATA_SECONDARY) {
+ printk(KERN_INFO "%s: simplex device: DMA disabled\n", dev->name);
+ dma_base = 0;
+ }
+ }
+ }
+ } else {
+ printk(KERN_INFO "%s: %s Bus-Master DMA was disabled by BIOS\n",
+ ch->name, dev->name);
+
+ goto no_dma;
+ }
+ if (!(*pcicmd & PCI_COMMAND_MASTER)) {
+ /*
+ * Set up BM-DMA capability (PnP BIOS should have done this
+ * already). Default to DMA off on the drive, if we had to
+ * configure it here. This should most propably be enabled no
+ * all chipsets which can be expected to be used on systems
+ * without a BIOS equivalent.
+ */
+ if (!(d->flags | ATA_F_FDMA))
+ ch->autodma = 0;
+ pci_write_config_word(dev, PCI_COMMAND, *pcicmd | PCI_COMMAND_MASTER);
+ if (pci_read_config_word(dev, PCI_COMMAND, pcicmd) || !(*pcicmd & PCI_COMMAND_MASTER)) {
+ printk("%s: %s error updating PCICMD\n",
+ ch->name, dev->name);
+ dma_base = 0;
+ }
+ }
+ if (d->init_dma)
+ d->init_dma(ch, dma_base);
+ else
+ ata_init_dma(ch, dma_base);
#endif
no_dma:
@@ -428,7 +380,7 @@
check_if_enabled:
if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) {
- printk("%s: error accessing PCI regs\n", dev->name);
+ printk(KERN_ERR "%s: error accessing PCI regs\n", dev->name);
return;
}
if (!(pcicmd & PCI_COMMAND_IO)) { /* is device disabled? */
@@ -495,8 +447,12 @@
*/
if (d->init_chipset)
pciirq = d->init_chipset(dev);
- else
- pciirq = trust_pci_irq(d, dev);
+ else {
+ if (d->flags & ATA_F_IRQ)
+ pciirq = dev->irq;
+ else
+ pciirq = 0;
+ }
} else if (tried_config) {
printk(KERN_INFO "ATA: will probe IRQs later\n");
pciirq = 0;
@@ -520,6 +476,10 @@
setup_host_channel(dev, d, ATA_SECONDARY, class_rev, pciirq, autodma, &pcicmd);
}
+/*
+ * Fix crossover IRQ line setups between primary and secondary channel. Quite
+ * a common bug apparently.
+ */
static void __init pdc20270_device_order_fixup (struct pci_dev *dev, struct ata_pci_device *d)
{
struct pci_dev *dev2 = NULL;
diff -urN linux-2.5.18/drivers/ide/pcihost.h linux/drivers/ide/pcihost.h
--- linux-2.5.18/drivers/ide/pcihost.h 2002-05-25 03:55:17.000000000 +0200
+++ linux/drivers/ide/pcihost.h 2002-05-29 14:27:18.000000000 +0200
@@ -102,14 +102,16 @@
/* Flags used to untangle quirk handling.
*/
-#define ATA_F_DMA 0x01
-#define ATA_F_NODMA 0x02 /* no DMA mode supported at all */
-#define ATA_F_NOADMA 0x04 /* DMA has to be enabled explicitely */
-#define ATA_F_FIXIRQ 0x08 /* fixed irq wiring */
-#define ATA_F_SER 0x10 /* serialize on first and second channel interrupts */
-#define ATA_F_IRQ 0x20 /* trust IRQ information from config */
-#define ATA_F_PHACK 0x40 /* apply PROMISE hacks */
-#define ATA_F_HPTHACK 0x80 /* apply HPT366 hacks */
+#define ATA_F_DMA 0x001
+#define ATA_F_NODMA 0x002 /* no DMA mode supported at all */
+#define ATA_F_NOADMA 0x004 /* DMA has to be enabled explicitely */
+#define ATA_F_FDMA 0x008 /* force autodma */
+#define ATA_F_FIXIRQ 0x010 /* fixed irq wiring */
+#define ATA_F_SER 0x020 /* serialize on first and second channel interrupts */
+#define ATA_F_IRQ 0x040 /* trust IRQ information from config */
+#define ATA_F_PHACK 0x080 /* apply PROMISE hacks */
+#define ATA_F_HPTHACK 0x100 /* apply HPT366 hacks */
+#define ATA_F_SIMPLEX 0x200 /* force treatment as simple device */
struct ata_pci_device {
diff -urN linux-2.5.18/drivers/ide/serverworks.c linux/drivers/ide/serverworks.c
--- linux-2.5.18/drivers/ide/serverworks.c 2002-05-29 02:34:39.000000000 +0200
+++ linux/drivers/ide/serverworks.c 2002-05-29 04:15:33.000000000 +0200
@@ -679,7 +679,8 @@
init_chipset: svwks_init_chipset,
ata66_check: svwks_ata66_check,
init_channel: ide_init_svwks,
- bootable: ON_BOARD
+ bootable: ON_BOARD,
+ flags: ATA_F_SIMPLEX
},
};
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] 2.5.18 IDE 75
2002-05-25 2:02 Linux-2.5.18 Linus Torvalds
` (5 preceding siblings ...)
2002-05-29 12:20 ` [PATCH] 2.5.18 IDE 74 Martin Dalecki
@ 2002-05-29 16:03 ` Martin Dalecki
6 siblings, 0 replies; 10+ messages in thread
From: Martin Dalecki @ 2002-05-29 16:03 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]
Wed May 29 15:13:06 CEST 2002 ide-clean-75
- Comment out config_chipset_for_pio from hpt366 driver. It seems to hang on it
and many people consistently reported that this may be necessary.
Well apparently this host chip is forced to be in DMA read mode anyway
and we where undoing this there.
- Apply small cosmetics to pdc202xx.c driver by Thierry Vignaud.
His change log entries follow:
> - factorize constants with PDC_CLOCK and UDMA_SPEED_FLAG macros and
> the init_high_16() static inline functions, thus removing floating
> constants in code
> - remove unused variables and pci space read
>
> - kill useless code in pdc202xx_udma_irq_status() resulting in
> removing unused variable: the code does lots of tests to check what
> value to return but just always return the same exact value in all
> code paths!
> this also saves a few cpu & pci bus cyles by removing a useless read
> in pci space
> - simplify #if/#else resulting in code duplication
> - make init_pdc202xx clearer
>
> - remove duplicated initializations in config_drive_xfer_rate() and
> simplify code paths
> check in you mail inbox for the exact demonstrations (which didn't
> even alter resulting binary since gcc seems to optimize out most of
> this useless/obscuring stuff)
- Kill unused init_speed member from ata_device struct. Spotted by
M.H.VanLeeuwen.
[-- Attachment #2: ide-clean-75.diff --]
[-- Type: text/plain, Size: 14903 bytes --]
diff -urN linux-2.5.18/drivers/ide/aec62xx.c linux/drivers/ide/aec62xx.c
--- linux-2.5.18/drivers/ide/aec62xx.c 2002-05-28 17:15:53.000000000 +0200
+++ linux/drivers/ide/aec62xx.c 2002-05-29 18:14:27.000000000 +0200
@@ -123,8 +123,6 @@
else
aec_set_speed_new(drive->channel->pci_dev, drive->dn, &t);
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return 0;
diff -urN linux-2.5.18/drivers/ide/alim15x3.c linux/drivers/ide/alim15x3.c
--- linux-2.5.18/drivers/ide/alim15x3.c 2002-05-29 18:51:29.000000000 +0200
+++ linux/drivers/ide/alim15x3.c 2002-05-29 18:13:50.000000000 +0200
@@ -377,8 +377,6 @@
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return ide_config_drive_speed(drive, speed);
diff -urN linux-2.5.18/drivers/ide/amd74xx.c linux/drivers/ide/amd74xx.c
--- linux-2.5.18/drivers/ide/amd74xx.c 2002-05-29 18:51:29.000000000 +0200
+++ linux/drivers/ide/amd74xx.c 2002-05-29 18:13:50.000000000 +0200
@@ -251,8 +251,6 @@
amd_set_speed(drive->channel->pci_dev, drive->dn, &t);
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return 0;
diff -urN linux-2.5.18/drivers/ide/cmd64x.c linux/drivers/ide/cmd64x.c
--- linux-2.5.18/drivers/ide/cmd64x.c 2002-05-29 18:51:29.000000000 +0200
+++ linux/drivers/ide/cmd64x.c 2002-05-29 18:13:50.000000000 +0200
@@ -537,8 +537,6 @@
(void) pci_write_config_byte(dev, pciU, regU);
#endif /* CONFIG_BLK_DEV_IDEDMA */
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
#ifdef CONFIG_BLK_DEV_IDEDMA
@@ -657,8 +655,6 @@
pci_write_config_word(dev, dma_pci, multi);
pci_write_config_word(dev, udma_pci, ultra);
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return ide_config_drive_speed(drive, speed);
diff -urN linux-2.5.18/drivers/ide/hpt34x.c linux/drivers/ide/hpt34x.c
--- linux-2.5.18/drivers/ide/hpt34x.c 2002-05-29 02:34:39.000000000 +0200
+++ linux/drivers/ide/hpt34x.c 2002-05-29 18:13:50.000000000 +0200
@@ -137,8 +137,6 @@
hi_speed, lo_speed, err);
#endif
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return ide_config_drive_speed(drive, speed);
}
diff -urN linux-2.5.18/drivers/ide/hpt366.c linux/drivers/ide/hpt366.c
--- linux-2.5.18/drivers/ide/hpt366.c 2002-05-25 03:55:20.000000000 +0200
+++ linux/drivers/ide/hpt366.c 2002-05-29 18:13:50.000000000 +0200
@@ -486,11 +486,10 @@
static struct pci_dev *hpt_devs[HPT366_MAX_DEVS];
static int n_hpt_devs;
-static u8 hpt366_proc = 0;
-
static unsigned int hpt_min_rev(struct pci_dev *dev, int rev);
#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
+static u8 hpt366_proc = 0;
static int hpt366_get_info(char *, char **, off_t, int);
extern int (*hpt366_display_info)(char *, char **, off_t, int); /* ide-proc.c */
@@ -788,9 +787,6 @@
if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
return -1;
- if (!drive->init_speed)
- drive->init_speed = speed;
-
if (hpt_min_rev(dev, 7)) {
hpt374_tune_chipset(drive, speed);
} else if (hpt_min_rev(dev, 5)) {
@@ -864,9 +860,6 @@
int map;
byte mode;
- /* FIXME: remove this --bkz */
- config_chipset_for_pio(drive);
-
if (drive->type != ATA_DISK)
return 0;
diff -urN linux-2.5.18/drivers/ide/icside.c linux/drivers/ide/icside.c
--- linux-2.5.18/drivers/ide/icside.c 2002-05-29 02:34:39.000000000 +0200
+++ linux/drivers/ide/icside.c 2002-05-29 18:13:50.000000000 +0200
@@ -362,9 +362,6 @@
drive->drive_data = cycle_time;
- if (!drive->init_speed)
- drive->init_speed = xfer_mode;
-
if (cycle_time && ide_config_drive_speed(drive, xfer_mode) == 0)
on = 1;
else
diff -urN linux-2.5.18/drivers/ide/ide-pmac.c linux/drivers/ide/ide-pmac.c
--- linux-2.5.18/drivers/ide/ide-pmac.c 2002-05-25 03:55:29.000000000 +0200
+++ linux/drivers/ide/ide-pmac.c 2002-05-29 18:13:50.000000000 +0200
@@ -1247,9 +1247,6 @@
return 0;
}
- if (!drive->init_speed)
- drive->init_speed = feature;
-
/* which drive is it ? */
if (drive->select.b.unit & 0x01)
timings = &pmac_ide[idx].timings[1];
@@ -1286,9 +1283,6 @@
return 0;
}
- if (!drive->init_speed)
- drive->init_speed = feature;
-
/* which drive is it ? */
if (drive->select.b.unit & 0x01)
timings = &pmac_ide[idx].timings[1];
diff -urN linux-2.5.18/drivers/ide/it8172.c linux/drivers/ide/it8172.c
--- linux-2.5.18/drivers/ide/it8172.c 2002-05-25 03:55:18.000000000 +0200
+++ linux/drivers/ide/it8172.c 2002-05-29 18:13:50.000000000 +0200
@@ -187,8 +187,6 @@
it8172_tune_drive(drive, it8172_dma_2_pio(speed));
- if (!drive->init_speed)
- drive->init_speed = speed;
err = ide_config_drive_speed(drive, speed);
drive->current_speed = speed;
return err;
diff -urN linux-2.5.18/drivers/ide/pdc202xx.c linux/drivers/ide/pdc202xx.c
--- linux-2.5.18/drivers/ide/pdc202xx.c 2002-05-29 02:34:39.000000000 +0200
+++ linux/drivers/ide/pdc202xx.c 2002-05-29 18:13:50.000000000 +0200
@@ -1,6 +1,6 @@
/**** vi:set ts=8 sts=8 sw=8:************************************************
*
- * linux/drivers/ide/pdc202xx.c Version 0.30 Mar. 18, 2000
+ * linux/drivers/ide/pdc202xx.c Version 0.30 May. 28, 2002
*
* Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
* May be copied or modified under the terms of the GNU General Public License
@@ -61,6 +61,10 @@
#define IORDY_EN 0x20 /* PIO: IOREADY */
#define PREFETCH_EN 0x10 /* PIO: PREFETCH */
+
+#define PDC_CLOCK(high_16) IN_BYTE(high_16 + 0x11)
+#define UDMA_SPEED_FLAG(high_16) IN_BYTE(high_16 + 0x001f)
+
#if PDC202XX_DECODE_REGISTER_INFO
struct pdc_bit_messages {
@@ -119,6 +123,13 @@
}
#endif /* PDC202XX_DECODE_REGISTER_INFO */
+
+static inline int init_high_16 (struct pci_dev *dev)
+{
+ return pci_resource_start(dev, 4);
+}
+
+
int check_in_drive_lists(struct ata_device *drive)
{
static const char *pdc_quirk_drives[] = {
@@ -172,7 +183,7 @@
struct pci_dev *dev = hwif->pci_dev;
unsigned int drive_conf;
- byte drive_pci, AP, BP, CP, DP;
+ byte drive_pci, AP, BP, CP;
byte TA = 0, TB = 0, TC = 0;
if (drive->dn > 3)
@@ -187,7 +198,6 @@
pci_read_config_byte(dev, (drive_pci), &AP);
pci_read_config_byte(dev, (drive_pci)|0x01, &BP);
pci_read_config_byte(dev, (drive_pci)|0x02, &CP);
- pci_read_config_byte(dev, (drive_pci)|0x03, &DP);
#ifdef CONFIG_BLK_DEV_IDEDMA
if (speed >= XFER_SW_DMA_0) {
@@ -198,10 +208,9 @@
/* clear DMA modes of lower 8421 bits of C Register */
pci_write_config_byte(dev, (drive_pci)|0x02, CP & ~0x0F);
}
- } else {
-#else
- {
+ } else
#endif /* CONFIG_BLK_DEV_IDEDMA */
+ {
if ((AP & 0x0F) || (BP & 0x07)) {
/* clear PIO modes of lower 8421 bits of A Register */
pci_write_config_byte(dev, (drive_pci), AP & ~0x0F);
@@ -242,10 +251,9 @@
if (speed >= XFER_SW_DMA_0) {
pci_write_config_byte(dev, (drive_pci)|0x01, BP|TB);
pci_write_config_byte(dev, (drive_pci)|0x02, CP|TC);
- } else {
-#else
- {
+ } else
#endif /* CONFIG_BLK_DEV_IDEDMA */
+ {
pci_write_config_byte(dev, (drive_pci), AP|TA);
pci_write_config_byte(dev, (drive_pci)|0x01, BP|TB);
}
@@ -269,8 +277,6 @@
printk(KERN_DEBUG "DP(%x)\n", DP);
#endif
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
#if PDC202XX_DEBUG_DRIVE_INFO
@@ -300,7 +306,7 @@
unsigned long indexreg = (hwif->dma_base + 1);
unsigned long datareg = (hwif->dma_base + 3);
#else
- unsigned long high_16 = pci_resource_start(hwif->pci_dev, 4);
+ unsigned long high_16 = init_high_16(hwif->pci_dev);
unsigned long indexreg = high_16 + (hwif->unit ? 0x09 : 0x01);
unsigned long datareg = (indexreg + 2);
#endif /* CONFIG_BLK_DEV_IDEDMA */
@@ -394,8 +400,6 @@
;
}
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return ide_config_drive_speed(drive, speed);
@@ -427,7 +431,7 @@
struct ata_channel *hwif = drive->channel;
struct hd_driveid *mate_id = hwif->drives[!(drive->dn%2)].id;
struct pci_dev *dev = hwif->pci_dev;
- unsigned long high_16 = pci_resource_start(dev, 4);
+ unsigned long high_16 = init_high_16(dev);
unsigned long dma_base = hwif->dma_base;
unsigned long indexreg = dma_base + 1;
unsigned long datareg = dma_base + 3;
@@ -458,7 +462,7 @@
}
if (!jumpbit)
- CLKSPD = IN_BYTE(high_16 + 0x11);
+ CLKSPD = PDC_CLOCK(high_16);
/*
* Set the control register to use the 66Mhz system
* clock for UDMA 3/4 mode operation. If one drive on
@@ -568,12 +572,9 @@
if (id && (id->capability & 1) && hwif->autodma) {
/* Consult the list of known "bad" drives */
- if (udma_black_list(drive)) {
- on = 0;
- goto fast_ata_pio;
- }
- on = 0;
verbose = 0;
+ if (udma_black_list(drive))
+ goto no_dma_set;
if (id->field_valid & 4) {
if (id->dma_ultra & 0x007F) {
/* Force if Capable UltraDMA */
@@ -599,13 +600,8 @@
on = config_chipset_for_dma(drive, 0);
if (!on)
goto no_dma_set;
- } else {
- goto fast_ata_pio;
- }
+ } else goto no_dma_set;
} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
- on = 0;
- verbose = 0;
no_dma_set:
config_chipset_for_pio(drive, 5);
}
@@ -618,12 +614,12 @@
static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
{
struct ata_channel *ch = drive->channel;
- unsigned long high_16 = pci_resource_start(ch->pci_dev, 4);
+ unsigned long high_16 = init_high_16(ch->pci_dev);
unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
if (drive->addressing) {
unsigned long word_count = 0;
- u8 clock = IN_BYTE(high_16 + 0x11);
+ u8 clock = PDC_CLOCK(high_16);
outb(clock|(ch->unit ? 0x08 : 0x02), high_16 + 0x11);
word_count = (rq->nr_sectors << 8);
@@ -644,14 +640,14 @@
int pdc202xx_udma_stop(struct ata_device *drive)
{
struct ata_channel *ch = drive->channel;
- unsigned long high_16 = pci_resource_start(ch->pci_dev, 4);
+ unsigned long high_16 = init_high_16(ch->pci_dev);
unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
unsigned long dma_base = ch->dma_base;
u8 dma_stat, clock;
if (drive->addressing) {
outl(0, atapi_reg); /* zero out extra */
- clock = IN_BYTE(high_16 + 0x11);
+ clock = PDC_CLOCK(high_16);
OUT_BYTE(clock & ~(ch->unit ? 0x08:0x02), high_16 + 0x11);
}
@@ -667,22 +663,10 @@
static int pdc202xx_udma_irq_status(struct ata_device *drive)
{
struct ata_channel *ch = drive->channel;
- unsigned long high_16 = pci_resource_start(ch->pci_dev, 4);
- u8 dma_stat, sc1d;
+ u8 dma_stat;
dma_stat = IN_BYTE(ch->dma_base + 2);
- sc1d = IN_BYTE(high_16 + 0x001d);
- if (ch->unit) {
- if ((sc1d & 0x50) == 0x50) goto somebody_else;
- else if ((sc1d & 0x40) == 0x40)
- return (dma_stat & 4) == 4;
- } else {
- if ((sc1d & 0x05) == 0x05) goto somebody_else;
- else if ((sc1d & 0x04) == 0x04)
- return (dma_stat & 4) == 4;
- }
-somebody_else:
return (dma_stat & 4) == 4; /* return 1 if INTR asserted */
}
@@ -710,8 +694,8 @@
void pdc202xx_reset(struct ata_device *drive)
{
- unsigned long high_16 = pci_resource_start(drive->channel->pci_dev, 4);
- byte udma_speed_flag = IN_BYTE(high_16 + 0x001f);
+ unsigned long high_16 = init_high_16(drive->channel->pci_dev);
+ byte udma_speed_flag = UDMA_SPEED_FLAG(high_16);
set_reg_and_wait(udma_speed_flag | 0x10, high_16 + 0x001f, 100);
set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000); /* 2 seconds ?! */
@@ -722,8 +706,8 @@
/* FIXME: should be splited for old & new chipsets --bkz */
static unsigned int __init pdc202xx_init_chipset(struct pci_dev *dev)
{
- unsigned long high_16 = pci_resource_start(dev, 4);
- byte udma_speed_flag = IN_BYTE(high_16 + 0x001f);
+ unsigned long high_16 = init_high_16(dev);
+ byte udma_speed_flag = UDMA_SPEED_FLAG(high_16);
byte primary_mode = IN_BYTE(high_16 + 0x001a);
byte secondary_mode = IN_BYTE(high_16 + 0x001b);
byte newchip = 0;
@@ -788,7 +772,7 @@
if (!(udma_speed_flag & 1)) {
printk("%s: FORCING BURST BIT 0x%02x -> 0x%02x ", dev->name, udma_speed_flag, (udma_speed_flag|1));
OUT_BYTE(udma_speed_flag|1, high_16 + 0x001f);
- printk("%sCTIVE\n", (IN_BYTE(high_16 + 0x001f) & 1) ? "A" : "INA");
+ printk("%sCTIVE\n", (UDMA_SPEED_FLAG(high_16) & 1) ? "A" : "INA");
}
#endif /* CONFIG_PDC202XX_BURST */
@@ -856,16 +840,13 @@
hwif->highmem = 1;
if (!noautodma)
hwif->autodma = 1;
- } else {
+ } else
+#endif
+ {
hwif->drives[0].autotune = 1;
hwif->drives[1].autotune = 1;
hwif->autodma = 0;
}
-#else
- hwif->drives[0].autotune = 1;
- hwif->drives[1].autotune = 1;
- hwif->autodma = 0;
-#endif
}
@@ -980,9 +961,8 @@
{
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(chipsets); ++i) {
+ for (i = 0; i < ARRAY_SIZE(chipsets); ++i)
ata_register_chipset(&chipsets[i]);
- }
return 0;
}
diff -urN linux-2.5.18/drivers/ide/piix.c linux/drivers/ide/piix.c
--- linux-2.5.18/drivers/ide/piix.c 2002-05-25 03:55:24.000000000 +0200
+++ linux/drivers/ide/piix.c 2002-05-29 18:13:50.000000000 +0200
@@ -351,8 +351,6 @@
piix_set_speed(drive->channel->pci_dev, drive->dn, &t, umul);
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return 0;
diff -urN linux-2.5.18/drivers/ide/serverworks.c linux/drivers/ide/serverworks.c
--- linux-2.5.18/drivers/ide/serverworks.c 2002-05-29 18:51:29.000000000 +0200
+++ linux/drivers/ide/serverworks.c 2002-05-29 18:13:51.000000000 +0200
@@ -357,8 +357,6 @@
pci_write_config_byte(dev, drive_pci3, ultra_timing);
pci_write_config_byte(dev, 0x54, ultra_enable);
#endif
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return ide_config_drive_speed(drive, speed);
diff -urN linux-2.5.18/drivers/ide/via82cxxx.c linux/drivers/ide/via82cxxx.c
--- linux-2.5.18/drivers/ide/via82cxxx.c 2002-05-25 03:55:23.000000000 +0200
+++ linux/drivers/ide/via82cxxx.c 2002-05-29 18:13:50.000000000 +0200
@@ -332,8 +332,6 @@
via_set_speed(drive->channel->pci_dev, drive->dn, &t);
- if (!drive->init_speed)
- drive->init_speed = speed;
drive->current_speed = speed;
return 0;
diff -urN linux-2.5.18/include/linux/ide.h linux/include/linux/ide.h
--- linux-2.5.18/include/linux/ide.h 2002-05-29 02:34:40.000000000 +0200
+++ linux/include/linux/ide.h 2002-05-29 18:17:48.000000000 +0200
@@ -393,7 +393,6 @@
int crc_count; /* crc counter to reduce drive speed */
byte quirk_list; /* drive is considered quirky if set for a specific host */
byte suspend_reset; /* drive suspend mode flag, soft-reset recovers */
- byte init_speed; /* transfer rate set at boot */
byte current_speed; /* current transfer rate set */
byte dn; /* now wide spread use */
byte wcache; /* status of write cache */
^ permalink raw reply [flat|nested] 10+ messages in thread