From: Lukas Wunner <lukas@wunner.de>
To: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Keith Busch <kbusch@kernel.org>, Wolfram Sang <wsa@kernel.org>,
Jean Delvare <jdelvare@suse.de>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [bug report] lockdep WARN at PCI device rescan
Date: Wed, 29 Nov 2023 12:30:22 +0100 [thread overview]
Message-ID: <20231129113022.GB14152@wunner.de> (raw)
In-Reply-To: <l34l5gd6ann3wajjs7nruwlthjugyg4fawtw3cwellfilevrc2@xjxzr3zejfit>
On Tue, Nov 28, 2023 at 10:16:28AM +0000, Shinichiro Kawasaki wrote:
> Here are my three observations:
>
> A) pci drivers should be able to call p2sb_bar() in probe() without failure.
> B) when /sys/bus/pci/rescan is written, pci_rescan_remove_lock is locked then
> probe() is called.
> C) p2sb_bar() locks pci_rescan_remove_lock.
>
> These results in the deadlock. To avoid the deadlock, one of the three needs
> to change. A) is not to change. I guess changing B) will be too much. So, I
> would like to question if we can change C).
It is possible to allow recursive acquisition of a mutex by doing two
things:
* You need to store a pointer to the task_struct which is holding
the lock. This allows you to identify upon a recursive acquisition
that you're already holding the lock. The acquire operation becomes
a no-op in this case.
* You need a counter of how many times you've acquired the lock
recursively. This allows you to determine upon lock release
whether the release operation should be a no-op (due to previous
recursive acquisition) or whether it should result in actual
lock release (no previous recursive locking, or recursive locking
has ended).
Actually struct mutex already stores the owner of the lock,
but that's only available internally.
While it would be possible to allow recursive acquisition of
pci_rescan_remove_lock in this way, doing so merely because of
a vendor-specific platform quirk will likely be considered dodgy
by the upstream community. So Andy's proposal to stash the
struct resource on affected platforms seems more viable from
an upstream acceptability point of view.
Thanks,
Lukas
prev parent reply other threads:[~2023-11-29 11:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 6:54 [bug report] lockdep WARN at PCI device rescan Shinichiro Kawasaki
2023-11-14 10:16 ` Wolfram Sang
2023-11-14 10:47 ` Heiner Kallweit
2023-11-14 12:04 ` Andy Shevchenko
2023-11-14 15:57 ` Lukas Wunner
2023-11-14 16:11 ` Andy Shevchenko
2023-11-14 17:58 ` Andy Shevchenko
2023-11-24 10:49 ` Shinichiro Kawasaki
2023-11-24 15:22 ` Andy Shevchenko
2023-11-28 7:45 ` Shinichiro Kawasaki
2023-11-29 11:17 ` Lukas Wunner
[not found] ` <ZWdBnMTOq9wIt9L-@smile.fi.intel.com>
2023-11-29 13:53 ` Andy Shevchenko
2023-11-30 7:30 ` Shinichiro Kawasaki
2023-11-30 9:36 ` Lukas Wunner
2023-12-01 0:37 ` Bjorn Helgaas
2023-12-01 10:46 ` Shinichiro Kawasaki
2023-11-30 15:19 ` Andy Shevchenko
2023-12-01 10:34 ` Shinichiro Kawasaki
2023-11-24 17:30 ` Heiner Kallweit
2023-11-28 10:16 ` Shinichiro Kawasaki
2023-11-29 11:30 ` Lukas Wunner [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=20231129113022.GB14152@wunner.de \
--to=lukas@wunner.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=hkallweit1@gmail.com \
--cc=jdelvare@suse.de \
--cc=kbusch@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=wsa@kernel.org \
/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