Skip to contentSkip to conversation

ht6560b patch for 2.4 (and 2.6?)

DISCUSSION Jan Evert van Grootheest 2 participants 3 messages Dec 28, 2003 – Jan 10, 2004

lore
Share & tools
lore
#0 lore raw

Andre,

You're listed as the IDE maintainer for 2.4.
I'm one of the few people that own one of those Holtek 6560B VLB IDE interfaces.

Here's a patch against 2.4.23 that at least allows the kernel to boot when using the driver. Without this patch it simply hangs somewhere during early initialisation.

I won't be surprised if a comparable patch is required for 2.6, although I have not checked whether it applies. (I have no 2.6 sources yet)

This is my first kernel patch so if there is something not in order please let me know.

Thanks,
Jan Evert van Grootheest
[email protected]

--- ../../pristine/kernel-source-2.4.23-fswan-lmsens/drivers/ide/legacy/ht6560b.c

      2003-06-13 16:51:33.000000000 +0200

+++ drivers/ide/legacy/ht6560b.c 2003-12-28 15:03:01.000000000 +0100
@@ -23,6 +23,20 @@
* "Prefetch" mode bit OFF for ide disks and
* ON for anything else.
*

+ *  version 8          (dropped useless 0. from version)
+ *                     Jan Evert van Grootheest   <[email protected]>
+ *                     - Removed Mikko as maintainer; he admits to no longer

+ * having the proper hardware. Also the URL no longer
+ * works.
+ * - Fix things for 2.4 kernels.
+ * - Rename probe_ht6560b to setup_ht6560b; there's np
+ * probing there because that's done in try_to_init.
+ * So that one's been renamed to probe_
+ * - Remove the use of check_region(); patch from William
+ * Stinson that he made as part of kernel janitors for
+ * 2.6
+ * - this driver is not tested (by me) as module!
+ *
*
* HT-6560B EIDE-controller support
* To activate controller support use kernel parameter "ide0=ht6560b".
@@ -30,11 +44,9 @@
*

  *  Author:    Mikko Ala-Fossi            <[email protected]>
  *             Jan Evert van Grootheest   <[email protected]>

- *
- * Try: http://www.maf.iki.fi/~maf/ht6560b/
*/

-#define HT6560B_VERSION "v0.07"
+#define HT6560B_VERSION "v8"

#undef REALLY_SLOW_IO /* most systems can safely undef this */

@@ -173,7 +185,7 @@
/*
* Autodetection and initialization of ht6560b
*/
-static int __init try_to_init_ht6560b(void)
+static int __init probe_ht6560b(void)

 {
        u8 orig_value;
        int i;
@@ -194,6 +206,7 @@
                outb(orig_value, HT_CONFIG_PORT);
                return 0;
        }
+
        /*
         * Ht6560b autodetected
         */

@@ -312,11 +325,10 @@
#endif
}

-void __init probe_ht6560b (void)
+void __init setup_ht6560b (void)

 {
        int t;
-       request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name);
        ide_hwifs[0].chipset = ide_ht6560b;
        ide_hwifs[1].chipset = ide_ht6560b;
        ide_hwifs[0].selectproc = &ht6560b_selectproc;
@@ -371,6 +383,36 @@
        release_region(HT_CONFIG_PORT, 1);

}

