[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v9 8/8] vpci/msix: Free MSIX resources when init_msix() fails


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Wed, 30 Jul 2025 02:52:17 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Dv9krI3OyTUkSux+qLkEi96O7+xVdNvoQ41Cx7SfF70=; b=wF1ZoKpfN+RrmYJWaiJecDnuE3wulP6VKWfhdbCY5qYtu5NlepmJpwS6yJdfPDuharNnGhsXpo299Oh9qXg5A1QRIdf5Qv1q0QZeNqS9sZMhK4vE0tqLQZuaLLOtOU2U/41ZKAbiAcPM4nCVZBj8L767xoPQe+5/x3mKpqcPE7lM+8tcGFknlIXHNnxwdKod+yq2sYpQ3rfkIbsQD5NQ8hBE8Noo9wqnZc44myvjOKfQON+7EPlsr7nv26/5oM6B4JpZg0HmWZJTEuenDKlHninrl+5R/ol5eWm0hM39GkYAe7MGjCJr8qZ6iOAiSslpMT4hjVW5crCMJ5bilVJd7w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bCv8V3uO7Ni+IWfpsztioPMcOg8pjrrMiXd1RCBYx9oMMMnEpKuxA9YfXJ5y8sc1h4f6u62Wji3HW87e66U4iGKqvC7y5gOJ2Dbeq0muz1FDP0D/OqirMWisFrOcExt4fYVjAwErYERdec/7ZRolCo+cKsuQ5A2cduxJbezcy8E7t2FREsgl7R/I6mkWwmK7QfKmyB1i/Jja4i/LLvpaeCVBDBYINkyzW/srcLh/mbM2hkOzTas4ZYivscyqAqqiEpCadATl5cjffGaQu9NQVw/tYj/lno/+8TmQO5AS6SS/GLDfk30qNWqIllafAJC/bNYczh6yRMUx42T23jowuA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Wed, 30 Jul 2025 02:52:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb/30igYEmGROipE+ztoDHPTv4H7RJTtYAgAExLoA=
  • Thread-topic: [PATCH v9 8/8] vpci/msix: Free MSIX resources when init_msix() fails

On 2025/7/30 00:36, Roger Pau Monné wrote:
> On Mon, Jul 28, 2025 at 01:04:01PM +0800, Jiqian Chen wrote:
>> diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
>> index 4b8e6b28bd07..258356019535 100644
>> --- a/xen/drivers/vpci/vpci.c
>> +++ b/xen/drivers/vpci/vpci.c
>> @@ -321,6 +321,14 @@ void vpci_deassign_device(struct pci_dev *pdev)
>>                      &pdev->domain->vpci_dev_assigned_map);
>>  #endif
>>  
>> +    if ( pdev->vpci->msix )
>> +    {
>> +        int rc = cleanup_msix(pdev);
>> +        if ( rc )
>> +            printk(XENLOG_ERR "%pd %pp: fail to cleanup MSIX datas rc=%d\n",
>> +                   pdev->domain, &pdev->sbdf, rc);
>> +    }
>> +
>>      spin_lock(&pdev->vpci->lock);
>>      while ( !list_empty(&pdev->vpci->handlers) )
>>      {
>> @@ -332,18 +340,10 @@ void vpci_deassign_device(struct pci_dev *pdev)
>>          xfree(r);
>>      }
>>      spin_unlock(&pdev->vpci->lock);
>> -    if ( pdev->vpci->msix )
>> -    {
>> -        list_del(&pdev->vpci->msix->next);
>> -        for ( i = 0; i < ARRAY_SIZE(pdev->vpci->msix->table); i++ )
>> -            if ( pdev->vpci->msix->table[i] )
>> -                iounmap(pdev->vpci->msix->table[i]);
>> -    }
>>  
>>      for ( i = 0; i < ARRAY_SIZE(pdev->vpci->header.bars); i++ )
>>          rangeset_destroy(pdev->vpci->header.bars[i].mem);
>>  
>> -    xfree(pdev->vpci->msix);
> 
> Oh, I'm afraid this is not what I was expecting.  You should call all
> the cleanup hooks here, so that you can also remove the vpci->msi
> xfree() (and any future ones).  You want a loop over the array of
> registered vpci_capability_t and call all the defined cleanup()
> methods against the deassigned device IMO.
Oh, sorry to misunderstand.
Will change.

> 
> That avoids having to reference any specific capability here, and new
> capabilities will only need to implement a cleanup handler without
> having to modify vpci_deassign_device().  You won't need to export
> cleanup_msix() either, which is ugly.
> 
> Thanks, Roger.

-- 
Best regards,
Jiqian Chen.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.