Skip to content

Commit 774800c

Browse files
committed
Merge branch 'pci/resource'
- Protect pci_reassign_bridge_resources() against concurrent addition/removal (Benjamin Herrenschmidt) - Fix bridge dma_ranges resource list cleanup (Rob Herring) - Add PCI_STD_NUM_BARS for the number of standard BARs (Denis Efremov) - Add "pci=hpmmiosize" and "pci=hpmmioprefsize" parameters to control the MMIO and prefetchable MMIO window sizes of hotplug bridges independently (Nicholas Johnson) - Fix MMIO/MMIO_PREF window assignment that assigned more space than desired (Nicholas Johnson) - Only enforce bus numbers from bridge EA if the bridge has EA devices downstream (Subbaraya Sundeep) * pci/resource: PCI: Do not use bus number zero from EA capability PCI: Avoid double hpmemsize MMIO window assignment PCI: Add "pci=hpmmiosize" and "pci=hpmmioprefsize" parameters PCI: Add PCI_STD_NUM_BARS for the number of standard BARs PCI: Fix missing bridge dma_ranges resource list cleanup PCI: Protect pci_reassign_bridge_resources() against concurrent addition/removal
2 parents 7cfe163 + 73884a7 commit 774800c

File tree

50 files changed

+195
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+195
-147
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,8 +3492,15 @@
34923492
hpiosize=nn[KMG] The fixed amount of bus space which is
34933493
reserved for hotplug bridge's IO window.
34943494
Default size is 256 bytes.
3495+
hpmmiosize=nn[KMG] The fixed amount of bus space which is
3496+
reserved for hotplug bridge's MMIO window.
3497+
Default size is 2 megabytes.
3498+
hpmmioprefsize=nn[KMG] The fixed amount of bus space which is
3499+
reserved for hotplug bridge's MMIO_PREF window.
3500+
Default size is 2 megabytes.
34953501
hpmemsize=nn[KMG] The fixed amount of bus space which is
3496-
reserved for hotplug bridge's memory window.
3502+
reserved for hotplug bridge's MMIO and
3503+
MMIO_PREF window.
34973504
Default size is 2 megabytes.
34983505
hpbussize=nn The minimum amount of additional bus numbers
34993506
reserved for buses below a hotplug bridge.

