Re: [PATCH 3/9] ide-disk: remove stale init_idedisk_capacity() documentation

Previous thread: [PATCH] x86/percpu: silence section mismatch warnings related to EARLY_PER_CPU variables by Marcin Slusarz on Sunday, August 17, 2008 - 8:50 am. (4 messages)

Next thread: [PATCH 0/5] ide debugging macros by Borislav Petkov on Sunday, August 17, 2008 - 10:23 am. (12 messages)
From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:14 am

ACPI _GTM / _PS0 / _STM were not called if only slave device was present.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Index: b/drivers/ide/ide.c
===================================================================
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -365,15 +365,15 @@ __IDE_DEVSET(pio_mode, 0, NULL, set_pio_
 
 static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
 {
-	ide_drive_t *drive = dev->driver_data;
+	ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
 	ide_hwif_t *hwif = HWIF(drive);
 	struct request *rq;
 	struct request_pm_state rqpm;
 	ide_task_t args;
 	int ret;
 
-	/* Call ACPI _GTM only once */
-	if (!(drive->dn % 2))
+	/* call ACPI _GTM only once */
+	if ((drive->dn & 1) == 0 || pair == NULL)
 		ide_acpi_get_timing(hwif);
 
 	memset(&rqpm, 0, sizeof(rqpm));
@@ -389,26 +389,25 @@ static int generic_ide_suspend(struct de
 
 	ret = blk_execute_rq(drive->queue, NULL, rq, 0);
 	blk_put_request(rq);
-	/* only call ACPI _PS3 after both drivers are suspended */
-	if (!ret && (((drive->dn % 2) && hwif->drives[0].present
-		 && hwif->drives[1].present)
-		 || !hwif->drives[0].present
-		 || !hwif->drives[1].present))
+
+	/* call ACPI _PS3 only after both devices are suspended */
+	if (ret == 0 && ((drive->dn & 1) || pair == NULL))
 		ide_acpi_set_state(hwif, 0);
+
 	return ret;
 }
 
 static int generic_ide_resume(struct device *dev)
 {
-	ide_drive_t *drive = dev->driver_data;
+	ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
 	ide_hwif_t *hwif = HWIF(drive);
 	struct request *rq;
 	struct request_pm_state rqpm;
 	ide_task_t args;
 	int err;
 
-	/* Call ACPI _STM only once */
-	if (!(drive->dn % 2)) {
+	/* call ACPI _PS0 / _STM only once */
+	if ((drive->dn & 1) == 0 || pair == NULL) {
 		ide_acpi_set_state(hwif, 1);
 		ide_acpi_push_timing(hwif);
 ...
From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

* Return -EIO if arg > 0 and LBA48 is unsupported.

* No need to reset ->addressing.

* Make ->addressing a single bit flag.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-disk.c |   11 +++++------
 include/linux/ide.h    |    2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

Index: b/drivers/ide/ide-disk.c
===================================================================
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -694,14 +694,13 @@ static int set_addressing(ide_drive_t *d
 	if (arg < 0 || arg > 2)
 		return -EINVAL;
 
-	drive->addressing =  0;
-
-	if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48)
-		return 0;
-
-	if (ata_id_lba48_enabled(drive->id) == 0)
+	if (arg && ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) ||
+	    ata_id_lba48_enabled(drive->id) == 0))
 		return -EIO;
 
+	if (arg == 2)
+		arg = 0;
+
 	drive->addressing = arg;
 
 	return 0;
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -507,7 +507,7 @@ struct ide_drive_s {
 	unsigned sleeping	: 1;	/* 1=sleeping & sleep field valid */
 	unsigned post_reset	: 1;
 	unsigned udma33_warned	: 1;
-	unsigned addressing	: 2;	/* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */
+	unsigned addressing	: 1;	/* 0=28-bit, 1=48-bit */
 	unsigned wcache		: 1;	/* status of write cache */
 	unsigned nowerr		: 1;	/* used for ignoring ATA_DF */
 
--

From: Sergei Shtylyov
Date: Saturday, August 23, 2008 - 2:45 pm

Hello.


   Don't you want to get rid of things like:

        u8 lba48 = (drive->addressing == 1) ? 1 : 0;

MBR, Sergei


--

From: Bartlomiej Zolnierkiewicz
Date: Monday, August 25, 2008 - 1:23 pm

This was dealt with in "[PATCH 5/9] ide: add device flags" - since patch
#5/9 was going to touch the code anyway and there were no benefits besides
aesthetics in doing it in #2/9 I optimized the development process a bit...
--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-disk.c |   14 --------------
 1 file changed, 14 deletions(-)

Index: b/drivers/ide/ide-disk.c
===================================================================
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -375,20 +375,6 @@ static void idedisk_check_hpa(ide_drive_
 	}
 }
 
-/*
- * Compute drive->capacity, the full capacity of the drive
- * Called with drive->id != NULL.
- *
- * To compute capacity, this uses either of
- *
- *    1. CHS value set by user       (whatever user sets will be trusted)
- *    2. LBA value from target drive (require new ATA feature)
- *    3. LBA value from system BIOS  (new one is OK, old one may break)
- *    4. CHS value from system BIOS  (traditional style)
- *
- * in above order (i.e., if value of higher priority is available,
- * reset will be ignored).
- */
 static void init_idedisk_capacity(ide_drive_t *drive)
 {
 	u16 *id = drive->id;
--

From: Sergei Shtylyov
Date: Wednesday, August 20, 2008 - 3:06 am

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

MBR, Sergei


--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Add ide_do_setfeature() helper and convert set_{wcache,acoustic}()
to use it.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-disk.c |   34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

Index: b/drivers/ide/ide-disk.c
===================================================================
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -574,6 +574,19 @@ static int set_nowerr(ide_drive_t *drive
 	return 0;
 }
 
+static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect)
+{
+	ide_task_t task;
+
+	memset(&task, 0, sizeof(task));
+	task.tf.feature = feature;
+	task.tf.nsect   = nsect;
+	task.tf.command = ATA_CMD_SET_FEATURES;
+	task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
+
+	return ide_no_data_taskfile(drive, &task);
+}
+
 static void update_ordered(ide_drive_t *drive)
 {
 	u16 *id = drive->id;
@@ -613,19 +626,14 @@ ide_devset_get(wcache, wcache);
 
 static int set_wcache(ide_drive_t *drive, int arg)
 {
-	ide_task_t args;
 	int err = 1;
 
 	if (arg < 0 || arg > 1)
 		return -EINVAL;
 
 	if (ata_id_flush_enabled(drive->id)) {
-		memset(&args, 0, sizeof(ide_task_t));
-		args.tf.feature = arg ?
-			SETFEATURES_WC_ON : SETFEATURES_WC_OFF;
-		args.tf.command = ATA_CMD_SET_FEATURES;
-		args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
-		err = ide_no_data_taskfile(drive, &args);
+		err = ide_do_setfeature(drive,
+			arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0);
 		if (err == 0)
 			drive->wcache = arg;
 	}
@@ -652,18 +660,14 @@ ide_devset_get(acoustic, acoustic);
 
 static int set_acoustic(ide_drive_t *drive, int arg)
 {
-	ide_task_t args;
-
 	if (arg < 0 || arg > 254)
 		return -EINVAL;
 
-	memset(&args, 0, sizeof(ide_task_t));
-	args.tf.feature = arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF;
-	args.tf.nsect   = arg;
-	args.tf.command = ATA_CMD_SET_FEATURES;
-	args.tf_flags = ...
From: Sergei Shtylyov
Date: Wednesday, August 20, 2008 - 3:04 am

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

MBR, Sergei


--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields
to IDE_DFLAG_* flags.

While at it:
- IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48
- fixup some comments
- remove needless g->flags zeroing from ide*_probe()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-acpi.c         |   12 ++--
 drivers/ide/ide-atapi.c        |   21 ++++----
 drivers/ide/ide-cd.c           |   17 +++---
 drivers/ide/ide-disk.c         |   93 ++++++++++++++++++++++--------------
 drivers/ide/ide-dma.c          |    7 +-
 drivers/ide/ide-floppy.c       |    9 +--
 drivers/ide/ide-io.c           |   55 +++++++++++++--------
 drivers/ide/ide-ioctls.c       |   21 +++++---
 drivers/ide/ide-iops.c         |   24 +++++----
 drivers/ide/ide-lib.c          |    2 
 drivers/ide/ide-probe.c        |  104 ++++++++++++++++++++++-------------------
 drivers/ide/ide-proc.c         |    6 --
 drivers/ide/ide-tape.c         |   30 +++++++----
 drivers/ide/ide-taskfile.c     |   14 ++---
 drivers/ide/ide.c              |   35 ++++++++-----
 drivers/ide/legacy/ht6560b.c   |    9 +--
 drivers/ide/pci/amd74xx.c      |    2 
 drivers/ide/pci/cmd640.c       |   14 ++---
 drivers/ide/pci/it821x.c       |    2 
 drivers/ide/pci/ns87415.c      |   11 +++-
 drivers/ide/pci/pdc202xx_old.c |    4 -
 drivers/ide/pci/sc1200.c       |    3 -
 drivers/ide/pci/trm290.c       |    4 -
 drivers/ide/ppc/pmac.c         |    4 -
 drivers/scsi/ide-scsi.c        |    9 +--
 include/linux/ide.h            |  100 ++++++++++++++++++++++++++++-----------
 26 files changed, 370 insertions(+), 242 deletions(-)

Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -290,7 +290,7 @@ static int do_drive_get_GTF(ide_drive_t 
 	DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
 		 hwif->name, dev->bus_id, port, ...
From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Add IDE_DFLAG_DMA_PIO_RETRY and use it instead of
ide_drive_t.state + DMA_PIO_RETRY.

There should be no functional changes cause by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-io.c |    7 ++++---
 include/linux/ide.h  |    9 ++-------
 2 files changed, 6 insertions(+), 10 deletions(-)

Index: b/drivers/ide/ide-io.c
===================================================================
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -78,8 +78,9 @@ static int __ide_end_request(ide_drive_t
 	 * decide whether to reenable DMA -- 3 is a random magic for now,
 	 * if we DMA timeout more than 3 times, just stay in PIO
 	 */
-	if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) {
-		drive->state = 0;
+	if ((drive->dev_flags & IDE_DFLAG_DMA_PIO_RETRY) &&
+	    drive->retry_pio <= 3) {
+		drive->dev_flags &= ~IDE_DFLAG_DMA_PIO_RETRY;
 		ide_dma_on(drive);
 	}
 
@@ -1195,8 +1196,8 @@ static ide_startstop_t ide_dma_timeout_r
 	 * a timeout -- we'll reenable after we finish this next request
 	 * (or rather the first chunk of it) in pio.
 	 */
+	drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY;
 	drive->retry_pio++;
-	drive->state = DMA_PIO_RETRY;
 	ide_dma_off_quietly(drive);
 
 	/*
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -48,12 +48,6 @@ typedef unsigned char	byte;	/* used ever
 #define ERROR_RESET	3	/* Reset controller every 4th retry */
 #define ERROR_RECAL	1	/* Recalibrate every 2nd retry */
 
-/*
- * state flags
- */
-
-#define DMA_PIO_RETRY	1	/* retrying in PIO */
-
 #define HWIF(drive)		((ide_hwif_t *)((drive)->hwif))
 #define HWGROUP(drive)		((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
 
@@ -504,6 +498,8 @@ enum {
 	IDE_DFLAG_WCACHE		= (1 << 23),
 	/* used for ignoring ATA_DF */
 	IDE_DFLAG_NOWERR		= (1 << 24),
+	/* retrying in PIO */
+	IDE_DFLAG_DMA_PIO_RETRY		= (1 << 25),
 };
 
 ...
From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-cd.c     |    1 -
 drivers/ide/ide-disk.c   |    1 -
 drivers/ide/ide-floppy.c |    1 -
 drivers/ide/ide-tape.c   |    1 -
 drivers/scsi/ide-scsi.c  |    1 -
 include/linux/ide.h      |    1 -
 6 files changed, 6 deletions(-)

Index: b/drivers/ide/ide-cd.c
===================================================================
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1967,7 +1967,6 @@ static ide_driver_t ide_cdrom_driver = {
 	.probe			= ide_cd_probe,
 	.remove			= ide_cd_remove,
 	.version		= IDECD_VERSION,
-	.media			= ide_cdrom,
 	.do_request		= ide_cd_do_request,
 	.end_request		= ide_end_request,
 	.error			= __ide_error,
Index: b/drivers/ide/ide-disk.c
===================================================================
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -932,7 +932,6 @@ static ide_driver_t idedisk_driver = {
 	.resume			= ide_disk_resume,
 	.shutdown		= ide_device_shutdown,
 	.version		= IDEDISK_VERSION,
-	.media			= ide_disk,
 	.do_request		= ide_do_rw_disk,
 	.end_request		= ide_end_request,
 	.error			= __ide_error,
Index: b/drivers/ide/ide-floppy.c
===================================================================
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -664,7 +664,6 @@ static ide_driver_t idefloppy_driver = {
 	.probe			= ide_floppy_probe,
 	.remove			= ide_floppy_remove,
 	.version		= IDEFLOPPY_VERSION,
-	.media			= ide_floppy,
 	.do_request		= idefloppy_do_request,
 	.end_request		= idefloppy_end_request,
 	.error			= __ide_error,
Index: b/drivers/ide/ide-tape.c
===================================================================
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2324,7 +2324,6 @@ static ide_driver_t idetape_driver = {
 	.probe			= ide_tape_probe,
 	.remove			= ide_tape_remove,
 	.version		= IDETAPE_VERSION,
-	.media			= ide_tape,
 	.do_request		= idetape_do_request,
 ...
From: Sergei Shtylyov
Date: Saturday, August 23, 2008 - 2:07 pm

Hello.


Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

MBR, Sergei


--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-dma.c      |    2 --
 drivers/ide/pci/scc_pata.c |    2 --
 include/linux/ide.h        |    2 --
 3 files changed, 6 deletions(-)

Index: b/drivers/ide/ide-dma.c
===================================================================
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -525,7 +525,6 @@ void ide_dma_start(ide_drive_t *drive)
 		outb(dma_cmd | 1, hwif->dma_base + ATA_DMA_CMD);
 	}
 
-	hwif->dma = 1;
 	wmb();
 }
 
@@ -564,7 +563,6 @@ int __ide_dma_end (ide_drive_t *drive)
 	/* purge DMA mappings */
 	ide_destroy_dmatable(drive);
 	/* verify good DMA status */
-	hwif->dma = 0;
 	wmb();
 	return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0;
 }
Index: b/drivers/ide/pci/scc_pata.c
===================================================================
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -353,7 +353,6 @@ static void scc_dma_start(ide_drive_t *d
 
 	/* start DMA */
 	scc_ide_outb(dma_cmd | 1, hwif->dma_base);
-	hwif->dma = 1;
 	wmb();
 }
 
@@ -374,7 +373,6 @@ static int __scc_dma_end(ide_drive_t *dr
 	/* purge DMA mappings */
 	ide_destroy_dmatable(drive);
 	/* verify good DMA status */
-	hwif->dma = 0;
 	wmb();
 	return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0;
 }
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -745,8 +745,6 @@ typedef struct hwif_s {
 
 	void		*hwif_data;	/* extra hwif data */
 
-	unsigned dma;
-
 #ifdef CONFIG_BLK_DEV_IDEACPI
 	struct ide_acpi_hwif_link *acpidata;
 #endif
--

From: Sergei Shtylyov
Date: Wednesday, August 20, 2008 - 3:15 am

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

MBR, Sergei


--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 17, 2008 - 10:15 am

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-dma.c         |    4 +---
 drivers/ide/mips/au1xxx-ide.c |    6 +-----
 drivers/ide/pci/hpt366.c      |    3 ---
 drivers/ide/pci/scc_pata.c    |    3 ---
 drivers/ide/ppc/pmac.c        |    3 ---
 5 files changed, 2 insertions(+), 17 deletions(-)

Index: b/drivers/ide/ide-dma.c
===================================================================
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -578,9 +578,7 @@ int ide_dma_test_irq(ide_drive_t *drive)
 	/* return 1 if INTR asserted */
 	if ((dma_stat & 4) == 4)
 		return 1;
-	if (!drive->waiting_for_dma)
-		printk(KERN_WARNING "%s: (%s) called while not waiting\n",
-			drive->name, __func__);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ide_dma_test_irq);
Index: b/drivers/ide/mips/au1xxx-ide.c
===================================================================
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -322,11 +322,7 @@ static int auide_dma_setup(ide_drive_t *
 }
 
 static int auide_dma_test_irq(ide_drive_t *drive)
-{	
-	if (drive->waiting_for_dma == 0)
-		printk(KERN_WARNING "%s: ide_dma_test_irq \
-                                     called while not waiting\n", drive->name);
-
+{
 	/* If dbdma didn't execute the STOP command yet, the
 	 * active bit is still set
 	 */
Index: b/drivers/ide/pci/hpt366.c
===================================================================
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -861,9 +861,6 @@ static int hpt374_dma_test_irq(ide_drive
 	if (dma_stat & 4)
 		return 1;
 
-	if (!drive->waiting_for_dma)
-		printk(KERN_WARNING "%s: (%s) called while not waiting\n",
-				drive->name, __func__);
 	return 0;
 }
 
Index: b/drivers/ide/pci/scc_pata.c
===================================================================
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -509,9 +509,6 @@ static int scc_dma_test_irq(ide_drive_t ...
From: Sergei Shtylyov
Date: Wednesday, August 20, 2008 - 3:08 am

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

MBR, Sergei


--

Previous thread: [PATCH] x86/percpu: silence section mismatch warnings related to EARLY_PER_CPU variables by Marcin Slusarz on Sunday, August 17, 2008 - 8:50 am. (4 messages)

Next thread: [PATCH 0/5] ide debugging macros by Borislav Petkov on Sunday, August 17, 2008 - 10:23 am. (12 messages)