From e6c866d417d1a09536f489e66c21cf49b7ec60b6 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 15 Sep 2011 20:49:49 +0000 Subject: pseries: Refactor spapr irq allocation Paulo Bonzini changed the original spapr code, which manually assigned irq numbers for each virtual device, to allocate them automatically from the device initialization. That allowed spapr virtual devices to be constructed with -device, which is a good start. However, the way that patch worked doesn't extend nicely for the future when we want to support devices other than sPAPR VIO devices (e.g. virtio and PCI). This patch rearranges the irq allocation to be global across the sPAPR environment, so it can be used by other bus types as well. Signed-off-by: David Gibson Signed-off-by: Alexander Graf --- hw/spapr_vio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'hw/spapr_vio.c') diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index 0546ccb043..35818e18f1 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -600,7 +600,6 @@ static int spapr_vio_busdev_init(DeviceState *qdev, DeviceInfo *qinfo) { VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qinfo; VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev; - VIOsPAPRBus *bus = DO_UPCAST(VIOsPAPRBus, bus, dev->qdev.parent_bus); char *id; if (asprintf(&id, "%s@%x", info->dt_name, dev->reg) < 0) { @@ -608,10 +607,11 @@ static int spapr_vio_busdev_init(DeviceState *qdev, DeviceInfo *qinfo) } dev->qdev.id = id; - if (!dev->vio_irq_num) { - dev->vio_irq_num = bus->irq++; + + dev->qirq = spapr_allocate_irq(dev->vio_irq_num, &dev->vio_irq_num); + if (!dev->qirq) { + return -1; } - dev->qirq = spapr_find_qirq(spapr, dev->vio_irq_num); rtce_init(dev); @@ -666,7 +666,6 @@ VIOsPAPRBus *spapr_vio_bus_init(void) qbus = qbus_create(&spapr_vio_bus_info, dev, "spapr-vio"); bus = DO_UPCAST(VIOsPAPRBus, bus, qbus); - bus->irq = 16; /* hcall-vio */ spapr_register_hypercall(H_VIO_SIGNAL, h_vio_signal); -- cgit v1.2.3