arch/alpha/kernel/pci-sysfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ static int pci_mmap_resource(struct kobject *kobj,
7171
struct pci_bus_region bar;
7272
int i;
7373

74-
for (i = 0; i < PCI_ROM_RESOURCE; i++)
74+
for (i = 0; i < PCI_STD_NUM_BARS; i++)
7575
if (res == &pdev->resource[i])
7676
break;
77-
if (i >= PCI_ROM_RESOURCE)
77+
if (i >= PCI_STD_NUM_BARS)
7878
return -ENODEV;
7979

8080
if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start))
@@ -115,7 +115,7 @@ void pci_remove_resource_files(struct pci_dev *pdev)
115115
{
116116
int i;
117117

118-
for (i = 0; i < PCI_ROM_RESOURCE; i++) {
118+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
119119
struct bin_attribute *res_attr;
120120

121121
res_attr = pdev->res_attr[i];
@@ -232,7 +232,7 @@ int pci_create_resource_files(struct pci_dev *pdev)
232232
int retval;
233233

234234
/* Expose the PCI resources from this device as files */
235-
for (i = 0; i < PCI_ROM_RESOURCE; i++) {
235+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
236236

237237
/* skip empty resources */
238238
if (!pci_resource_len(pdev, i))

arch/s390/include/asm/pci.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#ifndef __ASM_S390_PCI_H
33
#define __ASM_S390_PCI_H
44

5-
/* must be set before including pci_clp.h */
6-
#define PCI_BAR_COUNT 6
7-
85
#include <linux/pci.h>
96
#include <linux/mutex.h>
107
#include <linux/iommu.h>
@@ -138,7 +135,7 @@ struct zpci_dev {
138135

139136
char res_name[16];
140137
bool mio_capable;
141-
struct zpci_bar_struct bars[PCI_BAR_COUNT];
138+
struct zpci_bar_struct bars[PCI_STD_NUM_BARS];
142139

143140
u64 start_dma; /* Start of available DMA addresses */
144141
u64 end_dma; /* End of available DMA addresses */

arch/s390/include/asm/pci_clp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct mio_info {
7777
struct {
7878
u64 wb;
7979
u64 wt;
80-
} addr[PCI_BAR_COUNT];
80+
} addr[PCI_STD_NUM_BARS];
8181
u32 reserved[6];
8282
} __packed;
8383

@@ -98,9 +98,9 @@ struct clp_rsp_query_pci {
9898
u16 util_str_avail : 1; /* utility string available? */
9999
u16 pfgid : 8; /* pci function group id */
100100
u32 fid; /* pci function id */
101-
u8 bar_size[PCI_BAR_COUNT];
101+
u8 bar_size[PCI_STD_NUM_BARS];
102102
u16 pchid;
103-
__le32 bar[PCI_BAR_COUNT];
103+
__le32 bar[PCI_STD_NUM_BARS];
104104
u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
105105
u32 : 16;
106106
u8 fmb_len;

arch/s390/pci/pci.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES);
4343
static DEFINE_SPINLOCK(zpci_domain_lock);
4444

4545
#define ZPCI_IOMAP_ENTRIES \
46-
min(((unsigned long) ZPCI_NR_DEVICES * PCI_BAR_COUNT / 2), \
46+
min(((unsigned long) ZPCI_NR_DEVICES * PCI_STD_NUM_BARS / 2), \
4747
ZPCI_IOMAP_MAX_ENTRIES)
4848

4949
static DEFINE_SPINLOCK(zpci_iomap_lock);
@@ -294,7 +294,7 @@ static void __iomem *pci_iomap_range_mio(struct pci_dev *pdev, int bar,
294294
void __iomem *pci_iomap_range(struct pci_dev *pdev, int bar,
295295
unsigned long offset, unsigned long max)
296296
{
297-
if (!pci_resource_len(pdev, bar) || bar >= PCI_BAR_COUNT)
297+
if (bar >= PCI_STD_NUM_BARS || !pci_resource_len(pdev, bar))
298298
return NULL;
299299

300300
if (static_branch_likely(&have_mio))
@@ -324,7 +324,7 @@ static void __iomem *pci_iomap_wc_range_mio(struct pci_dev *pdev, int bar,
324324
void __iomem *pci_iomap_wc_range(struct pci_dev *pdev, int bar,
325325
unsigned long offset, unsigned long max)
326326
{
327-
if (!pci_resource_len(pdev, bar) || bar >= PCI_BAR_COUNT)
327+
if (bar >= PCI_STD_NUM_BARS || !pci_resource_len(pdev, bar))
328328
return NULL;
329329

330330
if (static_branch_likely(&have_mio))
@@ -416,7 +416,7 @@ static void zpci_map_resources(struct pci_dev *pdev)
416416
resource_size_t len;
417417
int i;
418418

419-
for (i = 0; i < PCI_BAR_COUNT; i++) {
419+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
420420
len = pci_resource_len(pdev, i);
421421
if (!len)
422422
continue;
@@ -451,7 +451,7 @@ static void zpci_unmap_resources(struct pci_dev *pdev)
451451
if (zpci_use_mio(zdev))
452452
return;
453453

454-
for (i = 0; i < PCI_BAR_COUNT; i++) {
454+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
455455
len = pci_resource_len(pdev, i);
456456
if (!len)
457457
continue;
@@ -514,7 +514,7 @@ static int zpci_setup_bus_resources(struct zpci_dev *zdev,
514514
snprintf(zdev->res_name, sizeof(zdev->res_name),
515515
"PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR);
516516

517-
for (i = 0; i < PCI_BAR_COUNT; i++) {
517+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
518518
if (!zdev->bars[i].size)
519519
continue;
520520
entry = zpci_alloc_iomap(zdev);
@@ -551,7 +551,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev)
551551
{
552552
int i;
553553

554-
for (i = 0; i < PCI_BAR_COUNT; i++) {
554+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
555555
if (!zdev->bars[i].size || !zdev->bars[i].res)
556556
continue;
557557

@@ -573,7 +573,7 @@ int pcibios_add_device(struct pci_dev *pdev)
573573
pdev->dev.dma_ops = &s390_pci_dma_ops;
574574
zpci_map_resources(pdev);
575575

576-
for (i = 0; i < PCI_BAR_COUNT; i++) {
576+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
577577
res = &pdev->resource[i];
578578
if (res->parent || !res->flags)
579579
continue;

arch/s390/pci/pci_clp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int clp_store_query_pci_fn(struct zpci_dev *zdev,
145145
{
146146
int i;
147147

148-
for (i = 0; i < PCI_BAR_COUNT; i++) {
148+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
149149
zdev->bars[i].val = le32_to_cpu(response->bar[i]);
150150
zdev->bars[i].size = response->bar_size[i];
151151
}
@@ -164,8 +164,8 @@ static int clp_store_query_pci_fn(struct zpci_dev *zdev,
164164
sizeof(zdev->util_str));
165165
}
166166
zdev->mio_capable = response->mio_addr_avail;
167-
for (i = 0; i < PCI_BAR_COUNT; i++) {
168-
if (!(response->mio.valid & (1 << (PCI_BAR_COUNT - i - 1))))
167+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
168+
if (!(response->mio.valid & (1 << (PCI_STD_NUM_BARS - i - 1))))
169169
continue;
170170

171171
zdev->bars[i].mio_wb = (void __iomem *) response->mio.addr[i].wb;

arch/x86/pci/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static void pcibios_fixup_device_resources(struct pci_dev *dev)
135135
* resource so the kernel doesn't attempt to assign
136136
* it later on in pci_assign_unassigned_resources
137137
*/
138-
for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) {
138+
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
139139
bar_r = &dev->resource[bar];
140140
if (bar_r->start == 0 && bar_r->end != 0) {
141141
bar_r->flags = 0;

arch/x86/pci/intel_mid_pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static void pci_fixed_bar_fixup(struct pci_dev *dev)
382382
PCI_DEVFN(2, 2) == dev->devfn)
383383
return;
384384

385-
for (i = 0; i < PCI_ROM_RESOURCE; i++) {
385+
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
386386
pci_read_config_dword(dev, offset + 8 + (i * 4), &size);
387387
dev->resource[i].end = dev->resource[i].start + size - 1;
388388
dev->resource[i].flags |= IORESOURCE_PCI_FIXED;

drivers/ata/pata_atp867x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)
422422
#ifdef ATP867X_DEBUG
423423
atp867x_check_res(pdev);
424424

425-
for (i = 0; i < PCI_ROM_RESOURCE; i++)
425+
for (i = 0; i < PCI_STD_NUM_BARS; i++)
426426
printk(KERN_DEBUG "ATP867X: iomap[%d]=0x%llx\n", i,
427427
(unsigned long long)(host->iomap[i]));
428428
#endif

drivers/ata/sata_nv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
23252325
// Make sure this is a SATA controller by counting the number of bars
23262326
// (NVIDIA SATA controllers will always have six bars). Otherwise,
23272327
// it's an IDE controller and we ignore it.
2328-
for (bar = 0; bar < 6; bar++)
2328+
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++)
23292329
if (pci_resource_start(pdev, bar) == 0)
23302330
return -ENODEV;
23312331

0 commit comments

Comments
 (0)