From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <gregkh@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Len Brown <lenb@kernel.org>, Ingo Molnar <mingo@elte.hu>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
pm list <linux-pm@lists.linux-foundation.org>
Subject: Re: [PATCH] PM: Acquire device locks on suspend
Date: Sun, 6 Jan 2008 23:34:05 +0100 [thread overview]
Message-ID: <200801062334.05982.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0801061712480.19222-100000@netrider.rowland.org>
On Sunday, 6 of January 2008, Alan Stern wrote:
> On Sun, 6 Jan 2008, Rafael J. Wysocki wrote:
>
> > > Still, shouldn't we fail the removal of the device apart from giving the
> > > warning?
> >
> > Actually, having thought about it a bit more, I don't see the point in
> > preventing the removal of the device from the list in device_pm_remove() if
> > we allow all of the operations in device_del() preceding it to be performed.
>
> That's not the issue. We _don't_ allow all of the operations in
> device_del() preceding the call to device_pm_remove(). In particular,
> the call to the device's driver's remove method will deadlock because
> device_release_driver() always has to acquire dev->sem.
>
> > Shouldn't we just take pm_sleep_rwsem in device_del() upfront and block on that
> > if locked?
>
> No -- the whole idea here is to print an error message in the system
> log if a driver's resume method tries to call device_del(). Deadlock
> is unavoidable in this case, but at least we'll know which driver is
> guilty.
Still, if we do that, we won't need to acquire dev->sem in device_pm_remove()
any more. Apart from this, by acqiring pm_sleep_rwsem for reading in
device_del() we can prevent a suspend from starting while the device is being
removed.
Consider, for example, the scenario possible with the $subject patch:
- device_del() starts and notices pm_sleep_rwsem unlocked, so the warning is
not printed
- it proceeds and everything before device_pm_remove() succeeds
- now, device_suspend() is called and locks dev->sem
- device_del() calls device_pm_remove() and blocks on that with the device
partialy removed
I think we should prevent this from happening.
Rafael
next prev parent reply other threads:[~2008-01-06 22:31 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-05 18:36 [PATCH] PM: Acquire device locks on suspend Rafael J. Wysocki
2008-01-05 20:08 ` Alan Stern
2008-01-05 20:08 ` Alan Stern
2008-01-05 20:19 ` Rafael J. Wysocki
2008-01-05 20:19 ` Rafael J. Wysocki
2008-01-05 20:39 ` Alan Stern
2008-01-05 20:39 ` Alan Stern
2008-01-05 21:13 ` Rafael J. Wysocki
2008-01-05 21:41 ` Alan Stern
2008-01-05 21:58 ` Rafael J. Wysocki
2008-01-06 4:04 ` Alan Stern
2008-01-06 4:04 ` Alan Stern
2008-01-06 13:19 ` Rafael J. Wysocki
2008-01-06 17:06 ` Alan Stern
2008-01-06 19:05 ` Rafael J. Wysocki
2008-01-06 19:05 ` Rafael J. Wysocki
2008-01-06 19:57 ` Rafael J. Wysocki
2008-01-06 19:57 ` Rafael J. Wysocki
2008-01-06 22:19 ` Rafael J. Wysocki
2008-01-06 22:19 ` Rafael J. Wysocki
2008-01-06 22:21 ` Alan Stern
2008-01-06 22:21 ` Alan Stern
2008-01-06 22:34 ` Rafael J. Wysocki [this message]
2008-01-06 22:39 ` Alan Stern
2008-01-06 22:39 ` Alan Stern
2008-01-06 22:47 ` Rafael J. Wysocki
2008-01-06 23:46 ` Johannes Berg
[not found] ` <49505.::ffff:91.5.86.36.1199663162.squirrel@secure.sipsolutions.net>
2008-01-06 23:59 ` [linux-pm] " Rafael J. Wysocki
2008-01-07 0:49 ` Rafael J. Wysocki
2008-01-07 0:49 ` Rafael J. Wysocki
2008-01-06 23:59 ` Rafael J. Wysocki
2008-01-07 16:16 ` Alan Stern
2008-01-07 16:51 ` Rafael J. Wysocki
2008-01-07 16:51 ` Rafael J. Wysocki
2008-01-07 17:23 ` Alan Stern
2008-01-07 17:23 ` Alan Stern
2008-01-07 18:01 ` Rafael J. Wysocki
2008-01-07 19:29 ` Alan Stern
2008-01-07 20:37 ` Rafael J. Wysocki
2008-01-07 21:32 ` Alan Stern
2008-01-08 0:25 ` Rafael J. Wysocki
2008-01-08 0:25 ` Rafael J. Wysocki
2008-01-09 21:01 ` Alan Stern
2008-01-09 21:01 ` Alan Stern
2008-01-09 22:14 ` Rafael J. Wysocki
2008-01-09 22:46 ` Alan Stern
2008-01-09 23:29 ` Rafael J. Wysocki
2008-01-10 15:35 ` Alan Stern
2008-01-10 15:35 ` Alan Stern
2008-01-10 16:59 ` Rafael J. Wysocki
2008-01-10 16:59 ` Rafael J. Wysocki
2008-01-10 17:04 ` Alan Stern
2008-01-10 17:04 ` Alan Stern
2008-01-09 23:29 ` Rafael J. Wysocki
2008-01-09 22:46 ` Alan Stern
2008-01-09 22:14 ` Rafael J. Wysocki
2008-01-07 21:32 ` Alan Stern
2008-01-07 20:37 ` Rafael J. Wysocki
2008-01-07 19:29 ` Alan Stern
2008-01-07 18:01 ` Rafael J. Wysocki
2008-01-07 16:16 ` Alan Stern
2008-01-06 22:47 ` Rafael J. Wysocki
2008-01-06 22:34 ` Rafael J. Wysocki
2008-01-06 22:11 ` Alan Stern
2008-01-06 22:24 ` Rafael J. Wysocki
2008-01-06 22:24 ` Rafael J. Wysocki
2008-01-06 22:31 ` Alan Stern
2008-01-06 22:31 ` Alan Stern
2008-01-06 22:11 ` Alan Stern
2008-01-06 17:06 ` Alan Stern
2008-01-06 13:19 ` Rafael J. Wysocki
2008-01-05 21:58 ` Rafael J. Wysocki
2008-01-05 21:41 ` Alan Stern
2008-01-05 21:13 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2008-01-05 18:36 Rafael J. Wysocki
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=200801062334.05982.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=gregkh@suse.de \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mingo@elte.hu \
--cc=stern@rowland.harvard.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.