Skip to contentSkip to conversation

2.5.51 ide module problem

DISCUSSION Adam J. Richter 3 participants 6 messages Dec 11, 2002 – Dec 14, 2002 1 message not in the archive

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

depmod will ecounter "Segmentation fault" if the ide.ko and ide-io.ps modules are in /lib/modules/2.5.51/kernel

I think the new depmod recurses infinitely when it encounters
circular dependencies. It eventually segfaults and leaves a huge modules.dep file from the infinite loop. If you look at the final huge line in that file, you can see where the loop occurred.

depmod has no need to do any recursion, since it only needs
to determine the immediate dependencies of each module. However, noticing such loops and printing them out would be a handy feature.

I use IDE as a module, but I had to change the Makefile to
build a big ide-mod.o from most of the core objects rather than allowing each one to be its own module. I believe I posted IDE modularization patches at least once a couple of months ago, but it seems to have fallen between the cracks. I could repost it if need be, although I have not yet booted 2.5.51.

Also note that I have not used the in kernel-based module
loader recently, as I have been patching my kernels to use the user level module code. I am planning to try the kernel-base module loader in 2.5.51 once I fix other problems it has finding the root device under devfs. So, it's remotely possible that you may also see module problems that I've missed.

Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America

"Free Software For The Rest Of Us."

#1 lore raw
Quoted 12 lines · Adam J. Richter
Quoted 2 lines

depmod will ecounter "Segmentation fault" if the ide.ko and ide-io.ps modules are in /lib/modules/2.5.51/kernel

I think the new depmod recurses infinitely when it encounters
circular dependencies. It eventually segfaults and leaves a huge modules.dep file from the infinite loop. If you look at the final huge line in that file, you can see where the loop occurred.

depmod has no need to do any recursion, since it only needs
to determine the immediate dependencies of each module. However, noticing such loops and printing them out would be a handy feature.

Quoted 6 lines

I use IDE as a module, but I had to change the Makefile to
build a big ide-mod.o from most of the core objects rather than allowing each one to be its own module. I believe I posted IDE modularization patches at least once a couple of months ago, but it seems to have fallen between the cracks. I could repost it if need be

Yes, please, send me your patch. I hope this patch works for module-init-tools-0.9.3

Quoted 1 line

, although I have not yet booted 2.5.51.

I had same problem with pre 2.5.51. With 2.5.51, kernel now boot and I'm able to get login prompt using ramdisk. Only catch is I've to specify root=/dev/ram0 instead of /dev/ram for it to boot.

Thanks,
Jeff.

Quoted 13 lines

Also note that I have not used the in kernel-based module
loader recently, as I have been patching my kernels to use the user level module code. I am planning to try the kernel-base module loader in 2.5.51 once I fix other problems it has finding the root device under devfs. So, it's remotely possible that you may also see module problems that I've missed.

Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America

"Free Software For The Rest Of Us."

#2 lore raw
Quoted 10 lines · Jeff Chua
Quoted 6 lines · Adam J. Richter

I use IDE as a module, but I had to change the Makefile to
build a big ide-mod.o from most of the core objects rather than allowing each one to be its own module. I believe I posted IDE modularization patches at least once a couple of months ago, but it seems to have fallen between the cracks. I could repost it if need be

Yes, please, send me your patch. I hope this patch works for module-init-tools-0.9.3

Here is a quick diff of my drivers/ide subdirectory versus stock 2.5.51.

Signature · 4 lines
Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America
                         "Free Software For The Rest Of Us."
drivers/ide/Kconfig +2 -2
diff -u -r linux-2.5.51/drivers/ide/Kconfig linux/drivers/ide/Kconfig
@@ -199,7 +199,7 @@
 	depends on BLK_DEV_IDE
 
 config BLK_DEV_CMD640
-	bool "CMD640 chipset bugfix/support"
+	tristate "CMD640 chipset bugfix/support"
 	depends on BLK_DEV_IDE && X86
 	---help---
 	  The CMD-Technologies CMD640 IDE chip is used on many common 486 and
@@ -247,7 +247,7 @@
 	default BLK_DEV_IDEDMA_PMAC if ALL_PPC && BLK_DEV_IDEDMA_PMAC
 
 config BLK_DEV_GENERIC
-	bool "Generic PCI IDE Chipset Support"
+	tristate "Generic PCI IDE Chipset Support"
 	depends on PCI && BLK_DEV_IDEPCI
 
 config IDEPCI_SHARE_IRQ