+
+#ifndef MODULE
+void __init ide_probe_for_ht6560b(void)
+#else
+int ide_probe_for_ht6560b(void)
+#endif
+{
+ if (!request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name)) {
+ printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", __FUNCTION__);
+ }
+ else if (!probe_ht6560b()) {
+ release_region(HT_CONFIG_PORT, 1);
+ printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
+ }
+ else {

+               printk("\ndebug %d", __LINE__);
+               setup_ht6560b();
+               printk("\ndebug %d", __LINE__);

+#ifdef MODULE
+ return 1;
+#endif
+ }
+
+#ifdef MODULE
+ return 0;
+#endif
+}
+
+
+
#ifndef MODULE
/*
* init_ht6560b:
@@ -380,16 +422,7 @@

void __init init_ht6560b (void)
{
- if (check_region(HT_CONFIG_PORT,1)) {
- printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
- __FUNCTION__);
- return;
- }
- if (!try_to_init_ht6560b()) {
- printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
- return;

-       }
-       probe_ht6560b();
+       ide_register_driver(ide_probe_for_ht6560b);

}

#else
@@ -400,23 +433,15 @@

int __init ht6560b_mod_init(void)
{
- if (check_region(HT_CONFIG_PORT,1)) {
- printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
- __FUNCTION__);
+ if (!ide_probe_for_ht6560b())

                return -ENODEV;

- }
-
- if (!try_to_init_ht6560b()) {
- printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
- return -ENODEV;
- }
-
- probe_ht6560b();
+

         if (ide_hwifs[0].chipset != ide_ht6560b &&
             ide_hwifs[1].chipset != ide_ht6560b) {
                 ht6560b_release();
                 return -ENODEV;
-        }
+       }
+
         return 0;

}
module_init(ht6560b_mod_init);

#1 lore raw

Hi,

Sorry for long delay.

Quoted 5 lines · Jan Evert van Grootheest

Andre,

You're listed as the IDE maintainer for 2.4.
I'm one of the few people that own one of those Holtek 6560B VLB IDE interfaces.

Andre no longer have time to do this.
You can contact me although I am concentrated on 2.6.x.

Quoted 6 lines

Here's a patch against 2.4.23 that at least allows the kernel to boot when using the driver. Without this patch it simply hangs somewhere during early initialisation.

I won't be surprised if a comparable patch is required for 2.6, although I have not checked whether it applies. (I have no 2.6 sources yet)

Surprise, surprise :-).

Quoted 2 lines

This is my first kernel patch so if there is something not in order please let me know.

Can you try this patch against kernel 2.4.24?
It is backport of my 2.6.x patch plus your ide_register_driver() fix.

--bart

[IDE] update ht6560b driver

From: Jan Evert van Grootheest <[email protected]>:
- register driver with IDE core or it won't work

Backport of my 2.6.x changes:
- common ht6560b_init() for built-in and module
- release hwif only if hwif->chipset == ide_ht6560b
- when releasing hwif, restore hwif->channel to the default value
- mark exit functions with __exit
- do not use ide_hwifs[] directly
- minor cleanups

 drivers/ide/legacy/ht6560b.c |  155 ++++++++++++++++++-------------------------
 1 files changed, 67 insertions(+), 88 deletions(-)
drivers/ide/legacy/ht6560b.c renamed from drivers/ide/legacy/ht6560b.c~ide-ht6560b-update +67 -88
diff -puN drivers/ide/legacy/ht6560b.c~ide-ht6560b-update drivers/ide/legacy/ht6560b.c
@@ -312,119 +312,98 @@ static void tune_ht6560b (ide_drive_t *d
 #endif
 }
 
-void __init probe_ht6560b (void)
+static int __init ht6560b_init(void)
 {
+	ide_hwif_t *hwif, *mate;
 	int t;
-	
-	request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name);
-	ide_hwifs[0].chipset = ide_ht6560b;
-	ide_hwifs[1].chipset = ide_ht6560b;
-	ide_hwifs[0].selectproc = &ht6560b_selectproc;
-	ide_hwifs[1].selectproc = &ht6560b_selectproc;
-	ide_hwifs[0].tuneproc = &tune_ht6560b;
-	ide_hwifs[1].tuneproc = &tune_ht6560b;
-	ide_hwifs[0].serialized = 1;  /* is this needed? */
-	ide_hwifs[1].serialized = 1;  /* is this needed? */
-	ide_hwifs[0].mate = &ide_hwifs[1];
-	ide_hwifs[1].mate = &ide_hwifs[0];
-	ide_hwifs[1].channel = 1;
-			
+
+	hwif = &ide_hwifs[0];
+	mate = &ide_hwifs[1];
+
+	if (!request_region(HT_CONFIG_PORT, 1, hwif->name)) {
+		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
+			__FUNCTION__);
+		return -ENODEV;
+	}
+
+	if (!try_to_init_ht6560b()) {
+		release_region(HT_CONFIG_PORT, 1);
+		printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
+		return -ENODEV;
+	}
+
+	hwif->chipset = ide_ht6560b;
+	hwif->selectproc = &ht6560b_selectproc;
+	hwif->tuneproc = &tune_ht6560b;
+	hwif->serialized = 1;	/* is this needed? */
+	hwif->mate = mate;
+
+	mate->chipset = ide_ht6560b;
+	mate->selectproc = &ht6560b_selectproc;
+	mate->tuneproc = &tune_ht6560b;
+	mate->serialized = 1;	/* is this needed? */
+	mate->mate = hwif;
+	mate->channel = 1;
+
 	/*
 	 * Setting default configurations for drives
 	 */
 	t = (HT_CONFIG_DEFAULT << 8);
 	t |= HT_TIMING_DEFAULT;
-	ide_hwifs[0].drives[0].drive_data = t;
-	ide_hwifs[0].drives[1].drive_data = t;
+	hwif->drives[0].drive_data = t;
+	hwif->drives[1].drive_data = t;
+
 	t |= (HT_SECONDARY_IF << 8);
-	ide_hwifs[1].drives[0].drive_data = t;
-	ide_hwifs[1].drives[1].drive_data = t;
+	mate->drives[0].drive_data = t;
+	mate->drives[1].drive_data = t;
 
 #ifndef HWIF_PROBE_CLASSIC_METHOD
-	probe_hwif_init(&ide_hwifs[0]);
-	probe_hwif_init(&ide_hwifs[1]);
-#endif /* HWIF_PROBE_CLASSIC_METHOD */
+	probe_hwif_init(hwif);
+	probe_hwif_init(mate);
+#endif
 
+	return 0;
 }
 
-void __init ht6560b_release (void)
+#ifndef MODULE
+/* Can be called from ide.c. */
+void __init ht6560b_builtin_init(void)
 {
-	if (ide_hwifs[0].chipset != ide_ht6560b &&
-	    ide_hwifs[1].chipset != ide_ht6560b)
-                return;
-
-	ide_hwifs[0].chipset = ide_unknown;
-	ide_hwifs[1].chipset = ide_unknown;
-	ide_hwifs[0].tuneproc = NULL;
-	ide_hwifs[1].tuneproc = NULL;
-	ide_hwifs[0].selectproc = NULL;
-	ide_hwifs[1].selectproc = NULL;
-	ide_hwifs[0].serialized = 0;
-	ide_hwifs[1].serialized = 0;
-	ide_hwifs[0].mate = NULL;
-	ide_hwifs[1].mate = NULL;
-
-	ide_hwifs[0].drives[0].drive_data = 0;
-	ide_hwifs[0].drives[1].drive_data = 0;
-	ide_hwifs[1].drives[0].drive_data = 0;
-	ide_hwifs[1].drives[1].drive_data = 0;
-	release_region(HT_CONFIG_PORT, 1);
+	(void)ht6560b_init();
 }
 
-#ifndef MODULE
-/*
- * init_ht6560b:
- *
- * called by ide.c when parsing command line
- */
-
-void __init init_ht6560b (void)
+void __init init_ht6560b(void)
 {
-	if (check_region(HT_CONFIG_PORT,1)) {
-		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
-			__FUNCTION__);
-		return;
-	}
-	if (!try_to_init_ht6560b()) {
-                printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
-		return;
-	}
-	probe_ht6560b();
+	ide_register_driver(ht6560b_builtin_init);
 }
-
 #else
-
-MODULE_AUTHOR("See Local File");
-MODULE_DESCRIPTION("HT-6560B EIDE-controller support");
-MODULE_LICENSE("GPL");
-
-int __init ht6560b_mod_init(void)
+static void __exit ht6560b_release_hwif(ide_hwif_t *hwif)
 {
-	if (check_region(HT_CONFIG_PORT,1)) {
-		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
-			__FUNCTION__);
-		return -ENODEV;
-	}
+	if (hwif->chipset != ide_ht6560b)
+		return;
 
-	if (!try_to_init_ht6560b()) {
-		printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
-		return -ENODEV;
-	}
+	hwif->chipset = ide_unknown;
+	hwif->tuneproc = NULL;
+	hwif->selectproc = NULL;
+	hwif->serialized = 0;
+	hwif->mate = NULL;
+	hwif->channel = 0;
 
-	probe_ht6560b();
-        if (ide_hwifs[0].chipset != ide_ht6560b &&
-            ide_hwifs[1].chipset != ide_ht6560b) {
-                ht6560b_release();
-                return -ENODEV;
-        }
-        return 0;
+	hwif->drives[0].drive_data = 0;
+	hwif->drives[1].drive_data = 0;
 }
-module_init(ht6560b_mod_init);
 
-void __init ht6560b_mod_exit(void)
+static void __exit ht6560b_exit(void)
 {
-        ht6560b_release();
+	ht6560b_release_hwif(&ide_hwifs[0]);
+	ht6560b_release_hwif(&ide_hwifs[1]);
+	release_region(HT_CONFIG_PORT, 1);
 }
-module_exit(ht6560b_mod_exit);
+
+module_init(ht6560b_init);
+module_exit(ht6560b_exit);
 #endif
 
+MODULE_AUTHOR("See Local File");
+MODULE_DESCRIPTION("HT-6560B EIDE-controller support");
+MODULE_LICENSE("GPL");

