diff options
Diffstat (limited to 'drivers/pci')
162 files changed, 3920 insertions, 2591 deletions
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index bda151788f3f..34b56a8f8480 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI configuration | 3 | # PCI configuration |
3 | # | 4 | # |
@@ -125,6 +126,7 @@ config PCI_PASID | |||
125 | 126 | ||
126 | config PCI_LABEL | 127 | config PCI_LABEL |
127 | def_bool y if (DMI || ACPI) | 128 | def_bool y if (DMI || ACPI) |
129 | depends on PCI | ||
128 | select NLS | 130 | select NLS |
129 | 131 | ||
130 | config PCI_HYPERV | 132 | config PCI_HYPERV |
@@ -135,6 +137,7 @@ config PCI_HYPERV | |||
135 | PCI devices from a PCI backend to support PCI driver domains. | 137 | PCI devices from a PCI backend to support PCI driver domains. |
136 | 138 | ||
137 | source "drivers/pci/hotplug/Kconfig" | 139 | source "drivers/pci/hotplug/Kconfig" |
140 | source "drivers/pci/cadence/Kconfig" | ||
138 | source "drivers/pci/dwc/Kconfig" | 141 | source "drivers/pci/dwc/Kconfig" |
139 | source "drivers/pci/host/Kconfig" | 142 | source "drivers/pci/host/Kconfig" |
140 | source "drivers/pci/endpoint/Kconfig" | 143 | source "drivers/pci/endpoint/Kconfig" |
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index c7819b973df7..941970936840 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile | |||
@@ -3,12 +3,15 @@ | |||
3 | # Makefile for the PCI bus specific drivers. | 3 | # Makefile for the PCI bus specific drivers. |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y += access.o bus.o probe.o host-bridge.o remove.o pci.o \ | 6 | obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o remove.o pci.o \ |
7 | pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ | 7 | pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ |
8 | irq.o vpd.o setup-bus.o vc.o mmap.o setup-irq.o | 8 | irq.o vpd.o setup-bus.o vc.o mmap.o setup-irq.o |
9 | 9 | ||
10 | ifdef CONFIG_PCI | ||
10 | obj-$(CONFIG_PROC_FS) += proc.o | 11 | obj-$(CONFIG_PROC_FS) += proc.o |
11 | obj-$(CONFIG_SYSFS) += slot.o | 12 | obj-$(CONFIG_SYSFS) += slot.o |
13 | obj-$(CONFIG_OF) += of.o | ||
14 | endif | ||
12 | 15 | ||
13 | obj-$(CONFIG_PCI_QUIRKS) += quirks.o | 16 | obj-$(CONFIG_PCI_QUIRKS) += quirks.o |
14 | 17 | ||
@@ -44,10 +47,15 @@ obj-$(CONFIG_PCI_ECAM) += ecam.o | |||
44 | 47 | ||
45 | obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o | 48 | obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o |
46 | 49 | ||
47 | obj-$(CONFIG_OF) += of.o | ||
48 | |||
49 | ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG | 50 | ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG |
50 | 51 | ||
51 | # PCI host controller drivers | 52 | # PCI host controller drivers |
52 | obj-y += host/ | 53 | obj-y += host/ |
53 | obj-y += switch/ | 54 | obj-y += switch/ |
55 | |||
56 | obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ | ||
57 | |||
58 | # Endpoint library must be initialized before its users | ||
59 | obj-$(CONFIG_PCIE_CADENCE) += cadence/ | ||
60 | # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW | ||
61 | obj-y += dwc/ | ||
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 913d6722ece9..5e9a9822d9d4 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | #include <linux/delay.h> | 2 | #include <linux/delay.h> |
2 | #include <linux/pci.h> | 3 | #include <linux/pci.h> |
3 | #include <linux/module.h> | 4 | #include <linux/module.h> |
@@ -333,8 +334,7 @@ static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size) | |||
333 | (tag == PCI_VPD_LTIN_RW_DATA)) { | 334 | (tag == PCI_VPD_LTIN_RW_DATA)) { |
334 | if (pci_read_vpd(dev, off+1, 2, | 335 | if (pci_read_vpd(dev, off+1, 2, |
335 | &header[1]) != 2) { | 336 | &header[1]) != 2) { |
336 | dev_warn(&dev->dev, | 337 | pci_warn(dev, "invalid large VPD tag %02x size at offset %zu", |
337 | "invalid large VPD tag %02x size at offset %zu", | ||
338 | tag, off + 1); | 338 | tag, off + 1); |
339 | return 0; | 339 | return 0; |
340 | } | 340 | } |
@@ -354,8 +354,7 @@ static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size) | |||
354 | if ((tag != PCI_VPD_LTIN_ID_STRING) && | 354 | if ((tag != PCI_VPD_LTIN_ID_STRING) && |
355 | (tag != PCI_VPD_LTIN_RO_DATA) && | 355 | (tag != PCI_VPD_LTIN_RO_DATA) && |
356 | (tag != PCI_VPD_LTIN_RW_DATA)) { | 356 | (tag != PCI_VPD_LTIN_RW_DATA)) { |
357 | dev_warn(&dev->dev, | 357 | pci_warn(dev, "invalid %s VPD tag %02x at offset %zu", |
358 | "invalid %s VPD tag %02x at offset %zu", | ||
359 | (header[0] & PCI_VPD_LRDT) ? "large" : "short", | 358 | (header[0] & PCI_VPD_LRDT) ? "large" : "short", |
360 | tag, off); | 359 | tag, off); |
361 | return 0; | 360 | return 0; |
@@ -402,7 +401,7 @@ static int pci_vpd_wait(struct pci_dev *dev) | |||
402 | max_sleep *= 2; | 401 | max_sleep *= 2; |
403 | } | 402 | } |
404 | 403 | ||
405 | dev_warn(&dev->dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n"); | 404 | pci_warn(dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n"); |
406 | return -ETIMEDOUT; | 405 | return -ETIMEDOUT; |
407 | } | 406 | } |
408 | 407 | ||
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index ad8ddbbbf245..6ad80a1fd5a7 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/ats.c | 3 | * drivers/pci/ats.c |
3 | * | 4 | * |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index bc56cf19afd3..737d1c52f002 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/bus.c | 3 | * drivers/pci/bus.c |
3 | * | 4 | * |
@@ -289,7 +290,7 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx) | |||
289 | res->end = end; | 290 | res->end = end; |
290 | res->flags &= ~IORESOURCE_UNSET; | 291 | res->flags &= ~IORESOURCE_UNSET; |
291 | orig_res.flags &= ~IORESOURCE_UNSET; | 292 | orig_res.flags &= ~IORESOURCE_UNSET; |
292 | dev_printk(KERN_DEBUG, &dev->dev, "%pR clipped to %pR\n", | 293 | pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n", |
293 | &orig_res, res); | 294 | &orig_res, res); |
294 | 295 | ||
295 | return true; | 296 | return true; |
@@ -325,7 +326,7 @@ void pci_bus_add_device(struct pci_dev *dev) | |||
325 | dev->match_driver = true; | 326 | dev->match_driver = true; |
326 | retval = device_attach(&dev->dev); | 327 | retval = device_attach(&dev->dev); |
327 | if (retval < 0 && retval != -EPROBE_DEFER) { | 328 | if (retval < 0 && retval != -EPROBE_DEFER) { |
328 | dev_warn(&dev->dev, "device attach failed (%d)\n", retval); | 329 | pci_warn(dev, "device attach failed (%d)\n", retval); |
329 | pci_proc_detach_device(dev); | 330 | pci_proc_detach_device(dev); |
330 | pci_remove_sysfs_dev_files(dev); | 331 | pci_remove_sysfs_dev_files(dev); |
331 | return; | 332 | return; |
diff --git a/drivers/pci/cadence/Kconfig b/drivers/pci/cadence/Kconfig new file mode 100644 index 000000000000..e6824cb56c16 --- /dev/null +++ b/drivers/pci/cadence/Kconfig | |||
@@ -0,0 +1,27 @@ | |||
1 | menu "Cadence PCIe controllers support" | ||
2 | |||
3 | config PCIE_CADENCE | ||
4 | bool | ||
5 | |||
6 | config PCIE_CADENCE_HOST | ||
7 | bool "Cadence PCIe host controller" | ||
8 | depends on OF | ||
9 | depends on PCI | ||
10 | select IRQ_DOMAIN | ||
11 | select PCIE_CADENCE | ||
12 | help | ||
13 | Say Y here if you want to support the Cadence PCIe controller in host | ||
14 | mode. This PCIe controller may be embedded into many different vendors | ||
15 | SoCs. | ||
16 | |||
17 | config PCIE_CADENCE_EP | ||
18 | bool "Cadence PCIe endpoint controller" | ||
19 | depends on OF | ||
20 | depends on PCI_ENDPOINT | ||
21 | select PCIE_CADENCE | ||
22 | help | ||
23 | Say Y here if you want to support the Cadence PCIe controller in | ||
24 | endpoint mode. This PCIe controller may be embedded into many | ||
25 | different vendors SoCs. | ||
26 | |||
27 | endmenu | ||
diff --git a/drivers/pci/cadence/Makefile b/drivers/pci/cadence/Makefile new file mode 100644 index 000000000000..719392b97998 --- /dev/null +++ b/drivers/pci/cadence/Makefile | |||
@@ -0,0 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
2 | obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o | ||
3 | obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o | ||
4 | obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o | ||
diff --git a/drivers/pci/cadence/pcie-cadence-ep.c b/drivers/pci/cadence/pcie-cadence-ep.c new file mode 100644 index 000000000000..3c3a97743453 --- /dev/null +++ b/drivers/pci/cadence/pcie-cadence-ep.c | |||
@@ -0,0 +1,542 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | // Copyright (c) 2017 Cadence | ||
3 | // Cadence PCIe endpoint controller driver. | ||
4 | // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com> | ||
5 | |||
6 | #include <linux/delay.h> | ||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/of.h> | ||
9 | #include <linux/pci-epc.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/pm_runtime.h> | ||
12 | #include <linux/sizes.h> | ||
13 | |||
14 | #include "pcie-cadence.h" | ||
15 | |||
16 | #define CDNS_PCIE_EP_MIN_APERTURE 128 /* 128 bytes */ | ||
17 | #define CDNS_PCIE_EP_IRQ_PCI_ADDR_NONE 0x1 | ||
18 | #define CDNS_PCIE_EP_IRQ_PCI_ADDR_LEGACY 0x3 | ||
19 | |||
20 | /** | ||
21 | * struct cdns_pcie_ep - private data for this PCIe endpoint controller driver | ||
22 | * @pcie: Cadence PCIe controller | ||
23 | * @max_regions: maximum number of regions supported by hardware | ||
24 | * @ob_region_map: bitmask of mapped outbound regions | ||
25 | * @ob_addr: base addresses in the AXI bus where the outbound regions start | ||
26 | * @irq_phys_addr: base address on the AXI bus where the MSI/legacy IRQ | ||
27 | * dedicated outbound regions is mapped. | ||
28 | * @irq_cpu_addr: base address in the CPU space where a write access triggers | ||
29 | * the sending of a memory write (MSI) / normal message (legacy | ||
30 | * IRQ) TLP through the PCIe bus. | ||
31 | * @irq_pci_addr: used to save the current mapping of the MSI/legacy IRQ | ||
32 | * dedicated outbound region. | ||
33 | * @irq_pci_fn: the latest PCI function that has updated the mapping of | ||
34 | * the MSI/legacy IRQ dedicated outbound region. | ||
35 | * @irq_pending: bitmask of asserted legacy IRQs. | ||
36 | */ | ||
37 | struct cdns_pcie_ep { | ||
38 | struct cdns_pcie pcie; | ||
39 | u32 max_regions; | ||
40 | unsigned long ob_region_map; | ||
41 | phys_addr_t *ob_addr; | ||
42 | phys_addr_t irq_phys_addr; | ||
43 | void __iomem *irq_cpu_addr; | ||
44 | u64 irq_pci_addr; | ||
45 | u8 irq_pci_fn; | ||
46 | u8 irq_pending; | ||
47 | }; | ||
48 | |||
49 | static int cdns_pcie_ep_write_header(struct pci_epc *epc, u8 fn, | ||
50 | struct pci_epf_header *hdr) | ||
51 | { | ||
52 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
53 | struct cdns_pcie *pcie = &ep->pcie; | ||
54 | |||
55 | cdns_pcie_ep_fn_writew(pcie, fn, PCI_DEVICE_ID, hdr->deviceid); | ||
56 | cdns_pcie_ep_fn_writeb(pcie, fn, PCI_REVISION_ID, hdr->revid); | ||
57 | cdns_pcie_ep_fn_writeb(pcie, fn, PCI_CLASS_PROG, hdr->progif_code); | ||
58 | cdns_pcie_ep_fn_writew(pcie, fn, PCI_CLASS_DEVICE, | ||
59 | hdr->subclass_code | hdr->baseclass_code << 8); | ||
60 | cdns_pcie_ep_fn_writeb(pcie, fn, PCI_CACHE_LINE_SIZE, | ||
61 | hdr->cache_line_size); | ||
62 | cdns_pcie_ep_fn_writew(pcie, fn, PCI_SUBSYSTEM_ID, hdr->subsys_id); | ||
63 | cdns_pcie_ep_fn_writeb(pcie, fn, PCI_INTERRUPT_PIN, hdr->interrupt_pin); | ||
64 | |||
65 | /* | ||
66 | * Vendor ID can only be modified from function 0, all other functions | ||
67 | * use the same vendor ID as function 0. | ||
68 | */ | ||
69 | if (fn == 0) { | ||
70 | /* Update the vendor IDs. */ | ||
71 | u32 id = CDNS_PCIE_LM_ID_VENDOR(hdr->vendorid) | | ||
72 | CDNS_PCIE_LM_ID_SUBSYS(hdr->subsys_vendor_id); | ||
73 | |||
74 | cdns_pcie_writel(pcie, CDNS_PCIE_LM_ID, id); | ||
75 | } | ||
76 | |||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn, enum pci_barno bar, | ||
81 | dma_addr_t bar_phys, size_t size, int flags) | ||
82 | { | ||
83 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
84 | struct cdns_pcie *pcie = &ep->pcie; | ||
85 | u32 addr0, addr1, reg, cfg, b, aperture, ctrl; | ||
86 | u64 sz; | ||
87 | |||
88 | /* BAR size is 2^(aperture + 7) */ | ||
89 | sz = max_t(size_t, size, CDNS_PCIE_EP_MIN_APERTURE); | ||
90 | /* | ||
91 | * roundup_pow_of_two() returns an unsigned long, which is not suited | ||
92 | * for 64bit values. | ||
93 | */ | ||
94 | sz = 1ULL << fls64(sz - 1); | ||
95 | aperture = ilog2(sz) - 7; /* 128B -> 0, 256B -> 1, 512B -> 2, ... */ | ||
96 | |||
97 | if ((flags & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) { | ||
98 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS; | ||
99 | } else { | ||
100 | bool is_prefetch = !!(flags & PCI_BASE_ADDRESS_MEM_PREFETCH); | ||
101 | bool is_64bits = sz > SZ_2G; | ||
102 | |||
103 | if (is_64bits && (bar & 1)) | ||
104 | return -EINVAL; | ||
105 | |||
106 | if (is_64bits && is_prefetch) | ||
107 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS; | ||
108 | else if (is_prefetch) | ||
109 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS; | ||
110 | else if (is_64bits) | ||
111 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS; | ||
112 | else | ||
113 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS; | ||
114 | } | ||
115 | |||
116 | addr0 = lower_32_bits(bar_phys); | ||
117 | addr1 = upper_32_bits(bar_phys); | ||
118 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR0(fn, bar), | ||
119 | addr0); | ||
120 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR1(fn, bar), | ||
121 | addr1); | ||
122 | |||
123 | if (bar < BAR_4) { | ||
124 | reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn); | ||
125 | b = bar; | ||
126 | } else { | ||
127 | reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn); | ||
128 | b = bar - BAR_4; | ||
129 | } | ||
130 | |||
131 | cfg = cdns_pcie_readl(pcie, reg); | ||
132 | cfg &= ~(CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b) | | ||
133 | CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b)); | ||
134 | cfg |= (CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE(b, aperture) | | ||
135 | CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL(b, ctrl)); | ||
136 | cdns_pcie_writel(pcie, reg, cfg); | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static void cdns_pcie_ep_clear_bar(struct pci_epc *epc, u8 fn, | ||
142 | enum pci_barno bar) | ||
143 | { | ||
144 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
145 | struct cdns_pcie *pcie = &ep->pcie; | ||
146 | u32 reg, cfg, b, ctrl; | ||
147 | |||
148 | if (bar < BAR_4) { | ||
149 | reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn); | ||
150 | b = bar; | ||
151 | } else { | ||
152 | reg = CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn); | ||
153 | b = bar - BAR_4; | ||
154 | } | ||
155 | |||
156 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED; | ||
157 | cfg = cdns_pcie_readl(pcie, reg); | ||
158 | cfg &= ~(CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b) | | ||
159 | CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b)); | ||
160 | cfg |= CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL(b, ctrl); | ||
161 | cdns_pcie_writel(pcie, reg, cfg); | ||
162 | |||
163 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR0(fn, bar), 0); | ||
164 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR1(fn, bar), 0); | ||
165 | } | ||
166 | |||
167 | static int cdns_pcie_ep_map_addr(struct pci_epc *epc, u8 fn, phys_addr_t addr, | ||
168 | u64 pci_addr, size_t size) | ||
169 | { | ||
170 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
171 | struct cdns_pcie *pcie = &ep->pcie; | ||
172 | u32 r; | ||
173 | |||
174 | r = find_first_zero_bit(&ep->ob_region_map, | ||
175 | sizeof(ep->ob_region_map) * BITS_PER_LONG); | ||
176 | if (r >= ep->max_regions - 1) { | ||
177 | dev_err(&epc->dev, "no free outbound region\n"); | ||
178 | return -EINVAL; | ||
179 | } | ||
180 | |||
181 | cdns_pcie_set_outbound_region(pcie, fn, r, false, addr, pci_addr, size); | ||
182 | |||
183 | set_bit(r, &ep->ob_region_map); | ||
184 | ep->ob_addr[r] = addr; | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | static void cdns_pcie_ep_unmap_addr(struct pci_epc *epc, u8 fn, | ||
190 | phys_addr_t addr) | ||
191 | { | ||
192 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
193 | struct cdns_pcie *pcie = &ep->pcie; | ||
194 | u32 r; | ||
195 | |||
196 | for (r = 0; r < ep->max_regions - 1; r++) | ||
197 | if (ep->ob_addr[r] == addr) | ||
198 | break; | ||
199 | |||
200 | if (r == ep->max_regions - 1) | ||
201 | return; | ||
202 | |||
203 | cdns_pcie_reset_outbound_region(pcie, r); | ||
204 | |||
205 | ep->ob_addr[r] = 0; | ||
206 | clear_bit(r, &ep->ob_region_map); | ||
207 | } | ||
208 | |||
209 | static int cdns_pcie_ep_set_msi(struct pci_epc *epc, u8 fn, u8 mmc) | ||
210 | { | ||
211 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
212 | struct cdns_pcie *pcie = &ep->pcie; | ||
213 | u32 cap = CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET; | ||
214 | u16 flags; | ||
215 | |||
216 | /* | ||
217 | * Set the Multiple Message Capable bitfield into the Message Control | ||
218 | * register. | ||
219 | */ | ||
220 | flags = cdns_pcie_ep_fn_readw(pcie, fn, cap + PCI_MSI_FLAGS); | ||
221 | flags = (flags & ~PCI_MSI_FLAGS_QMASK) | (mmc << 1); | ||
222 | flags |= PCI_MSI_FLAGS_64BIT; | ||
223 | flags &= ~PCI_MSI_FLAGS_MASKBIT; | ||
224 | cdns_pcie_ep_fn_writew(pcie, fn, cap + PCI_MSI_FLAGS, flags); | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static int cdns_pcie_ep_get_msi(struct pci_epc *epc, u8 fn) | ||
230 | { | ||
231 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
232 | struct cdns_pcie *pcie = &ep->pcie; | ||
233 | u32 cap = CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET; | ||
234 | u16 flags, mmc, mme; | ||
235 | |||
236 | /* Validate that the MSI feature is actually enabled. */ | ||
237 | flags = cdns_pcie_ep_fn_readw(pcie, fn, cap + PCI_MSI_FLAGS); | ||
238 | if (!(flags & PCI_MSI_FLAGS_ENABLE)) | ||
239 | return -EINVAL; | ||
240 | |||
241 | /* | ||
242 | * Get the Multiple Message Enable bitfield from the Message Control | ||
243 | * register. | ||
244 | */ | ||
245 | mmc = (flags & PCI_MSI_FLAGS_QMASK) >> 1; | ||
246 | mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4; | ||
247 | |||
248 | return mme; | ||
249 | } | ||
250 | |||
251 | static void cdns_pcie_ep_assert_intx(struct cdns_pcie_ep *ep, u8 fn, | ||
252 | u8 intx, bool is_asserted) | ||
253 | { | ||
254 | struct cdns_pcie *pcie = &ep->pcie; | ||
255 | u32 r = ep->max_regions - 1; | ||
256 | u32 offset; | ||
257 | u16 status; | ||
258 | u8 msg_code; | ||
259 | |||
260 | intx &= 3; | ||
261 | |||
262 | /* Set the outbound region if needed. */ | ||
263 | if (unlikely(ep->irq_pci_addr != CDNS_PCIE_EP_IRQ_PCI_ADDR_LEGACY || | ||
264 | ep->irq_pci_fn != fn)) { | ||
265 | /* Last region was reserved for IRQ writes. */ | ||
266 | cdns_pcie_set_outbound_region_for_normal_msg(pcie, fn, r, | ||
267 | ep->irq_phys_addr); | ||
268 | ep->irq_pci_addr = CDNS_PCIE_EP_IRQ_PCI_ADDR_LEGACY; | ||
269 | ep->irq_pci_fn = fn; | ||
270 | } | ||
271 | |||
272 | if (is_asserted) { | ||
273 | ep->irq_pending |= BIT(intx); | ||
274 | msg_code = MSG_CODE_ASSERT_INTA + intx; | ||
275 | } else { | ||
276 | ep->irq_pending &= ~BIT(intx); | ||
277 | msg_code = MSG_CODE_DEASSERT_INTA + intx; | ||
278 | } | ||
279 | |||
280 | status = cdns_pcie_ep_fn_readw(pcie, fn, PCI_STATUS); | ||
281 | if (((status & PCI_STATUS_INTERRUPT) != 0) ^ (ep->irq_pending != 0)) { | ||
282 | status ^= PCI_STATUS_INTERRUPT; | ||
283 | cdns_pcie_ep_fn_writew(pcie, fn, PCI_STATUS, status); | ||
284 | } | ||
285 | |||
286 | offset = CDNS_PCIE_NORMAL_MSG_ROUTING(MSG_ROUTING_LOCAL) | | ||
287 | CDNS_PCIE_NORMAL_MSG_CODE(msg_code) | | ||
288 | CDNS_PCIE_MSG_NO_DATA; | ||
289 | writel(0, ep->irq_cpu_addr + offset); | ||
290 | } | ||
291 | |||
292 | static int cdns_pcie_ep_send_legacy_irq(struct cdns_pcie_ep *ep, u8 fn, u8 intx) | ||
293 | { | ||
294 | u16 cmd; | ||
295 | |||
296 | cmd = cdns_pcie_ep_fn_readw(&ep->pcie, fn, PCI_COMMAND); | ||
297 | if (cmd & PCI_COMMAND_INTX_DISABLE) | ||
298 | return -EINVAL; | ||
299 | |||
300 | cdns_pcie_ep_assert_intx(ep, fn, intx, true); | ||
301 | /* | ||
302 | * The mdelay() value was taken from dra7xx_pcie_raise_legacy_irq() | ||
303 | * from drivers/pci/dwc/pci-dra7xx.c | ||
304 | */ | ||
305 | mdelay(1); | ||
306 | cdns_pcie_ep_assert_intx(ep, fn, intx, false); | ||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn, | ||
311 | u8 interrupt_num) | ||
312 | { | ||
313 | struct cdns_pcie *pcie = &ep->pcie; | ||
314 | u32 cap = CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET; | ||
315 | u16 flags, mme, data, data_mask; | ||
316 | u8 msi_count; | ||
317 | u64 pci_addr, pci_addr_mask = 0xff; | ||
318 | |||
319 | /* Check whether the MSI feature has been enabled by the PCI host. */ | ||
320 | flags = cdns_pcie_ep_fn_readw(pcie, fn, cap + PCI_MSI_FLAGS); | ||
321 | if (!(flags & PCI_MSI_FLAGS_ENABLE)) | ||
322 | return -EINVAL; | ||
323 | |||
324 | /* Get the number of enabled MSIs */ | ||
325 | mme = (flags & PCI_MSI_FLAGS_QSIZE) >> 4; | ||
326 | msi_count = 1 << mme; | ||
327 | if (!interrupt_num || interrupt_num > msi_count) | ||
328 | return -EINVAL; | ||
329 | |||
330 | /* Compute the data value to be written. */ | ||
331 | data_mask = msi_count - 1; | ||
332 | data = cdns_pcie_ep_fn_readw(pcie, fn, cap + PCI_MSI_DATA_64); | ||
333 | data = (data & ~data_mask) | ((interrupt_num - 1) & data_mask); | ||
334 | |||
335 | /* Get the PCI address where to write the data into. */ | ||
336 | pci_addr = cdns_pcie_ep_fn_readl(pcie, fn, cap + PCI_MSI_ADDRESS_HI); | ||
337 | pci_addr <<= 32; | ||
338 | pci_addr |= cdns_pcie_ep_fn_readl(pcie, fn, cap + PCI_MSI_ADDRESS_LO); | ||
339 | pci_addr &= GENMASK_ULL(63, 2); | ||
340 | |||
341 | /* Set the outbound region if needed. */ | ||
342 | if (unlikely(ep->irq_pci_addr != (pci_addr & ~pci_addr_mask) || | ||
343 | ep->irq_pci_fn != fn)) { | ||
344 | /* Last region was reserved for IRQ writes. */ | ||
345 | cdns_pcie_set_outbound_region(pcie, fn, ep->max_regions - 1, | ||
346 | false, | ||
347 | ep->irq_phys_addr, | ||
348 | pci_addr & ~pci_addr_mask, | ||
349 | pci_addr_mask + 1); | ||
350 | ep->irq_pci_addr = (pci_addr & ~pci_addr_mask); | ||
351 | ep->irq_pci_fn = fn; | ||
352 | } | ||
353 | writew(data, ep->irq_cpu_addr + (pci_addr & pci_addr_mask)); | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static int cdns_pcie_ep_raise_irq(struct pci_epc *epc, u8 fn, | ||
359 | enum pci_epc_irq_type type, u8 interrupt_num) | ||
360 | { | ||
361 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
362 | |||
363 | switch (type) { | ||
364 | case PCI_EPC_IRQ_LEGACY: | ||
365 | return cdns_pcie_ep_send_legacy_irq(ep, fn, 0); | ||
366 | |||
367 | case PCI_EPC_IRQ_MSI: | ||
368 | return cdns_pcie_ep_send_msi_irq(ep, fn, interrupt_num); | ||
369 | |||
370 | default: | ||
371 | break; | ||
372 | } | ||
373 | |||
374 | return -EINVAL; | ||
375 | } | ||
376 | |||
377 | static int cdns_pcie_ep_start(struct pci_epc *epc) | ||
378 | { | ||
379 | struct cdns_pcie_ep *ep = epc_get_drvdata(epc); | ||
380 | struct cdns_pcie *pcie = &ep->pcie; | ||
381 | struct pci_epf *epf; | ||
382 | u32 cfg; | ||
383 | |||
384 | /* | ||
385 | * BIT(0) is hardwired to 1, hence function 0 is always enabled | ||
386 | * and can't be disabled anyway. | ||
387 | */ | ||
388 | cfg = BIT(0); | ||
389 | list_for_each_entry(epf, &epc->pci_epf, list) | ||
390 | cfg |= BIT(epf->func_no); | ||
391 | cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, cfg); | ||
392 | |||
393 | /* | ||
394 | * The PCIe links are automatically established by the controller | ||
395 | * once for all at powerup: the software can neither start nor stop | ||
396 | * those links later at runtime. | ||
397 | * | ||
398 | * Then we only have to notify the EP core that our links are already | ||
399 | * established. However we don't call directly pci_epc_linkup() because | ||
400 | * we've already locked the epc->lock. | ||
401 | */ | ||
402 | list_for_each_entry(epf, &epc->pci_epf, list) | ||
403 | pci_epf_linkup(epf); | ||
404 | |||
405 | return 0; | ||
406 | } | ||
407 | |||
408 | static const struct pci_epc_ops cdns_pcie_epc_ops = { | ||
409 | .write_header = cdns_pcie_ep_write_header, | ||
410 | .set_bar = cdns_pcie_ep_set_bar, | ||
411 | .clear_bar = cdns_pcie_ep_clear_bar, | ||
412 | .map_addr = cdns_pcie_ep_map_addr, | ||
413 | .unmap_addr = cdns_pcie_ep_unmap_addr, | ||
414 | .set_msi = cdns_pcie_ep_set_msi, | ||
415 | .get_msi = cdns_pcie_ep_get_msi, | ||
416 | .raise_irq = cdns_pcie_ep_raise_irq, | ||
417 | .start = cdns_pcie_ep_start, | ||
418 | }; | ||
419 | |||
420 | static const struct of_device_id cdns_pcie_ep_of_match[] = { | ||
421 | { .compatible = "cdns,cdns-pcie-ep" }, | ||
422 | |||
423 | { }, | ||
424 | }; | ||
425 | |||
426 | static int cdns_pcie_ep_probe(struct platform_device *pdev) | ||
427 | { | ||
428 | struct device *dev = &pdev->dev; | ||
429 | struct device_node *np = dev->of_node; | ||
430 | struct cdns_pcie_ep *ep; | ||
431 | struct cdns_pcie *pcie; | ||
432 | struct pci_epc *epc; | ||
433 | struct resource *res; | ||
434 | int ret; | ||
435 | |||
436 | ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL); | ||
437 | if (!ep) | ||
438 | return -ENOMEM; | ||
439 | |||
440 | pcie = &ep->pcie; | ||
441 | pcie->is_rc = false; | ||
442 | |||
443 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg"); | ||
444 | pcie->reg_base = devm_ioremap_resource(dev, res); | ||
445 | if (IS_ERR(pcie->reg_base)) { | ||
446 | dev_err(dev, "missing \"reg\"\n"); | ||
447 | return PTR_ERR(pcie->reg_base); | ||
448 | } | ||
449 | |||
450 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem"); | ||
451 | if (!res) { | ||
452 | dev_err(dev, "missing \"mem\"\n"); | ||
453 | return -EINVAL; | ||
454 | } | ||
455 | pcie->mem_res = res; | ||
456 | |||
457 | ret = of_property_read_u32(np, "cdns,max-outbound-regions", | ||
458 | &ep->max_regions); | ||
459 | if (ret < 0) { | ||
460 | dev_err(dev, "missing \"cdns,max-outbound-regions\"\n"); | ||
461 | return ret; | ||
462 | } | ||
463 | ep->ob_addr = devm_kzalloc(dev, ep->max_regions * sizeof(*ep->ob_addr), | ||
464 | GFP_KERNEL); | ||
465 | if (!ep->ob_addr) | ||
466 | return -ENOMEM; | ||
467 | |||
468 | pm_runtime_enable(dev); | ||
469 | ret = pm_runtime_get_sync(dev); | ||
470 | if (ret < 0) { | ||
471 | dev_err(dev, "pm_runtime_get_sync() failed\n"); | ||
472 | goto err_get_sync; | ||
473 | } | ||
474 | |||
475 | /* Disable all but function 0 (anyway BIT(0) is hardwired to 1). */ | ||
476 | cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, BIT(0)); | ||
477 | |||
478 | epc = devm_pci_epc_create(dev, &cdns_pcie_epc_ops); | ||
479 | if (IS_ERR(epc)) { | ||
480 | dev_err(dev, "failed to create epc device\n"); | ||
481 | ret = PTR_ERR(epc); | ||
482 | goto err_init; | ||
483 | } | ||
484 | |||
485 | epc_set_drvdata(epc, ep); | ||
486 | |||
487 | if (of_property_read_u8(np, "max-functions", &epc->max_functions) < 0) | ||
488 | epc->max_functions = 1; | ||
489 | |||
490 | ret = pci_epc_mem_init(epc, pcie->mem_res->start, | ||
491 | resource_size(pcie->mem_res)); | ||
492 | if (ret < 0) { | ||
493 | dev_err(dev, "failed to initialize the memory space\n"); | ||
494 | goto err_init; | ||
495 | } | ||
496 | |||
497 | ep->irq_cpu_addr = pci_epc_mem_alloc_addr(epc, &ep->irq_phys_addr, | ||
498 | SZ_128K); | ||
499 | if (!ep->irq_cpu_addr) { | ||
500 | dev_err(dev, "failed to reserve memory space for MSI\n"); | ||
501 | ret = -ENOMEM; | ||
502 | goto free_epc_mem; | ||
503 | } | ||
504 | ep->irq_pci_addr = CDNS_PCIE_EP_IRQ_PCI_ADDR_NONE; | ||
505 | |||
506 | return 0; | ||
507 | |||
508 | free_epc_mem: | ||
509 | pci_epc_mem_exit(epc); | ||
510 | |||
511 | err_init: | ||
512 | pm_runtime_put_sync(dev); | ||
513 | |||
514 | err_get_sync: | ||
515 | pm_runtime_disable(dev); | ||
516 | |||
517 | return ret; | ||
518 | } | ||
519 | |||
520 | static void cdns_pcie_ep_shutdown(struct platform_device *pdev) | ||
521 | { | ||
522 | struct device *dev = &pdev->dev; | ||
523 | int ret; | ||
524 | |||
525 | ret = pm_runtime_put_sync(dev); | ||
526 | if (ret < 0) | ||
527 | dev_dbg(dev, "pm_runtime_put_sync failed\n"); | ||
528 | |||
529 | pm_runtime_disable(dev); | ||
530 | |||
531 | /* The PCIe controller can't be disabled. */ | ||
532 | } | ||
533 | |||
534 | static struct platform_driver cdns_pcie_ep_driver = { | ||
535 | .driver = { | ||
536 | .name = "cdns-pcie-ep", | ||
537 | .of_match_table = cdns_pcie_ep_of_match, | ||
538 | }, | ||
539 | .probe = cdns_pcie_ep_probe, | ||
540 | .shutdown = cdns_pcie_ep_shutdown, | ||
541 | }; | ||
542 | builtin_platform_driver(cdns_pcie_ep_driver); | ||
diff --git a/drivers/pci/cadence/pcie-cadence-host.c b/drivers/pci/cadence/pcie-cadence-host.c new file mode 100644 index 000000000000..a4ebbd37b553 --- /dev/null +++ b/drivers/pci/cadence/pcie-cadence-host.c | |||
@@ -0,0 +1,336 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | // Copyright (c) 2017 Cadence | ||
3 | // Cadence PCIe host controller driver. | ||
4 | // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com> | ||
5 | |||
6 | #include <linux/kernel.h> | ||
7 | #include <linux/of_address.h> | ||
8 | #include <linux/of_pci.h> | ||
9 | #include <linux/platform_device.h> | ||
10 | #include <linux/pm_runtime.h> | ||
11 | |||
12 | #include "pcie-cadence.h" | ||
13 | |||
14 | /** | ||
15 | * struct cdns_pcie_rc - private data for this PCIe Root Complex driver | ||
16 | * @pcie: Cadence PCIe controller | ||
17 | * @dev: pointer to PCIe device | ||
18 | * @cfg_res: start/end offsets in the physical system memory to map PCI | ||
19 | * configuration space accesses | ||
20 | * @bus_range: first/last buses behind the PCIe host controller | ||
21 | * @cfg_base: IO mapped window to access the PCI configuration space of a | ||
22 | * single function at a time | ||
23 | * @max_regions: maximum number of regions supported by the hardware | ||
24 | * @no_bar_nbits: Number of bits to keep for inbound (PCIe -> CPU) address | ||
25 | * translation (nbits sets into the "no BAR match" register) | ||
26 | * @vendor_id: PCI vendor ID | ||
27 | * @device_id: PCI device ID | ||
28 | */ | ||
29 | struct cdns_pcie_rc { | ||
30 | struct cdns_pcie pcie; | ||
31 | struct device *dev; | ||
32 | struct resource *cfg_res; | ||
33 | struct resource *bus_range; | ||
34 | void __iomem *cfg_base; | ||
35 | u32 max_regions; | ||
36 | u32 no_bar_nbits; | ||
37 | u16 vendor_id; | ||
38 | u16 device_id; | ||
39 | }; | ||
40 | |||
41 | static void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn, | ||
42 | int where) | ||
43 | { | ||
44 | struct pci_host_bridge *bridge = pci_find_host_bridge(bus); | ||
45 | struct cdns_pcie_rc *rc = pci_host_bridge_priv(bridge); | ||
46 | struct cdns_pcie *pcie = &rc->pcie; | ||
47 | unsigned int busn = bus->number; | ||
48 | u32 addr0, desc0; | ||
49 | |||
50 | if (busn == rc->bus_range->start) { | ||
51 | /* | ||
52 | * Only the root port (devfn == 0) is connected to this bus. | ||
53 | * All other PCI devices are behind some bridge hence on another | ||
54 | * bus. | ||
55 | */ | ||
56 | if (devfn) | ||
57 | return NULL; | ||
58 | |||
59 | return pcie->reg_base + (where & 0xfff); | ||
60 | } | ||
61 | |||
62 | /* Update Output registers for AXI region 0. */ | ||
63 | addr0 = CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS(12) | | ||
64 | CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN(devfn) | | ||
65 | CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS(busn); | ||
66 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(0), addr0); | ||
67 | |||
68 | /* Configuration Type 0 or Type 1 access. */ | ||
69 | desc0 = CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID | | ||
70 | CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(0); | ||
71 | /* | ||
72 | * The bus number was already set once for all in desc1 by | ||
73 | * cdns_pcie_host_init_address_translation(). | ||
74 | */ | ||
75 | if (busn == rc->bus_range->start + 1) | ||
76 | desc0 |= CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0; | ||
77 | else | ||
78 | desc0 |= CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1; | ||
79 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(0), desc0); | ||
80 | |||
81 | return rc->cfg_base + (where & 0xfff); | ||
82 | } | ||
83 | |||
84 | static struct pci_ops cdns_pcie_host_ops = { | ||
85 | .map_bus = cdns_pci_map_bus, | ||
86 | .read = pci_generic_config_read, | ||
87 | .write = pci_generic_config_write, | ||
88 | }; | ||
89 | |||
90 | static const struct of_device_id cdns_pcie_host_of_match[] = { | ||
91 | { .compatible = "cdns,cdns-pcie-host" }, | ||
92 | |||
93 | { }, | ||
94 | }; | ||
95 | |||
96 | static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc) | ||
97 | { | ||
98 | struct cdns_pcie *pcie = &rc->pcie; | ||
99 | u32 value, ctrl; | ||
100 | |||
101 | /* | ||
102 | * Set the root complex BAR configuration register: | ||
103 | * - disable both BAR0 and BAR1. | ||
104 | * - enable Prefetchable Memory Base and Limit registers in type 1 | ||
105 | * config space (64 bits). | ||
106 | * - enable IO Base and Limit registers in type 1 config | ||
107 | * space (32 bits). | ||
108 | */ | ||
109 | ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED; | ||
110 | value = CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL(ctrl) | | ||
111 | CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL(ctrl) | | ||
112 | CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE | | ||
113 | CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS | | ||
114 | CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE | | ||
115 | CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS; | ||
116 | cdns_pcie_writel(pcie, CDNS_PCIE_LM_RC_BAR_CFG, value); | ||
117 | |||
118 | /* Set root port configuration space */ | ||
119 | if (rc->vendor_id != 0xffff) | ||
120 | cdns_pcie_rp_writew(pcie, PCI_VENDOR_ID, rc->vendor_id); | ||
121 | if (rc->device_id != 0xffff) | ||
122 | cdns_pcie_rp_writew(pcie, PCI_DEVICE_ID, rc->device_id); | ||
123 | |||
124 | cdns_pcie_rp_writeb(pcie, PCI_CLASS_REVISION, 0); | ||
125 | cdns_pcie_rp_writeb(pcie, PCI_CLASS_PROG, 0); | ||
126 | cdns_pcie_rp_writew(pcie, PCI_CLASS_DEVICE, PCI_CLASS_BRIDGE_PCI); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc) | ||
132 | { | ||
133 | struct cdns_pcie *pcie = &rc->pcie; | ||
134 | struct resource *cfg_res = rc->cfg_res; | ||
135 | struct resource *mem_res = pcie->mem_res; | ||
136 | struct resource *bus_range = rc->bus_range; | ||
137 | struct device *dev = rc->dev; | ||
138 | struct device_node *np = dev->of_node; | ||
139 | struct of_pci_range_parser parser; | ||
140 | struct of_pci_range range; | ||
141 | u32 addr0, addr1, desc1; | ||
142 | u64 cpu_addr; | ||
143 | int r, err; | ||
144 | |||
145 | /* | ||
146 | * Reserve region 0 for PCI configure space accesses: | ||
147 | * OB_REGION_PCI_ADDR0 and OB_REGION_DESC0 are updated dynamically by | ||
148 | * cdns_pci_map_bus(), other region registers are set here once for all. | ||
149 | */ | ||
150 | addr1 = 0; /* Should be programmed to zero. */ | ||
151 | desc1 = CDNS_PCIE_AT_OB_REGION_DESC1_BUS(bus_range->start); | ||
152 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(0), addr1); | ||
153 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(0), desc1); | ||
154 | |||
155 | cpu_addr = cfg_res->start - mem_res->start; | ||
156 | addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(12) | | ||
157 | (lower_32_bits(cpu_addr) & GENMASK(31, 8)); | ||
158 | addr1 = upper_32_bits(cpu_addr); | ||
159 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(0), addr0); | ||
160 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(0), addr1); | ||
161 | |||
162 | err = of_pci_range_parser_init(&parser, np); | ||
163 | if (err) | ||
164 | return err; | ||
165 | |||
166 | r = 1; | ||
167 | for_each_of_pci_range(&parser, &range) { | ||
168 | bool is_io; | ||
169 | |||
170 | if (r >= rc->max_regions) | ||
171 | break; | ||
172 | |||
173 | if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM) | ||
174 | is_io = false; | ||
175 | else if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_IO) | ||
176 | is_io = true; | ||
177 | else | ||
178 | continue; | ||
179 | |||
180 | cdns_pcie_set_outbound_region(pcie, 0, r, is_io, | ||
181 | range.cpu_addr, | ||
182 | range.pci_addr, | ||
183 | range.size); | ||
184 | r++; | ||
185 | } | ||
186 | |||
187 | /* | ||
188 | * Set Root Port no BAR match Inbound Translation registers: | ||
189 | * needed for MSI and DMA. | ||
190 | * Root Port BAR0 and BAR1 are disabled, hence no need to set their | ||
191 | * inbound translation registers. | ||
192 | */ | ||
193 | addr0 = CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS(rc->no_bar_nbits); | ||
194 | addr1 = 0; | ||
195 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_RP_BAR_ADDR0(RP_NO_BAR), addr0); | ||
196 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_IB_RP_BAR_ADDR1(RP_NO_BAR), addr1); | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static int cdns_pcie_host_init(struct device *dev, | ||
202 | struct list_head *resources, | ||
203 | struct cdns_pcie_rc *rc) | ||
204 | { | ||
205 | struct resource *bus_range = NULL; | ||
206 | int err; | ||
207 | |||
208 | /* Parse our PCI ranges and request their resources */ | ||
209 | err = pci_parse_request_of_pci_ranges(dev, resources, &bus_range); | ||
210 | if (err) | ||
211 | return err; | ||
212 | |||
213 | rc->bus_range = bus_range; | ||
214 | rc->pcie.bus = bus_range->start; | ||
215 | |||
216 | err = cdns_pcie_host_init_root_port(rc); | ||
217 | if (err) | ||
218 | goto err_out; | ||
219 | |||
220 | err = cdns_pcie_host_init_address_translation(rc); | ||
221 | if (err) | ||
222 | goto err_out; | ||
223 | |||
224 | return 0; | ||
225 | |||
226 | err_out: | ||
227 | pci_free_resource_list(resources); | ||
228 | return err; | ||
229 | } | ||
230 | |||
231 | static int cdns_pcie_host_probe(struct platform_device *pdev) | ||
232 | { | ||
233 | const char *type; | ||
234 | struct device *dev = &pdev->dev; | ||
235 | struct device_node *np = dev->of_node; | ||
236 | struct pci_host_bridge *bridge; | ||
237 | struct list_head resources; | ||
238 | struct cdns_pcie_rc *rc; | ||
239 | struct cdns_pcie *pcie; | ||
240 | struct resource *res; | ||
241 | int ret; | ||
242 | |||
243 | bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rc)); | ||
244 | if (!bridge) | ||
245 | return -ENOMEM; | ||
246 | |||
247 | rc = pci_host_bridge_priv(bridge); | ||
248 | rc->dev = dev; | ||
249 | |||
250 | pcie = &rc->pcie; | ||
251 | pcie->is_rc = true; | ||
252 | |||
253 | rc->max_regions = 32; | ||
254 | of_property_read_u32(np, "cdns,max-outbound-regions", &rc->max_regions); | ||
255 | |||
256 | rc->no_bar_nbits = 32; | ||
257 | of_property_read_u32(np, "cdns,no-bar-match-nbits", &rc->no_bar_nbits); | ||
258 | |||
259 | rc->vendor_id = 0xffff; | ||
260 | of_property_read_u16(np, "vendor-id", &rc->vendor_id); | ||
261 | |||
262 | rc->device_id = 0xffff; | ||
263 | of_property_read_u16(np, "device-id", &rc->device_id); | ||
264 | |||
265 | type = of_get_property(np, "device_type", NULL); | ||
266 | if (!type || strcmp(type, "pci")) { | ||
267 | dev_err(dev, "invalid \"device_type\" %s\n", type); | ||
268 | return -EINVAL; | ||
269 | } | ||
270 | |||
271 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg"); | ||
272 | pcie->reg_base = devm_ioremap_resource(dev, res); | ||
273 | if (IS_ERR(pcie->reg_base)) { | ||
274 | dev_err(dev, "missing \"reg\"\n"); | ||
275 | return PTR_ERR(pcie->reg_base); | ||
276 | } | ||
277 | |||
278 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); | ||
279 | rc->cfg_base = devm_pci_remap_cfg_resource(dev, res); | ||
280 | if (IS_ERR(rc->cfg_base)) { | ||
281 | dev_err(dev, "missing \"cfg\"\n"); | ||
282 | return PTR_ERR(rc->cfg_base); | ||
283 | } | ||
284 | rc->cfg_res = res; | ||
285 | |||
286 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem"); | ||
287 | if (!res) { | ||
288 | dev_err(dev, "missing \"mem\"\n"); | ||
289 | return -EINVAL; | ||
290 | } | ||
291 | pcie->mem_res = res; | ||
292 | |||
293 | pm_runtime_enable(dev); | ||
294 | ret = pm_runtime_get_sync(dev); | ||
295 | if (ret < 0) { | ||
296 | dev_err(dev, "pm_runtime_get_sync() failed\n"); | ||
297 | goto err_get_sync; | ||
298 | } | ||
299 | |||
300 | ret = cdns_pcie_host_init(dev, &resources, rc); | ||
301 | if (ret) | ||
302 | goto err_init; | ||
303 | |||
304 | list_splice_init(&resources, &bridge->windows); | ||
305 | bridge->dev.parent = dev; | ||
306 | bridge->busnr = pcie->bus; | ||
307 | bridge->ops = &cdns_pcie_host_ops; | ||
308 | bridge->map_irq = of_irq_parse_and_map_pci; | ||
309 | bridge->swizzle_irq = pci_common_swizzle; | ||
310 | |||
311 | ret = pci_host_probe(bridge); | ||
312 | if (ret < 0) | ||
313 | goto err_host_probe; | ||
314 | |||
315 | return 0; | ||
316 | |||
317 | err_host_probe: | ||
318 | pci_free_resource_list(&resources); | ||
319 | |||
320 | err_init: | ||
321 | pm_runtime_put_sync(dev); | ||
322 | |||
323 | err_get_sync: | ||
324 | pm_runtime_disable(dev); | ||
325 | |||
326 | return ret; | ||
327 | } | ||
328 | |||
329 | static struct platform_driver cdns_pcie_host_driver = { | ||
330 | .driver = { | ||
331 | .name = "cdns-pcie-host", | ||
332 | .of_match_table = cdns_pcie_host_of_match, | ||
333 | }, | ||
334 | .probe = cdns_pcie_host_probe, | ||
335 | }; | ||
336 | builtin_platform_driver(cdns_pcie_host_driver); | ||
diff --git a/drivers/pci/cadence/pcie-cadence.c b/drivers/pci/cadence/pcie-cadence.c new file mode 100644 index 000000000000..138d113eb45d --- /dev/null +++ b/drivers/pci/cadence/pcie-cadence.c | |||
@@ -0,0 +1,126 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | // Copyright (c) 2017 Cadence | ||
3 | // Cadence PCIe controller driver. | ||
4 | // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com> | ||
5 | |||
6 | #include <linux/kernel.h> | ||
7 | |||
8 | #include "pcie-cadence.h" | ||
9 | |||
10 | void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 fn, | ||
11 | u32 r, bool is_io, | ||
12 | u64 cpu_addr, u64 pci_addr, size_t size) | ||
13 | { | ||
14 | /* | ||
15 | * roundup_pow_of_two() returns an unsigned long, which is not suited | ||
16 | * for 64bit values. | ||
17 | */ | ||
18 | u64 sz = 1ULL << fls64(size - 1); | ||
19 | int nbits = ilog2(sz); | ||
20 | u32 addr0, addr1, desc0, desc1; | ||
21 | |||
22 | if (nbits < 8) | ||
23 | nbits = 8; | ||
24 | |||
25 | /* Set the PCI address */ | ||
26 | addr0 = CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS(nbits) | | ||
27 | (lower_32_bits(pci_addr) & GENMASK(31, 8)); | ||
28 | addr1 = upper_32_bits(pci_addr); | ||
29 | |||
30 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r), addr0); | ||
31 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r), addr1); | ||
32 | |||
33 | /* Set the PCIe header descriptor */ | ||
34 | if (is_io) | ||
35 | desc0 = CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_IO; | ||
36 | else | ||
37 | desc0 = CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MEM; | ||
38 | desc1 = 0; | ||
39 | |||
40 | /* | ||
41 | * Whatever Bit [23] is set or not inside DESC0 register of the outbound | ||
42 | * PCIe descriptor, the PCI function number must be set into | ||
43 | * Bits [26:24] of DESC0 anyway. | ||
44 | * | ||
45 | * In Root Complex mode, the function number is always 0 but in Endpoint | ||
46 | * mode, the PCIe controller may support more than one function. This | ||
47 | * function number needs to be set properly into the outbound PCIe | ||
48 | * descriptor. | ||
49 | * | ||
50 | * Besides, setting Bit [23] is mandatory when in Root Complex mode: | ||
51 | * then the driver must provide the bus, resp. device, number in | ||
52 | * Bits [7:0] of DESC1, resp. Bits[31:27] of DESC0. Like the function | ||
53 | * number, the device number is always 0 in Root Complex mode. | ||
54 | * | ||
55 | * However when in Endpoint mode, we can clear Bit [23] of DESC0, hence | ||
56 | * the PCIe controller will use the captured values for the bus and | ||
57 | * device numbers. | ||
58 | */ | ||
59 | if (pcie->is_rc) { | ||
60 | /* The device and function numbers are always 0. */ | ||
61 | desc0 |= CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID | | ||
62 | CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(0); | ||
63 | desc1 |= CDNS_PCIE_AT_OB_REGION_DESC1_BUS(pcie->bus); | ||
64 | } else { | ||
65 | /* | ||
66 | * Use captured values for bus and device numbers but still | ||
67 | * need to set the function number. | ||
68 | */ | ||
69 | desc0 |= CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(fn); | ||
70 | } | ||
71 | |||
72 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(r), desc0); | ||
73 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), desc1); | ||
74 | |||
75 | /* Set the CPU address */ | ||
76 | cpu_addr -= pcie->mem_res->start; | ||
77 | addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) | | ||
78 | (lower_32_bits(cpu_addr) & GENMASK(31, 8)); | ||
79 | addr1 = upper_32_bits(cpu_addr); | ||
80 | |||
81 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), addr0); | ||
82 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), addr1); | ||
83 | } | ||
84 | |||
85 | void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie, u8 fn, | ||
86 | u32 r, u64 cpu_addr) | ||
87 | { | ||
88 | u32 addr0, addr1, desc0, desc1; | ||
89 | |||
90 | desc0 = CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_NORMAL_MSG; | ||
91 | desc1 = 0; | ||
92 | |||
93 | /* See cdns_pcie_set_outbound_region() comments above. */ | ||
94 | if (pcie->is_rc) { | ||
95 | desc0 |= CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID | | ||
96 | CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(0); | ||
97 | desc1 |= CDNS_PCIE_AT_OB_REGION_DESC1_BUS(pcie->bus); | ||
98 | } else { | ||
99 | desc0 |= CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(fn); | ||
100 | } | ||
101 | |||
102 | /* Set the CPU address */ | ||
103 | cpu_addr -= pcie->mem_res->start; | ||
104 | addr0 = CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(17) | | ||
105 | (lower_32_bits(cpu_addr) & GENMASK(31, 8)); | ||
106 | addr1 = upper_32_bits(cpu_addr); | ||
107 | |||
108 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r), 0); | ||
109 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r), 0); | ||
110 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(r), desc0); | ||
111 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), desc1); | ||
112 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), addr0); | ||
113 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), addr1); | ||
114 | } | ||
115 | |||
116 | void cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r) | ||
117 | { | ||
118 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r), 0); | ||
119 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r), 0); | ||
120 | |||
121 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(r), 0); | ||
122 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), 0); | ||
123 | |||
124 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), 0); | ||
125 | cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), 0); | ||
126 | } | ||
diff --git a/drivers/pci/cadence/pcie-cadence.h b/drivers/pci/cadence/pcie-cadence.h new file mode 100644 index 000000000000..4bb27333b05c --- /dev/null +++ b/drivers/pci/cadence/pcie-cadence.h | |||
@@ -0,0 +1,311 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | // Copyright (c) 2017 Cadence | ||
3 | // Cadence PCIe controller driver. | ||
4 | // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com> | ||
5 | |||
6 | #ifndef _PCIE_CADENCE_H | ||
7 | #define _PCIE_CADENCE_H | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/pci.h> | ||
11 | |||
12 | /* | ||
13 | * Local Management Registers | ||
14 | */ | ||
15 | #define CDNS_PCIE_LM_BASE 0x00100000 | ||
16 | |||
17 | /* Vendor ID Register */ | ||
18 | #define CDNS_PCIE_LM_ID (CDNS_PCIE_LM_BASE + 0x0044) | ||
19 | #define CDNS_PCIE_LM_ID_VENDOR_MASK GENMASK(15, 0) | ||
20 | #define CDNS_PCIE_LM_ID_VENDOR_SHIFT 0 | ||
21 | #define CDNS_PCIE_LM_ID_VENDOR(vid) \ | ||
22 | (((vid) << CDNS_PCIE_LM_ID_VENDOR_SHIFT) & CDNS_PCIE_LM_ID_VENDOR_MASK) | ||
23 | #define CDNS_PCIE_LM_ID_SUBSYS_MASK GENMASK(31, 16) | ||
24 | #define CDNS_PCIE_LM_ID_SUBSYS_SHIFT 16 | ||
25 | #define CDNS_PCIE_LM_ID_SUBSYS(sub) \ | ||
26 | (((sub) << CDNS_PCIE_LM_ID_SUBSYS_SHIFT) & CDNS_PCIE_LM_ID_SUBSYS_MASK) | ||
27 | |||
28 | /* Root Port Requestor ID Register */ | ||
29 | #define CDNS_PCIE_LM_RP_RID (CDNS_PCIE_LM_BASE + 0x0228) | ||
30 | #define CDNS_PCIE_LM_RP_RID_MASK GENMASK(15, 0) | ||
31 | #define CDNS_PCIE_LM_RP_RID_SHIFT 0 | ||
32 | #define CDNS_PCIE_LM_RP_RID_(rid) \ | ||
33 | (((rid) << CDNS_PCIE_LM_RP_RID_SHIFT) & CDNS_PCIE_LM_RP_RID_MASK) | ||
34 | |||
35 | /* Endpoint Bus and Device Number Register */ | ||
36 | #define CDNS_PCIE_LM_EP_ID (CDNS_PCIE_LM_BASE + 0x022c) | ||
37 | #define CDNS_PCIE_LM_EP_ID_DEV_MASK GENMASK(4, 0) | ||
38 | #define CDNS_PCIE_LM_EP_ID_DEV_SHIFT 0 | ||
39 | #define CDNS_PCIE_LM_EP_ID_BUS_MASK GENMASK(15, 8) | ||
40 | #define CDNS_PCIE_LM_EP_ID_BUS_SHIFT 8 | ||
41 | |||
42 | /* Endpoint Function f BAR b Configuration Registers */ | ||
43 | #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) \ | ||
44 | (CDNS_PCIE_LM_BASE + 0x0240 + (fn) * 0x0008) | ||
45 | #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn) \ | ||
46 | (CDNS_PCIE_LM_BASE + 0x0244 + (fn) * 0x0008) | ||
47 | #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b) \ | ||
48 | (GENMASK(4, 0) << ((b) * 8)) | ||
49 | #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE(b, a) \ | ||
50 | (((a) << ((b) * 8)) & CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b)) | ||
51 | #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b) \ | ||
52 | (GENMASK(7, 5) << ((b) * 8)) | ||
53 | #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL(b, c) \ | ||
54 | (((c) << ((b) * 8 + 5)) & CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b)) | ||
55 | |||
56 | /* Endpoint Function Configuration Register */ | ||
57 | #define CDNS_PCIE_LM_EP_FUNC_CFG (CDNS_PCIE_LM_BASE + 0x02c0) | ||
58 | |||
59 | /* Root Complex BAR Configuration Register */ | ||
60 | #define CDNS_PCIE_LM_RC_BAR_CFG (CDNS_PCIE_LM_BASE + 0x0300) | ||
61 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK GENMASK(5, 0) | ||
62 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE(a) \ | ||
63 | (((a) << 0) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK) | ||
64 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK GENMASK(8, 6) | ||
65 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL(c) \ | ||
66 | (((c) << 6) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK) | ||
67 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK GENMASK(13, 9) | ||
68 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE(a) \ | ||
69 | (((a) << 9) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK) | ||
70 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK GENMASK(16, 14) | ||
71 | #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL(c) \ | ||
72 | (((c) << 14) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK) | ||
73 | #define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE BIT(17) | ||
74 | #define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_32BITS 0 | ||
75 | #define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS BIT(18) | ||
76 | #define CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE BIT(19) | ||
77 | #define CDNS_PCIE_LM_RC_BAR_CFG_IO_16BITS 0 | ||
78 | #define CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS BIT(20) | ||
79 | #define CDNS_PCIE_LM_RC_BAR_CFG_CHECK_ENABLE BIT(31) | ||
80 | |||
81 | /* BAR control values applicable to both Endpoint Function and Root Complex */ | ||
82 | #define CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED 0x0 | ||
83 | #define CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS 0x1 | ||
84 | #define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS 0x4 | ||
85 | #define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS 0x5 | ||
86 | #define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS 0x6 | ||
87 | #define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS 0x7 | ||
88 | |||
89 | |||
90 | /* | ||
91 | * Endpoint Function Registers (PCI configuration space for endpoint functions) | ||
92 | */ | ||
93 | #define CDNS_PCIE_EP_FUNC_BASE(fn) (((fn) << 12) & GENMASK(19, 12)) | ||
94 | |||
95 | #define CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET 0x90 | ||
96 | |||
97 | /* | ||
98 | * Root Port Registers (PCI configuration space for the root port function) | ||
99 | */ | ||
100 | #define CDNS_PCIE_RP_BASE 0x00200000 | ||
101 | |||
102 | |||
103 | /* | ||
104 | * Address Translation Registers | ||
105 | */ | ||
106 | #define CDNS_PCIE_AT_BASE 0x00400000 | ||
107 | |||
108 | /* Region r Outbound AXI to PCIe Address Translation Register 0 */ | ||
109 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r) \ | ||
110 | (CDNS_PCIE_AT_BASE + 0x0000 + ((r) & 0x1f) * 0x0020) | ||
111 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK GENMASK(5, 0) | ||
112 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS(nbits) \ | ||
113 | (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK) | ||
114 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK GENMASK(19, 12) | ||
115 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN(devfn) \ | ||
116 | (((devfn) << 12) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK) | ||
117 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK GENMASK(27, 20) | ||
118 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS(bus) \ | ||
119 | (((bus) << 20) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK) | ||
120 | |||
121 | /* Region r Outbound AXI to PCIe Address Translation Register 1 */ | ||
122 | #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r) \ | ||
123 | (CDNS_PCIE_AT_BASE + 0x0004 + ((r) & 0x1f) * 0x0020) | ||
124 | |||
125 | /* Region r Outbound PCIe Descriptor Register 0 */ | ||
126 | #define CDNS_PCIE_AT_OB_REGION_DESC0(r) \ | ||
127 | (CDNS_PCIE_AT_BASE + 0x0008 + ((r) & 0x1f) * 0x0020) | ||
128 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MASK GENMASK(3, 0) | ||
129 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MEM 0x2 | ||
130 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_IO 0x6 | ||
131 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 0xa | ||
132 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 0xb | ||
133 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_NORMAL_MSG 0xc | ||
134 | #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_VENDOR_MSG 0xd | ||
135 | /* Bit 23 MUST be set in RC mode. */ | ||
136 | #define CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID BIT(23) | ||
137 | #define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK GENMASK(31, 24) | ||
138 | #define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(devfn) \ | ||
139 | (((devfn) << 24) & CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK) | ||
140 | |||
141 | /* Region r Outbound PCIe Descriptor Register 1 */ | ||
142 | #define CDNS_PCIE_AT_OB_REGION_DESC1(r) \ | ||
143 | (CDNS_PCIE_AT_BASE + 0x000c + ((r) & 0x1f) * 0x0020) | ||
144 | #define CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK GENMASK(7, 0) | ||
145 | #define CDNS_PCIE_AT_OB_REGION_DESC1_BUS(bus) \ | ||
146 | ((bus) & CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK) | ||
147 | |||
148 | /* Region r AXI Region Base Address Register 0 */ | ||
149 | #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r) \ | ||
150 | (CDNS_PCIE_AT_BASE + 0x0018 + ((r) & 0x1f) * 0x0020) | ||
151 | #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK GENMASK(5, 0) | ||
152 | #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) \ | ||
153 | (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK) | ||
154 | |||
155 | /* Region r AXI Region Base Address Register 1 */ | ||
156 | #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r) \ | ||
157 | (CDNS_PCIE_AT_BASE + 0x001c + ((r) & 0x1f) * 0x0020) | ||
158 | |||
159 | /* Root Port BAR Inbound PCIe to AXI Address Translation Register */ | ||
160 | #define CDNS_PCIE_AT_IB_RP_BAR_ADDR0(bar) \ | ||
161 | (CDNS_PCIE_AT_BASE + 0x0800 + (bar) * 0x0008) | ||
162 | #define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK GENMASK(5, 0) | ||
163 | #define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS(nbits) \ | ||
164 | (((nbits) - 1) & CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK) | ||
165 | #define CDNS_PCIE_AT_IB_RP_BAR_ADDR1(bar) \ | ||
166 | (CDNS_PCIE_AT_BASE + 0x0804 + (bar) * 0x0008) | ||
167 | |||
168 | enum cdns_pcie_rp_bar { | ||
169 | RP_BAR0, | ||
170 | RP_BAR1, | ||
171 | RP_NO_BAR | ||
172 | }; | ||
173 | |||
174 | /* Endpoint Function BAR Inbound PCIe to AXI Address Translation Register */ | ||
175 | #define CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR0(fn, bar) \ | ||
176 | (CDNS_PCIE_AT_BASE + 0x0840 + (fn) * 0x0040 + (bar) * 0x0008) | ||
177 | #define CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR1(fn, bar) \ | ||
178 | (CDNS_PCIE_AT_BASE + 0x0844 + (fn) * 0x0040 + (bar) * 0x0008) | ||
179 | |||
180 | /* Normal/Vendor specific message access: offset inside some outbound region */ | ||
181 | #define CDNS_PCIE_NORMAL_MSG_ROUTING_MASK GENMASK(7, 5) | ||
182 | #define CDNS_PCIE_NORMAL_MSG_ROUTING(route) \ | ||
183 | (((route) << 5) & CDNS_PCIE_NORMAL_MSG_ROUTING_MASK) | ||
184 | #define CDNS_PCIE_NORMAL_MSG_CODE_MASK GENMASK(15, 8) | ||
185 | #define CDNS_PCIE_NORMAL_MSG_CODE(code) \ | ||
186 | (((code) << 8) & CDNS_PCIE_NORMAL_MSG_CODE_MASK) | ||
187 | #define CDNS_PCIE_MSG_NO_DATA BIT(16) | ||
188 | |||
189 | enum cdns_pcie_msg_code { | ||
190 | MSG_CODE_ASSERT_INTA = 0x20, | ||
191 | MSG_CODE_ASSERT_INTB = 0x21, | ||
192 | MSG_CODE_ASSERT_INTC = 0x22, | ||
193 | MSG_CODE_ASSERT_INTD = 0x23, | ||
194 | MSG_CODE_DEASSERT_INTA = 0x24, | ||
195 | MSG_CODE_DEASSERT_INTB = 0x25, | ||
196 | MSG_CODE_DEASSERT_INTC = 0x26, | ||
197 | MSG_CODE_DEASSERT_INTD = 0x27, | ||
198 | }; | ||
199 | |||
200 | enum cdns_pcie_msg_routing { | ||
201 | /* Route to Root Complex */ | ||
202 | MSG_ROUTING_TO_RC, | ||
203 | |||
204 | /* Use Address Routing */ | ||
205 | MSG_ROUTING_BY_ADDR, | ||
206 | |||
207 | /* Use ID Routing */ | ||
208 | MSG_ROUTING_BY_ID, | ||
209 | |||
210 | /* Route as Broadcast Message from Root Complex */ | ||
211 | MSG_ROUTING_BCAST, | ||
212 | |||
213 | /* Local message; terminate at receiver (INTx messages) */ | ||
214 | MSG_ROUTING_LOCAL, | ||
215 | |||
216 | /* Gather & route to Root Complex (PME_TO_Ack message) */ | ||
217 | MSG_ROUTING_GATHER, | ||
218 | }; | ||
219 | |||
220 | /** | ||
221 | * struct cdns_pcie - private data for Cadence PCIe controller drivers | ||
222 | * @reg_base: IO mapped register base | ||
223 | * @mem_res: start/end offsets in the physical system memory to map PCI accesses | ||
224 | * @is_rc: tell whether the PCIe controller mode is Root Complex or Endpoint. | ||
225 | * @bus: In Root Complex mode, the bus number | ||
226 | */ | ||
227 | struct cdns_pcie { | ||
228 | void __iomem *reg_base; | ||
229 | struct resource *mem_res; | ||
230 | bool is_rc; | ||
231 | u8 bus; | ||
232 | }; | ||
233 | |||
234 | /* Register access */ | ||
235 | static inline void cdns_pcie_writeb(struct cdns_pcie *pcie, u32 reg, u8 value) | ||
236 | { | ||
237 | writeb(value, pcie->reg_base + reg); | ||
238 | } | ||
239 | |||
240 | static inline void cdns_pcie_writew(struct cdns_pcie *pcie, u32 reg, u16 value) | ||
241 | { | ||
242 | writew(value, pcie->reg_base + reg); | ||
243 | } | ||
244 | |||
245 | static inline void cdns_pcie_writel(struct cdns_pcie *pcie, u32 reg, u32 value) | ||
246 | { | ||
247 | writel(value, pcie->reg_base + reg); | ||
248 | } | ||
249 | |||
250 | static inline u32 cdns_pcie_readl(struct cdns_pcie *pcie, u32 reg) | ||
251 | { | ||
252 | return readl(pcie->reg_base + reg); | ||
253 | } | ||
254 | |||
255 | /* Root Port register access */ | ||
256 | static inline void cdns_pcie_rp_writeb(struct cdns_pcie *pcie, | ||
257 | u32 reg, u8 value) | ||
258 | { | ||
259 | writeb(value, pcie->reg_base + CDNS_PCIE_RP_BASE + reg); | ||
260 | } | ||
261 | |||
262 | static inline void cdns_pcie_rp_writew(struct cdns_pcie *pcie, | ||
263 | u32 reg, u16 value) | ||
264 | { | ||
265 | writew(value, pcie->reg_base + CDNS_PCIE_RP_BASE + reg); | ||
266 | } | ||
267 | |||
268 | /* Endpoint Function register access */ | ||
269 | static inline void cdns_pcie_ep_fn_writeb(struct cdns_pcie *pcie, u8 fn, | ||
270 | u32 reg, u8 value) | ||
271 | { | ||
272 | writeb(value, pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg); | ||
273 | } | ||
274 | |||
275 | static inline void cdns_pcie_ep_fn_writew(struct cdns_pcie *pcie, u8 fn, | ||
276 | u32 reg, u16 value) | ||
277 | { | ||
278 | writew(value, pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg); | ||
279 | } | ||
280 | |||
281 | static inline void cdns_pcie_ep_fn_writel(struct cdns_pcie *pcie, u8 fn, | ||
282 | u32 reg, u16 value) | ||
283 | { | ||
284 | writel(value, pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg); | ||
285 | } | ||
286 | |||
287 | static inline u8 cdns_pcie_ep_fn_readb(struct cdns_pcie *pcie, u8 fn, u32 reg) | ||
288 | { | ||
289 | return readb(pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg); | ||
290 | } | ||
291 | |||
292 | static inline u16 cdns_pcie_ep_fn_readw(struct cdns_pcie *pcie, u8 fn, u32 reg) | ||
293 | { | ||
294 | return readw(pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg); | ||
295 | } | ||
296 | |||
297 | static inline u32 cdns_pcie_ep_fn_readl(struct cdns_pcie *pcie, u8 fn, u32 reg) | ||
298 | { | ||
299 | return readl(pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg); | ||
300 | } | ||
301 | |||
302 | void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 fn, | ||
303 | u32 r, bool is_io, | ||
304 | u64 cpu_addr, u64 pci_addr, size_t size); | ||
305 | |||
306 | void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie, u8 fn, | ||
307 | u32 r, u64 cpu_addr); | ||
308 | |||
309 | void cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r); | ||
310 | |||
311 | #endif /* _PCIE_CADENCE_H */ | ||
diff --git a/drivers/pci/dwc/Kconfig b/drivers/pci/dwc/Kconfig index 113e09440f85..0f666b1ce289 100644 --- a/drivers/pci/dwc/Kconfig +++ b/drivers/pci/dwc/Kconfig | |||
@@ -1,3 +1,5 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
2 | |||
1 | menu "DesignWare PCI Core Support" | 3 | menu "DesignWare PCI Core Support" |
2 | 4 | ||
3 | config PCIE_DW | 5 | config PCIE_DW |
@@ -15,39 +17,38 @@ config PCIE_DW_EP | |||
15 | select PCIE_DW | 17 | select PCIE_DW |
16 | 18 | ||
17 | config PCI_DRA7XX | 19 | config PCI_DRA7XX |
18 | bool "TI DRA7xx PCIe controller" | 20 | bool |
19 | depends on SOC_DRA7XX || COMPILE_TEST | ||
20 | depends on (PCI && PCI_MSI_IRQ_DOMAIN) || PCI_ENDPOINT | ||
21 | depends on OF && HAS_IOMEM && TI_PIPE3 | ||
22 | help | ||
23 | Enables support for the PCIe controller in the DRA7xx SoC. There | ||
24 | are two instances of PCIe controller in DRA7xx. This controller can | ||
25 | work either as EP or RC. In order to enable host-specific features | ||
26 | PCI_DRA7XX_HOST must be selected and in order to enable device- | ||
27 | specific features PCI_DRA7XX_EP must be selected. This uses | ||
28 | the DesignWare core. | ||
29 | |||
30 | if PCI_DRA7XX | ||
31 | 21 | ||
32 | config PCI_DRA7XX_HOST | 22 | config PCI_DRA7XX_HOST |
33 | bool "PCI DRA7xx Host Mode" | 23 | bool "TI DRA7xx PCIe controller Host Mode" |
34 | depends on PCI | 24 | depends on SOC_DRA7XX || COMPILE_TEST |
35 | depends on PCI_MSI_IRQ_DOMAIN | 25 | depends on PCI && PCI_MSI_IRQ_DOMAIN |
26 | depends on OF && HAS_IOMEM && TI_PIPE3 | ||
36 | select PCIE_DW_HOST | 27 | select PCIE_DW_HOST |
28 | select PCI_DRA7XX | ||
37 | default y | 29 | default y |
38 | help | 30 | help |
39 | Enables support for the PCIe controller in the DRA7xx SoC to work in | 31 | Enables support for the PCIe controller in the DRA7xx SoC to work in |
40 | host mode. | 32 | host mode. There are two instances of PCIe controller in DRA7xx. |
33 | This controller can work either as EP or RC. In order to enable | ||
34 | host-specific features PCI_DRA7XX_HOST must be selected and in order | ||
35 | to enable device-specific features PCI_DRA7XX_EP must be selected. | ||
36 | This uses the DesignWare core. | ||
41 | 37 | ||
42 | config PCI_DRA7XX_EP | 38 | config PCI_DRA7XX_EP |
43 | bool "PCI DRA7xx Endpoint Mode" | 39 | bool "TI DRA7xx PCIe controller Endpoint Mode" |
40 | depends on SOC_DRA7XX || COMPILE_TEST | ||
44 | depends on PCI_ENDPOINT | 41 | depends on PCI_ENDPOINT |
42 | depends on OF && HAS_IOMEM && TI_PIPE3 | ||
45 | select PCIE_DW_EP | 43 | select PCIE_DW_EP |
44 | select PCI_DRA7XX | ||
46 | help | 45 | help |
47 | Enables support for the PCIe controller in the DRA7xx SoC to work in | 46 | Enables support for the PCIe controller in the DRA7xx SoC to work in |
48 | endpoint mode. | 47 | endpoint mode. There are two instances of PCIe controller in DRA7xx. |
49 | 48 | This controller can work either as EP or RC. In order to enable | |
50 | endif | 49 | host-specific features PCI_DRA7XX_HOST must be selected and in order |
50 | to enable device-specific features PCI_DRA7XX_EP must be selected. | ||
51 | This uses the DesignWare core. | ||
51 | 52 | ||
52 | config PCIE_DW_PLAT | 53 | config PCIE_DW_PLAT |
53 | bool "Platform bus based DesignWare PCIe Controller" | 54 | bool "Platform bus based DesignWare PCIe Controller" |
@@ -149,15 +150,28 @@ config PCIE_ARMADA_8K | |||
149 | DesignWare core functions to implement the driver. | 150 | DesignWare core functions to implement the driver. |
150 | 151 | ||
151 | config PCIE_ARTPEC6 | 152 | config PCIE_ARTPEC6 |
152 | bool "Axis ARTPEC-6 PCIe controller" | 153 | bool |
153 | depends on PCI | 154 | |
155 | config PCIE_ARTPEC6_HOST | ||
156 | bool "Axis ARTPEC-6 PCIe controller Host Mode" | ||
154 | depends on MACH_ARTPEC6 | 157 | depends on MACH_ARTPEC6 |
155 | depends on PCI_MSI_IRQ_DOMAIN | 158 | depends on PCI && PCI_MSI_IRQ_DOMAIN |
156 | select PCIEPORTBUS | 159 | select PCIEPORTBUS |
157 | select PCIE_DW_HOST | 160 | select PCIE_DW_HOST |
161 | select PCIE_ARTPEC6 | ||
162 | help | ||
163 | Enables support for the PCIe controller in the ARTPEC-6 SoC to work in | ||
164 | host mode. This uses the DesignWare core. | ||
165 | |||
166 | config PCIE_ARTPEC6_EP | ||
167 | bool "Axis ARTPEC-6 PCIe controller Endpoint Mode" | ||
168 | depends on MACH_ARTPEC6 | ||
169 | depends on PCI_ENDPOINT | ||
170 | select PCIE_DW_EP | ||
171 | select PCIE_ARTPEC6 | ||
158 | help | 172 | help |
159 | Say Y here to enable PCIe controller support on Axis ARTPEC-6 | 173 | Enables support for the PCIe controller in the ARTPEC-6 SoC to work in |
160 | SoCs. This PCIe controller uses the DesignWare core. | 174 | endpoint mode. This uses the DesignWare core. |
161 | 175 | ||
162 | config PCIE_KIRIN | 176 | config PCIE_KIRIN |
163 | depends on OF && ARM64 | 177 | depends on OF && ARM64 |
diff --git a/drivers/pci/dwc/Makefile b/drivers/pci/dwc/Makefile index 41ba499c96ee..5d2ce72c7a52 100644 --- a/drivers/pci/dwc/Makefile +++ b/drivers/pci/dwc/Makefile | |||
@@ -3,9 +3,7 @@ obj-$(CONFIG_PCIE_DW) += pcie-designware.o | |||
3 | obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o | 3 | obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o |
4 | obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o | 4 | obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o |
5 | obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o | 5 | obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o |
6 | ifneq ($(filter y,$(CONFIG_PCI_DRA7XX_HOST) $(CONFIG_PCI_DRA7XX_EP)),) | 6 | obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o |
7 | obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o | ||
8 | endif | ||
9 | obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o | 7 | obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o |
10 | obj-$(CONFIG_PCI_IMX6) += pci-imx6.o | 8 | obj-$(CONFIG_PCI_IMX6) += pci-imx6.o |
11 | obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o | 9 | obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o |
@@ -27,4 +25,6 @@ obj-$(CONFIG_PCIE_HISI_STB) += pcie-histb.o | |||
27 | # ARM64 and use internal ifdefs to only build the pieces we need | 25 | # ARM64 and use internal ifdefs to only build the pieces we need |
28 | # depending on whether ACPI, the DT driver, or both are enabled. | 26 | # depending on whether ACPI, the DT driver, or both are enabled. |
29 | 27 | ||
28 | ifdef CONFIG_PCI | ||
30 | obj-$(CONFIG_ARM64) += pcie-hisi.o | 29 | obj-$(CONFIG_ARM64) += pcie-hisi.o |
30 | endif | ||
diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c index e77a4ceed74c..ed8558d638e5 100644 --- a/drivers/pci/dwc/pci-dra7xx.c +++ b/drivers/pci/dwc/pci-dra7xx.c | |||
@@ -1,13 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * pcie-dra7xx - PCIe controller driver for TI DRA7xx SoCs | 3 | * pcie-dra7xx - PCIe controller driver for TI DRA7xx SoCs |
3 | * | 4 | * |
4 | * Copyright (C) 2013-2014 Texas Instruments Incorporated - http://www.ti.com | 5 | * Copyright (C) 2013-2014 Texas Instruments Incorporated - http://www.ti.com |
5 | * | 6 | * |
6 | * Authors: Kishon Vijay Abraham I <kishon@ti.com> | 7 | * Authors: Kishon Vijay Abraham I <kishon@ti.com> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | 8 | */ |
12 | 9 | ||
13 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
@@ -110,7 +107,7 @@ static inline void dra7xx_pcie_writel(struct dra7xx_pcie *pcie, u32 offset, | |||
110 | writel(value, pcie->base + offset); | 107 | writel(value, pcie->base + offset); |
111 | } | 108 | } |
112 | 109 | ||
113 | static u64 dra7xx_pcie_cpu_addr_fixup(u64 pci_addr) | 110 | static u64 dra7xx_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 pci_addr) |
114 | { | 111 | { |
115 | return pci_addr & DRA7XX_CPU_TO_BUS_ADDR; | 112 | return pci_addr & DRA7XX_CPU_TO_BUS_ADDR; |
116 | } | 113 | } |
@@ -226,6 +223,7 @@ static int dra7xx_pcie_intx_map(struct irq_domain *domain, unsigned int irq, | |||
226 | 223 | ||
227 | static const struct irq_domain_ops intx_domain_ops = { | 224 | static const struct irq_domain_ops intx_domain_ops = { |
228 | .map = dra7xx_pcie_intx_map, | 225 | .map = dra7xx_pcie_intx_map, |
226 | .xlate = pci_irqd_intx_xlate, | ||
229 | }; | 227 | }; |
230 | 228 | ||
231 | static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) | 229 | static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) |
@@ -256,7 +254,8 @@ static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg) | |||
256 | struct dra7xx_pcie *dra7xx = arg; | 254 | struct dra7xx_pcie *dra7xx = arg; |
257 | struct dw_pcie *pci = dra7xx->pci; | 255 | struct dw_pcie *pci = dra7xx->pci; |
258 | struct pcie_port *pp = &pci->pp; | 256 | struct pcie_port *pp = &pci->pp; |
259 | u32 reg; | 257 | unsigned long reg; |
258 | u32 virq, bit; | ||
260 | 259 | ||
261 | reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI); | 260 | reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI); |
262 | 261 | ||
@@ -268,8 +267,11 @@ static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg) | |||
268 | case INTB: | 267 | case INTB: |
269 | case INTC: | 268 | case INTC: |
270 | case INTD: | 269 | case INTD: |
271 | generic_handle_irq(irq_find_mapping(dra7xx->irq_domain, | 270 | for_each_set_bit(bit, ®, PCI_NUM_INTX) { |
272 | ffs(reg))); | 271 | virq = irq_find_mapping(dra7xx->irq_domain, bit); |
272 | if (virq) | ||
273 | generic_handle_irq(virq); | ||
274 | } | ||
273 | break; | 275 | break; |
274 | } | 276 | } |
275 | 277 | ||
@@ -337,15 +339,6 @@ static irqreturn_t dra7xx_pcie_irq_handler(int irq, void *arg) | |||
337 | return IRQ_HANDLED; | 339 | return IRQ_HANDLED; |
338 | } | 340 | } |
339 | 341 | ||
340 | static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) | ||
341 | { | ||
342 | u32 reg; | ||
343 | |||
344 | reg = PCI_BASE_ADDRESS_0 + (4 * bar); | ||
345 | dw_pcie_writel_dbi2(pci, reg, 0x0); | ||
346 | dw_pcie_writel_dbi(pci, reg, 0x0); | ||
347 | } | ||
348 | |||
349 | static void dra7xx_pcie_ep_init(struct dw_pcie_ep *ep) | 342 | static void dra7xx_pcie_ep_init(struct dw_pcie_ep *ep) |
350 | { | 343 | { |
351 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 344 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
@@ -375,7 +368,7 @@ static void dra7xx_pcie_raise_msi_irq(struct dra7xx_pcie *dra7xx, | |||
375 | dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_MSI_XMT, reg); | 368 | dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_MSI_XMT, reg); |
376 | } | 369 | } |
377 | 370 | ||
378 | static int dra7xx_pcie_raise_irq(struct dw_pcie_ep *ep, | 371 | static int dra7xx_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no, |
379 | enum pci_epc_irq_type type, u8 interrupt_num) | 372 | enum pci_epc_irq_type type, u8 interrupt_num) |
380 | { | 373 | { |
381 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 374 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
@@ -470,6 +463,8 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, | |||
470 | if (!pci->dbi_base) | 463 | if (!pci->dbi_base) |
471 | return -ENOMEM; | 464 | return -ENOMEM; |
472 | 465 | ||
466 | pp->ops = &dra7xx_pcie_host_ops; | ||
467 | |||
473 | ret = dw_pcie_host_init(pp); | 468 | ret = dw_pcie_host_init(pp); |
474 | if (ret) { | 469 | if (ret) { |
475 | dev_err(dev, "failed to initialize host\n"); | 470 | dev_err(dev, "failed to initialize host\n"); |
@@ -599,7 +594,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) | |||
599 | void __iomem *base; | 594 | void __iomem *base; |
600 | struct resource *res; | 595 | struct resource *res; |
601 | struct dw_pcie *pci; | 596 | struct dw_pcie *pci; |
602 | struct pcie_port *pp; | ||
603 | struct dra7xx_pcie *dra7xx; | 597 | struct dra7xx_pcie *dra7xx; |
604 | struct device *dev = &pdev->dev; | 598 | struct device *dev = &pdev->dev; |
605 | struct device_node *np = dev->of_node; | 599 | struct device_node *np = dev->of_node; |
@@ -627,9 +621,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) | |||
627 | pci->dev = dev; | 621 | pci->dev = dev; |
628 | pci->ops = &dw_pcie_ops; | 622 | pci->ops = &dw_pcie_ops; |
629 | 623 | ||
630 | pp = &pci->pp; | ||
631 | pp->ops = &dra7xx_pcie_host_ops; | ||
632 | |||
633 | irq = platform_get_irq(pdev, 0); | 624 | irq = platform_get_irq(pdev, 0); |
634 | if (irq < 0) { | 625 | if (irq < 0) { |
635 | dev_err(dev, "missing IRQ resource: %d\n", irq); | 626 | dev_err(dev, "missing IRQ resource: %d\n", irq); |
@@ -705,6 +696,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) | |||
705 | 696 | ||
706 | switch (mode) { | 697 | switch (mode) { |
707 | case DW_PCIE_RC_TYPE: | 698 | case DW_PCIE_RC_TYPE: |
699 | if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) { | ||
700 | ret = -ENODEV; | ||
701 | goto err_gpio; | ||
702 | } | ||
703 | |||
708 | dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, | 704 | dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, |
709 | DEVICE_TYPE_RC); | 705 | DEVICE_TYPE_RC); |
710 | ret = dra7xx_add_pcie_port(dra7xx, pdev); | 706 | ret = dra7xx_add_pcie_port(dra7xx, pdev); |
@@ -712,6 +708,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) | |||
712 | goto err_gpio; | 708 | goto err_gpio; |
713 | break; | 709 | break; |
714 | case DW_PCIE_EP_TYPE: | 710 | case DW_PCIE_EP_TYPE: |
711 | if (!IS_ENABLED(CONFIG_PCI_DRA7XX_EP)) { | ||
712 | ret = -ENODEV; | ||
713 | goto err_gpio; | ||
714 | } | ||
715 | |||
715 | dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, | 716 | dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, |
716 | DEVICE_TYPE_EP); | 717 | DEVICE_TYPE_EP); |
717 | 718 | ||
@@ -810,7 +811,7 @@ static int dra7xx_pcie_resume_noirq(struct device *dev) | |||
810 | } | 811 | } |
811 | #endif | 812 | #endif |
812 | 813 | ||
813 | void dra7xx_pcie_shutdown(struct platform_device *pdev) | 814 | static void dra7xx_pcie_shutdown(struct platform_device *pdev) |
814 | { | 815 | { |
815 | struct device *dev = &pdev->dev; | 816 | struct device *dev = &pdev->dev; |
816 | struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); | 817 | struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); |
diff --git a/drivers/pci/dwc/pci-exynos.c b/drivers/pci/dwc/pci-exynos.c index 5596fdedbb94..ca6278113936 100644 --- a/drivers/pci/dwc/pci-exynos.c +++ b/drivers/pci/dwc/pci-exynos.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Samsung EXYNOS SoCs | 3 | * PCIe host controller driver for Samsung EXYNOS SoCs |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * http://www.samsung.com | 6 | * http://www.samsung.com |
6 | * | 7 | * |
7 | * Author: Jingoo Han <jg1.han@samsung.com> | 8 | * Author: Jingoo Han <jg1.han@samsung.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/clk.h> | 11 | #include <linux/clk.h> |
@@ -55,49 +52,8 @@ | |||
55 | #define PCIE_ELBI_SLV_ARMISC 0x120 | 52 | #define PCIE_ELBI_SLV_ARMISC 0x120 |
56 | #define PCIE_ELBI_SLV_DBI_ENABLE BIT(21) | 53 | #define PCIE_ELBI_SLV_DBI_ENABLE BIT(21) |
57 | 54 | ||
58 | /* PCIe Purple registers */ | ||
59 | #define PCIE_PHY_GLOBAL_RESET 0x000 | ||
60 | #define PCIE_PHY_COMMON_RESET 0x004 | ||
61 | #define PCIE_PHY_CMN_REG 0x008 | ||
62 | #define PCIE_PHY_MAC_RESET 0x00c | ||
63 | #define PCIE_PHY_PLL_LOCKED 0x010 | ||
64 | #define PCIE_PHY_TRSVREG_RESET 0x020 | ||
65 | #define PCIE_PHY_TRSV_RESET 0x024 | ||
66 | |||
67 | /* PCIe PHY registers */ | ||
68 | #define PCIE_PHY_IMPEDANCE 0x004 | ||
69 | #define PCIE_PHY_PLL_DIV_0 0x008 | ||
70 | #define PCIE_PHY_PLL_BIAS 0x00c | ||
71 | #define PCIE_PHY_DCC_FEEDBACK 0x014 | ||
72 | #define PCIE_PHY_PLL_DIV_1 0x05c | ||
73 | #define PCIE_PHY_COMMON_POWER 0x064 | ||
74 | #define PCIE_PHY_COMMON_PD_CMN BIT(3) | ||
75 | #define PCIE_PHY_TRSV0_EMP_LVL 0x084 | ||
76 | #define PCIE_PHY_TRSV0_DRV_LVL 0x088 | ||
77 | #define PCIE_PHY_TRSV0_RXCDR 0x0ac | ||
78 | #define PCIE_PHY_TRSV0_POWER 0x0c4 | ||
79 | #define PCIE_PHY_TRSV0_PD_TSV BIT(7) | ||
80 | #define PCIE_PHY_TRSV0_LVCC 0x0dc | ||
81 | #define PCIE_PHY_TRSV1_EMP_LVL 0x144 | ||
82 | #define PCIE_PHY_TRSV1_RXCDR 0x16c | ||
83 | #define PCIE_PHY_TRSV1_POWER 0x184 | ||
84 | #define PCIE_PHY_TRSV1_PD_TSV BIT(7) | ||
85 | #define PCIE_PHY_TRSV1_LVCC 0x19c | ||
86 | #define PCIE_PHY_TRSV2_EMP_LVL 0x204 | ||
87 | #define PCIE_PHY_TRSV2_RXCDR 0x22c | ||
88 | #define PCIE_PHY_TRSV2_POWER 0x244 | ||
89 | #define PCIE_PHY_TRSV2_PD_TSV BIT(7) | ||
90 | #define PCIE_PHY_TRSV2_LVCC 0x25c | ||
91 | #define PCIE_PHY_TRSV3_EMP_LVL 0x2c4 | ||
92 | #define PCIE_PHY_TRSV3_RXCDR 0x2ec | ||
93 | #define PCIE_PHY_TRSV3_POWER 0x304 | ||
94 | #define PCIE_PHY_TRSV3_PD_TSV BIT(7) | ||
95 | #define PCIE_PHY_TRSV3_LVCC 0x31c | ||
96 | |||
97 | struct exynos_pcie_mem_res { | 55 | struct exynos_pcie_mem_res { |
98 | void __iomem *elbi_base; /* DT 0th resource: PCIe CTRL */ | 56 | void __iomem *elbi_base; /* DT 0th resource: PCIe CTRL */ |
99 | void __iomem *phy_base; /* DT 1st resource: PHY CTRL */ | ||
100 | void __iomem *block_base; /* DT 2nd resource: PHY ADDITIONAL CTRL */ | ||
101 | }; | 57 | }; |
102 | 58 | ||
103 | struct exynos_pcie_clk_res { | 59 | struct exynos_pcie_clk_res { |
@@ -112,8 +68,6 @@ struct exynos_pcie { | |||
112 | const struct exynos_pcie_ops *ops; | 68 | const struct exynos_pcie_ops *ops; |
113 | int reset_gpio; | 69 | int reset_gpio; |
114 | 70 | ||
115 | /* For Generic PHY Framework */ | ||
116 | bool using_phy; | ||
117 | struct phy *phy; | 71 | struct phy *phy; |
118 | }; | 72 | }; |
119 | 73 | ||
@@ -141,20 +95,6 @@ static int exynos5440_pcie_get_mem_resources(struct platform_device *pdev, | |||
141 | if (IS_ERR(ep->mem_res->elbi_base)) | 95 | if (IS_ERR(ep->mem_res->elbi_base)) |
142 | return PTR_ERR(ep->mem_res->elbi_base); | 96 | return PTR_ERR(ep->mem_res->elbi_base); |
143 | 97 | ||
144 | /* If using the PHY framework, doesn't need to get other resource */ | ||
145 | if (ep->using_phy) | ||
146 | return 0; | ||
147 | |||
148 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
149 | ep->mem_res->phy_base = devm_ioremap_resource(dev, res); | ||
150 | if (IS_ERR(ep->mem_res->phy_base)) | ||
151 | return PTR_ERR(ep->mem_res->phy_base); | ||
152 | |||
153 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); | ||
154 | ep->mem_res->block_base = devm_ioremap_resource(dev, res); | ||
155 | if (IS_ERR(ep->mem_res->block_base)) | ||
156 | return PTR_ERR(ep->mem_res->block_base); | ||
157 | |||
158 | return 0; | 98 | return 0; |
159 | } | 99 | } |
160 | 100 | ||
@@ -279,111 +219,6 @@ static void exynos_pcie_deassert_core_reset(struct exynos_pcie *ep) | |||
279 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_NONSTICKY_RESET); | 219 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_NONSTICKY_RESET); |
280 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_APP_INIT_RESET); | 220 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_APP_INIT_RESET); |
281 | exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_APP_INIT_RESET); | 221 | exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_APP_INIT_RESET); |
282 | exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_MAC_RESET); | ||
283 | } | ||
284 | |||
285 | static void exynos_pcie_assert_phy_reset(struct exynos_pcie *ep) | ||
286 | { | ||
287 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_MAC_RESET); | ||
288 | exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_GLOBAL_RESET); | ||
289 | } | ||
290 | |||
291 | static void exynos_pcie_deassert_phy_reset(struct exynos_pcie *ep) | ||
292 | { | ||
293 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_GLOBAL_RESET); | ||
294 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_PWR_RESET); | ||
295 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_COMMON_RESET); | ||
296 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_CMN_REG); | ||
297 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_TRSVREG_RESET); | ||
298 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_TRSV_RESET); | ||
299 | } | ||
300 | |||
301 | static void exynos_pcie_power_on_phy(struct exynos_pcie *ep) | ||
302 | { | ||
303 | u32 val; | ||
304 | |||
305 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_COMMON_POWER); | ||
306 | val &= ~PCIE_PHY_COMMON_PD_CMN; | ||
307 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_COMMON_POWER); | ||
308 | |||
309 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV0_POWER); | ||
310 | val &= ~PCIE_PHY_TRSV0_PD_TSV; | ||
311 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV0_POWER); | ||
312 | |||
313 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV1_POWER); | ||
314 | val &= ~PCIE_PHY_TRSV1_PD_TSV; | ||
315 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV1_POWER); | ||
316 | |||
317 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV2_POWER); | ||
318 | val &= ~PCIE_PHY_TRSV2_PD_TSV; | ||
319 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV2_POWER); | ||
320 | |||
321 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV3_POWER); | ||
322 | val &= ~PCIE_PHY_TRSV3_PD_TSV; | ||
323 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV3_POWER); | ||
324 | } | ||
325 | |||
326 | static void exynos_pcie_power_off_phy(struct exynos_pcie *ep) | ||
327 | { | ||
328 | u32 val; | ||
329 | |||
330 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_COMMON_POWER); | ||
331 | val |= PCIE_PHY_COMMON_PD_CMN; | ||
332 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_COMMON_POWER); | ||
333 | |||
334 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV0_POWER); | ||
335 | val |= PCIE_PHY_TRSV0_PD_TSV; | ||
336 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV0_POWER); | ||
337 | |||
338 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV1_POWER); | ||
339 | val |= PCIE_PHY_TRSV1_PD_TSV; | ||
340 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV1_POWER); | ||
341 | |||
342 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV2_POWER); | ||
343 | val |= PCIE_PHY_TRSV2_PD_TSV; | ||
344 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV2_POWER); | ||
345 | |||
346 | val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV3_POWER); | ||
347 | val |= PCIE_PHY_TRSV3_PD_TSV; | ||
348 | exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV3_POWER); | ||
349 | } | ||
350 | |||
351 | static void exynos_pcie_init_phy(struct exynos_pcie *ep) | ||
352 | { | ||
353 | /* DCC feedback control off */ | ||
354 | exynos_pcie_writel(ep->mem_res->phy_base, 0x29, PCIE_PHY_DCC_FEEDBACK); | ||
355 | |||
356 | /* set TX/RX impedance */ | ||
357 | exynos_pcie_writel(ep->mem_res->phy_base, 0xd5, PCIE_PHY_IMPEDANCE); | ||
358 | |||
359 | /* set 50Mhz PHY clock */ | ||
360 | exynos_pcie_writel(ep->mem_res->phy_base, 0x14, PCIE_PHY_PLL_DIV_0); | ||
361 | exynos_pcie_writel(ep->mem_res->phy_base, 0x12, PCIE_PHY_PLL_DIV_1); | ||
362 | |||
363 | /* set TX Differential output for lane 0 */ | ||
364 | exynos_pcie_writel(ep->mem_res->phy_base, 0x7f, PCIE_PHY_TRSV0_DRV_LVL); | ||
365 | |||
366 | /* set TX Pre-emphasis Level Control for lane 0 to minimum */ | ||
367 | exynos_pcie_writel(ep->mem_res->phy_base, 0x0, PCIE_PHY_TRSV0_EMP_LVL); | ||
368 | |||
369 | /* set RX clock and data recovery bandwidth */ | ||
370 | exynos_pcie_writel(ep->mem_res->phy_base, 0xe7, PCIE_PHY_PLL_BIAS); | ||
371 | exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV0_RXCDR); | ||
372 | exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV1_RXCDR); | ||
373 | exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV2_RXCDR); | ||
374 | exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV3_RXCDR); | ||
375 | |||
376 | /* change TX Pre-emphasis Level Control for lanes */ | ||
377 | exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV0_EMP_LVL); | ||
378 | exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV1_EMP_LVL); | ||
379 | exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV2_EMP_LVL); | ||
380 | exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV3_EMP_LVL); | ||
381 | |||
382 | /* set LVCC */ | ||
383 | exynos_pcie_writel(ep->mem_res->phy_base, 0x20, PCIE_PHY_TRSV0_LVCC); | ||
384 | exynos_pcie_writel(ep->mem_res->phy_base, 0xa0, PCIE_PHY_TRSV1_LVCC); | ||
385 | exynos_pcie_writel(ep->mem_res->phy_base, 0xa0, PCIE_PHY_TRSV2_LVCC); | ||
386 | exynos_pcie_writel(ep->mem_res->phy_base, 0xa0, PCIE_PHY_TRSV3_LVCC); | ||
387 | } | 222 | } |
388 | 223 | ||
389 | static void exynos_pcie_assert_reset(struct exynos_pcie *ep) | 224 | static void exynos_pcie_assert_reset(struct exynos_pcie *ep) |
@@ -401,7 +236,6 @@ static int exynos_pcie_establish_link(struct exynos_pcie *ep) | |||
401 | struct dw_pcie *pci = ep->pci; | 236 | struct dw_pcie *pci = ep->pci; |
402 | struct pcie_port *pp = &pci->pp; | 237 | struct pcie_port *pp = &pci->pp; |
403 | struct device *dev = pci->dev; | 238 | struct device *dev = pci->dev; |
404 | u32 val; | ||
405 | 239 | ||
406 | if (dw_pcie_link_up(pci)) { | 240 | if (dw_pcie_link_up(pci)) { |
407 | dev_err(dev, "Link already up\n"); | 241 | dev_err(dev, "Link already up\n"); |
@@ -410,32 +244,13 @@ static int exynos_pcie_establish_link(struct exynos_pcie *ep) | |||
410 | 244 | ||
411 | exynos_pcie_assert_core_reset(ep); | 245 | exynos_pcie_assert_core_reset(ep); |
412 | 246 | ||
413 | if (ep->using_phy) { | 247 | phy_reset(ep->phy); |
414 | phy_reset(ep->phy); | ||
415 | |||
416 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, | ||
417 | PCIE_PWR_RESET); | ||
418 | |||
419 | phy_power_on(ep->phy); | ||
420 | phy_init(ep->phy); | ||
421 | } else { | ||
422 | exynos_pcie_assert_phy_reset(ep); | ||
423 | exynos_pcie_deassert_phy_reset(ep); | ||
424 | exynos_pcie_power_on_phy(ep); | ||
425 | exynos_pcie_init_phy(ep); | ||
426 | |||
427 | /* pulse for common reset */ | ||
428 | exynos_pcie_writel(ep->mem_res->block_base, 1, | ||
429 | PCIE_PHY_COMMON_RESET); | ||
430 | udelay(500); | ||
431 | exynos_pcie_writel(ep->mem_res->block_base, 0, | ||
432 | PCIE_PHY_COMMON_RESET); | ||
433 | } | ||
434 | 248 | ||
435 | /* pulse for common reset */ | 249 | exynos_pcie_writel(ep->mem_res->elbi_base, 1, |
436 | exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_COMMON_RESET); | 250 | PCIE_PWR_RESET); |
437 | udelay(500); | 251 | |
438 | exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_COMMON_RESET); | 252 | phy_power_on(ep->phy); |
253 | phy_init(ep->phy); | ||
439 | 254 | ||
440 | exynos_pcie_deassert_core_reset(ep); | 255 | exynos_pcie_deassert_core_reset(ep); |
441 | dw_pcie_setup_rc(pp); | 256 | dw_pcie_setup_rc(pp); |
@@ -449,18 +264,7 @@ static int exynos_pcie_establish_link(struct exynos_pcie *ep) | |||
449 | if (!dw_pcie_wait_for_link(pci)) | 264 | if (!dw_pcie_wait_for_link(pci)) |
450 | return 0; | 265 | return 0; |
451 | 266 | ||
452 | if (ep->using_phy) { | 267 | phy_power_off(ep->phy); |
453 | phy_power_off(ep->phy); | ||
454 | return -ETIMEDOUT; | ||
455 | } | ||
456 | |||
457 | while (exynos_pcie_readl(ep->mem_res->phy_base, | ||
458 | PCIE_PHY_PLL_LOCKED) == 0) { | ||
459 | val = exynos_pcie_readl(ep->mem_res->block_base, | ||
460 | PCIE_PHY_PLL_LOCKED); | ||
461 | dev_info(dev, "PLL Locked: 0x%x\n", val); | ||
462 | } | ||
463 | exynos_pcie_power_off_phy(ep); | ||
464 | return -ETIMEDOUT; | 268 | return -ETIMEDOUT; |
465 | } | 269 | } |
466 | 270 | ||
@@ -678,16 +482,13 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) | |||
678 | 482 | ||
679 | ep->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); | 483 | ep->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); |
680 | 484 | ||
681 | /* Assume that controller doesn't use the PHY framework */ | ||
682 | ep->using_phy = false; | ||
683 | |||
684 | ep->phy = devm_of_phy_get(dev, np, NULL); | 485 | ep->phy = devm_of_phy_get(dev, np, NULL); |
685 | if (IS_ERR(ep->phy)) { | 486 | if (IS_ERR(ep->phy)) { |
686 | if (PTR_ERR(ep->phy) == -EPROBE_DEFER) | 487 | if (PTR_ERR(ep->phy) == -EPROBE_DEFER) |
687 | return PTR_ERR(ep->phy); | 488 | return PTR_ERR(ep->phy); |
688 | dev_warn(dev, "Use the 'phy' property. Current DT of pci-exynos was deprecated!!\n"); | 489 | |
689 | } else | 490 | ep->phy = NULL; |
690 | ep->using_phy = true; | 491 | } |
691 | 492 | ||
692 | if (ep->ops && ep->ops->get_mem_resources) { | 493 | if (ep->ops && ep->ops->get_mem_resources) { |
693 | ret = ep->ops->get_mem_resources(pdev, ep); | 494 | ret = ep->ops->get_mem_resources(pdev, ep); |
@@ -695,7 +496,8 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) | |||
695 | return ret; | 496 | return ret; |
696 | } | 497 | } |
697 | 498 | ||
698 | if (ep->ops && ep->ops->get_clk_resources) { | 499 | if (ep->ops && ep->ops->get_clk_resources && |
500 | ep->ops->init_clk_resources) { | ||
699 | ret = ep->ops->get_clk_resources(ep); | 501 | ret = ep->ops->get_clk_resources(ep); |
700 | if (ret) | 502 | if (ret) |
701 | return ret; | 503 | return ret; |
@@ -713,8 +515,7 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) | |||
713 | return 0; | 515 | return 0; |
714 | 516 | ||
715 | fail_probe: | 517 | fail_probe: |
716 | if (ep->using_phy) | 518 | phy_exit(ep->phy); |
717 | phy_exit(ep->phy); | ||
718 | 519 | ||
719 | if (ep->ops && ep->ops->deinit_clk_resources) | 520 | if (ep->ops && ep->ops->deinit_clk_resources) |
720 | ep->ops->deinit_clk_resources(ep); | 521 | ep->ops->deinit_clk_resources(ep); |
diff --git a/drivers/pci/dwc/pci-imx6.c b/drivers/pci/dwc/pci-imx6.c index b73483534a5b..4fddbd08b089 100644 --- a/drivers/pci/dwc/pci-imx6.c +++ b/drivers/pci/dwc/pci-imx6.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Freescale i.MX6 SoCs | 3 | * PCIe host controller driver for Freescale i.MX6 SoCs |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * http://www.kosagi.com | 6 | * http://www.kosagi.com |
6 | * | 7 | * |
7 | * Author: Sean Cross <xobs@kosagi.com> | 8 | * Author: Sean Cross <xobs@kosagi.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/clk.h> | 11 | #include <linux/clk.h> |
diff --git a/drivers/pci/dwc/pci-keystone-dw.c b/drivers/pci/dwc/pci-keystone-dw.c index 2fb20b887d2a..99a0e7076221 100644 --- a/drivers/pci/dwc/pci-keystone-dw.c +++ b/drivers/pci/dwc/pci-keystone-dw.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * DesignWare application register space functions for Keystone PCI controller | 3 | * DesignWare application register space functions for Keystone PCI controller |
3 | * | 4 | * |
@@ -5,11 +6,6 @@ | |||
5 | * http://www.ti.com | 6 | * http://www.ti.com |
6 | * | 7 | * |
7 | * Author: Murali Karicheri <m-karicheri2@ti.com> | 8 | * Author: Murali Karicheri <m-karicheri2@ti.com> |
8 | * | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | 9 | */ |
14 | 10 | ||
15 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
diff --git a/drivers/pci/dwc/pci-keystone.c b/drivers/pci/dwc/pci-keystone.c index 5bee3af47588..d4f8ab90c018 100644 --- a/drivers/pci/dwc/pci-keystone.c +++ b/drivers/pci/dwc/pci-keystone.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Texas Instruments Keystone SoCs | 3 | * PCIe host controller driver for Texas Instruments Keystone SoCs |
3 | * | 4 | * |
@@ -6,10 +7,6 @@ | |||
6 | * | 7 | * |
7 | * Author: Murali Karicheri <m-karicheri2@ti.com> | 8 | * Author: Murali Karicheri <m-karicheri2@ti.com> |
8 | * Implementation based on pci-exynos.c and pcie-designware.c | 9 | * Implementation based on pci-exynos.c and pcie-designware.c |
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | 10 | */ |
14 | 11 | ||
15 | #include <linux/irqchip/chained_irq.h> | 12 | #include <linux/irqchip/chained_irq.h> |
@@ -178,7 +175,7 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, | |||
178 | } | 175 | } |
179 | 176 | ||
180 | /* interrupt controller is in a child node */ | 177 | /* interrupt controller is in a child node */ |
181 | *np_temp = of_find_node_by_name(np_pcie, controller); | 178 | *np_temp = of_get_child_by_name(np_pcie, controller); |
182 | if (!(*np_temp)) { | 179 | if (!(*np_temp)) { |
183 | dev_err(dev, "Node for %s is absent\n", controller); | 180 | dev_err(dev, "Node for %s is absent\n", controller); |
184 | return -EINVAL; | 181 | return -EINVAL; |
@@ -187,6 +184,7 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, | |||
187 | temp = of_irq_count(*np_temp); | 184 | temp = of_irq_count(*np_temp); |
188 | if (!temp) { | 185 | if (!temp) { |
189 | dev_err(dev, "No IRQ entries in %s\n", controller); | 186 | dev_err(dev, "No IRQ entries in %s\n", controller); |
187 | of_node_put(*np_temp); | ||
190 | return -EINVAL; | 188 | return -EINVAL; |
191 | } | 189 | } |
192 | 190 | ||
@@ -204,6 +202,8 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, | |||
204 | break; | 202 | break; |
205 | } | 203 | } |
206 | 204 | ||
205 | of_node_put(*np_temp); | ||
206 | |||
207 | if (temp) { | 207 | if (temp) { |
208 | *num_irqs = temp; | 208 | *num_irqs = temp; |
209 | return 0; | 209 | return 0; |
diff --git a/drivers/pci/dwc/pci-keystone.h b/drivers/pci/dwc/pci-keystone.h index 30b7bc2ac380..1dd1f3ef98e7 100644 --- a/drivers/pci/dwc/pci-keystone.h +++ b/drivers/pci/dwc/pci-keystone.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
1 | /* | 2 | /* |
2 | * Keystone PCI Controller's common includes | 3 | * Keystone PCI Controller's common includes |
3 | * | 4 | * |
@@ -5,11 +6,6 @@ | |||
5 | * http://www.ti.com | 6 | * http://www.ti.com |
6 | * | 7 | * |
7 | * Author: Murali Karicheri <m-karicheri2@ti.com> | 8 | * Author: Murali Karicheri <m-karicheri2@ti.com> |
8 | * | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | 9 | */ |
14 | 10 | ||
15 | #define MAX_MSI_HOST_IRQS 8 | 11 | #define MAX_MSI_HOST_IRQS 8 |
diff --git a/drivers/pci/dwc/pci-layerscape.c b/drivers/pci/dwc/pci-layerscape.c index 8f34c2fdc600..a7b4159631ae 100644 --- a/drivers/pci/dwc/pci-layerscape.c +++ b/drivers/pci/dwc/pci-layerscape.c | |||
@@ -1,13 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Freescale Layerscape SoCs | 3 | * PCIe host controller driver for Freescale Layerscape SoCs |
3 | * | 4 | * |
4 | * Copyright (C) 2014 Freescale Semiconductor. | 5 | * Copyright (C) 2014 Freescale Semiconductor. |
5 | * | 6 | * |
6 | * Author: Minghuan Lian <Minghuan.Lian@freescale.com> | 7 | * Author: Minghuan Lian <Minghuan.Lian@freescale.com> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | 8 | */ |
12 | 9 | ||
13 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
diff --git a/drivers/pci/dwc/pcie-armada8k.c b/drivers/pci/dwc/pcie-armada8k.c index 370d057c0046..b587352f8b9f 100644 --- a/drivers/pci/dwc/pcie-armada8k.c +++ b/drivers/pci/dwc/pcie-armada8k.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Marvell Armada-8K SoCs | 3 | * PCIe host controller driver for Marvell Armada-8K SoCs |
3 | * | 4 | * |
@@ -7,10 +8,6 @@ | |||
7 | * | 8 | * |
8 | * Author: Yehuda Yitshak <yehuday@marvell.com> | 9 | * Author: Yehuda Yitshak <yehuday@marvell.com> |
9 | * Author: Shadi Ammouri <shadi@marvell.com> | 10 | * Author: Shadi Ammouri <shadi@marvell.com> |
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public | ||
12 | * License version 2. This program is licensed "as is" without any | ||
13 | * warranty of any kind, whether express or implied. | ||
14 | */ | 11 | */ |
15 | 12 | ||
16 | #include <linux/clk.h> | 13 | #include <linux/clk.h> |
diff --git a/drivers/pci/dwc/pcie-artpec6.c b/drivers/pci/dwc/pcie-artpec6.c index 6653619db6a1..93b3df9ed1b5 100644 --- a/drivers/pci/dwc/pcie-artpec6.c +++ b/drivers/pci/dwc/pcie-artpec6.c | |||
@@ -1,18 +1,16 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Axis ARTPEC-6 SoC | 3 | * PCIe host controller driver for Axis ARTPEC-6 SoC |
3 | * | 4 | * |
4 | * Author: Niklas Cassel <niklas.cassel@axis.com> | 5 | * Author: Niklas Cassel <niklas.cassel@axis.com> |
5 | * | 6 | * |
6 | * Based on work done by Phil Edworthy <phil@edworthys.org> | 7 | * Based on work done by Phil Edworthy <phil@edworthys.org> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | 8 | */ |
12 | 9 | ||
13 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
14 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/of_device.h> | ||
16 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
17 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
18 | #include <linux/resource.h> | 16 | #include <linux/resource.h> |
@@ -26,44 +24,72 @@ | |||
26 | 24 | ||
27 | #define to_artpec6_pcie(x) dev_get_drvdata((x)->dev) | 25 | #define to_artpec6_pcie(x) dev_get_drvdata((x)->dev) |
28 | 26 | ||
27 | enum artpec_pcie_variants { | ||
28 | ARTPEC6, | ||
29 | ARTPEC7, | ||
30 | }; | ||
31 | |||
29 | struct artpec6_pcie { | 32 | struct artpec6_pcie { |
30 | struct dw_pcie *pci; | 33 | struct dw_pcie *pci; |
31 | struct regmap *regmap; /* DT axis,syscon-pcie */ | 34 | struct regmap *regmap; /* DT axis,syscon-pcie */ |
32 | void __iomem *phy_base; /* DT phy */ | 35 | void __iomem *phy_base; /* DT phy */ |
36 | enum artpec_pcie_variants variant; | ||
37 | enum dw_pcie_device_mode mode; | ||
33 | }; | 38 | }; |
34 | 39 | ||
40 | struct artpec_pcie_of_data { | ||
41 | enum artpec_pcie_variants variant; | ||
42 | enum dw_pcie_device_mode mode; | ||
43 | }; | ||
44 | |||
45 | static const struct of_device_id artpec6_pcie_of_match[]; | ||
46 | |||
35 | /* PCIe Port Logic registers (memory-mapped) */ | 47 | /* PCIe Port Logic registers (memory-mapped) */ |
36 | #define PL_OFFSET 0x700 | 48 | #define PL_OFFSET 0x700 |
37 | #define PCIE_PHY_DEBUG_R0 (PL_OFFSET + 0x28) | ||
38 | #define PCIE_PHY_DEBUG_R1 (PL_OFFSET + 0x2c) | ||
39 | 49 | ||
40 | #define MISC_CONTROL_1_OFF (PL_OFFSET + 0x1bc) | 50 | #define ACK_F_ASPM_CTRL_OFF (PL_OFFSET + 0xc) |
41 | #define DBI_RO_WR_EN 1 | 51 | #define ACK_N_FTS_MASK GENMASK(15, 8) |
52 | #define ACK_N_FTS(x) (((x) << 8) & ACK_N_FTS_MASK) | ||
53 | |||
54 | #define FAST_TRAINING_SEQ_MASK GENMASK(7, 0) | ||
55 | #define FAST_TRAINING_SEQ(x) (((x) << 0) & FAST_TRAINING_SEQ_MASK) | ||
42 | 56 | ||
43 | /* ARTPEC-6 specific registers */ | 57 | /* ARTPEC-6 specific registers */ |
44 | #define PCIECFG 0x18 | 58 | #define PCIECFG 0x18 |
45 | #define PCIECFG_DBG_OEN (1 << 24) | 59 | #define PCIECFG_DBG_OEN BIT(24) |
46 | #define PCIECFG_CORE_RESET_REQ (1 << 21) | 60 | #define PCIECFG_CORE_RESET_REQ BIT(21) |
47 | #define PCIECFG_LTSSM_ENABLE (1 << 20) | 61 | #define PCIECFG_LTSSM_ENABLE BIT(20) |
48 | #define PCIECFG_CLKREQ_B (1 << 11) | 62 | #define PCIECFG_DEVICE_TYPE_MASK GENMASK(19, 16) |
49 | #define PCIECFG_REFCLK_ENABLE (1 << 10) | 63 | #define PCIECFG_CLKREQ_B BIT(11) |
50 | #define PCIECFG_PLL_ENABLE (1 << 9) | 64 | #define PCIECFG_REFCLK_ENABLE BIT(10) |
51 | #define PCIECFG_PCLK_ENABLE (1 << 8) | 65 | #define PCIECFG_PLL_ENABLE BIT(9) |
52 | #define PCIECFG_RISRCREN (1 << 4) | 66 | #define PCIECFG_PCLK_ENABLE BIT(8) |
53 | #define PCIECFG_MODE_TX_DRV_EN (1 << 3) | 67 | #define PCIECFG_RISRCREN BIT(4) |
54 | #define PCIECFG_CISRREN (1 << 2) | 68 | #define PCIECFG_MODE_TX_DRV_EN BIT(3) |
55 | #define PCIECFG_MACRO_ENABLE (1 << 0) | 69 | #define PCIECFG_CISRREN BIT(2) |
70 | #define PCIECFG_MACRO_ENABLE BIT(0) | ||
71 | /* ARTPEC-7 specific fields */ | ||
72 | #define PCIECFG_REFCLKSEL BIT(23) | ||
73 | #define PCIECFG_NOC_RESET BIT(3) | ||
74 | |||
75 | #define PCIESTAT 0x1c | ||
76 | /* ARTPEC-7 specific fields */ | ||
77 | #define PCIESTAT_EXTREFCLK BIT(3) | ||
56 | 78 | ||
57 | #define NOCCFG 0x40 | 79 | #define NOCCFG 0x40 |
58 | #define NOCCFG_ENABLE_CLK_PCIE (1 << 4) | 80 | #define NOCCFG_ENABLE_CLK_PCIE BIT(4) |
59 | #define NOCCFG_POWER_PCIE_IDLEACK (1 << 3) | 81 | #define NOCCFG_POWER_PCIE_IDLEACK BIT(3) |
60 | #define NOCCFG_POWER_PCIE_IDLE (1 << 2) | 82 | #define NOCCFG_POWER_PCIE_IDLE BIT(2) |
61 | #define NOCCFG_POWER_PCIE_IDLEREQ (1 << 1) | 83 | #define NOCCFG_POWER_PCIE_IDLEREQ BIT(1) |
62 | 84 | ||
63 | #define PHY_STATUS 0x118 | 85 | #define PHY_STATUS 0x118 |
64 | #define PHY_COSPLLLOCK (1 << 0) | 86 | #define PHY_COSPLLLOCK BIT(0) |
87 | |||
88 | #define PHY_TX_ASIC_OUT 0x4040 | ||
89 | #define PHY_TX_ASIC_OUT_TX_ACK BIT(0) | ||
65 | 90 | ||
66 | #define ARTPEC6_CPU_TO_BUS_ADDR 0x0fffffff | 91 | #define PHY_RX_ASIC_OUT 0x405c |
92 | #define PHY_RX_ASIC_OUT_ACK BIT(0) | ||
67 | 93 | ||
68 | static u32 artpec6_pcie_readl(struct artpec6_pcie *artpec6_pcie, u32 offset) | 94 | static u32 artpec6_pcie_readl(struct artpec6_pcie *artpec6_pcie, u32 offset) |
69 | { | 95 | { |
@@ -78,22 +104,123 @@ static void artpec6_pcie_writel(struct artpec6_pcie *artpec6_pcie, u32 offset, u | |||
78 | regmap_write(artpec6_pcie->regmap, offset, val); | 104 | regmap_write(artpec6_pcie->regmap, offset, val); |
79 | } | 105 | } |
80 | 106 | ||
81 | static u64 artpec6_pcie_cpu_addr_fixup(u64 pci_addr) | 107 | static u64 artpec6_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 pci_addr) |
82 | { | 108 | { |
83 | return pci_addr & ARTPEC6_CPU_TO_BUS_ADDR; | 109 | struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); |
110 | struct pcie_port *pp = &pci->pp; | ||
111 | struct dw_pcie_ep *ep = &pci->ep; | ||
112 | |||
113 | switch (artpec6_pcie->mode) { | ||
114 | case DW_PCIE_RC_TYPE: | ||
115 | return pci_addr - pp->cfg0_base; | ||
116 | case DW_PCIE_EP_TYPE: | ||
117 | return pci_addr - ep->phys_base; | ||
118 | default: | ||
119 | dev_err(pci->dev, "UNKNOWN device type\n"); | ||
120 | } | ||
121 | return pci_addr; | ||
84 | } | 122 | } |
85 | 123 | ||
86 | static int artpec6_pcie_establish_link(struct artpec6_pcie *artpec6_pcie) | 124 | static int artpec6_pcie_establish_link(struct dw_pcie *pci) |
87 | { | 125 | { |
88 | struct dw_pcie *pci = artpec6_pcie->pci; | 126 | struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); |
89 | struct pcie_port *pp = &pci->pp; | 127 | u32 val; |
128 | |||
129 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); | ||
130 | val |= PCIECFG_LTSSM_ENABLE; | ||
131 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | static void artpec6_pcie_stop_link(struct dw_pcie *pci) | ||
137 | { | ||
138 | struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); | ||
90 | u32 val; | 139 | u32 val; |
91 | unsigned int retries; | ||
92 | 140 | ||
93 | /* Hold DW core in reset */ | ||
94 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); | 141 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); |
95 | val |= PCIECFG_CORE_RESET_REQ; | 142 | val &= ~PCIECFG_LTSSM_ENABLE; |
96 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); | 143 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); |
144 | } | ||
145 | |||
146 | static const struct dw_pcie_ops dw_pcie_ops = { | ||
147 | .cpu_addr_fixup = artpec6_pcie_cpu_addr_fixup, | ||
148 | .start_link = artpec6_pcie_establish_link, | ||
149 | .stop_link = artpec6_pcie_stop_link, | ||
150 | }; | ||
151 | |||
152 | static void artpec6_pcie_wait_for_phy_a6(struct artpec6_pcie *artpec6_pcie) | ||
153 | { | ||
154 | struct dw_pcie *pci = artpec6_pcie->pci; | ||
155 | struct device *dev = pci->dev; | ||
156 | u32 val; | ||
157 | unsigned int retries; | ||
158 | |||
159 | retries = 50; | ||
160 | do { | ||
161 | usleep_range(1000, 2000); | ||
162 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); | ||
163 | retries--; | ||
164 | } while (retries && | ||
165 | (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); | ||
166 | if (!retries) | ||
167 | dev_err(dev, "PCIe clock manager did not leave idle state\n"); | ||
168 | |||
169 | retries = 50; | ||
170 | do { | ||
171 | usleep_range(1000, 2000); | ||
172 | val = readl(artpec6_pcie->phy_base + PHY_STATUS); | ||
173 | retries--; | ||
174 | } while (retries && !(val & PHY_COSPLLLOCK)); | ||
175 | if (!retries) | ||
176 | dev_err(dev, "PHY PLL did not lock\n"); | ||
177 | } | ||
178 | |||
179 | static void artpec6_pcie_wait_for_phy_a7(struct artpec6_pcie *artpec6_pcie) | ||
180 | { | ||
181 | struct dw_pcie *pci = artpec6_pcie->pci; | ||
182 | struct device *dev = pci->dev; | ||
183 | u32 val; | ||
184 | u16 phy_status_tx, phy_status_rx; | ||
185 | unsigned int retries; | ||
186 | |||
187 | retries = 50; | ||
188 | do { | ||
189 | usleep_range(1000, 2000); | ||
190 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); | ||
191 | retries--; | ||
192 | } while (retries && | ||
193 | (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); | ||
194 | if (!retries) | ||
195 | dev_err(dev, "PCIe clock manager did not leave idle state\n"); | ||
196 | |||
197 | retries = 50; | ||
198 | do { | ||
199 | usleep_range(1000, 2000); | ||
200 | phy_status_tx = readw(artpec6_pcie->phy_base + PHY_TX_ASIC_OUT); | ||
201 | phy_status_rx = readw(artpec6_pcie->phy_base + PHY_RX_ASIC_OUT); | ||
202 | retries--; | ||
203 | } while (retries && ((phy_status_tx & PHY_TX_ASIC_OUT_TX_ACK) || | ||
204 | (phy_status_rx & PHY_RX_ASIC_OUT_ACK))); | ||
205 | if (!retries) | ||
206 | dev_err(dev, "PHY did not enter Pn state\n"); | ||
207 | } | ||
208 | |||
209 | static void artpec6_pcie_wait_for_phy(struct artpec6_pcie *artpec6_pcie) | ||
210 | { | ||
211 | switch (artpec6_pcie->variant) { | ||
212 | case ARTPEC6: | ||
213 | artpec6_pcie_wait_for_phy_a6(artpec6_pcie); | ||
214 | break; | ||
215 | case ARTPEC7: | ||
216 | artpec6_pcie_wait_for_phy_a7(artpec6_pcie); | ||
217 | break; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | static void artpec6_pcie_init_phy_a6(struct artpec6_pcie *artpec6_pcie) | ||
222 | { | ||
223 | u32 val; | ||
97 | 224 | ||
98 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); | 225 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); |
99 | val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ | 226 | val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ |
@@ -119,45 +246,110 @@ static int artpec6_pcie_establish_link(struct artpec6_pcie *artpec6_pcie) | |||
119 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); | 246 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); |
120 | val &= ~NOCCFG_POWER_PCIE_IDLEREQ; | 247 | val &= ~NOCCFG_POWER_PCIE_IDLEREQ; |
121 | artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); | 248 | artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); |
249 | } | ||
122 | 250 | ||
123 | retries = 50; | 251 | static void artpec6_pcie_init_phy_a7(struct artpec6_pcie *artpec6_pcie) |
124 | do { | 252 | { |
125 | usleep_range(1000, 2000); | 253 | struct dw_pcie *pci = artpec6_pcie->pci; |
126 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); | 254 | u32 val; |
127 | retries--; | 255 | bool extrefclk; |
128 | } while (retries && | ||
129 | (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); | ||
130 | 256 | ||
131 | retries = 50; | 257 | /* Check if external reference clock is connected */ |
132 | do { | 258 | val = artpec6_pcie_readl(artpec6_pcie, PCIESTAT); |
133 | usleep_range(1000, 2000); | 259 | extrefclk = !!(val & PCIESTAT_EXTREFCLK); |
134 | val = readl(artpec6_pcie->phy_base + PHY_STATUS); | 260 | dev_dbg(pci->dev, "Using reference clock: %s\n", |
135 | retries--; | 261 | extrefclk ? "external" : "internal"); |
136 | } while (retries && !(val & PHY_COSPLLLOCK)); | ||
137 | 262 | ||
138 | /* Take DW core out of reset */ | ||
139 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); | 263 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); |
140 | val &= ~PCIECFG_CORE_RESET_REQ; | 264 | val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ |
265 | PCIECFG_PCLK_ENABLE; | ||
266 | if (extrefclk) | ||
267 | val |= PCIECFG_REFCLKSEL; | ||
268 | else | ||
269 | val &= ~PCIECFG_REFCLKSEL; | ||
141 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); | 270 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); |
142 | usleep_range(100, 200); | 271 | usleep_range(10, 20); |
143 | 272 | ||
144 | /* setup root complex */ | 273 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); |
145 | dw_pcie_setup_rc(pp); | 274 | val |= NOCCFG_ENABLE_CLK_PCIE; |
275 | artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); | ||
276 | usleep_range(20, 30); | ||
277 | |||
278 | val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); | ||
279 | val &= ~NOCCFG_POWER_PCIE_IDLEREQ; | ||
280 | artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); | ||
281 | } | ||
282 | |||
283 | static void artpec6_pcie_init_phy(struct artpec6_pcie *artpec6_pcie) | ||
284 | { | ||
285 | switch (artpec6_pcie->variant) { | ||
286 | case ARTPEC6: | ||
287 | artpec6_pcie_init_phy_a6(artpec6_pcie); | ||
288 | break; | ||
289 | case ARTPEC7: | ||
290 | artpec6_pcie_init_phy_a7(artpec6_pcie); | ||
291 | break; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | static void artpec6_pcie_set_nfts(struct artpec6_pcie *artpec6_pcie) | ||
296 | { | ||
297 | struct dw_pcie *pci = artpec6_pcie->pci; | ||
298 | u32 val; | ||
299 | |||
300 | if (artpec6_pcie->variant != ARTPEC7) | ||
301 | return; | ||
302 | |||
303 | /* | ||
304 | * Increase the N_FTS (Number of Fast Training Sequences) | ||
305 | * to be transmitted when transitioning from L0s to L0. | ||
306 | */ | ||
307 | val = dw_pcie_readl_dbi(pci, ACK_F_ASPM_CTRL_OFF); | ||
308 | val &= ~ACK_N_FTS_MASK; | ||
309 | val |= ACK_N_FTS(180); | ||
310 | dw_pcie_writel_dbi(pci, ACK_F_ASPM_CTRL_OFF, val); | ||
311 | |||
312 | /* | ||
313 | * Set the Number of Fast Training Sequences that the core | ||
314 | * advertises as its N_FTS during Gen2 or Gen3 link training. | ||
315 | */ | ||
316 | val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL); | ||
317 | val &= ~FAST_TRAINING_SEQ_MASK; | ||
318 | val |= FAST_TRAINING_SEQ(180); | ||
319 | dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val); | ||
320 | } | ||
321 | |||
322 | static void artpec6_pcie_assert_core_reset(struct artpec6_pcie *artpec6_pcie) | ||
323 | { | ||
324 | u32 val; | ||
146 | 325 | ||
147 | /* assert LTSSM enable */ | ||
148 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); | 326 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); |
149 | val |= PCIECFG_LTSSM_ENABLE; | 327 | switch (artpec6_pcie->variant) { |
328 | case ARTPEC6: | ||
329 | val |= PCIECFG_CORE_RESET_REQ; | ||
330 | break; | ||
331 | case ARTPEC7: | ||
332 | val &= ~PCIECFG_NOC_RESET; | ||
333 | break; | ||
334 | } | ||
150 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); | 335 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); |
336 | } | ||
151 | 337 | ||
152 | /* check if the link is up or not */ | 338 | static void artpec6_pcie_deassert_core_reset(struct artpec6_pcie *artpec6_pcie) |
153 | if (!dw_pcie_wait_for_link(pci)) | 339 | { |
154 | return 0; | 340 | u32 val; |
155 | |||
156 | dev_dbg(pci->dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n", | ||
157 | dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R0), | ||
158 | dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R1)); | ||
159 | 341 | ||
160 | return -ETIMEDOUT; | 342 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); |
343 | switch (artpec6_pcie->variant) { | ||
344 | case ARTPEC6: | ||
345 | val &= ~PCIECFG_CORE_RESET_REQ; | ||
346 | break; | ||
347 | case ARTPEC7: | ||
348 | val |= PCIECFG_NOC_RESET; | ||
349 | break; | ||
350 | } | ||
351 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); | ||
352 | usleep_range(100, 200); | ||
161 | } | 353 | } |
162 | 354 | ||
163 | static void artpec6_pcie_enable_interrupts(struct artpec6_pcie *artpec6_pcie) | 355 | static void artpec6_pcie_enable_interrupts(struct artpec6_pcie *artpec6_pcie) |
@@ -174,7 +366,14 @@ static int artpec6_pcie_host_init(struct pcie_port *pp) | |||
174 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | 366 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); |
175 | struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); | 367 | struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); |
176 | 368 | ||
177 | artpec6_pcie_establish_link(artpec6_pcie); | 369 | artpec6_pcie_assert_core_reset(artpec6_pcie); |
370 | artpec6_pcie_init_phy(artpec6_pcie); | ||
371 | artpec6_pcie_deassert_core_reset(artpec6_pcie); | ||
372 | artpec6_pcie_wait_for_phy(artpec6_pcie); | ||
373 | artpec6_pcie_set_nfts(artpec6_pcie); | ||
374 | dw_pcie_setup_rc(pp); | ||
375 | artpec6_pcie_establish_link(pci); | ||
376 | dw_pcie_wait_for_link(pci); | ||
178 | artpec6_pcie_enable_interrupts(artpec6_pcie); | 377 | artpec6_pcie_enable_interrupts(artpec6_pcie); |
179 | 378 | ||
180 | return 0; | 379 | return 0; |
@@ -230,10 +429,78 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie, | |||
230 | return 0; | 429 | return 0; |
231 | } | 430 | } |
232 | 431 | ||
233 | static const struct dw_pcie_ops dw_pcie_ops = { | 432 | static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) |
234 | .cpu_addr_fixup = artpec6_pcie_cpu_addr_fixup, | 433 | { |
434 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | ||
435 | struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); | ||
436 | enum pci_barno bar; | ||
437 | |||
438 | artpec6_pcie_assert_core_reset(artpec6_pcie); | ||
439 | artpec6_pcie_init_phy(artpec6_pcie); | ||
440 | artpec6_pcie_deassert_core_reset(artpec6_pcie); | ||
441 | artpec6_pcie_wait_for_phy(artpec6_pcie); | ||
442 | artpec6_pcie_set_nfts(artpec6_pcie); | ||
443 | |||
444 | for (bar = BAR_0; bar <= BAR_5; bar++) | ||
445 | dw_pcie_ep_reset_bar(pci, bar); | ||
446 | } | ||
447 | |||
448 | static int artpec6_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no, | ||
449 | enum pci_epc_irq_type type, u8 interrupt_num) | ||
450 | { | ||
451 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | ||
452 | |||
453 | switch (type) { | ||
454 | case PCI_EPC_IRQ_LEGACY: | ||
455 | dev_err(pci->dev, "EP cannot trigger legacy IRQs\n"); | ||
456 | return -EINVAL; | ||
457 | case PCI_EPC_IRQ_MSI: | ||
458 | return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); | ||
459 | default: | ||
460 | dev_err(pci->dev, "UNKNOWN IRQ type\n"); | ||
461 | } | ||
462 | |||
463 | return 0; | ||
464 | } | ||
465 | |||
466 | static struct dw_pcie_ep_ops pcie_ep_ops = { | ||
467 | .ep_init = artpec6_pcie_ep_init, | ||
468 | .raise_irq = artpec6_pcie_raise_irq, | ||
235 | }; | 469 | }; |
236 | 470 | ||
471 | static int artpec6_add_pcie_ep(struct artpec6_pcie *artpec6_pcie, | ||
472 | struct platform_device *pdev) | ||
473 | { | ||
474 | int ret; | ||
475 | struct dw_pcie_ep *ep; | ||
476 | struct resource *res; | ||
477 | struct device *dev = &pdev->dev; | ||
478 | struct dw_pcie *pci = artpec6_pcie->pci; | ||
479 | |||
480 | ep = &pci->ep; | ||
481 | ep->ops = &pcie_ep_ops; | ||
482 | |||
483 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi2"); | ||
484 | pci->dbi_base2 = devm_ioremap(dev, res->start, resource_size(res)); | ||
485 | if (!pci->dbi_base2) | ||
486 | return -ENOMEM; | ||
487 | |||
488 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); | ||
489 | if (!res) | ||
490 | return -EINVAL; | ||
491 | |||
492 | ep->phys_base = res->start; | ||
493 | ep->addr_size = resource_size(res); | ||
494 | |||
495 | ret = dw_pcie_ep_init(ep); | ||
496 | if (ret) { | ||
497 | dev_err(dev, "failed to initialize endpoint\n"); | ||
498 | return ret; | ||
499 | } | ||
500 | |||
501 | return 0; | ||
502 | } | ||
503 | |||
237 | static int artpec6_pcie_probe(struct platform_device *pdev) | 504 | static int artpec6_pcie_probe(struct platform_device *pdev) |
238 | { | 505 | { |
239 | struct device *dev = &pdev->dev; | 506 | struct device *dev = &pdev->dev; |
@@ -242,6 +509,18 @@ static int artpec6_pcie_probe(struct platform_device *pdev) | |||
242 | struct resource *dbi_base; | 509 | struct resource *dbi_base; |
243 | struct resource *phy_base; | 510 | struct resource *phy_base; |
244 | int ret; | 511 | int ret; |
512 | const struct of_device_id *match; | ||
513 | const struct artpec_pcie_of_data *data; | ||
514 | enum artpec_pcie_variants variant; | ||
515 | enum dw_pcie_device_mode mode; | ||
516 | |||
517 | match = of_match_device(artpec6_pcie_of_match, dev); | ||
518 | if (!match) | ||
519 | return -EINVAL; | ||
520 | |||
521 | data = (struct artpec_pcie_of_data *)match->data; | ||
522 | variant = (enum artpec_pcie_variants)data->variant; | ||
523 | mode = (enum dw_pcie_device_mode)data->mode; | ||
245 | 524 | ||
246 | artpec6_pcie = devm_kzalloc(dev, sizeof(*artpec6_pcie), GFP_KERNEL); | 525 | artpec6_pcie = devm_kzalloc(dev, sizeof(*artpec6_pcie), GFP_KERNEL); |
247 | if (!artpec6_pcie) | 526 | if (!artpec6_pcie) |
@@ -255,6 +534,8 @@ static int artpec6_pcie_probe(struct platform_device *pdev) | |||
255 | pci->ops = &dw_pcie_ops; | 534 | pci->ops = &dw_pcie_ops; |
256 | 535 | ||
257 | artpec6_pcie->pci = pci; | 536 | artpec6_pcie->pci = pci; |
537 | artpec6_pcie->variant = variant; | ||
538 | artpec6_pcie->mode = mode; | ||
258 | 539 | ||
259 | dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); | 540 | dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); |
260 | pci->dbi_base = devm_ioremap_resource(dev, dbi_base); | 541 | pci->dbi_base = devm_ioremap_resource(dev, dbi_base); |
@@ -274,15 +555,73 @@ static int artpec6_pcie_probe(struct platform_device *pdev) | |||
274 | 555 | ||
275 | platform_set_drvdata(pdev, artpec6_pcie); | 556 | platform_set_drvdata(pdev, artpec6_pcie); |
276 | 557 | ||
277 | ret = artpec6_add_pcie_port(artpec6_pcie, pdev); | 558 | switch (artpec6_pcie->mode) { |
278 | if (ret < 0) | 559 | case DW_PCIE_RC_TYPE: |
279 | return ret; | 560 | if (!IS_ENABLED(CONFIG_PCIE_ARTPEC6_HOST)) |
561 | return -ENODEV; | ||
562 | |||
563 | ret = artpec6_add_pcie_port(artpec6_pcie, pdev); | ||
564 | if (ret < 0) | ||
565 | return ret; | ||
566 | break; | ||
567 | case DW_PCIE_EP_TYPE: { | ||
568 | u32 val; | ||
569 | |||
570 | if (!IS_ENABLED(CONFIG_PCIE_ARTPEC6_EP)) | ||
571 | return -ENODEV; | ||
572 | |||
573 | val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); | ||
574 | val &= ~PCIECFG_DEVICE_TYPE_MASK; | ||
575 | artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); | ||
576 | ret = artpec6_add_pcie_ep(artpec6_pcie, pdev); | ||
577 | if (ret < 0) | ||
578 | return ret; | ||
579 | break; | ||
580 | } | ||
581 | default: | ||
582 | dev_err(dev, "INVALID device type %d\n", artpec6_pcie->mode); | ||
583 | } | ||
280 | 584 | ||
281 | return 0; | 585 | return 0; |
282 | } | 586 | } |
283 | 587 | ||
588 | static const struct artpec_pcie_of_data artpec6_pcie_rc_of_data = { | ||
589 | .variant = ARTPEC6, | ||
590 | .mode = DW_PCIE_RC_TYPE, | ||
591 | }; | ||
592 | |||
593 | static const struct artpec_pcie_of_data artpec6_pcie_ep_of_data = { | ||
594 | .variant = ARTPEC6, | ||
595 | .mode = DW_PCIE_EP_TYPE, | ||
596 | }; | ||
597 | |||
598 | static const struct artpec_pcie_of_data artpec7_pcie_rc_of_data = { | ||
599 | .variant = ARTPEC7, | ||
600 | .mode = DW_PCIE_RC_TYPE, | ||
601 | }; | ||
602 | |||
603 | static const struct artpec_pcie_of_data artpec7_pcie_ep_of_data = { | ||
604 | .variant = ARTPEC7, | ||
605 | .mode = DW_PCIE_EP_TYPE, | ||
606 | }; | ||
607 | |||
284 | static const struct of_device_id artpec6_pcie_of_match[] = { | 608 | static const struct of_device_id artpec6_pcie_of_match[] = { |
285 | { .compatible = "axis,artpec6-pcie", }, | 609 | { |
610 | .compatible = "axis,artpec6-pcie", | ||
611 | .data = &artpec6_pcie_rc_of_data, | ||
612 | }, | ||
613 | { | ||
614 | .compatible = "axis,artpec6-pcie-ep", | ||
615 | .data = &artpec6_pcie_ep_of_data, | ||
616 | }, | ||
617 | { | ||
618 | .compatible = "axis,artpec7-pcie", | ||
619 | .data = &artpec7_pcie_rc_of_data, | ||
620 | }, | ||
621 | { | ||
622 | .compatible = "axis,artpec7-pcie-ep", | ||
623 | .data = &artpec7_pcie_ep_of_data, | ||
624 | }, | ||
286 | {}, | 625 | {}, |
287 | }; | 626 | }; |
288 | 627 | ||
diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index d53d5f168363..3a6feeff5f5b 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c | |||
@@ -1,20 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * Synopsys DesignWare PCIe Endpoint controller driver | 3 | * Synopsys DesignWare PCIe Endpoint controller driver |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/of.h> | 9 | #include <linux/of.h> |
@@ -30,21 +19,24 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) | |||
30 | pci_epc_linkup(epc); | 19 | pci_epc_linkup(epc); |
31 | } | 20 | } |
32 | 21 | ||
33 | static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) | 22 | void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) |
34 | { | 23 | { |
35 | u32 reg; | 24 | u32 reg; |
36 | 25 | ||
37 | reg = PCI_BASE_ADDRESS_0 + (4 * bar); | 26 | reg = PCI_BASE_ADDRESS_0 + (4 * bar); |
27 | dw_pcie_dbi_ro_wr_en(pci); | ||
38 | dw_pcie_writel_dbi2(pci, reg, 0x0); | 28 | dw_pcie_writel_dbi2(pci, reg, 0x0); |
39 | dw_pcie_writel_dbi(pci, reg, 0x0); | 29 | dw_pcie_writel_dbi(pci, reg, 0x0); |
30 | dw_pcie_dbi_ro_wr_dis(pci); | ||
40 | } | 31 | } |
41 | 32 | ||
42 | static int dw_pcie_ep_write_header(struct pci_epc *epc, | 33 | static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, |
43 | struct pci_epf_header *hdr) | 34 | struct pci_epf_header *hdr) |
44 | { | 35 | { |
45 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); | 36 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); |
46 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 37 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
47 | 38 | ||
39 | dw_pcie_dbi_ro_wr_en(pci); | ||
48 | dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); | 40 | dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); |
49 | dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); | 41 | dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); |
50 | dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); | 42 | dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); |
@@ -58,6 +50,7 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, | |||
58 | dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); | 50 | dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); |
59 | dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, | 51 | dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, |
60 | hdr->interrupt_pin); | 52 | hdr->interrupt_pin); |
53 | dw_pcie_dbi_ro_wr_dis(pci); | ||
61 | 54 | ||
62 | return 0; | 55 | return 0; |
63 | } | 56 | } |
@@ -70,8 +63,7 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, | |||
70 | u32 free_win; | 63 | u32 free_win; |
71 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 64 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
72 | 65 | ||
73 | free_win = find_first_zero_bit(&ep->ib_window_map, | 66 | free_win = find_first_zero_bit(ep->ib_window_map, ep->num_ib_windows); |
74 | sizeof(ep->ib_window_map)); | ||
75 | if (free_win >= ep->num_ib_windows) { | 67 | if (free_win >= ep->num_ib_windows) { |
76 | dev_err(pci->dev, "no free inbound window\n"); | 68 | dev_err(pci->dev, "no free inbound window\n"); |
77 | return -EINVAL; | 69 | return -EINVAL; |
@@ -85,7 +77,7 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, | |||
85 | } | 77 | } |
86 | 78 | ||
87 | ep->bar_to_atu[bar] = free_win; | 79 | ep->bar_to_atu[bar] = free_win; |
88 | set_bit(free_win, &ep->ib_window_map); | 80 | set_bit(free_win, ep->ib_window_map); |
89 | 81 | ||
90 | return 0; | 82 | return 0; |
91 | } | 83 | } |
@@ -96,8 +88,7 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, phys_addr_t phys_addr, | |||
96 | u32 free_win; | 88 | u32 free_win; |
97 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 89 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
98 | 90 | ||
99 | free_win = find_first_zero_bit(&ep->ob_window_map, | 91 | free_win = find_first_zero_bit(ep->ob_window_map, ep->num_ob_windows); |
100 | sizeof(ep->ob_window_map)); | ||
101 | if (free_win >= ep->num_ob_windows) { | 92 | if (free_win >= ep->num_ob_windows) { |
102 | dev_err(pci->dev, "no free outbound window\n"); | 93 | dev_err(pci->dev, "no free outbound window\n"); |
103 | return -EINVAL; | 94 | return -EINVAL; |
@@ -106,13 +97,14 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, phys_addr_t phys_addr, | |||
106 | dw_pcie_prog_outbound_atu(pci, free_win, PCIE_ATU_TYPE_MEM, | 97 | dw_pcie_prog_outbound_atu(pci, free_win, PCIE_ATU_TYPE_MEM, |
107 | phys_addr, pci_addr, size); | 98 | phys_addr, pci_addr, size); |
108 | 99 | ||
109 | set_bit(free_win, &ep->ob_window_map); | 100 | set_bit(free_win, ep->ob_window_map); |
110 | ep->outbound_addr[free_win] = phys_addr; | 101 | ep->outbound_addr[free_win] = phys_addr; |
111 | 102 | ||
112 | return 0; | 103 | return 0; |
113 | } | 104 | } |
114 | 105 | ||
115 | static void dw_pcie_ep_clear_bar(struct pci_epc *epc, enum pci_barno bar) | 106 | static void dw_pcie_ep_clear_bar(struct pci_epc *epc, u8 func_no, |
107 | enum pci_barno bar) | ||
116 | { | 108 | { |
117 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); | 109 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); |
118 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 110 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
@@ -121,10 +113,11 @@ static void dw_pcie_ep_clear_bar(struct pci_epc *epc, enum pci_barno bar) | |||
121 | dw_pcie_ep_reset_bar(pci, bar); | 113 | dw_pcie_ep_reset_bar(pci, bar); |
122 | 114 | ||
123 | dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_INBOUND); | 115 | dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_INBOUND); |
124 | clear_bit(atu_index, &ep->ib_window_map); | 116 | clear_bit(atu_index, ep->ib_window_map); |
125 | } | 117 | } |
126 | 118 | ||
127 | static int dw_pcie_ep_set_bar(struct pci_epc *epc, enum pci_barno bar, | 119 | static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, |
120 | enum pci_barno bar, | ||
128 | dma_addr_t bar_phys, size_t size, int flags) | 121 | dma_addr_t bar_phys, size_t size, int flags) |
129 | { | 122 | { |
130 | int ret; | 123 | int ret; |
@@ -142,8 +135,10 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, enum pci_barno bar, | |||
142 | if (ret) | 135 | if (ret) |
143 | return ret; | 136 | return ret; |
144 | 137 | ||
138 | dw_pcie_dbi_ro_wr_en(pci); | ||
145 | dw_pcie_writel_dbi2(pci, reg, size - 1); | 139 | dw_pcie_writel_dbi2(pci, reg, size - 1); |
146 | dw_pcie_writel_dbi(pci, reg, flags); | 140 | dw_pcie_writel_dbi(pci, reg, flags); |
141 | dw_pcie_dbi_ro_wr_dis(pci); | ||
147 | 142 | ||
148 | return 0; | 143 | return 0; |
149 | } | 144 | } |
@@ -163,7 +158,8 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr, | |||
163 | return -EINVAL; | 158 | return -EINVAL; |
164 | } | 159 | } |
165 | 160 | ||
166 | static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, phys_addr_t addr) | 161 | static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, u8 func_no, |
162 | phys_addr_t addr) | ||
167 | { | 163 | { |
168 | int ret; | 164 | int ret; |
169 | u32 atu_index; | 165 | u32 atu_index; |
@@ -175,10 +171,11 @@ static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, phys_addr_t addr) | |||
175 | return; | 171 | return; |
176 | 172 | ||
177 | dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_OUTBOUND); | 173 | dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_OUTBOUND); |
178 | clear_bit(atu_index, &ep->ob_window_map); | 174 | clear_bit(atu_index, ep->ob_window_map); |
179 | } | 175 | } |
180 | 176 | ||
181 | static int dw_pcie_ep_map_addr(struct pci_epc *epc, phys_addr_t addr, | 177 | static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, |
178 | phys_addr_t addr, | ||
182 | u64 pci_addr, size_t size) | 179 | u64 pci_addr, size_t size) |
183 | { | 180 | { |
184 | int ret; | 181 | int ret; |
@@ -194,39 +191,37 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, phys_addr_t addr, | |||
194 | return 0; | 191 | return 0; |
195 | } | 192 | } |
196 | 193 | ||
197 | static int dw_pcie_ep_get_msi(struct pci_epc *epc) | 194 | static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no) |
198 | { | 195 | { |
199 | int val; | 196 | int val; |
200 | u32 lower_addr; | ||
201 | u32 upper_addr; | ||
202 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); | 197 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); |
203 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 198 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
204 | 199 | ||
205 | val = dw_pcie_readb_dbi(pci, MSI_MESSAGE_CONTROL); | 200 | val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); |
206 | val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; | 201 | if (!(val & MSI_CAP_MSI_EN_MASK)) |
207 | |||
208 | lower_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); | ||
209 | upper_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); | ||
210 | |||
211 | if (!(lower_addr || upper_addr)) | ||
212 | return -EINVAL; | 202 | return -EINVAL; |
213 | 203 | ||
204 | val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; | ||
214 | return val; | 205 | return val; |
215 | } | 206 | } |
216 | 207 | ||
217 | static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 encode_int) | 208 | static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 encode_int) |
218 | { | 209 | { |
219 | int val; | 210 | int val; |
220 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); | 211 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); |
221 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 212 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
222 | 213 | ||
223 | val = (encode_int << MSI_CAP_MMC_SHIFT); | 214 | val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); |
215 | val &= ~MSI_CAP_MMC_MASK; | ||
216 | val |= (encode_int << MSI_CAP_MMC_SHIFT) & MSI_CAP_MMC_MASK; | ||
217 | dw_pcie_dbi_ro_wr_en(pci); | ||
224 | dw_pcie_writew_dbi(pci, MSI_MESSAGE_CONTROL, val); | 218 | dw_pcie_writew_dbi(pci, MSI_MESSAGE_CONTROL, val); |
219 | dw_pcie_dbi_ro_wr_dis(pci); | ||
225 | 220 | ||
226 | return 0; | 221 | return 0; |
227 | } | 222 | } |
228 | 223 | ||
229 | static int dw_pcie_ep_raise_irq(struct pci_epc *epc, | 224 | static int dw_pcie_ep_raise_irq(struct pci_epc *epc, u8 func_no, |
230 | enum pci_epc_irq_type type, u8 interrupt_num) | 225 | enum pci_epc_irq_type type, u8 interrupt_num) |
231 | { | 226 | { |
232 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); | 227 | struct dw_pcie_ep *ep = epc_get_drvdata(epc); |
@@ -234,7 +229,7 @@ static int dw_pcie_ep_raise_irq(struct pci_epc *epc, | |||
234 | if (!ep->ops->raise_irq) | 229 | if (!ep->ops->raise_irq) |
235 | return -EINVAL; | 230 | return -EINVAL; |
236 | 231 | ||
237 | return ep->ops->raise_irq(ep, type, interrupt_num); | 232 | return ep->ops->raise_irq(ep, func_no, type, interrupt_num); |
238 | } | 233 | } |
239 | 234 | ||
240 | static void dw_pcie_ep_stop(struct pci_epc *epc) | 235 | static void dw_pcie_ep_stop(struct pci_epc *epc) |
@@ -272,10 +267,48 @@ static const struct pci_epc_ops epc_ops = { | |||
272 | .stop = dw_pcie_ep_stop, | 267 | .stop = dw_pcie_ep_stop, |
273 | }; | 268 | }; |
274 | 269 | ||
270 | int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, | ||
271 | u8 interrupt_num) | ||
272 | { | ||
273 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | ||
274 | struct pci_epc *epc = ep->epc; | ||
275 | u16 msg_ctrl, msg_data; | ||
276 | u32 msg_addr_lower, msg_addr_upper; | ||
277 | u64 msg_addr; | ||
278 | bool has_upper; | ||
279 | int ret; | ||
280 | |||
281 | /* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */ | ||
282 | msg_ctrl = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); | ||
283 | has_upper = !!(msg_ctrl & PCI_MSI_FLAGS_64BIT); | ||
284 | msg_addr_lower = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); | ||
285 | if (has_upper) { | ||
286 | msg_addr_upper = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); | ||
287 | msg_data = dw_pcie_readw_dbi(pci, MSI_MESSAGE_DATA_64); | ||
288 | } else { | ||
289 | msg_addr_upper = 0; | ||
290 | msg_data = dw_pcie_readw_dbi(pci, MSI_MESSAGE_DATA_32); | ||
291 | } | ||
292 | msg_addr = ((u64) msg_addr_upper) << 32 | msg_addr_lower; | ||
293 | ret = dw_pcie_ep_map_addr(epc, func_no, ep->msi_mem_phys, msg_addr, | ||
294 | epc->mem->page_size); | ||
295 | if (ret) | ||
296 | return ret; | ||
297 | |||
298 | writel(msg_data | (interrupt_num - 1), ep->msi_mem); | ||
299 | |||
300 | dw_pcie_ep_unmap_addr(epc, func_no, ep->msi_mem_phys); | ||
301 | |||
302 | return 0; | ||
303 | } | ||
304 | |||
275 | void dw_pcie_ep_exit(struct dw_pcie_ep *ep) | 305 | void dw_pcie_ep_exit(struct dw_pcie_ep *ep) |
276 | { | 306 | { |
277 | struct pci_epc *epc = ep->epc; | 307 | struct pci_epc *epc = ep->epc; |
278 | 308 | ||
309 | pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem, | ||
310 | epc->mem->page_size); | ||
311 | |||
279 | pci_epc_mem_exit(epc); | 312 | pci_epc_mem_exit(epc); |
280 | } | 313 | } |
281 | 314 | ||
@@ -298,12 +331,32 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
298 | dev_err(dev, "unable to read *num-ib-windows* property\n"); | 331 | dev_err(dev, "unable to read *num-ib-windows* property\n"); |
299 | return ret; | 332 | return ret; |
300 | } | 333 | } |
334 | if (ep->num_ib_windows > MAX_IATU_IN) { | ||
335 | dev_err(dev, "invalid *num-ib-windows*\n"); | ||
336 | return -EINVAL; | ||
337 | } | ||
301 | 338 | ||
302 | ret = of_property_read_u32(np, "num-ob-windows", &ep->num_ob_windows); | 339 | ret = of_property_read_u32(np, "num-ob-windows", &ep->num_ob_windows); |
303 | if (ret < 0) { | 340 | if (ret < 0) { |
304 | dev_err(dev, "unable to read *num-ob-windows* property\n"); | 341 | dev_err(dev, "unable to read *num-ob-windows* property\n"); |
305 | return ret; | 342 | return ret; |
306 | } | 343 | } |
344 | if (ep->num_ob_windows > MAX_IATU_OUT) { | ||
345 | dev_err(dev, "invalid *num-ob-windows*\n"); | ||
346 | return -EINVAL; | ||
347 | } | ||
348 | |||
349 | ep->ib_window_map = devm_kzalloc(dev, sizeof(long) * | ||
350 | BITS_TO_LONGS(ep->num_ib_windows), | ||
351 | GFP_KERNEL); | ||
352 | if (!ep->ib_window_map) | ||
353 | return -ENOMEM; | ||
354 | |||
355 | ep->ob_window_map = devm_kzalloc(dev, sizeof(long) * | ||
356 | BITS_TO_LONGS(ep->num_ob_windows), | ||
357 | GFP_KERNEL); | ||
358 | if (!ep->ob_window_map) | ||
359 | return -ENOMEM; | ||
307 | 360 | ||
308 | addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows, | 361 | addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows, |
309 | GFP_KERNEL); | 362 | GFP_KERNEL); |
@@ -331,6 +384,13 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
331 | return ret; | 384 | return ret; |
332 | } | 385 | } |
333 | 386 | ||
387 | ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, | ||
388 | epc->mem->page_size); | ||
389 | if (!ep->msi_mem) { | ||
390 | dev_err(dev, "Failed to reserve memory for MSI\n"); | ||
391 | return -ENOMEM; | ||
392 | } | ||
393 | |||
334 | ep->epc = epc; | 394 | ep->epc = epc; |
335 | epc_set_drvdata(epc, ep); | 395 | epc_set_drvdata(epc, ep); |
336 | dw_pcie_setup(pci); | 396 | dw_pcie_setup(pci); |
diff --git a/drivers/pci/dwc/pcie-designware-host.c b/drivers/pci/dwc/pcie-designware-host.c index 81e2157a7cfb..8de2d5c69b1d 100644 --- a/drivers/pci/dwc/pcie-designware-host.c +++ b/drivers/pci/dwc/pcie-designware-host.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Synopsys DesignWare PCIe host controller driver | 3 | * Synopsys DesignWare PCIe host controller driver |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * http://www.samsung.com | 6 | * http://www.samsung.com |
6 | * | 7 | * |
7 | * Author: Jingoo Han <jg1.han@samsung.com> | 8 | * Author: Jingoo Han <jg1.han@samsung.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/irqdomain.h> | 11 | #include <linux/irqdomain.h> |
@@ -83,10 +80,19 @@ irqreturn_t dw_handle_msi_irq(struct pcie_port *pp) | |||
83 | 80 | ||
84 | void dw_pcie_msi_init(struct pcie_port *pp) | 81 | void dw_pcie_msi_init(struct pcie_port *pp) |
85 | { | 82 | { |
83 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | ||
84 | struct device *dev = pci->dev; | ||
85 | struct page *page; | ||
86 | u64 msi_target; | 86 | u64 msi_target; |
87 | 87 | ||
88 | pp->msi_data = __get_free_pages(GFP_KERNEL, 0); | 88 | page = alloc_page(GFP_KERNEL); |
89 | msi_target = virt_to_phys((void *)pp->msi_data); | 89 | pp->msi_data = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE); |
90 | if (dma_mapping_error(dev, pp->msi_data)) { | ||
91 | dev_err(dev, "failed to map MSI data\n"); | ||
92 | __free_page(page); | ||
93 | return; | ||
94 | } | ||
95 | msi_target = (u64)pp->msi_data; | ||
90 | 96 | ||
91 | /* program the msi_data */ | 97 | /* program the msi_data */ |
92 | dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4, | 98 | dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4, |
@@ -187,7 +193,7 @@ static void dw_msi_setup_msg(struct pcie_port *pp, unsigned int irq, u32 pos) | |||
187 | if (pp->ops->get_msi_addr) | 193 | if (pp->ops->get_msi_addr) |
188 | msi_target = pp->ops->get_msi_addr(pp); | 194 | msi_target = pp->ops->get_msi_addr(pp); |
189 | else | 195 | else |
190 | msi_target = virt_to_phys((void *)pp->msi_data); | 196 | msi_target = (u64)pp->msi_data; |
191 | 197 | ||
192 | msg.address_lo = (u32)(msi_target & 0xffffffff); | 198 | msg.address_lo = (u32)(msi_target & 0xffffffff); |
193 | msg.address_hi = (u32)(msi_target >> 32 & 0xffffffff); | 199 | msg.address_hi = (u32)(msi_target >> 32 & 0xffffffff); |
diff --git a/drivers/pci/dwc/pcie-designware-plat.c b/drivers/pci/dwc/pcie-designware-plat.c index 168e2380f493..ebdf28bcd67d 100644 --- a/drivers/pci/dwc/pcie-designware-plat.c +++ b/drivers/pci/dwc/pcie-designware-plat.c | |||
@@ -1,13 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe RC driver for Synopsys DesignWare Core | 3 | * PCIe RC driver for Synopsys DesignWare Core |
3 | * | 4 | * |
4 | * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) | 5 | * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) |
5 | * | 6 | * |
6 | * Authors: Joao Pinto <Joao.Pinto@synopsys.com> | 7 | * Authors: Joao Pinto <Joao.Pinto@synopsys.com> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | 8 | */ |
12 | #include <linux/clk.h> | 9 | #include <linux/clk.h> |
13 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
diff --git a/drivers/pci/dwc/pcie-designware.c b/drivers/pci/dwc/pcie-designware.c index 88abdddee2ad..1b7282e5b494 100644 --- a/drivers/pci/dwc/pcie-designware.c +++ b/drivers/pci/dwc/pcie-designware.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Synopsys DesignWare PCIe host controller driver | 3 | * Synopsys DesignWare PCIe host controller driver |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * http://www.samsung.com | 6 | * http://www.samsung.com |
6 | * | 7 | * |
7 | * Author: Jingoo Han <jg1.han@samsung.com> | 8 | * Author: Jingoo Han <jg1.han@samsung.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
@@ -149,7 +146,7 @@ void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, | |||
149 | u32 retries, val; | 146 | u32 retries, val; |
150 | 147 | ||
151 | if (pci->ops->cpu_addr_fixup) | 148 | if (pci->ops->cpu_addr_fixup) |
152 | cpu_addr = pci->ops->cpu_addr_fixup(cpu_addr); | 149 | cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr); |
153 | 150 | ||
154 | if (pci->iatu_unroll_enabled) { | 151 | if (pci->iatu_unroll_enabled) { |
155 | dw_pcie_prog_outbound_atu_unroll(pci, index, type, cpu_addr, | 152 | dw_pcie_prog_outbound_atu_unroll(pci, index, type, cpu_addr, |
diff --git a/drivers/pci/dwc/pcie-designware.h b/drivers/pci/dwc/pcie-designware.h index e5d9d77b778e..11b13864a406 100644 --- a/drivers/pci/dwc/pcie-designware.h +++ b/drivers/pci/dwc/pcie-designware.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
1 | /* | 2 | /* |
2 | * Synopsys DesignWare PCIe host controller driver | 3 | * Synopsys DesignWare PCIe host controller driver |
3 | * | 4 | * |
@@ -5,15 +6,12 @@ | |||
5 | * http://www.samsung.com | 6 | * http://www.samsung.com |
6 | * | 7 | * |
7 | * Author: Jingoo Han <jg1.han@samsung.com> | 8 | * Author: Jingoo Han <jg1.han@samsung.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #ifndef _PCIE_DESIGNWARE_H | 11 | #ifndef _PCIE_DESIGNWARE_H |
15 | #define _PCIE_DESIGNWARE_H | 12 | #define _PCIE_DESIGNWARE_H |
16 | 13 | ||
14 | #include <linux/dma-mapping.h> | ||
17 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
18 | #include <linux/msi.h> | 16 | #include <linux/msi.h> |
19 | #include <linux/pci.h> | 17 | #include <linux/pci.h> |
@@ -100,10 +98,14 @@ | |||
100 | 98 | ||
101 | #define MSI_MESSAGE_CONTROL 0x52 | 99 | #define MSI_MESSAGE_CONTROL 0x52 |
102 | #define MSI_CAP_MMC_SHIFT 1 | 100 | #define MSI_CAP_MMC_SHIFT 1 |
101 | #define MSI_CAP_MMC_MASK (7 << MSI_CAP_MMC_SHIFT) | ||
103 | #define MSI_CAP_MME_SHIFT 4 | 102 | #define MSI_CAP_MME_SHIFT 4 |
103 | #define MSI_CAP_MSI_EN_MASK 0x1 | ||
104 | #define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) | 104 | #define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) |
105 | #define MSI_MESSAGE_ADDR_L32 0x54 | 105 | #define MSI_MESSAGE_ADDR_L32 0x54 |
106 | #define MSI_MESSAGE_ADDR_U32 0x58 | 106 | #define MSI_MESSAGE_ADDR_U32 0x58 |
107 | #define MSI_MESSAGE_DATA_32 0x58 | ||
108 | #define MSI_MESSAGE_DATA_64 0x5C | ||
107 | 109 | ||
108 | /* | 110 | /* |
109 | * Maximum number of MSI IRQs can be 256 per controller. But keep | 111 | * Maximum number of MSI IRQs can be 256 per controller. But keep |
@@ -113,6 +115,10 @@ | |||
113 | #define MAX_MSI_IRQS 32 | 115 | #define MAX_MSI_IRQS 32 |
114 | #define MAX_MSI_CTRLS (MAX_MSI_IRQS / 32) | 116 | #define MAX_MSI_CTRLS (MAX_MSI_IRQS / 32) |
115 | 117 | ||
118 | /* Maximum number of inbound/outbound iATUs */ | ||
119 | #define MAX_IATU_IN 256 | ||
120 | #define MAX_IATU_OUT 256 | ||
121 | |||
116 | struct pcie_port; | 122 | struct pcie_port; |
117 | struct dw_pcie; | 123 | struct dw_pcie; |
118 | struct dw_pcie_ep; | 124 | struct dw_pcie_ep; |
@@ -168,7 +174,7 @@ struct pcie_port { | |||
168 | const struct dw_pcie_host_ops *ops; | 174 | const struct dw_pcie_host_ops *ops; |
169 | int msi_irq; | 175 | int msi_irq; |
170 | struct irq_domain *irq_domain; | 176 | struct irq_domain *irq_domain; |
171 | unsigned long msi_data; | 177 | dma_addr_t msi_data; |
172 | DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); | 178 | DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); |
173 | }; | 179 | }; |
174 | 180 | ||
@@ -180,8 +186,8 @@ enum dw_pcie_as_type { | |||
180 | 186 | ||
181 | struct dw_pcie_ep_ops { | 187 | struct dw_pcie_ep_ops { |
182 | void (*ep_init)(struct dw_pcie_ep *ep); | 188 | void (*ep_init)(struct dw_pcie_ep *ep); |
183 | int (*raise_irq)(struct dw_pcie_ep *ep, enum pci_epc_irq_type type, | 189 | int (*raise_irq)(struct dw_pcie_ep *ep, u8 func_no, |
184 | u8 interrupt_num); | 190 | enum pci_epc_irq_type type, u8 interrupt_num); |
185 | }; | 191 | }; |
186 | 192 | ||
187 | struct dw_pcie_ep { | 193 | struct dw_pcie_ep { |
@@ -192,14 +198,16 @@ struct dw_pcie_ep { | |||
192 | size_t page_size; | 198 | size_t page_size; |
193 | u8 bar_to_atu[6]; | 199 | u8 bar_to_atu[6]; |
194 | phys_addr_t *outbound_addr; | 200 | phys_addr_t *outbound_addr; |
195 | unsigned long ib_window_map; | 201 | unsigned long *ib_window_map; |
196 | unsigned long ob_window_map; | 202 | unsigned long *ob_window_map; |
197 | u32 num_ib_windows; | 203 | u32 num_ib_windows; |
198 | u32 num_ob_windows; | 204 | u32 num_ob_windows; |
205 | void __iomem *msi_mem; | ||
206 | phys_addr_t msi_mem_phys; | ||
199 | }; | 207 | }; |
200 | 208 | ||
201 | struct dw_pcie_ops { | 209 | struct dw_pcie_ops { |
202 | u64 (*cpu_addr_fixup)(u64 cpu_addr); | 210 | u64 (*cpu_addr_fixup)(struct dw_pcie *pcie, u64 cpu_addr); |
203 | u32 (*read_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, | 211 | u32 (*read_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, |
204 | size_t size); | 212 | size_t size); |
205 | void (*write_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, | 213 | void (*write_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, |
@@ -334,6 +342,9 @@ static inline int dw_pcie_host_init(struct pcie_port *pp) | |||
334 | void dw_pcie_ep_linkup(struct dw_pcie_ep *ep); | 342 | void dw_pcie_ep_linkup(struct dw_pcie_ep *ep); |
335 | int dw_pcie_ep_init(struct dw_pcie_ep *ep); | 343 | int dw_pcie_ep_init(struct dw_pcie_ep *ep); |
336 | void dw_pcie_ep_exit(struct dw_pcie_ep *ep); | 344 | void dw_pcie_ep_exit(struct dw_pcie_ep *ep); |
345 | int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, | ||
346 | u8 interrupt_num); | ||
347 | void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); | ||
337 | #else | 348 | #else |
338 | static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) | 349 | static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) |
339 | { | 350 | { |
@@ -347,5 +358,15 @@ static inline int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
347 | static inline void dw_pcie_ep_exit(struct dw_pcie_ep *ep) | 358 | static inline void dw_pcie_ep_exit(struct dw_pcie_ep *ep) |
348 | { | 359 | { |
349 | } | 360 | } |
361 | |||
362 | static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, | ||
363 | u8 interrupt_num) | ||
364 | { | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) | ||
369 | { | ||
370 | } | ||
350 | #endif | 371 | #endif |
351 | #endif /* _PCIE_DESIGNWARE_H */ | 372 | #endif /* _PCIE_DESIGNWARE_H */ |
diff --git a/drivers/pci/dwc/pcie-hisi.c b/drivers/pci/dwc/pcie-hisi.c index a20179169e06..2658aaebb993 100644 --- a/drivers/pci/dwc/pcie-hisi.c +++ b/drivers/pci/dwc/pcie-hisi.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for HiSilicon SoCs | 3 | * PCIe host controller driver for HiSilicon SoCs |
3 | * | 4 | * |
@@ -6,10 +7,6 @@ | |||
6 | * Authors: Zhou Wang <wangzhou1@hisilicon.com> | 7 | * Authors: Zhou Wang <wangzhou1@hisilicon.com> |
7 | * Dacai Zhu <zhudacai@hisilicon.com> | 8 | * Dacai Zhu <zhudacai@hisilicon.com> |
8 | * Gabriele Paoloni <gabriele.paoloni@huawei.com> | 9 | * Gabriele Paoloni <gabriele.paoloni@huawei.com> |
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | 10 | */ |
14 | #include <linux/interrupt.h> | 11 | #include <linux/interrupt.h> |
15 | #include <linux/init.h> | 12 | #include <linux/init.h> |
diff --git a/drivers/pci/dwc/pcie-histb.c b/drivers/pci/dwc/pcie-histb.c index 33b01b734d7d..70b5c0b108bf 100644 --- a/drivers/pci/dwc/pcie-histb.c +++ b/drivers/pci/dwc/pcie-histb.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for HiSilicon STB SoCs | 3 | * PCIe host controller driver for HiSilicon STB SoCs |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * | 6 | * |
6 | * Authors: Ruqiang Ju <juruqiang@hisilicon.com> | 7 | * Authors: Ruqiang Ju <juruqiang@hisilicon.com> |
7 | * Jianguo Sun <sunjianguo1@huawei.com> | 8 | * Jianguo Sun <sunjianguo1@huawei.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/clk.h> | 11 | #include <linux/clk.h> |
diff --git a/drivers/pci/dwc/pcie-kirin.c b/drivers/pci/dwc/pcie-kirin.c index dc3033cf3c19..13d839bd6160 100644 --- a/drivers/pci/dwc/pcie-kirin.c +++ b/drivers/pci/dwc/pcie-kirin.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Kirin Phone SoCs | 3 | * PCIe host controller driver for Kirin Phone SoCs |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * http://www.huawei.com | 6 | * http://www.huawei.com |
6 | * | 7 | * |
7 | * Author: Xiaowei Song <songxiaowei@huawei.com> | 8 | * Author: Xiaowei Song <songxiaowei@huawei.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <asm/compiler.h> | 11 | #include <asm/compiler.h> |
diff --git a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c index ce7ba5b7552a..6310c66e265c 100644 --- a/drivers/pci/dwc/pcie-qcom.c +++ b/drivers/pci/dwc/pcie-qcom.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Qualcomm PCIe root complex driver | 3 | * Qualcomm PCIe root complex driver |
3 | * | 4 | * |
@@ -5,15 +6,6 @@ | |||
5 | * Copyright 2015 Linaro Limited. | 6 | * Copyright 2015 Linaro Limited. |
6 | * | 7 | * |
7 | * Author: Stanimir Varbanov <svarbanov@mm-sol.com> | 8 | * Author: Stanimir Varbanov <svarbanov@mm-sol.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 and | ||
11 | * only version 2 as published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | */ | 9 | */ |
18 | 10 | ||
19 | #include <linux/clk.h> | 11 | #include <linux/clk.h> |
@@ -171,7 +163,7 @@ struct qcom_pcie { | |||
171 | union qcom_pcie_resources res; | 163 | union qcom_pcie_resources res; |
172 | struct phy *phy; | 164 | struct phy *phy; |
173 | struct gpio_desc *reset; | 165 | struct gpio_desc *reset; |
174 | struct qcom_pcie_ops *ops; | 166 | const struct qcom_pcie_ops *ops; |
175 | }; | 167 | }; |
176 | 168 | ||
177 | #define to_qcom_pcie(x) dev_get_drvdata((x)->dev) | 169 | #define to_qcom_pcie(x) dev_get_drvdata((x)->dev) |
@@ -1234,7 +1226,7 @@ static int qcom_pcie_probe(struct platform_device *pdev) | |||
1234 | 1226 | ||
1235 | pcie->pci = pci; | 1227 | pcie->pci = pci; |
1236 | 1228 | ||
1237 | pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev); | 1229 | pcie->ops = of_device_get_match_data(dev); |
1238 | 1230 | ||
1239 | pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); | 1231 | pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); |
1240 | if (IS_ERR(pcie->reset)) | 1232 | if (IS_ERR(pcie->reset)) |
diff --git a/drivers/pci/dwc/pcie-spear13xx.c b/drivers/pci/dwc/pcie-spear13xx.c index 709189d23b31..ecb58f7b7566 100644 --- a/drivers/pci/dwc/pcie-spear13xx.c +++ b/drivers/pci/dwc/pcie-spear13xx.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for ST Microelectronics SPEAr13xx SoCs | 3 | * PCIe host controller driver for ST Microelectronics SPEAr13xx SoCs |
3 | * | 4 | * |
@@ -6,10 +7,6 @@ | |||
6 | * Copyright (C) 2010-2014 ST Microelectronics | 7 | * Copyright (C) 2010-2014 ST Microelectronics |
7 | * Pratyush Anand <pratyush.anand@gmail.com> | 8 | * Pratyush Anand <pratyush.anand@gmail.com> |
8 | * Mohit Kumar <mohit.kumar.dhaka@gmail.com> | 9 | * Mohit Kumar <mohit.kumar.dhaka@gmail.com> |
9 | * | ||
10 | * This file is licensed under the terms of the GNU General Public | ||
11 | * License version 2. This program is licensed "as is" without any | ||
12 | * warranty of any kind, whether express or implied. | ||
13 | */ | 10 | */ |
14 | 11 | ||
15 | #include <linux/clk.h> | 12 | #include <linux/clk.h> |
diff --git a/drivers/pci/ecam.c b/drivers/pci/ecam.c index c228a2eb7faa..1a81af0ba961 100644 --- a/drivers/pci/ecam.c +++ b/drivers/pci/ecam.c | |||
@@ -1,17 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright 2016 Broadcom | 3 | * Copyright 2016 Broadcom |
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License, version 2, as | ||
6 | * published by the Free Software Foundation (the "GPL"). | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | * General Public License version 2 (GPLv2) for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * version 2 (GPLv2) along with this source code. | ||
15 | */ | 4 | */ |
16 | 5 | ||
17 | #include <linux/device.h> | 6 | #include <linux/device.h> |
diff --git a/drivers/pci/endpoint/Kconfig b/drivers/pci/endpoint/Kconfig index c09623ca8c3b..d1e7e4199432 100644 --- a/drivers/pci/endpoint/Kconfig +++ b/drivers/pci/endpoint/Kconfig | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI Endpoint Support | 3 | # PCI Endpoint Support |
3 | # | 4 | # |
diff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile index 1041f80a4645..95b2fe47e3b0 100644 --- a/drivers/pci/endpoint/Makefile +++ b/drivers/pci/endpoint/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # Makefile for PCI Endpoint Support | 3 | # Makefile for PCI Endpoint Support |
3 | # | 4 | # |
diff --git a/drivers/pci/endpoint/functions/Kconfig b/drivers/pci/endpoint/functions/Kconfig index 2942066607e0..8820d0f7ec77 100644 --- a/drivers/pci/endpoint/functions/Kconfig +++ b/drivers/pci/endpoint/functions/Kconfig | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI Endpoint Functions | 3 | # PCI Endpoint Functions |
3 | # | 4 | # |
diff --git a/drivers/pci/endpoint/functions/Makefile b/drivers/pci/endpoint/functions/Makefile index 6d94a4801838..d6fafff080e2 100644 --- a/drivers/pci/endpoint/functions/Makefile +++ b/drivers/pci/endpoint/functions/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # Makefile for PCI Endpoint Functions | 3 | # Makefile for PCI Endpoint Functions |
3 | # | 4 | # |
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index f9308c2f22e6..64d8a17f8094 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c | |||
@@ -1,20 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * Test driver to test endpoint functionality | 3 | * Test driver to test endpoint functionality |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/crc32.h> | 9 | #include <linux/crc32.h> |
@@ -104,7 +93,8 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) | |||
104 | goto err; | 93 | goto err; |
105 | } | 94 | } |
106 | 95 | ||
107 | ret = pci_epc_map_addr(epc, src_phys_addr, reg->src_addr, reg->size); | 96 | ret = pci_epc_map_addr(epc, epf->func_no, src_phys_addr, reg->src_addr, |
97 | reg->size); | ||
108 | if (ret) { | 98 | if (ret) { |
109 | dev_err(dev, "failed to map source address\n"); | 99 | dev_err(dev, "failed to map source address\n"); |
110 | reg->status = STATUS_SRC_ADDR_INVALID; | 100 | reg->status = STATUS_SRC_ADDR_INVALID; |
@@ -119,7 +109,8 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) | |||
119 | goto err_src_map_addr; | 109 | goto err_src_map_addr; |
120 | } | 110 | } |
121 | 111 | ||
122 | ret = pci_epc_map_addr(epc, dst_phys_addr, reg->dst_addr, reg->size); | 112 | ret = pci_epc_map_addr(epc, epf->func_no, dst_phys_addr, reg->dst_addr, |
113 | reg->size); | ||
123 | if (ret) { | 114 | if (ret) { |
124 | dev_err(dev, "failed to map destination address\n"); | 115 | dev_err(dev, "failed to map destination address\n"); |
125 | reg->status = STATUS_DST_ADDR_INVALID; | 116 | reg->status = STATUS_DST_ADDR_INVALID; |
@@ -128,13 +119,13 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) | |||
128 | 119 | ||
129 | memcpy(dst_addr, src_addr, reg->size); | 120 | memcpy(dst_addr, src_addr, reg->size); |
130 | 121 | ||
131 | pci_epc_unmap_addr(epc, dst_phys_addr); | 122 | pci_epc_unmap_addr(epc, epf->func_no, dst_phys_addr); |
132 | 123 | ||
133 | err_dst_addr: | 124 | err_dst_addr: |
134 | pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size); | 125 | pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size); |
135 | 126 | ||
136 | err_src_map_addr: | 127 | err_src_map_addr: |
137 | pci_epc_unmap_addr(epc, src_phys_addr); | 128 | pci_epc_unmap_addr(epc, epf->func_no, src_phys_addr); |
138 | 129 | ||
139 | err_src_addr: | 130 | err_src_addr: |
140 | pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size); | 131 | pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size); |
@@ -164,7 +155,8 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) | |||
164 | goto err; | 155 | goto err; |
165 | } | 156 | } |
166 | 157 | ||
167 | ret = pci_epc_map_addr(epc, phys_addr, reg->src_addr, reg->size); | 158 | ret = pci_epc_map_addr(epc, epf->func_no, phys_addr, reg->src_addr, |
159 | reg->size); | ||
168 | if (ret) { | 160 | if (ret) { |
169 | dev_err(dev, "failed to map address\n"); | 161 | dev_err(dev, "failed to map address\n"); |
170 | reg->status = STATUS_SRC_ADDR_INVALID; | 162 | reg->status = STATUS_SRC_ADDR_INVALID; |
@@ -186,7 +178,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) | |||
186 | kfree(buf); | 178 | kfree(buf); |
187 | 179 | ||
188 | err_map_addr: | 180 | err_map_addr: |
189 | pci_epc_unmap_addr(epc, phys_addr); | 181 | pci_epc_unmap_addr(epc, epf->func_no, phys_addr); |
190 | 182 | ||
191 | err_addr: | 183 | err_addr: |
192 | pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size); | 184 | pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size); |
@@ -215,7 +207,8 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) | |||
215 | goto err; | 207 | goto err; |
216 | } | 208 | } |
217 | 209 | ||
218 | ret = pci_epc_map_addr(epc, phys_addr, reg->dst_addr, reg->size); | 210 | ret = pci_epc_map_addr(epc, epf->func_no, phys_addr, reg->dst_addr, |
211 | reg->size); | ||
219 | if (ret) { | 212 | if (ret) { |
220 | dev_err(dev, "failed to map address\n"); | 213 | dev_err(dev, "failed to map address\n"); |
221 | reg->status = STATUS_DST_ADDR_INVALID; | 214 | reg->status = STATUS_DST_ADDR_INVALID; |
@@ -242,7 +235,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) | |||
242 | kfree(buf); | 235 | kfree(buf); |
243 | 236 | ||
244 | err_map_addr: | 237 | err_map_addr: |
245 | pci_epc_unmap_addr(epc, phys_addr); | 238 | pci_epc_unmap_addr(epc, epf->func_no, phys_addr); |
246 | 239 | ||
247 | err_addr: | 240 | err_addr: |
248 | pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size); | 241 | pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size); |
@@ -260,11 +253,11 @@ static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq) | |||
260 | struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; | 253 | struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; |
261 | 254 | ||
262 | reg->status |= STATUS_IRQ_RAISED; | 255 | reg->status |= STATUS_IRQ_RAISED; |
263 | msi_count = pci_epc_get_msi(epc); | 256 | msi_count = pci_epc_get_msi(epc, epf->func_no); |
264 | if (irq > msi_count || msi_count <= 0) | 257 | if (irq > msi_count || msi_count <= 0) |
265 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); | 258 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_LEGACY, 0); |
266 | else | 259 | else |
267 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_MSI, irq); | 260 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_MSI, irq); |
268 | } | 261 | } |
269 | 262 | ||
270 | static void pci_epf_test_cmd_handler(struct work_struct *work) | 263 | static void pci_epf_test_cmd_handler(struct work_struct *work) |
@@ -291,7 +284,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) | |||
291 | 284 | ||
292 | if (command & COMMAND_RAISE_LEGACY_IRQ) { | 285 | if (command & COMMAND_RAISE_LEGACY_IRQ) { |
293 | reg->status = STATUS_IRQ_RAISED; | 286 | reg->status = STATUS_IRQ_RAISED; |
294 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); | 287 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_LEGACY, 0); |
295 | goto reset_handler; | 288 | goto reset_handler; |
296 | } | 289 | } |
297 | 290 | ||
@@ -326,11 +319,11 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) | |||
326 | } | 319 | } |
327 | 320 | ||
328 | if (command & COMMAND_RAISE_MSI_IRQ) { | 321 | if (command & COMMAND_RAISE_MSI_IRQ) { |
329 | msi_count = pci_epc_get_msi(epc); | 322 | msi_count = pci_epc_get_msi(epc, epf->func_no); |
330 | if (irq > msi_count || msi_count <= 0) | 323 | if (irq > msi_count || msi_count <= 0) |
331 | goto reset_handler; | 324 | goto reset_handler; |
332 | reg->status = STATUS_IRQ_RAISED; | 325 | reg->status = STATUS_IRQ_RAISED; |
333 | pci_epc_raise_irq(epc, PCI_EPC_IRQ_MSI, irq); | 326 | pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_MSI, irq); |
334 | goto reset_handler; | 327 | goto reset_handler; |
335 | } | 328 | } |
336 | 329 | ||
@@ -358,7 +351,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf) | |||
358 | for (bar = BAR_0; bar <= BAR_5; bar++) { | 351 | for (bar = BAR_0; bar <= BAR_5; bar++) { |
359 | if (epf_test->reg[bar]) { | 352 | if (epf_test->reg[bar]) { |
360 | pci_epf_free_space(epf, epf_test->reg[bar], bar); | 353 | pci_epf_free_space(epf, epf_test->reg[bar], bar); |
361 | pci_epc_clear_bar(epc, bar); | 354 | pci_epc_clear_bar(epc, epf->func_no, bar); |
362 | } | 355 | } |
363 | } | 356 | } |
364 | } | 357 | } |
@@ -380,7 +373,8 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) | |||
380 | 373 | ||
381 | for (bar = BAR_0; bar <= BAR_5; bar++) { | 374 | for (bar = BAR_0; bar <= BAR_5; bar++) { |
382 | epf_bar = &epf->bar[bar]; | 375 | epf_bar = &epf->bar[bar]; |
383 | ret = pci_epc_set_bar(epc, bar, epf_bar->phys_addr, | 376 | ret = pci_epc_set_bar(epc, epf->func_no, bar, |
377 | epf_bar->phys_addr, | ||
384 | epf_bar->size, flags); | 378 | epf_bar->size, flags); |
385 | if (ret) { | 379 | if (ret) { |
386 | pci_epf_free_space(epf, epf_test->reg[bar], bar); | 380 | pci_epf_free_space(epf, epf_test->reg[bar], bar); |
@@ -433,7 +427,7 @@ static int pci_epf_test_bind(struct pci_epf *epf) | |||
433 | if (WARN_ON_ONCE(!epc)) | 427 | if (WARN_ON_ONCE(!epc)) |
434 | return -EINVAL; | 428 | return -EINVAL; |
435 | 429 | ||
436 | ret = pci_epc_write_header(epc, header); | 430 | ret = pci_epc_write_header(epc, epf->func_no, header); |
437 | if (ret) { | 431 | if (ret) { |
438 | dev_err(dev, "configuration header write failed\n"); | 432 | dev_err(dev, "configuration header write failed\n"); |
439 | return ret; | 433 | return ret; |
@@ -447,7 +441,7 @@ static int pci_epf_test_bind(struct pci_epf *epf) | |||
447 | if (ret) | 441 | if (ret) |
448 | return ret; | 442 | return ret; |
449 | 443 | ||
450 | ret = pci_epc_set_msi(epc, epf->msi_interrupts); | 444 | ret = pci_epc_set_msi(epc, epf->func_no, epf->msi_interrupts); |
451 | if (ret) | 445 | if (ret) |
452 | return ret; | 446 | return ret; |
453 | 447 | ||
diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index 4f74386c1ced..018ea3433cb5 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c | |||
@@ -1,35 +1,28 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * configfs to configure the PCI endpoint | 3 | * configfs to configure the PCI endpoint |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/idr.h> | ||
21 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
22 | 12 | ||
23 | #include <linux/pci-epc.h> | 13 | #include <linux/pci-epc.h> |
24 | #include <linux/pci-epf.h> | 14 | #include <linux/pci-epf.h> |
25 | #include <linux/pci-ep-cfs.h> | 15 | #include <linux/pci-ep-cfs.h> |
26 | 16 | ||
17 | static DEFINE_IDR(functions_idr); | ||
18 | static DEFINE_MUTEX(functions_mutex); | ||
27 | static struct config_group *functions_group; | 19 | static struct config_group *functions_group; |
28 | static struct config_group *controllers_group; | 20 | static struct config_group *controllers_group; |
29 | 21 | ||
30 | struct pci_epf_group { | 22 | struct pci_epf_group { |
31 | struct config_group group; | 23 | struct config_group group; |
32 | struct pci_epf *epf; | 24 | struct pci_epf *epf; |
25 | int index; | ||
33 | }; | 26 | }; |
34 | 27 | ||
35 | struct pci_epc_group { | 28 | struct pci_epc_group { |
@@ -97,22 +90,23 @@ static int pci_epc_epf_link(struct config_item *epc_item, | |||
97 | { | 90 | { |
98 | int ret; | 91 | int ret; |
99 | u32 func_no = 0; | 92 | u32 func_no = 0; |
100 | struct pci_epc *epc; | ||
101 | struct pci_epf *epf; | ||
102 | struct pci_epf_group *epf_group = to_pci_epf_group(epf_item); | 93 | struct pci_epf_group *epf_group = to_pci_epf_group(epf_item); |
103 | struct pci_epc_group *epc_group = to_pci_epc_group(epc_item); | 94 | struct pci_epc_group *epc_group = to_pci_epc_group(epc_item); |
104 | 95 | struct pci_epc *epc = epc_group->epc; | |
105 | epc = epc_group->epc; | 96 | struct pci_epf *epf = epf_group->epf; |
106 | epf = epf_group->epf; | ||
107 | ret = pci_epc_add_epf(epc, epf); | ||
108 | if (ret) | ||
109 | goto err_add_epf; | ||
110 | 97 | ||
111 | func_no = find_first_zero_bit(&epc_group->function_num_map, | 98 | func_no = find_first_zero_bit(&epc_group->function_num_map, |
112 | sizeof(epc_group->function_num_map)); | 99 | BITS_PER_LONG); |
100 | if (func_no >= BITS_PER_LONG) | ||
101 | return -EINVAL; | ||
102 | |||
113 | set_bit(func_no, &epc_group->function_num_map); | 103 | set_bit(func_no, &epc_group->function_num_map); |
114 | epf->func_no = func_no; | 104 | epf->func_no = func_no; |
115 | 105 | ||
106 | ret = pci_epc_add_epf(epc, epf); | ||
107 | if (ret) | ||
108 | goto err_add_epf; | ||
109 | |||
116 | ret = pci_epf_bind(epf); | 110 | ret = pci_epf_bind(epf); |
117 | if (ret) | 111 | if (ret) |
118 | goto err_epf_bind; | 112 | goto err_epf_bind; |
@@ -353,6 +347,9 @@ static void pci_epf_release(struct config_item *item) | |||
353 | { | 347 | { |
354 | struct pci_epf_group *epf_group = to_pci_epf_group(item); | 348 | struct pci_epf_group *epf_group = to_pci_epf_group(item); |
355 | 349 | ||
350 | mutex_lock(&functions_mutex); | ||
351 | idr_remove(&functions_idr, epf_group->index); | ||
352 | mutex_unlock(&functions_mutex); | ||
356 | pci_epf_destroy(epf_group->epf); | 353 | pci_epf_destroy(epf_group->epf); |
357 | kfree(epf_group); | 354 | kfree(epf_group); |
358 | } | 355 | } |
@@ -372,22 +369,57 @@ static struct config_group *pci_epf_make(struct config_group *group, | |||
372 | { | 369 | { |
373 | struct pci_epf_group *epf_group; | 370 | struct pci_epf_group *epf_group; |
374 | struct pci_epf *epf; | 371 | struct pci_epf *epf; |
372 | char *epf_name; | ||
373 | int index, err; | ||
375 | 374 | ||
376 | epf_group = kzalloc(sizeof(*epf_group), GFP_KERNEL); | 375 | epf_group = kzalloc(sizeof(*epf_group), GFP_KERNEL); |
377 | if (!epf_group) | 376 | if (!epf_group) |
378 | return ERR_PTR(-ENOMEM); | 377 | return ERR_PTR(-ENOMEM); |
379 | 378 | ||
379 | mutex_lock(&functions_mutex); | ||
380 | index = idr_alloc(&functions_idr, epf_group, 0, 0, GFP_KERNEL); | ||
381 | mutex_unlock(&functions_mutex); | ||
382 | if (index < 0) { | ||
383 | err = index; | ||
384 | goto free_group; | ||
385 | } | ||
386 | |||
387 | epf_group->index = index; | ||
388 | |||
380 | config_group_init_type_name(&epf_group->group, name, &pci_epf_type); | 389 | config_group_init_type_name(&epf_group->group, name, &pci_epf_type); |
381 | 390 | ||
382 | epf = pci_epf_create(group->cg_item.ci_name); | 391 | epf_name = kasprintf(GFP_KERNEL, "%s.%d", |
392 | group->cg_item.ci_name, epf_group->index); | ||
393 | if (!epf_name) { | ||
394 | err = -ENOMEM; | ||
395 | goto remove_idr; | ||
396 | } | ||
397 | |||
398 | epf = pci_epf_create(epf_name); | ||
383 | if (IS_ERR(epf)) { | 399 | if (IS_ERR(epf)) { |
384 | pr_err("failed to create endpoint function device\n"); | 400 | pr_err("failed to create endpoint function device\n"); |
385 | return ERR_PTR(-EINVAL); | 401 | err = -EINVAL; |
402 | goto free_name; | ||
386 | } | 403 | } |
387 | 404 | ||
388 | epf_group->epf = epf; | 405 | epf_group->epf = epf; |
389 | 406 | ||
407 | kfree(epf_name); | ||
408 | |||
390 | return &epf_group->group; | 409 | return &epf_group->group; |
410 | |||
411 | free_name: | ||
412 | kfree(epf_name); | ||
413 | |||
414 | remove_idr: | ||
415 | mutex_lock(&functions_mutex); | ||
416 | idr_remove(&functions_idr, epf_group->index); | ||
417 | mutex_unlock(&functions_mutex); | ||
418 | |||
419 | free_group: | ||
420 | kfree(epf_group); | ||
421 | |||
422 | return ERR_PTR(err); | ||
391 | } | 423 | } |
392 | 424 | ||
393 | static void pci_epf_drop(struct config_group *group, struct config_item *item) | 425 | static void pci_epf_drop(struct config_group *group, struct config_item *item) |
diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 42c2a1156325..e245bba0ab53 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c | |||
@@ -1,24 +1,12 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * PCI Endpoint *Controller* (EPC) library | 3 | * PCI Endpoint *Controller* (EPC) library |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/device.h> | 9 | #include <linux/device.h> |
21 | #include <linux/dma-mapping.h> | ||
22 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
23 | #include <linux/module.h> | 11 | #include <linux/module.h> |
24 | #include <linux/of_device.h> | 12 | #include <linux/of_device.h> |
@@ -142,25 +130,26 @@ EXPORT_SYMBOL_GPL(pci_epc_start); | |||
142 | /** | 130 | /** |
143 | * pci_epc_raise_irq() - interrupt the host system | 131 | * pci_epc_raise_irq() - interrupt the host system |
144 | * @epc: the EPC device which has to interrupt the host | 132 | * @epc: the EPC device which has to interrupt the host |
133 | * @func_no: the endpoint function number in the EPC device | ||
145 | * @type: specify the type of interrupt; legacy or MSI | 134 | * @type: specify the type of interrupt; legacy or MSI |
146 | * @interrupt_num: the MSI interrupt number | 135 | * @interrupt_num: the MSI interrupt number |
147 | * | 136 | * |
148 | * Invoke to raise an MSI or legacy interrupt | 137 | * Invoke to raise an MSI or legacy interrupt |
149 | */ | 138 | */ |
150 | int pci_epc_raise_irq(struct pci_epc *epc, enum pci_epc_irq_type type, | 139 | int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, |
151 | u8 interrupt_num) | 140 | enum pci_epc_irq_type type, u8 interrupt_num) |
152 | { | 141 | { |
153 | int ret; | 142 | int ret; |
154 | unsigned long flags; | 143 | unsigned long flags; |
155 | 144 | ||
156 | if (IS_ERR(epc)) | 145 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
157 | return -EINVAL; | 146 | return -EINVAL; |
158 | 147 | ||
159 | if (!epc->ops->raise_irq) | 148 | if (!epc->ops->raise_irq) |
160 | return 0; | 149 | return 0; |
161 | 150 | ||
162 | spin_lock_irqsave(&epc->lock, flags); | 151 | spin_lock_irqsave(&epc->lock, flags); |
163 | ret = epc->ops->raise_irq(epc, type, interrupt_num); | 152 | ret = epc->ops->raise_irq(epc, func_no, type, interrupt_num); |
164 | spin_unlock_irqrestore(&epc->lock, flags); | 153 | spin_unlock_irqrestore(&epc->lock, flags); |
165 | 154 | ||
166 | return ret; | 155 | return ret; |
@@ -170,22 +159,23 @@ EXPORT_SYMBOL_GPL(pci_epc_raise_irq); | |||
170 | /** | 159 | /** |
171 | * pci_epc_get_msi() - get the number of MSI interrupt numbers allocated | 160 | * pci_epc_get_msi() - get the number of MSI interrupt numbers allocated |
172 | * @epc: the EPC device to which MSI interrupts was requested | 161 | * @epc: the EPC device to which MSI interrupts was requested |
162 | * @func_no: the endpoint function number in the EPC device | ||
173 | * | 163 | * |
174 | * Invoke to get the number of MSI interrupts allocated by the RC | 164 | * Invoke to get the number of MSI interrupts allocated by the RC |
175 | */ | 165 | */ |
176 | int pci_epc_get_msi(struct pci_epc *epc) | 166 | int pci_epc_get_msi(struct pci_epc *epc, u8 func_no) |
177 | { | 167 | { |
178 | int interrupt; | 168 | int interrupt; |
179 | unsigned long flags; | 169 | unsigned long flags; |
180 | 170 | ||
181 | if (IS_ERR(epc)) | 171 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
182 | return 0; | 172 | return 0; |
183 | 173 | ||
184 | if (!epc->ops->get_msi) | 174 | if (!epc->ops->get_msi) |
185 | return 0; | 175 | return 0; |
186 | 176 | ||
187 | spin_lock_irqsave(&epc->lock, flags); | 177 | spin_lock_irqsave(&epc->lock, flags); |
188 | interrupt = epc->ops->get_msi(epc); | 178 | interrupt = epc->ops->get_msi(epc, func_no); |
189 | spin_unlock_irqrestore(&epc->lock, flags); | 179 | spin_unlock_irqrestore(&epc->lock, flags); |
190 | 180 | ||
191 | if (interrupt < 0) | 181 | if (interrupt < 0) |
@@ -200,17 +190,18 @@ EXPORT_SYMBOL_GPL(pci_epc_get_msi); | |||
200 | /** | 190 | /** |
201 | * pci_epc_set_msi() - set the number of MSI interrupt numbers required | 191 | * pci_epc_set_msi() - set the number of MSI interrupt numbers required |
202 | * @epc: the EPC device on which MSI has to be configured | 192 | * @epc: the EPC device on which MSI has to be configured |
193 | * @func_no: the endpoint function number in the EPC device | ||
203 | * @interrupts: number of MSI interrupts required by the EPF | 194 | * @interrupts: number of MSI interrupts required by the EPF |
204 | * | 195 | * |
205 | * Invoke to set the required number of MSI interrupts. | 196 | * Invoke to set the required number of MSI interrupts. |
206 | */ | 197 | */ |
207 | int pci_epc_set_msi(struct pci_epc *epc, u8 interrupts) | 198 | int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) |
208 | { | 199 | { |
209 | int ret; | 200 | int ret; |
210 | u8 encode_int; | 201 | u8 encode_int; |
211 | unsigned long flags; | 202 | unsigned long flags; |
212 | 203 | ||
213 | if (IS_ERR(epc)) | 204 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
214 | return -EINVAL; | 205 | return -EINVAL; |
215 | 206 | ||
216 | if (!epc->ops->set_msi) | 207 | if (!epc->ops->set_msi) |
@@ -219,7 +210,7 @@ int pci_epc_set_msi(struct pci_epc *epc, u8 interrupts) | |||
219 | encode_int = order_base_2(interrupts); | 210 | encode_int = order_base_2(interrupts); |
220 | 211 | ||
221 | spin_lock_irqsave(&epc->lock, flags); | 212 | spin_lock_irqsave(&epc->lock, flags); |
222 | ret = epc->ops->set_msi(epc, encode_int); | 213 | ret = epc->ops->set_msi(epc, func_no, encode_int); |
223 | spin_unlock_irqrestore(&epc->lock, flags); | 214 | spin_unlock_irqrestore(&epc->lock, flags); |
224 | 215 | ||
225 | return ret; | 216 | return ret; |
@@ -229,22 +220,24 @@ EXPORT_SYMBOL_GPL(pci_epc_set_msi); | |||
229 | /** | 220 | /** |
230 | * pci_epc_unmap_addr() - unmap CPU address from PCI address | 221 | * pci_epc_unmap_addr() - unmap CPU address from PCI address |
231 | * @epc: the EPC device on which address is allocated | 222 | * @epc: the EPC device on which address is allocated |
223 | * @func_no: the endpoint function number in the EPC device | ||
232 | * @phys_addr: physical address of the local system | 224 | * @phys_addr: physical address of the local system |
233 | * | 225 | * |
234 | * Invoke to unmap the CPU address from PCI address. | 226 | * Invoke to unmap the CPU address from PCI address. |
235 | */ | 227 | */ |
236 | void pci_epc_unmap_addr(struct pci_epc *epc, phys_addr_t phys_addr) | 228 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, |
229 | phys_addr_t phys_addr) | ||
237 | { | 230 | { |
238 | unsigned long flags; | 231 | unsigned long flags; |
239 | 232 | ||
240 | if (IS_ERR(epc)) | 233 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
241 | return; | 234 | return; |
242 | 235 | ||
243 | if (!epc->ops->unmap_addr) | 236 | if (!epc->ops->unmap_addr) |
244 | return; | 237 | return; |
245 | 238 | ||
246 | spin_lock_irqsave(&epc->lock, flags); | 239 | spin_lock_irqsave(&epc->lock, flags); |
247 | epc->ops->unmap_addr(epc, phys_addr); | 240 | epc->ops->unmap_addr(epc, func_no, phys_addr); |
248 | spin_unlock_irqrestore(&epc->lock, flags); | 241 | spin_unlock_irqrestore(&epc->lock, flags); |
249 | } | 242 | } |
250 | EXPORT_SYMBOL_GPL(pci_epc_unmap_addr); | 243 | EXPORT_SYMBOL_GPL(pci_epc_unmap_addr); |
@@ -252,26 +245,27 @@ EXPORT_SYMBOL_GPL(pci_epc_unmap_addr); | |||
252 | /** | 245 | /** |
253 | * pci_epc_map_addr() - map CPU address to PCI address | 246 | * pci_epc_map_addr() - map CPU address to PCI address |
254 | * @epc: the EPC device on which address is allocated | 247 | * @epc: the EPC device on which address is allocated |
248 | * @func_no: the endpoint function number in the EPC device | ||
255 | * @phys_addr: physical address of the local system | 249 | * @phys_addr: physical address of the local system |
256 | * @pci_addr: PCI address to which the physical address should be mapped | 250 | * @pci_addr: PCI address to which the physical address should be mapped |
257 | * @size: the size of the allocation | 251 | * @size: the size of the allocation |
258 | * | 252 | * |
259 | * Invoke to map CPU address with PCI address. | 253 | * Invoke to map CPU address with PCI address. |
260 | */ | 254 | */ |
261 | int pci_epc_map_addr(struct pci_epc *epc, phys_addr_t phys_addr, | 255 | int pci_epc_map_addr(struct pci_epc *epc, u8 func_no, |
262 | u64 pci_addr, size_t size) | 256 | phys_addr_t phys_addr, u64 pci_addr, size_t size) |
263 | { | 257 | { |
264 | int ret; | 258 | int ret; |
265 | unsigned long flags; | 259 | unsigned long flags; |
266 | 260 | ||
267 | if (IS_ERR(epc)) | 261 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
268 | return -EINVAL; | 262 | return -EINVAL; |
269 | 263 | ||
270 | if (!epc->ops->map_addr) | 264 | if (!epc->ops->map_addr) |
271 | return 0; | 265 | return 0; |
272 | 266 | ||
273 | spin_lock_irqsave(&epc->lock, flags); | 267 | spin_lock_irqsave(&epc->lock, flags); |
274 | ret = epc->ops->map_addr(epc, phys_addr, pci_addr, size); | 268 | ret = epc->ops->map_addr(epc, func_no, phys_addr, pci_addr, size); |
275 | spin_unlock_irqrestore(&epc->lock, flags); | 269 | spin_unlock_irqrestore(&epc->lock, flags); |
276 | 270 | ||
277 | return ret; | 271 | return ret; |
@@ -281,22 +275,23 @@ EXPORT_SYMBOL_GPL(pci_epc_map_addr); | |||
281 | /** | 275 | /** |
282 | * pci_epc_clear_bar() - reset the BAR | 276 | * pci_epc_clear_bar() - reset the BAR |
283 | * @epc: the EPC device for which the BAR has to be cleared | 277 | * @epc: the EPC device for which the BAR has to be cleared |
278 | * @func_no: the endpoint function number in the EPC device | ||
284 | * @bar: the BAR number that has to be reset | 279 | * @bar: the BAR number that has to be reset |
285 | * | 280 | * |
286 | * Invoke to reset the BAR of the endpoint device. | 281 | * Invoke to reset the BAR of the endpoint device. |
287 | */ | 282 | */ |
288 | void pci_epc_clear_bar(struct pci_epc *epc, int bar) | 283 | void pci_epc_clear_bar(struct pci_epc *epc, u8 func_no, int bar) |
289 | { | 284 | { |
290 | unsigned long flags; | 285 | unsigned long flags; |
291 | 286 | ||
292 | if (IS_ERR(epc)) | 287 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
293 | return; | 288 | return; |
294 | 289 | ||
295 | if (!epc->ops->clear_bar) | 290 | if (!epc->ops->clear_bar) |
296 | return; | 291 | return; |
297 | 292 | ||
298 | spin_lock_irqsave(&epc->lock, flags); | 293 | spin_lock_irqsave(&epc->lock, flags); |
299 | epc->ops->clear_bar(epc, bar); | 294 | epc->ops->clear_bar(epc, func_no, bar); |
300 | spin_unlock_irqrestore(&epc->lock, flags); | 295 | spin_unlock_irqrestore(&epc->lock, flags); |
301 | } | 296 | } |
302 | EXPORT_SYMBOL_GPL(pci_epc_clear_bar); | 297 | EXPORT_SYMBOL_GPL(pci_epc_clear_bar); |
@@ -304,26 +299,27 @@ EXPORT_SYMBOL_GPL(pci_epc_clear_bar); | |||
304 | /** | 299 | /** |
305 | * pci_epc_set_bar() - configure BAR in order for host to assign PCI addr space | 300 | * pci_epc_set_bar() - configure BAR in order for host to assign PCI addr space |
306 | * @epc: the EPC device on which BAR has to be configured | 301 | * @epc: the EPC device on which BAR has to be configured |
302 | * @func_no: the endpoint function number in the EPC device | ||
307 | * @bar: the BAR number that has to be configured | 303 | * @bar: the BAR number that has to be configured |
308 | * @size: the size of the addr space | 304 | * @size: the size of the addr space |
309 | * @flags: specify memory allocation/io allocation/32bit address/64 bit address | 305 | * @flags: specify memory allocation/io allocation/32bit address/64 bit address |
310 | * | 306 | * |
311 | * Invoke to configure the BAR of the endpoint device. | 307 | * Invoke to configure the BAR of the endpoint device. |
312 | */ | 308 | */ |
313 | int pci_epc_set_bar(struct pci_epc *epc, enum pci_barno bar, | 309 | int pci_epc_set_bar(struct pci_epc *epc, u8 func_no, enum pci_barno bar, |
314 | dma_addr_t bar_phys, size_t size, int flags) | 310 | dma_addr_t bar_phys, size_t size, int flags) |
315 | { | 311 | { |
316 | int ret; | 312 | int ret; |
317 | unsigned long irq_flags; | 313 | unsigned long irq_flags; |
318 | 314 | ||
319 | if (IS_ERR(epc)) | 315 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
320 | return -EINVAL; | 316 | return -EINVAL; |
321 | 317 | ||
322 | if (!epc->ops->set_bar) | 318 | if (!epc->ops->set_bar) |
323 | return 0; | 319 | return 0; |
324 | 320 | ||
325 | spin_lock_irqsave(&epc->lock, irq_flags); | 321 | spin_lock_irqsave(&epc->lock, irq_flags); |
326 | ret = epc->ops->set_bar(epc, bar, bar_phys, size, flags); | 322 | ret = epc->ops->set_bar(epc, func_no, bar, bar_phys, size, flags); |
327 | spin_unlock_irqrestore(&epc->lock, irq_flags); | 323 | spin_unlock_irqrestore(&epc->lock, irq_flags); |
328 | 324 | ||
329 | return ret; | 325 | return ret; |
@@ -333,6 +329,7 @@ EXPORT_SYMBOL_GPL(pci_epc_set_bar); | |||
333 | /** | 329 | /** |
334 | * pci_epc_write_header() - write standard configuration header | 330 | * pci_epc_write_header() - write standard configuration header |
335 | * @epc: the EPC device to which the configuration header should be written | 331 | * @epc: the EPC device to which the configuration header should be written |
332 | * @func_no: the endpoint function number in the EPC device | ||
336 | * @header: standard configuration header fields | 333 | * @header: standard configuration header fields |
337 | * | 334 | * |
338 | * Invoke to write the configuration header to the endpoint controller. Every | 335 | * Invoke to write the configuration header to the endpoint controller. Every |
@@ -340,19 +337,20 @@ EXPORT_SYMBOL_GPL(pci_epc_set_bar); | |||
340 | * configuration header would be written. The callback function should write | 337 | * configuration header would be written. The callback function should write |
341 | * the header fields to this dedicated location. | 338 | * the header fields to this dedicated location. |
342 | */ | 339 | */ |
343 | int pci_epc_write_header(struct pci_epc *epc, struct pci_epf_header *header) | 340 | int pci_epc_write_header(struct pci_epc *epc, u8 func_no, |
341 | struct pci_epf_header *header) | ||
344 | { | 342 | { |
345 | int ret; | 343 | int ret; |
346 | unsigned long flags; | 344 | unsigned long flags; |
347 | 345 | ||
348 | if (IS_ERR(epc)) | 346 | if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) |
349 | return -EINVAL; | 347 | return -EINVAL; |
350 | 348 | ||
351 | if (!epc->ops->write_header) | 349 | if (!epc->ops->write_header) |
352 | return 0; | 350 | return 0; |
353 | 351 | ||
354 | spin_lock_irqsave(&epc->lock, flags); | 352 | spin_lock_irqsave(&epc->lock, flags); |
355 | ret = epc->ops->write_header(epc, header); | 353 | ret = epc->ops->write_header(epc, func_no, header); |
356 | spin_unlock_irqrestore(&epc->lock, flags); | 354 | spin_unlock_irqrestore(&epc->lock, flags); |
357 | 355 | ||
358 | return ret; | 356 | return ret; |
@@ -371,7 +369,6 @@ EXPORT_SYMBOL_GPL(pci_epc_write_header); | |||
371 | int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) | 369 | int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) |
372 | { | 370 | { |
373 | unsigned long flags; | 371 | unsigned long flags; |
374 | struct device *dev = epc->dev.parent; | ||
375 | 372 | ||
376 | if (epf->epc) | 373 | if (epf->epc) |
377 | return -EBUSY; | 374 | return -EBUSY; |
@@ -383,12 +380,6 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) | |||
383 | return -EINVAL; | 380 | return -EINVAL; |
384 | 381 | ||
385 | epf->epc = epc; | 382 | epf->epc = epc; |
386 | if (dev->of_node) { | ||
387 | of_dma_configure(&epf->dev, dev->of_node); | ||
388 | } else { | ||
389 | dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); | ||
390 | epf->dev.dma_mask = epc->dev.dma_mask; | ||
391 | } | ||
392 | 383 | ||
393 | spin_lock_irqsave(&epc->lock, flags); | 384 | spin_lock_irqsave(&epc->lock, flags); |
394 | list_add_tail(&epf->list, &epc->pci_epf); | 385 | list_add_tail(&epf->list, &epc->pci_epf); |
@@ -503,9 +494,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, | |||
503 | INIT_LIST_HEAD(&epc->pci_epf); | 494 | INIT_LIST_HEAD(&epc->pci_epf); |
504 | 495 | ||
505 | device_initialize(&epc->dev); | 496 | device_initialize(&epc->dev); |
506 | dma_set_coherent_mask(&epc->dev, dev->coherent_dma_mask); | ||
507 | epc->dev.class = pci_epc_class; | 497 | epc->dev.class = pci_epc_class; |
508 | epc->dev.dma_mask = dev->dma_mask; | ||
509 | epc->dev.parent = dev; | 498 | epc->dev.parent = dev; |
510 | epc->ops = ops; | 499 | epc->ops = ops; |
511 | 500 | ||
diff --git a/drivers/pci/endpoint/pci-epc-mem.c b/drivers/pci/endpoint/pci-epc-mem.c index 83b7d5d3fc3e..2bf8bd1f0563 100644 --- a/drivers/pci/endpoint/pci-epc-mem.c +++ b/drivers/pci/endpoint/pci-epc-mem.c | |||
@@ -1,20 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * PCI Endpoint *Controller* Address Space Management | 3 | * PCI Endpoint *Controller* Address Space Management |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/io.h> | 9 | #include <linux/io.h> |
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index ae1611a62808..766ce1dca2ec 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c | |||
@@ -1,20 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /** | 2 | /** |
2 | * PCI Endpoint *Function* (EPF) library | 3 | * PCI Endpoint *Function* (EPF) library |
3 | * | 4 | * |
4 | * Copyright (C) 2017 Texas Instruments | 5 | * Copyright (C) 2017 Texas Instruments |
5 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | 6 | * Author: Kishon Vijay Abraham I <kishon@ti.com> |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/device.h> | 9 | #include <linux/device.h> |
@@ -99,7 +88,7 @@ EXPORT_SYMBOL_GPL(pci_epf_bind); | |||
99 | */ | 88 | */ |
100 | void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar) | 89 | void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar) |
101 | { | 90 | { |
102 | struct device *dev = &epf->dev; | 91 | struct device *dev = epf->epc->dev.parent; |
103 | 92 | ||
104 | if (!addr) | 93 | if (!addr) |
105 | return; | 94 | return; |
@@ -122,7 +111,7 @@ EXPORT_SYMBOL_GPL(pci_epf_free_space); | |||
122 | void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar) | 111 | void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar) |
123 | { | 112 | { |
124 | void *space; | 113 | void *space; |
125 | struct device *dev = &epf->dev; | 114 | struct device *dev = epf->epc->dev.parent; |
126 | dma_addr_t phys_addr; | 115 | dma_addr_t phys_addr; |
127 | 116 | ||
128 | if (size < 128) | 117 | if (size < 128) |
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index add66236215c..ac8d81268296 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * host bridge related code | 3 | * host bridge related code |
3 | */ | 4 | */ |
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 38d12980db0f..a4ed7484d127 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig | |||
@@ -1,3 +1,5 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
2 | |||
1 | menu "PCI host controller drivers" | 3 | menu "PCI host controller drivers" |
2 | depends on PCI | 4 | depends on PCI |
3 | 5 | ||
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index 34ec1d88f961..3b1059190867 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile | |||
@@ -34,6 +34,8 @@ obj-$(CONFIG_VMD) += vmd.o | |||
34 | # ARM64 and use internal ifdefs to only build the pieces we need | 34 | # ARM64 and use internal ifdefs to only build the pieces we need |
35 | # depending on whether ACPI, the DT driver, or both are enabled. | 35 | # depending on whether ACPI, the DT driver, or both are enabled. |
36 | 36 | ||
37 | ifdef CONFIG_PCI | ||
37 | obj-$(CONFIG_ARM64) += pci-thunder-ecam.o | 38 | obj-$(CONFIG_ARM64) += pci-thunder-ecam.o |
38 | obj-$(CONFIG_ARM64) += pci-thunder-pem.o | 39 | obj-$(CONFIG_ARM64) += pci-thunder-pem.o |
39 | obj-$(CONFIG_ARM64) += pci-xgene.o | 40 | obj-$(CONFIG_ARM64) += pci-xgene.o |
41 | endif | ||
diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c index 26ed0c08f209..b04d37b3c5de 100644 --- a/drivers/pci/host/pci-aardvark.c +++ b/drivers/pci/host/pci-aardvark.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Driver for the Aardvark PCIe controller, used on Marvell Armada | 3 | * Driver for the Aardvark PCIe controller, used on Marvell Armada |
3 | * 3700. | 4 | * 3700. |
@@ -5,10 +6,6 @@ | |||
5 | * Copyright (C) 2016 Marvell | 6 | * Copyright (C) 2016 Marvell |
6 | * | 7 | * |
7 | * Author: Hezi Shahmoon <hezi.shahmoon@marvell.com> | 8 | * Author: Hezi Shahmoon <hezi.shahmoon@marvell.com> |
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c index 44a47d4f0b8f..5d028f53fdcd 100644 --- a/drivers/pci/host/pci-host-common.c +++ b/drivers/pci/host/pci-host-common.c | |||
@@ -1,18 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Generic PCI host driver common code | 3 | * Generic PCI host driver common code |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | * | ||
16 | * Copyright (C) 2014 ARM Limited | 5 | * Copyright (C) 2014 ARM Limited |
17 | * | 6 | * |
18 | * Author: Will Deacon <will.deacon@arm.com> | 7 | * Author: Will Deacon <will.deacon@arm.com> |
@@ -24,50 +13,6 @@ | |||
24 | #include <linux/pci-ecam.h> | 13 | #include <linux/pci-ecam.h> |
25 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
26 | 15 | ||
27 | static int gen_pci_parse_request_of_pci_ranges(struct device *dev, | ||
28 | struct list_head *resources, struct resource **bus_range) | ||
29 | { | ||
30 | int err, res_valid = 0; | ||
31 | struct device_node *np = dev->of_node; | ||
32 | resource_size_t iobase; | ||
33 | struct resource_entry *win, *tmp; | ||
34 | |||
35 | err = of_pci_get_host_bridge_resources(np, 0, 0xff, resources, &iobase); | ||
36 | if (err) | ||
37 | return err; | ||
38 | |||
39 | err = devm_request_pci_bus_resources(dev, resources); | ||
40 | if (err) | ||
41 | return err; | ||
42 | |||
43 | resource_list_for_each_entry_safe(win, tmp, resources) { | ||
44 | struct resource *res = win->res; | ||
45 | |||
46 | switch (resource_type(res)) { | ||
47 | case IORESOURCE_IO: | ||
48 | err = pci_remap_iospace(res, iobase); | ||
49 | if (err) { | ||
50 | dev_warn(dev, "error %d: failed to map resource %pR\n", | ||
51 | err, res); | ||
52 | resource_list_destroy_entry(win); | ||
53 | } | ||
54 | break; | ||
55 | case IORESOURCE_MEM: | ||
56 | res_valid |= !(res->flags & IORESOURCE_PREFETCH); | ||
57 | break; | ||
58 | case IORESOURCE_BUS: | ||
59 | *bus_range = res; | ||
60 | break; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | if (res_valid) | ||
65 | return 0; | ||
66 | |||
67 | dev_err(dev, "non-prefetchable memory resource required\n"); | ||
68 | return -EINVAL; | ||
69 | } | ||
70 | |||
71 | static void gen_pci_unmap_cfg(void *ptr) | 16 | static void gen_pci_unmap_cfg(void *ptr) |
72 | { | 17 | { |
73 | pci_ecam_free((struct pci_config_window *)ptr); | 18 | pci_ecam_free((struct pci_config_window *)ptr); |
@@ -82,9 +27,9 @@ static struct pci_config_window *gen_pci_init(struct device *dev, | |||
82 | struct pci_config_window *cfg; | 27 | struct pci_config_window *cfg; |
83 | 28 | ||
84 | /* Parse our PCI ranges and request their resources */ | 29 | /* Parse our PCI ranges and request their resources */ |
85 | err = gen_pci_parse_request_of_pci_ranges(dev, resources, &bus_range); | 30 | err = pci_parse_request_of_pci_ranges(dev, resources, &bus_range); |
86 | if (err) | 31 | if (err) |
87 | goto err_out; | 32 | return ERR_PTR(err); |
88 | 33 | ||
89 | err = of_address_to_resource(dev->of_node, 0, &cfgres); | 34 | err = of_address_to_resource(dev->of_node, 0, &cfgres); |
90 | if (err) { | 35 | if (err) { |
@@ -116,7 +61,6 @@ int pci_host_common_probe(struct platform_device *pdev, | |||
116 | const char *type; | 61 | const char *type; |
117 | struct device *dev = &pdev->dev; | 62 | struct device *dev = &pdev->dev; |
118 | struct device_node *np = dev->of_node; | 63 | struct device_node *np = dev->of_node; |
119 | struct pci_bus *bus, *child; | ||
120 | struct pci_host_bridge *bridge; | 64 | struct pci_host_bridge *bridge; |
121 | struct pci_config_window *cfg; | 65 | struct pci_config_window *cfg; |
122 | struct list_head resources; | 66 | struct list_head resources; |
@@ -135,14 +79,13 @@ int pci_host_common_probe(struct platform_device *pdev, | |||
135 | of_pci_check_probe_only(); | 79 | of_pci_check_probe_only(); |
136 | 80 | ||
137 | /* Parse and map our Configuration Space windows */ | 81 | /* Parse and map our Configuration Space windows */ |
138 | INIT_LIST_HEAD(&resources); | ||
139 | cfg = gen_pci_init(dev, &resources, ops); | 82 | cfg = gen_pci_init(dev, &resources, ops); |
140 | if (IS_ERR(cfg)) | 83 | if (IS_ERR(cfg)) |
141 | return PTR_ERR(cfg); | 84 | return PTR_ERR(cfg); |
142 | 85 | ||
143 | /* Do not reassign resources if probe only */ | 86 | /* Do not reassign resources if probe only */ |
144 | if (!pci_has_flag(PCI_PROBE_ONLY)) | 87 | if (!pci_has_flag(PCI_PROBE_ONLY)) |
145 | pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); | 88 | pci_add_flags(PCI_REASSIGN_ALL_BUS); |
146 | 89 | ||
147 | list_splice_init(&resources, &bridge->windows); | 90 | list_splice_init(&resources, &bridge->windows); |
148 | bridge->dev.parent = dev; | 91 | bridge->dev.parent = dev; |
@@ -152,29 +95,11 @@ int pci_host_common_probe(struct platform_device *pdev, | |||
152 | bridge->map_irq = of_irq_parse_and_map_pci; | 95 | bridge->map_irq = of_irq_parse_and_map_pci; |
153 | bridge->swizzle_irq = pci_common_swizzle; | 96 | bridge->swizzle_irq = pci_common_swizzle; |
154 | 97 | ||
155 | ret = pci_scan_root_bus_bridge(bridge); | 98 | ret = pci_host_probe(bridge); |
156 | if (ret < 0) { | 99 | if (ret < 0) { |
157 | dev_err(dev, "Scanning root bridge failed"); | 100 | pci_free_resource_list(&resources); |
158 | return ret; | 101 | return ret; |
159 | } | 102 | } |
160 | 103 | ||
161 | bus = bridge->bus; | ||
162 | |||
163 | /* | ||
164 | * We insert PCI resources into the iomem_resource and | ||
165 | * ioport_resource trees in either pci_bus_claim_resources() | ||
166 | * or pci_bus_assign_resources(). | ||
167 | */ | ||
168 | if (pci_has_flag(PCI_PROBE_ONLY)) { | ||
169 | pci_bus_claim_resources(bus); | ||
170 | } else { | ||
171 | pci_bus_size_bridges(bus); | ||
172 | pci_bus_assign_resources(bus); | ||
173 | |||
174 | list_for_each_entry(child, &bus->children, node) | ||
175 | pcie_bus_configure_settings(child); | ||
176 | } | ||
177 | |||
178 | pci_bus_add_devices(bus); | ||
179 | return 0; | 104 | return 0; |
180 | } | 105 | } |
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 2f05511ce718..45319ee3b484 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c | |||
@@ -1,19 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Simple, generic PCI host controller driver targetting firmware-initialised | 3 | * Simple, generic PCI host controller driver targetting firmware-initialised |
3 | * systems and virtual machines (e.g. the PCI emulation provided by kvmtool). | 4 | * systems and virtual machines (e.g. the PCI emulation provided by kvmtool). |
4 | * | 5 | * |
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | * | ||
17 | * Copyright (C) 2014 ARM Limited | 6 | * Copyright (C) 2014 ARM Limited |
18 | * | 7 | * |
19 | * Author: Will Deacon <will.deacon@arm.com> | 8 | * Author: Will Deacon <will.deacon@arm.com> |
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 6b8d060d07de..2faf38eab785 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright (c) Microsoft Corporation. | 3 | * Copyright (c) Microsoft Corporation. |
3 | * | 4 | * |
@@ -34,17 +35,6 @@ | |||
34 | * read and write handlers for config space must be aware of this mechanism. | 35 | * read and write handlers for config space must be aware of this mechanism. |
35 | * Similarly, device setup and teardown involves messages sent to and from | 36 | * Similarly, device setup and teardown involves messages sent to and from |
36 | * the PCI back-end driver in Hyper-V. | 37 | * the PCI back-end driver in Hyper-V. |
37 | * | ||
38 | * This program is free software; you can redistribute it and/or modify it | ||
39 | * under the terms of the GNU General Public License version 2 as published | ||
40 | * by the Free Software Foundation. | ||
41 | * | ||
42 | * This program is distributed in the hope that it will be useful, but | ||
43 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
44 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
45 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
46 | * details. | ||
47 | * | ||
48 | */ | 38 | */ |
49 | 39 | ||
50 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 8d88f19dc171..5d4dccfc9d81 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c | |||
@@ -1,11 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe driver for Marvell Armada 370 and Armada XP SoCs | 3 | * PCIe driver for Marvell Armada 370 and Armada XP SoCs |
3 | * | 4 | * |
4 | * Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 5 | * Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | 6 | */ |
10 | 7 | ||
11 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index e46de69f0380..a28370bb2b2a 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * pci-rcar-gen2: internal PCI bus support | 3 | * pci-rcar-gen2: internal PCI bus support |
3 | * | 4 | * |
@@ -5,10 +6,6 @@ | |||
5 | * Copyright (C) 2013 Cogent Embedded, Inc. | 6 | * Copyright (C) 2013 Cogent Embedded, Inc. |
6 | * | 7 | * |
7 | * Author: Valentine Barshak <valentine.barshak@cogentembedded.com> | 8 | * Author: Valentine Barshak <valentine.barshak@cogentembedded.com> |
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index f9d3960dc39f..dd9b3bcc41c3 100644 --- a/drivers/pci/host/pci-tegra.c +++ b/drivers/pci/host/pci-tegra.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Tegra SoCs | 3 | * PCIe host controller driver for Tegra SoCs |
3 | * | 4 | * |
@@ -10,20 +11,6 @@ | |||
10 | * Bits taken from arch/arm/mach-dove/pcie.c | 11 | * Bits taken from arch/arm/mach-dove/pcie.c |
11 | * | 12 | * |
12 | * Author: Thierry Reding <treding@nvidia.com> | 13 | * Author: Thierry Reding <treding@nvidia.com> |
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or | ||
17 | * (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
20 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
21 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
22 | * more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License along | ||
25 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
26 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
27 | */ | 14 | */ |
28 | 15 | ||
29 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
@@ -269,11 +256,10 @@ struct tegra_pcie { | |||
269 | 256 | ||
270 | void __iomem *pads; | 257 | void __iomem *pads; |
271 | void __iomem *afi; | 258 | void __iomem *afi; |
259 | void __iomem *cfg; | ||
272 | int irq; | 260 | int irq; |
273 | 261 | ||
274 | struct list_head buses; | 262 | struct resource cs; |
275 | struct resource *cs; | ||
276 | |||
277 | struct resource io; | 263 | struct resource io; |
278 | struct resource pio; | 264 | struct resource pio; |
279 | struct resource mem; | 265 | struct resource mem; |
@@ -322,7 +308,6 @@ struct tegra_pcie_port { | |||
322 | }; | 308 | }; |
323 | 309 | ||
324 | struct tegra_pcie_bus { | 310 | struct tegra_pcie_bus { |
325 | struct vm_struct *area; | ||
326 | struct list_head list; | 311 | struct list_head list; |
327 | unsigned int nr; | 312 | unsigned int nr; |
328 | }; | 313 | }; |
@@ -362,109 +347,26 @@ static inline u32 pads_readl(struct tegra_pcie *pcie, unsigned long offset) | |||
362 | * | 347 | * |
363 | * Mapping the whole extended configuration space would require 256 MiB of | 348 | * Mapping the whole extended configuration space would require 256 MiB of |
364 | * virtual address space, only a small part of which will actually be used. | 349 | * virtual address space, only a small part of which will actually be used. |
365 | * To work around this, a 1 MiB of virtual addresses are allocated per bus | ||
366 | * when the bus is first accessed. When the physical range is mapped, the | ||
367 | * the bus number bits are hidden so that the extended register number bits | ||
368 | * appear as bits [19:16]. Therefore the virtual mapping looks like this: | ||
369 | * | 350 | * |
370 | * [19:16] extended register number | 351 | * To work around this, a 4 KiB region is used to generate the required |
371 | * [15:11] device number | 352 | * configuration transaction with relevant B:D:F and register offset values. |
372 | * [10: 8] function number | 353 | * This is achieved by dynamically programming base address and size of |
373 | * [ 7: 0] register number | 354 | * AFI_AXI_BAR used for end point config space mapping to make sure that the |
374 | * | 355 | * address (access to which generates correct config transaction) falls in |
375 | * This is achieved by stitching together 16 chunks of 64 KiB of physical | 356 | * this 4 KiB region. |
376 | * address space via the MMU. | ||
377 | */ | 357 | */ |
378 | static unsigned long tegra_pcie_conf_offset(unsigned int devfn, int where) | 358 | static unsigned int tegra_pcie_conf_offset(u8 bus, unsigned int devfn, |
379 | { | 359 | unsigned int where) |
380 | return ((where & 0xf00) << 8) | (PCI_SLOT(devfn) << 11) | | ||
381 | (PCI_FUNC(devfn) << 8) | (where & 0xfc); | ||
382 | } | ||
383 | |||
384 | static struct tegra_pcie_bus *tegra_pcie_bus_alloc(struct tegra_pcie *pcie, | ||
385 | unsigned int busnr) | ||
386 | { | ||
387 | struct device *dev = pcie->dev; | ||
388 | pgprot_t prot = pgprot_noncached(PAGE_KERNEL); | ||
389 | phys_addr_t cs = pcie->cs->start; | ||
390 | struct tegra_pcie_bus *bus; | ||
391 | unsigned int i; | ||
392 | int err; | ||
393 | |||
394 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); | ||
395 | if (!bus) | ||
396 | return ERR_PTR(-ENOMEM); | ||
397 | |||
398 | INIT_LIST_HEAD(&bus->list); | ||
399 | bus->nr = busnr; | ||
400 | |||
401 | /* allocate 1 MiB of virtual addresses */ | ||
402 | bus->area = get_vm_area(SZ_1M, VM_IOREMAP); | ||
403 | if (!bus->area) { | ||
404 | err = -ENOMEM; | ||
405 | goto free; | ||
406 | } | ||
407 | |||
408 | /* map each of the 16 chunks of 64 KiB each */ | ||
409 | for (i = 0; i < 16; i++) { | ||
410 | unsigned long virt = (unsigned long)bus->area->addr + | ||
411 | i * SZ_64K; | ||
412 | phys_addr_t phys = cs + i * SZ_16M + busnr * SZ_64K; | ||
413 | |||
414 | err = ioremap_page_range(virt, virt + SZ_64K, phys, prot); | ||
415 | if (err < 0) { | ||
416 | dev_err(dev, "ioremap_page_range() failed: %d\n", err); | ||
417 | goto unmap; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | return bus; | ||
422 | |||
423 | unmap: | ||
424 | vunmap(bus->area->addr); | ||
425 | free: | ||
426 | kfree(bus); | ||
427 | return ERR_PTR(err); | ||
428 | } | ||
429 | |||
430 | static int tegra_pcie_add_bus(struct pci_bus *bus) | ||
431 | { | ||
432 | struct pci_host_bridge *host = pci_find_host_bridge(bus); | ||
433 | struct tegra_pcie *pcie = pci_host_bridge_priv(host); | ||
434 | struct tegra_pcie_bus *b; | ||
435 | |||
436 | b = tegra_pcie_bus_alloc(pcie, bus->number); | ||
437 | if (IS_ERR(b)) | ||
438 | return PTR_ERR(b); | ||
439 | |||
440 | list_add_tail(&b->list, &pcie->buses); | ||
441 | |||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | static void tegra_pcie_remove_bus(struct pci_bus *child) | ||
446 | { | 360 | { |
447 | struct pci_host_bridge *host = pci_find_host_bridge(child); | 361 | return ((where & 0xf00) << 16) | (bus << 16) | (PCI_SLOT(devfn) << 11) | |
448 | struct tegra_pcie *pcie = pci_host_bridge_priv(host); | 362 | (PCI_FUNC(devfn) << 8) | (where & 0xff); |
449 | struct tegra_pcie_bus *bus, *tmp; | ||
450 | |||
451 | list_for_each_entry_safe(bus, tmp, &pcie->buses, list) { | ||
452 | if (bus->nr == child->number) { | ||
453 | vunmap(bus->area->addr); | ||
454 | list_del(&bus->list); | ||
455 | kfree(bus); | ||
456 | break; | ||
457 | } | ||
458 | } | ||
459 | } | 363 | } |
460 | 364 | ||
461 | static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus, | 365 | static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus, |
462 | unsigned int devfn, | 366 | unsigned int devfn, |
463 | int where) | 367 | int where) |
464 | { | 368 | { |
465 | struct pci_host_bridge *host = pci_find_host_bridge(bus); | 369 | struct tegra_pcie *pcie = bus->sysdata; |
466 | struct tegra_pcie *pcie = pci_host_bridge_priv(host); | ||
467 | struct device *dev = pcie->dev; | ||
468 | void __iomem *addr = NULL; | 370 | void __iomem *addr = NULL; |
469 | 371 | ||
470 | if (bus->number == 0) { | 372 | if (bus->number == 0) { |
@@ -478,19 +380,17 @@ static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus, | |||
478 | } | 380 | } |
479 | } | 381 | } |
480 | } else { | 382 | } else { |
481 | struct tegra_pcie_bus *b; | 383 | unsigned int offset; |
384 | u32 base; | ||
482 | 385 | ||
483 | list_for_each_entry(b, &pcie->buses, list) | 386 | offset = tegra_pcie_conf_offset(bus->number, devfn, where); |
484 | if (b->nr == bus->number) | ||
485 | addr = (void __iomem *)b->area->addr; | ||
486 | 387 | ||
487 | if (!addr) { | 388 | /* move 4 KiB window to offset within the FPCI region */ |
488 | dev_err(dev, "failed to map cfg. space for bus %u\n", | 389 | base = 0xfe100000 + ((offset & ~(SZ_4K - 1)) >> 8); |
489 | bus->number); | 390 | afi_writel(pcie, base, AFI_FPCI_BAR0); |
490 | return NULL; | ||
491 | } | ||
492 | 391 | ||
493 | addr += tegra_pcie_conf_offset(devfn, where); | 392 | /* move to correct offset within the 4 KiB page */ |
393 | addr = pcie->cfg + (offset & (SZ_4K - 1)); | ||
494 | } | 394 | } |
495 | 395 | ||
496 | return addr; | 396 | return addr; |
@@ -517,8 +417,6 @@ static int tegra_pcie_config_write(struct pci_bus *bus, unsigned int devfn, | |||
517 | } | 417 | } |
518 | 418 | ||
519 | static struct pci_ops tegra_pcie_ops = { | 419 | static struct pci_ops tegra_pcie_ops = { |
520 | .add_bus = tegra_pcie_add_bus, | ||
521 | .remove_bus = tegra_pcie_remove_bus, | ||
522 | .map_bus = tegra_pcie_map_bus, | 420 | .map_bus = tegra_pcie_map_bus, |
523 | .read = tegra_pcie_config_read, | 421 | .read = tegra_pcie_config_read, |
524 | .write = tegra_pcie_config_write, | 422 | .write = tegra_pcie_config_write, |
@@ -661,8 +559,7 @@ static int tegra_pcie_request_resources(struct tegra_pcie *pcie) | |||
661 | 559 | ||
662 | static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) | 560 | static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) |
663 | { | 561 | { |
664 | struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus); | 562 | struct tegra_pcie *pcie = pdev->bus->sysdata; |
665 | struct tegra_pcie *pcie = pci_host_bridge_priv(host); | ||
666 | int irq; | 563 | int irq; |
667 | 564 | ||
668 | tegra_cpuidle_pcie_irqs_in_use(); | 565 | tegra_cpuidle_pcie_irqs_in_use(); |
@@ -743,12 +640,9 @@ static void tegra_pcie_setup_translations(struct tegra_pcie *pcie) | |||
743 | u32 fpci_bar, size, axi_address; | 640 | u32 fpci_bar, size, axi_address; |
744 | 641 | ||
745 | /* Bar 0: type 1 extended configuration space */ | 642 | /* Bar 0: type 1 extended configuration space */ |
746 | fpci_bar = 0xfe100000; | 643 | size = resource_size(&pcie->cs); |
747 | size = resource_size(pcie->cs); | 644 | afi_writel(pcie, pcie->cs.start, AFI_AXI_BAR0_START); |
748 | axi_address = pcie->cs->start; | ||
749 | afi_writel(pcie, axi_address, AFI_AXI_BAR0_START); | ||
750 | afi_writel(pcie, size >> 12, AFI_AXI_BAR0_SZ); | 645 | afi_writel(pcie, size >> 12, AFI_AXI_BAR0_SZ); |
751 | afi_writel(pcie, fpci_bar, AFI_FPCI_BAR0); | ||
752 | 646 | ||
753 | /* Bar 1: downstream IO bar */ | 647 | /* Bar 1: downstream IO bar */ |
754 | fpci_bar = 0xfdfc0000; | 648 | fpci_bar = 0xfdfc0000; |
@@ -1353,10 +1247,14 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie) | |||
1353 | goto poweroff; | 1247 | goto poweroff; |
1354 | } | 1248 | } |
1355 | 1249 | ||
1356 | pcie->cs = devm_request_mem_region(dev, res->start, | 1250 | pcie->cs = *res; |
1357 | resource_size(res), res->name); | 1251 | |
1358 | if (!pcie->cs) { | 1252 | /* constrain configuration space to 4 KiB */ |
1359 | err = -EADDRNOTAVAIL; | 1253 | pcie->cs.end = pcie->cs.start + SZ_4K - 1; |
1254 | |||
1255 | pcie->cfg = devm_ioremap_resource(dev, &pcie->cs); | ||
1256 | if (IS_ERR(pcie->cfg)) { | ||
1257 | err = PTR_ERR(pcie->cfg); | ||
1360 | goto poweroff; | 1258 | goto poweroff; |
1361 | } | 1259 | } |
1362 | 1260 | ||
@@ -2345,9 +2243,9 @@ static int tegra_pcie_probe(struct platform_device *pdev) | |||
2345 | return -ENOMEM; | 2243 | return -ENOMEM; |
2346 | 2244 | ||
2347 | pcie = pci_host_bridge_priv(host); | 2245 | pcie = pci_host_bridge_priv(host); |
2246 | host->sysdata = pcie; | ||
2348 | 2247 | ||
2349 | pcie->soc = of_device_get_match_data(dev); | 2248 | pcie->soc = of_device_get_match_data(dev); |
2350 | INIT_LIST_HEAD(&pcie->buses); | ||
2351 | INIT_LIST_HEAD(&pcie->ports); | 2249 | INIT_LIST_HEAD(&pcie->ports); |
2352 | pcie->dev = dev; | 2250 | pcie->dev = dev; |
2353 | 2251 | ||
@@ -2382,7 +2280,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) | |||
2382 | 2280 | ||
2383 | tegra_pcie_enable_ports(pcie); | 2281 | tegra_pcie_enable_ports(pcie); |
2384 | 2282 | ||
2385 | pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); | ||
2386 | host->busnr = pcie->busn.start; | 2283 | host->busnr = pcie->busn.start; |
2387 | host->dev.parent = &pdev->dev; | 2284 | host->dev.parent = &pdev->dev; |
2388 | host->ops = &tegra_pcie_ops; | 2285 | host->ops = &tegra_pcie_ops; |
diff --git a/drivers/pci/host/pci-thunder-ecam.c b/drivers/pci/host/pci-thunder-ecam.c index fc0ca03f280e..32d1d7b81ef4 100644 --- a/drivers/pci/host/pci-thunder-ecam.c +++ b/drivers/pci/host/pci-thunder-ecam.c | |||
@@ -1,8 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2015, 2016 Cavium, Inc. | 3 | * Copyright (C) 2015, 2016 Cavium, Inc. |
7 | */ | 4 | */ |
8 | 5 | ||
diff --git a/drivers/pci/host/pci-thunder-pem.c b/drivers/pci/host/pci-thunder-pem.c index 6e066f8b74df..f127ce8bd4ef 100644 --- a/drivers/pci/host/pci-thunder-pem.c +++ b/drivers/pci/host/pci-thunder-pem.c | |||
@@ -1,16 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License version 2 as | ||
4 | * published by the Free Software Foundation. | ||
5 | * | ||
6 | * This program is distributed in the hope that it will be useful, | ||
7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
9 | * GNU General Public License for more details. | ||
10 | * | ||
11 | * You should have received a copy of the GNU General Public License | ||
12 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
13 | * | ||
14 | * Copyright (C) 2015 - 2016 Cavium, Inc. | 3 | * Copyright (C) 2015 - 2016 Cavium, Inc. |
15 | */ | 4 | */ |
16 | 5 | ||
diff --git a/drivers/pci/host/pci-v3-semi.c b/drivers/pci/host/pci-v3-semi.c index 02f6e1e3a421..7fef64869d19 100644 --- a/drivers/pci/host/pci-v3-semi.c +++ b/drivers/pci/host/pci-v3-semi.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Support for V3 Semiconductor PCI Local Bus to PCI Bridge | 3 | * Support for V3 Semiconductor PCI Local Bus to PCI Bridge |
3 | * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> | 4 | * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> |
diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c index d417acab0ecf..5b3876f5312b 100644 --- a/drivers/pci/host/pci-versatile.c +++ b/drivers/pci/host/pci-versatile.c | |||
@@ -1,18 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright 2004 Koninklijke Philips Electronics NV | 3 | * Copyright 2004 Koninklijke Philips Electronics NV |
3 | * | 4 | * |
4 | * Conversion to platform driver and DT: | 5 | * Conversion to platform driver and DT: |
5 | * Copyright 2014 Linaro Ltd. | 6 | * Copyright 2014 Linaro Ltd. |
6 | * | 7 | * |
7 | * This software is licensed under the terms of the GNU General Public | ||
8 | * License version 2, as published by the Free Software Foundation, and | ||
9 | * may be copied, distributed, and modified under those terms. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * 14/04/2005 Initial version, colin.king@philips.com | 8 | * 14/04/2005 Initial version, colin.king@philips.com |
17 | */ | 9 | */ |
18 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
@@ -202,7 +194,7 @@ static int versatile_pci_probe(struct platform_device *pdev) | |||
202 | writel(0, versatile_cfg_base[0] + PCI_INTERRUPT_LINE); | 194 | writel(0, versatile_cfg_base[0] + PCI_INTERRUPT_LINE); |
203 | 195 | ||
204 | pci_add_flags(PCI_ENABLE_PROC_DOMAINS); | 196 | pci_add_flags(PCI_ENABLE_PROC_DOMAINS); |
205 | pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC); | 197 | pci_add_flags(PCI_REASSIGN_ALL_BUS); |
206 | 198 | ||
207 | list_splice_init(&pci_res, &bridge->windows); | 199 | list_splice_init(&pci_res, &bridge->windows); |
208 | bridge->dev.parent = dev; | 200 | bridge->dev.parent = dev; |
diff --git a/drivers/pci/host/pci-xgene-msi.c b/drivers/pci/host/pci-xgene-msi.c index 1f42a202b021..df8e4bd5ddb2 100644 --- a/drivers/pci/host/pci-xgene-msi.c +++ b/drivers/pci/host/pci-xgene-msi.c | |||
@@ -1,19 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * APM X-Gene MSI Driver | 3 | * APM X-Gene MSI Driver |
3 | * | 4 | * |
4 | * Copyright (c) 2014, Applied Micro Circuits Corporation | 5 | * Copyright (c) 2014, Applied Micro Circuits Corporation |
5 | * Author: Tanmay Inamdar <tinamdar@apm.com> | 6 | * Author: Tanmay Inamdar <tinamdar@apm.com> |
6 | * Duc Dang <dhdang@apm.com> | 7 | * Duc Dang <dhdang@apm.com> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | */ | 8 | */ |
18 | #include <linux/cpu.h> | 9 | #include <linux/cpu.h> |
19 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index 465aa2a1b38d..0a0d7ee6d3c9 100644 --- a/drivers/pci/host/pci-xgene.c +++ b/drivers/pci/host/pci-xgene.c | |||
@@ -1,20 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /** | 2 | /** |
2 | * APM X-Gene PCIe Driver | 3 | * APM X-Gene PCIe Driver |
3 | * | 4 | * |
4 | * Copyright (c) 2014 Applied Micro Circuits Corporation. | 5 | * Copyright (c) 2014 Applied Micro Circuits Corporation. |
5 | * | 6 | * |
6 | * Author: Tanmay Inamdar <tinamdar@apm.com>. | 7 | * Author: Tanmay Inamdar <tinamdar@apm.com>. |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | */ | 8 | */ |
19 | #include <linux/clk.h> | 9 | #include <linux/clk.h> |
20 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
@@ -668,7 +658,6 @@ static int xgene_pcie_probe(struct platform_device *pdev) | |||
668 | 658 | ||
669 | bus = bridge->bus; | 659 | bus = bridge->bus; |
670 | 660 | ||
671 | pci_scan_child_bus(bus); | ||
672 | pci_assign_unassigned_bus_resources(bus); | 661 | pci_assign_unassigned_bus_resources(bus); |
673 | list_for_each_entry(child, &bus->children, node) | 662 | list_for_each_entry(child, &bus->children, node) |
674 | pcie_bus_configure_settings(child); | 663 | pcie_bus_configure_settings(child); |
diff --git a/drivers/pci/host/pcie-altera-msi.c b/drivers/pci/host/pcie-altera-msi.c index d8141f4865de..025ef7d9a046 100644 --- a/drivers/pci/host/pcie-altera-msi.c +++ b/drivers/pci/host/pcie-altera-msi.c | |||
@@ -1,21 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Altera PCIe MSI support | 3 | * Altera PCIe MSI support |
3 | * | 4 | * |
4 | * Author: Ley Foon Tan <lftan@altera.com> | 5 | * Author: Ley Foon Tan <lftan@altera.com> |
5 | * | 6 | * |
6 | * Copyright Altera Corporation (C) 2013-2015. All rights reserved | 7 | * Copyright Altera Corporation (C) 2013-2015. All rights reserved |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | * more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License along with | ||
18 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 8 | */ |
20 | 9 | ||
21 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c index 5cc4f594d79a..2235f4760951 100644 --- a/drivers/pci/host/pcie-altera.c +++ b/drivers/pci/host/pcie-altera.c | |||
@@ -1,20 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright Altera Corporation (C) 2013-2015. All rights reserved | 3 | * Copyright Altera Corporation (C) 2013-2015. All rights reserved |
3 | * | 4 | * |
4 | * Author: Ley Foon Tan <lftan@altera.com> | 5 | * Author: Ley Foon Tan <lftan@altera.com> |
5 | * Description: Altera PCIe host controller driver | 6 | * Description: Altera PCIe host controller driver |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms and conditions of the GNU General Public License, | ||
9 | * version 2, as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 7 | */ |
19 | 8 | ||
20 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c index f03d5e3612e9..603c83429cb3 100644 --- a/drivers/pci/host/pcie-iproc-bcma.c +++ b/drivers/pci/host/pcie-iproc-bcma.c | |||
@@ -1,15 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2015 Broadcom Corporation | 3 | * Copyright (C) 2015 Broadcom Corporation |
3 | * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de> | 4 | * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de> |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation version 2. | ||
8 | * | ||
9 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
10 | * kind, whether express or implied; without even the implied warranty | ||
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | */ | 5 | */ |
14 | 6 | ||
15 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
diff --git a/drivers/pci/host/pcie-iproc-msi.c b/drivers/pci/host/pcie-iproc-msi.c index 990fc906d73d..9deb56989d72 100644 --- a/drivers/pci/host/pcie-iproc-msi.c +++ b/drivers/pci/host/pcie-iproc-msi.c | |||
@@ -1,14 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2015 Broadcom Corporation | 3 | * Copyright (C) 2015 Broadcom Corporation |
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | 4 | */ |
13 | 5 | ||
14 | #include <linux/interrupt.h> | 6 | #include <linux/interrupt.h> |
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index a5073a921a04..e764a2a2693c 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c | |||
@@ -1,14 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2015 Broadcom Corporation | 3 | * Copyright (C) 2015 Broadcom Corporation |
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | 4 | */ |
13 | 5 | ||
14 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
@@ -92,6 +84,13 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | |||
92 | pcie->need_ob_cfg = true; | 84 | pcie->need_ob_cfg = true; |
93 | } | 85 | } |
94 | 86 | ||
87 | /* | ||
88 | * DT nodes are not used by all platforms that use the iProc PCIe | ||
89 | * core driver. For platforms that require explict inbound mapping | ||
90 | * configuration, "dma-ranges" would have been present in DT | ||
91 | */ | ||
92 | pcie->need_ib_cfg = of_property_read_bool(np, "dma-ranges"); | ||
93 | |||
95 | /* PHY use is optional */ | 94 | /* PHY use is optional */ |
96 | pcie->phy = devm_phy_get(dev, "pcie-phy"); | 95 | pcie->phy = devm_phy_get(dev, "pcie-phy"); |
97 | if (IS_ERR(pcie->phy)) { | 96 | if (IS_ERR(pcie->phy)) { |
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index 935909bbe5c4..cbb095481cdc 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c | |||
@@ -1,15 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de> | 3 | * Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de> |
3 | * Copyright (C) 2015 Broadcom Corporation | 4 | * Copyright (C) 2015 Broadcom Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation version 2. | ||
8 | * | ||
9 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
10 | * kind, whether express or implied; without even the implied warranty | ||
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | */ | 5 | */ |
14 | 6 | ||
15 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
@@ -1378,9 +1370,11 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) | |||
1378 | } | 1370 | } |
1379 | } | 1371 | } |
1380 | 1372 | ||
1381 | ret = iproc_pcie_map_dma_ranges(pcie); | 1373 | if (pcie->need_ib_cfg) { |
1382 | if (ret && ret != -ENOENT) | 1374 | ret = iproc_pcie_map_dma_ranges(pcie); |
1383 | goto err_power_off_phy; | 1375 | if (ret && ret != -ENOENT) |
1376 | goto err_power_off_phy; | ||
1377 | } | ||
1384 | 1378 | ||
1385 | #ifdef CONFIG_ARM | 1379 | #ifdef CONFIG_ARM |
1386 | pcie->sysdata.private_data = pcie; | 1380 | pcie->sysdata.private_data = pcie; |
diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index a6b55cec9a66..d55f56a186cd 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h | |||
@@ -1,14 +1,6 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
1 | /* | 2 | /* |
2 | * Copyright (C) 2014-2015 Broadcom Corporation | 3 | * Copyright (C) 2014-2015 Broadcom Corporation |
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | 4 | */ |
13 | 5 | ||
14 | #ifndef _PCIE_IPROC_H | 6 | #ifndef _PCIE_IPROC_H |
@@ -74,6 +66,7 @@ struct iproc_msi; | |||
74 | * @ob: outbound mapping related parameters | 66 | * @ob: outbound mapping related parameters |
75 | * @ob_map: outbound mapping related parameters specific to the controller | 67 | * @ob_map: outbound mapping related parameters specific to the controller |
76 | * | 68 | * |
69 | * @need_ib_cfg: indicates SW needs to configure the inbound mapping window | ||
77 | * @ib: inbound mapping related parameters | 70 | * @ib: inbound mapping related parameters |
78 | * @ib_map: outbound mapping region related parameters | 71 | * @ib_map: outbound mapping region related parameters |
79 | * | 72 | * |
@@ -101,6 +94,7 @@ struct iproc_pcie { | |||
101 | struct iproc_pcie_ob ob; | 94 | struct iproc_pcie_ob ob; |
102 | const struct iproc_pcie_ob_map *ob_map; | 95 | const struct iproc_pcie_ob_map *ob_map; |
103 | 96 | ||
97 | bool need_ib_cfg; | ||
104 | struct iproc_pcie_ib ib; | 98 | struct iproc_pcie_ib ib; |
105 | const struct iproc_pcie_ib_map *ib_map; | 99 | const struct iproc_pcie_ib_map *ib_map; |
106 | 100 | ||
diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c index db93efdf1d63..a8b20c5012a9 100644 --- a/drivers/pci/host/pcie-mediatek.c +++ b/drivers/pci/host/pcie-mediatek.c | |||
@@ -1,18 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * MediaTek PCIe host controller driver. | 3 | * MediaTek PCIe host controller driver. |
3 | * | 4 | * |
4 | * Copyright (c) 2017 MediaTek Inc. | 5 | * Copyright (c) 2017 MediaTek Inc. |
5 | * Author: Ryder Lee <ryder.lee@mediatek.com> | 6 | * Author: Ryder Lee <ryder.lee@mediatek.com> |
6 | * Honghui Zhang <honghui.zhang@mediatek.com> | 7 | * Honghui Zhang <honghui.zhang@mediatek.com> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | 8 | */ |
17 | 9 | ||
18 | #include <linux/clk.h> | 10 | #include <linux/clk.h> |
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 52ab3cb0a0bf..b4c4aad2cf66 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe driver for Renesas R-Car SoCs | 3 | * PCIe driver for Renesas R-Car SoCs |
3 | * Copyright (C) 2014 Renesas Electronics Europe Ltd | 4 | * Copyright (C) 2014 Renesas Electronics Europe Ltd |
@@ -8,10 +9,6 @@ | |||
8 | * Copyright (C) 2009 - 2011 Paul Mundt | 9 | * Copyright (C) 2009 - 2011 Paul Mundt |
9 | * | 10 | * |
10 | * Author: Phil Edworthy <phil.edworthy@renesas.com> | 11 | * Author: Phil Edworthy <phil.edworthy@renesas.com> |
11 | * | ||
12 | * This file is licensed under the terms of the GNU General Public | ||
13 | * License version 2. This program is licensed "as is" without any | ||
14 | * warranty of any kind, whether express or implied. | ||
15 | */ | 12 | */ |
16 | 13 | ||
17 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
@@ -459,7 +456,7 @@ static int rcar_pcie_enable(struct rcar_pcie *pcie) | |||
459 | 456 | ||
460 | rcar_pcie_setup(&bridge->windows, pcie); | 457 | rcar_pcie_setup(&bridge->windows, pcie); |
461 | 458 | ||
462 | pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); | 459 | pci_add_flags(PCI_REASSIGN_ALL_BUS); |
463 | 460 | ||
464 | bridge->dev.parent = dev; | 461 | bridge->dev.parent = dev; |
465 | bridge->sysdata = pcie; | 462 | bridge->sysdata = pcie; |
@@ -1123,7 +1120,9 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
1123 | 1120 | ||
1124 | INIT_LIST_HEAD(&pcie->resources); | 1121 | INIT_LIST_HEAD(&pcie->resources); |
1125 | 1122 | ||
1126 | rcar_pcie_parse_request_of_pci_ranges(pcie); | 1123 | err = rcar_pcie_parse_request_of_pci_ranges(pcie); |
1124 | if (err) | ||
1125 | goto err_free_bridge; | ||
1127 | 1126 | ||
1128 | err = rcar_pcie_get_resources(pcie); | 1127 | err = rcar_pcie_get_resources(pcie); |
1129 | if (err < 0) { | 1128 | if (err < 0) { |
@@ -1178,6 +1177,7 @@ err_pm_disable: | |||
1178 | 1177 | ||
1179 | err_free_resource_list: | 1178 | err_free_resource_list: |
1180 | pci_free_resource_list(&pcie->resources); | 1179 | pci_free_resource_list(&pcie->resources); |
1180 | err_free_bridge: | ||
1181 | pci_free_host_bridge(bridge); | 1181 | pci_free_host_bridge(bridge); |
1182 | 1182 | ||
1183 | return err; | 1183 | return err; |
diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c index 9051c6c8fea4..f1e8f97ea1fb 100644 --- a/drivers/pci/host/pcie-rockchip.c +++ b/drivers/pci/host/pcie-rockchip.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Rockchip AXI PCIe host controller driver | 3 | * Rockchip AXI PCIe host controller driver |
3 | * | 4 | * |
@@ -8,11 +9,6 @@ | |||
8 | * | 9 | * |
9 | * Bits taken from Synopsys DesignWare Host controller driver and | 10 | * Bits taken from Synopsys DesignWare Host controller driver and |
10 | * ARM PCI Host generic driver. | 11 | * ARM PCI Host generic driver. |
11 | * | ||
12 | * This program is free software: you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation, either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | */ | 12 | */ |
17 | 13 | ||
18 | #include <linux/bitrev.h> | 14 | #include <linux/bitrev.h> |
diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c index 65dea98b2643..0acaf483d031 100644 --- a/drivers/pci/host/pcie-xilinx-nwl.c +++ b/drivers/pci/host/pcie-xilinx-nwl.c | |||
@@ -1,13 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for NWL PCIe Bridge | 3 | * PCIe host controller driver for NWL PCIe Bridge |
3 | * Based on pcie-xilinx.c, pci-tegra.c | 4 | * Based on pcie-xilinx.c, pci-tegra.c |
4 | * | 5 | * |
5 | * (C) Copyright 2014 - 2015, Xilinx, Inc. | 6 | * (C) Copyright 2014 - 2015, Xilinx, Inc. |
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation, either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | 7 | */ |
12 | 8 | ||
13 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c index 7b5325990f5e..0ad188effc09 100644 --- a/drivers/pci/host/pcie-xilinx.c +++ b/drivers/pci/host/pcie-xilinx.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCIe host controller driver for Xilinx AXI PCIe Bridge | 3 | * PCIe host controller driver for Xilinx AXI PCIe Bridge |
3 | * | 4 | * |
@@ -7,11 +8,6 @@ | |||
7 | * | 8 | * |
8 | * Bits taken from Synopsys DesignWare Host controller driver and | 9 | * Bits taken from Synopsys DesignWare Host controller driver and |
9 | * ARM PCI Host generic driver. | 10 | * ARM PCI Host generic driver. |
10 | * | ||
11 | * This program is free software: you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation, either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | */ | 11 | */ |
16 | 12 | ||
17 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
diff --git a/drivers/pci/host/vmd.c b/drivers/pci/host/vmd.c index 509893bc3e63..930a8fa08bd6 100644 --- a/drivers/pci/host/vmd.c +++ b/drivers/pci/host/vmd.c | |||
@@ -1,15 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Volume Management Device driver | 3 | * Volume Management Device driver |
3 | * Copyright (c) 2015, Intel Corporation. | 4 | * Copyright (c) 2015, Intel Corporation. |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | 5 | */ |
14 | 6 | ||
15 | #include <linux/device.h> | 7 | #include <linux/device.h> |
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig index aadce45a9b4a..a8f21d051e0c 100644 --- a/drivers/pci/hotplug/Kconfig +++ b/drivers/pci/hotplug/Kconfig | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI Hotplug support | 3 | # PCI Hotplug support |
3 | # | 4 | # |
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index a5e66df4ad14..c9816166978e 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Common ACPI functions for hot plug platforms | 3 | * Common ACPI functions for hot plug platforms |
3 | * | 4 | * |
@@ -5,21 +6,6 @@ | |||
5 | * | 6 | * |
6 | * All rights reserved. | 7 | * All rights reserved. |
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
16 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | * | ||
23 | * Send feedback to <kristen.c.accardi@intel.com> | 9 | * Send feedback to <kristen.c.accardi@intel.com> |
24 | * | 10 | * |
25 | */ | 11 | */ |
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index f0ebc8b9a15a..e438a2d734f2 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * ACPI PCI Hot Plug Controller Driver | 3 | * ACPI PCI Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -12,21 +13,6 @@ | |||
12 | * | 13 | * |
13 | * All rights reserved. | 14 | * All rights reserved. |
14 | * | 15 | * |
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or (at | ||
18 | * your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, but | ||
21 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
23 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
24 | * details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License | ||
27 | * along with this program; if not, write to the Free Software | ||
28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | * | ||
30 | * Send feedback to <gregkh@us.ibm.com>, | 16 | * Send feedback to <gregkh@us.ibm.com>, |
31 | * <t-kochi@bq.jp.nec.com> | 17 | * <t-kochi@bq.jp.nec.com> |
32 | * | 18 | * |
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 3c81fc8b0103..12b5655fd390 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * ACPI PCI Hot Plug Controller Driver | 3 | * ACPI PCI Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -12,21 +13,6 @@ | |||
12 | * | 13 | * |
13 | * All rights reserved. | 14 | * All rights reserved. |
14 | * | 15 | * |
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or (at | ||
18 | * your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, but | ||
21 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
23 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
24 | * details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License | ||
27 | * along with this program; if not, write to the Free Software | ||
28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | * | ||
30 | * Send feedback to <kristen.c.accardi@intel.com> | 16 | * Send feedback to <kristen.c.accardi@intel.com> |
31 | * | 17 | * |
32 | */ | 18 | */ |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 5db6f1839dad..e2198a2feeca 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * ACPI PCI HotPlug glue functions to ACPI CA subsystem | 3 | * ACPI PCI HotPlug glue functions to ACPI CA subsystem |
3 | * | 4 | * |
@@ -11,21 +12,6 @@ | |||
11 | * | 12 | * |
12 | * All rights reserved. | 13 | * All rights reserved. |
13 | * | 14 | * |
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or (at | ||
17 | * your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, but | ||
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
22 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
23 | * details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | * | ||
29 | * Send feedback to <kristen.c.accardi@intel.com> | 15 | * Send feedback to <kristen.c.accardi@intel.com> |
30 | * | 16 | * |
31 | */ | 17 | */ |
@@ -811,10 +797,8 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) | |||
811 | 797 | ||
812 | handle = adev->handle; | 798 | handle = adev->handle; |
813 | bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 799 | bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
814 | if (!bridge) { | 800 | if (!bridge) |
815 | acpi_handle_err(handle, "No memory for bridge object\n"); | ||
816 | return; | 801 | return; |
817 | } | ||
818 | 802 | ||
819 | INIT_LIST_HEAD(&bridge->slots); | 803 | INIT_LIST_HEAD(&bridge->slots); |
820 | kref_init(&bridge->ref); | 804 | kref_init(&bridge->ref); |
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 8472c4a27f70..41713f16ff97 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * ACPI PCI Hot Plug IBM Extension | 3 | * ACPI PCI Hot Plug IBM Extension |
3 | * | 4 | * |
@@ -6,21 +7,6 @@ | |||
6 | * | 7 | * |
7 | * All rights reserved. | 8 | * All rights reserved. |
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Send feedback to <vernux@us.ibm.com> | 10 | * Send feedback to <vernux@us.ibm.com> |
25 | * | 11 | * |
26 | */ | 12 | */ |
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h index 60e66e027ebc..4658557be01a 100644 --- a/drivers/pci/hotplug/cpci_hotplug.h +++ b/drivers/pci/hotplug/cpci_hotplug.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * CompactPCI Hot Plug Core Functions | 3 | * CompactPCI Hot Plug Core Functions |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <scottm@somanetworks.com> | 11 | * Send feedback to <scottm@somanetworks.com> |
26 | */ | 12 | */ |
27 | 13 | ||
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 95f689f53920..07b533adc9df 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * CompactPCI Hot Plug Driver | 3 | * CompactPCI Hot Plug Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <scottm@somanetworks.com> | 11 | * Send feedback to <scottm@somanetworks.com> |
26 | */ | 12 | */ |
27 | 13 | ||
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index f616358fa938..389b8fb50cd9 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * CompactPCI Hot Plug Driver PCI functions | 3 | * CompactPCI Hot Plug Driver PCI functions |
3 | * | 4 | * |
@@ -5,21 +6,6 @@ | |||
5 | * | 6 | * |
6 | * All rights reserved. | 7 | * All rights reserved. |
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
16 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | * | ||
23 | * Send feedback to <scottm@somanetworks.com> | 9 | * Send feedback to <scottm@somanetworks.com> |
24 | */ | 10 | */ |
25 | 11 | ||
diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c index bbf9cf8aeaad..17d71edf046f 100644 --- a/drivers/pci/hotplug/cpcihp_generic.c +++ b/drivers/pci/hotplug/cpcihp_generic.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * cpcihp_generic.c | 3 | * cpcihp_generic.c |
3 | * | 4 | * |
@@ -7,26 +8,6 @@ | |||
7 | * Copyright 2001 Intel San Luis Obispo | 8 | * Copyright 2001 Intel San Luis Obispo |
8 | * Copyright 2000,2001 MontaVista Software Inc. | 9 | * Copyright 2000,2001 MontaVista Software Inc. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
17 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
18 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
22 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
23 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | * | ||
30 | * This generic CompactPCI hotplug driver should allow using the PCI hotplug | 11 | * This generic CompactPCI hotplug driver should allow using the PCI hotplug |
31 | * mechanism on any CompactPCI board that exposes the #ENUM signal as a bit | 12 | * mechanism on any CompactPCI board that exposes the #ENUM signal as a bit |
32 | * in a system register that can be read through standard port I/O. | 13 | * in a system register that can be read through standard port I/O. |
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c index 2f8659a148f5..ae63e5a393c2 100644 --- a/drivers/pci/hotplug/cpcihp_zt5550.c +++ b/drivers/pci/hotplug/cpcihp_zt5550.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * cpcihp_zt5550.c | 3 | * cpcihp_zt5550.c |
3 | * | 4 | * |
@@ -7,26 +8,6 @@ | |||
7 | * Copyright 2001 Intel San Luis Obispo | 8 | * Copyright 2001 Intel San Luis Obispo |
8 | * Copyright 2000,2001 MontaVista Software Inc. | 9 | * Copyright 2000,2001 MontaVista Software Inc. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
17 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
18 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
22 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
23 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | * | ||
30 | * Send feedback to <scottm@somanetworks.com> | 11 | * Send feedback to <scottm@somanetworks.com> |
31 | */ | 12 | */ |
32 | 13 | ||
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.h b/drivers/pci/hotplug/cpcihp_zt5550.h index 9a57fda5348c..5ea10df83dd9 100644 --- a/drivers/pci/hotplug/cpcihp_zt5550.h +++ b/drivers/pci/hotplug/cpcihp_zt5550.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * cpcihp_zt5550.h | 3 | * cpcihp_zt5550.h |
3 | * | 4 | * |
@@ -7,26 +8,6 @@ | |||
7 | * Copyright 2001 Intel San Luis Obispo | 8 | * Copyright 2001 Intel San Luis Obispo |
8 | * Copyright 2000,2001 MontaVista Software Inc. | 9 | * Copyright 2000,2001 MontaVista Software Inc. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
17 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
18 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
22 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
23 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | * | ||
30 | * Send feedback to <scottm@somanetworks.com> | 11 | * Send feedback to <scottm@somanetworks.com> |
31 | */ | 12 | */ |
32 | 13 | ||
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index c2bbe6b65d06..db78b394a075 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | */ | 13 | */ |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 70967ac75265..1797e36ec586 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | * Jan 12, 2003 - Added 66/100/133MHz PCI-X support, | 13 | * Jan 12, 2003 - Added 66/100/133MHz PCI-X support, |
@@ -835,7 +821,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
835 | 821 | ||
836 | bus = pdev->subordinate; | 822 | bus = pdev->subordinate; |
837 | if (!bus) { | 823 | if (!bus) { |
838 | dev_notice(&pdev->dev, "the device is not a bridge, skipping\n"); | 824 | pci_notice(pdev, "the device is not a bridge, skipping\n"); |
839 | rc = -ENODEV; | 825 | rc = -ENODEV; |
840 | goto err_disable_device; | 826 | goto err_disable_device; |
841 | } | 827 | } |
@@ -883,7 +869,6 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
883 | 869 | ||
884 | ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); | 870 | ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); |
885 | if (!ctrl) { | 871 | if (!ctrl) { |
886 | err("%s : out of memory\n", __func__); | ||
887 | rc = -ENOMEM; | 872 | rc = -ENOMEM; |
888 | goto err_disable_device; | 873 | goto err_disable_device; |
889 | } | 874 | } |
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index a93069e739cb..b1b6e45253b2 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | */ | 13 | */ |
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c index daae8071a156..00cd2b43364f 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.c +++ b/drivers/pci/hotplug/cpqphp_nvram.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | */ | 13 | */ |
diff --git a/drivers/pci/hotplug/cpqphp_nvram.h b/drivers/pci/hotplug/cpqphp_nvram.h index 34e4e54fcf15..918ff8dbfe62 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.h +++ b/drivers/pci/hotplug/cpqphp_nvram.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -6,21 +7,6 @@ | |||
6 | * | 7 | * |
7 | * All rights reserved. | 8 | * All rights reserved. |
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Send feedback to <greg@kroah.com> | 10 | * Send feedback to <greg@kroah.com> |
25 | * | 11 | * |
26 | */ | 12 | */ |
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index e220d49307bd..1b2b3f3b648b 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | */ | 13 | */ |
@@ -89,7 +75,9 @@ int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func) | |||
89 | pci_lock_rescan_remove(); | 75 | pci_lock_rescan_remove(); |
90 | 76 | ||
91 | if (func->pci_dev == NULL) | 77 | if (func->pci_dev == NULL) |
92 | func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function)); | 78 | func->pci_dev = pci_get_domain_bus_and_slot(0, func->bus, |
79 | PCI_DEVFN(func->device, | ||
80 | func->function)); | ||
93 | 81 | ||
94 | /* No pci device, we need to create it then */ | 82 | /* No pci device, we need to create it then */ |
95 | if (func->pci_dev == NULL) { | 83 | if (func->pci_dev == NULL) { |
@@ -99,7 +87,9 @@ int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func) | |||
99 | if (num) | 87 | if (num) |
100 | pci_bus_add_devices(ctrl->pci_dev->bus); | 88 | pci_bus_add_devices(ctrl->pci_dev->bus); |
101 | 89 | ||
102 | func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function)); | 90 | func->pci_dev = pci_get_domain_bus_and_slot(0, func->bus, |
91 | PCI_DEVFN(func->device, | ||
92 | func->function)); | ||
103 | if (func->pci_dev == NULL) { | 93 | if (func->pci_dev == NULL) { |
104 | dbg("ERROR: pci_dev still null\n"); | 94 | dbg("ERROR: pci_dev still null\n"); |
105 | goto out; | 95 | goto out; |
@@ -129,7 +119,10 @@ int cpqhp_unconfigure_device(struct pci_func *func) | |||
129 | 119 | ||
130 | pci_lock_rescan_remove(); | 120 | pci_lock_rescan_remove(); |
131 | for (j = 0; j < 8 ; j++) { | 121 | for (j = 0; j < 8 ; j++) { |
132 | struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j)); | 122 | struct pci_dev *temp = pci_get_domain_bus_and_slot(0, |
123 | func->bus, | ||
124 | PCI_DEVFN(func->device, | ||
125 | j)); | ||
133 | if (temp) { | 126 | if (temp) { |
134 | pci_dev_put(temp); | 127 | pci_dev_put(temp); |
135 | pci_stop_and_remove_bus_device(temp); | 128 | pci_stop_and_remove_bus_device(temp); |
@@ -319,6 +312,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) | |||
319 | int cloop = 0; | 312 | int cloop = 0; |
320 | int stop_it; | 313 | int stop_it; |
321 | int index; | 314 | int index; |
315 | u16 devfn; | ||
322 | 316 | ||
323 | /* Decide which slots are supported */ | 317 | /* Decide which slots are supported */ |
324 | 318 | ||
@@ -416,7 +410,9 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) | |||
416 | new_slot->switch_save = 0x10; | 410 | new_slot->switch_save = 0x10; |
417 | /* In case of unsupported board */ | 411 | /* In case of unsupported board */ |
418 | new_slot->status = DevError; | 412 | new_slot->status = DevError; |
419 | new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function); | 413 | devfn = (new_slot->device << 3) | new_slot->function; |
414 | new_slot->pci_dev = pci_get_domain_bus_and_slot(0, | ||
415 | new_slot->bus, devfn); | ||
420 | 416 | ||
421 | for (cloop = 0; cloop < 0x20; cloop++) { | 417 | for (cloop = 0; cloop < 0x20; cloop++) { |
422 | rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop])); | 418 | rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop])); |
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c index 775974deda74..fed1360ee9b1 100644 --- a/drivers/pci/hotplug/cpqphp_sysfs.c +++ b/drivers/pci/hotplug/cpqphp_sysfs.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | */ | 13 | */ |
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h index d3256838cb05..fddb78606c74 100644 --- a/drivers/pci/hotplug/ibmphp.h +++ b/drivers/pci/hotplug/ibmphp.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | #ifndef __IBMPHP_H | 2 | #ifndef __IBMPHP_H |
2 | #define __IBMPHP_H | 3 | #define __IBMPHP_H |
3 | 4 | ||
@@ -11,21 +12,6 @@ | |||
11 | * | 12 | * |
12 | * All rights reserved. | 13 | * All rights reserved. |
13 | * | 14 | * |
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or (at | ||
17 | * your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, but | ||
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
22 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
23 | * details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | * | ||
29 | * Send feedback to <gregkh@us.ibm.com> | 15 | * Send feedback to <gregkh@us.ibm.com> |
30 | * | 16 | * |
31 | */ | 17 | */ |
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 73cf84645c82..b81ca3fa0e84 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * IBM Hot Plug Controller Driver | 3 | * IBM Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <gregkh@us.ibm.com> | 12 | * Send feedback to <gregkh@us.ibm.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -603,10 +589,8 @@ int ibmphp_update_slot_info(struct slot *slot_cur) | |||
603 | u8 mode; | 589 | u8 mode; |
604 | 590 | ||
605 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 591 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
606 | if (!info) { | 592 | if (!info) |
607 | err("out of system memory\n"); | ||
608 | return -ENOMEM; | 593 | return -ENOMEM; |
609 | } | ||
610 | 594 | ||
611 | info->power_status = SLOT_PWRGD(slot_cur->status); | 595 | info->power_status = SLOT_PWRGD(slot_cur->status); |
612 | info->attention_status = SLOT_ATTN(slot_cur->status, | 596 | info->attention_status = SLOT_ATTN(slot_cur->status, |
@@ -707,7 +691,8 @@ static void ibm_unconfigure_device(struct pci_func *func) | |||
707 | pci_lock_rescan_remove(); | 691 | pci_lock_rescan_remove(); |
708 | 692 | ||
709 | for (j = 0; j < 0x08; j++) { | 693 | for (j = 0; j < 0x08; j++) { |
710 | temp = pci_get_bus_and_slot(func->busno, (func->device << 3) | j); | 694 | temp = pci_get_domain_bus_and_slot(0, func->busno, |
695 | (func->device << 3) | j); | ||
711 | if (temp) { | 696 | if (temp) { |
712 | pci_stop_and_remove_bus_device(temp); | 697 | pci_stop_and_remove_bus_device(temp); |
713 | pci_dev_put(temp); | 698 | pci_dev_put(temp); |
@@ -734,14 +719,12 @@ static u8 bus_structure_fixup(u8 busno) | |||
734 | return 1; | 719 | return 1; |
735 | 720 | ||
736 | bus = kmalloc(sizeof(*bus), GFP_KERNEL); | 721 | bus = kmalloc(sizeof(*bus), GFP_KERNEL); |
737 | if (!bus) { | 722 | if (!bus) |
738 | err("%s - out of memory\n", __func__); | ||
739 | return 1; | 723 | return 1; |
740 | } | 724 | |
741 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 725 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); |
742 | if (!dev) { | 726 | if (!dev) { |
743 | kfree(bus); | 727 | kfree(bus); |
744 | err("%s - out of memory\n", __func__); | ||
745 | return 1; | 728 | return 1; |
746 | } | 729 | } |
747 | 730 | ||
@@ -780,7 +763,7 @@ static int ibm_configure_device(struct pci_func *func) | |||
780 | if (!(bus_structure_fixup(func->busno))) | 763 | if (!(bus_structure_fixup(func->busno))) |
781 | flag = 1; | 764 | flag = 1; |
782 | if (func->dev == NULL) | 765 | if (func->dev == NULL) |
783 | func->dev = pci_get_bus_and_slot(func->busno, | 766 | func->dev = pci_get_domain_bus_and_slot(0, func->busno, |
784 | PCI_DEVFN(func->device, func->function)); | 767 | PCI_DEVFN(func->device, func->function)); |
785 | 768 | ||
786 | if (func->dev == NULL) { | 769 | if (func->dev == NULL) { |
@@ -793,7 +776,7 @@ static int ibm_configure_device(struct pci_func *func) | |||
793 | if (num) | 776 | if (num) |
794 | pci_bus_add_devices(bus); | 777 | pci_bus_add_devices(bus); |
795 | 778 | ||
796 | func->dev = pci_get_bus_and_slot(func->busno, | 779 | func->dev = pci_get_domain_bus_and_slot(0, func->busno, |
797 | PCI_DEVFN(func->device, func->function)); | 780 | PCI_DEVFN(func->device, func->function)); |
798 | if (func->dev == NULL) { | 781 | if (func->dev == NULL) { |
799 | err("ERROR... : pci_dev still NULL\n"); | 782 | err("ERROR... : pci_dev still NULL\n"); |
@@ -1101,7 +1084,6 @@ static int enable_slot(struct hotplug_slot *hs) | |||
1101 | if (!slot_cur->func) { | 1084 | if (!slot_cur->func) { |
1102 | /* We cannot do update_slot_info here, since no memory for | 1085 | /* We cannot do update_slot_info here, since no memory for |
1103 | * kmalloc n.e.ways, and update_slot_info allocates some */ | 1086 | * kmalloc n.e.ways, and update_slot_info allocates some */ |
1104 | err("out of system memory\n"); | ||
1105 | rc = -ENOMEM; | 1087 | rc = -ENOMEM; |
1106 | goto error_power; | 1088 | goto error_power; |
1107 | } | 1089 | } |
@@ -1208,7 +1190,6 @@ int ibmphp_do_disable_slot(struct slot *slot_cur) | |||
1208 | /* We need this for functions that were there on bootup */ | 1190 | /* We need this for functions that were there on bootup */ |
1209 | slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); | 1191 | slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); |
1210 | if (!slot_cur->func) { | 1192 | if (!slot_cur->func) { |
1211 | err("out of system memory\n"); | ||
1212 | rc = -ENOMEM; | 1193 | rc = -ENOMEM; |
1213 | goto error; | 1194 | goto error; |
1214 | } | 1195 | } |
@@ -1306,7 +1287,6 @@ static int __init ibmphp_init(void) | |||
1306 | 1287 | ||
1307 | ibmphp_pci_bus = kmalloc(sizeof(*ibmphp_pci_bus), GFP_KERNEL); | 1288 | ibmphp_pci_bus = kmalloc(sizeof(*ibmphp_pci_bus), GFP_KERNEL); |
1308 | if (!ibmphp_pci_bus) { | 1289 | if (!ibmphp_pci_bus) { |
1309 | err("out of memory\n"); | ||
1310 | rc = -ENOMEM; | 1290 | rc = -ENOMEM; |
1311 | goto exit; | 1291 | goto exit; |
1312 | } | 1292 | } |
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index a6a4dac798e5..64549aa24c0f 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * IBM Hot Plug Controller Driver | 3 | * IBM Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <gregkh@us.ibm.com> | 12 | * Send feedback to <gregkh@us.ibm.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c index a6b458e4ab46..752c384cbd4c 100644 --- a/drivers/pci/hotplug/ibmphp_hpc.c +++ b/drivers/pci/hotplug/ibmphp_hpc.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * IBM Hot Plug Controller Driver | 3 | * IBM Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <gregkh@us.ibm.com> | 11 | * Send feedback to <gregkh@us.ibm.com> |
26 | * <jshah@us.ibm.com> | 12 | * <jshah@us.ibm.com> |
27 | * | 13 | * |
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index 25edd0b18b75..e22d023f91d1 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * IBM Hot Plug Controller Driver | 3 | * IBM Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <gregkh@us.ibm.com> | 12 | * Send feedback to <gregkh@us.ibm.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -167,10 +153,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) | |||
167 | goto error; | 153 | goto error; |
168 | } | 154 | } |
169 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 155 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
170 | if (!newfunc) { | 156 | if (!newfunc) |
171 | err("out of system memory\n"); | ||
172 | return -ENOMEM; | 157 | return -ENOMEM; |
173 | } | 158 | |
174 | newfunc->busno = cur_func->busno; | 159 | newfunc->busno = cur_func->busno; |
175 | newfunc->device = device; | 160 | newfunc->device = device; |
176 | cur_func->next = newfunc; | 161 | cur_func->next = newfunc; |
@@ -205,10 +190,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) | |||
205 | for (i = 0; i < 32; i++) { | 190 | for (i = 0; i < 32; i++) { |
206 | if (func->devices[i]) { | 191 | if (func->devices[i]) { |
207 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 192 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
208 | if (!newfunc) { | 193 | if (!newfunc) |
209 | err("out of system memory\n"); | ||
210 | return -ENOMEM; | 194 | return -ENOMEM; |
211 | } | 195 | |
212 | newfunc->busno = sec_number; | 196 | newfunc->busno = sec_number; |
213 | newfunc->device = (u8) i; | 197 | newfunc->device = (u8) i; |
214 | for (j = 0; j < 4; j++) | 198 | for (j = 0; j < 4; j++) |
@@ -233,10 +217,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) | |||
233 | } | 217 | } |
234 | 218 | ||
235 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 219 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
236 | if (!newfunc) { | 220 | if (!newfunc) |
237 | err("out of system memory\n"); | ||
238 | return -ENOMEM; | 221 | return -ENOMEM; |
239 | } | 222 | |
240 | newfunc->busno = cur_func->busno; | 223 | newfunc->busno = cur_func->busno; |
241 | newfunc->device = device; | 224 | newfunc->device = device; |
242 | for (j = 0; j < 4; j++) | 225 | for (j = 0; j < 4; j++) |
@@ -279,10 +262,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) | |||
279 | if (func->devices[i]) { | 262 | if (func->devices[i]) { |
280 | debug("inside for loop, device is %x\n", i); | 263 | debug("inside for loop, device is %x\n", i); |
281 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); | 264 | newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); |
282 | if (!newfunc) { | 265 | if (!newfunc) |
283 | err(" out of system memory\n"); | ||
284 | return -ENOMEM; | 266 | return -ENOMEM; |
285 | } | 267 | |
286 | newfunc->busno = sec_number; | 268 | newfunc->busno = sec_number; |
287 | newfunc->device = (u8) i; | 269 | newfunc->device = (u8) i; |
288 | for (j = 0; j < 4; j++) | 270 | for (j = 0; j < 4; j++) |
@@ -405,10 +387,9 @@ static int configure_device(struct pci_func *func) | |||
405 | 387 | ||
406 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 388 | io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
407 | 389 | ||
408 | if (!io[count]) { | 390 | if (!io[count]) |
409 | err("out of system memory\n"); | ||
410 | return -ENOMEM; | 391 | return -ENOMEM; |
411 | } | 392 | |
412 | io[count]->type = IO; | 393 | io[count]->type = IO; |
413 | io[count]->busno = func->busno; | 394 | io[count]->busno = func->busno; |
414 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); | 395 | io[count]->devfunc = PCI_DEVFN(func->device, func->function); |
@@ -442,10 +423,9 @@ static int configure_device(struct pci_func *func) | |||
442 | debug("len[count] in PFMEM %x, count %d\n", len[count], count); | 423 | debug("len[count] in PFMEM %x, count %d\n", len[count], count); |
443 | 424 | ||
444 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 425 | pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
445 | if (!pfmem[count]) { | 426 | if (!pfmem[count]) |
446 | err("out of system memory\n"); | ||
447 | return -ENOMEM; | 427 | return -ENOMEM; |
448 | } | 428 | |
449 | pfmem[count]->type = PFMEM; | 429 | pfmem[count]->type = PFMEM; |
450 | pfmem[count]->busno = func->busno; | 430 | pfmem[count]->busno = func->busno; |
451 | pfmem[count]->devfunc = PCI_DEVFN(func->device, | 431 | pfmem[count]->devfunc = PCI_DEVFN(func->device, |
@@ -458,7 +438,6 @@ static int configure_device(struct pci_func *func) | |||
458 | } else { | 438 | } else { |
459 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 439 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
460 | if (!mem_tmp) { | 440 | if (!mem_tmp) { |
461 | err("out of system memory\n"); | ||
462 | kfree(pfmem[count]); | 441 | kfree(pfmem[count]); |
463 | return -ENOMEM; | 442 | return -ENOMEM; |
464 | } | 443 | } |
@@ -508,10 +487,9 @@ static int configure_device(struct pci_func *func) | |||
508 | debug("len[count] in Mem %x, count %d\n", len[count], count); | 487 | debug("len[count] in Mem %x, count %d\n", len[count], count); |
509 | 488 | ||
510 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 489 | mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
511 | if (!mem[count]) { | 490 | if (!mem[count]) |
512 | err("out of system memory\n"); | ||
513 | return -ENOMEM; | 491 | return -ENOMEM; |
514 | } | 492 | |
515 | mem[count]->type = MEM; | 493 | mem[count]->type = MEM; |
516 | mem[count]->busno = func->busno; | 494 | mem[count]->busno = func->busno; |
517 | mem[count]->devfunc = PCI_DEVFN(func->device, | 495 | mem[count]->devfunc = PCI_DEVFN(func->device, |
@@ -674,7 +652,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
674 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 652 | bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
675 | 653 | ||
676 | if (!bus_io[count]) { | 654 | if (!bus_io[count]) { |
677 | err("out of system memory\n"); | ||
678 | retval = -ENOMEM; | 655 | retval = -ENOMEM; |
679 | goto error; | 656 | goto error; |
680 | } | 657 | } |
@@ -706,7 +683,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
706 | 683 | ||
707 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 684 | bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
708 | if (!bus_pfmem[count]) { | 685 | if (!bus_pfmem[count]) { |
709 | err("out of system memory\n"); | ||
710 | retval = -ENOMEM; | 686 | retval = -ENOMEM; |
711 | goto error; | 687 | goto error; |
712 | } | 688 | } |
@@ -722,7 +698,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
722 | } else { | 698 | } else { |
723 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 699 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
724 | if (!mem_tmp) { | 700 | if (!mem_tmp) { |
725 | err("out of system memory\n"); | ||
726 | retval = -ENOMEM; | 701 | retval = -ENOMEM; |
727 | goto error; | 702 | goto error; |
728 | } | 703 | } |
@@ -763,7 +738,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
763 | 738 | ||
764 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 739 | bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
765 | if (!bus_mem[count]) { | 740 | if (!bus_mem[count]) { |
766 | err("out of system memory\n"); | ||
767 | retval = -ENOMEM; | 741 | retval = -ENOMEM; |
768 | goto error; | 742 | goto error; |
769 | } | 743 | } |
@@ -834,7 +808,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
834 | io = kzalloc(sizeof(*io), GFP_KERNEL); | 808 | io = kzalloc(sizeof(*io), GFP_KERNEL); |
835 | 809 | ||
836 | if (!io) { | 810 | if (!io) { |
837 | err("out of system memory\n"); | ||
838 | retval = -ENOMEM; | 811 | retval = -ENOMEM; |
839 | goto error; | 812 | goto error; |
840 | } | 813 | } |
@@ -856,7 +829,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
856 | debug("it wants %x memory behind the bridge\n", amount_needed->mem); | 829 | debug("it wants %x memory behind the bridge\n", amount_needed->mem); |
857 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); | 830 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); |
858 | if (!mem) { | 831 | if (!mem) { |
859 | err("out of system memory\n"); | ||
860 | retval = -ENOMEM; | 832 | retval = -ENOMEM; |
861 | goto error; | 833 | goto error; |
862 | } | 834 | } |
@@ -878,7 +850,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
878 | debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); | 850 | debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); |
879 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); | 851 | pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); |
880 | if (!pfmem) { | 852 | if (!pfmem) { |
881 | err("out of system memory\n"); | ||
882 | retval = -ENOMEM; | 853 | retval = -ENOMEM; |
883 | goto error; | 854 | goto error; |
884 | } | 855 | } |
@@ -893,7 +864,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
893 | } else { | 864 | } else { |
894 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); | 865 | mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); |
895 | if (!mem_tmp) { | 866 | if (!mem_tmp) { |
896 | err("out of system memory\n"); | ||
897 | retval = -ENOMEM; | 867 | retval = -ENOMEM; |
898 | goto error; | 868 | goto error; |
899 | } | 869 | } |
@@ -924,7 +894,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) | |||
924 | if (!bus) { | 894 | if (!bus) { |
925 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); | 895 | bus = kzalloc(sizeof(*bus), GFP_KERNEL); |
926 | if (!bus) { | 896 | if (!bus) { |
927 | err("out of system memory\n"); | ||
928 | retval = -ENOMEM; | 897 | retval = -ENOMEM; |
929 | goto error; | 898 | goto error; |
930 | } | 899 | } |
@@ -1652,10 +1621,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re | |||
1652 | } | 1621 | } |
1653 | if (io) { | 1622 | if (io) { |
1654 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); | 1623 | io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); |
1655 | if (!io_range) { | 1624 | if (!io_range) |
1656 | err("out of system memory\n"); | ||
1657 | return -ENOMEM; | 1625 | return -ENOMEM; |
1658 | } | 1626 | |
1659 | io_range->start = io->start; | 1627 | io_range->start = io->start; |
1660 | io_range->end = io->end; | 1628 | io_range->end = io->end; |
1661 | io_range->rangeno = 1; | 1629 | io_range->rangeno = 1; |
@@ -1664,10 +1632,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re | |||
1664 | } | 1632 | } |
1665 | if (mem) { | 1633 | if (mem) { |
1666 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); | 1634 | mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); |
1667 | if (!mem_range) { | 1635 | if (!mem_range) |
1668 | err("out of system memory\n"); | ||
1669 | return -ENOMEM; | 1636 | return -ENOMEM; |
1670 | } | 1637 | |
1671 | mem_range->start = mem->start; | 1638 | mem_range->start = mem->start; |
1672 | mem_range->end = mem->end; | 1639 | mem_range->end = mem->end; |
1673 | mem_range->rangeno = 1; | 1640 | mem_range->rangeno = 1; |
@@ -1676,10 +1643,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re | |||
1676 | } | 1643 | } |
1677 | if (pfmem) { | 1644 | if (pfmem) { |
1678 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); | 1645 | pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); |
1679 | if (!pfmem_range) { | 1646 | if (!pfmem_range) |
1680 | err("out of system memory\n"); | ||
1681 | return -ENOMEM; | 1647 | return -ENOMEM; |
1682 | } | 1648 | |
1683 | pfmem_range->start = pfmem->start; | 1649 | pfmem_range->start = pfmem->start; |
1684 | pfmem_range->end = pfmem->end; | 1650 | pfmem_range->end = pfmem->end; |
1685 | pfmem_range->rangeno = 1; | 1651 | pfmem_range->rangeno = 1; |
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c index aee6e41001e1..5e8caf7a4452 100644 --- a/drivers/pci/hotplug/ibmphp_res.c +++ b/drivers/pci/hotplug/ibmphp_res.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * IBM Hot Plug Controller Driver | 3 | * IBM Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <gregkh@us.ibm.com> | 12 | * Send feedback to <gregkh@us.ibm.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -56,10 +42,8 @@ static struct bus_node * __init alloc_error_bus(struct ebda_pci_rsrc *curr, u8 b | |||
56 | } | 42 | } |
57 | 43 | ||
58 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); | 44 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
59 | if (!newbus) { | 45 | if (!newbus) |
60 | err("out of system memory\n"); | ||
61 | return NULL; | 46 | return NULL; |
62 | } | ||
63 | 47 | ||
64 | if (flag) | 48 | if (flag) |
65 | newbus->busno = busno; | 49 | newbus->busno = busno; |
@@ -79,10 +63,9 @@ static struct resource_node * __init alloc_resources(struct ebda_pci_rsrc *curr) | |||
79 | } | 63 | } |
80 | 64 | ||
81 | rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 65 | rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
82 | if (!rs) { | 66 | if (!rs) |
83 | err("out of system memory\n"); | ||
84 | return NULL; | 67 | return NULL; |
85 | } | 68 | |
86 | rs->busno = curr->bus_num; | 69 | rs->busno = curr->bus_num; |
87 | rs->devfunc = curr->dev_fun; | 70 | rs->devfunc = curr->dev_fun; |
88 | rs->start = curr->start_addr; | 71 | rs->start = curr->start_addr; |
@@ -99,10 +82,9 @@ static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node * | |||
99 | 82 | ||
100 | if (first_bus) { | 83 | if (first_bus) { |
101 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); | 84 | newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); |
102 | if (!newbus) { | 85 | if (!newbus) |
103 | err("out of system memory.\n"); | ||
104 | return -ENOMEM; | 86 | return -ENOMEM; |
105 | } | 87 | |
106 | newbus->busno = curr->bus_num; | 88 | newbus->busno = curr->bus_num; |
107 | } else { | 89 | } else { |
108 | newbus = *new_bus; | 90 | newbus = *new_bus; |
@@ -123,7 +105,6 @@ static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node * | |||
123 | if (!newrange) { | 105 | if (!newrange) { |
124 | if (first_bus) | 106 | if (first_bus) |
125 | kfree(newbus); | 107 | kfree(newbus); |
126 | err("out of system memory\n"); | ||
127 | return -ENOMEM; | 108 | return -ENOMEM; |
128 | } | 109 | } |
129 | newrange->start = curr->start_addr; | 110 | newrange->start = curr->start_addr; |
@@ -1707,10 +1688,9 @@ static int __init once_over(void) | |||
1707 | bus_cur->firstPFMemFromMem = pfmem_cur; | 1688 | bus_cur->firstPFMemFromMem = pfmem_cur; |
1708 | 1689 | ||
1709 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 1690 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
1710 | if (!mem) { | 1691 | if (!mem) |
1711 | err("out of system memory\n"); | ||
1712 | return -ENOMEM; | 1692 | return -ENOMEM; |
1713 | } | 1693 | |
1714 | mem->type = MEM; | 1694 | mem->type = MEM; |
1715 | mem->busno = pfmem_cur->busno; | 1695 | mem->busno = pfmem_cur->busno; |
1716 | mem->devfunc = pfmem_cur->devfunc; | 1696 | mem->devfunc = pfmem_cur->devfunc; |
@@ -1989,10 +1969,9 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
1989 | 1969 | ||
1990 | if ((start_address) && (start_address <= end_address)) { | 1970 | if ((start_address) && (start_address <= end_address)) { |
1991 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 1971 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
1992 | if (!range) { | 1972 | if (!range) |
1993 | err("out of system memory\n"); | ||
1994 | return -ENOMEM; | 1973 | return -ENOMEM; |
1995 | } | 1974 | |
1996 | range->start = start_address; | 1975 | range->start = start_address; |
1997 | range->end = end_address + 0xfff; | 1976 | range->end = end_address + 0xfff; |
1998 | 1977 | ||
@@ -2016,7 +1995,6 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
2016 | io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 1995 | io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2017 | if (!io) { | 1996 | if (!io) { |
2018 | kfree(range); | 1997 | kfree(range); |
2019 | err("out of system memory\n"); | ||
2020 | return -ENOMEM; | 1998 | return -ENOMEM; |
2021 | } | 1999 | } |
2022 | io->type = IO; | 2000 | io->type = IO; |
@@ -2038,10 +2016,9 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
2038 | if ((start_address) && (start_address <= end_address)) { | 2016 | if ((start_address) && (start_address <= end_address)) { |
2039 | 2017 | ||
2040 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 2018 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2041 | if (!range) { | 2019 | if (!range) |
2042 | err("out of system memory\n"); | ||
2043 | return -ENOMEM; | 2020 | return -ENOMEM; |
2044 | } | 2021 | |
2045 | range->start = start_address; | 2022 | range->start = start_address; |
2046 | range->end = end_address + 0xfffff; | 2023 | range->end = end_address + 0xfffff; |
2047 | 2024 | ||
@@ -2066,7 +2043,6 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
2066 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 2043 | mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2067 | if (!mem) { | 2044 | if (!mem) { |
2068 | kfree(range); | 2045 | kfree(range); |
2069 | err("out of system memory\n"); | ||
2070 | return -ENOMEM; | 2046 | return -ENOMEM; |
2071 | } | 2047 | } |
2072 | mem->type = MEM; | 2048 | mem->type = MEM; |
@@ -2092,10 +2068,9 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
2092 | if ((start_address) && (start_address <= end_address)) { | 2068 | if ((start_address) && (start_address <= end_address)) { |
2093 | 2069 | ||
2094 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); | 2070 | range = kzalloc(sizeof(struct range_node), GFP_KERNEL); |
2095 | if (!range) { | 2071 | if (!range) |
2096 | err("out of system memory\n"); | ||
2097 | return -ENOMEM; | 2072 | return -ENOMEM; |
2098 | } | 2073 | |
2099 | range->start = start_address; | 2074 | range->start = start_address; |
2100 | range->end = end_address + 0xfffff; | 2075 | range->end = end_address + 0xfffff; |
2101 | 2076 | ||
@@ -2119,7 +2094,6 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
2119 | pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); | 2094 | pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); |
2120 | if (!pfmem) { | 2095 | if (!pfmem) { |
2121 | kfree(range); | 2096 | kfree(range); |
2122 | err("out of system memory\n"); | ||
2123 | return -ENOMEM; | 2097 | return -ENOMEM; |
2124 | } | 2098 | } |
2125 | pfmem->type = PFMEM; | 2099 | pfmem->type = PFMEM; |
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c index 7b0e97be9063..af92fed46ab7 100644 --- a/drivers/pci/hotplug/pci_hotplug_core.c +++ b/drivers/pci/hotplug/pci_hotplug_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI HotPlug Controller Core | 3 | * PCI HotPlug Controller Core |
3 | * | 4 | * |
@@ -6,21 +7,6 @@ | |||
6 | * | 7 | * |
7 | * All rights reserved. | 8 | * All rights reserved. |
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Send feedback to <kristen.c.accardi@intel.com> | 10 | * Send feedback to <kristen.c.accardi@intel.com> |
25 | * | 11 | * |
26 | * Authors: | 12 | * Authors: |
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 06109d40c4ac..636ed8f4b869 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * PCI Express Hot Plug Controller Driver | 3 | * PCI Express Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 35d84845d5af..332b723ff9e6 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Express Hot Plug Controller Driver | 3 | * PCI Express Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | * Authors: | 14 | * Authors: |
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 83f3d4af3677..c684faa43387 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Express Hot Plug Controller Driver | 3 | * PCI Express Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 7bab0606f1a9..18a42f8f5dc5 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Express PCI Hot Plug Driver | 3 | * PCI Express PCI Hot Plug Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -838,16 +824,22 @@ struct controller *pcie_init(struct pcie_device *dev) | |||
838 | struct pci_dev *pdev = dev->port; | 824 | struct pci_dev *pdev = dev->port; |
839 | 825 | ||
840 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); | 826 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
841 | if (!ctrl) { | 827 | if (!ctrl) |
842 | dev_err(&dev->device, "%s: Out of memory\n", __func__); | ||
843 | goto abort; | 828 | goto abort; |
844 | } | 829 | |
845 | ctrl->pcie = dev; | 830 | ctrl->pcie = dev; |
846 | pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap); | 831 | pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap); |
847 | 832 | ||
848 | if (pdev->hotplug_user_indicators) | 833 | if (pdev->hotplug_user_indicators) |
849 | slot_cap &= ~(PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_PIP); | 834 | slot_cap &= ~(PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_PIP); |
850 | 835 | ||
836 | /* | ||
837 | * We assume no Thunderbolt controllers support Command Complete events, | ||
838 | * but some controllers falsely claim they do. | ||
839 | */ | ||
840 | if (pdev->is_thunderbolt) | ||
841 | slot_cap |= PCI_EXP_SLTCAP_NCCS; | ||
842 | |||
851 | ctrl->slot_cap = slot_cap; | 843 | ctrl->slot_cap = slot_cap; |
852 | mutex_init(&ctrl->ctrl_lock); | 844 | mutex_init(&ctrl->ctrl_lock); |
853 | init_waitqueue_head(&ctrl->queue); | 845 | init_waitqueue_head(&ctrl->queue); |
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 2a1ca020cf5a..3f518dea856d 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Express Hot Plug Controller Driver | 3 | * PCI Express Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -79,7 +65,6 @@ int pciehp_configure_device(struct slot *p_slot) | |||
79 | int pciehp_unconfigure_device(struct slot *p_slot) | 65 | int pciehp_unconfigure_device(struct slot *p_slot) |
80 | { | 66 | { |
81 | int rc = 0; | 67 | int rc = 0; |
82 | u8 bctl = 0; | ||
83 | u8 presence = 0; | 68 | u8 presence = 0; |
84 | struct pci_dev *dev, *temp; | 69 | struct pci_dev *dev, *temp; |
85 | struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate; | 70 | struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate; |
@@ -101,17 +86,6 @@ int pciehp_unconfigure_device(struct slot *p_slot) | |||
101 | list_for_each_entry_safe_reverse(dev, temp, &parent->devices, | 86 | list_for_each_entry_safe_reverse(dev, temp, &parent->devices, |
102 | bus_list) { | 87 | bus_list) { |
103 | pci_dev_get(dev); | 88 | pci_dev_get(dev); |
104 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { | ||
105 | pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl); | ||
106 | if (bctl & PCI_BRIDGE_CTL_VGA) { | ||
107 | ctrl_err(ctrl, | ||
108 | "Cannot remove display device %s\n", | ||
109 | pci_name(dev)); | ||
110 | pci_dev_put(dev); | ||
111 | rc = -EINVAL; | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | if (!presence) { | 89 | if (!presence) { |
116 | pci_dev_set_disconnected(dev, NULL); | 90 | pci_dev_set_disconnected(dev, NULL); |
117 | if (pci_has_subordinate(dev)) | 91 | if (pci_has_subordinate(dev)) |
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c index 172ed89200cd..c19694a04d2c 100644 --- a/drivers/pci/hotplug/pcihp_skeleton.c +++ b/drivers/pci/hotplug/pcihp_skeleton.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Hot Plug Controller Skeleton Driver - 0.3 | 3 | * PCI Hot Plug Controller Skeleton Driver - 0.3 |
3 | * | 4 | * |
@@ -6,21 +7,6 @@ | |||
6 | * | 7 | * |
7 | * All rights reserved. | 8 | * All rights reserved. |
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
17 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
18 | * details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * This driver is to be used as a skeleton driver to show how to interface | 10 | * This driver is to be used as a skeleton driver to show how to interface |
25 | * with the pci hotplug core easily. | 11 | * with the pci hotplug core easily. |
26 | * | 12 | * |
diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c index 74f6a17e4614..23da3046f160 100644 --- a/drivers/pci/hotplug/pnv_php.c +++ b/drivers/pci/hotplug/pnv_php.c | |||
@@ -1,12 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Hotplug Driver for PowerPC PowerNV platform. | 3 | * PCI Hotplug Driver for PowerPC PowerNV platform. |
3 | * | 4 | * |
4 | * Copyright Gavin Shan, IBM Corporation 2016. | 5 | * Copyright Gavin Shan, IBM Corporation 2016. |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | 6 | */ |
11 | 7 | ||
12 | #include <linux/libfdt.h> | 8 | #include <linux/libfdt.h> |
@@ -266,22 +262,18 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot) | |||
266 | fdt1 = kzalloc(0x10000, GFP_KERNEL); | 262 | fdt1 = kzalloc(0x10000, GFP_KERNEL); |
267 | if (!fdt1) { | 263 | if (!fdt1) { |
268 | ret = -ENOMEM; | 264 | ret = -ENOMEM; |
269 | dev_warn(&php_slot->pdev->dev, "Cannot alloc FDT blob\n"); | ||
270 | goto out; | 265 | goto out; |
271 | } | 266 | } |
272 | 267 | ||
273 | ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000); | 268 | ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000); |
274 | if (ret) { | 269 | if (ret) { |
275 | dev_warn(&php_slot->pdev->dev, "Error %d getting FDT blob\n", | 270 | pci_warn(php_slot->pdev, "Error %d getting FDT blob\n", ret); |
276 | ret); | ||
277 | goto free_fdt1; | 271 | goto free_fdt1; |
278 | } | 272 | } |
279 | 273 | ||
280 | fdt = kzalloc(fdt_totalsize(fdt1), GFP_KERNEL); | 274 | fdt = kzalloc(fdt_totalsize(fdt1), GFP_KERNEL); |
281 | if (!fdt) { | 275 | if (!fdt) { |
282 | ret = -ENOMEM; | 276 | ret = -ENOMEM; |
283 | dev_warn(&php_slot->pdev->dev, "Cannot %d bytes memory\n", | ||
284 | fdt_totalsize(fdt1)); | ||
285 | goto free_fdt1; | 277 | goto free_fdt1; |
286 | } | 278 | } |
287 | 279 | ||
@@ -290,7 +282,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot) | |||
290 | dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL); | 282 | dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL); |
291 | if (!dt) { | 283 | if (!dt) { |
292 | ret = -EINVAL; | 284 | ret = -EINVAL; |
293 | dev_warn(&php_slot->pdev->dev, "Cannot unflatten FDT\n"); | 285 | pci_warn(php_slot->pdev, "Cannot unflatten FDT\n"); |
294 | goto free_fdt; | 286 | goto free_fdt; |
295 | } | 287 | } |
296 | 288 | ||
@@ -300,7 +292,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot) | |||
300 | ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn); | 292 | ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn); |
301 | if (ret) { | 293 | if (ret) { |
302 | pnv_php_reverse_nodes(php_slot->dn); | 294 | pnv_php_reverse_nodes(php_slot->dn); |
303 | dev_warn(&php_slot->pdev->dev, "Error %d populating changeset\n", | 295 | pci_warn(php_slot->pdev, "Error %d populating changeset\n", |
304 | ret); | 296 | ret); |
305 | goto free_dt; | 297 | goto free_dt; |
306 | } | 298 | } |
@@ -308,8 +300,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot) | |||
308 | php_slot->dn->child = NULL; | 300 | php_slot->dn->child = NULL; |
309 | ret = of_changeset_apply(&php_slot->ocs); | 301 | ret = of_changeset_apply(&php_slot->ocs); |
310 | if (ret) { | 302 | if (ret) { |
311 | dev_warn(&php_slot->pdev->dev, "Error %d applying changeset\n", | 303 | pci_warn(php_slot->pdev, "Error %d applying changeset\n", ret); |
312 | ret); | ||
313 | goto destroy_changeset; | 304 | goto destroy_changeset; |
314 | } | 305 | } |
315 | 306 | ||
@@ -345,14 +336,14 @@ int pnv_php_set_slot_power_state(struct hotplug_slot *slot, | |||
345 | if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle || | 336 | if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle || |
346 | be64_to_cpu(msg.params[2]) != state || | 337 | be64_to_cpu(msg.params[2]) != state || |
347 | be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) { | 338 | be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) { |
348 | dev_warn(&php_slot->pdev->dev, "Wrong msg (%lld, %lld, %lld)\n", | 339 | pci_warn(php_slot->pdev, "Wrong msg (%lld, %lld, %lld)\n", |
349 | be64_to_cpu(msg.params[1]), | 340 | be64_to_cpu(msg.params[1]), |
350 | be64_to_cpu(msg.params[2]), | 341 | be64_to_cpu(msg.params[2]), |
351 | be64_to_cpu(msg.params[3])); | 342 | be64_to_cpu(msg.params[3])); |
352 | return -ENOMSG; | 343 | return -ENOMSG; |
353 | } | 344 | } |
354 | } else if (ret < 0) { | 345 | } else if (ret < 0) { |
355 | dev_warn(&php_slot->pdev->dev, "Error %d powering %s\n", | 346 | pci_warn(php_slot->pdev, "Error %d powering %s\n", |
356 | ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off"); | 347 | ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off"); |
357 | return ret; | 348 | return ret; |
358 | } | 349 | } |
@@ -379,7 +370,7 @@ static int pnv_php_get_power_state(struct hotplug_slot *slot, u8 *state) | |||
379 | */ | 370 | */ |
380 | ret = pnv_pci_get_power_state(php_slot->id, &power_state); | 371 | ret = pnv_pci_get_power_state(php_slot->id, &power_state); |
381 | if (ret) { | 372 | if (ret) { |
382 | dev_warn(&php_slot->pdev->dev, "Error %d getting power status\n", | 373 | pci_warn(php_slot->pdev, "Error %d getting power status\n", |
383 | ret); | 374 | ret); |
384 | } else { | 375 | } else { |
385 | *state = power_state; | 376 | *state = power_state; |
@@ -405,8 +396,7 @@ static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state) | |||
405 | slot->info->adapter_status = presence; | 396 | slot->info->adapter_status = presence; |
406 | ret = 0; | 397 | ret = 0; |
407 | } else { | 398 | } else { |
408 | dev_warn(&php_slot->pdev->dev, "Error %d getting presence\n", | 399 | pci_warn(php_slot->pdev, "Error %d getting presence\n", ret); |
409 | ret); | ||
410 | } | 400 | } |
411 | 401 | ||
412 | return ret; | 402 | return ret; |
@@ -629,8 +619,7 @@ static int pnv_php_register_slot(struct pnv_php_slot *php_slot) | |||
629 | ret = pci_hp_register(&php_slot->slot, php_slot->bus, | 619 | ret = pci_hp_register(&php_slot->slot, php_slot->bus, |
630 | php_slot->slot_no, php_slot->name); | 620 | php_slot->slot_no, php_slot->name); |
631 | if (ret) { | 621 | if (ret) { |
632 | dev_warn(&php_slot->pdev->dev, "Error %d registering slot\n", | 622 | pci_warn(php_slot->pdev, "Error %d registering slot\n", ret); |
633 | ret); | ||
634 | return ret; | 623 | return ret; |
635 | } | 624 | } |
636 | 625 | ||
@@ -683,7 +672,7 @@ static int pnv_php_enable_msix(struct pnv_php_slot *php_slot) | |||
683 | /* Enable MSIx */ | 672 | /* Enable MSIx */ |
684 | ret = pci_enable_msix_exact(pdev, &entry, 1); | 673 | ret = pci_enable_msix_exact(pdev, &entry, 1); |
685 | if (ret) { | 674 | if (ret) { |
686 | dev_warn(&pdev->dev, "Error %d enabling MSIx\n", ret); | 675 | pci_warn(pdev, "Error %d enabling MSIx\n", ret); |
687 | return ret; | 676 | return ret; |
688 | } | 677 | } |
689 | 678 | ||
@@ -727,7 +716,7 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data) | |||
727 | (sts & PCI_EXP_SLTSTA_PDC)) { | 716 | (sts & PCI_EXP_SLTSTA_PDC)) { |
728 | ret = pnv_pci_get_presence_state(php_slot->id, &presence); | 717 | ret = pnv_pci_get_presence_state(php_slot->id, &presence); |
729 | if (ret) { | 718 | if (ret) { |
730 | dev_warn(&pdev->dev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n", | 719 | pci_warn(pdev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n", |
731 | php_slot->name, ret, sts); | 720 | php_slot->name, ret, sts); |
732 | return IRQ_HANDLED; | 721 | return IRQ_HANDLED; |
733 | } | 722 | } |
@@ -757,12 +746,12 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data) | |||
757 | */ | 746 | */ |
758 | event = kzalloc(sizeof(*event), GFP_ATOMIC); | 747 | event = kzalloc(sizeof(*event), GFP_ATOMIC); |
759 | if (!event) { | 748 | if (!event) { |
760 | dev_warn(&pdev->dev, "PCI slot [%s] missed hotplug event 0x%04x\n", | 749 | pci_warn(pdev, "PCI slot [%s] missed hotplug event 0x%04x\n", |
761 | php_slot->name, sts); | 750 | php_slot->name, sts); |
762 | return IRQ_HANDLED; | 751 | return IRQ_HANDLED; |
763 | } | 752 | } |
764 | 753 | ||
765 | dev_info(&pdev->dev, "PCI slot [%s] %s (IRQ: %d)\n", | 754 | pci_info(pdev, "PCI slot [%s] %s (IRQ: %d)\n", |
766 | php_slot->name, added ? "added" : "removed", irq); | 755 | php_slot->name, added ? "added" : "removed", irq); |
767 | INIT_WORK(&event->work, pnv_php_event_handler); | 756 | INIT_WORK(&event->work, pnv_php_event_handler); |
768 | event->added = added; | 757 | event->added = added; |
@@ -782,7 +771,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq) | |||
782 | /* Allocate workqueue */ | 771 | /* Allocate workqueue */ |
783 | php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name); | 772 | php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name); |
784 | if (!php_slot->wq) { | 773 | if (!php_slot->wq) { |
785 | dev_warn(&pdev->dev, "Cannot alloc workqueue\n"); | 774 | pci_warn(pdev, "Cannot alloc workqueue\n"); |
786 | pnv_php_disable_irq(php_slot, true); | 775 | pnv_php_disable_irq(php_slot, true); |
787 | return; | 776 | return; |
788 | } | 777 | } |
@@ -806,7 +795,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq) | |||
806 | php_slot->name, php_slot); | 795 | php_slot->name, php_slot); |
807 | if (ret) { | 796 | if (ret) { |
808 | pnv_php_disable_irq(php_slot, true); | 797 | pnv_php_disable_irq(php_slot, true); |
809 | dev_warn(&pdev->dev, "Error %d enabling IRQ %d\n", ret, irq); | 798 | pci_warn(pdev, "Error %d enabling IRQ %d\n", ret, irq); |
810 | return; | 799 | return; |
811 | } | 800 | } |
812 | 801 | ||
@@ -842,7 +831,7 @@ static void pnv_php_enable_irq(struct pnv_php_slot *php_slot) | |||
842 | 831 | ||
843 | ret = pci_enable_device(pdev); | 832 | ret = pci_enable_device(pdev); |
844 | if (ret) { | 833 | if (ret) { |
845 | dev_warn(&pdev->dev, "Error %d enabling device\n", ret); | 834 | pci_warn(pdev, "Error %d enabling device\n", ret); |
846 | return; | 835 | return; |
847 | } | 836 | } |
848 | 837 | ||
diff --git a/drivers/pci/hotplug/rpadlpar.h b/drivers/pci/hotplug/rpadlpar.h index 81df93931ad0..1eeb55d33171 100644 --- a/drivers/pci/hotplug/rpadlpar.h +++ b/drivers/pci/hotplug/rpadlpar.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * Interface for Dynamic Logical Partitioning of I/O Slots on | 3 | * Interface for Dynamic Logical Partitioning of I/O Slots on |
3 | * RPA-compliant PPC64 platform. | 4 | * RPA-compliant PPC64 platform. |
@@ -6,11 +7,6 @@ | |||
6 | * October 2003 | 7 | * October 2003 |
7 | * | 8 | * |
8 | * Copyright (C) 2003 IBM. | 9 | * Copyright (C) 2003 IBM. |
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | 10 | */ |
15 | #ifndef _RPADLPAR_IO_H_ | 11 | #ifndef _RPADLPAR_IO_H_ |
16 | #define _RPADLPAR_IO_H_ | 12 | #define _RPADLPAR_IO_H_ |
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index a3449d717a99..e2356a9c7088 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Interface for Dynamic Logical Partitioning of I/O Slots on | 3 | * Interface for Dynamic Logical Partitioning of I/O Slots on |
3 | * RPA-compliant PPC64 platform. | 4 | * RPA-compliant PPC64 platform. |
@@ -8,11 +9,6 @@ | |||
8 | * October 2003 | 9 | * October 2003 |
9 | * | 10 | * |
10 | * Copyright (C) 2003 IBM. | 11 | * Copyright (C) 2003 IBM. |
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | */ | 12 | */ |
17 | 13 | ||
18 | #undef DEBUG | 14 | #undef DEBUG |
@@ -27,6 +23,7 @@ | |||
27 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
28 | #include <asm/rtas.h> | 24 | #include <asm/rtas.h> |
29 | #include <asm/vio.h> | 25 | #include <asm/vio.h> |
26 | #include <linux/firmware.h> | ||
30 | 27 | ||
31 | #include "../pci.h" | 28 | #include "../pci.h" |
32 | #include "rpaphp.h" | 29 | #include "rpaphp.h" |
@@ -44,15 +41,14 @@ static struct device_node *find_vio_slot_node(char *drc_name) | |||
44 | { | 41 | { |
45 | struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); | 42 | struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); |
46 | struct device_node *dn = NULL; | 43 | struct device_node *dn = NULL; |
47 | char *name; | ||
48 | int rc; | 44 | int rc; |
49 | 45 | ||
50 | if (!parent) | 46 | if (!parent) |
51 | return NULL; | 47 | return NULL; |
52 | 48 | ||
53 | while ((dn = of_get_next_child(parent, dn))) { | 49 | while ((dn = of_get_next_child(parent, dn))) { |
54 | rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); | 50 | rc = rpaphp_check_drc_props(dn, drc_name, NULL); |
55 | if ((rc == 0) && (!strcmp(drc_name, name))) | 51 | if (rc == 0) |
56 | break; | 52 | break; |
57 | } | 53 | } |
58 | 54 | ||
@@ -64,15 +60,12 @@ static struct device_node *find_php_slot_pci_node(char *drc_name, | |||
64 | char *drc_type) | 60 | char *drc_type) |
65 | { | 61 | { |
66 | struct device_node *np = NULL; | 62 | struct device_node *np = NULL; |
67 | char *name; | ||
68 | char *type; | ||
69 | int rc; | 63 | int rc; |
70 | 64 | ||
71 | while ((np = of_find_node_by_name(np, "pci"))) { | 65 | while ((np = of_find_node_by_name(np, "pci"))) { |
72 | rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); | 66 | rc = rpaphp_check_drc_props(np, drc_name, drc_type); |
73 | if (rc == 0) | 67 | if (rc == 0) |
74 | if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) | 68 | break; |
75 | break; | ||
76 | } | 69 | } |
77 | 70 | ||
78 | return np; | 71 | return np; |
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c index edb5d8a53020..cdbfa5df3a51 100644 --- a/drivers/pci/hotplug/rpadlpar_sysfs.c +++ b/drivers/pci/hotplug/rpadlpar_sysfs.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Interface for Dynamic Logical Partitioning of I/O Slots on | 3 | * Interface for Dynamic Logical Partitioning of I/O Slots on |
3 | * RPA-compliant PPC64 platform. | 4 | * RPA-compliant PPC64 platform. |
@@ -6,16 +7,12 @@ | |||
6 | * October 2003 | 7 | * October 2003 |
7 | * | 8 | * |
8 | * Copyright (C) 2003 IBM. | 9 | * Copyright (C) 2003 IBM. |
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | 10 | */ |
15 | #include <linux/kobject.h> | 11 | #include <linux/kobject.h> |
16 | #include <linux/string.h> | 12 | #include <linux/string.h> |
17 | #include <linux/pci.h> | 13 | #include <linux/pci.h> |
18 | #include <linux/pci_hotplug.h> | 14 | #include <linux/pci_hotplug.h> |
15 | #include "rpaphp.h" | ||
19 | #include "rpadlpar.h" | 16 | #include "rpadlpar.h" |
20 | #include "../pci.h" | 17 | #include "../pci.h" |
21 | 18 | ||
@@ -27,8 +24,6 @@ | |||
27 | #define ADD_SLOT_ATTR_NAME add_slot | 24 | #define ADD_SLOT_ATTR_NAME add_slot |
28 | #define REMOVE_SLOT_ATTR_NAME remove_slot | 25 | #define REMOVE_SLOT_ATTR_NAME remove_slot |
29 | 26 | ||
30 | #define MAX_DRC_NAME_LEN 64 | ||
31 | |||
32 | static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, | 27 | static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, |
33 | const char *buf, size_t nbytes) | 28 | const char *buf, size_t nbytes) |
34 | { | 29 | { |
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 7db024e68fe6..c8311724bd76 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. | 3 | * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. |
3 | * | 4 | * |
@@ -5,21 +6,6 @@ | |||
5 | * | 6 | * |
6 | * All rights reserved. | 7 | * All rights reserved. |
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or (at | ||
11 | * your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
16 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
17 | * details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | * | ||
23 | * Send feedback to <lxie@us.ibm.com>, | 9 | * Send feedback to <lxie@us.ibm.com>, |
24 | * | 10 | * |
25 | */ | 11 | */ |
@@ -64,6 +50,10 @@ extern bool rpaphp_debug; | |||
64 | #define CONFIGURED 1 | 50 | #define CONFIGURED 1 |
65 | #define EMPTY 0 | 51 | #define EMPTY 0 |
66 | 52 | ||
53 | /* DRC constants */ | ||
54 | |||
55 | #define MAX_DRC_NAME_LEN 64 | ||
56 | |||
67 | /* | 57 | /* |
68 | * struct slot - slot information for each *physical* slot | 58 | * struct slot - slot information for each *physical* slot |
69 | */ | 59 | */ |
@@ -91,8 +81,8 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state); | |||
91 | 81 | ||
92 | /* rpaphp_core.c */ | 82 | /* rpaphp_core.c */ |
93 | int rpaphp_add_slot(struct device_node *dn); | 83 | int rpaphp_add_slot(struct device_node *dn); |
94 | int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, | 84 | int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, |
95 | char **drc_name, char **drc_type, int *drc_power_domain); | 85 | char *drc_type); |
96 | 86 | ||
97 | /* rpaphp_slot.c */ | 87 | /* rpaphp_slot.c */ |
98 | void dealloc_slot_struct(struct slot *slot); | 88 | void dealloc_slot_struct(struct slot *slot); |
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 1e29abaaea08..fb5e0845429d 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c | |||
@@ -1,24 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. | 3 | * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. |
3 | * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> | 4 | * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> |
4 | * | 5 | * |
5 | * All rights reserved. | 6 | * All rights reserved. |
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or (at | ||
10 | * your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
15 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
16 | * details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | * | ||
22 | * Send feedback to <lxie@us.ibm.com> | 8 | * Send feedback to <lxie@us.ibm.com> |
23 | * | 9 | * |
24 | */ | 10 | */ |
@@ -30,6 +16,7 @@ | |||
30 | #include <linux/smp.h> | 16 | #include <linux/smp.h> |
31 | #include <linux/init.h> | 17 | #include <linux/init.h> |
32 | #include <linux/vmalloc.h> | 18 | #include <linux/vmalloc.h> |
19 | #include <asm/firmware.h> | ||
33 | #include <asm/eeh.h> /* for eeh_add_device() */ | 20 | #include <asm/eeh.h> /* for eeh_add_device() */ |
34 | #include <asm/rtas.h> /* rtas_call */ | 21 | #include <asm/rtas.h> /* rtas_call */ |
35 | #include <asm/pci-bridge.h> /* for pci_controller */ | 22 | #include <asm/pci-bridge.h> /* for pci_controller */ |
@@ -196,25 +183,21 @@ static int get_children_props(struct device_node *dn, const int **drc_indexes, | |||
196 | return 0; | 183 | return 0; |
197 | } | 184 | } |
198 | 185 | ||
199 | /* To get the DRC props describing the current node, first obtain it's | 186 | |
200 | * my-drc-index property. Next obtain the DRC list from it's parent. Use | 187 | /* Verify the existence of 'drc_name' and/or 'drc_type' within the |
201 | * the my-drc-index for correlation, and obtain the requested properties. | 188 | * current node. First obtain it's my-drc-index property. Next, |
189 | * obtain the DRC info from it's parent. Use the my-drc-index for | ||
190 | * correlation, and obtain/validate the requested properties. | ||
202 | */ | 191 | */ |
203 | int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, | 192 | |
204 | char **drc_name, char **drc_type, int *drc_power_domain) | 193 | static int rpaphp_check_drc_props_v1(struct device_node *dn, char *drc_name, |
194 | char *drc_type, unsigned int my_index) | ||
205 | { | 195 | { |
196 | char *name_tmp, *type_tmp; | ||
206 | const int *indexes, *names; | 197 | const int *indexes, *names; |
207 | const int *types, *domains; | 198 | const int *types, *domains; |
208 | const unsigned int *my_index; | ||
209 | char *name_tmp, *type_tmp; | ||
210 | int i, rc; | 199 | int i, rc; |
211 | 200 | ||
212 | my_index = of_get_property(dn, "ibm,my-drc-index", NULL); | ||
213 | if (!my_index) { | ||
214 | /* Node isn't DLPAR/hotplug capable */ | ||
215 | return -EINVAL; | ||
216 | } | ||
217 | |||
218 | rc = get_children_props(dn->parent, &indexes, &names, &types, &domains); | 201 | rc = get_children_props(dn->parent, &indexes, &names, &types, &domains); |
219 | if (rc < 0) { | 202 | if (rc < 0) { |
220 | return -EINVAL; | 203 | return -EINVAL; |
@@ -225,24 +208,84 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, | |||
225 | 208 | ||
226 | /* Iterate through parent properties, looking for my-drc-index */ | 209 | /* Iterate through parent properties, looking for my-drc-index */ |
227 | for (i = 0; i < be32_to_cpu(indexes[0]); i++) { | 210 | for (i = 0; i < be32_to_cpu(indexes[0]); i++) { |
228 | if ((unsigned int) indexes[i + 1] == *my_index) { | 211 | if ((unsigned int) indexes[i + 1] == my_index) |
229 | if (drc_name) | 212 | break; |
230 | *drc_name = name_tmp; | 213 | |
231 | if (drc_type) | ||
232 | *drc_type = type_tmp; | ||
233 | if (drc_index) | ||
234 | *drc_index = be32_to_cpu(*my_index); | ||
235 | if (drc_power_domain) | ||
236 | *drc_power_domain = be32_to_cpu(domains[i+1]); | ||
237 | return 0; | ||
238 | } | ||
239 | name_tmp += (strlen(name_tmp) + 1); | 214 | name_tmp += (strlen(name_tmp) + 1); |
240 | type_tmp += (strlen(type_tmp) + 1); | 215 | type_tmp += (strlen(type_tmp) + 1); |
241 | } | 216 | } |
242 | 217 | ||
218 | if (((drc_name == NULL) || (drc_name && !strcmp(drc_name, name_tmp))) && | ||
219 | ((drc_type == NULL) || (drc_type && !strcmp(drc_type, type_tmp)))) | ||
220 | return 0; | ||
221 | |||
222 | return -EINVAL; | ||
223 | } | ||
224 | |||
225 | static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, | ||
226 | char *drc_type, unsigned int my_index) | ||
227 | { | ||
228 | struct property *info; | ||
229 | unsigned int entries; | ||
230 | struct of_drc_info drc; | ||
231 | const __be32 *value; | ||
232 | char cell_drc_name[MAX_DRC_NAME_LEN]; | ||
233 | int j, fndit; | ||
234 | |||
235 | info = of_find_property(dn->parent, "ibm,drc-info", NULL); | ||
236 | if (info == NULL) | ||
237 | return -EINVAL; | ||
238 | |||
239 | value = of_prop_next_u32(info, NULL, &entries); | ||
240 | if (!value) | ||
241 | return -EINVAL; | ||
242 | |||
243 | for (j = 0; j < entries; j++) { | ||
244 | of_read_drc_info_cell(&info, &value, &drc); | ||
245 | |||
246 | /* Should now know end of current entry */ | ||
247 | |||
248 | if (my_index > drc.last_drc_index) | ||
249 | continue; | ||
250 | |||
251 | fndit = 1; | ||
252 | break; | ||
253 | } | ||
254 | /* Found it */ | ||
255 | |||
256 | if (fndit) | ||
257 | sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, | ||
258 | my_index); | ||
259 | |||
260 | if (((drc_name == NULL) || | ||
261 | (drc_name && !strcmp(drc_name, cell_drc_name))) && | ||
262 | ((drc_type == NULL) || | ||
263 | (drc_type && !strcmp(drc_type, drc.drc_type)))) | ||
264 | return 0; | ||
265 | |||
243 | return -EINVAL; | 266 | return -EINVAL; |
244 | } | 267 | } |
245 | EXPORT_SYMBOL_GPL(rpaphp_get_drc_props); | 268 | |
269 | int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, | ||
270 | char *drc_type) | ||
271 | { | ||
272 | const unsigned int *my_index; | ||
273 | |||
274 | my_index = of_get_property(dn, "ibm,my-drc-index", NULL); | ||
275 | if (!my_index) { | ||
276 | /* Node isn't DLPAR/hotplug capable */ | ||
277 | return -EINVAL; | ||
278 | } | ||
279 | |||
280 | if (firmware_has_feature(FW_FEATURE_DRC_INFO)) | ||
281 | return rpaphp_check_drc_props_v2(dn, drc_name, drc_type, | ||
282 | *my_index); | ||
283 | else | ||
284 | return rpaphp_check_drc_props_v1(dn, drc_name, drc_type, | ||
285 | *my_index); | ||
286 | } | ||
287 | EXPORT_SYMBOL_GPL(rpaphp_check_drc_props); | ||
288 | |||
246 | 289 | ||
247 | static int is_php_type(char *drc_type) | 290 | static int is_php_type(char *drc_type) |
248 | { | 291 | { |
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 32aabc533be8..0aac33e15dab 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c | |||
@@ -1,24 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. | 3 | * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. |
3 | * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> | 4 | * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> |
4 | * | 5 | * |
5 | * All rights reserved. | 6 | * All rights reserved. |
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or (at | ||
10 | * your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
15 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
16 | * details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | * | ||
22 | * Send feedback to <lxie@us.ibm.com> | 8 | * Send feedback to <lxie@us.ibm.com> |
23 | * | 9 | * |
24 | */ | 10 | */ |
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 489862360f2c..3840a2075e6a 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -1,24 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * RPA Virtual I/O device functions | 3 | * RPA Virtual I/O device functions |
3 | * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com> | 4 | * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com> |
4 | * | 5 | * |
5 | * All rights reserved. | 6 | * All rights reserved. |
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or (at | ||
10 | * your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
15 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
16 | * details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | * | ||
22 | * Send feedback to <lxie@us.ibm.com> | 8 | * Send feedback to <lxie@us.ibm.com> |
23 | * | 9 | * |
24 | */ | 10 | */ |
diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c index 530d0e49f2ed..ffdc2977395d 100644 --- a/drivers/pci/hotplug/s390_pci_hpc.c +++ b/drivers/pci/hotplug/s390_pci_hpc.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI Hot Plug Controller Driver for System z | 3 | * PCI Hot Plug Controller Driver for System z |
3 | * | 4 | * |
@@ -5,8 +6,6 @@ | |||
5 | * | 6 | * |
6 | * Author(s): | 7 | * Author(s): |
7 | * Jan Glauber <jang@linux.vnet.ibm.com> | 8 | * Jan Glauber <jang@linux.vnet.ibm.com> |
8 | * | ||
9 | * License: GPL | ||
10 | */ | 9 | */ |
11 | 10 | ||
12 | #define KMSG_COMPONENT "zpci" | 11 | #define KMSG_COMPONENT "zpci" |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 339bce0403dd..78b6bdbb3a39 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -1,8 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2005-2006 Silicon Graphics, Inc. All rights reserved. | 3 | * Copyright (C) 2005-2006 Silicon Graphics, Inc. All rights reserved. |
7 | * | 4 | * |
8 | * This work was based on the 2.4/2.6 kernel development by Dick Reigner. | 5 | * This work was based on the 2.4/2.6 kernel development by Dick Reigner. |
@@ -245,18 +242,18 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot, | |||
245 | 242 | ||
246 | 243 | ||
247 | if (rc == PCI_SLOT_ALREADY_UP) { | 244 | if (rc == PCI_SLOT_ALREADY_UP) { |
248 | dev_dbg(&slot->pci_bus->self->dev, "is already active\n"); | 245 | pci_dbg(slot->pci_bus->self, "is already active\n"); |
249 | return 1; /* return 1 to user */ | 246 | return 1; /* return 1 to user */ |
250 | } | 247 | } |
251 | 248 | ||
252 | if (rc == PCI_L1_ERR) { | 249 | if (rc == PCI_L1_ERR) { |
253 | dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message: %s", | 250 | pci_dbg(slot->pci_bus->self, "L1 failure %d with message: %s", |
254 | resp.resp_sub_errno, resp.resp_l1_msg); | 251 | resp.resp_sub_errno, resp.resp_l1_msg); |
255 | return -EPERM; | 252 | return -EPERM; |
256 | } | 253 | } |
257 | 254 | ||
258 | if (rc) { | 255 | if (rc) { |
259 | dev_dbg(&slot->pci_bus->self->dev, "insert failed with error %d sub-error %d\n", | 256 | pci_dbg(slot->pci_bus->self, "insert failed with error %d sub-error %d\n", |
260 | rc, resp.resp_sub_errno); | 257 | rc, resp.resp_sub_errno); |
261 | return -EIO; | 258 | return -EIO; |
262 | } | 259 | } |
@@ -281,23 +278,23 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
281 | 278 | ||
282 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && | 279 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && |
283 | (rc == PCI_SLOT_ALREADY_DOWN)) { | 280 | (rc == PCI_SLOT_ALREADY_DOWN)) { |
284 | dev_dbg(&slot->pci_bus->self->dev, "Slot %s already inactive\n", slot->physical_path); | 281 | pci_dbg(slot->pci_bus->self, "Slot %s already inactive\n", slot->physical_path); |
285 | return 1; /* return 1 to user */ | 282 | return 1; /* return 1 to user */ |
286 | } | 283 | } |
287 | 284 | ||
288 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { | 285 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { |
289 | dev_dbg(&slot->pci_bus->self->dev, "Cannot remove last 33MHz card\n"); | 286 | pci_dbg(slot->pci_bus->self, "Cannot remove last 33MHz card\n"); |
290 | return -EPERM; | 287 | return -EPERM; |
291 | } | 288 | } |
292 | 289 | ||
293 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { | 290 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { |
294 | dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message \n%s\n", | 291 | pci_dbg(slot->pci_bus->self, "L1 failure %d with message \n%s\n", |
295 | resp.resp_sub_errno, resp.resp_l1_msg); | 292 | resp.resp_sub_errno, resp.resp_l1_msg); |
296 | return -EPERM; | 293 | return -EPERM; |
297 | } | 294 | } |
298 | 295 | ||
299 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { | 296 | if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { |
300 | dev_dbg(&slot->pci_bus->self->dev, "remove failed with error %d sub-error %d\n", | 297 | pci_dbg(slot->pci_bus->self, "remove failed with error %d sub-error %d\n", |
301 | rc, resp.resp_sub_errno); | 298 | rc, resp.resp_sub_errno); |
302 | return -EIO; | 299 | return -EIO; |
303 | } | 300 | } |
@@ -308,12 +305,12 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot, | |||
308 | if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { | 305 | if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { |
309 | pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); | 306 | pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); |
310 | pcibus_info->pbi_enabled_devices &= ~(1 << device_num); | 307 | pcibus_info->pbi_enabled_devices &= ~(1 << device_num); |
311 | dev_dbg(&slot->pci_bus->self->dev, "remove successful\n"); | 308 | pci_dbg(slot->pci_bus->self, "remove successful\n"); |
312 | return 0; | 309 | return 0; |
313 | } | 310 | } |
314 | 311 | ||
315 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { | 312 | if ((action == PCI_REQ_SLOT_DISABLE) && rc) { |
316 | dev_dbg(&slot->pci_bus->self->dev, "remove failed rc = %d\n", rc); | 313 | pci_dbg(slot->pci_bus->self, "remove failed rc = %d\n", rc); |
317 | } | 314 | } |
318 | 315 | ||
319 | return rc; | 316 | return rc; |
@@ -366,7 +363,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
366 | num_funcs = pci_scan_slot(slot->pci_bus, | 363 | num_funcs = pci_scan_slot(slot->pci_bus, |
367 | PCI_DEVFN(slot->device_num + 1, 0)); | 364 | PCI_DEVFN(slot->device_num + 1, 0)); |
368 | if (!num_funcs) { | 365 | if (!num_funcs) { |
369 | dev_dbg(&slot->pci_bus->self->dev, "no device in slot\n"); | 366 | pci_dbg(slot->pci_bus->self, "no device in slot\n"); |
370 | mutex_unlock(&sn_hotplug_mutex); | 367 | mutex_unlock(&sn_hotplug_mutex); |
371 | return -ENODEV; | 368 | return -ENODEV; |
372 | } | 369 | } |
@@ -412,7 +409,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
412 | phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion); | 409 | phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion); |
413 | 410 | ||
414 | if (acpi_bus_get_device(phandle, &pdevice)) { | 411 | if (acpi_bus_get_device(phandle, &pdevice)) { |
415 | dev_dbg(&slot->pci_bus->self->dev, "no parent device, assuming NULL\n"); | 412 | pci_dbg(slot->pci_bus->self, "no parent device, assuming NULL\n"); |
416 | pdevice = NULL; | 413 | pdevice = NULL; |
417 | } | 414 | } |
418 | 415 | ||
@@ -463,9 +460,9 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
463 | mutex_unlock(&sn_hotplug_mutex); | 460 | mutex_unlock(&sn_hotplug_mutex); |
464 | 461 | ||
465 | if (rc == 0) | 462 | if (rc == 0) |
466 | dev_dbg(&slot->pci_bus->self->dev, "insert operation successful\n"); | 463 | pci_dbg(slot->pci_bus->self, "insert operation successful\n"); |
467 | else | 464 | else |
468 | dev_dbg(&slot->pci_bus->self->dev, "insert operation failed rc = %d\n", rc); | 465 | pci_dbg(slot->pci_bus->self, "insert operation failed rc = %d\n", rc); |
469 | 466 | ||
470 | return rc; | 467 | return rc; |
471 | } | 468 | } |
@@ -643,16 +640,16 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
643 | if (rc) | 640 | if (rc) |
644 | goto register_err; | 641 | goto register_err; |
645 | } | 642 | } |
646 | dev_dbg(&pci_bus->self->dev, "Registered bus with hotplug\n"); | 643 | pci_dbg(pci_bus->self, "Registered bus with hotplug\n"); |
647 | return rc; | 644 | return rc; |
648 | 645 | ||
649 | register_err: | 646 | register_err: |
650 | dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n", | 647 | pci_dbg(pci_bus->self, "bus failed to register with err = %d\n", |
651 | rc); | 648 | rc); |
652 | 649 | ||
653 | alloc_err: | 650 | alloc_err: |
654 | if (rc == -ENOMEM) | 651 | if (rc == -ENOMEM) |
655 | dev_dbg(&pci_bus->self->dev, "Memory allocation error\n"); | 652 | pci_dbg(pci_bus->self, "Memory allocation error\n"); |
656 | 653 | ||
657 | /* destroy THIS element */ | 654 | /* destroy THIS element */ |
658 | if (bss_hotplug_slot) | 655 | if (bss_hotplug_slot) |
@@ -685,10 +682,10 @@ static int __init sn_pci_hotplug_init(void) | |||
685 | 682 | ||
686 | rc = sn_pci_bus_valid(pci_bus); | 683 | rc = sn_pci_bus_valid(pci_bus); |
687 | if (rc != 1) { | 684 | if (rc != 1) { |
688 | dev_dbg(&pci_bus->self->dev, "not a valid hotplug bus\n"); | 685 | pci_dbg(pci_bus->self, "not a valid hotplug bus\n"); |
689 | continue; | 686 | continue; |
690 | } | 687 | } |
691 | dev_dbg(&pci_bus->self->dev, "valid hotplug bus\n"); | 688 | pci_dbg(pci_bus->self, "valid hotplug bus\n"); |
692 | 689 | ||
693 | rc = sn_hotplug_slot_register(pci_bus); | 690 | rc = sn_hotplug_slot_register(pci_bus); |
694 | if (!rc) { | 691 | if (!rc) { |
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 70c7ea6af034..c55730b61c9a 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -1,3 +1,4 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
1 | /* | 2 | /* |
2 | * Standard Hot Plug Controller Driver | 3 | * Standard Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -62,15 +48,15 @@ do { \ | |||
62 | #define ctrl_dbg(ctrl, format, arg...) \ | 48 | #define ctrl_dbg(ctrl, format, arg...) \ |
63 | do { \ | 49 | do { \ |
64 | if (shpchp_debug) \ | 50 | if (shpchp_debug) \ |
65 | dev_printk(KERN_DEBUG, &ctrl->pci_dev->dev, \ | 51 | pci_printk(KERN_DEBUG, ctrl->pci_dev, \ |
66 | format, ## arg); \ | 52 | format, ## arg); \ |
67 | } while (0) | 53 | } while (0) |
68 | #define ctrl_err(ctrl, format, arg...) \ | 54 | #define ctrl_err(ctrl, format, arg...) \ |
69 | dev_err(&ctrl->pci_dev->dev, format, ## arg) | 55 | pci_err(ctrl->pci_dev, format, ## arg) |
70 | #define ctrl_info(ctrl, format, arg...) \ | 56 | #define ctrl_info(ctrl, format, arg...) \ |
71 | dev_info(&ctrl->pci_dev->dev, format, ## arg) | 57 | pci_info(ctrl->pci_dev, format, ## arg) |
72 | #define ctrl_warn(ctrl, format, arg...) \ | 58 | #define ctrl_warn(ctrl, format, arg...) \ |
73 | dev_warn(&ctrl->pci_dev->dev, format, ## arg) | 59 | pci_warn(ctrl->pci_dev, format, ## arg) |
74 | 60 | ||
75 | 61 | ||
76 | #define SLOT_NAME_SIZE 10 | 62 | #define SLOT_NAME_SIZE 10 |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 7bfb87bd2b7e..1f0f96908b5a 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Standard Hot Plug Controller Driver | 3 | * Standard Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -305,10 +291,9 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
305 | return -ENODEV; | 291 | return -ENODEV; |
306 | 292 | ||
307 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); | 293 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
308 | if (!ctrl) { | 294 | if (!ctrl) |
309 | dev_err(&pdev->dev, "%s: Out of memory\n", __func__); | ||
310 | goto err_out_none; | 295 | goto err_out_none; |
311 | } | 296 | |
312 | INIT_LIST_HEAD(&ctrl->slot_list); | 297 | INIT_LIST_HEAD(&ctrl->slot_list); |
313 | 298 | ||
314 | rc = shpc_init(ctrl, pdev); | 299 | rc = shpc_init(ctrl, pdev); |
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index 10c7927599b3..bedda5bda910 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Standard Hot Plug Controller Driver | 3 | * Standard Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 4810e9626d9f..db047284c291 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Standard PCI Hot Plug Driver | 3 | * Standard PCI Hot Plug Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index ea63db58b4b1..115701301487 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Standard Hot Plug Controller Driver | 3 | * Standard Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -8,21 +9,6 @@ | |||
8 | * | 9 | * |
9 | * All rights reserved. | 10 | * All rights reserved. |
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> | 12 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
27 | * | 13 | * |
28 | */ | 14 | */ |
@@ -78,7 +64,6 @@ int shpchp_configure_device(struct slot *p_slot) | |||
78 | int shpchp_unconfigure_device(struct slot *p_slot) | 64 | int shpchp_unconfigure_device(struct slot *p_slot) |
79 | { | 65 | { |
80 | int rc = 0; | 66 | int rc = 0; |
81 | u8 bctl = 0; | ||
82 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | 67 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; |
83 | struct pci_dev *dev, *temp; | 68 | struct pci_dev *dev, *temp; |
84 | struct controller *ctrl = p_slot->ctrl; | 69 | struct controller *ctrl = p_slot->ctrl; |
@@ -93,17 +78,6 @@ int shpchp_unconfigure_device(struct slot *p_slot) | |||
93 | continue; | 78 | continue; |
94 | 79 | ||
95 | pci_dev_get(dev); | 80 | pci_dev_get(dev); |
96 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | ||
97 | pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl); | ||
98 | if (bctl & PCI_BRIDGE_CTL_VGA) { | ||
99 | ctrl_err(ctrl, | ||
100 | "Cannot remove display device %s\n", | ||
101 | pci_name(dev)); | ||
102 | pci_dev_put(dev); | ||
103 | rc = -EINVAL; | ||
104 | break; | ||
105 | } | ||
106 | } | ||
107 | pci_stop_and_remove_bus_device(dev); | 81 | pci_stop_and_remove_bus_device(dev); |
108 | pci_dev_put(dev); | 82 | pci_dev_put(dev); |
109 | } | 83 | } |
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c index 7efb56a28c9f..45658bb5c554 100644 --- a/drivers/pci/hotplug/shpchp_sysfs.c +++ b/drivers/pci/hotplug/shpchp_sysfs.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * Compaq Hot Plug Controller Driver | 3 | * Compaq Hot Plug Controller Driver |
3 | * | 4 | * |
@@ -7,21 +8,6 @@ | |||
7 | * | 8 | * |
8 | * All rights reserved. | 9 | * All rights reserved. |
9 | * | 10 | * |
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, but | ||
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
18 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
19 | * details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | * Send feedback to <greg@kroah.com> | 11 | * Send feedback to <greg@kroah.com> |
26 | * | 12 | * |
27 | */ | 13 | */ |
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 6bacb8995e96..677924ae0350 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/iov.c | 3 | * drivers/pci/iov.c |
3 | * | 4 | * |
@@ -259,19 +260,19 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
259 | nres++; | 260 | nres++; |
260 | } | 261 | } |
261 | if (nres != iov->nres) { | 262 | if (nres != iov->nres) { |
262 | dev_err(&dev->dev, "not enough MMIO resources for SR-IOV\n"); | 263 | pci_err(dev, "not enough MMIO resources for SR-IOV\n"); |
263 | return -ENOMEM; | 264 | return -ENOMEM; |
264 | } | 265 | } |
265 | 266 | ||
266 | bus = pci_iov_virtfn_bus(dev, nr_virtfn - 1); | 267 | bus = pci_iov_virtfn_bus(dev, nr_virtfn - 1); |
267 | if (bus > dev->bus->busn_res.end) { | 268 | if (bus > dev->bus->busn_res.end) { |
268 | dev_err(&dev->dev, "can't enable %d VFs (bus %02x out of range of %pR)\n", | 269 | pci_err(dev, "can't enable %d VFs (bus %02x out of range of %pR)\n", |
269 | nr_virtfn, bus, &dev->bus->busn_res); | 270 | nr_virtfn, bus, &dev->bus->busn_res); |
270 | return -ENOMEM; | 271 | return -ENOMEM; |
271 | } | 272 | } |
272 | 273 | ||
273 | if (pci_enable_resources(dev, bars)) { | 274 | if (pci_enable_resources(dev, bars)) { |
274 | dev_err(&dev->dev, "SR-IOV: IOV BARS not allocated\n"); | 275 | pci_err(dev, "SR-IOV: IOV BARS not allocated\n"); |
275 | return -ENOMEM; | 276 | return -ENOMEM; |
276 | } | 277 | } |
277 | 278 | ||
@@ -298,7 +299,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
298 | 299 | ||
299 | rc = pcibios_sriov_enable(dev, initial); | 300 | rc = pcibios_sriov_enable(dev, initial); |
300 | if (rc) { | 301 | if (rc) { |
301 | dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", rc); | 302 | pci_err(dev, "failure %d from pcibios_sriov_enable()\n", rc); |
302 | goto err_pcibios; | 303 | goto err_pcibios; |
303 | } | 304 | } |
304 | 305 | ||
@@ -432,7 +433,7 @@ found: | |||
432 | } | 433 | } |
433 | iov->barsz[i] = resource_size(res); | 434 | iov->barsz[i] = resource_size(res); |
434 | res->end = res->start + resource_size(res) * total - 1; | 435 | res->end = res->start + resource_size(res) * total - 1; |
435 | dev_info(&dev->dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n", | 436 | pci_info(dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n", |
436 | i, res, i, total); | 437 | i, res, i, total); |
437 | i += bar64; | 438 | i += bar64; |
438 | nres++; | 439 | nres++; |
@@ -636,6 +637,17 @@ void pci_restore_iov_state(struct pci_dev *dev) | |||
636 | } | 637 | } |
637 | 638 | ||
638 | /** | 639 | /** |
640 | * pci_vf_drivers_autoprobe - set PF property drivers_autoprobe for VFs | ||
641 | * @dev: the PCI device | ||
642 | * @auto_probe: set VF drivers auto probe flag | ||
643 | */ | ||
644 | void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool auto_probe) | ||
645 | { | ||
646 | if (dev->is_physfn) | ||
647 | dev->sriov->drivers_autoprobe = auto_probe; | ||
648 | } | ||
649 | |||
650 | /** | ||
639 | * pci_iov_bus_range - find bus range used by Virtual Function | 651 | * pci_iov_bus_range - find bus range used by Virtual Function |
640 | * @bus: the PCI bus | 652 | * @bus: the PCI bus |
641 | * | 653 | * |
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c index 10929cd43d5d..2a808e10645f 100644 --- a/drivers/pci/irq.c +++ b/drivers/pci/irq.c | |||
@@ -16,11 +16,10 @@ static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason) | |||
16 | { | 16 | { |
17 | struct pci_dev *parent = to_pci_dev(pdev->dev.parent); | 17 | struct pci_dev *parent = to_pci_dev(pdev->dev.parent); |
18 | 18 | ||
19 | dev_err(&pdev->dev, | 19 | pci_err(pdev, "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", |
20 | "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", | ||
21 | dev_name(&parent->dev), parent->vendor, parent->device); | 20 | dev_name(&parent->dev), parent->vendor, parent->device); |
22 | dev_err(&pdev->dev, "%s\n", reason); | 21 | pci_err(pdev, "%s\n", reason); |
23 | dev_err(&pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); | 22 | pci_err(pdev, "Please report to linux-kernel@vger.kernel.org\n"); |
24 | WARN_ON(1); | 23 | WARN_ON(1); |
25 | } | 24 | } |
26 | 25 | ||
diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c index 9a5e5a9055eb..814a3ce341fc 100644 --- a/drivers/pci/mmap.c +++ b/drivers/pci/mmap.c | |||
@@ -1,13 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * mmap.c — generic PCI resource mmap helper | 3 | * mmap.c — generic PCI resource mmap helper |
3 | * | 4 | * |
4 | * Copyright © 2017 Amazon.com, Inc. or its affiliates. | 5 | * Copyright © 2017 Amazon.com, Inc. or its affiliates. |
5 | * | 6 | * |
6 | * Author: David Woodhouse <dwmw2@infradead.org> | 7 | * Author: David Woodhouse <dwmw2@infradead.org> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | 8 | */ |
12 | 9 | ||
13 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index e06607167858..8b0729c94bb7 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * File: msi.c | 3 | * File: msi.c |
3 | * Purpose: PCI Message Signaled Interrupt (MSI) | 4 | * Purpose: PCI Message Signaled Interrupt (MSI) |
@@ -578,7 +579,7 @@ static int msi_verify_entries(struct pci_dev *dev) | |||
578 | for_each_pci_msi_entry(entry, dev) { | 579 | for_each_pci_msi_entry(entry, dev) { |
579 | if (!dev->no_64bit_msi || !entry->msg.address_hi) | 580 | if (!dev->no_64bit_msi || !entry->msg.address_hi) |
580 | continue; | 581 | continue; |
581 | dev_err(&dev->dev, "Device has broken 64-bit MSI but arch" | 582 | pci_err(dev, "Device has broken 64-bit MSI but arch" |
582 | " tried to assign one above 4G\n"); | 583 | " tried to assign one above 4G\n"); |
583 | return -EIO; | 584 | return -EIO; |
584 | } | 585 | } |
@@ -962,7 +963,7 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, | |||
962 | 963 | ||
963 | /* Check whether driver already requested for MSI irq */ | 964 | /* Check whether driver already requested for MSI irq */ |
964 | if (dev->msi_enabled) { | 965 | if (dev->msi_enabled) { |
965 | dev_info(&dev->dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); | 966 | pci_info(dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); |
966 | return -EINVAL; | 967 | return -EINVAL; |
967 | } | 968 | } |
968 | return msix_capability_init(dev, entries, nvec, affd); | 969 | return msix_capability_init(dev, entries, nvec, affd); |
@@ -1032,8 +1033,7 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, | |||
1032 | 1033 | ||
1033 | /* Check whether driver already requested MSI-X irqs */ | 1034 | /* Check whether driver already requested MSI-X irqs */ |
1034 | if (dev->msix_enabled) { | 1035 | if (dev->msix_enabled) { |
1035 | dev_info(&dev->dev, | 1036 | pci_info(dev, "can't enable MSI (MSI-X already enabled)\n"); |
1036 | "can't enable MSI (MSI-X already enabled)\n"); | ||
1037 | return -EINVAL; | 1037 | return -EINVAL; |
1038 | } | 1038 | } |
1039 | 1039 | ||
diff --git a/drivers/pci/of.c b/drivers/pci/of.c index e112da11630e..a28355c273ae 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c | |||
@@ -1,19 +1,17 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * PCI <-> OF mapping helpers | 3 | * PCI <-> OF mapping helpers |
3 | * | 4 | * |
4 | * Copyright 2011 IBM Corp. | 5 | * Copyright 2011 IBM Corp. |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | 6 | */ |
7 | #define pr_fmt(fmt) "PCI: OF: " fmt | ||
11 | 8 | ||
12 | #include <linux/irqdomain.h> | 9 | #include <linux/irqdomain.h> |
13 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
14 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
15 | #include <linux/of.h> | 12 | #include <linux/of.h> |
16 | #include <linux/of_irq.h> | 13 | #include <linux/of_irq.h> |
14 | #include <linux/of_address.h> | ||
17 | #include <linux/of_pci.h> | 15 | #include <linux/of_pci.h> |
18 | #include "pci.h" | 16 | #include "pci.h" |
19 | 17 | ||
@@ -51,8 +49,9 @@ struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus) | |||
51 | if (WARN_ON(bus->self || bus->parent)) | 49 | if (WARN_ON(bus->self || bus->parent)) |
52 | return NULL; | 50 | return NULL; |
53 | 51 | ||
54 | /* Look for a node pointer in either the intermediary device we | 52 | /* |
55 | * create above the root bus or it's own parent. Normally only | 53 | * Look for a node pointer in either the intermediary device we |
54 | * create above the root bus or its own parent. Normally only | ||
56 | * the later is populated. | 55 | * the later is populated. |
57 | */ | 56 | */ |
58 | if (bus->bridge->of_node) | 57 | if (bus->bridge->of_node) |
@@ -88,3 +87,561 @@ struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus) | |||
88 | return NULL; | 87 | return NULL; |
89 | #endif | 88 | #endif |
90 | } | 89 | } |
90 | |||
91 | static inline int __of_pci_pci_compare(struct device_node *node, | ||
92 | unsigned int data) | ||
93 | { | ||
94 | int devfn; | ||
95 | |||
96 | devfn = of_pci_get_devfn(node); | ||
97 | if (devfn < 0) | ||
98 | return 0; | ||
99 | |||
100 | return devfn == data; | ||
101 | } | ||
102 | |||
103 | struct device_node *of_pci_find_child_device(struct device_node *parent, | ||
104 | unsigned int devfn) | ||
105 | { | ||
106 | struct device_node *node, *node2; | ||
107 | |||
108 | for_each_child_of_node(parent, node) { | ||
109 | if (__of_pci_pci_compare(node, devfn)) | ||
110 | return node; | ||
111 | /* | ||
112 | * Some OFs create a parent node "multifunc-device" as | ||
113 | * a fake root for all functions of a multi-function | ||
114 | * device we go down them as well. | ||
115 | */ | ||
116 | if (!strcmp(node->name, "multifunc-device")) { | ||
117 | for_each_child_of_node(node, node2) { | ||
118 | if (__of_pci_pci_compare(node2, devfn)) { | ||
119 | of_node_put(node); | ||
120 | return node2; | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | return NULL; | ||
126 | } | ||
127 | EXPORT_SYMBOL_GPL(of_pci_find_child_device); | ||
128 | |||
129 | /** | ||
130 | * of_pci_get_devfn() - Get device and function numbers for a device node | ||
131 | * @np: device node | ||
132 | * | ||
133 | * Parses a standard 5-cell PCI resource and returns an 8-bit value that can | ||
134 | * be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device | ||
135 | * and function numbers respectively. On error a negative error code is | ||
136 | * returned. | ||
137 | */ | ||
138 | int of_pci_get_devfn(struct device_node *np) | ||
139 | { | ||
140 | u32 reg[5]; | ||
141 | int error; | ||
142 | |||
143 | error = of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg)); | ||
144 | if (error) | ||
145 | return error; | ||
146 | |||
147 | return (reg[0] >> 8) & 0xff; | ||
148 | } | ||
149 | EXPORT_SYMBOL_GPL(of_pci_get_devfn); | ||
150 | |||
151 | /** | ||
152 | * of_pci_parse_bus_range() - parse the bus-range property of a PCI device | ||
153 | * @node: device node | ||
154 | * @res: address to a struct resource to return the bus-range | ||
155 | * | ||
156 | * Returns 0 on success or a negative error-code on failure. | ||
157 | */ | ||
158 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res) | ||
159 | { | ||
160 | u32 bus_range[2]; | ||
161 | int error; | ||
162 | |||
163 | error = of_property_read_u32_array(node, "bus-range", bus_range, | ||
164 | ARRAY_SIZE(bus_range)); | ||
165 | if (error) | ||
166 | return error; | ||
167 | |||
168 | res->name = node->name; | ||
169 | res->start = bus_range[0]; | ||
170 | res->end = bus_range[1]; | ||
171 | res->flags = IORESOURCE_BUS; | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); | ||
176 | |||
177 | /** | ||
178 | * This function will try to obtain the host bridge domain number by | ||
179 | * finding a property called "linux,pci-domain" of the given device node. | ||
180 | * | ||
181 | * @node: device tree node with the domain information | ||
182 | * | ||
183 | * Returns the associated domain number from DT in the range [0-0xffff], or | ||
184 | * a negative value if the required property is not found. | ||
185 | */ | ||
186 | int of_get_pci_domain_nr(struct device_node *node) | ||
187 | { | ||
188 | u32 domain; | ||
189 | int error; | ||
190 | |||
191 | error = of_property_read_u32(node, "linux,pci-domain", &domain); | ||
192 | if (error) | ||
193 | return error; | ||
194 | |||
195 | return (u16)domain; | ||
196 | } | ||
197 | EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); | ||
198 | |||
199 | /** | ||
200 | * This function will try to find the limitation of link speed by finding | ||
201 | * a property called "max-link-speed" of the given device node. | ||
202 | * | ||
203 | * @node: device tree node with the max link speed information | ||
204 | * | ||
205 | * Returns the associated max link speed from DT, or a negative value if the | ||
206 | * required property is not found or is invalid. | ||
207 | */ | ||
208 | int of_pci_get_max_link_speed(struct device_node *node) | ||
209 | { | ||
210 | u32 max_link_speed; | ||
211 | |||
212 | if (of_property_read_u32(node, "max-link-speed", &max_link_speed) || | ||
213 | max_link_speed > 4) | ||
214 | return -EINVAL; | ||
215 | |||
216 | return max_link_speed; | ||
217 | } | ||
218 | EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); | ||
219 | |||
220 | /** | ||
221 | * of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only | ||
222 | * is present and valid | ||
223 | */ | ||
224 | void of_pci_check_probe_only(void) | ||
225 | { | ||
226 | u32 val; | ||
227 | int ret; | ||
228 | |||
229 | ret = of_property_read_u32(of_chosen, "linux,pci-probe-only", &val); | ||
230 | if (ret) { | ||
231 | if (ret == -ENODATA || ret == -EOVERFLOW) | ||
232 | pr_warn("linux,pci-probe-only without valid value, ignoring\n"); | ||
233 | return; | ||
234 | } | ||
235 | |||
236 | if (val) | ||
237 | pci_add_flags(PCI_PROBE_ONLY); | ||
238 | else | ||
239 | pci_clear_flags(PCI_PROBE_ONLY); | ||
240 | |||
241 | pr_info("PROBE_ONLY %sabled\n", val ? "en" : "dis"); | ||
242 | } | ||
243 | EXPORT_SYMBOL_GPL(of_pci_check_probe_only); | ||
244 | |||
245 | #if defined(CONFIG_OF_ADDRESS) | ||
246 | /** | ||
247 | * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT | ||
248 | * @dev: device node of the host bridge having the range property | ||
249 | * @busno: bus number associated with the bridge root bus | ||
250 | * @bus_max: maximum number of buses for this bridge | ||
251 | * @resources: list where the range of resources will be added after DT parsing | ||
252 | * @io_base: pointer to a variable that will contain on return the physical | ||
253 | * address for the start of the I/O range. Can be NULL if the caller doesn't | ||
254 | * expect I/O ranges to be present in the device tree. | ||
255 | * | ||
256 | * It is the caller's job to free the @resources list. | ||
257 | * | ||
258 | * This function will parse the "ranges" property of a PCI host bridge device | ||
259 | * node and setup the resource mapping based on its content. It is expected | ||
260 | * that the property conforms with the Power ePAPR document. | ||
261 | * | ||
262 | * It returns zero if the range parsing has been successful or a standard error | ||
263 | * value if it failed. | ||
264 | */ | ||
265 | int of_pci_get_host_bridge_resources(struct device_node *dev, | ||
266 | unsigned char busno, unsigned char bus_max, | ||
267 | struct list_head *resources, resource_size_t *io_base) | ||
268 | { | ||
269 | struct resource_entry *window; | ||
270 | struct resource *res; | ||
271 | struct resource *bus_range; | ||
272 | struct of_pci_range range; | ||
273 | struct of_pci_range_parser parser; | ||
274 | char range_type[4]; | ||
275 | int err; | ||
276 | |||
277 | if (io_base) | ||
278 | *io_base = (resource_size_t)OF_BAD_ADDR; | ||
279 | |||
280 | bus_range = kzalloc(sizeof(*bus_range), GFP_KERNEL); | ||
281 | if (!bus_range) | ||
282 | return -ENOMEM; | ||
283 | |||
284 | pr_info("host bridge %pOF ranges:\n", dev); | ||
285 | |||
286 | err = of_pci_parse_bus_range(dev, bus_range); | ||
287 | if (err) { | ||
288 | bus_range->start = busno; | ||
289 | bus_range->end = bus_max; | ||
290 | bus_range->flags = IORESOURCE_BUS; | ||
291 | pr_info(" No bus range found for %pOF, using %pR\n", | ||
292 | dev, bus_range); | ||
293 | } else { | ||
294 | if (bus_range->end > bus_range->start + bus_max) | ||
295 | bus_range->end = bus_range->start + bus_max; | ||
296 | } | ||
297 | pci_add_resource(resources, bus_range); | ||
298 | |||
299 | /* Check for ranges property */ | ||
300 | err = of_pci_range_parser_init(&parser, dev); | ||
301 | if (err) | ||
302 | goto parse_failed; | ||
303 | |||
304 | pr_debug("Parsing ranges property...\n"); | ||
305 | for_each_of_pci_range(&parser, &range) { | ||
306 | /* Read next ranges element */ | ||
307 | if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_IO) | ||
308 | snprintf(range_type, 4, " IO"); | ||
309 | else if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM) | ||
310 | snprintf(range_type, 4, "MEM"); | ||
311 | else | ||
312 | snprintf(range_type, 4, "err"); | ||
313 | pr_info(" %s %#010llx..%#010llx -> %#010llx\n", range_type, | ||
314 | range.cpu_addr, range.cpu_addr + range.size - 1, | ||
315 | range.pci_addr); | ||
316 | |||
317 | /* | ||
318 | * If we failed translation or got a zero-sized region | ||
319 | * then skip this range | ||
320 | */ | ||
321 | if (range.cpu_addr == OF_BAD_ADDR || range.size == 0) | ||
322 | continue; | ||
323 | |||
324 | res = kzalloc(sizeof(struct resource), GFP_KERNEL); | ||
325 | if (!res) { | ||
326 | err = -ENOMEM; | ||
327 | goto parse_failed; | ||
328 | } | ||
329 | |||
330 | err = of_pci_range_to_resource(&range, dev, res); | ||
331 | if (err) { | ||
332 | kfree(res); | ||
333 | continue; | ||
334 | } | ||
335 | |||
336 | if (resource_type(res) == IORESOURCE_IO) { | ||
337 | if (!io_base) { | ||
338 | pr_err("I/O range found for %pOF. Please provide an io_base pointer to save CPU base address\n", | ||
339 | dev); | ||
340 | err = -EINVAL; | ||
341 | goto conversion_failed; | ||
342 | } | ||
343 | if (*io_base != (resource_size_t)OF_BAD_ADDR) | ||
344 | pr_warn("More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", | ||
345 | dev); | ||
346 | *io_base = range.cpu_addr; | ||
347 | } | ||
348 | |||
349 | pci_add_resource_offset(resources, res, res->start - range.pci_addr); | ||
350 | } | ||
351 | |||
352 | return 0; | ||
353 | |||
354 | conversion_failed: | ||
355 | kfree(res); | ||
356 | parse_failed: | ||
357 | resource_list_for_each_entry(window, resources) | ||
358 | kfree(window->res); | ||
359 | pci_free_resource_list(resources); | ||
360 | return err; | ||
361 | } | ||
362 | EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources); | ||
363 | #endif /* CONFIG_OF_ADDRESS */ | ||
364 | |||
365 | /** | ||
366 | * of_pci_map_rid - Translate a requester ID through a downstream mapping. | ||
367 | * @np: root complex device node. | ||
368 | * @rid: PCI requester ID to map. | ||
369 | * @map_name: property name of the map to use. | ||
370 | * @map_mask_name: optional property name of the mask to use. | ||
371 | * @target: optional pointer to a target device node. | ||
372 | * @id_out: optional pointer to receive the translated ID. | ||
373 | * | ||
374 | * Given a PCI requester ID, look up the appropriate implementation-defined | ||
375 | * platform ID and/or the target device which receives transactions on that | ||
376 | * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or | ||
377 | * @id_out may be NULL if only the other is required. If @target points to | ||
378 | * a non-NULL device node pointer, only entries targeting that node will be | ||
379 | * matched; if it points to a NULL value, it will receive the device node of | ||
380 | * the first matching target phandle, with a reference held. | ||
381 | * | ||
382 | * Return: 0 on success or a standard error code on failure. | ||
383 | */ | ||
384 | int of_pci_map_rid(struct device_node *np, u32 rid, | ||
385 | const char *map_name, const char *map_mask_name, | ||
386 | struct device_node **target, u32 *id_out) | ||
387 | { | ||
388 | u32 map_mask, masked_rid; | ||
389 | int map_len; | ||
390 | const __be32 *map = NULL; | ||
391 | |||
392 | if (!np || !map_name || (!target && !id_out)) | ||
393 | return -EINVAL; | ||
394 | |||
395 | map = of_get_property(np, map_name, &map_len); | ||
396 | if (!map) { | ||
397 | if (target) | ||
398 | return -ENODEV; | ||
399 | /* Otherwise, no map implies no translation */ | ||
400 | *id_out = rid; | ||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | if (!map_len || map_len % (4 * sizeof(*map))) { | ||
405 | pr_err("%pOF: Error: Bad %s length: %d\n", np, | ||
406 | map_name, map_len); | ||
407 | return -EINVAL; | ||
408 | } | ||
409 | |||
410 | /* The default is to select all bits. */ | ||
411 | map_mask = 0xffffffff; | ||
412 | |||
413 | /* | ||
414 | * Can be overridden by "{iommu,msi}-map-mask" property. | ||
415 | * If of_property_read_u32() fails, the default is used. | ||
416 | */ | ||
417 | if (map_mask_name) | ||
418 | of_property_read_u32(np, map_mask_name, &map_mask); | ||
419 | |||
420 | masked_rid = map_mask & rid; | ||
421 | for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) { | ||
422 | struct device_node *phandle_node; | ||
423 | u32 rid_base = be32_to_cpup(map + 0); | ||
424 | u32 phandle = be32_to_cpup(map + 1); | ||
425 | u32 out_base = be32_to_cpup(map + 2); | ||
426 | u32 rid_len = be32_to_cpup(map + 3); | ||
427 | |||
428 | if (rid_base & ~map_mask) { | ||
429 | pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", | ||
430 | np, map_name, map_name, | ||
431 | map_mask, rid_base); | ||
432 | return -EFAULT; | ||
433 | } | ||
434 | |||
435 | if (masked_rid < rid_base || masked_rid >= rid_base + rid_len) | ||
436 | continue; | ||
437 | |||
438 | phandle_node = of_find_node_by_phandle(phandle); | ||
439 | if (!phandle_node) | ||
440 | return -ENODEV; | ||
441 | |||
442 | if (target) { | ||
443 | if (*target) | ||
444 | of_node_put(phandle_node); | ||
445 | else | ||
446 | *target = phandle_node; | ||
447 | |||
448 | if (*target != phandle_node) | ||
449 | continue; | ||
450 | } | ||
451 | |||
452 | if (id_out) | ||
453 | *id_out = masked_rid - rid_base + out_base; | ||
454 | |||
455 | pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", | ||
456 | np, map_name, map_mask, rid_base, out_base, | ||
457 | rid_len, rid, masked_rid - rid_base + out_base); | ||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n", | ||
462 | np, map_name, rid, target && *target ? *target : NULL); | ||
463 | return -EFAULT; | ||
464 | } | ||
465 | |||
466 | #if IS_ENABLED(CONFIG_OF_IRQ) | ||
467 | /** | ||
468 | * of_irq_parse_pci - Resolve the interrupt for a PCI device | ||
469 | * @pdev: the device whose interrupt is to be resolved | ||
470 | * @out_irq: structure of_irq filled by this function | ||
471 | * | ||
472 | * This function resolves the PCI interrupt for a given PCI device. If a | ||
473 | * device-node exists for a given pci_dev, it will use normal OF tree | ||
474 | * walking. If not, it will implement standard swizzling and walk up the | ||
475 | * PCI tree until an device-node is found, at which point it will finish | ||
476 | * resolving using the OF tree walking. | ||
477 | */ | ||
478 | static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) | ||
479 | { | ||
480 | struct device_node *dn, *ppnode; | ||
481 | struct pci_dev *ppdev; | ||
482 | __be32 laddr[3]; | ||
483 | u8 pin; | ||
484 | int rc; | ||
485 | |||
486 | /* | ||
487 | * Check if we have a device node, if yes, fallback to standard | ||
488 | * device tree parsing | ||
489 | */ | ||
490 | dn = pci_device_to_OF_node(pdev); | ||
491 | if (dn) { | ||
492 | rc = of_irq_parse_one(dn, 0, out_irq); | ||
493 | if (!rc) | ||
494 | return rc; | ||
495 | } | ||
496 | |||
497 | /* | ||
498 | * Ok, we don't, time to have fun. Let's start by building up an | ||
499 | * interrupt spec. we assume #interrupt-cells is 1, which is standard | ||
500 | * for PCI. If you do different, then don't use that routine. | ||
501 | */ | ||
502 | rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin); | ||
503 | if (rc != 0) | ||
504 | goto err; | ||
505 | /* No pin, exit with no error message. */ | ||
506 | if (pin == 0) | ||
507 | return -ENODEV; | ||
508 | |||
509 | /* Now we walk up the PCI tree */ | ||
510 | for (;;) { | ||
511 | /* Get the pci_dev of our parent */ | ||
512 | ppdev = pdev->bus->self; | ||
513 | |||
514 | /* Ouch, it's a host bridge... */ | ||
515 | if (ppdev == NULL) { | ||
516 | ppnode = pci_bus_to_OF_node(pdev->bus); | ||
517 | |||
518 | /* No node for host bridge ? give up */ | ||
519 | if (ppnode == NULL) { | ||
520 | rc = -EINVAL; | ||
521 | goto err; | ||
522 | } | ||
523 | } else { | ||
524 | /* We found a P2P bridge, check if it has a node */ | ||
525 | ppnode = pci_device_to_OF_node(ppdev); | ||
526 | } | ||
527 | |||
528 | /* | ||
529 | * Ok, we have found a parent with a device-node, hand over to | ||
530 | * the OF parsing code. | ||
531 | * We build a unit address from the linux device to be used for | ||
532 | * resolution. Note that we use the linux bus number which may | ||
533 | * not match your firmware bus numbering. | ||
534 | * Fortunately, in most cases, interrupt-map-mask doesn't | ||
535 | * include the bus number as part of the matching. | ||
536 | * You should still be careful about that though if you intend | ||
537 | * to rely on this function (you ship a firmware that doesn't | ||
538 | * create device nodes for all PCI devices). | ||
539 | */ | ||
540 | if (ppnode) | ||
541 | break; | ||
542 | |||
543 | /* | ||
544 | * We can only get here if we hit a P2P bridge with no node; | ||
545 | * let's do standard swizzling and try again | ||
546 | */ | ||
547 | pin = pci_swizzle_interrupt_pin(pdev, pin); | ||
548 | pdev = ppdev; | ||
549 | } | ||
550 | |||
551 | out_irq->np = ppnode; | ||
552 | out_irq->args_count = 1; | ||
553 | out_irq->args[0] = pin; | ||
554 | laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); | ||
555 | laddr[1] = laddr[2] = cpu_to_be32(0); | ||
556 | rc = of_irq_parse_raw(laddr, out_irq); | ||
557 | if (rc) | ||
558 | goto err; | ||
559 | return 0; | ||
560 | err: | ||
561 | if (rc == -ENOENT) { | ||
562 | dev_warn(&pdev->dev, | ||
563 | "%s: no interrupt-map found, INTx interrupts not available\n", | ||
564 | __func__); | ||
565 | pr_warn_once("%s: possibly some PCI slots don't have level triggered interrupts capability\n", | ||
566 | __func__); | ||
567 | } else { | ||
568 | dev_err(&pdev->dev, "%s: failed with rc=%d\n", __func__, rc); | ||
569 | } | ||
570 | return rc; | ||
571 | } | ||
572 | |||
573 | /** | ||
574 | * of_irq_parse_and_map_pci() - Decode a PCI IRQ from the device tree and map to a VIRQ | ||
575 | * @dev: The PCI device needing an IRQ | ||
576 | * @slot: PCI slot number; passed when used as map_irq callback. Unused | ||
577 | * @pin: PCI IRQ pin number; passed when used as map_irq callback. Unused | ||
578 | * | ||
579 | * @slot and @pin are unused, but included in the function so that this | ||
580 | * function can be used directly as the map_irq callback to | ||
581 | * pci_assign_irq() and struct pci_host_bridge.map_irq pointer | ||
582 | */ | ||
583 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) | ||
584 | { | ||
585 | struct of_phandle_args oirq; | ||
586 | int ret; | ||
587 | |||
588 | ret = of_irq_parse_pci(dev, &oirq); | ||
589 | if (ret) | ||
590 | return 0; /* Proper return code 0 == NO_IRQ */ | ||
591 | |||
592 | return irq_create_of_mapping(&oirq); | ||
593 | } | ||
594 | EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci); | ||
595 | #endif /* CONFIG_OF_IRQ */ | ||
596 | |||
597 | int pci_parse_request_of_pci_ranges(struct device *dev, | ||
598 | struct list_head *resources, | ||
599 | struct resource **bus_range) | ||
600 | { | ||
601 | int err, res_valid = 0; | ||
602 | struct device_node *np = dev->of_node; | ||
603 | resource_size_t iobase; | ||
604 | struct resource_entry *win, *tmp; | ||
605 | |||
606 | INIT_LIST_HEAD(resources); | ||
607 | err = of_pci_get_host_bridge_resources(np, 0, 0xff, resources, &iobase); | ||
608 | if (err) | ||
609 | return err; | ||
610 | |||
611 | err = devm_request_pci_bus_resources(dev, resources); | ||
612 | if (err) | ||
613 | goto out_release_res; | ||
614 | |||
615 | resource_list_for_each_entry_safe(win, tmp, resources) { | ||
616 | struct resource *res = win->res; | ||
617 | |||
618 | switch (resource_type(res)) { | ||
619 | case IORESOURCE_IO: | ||
620 | err = pci_remap_iospace(res, iobase); | ||
621 | if (err) { | ||
622 | dev_warn(dev, "error %d: failed to map resource %pR\n", | ||
623 | err, res); | ||
624 | resource_list_destroy_entry(win); | ||
625 | } | ||
626 | break; | ||
627 | case IORESOURCE_MEM: | ||
628 | res_valid |= !(res->flags & IORESOURCE_PREFETCH); | ||
629 | break; | ||
630 | case IORESOURCE_BUS: | ||
631 | if (bus_range) | ||
632 | *bus_range = res; | ||
633 | break; | ||
634 | } | ||
635 | } | ||
636 | |||
637 | if (res_valid) | ||
638 | return 0; | ||
639 | |||
640 | dev_err(dev, "non-prefetchable memory resource required\n"); | ||
641 | err = -EINVAL; | ||
642 | |||
643 | out_release_res: | ||
644 | pci_free_resource_list(resources); | ||
645 | return err; | ||
646 | } | ||
647 | |||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 4708eb9df71b..78157688dcc9 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * File: pci-acpi.c | 3 | * File: pci-acpi.c |
3 | * Purpose: Provide PCI support in ACPI | 4 | * Purpose: Provide PCI support in ACPI |
@@ -542,7 +543,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
542 | } | 543 | } |
543 | 544 | ||
544 | if (!error) | 545 | if (!error) |
545 | dev_dbg(&dev->dev, "power state changed by ACPI to %s\n", | 546 | pci_dbg(dev, "power state changed by ACPI to %s\n", |
546 | acpi_power_state_string(state_conv[state])); | 547 | acpi_power_state_string(state_conv[state])); |
547 | 548 | ||
548 | return error; | 549 | return error; |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 5958c8dda4e3..3bed6beda051 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -1,11 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/pci-driver.c | 3 | * drivers/pci/pci-driver.c |
3 | * | 4 | * |
4 | * (C) Copyright 2002-2004, 2007 Greg Kroah-Hartman <greg@kroah.com> | 5 | * (C) Copyright 2002-2004, 2007 Greg Kroah-Hartman <greg@kroah.com> |
5 | * (C) Copyright 2007 Novell Inc. | 6 | * (C) Copyright 2007 Novell Inc. |
6 | * | ||
7 | * Released under the GPL v2 only. | ||
8 | * | ||
9 | */ | 7 | */ |
10 | 8 | ||
11 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
diff --git a/drivers/pci/pci-mid.c b/drivers/pci/pci-mid.c index a4ac940c7696..314e135014dc 100644 --- a/drivers/pci/pci-mid.c +++ b/drivers/pci/pci-mid.c | |||
@@ -1,13 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Intel MID platform PM support | 3 | * Intel MID platform PM support |
3 | * | 4 | * |
4 | * Copyright (C) 2016, Intel Corporation | 5 | * Copyright (C) 2016, Intel Corporation |
5 | * | 6 | * |
6 | * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 7 | * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | */ | 8 | */ |
12 | 9 | ||
13 | #include <linux/init.h> | 10 | #include <linux/init.h> |
diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index 886fb3570278..10d54f939048 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c | |||
@@ -1,11 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* pci-stub - simple stub driver to reserve a pci device | 2 | /* pci-stub - simple stub driver to reserve a pci device |
2 | * | 3 | * |
3 | * Copyright (C) 2008 Red Hat, Inc. | 4 | * Copyright (C) 2008 Red Hat, Inc. |
4 | * Author: | 5 | * Author: |
5 | * Chris Wright | 6 | * Chris Wright |
6 | * | 7 | * |
7 | * This work is licensed under the terms of the GNU GPL, version 2. | ||
8 | * | ||
9 | * Usage is simple, allocate a new id to the stub driver and bind the | 8 | * Usage is simple, allocate a new id to the stub driver and bind the |
10 | * device to it. For example: | 9 | * device to it. For example: |
11 | * | 10 | * |
@@ -28,7 +27,7 @@ MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is " | |||
28 | 27 | ||
29 | static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) | 28 | static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) |
30 | { | 29 | { |
31 | dev_info(&dev->dev, "claimed by stub\n"); | 30 | pci_info(dev, "claimed by stub\n"); |
32 | return 0; | 31 | return 0; |
33 | } | 32 | } |
34 | 33 | ||
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 06c7f0b85cd2..eb6bee8724cc 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -278,6 +278,16 @@ static ssize_t subordinate_bus_number_show(struct device *dev, | |||
278 | } | 278 | } |
279 | static DEVICE_ATTR_RO(subordinate_bus_number); | 279 | static DEVICE_ATTR_RO(subordinate_bus_number); |
280 | 280 | ||
281 | static ssize_t ari_enabled_show(struct device *dev, | ||
282 | struct device_attribute *attr, | ||
283 | char *buf) | ||
284 | { | ||
285 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
286 | |||
287 | return sprintf(buf, "%u\n", pci_ari_enabled(pci_dev->bus)); | ||
288 | } | ||
289 | static DEVICE_ATTR_RO(ari_enabled); | ||
290 | |||
281 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, | 291 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, |
282 | char *buf) | 292 | char *buf) |
283 | { | 293 | { |
@@ -348,7 +358,7 @@ static ssize_t numa_node_store(struct device *dev, | |||
348 | return -EINVAL; | 358 | return -EINVAL; |
349 | 359 | ||
350 | add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); | 360 | add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); |
351 | dev_alert(&pdev->dev, FW_BUG "Overriding NUMA node to %d. Contact your vendor for updates.", | 361 | pci_alert(pdev, FW_BUG "Overriding NUMA node to %d. Contact your vendor for updates.", |
352 | node); | 362 | node); |
353 | 363 | ||
354 | dev->numa_node = node; | 364 | dev->numa_node = node; |
@@ -411,7 +421,7 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, | |||
411 | */ | 421 | */ |
412 | if (!subordinate) { | 422 | if (!subordinate) { |
413 | pdev->no_msi = !val; | 423 | pdev->no_msi = !val; |
414 | dev_info(&pdev->dev, "MSI/MSI-X %s for future drivers\n", | 424 | pci_info(pdev, "MSI/MSI-X %s for future drivers\n", |
415 | val ? "allowed" : "disallowed"); | 425 | val ? "allowed" : "disallowed"); |
416 | return count; | 426 | return count; |
417 | } | 427 | } |
@@ -613,7 +623,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, | |||
613 | 623 | ||
614 | /* is PF driver loaded w/callback */ | 624 | /* is PF driver loaded w/callback */ |
615 | if (!pdev->driver || !pdev->driver->sriov_configure) { | 625 | if (!pdev->driver || !pdev->driver->sriov_configure) { |
616 | dev_info(&pdev->dev, "Driver doesn't support SRIOV configuration via sysfs\n"); | 626 | pci_info(pdev, "Driver doesn't support SRIOV configuration via sysfs\n"); |
617 | ret = -ENOENT; | 627 | ret = -ENOENT; |
618 | goto exit; | 628 | goto exit; |
619 | } | 629 | } |
@@ -626,7 +636,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, | |||
626 | 636 | ||
627 | /* enable VFs */ | 637 | /* enable VFs */ |
628 | if (pdev->sriov->num_VFs) { | 638 | if (pdev->sriov->num_VFs) { |
629 | dev_warn(&pdev->dev, "%d VFs already enabled. Disable before enabling %d VFs\n", | 639 | pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", |
630 | pdev->sriov->num_VFs, num_vfs); | 640 | pdev->sriov->num_VFs, num_vfs); |
631 | ret = -EBUSY; | 641 | ret = -EBUSY; |
632 | goto exit; | 642 | goto exit; |
@@ -637,7 +647,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, | |||
637 | goto exit; | 647 | goto exit; |
638 | 648 | ||
639 | if (ret != num_vfs) | 649 | if (ret != num_vfs) |
640 | dev_warn(&pdev->dev, "%d VFs requested; only %d enabled\n", | 650 | pci_warn(pdev, "%d VFs requested; only %d enabled\n", |
641 | num_vfs, ret); | 651 | num_vfs, ret); |
642 | 652 | ||
643 | exit: | 653 | exit: |
@@ -786,6 +796,7 @@ static struct attribute *pci_dev_attrs[] = { | |||
786 | &dev_attr_devspec.attr, | 796 | &dev_attr_devspec.attr, |
787 | #endif | 797 | #endif |
788 | &dev_attr_driver_override.attr, | 798 | &dev_attr_driver_override.attr, |
799 | &dev_attr_ari_enabled.attr, | ||
789 | NULL, | 800 | NULL, |
790 | }; | 801 | }; |
791 | 802 | ||
@@ -1216,14 +1227,9 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | |||
1216 | if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) | 1227 | if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) |
1217 | return -EINVAL; | 1228 | return -EINVAL; |
1218 | 1229 | ||
1219 | if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS)) { | 1230 | if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS)) |
1220 | WARN(1, "process \"%s\" tried to map 0x%08lx bytes at page 0x%08lx on %s BAR %d (start 0x%16Lx, size 0x%16Lx)\n", | ||
1221 | current->comm, vma->vm_end-vma->vm_start, vma->vm_pgoff, | ||
1222 | pci_name(pdev), bar, | ||
1223 | (u64)pci_resource_start(pdev, bar), | ||
1224 | (u64)pci_resource_len(pdev, bar)); | ||
1225 | return -EINVAL; | 1231 | return -EINVAL; |
1226 | } | 1232 | |
1227 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; | 1233 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; |
1228 | 1234 | ||
1229 | return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine); | 1235 | return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine); |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4a7c6864fdf4..f6a4dd10d9b0 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCI Bus Services, see include/linux/pci.h for further explanation. | 3 | * PCI Bus Services, see include/linux/pci.h for further explanation. |
3 | * | 4 | * |
@@ -156,7 +157,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) | |||
156 | * Make sure the BAR is actually a memory resource, not an IO resource | 157 | * Make sure the BAR is actually a memory resource, not an IO resource |
157 | */ | 158 | */ |
158 | if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { | 159 | if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { |
159 | dev_warn(&pdev->dev, "can't ioremap BAR %d: %pR\n", bar, res); | 160 | pci_warn(pdev, "can't ioremap BAR %d: %pR\n", bar, res); |
160 | return NULL; | 161 | return NULL; |
161 | } | 162 | } |
162 | return ioremap_nocache(res->start, resource_size(res)); | 163 | return ioremap_nocache(res->start, resource_size(res)); |
@@ -648,7 +649,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
648 | */ | 649 | */ |
649 | if (state != PCI_D0 && dev->current_state <= PCI_D3cold | 650 | if (state != PCI_D0 && dev->current_state <= PCI_D3cold |
650 | && dev->current_state > state) { | 651 | && dev->current_state > state) { |
651 | dev_err(&dev->dev, "invalid power transition (from state %d to %d)\n", | 652 | pci_err(dev, "invalid power transition (from state %d to %d)\n", |
652 | dev->current_state, state); | 653 | dev->current_state, state); |
653 | return -EINVAL; | 654 | return -EINVAL; |
654 | } | 655 | } |
@@ -696,7 +697,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
696 | pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); | 697 | pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); |
697 | dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); | 698 | dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); |
698 | if (dev->current_state != state && printk_ratelimit()) | 699 | if (dev->current_state != state && printk_ratelimit()) |
699 | dev_info(&dev->dev, "Refused to change power state, currently in D%d\n", | 700 | pci_info(dev, "Refused to change power state, currently in D%d\n", |
700 | dev->current_state); | 701 | dev->current_state); |
701 | 702 | ||
702 | /* | 703 | /* |
@@ -970,7 +971,7 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) | |||
970 | case PM_EVENT_HIBERNATE: | 971 | case PM_EVENT_HIBERNATE: |
971 | return PCI_D3hot; | 972 | return PCI_D3hot; |
972 | default: | 973 | default: |
973 | dev_info(&dev->dev, "unrecognized suspend event %d\n", | 974 | pci_info(dev, "unrecognized suspend event %d\n", |
974 | state.event); | 975 | state.event); |
975 | BUG(); | 976 | BUG(); |
976 | } | 977 | } |
@@ -1013,7 +1014,7 @@ static int pci_save_pcie_state(struct pci_dev *dev) | |||
1013 | 1014 | ||
1014 | save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); | 1015 | save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); |
1015 | if (!save_state) { | 1016 | if (!save_state) { |
1016 | dev_err(&dev->dev, "buffer not found in %s\n", __func__); | 1017 | pci_err(dev, "buffer not found in %s\n", __func__); |
1017 | return -ENOMEM; | 1018 | return -ENOMEM; |
1018 | } | 1019 | } |
1019 | 1020 | ||
@@ -1061,7 +1062,7 @@ static int pci_save_pcix_state(struct pci_dev *dev) | |||
1061 | 1062 | ||
1062 | save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX); | 1063 | save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX); |
1063 | if (!save_state) { | 1064 | if (!save_state) { |
1064 | dev_err(&dev->dev, "buffer not found in %s\n", __func__); | 1065 | pci_err(dev, "buffer not found in %s\n", __func__); |
1065 | return -ENOMEM; | 1066 | return -ENOMEM; |
1066 | } | 1067 | } |
1067 | 1068 | ||
@@ -1121,7 +1122,7 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset, | |||
1121 | return; | 1122 | return; |
1122 | 1123 | ||
1123 | for (;;) { | 1124 | for (;;) { |
1124 | dev_dbg(&pdev->dev, "restoring config space at offset %#x (was %#x, writing %#x)\n", | 1125 | pci_dbg(pdev, "restoring config space at offset %#x (was %#x, writing %#x)\n", |
1125 | offset, val, saved_val); | 1126 | offset, val, saved_val); |
1126 | pci_write_config_dword(pdev, offset, saved_val); | 1127 | pci_write_config_dword(pdev, offset, saved_val); |
1127 | if (retry-- <= 0) | 1128 | if (retry-- <= 0) |
@@ -1358,7 +1359,7 @@ static void pci_enable_bridge(struct pci_dev *dev) | |||
1358 | 1359 | ||
1359 | retval = pci_enable_device(dev); | 1360 | retval = pci_enable_device(dev); |
1360 | if (retval) | 1361 | if (retval) |
1361 | dev_err(&dev->dev, "Error enabling bridge (%d), continuing\n", | 1362 | pci_err(dev, "Error enabling bridge (%d), continuing\n", |
1362 | retval); | 1363 | retval); |
1363 | pci_set_master(dev); | 1364 | pci_set_master(dev); |
1364 | } | 1365 | } |
@@ -1458,6 +1459,7 @@ struct pci_devres { | |||
1458 | unsigned int pinned:1; | 1459 | unsigned int pinned:1; |
1459 | unsigned int orig_intx:1; | 1460 | unsigned int orig_intx:1; |
1460 | unsigned int restore_intx:1; | 1461 | unsigned int restore_intx:1; |
1462 | unsigned int mwi:1; | ||
1461 | u32 region_mask; | 1463 | u32 region_mask; |
1462 | }; | 1464 | }; |
1463 | 1465 | ||
@@ -1476,6 +1478,9 @@ static void pcim_release(struct device *gendev, void *res) | |||
1476 | if (this->region_mask & (1 << i)) | 1478 | if (this->region_mask & (1 << i)) |
1477 | pci_release_region(dev, i); | 1479 | pci_release_region(dev, i); |
1478 | 1480 | ||
1481 | if (this->mwi) | ||
1482 | pci_clear_mwi(dev); | ||
1483 | |||
1479 | if (this->restore_intx) | 1484 | if (this->restore_intx) |
1480 | pci_intx(dev, this->orig_intx); | 1485 | pci_intx(dev, this->orig_intx); |
1481 | 1486 | ||
@@ -1863,7 +1868,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1863 | pme_dev = kmalloc(sizeof(struct pci_pme_device), | 1868 | pme_dev = kmalloc(sizeof(struct pci_pme_device), |
1864 | GFP_KERNEL); | 1869 | GFP_KERNEL); |
1865 | if (!pme_dev) { | 1870 | if (!pme_dev) { |
1866 | dev_warn(&dev->dev, "can't enable PME#\n"); | 1871 | pci_warn(dev, "can't enable PME#\n"); |
1867 | return; | 1872 | return; |
1868 | } | 1873 | } |
1869 | pme_dev->dev = dev; | 1874 | pme_dev->dev = dev; |
@@ -1887,7 +1892,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1887 | } | 1892 | } |
1888 | } | 1893 | } |
1889 | 1894 | ||
1890 | dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled"); | 1895 | pci_dbg(dev, "PME# %s\n", enable ? "enabled" : "disabled"); |
1891 | } | 1896 | } |
1892 | EXPORT_SYMBOL(pci_pme_active); | 1897 | EXPORT_SYMBOL(pci_pme_active); |
1893 | 1898 | ||
@@ -2424,7 +2429,7 @@ void pci_pm_init(struct pci_dev *dev) | |||
2424 | pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc); | 2429 | pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc); |
2425 | 2430 | ||
2426 | if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { | 2431 | if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { |
2427 | dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", | 2432 | pci_err(dev, "unsupported PM cap regs version (%u)\n", |
2428 | pmc & PCI_PM_CAP_VER_MASK); | 2433 | pmc & PCI_PM_CAP_VER_MASK); |
2429 | return; | 2434 | return; |
2430 | } | 2435 | } |
@@ -2444,15 +2449,14 @@ void pci_pm_init(struct pci_dev *dev) | |||
2444 | dev->d2_support = true; | 2449 | dev->d2_support = true; |
2445 | 2450 | ||
2446 | if (dev->d1_support || dev->d2_support) | 2451 | if (dev->d1_support || dev->d2_support) |
2447 | dev_printk(KERN_DEBUG, &dev->dev, "supports%s%s\n", | 2452 | pci_printk(KERN_DEBUG, dev, "supports%s%s\n", |
2448 | dev->d1_support ? " D1" : "", | 2453 | dev->d1_support ? " D1" : "", |
2449 | dev->d2_support ? " D2" : ""); | 2454 | dev->d2_support ? " D2" : ""); |
2450 | } | 2455 | } |
2451 | 2456 | ||
2452 | pmc &= PCI_PM_CAP_PME_MASK; | 2457 | pmc &= PCI_PM_CAP_PME_MASK; |
2453 | if (pmc) { | 2458 | if (pmc) { |
2454 | dev_printk(KERN_DEBUG, &dev->dev, | 2459 | pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", |
2455 | "PME# supported from%s%s%s%s%s\n", | ||
2456 | (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", | 2460 | (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", |
2457 | (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", | 2461 | (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", |
2458 | (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "", | 2462 | (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "", |
@@ -2544,13 +2548,13 @@ static int pci_ea_read(struct pci_dev *dev, int offset) | |||
2544 | 2548 | ||
2545 | res = pci_ea_get_resource(dev, bei, prop); | 2549 | res = pci_ea_get_resource(dev, bei, prop); |
2546 | if (!res) { | 2550 | if (!res) { |
2547 | dev_err(&dev->dev, "Unsupported EA entry BEI: %u\n", bei); | 2551 | pci_err(dev, "Unsupported EA entry BEI: %u\n", bei); |
2548 | goto out; | 2552 | goto out; |
2549 | } | 2553 | } |
2550 | 2554 | ||
2551 | flags = pci_ea_flags(dev, prop); | 2555 | flags = pci_ea_flags(dev, prop); |
2552 | if (!flags) { | 2556 | if (!flags) { |
2553 | dev_err(&dev->dev, "Unsupported EA properties: %#x\n", prop); | 2557 | pci_err(dev, "Unsupported EA properties: %#x\n", prop); |
2554 | goto out; | 2558 | goto out; |
2555 | } | 2559 | } |
2556 | 2560 | ||
@@ -2600,13 +2604,12 @@ static int pci_ea_read(struct pci_dev *dev, int offset) | |||
2600 | } | 2604 | } |
2601 | 2605 | ||
2602 | if (end < start) { | 2606 | if (end < start) { |
2603 | dev_err(&dev->dev, "EA Entry crosses address boundary\n"); | 2607 | pci_err(dev, "EA Entry crosses address boundary\n"); |
2604 | goto out; | 2608 | goto out; |
2605 | } | 2609 | } |
2606 | 2610 | ||
2607 | if (ent_size != ent_offset - offset) { | 2611 | if (ent_size != ent_offset - offset) { |
2608 | dev_err(&dev->dev, | 2612 | pci_err(dev, "EA Entry Size (%d) does not match length read (%d)\n", |
2609 | "EA Entry Size (%d) does not match length read (%d)\n", | ||
2610 | ent_size, ent_offset - offset); | 2613 | ent_size, ent_offset - offset); |
2611 | goto out; | 2614 | goto out; |
2612 | } | 2615 | } |
@@ -2617,16 +2620,16 @@ static int pci_ea_read(struct pci_dev *dev, int offset) | |||
2617 | res->flags = flags; | 2620 | res->flags = flags; |
2618 | 2621 | ||
2619 | if (bei <= PCI_EA_BEI_BAR5) | 2622 | if (bei <= PCI_EA_BEI_BAR5) |
2620 | dev_printk(KERN_DEBUG, &dev->dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", | 2623 | pci_printk(KERN_DEBUG, dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", |
2621 | bei, res, prop); | 2624 | bei, res, prop); |
2622 | else if (bei == PCI_EA_BEI_ROM) | 2625 | else if (bei == PCI_EA_BEI_ROM) |
2623 | dev_printk(KERN_DEBUG, &dev->dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", | 2626 | pci_printk(KERN_DEBUG, dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", |
2624 | res, prop); | 2627 | res, prop); |
2625 | else if (bei >= PCI_EA_BEI_VF_BAR0 && bei <= PCI_EA_BEI_VF_BAR5) | 2628 | else if (bei >= PCI_EA_BEI_VF_BAR0 && bei <= PCI_EA_BEI_VF_BAR5) |
2626 | dev_printk(KERN_DEBUG, &dev->dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", | 2629 | pci_printk(KERN_DEBUG, dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", |
2627 | bei - PCI_EA_BEI_VF_BAR0, res, prop); | 2630 | bei - PCI_EA_BEI_VF_BAR0, res, prop); |
2628 | else | 2631 | else |
2629 | dev_printk(KERN_DEBUG, &dev->dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", | 2632 | pci_printk(KERN_DEBUG, dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", |
2630 | bei, res, prop); | 2633 | bei, res, prop); |
2631 | 2634 | ||
2632 | out: | 2635 | out: |
@@ -2723,13 +2726,11 @@ void pci_allocate_cap_save_buffers(struct pci_dev *dev) | |||
2723 | error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, | 2726 | error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, |
2724 | PCI_EXP_SAVE_REGS * sizeof(u16)); | 2727 | PCI_EXP_SAVE_REGS * sizeof(u16)); |
2725 | if (error) | 2728 | if (error) |
2726 | dev_err(&dev->dev, | 2729 | pci_err(dev, "unable to preallocate PCI Express save buffer\n"); |
2727 | "unable to preallocate PCI Express save buffer\n"); | ||
2728 | 2730 | ||
2729 | error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16)); | 2731 | error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16)); |
2730 | if (error) | 2732 | if (error) |
2731 | dev_err(&dev->dev, | 2733 | pci_err(dev, "unable to preallocate PCI-X save buffer\n"); |
2732 | "unable to preallocate PCI-X save buffer\n"); | ||
2733 | 2734 | ||
2734 | pci_allocate_vc_save_buffers(dev); | 2735 | pci_allocate_vc_save_buffers(dev); |
2735 | } | 2736 | } |
@@ -3066,6 +3067,81 @@ int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size) | |||
3066 | } | 3067 | } |
3067 | 3068 | ||
3068 | /** | 3069 | /** |
3070 | * pci_enable_atomic_ops_to_root - enable AtomicOp requests to root port | ||
3071 | * @dev: the PCI device | ||
3072 | * @cap_mask: mask of desired AtomicOp sizes, including one or more of: | ||
3073 | * PCI_EXP_DEVCAP2_ATOMIC_COMP32 | ||
3074 | * PCI_EXP_DEVCAP2_ATOMIC_COMP64 | ||
3075 | * PCI_EXP_DEVCAP2_ATOMIC_COMP128 | ||
3076 | * | ||
3077 | * Return 0 if all upstream bridges support AtomicOp routing, egress | ||
3078 | * blocking is disabled on all upstream ports, and the root port supports | ||
3079 | * the requested completion capabilities (32-bit, 64-bit and/or 128-bit | ||
3080 | * AtomicOp completion), or negative otherwise. | ||
3081 | */ | ||
3082 | int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) | ||
3083 | { | ||
3084 | struct pci_bus *bus = dev->bus; | ||
3085 | struct pci_dev *bridge; | ||
3086 | u32 cap, ctl2; | ||
3087 | |||
3088 | if (!pci_is_pcie(dev)) | ||
3089 | return -EINVAL; | ||
3090 | |||
3091 | /* | ||
3092 | * Per PCIe r4.0, sec 6.15, endpoints and root ports may be | ||
3093 | * AtomicOp requesters. For now, we only support endpoints as | ||
3094 | * requesters and root ports as completers. No endpoints as | ||
3095 | * completers, and no peer-to-peer. | ||
3096 | */ | ||
3097 | |||
3098 | switch (pci_pcie_type(dev)) { | ||
3099 | case PCI_EXP_TYPE_ENDPOINT: | ||
3100 | case PCI_EXP_TYPE_LEG_END: | ||
3101 | case PCI_EXP_TYPE_RC_END: | ||
3102 | break; | ||
3103 | default: | ||
3104 | return -EINVAL; | ||
3105 | } | ||
3106 | |||
3107 | while (bus->parent) { | ||
3108 | bridge = bus->self; | ||
3109 | |||
3110 | pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap); | ||
3111 | |||
3112 | switch (pci_pcie_type(bridge)) { | ||
3113 | /* Ensure switch ports support AtomicOp routing */ | ||
3114 | case PCI_EXP_TYPE_UPSTREAM: | ||
3115 | case PCI_EXP_TYPE_DOWNSTREAM: | ||
3116 | if (!(cap & PCI_EXP_DEVCAP2_ATOMIC_ROUTE)) | ||
3117 | return -EINVAL; | ||
3118 | break; | ||
3119 | |||
3120 | /* Ensure root port supports all the sizes we care about */ | ||
3121 | case PCI_EXP_TYPE_ROOT_PORT: | ||
3122 | if ((cap & cap_mask) != cap_mask) | ||
3123 | return -EINVAL; | ||
3124 | break; | ||
3125 | } | ||
3126 | |||
3127 | /* Ensure upstream ports don't block AtomicOps on egress */ | ||
3128 | if (!bridge->has_secondary_link) { | ||
3129 | pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, | ||
3130 | &ctl2); | ||
3131 | if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK) | ||
3132 | return -EINVAL; | ||
3133 | } | ||
3134 | |||
3135 | bus = bus->parent; | ||
3136 | } | ||
3137 | |||
3138 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, | ||
3139 | PCI_EXP_DEVCTL2_ATOMIC_REQ); | ||
3140 | return 0; | ||
3141 | } | ||
3142 | EXPORT_SYMBOL(pci_enable_atomic_ops_to_root); | ||
3143 | |||
3144 | /** | ||
3069 | * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge | 3145 | * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge |
3070 | * @dev: the PCI device | 3146 | * @dev: the PCI device |
3071 | * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD) | 3147 | * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD) |
@@ -3198,7 +3274,7 @@ static int __pci_request_region(struct pci_dev *pdev, int bar, | |||
3198 | return 0; | 3274 | return 0; |
3199 | 3275 | ||
3200 | err_out: | 3276 | err_out: |
3201 | dev_warn(&pdev->dev, "BAR %d: can't reserve %pR\n", bar, | 3277 | pci_warn(pdev, "BAR %d: can't reserve %pR\n", bar, |
3202 | &pdev->resource[bar]); | 3278 | &pdev->resource[bar]); |
3203 | return -EBUSY; | 3279 | return -EBUSY; |
3204 | } | 3280 | } |
@@ -3621,7 +3697,7 @@ static void __pci_set_master(struct pci_dev *dev, bool enable) | |||
3621 | else | 3697 | else |
3622 | cmd = old_cmd & ~PCI_COMMAND_MASTER; | 3698 | cmd = old_cmd & ~PCI_COMMAND_MASTER; |
3623 | if (cmd != old_cmd) { | 3699 | if (cmd != old_cmd) { |
3624 | dev_dbg(&dev->dev, "%s bus mastering\n", | 3700 | pci_dbg(dev, "%s bus mastering\n", |
3625 | enable ? "enabling" : "disabling"); | 3701 | enable ? "enabling" : "disabling"); |
3626 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 3702 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
3627 | } | 3703 | } |
@@ -3722,7 +3798,7 @@ int pci_set_cacheline_size(struct pci_dev *dev) | |||
3722 | if (cacheline_size == pci_cache_line_size) | 3798 | if (cacheline_size == pci_cache_line_size) |
3723 | return 0; | 3799 | return 0; |
3724 | 3800 | ||
3725 | dev_printk(KERN_DEBUG, &dev->dev, "cache line size of %d is not supported\n", | 3801 | pci_printk(KERN_DEBUG, dev, "cache line size of %d is not supported\n", |
3726 | pci_cache_line_size << 2); | 3802 | pci_cache_line_size << 2); |
3727 | 3803 | ||
3728 | return -EINVAL; | 3804 | return -EINVAL; |
@@ -3751,7 +3827,7 @@ int pci_set_mwi(struct pci_dev *dev) | |||
3751 | 3827 | ||
3752 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | 3828 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
3753 | if (!(cmd & PCI_COMMAND_INVALIDATE)) { | 3829 | if (!(cmd & PCI_COMMAND_INVALIDATE)) { |
3754 | dev_dbg(&dev->dev, "enabling Mem-Wr-Inval\n"); | 3830 | pci_dbg(dev, "enabling Mem-Wr-Inval\n"); |
3755 | cmd |= PCI_COMMAND_INVALIDATE; | 3831 | cmd |= PCI_COMMAND_INVALIDATE; |
3756 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 3832 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
3757 | } | 3833 | } |
@@ -3761,6 +3837,27 @@ int pci_set_mwi(struct pci_dev *dev) | |||
3761 | EXPORT_SYMBOL(pci_set_mwi); | 3837 | EXPORT_SYMBOL(pci_set_mwi); |
3762 | 3838 | ||
3763 | /** | 3839 | /** |
3840 | * pcim_set_mwi - a device-managed pci_set_mwi() | ||
3841 | * @dev: the PCI device for which MWI is enabled | ||
3842 | * | ||
3843 | * Managed pci_set_mwi(). | ||
3844 | * | ||
3845 | * RETURNS: An appropriate -ERRNO error value on error, or zero for success. | ||
3846 | */ | ||
3847 | int pcim_set_mwi(struct pci_dev *dev) | ||
3848 | { | ||
3849 | struct pci_devres *dr; | ||
3850 | |||
3851 | dr = find_pci_dr(dev); | ||
3852 | if (!dr) | ||
3853 | return -ENOMEM; | ||
3854 | |||
3855 | dr->mwi = 1; | ||
3856 | return pci_set_mwi(dev); | ||
3857 | } | ||
3858 | EXPORT_SYMBOL(pcim_set_mwi); | ||
3859 | |||
3860 | /** | ||
3764 | * pci_try_set_mwi - enables memory-write-invalidate PCI transaction | 3861 | * pci_try_set_mwi - enables memory-write-invalidate PCI transaction |
3765 | * @dev: the PCI device for which MWI is enabled | 3862 | * @dev: the PCI device for which MWI is enabled |
3766 | * | 3863 | * |
@@ -3947,13 +4044,13 @@ static void pci_flr_wait(struct pci_dev *dev) | |||
3947 | pci_read_config_dword(dev, PCI_COMMAND, &id); | 4044 | pci_read_config_dword(dev, PCI_COMMAND, &id); |
3948 | while (id == ~0) { | 4045 | while (id == ~0) { |
3949 | if (delay > timeout) { | 4046 | if (delay > timeout) { |
3950 | dev_warn(&dev->dev, "not ready %dms after FLR; giving up\n", | 4047 | pci_warn(dev, "not ready %dms after FLR; giving up\n", |
3951 | 100 + delay - 1); | 4048 | 100 + delay - 1); |
3952 | return; | 4049 | return; |
3953 | } | 4050 | } |
3954 | 4051 | ||
3955 | if (delay > 1000) | 4052 | if (delay > 1000) |
3956 | dev_info(&dev->dev, "not ready %dms after FLR; waiting\n", | 4053 | pci_info(dev, "not ready %dms after FLR; waiting\n", |
3957 | 100 + delay - 1); | 4054 | 100 + delay - 1); |
3958 | 4055 | ||
3959 | msleep(delay); | 4056 | msleep(delay); |
@@ -3962,7 +4059,7 @@ static void pci_flr_wait(struct pci_dev *dev) | |||
3962 | } | 4059 | } |
3963 | 4060 | ||
3964 | if (delay > 1000) | 4061 | if (delay > 1000) |
3965 | dev_info(&dev->dev, "ready %dms after FLR\n", 100 + delay - 1); | 4062 | pci_info(dev, "ready %dms after FLR\n", 100 + delay - 1); |
3966 | } | 4063 | } |
3967 | 4064 | ||
3968 | /** | 4065 | /** |
@@ -3994,7 +4091,7 @@ static bool pcie_has_flr(struct pci_dev *dev) | |||
3994 | void pcie_flr(struct pci_dev *dev) | 4091 | void pcie_flr(struct pci_dev *dev) |
3995 | { | 4092 | { |
3996 | if (!pci_wait_for_pending_transaction(dev)) | 4093 | if (!pci_wait_for_pending_transaction(dev)) |
3997 | dev_err(&dev->dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); | 4094 | pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); |
3998 | 4095 | ||
3999 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); | 4096 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); |
4000 | pci_flr_wait(dev); | 4097 | pci_flr_wait(dev); |
@@ -4027,7 +4124,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe) | |||
4027 | */ | 4124 | */ |
4028 | if (!pci_wait_for_pending(dev, pos + PCI_AF_CTRL, | 4125 | if (!pci_wait_for_pending(dev, pos + PCI_AF_CTRL, |
4029 | PCI_AF_STATUS_TP << 8)) | 4126 | PCI_AF_STATUS_TP << 8)) |
4030 | dev_err(&dev->dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); | 4127 | pci_err(dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); |
4031 | 4128 | ||
4032 | pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); | 4129 | pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); |
4033 | pci_flr_wait(dev); | 4130 | pci_flr_wait(dev); |
@@ -5150,12 +5247,12 @@ void pci_add_dma_alias(struct pci_dev *dev, u8 devfn) | |||
5150 | dev->dma_alias_mask = kcalloc(BITS_TO_LONGS(U8_MAX), | 5247 | dev->dma_alias_mask = kcalloc(BITS_TO_LONGS(U8_MAX), |
5151 | sizeof(long), GFP_KERNEL); | 5248 | sizeof(long), GFP_KERNEL); |
5152 | if (!dev->dma_alias_mask) { | 5249 | if (!dev->dma_alias_mask) { |
5153 | dev_warn(&dev->dev, "Unable to allocate DMA alias mask\n"); | 5250 | pci_warn(dev, "Unable to allocate DMA alias mask\n"); |
5154 | return; | 5251 | return; |
5155 | } | 5252 | } |
5156 | 5253 | ||
5157 | set_bit(devfn, dev->dma_alias_mask); | 5254 | set_bit(devfn, dev->dma_alias_mask); |
5158 | dev_info(&dev->dev, "Enabling fixed DMA alias to %02x.%d\n", | 5255 | pci_info(dev, "Enabling fixed DMA alias to %02x.%d\n", |
5159 | PCI_SLOT(devfn), PCI_FUNC(devfn)); | 5256 | PCI_SLOT(devfn), PCI_FUNC(devfn)); |
5160 | } | 5257 | } |
5161 | 5258 | ||
@@ -5304,7 +5401,7 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar, | |||
5304 | return; | 5401 | return; |
5305 | 5402 | ||
5306 | if (r->flags & IORESOURCE_PCI_FIXED) { | 5403 | if (r->flags & IORESOURCE_PCI_FIXED) { |
5307 | dev_info(&dev->dev, "BAR%d %pR: ignoring requested alignment %#llx\n", | 5404 | pci_info(dev, "BAR%d %pR: ignoring requested alignment %#llx\n", |
5308 | bar, r, (unsigned long long)align); | 5405 | bar, r, (unsigned long long)align); |
5309 | return; | 5406 | return; |
5310 | } | 5407 | } |
@@ -5341,7 +5438,7 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar, | |||
5341 | * devices and we use the second. | 5438 | * devices and we use the second. |
5342 | */ | 5439 | */ |
5343 | 5440 | ||
5344 | dev_info(&dev->dev, "BAR%d %pR: requesting alignment to %#llx\n", | 5441 | pci_info(dev, "BAR%d %pR: requesting alignment to %#llx\n", |
5345 | bar, r, (unsigned long long)align); | 5442 | bar, r, (unsigned long long)align); |
5346 | 5443 | ||
5347 | if (resize) { | 5444 | if (resize) { |
@@ -5387,13 +5484,11 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) | |||
5387 | 5484 | ||
5388 | if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && | 5485 | if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && |
5389 | (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) { | 5486 | (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) { |
5390 | dev_warn(&dev->dev, | 5487 | pci_warn(dev, "Can't reassign resources to host bridge\n"); |
5391 | "Can't reassign resources to host bridge.\n"); | ||
5392 | return; | 5488 | return; |
5393 | } | 5489 | } |
5394 | 5490 | ||
5395 | dev_info(&dev->dev, | 5491 | pci_info(dev, "Disabling memory decoding and releasing memory resources\n"); |
5396 | "Disabling memory decoding and releasing memory resources.\n"); | ||
5397 | pci_read_config_word(dev, PCI_COMMAND, &command); | 5492 | pci_read_config_word(dev, PCI_COMMAND, &command); |
5398 | command &= ~PCI_COMMAND_MEMORY; | 5493 | command &= ~PCI_COMMAND_MEMORY; |
5399 | pci_write_config_word(dev, PCI_COMMAND, command); | 5494 | pci_write_config_word(dev, PCI_COMMAND, command); |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f6b58b32a67c..fcd81911b127 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -38,21 +38,21 @@ int pci_probe_reset_function(struct pci_dev *dev); | |||
38 | * struct pci_platform_pm_ops - Firmware PM callbacks | 38 | * struct pci_platform_pm_ops - Firmware PM callbacks |
39 | * | 39 | * |
40 | * @is_manageable: returns 'true' if given device is power manageable by the | 40 | * @is_manageable: returns 'true' if given device is power manageable by the |
41 | * platform firmware | 41 | * platform firmware |
42 | * | 42 | * |
43 | * @set_state: invokes the platform firmware to set the device's power state | 43 | * @set_state: invokes the platform firmware to set the device's power state |
44 | * | 44 | * |
45 | * @get_state: queries the platform firmware for a device's current power state | 45 | * @get_state: queries the platform firmware for a device's current power state |
46 | * | 46 | * |
47 | * @choose_state: returns PCI power state of given device preferred by the | 47 | * @choose_state: returns PCI power state of given device preferred by the |
48 | * platform; to be used during system-wide transitions from a | 48 | * platform; to be used during system-wide transitions from a |
49 | * sleeping state to the working state and vice versa | 49 | * sleeping state to the working state and vice versa |
50 | * | 50 | * |
51 | * @set_wakeup: enables/disables wakeup capability for the device | 51 | * @set_wakeup: enables/disables wakeup capability for the device |
52 | * | 52 | * |
53 | * @need_resume: returns 'true' if the given device (which is currently | 53 | * @need_resume: returns 'true' if the given device (which is currently |
54 | * suspended) needs to be resumed to be configured for system | 54 | * suspended) needs to be resumed to be configured for system |
55 | * wakeup. | 55 | * wakeup. |
56 | * | 56 | * |
57 | * If given platform is generally capable of power managing PCI devices, all of | 57 | * If given platform is generally capable of power managing PCI devices, all of |
58 | * these callbacks are mandatory. | 58 | * these callbacks are mandatory. |
@@ -112,7 +112,7 @@ struct pci_vpd_ops { | |||
112 | 112 | ||
113 | struct pci_vpd { | 113 | struct pci_vpd { |
114 | const struct pci_vpd_ops *ops; | 114 | const struct pci_vpd_ops *ops; |
115 | struct bin_attribute *attr; /* descriptor for sysfs VPD entry */ | 115 | struct bin_attribute *attr; /* Descriptor for sysfs VPD entry */ |
116 | struct mutex lock; | 116 | struct mutex lock; |
117 | unsigned int len; | 117 | unsigned int len; |
118 | u16 flag; | 118 | u16 flag; |
@@ -199,7 +199,7 @@ extern const struct attribute_group *pci_bus_groups[]; | |||
199 | 199 | ||
200 | /** | 200 | /** |
201 | * pci_match_one_device - Tell if a PCI device structure has a matching | 201 | * pci_match_one_device - Tell if a PCI device structure has a matching |
202 | * PCI device id structure | 202 | * PCI device id structure |
203 | * @id: single PCI device id structure to match | 203 | * @id: single PCI device id structure to match |
204 | * @dev: the PCI device structure to match against | 204 | * @dev: the PCI device structure to match against |
205 | * | 205 | * |
@@ -231,7 +231,7 @@ struct pci_slot_attribute { | |||
231 | 231 | ||
232 | enum pci_bar_type { | 232 | enum pci_bar_type { |
233 | pci_bar_unknown, /* Standard PCI BAR probe */ | 233 | pci_bar_unknown, /* Standard PCI BAR probe */ |
234 | pci_bar_io, /* An io port BAR */ | 234 | pci_bar_io, /* An I/O port BAR */ |
235 | pci_bar_mem32, /* A 32-bit memory BAR */ | 235 | pci_bar_mem32, /* A 32-bit memory BAR */ |
236 | pci_bar_mem64, /* A 64-bit memory BAR */ | 236 | pci_bar_mem64, /* A 64-bit memory BAR */ |
237 | }; | 237 | }; |
@@ -255,24 +255,24 @@ void pci_disable_bridge_window(struct pci_dev *dev); | |||
255 | 255 | ||
256 | /* Single Root I/O Virtualization */ | 256 | /* Single Root I/O Virtualization */ |
257 | struct pci_sriov { | 257 | struct pci_sriov { |
258 | int pos; /* capability position */ | 258 | int pos; /* Capability position */ |
259 | int nres; /* number of resources */ | 259 | int nres; /* Number of resources */ |
260 | u32 cap; /* SR-IOV Capabilities */ | 260 | u32 cap; /* SR-IOV Capabilities */ |
261 | u16 ctrl; /* SR-IOV Control */ | 261 | u16 ctrl; /* SR-IOV Control */ |
262 | u16 total_VFs; /* total VFs associated with the PF */ | 262 | u16 total_VFs; /* Total VFs associated with the PF */ |
263 | u16 initial_VFs; /* initial VFs associated with the PF */ | 263 | u16 initial_VFs; /* Initial VFs associated with the PF */ |
264 | u16 num_VFs; /* number of VFs available */ | 264 | u16 num_VFs; /* Number of VFs available */ |
265 | u16 offset; /* first VF Routing ID offset */ | 265 | u16 offset; /* First VF Routing ID offset */ |
266 | u16 stride; /* following VF stride */ | 266 | u16 stride; /* Following VF stride */ |
267 | u16 vf_device; /* VF device ID */ | 267 | u16 vf_device; /* VF device ID */ |
268 | u32 pgsz; /* page size for BAR alignment */ | 268 | u32 pgsz; /* Page size for BAR alignment */ |
269 | u8 link; /* Function Dependency Link */ | 269 | u8 link; /* Function Dependency Link */ |
270 | u8 max_VF_buses; /* max buses consumed by VFs */ | 270 | u8 max_VF_buses; /* Max buses consumed by VFs */ |
271 | u16 driver_max_VFs; /* max num VFs driver supports */ | 271 | u16 driver_max_VFs; /* Max num VFs driver supports */ |
272 | struct pci_dev *dev; /* lowest numbered PF */ | 272 | struct pci_dev *dev; /* Lowest numbered PF */ |
273 | struct pci_dev *self; /* this PF */ | 273 | struct pci_dev *self; /* This PF */ |
274 | resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ | 274 | resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ |
275 | bool drivers_autoprobe; /* auto probing of VFs by driver */ | 275 | bool drivers_autoprobe; /* Auto probing of VFs by driver */ |
276 | }; | 276 | }; |
277 | 277 | ||
278 | /* pci_dev priv_flags */ | 278 | /* pci_dev priv_flags */ |
@@ -335,13 +335,33 @@ static inline resource_size_t pci_resource_alignment(struct pci_dev *dev, | |||
335 | if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END) | 335 | if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END) |
336 | return pci_sriov_resource_alignment(dev, resno); | 336 | return pci_sriov_resource_alignment(dev, resno); |
337 | #endif | 337 | #endif |
338 | if (dev->class >> 8 == PCI_CLASS_BRIDGE_CARDBUS) | 338 | if (dev->class >> 8 == PCI_CLASS_BRIDGE_CARDBUS) |
339 | return pci_cardbus_resource_alignment(res); | 339 | return pci_cardbus_resource_alignment(res); |
340 | return resource_alignment(res); | 340 | return resource_alignment(res); |
341 | } | 341 | } |
342 | 342 | ||
343 | void pci_enable_acs(struct pci_dev *dev); | 343 | void pci_enable_acs(struct pci_dev *dev); |
344 | 344 | ||
345 | #ifdef CONFIG_PCIEASPM | ||
346 | void pcie_aspm_init_link_state(struct pci_dev *pdev); | ||
347 | void pcie_aspm_exit_link_state(struct pci_dev *pdev); | ||
348 | void pcie_aspm_pm_state_change(struct pci_dev *pdev); | ||
349 | void pcie_aspm_powersave_config_link(struct pci_dev *pdev); | ||
350 | #else | ||
351 | static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { } | ||
352 | static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { } | ||
353 | static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { } | ||
354 | static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { } | ||
355 | #endif | ||
356 | |||
357 | #ifdef CONFIG_PCIEASPM_DEBUG | ||
358 | void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev); | ||
359 | void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev); | ||
360 | #else | ||
361 | static inline void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) { } | ||
362 | static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) { } | ||
363 | #endif | ||
364 | |||
345 | #ifdef CONFIG_PCIE_PTM | 365 | #ifdef CONFIG_PCIE_PTM |
346 | void pci_ptm_init(struct pci_dev *dev); | 366 | void pci_ptm_init(struct pci_dev *dev); |
347 | #else | 367 | #else |
diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index ac53edbc9613..b12e28b3d8f9 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI Express Port Bus Configuration | 3 | # PCI Express Port Bus Configuration |
3 | # | 4 | # |
@@ -92,7 +93,7 @@ config PCIE_PME | |||
92 | 93 | ||
93 | config PCIE_DPC | 94 | config PCIE_DPC |
94 | bool "PCIe Downstream Port Containment support" | 95 | bool "PCIe Downstream Port Containment support" |
95 | depends on PCIEPORTBUS | 96 | depends on PCIEPORTBUS && PCIEAER |
96 | default n | 97 | default n |
97 | help | 98 | help |
98 | This enables PCI Express Downstream Port Containment (DPC) | 99 | This enables PCI Express Downstream Port Containment (DPC) |
diff --git a/drivers/pci/pcie/aer/Kconfig b/drivers/pci/pcie/aer/Kconfig index 7d1437b01fdd..5a64eb3d6c7a 100644 --- a/drivers/pci/pcie/aer/Kconfig +++ b/drivers/pci/pcie/aer/Kconfig | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI Express Root Port Device AER Configuration | 3 | # PCI Express Root Port Device AER Configuration |
3 | # | 4 | # |
diff --git a/drivers/pci/pcie/aer/Kconfig.debug b/drivers/pci/pcie/aer/Kconfig.debug index 9142949734f5..67e02174b65b 100644 --- a/drivers/pci/pcie/aer/Kconfig.debug +++ b/drivers/pci/pcie/aer/Kconfig.debug | |||
@@ -1,3 +1,4 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | # | 2 | # |
2 | # PCI Express Root Port Device AER Debug Configuration | 3 | # PCI Express Root Port Device AER Debug Configuration |
3 | # | 4 | # |
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c index 2b6a59266689..25e1feb962c5 100644 --- a/drivers/pci/pcie/aer/aer_inject.c +++ b/drivers/pci/pcie/aer/aer_inject.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe AER software error injection support. | 3 | * PCIe AER software error injection support. |
3 | * | 4 | * |
@@ -9,12 +10,6 @@ | |||
9 | * | 10 | * |
10 | * Copyright 2009 Intel Corporation. | 11 | * Copyright 2009 Intel Corporation. |
11 | * Huang Ying <ying.huang@intel.com> | 12 | * Huang Ying <ying.huang@intel.com> |
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; version 2 | ||
16 | * of the License. | ||
17 | * | ||
18 | */ | 13 | */ |
19 | 14 | ||
20 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -344,14 +339,14 @@ static int aer_inject(struct aer_error_inj *einj) | |||
344 | return -ENODEV; | 339 | return -ENODEV; |
345 | rpdev = pcie_find_root_port(dev); | 340 | rpdev = pcie_find_root_port(dev); |
346 | if (!rpdev) { | 341 | if (!rpdev) { |
347 | dev_err(&dev->dev, "aer_inject: Root port not found\n"); | 342 | pci_err(dev, "aer_inject: Root port not found\n"); |
348 | ret = -ENODEV; | 343 | ret = -ENODEV; |
349 | goto out_put; | 344 | goto out_put; |
350 | } | 345 | } |
351 | 346 | ||
352 | pos_cap_err = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | 347 | pos_cap_err = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
353 | if (!pos_cap_err) { | 348 | if (!pos_cap_err) { |
354 | dev_err(&dev->dev, "aer_inject: Device doesn't support AER\n"); | 349 | pci_err(dev, "aer_inject: Device doesn't support AER\n"); |
355 | ret = -EPROTONOSUPPORT; | 350 | ret = -EPROTONOSUPPORT; |
356 | goto out_put; | 351 | goto out_put; |
357 | } | 352 | } |
@@ -362,8 +357,7 @@ static int aer_inject(struct aer_error_inj *einj) | |||
362 | 357 | ||
363 | rp_pos_cap_err = pci_find_ext_capability(rpdev, PCI_EXT_CAP_ID_ERR); | 358 | rp_pos_cap_err = pci_find_ext_capability(rpdev, PCI_EXT_CAP_ID_ERR); |
364 | if (!rp_pos_cap_err) { | 359 | if (!rp_pos_cap_err) { |
365 | dev_err(&rpdev->dev, | 360 | pci_err(rpdev, "aer_inject: Root port doesn't support AER\n"); |
366 | "aer_inject: Root port doesn't support AER\n"); | ||
367 | ret = -EPROTONOSUPPORT; | 361 | ret = -EPROTONOSUPPORT; |
368 | goto out_put; | 362 | goto out_put; |
369 | } | 363 | } |
@@ -411,16 +405,14 @@ static int aer_inject(struct aer_error_inj *einj) | |||
411 | if (!aer_mask_override && einj->cor_status && | 405 | if (!aer_mask_override && einj->cor_status && |
412 | !(einj->cor_status & ~cor_mask)) { | 406 | !(einj->cor_status & ~cor_mask)) { |
413 | ret = -EINVAL; | 407 | ret = -EINVAL; |
414 | dev_warn(&dev->dev, | 408 | pci_warn(dev, "aer_inject: The correctable error(s) is masked by device\n"); |
415 | "aer_inject: The correctable error(s) is masked by device\n"); | ||
416 | spin_unlock_irqrestore(&inject_lock, flags); | 409 | spin_unlock_irqrestore(&inject_lock, flags); |
417 | goto out_put; | 410 | goto out_put; |
418 | } | 411 | } |
419 | if (!aer_mask_override && einj->uncor_status && | 412 | if (!aer_mask_override && einj->uncor_status && |
420 | !(einj->uncor_status & ~uncor_mask)) { | 413 | !(einj->uncor_status & ~uncor_mask)) { |
421 | ret = -EINVAL; | 414 | ret = -EINVAL; |
422 | dev_warn(&dev->dev, | 415 | pci_warn(dev, "aer_inject: The uncorrectable error(s) is masked by device\n"); |
423 | "aer_inject: The uncorrectable error(s) is masked by device\n"); | ||
424 | spin_unlock_irqrestore(&inject_lock, flags); | 416 | spin_unlock_irqrestore(&inject_lock, flags); |
425 | goto out_put; | 417 | goto out_put; |
426 | } | 418 | } |
@@ -483,7 +475,7 @@ static int aer_inject(struct aer_error_inj *einj) | |||
483 | einj->cor_status, einj->uncor_status, pci_name(dev)); | 475 | einj->cor_status, einj->uncor_status, pci_name(dev)); |
484 | aer_irq(-1, edev); | 476 | aer_irq(-1, edev); |
485 | } else { | 477 | } else { |
486 | dev_err(&rpdev->dev, "aer_inject: AER device not found\n"); | 478 | pci_err(rpdev, "aer_inject: AER device not found\n"); |
487 | ret = -ENODEV; | 479 | ret = -ENODEV; |
488 | } | 480 | } |
489 | out_put: | 481 | out_put: |
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 6ff5f5b4f5e6..da8331f5684d 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -1,10 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/pcie/aer/aerdrv.c | 3 | * drivers/pci/pcie/aer/aerdrv.c |
3 | * | 4 | * |
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * This file implements the AER root port service driver. The driver will | 5 | * This file implements the AER root port service driver. The driver will |
9 | * register an irq handler. When root port triggers an AER interrupt, the irq | 6 | * register an irq handler. When root port triggers an AER interrupt, the irq |
10 | * handler will collect root port status and schedule a work. | 7 | * handler will collect root port status and schedule a work. |
@@ -326,7 +323,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) | |||
326 | pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); | 323 | pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); |
327 | 324 | ||
328 | pci_reset_bridge_secondary_bus(dev); | 325 | pci_reset_bridge_secondary_bus(dev); |
329 | dev_printk(KERN_DEBUG, &dev->dev, "Root Port link has been reset\n"); | 326 | pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); |
330 | 327 | ||
331 | /* Clear Root Error Status */ | 328 | /* Clear Root Error Status */ |
332 | pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, ®32); | 329 | pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, ®32); |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 744805232155..a4bfea52e7d4 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -1,10 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/pcie/aer/aerdrv_core.c | 3 | * drivers/pci/pcie/aer/aerdrv_core.c |
3 | * | 4 | * |
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * This file implements the core part of PCIe AER. When a PCIe | 5 | * This file implements the core part of PCIe AER. When a PCIe |
9 | * error is delivered, an error message will be collected and printed to | 6 | * error is delivered, an error message will be collected and printed to |
10 | * console, then, an error recovery procedure will be executed by following | 7 | * console, then, an error recovery procedure will be executed by following |
@@ -226,9 +223,8 @@ static bool find_source_device(struct pci_dev *parent, | |||
226 | pci_walk_bus(parent->subordinate, find_device_iter, e_info); | 223 | pci_walk_bus(parent->subordinate, find_device_iter, e_info); |
227 | 224 | ||
228 | if (!e_info->error_dev_num) { | 225 | if (!e_info->error_dev_num) { |
229 | dev_printk(KERN_DEBUG, &parent->dev, | 226 | pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n", |
230 | "can't find device of ID%04x\n", | 227 | e_info->id); |
231 | e_info->id); | ||
232 | return false; | 228 | return false; |
233 | } | 229 | } |
234 | return true; | 230 | return true; |
@@ -256,7 +252,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
256 | * of a driver for this device is unaware of | 252 | * of a driver for this device is unaware of |
257 | * its hw state. | 253 | * its hw state. |
258 | */ | 254 | */ |
259 | dev_printk(KERN_DEBUG, &dev->dev, "device has %s\n", | 255 | pci_printk(KERN_DEBUG, dev, "device has %s\n", |
260 | dev->driver ? | 256 | dev->driver ? |
261 | "no AER-aware driver" : "no driver"); | 257 | "no AER-aware driver" : "no driver"); |
262 | } | 258 | } |
@@ -278,6 +274,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
278 | } else { | 274 | } else { |
279 | err_handler = dev->driver->err_handler; | 275 | err_handler = dev->driver->err_handler; |
280 | vote = err_handler->error_detected(dev, result_data->state); | 276 | vote = err_handler->error_detected(dev, result_data->state); |
277 | pci_uevent_ers(dev, PCI_ERS_RESULT_NONE); | ||
281 | } | 278 | } |
282 | 279 | ||
283 | result_data->result = merge_result(result_data->result, vote); | 280 | result_data->result = merge_result(result_data->result, vote); |
@@ -341,6 +338,7 @@ static int report_resume(struct pci_dev *dev, void *data) | |||
341 | 338 | ||
342 | err_handler = dev->driver->err_handler; | 339 | err_handler = dev->driver->err_handler; |
343 | err_handler->resume(dev); | 340 | err_handler->resume(dev); |
341 | pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED); | ||
344 | out: | 342 | out: |
345 | device_unlock(&dev->dev); | 343 | device_unlock(&dev->dev); |
346 | return 0; | 344 | return 0; |
@@ -364,7 +362,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, | |||
364 | { | 362 | { |
365 | struct aer_broadcast_data result_data; | 363 | struct aer_broadcast_data result_data; |
366 | 364 | ||
367 | dev_printk(KERN_DEBUG, &dev->dev, "broadcast %s message\n", error_mesg); | 365 | pci_printk(KERN_DEBUG, dev, "broadcast %s message\n", error_mesg); |
368 | result_data.state = state; | 366 | result_data.state = state; |
369 | if (cb == report_error_detected) | 367 | if (cb == report_error_detected) |
370 | result_data.result = PCI_ERS_RESULT_CAN_RECOVER; | 368 | result_data.result = PCI_ERS_RESULT_CAN_RECOVER; |
@@ -413,7 +411,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, | |||
413 | static pci_ers_result_t default_reset_link(struct pci_dev *dev) | 411 | static pci_ers_result_t default_reset_link(struct pci_dev *dev) |
414 | { | 412 | { |
415 | pci_reset_bridge_secondary_bus(dev); | 413 | pci_reset_bridge_secondary_bus(dev); |
416 | dev_printk(KERN_DEBUG, &dev->dev, "downstream link has been reset\n"); | 414 | pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); |
417 | return PCI_ERS_RESULT_RECOVERED; | 415 | return PCI_ERS_RESULT_RECOVERED; |
418 | } | 416 | } |
419 | 417 | ||
@@ -465,15 +463,13 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) | |||
465 | } else if (udev->has_secondary_link) { | 463 | } else if (udev->has_secondary_link) { |
466 | status = default_reset_link(udev); | 464 | status = default_reset_link(udev); |
467 | } else { | 465 | } else { |
468 | dev_printk(KERN_DEBUG, &dev->dev, | 466 | pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", |
469 | "no link-reset support at upstream device %s\n", | ||
470 | pci_name(udev)); | 467 | pci_name(udev)); |
471 | return PCI_ERS_RESULT_DISCONNECT; | 468 | return PCI_ERS_RESULT_DISCONNECT; |
472 | } | 469 | } |
473 | 470 | ||
474 | if (status != PCI_ERS_RESULT_RECOVERED) { | 471 | if (status != PCI_ERS_RESULT_RECOVERED) { |
475 | dev_printk(KERN_DEBUG, &dev->dev, | 472 | pci_printk(KERN_DEBUG, dev, "link reset at upstream device %s failed\n", |
476 | "link reset at upstream device %s failed\n", | ||
477 | pci_name(udev)); | 473 | pci_name(udev)); |
478 | return PCI_ERS_RESULT_DISCONNECT; | 474 | return PCI_ERS_RESULT_DISCONNECT; |
479 | } | 475 | } |
@@ -537,12 +533,13 @@ static void do_recovery(struct pci_dev *dev, int severity) | |||
537 | "resume", | 533 | "resume", |
538 | report_resume); | 534 | report_resume); |
539 | 535 | ||
540 | dev_info(&dev->dev, "AER: Device recovery successful\n"); | 536 | pci_info(dev, "AER: Device recovery successful\n"); |
541 | return; | 537 | return; |
542 | 538 | ||
543 | failed: | 539 | failed: |
540 | pci_uevent_ers(dev, PCI_ERS_RESULT_DISCONNECT); | ||
544 | /* TODO: Should kernel panic here? */ | 541 | /* TODO: Should kernel panic here? */ |
545 | dev_info(&dev->dev, "AER: Device recovery failed\n"); | 542 | pci_info(dev, "AER: Device recovery failed\n"); |
546 | } | 543 | } |
547 | 544 | ||
548 | /** | 545 | /** |
@@ -633,7 +630,8 @@ static void aer_recover_work_func(struct work_struct *work) | |||
633 | continue; | 630 | continue; |
634 | } | 631 | } |
635 | cper_print_aer(pdev, entry.severity, entry.regs); | 632 | cper_print_aer(pdev, entry.severity, entry.regs); |
636 | do_recovery(pdev, entry.severity); | 633 | if (entry.severity != AER_CORRECTABLE) |
634 | do_recovery(pdev, entry.severity); | ||
637 | pci_dev_put(pdev); | 635 | pci_dev_put(pdev); |
638 | } | 636 | } |
639 | } | 637 | } |
@@ -660,7 +658,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) | |||
660 | 658 | ||
661 | /* The device might not support AER */ | 659 | /* The device might not support AER */ |
662 | if (!pos) | 660 | if (!pos) |
663 | return 1; | 661 | return 0; |
664 | 662 | ||
665 | if (info->severity == AER_CORRECTABLE) { | 663 | if (info->severity == AER_CORRECTABLE) { |
666 | pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, | 664 | pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, |
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c index 54c4b691e51f..6a352e638699 100644 --- a/drivers/pci/pcie/aer/aerdrv_errprint.c +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c | |||
@@ -1,10 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/pcie/aer/aerdrv_errprint.c | 3 | * drivers/pci/pcie/aer/aerdrv_errprint.c |
3 | * | 4 | * |
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Format error messages and print them to console. | 5 | * Format error messages and print them to console. |
9 | * | 6 | * |
10 | * Copyright (C) 2006 Intel Corp. | 7 | * Copyright (C) 2006 Intel Corp. |
@@ -132,7 +129,7 @@ static const char *aer_agent_string[] = { | |||
132 | static void __print_tlp_header(struct pci_dev *dev, | 129 | static void __print_tlp_header(struct pci_dev *dev, |
133 | struct aer_header_log_regs *t) | 130 | struct aer_header_log_regs *t) |
134 | { | 131 | { |
135 | dev_err(&dev->dev, " TLP Header: %08x %08x %08x %08x\n", | 132 | pci_err(dev, " TLP Header: %08x %08x %08x %08x\n", |
136 | t->dw0, t->dw1, t->dw2, t->dw3); | 133 | t->dw0, t->dw1, t->dw2, t->dw3); |
137 | } | 134 | } |
138 | 135 | ||
@@ -155,10 +152,10 @@ static void __aer_print_error(struct pci_dev *dev, | |||
155 | aer_uncorrectable_error_string[i] : NULL; | 152 | aer_uncorrectable_error_string[i] : NULL; |
156 | 153 | ||
157 | if (errmsg) | 154 | if (errmsg) |
158 | dev_err(&dev->dev, " [%2d] %-22s%s\n", i, errmsg, | 155 | pci_err(dev, " [%2d] %-22s%s\n", i, errmsg, |
159 | info->first_error == i ? " (First)" : ""); | 156 | info->first_error == i ? " (First)" : ""); |
160 | else | 157 | else |
161 | dev_err(&dev->dev, " [%2d] Unknown Error Bit%s\n", | 158 | pci_err(dev, " [%2d] Unknown Error Bit%s\n", |
162 | i, info->first_error == i ? " (First)" : ""); | 159 | i, info->first_error == i ? " (First)" : ""); |
163 | } | 160 | } |
164 | } | 161 | } |
@@ -169,7 +166,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) | |||
169 | int id = ((dev->bus->number << 8) | dev->devfn); | 166 | int id = ((dev->bus->number << 8) | dev->devfn); |
170 | 167 | ||
171 | if (!info->status) { | 168 | if (!info->status) { |
172 | dev_err(&dev->dev, "PCIe Bus Error: severity=%s, type=Unaccessible, id=%04x(Unregistered Agent ID)\n", | 169 | pci_err(dev, "PCIe Bus Error: severity=%s, type=Unaccessible, id=%04x(Unregistered Agent ID)\n", |
173 | aer_error_severity_string[info->severity], id); | 170 | aer_error_severity_string[info->severity], id); |
174 | goto out; | 171 | goto out; |
175 | } | 172 | } |
@@ -177,11 +174,11 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) | |||
177 | layer = AER_GET_LAYER_ERROR(info->severity, info->status); | 174 | layer = AER_GET_LAYER_ERROR(info->severity, info->status); |
178 | agent = AER_GET_AGENT(info->severity, info->status); | 175 | agent = AER_GET_AGENT(info->severity, info->status); |
179 | 176 | ||
180 | dev_err(&dev->dev, "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", | 177 | pci_err(dev, "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", |
181 | aer_error_severity_string[info->severity], | 178 | aer_error_severity_string[info->severity], |
182 | aer_error_layer[layer], id, aer_agent_string[agent]); | 179 | aer_error_layer[layer], id, aer_agent_string[agent]); |
183 | 180 | ||
184 | dev_err(&dev->dev, " device [%04x:%04x] error status/mask=%08x/%08x\n", | 181 | pci_err(dev, " device [%04x:%04x] error status/mask=%08x/%08x\n", |
185 | dev->vendor, dev->device, | 182 | dev->vendor, dev->device, |
186 | info->status, info->mask); | 183 | info->status, info->mask); |
187 | 184 | ||
@@ -192,7 +189,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) | |||
192 | 189 | ||
193 | out: | 190 | out: |
194 | if (info->id && info->error_dev_num > 1 && info->id == id) | 191 | if (info->id && info->error_dev_num > 1 && info->id == id) |
195 | dev_err(&dev->dev, " Error of this Agent(%04x) is reported first\n", id); | 192 | pci_err(dev, " Error of this Agent(%04x) is reported first\n", id); |
196 | 193 | ||
197 | trace_aer_event(dev_name(&dev->dev), (info->status & ~info->mask), | 194 | trace_aer_event(dev_name(&dev->dev), (info->status & ~info->mask), |
198 | info->severity); | 195 | info->severity); |
@@ -200,7 +197,7 @@ out: | |||
200 | 197 | ||
201 | void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) | 198 | void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) |
202 | { | 199 | { |
203 | dev_info(&dev->dev, "AER: %s%s error received: id=%04x\n", | 200 | pci_info(dev, "AER: %s%s error received: id=%04x\n", |
204 | info->multi_error_valid ? "Multiple " : "", | 201 | info->multi_error_valid ? "Multiple " : "", |
205 | aer_error_severity_string[info->severity], info->id); | 202 | aer_error_severity_string[info->severity], info->id); |
206 | } | 203 | } |
@@ -242,13 +239,13 @@ void cper_print_aer(struct pci_dev *dev, int aer_severity, | |||
242 | layer = AER_GET_LAYER_ERROR(aer_severity, status); | 239 | layer = AER_GET_LAYER_ERROR(aer_severity, status); |
243 | agent = AER_GET_AGENT(aer_severity, status); | 240 | agent = AER_GET_AGENT(aer_severity, status); |
244 | 241 | ||
245 | dev_err(&dev->dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); | 242 | pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); |
246 | cper_print_bits("", status, status_strs, status_strs_size); | 243 | cper_print_bits("", status, status_strs, status_strs_size); |
247 | dev_err(&dev->dev, "aer_layer=%s, aer_agent=%s\n", | 244 | pci_err(dev, "aer_layer=%s, aer_agent=%s\n", |
248 | aer_error_layer[layer], aer_agent_string[agent]); | 245 | aer_error_layer[layer], aer_agent_string[agent]); |
249 | 246 | ||
250 | if (aer_severity != AER_CORRECTABLE) | 247 | if (aer_severity != AER_CORRECTABLE) |
251 | dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n", | 248 | pci_err(dev, "aer_uncor_severity: 0x%08x\n", |
252 | aer->uncor_severity); | 249 | aer->uncor_severity); |
253 | 250 | ||
254 | if (tlp_header_valid) | 251 | if (tlp_header_valid) |
diff --git a/drivers/pci/pcie/aer/ecrc.c b/drivers/pci/pcie/aer/ecrc.c index a2747a663bc9..26d3cac9e635 100644 --- a/drivers/pci/pcie/aer/ecrc.c +++ b/drivers/pci/pcie/aer/ecrc.c | |||
@@ -1,23 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Enables/disables PCIe ECRC checking. | 3 | * Enables/disables PCIe ECRC checking. |
3 | * | 4 | * |
4 | * (C) Copyright 2009 Hewlett-Packard Development Company, L.P. | 5 | * (C) Copyright 2009 Hewlett-Packard Development Company, L.P. |
5 | * Andrew Patterson <andrew.patterson@hp.com> | 6 | * Andrew Patterson <andrew.patterson@hp.com> |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; version 2 of the License. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
19 | * 02111-1307, USA. | ||
20 | * | ||
21 | */ | 7 | */ |
22 | 8 | ||
23 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 9783e10da3a9..57feef2ecfe7 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -43,18 +43,6 @@ | |||
43 | #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1 | \ | 43 | #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1 | \ |
44 | ASPM_STATE_L1SS) | 44 | ASPM_STATE_L1SS) |
45 | 45 | ||
46 | /* | ||
47 | * When L1 substates are enabled, the LTR L1.2 threshold is a timing parameter | ||
48 | * that decides whether L1.1 or L1.2 is entered (Refer PCIe spec for details). | ||
49 | * Not sure is there is a way to "calculate" this on the fly, but maybe we | ||
50 | * could turn it into a parameter in future. This value has been taken from | ||
51 | * the following files from Intel's coreboot (which is the only code I found | ||
52 | * to have used this): | ||
53 | * https://www.coreboot.org/pipermail/coreboot-gerrit/2015-March/021134.html | ||
54 | * https://review.coreboot.org/#/c/8832/ | ||
55 | */ | ||
56 | #define LTR_L1_2_THRESHOLD_BITS ((1 << 21) | (1 << 23) | (1 << 30)) | ||
57 | |||
58 | struct aspm_latency { | 46 | struct aspm_latency { |
59 | u32 l0s; /* L0s latency (nsec) */ | 47 | u32 l0s; /* L0s latency (nsec) */ |
60 | u32 l1; /* L1 latency (nsec) */ | 48 | u32 l1; /* L1 latency (nsec) */ |
@@ -278,7 +266,7 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) | |||
278 | return; | 266 | return; |
279 | 267 | ||
280 | /* Training failed. Restore common clock configurations */ | 268 | /* Training failed. Restore common clock configurations */ |
281 | dev_err(&parent->dev, "ASPM: Could not configure common clock\n"); | 269 | pci_err(parent, "ASPM: Could not configure common clock\n"); |
282 | list_for_each_entry(child, &linkbus->devices, bus_list) | 270 | list_for_each_entry(child, &linkbus->devices, bus_list) |
283 | pcie_capability_write_word(child, PCI_EXP_LNKCTL, | 271 | pcie_capability_write_word(child, PCI_EXP_LNKCTL, |
284 | child_reg[PCI_FUNC(child->devfn)]); | 272 | child_reg[PCI_FUNC(child->devfn)]); |
@@ -328,11 +316,36 @@ static u32 calc_l1ss_pwron(struct pci_dev *pdev, u32 scale, u32 val) | |||
328 | case 2: | 316 | case 2: |
329 | return val * 100; | 317 | return val * 100; |
330 | } | 318 | } |
331 | dev_err(&pdev->dev, "%s: Invalid T_PwrOn scale: %u\n", | 319 | pci_err(pdev, "%s: Invalid T_PwrOn scale: %u\n", __func__, scale); |
332 | __func__, scale); | ||
333 | return 0; | 320 | return 0; |
334 | } | 321 | } |
335 | 322 | ||
323 | static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) | ||
324 | { | ||
325 | u64 threshold_ns = threshold_us * 1000; | ||
326 | |||
327 | /* See PCIe r3.1, sec 7.33.3 and sec 6.18 */ | ||
328 | if (threshold_ns < 32) { | ||
329 | *scale = 0; | ||
330 | *value = threshold_ns; | ||
331 | } else if (threshold_ns < 1024) { | ||
332 | *scale = 1; | ||
333 | *value = threshold_ns >> 5; | ||
334 | } else if (threshold_ns < 32768) { | ||
335 | *scale = 2; | ||
336 | *value = threshold_ns >> 10; | ||
337 | } else if (threshold_ns < 1048576) { | ||
338 | *scale = 3; | ||
339 | *value = threshold_ns >> 15; | ||
340 | } else if (threshold_ns < 33554432) { | ||
341 | *scale = 4; | ||
342 | *value = threshold_ns >> 20; | ||
343 | } else { | ||
344 | *scale = 5; | ||
345 | *value = threshold_ns >> 25; | ||
346 | } | ||
347 | } | ||
348 | |||
336 | struct aspm_register_info { | 349 | struct aspm_register_info { |
337 | u32 support:2; | 350 | u32 support:2; |
338 | u32 enabled:2; | 351 | u32 enabled:2; |
@@ -443,6 +456,7 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link, | |||
443 | struct aspm_register_info *dwreg) | 456 | struct aspm_register_info *dwreg) |
444 | { | 457 | { |
445 | u32 val1, val2, scale1, scale2; | 458 | u32 val1, val2, scale1, scale2; |
459 | u32 t_common_mode, t_power_on, l1_2_threshold, scale, value; | ||
446 | 460 | ||
447 | link->l1ss.up_cap_ptr = upreg->l1ss_cap_ptr; | 461 | link->l1ss.up_cap_ptr = upreg->l1ss_cap_ptr; |
448 | link->l1ss.dw_cap_ptr = dwreg->l1ss_cap_ptr; | 462 | link->l1ss.dw_cap_ptr = dwreg->l1ss_cap_ptr; |
@@ -454,16 +468,7 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link, | |||
454 | /* Choose the greater of the two Port Common_Mode_Restore_Times */ | 468 | /* Choose the greater of the two Port Common_Mode_Restore_Times */ |
455 | val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; | 469 | val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; |
456 | val2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; | 470 | val2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; |
457 | if (val1 > val2) | 471 | t_common_mode = max(val1, val2); |
458 | link->l1ss.ctl1 |= val1 << 8; | ||
459 | else | ||
460 | link->l1ss.ctl1 |= val2 << 8; | ||
461 | |||
462 | /* | ||
463 | * We currently use LTR L1.2 threshold to be fixed constant picked from | ||
464 | * Intel's coreboot. | ||
465 | */ | ||
466 | link->l1ss.ctl1 |= LTR_L1_2_THRESHOLD_BITS; | ||
467 | 472 | ||
468 | /* Choose the greater of the two Port T_POWER_ON times */ | 473 | /* Choose the greater of the two Port T_POWER_ON times */ |
469 | val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_VALUE) >> 19; | 474 | val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_VALUE) >> 19; |
@@ -472,10 +477,27 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link, | |||
472 | scale2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_SCALE) >> 16; | 477 | scale2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_SCALE) >> 16; |
473 | 478 | ||
474 | if (calc_l1ss_pwron(link->pdev, scale1, val1) > | 479 | if (calc_l1ss_pwron(link->pdev, scale1, val1) > |
475 | calc_l1ss_pwron(link->downstream, scale2, val2)) | 480 | calc_l1ss_pwron(link->downstream, scale2, val2)) { |
476 | link->l1ss.ctl2 |= scale1 | (val1 << 3); | 481 | link->l1ss.ctl2 |= scale1 | (val1 << 3); |
477 | else | 482 | t_power_on = calc_l1ss_pwron(link->pdev, scale1, val1); |
483 | } else { | ||
478 | link->l1ss.ctl2 |= scale2 | (val2 << 3); | 484 | link->l1ss.ctl2 |= scale2 | (val2 << 3); |
485 | t_power_on = calc_l1ss_pwron(link->downstream, scale2, val2); | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | * Set LTR_L1.2_THRESHOLD to the time required to transition the | ||
490 | * Link from L0 to L1.2 and back to L0 so we enter L1.2 only if | ||
491 | * downstream devices report (via LTR) that they can tolerate at | ||
492 | * least that much latency. | ||
493 | * | ||
494 | * Based on PCIe r3.1, sec 5.5.3.3.1, Figures 5-16 and 5-17, and | ||
495 | * Table 5-11. T(POWER_OFF) is at most 2us and T(L1.2) is at | ||
496 | * least 4us. | ||
497 | */ | ||
498 | l1_2_threshold = 2 + 4 + t_common_mode + t_power_on; | ||
499 | encode_l12_threshold(l1_2_threshold, &scale, &value); | ||
500 | link->l1ss.ctl1 |= t_common_mode << 8 | scale << 29 | value << 16; | ||
479 | } | 501 | } |
480 | 502 | ||
481 | static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) | 503 | static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) |
@@ -786,7 +808,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
786 | */ | 808 | */ |
787 | pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); | 809 | pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); |
788 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { | 810 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { |
789 | dev_info(&child->dev, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); | 811 | pci_info(child, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); |
790 | return -EINVAL; | 812 | return -EINVAL; |
791 | } | 813 | } |
792 | } | 814 | } |
@@ -1027,7 +1049,7 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) | |||
1027 | * ignored in this situation. | 1049 | * ignored in this situation. |
1028 | */ | 1050 | */ |
1029 | if (aspm_disabled) { | 1051 | if (aspm_disabled) { |
1030 | dev_warn(&pdev->dev, "can't disable ASPM; OS doesn't have ASPM control\n"); | 1052 | pci_warn(pdev, "can't disable ASPM; OS doesn't have ASPM control\n"); |
1031 | return; | 1053 | return; |
1032 | } | 1054 | } |
1033 | 1055 | ||
diff --git a/drivers/pci/pcie/pcie-dpc.c b/drivers/pci/pcie/pcie-dpc.c index 2d976a623ddc..38e40c6c576f 100644 --- a/drivers/pci/pcie/pcie-dpc.c +++ b/drivers/pci/pcie/pcie-dpc.c | |||
@@ -1,12 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCI Express Downstream Port Containment services driver | 3 | * PCI Express Downstream Port Containment services driver |
3 | * Author: Keith Busch <keith.busch@intel.com> | 4 | * Author: Keith Busch <keith.busch@intel.com> |
4 | * | 5 | * |
5 | * Copyright (C) 2016 Intel Corp. | 6 | * Copyright (C) 2016 Intel Corp. |
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | */ | 7 | */ |
11 | 8 | ||
12 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
@@ -15,34 +12,15 @@ | |||
15 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
16 | #include <linux/pcieport_if.h> | 13 | #include <linux/pcieport_if.h> |
17 | #include "../pci.h" | 14 | #include "../pci.h" |
18 | 15 | #include "aer/aerdrv.h" | |
19 | struct rp_pio_header_log_regs { | ||
20 | u32 dw0; | ||
21 | u32 dw1; | ||
22 | u32 dw2; | ||
23 | u32 dw3; | ||
24 | }; | ||
25 | |||
26 | struct dpc_rp_pio_regs { | ||
27 | u32 status; | ||
28 | u32 mask; | ||
29 | u32 severity; | ||
30 | u32 syserror; | ||
31 | u32 exception; | ||
32 | |||
33 | struct rp_pio_header_log_regs header_log; | ||
34 | u32 impspec_log; | ||
35 | u32 tlp_prefix_log[4]; | ||
36 | u32 log_size; | ||
37 | u16 first_error; | ||
38 | }; | ||
39 | 16 | ||
40 | struct dpc_dev { | 17 | struct dpc_dev { |
41 | struct pcie_device *dev; | 18 | struct pcie_device *dev; |
42 | struct work_struct work; | 19 | struct work_struct work; |
43 | int cap_pos; | 20 | u16 cap_pos; |
44 | bool rp; | 21 | bool rp_extensions; |
45 | u32 rp_pio_status; | 22 | u32 rp_pio_status; |
23 | u8 rp_log_size; | ||
46 | }; | 24 | }; |
47 | 25 | ||
48 | static const char * const rp_pio_error_string[] = { | 26 | static const char * const rp_pio_error_string[] = { |
@@ -72,13 +50,13 @@ static int dpc_wait_rp_inactive(struct dpc_dev *dpc) | |||
72 | unsigned long timeout = jiffies + HZ; | 50 | unsigned long timeout = jiffies + HZ; |
73 | struct pci_dev *pdev = dpc->dev->port; | 51 | struct pci_dev *pdev = dpc->dev->port; |
74 | struct device *dev = &dpc->dev->device; | 52 | struct device *dev = &dpc->dev->device; |
75 | u16 status; | 53 | u16 cap = dpc->cap_pos, status; |
76 | 54 | ||
77 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); | 55 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); |
78 | while (status & PCI_EXP_DPC_RP_BUSY && | 56 | while (status & PCI_EXP_DPC_RP_BUSY && |
79 | !time_after(jiffies, timeout)) { | 57 | !time_after(jiffies, timeout)) { |
80 | msleep(10); | 58 | msleep(10); |
81 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); | 59 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); |
82 | } | 60 | } |
83 | if (status & PCI_EXP_DPC_RP_BUSY) { | 61 | if (status & PCI_EXP_DPC_RP_BUSY) { |
84 | dev_warn(dev, "DPC root port still busy\n"); | 62 | dev_warn(dev, "DPC root port still busy\n"); |
@@ -104,11 +82,12 @@ static void dpc_wait_link_inactive(struct dpc_dev *dpc) | |||
104 | dev_warn(dev, "Link state not disabled for DPC event\n"); | 82 | dev_warn(dev, "Link state not disabled for DPC event\n"); |
105 | } | 83 | } |
106 | 84 | ||
107 | static void interrupt_event_handler(struct work_struct *work) | 85 | static void dpc_work(struct work_struct *work) |
108 | { | 86 | { |
109 | struct dpc_dev *dpc = container_of(work, struct dpc_dev, work); | 87 | struct dpc_dev *dpc = container_of(work, struct dpc_dev, work); |
110 | struct pci_dev *dev, *temp, *pdev = dpc->dev->port; | 88 | struct pci_dev *dev, *temp, *pdev = dpc->dev->port; |
111 | struct pci_bus *parent = pdev->subordinate; | 89 | struct pci_bus *parent = pdev->subordinate; |
90 | u16 cap = dpc->cap_pos, ctl; | ||
112 | 91 | ||
113 | pci_lock_rescan_remove(); | 92 | pci_lock_rescan_remove(); |
114 | list_for_each_entry_safe_reverse(dev, temp, &parent->devices, | 93 | list_for_each_entry_safe_reverse(dev, temp, &parent->devices, |
@@ -124,159 +103,127 @@ static void interrupt_event_handler(struct work_struct *work) | |||
124 | pci_unlock_rescan_remove(); | 103 | pci_unlock_rescan_remove(); |
125 | 104 | ||
126 | dpc_wait_link_inactive(dpc); | 105 | dpc_wait_link_inactive(dpc); |
127 | if (dpc->rp && dpc_wait_rp_inactive(dpc)) | 106 | if (dpc->rp_extensions && dpc_wait_rp_inactive(dpc)) |
128 | return; | 107 | return; |
129 | if (dpc->rp && dpc->rp_pio_status) { | 108 | if (dpc->rp_extensions && dpc->rp_pio_status) { |
130 | pci_write_config_dword(pdev, | 109 | pci_write_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, |
131 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_STATUS, | 110 | dpc->rp_pio_status); |
132 | dpc->rp_pio_status); | ||
133 | dpc->rp_pio_status = 0; | 111 | dpc->rp_pio_status = 0; |
134 | } | 112 | } |
135 | 113 | ||
136 | pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, | 114 | pci_write_config_word(pdev, cap + PCI_EXP_DPC_STATUS, |
137 | PCI_EXP_DPC_STATUS_TRIGGER | PCI_EXP_DPC_STATUS_INTERRUPT); | 115 | PCI_EXP_DPC_STATUS_TRIGGER | PCI_EXP_DPC_STATUS_INTERRUPT); |
138 | } | ||
139 | 116 | ||
140 | static void dpc_rp_pio_print_tlp_header(struct device *dev, | 117 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_CTL, &ctl); |
141 | struct rp_pio_header_log_regs *t) | 118 | pci_write_config_word(pdev, cap + PCI_EXP_DPC_CTL, |
142 | { | 119 | ctl | PCI_EXP_DPC_CTL_INT_EN); |
143 | dev_err(dev, "TLP Header: %#010x %#010x %#010x %#010x\n", | ||
144 | t->dw0, t->dw1, t->dw2, t->dw3); | ||
145 | } | 120 | } |
146 | 121 | ||
147 | static void dpc_rp_pio_print_error(struct dpc_dev *dpc, | 122 | static void dpc_process_rp_pio_error(struct dpc_dev *dpc) |
148 | struct dpc_rp_pio_regs *rp_pio) | ||
149 | { | 123 | { |
150 | struct device *dev = &dpc->dev->device; | 124 | struct device *dev = &dpc->dev->device; |
125 | struct pci_dev *pdev = dpc->dev->port; | ||
126 | u16 cap = dpc->cap_pos, dpc_status, first_error; | ||
127 | u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix; | ||
151 | int i; | 128 | int i; |
152 | u32 status; | ||
153 | 129 | ||
130 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, &status); | ||
131 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_MASK, &mask); | ||
154 | dev_err(dev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n", | 132 | dev_err(dev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n", |
155 | rp_pio->status, rp_pio->mask); | 133 | status, mask); |
156 | 134 | ||
135 | dpc->rp_pio_status = status; | ||
136 | |||
137 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SEVERITY, &sev); | ||
138 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SYSERROR, &syserr); | ||
139 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_EXCEPTION, &exc); | ||
157 | dev_err(dev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n", | 140 | dev_err(dev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n", |
158 | rp_pio->severity, rp_pio->syserror, rp_pio->exception); | 141 | sev, syserr, exc); |
159 | 142 | ||
160 | status = (rp_pio->status & ~rp_pio->mask); | 143 | /* Get First Error Pointer */ |
144 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &dpc_status); | ||
145 | first_error = (dpc_status & 0x1f00) >> 8; | ||
161 | 146 | ||
147 | status &= ~mask; | ||
162 | for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { | 148 | for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { |
163 | if (!(status & (1 << i))) | 149 | if (status & (1 << i)) |
164 | continue; | 150 | dev_err(dev, "[%2d] %s%s\n", i, rp_pio_error_string[i], |
165 | 151 | first_error == i ? " (First)" : ""); | |
166 | dev_err(dev, "[%2d] %s%s\n", i, rp_pio_error_string[i], | ||
167 | rp_pio->first_error == i ? " (First)" : ""); | ||
168 | } | 152 | } |
169 | 153 | ||
170 | dpc_rp_pio_print_tlp_header(dev, &rp_pio->header_log); | 154 | if (dpc->rp_log_size < 4) |
171 | if (rp_pio->log_size == 4) | ||
172 | return; | 155 | return; |
173 | dev_err(dev, "RP PIO ImpSpec Log %#010x\n", rp_pio->impspec_log); | 156 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, |
157 | &dw0); | ||
158 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 4, | ||
159 | &dw1); | ||
160 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 8, | ||
161 | &dw2); | ||
162 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12, | ||
163 | &dw3); | ||
164 | dev_err(dev, "TLP Header: %#010x %#010x %#010x %#010x\n", | ||
165 | dw0, dw1, dw2, dw3); | ||
166 | |||
167 | if (dpc->rp_log_size < 5) | ||
168 | return; | ||
169 | pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, &log); | ||
170 | dev_err(dev, "RP PIO ImpSpec Log %#010x\n", log); | ||
174 | 171 | ||
175 | for (i = 0; i < rp_pio->log_size - 5; i++) | 172 | for (i = 0; i < dpc->rp_log_size - 5; i++) { |
176 | dev_err(dev, "TLP Prefix Header: dw%d, %#010x\n", i, | 173 | pci_read_config_dword(pdev, |
177 | rp_pio->tlp_prefix_log[i]); | 174 | cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, &prefix); |
175 | dev_err(dev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix); | ||
176 | } | ||
178 | } | 177 | } |
179 | 178 | ||
180 | static void dpc_rp_pio_get_info(struct dpc_dev *dpc, | 179 | static irqreturn_t dpc_irq(int irq, void *context) |
181 | struct dpc_rp_pio_regs *rp_pio) | ||
182 | { | 180 | { |
181 | struct dpc_dev *dpc = (struct dpc_dev *)context; | ||
183 | struct pci_dev *pdev = dpc->dev->port; | 182 | struct pci_dev *pdev = dpc->dev->port; |
184 | struct device *dev = &dpc->dev->device; | 183 | struct device *dev = &dpc->dev->device; |
185 | int i; | 184 | u16 cap = dpc->cap_pos, ctl, status, source, reason, ext_reason; |
186 | u16 cap; | ||
187 | u16 status; | ||
188 | |||
189 | pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_STATUS, | ||
190 | &rp_pio->status); | ||
191 | pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_MASK, | ||
192 | &rp_pio->mask); | ||
193 | |||
194 | pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_SEVERITY, | ||
195 | &rp_pio->severity); | ||
196 | pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_SYSERROR, | ||
197 | &rp_pio->syserror); | ||
198 | pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_EXCEPTION, | ||
199 | &rp_pio->exception); | ||
200 | |||
201 | /* Get First Error Pointer */ | ||
202 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); | ||
203 | rp_pio->first_error = (status & 0x1f00) >> 8; | ||
204 | 185 | ||
205 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CAP, &cap); | 186 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_CTL, &ctl); |
206 | rp_pio->log_size = (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8; | ||
207 | if (rp_pio->log_size < 4 || rp_pio->log_size > 9) { | ||
208 | dev_err(dev, "RP PIO log size %u is invalid\n", | ||
209 | rp_pio->log_size); | ||
210 | return; | ||
211 | } | ||
212 | 187 | ||
213 | pci_read_config_dword(pdev, | 188 | if (!(ctl & PCI_EXP_DPC_CTL_INT_EN) || ctl == (u16)(~0)) |
214 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG, | 189 | return IRQ_NONE; |
215 | &rp_pio->header_log.dw0); | ||
216 | pci_read_config_dword(pdev, | ||
217 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 4, | ||
218 | &rp_pio->header_log.dw1); | ||
219 | pci_read_config_dword(pdev, | ||
220 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 8, | ||
221 | &rp_pio->header_log.dw2); | ||
222 | pci_read_config_dword(pdev, | ||
223 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12, | ||
224 | &rp_pio->header_log.dw3); | ||
225 | if (rp_pio->log_size == 4) | ||
226 | return; | ||
227 | 190 | ||
228 | pci_read_config_dword(pdev, | 191 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); |
229 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, | ||
230 | &rp_pio->impspec_log); | ||
231 | for (i = 0; i < rp_pio->log_size - 5; i++) | ||
232 | pci_read_config_dword(pdev, | ||
233 | dpc->cap_pos + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, | ||
234 | &rp_pio->tlp_prefix_log[i]); | ||
235 | } | ||
236 | 192 | ||
237 | static void dpc_process_rp_pio_error(struct dpc_dev *dpc) | 193 | if (!(status & PCI_EXP_DPC_STATUS_INTERRUPT)) |
238 | { | 194 | return IRQ_NONE; |
239 | struct dpc_rp_pio_regs rp_pio_regs; | ||
240 | 195 | ||
241 | dpc_rp_pio_get_info(dpc, &rp_pio_regs); | 196 | if (!(status & PCI_EXP_DPC_STATUS_TRIGGER)) { |
242 | dpc_rp_pio_print_error(dpc, &rp_pio_regs); | 197 | pci_write_config_word(pdev, cap + PCI_EXP_DPC_STATUS, |
198 | PCI_EXP_DPC_STATUS_INTERRUPT); | ||
199 | return IRQ_HANDLED; | ||
200 | } | ||
243 | 201 | ||
244 | dpc->rp_pio_status = rp_pio_regs.status; | 202 | pci_write_config_word(pdev, cap + PCI_EXP_DPC_CTL, |
245 | } | 203 | ctl & ~PCI_EXP_DPC_CTL_INT_EN); |
246 | 204 | ||
247 | static irqreturn_t dpc_irq(int irq, void *context) | 205 | pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, |
248 | { | ||
249 | struct dpc_dev *dpc = (struct dpc_dev *)context; | ||
250 | struct pci_dev *pdev = dpc->dev->port; | ||
251 | struct device *dev = &dpc->dev->device; | ||
252 | u16 status, source; | ||
253 | |||
254 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); | ||
255 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_SOURCE_ID, | ||
256 | &source); | 206 | &source); |
257 | if (!status || status == (u16)(~0)) | ||
258 | return IRQ_NONE; | ||
259 | 207 | ||
260 | dev_info(dev, "DPC containment event, status:%#06x source:%#06x\n", | 208 | dev_info(dev, "DPC containment event, status:%#06x source:%#06x\n", |
261 | status, source); | 209 | status, source); |
262 | 210 | ||
263 | if (status & PCI_EXP_DPC_STATUS_TRIGGER) { | 211 | reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1; |
264 | u16 reason = (status >> 1) & 0x3; | 212 | ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5; |
265 | u16 ext_reason = (status >> 5) & 0x3; | 213 | |
266 | 214 | dev_warn(dev, "DPC %s detected, remove downstream devices\n", | |
267 | dev_warn(dev, "DPC %s detected, remove downstream devices\n", | 215 | (reason == 0) ? "unmasked uncorrectable error" : |
268 | (reason == 0) ? "unmasked uncorrectable error" : | 216 | (reason == 1) ? "ERR_NONFATAL" : |
269 | (reason == 1) ? "ERR_NONFATAL" : | 217 | (reason == 2) ? "ERR_FATAL" : |
270 | (reason == 2) ? "ERR_FATAL" : | 218 | (ext_reason == 0) ? "RP PIO error" : |
271 | (ext_reason == 0) ? "RP PIO error" : | 219 | (ext_reason == 1) ? "software trigger" : |
272 | (ext_reason == 1) ? "software trigger" : | 220 | "reserved error"); |
273 | "reserved error"); | 221 | /* show RP PIO error detail information */ |
274 | /* show RP PIO error detail information */ | 222 | if (dpc->rp_extensions && reason == 3 && ext_reason == 0) |
275 | if (reason == 3 && ext_reason == 0) | 223 | dpc_process_rp_pio_error(dpc); |
276 | dpc_process_rp_pio_error(dpc); | 224 | |
277 | 225 | schedule_work(&dpc->work); | |
278 | schedule_work(&dpc->work); | 226 | |
279 | } | ||
280 | return IRQ_HANDLED; | 227 | return IRQ_HANDLED; |
281 | } | 228 | } |
282 | 229 | ||
@@ -289,13 +236,16 @@ static int dpc_probe(struct pcie_device *dev) | |||
289 | int status; | 236 | int status; |
290 | u16 ctl, cap; | 237 | u16 ctl, cap; |
291 | 238 | ||
239 | if (pcie_aer_get_firmware_first(pdev)) | ||
240 | return -ENOTSUPP; | ||
241 | |||
292 | dpc = devm_kzalloc(device, sizeof(*dpc), GFP_KERNEL); | 242 | dpc = devm_kzalloc(device, sizeof(*dpc), GFP_KERNEL); |
293 | if (!dpc) | 243 | if (!dpc) |
294 | return -ENOMEM; | 244 | return -ENOMEM; |
295 | 245 | ||
296 | dpc->cap_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DPC); | 246 | dpc->cap_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DPC); |
297 | dpc->dev = dev; | 247 | dpc->dev = dev; |
298 | INIT_WORK(&dpc->work, interrupt_event_handler); | 248 | INIT_WORK(&dpc->work, dpc_work); |
299 | set_service_data(dev, dpc); | 249 | set_service_data(dev, dpc); |
300 | 250 | ||
301 | status = devm_request_irq(device, dev->irq, dpc_irq, IRQF_SHARED, | 251 | status = devm_request_irq(device, dev->irq, dpc_irq, IRQF_SHARED, |
@@ -309,15 +259,23 @@ static int dpc_probe(struct pcie_device *dev) | |||
309 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CAP, &cap); | 259 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CAP, &cap); |
310 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, &ctl); | 260 | pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, &ctl); |
311 | 261 | ||
312 | dpc->rp = (cap & PCI_EXP_DPC_CAP_RP_EXT); | 262 | dpc->rp_extensions = (cap & PCI_EXP_DPC_CAP_RP_EXT); |
263 | if (dpc->rp_extensions) { | ||
264 | dpc->rp_log_size = (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8; | ||
265 | if (dpc->rp_log_size < 4 || dpc->rp_log_size > 9) { | ||
266 | dev_err(device, "RP PIO log size %u is invalid\n", | ||
267 | dpc->rp_log_size); | ||
268 | dpc->rp_log_size = 0; | ||
269 | } | ||
270 | } | ||
313 | 271 | ||
314 | ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_NONFATAL | PCI_EXP_DPC_CTL_INT_EN; | 272 | ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_NONFATAL | PCI_EXP_DPC_CTL_INT_EN; |
315 | pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, ctl); | 273 | pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, ctl); |
316 | 274 | ||
317 | dev_info(device, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n", | 275 | dev_info(device, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n", |
318 | cap & 0xf, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT), | 276 | cap & PCI_EXP_DPC_IRQ, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT), |
319 | FLAG(cap, PCI_EXP_DPC_CAP_POISONED_TLP), | 277 | FLAG(cap, PCI_EXP_DPC_CAP_POISONED_TLP), |
320 | FLAG(cap, PCI_EXP_DPC_CAP_SW_TRIGGER), (cap >> 8) & 0xf, | 278 | FLAG(cap, PCI_EXP_DPC_CAP_SW_TRIGGER), dpc->rp_log_size, |
321 | FLAG(cap, PCI_EXP_DPC_CAP_DL_ACTIVE)); | 279 | FLAG(cap, PCI_EXP_DPC_CAP_DL_ACTIVE)); |
322 | return status; | 280 | return status; |
323 | } | 281 | } |
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index df290aa58dce..5480f54f7612 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c | |||
@@ -1,13 +1,10 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe Native PME support | 3 | * PCIe Native PME support |
3 | * | 4 | * |
4 | * Copyright (C) 2007 - 2009 Intel Corp | 5 | * Copyright (C) 2007 - 2009 Intel Corp |
5 | * Copyright (C) 2007 - 2009 Shaohua Li <shaohua.li@intel.com> | 6 | * Copyright (C) 2007 - 2009 Shaohua Li <shaohua.li@intel.com> |
6 | * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. | 7 | * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. |
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License V2. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | 8 | */ |
12 | 9 | ||
13 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
@@ -198,14 +195,14 @@ static void pcie_pme_handle_request(struct pci_dev *port, u16 req_id) | |||
198 | * assuming that the PME was reported by a PCIe-PCI bridge that | 195 | * assuming that the PME was reported by a PCIe-PCI bridge that |
199 | * used devfn different from zero. | 196 | * used devfn different from zero. |
200 | */ | 197 | */ |
201 | dev_dbg(&port->dev, "PME interrupt generated for non-existent device %02x:%02x.%d\n", | 198 | pci_dbg(port, "PME interrupt generated for non-existent device %02x:%02x.%d\n", |
202 | busnr, PCI_SLOT(devfn), PCI_FUNC(devfn)); | 199 | busnr, PCI_SLOT(devfn), PCI_FUNC(devfn)); |
203 | found = pcie_pme_from_pci_bridge(bus, 0); | 200 | found = pcie_pme_from_pci_bridge(bus, 0); |
204 | } | 201 | } |
205 | 202 | ||
206 | out: | 203 | out: |
207 | if (!found) | 204 | if (!found) |
208 | dev_dbg(&port->dev, "Spurious native PME interrupt!\n"); | 205 | pci_dbg(port, "Spurious native PME interrupt!\n"); |
209 | } | 206 | } |
210 | 207 | ||
211 | /** | 208 | /** |
@@ -345,7 +342,7 @@ static int pcie_pme_probe(struct pcie_device *srv) | |||
345 | return ret; | 342 | return ret; |
346 | } | 343 | } |
347 | 344 | ||
348 | dev_info(&port->dev, "Signaling PME with IRQ %d\n", srv->irq); | 345 | pci_info(port, "Signaling PME with IRQ %d\n", srv->irq); |
349 | 346 | ||
350 | pcie_pme_mark_devices(port); | 347 | pcie_pme_mark_devices(port); |
351 | pcie_pme_interrupt_enable(port, true); | 348 | pcie_pme_interrupt_enable(port, true); |
diff --git a/drivers/pci/pcie/portdrv_acpi.c b/drivers/pci/pcie/portdrv_acpi.c index 6b8c2f1d0e71..319c94976873 100644 --- a/drivers/pci/pcie/portdrv_acpi.c +++ b/drivers/pci/pcie/portdrv_acpi.c | |||
@@ -1,11 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCIe Port Native Services Support, ACPI-Related Part | 3 | * PCIe Port Native Services Support, ACPI-Related Part |
3 | * | 4 | * |
4 | * Copyright (C) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. | 5 | * Copyright (C) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. |
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License V2. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | 6 | */ |
10 | 7 | ||
11 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c index 87e79a6ffb5a..f0fba552a0e2 100644 --- a/drivers/pci/pcie/portdrv_bus.c +++ b/drivers/pci/pcie/portdrv_bus.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * File: portdrv_bus.c | 3 | * File: portdrv_bus.c |
3 | * Purpose: PCI Express Port Bus Driver's Bus Overloading Functions | 4 | * Purpose: PCI Express Port Bus Driver's Bus Overloading Functions |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index a59210350c44..ef3bad4ad010 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -216,9 +216,9 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
216 | return 0; | 216 | return 0; |
217 | 217 | ||
218 | cap_mask = PCIE_PORT_SERVICE_PME | PCIE_PORT_SERVICE_HP | 218 | cap_mask = PCIE_PORT_SERVICE_PME | PCIE_PORT_SERVICE_HP |
219 | | PCIE_PORT_SERVICE_VC | PCIE_PORT_SERVICE_DPC; | 219 | | PCIE_PORT_SERVICE_VC; |
220 | if (pci_aer_available()) | 220 | if (pci_aer_available()) |
221 | cap_mask |= PCIE_PORT_SERVICE_AER; | 221 | cap_mask |= PCIE_PORT_SERVICE_AER | PCIE_PORT_SERVICE_DPC; |
222 | 222 | ||
223 | if (pcie_ports_auto) | 223 | if (pcie_ports_auto) |
224 | pcie_port_platform_notify(dev, &cap_mask); | 224 | pcie_port_platform_notify(dev, &cap_mask); |
diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c index bab8ac63c4f3..98cfa30f3fae 100644 --- a/drivers/pci/pcie/ptm.c +++ b/drivers/pci/pcie/ptm.c | |||
@@ -1,15 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCI Express Precision Time Measurement | 3 | * PCI Express Precision Time Measurement |
3 | * Copyright (c) 2016, Intel Corporation. | 4 | * Copyright (c) 2016, Intel Corporation. |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | 5 | */ |
14 | 6 | ||
15 | #include <linux/module.h> | 7 | #include <linux/module.h> |
@@ -33,7 +25,7 @@ static void pci_ptm_info(struct pci_dev *dev) | |||
33 | dev->ptm_granularity); | 25 | dev->ptm_granularity); |
34 | break; | 26 | break; |
35 | } | 27 | } |
36 | dev_info(&dev->dev, "PTM enabled%s, %s granularity\n", | 28 | pci_info(dev, "PTM enabled%s, %s granularity\n", |
37 | dev->ptm_root ? " (root)" : "", clock_desc); | 29 | dev->ptm_root ? " (root)" : "", clock_desc); |
38 | } | 30 | } |
39 | 31 | ||
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 14e0ea1ff38b..ef5377438a1e 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * probe.c - PCI detection and setup code | 3 | * probe.c - PCI detection and setup code |
3 | */ | 4 | */ |
@@ -69,8 +70,8 @@ static int find_anything(struct device *dev, void *data) | |||
69 | } | 70 | } |
70 | 71 | ||
71 | /* | 72 | /* |
72 | * Some device drivers need know if pci is initiated. | 73 | * Some device drivers need know if PCI is initiated. |
73 | * Basically, we think pci is not initiated when there | 74 | * Basically, we think PCI is not initiated when there |
74 | * is no device to be found on the pci_bus_type. | 75 | * is no device to be found on the pci_bus_type. |
75 | */ | 76 | */ |
76 | int no_pci_devices(void) | 77 | int no_pci_devices(void) |
@@ -116,12 +117,16 @@ static u64 pci_size(u64 base, u64 maxbase, u64 mask) | |||
116 | if (!size) | 117 | if (!size) |
117 | return 0; | 118 | return 0; |
118 | 119 | ||
119 | /* Get the lowest of them to find the decode size, and | 120 | /* |
120 | from that the extent. */ | 121 | * Get the lowest of them to find the decode size, and from that |
122 | * the extent. | ||
123 | */ | ||
121 | size = (size & ~(size-1)) - 1; | 124 | size = (size & ~(size-1)) - 1; |
122 | 125 | ||
123 | /* base == maxbase can be valid only if the BAR has | 126 | /* |
124 | already been programmed with all 1s. */ | 127 | * base == maxbase can be valid only if the BAR has already been |
128 | * programmed with all 1s. | ||
129 | */ | ||
125 | if (base == maxbase && ((base | size) & mask) != mask) | 130 | if (base == maxbase && ((base | size) & mask) != mask) |
126 | return 0; | 131 | return 0; |
127 | 132 | ||
@@ -164,7 +169,7 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar) | |||
164 | #define PCI_COMMAND_DECODE_ENABLE (PCI_COMMAND_MEMORY | PCI_COMMAND_IO) | 169 | #define PCI_COMMAND_DECODE_ENABLE (PCI_COMMAND_MEMORY | PCI_COMMAND_IO) |
165 | 170 | ||
166 | /** | 171 | /** |
167 | * pci_read_base - read a PCI BAR | 172 | * pci_read_base - Read a PCI BAR |
168 | * @dev: the PCI device | 173 | * @dev: the PCI device |
169 | * @type: type of the BAR | 174 | * @type: type of the BAR |
170 | * @res: resource buffer to be filled in | 175 | * @res: resource buffer to be filled in |
@@ -253,7 +258,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
253 | 258 | ||
254 | sz64 = pci_size(l64, sz64, mask64); | 259 | sz64 = pci_size(l64, sz64, mask64); |
255 | if (!sz64) { | 260 | if (!sz64) { |
256 | dev_info(&dev->dev, FW_BUG "reg 0x%x: invalid BAR (can't size)\n", | 261 | pci_info(dev, FW_BUG "reg 0x%x: invalid BAR (can't size)\n", |
257 | pos); | 262 | pos); |
258 | goto fail; | 263 | goto fail; |
259 | } | 264 | } |
@@ -264,7 +269,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
264 | res->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED; | 269 | res->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED; |
265 | res->start = 0; | 270 | res->start = 0; |
266 | res->end = 0; | 271 | res->end = 0; |
267 | dev_err(&dev->dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n", | 272 | pci_err(dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n", |
268 | pos, (unsigned long long)sz64); | 273 | pos, (unsigned long long)sz64); |
269 | goto out; | 274 | goto out; |
270 | } | 275 | } |
@@ -274,7 +279,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
274 | res->flags |= IORESOURCE_UNSET; | 279 | res->flags |= IORESOURCE_UNSET; |
275 | res->start = 0; | 280 | res->start = 0; |
276 | res->end = sz64; | 281 | res->end = sz64; |
277 | dev_info(&dev->dev, "reg 0x%x: can't handle BAR above 4GB (bus address %#010llx)\n", | 282 | pci_info(dev, "reg 0x%x: can't handle BAR above 4GB (bus address %#010llx)\n", |
278 | pos, (unsigned long long)l64); | 283 | pos, (unsigned long long)l64); |
279 | goto out; | 284 | goto out; |
280 | } | 285 | } |
@@ -301,7 +306,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
301 | res->flags |= IORESOURCE_UNSET; | 306 | res->flags |= IORESOURCE_UNSET; |
302 | res->start = 0; | 307 | res->start = 0; |
303 | res->end = region.end - region.start; | 308 | res->end = region.end - region.start; |
304 | dev_info(&dev->dev, "reg 0x%x: initial BAR value %#010llx invalid\n", | 309 | pci_info(dev, "reg 0x%x: initial BAR value %#010llx invalid\n", |
305 | pos, (unsigned long long)region.start); | 310 | pos, (unsigned long long)region.start); |
306 | } | 311 | } |
307 | 312 | ||
@@ -312,7 +317,7 @@ fail: | |||
312 | res->flags = 0; | 317 | res->flags = 0; |
313 | out: | 318 | out: |
314 | if (res->flags) | 319 | if (res->flags) |
315 | dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res); | 320 | pci_printk(KERN_DEBUG, dev, "reg 0x%x: %pR\n", pos, res); |
316 | 321 | ||
317 | return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; | 322 | return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; |
318 | } | 323 | } |
@@ -375,7 +380,7 @@ static void pci_read_bridge_io(struct pci_bus *child) | |||
375 | region.start = base; | 380 | region.start = base; |
376 | region.end = limit + io_granularity - 1; | 381 | region.end = limit + io_granularity - 1; |
377 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 382 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
378 | dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); | 383 | pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); |
379 | } | 384 | } |
380 | } | 385 | } |
381 | 386 | ||
@@ -397,7 +402,7 @@ static void pci_read_bridge_mmio(struct pci_bus *child) | |||
397 | region.start = base; | 402 | region.start = base; |
398 | region.end = limit + 0xfffff; | 403 | region.end = limit + 0xfffff; |
399 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 404 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
400 | dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); | 405 | pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); |
401 | } | 406 | } |
402 | } | 407 | } |
403 | 408 | ||
@@ -437,7 +442,7 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child) | |||
437 | limit = (pci_bus_addr_t) limit64; | 442 | limit = (pci_bus_addr_t) limit64; |
438 | 443 | ||
439 | if (base != base64) { | 444 | if (base != base64) { |
440 | dev_err(&dev->dev, "can't handle bridge window above 4GB (bus address %#010llx)\n", | 445 | pci_err(dev, "can't handle bridge window above 4GB (bus address %#010llx)\n", |
441 | (unsigned long long) base64); | 446 | (unsigned long long) base64); |
442 | return; | 447 | return; |
443 | } | 448 | } |
@@ -450,7 +455,7 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child) | |||
450 | region.start = base; | 455 | region.start = base; |
451 | region.end = limit + 0xfffff; | 456 | region.end = limit + 0xfffff; |
452 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 457 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
453 | dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); | 458 | pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); |
454 | } | 459 | } |
455 | } | 460 | } |
456 | 461 | ||
@@ -463,7 +468,7 @@ void pci_read_bridge_bases(struct pci_bus *child) | |||
463 | if (pci_is_root_bus(child)) /* It's a host bus, nothing to read */ | 468 | if (pci_is_root_bus(child)) /* It's a host bus, nothing to read */ |
464 | return; | 469 | return; |
465 | 470 | ||
466 | dev_info(&dev->dev, "PCI bridge to %pR%s\n", | 471 | pci_info(dev, "PCI bridge to %pR%s\n", |
467 | &child->busn_res, | 472 | &child->busn_res, |
468 | dev->transparent ? " (subtractive decode)" : ""); | 473 | dev->transparent ? " (subtractive decode)" : ""); |
469 | 474 | ||
@@ -480,7 +485,7 @@ void pci_read_bridge_bases(struct pci_bus *child) | |||
480 | if (res && res->flags) { | 485 | if (res && res->flags) { |
481 | pci_bus_add_resource(child, res, | 486 | pci_bus_add_resource(child, res, |
482 | PCI_SUBTRACTIVE_DECODE); | 487 | PCI_SUBTRACTIVE_DECODE); |
483 | dev_printk(KERN_DEBUG, &dev->dev, | 488 | pci_printk(KERN_DEBUG, dev, |
484 | " bridge window %pR (subtractive decode)\n", | 489 | " bridge window %pR (subtractive decode)\n", |
485 | res); | 490 | res); |
486 | } | 491 | } |
@@ -764,7 +769,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) | |||
764 | 769 | ||
765 | bridge->bus = bus; | 770 | bridge->bus = bus; |
766 | 771 | ||
767 | /* temporarily move resources off the list */ | 772 | /* Temporarily move resources off the list */ |
768 | list_splice_init(&bridge->windows, &resources); | 773 | list_splice_init(&bridge->windows, &resources); |
769 | bus->sysdata = bridge->sysdata; | 774 | bus->sysdata = bridge->sysdata; |
770 | bus->msi = bridge->msi; | 775 | bus->msi = bridge->msi; |
@@ -776,7 +781,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) | |||
776 | 781 | ||
777 | b = pci_find_bus(pci_domain_nr(bus), bridge->busnr); | 782 | b = pci_find_bus(pci_domain_nr(bus), bridge->busnr); |
778 | if (b) { | 783 | if (b) { |
779 | /* If we already got to this bus through a different bridge, ignore it */ | 784 | /* Ignore it if we already got here via a different bridge */ |
780 | dev_dbg(&b->dev, "bus already known\n"); | 785 | dev_dbg(&b->dev, "bus already known\n"); |
781 | err = -EEXIST; | 786 | err = -EEXIST; |
782 | goto free; | 787 | goto free; |
@@ -869,9 +874,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
869 | int i; | 874 | int i; |
870 | int ret; | 875 | int ret; |
871 | 876 | ||
872 | /* | 877 | /* Allocate a new bus and inherit stuff from the parent */ |
873 | * Allocate a new bus, and inherit stuff from the parent.. | ||
874 | */ | ||
875 | child = pci_alloc_bus(parent); | 878 | child = pci_alloc_bus(parent); |
876 | if (!child) | 879 | if (!child) |
877 | return NULL; | 880 | return NULL; |
@@ -882,16 +885,14 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
882 | child->sysdata = parent->sysdata; | 885 | child->sysdata = parent->sysdata; |
883 | child->bus_flags = parent->bus_flags; | 886 | child->bus_flags = parent->bus_flags; |
884 | 887 | ||
885 | /* initialize some portions of the bus device, but don't register it | 888 | /* |
886 | * now as the parent is not properly set up yet. | 889 | * Initialize some portions of the bus device, but don't register |
890 | * it now as the parent is not properly set up yet. | ||
887 | */ | 891 | */ |
888 | child->dev.class = &pcibus_class; | 892 | child->dev.class = &pcibus_class; |
889 | dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr); | 893 | dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr); |
890 | 894 | ||
891 | /* | 895 | /* Set up the primary, secondary and subordinate bus numbers */ |
892 | * Set up the primary, secondary and subordinate | ||
893 | * bus numbers. | ||
894 | */ | ||
895 | child->number = child->busn_res.start = busnr; | 896 | child->number = child->busn_res.start = busnr; |
896 | child->primary = parent->busn_res.start; | 897 | child->primary = parent->busn_res.start; |
897 | child->busn_res.end = 0xff; | 898 | child->busn_res.end = 0xff; |
@@ -907,7 +908,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
907 | pci_set_bus_of_node(child); | 908 | pci_set_bus_of_node(child); |
908 | pci_set_bus_speed(child); | 909 | pci_set_bus_speed(child); |
909 | 910 | ||
910 | /* Set up default resource pointers and names.. */ | 911 | /* Set up default resource pointers and names */ |
911 | for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) { | 912 | for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) { |
912 | child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i]; | 913 | child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i]; |
913 | child->resource[i]->name = child->name; | 914 | child->resource[i]->name = child->name; |
@@ -1005,11 +1006,11 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1005 | secondary = (buses >> 8) & 0xFF; | 1006 | secondary = (buses >> 8) & 0xFF; |
1006 | subordinate = (buses >> 16) & 0xFF; | 1007 | subordinate = (buses >> 16) & 0xFF; |
1007 | 1008 | ||
1008 | dev_dbg(&dev->dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n", | 1009 | pci_dbg(dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n", |
1009 | secondary, subordinate, pass); | 1010 | secondary, subordinate, pass); |
1010 | 1011 | ||
1011 | if (!primary && (primary != bus->number) && secondary && subordinate) { | 1012 | if (!primary && (primary != bus->number) && secondary && subordinate) { |
1012 | dev_warn(&dev->dev, "Primary bus is hard wired to 0\n"); | 1013 | pci_warn(dev, "Primary bus is hard wired to 0\n"); |
1013 | primary = bus->number; | 1014 | primary = bus->number; |
1014 | } | 1015 | } |
1015 | 1016 | ||
@@ -1017,13 +1018,15 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1017 | if (!pass && | 1018 | if (!pass && |
1018 | (primary != bus->number || secondary <= bus->number || | 1019 | (primary != bus->number || secondary <= bus->number || |
1019 | secondary > subordinate)) { | 1020 | secondary > subordinate)) { |
1020 | dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", | 1021 | pci_info(dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", |
1021 | secondary, subordinate); | 1022 | secondary, subordinate); |
1022 | broken = 1; | 1023 | broken = 1; |
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | /* Disable MasterAbortMode during probing to avoid reporting | 1026 | /* |
1026 | of bus errors (in some architectures) */ | 1027 | * Disable Master-Abort Mode during probing to avoid reporting of |
1028 | * bus errors in some architectures. | ||
1029 | */ | ||
1027 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); | 1030 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); |
1028 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, | 1031 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, |
1029 | bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); | 1032 | bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); |
@@ -1033,18 +1036,19 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1033 | if ((secondary || subordinate) && !pcibios_assign_all_busses() && | 1036 | if ((secondary || subordinate) && !pcibios_assign_all_busses() && |
1034 | !is_cardbus && !broken) { | 1037 | !is_cardbus && !broken) { |
1035 | unsigned int cmax; | 1038 | unsigned int cmax; |
1039 | |||
1036 | /* | 1040 | /* |
1037 | * Bus already configured by firmware, process it in the first | 1041 | * Bus already configured by firmware, process it in the |
1038 | * pass and just note the configuration. | 1042 | * first pass and just note the configuration. |
1039 | */ | 1043 | */ |
1040 | if (pass) | 1044 | if (pass) |
1041 | goto out; | 1045 | goto out; |
1042 | 1046 | ||
1043 | /* | 1047 | /* |
1044 | * The bus might already exist for two reasons: Either we are | 1048 | * The bus might already exist for two reasons: Either we |
1045 | * rescanning the bus or the bus is reachable through more than | 1049 | * are rescanning the bus or the bus is reachable through |
1046 | * one bridge. The second case can happen with the i450NX | 1050 | * more than one bridge. The second case can happen with |
1047 | * chipset. | 1051 | * the i450NX chipset. |
1048 | */ | 1052 | */ |
1049 | child = pci_find_bus(pci_domain_nr(bus), secondary); | 1053 | child = pci_find_bus(pci_domain_nr(bus), secondary); |
1050 | if (!child) { | 1054 | if (!child) { |
@@ -1058,24 +1062,29 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1058 | 1062 | ||
1059 | cmax = pci_scan_child_bus(child); | 1063 | cmax = pci_scan_child_bus(child); |
1060 | if (cmax > subordinate) | 1064 | if (cmax > subordinate) |
1061 | dev_warn(&dev->dev, "bridge has subordinate %02x but max busn %02x\n", | 1065 | pci_warn(dev, "bridge has subordinate %02x but max busn %02x\n", |
1062 | subordinate, cmax); | 1066 | subordinate, cmax); |
1063 | /* subordinate should equal child->busn_res.end */ | 1067 | |
1068 | /* Subordinate should equal child->busn_res.end */ | ||
1064 | if (subordinate > max) | 1069 | if (subordinate > max) |
1065 | max = subordinate; | 1070 | max = subordinate; |
1066 | } else { | 1071 | } else { |
1072 | |||
1067 | /* | 1073 | /* |
1068 | * We need to assign a number to this bus which we always | 1074 | * We need to assign a number to this bus which we always |
1069 | * do in the second pass. | 1075 | * do in the second pass. |
1070 | */ | 1076 | */ |
1071 | if (!pass) { | 1077 | if (!pass) { |
1072 | if (pcibios_assign_all_busses() || broken || is_cardbus) | 1078 | if (pcibios_assign_all_busses() || broken || is_cardbus) |
1073 | /* Temporarily disable forwarding of the | 1079 | |
1074 | configuration cycles on all bridges in | 1080 | /* |
1075 | this bus segment to avoid possible | 1081 | * Temporarily disable forwarding of the |
1076 | conflicts in the second pass between two | 1082 | * configuration cycles on all bridges in |
1077 | bridges programmed with overlapping | 1083 | * this bus segment to avoid possible |
1078 | bus ranges. */ | 1084 | * conflicts in the second pass between two |
1085 | * bridges programmed with overlapping bus | ||
1086 | * ranges. | ||
1087 | */ | ||
1079 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, | 1088 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, |
1080 | buses & ~0xffffff); | 1089 | buses & ~0xffffff); |
1081 | goto out; | 1090 | goto out; |
@@ -1084,9 +1093,11 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1084 | /* Clear errors */ | 1093 | /* Clear errors */ |
1085 | pci_write_config_word(dev, PCI_STATUS, 0xffff); | 1094 | pci_write_config_word(dev, PCI_STATUS, 0xffff); |
1086 | 1095 | ||
1087 | /* Prevent assigning a bus number that already exists. | 1096 | /* |
1088 | * This can happen when a bridge is hot-plugged, so in | 1097 | * Prevent assigning a bus number that already exists. |
1089 | * this case we only re-scan this bus. */ | 1098 | * This can happen when a bridge is hot-plugged, so in this |
1099 | * case we only re-scan this bus. | ||
1100 | */ | ||
1090 | child = pci_find_bus(pci_domain_nr(bus), max+1); | 1101 | child = pci_find_bus(pci_domain_nr(bus), max+1); |
1091 | if (!child) { | 1102 | if (!child) { |
1092 | child = pci_add_new_bus(bus, dev, max+1); | 1103 | child = pci_add_new_bus(bus, dev, max+1); |
@@ -1113,19 +1124,18 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1113 | buses |= CARDBUS_LATENCY_TIMER << 24; | 1124 | buses |= CARDBUS_LATENCY_TIMER << 24; |
1114 | } | 1125 | } |
1115 | 1126 | ||
1116 | /* | 1127 | /* We need to blast all three values with a single write */ |
1117 | * We need to blast all three values with a single write. | ||
1118 | */ | ||
1119 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); | 1128 | pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); |
1120 | 1129 | ||
1121 | if (!is_cardbus) { | 1130 | if (!is_cardbus) { |
1122 | child->bridge_ctl = bctl; | 1131 | child->bridge_ctl = bctl; |
1123 | max = pci_scan_child_bus_extend(child, available_buses); | 1132 | max = pci_scan_child_bus_extend(child, available_buses); |
1124 | } else { | 1133 | } else { |
1134 | |||
1125 | /* | 1135 | /* |
1126 | * For CardBus bridges, we leave 4 bus numbers | 1136 | * For CardBus bridges, we leave 4 bus numbers as |
1127 | * as cards with a PCI-to-PCI bridge can be | 1137 | * cards with a PCI-to-PCI bridge can be inserted |
1128 | * inserted later. | 1138 | * later. |
1129 | */ | 1139 | */ |
1130 | for (i = 0; i < CARDBUS_RESERVE_BUSNR; i++) { | 1140 | for (i = 0; i < CARDBUS_RESERVE_BUSNR; i++) { |
1131 | struct pci_bus *parent = bus; | 1141 | struct pci_bus *parent = bus; |
@@ -1141,10 +1151,11 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1141 | parent = parent->parent; | 1151 | parent = parent->parent; |
1142 | } | 1152 | } |
1143 | if (j) { | 1153 | if (j) { |
1154 | |||
1144 | /* | 1155 | /* |
1145 | * Often, there are two cardbus bridges | 1156 | * Often, there are two CardBus |
1146 | * -- try to leave one valid bus number | 1157 | * bridges -- try to leave one |
1147 | * for each one. | 1158 | * valid bus number for each one. |
1148 | */ | 1159 | */ |
1149 | i /= 2; | 1160 | i /= 2; |
1150 | break; | 1161 | break; |
@@ -1152,9 +1163,8 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev, | |||
1152 | } | 1163 | } |
1153 | max += i; | 1164 | max += i; |
1154 | } | 1165 | } |
1155 | /* | 1166 | |
1156 | * Set the subordinate bus number to its real value. | 1167 | /* Set subordinate bus number to its real value */ |
1157 | */ | ||
1158 | pci_bus_update_busn_res_end(child, max); | 1168 | pci_bus_update_busn_res_end(child, max); |
1159 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); | 1169 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); |
1160 | } | 1170 | } |
@@ -1295,7 +1305,7 @@ static void set_pcie_thunderbolt(struct pci_dev *dev) | |||
1295 | } | 1305 | } |
1296 | 1306 | ||
1297 | /** | 1307 | /** |
1298 | * pci_ext_cfg_is_aliased - is ext config space just an alias of std config? | 1308 | * pci_ext_cfg_is_aliased - Is ext config space just an alias of std config? |
1299 | * @dev: PCI device | 1309 | * @dev: PCI device |
1300 | * | 1310 | * |
1301 | * PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says that | 1311 | * PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says that |
@@ -1332,7 +1342,7 @@ static bool pci_ext_cfg_is_aliased(struct pci_dev *dev) | |||
1332 | } | 1342 | } |
1333 | 1343 | ||
1334 | /** | 1344 | /** |
1335 | * pci_cfg_space_size - get the configuration space size of the PCI device. | 1345 | * pci_cfg_space_size - Get the configuration space size of the PCI device |
1336 | * @dev: PCI device | 1346 | * @dev: PCI device |
1337 | * | 1347 | * |
1338 | * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices | 1348 | * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices |
@@ -1398,7 +1408,7 @@ static void pci_msi_setup_pci_dev(struct pci_dev *dev) | |||
1398 | } | 1408 | } |
1399 | 1409 | ||
1400 | /** | 1410 | /** |
1401 | * pci_intx_mask_broken - test PCI_COMMAND_INTX_DISABLE writability | 1411 | * pci_intx_mask_broken - Test PCI_COMMAND_INTX_DISABLE writability |
1402 | * @dev: PCI device | 1412 | * @dev: PCI device |
1403 | * | 1413 | * |
1404 | * Test whether PCI_COMMAND_INTX_DISABLE is writable for @dev. Check this | 1414 | * Test whether PCI_COMMAND_INTX_DISABLE is writable for @dev. Check this |
@@ -1426,11 +1436,11 @@ static int pci_intx_mask_broken(struct pci_dev *dev) | |||
1426 | } | 1436 | } |
1427 | 1437 | ||
1428 | /** | 1438 | /** |
1429 | * pci_setup_device - fill in class and map information of a device | 1439 | * pci_setup_device - Fill in class and map information of a device |
1430 | * @dev: the device structure to fill | 1440 | * @dev: the device structure to fill |
1431 | * | 1441 | * |
1432 | * Initialize the device structure with information about the device's | 1442 | * Initialize the device structure with information about the device's |
1433 | * vendor,class,memory and IO-space addresses,IRQ lines etc. | 1443 | * vendor,class,memory and IO-space addresses, IRQ lines etc. |
1434 | * Called at initialisation of the PCI subsystem and by CardBus services. | 1444 | * Called at initialisation of the PCI subsystem and by CardBus services. |
1435 | * Returns 0 on success and negative if unknown type of device (not normal, | 1445 | * Returns 0 on success and negative if unknown type of device (not normal, |
1436 | * bridge or CardBus). | 1446 | * bridge or CardBus). |
@@ -1456,8 +1466,11 @@ int pci_setup_device(struct pci_dev *dev) | |||
1456 | set_pcie_port_type(dev); | 1466 | set_pcie_port_type(dev); |
1457 | 1467 | ||
1458 | pci_dev_assign_slot(dev); | 1468 | pci_dev_assign_slot(dev); |
1459 | /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) | 1469 | |
1460 | set this higher, assuming the system even supports it. */ | 1470 | /* |
1471 | * Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) | ||
1472 | * set this higher, assuming the system even supports it. | ||
1473 | */ | ||
1461 | dev->dma_mask = 0xffffffff; | 1474 | dev->dma_mask = 0xffffffff; |
1462 | 1475 | ||
1463 | dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus), | 1476 | dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus), |
@@ -1468,13 +1481,13 @@ int pci_setup_device(struct pci_dev *dev) | |||
1468 | dev->revision = class & 0xff; | 1481 | dev->revision = class & 0xff; |
1469 | dev->class = class >> 8; /* upper 3 bytes */ | 1482 | dev->class = class >> 8; /* upper 3 bytes */ |
1470 | 1483 | ||
1471 | dev_printk(KERN_DEBUG, &dev->dev, "[%04x:%04x] type %02x class %#08x\n", | 1484 | pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n", |
1472 | dev->vendor, dev->device, dev->hdr_type, dev->class); | 1485 | dev->vendor, dev->device, dev->hdr_type, dev->class); |
1473 | 1486 | ||
1474 | /* need to have dev->class ready */ | 1487 | /* Need to have dev->class ready */ |
1475 | dev->cfg_size = pci_cfg_space_size(dev); | 1488 | dev->cfg_size = pci_cfg_space_size(dev); |
1476 | 1489 | ||
1477 | /* need to have dev->cfg_size ready */ | 1490 | /* Need to have dev->cfg_size ready */ |
1478 | set_pcie_thunderbolt(dev); | 1491 | set_pcie_thunderbolt(dev); |
1479 | 1492 | ||
1480 | /* "Unknown power state" */ | 1493 | /* "Unknown power state" */ |
@@ -1482,13 +1495,14 @@ int pci_setup_device(struct pci_dev *dev) | |||
1482 | 1495 | ||
1483 | /* Early fixups, before probing the BARs */ | 1496 | /* Early fixups, before probing the BARs */ |
1484 | pci_fixup_device(pci_fixup_early, dev); | 1497 | pci_fixup_device(pci_fixup_early, dev); |
1485 | /* device class may be changed after fixup */ | 1498 | |
1499 | /* Device class may be changed after fixup */ | ||
1486 | class = dev->class >> 8; | 1500 | class = dev->class >> 8; |
1487 | 1501 | ||
1488 | if (dev->non_compliant_bars) { | 1502 | if (dev->non_compliant_bars) { |
1489 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | 1503 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
1490 | if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { | 1504 | if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { |
1491 | dev_info(&dev->dev, "device has non-compliant BARs; disabling IO/MEM decoding\n"); | 1505 | pci_info(dev, "device has non-compliant BARs; disabling IO/MEM decoding\n"); |
1492 | cmd &= ~PCI_COMMAND_IO; | 1506 | cmd &= ~PCI_COMMAND_IO; |
1493 | cmd &= ~PCI_COMMAND_MEMORY; | 1507 | cmd &= ~PCI_COMMAND_MEMORY; |
1494 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 1508 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
@@ -1521,14 +1535,14 @@ int pci_setup_device(struct pci_dev *dev) | |||
1521 | res = &dev->resource[0]; | 1535 | res = &dev->resource[0]; |
1522 | res->flags = LEGACY_IO_RESOURCE; | 1536 | res->flags = LEGACY_IO_RESOURCE; |
1523 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 1537 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
1524 | dev_info(&dev->dev, "legacy IDE quirk: reg 0x10: %pR\n", | 1538 | pci_info(dev, "legacy IDE quirk: reg 0x10: %pR\n", |
1525 | res); | 1539 | res); |
1526 | region.start = 0x3F6; | 1540 | region.start = 0x3F6; |
1527 | region.end = 0x3F6; | 1541 | region.end = 0x3F6; |
1528 | res = &dev->resource[1]; | 1542 | res = &dev->resource[1]; |
1529 | res->flags = LEGACY_IO_RESOURCE; | 1543 | res->flags = LEGACY_IO_RESOURCE; |
1530 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 1544 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
1531 | dev_info(&dev->dev, "legacy IDE quirk: reg 0x14: %pR\n", | 1545 | pci_info(dev, "legacy IDE quirk: reg 0x14: %pR\n", |
1532 | res); | 1546 | res); |
1533 | } | 1547 | } |
1534 | if ((progif & 4) == 0) { | 1548 | if ((progif & 4) == 0) { |
@@ -1537,14 +1551,14 @@ int pci_setup_device(struct pci_dev *dev) | |||
1537 | res = &dev->resource[2]; | 1551 | res = &dev->resource[2]; |
1538 | res->flags = LEGACY_IO_RESOURCE; | 1552 | res->flags = LEGACY_IO_RESOURCE; |
1539 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 1553 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
1540 | dev_info(&dev->dev, "legacy IDE quirk: reg 0x18: %pR\n", | 1554 | pci_info(dev, "legacy IDE quirk: reg 0x18: %pR\n", |
1541 | res); | 1555 | res); |
1542 | region.start = 0x376; | 1556 | region.start = 0x376; |
1543 | region.end = 0x376; | 1557 | region.end = 0x376; |
1544 | res = &dev->resource[3]; | 1558 | res = &dev->resource[3]; |
1545 | res->flags = LEGACY_IO_RESOURCE; | 1559 | res->flags = LEGACY_IO_RESOURCE; |
1546 | pcibios_bus_to_resource(dev->bus, res, ®ion); | 1560 | pcibios_bus_to_resource(dev->bus, res, ®ion); |
1547 | dev_info(&dev->dev, "legacy IDE quirk: reg 0x1c: %pR\n", | 1561 | pci_info(dev, "legacy IDE quirk: reg 0x1c: %pR\n", |
1548 | res); | 1562 | res); |
1549 | } | 1563 | } |
1550 | } | 1564 | } |
@@ -1553,9 +1567,12 @@ int pci_setup_device(struct pci_dev *dev) | |||
1553 | case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ | 1567 | case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ |
1554 | if (class != PCI_CLASS_BRIDGE_PCI) | 1568 | if (class != PCI_CLASS_BRIDGE_PCI) |
1555 | goto bad; | 1569 | goto bad; |
1556 | /* The PCI-to-PCI bridge spec requires that subtractive | 1570 | |
1557 | decoding (i.e. transparent) bridge must have programming | 1571 | /* |
1558 | interface code of 0x01. */ | 1572 | * The PCI-to-PCI bridge spec requires that subtractive |
1573 | * decoding (i.e. transparent) bridge must have programming | ||
1574 | * interface code of 0x01. | ||
1575 | */ | ||
1559 | pci_read_irq(dev); | 1576 | pci_read_irq(dev); |
1560 | dev->transparent = ((dev->class & 0xff) == 1); | 1577 | dev->transparent = ((dev->class & 0xff) == 1); |
1561 | pci_read_bases(dev, 2, PCI_ROM_ADDRESS1); | 1578 | pci_read_bases(dev, 2, PCI_ROM_ADDRESS1); |
@@ -1577,12 +1594,12 @@ int pci_setup_device(struct pci_dev *dev) | |||
1577 | break; | 1594 | break; |
1578 | 1595 | ||
1579 | default: /* unknown header */ | 1596 | default: /* unknown header */ |
1580 | dev_err(&dev->dev, "unknown header type %02x, ignoring device\n", | 1597 | pci_err(dev, "unknown header type %02x, ignoring device\n", |
1581 | dev->hdr_type); | 1598 | dev->hdr_type); |
1582 | return -EIO; | 1599 | return -EIO; |
1583 | 1600 | ||
1584 | bad: | 1601 | bad: |
1585 | dev_err(&dev->dev, "ignoring class %#08x (doesn't match header type %02x)\n", | 1602 | pci_err(dev, "ignoring class %#08x (doesn't match header type %02x)\n", |
1586 | dev->class, dev->hdr_type); | 1603 | dev->class, dev->hdr_type); |
1587 | dev->class = PCI_CLASS_NOT_DEFINED << 8; | 1604 | dev->class = PCI_CLASS_NOT_DEFINED << 8; |
1588 | } | 1605 | } |
@@ -1606,7 +1623,7 @@ static void pci_configure_mps(struct pci_dev *dev) | |||
1606 | return; | 1623 | return; |
1607 | 1624 | ||
1608 | if (pcie_bus_config == PCIE_BUS_TUNE_OFF) { | 1625 | if (pcie_bus_config == PCIE_BUS_TUNE_OFF) { |
1609 | dev_warn(&dev->dev, "Max Payload Size %d, but upstream %s set to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n", | 1626 | pci_warn(dev, "Max Payload Size %d, but upstream %s set to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n", |
1610 | mps, pci_name(bridge), p_mps); | 1627 | mps, pci_name(bridge), p_mps); |
1611 | return; | 1628 | return; |
1612 | } | 1629 | } |
@@ -1620,12 +1637,12 @@ static void pci_configure_mps(struct pci_dev *dev) | |||
1620 | 1637 | ||
1621 | rc = pcie_set_mps(dev, p_mps); | 1638 | rc = pcie_set_mps(dev, p_mps); |
1622 | if (rc) { | 1639 | if (rc) { |
1623 | dev_warn(&dev->dev, "can't set Max Payload Size to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n", | 1640 | pci_warn(dev, "can't set Max Payload Size to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n", |
1624 | p_mps); | 1641 | p_mps); |
1625 | return; | 1642 | return; |
1626 | } | 1643 | } |
1627 | 1644 | ||
1628 | dev_info(&dev->dev, "Max Payload Size set to %d (was %d, max %d)\n", | 1645 | pci_info(dev, "Max Payload Size set to %d (was %d, max %d)\n", |
1629 | p_mps, mps, 128 << dev->pcie_mpss); | 1646 | p_mps, mps, 128 << dev->pcie_mpss); |
1630 | } | 1647 | } |
1631 | 1648 | ||
@@ -1645,8 +1662,7 @@ static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp) | |||
1645 | hpp = &pci_default_type0; | 1662 | hpp = &pci_default_type0; |
1646 | 1663 | ||
1647 | if (hpp->revision > 1) { | 1664 | if (hpp->revision > 1) { |
1648 | dev_warn(&dev->dev, | 1665 | pci_warn(dev, "PCI settings rev %d not supported; using defaults\n", |
1649 | "PCI settings rev %d not supported; using defaults\n", | ||
1650 | hpp->revision); | 1666 | hpp->revision); |
1651 | hpp = &pci_default_type0; | 1667 | hpp = &pci_default_type0; |
1652 | } | 1668 | } |
@@ -1684,7 +1700,7 @@ static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp) | |||
1684 | if (!pos) | 1700 | if (!pos) |
1685 | return; | 1701 | return; |
1686 | 1702 | ||
1687 | dev_warn(&dev->dev, "PCI-X settings not supported\n"); | 1703 | pci_warn(dev, "PCI-X settings not supported\n"); |
1688 | } | 1704 | } |
1689 | 1705 | ||
1690 | static bool pcie_root_rcb_set(struct pci_dev *dev) | 1706 | static bool pcie_root_rcb_set(struct pci_dev *dev) |
@@ -1714,7 +1730,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) | |||
1714 | return; | 1730 | return; |
1715 | 1731 | ||
1716 | if (hpp->revision > 1) { | 1732 | if (hpp->revision > 1) { |
1717 | dev_warn(&dev->dev, "PCIe settings rev %d not supported\n", | 1733 | pci_warn(dev, "PCIe settings rev %d not supported\n", |
1718 | hpp->revision); | 1734 | hpp->revision); |
1719 | return; | 1735 | return; |
1720 | } | 1736 | } |
@@ -1772,6 +1788,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) | |||
1772 | /* Initialize Advanced Error Capabilities and Control Register */ | 1788 | /* Initialize Advanced Error Capabilities and Control Register */ |
1773 | pci_read_config_dword(dev, pos + PCI_ERR_CAP, ®32); | 1789 | pci_read_config_dword(dev, pos + PCI_ERR_CAP, ®32); |
1774 | reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or; | 1790 | reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or; |
1791 | |||
1775 | /* Don't enable ECRC generation or checking if unsupported */ | 1792 | /* Don't enable ECRC generation or checking if unsupported */ |
1776 | if (!(reg32 & PCI_ERR_CAP_ECRC_GENC)) | 1793 | if (!(reg32 & PCI_ERR_CAP_ECRC_GENC)) |
1777 | reg32 &= ~PCI_ERR_CAP_ECRC_GENE; | 1794 | reg32 &= ~PCI_ERR_CAP_ECRC_GENE; |
@@ -1818,7 +1835,7 @@ int pci_configure_extended_tags(struct pci_dev *dev, void *ign) | |||
1818 | */ | 1835 | */ |
1819 | if (host->no_ext_tags) { | 1836 | if (host->no_ext_tags) { |
1820 | if (ctl & PCI_EXP_DEVCTL_EXT_TAG) { | 1837 | if (ctl & PCI_EXP_DEVCTL_EXT_TAG) { |
1821 | dev_info(&dev->dev, "disabling Extended Tags\n"); | 1838 | pci_info(dev, "disabling Extended Tags\n"); |
1822 | pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, | 1839 | pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, |
1823 | PCI_EXP_DEVCTL_EXT_TAG); | 1840 | PCI_EXP_DEVCTL_EXT_TAG); |
1824 | } | 1841 | } |
@@ -1826,7 +1843,7 @@ int pci_configure_extended_tags(struct pci_dev *dev, void *ign) | |||
1826 | } | 1843 | } |
1827 | 1844 | ||
1828 | if (!(ctl & PCI_EXP_DEVCTL_EXT_TAG)) { | 1845 | if (!(ctl & PCI_EXP_DEVCTL_EXT_TAG)) { |
1829 | dev_info(&dev->dev, "enabling Extended Tags\n"); | 1846 | pci_info(dev, "enabling Extended Tags\n"); |
1830 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, | 1847 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, |
1831 | PCI_EXP_DEVCTL_EXT_TAG); | 1848 | PCI_EXP_DEVCTL_EXT_TAG); |
1832 | } | 1849 | } |
@@ -1871,10 +1888,42 @@ static void pci_configure_relaxed_ordering(struct pci_dev *dev) | |||
1871 | if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) { | 1888 | if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) { |
1872 | pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, | 1889 | pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, |
1873 | PCI_EXP_DEVCTL_RELAX_EN); | 1890 | PCI_EXP_DEVCTL_RELAX_EN); |
1874 | dev_info(&dev->dev, "Disable Relaxed Ordering because the Root Port didn't support it\n"); | 1891 | pci_info(dev, "Relaxed Ordering disabled because the Root Port didn't support it\n"); |
1875 | } | 1892 | } |
1876 | } | 1893 | } |
1877 | 1894 | ||
1895 | static void pci_configure_ltr(struct pci_dev *dev) | ||
1896 | { | ||
1897 | #ifdef CONFIG_PCIEASPM | ||
1898 | u32 cap; | ||
1899 | struct pci_dev *bridge; | ||
1900 | |||
1901 | if (!pci_is_pcie(dev)) | ||
1902 | return; | ||
1903 | |||
1904 | pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap); | ||
1905 | if (!(cap & PCI_EXP_DEVCAP2_LTR)) | ||
1906 | return; | ||
1907 | |||
1908 | /* | ||
1909 | * Software must not enable LTR in an Endpoint unless the Root | ||
1910 | * Complex and all intermediate Switches indicate support for LTR. | ||
1911 | * PCIe r3.1, sec 6.18. | ||
1912 | */ | ||
1913 | if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) | ||
1914 | dev->ltr_path = 1; | ||
1915 | else { | ||
1916 | bridge = pci_upstream_bridge(dev); | ||
1917 | if (bridge && bridge->ltr_path) | ||
1918 | dev->ltr_path = 1; | ||
1919 | } | ||
1920 | |||
1921 | if (dev->ltr_path) | ||
1922 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, | ||
1923 | PCI_EXP_DEVCTL2_LTR_EN); | ||
1924 | #endif | ||
1925 | } | ||
1926 | |||
1878 | static void pci_configure_device(struct pci_dev *dev) | 1927 | static void pci_configure_device(struct pci_dev *dev) |
1879 | { | 1928 | { |
1880 | struct hotplug_params hpp; | 1929 | struct hotplug_params hpp; |
@@ -1883,6 +1932,7 @@ static void pci_configure_device(struct pci_dev *dev) | |||
1883 | pci_configure_mps(dev); | 1932 | pci_configure_mps(dev); |
1884 | pci_configure_extended_tags(dev, NULL); | 1933 | pci_configure_extended_tags(dev, NULL); |
1885 | pci_configure_relaxed_ordering(dev); | 1934 | pci_configure_relaxed_ordering(dev); |
1935 | pci_configure_ltr(dev); | ||
1886 | 1936 | ||
1887 | memset(&hpp, 0, sizeof(hpp)); | 1937 | memset(&hpp, 0, sizeof(hpp)); |
1888 | ret = pci_get_hp_params(dev, &hpp); | 1938 | ret = pci_get_hp_params(dev, &hpp); |
@@ -1902,10 +1952,11 @@ static void pci_release_capabilities(struct pci_dev *dev) | |||
1902 | } | 1952 | } |
1903 | 1953 | ||
1904 | /** | 1954 | /** |
1905 | * pci_release_dev - free a pci device structure when all users of it are finished. | 1955 | * pci_release_dev - Free a PCI device structure when all users of it are |
1956 | * finished | ||
1906 | * @dev: device that's been disconnected | 1957 | * @dev: device that's been disconnected |
1907 | * | 1958 | * |
1908 | * Will be called only by the device core when all users of this pci device are | 1959 | * Will be called only by the device core when all users of this PCI device are |
1909 | * done. | 1960 | * done. |
1910 | */ | 1961 | */ |
1911 | static void pci_release_dev(struct device *dev) | 1962 | static void pci_release_dev(struct device *dev) |
@@ -1993,7 +2044,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, | |||
1993 | if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) | 2044 | if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) |
1994 | return false; | 2045 | return false; |
1995 | 2046 | ||
1996 | /* some broken boards return 0 or ~0 if a slot is empty: */ | 2047 | /* Some broken boards return 0 or ~0 if a slot is empty: */ |
1997 | if (*l == 0xffffffff || *l == 0x00000000 || | 2048 | if (*l == 0xffffffff || *l == 0x00000000 || |
1998 | *l == 0x0000ffff || *l == 0xffff0000) | 2049 | *l == 0x0000ffff || *l == 0xffff0000) |
1999 | return false; | 2050 | return false; |
@@ -2006,8 +2057,8 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, | |||
2006 | EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); | 2057 | EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); |
2007 | 2058 | ||
2008 | /* | 2059 | /* |
2009 | * Read the config data for a PCI device, sanity-check it | 2060 | * Read the config data for a PCI device, sanity-check it, |
2010 | * and fill in the dev structure... | 2061 | * and fill in the dev structure. |
2011 | */ | 2062 | */ |
2012 | static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) | 2063 | static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) |
2013 | { | 2064 | { |
@@ -2073,7 +2124,7 @@ static void pci_init_capabilities(struct pci_dev *dev) | |||
2073 | } | 2124 | } |
2074 | 2125 | ||
2075 | /* | 2126 | /* |
2076 | * This is the equivalent of pci_host_bridge_msi_domain that acts on | 2127 | * This is the equivalent of pci_host_bridge_msi_domain() that acts on |
2077 | * devices. Firmware interfaces that can select the MSI domain on a | 2128 | * devices. Firmware interfaces that can select the MSI domain on a |
2078 | * per-device basis should be called from here. | 2129 | * per-device basis should be called from here. |
2079 | */ | 2130 | */ |
@@ -2082,7 +2133,7 @@ static struct irq_domain *pci_dev_msi_domain(struct pci_dev *dev) | |||
2082 | struct irq_domain *d; | 2133 | struct irq_domain *d; |
2083 | 2134 | ||
2084 | /* | 2135 | /* |
2085 | * If a domain has been set through the pcibios_add_device | 2136 | * If a domain has been set through the pcibios_add_device() |
2086 | * callback, then this is the one (platform code knows best). | 2137 | * callback, then this is the one (platform code knows best). |
2087 | */ | 2138 | */ |
2088 | d = dev_get_msi_domain(&dev->dev); | 2139 | d = dev_get_msi_domain(&dev->dev); |
@@ -2136,10 +2187,10 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | |||
2136 | /* Fix up broken headers */ | 2187 | /* Fix up broken headers */ |
2137 | pci_fixup_device(pci_fixup_header, dev); | 2188 | pci_fixup_device(pci_fixup_header, dev); |
2138 | 2189 | ||
2139 | /* moved out from quirk header fixup code */ | 2190 | /* Moved out from quirk header fixup code */ |
2140 | pci_reassigndev_resource_alignment(dev); | 2191 | pci_reassigndev_resource_alignment(dev); |
2141 | 2192 | ||
2142 | /* Clear the state_saved flag. */ | 2193 | /* Clear the state_saved flag */ |
2143 | dev->state_saved = false; | 2194 | dev->state_saved = false; |
2144 | 2195 | ||
2145 | /* Initialize various capabilities */ | 2196 | /* Initialize various capabilities */ |
@@ -2156,7 +2207,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | |||
2156 | ret = pcibios_add_device(dev); | 2207 | ret = pcibios_add_device(dev); |
2157 | WARN_ON(ret < 0); | 2208 | WARN_ON(ret < 0); |
2158 | 2209 | ||
2159 | /* Setup MSI irq domain */ | 2210 | /* Set up MSI IRQ domain */ |
2160 | pci_set_msi_domain(dev); | 2211 | pci_set_msi_domain(dev); |
2161 | 2212 | ||
2162 | /* Notifier could use PCI capabilities */ | 2213 | /* Notifier could use PCI capabilities */ |
@@ -2215,29 +2266,34 @@ static unsigned next_fn(struct pci_bus *bus, struct pci_dev *dev, unsigned fn) | |||
2215 | 2266 | ||
2216 | static int only_one_child(struct pci_bus *bus) | 2267 | static int only_one_child(struct pci_bus *bus) |
2217 | { | 2268 | { |
2218 | struct pci_dev *parent = bus->self; | 2269 | struct pci_dev *bridge = bus->self; |
2219 | 2270 | ||
2220 | if (!parent || !pci_is_pcie(parent)) | 2271 | /* |
2272 | * Systems with unusual topologies set PCI_SCAN_ALL_PCIE_DEVS so | ||
2273 | * we scan for all possible devices, not just Device 0. | ||
2274 | */ | ||
2275 | if (pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) | ||
2221 | return 0; | 2276 | return 0; |
2222 | if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT) | ||
2223 | return 1; | ||
2224 | 2277 | ||
2225 | /* | 2278 | /* |
2226 | * PCIe downstream ports are bridges that normally lead to only a | 2279 | * A PCIe Downstream Port normally leads to a Link with only Device |
2227 | * device 0, but if PCI_SCAN_ALL_PCIE_DEVS is set, scan all | 2280 | * 0 on it (PCIe spec r3.1, sec 7.3.1). As an optimization, scan |
2228 | * possible devices, not just device 0. See PCIe spec r3.0, | 2281 | * only for Device 0 in that situation. |
2229 | * sec 7.3.1. | 2282 | * |
2283 | * Checking has_secondary_link is a hack to identify Downstream | ||
2284 | * Ports because sometimes Switches are configured such that the | ||
2285 | * PCIe Port Type labels are backwards. | ||
2230 | */ | 2286 | */ |
2231 | if (parent->has_secondary_link && | 2287 | if (bridge && pci_is_pcie(bridge) && bridge->has_secondary_link) |
2232 | !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) | ||
2233 | return 1; | 2288 | return 1; |
2289 | |||
2234 | return 0; | 2290 | return 0; |
2235 | } | 2291 | } |
2236 | 2292 | ||
2237 | /** | 2293 | /** |
2238 | * pci_scan_slot - scan a PCI slot on a bus for devices. | 2294 | * pci_scan_slot - Scan a PCI slot on a bus for devices |
2239 | * @bus: PCI bus to scan | 2295 | * @bus: PCI bus to scan |
2240 | * @devfn: slot number to scan (must have zero function.) | 2296 | * @devfn: slot number to scan (must have zero function) |
2241 | * | 2297 | * |
2242 | * Scan a PCI slot on the specified PCI bus for devices, adding | 2298 | * Scan a PCI slot on the specified PCI bus for devices, adding |
2243 | * discovered devices to the @bus->devices list. New devices | 2299 | * discovered devices to the @bus->devices list. New devices |
@@ -2268,7 +2324,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) | |||
2268 | } | 2324 | } |
2269 | } | 2325 | } |
2270 | 2326 | ||
2271 | /* only one slot has pcie device */ | 2327 | /* Only one slot has PCIe device */ |
2272 | if (bus->self && nr) | 2328 | if (bus->self && nr) |
2273 | pcie_aspm_init_link_state(bus->self); | 2329 | pcie_aspm_init_link_state(bus->self); |
2274 | 2330 | ||
@@ -2317,7 +2373,9 @@ static void pcie_write_mps(struct pci_dev *dev, int mps) | |||
2317 | 2373 | ||
2318 | if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT && | 2374 | if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT && |
2319 | dev->bus->self) | 2375 | dev->bus->self) |
2320 | /* For "Performance", the assumption is made that | 2376 | |
2377 | /* | ||
2378 | * For "Performance", the assumption is made that | ||
2321 | * downstream communication will never be larger than | 2379 | * downstream communication will never be larger than |
2322 | * the MRRS. So, the MPS only needs to be configured | 2380 | * the MRRS. So, the MPS only needs to be configured |
2323 | * for the upstream communication. This being the case, | 2381 | * for the upstream communication. This being the case, |
@@ -2334,27 +2392,30 @@ static void pcie_write_mps(struct pci_dev *dev, int mps) | |||
2334 | 2392 | ||
2335 | rc = pcie_set_mps(dev, mps); | 2393 | rc = pcie_set_mps(dev, mps); |
2336 | if (rc) | 2394 | if (rc) |
2337 | dev_err(&dev->dev, "Failed attempting to set the MPS\n"); | 2395 | pci_err(dev, "Failed attempting to set the MPS\n"); |
2338 | } | 2396 | } |
2339 | 2397 | ||
2340 | static void pcie_write_mrrs(struct pci_dev *dev) | 2398 | static void pcie_write_mrrs(struct pci_dev *dev) |
2341 | { | 2399 | { |
2342 | int rc, mrrs; | 2400 | int rc, mrrs; |
2343 | 2401 | ||
2344 | /* In the "safe" case, do not configure the MRRS. There appear to be | 2402 | /* |
2403 | * In the "safe" case, do not configure the MRRS. There appear to be | ||
2345 | * issues with setting MRRS to 0 on a number of devices. | 2404 | * issues with setting MRRS to 0 on a number of devices. |
2346 | */ | 2405 | */ |
2347 | if (pcie_bus_config != PCIE_BUS_PERFORMANCE) | 2406 | if (pcie_bus_config != PCIE_BUS_PERFORMANCE) |
2348 | return; | 2407 | return; |
2349 | 2408 | ||
2350 | /* For Max performance, the MRRS must be set to the largest supported | 2409 | /* |
2410 | * For max performance, the MRRS must be set to the largest supported | ||
2351 | * value. However, it cannot be configured larger than the MPS the | 2411 | * value. However, it cannot be configured larger than the MPS the |
2352 | * device or the bus can support. This should already be properly | 2412 | * device or the bus can support. This should already be properly |
2353 | * configured by a prior call to pcie_write_mps. | 2413 | * configured by a prior call to pcie_write_mps(). |
2354 | */ | 2414 | */ |
2355 | mrrs = pcie_get_mps(dev); | 2415 | mrrs = pcie_get_mps(dev); |
2356 | 2416 | ||
2357 | /* MRRS is a R/W register. Invalid values can be written, but a | 2417 | /* |
2418 | * MRRS is a R/W register. Invalid values can be written, but a | ||
2358 | * subsequent read will verify if the value is acceptable or not. | 2419 | * subsequent read will verify if the value is acceptable or not. |
2359 | * If the MRRS value provided is not acceptable (e.g., too large), | 2420 | * If the MRRS value provided is not acceptable (e.g., too large), |
2360 | * shrink the value until it is acceptable to the HW. | 2421 | * shrink the value until it is acceptable to the HW. |
@@ -2364,12 +2425,12 @@ static void pcie_write_mrrs(struct pci_dev *dev) | |||
2364 | if (!rc) | 2425 | if (!rc) |
2365 | break; | 2426 | break; |
2366 | 2427 | ||
2367 | dev_warn(&dev->dev, "Failed attempting to set the MRRS\n"); | 2428 | pci_warn(dev, "Failed attempting to set the MRRS\n"); |
2368 | mrrs /= 2; | 2429 | mrrs /= 2; |
2369 | } | 2430 | } |
2370 | 2431 | ||
2371 | if (mrrs < 128) | 2432 | if (mrrs < 128) |
2372 | dev_err(&dev->dev, "MRRS was unable to be configured with a safe value. If problems are experienced, try running with pci=pcie_bus_safe\n"); | 2433 | pci_err(dev, "MRRS was unable to be configured with a safe value. If problems are experienced, try running with pci=pcie_bus_safe\n"); |
2373 | } | 2434 | } |
2374 | 2435 | ||
2375 | static int pcie_bus_configure_set(struct pci_dev *dev, void *data) | 2436 | static int pcie_bus_configure_set(struct pci_dev *dev, void *data) |
@@ -2389,14 +2450,15 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data) | |||
2389 | pcie_write_mps(dev, mps); | 2450 | pcie_write_mps(dev, mps); |
2390 | pcie_write_mrrs(dev); | 2451 | pcie_write_mrrs(dev); |
2391 | 2452 | ||
2392 | dev_info(&dev->dev, "Max Payload Size set to %4d/%4d (was %4d), Max Read Rq %4d\n", | 2453 | pci_info(dev, "Max Payload Size set to %4d/%4d (was %4d), Max Read Rq %4d\n", |
2393 | pcie_get_mps(dev), 128 << dev->pcie_mpss, | 2454 | pcie_get_mps(dev), 128 << dev->pcie_mpss, |
2394 | orig_mps, pcie_get_readrq(dev)); | 2455 | orig_mps, pcie_get_readrq(dev)); |
2395 | 2456 | ||
2396 | return 0; | 2457 | return 0; |
2397 | } | 2458 | } |
2398 | 2459 | ||
2399 | /* pcie_bus_configure_settings requires that pci_walk_bus work in a top-down, | 2460 | /* |
2461 | * pcie_bus_configure_settings() requires that pci_walk_bus work in a top-down, | ||
2400 | * parents then children fashion. If this changes, then this code will not | 2462 | * parents then children fashion. If this changes, then this code will not |
2401 | * work as designed. | 2463 | * work as designed. |
2402 | */ | 2464 | */ |
@@ -2410,7 +2472,8 @@ void pcie_bus_configure_settings(struct pci_bus *bus) | |||
2410 | if (!pci_is_pcie(bus->self)) | 2472 | if (!pci_is_pcie(bus->self)) |
2411 | return; | 2473 | return; |
2412 | 2474 | ||
2413 | /* FIXME - Peer to peer DMA is possible, though the endpoint would need | 2475 | /* |
2476 | * FIXME - Peer to peer DMA is possible, though the endpoint would need | ||
2414 | * to be aware of the MPS of the destination. To work around this, | 2477 | * to be aware of the MPS of the destination. To work around this, |
2415 | * simply force the MPS of the entire system to the smallest possible. | 2478 | * simply force the MPS of the entire system to the smallest possible. |
2416 | */ | 2479 | */ |
@@ -2464,7 +2527,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, | |||
2464 | for (devfn = 0; devfn < 0x100; devfn += 8) | 2527 | for (devfn = 0; devfn < 0x100; devfn += 8) |
2465 | pci_scan_slot(bus, devfn); | 2528 | pci_scan_slot(bus, devfn); |
2466 | 2529 | ||
2467 | /* Reserve buses for SR-IOV capability. */ | 2530 | /* Reserve buses for SR-IOV capability */ |
2468 | used_buses = pci_iov_bus_range(bus); | 2531 | used_buses = pci_iov_bus_range(bus); |
2469 | max += used_buses; | 2532 | max += used_buses; |
2470 | 2533 | ||
@@ -2506,6 +2569,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, | |||
2506 | unsigned int buses = 0; | 2569 | unsigned int buses = 0; |
2507 | 2570 | ||
2508 | if (!hotplug_bridges && normal_bridges == 1) { | 2571 | if (!hotplug_bridges && normal_bridges == 1) { |
2572 | |||
2509 | /* | 2573 | /* |
2510 | * There is only one bridge on the bus (upstream | 2574 | * There is only one bridge on the bus (upstream |
2511 | * port) so it gets all available buses which it | 2575 | * port) so it gets all available buses which it |
@@ -2514,6 +2578,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, | |||
2514 | */ | 2578 | */ |
2515 | buses = available_buses; | 2579 | buses = available_buses; |
2516 | } else if (dev->is_hotplug_bridge) { | 2580 | } else if (dev->is_hotplug_bridge) { |
2581 | |||
2517 | /* | 2582 | /* |
2518 | * Distribute the extra buses between hotplug | 2583 | * Distribute the extra buses between hotplug |
2519 | * bridges if any. | 2584 | * bridges if any. |
@@ -2572,8 +2637,8 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) | |||
2572 | EXPORT_SYMBOL_GPL(pci_scan_child_bus); | 2637 | EXPORT_SYMBOL_GPL(pci_scan_child_bus); |
2573 | 2638 | ||
2574 | /** | 2639 | /** |
2575 | * pcibios_root_bridge_prepare - Platform-specific host bridge setup. | 2640 | * pcibios_root_bridge_prepare - Platform-specific host bridge setup |
2576 | * @bridge: Host bridge to set up. | 2641 | * @bridge: Host bridge to set up |
2577 | * | 2642 | * |
2578 | * Default empty implementation. Replace with an architecture-specific setup | 2643 | * Default empty implementation. Replace with an architecture-specific setup |
2579 | * routine, if necessary. | 2644 | * routine, if necessary. |
@@ -2620,6 +2685,39 @@ err_out: | |||
2620 | } | 2685 | } |
2621 | EXPORT_SYMBOL_GPL(pci_create_root_bus); | 2686 | EXPORT_SYMBOL_GPL(pci_create_root_bus); |
2622 | 2687 | ||
2688 | int pci_host_probe(struct pci_host_bridge *bridge) | ||
2689 | { | ||
2690 | struct pci_bus *bus, *child; | ||
2691 | int ret; | ||
2692 | |||
2693 | ret = pci_scan_root_bus_bridge(bridge); | ||
2694 | if (ret < 0) { | ||
2695 | dev_err(bridge->dev.parent, "Scanning root bridge failed"); | ||
2696 | return ret; | ||
2697 | } | ||
2698 | |||
2699 | bus = bridge->bus; | ||
2700 | |||
2701 | /* | ||
2702 | * We insert PCI resources into the iomem_resource and | ||
2703 | * ioport_resource trees in either pci_bus_claim_resources() | ||
2704 | * or pci_bus_assign_resources(). | ||
2705 | */ | ||
2706 | if (pci_has_flag(PCI_PROBE_ONLY)) { | ||
2707 | pci_bus_claim_resources(bus); | ||
2708 | } else { | ||
2709 | pci_bus_size_bridges(bus); | ||
2710 | pci_bus_assign_resources(bus); | ||
2711 | |||
2712 | list_for_each_entry(child, &bus->children, node) | ||
2713 | pcie_bus_configure_settings(child); | ||
2714 | } | ||
2715 | |||
2716 | pci_bus_add_devices(bus); | ||
2717 | return 0; | ||
2718 | } | ||
2719 | EXPORT_SYMBOL_GPL(pci_host_probe); | ||
2720 | |||
2623 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) | 2721 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) |
2624 | { | 2722 | { |
2625 | struct resource *res = &b->busn_res; | 2723 | struct resource *res = &b->busn_res; |
@@ -2776,7 +2874,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, | |||
2776 | EXPORT_SYMBOL(pci_scan_bus); | 2874 | EXPORT_SYMBOL(pci_scan_bus); |
2777 | 2875 | ||
2778 | /** | 2876 | /** |
2779 | * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. | 2877 | * pci_rescan_bus_bridge_resize - Scan a PCI bus for devices |
2780 | * @bridge: PCI bridge for the bus to scan | 2878 | * @bridge: PCI bridge for the bus to scan |
2781 | * | 2879 | * |
2782 | * Scan a PCI bus and child buses for new devices, add them, | 2880 | * Scan a PCI bus and child buses for new devices, add them, |
@@ -2801,11 +2899,11 @@ unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge) | |||
2801 | } | 2899 | } |
2802 | 2900 | ||
2803 | /** | 2901 | /** |
2804 | * pci_rescan_bus - scan a PCI bus for devices. | 2902 | * pci_rescan_bus - Scan a PCI bus for devices |
2805 | * @bus: PCI bus to scan | 2903 | * @bus: PCI bus to scan |
2806 | * | 2904 | * |
2807 | * Scan a PCI bus and child buses for new devices, adds them, | 2905 | * Scan a PCI bus and child buses for new devices, add them, |
2808 | * and enables them. | 2906 | * and enable them. |
2809 | * | 2907 | * |
2810 | * Returns the max number of subordinate bus discovered. | 2908 | * Returns the max number of subordinate bus discovered. |
2811 | */ | 2909 | */ |
@@ -2874,7 +2972,7 @@ int pci_hp_add_bridge(struct pci_dev *dev) | |||
2874 | break; | 2972 | break; |
2875 | } | 2973 | } |
2876 | if (busnr-- > end) { | 2974 | if (busnr-- > end) { |
2877 | dev_err(&dev->dev, "No bus number available for hot-added bridge\n"); | 2975 | pci_err(dev, "No bus number available for hot-added bridge\n"); |
2878 | return -1; | 2976 | return -1; |
2879 | } | 2977 | } |
2880 | 2978 | ||
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 10684b17d0bd..fc734014206f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/acpi.h> | 21 | #include <linux/acpi.h> |
22 | #include <linux/kallsyms.h> | ||
23 | #include <linux/dmi.h> | 22 | #include <linux/dmi.h> |
24 | #include <linux/pci-aspm.h> | 23 | #include <linux/pci-aspm.h> |
25 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
@@ -66,7 +65,7 @@ static void quirk_passive_release(struct pci_dev *dev) | |||
66 | while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) { | 65 | while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) { |
67 | pci_read_config_byte(d, 0x82, &dlc); | 66 | pci_read_config_byte(d, 0x82, &dlc); |
68 | if (!(dlc & 1<<1)) { | 67 | if (!(dlc & 1<<1)) { |
69 | dev_info(&d->dev, "PIIX3: Enabling Passive Release\n"); | 68 | pci_info(d, "PIIX3: Enabling Passive Release\n"); |
70 | dlc |= 1<<1; | 69 | dlc |= 1<<1; |
71 | pci_write_config_byte(d, 0x82, dlc); | 70 | pci_write_config_byte(d, 0x82, dlc); |
72 | } | 71 | } |
@@ -86,7 +85,7 @@ static void quirk_isa_dma_hangs(struct pci_dev *dev) | |||
86 | { | 85 | { |
87 | if (!isa_dma_bridge_buggy) { | 86 | if (!isa_dma_bridge_buggy) { |
88 | isa_dma_bridge_buggy = 1; | 87 | isa_dma_bridge_buggy = 1; |
89 | dev_info(&dev->dev, "Activating ISA DMA hang workarounds\n"); | 88 | pci_info(dev, "Activating ISA DMA hang workarounds\n"); |
90 | } | 89 | } |
91 | } | 90 | } |
92 | /* | 91 | /* |
@@ -115,7 +114,7 @@ static void quirk_tigerpoint_bm_sts(struct pci_dev *dev) | |||
115 | pm1a = inw(pmbase); | 114 | pm1a = inw(pmbase); |
116 | 115 | ||
117 | if (pm1a & 0x10) { | 116 | if (pm1a & 0x10) { |
118 | dev_info(&dev->dev, FW_BUG "TigerPoint LPC.BM_STS cleared\n"); | 117 | pci_info(dev, FW_BUG "TigerPoint LPC.BM_STS cleared\n"); |
119 | outw(0x10, pmbase); | 118 | outw(0x10, pmbase); |
120 | } | 119 | } |
121 | } | 120 | } |
@@ -127,7 +126,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TGP_LPC, quirk | |||
127 | static void quirk_nopcipci(struct pci_dev *dev) | 126 | static void quirk_nopcipci(struct pci_dev *dev) |
128 | { | 127 | { |
129 | if ((pci_pci_problems & PCIPCI_FAIL) == 0) { | 128 | if ((pci_pci_problems & PCIPCI_FAIL) == 0) { |
130 | dev_info(&dev->dev, "Disabling direct PCI/PCI transfers\n"); | 129 | pci_info(dev, "Disabling direct PCI/PCI transfers\n"); |
131 | pci_pci_problems |= PCIPCI_FAIL; | 130 | pci_pci_problems |= PCIPCI_FAIL; |
132 | } | 131 | } |
133 | } | 132 | } |
@@ -140,7 +139,7 @@ static void quirk_nopciamd(struct pci_dev *dev) | |||
140 | pci_read_config_byte(dev, 0x08, &rev); | 139 | pci_read_config_byte(dev, 0x08, &rev); |
141 | if (rev == 0x13) { | 140 | if (rev == 0x13) { |
142 | /* Erratum 24 */ | 141 | /* Erratum 24 */ |
143 | dev_info(&dev->dev, "Chipset erratum: Disabling direct PCI/AGP transfers\n"); | 142 | pci_info(dev, "Chipset erratum: Disabling direct PCI/AGP transfers\n"); |
144 | pci_pci_problems |= PCIAGP_FAIL; | 143 | pci_pci_problems |= PCIAGP_FAIL; |
145 | } | 144 | } |
146 | } | 145 | } |
@@ -152,7 +151,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8151_0, quirk_nopci | |||
152 | static void quirk_triton(struct pci_dev *dev) | 151 | static void quirk_triton(struct pci_dev *dev) |
153 | { | 152 | { |
154 | if ((pci_pci_problems&PCIPCI_TRITON) == 0) { | 153 | if ((pci_pci_problems&PCIPCI_TRITON) == 0) { |
155 | dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); | 154 | pci_info(dev, "Limiting direct PCI/PCI transfers\n"); |
156 | pci_pci_problems |= PCIPCI_TRITON; | 155 | pci_pci_problems |= PCIPCI_TRITON; |
157 | } | 156 | } |
158 | } | 157 | } |
@@ -212,7 +211,7 @@ static void quirk_vialatency(struct pci_dev *dev) | |||
212 | busarb &= ~(1<<5); | 211 | busarb &= ~(1<<5); |
213 | busarb |= (1<<4); | 212 | busarb |= (1<<4); |
214 | pci_write_config_byte(dev, 0x76, busarb); | 213 | pci_write_config_byte(dev, 0x76, busarb); |
215 | dev_info(&dev->dev, "Applying VIA southbridge workaround\n"); | 214 | pci_info(dev, "Applying VIA southbridge workaround\n"); |
216 | exit: | 215 | exit: |
217 | pci_dev_put(p); | 216 | pci_dev_put(p); |
218 | } | 217 | } |
@@ -230,7 +229,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, quirk_viala | |||
230 | static void quirk_viaetbf(struct pci_dev *dev) | 229 | static void quirk_viaetbf(struct pci_dev *dev) |
231 | { | 230 | { |
232 | if ((pci_pci_problems&PCIPCI_VIAETBF) == 0) { | 231 | if ((pci_pci_problems&PCIPCI_VIAETBF) == 0) { |
233 | dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); | 232 | pci_info(dev, "Limiting direct PCI/PCI transfers\n"); |
234 | pci_pci_problems |= PCIPCI_VIAETBF; | 233 | pci_pci_problems |= PCIPCI_VIAETBF; |
235 | } | 234 | } |
236 | } | 235 | } |
@@ -239,7 +238,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_via | |||
239 | static void quirk_vsfx(struct pci_dev *dev) | 238 | static void quirk_vsfx(struct pci_dev *dev) |
240 | { | 239 | { |
241 | if ((pci_pci_problems&PCIPCI_VSFX) == 0) { | 240 | if ((pci_pci_problems&PCIPCI_VSFX) == 0) { |
242 | dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); | 241 | pci_info(dev, "Limiting direct PCI/PCI transfers\n"); |
243 | pci_pci_problems |= PCIPCI_VSFX; | 242 | pci_pci_problems |= PCIPCI_VSFX; |
244 | } | 243 | } |
245 | } | 244 | } |
@@ -254,7 +253,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576, quirk_vsfx) | |||
254 | static void quirk_alimagik(struct pci_dev *dev) | 253 | static void quirk_alimagik(struct pci_dev *dev) |
255 | { | 254 | { |
256 | if ((pci_pci_problems&PCIPCI_ALIMAGIK) == 0) { | 255 | if ((pci_pci_problems&PCIPCI_ALIMAGIK) == 0) { |
257 | dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); | 256 | pci_info(dev, "Limiting direct PCI/PCI transfers\n"); |
258 | pci_pci_problems |= PCIPCI_ALIMAGIK|PCIPCI_TRITON; | 257 | pci_pci_problems |= PCIPCI_ALIMAGIK|PCIPCI_TRITON; |
259 | } | 258 | } |
260 | } | 259 | } |
@@ -268,7 +267,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1651, quirk_alimagi | |||
268 | static void quirk_natoma(struct pci_dev *dev) | 267 | static void quirk_natoma(struct pci_dev *dev) |
269 | { | 268 | { |
270 | if ((pci_pci_problems&PCIPCI_NATOMA) == 0) { | 269 | if ((pci_pci_problems&PCIPCI_NATOMA) == 0) { |
271 | dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); | 270 | pci_info(dev, "Limiting direct PCI/PCI transfers\n"); |
272 | pci_pci_problems |= PCIPCI_NATOMA; | 271 | pci_pci_problems |= PCIPCI_NATOMA; |
273 | } | 272 | } |
274 | } | 273 | } |
@@ -313,7 +312,7 @@ static void quirk_extend_bar_to_page(struct pci_dev *dev) | |||
313 | r->end = PAGE_SIZE - 1; | 312 | r->end = PAGE_SIZE - 1; |
314 | r->start = 0; | 313 | r->start = 0; |
315 | r->flags |= IORESOURCE_UNSET; | 314 | r->flags |= IORESOURCE_UNSET; |
316 | dev_info(&dev->dev, "expanded BAR %d to page size: %pR\n", | 315 | pci_info(dev, "expanded BAR %d to page size: %pR\n", |
317 | i, r); | 316 | i, r); |
318 | } | 317 | } |
319 | } | 318 | } |
@@ -360,7 +359,7 @@ static void quirk_io(struct pci_dev *dev, int pos, unsigned size, | |||
360 | bus_region.end = region + size - 1; | 359 | bus_region.end = region + size - 1; |
361 | pcibios_bus_to_resource(dev->bus, res, &bus_region); | 360 | pcibios_bus_to_resource(dev->bus, res, &bus_region); |
362 | 361 | ||
363 | dev_info(&dev->dev, FW_BUG "%s quirk: reg 0x%x: %pR\n", | 362 | pci_info(dev, FW_BUG "%s quirk: reg 0x%x: %pR\n", |
364 | name, PCI_BASE_ADDRESS_0 + (pos << 2), res); | 363 | name, PCI_BASE_ADDRESS_0 + (pos << 2), res); |
365 | } | 364 | } |
366 | 365 | ||
@@ -381,7 +380,7 @@ static void quirk_cs5536_vsa(struct pci_dev *dev) | |||
381 | quirk_io(dev, 0, 8, name); /* SMB */ | 380 | quirk_io(dev, 0, 8, name); /* SMB */ |
382 | quirk_io(dev, 1, 256, name); /* GPIO */ | 381 | quirk_io(dev, 1, 256, name); /* GPIO */ |
383 | quirk_io(dev, 2, 64, name); /* MFGPT */ | 382 | quirk_io(dev, 2, 64, name); /* MFGPT */ |
384 | dev_info(&dev->dev, "%s bug detected (incorrect header); workaround applied\n", | 383 | pci_info(dev, "%s bug detected (incorrect header); workaround applied\n", |
385 | name); | 384 | name); |
386 | } | 385 | } |
387 | } | 386 | } |
@@ -409,7 +408,7 @@ static void quirk_io_region(struct pci_dev *dev, int port, | |||
409 | pcibios_bus_to_resource(dev->bus, res, &bus_region); | 408 | pcibios_bus_to_resource(dev->bus, res, &bus_region); |
410 | 409 | ||
411 | if (!pci_claim_resource(dev, nr)) | 410 | if (!pci_claim_resource(dev, nr)) |
412 | dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name); | 411 | pci_info(dev, "quirk: %pR claimed by %s\n", res, name); |
413 | } | 412 | } |
414 | 413 | ||
415 | /* | 414 | /* |
@@ -418,7 +417,7 @@ static void quirk_io_region(struct pci_dev *dev, int port, | |||
418 | */ | 417 | */ |
419 | static void quirk_ati_exploding_mce(struct pci_dev *dev) | 418 | static void quirk_ati_exploding_mce(struct pci_dev *dev) |
420 | { | 419 | { |
421 | dev_info(&dev->dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n"); | 420 | pci_info(dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n"); |
422 | /* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */ | 421 | /* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */ |
423 | request_region(0x3b0, 0x0C, "RadeonIGP"); | 422 | request_region(0x3b0, 0x0C, "RadeonIGP"); |
424 | request_region(0x3d3, 0x01, "RadeonIGP"); | 423 | request_region(0x3d3, 0x01, "RadeonIGP"); |
@@ -441,7 +440,7 @@ static void quirk_amd_nl_class(struct pci_dev *pdev) | |||
441 | 440 | ||
442 | /* Use "USB Device (not host controller)" class */ | 441 | /* Use "USB Device (not host controller)" class */ |
443 | pdev->class = PCI_CLASS_SERIAL_USB_DEVICE; | 442 | pdev->class = PCI_CLASS_SERIAL_USB_DEVICE; |
444 | dev_info(&pdev->dev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n", | 443 | pci_info(pdev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n", |
445 | class, pdev->class); | 444 | class, pdev->class); |
446 | } | 445 | } |
447 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB, | 446 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB, |
@@ -488,8 +487,7 @@ static void piix4_io_quirk(struct pci_dev *dev, const char *name, unsigned int p | |||
488 | * let's get enough confirmation reports first. | 487 | * let's get enough confirmation reports first. |
489 | */ | 488 | */ |
490 | base &= -size; | 489 | base &= -size; |
491 | dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, | 490 | pci_info(dev, "%s PIO at %04x-%04x\n", name, base, base + size - 1); |
492 | base + size - 1); | ||
493 | } | 491 | } |
494 | 492 | ||
495 | static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable) | 493 | static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable) |
@@ -514,8 +512,7 @@ static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int | |||
514 | * reserve it, but let's get enough confirmation reports first. | 512 | * reserve it, but let's get enough confirmation reports first. |
515 | */ | 513 | */ |
516 | base &= -size; | 514 | base &= -size; |
517 | dev_info(&dev->dev, "%s MMIO at %04x-%04x\n", name, base, | 515 | pci_info(dev, "%s MMIO at %04x-%04x\n", name, base, base + size - 1); |
518 | base + size - 1); | ||
519 | } | 516 | } |
520 | 517 | ||
521 | /* | 518 | /* |
@@ -644,7 +641,7 @@ static void ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const cha | |||
644 | base &= ~(size-1); | 641 | base &= ~(size-1); |
645 | 642 | ||
646 | /* Just print it out for now. We should reserve it after more debugging */ | 643 | /* Just print it out for now. We should reserve it after more debugging */ |
647 | dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base+size-1); | 644 | pci_info(dev, "%s PIO at %04x-%04x\n", name, base, base+size-1); |
648 | } | 645 | } |
649 | 646 | ||
650 | static void quirk_ich6_lpc(struct pci_dev *dev) | 647 | static void quirk_ich6_lpc(struct pci_dev *dev) |
@@ -679,7 +676,7 @@ static void ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const cha | |||
679 | mask |= 3; | 676 | mask |= 3; |
680 | 677 | ||
681 | /* Just print it out for now. We should reserve it after more debugging */ | 678 | /* Just print it out for now. We should reserve it after more debugging */ |
682 | dev_info(&dev->dev, "%s PIO at %04x (mask %04x)\n", name, base, mask); | 679 | pci_info(dev, "%s PIO at %04x (mask %04x)\n", name, base, mask); |
683 | } | 680 | } |
684 | 681 | ||
685 | /* ICH7-10 has the same common LPC generic IO decode registers */ | 682 | /* ICH7-10 has the same common LPC generic IO decode registers */ |
@@ -758,7 +755,7 @@ static void quirk_xio2000a(struct pci_dev *dev) | |||
758 | struct pci_dev *pdev; | 755 | struct pci_dev *pdev; |
759 | u16 command; | 756 | u16 command; |
760 | 757 | ||
761 | dev_warn(&dev->dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n"); | 758 | pci_warn(dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n"); |
762 | list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) { | 759 | list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) { |
763 | pci_read_config_word(pdev, PCI_COMMAND, &command); | 760 | pci_read_config_word(pdev, PCI_COMMAND, &command); |
764 | if (command & PCI_COMMAND_FAST_BACK) | 761 | if (command & PCI_COMMAND_FAST_BACK) |
@@ -788,7 +785,7 @@ static void quirk_via_ioapic(struct pci_dev *dev) | |||
788 | else | 785 | else |
789 | tmp = 0x1f; /* all known bits (4-0) routed to external APIC */ | 786 | tmp = 0x1f; /* all known bits (4-0) routed to external APIC */ |
790 | 787 | ||
791 | dev_info(&dev->dev, "%sbling VIA external APIC routing\n", | 788 | pci_info(dev, "%sbling VIA external APIC routing\n", |
792 | tmp == 0 ? "Disa" : "Ena"); | 789 | tmp == 0 ? "Disa" : "Ena"); |
793 | 790 | ||
794 | /* Offset 0x58: External APIC IRQ output control */ | 791 | /* Offset 0x58: External APIC IRQ output control */ |
@@ -810,7 +807,7 @@ static void quirk_via_vt8237_bypass_apic_deassert(struct pci_dev *dev) | |||
810 | 807 | ||
811 | pci_read_config_byte(dev, 0x5B, &misc_control2); | 808 | pci_read_config_byte(dev, 0x5B, &misc_control2); |
812 | if (!(misc_control2 & BYPASS_APIC_DEASSERT)) { | 809 | if (!(misc_control2 & BYPASS_APIC_DEASSERT)) { |
813 | dev_info(&dev->dev, "Bypassing VIA 8237 APIC De-Assert Message\n"); | 810 | pci_info(dev, "Bypassing VIA 8237 APIC De-Assert Message\n"); |
814 | pci_write_config_byte(dev, 0x5B, misc_control2|BYPASS_APIC_DEASSERT); | 811 | pci_write_config_byte(dev, 0x5B, misc_control2|BYPASS_APIC_DEASSERT); |
815 | } | 812 | } |
816 | } | 813 | } |
@@ -829,8 +826,8 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk | |||
829 | static void quirk_amd_ioapic(struct pci_dev *dev) | 826 | static void quirk_amd_ioapic(struct pci_dev *dev) |
830 | { | 827 | { |
831 | if (dev->revision >= 0x02) { | 828 | if (dev->revision >= 0x02) { |
832 | dev_warn(&dev->dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n"); | 829 | pci_warn(dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n"); |
833 | dev_warn(&dev->dev, " : booting with the \"noapic\" option\n"); | 830 | pci_warn(dev, " : booting with the \"noapic\" option\n"); |
834 | } | 831 | } |
835 | } | 832 | } |
836 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, quirk_amd_ioapic); | 833 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, quirk_amd_ioapic); |
@@ -854,7 +851,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CAVIUM, 0xa018, quirk_cavium_sriov_rnm_lin | |||
854 | static void quirk_amd_8131_mmrbc(struct pci_dev *dev) | 851 | static void quirk_amd_8131_mmrbc(struct pci_dev *dev) |
855 | { | 852 | { |
856 | if (dev->subordinate && dev->revision <= 0x12) { | 853 | if (dev->subordinate && dev->revision <= 0x12) { |
857 | dev_info(&dev->dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n", | 854 | pci_info(dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n", |
858 | dev->revision); | 855 | dev->revision); |
859 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MMRBC; | 856 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MMRBC; |
860 | } | 857 | } |
@@ -962,7 +959,7 @@ static void quirk_via_vlink(struct pci_dev *dev) | |||
962 | 959 | ||
963 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); | 960 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); |
964 | if (new_irq != irq) { | 961 | if (new_irq != irq) { |
965 | dev_info(&dev->dev, "VIA VLink IRQ fixup, from %d to %d\n", | 962 | pci_info(dev, "VIA VLink IRQ fixup, from %d to %d\n", |
966 | irq, new_irq); | 963 | irq, new_irq); |
967 | udelay(15); /* unknown if delay really needed */ | 964 | udelay(15); /* unknown if delay really needed */ |
968 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); | 965 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); |
@@ -1011,7 +1008,7 @@ static void quirk_amd_ordering(struct pci_dev *dev) | |||
1011 | pci_read_config_dword(dev, 0x4C, &pcic); | 1008 | pci_read_config_dword(dev, 0x4C, &pcic); |
1012 | if ((pcic & 6) != 6) { | 1009 | if ((pcic & 6) != 6) { |
1013 | pcic |= 6; | 1010 | pcic |= 6; |
1014 | dev_warn(&dev->dev, "BIOS failed to enable PCI standards compliance; fixing this error\n"); | 1011 | pci_warn(dev, "BIOS failed to enable PCI standards compliance; fixing this error\n"); |
1015 | pci_write_config_dword(dev, 0x4C, pcic); | 1012 | pci_write_config_dword(dev, 0x4C, pcic); |
1016 | pci_read_config_dword(dev, 0x84, &pcic); | 1013 | pci_read_config_dword(dev, 0x84, &pcic); |
1017 | pcic |= (1 << 23); /* Required in this mode */ | 1014 | pcic |= (1 << 23); /* Required in this mode */ |
@@ -1064,7 +1061,7 @@ static void quirk_mediagx_master(struct pci_dev *dev) | |||
1064 | pci_read_config_byte(dev, 0x41, ®); | 1061 | pci_read_config_byte(dev, 0x41, ®); |
1065 | if (reg & 2) { | 1062 | if (reg & 2) { |
1066 | reg &= ~2; | 1063 | reg &= ~2; |
1067 | dev_info(&dev->dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", | 1064 | pci_info(dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", |
1068 | reg); | 1065 | reg); |
1069 | pci_write_config_byte(dev, 0x41, reg); | 1066 | pci_write_config_byte(dev, 0x41, reg); |
1070 | } | 1067 | } |
@@ -1087,7 +1084,7 @@ static void quirk_disable_pxb(struct pci_dev *pdev) | |||
1087 | if (config & (1<<6)) { | 1084 | if (config & (1<<6)) { |
1088 | config &= ~(1<<6); | 1085 | config &= ~(1<<6); |
1089 | pci_write_config_word(pdev, 0x40, config); | 1086 | pci_write_config_word(pdev, 0x40, config); |
1090 | dev_info(&pdev->dev, "C0 revision 450NX. Disabling PCI restreaming\n"); | 1087 | pci_info(pdev, "C0 revision 450NX. Disabling PCI restreaming\n"); |
1091 | } | 1088 | } |
1092 | } | 1089 | } |
1093 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); | 1090 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); |
@@ -1107,7 +1104,7 @@ static void quirk_amd_ide_mode(struct pci_dev *pdev) | |||
1107 | pci_write_config_byte(pdev, 0x40, tmp); | 1104 | pci_write_config_byte(pdev, 0x40, tmp); |
1108 | 1105 | ||
1109 | pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; | 1106 | pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; |
1110 | dev_info(&pdev->dev, "set SATA to AHCI mode\n"); | 1107 | pci_info(pdev, "set SATA to AHCI mode\n"); |
1111 | } | 1108 | } |
1112 | } | 1109 | } |
1113 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); | 1110 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); |
@@ -1145,7 +1142,7 @@ static void quirk_ide_samemode(struct pci_dev *pdev) | |||
1145 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); | 1142 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); |
1146 | 1143 | ||
1147 | if (((prog & 1) && !(prog & 4)) || ((prog & 4) && !(prog & 1))) { | 1144 | if (((prog & 1) && !(prog & 4)) || ((prog & 4) && !(prog & 1))) { |
1148 | dev_info(&pdev->dev, "IDE mode mismatch; forcing legacy mode\n"); | 1145 | pci_info(pdev, "IDE mode mismatch; forcing legacy mode\n"); |
1149 | prog &= ~5; | 1146 | prog &= ~5; |
1150 | pdev->class &= ~5; | 1147 | pdev->class &= ~5; |
1151 | pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); | 1148 | pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); |
@@ -1356,10 +1353,10 @@ static void asus_hides_smbus_lpc(struct pci_dev *dev) | |||
1356 | pci_write_config_word(dev, 0xF2, val & (~0x8)); | 1353 | pci_write_config_word(dev, 0xF2, val & (~0x8)); |
1357 | pci_read_config_word(dev, 0xF2, &val); | 1354 | pci_read_config_word(dev, 0xF2, &val); |
1358 | if (val & 0x8) | 1355 | if (val & 0x8) |
1359 | dev_info(&dev->dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n", | 1356 | pci_info(dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n", |
1360 | val); | 1357 | val); |
1361 | else | 1358 | else |
1362 | dev_info(&dev->dev, "Enabled i801 SMBus device\n"); | 1359 | pci_info(dev, "Enabled i801 SMBus device\n"); |
1363 | } | 1360 | } |
1364 | } | 1361 | } |
1365 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); | 1362 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); |
@@ -1411,7 +1408,7 @@ static void asus_hides_smbus_lpc_ich6_resume(struct pci_dev *dev) | |||
1411 | return; | 1408 | return; |
1412 | iounmap(asus_rcba_base); | 1409 | iounmap(asus_rcba_base); |
1413 | asus_rcba_base = NULL; | 1410 | asus_rcba_base = NULL; |
1414 | dev_info(&dev->dev, "Enabled ICH6/i801 SMBus device\n"); | 1411 | pci_info(dev, "Enabled ICH6/i801 SMBus device\n"); |
1415 | } | 1412 | } |
1416 | 1413 | ||
1417 | static void asus_hides_smbus_lpc_ich6(struct pci_dev *dev) | 1414 | static void asus_hides_smbus_lpc_ich6(struct pci_dev *dev) |
@@ -1433,7 +1430,7 @@ static void quirk_sis_96x_smbus(struct pci_dev *dev) | |||
1433 | u8 val = 0; | 1430 | u8 val = 0; |
1434 | pci_read_config_byte(dev, 0x77, &val); | 1431 | pci_read_config_byte(dev, 0x77, &val); |
1435 | if (val & 0x10) { | 1432 | if (val & 0x10) { |
1436 | dev_info(&dev->dev, "Enabling SiS 96x SMBus\n"); | 1433 | pci_info(dev, "Enabling SiS 96x SMBus\n"); |
1437 | pci_write_config_byte(dev, 0x77, val & ~0x10); | 1434 | pci_write_config_byte(dev, 0x77, val & ~0x10); |
1438 | } | 1435 | } |
1439 | } | 1436 | } |
@@ -1505,10 +1502,10 @@ static void asus_hides_ac97_lpc(struct pci_dev *dev) | |||
1505 | pci_write_config_byte(dev, 0x50, val & (~0xc0)); | 1502 | pci_write_config_byte(dev, 0x50, val & (~0xc0)); |
1506 | pci_read_config_byte(dev, 0x50, &val); | 1503 | pci_read_config_byte(dev, 0x50, &val); |
1507 | if (val & 0xc0) | 1504 | if (val & 0xc0) |
1508 | dev_info(&dev->dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", | 1505 | pci_info(dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", |
1509 | val); | 1506 | val); |
1510 | else | 1507 | else |
1511 | dev_info(&dev->dev, "Enabled onboard AC97/MC97 devices\n"); | 1508 | pci_info(dev, "Enabled onboard AC97/MC97 devices\n"); |
1512 | } | 1509 | } |
1513 | } | 1510 | } |
1514 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); | 1511 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); |
@@ -1599,7 +1596,7 @@ static void quirk_jmicron_async_suspend(struct pci_dev *dev) | |||
1599 | { | 1596 | { |
1600 | if (dev->multifunction) { | 1597 | if (dev->multifunction) { |
1601 | device_disable_async_suspend(&dev->dev); | 1598 | device_disable_async_suspend(&dev->dev); |
1602 | dev_info(&dev->dev, "async suspend disabled to avoid multi-function power-on ordering issue\n"); | 1599 | pci_info(dev, "async suspend disabled to avoid multi-function power-on ordering issue\n"); |
1603 | } | 1600 | } |
1604 | } | 1601 | } |
1605 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE, 8, quirk_jmicron_async_suspend); | 1602 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE, 8, quirk_jmicron_async_suspend); |
@@ -1636,8 +1633,8 @@ static void quirk_pcie_mch(struct pci_dev *pdev) | |||
1636 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_pcie_mch); | 1633 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_pcie_mch); |
1637 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch); | 1634 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch); |
1638 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_pcie_mch); | 1635 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_pcie_mch); |
1639 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, quirk_pcie_mch); | ||
1640 | 1636 | ||
1637 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI, 8, quirk_pcie_mch); | ||
1641 | 1638 | ||
1642 | /* | 1639 | /* |
1643 | * It's possible for the MSI to get corrupted if shpc and acpi | 1640 | * It's possible for the MSI to get corrupted if shpc and acpi |
@@ -1646,7 +1643,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, quirk_pcie_mch); | |||
1646 | static void quirk_pcie_pxh(struct pci_dev *dev) | 1643 | static void quirk_pcie_pxh(struct pci_dev *dev) |
1647 | { | 1644 | { |
1648 | dev->no_msi = 1; | 1645 | dev->no_msi = 1; |
1649 | dev_warn(&dev->dev, "PXH quirk detected; SHPC device MSI disabled\n"); | 1646 | pci_warn(dev, "PXH quirk detected; SHPC device MSI disabled\n"); |
1650 | } | 1647 | } |
1651 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_0, quirk_pcie_pxh); | 1648 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_0, quirk_pcie_pxh); |
1652 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_1, quirk_pcie_pxh); | 1649 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_1, quirk_pcie_pxh); |
@@ -1692,7 +1689,7 @@ static void quirk_radeon_pm(struct pci_dev *dev) | |||
1692 | dev->subsystem_device == 0x00e2) { | 1689 | dev->subsystem_device == 0x00e2) { |
1693 | if (dev->d3_delay < 20) { | 1690 | if (dev->d3_delay < 20) { |
1694 | dev->d3_delay = 20; | 1691 | dev->d3_delay = 20; |
1695 | dev_info(&dev->dev, "extending delay after power-on from D3 to %d msec\n", | 1692 | pci_info(dev, "extending delay after power-on from D3 to %d msec\n", |
1696 | dev->d3_delay); | 1693 | dev->d3_delay); |
1697 | } | 1694 | } |
1698 | } | 1695 | } |
@@ -1736,7 +1733,7 @@ static void quirk_reroute_to_boot_interrupts_intel(struct pci_dev *dev) | |||
1736 | return; | 1733 | return; |
1737 | 1734 | ||
1738 | dev->irq_reroute_variant = INTEL_IRQ_REROUTE_VARIANT; | 1735 | dev->irq_reroute_variant = INTEL_IRQ_REROUTE_VARIANT; |
1739 | dev_info(&dev->dev, "rerouting interrupts for [%04x:%04x]\n", | 1736 | pci_info(dev, "rerouting interrupts for [%04x:%04x]\n", |
1740 | dev->vendor, dev->device); | 1737 | dev->vendor, dev->device); |
1741 | } | 1738 | } |
1742 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel); | 1739 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel); |
@@ -1779,7 +1776,7 @@ static void quirk_disable_intel_boot_interrupt(struct pci_dev *dev) | |||
1779 | pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ; | 1776 | pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ; |
1780 | pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, pci_config_word); | 1777 | pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, pci_config_word); |
1781 | 1778 | ||
1782 | dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", | 1779 | pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", |
1783 | dev->vendor, dev->device); | 1780 | dev->vendor, dev->device); |
1784 | } | 1781 | } |
1785 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt); | 1782 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt); |
@@ -1812,7 +1809,7 @@ static void quirk_disable_broadcom_boot_interrupt(struct pci_dev *dev) | |||
1812 | 1809 | ||
1813 | pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword); | 1810 | pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword); |
1814 | 1811 | ||
1815 | dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", | 1812 | pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", |
1816 | dev->vendor, dev->device); | 1813 | dev->vendor, dev->device); |
1817 | } | 1814 | } |
1818 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); | 1815 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); |
@@ -1845,7 +1842,7 @@ static void quirk_disable_amd_813x_boot_interrupt(struct pci_dev *dev) | |||
1845 | pci_config_dword &= ~AMD_813X_NOIOAMODE; | 1842 | pci_config_dword &= ~AMD_813X_NOIOAMODE; |
1846 | pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword); | 1843 | pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword); |
1847 | 1844 | ||
1848 | dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", | 1845 | pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", |
1849 | dev->vendor, dev->device); | 1846 | dev->vendor, dev->device); |
1850 | } | 1847 | } |
1851 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt); | 1848 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt); |
@@ -1864,12 +1861,12 @@ static void quirk_disable_amd_8111_boot_interrupt(struct pci_dev *dev) | |||
1864 | 1861 | ||
1865 | pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word); | 1862 | pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word); |
1866 | if (!pci_config_word) { | 1863 | if (!pci_config_word) { |
1867 | dev_info(&dev->dev, "boot interrupts on device [%04x:%04x] already disabled\n", | 1864 | pci_info(dev, "boot interrupts on device [%04x:%04x] already disabled\n", |
1868 | dev->vendor, dev->device); | 1865 | dev->vendor, dev->device); |
1869 | return; | 1866 | return; |
1870 | } | 1867 | } |
1871 | pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0); | 1868 | pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0); |
1872 | dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", | 1869 | pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", |
1873 | dev->vendor, dev->device); | 1870 | dev->vendor, dev->device); |
1874 | } | 1871 | } |
1875 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); | 1872 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); |
@@ -1913,7 +1910,7 @@ static void quirk_plx_pci9050(struct pci_dev *dev) | |||
1913 | if (pci_resource_len(dev, bar) == 0x80 && | 1910 | if (pci_resource_len(dev, bar) == 0x80 && |
1914 | (pci_resource_start(dev, bar) & 0x80)) { | 1911 | (pci_resource_start(dev, bar) & 0x80)) { |
1915 | struct resource *r = &dev->resource[bar]; | 1912 | struct resource *r = &dev->resource[bar]; |
1916 | dev_info(&dev->dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", | 1913 | pci_info(dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", |
1917 | bar); | 1914 | bar); |
1918 | r->flags |= IORESOURCE_UNSET; | 1915 | r->flags |= IORESOURCE_UNSET; |
1919 | r->start = 0; | 1916 | r->start = 0; |
@@ -1960,7 +1957,7 @@ static void quirk_netmos(struct pci_dev *dev) | |||
1960 | case PCI_DEVICE_ID_NETMOS_9845: | 1957 | case PCI_DEVICE_ID_NETMOS_9845: |
1961 | case PCI_DEVICE_ID_NETMOS_9855: | 1958 | case PCI_DEVICE_ID_NETMOS_9855: |
1962 | if (num_parallel) { | 1959 | if (num_parallel) { |
1963 | dev_info(&dev->dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n", | 1960 | pci_info(dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n", |
1964 | dev->device, num_parallel, num_serial); | 1961 | dev->device, num_parallel, num_serial); |
1965 | dev->class = (PCI_CLASS_COMMUNICATION_OTHER << 8) | | 1962 | dev->class = (PCI_CLASS_COMMUNICATION_OTHER << 8) | |
1966 | (dev->class & 0xff); | 1963 | (dev->class & 0xff); |
@@ -2046,13 +2043,13 @@ static void quirk_e100_interrupt(struct pci_dev *dev) | |||
2046 | /* Convert from PCI bus to resource space. */ | 2043 | /* Convert from PCI bus to resource space. */ |
2047 | csr = ioremap(pci_resource_start(dev, 0), 8); | 2044 | csr = ioremap(pci_resource_start(dev, 0), 8); |
2048 | if (!csr) { | 2045 | if (!csr) { |
2049 | dev_warn(&dev->dev, "Can't map e100 registers\n"); | 2046 | pci_warn(dev, "Can't map e100 registers\n"); |
2050 | return; | 2047 | return; |
2051 | } | 2048 | } |
2052 | 2049 | ||
2053 | cmd_hi = readb(csr + 3); | 2050 | cmd_hi = readb(csr + 3); |
2054 | if (cmd_hi == 0) { | 2051 | if (cmd_hi == 0) { |
2055 | dev_warn(&dev->dev, "Firmware left e100 interrupts enabled; disabling\n"); | 2052 | pci_warn(dev, "Firmware left e100 interrupts enabled; disabling\n"); |
2056 | writeb(1, csr + 3); | 2053 | writeb(1, csr + 3); |
2057 | } | 2054 | } |
2058 | 2055 | ||
@@ -2067,7 +2064,7 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, | |||
2067 | */ | 2064 | */ |
2068 | static void quirk_disable_aspm_l0s(struct pci_dev *dev) | 2065 | static void quirk_disable_aspm_l0s(struct pci_dev *dev) |
2069 | { | 2066 | { |
2070 | dev_info(&dev->dev, "Disabling L0s\n"); | 2067 | pci_info(dev, "Disabling L0s\n"); |
2071 | pci_disable_link_state(dev, PCIE_LINK_STATE_L0S); | 2068 | pci_disable_link_state(dev, PCIE_LINK_STATE_L0S); |
2072 | } | 2069 | } |
2073 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s); | 2070 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s); |
@@ -2097,7 +2094,7 @@ static void fixup_rev1_53c810(struct pci_dev *dev) | |||
2097 | return; | 2094 | return; |
2098 | 2095 | ||
2099 | dev->class = PCI_CLASS_STORAGE_SCSI << 8; | 2096 | dev->class = PCI_CLASS_STORAGE_SCSI << 8; |
2100 | dev_info(&dev->dev, "NCR 53c810 rev 1 PCI class overridden (%#08x -> %#08x)\n", | 2097 | pci_info(dev, "NCR 53c810 rev 1 PCI class overridden (%#08x -> %#08x)\n", |
2101 | class, dev->class); | 2098 | class, dev->class); |
2102 | } | 2099 | } |
2103 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); | 2100 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); |
@@ -2110,7 +2107,7 @@ static void quirk_p64h2_1k_io(struct pci_dev *dev) | |||
2110 | pci_read_config_word(dev, 0x40, &en1k); | 2107 | pci_read_config_word(dev, 0x40, &en1k); |
2111 | 2108 | ||
2112 | if (en1k & 0x200) { | 2109 | if (en1k & 0x200) { |
2113 | dev_info(&dev->dev, "Enable I/O Space to 1KB granularity\n"); | 2110 | pci_info(dev, "Enable I/O Space to 1KB granularity\n"); |
2114 | dev->io_window_1k = 1; | 2111 | dev->io_window_1k = 1; |
2115 | } | 2112 | } |
2116 | } | 2113 | } |
@@ -2126,7 +2123,7 @@ static void quirk_nvidia_ck804_pcie_aer_ext_cap(struct pci_dev *dev) | |||
2126 | if (pci_read_config_byte(dev, 0xf41, &b) == 0) { | 2123 | if (pci_read_config_byte(dev, 0xf41, &b) == 0) { |
2127 | if (!(b & 0x20)) { | 2124 | if (!(b & 0x20)) { |
2128 | pci_write_config_byte(dev, 0xf41, b | 0x20); | 2125 | pci_write_config_byte(dev, 0xf41, b | 0x20); |
2129 | dev_info(&dev->dev, "Linking AER extended capability\n"); | 2126 | pci_info(dev, "Linking AER extended capability\n"); |
2130 | } | 2127 | } |
2131 | } | 2128 | } |
2132 | } | 2129 | } |
@@ -2164,7 +2161,7 @@ static void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | |||
2164 | /* Turn off PCI Bus Parking */ | 2161 | /* Turn off PCI Bus Parking */ |
2165 | pci_write_config_byte(dev, 0x76, b ^ 0x40); | 2162 | pci_write_config_byte(dev, 0x76, b ^ 0x40); |
2166 | 2163 | ||
2167 | dev_info(&dev->dev, "Disabling VIA CX700 PCI parking\n"); | 2164 | pci_info(dev, "Disabling VIA CX700 PCI parking\n"); |
2168 | } | 2165 | } |
2169 | } | 2166 | } |
2170 | 2167 | ||
@@ -2179,7 +2176,7 @@ static void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | |||
2179 | /* Disable "Read FIFO Timer" */ | 2176 | /* Disable "Read FIFO Timer" */ |
2180 | pci_write_config_byte(dev, 0x77, 0x0); | 2177 | pci_write_config_byte(dev, 0x77, 0x0); |
2181 | 2178 | ||
2182 | dev_info(&dev->dev, "Disabling VIA CX700 PCI caching\n"); | 2179 | pci_info(dev, "Disabling VIA CX700 PCI caching\n"); |
2183 | } | 2180 | } |
2184 | } | 2181 | } |
2185 | } | 2182 | } |
@@ -2196,7 +2193,7 @@ static void quirk_blacklist_vpd(struct pci_dev *dev) | |||
2196 | { | 2193 | { |
2197 | if (dev->vpd) { | 2194 | if (dev->vpd) { |
2198 | dev->vpd->len = 0; | 2195 | dev->vpd->len = 0; |
2199 | dev_warn(&dev->dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n"); | 2196 | pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n"); |
2200 | } | 2197 | } |
2201 | } | 2198 | } |
2202 | 2199 | ||
@@ -2312,7 +2309,7 @@ static void quirk_unhide_mch_dev6(struct pci_dev *dev) | |||
2312 | u8 reg; | 2309 | u8 reg; |
2313 | 2310 | ||
2314 | if (pci_read_config_byte(dev, 0xF4, ®) == 0 && !(reg & 0x02)) { | 2311 | if (pci_read_config_byte(dev, 0xF4, ®) == 0 && !(reg & 0x02)) { |
2315 | dev_info(&dev->dev, "Enabling MCH 'Overflow' Device\n"); | 2312 | pci_info(dev, "Enabling MCH 'Overflow' Device\n"); |
2316 | pci_write_config_byte(dev, 0xF4, reg | 0x02); | 2313 | pci_write_config_byte(dev, 0xF4, reg | 0x02); |
2317 | } | 2314 | } |
2318 | } | 2315 | } |
@@ -2351,7 +2348,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PLX, 0x8624, quirk_tile_plx_gen1); | |||
2351 | static void quirk_disable_all_msi(struct pci_dev *dev) | 2348 | static void quirk_disable_all_msi(struct pci_dev *dev) |
2352 | { | 2349 | { |
2353 | pci_no_msi(); | 2350 | pci_no_msi(); |
2354 | dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n"); | 2351 | pci_warn(dev, "MSI quirk detected; MSI disabled\n"); |
2355 | } | 2352 | } |
2356 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi); | 2353 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi); |
2357 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); | 2354 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); |
@@ -2366,7 +2363,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, 0x0761, quirk_disable_all_msi); | |||
2366 | static void quirk_disable_msi(struct pci_dev *dev) | 2363 | static void quirk_disable_msi(struct pci_dev *dev) |
2367 | { | 2364 | { |
2368 | if (dev->subordinate) { | 2365 | if (dev->subordinate) { |
2369 | dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n"); | 2366 | pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); |
2370 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | 2367 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; |
2371 | } | 2368 | } |
2372 | } | 2369 | } |
@@ -2406,7 +2403,7 @@ static int msi_ht_cap_enabled(struct pci_dev *dev) | |||
2406 | 2403 | ||
2407 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, | 2404 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, |
2408 | &flags) == 0) { | 2405 | &flags) == 0) { |
2409 | dev_info(&dev->dev, "Found %s HT MSI Mapping\n", | 2406 | pci_info(dev, "Found %s HT MSI Mapping\n", |
2410 | flags & HT_MSI_FLAGS_ENABLE ? | 2407 | flags & HT_MSI_FLAGS_ENABLE ? |
2411 | "enabled" : "disabled"); | 2408 | "enabled" : "disabled"); |
2412 | return (flags & HT_MSI_FLAGS_ENABLE) != 0; | 2409 | return (flags & HT_MSI_FLAGS_ENABLE) != 0; |
@@ -2422,7 +2419,7 @@ static int msi_ht_cap_enabled(struct pci_dev *dev) | |||
2422 | static void quirk_msi_ht_cap(struct pci_dev *dev) | 2419 | static void quirk_msi_ht_cap(struct pci_dev *dev) |
2423 | { | 2420 | { |
2424 | if (dev->subordinate && !msi_ht_cap_enabled(dev)) { | 2421 | if (dev->subordinate && !msi_ht_cap_enabled(dev)) { |
2425 | dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n"); | 2422 | pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); |
2426 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | 2423 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; |
2427 | } | 2424 | } |
2428 | } | 2425 | } |
@@ -2446,7 +2443,7 @@ static void quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev) | |||
2446 | if (!pdev) | 2443 | if (!pdev) |
2447 | return; | 2444 | return; |
2448 | if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) { | 2445 | if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) { |
2449 | dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n"); | 2446 | pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); |
2450 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | 2447 | dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; |
2451 | } | 2448 | } |
2452 | pci_dev_put(pdev); | 2449 | pci_dev_put(pdev); |
@@ -2465,7 +2462,7 @@ static void ht_enable_msi_mapping(struct pci_dev *dev) | |||
2465 | 2462 | ||
2466 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, | 2463 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, |
2467 | &flags) == 0) { | 2464 | &flags) == 0) { |
2468 | dev_info(&dev->dev, "Enabling HT MSI Mapping\n"); | 2465 | pci_info(dev, "Enabling HT MSI Mapping\n"); |
2469 | 2466 | ||
2470 | pci_write_config_byte(dev, pos + HT_MSI_FLAGS, | 2467 | pci_write_config_byte(dev, pos + HT_MSI_FLAGS, |
2471 | flags | HT_MSI_FLAGS_ENABLE); | 2468 | flags | HT_MSI_FLAGS_ENABLE); |
@@ -2492,7 +2489,7 @@ static void nvenet_msi_disable(struct pci_dev *dev) | |||
2492 | if (board_name && | 2489 | if (board_name && |
2493 | (strstr(board_name, "P5N32-SLI PREMIUM") || | 2490 | (strstr(board_name, "P5N32-SLI PREMIUM") || |
2494 | strstr(board_name, "P5N32-E SLI"))) { | 2491 | strstr(board_name, "P5N32-E SLI"))) { |
2495 | dev_info(&dev->dev, "Disabling msi for MCP55 NIC on P5N32-SLI\n"); | 2492 | pci_info(dev, "Disabling MSI for MCP55 NIC on P5N32-SLI\n"); |
2496 | dev->no_msi = 1; | 2493 | dev->no_msi = 1; |
2497 | } | 2494 | } |
2498 | } | 2495 | } |
@@ -2669,7 +2666,7 @@ static void ht_disable_msi_mapping(struct pci_dev *dev) | |||
2669 | 2666 | ||
2670 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, | 2667 | if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, |
2671 | &flags) == 0) { | 2668 | &flags) == 0) { |
2672 | dev_info(&dev->dev, "Disabling HT MSI Mapping\n"); | 2669 | pci_info(dev, "Disabling HT MSI Mapping\n"); |
2673 | 2670 | ||
2674 | pci_write_config_byte(dev, pos + HT_MSI_FLAGS, | 2671 | pci_write_config_byte(dev, pos + HT_MSI_FLAGS, |
2675 | flags & ~HT_MSI_FLAGS_ENABLE); | 2672 | flags & ~HT_MSI_FLAGS_ENABLE); |
@@ -2699,9 +2696,10 @@ static void __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all) | |||
2699 | * HT MSI mapping should be disabled on devices that are below | 2696 | * HT MSI mapping should be disabled on devices that are below |
2700 | * a non-Hypertransport host bridge. Locate the host bridge... | 2697 | * a non-Hypertransport host bridge. Locate the host bridge... |
2701 | */ | 2698 | */ |
2702 | host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); | 2699 | host_bridge = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus), 0, |
2700 | PCI_DEVFN(0, 0)); | ||
2703 | if (host_bridge == NULL) { | 2701 | if (host_bridge == NULL) { |
2704 | dev_warn(&dev->dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n"); | 2702 | pci_warn(dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n"); |
2705 | return; | 2703 | return; |
2706 | } | 2704 | } |
2707 | 2705 | ||
@@ -2770,7 +2768,7 @@ static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev) | |||
2770 | { | 2768 | { |
2771 | /* AR816X/AR817X/E210X MSI is fixed at HW level from revision 0x18 */ | 2769 | /* AR816X/AR817X/E210X MSI is fixed at HW level from revision 0x18 */ |
2772 | if (dev->revision < 0x18) { | 2770 | if (dev->revision < 0x18) { |
2773 | dev_info(&dev->dev, "set MSI_INTX_DISABLE_BUG flag\n"); | 2771 | pci_info(dev, "set MSI_INTX_DISABLE_BUG flag\n"); |
2774 | dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; | 2772 | dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; |
2775 | } | 2773 | } |
2776 | } | 2774 | } |
@@ -2899,8 +2897,8 @@ static void ricoh_mmc_fixup_rl5c476(struct pci_dev *dev) | |||
2899 | pci_write_config_byte(dev, 0x8E, write_enable); | 2897 | pci_write_config_byte(dev, 0x8E, write_enable); |
2900 | pci_write_config_byte(dev, 0x8D, write_target); | 2898 | pci_write_config_byte(dev, 0x8D, write_target); |
2901 | 2899 | ||
2902 | dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via cardbus function)\n"); | 2900 | pci_notice(dev, "proprietary Ricoh MMC controller disabled (via cardbus function)\n"); |
2903 | dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n"); | 2901 | pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n"); |
2904 | } | 2902 | } |
2905 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); | 2903 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); |
2906 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); | 2904 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); |
@@ -2935,7 +2933,7 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev) | |||
2935 | pci_write_config_byte(dev, 0xe1, 0x32); | 2933 | pci_write_config_byte(dev, 0xe1, 0x32); |
2936 | pci_write_config_byte(dev, 0xfc, 0x00); | 2934 | pci_write_config_byte(dev, 0xfc, 0x00); |
2937 | 2935 | ||
2938 | dev_notice(&dev->dev, "MMC controller base frequency changed to 50Mhz.\n"); | 2936 | pci_notice(dev, "MMC controller base frequency changed to 50Mhz.\n"); |
2939 | } | 2937 | } |
2940 | 2938 | ||
2941 | pci_read_config_byte(dev, 0xCB, &disable); | 2939 | pci_read_config_byte(dev, 0xCB, &disable); |
@@ -2948,8 +2946,8 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev) | |||
2948 | pci_write_config_byte(dev, 0xCB, disable | 0x02); | 2946 | pci_write_config_byte(dev, 0xCB, disable | 0x02); |
2949 | pci_write_config_byte(dev, 0xCA, write_enable); | 2947 | pci_write_config_byte(dev, 0xCA, write_enable); |
2950 | 2948 | ||
2951 | dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n"); | 2949 | pci_notice(dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n"); |
2952 | dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n"); | 2950 | pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n"); |
2953 | 2951 | ||
2954 | } | 2952 | } |
2955 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); | 2953 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); |
@@ -2990,7 +2988,7 @@ static void fixup_ti816x_class(struct pci_dev *dev) | |||
2990 | 2988 | ||
2991 | /* TI 816x devices do not have class code set when in PCIe boot mode */ | 2989 | /* TI 816x devices do not have class code set when in PCIe boot mode */ |
2992 | dev->class = PCI_CLASS_MULTIMEDIA_VIDEO << 8; | 2990 | dev->class = PCI_CLASS_MULTIMEDIA_VIDEO << 8; |
2993 | dev_info(&dev->dev, "PCI class overridden (%#08x -> %#08x)\n", | 2991 | pci_info(dev, "PCI class overridden (%#08x -> %#08x)\n", |
2994 | class, dev->class); | 2992 | class, dev->class); |
2995 | } | 2993 | } |
2996 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800, | 2994 | DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800, |
@@ -3032,7 +3030,7 @@ static void quirk_intel_mc_errata(struct pci_dev *dev) | |||
3032 | */ | 3030 | */ |
3033 | err = pci_read_config_word(dev, 0x48, &rcc); | 3031 | err = pci_read_config_word(dev, 0x48, &rcc); |
3034 | if (err) { | 3032 | if (err) { |
3035 | dev_err(&dev->dev, "Error attempting to read the read completion coalescing register\n"); | 3033 | pci_err(dev, "Error attempting to read the read completion coalescing register\n"); |
3036 | return; | 3034 | return; |
3037 | } | 3035 | } |
3038 | 3036 | ||
@@ -3043,7 +3041,7 @@ static void quirk_intel_mc_errata(struct pci_dev *dev) | |||
3043 | 3041 | ||
3044 | err = pci_write_config_word(dev, 0x48, rcc); | 3042 | err = pci_write_config_word(dev, 0x48, rcc); |
3045 | if (err) { | 3043 | if (err) { |
3046 | dev_err(&dev->dev, "Error attempting to write the read completion coalescing register\n"); | 3044 | pci_err(dev, "Error attempting to write the read completion coalescing register\n"); |
3047 | return; | 3045 | return; |
3048 | } | 3046 | } |
3049 | 3047 | ||
@@ -3108,7 +3106,7 @@ static ktime_t fixup_debug_start(struct pci_dev *dev, | |||
3108 | { | 3106 | { |
3109 | ktime_t calltime = 0; | 3107 | ktime_t calltime = 0; |
3110 | 3108 | ||
3111 | dev_dbg(&dev->dev, "calling %pF\n", fn); | 3109 | pci_dbg(dev, "calling %pF\n", fn); |
3112 | if (initcall_debug) { | 3110 | if (initcall_debug) { |
3113 | pr_debug("calling %pF @ %i for %s\n", | 3111 | pr_debug("calling %pF @ %i for %s\n", |
3114 | fn, task_pid_nr(current), dev_name(&dev->dev)); | 3112 | fn, task_pid_nr(current), dev_name(&dev->dev)); |
@@ -3150,13 +3148,13 @@ static void disable_igfx_irq(struct pci_dev *dev) | |||
3150 | { | 3148 | { |
3151 | void __iomem *regs = pci_iomap(dev, 0, 0); | 3149 | void __iomem *regs = pci_iomap(dev, 0, 0); |
3152 | if (regs == NULL) { | 3150 | if (regs == NULL) { |
3153 | dev_warn(&dev->dev, "igfx quirk: Can't iomap PCI device\n"); | 3151 | pci_warn(dev, "igfx quirk: Can't iomap PCI device\n"); |
3154 | return; | 3152 | return; |
3155 | } | 3153 | } |
3156 | 3154 | ||
3157 | /* Check if any interrupt line is still enabled */ | 3155 | /* Check if any interrupt line is still enabled */ |
3158 | if (readl(regs + I915_DEIER_REG) != 0) { | 3156 | if (readl(regs + I915_DEIER_REG) != 0) { |
3159 | dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; disabling\n"); | 3157 | pci_warn(dev, "BIOS left Intel GPU interrupts enabled; disabling\n"); |
3160 | 3158 | ||
3161 | writel(0, regs + I915_DEIER_REG); | 3159 | writel(0, regs + I915_DEIER_REG); |
3162 | } | 3160 | } |
@@ -3215,6 +3213,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x0030, | |||
3215 | quirk_broken_intx_masking); | 3213 | quirk_broken_intx_masking); |
3216 | DECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */ | 3214 | DECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */ |
3217 | quirk_broken_intx_masking); | 3215 | quirk_broken_intx_masking); |
3216 | DECLARE_PCI_FIXUP_FINAL(0x1b7c, 0x0004, /* Ceton InfiniTV4 */ | ||
3217 | quirk_broken_intx_masking); | ||
3218 | 3218 | ||
3219 | /* | 3219 | /* |
3220 | * Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10) | 3220 | * Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10) |
@@ -3317,13 +3317,13 @@ static void mellanox_check_broken_intx_masking(struct pci_dev *pdev) | |||
3317 | 3317 | ||
3318 | /* For ConnectX-4 and ConnectX-4LX, need to check FW support */ | 3318 | /* For ConnectX-4 and ConnectX-4LX, need to check FW support */ |
3319 | if (pci_enable_device_mem(pdev)) { | 3319 | if (pci_enable_device_mem(pdev)) { |
3320 | dev_warn(&pdev->dev, "Can't enable device memory\n"); | 3320 | pci_warn(pdev, "Can't enable device memory\n"); |
3321 | return; | 3321 | return; |
3322 | } | 3322 | } |
3323 | 3323 | ||
3324 | fw_ver = ioremap(pci_resource_start(pdev, 0), 4); | 3324 | fw_ver = ioremap(pci_resource_start(pdev, 0), 4); |
3325 | if (!fw_ver) { | 3325 | if (!fw_ver) { |
3326 | dev_warn(&pdev->dev, "Can't map ConnectX-4 initialization segment\n"); | 3326 | pci_warn(pdev, "Can't map ConnectX-4 initialization segment\n"); |
3327 | goto out; | 3327 | goto out; |
3328 | } | 3328 | } |
3329 | 3329 | ||
@@ -3335,7 +3335,7 @@ static void mellanox_check_broken_intx_masking(struct pci_dev *pdev) | |||
3335 | fw_subminor = fw_sub_min & 0xffff; | 3335 | fw_subminor = fw_sub_min & 0xffff; |
3336 | if (fw_minor > CONNECTX_4_CURR_MAX_MINOR || | 3336 | if (fw_minor > CONNECTX_4_CURR_MAX_MINOR || |
3337 | fw_minor < CONNECTX_4_INTX_SUPPORT_MINOR) { | 3337 | fw_minor < CONNECTX_4_INTX_SUPPORT_MINOR) { |
3338 | dev_warn(&pdev->dev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n", | 3338 | pci_warn(pdev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n", |
3339 | fw_major, fw_minor, fw_subminor, pdev->device == | 3339 | fw_major, fw_minor, fw_subminor, pdev->device == |
3340 | PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14); | 3340 | PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14); |
3341 | pdev->broken_intx_masking = 1; | 3341 | pdev->broken_intx_masking = 1; |
@@ -3473,7 +3473,7 @@ static void quirk_apple_poweroff_thunderbolt(struct pci_dev *dev) | |||
3473 | || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXFP", &SXFP)) | 3473 | || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXFP", &SXFP)) |
3474 | || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXLV", &SXLV))) | 3474 | || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXLV", &SXLV))) |
3475 | return; | 3475 | return; |
3476 | dev_info(&dev->dev, "quirk: cutting power to thunderbolt controller...\n"); | 3476 | pci_info(dev, "quirk: cutting power to thunderbolt controller...\n"); |
3477 | 3477 | ||
3478 | /* magic sequence */ | 3478 | /* magic sequence */ |
3479 | acpi_execute_simple_method(SXIO, NULL, 1); | 3479 | acpi_execute_simple_method(SXIO, NULL, 1); |
@@ -3524,7 +3524,7 @@ static void quirk_apple_wait_for_thunderbolt(struct pci_dev *dev) | |||
3524 | nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI) | 3524 | nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI) |
3525 | || nhi->class != PCI_CLASS_SYSTEM_OTHER << 8) | 3525 | || nhi->class != PCI_CLASS_SYSTEM_OTHER << 8) |
3526 | goto out; | 3526 | goto out; |
3527 | dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); | 3527 | pci_info(dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); |
3528 | device_pm_wait_for_dev(&dev->dev, &nhi->dev); | 3528 | device_pm_wait_for_dev(&dev->dev, &nhi->dev); |
3529 | out: | 3529 | out: |
3530 | pci_dev_put(nhi); | 3530 | pci_dev_put(nhi); |
@@ -3740,7 +3740,7 @@ static int reset_ivb_igd(struct pci_dev *dev, int probe) | |||
3740 | goto reset_complete; | 3740 | goto reset_complete; |
3741 | msleep(10); | 3741 | msleep(10); |
3742 | } while (time_before(jiffies, timeout)); | 3742 | } while (time_before(jiffies, timeout)); |
3743 | dev_warn(&dev->dev, "timeout during reset\n"); | 3743 | pci_warn(dev, "timeout during reset\n"); |
3744 | 3744 | ||
3745 | reset_complete: | 3745 | reset_complete: |
3746 | iowrite32(0x00000002, mmio_base + NSDE_PWR_STATE); | 3746 | iowrite32(0x00000002, mmio_base + NSDE_PWR_STATE); |
@@ -3879,6 +3879,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9120, | |||
3879 | quirk_dma_func1_alias); | 3879 | quirk_dma_func1_alias); |
3880 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9123, | 3880 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9123, |
3881 | quirk_dma_func1_alias); | 3881 | quirk_dma_func1_alias); |
3882 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9128, | ||
3883 | quirk_dma_func1_alias); | ||
3882 | /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ | 3884 | /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ |
3883 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130, | 3885 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130, |
3884 | quirk_dma_func1_alias); | 3886 | quirk_dma_func1_alias); |
@@ -4012,7 +4014,7 @@ static void quirk_tw686x_class(struct pci_dev *pdev) | |||
4012 | 4014 | ||
4013 | /* Use "Multimedia controller" class */ | 4015 | /* Use "Multimedia controller" class */ |
4014 | pdev->class = (PCI_CLASS_MULTIMEDIA_OTHER << 8) | 0x01; | 4016 | pdev->class = (PCI_CLASS_MULTIMEDIA_OTHER << 8) | 0x01; |
4015 | dev_info(&pdev->dev, "TW686x PCI class overridden (%#08x -> %#08x)\n", | 4017 | pci_info(pdev, "TW686x PCI class overridden (%#08x -> %#08x)\n", |
4016 | class, pdev->class); | 4018 | class, pdev->class); |
4017 | } | 4019 | } |
4018 | DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6864, PCI_CLASS_NOT_DEFINED, 8, | 4020 | DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6864, PCI_CLASS_NOT_DEFINED, 8, |
@@ -4032,7 +4034,7 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6869, PCI_CLASS_NOT_DEFINED, 8, | |||
4032 | static void quirk_relaxedordering_disable(struct pci_dev *dev) | 4034 | static void quirk_relaxedordering_disable(struct pci_dev *dev) |
4033 | { | 4035 | { |
4034 | dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING; | 4036 | dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING; |
4035 | dev_info(&dev->dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n"); | 4037 | pci_info(dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n"); |
4036 | } | 4038 | } |
4037 | 4039 | ||
4038 | /* | 4040 | /* |
@@ -4141,11 +4143,11 @@ static void quirk_disable_root_port_attributes(struct pci_dev *pdev) | |||
4141 | struct pci_dev *root_port = pci_find_pcie_root_port(pdev); | 4143 | struct pci_dev *root_port = pci_find_pcie_root_port(pdev); |
4142 | 4144 | ||
4143 | if (!root_port) { | 4145 | if (!root_port) { |
4144 | dev_warn(&pdev->dev, "PCIe Completion erratum may cause device errors\n"); | 4146 | pci_warn(pdev, "PCIe Completion erratum may cause device errors\n"); |
4145 | return; | 4147 | return; |
4146 | } | 4148 | } |
4147 | 4149 | ||
4148 | dev_info(&root_port->dev, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", | 4150 | pci_info(root_port, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", |
4149 | dev_name(&pdev->dev)); | 4151 | dev_name(&pdev->dev)); |
4150 | pcie_capability_clear_and_set_word(root_port, PCI_EXP_DEVCTL, | 4152 | pcie_capability_clear_and_set_word(root_port, PCI_EXP_DEVCTL, |
4151 | PCI_EXP_DEVCTL_RELAX_EN | | 4153 | PCI_EXP_DEVCTL_RELAX_EN | |
@@ -4339,7 +4341,7 @@ static int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags) | |||
4339 | u16 flags = (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV); | 4341 | u16 flags = (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV); |
4340 | int ret = acs_flags & ~flags ? 0 : 1; | 4342 | int ret = acs_flags & ~flags ? 0 : 1; |
4341 | 4343 | ||
4342 | dev_info(&dev->dev, "Using QCOM ACS Quirk (%d)\n", ret); | 4344 | pci_info(dev, "Using QCOM ACS Quirk (%d)\n", ret); |
4343 | 4345 | ||
4344 | return ret; | 4346 | return ret; |
4345 | } | 4347 | } |
@@ -4591,7 +4593,7 @@ static int pci_quirk_enable_intel_lpc_acs(struct pci_dev *dev) | |||
4591 | if (bspr != (INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD)) { | 4593 | if (bspr != (INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD)) { |
4592 | updcr = readl(rcba_mem + INTEL_UPDCR_REG); | 4594 | updcr = readl(rcba_mem + INTEL_UPDCR_REG); |
4593 | if (updcr & INTEL_UPDCR_REG_MASK) { | 4595 | if (updcr & INTEL_UPDCR_REG_MASK) { |
4594 | dev_info(&dev->dev, "Disabling UPDCR peer decodes\n"); | 4596 | pci_info(dev, "Disabling UPDCR peer decodes\n"); |
4595 | updcr &= ~INTEL_UPDCR_REG_MASK; | 4597 | updcr &= ~INTEL_UPDCR_REG_MASK; |
4596 | writel(updcr, rcba_mem + INTEL_UPDCR_REG); | 4598 | writel(updcr, rcba_mem + INTEL_UPDCR_REG); |
4597 | } | 4599 | } |
@@ -4618,7 +4620,7 @@ static void pci_quirk_enable_intel_rp_mpc_acs(struct pci_dev *dev) | |||
4618 | */ | 4620 | */ |
4619 | pci_read_config_dword(dev, INTEL_MPC_REG, &mpc); | 4621 | pci_read_config_dword(dev, INTEL_MPC_REG, &mpc); |
4620 | if (!(mpc & INTEL_MPC_REG_IRBNCE)) { | 4622 | if (!(mpc & INTEL_MPC_REG_IRBNCE)) { |
4621 | dev_info(&dev->dev, "Enabling MPC IRBNCE\n"); | 4623 | pci_info(dev, "Enabling MPC IRBNCE\n"); |
4622 | mpc |= INTEL_MPC_REG_IRBNCE; | 4624 | mpc |= INTEL_MPC_REG_IRBNCE; |
4623 | pci_write_config_word(dev, INTEL_MPC_REG, mpc); | 4625 | pci_write_config_word(dev, INTEL_MPC_REG, mpc); |
4624 | } | 4626 | } |
@@ -4630,7 +4632,7 @@ static int pci_quirk_enable_intel_pch_acs(struct pci_dev *dev) | |||
4630 | return -ENOTTY; | 4632 | return -ENOTTY; |
4631 | 4633 | ||
4632 | if (pci_quirk_enable_intel_lpc_acs(dev)) { | 4634 | if (pci_quirk_enable_intel_lpc_acs(dev)) { |
4633 | dev_warn(&dev->dev, "Failed to enable Intel PCH ACS quirk\n"); | 4635 | pci_warn(dev, "Failed to enable Intel PCH ACS quirk\n"); |
4634 | return 0; | 4636 | return 0; |
4635 | } | 4637 | } |
4636 | 4638 | ||
@@ -4638,7 +4640,7 @@ static int pci_quirk_enable_intel_pch_acs(struct pci_dev *dev) | |||
4638 | 4640 | ||
4639 | dev->dev_flags |= PCI_DEV_FLAGS_ACS_ENABLED_QUIRK; | 4641 | dev->dev_flags |= PCI_DEV_FLAGS_ACS_ENABLED_QUIRK; |
4640 | 4642 | ||
4641 | dev_info(&dev->dev, "Intel PCH root port ACS workaround enabled\n"); | 4643 | pci_info(dev, "Intel PCH root port ACS workaround enabled\n"); |
4642 | 4644 | ||
4643 | return 0; | 4645 | return 0; |
4644 | } | 4646 | } |
@@ -4665,7 +4667,7 @@ static int pci_quirk_enable_intel_spt_pch_acs(struct pci_dev *dev) | |||
4665 | 4667 | ||
4666 | pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); | 4668 | pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); |
4667 | 4669 | ||
4668 | dev_info(&dev->dev, "Intel SPT PCH root port ACS workaround enabled\n"); | 4670 | pci_info(dev, "Intel SPT PCH root port ACS workaround enabled\n"); |
4669 | 4671 | ||
4670 | return 0; | 4672 | return 0; |
4671 | } | 4673 | } |
@@ -4800,7 +4802,7 @@ static void quirk_no_ext_tags(struct pci_dev *pdev) | |||
4800 | return; | 4802 | return; |
4801 | 4803 | ||
4802 | bridge->no_ext_tags = 1; | 4804 | bridge->no_ext_tags = 1; |
4803 | dev_info(&pdev->dev, "disabling Extended Tags (this device can't handle them)\n"); | 4805 | pci_info(pdev, "disabling Extended Tags (this device can't handle them)\n"); |
4804 | 4806 | ||
4805 | pci_walk_bus(bridge->bus, pci_configure_extended_tags, NULL); | 4807 | pci_walk_bus(bridge->bus, pci_configure_extended_tags, NULL); |
4806 | } | 4808 | } |
@@ -4815,7 +4817,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0144, quirk_no_ext_tags); | |||
4815 | */ | 4817 | */ |
4816 | static void quirk_no_ats(struct pci_dev *pdev) | 4818 | static void quirk_no_ats(struct pci_dev *pdev) |
4817 | { | 4819 | { |
4818 | dev_info(&pdev->dev, "disabling ATS (broken on this device)\n"); | 4820 | pci_info(pdev, "disabling ATS (broken on this device)\n"); |
4819 | pdev->ats_cap = 0; | 4821 | pdev->ats_cap = 0; |
4820 | } | 4822 | } |
4821 | 4823 | ||
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 2fa0dbde36b7..6f072eae4f7a 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | #include <linux/pci.h> | 2 | #include <linux/pci.h> |
2 | #include <linux/module.h> | 3 | #include <linux/module.h> |
3 | #include <linux/pci-aspm.h> | 4 | #include <linux/pci-aspm.h> |
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 1f5e6af96c83..374a33443be9 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/rom.c | 3 | * drivers/pci/rom.c |
3 | * | 4 | * |
@@ -92,15 +93,15 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size) | |||
92 | void __iomem *pds; | 93 | void __iomem *pds; |
93 | /* Standard PCI ROMs start out with these bytes 55 AA */ | 94 | /* Standard PCI ROMs start out with these bytes 55 AA */ |
94 | if (readw(image) != 0xAA55) { | 95 | if (readw(image) != 0xAA55) { |
95 | dev_err(&pdev->dev, "Invalid PCI ROM header signature: expecting 0xaa55, got %#06x\n", | 96 | pci_info(pdev, "Invalid PCI ROM header signature: expecting 0xaa55, got %#06x\n", |
96 | readw(image)); | 97 | readw(image)); |
97 | break; | 98 | break; |
98 | } | 99 | } |
99 | /* get the PCI data structure and check its "PCIR" signature */ | 100 | /* get the PCI data structure and check its "PCIR" signature */ |
100 | pds = image + readw(image + 24); | 101 | pds = image + readw(image + 24); |
101 | if (readl(pds) != 0x52494350) { | 102 | if (readl(pds) != 0x52494350) { |
102 | dev_err(&pdev->dev, "Invalid PCI ROM data signature: expecting 0x52494350, got %#010x\n", | 103 | pci_info(pdev, "Invalid PCI ROM data signature: expecting 0x52494350, got %#010x\n", |
103 | readl(pds)); | 104 | readl(pds)); |
104 | break; | 105 | break; |
105 | } | 106 | } |
106 | last_image = readb(pds + 21) & 0x80; | 107 | last_image = readb(pds + 21) & 0x80; |
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 4c6044ad7368..bc1e023f1353 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCI searching functions. | 3 | * PCI searching functions. |
3 | * | 4 | * |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index b1ad466199ad..3cce29a069e6 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/setup-bus.c | 3 | * drivers/pci/setup-bus.c |
3 | * | 4 | * |
@@ -67,10 +68,8 @@ static int add_to_list(struct list_head *head, | |||
67 | struct pci_dev_resource *tmp; | 68 | struct pci_dev_resource *tmp; |
68 | 69 | ||
69 | tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); | 70 | tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); |
70 | if (!tmp) { | 71 | if (!tmp) |
71 | pr_warn("add_to_list: kmalloc() failed!\n"); | ||
72 | return -ENOMEM; | 72 | return -ENOMEM; |
73 | } | ||
74 | 73 | ||
75 | tmp->res = res; | 74 | tmp->res = res; |
76 | tmp->dev = dev; | 75 | tmp->dev = dev; |
@@ -152,7 +151,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) | |||
152 | 151 | ||
153 | r_align = pci_resource_alignment(dev, r); | 152 | r_align = pci_resource_alignment(dev, r); |
154 | if (!r_align) { | 153 | if (!r_align) { |
155 | dev_warn(&dev->dev, "BAR %d: %pR has bogus alignment\n", | 154 | pci_warn(dev, "BAR %d: %pR has bogus alignment\n", |
156 | i, r); | 155 | i, r); |
157 | continue; | 156 | continue; |
158 | } | 157 | } |
@@ -260,7 +259,7 @@ static void reassign_resources_sorted(struct list_head *realloc_head, | |||
260 | (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); | 259 | (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); |
261 | if (pci_reassign_resource(add_res->dev, idx, | 260 | if (pci_reassign_resource(add_res->dev, idx, |
262 | add_size, align)) | 261 | add_size, align)) |
263 | dev_printk(KERN_DEBUG, &add_res->dev->dev, | 262 | pci_printk(KERN_DEBUG, add_res->dev, |
264 | "failed to add %llx res[%d]=%pR\n", | 263 | "failed to add %llx res[%d]=%pR\n", |
265 | (unsigned long long)add_size, | 264 | (unsigned long long)add_size, |
266 | idx, res); | 265 | idx, res); |
@@ -519,7 +518,7 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
519 | struct resource *res; | 518 | struct resource *res; |
520 | struct pci_bus_region region; | 519 | struct pci_bus_region region; |
521 | 520 | ||
522 | dev_info(&bridge->dev, "CardBus bridge to %pR\n", | 521 | pci_info(bridge, "CardBus bridge to %pR\n", |
523 | &bus->busn_res); | 522 | &bus->busn_res); |
524 | 523 | ||
525 | res = bus->resource[0]; | 524 | res = bus->resource[0]; |
@@ -529,7 +528,7 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
529 | * The IO resource is allocated a range twice as large as it | 528 | * The IO resource is allocated a range twice as large as it |
530 | * would normally need. This allows us to set both IO regs. | 529 | * would normally need. This allows us to set both IO regs. |
531 | */ | 530 | */ |
532 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 531 | pci_info(bridge, " bridge window %pR\n", res); |
533 | pci_write_config_dword(bridge, PCI_CB_IO_BASE_0, | 532 | pci_write_config_dword(bridge, PCI_CB_IO_BASE_0, |
534 | region.start); | 533 | region.start); |
535 | pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_0, | 534 | pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_0, |
@@ -539,7 +538,7 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
539 | res = bus->resource[1]; | 538 | res = bus->resource[1]; |
540 | pcibios_resource_to_bus(bridge->bus, ®ion, res); | 539 | pcibios_resource_to_bus(bridge->bus, ®ion, res); |
541 | if (res->flags & IORESOURCE_IO) { | 540 | if (res->flags & IORESOURCE_IO) { |
542 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 541 | pci_info(bridge, " bridge window %pR\n", res); |
543 | pci_write_config_dword(bridge, PCI_CB_IO_BASE_1, | 542 | pci_write_config_dword(bridge, PCI_CB_IO_BASE_1, |
544 | region.start); | 543 | region.start); |
545 | pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_1, | 544 | pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_1, |
@@ -549,7 +548,7 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
549 | res = bus->resource[2]; | 548 | res = bus->resource[2]; |
550 | pcibios_resource_to_bus(bridge->bus, ®ion, res); | 549 | pcibios_resource_to_bus(bridge->bus, ®ion, res); |
551 | if (res->flags & IORESOURCE_MEM) { | 550 | if (res->flags & IORESOURCE_MEM) { |
552 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 551 | pci_info(bridge, " bridge window %pR\n", res); |
553 | pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0, | 552 | pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0, |
554 | region.start); | 553 | region.start); |
555 | pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_0, | 554 | pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_0, |
@@ -559,7 +558,7 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
559 | res = bus->resource[3]; | 558 | res = bus->resource[3]; |
560 | pcibios_resource_to_bus(bridge->bus, ®ion, res); | 559 | pcibios_resource_to_bus(bridge->bus, ®ion, res); |
561 | if (res->flags & IORESOURCE_MEM) { | 560 | if (res->flags & IORESOURCE_MEM) { |
562 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 561 | pci_info(bridge, " bridge window %pR\n", res); |
563 | pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1, | 562 | pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1, |
564 | region.start); | 563 | region.start); |
565 | pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_1, | 564 | pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_1, |
@@ -602,7 +601,7 @@ static void pci_setup_bridge_io(struct pci_dev *bridge) | |||
602 | l = ((u16) io_limit_lo << 8) | io_base_lo; | 601 | l = ((u16) io_limit_lo << 8) | io_base_lo; |
603 | /* Set up upper 16 bits of I/O base/limit. */ | 602 | /* Set up upper 16 bits of I/O base/limit. */ |
604 | io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); | 603 | io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); |
605 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 604 | pci_info(bridge, " bridge window %pR\n", res); |
606 | } else { | 605 | } else { |
607 | /* Clear upper 16 bits of I/O base/limit. */ | 606 | /* Clear upper 16 bits of I/O base/limit. */ |
608 | io_upper16 = 0; | 607 | io_upper16 = 0; |
@@ -628,7 +627,7 @@ static void pci_setup_bridge_mmio(struct pci_dev *bridge) | |||
628 | if (res->flags & IORESOURCE_MEM) { | 627 | if (res->flags & IORESOURCE_MEM) { |
629 | l = (region.start >> 16) & 0xfff0; | 628 | l = (region.start >> 16) & 0xfff0; |
630 | l |= region.end & 0xfff00000; | 629 | l |= region.end & 0xfff00000; |
631 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 630 | pci_info(bridge, " bridge window %pR\n", res); |
632 | } else { | 631 | } else { |
633 | l = 0x0000fff0; | 632 | l = 0x0000fff0; |
634 | } | 633 | } |
@@ -657,7 +656,7 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev *bridge) | |||
657 | bu = upper_32_bits(region.start); | 656 | bu = upper_32_bits(region.start); |
658 | lu = upper_32_bits(region.end); | 657 | lu = upper_32_bits(region.end); |
659 | } | 658 | } |
660 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 659 | pci_info(bridge, " bridge window %pR\n", res); |
661 | } else { | 660 | } else { |
662 | l = 0x0000fff0; | 661 | l = 0x0000fff0; |
663 | } | 662 | } |
@@ -672,7 +671,7 @@ static void __pci_setup_bridge(struct pci_bus *bus, unsigned long type) | |||
672 | { | 671 | { |
673 | struct pci_dev *bridge = bus->self; | 672 | struct pci_dev *bridge = bus->self; |
674 | 673 | ||
675 | dev_info(&bridge->dev, "PCI bridge to %pR\n", | 674 | pci_info(bridge, "PCI bridge to %pR\n", |
676 | &bus->busn_res); | 675 | &bus->busn_res); |
677 | 676 | ||
678 | if (type & IORESOURCE_IO) | 677 | if (type & IORESOURCE_IO) |
@@ -944,7 +943,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
944 | resource_size(b_res), min_align); | 943 | resource_size(b_res), min_align); |
945 | if (!size0 && !size1) { | 944 | if (!size0 && !size1) { |
946 | if (b_res->start || b_res->end) | 945 | if (b_res->start || b_res->end) |
947 | dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n", | 946 | pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", |
948 | b_res, &bus->busn_res); | 947 | b_res, &bus->busn_res); |
949 | b_res->flags = 0; | 948 | b_res->flags = 0; |
950 | return; | 949 | return; |
@@ -956,7 +955,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
956 | if (size1 > size0 && realloc_head) { | 955 | if (size1 > size0 && realloc_head) { |
957 | add_to_list(realloc_head, bus->self, b_res, size1-size0, | 956 | add_to_list(realloc_head, bus->self, b_res, size1-size0, |
958 | min_align); | 957 | min_align); |
959 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx\n", | 958 | pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", |
960 | b_res, &bus->busn_res, | 959 | b_res, &bus->busn_res, |
961 | (unsigned long long)size1-size0); | 960 | (unsigned long long)size1-size0); |
962 | } | 961 | } |
@@ -1061,7 +1060,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1061 | if (order < 0) | 1060 | if (order < 0) |
1062 | order = 0; | 1061 | order = 0; |
1063 | if (order >= ARRAY_SIZE(aligns)) { | 1062 | if (order >= ARRAY_SIZE(aligns)) { |
1064 | dev_warn(&dev->dev, "disabling BAR %d: %pR (bad alignment %#llx)\n", | 1063 | pci_warn(dev, "disabling BAR %d: %pR (bad alignment %#llx)\n", |
1065 | i, r, (unsigned long long) align); | 1064 | i, r, (unsigned long long) align); |
1066 | r->flags = 0; | 1065 | r->flags = 0; |
1067 | continue; | 1066 | continue; |
@@ -1093,7 +1092,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1093 | resource_size(b_res), add_align); | 1092 | resource_size(b_res), add_align); |
1094 | if (!size0 && !size1) { | 1093 | if (!size0 && !size1) { |
1095 | if (b_res->start || b_res->end) | 1094 | if (b_res->start || b_res->end) |
1096 | dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n", | 1095 | pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", |
1097 | b_res, &bus->busn_res); | 1096 | b_res, &bus->busn_res); |
1098 | b_res->flags = 0; | 1097 | b_res->flags = 0; |
1099 | return 0; | 1098 | return 0; |
@@ -1103,7 +1102,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1103 | b_res->flags |= IORESOURCE_STARTALIGN; | 1102 | b_res->flags |= IORESOURCE_STARTALIGN; |
1104 | if (size1 > size0 && realloc_head) { | 1103 | if (size1 > size0 && realloc_head) { |
1105 | add_to_list(realloc_head, bus->self, b_res, size1-size0, add_align); | 1104 | add_to_list(realloc_head, bus->self, b_res, size1-size0, add_align); |
1106 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx add_align %llx\n", | 1105 | pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", |
1107 | b_res, &bus->busn_res, | 1106 | b_res, &bus->busn_res, |
1108 | (unsigned long long) (size1 - size0), | 1107 | (unsigned long long) (size1 - size0), |
1109 | (unsigned long long) add_align); | 1108 | (unsigned long long) add_align); |
@@ -1407,7 +1406,7 @@ void __pci_bus_assign_resources(const struct pci_bus *bus, | |||
1407 | break; | 1406 | break; |
1408 | 1407 | ||
1409 | default: | 1408 | default: |
1410 | dev_info(&dev->dev, "not setting up bridge for bus %04x:%02x\n", | 1409 | pci_info(dev, "not setting up bridge for bus %04x:%02x\n", |
1411 | pci_domain_nr(b), b->number); | 1410 | pci_domain_nr(b), b->number); |
1412 | break; | 1411 | break; |
1413 | } | 1412 | } |
@@ -1513,7 +1512,7 @@ static void __pci_bridge_assign_resources(const struct pci_dev *bridge, | |||
1513 | break; | 1512 | break; |
1514 | 1513 | ||
1515 | default: | 1514 | default: |
1516 | dev_info(&bridge->dev, "not setting up bridge for bus %04x:%02x\n", | 1515 | pci_info(bridge, "not setting up bridge for bus %04x:%02x\n", |
1517 | pci_domain_nr(b), b->number); | 1516 | pci_domain_nr(b), b->number); |
1518 | break; | 1517 | break; |
1519 | } | 1518 | } |
@@ -1571,7 +1570,7 @@ static void pci_bridge_release_resources(struct pci_bus *bus, | |||
1571 | release_child_resources(r); | 1570 | release_child_resources(r); |
1572 | if (!release_resource(r)) { | 1571 | if (!release_resource(r)) { |
1573 | type = old_flags = r->flags & PCI_RES_TYPE_MASK; | 1572 | type = old_flags = r->flags & PCI_RES_TYPE_MASK; |
1574 | dev_printk(KERN_DEBUG, &dev->dev, "resource %d %pR released\n", | 1573 | pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n", |
1575 | PCI_BRIDGE_RESOURCES + idx, r); | 1574 | PCI_BRIDGE_RESOURCES + idx, r); |
1576 | /* keep the old size */ | 1575 | /* keep the old size */ |
1577 | r->end = resource_size(r) - 1; | 1576 | r->end = resource_size(r) - 1; |
@@ -1874,7 +1873,7 @@ static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, | |||
1874 | return; | 1873 | return; |
1875 | 1874 | ||
1876 | dev_res->add_size = available - resource_size(res); | 1875 | dev_res->add_size = available - resource_size(res); |
1877 | dev_dbg(&bridge->dev, "bridge window %pR extended by %pa\n", res, | 1876 | pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, |
1878 | &dev_res->add_size); | 1877 | &dev_res->add_size); |
1879 | } | 1878 | } |
1880 | 1879 | ||
@@ -2085,7 +2084,7 @@ again: | |||
2085 | enable_all: | 2084 | enable_all: |
2086 | retval = pci_reenable_device(bridge); | 2085 | retval = pci_reenable_device(bridge); |
2087 | if (retval) | 2086 | if (retval) |
2088 | dev_err(&bridge->dev, "Error reenabling bridge (%d)\n", retval); | 2087 | pci_err(bridge, "Error reenabling bridge (%d)\n", retval); |
2089 | pci_set_master(bridge); | 2088 | pci_set_master(bridge); |
2090 | } | 2089 | } |
2091 | EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); | 2090 | EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); |
@@ -2119,7 +2118,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type) | |||
2119 | if (ret) | 2118 | if (ret) |
2120 | goto cleanup; | 2119 | goto cleanup; |
2121 | 2120 | ||
2122 | dev_info(&bridge->dev, "BAR %d: releasing %pR\n", | 2121 | pci_info(bridge, "BAR %d: releasing %pR\n", |
2123 | i, res); | 2122 | i, res); |
2124 | 2123 | ||
2125 | if (res->parent) | 2124 | if (res->parent) |
diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c index 86106c44ce94..5ad4ee7d7b1e 100644 --- a/drivers/pci/setup-irq.c +++ b/drivers/pci/setup-irq.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/setup-irq.c | 3 | * drivers/pci/setup-irq.c |
3 | * | 4 | * |
@@ -25,7 +26,7 @@ void pci_assign_irq(struct pci_dev *dev) | |||
25 | struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); | 26 | struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); |
26 | 27 | ||
27 | if (!(hbrg->map_irq)) { | 28 | if (!(hbrg->map_irq)) { |
28 | dev_dbg(&dev->dev, "runtime IRQ mapping not provided by arch\n"); | 29 | pci_dbg(dev, "runtime IRQ mapping not provided by arch\n"); |
29 | return; | 30 | return; |
30 | } | 31 | } |
31 | 32 | ||
@@ -55,7 +56,7 @@ void pci_assign_irq(struct pci_dev *dev) | |||
55 | } | 56 | } |
56 | dev->irq = irq; | 57 | dev->irq = irq; |
57 | 58 | ||
58 | dev_dbg(&dev->dev, "assign IRQ: got %d\n", dev->irq); | 59 | pci_dbg(dev, "assign IRQ: got %d\n", dev->irq); |
59 | 60 | ||
60 | /* Always tell the device, so the driver knows what is | 61 | /* Always tell the device, so the driver knows what is |
61 | the real IRQ to use; the device does not use it. */ | 62 | the real IRQ to use; the device does not use it. */ |
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index e815111f3f81..369d48d6c6f1 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c | |||
@@ -103,7 +103,7 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno) | |||
103 | pci_read_config_dword(dev, reg, &check); | 103 | pci_read_config_dword(dev, reg, &check); |
104 | 104 | ||
105 | if ((new ^ check) & mask) { | 105 | if ((new ^ check) & mask) { |
106 | dev_err(&dev->dev, "BAR %d: error updating (%#08x != %#08x)\n", | 106 | pci_err(dev, "BAR %d: error updating (%#08x != %#08x)\n", |
107 | resno, new, check); | 107 | resno, new, check); |
108 | } | 108 | } |
109 | 109 | ||
@@ -112,7 +112,7 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno) | |||
112 | pci_write_config_dword(dev, reg + 4, new); | 112 | pci_write_config_dword(dev, reg + 4, new); |
113 | pci_read_config_dword(dev, reg + 4, &check); | 113 | pci_read_config_dword(dev, reg + 4, &check); |
114 | if (check != new) { | 114 | if (check != new) { |
115 | dev_err(&dev->dev, "BAR %d: error updating (high %#08x != %#08x)\n", | 115 | pci_err(dev, "BAR %d: error updating (high %#08x != %#08x)\n", |
116 | resno, new, check); | 116 | resno, new, check); |
117 | } | 117 | } |
118 | } | 118 | } |
@@ -137,7 +137,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource) | |||
137 | struct resource *root, *conflict; | 137 | struct resource *root, *conflict; |
138 | 138 | ||
139 | if (res->flags & IORESOURCE_UNSET) { | 139 | if (res->flags & IORESOURCE_UNSET) { |
140 | dev_info(&dev->dev, "can't claim BAR %d %pR: no address assigned\n", | 140 | pci_info(dev, "can't claim BAR %d %pR: no address assigned\n", |
141 | resource, res); | 141 | resource, res); |
142 | return -EINVAL; | 142 | return -EINVAL; |
143 | } | 143 | } |
@@ -152,7 +152,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource) | |||
152 | 152 | ||
153 | root = pci_find_parent_resource(dev, res); | 153 | root = pci_find_parent_resource(dev, res); |
154 | if (!root) { | 154 | if (!root) { |
155 | dev_info(&dev->dev, "can't claim BAR %d %pR: no compatible bridge window\n", | 155 | pci_info(dev, "can't claim BAR %d %pR: no compatible bridge window\n", |
156 | resource, res); | 156 | resource, res); |
157 | res->flags |= IORESOURCE_UNSET; | 157 | res->flags |= IORESOURCE_UNSET; |
158 | return -EINVAL; | 158 | return -EINVAL; |
@@ -160,7 +160,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource) | |||
160 | 160 | ||
161 | conflict = request_resource_conflict(root, res); | 161 | conflict = request_resource_conflict(root, res); |
162 | if (conflict) { | 162 | if (conflict) { |
163 | dev_info(&dev->dev, "can't claim BAR %d %pR: address conflict with %s %pR\n", | 163 | pci_info(dev, "can't claim BAR %d %pR: address conflict with %s %pR\n", |
164 | resource, res, conflict->name, conflict); | 164 | resource, res, conflict->name, conflict); |
165 | res->flags |= IORESOURCE_UNSET; | 165 | res->flags |= IORESOURCE_UNSET; |
166 | return -EBUSY; | 166 | return -EBUSY; |
@@ -172,7 +172,7 @@ EXPORT_SYMBOL(pci_claim_resource); | |||
172 | 172 | ||
173 | void pci_disable_bridge_window(struct pci_dev *dev) | 173 | void pci_disable_bridge_window(struct pci_dev *dev) |
174 | { | 174 | { |
175 | dev_info(&dev->dev, "disabling bridge mem windows\n"); | 175 | pci_info(dev, "disabling bridge mem windows\n"); |
176 | 176 | ||
177 | /* MMIO Base/Limit */ | 177 | /* MMIO Base/Limit */ |
178 | pci_write_config_dword(dev, PCI_MEMORY_BASE, 0x0000fff0); | 178 | pci_write_config_dword(dev, PCI_MEMORY_BASE, 0x0000fff0); |
@@ -221,11 +221,11 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev, | |||
221 | root = &iomem_resource; | 221 | root = &iomem_resource; |
222 | } | 222 | } |
223 | 223 | ||
224 | dev_info(&dev->dev, "BAR %d: trying firmware assignment %pR\n", | 224 | pci_info(dev, "BAR %d: trying firmware assignment %pR\n", |
225 | resno, res); | 225 | resno, res); |
226 | conflict = request_resource_conflict(root, res); | 226 | conflict = request_resource_conflict(root, res); |
227 | if (conflict) { | 227 | if (conflict) { |
228 | dev_info(&dev->dev, "BAR %d: %pR conflicts with %s %pR\n", | 228 | pci_info(dev, "BAR %d: %pR conflicts with %s %pR\n", |
229 | resno, res, conflict->name, conflict); | 229 | resno, res, conflict->name, conflict); |
230 | res->start = start; | 230 | res->start = start; |
231 | res->end = end; | 231 | res->end = end; |
@@ -324,7 +324,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno) | |||
324 | res->flags |= IORESOURCE_UNSET; | 324 | res->flags |= IORESOURCE_UNSET; |
325 | align = pci_resource_alignment(dev, res); | 325 | align = pci_resource_alignment(dev, res); |
326 | if (!align) { | 326 | if (!align) { |
327 | dev_info(&dev->dev, "BAR %d: can't assign %pR (bogus alignment)\n", | 327 | pci_info(dev, "BAR %d: can't assign %pR (bogus alignment)\n", |
328 | resno, res); | 328 | resno, res); |
329 | return -EINVAL; | 329 | return -EINVAL; |
330 | } | 330 | } |
@@ -338,19 +338,18 @@ int pci_assign_resource(struct pci_dev *dev, int resno) | |||
338 | * working, which is better than just leaving it disabled. | 338 | * working, which is better than just leaving it disabled. |
339 | */ | 339 | */ |
340 | if (ret < 0) { | 340 | if (ret < 0) { |
341 | dev_info(&dev->dev, "BAR %d: no space for %pR\n", resno, res); | 341 | pci_info(dev, "BAR %d: no space for %pR\n", resno, res); |
342 | ret = pci_revert_fw_address(res, dev, resno, size); | 342 | ret = pci_revert_fw_address(res, dev, resno, size); |
343 | } | 343 | } |
344 | 344 | ||
345 | if (ret < 0) { | 345 | if (ret < 0) { |
346 | dev_info(&dev->dev, "BAR %d: failed to assign %pR\n", resno, | 346 | pci_info(dev, "BAR %d: failed to assign %pR\n", resno, res); |
347 | res); | ||
348 | return ret; | 347 | return ret; |
349 | } | 348 | } |
350 | 349 | ||
351 | res->flags &= ~IORESOURCE_UNSET; | 350 | res->flags &= ~IORESOURCE_UNSET; |
352 | res->flags &= ~IORESOURCE_STARTALIGN; | 351 | res->flags &= ~IORESOURCE_STARTALIGN; |
353 | dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); | 352 | pci_info(dev, "BAR %d: assigned %pR\n", resno, res); |
354 | if (resno < PCI_BRIDGE_RESOURCES) | 353 | if (resno < PCI_BRIDGE_RESOURCES) |
355 | pci_update_resource(dev, resno); | 354 | pci_update_resource(dev, resno); |
356 | 355 | ||
@@ -372,7 +371,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz | |||
372 | flags = res->flags; | 371 | flags = res->flags; |
373 | res->flags |= IORESOURCE_UNSET; | 372 | res->flags |= IORESOURCE_UNSET; |
374 | if (!res->parent) { | 373 | if (!res->parent) { |
375 | dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n", | 374 | pci_info(dev, "BAR %d: can't reassign an unassigned resource %pR\n", |
376 | resno, res); | 375 | resno, res); |
377 | return -EINVAL; | 376 | return -EINVAL; |
378 | } | 377 | } |
@@ -382,14 +381,14 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz | |||
382 | ret = _pci_assign_resource(dev, resno, new_size, min_align); | 381 | ret = _pci_assign_resource(dev, resno, new_size, min_align); |
383 | if (ret) { | 382 | if (ret) { |
384 | res->flags = flags; | 383 | res->flags = flags; |
385 | dev_info(&dev->dev, "BAR %d: %pR (failed to expand by %#llx)\n", | 384 | pci_info(dev, "BAR %d: %pR (failed to expand by %#llx)\n", |
386 | resno, res, (unsigned long long) addsize); | 385 | resno, res, (unsigned long long) addsize); |
387 | return ret; | 386 | return ret; |
388 | } | 387 | } |
389 | 388 | ||
390 | res->flags &= ~IORESOURCE_UNSET; | 389 | res->flags &= ~IORESOURCE_UNSET; |
391 | res->flags &= ~IORESOURCE_STARTALIGN; | 390 | res->flags &= ~IORESOURCE_STARTALIGN; |
392 | dev_info(&dev->dev, "BAR %d: reassigned %pR (expanded by %#llx)\n", | 391 | pci_info(dev, "BAR %d: reassigned %pR (expanded by %#llx)\n", |
393 | resno, res, (unsigned long long) addsize); | 392 | resno, res, (unsigned long long) addsize); |
394 | if (resno < PCI_BRIDGE_RESOURCES) | 393 | if (resno < PCI_BRIDGE_RESOURCES) |
395 | pci_update_resource(dev, resno); | 394 | pci_update_resource(dev, resno); |
@@ -401,7 +400,7 @@ void pci_release_resource(struct pci_dev *dev, int resno) | |||
401 | { | 400 | { |
402 | struct resource *res = dev->resource + resno; | 401 | struct resource *res = dev->resource + resno; |
403 | 402 | ||
404 | dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res); | 403 | pci_info(dev, "BAR %d: releasing %pR\n", resno, res); |
405 | release_resource(res); | 404 | release_resource(res); |
406 | res->end = resource_size(res) - 1; | 405 | res->end = resource_size(res) - 1; |
407 | res->start = 0; | 406 | res->start = 0; |
@@ -477,13 +476,13 @@ int pci_enable_resources(struct pci_dev *dev, int mask) | |||
477 | continue; | 476 | continue; |
478 | 477 | ||
479 | if (r->flags & IORESOURCE_UNSET) { | 478 | if (r->flags & IORESOURCE_UNSET) { |
480 | dev_err(&dev->dev, "can't enable device: BAR %d %pR not assigned\n", | 479 | pci_err(dev, "can't enable device: BAR %d %pR not assigned\n", |
481 | i, r); | 480 | i, r); |
482 | return -EINVAL; | 481 | return -EINVAL; |
483 | } | 482 | } |
484 | 483 | ||
485 | if (!r->parent) { | 484 | if (!r->parent) { |
486 | dev_err(&dev->dev, "can't enable device: BAR %d %pR not claimed\n", | 485 | pci_err(dev, "can't enable device: BAR %d %pR not claimed\n", |
487 | i, r); | 486 | i, r); |
488 | return -EINVAL; | 487 | return -EINVAL; |
489 | } | 488 | } |
@@ -495,8 +494,7 @@ int pci_enable_resources(struct pci_dev *dev, int mask) | |||
495 | } | 494 | } |
496 | 495 | ||
497 | if (cmd != old_cmd) { | 496 | if (cmd != old_cmd) { |
498 | dev_info(&dev->dev, "enabling device (%04x -> %04x)\n", | 497 | pci_info(dev, "enabling device (%04x -> %04x)\n", old_cmd, cmd); |
499 | old_cmd, cmd); | ||
500 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 498 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
501 | } | 499 | } |
502 | return 0; | 500 | return 0; |
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index e42909524dee..d10f556dc03e 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * drivers/pci/slot.c | 3 | * drivers/pci/slot.c |
3 | * Copyright (C) 2006 Matthew Wilcox <matthew@wil.cx> | 4 | * Copyright (C) 2006 Matthew Wilcox <matthew@wil.cx> |
diff --git a/drivers/pci/switch/Kconfig b/drivers/pci/switch/Kconfig index 4c49648e0646..aee28a5bb98f 100644 --- a/drivers/pci/switch/Kconfig +++ b/drivers/pci/switch/Kconfig | |||
@@ -1,3 +1,5 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
2 | |||
1 | menu "PCI switch controller drivers" | 3 | menu "PCI switch controller drivers" |
2 | depends on PCI | 4 | depends on PCI |
3 | 5 | ||
diff --git a/drivers/pci/switch/Makefile b/drivers/pci/switch/Makefile index 37d8cfb03f3f..acd56d3b4a35 100644 --- a/drivers/pci/switch/Makefile +++ b/drivers/pci/switch/Makefile | |||
@@ -1 +1,2 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
1 | obj-$(CONFIG_PCI_SW_SWITCHTEC) += switchtec.o | 2 | obj-$(CONFIG_PCI_SW_SWITCHTEC) += switchtec.o |
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 730cc897b94d..a60c0ab7883d 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c | |||
@@ -1,16 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Microsemi Switchtec(tm) PCIe Management Driver | 3 | * Microsemi Switchtec(tm) PCIe Management Driver |
3 | * Copyright (c) 2017, Microsemi Corporation | 4 | * Copyright (c) 2017, Microsemi Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | */ | 5 | */ |
15 | 6 | ||
16 | #include <linux/switchtec.h> | 7 | #include <linux/switchtec.h> |
@@ -510,11 +501,11 @@ out: | |||
510 | return -EBADMSG; | 501 | return -EBADMSG; |
511 | } | 502 | } |
512 | 503 | ||
513 | static unsigned int switchtec_dev_poll(struct file *filp, poll_table *wait) | 504 | static __poll_t switchtec_dev_poll(struct file *filp, poll_table *wait) |
514 | { | 505 | { |
515 | struct switchtec_user *stuser = filp->private_data; | 506 | struct switchtec_user *stuser = filp->private_data; |
516 | struct switchtec_dev *stdev = stuser->stdev; | 507 | struct switchtec_dev *stdev = stuser->stdev; |
517 | int ret = 0; | 508 | __poll_t ret = 0; |
518 | 509 | ||
519 | poll_wait(filp, &stuser->comp.wait, wait); | 510 | poll_wait(filp, &stuser->comp.wait, wait); |
520 | poll_wait(filp, &stdev->event_wq, wait); | 511 | poll_wait(filp, &stdev->event_wq, wait); |
@@ -707,6 +698,7 @@ static const struct event_reg { | |||
707 | EV_GLB(SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP_ASYNC, | 698 | EV_GLB(SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP_ASYNC, |
708 | cli_mrpc_comp_async_hdr), | 699 | cli_mrpc_comp_async_hdr), |
709 | EV_GLB(SWITCHTEC_IOCTL_EVENT_GPIO_INT, gpio_interrupt_hdr), | 700 | EV_GLB(SWITCHTEC_IOCTL_EVENT_GPIO_INT, gpio_interrupt_hdr), |
701 | EV_GLB(SWITCHTEC_IOCTL_EVENT_GFMS, gfms_event_hdr), | ||
710 | EV_PAR(SWITCHTEC_IOCTL_EVENT_PART_RESET, part_reset_hdr), | 702 | EV_PAR(SWITCHTEC_IOCTL_EVENT_PART_RESET, part_reset_hdr), |
711 | EV_PAR(SWITCHTEC_IOCTL_EVENT_MRPC_COMP, mrpc_comp_hdr), | 703 | EV_PAR(SWITCHTEC_IOCTL_EVENT_MRPC_COMP, mrpc_comp_hdr), |
712 | EV_PAR(SWITCHTEC_IOCTL_EVENT_MRPC_COMP_ASYNC, mrpc_comp_async_hdr), | 704 | EV_PAR(SWITCHTEC_IOCTL_EVENT_MRPC_COMP_ASYNC, mrpc_comp_async_hdr), |
@@ -1352,6 +1344,8 @@ static const struct pci_device_id switchtec_pci_tbl[] = { | |||
1352 | SWITCHTEC_PCI_DEVICE(0x8534), //PFX 64xG3 | 1344 | SWITCHTEC_PCI_DEVICE(0x8534), //PFX 64xG3 |
1353 | SWITCHTEC_PCI_DEVICE(0x8535), //PFX 80xG3 | 1345 | SWITCHTEC_PCI_DEVICE(0x8535), //PFX 80xG3 |
1354 | SWITCHTEC_PCI_DEVICE(0x8536), //PFX 96xG3 | 1346 | SWITCHTEC_PCI_DEVICE(0x8536), //PFX 96xG3 |
1347 | SWITCHTEC_PCI_DEVICE(0x8541), //PSX 24xG3 | ||
1348 | SWITCHTEC_PCI_DEVICE(0x8542), //PSX 32xG3 | ||
1355 | SWITCHTEC_PCI_DEVICE(0x8543), //PSX 48xG3 | 1349 | SWITCHTEC_PCI_DEVICE(0x8543), //PSX 48xG3 |
1356 | SWITCHTEC_PCI_DEVICE(0x8544), //PSX 64xG3 | 1350 | SWITCHTEC_PCI_DEVICE(0x8544), //PSX 64xG3 |
1357 | SWITCHTEC_PCI_DEVICE(0x8545), //PSX 80xG3 | 1351 | SWITCHTEC_PCI_DEVICE(0x8545), //PSX 80xG3 |
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c index 83efa001c2e7..e725f99b5479 100644 --- a/drivers/pci/syscall.c +++ b/drivers/pci/syscall.c | |||
@@ -28,7 +28,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, | |||
28 | return -EPERM; | 28 | return -EPERM; |
29 | 29 | ||
30 | err = -ENODEV; | 30 | err = -ENODEV; |
31 | dev = pci_get_bus_and_slot(bus, dfn); | 31 | dev = pci_get_domain_bus_and_slot(0, bus, dfn); |
32 | if (!dev) | 32 | if (!dev) |
33 | goto error; | 33 | goto error; |
34 | 34 | ||
@@ -96,7 +96,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn, | |||
96 | if (!capable(CAP_SYS_ADMIN)) | 96 | if (!capable(CAP_SYS_ADMIN)) |
97 | return -EPERM; | 97 | return -EPERM; |
98 | 98 | ||
99 | dev = pci_get_bus_and_slot(bus, dfn); | 99 | dev = pci_get_domain_bus_and_slot(0, bus, dfn); |
100 | if (!dev) | 100 | if (!dev) |
101 | return -ENODEV; | 101 | return -ENODEV; |
102 | 102 | ||
diff --git a/drivers/pci/vc.c b/drivers/pci/vc.c index 1fa3a3219c45..5acd9c02683a 100644 --- a/drivers/pci/vc.c +++ b/drivers/pci/vc.c | |||
@@ -1,12 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * PCI Virtual Channel support | 3 | * PCI Virtual Channel support |
3 | * | 4 | * |
4 | * Copyright (C) 2013 Red Hat, Inc. All rights reserved. | 5 | * Copyright (C) 2013 Red Hat, Inc. All rights reserved. |
5 | * Author: Alex Williamson <alex.williamson@redhat.com> | 6 | * Author: Alex Williamson <alex.williamson@redhat.com> |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | 7 | */ |
11 | 8 | ||
12 | #include <linux/device.h> | 9 | #include <linux/device.h> |
@@ -57,7 +54,7 @@ static void pci_vc_load_arb_table(struct pci_dev *dev, int pos) | |||
57 | PCI_VC_PORT_STATUS_TABLE)) | 54 | PCI_VC_PORT_STATUS_TABLE)) |
58 | return; | 55 | return; |
59 | 56 | ||
60 | dev_err(&dev->dev, "VC arbitration table failed to load\n"); | 57 | pci_err(dev, "VC arbitration table failed to load\n"); |
61 | } | 58 | } |
62 | 59 | ||
63 | /** | 60 | /** |
@@ -85,7 +82,7 @@ static void pci_vc_load_port_arb_table(struct pci_dev *dev, int pos, int res) | |||
85 | if (pci_wait_for_pending(dev, status_pos, PCI_VC_RES_STATUS_TABLE)) | 82 | if (pci_wait_for_pending(dev, status_pos, PCI_VC_RES_STATUS_TABLE)) |
86 | return; | 83 | return; |
87 | 84 | ||
88 | dev_err(&dev->dev, "VC%d port arbitration table failed to load\n", res); | 85 | pci_err(dev, "VC%d port arbitration table failed to load\n", res); |
89 | } | 86 | } |
90 | 87 | ||
91 | /** | 88 | /** |
@@ -161,11 +158,11 @@ enable: | |||
161 | pci_write_config_dword(dev, ctrl_pos, ctrl); | 158 | pci_write_config_dword(dev, ctrl_pos, ctrl); |
162 | 159 | ||
163 | if (!pci_wait_for_pending(dev, status_pos, PCI_VC_RES_STATUS_NEGO)) | 160 | if (!pci_wait_for_pending(dev, status_pos, PCI_VC_RES_STATUS_NEGO)) |
164 | dev_err(&dev->dev, "VC%d negotiation stuck pending\n", id); | 161 | pci_err(dev, "VC%d negotiation stuck pending\n", id); |
165 | 162 | ||
166 | if (link && !pci_wait_for_pending(link, status_pos2, | 163 | if (link && !pci_wait_for_pending(link, status_pos2, |
167 | PCI_VC_RES_STATUS_NEGO)) | 164 | PCI_VC_RES_STATUS_NEGO)) |
168 | dev_err(&link->dev, "VC%d negotiation stuck pending\n", id); | 165 | pci_err(link, "VC%d negotiation stuck pending\n", id); |
169 | } | 166 | } |
170 | 167 | ||
171 | /** | 168 | /** |
@@ -195,8 +192,7 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos, | |||
195 | /* Sanity check buffer size for save/restore */ | 192 | /* Sanity check buffer size for save/restore */ |
196 | if (buf && save_state->cap.size != | 193 | if (buf && save_state->cap.size != |
197 | pci_vc_do_save_buffer(dev, pos, NULL, save)) { | 194 | pci_vc_do_save_buffer(dev, pos, NULL, save)) { |
198 | dev_err(&dev->dev, | 195 | pci_err(dev, "VC save buffer size does not match @0x%x\n", pos); |
199 | "VC save buffer size does not match @0x%x\n", pos); | ||
200 | return -ENOMEM; | 196 | return -ENOMEM; |
201 | } | 197 | } |
202 | 198 | ||
@@ -366,14 +362,14 @@ int pci_save_vc_state(struct pci_dev *dev) | |||
366 | 362 | ||
367 | save_state = pci_find_saved_ext_cap(dev, vc_caps[i].id); | 363 | save_state = pci_find_saved_ext_cap(dev, vc_caps[i].id); |
368 | if (!save_state) { | 364 | if (!save_state) { |
369 | dev_err(&dev->dev, "%s buffer not found in %s\n", | 365 | pci_err(dev, "%s buffer not found in %s\n", |
370 | vc_caps[i].name, __func__); | 366 | vc_caps[i].name, __func__); |
371 | return -ENOMEM; | 367 | return -ENOMEM; |
372 | } | 368 | } |
373 | 369 | ||
374 | ret = pci_vc_do_save_buffer(dev, pos, save_state, true); | 370 | ret = pci_vc_do_save_buffer(dev, pos, save_state, true); |
375 | if (ret) { | 371 | if (ret) { |
376 | dev_err(&dev->dev, "%s save unsuccessful %s\n", | 372 | pci_err(dev, "%s save unsuccessful %s\n", |
377 | vc_caps[i].name, __func__); | 373 | vc_caps[i].name, __func__); |
378 | return ret; | 374 | return ret; |
379 | } | 375 | } |
@@ -426,8 +422,7 @@ void pci_allocate_vc_save_buffers(struct pci_dev *dev) | |||
426 | 422 | ||
427 | len = pci_vc_do_save_buffer(dev, pos, NULL, false); | 423 | len = pci_vc_do_save_buffer(dev, pos, NULL, false); |
428 | if (pci_add_ext_cap_save_buffer(dev, vc_caps[i].id, len)) | 424 | if (pci_add_ext_cap_save_buffer(dev, vc_caps[i].id, len)) |
429 | dev_err(&dev->dev, | 425 | pci_err(dev, "unable to preallocate %s save buffer\n", |
430 | "unable to preallocate %s save buffer\n", | ||
431 | vc_caps[i].name); | 426 | vc_caps[i].name); |
432 | } | 427 | } |
433 | } | 428 | } |
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 39b79070335d..70fba57d6103 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * File: vpd.c | 3 | * File: vpd.c |
3 | * Purpose: Provide PCI VPD support | 4 | * Purpose: Provide PCI VPD support |
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 8fc2e9532575..8785014f656e 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * Xen PCI Frontend. | 3 | * Xen PCI Frontend. |
3 | * | 4 | * |
@@ -261,8 +262,8 @@ static int pci_frontend_enable_msix(struct pci_dev *dev, | |||
261 | struct msi_desc *entry; | 262 | struct msi_desc *entry; |
262 | 263 | ||
263 | if (nvec > SH_INFO_MAX_VEC) { | 264 | if (nvec > SH_INFO_MAX_VEC) { |
264 | dev_err(&dev->dev, "too much vector for pci frontend: %x." | 265 | pci_err(dev, "too many vectors (0x%x) for PCI frontend:" |
265 | " Increase SH_INFO_MAX_VEC.\n", nvec); | 266 | " Increase SH_INFO_MAX_VEC\n", nvec); |
266 | return -EINVAL; | 267 | return -EINVAL; |
267 | } | 268 | } |
268 | 269 | ||
@@ -281,7 +282,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev, | |||
281 | /* we get the result */ | 282 | /* we get the result */ |
282 | for (i = 0; i < nvec; i++) { | 283 | for (i = 0; i < nvec; i++) { |
283 | if (op.msix_entries[i].vector <= 0) { | 284 | if (op.msix_entries[i].vector <= 0) { |
284 | dev_warn(&dev->dev, "MSI-X entry %d is invalid: %d!\n", | 285 | pci_warn(dev, "MSI-X entry %d is invalid: %d!\n", |
285 | i, op.msix_entries[i].vector); | 286 | i, op.msix_entries[i].vector); |
286 | err = -EINVAL; | 287 | err = -EINVAL; |
287 | vector[i] = -1; | 288 | vector[i] = -1; |
@@ -295,7 +296,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev, | |||
295 | err = op.value; | 296 | err = op.value; |
296 | } | 297 | } |
297 | } else { | 298 | } else { |
298 | dev_err(&dev->dev, "enable msix get err %x\n", err); | 299 | pci_err(dev, "enable msix get err %x\n", err); |
299 | } | 300 | } |
300 | return err; | 301 | return err; |
301 | } | 302 | } |
@@ -316,7 +317,7 @@ static void pci_frontend_disable_msix(struct pci_dev *dev) | |||
316 | 317 | ||
317 | /* What should do for error ? */ | 318 | /* What should do for error ? */ |
318 | if (err) | 319 | if (err) |
319 | dev_err(&dev->dev, "pci_disable_msix get err %x\n", err); | 320 | pci_err(dev, "pci_disable_msix get err %x\n", err); |
320 | } | 321 | } |
321 | 322 | ||
322 | static int pci_frontend_enable_msi(struct pci_dev *dev, int vector[]) | 323 | static int pci_frontend_enable_msi(struct pci_dev *dev, int vector[]) |
@@ -335,13 +336,13 @@ static int pci_frontend_enable_msi(struct pci_dev *dev, int vector[]) | |||
335 | if (likely(!err)) { | 336 | if (likely(!err)) { |
336 | vector[0] = op.value; | 337 | vector[0] = op.value; |
337 | if (op.value <= 0) { | 338 | if (op.value <= 0) { |
338 | dev_warn(&dev->dev, "MSI entry is invalid: %d!\n", | 339 | pci_warn(dev, "MSI entry is invalid: %d!\n", |
339 | op.value); | 340 | op.value); |
340 | err = -EINVAL; | 341 | err = -EINVAL; |
341 | vector[0] = -1; | 342 | vector[0] = -1; |
342 | } | 343 | } |
343 | } else { | 344 | } else { |
344 | dev_err(&dev->dev, "pci frontend enable msi failed for dev " | 345 | pci_err(dev, "pci frontend enable msi failed for dev " |
345 | "%x:%x\n", op.bus, op.devfn); | 346 | "%x:%x\n", op.bus, op.devfn); |
346 | err = -EINVAL; | 347 | err = -EINVAL; |
347 | } | 348 | } |
@@ -560,7 +561,7 @@ static void free_root_bus_devs(struct pci_bus *bus) | |||
560 | while (!list_empty(&bus->devices)) { | 561 | while (!list_empty(&bus->devices)) { |
561 | dev = container_of(bus->devices.next, struct pci_dev, | 562 | dev = container_of(bus->devices.next, struct pci_dev, |
562 | bus_list); | 563 | bus_list); |
563 | dev_dbg(&dev->dev, "removing device\n"); | 564 | pci_dbg(dev, "removing device\n"); |
564 | pci_stop_and_remove_bus_device(dev); | 565 | pci_stop_and_remove_bus_device(dev); |
565 | } | 566 | } |
566 | } | 567 | } |
@@ -595,6 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd, | |||
595 | struct pci_driver *pdrv; | 596 | struct pci_driver *pdrv; |
596 | int bus = pdev->sh_info->aer_op.bus; | 597 | int bus = pdev->sh_info->aer_op.bus; |
597 | int devfn = pdev->sh_info->aer_op.devfn; | 598 | int devfn = pdev->sh_info->aer_op.devfn; |
599 | int domain = pdev->sh_info->aer_op.domain; | ||
598 | struct pci_dev *pcidev; | 600 | struct pci_dev *pcidev; |
599 | int flag = 0; | 601 | int flag = 0; |
600 | 602 | ||
@@ -603,7 +605,7 @@ static pci_ers_result_t pcifront_common_process(int cmd, | |||
603 | cmd, bus, devfn); | 605 | cmd, bus, devfn); |
604 | result = PCI_ERS_RESULT_NONE; | 606 | result = PCI_ERS_RESULT_NONE; |
605 | 607 | ||
606 | pcidev = pci_get_bus_and_slot(bus, devfn); | 608 | pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn); |
607 | if (!pcidev || !pcidev->driver) { | 609 | if (!pcidev || !pcidev->driver) { |
608 | dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); | 610 | dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); |
609 | pci_dev_put(pcidev); | 611 | pci_dev_put(pcidev); |
@@ -613,8 +615,7 @@ static pci_ers_result_t pcifront_common_process(int cmd, | |||
613 | 615 | ||
614 | if (pdrv) { | 616 | if (pdrv) { |
615 | if (pdrv->err_handler && pdrv->err_handler->error_detected) { | 617 | if (pdrv->err_handler && pdrv->err_handler->error_detected) { |
616 | dev_dbg(&pcidev->dev, | 618 | pci_dbg(pcidev, "trying to call AER service\n"); |
617 | "trying to call AER service\n"); | ||
618 | if (pcidev) { | 619 | if (pcidev) { |
619 | flag = 1; | 620 | flag = 1; |
620 | switch (cmd) { | 621 | switch (cmd) { |