mbox series

[v2,0/6] PCI: Fix deadlocks when enabling ASPM

Message ID 20231128081512.19387-1-johan+linaro@kernel.org (mailing list archive)
Headers show
Series PCI: Fix deadlocks when enabling ASPM | expand

Message

Johan Hovold Nov. 28, 2023, 8:15 a.m. UTC
The pci_enable_link_state() helper is currently only called from
pci_walk_bus(), something which can lead to a deadlock as both helpers
take a pci_bus_sem read lock.

Add a new locked helper which can be called with the read lock held and
fix up the two current users (the second is new in 6.7-rc1).

Note that there are no users left of the original unlocked variant after
this series, but I decided to leave it in place for now (e.g. to mirror
the corresponding helpers to disable link states).

Included are also a couple of related cleanups.

Johan


Changes in v2
 - fix up the function name in a kernel doc comment as reported by the
   kernel test robot <lkp@intel.com>


Johan Hovold (6):
  PCI/ASPM: Add locked helper for enabling link state
  PCI: vmd: Fix deadlock when enabling ASPM
  PCI: qcom: Fix deadlock when enabling ASPM
  PCI: qcom: Clean up ASPM comment
  PCI/ASPM: Clean up disable link state parameter
  PCI/ASPM: Add lockdep assert to link state helper

 drivers/pci/controller/dwc/pcie-qcom.c |  7 ++-
 drivers/pci/controller/vmd.c           |  2 +-
 drivers/pci/pcie/aspm.c                | 65 +++++++++++++++++++-------
 include/linux/pci.h                    |  3 ++
 4 files changed, 56 insertions(+), 21 deletions(-)

Comments

Johan Hovold Dec. 7, 2023, 1:25 p.m. UTC | #1
Hi PCI maintainers,

On Tue, Nov 28, 2023 at 09:15:06AM +0100, Johan Hovold wrote:
> The pci_enable_link_state() helper is currently only called from
> pci_walk_bus(), something which can lead to a deadlock as both helpers
> take a pci_bus_sem read lock.
> 
> Add a new locked helper which can be called with the read lock held and
> fix up the two current users (the second is new in 6.7-rc1).
> 
> Note that there are no users left of the original unlocked variant after
> this series, but I decided to leave it in place for now (e.g. to mirror
> the corresponding helpers to disable link states).
> 
> Included are also a couple of related cleanups.

> Johan Hovold (6):
>   PCI/ASPM: Add locked helper for enabling link state
>   PCI: vmd: Fix deadlock when enabling ASPM
>   PCI: qcom: Fix deadlock when enabling ASPM
>   PCI: qcom: Clean up ASPM comment
>   PCI/ASPM: Clean up disable link state parameter
>   PCI/ASPM: Add lockdep assert to link state helper

Could we get this merged for 6.7-rc5? Even if the risk of a deadlock is
not that great, this bug prevents using lockdep on Qualcomm platforms so
that more locking issues can potentially make their way into the kernel.

And for Qualcomm platforms, this is a regression in 6.7-rc1.

Johan


#regzbot introduced: 9f4f3dfad8cf
Bjorn Helgaas Dec. 8, 2023, 5:53 p.m. UTC | #2
On Tue, Nov 28, 2023 at 09:15:06AM +0100, Johan Hovold wrote:
> The pci_enable_link_state() helper is currently only called from
> pci_walk_bus(), something which can lead to a deadlock as both helpers
> take a pci_bus_sem read lock.
> 
> Add a new locked helper which can be called with the read lock held and
> fix up the two current users (the second is new in 6.7-rc1).
> 
> Note that there are no users left of the original unlocked variant after
> this series, but I decided to leave it in place for now (e.g. to mirror
> the corresponding helpers to disable link states).
> 
> Included are also a couple of related cleanups.
> 
> Johan
> 
> 
> Changes in v2
>  - fix up the function name in a kernel doc comment as reported by the
>    kernel test robot <lkp@intel.com>
> 
> 
> Johan Hovold (6):
>   PCI/ASPM: Add locked helper for enabling link state
>   PCI: vmd: Fix deadlock when enabling ASPM
>   PCI: qcom: Fix deadlock when enabling ASPM
>   PCI: qcom: Clean up ASPM comment
>   PCI/ASPM: Clean up disable link state parameter
>   PCI/ASPM: Add lockdep assert to link state helper
> 
>  drivers/pci/controller/dwc/pcie-qcom.c |  7 ++-
>  drivers/pci/controller/vmd.c           |  2 +-
>  drivers/pci/pcie/aspm.c                | 65 +++++++++++++++++++-------
>  include/linux/pci.h                    |  3 ++
>  4 files changed, 56 insertions(+), 21 deletions(-)

Applied to for-linus for v6.7, thanks, Johan!
Thorsten Leemhuis Dec. 10, 2023, 12:35 p.m. UTC | #3
[TLDR: This mail in primarily relevant for Linux kernel regression
tracking. See link in footer if these mails annoy you.]

