Skip to content

Commit 134cd00

Browse files
committed
Merge branches 'pci/enumeration', 'pci/misc' and 'pci/virtualization' into next
* pci/enumeration: PCI: Enable CRS Software Visibility for root port if it is supported PCI: Check only the Vendor ID to identify Configuration Request Retry * pci/misc: PCI: Parenthesize PCI_DEVID and PCI_VPD_LRDT_ID parameters PCI: Increase IBM ipr SAS Crocodile BARs to at least system page size PCI/AER: Make <linux/aer.h> standalone includable * pci/virtualization: PCI: Use device flag helper functions xen/pciback: Use PCI device flag helper functions KVM: Use PCI device flag helper functions PCI: Add device flag helper functions PCI: Assume all Mellanox devices have broken INTx masking
4 parents a2351ef + f3dbd80 + 63ddc0b + be63497 commit 134cd00

8 files changed

Lines changed: 64 additions & 10 deletions

File tree

‎drivers/pci/iov.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ int pci_vfs_assigned(struct pci_dev *dev)
633633
* our dev as the physical function and the assigned bit is set
634634
*/
635635
if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
636-
(vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
636+
pci_is_dev_assigned(vfdev))
637637
vfs_assigned++;
638638

639639
vfdev = pci_get_device(dev->vendor, dev_id, vfdev);

‎drivers/pci/probe.c‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,17 @@ struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
740740
}
741741
EXPORT_SYMBOL(pci_add_new_bus);
742742

743+
static void pci_enable_crs(struct pci_dev *pdev)
744+
{
745+
u16 root_cap = 0;
746+
747+
/* Enable CRS Software Visibility if supported */
748+
pcie_capability_read_word(pdev, PCI_EXP_RTCAP, &root_cap);
749+
if (root_cap & PCI_EXP_RTCAP_CRSVIS)
750+
pcie_capability_set_word(pdev, PCI_EXP_RTCTL,
751+
PCI_EXP_RTCTL_CRSSVE);
752+
}
753+
743754
/*
744755
* If it's a bridge, configure it and scan the bus behind it.
745756
* For CardBus bridges, we don't scan behind as the devices will
@@ -787,6 +798,8 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
787798
pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
788799
bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
789800

801+
pci_enable_crs(dev);
802+
790803
if ((secondary || subordinate) && !pcibios_assign_all_busses() &&
791804
!is_cardbus && !broken) {
792805
unsigned int cmax;
@@ -1292,8 +1305,13 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
12921305
*l == 0x0000ffff || *l == 0xffff0000)
12931306
return false;
12941307

1295-
/* Configuration request Retry Status */
1296-
while (*l == 0xffff0001) {
1308+
/*
1309+
* Configuration Request Retry Status. Some root ports return the
1310+
* actual device ID instead of the synthetic ID (0xFFFF) required
1311+
* by the PCIe spec. Ignore the device ID and only check for
1312+
* (vendor id == 1).
1313+
*/
1314+
while ((*l & 0xffff) == 0x0001) {
12971315
if (!crs_timeout)
12981316
return false;
12991317

‎drivers/pci/quirks.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/ioport.h>
2525
#include <linux/sched.h>
2626
#include <linux/ktime.h>
27+
#include <linux/mm.h>
2728
#include <asm/dma.h> /* isa_dma_bridge_buggy */
2829
#include "pci.h"
2930

@@ -287,6 +288,25 @@ static void quirk_citrine(struct pci_dev *dev)
287288
}
288289
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine);
289290

291+
/* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */
292+
static void quirk_extend_bar_to_page(struct pci_dev *dev)
293+
{
294+
int i;
295+
296+
for (i = 0; i < PCI_STD_RESOURCE_END; i++) {
297+
struct resource *r = &dev->resource[i];
298+
299+
if (r->flags & IORESOURCE_MEM && resource_size(r) < PAGE_SIZE) {
300+
r->end = PAGE_SIZE - 1;
301+
r->start = 0;
302+
r->flags |= IORESOURCE_UNSET;
303+
dev_info(&dev->dev, "expanded BAR %d to page size: %pR\n",
304+
i, r);
305+
}
306+
}
307+
}
308+
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, 0x034a, quirk_extend_bar_to_page);
309+
290310
/*
291311
* S3 868 and 968 chips report region size equal to 32M, but they decode 64M.
292312
* If it's needed, re-allocate the region.
@@ -2985,6 +3005,8 @@ DECLARE_PCI_FIXUP_HEADER(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
29853005
*/
29863006
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_REALTEK, 0x8169,
29873007
quirk_broken_intx_masking);
3008+
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
3009+
quirk_broken_intx_masking);
29883010

