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

Re: [PATCH v5] vpci: Add resizable bar support


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Wed, 22 Jan 2025 02:50:48 +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=3wBsXJWENb6NtyWsyU6BabsVXTBN5XirCiQcIt5/C0E=; b=gLRlgTh97fP4bVE4L/rFvyj9PAYhgtN1Qn0zN8KJsx0Eeg0pjYrC5z5lCcv0qJ7HWrld9PeuTivySDTnzf+sHLJqbuA/ttn78J5ynmeYBd/A+d5XxPk3KaECNiUMVTBMmNaGYfdoKpg9gBnb9yHmOHwH8umME06QLXhhuN6CsK0fk80DFzWAEejC/AB24cp2iNd1mCqIcmQVCuqTL+BspXb3mvDI6mzOJeFizZ7Np9oayk/6xNKegKBxcoXmB4g3a6Zed6Xi7pVsYiuC567aGV0pZ0xzI8TUS7Qmx2OBXrs41yiJeVDqmmTQBdMQR4AicPlGHKKcM7mML3ZMeZ8eOw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oyunNs0zzgg72DXS1Z6Yrilx3ywn3ApSPAE7B2HQChBERMFqG8j5NfGBiNW87MuEwh9QcOw6kVXJjP2OTBII8mPSiNRFpxQDv40eX9DIHR8hoH7ws8YO5jZ/Wg3uS27VfL5fAuY8yW++wtxB3oftcUm4CuXxH7v62l4NSXnXzgKaLC4t0Fn5cICwiC4kU0dvML3TuyKbMbV2kkZjmiL69YFLUhir2Bk0uOoBPPvkfopNVbP9cwzvrBgMTrtLIP3exrm77ZptWVp/0ZyMg6ZiIrCXzE0K51FZUTkq5jHlQrUEa7LwxCx1dVO3Vh678qANmTdi39AM965wiYJyjeS1cQ==
  • 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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Wed, 22 Jan 2025 02:51:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHbZjRJ+4D0uojYEUmC9gRuRAux1rMg9ZEAgACK3YD//4D+AIAAEMqAgAGX2oA=
  • Thread-topic: [PATCH v5] vpci: Add resizable bar support

On 2025/1/21 18:29, Jan Beulich wrote:
> On 21.01.2025 10:29, Roger Pau Monné wrote:
>> On Tue, Jan 21, 2025 at 09:10:26AM +0000, Chen, Jiqian wrote:
>>> On 2025/1/21 16:46, Roger Pau Monné wrote:
>>>> On Tue, Jan 14, 2025 at 11:26:36AM +0800, Jiqian Chen wrote:
>>>>> +    ctrl = pci_conf_read32(pdev->sbdf, rebar_offset + PCI_REBAR_CTRL(0));
>>>>> +    nbars = MASK_EXTR(ctrl, PCI_REBAR_CTRL_NBAR_MASK);
>>>>> +    for ( unsigned int i = 0; i < nbars; i++ )
>>>>> +    {
>>>>> +        int rc;
>>>>> +        struct vpci_bar *bar;
>>>>> +        unsigned int index;
>>>>> +
>>>>> +        ctrl = pci_conf_read32(pdev->sbdf, rebar_offset + 
>>>>> PCI_REBAR_CTRL(i));
>>>>> +        index = ctrl & PCI_REBAR_CTRL_BAR_IDX;
>>>>> +        if ( index >= PCI_HEADER_NORMAL_NR_BARS )
>>>>> +        {
>>>>> +            printk(XENLOG_ERR "%pd %pp: too big BAR number %u in 
>>>>> REBAR_CTRL\n",
>>>>> +                   pdev->domain, &pdev->sbdf, index);
>>>>> +            continue;
>>>>> +        }
>>>>> +
>>>>> +        bar = &pdev->vpci->header.bars[index];
>>>>> +        if ( bar->type != VPCI_BAR_MEM64_LO && bar->type != 
>>>>> VPCI_BAR_MEM32 )
>>>>> +        {
>>>>> +            printk(XENLOG_ERR "%pd %pp: BAR%u is not in memory space\n",
>>>>> +                   pdev->domain, &pdev->sbdf, index);
>>>>> +            continue;
>>>>> +        }
>>>>> +
>>>>> +        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, 
>>>>> vpci_hw_write32,
>>>>> +                               rebar_offset + PCI_REBAR_CAP(i), 4, NULL);
>>>>> +        if ( rc )
>>>>> +        {
>>>>> +            /*
>>>>> +             * TODO: for failed pathes, need to hide ReBar capability
>>>>> +             * from hardware domain instead of returning an error.
>>>>> +             */
>>>>> +            printk(XENLOG_ERR "%pd %pp: fail to add reg of REBAR_CAP 
>>>>> rc=%d\n",
>>>>> +                   pdev->domain, &pdev->sbdf, rc);
>>>>> +            return rc;
>>>>> +        }
>>>>> +
>>>>> +        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, 
>>>>> rebar_ctrl_write,
>>>>> +                               rebar_offset + PCI_REBAR_CTRL(i), 4, bar);
>>>>> +        if ( rc )
>>>>> +        {
>>>>> +            printk(XENLOG_ERR "%pd %pp: fail to add reg of REBAR_CTRL 
>>>>> rc=%d\n",
>>>>> +                   pdev->domain, &pdev->sbdf, rc);
>>>>> +            return rc;
>>>>
>>>> I think we said we wanted to attempt to continue here, rather than
>>>> returning an error and thus removing all vPCI handlers from the
>>>> device?
>>> I thought the result of your discussion with Jan was that I only needed to 
>>> change the above two error paths to be "continue".
>>> If these two also need to be changed, I will modify them in the next 
>>> version.
>>
>> Hm, let's wait for Jan to confirm, but even if handler cannot be setup
>> for some of the registers, it's better than just allowing dom0
>> unmediated access to the capability.
> 
> I remained silent on this because I accepted this middle ground as ...
> 
>> None of this is ideal, but it seems to be the option that gives dom0
>> most options to successfully boot.
> 
> ... perhaps the most reasonable compromise.
OK, I see.
I will change to "continue" in next version and send v6 soon.
Thank you.

> 
> Jan

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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