PATCH: "Pass module parameters" to built-in drivers
Subsystems (12)
Alan, Keith, All,
Here's a proposed v2.4 "quick fix" to allow specifying "module parameters" to any of the many drivers without option parsers when built in to the kernel.
I understand Keith has intentions to do this differently in v2.5, however I'd be happy if something along these lines could find its way into v2.4, maybe the below, something similar to the below but with the default of "N" instead, or maybe a completely different.
I haven't tested it extensively - only so far as that it works just fine with all the modules that I wanted set options for on bootup; none of these are, for example, string or integer list options so those aren't tested.
All code is placed in init functions, I'm not sure about where the strings specified as options to generic_parse_function will end up though.
Comments/feedback?
(and I know without the ".c" would be nicer, but AFAIK that can't be done without either extra run-time code (chop the .c at run-time) or makefile support (-D__FILEBASE__=....).
Documentation/Configure.help renamed from linux/Documentation/Configure.help +8 -0
@@ -3729,6 +3729,14 @@ replacement for kerneld.) Say Y here and read about configuring it in Documentation/kmod.txt. +Module parameter parsing for non-modular drivers +CONFIG_MODPARM_BUILTIN + This allows you to set parameters which are normally passed as + options to modules by specifying the parameter as file.c:var=value + on the kernel command line (eg, xirc2ps_cs.c:lockup_hack=1). + Say Y here if unsure - all additional memory used is freed during + bootup. + ARP daemon support (EXPERIMENTAL) CONFIG_ARPD Normally, the kernel maintains an internal cache which maps IP
arch/alpha/config.in renamed from linux/arch/alpha/config.in +1 -0
@@ -20,6 +20,7 @@ bool 'Set version information on all symbols for modules' CONFIG_MODVERSIONS bool 'Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/alpha/defconfig renamed from linux/arch/alpha/defconfig +1 -0
@@ -14,6 +14,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
arch/arm/config.in renamed from linux/arch/arm/config.in +1 -0
@@ -25,6 +25,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu
arch/arm/defconfig renamed from linux/arch/arm/defconfig +1 -0
@@ -42,6 +42,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
arch/i386/config.in renamed from linux/arch/i386/config.in +1 -0
@@ -22,6 +22,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/i386/defconfig renamed from linux/arch/i386/defconfig +1 -0
@@ -17,6 +17,7 @@ CONFIG_MODULES=y CONFIG_MODVERSIONS=y CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # Processor type and features
arch/ia64/config.in renamed from linux/arch/ia64/config.in +1 -0
@@ -12,6 +12,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/ia64/defconfig renamed from linux/arch/ia64/defconfig +1 -0
@@ -39,6 +39,7 @@ # Loadable module support # # CONFIG_MODULES is not set +CONFIG_MODPARM_BUILTIN=y # # Parallel port support
arch/m68k/config.in renamed from linux/arch/m68k/config.in +1 -0
@@ -19,6 +19,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/m68k/defconfig renamed from linux/arch/m68k/defconfig +1 -0
@@ -58,6 +58,7 @@ # Loadable module support # # CONFIG_MODULES is not set +CONFIG_MODPARM_BUILTIN=y # # Block devices
arch/mips/config.in renamed from linux/arch/mips/config.in +1 -0
@@ -101,6 +101,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/mips/defconfig renamed from linux/arch/mips/defconfig +1 -0
@@ -34,6 +34,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # CPU selection
arch/mips64/config.in renamed from linux/arch/mips64/config.in +1 -0
@@ -120,6 +120,7 @@ bool 'Set version information on all symbols for modules' CONFIG_MODVERSIONS bool 'Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN source drivers/pci/Config.in
arch/mips64/defconfig renamed from linux/arch/mips64/defconfig +1 -0
@@ -60,6 +60,7 @@ # Loadable module support # # CONFIG_MODULES is not set +CONFIG_MODPARM_BUILTIN=y CONFIG_PCI_NAMES=y #
arch/parisc/config.in renamed from linux/arch/parisc/config.in +1 -0
@@ -53,6 +53,7 @@ bool 'Set version information on all symbols for modules' CONFIG_MODVERSIONS bool 'Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/parisc/defconfig renamed from linux/arch/parisc/defconfig +1 -0
@@ -29,6 +29,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
arch/ppc/config.in renamed from linux/arch/ppc/config.in +1 -0
@@ -18,6 +18,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/ppc/defconfig renamed from linux/arch/ppc/defconfig +1 -0
@@ -14,6 +14,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # Platform support
arch/s390/config.in renamed from linux/arch/s390/config.in +1 -0
@@ -23,6 +23,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/s390/defconfig renamed from linux/arch/s390/defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
arch/s390x/config.in renamed from linux/arch/s390x/config.in +1 -0
@@ -32,6 +32,7 @@ bool 'Set version information on all symbols for modules' CONFIG_MODVERSIONS bool 'Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/s390x/defconfig renamed from linux/arch/s390x/defconfig +1 -0
@@ -25,6 +25,7 @@ CONFIG_MODULES=y # CONFIG_MODVERSIONS is not set CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
arch/sh/config.in renamed from linux/arch/sh/config.in +1 -0
@@ -20,6 +20,7 @@ bool ' Set version information on all module symbols' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/sh/defconfig renamed from linux/arch/sh/defconfig +1 -0
@@ -13,6 +13,7 @@ # Loadable module support # # CONFIG_MODULES is not set +CONFIG_MODPARM_BUILTIN=y # # Processor type and features
arch/sparc/config.in renamed from linux/arch/sparc/config.in +1 -0
@@ -19,6 +19,7 @@ bool ' Set version information on all symbols for modules' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/sparc/defconfig renamed from linux/arch/sparc/defconfig +1 -0
@@ -15,6 +15,7 @@ CONFIG_MODULES=y CONFIG_MODVERSIONS=y CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
arch/sparc64/config.in renamed from linux/arch/sparc64/config.in +1 -0
@@ -16,6 +16,7 @@ bool ' Set version information on all symbols for modules' CONFIG_MODVERSIONS bool ' Kernel module loader' CONFIG_KMOD fi +bool 'Module parameter passing for non-modular drivers' CONFIG_MODPARM_BUILTIN endmenu mainmenu_option next_comment
arch/sparc64/defconfig renamed from linux/arch/sparc64/defconfig +1 -0
@@ -13,6 +13,7 @@ CONFIG_MODULES=y CONFIG_MODVERSIONS=y CONFIG_KMOD=y +CONFIG_MODPARM_BUILTIN=y # # General setup
drivers/scsi/sr.c renamed from linux/drivers/scsi/sr.c +4 -0
@@ -56,6 +56,10 @@#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */ #include "constants.h" +#ifndef MODULE +extern int xa_test; +#endif +MODULE_PARM (xa_test,"i" );/* see sr_ioctl.c */ #define MAX_RETRIES 3
drivers/scsi/sr_ioctl.c renamed from linux/drivers/scsi/sr_ioctl.c +4 -0
@@ -21,7 +21,11 @@/* The sr_is_xa() seems to trigger firmware bugs with some drives :-( * It is off by default and can be turned on with this module parameter */ +#ifdef MODULE static int xa_test =0 ; +#else +int xa_test =0 ; +#endif extern void get_sectorsize (int );
include/linux/module.h renamed from linux/include/linux/module.h +15 -0
@@ -274,10 +274,25 @@#else /* MODULE */ +/* needed for __init */ +#include <linux/init.h> + +/* from main.c but used (and only used) here */ +extern int generic_parse_function (char *input,const char *name,void *loc,const char *fmt)__init ; +#define MODULE_AUTHOR (name)#define MODULE_DESCRIPTION (desc)#define MODULE_SUPPORTED_DEVICE (name) +#ifdef CONFIG_MODPARM_BUILTIN +#define MODULE_PARM(var,type) \ + static int __init _setup_##var (char *str) { \ + /* are the strings put in the correct section? */ \ + return generic_parse_function(str, __FILE__##":"#var, &var, type); \ + } \ + __setup (__FILE__##":"#var"=", _setup_##var); +#else #define MODULE_PARM (var,type) +#endif #define MODULE_PARM_DESC (var,desc)#define MODULE_GENERIC_TABLE (gtype,name)#define MODULE_DEVICE_TABLE (type,name)
lib/cmdline.c renamed from linux/lib/cmdline.c +205 -0
211 lines not on this page · raw message
David.
--
David Luyer Phone: +61 3 9674 7525 Senior Network Engineer P A C I F I C Fax: +61 3 9699 8693 Pacific Internet (Australia) I N T E R N E T Mobile: +61 4 1111 2983 http://www.pacific.net.au/ NASDAQ: PCNTF
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 2 lines · David Luyer
Here's a proposed v2.4 "quick fix" to allow specifying "module parameters" to any of the many drivers without option parsers when built in to the kernel.
Fundamental problem: you assume that each module is built from a source of the same name, this is not true. For example, scsi_mod is built from several objects, including scsi.c and scsi_scan.c which contain MODULE_PARM. With your patch the user has to do
scsi.c:scsihosts="..." scsi_scan.c:max_scsi_luns=n (built in)
or
options scsi_mod scsihosts="..." max_scsi_luns=n (module)
Inconsistent methods for setting the same parameter are bad. I can and will do this cleanly in 2.5. Parameters will be always be keyed by the module name, even if they are compiled in. Adding an inconsistent method to 2.4 then changing to a correct method in 2.5 is a bad idea, wait until we can do it right.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 3 lines · Keith Owens
Inconsistent methods for setting the same parameter are bad. I can and will do this cleanly in 2.5. Parameters will be always be keyed by the module name, even if they are compiled in. Adding an inconsistent
I'm curious as to what boot argument equivalent you envision for e.g.
options ne io=0x280,0x300 irq=10,12 bad=0,1
Quoted 2 lines
method to 2.4 then changing to a correct method in 2.5 is a bad idea, wait until we can do it right.
As a related issue, this will allow me (or whoever) to kill off the ether=x,y,z,ethN boot argument for compiled in ethernet drivers at the same time. It made sense back in 1.0/1.2 days when distro kernels were shipped with everything compiled in and ISA cards were the norm. Now it is hardly used and generally a PITA to support.
Paul.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 3 lines · Paul Gortmaker
I'm curious as to what boot argument equivalent you envision for e.g.
options ne io=0x280,0x300 irq=10,12 bad=0,1
ne.io=0x280,0x300 ne.irq=10,12 ne.bad=0,1. I might even be generous and handle ne{io=0x280,0x300 irq=10,12 bad=0,1}
If a parameter name is unique amongst all compiled in objects then it does not need the object/module name, although it is recommended.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 2 lines · Keith Owens
Inconsistent methods for setting the same parameter are bad. I can and will do this cleanly in 2.5.
If your approach isn't overly intrusive (i.e. doesn't require changes to all files containing module parameters, or such), maybe you could make a patch for 2.4.x and wave it a little under Linus' nose. Maybe he likes the scent ;-)
In any case, once it's in 2.5.x, and if it is as useful as I suspect it to be, it would probably be back-ported to 2.4 sooner or later.
- Werner
Signature · 7 lines
_________________________________________________________________________ / Werner Almesberger, ICA, EPFL, CH [email protected] / /_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Quoted 8 lines · Werner Almesberger
Quoted 2 lines · Keith Owens
Inconsistent methods for setting the same parameter are bad. I can and will do this cleanly in 2.5.
If your approach isn't overly intrusive (i.e. doesn't require changes to all files containing module parameters, or such), maybe you could make a patch for 2.4.x and wave it a little under Linus' nose. Maybe he likes the scent ;-)
It is part of my total Makefile rewrite for 2.5. A clean implementation of module parameters mapping to setup code requires the mapping of a source file to the module it is linked into. That information is difficult to extract with the current Makefile system, my rewrite makes it easy.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines · Keith Owens
It is part of my total
Makefilerewrite for 2.5. A clean implementation of module parameters mapping to setup code requires the mapping of a source file to the module it is linked into. That information is difficult to extract with the currentMakefilesystem, my rewrite makes it easy.
Hmm, don't we already have all that __setup() stuff laying around? Ok, it might not be built into the .o for modules, but it could be. Could we not do something along the lines of:
1. User passes parameters on the kernel command line.
2. modprobe reads the kernel command line and sorts out those that correspond to the __setup() stuff in the module being loaded.
3. modprobe combines in any extra settings from /etc/modules.conf
IIRC, this would satisfy the original posters intentions, presumably without too much hastle?
--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 11 lines · Russell King
Hmm, don't we already have all that
__setup()stuff laying around? Ok, it might not be built into the .o for modules, but it could be. Could we not do something along the lines of:1. User passes parameters on the kernel command line.
2. modprobe reads the kernel command line and sorts out those that correspond to the__setup()stuff in the module being loaded.
3. modprobe combines in any extra settings from/etc/modules.confIIRC, this would satisfy the original posters intentions, presumably without too much hastle?
Apart from the fact that it is completely backwards from the original intent. The problem is objects that have MODULE_PARM but no __setup.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 1 line · Keith Owens
It is part of my total
Makefilerewrite for 2.5.
Oh, I see. Too bad.
Quoted 2 lines
A clean implementation of module parameters mapping to setup code requires the mapping of a source file to the module it is linked into.
I was afraid that this would be a problem (and hoping that you've found some miracle solution ;-)
- Werner
Signature · 7 lines
_________________________________________________________________________ / Werner Almesberger, ICA, EPFL, CH [email protected] / /_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] Please read the FAQ at http://www.tux.org/lkml/
Hi!
Well, I did a very similar patch about 2.3.3x and it got even included in -acXX during a Linus vacation - but it got dropped for some reason (f.i. such an approach does not work well for multi-file modules, I was told). I re-sent it during the 2.4.0-test phase and got no reply, so I think just adding __setup() stuff manually to every module seems the way to go... :(
Richard.
Quoted 14 lines · Werner Almesberger
Quoted 2 lines · Keith Owens
Inconsistent methods for setting the same parameter are bad. I can and will do this cleanly in 2.5.
If your approach isn't overly intrusive (i.e. doesn't require changes to all files containing module parameters, or such), maybe you could make a patch for 2.4.x and wave it a little under Linus' nose. Maybe he likes the scent ;-)
In any case, once it's in 2.5.x, and if it is as useful as I suspect it to be, it would probably be back-ported to 2.4 sooner or later.
- Werner
Quoted 9 lines
--
_________________________________________________________________________
/ Werner Almesberger, ICA, EPFL, CH [email protected] /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/ -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
--
Richard Guenther <[email protected]>
WWW: http://www.anatom.uni-tuebingen.de/~richi/
The GLAME Project: http://www.glame.de/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/