Skip to contentSkip to conversation

ide: Reinitilize idedisk_capacity for HPA drives on resume

PATCH In review Lee Trager 2 participants 4 messages Aug 21, 2006 libata

lore
Share & tools
lore

Lee Trager

author
#0 lore raw

PATCH 1/1 ide: Reinitilize idedisk_capacity for HPA drives on resume

This patch fixes a problem that when a computer with HPA on it's hard drive comes out of sleep mode it needs the disks capacity reinitialized.

This is my first patch to the Linux kernel so if I did anything wrong please be gentle ;)

Lee Trager

diff -Naur linux-2.6.18-rc4-old/include/linux/ide.h linux-2.6.18-rc4/include/linux/ide.h
--- linux-2.6.18-rc4-old/include/linux/ide.h 2006-08-19
03:49:03.000000000 -0400
+++ linux-2.6.18-rc4/include/linux/ide.h 2006-08-20
19:13:10.000000000 -0400
@@ -1201,6 +1201,17 @@
void ide_register_subdriver(ide_drive_t *, ide_driver_t *); void ide_unregister_subdriver(ide_drive_t *, ide_driver_t *);

+/* Bits 10 of command_set_1 and cfs_enable_1 must be equal,
+ * so on non-buggy drives we need test only one.
+ * However, we should also check whether these fields are valid. +*/
+static inline int idedisk_supports_hpa(const struct hd_driveid *id) +{
+ return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
+}
+
+extern void init_idedisk_capacity (ide_drive_t *drive); +
#define ON_BOARD 1
#define NEVER_BOARD 0

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide-disk.c linux-2.6.18-rc4/drivers/ide/ide-disk.c
--- linux-2.6.18-rc4-old/drivers/ide/ide-disk.c 2006-08-19
03:49:03.000000000 -0400
+++ linux-2.6.18-rc4/drivers/ide/ide-disk.c 2006-08-20
19:13:56.000000000 -0400
@@ -464,16 +464,6 @@
}

/*
- * Bits 10 of command_set_1 and cfs_enable_1 must be equal,
- * so on non-buggy drives we need test only one.
- * However, we should also check whether these fields are valid.
- */
-static inline int idedisk_supports_hpa(const struct hd_driveid *id) -{
- return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
-}
-
-/*
* The same here.
*/
static inline int idedisk_supports_lba48(const struct hd_driveid *id)
@@ -528,7 +518,7 @@
* 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) +void init_idedisk_capacity (ide_drive_t *drive)

 {
     struct hd_driveid *id = drive->id;
     /*
@@ -555,6 +545,8 @@
     }

}

+EXPORT_SYMBOL(init_idedisk_capacity);
+
static sector_t idedisk_capacity (ide_drive_t *drive)

 {
     return drive->capacity64 - drive->sect0;

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide.c
linux-2.6.18-rc4/drivers/ide/ide.c
--- linux-2.6.18-rc4-old/drivers/ide/ide.c 2006-08-19
03:49:03.000000000 -0400
+++ linux-2.6.18-rc4/drivers/ide/ide.c 2006-08-20 19:12:38.000000000
-0400
@@ -1232,6 +1232,7 @@

     struct request rq;
     struct request_pm_state rqpm;
     ide_task_t args;

+ int ide_cmd;

     memset(&rq, 0, sizeof(rq));
     memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1243,15 @@
     rqpm.pm_step = ide_pm_state_start_resume;
     rqpm.pm_state = PM_EVENT_ON;

- return ide_do_drive_cmd(drive, &rq, ide_head_wait);
+ ide_cmd = ide_do_drive_cmd(drive, &rq, ide_head_wait);
+
+ /* check to see if this is a hard drive
+ * if it is then checkhpa needs to be
+ * disabled */
+ if(drive->media == ide_disk && idedisk_supports_hpa(drive->id))
+ init_idedisk_capacity(drive);
+
+ return ide_cmd;
}

