All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Niklas Schnelle" <schnelle@linux.ibm.com>
Cc: linux-s390 <linux-s390@vger.kernel.org>,
	linux-pci@vger.kernel.org, virtualization@lists.linux.dev,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v6 2/4] PCI: loongson: Handle missing function 0 explicitly not via isolated functions
Date: Fri, 04 Dec 2026 14:45:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-250007@kernel.org> (raw)
In-Reply-To: <20261204-ari_no_bus_dev-v6-2-855e75237600@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] PCI: loongson: unsynchronized bus_flags RMW in
  pci_loongson_add_bus()
--

commit a00d743eeef918a05cf235d984b0deccce027b91
Author: Niklas Schnelle <schnelle@linux.ibm.com>

PCI: loongson: Handle missing function 0 explicitly not via isolated functions

This commit introduces the PCI_BUS_FLAGS_MAYBE_NO_FN0 bus flag for
Loongson PCI controllers via pci_loongson_add_bus() and checks it in
pci_scan_slot(), replacing the CONFIG_LOONGARCH check in
hypervisor_isolated_pci_functions().

Link: https://lore.kernel.org/lkml/CAAhV-H6qqppoX_G5KrWmPor16bXfvNTE2x8Xx6yajAYPqxpigw@mail.gmail.com/
Link: https://lore.kernel.org/linux-pci/20251014074100.2149737-1-chenhuacai@loongson.cn/

> diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c
> index 6c0b7a3f4ba05..6241b8038fe16 100644
> --- a/drivers/pci/controller/pci-loongson.c
> +++ b/drivers/pci/controller/pci-loongson.c
> @@ -252,6 +252,19 @@ static void __iomem *cfg1_map(struct loongson_pci *priv, struct pci_bus *bus,
>  	return priv->cfg1_base + addroff;
>  }
>  
> +static int pci_loongson_add_bus(struct pci_bus *bus)
> +{
> +	/*
> +	 * Some Loongson systems rely on PCI devices with
> +	 * a disabled function 0. Tell common code to keep looking
> +	 * for PCI functions even if function 0 is missing.
> +	 * This does not drop the checks for ARI and multifunction.
> +	 */
> +	bus->bus_flags |= PCI_BUS_FLAGS_MAYBE_NO_FN0;
> +
> +	return 0;
> +}

[Severity: Low]
Can this read-modify-write on bus->bus_flags race with msi_bus_store()
on child buses?

During a PCI rescan or hotplug of a bridge, pci_device_add() exposes
the bridge's msi_bus sysfs attribute before pci_alloc_child_bus() creates
its subordinate bus.  Inside pci_alloc_child_bus(), bridge->subordinate
is published before device_register(&child->dev) and
child->ops->add_bus(child) run, while msi_bus_store() modifies
subordinate->bus_flags without holding any lock:

CPU0                              CPU1
pci_alloc_child_bus()
  bridge->subordinate = child
  device_register(&child->dev)
                                  msi_bus_store()
                                    subordinate = pdev->subordinate
  pci_loongson_add_bus(child)
    bus->bus_flags |= ...           subordinate->bus_flags |= ...
                                    <-- data race on bus_flags

Because both sides perform unlocked non-atomic read-modify-writes, a
concurrent update can silently lose a PCI_BUS_FLAGS_NO_MSI toggle even
though msi_bus_store() returns success.

Since pci_alloc_child_bus() already inherits parent->bus_flags before
publishing bridge->subordinate, setting PCI_BUS_FLAGS_MAYBE_NO_FN0 only
when pci_is_root_bus(bus) is true would avoid the redundant write on
child buses.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-ari_no_bus_dev-v6-0-855e75237600@linux.ibm.com?part=2

  reply	other threads:[~2026-12-04 14:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 14:14 [PATCH v6 0/4] PCI: Fix isolated function probing and enable ARI for s390 Niklas Schnelle
2026-12-04 14:14 ` [PATCH v6 1/4] jailhouse: Fix leak of device node in jailhouse_paravirt() on non-x86 Niklas Schnelle
2026-12-04 14:14 ` [PATCH v6 2/4] PCI: loongson: Handle missing function 0 explicitly not via isolated functions Niklas Schnelle
2026-12-04 14:45   ` sashiko-bot [this message]
2026-12-04 14:14 ` [PATCH v6 3/4] PCI: Fix isolated PCI function probing with ARI and SR-IOV Niklas Schnelle
2026-12-04 15:02   ` sashiko-bot
2026-12-04 14:14 ` [PATCH v6 4/4] PCI: s390: Handle ARI on bus without associated struct pci_dev Niklas Schnelle
2026-12-04 15:25   ` sashiko-bot
2026-12-04 15:25 ` [PATCH v6 0/4] PCI: Fix isolated function probing and enable ARI for s390 sashiko-bot
2026-12-05 17:32   ` 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=sashiko-outbox-250007@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=eperezma@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=schnelle@linux.ibm.com \
    --cc=virtualization@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.