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

Re: [RFC XEN PATCH v5 4/5] libxl: Use gsi instead of irq for mapping pirq


  • To: Anthony PERARD <anthony.perard@xxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Thu, 22 Feb 2024 06:48: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=arcselector9901; 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=1Nfz7P6UJHvUs6YcEs4ycdOvGyo632KuQH4oNfnI+78=; b=Q37wswcbCTUs7+BFvvJR2rPo4MT4e2Ji7b1ROqcnU6aTGPp0S++F0JjZwIi6XwKOYHr4YE6e9qXyN3fkKKFjMPIx4hToRfd3w/PVHcqLg/9EKZgIxrK7dREPuaZFPjANXR+KN/wHZrRPS9QnWvb7YlT8QpNC/6c/6pSRC7Sh5zZWctbTMUq+2dzDdHDE548ezzw87WOMoNHycYzEO6MSLzElxcNePKe6CRDfm4vq37KbPcZ8kLRtsQMhM7CbH5GRbI5IdhnJngiOF/d/UE0Y6q54wCuFyPEy4dHchGLFY2jkq3jG5W+DDE1J/6mIwvalegoRqathq73AUK8sfs2xvA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iiqJcXYUmILCMol7m5G5CXvKI4Txm5VVPmAailYx2C/QmhehQB2p3i0pmJEWN2MfczEyzzr6Mm2Tcz0uQfaYMsCsb9rfeYnKVz6JX4PSQW1/TxbHqzCrADsAZ04EFEnHmFNcfYKCWU/8zXJYn94ICxNXxa+I+wldn/dGD8dwD56BO7Uzd9/RMRVdgOmHcS4oc6NWUyCongdJaPYAenRepYOmGtkjrPus2eNKTgo7Qg60CLH6eT4Yxsj12fqhcYDDbCH/QxLjXqa1bTyEWkcm6dEj75QYdD+TMhEISLzr0wqOh1TT836OUpZT4EtvliMb82Y9i0UYJ8/7jvrdL6ekPA==
  • 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>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Thu, 22 Feb 2024 06:49:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaRR630AyI7Bl4yEKb4z8ADq0CA7EVDEGAgAGgyAA=
  • Thread-topic: [RFC XEN PATCH v5 4/5] libxl: Use gsi instead of irq for mapping pirq

Hi Anthony,

On 2024/2/21 21:38, Anthony PERARD wrote:
> Hi Jiqian,
> 
> On Fri, Jan 12, 2024 at 02:13:16PM +0800, Jiqian Chen wrote:
>> In PVH dom0, it uses the linux local interrupt mechanism,
>> when it allocs irq for a gsi, it is dynamic, and follow
>> the principle of applying first, distributing first. And
>> the irq number is alloced from small to large, but the
>> applying gsi number is not, may gsi 38 comes before gsi
>> 28, that causes the irq number is not equal with the gsi
>> number. And when passthrough a device, xl wants to use
>> gsi to map pirq, see pci_add_dm_done->xc_physdev_map_pirq,
>> but the gsi number is got from file
>> /sys/bus/pci/devices/<sbdf>/irq in current code, so it
>> will fail when mapping.
>>
>> So, use real gsi number read from gsi sysfs.
>>
>> Co-developed-by: Huang Rui <ray.huang@xxxxxxx>
> 
> The "Co-developed-by" tag isn't really defined in Xen, it's fine to keep
> I guess, but it mean that another tag is missing, I'm pretty sure you
> need to add "Signed-off-by: Huang Rui <ray.huang@xxxxxxx>"
Ok, will add this in next version.

> 
> Beyond that, the patch looks good, I've only coding style issues.
There are two encoding styles in the current file, and I was also struggling 
with which one to follow when I write my code, it seems that I made the wrong 
choice.
Thank you very much for your suggestions. I will fix all coding style issues 
that you pointed out in next version.

> 
>> Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
>> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
>> ---
>>  tools/libs/light/libxl_pci.c | 25 +++++++++++++++++++++++--
>>  1 file changed, 23 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
>> index 96cb4da0794e..a1c6e82631e9 100644
>> --- a/tools/libs/light/libxl_pci.c
>> +++ b/tools/libs/light/libxl_pci.c
>> @@ -1478,8 +1478,19 @@ static void pci_add_dm_done(libxl__egc *egc,
>>      fclose(f);
>>      if (!pci_supp_legacy_irq())
>>          goto out_no_irq;
>> -    sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain,
>> +    sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/gsi", pci->domain,
>>                                  pci->bus, pci->dev, pci->func);
>> +
>> +    if ( access(sysfs_path, F_OK) != 0 ) {
> 
> So, the coding style in libxl is a bit different, first could you store
> the return value of access() in 'r', then check that value? Then
> "if (r)" will be enough, no need for "!= 0".
> 
> Second, there's no around space the condition in the if statement, so
> just "if (r)".
> 
>> +        if ( errno == ENOENT )
>> +            sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", 
>> pci->domain,
>> +                                pci->bus, pci->dev, pci->func);
> 
> Has the else part of this if..else is in a {}-block, could you add { }
> here, for the if part? To quote the CODING_STYLE libxl document: "To
> avoid confusion, either all the blocks in an if...else chain have
> braces, or none of them do.
> 
>> +        else {
>> +            LOGED(ERROR, domainid, "Can't access %s", sysfs_path);
> 
> This error message is kind of redundant, we could could simply let the code
> try fopen() on this "/gsi" path, even if we know that it's not going to
> work, as the error check on fopen() will produce the same error message.
> ;-)
> 
> And without that else part, the code could be simplified to:
> 
>     /* If /gsi path doesn't exist, fallback to /irq */
>     if (r && errno == ENOENT)
>         sysfs_path = "..../irq";
> 
> 
> 
> And those comments also apply to the changes in pci_remove_detached().
> 
> Thanks,
> 

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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