]> git.proxmox.com Git - pve-kernel-jessie.git/blob - override_for_missing_acs_capabilities.patch
add scheduler fix for ceph on numa hosts
[pve-kernel-jessie.git] / override_for_missing_acs_capabilities.patch
1 diff -rupN linux-3.15.old/Documentation/kernel-parameters.txt linux-3.15/Documentation/kernel-parameters.txt
2 --- linux-3.15.old/Documentation/kernel-parameters.txt 2014-06-08 15:19:54.000000000 -0300
3 +++ linux-3.15/Documentation/kernel-parameters.txt 2014-06-09 18:05:31.744055580 -0300
4 @@ -2554,6 +2554,16 @@ bytes respectively. Such letter suffixes
5 nomsi Do not use MSI for native PCIe PME signaling (this makes
6 all PCIe root ports use INTx for all services).
7
8 + pcie_acs_override =
9 + [PCIE] Override missing PCIe ACS support for:
10 + downstream
11 + All downstream ports - full ACS capabilties
12 + multifunction
13 + All multifunction devices - multifunction ACS subset
14 + id:nnnn:nnnn
15 + Specfic device - full ACS capabilities
16 + Specified as vid:did (vendor/device ID) in hex
17 +
18 pcmv= [HW,PCMCIA] BadgePAD 4
19
20 pd_ignore_unused
21 diff -rupN linux-3.15.old/drivers/pci/quirks.c linux-3.15/drivers/pci/quirks.c
22 --- linux-3.15.old/drivers/pci/quirks.c 2014-06-08 15:19:54.000000000 -0300
23 +++ linux-3.15/drivers/pci/quirks.c 2014-06-09 18:06:36.688743183 -0300
24 @@ -3384,6 +3384,107 @@ struct pci_dev *pci_get_dma_source(struc
25 return pci_dev_get(dev);
26 }
27
28 +static bool acs_on_downstream;
29 +static bool acs_on_multifunction;
30 +
31 +#define NUM_ACS_IDS 16
32 +struct acs_on_id {
33 + unsigned short vendor;
34 + unsigned short device;
35 +};
36 +static struct acs_on_id acs_on_ids[NUM_ACS_IDS];
37 +static u8 max_acs_id;
38 +
39 +static __init int pcie_acs_override_setup(char *p)
40 +{
41 + if (!p)
42 + return -EINVAL;
43 +
44 + while (*p) {
45 + if (!strncmp(p, "downstream", 10))
46 + acs_on_downstream = true;
47 + if (!strncmp(p, "multifunction", 13))
48 + acs_on_multifunction = true;
49 + if (!strncmp(p, "id:", 3)) {
50 + char opt[5];
51 + int ret;
52 + long val;
53 +
54 + if (max_acs_id >= NUM_ACS_IDS - 1) {
55 + pr_warn("Out of PCIe ACS override slots (%d)\n",
56 + NUM_ACS_IDS);
57 + goto next;
58 + }
59 +
60 + p += 3;
61 + snprintf(opt, 5, "%s", p);
62 + ret = kstrtol(opt, 16, &val);
63 + if (ret) {
64 + pr_warn("PCIe ACS ID parse error %d\n", ret);
65 + goto next;
66 + }
67 + acs_on_ids[max_acs_id].vendor = val;
68 +
69 + p += strcspn(p, ":");
70 + if (*p != ':') {
71 + pr_warn("PCIe ACS invalid ID\n");
72 + goto next;
73 + }
74 +
75 + p++;
76 + snprintf(opt, 5, "%s", p);
77 + ret = kstrtol(opt, 16, &val);
78 + if (ret) {
79 + pr_warn("PCIe ACS ID parse error %d\n", ret);
80 + goto next;
81 + }
82 + acs_on_ids[max_acs_id].device = val;
83 + max_acs_id++;
84 + }
85 +next:
86 + p += strcspn(p, ",");
87 + if (*p == ',')
88 + p++;
89 + }
90 +
91 + if (acs_on_downstream || acs_on_multifunction || max_acs_id)
92 + pr_warn("Warning: PCIe ACS overrides enabled; This may allow non-IOMMU protected peer-to-peer DMA\n");
93 +
94 + return 0;
95 +}
96 +early_param("pcie_acs_override", pcie_acs_override_setup);
97 +
98 +static int pcie_acs_overrides(struct pci_dev *dev, u16 acs_flags)
99 +{
100 + int i;
101 +
102 + /* Never override ACS for legacy devices or devices with ACS caps */
103 + if (!pci_is_pcie(dev) ||
104 + pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS))
105 + return -ENOTTY;
106 +
107 + for (i = 0; i < max_acs_id; i++)
108 + if (acs_on_ids[i].vendor == dev->vendor &&
109 + acs_on_ids[i].device == dev->device)
110 + return 1;
111 +
112 + switch (pci_pcie_type(dev)) {
113 + case PCI_EXP_TYPE_DOWNSTREAM:
114 + case PCI_EXP_TYPE_ROOT_PORT:
115 + if (acs_on_downstream)
116 + return 1;
117 + break;
118 + case PCI_EXP_TYPE_ENDPOINT:
119 + case PCI_EXP_TYPE_UPSTREAM:
120 + case PCI_EXP_TYPE_LEG_END:
121 + case PCI_EXP_TYPE_RC_END:
122 + if (acs_on_multifunction && dev->multifunction)
123 + return 1;
124 + }
125 +
126 + return -ENOTTY;
127 +}
128 +
129 /*
130 * AMD has indicated that the devices below do not support peer-to-peer
131 * in any system where they are found in the southbridge with an AMD
132 @@ -3483,6 +3584,7 @@ static int pci_quirk_intel_pch_acs(struc
133 return acs_flags & ~flags ? 0 : 1;
134 }
135
136 +
137 static const struct pci_dev_acs_enabled {
138 u16 vendor;
139 u16 device;
140 @@ -3495,6 +3597,7 @@ static const struct pci_dev_acs_enabled
141 { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs },
142 { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */
143 { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */
144 + { PCI_ANY_ID, PCI_ANY_ID, pcie_acs_overrides },
145 { 0 }
146 };
147