lkml.org 
[lkml]   [2003]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] work around deadlock in add_intf
hi :)


the note for cpufreq sysfs support regarding locking in add_intf
has bitten me, too

i don't have a really good idea how to change the locking
so that it just works, so i wrote a workaround

the following patch allows to add interfaces again for me,
it just deferres the actual device additions:


--- src/linux-2.5/drivers/base/intf.c Mon Jan 13 09:49:02 2003
+++ src/linux-rc/drivers/base/intf.c Thu Jan 16 11:13:19 2003
@@ -132,6 +132,22 @@


/**
+ * delayed_add - version of add() called via schedule_work
+ * @_data: pointer to arguments
+ */
+static void delayed_add(void *_data)
+{
+ struct {
+ struct device_interface *intf;
+ struct device *dev;
+ struct work_struct work;
+ } *data = _data;
+
+ add(data->intf, data->dev);
+ kfree(data);
+}
+
+/**
* add_intf - add class's devices to interface.
* @intf: interface.
*
@@ -142,12 +158,24 @@
*/
static void add_intf(struct device_interface * intf)
{
+ struct {
+ struct device_interface *intf;
+ struct device *dev;
+ struct work_struct work;
+ } *data;
struct device_class * cls = intf->devclass;
struct list_head * entry;

down_write(&cls->subsys.rwsem);
- list_for_each(entry,&cls->devices.list)
- add(intf,to_dev(entry));
+ list_for_each(entry,&cls->devices.list) {
+ /* add will lock subsys.rwsem via interface_add_data, */
+ /* do it after lock is released */
+ data = kmalloc(sizeof(*data), GFP_KERNEL);
+ INIT_WORK(&data->work, delayed_add, data);
+ data->intf = intf;
+ data->dev = to_dev(entry);
+ schedule_work(&data->work);
+ }
up_write(&cls->subsys.rwsem);
}


--
CU, / Friedrich-Alexander University Erlangen, Germany
Martin Waitz // [Tali on IRCnet] [tali.home.pages.de] _________
______________/// - - - - - - - - - - - - - - - - - - - - ///
dies ist eine manuell generierte mail, sie beinhaltet //
tippfehler und ist auch ohne grossbuchstaben gueltig. /
-
Wer bereit ist, grundlegende Freiheiten aufzugeben, um sich
kurzfristige Sicherheit zu verschaffen, der hat weder Freiheit
noch Sicherheit verdient. Benjamin Franklin (1706 - 1790)[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 13:32    [W:0.022 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site