Skip to content

Commit 3f906da

Browse files
committed
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
2 parents 0dfcabe + b7360f6 commit 3f906da

File tree

11 files changed

+169
-159
lines changed

11 files changed

+169
-159
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4730,20 +4730,20 @@ const struct attribute_group *intel_iommu_groups[] = {
47304730
NULL,
47314731
};
47324732

4733-
static inline bool has_untrusted_dev(void)
4733+
static inline bool has_external_pci(void)
47344734
{
47354735
struct pci_dev *pdev = NULL;
47364736

47374737
for_each_pci_dev(pdev)
4738-
if (pdev->untrusted)
4738+
if (pdev->external_facing)
47394739
return true;
47404740

47414741
return false;
47424742
}
47434743

47444744
static int __init platform_optin_force_iommu(void)
47454745
{
4746-
if (!dmar_platform_optin() || no_platform_optin || !has_untrusted_dev())
4746+
if (!dmar_platform_optin() || no_platform_optin || !has_external_pci())
47474747
return 0;
47484748

47494749
if (no_iommu || dmar_disabled)

drivers/pci/access.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,13 @@ EXPORT_SYMBOL(pci_bus_set_ops);
204204
static DECLARE_WAIT_QUEUE_HEAD(pci_cfg_wait);
205205

206206
static noinline void pci_wait_cfg(struct pci_dev *dev)
207+
__must_hold(&pci_lock)
207208
{
208-
DECLARE_WAITQUEUE(wait, current);
209-
210-
__add_wait_queue(&pci_cfg_wait, &wait);
211209
do {
212-
set_current_state(TASK_UNINTERRUPTIBLE);
213210
raw_spin_unlock_irq(&pci_lock);
214-
schedule();
211+
wait_event(pci_cfg_wait, !dev->block_cfg_access);
215212
raw_spin_lock_irq(&pci_lock);
216213
} while (dev->block_cfg_access);
217-
__remove_wait_queue(&pci_cfg_wait, &wait);
218214
}
219215

220216
/* Returns 0 on success, negative values indicate error. */

drivers/pci/bus.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,8 @@ void pci_bus_add_device(struct pci_dev *dev)
322322

323323
dev->match_driver = true;
324324
retval = device_attach(&dev->dev);
325-
if (retval < 0 && retval != -EPROBE_DEFER) {
325+
if (retval < 0 && retval != -EPROBE_DEFER)
326326
pci_warn(dev, "device attach failed (%d)\n", retval);
327-
pci_proc_detach_device(dev);
328-
pci_remove_sysfs_dev_files(dev);
329-
return;
330-
}
331327

332328
pci_dev_assign_added(dev, true);
333329
}

drivers/pci/of.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void pci_set_bus_of_node(struct pci_bus *bus)
4242
} else {
4343
node = of_node_get(bus->self->dev.of_node);
4444
if (node && of_property_read_bool(node, "external-facing"))
45-
bus->self->untrusted = true;
45+
bus->self->external_facing = true;
4646
}
4747

4848
bus->dev.of_node = node;

drivers/pci/p2pdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev)
253253
int pos;
254254
u16 ctrl;
255255

256-
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
256+
pos = pdev->acs_cap;
257257
if (!pos)
258258
return 0;
259259

drivers/pci/pci-acpi.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
12131213
ACPI_FREE(obj);
12141214
}
12151215

1216-
static void pci_acpi_set_untrusted(struct pci_dev *dev)
1216+
static void pci_acpi_set_external_facing(struct pci_dev *dev)
12171217
{
12181218
u8 val;
12191219

@@ -1224,11 +1224,10 @@ static void pci_acpi_set_untrusted(struct pci_dev *dev)
12241224

12251225
/*
12261226
* These root ports expose PCIe (including DMA) outside of the
1227-
* system so make sure we treat them and everything behind as
1228-
* untrusted.
1227+
* system. Everything downstream from them is external.
12291228
*/
12301229
if (val)
1231-
dev->untrusted = 1;
1230+
dev->external_facing = 1;
12321231
}
12331232

12341233
static void pci_acpi_setup(struct device *dev)
@@ -1240,7 +1239,7 @@ static void pci_acpi_setup(struct device *dev)
12401239
return;
12411240

12421241
pci_acpi_optimize_delay(pci_dev, adev->handle);
1243-
pci_acpi_set_untrusted(pci_dev);
1242+
pci_acpi_set_external_facing(pci_dev);
12441243
pci_acpi_add_edr_notifier(pci_dev);
12451244

12461245
pci_acpi_add_pm_notifier(adev, pci_dev);

0 commit comments

Comments
 (0)