diff options
69 files changed, 1796 insertions, 1077 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 46b826fcb5ad..7d407bdded99 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
@@ -3452,12 +3452,13 @@ | |||
3452 | specify the device is described above. | 3452 | specify the device is described above. |
3453 | If <order of align> is not specified, | 3453 | If <order of align> is not specified, |
3454 | PAGE_SIZE is used as alignment. | 3454 | PAGE_SIZE is used as alignment. |
3455 | PCI-PCI bridge can be specified, if resource | 3455 | A PCI-PCI bridge can be specified if resource |
3456 | windows need to be expanded. | 3456 | windows need to be expanded. |
3457 | To specify the alignment for several | 3457 | To specify the alignment for several |
3458 | instances of a device, the PCI vendor, | 3458 | instances of a device, the PCI vendor, |
3459 | device, subvendor, and subdevice may be | 3459 | device, subvendor, and subdevice may be |
3460 | specified, e.g., 4096@pci:8086:9c22:103c:198f | 3460 | specified, e.g., 12@pci:8086:9c22:103c:198f |
3461 | for 4096-byte alignment. | ||
3461 | ecrc= Enable/disable PCIe ECRC (transaction layer | 3462 | ecrc= Enable/disable PCIe ECRC (transaction layer |
3462 | end-to-end CRC checking). | 3463 | end-to-end CRC checking). |
3463 | bios: Use BIOS/firmware settings. This is the | 3464 | bios: Use BIOS/firmware settings. This is the |
diff --git a/Documentation/devicetree/bindings/pci/designware-pcie.txt b/Documentation/devicetree/bindings/pci/designware-pcie.txt index 5561a1c060d0..bd880df39a79 100644 --- a/Documentation/devicetree/bindings/pci/designware-pcie.txt +++ b/Documentation/devicetree/bindings/pci/designware-pcie.txt | |||
@@ -11,7 +11,6 @@ Required properties: | |||
11 | the ATU address space. | 11 | the ATU address space. |
12 | (The old way of getting the configuration address space from "ranges" | 12 | (The old way of getting the configuration address space from "ranges" |
13 | is deprecated and should be avoided.) | 13 | is deprecated and should be avoided.) |
14 | - num-lanes: number of lanes to use | ||
15 | RC mode: | 14 | RC mode: |
16 | - #address-cells: set to <3> | 15 | - #address-cells: set to <3> |
17 | - #size-cells: set to <2> | 16 | - #size-cells: set to <2> |
diff --git a/Documentation/devicetree/bindings/pci/pcie-al.txt b/Documentation/devicetree/bindings/pci/pcie-al.txt new file mode 100644 index 000000000000..557a5089229d --- /dev/null +++ b/Documentation/devicetree/bindings/pci/pcie-al.txt | |||
@@ -0,0 +1,46 @@ | |||
1 | * Amazon Annapurna Labs PCIe host bridge | ||
2 | |||
3 | Amazon's Annapurna Labs PCIe Host Controller is based on the Synopsys DesignWare | ||
4 | PCI core. It inherits common properties defined in | ||
5 | Documentation/devicetree/bindings/pci/designware-pcie.txt. | ||
6 | |||
7 | Properties of the host controller node that differ from it are: | ||
8 | |||
9 | - compatible: | ||
10 | Usage: required | ||
11 | Value type: <stringlist> | ||
12 | Definition: Value should contain | ||
13 | - "amazon,al-alpine-v2-pcie" for alpine_v2 | ||
14 | - "amazon,al-alpine-v3-pcie" for alpine_v3 | ||
15 | |||
16 | - reg: | ||
17 | Usage: required | ||
18 | Value type: <prop-encoded-array> | ||
19 | Definition: Register ranges as listed in the reg-names property | ||
20 | |||
21 | - reg-names: | ||
22 | Usage: required | ||
23 | Value type: <stringlist> | ||
24 | Definition: Must include the following entries | ||
25 | - "config" PCIe ECAM space | ||
26 | - "controller" AL proprietary registers | ||
27 | - "dbi" Designware PCIe registers | ||
28 | |||
29 | Example: | ||
30 | |||
31 | pcie-external0: pcie@fb600000 { | ||
32 | compatible = "amazon,al-alpine-v3-pcie"; | ||
33 | reg = <0x0 0xfb600000 0x0 0x00100000 | ||
34 | 0x0 0xfd800000 0x0 0x00010000 | ||
35 | 0x0 0xfd810000 0x0 0x00001000>; | ||
36 | reg-names = "config", "controller", "dbi"; | ||
37 | bus-range = <0 255>; | ||
38 | device_type = "pci"; | ||
39 | #address-cells = <3>; | ||
40 | #size-cells = <2>; | ||
41 | #interrupt-cells = <1>; | ||
42 | interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; | ||
43 | interrupt-map-mask = <0x00 0 0 7>; | ||
44 | interrupt-map = <0x0000 0 0 1 &gic GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>; /* INTa */ | ||
45 | ranges = <0x02000000 0x0 0xc0010000 0x0 0xc0010000 0x0 0x07ff0000>; | ||
46 | }; | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 783569e3c4b4..d200b16fa95c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -12448,10 +12448,11 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/ | |||
12448 | S: Supported | 12448 | S: Supported |
12449 | F: drivers/pci/controller/ | 12449 | F: drivers/pci/controller/ |
12450 | 12450 | ||
12451 | PCIE DRIVER FOR ANNAPURNA LABS | 12451 | PCIE DRIVER FOR AMAZON ANNAPURNA LABS |
12452 | M: Jonathan Chocron <jonnyc@amazon.com> | 12452 | M: Jonathan Chocron <jonnyc@amazon.com> |
12453 | L: linux-pci@vger.kernel.org | 12453 | L: linux-pci@vger.kernel.org |
12454 | S: Maintained | 12454 | S: Maintained |
12455 | F: Documentation/devicetree/bindings/pci/pcie-al.txt | ||
12455 | F: drivers/pci/controller/dwc/pcie-al.c | 12456 | F: drivers/pci/controller/dwc/pcie-al.c |
12456 | 12457 | ||
12457 | PCIE DRIVER FOR AMLOGIC MESON | 12458 | PCIE DRIVER FOR AMLOGIC MESON |
diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi index 464df4290ffc..2f6977ada447 100644 --- a/arch/arm/boot/dts/ls1021a.dtsi +++ b/arch/arm/boot/dts/ls1021a.dtsi | |||
@@ -874,7 +874,6 @@ | |||
874 | #address-cells = <3>; | 874 | #address-cells = <3>; |
875 | #size-cells = <2>; | 875 | #size-cells = <2>; |
876 | device_type = "pci"; | 876 | device_type = "pci"; |
877 | num-lanes = <4>; | ||
878 | num-viewport = <6>; | 877 | num-viewport = <6>; |
879 | bus-range = <0x0 0xff>; | 878 | bus-range = <0x0 0xff>; |
880 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ | 879 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -899,7 +898,6 @@ | |||
899 | #address-cells = <3>; | 898 | #address-cells = <3>; |
900 | #size-cells = <2>; | 899 | #size-cells = <2>; |
901 | device_type = "pci"; | 900 | device_type = "pci"; |
902 | num-lanes = <4>; | ||
903 | num-viewport = <6>; | 901 | num-viewport = <6>; |
904 | bus-range = <0x0 0xff>; | 902 | bus-range = <0x0 0xff>; |
905 | ranges = <0x81000000 0x0 0x00000000 0x48 0x00010000 0x0 0x00010000 /* downstream I/O */ | 903 | ranges = <0x81000000 0x0 0x00000000 0x48 0x00010000 0x0 0x00010000 /* downstream I/O */ |
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi index ec6257a5b251..119c597ca867 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi | |||
@@ -486,7 +486,6 @@ | |||
486 | #address-cells = <3>; | 486 | #address-cells = <3>; |
487 | #size-cells = <2>; | 487 | #size-cells = <2>; |
488 | device_type = "pci"; | 488 | device_type = "pci"; |
489 | num-lanes = <4>; | ||
490 | num-viewport = <2>; | 489 | num-viewport = <2>; |
491 | bus-range = <0x0 0xff>; | 490 | bus-range = <0x0 0xff>; |
492 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ | 491 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ |
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi index 71d9ed9ff985..c084c7a4b6a6 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi | |||
@@ -677,7 +677,6 @@ | |||
677 | #size-cells = <2>; | 677 | #size-cells = <2>; |
678 | device_type = "pci"; | 678 | device_type = "pci"; |
679 | dma-coherent; | 679 | dma-coherent; |
680 | num-lanes = <4>; | ||
681 | num-viewport = <6>; | 680 | num-viewport = <6>; |
682 | bus-range = <0x0 0xff>; | 681 | bus-range = <0x0 0xff>; |
683 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ | 682 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -704,7 +703,6 @@ | |||
704 | #size-cells = <2>; | 703 | #size-cells = <2>; |
705 | device_type = "pci"; | 704 | device_type = "pci"; |
706 | dma-coherent; | 705 | dma-coherent; |
707 | num-lanes = <2>; | ||
708 | num-viewport = <6>; | 706 | num-viewport = <6>; |
709 | bus-range = <0x0 0xff>; | 707 | bus-range = <0x0 0xff>; |
710 | ranges = <0x81000000 0x0 0x00000000 0x48 0x00010000 0x0 0x00010000 /* downstream I/O */ | 708 | ranges = <0x81000000 0x0 0x00000000 0x48 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -731,7 +729,6 @@ | |||
731 | #size-cells = <2>; | 729 | #size-cells = <2>; |
732 | device_type = "pci"; | 730 | device_type = "pci"; |
733 | dma-coherent; | 731 | dma-coherent; |
734 | num-lanes = <2>; | ||
735 | num-viewport = <6>; | 732 | num-viewport = <6>; |
736 | bus-range = <0x0 0xff>; | 733 | bus-range = <0x0 0xff>; |
737 | ranges = <0x81000000 0x0 0x00000000 0x50 0x00010000 0x0 0x00010000 /* downstream I/O */ | 734 | ranges = <0x81000000 0x0 0x00000000 0x50 0x00010000 0x0 0x00010000 /* downstream I/O */ |
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi index b0ef08b090dd..d4c1da3d4bde 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi | |||
@@ -649,7 +649,6 @@ | |||
649 | #size-cells = <2>; | 649 | #size-cells = <2>; |
650 | device_type = "pci"; | 650 | device_type = "pci"; |
651 | dma-coherent; | 651 | dma-coherent; |
652 | num-lanes = <4>; | ||
653 | num-viewport = <8>; | 652 | num-viewport = <8>; |
654 | bus-range = <0x0 0xff>; | 653 | bus-range = <0x0 0xff>; |
655 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ | 654 | ranges = <0x81000000 0x0 0x00000000 0x40 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -671,7 +670,6 @@ | |||
671 | reg-names = "regs", "addr_space"; | 670 | reg-names = "regs", "addr_space"; |
672 | num-ib-windows = <6>; | 671 | num-ib-windows = <6>; |
673 | num-ob-windows = <8>; | 672 | num-ob-windows = <8>; |
674 | num-lanes = <2>; | ||
675 | status = "disabled"; | 673 | status = "disabled"; |
676 | }; | 674 | }; |
677 | 675 | ||
@@ -687,7 +685,6 @@ | |||
687 | #size-cells = <2>; | 685 | #size-cells = <2>; |
688 | device_type = "pci"; | 686 | device_type = "pci"; |
689 | dma-coherent; | 687 | dma-coherent; |
690 | num-lanes = <2>; | ||
691 | num-viewport = <8>; | 688 | num-viewport = <8>; |
692 | bus-range = <0x0 0xff>; | 689 | bus-range = <0x0 0xff>; |
693 | ranges = <0x81000000 0x0 0x00000000 0x48 0x00010000 0x0 0x00010000 /* downstream I/O */ | 690 | ranges = <0x81000000 0x0 0x00000000 0x48 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -709,7 +706,6 @@ | |||
709 | reg-names = "regs", "addr_space"; | 706 | reg-names = "regs", "addr_space"; |
710 | num-ib-windows = <6>; | 707 | num-ib-windows = <6>; |
711 | num-ob-windows = <8>; | 708 | num-ob-windows = <8>; |
712 | num-lanes = <2>; | ||
713 | status = "disabled"; | 709 | status = "disabled"; |
714 | }; | 710 | }; |
715 | 711 | ||
@@ -725,7 +721,6 @@ | |||
725 | #size-cells = <2>; | 721 | #size-cells = <2>; |
726 | device_type = "pci"; | 722 | device_type = "pci"; |
727 | dma-coherent; | 723 | dma-coherent; |
728 | num-lanes = <2>; | ||
729 | num-viewport = <8>; | 724 | num-viewport = <8>; |
730 | bus-range = <0x0 0xff>; | 725 | bus-range = <0x0 0xff>; |
731 | ranges = <0x81000000 0x0 0x00000000 0x50 0x00010000 0x0 0x00010000 /* downstream I/O */ | 726 | ranges = <0x81000000 0x0 0x00000000 0x50 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -747,7 +742,6 @@ | |||
747 | reg-names = "regs", "addr_space"; | 742 | reg-names = "regs", "addr_space"; |
748 | num-ib-windows = <6>; | 743 | num-ib-windows = <6>; |
749 | num-ob-windows = <8>; | 744 | num-ob-windows = <8>; |
750 | num-lanes = <2>; | ||
751 | status = "disabled"; | 745 | status = "disabled"; |
752 | }; | 746 | }; |
753 | 747 | ||
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi index dacd8cf03a7f..ce48a2323337 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | |||
@@ -452,7 +452,6 @@ | |||
452 | #size-cells = <2>; | 452 | #size-cells = <2>; |
453 | device_type = "pci"; | 453 | device_type = "pci"; |
454 | dma-coherent; | 454 | dma-coherent; |
455 | num-lanes = <4>; | ||
456 | num-viewport = <256>; | 455 | num-viewport = <256>; |
457 | bus-range = <0x0 0xff>; | 456 | bus-range = <0x0 0xff>; |
458 | ranges = <0x81000000 0x0 0x00000000 0x20 0x00010000 0x0 0x00010000 /* downstream I/O */ | 457 | ranges = <0x81000000 0x0 0x00000000 0x20 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -478,7 +477,6 @@ | |||
478 | #size-cells = <2>; | 477 | #size-cells = <2>; |
479 | device_type = "pci"; | 478 | device_type = "pci"; |
480 | dma-coherent; | 479 | dma-coherent; |
481 | num-lanes = <4>; | ||
482 | num-viewport = <6>; | 480 | num-viewport = <6>; |
483 | bus-range = <0x0 0xff>; | 481 | bus-range = <0x0 0xff>; |
484 | ranges = <0x81000000 0x0 0x00000000 0x28 0x00010000 0x0 0x00010000 /* downstream I/O */ | 482 | ranges = <0x81000000 0x0 0x00000000 0x28 0x00010000 0x0 0x00010000 /* downstream I/O */ |
@@ -504,7 +502,6 @@ | |||
504 | #size-cells = <2>; | 502 | #size-cells = <2>; |
505 | device_type = "pci"; | 503 | device_type = "pci"; |
506 | dma-coherent; | 504 | dma-coherent; |
507 | num-lanes = <8>; | ||
508 | num-viewport = <6>; | 505 | num-viewport = <6>; |
509 | bus-range = <0x0 0xff>; | 506 | bus-range = <0x0 0xff>; |
510 | ranges = <0x81000000 0x0 0x00000000 0x30 0x00010000 0x0 0x00010000 /* downstream I/O */ | 507 | ranges = <0x81000000 0x0 0x00000000 0x30 0x00010000 0x0 0x00010000 /* downstream I/O */ |
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi index 3ace91945b72..d4993a2b404f 100644 --- a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +++ b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | |||
@@ -634,7 +634,6 @@ | |||
634 | #size-cells = <2>; | 634 | #size-cells = <2>; |
635 | device_type = "pci"; | 635 | device_type = "pci"; |
636 | dma-coherent; | 636 | dma-coherent; |
637 | num-lanes = <4>; | ||
638 | num-viewport = <6>; | 637 | num-viewport = <6>; |
639 | bus-range = <0x0 0xff>; | 638 | bus-range = <0x0 0xff>; |
640 | msi-parent = <&its>; | 639 | msi-parent = <&its>; |
@@ -656,7 +655,6 @@ | |||
656 | #size-cells = <2>; | 655 | #size-cells = <2>; |
657 | device_type = "pci"; | 656 | device_type = "pci"; |
658 | dma-coherent; | 657 | dma-coherent; |
659 | num-lanes = <4>; | ||
660 | num-viewport = <6>; | 658 | num-viewport = <6>; |
661 | bus-range = <0x0 0xff>; | 659 | bus-range = <0x0 0xff>; |
662 | msi-parent = <&its>; | 660 | msi-parent = <&its>; |
@@ -678,7 +676,6 @@ | |||
678 | #size-cells = <2>; | 676 | #size-cells = <2>; |
679 | device_type = "pci"; | 677 | device_type = "pci"; |
680 | dma-coherent; | 678 | dma-coherent; |
681 | num-lanes = <8>; | ||
682 | num-viewport = <256>; | 679 | num-viewport = <256>; |
683 | bus-range = <0x0 0xff>; | 680 | bus-range = <0x0 0xff>; |
684 | msi-parent = <&its>; | 681 | msi-parent = <&its>; |
@@ -700,7 +697,6 @@ | |||
700 | #size-cells = <2>; | 697 | #size-cells = <2>; |
701 | device_type = "pci"; | 698 | device_type = "pci"; |
702 | dma-coherent; | 699 | dma-coherent; |
703 | num-lanes = <4>; | ||
704 | num-viewport = <6>; | 700 | num-viewport = <6>; |
705 | bus-range = <0x0 0xff>; | 701 | bus-range = <0x0 0xff>; |
706 | msi-parent = <&its>; | 702 | msi-parent = <&its>; |
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h index 21ddba9188b2..7c4dc5d85f53 100644 --- a/arch/microblaze/include/asm/pci.h +++ b/arch/microblaze/include/asm/pci.h | |||
@@ -66,8 +66,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file, | |||
66 | unsigned long size, | 66 | unsigned long size, |
67 | pgprot_t prot); | 67 | pgprot_t prot); |
68 | 68 | ||
69 | #define HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
70 | |||
71 | /* This part of code was originally in xilinx-pci.h */ | 69 | /* This part of code was originally in xilinx-pci.h */ |
72 | #ifdef CONFIG_PCI_XILINX | 70 | #ifdef CONFIG_PCI_XILINX |
73 | extern void __init xilinx_pci_init(void); | 71 | extern void __init xilinx_pci_init(void); |
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h index 436099883022..6f48649201c5 100644 --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h | |||
@@ -108,7 +108,6 @@ extern unsigned long PCIBIOS_MIN_MEM; | |||
108 | 108 | ||
109 | #define HAVE_PCI_MMAP | 109 | #define HAVE_PCI_MMAP |
110 | #define ARCH_GENERIC_PCI_MMAP_RESOURCE | 110 | #define ARCH_GENERIC_PCI_MMAP_RESOURCE |
111 | #define HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
112 | 111 | ||
113 | /* | 112 | /* |
114 | * Dynamic DMA mapping stuff. | 113 | * Dynamic DMA mapping stuff. |
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 2372d35533ad..327567b8f7d6 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h | |||
@@ -112,8 +112,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file, | |||
112 | unsigned long size, | 112 | unsigned long size, |
113 | pgprot_t prot); | 113 | pgprot_t prot); |
114 | 114 | ||
115 | #define HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
116 | |||
117 | extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); | 115 | extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); |
118 | extern void pcibios_setup_bus_devices(struct pci_bus *bus); | 116 | extern void pcibios_setup_bus_devices(struct pci_bus *bus); |
119 | extern void pcibios_setup_bus_self(struct pci_bus *bus); | 117 | extern void pcibios_setup_bus_self(struct pci_bus *bus); |
diff --git a/arch/sparc/include/asm/pci.h b/arch/sparc/include/asm/pci.h index cfec79bb1831..4deddf430e5d 100644 --- a/arch/sparc/include/asm/pci.h +++ b/arch/sparc/include/asm/pci.h | |||
@@ -38,8 +38,6 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
38 | #define arch_can_pci_mmap_io() 1 | 38 | #define arch_can_pci_mmap_io() 1 |
39 | #define HAVE_ARCH_PCI_GET_UNMAPPED_AREA | 39 | #define HAVE_ARCH_PCI_GET_UNMAPPED_AREA |
40 | #define get_pci_unmapped_area get_fb_unmapped_area | 40 | #define get_pci_unmapped_area get_fb_unmapped_area |
41 | |||
42 | #define HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
43 | #endif /* CONFIG_SPARC64 */ | 41 | #endif /* CONFIG_SPARC64 */ |
44 | 42 | ||
45 | #if defined(CONFIG_SPARC64) || defined(CONFIG_LEON_PCI) | 43 | #if defined(CONFIG_SPARC64) || defined(CONFIG_LEON_PCI) |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 314a187ed572..d1e666ef3fcc 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/pm_runtime.h> | 15 | #include <linux/pm_runtime.h> |
16 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
17 | #include <linux/pci-acpi.h> | 17 | #include <linux/pci-acpi.h> |
18 | #include <linux/pci-aspm.h> | ||
19 | #include <linux/dmar.h> | 18 | #include <linux/dmar.h> |
20 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
21 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
diff --git a/drivers/char/xillybus/xillybus_pcie.c b/drivers/char/xillybus/xillybus_pcie.c index 02c15952b103..18b0c392bc93 100644 --- a/drivers/char/xillybus/xillybus_pcie.c +++ b/drivers/char/xillybus/xillybus_pcie.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
12 | #include <linux/pci-aspm.h> | ||
13 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
14 | #include "xillybus.h" | 13 | #include "xillybus.h" |
15 | 14 | ||
diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c index dce06108c8c3..5337393d4dfe 100644 --- a/drivers/infiniband/core/rw.c +++ b/drivers/infiniband/core/rw.c | |||
@@ -583,8 +583,10 @@ void rdma_rw_ctx_destroy(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num, | |||
583 | break; | 583 | break; |
584 | } | 584 | } |
585 | 585 | ||
586 | /* P2PDMA contexts do not need to be unmapped */ | 586 | if (is_pci_p2pdma_page(sg_page(sg))) |
587 | if (!is_pci_p2pdma_page(sg_page(sg))) | 587 | pci_p2pdma_unmap_sg(qp->pd->device->dma_device, sg, |
588 | sg_cnt, dir); | ||
589 | else | ||
588 | ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); | 590 | ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); |
589 | } | 591 | } |
590 | EXPORT_SYMBOL(rdma_rw_ctx_destroy); | 592 | EXPORT_SYMBOL(rdma_rw_ctx_destroy); |
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 34cd67951aec..6c51b1bad8c4 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
15 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
16 | #include <linux/pci-aspm.h> | ||
17 | #include <linux/crc32.h> | 16 | #include <linux/crc32.h> |
18 | #include <linux/if_vlan.h> | 17 | #include <linux/if_vlan.h> |
19 | #include <linux/timecounter.h> | 18 | #include <linux/timecounter.h> |
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 0b668357db4d..57e8aea98969 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
17 | #include <linux/pci-aspm.h> | ||
18 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
19 | #include <linux/etherdevice.h> | 18 | #include <linux/etherdevice.h> |
20 | #include <linux/ethtool.h> | 19 | #include <linux/ethtool.h> |
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 0637c6752a78..a6d8e7f5fde7 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
29 | #include <linux/pm_runtime.h> | 29 | #include <linux/pm_runtime.h> |
30 | #include <linux/prefetch.h> | 30 | #include <linux/prefetch.h> |
31 | #include <linux/pci-aspm.h> | ||
32 | #include <linux/ipv6.h> | 31 | #include <linux/ipv6.h> |
33 | #include <net/ip6_checksum.h> | 32 | #include <net/ip6_checksum.h> |
34 | 33 | ||
diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c index c6156cc38940..d5ee32ce9eb3 100644 --- a/drivers/net/wireless/ath/ath5k/pci.c +++ b/drivers/net/wireless/ath/ath5k/pci.c | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | #include <linux/nl80211.h> | 19 | #include <linux/nl80211.h> |
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/pci-aspm.h> | ||
22 | #include <linux/etherdevice.h> | 21 | #include <linux/etherdevice.h> |
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
24 | #include "../ath.h" | 23 | #include "../ath.h" |
diff --git a/drivers/net/wireless/intel/iwlegacy/3945-mac.c b/drivers/net/wireless/intel/iwlegacy/3945-mac.c index b82da75a9ae3..4fbcc7fba3cc 100644 --- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/pci-aspm.h> | ||
22 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
23 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
24 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c index fa2c02881939..ffb705b18fb1 100644 --- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/pci-aspm.h> | ||
22 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
23 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
24 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index f5df5b370d78..4c308e33ee21 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c | |||
@@ -62,7 +62,6 @@ | |||
62 | * | 62 | * |
63 | *****************************************************************************/ | 63 | *****************************************************************************/ |
64 | #include <linux/pci.h> | 64 | #include <linux/pci.h> |
65 | #include <linux/pci-aspm.h> | ||
66 | #include <linux/interrupt.h> | 65 | #include <linux/interrupt.h> |
67 | #include <linux/debugfs.h> | 66 | #include <linux/debugfs.h> |
68 | #include <linux/sched.h> | 67 | #include <linux/sched.h> |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index bb970ca82517..2348b15f6bd0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -547,8 +547,10 @@ static void nvme_unmap_data(struct nvme_dev *dev, struct request *req) | |||
547 | 547 | ||
548 | WARN_ON_ONCE(!iod->nents); | 548 | WARN_ON_ONCE(!iod->nents); |
549 | 549 | ||
550 | /* P2PDMA requests do not need to be unmapped */ | 550 | if (is_pci_p2pdma_page(sg_page(iod->sg))) |
551 | if (!is_pci_p2pdma_page(sg_page(iod->sg))) | 551 | pci_p2pdma_unmap_sg(dev->dev, iod->sg, iod->nents, |
552 | rq_dma_dir(req)); | ||
553 | else | ||
552 | dma_unmap_sg(dev->dev, iod->sg, iod->nents, rq_dma_dir(req)); | 554 | dma_unmap_sg(dev->dev, iod->sg, iod->nents, rq_dma_dir(req)); |
553 | 555 | ||
554 | 556 | ||
@@ -832,8 +834,8 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, | |||
832 | goto out; | 834 | goto out; |
833 | 835 | ||
834 | if (is_pci_p2pdma_page(sg_page(iod->sg))) | 836 | if (is_pci_p2pdma_page(sg_page(iod->sg))) |
835 | nr_mapped = pci_p2pdma_map_sg(dev->dev, iod->sg, iod->nents, | 837 | nr_mapped = pci_p2pdma_map_sg_attrs(dev->dev, iod->sg, |
836 | rq_dma_dir(req)); | 838 | iod->nents, rq_dma_dir(req), DMA_ATTR_NO_WARN); |
837 | else | 839 | else |
838 | nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents, | 840 | nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents, |
839 | rq_dma_dir(req), DMA_ATTR_NO_WARN); | 841 | rq_dma_dir(req), DMA_ATTR_NO_WARN); |
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 2ab92409210a..232042722261 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig | |||
@@ -52,7 +52,7 @@ config PCI_MSI | |||
52 | If you don't know what to do here, say Y. | 52 | If you don't know what to do here, say Y. |
53 | 53 | ||
54 | config PCI_MSI_IRQ_DOMAIN | 54 | config PCI_MSI_IRQ_DOMAIN |
55 | def_bool ARC || ARM || ARM64 || X86 | 55 | def_bool ARC || ARM || ARM64 || X86 || RISCV |
56 | depends on PCI_MSI | 56 | depends on PCI_MSI |
57 | select GENERIC_MSI_IRQ_DOMAIN | 57 | select GENERIC_MSI_IRQ_DOMAIN |
58 | 58 | ||
@@ -181,7 +181,7 @@ config PCI_LABEL | |||
181 | 181 | ||
182 | config PCI_HYPERV | 182 | config PCI_HYPERV |
183 | tristate "Hyper-V PCI Frontend" | 183 | tristate "Hyper-V PCI Frontend" |
184 | depends on X86 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && X86_64 | 184 | depends on X86_64 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS |
185 | help | 185 | help |
186 | The PCI device frontend driver allows the kernel to import arbitrary | 186 | The PCI device frontend driver allows the kernel to import arbitrary |
187 | PCI devices from a PCI backend to support PCI driver domains. | 187 | PCI devices from a PCI backend to support PCI driver domains. |
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 544922f097c0..2fccb5762c76 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -336,15 +336,6 @@ static inline int pcie_cap_version(const struct pci_dev *dev) | |||
336 | return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS; | 336 | return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS; |
337 | } | 337 | } |
338 | 338 | ||
339 | static bool pcie_downstream_port(const struct pci_dev *dev) | ||
340 | { | ||
341 | int type = pci_pcie_type(dev); | ||
342 | |||
343 | return type == PCI_EXP_TYPE_ROOT_PORT || | ||
344 | type == PCI_EXP_TYPE_DOWNSTREAM || | ||
345 | type == PCI_EXP_TYPE_PCIE_BRIDGE; | ||
346 | } | ||
347 | |||
348 | bool pcie_cap_has_lnkctl(const struct pci_dev *dev) | 339 | bool pcie_cap_has_lnkctl(const struct pci_dev *dev) |
349 | { | 340 | { |
350 | int type = pci_pcie_type(dev); | 341 | int type = pci_pcie_type(dev); |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 495059d923f7..8e40b3e6da77 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -417,11 +417,9 @@ struct pci_bus *pci_bus_get(struct pci_bus *bus) | |||
417 | get_device(&bus->dev); | 417 | get_device(&bus->dev); |
418 | return bus; | 418 | return bus; |
419 | } | 419 | } |
420 | EXPORT_SYMBOL(pci_bus_get); | ||
421 | 420 | ||
422 | void pci_bus_put(struct pci_bus *bus) | 421 | void pci_bus_put(struct pci_bus *bus) |
423 | { | 422 | { |
424 | if (bus) | 423 | if (bus) |
425 | put_device(&bus->dev); | 424 | put_device(&bus->dev); |
426 | } | 425 | } |
427 | EXPORT_SYMBOL(pci_bus_put); | ||
diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index 6ea778ae4877..2926990e97eb 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig | |||
@@ -131,13 +131,29 @@ config PCI_KEYSTONE_EP | |||
131 | DesignWare core functions to implement the driver. | 131 | DesignWare core functions to implement the driver. |
132 | 132 | ||
133 | config PCI_LAYERSCAPE | 133 | config PCI_LAYERSCAPE |
134 | bool "Freescale Layerscape PCIe controller" | 134 | bool "Freescale Layerscape PCIe controller - Host mode" |
135 | depends on OF && (ARM || ARCH_LAYERSCAPE || COMPILE_TEST) | 135 | depends on OF && (ARM || ARCH_LAYERSCAPE || COMPILE_TEST) |
136 | depends on PCI_MSI_IRQ_DOMAIN | 136 | depends on PCI_MSI_IRQ_DOMAIN |
137 | select MFD_SYSCON | 137 | select MFD_SYSCON |
138 | select PCIE_DW_HOST | 138 | select PCIE_DW_HOST |
139 | help | 139 | help |
140 | Say Y here if you want PCIe controller support on Layerscape SoCs. | 140 | Say Y here if you want to enable PCIe controller support on Layerscape |
141 | SoCs to work in Host mode. | ||
142 | This controller can work either as EP or RC. The RCW[HOST_AGT_PEX] | ||
143 | determines which PCIe controller works in EP mode and which PCIe | ||
144 | controller works in RC mode. | ||
145 | |||
146 | config PCI_LAYERSCAPE_EP | ||
147 | bool "Freescale Layerscape PCIe controller - Endpoint mode" | ||
148 | depends on OF && (ARM || ARCH_LAYERSCAPE || COMPILE_TEST) | ||
149 | depends on PCI_ENDPOINT | ||
150 | select PCIE_DW_EP | ||
151 | help | ||
152 | Say Y here if you want to enable PCIe controller support on Layerscape | ||
153 | SoCs to work in Endpoint mode. | ||
154 | This controller can work either as EP or RC. The RCW[HOST_AGT_PEX] | ||
155 | determines which PCIe controller works in EP mode and which PCIe | ||
156 | controller works in RC mode. | ||
141 | 157 | ||
142 | config PCI_HISI | 158 | config PCI_HISI |
143 | depends on OF && (ARM64 || COMPILE_TEST) | 159 | depends on OF && (ARM64 || COMPILE_TEST) |
@@ -230,4 +246,16 @@ config PCIE_UNIPHIER | |||
230 | Say Y here if you want PCIe controller support on UniPhier SoCs. | 246 | Say Y here if you want PCIe controller support on UniPhier SoCs. |
231 | This driver supports LD20 and PXs3 SoCs. | 247 | This driver supports LD20 and PXs3 SoCs. |
232 | 248 | ||
249 | config PCIE_AL | ||
250 | bool "Amazon Annapurna Labs PCIe controller" | ||
251 | depends on OF && (ARM64 || COMPILE_TEST) | ||
252 | depends on PCI_MSI_IRQ_DOMAIN | ||
253 | select PCIE_DW_HOST | ||
254 | help | ||
255 | Say Y here to enable support of the Amazon's Annapurna Labs PCIe | ||
256 | controller IP on Amazon SoCs. The PCIe controller uses the DesignWare | ||
257 | core plus Annapurna Labs proprietary hardware wrappers. This is | ||
258 | required only for DT-based platforms. ACPI platforms with the | ||
259 | Annapurna Labs PCIe controller don't need to enable this. | ||
260 | |||
233 | endmenu | 261 | endmenu |
diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile index b085dfd4fab7..824fde7ae750 100644 --- a/drivers/pci/controller/dwc/Makefile +++ b/drivers/pci/controller/dwc/Makefile | |||
@@ -8,7 +8,8 @@ obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o | |||
8 | obj-$(CONFIG_PCI_IMX6) += pci-imx6.o | 8 | obj-$(CONFIG_PCI_IMX6) += pci-imx6.o |
9 | obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o | 9 | obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o |
10 | obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone.o | 10 | obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone.o |
11 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o pci-layerscape-ep.o | 11 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o |
12 | obj-$(CONFIG_PCI_LAYERSCAPE_EP) += pci-layerscape-ep.o | ||
12 | obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o | 13 | obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o |
13 | obj-$(CONFIG_PCIE_ARMADA_8K) += pcie-armada8k.o | 14 | obj-$(CONFIG_PCIE_ARMADA_8K) += pcie-armada8k.o |
14 | obj-$(CONFIG_PCIE_ARTPEC6) += pcie-artpec6.o | 15 | obj-$(CONFIG_PCIE_ARTPEC6) += pcie-artpec6.o |
diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 9b5cb5b70389..8b8efa3063f5 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c | |||
@@ -57,6 +57,7 @@ enum imx6_pcie_variants { | |||
57 | struct imx6_pcie_drvdata { | 57 | struct imx6_pcie_drvdata { |
58 | enum imx6_pcie_variants variant; | 58 | enum imx6_pcie_variants variant; |
59 | u32 flags; | 59 | u32 flags; |
60 | int dbi_length; | ||
60 | }; | 61 | }; |
61 | 62 | ||
62 | struct imx6_pcie { | 63 | struct imx6_pcie { |
@@ -1212,6 +1213,7 @@ static const struct imx6_pcie_drvdata drvdata[] = { | |||
1212 | .variant = IMX6Q, | 1213 | .variant = IMX6Q, |
1213 | .flags = IMX6_PCIE_FLAG_IMX6_PHY | | 1214 | .flags = IMX6_PCIE_FLAG_IMX6_PHY | |
1214 | IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE, | 1215 | IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE, |
1216 | .dbi_length = 0x200, | ||
1215 | }, | 1217 | }, |
1216 | [IMX6SX] = { | 1218 | [IMX6SX] = { |
1217 | .variant = IMX6SX, | 1219 | .variant = IMX6SX, |
@@ -1254,6 +1256,37 @@ static struct platform_driver imx6_pcie_driver = { | |||
1254 | .shutdown = imx6_pcie_shutdown, | 1256 | .shutdown = imx6_pcie_shutdown, |
1255 | }; | 1257 | }; |
1256 | 1258 | ||
1259 | static void imx6_pcie_quirk(struct pci_dev *dev) | ||
1260 | { | ||
1261 | struct pci_bus *bus = dev->bus; | ||
1262 | struct pcie_port *pp = bus->sysdata; | ||
1263 | |||
1264 | /* Bus parent is the PCI bridge, its parent is this platform driver */ | ||
1265 | if (!bus->dev.parent || !bus->dev.parent->parent) | ||
1266 | return; | ||
1267 | |||
1268 | /* Make sure we only quirk devices associated with this driver */ | ||
1269 | if (bus->dev.parent->parent->driver != &imx6_pcie_driver.driver) | ||
1270 | return; | ||
1271 | |||
1272 | if (bus->number == pp->root_bus_nr) { | ||
1273 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | ||
1274 | struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); | ||
1275 | |||
1276 | /* | ||
1277 | * Limit config length to avoid the kernel reading beyond | ||
1278 | * the register set and causing an abort on i.MX 6Quad | ||
1279 | */ | ||
1280 | if (imx6_pcie->drvdata->dbi_length) { | ||
1281 | dev->cfg_size = imx6_pcie->drvdata->dbi_length; | ||
1282 | dev_info(&dev->dev, "Limiting cfg_size to %d\n", | ||
1283 | dev->cfg_size); | ||
1284 | } | ||
1285 | } | ||
1286 | } | ||
1287 | DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd, | ||
1288 | PCI_CLASS_BRIDGE_PCI, 8, imx6_pcie_quirk); | ||
1289 | |||
1257 | static int __init imx6_pcie_init(void) | 1290 | static int __init imx6_pcie_init(void) |
1258 | { | 1291 | { |
1259 | #ifdef CONFIG_ARM | 1292 | #ifdef CONFIG_ARM |
diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c index be61d96cc95e..ca9aa4501e7e 100644 --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c | |||
@@ -44,6 +44,7 @@ static const struct pci_epc_features ls_pcie_epc_features = { | |||
44 | .linkup_notifier = false, | 44 | .linkup_notifier = false, |
45 | .msi_capable = true, | 45 | .msi_capable = true, |
46 | .msix_capable = false, | 46 | .msix_capable = false, |
47 | .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), | ||
47 | }; | 48 | }; |
48 | 49 | ||
49 | static const struct pci_epc_features* | 50 | static const struct pci_epc_features* |
diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c index 3ab58f0584a8..1eeda2f6371f 100644 --- a/drivers/pci/controller/dwc/pcie-al.c +++ b/drivers/pci/controller/dwc/pcie-al.c | |||
@@ -91,3 +91,368 @@ struct pci_ecam_ops al_pcie_ops = { | |||
91 | }; | 91 | }; |
92 | 92 | ||
93 | #endif /* defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS) */ | 93 | #endif /* defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS) */ |
94 | |||
95 | #ifdef CONFIG_PCIE_AL | ||
96 | |||
97 | #include <linux/of_pci.h> | ||
98 | #include "pcie-designware.h" | ||
99 | |||
100 | #define AL_PCIE_REV_ID_2 2 | ||
101 | #define AL_PCIE_REV_ID_3 3 | ||
102 | #define AL_PCIE_REV_ID_4 4 | ||
103 | |||
104 | #define AXI_BASE_OFFSET 0x0 | ||
105 | |||
106 | #define DEVICE_ID_OFFSET 0x16c | ||
107 | |||
108 | #define DEVICE_REV_ID 0x0 | ||
109 | #define DEVICE_REV_ID_DEV_ID_MASK GENMASK(31, 16) | ||
110 | |||
111 | #define DEVICE_REV_ID_DEV_ID_X4 0 | ||
112 | #define DEVICE_REV_ID_DEV_ID_X8 2 | ||
113 | #define DEVICE_REV_ID_DEV_ID_X16 4 | ||
114 | |||
115 | #define OB_CTRL_REV1_2_OFFSET 0x0040 | ||
116 | #define OB_CTRL_REV3_5_OFFSET 0x0030 | ||
117 | |||
118 | #define CFG_TARGET_BUS 0x0 | ||
119 | #define CFG_TARGET_BUS_MASK_MASK GENMASK(7, 0) | ||
120 | #define CFG_TARGET_BUS_BUSNUM_MASK GENMASK(15, 8) | ||
121 | |||
122 | #define CFG_CONTROL 0x4 | ||
123 | #define CFG_CONTROL_SUBBUS_MASK GENMASK(15, 8) | ||
124 | #define CFG_CONTROL_SEC_BUS_MASK GENMASK(23, 16) | ||
125 | |||
126 | struct al_pcie_reg_offsets { | ||
127 | unsigned int ob_ctrl; | ||
128 | }; | ||
129 | |||
130 | struct al_pcie_target_bus_cfg { | ||
131 | u8 reg_val; | ||
132 | u8 reg_mask; | ||
133 | u8 ecam_mask; | ||
134 | }; | ||
135 | |||
136 | struct al_pcie { | ||
137 | struct dw_pcie *pci; | ||
138 | void __iomem *controller_base; /* base of PCIe unit (not DW core) */ | ||
139 | struct device *dev; | ||
140 | resource_size_t ecam_size; | ||
141 | unsigned int controller_rev_id; | ||
142 | struct al_pcie_reg_offsets reg_offsets; | ||
143 | struct al_pcie_target_bus_cfg target_bus_cfg; | ||
144 | }; | ||
145 | |||
146 | #define PCIE_ECAM_DEVFN(x) (((x) & 0xff) << 12) | ||
147 | |||
148 | #define to_al_pcie(x) dev_get_drvdata((x)->dev) | ||
149 | |||
150 | static inline u32 al_pcie_controller_readl(struct al_pcie *pcie, u32 offset) | ||
151 | { | ||
152 | return readl_relaxed(pcie->controller_base + offset); | ||
153 | } | ||
154 | |||
155 | static inline void al_pcie_controller_writel(struct al_pcie *pcie, u32 offset, | ||
156 | u32 val) | ||
157 | { | ||
158 | writel_relaxed(val, pcie->controller_base + offset); | ||
159 | } | ||
160 | |||
161 | static int al_pcie_rev_id_get(struct al_pcie *pcie, unsigned int *rev_id) | ||
162 | { | ||
163 | u32 dev_rev_id_val; | ||
164 | u32 dev_id_val; | ||
165 | |||
166 | dev_rev_id_val = al_pcie_controller_readl(pcie, AXI_BASE_OFFSET + | ||
167 | DEVICE_ID_OFFSET + | ||
168 | DEVICE_REV_ID); | ||
169 | dev_id_val = FIELD_GET(DEVICE_REV_ID_DEV_ID_MASK, dev_rev_id_val); | ||
170 | |||
171 | switch (dev_id_val) { | ||
172 | case DEVICE_REV_ID_DEV_ID_X4: | ||
173 | *rev_id = AL_PCIE_REV_ID_2; | ||
174 | break; | ||
175 | case DEVICE_REV_ID_DEV_ID_X8: | ||
176 | *rev_id = AL_PCIE_REV_ID_3; | ||
177 | break; | ||
178 | case DEVICE_REV_ID_DEV_ID_X16: | ||
179 | *rev_id = AL_PCIE_REV_ID_4; | ||
180 | break; | ||
181 | default: | ||
182 | dev_err(pcie->dev, "Unsupported dev_id_val (0x%x)\n", | ||
183 | dev_id_val); | ||
184 | return -EINVAL; | ||
185 | } | ||
186 | |||
187 | dev_dbg(pcie->dev, "dev_id_val: 0x%x\n", dev_id_val); | ||
188 | |||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | static int al_pcie_reg_offsets_set(struct al_pcie *pcie) | ||
193 | { | ||
194 | switch (pcie->controller_rev_id) { | ||
195 | case AL_PCIE_REV_ID_2: | ||
196 | pcie->reg_offsets.ob_ctrl = OB_CTRL_REV1_2_OFFSET; | ||
197 | break; | ||
198 | case AL_PCIE_REV_ID_3: | ||
199 | case AL_PCIE_REV_ID_4: | ||
200 | pcie->reg_offsets.ob_ctrl = OB_CTRL_REV3_5_OFFSET; | ||
201 | break; | ||
202 | default: | ||
203 | dev_err(pcie->dev, "Unsupported controller rev_id: 0x%x\n", | ||
204 | pcie->controller_rev_id); | ||
205 | return -EINVAL; | ||
206 | } | ||
207 | |||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static inline void al_pcie_target_bus_set(struct al_pcie *pcie, | ||
212 | u8 target_bus, | ||
213 | u8 mask_target_bus) | ||
214 | { | ||
215 | u32 reg; | ||
216 | |||
217 | reg = FIELD_PREP(CFG_TARGET_BUS_MASK_MASK, mask_target_bus) | | ||
218 | FIELD_PREP(CFG_TARGET_BUS_BUSNUM_MASK, target_bus); | ||
219 | |||
220 | al_pcie_controller_writel(pcie, AXI_BASE_OFFSET + | ||
221 | pcie->reg_offsets.ob_ctrl + CFG_TARGET_BUS, | ||
222 | reg); | ||
223 | } | ||
224 | |||
225 | static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie, | ||
226 | unsigned int busnr, | ||
227 | unsigned int devfn) | ||
228 | { | ||
229 | struct al_pcie_target_bus_cfg *target_bus_cfg = &pcie->target_bus_cfg; | ||
230 | unsigned int busnr_ecam = busnr & target_bus_cfg->ecam_mask; | ||
231 | unsigned int busnr_reg = busnr & target_bus_cfg->reg_mask; | ||
232 | struct pcie_port *pp = &pcie->pci->pp; | ||
233 | void __iomem *pci_base_addr; | ||
234 | |||
235 | pci_base_addr = (void __iomem *)((uintptr_t)pp->va_cfg0_base + | ||
236 | (busnr_ecam << 20) + | ||
237 | PCIE_ECAM_DEVFN(devfn)); | ||
238 | |||
239 | if (busnr_reg != target_bus_cfg->reg_val) { | ||
240 | dev_dbg(pcie->pci->dev, "Changing target bus busnum val from 0x%x to 0x%x\n", | ||
241 | target_bus_cfg->reg_val, busnr_reg); | ||
242 | target_bus_cfg->reg_val = busnr_reg; | ||
243 | al_pcie_target_bus_set(pcie, | ||
244 | target_bus_cfg->reg_val, | ||
245 | target_bus_cfg->reg_mask); | ||
246 | } | ||
247 | |||
248 | return pci_base_addr; | ||
249 | } | ||
250 | |||
251 | static int al_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, | ||
252 | unsigned int devfn, int where, int size, | ||
253 | u32 *val) | ||
254 | { | ||
255 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | ||
256 | struct al_pcie *pcie = to_al_pcie(pci); | ||
257 | unsigned int busnr = bus->number; | ||
258 | void __iomem *pci_addr; | ||
259 | int rc; | ||
260 | |||
261 | pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn); | ||
262 | |||
263 | rc = dw_pcie_read(pci_addr + where, size, val); | ||
264 | |||
265 | dev_dbg(pci->dev, "%d-byte config read from %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n", | ||
266 | size, pci_domain_nr(bus), bus->number, | ||
267 | PCI_SLOT(devfn), PCI_FUNC(devfn), where, | ||
268 | (pci_addr + where), *val); | ||
269 | |||
270 | return rc; | ||
271 | } | ||
272 | |||
273 | static int al_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus, | ||
274 | unsigned int devfn, int where, int size, | ||
275 | u32 val) | ||
276 | { | ||
277 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | ||
278 | struct al_pcie *pcie = to_al_pcie(pci); | ||
279 | unsigned int busnr = bus->number; | ||
280 | void __iomem *pci_addr; | ||
281 | int rc; | ||
282 | |||
283 | pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn); | ||
284 | |||
285 | rc = dw_pcie_write(pci_addr + where, size, val); | ||
286 | |||
287 | dev_dbg(pci->dev, "%d-byte config write to %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n", | ||
288 | size, pci_domain_nr(bus), bus->number, | ||
289 | PCI_SLOT(devfn), PCI_FUNC(devfn), where, | ||
290 | (pci_addr + where), val); | ||
291 | |||
292 | return rc; | ||
293 | } | ||
294 | |||
295 | static void al_pcie_config_prepare(struct al_pcie *pcie) | ||
296 | { | ||
297 | struct al_pcie_target_bus_cfg *target_bus_cfg; | ||
298 | struct pcie_port *pp = &pcie->pci->pp; | ||
299 | unsigned int ecam_bus_mask; | ||
300 | u32 cfg_control_offset; | ||
301 | u8 subordinate_bus; | ||
302 | u8 secondary_bus; | ||
303 | u32 cfg_control; | ||
304 | u32 reg; | ||
305 | |||
306 | target_bus_cfg = &pcie->target_bus_cfg; | ||
307 | |||
308 | ecam_bus_mask = (pcie->ecam_size >> 20) - 1; | ||
309 | if (ecam_bus_mask > 255) { | ||
310 | dev_warn(pcie->dev, "ECAM window size is larger than 256MB. Cutting off at 256\n"); | ||
311 | ecam_bus_mask = 255; | ||
312 | } | ||
313 | |||
314 | /* This portion is taken from the transaction address */ | ||
315 | target_bus_cfg->ecam_mask = ecam_bus_mask; | ||
316 | /* This portion is taken from the cfg_target_bus reg */ | ||
317 | target_bus_cfg->reg_mask = ~target_bus_cfg->ecam_mask; | ||
318 | target_bus_cfg->reg_val = pp->busn->start & target_bus_cfg->reg_mask; | ||
319 | |||
320 | al_pcie_target_bus_set(pcie, target_bus_cfg->reg_val, | ||
321 | target_bus_cfg->reg_mask); | ||
322 | |||
323 | secondary_bus = pp->busn->start + 1; | ||
324 | subordinate_bus = pp->busn->end; | ||
325 | |||
326 | /* Set the valid values of secondary and subordinate buses */ | ||
327 | cfg_control_offset = AXI_BASE_OFFSET + pcie->reg_offsets.ob_ctrl + | ||
328 | CFG_CONTROL; | ||
329 | |||
330 | cfg_control = al_pcie_controller_readl(pcie, cfg_control_offset); | ||
331 | |||
332 | reg = cfg_control & | ||
333 | ~(CFG_CONTROL_SEC_BUS_MASK | CFG_CONTROL_SUBBUS_MASK); | ||
334 | |||
335 | reg |= FIELD_PREP(CFG_CONTROL_SUBBUS_MASK, subordinate_bus) | | ||
336 | FIELD_PREP(CFG_CONTROL_SEC_BUS_MASK, secondary_bus); | ||
337 | |||
338 | al_pcie_controller_writel(pcie, cfg_control_offset, reg); | ||
339 | } | ||
340 | |||
341 | static int al_pcie_host_init(struct pcie_port *pp) | ||
342 | { | ||
343 | struct dw_pcie *pci = to_dw_pcie_from_pp(pp); | ||
344 | struct al_pcie *pcie = to_al_pcie(pci); | ||
345 | int rc; | ||
346 | |||
347 | rc = al_pcie_rev_id_get(pcie, &pcie->controller_rev_id); | ||
348 | if (rc) | ||
349 | return rc; | ||
350 | |||
351 | rc = al_pcie_reg_offsets_set(pcie); | ||
352 | if (rc) | ||
353 | return rc; | ||
354 | |||
355 | al_pcie_config_prepare(pcie); | ||
356 | |||
357 | return 0; | ||
358 | } | ||
359 | |||
360 | static const struct dw_pcie_host_ops al_pcie_host_ops = { | ||
361 | .rd_other_conf = al_pcie_rd_other_conf, | ||
362 | .wr_other_conf = al_pcie_wr_other_conf, | ||
363 | .host_init = al_pcie_host_init, | ||
364 | }; | ||
365 | |||
366 | static int al_add_pcie_port(struct pcie_port *pp, | ||
367 | struct platform_device *pdev) | ||
368 | { | ||
369 | struct device *dev = &pdev->dev; | ||
370 | int ret; | ||
371 | |||
372 | pp->ops = &al_pcie_host_ops; | ||
373 | |||
374 | ret = dw_pcie_host_init(pp); | ||
375 | if (ret) { | ||
376 | dev_err(dev, "failed to initialize host\n"); | ||
377 | return ret; | ||
378 | } | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static const struct dw_pcie_ops dw_pcie_ops = { | ||
384 | }; | ||
385 | |||
386 | static int al_pcie_probe(struct platform_device *pdev) | ||
387 | { | ||
388 | struct device *dev = &pdev->dev; | ||
389 | struct resource *controller_res; | ||
390 | struct resource *ecam_res; | ||
391 | struct resource *dbi_res; | ||
392 | struct al_pcie *al_pcie; | ||
393 | struct dw_pcie *pci; | ||
394 | |||
395 | al_pcie = devm_kzalloc(dev, sizeof(*al_pcie), GFP_KERNEL); | ||
396 | if (!al_pcie) | ||
397 | return -ENOMEM; | ||
398 | |||
399 | pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); | ||
400 | if (!pci) | ||
401 | return -ENOMEM; | ||
402 | |||
403 | pci->dev = dev; | ||
404 | pci->ops = &dw_pcie_ops; | ||
405 | |||
406 | al_pcie->pci = pci; | ||
407 | al_pcie->dev = dev; | ||
408 | |||
409 | dbi_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); | ||
410 | pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_res); | ||
411 | if (IS_ERR(pci->dbi_base)) { | ||
412 | dev_err(dev, "couldn't remap dbi base %pR\n", dbi_res); | ||
413 | return PTR_ERR(pci->dbi_base); | ||
414 | } | ||
415 | |||
416 | ecam_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config"); | ||
417 | if (!ecam_res) { | ||
418 | dev_err(dev, "couldn't find 'config' reg in DT\n"); | ||
419 | return -ENOENT; | ||
420 | } | ||
421 | al_pcie->ecam_size = resource_size(ecam_res); | ||
422 | |||
423 | controller_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | ||
424 | "controller"); | ||
425 | al_pcie->controller_base = devm_ioremap_resource(dev, controller_res); | ||
426 | if (IS_ERR(al_pcie->controller_base)) { | ||
427 | dev_err(dev, "couldn't remap controller base %pR\n", | ||
428 | controller_res); | ||
429 | return PTR_ERR(al_pcie->controller_base); | ||
430 | } | ||
431 | |||
432 | dev_dbg(dev, "From DT: dbi_base: %pR, controller_base: %pR\n", | ||
433 | dbi_res, controller_res); | ||
434 | |||
435 | platform_set_drvdata(pdev, al_pcie); | ||
436 | |||
437 | return al_add_pcie_port(&pci->pp, pdev); | ||
438 | } | ||
439 | |||
440 | static const struct of_device_id al_pcie_of_match[] = { | ||
441 | { .compatible = "amazon,al-alpine-v2-pcie", | ||
442 | }, | ||
443 | { .compatible = "amazon,al-alpine-v3-pcie", | ||
444 | }, | ||
445 | {}, | ||
446 | }; | ||
447 | |||
448 | static struct platform_driver al_pcie_driver = { | ||
449 | .driver = { | ||
450 | .name = "al-pcie", | ||
451 | .of_match_table = al_pcie_of_match, | ||
452 | .suppress_bind_attrs = true, | ||
453 | }, | ||
454 | .probe = al_pcie_probe, | ||
455 | }; | ||
456 | builtin_platform_driver(al_pcie_driver); | ||
457 | |||
458 | #endif /* CONFIG_PCIE_AL*/ | ||
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 2bf5a35c0570..0b9a9b27175c 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c | |||
@@ -531,6 +531,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
531 | int ret; | 531 | int ret; |
532 | u32 reg; | 532 | u32 reg; |
533 | void *addr; | 533 | void *addr; |
534 | u8 hdr_type; | ||
534 | unsigned int nbars; | 535 | unsigned int nbars; |
535 | unsigned int offset; | 536 | unsigned int offset; |
536 | struct pci_epc *epc; | 537 | struct pci_epc *epc; |
@@ -595,6 +596,13 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
595 | if (ep->ops->ep_init) | 596 | if (ep->ops->ep_init) |
596 | ep->ops->ep_init(ep); | 597 | ep->ops->ep_init(ep); |
597 | 598 | ||
599 | hdr_type = dw_pcie_readb_dbi(pci, PCI_HEADER_TYPE); | ||
600 | if (hdr_type != PCI_HEADER_TYPE_NORMAL) { | ||
601 | dev_err(pci->dev, "PCIe controller is not set to EP mode (hdr_type:0x%x)!\n", | ||
602 | hdr_type); | ||
603 | return -EIO; | ||
604 | } | ||
605 | |||
598 | ret = of_property_read_u8(np, "max-functions", &epc->max_functions); | 606 | ret = of_property_read_u8(np, "max-functions", &epc->max_functions); |
599 | if (ret < 0) | 607 | if (ret < 0) |
600 | epc->max_functions = 1; | 608 | epc->max_functions = 1; |
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index f93252d0da5b..bb275b5e787a 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c | |||
@@ -323,6 +323,7 @@ int dw_pcie_host_init(struct pcie_port *pp) | |||
323 | struct pci_bus *child; | 323 | struct pci_bus *child; |
324 | struct pci_host_bridge *bridge; | 324 | struct pci_host_bridge *bridge; |
325 | struct resource *cfg_res; | 325 | struct resource *cfg_res; |
326 | u32 hdr_type; | ||
326 | int ret; | 327 | int ret; |
327 | 328 | ||
328 | raw_spin_lock_init(&pci->pp.lock); | 329 | raw_spin_lock_init(&pci->pp.lock); |
@@ -464,6 +465,21 @@ int dw_pcie_host_init(struct pcie_port *pp) | |||
464 | goto err_free_msi; | 465 | goto err_free_msi; |
465 | } | 466 | } |
466 | 467 | ||
468 | ret = dw_pcie_rd_own_conf(pp, PCI_HEADER_TYPE, 1, &hdr_type); | ||
469 | if (ret != PCIBIOS_SUCCESSFUL) { | ||
470 | dev_err(pci->dev, "Failed reading PCI_HEADER_TYPE cfg space reg (ret: 0x%x)\n", | ||
471 | ret); | ||
472 | ret = pcibios_err_to_errno(ret); | ||
473 | goto err_free_msi; | ||
474 | } | ||
475 | if (hdr_type != PCI_HEADER_TYPE_BRIDGE) { | ||
476 | dev_err(pci->dev, | ||
477 | "PCIe controller is not set to bridge type (hdr_type: 0x%x)!\n", | ||
478 | hdr_type); | ||
479 | ret = -EIO; | ||
480 | goto err_free_msi; | ||
481 | } | ||
482 | |||
467 | pp->root_bus_nr = pp->busn->start; | 483 | pp->root_bus_nr = pp->busn->start; |
468 | 484 | ||
469 | bridge->dev.parent = dev; | 485 | bridge->dev.parent = dev; |
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 7d25102c304c..0a89bfd1636e 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c | |||
@@ -423,8 +423,10 @@ void dw_pcie_setup(struct dw_pcie *pci) | |||
423 | 423 | ||
424 | 424 | ||
425 | ret = of_property_read_u32(np, "num-lanes", &lanes); | 425 | ret = of_property_read_u32(np, "num-lanes", &lanes); |
426 | if (ret) | 426 | if (ret) { |
427 | lanes = 0; | 427 | dev_dbg(pci->dev, "property num-lanes isn't found\n"); |
428 | return; | ||
429 | } | ||
428 | 430 | ||
429 | /* Set the number of lanes */ | 431 | /* Set the number of lanes */ |
430 | val = dw_pcie_readl_dbi(pci, PCIE_PORT_LINK_CONTROL); | 432 | val = dw_pcie_readl_dbi(pci, PCIE_PORT_LINK_CONTROL); |
diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 8df1914226be..c19617a912bd 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c | |||
@@ -436,7 +436,7 @@ static int kirin_pcie_host_init(struct pcie_port *pp) | |||
436 | return 0; | 436 | return 0; |
437 | } | 437 | } |
438 | 438 | ||
439 | static struct dw_pcie_ops kirin_dw_pcie_ops = { | 439 | static const struct dw_pcie_ops kirin_dw_pcie_ops = { |
440 | .read_dbi = kirin_pcie_read_dbi, | 440 | .read_dbi = kirin_pcie_read_dbi, |
441 | .write_dbi = kirin_pcie_write_dbi, | 441 | .write_dbi = kirin_pcie_write_dbi, |
442 | .link_up = kirin_pcie_link_up, | 442 | .link_up = kirin_pcie_link_up, |
diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c index c742881b5061..c8cb9c5188a4 100644 --- a/drivers/pci/controller/pci-host-common.c +++ b/drivers/pci/controller/pci-host-common.c | |||
@@ -43,9 +43,8 @@ static struct pci_config_window *gen_pci_init(struct device *dev, | |||
43 | goto err_out; | 43 | goto err_out; |
44 | } | 44 | } |
45 | 45 | ||
46 | err = devm_add_action(dev, gen_pci_unmap_cfg, cfg); | 46 | err = devm_add_action_or_reset(dev, gen_pci_unmap_cfg, cfg); |
47 | if (err) { | 47 | if (err) { |
48 | gen_pci_unmap_cfg(cfg); | ||
49 | goto err_out; | 48 | goto err_out; |
50 | } | 49 | } |
51 | return cfg; | 50 | return cfg; |
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 40b625458afa..3a56de6b2ec2 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c | |||
@@ -2510,6 +2510,48 @@ static void put_hvpcibus(struct hv_pcibus_device *hbus) | |||
2510 | complete(&hbus->remove_event); | 2510 | complete(&hbus->remove_event); |
2511 | } | 2511 | } |
2512 | 2512 | ||
2513 | #define HVPCI_DOM_MAP_SIZE (64 * 1024) | ||
2514 | static DECLARE_BITMAP(hvpci_dom_map, HVPCI_DOM_MAP_SIZE); | ||
2515 | |||
2516 | /* | ||
2517 | * PCI domain number 0 is used by emulated devices on Gen1 VMs, so define 0 | ||
2518 | * as invalid for passthrough PCI devices of this driver. | ||
2519 | */ | ||
2520 | #define HVPCI_DOM_INVALID 0 | ||
2521 | |||
2522 | /** | ||
2523 | * hv_get_dom_num() - Get a valid PCI domain number | ||
2524 | * Check if the PCI domain number is in use, and return another number if | ||
2525 | * it is in use. | ||
2526 | * | ||
2527 | * @dom: Requested domain number | ||
2528 | * | ||
2529 | * return: domain number on success, HVPCI_DOM_INVALID on failure | ||
2530 | */ | ||
2531 | static u16 hv_get_dom_num(u16 dom) | ||
2532 | { | ||
2533 | unsigned int i; | ||
2534 | |||
2535 | if (test_and_set_bit(dom, hvpci_dom_map) == 0) | ||
2536 | return dom; | ||
2537 | |||
2538 | for_each_clear_bit(i, hvpci_dom_map, HVPCI_DOM_MAP_SIZE) { | ||
2539 | if (test_and_set_bit(i, hvpci_dom_map) == 0) | ||
2540 | return i; | ||
2541 | } | ||
2542 | |||
2543 | return HVPCI_DOM_INVALID; | ||
2544 | } | ||
2545 | |||
2546 | /** | ||
2547 | * hv_put_dom_num() - Mark the PCI domain number as free | ||
2548 | * @dom: Domain number to be freed | ||
2549 | */ | ||
2550 | static void hv_put_dom_num(u16 dom) | ||
2551 | { | ||
2552 | clear_bit(dom, hvpci_dom_map); | ||
2553 | } | ||
2554 | |||
2513 | /** | 2555 | /** |
2514 | * hv_pci_probe() - New VMBus channel probe, for a root PCI bus | 2556 | * hv_pci_probe() - New VMBus channel probe, for a root PCI bus |
2515 | * @hdev: VMBus's tracking struct for this root PCI bus | 2557 | * @hdev: VMBus's tracking struct for this root PCI bus |
@@ -2521,6 +2563,7 @@ static int hv_pci_probe(struct hv_device *hdev, | |||
2521 | const struct hv_vmbus_device_id *dev_id) | 2563 | const struct hv_vmbus_device_id *dev_id) |
2522 | { | 2564 | { |
2523 | struct hv_pcibus_device *hbus; | 2565 | struct hv_pcibus_device *hbus; |
2566 | u16 dom_req, dom; | ||
2524 | int ret; | 2567 | int ret; |
2525 | 2568 | ||
2526 | /* | 2569 | /* |
@@ -2535,19 +2578,34 @@ static int hv_pci_probe(struct hv_device *hdev, | |||
2535 | hbus->state = hv_pcibus_init; | 2578 | hbus->state = hv_pcibus_init; |
2536 | 2579 | ||
2537 | /* | 2580 | /* |
2538 | * The PCI bus "domain" is what is called "segment" in ACPI and | 2581 | * The PCI bus "domain" is what is called "segment" in ACPI and other |
2539 | * other specs. Pull it from the instance ID, to get something | 2582 | * specs. Pull it from the instance ID, to get something usually |
2540 | * unique. Bytes 8 and 9 are what is used in Windows guests, so | 2583 | * unique. In rare cases of collision, we will find out another number |
2541 | * do the same thing for consistency. Note that, since this code | 2584 | * not in use. |
2542 | * only runs in a Hyper-V VM, Hyper-V can (and does) guarantee | 2585 | * |
2543 | * that (1) the only domain in use for something that looks like | 2586 | * Note that, since this code only runs in a Hyper-V VM, Hyper-V |
2544 | * a physical PCI bus (which is actually emulated by the | 2587 | * together with this guest driver can guarantee that (1) The only |
2545 | * hypervisor) is domain 0 and (2) there will be no overlap | 2588 | * domain used by Gen1 VMs for something that looks like a physical |
2546 | * between domains derived from these instance IDs in the same | 2589 | * PCI bus (which is actually emulated by the hypervisor) is domain 0. |
2547 | * VM. | 2590 | * (2) There will be no overlap between domains (after fixing possible |
2591 | * collisions) in the same VM. | ||
2548 | */ | 2592 | */ |
2549 | hbus->sysdata.domain = hdev->dev_instance.b[9] | | 2593 | dom_req = hdev->dev_instance.b[5] << 8 | hdev->dev_instance.b[4]; |
2550 | hdev->dev_instance.b[8] << 8; | 2594 | dom = hv_get_dom_num(dom_req); |
2595 | |||
2596 | if (dom == HVPCI_DOM_INVALID) { | ||
2597 | dev_err(&hdev->device, | ||
2598 | "Unable to use dom# 0x%hx or other numbers", dom_req); | ||
2599 | ret = -EINVAL; | ||
2600 | goto free_bus; | ||
2601 | } | ||
2602 | |||
2603 | if (dom != dom_req) | ||
2604 | dev_info(&hdev->device, | ||
2605 | "PCI dom# 0x%hx has collision, using 0x%hx", | ||
2606 | dom_req, dom); | ||
2607 | |||
2608 | hbus->sysdata.domain = dom; | ||
2551 | 2609 | ||
2552 | hbus->hdev = hdev; | 2610 | hbus->hdev = hdev; |
2553 | refcount_set(&hbus->remove_lock, 1); | 2611 | refcount_set(&hbus->remove_lock, 1); |
@@ -2562,7 +2620,7 @@ static int hv_pci_probe(struct hv_device *hdev, | |||
2562 | hbus->sysdata.domain); | 2620 | hbus->sysdata.domain); |
2563 | if (!hbus->wq) { | 2621 | if (!hbus->wq) { |
2564 | ret = -ENOMEM; | 2622 | ret = -ENOMEM; |
2565 | goto free_bus; | 2623 | goto free_dom; |
2566 | } | 2624 | } |
2567 | 2625 | ||
2568 | ret = vmbus_open(hdev->channel, pci_ring_size, pci_ring_size, NULL, 0, | 2626 | ret = vmbus_open(hdev->channel, pci_ring_size, pci_ring_size, NULL, 0, |
@@ -2639,6 +2697,8 @@ close: | |||
2639 | vmbus_close(hdev->channel); | 2697 | vmbus_close(hdev->channel); |
2640 | destroy_wq: | 2698 | destroy_wq: |
2641 | destroy_workqueue(hbus->wq); | 2699 | destroy_workqueue(hbus->wq); |
2700 | free_dom: | ||
2701 | hv_put_dom_num(hbus->sysdata.domain); | ||
2642 | free_bus: | 2702 | free_bus: |
2643 | free_page((unsigned long)hbus); | 2703 | free_page((unsigned long)hbus); |
2644 | return ret; | 2704 | return ret; |
@@ -2701,8 +2761,8 @@ static int hv_pci_remove(struct hv_device *hdev) | |||
2701 | /* Remove the bus from PCI's point of view. */ | 2761 | /* Remove the bus from PCI's point of view. */ |
2702 | pci_lock_rescan_remove(); | 2762 | pci_lock_rescan_remove(); |
2703 | pci_stop_root_bus(hbus->pci_bus); | 2763 | pci_stop_root_bus(hbus->pci_bus); |
2704 | pci_remove_root_bus(hbus->pci_bus); | ||
2705 | hv_pci_remove_slots(hbus); | 2764 | hv_pci_remove_slots(hbus); |
2765 | pci_remove_root_bus(hbus->pci_bus); | ||
2706 | pci_unlock_rescan_remove(); | 2766 | pci_unlock_rescan_remove(); |
2707 | hbus->state = hv_pcibus_removed; | 2767 | hbus->state = hv_pcibus_removed; |
2708 | } | 2768 | } |
@@ -2720,6 +2780,9 @@ static int hv_pci_remove(struct hv_device *hdev) | |||
2720 | put_hvpcibus(hbus); | 2780 | put_hvpcibus(hbus); |
2721 | wait_for_completion(&hbus->remove_event); | 2781 | wait_for_completion(&hbus->remove_event); |
2722 | destroy_workqueue(hbus->wq); | 2782 | destroy_workqueue(hbus->wq); |
2783 | |||
2784 | hv_put_dom_num(hbus->sysdata.domain); | ||
2785 | |||
2723 | free_page((unsigned long)hbus); | 2786 | free_page((unsigned long)hbus); |
2724 | return 0; | 2787 | return 0; |
2725 | } | 2788 | } |
@@ -2747,6 +2810,9 @@ static void __exit exit_hv_pci_drv(void) | |||
2747 | 2810 | ||
2748 | static int __init init_hv_pci_drv(void) | 2811 | static int __init init_hv_pci_drv(void) |
2749 | { | 2812 | { |
2813 | /* Set the invalid domain number's bit, so it will not be used */ | ||
2814 | set_bit(HVPCI_DOM_INVALID, hvpci_dom_map); | ||
2815 | |||
2750 | return vmbus_driver_register(&hv_pci_drv); | 2816 | return vmbus_driver_register(&hv_pci_drv); |
2751 | } | 2817 | } |
2752 | 2818 | ||
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c index 5e8caf7a4452..5c93aa14f0de 100644 --- a/drivers/pci/hotplug/ibmphp_res.c +++ b/drivers/pci/hotplug/ibmphp_res.c | |||
@@ -1941,6 +1941,7 @@ static int __init update_bridge_ranges(struct bus_node **bus) | |||
1941 | break; | 1941 | break; |
1942 | case PCI_HEADER_TYPE_BRIDGE: | 1942 | case PCI_HEADER_TYPE_BRIDGE: |
1943 | function = 0x8; | 1943 | function = 0x8; |
1944 | /* fall through */ | ||
1944 | case PCI_HEADER_TYPE_MULTIBRIDGE: | 1945 | case PCI_HEADER_TYPE_MULTIBRIDGE: |
1945 | /* We assume here that only 1 bus behind the bridge | 1946 | /* We assume here that only 1 bus behind the bridge |
1946 | TO DO: add functionality for several: | 1947 | TO DO: add functionality for several: |
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 8c51a04b8083..654c972b8ea0 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -110,9 +110,9 @@ struct controller { | |||
110 | * | 110 | * |
111 | * @OFF_STATE: slot is powered off, no subordinate devices are enumerated | 111 | * @OFF_STATE: slot is powered off, no subordinate devices are enumerated |
112 | * @BLINKINGON_STATE: slot will be powered on after the 5 second delay, | 112 | * @BLINKINGON_STATE: slot will be powered on after the 5 second delay, |
113 | * green led is blinking | 113 | * Power Indicator is blinking |
114 | * @BLINKINGOFF_STATE: slot will be powered off after the 5 second delay, | 114 | * @BLINKINGOFF_STATE: slot will be powered off after the 5 second delay, |
115 | * green led is blinking | 115 | * Power Indicator is blinking |
116 | * @POWERON_STATE: slot is currently powering on | 116 | * @POWERON_STATE: slot is currently powering on |
117 | * @POWEROFF_STATE: slot is currently powering off | 117 | * @POWEROFF_STATE: slot is currently powering off |
118 | * @ON_STATE: slot is powered on, subordinate devices have been enumerated | 118 | * @ON_STATE: slot is powered on, subordinate devices have been enumerated |
@@ -167,12 +167,11 @@ int pciehp_power_on_slot(struct controller *ctrl); | |||
167 | void pciehp_power_off_slot(struct controller *ctrl); | 167 | void pciehp_power_off_slot(struct controller *ctrl); |
168 | void pciehp_get_power_status(struct controller *ctrl, u8 *status); | 168 | void pciehp_get_power_status(struct controller *ctrl, u8 *status); |
169 | 169 | ||
170 | void pciehp_set_attention_status(struct controller *ctrl, u8 status); | 170 | #define INDICATOR_NOOP -1 /* Leave indicator unchanged */ |
171 | void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn); | ||
172 | |||
171 | void pciehp_get_latch_status(struct controller *ctrl, u8 *status); | 173 | void pciehp_get_latch_status(struct controller *ctrl, u8 *status); |
172 | int pciehp_query_power_fault(struct controller *ctrl); | 174 | int pciehp_query_power_fault(struct controller *ctrl); |
173 | void pciehp_green_led_on(struct controller *ctrl); | ||
174 | void pciehp_green_led_off(struct controller *ctrl); | ||
175 | void pciehp_green_led_blink(struct controller *ctrl); | ||
176 | bool pciehp_card_present(struct controller *ctrl); | 175 | bool pciehp_card_present(struct controller *ctrl); |
177 | bool pciehp_card_present_or_link_active(struct controller *ctrl); | 176 | bool pciehp_card_present_or_link_active(struct controller *ctrl); |
178 | int pciehp_check_link_status(struct controller *ctrl); | 177 | int pciehp_check_link_status(struct controller *ctrl); |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 6ad0d86762cb..b3122c151b80 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -95,15 +95,20 @@ static void cleanup_slot(struct controller *ctrl) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * set_attention_status - Turns the Amber LED for a slot on, off or blink | 98 | * set_attention_status - Turns the Attention Indicator on, off or blinking |
99 | */ | 99 | */ |
100 | static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) | 100 | static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) |
101 | { | 101 | { |
102 | struct controller *ctrl = to_ctrl(hotplug_slot); | 102 | struct controller *ctrl = to_ctrl(hotplug_slot); |
103 | struct pci_dev *pdev = ctrl->pcie->port; | 103 | struct pci_dev *pdev = ctrl->pcie->port; |
104 | 104 | ||
105 | if (status) | ||
106 | status <<= PCI_EXP_SLTCTL_ATTN_IND_SHIFT; | ||
107 | else | ||
108 | status = PCI_EXP_SLTCTL_ATTN_IND_OFF; | ||
109 | |||
105 | pci_config_pm_runtime_get(pdev); | 110 | pci_config_pm_runtime_get(pdev); |
106 | pciehp_set_attention_status(ctrl, status); | 111 | pciehp_set_indicators(ctrl, INDICATOR_NOOP, status); |
107 | pci_config_pm_runtime_put(pdev); | 112 | pci_config_pm_runtime_put(pdev); |
108 | return 0; | 113 | return 0; |
109 | } | 114 | } |
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 631ced0ab28a..21af7b16d7a4 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -30,7 +30,10 @@ | |||
30 | 30 | ||
31 | static void set_slot_off(struct controller *ctrl) | 31 | static void set_slot_off(struct controller *ctrl) |
32 | { | 32 | { |
33 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ | 33 | /* |
34 | * Turn off slot, turn on attention indicator, turn off power | ||
35 | * indicator | ||
36 | */ | ||
34 | if (POWER_CTRL(ctrl)) { | 37 | if (POWER_CTRL(ctrl)) { |
35 | pciehp_power_off_slot(ctrl); | 38 | pciehp_power_off_slot(ctrl); |
36 | 39 | ||
@@ -42,8 +45,8 @@ static void set_slot_off(struct controller *ctrl) | |||
42 | msleep(1000); | 45 | msleep(1000); |
43 | } | 46 | } |
44 | 47 | ||
45 | pciehp_green_led_off(ctrl); | 48 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, |
46 | pciehp_set_attention_status(ctrl, 1); | 49 | PCI_EXP_SLTCTL_ATTN_IND_ON); |
47 | } | 50 | } |
48 | 51 | ||
49 | /** | 52 | /** |
@@ -65,7 +68,8 @@ static int board_added(struct controller *ctrl) | |||
65 | return retval; | 68 | return retval; |
66 | } | 69 | } |
67 | 70 | ||
68 | pciehp_green_led_blink(ctrl); | 71 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, |
72 | INDICATOR_NOOP); | ||
69 | 73 | ||
70 | /* Check link training status */ | 74 | /* Check link training status */ |
71 | retval = pciehp_check_link_status(ctrl); | 75 | retval = pciehp_check_link_status(ctrl); |
@@ -90,8 +94,8 @@ static int board_added(struct controller *ctrl) | |||
90 | } | 94 | } |
91 | } | 95 | } |
92 | 96 | ||
93 | pciehp_green_led_on(ctrl); | 97 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, |
94 | pciehp_set_attention_status(ctrl, 0); | 98 | PCI_EXP_SLTCTL_ATTN_IND_OFF); |
95 | return 0; | 99 | return 0; |
96 | 100 | ||
97 | err_exit: | 101 | err_exit: |
@@ -100,7 +104,7 @@ err_exit: | |||
100 | } | 104 | } |
101 | 105 | ||
102 | /** | 106 | /** |
103 | * remove_board - Turns off slot and LEDs | 107 | * remove_board - Turn off slot and Power Indicator |
104 | * @ctrl: PCIe hotplug controller where board is being removed | 108 | * @ctrl: PCIe hotplug controller where board is being removed |
105 | * @safe_removal: whether the board is safely removed (versus surprise removed) | 109 | * @safe_removal: whether the board is safely removed (versus surprise removed) |
106 | */ | 110 | */ |
@@ -123,8 +127,8 @@ static void remove_board(struct controller *ctrl, bool safe_removal) | |||
123 | &ctrl->pending_events); | 127 | &ctrl->pending_events); |
124 | } | 128 | } |
125 | 129 | ||
126 | /* turn off Green LED */ | 130 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, |
127 | pciehp_green_led_off(ctrl); | 131 | INDICATOR_NOOP); |
128 | } | 132 | } |
129 | 133 | ||
130 | static int pciehp_enable_slot(struct controller *ctrl); | 134 | static int pciehp_enable_slot(struct controller *ctrl); |
@@ -171,9 +175,9 @@ void pciehp_handle_button_press(struct controller *ctrl) | |||
171 | ctrl_info(ctrl, "Slot(%s) Powering on due to button press\n", | 175 | ctrl_info(ctrl, "Slot(%s) Powering on due to button press\n", |
172 | slot_name(ctrl)); | 176 | slot_name(ctrl)); |
173 | } | 177 | } |
174 | /* blink green LED and turn off amber */ | 178 | /* blink power indicator and turn off attention */ |
175 | pciehp_green_led_blink(ctrl); | 179 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, |
176 | pciehp_set_attention_status(ctrl, 0); | 180 | PCI_EXP_SLTCTL_ATTN_IND_OFF); |
177 | schedule_delayed_work(&ctrl->button_work, 5 * HZ); | 181 | schedule_delayed_work(&ctrl->button_work, 5 * HZ); |
178 | break; | 182 | break; |
179 | case BLINKINGOFF_STATE: | 183 | case BLINKINGOFF_STATE: |
@@ -187,12 +191,13 @@ void pciehp_handle_button_press(struct controller *ctrl) | |||
187 | cancel_delayed_work(&ctrl->button_work); | 191 | cancel_delayed_work(&ctrl->button_work); |
188 | if (ctrl->state == BLINKINGOFF_STATE) { | 192 | if (ctrl->state == BLINKINGOFF_STATE) { |
189 | ctrl->state = ON_STATE; | 193 | ctrl->state = ON_STATE; |
190 | pciehp_green_led_on(ctrl); | 194 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, |
195 | PCI_EXP_SLTCTL_ATTN_IND_OFF); | ||
191 | } else { | 196 | } else { |
192 | ctrl->state = OFF_STATE; | 197 | ctrl->state = OFF_STATE; |
193 | pciehp_green_led_off(ctrl); | 198 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, |
199 | PCI_EXP_SLTCTL_ATTN_IND_OFF); | ||
194 | } | 200 | } |
195 | pciehp_set_attention_status(ctrl, 0); | ||
196 | ctrl_info(ctrl, "Slot(%s): Action canceled due to button press\n", | 201 | ctrl_info(ctrl, "Slot(%s): Action canceled due to button press\n", |
197 | slot_name(ctrl)); | 202 | slot_name(ctrl)); |
198 | break; | 203 | break; |
@@ -310,7 +315,9 @@ static int pciehp_enable_slot(struct controller *ctrl) | |||
310 | pm_runtime_get_sync(&ctrl->pcie->port->dev); | 315 | pm_runtime_get_sync(&ctrl->pcie->port->dev); |
311 | ret = __pciehp_enable_slot(ctrl); | 316 | ret = __pciehp_enable_slot(ctrl); |
312 | if (ret && ATTN_BUTTN(ctrl)) | 317 | if (ret && ATTN_BUTTN(ctrl)) |
313 | pciehp_green_led_off(ctrl); /* may be blinking */ | 318 | /* may be blinking */ |
319 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, | ||
320 | INDICATOR_NOOP); | ||
314 | pm_runtime_put(&ctrl->pcie->port->dev); | 321 | pm_runtime_put(&ctrl->pcie->port->dev); |
315 | 322 | ||
316 | mutex_lock(&ctrl->state_lock); | 323 | mutex_lock(&ctrl->state_lock); |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index bd990e3371e3..1a522c1c4177 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -418,65 +418,40 @@ int pciehp_set_raw_indicator_status(struct hotplug_slot *hotplug_slot, | |||
418 | return 0; | 418 | return 0; |
419 | } | 419 | } |
420 | 420 | ||
421 | void pciehp_set_attention_status(struct controller *ctrl, u8 value) | 421 | /** |
422 | * pciehp_set_indicators() - set attention indicator, power indicator, or both | ||
423 | * @ctrl: PCIe hotplug controller | ||
424 | * @pwr: one of: | ||
425 | * PCI_EXP_SLTCTL_PWR_IND_ON | ||
426 | * PCI_EXP_SLTCTL_PWR_IND_BLINK | ||
427 | * PCI_EXP_SLTCTL_PWR_IND_OFF | ||
428 | * @attn: one of: | ||
429 | * PCI_EXP_SLTCTL_ATTN_IND_ON | ||
430 | * PCI_EXP_SLTCTL_ATTN_IND_BLINK | ||
431 | * PCI_EXP_SLTCTL_ATTN_IND_OFF | ||
432 | * | ||
433 | * Either @pwr or @attn can also be INDICATOR_NOOP to leave that indicator | ||
434 | * unchanged. | ||
435 | */ | ||
436 | void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn) | ||
422 | { | 437 | { |
423 | u16 slot_cmd; | 438 | u16 cmd = 0, mask = 0; |
424 | 439 | ||
425 | if (!ATTN_LED(ctrl)) | 440 | if (PWR_LED(ctrl) && pwr != INDICATOR_NOOP) { |
426 | return; | 441 | cmd |= (pwr & PCI_EXP_SLTCTL_PIC); |
427 | 442 | mask |= PCI_EXP_SLTCTL_PIC; | |
428 | switch (value) { | ||
429 | case 0: /* turn off */ | ||
430 | slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_OFF; | ||
431 | break; | ||
432 | case 1: /* turn on */ | ||
433 | slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_ON; | ||
434 | break; | ||
435 | case 2: /* turn blink */ | ||
436 | slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_BLINK; | ||
437 | break; | ||
438 | default: | ||
439 | return; | ||
440 | } | 443 | } |
441 | pcie_write_cmd_nowait(ctrl, slot_cmd, PCI_EXP_SLTCTL_AIC); | ||
442 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, | ||
443 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd); | ||
444 | } | ||
445 | 444 | ||
446 | void pciehp_green_led_on(struct controller *ctrl) | 445 | if (ATTN_LED(ctrl) && attn != INDICATOR_NOOP) { |
447 | { | 446 | cmd |= (attn & PCI_EXP_SLTCTL_AIC); |
448 | if (!PWR_LED(ctrl)) | 447 | mask |= PCI_EXP_SLTCTL_AIC; |
449 | return; | 448 | } |
450 | |||
451 | pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, | ||
452 | PCI_EXP_SLTCTL_PIC); | ||
453 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, | ||
454 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, | ||
455 | PCI_EXP_SLTCTL_PWR_IND_ON); | ||
456 | } | ||
457 | |||
458 | void pciehp_green_led_off(struct controller *ctrl) | ||
459 | { | ||
460 | if (!PWR_LED(ctrl)) | ||
461 | return; | ||
462 | |||
463 | pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, | ||
464 | PCI_EXP_SLTCTL_PIC); | ||
465 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, | ||
466 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, | ||
467 | PCI_EXP_SLTCTL_PWR_IND_OFF); | ||
468 | } | ||
469 | |||
470 | void pciehp_green_led_blink(struct controller *ctrl) | ||
471 | { | ||
472 | if (!PWR_LED(ctrl)) | ||
473 | return; | ||
474 | 449 | ||
475 | pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, | 450 | if (cmd) { |
476 | PCI_EXP_SLTCTL_PIC); | 451 | pcie_write_cmd_nowait(ctrl, cmd, mask); |
477 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, | 452 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, |
478 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, | 453 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd); |
479 | PCI_EXP_SLTCTL_PWR_IND_BLINK); | 454 | } |
480 | } | 455 | } |
481 | 456 | ||
482 | int pciehp_power_on_slot(struct controller *ctrl) | 457 | int pciehp_power_on_slot(struct controller *ctrl) |
@@ -638,8 +613,8 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) | |||
638 | if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { | 613 | if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { |
639 | ctrl->power_fault_detected = 1; | 614 | ctrl->power_fault_detected = 1; |
640 | ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl)); | 615 | ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl)); |
641 | pciehp_set_attention_status(ctrl, 1); | 616 | pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, |
642 | pciehp_green_led_off(ctrl); | 617 | PCI_EXP_SLTCTL_ATTN_IND_ON); |
643 | } | 618 | } |
644 | 619 | ||
645 | /* | 620 | /* |
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 525fd3f272b3..b3f972e8cfed 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -240,6 +240,173 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id) | |||
240 | pci_dev_put(dev); | 240 | pci_dev_put(dev); |
241 | } | 241 | } |
242 | 242 | ||
243 | static ssize_t sriov_totalvfs_show(struct device *dev, | ||
244 | struct device_attribute *attr, | ||
245 | char *buf) | ||
246 | { | ||
247 | struct pci_dev *pdev = to_pci_dev(dev); | ||
248 | |||
249 | return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); | ||
250 | } | ||
251 | |||
252 | static ssize_t sriov_numvfs_show(struct device *dev, | ||
253 | struct device_attribute *attr, | ||
254 | char *buf) | ||
255 | { | ||
256 | struct pci_dev *pdev = to_pci_dev(dev); | ||
257 | |||
258 | return sprintf(buf, "%u\n", pdev->sriov->num_VFs); | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * num_vfs > 0; number of VFs to enable | ||
263 | * num_vfs = 0; disable all VFs | ||
264 | * | ||
265 | * Note: SRIOV spec does not allow partial VF | ||
266 | * disable, so it's all or none. | ||
267 | */ | ||
268 | static ssize_t sriov_numvfs_store(struct device *dev, | ||
269 | struct device_attribute *attr, | ||
270 | const char *buf, size_t count) | ||
271 | { | ||
272 | struct pci_dev *pdev = to_pci_dev(dev); | ||
273 | int ret; | ||
274 | u16 num_vfs; | ||
275 | |||
276 | ret = kstrtou16(buf, 0, &num_vfs); | ||
277 | if (ret < 0) | ||
278 | return ret; | ||
279 | |||
280 | if (num_vfs > pci_sriov_get_totalvfs(pdev)) | ||
281 | return -ERANGE; | ||
282 | |||
283 | device_lock(&pdev->dev); | ||
284 | |||
285 | if (num_vfs == pdev->sriov->num_VFs) | ||
286 | goto exit; | ||
287 | |||
288 | /* is PF driver loaded w/callback */ | ||
289 | if (!pdev->driver || !pdev->driver->sriov_configure) { | ||
290 | pci_info(pdev, "Driver does not support SRIOV configuration via sysfs\n"); | ||
291 | ret = -ENOENT; | ||
292 | goto exit; | ||
293 | } | ||
294 | |||
295 | if (num_vfs == 0) { | ||
296 | /* disable VFs */ | ||
297 | ret = pdev->driver->sriov_configure(pdev, 0); | ||
298 | goto exit; | ||
299 | } | ||
300 | |||
301 | /* enable VFs */ | ||
302 | if (pdev->sriov->num_VFs) { | ||
303 | pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", | ||
304 | pdev->sriov->num_VFs, num_vfs); | ||
305 | ret = -EBUSY; | ||
306 | goto exit; | ||
307 | } | ||
308 | |||
309 | ret = pdev->driver->sriov_configure(pdev, num_vfs); | ||
310 | if (ret < 0) | ||
311 | goto exit; | ||
312 | |||
313 | if (ret != num_vfs) | ||
314 | pci_warn(pdev, "%d VFs requested; only %d enabled\n", | ||
315 | num_vfs, ret); | ||
316 | |||
317 | exit: | ||
318 | device_unlock(&pdev->dev); | ||
319 | |||
320 | if (ret < 0) | ||
321 | return ret; | ||
322 | |||
323 | return count; | ||
324 | } | ||
325 | |||
326 | static ssize_t sriov_offset_show(struct device *dev, | ||
327 | struct device_attribute *attr, | ||
328 | char *buf) | ||
329 | { | ||
330 | struct pci_dev *pdev = to_pci_dev(dev); | ||
331 | |||
332 | return sprintf(buf, "%u\n", pdev->sriov->offset); | ||
333 | } | ||
334 | |||
335 | static ssize_t sriov_stride_show(struct device *dev, | ||
336 | struct device_attribute *attr, | ||
337 | char *buf) | ||
338 | { | ||
339 | struct pci_dev *pdev = to_pci_dev(dev); | ||
340 | |||
341 | return sprintf(buf, "%u\n", pdev->sriov->stride); | ||
342 | } | ||
343 | |||
344 | static ssize_t sriov_vf_device_show(struct device *dev, | ||
345 | struct device_attribute *attr, | ||
346 | char *buf) | ||
347 | { | ||
348 | struct pci_dev *pdev = to_pci_dev(dev); | ||
349 | |||
350 | return sprintf(buf, "%x\n", pdev->sriov->vf_device); | ||
351 | } | ||
352 | |||
353 | static ssize_t sriov_drivers_autoprobe_show(struct device *dev, | ||
354 | struct device_attribute *attr, | ||
355 | char *buf) | ||
356 | { | ||
357 | struct pci_dev *pdev = to_pci_dev(dev); | ||
358 | |||
359 | return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe); | ||
360 | } | ||
361 | |||
362 | static ssize_t sriov_drivers_autoprobe_store(struct device *dev, | ||
363 | struct device_attribute *attr, | ||
364 | const char *buf, size_t count) | ||
365 | { | ||
366 | struct pci_dev *pdev = to_pci_dev(dev); | ||
367 | bool drivers_autoprobe; | ||
368 | |||
369 | if (kstrtobool(buf, &drivers_autoprobe) < 0) | ||
370 | return -EINVAL; | ||
371 | |||
372 | pdev->sriov->drivers_autoprobe = drivers_autoprobe; | ||
373 | |||
374 | return count; | ||
375 | } | ||
376 | |||
377 | static DEVICE_ATTR_RO(sriov_totalvfs); | ||
378 | static DEVICE_ATTR_RW(sriov_numvfs); | ||
379 | static DEVICE_ATTR_RO(sriov_offset); | ||
380 | static DEVICE_ATTR_RO(sriov_stride); | ||
381 | static DEVICE_ATTR_RO(sriov_vf_device); | ||
382 | static DEVICE_ATTR_RW(sriov_drivers_autoprobe); | ||
383 | |||
384 | static struct attribute *sriov_dev_attrs[] = { | ||
385 | &dev_attr_sriov_totalvfs.attr, | ||
386 | &dev_attr_sriov_numvfs.attr, | ||
387 | &dev_attr_sriov_offset.attr, | ||
388 | &dev_attr_sriov_stride.attr, | ||
389 | &dev_attr_sriov_vf_device.attr, | ||
390 | &dev_attr_sriov_drivers_autoprobe.attr, | ||
391 | NULL, | ||
392 | }; | ||
393 | |||
394 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, | ||
395 | struct attribute *a, int n) | ||
396 | { | ||
397 | struct device *dev = kobj_to_dev(kobj); | ||
398 | |||
399 | if (!dev_is_pf(dev)) | ||
400 | return 0; | ||
401 | |||
402 | return a->mode; | ||
403 | } | ||
404 | |||
405 | const struct attribute_group sriov_dev_attr_group = { | ||
406 | .attrs = sriov_dev_attrs, | ||
407 | .is_visible = sriov_attrs_are_visible, | ||
408 | }; | ||
409 | |||
243 | int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) | 410 | int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) |
244 | { | 411 | { |
245 | return 0; | 412 | return 0; |
@@ -557,8 +724,8 @@ static void sriov_restore_state(struct pci_dev *dev) | |||
557 | ctrl |= iov->ctrl & PCI_SRIOV_CTRL_ARI; | 724 | ctrl |= iov->ctrl & PCI_SRIOV_CTRL_ARI; |
558 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, ctrl); | 725 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, ctrl); |
559 | 726 | ||
560 | for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) | 727 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) |
561 | pci_update_resource(dev, i); | 728 | pci_update_resource(dev, i + PCI_IOV_RESOURCES); |
562 | 729 | ||
563 | pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); | 730 | pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); |
564 | pci_iov_set_numvfs(dev, iov->num_VFs); | 731 | pci_iov_set_numvfs(dev, iov->num_VFs); |
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 234476226529..0608aae72ccc 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c | |||
@@ -18,13 +18,32 @@ | |||
18 | #include <linux/percpu-refcount.h> | 18 | #include <linux/percpu-refcount.h> |
19 | #include <linux/random.h> | 19 | #include <linux/random.h> |
20 | #include <linux/seq_buf.h> | 20 | #include <linux/seq_buf.h> |
21 | #include <linux/iommu.h> | 21 | #include <linux/xarray.h> |
22 | |||
23 | enum pci_p2pdma_map_type { | ||
24 | PCI_P2PDMA_MAP_UNKNOWN = 0, | ||
25 | PCI_P2PDMA_MAP_NOT_SUPPORTED, | ||
26 | PCI_P2PDMA_MAP_BUS_ADDR, | ||
27 | PCI_P2PDMA_MAP_THRU_HOST_BRIDGE, | ||
28 | }; | ||
22 | 29 | ||
23 | struct pci_p2pdma { | 30 | struct pci_p2pdma { |
24 | struct gen_pool *pool; | 31 | struct gen_pool *pool; |
25 | bool p2pmem_published; | 32 | bool p2pmem_published; |
33 | struct xarray map_types; | ||
26 | }; | 34 | }; |
27 | 35 | ||
36 | struct pci_p2pdma_pagemap { | ||
37 | struct dev_pagemap pgmap; | ||
38 | struct pci_dev *provider; | ||
39 | u64 bus_offset; | ||
40 | }; | ||
41 | |||
42 | static struct pci_p2pdma_pagemap *to_p2p_pgmap(struct dev_pagemap *pgmap) | ||
43 | { | ||
44 | return container_of(pgmap, struct pci_p2pdma_pagemap, pgmap); | ||
45 | } | ||
46 | |||
28 | static ssize_t size_show(struct device *dev, struct device_attribute *attr, | 47 | static ssize_t size_show(struct device *dev, struct device_attribute *attr, |
29 | char *buf) | 48 | char *buf) |
30 | { | 49 | { |
@@ -87,6 +106,7 @@ static void pci_p2pdma_release(void *data) | |||
87 | 106 | ||
88 | gen_pool_destroy(p2pdma->pool); | 107 | gen_pool_destroy(p2pdma->pool); |
89 | sysfs_remove_group(&pdev->dev.kobj, &p2pmem_group); | 108 | sysfs_remove_group(&pdev->dev.kobj, &p2pmem_group); |
109 | xa_destroy(&p2pdma->map_types); | ||
90 | } | 110 | } |
91 | 111 | ||
92 | static int pci_p2pdma_setup(struct pci_dev *pdev) | 112 | static int pci_p2pdma_setup(struct pci_dev *pdev) |
@@ -98,6 +118,8 @@ static int pci_p2pdma_setup(struct pci_dev *pdev) | |||
98 | if (!p2p) | 118 | if (!p2p) |
99 | return -ENOMEM; | 119 | return -ENOMEM; |
100 | 120 | ||
121 | xa_init(&p2p->map_types); | ||
122 | |||
101 | p2p->pool = gen_pool_create(PAGE_SHIFT, dev_to_node(&pdev->dev)); | 123 | p2p->pool = gen_pool_create(PAGE_SHIFT, dev_to_node(&pdev->dev)); |
102 | if (!p2p->pool) | 124 | if (!p2p->pool) |
103 | goto out; | 125 | goto out; |
@@ -135,6 +157,7 @@ out: | |||
135 | int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, | 157 | int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, |
136 | u64 offset) | 158 | u64 offset) |
137 | { | 159 | { |
160 | struct pci_p2pdma_pagemap *p2p_pgmap; | ||
138 | struct dev_pagemap *pgmap; | 161 | struct dev_pagemap *pgmap; |
139 | void *addr; | 162 | void *addr; |
140 | int error; | 163 | int error; |
@@ -157,14 +180,18 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, | |||
157 | return error; | 180 | return error; |
158 | } | 181 | } |
159 | 182 | ||
160 | pgmap = devm_kzalloc(&pdev->dev, sizeof(*pgmap), GFP_KERNEL); | 183 | p2p_pgmap = devm_kzalloc(&pdev->dev, sizeof(*p2p_pgmap), GFP_KERNEL); |
161 | if (!pgmap) | 184 | if (!p2p_pgmap) |
162 | return -ENOMEM; | 185 | return -ENOMEM; |
186 | |||
187 | pgmap = &p2p_pgmap->pgmap; | ||
163 | pgmap->res.start = pci_resource_start(pdev, bar) + offset; | 188 | pgmap->res.start = pci_resource_start(pdev, bar) + offset; |
164 | pgmap->res.end = pgmap->res.start + size - 1; | 189 | pgmap->res.end = pgmap->res.start + size - 1; |
165 | pgmap->res.flags = pci_resource_flags(pdev, bar); | 190 | pgmap->res.flags = pci_resource_flags(pdev, bar); |
166 | pgmap->type = MEMORY_DEVICE_PCI_P2PDMA; | 191 | pgmap->type = MEMORY_DEVICE_PCI_P2PDMA; |
167 | pgmap->pci_p2pdma_bus_offset = pci_bus_address(pdev, bar) - | 192 | |
193 | p2p_pgmap->provider = pdev; | ||
194 | p2p_pgmap->bus_offset = pci_bus_address(pdev, bar) - | ||
168 | pci_resource_start(pdev, bar); | 195 | pci_resource_start(pdev, bar); |
169 | 196 | ||
170 | addr = devm_memremap_pages(&pdev->dev, pgmap); | 197 | addr = devm_memremap_pages(&pdev->dev, pgmap); |
@@ -246,19 +273,32 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev) | |||
246 | seq_buf_printf(buf, "%s;", pci_name(pdev)); | 273 | seq_buf_printf(buf, "%s;", pci_name(pdev)); |
247 | } | 274 | } |
248 | 275 | ||
249 | /* | 276 | static const struct pci_p2pdma_whitelist_entry { |
250 | * If we can't find a common upstream bridge take a look at the root | 277 | unsigned short vendor; |
251 | * complex and compare it to a whitelist of known good hardware. | 278 | unsigned short device; |
252 | */ | 279 | enum { |
253 | static bool root_complex_whitelist(struct pci_dev *dev) | 280 | REQ_SAME_HOST_BRIDGE = 1 << 0, |
281 | } flags; | ||
282 | } pci_p2pdma_whitelist[] = { | ||
283 | /* AMD ZEN */ | ||
284 | {PCI_VENDOR_ID_AMD, 0x1450, 0}, | ||
285 | |||
286 | /* Intel Xeon E5/Core i7 */ | ||
287 | {PCI_VENDOR_ID_INTEL, 0x3c00, REQ_SAME_HOST_BRIDGE}, | ||
288 | {PCI_VENDOR_ID_INTEL, 0x3c01, REQ_SAME_HOST_BRIDGE}, | ||
289 | /* Intel Xeon E7 v3/Xeon E5 v3/Core i7 */ | ||
290 | {PCI_VENDOR_ID_INTEL, 0x2f00, REQ_SAME_HOST_BRIDGE}, | ||
291 | {PCI_VENDOR_ID_INTEL, 0x2f01, REQ_SAME_HOST_BRIDGE}, | ||
292 | {} | ||
293 | }; | ||
294 | |||
295 | static bool __host_bridge_whitelist(struct pci_host_bridge *host, | ||
296 | bool same_host_bridge) | ||
254 | { | 297 | { |
255 | struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); | ||
256 | struct pci_dev *root = pci_get_slot(host->bus, PCI_DEVFN(0, 0)); | 298 | struct pci_dev *root = pci_get_slot(host->bus, PCI_DEVFN(0, 0)); |
299 | const struct pci_p2pdma_whitelist_entry *entry; | ||
257 | unsigned short vendor, device; | 300 | unsigned short vendor, device; |
258 | 301 | ||
259 | if (iommu_present(dev->dev.bus)) | ||
260 | return false; | ||
261 | |||
262 | if (!root) | 302 | if (!root) |
263 | return false; | 303 | return false; |
264 | 304 | ||
@@ -266,65 +306,49 @@ static bool root_complex_whitelist(struct pci_dev *dev) | |||
266 | device = root->device; | 306 | device = root->device; |
267 | pci_dev_put(root); | 307 | pci_dev_put(root); |
268 | 308 | ||
269 | /* AMD ZEN host bridges can do peer to peer */ | 309 | for (entry = pci_p2pdma_whitelist; entry->vendor; entry++) { |
270 | if (vendor == PCI_VENDOR_ID_AMD && device == 0x1450) | 310 | if (vendor != entry->vendor || device != entry->device) |
311 | continue; | ||
312 | if (entry->flags & REQ_SAME_HOST_BRIDGE && !same_host_bridge) | ||
313 | return false; | ||
314 | |||
271 | return true; | 315 | return true; |
316 | } | ||
272 | 317 | ||
273 | return false; | 318 | return false; |
274 | } | 319 | } |
275 | 320 | ||
276 | /* | 321 | /* |
277 | * Find the distance through the nearest common upstream bridge between | 322 | * If we can't find a common upstream bridge take a look at the root |
278 | * two PCI devices. | 323 | * complex and compare it to a whitelist of known good hardware. |
279 | * | ||
280 | * If the two devices are the same device then 0 will be returned. | ||
281 | * | ||
282 | * If there are two virtual functions of the same device behind the same | ||
283 | * bridge port then 2 will be returned (one step down to the PCIe switch, | ||
284 | * then one step back to the same device). | ||
285 | * | ||
286 | * In the case where two devices are connected to the same PCIe switch, the | ||
287 | * value 4 will be returned. This corresponds to the following PCI tree: | ||
288 | * | ||
289 | * -+ Root Port | ||
290 | * \+ Switch Upstream Port | ||
291 | * +-+ Switch Downstream Port | ||
292 | * + \- Device A | ||
293 | * \-+ Switch Downstream Port | ||
294 | * \- Device B | ||
295 | * | ||
296 | * The distance is 4 because we traverse from Device A through the downstream | ||
297 | * port of the switch, to the common upstream port, back up to the second | ||
298 | * downstream port and then to Device B. | ||
299 | * | ||
300 | * Any two devices that don't have a common upstream bridge will return -1. | ||
301 | * In this way devices on separate PCIe root ports will be rejected, which | ||
302 | * is what we want for peer-to-peer seeing each PCIe root port defines a | ||
303 | * separate hierarchy domain and there's no way to determine whether the root | ||
304 | * complex supports forwarding between them. | ||
305 | * | ||
306 | * In the case where two devices are connected to different PCIe switches, | ||
307 | * this function will still return a positive distance as long as both | ||
308 | * switches eventually have a common upstream bridge. Note this covers | ||
309 | * the case of using multiple PCIe switches to achieve a desired level of | ||
310 | * fan-out from a root port. The exact distance will be a function of the | ||
311 | * number of switches between Device A and Device B. | ||
312 | * | ||
313 | * If a bridge which has any ACS redirection bits set is in the path | ||
314 | * then this functions will return -2. This is so we reject any | ||
315 | * cases where the TLPs are forwarded up into the root complex. | ||
316 | * In this case, a list of all infringing bridge addresses will be | ||
317 | * populated in acs_list (assuming it's non-null) for printk purposes. | ||
318 | */ | 324 | */ |
319 | static int upstream_bridge_distance(struct pci_dev *provider, | 325 | static bool host_bridge_whitelist(struct pci_dev *a, struct pci_dev *b) |
320 | struct pci_dev *client, | 326 | { |
321 | struct seq_buf *acs_list) | 327 | struct pci_host_bridge *host_a = pci_find_host_bridge(a->bus); |
328 | struct pci_host_bridge *host_b = pci_find_host_bridge(b->bus); | ||
329 | |||
330 | if (host_a == host_b) | ||
331 | return __host_bridge_whitelist(host_a, true); | ||
332 | |||
333 | if (__host_bridge_whitelist(host_a, false) && | ||
334 | __host_bridge_whitelist(host_b, false)) | ||
335 | return true; | ||
336 | |||
337 | return false; | ||
338 | } | ||
339 | |||
340 | static enum pci_p2pdma_map_type | ||
341 | __upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client, | ||
342 | int *dist, bool *acs_redirects, struct seq_buf *acs_list) | ||
322 | { | 343 | { |
323 | struct pci_dev *a = provider, *b = client, *bb; | 344 | struct pci_dev *a = provider, *b = client, *bb; |
324 | int dist_a = 0; | 345 | int dist_a = 0; |
325 | int dist_b = 0; | 346 | int dist_b = 0; |
326 | int acs_cnt = 0; | 347 | int acs_cnt = 0; |
327 | 348 | ||
349 | if (acs_redirects) | ||
350 | *acs_redirects = false; | ||
351 | |||
328 | /* | 352 | /* |
329 | * Note, we don't need to take references to devices returned by | 353 | * Note, we don't need to take references to devices returned by |
330 | * pci_upstream_bridge() seeing we hold a reference to a child | 354 | * pci_upstream_bridge() seeing we hold a reference to a child |
@@ -353,15 +377,10 @@ static int upstream_bridge_distance(struct pci_dev *provider, | |||
353 | dist_a++; | 377 | dist_a++; |
354 | } | 378 | } |
355 | 379 | ||
356 | /* | 380 | if (dist) |
357 | * Allow the connection if both devices are on a whitelisted root | 381 | *dist = dist_a + dist_b; |
358 | * complex, but add an arbitrary large value to the distance. | ||
359 | */ | ||
360 | if (root_complex_whitelist(provider) && | ||
361 | root_complex_whitelist(client)) | ||
362 | return 0x1000 + dist_a + dist_b; | ||
363 | 382 | ||
364 | return -1; | 383 | return PCI_P2PDMA_MAP_THRU_HOST_BRIDGE; |
365 | 384 | ||
366 | check_b_path_acs: | 385 | check_b_path_acs: |
367 | bb = b; | 386 | bb = b; |
@@ -378,33 +397,110 @@ check_b_path_acs: | |||
378 | bb = pci_upstream_bridge(bb); | 397 | bb = pci_upstream_bridge(bb); |
379 | } | 398 | } |
380 | 399 | ||
381 | if (acs_cnt) | 400 | if (dist) |
382 | return -2; | 401 | *dist = dist_a + dist_b; |
402 | |||
403 | if (acs_cnt) { | ||
404 | if (acs_redirects) | ||
405 | *acs_redirects = true; | ||
406 | |||
407 | return PCI_P2PDMA_MAP_THRU_HOST_BRIDGE; | ||
408 | } | ||
409 | |||
410 | return PCI_P2PDMA_MAP_BUS_ADDR; | ||
411 | } | ||
412 | |||
413 | static unsigned long map_types_idx(struct pci_dev *client) | ||
414 | { | ||
415 | return (pci_domain_nr(client->bus) << 16) | | ||
416 | (client->bus->number << 8) | client->devfn; | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | * Find the distance through the nearest common upstream bridge between | ||
421 | * two PCI devices. | ||
422 | * | ||
423 | * If the two devices are the same device then 0 will be returned. | ||
424 | * | ||
425 | * If there are two virtual functions of the same device behind the same | ||
426 | * bridge port then 2 will be returned (one step down to the PCIe switch, | ||
427 | * then one step back to the same device). | ||
428 | * | ||
429 | * In the case where two devices are connected to the same PCIe switch, the | ||
430 | * value 4 will be returned. This corresponds to the following PCI tree: | ||
431 | * | ||
432 | * -+ Root Port | ||
433 | * \+ Switch Upstream Port | ||
434 | * +-+ Switch Downstream Port | ||
435 | * + \- Device A | ||
436 | * \-+ Switch Downstream Port | ||
437 | * \- Device B | ||
438 | * | ||
439 | * The distance is 4 because we traverse from Device A through the downstream | ||
440 | * port of the switch, to the common upstream port, back up to the second | ||
441 | * downstream port and then to Device B. | ||
442 | * | ||
443 | * Any two devices that cannot communicate using p2pdma will return | ||
444 | * PCI_P2PDMA_MAP_NOT_SUPPORTED. | ||
445 | * | ||
446 | * Any two devices that have a data path that goes through the host bridge | ||
447 | * will consult a whitelist. If the host bridges are on the whitelist, | ||
448 | * this function will return PCI_P2PDMA_MAP_THRU_HOST_BRIDGE. | ||
449 | * | ||
450 | * If either bridge is not on the whitelist this function returns | ||
451 | * PCI_P2PDMA_MAP_NOT_SUPPORTED. | ||
452 | * | ||
453 | * If a bridge which has any ACS redirection bits set is in the path, | ||
454 | * acs_redirects will be set to true. In this case, a list of all infringing | ||
455 | * bridge addresses will be populated in acs_list (assuming it's non-null) | ||
456 | * for printk purposes. | ||
457 | */ | ||
458 | static enum pci_p2pdma_map_type | ||
459 | upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client, | ||
460 | int *dist, bool *acs_redirects, struct seq_buf *acs_list) | ||
461 | { | ||
462 | enum pci_p2pdma_map_type map_type; | ||
463 | |||
464 | map_type = __upstream_bridge_distance(provider, client, dist, | ||
465 | acs_redirects, acs_list); | ||
466 | |||
467 | if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) { | ||
468 | if (!host_bridge_whitelist(provider, client)) | ||
469 | map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED; | ||
470 | } | ||
471 | |||
472 | if (provider->p2pdma) | ||
473 | xa_store(&provider->p2pdma->map_types, map_types_idx(client), | ||
474 | xa_mk_value(map_type), GFP_KERNEL); | ||
383 | 475 | ||
384 | return dist_a + dist_b; | 476 | return map_type; |
385 | } | 477 | } |
386 | 478 | ||
387 | static int upstream_bridge_distance_warn(struct pci_dev *provider, | 479 | static enum pci_p2pdma_map_type |
388 | struct pci_dev *client) | 480 | upstream_bridge_distance_warn(struct pci_dev *provider, struct pci_dev *client, |
481 | int *dist) | ||
389 | { | 482 | { |
390 | struct seq_buf acs_list; | 483 | struct seq_buf acs_list; |
484 | bool acs_redirects; | ||
391 | int ret; | 485 | int ret; |
392 | 486 | ||
393 | seq_buf_init(&acs_list, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); | 487 | seq_buf_init(&acs_list, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); |
394 | if (!acs_list.buffer) | 488 | if (!acs_list.buffer) |
395 | return -ENOMEM; | 489 | return -ENOMEM; |
396 | 490 | ||
397 | ret = upstream_bridge_distance(provider, client, &acs_list); | 491 | ret = upstream_bridge_distance(provider, client, dist, &acs_redirects, |
398 | if (ret == -2) { | 492 | &acs_list); |
399 | pci_warn(client, "cannot be used for peer-to-peer DMA as ACS redirect is set between the client and provider (%s)\n", | 493 | if (acs_redirects) { |
494 | pci_warn(client, "ACS redirect is set between the client and provider (%s)\n", | ||
400 | pci_name(provider)); | 495 | pci_name(provider)); |
401 | /* Drop final semicolon */ | 496 | /* Drop final semicolon */ |
402 | acs_list.buffer[acs_list.len-1] = 0; | 497 | acs_list.buffer[acs_list.len-1] = 0; |
403 | pci_warn(client, "to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n", | 498 | pci_warn(client, "to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n", |
404 | acs_list.buffer); | 499 | acs_list.buffer); |
500 | } | ||
405 | 501 | ||
406 | } else if (ret < 0) { | 502 | if (ret == PCI_P2PDMA_MAP_NOT_SUPPORTED) { |
407 | pci_warn(client, "cannot be used for peer-to-peer DMA as the client and provider (%s) do not share an upstream bridge\n", | 503 | pci_warn(client, "cannot be used for peer-to-peer DMA as the client and provider (%s) do not share an upstream bridge or whitelisted host bridge\n", |
408 | pci_name(provider)); | 504 | pci_name(provider)); |
409 | } | 505 | } |
410 | 506 | ||
@@ -421,22 +517,22 @@ static int upstream_bridge_distance_warn(struct pci_dev *provider, | |||
421 | * @num_clients: number of clients in the array | 517 | * @num_clients: number of clients in the array |
422 | * @verbose: if true, print warnings for devices when we return -1 | 518 | * @verbose: if true, print warnings for devices when we return -1 |
423 | * | 519 | * |
424 | * Returns -1 if any of the clients are not compatible (behind the same | 520 | * Returns -1 if any of the clients are not compatible, otherwise returns a |
425 | * root port as the provider), otherwise returns a positive number where | 521 | * positive number where a lower number is the preferable choice. (If there's |
426 | * a lower number is the preferable choice. (If there's one client | 522 | * one client that's the same as the provider it will return 0, which is best |
427 | * that's the same as the provider it will return 0, which is best choice). | 523 | * choice). |
428 | * | 524 | * |
429 | * For now, "compatible" means the provider and the clients are all behind | 525 | * "compatible" means the provider and the clients are either all behind |
430 | * the same PCI root port. This cuts out cases that may work but is safest | 526 | * the same PCI root port or the host bridges connected to each of the devices |
431 | * for the user. Future work can expand this to white-list root complexes that | 527 | * are listed in the 'pci_p2pdma_whitelist'. |
432 | * can safely forward between each ports. | ||
433 | */ | 528 | */ |
434 | int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients, | 529 | int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients, |
435 | int num_clients, bool verbose) | 530 | int num_clients, bool verbose) |
436 | { | 531 | { |
437 | bool not_supported = false; | 532 | bool not_supported = false; |
438 | struct pci_dev *pci_client; | 533 | struct pci_dev *pci_client; |
439 | int distance = 0; | 534 | int total_dist = 0; |
535 | int distance; | ||
440 | int i, ret; | 536 | int i, ret; |
441 | 537 | ||
442 | if (num_clients == 0) | 538 | if (num_clients == 0) |
@@ -461,26 +557,26 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients, | |||
461 | 557 | ||
462 | if (verbose) | 558 | if (verbose) |
463 | ret = upstream_bridge_distance_warn(provider, | 559 | ret = upstream_bridge_distance_warn(provider, |
464 | pci_client); | 560 | pci_client, &distance); |
465 | else | 561 | else |
466 | ret = upstream_bridge_distance(provider, pci_client, | 562 | ret = upstream_bridge_distance(provider, pci_client, |
467 | NULL); | 563 | &distance, NULL, NULL); |
468 | 564 | ||
469 | pci_dev_put(pci_client); | 565 | pci_dev_put(pci_client); |
470 | 566 | ||
471 | if (ret < 0) | 567 | if (ret == PCI_P2PDMA_MAP_NOT_SUPPORTED) |
472 | not_supported = true; | 568 | not_supported = true; |
473 | 569 | ||
474 | if (not_supported && !verbose) | 570 | if (not_supported && !verbose) |
475 | break; | 571 | break; |
476 | 572 | ||
477 | distance += ret; | 573 | total_dist += distance; |
478 | } | 574 | } |
479 | 575 | ||
480 | if (not_supported) | 576 | if (not_supported) |
481 | return -1; | 577 | return -1; |
482 | 578 | ||
483 | return distance; | 579 | return total_dist; |
484 | } | 580 | } |
485 | EXPORT_SYMBOL_GPL(pci_p2pdma_distance_many); | 581 | EXPORT_SYMBOL_GPL(pci_p2pdma_distance_many); |
486 | 582 | ||
@@ -706,21 +802,19 @@ void pci_p2pmem_publish(struct pci_dev *pdev, bool publish) | |||
706 | } | 802 | } |
707 | EXPORT_SYMBOL_GPL(pci_p2pmem_publish); | 803 | EXPORT_SYMBOL_GPL(pci_p2pmem_publish); |
708 | 804 | ||
709 | /** | 805 | static enum pci_p2pdma_map_type pci_p2pdma_map_type(struct pci_dev *provider, |
710 | * pci_p2pdma_map_sg - map a PCI peer-to-peer scatterlist for DMA | 806 | struct pci_dev *client) |
711 | * @dev: device doing the DMA request | 807 | { |
712 | * @sg: scatter list to map | 808 | if (!provider->p2pdma) |
713 | * @nents: elements in the scatterlist | 809 | return PCI_P2PDMA_MAP_NOT_SUPPORTED; |
714 | * @dir: DMA direction | 810 | |
715 | * | 811 | return xa_to_value(xa_load(&provider->p2pdma->map_types, |
716 | * Scatterlists mapped with this function should not be unmapped in any way. | 812 | map_types_idx(client))); |
717 | * | 813 | } |
718 | * Returns the number of SG entries mapped or 0 on error. | 814 | |
719 | */ | 815 | static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap, |
720 | int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | 816 | struct device *dev, struct scatterlist *sg, int nents) |
721 | enum dma_data_direction dir) | ||
722 | { | 817 | { |
723 | struct dev_pagemap *pgmap; | ||
724 | struct scatterlist *s; | 818 | struct scatterlist *s; |
725 | phys_addr_t paddr; | 819 | phys_addr_t paddr; |
726 | int i; | 820 | int i; |
@@ -736,16 +830,80 @@ int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
736 | return 0; | 830 | return 0; |
737 | 831 | ||
738 | for_each_sg(sg, s, nents, i) { | 832 | for_each_sg(sg, s, nents, i) { |
739 | pgmap = sg_page(s)->pgmap; | ||
740 | paddr = sg_phys(s); | 833 | paddr = sg_phys(s); |
741 | 834 | ||
742 | s->dma_address = paddr - pgmap->pci_p2pdma_bus_offset; | 835 | s->dma_address = paddr - p2p_pgmap->bus_offset; |
743 | sg_dma_len(s) = s->length; | 836 | sg_dma_len(s) = s->length; |
744 | } | 837 | } |
745 | 838 | ||
746 | return nents; | 839 | return nents; |
747 | } | 840 | } |
748 | EXPORT_SYMBOL_GPL(pci_p2pdma_map_sg); | 841 | |
842 | /** | ||
843 | * pci_p2pdma_map_sg - map a PCI peer-to-peer scatterlist for DMA | ||
844 | * @dev: device doing the DMA request | ||
845 | * @sg: scatter list to map | ||
846 | * @nents: elements in the scatterlist | ||
847 | * @dir: DMA direction | ||
848 | * @attrs: DMA attributes passed to dma_map_sg() (if called) | ||
849 | * | ||
850 | * Scatterlists mapped with this function should be unmapped using | ||
851 | * pci_p2pdma_unmap_sg_attrs(). | ||
852 | * | ||
853 | * Returns the number of SG entries mapped or 0 on error. | ||
854 | */ | ||
855 | int pci_p2pdma_map_sg_attrs(struct device *dev, struct scatterlist *sg, | ||
856 | int nents, enum dma_data_direction dir, unsigned long attrs) | ||
857 | { | ||
858 | struct pci_p2pdma_pagemap *p2p_pgmap = | ||
859 | to_p2p_pgmap(sg_page(sg)->pgmap); | ||
860 | struct pci_dev *client; | ||
861 | |||
862 | if (WARN_ON_ONCE(!dev_is_pci(dev))) | ||
863 | return 0; | ||
864 | |||
865 | client = to_pci_dev(dev); | ||
866 | |||
867 | switch (pci_p2pdma_map_type(p2p_pgmap->provider, client)) { | ||
868 | case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE: | ||
869 | return dma_map_sg_attrs(dev, sg, nents, dir, attrs); | ||
870 | case PCI_P2PDMA_MAP_BUS_ADDR: | ||
871 | return __pci_p2pdma_map_sg(p2p_pgmap, dev, sg, nents); | ||
872 | default: | ||
873 | WARN_ON_ONCE(1); | ||
874 | return 0; | ||
875 | } | ||
876 | } | ||
877 | EXPORT_SYMBOL_GPL(pci_p2pdma_map_sg_attrs); | ||
878 | |||
879 | /** | ||
880 | * pci_p2pdma_unmap_sg - unmap a PCI peer-to-peer scatterlist that was | ||
881 | * mapped with pci_p2pdma_map_sg() | ||
882 | * @dev: device doing the DMA request | ||
883 | * @sg: scatter list to map | ||
884 | * @nents: number of elements returned by pci_p2pdma_map_sg() | ||
885 | * @dir: DMA direction | ||
886 | * @attrs: DMA attributes passed to dma_unmap_sg() (if called) | ||
887 | */ | ||
888 | void pci_p2pdma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, | ||
889 | int nents, enum dma_data_direction dir, unsigned long attrs) | ||
890 | { | ||
891 | struct pci_p2pdma_pagemap *p2p_pgmap = | ||
892 | to_p2p_pgmap(sg_page(sg)->pgmap); | ||
893 | enum pci_p2pdma_map_type map_type; | ||
894 | struct pci_dev *client; | ||
895 | |||
896 | if (WARN_ON_ONCE(!dev_is_pci(dev))) | ||
897 | return; | ||
898 | |||
899 | client = to_pci_dev(dev); | ||
900 | |||
901 | map_type = pci_p2pdma_map_type(p2p_pgmap->provider, client); | ||
902 | |||
903 | if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) | ||
904 | dma_unmap_sg_attrs(dev, sg, nents, dir, attrs); | ||
905 | } | ||
906 | EXPORT_SYMBOL_GPL(pci_p2pdma_unmap_sg_attrs); | ||
749 | 907 | ||
750 | /** | 908 | /** |
751 | * pci_p2pdma_enable_store - parse a configfs/sysfs attribute store | 909 | * pci_p2pdma_enable_store - parse a configfs/sysfs attribute store |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 45049f558860..0c02d500158f 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/msi.h> | 14 | #include <linux/msi.h> |
15 | #include <linux/pci_hotplug.h> | 15 | #include <linux/pci_hotplug.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/pci-aspm.h> | ||
18 | #include <linux/pci-acpi.h> | 17 | #include <linux/pci-acpi.h> |
19 | #include <linux/pm_runtime.h> | 18 | #include <linux/pm_runtime.h> |
20 | #include <linux/pm_qos.h> | 19 | #include <linux/pm_qos.h> |
@@ -118,8 +117,58 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) | |||
118 | return (phys_addr_t)mcfg_addr; | 117 | return (phys_addr_t)mcfg_addr; |
119 | } | 118 | } |
120 | 119 | ||
120 | /* _HPX PCI Setting Record (Type 0); same as _HPP */ | ||
121 | struct hpx_type0 { | ||
122 | u32 revision; /* Not present in _HPP */ | ||
123 | u8 cache_line_size; /* Not applicable to PCIe */ | ||
124 | u8 latency_timer; /* Not applicable to PCIe */ | ||
125 | u8 enable_serr; | ||
126 | u8 enable_perr; | ||
127 | }; | ||
128 | |||
129 | static struct hpx_type0 pci_default_type0 = { | ||
130 | .revision = 1, | ||
131 | .cache_line_size = 8, | ||
132 | .latency_timer = 0x40, | ||
133 | .enable_serr = 0, | ||
134 | .enable_perr = 0, | ||
135 | }; | ||
136 | |||
137 | static void program_hpx_type0(struct pci_dev *dev, struct hpx_type0 *hpx) | ||
138 | { | ||
139 | u16 pci_cmd, pci_bctl; | ||
140 | |||
141 | if (!hpx) | ||
142 | hpx = &pci_default_type0; | ||
143 | |||
144 | if (hpx->revision > 1) { | ||
145 | pci_warn(dev, "PCI settings rev %d not supported; using defaults\n", | ||
146 | hpx->revision); | ||
147 | hpx = &pci_default_type0; | ||
148 | } | ||
149 | |||
150 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpx->cache_line_size); | ||
151 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpx->latency_timer); | ||
152 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | ||
153 | if (hpx->enable_serr) | ||
154 | pci_cmd |= PCI_COMMAND_SERR; | ||
155 | if (hpx->enable_perr) | ||
156 | pci_cmd |= PCI_COMMAND_PARITY; | ||
157 | pci_write_config_word(dev, PCI_COMMAND, pci_cmd); | ||
158 | |||
159 | /* Program bridge control value */ | ||
160 | if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { | ||
161 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, | ||
162 | hpx->latency_timer); | ||
163 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); | ||
164 | if (hpx->enable_perr) | ||
165 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; | ||
166 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl); | ||
167 | } | ||
168 | } | ||
169 | |||
121 | static acpi_status decode_type0_hpx_record(union acpi_object *record, | 170 | static acpi_status decode_type0_hpx_record(union acpi_object *record, |
122 | struct hpp_type0 *hpx0) | 171 | struct hpx_type0 *hpx0) |
123 | { | 172 | { |
124 | int i; | 173 | int i; |
125 | union acpi_object *fields = record->package.elements; | 174 | union acpi_object *fields = record->package.elements; |
@@ -146,8 +195,30 @@ static acpi_status decode_type0_hpx_record(union acpi_object *record, | |||
146 | return AE_OK; | 195 | return AE_OK; |
147 | } | 196 | } |
148 | 197 | ||
198 | /* _HPX PCI-X Setting Record (Type 1) */ | ||
199 | struct hpx_type1 { | ||
200 | u32 revision; | ||
201 | u8 max_mem_read; | ||
202 | u8 avg_max_split; | ||
203 | u16 tot_max_split; | ||
204 | }; | ||
205 | |||
206 | static void program_hpx_type1(struct pci_dev *dev, struct hpx_type1 *hpx) | ||
207 | { | ||
208 | int pos; | ||
209 | |||
210 | if (!hpx) | ||
211 | return; | ||
212 | |||
213 | pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); | ||
214 | if (!pos) | ||
215 | return; | ||
216 | |||
217 | pci_warn(dev, "PCI-X settings not supported\n"); | ||
218 | } | ||
219 | |||
149 | static acpi_status decode_type1_hpx_record(union acpi_object *record, | 220 | static acpi_status decode_type1_hpx_record(union acpi_object *record, |
150 | struct hpp_type1 *hpx1) | 221 | struct hpx_type1 *hpx1) |
151 | { | 222 | { |
152 | int i; | 223 | int i; |
153 | union acpi_object *fields = record->package.elements; | 224 | union acpi_object *fields = record->package.elements; |
@@ -173,8 +244,130 @@ static acpi_status decode_type1_hpx_record(union acpi_object *record, | |||
173 | return AE_OK; | 244 | return AE_OK; |
174 | } | 245 | } |
175 | 246 | ||
247 | static bool pcie_root_rcb_set(struct pci_dev *dev) | ||
248 | { | ||
249 | struct pci_dev *rp = pcie_find_root_port(dev); | ||
250 | u16 lnkctl; | ||
251 | |||
252 | if (!rp) | ||
253 | return false; | ||
254 | |||
255 | pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl); | ||
256 | if (lnkctl & PCI_EXP_LNKCTL_RCB) | ||
257 | return true; | ||
258 | |||
259 | return false; | ||
260 | } | ||
261 | |||
262 | /* _HPX PCI Express Setting Record (Type 2) */ | ||
263 | struct hpx_type2 { | ||
264 | u32 revision; | ||
265 | u32 unc_err_mask_and; | ||
266 | u32 unc_err_mask_or; | ||
267 | u32 unc_err_sever_and; | ||
268 | u32 unc_err_sever_or; | ||
269 | u32 cor_err_mask_and; | ||
270 | u32 cor_err_mask_or; | ||
271 | u32 adv_err_cap_and; | ||
272 | u32 adv_err_cap_or; | ||
273 | u16 pci_exp_devctl_and; | ||
274 | u16 pci_exp_devctl_or; | ||
275 | u16 pci_exp_lnkctl_and; | ||
276 | u16 pci_exp_lnkctl_or; | ||
277 | u32 sec_unc_err_sever_and; | ||
278 | u32 sec_unc_err_sever_or; | ||
279 | u32 sec_unc_err_mask_and; | ||
280 | u32 sec_unc_err_mask_or; | ||
281 | }; | ||
282 | |||
283 | static void program_hpx_type2(struct pci_dev *dev, struct hpx_type2 *hpx) | ||
284 | { | ||
285 | int pos; | ||
286 | u32 reg32; | ||
287 | |||
288 | if (!hpx) | ||
289 | return; | ||
290 | |||
291 | if (!pci_is_pcie(dev)) | ||
292 | return; | ||
293 | |||
294 | if (hpx->revision > 1) { | ||
295 | pci_warn(dev, "PCIe settings rev %d not supported\n", | ||
296 | hpx->revision); | ||
297 | return; | ||
298 | } | ||
299 | |||
300 | /* | ||
301 | * Don't allow _HPX to change MPS or MRRS settings. We manage | ||
302 | * those to make sure they're consistent with the rest of the | ||
303 | * platform. | ||
304 | */ | ||
305 | hpx->pci_exp_devctl_and |= PCI_EXP_DEVCTL_PAYLOAD | | ||
306 | PCI_EXP_DEVCTL_READRQ; | ||
307 | hpx->pci_exp_devctl_or &= ~(PCI_EXP_DEVCTL_PAYLOAD | | ||
308 | PCI_EXP_DEVCTL_READRQ); | ||
309 | |||
310 | /* Initialize Device Control Register */ | ||
311 | pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, | ||
312 | ~hpx->pci_exp_devctl_and, hpx->pci_exp_devctl_or); | ||
313 | |||
314 | /* Initialize Link Control Register */ | ||
315 | if (pcie_cap_has_lnkctl(dev)) { | ||
316 | |||
317 | /* | ||
318 | * If the Root Port supports Read Completion Boundary of | ||
319 | * 128, set RCB to 128. Otherwise, clear it. | ||
320 | */ | ||
321 | hpx->pci_exp_lnkctl_and |= PCI_EXP_LNKCTL_RCB; | ||
322 | hpx->pci_exp_lnkctl_or &= ~PCI_EXP_LNKCTL_RCB; | ||
323 | if (pcie_root_rcb_set(dev)) | ||
324 | hpx->pci_exp_lnkctl_or |= PCI_EXP_LNKCTL_RCB; | ||
325 | |||
326 | pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, | ||
327 | ~hpx->pci_exp_lnkctl_and, hpx->pci_exp_lnkctl_or); | ||
328 | } | ||
329 | |||
330 | /* Find Advanced Error Reporting Enhanced Capability */ | ||
331 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | ||
332 | if (!pos) | ||
333 | return; | ||
334 | |||
335 | /* Initialize Uncorrectable Error Mask Register */ | ||
336 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, ®32); | ||
337 | reg32 = (reg32 & hpx->unc_err_mask_and) | hpx->unc_err_mask_or; | ||
338 | pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, reg32); | ||
339 | |||
340 | /* Initialize Uncorrectable Error Severity Register */ | ||
341 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, ®32); | ||
342 | reg32 = (reg32 & hpx->unc_err_sever_and) | hpx->unc_err_sever_or; | ||
343 | pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, reg32); | ||
344 | |||
345 | /* Initialize Correctable Error Mask Register */ | ||
346 | pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, ®32); | ||
347 | reg32 = (reg32 & hpx->cor_err_mask_and) | hpx->cor_err_mask_or; | ||
348 | pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg32); | ||
349 | |||
350 | /* Initialize Advanced Error Capabilities and Control Register */ | ||
351 | pci_read_config_dword(dev, pos + PCI_ERR_CAP, ®32); | ||
352 | reg32 = (reg32 & hpx->adv_err_cap_and) | hpx->adv_err_cap_or; | ||
353 | |||
354 | /* Don't enable ECRC generation or checking if unsupported */ | ||
355 | if (!(reg32 & PCI_ERR_CAP_ECRC_GENC)) | ||
356 | reg32 &= ~PCI_ERR_CAP_ECRC_GENE; | ||
357 | if (!(reg32 & PCI_ERR_CAP_ECRC_CHKC)) | ||
358 | reg32 &= ~PCI_ERR_CAP_ECRC_CHKE; | ||
359 | pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32); | ||
360 | |||
361 | /* | ||
362 | * FIXME: The following two registers are not supported yet. | ||
363 | * | ||
364 | * o Secondary Uncorrectable Error Severity Register | ||
365 | * o Secondary Uncorrectable Error Mask Register | ||
366 | */ | ||
367 | } | ||
368 | |||
176 | static acpi_status decode_type2_hpx_record(union acpi_object *record, | 369 | static acpi_status decode_type2_hpx_record(union acpi_object *record, |
177 | struct hpp_type2 *hpx2) | 370 | struct hpx_type2 *hpx2) |
178 | { | 371 | { |
179 | int i; | 372 | int i; |
180 | union acpi_object *fields = record->package.elements; | 373 | union acpi_object *fields = record->package.elements; |
@@ -213,6 +406,164 @@ static acpi_status decode_type2_hpx_record(union acpi_object *record, | |||
213 | return AE_OK; | 406 | return AE_OK; |
214 | } | 407 | } |
215 | 408 | ||
409 | /* _HPX PCI Express Setting Record (Type 3) */ | ||
410 | struct hpx_type3 { | ||
411 | u16 device_type; | ||
412 | u16 function_type; | ||
413 | u16 config_space_location; | ||
414 | u16 pci_exp_cap_id; | ||
415 | u16 pci_exp_cap_ver; | ||
416 | u16 pci_exp_vendor_id; | ||
417 | u16 dvsec_id; | ||
418 | u16 dvsec_rev; | ||
419 | u16 match_offset; | ||
420 | u32 match_mask_and; | ||
421 | u32 match_value; | ||
422 | u16 reg_offset; | ||
423 | u32 reg_mask_and; | ||
424 | u32 reg_mask_or; | ||
425 | }; | ||
426 | |||
427 | enum hpx_type3_dev_type { | ||
428 | HPX_TYPE_ENDPOINT = BIT(0), | ||
429 | HPX_TYPE_LEG_END = BIT(1), | ||
430 | HPX_TYPE_RC_END = BIT(2), | ||
431 | HPX_TYPE_RC_EC = BIT(3), | ||
432 | HPX_TYPE_ROOT_PORT = BIT(4), | ||
433 | HPX_TYPE_UPSTREAM = BIT(5), | ||
434 | HPX_TYPE_DOWNSTREAM = BIT(6), | ||
435 | HPX_TYPE_PCI_BRIDGE = BIT(7), | ||
436 | HPX_TYPE_PCIE_BRIDGE = BIT(8), | ||
437 | }; | ||
438 | |||
439 | static u16 hpx3_device_type(struct pci_dev *dev) | ||
440 | { | ||
441 | u16 pcie_type = pci_pcie_type(dev); | ||
442 | const int pcie_to_hpx3_type[] = { | ||
443 | [PCI_EXP_TYPE_ENDPOINT] = HPX_TYPE_ENDPOINT, | ||
444 | [PCI_EXP_TYPE_LEG_END] = HPX_TYPE_LEG_END, | ||
445 | [PCI_EXP_TYPE_RC_END] = HPX_TYPE_RC_END, | ||
446 | [PCI_EXP_TYPE_RC_EC] = HPX_TYPE_RC_EC, | ||
447 | [PCI_EXP_TYPE_ROOT_PORT] = HPX_TYPE_ROOT_PORT, | ||
448 | [PCI_EXP_TYPE_UPSTREAM] = HPX_TYPE_UPSTREAM, | ||
449 | [PCI_EXP_TYPE_DOWNSTREAM] = HPX_TYPE_DOWNSTREAM, | ||
450 | [PCI_EXP_TYPE_PCI_BRIDGE] = HPX_TYPE_PCI_BRIDGE, | ||
451 | [PCI_EXP_TYPE_PCIE_BRIDGE] = HPX_TYPE_PCIE_BRIDGE, | ||
452 | }; | ||
453 | |||
454 | if (pcie_type >= ARRAY_SIZE(pcie_to_hpx3_type)) | ||
455 | return 0; | ||
456 | |||
457 | return pcie_to_hpx3_type[pcie_type]; | ||
458 | } | ||
459 | |||
460 | enum hpx_type3_fn_type { | ||
461 | HPX_FN_NORMAL = BIT(0), | ||
462 | HPX_FN_SRIOV_PHYS = BIT(1), | ||
463 | HPX_FN_SRIOV_VIRT = BIT(2), | ||
464 | }; | ||
465 | |||
466 | static u8 hpx3_function_type(struct pci_dev *dev) | ||
467 | { | ||
468 | if (dev->is_virtfn) | ||
469 | return HPX_FN_SRIOV_VIRT; | ||
470 | else if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV) > 0) | ||
471 | return HPX_FN_SRIOV_PHYS; | ||
472 | else | ||
473 | return HPX_FN_NORMAL; | ||
474 | } | ||
475 | |||
476 | static bool hpx3_cap_ver_matches(u8 pcie_cap_id, u8 hpx3_cap_id) | ||
477 | { | ||
478 | u8 cap_ver = hpx3_cap_id & 0xf; | ||
479 | |||
480 | if ((hpx3_cap_id & BIT(4)) && cap_ver >= pcie_cap_id) | ||
481 | return true; | ||
482 | else if (cap_ver == pcie_cap_id) | ||
483 | return true; | ||
484 | |||
485 | return false; | ||
486 | } | ||
487 | |||
488 | enum hpx_type3_cfg_loc { | ||
489 | HPX_CFG_PCICFG = 0, | ||
490 | HPX_CFG_PCIE_CAP = 1, | ||
491 | HPX_CFG_PCIE_CAP_EXT = 2, | ||
492 | HPX_CFG_VEND_CAP = 3, | ||
493 | HPX_CFG_DVSEC = 4, | ||
494 | HPX_CFG_MAX, | ||
495 | }; | ||
496 | |||
497 | static void program_hpx_type3_register(struct pci_dev *dev, | ||
498 | const struct hpx_type3 *reg) | ||
499 | { | ||
500 | u32 match_reg, write_reg, header, orig_value; | ||
501 | u16 pos; | ||
502 | |||
503 | if (!(hpx3_device_type(dev) & reg->device_type)) | ||
504 | return; | ||
505 | |||
506 | if (!(hpx3_function_type(dev) & reg->function_type)) | ||
507 | return; | ||
508 | |||
509 | switch (reg->config_space_location) { | ||
510 | case HPX_CFG_PCICFG: | ||
511 | pos = 0; | ||
512 | break; | ||
513 | case HPX_CFG_PCIE_CAP: | ||
514 | pos = pci_find_capability(dev, reg->pci_exp_cap_id); | ||
515 | if (pos == 0) | ||
516 | return; | ||
517 | |||
518 | break; | ||
519 | case HPX_CFG_PCIE_CAP_EXT: | ||
520 | pos = pci_find_ext_capability(dev, reg->pci_exp_cap_id); | ||
521 | if (pos == 0) | ||
522 | return; | ||
523 | |||
524 | pci_read_config_dword(dev, pos, &header); | ||
525 | if (!hpx3_cap_ver_matches(PCI_EXT_CAP_VER(header), | ||
526 | reg->pci_exp_cap_ver)) | ||
527 | return; | ||
528 | |||
529 | break; | ||
530 | case HPX_CFG_VEND_CAP: /* Fall through */ | ||
531 | case HPX_CFG_DVSEC: /* Fall through */ | ||
532 | default: | ||
533 | pci_warn(dev, "Encountered _HPX type 3 with unsupported config space location"); | ||
534 | return; | ||
535 | } | ||
536 | |||
537 | pci_read_config_dword(dev, pos + reg->match_offset, &match_reg); | ||
538 | |||
539 | if ((match_reg & reg->match_mask_and) != reg->match_value) | ||
540 | return; | ||
541 | |||
542 | pci_read_config_dword(dev, pos + reg->reg_offset, &write_reg); | ||
543 | orig_value = write_reg; | ||
544 | write_reg &= reg->reg_mask_and; | ||
545 | write_reg |= reg->reg_mask_or; | ||
546 | |||
547 | if (orig_value == write_reg) | ||
548 | return; | ||
549 | |||
550 | pci_write_config_dword(dev, pos + reg->reg_offset, write_reg); | ||
551 | |||
552 | pci_dbg(dev, "Applied _HPX3 at [0x%x]: 0x%08x -> 0x%08x", | ||
553 | pos, orig_value, write_reg); | ||
554 | } | ||
555 | |||
556 | static void program_hpx_type3(struct pci_dev *dev, struct hpx_type3 *hpx) | ||
557 | { | ||
558 | if (!hpx) | ||
559 | return; | ||
560 | |||
561 | if (!pci_is_pcie(dev)) | ||
562 | return; | ||
563 | |||
564 | program_hpx_type3_register(dev, hpx); | ||
565 | } | ||
566 | |||
216 | static void parse_hpx3_register(struct hpx_type3 *hpx3_reg, | 567 | static void parse_hpx3_register(struct hpx_type3 *hpx3_reg, |
217 | union acpi_object *reg_fields) | 568 | union acpi_object *reg_fields) |
218 | { | 569 | { |
@@ -233,8 +584,7 @@ static void parse_hpx3_register(struct hpx_type3 *hpx3_reg, | |||
233 | } | 584 | } |
234 | 585 | ||
235 | static acpi_status program_type3_hpx_record(struct pci_dev *dev, | 586 | static acpi_status program_type3_hpx_record(struct pci_dev *dev, |
236 | union acpi_object *record, | 587 | union acpi_object *record) |
237 | const struct hotplug_program_ops *hp_ops) | ||
238 | { | 588 | { |
239 | union acpi_object *fields = record->package.elements; | 589 | union acpi_object *fields = record->package.elements; |
240 | u32 desc_count, expected_length, revision; | 590 | u32 desc_count, expected_length, revision; |
@@ -258,7 +608,7 @@ static acpi_status program_type3_hpx_record(struct pci_dev *dev, | |||
258 | for (i = 0; i < desc_count; i++) { | 608 | for (i = 0; i < desc_count; i++) { |
259 | reg_fields = fields + 3 + i * 14; | 609 | reg_fields = fields + 3 + i * 14; |
260 | parse_hpx3_register(&hpx3, reg_fields); | 610 | parse_hpx3_register(&hpx3, reg_fields); |
261 | hp_ops->program_type3(dev, &hpx3); | 611 | program_hpx_type3(dev, &hpx3); |
262 | } | 612 | } |
263 | 613 | ||
264 | break; | 614 | break; |
@@ -271,15 +621,14 @@ static acpi_status program_type3_hpx_record(struct pci_dev *dev, | |||
271 | return AE_OK; | 621 | return AE_OK; |
272 | } | 622 | } |
273 | 623 | ||
274 | static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle, | 624 | static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle) |
275 | const struct hotplug_program_ops *hp_ops) | ||
276 | { | 625 | { |
277 | acpi_status status; | 626 | acpi_status status; |
278 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 627 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
279 | union acpi_object *package, *record, *fields; | 628 | union acpi_object *package, *record, *fields; |
280 | struct hpp_type0 hpx0; | 629 | struct hpx_type0 hpx0; |
281 | struct hpp_type1 hpx1; | 630 | struct hpx_type1 hpx1; |
282 | struct hpp_type2 hpx2; | 631 | struct hpx_type2 hpx2; |
283 | u32 type; | 632 | u32 type; |
284 | int i; | 633 | int i; |
285 | 634 | ||
@@ -314,24 +663,24 @@ static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle, | |||
314 | status = decode_type0_hpx_record(record, &hpx0); | 663 | status = decode_type0_hpx_record(record, &hpx0); |
315 | if (ACPI_FAILURE(status)) | 664 | if (ACPI_FAILURE(status)) |
316 | goto exit; | 665 | goto exit; |
317 | hp_ops->program_type0(dev, &hpx0); | 666 | program_hpx_type0(dev, &hpx0); |
318 | break; | 667 | break; |
319 | case 1: | 668 | case 1: |
320 | memset(&hpx1, 0, sizeof(hpx1)); | 669 | memset(&hpx1, 0, sizeof(hpx1)); |
321 | status = decode_type1_hpx_record(record, &hpx1); | 670 | status = decode_type1_hpx_record(record, &hpx1); |
322 | if (ACPI_FAILURE(status)) | 671 | if (ACPI_FAILURE(status)) |
323 | goto exit; | 672 | goto exit; |
324 | hp_ops->program_type1(dev, &hpx1); | 673 | program_hpx_type1(dev, &hpx1); |
325 | break; | 674 | break; |
326 | case 2: | 675 | case 2: |
327 | memset(&hpx2, 0, sizeof(hpx2)); | 676 | memset(&hpx2, 0, sizeof(hpx2)); |
328 | status = decode_type2_hpx_record(record, &hpx2); | 677 | status = decode_type2_hpx_record(record, &hpx2); |
329 | if (ACPI_FAILURE(status)) | 678 | if (ACPI_FAILURE(status)) |
330 | goto exit; | 679 | goto exit; |
331 | hp_ops->program_type2(dev, &hpx2); | 680 | program_hpx_type2(dev, &hpx2); |
332 | break; | 681 | break; |
333 | case 3: | 682 | case 3: |
334 | status = program_type3_hpx_record(dev, record, hp_ops); | 683 | status = program_type3_hpx_record(dev, record); |
335 | if (ACPI_FAILURE(status)) | 684 | if (ACPI_FAILURE(status)) |
336 | goto exit; | 685 | goto exit; |
337 | break; | 686 | break; |
@@ -347,16 +696,15 @@ static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle, | |||
347 | return status; | 696 | return status; |
348 | } | 697 | } |
349 | 698 | ||
350 | static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle, | 699 | static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle) |
351 | const struct hotplug_program_ops *hp_ops) | ||
352 | { | 700 | { |
353 | acpi_status status; | 701 | acpi_status status; |
354 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 702 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
355 | union acpi_object *package, *fields; | 703 | union acpi_object *package, *fields; |
356 | struct hpp_type0 hpp0; | 704 | struct hpx_type0 hpx0; |
357 | int i; | 705 | int i; |
358 | 706 | ||
359 | memset(&hpp0, 0, sizeof(hpp0)); | 707 | memset(&hpx0, 0, sizeof(hpx0)); |
360 | 708 | ||
361 | status = acpi_evaluate_object(handle, "_HPP", NULL, &buffer); | 709 | status = acpi_evaluate_object(handle, "_HPP", NULL, &buffer); |
362 | if (ACPI_FAILURE(status)) | 710 | if (ACPI_FAILURE(status)) |
@@ -377,26 +725,24 @@ static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle, | |||
377 | } | 725 | } |
378 | } | 726 | } |
379 | 727 | ||
380 | hpp0.revision = 1; | 728 | hpx0.revision = 1; |
381 | hpp0.cache_line_size = fields[0].integer.value; | 729 | hpx0.cache_line_size = fields[0].integer.value; |
382 | hpp0.latency_timer = fields[1].integer.value; | 730 | hpx0.latency_timer = fields[1].integer.value; |
383 | hpp0.enable_serr = fields[2].integer.value; | 731 | hpx0.enable_serr = fields[2].integer.value; |
384 | hpp0.enable_perr = fields[3].integer.value; | 732 | hpx0.enable_perr = fields[3].integer.value; |
385 | 733 | ||
386 | hp_ops->program_type0(dev, &hpp0); | 734 | program_hpx_type0(dev, &hpx0); |
387 | 735 | ||
388 | exit: | 736 | exit: |
389 | kfree(buffer.pointer); | 737 | kfree(buffer.pointer); |
390 | return status; | 738 | return status; |
391 | } | 739 | } |
392 | 740 | ||
393 | /* pci_get_hp_params | 741 | /* pci_acpi_program_hp_params |
394 | * | 742 | * |
395 | * @dev - the pci_dev for which we want parameters | 743 | * @dev - the pci_dev for which we want parameters |
396 | * @hpp - allocated by the caller | ||
397 | */ | 744 | */ |
398 | int pci_acpi_program_hp_params(struct pci_dev *dev, | 745 | int pci_acpi_program_hp_params(struct pci_dev *dev) |
399 | const struct hotplug_program_ops *hp_ops) | ||
400 | { | 746 | { |
401 | acpi_status status; | 747 | acpi_status status; |
402 | acpi_handle handle, phandle; | 748 | acpi_handle handle, phandle; |
@@ -419,10 +765,10 @@ int pci_acpi_program_hp_params(struct pci_dev *dev, | |||
419 | * this pci dev. | 765 | * this pci dev. |
420 | */ | 766 | */ |
421 | while (handle) { | 767 | while (handle) { |
422 | status = acpi_run_hpx(dev, handle, hp_ops); | 768 | status = acpi_run_hpx(dev, handle); |
423 | if (ACPI_SUCCESS(status)) | 769 | if (ACPI_SUCCESS(status)) |
424 | return 0; | 770 | return 0; |
425 | status = acpi_run_hpp(dev, handle, hp_ops); | 771 | status = acpi_run_hpp(dev, handle); |
426 | if (ACPI_SUCCESS(status)) | 772 | if (ACPI_SUCCESS(status)) |
427 | return 0; | 773 | return 0; |
428 | if (acpi_is_root_bridge(handle)) | 774 | if (acpi_is_root_bridge(handle)) |
diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c index 06083b86d4f4..5fd90105510d 100644 --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c | |||
@@ -38,7 +38,7 @@ struct pci_bridge_reg_behavior { | |||
38 | u32 rsvd; | 38 | u32 rsvd; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | const static struct pci_bridge_reg_behavior pci_regs_behavior[] = { | 41 | static const struct pci_bridge_reg_behavior pci_regs_behavior[] = { |
42 | [PCI_VENDOR_ID / 4] = { .ro = ~0 }, | 42 | [PCI_VENDOR_ID / 4] = { .ro = ~0 }, |
43 | [PCI_COMMAND / 4] = { | 43 | [PCI_COMMAND / 4] = { |
44 | .rw = (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | | 44 | .rw = (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | |
@@ -173,7 +173,7 @@ const static struct pci_bridge_reg_behavior pci_regs_behavior[] = { | |||
173 | }, | 173 | }, |
174 | }; | 174 | }; |
175 | 175 | ||
176 | const static struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = { | 176 | static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = { |
177 | [PCI_CAP_LIST_ID / 4] = { | 177 | [PCI_CAP_LIST_ID / 4] = { |
178 | /* | 178 | /* |
179 | * Capability ID, Next Capability Pointer and | 179 | * Capability ID, Next Capability Pointer and |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 965c72104150..868e35109284 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -464,9 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev, | |||
464 | } | 464 | } |
465 | return count; | 465 | return count; |
466 | } | 466 | } |
467 | static struct device_attribute dev_rescan_attr = __ATTR(rescan, | 467 | static DEVICE_ATTR_WO(dev_rescan); |
468 | (S_IWUSR|S_IWGRP), | ||
469 | NULL, dev_rescan_store); | ||
470 | 468 | ||
471 | static ssize_t remove_store(struct device *dev, struct device_attribute *attr, | 469 | static ssize_t remove_store(struct device *dev, struct device_attribute *attr, |
472 | const char *buf, size_t count) | 470 | const char *buf, size_t count) |
@@ -480,13 +478,12 @@ static ssize_t remove_store(struct device *dev, struct device_attribute *attr, | |||
480 | pci_stop_and_remove_bus_device_locked(to_pci_dev(dev)); | 478 | pci_stop_and_remove_bus_device_locked(to_pci_dev(dev)); |
481 | return count; | 479 | return count; |
482 | } | 480 | } |
483 | static struct device_attribute dev_remove_attr = __ATTR_IGNORE_LOCKDEP(remove, | 481 | static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL, |
484 | (S_IWUSR|S_IWGRP), | 482 | remove_store); |
485 | NULL, remove_store); | ||
486 | 483 | ||
487 | static ssize_t dev_bus_rescan_store(struct device *dev, | 484 | static ssize_t bus_rescan_store(struct device *dev, |
488 | struct device_attribute *attr, | 485 | struct device_attribute *attr, |
489 | const char *buf, size_t count) | 486 | const char *buf, size_t count) |
490 | { | 487 | { |
491 | unsigned long val; | 488 | unsigned long val; |
492 | struct pci_bus *bus = to_pci_bus(dev); | 489 | struct pci_bus *bus = to_pci_bus(dev); |
@@ -504,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev, | |||
504 | } | 501 | } |
505 | return count; | 502 | return count; |
506 | } | 503 | } |
507 | static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store); | 504 | static DEVICE_ATTR_WO(bus_rescan); |
508 | 505 | ||
509 | #if defined(CONFIG_PM) && defined(CONFIG_ACPI) | 506 | #if defined(CONFIG_PM) && defined(CONFIG_ACPI) |
510 | static ssize_t d3cold_allowed_store(struct device *dev, | 507 | static ssize_t d3cold_allowed_store(struct device *dev, |
@@ -551,154 +548,6 @@ static ssize_t devspec_show(struct device *dev, | |||
551 | static DEVICE_ATTR_RO(devspec); | 548 | static DEVICE_ATTR_RO(devspec); |
552 | #endif | 549 | #endif |
553 | 550 | ||
554 | #ifdef CONFIG_PCI_IOV | ||
555 | static ssize_t sriov_totalvfs_show(struct device *dev, | ||
556 | struct device_attribute *attr, | ||
557 | char *buf) | ||
558 | { | ||
559 | struct pci_dev *pdev = to_pci_dev(dev); | ||
560 | |||
561 | return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); | ||
562 | } | ||
563 | |||
564 | |||
565 | static ssize_t sriov_numvfs_show(struct device *dev, | ||
566 | struct device_attribute *attr, | ||
567 | char *buf) | ||
568 | { | ||
569 | struct pci_dev *pdev = to_pci_dev(dev); | ||
570 | |||
571 | return sprintf(buf, "%u\n", pdev->sriov->num_VFs); | ||
572 | } | ||
573 | |||
574 | /* | ||
575 | * num_vfs > 0; number of VFs to enable | ||
576 | * num_vfs = 0; disable all VFs | ||
577 | * | ||
578 | * Note: SRIOV spec doesn't allow partial VF | ||
579 | * disable, so it's all or none. | ||
580 | */ | ||
581 | static ssize_t sriov_numvfs_store(struct device *dev, | ||
582 | struct device_attribute *attr, | ||
583 | const char *buf, size_t count) | ||
584 | { | ||
585 | struct pci_dev *pdev = to_pci_dev(dev); | ||
586 | int ret; | ||
587 | u16 num_vfs; | ||
588 | |||
589 | ret = kstrtou16(buf, 0, &num_vfs); | ||
590 | if (ret < 0) | ||
591 | return ret; | ||
592 | |||
593 | if (num_vfs > pci_sriov_get_totalvfs(pdev)) | ||
594 | return -ERANGE; | ||
595 | |||
596 | device_lock(&pdev->dev); | ||
597 | |||
598 | if (num_vfs == pdev->sriov->num_VFs) | ||
599 | goto exit; | ||
600 | |||
601 | /* is PF driver loaded w/callback */ | ||
602 | if (!pdev->driver || !pdev->driver->sriov_configure) { | ||
603 | pci_info(pdev, "Driver doesn't support SRIOV configuration via sysfs\n"); | ||
604 | ret = -ENOENT; | ||
605 | goto exit; | ||
606 | } | ||
607 | |||
608 | if (num_vfs == 0) { | ||
609 | /* disable VFs */ | ||
610 | ret = pdev->driver->sriov_configure(pdev, 0); | ||
611 | goto exit; | ||
612 | } | ||
613 | |||
614 | /* enable VFs */ | ||
615 | if (pdev->sriov->num_VFs) { | ||
616 | pci_warn(pdev, "%d VFs already enabled. Disable before enabling %d VFs\n", | ||
617 | pdev->sriov->num_VFs, num_vfs); | ||
618 | ret = -EBUSY; | ||
619 | goto exit; | ||
620 | } | ||
621 | |||
622 | ret = pdev->driver->sriov_configure(pdev, num_vfs); | ||
623 | if (ret < 0) | ||
624 | goto exit; | ||
625 | |||
626 | if (ret != num_vfs) | ||
627 | pci_warn(pdev, "%d VFs requested; only %d enabled\n", | ||
628 | num_vfs, ret); | ||
629 | |||
630 | exit: | ||
631 | device_unlock(&pdev->dev); | ||
632 | |||
633 | if (ret < 0) | ||
634 | return ret; | ||
635 | |||
636 | return count; | ||
637 | } | ||
638 | |||
639 | static ssize_t sriov_offset_show(struct device *dev, | ||
640 | struct device_attribute *attr, | ||
641 | char *buf) | ||
642 | { | ||
643 | struct pci_dev *pdev = to_pci_dev(dev); | ||
644 | |||
645 | return sprintf(buf, "%u\n", pdev->sriov->offset); | ||
646 | } | ||
647 | |||
648 | static ssize_t sriov_stride_show(struct device *dev, | ||
649 | struct device_attribute *attr, | ||
650 | char *buf) | ||
651 | { | ||
652 | struct pci_dev *pdev = to_pci_dev(dev); | ||
653 | |||
654 | return sprintf(buf, "%u\n", pdev->sriov->stride); | ||
655 | } | ||
656 | |||
657 | static ssize_t sriov_vf_device_show(struct device *dev, | ||
658 | struct device_attribute *attr, | ||
659 | char *buf) | ||
660 | { | ||
661 | struct pci_dev *pdev = to_pci_dev(dev); | ||
662 | |||
663 | return sprintf(buf, "%x\n", pdev->sriov->vf_device); | ||
664 | } | ||
665 | |||
666 | static ssize_t sriov_drivers_autoprobe_show(struct device *dev, | ||
667 | struct device_attribute *attr, | ||
668 | char *buf) | ||
669 | { | ||
670 | struct pci_dev *pdev = to_pci_dev(dev); | ||
671 | |||
672 | return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe); | ||
673 | } | ||
674 | |||
675 | static ssize_t sriov_drivers_autoprobe_store(struct device *dev, | ||
676 | struct device_attribute *attr, | ||
677 | const char *buf, size_t count) | ||
678 | { | ||
679 | struct pci_dev *pdev = to_pci_dev(dev); | ||
680 | bool drivers_autoprobe; | ||
681 | |||
682 | if (kstrtobool(buf, &drivers_autoprobe) < 0) | ||
683 | return -EINVAL; | ||
684 | |||
685 | pdev->sriov->drivers_autoprobe = drivers_autoprobe; | ||
686 | |||
687 | return count; | ||
688 | } | ||
689 | |||
690 | static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs); | ||
691 | static struct device_attribute sriov_numvfs_attr = | ||
692 | __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP), | ||
693 | sriov_numvfs_show, sriov_numvfs_store); | ||
694 | static struct device_attribute sriov_offset_attr = __ATTR_RO(sriov_offset); | ||
695 | static struct device_attribute sriov_stride_attr = __ATTR_RO(sriov_stride); | ||
696 | static struct device_attribute sriov_vf_device_attr = __ATTR_RO(sriov_vf_device); | ||
697 | static struct device_attribute sriov_drivers_autoprobe_attr = | ||
698 | __ATTR(sriov_drivers_autoprobe, (S_IRUGO|S_IWUSR|S_IWGRP), | ||
699 | sriov_drivers_autoprobe_show, sriov_drivers_autoprobe_store); | ||
700 | #endif /* CONFIG_PCI_IOV */ | ||
701 | |||
702 | static ssize_t driver_override_store(struct device *dev, | 551 | static ssize_t driver_override_store(struct device *dev, |
703 | struct device_attribute *attr, | 552 | struct device_attribute *attr, |
704 | const char *buf, size_t count) | 553 | const char *buf, size_t count) |
@@ -792,7 +641,7 @@ static struct attribute *pcie_dev_attrs[] = { | |||
792 | }; | 641 | }; |
793 | 642 | ||
794 | static struct attribute *pcibus_attrs[] = { | 643 | static struct attribute *pcibus_attrs[] = { |
795 | &dev_attr_rescan.attr, | 644 | &dev_attr_bus_rescan.attr, |
796 | &dev_attr_cpuaffinity.attr, | 645 | &dev_attr_cpuaffinity.attr, |
797 | &dev_attr_cpulistaffinity.attr, | 646 | &dev_attr_cpulistaffinity.attr, |
798 | NULL, | 647 | NULL, |
@@ -820,7 +669,7 @@ static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr, | |||
820 | !!(pdev->resource[PCI_ROM_RESOURCE].flags & | 669 | !!(pdev->resource[PCI_ROM_RESOURCE].flags & |
821 | IORESOURCE_ROM_SHADOW)); | 670 | IORESOURCE_ROM_SHADOW)); |
822 | } | 671 | } |
823 | static struct device_attribute vga_attr = __ATTR_RO(boot_vga); | 672 | static DEVICE_ATTR_RO(boot_vga); |
824 | 673 | ||
825 | static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, | 674 | static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, |
826 | struct bin_attribute *bin_attr, char *buf, | 675 | struct bin_attribute *bin_attr, char *buf, |
@@ -1085,7 +934,7 @@ void pci_create_legacy_files(struct pci_bus *b) | |||
1085 | sysfs_bin_attr_init(b->legacy_io); | 934 | sysfs_bin_attr_init(b->legacy_io); |
1086 | b->legacy_io->attr.name = "legacy_io"; | 935 | b->legacy_io->attr.name = "legacy_io"; |
1087 | b->legacy_io->size = 0xffff; | 936 | b->legacy_io->size = 0xffff; |
1088 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | 937 | b->legacy_io->attr.mode = 0600; |
1089 | b->legacy_io->read = pci_read_legacy_io; | 938 | b->legacy_io->read = pci_read_legacy_io; |
1090 | b->legacy_io->write = pci_write_legacy_io; | 939 | b->legacy_io->write = pci_write_legacy_io; |
1091 | b->legacy_io->mmap = pci_mmap_legacy_io; | 940 | b->legacy_io->mmap = pci_mmap_legacy_io; |
@@ -1099,7 +948,7 @@ void pci_create_legacy_files(struct pci_bus *b) | |||
1099 | sysfs_bin_attr_init(b->legacy_mem); | 948 | sysfs_bin_attr_init(b->legacy_mem); |
1100 | b->legacy_mem->attr.name = "legacy_mem"; | 949 | b->legacy_mem->attr.name = "legacy_mem"; |
1101 | b->legacy_mem->size = 1024*1024; | 950 | b->legacy_mem->size = 1024*1024; |
1102 | b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; | 951 | b->legacy_mem->attr.mode = 0600; |
1103 | b->legacy_mem->mmap = pci_mmap_legacy_mem; | 952 | b->legacy_mem->mmap = pci_mmap_legacy_mem; |
1104 | pci_adjust_legacy_attr(b, pci_mmap_mem); | 953 | pci_adjust_legacy_attr(b, pci_mmap_mem); |
1105 | error = device_create_bin_file(&b->dev, b->legacy_mem); | 954 | error = device_create_bin_file(&b->dev, b->legacy_mem); |
@@ -1306,7 +1155,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine) | |||
1306 | } | 1155 | } |
1307 | } | 1156 | } |
1308 | res_attr->attr.name = res_attr_name; | 1157 | res_attr->attr.name = res_attr_name; |
1309 | res_attr->attr.mode = S_IRUSR | S_IWUSR; | 1158 | res_attr->attr.mode = 0600; |
1310 | res_attr->size = pci_resource_len(pdev, num); | 1159 | res_attr->size = pci_resource_len(pdev, num); |
1311 | res_attr->private = (void *)(unsigned long)num; | 1160 | res_attr->private = (void *)(unsigned long)num; |
1312 | retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); | 1161 | retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); |
@@ -1419,7 +1268,7 @@ static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj, | |||
1419 | static const struct bin_attribute pci_config_attr = { | 1268 | static const struct bin_attribute pci_config_attr = { |
1420 | .attr = { | 1269 | .attr = { |
1421 | .name = "config", | 1270 | .name = "config", |
1422 | .mode = S_IRUGO | S_IWUSR, | 1271 | .mode = 0644, |
1423 | }, | 1272 | }, |
1424 | .size = PCI_CFG_SPACE_SIZE, | 1273 | .size = PCI_CFG_SPACE_SIZE, |
1425 | .read = pci_read_config, | 1274 | .read = pci_read_config, |
@@ -1429,7 +1278,7 @@ static const struct bin_attribute pci_config_attr = { | |||
1429 | static const struct bin_attribute pcie_config_attr = { | 1278 | static const struct bin_attribute pcie_config_attr = { |
1430 | .attr = { | 1279 | .attr = { |
1431 | .name = "config", | 1280 | .name = "config", |
1432 | .mode = S_IRUGO | S_IWUSR, | 1281 | .mode = 0644, |
1433 | }, | 1282 | }, |
1434 | .size = PCI_CFG_SPACE_EXP_SIZE, | 1283 | .size = PCI_CFG_SPACE_EXP_SIZE, |
1435 | .read = pci_read_config, | 1284 | .read = pci_read_config, |
@@ -1458,7 +1307,7 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr, | |||
1458 | return count; | 1307 | return count; |
1459 | } | 1308 | } |
1460 | 1309 | ||
1461 | static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_store); | 1310 | static DEVICE_ATTR(reset, 0200, NULL, reset_store); |
1462 | 1311 | ||
1463 | static int pci_create_capabilities_sysfs(struct pci_dev *dev) | 1312 | static int pci_create_capabilities_sysfs(struct pci_dev *dev) |
1464 | { | 1313 | { |
@@ -1468,7 +1317,7 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev) | |||
1468 | pcie_aspm_create_sysfs_dev_files(dev); | 1317 | pcie_aspm_create_sysfs_dev_files(dev); |
1469 | 1318 | ||
1470 | if (dev->reset_fn) { | 1319 | if (dev->reset_fn) { |
1471 | retval = device_create_file(&dev->dev, &reset_attr); | 1320 | retval = device_create_file(&dev->dev, &dev_attr_reset); |
1472 | if (retval) | 1321 | if (retval) |
1473 | goto error; | 1322 | goto error; |
1474 | } | 1323 | } |
@@ -1511,7 +1360,7 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) | |||
1511 | sysfs_bin_attr_init(attr); | 1360 | sysfs_bin_attr_init(attr); |
1512 | attr->size = rom_size; | 1361 | attr->size = rom_size; |
1513 | attr->attr.name = "rom"; | 1362 | attr->attr.name = "rom"; |
1514 | attr->attr.mode = S_IRUSR | S_IWUSR; | 1363 | attr->attr.mode = 0600; |
1515 | attr->read = pci_read_rom; | 1364 | attr->read = pci_read_rom; |
1516 | attr->write = pci_write_rom; | 1365 | attr->write = pci_write_rom; |
1517 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); | 1366 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); |
@@ -1553,7 +1402,7 @@ static void pci_remove_capabilities_sysfs(struct pci_dev *dev) | |||
1553 | pcie_vpd_remove_sysfs_dev_files(dev); | 1402 | pcie_vpd_remove_sysfs_dev_files(dev); |
1554 | pcie_aspm_remove_sysfs_dev_files(dev); | 1403 | pcie_aspm_remove_sysfs_dev_files(dev); |
1555 | if (dev->reset_fn) { | 1404 | if (dev->reset_fn) { |
1556 | device_remove_file(&dev->dev, &reset_attr); | 1405 | device_remove_file(&dev->dev, &dev_attr_reset); |
1557 | dev->reset_fn = 0; | 1406 | dev->reset_fn = 0; |
1558 | } | 1407 | } |
1559 | } | 1408 | } |
@@ -1606,7 +1455,7 @@ static int __init pci_sysfs_init(void) | |||
1606 | late_initcall(pci_sysfs_init); | 1455 | late_initcall(pci_sysfs_init); |
1607 | 1456 | ||
1608 | static struct attribute *pci_dev_dev_attrs[] = { | 1457 | static struct attribute *pci_dev_dev_attrs[] = { |
1609 | &vga_attr.attr, | 1458 | &dev_attr_boot_vga.attr, |
1610 | NULL, | 1459 | NULL, |
1611 | }; | 1460 | }; |
1612 | 1461 | ||
@@ -1616,7 +1465,7 @@ static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | |||
1616 | struct device *dev = kobj_to_dev(kobj); | 1465 | struct device *dev = kobj_to_dev(kobj); |
1617 | struct pci_dev *pdev = to_pci_dev(dev); | 1466 | struct pci_dev *pdev = to_pci_dev(dev); |
1618 | 1467 | ||
1619 | if (a == &vga_attr.attr) | 1468 | if (a == &dev_attr_boot_vga.attr) |
1620 | if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) | 1469 | if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) |
1621 | return 0; | 1470 | return 0; |
1622 | 1471 | ||
@@ -1624,8 +1473,8 @@ static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | |||
1624 | } | 1473 | } |
1625 | 1474 | ||
1626 | static struct attribute *pci_dev_hp_attrs[] = { | 1475 | static struct attribute *pci_dev_hp_attrs[] = { |
1627 | &dev_remove_attr.attr, | 1476 | &dev_attr_remove.attr, |
1628 | &dev_rescan_attr.attr, | 1477 | &dev_attr_dev_rescan.attr, |
1629 | NULL, | 1478 | NULL, |
1630 | }; | 1479 | }; |
1631 | 1480 | ||
@@ -1697,34 +1546,6 @@ static const struct attribute_group pci_dev_hp_attr_group = { | |||
1697 | .is_visible = pci_dev_hp_attrs_are_visible, | 1546 | .is_visible = pci_dev_hp_attrs_are_visible, |
1698 | }; | 1547 | }; |
1699 | 1548 | ||
1700 | #ifdef CONFIG_PCI_IOV | ||
1701 | static struct attribute *sriov_dev_attrs[] = { | ||
1702 | &sriov_totalvfs_attr.attr, | ||
1703 | &sriov_numvfs_attr.attr, | ||
1704 | &sriov_offset_attr.attr, | ||
1705 | &sriov_stride_attr.attr, | ||
1706 | &sriov_vf_device_attr.attr, | ||
1707 | &sriov_drivers_autoprobe_attr.attr, | ||
1708 | NULL, | ||
1709 | }; | ||
1710 | |||
1711 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, | ||
1712 | struct attribute *a, int n) | ||
1713 | { | ||
1714 | struct device *dev = kobj_to_dev(kobj); | ||
1715 | |||
1716 | if (!dev_is_pf(dev)) | ||
1717 | return 0; | ||
1718 | |||
1719 | return a->mode; | ||
1720 | } | ||
1721 | |||
1722 | static const struct attribute_group sriov_dev_attr_group = { | ||
1723 | .attrs = sriov_dev_attrs, | ||
1724 | .is_visible = sriov_attrs_are_visible, | ||
1725 | }; | ||
1726 | #endif /* CONFIG_PCI_IOV */ | ||
1727 | |||
1728 | static const struct attribute_group pci_dev_attr_group = { | 1549 | static const struct attribute_group pci_dev_attr_group = { |
1729 | .attrs = pci_dev_dev_attrs, | 1550 | .attrs = pci_dev_dev_attrs, |
1730 | .is_visible = pci_dev_attrs_are_visible, | 1551 | .is_visible = pci_dev_attrs_are_visible, |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 29ed5ec1ac27..80fe2d24fa37 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -890,8 +890,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
890 | 890 | ||
891 | pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); | 891 | pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); |
892 | dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); | 892 | dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); |
893 | if (dev->current_state != state && printk_ratelimit()) | 893 | if (dev->current_state != state) |
894 | pci_info(dev, "Refused to change power state, currently in D%d\n", | 894 | pci_info_ratelimited(dev, "Refused to change power state, currently in D%d\n", |
895 | dev->current_state); | 895 | dev->current_state); |
896 | 896 | ||
897 | /* | 897 | /* |
@@ -1438,7 +1438,7 @@ static void pci_restore_rebar_state(struct pci_dev *pdev) | |||
1438 | pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); | 1438 | pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); |
1439 | bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX; | 1439 | bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX; |
1440 | res = pdev->resource + bar_idx; | 1440 | res = pdev->resource + bar_idx; |
1441 | size = order_base_2((resource_size(res) >> 20) | 1) - 1; | 1441 | size = ilog2(resource_size(res)) - 20; |
1442 | ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE; | 1442 | ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE; |
1443 | ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT; | 1443 | ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT; |
1444 | pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl); | 1444 | pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl); |
@@ -3576,7 +3576,7 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) | |||
3576 | } | 3576 | } |
3577 | 3577 | ||
3578 | /* Ensure upstream ports don't block AtomicOps on egress */ | 3578 | /* Ensure upstream ports don't block AtomicOps on egress */ |
3579 | if (!bridge->has_secondary_link) { | 3579 | if (pci_pcie_type(bridge) == PCI_EXP_TYPE_UPSTREAM) { |
3580 | pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, | 3580 | pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, |
3581 | &ctl2); | 3581 | &ctl2); |
3582 | if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK) | 3582 | if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK) |
@@ -5932,8 +5932,19 @@ resource_size_t __weak pcibios_default_alignment(void) | |||
5932 | return 0; | 5932 | return 0; |
5933 | } | 5933 | } |
5934 | 5934 | ||
5935 | #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE | 5935 | /* |
5936 | static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; | 5936 | * Arches that don't want to expose struct resource to userland as-is in |
5937 | * sysfs and /proc can implement their own pci_resource_to_user(). | ||
5938 | */ | ||
5939 | void __weak pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
5940 | const struct resource *rsrc, | ||
5941 | resource_size_t *start, resource_size_t *end) | ||
5942 | { | ||
5943 | *start = rsrc->start; | ||
5944 | *end = rsrc->end; | ||
5945 | } | ||
5946 | |||
5947 | static char *resource_alignment_param; | ||
5937 | static DEFINE_SPINLOCK(resource_alignment_lock); | 5948 | static DEFINE_SPINLOCK(resource_alignment_lock); |
5938 | 5949 | ||
5939 | /** | 5950 | /** |
@@ -5954,7 +5965,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, | |||
5954 | 5965 | ||
5955 | spin_lock(&resource_alignment_lock); | 5966 | spin_lock(&resource_alignment_lock); |
5956 | p = resource_alignment_param; | 5967 | p = resource_alignment_param; |
5957 | if (!*p && !align) | 5968 | if (!p || !*p) |
5958 | goto out; | 5969 | goto out; |
5959 | if (pci_has_flag(PCI_PROBE_ONLY)) { | 5970 | if (pci_has_flag(PCI_PROBE_ONLY)) { |
5960 | align = 0; | 5971 | align = 0; |
@@ -6118,35 +6129,41 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) | |||
6118 | } | 6129 | } |
6119 | } | 6130 | } |
6120 | 6131 | ||
6121 | static ssize_t pci_set_resource_alignment_param(const char *buf, size_t count) | 6132 | static ssize_t resource_alignment_show(struct bus_type *bus, char *buf) |
6122 | { | 6133 | { |
6123 | if (count > RESOURCE_ALIGNMENT_PARAM_SIZE - 1) | 6134 | size_t count = 0; |
6124 | count = RESOURCE_ALIGNMENT_PARAM_SIZE - 1; | ||
6125 | spin_lock(&resource_alignment_lock); | ||
6126 | strncpy(resource_alignment_param, buf, count); | ||
6127 | resource_alignment_param[count] = '\0'; | ||
6128 | spin_unlock(&resource_alignment_lock); | ||
6129 | return count; | ||
6130 | } | ||
6131 | 6135 | ||
6132 | static ssize_t pci_get_resource_alignment_param(char *buf, size_t size) | ||
6133 | { | ||
6134 | size_t count; | ||
6135 | spin_lock(&resource_alignment_lock); | 6136 | spin_lock(&resource_alignment_lock); |
6136 | count = snprintf(buf, size, "%s", resource_alignment_param); | 6137 | if (resource_alignment_param) |
6138 | count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param); | ||
6137 | spin_unlock(&resource_alignment_lock); | 6139 | spin_unlock(&resource_alignment_lock); |
6138 | return count; | ||
6139 | } | ||
6140 | 6140 | ||
6141 | static ssize_t resource_alignment_show(struct bus_type *bus, char *buf) | 6141 | /* |
6142 | { | 6142 | * When set by the command line, resource_alignment_param will not |
6143 | return pci_get_resource_alignment_param(buf, PAGE_SIZE); | 6143 | * have a trailing line feed, which is ugly. So conditionally add |
6144 | * it here. | ||
6145 | */ | ||
6146 | if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) { | ||
6147 | buf[count - 1] = '\n'; | ||
6148 | buf[count++] = 0; | ||
6149 | } | ||
6150 | |||
6151 | return count; | ||
6144 | } | 6152 | } |
6145 | 6153 | ||
6146 | static ssize_t resource_alignment_store(struct bus_type *bus, | 6154 | static ssize_t resource_alignment_store(struct bus_type *bus, |
6147 | const char *buf, size_t count) | 6155 | const char *buf, size_t count) |
6148 | { | 6156 | { |
6149 | return pci_set_resource_alignment_param(buf, count); | 6157 | char *param = kstrndup(buf, count, GFP_KERNEL); |
6158 | |||
6159 | if (!param) | ||
6160 | return -ENOMEM; | ||
6161 | |||
6162 | spin_lock(&resource_alignment_lock); | ||
6163 | kfree(resource_alignment_param); | ||
6164 | resource_alignment_param = param; | ||
6165 | spin_unlock(&resource_alignment_lock); | ||
6166 | return count; | ||
6150 | } | 6167 | } |
6151 | 6168 | ||
6152 | static BUS_ATTR_RW(resource_alignment); | 6169 | static BUS_ATTR_RW(resource_alignment); |
@@ -6275,8 +6292,7 @@ static int __init pci_setup(char *str) | |||
6275 | } else if (!strncmp(str, "cbmemsize=", 10)) { | 6292 | } else if (!strncmp(str, "cbmemsize=", 10)) { |
6276 | pci_cardbus_mem_size = memparse(str + 10, &str); | 6293 | pci_cardbus_mem_size = memparse(str + 10, &str); |
6277 | } else if (!strncmp(str, "resource_alignment=", 19)) { | 6294 | } else if (!strncmp(str, "resource_alignment=", 19)) { |
6278 | pci_set_resource_alignment_param(str + 19, | 6295 | resource_alignment_param = str + 19; |
6279 | strlen(str + 19)); | ||
6280 | } else if (!strncmp(str, "ecrc=", 5)) { | 6296 | } else if (!strncmp(str, "ecrc=", 5)) { |
6281 | pcie_ecrc_get_policy(str + 5); | 6297 | pcie_ecrc_get_policy(str + 5); |
6282 | } else if (!strncmp(str, "hpiosize=", 9)) { | 6298 | } else if (!strncmp(str, "hpiosize=", 9)) { |
@@ -6311,15 +6327,18 @@ static int __init pci_setup(char *str) | |||
6311 | early_param("pci", pci_setup); | 6327 | early_param("pci", pci_setup); |
6312 | 6328 | ||
6313 | /* | 6329 | /* |
6314 | * 'disable_acs_redir_param' is initialized in pci_setup(), above, to point | 6330 | * 'resource_alignment_param' and 'disable_acs_redir_param' are initialized |
6315 | * to data in the __initdata section which will be freed after the init | 6331 | * in pci_setup(), above, to point to data in the __initdata section which |
6316 | * sequence is complete. We can't allocate memory in pci_setup() because some | 6332 | * will be freed after the init sequence is complete. We can't allocate memory |
6317 | * architectures do not have any memory allocation service available during | 6333 | * in pci_setup() because some architectures do not have any memory allocation |
6318 | * an early_param() call. So we allocate memory and copy the variable here | 6334 | * service available during an early_param() call. So we allocate memory and |
6319 | * before the init section is freed. | 6335 | * copy the variable here before the init section is freed. |
6336 | * | ||
6320 | */ | 6337 | */ |
6321 | static int __init pci_realloc_setup_params(void) | 6338 | static int __init pci_realloc_setup_params(void) |
6322 | { | 6339 | { |
6340 | resource_alignment_param = kstrdup(resource_alignment_param, | ||
6341 | GFP_KERNEL); | ||
6323 | disable_acs_redir_param = kstrdup(disable_acs_redir_param, GFP_KERNEL); | 6342 | disable_acs_redir_param = kstrdup(disable_acs_redir_param, GFP_KERNEL); |
6324 | 6343 | ||
6325 | return 0; | 6344 | return 0; |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 1be03a97cb92..0113343cfd1e 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -39,6 +39,11 @@ int pci_probe_reset_function(struct pci_dev *dev); | |||
39 | int pci_bridge_secondary_bus_reset(struct pci_dev *dev); | 39 | int pci_bridge_secondary_bus_reset(struct pci_dev *dev); |
40 | int pci_bus_error_reset(struct pci_dev *dev); | 40 | int pci_bus_error_reset(struct pci_dev *dev); |
41 | 41 | ||
42 | #define PCI_PM_D2_DELAY 200 | ||
43 | #define PCI_PM_D3_WAIT 10 | ||
44 | #define PCI_PM_D3COLD_WAIT 100 | ||
45 | #define PCI_PM_BUS_WAIT 50 | ||
46 | |||
42 | /** | 47 | /** |
43 | * struct pci_platform_pm_ops - Firmware PM callbacks | 48 | * struct pci_platform_pm_ops - Firmware PM callbacks |
44 | * | 49 | * |
@@ -84,6 +89,8 @@ void pci_power_up(struct pci_dev *dev); | |||
84 | void pci_disable_enabled_device(struct pci_dev *dev); | 89 | void pci_disable_enabled_device(struct pci_dev *dev); |
85 | int pci_finish_runtime_suspend(struct pci_dev *dev); | 90 | int pci_finish_runtime_suspend(struct pci_dev *dev); |
86 | void pcie_clear_root_pme_status(struct pci_dev *dev); | 91 | void pcie_clear_root_pme_status(struct pci_dev *dev); |
92 | bool pci_check_pme_status(struct pci_dev *dev); | ||
93 | void pci_pme_wakeup_bus(struct pci_bus *bus); | ||
87 | int __pci_pme_wakeup(struct pci_dev *dev, void *ign); | 94 | int __pci_pme_wakeup(struct pci_dev *dev, void *ign); |
88 | void pci_pme_restore(struct pci_dev *dev); | 95 | void pci_pme_restore(struct pci_dev *dev); |
89 | bool pci_dev_need_resume(struct pci_dev *dev); | 96 | bool pci_dev_need_resume(struct pci_dev *dev); |
@@ -118,11 +125,25 @@ static inline bool pci_power_manageable(struct pci_dev *pci_dev) | |||
118 | return !pci_has_subordinate(pci_dev) || pci_dev->bridge_d3; | 125 | return !pci_has_subordinate(pci_dev) || pci_dev->bridge_d3; |
119 | } | 126 | } |
120 | 127 | ||
128 | static inline bool pcie_downstream_port(const struct pci_dev *dev) | ||
129 | { | ||
130 | int type = pci_pcie_type(dev); | ||
131 | |||
132 | return type == PCI_EXP_TYPE_ROOT_PORT || | ||
133 | type == PCI_EXP_TYPE_DOWNSTREAM || | ||
134 | type == PCI_EXP_TYPE_PCIE_BRIDGE; | ||
135 | } | ||
136 | |||
121 | int pci_vpd_init(struct pci_dev *dev); | 137 | int pci_vpd_init(struct pci_dev *dev); |
122 | void pci_vpd_release(struct pci_dev *dev); | 138 | void pci_vpd_release(struct pci_dev *dev); |
123 | void pcie_vpd_create_sysfs_dev_files(struct pci_dev *dev); | 139 | void pcie_vpd_create_sysfs_dev_files(struct pci_dev *dev); |
124 | void pcie_vpd_remove_sysfs_dev_files(struct pci_dev *dev); | 140 | void pcie_vpd_remove_sysfs_dev_files(struct pci_dev *dev); |
125 | 141 | ||
142 | /* PCI Virtual Channel */ | ||
143 | int pci_save_vc_state(struct pci_dev *dev); | ||
144 | void pci_restore_vc_state(struct pci_dev *dev); | ||
145 | void pci_allocate_vc_save_buffers(struct pci_dev *dev); | ||
146 | |||
126 | /* PCI /proc functions */ | 147 | /* PCI /proc functions */ |
127 | #ifdef CONFIG_PROC_FS | 148 | #ifdef CONFIG_PROC_FS |
128 | int pci_proc_attach_device(struct pci_dev *dev); | 149 | int pci_proc_attach_device(struct pci_dev *dev); |
@@ -196,6 +217,9 @@ extern const struct attribute_group *pcibus_groups[]; | |||
196 | extern const struct device_type pci_dev_type; | 217 | extern const struct device_type pci_dev_type; |
197 | extern const struct attribute_group *pci_bus_groups[]; | 218 | extern const struct attribute_group *pci_bus_groups[]; |
198 | 219 | ||
220 | extern unsigned long pci_hotplug_io_size; | ||
221 | extern unsigned long pci_hotplug_mem_size; | ||
222 | extern unsigned long pci_hotplug_bus_size; | ||
199 | 223 | ||
200 | /** | 224 | /** |
201 | * pci_match_one_device - Tell if a PCI device structure has a matching | 225 | * pci_match_one_device - Tell if a PCI device structure has a matching |
@@ -236,6 +260,9 @@ enum pci_bar_type { | |||
236 | pci_bar_mem64, /* A 64-bit memory BAR */ | 260 | pci_bar_mem64, /* A 64-bit memory BAR */ |
237 | }; | 261 | }; |
238 | 262 | ||
263 | struct device *pci_get_host_bridge_device(struct pci_dev *dev); | ||
264 | void pci_put_host_bridge_device(struct device *dev); | ||
265 | |||
239 | int pci_configure_extended_tags(struct pci_dev *dev, void *ign); | 266 | int pci_configure_extended_tags(struct pci_dev *dev, void *ign); |
240 | bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl, | 267 | bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl, |
241 | int crs_timeout); | 268 | int crs_timeout); |
@@ -256,6 +283,8 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx); | |||
256 | 283 | ||
257 | void pci_reassigndev_resource_alignment(struct pci_dev *dev); | 284 | void pci_reassigndev_resource_alignment(struct pci_dev *dev); |
258 | void pci_disable_bridge_window(struct pci_dev *dev); | 285 | void pci_disable_bridge_window(struct pci_dev *dev); |
286 | struct pci_bus *pci_bus_get(struct pci_bus *bus); | ||
287 | void pci_bus_put(struct pci_bus *bus); | ||
259 | 288 | ||
260 | /* PCIe link information */ | 289 | /* PCIe link information */ |
261 | #define PCIE_SPEED2STR(speed) \ | 290 | #define PCIE_SPEED2STR(speed) \ |
@@ -279,6 +308,7 @@ u32 pcie_bandwidth_capable(struct pci_dev *dev, enum pci_bus_speed *speed, | |||
279 | enum pcie_link_width *width); | 308 | enum pcie_link_width *width); |
280 | void __pcie_print_link_status(struct pci_dev *dev, bool verbose); | 309 | void __pcie_print_link_status(struct pci_dev *dev, bool verbose); |
281 | void pcie_report_downtraining(struct pci_dev *dev); | 310 | void pcie_report_downtraining(struct pci_dev *dev); |
311 | void pcie_update_link_speed(struct pci_bus *bus, u16 link_status); | ||
282 | 312 | ||
283 | /* Single Root I/O Virtualization */ | 313 | /* Single Root I/O Virtualization */ |
284 | struct pci_sriov { | 314 | struct pci_sriov { |
@@ -418,11 +448,12 @@ static inline void pci_restore_dpc_state(struct pci_dev *dev) {} | |||
418 | #endif | 448 | #endif |
419 | 449 | ||
420 | #ifdef CONFIG_PCI_ATS | 450 | #ifdef CONFIG_PCI_ATS |
451 | /* Address Translation Service */ | ||
452 | void pci_ats_init(struct pci_dev *dev); | ||
421 | void pci_restore_ats_state(struct pci_dev *dev); | 453 | void pci_restore_ats_state(struct pci_dev *dev); |
422 | #else | 454 | #else |
423 | static inline void pci_restore_ats_state(struct pci_dev *dev) | 455 | static inline void pci_ats_init(struct pci_dev *d) { } |
424 | { | 456 | static inline void pci_restore_ats_state(struct pci_dev *dev) { } |
425 | } | ||
426 | #endif /* CONFIG_PCI_ATS */ | 457 | #endif /* CONFIG_PCI_ATS */ |
427 | 458 | ||
428 | #ifdef CONFIG_PCI_IOV | 459 | #ifdef CONFIG_PCI_IOV |
@@ -433,7 +464,7 @@ void pci_iov_update_resource(struct pci_dev *dev, int resno); | |||
433 | resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); | 464 | resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); |
434 | void pci_restore_iov_state(struct pci_dev *dev); | 465 | void pci_restore_iov_state(struct pci_dev *dev); |
435 | int pci_iov_bus_range(struct pci_bus *bus); | 466 | int pci_iov_bus_range(struct pci_bus *bus); |
436 | 467 | extern const struct attribute_group sriov_dev_attr_group; | |
437 | #else | 468 | #else |
438 | static inline int pci_iov_init(struct pci_dev *dev) | 469 | static inline int pci_iov_init(struct pci_dev *dev) |
439 | { | 470 | { |
@@ -519,10 +550,21 @@ static inline void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) { } | |||
519 | static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) { } | 550 | static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) { } |
520 | #endif | 551 | #endif |
521 | 552 | ||
553 | #ifdef CONFIG_PCIE_ECRC | ||
554 | void pcie_set_ecrc_checking(struct pci_dev *dev); | ||
555 | void pcie_ecrc_get_policy(char *str); | ||
556 | #else | ||
557 | static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { } | ||
558 | static inline void pcie_ecrc_get_policy(char *str) { } | ||
559 | #endif | ||
560 | |||
522 | #ifdef CONFIG_PCIE_PTM | 561 | #ifdef CONFIG_PCIE_PTM |
523 | void pci_ptm_init(struct pci_dev *dev); | 562 | void pci_ptm_init(struct pci_dev *dev); |
563 | int pci_enable_ptm(struct pci_dev *dev, u8 *granularity); | ||
524 | #else | 564 | #else |
525 | static inline void pci_ptm_init(struct pci_dev *dev) { } | 565 | static inline void pci_ptm_init(struct pci_dev *dev) { } |
566 | static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity) | ||
567 | { return -EINVAL; } | ||
526 | #endif | 568 | #endif |
527 | 569 | ||
528 | struct pci_dev_reset_methods { | 570 | struct pci_dev_reset_methods { |
@@ -559,6 +601,10 @@ struct device_node; | |||
559 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); | 601 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); |
560 | int of_get_pci_domain_nr(struct device_node *node); | 602 | int of_get_pci_domain_nr(struct device_node *node); |
561 | int of_pci_get_max_link_speed(struct device_node *node); | 603 | int of_pci_get_max_link_speed(struct device_node *node); |
604 | void pci_set_of_node(struct pci_dev *dev); | ||
605 | void pci_release_of_node(struct pci_dev *dev); | ||
606 | void pci_set_bus_of_node(struct pci_bus *bus); | ||
607 | void pci_release_bus_of_node(struct pci_bus *bus); | ||
562 | 608 | ||
563 | #else | 609 | #else |
564 | static inline int | 610 | static inline int |
@@ -578,6 +624,11 @@ of_pci_get_max_link_speed(struct device_node *node) | |||
578 | { | 624 | { |
579 | return -EINVAL; | 625 | return -EINVAL; |
580 | } | 626 | } |
627 | |||
628 | static inline void pci_set_of_node(struct pci_dev *dev) { } | ||
629 | static inline void pci_release_of_node(struct pci_dev *dev) { } | ||
630 | static inline void pci_set_bus_of_node(struct pci_bus *bus) { } | ||
631 | static inline void pci_release_bus_of_node(struct pci_bus *bus) { } | ||
581 | #endif /* CONFIG_OF */ | 632 | #endif /* CONFIG_OF */ |
582 | 633 | ||
583 | #if defined(CONFIG_OF_ADDRESS) | 634 | #if defined(CONFIG_OF_ADDRESS) |
@@ -608,4 +659,13 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { } | |||
608 | static inline void pci_aer_clear_device_status(struct pci_dev *dev) { } | 659 | static inline void pci_aer_clear_device_status(struct pci_dev *dev) { } |
609 | #endif | 660 | #endif |
610 | 661 | ||
662 | #ifdef CONFIG_ACPI | ||
663 | int pci_acpi_program_hp_params(struct pci_dev *dev); | ||
664 | #else | ||
665 | static inline int pci_acpi_program_hp_params(struct pci_dev *dev) | ||
666 | { | ||
667 | return -ENODEV; | ||
668 | } | ||
669 | #endif | ||
670 | |||
611 | #endif /* DRIVERS_PCI_H */ | 671 | #endif /* DRIVERS_PCI_H */ |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index e44af7f4d37f..55a6951cedd1 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/jiffies.h> | 19 | #include <linux/jiffies.h> |
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/pci-aspm.h> | ||
22 | #include "../pci.h" | 21 | #include "../pci.h" |
23 | 22 | ||
24 | #ifdef MODULE_PARAM_PREFIX | 23 | #ifdef MODULE_PARAM_PREFIX |
@@ -913,10 +912,10 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev) | |||
913 | 912 | ||
914 | /* | 913 | /* |
915 | * We allocate pcie_link_state for the component on the upstream | 914 | * We allocate pcie_link_state for the component on the upstream |
916 | * end of a Link, so there's nothing to do unless this device has a | 915 | * end of a Link, so there's nothing to do unless this device is |
917 | * Link on its secondary side. | 916 | * downstream port. |
918 | */ | 917 | */ |
919 | if (!pdev->has_secondary_link) | 918 | if (!pcie_downstream_port(pdev)) |
920 | return; | 919 | return; |
921 | 920 | ||
922 | /* VIA has a strange chipset, root port is under a bridge */ | 921 | /* VIA has a strange chipset, root port is under a bridge */ |
@@ -1070,7 +1069,7 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) | |||
1070 | if (!pci_is_pcie(pdev)) | 1069 | if (!pci_is_pcie(pdev)) |
1071 | return 0; | 1070 | return 0; |
1072 | 1071 | ||
1073 | if (pdev->has_secondary_link) | 1072 | if (pcie_downstream_port(pdev)) |
1074 | parent = pdev; | 1073 | parent = pdev; |
1075 | if (!parent || !parent->link_state) | 1074 | if (!parent || !parent->link_state) |
1076 | return -EINVAL; | 1075 | return -EINVAL; |
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 773197a12568..b0e6048a9208 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c | |||
@@ -166,7 +166,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev, u32 service) | |||
166 | driver = pcie_port_find_service(dev, service); | 166 | driver = pcie_port_find_service(dev, service); |
167 | if (driver && driver->reset_link) { | 167 | if (driver && driver->reset_link) { |
168 | status = driver->reset_link(dev); | 168 | status = driver->reset_link(dev); |
169 | } else if (dev->has_secondary_link) { | 169 | } else if (pcie_downstream_port(dev)) { |
170 | status = default_reset_link(dev); | 170 | status = default_reset_link(dev); |
171 | } else { | 171 | } else { |
172 | pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", | 172 | pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index a3c7338fad86..3bfa57d58402 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -1431,26 +1431,38 @@ void set_pcie_port_type(struct pci_dev *pdev) | |||
1431 | pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16); | 1431 | pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16); |
1432 | pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; | 1432 | pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; |
1433 | 1433 | ||
1434 | parent = pci_upstream_bridge(pdev); | ||
1435 | if (!parent) | ||
1436 | return; | ||
1437 | |||
1434 | /* | 1438 | /* |
1435 | * A Root Port or a PCI-to-PCIe bridge is always the upstream end | 1439 | * Some systems do not identify their upstream/downstream ports |
1436 | * of a Link. No PCIe component has two Links. Two Links are | 1440 | * correctly so detect impossible configurations here and correct |
1437 | * connected by a Switch that has a Port on each Link and internal | 1441 | * the port type accordingly. |
1438 | * logic to connect the two Ports. | ||
1439 | */ | 1442 | */ |
1440 | type = pci_pcie_type(pdev); | 1443 | type = pci_pcie_type(pdev); |
1441 | if (type == PCI_EXP_TYPE_ROOT_PORT || | 1444 | if (type == PCI_EXP_TYPE_DOWNSTREAM) { |
1442 | type == PCI_EXP_TYPE_PCIE_BRIDGE) | ||
1443 | pdev->has_secondary_link = 1; | ||
1444 | else if (type == PCI_EXP_TYPE_UPSTREAM || | ||
1445 | type == PCI_EXP_TYPE_DOWNSTREAM) { | ||
1446 | parent = pci_upstream_bridge(pdev); | ||
1447 | |||
1448 | /* | 1445 | /* |
1449 | * Usually there's an upstream device (Root Port or Switch | 1446 | * If pdev claims to be downstream port but the parent |
1450 | * Downstream Port), but we can't assume one exists. | 1447 | * device is also downstream port assume pdev is actually |
1448 | * upstream port. | ||
1451 | */ | 1449 | */ |
1452 | if (parent && !parent->has_secondary_link) | 1450 | if (pcie_downstream_port(parent)) { |
1453 | pdev->has_secondary_link = 1; | 1451 | pci_info(pdev, "claims to be downstream port but is acting as upstream port, correcting type\n"); |
1452 | pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE; | ||
1453 | pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM; | ||
1454 | } | ||
1455 | } else if (type == PCI_EXP_TYPE_UPSTREAM) { | ||
1456 | /* | ||
1457 | * If pdev claims to be upstream port but the parent | ||
1458 | * device is also upstream port assume pdev is actually | ||
1459 | * downstream port. | ||
1460 | */ | ||
1461 | if (pci_pcie_type(parent) == PCI_EXP_TYPE_UPSTREAM) { | ||
1462 | pci_info(pdev, "claims to be upstream port but is acting as downstream port, correcting type\n"); | ||
1463 | pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE; | ||
1464 | pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM; | ||
1465 | } | ||
1454 | } | 1466 | } |
1455 | } | 1467 | } |
1456 | 1468 | ||
@@ -1920,275 +1932,6 @@ static void pci_configure_mps(struct pci_dev *dev) | |||
1920 | p_mps, mps, mpss); | 1932 | p_mps, mps, mpss); |
1921 | } | 1933 | } |
1922 | 1934 | ||
1923 | static struct hpp_type0 pci_default_type0 = { | ||
1924 | .revision = 1, | ||
1925 | .cache_line_size = 8, | ||
1926 | .latency_timer = 0x40, | ||
1927 | .enable_serr = 0, | ||
1928 | .enable_perr = 0, | ||
1929 | }; | ||
1930 | |||
1931 | static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp) | ||
1932 | { | ||
1933 | u16 pci_cmd, pci_bctl; | ||
1934 | |||
1935 | if (!hpp) | ||
1936 | hpp = &pci_default_type0; | ||
1937 | |||
1938 | if (hpp->revision > 1) { | ||
1939 | pci_warn(dev, "PCI settings rev %d not supported; using defaults\n", | ||
1940 | hpp->revision); | ||
1941 | hpp = &pci_default_type0; | ||
1942 | } | ||
1943 | |||
1944 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp->cache_line_size); | ||
1945 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp->latency_timer); | ||
1946 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | ||
1947 | if (hpp->enable_serr) | ||
1948 | pci_cmd |= PCI_COMMAND_SERR; | ||
1949 | if (hpp->enable_perr) | ||
1950 | pci_cmd |= PCI_COMMAND_PARITY; | ||
1951 | pci_write_config_word(dev, PCI_COMMAND, pci_cmd); | ||
1952 | |||
1953 | /* Program bridge control value */ | ||
1954 | if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { | ||
1955 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, | ||
1956 | hpp->latency_timer); | ||
1957 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); | ||
1958 | if (hpp->enable_perr) | ||
1959 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; | ||
1960 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl); | ||
1961 | } | ||
1962 | } | ||
1963 | |||
1964 | static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp) | ||
1965 | { | ||
1966 | int pos; | ||
1967 | |||
1968 | if (!hpp) | ||
1969 | return; | ||
1970 | |||
1971 | pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); | ||
1972 | if (!pos) | ||
1973 | return; | ||
1974 | |||
1975 | pci_warn(dev, "PCI-X settings not supported\n"); | ||
1976 | } | ||
1977 | |||
1978 | static bool pcie_root_rcb_set(struct pci_dev *dev) | ||
1979 | { | ||
1980 | struct pci_dev *rp = pcie_find_root_port(dev); | ||
1981 | u16 lnkctl; | ||
1982 | |||
1983 | if (!rp) | ||
1984 | return false; | ||
1985 | |||
1986 | pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl); | ||
1987 | if (lnkctl & PCI_EXP_LNKCTL_RCB) | ||
1988 | return true; | ||
1989 | |||
1990 | return false; | ||
1991 | } | ||
1992 | |||
1993 | static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) | ||
1994 | { | ||
1995 | int pos; | ||
1996 | u32 reg32; | ||
1997 | |||
1998 | if (!hpp) | ||
1999 | return; | ||
2000 | |||
2001 | if (!pci_is_pcie(dev)) | ||
2002 | return; | ||
2003 | |||
2004 | if (hpp->revision > 1) { | ||
2005 | pci_warn(dev, "PCIe settings rev %d not supported\n", | ||
2006 | hpp->revision); | ||
2007 | return; | ||
2008 | } | ||
2009 | |||
2010 | /* | ||
2011 | * Don't allow _HPX to change MPS or MRRS settings. We manage | ||
2012 | * those to make sure they're consistent with the rest of the | ||
2013 | * platform. | ||
2014 | */ | ||
2015 | hpp->pci_exp_devctl_and |= PCI_EXP_DEVCTL_PAYLOAD | | ||
2016 | PCI_EXP_DEVCTL_READRQ; | ||
2017 | hpp->pci_exp_devctl_or &= ~(PCI_EXP_DEVCTL_PAYLOAD | | ||
2018 | PCI_EXP_DEVCTL_READRQ); | ||
2019 | |||
2020 | /* Initialize Device Control Register */ | ||
2021 | pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, | ||
2022 | ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or); | ||
2023 | |||
2024 | /* Initialize Link Control Register */ | ||
2025 | if (pcie_cap_has_lnkctl(dev)) { | ||
2026 | |||
2027 | /* | ||
2028 | * If the Root Port supports Read Completion Boundary of | ||
2029 | * 128, set RCB to 128. Otherwise, clear it. | ||
2030 | */ | ||
2031 | hpp->pci_exp_lnkctl_and |= PCI_EXP_LNKCTL_RCB; | ||
2032 | hpp->pci_exp_lnkctl_or &= ~PCI_EXP_LNKCTL_RCB; | ||
2033 | if (pcie_root_rcb_set(dev)) | ||
2034 | hpp->pci_exp_lnkctl_or |= PCI_EXP_LNKCTL_RCB; | ||
2035 | |||
2036 | pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, | ||
2037 | ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or); | ||
2038 | } | ||
2039 | |||
2040 | /* Find Advanced Error Reporting Enhanced Capability */ | ||
2041 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | ||
2042 | if (!pos) | ||
2043 | return; | ||
2044 | |||
2045 | /* Initialize Uncorrectable Error Mask Register */ | ||
2046 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, ®32); | ||
2047 | reg32 = (reg32 & hpp->unc_err_mask_and) | hpp->unc_err_mask_or; | ||
2048 | pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, reg32); | ||
2049 | |||
2050 | /* Initialize Uncorrectable Error Severity Register */ | ||
2051 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, ®32); | ||
2052 | reg32 = (reg32 & hpp->unc_err_sever_and) | hpp->unc_err_sever_or; | ||
2053 | pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, reg32); | ||
2054 | |||
2055 | /* Initialize Correctable Error Mask Register */ | ||
2056 | pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, ®32); | ||
2057 | reg32 = (reg32 & hpp->cor_err_mask_and) | hpp->cor_err_mask_or; | ||
2058 | pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg32); | ||
2059 | |||
2060 | /* Initialize Advanced Error Capabilities and Control Register */ | ||
2061 | pci_read_config_dword(dev, pos + PCI_ERR_CAP, ®32); | ||
2062 | reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or; | ||
2063 | |||
2064 | /* Don't enable ECRC generation or checking if unsupported */ | ||
2065 | if (!(reg32 & PCI_ERR_CAP_ECRC_GENC)) | ||
2066 | reg32 &= ~PCI_ERR_CAP_ECRC_GENE; | ||
2067 | if (!(reg32 & PCI_ERR_CAP_ECRC_CHKC)) | ||
2068 | reg32 &= ~PCI_ERR_CAP_ECRC_CHKE; | ||
2069 | pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32); | ||
2070 | |||
2071 | /* | ||
2072 | * FIXME: The following two registers are not supported yet. | ||
2073 | * | ||
2074 | * o Secondary Uncorrectable Error Severity Register | ||
2075 | * o Secondary Uncorrectable Error Mask Register | ||
2076 | */ | ||
2077 | } | ||
2078 | |||
2079 | static u16 hpx3_device_type(struct pci_dev *dev) | ||
2080 | { | ||
2081 | u16 pcie_type = pci_pcie_type(dev); | ||
2082 | const int pcie_to_hpx3_type[] = { | ||
2083 | [PCI_EXP_TYPE_ENDPOINT] = HPX_TYPE_ENDPOINT, | ||
2084 | [PCI_EXP_TYPE_LEG_END] = HPX_TYPE_LEG_END, | ||
2085 | [PCI_EXP_TYPE_RC_END] = HPX_TYPE_RC_END, | ||
2086 | [PCI_EXP_TYPE_RC_EC] = HPX_TYPE_RC_EC, | ||
2087 | [PCI_EXP_TYPE_ROOT_PORT] = HPX_TYPE_ROOT_PORT, | ||
2088 | [PCI_EXP_TYPE_UPSTREAM] = HPX_TYPE_UPSTREAM, | ||
2089 | [PCI_EXP_TYPE_DOWNSTREAM] = HPX_TYPE_DOWNSTREAM, | ||
2090 | [PCI_EXP_TYPE_PCI_BRIDGE] = HPX_TYPE_PCI_BRIDGE, | ||
2091 | [PCI_EXP_TYPE_PCIE_BRIDGE] = HPX_TYPE_PCIE_BRIDGE, | ||
2092 | }; | ||
2093 | |||
2094 | if (pcie_type >= ARRAY_SIZE(pcie_to_hpx3_type)) | ||
2095 | return 0; | ||
2096 | |||
2097 | return pcie_to_hpx3_type[pcie_type]; | ||
2098 | } | ||
2099 | |||
2100 | static u8 hpx3_function_type(struct pci_dev *dev) | ||
2101 | { | ||
2102 | if (dev->is_virtfn) | ||
2103 | return HPX_FN_SRIOV_VIRT; | ||
2104 | else if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV) > 0) | ||
2105 | return HPX_FN_SRIOV_PHYS; | ||
2106 | else | ||
2107 | return HPX_FN_NORMAL; | ||
2108 | } | ||
2109 | |||
2110 | static bool hpx3_cap_ver_matches(u8 pcie_cap_id, u8 hpx3_cap_id) | ||
2111 | { | ||
2112 | u8 cap_ver = hpx3_cap_id & 0xf; | ||
2113 | |||
2114 | if ((hpx3_cap_id & BIT(4)) && cap_ver >= pcie_cap_id) | ||
2115 | return true; | ||
2116 | else if (cap_ver == pcie_cap_id) | ||
2117 | return true; | ||
2118 | |||
2119 | return false; | ||
2120 | } | ||
2121 | |||
2122 | static void program_hpx_type3_register(struct pci_dev *dev, | ||
2123 | const struct hpx_type3 *reg) | ||
2124 | { | ||
2125 | u32 match_reg, write_reg, header, orig_value; | ||
2126 | u16 pos; | ||
2127 | |||
2128 | if (!(hpx3_device_type(dev) & reg->device_type)) | ||
2129 | return; | ||
2130 | |||
2131 | if (!(hpx3_function_type(dev) & reg->function_type)) | ||
2132 | return; | ||
2133 | |||
2134 | switch (reg->config_space_location) { | ||
2135 | case HPX_CFG_PCICFG: | ||
2136 | pos = 0; | ||
2137 | break; | ||
2138 | case HPX_CFG_PCIE_CAP: | ||
2139 | pos = pci_find_capability(dev, reg->pci_exp_cap_id); | ||
2140 | if (pos == 0) | ||
2141 | return; | ||
2142 | |||
2143 | break; | ||
2144 | case HPX_CFG_PCIE_CAP_EXT: | ||
2145 | pos = pci_find_ext_capability(dev, reg->pci_exp_cap_id); | ||
2146 | if (pos == 0) | ||
2147 | return; | ||
2148 | |||
2149 | pci_read_config_dword(dev, pos, &header); | ||
2150 | if (!hpx3_cap_ver_matches(PCI_EXT_CAP_VER(header), | ||
2151 | reg->pci_exp_cap_ver)) | ||
2152 | return; | ||
2153 | |||
2154 | break; | ||
2155 | case HPX_CFG_VEND_CAP: /* Fall through */ | ||
2156 | case HPX_CFG_DVSEC: /* Fall through */ | ||
2157 | default: | ||
2158 | pci_warn(dev, "Encountered _HPX type 3 with unsupported config space location"); | ||
2159 | return; | ||
2160 | } | ||
2161 | |||
2162 | pci_read_config_dword(dev, pos + reg->match_offset, &match_reg); | ||
2163 | |||
2164 | if ((match_reg & reg->match_mask_and) != reg->match_value) | ||
2165 | return; | ||
2166 | |||
2167 | pci_read_config_dword(dev, pos + reg->reg_offset, &write_reg); | ||
2168 | orig_value = write_reg; | ||
2169 | write_reg &= reg->reg_mask_and; | ||
2170 | write_reg |= reg->reg_mask_or; | ||
2171 | |||
2172 | if (orig_value == write_reg) | ||
2173 | return; | ||
2174 | |||
2175 | pci_write_config_dword(dev, pos + reg->reg_offset, write_reg); | ||
2176 | |||
2177 | pci_dbg(dev, "Applied _HPX3 at [0x%x]: 0x%08x -> 0x%08x", | ||
2178 | pos, orig_value, write_reg); | ||
2179 | } | ||
2180 | |||
2181 | static void program_hpx_type3(struct pci_dev *dev, struct hpx_type3 *hpx3) | ||
2182 | { | ||
2183 | if (!hpx3) | ||
2184 | return; | ||
2185 | |||
2186 | if (!pci_is_pcie(dev)) | ||
2187 | return; | ||
2188 | |||
2189 | program_hpx_type3_register(dev, hpx3); | ||
2190 | } | ||
2191 | |||
2192 | int pci_configure_extended_tags(struct pci_dev *dev, void *ign) | 1935 | int pci_configure_extended_tags(struct pci_dev *dev, void *ign) |
2193 | { | 1936 | { |
2194 | struct pci_host_bridge *host; | 1937 | struct pci_host_bridge *host; |
@@ -2369,13 +2112,6 @@ static void pci_configure_serr(struct pci_dev *dev) | |||
2369 | 2112 | ||
2370 | static void pci_configure_device(struct pci_dev *dev) | 2113 | static void pci_configure_device(struct pci_dev *dev) |
2371 | { | 2114 | { |
2372 | static const struct hotplug_program_ops hp_ops = { | ||
2373 | .program_type0 = program_hpp_type0, | ||
2374 | .program_type1 = program_hpp_type1, | ||
2375 | .program_type2 = program_hpp_type2, | ||
2376 | .program_type3 = program_hpx_type3, | ||
2377 | }; | ||
2378 | |||
2379 | pci_configure_mps(dev); | 2115 | pci_configure_mps(dev); |
2380 | pci_configure_extended_tags(dev, NULL); | 2116 | pci_configure_extended_tags(dev, NULL); |
2381 | pci_configure_relaxed_ordering(dev); | 2117 | pci_configure_relaxed_ordering(dev); |
@@ -2383,7 +2119,7 @@ static void pci_configure_device(struct pci_dev *dev) | |||
2383 | pci_configure_eetlp_prefix(dev); | 2119 | pci_configure_eetlp_prefix(dev); |
2384 | pci_configure_serr(dev); | 2120 | pci_configure_serr(dev); |
2385 | 2121 | ||
2386 | pci_acpi_program_hp_params(dev, &hp_ops); | 2122 | pci_acpi_program_hp_params(dev); |
2387 | } | 2123 | } |
2388 | 2124 | ||
2389 | static void pci_release_capabilities(struct pci_dev *dev) | 2125 | static void pci_release_capabilities(struct pci_dev *dev) |
@@ -2764,12 +2500,8 @@ static int only_one_child(struct pci_bus *bus) | |||
2764 | * A PCIe Downstream Port normally leads to a Link with only Device | 2500 | * A PCIe Downstream Port normally leads to a Link with only Device |
2765 | * 0 on it (PCIe spec r3.1, sec 7.3.1). As an optimization, scan | 2501 | * 0 on it (PCIe spec r3.1, sec 7.3.1). As an optimization, scan |
2766 | * only for Device 0 in that situation. | 2502 | * only for Device 0 in that situation. |
2767 | * | ||
2768 | * Checking has_secondary_link is a hack to identify Downstream | ||
2769 | * Ports because sometimes Switches are configured such that the | ||
2770 | * PCIe Port Type labels are backwards. | ||
2771 | */ | 2503 | */ |
2772 | if (bridge && pci_is_pcie(bridge) && bridge->has_secondary_link) | 2504 | if (bridge && pci_is_pcie(bridge) && pcie_downstream_port(bridge)) |
2773 | return 1; | 2505 | return 1; |
2774 | 2506 | ||
2775 | return 0; | 2507 | return 0; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 208aacf39329..87f591caccd9 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/acpi.h> | 21 | #include <linux/acpi.h> |
22 | #include <linux/dmi.h> | 22 | #include <linux/dmi.h> |
23 | #include <linux/pci-aspm.h> | ||
24 | #include <linux/ioport.h> | 23 | #include <linux/ioport.h> |
25 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
26 | #include <linux/ktime.h> | 25 | #include <linux/ktime.h> |
@@ -2925,6 +2924,24 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x10a1, | |||
2925 | quirk_msi_intx_disable_qca_bug); | 2924 | quirk_msi_intx_disable_qca_bug); |
2926 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0xe091, | 2925 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0xe091, |
2927 | quirk_msi_intx_disable_qca_bug); | 2926 | quirk_msi_intx_disable_qca_bug); |
2927 | |||
2928 | /* | ||
2929 | * Amazon's Annapurna Labs 1c36:0031 Root Ports don't support MSI-X, so it | ||
2930 | * should be disabled on platforms where the device (mistakenly) advertises it. | ||
2931 | * | ||
2932 | * Notice that this quirk also disables MSI (which may work, but hasn't been | ||
2933 | * tested), since currently there is no standard way to disable only MSI-X. | ||
2934 | * | ||
2935 | * The 0031 device id is reused for other non Root Port device types, | ||
2936 | * therefore the quirk is registered for the PCI_CLASS_BRIDGE_PCI class. | ||
2937 | */ | ||
2938 | static void quirk_al_msi_disable(struct pci_dev *dev) | ||
2939 | { | ||
2940 | dev->no_msi = 1; | ||
2941 | pci_warn(dev, "Disabling MSI/MSI-X\n"); | ||
2942 | } | ||
2943 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, | ||
2944 | PCI_CLASS_BRIDGE_PCI, 8, quirk_al_msi_disable); | ||
2928 | #endif /* CONFIG_PCI_MSI */ | 2945 | #endif /* CONFIG_PCI_MSI */ |
2929 | 2946 | ||
2930 | /* | 2947 | /* |
@@ -4366,6 +4383,24 @@ static int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags) | |||
4366 | return ret; | 4383 | return ret; |
4367 | } | 4384 | } |
4368 | 4385 | ||
4386 | static int pci_quirk_al_acs(struct pci_dev *dev, u16 acs_flags) | ||
4387 | { | ||
4388 | if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) | ||
4389 | return -ENOTTY; | ||
4390 | |||
4391 | /* | ||
4392 | * Amazon's Annapurna Labs root ports don't include an ACS capability, | ||
4393 | * but do include ACS-like functionality. The hardware doesn't support | ||
4394 | * peer-to-peer transactions via the root port and each has a unique | ||
4395 | * segment number. | ||
4396 | * | ||
4397 | * Additionally, the root ports cannot send traffic to each other. | ||
4398 | */ | ||
4399 | acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); | ||
4400 | |||
4401 | return acs_flags ? 0 : 1; | ||
4402 | } | ||
4403 | |||
4369 | /* | 4404 | /* |
4370 | * Sunrise Point PCH root ports implement ACS, but unfortunately as shown in | 4405 | * Sunrise Point PCH root ports implement ACS, but unfortunately as shown in |
4371 | * the datasheet (Intel 100 Series Chipset Family PCH Datasheet, Vol. 2, | 4406 | * the datasheet (Intel 100 Series Chipset Family PCH Datasheet, Vol. 2, |
@@ -4466,6 +4501,19 @@ static int pci_quirk_mf_endpoint_acs(struct pci_dev *dev, u16 acs_flags) | |||
4466 | return acs_flags ? 0 : 1; | 4501 | return acs_flags ? 0 : 1; |
4467 | } | 4502 | } |
4468 | 4503 | ||
4504 | static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags) | ||
4505 | { | ||
4506 | /* | ||
4507 | * iProc PAXB Root Ports don't advertise an ACS capability, but | ||
4508 | * they do not allow peer-to-peer transactions between Root Ports. | ||
4509 | * Allow each Root Port to be in a separate IOMMU group by masking | ||
4510 | * SV/RR/CR/UF bits. | ||
4511 | */ | ||
4512 | acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); | ||
4513 | |||
4514 | return acs_flags ? 0 : 1; | ||
4515 | } | ||
4516 | |||
4469 | static const struct pci_dev_acs_enabled { | 4517 | static const struct pci_dev_acs_enabled { |
4470 | u16 vendor; | 4518 | u16 vendor; |
4471 | u16 device; | 4519 | u16 device; |
@@ -4559,6 +4607,9 @@ static const struct pci_dev_acs_enabled { | |||
4559 | { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs }, | 4607 | { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs }, |
4560 | { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs }, | 4608 | { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs }, |
4561 | { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs }, | 4609 | { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs }, |
4610 | { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs }, | ||
4611 | /* Amazon Annapurna Labs */ | ||
4612 | { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs }, | ||
4562 | { 0 } | 4613 | { 0 } |
4563 | }; | 4614 | }; |
4564 | 4615 | ||
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 7f4e65872b8d..bade14002fd8 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include "pci.h" | 15 | #include "pci.h" |
16 | 16 | ||
17 | DECLARE_RWSEM(pci_bus_sem); | 17 | DECLARE_RWSEM(pci_bus_sem); |
18 | EXPORT_SYMBOL_GPL(pci_bus_sem); | ||
19 | 18 | ||
20 | /* | 19 | /* |
21 | * pci_for_each_dma_alias - Iterate over DMA aliases for a device | 20 | * pci_for_each_dma_alias - Iterate over DMA aliases for a device |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 79b1fa6519be..e7dbe21705ba 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1662,8 +1662,8 @@ static int iov_resources_unassigned(struct pci_dev *dev, void *data) | |||
1662 | int i; | 1662 | int i; |
1663 | bool *unassigned = data; | 1663 | bool *unassigned = data; |
1664 | 1664 | ||
1665 | for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { | 1665 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { |
1666 | struct resource *r = &dev->resource[i]; | 1666 | struct resource *r = &dev->resource[i + PCI_IOV_RESOURCES]; |
1667 | struct pci_bus_region region; | 1667 | struct pci_bus_region region; |
1668 | 1668 | ||
1669 | /* Not assigned or rejected by kernel? */ | 1669 | /* Not assigned or rejected by kernel? */ |
diff --git a/drivers/pci/vc.c b/drivers/pci/vc.c index 5acd9c02683a..9ae9fb9339e8 100644 --- a/drivers/pci/vc.c +++ b/drivers/pci/vc.c | |||
@@ -13,6 +13,8 @@ | |||
13 | #include <linux/pci_regs.h> | 13 | #include <linux/pci_regs.h> |
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | 15 | ||
16 | #include "pci.h" | ||
17 | |||
16 | /** | 18 | /** |
17 | * pci_vc_save_restore_dwords - Save or restore a series of dwords | 19 | * pci_vc_save_restore_dwords - Save or restore a series of dwords |
18 | * @dev: device | 20 | * @dev: device |
@@ -105,7 +107,7 @@ static void pci_vc_enable(struct pci_dev *dev, int pos, int res) | |||
105 | struct pci_dev *link = NULL; | 107 | struct pci_dev *link = NULL; |
106 | 108 | ||
107 | /* Enable VCs from the downstream device */ | 109 | /* Enable VCs from the downstream device */ |
108 | if (!dev->has_secondary_link) | 110 | if (!pci_is_pcie(dev) || !pcie_downstream_port(dev)) |
109 | return; | 111 | return; |
110 | 112 | ||
111 | ctrl_pos = pos + PCI_VC_RES_CTRL + (res * PCI_CAP_VC_PER_VC_SIZEOF); | 113 | ctrl_pos = pos + PCI_VC_RES_CTRL + (res * PCI_CAP_VC_PER_VC_SIZEOF); |
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 4963c2e2bd4c..7915d10f9aa1 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c | |||
@@ -571,6 +571,12 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005f, quirk_blacklist_vpd); | |||
571 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID, | 571 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID, |
572 | quirk_blacklist_vpd); | 572 | quirk_blacklist_vpd); |
573 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_QLOGIC, 0x2261, quirk_blacklist_vpd); | 573 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_QLOGIC, 0x2261, quirk_blacklist_vpd); |
574 | /* | ||
575 | * The Amazon Annapurna Labs 0x0031 device id is reused for other non Root Port | ||
576 | * device types, so the quirk is registered for the PCI_CLASS_BRIDGE_PCI class. | ||
577 | */ | ||
578 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, | ||
579 | PCI_CLASS_BRIDGE_PCI, 8, quirk_blacklist_vpd); | ||
574 | 580 | ||
575 | /* | 581 | /* |
576 | * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the | 582 | * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 644f7f5c61a2..4a858789e6c5 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/pci.h> | 28 | #include <linux/pci.h> |
29 | #include <linux/aer.h> | 29 | #include <linux/aer.h> |
30 | #include <linux/pci-aspm.h> | ||
31 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
32 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
33 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 43a6b5350775..148663373f7d 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
24 | #include <linux/pci-aspm.h> | ||
25 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
27 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 717ba0845a2a..27fdbc165446 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c | |||
@@ -51,7 +51,6 @@ | |||
51 | #include <linux/workqueue.h> | 51 | #include <linux/workqueue.h> |
52 | #include <linux/delay.h> | 52 | #include <linux/delay.h> |
53 | #include <linux/pci.h> | 53 | #include <linux/pci.h> |
54 | #include <linux/pci-aspm.h> | ||
55 | #include <linux/interrupt.h> | 54 | #include <linux/interrupt.h> |
56 | #include <linux/aer.h> | 55 | #include <linux/aer.h> |
57 | #include <linux/raid_class.h> | 56 | #include <linux/raid_class.h> |
diff --git a/include/linux/memremap.h b/include/linux/memremap.h index f8a5b2a19945..b459518ce475 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h | |||
@@ -112,7 +112,6 @@ struct dev_pagemap { | |||
112 | struct device *dev; | 112 | struct device *dev; |
113 | enum memory_type type; | 113 | enum memory_type type; |
114 | unsigned int flags; | 114 | unsigned int flags; |
115 | u64 pci_p2pdma_bus_offset; | ||
116 | const struct dev_pagemap_ops *ops; | 115 | const struct dev_pagemap_ops *ops; |
117 | }; | 116 | }; |
118 | 117 | ||
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h deleted file mode 100644 index 67064145d76e..000000000000 --- a/include/linux/pci-aspm.h +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* | ||
3 | * aspm.h | ||
4 | * | ||
5 | * PCI Express ASPM defines and function prototypes | ||
6 | * | ||
7 | * Copyright (C) 2007 Intel Corp. | ||
8 | * Zhang Yanmin (yanmin.zhang@intel.com) | ||
9 | * Shaohua Li (shaohua.li@intel.com) | ||
10 | * | ||
11 | * For more information, please consult the following manuals (look at | ||
12 | * http://www.pcisig.com/ for how to get them): | ||
13 | * | ||
14 | * PCI Express Specification | ||
15 | */ | ||
16 | |||
17 | #ifndef LINUX_ASPM_H | ||
18 | #define LINUX_ASPM_H | ||
19 | |||
20 | #include <linux/pci.h> | ||
21 | |||
22 | #define PCIE_LINK_STATE_L0S 1 | ||
23 | #define PCIE_LINK_STATE_L1 2 | ||
24 | #define PCIE_LINK_STATE_CLKPM 4 | ||
25 | |||
26 | #ifdef CONFIG_PCIEASPM | ||
27 | int pci_disable_link_state(struct pci_dev *pdev, int state); | ||
28 | int pci_disable_link_state_locked(struct pci_dev *pdev, int state); | ||
29 | void pcie_no_aspm(void); | ||
30 | #else | ||
31 | static inline int pci_disable_link_state(struct pci_dev *pdev, int state) | ||
32 | { return 0; } | ||
33 | static inline void pcie_no_aspm(void) { } | ||
34 | #endif | ||
35 | |||
36 | #endif /* LINUX_ASPM_H */ | ||
diff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h index bca9bc3e5be7..8318a97c9c61 100644 --- a/include/linux/pci-p2pdma.h +++ b/include/linux/pci-p2pdma.h | |||
@@ -30,8 +30,10 @@ struct scatterlist *pci_p2pmem_alloc_sgl(struct pci_dev *pdev, | |||
30 | unsigned int *nents, u32 length); | 30 | unsigned int *nents, u32 length); |
31 | void pci_p2pmem_free_sgl(struct pci_dev *pdev, struct scatterlist *sgl); | 31 | void pci_p2pmem_free_sgl(struct pci_dev *pdev, struct scatterlist *sgl); |
32 | void pci_p2pmem_publish(struct pci_dev *pdev, bool publish); | 32 | void pci_p2pmem_publish(struct pci_dev *pdev, bool publish); |
33 | int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | 33 | int pci_p2pdma_map_sg_attrs(struct device *dev, struct scatterlist *sg, |
34 | enum dma_data_direction dir); | 34 | int nents, enum dma_data_direction dir, unsigned long attrs); |
35 | void pci_p2pdma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, | ||
36 | int nents, enum dma_data_direction dir, unsigned long attrs); | ||
35 | int pci_p2pdma_enable_store(const char *page, struct pci_dev **p2p_dev, | 37 | int pci_p2pdma_enable_store(const char *page, struct pci_dev **p2p_dev, |
36 | bool *use_p2pdma); | 38 | bool *use_p2pdma); |
37 | ssize_t pci_p2pdma_enable_show(char *page, struct pci_dev *p2p_dev, | 39 | ssize_t pci_p2pdma_enable_show(char *page, struct pci_dev *p2p_dev, |
@@ -81,11 +83,17 @@ static inline void pci_p2pmem_free_sgl(struct pci_dev *pdev, | |||
81 | static inline void pci_p2pmem_publish(struct pci_dev *pdev, bool publish) | 83 | static inline void pci_p2pmem_publish(struct pci_dev *pdev, bool publish) |
82 | { | 84 | { |
83 | } | 85 | } |
84 | static inline int pci_p2pdma_map_sg(struct device *dev, | 86 | static inline int pci_p2pdma_map_sg_attrs(struct device *dev, |
85 | struct scatterlist *sg, int nents, enum dma_data_direction dir) | 87 | struct scatterlist *sg, int nents, enum dma_data_direction dir, |
88 | unsigned long attrs) | ||
86 | { | 89 | { |
87 | return 0; | 90 | return 0; |
88 | } | 91 | } |
92 | static inline void pci_p2pdma_unmap_sg_attrs(struct device *dev, | ||
93 | struct scatterlist *sg, int nents, enum dma_data_direction dir, | ||
94 | unsigned long attrs) | ||
95 | { | ||
96 | } | ||
89 | static inline int pci_p2pdma_enable_store(const char *page, | 97 | static inline int pci_p2pdma_enable_store(const char *page, |
90 | struct pci_dev **p2p_dev, bool *use_p2pdma) | 98 | struct pci_dev **p2p_dev, bool *use_p2pdma) |
91 | { | 99 | { |
@@ -111,4 +119,16 @@ static inline struct pci_dev *pci_p2pmem_find(struct device *client) | |||
111 | return pci_p2pmem_find_many(&client, 1); | 119 | return pci_p2pmem_find_many(&client, 1); |
112 | } | 120 | } |
113 | 121 | ||
122 | static inline int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, | ||
123 | int nents, enum dma_data_direction dir) | ||
124 | { | ||
125 | return pci_p2pdma_map_sg_attrs(dev, sg, nents, dir, 0); | ||
126 | } | ||
127 | |||
128 | static inline void pci_p2pdma_unmap_sg(struct device *dev, | ||
129 | struct scatterlist *sg, int nents, enum dma_data_direction dir) | ||
130 | { | ||
131 | pci_p2pdma_unmap_sg_attrs(dev, sg, nents, dir, 0); | ||
132 | } | ||
133 | |||
114 | #endif /* _LINUX_PCI_P2P_H */ | 134 | #endif /* _LINUX_PCI_P2P_H */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 9e700d9f9f28..c1c2e4c7242a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -6,12 +6,18 @@ | |||
6 | * Copyright 1994, Drew Eckhardt | 6 | * Copyright 1994, Drew Eckhardt |
7 | * Copyright 1997--1999 Martin Mares <mj@ucw.cz> | 7 | * Copyright 1997--1999 Martin Mares <mj@ucw.cz> |
8 | * | 8 | * |
9 | * PCI Express ASPM defines and function prototypes | ||
10 | * Copyright (c) 2007 Intel Corp. | ||
11 | * Zhang Yanmin (yanmin.zhang@intel.com) | ||
12 | * Shaohua Li (shaohua.li@intel.com) | ||
13 | * | ||
9 | * For more information, please consult the following manuals (look at | 14 | * For more information, please consult the following manuals (look at |
10 | * http://www.pcisig.com/ for how to get them): | 15 | * http://www.pcisig.com/ for how to get them): |
11 | * | 16 | * |
12 | * PCI BIOS Specification | 17 | * PCI BIOS Specification |
13 | * PCI Local Bus Specification | 18 | * PCI Local Bus Specification |
14 | * PCI to PCI Bridge Specification | 19 | * PCI to PCI Bridge Specification |
20 | * PCI Express Specification | ||
15 | * PCI System Design Guide | 21 | * PCI System Design Guide |
16 | */ | 22 | */ |
17 | #ifndef LINUX_PCI_H | 23 | #ifndef LINUX_PCI_H |
@@ -145,11 +151,6 @@ static inline const char *pci_power_name(pci_power_t state) | |||
145 | return pci_power_names[1 + (__force int) state]; | 151 | return pci_power_names[1 + (__force int) state]; |
146 | } | 152 | } |
147 | 153 | ||
148 | #define PCI_PM_D2_DELAY 200 | ||
149 | #define PCI_PM_D3_WAIT 10 | ||
150 | #define PCI_PM_D3COLD_WAIT 100 | ||
151 | #define PCI_PM_BUS_WAIT 50 | ||
152 | |||
153 | /** | 154 | /** |
154 | * typedef pci_channel_state_t | 155 | * typedef pci_channel_state_t |
155 | * | 156 | * |
@@ -418,7 +419,6 @@ struct pci_dev { | |||
418 | unsigned int broken_intx_masking:1; /* INTx masking can't be used */ | 419 | unsigned int broken_intx_masking:1; /* INTx masking can't be used */ |
419 | unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */ | 420 | unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */ |
420 | unsigned int irq_managed:1; | 421 | unsigned int irq_managed:1; |
421 | unsigned int has_secondary_link:1; | ||
422 | unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */ | 422 | unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */ |
423 | unsigned int is_probed:1; /* Device probing in progress */ | 423 | unsigned int is_probed:1; /* Device probing in progress */ |
424 | unsigned int link_active_reporting:1;/* Device capable of reporting link active */ | 424 | unsigned int link_active_reporting:1;/* Device capable of reporting link active */ |
@@ -649,9 +649,6 @@ static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) | |||
649 | return dev->bus->self; | 649 | return dev->bus->self; |
650 | } | 650 | } |
651 | 651 | ||
652 | struct device *pci_get_host_bridge_device(struct pci_dev *dev); | ||
653 | void pci_put_host_bridge_device(struct device *dev); | ||
654 | |||
655 | #ifdef CONFIG_PCI_MSI | 652 | #ifdef CONFIG_PCI_MSI |
656 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) | 653 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) |
657 | { | 654 | { |
@@ -925,6 +922,11 @@ enum { | |||
925 | PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* Scan all, not just dev 0 */ | 922 | PCI_SCAN_ALL_PCIE_DEVS = 0x00000040, /* Scan all, not just dev 0 */ |
926 | }; | 923 | }; |
927 | 924 | ||
925 | #define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */ | ||
926 | #define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */ | ||
927 | #define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */ | ||
928 | #define PCI_IRQ_AFFINITY (1 << 3) /* Auto-assign affinity */ | ||
929 | |||
928 | /* These external functions are only available when PCI support is enabled */ | 930 | /* These external functions are only available when PCI support is enabled */ |
929 | #ifdef CONFIG_PCI | 931 | #ifdef CONFIG_PCI |
930 | 932 | ||
@@ -995,7 +997,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, | |||
995 | int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge); | 997 | int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge); |
996 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | 998 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, |
997 | int busnr); | 999 | int busnr); |
998 | void pcie_update_link_speed(struct pci_bus *bus, u16 link_status); | ||
999 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | 1000 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, |
1000 | const char *name, | 1001 | const char *name, |
1001 | struct hotplug_slot *hotplug); | 1002 | struct hotplug_slot *hotplug); |
@@ -1241,19 +1242,12 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable); | |||
1241 | int pci_prepare_to_sleep(struct pci_dev *dev); | 1242 | int pci_prepare_to_sleep(struct pci_dev *dev); |
1242 | int pci_back_from_sleep(struct pci_dev *dev); | 1243 | int pci_back_from_sleep(struct pci_dev *dev); |
1243 | bool pci_dev_run_wake(struct pci_dev *dev); | 1244 | bool pci_dev_run_wake(struct pci_dev *dev); |
1244 | bool pci_check_pme_status(struct pci_dev *dev); | ||
1245 | void pci_pme_wakeup_bus(struct pci_bus *bus); | ||
1246 | void pci_d3cold_enable(struct pci_dev *dev); | 1245 | void pci_d3cold_enable(struct pci_dev *dev); |
1247 | void pci_d3cold_disable(struct pci_dev *dev); | 1246 | void pci_d3cold_disable(struct pci_dev *dev); |
1248 | bool pcie_relaxed_ordering_enabled(struct pci_dev *dev); | 1247 | bool pcie_relaxed_ordering_enabled(struct pci_dev *dev); |
1249 | void pci_wakeup_bus(struct pci_bus *bus); | 1248 | void pci_wakeup_bus(struct pci_bus *bus); |
1250 | void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state); | 1249 | void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state); |
1251 | 1250 | ||
1252 | /* PCI Virtual Channel */ | ||
1253 | int pci_save_vc_state(struct pci_dev *dev); | ||
1254 | void pci_restore_vc_state(struct pci_dev *dev); | ||
1255 | void pci_allocate_vc_save_buffers(struct pci_dev *dev); | ||
1256 | |||
1257 | /* For use by arch with custom probe code */ | 1251 | /* For use by arch with custom probe code */ |
1258 | void set_pcie_port_type(struct pci_dev *pdev); | 1252 | void set_pcie_port_type(struct pci_dev *pdev); |
1259 | void set_pcie_hotplug_bridge(struct pci_dev *pdev); | 1253 | void set_pcie_hotplug_bridge(struct pci_dev *pdev); |
@@ -1297,8 +1291,6 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *); | |||
1297 | void pci_release_selected_regions(struct pci_dev *, int); | 1291 | void pci_release_selected_regions(struct pci_dev *, int); |
1298 | 1292 | ||
1299 | /* drivers/pci/bus.c */ | 1293 | /* drivers/pci/bus.c */ |
1300 | struct pci_bus *pci_bus_get(struct pci_bus *bus); | ||
1301 | void pci_bus_put(struct pci_bus *bus); | ||
1302 | void pci_add_resource(struct list_head *resources, struct resource *res); | 1294 | void pci_add_resource(struct list_head *resources, struct resource *res); |
1303 | void pci_add_resource_offset(struct list_head *resources, struct resource *res, | 1295 | void pci_add_resource_offset(struct list_head *resources, struct resource *res, |
1304 | resource_size_t offset); | 1296 | resource_size_t offset); |
@@ -1408,11 +1400,6 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus, | |||
1408 | int pci_set_vga_state(struct pci_dev *pdev, bool decode, | 1400 | int pci_set_vga_state(struct pci_dev *pdev, bool decode, |
1409 | unsigned int command_bits, u32 flags); | 1401 | unsigned int command_bits, u32 flags); |
1410 | 1402 | ||
1411 | #define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */ | ||
1412 | #define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */ | ||
1413 | #define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */ | ||
1414 | #define PCI_IRQ_AFFINITY (1 << 3) /* Auto-assign affinity */ | ||
1415 | |||
1416 | /* | 1403 | /* |
1417 | * Virtual interrupts allow for more interrupts to be allocated | 1404 | * Virtual interrupts allow for more interrupts to be allocated |
1418 | * than the device has interrupts for. These are not programmed | 1405 | * than the device has interrupts for. These are not programmed |
@@ -1517,14 +1504,6 @@ static inline int pci_irq_get_node(struct pci_dev *pdev, int vec) | |||
1517 | } | 1504 | } |
1518 | #endif | 1505 | #endif |
1519 | 1506 | ||
1520 | static inline int | ||
1521 | pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, | ||
1522 | unsigned int max_vecs, unsigned int flags) | ||
1523 | { | ||
1524 | return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, | ||
1525 | NULL); | ||
1526 | } | ||
1527 | |||
1528 | /** | 1507 | /** |
1529 | * pci_irqd_intx_xlate() - Translate PCI INTx value to an IRQ domain hwirq | 1508 | * pci_irqd_intx_xlate() - Translate PCI INTx value to an IRQ domain hwirq |
1530 | * @d: the INTx IRQ domain | 1509 | * @d: the INTx IRQ domain |
@@ -1565,9 +1544,21 @@ extern bool pcie_ports_native; | |||
1565 | #define pcie_ports_native false | 1544 | #define pcie_ports_native false |
1566 | #endif | 1545 | #endif |
1567 | 1546 | ||
1547 | #define PCIE_LINK_STATE_L0S 1 | ||
1548 | #define PCIE_LINK_STATE_L1 2 | ||
1549 | #define PCIE_LINK_STATE_CLKPM 4 | ||
1550 | |||
1568 | #ifdef CONFIG_PCIEASPM | 1551 | #ifdef CONFIG_PCIEASPM |
1552 | int pci_disable_link_state(struct pci_dev *pdev, int state); | ||
1553 | int pci_disable_link_state_locked(struct pci_dev *pdev, int state); | ||
1554 | void pcie_no_aspm(void); | ||
1569 | bool pcie_aspm_support_enabled(void); | 1555 | bool pcie_aspm_support_enabled(void); |
1570 | #else | 1556 | #else |
1557 | static inline int pci_disable_link_state(struct pci_dev *pdev, int state) | ||
1558 | { return 0; } | ||
1559 | static inline int pci_disable_link_state_locked(struct pci_dev *pdev, int state) | ||
1560 | { return 0; } | ||
1561 | static inline void pcie_no_aspm(void) { } | ||
1571 | static inline bool pcie_aspm_support_enabled(void) { return false; } | 1562 | static inline bool pcie_aspm_support_enabled(void) { return false; } |
1572 | #endif | 1563 | #endif |
1573 | 1564 | ||
@@ -1577,23 +1568,8 @@ bool pci_aer_available(void); | |||
1577 | static inline bool pci_aer_available(void) { return false; } | 1568 | static inline bool pci_aer_available(void) { return false; } |
1578 | #endif | 1569 | #endif |
1579 | 1570 | ||
1580 | #ifdef CONFIG_PCIE_ECRC | ||
1581 | void pcie_set_ecrc_checking(struct pci_dev *dev); | ||
1582 | void pcie_ecrc_get_policy(char *str); | ||
1583 | #else | ||
1584 | static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { } | ||
1585 | static inline void pcie_ecrc_get_policy(char *str) { } | ||
1586 | #endif | ||
1587 | |||
1588 | bool pci_ats_disabled(void); | 1571 | bool pci_ats_disabled(void); |
1589 | 1572 | ||
1590 | #ifdef CONFIG_PCIE_PTM | ||
1591 | int pci_enable_ptm(struct pci_dev *dev, u8 *granularity); | ||
1592 | #else | ||
1593 | static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity) | ||
1594 | { return -EINVAL; } | ||
1595 | #endif | ||
1596 | |||
1597 | void pci_cfg_access_lock(struct pci_dev *dev); | 1573 | void pci_cfg_access_lock(struct pci_dev *dev); |
1598 | bool pci_cfg_access_trylock(struct pci_dev *dev); | 1574 | bool pci_cfg_access_trylock(struct pci_dev *dev); |
1599 | void pci_cfg_access_unlock(struct pci_dev *dev); | 1575 | void pci_cfg_access_unlock(struct pci_dev *dev); |
@@ -1747,11 +1723,6 @@ static inline void pci_release_regions(struct pci_dev *dev) { } | |||
1747 | 1723 | ||
1748 | static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } | 1724 | static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } |
1749 | 1725 | ||
1750 | static inline void pci_block_cfg_access(struct pci_dev *dev) { } | ||
1751 | static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev) | ||
1752 | { return 0; } | ||
1753 | static inline void pci_unblock_cfg_access(struct pci_dev *dev) { } | ||
1754 | |||
1755 | static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) | 1726 | static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) |
1756 | { return NULL; } | 1727 | { return NULL; } |
1757 | static inline struct pci_dev *pci_get_slot(struct pci_bus *bus, | 1728 | static inline struct pci_dev *pci_get_slot(struct pci_bus *bus, |
@@ -1780,17 +1751,36 @@ static inline const struct pci_device_id *pci_match_id(const struct pci_device_i | |||
1780 | struct pci_dev *dev) | 1751 | struct pci_dev *dev) |
1781 | { return NULL; } | 1752 | { return NULL; } |
1782 | static inline bool pci_ats_disabled(void) { return true; } | 1753 | static inline bool pci_ats_disabled(void) { return true; } |
1754 | |||
1755 | static inline int pci_irq_vector(struct pci_dev *dev, unsigned int nr) | ||
1756 | { | ||
1757 | return -EINVAL; | ||
1758 | } | ||
1759 | |||
1760 | static inline int | ||
1761 | pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, | ||
1762 | unsigned int max_vecs, unsigned int flags, | ||
1763 | struct irq_affinity *aff_desc) | ||
1764 | { | ||
1765 | return -ENOSPC; | ||
1766 | } | ||
1783 | #endif /* CONFIG_PCI */ | 1767 | #endif /* CONFIG_PCI */ |
1784 | 1768 | ||
1769 | static inline int | ||
1770 | pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, | ||
1771 | unsigned int max_vecs, unsigned int flags) | ||
1772 | { | ||
1773 | return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, | ||
1774 | NULL); | ||
1775 | } | ||
1776 | |||
1785 | #ifdef CONFIG_PCI_ATS | 1777 | #ifdef CONFIG_PCI_ATS |
1786 | /* Address Translation Service */ | 1778 | /* Address Translation Service */ |
1787 | void pci_ats_init(struct pci_dev *dev); | ||
1788 | int pci_enable_ats(struct pci_dev *dev, int ps); | 1779 | int pci_enable_ats(struct pci_dev *dev, int ps); |
1789 | void pci_disable_ats(struct pci_dev *dev); | 1780 | void pci_disable_ats(struct pci_dev *dev); |
1790 | int pci_ats_queue_depth(struct pci_dev *dev); | 1781 | int pci_ats_queue_depth(struct pci_dev *dev); |
1791 | int pci_ats_page_aligned(struct pci_dev *dev); | 1782 | int pci_ats_page_aligned(struct pci_dev *dev); |
1792 | #else | 1783 | #else |
1793 | static inline void pci_ats_init(struct pci_dev *d) { } | ||
1794 | static inline int pci_enable_ats(struct pci_dev *d, int ps) { return -ENODEV; } | 1784 | static inline int pci_enable_ats(struct pci_dev *d, int ps) { return -ENODEV; } |
1795 | static inline void pci_disable_ats(struct pci_dev *d) { } | 1785 | static inline void pci_disable_ats(struct pci_dev *d) { } |
1796 | static inline int pci_ats_queue_depth(struct pci_dev *d) { return -ENODEV; } | 1786 | static inline int pci_ats_queue_depth(struct pci_dev *d) { return -ENODEV; } |
@@ -1870,25 +1860,9 @@ static inline const char *pci_name(const struct pci_dev *pdev) | |||
1870 | return dev_name(&pdev->dev); | 1860 | return dev_name(&pdev->dev); |
1871 | } | 1861 | } |
1872 | 1862 | ||
1873 | |||
1874 | /* | ||
1875 | * Some archs don't want to expose struct resource to userland as-is | ||
1876 | * in sysfs and /proc | ||
1877 | */ | ||
1878 | #ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
1879 | void pci_resource_to_user(const struct pci_dev *dev, int bar, | 1863 | void pci_resource_to_user(const struct pci_dev *dev, int bar, |
1880 | const struct resource *rsrc, | 1864 | const struct resource *rsrc, |
1881 | resource_size_t *start, resource_size_t *end); | 1865 | resource_size_t *start, resource_size_t *end); |
1882 | #else | ||
1883 | static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
1884 | const struct resource *rsrc, resource_size_t *start, | ||
1885 | resource_size_t *end) | ||
1886 | { | ||
1887 | *start = rsrc->start; | ||
1888 | *end = rsrc->end; | ||
1889 | } | ||
1890 | #endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */ | ||
1891 | |||
1892 | 1866 | ||
1893 | /* | 1867 | /* |
1894 | * The world is not perfect and supplies us with broken PCI devices. | 1868 | * The world is not perfect and supplies us with broken PCI devices. |
@@ -2030,10 +2004,6 @@ extern unsigned long pci_cardbus_mem_size; | |||
2030 | extern u8 pci_dfl_cache_line_size; | 2004 | extern u8 pci_dfl_cache_line_size; |
2031 | extern u8 pci_cache_line_size; | 2005 | extern u8 pci_cache_line_size; |
2032 | 2006 | ||
2033 | extern unsigned long pci_hotplug_io_size; | ||
2034 | extern unsigned long pci_hotplug_mem_size; | ||
2035 | extern unsigned long pci_hotplug_bus_size; | ||
2036 | |||
2037 | /* Architecture-specific versions may override these (weak) */ | 2007 | /* Architecture-specific versions may override these (weak) */ |
2038 | void pcibios_disable_device(struct pci_dev *dev); | 2008 | void pcibios_disable_device(struct pci_dev *dev); |
2039 | void pcibios_set_master(struct pci_dev *dev); | 2009 | void pcibios_set_master(struct pci_dev *dev); |
@@ -2303,10 +2273,6 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, | |||
2303 | #ifdef CONFIG_OF | 2273 | #ifdef CONFIG_OF |
2304 | struct device_node; | 2274 | struct device_node; |
2305 | struct irq_domain; | 2275 | struct irq_domain; |
2306 | void pci_set_of_node(struct pci_dev *dev); | ||
2307 | void pci_release_of_node(struct pci_dev *dev); | ||
2308 | void pci_set_bus_of_node(struct pci_bus *bus); | ||
2309 | void pci_release_bus_of_node(struct pci_bus *bus); | ||
2310 | struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus); | 2276 | struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus); |
2311 | int pci_parse_request_of_pci_ranges(struct device *dev, | 2277 | int pci_parse_request_of_pci_ranges(struct device *dev, |
2312 | struct list_head *resources, | 2278 | struct list_head *resources, |
@@ -2316,10 +2282,6 @@ int pci_parse_request_of_pci_ranges(struct device *dev, | |||
2316 | struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); | 2282 | struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus); |
2317 | 2283 | ||
2318 | #else /* CONFIG_OF */ | 2284 | #else /* CONFIG_OF */ |
2319 | static inline void pci_set_of_node(struct pci_dev *dev) { } | ||
2320 | static inline void pci_release_of_node(struct pci_dev *dev) { } | ||
2321 | static inline void pci_set_bus_of_node(struct pci_bus *bus) { } | ||
2322 | static inline void pci_release_bus_of_node(struct pci_bus *bus) { } | ||
2323 | static inline struct irq_domain * | 2285 | static inline struct irq_domain * |
2324 | pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } | 2286 | pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; } |
2325 | static inline int pci_parse_request_of_pci_ranges(struct device *dev, | 2287 | static inline int pci_parse_request_of_pci_ranges(struct device *dev, |
@@ -2433,4 +2395,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type); | |||
2433 | #define pci_notice_ratelimited(pdev, fmt, arg...) \ | 2395 | #define pci_notice_ratelimited(pdev, fmt, arg...) \ |
2434 | dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg) | 2396 | dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg) |
2435 | 2397 | ||
2398 | #define pci_info_ratelimited(pdev, fmt, arg...) \ | ||
2399 | dev_info_ratelimited(&(pdev)->dev, fmt, ##arg) | ||
2400 | |||
2436 | #endif /* LINUX_PCI_H */ | 2401 | #endif /* LINUX_PCI_H */ |
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h index f694eb2ca978..b482e42d7153 100644 --- a/include/linux/pci_hotplug.h +++ b/include/linux/pci_hotplug.h | |||
@@ -86,114 +86,14 @@ void pci_hp_deregister(struct hotplug_slot *slot); | |||
86 | #define pci_hp_initialize(slot, bus, nr, name) \ | 86 | #define pci_hp_initialize(slot, bus, nr, name) \ |
87 | __pci_hp_initialize(slot, bus, nr, name, THIS_MODULE, KBUILD_MODNAME) | 87 | __pci_hp_initialize(slot, bus, nr, name, THIS_MODULE, KBUILD_MODNAME) |
88 | 88 | ||
89 | /* PCI Setting Record (Type 0) */ | ||
90 | struct hpp_type0 { | ||
91 | u32 revision; | ||
92 | u8 cache_line_size; | ||
93 | u8 latency_timer; | ||
94 | u8 enable_serr; | ||
95 | u8 enable_perr; | ||
96 | }; | ||
97 | |||
98 | /* PCI-X Setting Record (Type 1) */ | ||
99 | struct hpp_type1 { | ||
100 | u32 revision; | ||
101 | u8 max_mem_read; | ||
102 | u8 avg_max_split; | ||
103 | u16 tot_max_split; | ||
104 | }; | ||
105 | |||
106 | /* PCI Express Setting Record (Type 2) */ | ||
107 | struct hpp_type2 { | ||
108 | u32 revision; | ||
109 | u32 unc_err_mask_and; | ||
110 | u32 unc_err_mask_or; | ||
111 | u32 unc_err_sever_and; | ||
112 | u32 unc_err_sever_or; | ||
113 | u32 cor_err_mask_and; | ||
114 | u32 cor_err_mask_or; | ||
115 | u32 adv_err_cap_and; | ||
116 | u32 adv_err_cap_or; | ||
117 | u16 pci_exp_devctl_and; | ||
118 | u16 pci_exp_devctl_or; | ||
119 | u16 pci_exp_lnkctl_and; | ||
120 | u16 pci_exp_lnkctl_or; | ||
121 | u32 sec_unc_err_sever_and; | ||
122 | u32 sec_unc_err_sever_or; | ||
123 | u32 sec_unc_err_mask_and; | ||
124 | u32 sec_unc_err_mask_or; | ||
125 | }; | ||
126 | |||
127 | /* | ||
128 | * _HPX PCI Express Setting Record (Type 3) | ||
129 | */ | ||
130 | struct hpx_type3 { | ||
131 | u16 device_type; | ||
132 | u16 function_type; | ||
133 | u16 config_space_location; | ||
134 | u16 pci_exp_cap_id; | ||
135 | u16 pci_exp_cap_ver; | ||
136 | u16 pci_exp_vendor_id; | ||
137 | u16 dvsec_id; | ||
138 | u16 dvsec_rev; | ||
139 | u16 match_offset; | ||
140 | u32 match_mask_and; | ||
141 | u32 match_value; | ||
142 | u16 reg_offset; | ||
143 | u32 reg_mask_and; | ||
144 | u32 reg_mask_or; | ||
145 | }; | ||
146 | |||
147 | struct hotplug_program_ops { | ||
148 | void (*program_type0)(struct pci_dev *dev, struct hpp_type0 *hpp); | ||
149 | void (*program_type1)(struct pci_dev *dev, struct hpp_type1 *hpp); | ||
150 | void (*program_type2)(struct pci_dev *dev, struct hpp_type2 *hpp); | ||
151 | void (*program_type3)(struct pci_dev *dev, struct hpx_type3 *hpp); | ||
152 | }; | ||
153 | |||
154 | enum hpx_type3_dev_type { | ||
155 | HPX_TYPE_ENDPOINT = BIT(0), | ||
156 | HPX_TYPE_LEG_END = BIT(1), | ||
157 | HPX_TYPE_RC_END = BIT(2), | ||
158 | HPX_TYPE_RC_EC = BIT(3), | ||
159 | HPX_TYPE_ROOT_PORT = BIT(4), | ||
160 | HPX_TYPE_UPSTREAM = BIT(5), | ||
161 | HPX_TYPE_DOWNSTREAM = BIT(6), | ||
162 | HPX_TYPE_PCI_BRIDGE = BIT(7), | ||
163 | HPX_TYPE_PCIE_BRIDGE = BIT(8), | ||
164 | }; | ||
165 | |||
166 | enum hpx_type3_fn_type { | ||
167 | HPX_FN_NORMAL = BIT(0), | ||
168 | HPX_FN_SRIOV_PHYS = BIT(1), | ||
169 | HPX_FN_SRIOV_VIRT = BIT(2), | ||
170 | }; | ||
171 | |||
172 | enum hpx_type3_cfg_loc { | ||
173 | HPX_CFG_PCICFG = 0, | ||
174 | HPX_CFG_PCIE_CAP = 1, | ||
175 | HPX_CFG_PCIE_CAP_EXT = 2, | ||
176 | HPX_CFG_VEND_CAP = 3, | ||
177 | HPX_CFG_DVSEC = 4, | ||
178 | HPX_CFG_MAX, | ||
179 | }; | ||
180 | |||
181 | #ifdef CONFIG_ACPI | 89 | #ifdef CONFIG_ACPI |
182 | #include <linux/acpi.h> | 90 | #include <linux/acpi.h> |
183 | int pci_acpi_program_hp_params(struct pci_dev *dev, | ||
184 | const struct hotplug_program_ops *hp_ops); | ||
185 | bool pciehp_is_native(struct pci_dev *bridge); | 91 | bool pciehp_is_native(struct pci_dev *bridge); |
186 | int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge); | 92 | int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge); |
187 | bool shpchp_is_native(struct pci_dev *bridge); | 93 | bool shpchp_is_native(struct pci_dev *bridge); |
188 | int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle); | 94 | int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle); |
189 | int acpi_pci_detect_ejectable(acpi_handle handle); | 95 | int acpi_pci_detect_ejectable(acpi_handle handle); |
190 | #else | 96 | #else |
191 | static inline int pci_acpi_program_hp_params(struct pci_dev *dev, | ||
192 | const struct hotplug_program_ops *hp_ops) | ||
193 | { | ||
194 | return -ENODEV; | ||
195 | } | ||
196 | |||
197 | static inline int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge) | 97 | static inline int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge) |
198 | { | 98 | { |
199 | return 0; | 99 | return 0; |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index f59a6f98900c..f3130542c752 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -2571,6 +2571,8 @@ | |||
2571 | 2571 | ||
2572 | #define PCI_VENDOR_ID_ASMEDIA 0x1b21 | 2572 | #define PCI_VENDOR_ID_ASMEDIA 0x1b21 |
2573 | 2573 | ||
2574 | #define PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS 0x1c36 | ||
2575 | |||
2574 | #define PCI_VENDOR_ID_CIRCUITCO 0x1cc8 | 2576 | #define PCI_VENDOR_ID_CIRCUITCO 0x1cc8 |
2575 | #define PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD 0x0001 | 2577 | #define PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD 0x0001 |
2576 | 2578 | ||
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f28e562d7ca8..de3e58afc564 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h | |||
@@ -591,6 +591,7 @@ | |||
591 | #define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */ | 591 | #define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */ |
592 | #define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */ | 592 | #define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */ |
593 | #define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */ | 593 | #define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */ |
594 | #define PCI_EXP_SLTCTL_ATTN_IND_SHIFT 6 /* Attention Indicator shift */ | ||
594 | #define PCI_EXP_SLTCTL_ATTN_IND_ON 0x0040 /* Attention Indicator on */ | 595 | #define PCI_EXP_SLTCTL_ATTN_IND_ON 0x0040 /* Attention Indicator on */ |
595 | #define PCI_EXP_SLTCTL_ATTN_IND_BLINK 0x0080 /* Attention Indicator blinking */ | 596 | #define PCI_EXP_SLTCTL_ATTN_IND_BLINK 0x0080 /* Attention Indicator blinking */ |
596 | #define PCI_EXP_SLTCTL_ATTN_IND_OFF 0x00c0 /* Attention Indicator off */ | 597 | #define PCI_EXP_SLTCTL_ATTN_IND_OFF 0x00c0 /* Attention Indicator off */ |