int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct
block_device *bdev,

#1 lore raw

Hello.

Quoted 5 lines · Lee Trager

This patch fixes a problem that when a computer with HPA on it's hard drive comes out of sleep mode it needs the disks capacity reinitialized.

This is my first patch to the Linux kernel so if I did anything wrong please be gentle ;)

Your mailer spoils tabs, so either attach your patch or use the different
mailer.

[...]

Quoted 19 lines

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide.c
linux-2.6.18-rc4/drivers/ide/ide.c
--- linux-2.6.18-rc4-old/drivers/ide/ide.c 2006-08-19
03:49:03.000000000 -0400
+++ linux-2.6.18-rc4/drivers/ide/ide.c 2006-08-20 19:12:38.000000000
-0400

(quoted diff) +1 -1
@@ -1232,6 +1232,7 @@
     struct request rq;
     struct request_pm_state rqpm;
     ide_task_t args;
+    int ide_cmd;
 
     memset(&rq, 0, sizeof(rq));
     memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1243,15 @@
     rqpm.pm_step = ide_pm_state_start_resume;
     rqpm.pm_state = PM_EVENT_ON;
 
-    return ide_do_drive_cmd(drive, &rq, ide_head_wait);

Review line 1255

Quoted 10 lines
(quoted diff) +9 -0
+    ide_cmd = ide_do_drive_cmd(drive, &rq, ide_head_wait);
+
+    /* check to see if this is a hard drive
+     * if it is then checkhpa needs to be
+     * disabled */
+    if(drive->media == ide_disk && idedisk_supports_hpa(drive->id))
+        init_idedisk_capacity(drive);
+
+    return ide_cmd;
 }

Hm, shouldn't this be handled as a separate resume process step?

MBR, Sergei

author
#2 lore raw
Quoted 48 lines · Sergei Shtylyov

Hello.

Quoted 5 lines · Lee Trager

This patch fixes a problem that when a computer with HPA on it's hard drive comes out of sleep mode it needs the disks capacity reinitialized.

This is my first patch to the Linux kernel so if I did anything wrong please be gentle ;)

Your mailer spoils tabs, so either attach your patch or use the
different
mailer.

[...]

Quoted 19 lines

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide.c
linux-2.6.18-rc4/drivers/ide/ide.c
--- linux-2.6.18-rc4-old/drivers/ide/ide.c 2006-08-19
03:49:03.000000000 -0400
+++ linux-2.6.18-rc4/drivers/ide/ide.c 2006-08-20 19:12:38.000000000
-0400

(quoted diff) +1 -1
@@ -1232,6 +1232,7 @@
     struct request rq;
     struct request_pm_state rqpm;
     ide_task_t args;
+    int ide_cmd;
 
     memset(&rq, 0, sizeof(rq));
     memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1243,15 @@
     rqpm.pm_step = ide_pm_state_start_resume;
     rqpm.pm_state = PM_EVENT_ON;
 
-    return ide_do_drive_cmd(drive, &rq, ide_head_wait);

Review line 1255

Quoted 10 lines
(quoted diff) +9 -0
+    ide_cmd = ide_do_drive_cmd(drive, &rq, ide_head_wait);
+
+    /* check to see if this is a hard drive
+     * if it is then checkhpa needs to be
+     * disabled */
+    if(drive->media == ide_disk && idedisk_supports_hpa(drive->id))
+        init_idedisk_capacity(drive);
+
+    return ide_cmd;
 }

Hm, shouldn't this be handled as a separate resume process step?

Quoted 7 lines

MBR, Sergei

-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Ok I attached it now.

include/linux/ide.h +11 -0
diff -Naur linux-2.6.18-rc4-old/include/linux/ide.h linux-2.6.18-rc4/include/linux/ide.h
@@ -1201,6 +1201,17 @@
 void ide_register_subdriver(ide_drive_t *, ide_driver_t *);
 void ide_unregister_subdriver(ide_drive_t *, ide_driver_t *);
 
+/* Bits 10 of command_set_1 and cfs_enable_1 must be equal,
+ * so on non-buggy drives we need test only one.
+ * However, we should also check whether these fields are valid.
+*/
+static inline int idedisk_supports_hpa(const struct hd_driveid *id)
+{
+        return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
+}
+
+extern void init_idedisk_capacity (ide_drive_t  *drive);
+
 #define ON_BOARD		1
 #define NEVER_BOARD		0
 
drivers/ide/ide-disk.c +3 -11
diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide-disk.c linux-2.6.18-rc4/drivers/ide/ide-disk.c
@@ -464,16 +464,6 @@
 }
 
 /*
- * Bits 10 of command_set_1 and cfs_enable_1 must be equal,
- * so on non-buggy drives we need test only one.
- * However, we should also check whether these fields are valid.
- */
-static inline int idedisk_supports_hpa(const struct hd_driveid *id)
-{
-	return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
-}
-
-/*
  * The same here.
  */
 static inline int idedisk_supports_lba48(const struct hd_driveid *id)
@@ -528,7 +518,7 @@
  * 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)
+void init_idedisk_capacity (ide_drive_t  *drive)
 {
 	struct hd_driveid *id = drive->id;
 	/*
@@ -555,6 +545,8 @@
 	}
 }
 
+EXPORT_SYMBOL(init_idedisk_capacity);
+
 static sector_t idedisk_capacity (ide_drive_t *drive)
 {
 	return drive->capacity64 - drive->sect0;
drivers/ide/ide.c +10 -1
diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide.c linux-2.6.18-rc4/drivers/ide/ide.c
@@ -1232,6 +1232,7 @@
 	struct request rq;
 	struct request_pm_state rqpm;
 	ide_task_t args;
+	int ide_cmd;
 
 	memset(&rq, 0, sizeof(rq));
 	memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1243,15 @@
 	rqpm.pm_step = ide_pm_state_start_resume;
 	rqpm.pm_state = PM_EVENT_ON;
 
-	return ide_do_drive_cmd(drive, &rq, ide_head_wait);
+	ide_cmd = ide_do_drive_cmd(drive, &rq, ide_head_wait);
+
+	/* check to see if this is a hard drive
+	 * if it is then checkhpa needs to be
+	 * disabled */
+	if(drive->media == ide_disk && idedisk_supports_hpa(drive->id))
+		init_idedisk_capacity(drive);
+
+	return ide_cmd;
 }
 
 int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
author
#3 lore raw
Quoted 142 lines · Lee Trager
Quoted 50 lines · Sergei Shtylyov

Hello.

Quoted 6 lines · Lee Trager

This patch fixes a problem that when a computer with HPA on it's hard drive comes out of sleep mode it needs the disks capacity reinitialized.

This is my first patch to the Linux kernel so if I did anything wrong please be gentle ;)

Your mailer spoils tabs, so either attach your patch or use the
different
mailer.

[...]

Quoted 20 lines

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide.c
linux-2.6.18-rc4/drivers/ide/ide.c
--- linux-2.6.18-rc4-old/drivers/ide/ide.c 2006-08-19
03:49:03.000000000 -0400
+++ linux-2.6.18-rc4/drivers/ide/ide.c 2006-08-20 19:12:38.000000000
-0400

drivers/ide/ide.c +2 -1
@@ -1232,6 +1232,7 @@
     struct request rq;
     struct request_pm_state rqpm;
     ide_task_t args;
+    int ide_cmd;
 
     memset(&rq, 0, sizeof(rq));
     memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1243,15 @@
     rqpm.pm_step = ide_pm_state_start_resume;
     rqpm.pm_state = PM_EVENT_ON;
 
-    return ide_do_drive_cmd(drive, &rq, ide_head_wait);
+    ide_cmd = ide_do_drive_cmd(drive, &rq, ide_head_wait);

