Skip to contentSkip to conversation

fix for missing proc dir in megaraid driver.

PATCH In review Paul Wagland 3 participants 4 messages Feb 17, 2004 – Feb 18, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix for missing proc dir in megaraid driver.

This applies against 2.6.2. and resolves the problem of the missing /proc/megaraid/* entries. The problem was that the megaraid directory was getting created after it was used. Sometime in the next few days I will also send through the work I have done to convert to sysfs.

Hope this helps,
Paul
patch follows:

drivers/scsi/megaraid.c +7 -4
diff --recursive --unified linux-2.6.2/drivers/scsi/megaraid.c linux-2.6.2.megaraid/drivers/scsi/megaraid.c
@@ -5118,17 +5118,20 @@
 	if (max_mbox_busy_wait > MBOX_BUSY_WAIT)
 		max_mbox_busy_wait = MBOX_BUSY_WAIT;
 
-	error = pci_module_init(&megaraid_pci_driver);
-	if (error) 
-		return error;
-	
 #ifdef CONFIG_PROC_FS
 	mega_proc_dir_entry = proc_mkdir("megaraid", &proc_root);
 	if (!mega_proc_dir_entry) {
 		printk(KERN_WARNING
 				"megaraid: failed to create megaraid root\n");
 	}
 #endif
+	error = pci_module_init(&megaraid_pci_driver);
+	if (error) {
+#ifdef CONFIG_PROC_FS
+		remove_proc_entry("megaraid", &proc_root);
+#endif
+		return error;
+	}
 
 	/*
 	 * Register the driver as a character device, for applications
#1 lore raw
Quoted 29 lines · Paul Wagland

This applies against 2.6.2. and resolves the problem of the missing /proc/megaraid/* entries. The problem was that the megaraid directory was getting created after it was used. Sometime in the next few days I will also send through the work I have done to convert to sysfs.

Hope this helps,
Paul
patch follows:

diff --recursive --unified linux-2.6.2/drivers/scsi/megaraid.c linux-2.6.2.megaraid/drivers/scsi/megaraid.c

drivers/scsi/megaraid.c +0 -4
@@ -5118,17 +5118,20 @@
 	if (max_mbox_busy_wait > MBOX_BUSY_WAIT)
 		max_mbox_busy_wait = MBOX_BUSY_WAIT;
 
-	error = pci_module_init(&megaraid_pci_driver);
-	if (error) 
-		return error;
-	
 #ifdef CONFIG_PROC_FS
 	mega_proc_dir_entry = proc_mkdir("megaraid", &proc_root);
 	if (!mega_proc_dir_entry) {
 		printk(KERN_WARNING
 				"megaraid: failed to create megaraid root\n");
 	}
 #endif

drivers/scsi/megaraid.c line 5137

Quoted 10 lines
drivers/scsi/megaraid.c +7 -0
+	error = pci_module_init(&megaraid_pci_driver);
+	if (error) {
+#ifdef CONFIG_PROC_FS
+		remove_proc_entry("megaraid", &proc_root);
+#endif
+		return error;
+	}
 
 	/*
 	 * Register the driver as a character device, for applications

Actually, all the CONFIG_PROC_FS ifdefs can go away. They're properly stubbed in include/linux/proc_fs.h.

Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
#2 lore raw
Quoted 9 lines · Matthew Wilcox
Quoted 5 lines · Paul Wagland

This applies against 2.6.2. and resolves the problem of the missing /proc/megaraid/* entries. The problem was that the megaraid directory was getting created after it was used. Sometime in the next few days I will also send through the work I have done to convert to sysfs.

Actually, all the CONFIG_PROC_FS ifdefs can go away. They're properly stubbed in include/linux/proc_fs.h.

OK, I can resubmit with those #ifdefs in megaraid_init removed, though this does raise the size of the module in that case by a small amount, and also means that even though the kernel is configured as being a non-procfs kernel, the megaraid module will still complain that it cannot "create megaraid root". Hmm. Looking at this, this error message is not overly intuitive anyway :-), but when procfs is not even configured this could easily be mistaken for something quite serious.

If you would like a re-submit with the CONFIG_PROC_FS removed, then just let me know.

Cheers,
Paul

#3 lore raw
Quoted 10 lines · Paul Wagland

OK, I can resubmit with those #ifdefs in megaraid_init removed, though this does raise the size of the module in that case by a small amount, and also means that even though the kernel is configured as being a non-procfs kernel, the megaraid module will still complain that it cannot "create megaraid root". Hmm. Looking at this, this error message is not overly intuitive anyway :-), but when procfs is not even configured this could easily be mistaken for something quite serious.

If you would like a re-submit with the CONFIG_PROC_FS removed, then just let me know.

Hmmmm ...

A separate issue, but I can't even boot if I enable CONFIG_SCSI_PROC_FS but disable CONFIG_PROC_FS. We need to tie the two together.

I get this error hidden away in the dmesg:

SCSI subsystem failed to initialize, error = 12

And this badness and oops in init_this_scsi_driver:

Badness in kobject_get at lib/kobject.c:431

Call Trace:
 [<c01996e2>] kobject_get+0x2e/0x3c
 [<c01bfdfe>] class_get+0x16/0x34
 [<c01c00ce>] class_device_add+0x4a/0x140
 [<c01bea45>] get_device+0x11/0x20
 [<c01dd850>] scsi_add_host+0xb4/0x100
 [<c0356a9a>] init_this_scsi_driver+0x7a/0xe0
 [<c03447ad>] do_initcalls+0x3d/0x8c
 [<c0344815>] do_basic_setup+0x19/0x1a
 [<c01050cc>] init+0x44/0x148
 [<c0105088>] init+0x0/0x148
 [<c0106ed1>] kernel_thread_helper+0x5/0xc

Unable to handle kernel NULL pointer dereference at virtual address

0000000c
printing eip:
c017384f
*pde = 00104001

Oops: 0000 [#1]
CPU:    0
EIP:    0060:[<c017384f>]    Not tainted
EFLAGS: 00010286

EIP is at create_dir+0xf/0x88
eax: f4b86964 ebx: f4b86960 ecx: c03087c8 edx: f4b86964
esi: c3d7ff54 edi: 00000000 ebp: f4b868c0 esp: c3d7ff30
ds: 007b es: 007b ss: 0068
Process swapper (pid: 1, threadinfo=c3d7e000 task=f519f900)

Stack: f4b86960 f4b86960 c0308780 c017393f f4b86960 00000000 f4b86964
c3d7ff54 
       00000000 00000000 c01990c3 f4b86960 f4b86960 c030a914 c0199519
f4b86960 
       f4b86960 c030a900 c030a914 c01c00f8 f4b86960 f4b86958 00000000
f4b86800 
Call Trace:
 [<c017393f>] sysfs_create_dir+0x5b/0x70
 [<c01990c3>] create_dir+0x13/0x3c
 [<c0199519>] kobject_add+0xa9/0xe4
 [<c01c00f8>] class_device_add+0x74/0x140
 [<c01bea45>] get_device+0x11/0x20
 [<c01dd850>] scsi_add_host+0xb4/0x100
 [<c0356a9a>] init_this_scsi_driver+0x7a/0xe0
 [<c03447ad>] do_initcalls+0x3d/0x8c
 [<c0344815>] do_basic_setup+0x19/0x1a
 [<c01050cc>] init+0x44/0x148
 [<c0105088>] init+0x0/0x148
 [<c0106ed1>] kernel_thread_helper+0x5/0xc

Code: 8b 47 0c 8d 48 6c f0 ff 48 6c 0f 88 ce 02 00 00 52 57 e8 9a 
 <0>Kernel panic: Attempted to kill init!

-- Patrick Mansfield