Commit 3f906da7 authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

Merge branch 'pci/enumeration'

- Fix pci_cfg_wait queue locking problem (Xiang Zheng, Bjorn Helgaas)

- Keep device in system even if driver attach fails (Rajat Jain)

- Cache ACS capability offset in device (Rajat Jain)

- Treat "external-facing" devices themselves as internal, not external
  (Rajat Jain)

- Announce device after early fixups (Tiezhu Yang)

* pci/enumeration:
  PCI: Announce device after early fixups
  PCI: Treat "external-facing" devices themselves as internal
  PCI: Cache ACS capability offset in device
  PCI: Reorder pci_enable_acs() and dependencies
  PCI: Add device even if driver attach failed
  PCI: Fix pci_cfg_wait queue locking problem
parents 0dfcabe9 b7360f60
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4730,12 +4730,12 @@ const struct attribute_group *intel_iommu_groups[] = {
	NULL,
};

static inline bool has_untrusted_dev(void)
static inline bool has_external_pci(void)
{
	struct pci_dev *pdev = NULL;

	for_each_pci_dev(pdev)
		if (pdev->untrusted)
		if (pdev->external_facing)
			return true;

	return false;
@@ -4743,7 +4743,7 @@ static inline bool has_untrusted_dev(void)

static int __init platform_optin_force_iommu(void)
{
	if (!dmar_platform_optin() || no_platform_optin || !has_untrusted_dev())
	if (!dmar_platform_optin() || no_platform_optin || !has_external_pci())
		return 0;

	if (no_iommu || dmar_disabled)
+2 −6
Original line number Diff line number Diff line
@@ -204,17 +204,13 @@ EXPORT_SYMBOL(pci_bus_set_ops);
static DECLARE_WAIT_QUEUE_HEAD(pci_cfg_wait);

static noinline void pci_wait_cfg(struct pci_dev *dev)
	__must_hold(&pci_lock)
{
	DECLARE_WAITQUEUE(wait, current);

	__add_wait_queue(&pci_cfg_wait, &wait);
	do {
		set_current_state(TASK_UNINTERRUPTIBLE);
		raw_spin_unlock_irq(&pci_lock);
		schedule();
		wait_event(pci_cfg_wait, !dev->block_cfg_access);
		raw_spin_lock_irq(&pci_lock);
	} while (dev->block_cfg_access);
	__remove_wait_queue(&pci_cfg_wait, &wait);
}

/* Returns 0 on success, negative values indicate error. */
+1 −5
Original line number Diff line number Diff line
@@ -322,12 +322,8 @@ void pci_bus_add_device(struct pci_dev *dev)

	dev->match_driver = true;
	retval = device_attach(&dev->dev);
	if (retval < 0 && retval != -EPROBE_DEFER) {
	if (retval < 0 && retval != -EPROBE_DEFER)
		pci_warn(dev, "device attach failed (%d)\n", retval);
		pci_proc_detach_device(dev);
		pci_remove_sysfs_dev_files(dev);
		return;
	}

	pci_dev_assign_added(dev, true);
}
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ void pci_set_bus_of_node(struct pci_bus *bus)
	} else {
		node = of_node_get(bus->self->dev.of_node);
		if (node && of_property_read_bool(node, "external-facing"))
			bus->self->untrusted = true;
			bus->self->external_facing = true;
	}

	bus->dev.of_node = node;
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev)
	int pos;
	u16 ctrl;

	pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
	pos = pdev->acs_cap;
	if (!pos)
		return 0;

Loading