_

#2 lore raw

Bart,

Thanks! I'll get on with it as soon as possible.

If you don't mind, I'd like to remove the module code.
I don't use it and I'm not convinced that all functions have proper __init or similar designations.

In the meantime, perhaps you could give some hints how to get DMA going?
In 2.2 it would do to use hdparm -d1, but in 2.4 that fails (for obvious reasons when examining the code). Would it be a trivial task?

Thanks,
Jan Evert

Quoted 246 lines · Bartlomiej Zolnierkiewicz

Hi,

Sorry for long delay.

Quoted 5 lines · Jan Evert van Grootheest

Andre,

You're listed as the IDE maintainer for 2.4.
I'm one of the few people that own one of those Holtek 6560B VLB IDE interfaces.

Andre no longer have time to do this.
You can contact me although I am concentrated on 2.6.x.

Quoted 6 lines

Here's a patch against 2.4.23 that at least allows the kernel to boot when using the driver. Without this patch it simply hangs somewhere during early initialisation.

I won't be surprised if a comparable patch is required for 2.6, although I have not checked whether it applies. (I have no 2.6 sources yet)

Surprise, surprise :-).

Quoted 2 lines

This is my first kernel patch so if there is something not in order please let me know.

Can you try this patch against kernel 2.4.24?
It is backport of my 2.6.x patch plus your ide_register_driver() fix.

--bart

[IDE] update ht6560b driver

From: Jan Evert van Grootheest <[email protected]>:
- register driver with IDE core or it won't work

Backport of my 2.6.x changes:
- common ht6560b_init() for built-in and module
- release hwif only if hwif->chipset == ide_ht6560b
- when releasing hwif, restore hwif->channel to the default value
- mark exit functions with __exit
- do not use ide_hwifs[] directly
- minor cleanups

 drivers/ide/legacy/ht6560b.c |  155 ++++++++++++++++++-------------------------
 1 files changed, 67 insertions(+), 88 deletions(-)

diff -puN drivers/ide/legacy/ht6560b.c~ide-ht6560b-update drivers/ide/legacy/ht6560b.c

drivers/ide/legacy/ht6560b.c renamed from drivers/ide/legacy/ht6560b.c~ide-ht6560b-update +67 -88
@@ -312,119 +312,98 @@ static void tune_ht6560b (ide_drive_t *d
 #endif
 }
 
-void __init probe_ht6560b (void)
+static int __init ht6560b_init(void)
 {
+	ide_hwif_t *hwif, *mate;
 	int t;
-	
-	request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name);
-	ide_hwifs[0].chipset = ide_ht6560b;
-	ide_hwifs[1].chipset = ide_ht6560b;
-	ide_hwifs[0].selectproc = &ht6560b_selectproc;
-	ide_hwifs[1].selectproc = &ht6560b_selectproc;
-	ide_hwifs[0].tuneproc = &tune_ht6560b;
-	ide_hwifs[1].tuneproc = &tune_ht6560b;
-	ide_hwifs[0].serialized = 1;  /* is this needed? */
-	ide_hwifs[1].serialized = 1;  /* is this needed? */
-	ide_hwifs[0].mate = &ide_hwifs[1];
-	ide_hwifs[1].mate = &ide_hwifs[0];
-	ide_hwifs[1].channel = 1;
-			
+
+	hwif = &ide_hwifs[0];
+	mate = &ide_hwifs[1];
+
+	if (!request_region(HT_CONFIG_PORT, 1, hwif->name)) {
+		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
+			__FUNCTION__);
+		return -ENODEV;
+	}
+
+	if (!try_to_init_ht6560b()) {
+		release_region(HT_CONFIG_PORT, 1);
+		printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
+		return -ENODEV;
+	}
+
+	hwif->chipset = ide_ht6560b;
+	hwif->selectproc = &ht6560b_selectproc;
+	hwif->tuneproc = &tune_ht6560b;
+	hwif->serialized = 1;	/* is this needed? */
+	hwif->mate = mate;
+
+	mate->chipset = ide_ht6560b;
+	mate->selectproc = &ht6560b_selectproc;
+	mate->tuneproc = &tune_ht6560b;
+	mate->serialized = 1;	/* is this needed? */
+	mate->mate = hwif;
+	mate->channel = 1;
+
 	/*
 	 * Setting default configurations for drives
 	 */
 	t = (HT_CONFIG_DEFAULT << 8);
 	t |= HT_TIMING_DEFAULT;
