Skip to contentSkip to conversation

2.5.30 IDE 113

PATCH New Marcin Dalecki 1 participant 1 message Aug 6, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.30 IDE 113

OK now an interresting part.

- Split up the handling of SG list setup, so we can now handle the TRM-290, which is using a custom physical layout better. The BIO code for detecting sectors crossing sector size boundaries is still, well somehow flaky. One thing for example is that the PIIX4 docu states cleanly that all SG list entires should be double word aligned, but we don't see any code there to maintain this property. Purly accidentally the kernel allocation code is maintaining cache boundaries, which makes this code work accidentally right now :-/ We will target this next.

- Make some local stuff properly tagged as static. Review the host controller code for such occurencies.

- Actually use blk_insert_request() in ide_raw_taskfile. Use a preallocated structure there for REQ_SPECIAL requests to avoid passing down values residing on the stack.

- Open code ata_start_dma() to make the host controller drivers more independant from the generic code. We don't have anything chipset specific in pcidma.c anylonger.

drivers/ide/alim15x3.c +3 -5
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/alim15x3.c linux/drivers/ide/alim15x3.c
@@ -362,12 +362,10 @@ static void __init ali15x3_init_channel(
 
 static void __init ali15x3_init_dma(struct ata_channel *ch, unsigned long dmabase)
 {
-	if (dmabase && (m5229_revision < 0x20)) {
+	if (dmabase && (m5229_revision < 0x20))
 		ch->autodma = 0;
-		return;
-	}
-
-	ata_init_dma(ch, dmabase);
+	else
+		ata_init_dma(ch, dmabase);
 }
 
 
drivers/ide/cmd640.c +14 -18
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/cmd640.c linux/drivers/ide/cmd640.c
@@ -220,7 +220,7 @@ static unsigned int cmd640_chip_version;
 static void put_cmd640_reg_pci1 (unsigned short reg, u8 val)
 {
 	unsigned long flags;
-	
+
 	spin_lock_irqsave(&pci_lock, flags);
 	outb_p((reg & 0xfc) | cmd640_key, 0xcf8);
 	outb_p(val, (reg & 3) | 0xcfc);
@@ -382,7 +382,7 @@ static int __init secondary_port_respond
 /*
  * Dump out all cmd640 registers.  May be called from ide.c
  */
-void cmd640_dump_regs (void)
+static void cmd640_dump_regs (void)
 {
 	unsigned int reg = cmd640_vlb ? 0x50 : 0x00;
 
@@ -693,18 +693,17 @@ out_lock:
 
 #endif
 
-/**
- *	pci_conf1	-	check for PCI type 1 configuration
- *	
- *	Issues a safe probe sequence for PCI configuration type 1 and
- *	returns non-zero if conf1 is supported. Takes the pci_config lock
+/*
+ * Check for PCI type 1 configuration
+ *
+ * Issues a safe probe sequence for PCI configuration type 1 and
+ * returns non-zero if conf1 is supported. Takes the pci_config lock
  */
- 
 static int pci_conf1(void)
 {
 	u32 tmp;
 	unsigned long flags;
-	
+
 	spin_lock_irqsave(&pci_lock, flags);
 
 	OUT_BYTE(0x01, 0xCFB);
@@ -720,19 +719,17 @@ static int pci_conf1(void)
 	return 0;
 }
 
-/**
- *	pci_conf2	-	check for PCI type 2 configuration
- *	
- *	Issues a safe probe sequence for PCI configuration type 2 and
- *	returns non-zero if conf2 is supported. Takes the pci_config lock.
+/*
+ * Check for PCI type 2 configuration
+ *
+ * Issues a safe probe sequence for PCI configuration type 2 and
+ * returns non-zero if conf2 is supported. Takes the pci_config lock.
  */
- 
-
 static int pci_conf2(void)
 {
 	unsigned long flags;
 	spin_lock_irqsave(&pci_lock, flags);
-	
+
 	OUT_BYTE(0x00, 0xCFB);
 	OUT_BYTE(0x00, 0xCF8);
 	OUT_BYTE(0x00, 0xCFA);
@@ -904,4 +901,3 @@ int __init ide_probe_for_cmd640x(void)
 #endif
 	return 1;
 }
-
drivers/ide/cmd64x.c +3 -3
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/cmd64x.c linux/drivers/ide/cmd64x.c
@@ -30,9 +30,9 @@
 #define CMD_DEBUG 0
 
 #if CMD_DEBUG
-#define cmdprintk(x...)	printk(##x)
+# define cmdprintk(x...)	printk(##x)
 #else
-#define cmdprintk(x...)
+# define cmdprintk(x...)
 #endif
 
 /*
@@ -49,7 +49,7 @@
 #define	CMDTIM		0x52
 #define	ARTTIM0		0x53
 #define	DRWTIM0		0x54
-#define ARTTIM1 	0x55
+#define ARTTIM1		0x55
 #define DRWTIM1		0x56
 #define ARTTIM23	0x57
 #define   ARTTIM23_DIS_RA2	0x04
drivers/ide/cs5530.c +1 -1
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/cs5530.c linux/drivers/ide/cs5530.c
@@ -35,7 +35,7 @@
 /*
  * Set a new transfer mode at the drive
  */
-int cs5530_set_xfer_mode(struct ata_device *drive, u8 mode)
+static int cs5530_set_xfer_mode(struct ata_device *drive, u8 mode)
 {
 	int error = 0;
 
drivers/ide/hpt34x.c +18 -11
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/hpt34x.c linux/drivers/ide/hpt34x.c
@@ -99,26 +99,33 @@ static int hpt34x_udma_init(struct ata_d
 {
 	struct ata_channel *ch = drive->channel;
 	unsigned long dma_base = ch->dma_base;
-	unsigned int count;
 	u8 cmd;
 
-	if (!(count = udma_new_table(drive, rq)))
-		return ATA_OP_FINISHED;	/* try PIO instead of DMA */
+	/* try PIO instead of DMA */
+	if (!udma_new_table(drive, rq))
+		return ATA_OP_FINISHED;
 
+	/* No DMA transfers on ATAPI devices. */
+	if (drive->type != ATA_DISK)
+		return ATA_OP_CONTINUES;
+
+	/* The only difference from standard PIIX code is that we must have the
+	 * lowest bit set in the command word here.
+	 */
 	if (rq_data_dir(rq) == READ)
 		cmd = 0x09;
 	else
 		cmd = 0x01;
 
-	outl(ch->dmatable_dma, dma_base + 4);	/* PRD table */
-	outb(cmd, dma_base);			/* specify r/w */
-	outb(inb(dma_base+2)|6, dma_base+2);	/* clear INTR & ERROR flags */
+	outl(ch->dmatable_dma, dma_base + 4);		/* PRD table */
+	outb(cmd, dma_base);				/* specify r/w */
+	outb(inb(dma_base + 2) | 6, dma_base + 2);	/* clear INTR & ERROR flags */
 
-	if (drive->type == ATA_DISK) {
-		ata_set_handler(drive, ide_dma_intr, WAIT_CMD, NULL);	/* issue cmd to drive */
-		OUT_BYTE((cmd == 0x09) ? WIN_READDMA : WIN_WRITEDMA, IDE_COMMAND_REG);
-	}
+	ata_set_handler(drive, ide_dma_intr, WAIT_CMD, NULL);
+	/* issue cmd to drive */
+	OUT_BYTE((cmd == 0x09) ? WIN_READDMA : WIN_WRITEDMA, IDE_COMMAND_REG);
 
+	/* FIXME: should we call udma_start here?! */
 	return ATA_OP_CONTINUES;
 }
 #endif
@@ -190,7 +197,7 @@ static void __init ide_init_hpt34x(struc
 		hwif->no_atapi_autodma = 1;
 		hwif->udma_setup = hpt34x_udma_setup;
 		hwif->highmem = 1;
-	} else 
+	} else
 #endif
 	{
 		hwif->drives[0].autotune = 1;
drivers/ide/icside.c +1 -1
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/icside.c linux/drivers/ide/icside.c
@@ -598,7 +598,7 @@ failed:
 	return 0;
 }
 
-void ide_release_dma(struct ata_channel *ch)
+void ata_release_dma(struct ata_channel *ch)
 {
 	if (ch->sg_table) {
 		kfree(ch->sg_table);
drivers/ide/ide-taskfile.c +4 -19
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/ide-taskfile.c linux/drivers/ide/ide-taskfile.c
@@ -188,41 +188,26 @@ static ide_startstop_t special_intr(stru
 
 int ide_raw_taskfile(struct ata_device *drive, struct ata_taskfile *ar, char *buf)
 {
-	struct request *rq;
-	unsigned long flags;
+	struct request *rq = &drive->srequest;
 	struct ata_channel *ch = drive->channel;
 	request_queue_t *q = &drive->queue;
-	struct list_head *queue_head = &q->queue_head;
 	DECLARE_COMPLETION(wait);
-	struct request req;
 
 #ifdef CONFIG_BLK_DEV_PDC4030
 	if (ch->chipset == ide_pdc4030 && buf)
 		return -ENOSYS;  /* special drive cmds not supported */
 #endif
 
-	memset(&req, 0, sizeof(req));
-	rq = &req;
-	
-	rq->flags = REQ_SPECIAL;
+	memset(rq, 0, sizeof(*rq));
+
 	rq->buffer = buf;
-	rq->special = ar;
-	rq->errors = 0;
 	rq->rq_status = RQ_ACTIVE;
 	rq->waiting = &wait;
 
 	ar->XXX_handler = special_intr;
 	ar->command_type = IDE_DRIVE_TASK_NO_DATA;
 
-	spin_lock_irqsave(ch->lock, flags);
-
-	if (!blk_queue_empty(&drive->queue))
-		queue_head = queue_head->prev;
-	__elv_add_request(q, rq, queue_head);
-
-	q->request_fn(q);
-	spin_unlock_irqrestore(ch->lock, flags);
-
+	blk_insert_request(q, rq, 1, ar);
 	wait_for_completion(&wait);	/* wait for it to be serviced */
 
 	return rq->errors ? -EIO : 0;	/* return -EIO if errors */
drivers/ide/main.c +1 -1
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/main.c linux/drivers/ide/main.c
@@ -478,7 +478,7 @@ void ide_unregister(struct ata_channel *
 	}
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-	ide_release_dma(ch);
+	ata_release_dma(ch);
 #endif
 
 	/*
drivers/ide/opti621.c +7 -6
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/opti621.c linux/drivers/ide/opti621.c
@@ -130,7 +130,7 @@
 #define STRAP_REG 5	/* index of Strap register */
 #define MISC_REG 6	/* index of Miscellaneous register */
 
-int reg_base;
+static int reg_base;
 
 #define PIO_NOT_EXIST 254
 #define PIO_DONT_KNOW 255
@@ -244,10 +244,11 @@ static void compute_clocks(int pio, pio_
 
 }
 
-/* Main tune procedure, called from tuneproc.
-   Assumes IRQ's are disabled or at least that no other process will
-   attempt to access the IDE registers concurrently.
-*/
+/*
+ * Main tune procedure, called from tuneproc.
+ * Assumes IRQ's are disabled or at least that no other process will
+ * attempt to access the IDE registers concurrently.
+ */
 static void opti621_tune_drive(struct ata_device *drive, u8 pio)
 {
 	/* primary and secondary drives share some registers,
@@ -308,7 +309,7 @@ static void opti621_tune_drive(struct at
 }
 
 /*
- * ide_init_opti621() is called once for each hwif found at boot.
+ * This is called once for each hwif found at boot.
  */
 static void __init ide_init_opti621(struct ata_channel *hwif)
 {
drivers/ide/pcidma.c +50 -122

256 lines not on this page · raw message

drivers/ide/pdc202xx.c +4 -4
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/pdc202xx.c linux/drivers/ide/pdc202xx.c
@@ -3,7 +3,7 @@
  *  linux/drivers/ide/pdc202xx.c	Version 0.30	May. 28, 2002
  *
  *  Copyright (C) 1998-2000	Andre Hedrick <[email protected]>
- *  Copyright (C) 2002		Bart�^�omiej Żo�^�nierkiewicz
+ *  Copyright (C) 2002		Bartłomiej Żołnierkiewicz
  *
  *  Portions Copyright (C) 1999-2002 Promise Technology, Inc.
  *  Author:	Frank Tiernan <[email protected]>
@@ -117,11 +117,11 @@ static void pdc_dump_bits(struct pdc_bit
 
 	printk(KERN_DEBUG " }\n");
 }
-#endif				/* PDC202XX_DECODE_REGISTER_INFO */
+#endif
 
 static struct ata_device *drives[4];
 
-int check_in_drive_lists(struct ata_device *drive)
+static int check_in_drive_lists(struct ata_device *drive)
 {
 	static const char *pdc_quirk_drives[] = {
 		"QUANTUM FIREBALLlct08 08",
@@ -661,7 +661,7 @@ static void pdc202xx_reset_host(struct p
 	printk(KERN_INFO "%s: device reseted.\n", dev->name);
 }
 
-void pdc202xx_reset(struct ata_device *drive)
+static void pdc202xx_reset(struct ata_device *drive)
 {
 	struct ata_channel *ch = drive->channel;
 	printk(KERN_INFO "%s: channel needs reset.\n", ch->name);
drivers/ide/piix.c +2 -2
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/piix.c linux/drivers/ide/piix.c
@@ -380,8 +380,8 @@ static void __init piix_init_channel(str
 static void __init piix_init_dma(struct ata_channel *ch, unsigned long dmabase)
 {
 	if (((piix_enabled >> ch->unit) & 1)
-		&& !(piix_config->flags & PIIX_NODMA))
-			ata_init_dma(ch, dmabase);
+			&& !(piix_config->flags & PIIX_NODMA))
+		ata_init_dma(ch, dmabase);
 }
 
 
drivers/ide/tcq.c +15 -1
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/tcq.c linux/drivers/ide/tcq.c
@@ -523,10 +523,14 @@ static int tcq_wait_dataphase(struct ata
 /*
  * Invoked from a SERVICE interrupt, command etc already known.  Just need to
  * start the dma engine for this tag.
+ *
+ * FIXME: Integrate this with udma_pci_init().
  */
 static ide_startstop_t udma_tcq_start(struct ata_device *drive, struct request *rq)
 {
 	struct ata_channel *ch = drive->channel;
+	unsigned long dma_base = ch->dma_base;
+	u8 cmd = 0;
 
 	TCQ_PRINTK("%s: setting up queued %d\n", __FUNCTION__, rq->tag);
 	if (!test_bit(IDE_BUSY, ch->active))
@@ -535,9 +539,19 @@ static ide_startstop_t udma_tcq_start(st
 	if (tcq_wait_dataphase(drive))
 		return ATA_OP_FINISHED;
 
-	if (ata_start_dma(drive, rq))
+	/* try PIO instead of DMA */
+	if (!udma_new_table(drive, rq))
 		return ATA_OP_FINISHED;
 
+	if (rq_data_dir(rq) == READ)
+		cmd = 0x08;
+	else
+		cmd = 0x00;
+
+	outl(ch->dmatable_dma, dma_base + 4);		/* PRD table */
+	outb(cmd, dma_base);				/* specify r/w */
+	outb(inb(dma_base + 2) | 6, dma_base + 2);	/* clear INTR & ERROR flags */
+
 	__set_irq(ch, ide_dmaq_intr);
 	udma_start(drive, rq);
 
drivers/ide/trm290.c +112 -51

245 lines not on this page · raw message

drivers/ide/umc8672.c +2 -4
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/umc8672.c linux/drivers/ide/umc8672.c
@@ -2,9 +2,7 @@
  *  linux/drivers/ide/umc8672.c		Version 0.05	Jul 31, 1996
  *
  *  Copyright (C) 1995-1996  Linus Torvalds & author (see below)
- */
-
-/*
+ *
  *  Principal Author/Maintainer:  [email protected] (Wolfram Podien)
  *
  *  This file provides support for the advanced features
@@ -118,7 +116,7 @@ static void tune_umc(struct ata_device *
 	umc_set_speeds (current_speeds);
 }
 
-void __init init_umc8672(void)	/* called from ide.c */
+void __init init_umc8672(void)
 {
 	unsigned long flags;
 
drivers/ide/via82cxxx.c +1 -3
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/drivers/ide/via82cxxx.c linux/drivers/ide/via82cxxx.c
@@ -8,9 +8,7 @@
  *	Michel Aubry
  *	Jeff Garzik
  *	Andre Hedrick
- */
-
-/*
+ *
  * VIA IDE driver for Linux. Supports
  *
  *   vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b,
include/linux/ide.h +2 -2
diff -durNp -X /tmp/diff.hDAz3d linux-2.5.30/include/linux/ide.h linux/include/linux/ide.h
@@ -763,6 +763,7 @@ struct ata_device {
 
 	request_queue_t	queue;		/* per device request queue */
 	struct request *rq;		/* current request */
+	struct request srequest;	/* special requests */
 
 	u8	 retry_pio;		/* retrying dma capable host in pio */
 	u8	 state;			/* retry state */
@@ -1245,10 +1246,9 @@ extern int udma_tcq_enable(struct ata_de
 
 extern ide_startstop_t ide_dma_intr(struct ata_device *, struct request *);
 extern int check_drive_lists(struct ata_device *, int good_bad);
-extern void ide_release_dma(struct ata_channel *);
-extern int ata_start_dma(struct ata_device *, struct request *rq);
 
 extern void ata_init_dma(struct ata_channel *,	unsigned long) __init;
+extern void ata_release_dma(struct ata_channel *);
 
 #endif