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

Re: [PATCH v6 7/8] vpci/msi: Free MSI resources when init_msi() fails


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Thu, 19 Jun 2025 08:01:47 +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=zGBSG5Cv4iPoOUtagzQJJy3P/dyWB4ohs1B182hoTdo=; b=FbeRm/QngRuIWdOva1wlI4qmqBSPie6tczXzjhOPtaiQLjm7ntjY2q/SuGOugtuYJ//KaqdhUR72LfkhpWCURUGqwEYzJYjvXXnnCw6yyUO0vuCOnCriEAWZFKL+veXZIdbHtMZHyHN1q7wti+PBdc11P5FD+QbTQWtVRN/RdPPWiVX9g4f6nX/P3cURkgDK4wkDu8NhvtCu5kEnJiyrZX3stJb3tT9+U5I5mvk3o5LY0qLK2resEGZXktAVtgR52KQCvqSbVbXY7jw7VeDrO8p7E6eA0YheuUBjph5FPeLyaKCsduH7gxM1eilzRvxgCT4oJy+dR+l4WxCoqtEW4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M/b3UtQ45g2dmbUctY2HSDyMXdL5RRfAHfmdYFuTrLmiRn6at7RtNkkPO2vbxT68AdTctpVCyXe2cdiYcdSI9RPMsAmzbCuz3RT0kPp4GbNQbQRvZnwNOgR1jtaXErdnASAhbOFSY19AeRsv6HAjts7nUwr/WzTUz1kQf+/dG0wlhKT+LsKOSmZj9ozC5eoqpLURFkVM1hPHikHpoV0IY9p3YgcYEzFnzIildn1M7/3nR+aw/BxKxzme6RK5wGCWunAa4Pwghy5JgiqsxM0DaX4n8wypnR/0aJHk3aIsT5y4FpNFZ8wJZ/ppx7KAboapPnmWq0uOMcSU/VHNbktAxQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Thu, 19 Jun 2025 08:01:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb23yeMT8YFCMR3kaLDqQP1+DTK7QJBi8AgAGktoA=
  • Thread-topic: [PATCH v6 7/8] vpci/msi: Free MSI resources when init_msi() fails

On 2025/6/18 22:37, Jan Beulich wrote:
> On 12.06.2025 11:29, Jiqian Chen wrote:
>> --- a/xen/drivers/vpci/msi.c
>> +++ b/xen/drivers/vpci/msi.c
>> @@ -193,6 +193,33 @@ static void cf_check mask_write(
>>      msi->mask = val;
>>  }
>>  
>> +static int cf_check cleanup_msi(struct pci_dev *pdev)
>> +{
>> +    int rc;
>> +    unsigned int end, size;
>> +    struct vpci *vpci = pdev->vpci;
>> +    const unsigned int msi_pos = pdev->msi_pos;
>> +    const unsigned int ctrl = msi_control_reg(msi_pos);
>> +
>> +    if ( !msi_pos || !vpci->msi )
>> +        return 0;
>> +
>> +    if ( vpci->msi->masking )
>> +        end = msi_pending_bits_reg(msi_pos, vpci->msi->address64);
>> +    else
>> +        end = msi_mask_bits_reg(msi_pos, vpci->msi->address64) - 2;
>> +
>> +    size = end - ctrl;
>> +
>> +    rc = vpci_remove_registers(vpci, ctrl, size);
>> +    if ( rc )
>> +        return rc;
>> +
>> +    XFREE(vpci->msi);
>> +
>> +    return vpci_add_register(pdev->vpci, vpci_hw_read16, NULL, ctrl, 2, 
>> NULL);
> 
> Why not use the local variable "vpci" here?
That's my fault, will change in next version. And the same in msix.c

> 
> I also think this (re)adding warrants a comment, as to why we do this.
I write a draft as below, could you help to modify?
    /*
     * The driver may not traverse the capability list and think device
     * supports MSI by default. So here let the control register of MSI
     * be Read-Only is to ensure MSI disabled.
     */

> 
> Jan

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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