drivers/ide/Makefile +10 -9
diff -u -r linux-2.5.51/drivers/ide/Makefile linux/drivers/ide/Makefile
@@ -14,20 +14,21 @@
 
 # Core IDE code - must come before legacy
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o
+obj-$(CONFIG_BLK_DEV_IDE)		+= ide-mod.o
+ide-mod-objs				+= ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o
 obj-$(CONFIG_BLK_DEV_IDEDISK)		+= ide-disk.o
 obj-$(CONFIG_BLK_DEV_IDECD)		+= ide-cd.o
 obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy.o
 
-obj-$(CONFIG_BLK_DEV_IDEPCI)		+= setup-pci.o
-obj-$(CONFIG_BLK_DEV_IDEDMA_PCI)	+= ide-dma.o
-obj-$(CONFIG_BLK_DEV_IDE_TCQ)		+= ide-tcq.o
-obj-$(CONFIG_BLK_DEV_ISAPNP)		+= ide-pnp.o
-
-ifeq ($(CONFIG_BLK_DEV_IDE),y)
-obj-$(CONFIG_PROC_FS)			+= ide-proc.o
-endif
+obj-ide-$(CONFIG_BLK_DEV_IDEPCI)	+= setup-pci.o
+obj-ide-$(CONFIG_BLK_DEV_IDEDMA_PCI)	+= ide-dma.o
+obj-ide-$(CONFIG_BLK_DEV_IDE_TCQ)	+= ide-tcq.o
+obj-ide-$(CONFIG_BLK_DEV_ISAPNP)	+= ide-pnp.o
+obj-ide-$(CONFIG_PROC_FS)		+= ide-proc.o
+
+ide-mod-objs				+= $(obj-ide-y)
+obj-m					+= $(obj-ide-m)
 
 obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ ppc/ arm/
 
drivers/ide/ide-pnp.c +13 -0
diff -u -r linux-2.5.51/drivers/ide/ide-pnp.c linux/drivers/ide/ide-pnp.c
@@ -19,6 +19,7 @@
 #include <linux/ide.h>
 #include <linux/init.h>
 
+#include <linux/module.h>
 #include <linux/isapnp.h>
 
 #define DEV_IO(dev, index) (dev->resource[index].start)
@@ -88,6 +89,18 @@
 	{	0 }
 };
 
+#ifdef MODULE
+static struct isapnp_card_id ide_isa_ids[] __initdata = {
+	{
+		card_vendor: ISAPNP_ANY_ID,
+		card_device: ISAPNP_ANY_ID,
+                devs: {	ISAPNP_DEVICE_ID('P', 'N', 'P', 0x0600) },
+	},
+	{ ISAPNP_CARD_END }
+};
+ISAPNP_CARD_TABLE(ide_isa_ids);
+#endif
+
 #define NR_PNP_DEVICES 8
 struct pnp_dev_inst {
 	struct pci_dev *dev;
drivers/ide/ide-probe.c +6 -6
diff -u -r linux-2.5.51/drivers/ide/ide-probe.c linux/drivers/ide/ide-probe.c
@@ -831,7 +831,8 @@
 	ide_toggle_bounce(drive, 1);
 
 #ifdef CONFIG_BLK_DEV_IDE_TCQ_DEFAULT
-	HWIF(drive)->ide_dma_queued_on(drive);
+	if (HWIF(drive)->ide_dma_queued_on)
+		HWIF(drive)->ide_dma_queued_on(drive);
 #endif
 }
 
@@ -1221,10 +1222,10 @@
 	return 0;
 }
 
-#ifdef MODULE
-extern int (*ide_xlate_1024_hook)(struct block_device *, int, int, const char *);
+int (*ide_xlate_1024_hook)(struct block_device *, int, int, const char *);
+EXPORT_SYMBOL(ide_xlate_1024_hook);
 
-int init_module (void)
+int ide_probe_init (void)
 {
 	unsigned int index;
 	
@@ -1236,10 +1237,9 @@
 	return 0;
 }
 
-void cleanup_module (void)
+void ide_probe_cleanup (void)
 {
 	ide_probe = NULL;
 	ide_xlate_1024_hook = 0;
 }
 MODULE_LICENSE("GPL");
