public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Keith Busch <kbusch@meta.com>,
	linux-pci@vger.kernel.org, bhelgaas@google.com,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCHv3 1/5] pci: make pci_stop_dev concurrent safe
Date: Thu, 7 Nov 2024 08:56:26 -0700	[thread overview]
Message-ID: <ZyzjKrNPxn5Vw7cF@kbusch-mbp> (raw)
In-Reply-To: <ZyzJgaEOJOKmh_xw@wunner.de>

On Thu, Nov 07, 2024 at 03:06:57PM +0100, Lukas Wunner wrote:
> On Tue, Oct 22, 2024 at 03:48:47PM -0700, Keith Busch wrote:
> > --- a/drivers/pci/remove.c
> > +++ b/drivers/pci/remove.c
> > @@ -31,18 +31,16 @@ static int pci_pwrctl_unregister(struct device *dev, void *data)
> >  
> >  static void pci_stop_dev(struct pci_dev *dev)
> >  {
> > -	pci_pme_active(dev, false);
> > -
> > -	if (pci_dev_is_added(dev)) {
> > -		device_for_each_child(dev->dev.parent, dev_of_node(&dev->dev),
> > -				      pci_pwrctl_unregister);
> > -		device_release_driver(&dev->dev);
> > -		pci_proc_detach_device(dev);
> > -		pci_remove_sysfs_dev_files(dev);
> > -		of_pci_remove_node(dev);
> > +	if (!pci_dev_test_and_clear_added(dev))
> > +		return;
> >  
> > -		pci_dev_assign_added(dev, false);
> > -	}
> > +	pci_pme_active(dev, false);
> > +	device_for_each_child(dev->dev.parent, dev_of_node(&dev->dev),
> > +			      pci_pwrctl_unregister);
> > +	device_release_driver(&dev->dev);
> > +	pci_proc_detach_device(dev);
> > +	pci_remove_sysfs_dev_files(dev);
> > +	of_pci_remove_node(dev);
> >  }
> 
> The above is now queued for v6.13 as commit 6d6d962a8dc2 on pci/locking.
> 
> I note there's a behavioral change here:
> 
> Previously "pci_pme_active(dev, false)" was called unconditionally,
> now only if the "added" flag has been set.  The commit message
> doesn't explain why this change is fine, so perhaps it's inadvertent?

Hm, not exactly intentional. It doesn't appear to accomplish anything to
call it multiple times, but it also looks hamrless to do so.  Looking at
the history of this, it looks like it was purposefully done
unconditionally with the understanding it's "safe" to do that. With that
in mind, I'm happy to move it back where it was.

  reply	other threads:[~2024-11-07 15:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-22 22:48 [PATCHv3 0/5] pci cleanup/prep patches Keith Busch
2024-10-22 22:48 ` [PATCHv3 1/5] pci: make pci_stop_dev concurrent safe Keith Busch
2024-11-07 14:06   ` Lukas Wunner
2024-11-07 15:56     ` Keith Busch [this message]
2024-11-11  7:20       ` Lukas Wunner
2024-10-22 22:48 ` [PATCHv3 2/5] pci: make pci_destroy_dev " Keith Busch
2024-10-22 22:48 ` [PATCHv3 3/5] pci: move the walk bus lock to where its needed Keith Busch
2024-10-22 22:48 ` [PATCHv3 4/5] pci: walk bus recursively Keith Busch
2024-11-11  8:21   ` Lukas Wunner
2024-10-22 22:48 ` [PATCHv3 5/5] pci: unexport pci_walk_bus_locked Keith Busch
2024-10-23 21:43   ` Bjorn Helgaas
2024-10-23 22:00     ` Keith Busch
2024-10-23 22:07       ` Bjorn Helgaas
2024-10-23 22:20 ` [PATCHv3 0/5] pci cleanup/prep patches Bjorn Helgaas

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=ZyzjKrNPxn5Vw7cF@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=kbusch@meta.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    /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