On 07.12.23 14:25, Johan Hovold wrote:
> On Tue, Nov 28, 2023 at 09:15:06AM +0100, Johan Hovold wrote:
>> The pci_enable_link_state() helper is currently only called from
>> pci_walk_bus(), something which can lead to a deadlock as both helpers
>> take a pci_bus_sem read lock.
>>
>> Add a new locked helper which can be called with the read lock held and
>> fix up the two current users (the second is new in 6.7-rc1).
>>
>> Note that there are no users left of the original unlocked variant after
>> this series, but I decided to leave it in place for now (e.g. to mirror
>> the corresponding helpers to disable link states).
>>
>> Included are also a couple of related cleanups.
> 
>> Johan Hovold (6):
>>   PCI/ASPM: Add locked helper for enabling link state
>>   PCI: vmd: Fix deadlock when enabling ASPM
>>   PCI: qcom: Fix deadlock when enabling ASPM
>>   PCI: qcom: Clean up ASPM comment
>>   PCI/ASPM: Clean up disable link state parameter
>>   PCI/ASPM: Add lockdep assert to link state helper
> 
> Could we get this merged for 6.7-rc5? Even if the risk of a deadlock is
> not that great, this bug prevents using lockdep on Qualcomm platforms so
> that more locking issues can potentially make their way into the kernel.
> 
> And for Qualcomm platforms, this is a regression in 6.7-rc1.
> 
> #regzbot introduced: 9f4f3dfad8cf

Fixes are now here:
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=for-linus

#regzbot fix: 075268be58232b0a2ae
#regzbot ignore-activity

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
--
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
That page also explains what to do if mails like this annoy you.
Johan Hovold Dec. 11, 2023, 5:35 p.m. UTC | #4
Hi Bjorn,

On Fri, Dec 08, 2023 at 11:53:12AM -0600, Bjorn Helgaas wrote:
> On Tue, Nov 28, 2023 at 09:15:06AM +0100, Johan Hovold wrote:

> > Johan Hovold (6):
> >   PCI/ASPM: Add locked helper for enabling link state
> >   PCI: vmd: Fix deadlock when enabling ASPM
> >   PCI: qcom: Fix deadlock when enabling ASPM
> >   PCI: qcom: Clean up ASPM comment
> >   PCI/ASPM: Clean up disable link state parameter
> >   PCI/ASPM: Add lockdep assert to link state helper

> Applied to for-linus for v6.7, thanks, Johan!

I've noticed that you're pretty keen on amending commit messages.

For this series, for example, I noticed that you added an American comma
after "e.g." even though this is not expected in British English that I
(try to) use. This risks introducing inconsistencies and frankly I see no
reason for this kind of editing. British English is not an error. :)

You also added a plus sign after the stable kernel versions in the
comments after the CC-stable tags even though this is not the right
notation for this (see the stable kernel rules).

I'm more OK with you preferring to use function names over free text in
commit messages even if that is not my preferred style.

But generally I find it a bit odd that you insist on rewriting commit
messages like this and would prefer if you did not (especially since
there's no record of you having done this in the commits themselves).

Fixing typos and grammar issues, or rewriting bad commit messages, is
another thing of course.

Johan
Bjorn Helgaas Dec. 11, 2023, 6:11 p.m. UTC | #5
On Mon, Dec 11, 2023 at 06:35:46PM +0100, Johan Hovold wrote:
> Hi Bjorn,
> 
> On Fri, Dec 08, 2023 at 11:53:12AM -0600, Bjorn Helgaas wrote:
> > On Tue, Nov 28, 2023 at 09:15:06AM +0100, Johan Hovold wrote:
> 
> > > Johan Hovold (6):
> > >   PCI/ASPM: Add locked helper for enabling link state
> > >   PCI: vmd: Fix deadlock when enabling ASPM
> > >   PCI: qcom: Fix deadlock when enabling ASPM
> > >   PCI: qcom: Clean up ASPM comment
> > >   PCI/ASPM: Clean up disable link state parameter
> > >   PCI/ASPM: Add lockdep assert to link state helper
> 
> > Applied to for-linus for v6.7, thanks, Johan!
> 
> I've noticed that you're pretty keen on amending commit messages.
> 
> For this series, for example, I noticed that you added an American comma
> after "e.g." even though this is not expected in British English that I
> (try to) use. This risks introducing inconsistencies and frankly I see no
> reason for this kind of editing. British English is not an error. :)
> 
> You also added a plus sign after the stable kernel versions in the
> comments after the CC-stable tags even though this is not the right
> notation for this (see the stable kernel rules).

Fixed, sorry.
Johan Hovold Dec. 11, 2023, 8:13 p.m. UTC | #6
On Mon, Dec 11, 2023 at 12:11:53PM -0600, Bjorn Helgaas wrote:
> On Mon, Dec 11, 2023 at 06:35:46PM +0100, Johan Hovold wrote:

> > I've noticed that you're pretty keen on amending commit messages.
> > 
> > For this series, for example, I noticed that you added an American comma
> > after "e.g." even though this is not expected in British English that I
> > (try to) use. This risks introducing inconsistencies and frankly I see no
> > reason for this kind of editing. British English is not an error. :)
> > 
> > You also added a plus sign after the stable kernel versions in the
> > comments after the CC-stable tags even though this is not the right
> > notation for this (see the stable kernel rules).
> 
> Fixed, sorry.

Thanks!

Johan