On 27 June 2014 13:52, Alexander Graf <ag...@suse.de> wrote: > From: Alexey Kardashevskiy <a...@ozlabs.ru> > > Currently SPAPR PHB keeps track of all allocated MSI (here and below > MSI stands for both MSI and MSIX) interrupt because > XICS used to be unable to reuse interrupts. This is a problem for > dynamic MSI reconfiguration which happens when guest reloads a driver > or performs PCI hotplug. Another problem is that the existing > implementation can enable MSI on 32 devices maximum > (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason for that. > > This makes use of new XICS ability to reuse interrupts. > > This reorganizes MSI information storage in sPAPRPHBState. Instead of > static array of 32 descriptors (one per a PCI function), this patch adds > a GHashTable when @config_addr is a key and (first_irq, num) pair is > a value. GHashTable can dynamically grow and shrink so the initial limit > of 32 devices is gone.
> +static void spapr_pci_pre_save(void *opaque) > +{ > + sPAPRPHBState *sphb = opaque; > + GHashTableIter iter; > + gpointer key, value; > + int i; > + > + if (sphb->msi_devs) { > + g_free(sphb->msi_devs); > + sphb->msi_devs = NULL; > + } > + sphb->msi_devs_num = g_hash_table_size(sphb->msi); > + if (!sphb->msi_devs_num) { > + return; > + } > + sphb->msi_devs = g_malloc(sphb->msi_devs_num * > sizeof(spapr_pci_msi_mig)); > + > + g_hash_table_iter_init(&iter, sphb->msi); > + for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { > + sphb->msi_devs[i].key = *(uint32_t *) key; > + sphb->msi_devs[i].value = *(spapr_pci_msi *) value; > + } > +} Hi. I'm afraid this doesn't build under glib 2.12: /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c: In function 'spapr_pci_pre_save': /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:710: error: 'GHashTableIter' undeclared (first use in this function) /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:710: error: (Each undeclared identifier is reported only once /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:710: error: for each function it appears in.) /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:710: error: expected ';' before 'iter' /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:724: warning: implicit declaration of function 'g_hash_table_iter_init' /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:724: warning: nested extern declaration of 'g_hash_table_iter_init' /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:724: error: 'iter' undeclared (first use in this function) /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:725: warning: implicit declaration of function 'g_hash_table_iter_next' /home/petmay01/linaro/qemu-for-merges/hw/ppc/spapr_pci.c:725: warning: nested extern declaration of 'g_hash_table_iter_next' g_hash_table_iter_init was only added in glib 2.16; the old style way to do this is using g_hash_table_foreach() (and a helper function). thanks -- PMM