-	ide_hwifs[0].drives[0].drive_data = t;
-	ide_hwifs[0].drives[1].drive_data = t;
+	hwif->drives[0].drive_data = t;
+	hwif->drives[1].drive_data = t;
+
 	t |= (HT_SECONDARY_IF << 8);
-	ide_hwifs[1].drives[0].drive_data = t;
-	ide_hwifs[1].drives[1].drive_data = t;
+	mate->drives[0].drive_data = t;
+	mate->drives[1].drive_data = t;
 
 #ifndef HWIF_PROBE_CLASSIC_METHOD
-	probe_hwif_init(&ide_hwifs[0]);
-	probe_hwif_init(&ide_hwifs[1]);
-#endif /* HWIF_PROBE_CLASSIC_METHOD */
+	probe_hwif_init(hwif);
+	probe_hwif_init(mate);
+#endif
 
+	return 0;
 }
 
-void __init ht6560b_release (void)
+#ifndef MODULE
+/* Can be called from ide.c. */
+void __init ht6560b_builtin_init(void)
 {
-	if (ide_hwifs[0].chipset != ide_ht6560b &&
-	    ide_hwifs[1].chipset != ide_ht6560b)
-                return;
-
-	ide_hwifs[0].chipset = ide_unknown;
-	ide_hwifs[1].chipset = ide_unknown;
-	ide_hwifs[0].tuneproc = NULL;
-	ide_hwifs[1].tuneproc = NULL;
-	ide_hwifs[0].selectproc = NULL;
-	ide_hwifs[1].selectproc = NULL;
-	ide_hwifs[0].serialized = 0;
-	ide_hwifs[1].serialized = 0;
-	ide_hwifs[0].mate = NULL;
-	ide_hwifs[1].mate = NULL;
-
-	ide_hwifs[0].drives[0].drive_data = 0;
-	ide_hwifs[0].drives[1].drive_data = 0;
-	ide_hwifs[1].drives[0].drive_data = 0;
-	ide_hwifs[1].drives[1].drive_data = 0;
-	release_region(HT_CONFIG_PORT, 1);
+	(void)ht6560b_init();
 }
 
-#ifndef MODULE
-/*
- * init_ht6560b:
- *
- * called by ide.c when parsing command line
- */
-
-void __init init_ht6560b (void)
+void __init init_ht6560b(void)
 {
-	if (check_region(HT_CONFIG_PORT,1)) {
-		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
-			__FUNCTION__);
-		return;
-	}
-	if (!try_to_init_ht6560b()) {
-                printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
-		return;
-	}
-	probe_ht6560b();
+	ide_register_driver(ht6560b_builtin_init);
 }
-
 #else
-
-MODULE_AUTHOR("See Local File");
-MODULE_DESCRIPTION("HT-6560B EIDE-controller support");
-MODULE_LICENSE("GPL");
-
-int __init ht6560b_mod_init(void)
+static void __exit ht6560b_release_hwif(ide_hwif_t *hwif)
 {
-	if (check_region(HT_CONFIG_PORT,1)) {
-		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
-			__FUNCTION__);
-		return -ENODEV;
-	}
+	if (hwif->chipset != ide_ht6560b)
+		return;
 
-	if (!try_to_init_ht6560b()) {
-		printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
-		return -ENODEV;
-	}
+	hwif->chipset = ide_unknown;
+	hwif->tuneproc = NULL;
+	hwif->selectproc = NULL;
+	hwif->serialized = 0;
+	hwif->mate = NULL;
+	hwif->channel = 0;
 
-	probe_ht6560b();
-        if (ide_hwifs[0].chipset != ide_ht6560b &&
-            ide_hwifs[1].chipset != ide_ht6560b) {
-                ht6560b_release();
-                return -ENODEV;
-        }
-        return 0;
+	hwif->drives[0].drive_data = 0;
+	hwif->drives[1].drive_data = 0;
 }
-module_init(ht6560b_mod_init);
 
-void __init ht6560b_mod_exit(void)
+static void __exit ht6560b_exit(void)
 {
-        ht6560b_release();
+	ht6560b_release_hwif(&ide_hwifs[0]);
+	ht6560b_release_hwif(&ide_hwifs[1]);
+	release_region(HT_CONFIG_PORT, 1);
 }
-module_exit(ht6560b_mod_exit);
+
+module_init(ht6560b_init);
+module_exit(ht6560b_exit);
 #endif
 
+MODULE_AUTHOR("See Local File");
+MODULE_DESCRIPTION("HT-6560B EIDE-controller support");
+MODULE_LICENSE("GPL");

_