Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ian Campbell and committed by
Konrad Rzeszutek Wilk
f4d0635b 0a85226f

+40 -18
+29 -12
arch/x86/pci/xen.c
··· 50 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 55 printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq); 56 56 ··· 237 237 { 238 238 int rc; 239 239 int share = 1; 240 + int pirq; 240 241 u8 gsi; 241 242 242 243 rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi); ··· 247 246 return rc; 248 247 } 249 248 249 + rc = xen_allocate_pirq_gsi(gsi); 250 + if (rc < 0) { 251 + dev_warn(&dev->dev, "Xen PCI: failed to allocate a PIRQ for GSI%d: %d\n", 252 + gsi, rc); 253 + return rc; 254 + } 255 + pirq = rc; 256 + 250 257 if (gsi < NR_IRQS_LEGACY) 251 258 share = 0; 252 259 253 - rc = xen_allocate_pirq(gsi, share, "pcifront"); 260 + rc = xen_bind_pirq_gsi_to_irq(gsi, pirq, share, "pcifront"); 254 261 if (rc < 0) { 255 - dev_warn(&dev->dev, "Xen PCI: failed to register GSI%d: %d\n", 256 - gsi, rc); 262 + dev_warn(&dev->dev, "Xen PCI: failed to bind GSI%d (PIRQ%d) to IRQ: %d\n", 263 + gsi, pirq, rc); 257 264 return rc; 258 265 } 259 266 ··· 318 309 #ifdef CONFIG_XEN_DOM0 319 310 static int xen_register_pirq(u32 gsi, int triggering) 320 311 { 321 - int rc, irq; 312 + int rc, pirq, irq = -1; 322 313 struct physdev_map_pirq map_irq; 323 314 int shareable = 0; 324 315 char *name; ··· 334 325 name = "ioapic-level"; 335 326 } 336 327 337 - irq = xen_allocate_pirq(gsi, shareable, name); 328 + pirq = xen_allocate_pirq_gsi(gsi); 329 + if (pirq < 0) 330 + goto out; 338 331 339 - printk(KERN_DEBUG "xen: --> irq=%d\n", irq); 340 - 332 + irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name); 341 333 if (irq < 0) 342 334 goto out; 335 + 336 + printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq); 343 337 344 338 map_irq.domid = DOMID_SELF; 345 339 map_irq.type = MAP_PIRQ_TYPE_GSI; 346 340 map_irq.index = gsi; 347 - map_irq.pirq = irq; 341 + map_irq.pirq = pirq; 348 342 349 343 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); 350 344 if (rc) { ··· 434 422 435 423 void __init xen_setup_pirqs(void) 436 424 { 437 - int irq; 425 + int pirq, irq; 438 426 439 427 pci_xen_initial_domain(); 440 428 441 429 if (0 == nr_ioapics) { 442 - for (irq = 0; irq < NR_IRQS_LEGACY; irq++) 443 - xen_allocate_pirq(irq, 0, "xt-pic"); 430 + for (irq = 0; irq < NR_IRQS_LEGACY; irq++) { 431 + pirq = xen_allocate_pirq_gsi(irq); 432 + if (WARN(pirq < 0, 433 + "Could not allocate PIRQ for legacy interrupt\n")) 434 + break; 435 + irq = xen_bind_pirq_gsi_to_irq(irq, pirq, 0, "xt-pic"); 436 + } 444 437 return; 445 438 } 446 439
+4 -3
drivers/xen/events.c
··· 568 568 return -1; 569 569 } 570 570 571 - int xen_allocate_pirq(unsigned gsi, int shareable, char *name) 571 + int 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 580 * Note: We don't assign an event channel until the irq actually started 581 581 * up. Return an existing irq if we've already got one for the gsi. 582 582 */ 583 - int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name) 583 + int xen_bind_pirq_gsi_to_irq(unsigned gsi, 584 + unsigned pirq, int shareable, char *name) 584 585 { 585 586 int irq = -1; 586 587 struct physdev_irq irq_op;
+7 -3
include/xen/events.h
··· 68 68 void xen_evtchn_do_upcall(struct pt_regs *regs); 69 69 void xen_hvm_evtchn_do_upcall(void); 70 70 71 - /* Allocate an irq for a physical interrupt, given a gsi. */ 72 - int xen_allocate_pirq(unsigned gsi, int shareable, char *name); 73 - int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name); 71 + /* Allocate a pirq for a physical interrupt, given a gsi. */ 72 + int xen_allocate_pirq_gsi(unsigned gsi); 73 + /* Bind a pirq for a physical interrupt to an irq. */ 74 + int xen_bind_pirq_gsi_to_irq(unsigned gsi, 75 + unsigned pirq, int shareable, char *name); 74 76 75 77 #ifdef CONFIG_PCI_MSI 78 + /* Allocate a pirq for a MSI style physical interrupt. */ 76 79 int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc); 80 + /* Bind an PSI pirq to an irq. */ 77 81 int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, 78 82 int pirq, int vector, const char *name); 79 83 #endif