-#endif /* MODULE */
drivers/ide/ide.c +1 -1
diff -u -r linux-2.5.51/drivers/ide/ide.c linux/drivers/ide/ide.c
@@ -2375,7 +2375,7 @@
 	ide_init_builtin_drivers();
 	initializing = 0;
 
-	return 0;
+	return ide_probe_init();
 }
 
 #ifdef MODULE
drivers/ide/pci/cmd640.c +3 -7
diff -u -r linux-2.5.51/drivers/ide/pci/cmd640.c linux/drivers/ide/pci/cmd640.c
@@ -102,6 +102,7 @@
 #define CMD640_PREFETCH_MASKS 1
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
@@ -118,11 +119,6 @@
 #include "ide_modes.h"
 
 /*
- * This flag is set in ide.c by the parameter:  ide0=cmd640_vlb
- */
-int cmd640_vlb = 0;
-
-/*
  * CMD640 specific registers definition.
  */
 
@@ -723,7 +719,7 @@
 /*
  * Probe for a cmd640 chipset, and initialize it if found.  Called from ide.c
  */
-int __init ide_probe_for_cmd640x (void)
+static int ide_probe_for_cmd640x (void)
 {
 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
 	int second_port_toggled = 0;
@@ -883,4 +879,4 @@
 #endif
 	return 1;
 }
-
+module_init(ide_probe_for_cmd640x);

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines · Jeff Chua
Quoted 1 line · Adam J. Richter

Here is a quick diff of my drivers/ide subdirectory versus stock 2.5.51.

+++ linux/drivers/ide/pci/cmd640.c 2002-11-27 18:24:00.000000000
-int cmd640_vlb = 0;

These lines must "stay" in cmd640.c, else it won't compile.

Quoted 7 lines

"depmod -a" works now, but encounter a new problem when I tried to load ide ...

# modprobe ide-mod
FATAL: Error inserting ide_mod (/lib/modules/2.5.51/kernel/ide-mod.ko):
Unknown symbol in module
ide_mod: Unknown symbol pci_enable_device_bars

Jeff: Sorry, I forgot to include diffs for include/linux/ide.h
and drivers/pci/pci.c. Here is a corrected patch. I am running the code on that machine on which I'm composing this email, and I have also verified that cmd640.c compiled without complaint (well, actually, I've modified the patch slightly to eliminate some unrelated diffs).

Alan: If you want, please feel free to merge this change.
Alternatively, if you're stepping away from 2.5 while waiting for modules to stabilize, I'd appreciate knowing what you'd prefer be done with incoming IDE patches (submit them to Andre and Jens, just wait, something else?). For what it's worth, 2.5.51 + init-module-tools-0.9.3 is the first kernel-based module loader configuration which works enough so that I'm able to work on other things. For the past few releases, I had been restoring user level module loading. There still are a lot of quirks with the kernel based module loading, but you might find it sufficient to get things done.

Adam J. Richter     __     ______________   575 Oroville Road
[email protected]     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America

"Free Software For The Rest Of Us."

include/linux/ide.h +6 -1
@@ -1742,8 +1742,12 @@
 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
 
+/* ide.c */
+extern int ide_probe_init(void);
+extern void ide_probe_cleanup(void);
+extern int cmd640_vlb;
 extern spinlock_t ide_lock;
 
 #define local_irq_set(flags)	do { local_save_flags((flags)); local_irq_enable(); } while (0)
--- linux-2.5.51/drivers/pci/pci.c	2002-12-09 18:45:52.000000000 -0800
+++ linux/drivers/pci/pci.c	2002-12-09 19:03:18.000000000 -0800
@@ -736,6 +736,7 @@
 EXPORT_SYMBOL(isa_bridge);
 #endif
 
+EXPORT_SYMBOL(pci_enable_device_bars);
 EXPORT_SYMBOL(pci_enable_device);
 EXPORT_SYMBOL(pci_disable_device);
 EXPORT_SYMBOL(pci_max_busnr);
drivers/ide/Kconfig +2 -2
diff -r -u linux-2.5.51/drivers/ide/Kconfig linux/drivers/ide/Kconfig
@@ -199,7 +199,7 @@
 	depends on BLK_DEV_IDE
 
 config BLK_DEV_CMD640
-	bool "CMD640 chipset bugfix/support"
+	tristate "CMD640 chipset bugfix/support"
 	depends on BLK_DEV_IDE && X86
 	---help---
 	  The CMD-Technologies CMD640 IDE chip is used on many common 486 and
