[PATCH] HPA resume fix



This patch fixes a problem with computers that have HPA on their hard
drive and not being able to come out of resume from RAM or disk. This is
my first patch to the kernel and third time submitting it, hopefully I
got it right this time.

Signed-off-by: Lee Trager <Lee@xxxxxxxxxxxxxxxxxxxx>

---

diff -uprN -X linux-2.6.18-rc5/Documentation/dontdiff linux-2.6.18-rc5-old/drivers/ide/ide-disk.c linux-2.6.18-rc5/drivers/ide/ide-disk.c
--- linux-2.6.18-rc5-old/drivers/ide/ide-disk.c 2006-08-29 05:14:43.000000000 -0400
+++ linux-2.6.18-rc5/drivers/ide/ide-disk.c 2006-08-29 05:18:13.000000000 -0400
@@ -1024,6 +1024,17 @@ static void ide_disk_release(struct kref

static int ide_disk_probe(ide_drive_t *drive);

+/*
+ * On HPA drives the capacity needs to be
+ * reinitilized on resume otherwise the disk
+ * can not be used and a hard reset is required
+ */
+static void ide_disk_resume(ide_drive_t *drive)
+{
+ if (idedisk_supports_hpa(drive->id))
+ init_idedisk_capacity(drive);
+}
+
static void ide_device_shutdown(ide_drive_t *drive)
{
#ifdef CONFIG_ALPHA
@@ -1067,6 +1078,7 @@ static ide_driver_t idedisk_driver = {
.error = __ide_error,
.abort = __ide_abort,
.proc = idedisk_proc,
+ .resume = ide_disk_resume,
};

static int idedisk_open(struct inode *inode, struct file *filp)
diff -uprN -X linux-2.6.18-rc5/Documentation/dontdiff linux-2.6.18-rc5-old/drivers/ide/ide.c linux-2.6.18-rc5/drivers/ide/ide.c
--- linux-2.6.18-rc5-old/drivers/ide/ide.c 2006-08-29 05:14:43.000000000 -0400
+++ linux-2.6.18-rc5/drivers/ide/ide.c 2006-08-29 05:18:13.000000000 -0400
@@ -1229,9 +1229,11 @@ static int generic_ide_suspend(struct de
static int generic_ide_resume(struct device *dev)
{
ide_drive_t *drive = dev->driver_data;
+ ide_driver_t *drv = to_ide_driver(dev->driver);
struct request rq;
struct request_pm_state rqpm;
ide_task_t args;
+ int err;

memset(&rq, 0, sizeof(rq));
memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1244,12 @@ static int generic_ide_resume(struct dev
rqpm.pm_step = ide_pm_state_start_resume;
rqpm.pm_state = PM_EVENT_ON;

- return ide_do_drive_cmd(drive, &rq, ide_head_wait);
+ err = ide_do_drive_cmd(drive, &rq, ide_head_wait);
+
+ if (err == 0 && drv->resume)
+ drv->resume(drive);
+
+ return err;
}

int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
diff -uprN -X linux-2.6.18-rc5/Documentation/dontdiff linux-2.6.18-rc5-old/include/linux/ide.h linux-2.6.18-rc5/include/linux/ide.h
--- linux-2.6.18-rc5-old/include/linux/ide.h 2006-08-29 05:15:53.000000000 -0400
+++ linux-2.6.18-rc5/include/linux/ide.h 2006-08-29 05:18:13.000000000 -0400
@@ -987,6 +987,7 @@ typedef struct ide_driver_s {
int (*probe)(ide_drive_t *);
void (*remove)(ide_drive_t *);
void (*shutdown)(ide_drive_t *);
+ void (*resume)(ide_drive_t *);
} ide_driver_t;

#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Single File Restore - what is it?
    ... looking in the Disk Management area, I discovered it is a 9.7GB ... probably a Host Protected Area (HPA) that IBM ... I've got both Acronis True Image and Norton's Ghost, ... the drives had to be cloned, or re-loaded (been there, done that - I ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: IDE HPA
    ... > some other OS or Distro that wasn't designed with to screw up the disk. ... If you shrink existing partitions it won't ever screw you up. ... geometry data for the partition table spans only the non HPA area. ... HPA when we can do it ourselves, and we can clip non HPA capable drives ...
    (Linux-Kernel)
  • Re: 3B2 Disks
    ... being able to read the disk in its present format. ... 2 MFM drives on a custom controller. ... SCSI came much later as an add on card. ...
    (comp.sys.3b1)
  • Re: OT-True Image Backup
    ... Make sure the USB drives file system is NTFS and not FAT32.. ... Jaymon is correct in that the disk image you create and save to the D: ... partition of your USB external HDD will have no effect on the other ... Step-by-Step Instructions for Using the Acronis True Image Program to Backup ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: OT-True Image Backup
    ... Make sure the USB drives file system is NTFS and not FAT32.. ... Jaymon is correct in that the disk image you create and save to the D: ... partition of your USB external HDD will have no effect on the other ... Since the disk images you will be creating (at least the initial backup ...
    (microsoft.public.windowsxp.help_and_support)