All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Keith Busch <kbusch@kernel.org>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: Simplify pci_dev_reset_slot_function()
Date: Thu, 17 Sep 2020 16:26:44 -0500	[thread overview]
Message-ID: <20200917212644.GA1739569@bjorn-Precision-5520> (raw)
In-Reply-To: <c6aab5af096f7b1b3db57f6335cebba8f0fcca89.1595330431.git.lukas@wunner.de>

On Tue, Jul 21, 2020 at 01:24:51PM +0200, Lukas Wunner wrote:
> pci_dev_reset_slot_function() refuses to reset a hotplug slot if it is
> shared by multiple pci_devs.  That's the case if and only if the slot is
> occupied by a multifunction device.
> 
> Simplify the function to check the device's multifunction flag instead
> of iterating over the devices on the bus.  (Iterating over the devices
> requires holding pci_bus_sem, which the function erroneously does not
> acquire.)
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: Alex Williamson <alex.williamson@redhat.com>

Applied to pci/misc for v5.10, thanks!

> ---
>  drivers/pci/pci.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 455da72..b406611 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4914,16 +4914,10 @@ static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe)
>  
>  static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe)
>  {
> -	struct pci_dev *pdev;
> -
> -	if (dev->subordinate || !dev->slot ||
> +	if (dev->multifunction || dev->subordinate || !dev->slot ||
>  	    dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
>  		return -ENOTTY;
>  
> -	list_for_each_entry(pdev, &dev->bus->devices, bus_list)
> -		if (pdev != dev && pdev->slot == dev->slot)
> -			return -ENOTTY;
> -
>  	return pci_reset_hotplug_slot(dev->slot->hotplug, probe);
>  }
>  
> -- 
> 2.27.0
> 

      reply	other threads:[~2020-09-17 21:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 11:24 [PATCH] PCI: Simplify pci_dev_reset_slot_function() Lukas Wunner
2020-09-17 21:26 ` Bjorn Helgaas [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=20200917212644.GA1739569@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=kbusch@kernel.org \
    --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 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.