From: Huang Ying <ying.huang@intel.com>
To: bhelgaas@google.com
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
yanmin.zhang@intel.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, rjw@sisk.pl
Subject: Why hold device_lock when calling callback in pci_walk_bus?
Date: Fri, 28 Sep 2012 16:15:18 +0800 [thread overview]
Message-ID: <1348820118.4530.41.camel@yhuang-mobile.sh.intel.com> (raw)
Hi, All,
If my understanding were correct, device_lock is used to provide mutual
exclusion between device probe/remove/suspend/resume etc. Why hold
device_lock when calling callback in pci_walk_bus.
This is introduced by the following commit.
commit d71374dafbba7ec3f67371d3b7e9f6310a588808
Author: Zhang Yanmin <yanmin.zhang@intel.com>
Date: Fri Jun 2 12:35:43 2006 +0800
[PATCH] PCI: fix race with pci_walk_bus and pci_destroy_dev
pci_walk_bus has a race with pci_destroy_dev. When cb is called
in pci_walk_bus, pci_destroy_dev might unlink the dev pointed by next.
Later on in the next loop, pointer next becomes NULL and cause
kernel panic.
Below patch against 2.6.17-rc4 fixes it by changing pci_bus_lock (spin_lock)
to pci_bus_sem (rw_semaphore).
Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Corresponding email thread is: https://lkml.org/lkml/2006/5/26/38
But from the commit and email thread, I can not find why we need to do
that.
I ask this question because I want to use pci_walk_bus in a function (in
pci runtime resume path) which may be called with device_lock held.
Can anyone help me on that?
Best Regards,
Huang Ying
next reply other threads:[~2012-09-28 8:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-28 8:15 Huang Ying [this message]
2012-09-28 8:29 ` Why hold device_lock when calling callback in pci_walk_bus? Zhang, Yanmin
2012-09-28 13:27 ` Huang Ying
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=1348820118.4530.41.camel@yhuang-mobile.sh.intel.com \
--to=ying.huang@intel.com \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=yanmin.zhang@intel.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;
as well as URLs for NNTP newsgroup(s).