Add a global ide=off switch for drivers/ide
Subsystems (2)
PATCH 1/1 Add a global ide=off switch for drivers/ide
Had a situation where drivers/ide was compiled in, but I wanted to turn it off to let the drivers/ata drivers take over. I ended up using ide*=noprobe, but that was somewhat clumpsy because I wasn't sure how many IDE interfaces the machine really had.
Add a global ide=off switch to handle this situation better.
The patch is a little bigger because I tried to cover all modules.
I'm also not 100% sure ENODEV is the right error return for this case, but I didn't come up with a better one.
The ARM/MIPS part is uncompiled.
drivers/ide/ide.c +13 -0
@@ -91,6 +91,9 @@ static const u8 ide_hwif_to_major[] = {static int idebus_parameter;/* holds the "idebus=" parameter */ static int system_bus_speed;/* holds what we think is VESA/PCI bus speed */ +int ide_off; +EXPORT_SYMBOL (ide_off); +DEFINE_MUTEX (ide_cfg_mtx);__cacheline_aligned_in_smp DEFINE_SPINLOCK (ide_lock );
@@ -1249,6 +1252,13 @@ static int __init ide_setup(char *s)return 0 ;printk (KERN_INFO "ide_setup: %s" , s); + +if (!strcmp (s,"ide=off" )) { +printk (" : IDE disabled\n" ); + ide_off =1 ; +return 1 ; + } +init_ide_data ();#ifdef CONFIG_BLK_DEV_IDEDOUBLER
@@ -1717,6 +1727,9 @@ static int __init ide_init(void) {int ret; +if (ide_off) +return -ENODEV ; +printk (KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n" ); system_bus_speed =ide_system_bus_speed ();
drivers/ide/setup-pci.c +2 -0
@@ -793,6 +793,8 @@ static LIST_HEAD(ide_pci_drivers);int __ide_pci_register_driver (struct pci_driver *driver,struct module *module,const char *mod_name) { +if (ide_off) +return -ENODEV ;if (!pre_init)return __pci_register_driver (driver, module, mod_name); driver->driver.owner = module;
include/linux/ide.h +2 -0
@@ -871,6 +871,8 @@ typedef struct ide_driver_s ide_driver_textern struct mutex ide_setting_mtx; +extern int ide_off; +int set_io_32bit (ide_drive_t *,int );int set_pio_mode (ide_drive_t *,int );int set_using_dma (ide_drive_t *,int );
drivers/ide/arm/bast-ide.c +3 -0
@@ -52,6 +52,9 @@ bastide_register(unsigned int base, unsistatic int __init bastide_init (void ) { +if (ide_off) +return -ENODEV ; +/* we can treat the VR1000 and the BAST the same */ if (!(machine_is_bast () ||machine_is_vr1000 ()))
drivers/ide/arm/icside.c +2 -0
@@ -824,6 +824,8 @@ static struct ecard_driver icside_driverstatic int __init icside_init (void ) { +if (ide_off) +return -ENODEV ;return ecard_register_driver (&icside_driver); }
drivers/ide/arm/rapide.c +2 -0
@@ -113,6 +113,8 @@ static struct ecard_driver rapide_driverstatic int __init rapide_init (void ) { +if (ide_off) +return -ENODEV ;return ecard_register_driver (&rapide_driver); }
drivers/ide/ide-cd.c +2 -0
@@ -3568,6 +3568,8 @@ static void __exit ide_cdrom_exit(void)static int __init ide_cdrom_init (void ) { +if (ide_off) +return -ENODEV ;return driver_register (&ide_cdrom_driver.gen_driver); }
drivers/ide/ide-disk.c +2 -0
@@ -1329,6 +1329,8 @@ static void __exit idedisk_exit (void)static int __init idedisk_init (void ) { +if (ide_off) +return -ENODEV ;return driver_register (&idedisk_driver.gen_driver); }
drivers/ide/ide-floppy.c +2 -0
@@ -2215,6 +2215,8 @@ static void __exit idefloppy_exit (void)static int __init idefloppy_init (void ) { +if (ide_off) +return -ENODEV ;printk ("ide-floppy driver " IDEFLOPPY_VERSION "\n" );return driver_register (&idefloppy_driver.gen_driver); }
drivers/ide/ide-generic.c +2 -0
@@ -14,6 +14,8 @@static int __init ide_generic_init (void ) { +if (ide_off) +return -ENODEV ;if (ide_hwifs[0 ].io_ports[IDE_DATA_OFFSET ])ide_get_lock (NULL ,NULL );/* for atari only */
drivers/ide/ide-tape.c +2 -0
@@ -4914,6 +4914,8 @@ static void __exit idetape_exit (void)static int __init idetape_init (void ) {int error =1 ; +if (ide_off) +return -ENODEV ; idetape_sysfs_class =class_create (THIS_MODULE ,"ide_tape" );if (IS_ERR (idetape_sysfs_class)) { idetape_sysfs_class =NULL ;
drivers/ide/legacy/ali14xx.c +1 -1
@@ -238,7 +238,7 @@ MODULE_PARM_DESC(probe, "probe for ALI M/* Can be called directly from ide.c. */ int __init ali14xx_init (void ) { -if (probe_ali14xx ==0 ) +if (probe_ali14xx ==0 || ide_off) goto out;/* auto-detect IDE controller port */
drivers/ide/legacy/dtc2278.c +1 -1
@@ -153,7 +153,7 @@ MODULE_PARM_DESC(probe, "probe for DTC22/* Can be called directly from ide.c. */ int __init dtc2278_init (void ) { -if (probe_dtc2278 ==0 ) +if (probe_dtc2278 ==0 || ide_off)return -ENODEV ;if (dtc2278_probe ()) {
drivers/ide/legacy/ht6560b.c +1 -1
@@ -314,7 +314,7 @@ int __init ht6560b_init(void)ide_hwif_t *hwif, *mate;int t; -if (probe_ht6560b ==0 ) +if (probe_ht6560b ==0 || ide_off)return -ENODEV ; hwif = &ide_hwifs[0 ];
drivers/ide/legacy/qd65xx.c +1 -1
@@ -497,7 +497,7 @@ MODULE_PARM_DESC(probe, "probe for QD65x/* Can be called directly from ide.c. */ int __init qd65xx_init (void ) { -if (probe_qd65xx ==0 ) +if (probe_qd65xx ==0 || ide_off)return -ENODEV ;if (qd_probe (0x30 ))
drivers/ide/legacy/umc8672.c +1 -1
@@ -176,7 +176,7 @@ MODULE_PARM_DESC(probe, "probe for UMC86/* Can be called directly from ide.c. */ int __init umc8672_init (void ) { -if (probe_umc8672 ==0 ) +if (probe_umc8672 ==0 || ide_off) goto out;if (umc8672_probe () ==0 )
drivers/ide/mips/au1xxx-ide.c +2 -0
@@ -793,6 +793,8 @@ static struct device_driver au1200_ide_dstatic int __init au_ide_init (void ) { +if (ide_off) +return -ENODEV ;return driver_register (&au1200_ide_driver); }
drivers/ide/mips/swarm.c +2 -0
@@ -157,6 +157,8 @@ static int __devinit swarm_ide_init_modustruct platform_device *pldev;int err; +if (ide_off) +return -ENODEV ;printk (KERN_INFO "SWARM IDE driver\n" );if (driver_register (&swarm_ide_driver)) {
drivers/ide/pci/piix.c +2 -0
@@ -629,6 +629,8 @@ static struct pci_driver driver = {static int __init piix_ide_init (void ) { +if (ide_off) +return -ENODEV ;piix_check_450nx ();return ide_pci_register_driver (&driver); }
Documentation/ide.txt +2 -0
@@ -290,6 +290,8 @@ Summary of ide driver parameters for ker "ide=nodma" : disable DMA globally for the IDE subsystem. + "ide=off" : Disable the IDE subsystem completely + The following are valid ONLY on ide0, which usually corresponds to the first ATA interface found on the particular host, and the defaults for the base,ctl ports must not be altered.
Hi Andi,
Sorry for the delay (the last week was a bit hectic).
Quoted 7 lines · Andi Kleen
Had a situation where
drivers/idewas compiled in, but I wanted to turn it off to let thedrivers/atadrivers take over. I ended up using ide*=noprobe, but that was somewhat clumpsy because I wasn't sure how many IDE interfaces the machine really had.Add a global ide=off switch to handle this situation better.
Overall looks OK but I think we should limit it to IDE built-in case (when IDE is modular it is all up to the user-space anyway).
Quoted 1 line
The patch is a little bigger because I tried to cover all modules.
A few still needs to be covered:
- drivers/scsi/ide-scsi.c (other directory)
- drivers/ide/legacy/ide_platform.c (new driver)
- drivers/ide/legacy/ide-cs.c (late_initcall)
- drivers/ide/pci/sgiioc4.c (ditto, not a SFF-PCI driver)
Quoted 2 lines
I'm also not 100% sure ENODEV is the right error return for this case, but I didn't come up with a better one.
-EPERM? IMO it would be more appropriate (and easy to distinguish from the "real" -ENODEV).
Quoted 9 lines
The ARM/MIPS part is uncompiled.
Signed-off-by Andi Kleen <[email protected]>Index:
linux-2.6.23-rc8-misc/drivers/ide/ide.c
===================================================================
drivers/ide/ide.c static const u8 ide_hwif_to_major[] = { · line 96
Quoted 6 lines
drivers/ide/ide.c +3
-0@@ -91,6 +91,9 @@ static const u8 ide_hwif_to_major[] = {static int idebus_parameter;/* holds the "idebus=" parameter */ static int system_bus_speed;/* holds what we think is VESA/PCI bus speed */ +int ide_off; +EXPORT_SYMBOL (ide_off); +
_GPL?
Please cover it with #ifdef/#endif CONFIG_BLK_DEV_IDE as it should be valid only when IDE is built-in.
Quoted 4 lines
drivers/ide/ide.c +0
-0DEFINE_MUTEX (ide_cfg_mtx);__cacheline_aligned_in_smp DEFINE_SPINLOCK (ide_lock );
drivers/ide/ide.c static int __init ide_setup(char *s) · line 1261
Quoted 10 lines
drivers/ide/ide.c +7
-0@@ -1249,6 +1252,13 @@ static int __init ide_setup(char *s)return 0 ;printk (KERN_INFO "ide_setup: %s" , s); + +if (!strcmp (s,"ide=off" )) { +printk (" : IDE disabled\n" ); + ide_off =1 ; +return 1 ; + } +
ditto
drivers/ide/ide.c static int __init ide_init(void) · line 1732
Quoted 10 lines
drivers/ide/ide.c +3
-0init_ide_data ();#ifdef CONFIG_BLK_DEV_IDEDOUBLER @@ -1717,6 +1727,9 @@ static int __init ide_init(void) {int ret; +if (ide_off) +return -ENODEV ; +
ditto
drivers/ide/setup-pci.c static LIST_HEAD(ide_pci_drivers); · line 797
Quoted 13 lines
drivers/ide/ide.c +0
-0printk (KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n" ); system_bus_speed =ide_system_bus_speed ();Index:
linux-2.6.23-rc8-misc/drivers/ide/setup-pci.c
===================================================================drivers/ide/setup-pci.c +2
-0@@ -793,6 +793,8 @@ static LIST_HEAD(ide_pci_drivers);int __ide_pci_register_driver (struct pci_driver *driver,struct module *module,const char *mod_name) { +if (ide_off) +return -ENODEV ;
No #ifdef/#endif CONFIG_BLK_DEV_IDE needed because all this code is under IDEPCI_PCIBUS_ORDER #ifdef/#endif (which depends on BLK_DEV_IDE=y).
[ This also means that in the current form patch doesn't cover SFF-PCI
host drivers when IDE is not built-in. ]
include/linux/ide.h typedef struct ide_driver_s ide_driver_t · line 875
Quoted 13 lines
drivers/ide/setup-pci.c +0
-0if (!pre_init)return __pci_register_driver (driver, module, mod_name); driver->driver.owner = module;Index:
linux-2.6.23-rc8-misc/include/linux/ide.h
===================================================================include/linux/ide.h +2
-0@@ -871,6 +871,8 @@ typedef struct ide_driver_s ide_driver_textern struct mutex ide_setting_mtx; +extern int ide_off; +
Please add "ide_is_off()" [ or choose some other fancy name :) ] static inline which returns ide_off if CONFIG_BLK_DEV_IDE is defined and zero otherwise.
This way we don't pollute device/host drivers with CONFIG_BLK_DEV_IDE #ifdefs.
drivers/ide/arm/bast-ide.c bastide_register(unsigned int base, unsi · line 55
Quoted 12 lines
include/linux/ide.h +0
-0int set_io_32bit (ide_drive_t *,int );int set_pio_mode (ide_drive_t *,int );int set_using_dma (ide_drive_t *,int );Index:
linux-2.6.23-rc8-misc/drivers/ide/arm/bast-ide.c
===================================================================drivers/ide/arm/bast-ide.c +1
-0@@ -52,6 +52,9 @@ bastide_register(unsigned int base, unsistatic int __init bastide_init (void ) { +if (ide_off)
"ide_is_off()"
same for all the drivers below
Quoted 205 lines
drivers/ide/arm/bast-ide.c +2
-0+return -ENODEV ; +/* we can treat the VR1000 and the BAST the same */ if (!(machine_is_bast () ||machine_is_vr1000 ()))Index:
linux-2.6.23-rc8-misc/drivers/ide/arm/icside.c
===================================================================drivers/ide/arm/icside.c +2
-0@@ -824,6 +824,8 @@ static struct ecard_driver icside_driverstatic int __init icside_init (void ) { +if (ide_off) +return -ENODEV ;return ecard_register_driver (&icside_driver); }Index:
linux-2.6.23-rc8-misc/drivers/ide/arm/rapide.c
===================================================================drivers/ide/arm/rapide.c +2
-0@@ -113,6 +113,8 @@ static struct ecard_driver rapide_driverstatic int __init rapide_init (void ) { +if (ide_off) +return -ENODEV ;return ecard_register_driver (&rapide_driver); }Index:
linux-2.6.23-rc8-misc/drivers/ide/ide-cd.c
===================================================================drivers/ide/ide-cd.c +2
-0@@ -3568,6 +3568,8 @@ static void __exit ide_cdrom_exit(void)static int __init ide_cdrom_init (void ) { +if (ide_off) +return -ENODEV ;return driver_register (&ide_cdrom_driver.gen_driver); }Index:
linux-2.6.23-rc8-misc/drivers/ide/ide-disk.c
===================================================================drivers/ide/ide-disk.c +2
-0@@ -1329,6 +1329,8 @@ static void __exit idedisk_exit (void)static int __init idedisk_init (void ) { +if (ide_off) +return -ENODEV ;return driver_register (&idedisk_driver.gen_driver); }Index:
linux-2.6.23-rc8-misc/drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c +2
-0@@ -2215,6 +2215,8 @@ static void __exit idefloppy_exit (void)static int __init idefloppy_init (void ) { +if (ide_off) +return -ENODEV ;printk ("ide-floppy driver " IDEFLOPPY_VERSION "\n" );return driver_register (&idefloppy_driver.gen_driver); }Index:
linux-2.6.23-rc8-misc/drivers/ide/ide-generic.c
===================================================================drivers/ide/ide-generic.c +2
-0@@ -14,6 +14,8 @@static int __init ide_generic_init (void ) { +if (ide_off) +return -ENODEV ;if (ide_hwifs[0 ].io_ports[IDE_DATA_OFFSET ])ide_get_lock (NULL ,NULL );/* for atari only */ Index:
linux-2.6.23-rc8-misc/drivers/ide/ide-tape.c
===================================================================drivers/ide/ide-tape.c +2
-0@@ -4914,6 +4914,8 @@ static void __exit idetape_exit (void)static int __init idetape_init (void ) {int error =1 ; +if (ide_off) +return -ENODEV ; idetape_sysfs_class =class_create (THIS_MODULE ,"ide_tape" );if (IS_ERR (idetape_sysfs_class)) { idetape_sysfs_class =NULL ;Index:
linux-2.6.23-rc8-misc/drivers/ide/legacy/ali14xx.c
===================================================================drivers/ide/legacy/ali14xx.c +1
-1@@ -238,7 +238,7 @@ MODULE_PARM_DESC(probe, "probe for ALI M/* Can be called directly from ide.c. */ int __init ali14xx_init (void ) { -if (probe_ali14xx ==0 ) +if (probe_ali14xx ==0 || ide_off) goto out;/* auto-detect IDE controller port */ Index:
linux-2.6.23-rc8-misc/drivers/ide/legacy/dtc2278.c
===================================================================drivers/ide/legacy/dtc2278.c +1
-1@@ -153,7 +153,7 @@ MODULE_PARM_DESC(probe, "probe for DTC22/* Can be called directly from ide.c. */ int __init dtc2278_init (void ) { -if (probe_dtc2278 ==0 ) +if (probe_dtc2278 ==0 || ide_off)return -ENODEV ;if (dtc2278_probe ()) {Index:
linux-2.6.23-rc8-misc/drivers/ide/legacy/ht6560b.c
===================================================================drivers/ide/legacy/ht6560b.c +1
-1@@ -314,7 +314,7 @@ int __init ht6560b_init(void)ide_hwif_t *hwif, *mate;int t; -if (probe_ht6560b ==0 ) +if (probe_ht6560b ==0 || ide_off)return -ENODEV ; hwif = &ide_hwifs[0 ];Index:
linux-2.6.23-rc8-misc/drivers/ide/legacy/qd65xx.c
===================================================================drivers/ide/legacy/qd65xx.c +1
-1@@ -497,7 +497,7 @@ MODULE_PARM_DESC(probe, "probe for QD65x/* Can be called directly from ide.c. */ int __init qd65xx_init (void ) { -if (probe_qd65xx ==0 ) +if (probe_qd65xx ==0 || ide_off)return -ENODEV ;if (qd_probe (0x30 ))Index:
linux-2.6.23-rc8-misc/drivers/ide/legacy/umc8672.c
===================================================================drivers/ide/legacy/umc8672.c +1
-1@@ -176,7 +176,7 @@ MODULE_PARM_DESC(probe, "probe for UMC86/* Can be called directly from ide.c. */ int __init umc8672_init (void ) { -if (probe_umc8672 ==0 ) +if (probe_umc8672 ==0 || ide_off) goto out;if (umc8672_probe () ==0 )Index:
linux-2.6.23-rc8-misc/drivers/ide/mips/au1xxx-ide.c
===================================================================drivers/ide/mips/au1xxx-ide.c +2
-0@@ -793,6 +793,8 @@ static struct device_driver au1200_ide_dstatic int __init au_ide_init (void ) { +if (ide_off) +return -ENODEV ;return driver_register (&au1200_ide_driver); }Index:
linux-2.6.23-rc8-misc/drivers/ide/mips/swarm.c
===================================================================drivers/ide/mips/swarm.c +2
-0@@ -157,6 +157,8 @@ static int __devinit swarm_ide_init_modustruct platform_device *pldev;int err; +if (ide_off) +return -ENODEV ;printk (KERN_INFO "SWARM IDE driver\n" );if (driver_register (&swarm_ide_driver)) {Index:
linux-2.6.23-rc8-misc/drivers/ide/pci/piix.c
===================================================================drivers/ide/pci/piix.c +2
-0@@ -629,6 +629,8 @@ static struct pci_driver driver = {static int __init piix_ide_init (void ) { +if (ide_off) +return -ENODEV ;piix_check_450nx ();return ide_pci_register_driver (&driver); }Index:
linux-2.6.23-rc8-misc/Documentation/ide.txt
===================================================================
Documentation/ide.txt Summary of ide driver parameters for ker · line 294
Quoted 5 lines
Documentation/ide.txt +2
-0@@ -290,6 +290,8 @@ Summary of ide driver parameters for ker "ide=nodma" : disable DMA globally for the IDE subsystem. + "ide=off" : Disable the IDE subsystem completely +
Should be updated to reflect the fact that it is valid iff IDE is built-in.
Documentation/ide.txt Summary of ide driver parameters for ker · line 297
Quoted 3 lines
Documentation/ide.txt +0
-0The following are valid ONLY on ide0, which usually corresponds to the first ATA interface found on the particular host, and the defaults for the base,ctl ports must not be altered.
Otherwise looks fine.
Please recast the patch so I could push it Linus (I think it is straightforward enough to be still merged for 2.6.24).
Thanks,
Bart
Quoted 11 lines · On Thursday 25 October 2007 23:07:23 Bartlomiej Zolnierkiewicz wrote:
Quoted 7 lines · Andi Kleen
Had a situation where
drivers/idewas compiled in, but I wanted to turn it off to let thedrivers/atadrivers take over. I ended up using ide*=noprobe, but that was somewhat clumpsy because I wasn't sure how many IDE interfaces the machine really had.Add a global ide=off switch to handle this situation better.
Overall looks OK but I think we should limit it to IDE built-in case (when IDE is modular it is all up to the user-space anyway).
Disagree. It's useful for the modular case too e.g. if you have the ide modules in your initrd and you want to not load them for some reason (e.g. debugging)
Besides adding so many ifdefs would be ugly in my opinion.
Quoted 8 lines
Quoted 2 lines
The patch is a little bigger because I tried to cover all modules.
A few still needs to be covered:
-drivers/scsi/ide-scsi.c(other directory)
-drivers/ide/legacy/ide_platform.c(new driver)
-drivers/ide/legacy/ide-cs.c(late_initcall)
-drivers/ide/pci/sgiioc4.c(ditto, not a SFF-PCI driver)
Thanks I'll fix those.
Quoted 5 lines
Quoted 2 lines
I'm also not 100% sure ENODEV is the right error return for this case, but I didn't come up with a better one.
-EPERM? IMO it would be more appropriate (and easy to distinguish from the "real"-ENODEV).
Ok.
Quoted 6 lines
drivers/ide/ide.c static const u8 ide_hwif_to_major[] = { · line 96
Quoted 3 lines
drivers/ide/ide.c +3
-0+int ide_off; +EXPORT_SYMBOL (ide_off); +
_GPL?
Quoted 6 lines
Please cover it with #ifdef/#endif
CONFIG_BLK_DEV_IDEas it should be valid only when IDE is built-in.This way we don't pollute device/host drivers with
CONFIG_BLK_DEV_IDE#ifdefs.
What CONFIG_BLK_DEV_IDE ifdefs? I added the check only to code that is already conditional to this I believe and there were no additional ifdefs at all.
-Andi
Quoted 9 lines · Andi Kleen
Quoted 7 lines · On Thursday 25 October 2007 23:07:23 Bartlomiej Zolnierkiewicz wrote:
Quoted 6 lines · Andi Kleen
Had a situation where
drivers/idewas compiled in, but I wanted to turn it off to let thedrivers/atadrivers take over. I ended up using ide*=noprobe, but that was somewhat clumpsy because I wasn't sure how many IDE interfaces the machine really had.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Add a global ide=off switch to handle this situation better.
Overall looks OK but I think we should limit it to IDE built-in case (when IDE is modular it is all up to the user-space anyway).
Disagree. It's useful for the modular case too e.g. if you have the ide modules in your initrd and you want to not load them for some reason (e.g. debugging)
This argument sounds rather weak, you may want to not load any other modules from your inird and you don't add "module=off" to them. :)
Besides the patch in the current form is buggy for the modular IDE since __ide_pci_register_driver() is valid only when IDE is built-in (please see how ide_pci_register_driver() is defined in ide.h) and the patch depends on it to handle "ide=off" for IDE PCI host drivers.
[ No hard feelings wrt modular IDE support if the above issue gets fixed. ]
Quoted 4 lines
Quoted 1 line
This way we don't pollute device/host drivers with
CONFIG_BLK_DEV_IDE#ifdefs.What
CONFIG_BLK_DEV_IDEifdefs? I added the check only to code that is already conditional to this I believe and there were no additional ifdefs at all.
I meant the case if we made "ide=off" valid only for built-in IDE (then simply referencing ide_off in device/host drivers is incorrect since ide_off is covered by CONFIG_BLK_DEV_IDE #ifdef/#endif).
Thanks,
Bart