Skip to content

Commit 081f369

Browse files
committed
Merge tag 'pci-v4.4-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI fixes from Bjorn Helgaas: "Here are a few fixes I'd like to have in v4.4: a generic one for sysfs and three for HiSilicon and DesignWare host controllers. Summary: NUMA: - Prevent out of bounds access in numa_node override (Mathias Krause) HiSilicon host bridge driver: - Fix deferred probing (Arnd Bergmann) Synopsys DesignWare host bridge driver: - Remove incorrect io_base assignment (Stanimir Varbanov) - Move align_resource function pointer to pci_host_bridge structure (Gabriele Paoloni)" * tag 'pci-v4.4-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: ARM/PCI: Move align_resource function pointer to pci_host_bridge structure PCI: hisi: Fix deferred probing PCI: designware: Remove incorrect io_base assignment PCI: Prevent out of bounds access in numa_node override
2 parents 8003a57 + 7c7a0e9 commit 081f369

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

arch/arm/kernel/bios32.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
#include <asm/mach/pci.h>
1818

1919
static int debug_pci;
20-
static resource_size_t (*align_resource)(struct pci_dev *dev,
21-
const struct resource *res,
22-
resource_size_t start,
23-
resource_size_t size,
24-
resource_size_t align) = NULL;
2520

2621
/*
2722
* We can't use pci_get_device() here since we are
@@ -461,7 +456,6 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
461456
sys->busnr = busnr;
462457
sys->swizzle = hw->swizzle;
463458
sys->map_irq = hw->map_irq;
464-
align_resource = hw->align_resource;
465459
INIT_LIST_HEAD(&sys->resources);
466460

467461
if (hw->private_data)
@@ -470,6 +464,8 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
470464
ret = hw->setup(nr, sys);
471465

472466
if (ret > 0) {
467+
struct pci_host_bridge *host_bridge;
468+
473469
ret = pcibios_init_resources(nr, sys);
474470
if (ret) {
475471
kfree(sys);
@@ -491,6 +487,9 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
491487
busnr = sys->bus->busn_res.end + 1;
492488

493489
list_add(&sys->node, head);
490+
491+
host_bridge = pci_find_host_bridge(sys->bus);
492+
host_bridge->align_resource = hw->align_resource;
494493
} else {
495494
kfree(sys);
496495
if (ret < 0)
@@ -578,14 +577,18 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
578577
{
579578
struct pci_dev *dev = data;
580579
resource_size_t start = res->start;
580+
struct pci_host_bridge *host_bridge;
581581

582582
if (res->flags & IORESOURCE_IO && start & 0x300)
583583
start = (start + 0x3ff) & ~0x3ff;
584584

585585
start = (start + align - 1) & ~(align - 1);
586586

587-
if (align_resource)
588-
return align_resource(dev, res, start, size, align);
587+
host_bridge = pci_find_host_bridge(dev->bus);
588+
589+
if (host_bridge->align_resource)
590+
return host_bridge->align_resource(dev, res,
591+
start, size, align);
589592

590593
return start;
591594
}

drivers/pci/host/pcie-designware.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
440440
ret, pp->io);
441441
continue;
442442
}
443-
pp->io_base = pp->io->start;
444443
break;
445444
case IORESOURCE_MEM:
446445
pp->mem = win->res;

drivers/pci/host/pcie-hisi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static struct pcie_host_ops hisi_pcie_host_ops = {
111111
.link_up = hisi_pcie_link_up,
112112
};
113113

114-
static int __init hisi_add_pcie_port(struct pcie_port *pp,
114+
static int hisi_add_pcie_port(struct pcie_port *pp,
115115
struct platform_device *pdev)
116116
{
117117
int ret;
@@ -139,7 +139,7 @@ static int __init hisi_add_pcie_port(struct pcie_port *pp,
139139
return 0;
140140
}
141141

142-
static int __init hisi_pcie_probe(struct platform_device *pdev)
142+
static int hisi_pcie_probe(struct platform_device *pdev)
143143
{
144144
struct hisi_pcie *hisi_pcie;
145145
struct pcie_port *pp;

drivers/pci/pci-sysfs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ static ssize_t numa_node_store(struct device *dev,
216216
if (ret)
217217
return ret;
218218

219-
if (node >= MAX_NUMNODES || !node_online(node))
219+
if ((node < 0 && node != NUMA_NO_NODE) || node >= MAX_NUMNODES)
220+
return -EINVAL;
221+
222+
if (node != NUMA_NO_NODE && !node_online(node))
220223
return -EINVAL;
221224

222225
add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);

drivers/pci/pci.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,4 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
337337
}
338338
#endif
339339

340-
struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
341-
342340
#endif /* DRIVERS_PCI_H */

include/linux/pci.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,18 @@ struct pci_host_bridge {
412412
void (*release_fn)(struct pci_host_bridge *);
413413
void *release_data;
414414
unsigned int ignore_reset_delay:1; /* for entire hierarchy */
415+
/* Resource alignment requirements */
416+
resource_size_t (*align_resource)(struct pci_dev *dev,
417+
const struct resource *res,
418+
resource_size_t start,
419+
resource_size_t size,
420+
resource_size_t align);
415421
};
416422

417423
#define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
424+
425+
struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
426+
418427
void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
419428
void (*release_fn)(struct pci_host_bridge *),
420429
void *release_data);

0 commit comments

Comments
 (0)