diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 16:44:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 16:44:53 -0400 |
commit | 997271cf5e12c1b38aec0764187094663501c984 (patch) | |
tree | 45760ec5aa3fd3da05f73b1e52190562fe286093 | |
parent | 896d01796d33e50589c96bbef5f0017d3cfc4ee8 (diff) | |
parent | 97ffab1f14638d2c95ad986ce735481d164a0bd2 (diff) |
Merge branch 'stable/pci.cleanups.v1' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
* 'stable/pci.cleanups.v1' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
xen/pci: Use 'acpi_gsi_to_irq' value unconditionally.
xen/pci: Remove 'xen_allocate_pirq_gsi'.
xen/pci: Retire unnecessary #ifdef CONFIG_ACPI
xen/pci: Move the allocation of IRQs when there are no IOAPIC's to the end
xen/pci: Squash pci_xen_initial_domain and xen_setup_pirqs together.
xen/pci: Use the xen_register_pirq for HVM and initial domain users
xen/pci: In xen_register_pirq bind the GSI to the IRQ after the hypercall.
xen/pci: Provide #ifdef CONFIG_ACPI to easy code squashing.
xen/pci: Update comments and fix empty spaces.
xen/pci: Shuffle code around.
-rw-r--r-- | arch/x86/include/asm/xen/pci.h | 5 | ||||
-rw-r--r-- | arch/x86/pci/xen.c | 371 | ||||
-rw-r--r-- | drivers/xen/events.c | 7 | ||||
-rw-r--r-- | include/xen/events.h | 2 |
4 files changed, 165 insertions, 220 deletions
diff --git a/arch/x86/include/asm/xen/pci.h b/arch/x86/include/asm/xen/pci.h index 4fbda9a3f339..968d57dd54c9 100644 --- a/arch/x86/include/asm/xen/pci.h +++ b/arch/x86/include/asm/xen/pci.h | |||
@@ -14,13 +14,14 @@ static inline int pci_xen_hvm_init(void) | |||
14 | } | 14 | } |
15 | #endif | 15 | #endif |
16 | #if defined(CONFIG_XEN_DOM0) | 16 | #if defined(CONFIG_XEN_DOM0) |
17 | void __init xen_setup_pirqs(void); | 17 | int __init pci_xen_initial_domain(void); |
18 | int xen_find_device_domain_owner(struct pci_dev *dev); | 18 | int xen_find_device_domain_owner(struct pci_dev *dev); |
19 | int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain); | 19 | int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain); |
20 | int xen_unregister_device_domain_owner(struct pci_dev *dev); | 20 | int xen_unregister_device_domain_owner(struct pci_dev *dev); |
21 | #else | 21 | #else |
22 | static inline void __init xen_setup_pirqs(void) | 22 | static inline int __init pci_xen_initial_domain(void) |
23 | { | 23 | { |
24 | return -1; | ||
24 | } | 25 | } |
25 | static inline int xen_find_device_domain_owner(struct pci_dev *dev) | 26 | static inline int xen_find_device_domain_owner(struct pci_dev *dev) |
26 | { | 27 | { |
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c index f567965c0620..1017c7bee388 100644 --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c | |||
@@ -1,8 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * Xen PCI Frontend Stub - puts some "dummy" functions in to the Linux | 2 | * Xen PCI - handle PCI (INTx) and MSI infrastructure calls for PV, HVM and |
3 | * x86 PCI core to support the Xen PCI Frontend | 3 | * initial domain support. We also handle the DSDT _PRT callbacks for GSI's |
4 | * used in HVM and initial domain mode (PV does not parse ACPI, so it has no | ||
5 | * concept of GSIs). Under PV we hook under the pnbbios API for IRQs and | ||
6 | * 0xcf8 PCI configuration read/write. | ||
4 | * | 7 | * |
5 | * Author: Ryan Wilson <hap9@epoch.ncsc.mil> | 8 | * Author: Ryan Wilson <hap9@epoch.ncsc.mil> |
9 | * Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | ||
10 | * Stefano Stabellini <stefano.stabellini@eu.citrix.com> | ||
6 | */ | 11 | */ |
7 | #include <linux/module.h> | 12 | #include <linux/module.h> |
8 | #include <linux/init.h> | 13 | #include <linux/init.h> |
@@ -19,22 +24,53 @@ | |||
19 | #include <xen/events.h> | 24 | #include <xen/events.h> |
20 | #include <asm/xen/pci.h> | 25 | #include <asm/xen/pci.h> |
21 | 26 | ||
27 | static int xen_pcifront_enable_irq(struct pci_dev *dev) | ||
28 | { | ||
29 | int rc; | ||
30 | int share = 1; | ||
31 | int pirq; | ||
32 | u8 gsi; | ||
33 | |||
34 | rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi); | ||
35 | if (rc < 0) { | ||
36 | dev_warn(&dev->dev, "Xen PCI: failed to read interrupt line: %d\n", | ||
37 | rc); | ||
38 | return rc; | ||
39 | } | ||
40 | /* In PV DomU the Xen PCI backend puts the PIRQ in the interrupt line.*/ | ||
41 | pirq = gsi; | ||
42 | |||
43 | if (gsi < NR_IRQS_LEGACY) | ||
44 | share = 0; | ||
45 | |||
46 | rc = xen_bind_pirq_gsi_to_irq(gsi, pirq, share, "pcifront"); | ||
47 | if (rc < 0) { | ||
48 | dev_warn(&dev->dev, "Xen PCI: failed to bind GSI%d (PIRQ%d) to IRQ: %d\n", | ||
49 | gsi, pirq, rc); | ||
50 | return rc; | ||
51 | } | ||
52 | |||
53 | dev->irq = rc; | ||
54 | dev_info(&dev->dev, "Xen PCI mapped GSI%d to IRQ%d\n", gsi, dev->irq); | ||
55 | return 0; | ||
56 | } | ||
57 | |||
22 | #ifdef CONFIG_ACPI | 58 | #ifdef CONFIG_ACPI |
23 | static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi, | 59 | static int xen_register_pirq(u32 gsi, int gsi_override, int triggering, |
24 | int trigger, int polarity) | 60 | bool set_pirq) |
25 | { | 61 | { |
26 | int rc, irq; | 62 | int rc, pirq = -1, irq = -1; |
27 | struct physdev_map_pirq map_irq; | 63 | struct physdev_map_pirq map_irq; |
28 | int shareable = 0; | 64 | int shareable = 0; |
29 | char *name; | 65 | char *name; |
30 | 66 | ||
31 | if (!xen_hvm_domain()) | 67 | if (set_pirq) |
32 | return -1; | 68 | pirq = gsi; |
33 | 69 | ||
34 | map_irq.domid = DOMID_SELF; | 70 | map_irq.domid = DOMID_SELF; |
35 | map_irq.type = MAP_PIRQ_TYPE_GSI; | 71 | map_irq.type = MAP_PIRQ_TYPE_GSI; |
36 | map_irq.index = gsi; | 72 | map_irq.index = gsi; |
37 | map_irq.pirq = -1; | 73 | map_irq.pirq = pirq; |
38 | 74 | ||
39 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); | 75 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); |
40 | if (rc) { | 76 | if (rc) { |
@@ -42,7 +78,7 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi, | |||
42 | return -1; | 78 | return -1; |
43 | } | 79 | } |
44 | 80 | ||
45 | if (trigger == ACPI_EDGE_SENSITIVE) { | 81 | if (triggering == ACPI_EDGE_SENSITIVE) { |
46 | shareable = 0; | 82 | shareable = 0; |
47 | name = "ioapic-edge"; | 83 | name = "ioapic-edge"; |
48 | } else { | 84 | } else { |
@@ -50,12 +86,63 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi, | |||
50 | name = "ioapic-level"; | 86 | name = "ioapic-level"; |
51 | } | 87 | } |
52 | 88 | ||
89 | if (gsi_override >= 0) | ||
90 | gsi = gsi_override; | ||
91 | |||
53 | irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name); | 92 | irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name); |
93 | if (irq < 0) | ||
94 | goto out; | ||
95 | |||
96 | printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d (gsi=%d)\n", map_irq.pirq, irq, gsi); | ||
97 | out: | ||
98 | return irq; | ||
99 | } | ||
100 | |||
101 | static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi, | ||
102 | int trigger, int polarity) | ||
103 | { | ||
104 | if (!xen_hvm_domain()) | ||
105 | return -1; | ||
54 | 106 | ||
55 | printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq); | 107 | return xen_register_pirq(gsi, -1 /* no GSI override */, trigger, |
108 | false /* no mapping of GSI to PIRQ */); | ||
109 | } | ||
110 | |||
111 | #ifdef CONFIG_XEN_DOM0 | ||
112 | static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polarity) | ||
113 | { | ||
114 | int rc, irq; | ||
115 | struct physdev_setup_gsi setup_gsi; | ||
116 | |||
117 | if (!xen_pv_domain()) | ||
118 | return -1; | ||
119 | |||
120 | printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n", | ||
121 | gsi, triggering, polarity); | ||
122 | |||
123 | irq = xen_register_pirq(gsi, gsi_override, triggering, true); | ||
124 | |||
125 | setup_gsi.gsi = gsi; | ||
126 | setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1); | ||
127 | setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1); | ||
128 | |||
129 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi); | ||
130 | if (rc == -EEXIST) | ||
131 | printk(KERN_INFO "Already setup the GSI :%d\n", gsi); | ||
132 | else if (rc) { | ||
133 | printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n", | ||
134 | gsi, rc); | ||
135 | } | ||
56 | 136 | ||
57 | return irq; | 137 | return irq; |
58 | } | 138 | } |
139 | |||
140 | static int acpi_register_gsi_xen(struct device *dev, u32 gsi, | ||
141 | int trigger, int polarity) | ||
142 | { | ||
143 | return xen_register_gsi(gsi, -1 /* no GSI override */, trigger, polarity); | ||
144 | } | ||
145 | #endif | ||
59 | #endif | 146 | #endif |
60 | 147 | ||
61 | #if defined(CONFIG_PCI_MSI) | 148 | #if defined(CONFIG_PCI_MSI) |
@@ -65,6 +152,43 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi, | |||
65 | struct xen_pci_frontend_ops *xen_pci_frontend; | 152 | struct xen_pci_frontend_ops *xen_pci_frontend; |
66 | EXPORT_SYMBOL_GPL(xen_pci_frontend); | 153 | EXPORT_SYMBOL_GPL(xen_pci_frontend); |
67 | 154 | ||
155 | static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | ||
156 | { | ||
157 | int irq, ret, i; | ||
158 | struct msi_desc *msidesc; | ||
159 | int *v; | ||
160 | |||
161 | v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL); | ||
162 | if (!v) | ||
163 | return -ENOMEM; | ||
164 | |||
165 | if (type == PCI_CAP_ID_MSIX) | ||
166 | ret = xen_pci_frontend_enable_msix(dev, v, nvec); | ||
167 | else | ||
168 | ret = xen_pci_frontend_enable_msi(dev, v); | ||
169 | if (ret) | ||
170 | goto error; | ||
171 | i = 0; | ||
172 | list_for_each_entry(msidesc, &dev->msi_list, list) { | ||
173 | irq = xen_bind_pirq_msi_to_irq(dev, msidesc, v[i], 0, | ||
174 | (type == PCI_CAP_ID_MSIX) ? | ||
175 | "pcifront-msi-x" : | ||
176 | "pcifront-msi", | ||
177 | DOMID_SELF); | ||
178 | if (irq < 0) | ||
179 | goto free; | ||
180 | i++; | ||
181 | } | ||
182 | kfree(v); | ||
183 | return 0; | ||
184 | |||
185 | error: | ||
186 | dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n"); | ||
187 | free: | ||
188 | kfree(v); | ||
189 | return ret; | ||
190 | } | ||
191 | |||
68 | #define XEN_PIRQ_MSI_DATA (MSI_DATA_TRIGGER_EDGE | \ | 192 | #define XEN_PIRQ_MSI_DATA (MSI_DATA_TRIGGER_EDGE | \ |
69 | MSI_DATA_LEVEL_ASSERT | (3 << 8) | MSI_DATA_VECTOR(0)) | 193 | MSI_DATA_LEVEL_ASSERT | (3 << 8) | MSI_DATA_VECTOR(0)) |
70 | 194 | ||
@@ -123,67 +247,6 @@ error: | |||
123 | return -ENODEV; | 247 | return -ENODEV; |
124 | } | 248 | } |
125 | 249 | ||
126 | /* | ||
127 | * For MSI interrupts we have to use drivers/xen/event.s functions to | ||
128 | * allocate an irq_desc and setup the right */ | ||
129 | |||
130 | |||
131 | static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | ||
132 | { | ||
133 | int irq, ret, i; | ||
134 | struct msi_desc *msidesc; | ||
135 | int *v; | ||
136 | |||
137 | v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL); | ||
138 | if (!v) | ||
139 | return -ENOMEM; | ||
140 | |||
141 | if (type == PCI_CAP_ID_MSIX) | ||
142 | ret = xen_pci_frontend_enable_msix(dev, v, nvec); | ||
143 | else | ||
144 | ret = xen_pci_frontend_enable_msi(dev, v); | ||
145 | if (ret) | ||
146 | goto error; | ||
147 | i = 0; | ||
148 | list_for_each_entry(msidesc, &dev->msi_list, list) { | ||
149 | irq = xen_bind_pirq_msi_to_irq(dev, msidesc, v[i], 0, | ||
150 | (type == PCI_CAP_ID_MSIX) ? | ||
151 | "pcifront-msi-x" : | ||
152 | "pcifront-msi", | ||
153 | DOMID_SELF); | ||
154 | if (irq < 0) | ||
155 | goto free; | ||
156 | i++; | ||
157 | } | ||
158 | kfree(v); | ||
159 | return 0; | ||
160 | |||
161 | error: | ||
162 | dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n"); | ||
163 | free: | ||
164 | kfree(v); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | static void xen_teardown_msi_irqs(struct pci_dev *dev) | ||
169 | { | ||
170 | struct msi_desc *msidesc; | ||
171 | |||
172 | msidesc = list_entry(dev->msi_list.next, struct msi_desc, list); | ||
173 | if (msidesc->msi_attrib.is_msix) | ||
174 | xen_pci_frontend_disable_msix(dev); | ||
175 | else | ||
176 | xen_pci_frontend_disable_msi(dev); | ||
177 | |||
178 | /* Free the IRQ's and the msidesc using the generic code. */ | ||
179 | default_teardown_msi_irqs(dev); | ||
180 | } | ||
181 | |||
182 | static void xen_teardown_msi_irq(unsigned int irq) | ||
183 | { | ||
184 | xen_destroy_irq(irq); | ||
185 | } | ||
186 | |||
187 | #ifdef CONFIG_XEN_DOM0 | 250 | #ifdef CONFIG_XEN_DOM0 |
188 | static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | 251 | static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) |
189 | { | 252 | { |
@@ -242,45 +305,28 @@ out: | |||
242 | return ret; | 305 | return ret; |
243 | } | 306 | } |
244 | #endif | 307 | #endif |
245 | #endif | ||
246 | 308 | ||
247 | static int xen_pcifront_enable_irq(struct pci_dev *dev) | 309 | static void xen_teardown_msi_irqs(struct pci_dev *dev) |
248 | { | 310 | { |
249 | int rc; | 311 | struct msi_desc *msidesc; |
250 | int share = 1; | ||
251 | int pirq; | ||
252 | u8 gsi; | ||
253 | |||
254 | rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi); | ||
255 | if (rc < 0) { | ||
256 | dev_warn(&dev->dev, "Xen PCI: failed to read interrupt line: %d\n", | ||
257 | rc); | ||
258 | return rc; | ||
259 | } | ||
260 | |||
261 | rc = xen_allocate_pirq_gsi(gsi); | ||
262 | if (rc < 0) { | ||
263 | dev_warn(&dev->dev, "Xen PCI: failed to allocate a PIRQ for GSI%d: %d\n", | ||
264 | gsi, rc); | ||
265 | return rc; | ||
266 | } | ||
267 | pirq = rc; | ||
268 | 312 | ||
269 | if (gsi < NR_IRQS_LEGACY) | 313 | msidesc = list_entry(dev->msi_list.next, struct msi_desc, list); |
270 | share = 0; | 314 | if (msidesc->msi_attrib.is_msix) |
315 | xen_pci_frontend_disable_msix(dev); | ||
316 | else | ||
317 | xen_pci_frontend_disable_msi(dev); | ||
271 | 318 | ||
272 | rc = xen_bind_pirq_gsi_to_irq(gsi, pirq, share, "pcifront"); | 319 | /* Free the IRQ's and the msidesc using the generic code. */ |
273 | if (rc < 0) { | 320 | default_teardown_msi_irqs(dev); |
274 | dev_warn(&dev->dev, "Xen PCI: failed to bind GSI%d (PIRQ%d) to IRQ: %d\n", | 321 | } |
275 | gsi, pirq, rc); | ||
276 | return rc; | ||
277 | } | ||
278 | 322 | ||
279 | dev->irq = rc; | 323 | static void xen_teardown_msi_irq(unsigned int irq) |
280 | dev_info(&dev->dev, "Xen PCI mapped GSI%d to IRQ%d\n", gsi, dev->irq); | 324 | { |
281 | return 0; | 325 | xen_destroy_irq(irq); |
282 | } | 326 | } |
283 | 327 | ||
328 | #endif | ||
329 | |||
284 | int __init pci_xen_init(void) | 330 | int __init pci_xen_init(void) |
285 | { | 331 | { |
286 | if (!xen_pv_domain() || xen_initial_domain()) | 332 | if (!xen_pv_domain() || xen_initial_domain()) |
@@ -327,79 +373,6 @@ int __init pci_xen_hvm_init(void) | |||
327 | } | 373 | } |
328 | 374 | ||
329 | #ifdef CONFIG_XEN_DOM0 | 375 | #ifdef CONFIG_XEN_DOM0 |
330 | static int xen_register_pirq(u32 gsi, int gsi_override, int triggering) | ||
331 | { | ||
332 | int rc, pirq, irq = -1; | ||
333 | struct physdev_map_pirq map_irq; | ||
334 | int shareable = 0; | ||
335 | char *name; | ||
336 | |||
337 | if (!xen_pv_domain()) | ||
338 | return -1; | ||
339 | |||
340 | if (triggering == ACPI_EDGE_SENSITIVE) { | ||
341 | shareable = 0; | ||
342 | name = "ioapic-edge"; | ||
343 | } else { | ||
344 | shareable = 1; | ||
345 | name = "ioapic-level"; | ||
346 | } | ||
347 | pirq = xen_allocate_pirq_gsi(gsi); | ||
348 | if (pirq < 0) | ||
349 | goto out; | ||
350 | |||
351 | if (gsi_override >= 0) | ||
352 | irq = xen_bind_pirq_gsi_to_irq(gsi_override, pirq, shareable, name); | ||
353 | else | ||
354 | irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name); | ||
355 | if (irq < 0) | ||
356 | goto out; | ||
357 | |||
358 | printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d (gsi=%d)\n", pirq, irq, gsi); | ||
359 | |||
360 | map_irq.domid = DOMID_SELF; | ||
361 | map_irq.type = MAP_PIRQ_TYPE_GSI; | ||
362 | map_irq.index = gsi; | ||
363 | map_irq.pirq = pirq; | ||
364 | |||
365 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); | ||
366 | if (rc) { | ||
367 | printk(KERN_WARNING "xen map irq failed %d\n", rc); | ||
368 | return -1; | ||
369 | } | ||
370 | |||
371 | out: | ||
372 | return irq; | ||
373 | } | ||
374 | |||
375 | static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polarity) | ||
376 | { | ||
377 | int rc, irq; | ||
378 | struct physdev_setup_gsi setup_gsi; | ||
379 | |||
380 | if (!xen_pv_domain()) | ||
381 | return -1; | ||
382 | |||
383 | printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n", | ||
384 | gsi, triggering, polarity); | ||
385 | |||
386 | irq = xen_register_pirq(gsi, gsi_override, triggering); | ||
387 | |||
388 | setup_gsi.gsi = gsi; | ||
389 | setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1); | ||
390 | setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1); | ||
391 | |||
392 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi); | ||
393 | if (rc == -EEXIST) | ||
394 | printk(KERN_INFO "Already setup the GSI :%d\n", gsi); | ||
395 | else if (rc) { | ||
396 | printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n", | ||
397 | gsi, rc); | ||
398 | } | ||
399 | |||
400 | return irq; | ||
401 | } | ||
402 | |||
403 | static __init void xen_setup_acpi_sci(void) | 376 | static __init void xen_setup_acpi_sci(void) |
404 | { | 377 | { |
405 | int rc; | 378 | int rc; |
@@ -419,7 +392,7 @@ static __init void xen_setup_acpi_sci(void) | |||
419 | } | 392 | } |
420 | trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; | 393 | trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; |
421 | polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; | 394 | polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; |
422 | 395 | ||
423 | printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d " | 396 | printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d " |
424 | "polarity=%d\n", gsi, trigger, polarity); | 397 | "polarity=%d\n", gsi, trigger, polarity); |
425 | 398 | ||
@@ -434,10 +407,9 @@ static __init void xen_setup_acpi_sci(void) | |||
434 | * the ACPI interpreter and keels over since IRQ 9 has not been | 407 | * the ACPI interpreter and keels over since IRQ 9 has not been |
435 | * setup as we had setup IRQ 20 for it). | 408 | * setup as we had setup IRQ 20 for it). |
436 | */ | 409 | */ |
437 | /* Check whether the GSI != IRQ */ | ||
438 | if (acpi_gsi_to_irq(gsi, &irq) == 0) { | 410 | if (acpi_gsi_to_irq(gsi, &irq) == 0) { |
439 | if (irq >= 0 && irq != gsi) | 411 | /* Use the provided value if it's valid. */ |
440 | /* Bugger, we MUST have that IRQ. */ | 412 | if (irq >= 0) |
441 | gsi_override = irq; | 413 | gsi_override = irq; |
442 | } | 414 | } |
443 | 415 | ||
@@ -447,41 +419,16 @@ static __init void xen_setup_acpi_sci(void) | |||
447 | return; | 419 | return; |
448 | } | 420 | } |
449 | 421 | ||
450 | static int acpi_register_gsi_xen(struct device *dev, u32 gsi, | 422 | int __init pci_xen_initial_domain(void) |
451 | int trigger, int polarity) | ||
452 | { | 423 | { |
453 | return xen_register_gsi(gsi, -1 /* no GSI override */, trigger, polarity); | 424 | int irq; |
454 | } | ||
455 | 425 | ||
456 | static int __init pci_xen_initial_domain(void) | ||
457 | { | ||
458 | #ifdef CONFIG_PCI_MSI | 426 | #ifdef CONFIG_PCI_MSI |
459 | x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs; | 427 | x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs; |
460 | x86_msi.teardown_msi_irq = xen_teardown_msi_irq; | 428 | x86_msi.teardown_msi_irq = xen_teardown_msi_irq; |
461 | #endif | 429 | #endif |
462 | xen_setup_acpi_sci(); | 430 | xen_setup_acpi_sci(); |
463 | __acpi_register_gsi = acpi_register_gsi_xen; | 431 | __acpi_register_gsi = acpi_register_gsi_xen; |
464 | |||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | void __init xen_setup_pirqs(void) | ||
469 | { | ||
470 | int pirq, irq; | ||
471 | |||
472 | pci_xen_initial_domain(); | ||
473 | |||
474 | if (0 == nr_ioapics) { | ||
475 | for (irq = 0; irq < NR_IRQS_LEGACY; irq++) { | ||
476 | pirq = xen_allocate_pirq_gsi(irq); | ||
477 | if (WARN(pirq < 0, | ||
478 | "Could not allocate PIRQ for legacy interrupt\n")) | ||
479 | break; | ||
480 | irq = xen_bind_pirq_gsi_to_irq(irq, pirq, 0, "xt-pic"); | ||
481 | } | ||
482 | return; | ||
483 | } | ||
484 | |||
485 | /* Pre-allocate legacy irqs */ | 432 | /* Pre-allocate legacy irqs */ |
486 | for (irq = 0; irq < NR_IRQS_LEGACY; irq++) { | 433 | for (irq = 0; irq < NR_IRQS_LEGACY; irq++) { |
487 | int trigger, polarity; | 434 | int trigger, polarity; |
@@ -490,12 +437,16 @@ void __init xen_setup_pirqs(void) | |||
490 | continue; | 437 | continue; |
491 | 438 | ||
492 | xen_register_pirq(irq, -1 /* no GSI override */, | 439 | xen_register_pirq(irq, -1 /* no GSI override */, |
493 | trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE); | 440 | trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE, |
441 | true /* Map GSI to PIRQ */); | ||
494 | } | 442 | } |
443 | if (0 == nr_ioapics) { | ||
444 | for (irq = 0; irq < NR_IRQS_LEGACY; irq++) | ||
445 | xen_bind_pirq_gsi_to_irq(irq, irq, 0, "xt-pic"); | ||
446 | } | ||
447 | return 0; | ||
495 | } | 448 | } |
496 | #endif | ||
497 | 449 | ||
498 | #ifdef CONFIG_XEN_DOM0 | ||
499 | struct xen_device_domain_owner { | 450 | struct xen_device_domain_owner { |
500 | domid_t domain; | 451 | domid_t domain; |
501 | struct pci_dev *dev; | 452 | struct pci_dev *dev; |
diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 30df85d8fca8..da70f5c32eb9 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c | |||
@@ -615,11 +615,6 @@ static int find_irq_by_gsi(unsigned gsi) | |||
615 | return -1; | 615 | return -1; |
616 | } | 616 | } |
617 | 617 | ||
618 | int xen_allocate_pirq_gsi(unsigned gsi) | ||
619 | { | ||
620 | return gsi; | ||
621 | } | ||
622 | |||
623 | /* | 618 | /* |
624 | * Do not make any assumptions regarding the relationship between the | 619 | * Do not make any assumptions regarding the relationship between the |
625 | * IRQ number returned here and the Xen pirq argument. | 620 | * IRQ number returned here and the Xen pirq argument. |
@@ -1693,6 +1688,6 @@ void __init xen_init_IRQ(void) | |||
1693 | } else { | 1688 | } else { |
1694 | irq_ctx_init(smp_processor_id()); | 1689 | irq_ctx_init(smp_processor_id()); |
1695 | if (xen_initial_domain()) | 1690 | if (xen_initial_domain()) |
1696 | xen_setup_pirqs(); | 1691 | pci_xen_initial_domain(); |
1697 | } | 1692 | } |
1698 | } | 1693 | } |
diff --git a/include/xen/events.h b/include/xen/events.h index 9af21e19545a..d287997d3eab 100644 --- a/include/xen/events.h +++ b/include/xen/events.h | |||
@@ -74,8 +74,6 @@ int xen_set_callback_via(uint64_t via); | |||
74 | void xen_evtchn_do_upcall(struct pt_regs *regs); | 74 | void xen_evtchn_do_upcall(struct pt_regs *regs); |
75 | void xen_hvm_evtchn_do_upcall(void); | 75 | void xen_hvm_evtchn_do_upcall(void); |
76 | 76 | ||
77 | /* Allocate a pirq for a physical interrupt, given a gsi. */ | ||
78 | int xen_allocate_pirq_gsi(unsigned gsi); | ||
79 | /* Bind a pirq for a physical interrupt to an irq. */ | 77 | /* Bind a pirq for a physical interrupt to an irq. */ |
80 | int xen_bind_pirq_gsi_to_irq(unsigned gsi, | 78 | int xen_bind_pirq_gsi_to_irq(unsigned gsi, |
81 | unsigned pirq, int shareable, char *name); | 79 | unsigned pirq, int shareable, char *name); |