From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [Qemu-devel] [PATCH 1/3] spapr/pci: Consolidate de-allocation of MSIs
Date: Sun, 28 Jul 2019 11:54:44 +1000 [thread overview]
Message-ID: <20190728015444.GB5110@umbus> (raw)
In-Reply-To: <156415227855.1064338.5657793835271464648.stgit@bahia.lan>
[-- Attachment #1: Type: text/plain, Size: 3161 bytes --]
On Fri, Jul 26, 2019 at 04:44:38PM +0200, Greg Kurz wrote:
> When freeing MSIs, we need to:
> - remove them from the machine's MSI bitmap
> - remove them from the IC backend
> - remove them from the PHB's MSI cache
>
> This is currently open coded in two places in rtas_ibm_change_msi(),
> and we're about to need this in spapr_phb_reset() as well. Instead of
> duplicating this code again, make it a destroy function for the PHB's
> MSI cache. Removing an MSI device from the cache will call the destroy
> function internally.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Applied to ppc-for-4.2.
> ---
> hw/ppc/spapr_pci.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 2d5697d119f4..bc22568bfa71 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -336,10 +336,6 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, SpaprMachineState *spapr,
> return;
> }
>
> - if (!smc->legacy_irq_allocation) {
> - spapr_irq_msi_free(spapr, msi->first_irq, msi->num);
> - }
> - spapr_irq_free(spapr, msi->first_irq, msi->num);
> if (msi_present(pdev)) {
> spapr_msi_setmsg(pdev, 0, false, 0, 0);
> }
> @@ -409,10 +405,6 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, SpaprMachineState *spapr,
>
> /* Release previous MSIs */
> if (msi) {
> - if (!smc->legacy_irq_allocation) {
> - spapr_irq_msi_free(spapr, msi->first_irq, msi->num);
> - }
> - spapr_irq_free(spapr, msi->first_irq, msi->num);
> g_hash_table_remove(phb->msi, &config_addr);
> }
>
> @@ -1806,6 +1798,19 @@ static void spapr_phb_unrealize(DeviceState *dev, Error **errp)
> memory_region_del_subregion(get_system_memory(), &sphb->mem32window);
> }
>
> +static void spapr_phb_destroy_msi(gpointer opaque)
> +{
> + SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> + SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
> + spapr_pci_msi *msi = opaque;
> +
> + if (!smc->legacy_irq_allocation) {
> + spapr_irq_msi_free(spapr, msi->first_irq, msi->num);
> + }
> + spapr_irq_free(spapr, msi->first_irq, msi->num);
> + g_free(msi);
> +}
> +
> static void spapr_phb_realize(DeviceState *dev, Error **errp)
> {
> /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user
> @@ -2017,7 +2022,8 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
> spapr_tce_get_iommu(tcet));
> }
>
> - sphb->msi = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
> + sphb->msi = g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
> + spapr_phb_destroy_msi);
> return;
>
> unrealize:
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-07-28 2:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 14:44 [Qemu-devel] [PATCH 0/3] spapr/pci: Improve MSI tracking Greg Kurz
2019-07-26 14:44 ` [Qemu-devel] [PATCH 1/3] spapr/pci: Consolidate de-allocation of MSIs Greg Kurz
2019-07-26 14:56 ` Cédric Le Goater
2019-07-28 1:54 ` David Gibson [this message]
2019-07-26 14:44 ` [Qemu-devel] [PATCH 2/3] spapr/pci: Free MSIs during reset Greg Kurz
2019-07-26 14:56 ` Cédric Le Goater
2019-07-26 16:17 ` Philippe Mathieu-Daudé
2019-07-26 17:04 ` Greg Kurz
2019-07-28 7:06 ` David Gibson
2019-07-26 14:44 ` [Qemu-devel] [PATCH 3/3] spapr/irq: Drop spapr_irq_msi_reset() Greg Kurz
2019-07-26 15:01 ` Cédric Le Goater
2019-07-26 15:06 ` Greg Kurz
2019-07-28 7:07 ` David Gibson
2019-07-28 1:51 ` [Qemu-devel] [PATCH 0/3] spapr/pci: Improve MSI tracking David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190728015444.GB5110@umbus \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).