@@ -247,7 +247,7 @@
 	default BLK_DEV_IDEDMA_PMAC if ALL_PPC && BLK_DEV_IDEDMA_PMAC
 
 config BLK_DEV_GENERIC
-	bool "Generic PCI IDE Chipset Support"
+	tristate "Generic PCI IDE Chipset Support"
 	depends on PCI && BLK_DEV_IDEPCI
 
 config IDEPCI_SHARE_IRQ
drivers/ide/Makefile +10 -9
diff -r -u linux-2.5.51/drivers/ide/Makefile linux/drivers/ide/Makefile
@@ -14,21 +14,22 @@
 
 # Core IDE code - must come before legacy
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o
+obj-$(CONFIG_BLK_DEV_IDE)		+= ide-mod.o
+ide-mod-objs				+= ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o
 obj-$(CONFIG_BLK_DEV_IDEDISK)		+= ide-disk.o
 obj-$(CONFIG_BLK_DEV_IDECD)		+= ide-cd.o
 obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy.o
 
-obj-$(CONFIG_BLK_DEV_IDEPCI)		+= setup-pci.o
-obj-$(CONFIG_BLK_DEV_IDEDMA_PCI)	+= ide-dma.o
-obj-$(CONFIG_BLK_DEV_IDE_TCQ)		+= ide-tcq.o
-obj-$(CONFIG_BLK_DEV_ISAPNP)		+= ide-pnp.o
-
-ifeq ($(CONFIG_BLK_DEV_IDE),y)
-obj-$(CONFIG_PROC_FS)			+= ide-proc.o
-endif
+obj-ide-$(CONFIG_BLK_DEV_IDEPCI)	+= setup-pci.o
+obj-ide-$(CONFIG_BLK_DEV_IDEDMA_PCI)	+= ide-dma.o
+obj-ide-$(CONFIG_BLK_DEV_IDE_TCQ)	+= ide-tcq.o
+obj-ide-$(CONFIG_BLK_DEV_ISAPNP)	+= ide-pnp.o
+obj-ide-$(CONFIG_PROC_FS)		+= ide-proc.o
+
+ide-mod-objs				+= $(obj-ide-y)
+obj-m					+= $(obj-ide-m)
 
 obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ ppc/ arm/
 
drivers/ide/ide.c +1 -1
diff -r -u linux-2.5.51/drivers/ide/ide.c linux/drivers/ide/ide.c
@@ -2375,7 +2375,7 @@
 	ide_init_builtin_drivers();
 	initializing = 0;
 
-	return 0;
+	return ide_probe_init();
 }
 
 #ifdef MODULE
drivers/ide/pci/cmd640.c +3 -7
diff -r -u linux-2.5.51/drivers/ide/pci/cmd640.c linux/drivers/ide/pci/cmd640.c
@@ -102,6 +102,7 @@
 #define CMD640_PREFETCH_MASKS 1
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
@@ -118,11 +119,6 @@
 #include "ide_modes.h"
 
 /*
- * This flag is set in ide.c by the parameter:  ide0=cmd640_vlb
- */
-int cmd640_vlb = 0;
-
-/*
  * CMD640 specific registers definition.
  */
 
@@ -723,7 +719,7 @@
 /*
  * Probe for a cmd640 chipset, and initialize it if found.  Called from ide.c
  */
-int __init ide_probe_for_cmd640x (void)
+static int ide_probe_for_cmd640x (void)
 {
 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
 	int second_port_toggled = 0;
@@ -883,4 +879,4 @@
 #endif
 	return 1;
 }
-
+module_init(ide_probe_for_cmd640x);
drivers/ide/ide-probe.c +4 -5
@@ -831,7 +831,8 @@
 	ide_toggle_bounce(drive, 1);
 
 #ifdef CONFIG_BLK_DEV_IDE_TCQ_DEFAULT
-	HWIF(drive)->ide_dma_queued_on(drive);
+	if (HWIF(drive)->ide_dma_queued_on)
+		HWIF(drive)->ide_dma_queued_on(drive);
 #endif
 }
 
@@ -1221,10 +1222,9 @@
 	return 0;
 }
 
-#ifdef MODULE
 extern int (*ide_xlate_1024_hook)(struct block_device *, int, int, const char *);
 
