All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@nvidia.com>
To: "Anthony Pighin (Nokia)" <anthony.pighin@nokia.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Nathan Chen <nathanc@nvidia.com>,
	"Jason Gunthorpe" <jgg@nvidia.com>
Subject: Re: [PATCH] PCI: Lock upstream bridge for pci_try_reset_function()
Date: Tue, 13 Jan 2026 16:37:46 -0700	[thread overview]
Message-ID: <20260113163746.107aaeb2@nvidia.com> (raw)
In-Reply-To: <BN0PR08MB69514F34E3CA505AE910F2F8838EA@BN0PR08MB6951.namprd08.prod.outlook.com>

On Tue, 13 Jan 2026 21:21:25 +0000
"Anthony Pighin (Nokia)" <anthony.pighin@nokia.com> wrote:

> Address this issue:
> [  125.942583] pcieport 0000:00:00.0: unlocked secondary bus reset via:
>                pci_reset_bus_function+0x188/0x1b8
> 
> which flows from a VFIO_GROUP_GET_DEVICE_FD ioctl when a PCI device is
> being added to a VFIO group.
> 
> Commit 920f6468924f ("Warn on missing cfg_access_lock during secondary
> bus reset") added a warning if the PCI configuration space was not
> locked during a secondary bus reset request. That was in response to
> commit 7e89efc6e9e4 ("Lock upstream bridge for pci_reset_function()")
> such that remaining paths would be made more visible.
> 
> Address the pci_try_reset_function() path.
> 

Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")

> Signed-off-by: Anthony Pighin <anthony.pighin@nokia.com>
> ---
>  drivers/pci/pci.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)


Reviewed-by: Alex Williamson <alex.williamson@nvidia.com>


> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 13dbb405dc31..ff3f2df7e9c8 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5196,19 +5196,34 @@ EXPORT_SYMBOL_GPL(pci_reset_function_locked);
>   */
>  int pci_try_reset_function(struct pci_dev *dev)
>  {
> +	struct pci_dev *bridge;
>  	int rc;
>  
>  	if (!pci_reset_supported(dev))
>  		return -ENOTTY;
>  
> -	if (!pci_dev_trylock(dev))
> +	/*
> +	 * If there's no upstream bridge, no locking is needed since there is
> +	 * no upstream bridge configuration to hold consistent.
> +	 */
> +	bridge = pci_upstream_bridge(dev);
> +	if (bridge && !pci_dev_trylock(bridge))
>  		return -EAGAIN;
>  
> +	if (!pci_dev_trylock(dev)) {
> +		rc = -EAGAIN;
> +		goto out_unlock_bridge;
> +	}
> +
>  	pci_dev_save_and_disable(dev);
>  	rc = __pci_reset_function_locked(dev);
>  	pci_dev_restore(dev);
>  	pci_dev_unlock(dev);
>  
> +out_unlock_bridge:
> +	if (bridge)
> +		pci_dev_unlock(bridge);
> +
>  	return rc;
>  }
>  EXPORT_SYMBOL_GPL(pci_try_reset_function);


  reply	other threads:[~2026-01-13 23:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13 21:21 [PATCH] PCI: Lock upstream bridge for pci_try_reset_function() Anthony Pighin (Nokia)
2026-01-13 23:37 ` Alex Williamson [this message]
2026-01-14  8:24 ` Ilpo Järvinen

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=20260113163746.107aaeb2@nvidia.com \
    --to=alex.williamson@nvidia.com \
    --cc=anthony.pighin@nokia.com \
    --cc=jgg@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nathanc@nvidia.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 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.