linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [git pull] IDE fixes
@ 2009-02-25 19:54 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-02-25 19:54 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


amd74xx/atiixp bugfixes (from Roel Kluin), host driver module removal
issue fix (debugged/tested by Stanislaw Gruszka) and ide documentation
updates (from David Fries)

Linus, Please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 Documentation/kernel-parameters.txt |    6 ++++--
 drivers/ide/Kconfig                 |    2 +-
 drivers/ide/amd74xx.c               |    2 +-
 drivers/ide/atiixp.c                |    4 ++--
 drivers/ide/ide-cd.c                |   35 ++++++++++++++++++++++++++---------
 drivers/ide/ide-cd.h                |    2 +-
 drivers/ide/ide-gd.c                |   26 +++++++++++++++++---------
 drivers/ide/ide-gd.h                |    2 +-
 drivers/ide/ide-tape.c              |   29 +++++++++++++++++++----------
 drivers/ide/ide.c                   |   11 ++++++++---
 drivers/ide/it821x.c                |    5 ++---
 include/linux/ide.h                 |    2 +-
 12 files changed, 83 insertions(+), 43 deletions(-)


Bartlomiej Zolnierkiewicz (3):
      it821x: remove dead URL
      ide-cd: document capacity hack
      ide: fix refcounting in device drivers

David Fries (1):
      ide: ide.c 'clear' fix, update "ide=nodma" documentation

Roel Kluin (2):
      amd74xx: device/vendor confusion
      atiixp: fix missing parentheses


diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 319785b..0ed3234 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -868,8 +868,10 @@ and is between 256 and 4096 characters. It is defined in the file
 	icn=		[HW,ISDN]
 			Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]
 
-	ide=		[HW] (E)IDE subsystem
-			Format: ide=nodma or ide=doubler
+	ide-core.nodma=	[HW] (E)IDE subsystem
+			Format: =0.0 to prevent dma on hda, =0.1 hdb =1.0 hdc
+			.vlb_clock .pci_clock .noflush .noprobe .nowerr .cdrom
+			.chs .ignore_cable are additional options
 			See Documentation/ide/ide.txt.
 
 	idebus=		[HW] (E)IDE subsystem - VLB/PCI bus speed
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 3dad229..e072903 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -46,7 +46,7 @@ menuconfig IDE
 	  SMART parameters from disk drives.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called ide.
+	  module will be called ide-core.ko.
 
 	  For further information, please read <file:Documentation/ide/ide.txt>.
 
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
index 69660a4..77267c8 100644
--- a/drivers/ide/amd74xx.c
+++ b/drivers/ide/amd74xx.c
@@ -166,7 +166,7 @@ static unsigned int init_chipset_amd74xx(struct pci_dev *dev)
 	 * Check for broken FIFO support.
 	 */
 	if (dev->vendor == PCI_VENDOR_ID_AMD &&
-	    dev->vendor == PCI_DEVICE_ID_AMD_VIPER_7411)
+	    dev->device == PCI_DEVICE_ID_AMD_VIPER_7411)
 		t &= 0x0f;
 	else
 		t |= 0xf0;
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c
index b2735d2..ecd1e62 100644
--- a/drivers/ide/atiixp.c
+++ b/drivers/ide/atiixp.c
@@ -52,7 +52,7 @@ static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
 	struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
 	unsigned long flags;
-	int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8;
+	int timing_shift = (drive->dn ^ 1) * 8;
 	u32 pio_timing_data;
 	u16 pio_mode_data;
 
@@ -85,7 +85,7 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
 	struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
 	unsigned long flags;
-	int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8;
+	int timing_shift = (drive->dn ^ 1) * 8;
 	u32 tmp32;
 	u16 tmp16;
 	u16 udma_ctl = 0;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 0bfeb0c..ddfbea4 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -55,7 +55,7 @@
 
 static DEFINE_MUTEX(idecd_ref_mutex);
 
-static void ide_cd_release(struct kref *);
+static void ide_cd_release(struct device *);
 
 static struct cdrom_info *ide_cd_get(struct gendisk *disk)
 {
@@ -67,7 +67,7 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk)
 		if (ide_device_get(cd->drive))
 			cd = NULL;
 		else
-			kref_get(&cd->kref);
+			get_device(&cd->dev);
 
 	}
 	mutex_unlock(&idecd_ref_mutex);
@@ -79,7 +79,7 @@ static void ide_cd_put(struct cdrom_info *cd)
 	ide_drive_t *drive = cd->drive;
 
 	mutex_lock(&idecd_ref_mutex);
-	kref_put(&cd->kref, ide_cd_release);
+	put_device(&cd->dev);
 	ide_device_put(drive);
 	mutex_unlock(&idecd_ref_mutex);
 }
@@ -194,6 +194,14 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
 			bio_sectors = max(bio_sectors(failed_command->bio), 4U);
 			sector &= ~(bio_sectors - 1);
 
+			/*
+			 * The SCSI specification allows for the value
+			 * returned by READ CAPACITY to be up to 75 2K
+			 * sectors past the last readable block.
+			 * Therefore, if we hit a medium error within the
+			 * last 75 2K sectors, we decrease the saved size
+			 * value.
+			 */
 			if (sector < get_capacity(info->disk) &&
 			    drive->probed_capacity - sector < 4 * 75)
 				set_capacity(info->disk, sector);
@@ -1790,15 +1798,17 @@ static void ide_cd_remove(ide_drive_t *drive)
 	ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
 
 	ide_proc_unregister_driver(drive, info->driver);
-
+	device_del(&info->dev);
 	del_gendisk(info->disk);
 
-	ide_cd_put(info);
+	mutex_lock(&idecd_ref_mutex);
+	put_device(&info->dev);
+	mutex_unlock(&idecd_ref_mutex);
 }
 
-static void ide_cd_release(struct kref *kref)
+static void ide_cd_release(struct device *dev)
 {
-	struct cdrom_info *info = to_ide_drv(kref, cdrom_info);
+	struct cdrom_info *info = to_ide_drv(dev, cdrom_info);
 	struct cdrom_device_info *devinfo = &info->devinfo;
 	ide_drive_t *drive = info->drive;
 	struct gendisk *g = info->disk;
@@ -1997,7 +2007,12 @@ static int ide_cd_probe(ide_drive_t *drive)
 
 	ide_init_disk(g, drive);
 
-	kref_init(&info->kref);
+	info->dev.parent = &drive->gendev;
+	info->dev.release = ide_cd_release;
+	dev_set_name(&info->dev, dev_name(&drive->gendev));
+
+	if (device_register(&info->dev))
+		goto out_free_disk;
 
 	info->drive = drive;
 	info->driver = &ide_cdrom_driver;
@@ -2011,7 +2026,7 @@ static int ide_cd_probe(ide_drive_t *drive)
 	g->driverfs_dev = &drive->gendev;
 	g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
 	if (ide_cdrom_setup(drive)) {
-		ide_cd_release(&info->kref);
+		put_device(&info->dev);
 		goto failed;
 	}
 
@@ -2021,6 +2036,8 @@ static int ide_cd_probe(ide_drive_t *drive)
 	add_disk(g);
 	return 0;
 
+out_free_disk:
+	put_disk(g);
 out_free_cd:
 	kfree(info);
 failed:
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index ac40d6c..c878bfc 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -80,7 +80,7 @@ struct cdrom_info {
 	ide_drive_t		*drive;
 	struct ide_driver	*driver;
 	struct gendisk		*disk;
-	struct kref		kref;
+	struct device		dev;
 
 	/* Buffer for table of contents.  NULL if we haven't allocated
 	   a TOC buffer for this device yet. */
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 7857b20..0471094 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -25,7 +25,7 @@ module_param(debug_mask, ulong, 0644);
 
 static DEFINE_MUTEX(ide_disk_ref_mutex);
 
-static void ide_disk_release(struct kref *);
+static void ide_disk_release(struct device *);
 
 static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
 {
@@ -37,7 +37,7 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
 		if (ide_device_get(idkp->drive))
 			idkp = NULL;
 		else
-			kref_get(&idkp->kref);
+			get_device(&idkp->dev);
 	}
 	mutex_unlock(&ide_disk_ref_mutex);
 	return idkp;
@@ -48,7 +48,7 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
 	ide_drive_t *drive = idkp->drive;
 
 	mutex_lock(&ide_disk_ref_mutex);
-	kref_put(&idkp->kref, ide_disk_release);
+	put_device(&idkp->dev);
 	ide_device_put(drive);
 	mutex_unlock(&ide_disk_ref_mutex);
 }
@@ -66,17 +66,18 @@ static void ide_gd_remove(ide_drive_t *drive)
 	struct gendisk *g = idkp->disk;
 
 	ide_proc_unregister_driver(drive, idkp->driver);
-
+	device_del(&idkp->dev);
 	del_gendisk(g);
-
 	drive->disk_ops->flush(drive);
 
-	ide_disk_put(idkp);
+	mutex_lock(&ide_disk_ref_mutex);
+	put_device(&idkp->dev);
+	mutex_unlock(&ide_disk_ref_mutex);
 }
 
-static void ide_disk_release(struct kref *kref)
+static void ide_disk_release(struct device *dev)
 {
-	struct ide_disk_obj *idkp = to_ide_drv(kref, ide_disk_obj);
+	struct ide_disk_obj *idkp = to_ide_drv(dev, ide_disk_obj);
 	ide_drive_t *drive = idkp->drive;
 	struct gendisk *g = idkp->disk;
 
@@ -348,7 +349,12 @@ static int ide_gd_probe(ide_drive_t *drive)
 
 	ide_init_disk(g, drive);
 
-	kref_init(&idkp->kref);
+	idkp->dev.parent = &drive->gendev;
+	idkp->dev.release = ide_disk_release;
+	dev_set_name(&idkp->dev, dev_name(&drive->gendev));
+
+	if (device_register(&idkp->dev))
+		goto out_free_disk;
 
 	idkp->drive = drive;
 	idkp->driver = &ide_gd_driver;
@@ -373,6 +379,8 @@ static int ide_gd_probe(ide_drive_t *drive)
 	add_disk(g);
 	return 0;
 
+out_free_disk:
+	put_disk(g);
 out_free_idkp:
 	kfree(idkp);
 failed:
diff --git a/drivers/ide/ide-gd.h b/drivers/ide/ide-gd.h
index a86779f..b604bdd 100644
--- a/drivers/ide/ide-gd.h
+++ b/drivers/ide/ide-gd.h
@@ -17,7 +17,7 @@ struct ide_disk_obj {
 	ide_drive_t		*drive;
 	struct ide_driver	*driver;
 	struct gendisk		*disk;
-	struct kref		kref;
+	struct device		dev;
 	unsigned int		openers;	/* protected by BKL for now */
 
 	/* Last failed packet command */
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index d7ecd3c..bb450a7 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -169,7 +169,7 @@ typedef struct ide_tape_obj {
 	ide_drive_t		*drive;
 	struct ide_driver	*driver;
 	struct gendisk		*disk;
-	struct kref		kref;
+	struct device		dev;
 
 	/*
 	 *	failed_pc points to the last failed packet command, or contains
@@ -267,7 +267,7 @@ static DEFINE_MUTEX(idetape_ref_mutex);
 
 static struct class *idetape_sysfs_class;
 
-static void ide_tape_release(struct kref *);
+static void ide_tape_release(struct device *);
 
 static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
 {
@@ -279,7 +279,7 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
 		if (ide_device_get(tape->drive))
 			tape = NULL;
 		else
-			kref_get(&tape->kref);
+			get_device(&tape->dev);
 	}
 	mutex_unlock(&idetape_ref_mutex);
 	return tape;
@@ -290,7 +290,7 @@ static void ide_tape_put(struct ide_tape_obj *tape)
 	ide_drive_t *drive = tape->drive;
 
 	mutex_lock(&idetape_ref_mutex);
-	kref_put(&tape->kref, ide_tape_release);
+	put_device(&tape->dev);
 	ide_device_put(drive);
 	mutex_unlock(&idetape_ref_mutex);
 }
@@ -308,7 +308,7 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
 	mutex_lock(&idetape_ref_mutex);
 	tape = idetape_devs[i];
 	if (tape)
-		kref_get(&tape->kref);
+		get_device(&tape->dev);
 	mutex_unlock(&idetape_ref_mutex);
 	return tape;
 }
@@ -2256,15 +2256,17 @@ static void ide_tape_remove(ide_drive_t *drive)
 	idetape_tape_t *tape = drive->driver_data;
 
 	ide_proc_unregister_driver(drive, tape->driver);
-
+	device_del(&tape->dev);
 	ide_unregister_region(tape->disk);
 
-	ide_tape_put(tape);
+	mutex_lock(&idetape_ref_mutex);
+	put_device(&tape->dev);
+	mutex_unlock(&idetape_ref_mutex);
 }
 
-static void ide_tape_release(struct kref *kref)
+static void ide_tape_release(struct device *dev)
 {
-	struct ide_tape_obj *tape = to_ide_drv(kref, ide_tape_obj);
+	struct ide_tape_obj *tape = to_ide_drv(dev, ide_tape_obj);
 	ide_drive_t *drive = tape->drive;
 	struct gendisk *g = tape->disk;
 
@@ -2407,7 +2409,12 @@ static int ide_tape_probe(ide_drive_t *drive)
 
 	ide_init_disk(g, drive);
 
-	kref_init(&tape->kref);
+	tape->dev.parent = &drive->gendev;
+	tape->dev.release = ide_tape_release;
+	dev_set_name(&tape->dev, dev_name(&drive->gendev));
+
+	if (device_register(&tape->dev))
+		goto out_free_disk;
 
 	tape->drive = drive;
 	tape->driver = &idetape_driver;
@@ -2436,6 +2443,8 @@ static int ide_tape_probe(ide_drive_t *drive)
 
 	return 0;
 
+out_free_disk:
+	put_disk(g);
 out_free_tape:
 	kfree(tape);
 failed:
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 258805d..0920e3b 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -337,6 +337,7 @@ static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp)
 	int a, b, i, j = 1;
 	unsigned int *dev_param_mask = (unsigned int *)kp->arg;
 
+	/* controller . device (0 or 1) [ : 1 (set) | 0 (clear) ] */
 	if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 &&
 	    sscanf(s, "%d.%d", &a, &b) != 2)
 		return -EINVAL;
@@ -349,7 +350,7 @@ static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp)
 	if (j)
 		*dev_param_mask |= (1 << i);
 	else
-		*dev_param_mask &= (1 << i);
+		*dev_param_mask &= ~(1 << i);
 
 	return 0;
 }
@@ -392,6 +393,8 @@ static int ide_set_disk_chs(const char *str, struct kernel_param *kp)
 {
 	int a, b, c = 0, h = 0, s = 0, i, j = 1;
 
+	/* controller . device (0 or 1) : Cylinders , Heads , Sectors */
+	/* controller . device (0 or 1) : 1 (use CHS) | 0 (ignore CHS) */
 	if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 &&
 	    sscanf(str, "%d.%d:%d", &a, &b, &j) != 3)
 		return -EINVAL;
@@ -407,7 +410,7 @@ static int ide_set_disk_chs(const char *str, struct kernel_param *kp)
 	if (j)
 		ide_disks |= (1 << i);
 	else
-		ide_disks &= (1 << i);
+		ide_disks &= ~(1 << i);
 
 	ide_disks_chs[i].cyl  = c;
 	ide_disks_chs[i].head = h;
@@ -469,6 +472,8 @@ static int ide_set_ignore_cable(const char *s, struct kernel_param *kp)
 {
 	int i, j = 1;
 
+	/* controller (ignore) */
+	/* controller : 1 (ignore) | 0 (use) */
 	if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1)
 		return -EINVAL;
 
@@ -478,7 +483,7 @@ static int ide_set_ignore_cable(const char *s, struct kernel_param *kp)
 	if (j)
 		ide_ignore_cable |= (1 << i);
 	else
-		ide_ignore_cable &= (1 << i);
+		ide_ignore_cable &= ~(1 << i);
 
 	return 0;
 }
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
index e1c4f54..13b8153 100644
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -5,9 +5,8 @@
  *  May be copied or modified under the terms of the GNU General Public License
  *  Based in part on the ITE vendor provided SCSI driver.
  *
- *  Documentation available from
- * 	http://www.ite.com.tw/pc/IT8212F_V04.pdf
- *  Some other documents are NDA.
+ *  Documentation:
+ *	Datasheet is freely available, some other documents under NDA.
  *
  *  The ITE8212 isn't exactly a standard IDE controller. It has two
  *  modes. In pass through mode then it is an IDE controller. In its smart
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 194da5a..fe235b6 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -663,7 +663,7 @@ typedef struct ide_drive_s ide_drive_t;
 #define to_ide_device(dev)		container_of(dev, ide_drive_t, gendev)
 
 #define to_ide_drv(obj, cont_type)	\
-	container_of(obj, struct cont_type, kref)
+	container_of(obj, struct cont_type, dev)
 
 #define ide_drv_g(disk, cont_type)	\
 	container_of((disk)->private_data, struct cont_type, driver)

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 23:57                           ` Linus Torvalds
@ 2009-06-08  0:54                             ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-08  0:54 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Pekka Enberg, James Bottomley, Alan Cox, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Monday 08 June 2009 01:57:19 Linus Torvalds wrote:
> 
> On Mon, 8 Jun 2009, Bartlomiej Zolnierkiewicz wrote:
> > 
> > This is not a new feature and basing your opinions on opinions of people
> > who don't read the code before commenting is bad, really bad, m'kay?
> 
> The thing is, I had planned on doing a final release yesterday, even 

I don't want IDE to possibly hold off the final release so...


Linus, please pull from 'for-linus' branch of:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus

to receive the following updates:

 drivers/ide/pdc202xx_old.c |   22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)


Sergei Shtylyov (2):
      pdc202xx_old: fix 'pdc20246_dma_ops'
      pdc202xx_old: fix resetproc() method


diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 248a54b..b3bc96f 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1998-2002		Andre Hedrick <andre@linux-ide.org>
- *  Copyright (C) 2006-2007		MontaVista Software, Inc.
+ *  Copyright (C) 2006-2007, 2009	MontaVista Software, Inc.
  *  Copyright (C) 2007			Bartlomiej Zolnierkiewicz
  *
  *  Portions Copyright (C) 1999 Promise Technology, Inc.
@@ -227,28 +227,19 @@ somebody_else:
 	return (dma_stat & 4) == 4;	/* return 1 if INTR asserted */
 }
 
-static void pdc202xx_reset_host (ide_hwif_t *hwif)
+static void pdc202xx_reset(ide_drive_t *drive)
 {
+	ide_hwif_t *hwif	= drive->hwif;
 	unsigned long high_16	= hwif->extra_base - 16;
 	u8 udma_speed_flag	= inb(high_16 | 0x001f);
 
+	printk(KERN_WARNING "PDC202xx: software reset...\n");
+
 	outb(udma_speed_flag | 0x10, high_16 | 0x001f);
 	mdelay(100);
 	outb(udma_speed_flag & ~0x10, high_16 | 0x001f);
 	mdelay(2000);	/* 2 seconds ?! */
 
-	printk(KERN_WARNING "PDC202XX: %s channel reset.\n",
-		hwif->channel ? "Secondary" : "Primary");
-}
-
-static void pdc202xx_reset (ide_drive_t *drive)
-{
-	ide_hwif_t *hwif	= drive->hwif;
-	ide_hwif_t *mate	= hwif->mate;
-
-	pdc202xx_reset_host(hwif);
-	pdc202xx_reset_host(mate);
-
 	ide_set_max_pio(drive);
 }
 
@@ -328,9 +319,8 @@ static const struct ide_dma_ops pdc20246_dma_ops = {
 	.dma_start		= ide_dma_start,
 	.dma_end		= ide_dma_end,
 	.dma_test_irq		= pdc202xx_dma_test_irq,
-	.dma_lost_irq		= pdc202xx_dma_lost_irq,
+	.dma_lost_irq		= ide_dma_lost_irq,
 	.dma_timer_expiry	= ide_dma_sff_timer_expiry,
-	.dma_clear		= pdc202xx_reset,
 	.dma_sff_read_status	= ide_dma_sff_read_status,
 };
 

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 23:47                         ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 23:57                           ` Linus Torvalds
  2009-06-08  0:54                             ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Linus Torvalds @ 2009-06-07 23:57 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Pekka Enberg, James Bottomley, Alan Cox, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel



On Mon, 8 Jun 2009, Bartlomiej Zolnierkiewicz wrote:
> 
> This is not a new feature and basing your opinions on opinions of people
> who don't read the code before commenting is bad, really bad, m'kay?

The thing is, I had planned on doing a final release yesterday, even 
before your pull came in. I decided to hold off, let it be, just to test 
the _current_ state a bit more. No way am I then adding some effectively 
totally untested new code-path.

And if you start messing in partitions.c and adding whole new callback 
functions to generic block_device_operations, then that's a new code-path. 
The IDE subsystem has _no_ business adding random new callbacks in 
the very last days of a release.

It sure as hell is not just a bugfix, it's a new feature. The feature may 
be _needed_ for some specific bug report, but that is totally irrelevant. 
We don't do things like that.

It's also almost certainly not a regression, is it? So by no measure does 
it work as a "late in the -rc sequence" patch.

		Linus

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 23:15                       ` Linus Torvalds
@ 2009-06-07 23:47                         ` Bartlomiej Zolnierkiewicz
  2009-06-07 23:57                           ` Linus Torvalds
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 23:47 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Pekka Enberg, James Bottomley, Alan Cox, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Monday 08 June 2009 01:15:42 Linus Torvalds wrote:
> 
> On Sun, 7 Jun 2009, Bartlomiej Zolnierkiewicz wrote:
> > 
> > To be perfectly clear on this:
> > 
> > * all patches were posted a week ago to the list (they replaced patches
> >   from two weeks ago -- which were intended for -rc8 but thanks to feedback
> >   I found a better way to do it).
> 
> Bartlomiej - if you want to add new features, they should have been posted 
> on the list BEFORE THE MERGE WINDOW EVEN OPENED.

This is not a new feature and basing your opinions on opinions of people
who don't read the code before commenting is bad, really bad, m'kay?

Anyway I'll revisit the pull request tomorrow.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 19:25                     ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 23:15                       ` Linus Torvalds
  2009-06-07 23:47                         ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Linus Torvalds @ 2009-06-07 23:15 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Pekka Enberg, James Bottomley, Alan Cox, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel



On Sun, 7 Jun 2009, Bartlomiej Zolnierkiewicz wrote:
> 
> To be perfectly clear on this:
> 
> * all patches were posted a week ago to the list (they replaced patches
>   from two weeks ago -- which were intended for -rc8 but thanks to feedback
>   I found a better way to do it).

Bartlomiej - if you want to add new features, they should have been posted 
on the list BEFORE THE MERGE WINDOW EVEN OPENED.

Not just after -rc7 or something like that.

			Linus

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 17:55             ` Bartlomiej Zolnierkiewicz
  2009-06-07 18:21               ` Pekka Enberg
@ 2009-06-07 23:14               ` Linus Torvalds
  1 sibling, 0 replies; 58+ messages in thread
From: Linus Torvalds @ 2009-06-07 23:14 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Pekka Enberg, James Bottomley, Alan Cox, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel



On Sun, 7 Jun 2009, Bartlomiej Zolnierkiewicz wrote:
> 
> My honest opinion is that it is as appropriate now as it will be 2.6.31.

No.

I['m not pulling new features after -rc8. It had better be a major bugfix 
to a major oops or security issue.

This is not a "2.6.30" vs "2.6.31" issue. It's a "before -rc1" vs "after 
-rc8" issue.

			Linus

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:57     ` Bartlomiej Zolnierkiewicz
  2009-06-07 15:18       ` James Bottomley
@ 2009-06-07 23:12       ` Linus Torvalds
  1 sibling, 0 replies; 58+ messages in thread
From: Linus Torvalds @ 2009-06-07 23:12 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: James Bottomley, Alan Cox, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel



On Sun, 7 Jun 2009, Bartlomiej Zolnierkiewicz wrote:

> They don't export anything to user-space.

Bartlomiej, that's irrelevant. I want to release 2.6.30. We're not adding 
some totally new interfaces after -rc8.

This has nothing to do with user space or anything else. It's a new 
feature.

		Linus

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 20:39                   ` James Bottomley
@ 2009-06-07 21:08                     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 21:08 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sunday 07 June 2009 22:39:45 James Bottomley wrote:
> On Sun, 2009-06-07 at 21:07 +0100, Alan Cox wrote:
> > > > [ I also tried to encourage libata developers to look into making the needed
> > > >   libata changes (see my initial posting of HPA patches) and I will still be
> > > >   glad to help with libata patches if somebody would like to work on them
> > > >   (Robert? Tejun?). ]
> > > 
> > > OK, so back off on the 2.6.30-rc7 release of this and I'll undertake to
> > > get libata engaged for integrating this into both subsystems for
> > > 2.6.31 ... does that sound fair?
> > 
> > libata already is, and I've been following and reviewing the patches. The
> > problem remaining is basically that this is not the time to merge
> > it.
> 
> Actually, I was talking about the fallback to disabling heuristic which
> this patch set introduces, and which would fix bug 13365 if it were
> applied to libata, but which is the bit I think needs some testing.

My patches fix the root cause of the problem and alleviate the issue for
all new installations.  In libata's case more testing is needed because
the libata's default is to keep HPA enabled (which is proper for modern
systems).

Once you get all HPA details (it is a complicated mess -- that is why
kernel/distributions couldn't get it right for years) you will see the
overall picture of the problem -- the work on multiple fronts at once
(including user-space) is needed to fix it properly.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 20:07                 ` Alan Cox
  2009-06-07 20:39                   ` James Bottomley
@ 2009-06-07 20:42                   ` Bartlomiej Zolnierkiewicz
  1 sibling, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 20:42 UTC (permalink / raw)
  To: Alan Cox
  Cc: James Bottomley, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sunday 07 June 2009 22:07:01 Alan Cox wrote:
> > > [ I also tried to encourage libata developers to look into making the needed
> > >   libata changes (see my initial posting of HPA patches) and I will still be
> > >   glad to help with libata patches if somebody would like to work on them
> > >   (Robert? Tejun?). ]
> > 
> > OK, so back off on the 2.6.30-rc7 release of this and I'll undertake to
> > get libata engaged for integrating this into both subsystems for
> > 2.6.31 ... does that sound fair?
> 
> libata already is, and I've been following and reviewing the patches. The
> problem remaining is basically that this is not the time to merge
> it.

In ide's case the situation is a bit different:

This is a bug fix.  Not an obvious one but it will help anyone installing
a new distribution/kernel using ide on machine with HPA, as it will allow
this user for streamline transition to a distribution/kernel using libata
later if needed (even though I don't recommend it :).

I just want a fair treatment.  I'm not posting crap -rc pull request so
I see no reason why I have to pay for other maintainers mistakes.

This was better tested and reviewed that some other changes that got in
after 2.6.30-rc8 (and is smaller than at least one other pull request
that got in).

I even admitted in the pull request that this may be too late but based on
my technical judgment (strongly backed by on reviews from you and Sergei)
I considered those changes to be on the edge...

It is not a *must*have* for 2.6.30 but still 2.6.30 *shall*have* it.

> It will probably also be worth looking at the way the CD driver plays
> fast and loose with capacity when handling CD-R devices as a follow on
> from this stuff.

Sure and it would be easier to look into this (and libata changes) with
partitions/ide changes in.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 20:07                 ` Alan Cox
@ 2009-06-07 20:39                   ` James Bottomley
  2009-06-07 21:08                     ` Bartlomiej Zolnierkiewicz
  2009-06-07 20:42                   ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 58+ messages in thread
From: James Bottomley @ 2009-06-07 20:39 UTC (permalink / raw)
  To: Alan Cox
  Cc: Bartlomiej Zolnierkiewicz, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Sun, 2009-06-07 at 21:07 +0100, Alan Cox wrote:
> > > [ I also tried to encourage libata developers to look into making the needed
> > >   libata changes (see my initial posting of HPA patches) and I will still be
> > >   glad to help with libata patches if somebody would like to work on them
> > >   (Robert? Tejun?). ]
> > 
> > OK, so back off on the 2.6.30-rc7 release of this and I'll undertake to
> > get libata engaged for integrating this into both subsystems for
> > 2.6.31 ... does that sound fair?
> 
> libata already is, and I've been following and reviewing the patches. The
> problem remaining is basically that this is not the time to merge
> it.

Actually, I was talking about the fallback to disabling heuristic which
this patch set introduces, and which would fix bug 13365 if it were
applied to libata, but which is the bit I think needs some testing.

> It will probably also be worth looking at the way the CD driver plays
> fast and loose with capacity when handling CD-R devices as a follow on
> from this stuff.

James



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 19:08               ` James Bottomley
  2009-06-07 19:23                 ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 20:07                 ` Alan Cox
  2009-06-07 20:39                   ` James Bottomley
  2009-06-07 20:42                   ` Bartlomiej Zolnierkiewicz
  1 sibling, 2 replies; 58+ messages in thread
From: Alan Cox @ 2009-06-07 20:07 UTC (permalink / raw)
  To: James Bottomley
  Cc: Bartlomiej Zolnierkiewicz, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

> > [ I also tried to encourage libata developers to look into making the needed
> >   libata changes (see my initial posting of HPA patches) and I will still be
> >   glad to help with libata patches if somebody would like to work on them
> >   (Robert? Tejun?). ]
> 
> OK, so back off on the 2.6.30-rc7 release of this and I'll undertake to
> get libata engaged for integrating this into both subsystems for
> 2.6.31 ... does that sound fair?

libata already is, and I've been following and reviewing the patches. The
problem remaining is basically that this is not the time to merge
it.

It will probably also be worth looking at the way the CD driver plays
fast and loose with capacity when handling CD-R devices as a follow on
from this stuff.


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 19:09                   ` Pekka Enberg
@ 2009-06-07 19:25                     ` Bartlomiej Zolnierkiewicz
  2009-06-07 23:15                       ` Linus Torvalds
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 19:25 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: James Bottomley, Alan Cox, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Sunday 07 June 2009 21:09:47 Pekka Enberg wrote:
> Hi Bartlomiej,
> 
> On Sun, Jun 7, 2009 at 10:00 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
> >> > My honest opinion is that it is as appropriate now as it will be 2.6.31.
> >> >
> >> > [ I'm still amazed by the amount of *completely* bogus reasons given for
> >> >  not merging it. ]
> >>
> >> I don't consider this a bogus reason at all:
> >>
> >>  10 files changed, 134 insertions(+), 43 deletions(-)
> >
> > Since when do we validate code quality based solely on LOC changed? :)
> 
> Since when we entered -rc8 (or even earlier).

To be perfectly clear on this:

* all patches were posted a week ago to the list (they replaced patches
  from two weeks ago -- which were intended for -rc8 but thanks to feedback
  I found a better way to do it).

> On Sun, Jun 7, 2009 at 10:00 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
> > I'm yet to see anybody posting a single code chunk in this whole discussion.
> 
> That's because I am not objecting to the code. I am objecting to the
> fact that you're submitting something as big as this so late in the
> release cycle and the fact that it's not a clear-cut bug fix.

That is a valid objection in contrast to some other ones.

Still, changes are really *safe*:

* fs/partitions/check.c change is straight-forward
  (doesn't affect anything besides ide-gd)

* ide-gd changes are making it similar in HPA behavior to libata
  (which is what most distributions are shipping)

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 19:08               ` James Bottomley
@ 2009-06-07 19:23                 ` Bartlomiej Zolnierkiewicz
  2009-06-07 20:07                 ` Alan Cox
  1 sibling, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 19:23 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sunday 07 June 2009 21:08:49 James Bottomley wrote:
> On Sun, 2009-06-07 at 19:47 +0200, Bartlomiej Zolnierkiewicz wrote:
> > On Sunday 07 June 2009 18:08:09 James Bottomley wrote:
> > > So I have two specific problems with the way you're trying to one up
> > > libata:
> > > 
> > >      1. You're trying to get a jump on them by adding features as bug
> > >         fixes ... this is incredibly bad release practice.
> > 
> > It is a bugfix.  Long overdue one.
> 
> > However you have to look beyond kernel to see it.  From the commit log:
> > 
> > "
> > From the perspective of most users of recent systems, disabling Host
> > Protected Area (HPA) can break vendor RAID formats, GPT partitions and
> > risks corrupting firmware or overwriting vendor system recovery tools.
> > 
> > Unfortunately the original (kernels < 2.6.30) behavior (unconditionally
> > disabling HPA and using full disk capacity) was introduced at the time
> > when the main use of HPA was to make the drive look small enough for the
> > BIOS to allow the system to boot with large capacity drives.
> > 
> > Thus to allow the maximum compatibility with the existing setups (using
> > HPA and partitioned with HPA disabled) we automically disable HPA if
> > any partitions overlapping HPA are detected.  Additionally HPA can also
> > be disabled using the "nohpa" module parameter (i.e. "ide_core.nohpa=0.0"
> > to disable HPA on /dev/hda).
> > "
> > 
> > Yes, it is true that there is no rush.
> 
> So why 2.6.30-rc7 then?
> 
> > OTOH there are absolutely no valid technical reasons to slow it down!
> 
> There is incredibly valid reason not to put this in 2.6.30-rc7: You've
> added a feature (HPA) which ide previously ignored, so now you need to

No.  HPA as feature was always supported back to 2.4.x days.

End of discussion.  I'm not even reading the rest of your mail.

Please go read the code and don't come back till you do.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 19:00                 ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 19:09                   ` Pekka Enberg
  2009-06-07 19:25                     ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Pekka Enberg @ 2009-06-07 19:09 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: James Bottomley, Alan Cox, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

Hi Bartlomiej,

On Sun, Jun 7, 2009 at 10:00 PM, Bartlomiej Zolnierkiewicz
<bzolnier@gmail.com> wrote:
>> > My honest opinion is that it is as appropriate now as it will be 2.6.31.
>> >
>> > [ I'm still amazed by the amount of *completely* bogus reasons given for
>> >  not merging it. ]
>>
>> I don't consider this a bogus reason at all:
>>
>>  10 files changed, 134 insertions(+), 43 deletions(-)
>
> Since when do we validate code quality based solely on LOC changed? :)

Since when we entered -rc8 (or even earlier).

On Sun, Jun 7, 2009 at 10:00 PM, Bartlomiej Zolnierkiewicz
<bzolnier@gmail.com> wrote:
> I'm yet to see anybody posting a single code chunk in this whole discussion.

That's because I am not objecting to the code. I am objecting to the
fact that you're submitting something as big as this so late in the
release cycle and the fact that it's not a clear-cut bug fix.

But anyway, I don't really want to argue about this. I simply wanted
to point out that I agree with Alan's and James' comments and that I
don't think they have anything to do with "slowing down IDE fixes" but
rather with how the whole release cycle with fixed merge window works.

                        Pekka

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 17:47             ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 19:08               ` James Bottomley
  2009-06-07 19:23                 ` Bartlomiej Zolnierkiewicz
  2009-06-07 20:07                 ` Alan Cox
  0 siblings, 2 replies; 58+ messages in thread
From: James Bottomley @ 2009-06-07 19:08 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sun, 2009-06-07 at 19:47 +0200, Bartlomiej Zolnierkiewicz wrote:
> On Sunday 07 June 2009 18:08:09 James Bottomley wrote:
> > So I have two specific problems with the way you're trying to one up
> > libata:
> > 
> >      1. You're trying to get a jump on them by adding features as bug
> >         fixes ... this is incredibly bad release practice.
> 
> It is a bugfix.  Long overdue one.

> However you have to look beyond kernel to see it.  From the commit log:
> 
> "
> From the perspective of most users of recent systems, disabling Host
> Protected Area (HPA) can break vendor RAID formats, GPT partitions and
> risks corrupting firmware or overwriting vendor system recovery tools.
> 
> Unfortunately the original (kernels < 2.6.30) behavior (unconditionally
> disabling HPA and using full disk capacity) was introduced at the time
> when the main use of HPA was to make the drive look small enough for the
> BIOS to allow the system to boot with large capacity drives.
> 
> Thus to allow the maximum compatibility with the existing setups (using
> HPA and partitioned with HPA disabled) we automically disable HPA if
> any partitions overlapping HPA are detected.  Additionally HPA can also
> be disabled using the "nohpa" module parameter (i.e. "ide_core.nohpa=0.0"
> to disable HPA on /dev/hda).
> "
> 
> Yes, it is true that there is no rush.

So why 2.6.30-rc7 then?

> OTOH there are absolutely no valid technical reasons to slow it down!

There is incredibly valid reason not to put this in 2.6.30-rc7: You've
added a feature (HPA) which ide previously ignored, so now you need to
identify all those cases and turn it off.  The way you've done this is a
fallback heuristic in the partitions code which recognises that the
device has a partition into the host protected area and turns off the
HPA feature.  There are three areas of risk here

     1. Adding HPA at all.  We have zero outstanding bugs saying that
        ignoring HPA broke anyone's system.  Alan's concern you quote
        above is valid, but unproven at this point.  Conversely, by
        turning on HPA in IDE we may discover some legacy devices that
        don't behave well with it that haven't been picked up by libata.
        This is almost unquantifiable, but I'd guess high based on
        previous run ins with new IDE features and standards
        conformance.
     2. The modification of generic partition code for the fallback
        heuristic ... get something wrong in here and all of storage
        will suffer.  This is a medium risk which could be mitigated by
        a longer test cycle.
     3. Your actual heuristic: it sounds fine in principle, but what
        about people who use the kpartx method of partitioning or even
        just used native dm ... their disks suddenly and unexpectedly
        get shorter.  This heuristic has had insufficient testing to
        turn up any of these possible failure cases (or any others I
        haven't through of).  Again, this is high risk for an immediate
        release which could be mitigated by a longer test cycle.

All of this adds up to unacceptable risk in the last week of a release.

In the real world people get fired for this sort of thing (admittedly
only usually if the risk factor militates against them).

> >      2. this antagonism in feature evolution is likely to lead to
> >         interface incompatibility between libata and IDE ... and users
> >         will be the ultimate losers because of this.
> 
> Hmmm, did you *really* read the patches?

yes, so perhaps you'd have the courtesy to avoid newbie intimidation
tactics.

> They make libata and IDE more similar by making IDE also default to
> preserving HPA (which is what libata does).  So users get more coherent
> overall kernel behavior.
> 
> The only difference is that IDE for compatibility reasons must handle old
> installs (with HPA wrongly disabled and protected area used for filesystem
> data).

I know this, but as I said, the risk of IDE damaging a system by
ignoring HPA is theoretical at the moment ... you have to set that
against the introduced risks listed above.

> However it does it in a clean way (not a subsystem specific hack) which
> can be later used for implementing the same functionality in libata!

I agree with this too ... the problem is that doing things the right
way(tm) does increase the footprint of the changes and with it the
release risk.

> [ I also tried to encourage libata developers to look into making the needed
>   libata changes (see my initial posting of HPA patches) and I will still be
>   glad to help with libata patches if somebody would like to work on them
>   (Robert? Tejun?). ]

OK, so back off on the 2.6.30-rc7 release of this and I'll undertake to
get libata engaged for integrating this into both subsystems for
2.6.31 ... does that sound fair?

James



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 18:21               ` Pekka Enberg
@ 2009-06-07 19:00                 ` Bartlomiej Zolnierkiewicz
  2009-06-07 19:09                   ` Pekka Enberg
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 19:00 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: James Bottomley, Alan Cox, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Sunday 07 June 2009 20:21:11 Pekka Enberg wrote:
> Hi Bartlomiej,
> 
> On Sun, Jun 7, 2009 at 8:55 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
> > On Sunday 07 June 2009 18:54:08 Pekka Enberg wrote:
> >> Hi Bartlomiej,
> >>
> >> On Sun, Jun 7, 2009 at 6:44 PM, Bartlomiej Zolnierkiewicz
> >> <bzolnier@gmail.com> wrote:
> >> > Honestly, this should be solved on technical basis by somebody posting
> >> > needed libata patches instead of attempts to slow down IDE fixes.
> >>
> >> Nobody is "slowing down" IDE fixes here. Linus explicitly said that
> >> -rc8 is the last release candidate and the next one is going to be
> >> -final. There's absolutely _no way_ this series is appropriate at the
> >> very end of a release cycle.
> >
> > My honest opinion is that it is as appropriate now as it will be 2.6.31.
> >
> > [ I'm still amazed by the amount of *completely* bogus reasons given for
> >  not merging it. ]
> 
> I don't consider this a bogus reason at all:
> 
>  10 files changed, 134 insertions(+), 43 deletions(-)

Since when do we validate code quality based solely on LOC changed? :)

I'm yet to see anybody posting a single code chunk in this whole discussion.

> Just search the LKML archives for the amount of crap other subsystem
> maintainers have gotten from Linus when they've tried to sneak
> something like that after -rc4 or so.

How many of those other patches:

* got tested by the maintainer
* re-audited twice by the maintainer
* reviewed by two other subsystem gurus

Moreover there was no sneaking here at all:

I admitted in the pull request that I'm unsure if this is appropriate
that late in the cycle.

I'm fine with delaying those changes but I'm not fine with attempts to do
it using completely "made up" technical arguments (no risky core changes,
no 2K sector devices affected, no relation to alt_size sysfs interface, no
misrepresenting of feature as a bug fix -- to mention just a few).

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 17:55             ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 18:21               ` Pekka Enberg
  2009-06-07 19:00                 ` Bartlomiej Zolnierkiewicz
  2009-06-07 23:14               ` Linus Torvalds
  1 sibling, 1 reply; 58+ messages in thread
From: Pekka Enberg @ 2009-06-07 18:21 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: James Bottomley, Alan Cox, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

Hi Bartlomiej,

On Sun, Jun 7, 2009 at 8:55 PM, Bartlomiej Zolnierkiewicz
<bzolnier@gmail.com> wrote:
> On Sunday 07 June 2009 18:54:08 Pekka Enberg wrote:
>> Hi Bartlomiej,
>>
>> On Sun, Jun 7, 2009 at 6:44 PM, Bartlomiej Zolnierkiewicz
>> <bzolnier@gmail.com> wrote:
>> > Honestly, this should be solved on technical basis by somebody posting
>> > needed libata patches instead of attempts to slow down IDE fixes.
>>
>> Nobody is "slowing down" IDE fixes here. Linus explicitly said that
>> -rc8 is the last release candidate and the next one is going to be
>> -final. There's absolutely _no way_ this series is appropriate at the
>> very end of a release cycle.
>
> My honest opinion is that it is as appropriate now as it will be 2.6.31.
>
> [ I'm still amazed by the amount of *completely* bogus reasons given for
>  not merging it. ]

I don't consider this a bogus reason at all:

 10 files changed, 134 insertions(+), 43 deletions(-)

Just search the LKML archives for the amount of crap other subsystem
maintainers have gotten from Linus when they've tried to sneak
something like that after -rc4 or so.

                        Pekka

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 16:54           ` Pekka Enberg
@ 2009-06-07 17:55             ` Bartlomiej Zolnierkiewicz
  2009-06-07 18:21               ` Pekka Enberg
  2009-06-07 23:14               ` Linus Torvalds
  0 siblings, 2 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 17:55 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: James Bottomley, Alan Cox, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Sunday 07 June 2009 18:54:08 Pekka Enberg wrote:
> Hi Bartlomiej,
> 
> On Sun, Jun 7, 2009 at 6:44 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
> > Honestly, this should be solved on technical basis by somebody posting
> > needed libata patches instead of attempts to slow down IDE fixes.
> 
> Nobody is "slowing down" IDE fixes here. Linus explicitly said that
> -rc8 is the last release candidate and the next one is going to be
> -final. There's absolutely _no way_ this series is appropriate at the
> very end of a release cycle.

My honest opinion is that it is as appropriate now as it will be 2.6.31.

[ I'm still amazed by the amount of *completely* bogus reasons given for
  not merging it. ]

However it sure can wait, no big deal (though I still think that it was
worth to try to get it in and not make users wait another few months).

I'll let Linus decide and revise pull request if necessary.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 16:08           ` James Bottomley
@ 2009-06-07 17:47             ` Bartlomiej Zolnierkiewicz
  2009-06-07 19:08               ` James Bottomley
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 17:47 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sunday 07 June 2009 18:08:09 James Bottomley wrote:
> On Sun, 2009-06-07 at 17:44 +0200, Bartlomiej Zolnierkiewicz wrote:
> > On Sunday 07 June 2009 17:18:51 you wrote:
> > > On Sun, 2009-06-07 at 16:57 +0200, Bartlomiej Zolnierkiewicz wrote:
> > > > On Sunday 07 June 2009 16:38:56 James Bottomley wrote:
> > > > > On Sun, 2009-06-07 at 15:21 +0100, Alan Cox wrote:
> > > > > > > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > > > > > > index 99e33ef..4bc2c43 100644
> > > > > > > --- a/fs/partitions/check.c
> > > > > > > +++ b/fs/partitions/check.c
> > > > > > 
> > > > > > 
> > > > > > You seriously want to add code to the core partition handling logic
> > > > > > moments before release when we know we have all sorts of devices with
> > > > > > weird behaviours ?
> > > > > > 
> > > > > > This should be .31 stuff where we can take the time to see how it works
> > > > > > on all sorts of weird real world devices (eg those with 2K sector size)
> > > > > > and the like.
> > > > > 
> > > > > Absolutely seconded.
> > > > > 
> > > > > Plus this is only one of the proposals for dealing with IDE native sizes
> > > > > moving through the process.  The other one is in libata with the gendisk
> > > > > proposal for alt size instead of your set_capacity callback.   The last
> > > > 
> > > > ->set_capacity callback is needed for drivers/ide regardless of alt_size
> > > > sysfs interface and it don't conflict with it in any way.
> > > 
> > > It's used as a heuristic for selecting native vs protected disk size
> > > depending on what the partition table says ... I grant that's one way to
> > > handle the problem.
> > > 
> > > > Those patches are a complimentary work to Tejun's alt_size patches. 
> > > > 
> > > > They don't export anything to user-space.
> > > 
> > > So you're trying to solve the problem heuristically, and Tejun is trying
> > > to provide the user with full information.   At the end of the day it
> > > would be nice to get agreement on how we do this *before* exposing it to
> > > users.  It's certainly possible we could do both, but for that to happen
> > 
> > Sure.  My patches don't export anything to user-space.
> > 
> > If you find any code parts controversial please post them and I'll be
> > more than happy to discuss them in details.
> > 
> > > libata would have to implement .get_capacity() is that going to be the
> > > case?
> > 
> > Now we get the real source of Alan's and your complains...
> > 
> > Those patches (among other things) make IDE superior overt libata w.r.t.
> > HPA handling so libata now has to catch up.
> > 
> > Honestly, this should be solved on technical basis by somebody posting
> > needed libata patches instead of attempts to slow down IDE fixes.
> 
> You've got the wrong motive.  I have notice that you and Alan seem to
> have a somewhat antagonistic relationship resulting in a proxy battle
> over IDE/libata, so you would necessarily see this as at play in his
> first post.  I hoped, by emphasizing the point, that you'd see this

Please don't project your own way of thinking on me or (maybe?) try to
play on imaginary conflict between me and Alan for your own gains.

By emphasizing untrue point -- I have a much respect for Alan for all
his kernel work and also for being a long-term promoter of Linux -- you
are trying to move the discussion from technical means to political ones.

It is true that we get into heated arguments with Alan from time to time
but this is unavoidable given large differences in our views on kernel
development process (I was late to the game so I have very different
experiences that people who were doing it since the beginning) and also
on future directions of progress (i.e. I don't support segregation of
hardware support on "relevant" and "irrelevant" or dropping ISA support).

However as long as we stick to the *code* and discuss things based on the
*code* we have no problems with working together (which happens more often
then not).

[ Who I really have antagonistic relationship with are some smart-asses
  trying to play politics by using other people to do your dirty work
  (and no, I didn't went on hiatus in 2005 because of Alan if some people
  still wonder). ]

When it comes to libata: are you serious?

I gave libata a full green light back when it was introduced in 2003.

What I have been always complaining about w.r.t. libata is too slow
progress and a bit too little long-term planning.

[ Cause I know that we can do better! ]

When it comes libata PATA: "the battle" has been lost back in 2005
(nobody with semi-sane thinking would believe that it could be won),
or more like that there was never any battle since I was always fine
with PATA support in libata (though I was *extremely* unhappy with
the way it was introduced and resulting long-term consequences).

> adding features as bug fixes is a problem even from a more neutral
> perspective.
> 
> So I have two specific problems with the way you're trying to one up
> libata:
> 
>      1. You're trying to get a jump on them by adding features as bug
>         fixes ... this is incredibly bad release practice.

It is a bugfix.  Long overdue one.

However you have to look beyond kernel to see it.  From the commit log:

"
>From the perspective of most users of recent systems, disabling Host
Protected Area (HPA) can break vendor RAID formats, GPT partitions and
risks corrupting firmware or overwriting vendor system recovery tools.

Unfortunately the original (kernels < 2.6.30) behavior (unconditionally
disabling HPA and using full disk capacity) was introduced at the time
when the main use of HPA was to make the drive look small enough for the
BIOS to allow the system to boot with large capacity drives.

Thus to allow the maximum compatibility with the existing setups (using
HPA and partitioned with HPA disabled) we automically disable HPA if
any partitions overlapping HPA are detected.  Additionally HPA can also
be disabled using the "nohpa" module parameter (i.e. "ide_core.nohpa=0.0"
to disable HPA on /dev/hda).
"

Yes, it is true that there is no rush.

OTOH there are absolutely no valid technical reasons to slow it down!

>      2. this antagonism in feature evolution is likely to lead to
>         interface incompatibility between libata and IDE ... and users
>         will be the ultimate losers because of this.

Hmmm, did you *really* read the patches?

They make libata and IDE more similar by making IDE also default to
preserving HPA (which is what libata does).  So users get more coherent
overall kernel behavior.

The only difference is that IDE for compatibility reasons must handle old
installs (with HPA wrongly disabled and protected area used for filesystem
data).

However it does it in a clean way (not a subsystem specific hack) which
can be later used for implementing the same functionality in libata!

[ I also tried to encourage libata developers to look into making the needed
  libata changes (see my initial posting of HPA patches) and I will still be
  glad to help with libata patches if somebody would like to work on them
  (Robert? Tejun?). ]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 15:44         ` Bartlomiej Zolnierkiewicz
  2009-06-07 16:08           ` James Bottomley
@ 2009-06-07 16:54           ` Pekka Enberg
  2009-06-07 17:55             ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 58+ messages in thread
From: Pekka Enberg @ 2009-06-07 16:54 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: James Bottomley, Alan Cox, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

Hi Bartlomiej,

On Sun, Jun 7, 2009 at 6:44 PM, Bartlomiej Zolnierkiewicz
<bzolnier@gmail.com> wrote:
> Honestly, this should be solved on technical basis by somebody posting
> needed libata patches instead of attempts to slow down IDE fixes.

Nobody is "slowing down" IDE fixes here. Linus explicitly said that
-rc8 is the last release candidate and the next one is going to be
-final. There's absolutely _no way_ this series is appropriate at the
very end of a release cycle.

                         Pekka

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 15:44         ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 16:08           ` James Bottomley
  2009-06-07 17:47             ` Bartlomiej Zolnierkiewicz
  2009-06-07 16:54           ` Pekka Enberg
  1 sibling, 1 reply; 58+ messages in thread
From: James Bottomley @ 2009-06-07 16:08 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sun, 2009-06-07 at 17:44 +0200, Bartlomiej Zolnierkiewicz wrote:
> On Sunday 07 June 2009 17:18:51 you wrote:
> > On Sun, 2009-06-07 at 16:57 +0200, Bartlomiej Zolnierkiewicz wrote:
> > > On Sunday 07 June 2009 16:38:56 James Bottomley wrote:
> > > > On Sun, 2009-06-07 at 15:21 +0100, Alan Cox wrote:
> > > > > > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > > > > > index 99e33ef..4bc2c43 100644
> > > > > > --- a/fs/partitions/check.c
> > > > > > +++ b/fs/partitions/check.c
> > > > > 
> > > > > 
> > > > > You seriously want to add code to the core partition handling logic
> > > > > moments before release when we know we have all sorts of devices with
> > > > > weird behaviours ?
> > > > > 
> > > > > This should be .31 stuff where we can take the time to see how it works
> > > > > on all sorts of weird real world devices (eg those with 2K sector size)
> > > > > and the like.
> > > > 
> > > > Absolutely seconded.
> > > > 
> > > > Plus this is only one of the proposals for dealing with IDE native sizes
> > > > moving through the process.  The other one is in libata with the gendisk
> > > > proposal for alt size instead of your set_capacity callback.   The last
> > > 
> > > ->set_capacity callback is needed for drivers/ide regardless of alt_size
> > > sysfs interface and it don't conflict with it in any way.
> > 
> > It's used as a heuristic for selecting native vs protected disk size
> > depending on what the partition table says ... I grant that's one way to
> > handle the problem.
> > 
> > > Those patches are a complimentary work to Tejun's alt_size patches. 
> > > 
> > > They don't export anything to user-space.
> > 
> > So you're trying to solve the problem heuristically, and Tejun is trying
> > to provide the user with full information.   At the end of the day it
> > would be nice to get agreement on how we do this *before* exposing it to
> > users.  It's certainly possible we could do both, but for that to happen
> 
> Sure.  My patches don't export anything to user-space.
> 
> If you find any code parts controversial please post them and I'll be
> more than happy to discuss them in details.
> 
> > libata would have to implement .get_capacity() is that going to be the
> > case?
> 
> Now we get the real source of Alan's and your complains...
> 
> Those patches (among other things) make IDE superior overt libata w.r.t.
> HPA handling so libata now has to catch up.
> 
> Honestly, this should be solved on technical basis by somebody posting
> needed libata patches instead of attempts to slow down IDE fixes.

You've got the wrong motive.  I have notice that you and Alan seem to
have a somewhat antagonistic relationship resulting in a proxy battle
over IDE/libata, so you would necessarily see this as at play in his
first post.  I hoped, by emphasizing the point, that you'd see this
adding features as bug fixes is a problem even from a more neutral
perspective.

So I have two specific problems with the way you're trying to one up
libata:

     1. You're trying to get a jump on them by adding features as bug
        fixes ... this is incredibly bad release practice.
     2. this antagonism in feature evolution is likely to lead to
        interface incompatibility between libata and IDE ... and users
        will be the ultimate losers because of this.

James



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 15:18       ` James Bottomley
@ 2009-06-07 15:44         ` Bartlomiej Zolnierkiewicz
  2009-06-07 16:08           ` James Bottomley
  2009-06-07 16:54           ` Pekka Enberg
  0 siblings, 2 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 15:44 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sunday 07 June 2009 17:18:51 you wrote:
> On Sun, 2009-06-07 at 16:57 +0200, Bartlomiej Zolnierkiewicz wrote:
> > On Sunday 07 June 2009 16:38:56 James Bottomley wrote:
> > > On Sun, 2009-06-07 at 15:21 +0100, Alan Cox wrote:
> > > > > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > > > > index 99e33ef..4bc2c43 100644
> > > > > --- a/fs/partitions/check.c
> > > > > +++ b/fs/partitions/check.c
> > > > 
> > > > 
> > > > You seriously want to add code to the core partition handling logic
> > > > moments before release when we know we have all sorts of devices with
> > > > weird behaviours ?
> > > > 
> > > > This should be .31 stuff where we can take the time to see how it works
> > > > on all sorts of weird real world devices (eg those with 2K sector size)
> > > > and the like.
> > > 
> > > Absolutely seconded.
> > > 
> > > Plus this is only one of the proposals for dealing with IDE native sizes
> > > moving through the process.  The other one is in libata with the gendisk
> > > proposal for alt size instead of your set_capacity callback.   The last
> > 
> > ->set_capacity callback is needed for drivers/ide regardless of alt_size
> > sysfs interface and it don't conflict with it in any way.
> 
> It's used as a heuristic for selecting native vs protected disk size
> depending on what the partition table says ... I grant that's one way to
> handle the problem.
> 
> > Those patches are a complimentary work to Tejun's alt_size patches. 
> > 
> > They don't export anything to user-space.
> 
> So you're trying to solve the problem heuristically, and Tejun is trying
> to provide the user with full information.   At the end of the day it
> would be nice to get agreement on how we do this *before* exposing it to
> users.  It's certainly possible we could do both, but for that to happen

Sure.  My patches don't export anything to user-space.

If you find any code parts controversial please post them and I'll be
more than happy to discuss them in details.

> libata would have to implement .get_capacity() is that going to be the
> case?

Now we get the real source of Alan's and your complains...

Those patches (among other things) make IDE superior overt libata w.r.t.
HPA handling so libata now has to catch up.

Honestly, this should be solved on technical basis by somebody posting
needed libata patches instead of attempts to slow down IDE fixes.

> > > thing we want is two separate mechanisms for this, so trying to push
> > > anything upstream before we have agreement on direction is premature ...
> > > trying to send a feature as a bug fix is doubly so.
> > 
> > James, please (re-)read commits, then bug #13365 at kernel.org and if you
> > still find some code parts controversial I'll be happy to discuss them.
> 
> Um, that's a red herring, isn't it?  That bug complains that a migration
> from IDE to libata failed because IDE was ignoring HPA and libata was
> respecting it resulting in a disk under libata whose partition table was
> too big for its HPA reduced capacity; the fix was to turn off libata HPA
> in that configuration.  As far as I can tell nothing in the code you've
> added actually fixes that bug.  To fix it, we'd have to add a
> get_capacity() method to libata as well so that it could use your
> partition heuristics to turn off the HPA.

Indeed.

Though first you have to get somebody from libata agree that this is a bug
and that it should get fixed.  Then somebody would need to do the work.

However my patches make it *easier* for libata developers to fix the
aforementioned compatibility issue.

> What your code does instead is to add HPA handling to IDE so that you no
> longer always ignore it ... that's fine, but it's still a feature
> enhancement not a bug fix.

If you look at the whole HPA handling from the Big Picture perspective
(taking new system installs into account when the old behavior could
result in all sorts of problems including firmware corruption) than it
*really* is a bug fix.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:57     ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 15:18       ` James Bottomley
  2009-06-07 15:44         ` Bartlomiej Zolnierkiewicz
  2009-06-07 23:12       ` Linus Torvalds
  1 sibling, 1 reply; 58+ messages in thread
From: James Bottomley @ 2009-06-07 15:18 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sun, 2009-06-07 at 16:57 +0200, Bartlomiej Zolnierkiewicz wrote:
> On Sunday 07 June 2009 16:38:56 James Bottomley wrote:
> > On Sun, 2009-06-07 at 15:21 +0100, Alan Cox wrote:
> > > > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > > > index 99e33ef..4bc2c43 100644
> > > > --- a/fs/partitions/check.c
> > > > +++ b/fs/partitions/check.c
> > > 
> > > 
> > > You seriously want to add code to the core partition handling logic
> > > moments before release when we know we have all sorts of devices with
> > > weird behaviours ?
> > > 
> > > This should be .31 stuff where we can take the time to see how it works
> > > on all sorts of weird real world devices (eg those with 2K sector size)
> > > and the like.
> > 
> > Absolutely seconded.
> > 
> > Plus this is only one of the proposals for dealing with IDE native sizes
> > moving through the process.  The other one is in libata with the gendisk
> > proposal for alt size instead of your set_capacity callback.   The last
> 
> ->set_capacity callback is needed for drivers/ide regardless of alt_size
> sysfs interface and it don't conflict with it in any way.

It's used as a heuristic for selecting native vs protected disk size
depending on what the partition table says ... I grant that's one way to
handle the problem.

> Those patches are a complimentary work to Tejun's alt_size patches. 
> 
> They don't export anything to user-space.

So you're trying to solve the problem heuristically, and Tejun is trying
to provide the user with full information.   At the end of the day it
would be nice to get agreement on how we do this *before* exposing it to
users.  It's certainly possible we could do both, but for that to happen
libata would have to implement .get_capacity() is that going to be the
case?

> > thing we want is two separate mechanisms for this, so trying to push
> > anything upstream before we have agreement on direction is premature ...
> > trying to send a feature as a bug fix is doubly so.
> 
> James, please (re-)read commits, then bug #13365 at kernel.org and if you
> still find some code parts controversial I'll be happy to discuss them.

Um, that's a red herring, isn't it?  That bug complains that a migration
from IDE to libata failed because IDE was ignoring HPA and libata was
respecting it resulting in a disk under libata whose partition table was
too big for its HPA reduced capacity; the fix was to turn off libata HPA
in that configuration.  As far as I can tell nothing in the code you've
added actually fixes that bug.  To fix it, we'd have to add a
get_capacity() method to libata as well so that it could use your
partition heuristics to turn off the HPA.

What your code does instead is to add HPA handling to IDE so that you no
longer always ignore it ... that's fine, but it's still a feature
enhancement not a bug fix.

James



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 15:03       ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 15:11         ` Alan Cox
  0 siblings, 0 replies; 58+ messages in thread
From: Alan Cox @ 2009-06-07 15:11 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

> > This isn't about technical merits - it is about *risk*. You don't submit
> 
> fs/partitions/check.c change doesn't influence anything other that behavior
> of ide-gd driver and has been ACK-ed by Al Viro.

What part of "risk" don't you understand ? Any change to core code paths
is a risk, submitting it just before 2.6.30 is plain stupid.

> > patches to core code to add new features just before the final release.
> 
> This is not a feature but really a bug fix (requested by you along other
> people in the past).