-int init_module (void)
+int ide_probe_init (void)
 {
 	unsigned int index;
 	
@@ -1236,10 +1236,9 @@
 	return 0;
 }
 
-void cleanup_module (void)
+void ide_probe_cleanup (void)
 {
 	ide_probe = NULL;
 	ide_xlate_1024_hook = 0;
 }
 MODULE_LICENSE("GPL");
-#endif /* MODULE */
#5 lore raw

drivers/pci/pci.c line 742

Quoted 10 lines · Adam J. Richter
drivers/pci/pci.c +1 -0
@@ -736,6 +736,7 @@
 EXPORT_SYMBOL(isa_bridge);
 #endif
 
+EXPORT_SYMBOL(pci_enable_device_bars);
 EXPORT_SYMBOL(pci_enable_device);
 EXPORT_SYMBOL(pci_disable_device);
 EXPORT_SYMBOL(pci_max_busnr);

This one looks correct.

drivers/ide/Kconfig line 202

Quoted 9 lines

diff -r -u linux-2.5.51/drivers/ide/Kconfig linux/drivers/ide/Kconfig

drivers/ide/Kconfig +1 -1
@@ -199,7 +199,7 @@
 	depends on BLK_DEV_IDE
 
 config BLK_DEV_CMD640
-	bool "CMD640 chipset bugfix/support"
+	tristate "CMD640 chipset bugfix/support"

Please don't do this. You can't "load" the workaround meaningfully for this device

drivers/ide/Kconfig line 251

Quoted 4 lines
drivers/ide/Kconfig +1 -1
 config BLK_DEV_GENERIC
-	bool "Generic PCI IDE Chipset Support"
+	tristate "Generic PCI IDE Chipset Support"
 	depends on PCI && BLK_DEV_IDEPCI

Probably ok. I need to review that.

drivers/ide/Kconfig

Quoted 3 lines
drivers/ide/Kconfig +2 -1
-obj-$(CONFIG_BLK_DEV_IDE)		+= ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o
+obj-$(CONFIG_BLK_DEV_IDE)		+= ide-mod.o
+ide-mod-objs				+= ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o

Looks ok

drivers/ide/pci/cmd640.c

Quoted 4 lines

diff -r -u linux-2.5.51/drivers/ide/pci/cmd640.c linux/drivers/ide/pci/cmd640.c

drivers/ide/pci/cmd640.c +0 -0
@@ -102,6 +102,7 @@

No (as per comment above)

drivers/ide/ide-probe.c line 835

Quoted 9 lines
drivers/ide/ide-probe.c +2 -1
@@ -831,7 +831,8 @@
 	ide_toggle_bounce(drive, 1);
 
 #ifdef CONFIG_BLK_DEV_IDE_TCQ_DEFAULT
-	HWIF(drive)->ide_dma_queued_on(drive);
+	if (HWIF(drive)->ide_dma_queued_on)
+		HWIF(drive)->ide_dma_queued_on(drive);

Looks right

At a first glance (and its only that), drop out the CMD640 changes and the rest seems ok. Please check it on a few setups and also non modular since you've changed the probe bits a little.

Alan

#6 lore raw
In reply to Adam J. Richter
Quoted 6 lines · Adam J. Richter

something else?). For what it's worth, 2.5.51 + init-module-tools-0.9.3 is the first kernel-based module loader configuration which works enough so that I'm able to work on other things. For the past few releases, I had been restoring user level module loading. There still are a lot of quirks with the kernel based module loading, but you might find it sufficient to get things done.

I just test your patch and IDE modules are working now on 2.5.51. reiserfs, devmap and lvm2 are all working ... but the modules has to be loaded in a certain order, otherwise the whole system would crash.

modprobe ide-mod
ide_info /dev/hda
--> this crashs the system
ide_mod looks for ide_hwifs, start_request, ide_do_request, ide_do_drive_cmd, ide_diag_taskfile, ide_raw_taskfile, taskfile_lib_get_identify, task_in_intr, proc_ide_read_identify, proc_file_read, vfs_read, sys_read, syscall_call

modprobe ide-disk
ide_info /dev/hda
--> this works (ide-disk will load ide-mod first)

Under 2.4, I don't have to load the ide module first, calling fdisk /dev/hda will automatically loads the ide modules, but under 2.5, I've to manually load the ide modules.

Thanks,
Jeff.