All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Koichiro Den <den@valinux.co.jp>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
	"Frank Li" <Frank.Li@kernel.org>, "Jon Mason" <jdmason@kudzu.us>,
	"Dave Jiang" <dave.jiang@intel.com>,
	"Allen Hubbe" <allenbh@gmail.com>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	ntb@lists.linux.dev, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 1/2] PCI: endpoint: pci-epf-vntb: Serialize virtual PCI bus scan
Date: Tue, 1 Sep 2026 14:00:44 -0500	[thread overview]
Message-ID: <apcg3J8kzvQFDFld@SMW015318> (raw)
In-Reply-To: <20260901063238.631166-2-den@valinux.co.jp>

On Tue, Sep 01, 2026 at 03:32:37PM +0900, Koichiro Den wrote:
> The virtual PCI bus is scanned without holding the PCI rescan/remove
> lock. This can race with other PCI topology changes.
>
> Hold the lock across the bus scan and device addition.
>
> Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
> Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
> Link: https://lore.kernel.org/r/3tgrcel5fl55ulf3zjya4fkz4t2ms7iwwjif5rnzn2rafsydd6@i4e5etm7uqvz/
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---

It is okay for now, I suggest define cleanup by use guard() in future.

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes in v6:
>   - New patch based on Mani's review of v5 patch 4.
>
>  drivers/pci/endpoint/functions/pci-epf-vntb.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index c3caec927d74..412e8cc6fb1d 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> @@ -1332,14 +1332,19 @@ static int vpci_scan_bus(void *sysdata)
>  	struct pci_bus *vpci_bus;
>  	struct epf_ntb *ndev = sysdata;
>
> +	pci_lock_rescan_remove();
> +
>  	vpci_bus = pci_scan_bus(ndev->vbus_number, &vpci_ops, sysdata);
>  	if (!vpci_bus) {
>  		pr_err("create pci bus failed\n");
> +		pci_unlock_rescan_remove();
>  		return -EINVAL;
>  	}
>
>  	pci_bus_add_devices(vpci_bus);
>
> +	pci_unlock_rescan_remove();
> +
>  	return 0;
>  }
>
> --
> 2.51.0
>

  parent reply	other threads:[~2026-09-01 19:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  6:32 [PATCH v6 0/2] PCI: endpoint: pci-epf-*ntb: Harden vNTB resource management Koichiro Den
2026-09-01  6:32 ` [PATCH v6 1/2] PCI: endpoint: pci-epf-vntb: Serialize virtual PCI bus scan Koichiro Den
2026-09-01  6:47   ` sashiko-bot
2026-09-01 19:00   ` Frank Li [this message]
2026-09-01  6:32 ` [PATCH v6 2/2] PCI: endpoint: pci-epf-vntb: Manage virtual NTB and PCI bus lifetime Koichiro Den
2026-09-01  6:45   ` sashiko-bot
2026-09-01 19:05   ` Frank Li
2026-09-11 21:45   ` Bjorn Helgaas
2026-09-12 14:57     ` Koichiro Den
2026-09-10 14:59 ` [PATCH v6 0/2] PCI: endpoint: pci-epf-*ntb: Harden vNTB resource management Manivannan Sadhasivam

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=apcg3J8kzvQFDFld@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=allenbh@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=dave.jiang@intel.com \
    --cc=den@valinux.co.jp \
    --cc=jdmason@kudzu.us \
    --cc=kishon@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=ntb@lists.linux.dev \
    /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.