Its not an urgent this release doom-disaster fix - its a run of the mill
feature improvement that fixes up a long term issue and wants testing in
quantity before merging and nicely integrating so other storage people
are happy with it.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:40     ` Alan Cox
@ 2009-06-07 15:03       ` Bartlomiej Zolnierkiewicz
  2009-06-07 15:11         ` Alan Cox
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 15:03 UTC (permalink / raw)
  To: Alan Cox
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Sunday 07 June 2009 16:40:48 Alan Cox wrote:
> > If you want to discuss any code that I push upstream then *please* quote
> > it in your mails so we all can see what parts you question and discuss it
> > based on technical merits.
> 
> This isn't about technical merits - it is about *risk*. You don't submit

fs/partitions/check.c change doesn't influence anything other that behavior
of ide-gd driver and has been ACK-ed by Al Viro.

> patches to core code to add new features just before the final release.

This is not a feature but really a bug fix (requested by you along other
people in the past).

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:38   ` James Bottomley
@ 2009-06-07 14:57     ` Bartlomiej Zolnierkiewicz
  2009-06-07 15:18       ` James Bottomley
  2009-06-07 23:12       ` Linus Torvalds
  0 siblings, 2 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 14:57 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Cox, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Sunday 07 June 2009 16:38:56 James Bottomley wrote:
> On Sun, 2009-06-07 at 15:21 +0100, Alan Cox wrote:
> > > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > > index 99e33ef..4bc2c43 100644
> > > --- a/fs/partitions/check.c
> > > +++ b/fs/partitions/check.c
> > 
> > 
> > You seriously want to add code to the core partition handling logic
> > moments before release when we know we have all sorts of devices with
> > weird behaviours ?
> > 
> > This should be .31 stuff where we can take the time to see how it works
> > on all sorts of weird real world devices (eg those with 2K sector size)
> > and the like.
> 
> Absolutely seconded.
> 
> Plus this is only one of the proposals for dealing with IDE native sizes
> moving through the process.  The other one is in libata with the gendisk
> proposal for alt size instead of your set_capacity callback.   The last

->set_capacity callback is needed for drivers/ide regardless of alt_size
sysfs interface and it don't conflict with it in any way.

Those patches are a complimentary work to Tejun's alt_size patches. 

They don't export anything to user-space.

> thing we want is two separate mechanisms for this, so trying to push
> anything upstream before we have agreement on direction is premature ...
> trying to send a feature as a bug fix is doubly so.

James, please (re-)read commits, then bug #13365 at kernel.org and if you
still find some code parts controversial I'll be happy to discuss them.

Thanks.
Bart

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:32   ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 14:40     ` Alan Cox
  2009-06-07 15:03       ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Alan Cox @ 2009-06-07 14:40 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

> If you want to discuss any code that I push upstream then *please* quote
> it in your mails so we all can see what parts you question and discuss it
> based on technical merits.

This isn't about technical merits - it is about *risk*. You don't submit
patches to core code to add new features just before the final release.

And my email included enough meta-information (such as the patch header)
to make the neccessary point.

Alan

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:21 ` Alan Cox
  2009-06-07 14:32   ` Bartlomiej Zolnierkiewicz
@ 2009-06-07 14:38   ` James Bottomley
  2009-06-07 14:57     ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 58+ messages in thread
From: James Bottomley @ 2009-06-07 14:38 UTC (permalink / raw)
  To: Alan Cox
  Cc: Bartlomiej Zolnierkiewicz, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Sun, 2009-06-07 at 15:21 +0100, Alan Cox wrote:
> > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > index 99e33ef..4bc2c43 100644
> > --- a/fs/partitions/check.c
> > +++ b/fs/partitions/check.c
> 
> 
> You seriously want to add code to the core partition handling logic
> moments before release when we know we have all sorts of devices with
> weird behaviours ?
> 
> This should be .31 stuff where we can take the time to see how it works
> on all sorts of weird real world devices (eg those with 2K sector size)
> and the like.

Absolutely seconded.

Plus this is only one of the proposals for dealing with IDE native sizes
moving through the process.  The other one is in libata with the gendisk
proposal for alt size instead of your set_capacity callback.   The last
thing we want is two separate mechanisms for this, so trying to push
anything upstream before we have agreement on direction is premature ...
trying to send a feature as a bug fix is doubly so.

James



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 14:21 ` Alan Cox
@ 2009-06-07 14:32   ` Bartlomiej Zolnierkiewicz
  2009-06-07 14:40     ` Alan Cox
  2009-06-07 14:38   ` James Bottomley
  1 sibling, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 14:32 UTC (permalink / raw)
  To: Alan Cox
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Sunday 07 June 2009 16:21:51 Alan Cox wrote:
> > diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> > index 99e33ef..4bc2c43 100644
> > --- a/fs/partitions/check.c
> > +++ b/fs/partitions/check.c
> 
> 
> You seriously want to add code to the core partition handling logic
> moments before release when we know we have all sorts of devices with
> weird behaviours ?
> 
> This should be .31 stuff where we can take the time to see how it works
> on all sorts of weird real world devices (eg those with 2K sector size)
> and the like.

If you want to discuss any code that I push upstream then *please* quote
it in your mails so we all can see what parts you question and discuss it
based on technical merits.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-06-07 12:44 Bartlomiej Zolnierkiewicz
@ 2009-06-07 14:21 ` Alan Cox
  2009-06-07 14:32   ` Bartlomiej Zolnierkiewicz
  2009-06-07 14:38   ` James Bottomley
  0 siblings, 2 replies; 58+ messages in thread
From: Alan Cox @ 2009-06-07 14:21 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

> diff --git a/fs/partitions/check.c b/fs/partitions/check.c
> index 99e33ef..4bc2c43 100644
> --- a/fs/partitions/check.c
> +++ b/fs/partitions/check.c


You seriously want to add code to the core partition handling logic
moments before release when we know we have all sorts of devices with
weird behaviours ?

This should be .31 stuff where we can take the time to see how it works
on all sorts of weird real world devices (eg those with 2K sector size)
and the like.


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-06-07 12:44 Bartlomiej Zolnierkiewicz
  2009-06-07 14:21 ` Alan Cox
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-06-07 12:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Fixes for pdc202xx_old host driver and for Host Protected Area (HPA) support.

The latter ones come a bit late but since they were tested and reviewed
(fs/partitions/ part was acked by Al, drivers/ide/ parts by Alan and Sergei)
I see no real reason to delay them till 2.6.31, especially since they should
make everyone's life easier (as we have now the same default HPA behavior in
both ide/libata).


Linus, please pull from 'for-linus' branch of:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus

to receive the following updates:

 Documentation/ide/ide.txt           |    2 +
 Documentation/kernel-parameters.txt |    7 +--
 drivers/ide/ide-disk.c              |   71 ++++++++++++++++++++++++++++++-----
 drivers/ide/ide-gd.c                |   14 +++++++
 drivers/ide/ide.c                   |   10 +++++
 drivers/ide/pdc202xx_old.c          |   22 +++--------
 fs/partitions/check.c               |   42 ++++++++++++++++-----
 include/linux/blkdev.h              |    2 +
 include/linux/genhd.h               |    1 +
 include/linux/ide.h                 |    6 ++-
 10 files changed, 134 insertions(+), 43 deletions(-)


Bartlomiej Zolnierkiewicz (4):
      partitions: warn about the partition exceeding device capacity
      partitions: add ->set_capacity block device method
      ide-gd: implement block device ->set_capacity method (v2)
      ide: preserve Host Protected Area by default (v2)

Sergei Shtylyov (2):
      pdc202xx_old: fix 'pdc20246_dma_ops'
      pdc202xx_old: fix resetproc() method


diff --git a/Documentation/ide/ide.txt b/Documentation/ide/ide.txt
index 0c78f4b..e77bebf 100644
--- a/Documentation/ide/ide.txt
+++ b/Documentation/ide/ide.txt
@@ -216,6 +216,8 @@ Other kernel parameters for ide_core are:
 
 * "noflush=[interface_number.device_number]" to disable flush requests
 
+* "nohpa=[interface_number.device_number]" to disable Host Protected Area
+
 * "noprobe=[interface_number.device_number]" to skip probing
 
 * "nowerr=[interface_number.device_number]" to ignore the WRERR_STAT bit
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index a19f021..e58c91c 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -835,11 +835,8 @@ and is between 256 and 4096 characters. It is defined in the file
 
 	ide-core.nodma=	[HW] (E)IDE subsystem
 			Format: =0.0 to prevent dma on hda, =0.1 hdb =1.0 hdc
-			.vlb_clock .pci_clock .noflush .noprobe .nowerr .cdrom
-			.chs .ignore_cable are additional options
-			See Documentation/ide/ide.txt.
-
-	idebus=		[HW] (E)IDE subsystem - VLB/PCI bus speed
+			.vlb_clock .pci_clock .noflush .nohpa .noprobe .nowerr
+			.cdrom .chs .ignore_cable are additional options
 			See Documentation/ide/ide.txt.
 
 	ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index a9fbe2c..3d92c9d 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -302,14 +302,12 @@ static const struct drive_list_entry hpa_list[] = {
 	{ NULL,		NULL }
 };
 
-static void idedisk_check_hpa(ide_drive_t *drive)
+static u64 ide_disk_hpa_get_native_capacity(ide_drive_t *drive, int lba48)
 {
-	unsigned long long capacity, set_max;
-	int lba48 = ata_id_lba48_enabled(drive->id);
+	u64 capacity, set_max;
 
 	capacity = drive->capacity64;
-
-	set_max = idedisk_read_native_max_address(drive, lba48);
+	set_max  = idedisk_read_native_max_address(drive, lba48);
 
 	if (ide_in_drive_list(drive->id, hpa_list)) {
 		/*
@@ -320,9 +318,31 @@ static void idedisk_check_hpa(ide_drive_t *drive)
 			set_max--;
 	}
 
+	return set_max;
+}
+
+static u64 ide_disk_hpa_set_capacity(ide_drive_t *drive, u64 set_max, int lba48)
+{
+	set_max = idedisk_set_max_address(drive, set_max, lba48);
+	if (set_max)
+		drive->capacity64 = set_max;
+
+	return set_max;
+}
+
+static void idedisk_check_hpa(ide_drive_t *drive)
+{
+	u64 capacity, set_max;
+	int lba48 = ata_id_lba48_enabled(drive->id);
+
+	capacity = drive->capacity64;
+	set_max  = ide_disk_hpa_get_native_capacity(drive, lba48);
+
 	if (set_max <= capacity)
 		return;
 
+	drive->probed_capacity = set_max;
+
 	printk(KERN_INFO "%s: Host Protected Area detected.\n"
 			 "\tcurrent capacity is %llu sectors (%llu MB)\n"
 			 "\tnative  capacity is %llu sectors (%llu MB)\n",
@@ -330,13 +350,13 @@ static void idedisk_check_hpa(ide_drive_t *drive)
 			 capacity, sectors_to_MB(capacity),
 			 set_max, sectors_to_MB(set_max));
 
-	set_max = idedisk_set_max_address(drive, set_max, lba48);
+	if ((drive->dev_flags & IDE_DFLAG_NOHPA) == 0)
+		return;
 
-	if (set_max) {
-		drive->capacity64 = set_max;
+	set_max = ide_disk_hpa_set_capacity(drive, set_max, lba48);
+	if (set_max)
 		printk(KERN_INFO "%s: Host Protected Area disabled.\n",
 				 drive->name);
-	}
 }
 
 static int ide_disk_get_capacity(ide_drive_t *drive)
@@ -358,6 +378,8 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
 		drive->capacity64 = drive->cyl * drive->head * drive->sect;
 	}
 
+	drive->probed_capacity = drive->capacity64;
+
 	if (lba) {
 		drive->dev_flags |= IDE_DFLAG_LBA;
 
@@ -376,7 +398,7 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
 		       "%llu sectors (%llu MB)\n",
 		       drive->name, (unsigned long long)drive->capacity64,
 		       sectors_to_MB(drive->capacity64));
-		drive->capacity64 = 1ULL << 28;
+		drive->probed_capacity = drive->capacity64 = 1ULL << 28;
 	}
 
 	if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
@@ -392,6 +414,34 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
 	return 0;
 }
 
+static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity)
+{
+	u64 set = min(capacity, drive->probed_capacity);
+	u16 *id = drive->id;
+	int lba48 = ata_id_lba48_enabled(id);
+
+	if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
+	    ata_id_hpa_enabled(id) == 0)
+		goto out;
+
+	/*
+	 * according to the spec the SET MAX ADDRESS command shall be
+	 * immediately preceded by a READ NATIVE MAX ADDRESS command
+	 */
+	capacity = ide_disk_hpa_get_native_capacity(drive, lba48);
+	if (capacity == 0)
+		goto out;
+
+	set = ide_disk_hpa_set_capacity(drive, set, lba48);
+	if (set) {
+		/* needed for ->resume to disable HPA */
+		drive->dev_flags |= IDE_DFLAG_NOHPA;
+		return set;
+	}
+out:
+	return drive->capacity64;
+}
+
 static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
 {
 	ide_drive_t *drive = q->queuedata;
@@ -741,6 +791,7 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
 
 const struct ide_disk_ops ide_ata_disk_ops = {
 	.check		= ide_disk_check,
+	.set_capacity	= ide_disk_set_capacity,
 	.get_capacity	= ide_disk_get_capacity,
 	.setup		= ide_disk_setup,
 	.flush		= ide_disk_flush,
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 4b6b71e..2141190 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -287,6 +287,19 @@ static int ide_gd_media_changed(struct gendisk *disk)
 	return ret;
 }
 
+static unsigned long long ide_gd_set_capacity(struct gendisk *disk,
+					      unsigned long long capacity)
+{
+	struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
+	ide_drive_t *drive = idkp->drive;
+	const struct ide_disk_ops *disk_ops = drive->disk_ops;
+
+	if (disk_ops->set_capacity)
+		return disk_ops->set_capacity(drive, capacity);
+
+	return drive->capacity64;
+}
+
 static int ide_gd_revalidate_disk(struct gendisk *disk)
 {
 	struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
@@ -315,6 +328,7 @@ static struct block_device_operations ide_gd_ops = {
 	.locked_ioctl		= ide_gd_ioctl,
 	.getgeo			= ide_gd_getgeo,
 	.media_changed		= ide_gd_media_changed,
+	.set_capacity		= ide_gd_set_capacity,
 	.revalidate_disk	= ide_gd_revalidate_disk
 };
 
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 92c9b90..16d0569 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -211,6 +211,11 @@ static unsigned int ide_noflush;
 module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0);
 MODULE_PARM_DESC(noflush, "disable flush requests for a device");
 
+static unsigned int ide_nohpa;
+
+module_param_call(nohpa, ide_set_dev_param_mask, NULL, &ide_nohpa, 0);
+MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device");
+
 static unsigned int ide_noprobe;
 
 module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0);
@@ -281,6 +286,11 @@ static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
 				 drive->name);
 		drive->dev_flags |= IDE_DFLAG_NOFLUSH;
 	}
+	if (ide_nohpa & (1 << i)) {
+		printk(KERN_INFO "ide: disabling Host Protected Area for %s\n",
+				 drive->name);
+		drive->dev_flags |= IDE_DFLAG_NOHPA;
+	}
 	if (ide_noprobe & (1 << i)) {
 		printk(KERN_INFO "ide: skipping probe for %s\n", drive->name);
 		drive->dev_flags |= IDE_DFLAG_NOPROBE;
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 248a54b..b3bc96f 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1998-2002		Andre Hedrick <andre@linux-ide.org>
- *  Copyright (C) 2006-2007		MontaVista Software, Inc.
+ *  Copyright (C) 2006-2007, 2009	MontaVista Software, Inc.
  *  Copyright (C) 2007			Bartlomiej Zolnierkiewicz
  *
  *  Portions Copyright (C) 1999 Promise Technology, Inc.
@@ -227,28 +227,19 @@ somebody_else:
 	return (dma_stat & 4) == 4;	/* return 1 if INTR asserted */
 }
 
-static void pdc202xx_reset_host (ide_hwif_t *hwif)
+static void pdc202xx_reset(ide_drive_t *drive)
 {
+	ide_hwif_t *hwif	= drive->hwif;
 	unsigned long high_16	= hwif->extra_base - 16;
 	u8 udma_speed_flag	= inb(high_16 | 0x001f);
 
+	printk(KERN_WARNING "PDC202xx: software reset...\n");
+
 	outb(udma_speed_flag | 0x10, high_16 | 0x001f);
 	mdelay(100);
 	outb(udma_speed_flag & ~0x10, high_16 | 0x001f);
 	mdelay(2000);	/* 2 seconds ?! */
 
-	printk(KERN_WARNING "PDC202XX: %s channel reset.\n",
-		hwif->channel ? "Secondary" : "Primary");
-}
-
-static void pdc202xx_reset (ide_drive_t *drive)
-{
-	ide_hwif_t *hwif	= drive->hwif;
-	ide_hwif_t *mate	= hwif->mate;
-
-	pdc202xx_reset_host(hwif);
-	pdc202xx_reset_host(mate);
-
 	ide_set_max_pio(drive);
 }
 
@@ -328,9 +319,8 @@ static const struct ide_dma_ops pdc20246_dma_ops = {
 	.dma_start		= ide_dma_start,
 	.dma_end		= ide_dma_end,
 	.dma_test_irq		= pdc202xx_dma_test_irq,
-	.dma_lost_irq		= pdc202xx_dma_lost_irq,
+	.dma_lost_irq		= ide_dma_lost_irq,
 	.dma_timer_expiry	= ide_dma_sff_timer_expiry,
-	.dma_clear		= pdc202xx_reset,
 	.dma_sff_read_status	= ide_dma_sff_read_status,
 };
 
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 99e33ef..4bc2c43 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -546,27 +546,49 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
 
 	/* add partitions */
 	for (p = 1; p < state->limit; p++) {
-		sector_t size = state->parts[p].size;
-		sector_t from = state->parts[p].from;
+		sector_t size, from;
+try_scan:
+		size = state->parts[p].size;
 		if (!size)
 			continue;
+
+		from = state->parts[p].from;
 		if (from >= get_capacity(disk)) {
 			printk(KERN_WARNING
 			       "%s: p%d ignored, start %llu is behind the end of the disk\n",
 			       disk->disk_name, p, (unsigned long long) from);
 			continue;
 		}
+
 		if (from + size > get_capacity(disk)) {
-			/*
-			 * we can not ignore partitions of broken tables
-			 * created by for example camera firmware, but we
-			 * limit them to the end of the disk to avoid
-			 * creating invalid block devices
-			 */
+			struct block_device_operations *bdops = disk->fops;
+			unsigned long long capacity;
+
 			printk(KERN_WARNING
-			       "%s: p%d size %llu limited to end of disk\n",
+			       "%s: p%d size %llu exceeds device capacity, ",
 			       disk->disk_name, p, (unsigned long long) size);
-			size = get_capacity(disk) - from;
+
+			if (bdops->set_capacity &&
+			    (disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) {
+				printk(KERN_CONT "enabling native capacity\n");
+				capacity = bdops->set_capacity(disk, ~0ULL);
+				disk->flags |= GENHD_FL_NATIVE_CAPACITY;
+				if (capacity > get_capacity(disk)) {
+					set_capacity(disk, capacity);
+					check_disk_size_change(disk, bdev);
+					bdev->bd_invalidated = 0;
+				}
+				goto try_scan;
+			} else {
+				/*
+				 * we can not ignore partitions of broken tables
+				 * created by for example camera firmware, but
+				 * we limit them to the end of the disk to avoid
+				 * creating invalid block devices
+				 */
+				printk(KERN_CONT "limited to end of disk\n");
+				size = get_capacity(disk) - from;
+			}
 		}
 		part = add_partition(disk, p, from, size,
 				     state->parts[p].flags);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6f841fb..a2d7298 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1106,6 +1106,8 @@ struct block_device_operations {
 	int (*direct_access) (struct block_device *, sector_t,
 						void **, unsigned long *);
 	int (*media_changed) (struct gendisk *);
+	unsigned long long (*set_capacity) (struct gendisk *,
+						unsigned long long);
 	int (*revalidate_disk) (struct gendisk *);
 	int (*getgeo)(struct block_device *, struct hd_geometry *);
 	struct module *owner;
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 634c530..239e24b 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -113,6 +113,7 @@ struct hd_struct {
 #define GENHD_FL_UP				16
 #define GENHD_FL_SUPPRESS_PARTITION_INFO	32
 #define GENHD_FL_EXT_DEVT			64 /* allow extended devt */
+#define GENHD_FL_NATIVE_CAPACITY		128
 
 #define BLK_SCSI_MAX_CMDS	(256)
 #define BLK_SCSI_CMD_PER_LONG	(BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9fed365..45dce3b 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -397,6 +397,7 @@ struct ide_drive_s;
 struct ide_disk_ops {
 	int		(*check)(struct ide_drive_s *, const char *);
 	int		(*get_capacity)(struct ide_drive_s *);
+	u64		(*set_capacity)(struct ide_drive_s *, u64);
 	void		(*setup)(struct ide_drive_s *);
 	void		(*flush)(struct ide_drive_s *);
 	int		(*init_media)(struct ide_drive_s *, struct gendisk *);
@@ -474,6 +475,8 @@ enum {
 	IDE_DFLAG_NICE1			= (1 << 5),
 	/* device is physically present */
 	IDE_DFLAG_PRESENT		= (1 << 6),
+	/* disable Host Protected Area */
+	IDE_DFLAG_NOHPA			= (1 << 7),
 	/* id read from device (synthetic if not set) */
 	IDE_DFLAG_ID_READ		= (1 << 8),
 	IDE_DFLAG_NOPROBE		= (1 << 9),
@@ -568,8 +571,7 @@ struct ide_drive_s {
 	unsigned int	drive_data;	/* used by set_pio_mode/dev_select() */
 	unsigned int	failures;	/* current failure count */
 	unsigned int	max_failures;	/* maximum allowed failure count */
-	u64		probed_capacity;/* initial reported media capacity (ide-cd only currently) */
-
+	u64		probed_capacity;/* initial/native media capacity */
 	u64		capacity64;	/* total number of sectors */
 
 	int		lun;		/* logical unit */

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-05-22 15:17 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-22 15:17 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Fix for ide-cd error recovery OOPS, workaround for broken cable
detection on TSST SH-S202* ATAPI devices, improvements to error
reporting and addition of VIA VX855/VX875 IDE support.


Linus, please pull from 'for-linus' branch of:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus

to receive the following updates:

 drivers/ide/ide-io.c    |    4 ++--
 drivers/ide/ide-iops.c  |   21 +++++++++++++++++----
 drivers/ide/ide-lib.c   |   27 ++++++---------------------
 drivers/ide/ide-probe.c |    9 ++++++---
 drivers/ide/via82cxxx.c |    2 ++
 include/linux/ide.h     |    2 +-
 include/linux/pci_ids.h |    2 +-
 7 files changed, 35 insertions(+), 32 deletions(-)


Bartlomiej Zolnierkiewicz (5):
      ide: fix 40-wire cable detection for TSST SH-S202* ATAPI devices (v2)
      ide: fix OOPS during ide-cd error recovery
      ide: fix printk() levels in ide_dump_ata[pi]_error()
      ide: improve failed opcode reporting
      ide: report timeouts in ide_busy_sleep()

Harald Welte (1):
      via82cxxx: Add VIA VX855 PCI Device ID


diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 35dc38d..6415a2e 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -696,7 +696,7 @@ void ide_timer_expiry (unsigned long data)
 		}
 		spin_lock_irq(&hwif->lock);
 		enable_irq(hwif->irq);
-		if (startstop == ide_stopped) {
+		if (startstop == ide_stopped && hwif->polling == 0) {
 			ide_unlock_port(hwif);
 			plug_device = 1;
 		}
@@ -868,7 +868,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
 	 * same irq as is currently being serviced here, and Linux
 	 * won't allow another of the same (on any CPU) until we return.
 	 */
-	if (startstop == ide_stopped) {
+	if (startstop == ide_stopped && hwif->polling == 0) {
 		BUG_ON(hwif->handler);
 		ide_unlock_port(hwif);
 		plug_device = 1;
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index c19a221..06fe002 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -206,8 +206,6 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
 
 /*
  * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid.
- * We list them here and depend on the device side cable detection for them.
- *
  * Some optical devices with the buggy firmwares have the same problem.
  */
 static const struct drive_list_entry ivb_list[] = {
@@ -251,10 +249,25 @@ u8 eighty_ninty_three(ide_drive_t *drive)
 	 * - force bit13 (80c cable present) check also for !ivb devices
 	 *   (unless the slave device is pre-ATA3)
 	 */
-	if ((id[ATA_ID_HW_CONFIG] & 0x4000) ||
-	    (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000)))
+	if (id[ATA_ID_HW_CONFIG] & 0x4000)
 		return 1;
 
+	if (ivb) {
+		const char *model = (char *)&id[ATA_ID_PROD];
+
+		if (strstr(model, "TSSTcorp CDDVDW SH-S202")) {
+			/*
+			 * These ATAPI devices always report 80c cable
+			 * so we have to depend on the host in this case.
+			 */
+			if (hwif->cbl == ATA_CBL_PATA80)
+				return 1;
+		} else {
+			/* Depend on the device side cable detection. */
+			if (id[ATA_ID_HW_CONFIG] & 0x2000)
+				return 1;
+		}
+	}
 no_80w:
 	if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED)
 		return 0;
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 56ff8c4..2148df8 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -31,24 +31,6 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
 		blk_queue_bounce_limit(drive->queue, addr);
 }
 
-static void ide_dump_opcode(ide_drive_t *drive)
-{
-	struct request *rq = drive->hwif->rq;
-	struct ide_cmd *cmd = NULL;
-
-	if (!rq)
-		return;
-
-	if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
-		cmd = rq->special;
-
-	printk(KERN_ERR "ide: failed opcode was: ");
-	if (cmd == NULL)
-		printk(KERN_CONT "unknown\n");
-	else
-		printk(KERN_CONT "0x%02x\n", cmd->tf.command);
-}
-
 u64 ide_get_lba_addr(struct ide_cmd *cmd, int lba48)
 {
 	struct ide_taskfile *tf = &cmd->tf;
@@ -91,7 +73,7 @@ static void ide_dump_sector(ide_drive_t *drive)
 
 static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
 {
-	printk(KERN_ERR "{ ");
+	printk(KERN_CONT "{ ");
 	if (err & ATA_ABORTED)
 		printk(KERN_CONT "DriveStatusError ");
 	if (err & ATA_ICRC)
@@ -121,7 +103,7 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
 
 static void ide_dump_atapi_error(ide_drive_t *drive, u8 err)
 {
-	printk(KERN_ERR "{ ");
+	printk(KERN_CONT "{ ");
 	if (err & ATAPI_ILI)
 		printk(KERN_CONT "IllegalLengthIndication ");
 	if (err & ATAPI_EOM)
@@ -179,7 +161,10 @@ u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
 		else
 			ide_dump_atapi_error(drive, err);
 	}
-	ide_dump_opcode(drive);
+
+	printk(KERN_ERR "%s: possibly failed opcode: 0x%02x\n",
+		drive->name, drive->hwif->cmd.tf.command);
+
 	return err;
 }
 EXPORT_SYMBOL(ide_dump_status);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 7f264ed..c895ed5 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -295,7 +295,7 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
 
 	timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
 
-	if (ide_busy_sleep(hwif, timeout, use_altstatus))
+	if (ide_busy_sleep(drive, timeout, use_altstatus))
 		return 1;
 
 	/* wait for IRQ and ATA_DRQ */
@@ -316,8 +316,9 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
 	return rc;
 }
 
-int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
+int ide_busy_sleep(ide_drive_t *drive, unsigned long timeout, int altstatus)
 {
+	ide_hwif_t *hwif = drive->hwif;
 	u8 stat;
 
 	timeout += jiffies;
@@ -330,6 +331,8 @@ int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
 			return 0;
 	} while (time_before(jiffies, timeout));
 
+	printk(KERN_ERR "%s: timeout in %s\n", drive->name, __func__);
+
 	return 1;	/* drive timed-out */
 }
 
@@ -420,7 +423,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
 			tp_ops->dev_select(drive);
 			msleep(50);
 			tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
-			(void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
+			(void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0);
 			rc = ide_dev_read_id(drive, cmd, id);
 		}
 
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index 3ff7231..028de26 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -67,6 +67,7 @@ static struct via_isa_bridge {
 	u8 udma_mask;
 	u8 flags;
 } via_isa_bridges[] = {
+	{ "vx855",	PCI_DEVICE_ID_VIA_VX855,    0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
 	{ "vx800",	PCI_DEVICE_ID_VIA_VX800,    0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
 	{ "cx700",	PCI_DEVICE_ID_VIA_CX700,    0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
 	{ "vt8237s",	PCI_DEVICE_ID_VIA_8237S,    0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST },
@@ -474,6 +475,7 @@ static const struct pci_device_id via_pci_tbl[] = {
 	{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1),  0 },
 	{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1),  0 },
 	{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 },
+	{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_VX855_IDE), 0 },
 	{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410),      1 },
 	{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 },
 	{ 0, },
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ff65fff..9fed365 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1109,7 +1109,7 @@ void ide_fix_driveid(u16 *);
 
 extern void ide_fixstring(u8 *, const int, const int);
 
-int ide_busy_sleep(ide_hwif_t *, unsigned long, int);
+int ide_busy_sleep(ide_drive_t *, unsigned long, int);
 
 int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
 
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 06ba90c..0f71812 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1406,7 +1406,7 @@
 #define PCI_DEVICE_ID_VIA_82C598_1	0x8598
 #define PCI_DEVICE_ID_VIA_838X_1	0xB188
 #define PCI_DEVICE_ID_VIA_83_87XX_1	0xB198
-#define PCI_DEVICE_ID_VIA_C409_IDE	0XC409
+#define PCI_DEVICE_ID_VIA_VX855_IDE	0xC409
 #define PCI_DEVICE_ID_VIA_ANON		0xFFFF
 
 #define PCI_VENDOR_ID_SIEMENS           0x110A

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-05-16 19:22 ` Borislav Petkov
@ 2009-05-16 19:33   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-16 19:33 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Saturday 16 May 2009 21:22:19 Borislav Petkov wrote:
> Hi,
> 
> On Sat, May 16, 2009 at 09:16:23PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > 
> > ide-tape oops fix, icside regression fix and new piix cable quirk
> > 
> > Linus, please pull from 'for-linus' branch of:
> > 
> > master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus
> > 
> > to receive the following updates:
> > 
> >  drivers/ide/icside.c   |    2 +-
> >  drivers/ide/ide-tape.c |    6 ------
> >  drivers/ide/piix.c     |    1 +
> >  3 files changed, 2 insertions(+), 7 deletions(-)
> > 
> > 
> > Alan Cox (1):
> >       piix: The Sony TZ90 needs the cable type hardcoding
> > 
> > Sergei Shtylyov (1):
> >       icside: register second channel of version 6 PCB
> > 
> > Tejun Heo (1):
> >       ide-tape: remove back-to-back REQUEST_SENSE detection
> 
> I assume it is too late to add another ide-tape debug build fix I told
> you about earlier today:

No its too early -- this patch doesn't even apply to Linus' tree.

[ It applies on top of all 2.6.31 block+ide changes... ]

