Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'pci-v4.16-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI updates from Bjorn Helgaas:

- skip AER driver error recovery callbacks for correctable errors
reported via ACPI APEI, as we already do for errors reported via the
native path (Tyler Baicar)

- fix DPC shared interrupt handling (Alex Williamson)

- print full DPC interrupt number (Keith Busch)

- enable DPC only if AER is available (Keith Busch)

- simplify DPC code (Bjorn Helgaas)

- calculate ASPM L1 substate parameter instead of hardcoding it (Bjorn
Helgaas)

- enable Latency Tolerance Reporting for ASPM L1 substates (Bjorn
Helgaas)

- move ASPM internal interfaces out of public header (Bjorn Helgaas)

- allow hot-removal of VGA devices (Mika Westerberg)

- speed up unplug and shutdown by assuming Thunderbolt controllers
don't support Command Completed events (Lukas Wunner)

- add AtomicOps support for GPU and Infiniband drivers (Felix Kuehling,
Jay Cornwall)

- expose "ari_enabled" in sysfs to help NIC naming (Stuart Hayes)

- clean up PCI DMA interface usage (Christoph Hellwig)

- remove PCI pool API (replaced with DMA pool) (Romain Perier)

- deprecate pci_get_bus_and_slot(), which assumed PCI domain 0 (Sinan
Kaya)

- move DT PCI code from drivers/of/ to drivers/pci/ (Rob Herring)

- add PCI-specific wrappers for dev_info(), etc (Frederick Lawler)

- remove warnings on sysfs mmap failure (Bjorn Helgaas)

- quiet ROM validation messages (Alex Deucher)

- remove redundant memory alloc failure messages (Markus Elfring)

- fill in types for compile-time VGA and other I/O port resources
(Bjorn Helgaas)

- make "pci=pcie_scan_all" work for Root Ports as well as Downstream
Ports to help AmigaOne X1000 (Bjorn Helgaas)

- add SPDX tags to all PCI files (Bjorn Helgaas)

- quirk Marvell 9128 DMA aliases (Alex Williamson)

- quirk broken INTx disable on Ceton InfiniTV4 (Bjorn Helgaas)

- fix CONFIG_PCI=n build by adding dummy pci_irqd_intx_xlate() (Niklas
Cassel)

- use DMA API to get MSI address for DesignWare IP (Niklas Cassel)

- fix endpoint-mode DMA mask configuration (Kishon Vijay Abraham I)

- fix ARTPEC-6 incorrect IS_ERR() usage (Wei Yongjun)

- add support for ARTPEC-7 SoC (Niklas Cassel)

- add endpoint-mode support for ARTPEC (Niklas Cassel)

- add Cadence PCIe host and endpoint controller driver (Cyrille
Pitchen)

- handle multiple INTx status bits being set in dra7xx (Vignesh R)

- translate dra7xx hwirq range to fix INTD handling (Vignesh R)

- remove deprecated Exynos PHY initialization code (Jaehoon Chung)

- fix MSI erratum workaround for HiSilicon Hip06/Hip07 (Dongdong Liu)

- fix NULL pointer dereference in iProc BCMA driver (Ray Jui)

- fix Keystone interrupt-controller-node lookup (Johan Hovold)

- constify qcom driver structures (Julia Lawall)

- rework Tegra config space mapping to increase space available for
endpoints (Vidya Sagar)

- simplify Tegra driver by using bus->sysdata (Manikanta Maddireddy)

- remove PCI_REASSIGN_ALL_BUS usage on Tegra (Manikanta Maddireddy)

- add support for Global Fabric Manager Server (GFMS) event to
Microsemi Switchtec switch driver (Logan Gunthorpe)

- add IDs for Switchtec PSX 24xG3 and PSX 48xG3 (Kelvin Cao)

* tag 'pci-v4.16-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (140 commits)
PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe endpoint controller
PCI: endpoint: Fix EPF device name to support multi-function devices
PCI: endpoint: Add the function number as argument to EPC ops
PCI: cadence: Add host driver for Cadence PCIe controller
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host controller
PCI: Add vendor ID for Cadence
PCI: Add generic function to probe PCI host controllers
PCI: generic: fix missing call of pci_free_resource_list()
PCI: OF: Add generic function to parse and allocate PCI resources
PCI: Regroup all PCI related entries into drivers/pci/Makefile
PCI/DPC: Reformat DPC register definitions
PCI/DPC: Add and use DPC Status register field definitions
PCI/DPC: Squash dpc_rp_pio_get_info() into dpc_process_rp_pio_error()
PCI/DPC: Remove unnecessary RP PIO register structs
PCI/DPC: Push dpc->rp_pio_status assignment into dpc_rp_pio_get_info()
PCI/DPC: Squash dpc_rp_pio_print_error() into dpc_rp_pio_get_info()
PCI/DPC: Make RP PIO log size check more generic
PCI/DPC: Rename local "status" to "dpc_status"
PCI/DPC: Squash dpc_rp_pio_print_tlp_header() into dpc_rp_pio_print_error()
...

+4521 -3774
+5 -1
Documentation/admin-guide/kernel-parameters.txt
··· 3711 3711 [KNL, SMP] Set scheduler's default relax_domain_level. 3712 3712 See Documentation/cgroup-v1/cpusets.txt. 3713 3713 3714 - reserve= [KNL,BUGS] Force the kernel to ignore some iomem area 3714 + reserve= [KNL,BUGS] Force kernel to ignore I/O ports or memory 3715 + Format: <base1>,<size1>[,<base2>,<size2>,...] 3716 + Reserve I/O ports or memory so the kernel won't use 3717 + them. If <base> is less than 0x10000, the region 3718 + is assumed to be I/O ports; otherwise it is memory. 3715 3719 3716 3720 reservetop= [X86-32] 3717 3721 Format: nn[KMG]
+4 -1
Documentation/devicetree/bindings/pci/axis,artpec6-pcie.txt
··· 4 4 and thus inherits all the common properties defined in designware-pcie.txt. 5 5 6 6 Required properties: 7 - - compatible: "axis,artpec6-pcie", "snps,dw-pcie" 7 + - compatible: "axis,artpec6-pcie", "snps,dw-pcie" for ARTPEC-6 in RC mode; 8 + "axis,artpec6-pcie-ep", "snps,dw-pcie" for ARTPEC-6 in EP mode; 9 + "axis,artpec7-pcie", "snps,dw-pcie" for ARTPEC-7 in RC mode; 10 + "axis,artpec7-pcie-ep", "snps,dw-pcie" for ARTPEC-7 in EP mode; 8 11 - reg: base addresses and lengths of the PCIe controller (DBI), 9 12 the PHY controller, and configuration address space. 10 13 - reg-names: Must include the following entries:
+22
Documentation/devicetree/bindings/pci/cdns,cdns-pcie-ep.txt
··· 1 + * Cadence PCIe endpoint controller 2 + 3 + Required properties: 4 + - compatible: Should contain "cdns,cdns-pcie-ep" to identify the IP used. 5 + - reg: Should contain the controller register base address and AXI interface 6 + region base address respectively. 7 + - reg-names: Must be "reg" and "mem" respectively. 8 + - cdns,max-outbound-regions: Set to maximum number of outbound regions 9 + 10 + Optional properties: 11 + - max-functions: Maximum number of functions that can be configured (default 1). 12 + 13 + Example: 14 + 15 + pcie@fc000000 { 16 + compatible = "cdns,cdns-pcie-ep"; 17 + reg = <0x0 0xfc000000 0x0 0x01000000>, 18 + <0x0 0x80000000 0x0 0x40000000>; 19 + reg-names = "reg", "mem"; 20 + cdns,max-outbound-regions = <16>; 21 + max-functions = /bits/ 8 <8>; 22 + };
+60
Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt
··· 1 + * Cadence PCIe host controller 2 + 3 + This PCIe controller inherits the base properties defined in 4 + host-generic-pci.txt. 5 + 6 + Required properties: 7 + - compatible: Should contain "cdns,cdns-pcie-host" to identify the IP used. 8 + - reg: Should contain the controller register base address, PCIe configuration 9 + window base address, and AXI interface region base address respectively. 10 + - reg-names: Must be "reg", "cfg" and "mem" respectively. 11 + - #address-cells: Set to <3> 12 + - #size-cells: Set to <2> 13 + - device_type: Set to "pci" 14 + - ranges: Ranges for the PCI memory and I/O regions 15 + - #interrupt-cells: Set to <1> 16 + - interrupt-map-mask and interrupt-map: Standard PCI properties to define the 17 + mapping of the PCIe interface to interrupt numbers. 18 + 19 + Optional properties: 20 + - cdns,max-outbound-regions: Set to maximum number of outbound regions 21 + (default 32) 22 + - cdns,no-bar-match-nbits: Set into the no BAR match register to configure the 23 + number of least significant bits kept during inbound (PCIe -> AXI) address 24 + translations (default 32) 25 + - vendor-id: The PCI vendor ID (16 bits, default is design dependent) 26 + - device-id: The PCI device ID (16 bits, default is design dependent) 27 + 28 + Example: 29 + 30 + pcie@fb000000 { 31 + compatible = "cdns,cdns-pcie-host"; 32 + device_type = "pci"; 33 + #address-cells = <3>; 34 + #size-cells = <2>; 35 + bus-range = <0x0 0xff>; 36 + linux,pci-domain = <0>; 37 + cdns,max-outbound-regions = <16>; 38 + cdns,no-bar-match-nbits = <32>; 39 + vendor-id = /bits/ 16 <0x17cd>; 40 + device-id = /bits/ 16 <0x0200>; 41 + 42 + reg = <0x0 0xfb000000 0x0 0x01000000>, 43 + <0x0 0x41000000 0x0 0x00001000>, 44 + <0x0 0x40000000 0x0 0x04000000>; 45 + reg-names = "reg", "cfg", "mem"; 46 + 47 + ranges = <0x02000000 0x0 0x42000000 0x0 0x42000000 0x0 0x1000000>, 48 + <0x01000000 0x0 0x43000000 0x0 0x43000000 0x0 0x0010000>; 49 + 50 + #interrupt-cells = <0x1>; 51 + 52 + interrupt-map = <0x0 0x0 0x0 0x1 &gic 0x0 0x0 0x0 14 0x1 53 + 0x0 0x0 0x0 0x2 &gic 0x0 0x0 0x0 15 0x1 54 + 0x0 0x0 0x0 0x3 &gic 0x0 0x0 0x0 16 0x1 55 + 0x0 0x0 0x0 0x4 &gic 0x0 0x0 0x0 17 0x1>; 56 + 57 + interrupt-map-mask = <0x0 0x0 0x0 0x7>; 58 + 59 + msi-parent = <&its_pci>; 60 + };
+11 -47
Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt
··· 6 6 Required properties: 7 7 - compatible: "samsung,exynos5440-pcie" 8 8 - reg: base addresses and lengths of the PCIe controller, 9 - the PHY controller, additional register for the PHY controller. 10 - (Registers for the PHY controller are DEPRECATED. 11 - Use the PHY framework.) 12 9 - reg-names : First name should be set to "elbi". 13 10 And use the "config" instead of getting the configuration address space 14 11 from "ranges". ··· 20 23 21 24 Example: 22 25 23 - SoC-specific DT Entry: 26 + SoC-specific DT Entry (with using PHY framework): 24 27 25 - pcie@290000 { 26 - compatible = "samsung,exynos5440-pcie", "snps,dw-pcie"; 27 - reg = <0x290000 0x1000 28 - 0x270000 0x1000 29 - 0x271000 0x40>; 30 - interrupts = <0 20 0>, <0 21 0>, <0 22 0>; 31 - clocks = <&clock 28>, <&clock 27>; 32 - clock-names = "pcie", "pcie_bus"; 33 - #address-cells = <3>; 34 - #size-cells = <2>; 35 - device_type = "pci"; 36 - ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00001000 /* configuration space */ 37 - 0x81000000 0 0 0x40001000 0 0x00010000 /* downstream I/O */ 38 - 0x82000000 0 0x40011000 0x40011000 0 0x1ffef000>; /* non-prefetchable memory */ 39 - #interrupt-cells = <1>; 40 - interrupt-map-mask = <0 0 0 0>; 41 - interrupt-map = <0 0 0 0 &gic GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; 42 - num-lanes = <4>; 43 - }; 44 - 45 - pcie@2a0000 { 46 - compatible = "samsung,exynos5440-pcie", "snps,dw-pcie"; 47 - reg = <0x2a0000 0x1000 48 - 0x272000 0x1000 49 - 0x271040 0x40>; 50 - interrupts = <0 23 0>, <0 24 0>, <0 25 0>; 51 - clocks = <&clock 29>, <&clock 27>; 52 - clock-names = "pcie", "pcie_bus"; 53 - #address-cells = <3>; 54 - #size-cells = <2>; 55 - device_type = "pci"; 56 - ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00001000 /* configuration space */ 57 - 0x81000000 0 0 0x60001000 0 0x00010000 /* downstream I/O */ 58 - 0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>; /* non-prefetchable memory */ 59 - #interrupt-cells = <1>; 60 - interrupt-map-mask = <0 0 0 0>; 61 - interrupt-map = <0 0 0 0 &gic GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>; 62 - num-lanes = <4>; 63 - }; 64 - 65 - With using PHY framework: 66 28 pcie_phy0: pcie-phy@270000 { 67 29 ... 68 30 reg = <0x270000 0x1000>, <0x271000 0x40>; ··· 30 74 }; 31 75 32 76 pcie@290000 { 33 - ... 77 + compatible = "samsung,exynos5440-pcie", "snps,dw-pcie"; 34 78 reg = <0x290000 0x1000>, <0x40000000 0x1000>; 35 79 reg-names = "elbi", "config"; 80 + clocks = <&clock 28>, <&clock 27>; 81 + clock-names = "pcie", "pcie_bus"; 82 + #address-cells = <3>; 83 + #size-cells = <2>; 84 + device_type = "pci"; 36 85 phys = <&pcie_phy0>; 37 86 ranges = <0x81000000 0 0 0x60001000 0 0x00010000 38 87 0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>; 39 - ... 88 + #interrupt-cells = <1>; 89 + interrupt-map-mask = <0 0 0 0>; 90 + interrupt-map = <0 0 0 0 &gic GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; 91 + num-lanes = <4>; 40 92 }; 41 93 42 94 Board-specific DT Entry:
+11
MAINTAINERS
··· 10513 10513 F: Documentation/devicetree/bindings/pci/pci-armada8k.txt 10514 10514 F: drivers/pci/dwc/pcie-armada8k.c 10515 10515 10516 + PCI DRIVER FOR CADENCE PCIE IP 10517 + M: Alan Douglas <adouglas@cadence.com> 10518 + L: linux-pci@vger.kernel.org 10519 + S: Maintained 10520 + F: Documentation/devicetree/bindings/pci/cdns,*.txt 10521 + F: drivers/pci/cadence/pcie-cadence* 10522 + 10516 10523 PCI DRIVER FOR FREESCALE LAYERSCAPE 10517 10524 M: Minghuan Lian <minghuan.Lian@freescale.com> 10518 10525 M: Mingkai Hu <mingkai.hu@freescale.com> ··· 10670 10663 S: Supported 10671 10664 F: Documentation/devicetree/bindings/pci/ 10672 10665 F: Documentation/PCI/ 10666 + F: drivers/acpi/pci* 10673 10667 F: drivers/pci/ 10668 + F: include/asm-generic/pci* 10674 10669 F: include/linux/pci* 10670 + F: include/uapi/linux/pci* 10671 + F: lib/pci* 10675 10672 F: arch/x86/pci/ 10676 10673 F: arch/x86/kernel/quirks.c 10677 10674
+1
arch/alpha/kernel/console.c
··· 21 21 struct pci_controller *pci_vga_hose; 22 22 static struct resource alpha_vga = { 23 23 .name = "alpha-vga+", 24 + .flags = IORESOURCE_IO, 24 25 .start = 0x3C0, 25 26 .end = 0x3DF 26 27 };
+1 -4
arch/arm/include/asm/pci.h
··· 10 10 extern unsigned long pcibios_min_mem; 11 11 #define PCIBIOS_MIN_MEM pcibios_min_mem 12 12 13 - static inline int pcibios_assign_all_busses(void) 14 - { 15 - return pci_has_flag(PCI_REASSIGN_ALL_RSRC); 16 - } 13 + #define pcibios_assign_all_busses() pci_has_flag(PCI_REASSIGN_ALL_BUS) 17 14 18 15 #ifdef CONFIG_PCI_DOMAINS 19 16 static inline int pci_proc_domain(struct pci_bus *bus)
+1 -1
arch/arm/kernel/bios32.c
··· 527 527 struct pci_sys_data *sys; 528 528 LIST_HEAD(head); 529 529 530 - pci_add_flags(PCI_REASSIGN_ALL_RSRC); 530 + pci_add_flags(PCI_REASSIGN_ALL_BUS); 531 531 if (hw->preinit) 532 532 hw->preinit(); 533 533 pcibios_init_hw(parent, hw, &head);
-1
arch/arm/mach-mvebu/Kconfig
··· 10 10 select ZONE_DMA if ARM_LPAE 11 11 select GPIOLIB 12 12 select PCI_QUIRKS if PCI 13 - select OF_ADDRESS_PCI 14 13 15 14 if ARCH_MVEBU 16 15
+4 -4
arch/mips/jazz/setup.c
··· 32 32 .start = 0x00, 33 33 .end = 0x1f, 34 34 .name = "dma1", 35 - .flags = IORESOURCE_BUSY 35 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 36 36 }, { 37 37 .start = 0x40, 38 38 .end = 0x5f, 39 39 .name = "timer", 40 - .flags = IORESOURCE_BUSY 40 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 41 41 }, { 42 42 .start = 0x80, 43 43 .end = 0x8f, 44 44 .name = "dma page reg", 45 - .flags = IORESOURCE_BUSY 45 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 46 46 }, { 47 47 .start = 0xc0, 48 48 .end = 0xdf, 49 49 .name = "dma2", 50 - .flags = IORESOURCE_BUSY 50 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 51 51 } 52 52 }; 53 53
+5 -5
arch/mips/mti-malta/malta-setup.c
··· 47 47 .name = "dma1", 48 48 .start = 0x00, 49 49 .end = 0x1f, 50 - .flags = IORESOURCE_BUSY 50 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 51 51 }, 52 52 { 53 53 .name = "timer", 54 54 .start = 0x40, 55 55 .end = 0x5f, 56 - .flags = IORESOURCE_BUSY 56 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 57 57 }, 58 58 { 59 59 .name = "keyboard", 60 60 .start = 0x60, 61 61 .end = 0x6f, 62 - .flags = IORESOURCE_BUSY 62 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 63 63 }, 64 64 { 65 65 .name = "dma page reg", 66 66 .start = 0x80, 67 67 .end = 0x8f, 68 - .flags = IORESOURCE_BUSY 68 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 69 69 }, 70 70 { 71 71 .name = "dma2", 72 72 .start = 0xc0, 73 73 .end = 0xdf, 74 - .flags = IORESOURCE_BUSY 74 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 75 75 }, 76 76 }; 77 77
+3 -3
arch/powerpc/kernel/eeh.c
··· 756 756 eeh_ops->write_config(pdn, edev->pcie_cap + PCI_EXP_DEVCTL, 757 757 2, devctl); 758 758 759 - /* Disable Completion Timeout */ 759 + /* Disable Completion Timeout if possible */ 760 760 eeh_ops->read_config(pdn, edev->pcie_cap + PCI_EXP_DEVCAP2, 761 761 4, &cap2); 762 - if (cap2 & 0x10) { 762 + if (cap2 & PCI_EXP_DEVCAP2_COMP_TMOUT_DIS) { 763 763 eeh_ops->read_config(pdn, 764 764 edev->pcie_cap + PCI_EXP_DEVCTL2, 765 765 4, &cap2); 766 - cap2 |= 0x10; 766 + cap2 |= PCI_EXP_DEVCTL2_COMP_TMOUT_DIS; 767 767 eeh_ops->write_config(pdn, 768 768 edev->pcie_cap + PCI_EXP_DEVCTL2, 769 769 4, cap2);
+2 -8
arch/powerpc/kernel/pci-common.c
··· 362 362 */ 363 363 static int pci_read_irq_line(struct pci_dev *pci_dev) 364 364 { 365 - struct of_phandle_args oirq; 366 - unsigned int virq; 365 + unsigned int virq = 0; 367 366 368 367 pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev)); 369 368 ··· 370 371 memset(&oirq, 0xff, sizeof(oirq)); 371 372 #endif 372 373 /* Try to get a mapping from the device-tree */ 373 - if (of_irq_parse_pci(pci_dev, &oirq)) { 374 + if (!of_irq_parse_and_map_pci(pci_dev, 0, 0)) { 374 375 u8 line, pin; 375 376 376 377 /* If that fails, lets fallback to what is in the config ··· 394 395 virq = irq_create_mapping(NULL, line); 395 396 if (virq) 396 397 irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW); 397 - } else { 398 - pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %pOF\n", 399 - oirq.args_count, oirq.args[0], oirq.args[1], oirq.np); 400 - 401 - virq = irq_create_of_mapping(&oirq); 402 398 } 403 399 404 400 if (!virq) {
+12 -8
arch/powerpc/kernel/pci-hotplug.c
··· 104 104 */ 105 105 void pci_hp_add_devices(struct pci_bus *bus) 106 106 { 107 - int slotno, mode, pass, max; 107 + int slotno, mode, max; 108 108 struct pci_dev *dev; 109 109 struct pci_controller *phb; 110 110 struct device_node *dn = pci_bus_to_OF_node(bus); ··· 133 133 pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); 134 134 pcibios_setup_bus_devices(bus); 135 135 max = bus->busn_res.start; 136 - for (pass = 0; pass < 2; pass++) { 137 - list_for_each_entry(dev, &bus->devices, bus_list) { 138 - if (pci_is_bridge(dev)) 139 - max = pci_scan_bridge(bus, dev, 140 - max, pass); 141 - } 142 - } 136 + /* 137 + * Scan bridges that are already configured. We don't touch 138 + * them unless they are misconfigured (which will be done in 139 + * the second scan below). 140 + */ 141 + for_each_pci_bridge(dev, bus) 142 + max = pci_scan_bridge(bus, dev, max, 0); 143 + 144 + /* Scan bridges that need to be reconfigured */ 145 + for_each_pci_bridge(dev, bus) 146 + max = pci_scan_bridge(bus, dev, max, 1); 143 147 } 144 148 pcibios_finish_adding_to_bus(bus); 145 149 }
+2 -1
arch/powerpc/kernel/pci_32.c
··· 96 96 reg = of_get_property(node, "reg", NULL); 97 97 if (!reg) 98 98 continue; 99 - dev = pci_get_bus_and_slot(pci_bus, ((reg[0] >> 8) & 0xff)); 99 + dev = pci_get_domain_bus_and_slot(0, pci_bus, 100 + ((reg[0] >> 8) & 0xff)); 100 101 if (!dev || !dev->subordinate) { 101 102 pci_dev_put(dev); 102 103 continue;
+2 -5
arch/powerpc/kernel/pci_of_scan.c
··· 369 369 pcibios_setup_bus_devices(bus); 370 370 371 371 /* Now scan child busses */ 372 - list_for_each_entry(dev, &bus->devices, bus_list) { 373 - if (pci_is_bridge(dev)) { 374 - of_scan_pci_bridge(dev); 375 - } 376 - } 372 + for_each_pci_bridge(dev, bus) 373 + of_scan_pci_bridge(dev); 377 374 } 378 375 379 376 /**
+1 -1
arch/powerpc/platforms/maple/time.c
··· 134 134 135 135 static struct resource rtc_iores = { 136 136 .name = "rtc", 137 - .flags = IORESOURCE_BUSY, 137 + .flags = IORESOURCE_IO | IORESOURCE_BUSY, 138 138 }; 139 139 140 140 unsigned long __init maple_get_boot_time(void)
+1 -1
arch/powerpc/platforms/powermac/feature.c
··· 829 829 830 830 if (value) { 831 831 if (pci_device_from_OF_node(node, &pbus, &pid) == 0) 832 - pdev = pci_get_bus_and_slot(pbus, pid); 832 + pdev = pci_get_domain_bus_and_slot(0, pbus, pid); 833 833 if (pdev == NULL) 834 834 return 0; 835 835 rc = pci_enable_device(pdev);
+3 -3
arch/powerpc/sysdev/i8259.c
··· 145 145 .name = "8259 (master)", 146 146 .start = 0x20, 147 147 .end = 0x21, 148 - .flags = IORESOURCE_BUSY, 148 + .flags = IORESOURCE_IO | IORESOURCE_BUSY, 149 149 }; 150 150 151 151 static struct resource pic2_iores = { 152 152 .name = "8259 (slave)", 153 153 .start = 0xa0, 154 154 .end = 0xa1, 155 - .flags = IORESOURCE_BUSY, 155 + .flags = IORESOURCE_IO | IORESOURCE_BUSY, 156 156 }; 157 157 158 158 static struct resource pic_edgectrl_iores = { 159 159 .name = "8259 edge control", 160 160 .start = 0x4d0, 161 161 .end = 0x4d1, 162 - .flags = IORESOURCE_BUSY, 162 + .flags = IORESOURCE_IO | IORESOURCE_BUSY, 163 163 }; 164 164 165 165 static int i8259_host_match(struct irq_domain *h, struct device_node *node,
+2 -2
arch/powerpc/sysdev/mv64x60_pci.c
··· 37 37 if (count < MV64X60_VAL_LEN_MAX) 38 38 return -EINVAL; 39 39 40 - phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); 40 + phb = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0)); 41 41 if (!phb) 42 42 return -ENODEV; 43 43 pci_read_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, &v); ··· 61 61 if (sscanf(buf, "%i", &v) != 1) 62 62 return -EINVAL; 63 63 64 - phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); 64 + phb = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0)); 65 65 if (!phb) 66 66 return -ENODEV; 67 67 pci_write_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, v);
+2 -1
arch/x86/pci/irq.c
··· 839 839 DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for [%04x:%04x]\n", 840 840 rt->rtr_vendor, rt->rtr_device); 841 841 842 - pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn); 842 + pirq_router_dev = pci_get_domain_bus_and_slot(0, rt->rtr_bus, 843 + rt->rtr_devfn); 843 844 if (!pirq_router_dev) { 844 845 DBG(KERN_DEBUG "PCI: Interrupt router not found at " 845 846 "%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
+1 -3
arch/x86/pci/xen.c
··· 409 409 pcibios_enable_irq = xen_pcifront_enable_irq; 410 410 pcibios_disable_irq = NULL; 411 411 412 - #ifdef CONFIG_ACPI 413 412 /* Keep ACPI out of the picture */ 414 - acpi_noirq = 1; 415 - #endif 413 + acpi_noirq_set(); 416 414 417 415 #ifdef CONFIG_PCI_MSI 418 416 x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
+1 -4
drivers/Makefile
··· 16 16 obj-$(CONFIG_GPIOLIB) += gpio/ 17 17 obj-y += pwm/ 18 18 19 - obj-$(CONFIG_PCI) += pci/ 20 - obj-$(CONFIG_PCI_ENDPOINT) += pci/endpoint/ 21 - # PCI dwc controller drivers 22 - obj-y += pci/dwc/ 19 + obj-y += pci/ 23 20 24 21 obj-$(CONFIG_PARISC) += parisc/ 25 22 obj-$(CONFIG_RAPIDIO) += rapidio/
+2 -1
drivers/ata/pata_ali.c
··· 466 466 tmp |= 0x01; /* CD_ROM enable for DMA */ 467 467 pci_write_config_byte(pdev, 0x53, tmp); 468 468 } 469 - north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); 469 + north = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 0, 470 + PCI_DEVFN(0, 0)); 470 471 if (north && north->vendor == PCI_VENDOR_ID_AL && ali_isa_bridge) { 471 472 /* Configure the ALi bridge logic. For non ALi rely on BIOS. 472 473 Set the south bridge enable bit */
+18 -20
drivers/block/DAC960.c
··· 268 268 void *AllocationPointer = NULL; 269 269 void *ScatterGatherCPU = NULL; 270 270 dma_addr_t ScatterGatherDMA; 271 - struct pci_pool *ScatterGatherPool; 271 + struct dma_pool *ScatterGatherPool; 272 272 void *RequestSenseCPU = NULL; 273 273 dma_addr_t RequestSenseDMA; 274 - struct pci_pool *RequestSensePool = NULL; 274 + struct dma_pool *RequestSensePool = NULL; 275 275 276 276 if (Controller->FirmwareType == DAC960_V1_Controller) 277 277 { 278 278 CommandAllocationLength = offsetof(DAC960_Command_T, V1.EndMarker); 279 279 CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize; 280 - ScatterGatherPool = pci_pool_create("DAC960_V1_ScatterGather", 281 - Controller->PCIDevice, 280 + ScatterGatherPool = dma_pool_create("DAC960_V1_ScatterGather", 281 + &Controller->PCIDevice->dev, 282 282 DAC960_V1_ScatterGatherLimit * sizeof(DAC960_V1_ScatterGatherSegment_T), 283 283 sizeof(DAC960_V1_ScatterGatherSegment_T), 0); 284 284 if (ScatterGatherPool == NULL) ··· 290 290 { 291 291 CommandAllocationLength = offsetof(DAC960_Command_T, V2.EndMarker); 292 292 CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize; 293 - ScatterGatherPool = pci_pool_create("DAC960_V2_ScatterGather", 294 - Controller->PCIDevice, 293 + ScatterGatherPool = dma_pool_create("DAC960_V2_ScatterGather", 294 + &Controller->PCIDevice->dev, 295 295 DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T), 296 296 sizeof(DAC960_V2_ScatterGatherSegment_T), 0); 297 297 if (ScatterGatherPool == NULL) 298 298 return DAC960_Failure(Controller, 299 299 "AUXILIARY STRUCTURE CREATION (SG)"); 300 - RequestSensePool = pci_pool_create("DAC960_V2_RequestSense", 301 - Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T), 300 + RequestSensePool = dma_pool_create("DAC960_V2_RequestSense", 301 + &Controller->PCIDevice->dev, sizeof(DAC960_SCSI_RequestSense_T), 302 302 sizeof(int), 0); 303 303 if (RequestSensePool == NULL) { 304 - pci_pool_destroy(ScatterGatherPool); 304 + dma_pool_destroy(ScatterGatherPool); 305 305 return DAC960_Failure(Controller, 306 306 "AUXILIARY STRUCTURE CREATION (SG)"); 307 307 } ··· 335 335 Command->Next = Controller->FreeCommands; 336 336 Controller->FreeCommands = Command; 337 337 Controller->Commands[CommandIdentifier-1] = Command; 338 - ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC, 338 + ScatterGatherCPU = dma_pool_alloc(ScatterGatherPool, GFP_ATOMIC, 339 339 &ScatterGatherDMA); 340 340 if (ScatterGatherCPU == NULL) 341 341 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION"); 342 342 343 343 if (RequestSensePool != NULL) { 344 - RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC, 344 + RequestSenseCPU = dma_pool_alloc(RequestSensePool, GFP_ATOMIC, 345 345 &RequestSenseDMA); 346 346 if (RequestSenseCPU == NULL) { 347 - pci_pool_free(ScatterGatherPool, ScatterGatherCPU, 347 + dma_pool_free(ScatterGatherPool, ScatterGatherCPU, 348 348 ScatterGatherDMA); 349 349 return DAC960_Failure(Controller, 350 350 "AUXILIARY STRUCTURE CREATION"); ··· 379 379 static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller) 380 380 { 381 381 int i; 382 - struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool; 383 - struct pci_pool *RequestSensePool = NULL; 382 + struct dma_pool *ScatterGatherPool = Controller->ScatterGatherPool; 383 + struct dma_pool *RequestSensePool = NULL; 384 384 void *ScatterGatherCPU; 385 385 dma_addr_t ScatterGatherDMA; 386 386 void *RequestSenseCPU; ··· 411 411 RequestSenseDMA = Command->V2.RequestSenseDMA; 412 412 } 413 413 if (ScatterGatherCPU != NULL) 414 - pci_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA); 414 + dma_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA); 415 415 if (RequestSenseCPU != NULL) 416 - pci_pool_free(RequestSensePool, RequestSenseCPU, RequestSenseDMA); 416 + dma_pool_free(RequestSensePool, RequestSenseCPU, RequestSenseDMA); 417 417 418 418 if ((Command->CommandIdentifier 419 419 % Controller->CommandAllocationGroupSize) == 1) { ··· 437 437 Controller->CurrentStatusBuffer = NULL; 438 438 } 439 439 440 - if (ScatterGatherPool != NULL) 441 - pci_pool_destroy(ScatterGatherPool); 440 + dma_pool_destroy(ScatterGatherPool); 442 441 if (Controller->FirmwareType == DAC960_V1_Controller) 443 442 return; 444 443 445 - if (RequestSensePool != NULL) 446 - pci_pool_destroy(RequestSensePool); 444 + dma_pool_destroy(RequestSensePool); 447 445 448 446 for (i = 0; i < DAC960_MaxLogicalDrives; i++) { 449 447 kfree(Controller->V2.LogicalDeviceInformation[i]);
+2 -2
drivers/block/DAC960.h
··· 2316 2316 bool SuppressEnclosureMessages; 2317 2317 struct timer_list MonitoringTimer; 2318 2318 struct gendisk *disks[DAC960_MaxLogicalDrives]; 2319 - struct pci_pool *ScatterGatherPool; 2319 + struct dma_pool *ScatterGatherPool; 2320 2320 DAC960_Command_T *FreeCommands; 2321 2321 unsigned char *CombinedStatusBuffer; 2322 2322 unsigned char *CurrentStatusBuffer; ··· 2429 2429 bool NeedDeviceSerialNumberInformation; 2430 2430 bool StartLogicalDeviceInformationScan; 2431 2431 bool StartPhysicalDeviceInformationScan; 2432 - struct pci_pool *RequestSensePool; 2432 + struct dma_pool *RequestSensePool; 2433 2433 2434 2434 dma_addr_t FirstCommandMailboxDMA; 2435 2435 DAC960_V2_CommandMailbox_T *FirstCommandMailbox;
+9 -3
drivers/char/agp/nvidia-agp.c
··· 340 340 u8 cap_ptr; 341 341 342 342 nvidia_private.dev_1 = 343 - pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 1)); 343 + pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 344 + (unsigned int)pdev->bus->number, 345 + PCI_DEVFN(0, 1)); 344 346 nvidia_private.dev_2 = 345 - pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2)); 347 + pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 348 + (unsigned int)pdev->bus->number, 349 + PCI_DEVFN(0, 2)); 346 350 nvidia_private.dev_3 = 347 - pci_get_bus_and_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0)); 351 + pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 352 + (unsigned int)pdev->bus->number, 353 + PCI_DEVFN(30, 0)); 348 354 349 355 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) { 350 356 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
+2 -1
drivers/char/agp/sworks-agp.c
··· 474 474 } 475 475 476 476 /* Everything is on func 1 here so we are hardcoding function one */ 477 - bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number, 477 + bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 478 + (unsigned int)pdev->bus->number, 478 479 PCI_DEVFN(0, 1)); 479 480 if (!bridge_dev) { 480 481 dev_info(&pdev->dev, "can't find secondary device\n");
+4 -4
drivers/firmware/edd.c
··· 669 669 struct edd_info *info = edd_dev_get_info(edev); 670 670 671 671 if (edd_dev_is_type(edev, "PCI") || edd_dev_is_type(edev, "XPRS")) { 672 - return pci_get_bus_and_slot(info->params.interface_path.pci.bus, 673 - PCI_DEVFN(info->params.interface_path.pci.slot, 674 - info->params.interface_path.pci. 675 - function)); 672 + return pci_get_domain_bus_and_slot(0, 673 + info->params.interface_path.pci.bus, 674 + PCI_DEVFN(info->params.interface_path.pci.slot, 675 + info->params.interface_path.pci.function)); 676 676 } 677 677 return NULL; 678 678 }
+3 -2
drivers/firmware/iscsi_ibft.c
··· 719 719 * executes only devices which are in domain 0. Furthermore, the 720 720 * iBFT spec doesn't have a domain id field :-( 721 721 */ 722 - pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >> 8, 723 - (nic->pci_bdf & 0xff)); 722 + pci_dev = pci_get_domain_bus_and_slot(0, 723 + (nic->pci_bdf & 0xff00) >> 8, 724 + (nic->pci_bdf & 0xff)); 724 725 if (pci_dev) { 725 726 rc = sysfs_create_link(&boot_kobj->kobj, 726 727 &pci_dev->dev.kobj, "device");
+9 -7
drivers/gpu/drm/gma500/cdv_device.c
··· 185 185 * for this and the MID devices. 186 186 */ 187 187 188 - static inline u32 CDV_MSG_READ32(uint port, uint offset) 188 + static inline u32 CDV_MSG_READ32(int domain, uint port, uint offset) 189 189 { 190 190 int mcr = (0x10<<24) | (port << 16) | (offset << 8); 191 191 uint32_t ret_val = 0; 192 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 192 + struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 193 193 pci_write_config_dword(pci_root, 0xD0, mcr); 194 194 pci_read_config_dword(pci_root, 0xD4, &ret_val); 195 195 pci_dev_put(pci_root); 196 196 return ret_val; 197 197 } 198 198 199 - static inline void CDV_MSG_WRITE32(uint port, uint offset, u32 value) 199 + static inline void CDV_MSG_WRITE32(int domain, uint port, uint offset, 200 + u32 value) 200 201 { 201 202 int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0; 202 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 203 + struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 203 204 pci_write_config_dword(pci_root, 0xD4, value); 204 205 pci_write_config_dword(pci_root, 0xD0, mcr); 205 206 pci_dev_put(pci_root); ··· 217 216 { 218 217 struct drm_psb_private *dev_priv = dev->dev_private; 219 218 u32 pwr_cnt; 219 + int domain = pci_domain_nr(dev->pdev->bus); 220 220 int i; 221 221 222 - dev_priv->apm_base = CDV_MSG_READ32(PSB_PUNIT_PORT, 222 + dev_priv->apm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT, 223 223 PSB_APMBA) & 0xFFFF; 224 - dev_priv->ospm_base = CDV_MSG_READ32(PSB_PUNIT_PORT, 224 + dev_priv->ospm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT, 225 225 PSB_OSPMBA) & 0xFFFF; 226 226 227 227 /* Power status */ ··· 253 251 * Bonus Launch to work around the issue, by degrading 254 252 * performance. 255 253 */ 256 - CDV_MSG_WRITE32(3, 0x30, 0x08027108); 254 + CDV_MSG_WRITE32(pci_domain_nr(dev->pdev->bus), 3, 0x30, 0x08027108); 257 255 } 258 256 259 257 /**
+3 -1
drivers/gpu/drm/gma500/gma_device.c
··· 19 19 void gma_get_core_freq(struct drm_device *dev) 20 20 { 21 21 uint32_t clock; 22 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 22 + struct pci_dev *pci_root = 23 + pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus), 24 + 0, 0); 23 25 struct drm_psb_private *dev_priv = dev->dev_private; 24 26 25 27 /*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
+9 -3
drivers/gpu/drm/gma500/mid_bios.c
··· 32 32 static void mid_get_fuse_settings(struct drm_device *dev) 33 33 { 34 34 struct drm_psb_private *dev_priv = dev->dev_private; 35 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 35 + struct pci_dev *pci_root = 36 + pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus), 37 + 0, 0); 36 38 uint32_t fuse_value = 0; 37 39 uint32_t fuse_value_tmp = 0; 38 40 ··· 106 104 static void mid_get_pci_revID(struct drm_psb_private *dev_priv) 107 105 { 108 106 uint32_t platform_rev_id = 0; 109 - struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0)); 107 + int domain = pci_domain_nr(dev_priv->dev->pdev->bus); 108 + struct pci_dev *pci_gfx_root = 109 + pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(2, 0)); 110 110 111 111 if (pci_gfx_root == NULL) { 112 112 WARN_ON(1); ··· 285 281 u32 addr; 286 282 u8 __iomem *vbt_virtual; 287 283 struct mid_vbt_header vbt_header; 288 - struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0)); 284 + struct pci_dev *pci_gfx_root = 285 + pci_get_domain_bus_and_slot(pci_domain_nr(dev->pdev->bus), 286 + 0, PCI_DEVFN(2, 0)); 289 287 int ret = -1; 290 288 291 289 /* Get the address of the platform config vbt */
+8 -2
drivers/gpu/drm/gma500/psb_drv.c
··· 248 248 goto out_err; 249 249 250 250 if (IS_MRST(dev)) { 251 - dev_priv->aux_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(3, 0)); 251 + int domain = pci_domain_nr(dev->pdev->bus); 252 + 253 + dev_priv->aux_pdev = 254 + pci_get_domain_bus_and_slot(domain, 0, 255 + PCI_DEVFN(3, 0)); 252 256 253 257 if (dev_priv->aux_pdev) { 254 258 resource_start = pci_resource_start(dev_priv->aux_pdev, ··· 272 268 } 273 269 dev_priv->gmbus_reg = dev_priv->aux_reg; 274 270 275 - dev_priv->lpc_pdev = pci_get_bus_and_slot(0, PCI_DEVFN(31, 0)); 271 + dev_priv->lpc_pdev = 272 + pci_get_domain_bus_and_slot(domain, 0, 273 + PCI_DEVFN(31, 0)); 276 274 if (dev_priv->lpc_pdev) { 277 275 pci_read_config_word(dev_priv->lpc_pdev, PSB_LPC_GBA, 278 276 &dev_priv->lpc_gpio_base);
+10 -8
drivers/gpu/drm/gma500/psb_drv.h
··· 780 780 extern int drm_idle_check_interval; 781 781 782 782 /* Utilities */ 783 - static inline u32 MRST_MSG_READ32(uint port, uint offset) 783 + static inline u32 MRST_MSG_READ32(int domain, uint port, uint offset) 784 784 { 785 785 int mcr = (0xD0<<24) | (port << 16) | (offset << 8); 786 786 uint32_t ret_val = 0; 787 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 787 + struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 788 788 pci_write_config_dword(pci_root, 0xD0, mcr); 789 789 pci_read_config_dword(pci_root, 0xD4, &ret_val); 790 790 pci_dev_put(pci_root); 791 791 return ret_val; 792 792 } 793 - static inline void MRST_MSG_WRITE32(uint port, uint offset, u32 value) 793 + static inline void MRST_MSG_WRITE32(int domain, uint port, uint offset, 794 + u32 value) 794 795 { 795 796 int mcr = (0xE0<<24) | (port << 16) | (offset << 8) | 0xF0; 796 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 797 + struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 797 798 pci_write_config_dword(pci_root, 0xD4, value); 798 799 pci_write_config_dword(pci_root, 0xD0, mcr); 799 800 pci_dev_put(pci_root); 800 801 } 801 - static inline u32 MDFLD_MSG_READ32(uint port, uint offset) 802 + static inline u32 MDFLD_MSG_READ32(int domain, uint port, uint offset) 802 803 { 803 804 int mcr = (0x10<<24) | (port << 16) | (offset << 8); 804 805 uint32_t ret_val = 0; 805 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 806 + struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 806 807 pci_write_config_dword(pci_root, 0xD0, mcr); 807 808 pci_read_config_dword(pci_root, 0xD4, &ret_val); 808 809 pci_dev_put(pci_root); 809 810 return ret_val; 810 811 } 811 - static inline void MDFLD_MSG_WRITE32(uint port, uint offset, u32 value) 812 + static inline void MDFLD_MSG_WRITE32(int domain, uint port, uint offset, 813 + u32 value) 812 814 { 813 815 int mcr = (0x11<<24) | (port << 16) | (offset << 8) | 0xF0; 814 - struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0); 816 + struct pci_dev *pci_root = pci_get_domain_bus_and_slot(domain, 0, 0); 815 817 pci_write_config_dword(pci_root, 0xD4, value); 816 818 pci_write_config_dword(pci_root, 0xD0, mcr); 817 819 pci_dev_put(pci_root);
+3 -1
drivers/gpu/drm/nouveau/dispnv04/arb.c
··· 213 213 if ((dev->pdev->device & 0xffff) == 0x01a0 /*CHIPSET_NFORCE*/ || 214 214 (dev->pdev->device & 0xffff) == 0x01f0 /*CHIPSET_NFORCE2*/) { 215 215 uint32_t type; 216 + int domain = pci_domain_nr(dev->pdev->bus); 216 217 217 - pci_read_config_dword(pci_get_bus_and_slot(0, 1), 0x7c, &type); 218 + pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 1), 219 + 0x7c, &type); 218 220 219 221 sim_data.memory_type = (type >> 12) & 1; 220 222 sim_data.memory_width = 64;
+7 -3
drivers/gpu/drm/nouveau/dispnv04/hw.c
··· 216 216 { 217 217 struct nvkm_pll_vals pllvals; 218 218 int ret; 219 + int domain; 220 + 221 + domain = pci_domain_nr(dev->pdev->bus); 219 222 220 223 if (plltype == PLL_MEMORY && 221 224 (dev->pdev->device & 0x0ff0) == CHIPSET_NFORCE) { 222 225 uint32_t mpllP; 223 - 224 - pci_read_config_dword(pci_get_bus_and_slot(0, 3), 0x6c, &mpllP); 226 + pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 3), 227 + 0x6c, &mpllP); 225 228 mpllP = (mpllP >> 8) & 0xf; 226 229 if (!mpllP) 227 230 mpllP = 4; ··· 235 232 (dev->pdev->device & 0xff0) == CHIPSET_NFORCE2) { 236 233 uint32_t clock; 237 234 238 - pci_read_config_dword(pci_get_bus_and_slot(0, 5), 0x4c, &clock); 235 + pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 5), 236 + 0x4c, &clock); 239 237 return clock / 1000; 240 238 } 241 239
+2 -1
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 524 524 } 525 525 526 526 /* subfunction one is a hdmi audio device? */ 527 - drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number, 527 + drm->hdmi_device = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 528 + (unsigned int)pdev->bus->number, 528 529 PCI_DEVFN(PCI_SLOT(pdev->devfn), 1)); 529 530 530 531 if (!drm->hdmi_device) {
+9 -1
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c
··· 28 28 { 29 29 struct pci_dev *bridge; 30 30 u32 mem, mib; 31 + int domain = 0; 32 + struct pci_dev *pdev = NULL; 31 33 32 - bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1)); 34 + if (dev_is_pci(fb->subdev.device->dev)) 35 + pdev = to_pci_dev(fb->subdev.device->dev); 36 + 37 + if (pdev) 38 + domain = pci_domain_nr(pdev->bus); 39 + 40 + bridge = pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(0, 1)); 33 41 if (!bridge) { 34 42 nvkm_error(&fb->subdev, "no bridge device\n"); 35 43 return -ENODEV;
+3 -2
drivers/ide/sl82c105.c
··· 239 239 /* 240 240 * The bridge should be part of the same device, but function 0. 241 241 */ 242 - bridge = pci_get_bus_and_slot(dev->bus->number, 243 - PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); 242 + bridge = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus), 243 + dev->bus->number, 244 + PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); 244 245 if (!bridge) 245 246 return -1; 246 247
+8 -51
drivers/infiniband/hw/qedr/main.c
··· 430 430 431 431 static void qedr_pci_set_atomic(struct qedr_dev *dev, struct pci_dev *pdev) 432 432 { 433 - struct pci_dev *bridge; 434 - u32 ctl2, cap2; 435 - u16 flags; 436 - int rc; 433 + int rc = pci_enable_atomic_ops_to_root(pdev, 434 + PCI_EXP_DEVCAP2_ATOMIC_COMP64); 437 435 438 - bridge = pdev->bus->self; 439 - if (!bridge) 440 - goto disable; 441 - 442 - /* Check atomic routing support all the way to root complex */ 443 - while (bridge->bus->parent) { 444 - rc = pcie_capability_read_word(bridge, PCI_EXP_FLAGS, &flags); 445 - if (rc || ((flags & PCI_EXP_FLAGS_VERS) < 2)) 446 - goto disable; 447 - 448 - rc = pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap2); 449 - if (rc) 450 - goto disable; 451 - 452 - rc = pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, &ctl2); 453 - if (rc) 454 - goto disable; 455 - 456 - if (!(cap2 & PCI_EXP_DEVCAP2_ATOMIC_ROUTE) || 457 - (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK)) 458 - goto disable; 459 - bridge = bridge->bus->parent->self; 436 + if (rc) { 437 + dev->atomic_cap = IB_ATOMIC_NONE; 438 + DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability disabled\n"); 439 + } else { 440 + dev->atomic_cap = IB_ATOMIC_GLOB; 441 + DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability enabled\n"); 460 442 } 461 - 462 - rc = pcie_capability_read_word(bridge, PCI_EXP_FLAGS, &flags); 463 - if (rc || ((flags & PCI_EXP_FLAGS_VERS) < 2)) 464 - goto disable; 465 - 466 - rc = pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap2); 467 - if (rc || !(cap2 & PCI_EXP_DEVCAP2_ATOMIC_COMP64)) 468 - goto disable; 469 - 470 - /* Set atomic operations */ 471 - pcie_capability_set_word(pdev, PCI_EXP_DEVCTL2, 472 - PCI_EXP_DEVCTL2_ATOMIC_REQ); 473 - dev->atomic_cap = IB_ATOMIC_GLOB; 474 - 475 - DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability enabled\n"); 476 - 477 - return; 478 - 479 - disable: 480 - pcie_capability_clear_word(pdev, PCI_EXP_DEVCTL2, 481 - PCI_EXP_DEVCTL2_ATOMIC_REQ); 482 - dev->atomic_cap = IB_ATOMIC_NONE; 483 - 484 - DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability disabled\n"); 485 - 486 443 } 487 444 488 445 static const struct qed_rdma_ops *qed_ops;
+2 -1
drivers/iommu/amd_iommu.c
··· 527 527 struct iommu_dev_data *dev_data = NULL; 528 528 struct pci_dev *pdev; 529 529 530 - pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff); 530 + pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid), 531 + devid & 0xff); 531 532 if (pdev) 532 533 dev_data = get_dev_data(&pdev->dev); 533 534
+5 -4
drivers/iommu/amd_iommu_init.c
··· 1697 1697 u32 range, misc, low, high; 1698 1698 int ret; 1699 1699 1700 - iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid), 1701 - iommu->devid & 0xff); 1700 + iommu->dev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(iommu->devid), 1701 + iommu->devid & 0xff); 1702 1702 if (!iommu->dev) 1703 1703 return -ENODEV; 1704 1704 ··· 1764 1764 if (is_rd890_iommu(iommu->dev)) { 1765 1765 int i, j; 1766 1766 1767 - iommu->root_pdev = pci_get_bus_and_slot(iommu->dev->bus->number, 1768 - PCI_DEVFN(0, 0)); 1767 + iommu->root_pdev = 1768 + pci_get_domain_bus_and_slot(0, iommu->dev->bus->number, 1769 + PCI_DEVFN(0, 0)); 1769 1770 1770 1771 /* 1771 1772 * Some rd890 systems may not be fully reconfigured by the
+2 -1
drivers/iommu/amd_iommu_v2.c
··· 565 565 finish = (iommu_fault->tag >> 9) & 1; 566 566 567 567 devid = iommu_fault->device_id; 568 - pdev = pci_get_bus_and_slot(PCI_BUS_NUM(devid), devid & 0xff); 568 + pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid), 569 + devid & 0xff); 569 570 if (!pdev) 570 571 return -ENODEV; 571 572 dev_data = get_dev_data(&pdev->dev);
+2 -2
drivers/irqchip/irq-i8259.c
··· 289 289 .name = "pic1", 290 290 .start = PIC_MASTER_CMD, 291 291 .end = PIC_MASTER_IMR, 292 - .flags = IORESOURCE_BUSY 292 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 293 293 }; 294 294 295 295 static struct resource pic2_io_resource = { 296 296 .name = "pic2", 297 297 .start = PIC_SLAVE_CMD, 298 298 .end = PIC_SLAVE_IMR, 299 - .flags = IORESOURCE_BUSY 299 + .flags = IORESOURCE_IO | IORESOURCE_BUSY 300 300 }; 301 301 302 302 static int i8259A_irq_domain_map(struct irq_domain *d, unsigned int virq,
+1 -1
drivers/macintosh/via-pmu.c
··· 1799 1799 struct adb_request req; 1800 1800 struct pci_dev *grackle; 1801 1801 1802 - grackle = pci_get_bus_and_slot(0, 0); 1802 + grackle = pci_get_domain_bus_and_slot(0, 0, 0); 1803 1803 if (!grackle) 1804 1804 return -ENODEV; 1805 1805
+4 -14
drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
··· 102 102 unsigned int isoc_in_pipe; 103 103 104 104 void *iso_buffer; 105 - dma_addr_t iso_dma_handle; 106 105 107 106 struct urb *iso_urb[ISO_BUF_COUNT]; 108 107 ··· 791 792 792 793 for (i = 0; i < ISO_BUF_COUNT; i++) 793 794 usb_free_urb(ttusb->iso_urb[i]); 794 - 795 - pci_free_consistent(NULL, 796 - ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * 797 - ISO_BUF_COUNT, ttusb->iso_buffer, 798 - ttusb->iso_dma_handle); 795 + kfree(ttusb->iso_buffer); 799 796 } 800 797 801 798 static int ttusb_alloc_iso_urbs(struct ttusb *ttusb) 802 799 { 803 800 int i; 804 801 805 - ttusb->iso_buffer = pci_zalloc_consistent(NULL, 806 - ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT, 807 - &ttusb->iso_dma_handle); 808 - 809 - if (!ttusb->iso_buffer) { 810 - dprintk("%s: pci_alloc_consistent - not enough memory\n", 811 - __func__); 802 + ttusb->iso_buffer = kcalloc(FRAMES_PER_ISO_BUF * ISO_BUF_COUNT, 803 + ISO_FRAME_SIZE, GFP_KERNEL); 804 + if (!ttusb->iso_buffer) 812 805 return -ENOMEM; 813 - } 814 806 815 807 for (i = 0; i < ISO_BUF_COUNT; i++) { 816 808 struct urb *urb;
+4 -14
drivers/media/usb/ttusb-dec/ttusb_dec.c
··· 127 127 struct urb *irq_urb; 128 128 dma_addr_t irq_dma_handle; 129 129 void *iso_buffer; 130 - dma_addr_t iso_dma_handle; 131 130 struct urb *iso_urb[ISO_BUF_COUNT]; 132 131 int iso_stream_count; 133 132 struct mutex iso_mutex; ··· 1184 1185 1185 1186 for (i = 0; i < ISO_BUF_COUNT; i++) 1186 1187 usb_free_urb(dec->iso_urb[i]); 1187 - 1188 - pci_free_consistent(NULL, 1189 - ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * 1190 - ISO_BUF_COUNT), 1191 - dec->iso_buffer, dec->iso_dma_handle); 1188 + kfree(dec->iso_buffer); 1192 1189 } 1193 1190 1194 1191 static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec) ··· 1193 1198 1194 1199 dprintk("%s\n", __func__); 1195 1200 1196 - dec->iso_buffer = pci_zalloc_consistent(NULL, 1197 - ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT), 1198 - &dec->iso_dma_handle); 1199 - 1200 - if (!dec->iso_buffer) { 1201 - dprintk("%s: pci_alloc_consistent - not enough memory\n", 1202 - __func__); 1201 + dec->iso_buffer = kcalloc(FRAMES_PER_ISO_BUF * ISO_BUF_COUNT, 1202 + ISO_FRAME_SIZE, GFP_KERNEL); 1203 + if (!dec->iso_buffer) 1203 1204 return -ENOMEM; 1204 - } 1205 1205 1206 1206 for (i = 0; i < ISO_BUF_COUNT; i++) { 1207 1207 struct urb *urb;
+9 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
··· 812 812 if (!vf) 813 813 return false; 814 814 815 - dev = pci_get_bus_and_slot(vf->bus, vf->devfn); 815 + dev = pci_get_domain_bus_and_slot(vf->domain, vf->bus, vf->devfn); 816 816 if (dev) 817 817 return bnx2x_is_pcie_pending(dev); 818 818 return false; ··· 1039 1039 { 1040 1040 if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV)) 1041 1041 REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0); 1042 + } 1043 + 1044 + static int bnx2x_vf_domain(struct bnx2x *bp, int vfid) 1045 + { 1046 + struct pci_dev *dev = bp->pdev; 1047 + 1048 + return pci_domain_nr(dev->bus); 1042 1049 } 1043 1050 1044 1051 static int bnx2x_vf_bus(struct bnx2x *bp, int vfid) ··· 1613 1606 struct bnx2x_virtf *vf = BP_VF(bp, vfid); 1614 1607 1615 1608 /* fill in the BDF and bars */ 1609 + vf->domain = bnx2x_vf_domain(bp, vfid); 1616 1610 vf->bus = bnx2x_vf_bus(bp, vfid); 1617 1611 vf->devfn = bnx2x_vf_devfn(bp, vfid); 1618 1612 bnx2x_vf_set_bars(bp, vf);
+1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
··· 182 182 u32 error; /* 0 means all's-well */ 183 183 184 184 /* BDF */ 185 + unsigned int domain; 185 186 unsigned int bus; 186 187 unsigned int devfn; 187 188
+5 -5
drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
··· 143 143 struct hinic_hwif *hwif = cmdqs->hwif; 144 144 struct pci_dev *pdev = hwif->pdev; 145 145 146 - cmdq_buf->buf = pci_pool_alloc(cmdqs->cmdq_buf_pool, GFP_KERNEL, 146 + cmdq_buf->buf = dma_pool_alloc(cmdqs->cmdq_buf_pool, GFP_KERNEL, 147 147 &cmdq_buf->dma_addr); 148 148 if (!cmdq_buf->buf) { 149 149 dev_err(&pdev->dev, "Failed to allocate cmd from the pool\n"); ··· 161 161 void hinic_free_cmdq_buf(struct hinic_cmdqs *cmdqs, 162 162 struct hinic_cmdq_buf *cmdq_buf) 163 163 { 164 - pci_pool_free(cmdqs->cmdq_buf_pool, cmdq_buf->buf, cmdq_buf->dma_addr); 164 + dma_pool_free(cmdqs->cmdq_buf_pool, cmdq_buf->buf, cmdq_buf->dma_addr); 165 165 } 166 166 167 167 static unsigned int cmdq_wqe_size_from_bdlen(enum bufdesc_len len) ··· 875 875 int err; 876 876 877 877 cmdqs->hwif = hwif; 878 - cmdqs->cmdq_buf_pool = pci_pool_create("hinic_cmdq", pdev, 878 + cmdqs->cmdq_buf_pool = dma_pool_create("hinic_cmdq", &pdev->dev, 879 879 HINIC_CMDQ_BUF_SIZE, 880 880 HINIC_CMDQ_BUF_SIZE, 0); 881 881 if (!cmdqs->cmdq_buf_pool) ··· 916 916 devm_kfree(&pdev->dev, cmdqs->saved_wqs); 917 917 918 918 err_saved_wqs: 919 - pci_pool_destroy(cmdqs->cmdq_buf_pool); 919 + dma_pool_destroy(cmdqs->cmdq_buf_pool); 920 920 return err; 921 921 } 922 922 ··· 942 942 943 943 devm_kfree(&pdev->dev, cmdqs->saved_wqs); 944 944 945 - pci_pool_destroy(cmdqs->cmdq_buf_pool); 945 + dma_pool_destroy(cmdqs->cmdq_buf_pool); 946 946 }
+1 -1
drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h
··· 157 157 struct hinic_cmdqs { 158 158 struct hinic_hwif *hwif; 159 159 160 - struct pci_pool *cmdq_buf_pool; 160 + struct dma_pool *cmdq_buf_pool; 161 161 162 162 struct hinic_wq *saved_wqs; 163 163
+6 -6
drivers/net/ethernet/intel/e100.c
··· 607 607 struct mem *mem; 608 608 dma_addr_t dma_addr; 609 609 610 - struct pci_pool *cbs_pool; 610 + struct dma_pool *cbs_pool; 611 611 dma_addr_t cbs_dma_addr; 612 612 u8 adaptive_ifs; 613 613 u8 tx_threshold; ··· 1892 1892 nic->cb_to_clean = nic->cb_to_clean->next; 1893 1893 nic->cbs_avail++; 1894 1894 } 1895 - pci_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr); 1895 + dma_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr); 1896 1896 nic->cbs = NULL; 1897 1897 nic->cbs_avail = 0; 1898 1898 } ··· 1910 1910 nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL; 1911 1911 nic->cbs_avail = 0; 1912 1912 1913 - nic->cbs = pci_pool_zalloc(nic->cbs_pool, GFP_KERNEL, 1913 + nic->cbs = dma_pool_zalloc(nic->cbs_pool, GFP_KERNEL, 1914 1914 &nic->cbs_dma_addr); 1915 1915 if (!nic->cbs) 1916 1916 return -ENOMEM; ··· 2960 2960 netif_err(nic, probe, nic->netdev, "Cannot register net device, aborting\n"); 2961 2961 goto err_out_free; 2962 2962 } 2963 - nic->cbs_pool = pci_pool_create(netdev->name, 2964 - nic->pdev, 2963 + nic->cbs_pool = dma_pool_create(netdev->name, 2964 + &nic->pdev->dev, 2965 2965 nic->params.cbs.max * sizeof(struct cb), 2966 2966 sizeof(u32), 2967 2967 0); ··· 3001 3001 unregister_netdev(netdev); 3002 3002 e100_free(nic); 3003 3003 pci_iounmap(pdev, nic->csr); 3004 - pci_pool_destroy(nic->cbs_pool); 3004 + dma_pool_destroy(nic->cbs_pool); 3005 3005 free_netdev(netdev); 3006 3006 pci_release_regions(pdev); 3007 3007 pci_disable_device(pdev);
+4 -2
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
··· 2594 2594 if (adapter->pdata && adapter->pdata->platform_init) 2595 2595 adapter->pdata->platform_init(pdev); 2596 2596 2597 - adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number, 2598 - PCI_DEVFN(12, 4)); 2597 + adapter->ptp_pdev = 2598 + pci_get_domain_bus_and_slot(pci_domain_nr(adapter->pdev->bus), 2599 + adapter->pdev->bus->number, 2600 + PCI_DEVFN(12, 4)); 2599 2601 2600 2602 netdev->netdev_ops = &pch_gbe_netdev_ops; 2601 2603 netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD;
+20 -16
drivers/net/ethernet/tundra/tsi108_eth.c
··· 152 152 u32 msg_enable; /* debug message level */ 153 153 struct mii_if_info mii_if; 154 154 unsigned int init_media; 155 + 156 + struct platform_device *pdev; 155 157 }; 156 158 157 159 /* Structure for a device driver */ ··· 705 703 data->txskbs[tx] = skb; 706 704 707 705 if (i == 0) { 708 - data->txring[tx].buf0 = dma_map_single(NULL, skb->data, 709 - skb_headlen(skb), DMA_TO_DEVICE); 706 + data->txring[tx].buf0 = dma_map_single(&data->pdev->dev, 707 + skb->data, skb_headlen(skb), 708 + DMA_TO_DEVICE); 710 709 data->txring[tx].len = skb_headlen(skb); 711 710 misc |= TSI108_TX_SOF; 712 711 } else { 713 712 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; 714 713 715 - data->txring[tx].buf0 = skb_frag_dma_map(NULL, frag, 716 - 0, 717 - skb_frag_size(frag), 718 - DMA_TO_DEVICE); 714 + data->txring[tx].buf0 = 715 + skb_frag_dma_map(&data->pdev->dev, frag, 716 + 0, skb_frag_size(frag), 717 + DMA_TO_DEVICE); 719 718 data->txring[tx].len = skb_frag_size(frag); 720 719 } 721 720 ··· 811 808 if (!skb) 812 809 break; 813 810 814 - data->rxring[rx].buf0 = dma_map_single(NULL, skb->data, 815 - TSI108_RX_SKB_SIZE, 816 - DMA_FROM_DEVICE); 811 + data->rxring[rx].buf0 = dma_map_single(&data->pdev->dev, 812 + skb->data, TSI108_RX_SKB_SIZE, 813 + DMA_FROM_DEVICE); 817 814 818 815 /* Sometimes the hardware sets blen to zero after packet 819 816 * reception, even though the manual says that it's only ever ··· 1311 1308 data->id, dev->irq, dev->name); 1312 1309 } 1313 1310 1314 - data->rxring = dma_zalloc_coherent(NULL, rxring_size, &data->rxdma, 1315 - GFP_KERNEL); 1311 + data->rxring = dma_zalloc_coherent(&data->pdev->dev, rxring_size, 1312 + &data->rxdma, GFP_KERNEL); 1316 1313 if (!data->rxring) 1317 1314 return -ENOMEM; 1318 1315 1319 - data->txring = dma_zalloc_coherent(NULL, txring_size, &data->txdma, 1320 - GFP_KERNEL); 1316 + data->txring = dma_zalloc_coherent(&data->pdev->dev, txring_size, 1317 + &data->txdma, GFP_KERNEL); 1321 1318 if (!data->txring) { 1322 - pci_free_consistent(NULL, rxring_size, data->rxring, 1319 + dma_free_coherent(&data->pdev->dev, rxring_size, data->rxring, 1323 1320 data->rxdma); 1324 1321 return -ENOMEM; 1325 1322 } ··· 1431 1428 dev_kfree_skb(skb); 1432 1429 } 1433 1430 1434 - dma_free_coherent(0, 1431 + dma_free_coherent(&data->pdev->dev, 1435 1432 TSI108_RXRING_LEN * sizeof(rx_desc), 1436 1433 data->rxring, data->rxdma); 1437 - dma_free_coherent(0, 1434 + dma_free_coherent(&data->pdev->dev, 1438 1435 TSI108_TXRING_LEN * sizeof(tx_desc), 1439 1436 data->txring, data->txdma); 1440 1437 ··· 1579 1576 printk("tsi108_eth%d: probe...\n", pdev->id); 1580 1577 data = netdev_priv(dev); 1581 1578 data->dev = dev; 1579 + data->pdev = pdev; 1582 1580 1583 1581 pr_debug("tsi108_eth%d:regs:phyresgs:phy:irq_num=0x%x:0x%x:0x%x:0x%x\n", 1584 1582 pdev->id, einfo->regs, einfo->phyregs,
-16
drivers/of/Kconfig
··· 64 64 config OF_ADDRESS 65 65 def_bool y 66 66 depends on !SPARC && (HAS_IOMEM || UML) 67 - select OF_ADDRESS_PCI if PCI 68 - 69 - config OF_ADDRESS_PCI 70 - bool 71 67 72 68 config OF_IRQ 73 69 def_bool y ··· 79 83 select FIXED_PHY 80 84 help 81 85 OpenFirmware MDIO bus (Ethernet PHY) accessors 82 - 83 - config OF_PCI 84 - def_tristate PCI 85 - depends on PCI 86 - help 87 - OpenFirmware PCI bus accessors 88 - 89 - config OF_PCI_IRQ 90 - def_tristate PCI 91 - depends on OF_PCI && OF_IRQ 92 - help 93 - OpenFirmware PCI IRQ routing helpers 94 86 95 87 config OF_RESERVED_MEM 96 88 depends on OF_EARLY_FLATTREE
-2
drivers/of/Makefile
··· 10 10 obj-$(CONFIG_OF_NET) += of_net.o 11 11 obj-$(CONFIG_OF_UNITTEST) += unittest.o 12 12 obj-$(CONFIG_OF_MDIO) += of_mdio.o 13 - obj-$(CONFIG_OF_PCI) += of_pci.o 14 - obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o 15 13 obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o 16 14 obj-$(CONFIG_OF_RESOLVE) += resolver.o 17 15 obj-$(CONFIG_OF_OVERLAY) += overlay.o
+4 -5
drivers/of/address.c
··· 96 96 return IORESOURCE_MEM; 97 97 } 98 98 99 - #ifdef CONFIG_OF_ADDRESS_PCI 99 + #ifdef CONFIG_PCI 100 100 /* 101 101 * PCI bus specific translator 102 102 */ ··· 171 171 { 172 172 return of_bus_default_translate(addr + 1, offset, na - 1); 173 173 } 174 - #endif /* CONFIG_OF_ADDRESS_PCI */ 175 174 176 - #ifdef CONFIG_PCI 177 175 const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, 178 176 unsigned int *flags) 179 177 { ··· 359 361 res->end = (resource_size_t)OF_BAD_ADDR; 360 362 return err; 361 363 } 364 + EXPORT_SYMBOL(of_pci_range_to_resource); 362 365 #endif /* CONFIG_PCI */ 363 366 364 367 /* ··· 425 426 */ 426 427 427 428 static struct of_bus of_busses[] = { 428 - #ifdef CONFIG_OF_ADDRESS_PCI 429 + #ifdef CONFIG_PCI 429 430 /* PCI */ 430 431 { 431 432 .name = "pci", ··· 436 437 .translate = of_bus_pci_translate, 437 438 .get_flags = of_bus_pci_get_flags, 438 439 }, 439 - #endif /* CONFIG_OF_ADDRESS_PCI */ 440 + #endif /* CONFIG_PCI */ 440 441 /* ISA */ 441 442 { 442 443 .name = "isa",
-384
drivers/of/of_pci.c
··· 1 - #define pr_fmt(fmt) "OF: PCI: " fmt 2 - 3 - #include <linux/kernel.h> 4 - #include <linux/export.h> 5 - #include <linux/of.h> 6 - #include <linux/of_address.h> 7 - #include <linux/of_device.h> 8 - #include <linux/of_pci.h> 9 - #include <linux/slab.h> 10 - 11 - static inline int __of_pci_pci_compare(struct device_node *node, 12 - unsigned int data) 13 - { 14 - int devfn; 15 - 16 - devfn = of_pci_get_devfn(node); 17 - if (devfn < 0) 18 - return 0; 19 - 20 - return devfn == data; 21 - } 22 - 23 - struct device_node *of_pci_find_child_device(struct device_node *parent, 24 - unsigned int devfn) 25 - { 26 - struct device_node *node, *node2; 27 - 28 - for_each_child_of_node(parent, node) { 29 - if (__of_pci_pci_compare(node, devfn)) 30 - return node; 31 - /* 32 - * Some OFs create a parent node "multifunc-device" as 33 - * a fake root for all functions of a multi-function 34 - * device we go down them as well. 35 - */ 36 - if (!strcmp(node->name, "multifunc-device")) { 37 - for_each_child_of_node(node, node2) { 38 - if (__of_pci_pci_compare(node2, devfn)) { 39 - of_node_put(node); 40 - return node2; 41 - } 42 - } 43 - } 44 - } 45 - return NULL; 46 - } 47 - EXPORT_SYMBOL_GPL(of_pci_find_child_device); 48 - 49 - /** 50 - * of_pci_get_devfn() - Get device and function numbers for a device node 51 - * @np: device node 52 - * 53 - * Parses a standard 5-cell PCI resource and returns an 8-bit value that can 54 - * be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device 55 - * and function numbers respectively. On error a negative error code is 56 - * returned. 57 - */ 58 - int of_pci_get_devfn(struct device_node *np) 59 - { 60 - u32 reg[5]; 61 - int error; 62 - 63 - error = of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg)); 64 - if (error) 65 - return error; 66 - 67 - return (reg[0] >> 8) & 0xff; 68 - } 69 - EXPORT_SYMBOL_GPL(of_pci_get_devfn); 70 - 71 - /** 72 - * of_pci_parse_bus_range() - parse the bus-range property of a PCI device 73 - * @node: device node 74 - * @res: address to a struct resource to return the bus-range 75 - * 76 - * Returns 0 on success or a negative error-code on failure. 77 - */ 78 - int of_pci_parse_bus_range(struct device_node *node, struct resource *res) 79 - { 80 - u32 bus_range[2]; 81 - int error; 82 - 83 - error = of_property_read_u32_array(node, "bus-range", bus_range, 84 - ARRAY_SIZE(bus_range)); 85 - if (error) 86 - return error; 87 - 88 - res->name = node->name; 89 - res->start = bus_range[0]; 90 - res->end = bus_range[1]; 91 - res->flags = IORESOURCE_BUS; 92 - 93 - return 0; 94 - } 95 - EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); 96 - 97 - /** 98 - * This function will try to obtain the host bridge domain number by 99 - * finding a property called "linux,pci-domain" of the given device node. 100 - * 101 - * @node: device tree node with the domain information 102 - * 103 - * Returns the associated domain number from DT in the range [0-0xffff], or 104 - * a negative value if the required property is not found. 105 - */ 106 - int of_get_pci_domain_nr(struct device_node *node) 107 - { 108 - u32 domain; 109 - int error; 110 - 111 - error = of_property_read_u32(node, "linux,pci-domain", &domain); 112 - if (error) 113 - return error; 114 - 115 - return (u16)domain; 116 - } 117 - EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); 118 - 119 - /** 120 - * This function will try to find the limitation of link speed by finding 121 - * a property called "max-link-speed" of the given device node. 122 - * 123 - * @node: device tree node with the max link speed information 124 - * 125 - * Returns the associated max link speed from DT, or a negative value if the 126 - * required property is not found or is invalid. 127 - */ 128 - int of_pci_get_max_link_speed(struct device_node *node) 129 - { 130 - u32 max_link_speed; 131 - 132 - if (of_property_read_u32(node, "max-link-speed", &max_link_speed) || 133 - max_link_speed > 4) 134 - return -EINVAL; 135 - 136 - return max_link_speed; 137 - } 138 - EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); 139 - 140 - /** 141 - * of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only 142 - * is present and valid 143 - */ 144 - void of_pci_check_probe_only(void) 145 - { 146 - u32 val; 147 - int ret; 148 - 149 - ret = of_property_read_u32(of_chosen, "linux,pci-probe-only", &val); 150 - if (ret) { 151 - if (ret == -ENODATA || ret == -EOVERFLOW) 152 - pr_warn("linux,pci-probe-only without valid value, ignoring\n"); 153 - return; 154 - } 155 - 156 - if (val) 157 - pci_add_flags(PCI_PROBE_ONLY); 158 - else 159 - pci_clear_flags(PCI_PROBE_ONLY); 160 - 161 - pr_info("PROBE_ONLY %sabled\n", val ? "en" : "dis"); 162 - } 163 - EXPORT_SYMBOL_GPL(of_pci_check_probe_only); 164 - 165 - #if defined(CONFIG_OF_ADDRESS) 166 - /** 167 - * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT 168 - * @dev: device node of the host bridge having the range property 169 - * @busno: bus number associated with the bridge root bus 170 - * @bus_max: maximum number of buses for this bridge 171 - * @resources: list where the range of resources will be added after DT parsing 172 - * @io_base: pointer to a variable that will contain on return the physical 173 - * address for the start of the I/O range. Can be NULL if the caller doesn't 174 - * expect IO ranges to be present in the device tree. 175 - * 176 - * It is the caller's job to free the @resources list. 177 - * 178 - * This function will parse the "ranges" property of a PCI host bridge device 179 - * node and setup the resource mapping based on its content. It is expected 180 - * that the property conforms with the Power ePAPR document. 181 - * 182 - * It returns zero if the range parsing has been successful or a standard error 183 - * value if it failed. 184 - */ 185 - int of_pci_get_host_bridge_resources(struct device_node *dev, 186 - unsigned char busno, unsigned char bus_max, 187 - struct list_head *resources, resource_size_t *io_base) 188 - { 189 - struct resource_entry *window; 190 - struct resource *res; 191 - struct resource *bus_range; 192 - struct of_pci_range range; 193 - struct of_pci_range_parser parser; 194 - char range_type[4]; 195 - int err; 196 - 197 - if (io_base) 198 - *io_base = (resource_size_t)OF_BAD_ADDR; 199 - 200 - bus_range = kzalloc(sizeof(*bus_range), GFP_KERNEL); 201 - if (!bus_range) 202 - return -ENOMEM; 203 - 204 - pr_info("host bridge %pOF ranges:\n", dev); 205 - 206 - err = of_pci_parse_bus_range(dev, bus_range); 207 - if (err) { 208 - bus_range->start = busno; 209 - bus_range->end = bus_max; 210 - bus_range->flags = IORESOURCE_BUS; 211 - pr_info(" No bus range found for %pOF, using %pR\n", 212 - dev, bus_range); 213 - } else { 214 - if (bus_range->end > bus_range->start + bus_max) 215 - bus_range->end = bus_range->start + bus_max; 216 - } 217 - pci_add_resource(resources, bus_range); 218 - 219 - /* Check for ranges property */ 220 - err = of_pci_range_parser_init(&parser, dev); 221 - if (err) 222 - goto parse_failed; 223 - 224 - pr_debug("Parsing ranges property...\n"); 225 - for_each_of_pci_range(&parser, &range) { 226 - /* Read next ranges element */ 227 - if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_IO) 228 - snprintf(range_type, 4, " IO"); 229 - else if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM) 230 - snprintf(range_type, 4, "MEM"); 231 - else 232 - snprintf(range_type, 4, "err"); 233 - pr_info(" %s %#010llx..%#010llx -> %#010llx\n", range_type, 234 - range.cpu_addr, range.cpu_addr + range.size - 1, 235 - range.pci_addr); 236 - 237 - /* 238 - * If we failed translation or got a zero-sized region 239 - * then skip this range 240 - */ 241 - if (range.cpu_addr == OF_BAD_ADDR || range.size == 0) 242 - continue; 243 - 244 - res = kzalloc(sizeof(struct resource), GFP_KERNEL); 245 - if (!res) { 246 - err = -ENOMEM; 247 - goto parse_failed; 248 - } 249 - 250 - err = of_pci_range_to_resource(&range, dev, res); 251 - if (err) { 252 - kfree(res); 253 - continue; 254 - } 255 - 256 - if (resource_type(res) == IORESOURCE_IO) { 257 - if (!io_base) { 258 - pr_err("I/O range found for %pOF. Please provide an io_base pointer to save CPU base address\n", 259 - dev); 260 - err = -EINVAL; 261 - goto conversion_failed; 262 - } 263 - if (*io_base != (resource_size_t)OF_BAD_ADDR) 264 - pr_warn("More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", 265 - dev); 266 - *io_base = range.cpu_addr; 267 - } 268 - 269 - pci_add_resource_offset(resources, res, res->start - range.pci_addr); 270 - } 271 - 272 - return 0; 273 - 274 - conversion_failed: 275 - kfree(res); 276 - parse_failed: 277 - resource_list_for_each_entry(window, resources) 278 - kfree(window->res); 279 - pci_free_resource_list(resources); 280 - return err; 281 - } 282 - EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources); 283 - #endif /* CONFIG_OF_ADDRESS */ 284 - 285 - /** 286 - * of_pci_map_rid - Translate a requester ID through a downstream mapping. 287 - * @np: root complex device node. 288 - * @rid: PCI requester ID to map. 289 - * @map_name: property name of the map to use. 290 - * @map_mask_name: optional property name of the mask to use. 291 - * @target: optional pointer to a target device node. 292 - * @id_out: optional pointer to receive the translated ID. 293 - * 294 - * Given a PCI requester ID, look up the appropriate implementation-defined 295 - * platform ID and/or the target device which receives transactions on that 296 - * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or 297 - * @id_out may be NULL if only the other is required. If @target points to 298 - * a non-NULL device node pointer, only entries targeting that node will be 299 - * matched; if it points to a NULL value, it will receive the device node of 300 - * the first matching target phandle, with a reference held. 301 - * 302 - * Return: 0 on success or a standard error code on failure. 303 - */ 304 - int of_pci_map_rid(struct device_node *np, u32 rid, 305 - const char *map_name, const char *map_mask_name, 306 - struct device_node **target, u32 *id_out) 307 - { 308 - u32 map_mask, masked_rid; 309 - int map_len; 310 - const __be32 *map = NULL; 311 - 312 - if (!np || !map_name || (!target && !id_out)) 313 - return -EINVAL; 314 - 315 - map = of_get_property(np, map_name, &map_len); 316 - if (!map) { 317 - if (target) 318 - return -ENODEV; 319 - /* Otherwise, no map implies no translation */ 320 - *id_out = rid; 321 - return 0; 322 - } 323 - 324 - if (!map_len || map_len % (4 * sizeof(*map))) { 325 - pr_err("%pOF: Error: Bad %s length: %d\n", np, 326 - map_name, map_len); 327 - return -EINVAL; 328 - } 329 - 330 - /* The default is to select all bits. */ 331 - map_mask = 0xffffffff; 332 - 333 - /* 334 - * Can be overridden by "{iommu,msi}-map-mask" property. 335 - * If of_property_read_u32() fails, the default is used. 336 - */ 337 - if (map_mask_name) 338 - of_property_read_u32(np, map_mask_name, &map_mask); 339 - 340 - masked_rid = map_mask & rid; 341 - for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) { 342 - struct device_node *phandle_node; 343 - u32 rid_base = be32_to_cpup(map + 0); 344 - u32 phandle = be32_to_cpup(map + 1); 345 - u32 out_base = be32_to_cpup(map + 2); 346 - u32 rid_len = be32_to_cpup(map + 3); 347 - 348 - if (rid_base & ~map_mask) { 349 - pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", 350 - np, map_name, map_name, 351 - map_mask, rid_base); 352 - return -EFAULT; 353 - } 354 - 355 - if (masked_rid < rid_base || masked_rid >= rid_base + rid_len) 356 - continue; 357 - 358 - phandle_node = of_find_node_by_phandle(phandle); 359 - if (!phandle_node) 360 - return -ENODEV; 361 - 362 - if (target) { 363 - if (*target) 364 - of_node_put(phandle_node); 365 - else 366 - *target = phandle_node; 367 - 368 - if (*target != phandle_node) 369 - continue; 370 - } 371 - 372 - if (id_out) 373 - *id_out = masked_rid - rid_base + out_base; 374 - 375 - pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", 376 - np, map_name, map_mask, rid_base, out_base, 377 - rid_len, rid, masked_rid - rid_base + out_base); 378 - return 0; 379 - } 380 - 381 - pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n", 382 - np, map_name, rid, target && *target ? *target : NULL); 383 - return -EFAULT; 384 - }
-131
drivers/of/of_pci_irq.c
··· 1 - #include <linux/kernel.h> 2 - #include <linux/of_pci.h> 3 - #include <linux/of_irq.h> 4 - #include <linux/export.h> 5 - 6 - /** 7 - * of_irq_parse_pci - Resolve the interrupt for a PCI device 8 - * @pdev: the device whose interrupt is to be resolved 9 - * @out_irq: structure of_irq filled by this function 10 - * 11 - * This function resolves the PCI interrupt for a given PCI device. If a 12 - * device-node exists for a given pci_dev, it will use normal OF tree 13 - * walking. If not, it will implement standard swizzling and walk up the 14 - * PCI tree until an device-node is found, at which point it will finish 15 - * resolving using the OF tree walking. 16 - */ 17 - int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) 18 - { 19 - struct device_node *dn, *ppnode; 20 - struct pci_dev *ppdev; 21 - __be32 laddr[3]; 22 - u8 pin; 23 - int rc; 24 - 25 - /* Check if we have a device node, if yes, fallback to standard 26 - * device tree parsing 27 - */ 28 - dn = pci_device_to_OF_node(pdev); 29 - if (dn) { 30 - rc = of_irq_parse_one(dn, 0, out_irq); 31 - if (!rc) 32 - return rc; 33 - } 34 - 35 - /* Ok, we don't, time to have fun. Let's start by building up an 36 - * interrupt spec. we assume #interrupt-cells is 1, which is standard 37 - * for PCI. If you do different, then don't use that routine. 38 - */ 39 - rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin); 40 - if (rc != 0) 41 - goto err; 42 - /* No pin, exit with no error message. */ 43 - if (pin == 0) 44 - return -ENODEV; 45 - 46 - /* Now we walk up the PCI tree */ 47 - for (;;) { 48 - /* Get the pci_dev of our parent */ 49 - ppdev = pdev->bus->self; 50 - 51 - /* Ouch, it's a host bridge... */ 52 - if (ppdev == NULL) { 53 - ppnode = pci_bus_to_OF_node(pdev->bus); 54 - 55 - /* No node for host bridge ? give up */ 56 - if (ppnode == NULL) { 57 - rc = -EINVAL; 58 - goto err; 59 - } 60 - } else { 61 - /* We found a P2P bridge, check if it has a node */ 62 - ppnode = pci_device_to_OF_node(ppdev); 63 - } 64 - 65 - /* Ok, we have found a parent with a device-node, hand over to 66 - * the OF parsing code. 67 - * We build a unit address from the linux device to be used for 68 - * resolution. Note that we use the linux bus number which may 69 - * not match your firmware bus numbering. 70 - * Fortunately, in most cases, interrupt-map-mask doesn't 71 - * include the bus number as part of the matching. 72 - * You should still be careful about that though if you intend 73 - * to rely on this function (you ship a firmware that doesn't 74 - * create device nodes for all PCI devices). 75 - */ 76 - if (ppnode) 77 - break; 78 - 79 - /* We can only get here if we hit a P2P bridge with no node, 80 - * let's do standard swizzling and try again 81 - */ 82 - pin = pci_swizzle_interrupt_pin(pdev, pin); 83 - pdev = ppdev; 84 - } 85 - 86 - out_irq->np = ppnode; 87 - out_irq->args_count = 1; 88 - out_irq->args[0] = pin; 89 - laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); 90 - laddr[1] = laddr[2] = cpu_to_be32(0); 91 - rc = of_irq_parse_raw(laddr, out_irq); 92 - if (rc) 93 - goto err; 94 - return 0; 95 - err: 96 - if (rc == -ENOENT) { 97 - dev_warn(&pdev->dev, 98 - "%s: no interrupt-map found, INTx interrupts not available\n", 99 - __func__); 100 - pr_warn_once("%s: possibly some PCI slots don't have level triggered interrupts capability\n", 101 - __func__); 102 - } else { 103 - dev_err(&pdev->dev, "%s: failed with rc=%d\n", __func__, rc); 104 - } 105 - return rc; 106 - } 107 - EXPORT_SYMBOL_GPL(of_irq_parse_pci); 108 - 109 - /** 110 - * of_irq_parse_and_map_pci() - Decode a PCI irq from the device tree and map to a virq 111 - * @dev: The pci device needing an irq 112 - * @slot: PCI slot number; passed when used as map_irq callback. Unused 113 - * @pin: PCI irq pin number; passed when used as map_irq callback. Unused 114 - * 115 - * @slot and @pin are unused, but included in the function so that this 116 - * function can be used directly as the map_irq callback to 117 - * pci_assign_irq() and struct pci_host_bridge.map_irq pointer 118 - */ 119 - int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) 120 - { 121 - struct of_phandle_args oirq; 122 - int ret; 123 - 124 - ret = of_irq_parse_pci(dev, &oirq); 125 - if (ret) 126 - return 0; /* Proper return code 0 == NO_IRQ */ 127 - 128 - return irq_create_of_mapping(&oirq); 129 - } 130 - EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci); 131 -
+3
drivers/pci/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI configuration 3 4 # ··· 126 125 127 126 config PCI_LABEL 128 127 def_bool y if (DMI || ACPI) 128 + depends on PCI 129 129 select NLS 130 130 131 131 config PCI_HYPERV ··· 137 135 PCI devices from a PCI backend to support PCI driver domains. 138 136 139 137 source "drivers/pci/hotplug/Kconfig" 138 + source "drivers/pci/cadence/Kconfig" 140 139 source "drivers/pci/dwc/Kconfig" 141 140 source "drivers/pci/host/Kconfig" 142 141 source "drivers/pci/endpoint/Kconfig"
+11 -3
drivers/pci/Makefile
··· 3 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 7 pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ 8 8 irq.o vpd.o setup-bus.o vc.o mmap.o setup-irq.o 9 9 10 + ifdef CONFIG_PCI 10 11 obj-$(CONFIG_PROC_FS) += proc.o 11 12 obj-$(CONFIG_SYSFS) += slot.o 13 + obj-$(CONFIG_OF) += of.o 14 + endif 12 15 13 16 obj-$(CONFIG_PCI_QUIRKS) += quirks.o 14 17 ··· 47 44 48 45 obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o 49 46 50 - obj-$(CONFIG_OF) += of.o 51 - 52 47 ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG 53 48 54 49 # PCI host controller drivers 55 50 obj-y += host/ 56 51 obj-y += switch/ 52 + 53 + obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ 54 + 55 + # Endpoint library must be initialized before its users 56 + obj-$(CONFIG_PCIE_CADENCE) += cadence/ 57 + # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW 58 + obj-y += dwc/
+4 -5
drivers/pci/access.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 #include <linux/delay.h> 2 3 #include <linux/pci.h> 3 4 #include <linux/module.h> ··· 334 333 (tag == PCI_VPD_LTIN_RW_DATA)) { 335 334 if (pci_read_vpd(dev, off+1, 2, 336 335 &header[1]) != 2) { 337 - dev_warn(&dev->dev, 338 - "invalid large VPD tag %02x size at offset %zu", 336 + pci_warn(dev, "invalid large VPD tag %02x size at offset %zu", 339 337 tag, off + 1); 340 338 return 0; 341 339 } ··· 354 354 if ((tag != PCI_VPD_LTIN_ID_STRING) && 355 355 (tag != PCI_VPD_LTIN_RO_DATA) && 356 356 (tag != PCI_VPD_LTIN_RW_DATA)) { 357 - dev_warn(&dev->dev, 358 - "invalid %s VPD tag %02x at offset %zu", 357 + pci_warn(dev, "invalid %s VPD tag %02x at offset %zu", 359 358 (header[0] & PCI_VPD_LRDT) ? "large" : "short", 360 359 tag, off); 361 360 return 0; ··· 401 402 max_sleep *= 2; 402 403 } 403 404 404 - 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"); 405 + pci_warn(dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n"); 405 406 return -ETIMEDOUT; 406 407 } 407 408
+1
drivers/pci/ats.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/ats.c 3 4 *
+3 -2
drivers/pci/bus.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/bus.c 3 4 * ··· 290 289 res->end = end; 291 290 res->flags &= ~IORESOURCE_UNSET; 292 291 orig_res.flags &= ~IORESOURCE_UNSET; 293 - dev_printk(KERN_DEBUG, &dev->dev, "%pR clipped to %pR\n", 292 + pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n", 294 293 &orig_res, res); 295 294 296 295 return true; ··· 326 325 dev->match_driver = true; 327 326 retval = device_attach(&dev->dev); 328 327 if (retval < 0 && retval != -EPROBE_DEFER) { 329 - dev_warn(&dev->dev, "device attach failed (%d)\n", retval); 328 + pci_warn(dev, "device attach failed (%d)\n", retval); 330 329 pci_proc_detach_device(dev); 331 330 pci_remove_sysfs_dev_files(dev); 332 331 return;
+27
drivers/pci/cadence/Kconfig
··· 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
+4
drivers/pci/cadence/Makefile
··· 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
+542
drivers/pci/cadence/pcie-cadence-ep.c
··· 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);
+336
drivers/pci/cadence/pcie-cadence-host.c
··· 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);
+126
drivers/pci/cadence/pcie-cadence.c
··· 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 + }
+311
drivers/pci/cadence/pcie-cadence.h
··· 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 */
+42 -28
drivers/pci/dwc/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 1 3 menu "DesignWare PCI Core Support" 2 4 3 5 config PCIE_DW ··· 17 15 select PCIE_DW 18 16 19 17 config PCI_DRA7XX 20 - bool "TI DRA7xx PCIe controller" 21 - depends on SOC_DRA7XX || COMPILE_TEST 22 - depends on (PCI && PCI_MSI_IRQ_DOMAIN) || PCI_ENDPOINT 23 - depends on OF && HAS_IOMEM && TI_PIPE3 24 - help 25 - Enables support for the PCIe controller in the DRA7xx SoC. There 26 - are two instances of PCIe controller in DRA7xx. This controller can 27 - work either as EP or RC. In order to enable host-specific features 28 - PCI_DRA7XX_HOST must be selected and in order to enable device- 29 - specific features PCI_DRA7XX_EP must be selected. This uses 30 - the DesignWare core. 31 - 32 - if PCI_DRA7XX 18 + bool 33 19 34 20 config PCI_DRA7XX_HOST 35 - bool "PCI DRA7xx Host Mode" 36 - depends on PCI 37 - depends on PCI_MSI_IRQ_DOMAIN 21 + bool "TI DRA7xx PCIe controller Host Mode" 22 + depends on SOC_DRA7XX || COMPILE_TEST 23 + depends on PCI && PCI_MSI_IRQ_DOMAIN 24 + depends on OF && HAS_IOMEM && TI_PIPE3 38 25 select PCIE_DW_HOST 26 + select PCI_DRA7XX 39 27 default y 40 28 help 41 - Enables support for the PCIe controller in the DRA7xx SoC to work in 42 - host mode. 29 + Enables support for the PCIe controller in the DRA7xx SoC to work in 30 + host mode. There are two instances of PCIe controller in DRA7xx. 31 + This controller can work either as EP or RC. In order to enable 32 + host-specific features PCI_DRA7XX_HOST must be selected and in order 33 + to enable device-specific features PCI_DRA7XX_EP must be selected. 34 + This uses the DesignWare core. 43 35 44 36 config PCI_DRA7XX_EP 45 - bool "PCI DRA7xx Endpoint Mode" 37 + bool "TI DRA7xx PCIe controller Endpoint Mode" 38 + depends on SOC_DRA7XX || COMPILE_TEST 46 39 depends on PCI_ENDPOINT 40 + depends on OF && HAS_IOMEM && TI_PIPE3 47 41 select PCIE_DW_EP 42 + select PCI_DRA7XX 48 43 help 49 - Enables support for the PCIe controller in the DRA7xx SoC to work in 50 - endpoint mode. 51 - 52 - endif 44 + Enables support for the PCIe controller in the DRA7xx SoC to work in 45 + endpoint mode. There are two instances of PCIe controller in DRA7xx. 46 + This controller can work either as EP or RC. In order to enable 47 + host-specific features PCI_DRA7XX_HOST must be selected and in order 48 + to enable device-specific features PCI_DRA7XX_EP must be selected. 49 + This uses the DesignWare core. 53 50 54 51 config PCIE_DW_PLAT 55 52 bool "Platform bus based DesignWare PCIe Controller" ··· 150 149 DesignWare core functions to implement the driver. 151 150 152 151 config PCIE_ARTPEC6 153 - bool "Axis ARTPEC-6 PCIe controller" 154 - depends on PCI 152 + bool 153 + 154 + config PCIE_ARTPEC6_HOST 155 + bool "Axis ARTPEC-6 PCIe controller Host Mode" 155 156 depends on MACH_ARTPEC6 156 - depends on PCI_MSI_IRQ_DOMAIN 157 + depends on PCI && PCI_MSI_IRQ_DOMAIN 157 158 select PCIEPORTBUS 158 159 select PCIE_DW_HOST 160 + select PCIE_ARTPEC6 159 161 help 160 - Say Y here to enable PCIe controller support on Axis ARTPEC-6 161 - SoCs. This PCIe controller uses the DesignWare core. 162 + Enables support for the PCIe controller in the ARTPEC-6 SoC to work in 163 + host mode. This uses the DesignWare core. 164 + 165 + config PCIE_ARTPEC6_EP 166 + bool "Axis ARTPEC-6 PCIe controller Endpoint Mode" 167 + depends on MACH_ARTPEC6 168 + depends on PCI_ENDPOINT 169 + select PCIE_DW_EP 170 + select PCIE_ARTPEC6 171 + help 172 + Enables support for the PCIe controller in the ARTPEC-6 SoC to work in 173 + endpoint mode. This uses the DesignWare core. 162 174 163 175 config PCIE_KIRIN 164 176 depends on OF && ARM64
+3 -3
drivers/pci/dwc/Makefile
··· 3 3 obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o 4 4 obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o 5 5 obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o 6 - ifneq ($(filter y,$(CONFIG_PCI_DRA7XX_HOST) $(CONFIG_PCI_DRA7XX_EP)),) 7 - obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o 8 - endif 6 + obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o 9 7 obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o 10 8 obj-$(CONFIG_PCI_IMX6) += pci-imx6.o 11 9 obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o ··· 25 27 # ARM64 and use internal ifdefs to only build the pieces we need 26 28 # depending on whether ACPI, the DT driver, or both are enabled. 27 29 30 + ifdef CONFIG_PCI 28 31 obj-$(CONFIG_ARM64) += pcie-hisi.o 32 + endif
+24 -23
drivers/pci/dwc/pci-dra7xx.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * pcie-dra7xx - PCIe controller driver for TI DRA7xx SoCs 3 4 * 4 5 * Copyright (C) 2013-2014 Texas Instruments Incorporated - http://www.ti.com 5 6 * 6 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 10 #include <linux/delay.h> ··· 107 110 writel(value, pcie->base + offset); 108 111 } 109 112 110 - static u64 dra7xx_pcie_cpu_addr_fixup(u64 pci_addr) 113 + static u64 dra7xx_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 pci_addr) 111 114 { 112 115 return pci_addr & DRA7XX_CPU_TO_BUS_ADDR; 113 116 } ··· 223 226 224 227 static const struct irq_domain_ops intx_domain_ops = { 225 228 .map = dra7xx_pcie_intx_map, 229 + .xlate = pci_irqd_intx_xlate, 226 230 }; 227 231 228 232 static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) ··· 254 256 struct dra7xx_pcie *dra7xx = arg; 255 257 struct dw_pcie *pci = dra7xx->pci; 256 258 struct pcie_port *pp = &pci->pp; 257 - u32 reg; 259 + unsigned long reg; 260 + u32 virq, bit; 258 261 259 262 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI); 260 263 ··· 267 268 case INTB: 268 269 case INTC: 269 270 case INTD: 270 - generic_handle_irq(irq_find_mapping(dra7xx->irq_domain, 271 - ffs(reg))); 271 + for_each_set_bit(bit, &reg, PCI_NUM_INTX) { 272 + virq = irq_find_mapping(dra7xx->irq_domain, bit); 273 + if (virq) 274 + generic_handle_irq(virq); 275 + } 272 276 break; 273 277 } 274 278 ··· 339 337 return IRQ_HANDLED; 340 338 } 341 339 342 - static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) 343 - { 344 - u32 reg; 345 - 346 - reg = PCI_BASE_ADDRESS_0 + (4 * bar); 347 - dw_pcie_writel_dbi2(pci, reg, 0x0); 348 - dw_pcie_writel_dbi(pci, reg, 0x0); 349 - } 350 - 351 340 static void dra7xx_pcie_ep_init(struct dw_pcie_ep *ep) 352 341 { 353 342 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); ··· 368 375 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_MSI_XMT, reg); 369 376 } 370 377 371 - static int dra7xx_pcie_raise_irq(struct dw_pcie_ep *ep, 378 + static int dra7xx_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no, 372 379 enum pci_epc_irq_type type, u8 interrupt_num) 373 380 { 374 381 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); ··· 462 469 pci->dbi_base = devm_ioremap(dev, res->start, resource_size(res)); 463 470 if (!pci->dbi_base) 464 471 return -ENOMEM; 472 + 473 + pp->ops = &dra7xx_pcie_host_ops; 465 474 466 475 ret = dw_pcie_host_init(pp); 467 476 if (ret) { ··· 594 599 void __iomem *base; 595 600 struct resource *res; 596 601 struct dw_pcie *pci; 597 - struct pcie_port *pp; 598 602 struct dra7xx_pcie *dra7xx; 599 603 struct device *dev = &pdev->dev; 600 604 struct device_node *np = dev->of_node; ··· 620 626 621 627 pci->dev = dev; 622 628 pci->ops = &dw_pcie_ops; 623 - 624 - pp = &pci->pp; 625 - pp->ops = &dra7xx_pcie_host_ops; 626 629 627 630 irq = platform_get_irq(pdev, 0); 628 631 if (irq < 0) { ··· 696 705 697 706 switch (mode) { 698 707 case DW_PCIE_RC_TYPE: 708 + if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) { 709 + ret = -ENODEV; 710 + goto err_gpio; 711 + } 712 + 699 713 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, 700 714 DEVICE_TYPE_RC); 701 715 ret = dra7xx_add_pcie_port(dra7xx, pdev); ··· 708 712 goto err_gpio; 709 713 break; 710 714 case DW_PCIE_EP_TYPE: 715 + if (!IS_ENABLED(CONFIG_PCI_DRA7XX_EP)) { 716 + ret = -ENODEV; 717 + goto err_gpio; 718 + } 719 + 711 720 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, 712 721 DEVICE_TYPE_EP); 713 722 ··· 811 810 } 812 811 #endif 813 812 814 - void dra7xx_pcie_shutdown(struct platform_device *pdev) 813 + static void dra7xx_pcie_shutdown(struct platform_device *pdev) 815 814 { 816 815 struct device *dev = &pdev->dev; 817 816 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+13 -212
drivers/pci/dwc/pci-exynos.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Samsung EXYNOS SoCs 3 4 * ··· 6 5 * http://www.samsung.com 7 6 * 8 7 * Author: Jingoo Han <jg1.han@samsung.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 8 */ 14 9 15 10 #include <linux/clk.h> ··· 52 55 #define PCIE_ELBI_SLV_ARMISC 0x120 53 56 #define PCIE_ELBI_SLV_DBI_ENABLE BIT(21) 54 57 55 - /* PCIe Purple registers */ 56 - #define PCIE_PHY_GLOBAL_RESET 0x000 57 - #define PCIE_PHY_COMMON_RESET 0x004 58 - #define PCIE_PHY_CMN_REG 0x008 59 - #define PCIE_PHY_MAC_RESET 0x00c 60 - #define PCIE_PHY_PLL_LOCKED 0x010 61 - #define PCIE_PHY_TRSVREG_RESET 0x020 62 - #define PCIE_PHY_TRSV_RESET 0x024 63 - 64 - /* PCIe PHY registers */ 65 - #define PCIE_PHY_IMPEDANCE 0x004 66 - #define PCIE_PHY_PLL_DIV_0 0x008 67 - #define PCIE_PHY_PLL_BIAS 0x00c 68 - #define PCIE_PHY_DCC_FEEDBACK 0x014 69 - #define PCIE_PHY_PLL_DIV_1 0x05c 70 - #define PCIE_PHY_COMMON_POWER 0x064 71 - #define PCIE_PHY_COMMON_PD_CMN BIT(3) 72 - #define PCIE_PHY_TRSV0_EMP_LVL 0x084 73 - #define PCIE_PHY_TRSV0_DRV_LVL 0x088 74 - #define PCIE_PHY_TRSV0_RXCDR 0x0ac 75 - #define PCIE_PHY_TRSV0_POWER 0x0c4 76 - #define PCIE_PHY_TRSV0_PD_TSV BIT(7) 77 - #define PCIE_PHY_TRSV0_LVCC 0x0dc 78 - #define PCIE_PHY_TRSV1_EMP_LVL 0x144 79 - #define PCIE_PHY_TRSV1_RXCDR 0x16c 80 - #define PCIE_PHY_TRSV1_POWER 0x184 81 - #define PCIE_PHY_TRSV1_PD_TSV BIT(7) 82 - #define PCIE_PHY_TRSV1_LVCC 0x19c 83 - #define PCIE_PHY_TRSV2_EMP_LVL 0x204 84 - #define PCIE_PHY_TRSV2_RXCDR 0x22c 85 - #define PCIE_PHY_TRSV2_POWER 0x244 86 - #define PCIE_PHY_TRSV2_PD_TSV BIT(7) 87 - #define PCIE_PHY_TRSV2_LVCC 0x25c 88 - #define PCIE_PHY_TRSV3_EMP_LVL 0x2c4 89 - #define PCIE_PHY_TRSV3_RXCDR 0x2ec 90 - #define PCIE_PHY_TRSV3_POWER 0x304 91 - #define PCIE_PHY_TRSV3_PD_TSV BIT(7) 92 - #define PCIE_PHY_TRSV3_LVCC 0x31c 93 - 94 58 struct exynos_pcie_mem_res { 95 59 void __iomem *elbi_base; /* DT 0th resource: PCIe CTRL */ 96 - void __iomem *phy_base; /* DT 1st resource: PHY CTRL */ 97 - void __iomem *block_base; /* DT 2nd resource: PHY ADDITIONAL CTRL */ 98 60 }; 99 61 100 62 struct exynos_pcie_clk_res { ··· 68 112 const struct exynos_pcie_ops *ops; 69 113 int reset_gpio; 70 114 71 - /* For Generic PHY Framework */ 72 - bool using_phy; 73 115 struct phy *phy; 74 116 }; 75 117 ··· 94 140 ep->mem_res->elbi_base = devm_ioremap_resource(dev, res); 95 141 if (IS_ERR(ep->mem_res->elbi_base)) 96 142 return PTR_ERR(ep->mem_res->elbi_base); 97 - 98 - /* If using the PHY framework, doesn't need to get other resource */ 99 - if (ep->using_phy) 100 - return 0; 101 - 102 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 103 - ep->mem_res->phy_base = devm_ioremap_resource(dev, res); 104 - if (IS_ERR(ep->mem_res->phy_base)) 105 - return PTR_ERR(ep->mem_res->phy_base); 106 - 107 - res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 108 - ep->mem_res->block_base = devm_ioremap_resource(dev, res); 109 - if (IS_ERR(ep->mem_res->block_base)) 110 - return PTR_ERR(ep->mem_res->block_base); 111 143 112 144 return 0; 113 145 } ··· 219 279 exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_NONSTICKY_RESET); 220 280 exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_APP_INIT_RESET); 221 281 exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_APP_INIT_RESET); 222 - exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_MAC_RESET); 223 - } 224 - 225 - static void exynos_pcie_assert_phy_reset(struct exynos_pcie *ep) 226 - { 227 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_MAC_RESET); 228 - exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_GLOBAL_RESET); 229 - } 230 - 231 - static void exynos_pcie_deassert_phy_reset(struct exynos_pcie *ep) 232 - { 233 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_GLOBAL_RESET); 234 - exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_PWR_RESET); 235 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_COMMON_RESET); 236 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_CMN_REG); 237 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_TRSVREG_RESET); 238 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_TRSV_RESET); 239 - } 240 - 241 - static void exynos_pcie_power_on_phy(struct exynos_pcie *ep) 242 - { 243 - u32 val; 244 - 245 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_COMMON_POWER); 246 - val &= ~PCIE_PHY_COMMON_PD_CMN; 247 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_COMMON_POWER); 248 - 249 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV0_POWER); 250 - val &= ~PCIE_PHY_TRSV0_PD_TSV; 251 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV0_POWER); 252 - 253 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV1_POWER); 254 - val &= ~PCIE_PHY_TRSV1_PD_TSV; 255 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV1_POWER); 256 - 257 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV2_POWER); 258 - val &= ~PCIE_PHY_TRSV2_PD_TSV; 259 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV2_POWER); 260 - 261 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV3_POWER); 262 - val &= ~PCIE_PHY_TRSV3_PD_TSV; 263 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV3_POWER); 264 - } 265 - 266 - static void exynos_pcie_power_off_phy(struct exynos_pcie *ep) 267 - { 268 - u32 val; 269 - 270 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_COMMON_POWER); 271 - val |= PCIE_PHY_COMMON_PD_CMN; 272 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_COMMON_POWER); 273 - 274 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV0_POWER); 275 - val |= PCIE_PHY_TRSV0_PD_TSV; 276 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV0_POWER); 277 - 278 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV1_POWER); 279 - val |= PCIE_PHY_TRSV1_PD_TSV; 280 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV1_POWER); 281 - 282 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV2_POWER); 283 - val |= PCIE_PHY_TRSV2_PD_TSV; 284 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV2_POWER); 285 - 286 - val = exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_TRSV3_POWER); 287 - val |= PCIE_PHY_TRSV3_PD_TSV; 288 - exynos_pcie_writel(ep->mem_res->phy_base, val, PCIE_PHY_TRSV3_POWER); 289 - } 290 - 291 - static void exynos_pcie_init_phy(struct exynos_pcie *ep) 292 - { 293 - /* DCC feedback control off */ 294 - exynos_pcie_writel(ep->mem_res->phy_base, 0x29, PCIE_PHY_DCC_FEEDBACK); 295 - 296 - /* set TX/RX impedance */ 297 - exynos_pcie_writel(ep->mem_res->phy_base, 0xd5, PCIE_PHY_IMPEDANCE); 298 - 299 - /* set 50Mhz PHY clock */ 300 - exynos_pcie_writel(ep->mem_res->phy_base, 0x14, PCIE_PHY_PLL_DIV_0); 301 - exynos_pcie_writel(ep->mem_res->phy_base, 0x12, PCIE_PHY_PLL_DIV_1); 302 - 303 - /* set TX Differential output for lane 0 */ 304 - exynos_pcie_writel(ep->mem_res->phy_base, 0x7f, PCIE_PHY_TRSV0_DRV_LVL); 305 - 306 - /* set TX Pre-emphasis Level Control for lane 0 to minimum */ 307 - exynos_pcie_writel(ep->mem_res->phy_base, 0x0, PCIE_PHY_TRSV0_EMP_LVL); 308 - 309 - /* set RX clock and data recovery bandwidth */ 310 - exynos_pcie_writel(ep->mem_res->phy_base, 0xe7, PCIE_PHY_PLL_BIAS); 311 - exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV0_RXCDR); 312 - exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV1_RXCDR); 313 - exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV2_RXCDR); 314 - exynos_pcie_writel(ep->mem_res->phy_base, 0x82, PCIE_PHY_TRSV3_RXCDR); 315 - 316 - /* change TX Pre-emphasis Level Control for lanes */ 317 - exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV0_EMP_LVL); 318 - exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV1_EMP_LVL); 319 - exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV2_EMP_LVL); 320 - exynos_pcie_writel(ep->mem_res->phy_base, 0x39, PCIE_PHY_TRSV3_EMP_LVL); 321 - 322 - /* set LVCC */ 323 - exynos_pcie_writel(ep->mem_res->phy_base, 0x20, PCIE_PHY_TRSV0_LVCC); 324 - exynos_pcie_writel(ep->mem_res->phy_base, 0xa0, PCIE_PHY_TRSV1_LVCC); 325 - exynos_pcie_writel(ep->mem_res->phy_base, 0xa0, PCIE_PHY_TRSV2_LVCC); 326 - exynos_pcie_writel(ep->mem_res->phy_base, 0xa0, PCIE_PHY_TRSV3_LVCC); 327 282 } 328 283 329 284 static void exynos_pcie_assert_reset(struct exynos_pcie *ep) ··· 236 401 struct dw_pcie *pci = ep->pci; 237 402 struct pcie_port *pp = &pci->pp; 238 403 struct device *dev = pci->dev; 239 - u32 val; 240 404 241 405 if (dw_pcie_link_up(pci)) { 242 406 dev_err(dev, "Link already up\n"); ··· 244 410 245 411 exynos_pcie_assert_core_reset(ep); 246 412 247 - if (ep->using_phy) { 248 - phy_reset(ep->phy); 413 + phy_reset(ep->phy); 249 414 250 - exynos_pcie_writel(ep->mem_res->elbi_base, 1, 251 - PCIE_PWR_RESET); 415 + exynos_pcie_writel(ep->mem_res->elbi_base, 1, 416 + PCIE_PWR_RESET); 252 417 253 - phy_power_on(ep->phy); 254 - phy_init(ep->phy); 255 - } else { 256 - exynos_pcie_assert_phy_reset(ep); 257 - exynos_pcie_deassert_phy_reset(ep); 258 - exynos_pcie_power_on_phy(ep); 259 - exynos_pcie_init_phy(ep); 260 - 261 - /* pulse for common reset */ 262 - exynos_pcie_writel(ep->mem_res->block_base, 1, 263 - PCIE_PHY_COMMON_RESET); 264 - udelay(500); 265 - exynos_pcie_writel(ep->mem_res->block_base, 0, 266 - PCIE_PHY_COMMON_RESET); 267 - } 268 - 269 - /* pulse for common reset */ 270 - exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_COMMON_RESET); 271 - udelay(500); 272 - exynos_pcie_writel(ep->mem_res->block_base, 0, PCIE_PHY_COMMON_RESET); 418 + phy_power_on(ep->phy); 419 + phy_init(ep->phy); 273 420 274 421 exynos_pcie_deassert_core_reset(ep); 275 422 dw_pcie_setup_rc(pp); ··· 264 449 if (!dw_pcie_wait_for_link(pci)) 265 450 return 0; 266 451 267 - if (ep->using_phy) { 268 - phy_power_off(ep->phy); 269 - return -ETIMEDOUT; 270 - } 271 - 272 - while (exynos_pcie_readl(ep->mem_res->phy_base, 273 - PCIE_PHY_PLL_LOCKED) == 0) { 274 - val = exynos_pcie_readl(ep->mem_res->block_base, 275 - PCIE_PHY_PLL_LOCKED); 276 - dev_info(dev, "PLL Locked: 0x%x\n", val); 277 - } 278 - exynos_pcie_power_off_phy(ep); 452 + phy_power_off(ep->phy); 279 453 return -ETIMEDOUT; 280 454 } 281 455 ··· 482 678 483 679 ep->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); 484 680 485 - /* Assume that controller doesn't use the PHY framework */ 486 - ep->using_phy = false; 487 - 488 681 ep->phy = devm_of_phy_get(dev, np, NULL); 489 682 if (IS_ERR(ep->phy)) { 490 683 if (PTR_ERR(ep->phy) == -EPROBE_DEFER) 491 684 return PTR_ERR(ep->phy); 492 - dev_warn(dev, "Use the 'phy' property. Current DT of pci-exynos was deprecated!!\n"); 493 - } else 494 - ep->using_phy = true; 685 + 686 + ep->phy = NULL; 687 + } 495 688 496 689 if (ep->ops && ep->ops->get_mem_resources) { 497 690 ret = ep->ops->get_mem_resources(pdev, ep); ··· 496 695 return ret; 497 696 } 498 697 499 - if (ep->ops && ep->ops->get_clk_resources) { 698 + if (ep->ops && ep->ops->get_clk_resources && 699 + ep->ops->init_clk_resources) { 500 700 ret = ep->ops->get_clk_resources(ep); 501 701 if (ret) 502 702 return ret; ··· 515 713 return 0; 516 714 517 715 fail_probe: 518 - if (ep->using_phy) 519 - phy_exit(ep->phy); 716 + phy_exit(ep->phy); 520 717 521 718 if (ep->ops && ep->ops->deinit_clk_resources) 522 719 ep->ops->deinit_clk_resources(ep);
+1 -4
drivers/pci/dwc/pci-imx6.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Freescale i.MX6 SoCs 3 4 * ··· 6 5 * http://www.kosagi.com 7 6 * 8 7 * Author: Sean Cross <xobs@kosagi.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 8 */ 14 9 15 10 #include <linux/clk.h>
+1 -5
drivers/pci/dwc/pci-keystone-dw.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * DesignWare application register space functions for Keystone PCI controller 3 4 * ··· 6 5 * http://www.ti.com 7 6 * 8 7 * Author: Murali Karicheri <m-karicheri2@ti.com> 9 - * 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 version 2 as 13 - * published by the Free Software Foundation. 14 8 */ 15 9 16 10 #include <linux/irq.h>
+5 -5
drivers/pci/dwc/pci-keystone.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Texas Instruments Keystone SoCs 3 4 * ··· 7 6 * 8 7 * Author: Murali Karicheri <m-karicheri2@ti.com> 9 8 * Implementation based on pci-exynos.c and pcie-designware.c 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 version 2 as 13 - * published by the Free Software Foundation. 14 9 */ 15 10 16 11 #include <linux/irqchip/chained_irq.h> ··· 175 178 } 176 179 177 180 /* interrupt controller is in a child node */ 178 - *np_temp = of_find_node_by_name(np_pcie, controller); 181 + *np_temp = of_get_child_by_name(np_pcie, controller); 179 182 if (!(*np_temp)) { 180 183 dev_err(dev, "Node for %s is absent\n", controller); 181 184 return -EINVAL; ··· 184 187 temp = of_irq_count(*np_temp); 185 188 if (!temp) { 186 189 dev_err(dev, "No IRQ entries in %s\n", controller); 190 + of_node_put(*np_temp); 187 191 return -EINVAL; 188 192 } 189 193 ··· 201 203 if (!host_irqs[temp]) 202 204 break; 203 205 } 206 + 207 + of_node_put(*np_temp); 204 208 205 209 if (temp) { 206 210 *num_irqs = temp;
+1 -5
drivers/pci/dwc/pci-keystone.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Keystone PCI Controller's common includes 3 4 * ··· 6 5 * http://www.ti.com 7 6 * 8 7 * Author: Murali Karicheri <m-karicheri2@ti.com> 9 - * 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 version 2 as 13 - * published by the Free Software Foundation. 14 8 */ 15 9 16 10 #define MAX_MSI_HOST_IRQS 8
+1 -4
drivers/pci/dwc/pci-layerscape.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Freescale Layerscape SoCs 3 4 * 4 5 * Copyright (C) 2014 Freescale Semiconductor. 5 6 * 6 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 10 #include <linux/kernel.h>
+1 -4
drivers/pci/dwc/pcie-armada8k.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Marvell Armada-8K SoCs 3 4 * ··· 8 7 * 9 8 * Author: Yehuda Yitshak <yehuday@marvell.com> 10 9 * Author: Shadi Ammouri <shadi@marvell.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 10 */ 16 11 17 12 #include <linux/clk.h>
+412 -73
drivers/pci/dwc/pcie-artpec6.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Axis ARTPEC-6 SoC 3 4 * 4 5 * Author: Niklas Cassel <niklas.cassel@axis.com> 5 6 * 6 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 10 #include <linux/delay.h> 14 11 #include <linux/kernel.h> 15 12 #include <linux/init.h> 13 + #include <linux/of_device.h> 16 14 #include <linux/pci.h> 17 15 #include <linux/platform_device.h> 18 16 #include <linux/resource.h> ··· 24 26 25 27 #define to_artpec6_pcie(x) dev_get_drvdata((x)->dev) 26 28 29 + enum artpec_pcie_variants { 30 + ARTPEC6, 31 + ARTPEC7, 32 + }; 33 + 27 34 struct artpec6_pcie { 28 35 struct dw_pcie *pci; 29 36 struct regmap *regmap; /* DT axis,syscon-pcie */ 30 37 void __iomem *phy_base; /* DT phy */ 38 + enum artpec_pcie_variants variant; 39 + enum dw_pcie_device_mode mode; 31 40 }; 41 + 42 + struct artpec_pcie_of_data { 43 + enum artpec_pcie_variants variant; 44 + enum dw_pcie_device_mode mode; 45 + }; 46 + 47 + static const struct of_device_id artpec6_pcie_of_match[]; 32 48 33 49 /* PCIe Port Logic registers (memory-mapped) */ 34 50 #define PL_OFFSET 0x700 35 - #define PCIE_PHY_DEBUG_R0 (PL_OFFSET + 0x28) 36 - #define PCIE_PHY_DEBUG_R1 (PL_OFFSET + 0x2c) 37 51 38 - #define MISC_CONTROL_1_OFF (PL_OFFSET + 0x1bc) 39 - #define DBI_RO_WR_EN 1 52 + #define ACK_F_ASPM_CTRL_OFF (PL_OFFSET + 0xc) 53 + #define ACK_N_FTS_MASK GENMASK(15, 8) 54 + #define ACK_N_FTS(x) (((x) << 8) & ACK_N_FTS_MASK) 55 + 56 + #define FAST_TRAINING_SEQ_MASK GENMASK(7, 0) 57 + #define FAST_TRAINING_SEQ(x) (((x) << 0) & FAST_TRAINING_SEQ_MASK) 40 58 41 59 /* ARTPEC-6 specific registers */ 42 60 #define PCIECFG 0x18 43 - #define PCIECFG_DBG_OEN (1 << 24) 44 - #define PCIECFG_CORE_RESET_REQ (1 << 21) 45 - #define PCIECFG_LTSSM_ENABLE (1 << 20) 46 - #define PCIECFG_CLKREQ_B (1 << 11) 47 - #define PCIECFG_REFCLK_ENABLE (1 << 10) 48 - #define PCIECFG_PLL_ENABLE (1 << 9) 49 - #define PCIECFG_PCLK_ENABLE (1 << 8) 50 - #define PCIECFG_RISRCREN (1 << 4) 51 - #define PCIECFG_MODE_TX_DRV_EN (1 << 3) 52 - #define PCIECFG_CISRREN (1 << 2) 53 - #define PCIECFG_MACRO_ENABLE (1 << 0) 61 + #define PCIECFG_DBG_OEN BIT(24) 62 + #define PCIECFG_CORE_RESET_REQ BIT(21) 63 + #define PCIECFG_LTSSM_ENABLE BIT(20) 64 + #define PCIECFG_DEVICE_TYPE_MASK GENMASK(19, 16) 65 + #define PCIECFG_CLKREQ_B BIT(11) 66 + #define PCIECFG_REFCLK_ENABLE BIT(10) 67 + #define PCIECFG_PLL_ENABLE BIT(9) 68 + #define PCIECFG_PCLK_ENABLE BIT(8) 69 + #define PCIECFG_RISRCREN BIT(4) 70 + #define PCIECFG_MODE_TX_DRV_EN BIT(3) 71 + #define PCIECFG_CISRREN BIT(2) 72 + #define PCIECFG_MACRO_ENABLE BIT(0) 73 + /* ARTPEC-7 specific fields */ 74 + #define PCIECFG_REFCLKSEL BIT(23) 75 + #define PCIECFG_NOC_RESET BIT(3) 76 + 77 + #define PCIESTAT 0x1c 78 + /* ARTPEC-7 specific fields */ 79 + #define PCIESTAT_EXTREFCLK BIT(3) 54 80 55 81 #define NOCCFG 0x40 56 - #define NOCCFG_ENABLE_CLK_PCIE (1 << 4) 57 - #define NOCCFG_POWER_PCIE_IDLEACK (1 << 3) 58 - #define NOCCFG_POWER_PCIE_IDLE (1 << 2) 59 - #define NOCCFG_POWER_PCIE_IDLEREQ (1 << 1) 82 + #define NOCCFG_ENABLE_CLK_PCIE BIT(4) 83 + #define NOCCFG_POWER_PCIE_IDLEACK BIT(3) 84 + #define NOCCFG_POWER_PCIE_IDLE BIT(2) 85 + #define NOCCFG_POWER_PCIE_IDLEREQ BIT(1) 60 86 61 87 #define PHY_STATUS 0x118 62 - #define PHY_COSPLLLOCK (1 << 0) 88 + #define PHY_COSPLLLOCK BIT(0) 63 89 64 - #define ARTPEC6_CPU_TO_BUS_ADDR 0x0fffffff 90 + #define PHY_TX_ASIC_OUT 0x4040 91 + #define PHY_TX_ASIC_OUT_TX_ACK BIT(0) 92 + 93 + #define PHY_RX_ASIC_OUT 0x405c 94 + #define PHY_RX_ASIC_OUT_ACK BIT(0) 65 95 66 96 static u32 artpec6_pcie_readl(struct artpec6_pcie *artpec6_pcie, u32 offset) 67 97 { ··· 104 78 regmap_write(artpec6_pcie->regmap, offset, val); 105 79 } 106 80 107 - static u64 artpec6_pcie_cpu_addr_fixup(u64 pci_addr) 81 + static u64 artpec6_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 pci_addr) 108 82 { 109 - return pci_addr & ARTPEC6_CPU_TO_BUS_ADDR; 83 + struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); 84 + struct pcie_port *pp = &pci->pp; 85 + struct dw_pcie_ep *ep = &pci->ep; 86 + 87 + switch (artpec6_pcie->mode) { 88 + case DW_PCIE_RC_TYPE: 89 + return pci_addr - pp->cfg0_base; 90 + case DW_PCIE_EP_TYPE: 91 + return pci_addr - ep->phys_base; 92 + default: 93 + dev_err(pci->dev, "UNKNOWN device type\n"); 94 + } 95 + return pci_addr; 110 96 } 111 97 112 - static int artpec6_pcie_establish_link(struct artpec6_pcie *artpec6_pcie) 98 + static int artpec6_pcie_establish_link(struct dw_pcie *pci) 99 + { 100 + struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); 101 + u32 val; 102 + 103 + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 104 + val |= PCIECFG_LTSSM_ENABLE; 105 + artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 106 + 107 + return 0; 108 + } 109 + 110 + static void artpec6_pcie_stop_link(struct dw_pcie *pci) 111 + { 112 + struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); 113 + u32 val; 114 + 115 + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 116 + val &= ~PCIECFG_LTSSM_ENABLE; 117 + artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 118 + } 119 + 120 + static const struct dw_pcie_ops dw_pcie_ops = { 121 + .cpu_addr_fixup = artpec6_pcie_cpu_addr_fixup, 122 + .start_link = artpec6_pcie_establish_link, 123 + .stop_link = artpec6_pcie_stop_link, 124 + }; 125 + 126 + static void artpec6_pcie_wait_for_phy_a6(struct artpec6_pcie *artpec6_pcie) 113 127 { 114 128 struct dw_pcie *pci = artpec6_pcie->pci; 115 - struct pcie_port *pp = &pci->pp; 129 + struct device *dev = pci->dev; 116 130 u32 val; 117 131 unsigned int retries; 118 132 119 - /* Hold DW core in reset */ 120 - val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 121 - val |= PCIECFG_CORE_RESET_REQ; 122 - artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 133 + retries = 50; 134 + do { 135 + usleep_range(1000, 2000); 136 + val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); 137 + retries--; 138 + } while (retries && 139 + (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); 140 + if (!retries) 141 + dev_err(dev, "PCIe clock manager did not leave idle state\n"); 142 + 143 + retries = 50; 144 + do { 145 + usleep_range(1000, 2000); 146 + val = readl(artpec6_pcie->phy_base + PHY_STATUS); 147 + retries--; 148 + } while (retries && !(val & PHY_COSPLLLOCK)); 149 + if (!retries) 150 + dev_err(dev, "PHY PLL did not lock\n"); 151 + } 152 + 153 + static void artpec6_pcie_wait_for_phy_a7(struct artpec6_pcie *artpec6_pcie) 154 + { 155 + struct dw_pcie *pci = artpec6_pcie->pci; 156 + struct device *dev = pci->dev; 157 + u32 val; 158 + u16 phy_status_tx, phy_status_rx; 159 + unsigned int retries; 160 + 161 + retries = 50; 162 + do { 163 + usleep_range(1000, 2000); 164 + val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); 165 + retries--; 166 + } while (retries && 167 + (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); 168 + if (!retries) 169 + dev_err(dev, "PCIe clock manager did not leave idle state\n"); 170 + 171 + retries = 50; 172 + do { 173 + usleep_range(1000, 2000); 174 + phy_status_tx = readw(artpec6_pcie->phy_base + PHY_TX_ASIC_OUT); 175 + phy_status_rx = readw(artpec6_pcie->phy_base + PHY_RX_ASIC_OUT); 176 + retries--; 177 + } while (retries && ((phy_status_tx & PHY_TX_ASIC_OUT_TX_ACK) || 178 + (phy_status_rx & PHY_RX_ASIC_OUT_ACK))); 179 + if (!retries) 180 + dev_err(dev, "PHY did not enter Pn state\n"); 181 + } 182 + 183 + static void artpec6_pcie_wait_for_phy(struct artpec6_pcie *artpec6_pcie) 184 + { 185 + switch (artpec6_pcie->variant) { 186 + case ARTPEC6: 187 + artpec6_pcie_wait_for_phy_a6(artpec6_pcie); 188 + break; 189 + case ARTPEC7: 190 + artpec6_pcie_wait_for_phy_a7(artpec6_pcie); 191 + break; 192 + } 193 + } 194 + 195 + static void artpec6_pcie_init_phy_a6(struct artpec6_pcie *artpec6_pcie) 196 + { 197 + u32 val; 123 198 124 199 val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 125 200 val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ ··· 246 119 val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); 247 120 val &= ~NOCCFG_POWER_PCIE_IDLEREQ; 248 121 artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); 122 + } 249 123 250 - retries = 50; 251 - do { 252 - usleep_range(1000, 2000); 253 - val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); 254 - retries--; 255 - } while (retries && 256 - (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); 124 + static void artpec6_pcie_init_phy_a7(struct artpec6_pcie *artpec6_pcie) 125 + { 126 + struct dw_pcie *pci = artpec6_pcie->pci; 127 + u32 val; 128 + bool extrefclk; 257 129 258 - retries = 50; 259 - do { 260 - usleep_range(1000, 2000); 261 - val = readl(artpec6_pcie->phy_base + PHY_STATUS); 262 - retries--; 263 - } while (retries && !(val & PHY_COSPLLLOCK)); 130 + /* Check if external reference clock is connected */ 131 + val = artpec6_pcie_readl(artpec6_pcie, PCIESTAT); 132 + extrefclk = !!(val & PCIESTAT_EXTREFCLK); 133 + dev_dbg(pci->dev, "Using reference clock: %s\n", 134 + extrefclk ? "external" : "internal"); 264 135 265 - /* Take DW core out of reset */ 266 136 val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 267 - val &= ~PCIECFG_CORE_RESET_REQ; 137 + val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ 138 + PCIECFG_PCLK_ENABLE; 139 + if (extrefclk) 140 + val |= PCIECFG_REFCLKSEL; 141 + else 142 + val &= ~PCIECFG_REFCLKSEL; 143 + artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 144 + usleep_range(10, 20); 145 + 146 + val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); 147 + val |= NOCCFG_ENABLE_CLK_PCIE; 148 + artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); 149 + usleep_range(20, 30); 150 + 151 + val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); 152 + val &= ~NOCCFG_POWER_PCIE_IDLEREQ; 153 + artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); 154 + } 155 + 156 + static void artpec6_pcie_init_phy(struct artpec6_pcie *artpec6_pcie) 157 + { 158 + switch (artpec6_pcie->variant) { 159 + case ARTPEC6: 160 + artpec6_pcie_init_phy_a6(artpec6_pcie); 161 + break; 162 + case ARTPEC7: 163 + artpec6_pcie_init_phy_a7(artpec6_pcie); 164 + break; 165 + } 166 + } 167 + 168 + static void artpec6_pcie_set_nfts(struct artpec6_pcie *artpec6_pcie) 169 + { 170 + struct dw_pcie *pci = artpec6_pcie->pci; 171 + u32 val; 172 + 173 + if (artpec6_pcie->variant != ARTPEC7) 174 + return; 175 + 176 + /* 177 + * Increase the N_FTS (Number of Fast Training Sequences) 178 + * to be transmitted when transitioning from L0s to L0. 179 + */ 180 + val = dw_pcie_readl_dbi(pci, ACK_F_ASPM_CTRL_OFF); 181 + val &= ~ACK_N_FTS_MASK; 182 + val |= ACK_N_FTS(180); 183 + dw_pcie_writel_dbi(pci, ACK_F_ASPM_CTRL_OFF, val); 184 + 185 + /* 186 + * Set the Number of Fast Training Sequences that the core 187 + * advertises as its N_FTS during Gen2 or Gen3 link training. 188 + */ 189 + val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL); 190 + val &= ~FAST_TRAINING_SEQ_MASK; 191 + val |= FAST_TRAINING_SEQ(180); 192 + dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val); 193 + } 194 + 195 + static void artpec6_pcie_assert_core_reset(struct artpec6_pcie *artpec6_pcie) 196 + { 197 + u32 val; 198 + 199 + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 200 + switch (artpec6_pcie->variant) { 201 + case ARTPEC6: 202 + val |= PCIECFG_CORE_RESET_REQ; 203 + break; 204 + case ARTPEC7: 205 + val &= ~PCIECFG_NOC_RESET; 206 + break; 207 + } 208 + artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 209 + } 210 + 211 + static void artpec6_pcie_deassert_core_reset(struct artpec6_pcie *artpec6_pcie) 212 + { 213 + u32 val; 214 + 215 + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 216 + switch (artpec6_pcie->variant) { 217 + case ARTPEC6: 218 + val &= ~PCIECFG_CORE_RESET_REQ; 219 + break; 220 + case ARTPEC7: 221 + val |= PCIECFG_NOC_RESET; 222 + break; 223 + } 268 224 artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 269 225 usleep_range(100, 200); 270 - 271 - /* setup root complex */ 272 - dw_pcie_setup_rc(pp); 273 - 274 - /* assert LTSSM enable */ 275 - val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 276 - val |= PCIECFG_LTSSM_ENABLE; 277 - artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 278 - 279 - /* check if the link is up or not */ 280 - if (!dw_pcie_wait_for_link(pci)) 281 - return 0; 282 - 283 - dev_dbg(pci->dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n", 284 - dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R0), 285 - dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R1)); 286 - 287 - return -ETIMEDOUT; 288 226 } 289 227 290 228 static void artpec6_pcie_enable_interrupts(struct artpec6_pcie *artpec6_pcie) ··· 366 174 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 367 175 struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); 368 176 369 - artpec6_pcie_establish_link(artpec6_pcie); 177 + artpec6_pcie_assert_core_reset(artpec6_pcie); 178 + artpec6_pcie_init_phy(artpec6_pcie); 179 + artpec6_pcie_deassert_core_reset(artpec6_pcie); 180 + artpec6_pcie_wait_for_phy(artpec6_pcie); 181 + artpec6_pcie_set_nfts(artpec6_pcie); 182 + dw_pcie_setup_rc(pp); 183 + artpec6_pcie_establish_link(pci); 184 + dw_pcie_wait_for_link(pci); 370 185 artpec6_pcie_enable_interrupts(artpec6_pcie); 371 186 372 187 return 0; ··· 429 230 return 0; 430 231 } 431 232 432 - static const struct dw_pcie_ops dw_pcie_ops = { 433 - .cpu_addr_fixup = artpec6_pcie_cpu_addr_fixup, 233 + static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) 234 + { 235 + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 236 + struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); 237 + enum pci_barno bar; 238 + 239 + artpec6_pcie_assert_core_reset(artpec6_pcie); 240 + artpec6_pcie_init_phy(artpec6_pcie); 241 + artpec6_pcie_deassert_core_reset(artpec6_pcie); 242 + artpec6_pcie_wait_for_phy(artpec6_pcie); 243 + artpec6_pcie_set_nfts(artpec6_pcie); 244 + 245 + for (bar = BAR_0; bar <= BAR_5; bar++) 246 + dw_pcie_ep_reset_bar(pci, bar); 247 + } 248 + 249 + static int artpec6_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no, 250 + enum pci_epc_irq_type type, u8 interrupt_num) 251 + { 252 + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 253 + 254 + switch (type) { 255 + case PCI_EPC_IRQ_LEGACY: 256 + dev_err(pci->dev, "EP cannot trigger legacy IRQs\n"); 257 + return -EINVAL; 258 + case PCI_EPC_IRQ_MSI: 259 + return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); 260 + default: 261 + dev_err(pci->dev, "UNKNOWN IRQ type\n"); 262 + } 263 + 264 + return 0; 265 + } 266 + 267 + static struct dw_pcie_ep_ops pcie_ep_ops = { 268 + .ep_init = artpec6_pcie_ep_init, 269 + .raise_irq = artpec6_pcie_raise_irq, 434 270 }; 271 + 272 + static int artpec6_add_pcie_ep(struct artpec6_pcie *artpec6_pcie, 273 + struct platform_device *pdev) 274 + { 275 + int ret; 276 + struct dw_pcie_ep *ep; 277 + struct resource *res; 278 + struct device *dev = &pdev->dev; 279 + struct dw_pcie *pci = artpec6_pcie->pci; 280 + 281 + ep = &pci->ep; 282 + ep->ops = &pcie_ep_ops; 283 + 284 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi2"); 285 + pci->dbi_base2 = devm_ioremap(dev, res->start, resource_size(res)); 286 + if (!pci->dbi_base2) 287 + return -ENOMEM; 288 + 289 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); 290 + if (!res) 291 + return -EINVAL; 292 + 293 + ep->phys_base = res->start; 294 + ep->addr_size = resource_size(res); 295 + 296 + ret = dw_pcie_ep_init(ep); 297 + if (ret) { 298 + dev_err(dev, "failed to initialize endpoint\n"); 299 + return ret; 300 + } 301 + 302 + return 0; 303 + } 435 304 436 305 static int artpec6_pcie_probe(struct platform_device *pdev) 437 306 { ··· 509 242 struct resource *dbi_base; 510 243 struct resource *phy_base; 511 244 int ret; 245 + const struct of_device_id *match; 246 + const struct artpec_pcie_of_data *data; 247 + enum artpec_pcie_variants variant; 248 + enum dw_pcie_device_mode mode; 249 + 250 + match = of_match_device(artpec6_pcie_of_match, dev); 251 + if (!match) 252 + return -EINVAL; 253 + 254 + data = (struct artpec_pcie_of_data *)match->data; 255 + variant = (enum artpec_pcie_variants)data->variant; 256 + mode = (enum dw_pcie_device_mode)data->mode; 512 257 513 258 artpec6_pcie = devm_kzalloc(dev, sizeof(*artpec6_pcie), GFP_KERNEL); 514 259 if (!artpec6_pcie) ··· 534 255 pci->ops = &dw_pcie_ops; 535 256 536 257 artpec6_pcie->pci = pci; 258 + artpec6_pcie->variant = variant; 259 + artpec6_pcie->mode = mode; 537 260 538 261 dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); 539 262 pci->dbi_base = devm_ioremap_resource(dev, dbi_base); ··· 555 274 556 275 platform_set_drvdata(pdev, artpec6_pcie); 557 276 558 - ret = artpec6_add_pcie_port(artpec6_pcie, pdev); 559 - if (ret < 0) 560 - return ret; 277 + switch (artpec6_pcie->mode) { 278 + case DW_PCIE_RC_TYPE: 279 + if (!IS_ENABLED(CONFIG_PCIE_ARTPEC6_HOST)) 280 + return -ENODEV; 281 + 282 + ret = artpec6_add_pcie_port(artpec6_pcie, pdev); 283 + if (ret < 0) 284 + return ret; 285 + break; 286 + case DW_PCIE_EP_TYPE: { 287 + u32 val; 288 + 289 + if (!IS_ENABLED(CONFIG_PCIE_ARTPEC6_EP)) 290 + return -ENODEV; 291 + 292 + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); 293 + val &= ~PCIECFG_DEVICE_TYPE_MASK; 294 + artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); 295 + ret = artpec6_add_pcie_ep(artpec6_pcie, pdev); 296 + if (ret < 0) 297 + return ret; 298 + break; 299 + } 300 + default: 301 + dev_err(dev, "INVALID device type %d\n", artpec6_pcie->mode); 302 + } 561 303 562 304 return 0; 563 305 } 564 306 307 + static const struct artpec_pcie_of_data artpec6_pcie_rc_of_data = { 308 + .variant = ARTPEC6, 309 + .mode = DW_PCIE_RC_TYPE, 310 + }; 311 + 312 + static const struct artpec_pcie_of_data artpec6_pcie_ep_of_data = { 313 + .variant = ARTPEC6, 314 + .mode = DW_PCIE_EP_TYPE, 315 + }; 316 + 317 + static const struct artpec_pcie_of_data artpec7_pcie_rc_of_data = { 318 + .variant = ARTPEC7, 319 + .mode = DW_PCIE_RC_TYPE, 320 + }; 321 + 322 + static const struct artpec_pcie_of_data artpec7_pcie_ep_of_data = { 323 + .variant = ARTPEC7, 324 + .mode = DW_PCIE_EP_TYPE, 325 + }; 326 + 565 327 static const struct of_device_id artpec6_pcie_of_match[] = { 566 - { .compatible = "axis,artpec6-pcie", }, 328 + { 329 + .compatible = "axis,artpec6-pcie", 330 + .data = &artpec6_pcie_rc_of_data, 331 + }, 332 + { 333 + .compatible = "axis,artpec6-pcie-ep", 334 + .data = &artpec6_pcie_ep_of_data, 335 + }, 336 + { 337 + .compatible = "axis,artpec7-pcie", 338 + .data = &artpec7_pcie_rc_of_data, 339 + }, 340 + { 341 + .compatible = "axis,artpec7-pcie-ep", 342 + .data = &artpec7_pcie_ep_of_data, 343 + }, 567 344 {}, 568 345 }; 569 346
+100 -40
drivers/pci/dwc/pcie-designware-ep.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /** 2 3 * Synopsys DesignWare PCIe Endpoint controller driver 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 9 #include <linux/of.h> ··· 19 30 pci_epc_linkup(epc); 20 31 } 21 32 22 - static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) 33 + void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) 23 34 { 24 35 u32 reg; 25 36 26 37 reg = PCI_BASE_ADDRESS_0 + (4 * bar); 38 + dw_pcie_dbi_ro_wr_en(pci); 27 39 dw_pcie_writel_dbi2(pci, reg, 0x0); 28 40 dw_pcie_writel_dbi(pci, reg, 0x0); 41 + dw_pcie_dbi_ro_wr_dis(pci); 29 42 } 30 43 31 - static int dw_pcie_ep_write_header(struct pci_epc *epc, 44 + static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, 32 45 struct pci_epf_header *hdr) 33 46 { 34 47 struct dw_pcie_ep *ep = epc_get_drvdata(epc); 35 48 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 36 49 50 + dw_pcie_dbi_ro_wr_en(pci); 37 51 dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, hdr->vendorid); 38 52 dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, hdr->deviceid); 39 53 dw_pcie_writeb_dbi(pci, PCI_REVISION_ID, hdr->revid); ··· 50 58 dw_pcie_writew_dbi(pci, PCI_SUBSYSTEM_ID, hdr->subsys_id); 51 59 dw_pcie_writeb_dbi(pci, PCI_INTERRUPT_PIN, 52 60 hdr->interrupt_pin); 61 + dw_pcie_dbi_ro_wr_dis(pci); 53 62 54 63 return 0; 55 64 } ··· 63 70 u32 free_win; 64 71 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 65 72 66 - free_win = find_first_zero_bit(&ep->ib_window_map, 67 - sizeof(ep->ib_window_map)); 73 + free_win = find_first_zero_bit(ep->ib_window_map, ep->num_ib_windows); 68 74 if (free_win >= ep->num_ib_windows) { 69 75 dev_err(pci->dev, "no free inbound window\n"); 70 76 return -EINVAL; ··· 77 85 } 78 86 79 87 ep->bar_to_atu[bar] = free_win; 80 - set_bit(free_win, &ep->ib_window_map); 88 + set_bit(free_win, ep->ib_window_map); 81 89 82 90 return 0; 83 91 } ··· 88 96 u32 free_win; 89 97 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 90 98 91 - free_win = find_first_zero_bit(&ep->ob_window_map, 92 - sizeof(ep->ob_window_map)); 99 + free_win = find_first_zero_bit(ep->ob_window_map, ep->num_ob_windows); 93 100 if (free_win >= ep->num_ob_windows) { 94 101 dev_err(pci->dev, "no free outbound window\n"); 95 102 return -EINVAL; ··· 97 106 dw_pcie_prog_outbound_atu(pci, free_win, PCIE_ATU_TYPE_MEM, 98 107 phys_addr, pci_addr, size); 99 108 100 - set_bit(free_win, &ep->ob_window_map); 109 + set_bit(free_win, ep->ob_window_map); 101 110 ep->outbound_addr[free_win] = phys_addr; 102 111 103 112 return 0; 104 113 } 105 114 106 - static void dw_pcie_ep_clear_bar(struct pci_epc *epc, enum pci_barno bar) 115 + static void dw_pcie_ep_clear_bar(struct pci_epc *epc, u8 func_no, 116 + enum pci_barno bar) 107 117 { 108 118 struct dw_pcie_ep *ep = epc_get_drvdata(epc); 109 119 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); ··· 113 121 dw_pcie_ep_reset_bar(pci, bar); 114 122 115 123 dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_INBOUND); 116 - clear_bit(atu_index, &ep->ib_window_map); 124 + clear_bit(atu_index, ep->ib_window_map); 117 125 } 118 126 119 - static int dw_pcie_ep_set_bar(struct pci_epc *epc, enum pci_barno bar, 127 + static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, 128 + enum pci_barno bar, 120 129 dma_addr_t bar_phys, size_t size, int flags) 121 130 { 122 131 int ret; ··· 135 142 if (ret) 136 143 return ret; 137 144 145 + dw_pcie_dbi_ro_wr_en(pci); 138 146 dw_pcie_writel_dbi2(pci, reg, size - 1); 139 147 dw_pcie_writel_dbi(pci, reg, flags); 148 + dw_pcie_dbi_ro_wr_dis(pci); 140 149 141 150 return 0; 142 151 } ··· 158 163 return -EINVAL; 159 164 } 160 165 161 - static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, phys_addr_t addr) 166 + static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, u8 func_no, 167 + phys_addr_t addr) 162 168 { 163 169 int ret; 164 170 u32 atu_index; ··· 171 175 return; 172 176 173 177 dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_OUTBOUND); 174 - clear_bit(atu_index, &ep->ob_window_map); 178 + clear_bit(atu_index, ep->ob_window_map); 175 179 } 176 180 177 - static int dw_pcie_ep_map_addr(struct pci_epc *epc, phys_addr_t addr, 181 + static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, 182 + phys_addr_t addr, 178 183 u64 pci_addr, size_t size) 179 184 { 180 185 int ret; ··· 191 194 return 0; 192 195 } 193 196 194 - static int dw_pcie_ep_get_msi(struct pci_epc *epc) 197 + static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no) 195 198 { 196 199 int val; 197 - u32 lower_addr; 198 - u32 upper_addr; 199 200 struct dw_pcie_ep *ep = epc_get_drvdata(epc); 200 201 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 201 202 202 - val = dw_pcie_readb_dbi(pci, MSI_MESSAGE_CONTROL); 203 - val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; 204 - 205 - lower_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); 206 - upper_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); 207 - 208 - if (!(lower_addr || upper_addr)) 203 + val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); 204 + if (!(val & MSI_CAP_MSI_EN_MASK)) 209 205 return -EINVAL; 210 206 207 + val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; 211 208 return val; 212 209 } 213 210 214 - static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 encode_int) 211 + static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 encode_int) 215 212 { 216 213 int val; 217 214 struct dw_pcie_ep *ep = epc_get_drvdata(epc); 218 215 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 219 216 220 - val = (encode_int << MSI_CAP_MMC_SHIFT); 217 + val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); 218 + val &= ~MSI_CAP_MMC_MASK; 219 + val |= (encode_int << MSI_CAP_MMC_SHIFT) & MSI_CAP_MMC_MASK; 220 + dw_pcie_dbi_ro_wr_en(pci); 221 221 dw_pcie_writew_dbi(pci, MSI_MESSAGE_CONTROL, val); 222 + dw_pcie_dbi_ro_wr_dis(pci); 222 223 223 224 return 0; 224 225 } 225 226 226 - static int dw_pcie_ep_raise_irq(struct pci_epc *epc, 227 + static int dw_pcie_ep_raise_irq(struct pci_epc *epc, u8 func_no, 227 228 enum pci_epc_irq_type type, u8 interrupt_num) 228 229 { 229 230 struct dw_pcie_ep *ep = epc_get_drvdata(epc); ··· 229 234 if (!ep->ops->raise_irq) 230 235 return -EINVAL; 231 236 232 - return ep->ops->raise_irq(ep, type, interrupt_num); 237 + return ep->ops->raise_irq(ep, func_no, type, interrupt_num); 233 238 } 234 239 235 240 static void dw_pcie_ep_stop(struct pci_epc *epc) ··· 267 272 .stop = dw_pcie_ep_stop, 268 273 }; 269 274 275 + int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, 276 + u8 interrupt_num) 277 + { 278 + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 279 + struct pci_epc *epc = ep->epc; 280 + u16 msg_ctrl, msg_data; 281 + u32 msg_addr_lower, msg_addr_upper; 282 + u64 msg_addr; 283 + bool has_upper; 284 + int ret; 285 + 286 + /* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */ 287 + msg_ctrl = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); 288 + has_upper = !!(msg_ctrl & PCI_MSI_FLAGS_64BIT); 289 + msg_addr_lower = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); 290 + if (has_upper) { 291 + msg_addr_upper = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); 292 + msg_data = dw_pcie_readw_dbi(pci, MSI_MESSAGE_DATA_64); 293 + } else { 294 + msg_addr_upper = 0; 295 + msg_data = dw_pcie_readw_dbi(pci, MSI_MESSAGE_DATA_32); 296 + } 297 + msg_addr = ((u64) msg_addr_upper) << 32 | msg_addr_lower; 298 + ret = dw_pcie_ep_map_addr(epc, func_no, ep->msi_mem_phys, msg_addr, 299 + epc->mem->page_size); 300 + if (ret) 301 + return ret; 302 + 303 + writel(msg_data | (interrupt_num - 1), ep->msi_mem); 304 + 305 + dw_pcie_ep_unmap_addr(epc, func_no, ep->msi_mem_phys); 306 + 307 + return 0; 308 + } 309 + 270 310 void dw_pcie_ep_exit(struct dw_pcie_ep *ep) 271 311 { 272 312 struct pci_epc *epc = ep->epc; 313 + 314 + pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem, 315 + epc->mem->page_size); 273 316 274 317 pci_epc_mem_exit(epc); 275 318 } ··· 331 298 dev_err(dev, "unable to read *num-ib-windows* property\n"); 332 299 return ret; 333 300 } 301 + if (ep->num_ib_windows > MAX_IATU_IN) { 302 + dev_err(dev, "invalid *num-ib-windows*\n"); 303 + return -EINVAL; 304 + } 334 305 335 306 ret = of_property_read_u32(np, "num-ob-windows", &ep->num_ob_windows); 336 307 if (ret < 0) { 337 308 dev_err(dev, "unable to read *num-ob-windows* property\n"); 338 309 return ret; 339 310 } 311 + if (ep->num_ob_windows > MAX_IATU_OUT) { 312 + dev_err(dev, "invalid *num-ob-windows*\n"); 313 + return -EINVAL; 314 + } 315 + 316 + ep->ib_window_map = devm_kzalloc(dev, sizeof(long) * 317 + BITS_TO_LONGS(ep->num_ib_windows), 318 + GFP_KERNEL); 319 + if (!ep->ib_window_map) 320 + return -ENOMEM; 321 + 322 + ep->ob_window_map = devm_kzalloc(dev, sizeof(long) * 323 + BITS_TO_LONGS(ep->num_ob_windows), 324 + GFP_KERNEL); 325 + if (!ep->ob_window_map) 326 + return -ENOMEM; 340 327 341 328 addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows, 342 329 GFP_KERNEL); ··· 382 329 if (ret < 0) { 383 330 dev_err(dev, "Failed to initialize address space\n"); 384 331 return ret; 332 + } 333 + 334 + ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, 335 + epc->mem->page_size); 336 + if (!ep->msi_mem) { 337 + dev_err(dev, "Failed to reserve memory for MSI\n"); 338 + return -ENOMEM; 385 339 } 386 340 387 341 ep->epc = epc;
+13 -7
drivers/pci/dwc/pcie-designware-host.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Synopsys DesignWare PCIe host controller driver 3 4 * ··· 6 5 * http://www.samsung.com 7 6 * 8 7 * Author: Jingoo Han <jg1.han@samsung.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 8 */ 14 9 15 10 #include <linux/irqdomain.h> ··· 80 83 81 84 void dw_pcie_msi_init(struct pcie_port *pp) 82 85 { 86 + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 87 + struct device *dev = pci->dev; 88 + struct page *page; 83 89 u64 msi_target; 84 90 85 - pp->msi_data = __get_free_pages(GFP_KERNEL, 0); 86 - msi_target = virt_to_phys((void *)pp->msi_data); 91 + page = alloc_page(GFP_KERNEL); 92 + pp->msi_data = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE); 93 + if (dma_mapping_error(dev, pp->msi_data)) { 94 + dev_err(dev, "failed to map MSI data\n"); 95 + __free_page(page); 96 + return; 97 + } 98 + msi_target = (u64)pp->msi_data; 87 99 88 100 /* program the msi_data */ 89 101 dw_pcie_wr_own_conf(pp, PCIE_MSI_ADDR_LO, 4, ··· 193 187 if (pp->ops->get_msi_addr) 194 188 msi_target = pp->ops->get_msi_addr(pp); 195 189 else 196 - msi_target = virt_to_phys((void *)pp->msi_data); 190 + msi_target = (u64)pp->msi_data; 197 191 198 192 msg.address_lo = (u32)(msi_target & 0xffffffff); 199 193 msg.address_hi = (u32)(msi_target >> 32 & 0xffffffff);
+1 -4
drivers/pci/dwc/pcie-designware-plat.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe RC driver for Synopsys DesignWare Core 3 4 * 4 5 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) 5 6 * 6 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 9 #include <linux/clk.h> 13 10 #include <linux/delay.h>
+2 -5
drivers/pci/dwc/pcie-designware.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Synopsys DesignWare PCIe host controller driver 3 4 * ··· 6 5 * http://www.samsung.com 7 6 * 8 7 * Author: Jingoo Han <jg1.han@samsung.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 8 */ 14 9 15 10 #include <linux/delay.h> ··· 146 149 u32 retries, val; 147 150 148 151 if (pci->ops->cpu_addr_fixup) 149 - cpu_addr = pci->ops->cpu_addr_fixup(cpu_addr); 152 + cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr); 150 153 151 154 if (pci->iatu_unroll_enabled) { 152 155 dw_pcie_prog_outbound_atu_unroll(pci, index, type, cpu_addr,
+31 -10
drivers/pci/dwc/pcie-designware.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Synopsys DesignWare PCIe host controller driver 3 4 * ··· 6 5 * http://www.samsung.com 7 6 * 8 7 * Author: Jingoo Han <jg1.han@samsung.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 8 */ 14 9 15 10 #ifndef _PCIE_DESIGNWARE_H 16 11 #define _PCIE_DESIGNWARE_H 17 12 13 + #include <linux/dma-mapping.h> 18 14 #include <linux/irq.h> 19 15 #include <linux/msi.h> 20 16 #include <linux/pci.h> ··· 98 100 99 101 #define MSI_MESSAGE_CONTROL 0x52 100 102 #define MSI_CAP_MMC_SHIFT 1 103 + #define MSI_CAP_MMC_MASK (7 << MSI_CAP_MMC_SHIFT) 101 104 #define MSI_CAP_MME_SHIFT 4 105 + #define MSI_CAP_MSI_EN_MASK 0x1 102 106 #define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) 103 107 #define MSI_MESSAGE_ADDR_L32 0x54 104 108 #define MSI_MESSAGE_ADDR_U32 0x58 109 + #define MSI_MESSAGE_DATA_32 0x58 110 + #define MSI_MESSAGE_DATA_64 0x5C 105 111 106 112 /* 107 113 * Maximum number of MSI IRQs can be 256 per controller. But keep ··· 114 112 */ 115 113 #define MAX_MSI_IRQS 32 116 114 #define MAX_MSI_CTRLS (MAX_MSI_IRQS / 32) 115 + 116 + /* Maximum number of inbound/outbound iATUs */ 117 + #define MAX_IATU_IN 256 118 + #define MAX_IATU_OUT 256 117 119 118 120 struct pcie_port; 119 121 struct dw_pcie; ··· 174 168 const struct dw_pcie_host_ops *ops; 175 169 int msi_irq; 176 170 struct irq_domain *irq_domain; 177 - unsigned long msi_data; 171 + dma_addr_t msi_data; 178 172 DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); 179 173 }; 180 174 ··· 186 180 187 181 struct dw_pcie_ep_ops { 188 182 void (*ep_init)(struct dw_pcie_ep *ep); 189 - int (*raise_irq)(struct dw_pcie_ep *ep, enum pci_epc_irq_type type, 190 - u8 interrupt_num); 183 + int (*raise_irq)(struct dw_pcie_ep *ep, u8 func_no, 184 + enum pci_epc_irq_type type, u8 interrupt_num); 191 185 }; 192 186 193 187 struct dw_pcie_ep { ··· 198 192 size_t page_size; 199 193 u8 bar_to_atu[6]; 200 194 phys_addr_t *outbound_addr; 201 - unsigned long ib_window_map; 202 - unsigned long ob_window_map; 195 + unsigned long *ib_window_map; 196 + unsigned long *ob_window_map; 203 197 u32 num_ib_windows; 204 198 u32 num_ob_windows; 199 + void __iomem *msi_mem; 200 + phys_addr_t msi_mem_phys; 205 201 }; 206 202 207 203 struct dw_pcie_ops { 208 - u64 (*cpu_addr_fixup)(u64 cpu_addr); 204 + u64 (*cpu_addr_fixup)(struct dw_pcie *pcie, u64 cpu_addr); 209 205 u32 (*read_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, 210 206 size_t size); 211 207 void (*write_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg, ··· 342 334 void dw_pcie_ep_linkup(struct dw_pcie_ep *ep); 343 335 int dw_pcie_ep_init(struct dw_pcie_ep *ep); 344 336 void dw_pcie_ep_exit(struct dw_pcie_ep *ep); 337 + int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, 338 + u8 interrupt_num); 339 + void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); 345 340 #else 346 341 static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) 347 342 { ··· 356 345 } 357 346 358 347 static inline void dw_pcie_ep_exit(struct dw_pcie_ep *ep) 348 + { 349 + } 350 + 351 + static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, 352 + u8 interrupt_num) 353 + { 354 + return 0; 355 + } 356 + 357 + static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) 359 358 { 360 359 } 361 360 #endif
+1 -4
drivers/pci/dwc/pcie-hisi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for HiSilicon SoCs 3 4 * ··· 7 6 * Authors: Zhou Wang <wangzhou1@hisilicon.com> 8 7 * Dacai Zhu <zhudacai@hisilicon.com> 9 8 * Gabriele Paoloni <gabriele.paoloni@huawei.com> 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 version 2 as 13 - * published by the Free Software Foundation. 14 9 */ 15 10 #include <linux/interrupt.h> 16 11 #include <linux/init.h>
+1 -4
drivers/pci/dwc/pcie-histb.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for HiSilicon STB SoCs 3 4 * ··· 6 5 * 7 6 * Authors: Ruqiang Ju <juruqiang@hisilicon.com> 8 7 * Jianguo Sun <sunjianguo1@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 8 */ 14 9 15 10 #include <linux/clk.h>
+1 -4
drivers/pci/dwc/pcie-kirin.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for Kirin Phone SoCs 3 4 * ··· 6 5 * http://www.huawei.com 7 6 * 8 7 * Author: Xiaowei Song <songxiaowei@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 8 */ 14 9 15 10 #include <asm/compiler.h>
+3 -11
drivers/pci/dwc/pcie-qcom.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Qualcomm PCIe root complex driver 3 4 * ··· 6 5 * Copyright 2015 Linaro Limited. 7 6 * 8 7 * Author: Stanimir Varbanov <svarbanov@mm-sol.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 and 12 - * only version 2 as published by the Free Software Foundation. 13 - * 14 - * This program is distributed in the hope that it will be useful, 15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - * GNU General Public License for more details. 18 8 */ 19 9 20 10 #include <linux/clk.h> ··· 163 171 union qcom_pcie_resources res; 164 172 struct phy *phy; 165 173 struct gpio_desc *reset; 166 - struct qcom_pcie_ops *ops; 174 + const struct qcom_pcie_ops *ops; 167 175 }; 168 176 169 177 #define to_qcom_pcie(x) dev_get_drvdata((x)->dev) ··· 1226 1234 1227 1235 pcie->pci = pci; 1228 1236 1229 - pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev); 1237 + pcie->ops = of_device_get_match_data(dev); 1230 1238 1231 1239 pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); 1232 1240 if (IS_ERR(pcie->reset))
+1 -4
drivers/pci/dwc/pcie-spear13xx.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe host controller driver for ST Microelectronics SPEAr13xx SoCs 3 4 * ··· 7 6 * Copyright (C) 2010-2014 ST Microelectronics 8 7 * Pratyush Anand <pratyush.anand@gmail.com> 9 8 * Mohit Kumar <mohit.kumar.dhaka@gmail.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 9 */ 15 10 16 11 #include <linux/clk.h>
+1 -12
drivers/pci/ecam.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 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 6 #include <linux/device.h>
+1
drivers/pci/endpoint/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI Endpoint Support 3 4 #
+1
drivers/pci/endpoint/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # Makefile for PCI Endpoint Support 3 4 #
+1
drivers/pci/endpoint/functions/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI Endpoint Functions 3 4 #
+1
drivers/pci/endpoint/functions/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # Makefile for PCI Endpoint Functions 3 4 #
+24 -30
drivers/pci/endpoint/functions/pci-epf-test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /** 2 3 * Test driver to test endpoint functionality 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 9 #include <linux/crc32.h> ··· 93 104 goto err; 94 105 } 95 106 96 - ret = pci_epc_map_addr(epc, src_phys_addr, reg->src_addr, reg->size); 107 + ret = pci_epc_map_addr(epc, epf->func_no, src_phys_addr, reg->src_addr, 108 + reg->size); 97 109 if (ret) { 98 110 dev_err(dev, "failed to map source address\n"); 99 111 reg->status = STATUS_SRC_ADDR_INVALID; ··· 109 119 goto err_src_map_addr; 110 120 } 111 121 112 - ret = pci_epc_map_addr(epc, dst_phys_addr, reg->dst_addr, reg->size); 122 + ret = pci_epc_map_addr(epc, epf->func_no, dst_phys_addr, reg->dst_addr, 123 + reg->size); 113 124 if (ret) { 114 125 dev_err(dev, "failed to map destination address\n"); 115 126 reg->status = STATUS_DST_ADDR_INVALID; ··· 119 128 120 129 memcpy(dst_addr, src_addr, reg->size); 121 130 122 - pci_epc_unmap_addr(epc, dst_phys_addr); 131 + pci_epc_unmap_addr(epc, epf->func_no, dst_phys_addr); 123 132 124 133 err_dst_addr: 125 134 pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size); 126 135 127 136 err_src_map_addr: 128 - pci_epc_unmap_addr(epc, src_phys_addr); 137 + pci_epc_unmap_addr(epc, epf->func_no, src_phys_addr); 129 138 130 139 err_src_addr: 131 140 pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size); ··· 155 164 goto err; 156 165 } 157 166 158 - ret = pci_epc_map_addr(epc, phys_addr, reg->src_addr, reg->size); 167 + ret = pci_epc_map_addr(epc, epf->func_no, phys_addr, reg->src_addr, 168 + reg->size); 159 169 if (ret) { 160 170 dev_err(dev, "failed to map address\n"); 161 171 reg->status = STATUS_SRC_ADDR_INVALID; ··· 178 186 kfree(buf); 179 187 180 188 err_map_addr: 181 - pci_epc_unmap_addr(epc, phys_addr); 189 + pci_epc_unmap_addr(epc, epf->func_no, phys_addr); 182 190 183 191 err_addr: 184 192 pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size); ··· 207 215 goto err; 208 216 } 209 217 210 - ret = pci_epc_map_addr(epc, phys_addr, reg->dst_addr, reg->size); 218 + ret = pci_epc_map_addr(epc, epf->func_no, phys_addr, reg->dst_addr, 219 + reg->size); 211 220 if (ret) { 212 221 dev_err(dev, "failed to map address\n"); 213 222 reg->status = STATUS_DST_ADDR_INVALID; ··· 235 242 kfree(buf); 236 243 237 244 err_map_addr: 238 - pci_epc_unmap_addr(epc, phys_addr); 245 + pci_epc_unmap_addr(epc, epf->func_no, phys_addr); 239 246 240 247 err_addr: 241 248 pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size); ··· 253 260 struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; 254 261 255 262 reg->status |= STATUS_IRQ_RAISED; 256 - msi_count = pci_epc_get_msi(epc); 263 + msi_count = pci_epc_get_msi(epc, epf->func_no); 257 264 if (irq > msi_count || msi_count <= 0) 258 - pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); 265 + pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_LEGACY, 0); 259 266 else 260 - pci_epc_raise_irq(epc, PCI_EPC_IRQ_MSI, irq); 267 + pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_MSI, irq); 261 268 } 262 269 263 270 static void pci_epf_test_cmd_handler(struct work_struct *work) ··· 284 291 285 292 if (command & COMMAND_RAISE_LEGACY_IRQ) { 286 293 reg->status = STATUS_IRQ_RAISED; 287 - pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); 294 + pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_LEGACY, 0); 288 295 goto reset_handler; 289 296 } 290 297 ··· 319 326 } 320 327 321 328 if (command & COMMAND_RAISE_MSI_IRQ) { 322 - msi_count = pci_epc_get_msi(epc); 329 + msi_count = pci_epc_get_msi(epc, epf->func_no); 323 330 if (irq > msi_count || msi_count <= 0) 324 331 goto reset_handler; 325 332 reg->status = STATUS_IRQ_RAISED; 326 - pci_epc_raise_irq(epc, PCI_EPC_IRQ_MSI, irq); 333 + pci_epc_raise_irq(epc, epf->func_no, PCI_EPC_IRQ_MSI, irq); 327 334 goto reset_handler; 328 335 } 329 336 ··· 351 358 for (bar = BAR_0; bar <= BAR_5; bar++) { 352 359 if (epf_test->reg[bar]) { 353 360 pci_epf_free_space(epf, epf_test->reg[bar], bar); 354 - pci_epc_clear_bar(epc, bar); 361 + pci_epc_clear_bar(epc, epf->func_no, bar); 355 362 } 356 363 } 357 364 } ··· 373 380 374 381 for (bar = BAR_0; bar <= BAR_5; bar++) { 375 382 epf_bar = &epf->bar[bar]; 376 - ret = pci_epc_set_bar(epc, bar, epf_bar->phys_addr, 383 + ret = pci_epc_set_bar(epc, epf->func_no, bar, 384 + epf_bar->phys_addr, 377 385 epf_bar->size, flags); 378 386 if (ret) { 379 387 pci_epf_free_space(epf, epf_test->reg[bar], bar); ··· 427 433 if (WARN_ON_ONCE(!epc)) 428 434 return -EINVAL; 429 435 430 - ret = pci_epc_write_header(epc, header); 436 + ret = pci_epc_write_header(epc, epf->func_no, header); 431 437 if (ret) { 432 438 dev_err(dev, "configuration header write failed\n"); 433 439 return ret; ··· 441 447 if (ret) 442 448 return ret; 443 449 444 - ret = pci_epc_set_msi(epc, epf->msi_interrupts); 450 + ret = pci_epc_set_msi(epc, epf->func_no, epf->msi_interrupts); 445 451 if (ret) 446 452 return ret; 447 453
+55 -23
drivers/pci/endpoint/pci-ep-cfs.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /** 2 3 * configfs to configure the PCI endpoint 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 9 #include <linux/module.h> 10 + #include <linux/idr.h> 21 11 #include <linux/slab.h> 22 12 23 13 #include <linux/pci-epc.h> 24 14 #include <linux/pci-epf.h> 25 15 #include <linux/pci-ep-cfs.h> 26 16 17 + static DEFINE_IDR(functions_idr); 18 + static DEFINE_MUTEX(functions_mutex); 27 19 static struct config_group *functions_group; 28 20 static struct config_group *controllers_group; 29 21 30 22 struct pci_epf_group { 31 23 struct config_group group; 32 24 struct pci_epf *epf; 25 + int index; 33 26 }; 34 27 35 28 struct pci_epc_group { ··· 90 97 { 91 98 int ret; 92 99 u32 func_no = 0; 93 - struct pci_epc *epc; 94 - struct pci_epf *epf; 95 100 struct pci_epf_group *epf_group = to_pci_epf_group(epf_item); 96 101 struct pci_epc_group *epc_group = to_pci_epc_group(epc_item); 102 + struct pci_epc *epc = epc_group->epc; 103 + struct pci_epf *epf = epf_group->epf; 97 104 98 - epc = epc_group->epc; 99 - epf = epf_group->epf; 105 + func_no = find_first_zero_bit(&epc_group->function_num_map, 106 + BITS_PER_LONG); 107 + if (func_no >= BITS_PER_LONG) 108 + return -EINVAL; 109 + 110 + set_bit(func_no, &epc_group->function_num_map); 111 + epf->func_no = func_no; 112 + 100 113 ret = pci_epc_add_epf(epc, epf); 101 114 if (ret) 102 115 goto err_add_epf; 103 - 104 - func_no = find_first_zero_bit(&epc_group->function_num_map, 105 - sizeof(epc_group->function_num_map)); 106 - set_bit(func_no, &epc_group->function_num_map); 107 - epf->func_no = func_no; 108 116 109 117 ret = pci_epf_bind(epf); 110 118 if (ret) ··· 347 353 { 348 354 struct pci_epf_group *epf_group = to_pci_epf_group(item); 349 355 356 + mutex_lock(&functions_mutex); 357 + idr_remove(&functions_idr, epf_group->index); 358 + mutex_unlock(&functions_mutex); 350 359 pci_epf_destroy(epf_group->epf); 351 360 kfree(epf_group); 352 361 } ··· 369 372 { 370 373 struct pci_epf_group *epf_group; 371 374 struct pci_epf *epf; 375 + char *epf_name; 376 + int index, err; 372 377 373 378 epf_group = kzalloc(sizeof(*epf_group), GFP_KERNEL); 374 379 if (!epf_group) 375 380 return ERR_PTR(-ENOMEM); 376 381 382 + mutex_lock(&functions_mutex); 383 + index = idr_alloc(&functions_idr, epf_group, 0, 0, GFP_KERNEL); 384 + mutex_unlock(&functions_mutex); 385 + if (index < 0) { 386 + err = index; 387 + goto free_group; 388 + } 389 + 390 + epf_group->index = index; 391 + 377 392 config_group_init_type_name(&epf_group->group, name, &pci_epf_type); 378 393 379 - epf = pci_epf_create(group->cg_item.ci_name); 394 + epf_name = kasprintf(GFP_KERNEL, "%s.%d", 395 + group->cg_item.ci_name, epf_group->index); 396 + if (!epf_name) { 397 + err = -ENOMEM; 398 + goto remove_idr; 399 + } 400 + 401 + epf = pci_epf_create(epf_name); 380 402 if (IS_ERR(epf)) { 381 403 pr_err("failed to create endpoint function device\n"); 382 - return ERR_PTR(-EINVAL); 404 + err = -EINVAL; 405 + goto free_name; 383 406 } 384 407 385 408 epf_group->epf = epf; 386 409 410 + kfree(epf_name); 411 + 387 412 return &epf_group->group; 413 + 414 + free_name: 415 + kfree(epf_name); 416 + 417 + remove_idr: 418 + mutex_lock(&functions_mutex); 419 + idr_remove(&functions_idr, epf_group->index); 420 + mutex_unlock(&functions_mutex); 421 + 422 + free_group: 423 + kfree(epf_group); 424 + 425 + return ERR_PTR(err); 388 426 } 389 427 390 428 static void pci_epf_drop(struct config_group *group, struct config_item *item)
+37 -48
drivers/pci/endpoint/pci-epc-core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /** 2 3 * PCI Endpoint *Controller* (EPC) library 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 9 #include <linux/device.h> 21 - #include <linux/dma-mapping.h> 22 10 #include <linux/slab.h> 23 11 #include <linux/module.h> 24 12 #include <linux/of_device.h> ··· 130 142 /** 131 143 * pci_epc_raise_irq() - interrupt the host system 132 144 * @epc: the EPC device which has to interrupt the host 145 + * @func_no: the endpoint function number in the EPC device 133 146 * @type: specify the type of interrupt; legacy or MSI 134 147 * @interrupt_num: the MSI interrupt number 135 148 * 136 149 * Invoke to raise an MSI or legacy interrupt 137 150 */ 138 - int pci_epc_raise_irq(struct pci_epc *epc, enum pci_epc_irq_type type, 139 - u8 interrupt_num) 151 + int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, 152 + enum pci_epc_irq_type type, u8 interrupt_num) 140 153 { 141 154 int ret; 142 155 unsigned long flags; 143 156 144 - if (IS_ERR(epc)) 157 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 145 158 return -EINVAL; 146 159 147 160 if (!epc->ops->raise_irq) 148 161 return 0; 149 162 150 163 spin_lock_irqsave(&epc->lock, flags); 151 - ret = epc->ops->raise_irq(epc, type, interrupt_num); 164 + ret = epc->ops->raise_irq(epc, func_no, type, interrupt_num); 152 165 spin_unlock_irqrestore(&epc->lock, flags); 153 166 154 167 return ret; ··· 159 170 /** 160 171 * pci_epc_get_msi() - get the number of MSI interrupt numbers allocated 161 172 * @epc: the EPC device to which MSI interrupts was requested 173 + * @func_no: the endpoint function number in the EPC device 162 174 * 163 175 * Invoke to get the number of MSI interrupts allocated by the RC 164 176 */ 165 - int pci_epc_get_msi(struct pci_epc *epc) 177 + int pci_epc_get_msi(struct pci_epc *epc, u8 func_no) 166 178 { 167 179 int interrupt; 168 180 unsigned long flags; 169 181 170 - if (IS_ERR(epc)) 182 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 171 183 return 0; 172 184 173 185 if (!epc->ops->get_msi) 174 186 return 0; 175 187 176 188 spin_lock_irqsave(&epc->lock, flags); 177 - interrupt = epc->ops->get_msi(epc); 189 + interrupt = epc->ops->get_msi(epc, func_no); 178 190 spin_unlock_irqrestore(&epc->lock, flags); 179 191 180 192 if (interrupt < 0) ··· 190 200 /** 191 201 * pci_epc_set_msi() - set the number of MSI interrupt numbers required 192 202 * @epc: the EPC device on which MSI has to be configured 203 + * @func_no: the endpoint function number in the EPC device 193 204 * @interrupts: number of MSI interrupts required by the EPF 194 205 * 195 206 * Invoke to set the required number of MSI interrupts. 196 207 */ 197 - int pci_epc_set_msi(struct pci_epc *epc, u8 interrupts) 208 + int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) 198 209 { 199 210 int ret; 200 211 u8 encode_int; 201 212 unsigned long flags; 202 213 203 - if (IS_ERR(epc)) 214 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 204 215 return -EINVAL; 205 216 206 217 if (!epc->ops->set_msi) ··· 210 219 encode_int = order_base_2(interrupts); 211 220 212 221 spin_lock_irqsave(&epc->lock, flags); 213 - ret = epc->ops->set_msi(epc, encode_int); 222 + ret = epc->ops->set_msi(epc, func_no, encode_int); 214 223 spin_unlock_irqrestore(&epc->lock, flags); 215 224 216 225 return ret; ··· 220 229 /** 221 230 * pci_epc_unmap_addr() - unmap CPU address from PCI address 222 231 * @epc: the EPC device on which address is allocated 232 + * @func_no: the endpoint function number in the EPC device 223 233 * @phys_addr: physical address of the local system 224 234 * 225 235 * Invoke to unmap the CPU address from PCI address. 226 236 */ 227 - void pci_epc_unmap_addr(struct pci_epc *epc, phys_addr_t phys_addr) 237 + void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, 238 + phys_addr_t phys_addr) 228 239 { 229 240 unsigned long flags; 230 241 231 - if (IS_ERR(epc)) 242 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 232 243 return; 233 244 234 245 if (!epc->ops->unmap_addr) 235 246 return; 236 247 237 248 spin_lock_irqsave(&epc->lock, flags); 238 - epc->ops->unmap_addr(epc, phys_addr); 249 + epc->ops->unmap_addr(epc, func_no, phys_addr); 239 250 spin_unlock_irqrestore(&epc->lock, flags); 240 251 } 241 252 EXPORT_SYMBOL_GPL(pci_epc_unmap_addr); ··· 245 252 /** 246 253 * pci_epc_map_addr() - map CPU address to PCI address 247 254 * @epc: the EPC device on which address is allocated 255 + * @func_no: the endpoint function number in the EPC device 248 256 * @phys_addr: physical address of the local system 249 257 * @pci_addr: PCI address to which the physical address should be mapped 250 258 * @size: the size of the allocation 251 259 * 252 260 * Invoke to map CPU address with PCI address. 253 261 */ 254 - int pci_epc_map_addr(struct pci_epc *epc, phys_addr_t phys_addr, 255 - u64 pci_addr, size_t size) 262 + int pci_epc_map_addr(struct pci_epc *epc, u8 func_no, 263 + phys_addr_t phys_addr, u64 pci_addr, size_t size) 256 264 { 257 265 int ret; 258 266 unsigned long flags; 259 267 260 - if (IS_ERR(epc)) 268 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 261 269 return -EINVAL; 262 270 263 271 if (!epc->ops->map_addr) 264 272 return 0; 265 273 266 274 spin_lock_irqsave(&epc->lock, flags); 267 - ret = epc->ops->map_addr(epc, phys_addr, pci_addr, size); 275 + ret = epc->ops->map_addr(epc, func_no, phys_addr, pci_addr, size); 268 276 spin_unlock_irqrestore(&epc->lock, flags); 269 277 270 278 return ret; ··· 275 281 /** 276 282 * pci_epc_clear_bar() - reset the BAR 277 283 * @epc: the EPC device for which the BAR has to be cleared 284 + * @func_no: the endpoint function number in the EPC device 278 285 * @bar: the BAR number that has to be reset 279 286 * 280 287 * Invoke to reset the BAR of the endpoint device. 281 288 */ 282 - void pci_epc_clear_bar(struct pci_epc *epc, int bar) 289 + void pci_epc_clear_bar(struct pci_epc *epc, u8 func_no, int bar) 283 290 { 284 291 unsigned long flags; 285 292 286 - if (IS_ERR(epc)) 293 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 287 294 return; 288 295 289 296 if (!epc->ops->clear_bar) 290 297 return; 291 298 292 299 spin_lock_irqsave(&epc->lock, flags); 293 - epc->ops->clear_bar(epc, bar); 300 + epc->ops->clear_bar(epc, func_no, bar); 294 301 spin_unlock_irqrestore(&epc->lock, flags); 295 302 } 296 303 EXPORT_SYMBOL_GPL(pci_epc_clear_bar); ··· 299 304 /** 300 305 * pci_epc_set_bar() - configure BAR in order for host to assign PCI addr space 301 306 * @epc: the EPC device on which BAR has to be configured 307 + * @func_no: the endpoint function number in the EPC device 302 308 * @bar: the BAR number that has to be configured 303 309 * @size: the size of the addr space 304 310 * @flags: specify memory allocation/io allocation/32bit address/64 bit address 305 311 * 306 312 * Invoke to configure the BAR of the endpoint device. 307 313 */ 308 - int pci_epc_set_bar(struct pci_epc *epc, enum pci_barno bar, 314 + int pci_epc_set_bar(struct pci_epc *epc, u8 func_no, enum pci_barno bar, 309 315 dma_addr_t bar_phys, size_t size, int flags) 310 316 { 311 317 int ret; 312 318 unsigned long irq_flags; 313 319 314 - if (IS_ERR(epc)) 320 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 315 321 return -EINVAL; 316 322 317 323 if (!epc->ops->set_bar) 318 324 return 0; 319 325 320 326 spin_lock_irqsave(&epc->lock, irq_flags); 321 - ret = epc->ops->set_bar(epc, bar, bar_phys, size, flags); 327 + ret = epc->ops->set_bar(epc, func_no, bar, bar_phys, size, flags); 322 328 spin_unlock_irqrestore(&epc->lock, irq_flags); 323 329 324 330 return ret; ··· 329 333 /** 330 334 * pci_epc_write_header() - write standard configuration header 331 335 * @epc: the EPC device to which the configuration header should be written 336 + * @func_no: the endpoint function number in the EPC device 332 337 * @header: standard configuration header fields 333 338 * 334 339 * Invoke to write the configuration header to the endpoint controller. Every ··· 337 340 * configuration header would be written. The callback function should write 338 341 * the header fields to this dedicated location. 339 342 */ 340 - int pci_epc_write_header(struct pci_epc *epc, struct pci_epf_header *header) 343 + int pci_epc_write_header(struct pci_epc *epc, u8 func_no, 344 + struct pci_epf_header *header) 341 345 { 342 346 int ret; 343 347 unsigned long flags; 344 348 345 - if (IS_ERR(epc)) 349 + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) 346 350 return -EINVAL; 347 351 348 352 if (!epc->ops->write_header) 349 353 return 0; 350 354 351 355 spin_lock_irqsave(&epc->lock, flags); 352 - ret = epc->ops->write_header(epc, header); 356 + ret = epc->ops->write_header(epc, func_no, header); 353 357 spin_unlock_irqrestore(&epc->lock, flags); 354 358 355 359 return ret; ··· 369 371 int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) 370 372 { 371 373 unsigned long flags; 372 - struct device *dev = epc->dev.parent; 373 374 374 375 if (epf->epc) 375 376 return -EBUSY; ··· 380 383 return -EINVAL; 381 384 382 385 epf->epc = epc; 383 - if (dev->of_node) { 384 - of_dma_configure(&epf->dev, dev->of_node); 385 - } else { 386 - dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); 387 - epf->dev.dma_mask = epc->dev.dma_mask; 388 - } 389 386 390 387 spin_lock_irqsave(&epc->lock, flags); 391 388 list_add_tail(&epf->list, &epc->pci_epf); ··· 494 503 INIT_LIST_HEAD(&epc->pci_epf); 495 504 496 505 device_initialize(&epc->dev); 497 - dma_set_coherent_mask(&epc->dev, dev->coherent_dma_mask); 498 506 epc->dev.class = pci_epc_class; 499 - epc->dev.dma_mask = dev->dma_mask; 500 507 epc->dev.parent = dev; 501 508 epc->ops = ops; 502 509
+1 -12
drivers/pci/endpoint/pci-epc-mem.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /** 2 3 * PCI Endpoint *Controller* Address Space Management 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 9 #include <linux/io.h>
+3 -14
drivers/pci/endpoint/pci-epf-core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /** 2 3 * PCI Endpoint *Function* (EPF) library 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 9 #include <linux/device.h> ··· 88 99 */ 89 100 void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar) 90 101 { 91 - struct device *dev = &epf->dev; 102 + struct device *dev = epf->epc->dev.parent; 92 103 93 104 if (!addr) 94 105 return; ··· 111 122 void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar) 112 123 { 113 124 void *space; 114 - struct device *dev = &epf->dev; 125 + struct device *dev = epf->epc->dev.parent; 115 126 dma_addr_t phys_addr; 116 127 117 128 if (size < 128)
+1
drivers/pci/host-bridge.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * host bridge related code 3 4 */
+2
drivers/pci/host/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 1 3 menu "PCI host controller drivers" 2 4 depends on PCI 3 5
+2
drivers/pci/host/Makefile
··· 34 34 # ARM64 and use internal ifdefs to only build the pieces we need 35 35 # depending on whether ACPI, the DT driver, or both are enabled. 36 36 37 + ifdef CONFIG_PCI 37 38 obj-$(CONFIG_ARM64) += pci-thunder-ecam.o 38 39 obj-$(CONFIG_ARM64) += pci-thunder-pem.o 39 40 obj-$(CONFIG_ARM64) += pci-xgene.o 41 + endif
+1 -4
drivers/pci/host/pci-aardvark.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Driver for the Aardvark PCIe controller, used on Marvell Armada 3 4 * 3700. ··· 6 5 * Copyright (C) 2016 Marvell 7 6 * 8 7 * Author: Hezi Shahmoon <hezi.shahmoon@marvell.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 8 */ 14 9 15 10 #include <linux/delay.h>
+6 -81
drivers/pci/host/pci-host-common.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Generic PCI host driver common code 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. 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 4 * 16 5 * Copyright (C) 2014 ARM Limited 17 6 * ··· 12 23 #include <linux/of_pci.h> 13 24 #include <linux/pci-ecam.h> 14 25 #include <linux/platform_device.h> 15 - 16 - static int gen_pci_parse_request_of_pci_ranges(struct device *dev, 17 - struct list_head *resources, struct resource **bus_range) 18 - { 19 - int err, res_valid = 0; 20 - struct device_node *np = dev->of_node; 21 - resource_size_t iobase; 22 - struct resource_entry *win, *tmp; 23 - 24 - err = of_pci_get_host_bridge_resources(np, 0, 0xff, resources, &iobase); 25 - if (err) 26 - return err; 27 - 28 - err = devm_request_pci_bus_resources(dev, resources); 29 - if (err) 30 - return err; 31 - 32 - resource_list_for_each_entry_safe(win, tmp, resources) { 33 - struct resource *res = win->res; 34 - 35 - switch (resource_type(res)) { 36 - case IORESOURCE_IO: 37 - err = pci_remap_iospace(res, iobase); 38 - if (err) { 39 - dev_warn(dev, "error %d: failed to map resource %pR\n", 40 - err, res); 41 - resource_list_destroy_entry(win); 42 - } 43 - break; 44 - case IORESOURCE_MEM: 45 - res_valid |= !(res->flags & IORESOURCE_PREFETCH); 46 - break; 47 - case IORESOURCE_BUS: 48 - *bus_range = res; 49 - break; 50 - } 51 - } 52 - 53 - if (res_valid) 54 - return 0; 55 - 56 - dev_err(dev, "non-prefetchable memory resource required\n"); 57 - return -EINVAL; 58 - } 59 26 60 27 static void gen_pci_unmap_cfg(void *ptr) 61 28 { ··· 27 82 struct pci_config_window *cfg; 28 83 29 84 /* Parse our PCI ranges and request their resources */ 30 - err = gen_pci_parse_request_of_pci_ranges(dev, resources, &bus_range); 85 + err = pci_parse_request_of_pci_ranges(dev, resources, &bus_range); 31 86 if (err) 32 - goto err_out; 87 + return ERR_PTR(err); 33 88 34 89 err = of_address_to_resource(dev->of_node, 0, &cfgres); 35 90 if (err) { ··· 61 116 const char *type; 62 117 struct device *dev = &pdev->dev; 63 118 struct device_node *np = dev->of_node; 64 - struct pci_bus *bus, *child; 65 119 struct pci_host_bridge *bridge; 66 120 struct pci_config_window *cfg; 67 121 struct list_head resources; ··· 79 135 of_pci_check_probe_only(); 80 136 81 137 /* Parse and map our Configuration Space windows */ 82 - INIT_LIST_HEAD(&resources); 83 138 cfg = gen_pci_init(dev, &resources, ops); 84 139 if (IS_ERR(cfg)) 85 140 return PTR_ERR(cfg); 86 141 87 142 /* Do not reassign resources if probe only */ 88 143 if (!pci_has_flag(PCI_PROBE_ONLY)) 89 - pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); 144 + pci_add_flags(PCI_REASSIGN_ALL_BUS); 90 145 91 146 list_splice_init(&resources, &bridge->windows); 92 147 bridge->dev.parent = dev; ··· 95 152 bridge->map_irq = of_irq_parse_and_map_pci; 96 153 bridge->swizzle_irq = pci_common_swizzle; 97 154 98 - ret = pci_scan_root_bus_bridge(bridge); 155 + ret = pci_host_probe(bridge); 99 156 if (ret < 0) { 100 - dev_err(dev, "Scanning root bridge failed"); 157 + pci_free_resource_list(&resources); 101 158 return ret; 102 159 } 103 160 104 - bus = bridge->bus; 105 - 106 - /* 107 - * We insert PCI resources into the iomem_resource and 108 - * ioport_resource trees in either pci_bus_claim_resources() 109 - * or pci_bus_assign_resources(). 110 - */ 111 - if (pci_has_flag(PCI_PROBE_ONLY)) { 112 - pci_bus_claim_resources(bus); 113 - } else { 114 - pci_bus_size_bridges(bus); 115 - pci_bus_assign_resources(bus); 116 - 117 - list_for_each_entry(child, &bus->children, node) 118 - pcie_bus_configure_settings(child); 119 - } 120 - 121 - pci_bus_add_devices(bus); 122 161 return 0; 123 162 }
+1 -12
drivers/pci/host/pci-host-generic.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Simple, generic PCI host controller driver targetting firmware-initialised 3 4 * systems and virtual machines (e.g. the PCI emulation provided by kvmtool). 4 - * 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 5 * 17 6 * Copyright (C) 2014 ARM Limited 18 7 *
+1 -11
drivers/pci/host/pci-hyperv.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (c) Microsoft Corporation. 3 4 * ··· 35 34 * read and write handlers for config space must be aware of this mechanism. 36 35 * Similarly, device setup and teardown involves messages sent to and from 37 36 * the PCI back-end driver in Hyper-V. 38 - * 39 - * This program is free software; you can redistribute it and/or modify it 40 - * under the terms of the GNU General Public License version 2 as published 41 - * by the Free Software Foundation. 42 - * 43 - * This program is distributed in the hope that it will be useful, but 44 - * WITHOUT ANY WARRANTY; without even the implied warranty of 45 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 46 - * NON INFRINGEMENT. See the GNU General Public License for more 47 - * details. 48 - * 49 37 */ 50 38 51 39 #include <linux/kernel.h>
+1 -4
drivers/pci/host/pci-mvebu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe driver for Marvell Armada 370 and Armada XP SoCs 3 4 * 4 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 8 #include <linux/kernel.h>
+1 -4
drivers/pci/host/pci-rcar-gen2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * pci-rcar-gen2: internal PCI bus support 3 4 * ··· 6 5 * Copyright (C) 2013 Cogent Embedded, Inc. 7 6 * 8 7 * Author: Valentine Barshak <valentine.barshak@cogentembedded.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 8 */ 14 9 15 10 #include <linux/delay.h>
+34 -137
drivers/pci/host/pci-tegra.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCIe host controller driver for Tegra SoCs 3 4 * ··· 11 10 * Bits taken from arch/arm/mach-dove/pcie.c 12 11 * 13 12 * Author: Thierry Reding <treding@nvidia.com> 14 - * 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 18 - * (at your option) any later version. 19 - * 20 - * This program is distributed in the hope that it will be useful, but WITHOUT 21 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 23 - * more details. 24 - * 25 - * You should have received a copy of the GNU General Public License along 26 - * with this program; if not, write to the Free Software Foundation, Inc., 27 - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 28 13 */ 29 14 30 15 #include <linux/clk.h> ··· 256 269 257 270 void __iomem *pads; 258 271 void __iomem *afi; 272 + void __iomem *cfg; 259 273 int irq; 260 274 261 - struct list_head buses; 262 - struct resource *cs; 263 - 275 + struct resource cs; 264 276 struct resource io; 265 277 struct resource pio; 266 278 struct resource mem; ··· 308 322 }; 309 323 310 324 struct tegra_pcie_bus { 311 - struct vm_struct *area; 312 325 struct list_head list; 313 326 unsigned int nr; 314 327 }; ··· 347 362 * 348 363 * Mapping the whole extended configuration space would require 256 MiB of 349 364 * virtual address space, only a small part of which will actually be used. 350 - * To work around this, a 1 MiB of virtual addresses are allocated per bus 351 - * when the bus is first accessed. When the physical range is mapped, the 352 - * the bus number bits are hidden so that the extended register number bits 353 - * appear as bits [19:16]. Therefore the virtual mapping looks like this: 354 365 * 355 - * [19:16] extended register number 356 - * [15:11] device number 357 - * [10: 8] function number 358 - * [ 7: 0] register number 359 - * 360 - * This is achieved by stitching together 16 chunks of 64 KiB of physical 361 - * address space via the MMU. 366 + * To work around this, a 4 KiB region is used to generate the required 367 + * configuration transaction with relevant B:D:F and register offset values. 368 + * This is achieved by dynamically programming base address and size of 369 + * AFI_AXI_BAR used for end point config space mapping to make sure that the 370 + * address (access to which generates correct config transaction) falls in 371 + * this 4 KiB region. 362 372 */ 363 - static unsigned long tegra_pcie_conf_offset(unsigned int devfn, int where) 373 + static unsigned int tegra_pcie_conf_offset(u8 bus, unsigned int devfn, 374 + unsigned int where) 364 375 { 365 - return ((where & 0xf00) << 8) | (PCI_SLOT(devfn) << 11) | 366 - (PCI_FUNC(devfn) << 8) | (where & 0xfc); 367 - } 368 - 369 - static struct tegra_pcie_bus *tegra_pcie_bus_alloc(struct tegra_pcie *pcie, 370 - unsigned int busnr) 371 - { 372 - struct device *dev = pcie->dev; 373 - pgprot_t prot = pgprot_noncached(PAGE_KERNEL); 374 - phys_addr_t cs = pcie->cs->start; 375 - struct tegra_pcie_bus *bus; 376 - unsigned int i; 377 - int err; 378 - 379 - bus = kzalloc(sizeof(*bus), GFP_KERNEL); 380 - if (!bus) 381 - return ERR_PTR(-ENOMEM); 382 - 383 - INIT_LIST_HEAD(&bus->list); 384 - bus->nr = busnr; 385 - 386 - /* allocate 1 MiB of virtual addresses */ 387 - bus->area = get_vm_area(SZ_1M, VM_IOREMAP); 388 - if (!bus->area) { 389 - err = -ENOMEM; 390 - goto free; 391 - } 392 - 393 - /* map each of the 16 chunks of 64 KiB each */ 394 - for (i = 0; i < 16; i++) { 395 - unsigned long virt = (unsigned long)bus->area->addr + 396 - i * SZ_64K; 397 - phys_addr_t phys = cs + i * SZ_16M + busnr * SZ_64K; 398 - 399 - err = ioremap_page_range(virt, virt + SZ_64K, phys, prot); 400 - if (err < 0) { 401 - dev_err(dev, "ioremap_page_range() failed: %d\n", err); 402 - goto unmap; 403 - } 404 - } 405 - 406 - return bus; 407 - 408 - unmap: 409 - vunmap(bus->area->addr); 410 - free: 411 - kfree(bus); 412 - return ERR_PTR(err); 413 - } 414 - 415 - static int tegra_pcie_add_bus(struct pci_bus *bus) 416 - { 417 - struct pci_host_bridge *host = pci_find_host_bridge(bus); 418 - struct tegra_pcie *pcie = pci_host_bridge_priv(host); 419 - struct tegra_pcie_bus *b; 420 - 421 - b = tegra_pcie_bus_alloc(pcie, bus->number); 422 - if (IS_ERR(b)) 423 - return PTR_ERR(b); 424 - 425 - list_add_tail(&b->list, &pcie->buses); 426 - 427 - return 0; 428 - } 429 - 430 - static void tegra_pcie_remove_bus(struct pci_bus *child) 431 - { 432 - struct pci_host_bridge *host = pci_find_host_bridge(child); 433 - struct tegra_pcie *pcie = pci_host_bridge_priv(host); 434 - struct tegra_pcie_bus *bus, *tmp; 435 - 436 - list_for_each_entry_safe(bus, tmp, &pcie->buses, list) { 437 - if (bus->nr == child->number) { 438 - vunmap(bus->area->addr); 439 - list_del(&bus->list); 440 - kfree(bus); 441 - break; 442 - } 443 - } 376 + return ((where & 0xf00) << 16) | (bus << 16) | (PCI_SLOT(devfn) << 11) | 377 + (PCI_FUNC(devfn) << 8) | (where & 0xff); 444 378 } 445 379 446 380 static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus, 447 381 unsigned int devfn, 448 382 int where) 449 383 { 450 - struct pci_host_bridge *host = pci_find_host_bridge(bus); 451 - struct tegra_pcie *pcie = pci_host_bridge_priv(host); 452 - struct device *dev = pcie->dev; 384 + struct tegra_pcie *pcie = bus->sysdata; 453 385 void __iomem *addr = NULL; 454 386 455 387 if (bus->number == 0) { ··· 380 478 } 381 479 } 382 480 } else { 383 - struct tegra_pcie_bus *b; 481 + unsigned int offset; 482 + u32 base; 384 483 385 - list_for_each_entry(b, &pcie->buses, list) 386 - if (b->nr == bus->number) 387 - addr = (void __iomem *)b->area->addr; 484 + offset = tegra_pcie_conf_offset(bus->number, devfn, where); 388 485 389 - if (!addr) { 390 - dev_err(dev, "failed to map cfg. space for bus %u\n", 391 - bus->number); 392 - return NULL; 393 - } 486 + /* move 4 KiB window to offset within the FPCI region */ 487 + base = 0xfe100000 + ((offset & ~(SZ_4K - 1)) >> 8); 488 + afi_writel(pcie, base, AFI_FPCI_BAR0); 394 489 395 - addr += tegra_pcie_conf_offset(devfn, where); 490 + /* move to correct offset within the 4 KiB page */ 491 + addr = pcie->cfg + (offset & (SZ_4K - 1)); 396 492 } 397 493 398 494 return addr; ··· 417 517 } 418 518 419 519 static struct pci_ops tegra_pcie_ops = { 420 - .add_bus = tegra_pcie_add_bus, 421 - .remove_bus = tegra_pcie_remove_bus, 422 520 .map_bus = tegra_pcie_map_bus, 423 521 .read = tegra_pcie_config_read, 424 522 .write = tegra_pcie_config_write, ··· 559 661 560 662 static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) 561 663 { 562 - struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus); 563 - struct tegra_pcie *pcie = pci_host_bridge_priv(host); 664 + struct tegra_pcie *pcie = pdev->bus->sysdata; 564 665 int irq; 565 666 566 667 tegra_cpuidle_pcie_irqs_in_use(); ··· 640 743 u32 fpci_bar, size, axi_address; 641 744 642 745 /* Bar 0: type 1 extended configuration space */ 643 - fpci_bar = 0xfe100000; 644 - size = resource_size(pcie->cs); 645 - axi_address = pcie->cs->start; 646 - afi_writel(pcie, axi_address, AFI_AXI_BAR0_START); 746 + size = resource_size(&pcie->cs); 747 + afi_writel(pcie, pcie->cs.start, AFI_AXI_BAR0_START); 647 748 afi_writel(pcie, size >> 12, AFI_AXI_BAR0_SZ); 648 - afi_writel(pcie, fpci_bar, AFI_FPCI_BAR0); 649 749 650 750 /* Bar 1: downstream IO bar */ 651 751 fpci_bar = 0xfdfc0000; ··· 1247 1353 goto poweroff; 1248 1354 } 1249 1355 1250 - pcie->cs = devm_request_mem_region(dev, res->start, 1251 - resource_size(res), res->name); 1252 - if (!pcie->cs) { 1253 - err = -EADDRNOTAVAIL; 1356 + pcie->cs = *res; 1357 + 1358 + /* constrain configuration space to 4 KiB */ 1359 + pcie->cs.end = pcie->cs.start + SZ_4K - 1; 1360 + 1361 + pcie->cfg = devm_ioremap_resource(dev, &pcie->cs); 1362 + if (IS_ERR(pcie->cfg)) { 1363 + err = PTR_ERR(pcie->cfg); 1254 1364 goto poweroff; 1255 1365 } 1256 1366 ··· 2243 2345 return -ENOMEM; 2244 2346 2245 2347 pcie = pci_host_bridge_priv(host); 2348 + host->sysdata = pcie; 2246 2349 2247 2350 pcie->soc = of_device_get_match_data(dev); 2248 - INIT_LIST_HEAD(&pcie->buses); 2249 2351 INIT_LIST_HEAD(&pcie->ports); 2250 2352 pcie->dev = dev; 2251 2353 ··· 2280 2382 2281 2383 tegra_pcie_enable_ports(pcie); 2282 2384 2283 - pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); 2284 2385 host->busnr = pcie->busn.start; 2285 2386 host->dev.parent = &pdev->dev; 2286 2387 host->ops = &tegra_pcie_ops;
+1 -4
drivers/pci/host/pci-thunder-ecam.c
··· 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 3 * Copyright (C) 2015, 2016 Cavium, Inc. 7 4 */ 8 5
+1 -12
drivers/pci/host/pci-thunder-pem.c
··· 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 3 * Copyright (C) 2015 - 2016 Cavium, Inc. 15 4 */ 16 5
+1
drivers/pci/host/pci-v3-semi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Support for V3 Semiconductor PCI Local Bus to PCI Bridge 3 4 * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
+2 -10
drivers/pci/host/pci-versatile.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright 2004 Koninklijke Philips Electronics NV 3 4 * 4 5 * Conversion to platform driver and DT: 5 6 * Copyright 2014 Linaro Ltd. 6 - * 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 7 * 16 8 * 14/04/2005 Initial version, colin.king@philips.com 17 9 */ ··· 194 202 writel(0, versatile_cfg_base[0] + PCI_INTERRUPT_LINE); 195 203 196 204 pci_add_flags(PCI_ENABLE_PROC_DOMAINS); 197 - pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC); 205 + pci_add_flags(PCI_REASSIGN_ALL_BUS); 198 206 199 207 list_splice_init(&pci_res, &bridge->windows); 200 208 bridge->dev.parent = dev;
+1 -10
drivers/pci/host/pci-xgene-msi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * APM X-Gene MSI Driver 3 4 * 4 5 * Copyright (c) 2014, Applied Micro Circuits Corporation 5 6 * Author: Tanmay Inamdar <tinamdar@apm.com> 6 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 9 #include <linux/cpu.h> 19 10 #include <linux/interrupt.h>
+1 -12
drivers/pci/host/pci-xgene.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /** 2 3 * APM X-Gene PCIe Driver 3 4 * 4 5 * Copyright (c) 2014 Applied Micro Circuits Corporation. 5 6 * 6 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 9 #include <linux/clk.h> 20 10 #include <linux/delay.h> ··· 658 668 659 669 bus = bridge->bus; 660 670 661 - pci_scan_child_bus(bus); 662 671 pci_assign_unassigned_bus_resources(bus); 663 672 list_for_each_entry(child, &bus->children, node) 664 673 pcie_bus_configure_settings(child);
+1 -12
drivers/pci/host/pcie-altera-msi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Altera PCIe MSI support 3 4 * 4 5 * Author: Ley Foon Tan <lftan@altera.com> 5 6 * 6 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 10 #include <linux/interrupt.h>
+1 -12
drivers/pci/host/pcie-altera.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright Altera Corporation (C) 2013-2015. All rights reserved 3 4 * 4 5 * Author: Ley Foon Tan <lftan@altera.com> 5 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 9 #include <linux/delay.h>
+1 -9
drivers/pci/host/pcie-iproc-bcma.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2015 Broadcom Corporation 3 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 7 #include <linux/kernel.h>
+1 -9
drivers/pci/host/pcie-iproc-msi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 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 6 #include <linux/interrupt.h>
+8 -9
drivers/pci/host/pcie-iproc-platform.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 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 6 #include <linux/kernel.h> ··· 83 91 pcie->ob.axi_offset = val; 84 92 pcie->need_ob_cfg = true; 85 93 } 94 + 95 + /* 96 + * DT nodes are not used by all platforms that use the iProc PCIe 97 + * core driver. For platforms that require explict inbound mapping 98 + * configuration, "dma-ranges" would have been present in DT 99 + */ 100 + pcie->need_ib_cfg = of_property_read_bool(np, "dma-ranges"); 86 101 87 102 /* PHY use is optional */ 88 103 pcie->phy = devm_phy_get(dev, "pcie-phy");
+6 -12
drivers/pci/host/pcie-iproc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de> 3 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 7 #include <linux/kernel.h> ··· 1370 1378 } 1371 1379 } 1372 1380 1373 - ret = iproc_pcie_map_dma_ranges(pcie); 1374 - if (ret && ret != -ENOENT) 1375 - goto err_power_off_phy; 1381 + if (pcie->need_ib_cfg) { 1382 + ret = iproc_pcie_map_dma_ranges(pcie); 1383 + if (ret && ret != -ENOENT) 1384 + goto err_power_off_phy; 1385 + } 1376 1386 1377 1387 #ifdef CONFIG_ARM 1378 1388 pcie->sysdata.private_data = pcie;
+3 -9
drivers/pci/host/pcie-iproc.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 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 6 #ifndef _PCIE_IPROC_H ··· 66 74 * @ob: outbound mapping related parameters 67 75 * @ob_map: outbound mapping related parameters specific to the controller 68 76 * 77 + * @need_ib_cfg: indicates SW needs to configure the inbound mapping window 69 78 * @ib: inbound mapping related parameters 70 79 * @ib_map: outbound mapping region related parameters 71 80 * ··· 94 101 struct iproc_pcie_ob ob; 95 102 const struct iproc_pcie_ob_map *ob_map; 96 103 104 + bool need_ib_cfg; 97 105 struct iproc_pcie_ib ib; 98 106 const struct iproc_pcie_ib_map *ib_map; 99 107
+1 -9
drivers/pci/host/pcie-mediatek.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * MediaTek PCIe host controller driver. 3 4 * 4 5 * Copyright (c) 2017 MediaTek Inc. 5 6 * Author: Ryder Lee <ryder.lee@mediatek.com> 6 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 10 #include <linux/clk.h>
+6 -6
drivers/pci/host/pcie-rcar.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe driver for Renesas R-Car SoCs 3 4 * Copyright (C) 2014 Renesas Electronics Europe Ltd ··· 9 8 * Copyright (C) 2009 - 2011 Paul Mundt 10 9 * 11 10 * Author: Phil Edworthy <phil.edworthy@renesas.com> 12 - * 13 - * This file is licensed under the terms of the GNU General Public 14 - * License version 2. This program is licensed "as is" without any 15 - * warranty of any kind, whether express or implied. 16 11 */ 17 12 18 13 #include <linux/clk.h> ··· 456 459 457 460 rcar_pcie_setup(&bridge->windows, pcie); 458 461 459 - pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); 462 + pci_add_flags(PCI_REASSIGN_ALL_BUS); 460 463 461 464 bridge->dev.parent = dev; 462 465 bridge->sysdata = pcie; ··· 1120 1123 1121 1124 INIT_LIST_HEAD(&pcie->resources); 1122 1125 1123 - rcar_pcie_parse_request_of_pci_ranges(pcie); 1126 + err = rcar_pcie_parse_request_of_pci_ranges(pcie); 1127 + if (err) 1128 + goto err_free_bridge; 1124 1129 1125 1130 err = rcar_pcie_get_resources(pcie); 1126 1131 if (err < 0) { ··· 1177 1178 1178 1179 err_free_resource_list: 1179 1180 pci_free_resource_list(&pcie->resources); 1181 + err_free_bridge: 1180 1182 pci_free_host_bridge(bridge); 1181 1183 1182 1184 return err;
+1 -5
drivers/pci/host/pcie-rockchip.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Rockchip AXI PCIe host controller driver 3 4 * ··· 9 8 * 10 9 * Bits taken from Synopsys DesignWare Host controller driver and 11 10 * ARM PCI Host generic driver. 12 - * 13 - * This program is free software: you can redistribute it and/or modify 14 - * it under the terms of the GNU General Public License as published by 15 - * the Free Software Foundation, either version 2 of the License, or 16 - * (at your option) any later version. 17 11 */ 18 12 19 13 #include <linux/bitrev.h>
+1 -5
drivers/pci/host/pcie-xilinx-nwl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCIe host controller driver for NWL PCIe Bridge 3 4 * Based on pcie-xilinx.c, pci-tegra.c 4 5 * 5 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 9 #include <linux/delay.h>
+1 -5
drivers/pci/host/pcie-xilinx.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCIe host controller driver for Xilinx AXI PCIe Bridge 3 4 * ··· 8 7 * 9 8 * Bits taken from Synopsys DesignWare Host controller driver and 10 9 * 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 10 */ 17 11 18 12 #include <linux/interrupt.h>
+1 -9
drivers/pci/host/vmd.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Volume Management Device driver 3 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 7 #include <linux/device.h>
+1
drivers/pci/hotplug/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI Hotplug support 3 4 #
+1 -15
drivers/pci/hotplug/acpi_pcihp.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Common ACPI functions for hot plug platforms 3 4 * 4 5 * Copyright (C) 2006 Intel Corporation 5 6 * 6 7 * All rights reserved. 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 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 8 * 23 9 * Send feedback to <kristen.c.accardi@intel.com> 24 10 *
+1 -15
drivers/pci/hotplug/acpiphp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * ACPI PCI Hot Plug Controller Driver 3 4 * ··· 12 11 * Copyright (C) 2003-2005 Hewlett Packard 13 12 * 14 13 * All rights reserved. 15 - * 16 - * This program is free software; you can redistribute it and/or modify 17 - * it under the terms of the GNU General Public License as published by 18 - * the Free Software Foundation; either version 2 of the License, or (at 19 - * your option) any later version. 20 - * 21 - * This program is distributed in the hope that it will be useful, but 22 - * WITHOUT ANY WARRANTY; without even the implied warranty of 23 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 24 - * NON INFRINGEMENT. See the GNU General Public License for more 25 - * details. 26 - * 27 - * You should have received a copy of the GNU General Public License 28 - * along with this program; if not, write to the Free Software 29 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 14 * 31 15 * Send feedback to <gregkh@us.ibm.com>, 32 16 * <t-kochi@bq.jp.nec.com>
+1 -15
drivers/pci/hotplug/acpiphp_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * ACPI PCI Hot Plug Controller Driver 3 4 * ··· 12 11 * Copyright (C) 2003-2005 Hewlett Packard 13 12 * 14 13 * All rights reserved. 15 - * 16 - * This program is free software; you can redistribute it and/or modify 17 - * it under the terms of the GNU General Public License as published by 18 - * the Free Software Foundation; either version 2 of the License, or (at 19 - * your option) any later version. 20 - * 21 - * This program is distributed in the hope that it will be useful, but 22 - * WITHOUT ANY WARRANTY; without even the implied warranty of 23 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 24 - * NON INFRINGEMENT. See the GNU General Public License for more 25 - * details. 26 - * 27 - * You should have received a copy of the GNU General Public License 28 - * along with this program; if not, write to the Free Software 29 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 14 * 31 15 * Send feedback to <kristen.c.accardi@intel.com> 32 16 *
+2 -18
drivers/pci/hotplug/acpiphp_glue.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * ACPI PCI HotPlug glue functions to ACPI CA subsystem 3 4 * ··· 11 10 * Copyright (C) 2005 Intel Corporation 12 11 * 13 12 * All rights reserved. 14 - * 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 13 * 30 14 * Send feedback to <kristen.c.accardi@intel.com> 31 15 * ··· 797 811 798 812 handle = adev->handle; 799 813 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 800 - if (!bridge) { 801 - acpi_handle_err(handle, "No memory for bridge object\n"); 814 + if (!bridge) 802 815 return; 803 - } 804 816 805 817 INIT_LIST_HEAD(&bridge->slots); 806 818 kref_init(&bridge->ref);
+1 -15
drivers/pci/hotplug/acpiphp_ibm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * ACPI PCI Hot Plug IBM Extension 3 4 * ··· 6 5 * Copyright (C) 2004 IBM Corp. 7 6 * 8 7 * All rights reserved. 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 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 8 * 25 9 * Send feedback to <vernux@us.ibm.com> 26 10 *
+1 -15
drivers/pci/hotplug/cpci_hotplug.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * CompactPCI Hot Plug Core Functions 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <scottm@somanetworks.com> 27 11 */
+1 -15
drivers/pci/hotplug/cpci_hotplug_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * CompactPCI Hot Plug Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <scottm@somanetworks.com> 27 11 */
+1 -15
drivers/pci/hotplug/cpci_hotplug_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * CompactPCI Hot Plug Driver PCI functions 3 4 * 4 5 * Copyright (C) 2002,2005 by SOMA Networks, Inc. 5 6 * 6 7 * All rights reserved. 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 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 8 * 23 9 * Send feedback to <scottm@somanetworks.com> 24 10 */
+1 -20
drivers/pci/hotplug/cpcihp_generic.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * cpcihp_generic.c 3 4 * ··· 7 6 * Copyright 2002 SOMA Networks, Inc. 8 7 * Copyright 2001 Intel San Luis Obispo 9 8 * Copyright 2000,2001 MontaVista Software Inc. 10 - * 11 - * This program is free software; you can redistribute it and/or modify it 12 - * under the terms of the GNU General Public License as published by the 13 - * Free Software Foundation; either version 2 of the License, or (at your 14 - * option) any later version. 15 - * 16 - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 17 - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 - * 27 - * You should have received a copy of the GNU General Public License along 28 - * with this program; if not, write to the Free Software Foundation, Inc., 29 - * 675 Mass Ave, Cambridge, MA 02139, USA. 30 9 * 31 10 * This generic CompactPCI hotplug driver should allow using the PCI hotplug 32 11 * mechanism on any CompactPCI board that exposes the #ENUM signal as a bit
+1 -20
drivers/pci/hotplug/cpcihp_zt5550.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * cpcihp_zt5550.c 3 4 * ··· 7 6 * Copyright 2002 SOMA Networks, Inc. 8 7 * Copyright 2001 Intel San Luis Obispo 9 8 * Copyright 2000,2001 MontaVista Software Inc. 10 - * 11 - * This program is free software; you can redistribute it and/or modify it 12 - * under the terms of the GNU General Public License as published by the 13 - * Free Software Foundation; either version 2 of the License, or (at your 14 - * option) any later version. 15 - * 16 - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 17 - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 - * 27 - * You should have received a copy of the GNU General Public License along 28 - * with this program; if not, write to the Free Software Foundation, Inc., 29 - * 675 Mass Ave, Cambridge, MA 02139, USA. 30 9 * 31 10 * Send feedback to <scottm@somanetworks.com> 32 11 */
+1 -20
drivers/pci/hotplug/cpcihp_zt5550.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * cpcihp_zt5550.h 3 4 * ··· 7 6 * Copyright 2002 SOMA Networks, Inc. 8 7 * Copyright 2001 Intel San Luis Obispo 9 8 * Copyright 2000,2001 MontaVista Software Inc. 10 - * 11 - * This program is free software; you can redistribute it and/or modify it 12 - * under the terms of the GNU General Public License as published by the 13 - * Free Software Foundation; either version 2 of the License, or (at your 14 - * option) any later version. 15 - * 16 - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 17 - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 - * 27 - * You should have received a copy of the GNU General Public License along 28 - * with this program; if not, write to the Free Software Foundation, Inc., 29 - * 675 Mass Ave, Cambridge, MA 02139, USA. 30 9 * 31 10 * Send feedback to <scottm@somanetworks.com> 32 11 */
+1 -15
drivers/pci/hotplug/cpqphp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 *
+2 -17
drivers/pci/hotplug/cpqphp_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 * ··· 821 835 822 836 bus = pdev->subordinate; 823 837 if (!bus) { 824 - dev_notice(&pdev->dev, "the device is not a bridge, skipping\n"); 838 + pci_notice(pdev, "the device is not a bridge, skipping\n"); 825 839 rc = -ENODEV; 826 840 goto err_disable_device; 827 841 } ··· 869 883 870 884 ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); 871 885 if (!ctrl) { 872 - err("%s : out of memory\n", __func__); 873 886 rc = -ENOMEM; 874 887 goto err_disable_device; 875 888 }
+1 -15
drivers/pci/hotplug/cpqphp_ctrl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 *
+1 -15
drivers/pci/hotplug/cpqphp_nvram.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 *
+1 -15
drivers/pci/hotplug/cpqphp_nvram.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 6 5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) 7 6 * 8 7 * All rights reserved. 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 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 8 * 25 9 * Send feedback to <greg@kroah.com> 26 10 *
+15 -19
drivers/pci/hotplug/cpqphp_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 * ··· 75 89 pci_lock_rescan_remove(); 76 90 77 91 if (func->pci_dev == NULL) 78 - func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function)); 92 + func->pci_dev = pci_get_domain_bus_and_slot(0, func->bus, 93 + PCI_DEVFN(func->device, 94 + func->function)); 79 95 80 96 /* No pci device, we need to create it then */ 81 97 if (func->pci_dev == NULL) { ··· 87 99 if (num) 88 100 pci_bus_add_devices(ctrl->pci_dev->bus); 89 101 90 - func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function)); 102 + func->pci_dev = pci_get_domain_bus_and_slot(0, func->bus, 103 + PCI_DEVFN(func->device, 104 + func->function)); 91 105 if (func->pci_dev == NULL) { 92 106 dbg("ERROR: pci_dev still null\n"); 93 107 goto out; ··· 119 129 120 130 pci_lock_rescan_remove(); 121 131 for (j = 0; j < 8 ; j++) { 122 - struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j)); 132 + struct pci_dev *temp = pci_get_domain_bus_and_slot(0, 133 + func->bus, 134 + PCI_DEVFN(func->device, 135 + j)); 123 136 if (temp) { 124 137 pci_dev_put(temp); 125 138 pci_stop_and_remove_bus_device(temp); ··· 312 319 int cloop = 0; 313 320 int stop_it; 314 321 int index; 322 + u16 devfn; 315 323 316 324 /* Decide which slots are supported */ 317 325 ··· 410 416 new_slot->switch_save = 0x10; 411 417 /* In case of unsupported board */ 412 418 new_slot->status = DevError; 413 - new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function); 419 + devfn = (new_slot->device << 3) | new_slot->function; 420 + new_slot->pci_dev = pci_get_domain_bus_and_slot(0, 421 + new_slot->bus, devfn); 414 422 415 423 for (cloop = 0; cloop < 0x20; cloop++) { 416 424 rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop]));
+1 -15
drivers/pci/hotplug/cpqphp_sysfs.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 *
+1 -15
drivers/pci/hotplug/ibmphp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 #ifndef __IBMPHP_H 2 3 #define __IBMPHP_H 3 4 ··· 11 10 * Copyright (C) 2001-2003 IBM Corp. 12 11 * 13 12 * All rights reserved. 14 - * 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 13 * 30 14 * Send feedback to <gregkh@us.ibm.com> 31 15 *
+8 -28
drivers/pci/hotplug/ibmphp_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * IBM Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2001-2003 IBM Corp. 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <gregkh@us.ibm.com> 28 12 * ··· 589 603 u8 mode; 590 604 591 605 info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 592 - if (!info) { 593 - err("out of system memory\n"); 606 + if (!info) 594 607 return -ENOMEM; 595 - } 596 608 597 609 info->power_status = SLOT_PWRGD(slot_cur->status); 598 610 info->attention_status = SLOT_ATTN(slot_cur->status, ··· 691 707 pci_lock_rescan_remove(); 692 708 693 709 for (j = 0; j < 0x08; j++) { 694 - temp = pci_get_bus_and_slot(func->busno, (func->device << 3) | j); 710 + temp = pci_get_domain_bus_and_slot(0, func->busno, 711 + (func->device << 3) | j); 695 712 if (temp) { 696 713 pci_stop_and_remove_bus_device(temp); 697 714 pci_dev_put(temp); ··· 719 734 return 1; 720 735 721 736 bus = kmalloc(sizeof(*bus), GFP_KERNEL); 722 - if (!bus) { 723 - err("%s - out of memory\n", __func__); 737 + if (!bus) 724 738 return 1; 725 - } 739 + 726 740 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 727 741 if (!dev) { 728 742 kfree(bus); 729 - err("%s - out of memory\n", __func__); 730 743 return 1; 731 744 } 732 745 ··· 763 780 if (!(bus_structure_fixup(func->busno))) 764 781 flag = 1; 765 782 if (func->dev == NULL) 766 - func->dev = pci_get_bus_and_slot(func->busno, 783 + func->dev = pci_get_domain_bus_and_slot(0, func->busno, 767 784 PCI_DEVFN(func->device, func->function)); 768 785 769 786 if (func->dev == NULL) { ··· 776 793 if (num) 777 794 pci_bus_add_devices(bus); 778 795 779 - func->dev = pci_get_bus_and_slot(func->busno, 796 + func->dev = pci_get_domain_bus_and_slot(0, func->busno, 780 797 PCI_DEVFN(func->device, func->function)); 781 798 if (func->dev == NULL) { 782 799 err("ERROR... : pci_dev still NULL\n"); ··· 1084 1101 if (!slot_cur->func) { 1085 1102 /* We cannot do update_slot_info here, since no memory for 1086 1103 * kmalloc n.e.ways, and update_slot_info allocates some */ 1087 - err("out of system memory\n"); 1088 1104 rc = -ENOMEM; 1089 1105 goto error_power; 1090 1106 } ··· 1190 1208 /* We need this for functions that were there on bootup */ 1191 1209 slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); 1192 1210 if (!slot_cur->func) { 1193 - err("out of system memory\n"); 1194 1211 rc = -ENOMEM; 1195 1212 goto error; 1196 1213 } ··· 1287 1306 1288 1307 ibmphp_pci_bus = kmalloc(sizeof(*ibmphp_pci_bus), GFP_KERNEL); 1289 1308 if (!ibmphp_pci_bus) { 1290 - err("out of memory\n"); 1291 1309 rc = -ENOMEM; 1292 1310 goto exit; 1293 1311 }
+1 -15
drivers/pci/hotplug/ibmphp_ebda.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * IBM Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2001-2003 IBM Corp. 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <gregkh@us.ibm.com> 28 12 *
+1 -15
drivers/pci/hotplug/ibmphp_hpc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * IBM Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (C) 2001-2003 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <gregkh@us.ibm.com> 27 11 * <jshah@us.ibm.com>
+21 -55
drivers/pci/hotplug/ibmphp_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * IBM Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2001,2002 IBM Corp. 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <gregkh@us.ibm.com> 28 12 * ··· 153 167 goto error; 154 168 } 155 169 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 156 - if (!newfunc) { 157 - err("out of system memory\n"); 170 + if (!newfunc) 158 171 return -ENOMEM; 159 - } 172 + 160 173 newfunc->busno = cur_func->busno; 161 174 newfunc->device = device; 162 175 cur_func->next = newfunc; ··· 190 205 for (i = 0; i < 32; i++) { 191 206 if (func->devices[i]) { 192 207 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 193 - if (!newfunc) { 194 - err("out of system memory\n"); 208 + if (!newfunc) 195 209 return -ENOMEM; 196 - } 210 + 197 211 newfunc->busno = sec_number; 198 212 newfunc->device = (u8) i; 199 213 for (j = 0; j < 4; j++) ··· 217 233 } 218 234 219 235 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 220 - if (!newfunc) { 221 - err("out of system memory\n"); 236 + if (!newfunc) 222 237 return -ENOMEM; 223 - } 238 + 224 239 newfunc->busno = cur_func->busno; 225 240 newfunc->device = device; 226 241 for (j = 0; j < 4; j++) ··· 262 279 if (func->devices[i]) { 263 280 debug("inside for loop, device is %x\n", i); 264 281 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 265 - if (!newfunc) { 266 - err(" out of system memory\n"); 282 + if (!newfunc) 267 283 return -ENOMEM; 268 - } 284 + 269 285 newfunc->busno = sec_number; 270 286 newfunc->device = (u8) i; 271 287 for (j = 0; j < 4; j++) ··· 387 405 388 406 io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 389 407 390 - if (!io[count]) { 391 - err("out of system memory\n"); 408 + if (!io[count]) 392 409 return -ENOMEM; 393 - } 410 + 394 411 io[count]->type = IO; 395 412 io[count]->busno = func->busno; 396 413 io[count]->devfunc = PCI_DEVFN(func->device, func->function); ··· 423 442 debug("len[count] in PFMEM %x, count %d\n", len[count], count); 424 443 425 444 pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 426 - if (!pfmem[count]) { 427 - err("out of system memory\n"); 445 + if (!pfmem[count]) 428 446 return -ENOMEM; 429 - } 447 + 430 448 pfmem[count]->type = PFMEM; 431 449 pfmem[count]->busno = func->busno; 432 450 pfmem[count]->devfunc = PCI_DEVFN(func->device, ··· 438 458 } else { 439 459 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 440 460 if (!mem_tmp) { 441 - err("out of system memory\n"); 442 461 kfree(pfmem[count]); 443 462 return -ENOMEM; 444 463 } ··· 487 508 debug("len[count] in Mem %x, count %d\n", len[count], count); 488 509 489 510 mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 490 - if (!mem[count]) { 491 - err("out of system memory\n"); 511 + if (!mem[count]) 492 512 return -ENOMEM; 493 - } 513 + 494 514 mem[count]->type = MEM; 495 515 mem[count]->busno = func->busno; 496 516 mem[count]->devfunc = PCI_DEVFN(func->device, ··· 652 674 bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 653 675 654 676 if (!bus_io[count]) { 655 - err("out of system memory\n"); 656 677 retval = -ENOMEM; 657 678 goto error; 658 679 } ··· 683 706 684 707 bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 685 708 if (!bus_pfmem[count]) { 686 - err("out of system memory\n"); 687 709 retval = -ENOMEM; 688 710 goto error; 689 711 } ··· 698 722 } else { 699 723 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 700 724 if (!mem_tmp) { 701 - err("out of system memory\n"); 702 725 retval = -ENOMEM; 703 726 goto error; 704 727 } ··· 738 763 739 764 bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 740 765 if (!bus_mem[count]) { 741 - err("out of system memory\n"); 742 766 retval = -ENOMEM; 743 767 goto error; 744 768 } ··· 808 834 io = kzalloc(sizeof(*io), GFP_KERNEL); 809 835 810 836 if (!io) { 811 - err("out of system memory\n"); 812 837 retval = -ENOMEM; 813 838 goto error; 814 839 } ··· 829 856 debug("it wants %x memory behind the bridge\n", amount_needed->mem); 830 857 mem = kzalloc(sizeof(*mem), GFP_KERNEL); 831 858 if (!mem) { 832 - err("out of system memory\n"); 833 859 retval = -ENOMEM; 834 860 goto error; 835 861 } ··· 850 878 debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); 851 879 pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); 852 880 if (!pfmem) { 853 - err("out of system memory\n"); 854 881 retval = -ENOMEM; 855 882 goto error; 856 883 } ··· 864 893 } else { 865 894 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 866 895 if (!mem_tmp) { 867 - err("out of system memory\n"); 868 896 retval = -ENOMEM; 869 897 goto error; 870 898 } ··· 894 924 if (!bus) { 895 925 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 896 926 if (!bus) { 897 - err("out of system memory\n"); 898 927 retval = -ENOMEM; 899 928 goto error; 900 929 } ··· 1621 1652 } 1622 1653 if (io) { 1623 1654 io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); 1624 - if (!io_range) { 1625 - err("out of system memory\n"); 1655 + if (!io_range) 1626 1656 return -ENOMEM; 1627 - } 1657 + 1628 1658 io_range->start = io->start; 1629 1659 io_range->end = io->end; 1630 1660 io_range->rangeno = 1; ··· 1632 1664 } 1633 1665 if (mem) { 1634 1666 mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); 1635 - if (!mem_range) { 1636 - err("out of system memory\n"); 1667 + if (!mem_range) 1637 1668 return -ENOMEM; 1638 - } 1669 + 1639 1670 mem_range->start = mem->start; 1640 1671 mem_range->end = mem->end; 1641 1672 mem_range->rangeno = 1; ··· 1643 1676 } 1644 1677 if (pfmem) { 1645 1678 pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); 1646 - if (!pfmem_range) { 1647 - err("out of system memory\n"); 1679 + if (!pfmem_range) 1648 1680 return -ENOMEM; 1649 - } 1681 + 1650 1682 pfmem_range->start = pfmem->start; 1651 1683 pfmem_range->end = pfmem->end; 1652 1684 pfmem_range->rangeno = 1;
+14 -40
drivers/pci/hotplug/ibmphp_res.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * IBM Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2001,2002 IBM Corp. 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <gregkh@us.ibm.com> 28 12 * ··· 42 56 } 43 57 44 58 newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); 45 - if (!newbus) { 46 - err("out of system memory\n"); 59 + if (!newbus) 47 60 return NULL; 48 - } 49 61 50 62 if (flag) 51 63 newbus->busno = busno; ··· 63 79 } 64 80 65 81 rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 66 - if (!rs) { 67 - err("out of system memory\n"); 82 + if (!rs) 68 83 return NULL; 69 - } 84 + 70 85 rs->busno = curr->bus_num; 71 86 rs->devfunc = curr->dev_fun; 72 87 rs->start = curr->start_addr; ··· 82 99 83 100 if (first_bus) { 84 101 newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); 85 - if (!newbus) { 86 - err("out of system memory.\n"); 102 + if (!newbus) 87 103 return -ENOMEM; 88 - } 104 + 89 105 newbus->busno = curr->bus_num; 90 106 } else { 91 107 newbus = *new_bus; ··· 105 123 if (!newrange) { 106 124 if (first_bus) 107 125 kfree(newbus); 108 - err("out of system memory\n"); 109 126 return -ENOMEM; 110 127 } 111 128 newrange->start = curr->start_addr; ··· 1688 1707 bus_cur->firstPFMemFromMem = pfmem_cur; 1689 1708 1690 1709 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 1691 - if (!mem) { 1692 - err("out of system memory\n"); 1710 + if (!mem) 1693 1711 return -ENOMEM; 1694 - } 1712 + 1695 1713 mem->type = MEM; 1696 1714 mem->busno = pfmem_cur->busno; 1697 1715 mem->devfunc = pfmem_cur->devfunc; ··· 1969 1989 1970 1990 if ((start_address) && (start_address <= end_address)) { 1971 1991 range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 1972 - if (!range) { 1973 - err("out of system memory\n"); 1992 + if (!range) 1974 1993 return -ENOMEM; 1975 - } 1994 + 1976 1995 range->start = start_address; 1977 1996 range->end = end_address + 0xfff; 1978 1997 ··· 1995 2016 io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 1996 2017 if (!io) { 1997 2018 kfree(range); 1998 - err("out of system memory\n"); 1999 2019 return -ENOMEM; 2000 2020 } 2001 2021 io->type = IO; ··· 2016 2038 if ((start_address) && (start_address <= end_address)) { 2017 2039 2018 2040 range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 2019 - if (!range) { 2020 - err("out of system memory\n"); 2041 + if (!range) 2021 2042 return -ENOMEM; 2022 - } 2043 + 2023 2044 range->start = start_address; 2024 2045 range->end = end_address + 0xfffff; 2025 2046 ··· 2043 2066 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2044 2067 if (!mem) { 2045 2068 kfree(range); 2046 - err("out of system memory\n"); 2047 2069 return -ENOMEM; 2048 2070 } 2049 2071 mem->type = MEM; ··· 2068 2092 if ((start_address) && (start_address <= end_address)) { 2069 2093 2070 2094 range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 2071 - if (!range) { 2072 - err("out of system memory\n"); 2095 + if (!range) 2073 2096 return -ENOMEM; 2074 - } 2097 + 2075 2098 range->start = start_address; 2076 2099 range->end = end_address + 0xfffff; 2077 2100 ··· 2094 2119 pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2095 2120 if (!pfmem) { 2096 2121 kfree(range); 2097 - err("out of system memory\n"); 2098 2122 return -ENOMEM; 2099 2123 } 2100 2124 pfmem->type = PFMEM;
+1 -15
drivers/pci/hotplug/pci_hotplug_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI HotPlug Controller Core 3 4 * ··· 6 5 * Copyright (C) 2001-2002 IBM Corp. 7 6 * 8 7 * All rights reserved. 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 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 8 * 25 9 * Send feedback to <kristen.c.accardi@intel.com> 26 10 *
+1 -15
drivers/pci/hotplug/pciehp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * PCI Express Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 *
+1 -15
drivers/pci/hotplug/pciehp_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Express Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 *
+1 -15
drivers/pci/hotplug/pciehp_ctrl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Express Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 *
+10 -18
drivers/pci/hotplug/pciehp_hpc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Express PCI Hot Plug Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> 28 12 * ··· 824 838 struct pci_dev *pdev = dev->port; 825 839 826 840 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 827 - if (!ctrl) { 828 - dev_err(&dev->device, "%s: Out of memory\n", __func__); 841 + if (!ctrl) 829 842 goto abort; 830 - } 843 + 831 844 ctrl->pcie = dev; 832 845 pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, &slot_cap); 833 846 834 847 if (pdev->hotplug_user_indicators) 835 848 slot_cap &= ~(PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_PIP); 849 + 850 + /* 851 + * We assume no Thunderbolt controllers support Command Complete events, 852 + * but some controllers falsely claim they do. 853 + */ 854 + if (pdev->is_thunderbolt) 855 + slot_cap |= PCI_EXP_SLTCAP_NCCS; 836 856 837 857 ctrl->slot_cap = slot_cap; 838 858 mutex_init(&ctrl->ctrl_lock);
+1 -27
drivers/pci/hotplug/pciehp_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Express Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 * ··· 65 79 int pciehp_unconfigure_device(struct slot *p_slot) 66 80 { 67 81 int rc = 0; 68 - u8 bctl = 0; 69 82 u8 presence = 0; 70 83 struct pci_dev *dev, *temp; 71 84 struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate; ··· 86 101 list_for_each_entry_safe_reverse(dev, temp, &parent->devices, 87 102 bus_list) { 88 103 pci_dev_get(dev); 89 - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { 90 - pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl); 91 - if (bctl & PCI_BRIDGE_CTL_VGA) { 92 - ctrl_err(ctrl, 93 - "Cannot remove display device %s\n", 94 - pci_name(dev)); 95 - pci_dev_put(dev); 96 - rc = -EINVAL; 97 - break; 98 - } 99 - } 100 104 if (!presence) { 101 105 pci_dev_set_disconnected(dev, NULL); 102 106 if (pci_has_subordinate(dev))
+1 -15
drivers/pci/hotplug/pcihp_skeleton.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Hot Plug Controller Skeleton Driver - 0.3 3 4 * ··· 6 5 * Copyright (C) 2001,2003 IBM Corp. 7 6 * 8 7 * All rights reserved. 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 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 8 * 25 9 * This driver is to be used as a skeleton driver to show how to interface 26 10 * with the pci hotplug core easily.
+17 -28
drivers/pci/hotplug/pnv_php.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Hotplug Driver for PowerPC PowerNV platform. 3 4 * 4 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 8 #include <linux/libfdt.h> ··· 262 266 fdt1 = kzalloc(0x10000, GFP_KERNEL); 263 267 if (!fdt1) { 264 268 ret = -ENOMEM; 265 - dev_warn(&php_slot->pdev->dev, "Cannot alloc FDT blob\n"); 266 269 goto out; 267 270 } 268 271 269 272 ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000); 270 273 if (ret) { 271 - dev_warn(&php_slot->pdev->dev, "Error %d getting FDT blob\n", 272 - ret); 274 + pci_warn(php_slot->pdev, "Error %d getting FDT blob\n", ret); 273 275 goto free_fdt1; 274 276 } 275 277 276 278 fdt = kzalloc(fdt_totalsize(fdt1), GFP_KERNEL); 277 279 if (!fdt) { 278 280 ret = -ENOMEM; 279 - dev_warn(&php_slot->pdev->dev, "Cannot %d bytes memory\n", 280 - fdt_totalsize(fdt1)); 281 281 goto free_fdt1; 282 282 } 283 283 ··· 282 290 dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL); 283 291 if (!dt) { 284 292 ret = -EINVAL; 285 - dev_warn(&php_slot->pdev->dev, "Cannot unflatten FDT\n"); 293 + pci_warn(php_slot->pdev, "Cannot unflatten FDT\n"); 286 294 goto free_fdt; 287 295 } 288 296 ··· 292 300 ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn); 293 301 if (ret) { 294 302 pnv_php_reverse_nodes(php_slot->dn); 295 - dev_warn(&php_slot->pdev->dev, "Error %d populating changeset\n", 303 + pci_warn(php_slot->pdev, "Error %d populating changeset\n", 296 304 ret); 297 305 goto free_dt; 298 306 } ··· 300 308 php_slot->dn->child = NULL; 301 309 ret = of_changeset_apply(&php_slot->ocs); 302 310 if (ret) { 303 - dev_warn(&php_slot->pdev->dev, "Error %d applying changeset\n", 304 - ret); 311 + pci_warn(php_slot->pdev, "Error %d applying changeset\n", ret); 305 312 goto destroy_changeset; 306 313 } 307 314 ··· 336 345 if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle || 337 346 be64_to_cpu(msg.params[2]) != state || 338 347 be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) { 339 - dev_warn(&php_slot->pdev->dev, "Wrong msg (%lld, %lld, %lld)\n", 348 + pci_warn(php_slot->pdev, "Wrong msg (%lld, %lld, %lld)\n", 340 349 be64_to_cpu(msg.params[1]), 341 350 be64_to_cpu(msg.params[2]), 342 351 be64_to_cpu(msg.params[3])); 343 352 return -ENOMSG; 344 353 } 345 354 } else if (ret < 0) { 346 - dev_warn(&php_slot->pdev->dev, "Error %d powering %s\n", 355 + pci_warn(php_slot->pdev, "Error %d powering %s\n", 347 356 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off"); 348 357 return ret; 349 358 } ··· 370 379 */ 371 380 ret = pnv_pci_get_power_state(php_slot->id, &power_state); 372 381 if (ret) { 373 - dev_warn(&php_slot->pdev->dev, "Error %d getting power status\n", 382 + pci_warn(php_slot->pdev, "Error %d getting power status\n", 374 383 ret); 375 384 } else { 376 385 *state = power_state; ··· 396 405 slot->info->adapter_status = presence; 397 406 ret = 0; 398 407 } else { 399 - dev_warn(&php_slot->pdev->dev, "Error %d getting presence\n", 400 - ret); 408 + pci_warn(php_slot->pdev, "Error %d getting presence\n", ret); 401 409 } 402 410 403 411 return ret; ··· 619 629 ret = pci_hp_register(&php_slot->slot, php_slot->bus, 620 630 php_slot->slot_no, php_slot->name); 621 631 if (ret) { 622 - dev_warn(&php_slot->pdev->dev, "Error %d registering slot\n", 623 - ret); 632 + pci_warn(php_slot->pdev, "Error %d registering slot\n", ret); 624 633 return ret; 625 634 } 626 635 ··· 672 683 /* Enable MSIx */ 673 684 ret = pci_enable_msix_exact(pdev, &entry, 1); 674 685 if (ret) { 675 - dev_warn(&pdev->dev, "Error %d enabling MSIx\n", ret); 686 + pci_warn(pdev, "Error %d enabling MSIx\n", ret); 676 687 return ret; 677 688 } 678 689 ··· 716 727 (sts & PCI_EXP_SLTSTA_PDC)) { 717 728 ret = pnv_pci_get_presence_state(php_slot->id, &presence); 718 729 if (ret) { 719 - dev_warn(&pdev->dev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n", 730 + pci_warn(pdev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n", 720 731 php_slot->name, ret, sts); 721 732 return IRQ_HANDLED; 722 733 } ··· 746 757 */ 747 758 event = kzalloc(sizeof(*event), GFP_ATOMIC); 748 759 if (!event) { 749 - dev_warn(&pdev->dev, "PCI slot [%s] missed hotplug event 0x%04x\n", 760 + pci_warn(pdev, "PCI slot [%s] missed hotplug event 0x%04x\n", 750 761 php_slot->name, sts); 751 762 return IRQ_HANDLED; 752 763 } 753 764 754 - dev_info(&pdev->dev, "PCI slot [%s] %s (IRQ: %d)\n", 765 + pci_info(pdev, "PCI slot [%s] %s (IRQ: %d)\n", 755 766 php_slot->name, added ? "added" : "removed", irq); 756 767 INIT_WORK(&event->work, pnv_php_event_handler); 757 768 event->added = added; ··· 771 782 /* Allocate workqueue */ 772 783 php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name); 773 784 if (!php_slot->wq) { 774 - dev_warn(&pdev->dev, "Cannot alloc workqueue\n"); 785 + pci_warn(pdev, "Cannot alloc workqueue\n"); 775 786 pnv_php_disable_irq(php_slot, true); 776 787 return; 777 788 } ··· 795 806 php_slot->name, php_slot); 796 807 if (ret) { 797 808 pnv_php_disable_irq(php_slot, true); 798 - dev_warn(&pdev->dev, "Error %d enabling IRQ %d\n", ret, irq); 809 + pci_warn(pdev, "Error %d enabling IRQ %d\n", ret, irq); 799 810 return; 800 811 } 801 812 ··· 831 842 832 843 ret = pci_enable_device(pdev); 833 844 if (ret) { 834 - dev_warn(&pdev->dev, "Error %d enabling device\n", ret); 845 + pci_warn(pdev, "Error %d enabling device\n", ret); 835 846 return; 836 847 } 837 848
+1 -5
drivers/pci/hotplug/rpadlpar.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * Interface for Dynamic Logical Partitioning of I/O Slots on 3 4 * RPA-compliant PPC64 platform. ··· 7 6 * October 2003 8 7 * 9 8 * Copyright (C) 2003 IBM. 10 - * 11 - * This program is free software; you can redistribute it and/or 12 - * modify it under the terms of the GNU General Public License 13 - * as published by the Free Software Foundation; either version 14 - * 2 of the License, or (at your option) any later version. 15 9 */ 16 10 #ifndef _RPADLPAR_IO_H_ 17 11 #define _RPADLPAR_IO_H_
+1 -5
drivers/pci/hotplug/rpadlpar_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Interface for Dynamic Logical Partitioning of I/O Slots on 3 4 * RPA-compliant PPC64 platform. ··· 9 8 * October 2003 10 9 * 11 10 * Copyright (C) 2003 IBM. 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; either version 16 - * 2 of the License, or (at your option) any later version. 17 11 */ 18 12 19 13 #undef DEBUG
+1 -5
drivers/pci/hotplug/rpadlpar_sysfs.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Interface for Dynamic Logical Partitioning of I/O Slots on 3 4 * RPA-compliant PPC64 platform. ··· 7 6 * October 2003 8 7 * 9 8 * Copyright (C) 2003 IBM. 10 - * 11 - * This program is free software; you can redistribute it and/or 12 - * modify it under the terms of the GNU General Public License 13 - * as published by the Free Software Foundation; either version 14 - * 2 of the License, or (at your option) any later version. 15 9 */ 16 10 #include <linux/kobject.h> 17 11 #include <linux/string.h>
+1 -15
drivers/pci/hotplug/rpaphp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. 3 4 * 4 5 * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> 5 6 * 6 7 * All rights reserved. 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 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 8 * 23 9 * Send feedback to <lxie@us.ibm.com>, 24 10 *
+1 -15
drivers/pci/hotplug/rpaphp_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. 3 4 * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> 4 5 * 5 6 * All rights reserved. 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 (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 7 * 22 8 * Send feedback to <lxie@us.ibm.com> 23 9 *
+1 -15
drivers/pci/hotplug/rpaphp_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform. 3 4 * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com> 4 5 * 5 6 * All rights reserved. 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 (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 7 * 22 8 * Send feedback to <lxie@us.ibm.com> 23 9 *
+1 -15
drivers/pci/hotplug/rpaphp_slot.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * RPA Virtual I/O device functions 3 4 * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com> 4 5 * 5 6 * All rights reserved. 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 (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 7 * 22 8 * Send feedback to <lxie@us.ibm.com> 23 9 *
+1 -2
drivers/pci/hotplug/s390_pci_hpc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI Hot Plug Controller Driver for System z 3 4 * ··· 6 5 * 7 6 * Author(s): 8 7 * Jan Glauber <jang@linux.vnet.ibm.com> 9 - * 10 - * License: GPL 11 8 */ 12 9 13 10 #define KMSG_COMPONENT "zpci"
+19 -22
drivers/pci/hotplug/sgi_hotplug.c
··· 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 3 * Copyright (C) 2005-2006 Silicon Graphics, Inc. All rights reserved. 7 4 * 8 5 * This work was based on the 2.4/2.6 kernel development by Dick Reigner. ··· 242 245 243 246 244 247 if (rc == PCI_SLOT_ALREADY_UP) { 245 - dev_dbg(&slot->pci_bus->self->dev, "is already active\n"); 248 + pci_dbg(slot->pci_bus->self, "is already active\n"); 246 249 return 1; /* return 1 to user */ 247 250 } 248 251 249 252 if (rc == PCI_L1_ERR) { 250 - dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message: %s", 253 + pci_dbg(slot->pci_bus->self, "L1 failure %d with message: %s", 251 254 resp.resp_sub_errno, resp.resp_l1_msg); 252 255 return -EPERM; 253 256 } 254 257 255 258 if (rc) { 256 - dev_dbg(&slot->pci_bus->self->dev, "insert failed with error %d sub-error %d\n", 259 + pci_dbg(slot->pci_bus->self, "insert failed with error %d sub-error %d\n", 257 260 rc, resp.resp_sub_errno); 258 261 return -EIO; 259 262 } ··· 278 281 279 282 if ((action == PCI_REQ_SLOT_ELIGIBLE) && 280 283 (rc == PCI_SLOT_ALREADY_DOWN)) { 281 - dev_dbg(&slot->pci_bus->self->dev, "Slot %s already inactive\n", slot->physical_path); 284 + pci_dbg(slot->pci_bus->self, "Slot %s already inactive\n", slot->physical_path); 282 285 return 1; /* return 1 to user */ 283 286 } 284 287 285 288 if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { 286 - dev_dbg(&slot->pci_bus->self->dev, "Cannot remove last 33MHz card\n"); 289 + pci_dbg(slot->pci_bus->self, "Cannot remove last 33MHz card\n"); 287 290 return -EPERM; 288 291 } 289 292 290 293 if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { 291 - dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message \n%s\n", 294 + pci_dbg(slot->pci_bus->self, "L1 failure %d with message \n%s\n", 292 295 resp.resp_sub_errno, resp.resp_l1_msg); 293 296 return -EPERM; 294 297 } 295 298 296 299 if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { 297 - dev_dbg(&slot->pci_bus->self->dev, "remove failed with error %d sub-error %d\n", 300 + pci_dbg(slot->pci_bus->self, "remove failed with error %d sub-error %d\n", 298 301 rc, resp.resp_sub_errno); 299 302 return -EIO; 300 303 } ··· 305 308 if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { 306 309 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); 307 310 pcibus_info->pbi_enabled_devices &= ~(1 << device_num); 308 - dev_dbg(&slot->pci_bus->self->dev, "remove successful\n"); 311 + pci_dbg(slot->pci_bus->self, "remove successful\n"); 309 312 return 0; 310 313 } 311 314 312 315 if ((action == PCI_REQ_SLOT_DISABLE) && rc) { 313 - dev_dbg(&slot->pci_bus->self->dev, "remove failed rc = %d\n", rc); 316 + pci_dbg(slot->pci_bus->self, "remove failed rc = %d\n", rc); 314 317 } 315 318 316 319 return rc; ··· 363 366 num_funcs = pci_scan_slot(slot->pci_bus, 364 367 PCI_DEVFN(slot->device_num + 1, 0)); 365 368 if (!num_funcs) { 366 - dev_dbg(&slot->pci_bus->self->dev, "no device in slot\n"); 369 + pci_dbg(slot->pci_bus->self, "no device in slot\n"); 367 370 mutex_unlock(&sn_hotplug_mutex); 368 371 return -ENODEV; 369 372 } ··· 409 412 phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion); 410 413 411 414 if (acpi_bus_get_device(phandle, &pdevice)) { 412 - dev_dbg(&slot->pci_bus->self->dev, "no parent device, assuming NULL\n"); 415 + pci_dbg(slot->pci_bus->self, "no parent device, assuming NULL\n"); 413 416 pdevice = NULL; 414 417 } 415 418 ··· 460 463 mutex_unlock(&sn_hotplug_mutex); 461 464 462 465 if (rc == 0) 463 - dev_dbg(&slot->pci_bus->self->dev, "insert operation successful\n"); 466 + pci_dbg(slot->pci_bus->self, "insert operation successful\n"); 464 467 else 465 - dev_dbg(&slot->pci_bus->self->dev, "insert operation failed rc = %d\n", rc); 468 + pci_dbg(slot->pci_bus->self, "insert operation failed rc = %d\n", rc); 466 469 467 470 return rc; 468 471 } ··· 640 643 if (rc) 641 644 goto register_err; 642 645 } 643 - dev_dbg(&pci_bus->self->dev, "Registered bus with hotplug\n"); 646 + pci_dbg(pci_bus->self, "Registered bus with hotplug\n"); 644 647 return rc; 645 648 646 649 register_err: 647 - dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n", 650 + pci_dbg(pci_bus->self, "bus failed to register with err = %d\n", 648 651 rc); 649 652 650 653 alloc_err: 651 654 if (rc == -ENOMEM) 652 - dev_dbg(&pci_bus->self->dev, "Memory allocation error\n"); 655 + pci_dbg(pci_bus->self, "Memory allocation error\n"); 653 656 654 657 /* destroy THIS element */ 655 658 if (bss_hotplug_slot) ··· 682 685 683 686 rc = sn_pci_bus_valid(pci_bus); 684 687 if (rc != 1) { 685 - dev_dbg(&pci_bus->self->dev, "not a valid hotplug bus\n"); 688 + pci_dbg(pci_bus->self, "not a valid hotplug bus\n"); 686 689 continue; 687 690 } 688 - dev_dbg(&pci_bus->self->dev, "valid hotplug bus\n"); 691 + pci_dbg(pci_bus->self, "valid hotplug bus\n"); 689 692 690 693 rc = sn_hotplug_slot_register(pci_bus); 691 694 if (!rc) {
+5 -19
drivers/pci/hotplug/shpchp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * Standard Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> 28 12 * ··· 48 62 #define ctrl_dbg(ctrl, format, arg...) \ 49 63 do { \ 50 64 if (shpchp_debug) \ 51 - dev_printk(KERN_DEBUG, &ctrl->pci_dev->dev, \ 65 + pci_printk(KERN_DEBUG, ctrl->pci_dev, \ 52 66 format, ## arg); \ 53 67 } while (0) 54 68 #define ctrl_err(ctrl, format, arg...) \ 55 - dev_err(&ctrl->pci_dev->dev, format, ## arg) 69 + pci_err(ctrl->pci_dev, format, ## arg) 56 70 #define ctrl_info(ctrl, format, arg...) \ 57 - dev_info(&ctrl->pci_dev->dev, format, ## arg) 71 + pci_info(ctrl->pci_dev, format, ## arg) 58 72 #define ctrl_warn(ctrl, format, arg...) \ 59 - dev_warn(&ctrl->pci_dev->dev, format, ## arg) 73 + pci_warn(ctrl->pci_dev, format, ## arg) 60 74 61 75 62 76 #define SLOT_NAME_SIZE 10
+3 -18
drivers/pci/hotplug/shpchp_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Standard Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 * ··· 291 305 return -ENODEV; 292 306 293 307 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 294 - if (!ctrl) { 295 - dev_err(&pdev->dev, "%s: Out of memory\n", __func__); 308 + if (!ctrl) 296 309 goto err_out_none; 297 - } 310 + 298 311 INIT_LIST_HEAD(&ctrl->slot_list); 299 312 300 313 rc = shpc_init(ctrl, pdev);
+1 -15
drivers/pci/hotplug/shpchp_ctrl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Standard Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 *
+1 -15
drivers/pci/hotplug/shpchp_hpc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Standard PCI Hot Plug Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> 28 12 *
+1 -27
drivers/pci/hotplug/shpchp_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Standard Hot Plug Controller Driver 3 4 * ··· 8 7 * Copyright (C) 2003-2004 Intel Corporation 9 8 * 10 9 * All rights reserved. 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 (at 15 - * your option) any later version. 16 - * 17 - * This program is distributed in the hope that it will be useful, but 18 - * WITHOUT ANY WARRANTY; without even the implied warranty of 19 - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 20 - * NON INFRINGEMENT. See the GNU General Public License for more 21 - * details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 10 * 27 11 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> 28 12 * ··· 64 78 int shpchp_unconfigure_device(struct slot *p_slot) 65 79 { 66 80 int rc = 0; 67 - u8 bctl = 0; 68 81 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 69 82 struct pci_dev *dev, *temp; 70 83 struct controller *ctrl = p_slot->ctrl; ··· 78 93 continue; 79 94 80 95 pci_dev_get(dev); 81 - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 82 - pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl); 83 - if (bctl & PCI_BRIDGE_CTL_VGA) { 84 - ctrl_err(ctrl, 85 - "Cannot remove display device %s\n", 86 - pci_name(dev)); 87 - pci_dev_put(dev); 88 - rc = -EINVAL; 89 - break; 90 - } 91 - } 92 96 pci_stop_and_remove_bus_device(dev); 93 97 pci_dev_put(dev); 94 98 }
+1 -15
drivers/pci/hotplug/shpchp_sysfs.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Compaq Hot Plug Controller Driver 3 4 * ··· 7 6 * Copyright (c) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <greg@kroah.com> 27 11 *
+6 -5
drivers/pci/iov.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/iov.c 3 4 * ··· 260 259 nres++; 261 260 } 262 261 if (nres != iov->nres) { 263 - dev_err(&dev->dev, "not enough MMIO resources for SR-IOV\n"); 262 + pci_err(dev, "not enough MMIO resources for SR-IOV\n"); 264 263 return -ENOMEM; 265 264 } 266 265 267 266 bus = pci_iov_virtfn_bus(dev, nr_virtfn - 1); 268 267 if (bus > dev->bus->busn_res.end) { 269 - dev_err(&dev->dev, "can't enable %d VFs (bus %02x out of range of %pR)\n", 268 + pci_err(dev, "can't enable %d VFs (bus %02x out of range of %pR)\n", 270 269 nr_virtfn, bus, &dev->bus->busn_res); 271 270 return -ENOMEM; 272 271 } 273 272 274 273 if (pci_enable_resources(dev, bars)) { 275 - dev_err(&dev->dev, "SR-IOV: IOV BARS not allocated\n"); 274 + pci_err(dev, "SR-IOV: IOV BARS not allocated\n"); 276 275 return -ENOMEM; 277 276 } 278 277 ··· 299 298 300 299 rc = pcibios_sriov_enable(dev, initial); 301 300 if (rc) { 302 - dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", rc); 301 + pci_err(dev, "failure %d from pcibios_sriov_enable()\n", rc); 303 302 goto err_pcibios; 304 303 } 305 304 ··· 433 432 } 434 433 iov->barsz[i] = resource_size(res); 435 434 res->end = res->start + resource_size(res) * total - 1; 436 - dev_info(&dev->dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n", 435 + pci_info(dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n", 437 436 i, res, i, total); 438 437 i += bar64; 439 438 nres++;
+3 -4
drivers/pci/irq.c
··· 16 16 { 17 17 struct pci_dev *parent = to_pci_dev(pdev->dev.parent); 18 18 19 - dev_err(&pdev->dev, 20 - "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", 19 + pci_err(pdev, "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", 21 20 dev_name(&parent->dev), parent->vendor, parent->device); 22 - dev_err(&pdev->dev, "%s\n", reason); 23 - dev_err(&pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); 21 + pci_err(pdev, "%s\n", reason); 22 + pci_err(pdev, "Please report to linux-kernel@vger.kernel.org\n"); 24 23 WARN_ON(1); 25 24 } 26 25
+1 -4
drivers/pci/mmap.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * mmap.c — generic PCI resource mmap helper 3 4 * 4 5 * Copyright © 2017 Amazon.com, Inc. or its affiliates. 5 6 * 6 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 10 #include <linux/kernel.h>
+4 -4
drivers/pci/msi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * File: msi.c 3 4 * Purpose: PCI Message Signaled Interrupt (MSI) ··· 579 578 for_each_pci_msi_entry(entry, dev) { 580 579 if (!dev->no_64bit_msi || !entry->msg.address_hi) 581 580 continue; 582 - dev_err(&dev->dev, "Device has broken 64-bit MSI but arch" 581 + pci_err(dev, "Device has broken 64-bit MSI but arch" 583 582 " tried to assign one above 4G\n"); 584 583 return -EIO; 585 584 } ··· 963 962 964 963 /* Check whether driver already requested for MSI irq */ 965 964 if (dev->msi_enabled) { 966 - dev_info(&dev->dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); 965 + pci_info(dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); 967 966 return -EINVAL; 968 967 } 969 968 return msix_capability_init(dev, entries, nvec, affd); ··· 1033 1032 1034 1033 /* Check whether driver already requested MSI-X irqs */ 1035 1034 if (dev->msix_enabled) { 1036 - dev_info(&dev->dev, 1037 - "can't enable MSI (MSI-X already enabled)\n"); 1035 + pci_info(dev, "can't enable MSI (MSI-X already enabled)\n"); 1038 1036 return -EINVAL; 1039 1037 } 1040 1038
+564 -7
drivers/pci/of.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * PCI <-> OF mapping helpers 3 4 * 4 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 9 #include <linux/irqdomain.h> 13 10 #include <linux/kernel.h> 14 11 #include <linux/pci.h> 15 12 #include <linux/of.h> 16 13 #include <linux/of_irq.h> 14 + #include <linux/of_address.h> 17 15 #include <linux/of_pci.h> 18 16 #include "pci.h" 19 17 ··· 49 51 if (WARN_ON(bus->self || bus->parent)) 50 52 return NULL; 51 53 52 - /* Look for a node pointer in either the intermediary device we 53 - * create above the root bus or it's own parent. Normally only 54 + /* 55 + * Look for a node pointer in either the intermediary device we 56 + * create above the root bus or its own parent. Normally only 54 57 * the later is populated. 55 58 */ 56 59 if (bus->bridge->of_node) ··· 87 88 return NULL; 88 89 #endif 89 90 } 91 + 92 + static inline int __of_pci_pci_compare(struct device_node *node, 93 + unsigned int data) 94 + { 95 + int devfn; 96 + 97 + devfn = of_pci_get_devfn(node); 98 + if (devfn < 0) 99 + return 0; 100 + 101 + return devfn == data; 102 + } 103 + 104 + struct device_node *of_pci_find_child_device(struct device_node *parent, 105 + unsigned int devfn) 106 + { 107 + struct device_node *node, *node2; 108 + 109 + for_each_child_of_node(parent, node) { 110 + if (__of_pci_pci_compare(node, devfn)) 111 + return node; 112 + /* 113 + * Some OFs create a parent node "multifunc-device" as 114 + * a fake root for all functions of a multi-function 115 + * device we go down them as well. 116 + */ 117 + if (!strcmp(node->name, "multifunc-device")) { 118 + for_each_child_of_node(node, node2) { 119 + if (__of_pci_pci_compare(node2, devfn)) { 120 + of_node_put(node); 121 + return node2; 122 + } 123 + } 124 + } 125 + } 126 + return NULL; 127 + } 128 + EXPORT_SYMBOL_GPL(of_pci_find_child_device); 129 + 130 + /** 131 + * of_pci_get_devfn() - Get device and function numbers for a device node 132 + * @np: device node 133 + * 134 + * Parses a standard 5-cell PCI resource and returns an 8-bit value that can 135 + * be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device 136 + * and function numbers respectively. On error a negative error code is 137 + * returned. 138 + */ 139 + int of_pci_get_devfn(struct device_node *np) 140 + { 141 + u32 reg[5]; 142 + int error; 143 + 144 + error = of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg)); 145 + if (error) 146 + return error; 147 + 148 + return (reg[0] >> 8) & 0xff; 149 + } 150 + EXPORT_SYMBOL_GPL(of_pci_get_devfn); 151 + 152 + /** 153 + * of_pci_parse_bus_range() - parse the bus-range property of a PCI device 154 + * @node: device node 155 + * @res: address to a struct resource to return the bus-range 156 + * 157 + * Returns 0 on success or a negative error-code on failure. 158 + */ 159 + int of_pci_parse_bus_range(struct device_node *node, struct resource *res) 160 + { 161 + u32 bus_range[2]; 162 + int error; 163 + 164 + error = of_property_read_u32_array(node, "bus-range", bus_range, 165 + ARRAY_SIZE(bus_range)); 166 + if (error) 167 + return error; 168 + 169 + res->name = node->name; 170 + res->start = bus_range[0]; 171 + res->end = bus_range[1]; 172 + res->flags = IORESOURCE_BUS; 173 + 174 + return 0; 175 + } 176 + EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); 177 + 178 + /** 179 + * This function will try to obtain the host bridge domain number by 180 + * finding a property called "linux,pci-domain" of the given device node. 181 + * 182 + * @node: device tree node with the domain information 183 + * 184 + * Returns the associated domain number from DT in the range [0-0xffff], or 185 + * a negative value if the required property is not found. 186 + */ 187 + int of_get_pci_domain_nr(struct device_node *node) 188 + { 189 + u32 domain; 190 + int error; 191 + 192 + error = of_property_read_u32(node, "linux,pci-domain", &domain); 193 + if (error) 194 + return error; 195 + 196 + return (u16)domain; 197 + } 198 + EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); 199 + 200 + /** 201 + * This function will try to find the limitation of link speed by finding 202 + * a property called "max-link-speed" of the given device node. 203 + * 204 + * @node: device tree node with the max link speed information 205 + * 206 + * Returns the associated max link speed from DT, or a negative value if the 207 + * required property is not found or is invalid. 208 + */ 209 + int of_pci_get_max_link_speed(struct device_node *node) 210 + { 211 + u32 max_link_speed; 212 + 213 + if (of_property_read_u32(node, "max-link-speed", &max_link_speed) || 214 + max_link_speed > 4) 215 + return -EINVAL; 216 + 217 + return max_link_speed; 218 + } 219 + EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); 220 + 221 + /** 222 + * of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only 223 + * is present and valid 224 + */ 225 + void of_pci_check_probe_only(void) 226 + { 227 + u32 val; 228 + int ret; 229 + 230 + ret = of_property_read_u32(of_chosen, "linux,pci-probe-only", &val); 231 + if (ret) { 232 + if (ret == -ENODATA || ret == -EOVERFLOW) 233 + pr_warn("linux,pci-probe-only without valid value, ignoring\n"); 234 + return; 235 + } 236 + 237 + if (val) 238 + pci_add_flags(PCI_PROBE_ONLY); 239 + else 240 + pci_clear_flags(PCI_PROBE_ONLY); 241 + 242 + pr_info("PROBE_ONLY %sabled\n", val ? "en" : "dis"); 243 + } 244 + EXPORT_SYMBOL_GPL(of_pci_check_probe_only); 245 + 246 + #if defined(CONFIG_OF_ADDRESS) 247 + /** 248 + * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT 249 + * @dev: device node of the host bridge having the range property 250 + * @busno: bus number associated with the bridge root bus 251 + * @bus_max: maximum number of buses for this bridge 252 + * @resources: list where the range of resources will be added after DT parsing 253 + * @io_base: pointer to a variable that will contain on return the physical 254 + * address for the start of the I/O range. Can be NULL if the caller doesn't 255 + * expect I/O ranges to be present in the device tree. 256 + * 257 + * It is the caller's job to free the @resources list. 258 + * 259 + * This function will parse the "ranges" property of a PCI host bridge device 260 + * node and setup the resource mapping based on its content. It is expected 261 + * that the property conforms with the Power ePAPR document. 262 + * 263 + * It returns zero if the range parsing has been successful or a standard error 264 + * value if it failed. 265 + */ 266 + int of_pci_get_host_bridge_resources(struct device_node *dev, 267 + unsigned char busno, unsigned char bus_max, 268 + struct list_head *resources, resource_size_t *io_base) 269 + { 270 + struct resource_entry *window; 271 + struct resource *res; 272 + struct resource *bus_range; 273 + struct of_pci_range range; 274 + struct of_pci_range_parser parser; 275 + char range_type[4]; 276 + int err; 277 + 278 + if (io_base) 279 + *io_base = (resource_size_t)OF_BAD_ADDR; 280 + 281 + bus_range = kzalloc(sizeof(*bus_range), GFP_KERNEL); 282 + if (!bus_range) 283 + return -ENOMEM; 284 + 285 + pr_info("host bridge %pOF ranges:\n", dev); 286 + 287 + err = of_pci_parse_bus_range(dev, bus_range); 288 + if (err) { 289 + bus_range->start = busno; 290 + bus_range->end = bus_max; 291 + bus_range->flags = IORESOURCE_BUS; 292 + pr_info(" No bus range found for %pOF, using %pR\n", 293 + dev, bus_range); 294 + } else { 295 + if (bus_range->end > bus_range->start + bus_max) 296 + bus_range->end = bus_range->start + bus_max; 297 + } 298 + pci_add_resource(resources, bus_range); 299 + 300 + /* Check for ranges property */ 301 + err = of_pci_range_parser_init(&parser, dev); 302 + if (err) 303 + goto parse_failed; 304 + 305 + pr_debug("Parsing ranges property...\n"); 306 + for_each_of_pci_range(&parser, &range) { 307 + /* Read next ranges element */ 308 + if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_IO) 309 + snprintf(range_type, 4, " IO"); 310 + else if ((range.flags & IORESOURCE_TYPE_BITS) == IORESOURCE_MEM) 311 + snprintf(range_type, 4, "MEM"); 312 + else 313 + snprintf(range_type, 4, "err"); 314 + pr_info(" %s %#010llx..%#010llx -> %#010llx\n", range_type, 315 + range.cpu_addr, range.cpu_addr + range.size - 1, 316 + range.pci_addr); 317 + 318 + /* 319 + * If we failed translation or got a zero-sized region 320 + * then skip this range 321 + */ 322 + if (range.cpu_addr == OF_BAD_ADDR || range.size == 0) 323 + continue; 324 + 325 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 326 + if (!res) { 327 + err = -ENOMEM; 328 + goto parse_failed; 329 + } 330 + 331 + err = of_pci_range_to_resource(&range, dev, res); 332 + if (err) { 333 + kfree(res); 334 + continue; 335 + } 336 + 337 + if (resource_type(res) == IORESOURCE_IO) { 338 + if (!io_base) { 339 + pr_err("I/O range found for %pOF. Please provide an io_base pointer to save CPU base address\n", 340 + dev); 341 + err = -EINVAL; 342 + goto conversion_failed; 343 + } 344 + if (*io_base != (resource_size_t)OF_BAD_ADDR) 345 + pr_warn("More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", 346 + dev); 347 + *io_base = range.cpu_addr; 348 + } 349 + 350 + pci_add_resource_offset(resources, res, res->start - range.pci_addr); 351 + } 352 + 353 + return 0; 354 + 355 + conversion_failed: 356 + kfree(res); 357 + parse_failed: 358 + resource_list_for_each_entry(window, resources) 359 + kfree(window->res); 360 + pci_free_resource_list(resources); 361 + return err; 362 + } 363 + EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources); 364 + #endif /* CONFIG_OF_ADDRESS */ 365 + 366 + /** 367 + * of_pci_map_rid - Translate a requester ID through a downstream mapping. 368 + * @np: root complex device node. 369 + * @rid: PCI requester ID to map. 370 + * @map_name: property name of the map to use. 371 + * @map_mask_name: optional property name of the mask to use. 372 + * @target: optional pointer to a target device node. 373 + * @id_out: optional pointer to receive the translated ID. 374 + * 375 + * Given a PCI requester ID, look up the appropriate implementation-defined 376 + * platform ID and/or the target device which receives transactions on that 377 + * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or 378 + * @id_out may be NULL if only the other is required. If @target points to 379 + * a non-NULL device node pointer, only entries targeting that node will be 380 + * matched; if it points to a NULL value, it will receive the device node of 381 + * the first matching target phandle, with a reference held. 382 + * 383 + * Return: 0 on success or a standard error code on failure. 384 + */ 385 + int of_pci_map_rid(struct device_node *np, u32 rid, 386 + const char *map_name, const char *map_mask_name, 387 + struct device_node **target, u32 *id_out) 388 + { 389 + u32 map_mask, masked_rid; 390 + int map_len; 391 + const __be32 *map = NULL; 392 + 393 + if (!np || !map_name || (!target && !id_out)) 394 + return -EINVAL; 395 + 396 + map = of_get_property(np, map_name, &map_len); 397 + if (!map) { 398 + if (target) 399 + return -ENODEV; 400 + /* Otherwise, no map implies no translation */ 401 + *id_out = rid; 402 + return 0; 403 + } 404 + 405 + if (!map_len || map_len % (4 * sizeof(*map))) { 406 + pr_err("%pOF: Error: Bad %s length: %d\n", np, 407 + map_name, map_len); 408 + return -EINVAL; 409 + } 410 + 411 + /* The default is to select all bits. */ 412 + map_mask = 0xffffffff; 413 + 414 + /* 415 + * Can be overridden by "{iommu,msi}-map-mask" property. 416 + * If of_property_read_u32() fails, the default is used. 417 + */ 418 + if (map_mask_name) 419 + of_property_read_u32(np, map_mask_name, &map_mask); 420 + 421 + masked_rid = map_mask & rid; 422 + for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) { 423 + struct device_node *phandle_node; 424 + u32 rid_base = be32_to_cpup(map + 0); 425 + u32 phandle = be32_to_cpup(map + 1); 426 + u32 out_base = be32_to_cpup(map + 2); 427 + u32 rid_len = be32_to_cpup(map + 3); 428 + 429 + if (rid_base & ~map_mask) { 430 + pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", 431 + np, map_name, map_name, 432 + map_mask, rid_base); 433 + return -EFAULT; 434 + } 435 + 436 + if (masked_rid < rid_base || masked_rid >= rid_base + rid_len) 437 + continue; 438 + 439 + phandle_node = of_find_node_by_phandle(phandle); 440 + if (!phandle_node) 441 + return -ENODEV; 442 + 443 + if (target) { 444 + if (*target) 445 + of_node_put(phandle_node); 446 + else 447 + *target = phandle_node; 448 + 449 + if (*target != phandle_node) 450 + continue; 451 + } 452 + 453 + if (id_out) 454 + *id_out = masked_rid - rid_base + out_base; 455 + 456 + pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", 457 + np, map_name, map_mask, rid_base, out_base, 458 + rid_len, rid, masked_rid - rid_base + out_base); 459 + return 0; 460 + } 461 + 462 + pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n", 463 + np, map_name, rid, target && *target ? *target : NULL); 464 + return -EFAULT; 465 + } 466 + 467 + #if IS_ENABLED(CONFIG_OF_IRQ) 468 + /** 469 + * of_irq_parse_pci - Resolve the interrupt for a PCI device 470 + * @pdev: the device whose interrupt is to be resolved 471 + * @out_irq: structure of_irq filled by this function 472 + * 473 + * This function resolves the PCI interrupt for a given PCI device. If a 474 + * device-node exists for a given pci_dev, it will use normal OF tree 475 + * walking. If not, it will implement standard swizzling and walk up the 476 + * PCI tree until an device-node is found, at which point it will finish 477 + * resolving using the OF tree walking. 478 + */ 479 + static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) 480 + { 481 + struct device_node *dn, *ppnode; 482 + struct pci_dev *ppdev; 483 + __be32 laddr[3]; 484 + u8 pin; 485 + int rc; 486 + 487 + /* 488 + * Check if we have a device node, if yes, fallback to standard 489 + * device tree parsing 490 + */ 491 + dn = pci_device_to_OF_node(pdev); 492 + if (dn) { 493 + rc = of_irq_parse_one(dn, 0, out_irq); 494 + if (!rc) 495 + return rc; 496 + } 497 + 498 + /* 499 + * Ok, we don't, time to have fun. Let's start by building up an 500 + * interrupt spec. we assume #interrupt-cells is 1, which is standard 501 + * for PCI. If you do different, then don't use that routine. 502 + */ 503 + rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin); 504 + if (rc != 0) 505 + goto err; 506 + /* No pin, exit with no error message. */ 507 + if (pin == 0) 508 + return -ENODEV; 509 + 510 + /* Now we walk up the PCI tree */ 511 + for (;;) { 512 + /* Get the pci_dev of our parent */ 513 + ppdev = pdev->bus->self; 514 + 515 + /* Ouch, it's a host bridge... */ 516 + if (ppdev == NULL) { 517 + ppnode = pci_bus_to_OF_node(pdev->bus); 518 + 519 + /* No node for host bridge ? give up */ 520 + if (ppnode == NULL) { 521 + rc = -EINVAL; 522 + goto err; 523 + } 524 + } else { 525 + /* We found a P2P bridge, check if it has a node */ 526 + ppnode = pci_device_to_OF_node(ppdev); 527 + } 528 + 529 + /* 530 + * Ok, we have found a parent with a device-node, hand over to 531 + * the OF parsing code. 532 + * We build a unit address from the linux device to be used for 533 + * resolution. Note that we use the linux bus number which may 534 + * not match your firmware bus numbering. 535 + * Fortunately, in most cases, interrupt-map-mask doesn't 536 + * include the bus number as part of the matching. 537 + * You should still be careful about that though if you intend 538 + * to rely on this function (you ship a firmware that doesn't 539 + * create device nodes for all PCI devices). 540 + */ 541 + if (ppnode) 542 + break; 543 + 544 + /* 545 + * We can only get here if we hit a P2P bridge with no node; 546 + * let's do standard swizzling and try again 547 + */ 548 + pin = pci_swizzle_interrupt_pin(pdev, pin); 549 + pdev = ppdev; 550 + } 551 + 552 + out_irq->np = ppnode; 553 + out_irq->args_count = 1; 554 + out_irq->args[0] = pin; 555 + laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); 556 + laddr[1] = laddr[2] = cpu_to_be32(0); 557 + rc = of_irq_parse_raw(laddr, out_irq); 558 + if (rc) 559 + goto err; 560 + return 0; 561 + err: 562 + if (rc == -ENOENT) { 563 + dev_warn(&pdev->dev, 564 + "%s: no interrupt-map found, INTx interrupts not available\n", 565 + __func__); 566 + pr_warn_once("%s: possibly some PCI slots don't have level triggered interrupts capability\n", 567 + __func__); 568 + } else { 569 + dev_err(&pdev->dev, "%s: failed with rc=%d\n", __func__, rc); 570 + } 571 + return rc; 572 + } 573 + 574 + /** 575 + * of_irq_parse_and_map_pci() - Decode a PCI IRQ from the device tree and map to a VIRQ 576 + * @dev: The PCI device needing an IRQ 577 + * @slot: PCI slot number; passed when used as map_irq callback. Unused 578 + * @pin: PCI IRQ pin number; passed when used as map_irq callback. Unused 579 + * 580 + * @slot and @pin are unused, but included in the function so that this 581 + * function can be used directly as the map_irq callback to 582 + * pci_assign_irq() and struct pci_host_bridge.map_irq pointer 583 + */ 584 + int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) 585 + { 586 + struct of_phandle_args oirq; 587 + int ret; 588 + 589 + ret = of_irq_parse_pci(dev, &oirq); 590 + if (ret) 591 + return 0; /* Proper return code 0 == NO_IRQ */ 592 + 593 + return irq_create_of_mapping(&oirq); 594 + } 595 + EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci); 596 + #endif /* CONFIG_OF_IRQ */ 597 + 598 + int pci_parse_request_of_pci_ranges(struct device *dev, 599 + struct list_head *resources, 600 + struct resource **bus_range) 601 + { 602 + int err, res_valid = 0; 603 + struct device_node *np = dev->of_node; 604 + resource_size_t iobase; 605 + struct resource_entry *win, *tmp; 606 + 607 + INIT_LIST_HEAD(resources); 608 + err = of_pci_get_host_bridge_resources(np, 0, 0xff, resources, &iobase); 609 + if (err) 610 + return err; 611 + 612 + err = devm_request_pci_bus_resources(dev, resources); 613 + if (err) 614 + goto out_release_res; 615 + 616 + resource_list_for_each_entry_safe(win, tmp, resources) { 617 + struct resource *res = win->res; 618 + 619 + switch (resource_type(res)) { 620 + case IORESOURCE_IO: 621 + err = pci_remap_iospace(res, iobase); 622 + if (err) { 623 + dev_warn(dev, "error %d: failed to map resource %pR\n", 624 + err, res); 625 + resource_list_destroy_entry(win); 626 + } 627 + break; 628 + case IORESOURCE_MEM: 629 + res_valid |= !(res->flags & IORESOURCE_PREFETCH); 630 + break; 631 + case IORESOURCE_BUS: 632 + if (bus_range) 633 + *bus_range = res; 634 + break; 635 + } 636 + } 637 + 638 + if (res_valid) 639 + return 0; 640 + 641 + dev_err(dev, "non-prefetchable memory resource required\n"); 642 + err = -EINVAL; 643 + 644 + out_release_res: 645 + pci_free_resource_list(resources); 646 + return err; 647 + } 648 +
+2 -1
drivers/pci/pci-acpi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * File: pci-acpi.c 3 4 * Purpose: Provide PCI support in ACPI ··· 543 542 } 544 543 545 544 if (!error) 546 - dev_dbg(&dev->dev, "power state changed by ACPI to %s\n", 545 + pci_dbg(dev, "power state changed by ACPI to %s\n", 547 546 acpi_power_state_string(state_conv[state])); 548 547 549 548 return error;
+1 -3
drivers/pci/pci-driver.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/pci-driver.c 3 4 * 4 5 * (C) Copyright 2002-2004, 2007 Greg Kroah-Hartman <greg@kroah.com> 5 6 * (C) Copyright 2007 Novell Inc. 6 - * 7 - * Released under the GPL v2 only. 8 - * 9 7 */ 10 8 11 9 #include <linux/pci.h>
+1 -4
drivers/pci/pci-mid.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Intel MID platform PM support 3 4 * 4 5 * Copyright (C) 2016, Intel Corporation 5 6 * 6 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 10 #include <linux/init.h>
+2 -3
drivers/pci/pci-stub.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* pci-stub - simple stub driver to reserve a pci device 2 3 * 3 4 * Copyright (C) 2008 Red Hat, Inc. 4 5 * Author: 5 6 * Chris Wright 6 - * 7 - * This work is licensed under the terms of the GNU GPL, version 2. 8 7 * 9 8 * Usage is simple, allocate a new id to the stub driver and bind the 10 9 * device to it. For example: ··· 27 28 28 29 static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) 29 30 { 30 - dev_info(&dev->dev, "claimed by stub\n"); 31 + pci_info(dev, "claimed by stub\n"); 31 32 return 0; 32 33 } 33 34
+18 -12
drivers/pci/pci-sysfs.c
··· 278 278 } 279 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 291 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, 282 292 char *buf) 283 293 { ··· 358 348 return -EINVAL; 359 349 360 350 add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); 361 - dev_alert(&pdev->dev, FW_BUG "Overriding NUMA node to %d. Contact your vendor for updates.", 351 + pci_alert(pdev, FW_BUG "Overriding NUMA node to %d. Contact your vendor for updates.", 362 352 node); 363 353 364 354 dev->numa_node = node; ··· 421 411 */ 422 412 if (!subordinate) { 423 413 pdev->no_msi = !val; 424 - dev_info(&pdev->dev, "MSI/MSI-X %s for future drivers\n", 414 + pci_info(pdev, "MSI/MSI-X %s for future drivers\n", 425 415 val ? "allowed" : "disallowed"); 426 416 return count; 427 417 } ··· 623 613 624 614 /* is PF driver loaded w/callback */ 625 615 if (!pdev->driver || !pdev->driver->sriov_configure) { 626 - dev_info(&pdev->dev, "Driver doesn't support SRIOV configuration via sysfs\n"); 616 + pci_info(pdev, "Driver doesn't support SRIOV configuration via sysfs\n"); 627 617 ret = -ENOENT; 628 618 goto exit; 629 619 } ··· 636 626 637 627 /* enable VFs */ 638 628 if (pdev->sriov->num_VFs) { 639 - dev_warn(&pdev->dev, "%d VFs already enabled. Disable before enabling %d VFs\n", 629 + pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", 640 630 pdev->sriov->num_VFs, num_vfs); 641 631 ret = -EBUSY; 642 632 goto exit; ··· 647 637 goto exit; 648 638 649 639 if (ret != num_vfs) 650 - dev_warn(&pdev->dev, "%d VFs requested; only %d enabled\n", 640 + pci_warn(pdev, "%d VFs requested; only %d enabled\n", 651 641 num_vfs, ret); 652 642 653 643 exit: ··· 796 786 &dev_attr_devspec.attr, 797 787 #endif 798 788 &dev_attr_driver_override.attr, 789 + &dev_attr_ari_enabled.attr, 799 790 NULL, 800 791 }; 801 792 ··· 1227 1216 if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) 1228 1217 return -EINVAL; 1229 1218 1230 - if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS)) { 1231 - 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", 1232 - current->comm, vma->vm_end-vma->vm_start, vma->vm_pgoff, 1233 - pci_name(pdev), bar, 1234 - (u64)pci_resource_start(pdev, bar), 1235 - (u64)pci_resource_len(pdev, bar)); 1219 + if (!pci_mmap_fits(pdev, bar, vma, PCI_MMAP_SYSFS)) 1236 1220 return -EINVAL; 1237 - } 1221 + 1238 1222 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; 1239 1223 1240 1224 return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine);
+114 -44
drivers/pci/pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCI Bus Services, see include/linux/pci.h for further explanation. 3 4 * ··· 157 156 * Make sure the BAR is actually a memory resource, not an IO resource 158 157 */ 159 158 if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { 160 - dev_warn(&pdev->dev, "can't ioremap BAR %d: %pR\n", bar, res); 159 + pci_warn(pdev, "can't ioremap BAR %d: %pR\n", bar, res); 161 160 return NULL; 162 161 } 163 162 return ioremap_nocache(res->start, resource_size(res)); ··· 649 648 */ 650 649 if (state != PCI_D0 && dev->current_state <= PCI_D3cold 651 650 && dev->current_state > state) { 652 - dev_err(&dev->dev, "invalid power transition (from state %d to %d)\n", 651 + pci_err(dev, "invalid power transition (from state %d to %d)\n", 653 652 dev->current_state, state); 654 653 return -EINVAL; 655 654 } ··· 697 696 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 698 697 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); 699 698 if (dev->current_state != state && printk_ratelimit()) 700 - dev_info(&dev->dev, "Refused to change power state, currently in D%d\n", 699 + pci_info(dev, "Refused to change power state, currently in D%d\n", 701 700 dev->current_state); 702 701 703 702 /* ··· 971 970 case PM_EVENT_HIBERNATE: 972 971 return PCI_D3hot; 973 972 default: 974 - dev_info(&dev->dev, "unrecognized suspend event %d\n", 973 + pci_info(dev, "unrecognized suspend event %d\n", 975 974 state.event); 976 975 BUG(); 977 976 } ··· 1014 1013 1015 1014 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); 1016 1015 if (!save_state) { 1017 - dev_err(&dev->dev, "buffer not found in %s\n", __func__); 1016 + pci_err(dev, "buffer not found in %s\n", __func__); 1018 1017 return -ENOMEM; 1019 1018 } 1020 1019 ··· 1062 1061 1063 1062 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX); 1064 1063 if (!save_state) { 1065 - dev_err(&dev->dev, "buffer not found in %s\n", __func__); 1064 + pci_err(dev, "buffer not found in %s\n", __func__); 1066 1065 return -ENOMEM; 1067 1066 } 1068 1067 ··· 1122 1121 return; 1123 1122 1124 1123 for (;;) { 1125 - dev_dbg(&pdev->dev, "restoring config space at offset %#x (was %#x, writing %#x)\n", 1124 + pci_dbg(pdev, "restoring config space at offset %#x (was %#x, writing %#x)\n", 1126 1125 offset, val, saved_val); 1127 1126 pci_write_config_dword(pdev, offset, saved_val); 1128 1127 if (retry-- <= 0) ··· 1359 1358 1360 1359 retval = pci_enable_device(dev); 1361 1360 if (retval) 1362 - dev_err(&dev->dev, "Error enabling bridge (%d), continuing\n", 1361 + pci_err(dev, "Error enabling bridge (%d), continuing\n", 1363 1362 retval); 1364 1363 pci_set_master(dev); 1365 1364 } ··· 1868 1867 pme_dev = kmalloc(sizeof(struct pci_pme_device), 1869 1868 GFP_KERNEL); 1870 1869 if (!pme_dev) { 1871 - dev_warn(&dev->dev, "can't enable PME#\n"); 1870 + pci_warn(dev, "can't enable PME#\n"); 1872 1871 return; 1873 1872 } 1874 1873 pme_dev->dev = dev; ··· 1892 1891 } 1893 1892 } 1894 1893 1895 - dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled"); 1894 + pci_dbg(dev, "PME# %s\n", enable ? "enabled" : "disabled"); 1896 1895 } 1897 1896 EXPORT_SYMBOL(pci_pme_active); 1898 1897 ··· 2429 2428 pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc); 2430 2429 2431 2430 if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { 2432 - dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", 2431 + pci_err(dev, "unsupported PM cap regs version (%u)\n", 2433 2432 pmc & PCI_PM_CAP_VER_MASK); 2434 2433 return; 2435 2434 } ··· 2449 2448 dev->d2_support = true; 2450 2449 2451 2450 if (dev->d1_support || dev->d2_support) 2452 - dev_printk(KERN_DEBUG, &dev->dev, "supports%s%s\n", 2451 + pci_printk(KERN_DEBUG, dev, "supports%s%s\n", 2453 2452 dev->d1_support ? " D1" : "", 2454 2453 dev->d2_support ? " D2" : ""); 2455 2454 } 2456 2455 2457 2456 pmc &= PCI_PM_CAP_PME_MASK; 2458 2457 if (pmc) { 2459 - dev_printk(KERN_DEBUG, &dev->dev, 2460 - "PME# supported from%s%s%s%s%s\n", 2458 + pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", 2461 2459 (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", 2462 2460 (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", 2463 2461 (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "", ··· 2548 2548 2549 2549 res = pci_ea_get_resource(dev, bei, prop); 2550 2550 if (!res) { 2551 - dev_err(&dev->dev, "Unsupported EA entry BEI: %u\n", bei); 2551 + pci_err(dev, "Unsupported EA entry BEI: %u\n", bei); 2552 2552 goto out; 2553 2553 } 2554 2554 2555 2555 flags = pci_ea_flags(dev, prop); 2556 2556 if (!flags) { 2557 - dev_err(&dev->dev, "Unsupported EA properties: %#x\n", prop); 2557 + pci_err(dev, "Unsupported EA properties: %#x\n", prop); 2558 2558 goto out; 2559 2559 } 2560 2560 ··· 2604 2604 } 2605 2605 2606 2606 if (end < start) { 2607 - dev_err(&dev->dev, "EA Entry crosses address boundary\n"); 2607 + pci_err(dev, "EA Entry crosses address boundary\n"); 2608 2608 goto out; 2609 2609 } 2610 2610 2611 2611 if (ent_size != ent_offset - offset) { 2612 - dev_err(&dev->dev, 2613 - "EA Entry Size (%d) does not match length read (%d)\n", 2612 + pci_err(dev, "EA Entry Size (%d) does not match length read (%d)\n", 2614 2613 ent_size, ent_offset - offset); 2615 2614 goto out; 2616 2615 } ··· 2620 2621 res->flags = flags; 2621 2622 2622 2623 if (bei <= PCI_EA_BEI_BAR5) 2623 - dev_printk(KERN_DEBUG, &dev->dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", 2624 + pci_printk(KERN_DEBUG, dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", 2624 2625 bei, res, prop); 2625 2626 else if (bei == PCI_EA_BEI_ROM) 2626 - dev_printk(KERN_DEBUG, &dev->dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", 2627 + pci_printk(KERN_DEBUG, dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", 2627 2628 res, prop); 2628 2629 else if (bei >= PCI_EA_BEI_VF_BAR0 && bei <= PCI_EA_BEI_VF_BAR5) 2629 - dev_printk(KERN_DEBUG, &dev->dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", 2630 + pci_printk(KERN_DEBUG, dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", 2630 2631 bei - PCI_EA_BEI_VF_BAR0, res, prop); 2631 2632 else 2632 - dev_printk(KERN_DEBUG, &dev->dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", 2633 + pci_printk(KERN_DEBUG, dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", 2633 2634 bei, res, prop); 2634 2635 2635 2636 out: ··· 2726 2727 error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, 2727 2728 PCI_EXP_SAVE_REGS * sizeof(u16)); 2728 2729 if (error) 2729 - dev_err(&dev->dev, 2730 - "unable to preallocate PCI Express save buffer\n"); 2730 + pci_err(dev, "unable to preallocate PCI Express save buffer\n"); 2731 2731 2732 2732 error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16)); 2733 2733 if (error) 2734 - dev_err(&dev->dev, 2735 - "unable to preallocate PCI-X save buffer\n"); 2734 + pci_err(dev, "unable to preallocate PCI-X save buffer\n"); 2736 2735 2737 2736 pci_allocate_vc_save_buffers(dev); 2738 2737 } ··· 3067 3070 } 3068 3071 3069 3072 /** 3073 + * pci_enable_atomic_ops_to_root - enable AtomicOp requests to root port 3074 + * @dev: the PCI device 3075 + * @cap_mask: mask of desired AtomicOp sizes, including one or more of: 3076 + * PCI_EXP_DEVCAP2_ATOMIC_COMP32 3077 + * PCI_EXP_DEVCAP2_ATOMIC_COMP64 3078 + * PCI_EXP_DEVCAP2_ATOMIC_COMP128 3079 + * 3080 + * Return 0 if all upstream bridges support AtomicOp routing, egress 3081 + * blocking is disabled on all upstream ports, and the root port supports 3082 + * the requested completion capabilities (32-bit, 64-bit and/or 128-bit 3083 + * AtomicOp completion), or negative otherwise. 3084 + */ 3085 + int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) 3086 + { 3087 + struct pci_bus *bus = dev->bus; 3088 + struct pci_dev *bridge; 3089 + u32 cap, ctl2; 3090 + 3091 + if (!pci_is_pcie(dev)) 3092 + return -EINVAL; 3093 + 3094 + /* 3095 + * Per PCIe r4.0, sec 6.15, endpoints and root ports may be 3096 + * AtomicOp requesters. For now, we only support endpoints as 3097 + * requesters and root ports as completers. No endpoints as 3098 + * completers, and no peer-to-peer. 3099 + */ 3100 + 3101 + switch (pci_pcie_type(dev)) { 3102 + case PCI_EXP_TYPE_ENDPOINT: 3103 + case PCI_EXP_TYPE_LEG_END: 3104 + case PCI_EXP_TYPE_RC_END: 3105 + break; 3106 + default: 3107 + return -EINVAL; 3108 + } 3109 + 3110 + while (bus->parent) { 3111 + bridge = bus->self; 3112 + 3113 + pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap); 3114 + 3115 + switch (pci_pcie_type(bridge)) { 3116 + /* Ensure switch ports support AtomicOp routing */ 3117 + case PCI_EXP_TYPE_UPSTREAM: 3118 + case PCI_EXP_TYPE_DOWNSTREAM: 3119 + if (!(cap & PCI_EXP_DEVCAP2_ATOMIC_ROUTE)) 3120 + return -EINVAL; 3121 + break; 3122 + 3123 + /* Ensure root port supports all the sizes we care about */ 3124 + case PCI_EXP_TYPE_ROOT_PORT: 3125 + if ((cap & cap_mask) != cap_mask) 3126 + return -EINVAL; 3127 + break; 3128 + } 3129 + 3130 + /* Ensure upstream ports don't block AtomicOps on egress */ 3131 + if (!bridge->has_secondary_link) { 3132 + pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, 3133 + &ctl2); 3134 + if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK) 3135 + return -EINVAL; 3136 + } 3137 + 3138 + bus = bus->parent; 3139 + } 3140 + 3141 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, 3142 + PCI_EXP_DEVCTL2_ATOMIC_REQ); 3143 + return 0; 3144 + } 3145 + EXPORT_SYMBOL(pci_enable_atomic_ops_to_root); 3146 + 3147 + /** 3070 3148 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge 3071 3149 * @dev: the PCI device 3072 3150 * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD) ··· 3274 3202 return 0; 3275 3203 3276 3204 err_out: 3277 - dev_warn(&pdev->dev, "BAR %d: can't reserve %pR\n", bar, 3205 + pci_warn(pdev, "BAR %d: can't reserve %pR\n", bar, 3278 3206 &pdev->resource[bar]); 3279 3207 return -EBUSY; 3280 3208 } ··· 3697 3625 else 3698 3626 cmd = old_cmd & ~PCI_COMMAND_MASTER; 3699 3627 if (cmd != old_cmd) { 3700 - dev_dbg(&dev->dev, "%s bus mastering\n", 3628 + pci_dbg(dev, "%s bus mastering\n", 3701 3629 enable ? "enabling" : "disabling"); 3702 3630 pci_write_config_word(dev, PCI_COMMAND, cmd); 3703 3631 } ··· 3798 3726 if (cacheline_size == pci_cache_line_size) 3799 3727 return 0; 3800 3728 3801 - dev_printk(KERN_DEBUG, &dev->dev, "cache line size of %d is not supported\n", 3729 + pci_printk(KERN_DEBUG, dev, "cache line size of %d is not supported\n", 3802 3730 pci_cache_line_size << 2); 3803 3731 3804 3732 return -EINVAL; ··· 3827 3755 3828 3756 pci_read_config_word(dev, PCI_COMMAND, &cmd); 3829 3757 if (!(cmd & PCI_COMMAND_INVALIDATE)) { 3830 - dev_dbg(&dev->dev, "enabling Mem-Wr-Inval\n"); 3758 + pci_dbg(dev, "enabling Mem-Wr-Inval\n"); 3831 3759 cmd |= PCI_COMMAND_INVALIDATE; 3832 3760 pci_write_config_word(dev, PCI_COMMAND, cmd); 3833 3761 } ··· 4044 3972 pci_read_config_dword(dev, PCI_COMMAND, &id); 4045 3973 while (id == ~0) { 4046 3974 if (delay > timeout) { 4047 - dev_warn(&dev->dev, "not ready %dms after FLR; giving up\n", 3975 + pci_warn(dev, "not ready %dms after FLR; giving up\n", 4048 3976 100 + delay - 1); 4049 3977 return; 4050 3978 } 4051 3979 4052 3980 if (delay > 1000) 4053 - dev_info(&dev->dev, "not ready %dms after FLR; waiting\n", 3981 + pci_info(dev, "not ready %dms after FLR; waiting\n", 4054 3982 100 + delay - 1); 4055 3983 4056 3984 msleep(delay); ··· 4059 3987 } 4060 3988 4061 3989 if (delay > 1000) 4062 - dev_info(&dev->dev, "ready %dms after FLR\n", 100 + delay - 1); 3990 + pci_info(dev, "ready %dms after FLR\n", 100 + delay - 1); 4063 3991 } 4064 3992 4065 3993 /** ··· 4091 4019 void pcie_flr(struct pci_dev *dev) 4092 4020 { 4093 4021 if (!pci_wait_for_pending_transaction(dev)) 4094 - dev_err(&dev->dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); 4022 + pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); 4095 4023 4096 4024 pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); 4097 4025 pci_flr_wait(dev); ··· 4124 4052 */ 4125 4053 if (!pci_wait_for_pending(dev, pos + PCI_AF_CTRL, 4126 4054 PCI_AF_STATUS_TP << 8)) 4127 - dev_err(&dev->dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); 4055 + pci_err(dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); 4128 4056 4129 4057 pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); 4130 4058 pci_flr_wait(dev); ··· 5247 5175 dev->dma_alias_mask = kcalloc(BITS_TO_LONGS(U8_MAX), 5248 5176 sizeof(long), GFP_KERNEL); 5249 5177 if (!dev->dma_alias_mask) { 5250 - dev_warn(&dev->dev, "Unable to allocate DMA alias mask\n"); 5178 + pci_warn(dev, "Unable to allocate DMA alias mask\n"); 5251 5179 return; 5252 5180 } 5253 5181 5254 5182 set_bit(devfn, dev->dma_alias_mask); 5255 - dev_info(&dev->dev, "Enabling fixed DMA alias to %02x.%d\n", 5183 + pci_info(dev, "Enabling fixed DMA alias to %02x.%d\n", 5256 5184 PCI_SLOT(devfn), PCI_FUNC(devfn)); 5257 5185 } 5258 5186 ··· 5401 5329 return; 5402 5330 5403 5331 if (r->flags & IORESOURCE_PCI_FIXED) { 5404 - dev_info(&dev->dev, "BAR%d %pR: ignoring requested alignment %#llx\n", 5332 + pci_info(dev, "BAR%d %pR: ignoring requested alignment %#llx\n", 5405 5333 bar, r, (unsigned long long)align); 5406 5334 return; 5407 5335 } ··· 5438 5366 * devices and we use the second. 5439 5367 */ 5440 5368 5441 - dev_info(&dev->dev, "BAR%d %pR: requesting alignment to %#llx\n", 5369 + pci_info(dev, "BAR%d %pR: requesting alignment to %#llx\n", 5442 5370 bar, r, (unsigned long long)align); 5443 5371 5444 5372 if (resize) { ··· 5484 5412 5485 5413 if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && 5486 5414 (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) { 5487 - dev_warn(&dev->dev, 5488 - "Can't reassign resources to host bridge.\n"); 5415 + pci_warn(dev, "Can't reassign resources to host bridge\n"); 5489 5416 return; 5490 5417 } 5491 5418 5492 - dev_info(&dev->dev, 5493 - "Disabling memory decoding and releasing memory resources.\n"); 5419 + pci_info(dev, "Disabling memory decoding and releasing memory resources\n"); 5494 5420 pci_read_config_word(dev, PCI_COMMAND, &command); 5495 5421 command &= ~PCI_COMMAND_MEMORY; 5496 5422 pci_write_config_word(dev, PCI_COMMAND, command);
+47 -27
drivers/pci/pci.h
··· 38 38 * struct pci_platform_pm_ops - Firmware PM callbacks 39 39 * 40 40 * @is_manageable: returns 'true' if given device is power manageable by the 41 - * platform firmware 41 + * platform firmware 42 42 * 43 43 * @set_state: invokes the platform firmware to set the device's power state 44 44 * 45 45 * @get_state: queries the platform firmware for a device's current power state 46 46 * 47 47 * @choose_state: returns PCI power state of given device preferred by the 48 - * platform; to be used during system-wide transitions from a 49 - * sleeping state to the working state and vice versa 48 + * platform; to be used during system-wide transitions from a 49 + * sleeping state to the working state and vice versa 50 50 * 51 51 * @set_wakeup: enables/disables wakeup capability for the device 52 52 * 53 53 * @need_resume: returns 'true' if the given device (which is currently 54 - * suspended) needs to be resumed to be configured for system 55 - * wakeup. 54 + * suspended) needs to be resumed to be configured for system 55 + * wakeup. 56 56 * 57 57 * If given platform is generally capable of power managing PCI devices, all of 58 58 * these callbacks are mandatory. ··· 112 112 113 113 struct pci_vpd { 114 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 116 struct mutex lock; 117 117 unsigned int len; 118 118 u16 flag; ··· 199 199 200 200 /** 201 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 203 * @id: single PCI device id structure to match 204 204 * @dev: the PCI device structure to match against 205 205 * ··· 231 231 232 232 enum pci_bar_type { 233 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 235 pci_bar_mem32, /* A 32-bit memory BAR */ 236 236 pci_bar_mem64, /* A 64-bit memory BAR */ 237 237 }; ··· 255 255 256 256 /* Single Root I/O Virtualization */ 257 257 struct pci_sriov { 258 - int pos; /* capability position */ 259 - int nres; /* number of resources */ 260 - u32 cap; /* SR-IOV Capabilities */ 261 - u16 ctrl; /* SR-IOV Control */ 262 - u16 total_VFs; /* total VFs associated with the PF */ 263 - u16 initial_VFs; /* initial VFs associated with the PF */ 264 - u16 num_VFs; /* number of VFs available */ 265 - u16 offset; /* first VF Routing ID offset */ 266 - u16 stride; /* following VF stride */ 267 - u16 vf_device; /* VF device ID */ 268 - u32 pgsz; /* page size for BAR alignment */ 269 - u8 link; /* Function Dependency Link */ 270 - u8 max_VF_buses; /* max buses consumed by VFs */ 271 - u16 driver_max_VFs; /* max num VFs driver supports */ 272 - struct pci_dev *dev; /* lowest numbered PF */ 273 - struct pci_dev *self; /* this PF */ 274 - resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ 275 - bool drivers_autoprobe; /* auto probing of VFs by driver */ 258 + int pos; /* Capability position */ 259 + int nres; /* Number of resources */ 260 + u32 cap; /* SR-IOV Capabilities */ 261 + u16 ctrl; /* SR-IOV Control */ 262 + u16 total_VFs; /* Total VFs associated with the PF */ 263 + u16 initial_VFs; /* Initial VFs associated with the PF */ 264 + u16 num_VFs; /* Number of VFs available */ 265 + u16 offset; /* First VF Routing ID offset */ 266 + u16 stride; /* Following VF stride */ 267 + u16 vf_device; /* VF device ID */ 268 + u32 pgsz; /* Page size for BAR alignment */ 269 + u8 link; /* Function Dependency Link */ 270 + u8 max_VF_buses; /* Max buses consumed by VFs */ 271 + u16 driver_max_VFs; /* Max num VFs driver supports */ 272 + struct pci_dev *dev; /* Lowest numbered PF */ 273 + struct pci_dev *self; /* This PF */ 274 + resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ 275 + bool drivers_autoprobe; /* Auto probing of VFs by driver */ 276 276 }; 277 277 278 278 /* pci_dev priv_flags */ ··· 335 335 if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END) 336 336 return pci_sriov_resource_alignment(dev, resno); 337 337 #endif 338 - if (dev->class >> 8 == PCI_CLASS_BRIDGE_CARDBUS) 338 + if (dev->class >> 8 == PCI_CLASS_BRIDGE_CARDBUS) 339 339 return pci_cardbus_resource_alignment(res); 340 340 return resource_alignment(res); 341 341 } 342 342 343 343 void pci_enable_acs(struct pci_dev *dev); 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 344 364 345 365 #ifdef CONFIG_PCIE_PTM 346 366 void pci_ptm_init(struct pci_dev *dev);
+2 -1
drivers/pci/pcie/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI Express Port Bus Configuration 3 4 # ··· 93 92 94 93 config PCIE_DPC 95 94 bool "PCIe Downstream Port Containment support" 96 - depends on PCIEPORTBUS 95 + depends on PCIEPORTBUS && PCIEAER 97 96 default n 98 97 help 99 98 This enables PCI Express Downstream Port Containment (DPC)
+1
drivers/pci/pcie/aer/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI Express Root Port Device AER Configuration 3 4 #
+1
drivers/pci/pcie/aer/Kconfig.debug
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 # 2 3 # PCI Express Root Port Device AER Debug Configuration 3 4 #
+7 -15
drivers/pci/pcie/aer/aer_inject.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe AER software error injection support. 3 4 * ··· 10 9 * 11 10 * Copyright 2009 Intel Corporation. 12 11 * Huang Ying <ying.huang@intel.com> 13 - * 14 - * This program is free software; you can redistribute it and/or 15 - * modify it under the terms of the GNU General Public License 16 - * as published by the Free Software Foundation; version 2 17 - * of the License. 18 - * 19 12 */ 20 13 21 14 #include <linux/module.h> ··· 339 344 return -ENODEV; 340 345 rpdev = pcie_find_root_port(dev); 341 346 if (!rpdev) { 342 - dev_err(&dev->dev, "aer_inject: Root port not found\n"); 347 + pci_err(dev, "aer_inject: Root port not found\n"); 343 348 ret = -ENODEV; 344 349 goto out_put; 345 350 } 346 351 347 352 pos_cap_err = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 348 353 if (!pos_cap_err) { 349 - dev_err(&dev->dev, "aer_inject: Device doesn't support AER\n"); 354 + pci_err(dev, "aer_inject: Device doesn't support AER\n"); 350 355 ret = -EPROTONOSUPPORT; 351 356 goto out_put; 352 357 } ··· 357 362 358 363 rp_pos_cap_err = pci_find_ext_capability(rpdev, PCI_EXT_CAP_ID_ERR); 359 364 if (!rp_pos_cap_err) { 360 - dev_err(&rpdev->dev, 361 - "aer_inject: Root port doesn't support AER\n"); 365 + pci_err(rpdev, "aer_inject: Root port doesn't support AER\n"); 362 366 ret = -EPROTONOSUPPORT; 363 367 goto out_put; 364 368 } ··· 405 411 if (!aer_mask_override && einj->cor_status && 406 412 !(einj->cor_status & ~cor_mask)) { 407 413 ret = -EINVAL; 408 - dev_warn(&dev->dev, 409 - "aer_inject: The correctable error(s) is masked by device\n"); 414 + pci_warn(dev, "aer_inject: The correctable error(s) is masked by device\n"); 410 415 spin_unlock_irqrestore(&inject_lock, flags); 411 416 goto out_put; 412 417 } 413 418 if (!aer_mask_override && einj->uncor_status && 414 419 !(einj->uncor_status & ~uncor_mask)) { 415 420 ret = -EINVAL; 416 - dev_warn(&dev->dev, 417 - "aer_inject: The uncorrectable error(s) is masked by device\n"); 421 + pci_warn(dev, "aer_inject: The uncorrectable error(s) is masked by device\n"); 418 422 spin_unlock_irqrestore(&inject_lock, flags); 419 423 goto out_put; 420 424 } ··· 475 483 einj->cor_status, einj->uncor_status, pci_name(dev)); 476 484 aer_irq(-1, edev); 477 485 } else { 478 - dev_err(&rpdev->dev, "aer_inject: AER device not found\n"); 486 + pci_err(rpdev, "aer_inject: AER device not found\n"); 479 487 ret = -ENODEV; 480 488 } 481 489 out_put:
+2 -5
drivers/pci/pcie/aer/aerdrv.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/pcie/aer/aerdrv.c 3 - * 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 4 * 8 5 * This file implements the AER root port service driver. The driver will 9 6 * register an irq handler. When root port triggers an AER interrupt, the irq ··· 323 326 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); 324 327 325 328 pci_reset_bridge_secondary_bus(dev); 326 - dev_printk(KERN_DEBUG, &dev->dev, "Root Port link has been reset\n"); 329 + pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); 327 330 328 331 /* Clear Root Error Status */ 329 332 pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &reg32);
+13 -18
drivers/pci/pcie/aer/aerdrv_core.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/pcie/aer/aerdrv_core.c 3 - * 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 4 * 8 5 * This file implements the core part of PCIe AER. When a PCIe 9 6 * error is delivered, an error message will be collected and printed to ··· 223 226 pci_walk_bus(parent->subordinate, find_device_iter, e_info); 224 227 225 228 if (!e_info->error_dev_num) { 226 - dev_printk(KERN_DEBUG, &parent->dev, 227 - "can't find device of ID%04x\n", 228 - e_info->id); 229 + pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n", 230 + e_info->id); 229 231 return false; 230 232 } 231 233 return true; ··· 252 256 * of a driver for this device is unaware of 253 257 * its hw state. 254 258 */ 255 - dev_printk(KERN_DEBUG, &dev->dev, "device has %s\n", 259 + pci_printk(KERN_DEBUG, dev, "device has %s\n", 256 260 dev->driver ? 257 261 "no AER-aware driver" : "no driver"); 258 262 } ··· 362 366 { 363 367 struct aer_broadcast_data result_data; 364 368 365 - dev_printk(KERN_DEBUG, &dev->dev, "broadcast %s message\n", error_mesg); 369 + pci_printk(KERN_DEBUG, dev, "broadcast %s message\n", error_mesg); 366 370 result_data.state = state; 367 371 if (cb == report_error_detected) 368 372 result_data.result = PCI_ERS_RESULT_CAN_RECOVER; ··· 411 415 static pci_ers_result_t default_reset_link(struct pci_dev *dev) 412 416 { 413 417 pci_reset_bridge_secondary_bus(dev); 414 - dev_printk(KERN_DEBUG, &dev->dev, "downstream link has been reset\n"); 418 + pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); 415 419 return PCI_ERS_RESULT_RECOVERED; 416 420 } 417 421 ··· 463 467 } else if (udev->has_secondary_link) { 464 468 status = default_reset_link(udev); 465 469 } else { 466 - dev_printk(KERN_DEBUG, &dev->dev, 467 - "no link-reset support at upstream device %s\n", 470 + pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", 468 471 pci_name(udev)); 469 472 return PCI_ERS_RESULT_DISCONNECT; 470 473 } 471 474 472 475 if (status != PCI_ERS_RESULT_RECOVERED) { 473 - dev_printk(KERN_DEBUG, &dev->dev, 474 - "link reset at upstream device %s failed\n", 476 + pci_printk(KERN_DEBUG, dev, "link reset at upstream device %s failed\n", 475 477 pci_name(udev)); 476 478 return PCI_ERS_RESULT_DISCONNECT; 477 479 } ··· 533 539 "resume", 534 540 report_resume); 535 541 536 - dev_info(&dev->dev, "AER: Device recovery successful\n"); 542 + pci_info(dev, "AER: Device recovery successful\n"); 537 543 return; 538 544 539 545 failed: 540 546 pci_uevent_ers(dev, PCI_ERS_RESULT_DISCONNECT); 541 547 /* TODO: Should kernel panic here? */ 542 - dev_info(&dev->dev, "AER: Device recovery failed\n"); 548 + pci_info(dev, "AER: Device recovery failed\n"); 543 549 } 544 550 545 551 /** ··· 630 636 continue; 631 637 } 632 638 cper_print_aer(pdev, entry.severity, entry.regs); 633 - do_recovery(pdev, entry.severity); 639 + if (entry.severity != AER_CORRECTABLE) 640 + do_recovery(pdev, entry.severity); 634 641 pci_dev_put(pdev); 635 642 } 636 643 } ··· 658 663 659 664 /* The device might not support AER */ 660 665 if (!pos) 661 - return 1; 666 + return 0; 662 667 663 668 if (info->severity == AER_CORRECTABLE) { 664 669 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS,
+12 -15
drivers/pci/pcie/aer/aerdrv_errprint.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/pcie/aer/aerdrv_errprint.c 3 - * 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 4 * 8 5 * Format error messages and print them to console. 9 6 * ··· 129 132 static void __print_tlp_header(struct pci_dev *dev, 130 133 struct aer_header_log_regs *t) 131 134 { 132 - dev_err(&dev->dev, " TLP Header: %08x %08x %08x %08x\n", 135 + pci_err(dev, " TLP Header: %08x %08x %08x %08x\n", 133 136 t->dw0, t->dw1, t->dw2, t->dw3); 134 137 } 135 138 ··· 152 155 aer_uncorrectable_error_string[i] : NULL; 153 156 154 157 if (errmsg) 155 - dev_err(&dev->dev, " [%2d] %-22s%s\n", i, errmsg, 158 + pci_err(dev, " [%2d] %-22s%s\n", i, errmsg, 156 159 info->first_error == i ? " (First)" : ""); 157 160 else 158 - dev_err(&dev->dev, " [%2d] Unknown Error Bit%s\n", 161 + pci_err(dev, " [%2d] Unknown Error Bit%s\n", 159 162 i, info->first_error == i ? " (First)" : ""); 160 163 } 161 164 } ··· 166 169 int id = ((dev->bus->number << 8) | dev->devfn); 167 170 168 171 if (!info->status) { 169 - dev_err(&dev->dev, "PCIe Bus Error: severity=%s, type=Unaccessible, id=%04x(Unregistered Agent ID)\n", 172 + pci_err(dev, "PCIe Bus Error: severity=%s, type=Unaccessible, id=%04x(Unregistered Agent ID)\n", 170 173 aer_error_severity_string[info->severity], id); 171 174 goto out; 172 175 } ··· 174 177 layer = AER_GET_LAYER_ERROR(info->severity, info->status); 175 178 agent = AER_GET_AGENT(info->severity, info->status); 176 179 177 - dev_err(&dev->dev, "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", 180 + pci_err(dev, "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", 178 181 aer_error_severity_string[info->severity], 179 182 aer_error_layer[layer], id, aer_agent_string[agent]); 180 183 181 - dev_err(&dev->dev, " device [%04x:%04x] error status/mask=%08x/%08x\n", 184 + pci_err(dev, " device [%04x:%04x] error status/mask=%08x/%08x\n", 182 185 dev->vendor, dev->device, 183 186 info->status, info->mask); 184 187 ··· 189 192 190 193 out: 191 194 if (info->id && info->error_dev_num > 1 && info->id == id) 192 - dev_err(&dev->dev, " Error of this Agent(%04x) is reported first\n", id); 195 + pci_err(dev, " Error of this Agent(%04x) is reported first\n", id); 193 196 194 197 trace_aer_event(dev_name(&dev->dev), (info->status & ~info->mask), 195 198 info->severity); ··· 197 200 198 201 void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) 199 202 { 200 - dev_info(&dev->dev, "AER: %s%s error received: id=%04x\n", 203 + pci_info(dev, "AER: %s%s error received: id=%04x\n", 201 204 info->multi_error_valid ? "Multiple " : "", 202 205 aer_error_severity_string[info->severity], info->id); 203 206 } ··· 239 242 layer = AER_GET_LAYER_ERROR(aer_severity, status); 240 243 agent = AER_GET_AGENT(aer_severity, status); 241 244 242 - dev_err(&dev->dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); 245 + pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); 243 246 cper_print_bits("", status, status_strs, status_strs_size); 244 - dev_err(&dev->dev, "aer_layer=%s, aer_agent=%s\n", 247 + pci_err(dev, "aer_layer=%s, aer_agent=%s\n", 245 248 aer_error_layer[layer], aer_agent_string[agent]); 246 249 247 250 if (aer_severity != AER_CORRECTABLE) 248 - dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n", 251 + pci_err(dev, "aer_uncor_severity: 0x%08x\n", 249 252 aer->uncor_severity); 250 253 251 254 if (tlp_header_valid)
+1 -15
drivers/pci/pcie/aer/ecrc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Enables/disables PCIe ECRC checking. 3 4 * 4 5 * (C) Copyright 2009 Hewlett-Packard Development Company, L.P. 5 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 9 #include <linux/kernel.h>
+51 -29
drivers/pci/pcie/aspm.c
··· 43 43 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1 | \ 44 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 46 struct aspm_latency { 59 47 u32 l0s; /* L0s latency (nsec) */ 60 48 u32 l1; /* L1 latency (nsec) */ ··· 266 278 return; 267 279 268 280 /* Training failed. Restore common clock configurations */ 269 - dev_err(&parent->dev, "ASPM: Could not configure common clock\n"); 281 + pci_err(parent, "ASPM: Could not configure common clock\n"); 270 282 list_for_each_entry(child, &linkbus->devices, bus_list) 271 283 pcie_capability_write_word(child, PCI_EXP_LNKCTL, 272 284 child_reg[PCI_FUNC(child->devfn)]); ··· 316 328 case 2: 317 329 return val * 100; 318 330 } 319 - dev_err(&pdev->dev, "%s: Invalid T_PwrOn scale: %u\n", 320 - __func__, scale); 331 + pci_err(pdev, "%s: Invalid T_PwrOn scale: %u\n", __func__, scale); 321 332 return 0; 333 + } 334 + 335 + static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) 336 + { 337 + u64 threshold_ns = threshold_us * 1000; 338 + 339 + /* See PCIe r3.1, sec 7.33.3 and sec 6.18 */ 340 + if (threshold_ns < 32) { 341 + *scale = 0; 342 + *value = threshold_ns; 343 + } else if (threshold_ns < 1024) { 344 + *scale = 1; 345 + *value = threshold_ns >> 5; 346 + } else if (threshold_ns < 32768) { 347 + *scale = 2; 348 + *value = threshold_ns >> 10; 349 + } else if (threshold_ns < 1048576) { 350 + *scale = 3; 351 + *value = threshold_ns >> 15; 352 + } else if (threshold_ns < 33554432) { 353 + *scale = 4; 354 + *value = threshold_ns >> 20; 355 + } else { 356 + *scale = 5; 357 + *value = threshold_ns >> 25; 358 + } 322 359 } 323 360 324 361 struct aspm_register_info { ··· 456 443 struct aspm_register_info *dwreg) 457 444 { 458 445 u32 val1, val2, scale1, scale2; 446 + u32 t_common_mode, t_power_on, l1_2_threshold, scale, value; 459 447 460 448 link->l1ss.up_cap_ptr = upreg->l1ss_cap_ptr; 461 449 link->l1ss.dw_cap_ptr = dwreg->l1ss_cap_ptr; ··· 468 454 /* Choose the greater of the two Port Common_Mode_Restore_Times */ 469 455 val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; 470 456 val2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; 471 - if (val1 > val2) 472 - link->l1ss.ctl1 |= val1 << 8; 473 - else 474 - link->l1ss.ctl1 |= val2 << 8; 475 - 476 - /* 477 - * We currently use LTR L1.2 threshold to be fixed constant picked from 478 - * Intel's coreboot. 479 - */ 480 - link->l1ss.ctl1 |= LTR_L1_2_THRESHOLD_BITS; 457 + t_common_mode = max(val1, val2); 481 458 482 459 /* Choose the greater of the two Port T_POWER_ON times */ 483 460 val1 = (upreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_VALUE) >> 19; ··· 477 472 scale2 = (dwreg->l1ss_cap & PCI_L1SS_CAP_P_PWR_ON_SCALE) >> 16; 478 473 479 474 if (calc_l1ss_pwron(link->pdev, scale1, val1) > 480 - calc_l1ss_pwron(link->downstream, scale2, val2)) 475 + calc_l1ss_pwron(link->downstream, scale2, val2)) { 481 476 link->l1ss.ctl2 |= scale1 | (val1 << 3); 482 - else 477 + t_power_on = calc_l1ss_pwron(link->pdev, scale1, val1); 478 + } else { 483 479 link->l1ss.ctl2 |= scale2 | (val2 << 3); 480 + t_power_on = calc_l1ss_pwron(link->downstream, scale2, val2); 481 + } 482 + 483 + /* 484 + * Set LTR_L1.2_THRESHOLD to the time required to transition the 485 + * Link from L0 to L1.2 and back to L0 so we enter L1.2 only if 486 + * downstream devices report (via LTR) that they can tolerate at 487 + * least that much latency. 488 + * 489 + * Based on PCIe r3.1, sec 5.5.3.3.1, Figures 5-16 and 5-17, and 490 + * Table 5-11. T(POWER_OFF) is at most 2us and T(L1.2) is at 491 + * least 4us. 492 + */ 493 + l1_2_threshold = 2 + 4 + t_common_mode + t_power_on; 494 + encode_l12_threshold(l1_2_threshold, &scale, &value); 495 + link->l1ss.ctl1 |= t_common_mode << 8 | scale << 29 | value << 16; 484 496 } 485 497 486 498 static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) ··· 808 786 */ 809 787 pcie_capability_read_dword(child, PCI_EXP_DEVCAP, &reg32); 810 788 if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { 811 - dev_info(&child->dev, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); 789 + pci_info(child, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n"); 812 790 return -EINVAL; 813 791 } 814 792 } ··· 1049 1027 * ignored in this situation. 1050 1028 */ 1051 1029 if (aspm_disabled) { 1052 - dev_warn(&pdev->dev, "can't disable ASPM; OS doesn't have ASPM control\n"); 1030 + pci_warn(pdev, "can't disable ASPM; OS doesn't have ASPM control\n"); 1053 1031 return; 1054 1032 } 1055 1033
+119 -161
drivers/pci/pcie/pcie-dpc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCI Express Downstream Port Containment services driver 3 4 * Author: Keith Busch <keith.busch@intel.com> 4 5 * 5 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 9 #include <linux/delay.h> ··· 12 15 #include <linux/pci.h> 13 16 #include <linux/pcieport_if.h> 14 17 #include "../pci.h" 15 - 16 - struct rp_pio_header_log_regs { 17 - u32 dw0; 18 - u32 dw1; 19 - u32 dw2; 20 - u32 dw3; 21 - }; 22 - 23 - struct dpc_rp_pio_regs { 24 - u32 status; 25 - u32 mask; 26 - u32 severity; 27 - u32 syserror; 28 - u32 exception; 29 - 30 - struct rp_pio_header_log_regs header_log; 31 - u32 impspec_log; 32 - u32 tlp_prefix_log[4]; 33 - u32 log_size; 34 - u16 first_error; 35 - }; 18 + #include "aer/aerdrv.h" 36 19 37 20 struct dpc_dev { 38 21 struct pcie_device *dev; 39 22 struct work_struct work; 40 - int cap_pos; 41 - bool rp; 23 + u16 cap_pos; 24 + bool rp_extensions; 42 25 u32 rp_pio_status; 26 + u8 rp_log_size; 43 27 }; 44 28 45 29 static const char * const rp_pio_error_string[] = { ··· 50 72 unsigned long timeout = jiffies + HZ; 51 73 struct pci_dev *pdev = dpc->dev->port; 52 74 struct device *dev = &dpc->dev->device; 53 - u16 status; 75 + u16 cap = dpc->cap_pos, status; 54 76 55 - pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); 77 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); 56 78 while (status & PCI_EXP_DPC_RP_BUSY && 57 79 !time_after(jiffies, timeout)) { 58 80 msleep(10); 59 - pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); 81 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); 60 82 } 61 83 if (status & PCI_EXP_DPC_RP_BUSY) { 62 84 dev_warn(dev, "DPC root port still busy\n"); ··· 82 104 dev_warn(dev, "Link state not disabled for DPC event\n"); 83 105 } 84 106 85 - static void interrupt_event_handler(struct work_struct *work) 107 + static void dpc_work(struct work_struct *work) 86 108 { 87 109 struct dpc_dev *dpc = container_of(work, struct dpc_dev, work); 88 110 struct pci_dev *dev, *temp, *pdev = dpc->dev->port; 89 111 struct pci_bus *parent = pdev->subordinate; 112 + u16 cap = dpc->cap_pos, ctl; 90 113 91 114 pci_lock_rescan_remove(); 92 115 list_for_each_entry_safe_reverse(dev, temp, &parent->devices, ··· 103 124 pci_unlock_rescan_remove(); 104 125 105 126 dpc_wait_link_inactive(dpc); 106 - if (dpc->rp && dpc_wait_rp_inactive(dpc)) 127 + if (dpc->rp_extensions && dpc_wait_rp_inactive(dpc)) 107 128 return; 108 - if (dpc->rp && dpc->rp_pio_status) { 109 - pci_write_config_dword(pdev, 110 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_STATUS, 111 - dpc->rp_pio_status); 129 + if (dpc->rp_extensions && dpc->rp_pio_status) { 130 + pci_write_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, 131 + dpc->rp_pio_status); 112 132 dpc->rp_pio_status = 0; 113 133 } 114 134 115 - pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, 135 + pci_write_config_word(pdev, cap + PCI_EXP_DPC_STATUS, 116 136 PCI_EXP_DPC_STATUS_TRIGGER | PCI_EXP_DPC_STATUS_INTERRUPT); 117 - } 118 137 119 - static void dpc_rp_pio_print_tlp_header(struct device *dev, 120 - struct rp_pio_header_log_regs *t) 121 - { 122 - dev_err(dev, "TLP Header: %#010x %#010x %#010x %#010x\n", 123 - t->dw0, t->dw1, t->dw2, t->dw3); 124 - } 125 - 126 - static void dpc_rp_pio_print_error(struct dpc_dev *dpc, 127 - struct dpc_rp_pio_regs *rp_pio) 128 - { 129 - struct device *dev = &dpc->dev->device; 130 - int i; 131 - u32 status; 132 - 133 - dev_err(dev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n", 134 - rp_pio->status, rp_pio->mask); 135 - 136 - dev_err(dev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n", 137 - rp_pio->severity, rp_pio->syserror, rp_pio->exception); 138 - 139 - status = (rp_pio->status & ~rp_pio->mask); 140 - 141 - for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { 142 - if (!(status & (1 << i))) 143 - continue; 144 - 145 - dev_err(dev, "[%2d] %s%s\n", i, rp_pio_error_string[i], 146 - rp_pio->first_error == i ? " (First)" : ""); 147 - } 148 - 149 - dpc_rp_pio_print_tlp_header(dev, &rp_pio->header_log); 150 - if (rp_pio->log_size == 4) 151 - return; 152 - dev_err(dev, "RP PIO ImpSpec Log %#010x\n", rp_pio->impspec_log); 153 - 154 - for (i = 0; i < rp_pio->log_size - 5; i++) 155 - dev_err(dev, "TLP Prefix Header: dw%d, %#010x\n", i, 156 - rp_pio->tlp_prefix_log[i]); 157 - } 158 - 159 - static void dpc_rp_pio_get_info(struct dpc_dev *dpc, 160 - struct dpc_rp_pio_regs *rp_pio) 161 - { 162 - struct pci_dev *pdev = dpc->dev->port; 163 - struct device *dev = &dpc->dev->device; 164 - int i; 165 - u16 cap; 166 - u16 status; 167 - 168 - pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_STATUS, 169 - &rp_pio->status); 170 - pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_MASK, 171 - &rp_pio->mask); 172 - 173 - pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_SEVERITY, 174 - &rp_pio->severity); 175 - pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_SYSERROR, 176 - &rp_pio->syserror); 177 - pci_read_config_dword(pdev, dpc->cap_pos + PCI_EXP_DPC_RP_PIO_EXCEPTION, 178 - &rp_pio->exception); 179 - 180 - /* Get First Error Pointer */ 181 - pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); 182 - rp_pio->first_error = (status & 0x1f00) >> 8; 183 - 184 - pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CAP, &cap); 185 - rp_pio->log_size = (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8; 186 - if (rp_pio->log_size < 4 || rp_pio->log_size > 9) { 187 - dev_err(dev, "RP PIO log size %u is invalid\n", 188 - rp_pio->log_size); 189 - return; 190 - } 191 - 192 - pci_read_config_dword(pdev, 193 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG, 194 - &rp_pio->header_log.dw0); 195 - pci_read_config_dword(pdev, 196 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 4, 197 - &rp_pio->header_log.dw1); 198 - pci_read_config_dword(pdev, 199 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 8, 200 - &rp_pio->header_log.dw2); 201 - pci_read_config_dword(pdev, 202 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12, 203 - &rp_pio->header_log.dw3); 204 - if (rp_pio->log_size == 4) 205 - return; 206 - 207 - pci_read_config_dword(pdev, 208 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, 209 - &rp_pio->impspec_log); 210 - for (i = 0; i < rp_pio->log_size - 5; i++) 211 - pci_read_config_dword(pdev, 212 - dpc->cap_pos + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, 213 - &rp_pio->tlp_prefix_log[i]); 138 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_CTL, &ctl); 139 + pci_write_config_word(pdev, cap + PCI_EXP_DPC_CTL, 140 + ctl | PCI_EXP_DPC_CTL_INT_EN); 214 141 } 215 142 216 143 static void dpc_process_rp_pio_error(struct dpc_dev *dpc) 217 144 { 218 - struct dpc_rp_pio_regs rp_pio_regs; 145 + struct device *dev = &dpc->dev->device; 146 + struct pci_dev *pdev = dpc->dev->port; 147 + u16 cap = dpc->cap_pos, dpc_status, first_error; 148 + u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix; 149 + int i; 219 150 220 - dpc_rp_pio_get_info(dpc, &rp_pio_regs); 221 - dpc_rp_pio_print_error(dpc, &rp_pio_regs); 151 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, &status); 152 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_MASK, &mask); 153 + dev_err(dev, "rp_pio_status: %#010x, rp_pio_mask: %#010x\n", 154 + status, mask); 222 155 223 - dpc->rp_pio_status = rp_pio_regs.status; 156 + dpc->rp_pio_status = status; 157 + 158 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SEVERITY, &sev); 159 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_SYSERROR, &syserr); 160 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_EXCEPTION, &exc); 161 + dev_err(dev, "RP PIO severity=%#010x, syserror=%#010x, exception=%#010x\n", 162 + sev, syserr, exc); 163 + 164 + /* Get First Error Pointer */ 165 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &dpc_status); 166 + first_error = (dpc_status & 0x1f00) >> 8; 167 + 168 + status &= ~mask; 169 + for (i = 0; i < ARRAY_SIZE(rp_pio_error_string); i++) { 170 + if (status & (1 << i)) 171 + dev_err(dev, "[%2d] %s%s\n", i, rp_pio_error_string[i], 172 + first_error == i ? " (First)" : ""); 173 + } 174 + 175 + if (dpc->rp_log_size < 4) 176 + return; 177 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, 178 + &dw0); 179 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 4, 180 + &dw1); 181 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 8, 182 + &dw2); 183 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG + 12, 184 + &dw3); 185 + dev_err(dev, "TLP Header: %#010x %#010x %#010x %#010x\n", 186 + dw0, dw1, dw2, dw3); 187 + 188 + if (dpc->rp_log_size < 5) 189 + return; 190 + pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, &log); 191 + dev_err(dev, "RP PIO ImpSpec Log %#010x\n", log); 192 + 193 + for (i = 0; i < dpc->rp_log_size - 5; i++) { 194 + pci_read_config_dword(pdev, 195 + cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, &prefix); 196 + dev_err(dev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix); 197 + } 224 198 } 225 199 226 200 static irqreturn_t dpc_irq(int irq, void *context) ··· 181 249 struct dpc_dev *dpc = (struct dpc_dev *)context; 182 250 struct pci_dev *pdev = dpc->dev->port; 183 251 struct device *dev = &dpc->dev->device; 184 - u16 status, source; 252 + u16 cap = dpc->cap_pos, ctl, status, source, reason, ext_reason; 185 253 186 - pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_STATUS, &status); 187 - pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_SOURCE_ID, 188 - &source); 189 - if (!status || status == (u16)(~0)) 254 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_CTL, &ctl); 255 + 256 + if (!(ctl & PCI_EXP_DPC_CTL_INT_EN) || ctl == (u16)(~0)) 190 257 return IRQ_NONE; 258 + 259 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); 260 + 261 + if (!(status & PCI_EXP_DPC_STATUS_INTERRUPT)) 262 + return IRQ_NONE; 263 + 264 + if (!(status & PCI_EXP_DPC_STATUS_TRIGGER)) { 265 + pci_write_config_word(pdev, cap + PCI_EXP_DPC_STATUS, 266 + PCI_EXP_DPC_STATUS_INTERRUPT); 267 + return IRQ_HANDLED; 268 + } 269 + 270 + pci_write_config_word(pdev, cap + PCI_EXP_DPC_CTL, 271 + ctl & ~PCI_EXP_DPC_CTL_INT_EN); 272 + 273 + pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, 274 + &source); 191 275 192 276 dev_info(dev, "DPC containment event, status:%#06x source:%#06x\n", 193 277 status, source); 194 278 195 - if (status & PCI_EXP_DPC_STATUS_TRIGGER) { 196 - u16 reason = (status >> 1) & 0x3; 197 - u16 ext_reason = (status >> 5) & 0x3; 279 + reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1; 280 + ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5; 198 281 199 - dev_warn(dev, "DPC %s detected, remove downstream devices\n", 200 - (reason == 0) ? "unmasked uncorrectable error" : 201 - (reason == 1) ? "ERR_NONFATAL" : 202 - (reason == 2) ? "ERR_FATAL" : 203 - (ext_reason == 0) ? "RP PIO error" : 204 - (ext_reason == 1) ? "software trigger" : 205 - "reserved error"); 206 - /* show RP PIO error detail information */ 207 - if (reason == 3 && ext_reason == 0) 208 - dpc_process_rp_pio_error(dpc); 282 + dev_warn(dev, "DPC %s detected, remove downstream devices\n", 283 + (reason == 0) ? "unmasked uncorrectable error" : 284 + (reason == 1) ? "ERR_NONFATAL" : 285 + (reason == 2) ? "ERR_FATAL" : 286 + (ext_reason == 0) ? "RP PIO error" : 287 + (ext_reason == 1) ? "software trigger" : 288 + "reserved error"); 289 + /* show RP PIO error detail information */ 290 + if (dpc->rp_extensions && reason == 3 && ext_reason == 0) 291 + dpc_process_rp_pio_error(dpc); 209 292 210 - schedule_work(&dpc->work); 211 - } 293 + schedule_work(&dpc->work); 294 + 212 295 return IRQ_HANDLED; 213 296 } 214 297 ··· 236 289 int status; 237 290 u16 ctl, cap; 238 291 292 + if (pcie_aer_get_firmware_first(pdev)) 293 + return -ENOTSUPP; 294 + 239 295 dpc = devm_kzalloc(device, sizeof(*dpc), GFP_KERNEL); 240 296 if (!dpc) 241 297 return -ENOMEM; 242 298 243 299 dpc->cap_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DPC); 244 300 dpc->dev = dev; 245 - INIT_WORK(&dpc->work, interrupt_event_handler); 301 + INIT_WORK(&dpc->work, dpc_work); 246 302 set_service_data(dev, dpc); 247 303 248 304 status = devm_request_irq(device, dev->irq, dpc_irq, IRQF_SHARED, ··· 259 309 pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CAP, &cap); 260 310 pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, &ctl); 261 311 262 - dpc->rp = (cap & PCI_EXP_DPC_CAP_RP_EXT); 312 + dpc->rp_extensions = (cap & PCI_EXP_DPC_CAP_RP_EXT); 313 + if (dpc->rp_extensions) { 314 + dpc->rp_log_size = (cap & PCI_EXP_DPC_RP_PIO_LOG_SIZE) >> 8; 315 + if (dpc->rp_log_size < 4 || dpc->rp_log_size > 9) { 316 + dev_err(device, "RP PIO log size %u is invalid\n", 317 + dpc->rp_log_size); 318 + dpc->rp_log_size = 0; 319 + } 320 + } 263 321 264 322 ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_NONFATAL | PCI_EXP_DPC_CTL_INT_EN; 265 323 pci_write_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, ctl); 266 324 267 325 dev_info(device, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n", 268 - cap & 0xf, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT), 326 + cap & PCI_EXP_DPC_IRQ, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT), 269 327 FLAG(cap, PCI_EXP_DPC_CAP_POISONED_TLP), 270 - FLAG(cap, PCI_EXP_DPC_CAP_SW_TRIGGER), (cap >> 8) & 0xf, 328 + FLAG(cap, PCI_EXP_DPC_CAP_SW_TRIGGER), dpc->rp_log_size, 271 329 FLAG(cap, PCI_EXP_DPC_CAP_DL_ACTIVE)); 272 330 return status; 273 331 }
+4 -7
drivers/pci/pcie/pme.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe Native PME support 3 4 * 4 5 * Copyright (C) 2007 - 2009 Intel Corp 5 6 * Copyright (C) 2007 - 2009 Shaohua Li <shaohua.li@intel.com> 6 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 10 #include <linux/pci.h> ··· 195 198 * assuming that the PME was reported by a PCIe-PCI bridge that 196 199 * used devfn different from zero. 197 200 */ 198 - dev_dbg(&port->dev, "PME interrupt generated for non-existent device %02x:%02x.%d\n", 201 + pci_dbg(port, "PME interrupt generated for non-existent device %02x:%02x.%d\n", 199 202 busnr, PCI_SLOT(devfn), PCI_FUNC(devfn)); 200 203 found = pcie_pme_from_pci_bridge(bus, 0); 201 204 } 202 205 203 206 out: 204 207 if (!found) 205 - dev_dbg(&port->dev, "Spurious native PME interrupt!\n"); 208 + pci_dbg(port, "Spurious native PME interrupt!\n"); 206 209 } 207 210 208 211 /** ··· 342 345 return ret; 343 346 } 344 347 345 - dev_info(&port->dev, "Signaling PME with IRQ %d\n", srv->irq); 348 + pci_info(port, "Signaling PME with IRQ %d\n", srv->irq); 346 349 347 350 pcie_pme_mark_devices(port); 348 351 pcie_pme_interrupt_enable(port, true);
+1 -4
drivers/pci/pcie/portdrv_acpi.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCIe Port Native Services Support, ACPI-Related Part 3 4 * 4 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 8 #include <linux/pci.h>
+1
drivers/pci/pcie/portdrv_bus.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * File: portdrv_bus.c 3 4 * Purpose: PCI Express Port Bus Driver's Bus Overloading Functions
+2 -2
drivers/pci/pcie/portdrv_core.c
··· 216 216 return 0; 217 217 218 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 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 223 if (pcie_ports_auto) 224 224 pcie_port_platform_notify(dev, &cap_mask);
+2 -10
drivers/pci/pcie/ptm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCI Express Precision Time Measurement 3 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 7 #include <linux/module.h> ··· 25 33 dev->ptm_granularity); 26 34 break; 27 35 } 28 - dev_info(&dev->dev, "PTM enabled%s, %s granularity\n", 36 + pci_info(dev, "PTM enabled%s, %s granularity\n", 29 37 dev->ptm_root ? " (root)" : "", clock_desc); 30 38 } 31 39
+237 -139
drivers/pci/probe.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * probe.c - PCI detection and setup code 3 4 */ ··· 70 69 } 71 70 72 71 /* 73 - * Some device drivers need know if pci is initiated. 74 - * Basically, we think pci is not initiated when there 72 + * Some device drivers need know if PCI is initiated. 73 + * Basically, we think PCI is not initiated when there 75 74 * is no device to be found on the pci_bus_type. 76 75 */ 77 76 int no_pci_devices(void) ··· 117 116 if (!size) 118 117 return 0; 119 118 120 - /* Get the lowest of them to find the decode size, and 121 - from that the extent. */ 119 + /* 120 + * Get the lowest of them to find the decode size, and from that 121 + * the extent. 122 + */ 122 123 size = (size & ~(size-1)) - 1; 123 124 124 - /* base == maxbase can be valid only if the BAR has 125 - already been programmed with all 1s. */ 125 + /* 126 + * base == maxbase can be valid only if the BAR has already been 127 + * programmed with all 1s. 128 + */ 126 129 if (base == maxbase && ((base | size) & mask) != mask) 127 130 return 0; 128 131 ··· 169 164 #define PCI_COMMAND_DECODE_ENABLE (PCI_COMMAND_MEMORY | PCI_COMMAND_IO) 170 165 171 166 /** 172 - * pci_read_base - read a PCI BAR 167 + * pci_read_base - Read a PCI BAR 173 168 * @dev: the PCI device 174 169 * @type: type of the BAR 175 170 * @res: resource buffer to be filled in ··· 258 253 259 254 sz64 = pci_size(l64, sz64, mask64); 260 255 if (!sz64) { 261 - dev_info(&dev->dev, FW_BUG "reg 0x%x: invalid BAR (can't size)\n", 256 + pci_info(dev, FW_BUG "reg 0x%x: invalid BAR (can't size)\n", 262 257 pos); 263 258 goto fail; 264 259 } ··· 269 264 res->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED; 270 265 res->start = 0; 271 266 res->end = 0; 272 - dev_err(&dev->dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n", 267 + pci_err(dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n", 273 268 pos, (unsigned long long)sz64); 274 269 goto out; 275 270 } ··· 279 274 res->flags |= IORESOURCE_UNSET; 280 275 res->start = 0; 281 276 res->end = sz64; 282 - dev_info(&dev->dev, "reg 0x%x: can't handle BAR above 4GB (bus address %#010llx)\n", 277 + pci_info(dev, "reg 0x%x: can't handle BAR above 4GB (bus address %#010llx)\n", 283 278 pos, (unsigned long long)l64); 284 279 goto out; 285 280 } ··· 306 301 res->flags |= IORESOURCE_UNSET; 307 302 res->start = 0; 308 303 res->end = region.end - region.start; 309 - dev_info(&dev->dev, "reg 0x%x: initial BAR value %#010llx invalid\n", 304 + pci_info(dev, "reg 0x%x: initial BAR value %#010llx invalid\n", 310 305 pos, (unsigned long long)region.start); 311 306 } 312 307 ··· 317 312 res->flags = 0; 318 313 out: 319 314 if (res->flags) 320 - dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res); 315 + pci_printk(KERN_DEBUG, dev, "reg 0x%x: %pR\n", pos, res); 321 316 322 317 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; 323 318 } ··· 380 375 region.start = base; 381 376 region.end = limit + io_granularity - 1; 382 377 pcibios_bus_to_resource(dev->bus, res, &region); 383 - dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 378 + pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); 384 379 } 385 380 } 386 381 ··· 402 397 region.start = base; 403 398 region.end = limit + 0xfffff; 404 399 pcibios_bus_to_resource(dev->bus, res, &region); 405 - dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 400 + pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); 406 401 } 407 402 } 408 403 ··· 442 437 limit = (pci_bus_addr_t) limit64; 443 438 444 439 if (base != base64) { 445 - dev_err(&dev->dev, "can't handle bridge window above 4GB (bus address %#010llx)\n", 440 + pci_err(dev, "can't handle bridge window above 4GB (bus address %#010llx)\n", 446 441 (unsigned long long) base64); 447 442 return; 448 443 } ··· 455 450 region.start = base; 456 451 region.end = limit + 0xfffff; 457 452 pcibios_bus_to_resource(dev->bus, res, &region); 458 - dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 453 + pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); 459 454 } 460 455 } 461 456 ··· 468 463 if (pci_is_root_bus(child)) /* It's a host bus, nothing to read */ 469 464 return; 470 465 471 - dev_info(&dev->dev, "PCI bridge to %pR%s\n", 466 + pci_info(dev, "PCI bridge to %pR%s\n", 472 467 &child->busn_res, 473 468 dev->transparent ? " (subtractive decode)" : ""); 474 469 ··· 485 480 if (res && res->flags) { 486 481 pci_bus_add_resource(child, res, 487 482 PCI_SUBTRACTIVE_DECODE); 488 - dev_printk(KERN_DEBUG, &dev->dev, 483 + pci_printk(KERN_DEBUG, dev, 489 484 " bridge window %pR (subtractive decode)\n", 490 485 res); 491 486 } ··· 769 764 770 765 bridge->bus = bus; 771 766 772 - /* temporarily move resources off the list */ 767 + /* Temporarily move resources off the list */ 773 768 list_splice_init(&bridge->windows, &resources); 774 769 bus->sysdata = bridge->sysdata; 775 770 bus->msi = bridge->msi; ··· 781 776 782 777 b = pci_find_bus(pci_domain_nr(bus), bridge->busnr); 783 778 if (b) { 784 - /* If we already got to this bus through a different bridge, ignore it */ 779 + /* Ignore it if we already got here via a different bridge */ 785 780 dev_dbg(&b->dev, "bus already known\n"); 786 781 err = -EEXIST; 787 782 goto free; ··· 874 869 int i; 875 870 int ret; 876 871 877 - /* 878 - * Allocate a new bus, and inherit stuff from the parent.. 879 - */ 872 + /* Allocate a new bus and inherit stuff from the parent */ 880 873 child = pci_alloc_bus(parent); 881 874 if (!child) 882 875 return NULL; ··· 885 882 child->sysdata = parent->sysdata; 886 883 child->bus_flags = parent->bus_flags; 887 884 888 - /* initialize some portions of the bus device, but don't register it 889 - * now as the parent is not properly set up yet. 885 + /* 886 + * Initialize some portions of the bus device, but don't register 887 + * it now as the parent is not properly set up yet. 890 888 */ 891 889 child->dev.class = &pcibus_class; 892 890 dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr); 893 891 894 - /* 895 - * Set up the primary, secondary and subordinate 896 - * bus numbers. 897 - */ 892 + /* Set up the primary, secondary and subordinate bus numbers */ 898 893 child->number = child->busn_res.start = busnr; 899 894 child->primary = parent->busn_res.start; 900 895 child->busn_res.end = 0xff; ··· 908 907 pci_set_bus_of_node(child); 909 908 pci_set_bus_speed(child); 910 909 911 - /* Set up default resource pointers and names.. */ 910 + /* Set up default resource pointers and names */ 912 911 for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) { 913 912 child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i]; 914 913 child->resource[i]->name = child->name; ··· 1006 1005 secondary = (buses >> 8) & 0xFF; 1007 1006 subordinate = (buses >> 16) & 0xFF; 1008 1007 1009 - dev_dbg(&dev->dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n", 1008 + pci_dbg(dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n", 1010 1009 secondary, subordinate, pass); 1011 1010 1012 1011 if (!primary && (primary != bus->number) && secondary && subordinate) { 1013 - dev_warn(&dev->dev, "Primary bus is hard wired to 0\n"); 1012 + pci_warn(dev, "Primary bus is hard wired to 0\n"); 1014 1013 primary = bus->number; 1015 1014 } 1016 1015 ··· 1018 1017 if (!pass && 1019 1018 (primary != bus->number || secondary <= bus->number || 1020 1019 secondary > subordinate)) { 1021 - dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", 1020 + pci_info(dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", 1022 1021 secondary, subordinate); 1023 1022 broken = 1; 1024 1023 } 1025 1024 1026 - /* Disable MasterAbortMode during probing to avoid reporting 1027 - of bus errors (in some architectures) */ 1025 + /* 1026 + * Disable Master-Abort Mode during probing to avoid reporting of 1027 + * bus errors in some architectures. 1028 + */ 1028 1029 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); 1029 1030 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, 1030 1031 bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); ··· 1036 1033 if ((secondary || subordinate) && !pcibios_assign_all_busses() && 1037 1034 !is_cardbus && !broken) { 1038 1035 unsigned int cmax; 1036 + 1039 1037 /* 1040 - * Bus already configured by firmware, process it in the first 1041 - * pass and just note the configuration. 1038 + * Bus already configured by firmware, process it in the 1039 + * first pass and just note the configuration. 1042 1040 */ 1043 1041 if (pass) 1044 1042 goto out; 1045 1043 1046 1044 /* 1047 - * The bus might already exist for two reasons: Either we are 1048 - * rescanning the bus or the bus is reachable through more than 1049 - * one bridge. The second case can happen with the i450NX 1050 - * chipset. 1045 + * The bus might already exist for two reasons: Either we 1046 + * are rescanning the bus or the bus is reachable through 1047 + * more than one bridge. The second case can happen with 1048 + * the i450NX chipset. 1051 1049 */ 1052 1050 child = pci_find_bus(pci_domain_nr(bus), secondary); 1053 1051 if (!child) { ··· 1062 1058 1063 1059 cmax = pci_scan_child_bus(child); 1064 1060 if (cmax > subordinate) 1065 - dev_warn(&dev->dev, "bridge has subordinate %02x but max busn %02x\n", 1061 + pci_warn(dev, "bridge has subordinate %02x but max busn %02x\n", 1066 1062 subordinate, cmax); 1067 - /* subordinate should equal child->busn_res.end */ 1063 + 1064 + /* Subordinate should equal child->busn_res.end */ 1068 1065 if (subordinate > max) 1069 1066 max = subordinate; 1070 1067 } else { 1068 + 1071 1069 /* 1072 1070 * We need to assign a number to this bus which we always 1073 1071 * do in the second pass. 1074 1072 */ 1075 1073 if (!pass) { 1076 1074 if (pcibios_assign_all_busses() || broken || is_cardbus) 1077 - /* Temporarily disable forwarding of the 1078 - configuration cycles on all bridges in 1079 - this bus segment to avoid possible 1080 - conflicts in the second pass between two 1081 - bridges programmed with overlapping 1082 - bus ranges. */ 1075 + 1076 + /* 1077 + * Temporarily disable forwarding of the 1078 + * configuration cycles on all bridges in 1079 + * this bus segment to avoid possible 1080 + * conflicts in the second pass between two 1081 + * bridges programmed with overlapping bus 1082 + * ranges. 1083 + */ 1083 1084 pci_write_config_dword(dev, PCI_PRIMARY_BUS, 1084 1085 buses & ~0xffffff); 1085 1086 goto out; ··· 1093 1084 /* Clear errors */ 1094 1085 pci_write_config_word(dev, PCI_STATUS, 0xffff); 1095 1086 1096 - /* Prevent assigning a bus number that already exists. 1097 - * This can happen when a bridge is hot-plugged, so in 1098 - * this case we only re-scan this bus. */ 1087 + /* 1088 + * Prevent assigning a bus number that already exists. 1089 + * This can happen when a bridge is hot-plugged, so in this 1090 + * case we only re-scan this bus. 1091 + */ 1099 1092 child = pci_find_bus(pci_domain_nr(bus), max+1); 1100 1093 if (!child) { 1101 1094 child = pci_add_new_bus(bus, dev, max+1); ··· 1124 1113 buses |= CARDBUS_LATENCY_TIMER << 24; 1125 1114 } 1126 1115 1127 - /* 1128 - * We need to blast all three values with a single write. 1129 - */ 1116 + /* We need to blast all three values with a single write */ 1130 1117 pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); 1131 1118 1132 1119 if (!is_cardbus) { 1133 1120 child->bridge_ctl = bctl; 1134 1121 max = pci_scan_child_bus_extend(child, available_buses); 1135 1122 } else { 1123 + 1136 1124 /* 1137 - * For CardBus bridges, we leave 4 bus numbers 1138 - * as cards with a PCI-to-PCI bridge can be 1139 - * inserted later. 1125 + * For CardBus bridges, we leave 4 bus numbers as 1126 + * cards with a PCI-to-PCI bridge can be inserted 1127 + * later. 1140 1128 */ 1141 1129 for (i = 0; i < CARDBUS_RESERVE_BUSNR; i++) { 1142 1130 struct pci_bus *parent = bus; ··· 1151 1141 parent = parent->parent; 1152 1142 } 1153 1143 if (j) { 1144 + 1154 1145 /* 1155 - * Often, there are two cardbus bridges 1156 - * -- try to leave one valid bus number 1157 - * for each one. 1146 + * Often, there are two CardBus 1147 + * bridges -- try to leave one 1148 + * valid bus number for each one. 1158 1149 */ 1159 1150 i /= 2; 1160 1151 break; ··· 1163 1152 } 1164 1153 max += i; 1165 1154 } 1166 - /* 1167 - * Set the subordinate bus number to its real value. 1168 - */ 1155 + 1156 + /* Set subordinate bus number to its real value */ 1169 1157 pci_bus_update_busn_res_end(child, max); 1170 1158 pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); 1171 1159 } ··· 1305 1295 } 1306 1296 1307 1297 /** 1308 - * pci_ext_cfg_is_aliased - is ext config space just an alias of std config? 1298 + * pci_ext_cfg_is_aliased - Is ext config space just an alias of std config? 1309 1299 * @dev: PCI device 1310 1300 * 1311 1301 * PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says that ··· 1342 1332 } 1343 1333 1344 1334 /** 1345 - * pci_cfg_space_size - get the configuration space size of the PCI device. 1335 + * pci_cfg_space_size - Get the configuration space size of the PCI device 1346 1336 * @dev: PCI device 1347 1337 * 1348 1338 * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices ··· 1408 1398 } 1409 1399 1410 1400 /** 1411 - * pci_intx_mask_broken - test PCI_COMMAND_INTX_DISABLE writability 1401 + * pci_intx_mask_broken - Test PCI_COMMAND_INTX_DISABLE writability 1412 1402 * @dev: PCI device 1413 1403 * 1414 1404 * Test whether PCI_COMMAND_INTX_DISABLE is writable for @dev. Check this ··· 1436 1426 } 1437 1427 1438 1428 /** 1439 - * pci_setup_device - fill in class and map information of a device 1429 + * pci_setup_device - Fill in class and map information of a device 1440 1430 * @dev: the device structure to fill 1441 1431 * 1442 1432 * Initialize the device structure with information about the device's 1443 - * vendor,class,memory and IO-space addresses,IRQ lines etc. 1433 + * vendor,class,memory and IO-space addresses, IRQ lines etc. 1444 1434 * Called at initialisation of the PCI subsystem and by CardBus services. 1445 1435 * Returns 0 on success and negative if unknown type of device (not normal, 1446 1436 * bridge or CardBus). ··· 1466 1456 set_pcie_port_type(dev); 1467 1457 1468 1458 pci_dev_assign_slot(dev); 1469 - /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) 1470 - set this higher, assuming the system even supports it. */ 1459 + 1460 + /* 1461 + * Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) 1462 + * set this higher, assuming the system even supports it. 1463 + */ 1471 1464 dev->dma_mask = 0xffffffff; 1472 1465 1473 1466 dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus), ··· 1481 1468 dev->revision = class & 0xff; 1482 1469 dev->class = class >> 8; /* upper 3 bytes */ 1483 1470 1484 - dev_printk(KERN_DEBUG, &dev->dev, "[%04x:%04x] type %02x class %#08x\n", 1471 + pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n", 1485 1472 dev->vendor, dev->device, dev->hdr_type, dev->class); 1486 1473 1487 - /* need to have dev->class ready */ 1474 + /* Need to have dev->class ready */ 1488 1475 dev->cfg_size = pci_cfg_space_size(dev); 1489 1476 1490 - /* need to have dev->cfg_size ready */ 1477 + /* Need to have dev->cfg_size ready */ 1491 1478 set_pcie_thunderbolt(dev); 1492 1479 1493 1480 /* "Unknown power state" */ ··· 1495 1482 1496 1483 /* Early fixups, before probing the BARs */ 1497 1484 pci_fixup_device(pci_fixup_early, dev); 1498 - /* device class may be changed after fixup */ 1485 + 1486 + /* Device class may be changed after fixup */ 1499 1487 class = dev->class >> 8; 1500 1488 1501 1489 if (dev->non_compliant_bars) { 1502 1490 pci_read_config_word(dev, PCI_COMMAND, &cmd); 1503 1491 if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { 1504 - dev_info(&dev->dev, "device has non-compliant BARs; disabling IO/MEM decoding\n"); 1492 + pci_info(dev, "device has non-compliant BARs; disabling IO/MEM decoding\n"); 1505 1493 cmd &= ~PCI_COMMAND_IO; 1506 1494 cmd &= ~PCI_COMMAND_MEMORY; 1507 1495 pci_write_config_word(dev, PCI_COMMAND, cmd); ··· 1535 1521 res = &dev->resource[0]; 1536 1522 res->flags = LEGACY_IO_RESOURCE; 1537 1523 pcibios_bus_to_resource(dev->bus, res, &region); 1538 - dev_info(&dev->dev, "legacy IDE quirk: reg 0x10: %pR\n", 1524 + pci_info(dev, "legacy IDE quirk: reg 0x10: %pR\n", 1539 1525 res); 1540 1526 region.start = 0x3F6; 1541 1527 region.end = 0x3F6; 1542 1528 res = &dev->resource[1]; 1543 1529 res->flags = LEGACY_IO_RESOURCE; 1544 1530 pcibios_bus_to_resource(dev->bus, res, &region); 1545 - dev_info(&dev->dev, "legacy IDE quirk: reg 0x14: %pR\n", 1531 + pci_info(dev, "legacy IDE quirk: reg 0x14: %pR\n", 1546 1532 res); 1547 1533 } 1548 1534 if ((progif & 4) == 0) { ··· 1551 1537 res = &dev->resource[2]; 1552 1538 res->flags = LEGACY_IO_RESOURCE; 1553 1539 pcibios_bus_to_resource(dev->bus, res, &region); 1554 - dev_info(&dev->dev, "legacy IDE quirk: reg 0x18: %pR\n", 1540 + pci_info(dev, "legacy IDE quirk: reg 0x18: %pR\n", 1555 1541 res); 1556 1542 region.start = 0x376; 1557 1543 region.end = 0x376; 1558 1544 res = &dev->resource[3]; 1559 1545 res->flags = LEGACY_IO_RESOURCE; 1560 1546 pcibios_bus_to_resource(dev->bus, res, &region); 1561 - dev_info(&dev->dev, "legacy IDE quirk: reg 0x1c: %pR\n", 1547 + pci_info(dev, "legacy IDE quirk: reg 0x1c: %pR\n", 1562 1548 res); 1563 1549 } 1564 1550 } ··· 1567 1553 case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ 1568 1554 if (class != PCI_CLASS_BRIDGE_PCI) 1569 1555 goto bad; 1570 - /* The PCI-to-PCI bridge spec requires that subtractive 1571 - decoding (i.e. transparent) bridge must have programming 1572 - interface code of 0x01. */ 1556 + 1557 + /* 1558 + * The PCI-to-PCI bridge spec requires that subtractive 1559 + * decoding (i.e. transparent) bridge must have programming 1560 + * interface code of 0x01. 1561 + */ 1573 1562 pci_read_irq(dev); 1574 1563 dev->transparent = ((dev->class & 0xff) == 1); 1575 1564 pci_read_bases(dev, 2, PCI_ROM_ADDRESS1); ··· 1594 1577 break; 1595 1578 1596 1579 default: /* unknown header */ 1597 - dev_err(&dev->dev, "unknown header type %02x, ignoring device\n", 1580 + pci_err(dev, "unknown header type %02x, ignoring device\n", 1598 1581 dev->hdr_type); 1599 1582 return -EIO; 1600 1583 1601 1584 bad: 1602 - dev_err(&dev->dev, "ignoring class %#08x (doesn't match header type %02x)\n", 1585 + pci_err(dev, "ignoring class %#08x (doesn't match header type %02x)\n", 1603 1586 dev->class, dev->hdr_type); 1604 1587 dev->class = PCI_CLASS_NOT_DEFINED << 8; 1605 1588 } ··· 1623 1606 return; 1624 1607 1625 1608 if (pcie_bus_config == PCIE_BUS_TUNE_OFF) { 1626 - 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", 1609 + 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", 1627 1610 mps, pci_name(bridge), p_mps); 1628 1611 return; 1629 1612 } ··· 1637 1620 1638 1621 rc = pcie_set_mps(dev, p_mps); 1639 1622 if (rc) { 1640 - dev_warn(&dev->dev, "can't set Max Payload Size to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n", 1623 + pci_warn(dev, "can't set Max Payload Size to %d; if necessary, use \"pci=pcie_bus_safe\" and report a bug\n", 1641 1624 p_mps); 1642 1625 return; 1643 1626 } 1644 1627 1645 - dev_info(&dev->dev, "Max Payload Size set to %d (was %d, max %d)\n", 1628 + pci_info(dev, "Max Payload Size set to %d (was %d, max %d)\n", 1646 1629 p_mps, mps, 128 << dev->pcie_mpss); 1647 1630 } 1648 1631 ··· 1662 1645 hpp = &pci_default_type0; 1663 1646 1664 1647 if (hpp->revision > 1) { 1665 - dev_warn(&dev->dev, 1666 - "PCI settings rev %d not supported; using defaults\n", 1648 + pci_warn(dev, "PCI settings rev %d not supported; using defaults\n", 1667 1649 hpp->revision); 1668 1650 hpp = &pci_default_type0; 1669 1651 } ··· 1700 1684 if (!pos) 1701 1685 return; 1702 1686 1703 - dev_warn(&dev->dev, "PCI-X settings not supported\n"); 1687 + pci_warn(dev, "PCI-X settings not supported\n"); 1704 1688 } 1705 1689 1706 1690 static bool pcie_root_rcb_set(struct pci_dev *dev) ··· 1730 1714 return; 1731 1715 1732 1716 if (hpp->revision > 1) { 1733 - dev_warn(&dev->dev, "PCIe settings rev %d not supported\n", 1717 + pci_warn(dev, "PCIe settings rev %d not supported\n", 1734 1718 hpp->revision); 1735 1719 return; 1736 1720 } ··· 1788 1772 /* Initialize Advanced Error Capabilities and Control Register */ 1789 1773 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32); 1790 1774 reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or; 1775 + 1791 1776 /* Don't enable ECRC generation or checking if unsupported */ 1792 1777 if (!(reg32 & PCI_ERR_CAP_ECRC_GENC)) 1793 1778 reg32 &= ~PCI_ERR_CAP_ECRC_GENE; ··· 1835 1818 */ 1836 1819 if (host->no_ext_tags) { 1837 1820 if (ctl & PCI_EXP_DEVCTL_EXT_TAG) { 1838 - dev_info(&dev->dev, "disabling Extended Tags\n"); 1821 + pci_info(dev, "disabling Extended Tags\n"); 1839 1822 pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, 1840 1823 PCI_EXP_DEVCTL_EXT_TAG); 1841 1824 } ··· 1843 1826 } 1844 1827 1845 1828 if (!(ctl & PCI_EXP_DEVCTL_EXT_TAG)) { 1846 - dev_info(&dev->dev, "enabling Extended Tags\n"); 1829 + pci_info(dev, "enabling Extended Tags\n"); 1847 1830 pcie_capability_set_word(dev, PCI_EXP_DEVCTL, 1848 1831 PCI_EXP_DEVCTL_EXT_TAG); 1849 1832 } ··· 1888 1871 if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) { 1889 1872 pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, 1890 1873 PCI_EXP_DEVCTL_RELAX_EN); 1891 - dev_info(&dev->dev, "Disable Relaxed Ordering because the Root Port didn't support it\n"); 1874 + pci_info(dev, "Relaxed Ordering disabled because the Root Port didn't support it\n"); 1892 1875 } 1876 + } 1877 + 1878 + static void pci_configure_ltr(struct pci_dev *dev) 1879 + { 1880 + #ifdef CONFIG_PCIEASPM 1881 + u32 cap; 1882 + struct pci_dev *bridge; 1883 + 1884 + if (!pci_is_pcie(dev)) 1885 + return; 1886 + 1887 + pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap); 1888 + if (!(cap & PCI_EXP_DEVCAP2_LTR)) 1889 + return; 1890 + 1891 + /* 1892 + * Software must not enable LTR in an Endpoint unless the Root 1893 + * Complex and all intermediate Switches indicate support for LTR. 1894 + * PCIe r3.1, sec 6.18. 1895 + */ 1896 + if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) 1897 + dev->ltr_path = 1; 1898 + else { 1899 + bridge = pci_upstream_bridge(dev); 1900 + if (bridge && bridge->ltr_path) 1901 + dev->ltr_path = 1; 1902 + } 1903 + 1904 + if (dev->ltr_path) 1905 + pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, 1906 + PCI_EXP_DEVCTL2_LTR_EN); 1907 + #endif 1893 1908 } 1894 1909 1895 1910 static void pci_configure_device(struct pci_dev *dev) ··· 1932 1883 pci_configure_mps(dev); 1933 1884 pci_configure_extended_tags(dev, NULL); 1934 1885 pci_configure_relaxed_ordering(dev); 1886 + pci_configure_ltr(dev); 1935 1887 1936 1888 memset(&hpp, 0, sizeof(hpp)); 1937 1889 ret = pci_get_hp_params(dev, &hpp); ··· 1952 1902 } 1953 1903 1954 1904 /** 1955 - * pci_release_dev - free a pci device structure when all users of it are finished. 1905 + * pci_release_dev - Free a PCI device structure when all users of it are 1906 + * finished 1956 1907 * @dev: device that's been disconnected 1957 1908 * 1958 - * Will be called only by the device core when all users of this pci device are 1909 + * Will be called only by the device core when all users of this PCI device are 1959 1910 * done. 1960 1911 */ 1961 1912 static void pci_release_dev(struct device *dev) ··· 2044 1993 if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) 2045 1994 return false; 2046 1995 2047 - /* some broken boards return 0 or ~0 if a slot is empty: */ 1996 + /* Some broken boards return 0 or ~0 if a slot is empty: */ 2048 1997 if (*l == 0xffffffff || *l == 0x00000000 || 2049 1998 *l == 0x0000ffff || *l == 0xffff0000) 2050 1999 return false; ··· 2057 2006 EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); 2058 2007 2059 2008 /* 2060 - * Read the config data for a PCI device, sanity-check it 2061 - * and fill in the dev structure... 2009 + * Read the config data for a PCI device, sanity-check it, 2010 + * and fill in the dev structure. 2062 2011 */ 2063 2012 static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) 2064 2013 { ··· 2124 2073 } 2125 2074 2126 2075 /* 2127 - * This is the equivalent of pci_host_bridge_msi_domain that acts on 2076 + * This is the equivalent of pci_host_bridge_msi_domain() that acts on 2128 2077 * devices. Firmware interfaces that can select the MSI domain on a 2129 2078 * per-device basis should be called from here. 2130 2079 */ ··· 2133 2082 struct irq_domain *d; 2134 2083 2135 2084 /* 2136 - * If a domain has been set through the pcibios_add_device 2085 + * If a domain has been set through the pcibios_add_device() 2137 2086 * callback, then this is the one (platform code knows best). 2138 2087 */ 2139 2088 d = dev_get_msi_domain(&dev->dev); ··· 2187 2136 /* Fix up broken headers */ 2188 2137 pci_fixup_device(pci_fixup_header, dev); 2189 2138 2190 - /* moved out from quirk header fixup code */ 2139 + /* Moved out from quirk header fixup code */ 2191 2140 pci_reassigndev_resource_alignment(dev); 2192 2141 2193 - /* Clear the state_saved flag. */ 2142 + /* Clear the state_saved flag */ 2194 2143 dev->state_saved = false; 2195 2144 2196 2145 /* Initialize various capabilities */ ··· 2207 2156 ret = pcibios_add_device(dev); 2208 2157 WARN_ON(ret < 0); 2209 2158 2210 - /* Setup MSI irq domain */ 2159 + /* Set up MSI IRQ domain */ 2211 2160 pci_set_msi_domain(dev); 2212 2161 2213 2162 /* Notifier could use PCI capabilities */ ··· 2266 2215 2267 2216 static int only_one_child(struct pci_bus *bus) 2268 2217 { 2269 - struct pci_dev *parent = bus->self; 2270 - 2271 - if (!parent || !pci_is_pcie(parent)) 2272 - return 0; 2273 - if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT) 2274 - return 1; 2218 + struct pci_dev *bridge = bus->self; 2275 2219 2276 2220 /* 2277 - * PCIe downstream ports are bridges that normally lead to only a 2278 - * device 0, but if PCI_SCAN_ALL_PCIE_DEVS is set, scan all 2279 - * possible devices, not just device 0. See PCIe spec r3.0, 2280 - * sec 7.3.1. 2221 + * Systems with unusual topologies set PCI_SCAN_ALL_PCIE_DEVS so 2222 + * we scan for all possible devices, not just Device 0. 2281 2223 */ 2282 - if (parent->has_secondary_link && 2283 - !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) 2224 + if (pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) 2225 + return 0; 2226 + 2227 + /* 2228 + * A PCIe Downstream Port normally leads to a Link with only Device 2229 + * 0 on it (PCIe spec r3.1, sec 7.3.1). As an optimization, scan 2230 + * only for Device 0 in that situation. 2231 + * 2232 + * Checking has_secondary_link is a hack to identify Downstream 2233 + * Ports because sometimes Switches are configured such that the 2234 + * PCIe Port Type labels are backwards. 2235 + */ 2236 + if (bridge && pci_is_pcie(bridge) && bridge->has_secondary_link) 2284 2237 return 1; 2238 + 2285 2239 return 0; 2286 2240 } 2287 2241 2288 2242 /** 2289 - * pci_scan_slot - scan a PCI slot on a bus for devices. 2243 + * pci_scan_slot - Scan a PCI slot on a bus for devices 2290 2244 * @bus: PCI bus to scan 2291 - * @devfn: slot number to scan (must have zero function.) 2245 + * @devfn: slot number to scan (must have zero function) 2292 2246 * 2293 2247 * Scan a PCI slot on the specified PCI bus for devices, adding 2294 2248 * discovered devices to the @bus->devices list. New devices ··· 2324 2268 } 2325 2269 } 2326 2270 2327 - /* only one slot has pcie device */ 2271 + /* Only one slot has PCIe device */ 2328 2272 if (bus->self && nr) 2329 2273 pcie_aspm_init_link_state(bus->self); 2330 2274 ··· 2373 2317 2374 2318 if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT && 2375 2319 dev->bus->self) 2376 - /* For "Performance", the assumption is made that 2320 + 2321 + /* 2322 + * For "Performance", the assumption is made that 2377 2323 * downstream communication will never be larger than 2378 2324 * the MRRS. So, the MPS only needs to be configured 2379 2325 * for the upstream communication. This being the case, ··· 2392 2334 2393 2335 rc = pcie_set_mps(dev, mps); 2394 2336 if (rc) 2395 - dev_err(&dev->dev, "Failed attempting to set the MPS\n"); 2337 + pci_err(dev, "Failed attempting to set the MPS\n"); 2396 2338 } 2397 2339 2398 2340 static void pcie_write_mrrs(struct pci_dev *dev) 2399 2341 { 2400 2342 int rc, mrrs; 2401 2343 2402 - /* In the "safe" case, do not configure the MRRS. There appear to be 2344 + /* 2345 + * In the "safe" case, do not configure the MRRS. There appear to be 2403 2346 * issues with setting MRRS to 0 on a number of devices. 2404 2347 */ 2405 2348 if (pcie_bus_config != PCIE_BUS_PERFORMANCE) 2406 2349 return; 2407 2350 2408 - /* For Max performance, the MRRS must be set to the largest supported 2351 + /* 2352 + * For max performance, the MRRS must be set to the largest supported 2409 2353 * value. However, it cannot be configured larger than the MPS the 2410 2354 * device or the bus can support. This should already be properly 2411 - * configured by a prior call to pcie_write_mps. 2355 + * configured by a prior call to pcie_write_mps(). 2412 2356 */ 2413 2357 mrrs = pcie_get_mps(dev); 2414 2358 2415 - /* MRRS is a R/W register. Invalid values can be written, but a 2359 + /* 2360 + * MRRS is a R/W register. Invalid values can be written, but a 2416 2361 * subsequent read will verify if the value is acceptable or not. 2417 2362 * If the MRRS value provided is not acceptable (e.g., too large), 2418 2363 * shrink the value until it is acceptable to the HW. ··· 2425 2364 if (!rc) 2426 2365 break; 2427 2366 2428 - dev_warn(&dev->dev, "Failed attempting to set the MRRS\n"); 2367 + pci_warn(dev, "Failed attempting to set the MRRS\n"); 2429 2368 mrrs /= 2; 2430 2369 } 2431 2370 2432 2371 if (mrrs < 128) 2433 - 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"); 2372 + 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"); 2434 2373 } 2435 2374 2436 2375 static int pcie_bus_configure_set(struct pci_dev *dev, void *data) ··· 2450 2389 pcie_write_mps(dev, mps); 2451 2390 pcie_write_mrrs(dev); 2452 2391 2453 - dev_info(&dev->dev, "Max Payload Size set to %4d/%4d (was %4d), Max Read Rq %4d\n", 2392 + pci_info(dev, "Max Payload Size set to %4d/%4d (was %4d), Max Read Rq %4d\n", 2454 2393 pcie_get_mps(dev), 128 << dev->pcie_mpss, 2455 2394 orig_mps, pcie_get_readrq(dev)); 2456 2395 2457 2396 return 0; 2458 2397 } 2459 2398 2460 - /* pcie_bus_configure_settings requires that pci_walk_bus work in a top-down, 2399 + /* 2400 + * pcie_bus_configure_settings() requires that pci_walk_bus work in a top-down, 2461 2401 * parents then children fashion. If this changes, then this code will not 2462 2402 * work as designed. 2463 2403 */ ··· 2472 2410 if (!pci_is_pcie(bus->self)) 2473 2411 return; 2474 2412 2475 - /* FIXME - Peer to peer DMA is possible, though the endpoint would need 2413 + /* 2414 + * FIXME - Peer to peer DMA is possible, though the endpoint would need 2476 2415 * to be aware of the MPS of the destination. To work around this, 2477 2416 * simply force the MPS of the entire system to the smallest possible. 2478 2417 */ ··· 2527 2464 for (devfn = 0; devfn < 0x100; devfn += 8) 2528 2465 pci_scan_slot(bus, devfn); 2529 2466 2530 - /* Reserve buses for SR-IOV capability. */ 2467 + /* Reserve buses for SR-IOV capability */ 2531 2468 used_buses = pci_iov_bus_range(bus); 2532 2469 max += used_buses; 2533 2470 ··· 2569 2506 unsigned int buses = 0; 2570 2507 2571 2508 if (!hotplug_bridges && normal_bridges == 1) { 2509 + 2572 2510 /* 2573 2511 * There is only one bridge on the bus (upstream 2574 2512 * port) so it gets all available buses which it ··· 2578 2514 */ 2579 2515 buses = available_buses; 2580 2516 } else if (dev->is_hotplug_bridge) { 2517 + 2581 2518 /* 2582 2519 * Distribute the extra buses between hotplug 2583 2520 * bridges if any. ··· 2637 2572 EXPORT_SYMBOL_GPL(pci_scan_child_bus); 2638 2573 2639 2574 /** 2640 - * pcibios_root_bridge_prepare - Platform-specific host bridge setup. 2641 - * @bridge: Host bridge to set up. 2575 + * pcibios_root_bridge_prepare - Platform-specific host bridge setup 2576 + * @bridge: Host bridge to set up 2642 2577 * 2643 2578 * Default empty implementation. Replace with an architecture-specific setup 2644 2579 * routine, if necessary. ··· 2684 2619 return NULL; 2685 2620 } 2686 2621 EXPORT_SYMBOL_GPL(pci_create_root_bus); 2622 + 2623 + int pci_host_probe(struct pci_host_bridge *bridge) 2624 + { 2625 + struct pci_bus *bus, *child; 2626 + int ret; 2627 + 2628 + ret = pci_scan_root_bus_bridge(bridge); 2629 + if (ret < 0) { 2630 + dev_err(bridge->dev.parent, "Scanning root bridge failed"); 2631 + return ret; 2632 + } 2633 + 2634 + bus = bridge->bus; 2635 + 2636 + /* 2637 + * We insert PCI resources into the iomem_resource and 2638 + * ioport_resource trees in either pci_bus_claim_resources() 2639 + * or pci_bus_assign_resources(). 2640 + */ 2641 + if (pci_has_flag(PCI_PROBE_ONLY)) { 2642 + pci_bus_claim_resources(bus); 2643 + } else { 2644 + pci_bus_size_bridges(bus); 2645 + pci_bus_assign_resources(bus); 2646 + 2647 + list_for_each_entry(child, &bus->children, node) 2648 + pcie_bus_configure_settings(child); 2649 + } 2650 + 2651 + pci_bus_add_devices(bus); 2652 + return 0; 2653 + } 2654 + EXPORT_SYMBOL_GPL(pci_host_probe); 2687 2655 2688 2656 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) 2689 2657 { ··· 2874 2776 EXPORT_SYMBOL(pci_scan_bus); 2875 2777 2876 2778 /** 2877 - * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. 2779 + * pci_rescan_bus_bridge_resize - Scan a PCI bus for devices 2878 2780 * @bridge: PCI bridge for the bus to scan 2879 2781 * 2880 2782 * Scan a PCI bus and child buses for new devices, add them, ··· 2899 2801 } 2900 2802 2901 2803 /** 2902 - * pci_rescan_bus - scan a PCI bus for devices. 2804 + * pci_rescan_bus - Scan a PCI bus for devices 2903 2805 * @bus: PCI bus to scan 2904 2806 * 2905 - * Scan a PCI bus and child buses for new devices, adds them, 2906 - * and enables them. 2807 + * Scan a PCI bus and child buses for new devices, add them, 2808 + * and enable them. 2907 2809 * 2908 2810 * Returns the max number of subordinate bus discovered. 2909 2811 */ ··· 2972 2874 break; 2973 2875 } 2974 2876 if (busnr-- > end) { 2975 - dev_err(&dev->dev, "No bus number available for hot-added bridge\n"); 2877 + pci_err(dev, "No bus number available for hot-added bridge\n"); 2976 2878 return -1; 2977 2879 } 2978 2880
+106 -104
drivers/pci/quirks.c
··· 19 19 #include <linux/init.h> 20 20 #include <linux/delay.h> 21 21 #include <linux/acpi.h> 22 - #include <linux/kallsyms.h> 23 22 #include <linux/dmi.h> 24 23 #include <linux/pci-aspm.h> 25 24 #include <linux/ioport.h> ··· 65 66 while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) { 66 67 pci_read_config_byte(d, 0x82, &dlc); 67 68 if (!(dlc & 1<<1)) { 68 - dev_info(&d->dev, "PIIX3: Enabling Passive Release\n"); 69 + pci_info(d, "PIIX3: Enabling Passive Release\n"); 69 70 dlc |= 1<<1; 70 71 pci_write_config_byte(d, 0x82, dlc); 71 72 } ··· 85 86 { 86 87 if (!isa_dma_bridge_buggy) { 87 88 isa_dma_bridge_buggy = 1; 88 - dev_info(&dev->dev, "Activating ISA DMA hang workarounds\n"); 89 + pci_info(dev, "Activating ISA DMA hang workarounds\n"); 89 90 } 90 91 } 91 92 /* ··· 114 115 pm1a = inw(pmbase); 115 116 116 117 if (pm1a & 0x10) { 117 - dev_info(&dev->dev, FW_BUG "TigerPoint LPC.BM_STS cleared\n"); 118 + pci_info(dev, FW_BUG "TigerPoint LPC.BM_STS cleared\n"); 118 119 outw(0x10, pmbase); 119 120 } 120 121 } ··· 126 127 static void quirk_nopcipci(struct pci_dev *dev) 127 128 { 128 129 if ((pci_pci_problems & PCIPCI_FAIL) == 0) { 129 - dev_info(&dev->dev, "Disabling direct PCI/PCI transfers\n"); 130 + pci_info(dev, "Disabling direct PCI/PCI transfers\n"); 130 131 pci_pci_problems |= PCIPCI_FAIL; 131 132 } 132 133 } ··· 139 140 pci_read_config_byte(dev, 0x08, &rev); 140 141 if (rev == 0x13) { 141 142 /* Erratum 24 */ 142 - dev_info(&dev->dev, "Chipset erratum: Disabling direct PCI/AGP transfers\n"); 143 + pci_info(dev, "Chipset erratum: Disabling direct PCI/AGP transfers\n"); 143 144 pci_pci_problems |= PCIAGP_FAIL; 144 145 } 145 146 } ··· 151 152 static void quirk_triton(struct pci_dev *dev) 152 153 { 153 154 if ((pci_pci_problems&PCIPCI_TRITON) == 0) { 154 - dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); 155 + pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 155 156 pci_pci_problems |= PCIPCI_TRITON; 156 157 } 157 158 } ··· 211 212 busarb &= ~(1<<5); 212 213 busarb |= (1<<4); 213 214 pci_write_config_byte(dev, 0x76, busarb); 214 - dev_info(&dev->dev, "Applying VIA southbridge workaround\n"); 215 + pci_info(dev, "Applying VIA southbridge workaround\n"); 215 216 exit: 216 217 pci_dev_put(p); 217 218 } ··· 229 230 static void quirk_viaetbf(struct pci_dev *dev) 230 231 { 231 232 if ((pci_pci_problems&PCIPCI_VIAETBF) == 0) { 232 - dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); 233 + pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 233 234 pci_pci_problems |= PCIPCI_VIAETBF; 234 235 } 235 236 } ··· 238 239 static void quirk_vsfx(struct pci_dev *dev) 239 240 { 240 241 if ((pci_pci_problems&PCIPCI_VSFX) == 0) { 241 - dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); 242 + pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 242 243 pci_pci_problems |= PCIPCI_VSFX; 243 244 } 244 245 } ··· 253 254 static void quirk_alimagik(struct pci_dev *dev) 254 255 { 255 256 if ((pci_pci_problems&PCIPCI_ALIMAGIK) == 0) { 256 - dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); 257 + pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 257 258 pci_pci_problems |= PCIPCI_ALIMAGIK|PCIPCI_TRITON; 258 259 } 259 260 } ··· 267 268 static void quirk_natoma(struct pci_dev *dev) 268 269 { 269 270 if ((pci_pci_problems&PCIPCI_NATOMA) == 0) { 270 - dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); 271 + pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 271 272 pci_pci_problems |= PCIPCI_NATOMA; 272 273 } 273 274 } ··· 312 313 r->end = PAGE_SIZE - 1; 313 314 r->start = 0; 314 315 r->flags |= IORESOURCE_UNSET; 315 - dev_info(&dev->dev, "expanded BAR %d to page size: %pR\n", 316 + pci_info(dev, "expanded BAR %d to page size: %pR\n", 316 317 i, r); 317 318 } 318 319 } ··· 359 360 bus_region.end = region + size - 1; 360 361 pcibios_bus_to_resource(dev->bus, res, &bus_region); 361 362 362 - dev_info(&dev->dev, FW_BUG "%s quirk: reg 0x%x: %pR\n", 363 + pci_info(dev, FW_BUG "%s quirk: reg 0x%x: %pR\n", 363 364 name, PCI_BASE_ADDRESS_0 + (pos << 2), res); 364 365 } 365 366 ··· 380 381 quirk_io(dev, 0, 8, name); /* SMB */ 381 382 quirk_io(dev, 1, 256, name); /* GPIO */ 382 383 quirk_io(dev, 2, 64, name); /* MFGPT */ 383 - dev_info(&dev->dev, "%s bug detected (incorrect header); workaround applied\n", 384 + pci_info(dev, "%s bug detected (incorrect header); workaround applied\n", 384 385 name); 385 386 } 386 387 } ··· 408 409 pcibios_bus_to_resource(dev->bus, res, &bus_region); 409 410 410 411 if (!pci_claim_resource(dev, nr)) 411 - dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name); 412 + pci_info(dev, "quirk: %pR claimed by %s\n", res, name); 412 413 } 413 414 414 415 /* ··· 417 418 */ 418 419 static void quirk_ati_exploding_mce(struct pci_dev *dev) 419 420 { 420 - dev_info(&dev->dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n"); 421 + pci_info(dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n"); 421 422 /* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */ 422 423 request_region(0x3b0, 0x0C, "RadeonIGP"); 423 424 request_region(0x3d3, 0x01, "RadeonIGP"); ··· 440 441 441 442 /* Use "USB Device (not host controller)" class */ 442 443 pdev->class = PCI_CLASS_SERIAL_USB_DEVICE; 443 - dev_info(&pdev->dev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n", 444 + pci_info(pdev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n", 444 445 class, pdev->class); 445 446 } 446 447 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB, ··· 487 488 * let's get enough confirmation reports first. 488 489 */ 489 490 base &= -size; 490 - dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, 491 - base + size - 1); 491 + pci_info(dev, "%s PIO at %04x-%04x\n", name, base, base + size - 1); 492 492 } 493 493 494 494 static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable) ··· 512 514 * reserve it, but let's get enough confirmation reports first. 513 515 */ 514 516 base &= -size; 515 - dev_info(&dev->dev, "%s MMIO at %04x-%04x\n", name, base, 516 - base + size - 1); 517 + pci_info(dev, "%s MMIO at %04x-%04x\n", name, base, base + size - 1); 517 518 } 518 519 519 520 /* ··· 641 644 base &= ~(size-1); 642 645 643 646 /* Just print it out for now. We should reserve it after more debugging */ 644 - dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base+size-1); 647 + pci_info(dev, "%s PIO at %04x-%04x\n", name, base, base+size-1); 645 648 } 646 649 647 650 static void quirk_ich6_lpc(struct pci_dev *dev) ··· 676 679 mask |= 3; 677 680 678 681 /* Just print it out for now. We should reserve it after more debugging */ 679 - dev_info(&dev->dev, "%s PIO at %04x (mask %04x)\n", name, base, mask); 682 + pci_info(dev, "%s PIO at %04x (mask %04x)\n", name, base, mask); 680 683 } 681 684 682 685 /* ICH7-10 has the same common LPC generic IO decode registers */ ··· 755 758 struct pci_dev *pdev; 756 759 u16 command; 757 760 758 - dev_warn(&dev->dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n"); 761 + pci_warn(dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n"); 759 762 list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) { 760 763 pci_read_config_word(pdev, PCI_COMMAND, &command); 761 764 if (command & PCI_COMMAND_FAST_BACK) ··· 785 788 else 786 789 tmp = 0x1f; /* all known bits (4-0) routed to external APIC */ 787 790 788 - dev_info(&dev->dev, "%sbling VIA external APIC routing\n", 791 + pci_info(dev, "%sbling VIA external APIC routing\n", 789 792 tmp == 0 ? "Disa" : "Ena"); 790 793 791 794 /* Offset 0x58: External APIC IRQ output control */ ··· 807 810 808 811 pci_read_config_byte(dev, 0x5B, &misc_control2); 809 812 if (!(misc_control2 & BYPASS_APIC_DEASSERT)) { 810 - dev_info(&dev->dev, "Bypassing VIA 8237 APIC De-Assert Message\n"); 813 + pci_info(dev, "Bypassing VIA 8237 APIC De-Assert Message\n"); 811 814 pci_write_config_byte(dev, 0x5B, misc_control2|BYPASS_APIC_DEASSERT); 812 815 } 813 816 } ··· 826 829 static void quirk_amd_ioapic(struct pci_dev *dev) 827 830 { 828 831 if (dev->revision >= 0x02) { 829 - dev_warn(&dev->dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n"); 830 - dev_warn(&dev->dev, " : booting with the \"noapic\" option\n"); 832 + pci_warn(dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n"); 833 + pci_warn(dev, " : booting with the \"noapic\" option\n"); 831 834 } 832 835 } 833 836 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, quirk_amd_ioapic); ··· 851 854 static void quirk_amd_8131_mmrbc(struct pci_dev *dev) 852 855 { 853 856 if (dev->subordinate && dev->revision <= 0x12) { 854 - dev_info(&dev->dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n", 857 + pci_info(dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n", 855 858 dev->revision); 856 859 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MMRBC; 857 860 } ··· 959 962 960 963 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); 961 964 if (new_irq != irq) { 962 - dev_info(&dev->dev, "VIA VLink IRQ fixup, from %d to %d\n", 965 + pci_info(dev, "VIA VLink IRQ fixup, from %d to %d\n", 963 966 irq, new_irq); 964 967 udelay(15); /* unknown if delay really needed */ 965 968 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); ··· 1008 1011 pci_read_config_dword(dev, 0x4C, &pcic); 1009 1012 if ((pcic & 6) != 6) { 1010 1013 pcic |= 6; 1011 - dev_warn(&dev->dev, "BIOS failed to enable PCI standards compliance; fixing this error\n"); 1014 + pci_warn(dev, "BIOS failed to enable PCI standards compliance; fixing this error\n"); 1012 1015 pci_write_config_dword(dev, 0x4C, pcic); 1013 1016 pci_read_config_dword(dev, 0x84, &pcic); 1014 1017 pcic |= (1 << 23); /* Required in this mode */ ··· 1061 1064 pci_read_config_byte(dev, 0x41, &reg); 1062 1065 if (reg & 2) { 1063 1066 reg &= ~2; 1064 - dev_info(&dev->dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", 1067 + pci_info(dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", 1065 1068 reg); 1066 1069 pci_write_config_byte(dev, 0x41, reg); 1067 1070 } ··· 1084 1087 if (config & (1<<6)) { 1085 1088 config &= ~(1<<6); 1086 1089 pci_write_config_word(pdev, 0x40, config); 1087 - dev_info(&pdev->dev, "C0 revision 450NX. Disabling PCI restreaming\n"); 1090 + pci_info(pdev, "C0 revision 450NX. Disabling PCI restreaming\n"); 1088 1091 } 1089 1092 } 1090 1093 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); ··· 1104 1107 pci_write_config_byte(pdev, 0x40, tmp); 1105 1108 1106 1109 pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; 1107 - dev_info(&pdev->dev, "set SATA to AHCI mode\n"); 1110 + pci_info(pdev, "set SATA to AHCI mode\n"); 1108 1111 } 1109 1112 } 1110 1113 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); ··· 1142 1145 pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); 1143 1146 1144 1147 if (((prog & 1) && !(prog & 4)) || ((prog & 4) && !(prog & 1))) { 1145 - dev_info(&pdev->dev, "IDE mode mismatch; forcing legacy mode\n"); 1148 + pci_info(pdev, "IDE mode mismatch; forcing legacy mode\n"); 1146 1149 prog &= ~5; 1147 1150 pdev->class &= ~5; 1148 1151 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); ··· 1353 1356 pci_write_config_word(dev, 0xF2, val & (~0x8)); 1354 1357 pci_read_config_word(dev, 0xF2, &val); 1355 1358 if (val & 0x8) 1356 - dev_info(&dev->dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n", 1359 + pci_info(dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n", 1357 1360 val); 1358 1361 else 1359 - dev_info(&dev->dev, "Enabled i801 SMBus device\n"); 1362 + pci_info(dev, "Enabled i801 SMBus device\n"); 1360 1363 } 1361 1364 } 1362 1365 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); ··· 1408 1411 return; 1409 1412 iounmap(asus_rcba_base); 1410 1413 asus_rcba_base = NULL; 1411 - dev_info(&dev->dev, "Enabled ICH6/i801 SMBus device\n"); 1414 + pci_info(dev, "Enabled ICH6/i801 SMBus device\n"); 1412 1415 } 1413 1416 1414 1417 static void asus_hides_smbus_lpc_ich6(struct pci_dev *dev) ··· 1430 1433 u8 val = 0; 1431 1434 pci_read_config_byte(dev, 0x77, &val); 1432 1435 if (val & 0x10) { 1433 - dev_info(&dev->dev, "Enabling SiS 96x SMBus\n"); 1436 + pci_info(dev, "Enabling SiS 96x SMBus\n"); 1434 1437 pci_write_config_byte(dev, 0x77, val & ~0x10); 1435 1438 } 1436 1439 } ··· 1502 1505 pci_write_config_byte(dev, 0x50, val & (~0xc0)); 1503 1506 pci_read_config_byte(dev, 0x50, &val); 1504 1507 if (val & 0xc0) 1505 - dev_info(&dev->dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", 1508 + pci_info(dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", 1506 1509 val); 1507 1510 else 1508 - dev_info(&dev->dev, "Enabled onboard AC97/MC97 devices\n"); 1511 + pci_info(dev, "Enabled onboard AC97/MC97 devices\n"); 1509 1512 } 1510 1513 } 1511 1514 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); ··· 1596 1599 { 1597 1600 if (dev->multifunction) { 1598 1601 device_disable_async_suspend(&dev->dev); 1599 - dev_info(&dev->dev, "async suspend disabled to avoid multi-function power-on ordering issue\n"); 1602 + pci_info(dev, "async suspend disabled to avoid multi-function power-on ordering issue\n"); 1600 1603 } 1601 1604 } 1602 1605 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE, 8, quirk_jmicron_async_suspend); ··· 1633 1636 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_pcie_mch); 1634 1637 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch); 1635 1638 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_pcie_mch); 1636 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, quirk_pcie_mch); 1637 1639 1640 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI, 8, quirk_pcie_mch); 1638 1641 1639 1642 /* 1640 1643 * It's possible for the MSI to get corrupted if shpc and acpi ··· 1643 1646 static void quirk_pcie_pxh(struct pci_dev *dev) 1644 1647 { 1645 1648 dev->no_msi = 1; 1646 - dev_warn(&dev->dev, "PXH quirk detected; SHPC device MSI disabled\n"); 1649 + pci_warn(dev, "PXH quirk detected; SHPC device MSI disabled\n"); 1647 1650 } 1648 1651 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_0, quirk_pcie_pxh); 1649 1652 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_1, quirk_pcie_pxh); ··· 1689 1692 dev->subsystem_device == 0x00e2) { 1690 1693 if (dev->d3_delay < 20) { 1691 1694 dev->d3_delay = 20; 1692 - dev_info(&dev->dev, "extending delay after power-on from D3 to %d msec\n", 1695 + pci_info(dev, "extending delay after power-on from D3 to %d msec\n", 1693 1696 dev->d3_delay); 1694 1697 } 1695 1698 } ··· 1733 1736 return; 1734 1737 1735 1738 dev->irq_reroute_variant = INTEL_IRQ_REROUTE_VARIANT; 1736 - dev_info(&dev->dev, "rerouting interrupts for [%04x:%04x]\n", 1739 + pci_info(dev, "rerouting interrupts for [%04x:%04x]\n", 1737 1740 dev->vendor, dev->device); 1738 1741 } 1739 1742 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel); ··· 1776 1779 pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ; 1777 1780 pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, pci_config_word); 1778 1781 1779 - dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", 1782 + pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 1780 1783 dev->vendor, dev->device); 1781 1784 } 1782 1785 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt); ··· 1809 1812 1810 1813 pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword); 1811 1814 1812 - dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", 1815 + pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 1813 1816 dev->vendor, dev->device); 1814 1817 } 1815 1818 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); ··· 1842 1845 pci_config_dword &= ~AMD_813X_NOIOAMODE; 1843 1846 pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword); 1844 1847 1845 - dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", 1848 + pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 1846 1849 dev->vendor, dev->device); 1847 1850 } 1848 1851 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt); ··· 1861 1864 1862 1865 pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word); 1863 1866 if (!pci_config_word) { 1864 - dev_info(&dev->dev, "boot interrupts on device [%04x:%04x] already disabled\n", 1867 + pci_info(dev, "boot interrupts on device [%04x:%04x] already disabled\n", 1865 1868 dev->vendor, dev->device); 1866 1869 return; 1867 1870 } 1868 1871 pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0); 1869 - dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n", 1872 + pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 1870 1873 dev->vendor, dev->device); 1871 1874 } 1872 1875 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); ··· 1910 1913 if (pci_resource_len(dev, bar) == 0x80 && 1911 1914 (pci_resource_start(dev, bar) & 0x80)) { 1912 1915 struct resource *r = &dev->resource[bar]; 1913 - dev_info(&dev->dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", 1916 + pci_info(dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", 1914 1917 bar); 1915 1918 r->flags |= IORESOURCE_UNSET; 1916 1919 r->start = 0; ··· 1957 1960 case PCI_DEVICE_ID_NETMOS_9845: 1958 1961 case PCI_DEVICE_ID_NETMOS_9855: 1959 1962 if (num_parallel) { 1960 - dev_info(&dev->dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n", 1963 + pci_info(dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n", 1961 1964 dev->device, num_parallel, num_serial); 1962 1965 dev->class = (PCI_CLASS_COMMUNICATION_OTHER << 8) | 1963 1966 (dev->class & 0xff); ··· 2043 2046 /* Convert from PCI bus to resource space. */ 2044 2047 csr = ioremap(pci_resource_start(dev, 0), 8); 2045 2048 if (!csr) { 2046 - dev_warn(&dev->dev, "Can't map e100 registers\n"); 2049 + pci_warn(dev, "Can't map e100 registers\n"); 2047 2050 return; 2048 2051 } 2049 2052 2050 2053 cmd_hi = readb(csr + 3); 2051 2054 if (cmd_hi == 0) { 2052 - dev_warn(&dev->dev, "Firmware left e100 interrupts enabled; disabling\n"); 2055 + pci_warn(dev, "Firmware left e100 interrupts enabled; disabling\n"); 2053 2056 writeb(1, csr + 3); 2054 2057 } 2055 2058 ··· 2064 2067 */ 2065 2068 static void quirk_disable_aspm_l0s(struct pci_dev *dev) 2066 2069 { 2067 - dev_info(&dev->dev, "Disabling L0s\n"); 2070 + pci_info(dev, "Disabling L0s\n"); 2068 2071 pci_disable_link_state(dev, PCIE_LINK_STATE_L0S); 2069 2072 } 2070 2073 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s); ··· 2094 2097 return; 2095 2098 2096 2099 dev->class = PCI_CLASS_STORAGE_SCSI << 8; 2097 - dev_info(&dev->dev, "NCR 53c810 rev 1 PCI class overridden (%#08x -> %#08x)\n", 2100 + pci_info(dev, "NCR 53c810 rev 1 PCI class overridden (%#08x -> %#08x)\n", 2098 2101 class, dev->class); 2099 2102 } 2100 2103 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); ··· 2107 2110 pci_read_config_word(dev, 0x40, &en1k); 2108 2111 2109 2112 if (en1k & 0x200) { 2110 - dev_info(&dev->dev, "Enable I/O Space to 1KB granularity\n"); 2113 + pci_info(dev, "Enable I/O Space to 1KB granularity\n"); 2111 2114 dev->io_window_1k = 1; 2112 2115 } 2113 2116 } ··· 2123 2126 if (pci_read_config_byte(dev, 0xf41, &b) == 0) { 2124 2127 if (!(b & 0x20)) { 2125 2128 pci_write_config_byte(dev, 0xf41, b | 0x20); 2126 - dev_info(&dev->dev, "Linking AER extended capability\n"); 2129 + pci_info(dev, "Linking AER extended capability\n"); 2127 2130 } 2128 2131 } 2129 2132 } ··· 2161 2164 /* Turn off PCI Bus Parking */ 2162 2165 pci_write_config_byte(dev, 0x76, b ^ 0x40); 2163 2166 2164 - dev_info(&dev->dev, "Disabling VIA CX700 PCI parking\n"); 2167 + pci_info(dev, "Disabling VIA CX700 PCI parking\n"); 2165 2168 } 2166 2169 } 2167 2170 ··· 2176 2179 /* Disable "Read FIFO Timer" */ 2177 2180 pci_write_config_byte(dev, 0x77, 0x0); 2178 2181 2179 - dev_info(&dev->dev, "Disabling VIA CX700 PCI caching\n"); 2182 + pci_info(dev, "Disabling VIA CX700 PCI caching\n"); 2180 2183 } 2181 2184 } 2182 2185 } ··· 2193 2196 { 2194 2197 if (dev->vpd) { 2195 2198 dev->vpd->len = 0; 2196 - dev_warn(&dev->dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n"); 2199 + pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n"); 2197 2200 } 2198 2201 } 2199 2202 ··· 2309 2312 u8 reg; 2310 2313 2311 2314 if (pci_read_config_byte(dev, 0xF4, &reg) == 0 && !(reg & 0x02)) { 2312 - dev_info(&dev->dev, "Enabling MCH 'Overflow' Device\n"); 2315 + pci_info(dev, "Enabling MCH 'Overflow' Device\n"); 2313 2316 pci_write_config_byte(dev, 0xF4, reg | 0x02); 2314 2317 } 2315 2318 } ··· 2348 2351 static void quirk_disable_all_msi(struct pci_dev *dev) 2349 2352 { 2350 2353 pci_no_msi(); 2351 - dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n"); 2354 + pci_warn(dev, "MSI quirk detected; MSI disabled\n"); 2352 2355 } 2353 2356 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi); 2354 2357 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); ··· 2363 2366 static void quirk_disable_msi(struct pci_dev *dev) 2364 2367 { 2365 2368 if (dev->subordinate) { 2366 - dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n"); 2369 + pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); 2367 2370 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 2368 2371 } 2369 2372 } ··· 2403 2406 2404 2407 if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 2405 2408 &flags) == 0) { 2406 - dev_info(&dev->dev, "Found %s HT MSI Mapping\n", 2409 + pci_info(dev, "Found %s HT MSI Mapping\n", 2407 2410 flags & HT_MSI_FLAGS_ENABLE ? 2408 2411 "enabled" : "disabled"); 2409 2412 return (flags & HT_MSI_FLAGS_ENABLE) != 0; ··· 2419 2422 static void quirk_msi_ht_cap(struct pci_dev *dev) 2420 2423 { 2421 2424 if (dev->subordinate && !msi_ht_cap_enabled(dev)) { 2422 - dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n"); 2425 + pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); 2423 2426 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 2424 2427 } 2425 2428 } ··· 2443 2446 if (!pdev) 2444 2447 return; 2445 2448 if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) { 2446 - dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n"); 2449 + pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); 2447 2450 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 2448 2451 } 2449 2452 pci_dev_put(pdev); ··· 2462 2465 2463 2466 if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 2464 2467 &flags) == 0) { 2465 - dev_info(&dev->dev, "Enabling HT MSI Mapping\n"); 2468 + pci_info(dev, "Enabling HT MSI Mapping\n"); 2466 2469 2467 2470 pci_write_config_byte(dev, pos + HT_MSI_FLAGS, 2468 2471 flags | HT_MSI_FLAGS_ENABLE); ··· 2489 2492 if (board_name && 2490 2493 (strstr(board_name, "P5N32-SLI PREMIUM") || 2491 2494 strstr(board_name, "P5N32-E SLI"))) { 2492 - dev_info(&dev->dev, "Disabling msi for MCP55 NIC on P5N32-SLI\n"); 2495 + pci_info(dev, "Disabling MSI for MCP55 NIC on P5N32-SLI\n"); 2493 2496 dev->no_msi = 1; 2494 2497 } 2495 2498 } ··· 2666 2669 2667 2670 if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 2668 2671 &flags) == 0) { 2669 - dev_info(&dev->dev, "Disabling HT MSI Mapping\n"); 2672 + pci_info(dev, "Disabling HT MSI Mapping\n"); 2670 2673 2671 2674 pci_write_config_byte(dev, pos + HT_MSI_FLAGS, 2672 2675 flags & ~HT_MSI_FLAGS_ENABLE); ··· 2696 2699 * HT MSI mapping should be disabled on devices that are below 2697 2700 * a non-Hypertransport host bridge. Locate the host bridge... 2698 2701 */ 2699 - host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); 2702 + host_bridge = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus), 0, 2703 + PCI_DEVFN(0, 0)); 2700 2704 if (host_bridge == NULL) { 2701 - dev_warn(&dev->dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n"); 2705 + pci_warn(dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n"); 2702 2706 return; 2703 2707 } 2704 2708 ··· 2768 2770 { 2769 2771 /* AR816X/AR817X/E210X MSI is fixed at HW level from revision 0x18 */ 2770 2772 if (dev->revision < 0x18) { 2771 - dev_info(&dev->dev, "set MSI_INTX_DISABLE_BUG flag\n"); 2773 + pci_info(dev, "set MSI_INTX_DISABLE_BUG flag\n"); 2772 2774 dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; 2773 2775 } 2774 2776 } ··· 2897 2899 pci_write_config_byte(dev, 0x8E, write_enable); 2898 2900 pci_write_config_byte(dev, 0x8D, write_target); 2899 2901 2900 - dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via cardbus function)\n"); 2901 - dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n"); 2902 + pci_notice(dev, "proprietary Ricoh MMC controller disabled (via cardbus function)\n"); 2903 + pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n"); 2902 2904 } 2903 2905 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); 2904 2906 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); ··· 2933 2935 pci_write_config_byte(dev, 0xe1, 0x32); 2934 2936 pci_write_config_byte(dev, 0xfc, 0x00); 2935 2937 2936 - dev_notice(&dev->dev, "MMC controller base frequency changed to 50Mhz.\n"); 2938 + pci_notice(dev, "MMC controller base frequency changed to 50Mhz.\n"); 2937 2939 } 2938 2940 2939 2941 pci_read_config_byte(dev, 0xCB, &disable); ··· 2946 2948 pci_write_config_byte(dev, 0xCB, disable | 0x02); 2947 2949 pci_write_config_byte(dev, 0xCA, write_enable); 2948 2950 2949 - dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n"); 2950 - dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n"); 2951 + pci_notice(dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n"); 2952 + pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n"); 2951 2953 2952 2954 } 2953 2955 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); ··· 2988 2990 2989 2991 /* TI 816x devices do not have class code set when in PCIe boot mode */ 2990 2992 dev->class = PCI_CLASS_MULTIMEDIA_VIDEO << 8; 2991 - dev_info(&dev->dev, "PCI class overridden (%#08x -> %#08x)\n", 2993 + pci_info(dev, "PCI class overridden (%#08x -> %#08x)\n", 2992 2994 class, dev->class); 2993 2995 } 2994 2996 DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800, ··· 3030 3032 */ 3031 3033 err = pci_read_config_word(dev, 0x48, &rcc); 3032 3034 if (err) { 3033 - dev_err(&dev->dev, "Error attempting to read the read completion coalescing register\n"); 3035 + pci_err(dev, "Error attempting to read the read completion coalescing register\n"); 3034 3036 return; 3035 3037 } 3036 3038 ··· 3041 3043 3042 3044 err = pci_write_config_word(dev, 0x48, rcc); 3043 3045 if (err) { 3044 - dev_err(&dev->dev, "Error attempting to write the read completion coalescing register\n"); 3046 + pci_err(dev, "Error attempting to write the read completion coalescing register\n"); 3045 3047 return; 3046 3048 } 3047 3049 ··· 3106 3108 { 3107 3109 ktime_t calltime = 0; 3108 3110 3109 - dev_dbg(&dev->dev, "calling %pF\n", fn); 3111 + pci_dbg(dev, "calling %pF\n", fn); 3110 3112 if (initcall_debug) { 3111 3113 pr_debug("calling %pF @ %i for %s\n", 3112 3114 fn, task_pid_nr(current), dev_name(&dev->dev)); ··· 3148 3150 { 3149 3151 void __iomem *regs = pci_iomap(dev, 0, 0); 3150 3152 if (regs == NULL) { 3151 - dev_warn(&dev->dev, "igfx quirk: Can't iomap PCI device\n"); 3153 + pci_warn(dev, "igfx quirk: Can't iomap PCI device\n"); 3152 3154 return; 3153 3155 } 3154 3156 3155 3157 /* Check if any interrupt line is still enabled */ 3156 3158 if (readl(regs + I915_DEIER_REG) != 0) { 3157 - dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; disabling\n"); 3159 + pci_warn(dev, "BIOS left Intel GPU interrupts enabled; disabling\n"); 3158 3160 3159 3161 writel(0, regs + I915_DEIER_REG); 3160 3162 } ··· 3212 3214 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x0030, 3213 3215 quirk_broken_intx_masking); 3214 3216 DECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */ 3217 + quirk_broken_intx_masking); 3218 + DECLARE_PCI_FIXUP_FINAL(0x1b7c, 0x0004, /* Ceton InfiniTV4 */ 3215 3219 quirk_broken_intx_masking); 3216 3220 3217 3221 /* ··· 3317 3317 3318 3318 /* For ConnectX-4 and ConnectX-4LX, need to check FW support */ 3319 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 3321 return; 3322 3322 } 3323 3323 3324 3324 fw_ver = ioremap(pci_resource_start(pdev, 0), 4); 3325 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 3327 goto out; 3328 3328 } 3329 3329 ··· 3335 3335 fw_subminor = fw_sub_min & 0xffff; 3336 3336 if (fw_minor > CONNECTX_4_CURR_MAX_MINOR || 3337 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 3339 fw_major, fw_minor, fw_subminor, pdev->device == 3340 3340 PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14); 3341 3341 pdev->broken_intx_masking = 1; ··· 3473 3473 || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXFP", &SXFP)) 3474 3474 || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXLV", &SXLV))) 3475 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 3478 /* magic sequence */ 3479 3479 acpi_execute_simple_method(SXIO, NULL, 1); ··· 3524 3524 nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI) 3525 3525 || nhi->class != PCI_CLASS_SYSTEM_OTHER << 8) 3526 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 3528 device_pm_wait_for_dev(&dev->dev, &nhi->dev); 3529 3529 out: 3530 3530 pci_dev_put(nhi); ··· 3740 3740 goto reset_complete; 3741 3741 msleep(10); 3742 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 3745 reset_complete: 3746 3746 iowrite32(0x00000002, mmio_base + NSDE_PWR_STATE); ··· 3879 3879 quirk_dma_func1_alias); 3880 3880 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9123, 3881 3881 quirk_dma_func1_alias); 3882 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9128, 3883 + quirk_dma_func1_alias); 3882 3884 /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ 3883 3885 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130, 3884 3886 quirk_dma_func1_alias); ··· 4014 4012 4015 4013 /* Use "Multimedia controller" class */ 4016 4014 pdev->class = (PCI_CLASS_MULTIMEDIA_OTHER << 8) | 0x01; 4017 - dev_info(&pdev->dev, "TW686x PCI class overridden (%#08x -> %#08x)\n", 4015 + pci_info(pdev, "TW686x PCI class overridden (%#08x -> %#08x)\n", 4018 4016 class, pdev->class); 4019 4017 } 4020 4018 DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6864, PCI_CLASS_NOT_DEFINED, 8, ··· 4034 4032 static void quirk_relaxedordering_disable(struct pci_dev *dev) 4035 4033 { 4036 4034 dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING; 4037 - dev_info(&dev->dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n"); 4035 + pci_info(dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n"); 4038 4036 } 4039 4037 4040 4038 /* ··· 4143 4141 struct pci_dev *root_port = pci_find_pcie_root_port(pdev); 4144 4142 4145 4143 if (!root_port) { 4146 - dev_warn(&pdev->dev, "PCIe Completion erratum may cause device errors\n"); 4144 + pci_warn(pdev, "PCIe Completion erratum may cause device errors\n"); 4147 4145 return; 4148 4146 } 4149 4147 4150 - dev_info(&root_port->dev, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", 4148 + pci_info(root_port, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", 4151 4149 dev_name(&pdev->dev)); 4152 4150 pcie_capability_clear_and_set_word(root_port, PCI_EXP_DEVCTL, 4153 4151 PCI_EXP_DEVCTL_RELAX_EN | ··· 4341 4339 u16 flags = (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV); 4342 4340 int ret = acs_flags & ~flags ? 0 : 1; 4343 4341 4344 - dev_info(&dev->dev, "Using QCOM ACS Quirk (%d)\n", ret); 4342 + pci_info(dev, "Using QCOM ACS Quirk (%d)\n", ret); 4345 4343 4346 4344 return ret; 4347 4345 } ··· 4593 4591 if (bspr != (INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD)) { 4594 4592 updcr = readl(rcba_mem + INTEL_UPDCR_REG); 4595 4593 if (updcr & INTEL_UPDCR_REG_MASK) { 4596 - dev_info(&dev->dev, "Disabling UPDCR peer decodes\n"); 4594 + pci_info(dev, "Disabling UPDCR peer decodes\n"); 4597 4595 updcr &= ~INTEL_UPDCR_REG_MASK; 4598 4596 writel(updcr, rcba_mem + INTEL_UPDCR_REG); 4599 4597 } ··· 4620 4618 */ 4621 4619 pci_read_config_dword(dev, INTEL_MPC_REG, &mpc); 4622 4620 if (!(mpc & INTEL_MPC_REG_IRBNCE)) { 4623 - dev_info(&dev->dev, "Enabling MPC IRBNCE\n"); 4621 + pci_info(dev, "Enabling MPC IRBNCE\n"); 4624 4622 mpc |= INTEL_MPC_REG_IRBNCE; 4625 4623 pci_write_config_word(dev, INTEL_MPC_REG, mpc); 4626 4624 } ··· 4632 4630 return -ENOTTY; 4633 4631 4634 4632 if (pci_quirk_enable_intel_lpc_acs(dev)) { 4635 - dev_warn(&dev->dev, "Failed to enable Intel PCH ACS quirk\n"); 4633 + pci_warn(dev, "Failed to enable Intel PCH ACS quirk\n"); 4636 4634 return 0; 4637 4635 } 4638 4636 ··· 4640 4638 4641 4639 dev->dev_flags |= PCI_DEV_FLAGS_ACS_ENABLED_QUIRK; 4642 4640 4643 - dev_info(&dev->dev, "Intel PCH root port ACS workaround enabled\n"); 4641 + pci_info(dev, "Intel PCH root port ACS workaround enabled\n"); 4644 4642 4645 4643 return 0; 4646 4644 } ··· 4667 4665 4668 4666 pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); 4669 4667 4670 - dev_info(&dev->dev, "Intel SPT PCH root port ACS workaround enabled\n"); 4668 + pci_info(dev, "Intel SPT PCH root port ACS workaround enabled\n"); 4671 4669 4672 4670 return 0; 4673 4671 } ··· 4802 4800 return; 4803 4801 4804 4802 bridge->no_ext_tags = 1; 4805 - dev_info(&pdev->dev, "disabling Extended Tags (this device can't handle them)\n"); 4803 + pci_info(pdev, "disabling Extended Tags (this device can't handle them)\n"); 4806 4804 4807 4805 pci_walk_bus(bridge->bus, pci_configure_extended_tags, NULL); 4808 4806 } ··· 4817 4815 */ 4818 4816 static void quirk_no_ats(struct pci_dev *pdev) 4819 4817 { 4820 - dev_info(&pdev->dev, "disabling ATS (broken on this device)\n"); 4818 + pci_info(pdev, "disabling ATS (broken on this device)\n"); 4821 4819 pdev->ats_cap = 0; 4822 4820 } 4823 4821
+1
drivers/pci/remove.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 #include <linux/pci.h> 2 3 #include <linux/module.h> 3 4 #include <linux/pci-aspm.h>
+5 -4
drivers/pci/rom.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/rom.c 3 4 * ··· 93 92 void __iomem *pds; 94 93 /* Standard PCI ROMs start out with these bytes 55 AA */ 95 94 if (readw(image) != 0xAA55) { 96 - dev_err(&pdev->dev, "Invalid PCI ROM header signature: expecting 0xaa55, got %#06x\n", 97 - readw(image)); 95 + pci_info(pdev, "Invalid PCI ROM header signature: expecting 0xaa55, got %#06x\n", 96 + readw(image)); 98 97 break; 99 98 } 100 99 /* get the PCI data structure and check its "PCIR" signature */ 101 100 pds = image + readw(image + 24); 102 101 if (readl(pds) != 0x52494350) { 103 - dev_err(&pdev->dev, "Invalid PCI ROM data signature: expecting 0x52494350, got %#010x\n", 104 - readl(pds)); 102 + pci_info(pdev, "Invalid PCI ROM data signature: expecting 0x52494350, got %#010x\n", 103 + readl(pds)); 105 104 break; 106 105 } 107 106 last_image = readb(pds + 21) & 0x80;
+1
drivers/pci/search.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCI searching functions. 3 4 *
+24 -25
drivers/pci/setup-bus.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/setup-bus.c 3 4 * ··· 68 67 struct pci_dev_resource *tmp; 69 68 70 69 tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); 71 - if (!tmp) { 72 - pr_warn("add_to_list: kmalloc() failed!\n"); 70 + if (!tmp) 73 71 return -ENOMEM; 74 - } 75 72 76 73 tmp->res = res; 77 74 tmp->dev = dev; ··· 151 152 152 153 r_align = pci_resource_alignment(dev, r); 153 154 if (!r_align) { 154 - dev_warn(&dev->dev, "BAR %d: %pR has bogus alignment\n", 155 + pci_warn(dev, "BAR %d: %pR has bogus alignment\n", 155 156 i, r); 156 157 continue; 157 158 } ··· 259 260 (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); 260 261 if (pci_reassign_resource(add_res->dev, idx, 261 262 add_size, align)) 262 - dev_printk(KERN_DEBUG, &add_res->dev->dev, 263 + pci_printk(KERN_DEBUG, add_res->dev, 263 264 "failed to add %llx res[%d]=%pR\n", 264 265 (unsigned long long)add_size, 265 266 idx, res); ··· 518 519 struct resource *res; 519 520 struct pci_bus_region region; 520 521 521 - dev_info(&bridge->dev, "CardBus bridge to %pR\n", 522 + pci_info(bridge, "CardBus bridge to %pR\n", 522 523 &bus->busn_res); 523 524 524 525 res = bus->resource[0]; ··· 528 529 * The IO resource is allocated a range twice as large as it 529 530 * would normally need. This allows us to set both IO regs. 530 531 */ 531 - dev_info(&bridge->dev, " bridge window %pR\n", res); 532 + pci_info(bridge, " bridge window %pR\n", res); 532 533 pci_write_config_dword(bridge, PCI_CB_IO_BASE_0, 533 534 region.start); 534 535 pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_0, ··· 538 539 res = bus->resource[1]; 539 540 pcibios_resource_to_bus(bridge->bus, &region, res); 540 541 if (res->flags & IORESOURCE_IO) { 541 - dev_info(&bridge->dev, " bridge window %pR\n", res); 542 + pci_info(bridge, " bridge window %pR\n", res); 542 543 pci_write_config_dword(bridge, PCI_CB_IO_BASE_1, 543 544 region.start); 544 545 pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_1, ··· 548 549 res = bus->resource[2]; 549 550 pcibios_resource_to_bus(bridge->bus, &region, res); 550 551 if (res->flags & IORESOURCE_MEM) { 551 - dev_info(&bridge->dev, " bridge window %pR\n", res); 552 + pci_info(bridge, " bridge window %pR\n", res); 552 553 pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0, 553 554 region.start); 554 555 pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_0, ··· 558 559 res = bus->resource[3]; 559 560 pcibios_resource_to_bus(bridge->bus, &region, res); 560 561 if (res->flags & IORESOURCE_MEM) { 561 - dev_info(&bridge->dev, " bridge window %pR\n", res); 562 + pci_info(bridge, " bridge window %pR\n", res); 562 563 pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1, 563 564 region.start); 564 565 pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_1, ··· 601 602 l = ((u16) io_limit_lo << 8) | io_base_lo; 602 603 /* Set up upper 16 bits of I/O base/limit. */ 603 604 io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); 604 - dev_info(&bridge->dev, " bridge window %pR\n", res); 605 + pci_info(bridge, " bridge window %pR\n", res); 605 606 } else { 606 607 /* Clear upper 16 bits of I/O base/limit. */ 607 608 io_upper16 = 0; ··· 627 628 if (res->flags & IORESOURCE_MEM) { 628 629 l = (region.start >> 16) & 0xfff0; 629 630 l |= region.end & 0xfff00000; 630 - dev_info(&bridge->dev, " bridge window %pR\n", res); 631 + pci_info(bridge, " bridge window %pR\n", res); 631 632 } else { 632 633 l = 0x0000fff0; 633 634 } ··· 656 657 bu = upper_32_bits(region.start); 657 658 lu = upper_32_bits(region.end); 658 659 } 659 - dev_info(&bridge->dev, " bridge window %pR\n", res); 660 + pci_info(bridge, " bridge window %pR\n", res); 660 661 } else { 661 662 l = 0x0000fff0; 662 663 } ··· 671 672 { 672 673 struct pci_dev *bridge = bus->self; 673 674 674 - dev_info(&bridge->dev, "PCI bridge to %pR\n", 675 + pci_info(bridge, "PCI bridge to %pR\n", 675 676 &bus->busn_res); 676 677 677 678 if (type & IORESOURCE_IO) ··· 943 944 resource_size(b_res), min_align); 944 945 if (!size0 && !size1) { 945 946 if (b_res->start || b_res->end) 946 - dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n", 947 + pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", 947 948 b_res, &bus->busn_res); 948 949 b_res->flags = 0; 949 950 return; ··· 955 956 if (size1 > size0 && realloc_head) { 956 957 add_to_list(realloc_head, bus->self, b_res, size1-size0, 957 958 min_align); 958 - dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx\n", 959 + pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", 959 960 b_res, &bus->busn_res, 960 961 (unsigned long long)size1-size0); 961 962 } ··· 1060 1061 if (order < 0) 1061 1062 order = 0; 1062 1063 if (order >= ARRAY_SIZE(aligns)) { 1063 - dev_warn(&dev->dev, "disabling BAR %d: %pR (bad alignment %#llx)\n", 1064 + pci_warn(dev, "disabling BAR %d: %pR (bad alignment %#llx)\n", 1064 1065 i, r, (unsigned long long) align); 1065 1066 r->flags = 0; 1066 1067 continue; ··· 1092 1093 resource_size(b_res), add_align); 1093 1094 if (!size0 && !size1) { 1094 1095 if (b_res->start || b_res->end) 1095 - dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n", 1096 + pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", 1096 1097 b_res, &bus->busn_res); 1097 1098 b_res->flags = 0; 1098 1099 return 0; ··· 1102 1103 b_res->flags |= IORESOURCE_STARTALIGN; 1103 1104 if (size1 > size0 && realloc_head) { 1104 1105 add_to_list(realloc_head, bus->self, b_res, size1-size0, add_align); 1105 - dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx add_align %llx\n", 1106 + pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", 1106 1107 b_res, &bus->busn_res, 1107 1108 (unsigned long long) (size1 - size0), 1108 1109 (unsigned long long) add_align); ··· 1406 1407 break; 1407 1408 1408 1409 default: 1409 - dev_info(&dev->dev, "not setting up bridge for bus %04x:%02x\n", 1410 + pci_info(dev, "not setting up bridge for bus %04x:%02x\n", 1410 1411 pci_domain_nr(b), b->number); 1411 1412 break; 1412 1413 } ··· 1512 1513 break; 1513 1514 1514 1515 default: 1515 - dev_info(&bridge->dev, "not setting up bridge for bus %04x:%02x\n", 1516 + pci_info(bridge, "not setting up bridge for bus %04x:%02x\n", 1516 1517 pci_domain_nr(b), b->number); 1517 1518 break; 1518 1519 } ··· 1570 1571 release_child_resources(r); 1571 1572 if (!release_resource(r)) { 1572 1573 type = old_flags = r->flags & PCI_RES_TYPE_MASK; 1573 - dev_printk(KERN_DEBUG, &dev->dev, "resource %d %pR released\n", 1574 + pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n", 1574 1575 PCI_BRIDGE_RESOURCES + idx, r); 1575 1576 /* keep the old size */ 1576 1577 r->end = resource_size(r) - 1; ··· 1873 1874 return; 1874 1875 1875 1876 dev_res->add_size = available - resource_size(res); 1876 - dev_dbg(&bridge->dev, "bridge window %pR extended by %pa\n", res, 1877 + pci_dbg(bridge, "bridge window %pR extended by %pa\n", res, 1877 1878 &dev_res->add_size); 1878 1879 } 1879 1880 ··· 2084 2085 enable_all: 2085 2086 retval = pci_reenable_device(bridge); 2086 2087 if (retval) 2087 - dev_err(&bridge->dev, "Error reenabling bridge (%d)\n", retval); 2088 + pci_err(bridge, "Error reenabling bridge (%d)\n", retval); 2088 2089 pci_set_master(bridge); 2089 2090 } 2090 2091 EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); ··· 2118 2119 if (ret) 2119 2120 goto cleanup; 2120 2121 2121 - dev_info(&bridge->dev, "BAR %d: releasing %pR\n", 2122 + pci_info(bridge, "BAR %d: releasing %pR\n", 2122 2123 i, res); 2123 2124 2124 2125 if (res->parent)
+3 -2
drivers/pci/setup-irq.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/setup-irq.c 3 4 * ··· 26 25 struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); 27 26 28 27 if (!(hbrg->map_irq)) { 29 - dev_dbg(&dev->dev, "runtime IRQ mapping not provided by arch\n"); 28 + pci_dbg(dev, "runtime IRQ mapping not provided by arch\n"); 30 29 return; 31 30 } 32 31 ··· 56 55 } 57 56 dev->irq = irq; 58 57 59 - dev_dbg(&dev->dev, "assign IRQ: got %d\n", dev->irq); 58 + pci_dbg(dev, "assign IRQ: got %d\n", dev->irq); 60 59 61 60 /* Always tell the device, so the driver knows what is 62 61 the real IRQ to use; the device does not use it. */
+19 -21
drivers/pci/setup-res.c
··· 103 103 pci_read_config_dword(dev, reg, &check); 104 104 105 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 107 resno, new, check); 108 108 } 109 109 ··· 112 112 pci_write_config_dword(dev, reg + 4, new); 113 113 pci_read_config_dword(dev, reg + 4, &check); 114 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 116 resno, new, check); 117 117 } 118 118 } ··· 137 137 struct resource *root, *conflict; 138 138 139 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 141 resource, res); 142 142 return -EINVAL; 143 143 } ··· 152 152 153 153 root = pci_find_parent_resource(dev, res); 154 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 156 resource, res); 157 157 res->flags |= IORESOURCE_UNSET; 158 158 return -EINVAL; ··· 160 160 161 161 conflict = request_resource_conflict(root, res); 162 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 164 resource, res, conflict->name, conflict); 165 165 res->flags |= IORESOURCE_UNSET; 166 166 return -EBUSY; ··· 172 172 173 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 177 /* MMIO Base/Limit */ 178 178 pci_write_config_dword(dev, PCI_MEMORY_BASE, 0x0000fff0); ··· 221 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 225 resno, res); 226 226 conflict = request_resource_conflict(root, res); 227 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 229 resno, res, conflict->name, conflict); 230 230 res->start = start; 231 231 res->end = end; ··· 324 324 res->flags |= IORESOURCE_UNSET; 325 325 align = pci_resource_alignment(dev, res); 326 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 328 resno, res); 329 329 return -EINVAL; 330 330 } ··· 338 338 * working, which is better than just leaving it disabled. 339 339 */ 340 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 342 ret = pci_revert_fw_address(res, dev, resno, size); 343 343 } 344 344 345 345 if (ret < 0) { 346 - dev_info(&dev->dev, "BAR %d: failed to assign %pR\n", resno, 347 - res); 346 + pci_info(dev, "BAR %d: failed to assign %pR\n", resno, res); 348 347 return ret; 349 348 } 350 349 351 350 res->flags &= ~IORESOURCE_UNSET; 352 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 353 if (resno < PCI_BRIDGE_RESOURCES) 355 354 pci_update_resource(dev, resno); 356 355 ··· 371 372 flags = res->flags; 372 373 res->flags |= IORESOURCE_UNSET; 373 374 if (!res->parent) { 374 - dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n", 375 + pci_info(dev, "BAR %d: can't reassign an unassigned resource %pR\n", 375 376 resno, res); 376 377 return -EINVAL; 377 378 } ··· 381 382 ret = _pci_assign_resource(dev, resno, new_size, min_align); 382 383 if (ret) { 383 384 res->flags = flags; 384 - dev_info(&dev->dev, "BAR %d: %pR (failed to expand by %#llx)\n", 385 + pci_info(dev, "BAR %d: %pR (failed to expand by %#llx)\n", 385 386 resno, res, (unsigned long long) addsize); 386 387 return ret; 387 388 } 388 389 389 390 res->flags &= ~IORESOURCE_UNSET; 390 391 res->flags &= ~IORESOURCE_STARTALIGN; 391 - dev_info(&dev->dev, "BAR %d: reassigned %pR (expanded by %#llx)\n", 392 + pci_info(dev, "BAR %d: reassigned %pR (expanded by %#llx)\n", 392 393 resno, res, (unsigned long long) addsize); 393 394 if (resno < PCI_BRIDGE_RESOURCES) 394 395 pci_update_resource(dev, resno); ··· 400 401 { 401 402 struct resource *res = dev->resource + resno; 402 403 403 - dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res); 404 + pci_info(dev, "BAR %d: releasing %pR\n", resno, res); 404 405 release_resource(res); 405 406 res->end = resource_size(res) - 1; 406 407 res->start = 0; ··· 476 477 continue; 477 478 478 479 if (r->flags & IORESOURCE_UNSET) { 479 - dev_err(&dev->dev, "can't enable device: BAR %d %pR not assigned\n", 480 + pci_err(dev, "can't enable device: BAR %d %pR not assigned\n", 480 481 i, r); 481 482 return -EINVAL; 482 483 } 483 484 484 485 if (!r->parent) { 485 - dev_err(&dev->dev, "can't enable device: BAR %d %pR not claimed\n", 486 + pci_err(dev, "can't enable device: BAR %d %pR not claimed\n", 486 487 i, r); 487 488 return -EINVAL; 488 489 } ··· 494 495 } 495 496 496 497 if (cmd != old_cmd) { 497 - dev_info(&dev->dev, "enabling device (%04x -> %04x)\n", 498 - old_cmd, cmd); 498 + pci_info(dev, "enabling device (%04x -> %04x)\n", old_cmd, cmd); 499 499 pci_write_config_word(dev, PCI_COMMAND, cmd); 500 500 } 501 501 return 0;
+1
drivers/pci/slot.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * drivers/pci/slot.c 3 4 * Copyright (C) 2006 Matthew Wilcox <matthew@wil.cx>
+2
drivers/pci/switch/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 1 3 menu "PCI switch controller drivers" 2 4 depends on PCI 3 5
+1
drivers/pci/switch/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 1 2 obj-$(CONFIG_PCI_SW_SWITCHTEC) += switchtec.o
+4 -10
drivers/pci/switch/switchtec.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Microsemi Switchtec(tm) PCIe Management Driver 3 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 7 #include <linux/switchtec.h> ··· 698 707 EV_GLB(SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP_ASYNC, 699 708 cli_mrpc_comp_async_hdr), 700 709 EV_GLB(SWITCHTEC_IOCTL_EVENT_GPIO_INT, gpio_interrupt_hdr), 710 + EV_GLB(SWITCHTEC_IOCTL_EVENT_GFMS, gfms_event_hdr), 701 711 EV_PAR(SWITCHTEC_IOCTL_EVENT_PART_RESET, part_reset_hdr), 702 712 EV_PAR(SWITCHTEC_IOCTL_EVENT_MRPC_COMP, mrpc_comp_hdr), 703 713 EV_PAR(SWITCHTEC_IOCTL_EVENT_MRPC_COMP_ASYNC, mrpc_comp_async_hdr), ··· 1344 1352 SWITCHTEC_PCI_DEVICE(0x8534), //PFX 64xG3 1345 1353 SWITCHTEC_PCI_DEVICE(0x8535), //PFX 80xG3 1346 1354 SWITCHTEC_PCI_DEVICE(0x8536), //PFX 96xG3 1355 + SWITCHTEC_PCI_DEVICE(0x8541), //PSX 24xG3 1356 + SWITCHTEC_PCI_DEVICE(0x8542), //PSX 32xG3 1347 1357 SWITCHTEC_PCI_DEVICE(0x8543), //PSX 48xG3 1348 1358 SWITCHTEC_PCI_DEVICE(0x8544), //PSX 64xG3 1349 1359 SWITCHTEC_PCI_DEVICE(0x8545), //PSX 80xG3
+2 -2
drivers/pci/syscall.c
··· 28 28 return -EPERM; 29 29 30 30 err = -ENODEV; 31 - dev = pci_get_bus_and_slot(bus, dfn); 31 + dev = pci_get_domain_bus_and_slot(0, bus, dfn); 32 32 if (!dev) 33 33 goto error; 34 34 ··· 96 96 if (!capable(CAP_SYS_ADMIN)) 97 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 100 if (!dev) 101 101 return -ENODEV; 102 102
+9 -14
drivers/pci/vc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * PCI Virtual Channel support 3 4 * 4 5 * Copyright (C) 2013 Red Hat, Inc. All rights reserved. 5 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 9 #include <linux/device.h> ··· 54 57 PCI_VC_PORT_STATUS_TABLE)) 55 58 return; 56 59 57 - dev_err(&dev->dev, "VC arbitration table failed to load\n"); 60 + pci_err(dev, "VC arbitration table failed to load\n"); 58 61 } 59 62 60 63 /** ··· 82 85 if (pci_wait_for_pending(dev, status_pos, PCI_VC_RES_STATUS_TABLE)) 83 86 return; 84 87 85 - dev_err(&dev->dev, "VC%d port arbitration table failed to load\n", res); 88 + pci_err(dev, "VC%d port arbitration table failed to load\n", res); 86 89 } 87 90 88 91 /** ··· 158 161 pci_write_config_dword(dev, ctrl_pos, ctrl); 159 162 160 163 if (!pci_wait_for_pending(dev, status_pos, PCI_VC_RES_STATUS_NEGO)) 161 - dev_err(&dev->dev, "VC%d negotiation stuck pending\n", id); 164 + pci_err(dev, "VC%d negotiation stuck pending\n", id); 162 165 163 166 if (link && !pci_wait_for_pending(link, status_pos2, 164 167 PCI_VC_RES_STATUS_NEGO)) 165 - dev_err(&link->dev, "VC%d negotiation stuck pending\n", id); 168 + pci_err(link, "VC%d negotiation stuck pending\n", id); 166 169 } 167 170 168 171 /** ··· 192 195 /* Sanity check buffer size for save/restore */ 193 196 if (buf && save_state->cap.size != 194 197 pci_vc_do_save_buffer(dev, pos, NULL, save)) { 195 - dev_err(&dev->dev, 196 - "VC save buffer size does not match @0x%x\n", pos); 198 + pci_err(dev, "VC save buffer size does not match @0x%x\n", pos); 197 199 return -ENOMEM; 198 200 } 199 201 ··· 362 366 363 367 save_state = pci_find_saved_ext_cap(dev, vc_caps[i].id); 364 368 if (!save_state) { 365 - dev_err(&dev->dev, "%s buffer not found in %s\n", 369 + pci_err(dev, "%s buffer not found in %s\n", 366 370 vc_caps[i].name, __func__); 367 371 return -ENOMEM; 368 372 } 369 373 370 374 ret = pci_vc_do_save_buffer(dev, pos, save_state, true); 371 375 if (ret) { 372 - dev_err(&dev->dev, "%s save unsuccessful %s\n", 376 + pci_err(dev, "%s save unsuccessful %s\n", 373 377 vc_caps[i].name, __func__); 374 378 return ret; 375 379 } ··· 422 426 423 427 len = pci_vc_do_save_buffer(dev, pos, NULL, false); 424 428 if (pci_add_ext_cap_save_buffer(dev, vc_caps[i].id, len)) 425 - dev_err(&dev->dev, 426 - "unable to preallocate %s save buffer\n", 429 + pci_err(dev, "unable to preallocate %s save buffer\n", 427 430 vc_caps[i].name); 428 431 } 429 432 }
+1
drivers/pci/vpd.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * File: vpd.c 3 4 * Purpose: Provide PCI VPD support
+12 -11
drivers/pci/xen-pcifront.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Xen PCI Frontend. 3 4 * ··· 262 261 struct msi_desc *entry; 263 262 264 263 if (nvec > SH_INFO_MAX_VEC) { 265 - dev_err(&dev->dev, "too much vector for pci frontend: %x." 266 - " Increase SH_INFO_MAX_VEC.\n", nvec); 264 + pci_err(dev, "too many vectors (0x%x) for PCI frontend:" 265 + " Increase SH_INFO_MAX_VEC\n", nvec); 267 266 return -EINVAL; 268 267 } 269 268 ··· 282 281 /* we get the result */ 283 282 for (i = 0; i < nvec; i++) { 284 283 if (op.msix_entries[i].vector <= 0) { 285 - dev_warn(&dev->dev, "MSI-X entry %d is invalid: %d!\n", 284 + pci_warn(dev, "MSI-X entry %d is invalid: %d!\n", 286 285 i, op.msix_entries[i].vector); 287 286 err = -EINVAL; 288 287 vector[i] = -1; ··· 296 295 err = op.value; 297 296 } 298 297 } else { 299 - dev_err(&dev->dev, "enable msix get err %x\n", err); 298 + pci_err(dev, "enable msix get err %x\n", err); 300 299 } 301 300 return err; 302 301 } ··· 317 316 318 317 /* What should do for error ? */ 319 318 if (err) 320 - dev_err(&dev->dev, "pci_disable_msix get err %x\n", err); 319 + pci_err(dev, "pci_disable_msix get err %x\n", err); 321 320 } 322 321 323 322 static int pci_frontend_enable_msi(struct pci_dev *dev, int vector[]) ··· 336 335 if (likely(!err)) { 337 336 vector[0] = op.value; 338 337 if (op.value <= 0) { 339 - dev_warn(&dev->dev, "MSI entry is invalid: %d!\n", 338 + pci_warn(dev, "MSI entry is invalid: %d!\n", 340 339 op.value); 341 340 err = -EINVAL; 342 341 vector[0] = -1; 343 342 } 344 343 } else { 345 - dev_err(&dev->dev, "pci frontend enable msi failed for dev " 344 + pci_err(dev, "pci frontend enable msi failed for dev " 346 345 "%x:%x\n", op.bus, op.devfn); 347 346 err = -EINVAL; 348 347 } ··· 561 560 while (!list_empty(&bus->devices)) { 562 561 dev = container_of(bus->devices.next, struct pci_dev, 563 562 bus_list); 564 - dev_dbg(&dev->dev, "removing device\n"); 563 + pci_dbg(dev, "removing device\n"); 565 564 pci_stop_and_remove_bus_device(dev); 566 565 } 567 566 } ··· 596 595 struct pci_driver *pdrv; 597 596 int bus = pdev->sh_info->aer_op.bus; 598 597 int devfn = pdev->sh_info->aer_op.devfn; 598 + int domain = pdev->sh_info->aer_op.domain; 599 599 struct pci_dev *pcidev; 600 600 int flag = 0; 601 601 ··· 605 603 cmd, bus, devfn); 606 604 result = PCI_ERS_RESULT_NONE; 607 605 608 - pcidev = pci_get_bus_and_slot(bus, devfn); 606 + pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn); 609 607 if (!pcidev || !pcidev->driver) { 610 608 dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); 611 609 pci_dev_put(pcidev); ··· 615 613 616 614 if (pdrv) { 617 615 if (pdrv->err_handler && pdrv->err_handler->error_detected) { 618 - dev_dbg(&pcidev->dev, 619 - "trying to call AER service\n"); 616 + pci_dbg(pcidev, "trying to call AER service\n"); 620 617 if (pcidev) { 621 618 flag = 1; 622 619 switch (cmd) {
+3 -2
drivers/sbus/char/openprom.c
··· 251 251 struct pci_dev *pdev; 252 252 struct device_node *dp; 253 253 254 - pdev = pci_get_bus_and_slot (((int *) op->oprom_array)[0], 255 - ((int *) op->oprom_array)[1]); 254 + pdev = pci_get_domain_bus_and_slot(0, 255 + ((int *) op->oprom_array)[0], 256 + ((int *) op->oprom_array)[1]); 256 257 257 258 dp = pci_device_to_OF_node(pdev); 258 259 data->current_node = dp;
+26 -8
drivers/video/console/vgacon.c
··· 422 422 vga_video_port_val = VGA_CRT_DM; 423 423 if ((screen_info.orig_video_ega_bx & 0xff) != 0x10) { 424 424 static struct resource ega_console_resource = 425 - { .name = "ega", .start = 0x3B0, .end = 0x3BF }; 425 + { .name = "ega", 426 + .flags = IORESOURCE_IO, 427 + .start = 0x3B0, 428 + .end = 0x3BF }; 426 429 vga_video_type = VIDEO_TYPE_EGAM; 427 430 vga_vram_size = 0x8000; 428 431 display_desc = "EGA+"; ··· 433 430 &ega_console_resource); 434 431 } else { 435 432 static struct resource mda1_console_resource = 436 - { .name = "mda", .start = 0x3B0, .end = 0x3BB }; 433 + { .name = "mda", 434 + .flags = IORESOURCE_IO, 435 + .start = 0x3B0, 436 + .end = 0x3BB }; 437 437 static struct resource mda2_console_resource = 438 - { .name = "mda", .start = 0x3BF, .end = 0x3BF }; 438 + { .name = "mda", 439 + .flags = IORESOURCE_IO, 440 + .start = 0x3BF, 441 + .end = 0x3BF }; 439 442 vga_video_type = VIDEO_TYPE_MDA; 440 443 vga_vram_size = 0x2000; 441 444 display_desc = "*MDA"; ··· 463 454 vga_vram_size = 0x8000; 464 455 465 456 if (!screen_info.orig_video_isVGA) { 466 - static struct resource ega_console_resource 467 - = { .name = "ega", .start = 0x3C0, .end = 0x3DF }; 457 + static struct resource ega_console_resource = 458 + { .name = "ega", 459 + .flags = IORESOURCE_IO, 460 + .start = 0x3C0, 461 + .end = 0x3DF }; 468 462 vga_video_type = VIDEO_TYPE_EGAC; 469 463 display_desc = "EGA"; 470 464 request_resource(&ioport_resource, 471 465 &ega_console_resource); 472 466 } else { 473 - static struct resource vga_console_resource 474 - = { .name = "vga+", .start = 0x3C0, .end = 0x3DF }; 467 + static struct resource vga_console_resource = 468 + { .name = "vga+", 469 + .flags = IORESOURCE_IO, 470 + .start = 0x3C0, 471 + .end = 0x3DF }; 475 472 vga_video_type = VIDEO_TYPE_VGAC; 476 473 display_desc = "VGA+"; 477 474 request_resource(&ioport_resource, ··· 509 494 } 510 495 } else { 511 496 static struct resource cga_console_resource = 512 - { .name = "cga", .start = 0x3D4, .end = 0x3D5 }; 497 + { .name = "cga", 498 + .flags = IORESOURCE_IO, 499 + .start = 0x3D4, 500 + .end = 0x3D5 }; 513 501 vga_video_type = VIDEO_TYPE_CGA; 514 502 vga_vram_size = 0x2000; 515 503 display_desc = "*CGA";
+3 -1
drivers/video/fbdev/intelfb/intelfbhw.c
··· 181 181 return 1; 182 182 183 183 /* Find the bridge device. It is always 0:0.0 */ 184 - if (!(bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)))) { 184 + bridge_dev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 0, 185 + PCI_DEVFN(0, 0)); 186 + if (!bridge_dev) { 185 187 ERR_MSG("cannot find bridge device\n"); 186 188 return 1; 187 189 }
+6 -5
drivers/video/fbdev/nvidia/nv_hw.c
··· 683 683 nv10_sim_state sim_data; 684 684 unsigned int M, N, P, pll, MClk, NVClk, memctrl; 685 685 struct pci_dev *dev; 686 + int domain = pci_domain_nr(par->pci_dev->bus); 686 687 687 688 if ((par->Chipset & 0x0FF0) == 0x01A0) { 688 689 unsigned int uMClkPostDiv; 689 - dev = pci_get_bus_and_slot(0, 3); 690 + dev = pci_get_domain_bus_and_slot(domain, 0, 3); 690 691 pci_read_config_dword(dev, 0x6C, &uMClkPostDiv); 691 692 uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf; 692 693 ··· 695 694 uMClkPostDiv = 4; 696 695 MClk = 400000 / uMClkPostDiv; 697 696 } else { 698 - dev = pci_get_bus_and_slot(0, 5); 697 + dev = pci_get_domain_bus_and_slot(domain, 0, 5); 699 698 pci_read_config_dword(dev, 0x4c, &MClk); 700 699 MClk /= 1000; 701 700 } ··· 708 707 sim_data.pix_bpp = (char)pixelDepth; 709 708 sim_data.enable_video = 0; 710 709 sim_data.enable_mp = 0; 711 - dev = pci_get_bus_and_slot(0, 1); 710 + dev = pci_get_domain_bus_and_slot(domain, 0, 1); 712 711 pci_read_config_dword(dev, 0x7C, &sim_data.memory_type); 713 712 pci_dev_put(dev); 714 713 sim_data.memory_type = (sim_data.memory_type >> 12) & 1; 715 714 sim_data.memory_width = 64; 716 715 717 - dev = pci_get_bus_and_slot(0, 3); 716 + dev = pci_get_domain_bus_and_slot(domain, 0, 3); 718 717 pci_read_config_dword(dev, 0, &memctrl); 719 718 pci_dev_put(dev); 720 719 memctrl >>= 16; ··· 722 721 if ((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) { 723 722 u32 dimm[3]; 724 723 725 - dev = pci_get_bus_and_slot(0, 2); 724 + dev = pci_get_domain_bus_and_slot(domain, 0, 2); 726 725 pci_read_config_dword(dev, 0x40, &dimm[0]); 727 726 dimm[0] = (dimm[0] >> 8) & 0x4f; 728 727 pci_read_config_dword(dev, 0x44, &dimm[1]);
+2 -1
drivers/video/fbdev/nvidia/nv_setup.c
··· 264 264 } 265 265 #endif 266 266 267 - dev = pci_get_bus_and_slot(0, 1); 267 + dev = pci_get_domain_bus_and_slot(pci_domain_nr(par->pci_dev->bus), 268 + 0, 1); 268 269 if ((par->Chipset & 0xffff) == 0x01a0) { 269 270 u32 amt; 270 271
+1 -1
drivers/video/fbdev/riva/fbdev.c
··· 780 780 else 781 781 newmode.misc_output |= 0x80; 782 782 783 - rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width, 783 + rc = CalcStateExt(&par->riva, &newmode.ext, par->pdev, bpp, width, 784 784 hDisplaySize, height, dotClock); 785 785 if (rc) 786 786 goto out;
+4 -3
drivers/video/fbdev/riva/nv_driver.c
··· 159 159 unsigned int chipset = par->Chipset; 160 160 struct pci_dev* dev; 161 161 u32 amt; 162 + int domain = pci_domain_nr(par->pdev->bus); 162 163 163 164 switch (chip->Architecture) { 164 165 case NV_ARCH_03: ··· 227 226 case NV_ARCH_30: 228 227 if(chipset == NV_CHIP_IGEFORCE2) { 229 228 230 - dev = pci_get_bus_and_slot(0, 1); 229 + dev = pci_get_domain_bus_and_slot(domain, 0, 1); 231 230 pci_read_config_dword(dev, 0x7C, &amt); 232 231 pci_dev_put(dev); 233 232 memlen = (((amt >> 6) & 31) + 1) * 1024; 234 233 } else if (chipset == NV_CHIP_0x01F0) { 235 - dev = pci_get_bus_and_slot(0, 1); 234 + dev = pci_get_domain_bus_and_slot(domain, 0, 1); 236 235 pci_read_config_dword(dev, 0x84, &amt); 237 236 pci_dev_put(dev); 238 237 memlen = (((amt >> 4) & 127) + 1) * 1024; ··· 418 417 } 419 418 par->riva.flatPanel = (par->FlatPanel > 0) ? TRUE : FALSE; 420 419 421 - RivaGetConfig(&par->riva, par->Chipset); 420 + RivaGetConfig(&par->riva, par->pdev, par->Chipset); 422 421 } 423 422
+13 -7
drivers/video/fbdev/riva/riva_hw.c
··· 1108 1108 unsigned pixelDepth, 1109 1109 unsigned *burst, 1110 1110 unsigned *lwm, 1111 - RIVA_HW_INST *chip 1111 + RIVA_HW_INST *chip, 1112 + struct pci_dev *pdev 1112 1113 ) 1113 1114 { 1114 1115 nv10_fifo_info fifo_data; ··· 1117 1116 unsigned int M, N, P, pll, MClk, NVClk; 1118 1117 unsigned int uMClkPostDiv; 1119 1118 struct pci_dev *dev; 1119 + int domain = pci_domain_nr(pdev->bus); 1120 1120 1121 - dev = pci_get_bus_and_slot(0, 3); 1121 + dev = pci_get_domain_bus_and_slot(domain, 0, 3); 1122 1122 pci_read_config_dword(dev, 0x6C, &uMClkPostDiv); 1123 1123 pci_dev_put(dev); 1124 1124 uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf; ··· 1134 1132 sim_data.enable_video = 0; 1135 1133 sim_data.enable_mp = 0; 1136 1134 1137 - dev = pci_get_bus_and_slot(0, 1); 1135 + dev = pci_get_domain_bus_and_slot(domain, 0, 1); 1138 1136 pci_read_config_dword(dev, 0x7C, &sim_data.memory_type); 1139 1137 pci_dev_put(dev); 1140 1138 sim_data.memory_type = (sim_data.memory_type >> 12) & 1; ··· 1236 1234 ( 1237 1235 RIVA_HW_INST *chip, 1238 1236 RIVA_HW_STATE *state, 1237 + struct pci_dev *pdev, 1239 1238 int bpp, 1240 1239 int width, 1241 1240 int hDisplaySize, ··· 1303 1300 pixelDepth * 8, 1304 1301 &(state->arbitration0), 1305 1302 &(state->arbitration1), 1306 - chip); 1303 + chip, pdev); 1307 1304 } else { 1308 1305 nv10UpdateArbitrationSettings(VClk, 1309 1306 pixelDepth * 8, ··· 2105 2102 static void nv10GetConfig 2106 2103 ( 2107 2104 RIVA_HW_INST *chip, 2105 + struct pci_dev *pdev, 2108 2106 unsigned int chipset 2109 2107 ) 2110 2108 { 2111 2109 struct pci_dev* dev; 2110 + int domain = pci_domain_nr(pdev->bus); 2112 2111 u32 amt; 2113 2112 2114 2113 #ifdef __BIG_ENDIAN ··· 2123 2118 * Fill in chip configuration. 2124 2119 */ 2125 2120 if(chipset == NV_CHIP_IGEFORCE2) { 2126 - dev = pci_get_bus_and_slot(0, 1); 2121 + dev = pci_get_domain_bus_and_slot(domain, 0, 1); 2127 2122 pci_read_config_dword(dev, 0x7C, &amt); 2128 2123 pci_dev_put(dev); 2129 2124 chip->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024; 2130 2125 } else if(chipset == NV_CHIP_0x01F0) { 2131 - dev = pci_get_bus_and_slot(0, 1); 2126 + dev = pci_get_domain_bus_and_slot(domain, 0, 1); 2132 2127 pci_read_config_dword(dev, 0x84, &amt); 2133 2128 pci_dev_put(dev); 2134 2129 chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024; ··· 2229 2224 int RivaGetConfig 2230 2225 ( 2231 2226 RIVA_HW_INST *chip, 2227 + struct pci_dev *pdev, 2232 2228 unsigned int chipset 2233 2229 ) 2234 2230 { ··· 2251 2245 case NV_ARCH_10: 2252 2246 case NV_ARCH_20: 2253 2247 case NV_ARCH_30: 2254 - nv10GetConfig(chip, chipset); 2248 + nv10GetConfig(chip, pdev, chipset); 2255 2249 break; 2256 2250 default: 2257 2251 return (-1);
+2 -1
drivers/video/fbdev/riva/riva_hw.h
··· 536 536 ( 537 537 RIVA_HW_INST *chip, 538 538 RIVA_HW_STATE *state, 539 + struct pci_dev *pdev, 539 540 int bpp, 540 541 int width, 541 542 int hDisplaySize, ··· 547 546 /* 548 547 * External routines. 549 548 */ 550 - int RivaGetConfig(RIVA_HW_INST *, unsigned int); 549 + int RivaGetConfig(RIVA_HW_INST *chip, struct pci_dev *pdev, unsigned int c); 551 550 /* 552 551 * FIFO Free Count. Should attempt to yield processor if RIVA is busy. 553 552 */
+1 -5
include/asm-generic/pci_iomap.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* Generic I/O port emulation, based on MN10300 code 2 3 * 3 4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 4 5 * Written by David Howells (dhowells@redhat.com) 5 - * 6 - * This program is free software; you can redistribute it and/or 7 - * modify it under the terms of the GNU General Public Licence 8 - * as published by the Free Software Foundation; either version 9 - * 2 of the Licence, or (at your option) any later version. 10 6 */ 11 7 #ifndef __ASM_GENERIC_PCI_IOMAP_H 12 8 #define __ASM_GENERIC_PCI_IOMAP_H
+1 -7
include/linux/of_pci.h
··· 9 9 struct of_phandle_args; 10 10 struct device_node; 11 11 12 - #ifdef CONFIG_OF_PCI 13 - int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); 12 + #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PCI) 14 13 struct device_node *of_pci_find_child_device(struct device_node *parent, 15 14 unsigned int devfn); 16 15 int of_pci_get_devfn(struct device_node *np); ··· 22 23 const char *map_name, const char *map_mask_name, 23 24 struct device_node **target, u32 *id_out); 24 25 #else 25 - static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) 26 - { 27 - return 0; 28 - } 29 - 30 26 static inline struct device_node *of_pci_find_child_device(struct device_node *parent, 31 27 unsigned int devfn) 32 28 {
+2 -33
include/linux/pci-aspm.h
··· 24 24 #define PCIE_LINK_STATE_CLKPM 4 25 25 26 26 #ifdef CONFIG_PCIEASPM 27 - void pcie_aspm_init_link_state(struct pci_dev *pdev); 28 - void pcie_aspm_exit_link_state(struct pci_dev *pdev); 29 - void pcie_aspm_pm_state_change(struct pci_dev *pdev); 30 - void pcie_aspm_powersave_config_link(struct pci_dev *pdev); 31 27 void pci_disable_link_state(struct pci_dev *pdev, int state); 32 28 void pci_disable_link_state_locked(struct pci_dev *pdev, int state); 33 29 void pcie_no_aspm(void); 34 30 #else 35 - static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) 36 - { 37 - } 38 - static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) 39 - { 40 - } 41 - static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) 42 - { 43 - } 44 - static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) 45 - { 46 - } 47 - static inline void pci_disable_link_state(struct pci_dev *pdev, int state) 48 - { 49 - } 50 - static inline void pcie_no_aspm(void) 51 - { 52 - } 31 + static inline void pci_disable_link_state(struct pci_dev *pdev, int state) { } 32 + static inline void pcie_no_aspm(void) { } 53 33 #endif 54 34 55 - #ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */ 56 - void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev); 57 - void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev); 58 - #else 59 - static inline void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) 60 - { 61 - } 62 - static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) 63 - { 64 - } 65 - #endif 66 35 #endif /* LINUX_ASPM_H */
+13 -14
include/linux/pci-dma-compat.h
··· 17 17 pci_alloc_consistent(struct pci_dev *hwdev, size_t size, 18 18 dma_addr_t *dma_handle) 19 19 { 20 - return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC); 20 + return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC); 21 21 } 22 22 23 23 static inline void * 24 24 pci_zalloc_consistent(struct pci_dev *hwdev, size_t size, 25 25 dma_addr_t *dma_handle) 26 26 { 27 - return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, 28 - size, dma_handle, GFP_ATOMIC); 27 + return dma_zalloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC); 29 28 } 30 29 31 30 static inline void 32 31 pci_free_consistent(struct pci_dev *hwdev, size_t size, 33 32 void *vaddr, dma_addr_t dma_handle) 34 33 { 35 - dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle); 34 + dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle); 36 35 } 37 36 38 37 static inline dma_addr_t 39 38 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) 40 39 { 41 - return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction); 40 + return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction); 42 41 } 43 42 44 43 static inline void 45 44 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, 46 45 size_t size, int direction) 47 46 { 48 - dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); 47 + dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); 49 48 } 50 49 51 50 static inline dma_addr_t 52 51 pci_map_page(struct pci_dev *hwdev, struct page *page, 53 52 unsigned long offset, size_t size, int direction) 54 53 { 55 - return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction); 54 + return dma_map_page(&hwdev->dev, page, offset, size, (enum dma_data_direction)direction); 56 55 } 57 56 58 57 static inline void 59 58 pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, 60 59 size_t size, int direction) 61 60 { 62 - dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction); 61 + dma_unmap_page(&hwdev->dev, dma_address, size, (enum dma_data_direction)direction); 63 62 } 64 63 65 64 static inline int 66 65 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, 67 66 int nents, int direction) 68 67 { 69 - return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); 68 + return dma_map_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction); 70 69 } 71 70 72 71 static inline void 73 72 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, 74 73 int nents, int direction) 75 74 { 76 - dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); 75 + dma_unmap_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction); 77 76 } 78 77 79 78 static inline void 80 79 pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, 81 80 size_t size, int direction) 82 81 { 83 - dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 82 + dma_sync_single_for_cpu(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 84 83 } 85 84 86 85 static inline void 87 86 pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, 88 87 size_t size, int direction) 89 88 { 90 - dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 89 + dma_sync_single_for_device(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 91 90 } 92 91 93 92 static inline void 94 93 pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, 95 94 int nelems, int direction) 96 95 { 97 - dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 96 + dma_sync_sg_for_cpu(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 98 97 } 99 98 100 99 static inline void 101 100 pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, 102 101 int nelems, int direction) 103 102 { 104 - dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 103 + dma_sync_sg_for_device(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 105 104 } 106 105 107 106 static inline int
+1 -12
include/linux/pci-ecam.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 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 #ifndef DRIVERS_PCI_ECAM_H 17 6 #define DRIVERS_PCI_ECAM_H
+1 -4
include/linux/pci-ep-cfs.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /** 2 3 * PCI Endpoint ConfigFS header file 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 7 */ 11 8 12 9 #ifndef __LINUX_PCI_EP_CFS_H
+26 -22
include/linux/pci-epc.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /** 2 3 * PCI Endpoint *Controller* (EPC) header file 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 7 */ 11 8 12 9 #ifndef __LINUX_PCI_EPC_H ··· 36 39 * @owner: the module owner containing the ops 37 40 */ 38 41 struct pci_epc_ops { 39 - int (*write_header)(struct pci_epc *pci_epc, 42 + int (*write_header)(struct pci_epc *epc, u8 func_no, 40 43 struct pci_epf_header *hdr); 41 - int (*set_bar)(struct pci_epc *epc, enum pci_barno bar, 44 + int (*set_bar)(struct pci_epc *epc, u8 func_no, 45 + enum pci_barno bar, 42 46 dma_addr_t bar_phys, size_t size, int flags); 43 - void (*clear_bar)(struct pci_epc *epc, enum pci_barno bar); 44 - int (*map_addr)(struct pci_epc *epc, phys_addr_t addr, 45 - u64 pci_addr, size_t size); 46 - void (*unmap_addr)(struct pci_epc *epc, phys_addr_t addr); 47 - int (*set_msi)(struct pci_epc *epc, u8 interrupts); 48 - int (*get_msi)(struct pci_epc *epc); 49 - int (*raise_irq)(struct pci_epc *pci_epc, 47 + void (*clear_bar)(struct pci_epc *epc, u8 func_no, 48 + enum pci_barno bar); 49 + int (*map_addr)(struct pci_epc *epc, u8 func_no, 50 + phys_addr_t addr, u64 pci_addr, size_t size); 51 + void (*unmap_addr)(struct pci_epc *epc, u8 func_no, 52 + phys_addr_t addr); 53 + int (*set_msi)(struct pci_epc *epc, u8 func_no, u8 interrupts); 54 + int (*get_msi)(struct pci_epc *epc, u8 func_no); 55 + int (*raise_irq)(struct pci_epc *epc, u8 func_no, 50 56 enum pci_epc_irq_type type, u8 interrupt_num); 51 57 int (*start)(struct pci_epc *epc); 52 58 void (*stop)(struct pci_epc *epc); ··· 124 124 int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf); 125 125 void pci_epc_linkup(struct pci_epc *epc); 126 126 void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf); 127 - int pci_epc_write_header(struct pci_epc *epc, struct pci_epf_header *hdr); 128 - int pci_epc_set_bar(struct pci_epc *epc, enum pci_barno bar, 127 + int pci_epc_write_header(struct pci_epc *epc, u8 func_no, 128 + struct pci_epf_header *hdr); 129 + int pci_epc_set_bar(struct pci_epc *epc, u8 func_no, 130 + enum pci_barno bar, 129 131 dma_addr_t bar_phys, size_t size, int flags); 130 - void pci_epc_clear_bar(struct pci_epc *epc, int bar); 131 - int pci_epc_map_addr(struct pci_epc *epc, phys_addr_t phys_addr, 132 + void pci_epc_clear_bar(struct pci_epc *epc, u8 func_no, int bar); 133 + int pci_epc_map_addr(struct pci_epc *epc, u8 func_no, 134 + phys_addr_t phys_addr, 132 135 u64 pci_addr, size_t size); 133 - void pci_epc_unmap_addr(struct pci_epc *epc, phys_addr_t phys_addr); 134 - int pci_epc_set_msi(struct pci_epc *epc, u8 interrupts); 135 - int pci_epc_get_msi(struct pci_epc *epc); 136 - int pci_epc_raise_irq(struct pci_epc *epc, enum pci_epc_irq_type type, 137 - u8 interrupt_num); 136 + void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, 137 + phys_addr_t phys_addr); 138 + int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts); 139 + int pci_epc_get_msi(struct pci_epc *epc, u8 func_no); 140 + int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, 141 + enum pci_epc_irq_type type, u8 interrupt_num); 138 142 int pci_epc_start(struct pci_epc *epc); 139 143 void pci_epc_stop(struct pci_epc *epc); 140 144 struct pci_epc *pci_epc_get(const char *epc_name);
+1 -4
include/linux/pci-epf.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /** 2 3 * PCI Endpoint *Function* (EPF) header file 3 4 * 4 5 * Copyright (C) 2017 Texas Instruments 5 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 7 */ 11 8 12 9 #ifndef __LINUX_PCI_EPF_H
+226 -215
include/linux/pci.h
··· 48 48 * In the interest of not exposing interfaces to user-space unnecessarily, 49 49 * the following kernel-only defines are being added here. 50 50 */ 51 - #define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn)) 51 + #define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn)) 52 52 /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */ 53 53 #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff) 54 54 55 55 /* pci_slot represents a physical slot */ 56 56 struct pci_slot { 57 - struct pci_bus *bus; /* The bus this slot is on */ 58 - struct list_head list; /* node in list of slots on this bus */ 59 - struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ 60 - unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ 61 - struct kobject kobj; 57 + struct pci_bus *bus; /* Bus this slot is on */ 58 + struct list_head list; /* Node in list of slots */ 59 + struct hotplug_slot *hotplug; /* Hotplug info (move here) */ 60 + unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ 61 + struct kobject kobj; 62 62 }; 63 63 64 64 static inline const char *pci_slot_name(const struct pci_slot *slot) ··· 72 72 pci_mmap_mem 73 73 }; 74 74 75 - /* 76 - * For PCI devices, the region numbers are assigned this way: 77 - */ 75 + /* For PCI devices, the region numbers are assigned this way: */ 78 76 enum { 79 77 /* #0-5: standard PCI resources */ 80 78 PCI_STD_RESOURCES, ··· 81 83 /* #6: expansion ROM resource */ 82 84 PCI_ROM_RESOURCE, 83 85 84 - /* device specific resources */ 86 + /* Device-specific resources */ 85 87 #ifdef CONFIG_PCI_IOV 86 88 PCI_IOV_RESOURCES, 87 89 PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1, 88 90 #endif 89 91 90 - /* resources assigned to buses behind the bridge */ 92 + /* Resources assigned to buses behind the bridge */ 91 93 #define PCI_BRIDGE_RESOURCE_NUM 4 92 94 93 95 PCI_BRIDGE_RESOURCES, 94 96 PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES + 95 97 PCI_BRIDGE_RESOURCE_NUM - 1, 96 98 97 - /* total resources associated with a PCI device */ 99 + /* Total resources associated with a PCI device */ 98 100 PCI_NUM_RESOURCES, 99 101 100 - /* preserve this for compatibility */ 102 + /* Preserve this for compatibility */ 101 103 DEVICE_COUNT_RESOURCE = PCI_NUM_RESOURCES, 102 104 }; 103 105 ··· 150 152 #define PCI_PM_D3COLD_WAIT 100 151 153 #define PCI_PM_BUS_WAIT 50 152 154 153 - /** The pci_channel state describes connectivity between the CPU and 154 - * the pci device. If some PCI bus between here and the pci device 155 - * has crashed or locked up, this info is reflected here. 155 + /** 156 + * The pci_channel state describes connectivity between the CPU and 157 + * the PCI device. If some PCI bus between here and the PCI device 158 + * has crashed or locked up, this info is reflected here. 156 159 */ 157 160 typedef unsigned int __bitwise pci_channel_state_t; 158 161 ··· 183 184 184 185 typedef unsigned short __bitwise pci_dev_flags_t; 185 186 enum pci_dev_flags { 186 - /* INTX_DISABLE in PCI_COMMAND register disables MSI 187 - * generation too. 188 - */ 187 + /* INTX_DISABLE in PCI_COMMAND register disables MSI too */ 189 188 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) (1 << 0), 190 189 /* Device configuration is irrevocably lost if disabled into D3 */ 191 190 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) (1 << 1), ··· 199 202 PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7), 200 203 /* Get VPD from function 0 VPD */ 201 204 PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8), 202 - /* a non-root bridge where translation occurs, stop alias search here */ 205 + /* A non-root bridge where translation occurs, stop alias search here */ 203 206 PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9), 204 207 /* Do not use FLR even if device advertises PCI_AF_CAP */ 205 208 PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10), ··· 219 222 PCI_BUS_FLAGS_NO_AERSID = (__force pci_bus_flags_t) 4, 220 223 }; 221 224 222 - /* These values come from the PCI Express Spec */ 225 + /* Values from Link Status register, PCIe r3.1, sec 7.8.8 */ 223 226 enum pcie_link_width { 224 227 PCIE_LNK_WIDTH_RESRV = 0x00, 225 228 PCIE_LNK_X1 = 0x01, 226 229 PCIE_LNK_X2 = 0x02, 227 230 PCIE_LNK_X4 = 0x04, 228 231 PCIE_LNK_X8 = 0x08, 229 - PCIE_LNK_X12 = 0x0C, 232 + PCIE_LNK_X12 = 0x0c, 230 233 PCIE_LNK_X16 = 0x10, 231 234 PCIE_LNK_X32 = 0x20, 232 - PCIE_LNK_WIDTH_UNKNOWN = 0xFF, 235 + PCIE_LNK_WIDTH_UNKNOWN = 0xff, 233 236 }; 234 237 235 238 /* Based on the PCI Hotplug Spec, but some values are made up by us */ ··· 260 263 }; 261 264 262 265 struct pci_cap_saved_data { 263 - u16 cap_nr; 264 - bool cap_extended; 265 - unsigned int size; 266 - u32 data[0]; 266 + u16 cap_nr; 267 + bool cap_extended; 268 + unsigned int size; 269 + u32 data[0]; 267 270 }; 268 271 269 272 struct pci_cap_saved_state { 270 - struct hlist_node next; 271 - struct pci_cap_saved_data cap; 273 + struct hlist_node next; 274 + struct pci_cap_saved_data cap; 272 275 }; 273 276 274 277 struct irq_affinity; ··· 277 280 struct pci_sriov; 278 281 struct pci_ats; 279 282 280 - /* 281 - * The pci_dev structure is used to describe PCI devices. 282 - */ 283 + /* The pci_dev structure describes PCI devices */ 283 284 struct pci_dev { 284 - struct list_head bus_list; /* node in per-bus list */ 285 - struct pci_bus *bus; /* bus this device is on */ 286 - struct pci_bus *subordinate; /* bus this device bridges to */ 285 + struct list_head bus_list; /* Node in per-bus list */ 286 + struct pci_bus *bus; /* Bus this device is on */ 287 + struct pci_bus *subordinate; /* Bus this device bridges to */ 287 288 288 - void *sysdata; /* hook for sys-specific extension */ 289 - struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ 289 + void *sysdata; /* Hook for sys-specific extension */ 290 + struct proc_dir_entry *procent; /* Device entry in /proc/bus/pci */ 290 291 struct pci_slot *slot; /* Physical slot this device is in */ 291 292 292 - unsigned int devfn; /* encoded device & function index */ 293 + unsigned int devfn; /* Encoded device & function index */ 293 294 unsigned short vendor; 294 295 unsigned short device; 295 296 unsigned short subsystem_vendor; ··· 302 307 u8 msi_cap; /* MSI capability offset */ 303 308 u8 msix_cap; /* MSI-X capability offset */ 304 309 u8 pcie_mpss:3; /* PCIe Max Payload Size Supported */ 305 - u8 rom_base_reg; /* which config register controls the ROM */ 306 - u8 pin; /* which interrupt pin this device uses */ 307 - u16 pcie_flags_reg; /* cached PCIe Capabilities Register */ 308 - unsigned long *dma_alias_mask;/* mask of enabled devfn aliases */ 310 + u8 rom_base_reg; /* Config register controlling ROM */ 311 + u8 pin; /* Interrupt pin this device uses */ 312 + u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */ 313 + unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */ 309 314 310 - struct pci_driver *driver; /* which driver has allocated this device */ 315 + struct pci_driver *driver; /* Driver bound to this device */ 311 316 u64 dma_mask; /* Mask of the bits of bus address this 312 317 device implements. Normally this is 313 318 0xffffffff. You only need to change ··· 316 321 317 322 struct device_dma_parameters dma_parms; 318 323 319 - pci_power_t current_state; /* Current operating state. In ACPI-speak, 320 - this is D0-D3, D0 being fully functional, 321 - and D3 being off. */ 324 + pci_power_t current_state; /* Current operating state. In ACPI, 325 + this is D0-D3, D0 being fully 326 + functional, and D3 being off. */ 322 327 u8 pm_cap; /* PM capability offset */ 323 328 unsigned int pme_support:5; /* Bitmask of states from which PME# 324 329 can be generated */ ··· 329 334 unsigned int no_d3cold:1; /* D3cold is forbidden */ 330 335 unsigned int bridge_d3:1; /* Allow D3 for bridge */ 331 336 unsigned int d3cold_allowed:1; /* D3cold is allowed by user */ 332 - unsigned int mmio_always_on:1; /* disallow turning off io/mem 333 - decoding during bar sizing */ 337 + unsigned int mmio_always_on:1; /* Disallow turning off io/mem 338 + decoding during BAR sizing */ 334 339 unsigned int wakeup_prepared:1; 335 - unsigned int runtime_d3cold:1; /* whether go through runtime 340 + unsigned int runtime_d3cold:1; /* Whether go through runtime 336 341 D3cold, not set for devices 337 342 powered on/off by the 338 343 corresponding bridge */ ··· 345 350 346 351 #ifdef CONFIG_PCIEASPM 347 352 struct pcie_link_state *link_state; /* ASPM link state */ 353 + unsigned int ltr_path:1; /* Latency Tolerance Reporting 354 + supported from root to here */ 348 355 #endif 349 356 350 - pci_channel_state_t error_state; /* current connectivity state */ 351 - struct device dev; /* Generic device interface */ 357 + pci_channel_state_t error_state; /* Current connectivity state */ 358 + struct device dev; /* Generic device interface */ 352 359 353 - int cfg_size; /* Size of configuration space */ 360 + int cfg_size; /* Size of config space */ 354 361 355 362 /* 356 363 * Instead of touching interrupt line and base address registers ··· 361 364 unsigned int irq; 362 365 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 363 366 364 - bool match_driver; /* Skip attaching driver */ 365 - /* These fields are used by common fixups */ 366 - unsigned int transparent:1; /* Subtractive decode PCI bridge */ 367 - unsigned int multifunction:1;/* Part of multi-function device */ 368 - /* keep track of device state */ 367 + bool match_driver; /* Skip attaching driver */ 368 + 369 + unsigned int transparent:1; /* Subtractive decode bridge */ 370 + unsigned int multifunction:1; /* Multi-function device */ 371 + 369 372 unsigned int is_added:1; 370 - unsigned int is_busmaster:1; /* device is busmaster */ 371 - unsigned int no_msi:1; /* device may not use msi */ 372 - unsigned int no_64bit_msi:1; /* device may only use 32-bit MSIs */ 373 - unsigned int block_cfg_access:1; /* config space access is blocked */ 374 - unsigned int broken_parity_status:1; /* Device generates false positive parity */ 375 - unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */ 373 + unsigned int is_busmaster:1; /* Is busmaster */ 374 + unsigned int no_msi:1; /* May not use MSI */ 375 + unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */ 376 + unsigned int block_cfg_access:1; /* Config space access blocked */ 377 + unsigned int broken_parity_status:1; /* Generates false positive parity */ 378 + unsigned int irq_reroute_variant:2; /* Needs IRQ rerouting variant */ 376 379 unsigned int msi_enabled:1; 377 380 unsigned int msix_enabled:1; 378 - unsigned int ari_enabled:1; /* ARI forwarding */ 379 - unsigned int ats_enabled:1; /* Address Translation Service */ 381 + unsigned int ari_enabled:1; /* ARI forwarding */ 382 + unsigned int ats_enabled:1; /* Address Translation Svc */ 380 383 unsigned int pasid_enabled:1; /* Process Address Space ID */ 381 384 unsigned int pri_enabled:1; /* Page Request Interface */ 382 385 unsigned int is_managed:1; 383 - unsigned int needs_freset:1; /* Dev requires fundamental reset */ 386 + unsigned int needs_freset:1; /* Requires fundamental reset */ 384 387 unsigned int state_saved:1; 385 388 unsigned int is_physfn:1; 386 389 unsigned int is_virtfn:1; 387 390 unsigned int reset_fn:1; 388 - unsigned int is_hotplug_bridge:1; 389 - unsigned int is_thunderbolt:1; /* Thunderbolt controller */ 390 - unsigned int __aer_firmware_first_valid:1; 391 + unsigned int is_hotplug_bridge:1; 392 + unsigned int is_thunderbolt:1; /* Thunderbolt controller */ 393 + unsigned int __aer_firmware_first_valid:1; 391 394 unsigned int __aer_firmware_first:1; 392 - unsigned int broken_intx_masking:1; /* INTx masking can't be used */ 393 - unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */ 395 + unsigned int broken_intx_masking:1; /* INTx masking can't be used */ 396 + unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */ 394 397 unsigned int irq_managed:1; 395 398 unsigned int has_secondary_link:1; 396 - unsigned int non_compliant_bars:1; /* broken BARs; ignore them */ 397 - unsigned int is_probed:1; /* device probing in progress */ 399 + unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */ 400 + unsigned int is_probed:1; /* Device probing in progress */ 398 401 pci_dev_flags_t dev_flags; 399 402 atomic_t enable_cnt; /* pci_enable_device has been called */ 400 403 401 - u32 saved_config_space[16]; /* config space saved at suspend time */ 404 + u32 saved_config_space[16]; /* Config space saved at suspend time */ 402 405 struct hlist_head saved_cap_space; 403 - struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ 404 - int rom_attr_enabled; /* has display of the rom attribute been enabled? */ 406 + struct bin_attribute *rom_attr; /* Attribute descriptor for sysfs ROM entry */ 407 + int rom_attr_enabled; /* Display of ROM attribute enabled? */ 405 408 struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ 406 409 struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */ 407 410 ··· 416 419 struct pci_vpd *vpd; 417 420 #ifdef CONFIG_PCI_ATS 418 421 union { 419 - struct pci_sriov *sriov; /* SR-IOV capability related */ 420 - struct pci_dev *physfn; /* the PF this VF is associated with */ 422 + struct pci_sriov *sriov; /* PF: SR-IOV info */ 423 + struct pci_dev *physfn; /* VF: related PF */ 421 424 }; 422 425 u16 ats_cap; /* ATS Capability offset */ 423 426 u8 ats_stu; /* ATS Smallest Translation Unit */ 424 - atomic_t ats_ref_cnt; /* number of VFs with ATS enabled */ 427 + atomic_t ats_ref_cnt; /* Number of VFs with ATS enabled */ 425 428 #endif 426 429 #ifdef CONFIG_PCI_PRI 427 430 u32 pri_reqs_alloc; /* Number of PRI requests allocated */ ··· 429 432 #ifdef CONFIG_PCI_PASID 430 433 u16 pasid_features; 431 434 #endif 432 - phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */ 433 - size_t romlen; /* Length of ROM if it's not from the BAR */ 434 - char *driver_override; /* Driver name to force a match */ 435 + phys_addr_t rom; /* Physical address if not from BAR */ 436 + size_t romlen; /* Length if not from BAR */ 437 + char *driver_override; /* Driver name to force a match */ 435 438 436 - unsigned long priv_flags; /* Private flags for the pci driver */ 439 + unsigned long priv_flags; /* Private flags for the PCI driver */ 437 440 }; 438 441 439 442 static inline struct pci_dev *pci_physfn(struct pci_dev *dev) ··· 456 459 } 457 460 458 461 struct pci_host_bridge { 459 - struct device dev; 460 - struct pci_bus *bus; /* root bus */ 461 - struct pci_ops *ops; 462 - void *sysdata; 463 - int busnr; 462 + struct device dev; 463 + struct pci_bus *bus; /* Root bus */ 464 + struct pci_ops *ops; 465 + void *sysdata; 466 + int busnr; 464 467 struct list_head windows; /* resource_entry */ 465 - u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* platform IRQ swizzler */ 468 + u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */ 466 469 int (*map_irq)(const struct pci_dev *, u8, u8); 467 470 void (*release_fn)(struct pci_host_bridge *); 468 - void *release_data; 471 + void *release_data; 469 472 struct msi_controller *msi; 470 - unsigned int ignore_reset_delay:1; /* for entire hierarchy */ 471 - unsigned int no_ext_tags:1; /* no Extended Tags */ 473 + unsigned int ignore_reset_delay:1; /* For entire hierarchy */ 474 + unsigned int no_ext_tags:1; /* No Extended Tags */ 472 475 /* Resource alignment requirements */ 473 476 resource_size_t (*align_resource)(struct pci_dev *dev, 474 477 const struct resource *res, 475 478 resource_size_t start, 476 479 resource_size_t size, 477 480 resource_size_t align); 478 - unsigned long private[0] ____cacheline_aligned; 481 + unsigned long private[0] ____cacheline_aligned; 479 482 }; 480 483 481 484 #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev) ··· 497 500 struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus); 498 501 499 502 void pci_set_host_bridge_release(struct pci_host_bridge *bridge, 500 - void (*release_fn)(struct pci_host_bridge *), 501 - void *release_data); 503 + void (*release_fn)(struct pci_host_bridge *), 504 + void *release_data); 502 505 503 506 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge); 504 507 ··· 518 521 #define PCI_SUBTRACTIVE_DECODE 0x1 519 522 520 523 struct pci_bus_resource { 521 - struct list_head list; 522 - struct resource *res; 523 - unsigned int flags; 524 + struct list_head list; 525 + struct resource *res; 526 + unsigned int flags; 524 527 }; 525 528 526 529 #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ 527 530 528 531 struct pci_bus { 529 - struct list_head node; /* node in list of buses */ 530 - struct pci_bus *parent; /* parent bus this bridge is on */ 531 - struct list_head children; /* list of child buses */ 532 - struct list_head devices; /* list of devices on this bus */ 533 - struct pci_dev *self; /* bridge device as seen by parent */ 534 - struct list_head slots; /* list of slots on this bus; 532 + struct list_head node; /* Node in list of buses */ 533 + struct pci_bus *parent; /* Parent bus this bridge is on */ 534 + struct list_head children; /* List of child buses */ 535 + struct list_head devices; /* List of devices on this bus */ 536 + struct pci_dev *self; /* Bridge device as seen by parent */ 537 + struct list_head slots; /* List of slots on this bus; 535 538 protected by pci_slot_mutex */ 536 539 struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; 537 - struct list_head resources; /* address space routed to this bus */ 538 - struct resource busn_res; /* bus numbers routed to this bus */ 540 + struct list_head resources; /* Address space routed to this bus */ 541 + struct resource busn_res; /* Bus numbers routed to this bus */ 539 542 540 - struct pci_ops *ops; /* configuration access functions */ 543 + struct pci_ops *ops; /* Configuration access functions */ 541 544 struct msi_controller *msi; /* MSI controller */ 542 - void *sysdata; /* hook for sys-specific extension */ 543 - struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ 545 + void *sysdata; /* Hook for sys-specific extension */ 546 + struct proc_dir_entry *procdir; /* Directory entry in /proc/bus/pci */ 544 547 545 - unsigned char number; /* bus number */ 546 - unsigned char primary; /* number of primary bridge */ 548 + unsigned char number; /* Bus number */ 549 + unsigned char primary; /* Number of primary bridge */ 547 550 unsigned char max_bus_speed; /* enum pci_bus_speed */ 548 551 unsigned char cur_bus_speed; /* enum pci_bus_speed */ 549 552 #ifdef CONFIG_PCI_DOMAINS_GENERIC ··· 552 555 553 556 char name[48]; 554 557 555 - unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ 556 - pci_bus_flags_t bus_flags; /* inherited by child buses */ 558 + unsigned short bridge_ctl; /* Manage NO_ISA/FBB/et al behaviors */ 559 + pci_bus_flags_t bus_flags; /* Inherited by child buses */ 557 560 struct device *bridge; 558 561 struct device dev; 559 - struct bin_attribute *legacy_io; /* legacy I/O for this bus */ 560 - struct bin_attribute *legacy_mem; /* legacy mem */ 562 + struct bin_attribute *legacy_io; /* Legacy I/O for this bus */ 563 + struct bin_attribute *legacy_mem; /* Legacy mem */ 561 564 unsigned int is_added:1; 562 565 }; 563 566 ··· 614 617 static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; } 615 618 #endif 616 619 617 - /* 618 - * Error values that may be returned by PCI functions. 619 - */ 620 + /* Error values that may be returned by PCI functions */ 620 621 #define PCIBIOS_SUCCESSFUL 0x00 621 622 #define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 622 623 #define PCIBIOS_BAD_VENDOR_ID 0x83 ··· 623 628 #define PCIBIOS_SET_FAILED 0x88 624 629 #define PCIBIOS_BUFFER_TOO_SMALL 0x89 625 630 626 - /* 627 - * Translate above to generic errno for passing back through non-PCI code. 628 - */ 631 + /* Translate above to generic errno for passing back through non-PCI code */ 629 632 static inline int pcibios_err_to_errno(int err) 630 633 { 631 634 if (err <= PCIBIOS_SUCCESSFUL) ··· 673 680 #endif 674 681 675 682 struct pci_bus_region { 676 - pci_bus_addr_t start; 677 - pci_bus_addr_t end; 683 + pci_bus_addr_t start; 684 + pci_bus_addr_t end; 678 685 }; 679 686 680 687 struct pci_dynids { 681 - spinlock_t lock; /* protects list, index */ 682 - struct list_head list; /* for IDs added at runtime */ 688 + spinlock_t lock; /* Protects list, index */ 689 + struct list_head list; /* For IDs added at runtime */ 683 690 }; 684 691 685 692 ··· 693 700 typedef unsigned int __bitwise pci_ers_result_t; 694 701 695 702 enum pci_ers_result { 696 - /* no result/none/not supported in device driver */ 703 + /* No result/none/not supported in device driver */ 697 704 PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1, 698 705 699 706 /* Device driver can recover without slot reset */ 700 707 PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2, 701 708 702 - /* Device driver wants slot to be reset. */ 709 + /* Device driver wants slot to be reset */ 703 710 PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3, 704 711 705 712 /* Device has completely failed, is unrecoverable */ ··· 735 742 736 743 struct module; 737 744 struct pci_driver { 738 - struct list_head node; 739 - const char *name; 740 - const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ 741 - int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 742 - void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 743 - int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ 744 - int (*suspend_late) (struct pci_dev *dev, pm_message_t state); 745 - int (*resume_early) (struct pci_dev *dev); 746 - int (*resume) (struct pci_dev *dev); /* Device woken up */ 745 + struct list_head node; 746 + const char *name; 747 + const struct pci_device_id *id_table; /* Must be non-NULL for probe to be called */ 748 + int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 749 + void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 750 + int (*suspend)(struct pci_dev *dev, pm_message_t state); /* Device suspended */ 751 + int (*suspend_late)(struct pci_dev *dev, pm_message_t state); 752 + int (*resume_early)(struct pci_dev *dev); 753 + int (*resume) (struct pci_dev *dev); /* Device woken up */ 747 754 void (*shutdown) (struct pci_dev *dev); 748 - int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* PF pdev */ 755 + int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* On PF */ 749 756 const struct pci_error_handlers *err_handler; 750 757 const struct attribute_group **groups; 751 758 struct device_driver driver; 752 - struct pci_dynids dynids; 759 + struct pci_dynids dynids; 753 760 }; 754 761 755 762 #define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) 756 763 757 764 /** 758 - * PCI_DEVICE - macro used to describe a specific pci device 765 + * PCI_DEVICE - macro used to describe a specific PCI device 759 766 * @vend: the 16 bit PCI Vendor ID 760 767 * @dev: the 16 bit PCI Device ID 761 768 * ··· 768 775 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID 769 776 770 777 /** 771 - * PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem 778 + * PCI_DEVICE_SUB - macro used to describe a specific PCI device with subsystem 772 779 * @vend: the 16 bit PCI Vendor ID 773 780 * @dev: the 16 bit PCI Device ID 774 781 * @subvend: the 16 bit PCI Subvendor ID ··· 782 789 .subvendor = (subvend), .subdevice = (subdev) 783 790 784 791 /** 785 - * PCI_DEVICE_CLASS - macro used to describe a specific pci device class 792 + * PCI_DEVICE_CLASS - macro used to describe a specific PCI device class 786 793 * @dev_class: the class, subclass, prog-if triple for this device 787 794 * @dev_class_mask: the class mask for this device 788 795 * ··· 796 803 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID 797 804 798 805 /** 799 - * PCI_VDEVICE - macro used to describe a specific pci device in short form 806 + * PCI_VDEVICE - macro used to describe a specific PCI device in short form 800 807 * @vend: the vendor name 801 808 * @dev: the 16 bit PCI Device ID 802 809 * ··· 805 812 * to PCI_ANY_ID. The macro allows the next field to follow as the device 806 813 * private data. 807 814 */ 808 - 809 815 #define PCI_VDEVICE(vend, dev) \ 810 816 .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \ 811 817 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 812 818 813 819 enum { 814 - PCI_REASSIGN_ALL_RSRC = 0x00000001, /* ignore firmware setup */ 815 - PCI_REASSIGN_ALL_BUS = 0x00000002, /* reassign all bus numbers */ 816 - PCI_PROBE_ONLY = 0x00000004, /* use existing setup */ 817 - PCI_CAN_SKIP_ISA_ALIGN = 0x00000008, /* don't do ISA alignment */ 818 - PCI_ENABLE_PROC_DOMAINS = 0x00000010, /* enable domains in /proc */ 820 + PCI_REASSIGN_ALL_RSRC = 0x00000001, /* Ignore firmware setup */ 821 + PCI_REASSIGN_ALL_BUS = 0x00000002, /* Reassign all bus numbers */ 822 + PCI_PROBE_ONLY = 0x00000004, /* Use existing setup */ 823 + PCI_CAN_SKIP_ISA_ALIGN = 0x00000008, /* Don't do ISA alignment */ 824 + PCI_ENABLE_PROC_DOMAINS = 0x00000010, /* Enable domains in /proc */ 819 825 PCI_COMPAT_DOMAIN_0 = 0x00000020, /* ... except domain 0 */ 820 - PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* scan all, not just dev 0 */ 826 + PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* Scan all, not just dev 0 */ 821 827 }; 822 828 823 - /* these external functions are only available when PCI support is enabled */ 829 + /* These external functions are only available when PCI support is enabled */ 824 830 #ifdef CONFIG_PCI 825 831 826 832 extern unsigned int pci_flags; ··· 832 840 void pcie_bus_configure_settings(struct pci_bus *bus); 833 841 834 842 enum pcie_bus_config_types { 835 - PCIE_BUS_TUNE_OFF, /* don't touch MPS at all */ 836 - PCIE_BUS_DEFAULT, /* ensure MPS matches upstream bridge */ 837 - PCIE_BUS_SAFE, /* use largest MPS boot-time devices support */ 838 - PCIE_BUS_PERFORMANCE, /* use MPS and MRRS for best performance */ 839 - PCIE_BUS_PEER2PEER, /* set MPS = 128 for all devices */ 843 + PCIE_BUS_TUNE_OFF, /* Don't touch MPS at all */ 844 + PCIE_BUS_DEFAULT, /* Ensure MPS matches upstream bridge */ 845 + PCIE_BUS_SAFE, /* Use largest MPS boot-time devices support */ 846 + PCIE_BUS_PERFORMANCE, /* Use MPS and MRRS for best performance */ 847 + PCIE_BUS_PEER2PEER, /* Set MPS = 128 for all devices */ 840 848 }; 841 849 842 850 extern enum pcie_bus_config_types pcie_bus_config; ··· 845 853 846 854 /* Do NOT directly access these two variables, unless you are arch-specific PCI 847 855 * code, or PCI core code. */ 848 - extern struct list_head pci_root_buses; /* list of all known PCI buses */ 856 + extern struct list_head pci_root_buses; /* List of all known PCI buses */ 849 857 /* Some device drivers need know if PCI is initiated */ 850 858 int no_pci_devices(void); 851 859 ··· 879 887 struct pci_bus *pci_create_root_bus(struct device *parent, int bus, 880 888 struct pci_ops *ops, void *sysdata, 881 889 struct list_head *resources); 890 + int pci_host_probe(struct pci_host_bridge *bridge); 882 891 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); 883 892 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); 884 893 void pci_bus_release_busn_res(struct pci_bus *b); 885 894 struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, 886 - struct pci_ops *ops, void *sysdata, 887 - struct list_head *resources); 895 + struct pci_ops *ops, void *sysdata, 896 + struct list_head *resources); 888 897 int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge); 889 898 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, 890 899 int busnr); ··· 942 949 struct pci_bus *pci_find_next_bus(const struct pci_bus *from); 943 950 944 951 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, 945 - struct pci_dev *from); 952 + struct pci_dev *from); 946 953 struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, 947 - unsigned int ss_vendor, unsigned int ss_device, 948 - struct pci_dev *from); 954 + unsigned int ss_vendor, unsigned int ss_device, 955 + struct pci_dev *from); 949 956 struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); 950 957 struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus, 951 958 unsigned int devfn); ··· 1021 1028 return pcie_capability_clear_and_set_dword(dev, pos, clear, 0); 1022 1029 } 1023 1030 1024 - /* user-space driven config access */ 1031 + /* User-space driven config access */ 1025 1032 int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); 1026 1033 int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); 1027 1034 int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val); ··· 1164 1171 void pci_lock_rescan_remove(void); 1165 1172 void pci_unlock_rescan_remove(void); 1166 1173 1167 - /* Vital product data routines */ 1174 + /* Vital Product Data routines */ 1168 1175 ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf); 1169 1176 ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf); 1170 1177 int pci_set_vpd_size(struct pci_dev *dev, size_t len); ··· 1249 1256 int __must_check __pci_register_driver(struct pci_driver *, struct module *, 1250 1257 const char *mod_name); 1251 1258 1252 - /* 1253 - * pci_register_driver must be a macro so that KBUILD_MODNAME can be expanded 1254 - */ 1259 + /* pci_register_driver() must be a macro so KBUILD_MODNAME can be expanded */ 1255 1260 #define pci_register_driver(driver) \ 1256 1261 __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) 1257 1262 ··· 1264 1273 * use this macro once, and calling it replaces module_init() and module_exit() 1265 1274 */ 1266 1275 #define module_pci_driver(__pci_driver) \ 1267 - module_driver(__pci_driver, pci_register_driver, \ 1268 - pci_unregister_driver) 1276 + module_driver(__pci_driver, pci_register_driver, pci_unregister_driver) 1269 1277 1270 1278 /** 1271 1279 * builtin_pci_driver() - Helper macro for registering a PCI driver ··· 1303 1313 int pci_set_vga_state(struct pci_dev *pdev, bool decode, 1304 1314 unsigned int command_bits, u32 flags); 1305 1315 1306 - #define PCI_IRQ_LEGACY (1 << 0) /* allow legacy interrupts */ 1307 - #define PCI_IRQ_MSI (1 << 1) /* allow MSI interrupts */ 1308 - #define PCI_IRQ_MSIX (1 << 2) /* allow MSI-X interrupts */ 1309 - #define PCI_IRQ_AFFINITY (1 << 3) /* auto-assign affinity */ 1316 + #define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */ 1317 + #define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */ 1318 + #define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */ 1319 + #define PCI_IRQ_AFFINITY (1 << 3) /* Auto-assign affinity */ 1310 1320 #define PCI_IRQ_ALL_TYPES \ 1311 1321 (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX) 1312 1322 ··· 1325 1335 #define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr) 1326 1336 1327 1337 struct msix_entry { 1328 - u32 vector; /* kernel uses to write allocated vector */ 1329 - u16 entry; /* driver uses to specify entry, OS writes */ 1338 + u32 vector; /* Kernel uses to write allocated vector */ 1339 + u16 entry; /* Driver uses to specify entry, OS writes */ 1330 1340 }; 1331 1341 1332 1342 #ifdef CONFIG_PCI_MSI ··· 1366 1376 static inline int pci_enable_msi(struct pci_dev *dev) 1367 1377 { return -ENOSYS; } 1368 1378 static inline int pci_enable_msix_range(struct pci_dev *dev, 1369 - struct msix_entry *entries, int minvec, int maxvec) 1379 + struct msix_entry *entries, int minvec, int maxvec) 1370 1380 { return -ENOSYS; } 1371 1381 static inline int pci_enable_msix_exact(struct pci_dev *dev, 1372 - struct msix_entry *entries, int nvec) 1382 + struct msix_entry *entries, int nvec) 1373 1383 { return -ENOSYS; } 1374 1384 1375 1385 static inline int ··· 1534 1544 int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent); 1535 1545 #endif 1536 1546 1537 - /* some architectures require additional setup to direct VGA traffic */ 1547 + /* Some architectures require additional setup to direct VGA traffic */ 1538 1548 typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, 1539 - unsigned int command_bits, u32 flags); 1549 + unsigned int command_bits, u32 flags); 1540 1550 void pci_register_set_vga_state(arch_set_vga_state_t func); 1541 1551 1542 1552 static inline int ··· 1575 1585 static inline int pci_has_flag(int flag) { return 0; } 1576 1586 1577 1587 /* 1578 - * If the system does not have PCI, clearly these return errors. Define 1579 - * these as simple inline functions to avoid hair in drivers. 1588 + * If the system does not have PCI, clearly these return errors. Define 1589 + * these as simple inline functions to avoid hair in drivers. 1580 1590 */ 1581 - 1582 1591 #define _PCI_NOP(o, s, t) \ 1583 1592 static inline int pci_##o##_config_##s(struct pci_dev *dev, \ 1584 1593 int where, t val) \ ··· 1676 1687 #define dev_is_pf(d) (false) 1677 1688 static inline bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) 1678 1689 { return false; } 1690 + static inline int pci_irqd_intx_xlate(struct irq_domain *d, 1691 + struct device_node *node, 1692 + const u32 *intspec, 1693 + unsigned int intsize, 1694 + unsigned long *out_hwirq, 1695 + unsigned int *out_type) 1696 + { return -EINVAL; } 1679 1697 #endif /* CONFIG_PCI */ 1680 1698 1681 1699 /* Include architecture-dependent settings and functions */ ··· 1723 1727 #define pci_root_bus_fwnode(bus) NULL 1724 1728 #endif 1725 1729 1726 - /* these helpers provide future and backwards compatibility 1727 - * for accessing popular PCI BAR info */ 1730 + /* 1731 + * These helpers provide future and backwards compatibility 1732 + * for accessing popular PCI BAR info 1733 + */ 1728 1734 #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) 1729 1735 #define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) 1730 1736 #define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) ··· 1738 1740 (pci_resource_end((dev), (bar)) - \ 1739 1741 pci_resource_start((dev), (bar)) + 1)) 1740 1742 1741 - /* Similar to the helpers above, these manipulate per-pci_dev 1743 + /* 1744 + * Similar to the helpers above, these manipulate per-pci_dev 1742 1745 * driver-specific data. They are really just a wrapper around 1743 1746 * the generic device structure functions of these calls. 1744 1747 */ ··· 1753 1754 dev_set_drvdata(&pdev->dev, data); 1754 1755 } 1755 1756 1756 - /* If you want to know what to call your pci_dev, ask this function. 1757 - * Again, it's a wrapper around the generic device. 1758 - */ 1759 1757 static inline const char *pci_name(const struct pci_dev *pdev) 1760 1758 { 1761 1759 return dev_name(&pdev->dev); 1762 1760 } 1763 1761 1764 1762 1765 - /* Some archs don't want to expose struct resource to userland as-is 1763 + /* 1764 + * Some archs don't want to expose struct resource to userland as-is 1766 1765 * in sysfs and /proc 1767 1766 */ 1768 1767 #ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER ··· 1779 1782 1780 1783 1781 1784 /* 1782 - * The world is not perfect and supplies us with broken PCI devices. 1783 - * For at least a part of these bugs we need a work-around, so both 1784 - * generic (drivers/pci/quirks.c) and per-architecture code can define 1785 - * fixup hooks to be called for particular buggy devices. 1785 + * The world is not perfect and supplies us with broken PCI devices. 1786 + * For at least a part of these bugs we need a work-around, so both 1787 + * generic (drivers/pci/quirks.c) and per-architecture code can define 1788 + * fixup hooks to be called for particular buggy devices. 1786 1789 */ 1787 1790 1788 1791 struct pci_fixup { 1789 - u16 vendor; /* You can use PCI_ANY_ID here of course */ 1790 - u16 device; /* You can use PCI_ANY_ID here of course */ 1791 - u32 class; /* You can use PCI_ANY_ID here too */ 1792 + u16 vendor; /* Or PCI_ANY_ID */ 1793 + u16 device; /* Or PCI_ANY_ID */ 1794 + u32 class; /* Or PCI_ANY_ID */ 1792 1795 unsigned int class_shift; /* should be 0, 8, 16 */ 1793 1796 void (*hook)(struct pci_dev *dev); 1794 1797 }; ··· 1830 1833 #define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \ 1831 1834 class_shift, hook) \ 1832 1835 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1833 - resume##hook, vendor, device, class, \ 1834 - class_shift, hook) 1836 + resume##hook, vendor, device, class, class_shift, hook) 1835 1837 #define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \ 1836 1838 class_shift, hook) \ 1837 1839 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1838 - resume_early##hook, vendor, device, \ 1839 - class, class_shift, hook) 1840 + resume_early##hook, vendor, device, class, class_shift, hook) 1840 1841 #define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \ 1841 1842 class_shift, hook) \ 1842 1843 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1843 - suspend##hook, vendor, device, class, \ 1844 - class_shift, hook) 1844 + suspend##hook, vendor, device, class, class_shift, hook) 1845 1845 #define DECLARE_PCI_FIXUP_CLASS_SUSPEND_LATE(vendor, device, class, \ 1846 1846 class_shift, hook) \ 1847 1847 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late, \ 1848 - suspend_late##hook, vendor, device, \ 1849 - class, class_shift, hook) 1848 + suspend_late##hook, vendor, device, class, class_shift, hook) 1850 1849 1851 1850 #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ 1852 1851 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ ··· 1858 1865 hook, vendor, device, PCI_ANY_ID, 0, hook) 1859 1866 #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ 1860 1867 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1861 - resume##hook, vendor, device, \ 1862 - PCI_ANY_ID, 0, hook) 1868 + resume##hook, vendor, device, PCI_ANY_ID, 0, hook) 1863 1869 #define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ 1864 1870 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1865 - resume_early##hook, vendor, device, \ 1866 - PCI_ANY_ID, 0, hook) 1871 + resume_early##hook, vendor, device, PCI_ANY_ID, 0, hook) 1867 1872 #define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ 1868 1873 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1869 - suspend##hook, vendor, device, \ 1870 - PCI_ANY_ID, 0, hook) 1874 + suspend##hook, vendor, device, PCI_ANY_ID, 0, hook) 1871 1875 #define DECLARE_PCI_FIXUP_SUSPEND_LATE(vendor, device, hook) \ 1872 1876 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late, \ 1873 - suspend_late##hook, vendor, device, \ 1874 - PCI_ANY_ID, 0, hook) 1877 + suspend_late##hook, vendor, device, PCI_ANY_ID, 0, hook) 1875 1878 1876 1879 #ifdef CONFIG_PCI_QUIRKS 1877 1880 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); ··· 2053 2064 bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); 2054 2065 bool pci_acs_path_enabled(struct pci_dev *start, 2055 2066 struct pci_dev *end, u16 acs_flags); 2067 + int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask); 2056 2068 2057 2069 #define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ 2058 2070 #define PCI_VPD_LRDT_ID(x) ((x) | PCI_VPD_LRDT) ··· 2105 2115 */ 2106 2116 static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt) 2107 2117 { 2108 - return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK); 2118 + return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK); 2109 2119 } 2110 2120 2111 2121 /** ··· 2175 2185 void pci_set_bus_of_node(struct pci_bus *bus); 2176 2186 void pci_release_bus_of_node(struct pci_bus *bus); 2177 2187 struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus); 2188 + int pci_parse_request_of_pci_ranges(struct device *dev, 2189 + struct list_head *resources, 2190 + struct resource **bus_range); 2178 2191 2179 2192 /* Arch may override this (weak) */ 2180 2193 struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); ··· 2193 2200 return bus ? bus->dev.of_node : NULL; 2194 2201 } 2195 2202 2196 - #else /* CONFIG_OF */ 2203 + #else /* CONFIG_OF */ 2197 2204 static inline void pci_set_of_node(struct pci_dev *dev) { } 2198 2205 static inline void pci_release_of_node(struct pci_dev *dev) { } 2199 2206 static inline void pci_set_bus_of_node(struct pci_bus *bus) { } ··· 2202 2209 pci_device_to_OF_node(const struct pci_dev *pdev) { return NULL; } 2203 2210 static inline struct irq_domain * 2204 2211 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } 2212 + static inline int pci_parse_request_of_pci_ranges(struct device *dev, 2213 + struct list_head *resources, 2214 + struct resource **bus_range) 2215 + { 2216 + return -EINVAL; 2217 + } 2205 2218 #endif /* CONFIG_OF */ 2206 2219 2207 2220 #ifdef CONFIG_ACPI ··· 2233 2234 int (*fn)(struct pci_dev *pdev, 2234 2235 u16 alias, void *data), void *data); 2235 2236 2236 - /* helper functions for operation of device flag */ 2237 + /* Helper functions for operation of device flag */ 2237 2238 static inline void pci_set_dev_assigned(struct pci_dev *pdev) 2238 2239 { 2239 2240 pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED; ··· 2316 2317 } 2317 2318 } 2318 2319 2319 - /* provide the legacy pci_dma_* API */ 2320 + /* Provide the legacy pci_dma_* API */ 2320 2321 #include <linux/pci-dma-compat.h> 2322 + 2323 + #define pci_printk(level, pdev, fmt, arg...) \ 2324 + dev_printk(level, &(pdev)->dev, fmt, ##arg) 2325 + 2326 + #define pci_emerg(pdev, fmt, arg...) dev_emerg(&(pdev)->dev, fmt, ##arg) 2327 + #define pci_alert(pdev, fmt, arg...) dev_alert(&(pdev)->dev, fmt, ##arg) 2328 + #define pci_crit(pdev, fmt, arg...) dev_crit(&(pdev)->dev, fmt, ##arg) 2329 + #define pci_err(pdev, fmt, arg...) dev_err(&(pdev)->dev, fmt, ##arg) 2330 + #define pci_warn(pdev, fmt, arg...) dev_warn(&(pdev)->dev, fmt, ##arg) 2331 + #define pci_notice(pdev, fmt, arg...) dev_notice(&(pdev)->dev, fmt, ##arg) 2332 + #define pci_info(pdev, fmt, arg...) dev_info(&(pdev)->dev, fmt, ##arg) 2333 + #define pci_dbg(pdev, fmt, arg...) dev_dbg(&(pdev)->dev, fmt, ##arg) 2321 2334 2322 2335 #endif /* LINUX_PCI_H */
+1 -15
include/linux/pci_hotplug.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * PCI HotPlug Core Functions 3 4 * ··· 7 6 * Copyright (C) 2001 IBM Corp. 8 7 * 9 8 * All rights reserved. 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 (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 9 * 26 10 * Send feedback to <kristen.c.accardi@intel.com> 27 11 *
+2
include/linux/pci_ids.h
··· 2381 2381 2382 2382 #define PCI_VENDOR_ID_LENOVO 0x17aa 2383 2383 2384 + #define PCI_VENDOR_ID_CDNS 0x17cd 2385 + 2384 2386 #define PCI_VENDOR_ID_ARECA 0x17d3 2385 2387 #define PCI_DEVICE_ID_ARECA_1110 0x1110 2386 2388 #define PCI_DEVICE_ID_ARECA_1120 0x1120
+3
include/linux/switchtec.h
··· 100 100 u32 gpio_interrupt_hdr; 101 101 u32 gpio_interrupt_data; 102 102 u32 reserved16[4]; 103 + u32 gfms_event_hdr; 104 + u32 gfms_event_data; 105 + u32 reserved17[4]; 103 106 } __packed; 104 107 105 108 enum {
+18 -12
include/uapi/linux/pci_regs.h
··· 622 622 * safely. 623 623 */ 624 624 #define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */ 625 + #define PCI_EXP_DEVCAP2_COMP_TMOUT_DIS 0x00000010 /* Completion Timeout Disable supported */ 625 626 #define PCI_EXP_DEVCAP2_ARI 0x00000020 /* Alternative Routing-ID */ 626 627 #define PCI_EXP_DEVCAP2_ATOMIC_ROUTE 0x00000040 /* Atomic Op routing */ 627 - #define PCI_EXP_DEVCAP2_ATOMIC_COMP64 0x00000100 /* Atomic 64-bit compare */ 628 + #define PCI_EXP_DEVCAP2_ATOMIC_COMP32 0x00000080 /* 32b AtomicOp completion */ 629 + #define PCI_EXP_DEVCAP2_ATOMIC_COMP64 0x00000100 /* 64b AtomicOp completion */ 630 + #define PCI_EXP_DEVCAP2_ATOMIC_COMP128 0x00000200 /* 128b AtomicOp completion */ 628 631 #define PCI_EXP_DEVCAP2_LTR 0x00000800 /* Latency tolerance reporting */ 629 632 #define PCI_EXP_DEVCAP2_OBFF_MASK 0x000c0000 /* OBFF support mechanism */ 630 633 #define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ 631 634 #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ 632 635 #define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ 633 636 #define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */ 637 + #define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010 /* Completion Timeout Disable */ 634 638 #define PCI_EXP_DEVCTL2_ARI 0x0020 /* Alternative Routing-ID */ 635 639 #define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040 /* Set Atomic requests */ 636 640 #define PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK 0x0080 /* Block atomic egress */ ··· 970 966 971 967 /* Downstream Port Containment */ 972 968 #define PCI_EXP_DPC_CAP 4 /* DPC Capability */ 973 - #define PCI_EXP_DPC_IRQ 0x1f /* DPC Interrupt Message Number */ 974 - #define PCI_EXP_DPC_CAP_RP_EXT 0x20 /* Root Port Extensions for DPC */ 975 - #define PCI_EXP_DPC_CAP_POISONED_TLP 0x40 /* Poisoned TLP Egress Blocking Supported */ 976 - #define PCI_EXP_DPC_CAP_SW_TRIGGER 0x80 /* Software Triggering Supported */ 977 - #define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0xF00 /* RP PIO log size */ 969 + #define PCI_EXP_DPC_IRQ 0x001F /* Interrupt Message Number */ 970 + #define PCI_EXP_DPC_CAP_RP_EXT 0x0020 /* Root Port Extensions */ 971 + #define PCI_EXP_DPC_CAP_POISONED_TLP 0x0040 /* Poisoned TLP Egress Blocking Supported */ 972 + #define PCI_EXP_DPC_CAP_SW_TRIGGER 0x0080 /* Software Triggering Supported */ 973 + #define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0x0F00 /* RP PIO Log Size */ 978 974 #define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000 /* ERR_COR signal on DL_Active supported */ 979 975 980 976 #define PCI_EXP_DPC_CTL 6 /* DPC control */ 981 - #define PCI_EXP_DPC_CTL_EN_NONFATAL 0x02 /* Enable trigger on ERR_NONFATAL message */ 982 - #define PCI_EXP_DPC_CTL_INT_EN 0x08 /* DPC Interrupt Enable */ 977 + #define PCI_EXP_DPC_CTL_EN_NONFATAL 0x0002 /* Enable trigger on ERR_NONFATAL message */ 978 + #define PCI_EXP_DPC_CTL_INT_EN 0x0008 /* DPC Interrupt Enable */ 983 979 984 980 #define PCI_EXP_DPC_STATUS 8 /* DPC Status */ 985 - #define PCI_EXP_DPC_STATUS_TRIGGER 0x01 /* Trigger Status */ 986 - #define PCI_EXP_DPC_STATUS_INTERRUPT 0x08 /* Interrupt Status */ 987 - #define PCI_EXP_DPC_RP_BUSY 0x10 /* Root Port Busy */ 981 + #define PCI_EXP_DPC_STATUS_TRIGGER 0x0001 /* Trigger Status */ 982 + #define PCI_EXP_DPC_STATUS_TRIGGER_RSN 0x0006 /* Trigger Reason */ 983 + #define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */ 984 + #define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */ 985 + #define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */ 988 986 989 987 #define PCI_EXP_DPC_SOURCE_ID 10 /* DPC Source Identifier */ 990 988 991 989 #define PCI_EXP_DPC_RP_PIO_STATUS 0x0C /* RP PIO Status */ 992 - #define PCI_EXP_DPC_RP_PIO_MASK 0x10 /* RP PIO MASK */ 990 + #define PCI_EXP_DPC_RP_PIO_MASK 0x10 /* RP PIO Mask */ 993 991 #define PCI_EXP_DPC_RP_PIO_SEVERITY 0x14 /* RP PIO Severity */ 994 992 #define PCI_EXP_DPC_RP_PIO_SYSERROR 0x18 /* RP PIO SysError */ 995 993 #define PCI_EXP_DPC_RP_PIO_EXCEPTION 0x1C /* RP PIO Exception */
+2 -1
include/uapi/linux/switchtec_ioctl.h
··· 88 88 #define SWITCHTEC_IOCTL_EVENT_FORCE_SPEED 26 89 89 #define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT 27 90 90 #define SWITCHTEC_IOCTL_EVENT_LINK_STATE 28 91 - #define SWITCHTEC_IOCTL_MAX_EVENTS 29 91 + #define SWITCHTEC_IOCTL_EVENT_GFMS 29 92 + #define SWITCHTEC_IOCTL_MAX_EVENTS 30 92 93 93 94 #define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX -1 94 95 #define SWITCHTEC_IOCTL_EVENT_IDX_ALL -2
+21 -8
kernel/resource.c
··· 1022 1022 struct resource *conflict; 1023 1023 struct resource *res = alloc_resource(GFP_ATOMIC); 1024 1024 struct resource *next_res = NULL; 1025 + int type = resource_type(root); 1025 1026 1026 1027 if (!res) 1027 1028 return; ··· 1030 1029 res->name = name; 1031 1030 res->start = start; 1032 1031 res->end = end; 1033 - res->flags = IORESOURCE_BUSY; 1032 + res->flags = type | IORESOURCE_BUSY; 1034 1033 res->desc = IORES_DESC_NONE; 1035 1034 1036 1035 while (1) { ··· 1065 1064 next_res->name = name; 1066 1065 next_res->start = conflict->end + 1; 1067 1066 next_res->end = end; 1068 - next_res->flags = IORESOURCE_BUSY; 1067 + next_res->flags = type | IORESOURCE_BUSY; 1069 1068 next_res->desc = IORES_DESC_NONE; 1070 1069 } 1071 1070 } else { ··· 1479 1478 EXPORT_SYMBOL(__devm_release_region); 1480 1479 1481 1480 /* 1482 - * Called from init/main.c to reserve IO ports. 1481 + * Reserve I/O ports or memory based on "reserve=" kernel parameter. 1483 1482 */ 1484 1483 #define MAXRESERVE 4 1485 1484 static int __init reserve_setup(char *str) ··· 1490 1489 for (;;) { 1491 1490 unsigned int io_start, io_num; 1492 1491 int x = reserved; 1492 + struct resource *parent; 1493 1493 1494 - if (get_option (&str, &io_start) != 2) 1494 + if (get_option(&str, &io_start) != 2) 1495 1495 break; 1496 - if (get_option (&str, &io_num) == 0) 1496 + if (get_option(&str, &io_num) == 0) 1497 1497 break; 1498 1498 if (x < MAXRESERVE) { 1499 1499 struct resource *res = reserve + x; 1500 + 1501 + /* 1502 + * If the region starts below 0x10000, we assume it's 1503 + * I/O port space; otherwise assume it's memory. 1504 + */ 1505 + if (io_start < 0x10000) { 1506 + res->flags = IORESOURCE_IO; 1507 + parent = &ioport_resource; 1508 + } else { 1509 + res->flags = IORESOURCE_MEM; 1510 + parent = &iomem_resource; 1511 + } 1500 1512 res->name = "reserved"; 1501 1513 res->start = io_start; 1502 1514 res->end = io_start + io_num - 1; 1503 - res->flags = IORESOURCE_BUSY; 1515 + res->flags |= IORESOURCE_BUSY; 1504 1516 res->desc = IORES_DESC_NONE; 1505 1517 res->child = NULL; 1506 - if (request_resource(res->start >= 0x10000 ? &iomem_resource : &ioport_resource, res) == 0) 1518 + if (request_resource(parent, res) == 0) 1507 1519 reserved = x+1; 1508 1520 } 1509 1521 } 1510 1522 return 1; 1511 1523 } 1512 - 1513 1524 __setup("reserve=", reserve_setup); 1514 1525 1515 1526 /*
+1
lib/pci_iomap.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Implement the default iomap interfaces 3 4 *