The patch titled fix hotplug for legacy platform drivers has been added to the -mm tree. Its filename is fix-hotplug-for-legacy-platform-drivers.patch *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: fix hotplug for legacy platform drivers From: David Brownell <david-b@xxxxxxxxxxx> We've had various reports of some legacy "probe the hardware" style platform drivers having nasty problems with hotplug support. The core issue is that those legacy drivers don't fully conform to the driver model. They assume a role that should be the responsibility of infrastructure code: creating device nodes. The "modprobe" step in hotplugging relies on drivers to have split those roles into different modules. The lack of this split causes the problems. When a driver creates nodes for devices that don't exist (sending a hotplug event), then exits (aborting one modprobe) before the "modprobe $MODALIAS" step completes (by failing, since it's in the middle of a modprobe), the result can be an endless loop of modprobe invocations ... badness. This fix uses the newish per-device flag controlling issuance of "add" events. (A previous version of this patch used a per-device "driver can hotplug" flag, which only scrubbed $MODALIAS from the environment rather than suppressing the entire hotplug event.) It also shrinks that flag to one bit, saving a word in "struct device". So the net of this patch is removing some nasty failures with legacy drivers, while retaining hotplug capability for the majority of platform drivers. Signed-off-by: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx> Cc: Greg KH <gregkh@xxxxxxx> Cc: Andres Salomon <dilinger@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/base/platform.c | 18 ++++++++++++++++++ drivers/pcmcia/pxa2xx_mainstone.c | 2 ++ drivers/pcmcia/pxa2xx_sharpsl.c | 2 ++ include/linux/device.h | 4 ++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff -puN drivers/base/platform.c~fix-hotplug-for-legacy-platform-drivers drivers/base/platform.c --- a/drivers/base/platform.c~fix-hotplug-for-legacy-platform-drivers +++ a/drivers/base/platform.c @@ -160,6 +160,11 @@ static void platform_device_release(stru * * Create a platform device object which can have other objects attached * to it, and which will have attached objects freed when it is released. + * + * This device will be marked as not supporting hotpluggable drivers; in + * the unusual case that the device isn't being dynamically allocated as + * of a legacy "probe the hardware" driver, infrastructure code should + * reverse this marking. */ struct platform_device *platform_device_alloc(const char *name, unsigned int id) { @@ -172,6 +177,12 @@ struct platform_device *platform_device_ pa->pdev.id = id; device_initialize(&pa->pdev.dev); pa->pdev.dev.release = platform_device_release; + + /* prevent hotplug "modprobe $(MODALIAS)" from causing trouble in + * legacy probe-the-hardware drivers, which don't properly split + * out enumeration logic from drivers. + */ + pa->pdev.dev.uevent_suppress = 1; } return pa ? &pa->pdev : NULL; @@ -349,6 +360,13 @@ EXPORT_SYMBOL_GPL(platform_device_unregi * memory allocated for the device allows drivers using such devices * to be unloaded iwithout waiting for the last reference to the device * to be dropped. + * + * This interface is primarily intended for use with legacy drivers + * which probe hardware directly. Because such drivers create device + * nodes themselves, rather than letting system infrastructure handle + * such device enumeration tasks, they don't fully conform to the Linux + * driver model. In particular, when such drivers are built as modules, + * they can't be "hotplugged". */ struct platform_device *platform_device_register_simple(char *name, unsigned int id, struct resource *res, unsigned int num) diff -puN drivers/pcmcia/pxa2xx_mainstone.c~fix-hotplug-for-legacy-platform-drivers drivers/pcmcia/pxa2xx_mainstone.c --- a/drivers/pcmcia/pxa2xx_mainstone.c~fix-hotplug-for-legacy-platform-drivers +++ a/drivers/pcmcia/pxa2xx_mainstone.c @@ -175,6 +175,8 @@ static int __init mst_pcmcia_init(void) if (!mst_pcmcia_device) return -ENOMEM; + /* REVISIT just statically allocate the device */ + mst_pcmcia_device->dev.uevent_suppress = 0; mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; ret = platform_device_add(mst_pcmcia_device); diff -puN drivers/pcmcia/pxa2xx_sharpsl.c~fix-hotplug-for-legacy-platform-drivers drivers/pcmcia/pxa2xx_sharpsl.c --- a/drivers/pcmcia/pxa2xx_sharpsl.c~fix-hotplug-for-legacy-platform-drivers +++ a/drivers/pcmcia/pxa2xx_sharpsl.c @@ -261,6 +261,8 @@ static int __init sharpsl_pcmcia_init(vo if (!sharpsl_pcmcia_device) return -ENOMEM; + /* REVISIT just statically allocate the device */ + sharpsl_pcmcia_device->dev.uevent_suppress = 0; sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev; diff -puN include/linux/device.h~fix-hotplug-for-legacy-platform-drivers include/linux/device.h --- a/include/linux/device.h~fix-hotplug-for-legacy-platform-drivers +++ a/include/linux/device.h @@ -408,12 +408,13 @@ struct device { struct klist_node knode_parent; /* node in sibling list */ struct klist_node knode_driver; struct klist_node knode_bus; - struct device * parent; + struct device *parent; struct kobject kobj; char bus_id[BUS_ID_SIZE]; /* position on parent bus */ struct device_type *type; unsigned is_registered:1; + unsigned uevent_suppress:1; struct device_attribute uevent_attr; struct device_attribute *devt_attr; @@ -454,7 +455,6 @@ struct device { struct class *class; dev_t devt; /* dev_t, creates the sysfs "dev" */ struct attribute_group **groups; /* optional groups */ - int uevent_suppress; void (*release)(struct device * dev); }; _ Patches currently in -mm which might be from david-b@xxxxxxxxxxx are origin.patch rtc-cmos-lockdep-fix-irq-updates.patch scsi-newstyle-hotplug-coldplug-support.patch fix-hotplug-for-legacy-platform-drivers.patch update-documentation-driver-model-platformtxt.patch blackfin-on-chip-rtc-controller-driver.patch blackfin-blackfin-on-chip-spi-controller-driver.patch rework-pm_ops-pm_disk_mode-kill-misuse.patch power-management-remove-firmware-disk-mode.patch power-management-implement-pm_opsvalid-for-everybody.patch documentation-ask-driver-writers-to-provide-pm-support.patch init-dma-masks-in-pnp_dev.patch rtc-add-rtc-class-driver-for-the-maxim-max6900.patch char-cs5535_gpio-add-module_device_table.patch parport-dev-driver-model-support.patch parport-dev-driver-model-support-powerpc-fix.patch layered-parport-code-uses-parport-dev.patch minor-spi_butterfly-cleanup.patch rtc-remove-sys-class-rtc-dev.patch rtc-rtc-interfaces-dont-use-class_device.patch rtc-simplified-rtc-sysfs-attribute-handling.patch rtc-simplified-proc-driver-rtc-handling.patch rtc-remove-rest-of-class_device.patch rtc-suspend-resume-restores-system-clock.patch rtc-simplified-rtc-sysfs-attribute-handling-tidy.patch rtc-kconfig-cleanup.patch rtc-cmos-wakeup-interface.patch acpi-wakeup-hooks-for-rtc-cmos.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html