29893011
#ifdef CONFIG_ACPI
29903012
/*

‎drivers/xen/xen-pciback/pci_stub.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static void pcistub_device_release(struct kref *kref)
133133
xen_pcibk_config_free_dyn_fields(dev);
134134
xen_pcibk_config_free_dev(dev);
135135

136-
dev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
136+
pci_clear_dev_assigned(dev);
137137
pci_dev_put(dev);
138138

139139
kfree(psdev);
@@ -413,7 +413,7 @@ static int pcistub_init_device(struct pci_dev *dev)
413413
dev_dbg(&dev->dev, "reset device\n");
414414
xen_pcibk_reset_device(dev);
415415

416-
dev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED;
416+
pci_set_dev_assigned(dev);
417417
return 0;
418418

419419
config_release:

‎include/linux/pci.h‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* In the interest of not exposing interfaces to user-space unnecessarily,
4646
* the following kernel-only defines are being added here.
4747
*/
48-
#define PCI_DEVID(bus, devfn) ((((u16)bus) << 8) | devfn)
48+
#define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn))
4949
/* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
5050
#define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
5151

@@ -1701,7 +1701,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
17011701
struct pci_dev *end, u16 acs_flags);
17021702

17031703
#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */
1704-
#define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT)
1704+
#define PCI_VPD_LRDT_ID(x) ((x) | PCI_VPD_LRDT)
17051705

17061706
/* Large Resource Data Type Tag Item Names */
17071707
#define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */
@@ -1839,4 +1839,17 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
18391839
*/
18401840
struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev);
18411841

1842+
/* helper functions for operation of device flag */
1843+
static inline void pci_set_dev_assigned(struct pci_dev *pdev)
1844+
{
1845+
pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED;
1846+
}
1847+
static inline void pci_clear_dev_assigned(struct pci_dev *pdev)
1848+
{
1849+
pdev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
1850+
}
1851+
static inline bool pci_is_dev_assigned(struct pci_dev *pdev)
1852+
{
1853+
return (pdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED) == PCI_DEV_FLAGS_ASSIGNED;
1854+
}
18421855
#endif /* LINUX_PCI_H */

‎include/uapi/linux/pci_regs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@
552552
#define PCI_EXP_RTCTL_PMEIE 0x0008 /* PME Interrupt Enable */
553553
#define PCI_EXP_RTCTL_CRSSVE 0x0010 /* CRS Software Visibility Enable */
554554
#define PCI_EXP_RTCAP 30 /* Root Capabilities */
555+
#define PCI_EXP_RTCAP_CRSVIS 0x0001 /* CRS Software Visibility capability */
555556
#define PCI_EXP_RTSTA 32 /* Root Status */
556557
#define PCI_EXP_RTSTA_PME 0x00010000 /* PME status */
557558
#define PCI_EXP_RTSTA_PENDING 0x00020000 /* PME pending */

‎virt/kvm/assigned-dev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static void kvm_free_assigned_device(struct kvm *kvm,
302302
else
303303
pci_restore_state(assigned_dev->dev);
304304

305-
assigned_dev->dev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
305+
pci_clear_dev_assigned(assigned_dev->dev);
306306

307307
pci_release_regions(assigned_dev->dev);
308308
pci_disable_device(assigned_dev->dev);

‎virt/kvm/iommu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ int kvm_assign_device(struct kvm *kvm,
203203
goto out_unmap;
204204
}
205205

206-
pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED;
206+
pci_set_dev_assigned(pdev);
207207

208208
dev_info(&pdev->dev, "kvm assign device\n");
209209

@@ -229,7 +229,7 @@ int kvm_deassign_device(struct kvm *kvm,
229229

230230
iommu_detach_device(domain, &pdev->dev);
231231

232-
pdev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
232+
pci_clear_dev_assigned(pdev);
233233

234234
dev_info(&pdev->dev, "kvm deassign device\n");
235235

0 commit comments

Comments
 (0)