vpci: Use cleanup to free capability resource during deassign

As cleanup hook of all supported capabilities will be implemented in
follow-on changes, so to pre-call hook in vpci_deassign_device(), and
the capability specific clean open-code in there will be removed by
follow-on corresponding capability changes.

Since vpci_deassign_device() and vpci_init_capabilities() require
different cleanup actions, add a boolean parameter to cleanup hook
to distinguish them.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
This commit is contained in:
Jiqian Chen authored and Jan Beulich committed 2025-09-01 13:07:01 +02:00
1 parent 18ba7e257e
commit 70e6dace74
2 files changed
+26 -2

No files matched your search

+25 -1
View File
@@ -280,7 +280,7 @@ static int vpci_init_capabilities(struct pci_dev *pdev)
if ( capability->cleanup )
{
rc = capability->cleanup(pdev);
rc = capability->cleanup(pdev, true);
if ( rc )
{
printk(XENLOG_ERR "%pd %pp: clean %s cap %u fail rc=%d\n",
@@ -321,6 +321,30 @@ void vpci_deassign_device(struct pci_dev *pdev)
&pdev->domain->vpci_dev_assigned_map);
#endif
for ( i = 0; i < NUM_VPCI_INIT; i++ )
{
const vpci_capability_t *capability = &__start_vpci_array[i];
const unsigned int cap = capability->id;
unsigned int pos = 0;
if ( !capability->cleanup )
continue;
if ( !capability->is_ext )
pos = pci_find_cap_offset(pdev->sbdf, cap);
else if ( is_hardware_domain(pdev->domain) )
pos = pci_find_ext_capability(pdev->sbdf, cap);
if ( pos )
{
int rc = capability->cleanup(pdev, false);
if ( rc )
printk(XENLOG_ERR "%pd %pp: clean %s cap %u fail rc=%d\n",
pdev->domain, &pdev->sbdf,
capability->is_ext ? "extended" : "legacy", cap, rc);
}
}
spin_lock(&pdev->vpci->lock);
while ( !list_empty(&pdev->vpci->handlers) )
{
+1 -1
View File
@@ -17,7 +17,7 @@ typedef struct {
unsigned int id;
bool is_ext;
int (* init)(struct pci_dev *pdev);
int (* cleanup)(const struct pci_dev *pdev);
int (* cleanup)(const struct pci_dev *pdev, bool hide);
} vpci_capability_t;
#define VPCI_ECAM_BDF(addr) (((addr) & 0x0ffff000) >> 12)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.