aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci/xen.c
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 /arch/x86/pci/xen.c
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>
Diffstat (limited to 'arch/x86/pci/xen.c')
-rw-r--r--arch/x86/pci/xen.c41
1 files changed, 29 insertions, 12 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