> --
> From: Mark de Wever <koraq@xs4all.nl>
> Date: Sat, 16 May 2009 18:17:30 +0200
> Subject: [PATCH] ide-tape: fix debug call
> 
> This error only occurs when IDETAPE_DEBUG_LOG is enabled.
> 
> Signed-off-by: Mark de Wever <koraq@xs4all.nl>
> ---
>  drivers/ide/ide-tape.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> index 9ca2665..521a5f5 100644
> --- a/drivers/ide/ide-tape.c
> +++ b/drivers/ide/ide-tape.c
> @@ -592,7 +592,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
>  	struct ide_cmd cmd;
>  	u8 stat;
>  
> -	debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n"
> +	debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n",
>  		  (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq));
>  
>  	if (!(blk_special_request(rq) || blk_sense_request(rq))) {
> -- 
> 1.6.3
> 
> If so, you could still queue it for 30-rc7 if there would be one...
> 
> Thanks.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-05-16 19:16 Bartlomiej Zolnierkiewicz
@ 2009-05-16 19:22 ` Borislav Petkov
  2009-05-16 19:33   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Borislav Petkov @ 2009-05-16 19:22 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

Hi,

On Sat, May 16, 2009 at 09:16:23PM +0200, Bartlomiej Zolnierkiewicz wrote:
> 
> ide-tape oops fix, icside regression fix and new piix cable quirk
> 
> Linus, please pull from 'for-linus' branch of:
> 
> master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus
> 
> to receive the following updates:
> 
>  drivers/ide/icside.c   |    2 +-
>  drivers/ide/ide-tape.c |    6 ------
>  drivers/ide/piix.c     |    1 +
>  3 files changed, 2 insertions(+), 7 deletions(-)
> 
> 
> Alan Cox (1):
>       piix: The Sony TZ90 needs the cable type hardcoding
> 
> Sergei Shtylyov (1):
>       icside: register second channel of version 6 PCB
> 
> Tejun Heo (1):
>       ide-tape: remove back-to-back REQUEST_SENSE detection

I assume it is too late to add another ide-tape debug build fix I told
you about earlier today:

--
From: Mark de Wever <koraq@xs4all.nl>
Date: Sat, 16 May 2009 18:17:30 +0200
Subject: [PATCH] ide-tape: fix debug call

This error only occurs when IDETAPE_DEBUG_LOG is enabled.

Signed-off-by: Mark de Wever <koraq@xs4all.nl>
---
 drivers/ide/ide-tape.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 9ca2665..521a5f5 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -592,7 +592,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
 	struct ide_cmd cmd;
 	u8 stat;
 
-	debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n"
+	debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n",
 		  (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq));
 
 	if (!(blk_special_request(rq) || blk_sense_request(rq))) {
-- 
1.6.3

If so, you could still queue it for 30-rc7 if there would be one...

Thanks.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-05-16 19:16 Bartlomiej Zolnierkiewicz
  2009-05-16 19:22 ` Borislav Petkov
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-16 19:16 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


ide-tape oops fix, icside regression fix and new piix cable quirk

Linus, please pull from 'for-linus' branch of:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus

to receive the following updates:

 drivers/ide/icside.c   |    2 +-
 drivers/ide/ide-tape.c |    6 ------
 drivers/ide/piix.c     |    1 +
 3 files changed, 2 insertions(+), 7 deletions(-)


Alan Cox (1):
      piix: The Sony TZ90 needs the cable type hardcoding

Sergei Shtylyov (1):
      icside: register second channel of version 6 PCB

Tejun Heo (1):
      ide-tape: remove back-to-back REQUEST_SENSE detection


diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 4e16ce6..36da913 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -466,7 +466,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 	struct ide_host *host;
 	unsigned int sel = 0;
 	int ret;
-	hw_regs_t hw[2], *hws[] = { &hw[0], NULL, NULL, NULL };
+	hw_regs_t hw[2], *hws[] = { &hw[0], &hw[1], NULL, NULL };
 	struct ide_port_info d = icside_v6_port_info;
 
 	ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index cb942a9..3a53e08 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -614,12 +614,6 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
 {
 	idetape_tape_t *tape = drive->driver_data;
 
-	if (drive->pc->c[0] == REQUEST_SENSE &&
-	    pc->c[0] == REQUEST_SENSE) {
-		printk(KERN_ERR "ide-tape: possible ide-tape.c bug - "
-			"Two request sense in serial were issued\n");
-	}
-
 	if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE)
 		drive->failed_pc = pc;
 
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
index 2aa6999..69860de 100644
--- a/drivers/ide/piix.c
+++ b/drivers/ide/piix.c
@@ -263,6 +263,7 @@ static const struct ich_laptop ich_laptop[] = {
 	{ 0x24CA, 0x1025, 0x003d },	/* ICH4 on ACER TM290 */
 	{ 0x266F, 0x1025, 0x0066 },	/* ICH6 on ACER Aspire 1694WLMi */
 	{ 0x2653, 0x1043, 0x82D8 },	/* ICH6M on Asus Eee 701 */
+	{ 0x27df, 0x104d, 0x900e },	/* ICH7 on Sony TZ-90 */
 	/* end marker */
 	{ 0, }
 };

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 22:02         ` Ray Lee
  2009-04-22 22:51           ` Bartlomiej Zolnierkiewicz
@ 2009-04-22 22:58           ` Bartlomiej Zolnierkiewicz
  1 sibling, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-22 22:58 UTC (permalink / raw)
  To: Ray Lee
  Cc: Joe Perches, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Thursday 23 April 2009 00:02:38 Ray Lee wrote:
> On Wed, Apr 22, 2009 at 2:41 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
> > On Wednesday 22 April 2009 21:55:03 Joe Perches wrote:
> >> On Wed, 2009-04-22 at 21:43 +0200, Bartlomiej Zolnierkiewicz wrote:
> >> > IMO we should just remove extra commas and add some whitespaces.
> >>
> >> Your choice.
> >> Ignore, reject, accept, improve, fine by me.
> >>
> >> > I have also more general (process oriented) comment:
> >> >
> >> > All patches have been posted to linux-kernel or linux-ide for review before
> >> > and it is _much_ more efficient to raise issues (including CodingStyle ones)
> >> > during "review phase" instead of during "push to Linus" phase.
> >>
> >> Maybe for you, but I'm an intermittent
> >> and random reader.
> >
> > For everybody involved in the process -- this includes you.
> >
> > I'm not the original author of many patches so I simply cannot be
> > correcting every single issue because:
> >
> > a) it is physically impossible
> >
> > b) it doesn't really educate people
> 
> His point is that you can queue a follow-up patch to remove the
> ugliness. Just because it didn't get caught until the push stage
> doesn't mean the code needs to stay set in stone for the rest of
> eternity.

I get his point and of course patches are welcomed.

However my point is that it is still suboptimal way to address
the issue in the long-term and from my perspective the long-term
is what really matters.

Thanks,
Bart

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 22:02         ` Ray Lee
@ 2009-04-22 22:51           ` Bartlomiej Zolnierkiewicz
  2009-04-22 22:58           ` Bartlomiej Zolnierkiewicz
  1 sibling, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-22 22:51 UTC (permalink / raw)
  To: Ray Lee
  Cc: Joe Perches, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Thursday 23 April 2009 00:02:38 Ray Lee wrote:
> On Wed, Apr 22, 2009 at 2:41 PM, Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com> wrote:
> > On Wednesday 22 April 2009 21:55:03 Joe Perches wrote:
> >> On Wed, 2009-04-22 at 21:43 +0200, Bartlomiej Zolnierkiewicz wrote:
> >> > IMO we should just remove extra commas and add some whitespaces.
> >>
> >> Your choice.
> >> Ignore, reject, accept, improve, fine by me.
> >>
> >> > I have also more general (process oriented) comment:
> >> >
> >> > All patches have been posted to linux-kernel or linux-ide for review before
> >> > and it is _much_ more efficient to raise issues (including CodingStyle ones)
> >> > during "review phase" instead of during "push to Linus" phase.
> >>
> >> Maybe for you, but I'm an intermittent
> >> and random reader.
> >
> > For everybody involved in the process -- this includes you.
> >
> > I'm not the original author of many patches so I simply cannot be
> > correcting every single issue because:
> >
> > a) it is physically impossible
> >
> > b) it doesn't really educate people
> 
> His point is that you can queue a follow-up patch to remove the
> ugliness. Just because it didn't get caught until the push stage
> doesn't mean the code needs to stay set in stone for the rest of
> eternity.

I get his point and of course patches are welcomed.

However my point is that it is still suboptimal way to address
the issue in the long-term and from my perspective the long-term
is what really matters.

Thanks,
Bart

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 21:41       ` Bartlomiej Zolnierkiewicz
@ 2009-04-22 22:02         ` Ray Lee
  2009-04-22 22:51           ` Bartlomiej Zolnierkiewicz
  2009-04-22 22:58           ` Bartlomiej Zolnierkiewicz
  0 siblings, 2 replies; 58+ messages in thread
From: Ray Lee @ 2009-04-22 22:02 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Joe Perches, Linus Torvalds, Andrew Morton, Stephen Rothwell,
	linux-ide, linux-kernel

On Wed, Apr 22, 2009 at 2:41 PM, Bartlomiej Zolnierkiewicz
<bzolnier@gmail.com> wrote:
> On Wednesday 22 April 2009 21:55:03 Joe Perches wrote:
>> On Wed, 2009-04-22 at 21:43 +0200, Bartlomiej Zolnierkiewicz wrote:
>> > IMO we should just remove extra commas and add some whitespaces.
>>
>> Your choice.
>> Ignore, reject, accept, improve, fine by me.
>>
>> > I have also more general (process oriented) comment:
>> >
>> > All patches have been posted to linux-kernel or linux-ide for review before
>> > and it is _much_ more efficient to raise issues (including CodingStyle ones)
>> > during "review phase" instead of during "push to Linus" phase.
>>
>> Maybe for you, but I'm an intermittent
>> and random reader.
>
> For everybody involved in the process -- this includes you.
>
> I'm not the original author of many patches so I simply cannot be
> correcting every single issue because:
>
> a) it is physically impossible
>
> b) it doesn't really educate people

His point is that you can queue a follow-up patch to remove the
ugliness. Just because it didn't get caught until the push stage
doesn't mean the code needs to stay set in stone for the rest of
eternity.

What most maintainers do at this stage is say "Great idea! Send me a
patch." Perhaps you could try that tack instead.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 19:55     ` Joe Perches
@ 2009-04-22 21:41       ` Bartlomiej Zolnierkiewicz
  2009-04-22 22:02         ` Ray Lee
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-22 21:41 UTC (permalink / raw)
  To: Joe Perches
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Wednesday 22 April 2009 21:55:03 Joe Perches wrote:
> On Wed, 2009-04-22 at 21:43 +0200, Bartlomiej Zolnierkiewicz wrote:
> > IMO we should just remove extra commas and add some whitespaces.
> 
> Your choice.
> Ignore, reject, accept, improve, fine by me.
> 
> > I have also more general (process oriented) comment:
> > 
> > All patches have been posted to linux-kernel or linux-ide for review before
> > and it is _much_ more efficient to raise issues (including CodingStyle ones)
> > during "review phase" instead of during "push to Linus" phase.
> 
> Maybe for you, but I'm an intermittent
> and random reader.

For everybody involved in the process -- this includes you.

I'm not the original author of many patches so I simply cannot be
correcting every single issue because:

a) it is physically impossible

b) it doesn't really educate people

Thanks,
Bart

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 19:43   ` Bartlomiej Zolnierkiewicz
@ 2009-04-22 19:55     ` Joe Perches
  2009-04-22 21:41       ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Joe Perches @ 2009-04-22 19:55 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Wed, 2009-04-22 at 21:43 +0200, Bartlomiej Zolnierkiewicz wrote:
> IMO we should just remove extra commas and add some whitespaces.

Your choice.
Ignore, reject, accept, improve, fine by me.

> I have also more general (process oriented) comment:
> 
> All patches have been posted to linux-kernel or linux-ide for review before
> and it is _much_ more efficient to raise issues (including CodingStyle ones)
> during "review phase" instead of during "push to Linus" phase.

Maybe for you, but I'm an intermittent
and random reader.

If you accept an idea at all, queue it
up at your convenience.

cheers, Joe


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 19:06 ` Joe Perches
  2009-04-22 19:22   ` Sam Ravnborg
@ 2009-04-22 19:43   ` Bartlomiej Zolnierkiewicz
  2009-04-22 19:55     ` Joe Perches
  1 sibling, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-22 19:43 UTC (permalink / raw)
  To: Joe Perches
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Wednesday 22 April 2009 21:06:47 Joe Perches wrote:
> On Wed, 2009-04-22 at 20:48 +0200, Bartlomiej Zolnierkiewicz wrote:
> > diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> > index 3aec19d..3d4e099 100644
> > --- a/drivers/ide/ide-cd.c
> > +++ b/drivers/ide/ide-cd.c
> > @@ -609,7 +609,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
> >  	struct request *rq = hwif->rq;
> >  	ide_expiry_t *expiry = NULL;
> >  	int dma_error = 0, dma, thislen, uptodate = 0;
> > -	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
> > +	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors;
> >  	int sense = blk_sense_request(rq);
> >  	unsigned int timeout;
> >  	u16 len;
> 
> I think ide is the only subsystem to use the
> initialization style of "?:," with additional
> declarations.

Well, nothing wrong with it per se.

