From: Martin Waitz <tali@admingilde.org>
To: Patrick Mochel <mochel@osdl.org>
Cc: Dominik Brodowski <linux@brodo.de>,
torvalds@transmeta.com, linux-kernel@vger.kernel.org
Subject: [PATCH] work around deadlock in add_intf
Date: Thu, 16 Jan 2003 22:52:18 +0100 [thread overview]
Message-ID: <20030116215218.GB1770@admingilde.org> (raw)
In-Reply-To: <Pine.LNX.4.33.0301131425450.1136-100000@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2448 bytes --]
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)
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2003-01-16 21:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-13 20:53 [PATCH 2.5.57] cpufreq: add sysfs interface Dominik Brodowski
2003-01-13 20:27 ` Patrick Mochel
2003-01-16 21:52 ` Martin Waitz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030116215218.GB1770@admingilde.org \
--to=tali@admingilde.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@brodo.de \
--cc=mochel@osdl.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox