From mboxrd@z Thu Jan 1 00:00:00 1970 From: akpm@linux-foundation.org Subject: - driver-core-per-subsystem-multithreaded-probing.patch removed from -mm tree Date: Fri, 09 Feb 2007 21:24:08 -0800 Message-ID: <200702100524.l1A5O8fb004574@shell0.pdx.osdl.net> Reply-To: linux-kernel@vger.kernel.org Return-path: Received: from smtp.osdl.org ([65.172.181.24]:36695 "EHLO smtp.osdl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752680AbXBJFYi (ORCPT ); Sat, 10 Feb 2007 00:24:38 -0500 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: cornelia.huck@de.ibm.com, benh@kernel.crashing.org, greg@kroah.com, mm-commits@vger.kernel.org The patch titled driver core: per-subsystem multithreaded probing has been removed from the -mm tree. Its filename was driver-core-per-subsystem-multithreaded-probing.patch This patch was dropped because it was merged into mainline or a subsystem tree ------------------------------------------------------ Subject: driver core: per-subsystem multithreaded probing From: Cornelia Huck Make multithreaded probing work per subsystem instead of per driver. It doesn't make much sense to probe the same device for multiple drivers in parallel (after all, only one driver can bind to the device). Instead, create a probing thread for each device that probes the drivers one after another. Also make the decision to use multi-threaded probe per bus instead of per device and adapt the pci code. Signed-off-by: Cornelia Huck Cc: Greg KH Cc: Benjamin Herrenschmidt Signed-off-by: Andrew Morton --- drivers/base/dd.c | 62 ++++++++++++++++++------------------- drivers/pci/pci-driver.c | 6 --- include/linux/device.h | 4 +- include/linux/pci.h | 2 - 4 files changed, 34 insertions(+), 40 deletions(-) diff -puN drivers/base/dd.c~driver-core-per-subsystem-multithreaded-probing drivers/base/dd.c --- a/drivers/base/dd.c~driver-core-per-subsystem-multithreaded-probing +++ a/drivers/base/dd.c @@ -94,19 +94,11 @@ int device_bind_driver(struct device *de return ret; } -struct stupid_thread_structure { - struct device_driver *drv; - struct device *dev; -}; - static atomic_t probe_count = ATOMIC_INIT(0); static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); -static int really_probe(void *void_data) +static int really_probe(struct device *dev, struct device_driver *drv) { - struct stupid_thread_structure *data = void_data; - struct device_driver *drv = data->drv; - struct device *dev = data->dev; int ret = 0; atomic_inc(&probe_count); @@ -152,7 +144,6 @@ probe_failed: */ ret = 0; done: - kfree(data); atomic_dec(&probe_count); wake_up(&probe_waitqueue); return ret; @@ -184,16 +175,14 @@ int driver_probe_done(void) * format of the ID structures, nor what is to be considered a match and * what is not. * - * This function returns 1 if a match is found, an error if one occurs - * (that is not -ENODEV or -ENXIO), and 0 otherwise. + * This function returns 1 if a match is found, -ENODEV if the device is + * not registered, and 0 otherwise. * * This function must be called with @dev->sem held. When called for a * USB interface, @dev->parent->sem must be held as well. */ int driver_probe_device(struct device_driver * drv, struct device * dev) { - struct stupid_thread_structure *data; - struct task_struct *probe_task; int ret = 0; if (!device_is_registered(dev)) @@ -204,19 +193,7 @@ int driver_probe_device(struct device_dr pr_debug("%s: Matched Device %s with Driver %s\n", drv->bus->name, dev->bus_id, drv->name); - data = kmalloc(sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - data->drv = drv; - data->dev = dev; - - if (drv->multithread_probe) { - probe_task = kthread_run(really_probe, data, - "probe-%s", dev->bus_id); - if (IS_ERR(probe_task)) - ret = really_probe(data); - } else - ret = really_probe(data); + ret = really_probe(dev, drv); done: return ret; @@ -228,30 +205,53 @@ static int __device_attach(struct device return driver_probe_device(drv, dev); } +static int device_probe_drivers(void *data) +{ + struct device *dev = data; + int ret = 0; + + if (dev->bus) { + down(&dev->sem); + ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); + up(&dev->sem); + } + return ret; +} + /** * device_attach - try to attach device to a driver. * @dev: device. * * Walk the list of drivers that the bus has and call * driver_probe_device() for each pair. If a compatible - * pair is found, break out and return. + * pair is found, break out and return. If the bus specifies + * multithreaded probing, walking the list of drivers is done + * on a probing thread. * * Returns 1 if the device was bound to a driver; - * 0 if no matching device was found; error code otherwise. + * 0 if no matching device was found or multithreaded probing is done; + * error code otherwise. * * When called for a USB interface, @dev->parent->sem must be held. */ int device_attach(struct device * dev) { int ret = 0; + struct task_struct *probe_task = ERR_PTR(-ENOMEM); down(&dev->sem); if (dev->driver) { ret = device_bind_driver(dev); if (ret == 0) ret = 1; - } else - ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); + } else { + if (dev->bus->multithread_probe) + probe_task = kthread_run(device_probe_drivers, dev, + "probe-%s", dev->bus_id); + if(IS_ERR(probe_task)) + ret = bus_for_each_drv(dev->bus, NULL, dev, + __device_attach); + } up(&dev->sem); return ret; } diff -puN drivers/pci/pci-driver.c~driver-core-per-subsystem-multithreaded-probing drivers/pci/pci-driver.c --- a/drivers/pci/pci-driver.c~driver-core-per-subsystem-multithreaded-probing +++ a/drivers/pci/pci-driver.c @@ -434,11 +434,6 @@ int __pci_register_driver(struct pci_dri drv->driver.mod_name = mod_name; drv->driver.kobj.ktype = &pci_driver_kobj_type; - if (pci_multithread_probe) - drv->driver.multithread_probe = pci_multithread_probe; - else - drv->driver.multithread_probe = drv->multithread_probe; - spin_lock_init(&drv->dynids.lock); INIT_LIST_HEAD(&drv->dynids.list); @@ -574,6 +569,7 @@ struct bus_type pci_bus_type = { static int __init pci_driver_init(void) { + pci_bus_type.multithread_probe = pci_multithread_probe; return bus_register(&pci_bus_type); } diff -puN include/linux/device.h~driver-core-per-subsystem-multithreaded-probing include/linux/device.h --- a/include/linux/device.h~driver-core-per-subsystem-multithreaded-probing +++ a/include/linux/device.h @@ -60,6 +60,8 @@ struct bus_type { int (*suspend_late)(struct device * dev, pm_message_t state); int (*resume_early)(struct device * dev); int (*resume)(struct device * dev); + + unsigned int multithread_probe:1; }; extern int __must_check bus_register(struct bus_type * bus); @@ -133,8 +135,6 @@ struct device_driver { void (*shutdown) (struct device * dev); int (*suspend) (struct device * dev, pm_message_t state); int (*resume) (struct device * dev); - - unsigned int multithread_probe:1; }; diff -puN include/linux/pci.h~driver-core-per-subsystem-multithreaded-probing include/linux/pci.h --- a/include/linux/pci.h~driver-core-per-subsystem-multithreaded-probing +++ a/include/linux/pci.h @@ -362,8 +362,6 @@ struct pci_driver { struct pci_error_handlers *err_handler; struct device_driver driver; struct pci_dynids dynids; - - int multithread_probe; }; #define to_pci_driver(drv) container_of(drv,struct pci_driver, driver) _ Patches currently in -mm which might be from cornelia.huck@de.ibm.com are origin.patch git-s390.patch