From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jiqian Chen <Jiqian.Chen@amd.com>
Cc: xen-devel@lists.xenproject.org, Huang Rui <ray.huang@amd.com>
Subject: Re: [PATCH v5 10/10] vpci/msix: Free MSIX resources when init_msix() fails
Date: Thu, 5 Jun 2025 17:34:11 +0200 [thread overview]
Message-ID: <aEG482WJWGu_ZHQ6@macbook.local> (raw)
In-Reply-To: <20250526094559.140423-11-Jiqian.Chen@amd.com>
On Mon, May 26, 2025 at 05:45:59PM +0800, Jiqian Chen wrote:
> When init_msix() fails, current logic return fail and free MSIX-related
> resources in vpci_deassign_device(). But the previous new changes will
> hide MSIX capability and return success, it can't reach
> vpci_deassign_device() to remove resources if hiding success, so those
> resources must be removed in cleanup function of MSIX.
>
> To do that, implement cleanup function for MSIX.
>
> Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
> ---
> cc: "Roger Pau Monné" <roger.pau@citrix.com>
> ---
> v4->v5 changes:
> * Change definition "static void cleanup_msix" to "static int cf_check cleanup_msix" since cleanup hook is changed to be int.
> * Add a read-only register for MSIX Control Register in the end of cleanup_msix().
>
> v3->v4 changes:
> * Change function name from fini_msix() to cleanup_msix().
> * Change to use XFREE to free vpci->msix.
> * In cleanup function, change the sequence of check and remove action according to init_msix().
>
> v2->v3 changes:
> * Remove unnecessary clean operations in fini_msix().
>
> v1->v2 changes:
> new patch.
>
> Best regards,
> Jiqian Chen.
> ---
> xen/drivers/vpci/msix.c | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
> index 674815ead025..cf79320d3b6f 100644
> --- a/xen/drivers/vpci/msix.c
> +++ b/xen/drivers/vpci/msix.c
> @@ -655,6 +655,33 @@ int vpci_make_msix_hole(const struct pci_dev *pdev)
> return 0;
> }
>
> +static int cf_check cleanup_msix(struct pci_dev *pdev)
> +{
> + int rc;
> + struct vpci *vpci = pdev->vpci;
> + const unsigned int msix_pos = pdev->msix_pos;
> +
> + if ( !msix_pos )
> + return 0;
> +
> + rc = vpci_remove_registers(vpci, msix_control_reg(msix_pos), 2);
> + if ( rc )
> + return rc;
> +
> + if ( !vpci->msix )
> + return 0;
You cannot short-circuit here, as it then prevents adding the dummy
handlers done in the last return.
> +
> + for ( unsigned int i = 0; i < ARRAY_SIZE(vpci->msix->table); i++ )
> + if ( vpci->msix->table[i] )
> + iounmap(vpci->msix->table[i]);
> +
> + list_del(&vpci->msix->next);
> + XFREE(vpci->msix);
> +
> + return vpci_add_register(pdev->vpci, vpci_hw_read16, NULL,
> + msix_control_reg(msix_pos), 2, NULL);
The above needs to be added even if !vpci->msix.
Thanks, Roger.
next prev parent reply other threads:[~2025-06-05 15:34 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-26 9:45 [PATCH v5 00/10] Support hiding capability when its initialization fails Jiqian Chen
2025-05-26 9:45 ` [PATCH v5 01/10] vpci/header: Move emulating cap list logic into new function Jiqian Chen
2025-05-26 9:45 ` [PATCH v5 02/10] vpci/header: Emulate legacy capability list for dom0 Jiqian Chen
2025-06-05 10:54 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 03/10] vpci/header: Emulate extended " Jiqian Chen
2025-06-05 11:24 ` Roger Pau Monné
2025-06-06 4:05 ` Chen, Jiqian
2025-05-26 9:45 ` [PATCH v5 04/10] vpci: Refactor REGISTER_VPCI_INIT Jiqian Chen
2025-06-05 12:50 ` Roger Pau Monné
2025-06-05 12:59 ` Jan Beulich
2025-06-06 6:29 ` Chen, Jiqian
2025-06-06 7:05 ` Jan Beulich
2025-06-06 9:14 ` Roger Pau Monné
2025-06-09 7:50 ` Chen, Jiqian
2025-06-09 9:29 ` Roger Pau Monné
2025-06-09 10:18 ` Chen, Jiqian
2025-06-09 10:40 ` Roger Pau Monné
2025-06-10 3:52 ` Chen, Jiqian
2025-06-10 7:08 ` Jan Beulich
2025-06-10 9:03 ` Chen, Jiqian
2025-06-11 10:19 ` Chen, Jiqian
2025-06-11 10:57 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 05/10] vpci: Hide legacy capability when it fails to initialize Jiqian Chen
2025-06-05 13:35 ` Roger Pau Monné
2025-06-06 7:03 ` Chen, Jiqian
2025-06-06 9:16 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 06/10] vpci: Hide extended " Jiqian Chen
2025-06-05 14:47 ` Roger Pau Monné
2025-06-06 8:30 ` Chen, Jiqian
2025-06-06 9:18 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 07/10] vpci: Refactor vpci_remove_register to remove matched registers Jiqian Chen
2025-06-05 15:00 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 08/10] vpci/rebar: Free Rebar resources when init_rebar() fails Jiqian Chen
2025-06-05 15:14 ` Roger Pau Monné
2025-06-06 8:32 ` Chen, Jiqian
2025-06-06 9:20 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 09/10] vpci/msi: Free MSI resources when init_msi() fails Jiqian Chen
2025-06-05 15:19 ` Roger Pau Monné
2025-06-06 8:38 ` Chen, Jiqian
2025-06-06 9:21 ` Roger Pau Monné
2025-05-26 9:45 ` [PATCH v5 10/10] vpci/msix: Free MSIX resources when init_msix() fails Jiqian Chen
2025-06-05 15:34 ` Roger Pau Monné [this message]
2025-06-06 8:44 ` Chen, Jiqian
2025-06-06 9:23 ` Roger Pau Monné
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=aEG482WJWGu_ZHQ6@macbook.local \
--to=roger.pau@citrix.com \
--cc=Jiqian.Chen@amd.com \
--cc=ray.huang@amd.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.