aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-03-10 11:08:07 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-03-10 14:48:37 -0500
commitf4d0635bf8894b7ba43d7a54733f3e26fe6ced2e (patch)
tree5f55817bb87ef63694e6ee7cc967ad4dfba3324c
parent0a85226ff291a59b2d6596b28bbc4fe368ee5266 (diff)
xen: events: refactor GSI pirq bindings functions
Following the example set by xen_allocate_pirq_msi and xen_bind_pirq_msi_to_irq: xen_allocate_pirq becomes xen_allocate_pirq_gsi and now only allocates a pirq number and does not bind it. xen_map_pirq_gsi becomes xen_bind_pirq_gsi_to_irq and binds an existing pirq. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r--arch/x86/pci/xen.c41
-rw-r--r--drivers/xen/events.c7
-rw-r--r--include/xen/events.h10
3 files changed, 40 insertions, 18 deletions
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 8c4085a95ef1..e37b407a0ee8 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -50,7 +50,7 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
50 name = "ioapic-level"; 50 name = "ioapic-level";
51 } 51 }
52 52
53 irq = xen_map_pirq_gsi(map_irq.pirq, gsi, shareable, name); 53 irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name);
54 54
55 printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq); 55 printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq);
56 56
@@ -237,6 +237,7 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)
237{ 237{
238 int rc; 238 int rc;
239 int share = 1; 239 int share = 1;
240 int pirq;
240 u8 gsi; 241 u8 gsi;
241 242
242 rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi); 243 rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
@@ -246,13 +247,21 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)
246 return rc; 247 return rc;
247 } 248 }
248 249
250 rc = xen_allocate_pirq_gsi(gsi);
251 if (rc < 0) {
252 dev_warn(&dev->dev, "Xen PCI: failed to allocate a PIRQ for GSI%d: %d\n",
253 gsi, rc);
254 return rc;
255 }
256 pirq = rc;
257
249 if (gsi < NR_IRQS_LEGACY) 258 if (gsi < NR_IRQS_LEGACY)
250 share = 0; 259 share = 0;
251 260
252 rc = xen_allocate_pirq(gsi, share, "pcifront"); 261 rc = xen_bind_pirq_gsi_to_irq(gsi, pirq, share, "pcifront");
253 if (rc < 0) { 262 if (rc < 0) {
254 dev_warn(&dev->dev, "Xen PCI: failed to register GSI%d: %d\n", 263 dev_warn(&dev->dev, "Xen PCI: failed to bind GSI%d (PIRQ%d) to IRQ: %d\n",
255 gsi, rc); 264 gsi, pirq, rc);
256 return rc; 265 return rc;
257 } 266 }
258 267
@@ -309,7 +318,7 @@ int __init pci_xen_hvm_init(void)
309#ifdef CONFIG_XEN_DOM0 318#ifdef CONFIG_XEN_DOM0
310static int xen_register_pirq(u32 gsi, int triggering) 319static int xen_register_pirq(u32 gsi, int triggering)
311{ 320{
312 int rc, irq; 321 int rc, pirq, irq = -1;
313 struct physdev_map_pirq map_irq; 322 struct physdev_map_pirq map_irq;
314 int shareable = 0; 323 int shareable = 0;
315 char *name; 324 char *name;
@@ -325,17 +334,20 @@ static int xen_register_pirq(u32 gsi, int triggering)
325 name = "ioapic-level"; 334 name = "ioapic-level";
326 } 335 }
327 336
328 irq = xen_allocate_pirq(gsi, shareable, name); 337 pirq = xen_allocate_pirq_gsi(gsi);
329 338 if (pirq < 0)
330 printk(KERN_DEBUG "xen: --> irq=%d\n", irq); 339 goto out;
331 340
341 irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name);
332 if (irq < 0) 342 if (irq < 0)
333 goto out; 343 goto out;
334 344
345 printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq);
346
335 map_irq.domid = DOMID_SELF; 347 map_irq.domid = DOMID_SELF;
336 map_irq.type = MAP_PIRQ_TYPE_GSI; 348 map_irq.type = MAP_PIRQ_TYPE_GSI;
337 map_irq.index = gsi; 349 map_irq.index = gsi;
338 map_irq.pirq = irq; 350 map_irq.pirq = pirq;
339 351
340 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); 352 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
341 if (rc) { 353 if (rc) {
@@ -422,13 +434,18 @@ static int __init pci_xen_initial_domain(void)
422 434
423void __init xen_setup_pirqs(void) 435void __init xen_setup_pirqs(void)
424{ 436{
425 int irq; 437 int pirq, irq;
426 438
427 pci_xen_initial_domain(); 439 pci_xen_initial_domain();
428 440
429 if (0 == nr_ioapics) { 441 if (0 == nr_ioapics) {
430 for (irq = 0; irq < NR_IRQS_LEGACY; irq++) 442 for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
431 xen_allocate_pirq(irq, 0, "xt-pic"); 443 pirq = xen_allocate_pirq_gsi(irq);
444 if (WARN(pirq < 0,
445 "Could not allocate PIRQ for legacy interrupt\n"))
446 break;
447 irq = xen_bind_pirq_gsi_to_irq(irq, pirq, 0, "xt-pic");
448 }
432 return; 449 return;
433 } 450 }
434 451
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index e828456777e5..a40b2a1c6255 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -568,9 +568,9 @@ static int find_irq_by_gsi(unsigned gsi)
568 return -1; 568 return -1;
569} 569}
570 570
571int xen_allocate_pirq(unsigned gsi, int shareable, char *name) 571int xen_allocate_pirq_gsi(unsigned gsi)
572{ 572{
573 return xen_map_pirq_gsi(gsi, gsi, shareable, name); 573 return gsi;
574} 574}
575 575
576/* 576/*
@@ -580,7 +580,8 @@ int xen_allocate_pirq(unsigned gsi, int shareable, char *name)
580 * Note: We don't assign an event channel until the irq actually started 580 * Note: We don't assign an event channel until the irq actually started
581 * up. Return an existing irq if we've already got one for the gsi. 581 * up. Return an existing irq if we've already got one for the gsi.
582 */ 582 */
583int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name) 583int xen_bind_pirq_gsi_to_irq(unsigned gsi,
584 unsigned pirq, int shareable, char *name)
584{ 585{
585 int irq = -1; 586 int irq = -1;
586 struct physdev_irq irq_op; 587 struct physdev_irq irq_op;
diff --git a/include/xen/events.h b/include/xen/events.h
index 99a64f045732..32ebebacee7f 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -68,12 +68,16 @@ int xen_set_callback_via(uint64_t via);
68void xen_evtchn_do_upcall(struct pt_regs *regs); 68void xen_evtchn_do_upcall(struct pt_regs *regs);
69void xen_hvm_evtchn_do_upcall(void); 69void xen_hvm_evtchn_do_upcall(void);
70 70
71/* Allocate an irq for a physical interrupt, given a gsi. */ 71/* Allocate a pirq for a physical interrupt, given a gsi. */
72int xen_allocate_pirq(unsigned gsi, int shareable, char *name); 72int xen_allocate_pirq_gsi(unsigned gsi);
73int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name); 73/* Bind a pirq for a physical interrupt to an irq. */
74int xen_bind_pirq_gsi_to_irq(unsigned gsi,
75 unsigned pirq, int shareable, char *name);
74 76
75#ifdef CONFIG_PCI_MSI 77#ifdef CONFIG_PCI_MSI
78/* Allocate a pirq for a MSI style physical interrupt. */
76int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc); 79int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc);
80/* Bind an PSI pirq to an irq. */
77int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, 81int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc,
78 int pirq, int vector, const char *name); 82 int pirq, int vector, const char *name);
79#endif 83#endif