drivers/ide/ide.c line 1256

Quoted 10 lines
drivers/ide/ide.c +8 -0
+
+    /* check to see if this is a hard drive
+     * if it is then checkhpa needs to be
+     * disabled */
+    if(drive->media == ide_disk && idedisk_supports_hpa(drive->id))
+        init_idedisk_capacity(drive);
+
+    return ide_cmd;
 }
 

Hm, shouldn't this be handled as a separate resume process step?

Quoted 8 lines

MBR, Sergei

-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Ok I attached it now.

------------------------------------------------------------------------

diff -Naur linux-2.6.18-rc4-old/include/linux/ide.h linux-2.6.18-rc4/include/linux/ide.h

include/linux/ide.h +11 -0
@@ -1201,6 +1201,17 @@
 void ide_register_subdriver(ide_drive_t *, ide_driver_t *);
 void ide_unregister_subdriver(ide_drive_t *, ide_driver_t *);
 
+/* Bits 10 of command_set_1 and cfs_enable_1 must be equal,
+ * so on non-buggy drives we need test only one.
+ * However, we should also check whether these fields are valid.
+*/
+static inline int idedisk_supports_hpa(const struct hd_driveid *id)
+{
+        return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
+}
+
+extern void init_idedisk_capacity (ide_drive_t  *drive);
+
 #define ON_BOARD		1
 #define NEVER_BOARD		0
 

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide-disk.c linux-2.6.18-rc4/drivers/ide/ide-disk.c

drivers/ide/ide-disk.c +3 -11
@@ -464,16 +464,6 @@
 }
 
 /*
- * Bits 10 of command_set_1 and cfs_enable_1 must be equal,
- * so on non-buggy drives we need test only one.
- * However, we should also check whether these fields are valid.
- */
-static inline int idedisk_supports_hpa(const struct hd_driveid *id)
-{
-	return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
-}
-
-/*
  * The same here.
  */
 static inline int idedisk_supports_lba48(const struct hd_driveid *id)
@@ -528,7 +518,7 @@
  * 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)
+void init_idedisk_capacity (ide_drive_t  *drive)
 {
 	struct hd_driveid *id = drive->id;
 	/*
@@ -555,6 +545,8 @@
 	}
 }
 
+EXPORT_SYMBOL(init_idedisk_capacity);
+
 static sector_t idedisk_capacity (ide_drive_t *drive)
 {
 	return drive->capacity64 - drive->sect0;

diff -Naur linux-2.6.18-rc4-old/drivers/ide/ide.c linux-2.6.18-rc4/drivers/ide/ide.c

drivers/ide/ide.c +3 -1
@@ -1232,6 +1232,7 @@
 	struct request rq;
 	struct request_pm_state rqpm;
 	ide_task_t args;
+	int ide_cmd;
 
 	memset(&rq, 0, sizeof(rq));
 	memset(&rqpm, 0, sizeof(rqpm));
@@ -1242,7 +1243,15 @@
 	rqpm.pm_step = ide_pm_state_start_resume;
 	rqpm.pm_state = PM_EVENT_ON;
 
-	return ide_do_drive_cmd(drive, &rq, ide_head_wait);
+	ide_cmd = ide_do_drive_cmd(drive, &rq, ide_head_wait);
+

drivers/ide/ide.c line 1257

Quoted 10 lines
drivers/ide/ide.c +7 -0
+	/* check to see if this is a hard drive
+	 * if it is then checkhpa needs to be
+	 * disabled */
+	if(drive->media == ide_disk && idedisk_supports_hpa(drive->id))
+		init_idedisk_capacity(drive);
+
+	return ide_cmd;
 }
 
 int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,

I put it there because honestly I wasn't sure where else to put it. Anyway it is in the generic_ide_resume() and its something that needs to be done on an ide disk with HPA on resume.