> Would it be better to use a more standard style?
> 
> maybe:
> 	int dma_error = 0, dma, thislen, uptodate = 0, rc = 0, nsectors;
> 	int write = ((rq_data_dir(rq) == WRITE) ? 1 : 0;

Personally I would prefer:

	int write = !!(rq_data_dir(rq) == WRITE);

However the old code is also fine with me.

> > diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
> > index c7acca0..d1513b4 100644
> > --- a/drivers/ide/palm_bk3710.c
> > +++ b/drivers/ide/palm_bk3710.c
> []
> > @@ -75,13 +67,19 @@ struct palm_bk3710_udmatiming {
> >  
> >  static unsigned ideclk_period; /* in nanoseconds */
> >  
> > +struct palm_bk3710_udmatiming {
> > +	unsigned int rptime;	/* tRP -- Ready to pause time (nsec) */
> > +	unsigned int cycletime;	/* tCYCTYP2/2 -- avg Cycle Time (nsec) */
> > +				/* tENV is always a minimum of 20 nsec */
> > +};
> > +
> >  static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
> > -	{160, 240},		/* UDMA Mode 0 */
> > -	{125, 160},		/* UDMA Mode 1 */
> > -	{100, 120},		/* UDMA Mode 2 */
> > -	{100, 90},		/* UDMA Mode 3 */
> > -	{100, 60},		/* UDMA Mode 4 */
> > -	{85,  40},		/* UDMA Mode 5 */
> > +	{160, 240 / 2,},	/* UDMA Mode 0 */
> > +	{125, 160 / 2,},	/* UDMA Mode 1 */
> > +	{100, 120 / 2,},	/* UDMA Mode 2 */
> > +	{100, 90 / 2,},		/* UDMA Mode 3 */
> > +	{100, 60 / 2,},		/* UDMA Mode 4 */
> > +	{85,  40 / 2,},		/* UDMA Mode 5 */
> >  };
> >  
> >  static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,
> 
> Odd looking commas.
> 
> Maybe:
> 
> 	{.rptime = 160, .cycletime = 240 / 2 },	/* UDMA Mode 0 */
> etc.

I really don't consider this an improvement from readability perspective
and I also don't like the added code duplication...

IMO we should just remove extra commas and add some whitespaces.

I have also more general (process oriented) comment:

All patches have been posted to linux-kernel or linux-ide for review before
and it is _much_ more efficient to raise issues (including CodingStyle ones)
during "review phase" instead of during "push to Linus" phase.

Thanks,
Bart

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 19:06 ` Joe Perches
@ 2009-04-22 19:22   ` Sam Ravnborg
  2009-04-22 19:43   ` Bartlomiej Zolnierkiewicz
  1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2009-04-22 19:22 UTC (permalink / raw)
  To: Joe Perches
  Cc: Bartlomiej Zolnierkiewicz, Linus Torvalds, Andrew Morton,
	Stephen Rothwell, linux-ide, linux-kernel

On Wed, Apr 22, 2009 at 12:06:47PM -0700, Joe Perches wrote:
> On Wed, 2009-04-22 at 20:48 +0200, Bartlomiej Zolnierkiewicz wrote:
> > diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> > index 3aec19d..3d4e099 100644
> > --- a/drivers/ide/ide-cd.c
> > +++ b/drivers/ide/ide-cd.c
> > @@ -609,7 +609,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
> >  	struct request *rq = hwif->rq;
> >  	ide_expiry_t *expiry = NULL;
> >  	int dma_error = 0, dma, thislen, uptodate = 0;
> > -	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
> > +	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors;
> >  	int sense = blk_sense_request(rq);
> >  	unsigned int timeout;
> >  	u16 len;
> 
> I think ide is the only subsystem to use the
> initialization style of "?:," with additional
> declarations.
> 
> Would it be better to use a more standard style?
> 
> maybe:
> 	int dma_error = 0, dma, thislen, uptodate = 0, rc = 0, nsectors;
> 	int write = ((rq_data_dir(rq) == WRITE) ? 1 : 0;

Better to move assignment after variable definition.

	Sam

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-04-22 18:48 Bartlomiej Zolnierkiewicz
@ 2009-04-22 19:06 ` Joe Perches
  2009-04-22 19:22   ` Sam Ravnborg
  2009-04-22 19:43   ` Bartlomiej Zolnierkiewicz
  0 siblings, 2 replies; 58+ messages in thread
From: Joe Perches @ 2009-04-22 19:06 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Linus Torvalds, Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Wed, 2009-04-22 at 20:48 +0200, Bartlomiej Zolnierkiewicz wrote:
> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> index 3aec19d..3d4e099 100644
> --- a/drivers/ide/ide-cd.c
> +++ b/drivers/ide/ide-cd.c
> @@ -609,7 +609,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
>  	struct request *rq = hwif->rq;
>  	ide_expiry_t *expiry = NULL;
>  	int dma_error = 0, dma, thislen, uptodate = 0;
> -	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
> +	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors;
>  	int sense = blk_sense_request(rq);
>  	unsigned int timeout;
>  	u16 len;

I think ide is the only subsystem to use the
initialization style of "?:," with additional
declarations.

Would it be better to use a more standard style?

maybe:
	int dma_error = 0, dma, thislen, uptodate = 0, rc = 0, nsectors;
	int write = ((rq_data_dir(rq) == WRITE) ? 1 : 0;

> diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
> index c7acca0..d1513b4 100644
> --- a/drivers/ide/palm_bk3710.c
> +++ b/drivers/ide/palm_bk3710.c
[]
> @@ -75,13 +67,19 @@ struct palm_bk3710_udmatiming {
>  
>  static unsigned ideclk_period; /* in nanoseconds */
>  
> +struct palm_bk3710_udmatiming {
> +	unsigned int rptime;	/* tRP -- Ready to pause time (nsec) */
> +	unsigned int cycletime;	/* tCYCTYP2/2 -- avg Cycle Time (nsec) */
> +				/* tENV is always a minimum of 20 nsec */
> +};
> +
>  static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
> -	{160, 240},		/* UDMA Mode 0 */
> -	{125, 160},		/* UDMA Mode 1 */
> -	{100, 120},		/* UDMA Mode 2 */
> -	{100, 90},		/* UDMA Mode 3 */
> -	{100, 60},		/* UDMA Mode 4 */
> -	{85,  40},		/* UDMA Mode 5 */
> +	{160, 240 / 2,},	/* UDMA Mode 0 */
> +	{125, 160 / 2,},	/* UDMA Mode 1 */
> +	{100, 120 / 2,},	/* UDMA Mode 2 */
> +	{100, 90 / 2,},		/* UDMA Mode 3 */
> +	{100, 60 / 2,},		/* UDMA Mode 4 */
> +	{85,  40 / 2,},		/* UDMA Mode 5 */
>  };
>  
>  static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,

Odd looking commas.

Maybe:

	{.rptime = 160, .cycletime = 240 / 2 },	/* UDMA Mode 0 */
etc.


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-04-22 18:48 Bartlomiej Zolnierkiewicz
  2009-04-22 19:06 ` Joe Perches
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-22 18:48 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


[ mediabay.c changes are limited to <linux/ide.h> include removal ]

Linus, please pull from 'for-linus' branch of:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus

to receive the following updates:

 drivers/ide/ide-cd.c         |    2 +-
 drivers/ide/ide-gd.c         |   17 ++++++++++++++++-
 drivers/ide/palm_bk3710.c    |   26 ++++++++++++--------------
 drivers/macintosh/mediabay.c |    1 -
 4 files changed, 29 insertions(+), 17 deletions(-)


Bartlomiej Zolnierkiewicz (1):
      mediabay: fix build for CONFIG_BLOCK=n

Bruno Prémont (1):
      ide: Stop disks on reboot for laptop which cuts power

David Brownell (1):
      palm_bk3710: UDMA performance fix

Helge Deller (1):
      ide-cd: fix kernel crash on hppa regression


diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3aec19d..3d4e099 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -609,7 +609,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 	struct request *rq = hwif->rq;
 	ide_expiry_t *expiry = NULL;
 	int dma_error = 0, dma, thislen, uptodate = 0;
-	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
+	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors;
 	int sense = blk_sense_request(rq);
 	unsigned int timeout;
 	u16 len;
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 1aebdf1..4b6b71e 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -7,6 +7,7 @@
 #include <linux/mutex.h>
 #include <linux/ide.h>
 #include <linux/hdreg.h>
+#include <linux/dmi.h>
 
 #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
 #define IDE_DISK_MINORS		(1 << PARTN_BITS)
@@ -99,6 +100,19 @@ static void ide_gd_resume(ide_drive_t *drive)
 		(void)drive->disk_ops->get_capacity(drive);
 }
 
+static const struct dmi_system_id ide_coldreboot_table[] = {
+	{
+		/* Acer TravelMate 66x cuts power during reboot */
+		.ident   = "Acer TravelMate 660",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
+		},
+	},
+
+	{ }	/* terminate list */
+};
+
 static void ide_gd_shutdown(ide_drive_t *drive)
 {
 #ifdef	CONFIG_ALPHA
@@ -115,7 +129,8 @@ static void ide_gd_shutdown(ide_drive_t *drive)
 	   the disk to expire its write cache. */
 	if (system_state != SYSTEM_POWER_OFF) {
 #else
-	if (system_state == SYSTEM_RESTART) {
+	if (system_state == SYSTEM_RESTART &&
+		!dmi_check_system(ide_coldreboot_table)) {
 #endif
 		drive->disk_ops->flush(drive);
 		return;
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
index c7acca0..d1513b4 100644
--- a/drivers/ide/palm_bk3710.c
+++ b/drivers/ide/palm_bk3710.c
@@ -39,14 +39,6 @@
 /* Primary Control Offset */
 #define IDE_PALM_ATA_PRI_CTL_OFFSET 0x3F6
 
-/*
- * PalmChip 3710 IDE Controller UDMA timing structure Definition
- */
-struct palm_bk3710_udmatiming {
-	unsigned int rptime;	/* Ready to pause time  */
-	unsigned int cycletime;	/* Cycle Time           */
-};
-
 #define BK3710_BMICP		0x00
 #define BK3710_BMISP		0x02
 #define BK3710_BMIDTP		0x04
@@ -75,13 +67,19 @@ struct palm_bk3710_udmatiming {
 
 static unsigned ideclk_period; /* in nanoseconds */
 
+struct palm_bk3710_udmatiming {
+	unsigned int rptime;	/* tRP -- Ready to pause time (nsec) */
+	unsigned int cycletime;	/* tCYCTYP2/2 -- avg Cycle Time (nsec) */
+				/* tENV is always a minimum of 20 nsec */
+};
+
 static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
-	{160, 240},		/* UDMA Mode 0 */
-	{125, 160},		/* UDMA Mode 1 */
-	{100, 120},		/* UDMA Mode 2 */
-	{100, 90},		/* UDMA Mode 3 */
-	{100, 60},		/* UDMA Mode 4 */
-	{85,  40},		/* UDMA Mode 5 */
+	{160, 240 / 2,},	/* UDMA Mode 0 */
+	{125, 160 / 2,},	/* UDMA Mode 1 */
+	{100, 120 / 2,},	/* UDMA Mode 2 */
+	{100, 90 / 2,},		/* UDMA Mode 3 */
+	{100, 60 / 2,},		/* UDMA Mode 4 */
+	{85,  40 / 2,},		/* UDMA Mode 5 */
 };
 
 static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index d7e46d3..eca55ef 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -18,7 +18,6 @@
 #include <linux/timer.h>
 #include <linux/stddef.h>
 #include <linux/init.h>
-#include <linux/ide.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
 #include <asm/prom.h>

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-04-18 16:09 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-18 16:09 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Linus, please pull from 'for-linus' branch of:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git for-linus

to receive the following updates:

 drivers/ide/cs5536.c |    1 +
 drivers/ide/hpt366.c |   14 ++++++++------
 drivers/ide/ide-io.c |   11 +++++++----
 drivers/ide/pmac.c   |    2 +-
 4 files changed, 17 insertions(+), 11 deletions(-)


Bartlomiej Zolnierkiewicz (1):
      ide: fix barriers support

Jack Stone (1):
      ide: Remove void casts

Sergei Shtylyov (3):
      hpt366: fix HPT370 DMA timeouts
      hpt366: use ATA_DMA_* constants
      cs5536: define dma_sff_read_status() method


diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c
index 353a35b..0332a95 100644
--- a/drivers/ide/cs5536.c
+++ b/drivers/ide/cs5536.c
@@ -236,6 +236,7 @@ static const struct ide_dma_ops cs5536_dma_ops = {
 	.dma_test_irq		= ide_dma_test_irq,
 	.dma_lost_irq		= ide_dma_lost_irq,
 	.dma_timer_expiry	= ide_dma_sff_timer_expiry,
+	.dma_sff_read_status	= ide_dma_sff_read_status,
 };
 
 static const struct ide_port_info cs5536_info = {
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index a0eb87f..0feb66c 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -3,7 +3,7 @@
  * Portions Copyright (C) 2001	        Sun Microsystems, Inc.
  * Portions Copyright (C) 2003		Red Hat Inc
  * Portions Copyright (C) 2007		Bartlomiej Zolnierkiewicz
- * Portions Copyright (C) 2005-2008	MontaVista Software, Inc.
+ * Portions Copyright (C) 2005-2009	MontaVista Software, Inc.
  *
  * Thanks to HighPoint Technologies for their assistance, and hardware.
  * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
@@ -114,6 +114,8 @@
  *   the register setting lists into the table indexed by the clock selected
  * - set the correct hwif->ultra_mask for each individual chip
  * - add Ultra and MW DMA mode filtering for the HPT37[24] based SATA cards
+ * - stop resetting HPT370's state machine before each DMA transfer as that has
+ *   caused more harm than good
  *	Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com>
  */
 
@@ -133,7 +135,7 @@
 #define DRV_NAME "hpt366"
 
 /* various tuning parameters */
-#define HPT_RESET_STATE_ENGINE
+#undef	HPT_RESET_STATE_ENGINE
 #undef	HPT_DELAY_INTERRUPT
 
 static const char *quirk_drives[] = {
@@ -808,7 +810,7 @@ static void hpt370_irq_timeout(ide_drive_t *drive)
 	/* get DMA command mode */
 	dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
 	/* stop DMA */
-	outb(dma_cmd & ~0x1, hwif->dma_base + ATA_DMA_CMD);
+	outb(dma_cmd & ~ATA_DMA_START, hwif->dma_base + ATA_DMA_CMD);
 	hpt370_clear_engine(drive);
 }
 
@@ -825,11 +827,11 @@ static int hpt370_dma_end(ide_drive_t *drive)
 	ide_hwif_t *hwif	= drive->hwif;
 	u8  dma_stat		= inb(hwif->dma_base + ATA_DMA_STATUS);
 
-	if (dma_stat & 0x01) {
+	if (dma_stat & ATA_DMA_ACTIVE) {
 		/* wait a little */
 		udelay(20);
 		dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
-		if (dma_stat & 0x01)
+		if (dma_stat & ATA_DMA_ACTIVE)
 			hpt370_irq_timeout(drive);
 	}
 	return ide_dma_end(drive);
@@ -851,7 +853,7 @@ static int hpt374_dma_test_irq(ide_drive_t *drive)
 
 	dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
 	/* return 1 if INTR asserted */
-	if (dma_stat & 4)
+	if (dma_stat & ATA_DMA_INTR)
 		return 1;
 
 	return 0;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 2ae02b8..35dc38d 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -102,11 +102,14 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
 			drive->dev_flags |= IDE_DFLAG_PARKED;
 	}
 
-	if (rq && rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
-		memcpy(rq->special, cmd, sizeof(*cmd));
+	if (rq && rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
+		struct ide_cmd *orig_cmd = rq->special;
 
-	if (cmd->tf_flags & IDE_TFLAG_DYN)
-		kfree(cmd);
+		if (cmd->tf_flags & IDE_TFLAG_DYN)
+			kfree(orig_cmd);
+		else
+			memcpy(orig_cmd, cmd, sizeof(*cmd));
+	}
 }
 
 /* obsolete, blk_rq_bytes() should be used instead */
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 052b9bf..f76e4e6 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1682,7 +1682,7 @@ static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,
 	 * The +2 is +1 for the stop command and +1 to allow for
 	 * aligning the start address to a multiple of 16 bytes.
 	 */
-	pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
+	pmif->dma_table_cpu = pci_alloc_consistent(
 		dev,
 		(MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
 		&hwif->dmatable_dma);

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-03-13 20:49 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-03-13 20:49 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

ide-floppy regression fix (from Borislav Petkov) and an important
bug fix for DMA mapping code (from FUJITA Tomonori).


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 drivers/ide/ide-atapi.c  |   12 ++++++++++++
 drivers/ide/ide-dma.c    |   12 +++++++++---
 drivers/ide/ide-floppy.c |    6 ++++--
 include/linux/ide.h      |    1 +
 4 files changed, 26 insertions(+), 5 deletions(-)


Borislav Petkov (1):
      ide-floppy: do not map dataless cmds to an sg

FUJITA Tomonori (1):
      ide: save the returned value of dma_map_sg


diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index e96c012..e9d042d 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -140,6 +140,12 @@ static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
 	rq->cmd_flags |= REQ_PREEMPT;
 	rq->buffer = (char *)pc;
 	rq->rq_disk = disk;
+
+	if (pc->req_xfer) {
+		rq->data = pc->buf;
+		rq->data_len = pc->req_xfer;
+	}
+
 	memcpy(rq->cmd, pc->c, 12);
 	if (drive->media == ide_tape)
 		rq->cmd[13] = REQ_IDETAPE_PC1;
@@ -159,6 +165,12 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
 	rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
 	rq->cmd_type = REQ_TYPE_SPECIAL;
 	rq->buffer = (char *)pc;
+
+	if (pc->req_xfer) {
+		rq->data = pc->buf;
+		rq->data_len = pc->req_xfer;
+	}
+
 	memcpy(rq->cmd, pc->c, 12);
 	if (drive->media == ide_tape)
 		rq->cmd[13] = REQ_IDETAPE_PC1;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 72ebab0..059c90b 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -128,6 +128,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	struct scatterlist *sg = hwif->sg_table;
+	int i;
 
 	ide_map_sg(drive, rq);
 
@@ -136,8 +137,13 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
 	else
 		hwif->sg_dma_direction = DMA_TO_DEVICE;
 
-	return dma_map_sg(hwif->dev, sg, hwif->sg_nents,
-			  hwif->sg_dma_direction);
+	i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
+	if (i) {
+		hwif->orig_sg_nents = hwif->sg_nents;
+		hwif->sg_nents = i;
+	}
+
+	return i;
 }
 EXPORT_SYMBOL_GPL(ide_build_sglist);
 
@@ -156,7 +162,7 @@ void ide_destroy_dmatable(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = drive->hwif;
 
-	dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents,
+	dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->orig_sg_nents,
 		     hwif->sg_dma_direction);
 }
 EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 3eab1c6..317ec62 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -327,8 +327,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
 		return ide_stopped;
 	}
 
-	ide_init_sg_cmd(drive, rq);
-	ide_map_sg(drive, rq);
+	if (blk_fs_request(rq) || pc->req_xfer) {
+		ide_init_sg_cmd(drive, rq);
+		ide_map_sg(drive, rq);
+	}
 
 	pc->sg = hwif->sg_table;
 	pc->sg_cnt = hwif->sg_nents;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index e0cedfe..25087ae 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -797,6 +797,7 @@ typedef struct hwif_s {
 	struct scatterlist *sg_table;
 	int sg_max_nents;		/* Maximum number of entries in it */
 	int sg_nents;			/* Current number of entries in it */
+	int orig_sg_nents;
 	int sg_dma_direction;		/* dma transfer direction */
 
 	/* data phase of the active command (currently only valid for PIO/DMA) */

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [git pull] IDE fixes
  2009-03-05 15:30 Bartlomiej Zolnierkiewicz
@ 2009-03-05 16:27 ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-03-05 16:27 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

On Thursday 05 March 2009, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi,
> 
> Two bug fixes (for odd-length ATAPI PIO transfers from Sergei Shtylyov
> and for insanely long DMA timeouts from Roel Kluin), some sparse fixes
> (from Hannes Eder) and a new driver for AT91 Static Memory Controller
> with Compact Flash True IDE Mode logic (from Stanislaw Gruszka, arch
> specific part has been acked by a platform maintainer).

Now with <linux/ata.h> change (add CFA identify words for the future use)
from Sergei & Jeff.

> Linus, please pull from:
> 
> master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/
> 
> to receive the following updates:

 arch/arm/mach-at91/at91sam9263_devices.c |  105 +++++++
 arch/arm/mach-at91/include/mach/board.h  |    3 +
 drivers/ide/Kconfig                      |    5 +
 drivers/ide/Makefile                     |    1 +
 drivers/ide/at91_ide.c                   |  467 ++++++++++++++++++++++++++++++
 drivers/ide/ide-disk_proc.c              |    2 +-
 drivers/ide/ide-floppy_proc.c            |    2 +-
 drivers/ide/ide-io.c                     |    3 +-
 drivers/ide/ide-iops.c                   |    2 +
 drivers/ide/ide-probe.c                  |    7 +-
 drivers/ide/ide-proc.c                   |    2 +-
 drivers/ide/ide-tape.c                   |    2 +-
 include/linux/ata.h                      |    2 +
 include/linux/hdreg.h                    |    1 -
 include/linux/ide.h                      |    1 +
 15 files changed, 598 insertions(+), 7 deletions(-)
 create mode 100644 drivers/ide/at91_ide.c


Bartlomiej Zolnierkiewicz (1):
      remove stale comment from <linux/hdreg.h>

Hannes Eder (1):
      ide: NULL noise: drivers/ide/ide-*.c

Roel Kluin (1):
      ide: expiry() returns int, negative expiry() return values won't be noticed

Sergei Shtylyov (2):
      ide-iops: fix odd-length ATAPI PIO transfers
      ata: add CFA specific identify data words

Stanislaw Gruszka (3):
      ide: allow to wrap interrupt handler
      ide: add at91_ide driver
      AT91: initialize Compact Flash on AT91SAM9263 cpu

[...]

diff --git a/include/linux/ata.h b/include/linux/ata.h
index 08a86d5..9a061ac 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -89,6 +89,8 @@ enum {
 	ATA_ID_DLF		= 128,
 	ATA_ID_CSFO		= 129,
 	ATA_ID_CFA_POWER	= 160,
+	ATA_ID_CFA_KEY_MGMT	= 162,
+	ATA_ID_CFA_MODES	= 163,
 	ATA_ID_ROT_SPEED	= 217,
 	ATA_ID_PIO4		= (1 << 1),
 

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-03-05 15:30 Bartlomiej Zolnierkiewicz
  2009-03-05 16:27 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-03-05 15:30 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Two bug fixes (for odd-length ATAPI PIO transfers from Sergei Shtylyov
and for insanely long DMA timeouts from Roel Kluin), some sparse fixes
(from Hannes Eder) and a new driver for AT91 Static Memory Controller
with Compact Flash True IDE Mode logic (from Stanislaw Gruszka, arch
specific part has been acked by a platform maintainer).

Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 arch/arm/mach-at91/at91sam9263_devices.c |  105 +++++++
 arch/arm/mach-at91/include/mach/board.h  |    3 +
 drivers/ide/Kconfig                      |    5 +
 drivers/ide/Makefile                     |    1 +
 drivers/ide/at91_ide.c                   |  467 ++++++++++++++++++++++++++++++
 drivers/ide/ide-disk_proc.c              |    2 +-
 drivers/ide/ide-floppy_proc.c            |    2 +-
 drivers/ide/ide-io.c                     |    3 +-
 drivers/ide/ide-iops.c                   |    2 +
 drivers/ide/ide-probe.c                  |    7 +-
 drivers/ide/ide-proc.c                   |    2 +-
 drivers/ide/ide-tape.c                   |    2 +-
 include/linux/hdreg.h                    |    1 -
 include/linux/ide.h                      |    1 +
 14 files changed, 596 insertions(+), 7 deletions(-)
 create mode 100644 drivers/ide/at91_ide.c


Bartlomiej Zolnierkiewicz (1):
      remove stale comment from <linux/hdreg.h>

Hannes Eder (1):
      ide: NULL noise: drivers/ide/ide-*.c

Roel Kluin (1):
      ide: expiry() returns int, negative expiry() return values won't be noticed

Sergei Shtylyov (1):
      ide-iops: fix odd-length ATAPI PIO transfers

Stanislaw Gruszka (3):
      ide: allow to wrap interrupt handler
      ide: add at91_ide driver
      AT91: initialize Compact Flash on AT91SAM9263 cpu


diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 134af97..b7f2332 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -347,6 +347,111 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
 void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
 #endif
 
+/* --------------------------------------------------------------------
+ *  Compact Flash (PCMCIA or IDE)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) || \
+    defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
+
+static struct at91_cf_data cf0_data;
+
+static struct resource cf0_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_4,
+		.end	= AT91_CHIPSELECT_4 + SZ_256M - 1,
+		.flags	= IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
+	}
+};
+
+static struct platform_device cf0_device = {
+	.id		= 0,
+	.dev		= {
+				.platform_data	= &cf0_data,
+	},
+	.resource	= cf0_resources,
+	.num_resources	= ARRAY_SIZE(cf0_resources),
+};
+
+static struct at91_cf_data cf1_data;
+
+static struct resource cf1_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_5,
+		.end	= AT91_CHIPSELECT_5 + SZ_256M - 1,
+		.flags	= IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
+	}
+};
+
+static struct platform_device cf1_device = {
+	.id		= 1,
+	.dev		= {
+				.platform_data	= &cf1_data,
+	},
+	.resource	= cf1_resources,
+	.num_resources	= ARRAY_SIZE(cf1_resources),
+};
+
+void __init at91_add_device_cf(struct at91_cf_data *data)
+{
+	unsigned long ebi0_csa;
+	struct platform_device *pdev;
+
+	if (!data)
+		return;
+
+	/*
+	 * assign CS4 or CS5 to SMC with Compact Flash logic support,
+	 * we assume SMC timings are configured by board code,
+	 * except True IDE where timings are controlled by driver
+	 */
+	ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
+	switch (data->chipselect) {
+	case 4:
+		at91_set_A_periph(AT91_PIN_PD6, 0);  /* EBI0_NCS4/CFCS0 */
+		ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1;
+		cf0_data = *data;
+		pdev = &cf0_device;
+		break;
+	case 5:
+		at91_set_A_periph(AT91_PIN_PD7, 0);  /* EBI0_NCS5/CFCS1 */
+		ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2;
+		cf1_data = *data;
+		pdev = &cf1_device;
+		break;
+	default:
+		printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n",
+		       data->chipselect);
+		return;
+	}
+	at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
+
+	if (data->det_pin) {
+		at91_set_gpio_input(data->det_pin, 1);
+		at91_set_deglitch(data->det_pin, 1);
+	}
+
+	if (data->irq_pin) {
+		at91_set_gpio_input(data->irq_pin, 1);
+		at91_set_deglitch(data->irq_pin, 1);
+	}
+
+	if (data->vcc_pin)
+		/* initially off */
+		at91_set_gpio_output(data->vcc_pin, 0);
+
+	/* enable EBI controlled pins */
+	at91_set_A_periph(AT91_PIN_PD5, 1);  /* NWAIT */
+	at91_set_A_periph(AT91_PIN_PD8, 0);  /* CFCE1 */
+	at91_set_A_periph(AT91_PIN_PD9, 0);  /* CFCE2 */
+	at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */
+
+	pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "at91_ide" : "at91_cf";
+	platform_device_register(pdev);
+}
+#else
+void __init at91_add_device_cf(struct at91_cf_data *data) {}
+#endif
 
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 0b3ae21..793fe7b 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -56,6 +56,9 @@ struct at91_cf_data {
 	u8	vcc_pin;		/* power switching */
 	u8	rst_pin;		/* card reset */
 	u8	chipselect;		/* EBI Chip Select number */
+	u8	flags;
+#define AT91_CF_TRUE_IDE	0x01
+#define AT91_IDE_SWAP_A0_A2	0x02
 };
 extern void __init at91_add_device_cf(struct at91_cf_data *data);
 
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index e072903..5ea3bfa 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -721,6 +721,11 @@ config BLK_DEV_IDE_TX4939
 	depends on SOC_TX4939
 	select BLK_DEV_IDEDMA_SFF
 
+config BLK_DEV_IDE_AT91
+	tristate "Atmel AT91 (SAM9, CAP9, AT572D940HF) IDE support"
+	depends on ARM && ARCH_AT91 && !ARCH_AT91RM9200 && !ARCH_AT91X40
+	select IDE_TIMINGS
+
 config IDE_ARM
 	tristate "ARM IDE support"
 	depends on ARM && (ARCH_RPC || ARCH_SHARK)
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index d0e3d7d..1c326d9 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -116,3 +116,4 @@ obj-$(CONFIG_BLK_DEV_IDE_AU1XXX)	+= au1xxx-ide.o
 
 obj-$(CONFIG_BLK_DEV_IDE_TX4938)	+= tx4938ide.o
 obj-$(CONFIG_BLK_DEV_IDE_TX4939)	+= tx4939ide.o
+obj-$(CONFIG_BLK_DEV_IDE_AT91)		+= at91_ide.o
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c
new file mode 100644
index 0000000..1bb50f4
--- /dev/null
+++ b/drivers/ide/at91_ide.c
@@ -0,0 +1,467 @@
+/*
+ * IDE host driver for AT91 (SAM9, CAP9, AT572D940HF) Static Memory Controller
+ * with Compact Flash True IDE logic
+ *
+ * Copyright (c) 2008, 2009 Kelvatek Ltd.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/ide.h>
+#include <linux/platform_device.h>
+
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/at91sam9263.h>
+#include <mach/at91sam9_smc.h>
+#include <mach/at91sam9263_matrix.h>
+
+#define DRV_NAME "at91_ide"
+
+#define perr(fmt, args...) pr_err(DRV_NAME ": " fmt, ##args)
+#define pdbg(fmt, args...) pr_debug("%s " fmt, __func__, ##args)
+
+/*
+ * Access to IDE device is possible through EBI Static Memory Controller
+ * with Compact Flash logic. For details see EBI and SMC datasheet sections
+ * of any microcontroller from AT91SAM9 family.
+ *
+ * Within SMC chip select address space, lines A[23:21] distinguish Compact
+ * Flash modes (I/O, common memory, attribute memory, True IDE). IDE modes are:
+ *   0x00c0000 - True IDE
+ *   0x00e0000 - Alternate True IDE (Alt Status Register)
+ *
+ * On True IDE mode Task File and Data Register are mapped at the same address.
+ * To distinguish access between these two different bus data width is used:
+ * 8Bit for Task File, 16Bit for Data I/O.
+ *
+ * After initialization we do 8/16 bit flipping (changes in SMC MODE register)
+ * only inside IDE callback routines which are serialized by IDE layer,
+ * so no additional locking needed.
+ */
+
+#define TASK_FILE	0x00c00000
+#define ALT_MODE	0x00e00000
+#define REGS_SIZE	8
+
+#define enter_16bit(cs, mode) do {					\
+	mode = at91_sys_read(AT91_SMC_MODE(cs));			\
+	at91_sys_write(AT91_SMC_MODE(cs), mode | AT91_SMC_DBW_16);	\
+} while (0)
+
+#define leave_16bit(cs, mode) at91_sys_write(AT91_SMC_MODE(cs), mode);
+
+static void set_smc_timings(const u8 chipselect, const u16 cycle,
+			    const u16 setup, const u16 pulse,
+			    const u16 data_float, int use_iordy)
+{
+	unsigned long mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
+			     AT91_SMC_BAT_SELECT;
+
+	/* disable or enable waiting for IORDY signal */
+	if (use_iordy)
+		mode |= AT91_SMC_EXNWMODE_READY;
+
+	/* add data float cycles if needed */
+	if (data_float)
+		mode |= AT91_SMC_TDF_(data_float);
+
+	at91_sys_write(AT91_SMC_MODE(chipselect), mode);
+
+	/* setup timings in SMC */
+	at91_sys_write(AT91_SMC_SETUP(chipselect), AT91_SMC_NWESETUP_(setup) |
+						   AT91_SMC_NCS_WRSETUP_(0) |
+						   AT91_SMC_NRDSETUP_(setup) |
+						   AT91_SMC_NCS_RDSETUP_(0));
+	at91_sys_write(AT91_SMC_PULSE(chipselect), AT91_SMC_NWEPULSE_(pulse) |
+						   AT91_SMC_NCS_WRPULSE_(cycle) |
+						   AT91_SMC_NRDPULSE_(pulse) |
+						   AT91_SMC_NCS_RDPULSE_(cycle));
+	at91_sys_write(AT91_SMC_CYCLE(chipselect), AT91_SMC_NWECYCLE_(cycle) |
+						   AT91_SMC_NRDCYCLE_(cycle));
+}
+
+static unsigned int calc_mck_cycles(unsigned int ns, unsigned int mck_hz)
+{
+	u64 tmp = ns;
+
+	tmp *= mck_hz;
+	tmp += 1000*1000*1000 - 1; /* round up */
+	do_div(tmp, 1000*1000*1000);
+	return (unsigned int) tmp;
+}
+
+static void apply_timings(const u8 chipselect, const u8 pio,
+			  const struct ide_timing *timing, int use_iordy)
+{
+	unsigned int t0, t1, t2, t6z;
+	unsigned int cycle, setup, pulse, data_float;
+	unsigned int mck_hz;
+	struct clk *mck;
+
+	/* see table 22 of Compact Flash standard 4.1 for the meaning,
+	 * we do not stretch active (t2) time, so setup (t1) + hold time (th)
+	 * assure at least minimal recovery (t2i) time */
+	t0 = timing->cyc8b;
+	t1 = timing->setup;
+	t2 = timing->act8b;
+	t6z = (pio < 5) ? 30 : 20;
+
+	pdbg("t0=%u t1=%u t2=%u t6z=%u\n", t0, t1, t2, t6z);
+
+	mck = clk_get(NULL, "mck");
+	BUG_ON(IS_ERR(mck));
+	mck_hz = clk_get_rate(mck);
+	pdbg("mck_hz=%u\n", mck_hz);
+
+	cycle = calc_mck_cycles(t0, mck_hz);
+	setup = calc_mck_cycles(t1, mck_hz);
+	pulse = calc_mck_cycles(t2, mck_hz);
+	data_float = calc_mck_cycles(t6z, mck_hz);
+
+	pdbg("cycle=%u setup=%u pulse=%u data_float=%u\n",
+	     cycle, setup, pulse, data_float);
+
+	set_smc_timings(chipselect, cycle, setup, pulse, data_float, use_iordy);
+}
+
+static void at91_ide_input_data(ide_drive_t *drive, struct request *rq,
+				void *buf, unsigned int len)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct ide_io_ports *io_ports = &hwif->io_ports;
+	u8 chipselect = hwif->select_data;
+	unsigned long mode;
+
+	pdbg("cs %u buf %p len %d\n", chipselect, buf, len);
+
+	len++;
+
+	enter_16bit(chipselect, mode);
+	__ide_mm_insw((void __iomem *) io_ports->data_addr, buf, len / 2);
+	leave_16bit(chipselect, mode);
+}
+
+static void at91_ide_output_data(ide_drive_t *drive, struct request *rq,
+				 void *buf, unsigned int len)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct ide_io_ports *io_ports = &hwif->io_ports;
+	u8 chipselect = hwif->select_data;
+	unsigned long mode;
+
+	pdbg("cs %u buf %p len %d\n", chipselect,  buf, len);
+
+	enter_16bit(chipselect, mode);
+	__ide_mm_outsw((void __iomem *) io_ports->data_addr, buf, len / 2);
+	leave_16bit(chipselect, mode);
+}
+
+static u8 ide_mm_inb(unsigned long port)
+{
+	return readb((void __iomem *) port);
+}
+
+static void ide_mm_outb(u8 value, unsigned long port)
+{
+	writeb(value, (void __iomem *) port);
+}
+
+static void at91_ide_tf_load(ide_drive_t *drive, ide_task_t *task)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct ide_io_ports *io_ports = &hwif->io_ports;
+	struct ide_taskfile *tf = &task->tf;
+	u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
+
+	if (task->tf_flags & IDE_TFLAG_FLAGGED)
+		HIHI = 0xFF;
+
+	if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
+		u16 data = (tf->hob_data << 8) | tf->data;
+
+		at91_ide_output_data(drive, NULL, &data, 2);
+	}
+
+	if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
+		ide_mm_outb(tf->hob_feature, io_ports->feature_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
+		ide_mm_outb(tf->hob_nsect, io_ports->nsect_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
+		ide_mm_outb(tf->hob_lbal, io_ports->lbal_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
+		ide_mm_outb(tf->hob_lbam, io_ports->lbam_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
+		ide_mm_outb(tf->hob_lbah, io_ports->lbah_addr);
+
+	if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
+		ide_mm_outb(tf->feature, io_ports->feature_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
+		ide_mm_outb(tf->nsect, io_ports->nsect_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
+		ide_mm_outb(tf->lbal, io_ports->lbal_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
+		ide_mm_outb(tf->lbam, io_ports->lbam_addr);
+	if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
+		ide_mm_outb(tf->lbah, io_ports->lbah_addr);
+
+	if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
+		ide_mm_outb((tf->device & HIHI) | drive->select, io_ports->device_addr);
+}
+
+static void at91_ide_tf_read(ide_drive_t *drive, ide_task_t *task)
+{
+	ide_hwif_t *hwif = drive->hwif;
+	struct ide_io_ports *io_ports = &hwif->io_ports;
+	struct ide_taskfile *tf = &task->tf;
+
+	if (task->tf_flags & IDE_TFLAG_IN_DATA) {
+		u16 data;
+
+		at91_ide_input_data(drive, NULL, &data, 2);
+		tf->data = data & 0xff;
+		tf->hob_data = (data >> 8) & 0xff;
+	}
+
+	/* be sure we're looking at the low order bits */
+	ide_mm_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
+
+	if (task->tf_flags & IDE_TFLAG_IN_FEATURE)
+		tf->feature = ide_mm_inb(io_ports->feature_addr);
+	if (task->tf_flags & IDE_TFLAG_IN_NSECT)
+		tf->nsect  = ide_mm_inb(io_ports->nsect_addr);
+	if (task->tf_flags & IDE_TFLAG_IN_LBAL)
+		tf->lbal   = ide_mm_inb(io_ports->lbal_addr);
+	if (task->tf_flags & IDE_TFLAG_IN_LBAM)
+		tf->lbam   = ide_mm_inb(io_ports->lbam_addr);
+	if (task->tf_flags & IDE_TFLAG_IN_LBAH)
+		tf->lbah   = ide_mm_inb(io_ports->lbah_addr);
+	if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
+		tf->device = ide_mm_inb(io_ports->device_addr);
+
+	if (task->tf_flags & IDE_TFLAG_LBA48) {
+		ide_mm_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
+
+		if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
+			tf->hob_feature = ide_mm_inb(io_ports->feature_addr);
+		if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
+			tf->hob_nsect   = ide_mm_inb(io_ports->nsect_addr);
+		if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
+			tf->hob_lbal    = ide_mm_inb(io_ports->lbal_addr);
+		if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
+			tf->hob_lbam    = ide_mm_inb(io_ports->lbam_addr);
+		if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
+			tf->hob_lbah    = ide_mm_inb(io_ports->lbah_addr);
+	}
+}
+
+static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
+{
+	struct ide_timing *timing;
+	u8 chipselect = drive->hwif->select_data;
+	int use_iordy = 0;
+
+	pdbg("chipselect %u pio %u\n", chipselect, pio);
+
+	timing = ide_timing_find_mode(XFER_PIO_0 + pio);
+	BUG_ON(!timing);
+
+	if ((pio > 2 || ata_id_has_iordy(drive->id)) &&
+	    !(ata_id_is_cfa(drive->id) && pio > 4))
+		use_iordy = 1;
+
+	apply_timings(chipselect, pio, timing, use_iordy);
+}
+
+static const struct ide_tp_ops at91_ide_tp_ops = {
+	.exec_command	= ide_exec_command,
+	.read_status	= ide_read_status,
+	.read_altstatus	= ide_read_altstatus,
+	.set_irq	= ide_set_irq,
+
+	.tf_load	= at91_ide_tf_load,
+	.tf_read	= at91_ide_tf_read,
+
+	.input_data	= at91_ide_input_data,
+	.output_data	= at91_ide_output_data,
+};
+
+static const struct ide_port_ops at91_ide_port_ops = {
+	.set_pio_mode	= at91_ide_set_pio_mode,
+};
+
+static const struct ide_port_info at91_ide_port_info __initdata = {
+	.port_ops	= &at91_ide_port_ops,
+	.tp_ops		= &at91_ide_tp_ops,
+	.host_flags 	= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE |
+			  IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS,
+	.pio_mask 	= ATA_PIO5,
+};
+
+/*
+ * If interrupt is delivered through GPIO, IRQ are triggered on falling
+ * and rising edge of signal. Whereas IDE device request interrupt on high
+ * level (rising edge in our case). This mean we have fake interrupts, so
+ * we need to check interrupt pin and exit instantly from ISR when line
+ * is on low level.
+ */
+
+irqreturn_t at91_irq_handler(int irq, void *dev_id)
+{
+	int ntries = 8;
+	int pin_val1, pin_val2;
+
+	/* additional deglitch, line can be noisy in badly designed PCB */
+	do {
+		pin_val1 = at91_get_gpio_value(irq);
+		pin_val2 = at91_get_gpio_value(irq);
+	} while (pin_val1 != pin_val2 && --ntries > 0);
+
+	if (pin_val1 == 0 || ntries <= 0)
+		return IRQ_HANDLED;
+
+	return ide_intr(irq, dev_id);
+}
+
+static int __init at91_ide_probe(struct platform_device *pdev)
+{
+	int ret;
+	hw_regs_t hw;
+	hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
+	struct ide_host *host;
+	struct resource *res;
+	unsigned long tf_base = 0, ctl_base = 0;
+	struct at91_cf_data *board = pdev->dev.platform_data;
+
+	if (!board)
+		return -ENODEV;
+
+	if (board->det_pin && at91_get_gpio_value(board->det_pin) != 0) {
+		perr("no device detected\n");
+		return -ENODEV;
+	}
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		perr("can't get memory resource\n");
+		return -ENODEV;
+	}
+
+	if (!devm_request_mem_region(&pdev->dev, res->start + TASK_FILE,
+				     REGS_SIZE, "ide") ||
+	    !devm_request_mem_region(&pdev->dev, res->start + ALT_MODE,
+				     REGS_SIZE, "alt")) {
+		perr("memory resources in use\n");
+		return -EBUSY;
+	}
+
+	pdbg("chipselect %u irq %u res %08lx\n", board->chipselect,
+	     board->irq_pin, (unsigned long) res->start);
+
+	tf_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + TASK_FILE,
+					       REGS_SIZE);
+	ctl_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + ALT_MODE,
+						REGS_SIZE);
+	if (!tf_base || !ctl_base) {
+		perr("can't map memory regions\n");
+		return -EBUSY;
+	}
+
+	memset(&hw, 0, sizeof(hw));
+
+	if (board->flags & AT91_IDE_SWAP_A0_A2) {
+		/* workaround for stupid hardware bug */
+		hw.io_ports.data_addr	= tf_base + 0;
+		hw.io_ports.error_addr	= tf_base + 4;
+		hw.io_ports.nsect_addr	= tf_base + 2;
+		hw.io_ports.lbal_addr	= tf_base + 6;
+		hw.io_ports.lbam_addr	= tf_base + 1;
+		hw.io_ports.lbah_addr	= tf_base + 5;
+		hw.io_ports.device_addr = tf_base + 3;
+		hw.io_ports.command_addr = tf_base + 7;
+		hw.io_ports.ctl_addr	= ctl_base + 3;
+	} else
+		ide_std_init_ports(&hw, tf_base, ctl_base + 6);
+
+	hw.irq = board->irq_pin;
+	hw.chipset = ide_generic;
+	hw.dev = &pdev->dev;
+
+	host = ide_host_alloc(&at91_ide_port_info, hws);
+	if (!host) {
+		perr("failed to allocate ide host\n");
+		return -ENOMEM;
+	}
+
+	/* setup Static Memory Controller - PIO 0 as default */
+	apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0);
+
+	/* with GPIO interrupt we have to do quirks in handler */
+	if (board->irq_pin >= PIN_BASE)
+		host->irq_handler = at91_irq_handler;
+
+	host->ports[0]->select_data = board->chipselect;
+
+	ret = ide_host_register(host, &at91_ide_port_info, hws);
+	if (ret) {
+		perr("failed to register ide host\n");
+		goto err_free_host;
+	}
+	platform_set_drvdata(pdev, host);
+	return 0;
+
+err_free_host:
+	ide_host_free(host);
+	return ret;
+}
+
+static int __exit at91_ide_remove(struct platform_device *pdev)
+{
+	struct ide_host *host = platform_get_drvdata(pdev);
+
+	ide_host_remove(host);
+	return 0;
+}
+
+static struct platform_driver at91_ide_driver = {
+	.driver	= {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+	},
+	.remove	= __exit_p(at91_ide_remove),
+};
+
+static int __init at91_ide_init(void)
+{
+	return platform_driver_probe(&at91_ide_driver, at91_ide_probe);
+}
+
+static void __exit at91_ide_exit(void)
+{
+	platform_driver_unregister(&at91_ide_driver);
+}
+
+module_init(at91_ide_init);
+module_exit(at91_ide_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Stanislaw Gruszka <stf_xl@wp.pl>");
+
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 1146f42..1f86dcb 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -125,5 +125,5 @@ const struct ide_proc_devset ide_disk_settings[] = {
 	IDE_PROC_DEVSET(multcount,	0,    16),
 	IDE_PROC_DEVSET(nowerr,		0,     1),
 	IDE_PROC_DEVSET(wcache,		0,     1),
-	{ 0 },
+	{ NULL },
 };
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index 3ec762c..fcd4d81 100644
--- a/drivers/ide/ide-floppy_proc.c
+++ b/drivers/ide/ide-floppy_proc.c
@@ -29,5 +29,5 @@ const struct ide_proc_devset ide_floppy_settings[] = {
 	IDE_PROC_DEVSET(bios_head, 0,  255),
 	IDE_PROC_DEVSET(bios_sect, 0,   63),
 	IDE_PROC_DEVSET(ticks,	   0,  255),
-	{ 0 },
+	{ NULL },
 };
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 9ee51ad..a9a6c20 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -908,7 +908,7 @@ void ide_timer_expiry (unsigned long data)
 	ide_drive_t	*uninitialized_var(drive);
 	ide_handler_t	*handler;
 	unsigned long	flags;
-	unsigned long	wait = -1;
+	int		wait = -1;
 	int		plug_device = 0;
 
 	spin_lock_irqsave(&hwif->lock, flags);
@@ -1162,6 +1162,7 @@ out_early:
 
 	return irq_ret;
 }
+EXPORT_SYMBOL_GPL(ide_intr);
 
 /**
  *	ide_do_drive_cmd	-	issue IDE special command
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 753b92e..b1892bd 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -315,6 +315,8 @@ void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf,
 	u8 io_32bit = drive->io_32bit;
 	u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
 
+	len++;
+
 	if (io_32bit) {
 		unsigned long uninitialized_var(flags);
 
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index ce0818a..ee8e3e7 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -950,6 +950,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
 static int init_irq (ide_hwif_t *hwif)
 {
 	struct ide_io_ports *io_ports = &hwif->io_ports;
+	irq_handler_t irq_handler;
 	int sa = 0;
 
 	mutex_lock(&ide_cfg_mtx);
@@ -959,6 +960,10 @@ static int init_irq (ide_hwif_t *hwif)
 	hwif->timer.function = &ide_timer_expiry;
 	hwif->timer.data = (unsigned long)hwif;
 
+	irq_handler = hwif->host->irq_handler;
+	if (irq_handler == NULL)
+		irq_handler = ide_intr;
+
 #if defined(__mc68000__)
 	sa = IRQF_SHARED;
 #endif /* __mc68000__ */
@@ -969,7 +974,7 @@ static int init_irq (ide_hwif_t *hwif)
 	if (io_ports->ctl_addr)
 		hwif->tp_ops->set_irq(hwif, 1);
 
-	if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif))
+	if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif))
 		goto out_up;
 
 	if (!hwif->rqsize) {
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 1d8978b..a7b9287 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -231,7 +231,7 @@ static const struct ide_proc_devset ide_generic_settings[] = {
 	IDE_PROC_DEVSET(pio_mode, 0, 255),
 	IDE_PROC_DEVSET(unmaskirq, 0, 1),
 	IDE_PROC_DEVSET(using_dma, 0, 1),
-	{ 0 },
+	{ NULL },
 };
 
 static void proc_ide_settings_warn(void)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index bb450a7..4e6181c 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2166,7 +2166,7 @@ static const struct ide_proc_devset idetape_settings[] = {
 	__IDE_PROC_DEVSET(speed,	0, 0xffff, NULL, NULL),
 	__IDE_PROC_DEVSET(tdsc,		IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX,
 					mulf_tdsc, divf_tdsc),
-	{ 0 },
+	{ NULL },
 };
 #endif
 
diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h
index c37e924..ed21bd3 100644
--- a/include/linux/hdreg.h
+++ b/include/linux/hdreg.h
@@ -511,7 +511,6 @@ struct hd_driveid {
 	unsigned short	words69_70[2];	/* reserved words 69-70
 					 * future command overlap and queuing
 					 */
-	/* HDIO_GET_IDENTITY currently returns only words 0 through 70 */
 	unsigned short	words71_74[4];	/* reserved words 71-74
 					 * for IDENTIFY PACKET DEVICE command
 					 */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index fe235b6..e0cedfe 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -866,6 +866,7 @@ struct ide_host {
 	unsigned int	n_ports;
 	struct device	*dev[2];
 	unsigned int	(*init_chipset)(struct pci_dev *);
+	irq_handler_t	irq_handler;
 	unsigned long	host_flags;
 	void		*host_priv;
 	ide_hwif_t	*cur_port;	/* for hosts requiring serialization */

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-02-02 19:48 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-02-02 19:48 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel

Inside:

- ide-cd bug fix for non-bio backed requests from Borislav Petkov
  (closes kernel.org bug #12320).

- icside bug fix to make it work again on PCB v6.

- Port initialization failure handling fix from Ian Campbell.

- Support for CS5536 PATA controller (based on older driver
  from Martin K. Petersen, also extra thanks to Sergei Shtylyov
  for excellent review of the new driver).

- Support for AmigaOne board for VIA IDE host driver
  from Gerhard Pircher.

- dev->bus_id -> dev_name() conversion from Kay Sievers.

- tx4939ide update from Atsushi Nemoto.


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 drivers/ide/Kconfig     |   10 ++
 drivers/ide/Makefile    |    1 +
 drivers/ide/cs5536.c    |  308 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/ide/icside.c    |    2 +-
 drivers/ide/ide-acpi.c  |    2 +-
 drivers/ide/ide-cd.c    |    3 +
 drivers/ide/ide-io.c    |    9 +-
 drivers/ide/ide-probe.c |   43 +++++--
 drivers/ide/tx4939ide.c |    4 +-
 drivers/ide/via82cxxx.c |    5 +
 10 files changed, 371 insertions(+), 16 deletions(-)
 create mode 100644 drivers/ide/cs5536.c


Atsushi Nemoto (1):
      tx4939ide: typo fix and minor cleanup

Bartlomiej Zolnierkiewicz (3):
      ide: fix ide_register_port() failure handling
      ide: add CS5536 host driver (v3)
      icside: fix PCB version 6 support (v2)

Borislav Petkov (1):
      ide-cd: fix DMA for non bio-backed requests

Gerhard Pircher (1):
      ide: Force VIA IDE legacy interrupts for AmigaOne boards

Ian Campbell (1):
      IDE: Unregister and disable devices if initialization fails.

Kay Sievers (1):
      ide: struct device - replace bus_id with dev_name(), dev_set_name()


diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index b1c6f68..3dad229 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -465,6 +465,16 @@ config BLK_DEV_CS5535
 
 	  It is safe to say Y to this question.
 
+config BLK_DEV_CS5536
+	tristate "CS5536 chipset support"
+	depends on X86_32
+	select BLK_DEV_IDEDMA_PCI
+	help
+	  This option enables support for the AMD CS5536
+	  companion chip used with the Geode LX processor family.
+
+	  If unsure, say N.
+
 config BLK_DEV_HPT366
 	tristate "HPT36X/37X chipset support"
 	select BLK_DEV_IDEDMA_PCI
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index c2b9c93..d0e3d7d 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_BLK_DEV_CMD64X)		+= cmd64x.o
 obj-$(CONFIG_BLK_DEV_CS5520)		+= cs5520.o
 obj-$(CONFIG_BLK_DEV_CS5530)		+= cs5530.o
 obj-$(CONFIG_BLK_DEV_CS5535)		+= cs5535.o
+obj-$(CONFIG_BLK_DEV_CS5536)		+= cs5536.o
 obj-$(CONFIG_BLK_DEV_SC1200)		+= sc1200.o
 obj-$(CONFIG_BLK_DEV_CY82C693)		+= cy82c693.o
 obj-$(CONFIG_BLK_DEV_DELKIN)		+= delkin_cb.o
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c
new file mode 100644
index 0000000..7a62db7
--- /dev/null
+++ b/drivers/ide/cs5536.c
@@ -0,0 +1,308 @@
+/*
+ * CS5536 PATA support
+ * (C) 2007 Martin K. Petersen <mkp@mkp.net>
+ * (C) 2009 Bartlomiej Zolnierkiewicz
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Documentation:
+ *	Available from AMD web site.
+ *
+ * The IDE timing registers for the CS5536 live in the Geode Machine
+ * Specific Register file and not PCI config space.  Most BIOSes
+ * virtualize the PCI registers so the chip looks like a standard IDE
+ * controller.  Unfortunately not all implementations get this right.
+ * In particular some have problems with unaligned accesses to the
+ * virtualized PCI registers.  This driver always does full dword
+ * writes to work around the issue.  Also, in case of a bad BIOS this
+ * driver can be loaded with the "msr=1" parameter which forces using
+ * the Machine Specific Registers to configure the device.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/ide.h>
+#include <asm/msr.h>
+
+#define DRV_NAME	"cs5536"
+
+enum {
+	MSR_IDE_CFG		= 0x51300010,
+	PCI_IDE_CFG		= 0x40,
+
+	CFG			= 0,
+	DTC			= 2,
+	CAST			= 3,
+	ETC			= 4,
+
+	IDE_CFG_CHANEN		= (1 << 1),
+	IDE_CFG_CABLE		= (1 << 17) | (1 << 16),
+
+	IDE_D0_SHIFT		= 24,
+	IDE_D1_SHIFT		= 16,
+	IDE_DRV_MASK		= 0xff,
+
+	IDE_CAST_D0_SHIFT	= 6,
+	IDE_CAST_D1_SHIFT	= 4,
+	IDE_CAST_DRV_MASK	= 0x3,
+
+	IDE_CAST_CMD_SHIFT	= 24,
+	IDE_CAST_CMD_MASK	= 0xff,
+
+	IDE_ETC_UDMA_MASK	= 0xc0,
+};
+
+static int use_msr;
+
+static int cs5536_read(struct pci_dev *pdev, int reg, u32 *val)
+{
+	if (unlikely(use_msr)) {
+		u32 dummy;
+
+		rdmsr(MSR_IDE_CFG + reg, *val, dummy);
+		return 0;
+	}
+
+	return pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val);
+}
+
+static int cs5536_write(struct pci_dev *pdev, int reg, int val)
+{
+	if (unlikely(use_msr)) {
+		wrmsr(MSR_IDE_CFG + reg, val, 0);
+		return 0;
+	}
+
+	return pci_write_config_dword(pdev, PCI_IDE_CFG + reg * 4, val);
+}
+
+static void cs5536_program_dtc(ide_drive_t *drive, u8 tim)
+{
+	struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
+	int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT;
+	u32 dtc;
+
+	cs5536_read(pdev, DTC, &dtc);
+	dtc &= ~(IDE_DRV_MASK << dshift);
+	dtc |= tim << dshift;
+	cs5536_write(pdev, DTC, dtc);
+}
+
+/**
+ *	cs5536_cable_detect	-	detect cable type
+ *	@hwif: Port to detect on
+ *
+ *	Perform cable detection for ATA66 capable cable.
+ *
+ *	Returns a cable type.
+ */
+
+static u8 cs5536_cable_detect(ide_hwif_t *hwif)
+{
+	struct pci_dev *pdev = to_pci_dev(hwif->dev);
+	u32 cfg;
+
+	cs5536_read(pdev, CFG, &cfg);
+
+	if (cfg & IDE_CFG_CABLE)
+		return ATA_CBL_PATA80;
+	else
+		return ATA_CBL_PATA40;
+}
+
+/**
+ *	cs5536_set_pio_mode		-	PIO timing setup
+ *	@drive: ATA device
+ *	@pio: PIO mode number
+ */
+
+static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio)
+{
+	static const u8 drv_timings[5] = {
+		0x98, 0x55, 0x32, 0x21, 0x20,
+	};
+
+	static const u8 addr_timings[5] = {
+		0x2, 0x1, 0x0, 0x0, 0x0,
+	};
+
+	static const u8 cmd_timings[5] = {
+		0x99, 0x92, 0x90, 0x22, 0x20,
+	};
+
+	struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
+	ide_drive_t *pair = ide_get_pair_dev(drive);
+	int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT;
+	u32 cast;
+	u8 cmd_pio = pio;
+
+	if (pair)
+		cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4));
+
+	drive->drive_data &= (IDE_DRV_MASK << 8);
+	drive->drive_data |= drv_timings[pio];
+
+	cs5536_program_dtc(drive, drv_timings[pio]);
+
+	cs5536_read(pdev, CAST, &cast);
+
+	cast &= ~(IDE_CAST_DRV_MASK << cshift);
+	cast |= addr_timings[pio] << cshift;
+
+	cast &= ~(IDE_CAST_CMD_MASK << IDE_CAST_CMD_SHIFT);
+	cast |= cmd_timings[cmd_pio] << IDE_CAST_CMD_SHIFT;
+
+	cs5536_write(pdev, CAST, cast);
+}
+
+/**
+ *	cs5536_set_dma_mode		-	DMA timing setup
+ *	@drive: ATA device
+ *	@mode: DMA mode
+ */
+
+static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode)
+{
+	static const u8 udma_timings[6] = {
+		0xc2, 0xc1, 0xc0, 0xc4, 0xc5, 0xc6,
+	};
+
+	static const u8 mwdma_timings[3] = {
+		0x67, 0x21, 0x20,
+	};
+
+	struct pci_dev *pdev = to_pci_dev(drive->hwif->dev);
+	int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT;
+	u32 etc;
+
+	cs5536_read(pdev, ETC, &etc);
+
+	if (mode >= XFER_UDMA_0) {
+		etc &= ~(IDE_DRV_MASK << dshift);
+		etc |= udma_timings[mode - XFER_UDMA_0] << dshift;
+	} else { /* MWDMA */
+		etc &= ~(IDE_ETC_UDMA_MASK << dshift);
+		drive->drive_data &= IDE_DRV_MASK;
+		drive->drive_data |= mwdma_timings[mode - XFER_MW_DMA_0] << 8;
+	}
+
+	cs5536_write(pdev, ETC, etc);
+}
+
+static void cs5536_dma_start(ide_drive_t *drive)
+{
+	if (drive->current_speed < XFER_UDMA_0 &&
+	    (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK))
+		cs5536_program_dtc(drive, drive->drive_data >> 8);
+
+	ide_dma_start(drive);
+}
+
+static int cs5536_dma_end(ide_drive_t *drive)
+{
+	int ret = ide_dma_end(drive);
+
+	if (drive->current_speed < XFER_UDMA_0 &&
+	    (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK))
+		cs5536_program_dtc(drive, drive->drive_data & IDE_DRV_MASK);
+
+	return ret;
+}
+
+static const struct ide_port_ops cs5536_port_ops = {
+	.set_pio_mode		= cs5536_set_pio_mode,
+	.set_dma_mode		= cs5536_set_dma_mode,
+	.cable_detect		= cs5536_cable_detect,
+};
+
+static const struct ide_dma_ops cs5536_dma_ops = {
+	.dma_host_set		= ide_dma_host_set,
+	.dma_setup		= ide_dma_setup,
+	.dma_exec_cmd		= ide_dma_exec_cmd,
+	.dma_start		= cs5536_dma_start,
+	.dma_end		= cs5536_dma_end,
+	.dma_test_irq		= ide_dma_test_irq,
+	.dma_lost_irq		= ide_dma_lost_irq,
+	.dma_timeout		= ide_dma_timeout,
+};
+
+static const struct ide_port_info cs5536_info = {
+	.name		= DRV_NAME,
+	.port_ops	= &cs5536_port_ops,
+	.dma_ops	= &cs5536_dma_ops,
+	.host_flags	= IDE_HFLAG_SINGLE,
+	.pio_mask	= ATA_PIO4,
+	.mwdma_mask	= ATA_MWDMA2,
+	.udma_mask	= ATA_UDMA5,
+};
+
+/**
+ *	cs5536_init_one
+ *	@dev: PCI device
+ *	@id: Entry in match table
+ */
+
+static int cs5536_init_one(struct pci_dev *dev, const struct pci_device_id *id)
+{
+	u32 cfg;
+
+	if (use_msr)
+		printk(KERN_INFO DRV_NAME ": Using MSR regs instead of PCI\n");
+
+	cs5536_read(dev, CFG, &cfg);
+
+	if ((cfg & IDE_CFG_CHANEN) == 0) {
+		printk(KERN_ERR DRV_NAME ": disabled by BIOS\n");
+		return -ENODEV;
+	}
+
+	return ide_pci_init_one(dev, &cs5536_info, NULL);
+}
+
+static const struct pci_device_id cs5536_pci_tbl[] = {
+	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), },
+	{ },
+};
+
+static struct pci_driver cs5536_pci_driver = {
+	.name		= DRV_NAME,
+	.id_table	= cs5536_pci_tbl,
+	.probe		= cs5536_init_one,
+	.remove		= ide_pci_remove,
+	.suspend	= ide_pci_suspend,
+	.resume		= ide_pci_resume,
+};
+
+static int __init cs5536_init(void)
+{
+	return pci_register_driver(&cs5536_pci_driver);
+}
+
+static void __exit cs5536_exit(void)
+{
+	pci_unregister_driver(&cs5536_pci_driver);
+}
+
+MODULE_AUTHOR("Martin K. Petersen, Bartlomiej Zolnierkiewicz");
+MODULE_DESCRIPTION("low-level driver for the CS5536 IDE controller");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, cs5536_pci_tbl);
+
+module_param_named(msr, use_msr, int, 0644);
+MODULE_PARM_DESC(msr, "Force using MSR to configure IDE function (Default: 0)");
+
+module_init(cs5536_init);
+module_exit(cs5536_exit);
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 97a35c6..415d7e2 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -534,7 +534,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 		d.dma_ops = NULL;
 	}
 
-	ret = ide_host_register(host, NULL, hws);
+	ret = ide_host_register(host, &d, hws);
 	if (ret)
 		goto err_free;
 
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index d8f295b..ec7d07f 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -282,7 +282,7 @@ static int do_drive_get_GTF(ide_drive_t *drive,
 	port = hwif->channel ? drive->dn - 2: drive->dn;
 
 	DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
-		 hwif->name, dev->bus_id, port, hwif->channel);
+		 hwif->name, dev_name(dev), port, hwif->channel);
 
 	if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) {
 		DEBPRINT("%s drive %d:%d not present\n",
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index cae6937..0bfeb0c 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -787,6 +787,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 		if (blk_fs_request(rq)) {
 			ide_end_request(drive, 1, rq->nr_sectors);
 			return ide_stopped;
+		} else if (rq->cmd_type == REQ_TYPE_ATA_PC && !rq->bio) {
+			ide_end_request(drive, 1, 1);
+			return ide_stopped;
 		}
 		goto end_request;
 	}
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index cc16331..9ee51ad 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -418,11 +418,14 @@ void ide_map_sg(ide_drive_t *drive, struct request *rq)
 	ide_hwif_t *hwif = drive->hwif;
 	struct scatterlist *sg = hwif->sg_table;
 
-	if (rq->cmd_type != REQ_TYPE_ATA_TASKFILE) {
-		hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg);
-	} else {
+	if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
 		sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE);
 		hwif->sg_nents = 1;
+	} else if (!rq->bio) {
+		sg_init_one(sg, rq->data, rq->data_len);
+		hwif->sg_nents = 1;
+	} else {
+		hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg);
 	}
 }
 
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 0db1ed9..ce0818a 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1467,6 +1467,30 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
 }
 EXPORT_SYMBOL_GPL(ide_host_alloc);
 
+static void ide_port_free(ide_hwif_t *hwif)
+{
+	ide_port_free_devices(hwif);
+	ide_free_port_slot(hwif->index);
+	kfree(hwif);
+}
+
+static void ide_disable_port(ide_hwif_t *hwif)
+{
+	struct ide_host *host = hwif->host;
+	int i;
+
+	printk(KERN_INFO "%s: disabling port\n", hwif->name);
+
+	for (i = 0; i < MAX_HOST_PORTS; i++) {
+		if (host->ports[i] == hwif) {
+			host->ports[i] = NULL;
+			host->n_ports--;
+		}
+	}
+
+	ide_port_free(hwif);
+}
+
 int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
 		      hw_regs_t **hws)
 {
@@ -1507,8 +1531,12 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
 			hwif->present = 1;
 
 		if (hwif->chipset != ide_4drives || !hwif->mate ||
-		    !hwif->mate->present)
-			ide_register_port(hwif);
+		    !hwif->mate->present) {
+			if (ide_register_port(hwif)) {
+				ide_disable_port(hwif);
+				continue;
+			}
+		}
 
 		if (hwif->present)
 			ide_port_tune_devices(hwif);
@@ -1521,7 +1549,8 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
 		if (hwif_init(hwif) == 0) {
 			printk(KERN_INFO "%s: failed to initialize IDE "
 					 "interface\n", hwif->name);
-			hwif->present = 0;
+			device_unregister(&hwif->gendev);
+			ide_disable_port(hwif);
 			continue;
 		}
 
@@ -1660,12 +1689,8 @@ void ide_host_free(struct ide_host *host)
 	int i;
 
 	ide_host_for_each_port(i, hwif, host) {
-		if (hwif == NULL)
-			continue;
-
-		ide_port_free_devices(hwif);
-		ide_free_port_slot(hwif->index);
-		kfree(hwif);
+		if (hwif)
+			ide_port_free(hwif);
 	}
 
 	kfree(host);
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 882f6f0..40b0812 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -261,9 +261,9 @@ static int tx4939ide_build_dmatable(ide_drive_t *drive, struct request *rq)
 				bcount = cur_len;
 			/*
 			 * This workaround for zero count seems required.
-			 * (standard ide_build_dmatable do it too)
+			 * (standard ide_build_dmatable does it too)
 			 */
-			if ((bcount & 0xffff) == 0x0000)
+			if (bcount == 0x10000)
 				bcount = 0x8000;
 			*table++ = bcount & 0xffff;
 			*table++ = cur_addr;
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index 703c3ee..6092fe3 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -448,6 +448,11 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
 		d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS;
 #endif
 
+#ifdef CONFIG_AMIGAONE
+	if (machine_is(amigaone))
+		d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS;
+#endif
+
 	d.udma_mask = via_config->udma_mask;
 
 	vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2009-01-19 12:50 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-19 12:50 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Linus, please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/
to receive the following updates:
 drivers/ide/falconide.c   |    2 +- drivers/ide/ide-probe.c   |    3 ++- drivers/ide/palm_bk3710.c |   11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-)

Andreas Schwab (1):      ide: fix IDE PMAC breakage
David Brownell (1):      drivers/ide/palm_bk3710.c buildfix
Michael Schmitz (1):      ide: fix Falcon IDE breakage

diff --git a/drivers/ide/falconide.c b/drivers/ide/falconide.cindex a5ba820..a638e95 100644--- a/drivers/ide/falconide.c+++ b/drivers/ide/falconide.c@@ -82,7 +82,7 @@ static const struct ide_tp_ops falconide_tp_ops = {  static const struct ide_port_info falconide_port_info = { 	.tp_ops			= &falconide_tp_ops,-	.host_flags		= IDE_HFLAG_NO_DMA,+	.host_flags		= IDE_HFLAG_NO_DMA | IDE_HFLAG_SERIALIZE, };  static void __init falconide_setup_ports(hw_regs_t *hw)diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.cindex 312127e..0db1ed9 100644--- a/drivers/ide/ide-probe.c+++ b/drivers/ide/ide-probe.c@@ -649,7 +649,8 @@ static int ide_register_port(ide_hwif_t *hwif) 	/* register with global device tree */ 	dev_set_name(&hwif->gendev, hwif->name); 	hwif->gendev.driver_data = hwif;-	hwif->gendev.parent = hwif->dev;+	if (hwif->gendev.parent == NULL)+		hwif->gendev.parent = hwif->dev; 	hwif->gendev.release = hwif_release_dev;  	ret = device_register(&hwif->gendev);diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.cindex a7ac490..f38aac7 100644--- a/drivers/ide/palm_bk3710.c+++ b/drivers/ide/palm_bk3710.c@@ -346,7 +346,8 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) { 	struct clk *clk; 	struct resource *mem, *irq;-	unsigned long base, rate;+	void __iomem *base;+	unsigned long rate; 	int i, rc; 	hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; @@ -382,11 +383,13 @@ static int __init palm_bk3710_probe(struct platform_device *pdev) 	base = IO_ADDRESS(mem->start);  	/* Configure the Palm Chip controller */-	palm_bk3710_chipinit((void __iomem *)base);+	palm_bk3710_chipinit(base);  	for (i = 0; i < IDE_NR_PORTS - 2; i++)-		hw.io_ports_array[i] = base + IDE_PALM_ATA_PRI_REG_OFFSET + i;-	hw.io_ports.ctl_addr = base + IDE_PALM_ATA_PRI_CTL_OFFSET;+		hw.io_ports_array[i] = (unsigned long)+				(base + IDE_PALM_ATA_PRI_REG_OFFSET + i);+	hw.io_ports.ctl_addr = (unsigned long)+			(base + IDE_PALM_ATA_PRI_CTL_OFFSET); 	hw.irq = irq->start; 	hw.dev = &pdev->dev; 	hw.chipset = ide_palm3710;\0ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-12-22 22:08 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-22 22:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Linus, please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/
to receive the following updates:
 drivers/ide/cs5530.c |    3 ++- drivers/ide/sc1200.c |    3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)

Julia Lawall (1):      drivers/ide/{cs5530.c,sc1200.c}: Move a dereference below a NULL test

diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.cindex 53f079c..d8ede85 100644--- a/drivers/ide/cs5530.c+++ b/drivers/ide/cs5530.c@@ -81,11 +81,12 @@ static u8 cs5530_udma_filter(ide_drive_t *drive) { 	ide_hwif_t *hwif = drive->hwif; 	ide_drive_t *mate = ide_get_pair_dev(drive);-	u16 *mateid = mate->id;+	u16 *mateid; 	u8 mask = hwif->ultra_mask;  	if (mate == NULL) 		goto out;+	mateid = mate->id;  	if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) { 		if ((mateid[ATA_ID_FIELD_VALID] & 4) &&diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.cindex f1a8758..ec7f766 100644--- a/drivers/ide/sc1200.c+++ b/drivers/ide/sc1200.c@@ -104,11 +104,12 @@ static u8 sc1200_udma_filter(ide_drive_t *drive) { 	ide_hwif_t *hwif = drive->hwif; 	ide_drive_t *mate = ide_get_pair_dev(drive);-	u16 *mateid = mate->id;+	u16 *mateid; 	u8 mask = hwif->ultra_mask;  	if (mate == NULL) 		goto out;+	mateid = mate->id;  	if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) { 		if ((mateid[ATA_ID_FIELD_VALID] & 4) &&\0ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-12-08 16:55 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-08 16:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Linus, please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/
to receive the following updates:
 drivers/ide/Kconfig  |   14 +++----------- drivers/ide/ide-io.c |    6 ++++-- drivers/ide/pmac.c   |   30 +++--------------------------- 3 files changed, 10 insertions(+), 40 deletions(-)

Bartlomiej Zolnierkiewicz (2):      Revert "ide: respect current DMA setting during resume"      ide: build-fix for CONFIG_BLK_DEV_IDEDMA_PMAC=n

diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfigindex 6d74017..e6857e0 100644--- a/drivers/ide/Kconfig+++ b/drivers/ide/Kconfig@@ -669,10 +669,12 @@ config BLK_DEV_CELLEB  endif +# TODO: BLK_DEV_IDEDMA_PCI -> BLK_DEV_IDEDMA_SFF config BLK_DEV_IDE_PMAC 	tristate "PowerMac on-board IDE support" 	depends on PPC_PMAC && IDE=y 	select IDE_TIMINGS+	select BLK_DEV_IDEDMA_PCI 	help 	  This driver provides support for the on-board IDE controller on 	  most of the recent Apple Power Macintoshes and PowerBooks.@@ -689,16 +691,6 @@ config BLK_DEV_IDE_PMAC_ATA100FIRST 	  CD-ROM on hda. This option changes this to more natural hda for 	  hard disk and hdc for CD-ROM. -config BLK_DEV_IDEDMA_PMAC-	bool "PowerMac IDE DMA support"-	depends on BLK_DEV_IDE_PMAC-	select BLK_DEV_IDEDMA_PCI-	help-	  This option allows the driver for the on-board IDE controller on-	  Power Macintoshes and PowerBooks to use DMA (direct memory access)-	  to transfer data to and from memory.  Saying Y is safe and improves-	  performance.- config BLK_DEV_IDE_AU1XXX        bool "IDE for AMD Alchemy Au1200"        depends on SOC_AU1200@@ -912,7 +904,7 @@ config BLK_DEV_UMC8672 endif  config BLK_DEV_IDEDMA-	def_bool BLK_DEV_IDEDMA_SFF || BLK_DEV_IDEDMA_PMAC || \+	def_bool BLK_DEV_IDEDMA_SFF || \ 		 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA  endif # IDEdiff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.cindex 7d275b2..cc35d6d 100644--- a/drivers/ide/ide-io.c+++ b/drivers/ide/ide-io.c@@ -208,8 +208,10 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * 		 */ 		if (drive->hwif->dma_ops == NULL) 			break;-		if (drive->dev_flags & IDE_DFLAG_USING_DMA)-			ide_set_dma(drive);+		/*+		 * TODO: respect IDE_DFLAG_USING_DMA+		 */+		ide_set_dma(drive); 		break; 	} diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.cindex 2e19d62..7c481bb 100644--- a/drivers/ide/pmac.c+++ b/drivers/ide/pmac.c@@ -66,7 +66,6 @@ typedef struct pmac_ide_hwif { 	struct macio_dev		*mdev; 	u32				timings[4]; 	volatile u32 __iomem *		*kauai_fcr;-#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 	/* Those fields are duplicating what is in hwif. We currently 	 * can't use the hwif ones because of some assumptions that are 	 * beeing done by the generic code about the kind of dma controller@@ -74,8 +73,6 @@ typedef struct pmac_ide_hwif { 	 */ 	volatile struct dbdma_regs __iomem *	dma_regs; 	struct dbdma_cmd*		dma_table_cpu;-#endif-	 } pmac_ide_hwif_t;  enum {@@ -222,8 +219,6 @@ static const char* model_name[] = { #define KAUAI_FCR_UATA_RESET_N		0x00000002 #define KAUAI_FCR_UATA_ENABLE		0x00000001 -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC- /* Rounded Multiword DMA timings  *   * I gave up finding a generic formula for all controller@@ -413,8 +408,6 @@ static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); static void pmac_ide_selectproc(ide_drive_t *drive); static void pmac_ide_kauai_selectproc(ide_drive_t *drive); -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */- #define PMAC_IDE_REG(x) \ 	((void __iomem *)((drive)->hwif->io_ports.data_addr + (x))) @@ -584,8 +577,6 @@ pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) 	pmac_ide_do_update_timings(drive); } -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC- /*  * Calculate KeyLargo ATA/66 UDMA timings  */@@ -786,7 +777,6 @@ set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, 		drive->name, speed & 0xf,  *timings); #endif	 }-#endif /* #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC */  static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) {@@ -804,7 +794,6 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) 	tl[0] = *timings; 	tl[1] = *timings2; -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 	if (speed >= XFER_UDMA_0) { 		if (pmif->kind == controller_kl_ata4) 			ret = set_timings_udma_ata4(&tl[0], speed);@@ -817,7 +806,7 @@ static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) 			ret = -1; 	} else 		set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed);-#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */+ 	if (ret) 		return; @@ -1008,9 +997,7 @@ static const struct ide_port_info pmac_port_info = { 	.chipset		= ide_pmac, 	.tp_ops			= &pmac_tp_ops, 	.port_ops		= &pmac_ide_port_ops,-#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 	.dma_ops		= &pmac_dma_ops,-#endif 	.host_flags		= IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | 				  IDE_HFLAG_POST_SET_MODE | 				  IDE_HFLAG_MMIO |@@ -1182,7 +1169,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) 	pmif->regbase = regbase; 	pmif->irq = irq; 	pmif->kauai_fcr = NULL;-#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC+ 	if (macio_resource_count(mdev) >= 2) { 		if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) 			printk(KERN_WARNING "ide-pmac: can't request DMA "@@ -1192,7 +1179,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) 			pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); 	} else 		pmif->dma_regs = NULL;-#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */+ 	dev_set_drvdata(&mdev->ofdev.dev, pmif);  	memset(&hw, 0, sizeof(hw));@@ -1300,9 +1287,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)  	base = ioremap(rbase, rlen); 	pmif->regbase = (unsigned long) base + 0x2000;-#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 	pmif->dma_regs = base + 0x1000;-#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 	pmif->kauai_fcr = base; 	pmif->irq = pdev->irq; @@ -1434,8 +1419,6 @@ out: 	return error; } -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC- /*  * pmac_ide_build_dmatable builds the DBDMA command list  * for a transfer and sets the DBDMA channel to point to it.@@ -1723,13 +1706,6 @@ static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,  	return 0; }-#else-static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,-				       const struct ide_port_info *d)-{-	return -EOPNOTSUPP;-}-#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */  module_init(pmac_ide_probe); \0ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-10-05 16:38 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-10-05 16:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


The final polishing touch for 2.6.27...

[ Swarm commit outstands in diffstat but is a straightforward change. ]


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 arch/mips/sibyte/swarm/Makefile   |    3 +-
 arch/mips/sibyte/swarm/platform.c |   81 +++++++++++++++
 drivers/ide/Kconfig               |    4 -
 drivers/ide/ide-cd.c              |    6 +-
 drivers/ide/ide-dma.c             |    2 +-
 drivers/ide/ide-probe.c           |    2 +-
 drivers/ide/mips/Makefile         |    1 -
 drivers/ide/mips/swarm.c          |  197 -------------------------------------
 include/linux/ide.h               |    4 +-
 9 files changed, 93 insertions(+), 207 deletions(-)
 create mode 100644 arch/mips/sibyte/swarm/platform.c
 delete mode 100644 drivers/ide/mips/swarm.c


Bartlomiej Zolnierkiewicz (1):
      ide: workaround for bogus gcc warning in ide_sysfs_register_port()

Bodo Eggert (1):
      ide-cd: Optiarc DVD RW AD-7200A does play audio

Borislav Petkov (1):
      ide-cd: temporary tray close fix

Ralf Baechle (1):
      IDE: Fix platform device registration in Swarm IDE driver (v2)

Sergei Shtylylov (1):
      ide-dma: fix ide_build_dmatable() for TRM290


diff --git a/arch/mips/sibyte/swarm/Makefile b/arch/mips/sibyte/swarm/Makefile
index f18ba92..7b45f19 100644
--- a/arch/mips/sibyte/swarm/Makefile
+++ b/arch/mips/sibyte/swarm/Makefile
@@ -1,3 +1,4 @@
-obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
+obj-y				:= platform.o setup.o rtc_xicor1241.o \
+				   rtc_m41t81.o
 
 obj-$(CONFIG_I2C_BOARDINFO)	+= swarm-i2c.o
diff --git a/arch/mips/sibyte/swarm/platform.c b/arch/mips/sibyte/swarm/platform.c
new file mode 100644
index 0000000..dd0e5b9
--- /dev/null
+++ b/arch/mips/sibyte/swarm/platform.c
@@ -0,0 +1,81 @@
+#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/ata_platform.h>
+
+#include <asm/sibyte/board.h>
+#include <asm/sibyte/sb1250_genbus.h>
+#include <asm/sibyte/sb1250_regs.h>
+
+#define DRV_NAME	"pata-swarm"
+
+#define SWARM_IDE_SHIFT	5
+#define SWARM_IDE_BASE	0x1f0
+#define SWARM_IDE_CTRL	0x3f6
+
+static struct resource swarm_pata_resource[] = {
+	{
+		.name	= "Swarm GenBus IDE",
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.name	= "Swarm GenBus IDE",
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.name	= "Swarm GenBus IDE",
+		.flags	= IORESOURCE_IRQ,
+		.start	= K_INT_GB_IDE,
+		.end	= K_INT_GB_IDE,
+	},
+};
+
+static struct pata_platform_info pata_platform_data = {
+	.ioport_shift	= SWARM_IDE_SHIFT,
+};
+
+static struct platform_device swarm_pata_device = {
+	.name		= "pata_platform",
+	.id		= -1,
+	.resource	= swarm_pata_resource,
+	.num_resources	= ARRAY_SIZE(swarm_pata_resource),
+	.dev  = {
+		.platform_data		= &pata_platform_data,
+		.coherent_dma_mask	= ~0,	/* grumble */
+	},
+};
+
+static int __init swarm_pata_init(void)
+{
+	u8 __iomem *base;
+	phys_t offset, size;
+	struct resource *r;
+
+	if (!SIBYTE_HAVE_IDE)
+		return -ENODEV;
+
+	base = ioremap(A_IO_EXT_BASE, 0x800);
+	offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
+	size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
+	iounmap(base);
+
+	offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
+	size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
+	if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
+		pr_info(DRV_NAME ": PATA interface at GenBus disabled\n");
+
+		return -EBUSY;
+	}
+
+	pr_info(DRV_NAME ": PATA interface at GenBus slot %i\n", IDE_CS);
+
+	r = swarm_pata_resource;
+	r[0].start = offset + (SWARM_IDE_BASE << SWARM_IDE_SHIFT);
+	r[0].end   = offset + ((SWARM_IDE_BASE + 8) << SWARM_IDE_SHIFT) - 1;
+	r[1].start = offset + (SWARM_IDE_CTRL << SWARM_IDE_SHIFT);
+	r[1].end   = offset + ((SWARM_IDE_CTRL + 1) << SWARM_IDE_SHIFT) - 1;
+
+	return platform_device_register(&swarm_pata_device);
+}
+
+device_initcall(swarm_pata_init);
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 8e93a79..052879a 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -780,10 +780,6 @@ config BLK_DEV_IDEDMA_PMAC
 	  to transfer data to and from memory.  Saying Y is safe and improves
 	  performance.
 
-config BLK_DEV_IDE_SWARM
-	tristate "IDE for Sibyte evaluation boards"
-	depends on SIBYTE_SB1xxx_SOC
-
 config BLK_DEV_IDE_AU1XXX
        bool "IDE for AMD Alchemy Au1200"
        depends on SOC_AU1200
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 49a8c58..f16bb46 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1661,7 +1661,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
 		cdi->mask &= ~CDC_PLAY_AUDIO;
 
 	mechtype = buf[8 + 6] >> 5;
-	if (mechtype == mechtype_caddy || mechtype == mechtype_popup)
+	if (mechtype == mechtype_caddy ||
+	    mechtype == mechtype_popup ||
+	    (drive->atapi_flags & IDE_AFLAG_NO_AUTOCLOSE))
 		cdi->mask |= CDC_CLOSE_TRAY;
 
 	if (cdi->sanyo_slot > 0) {
@@ -1859,6 +1861,8 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
 	{ "MATSHITADVD-ROM SR-8176", NULL,   IDE_AFLAG_PLAY_AUDIO_OK	     },
 	{ "MATSHITADVD-ROM SR-8174", NULL,   IDE_AFLAG_PLAY_AUDIO_OK	     },
 	{ "Optiarc DVD RW AD-5200A", NULL,   IDE_AFLAG_PLAY_AUDIO_OK	     },
+	{ "Optiarc DVD RW AD-7200A", NULL,   IDE_AFLAG_PLAY_AUDIO_OK	     },
+	{ "Optiarc DVD RW AD-7543A", NULL,   IDE_AFLAG_NO_AUTOCLOSE	     },
 	{ NULL, NULL, 0 }
 };
 
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index adc6827..3fa07c0 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -211,7 +211,7 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
 				xcount = bcount & 0xffff;
 				if (is_trm290)
 					xcount = ((xcount >> 2) - 1) << 16;
-				if (xcount == 0x0000) {
+				else if (xcount == 0x0000) {
 	/* 
 	 * Most chipsets correctly interpret a length of 0x0000 as 64KB,
 	 * but at least one (e.g. CS5530) misinterprets it as zero (!).
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 994e410..a51a30e 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1492,7 +1492,7 @@ static struct device_attribute *ide_port_attrs[] = {
 
 static int ide_sysfs_register_port(ide_hwif_t *hwif)
 {
-	int i, rc;
+	int i, uninitialized_var(rc);
 
 	for (i = 0; ide_port_attrs[i]; i++) {
 		rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
index 677c7b2..5873fa0 100644
--- a/drivers/ide/mips/Makefile
+++ b/drivers/ide/mips/Makefile
@@ -1,4 +1,3 @@
-obj-$(CONFIG_BLK_DEV_IDE_SWARM)		+= swarm.o
 obj-$(CONFIG_BLK_DEV_IDE_AU1XXX)	+= au1xxx-ide.o
 
 EXTRA_CFLAGS    := -Idrivers/ide
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
deleted file mode 100644
index 39c9ee9..0000000
--- a/drivers/ide/mips/swarm.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2001, 2002, 2003 Broadcom Corporation
- * Copyright (C) 2004 MontaVista Software Inc.
- *	Author:	Manish Lachwani, mlachwani@mvista.com
- * Copyright (C) 2004  MIPS Technologies, Inc.  All rights reserved.
- *	Author: Maciej W. Rozycki <macro@mips.com>
- * Copyright (c) 2006, 2008  Maciej W. Rozycki
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-/*
- *  Derived loosely from ide-pmac.c, so:
- *  Copyright (C) 1998 Paul Mackerras.
- *  Copyright (C) 1995-1998 Mark Lord
- */
-
-/*
- * Boards with SiByte processors so far have supported IDE devices via
- * the Generic Bus, PCI bus, and built-in PCMCIA interface.  In all
- * cases, byte-swapping must be avoided for these devices (whereas
- * other PCI devices, for example, will require swapping).  Any
- * SiByte-targetted kernel including IDE support will include this
- * file.  Probing of a Generic Bus for an IDE device is controlled by
- * the definition of "SIBYTE_HAVE_IDE", which is provided by
- * <asm/sibyte/board.h> for Broadcom boards.
- */
-
-#include <linux/ide.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/platform_device.h>
-
-#include <asm/io.h>
-
-#include <asm/sibyte/board.h>
-#include <asm/sibyte/sb1250_genbus.h>
-#include <asm/sibyte/sb1250_regs.h>
-
-#define DRV_NAME "ide-swarm"
-
-static char swarm_ide_string[] = DRV_NAME;
-
-static struct resource swarm_ide_resource = {
-	.name	= "SWARM GenBus IDE",
-	.flags	= IORESOURCE_MEM,
-};
-
-static struct platform_device *swarm_ide_dev;
-
-static const struct ide_port_info swarm_port_info = {
-	.name			= DRV_NAME,
-	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
-};
-
-/*
- * swarm_ide_probe - if the board header indicates the existence of
- * Generic Bus IDE, allocate a HWIF for it.
- */
-static int __devinit swarm_ide_probe(struct device *dev)
-{
-	u8 __iomem *base;
-	struct ide_host *host;
-	phys_t offset, size;
-	int i, rc;
-	hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
-
-	if (!SIBYTE_HAVE_IDE)
-		return -ENODEV;
-
-	base = ioremap(A_IO_EXT_BASE, 0x800);
-	offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
-	size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
-	iounmap(base);
-
-	offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
-	size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
-	if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
-		printk(KERN_INFO DRV_NAME
-		       ": IDE interface at GenBus disabled\n");
-		return -EBUSY;
-	}
-
-	printk(KERN_INFO DRV_NAME ": IDE interface at GenBus slot %i\n",
-	       IDE_CS);
-
-	swarm_ide_resource.start = offset;
-	swarm_ide_resource.end = offset + size - 1;
-	if (request_resource(&iomem_resource, &swarm_ide_resource)) {
-		printk(KERN_ERR DRV_NAME
-		       ": can't request I/O memory resource\n");
-		return -EBUSY;
-	}
-
-	base = ioremap(offset, size);
-
-	memset(&hw, 0, sizeof(hw));
-	for (i = 0; i <= 7; i++)
-		hw.io_ports_array[i] =
-				(unsigned long)(base + ((0x1f0 + i) << 5));
-	hw.io_ports.ctl_addr =
-				(unsigned long)(base + (0x3f6 << 5));
-	hw.irq = K_INT_GB_IDE;
-	hw.chipset = ide_generic;
-
-	rc = ide_host_add(&swarm_port_info, hws, &host);
-	if (rc)
-		goto err;
-
-	dev_set_drvdata(dev, host);
-
-	return 0;
-err:
-	release_resource(&swarm_ide_resource);
-	iounmap(base);
-	return rc;
-}
-
-static struct device_driver swarm_ide_driver = {
-	.name	= swarm_ide_string,
-	.bus	= &platform_bus_type,
-	.probe	= swarm_ide_probe,
-};
-
-static void swarm_ide_platform_release(struct device *device)
-{
-	struct platform_device *pldev;
-
-	/* free device */
-	pldev = to_platform_device(device);
-	kfree(pldev);
-}
-
-static int __devinit swarm_ide_init_module(void)
-{
-	struct platform_device *pldev;
-	int err;
-
-	printk(KERN_INFO "SWARM IDE driver\n");
-
-	if (driver_register(&swarm_ide_driver)) {
-		printk(KERN_ERR "Driver registration failed\n");
-		err = -ENODEV;
-		goto out;
-	}
-
-        if (!(pldev = kzalloc(sizeof (*pldev), GFP_KERNEL))) {
-		err = -ENOMEM;
-		goto out_unregister_driver;
-	}
-
-	pldev->name		= swarm_ide_string;
-	pldev->id		= 0;
-	pldev->dev.release	= swarm_ide_platform_release;
-
-	if (platform_device_register(pldev)) {
-		err = -ENODEV;
-		goto out_free_pldev;
-	}
-
-        if (!pldev->dev.driver) {
-		/*
-		 * The driver was not bound to this device, there was
-                 * no hardware at this address. Unregister it, as the
-		 * release fuction will take care of freeing the
-		 * allocated structure
-		 */
-		platform_device_unregister (pldev);
-	}
-
-	swarm_ide_dev = pldev;
-
-	return 0;
-
-out_free_pldev:
-	kfree(pldev);
-
-out_unregister_driver:
-	driver_unregister(&swarm_ide_driver);
-out:
-	return err;
-}
-
-module_init(swarm_ide_init_module);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 1524829..6514db8 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -366,7 +366,9 @@ enum {
 	/* Currently on a filemark */
 	IDE_AFLAG_FILEMARK		= (1 << 25),
 	/* 0 = no tape is loaded, so we don't rewind after ejecting */
-	IDE_AFLAG_MEDIUM_PRESENT	= (1 << 26)
+	IDE_AFLAG_MEDIUM_PRESENT	= (1 << 26),
+
+	IDE_AFLAG_NO_AUTOCLOSE		= (1 << 27),
 };
 
 struct ide_drive_s {

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-09-27 17:47 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-27 17:47 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 Documentation/ioctl/cdrom.txt |    4 ++--
 drivers/ide/Kconfig           |   14 ++++++++++++++
 drivers/ide/ide-tape.c        |   10 +++++-----
 drivers/ide/mips/swarm.c      |    1 +
 4 files changed, 22 insertions(+), 7 deletions(-)


Borislav Petkov (1):
      ide-tape: fix vendor strings

Márton Németh (1):
      cdrom: update ioctl documentation

Ralf Baechle (1):
      Swarm: Fix crash due to missing initialization

Tejun Heo (1):
      ide: note that IDE generic may prevent other drivers from attaching


diff --git a/Documentation/ioctl/cdrom.txt b/Documentation/ioctl/cdrom.txt
index 62d4af4..59df81c 100644
--- a/Documentation/ioctl/cdrom.txt
+++ b/Documentation/ioctl/cdrom.txt
@@ -271,14 +271,14 @@ CDROMCLOSETRAY			pendant of CDROMEJECT
 
 	usage:
 
-	  ioctl(fd, CDROMEJECT, 0);
+	  ioctl(fd, CDROMCLOSETRAY, 0);
 
 	inputs:		none
 
 	outputs:	none
 
 	error returns:
-	  ENOSYS	cd drive not capable of ejecting
+	  ENOSYS	cd drive not capable of closing the tray
 	  EBUSY		other processes are accessing drive, or door is locked
 
 	notes:
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index fc735ab..8e93a79 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -292,6 +292,20 @@ config IDE_GENERIC
 	tristate "generic/default IDE chipset support"
 	depends on ALPHA || X86 || IA64 || M32R || MIPS
 	help
+	  This is the generic IDE driver.  This driver attaches to the
+	  fixed legacy ports (e.g. on PCs 0x1f0/0x170, 0x1e8/0x168 and
+	  so on).  Please note that if this driver is built into the
+	  kernel or loaded before other ATA (IDE or libata) drivers
+	  and the controller is located at legacy ports, this driver
+	  may grab those ports and thus can prevent the controller
+	  specific driver from attaching.
+
+	  Also, currently, IDE generic doesn't allow IRQ sharing
+	  meaning that the IRQs it grabs won't be available to other
+	  controllers sharing those IRQs which usually makes drivers
+	  for those controllers fail.  Generally, it's not a good idea
+	  to load IDE generic driver on modern systems.
+
 	  If unsure, say N.
 
 config BLK_DEV_PLATFORM
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1bce84b..3833189 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2338,7 +2338,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	struct ide_atapi_pc pc;
-	char fw_rev[6], vendor_id[10], product_id[18];
+	char fw_rev[4], vendor_id[8], product_id[16];
 
 	idetape_create_inquiry_cmd(&pc);
 	if (idetape_queue_pc_tail(drive, &pc)) {
@@ -2350,11 +2350,11 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
 	memcpy(product_id, &pc.buf[16], 16);
 	memcpy(fw_rev, &pc.buf[32], 4);
 
-	ide_fixstring(vendor_id, 10, 0);
-	ide_fixstring(product_id, 18, 0);
-	ide_fixstring(fw_rev, 6, 0);
+	ide_fixstring(vendor_id, 8, 0);
+	ide_fixstring(product_id, 16, 0);
+	ide_fixstring(fw_rev, 4, 0);
 
-	printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n",
+	printk(KERN_INFO "ide-tape: %s <-> %s: %.8s %.16s rev %.4s\n",
 			drive->name, tape->name, vendor_id, product_id, fw_rev);
 }
 
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
index badf79f..39c9ee9 100644
--- a/drivers/ide/mips/swarm.c
+++ b/drivers/ide/mips/swarm.c
@@ -107,6 +107,7 @@ static int __devinit swarm_ide_probe(struct device *dev)
 
 	base = ioremap(offset, size);
 
+	memset(&hw, 0, sizeof(hw));
 	for (i = 0; i <= 7; i++)
 		hw.io_ports_array[i] =
 				(unsigned long)(base + ((0x1f0 + i) << 5));

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-09-10 20:47 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-10 20:47 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Hopefully the last pull request before 2.6.27-final:

* Fixes hpt366 crash with HPT374 controllers
  (Masoud Sharbiani and Sergei Shtylyov).

* Adds ide-scsi to feature-removal-schedule.txt,
  which I forgot to do while deprecating the driver
  (FUJITA Tomonori).

BTW I'll be leaving for KS+LPC on Saturday's morning
so I may be a bit unresponsive for a while (preparations,
travelling and a "time zone change syndrome").


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 Documentation/feature-removal-schedule.txt |    8 +++++++
 drivers/ide/pci/hpt366.c                   |   31 +++++++++++++--------------
 2 files changed, 23 insertions(+), 16 deletions(-)


FUJITA Tomonori (1):
      add deprecated ide-scsi to feature-removal-schedule.txt

Masoud Sharbiani (1):
      ide: Fix pointer arithmetic in hpt3xx driver code (3rd try)


diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index eb1a47b..83c88ca 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -322,3 +322,11 @@ Why:  Accounting can now be enabled/disabled without kernel recompilation.
       controlled by a kernel/module/sysfs/sysctl parameter.
 Who:  Krzysztof Piotr Oledzki <ole@ans.pl>
 
+---------------------------
+
+What: ide-scsi (BLK_DEV_IDESCSI)
+When: 2.6.29
+Why:  The 2.6 kernel supports direct writing to ide CD drives, which
+      eliminates the need for ide-scsi. The new method is more
+      efficient in every way.
+Who:  FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index eb107ee..c37ab17 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -613,6 +613,14 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list)
 	return 0;
 }
 
+static struct hpt_info *hpt3xx_get_info(struct device *dev)
+{
+	struct ide_host *host	= dev_get_drvdata(dev);
+	struct hpt_info *info	= (struct hpt_info *)host->host_priv;
+
+	return dev == host->dev[1] ? info + 1 : info;
+}
+
 /*
  * The Marvell bridge chips used on the HighPoint SATA cards do not seem
  * to support the UltraDMA modes 1, 2, and 3 as well as any MWDMA modes...
@@ -621,9 +629,7 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list)
 static u8 hpt3xx_udma_filter(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct pci_dev *dev	= to_pci_dev(hwif->dev);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 	u8 mask 		= hwif->ultra_mask;
 
 	switch (info->chip_type) {
@@ -662,9 +668,7 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive)
 static u8 hpt3xx_mdma_filter(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct pci_dev *dev	= to_pci_dev(hwif->dev);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 
 	switch (info->chip_type) {
 	case HPT372 :
@@ -700,8 +704,7 @@ static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
 {
 	ide_hwif_t *hwif	= drive->hwif;
 	struct pci_dev *dev	= to_pci_dev(hwif->dev);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 	struct hpt_timings *t	= info->timings;
 	u8  itr_addr		= 0x40 + (drive->dn * 4);
 	u32 old_itr		= 0;
@@ -744,8 +747,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev	*dev	= to_pci_dev(hwif->dev);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 
 	if (drive->quirk_list) {
 		if (info->chip_type >= HPT370) {
@@ -973,8 +975,7 @@ static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f
 static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev)
 {
 	unsigned long io_base	= pci_resource_start(dev, 4);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (&dev->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(&dev->dev);
 	const char *name	= DRV_NAME;
 	u8 pci_clk,  dpll_clk	= 0;	/* PCI and DPLL clock in MHz */
 	u8 chip_type;
@@ -1217,8 +1218,7 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev)
 static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
 {
 	struct pci_dev	*dev	= to_pci_dev(hwif->dev);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 	u8 chip_type		= info->chip_type;
 	u8 scr1 = 0, ata66	= hwif->channel ? 0x01 : 0x02;
 
@@ -1262,8 +1262,7 @@ static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
 {
 	struct pci_dev *dev	= to_pci_dev(hwif->dev);
-	struct ide_host *host	= pci_get_drvdata(dev);
-	struct hpt_info *info	= host->host_priv + (hwif->dev == host->dev[1]);
+	struct hpt_info *info	= hpt3xx_get_info(hwif->dev);
 	int serialize		= HPT_SERIALIZE_IO;
 	u8  chip_type		= info->chip_type;
 	u8  new_mcr, old_mcr	= 0;

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-09-02 18:24 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-02 18:24 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 drivers/ide/Kconfig           |   16 +---------------
 drivers/ide/arm/palm_bk3710.c |    8 +++-----
 drivers/ide/ide-disk.c        |   14 --------------
 include/linux/ide.h           |    5 ++---
 4 files changed, 6 insertions(+), 37 deletions(-)


Bartlomiej Zolnierkiewicz (3):
      ide: fix hwif_to_node()
      ide-disk: remove stale init_idedisk_capacity() documentation
      ide/Kconfig: mark ide-scsi as deprecated

David Brownell (1):
      palm_bk3710: improve IDE registration

Kevin Hilman (2):
      IDE: compile fix for sff_dma_ops
      IDE: palm_bk3710: fix compile warning for unused variable


diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index a34758d..fc735ab 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -242,7 +242,7 @@ config BLK_DEV_IDEFLOPPY
 	  module will be called ide-floppy.
 
 config BLK_DEV_IDESCSI
-	tristate "SCSI emulation support"
+	tristate "SCSI emulation support (DEPRECATED)"
 	depends on SCSI
 	select IDE_ATAPI
 	---help---
@@ -255,20 +255,6 @@ config BLK_DEV_IDESCSI
 	  and will allow you to use a SCSI device driver instead of a native
 	  ATAPI driver.
 
-	  This is useful if you have an ATAPI device for which no native
-	  driver has been written (for example, an ATAPI PD-CD drive);
-	  you can then use this emulation together with an appropriate SCSI
-	  device driver. In order to do this, say Y here and to "SCSI support"
-	  and "SCSI generic support", below. You must then provide the kernel
-	  command line "hdx=ide-scsi" (try "man bootparam" or see the
-	  documentation of your boot loader (lilo or loadlin) about how to
-	  pass options to the kernel at boot time) for devices if you want the
-	  native EIDE sub-drivers to skip over the native support, so that
-	  this SCSI emulation can be used instead.
-
-	  Note that this option does NOT allow you to attach SCSI devices to a
-	  box that doesn't have a SCSI host adapter installed.
-
 	  If both this SCSI emulation and native ATAPI support are compiled
 	  into the kernel, the native support will be used.
 
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index f788fa5..4fd91dc 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -343,11 +343,10 @@ static struct ide_port_info __devinitdata palm_bk3710_port_info = {
 	.mwdma_mask		= ATA_MWDMA2,
 };
 
-static int __devinit palm_bk3710_probe(struct platform_device *pdev)
+static int __init palm_bk3710_probe(struct platform_device *pdev)
 {
 	struct clk *clk;
 	struct resource *mem, *irq;
-	struct ide_host *host;
 	unsigned long base, rate;
 	int i, rc;
 	hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
@@ -390,6 +389,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
 		hw.io_ports_array[i] = base + IDE_PALM_ATA_PRI_REG_OFFSET + i;
 	hw.io_ports.ctl_addr = base + IDE_PALM_ATA_PRI_CTL_OFFSET;
 	hw.irq = irq->start;
+	hw.dev = &pdev->dev;
 	hw.chipset = ide_palm3710;
 
 	palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 :
@@ -413,13 +413,11 @@ static struct platform_driver platform_bk_driver = {
 		.name = "palm_bk3710",
 		.owner = THIS_MODULE,
 	},
-	.probe = palm_bk3710_probe,
-	.remove = NULL,
 };
 
 static int __init palm_bk3710_init(void)
 {
-	return platform_driver_register(&platform_bk_driver);
+	return platform_driver_probe(&platform_bk_driver, palm_bk3710_probe);
 }
 
 module_init(palm_bk3710_init);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 68b9cf0..07ef88b 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -445,20 +445,6 @@ static void idedisk_check_hpa(ide_drive_t *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)
 {
 	struct hd_driveid *id = drive->id;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 87c12ed..1524829 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1111,7 +1111,6 @@ void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 int ide_pci_set_master(struct pci_dev *, const char *);
 unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
-extern const struct ide_dma_ops sff_dma_ops;
 int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *);
 int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
 #else
@@ -1275,6 +1274,7 @@ extern int __ide_dma_end(ide_drive_t *);
 int ide_dma_test_irq(ide_drive_t *);
 extern void ide_dma_lost_irq(ide_drive_t *);
 extern void ide_dma_timeout(ide_drive_t *);
+extern const struct ide_dma_ops sff_dma_ops;
 #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */
 
 #else
@@ -1448,8 +1448,7 @@ static inline void ide_dump_identify(u8 *id)
 
 static inline int hwif_to_node(ide_hwif_t *hwif)
 {
-	struct pci_dev *dev = to_pci_dev(hwif->dev);
-	return hwif->dev ? pcibus_to_node(dev->bus) : -1;
+	return hwif->dev ? dev_to_node(hwif->dev) : -1;
 }
 
 static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-08-18 20:22 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-08-18 20:22 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Inside:

* Some IDE PCI host drivers were not using __devexit_p() properly
  (Russell King discovered it the hard way & Adrian Bunk fixed it).

* Fix audio capabilities checking in cdrom.c (from Alexander Inyukhin
  with gdrom/viocd pre-fixes from Borislav Petkov).

* Add missing ATA_* defines to <linux/ata.h>, not fixes per-se
  but since they are obvious and merging it now will save us some
  merge conflicts in linux-next lets do it now.

* Misc obvious fixups/cleanups.

* No octopus.


Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 arch/powerpc/include/asm/ide.h |   43 +-----------
 drivers/cdrom/cdrom.c          |    7 --
 drivers/cdrom/gdrom.c          |    7 ++
 drivers/cdrom/viocd.c          |    7 ++
 drivers/ide/ide-cd.c           |   20 +++---
 drivers/ide/pci/aec62xx.c      |    2 +-
 drivers/ide/pci/cy82c693.c     |    2 +-
 drivers/ide/pci/hpt366.c       |    2 +-
 drivers/ide/pci/it821x.c       |    2 +-
 drivers/ide/pci/pdc202xx_new.c |    2 +-
 drivers/ide/pci/scc_pata.c     |    2 +-
 drivers/ide/pci/sgiioc4.c      |    4 +-
 drivers/ide/pci/siimage.c      |    2 +-
 drivers/ide/pci/sis5513.c      |    2 +-
 drivers/ide/pci/tc86c001.c     |    2 +-
 drivers/ide/pci/via82cxxx.c    |    2 +-
 include/linux/ata.h            |  155 ++++++++++++++++++++++++++++------------
 17 files changed, 146 insertions(+), 117 deletions(-)


Adrian Bunk (3):
      drivers/ide/pci/: use __devexit_p()
      cleanup powerpc/include/asm/ide.h
      ide-cd: use bcd2bin/bin2bcd

Alexander Inyukhin (1):
      cdrom: handle TOC

Bartlomiej Zolnierkiewicz (4):
      sgiioc4: fixup message on resource allocation failure
      ata: add missing ATA_ID_* defines (take 2)
      ata: add missing ATA_CMD_* defines
      ata: add missing ATA_* defines

Borislav Petkov (2):
      viocd: add dummy audio ioctl handler
      gdrom: add dummy audio_ioctl handler


diff --git a/arch/powerpc/include/asm/ide.h b/arch/powerpc/include/asm/ide.h
index 048480e..da01b20 100644
--- a/arch/powerpc/include/asm/ide.h
+++ b/arch/powerpc/include/asm/ide.h
@@ -6,12 +6,7 @@
 #ifndef _ASM_POWERPC_IDE_H
 #define _ASM_POWERPC_IDE_H
 
-#ifdef __KERNEL__
-
-#ifndef __powerpc64__
-#include <linux/sched.h>
-#include <asm/mpc8xx.h>
-#endif
+#include <linux/compiler.h>
 #include <asm/io.h>
 
 #define __ide_mm_insw(p, a, c)	readsw((void __iomem *)(p), (a), (c))
@@ -19,40 +14,4 @@
 #define __ide_mm_outsw(p, a, c)	writesw((void __iomem *)(p), (a), (c))
 #define __ide_mm_outsl(p, a, c)	writesl((void __iomem *)(p), (a), (c))
 
-#ifndef  __powerpc64__
-#include <linux/ioport.h>
-
-/* FIXME: use ide_platform host driver */
-static __inline__ int ide_default_irq(unsigned long base)
-{
-#ifdef CONFIG_PPLUS
-	switch (base) {
-	case 0x1f0:	return 14;
-	case 0x170:	return 15;
-	}
-#endif
-	return 0;
-}
-
-/* FIXME: use ide_platform host driver */
-static __inline__ unsigned long ide_default_io_base(int index)
-{
-#ifdef CONFIG_PPLUS
-	switch (index) {
-	case 0:		return 0x1f0;
-	case 1:		return 0x170;
-	}
-#endif
-	return 0;
-}
-
-#ifdef CONFIG_BLK_DEV_MPC8xx_IDE
-#define IDE_ARCH_ACK_INTR  1
-#define ide_ack_intr(hwif) ((hwif)->ack_intr ? (hwif)->ack_intr(hwif) : 1)
-#endif
-
-#endif /* __powerpc64__ */
-
-#endif /* __KERNEL__ */
-
 #endif /* _ASM_POWERPC_IDE_H */
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index d9d1b65..74031de 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -408,7 +408,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
 	ENSURE(get_last_session, CDC_MULTI_SESSION);
 	ENSURE(get_mcn, CDC_MCN);
 	ENSURE(reset, CDC_RESET);
-	ENSURE(audio_ioctl, CDC_PLAY_AUDIO);
 	ENSURE(generic_packet, CDC_GENERIC_PACKET);
 	cdi->mc_flags = 0;
 	cdo->n_minors = 0;
@@ -2506,8 +2505,6 @@ static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi,
 
 	/* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/
 
-	if (!CDROM_CAN(CDC_PLAY_AUDIO))
-		return -ENOSYS;
 	if (copy_from_user(&q, argp, sizeof(q)))
 		return -EFAULT;
 
@@ -2538,8 +2535,6 @@ static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi,
 
 	/* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */
 
-	if (!CDROM_CAN(CDC_PLAY_AUDIO))
-		return -ENOSYS;
 	if (copy_from_user(&header, argp, sizeof(header)))
 		return -EFAULT;
 
@@ -2562,8 +2557,6 @@ static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi,
 
 	/* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
 
-	if (!CDROM_CAN(CDC_PLAY_AUDIO))
-		return -ENOSYS;
 	if (copy_from_user(&entry, argp, sizeof(entry)))
 		return -EFAULT;
 
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 1e0455b..1231d95 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -471,6 +471,12 @@ cleanup_sense_final:
 	return err;
 }
 
+static int gdrom_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
+			     void *arg)
+{
+	return -EINVAL;
+}
+
 static struct cdrom_device_ops gdrom_ops = {
 	.open			= gdrom_open,
 	.release		= gdrom_release,
@@ -478,6 +484,7 @@ static struct cdrom_device_ops gdrom_ops = {
 	.media_changed		= gdrom_mediachanged,
 	.get_last_session	= gdrom_get_last_session,
 	.reset			= gdrom_hardreset,
+	.audio_ioctl		= gdrom_audio_ioctl,
 	.capability		= CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
 				  CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
 	.n_minors		= 1,
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 9d0dfe6..031e0e1 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -550,12 +550,19 @@ return_complete:
 	}
 }
 
+static int viocd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
+			     void *arg)
+{
+	return -EINVAL;
+}
+
 static struct cdrom_device_ops viocd_dops = {
 	.open = viocd_open,
 	.release = viocd_release,
 	.media_changed = viocd_media_changed,
 	.lock_door = viocd_lock_door,
 	.generic_packet = viocd_packet,
+	.audio_ioctl = viocd_audio_ioctl,
 	.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
 };
 
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 89a112d..49a8c58 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1272,9 +1272,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
  */
 static void msf_from_bcd(struct atapi_msf *msf)
 {
-	msf->minute = BCD2BIN(msf->minute);
-	msf->second = BCD2BIN(msf->second);
-	msf->frame  = BCD2BIN(msf->frame);
+	msf->minute = bcd2bin(msf->minute);
+	msf->second = bcd2bin(msf->second);
+	msf->frame  = bcd2bin(msf->frame);
 }
 
 int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
@@ -1415,8 +1415,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
 		return stat;
 
 	if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) {
-		toc->hdr.first_track = BCD2BIN(toc->hdr.first_track);
-		toc->hdr.last_track  = BCD2BIN(toc->hdr.last_track);
+		toc->hdr.first_track = bcd2bin(toc->hdr.first_track);
+		toc->hdr.last_track  = bcd2bin(toc->hdr.last_track);
 	}
 
 	ntracks = toc->hdr.last_track - toc->hdr.first_track + 1;
@@ -1456,8 +1456,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
 			return stat;
 
 		if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) {
-			toc->hdr.first_track = (u8)BIN2BCD(CDROM_LEADOUT);
-			toc->hdr.last_track = (u8)BIN2BCD(CDROM_LEADOUT);
+			toc->hdr.first_track = (u8)bin2bcd(CDROM_LEADOUT);
+			toc->hdr.last_track = (u8)bin2bcd(CDROM_LEADOUT);
 		} else {
 			toc->hdr.first_track = CDROM_LEADOUT;
 			toc->hdr.last_track = CDROM_LEADOUT;
@@ -1470,14 +1470,14 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
 	toc->hdr.toc_length = be16_to_cpu(toc->hdr.toc_length);
 
 	if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) {
-		toc->hdr.first_track = BCD2BIN(toc->hdr.first_track);
-		toc->hdr.last_track  = BCD2BIN(toc->hdr.last_track);
+		toc->hdr.first_track = bcd2bin(toc->hdr.first_track);
+		toc->hdr.last_track  = bcd2bin(toc->hdr.last_track);
 	}
 
 	for (i = 0; i <= ntracks; i++) {
 		if (drive->atapi_flags & IDE_AFLAG_TOCADDR_AS_BCD) {
 			if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD)
-				toc->ent[i].track = BCD2BIN(toc->ent[i].track);
+				toc->ent[i].track = bcd2bin(toc->ent[i].track);
 			msf_from_bcd(&toc->ent[i].addr.msf);
 		}
 		toc->ent[i].addr.lba = msf_to_lba(toc->ent[i].addr.msf.minute,
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 40644b6..3187215 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -307,7 +307,7 @@ static struct pci_driver driver = {
 	.name		= "AEC62xx_IDE",
 	.id_table	= aec62xx_pci_tbl,
 	.probe		= aec62xx_init_one,
-	.remove		= aec62xx_remove,
+	.remove		= __devexit_p(aec62xx_remove),
 };
 
 static int __init aec62xx_ide_init(void)
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index bfae2f8..e6d8ee8 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -447,7 +447,7 @@ static struct pci_driver driver = {
 	.name		= "Cypress_IDE",
 	.id_table	= cy82c693_pci_tbl,
 	.probe		= cy82c693_init_one,
-	.remove		= cy82c693_remove,
+	.remove		= __devexit_p(cy82c693_remove),
 };
 
 static int __init cy82c693_ide_init(void)
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 748793a..eb107ee 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1620,7 +1620,7 @@ static struct pci_driver driver = {
 	.name		= "HPT366_IDE",
 	.id_table	= hpt366_pci_tbl,
 	.probe		= hpt366_init_one,
-	.remove		= hpt366_remove,
+	.remove		= __devexit_p(hpt366_remove),
 };
 
 static int __init hpt366_ide_init(void)
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index b6dc723..4a1508a 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -686,7 +686,7 @@ static struct pci_driver driver = {
 	.name		= "ITE821x IDE",
 	.id_table	= it821x_pci_tbl,
 	.probe		= it821x_init_one,
-	.remove		= it821x_remove,
+	.remove		= __devexit_p(it821x_remove),
 };
 
 static int __init it821x_ide_init(void)
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 0f609b7..d477da6 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -566,7 +566,7 @@ static struct pci_driver driver = {
 	.name		= "Promise_IDE",
 	.id_table	= pdc202new_pci_tbl,
 	.probe		= pdc202new_init_one,
-	.remove		= pdc202new_remove,
+	.remove		= __devexit_p(pdc202new_remove),
 };
 
 static int __init pdc202new_ide_init(void)
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 6cde48b..44cccd1 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -954,7 +954,7 @@ static struct pci_driver driver = {
 	.name = "SCC IDE",
 	.id_table = scc_pci_tbl,
 	.probe = scc_init_one,
-	.remove = scc_remove,
+	.remove = __devexit_p(scc_remove),
 };
 
 static int scc_ide_init(void)
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 42eef19..681306c 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -621,9 +621,9 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
 	if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
 	    DRV_NAME)) {
 		printk(KERN_ERR
-			"%s : %s -- ERROR, Addresses "
+			"%s %s: -- ERROR, Addresses "
 			"0x%p to 0x%p ALREADY in use\n",
-		       __func__, DRV_NAME, (void *) cmd_phys_base,
+		       DRV_NAME, pci_name(dev), (void *)cmd_phys_base,
 		       (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
 		return -ENOMEM;
 	}
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 445ce6f..db2b88a 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -832,7 +832,7 @@ static struct pci_driver driver = {
 	.name		= "SiI_IDE",
 	.id_table	= siimage_pci_tbl,
 	.probe		= siimage_init_one,
-	.remove		= siimage_remove,
+	.remove		= __devexit_p(siimage_remove),
 };
 
 static int __init siimage_ide_init(void)
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index e5a4b42..5efe21d 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -610,7 +610,7 @@ static struct pci_driver driver = {
 	.name		= "SIS_IDE",
 	.id_table	= sis5513_pci_tbl,
 	.probe		= sis5513_init_one,
-	.remove		= sis5513_remove,
+	.remove		= __devexit_p(sis5513_remove),
 };
 
 static int __init sis5513_ide_init(void)
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 7fc88c3..927277c 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -249,7 +249,7 @@ static struct pci_driver driver = {
 	.name		= "TC86C001",
 	.id_table	= tc86c001_pci_tbl,
 	.probe		= tc86c001_init_one,
-	.remove		= tc86c001_remove,
+	.remove		= __devexit_p(tc86c001_remove),
 };
 
 static int __init tc86c001_ide_init(void)
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index a6b2cc8..94fb9ab 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -491,7 +491,7 @@ static struct pci_driver driver = {
 	.name 		= "VIA_IDE",
 	.id_table 	= via_pci_tbl,
 	.probe 		= via_init_one,
-	.remove		= via_remove,
+	.remove		= __devexit_p(via_remove),
 };
 
 static int __init via_ide_init(void)
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 1c622e2..1ce19c1 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -46,18 +46,48 @@ enum {
 	ATA_MAX_SECTORS_TAPE	= 65535,
 
 	ATA_ID_WORDS		= 256,
+	ATA_ID_CONFIG		= 0,
+	ATA_ID_CYLS		= 1,
+	ATA_ID_HEADS		= 3,
+	ATA_ID_SECTORS		= 6,
 	ATA_ID_SERNO		= 10,
+	ATA_ID_BUF_SIZE		= 21,
 	ATA_ID_FW_REV		= 23,
 	ATA_ID_PROD		= 27,
+	ATA_ID_MAX_MULTSECT	= 47,
+	ATA_ID_DWORD_IO		= 48,
+	ATA_ID_CAPABILITY	= 49,
 	ATA_ID_OLD_PIO_MODES	= 51,
+	ATA_ID_OLD_DMA_MODES	= 52,
 	ATA_ID_FIELD_VALID	= 53,
+	ATA_ID_CUR_CYLS		= 54,
+	ATA_ID_CUR_HEADS	= 55,
+	ATA_ID_CUR_SECTORS	= 56,
+	ATA_ID_MULTSECT		= 59,
+	ATA_ID_LBA_CAPACITY	= 60,
+	ATA_ID_SWDMA_MODES	= 62,
 	ATA_ID_MWDMA_MODES	= 63,
 	ATA_ID_PIO_MODES	= 64,
 	ATA_ID_EIDE_DMA_MIN	= 65,
+	ATA_ID_EIDE_DMA_TIME	= 66,
 	ATA_ID_EIDE_PIO		= 67,
 	ATA_ID_EIDE_PIO_IORDY	= 68,
-	ATA_ID_UDMA_MODES	= 88,
+	ATA_ID_QUEUE_DEPTH	= 75,
 	ATA_ID_MAJOR_VER	= 80,
+	ATA_ID_COMMAND_SET_1	= 82,
+	ATA_ID_COMMAND_SET_2	= 83,
+	ATA_ID_CFSSE		= 84,
+	ATA_ID_CFS_ENABLE_1	= 85,
+	ATA_ID_CFS_ENABLE_2	= 86,
+	ATA_ID_CSF_DEFAULT	= 87,
+	ATA_ID_UDMA_MODES	= 88,
+	ATA_ID_HW_CONFIG	= 93,
+	ATA_ID_SPG		= 98,
+	ATA_ID_LBA_CAPACITY_2	= 100,
+	ATA_ID_LAST_LUN		= 126,
+	ATA_ID_DLF		= 128,
+	ATA_ID_CSFO		= 129,
+	ATA_ID_CFA_POWER	= 160,
 	ATA_ID_PIO4		= (1 << 1),
 
 	ATA_ID_SERNO_LEN	= 20,
@@ -123,13 +153,26 @@ enum {
 	ATA_BUSY		= (1 << 7),	/* BSY status bit */
 	ATA_DRDY		= (1 << 6),	/* device ready */
 	ATA_DF			= (1 << 5),	/* device fault */
+	ATA_DSC			= (1 << 4),	/* drive seek complete */
 	ATA_DRQ			= (1 << 3),	/* data request i/o */
+	ATA_CORR		= (1 << 2),	/* corrected data error */
+	ATA_IDX			= (1 << 1),	/* index */
 	ATA_ERR			= (1 << 0),	/* have an error */
 	ATA_SRST		= (1 << 2),	/* software reset */
 	ATA_ICRC		= (1 << 7),	/* interface CRC error */
+	ATA_BBK			= ATA_ICRC,	/* pre-EIDE: block marked bad */
 	ATA_UNC			= (1 << 6),	/* uncorrectable media error */
+	ATA_MC			= (1 << 5),	/* media changed */
 	ATA_IDNF		= (1 << 4),	/* ID not found */
+	ATA_MCR			= (1 << 3),	/* media change requested */
 	ATA_ABORTED		= (1 << 2),	/* command aborted */
+	ATA_TRK0NF		= (1 << 1),	/* track 0 not found */
+	ATA_AMNF		= (1 << 0),	/* address mark not found */
+	ATAPI_LFS		= 0xF0,		/* last failed sense */
+	ATAPI_EOM		= ATA_TRK0NF,	/* end of media */
+	ATAPI_ILI		= ATA_AMNF,	/* illegal length indication */
+	ATAPI_IO		= (1 << 1),
+	ATAPI_COD		= (1 << 0),
 
 	/* ATA command block registers */
 	ATA_REG_DATA		= 0x00,
@@ -192,6 +235,13 @@ enum {
 	ATA_CMD_PMP_WRITE	= 0xE8,
 	ATA_CMD_CONF_OVERLAY	= 0xB1,
 	ATA_CMD_SEC_FREEZE_LOCK	= 0xF5,
+	ATA_CMD_SMART		= 0xB0,
+	ATA_CMD_MEDIA_LOCK	= 0xDE,
+	ATA_CMD_MEDIA_UNLOCK	= 0xDF,
+	/* marked obsolete in the ATA/ATAPI-7 spec */
+	ATA_CMD_RESTORE		= 0x10,
+	/* EXABYTE specific */
+	ATA_EXABYTE_ENABLE_NEST	= 0xF0,
 
 	/* READ_LOG_EXT pages */
 	ATA_LOG_SATA_NCQ	= 0x10,
@@ -232,6 +282,10 @@ enum {
 	SETFEATURES_WC_ON	= 0x02, /* Enable write cache */
 	SETFEATURES_WC_OFF	= 0x82, /* Disable write cache */
 
+	/* Enable/Disable Automatic Acoustic Management */
+	SETFEATURES_AAM_ON	= 0x42,
+	SETFEATURES_AAM_OFF	= 0xC2,
+
 	SETFEATURES_SPINUP	= 0x07, /* Spin-up drive */
 
 	SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */
@@ -254,6 +308,15 @@ enum {
 	ATA_DCO_IDENTIFY	= 0xC2,
 	ATA_DCO_SET		= 0xC3,
 
+	/* feature values for SMART */
+	ATA_SMART_ENABLE	= 0xD8,
+	ATA_SMART_READ_VALUES	= 0xD0,
+	ATA_SMART_READ_THRESHOLDS = 0xD1,
+
+	/* password used in LBA Mid / LBA High for executing SMART commands */
+	ATA_SMART_LBAM_PASS	= 0x4F,
+	ATA_SMART_LBAH_PASS	= 0xC2,
+
 	/* ATAPI stuff */
 	ATAPI_PKT_DMA		= (1 << 0),
 	ATAPI_DMADIR		= (1 << 2),	/* ATAPI data dir:
@@ -438,17 +501,17 @@ static inline int ata_is_data(u8 prot)
 /*
  * id tests
  */
-#define ata_id_is_ata(id)	(((id)[0] & (1 << 15)) == 0)
-#define ata_id_has_lba(id)	((id)[49] & (1 << 9))
-#define ata_id_has_dma(id)	((id)[49] & (1 << 8))
+#define ata_id_is_ata(id)	(((id)[ATA_ID_CONFIG] & (1 << 15)) == 0)
+#define ata_id_has_lba(id)	((id)[ATA_ID_CAPABILITY] & (1 << 9))
+#define ata_id_has_dma(id)	((id)[ATA_ID_CAPABILITY] & (1 << 8))
 #define ata_id_has_ncq(id)	((id)[76] & (1 << 8))
-#define ata_id_queue_depth(id)	(((id)[75] & 0x1f) + 1)
-#define ata_id_removeable(id)	((id)[0] & (1 << 7))
+#define ata_id_queue_depth(id)	(((id)[ATA_ID_QUEUE_DEPTH] & 0x1f) + 1)
+#define ata_id_removeable(id)	((id)[ATA_ID_CONFIG] & (1 << 7))
 #define ata_id_has_atapi_AN(id)	\
 	( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \
 	  ((id)[78] & (1 << 5)) )
-#define ata_id_iordy_disable(id) ((id)[49] & (1 << 10))
-#define ata_id_has_iordy(id) ((id)[49] & (1 << 11))
+#define ata_id_iordy_disable(id) ((id)[ATA_ID_CAPABILITY] & (1 << 10))
+#define ata_id_has_iordy(id) ((id)[ATA_ID_CAPABILITY] & (1 << 11))
 #define ata_id_u32(id,n)	\
 	(((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
 #define ata_id_u64(id,n)	\
@@ -457,7 +520,7 @@ static inline int ata_is_data(u8 prot)
 	  ((u64) (id)[(n) + 1] << 16) |	\
 	  ((u64) (id)[(n) + 0]) )
 
-#define ata_id_cdb_intr(id)	(((id)[0] & 0x60) == 0x20)
+#define ata_id_cdb_intr(id)	(((id)[ATA_ID_CONFIG] & 0x60) == 0x20)
 
 static inline bool ata_id_has_hipm(const u16 *id)
 {
@@ -482,75 +545,75 @@ static inline bool ata_id_has_dipm(const u16 *id)
 
 static inline int ata_id_has_fua(const u16 *id)
 {
-	if ((id[84] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)
 		return 0;
-	return id[84] & (1 << 6);
+	return id[ATA_ID_CFSSE] & (1 << 6);
 }
 
 static inline int ata_id_has_flush(const u16 *id)
 {
-	if ((id[83] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
 		return 0;
-	return id[83] & (1 << 12);
+	return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
 }
 
 static inline int ata_id_has_flush_ext(const u16 *id)
 {
-	if ((id[83] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
 		return 0;
-	return id[83] & (1 << 13);
+	return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
 }
 
 static inline int ata_id_has_lba48(const u16 *id)
 {
-	if ((id[83] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
 		return 0;
-	if (!ata_id_u64(id, 100))
+	if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2))
 		return 0;
-	return id[83] & (1 << 10);
+	return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
 }
 
 static inline int ata_id_hpa_enabled(const u16 *id)
 {
 	/* Yes children, word 83 valid bits cover word 82 data */
-	if ((id[83] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
 		return 0;
 	/* And 87 covers 85-87 */
-	if ((id[87] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
 		return 0;
 	/* Check command sets enabled as well as supported */
-	if ((id[85] & ( 1 << 10)) == 0)
+	if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0)
 		return 0;
-	return id[82] & (1 << 10);
+	return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
 }
 
 static inline int ata_id_has_wcache(const u16 *id)
 {
 	/* Yes children, word 83 valid bits cover word 82 data */
-	if ((id[83] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
 		return 0;
-	return id[82] & (1 << 5);
+	return id[ATA_ID_COMMAND_SET_1] & (1 << 5);
 }
 
 static inline int ata_id_has_pm(const u16 *id)
 {
-	if ((id[83] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
 		return 0;
-	return id[82] & (1 << 3);
+	return id[ATA_ID_COMMAND_SET_1] & (1 << 3);
 }
 
 static inline int ata_id_rahead_enabled(const u16 *id)
 {
-	if ((id[87] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
 		return 0;
-	return id[85] & (1 << 6);
+	return id[ATA_ID_CFS_ENABLE_1] & (1 << 6);
 }
 
 static inline int ata_id_wcache_enabled(const u16 *id)
 {
-	if ((id[87] & 0xC000) != 0x4000)
+	if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
 		return 0;
-	return id[85] & (1 << 5);
+	return id[ATA_ID_CFS_ENABLE_1] & (1 << 5);
 }
 
 /**
@@ -581,7 +644,7 @@ static inline unsigned int ata_id_major_version(const u16 *id)
 
 static inline int ata_id_is_sata(const u16 *id)
 {
-	return ata_id_major_version(id) >= 5 && id[93] == 0;
+	return ata_id_major_version(id) >= 5 && id[ATA_ID_HW_CONFIG] == 0;
 }
 
 static inline int ata_id_has_tpm(const u16 *id)
@@ -599,7 +662,7 @@ static inline int ata_id_has_dword_io(const u16 *id)
 	/* ATA 8 reuses this flag for "trusted" computing */
 	if (ata_id_major_version(id) > 7)
 		return 0;
-	if (id[48] & (1 << 0))
+	if (id[ATA_ID_DWORD_IO] & (1 << 0))
 		return 1;
 	return 0;
 }
@@ -608,22 +671,22 @@ static inline int ata_id_current_chs_valid(const u16 *id)
 {
 	/* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
 	   has not been issued to the device then the values of
-	   id[54] to id[56] are vendor specific. */
-	return (id[53] & 0x01) && /* Current translation valid */
-		id[54] &&  /* cylinders in current translation */
-		id[55] &&  /* heads in current translation */
-		id[55] <= 16 &&
-		id[56];    /* sectors in current translation */
+	   id[ATA_ID_CUR_CYLS] to id[ATA_ID_CUR_SECTORS] are vendor specific. */
+	return (id[ATA_ID_FIELD_VALID] & 1) && /* Current translation valid */
+		id[ATA_ID_CUR_CYLS] &&  /* cylinders in current translation */
+		id[ATA_ID_CUR_HEADS] &&  /* heads in current translation */
+		id[ATA_ID_CUR_HEADS] <= 16 &&
+		id[ATA_ID_CUR_SECTORS];    /* sectors in current translation */
 }
 
 static inline int ata_id_is_cfa(const u16 *id)
 {
-	u16 v = id[0];
-	if (v == 0x848A)	/* Standard CF */
+	if (id[ATA_ID_CONFIG] == 0x848A)	/* Standard CF */
 		return 1;
 	/* Could be CF hiding as standard ATA */
-	if (ata_id_major_version(id) >= 3 &&  id[82] != 0xFFFF &&
-			(id[82] & ( 1 << 2)))
+	if (ata_id_major_version(id) >= 3 &&
+	    id[ATA_ID_COMMAND_SET_1] != 0xFFFF &&
+	   (id[ATA_ID_COMMAND_SET_1] & (1 << 2)))
 		return 1;
 	return 0;
 }
@@ -632,21 +695,21 @@ static inline int ata_drive_40wire(const u16 *dev_id)
 {
 	if (ata_id_is_sata(dev_id))
 		return 0;	/* SATA */
-	if ((dev_id[93] & 0xE000) == 0x6000)
+	if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000)
 		return 0;	/* 80 wire */
 	return 1;
 }
 
 static inline int ata_drive_40wire_relaxed(const u16 *dev_id)
 {
-	if ((dev_id[93] & 0x2000) == 0x2000)
+	if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000)
 		return 0;	/* 80 wire */
 	return 1;
 }
 
 static inline int atapi_cdb_len(const u16 *dev_id)
 {
-	u16 tmp = dev_id[0] & 0x3;
+	u16 tmp = dev_id[ATA_ID_CONFIG] & 0x3;
 	switch (tmp) {
 	case 0:		return 12;
 	case 1:		return 16;
@@ -656,7 +719,7 @@ static inline int atapi_cdb_len(const u16 *dev_id)
 
 static inline int atapi_command_packet_set(const u16 *dev_id)
 {
-	return (dev_id[0] >> 8) & 0x1f;
+	return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f;
 }
 
 static inline int atapi_id_dmadir(const u16 *dev_id)

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [git pull] IDE fixes
@ 2008-07-08 17:38 Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-07-08 17:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Stephen Rothwell, linux-ide, linux-kernel


Hi,

Regression fix, palm_bk3710 bugfix from Sergei and an obvious it8213 fixup.

Linus, please pull from:

master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6.git/

to receive the following updates:

 drivers/ide/arm/palm_bk3710.c |   38 ++++++++++++++++++--------------------
 drivers/ide/ide-probe.c       |    8 ++------
 drivers/ide/pci/it8213.c      |    3 +--
 drivers/ide/pci/ns87415.c     |    6 +-----
 include/linux/ide.h           |   15 +++++++++++++++
 5 files changed, 37 insertions(+), 33 deletions(-)


Bartlomiej Zolnierkiewicz (2):
      ide: add __ide_default_irq() inline helper
      it8213: fix return value in it8213_init_one()

Sergei Shtylyov (1):
      palm_bk3710: fix IDECLK period calculation


diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index cc24803..2f2b4f4 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -76,7 +76,7 @@ struct palm_bk3710_udmatiming {
 
 #include "../ide-timing.h"
 
-static long ide_palm_clk;
+static unsigned ideclk_period; /* in nanoseconds */
 
 static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
 	{160, 240},		/* UDMA Mode 0 */
@@ -86,8 +86,6 @@ static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
 	{85,  60},		/* UDMA Mode 4 */
 };
 
-static struct clk *ideclkp;
-
 static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,
 				    unsigned int mode)
 {
@@ -97,10 +95,10 @@ static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,
 
 	/* DMA Data Setup */
 	t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime,
-			  ide_palm_clk) - 1;
-	tenv = DIV_ROUND_UP(20, ide_palm_clk) - 1;
+			  ideclk_period) - 1;
+	tenv = DIV_ROUND_UP(20, ideclk_period) - 1;
 	trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime,
-			   ide_palm_clk) - 1;
+			   ideclk_period) - 1;
 
 	/* udmatim Register */
 	val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0);
@@ -141,8 +139,8 @@ static void palm_bk3710_setdmamode(void __iomem *base, unsigned int dev,
 	cycletime = max_t(int, t->cycle, min_cycle);
 
 	/* DMA Data Setup */
-	t0 = DIV_ROUND_UP(cycletime, ide_palm_clk);
-	td = DIV_ROUND_UP(t->active, ide_palm_clk);
+	t0 = DIV_ROUND_UP(cycletime, ideclk_period);
+	td = DIV_ROUND_UP(t->active, ideclk_period);
 	tkw = t0 - td - 1;
 	td -= 1;
 
@@ -168,9 +166,9 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate,
 	struct ide_timing *t;
 
 	/* PIO Data Setup */
-	t0 = DIV_ROUND_UP(cycletime, ide_palm_clk);
+	t0 = DIV_ROUND_UP(cycletime, ideclk_period);
 	t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active,
-			  ide_palm_clk);
+			  ideclk_period);
 
 	t2i = t0 - t2 - 1;
 	t2 -= 1;
@@ -192,8 +190,8 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate,
 
 	/* TASKFILE Setup */
 	t = ide_timing_find_mode(XFER_PIO_0 + mode);
-	t0 = DIV_ROUND_UP(t->cyc8b, ide_palm_clk);
-	t2 = DIV_ROUND_UP(t->act8b, ide_palm_clk);
+	t0 = DIV_ROUND_UP(t->cyc8b, ideclk_period);
+	t2 = DIV_ROUND_UP(t->act8b, ideclk_period);
 
 	t2i = t0 - t2 - 1;
 	t2 -= 1;
@@ -350,22 +348,22 @@ static const struct ide_port_info __devinitdata palm_bk3710_port_info = {
 
 static int __devinit palm_bk3710_probe(struct platform_device *pdev)
 {
-	struct clk *clkp;
+	struct clk *clk;
 	struct resource *mem, *irq;
 	ide_hwif_t *hwif;
-	unsigned long base;
+	unsigned long base, rate;
 	int i;
 	hw_regs_t hw;
 	u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
-	clkp = clk_get(NULL, "IDECLK");
-	if (IS_ERR(clkp))
+	clk = clk_get(NULL, "IDECLK");
+	if (IS_ERR(clk))
 		return -ENODEV;
 
-	ideclkp = clkp;
-	clk_enable(ideclkp);
-	ide_palm_clk = clk_get_rate(ideclkp)/100000;
-	ide_palm_clk = (10000/ide_palm_clk) + 1;
+	clk_enable(clk);
+	rate = clk_get_rate(clk);
+	ideclk_period = 1000000000UL / rate;
+
 	/* Register the IDE interface with Linux ATA Interface */
 	memset(&hw, 0, sizeof(hw));
 
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index d27061b..26e68b6 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1218,16 +1218,12 @@ static void drive_release_dev (struct device *dev)
 	complete(&drive->gendev_rel_comp);
 }
 
-#ifndef ide_default_irq
-#define ide_default_irq(irq) 0
-#endif
-
 static int hwif_init(ide_hwif_t *hwif)
 {
 	int old_irq;
 
 	if (!hwif->irq) {
-		hwif->irq = ide_default_irq(hwif->io_ports.data_addr);
+		hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
 		if (!hwif->irq) {
 			printk("%s: DISABLED, NO IRQ\n", hwif->name);
 			return 0;
@@ -1257,7 +1253,7 @@ static int hwif_init(ide_hwif_t *hwif)
 	 *	It failed to initialise. Find the default IRQ for 
 	 *	this port and try that.
 	 */
-	hwif->irq = ide_default_irq(hwif->io_ports.data_addr);
+	hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
 	if (!hwif->irq) {
 		printk("%s: Disabled unable to get IRQ %d.\n",
 			hwif->name, old_irq);
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index 9053c87..2b71bdf 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -184,8 +184,7 @@ static const struct ide_port_info it8213_chipsets[] __devinitdata = {
 
 static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]);
-	return 0;
+	return ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]);
 }
 
 static const struct pci_device_id it8213_pci_tbl[] = {
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index fec4955..a7a41bb 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -225,10 +225,6 @@ static int ns87415_dma_setup(ide_drive_t *drive)
 	return 1;
 }
 
-#ifndef ide_default_irq
-#define ide_default_irq(irq) 0
-#endif
-
 static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
 {
 	struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -288,7 +284,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
 	}
 
 	if (!using_inta)
-		hwif->irq = ide_default_irq(hwif->io_ports.data_addr);
+		hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
 	else if (!hwif->irq && hwif->mate && hwif->mate->irq)
 		hwif->irq = hwif->mate->irq;	/* share IRQ with mate */
 
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9918772..eddb6da 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -189,6 +189,21 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
 	hw->io_ports.ctl_addr = ctl_addr;
 }
 
+/* for IDE PCI controllers in legacy mode, temporary */
+static inline int __ide_default_irq(unsigned long base)
+{
+	switch (base) {
+#ifdef CONFIG_IA64
+	case 0x1f0: return isa_irq_to_vector(14);
+	case 0x170: return isa_irq_to_vector(15);
+#else
+	case 0x1f0: return 14;
+	case 0x170: return 15;
+#endif
+	}
+	return 0;
+}
+
 #include <asm/ide.h>
 
 #if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED)

^ permalink raw reply related	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2009-06-08  0:52 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-25 19:54 [git pull] IDE fixes Bartlomiej Zolnierkiewicz
  -- strict thread matches above, loose matches on Subject: below --
2009-06-07 12:44 Bartlomiej Zolnierkiewicz
2009-06-07 14:21 ` Alan Cox
2009-06-07 14:32   ` Bartlomiej Zolnierkiewicz
2009-06-07 14:40     ` Alan Cox
2009-06-07 15:03       ` Bartlomiej Zolnierkiewicz
2009-06-07 15:11         ` Alan Cox
2009-06-07 14:38   ` James Bottomley
2009-06-07 14:57     ` Bartlomiej Zolnierkiewicz
2009-06-07 15:18       ` James Bottomley
2009-06-07 15:44         ` Bartlomiej Zolnierkiewicz
2009-06-07 16:08           ` James Bottomley
2009-06-07 17:47             ` Bartlomiej Zolnierkiewicz
2009-06-07 19:08               ` James Bottomley
2009-06-07 19:23                 ` Bartlomiej Zolnierkiewicz
2009-06-07 20:07                 ` Alan Cox
2009-06-07 20:39                   ` James Bottomley
2009-06-07 21:08                     ` Bartlomiej Zolnierkiewicz
2009-06-07 20:42                   ` Bartlomiej Zolnierkiewicz
2009-06-07 16:54           ` Pekka Enberg
2009-06-07 17:55             ` Bartlomiej Zolnierkiewicz
2009-06-07 18:21               ` Pekka Enberg
2009-06-07 19:00                 ` Bartlomiej Zolnierkiewicz
2009-06-07 19:09                   ` Pekka Enberg
2009-06-07 19:25                     ` Bartlomiej Zolnierkiewicz
2009-06-07 23:15                       ` Linus Torvalds
2009-06-07 23:47                         ` Bartlomiej Zolnierkiewicz
2009-06-07 23:57                           ` Linus Torvalds
2009-06-08  0:54                             ` Bartlomiej Zolnierkiewicz
2009-06-07 23:14               ` Linus Torvalds
2009-06-07 23:12       ` Linus Torvalds
2009-05-22 15:17 Bartlomiej Zolnierkiewicz
2009-05-16 19:16 Bartlomiej Zolnierkiewicz
2009-05-16 19:22 ` Borislav Petkov
2009-05-16 19:33   ` Bartlomiej Zolnierkiewicz
2009-04-22 18:48 Bartlomiej Zolnierkiewicz
2009-04-22 19:06 ` Joe Perches
2009-04-22 19:22   ` Sam Ravnborg
2009-04-22 19:43   ` Bartlomiej Zolnierkiewicz
2009-04-22 19:55     ` Joe Perches
2009-04-22 21:41       ` Bartlomiej Zolnierkiewicz
2009-04-22 22:02         ` Ray Lee
2009-04-22 22:51           ` Bartlomiej Zolnierkiewicz
2009-04-22 22:58           ` Bartlomiej Zolnierkiewicz
2009-04-18 16:09 Bartlomiej Zolnierkiewicz
2009-03-13 20:49 Bartlomiej Zolnierkiewicz
2009-03-05 15:30 Bartlomiej Zolnierkiewicz
2009-03-05 16:27 ` Bartlomiej Zolnierkiewicz
2009-02-02 19:48 Bartlomiej Zolnierkiewicz
2009-01-19 12:50 Bartlomiej Zolnierkiewicz
2008-12-22 22:08 Bartlomiej Zolnierkiewicz
2008-12-08 16:55 Bartlomiej Zolnierkiewicz
2008-10-05 16:38 Bartlomiej Zolnierkiewicz
2008-09-27 17:47 Bartlomiej Zolnierkiewicz
2008-09-10 20:47 Bartlomiej Zolnierkiewicz
2008-09-02 18:24 Bartlomiej Zolnierkiewicz
2008-08-18 20:22 Bartlomiej Zolnierkiewicz
2008-07-08 17:38 Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).