Re: [PATCH 02/11] PCI: Add pci_bus_isolation()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 01, 2025 at 01:28:59PM -0600, Alex Williamson wrote:
> > +enum pci_bus_isolation pci_bus_isolated(struct pci_bus *bus)
> > +{
> > +	struct pci_dev *bridge = bus->self;
> > +	int type;
> > +
> > +	/* Consider virtual busses isolated */
> > +	if (!bridge)
> > +		return PCIE_ISOLATED;
> > +	if (pci_is_root_bus(bus))
> > +		return PCIE_ISOLATED;
> 
> How do we know the root bus isn't conventional?

If I read this right this is dead code..

/*
 * Returns true if the PCI bus is root (behind host-PCI bridge),
 * false otherwise
 *
 * Some code assumes that "bus->self == NULL" means that bus is a root bus.
 * This is incorrect because "virtual" buses added for SR-IOV (via
 * virtfn_add_bus()) have "bus->self == NULL" but are not root buses.
 */
static inline bool pci_is_root_bus(struct pci_bus *pbus)
{
	return !(pbus->parent);

Looking at the call chain of pci_alloc_bus():
 pci_alloc_child_bus() - Parent bus may not be NULL
 pci_add_new_bus() - All callers pass !NULL bus
 pci_register_host_bridge() - Sets self and parent to NULL

Thus if pci_is_root() == true implies bus->self == NULL so we can't
get here.

So I will change it to be like:

	/*
	 * This bus was created by pci_register_host_bridge(). There is nothing
	 * upstream of this, assume it contains the TA and that the root complex
	 * does not allow P2P without going through the IOMMU.
	 */
	if (pci_is_root_bus(bus))
		return PCIE_ISOLATED;

	/*
	 * Sometimes SRIOV VFs can have a "virtual" bus if the SRIOV RID's
	 * extend past the bus numbers of the parent. The spec says that SRIOV
	 * VFs and PFs should act the same as functions in a MFD. MFD isolation
	 * is handled outside this function.
	 */
	if (!bridge)
		return PCIE_ISOLATED;

And now it seems we never took care with SRIOV, along with the PF
every SRIOV VF needs to have its ACS checked as though it was a MFD..

Jason




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux