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

Re: [RFC XEN PATCH v3 3/3] libxl: Use gsi instead of irq for mapping pirq


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Tue, 12 Dec 2023 06:55:02 +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=Xhub4pGIBu+Gf0Os2dvF3Ce35UcIgyx631hZF4gXrp8=; b=Dm+k8TEPAWTc9s7iqD3+zXagftpnahudvaS70dkfnz2QCvkb4k6EZDqVfACl8mlqjM00spBC00DuT2f9KHgX0jyNBKS9QNCugRS4fNzf3i9zWjgvkKzegRPtAfaF6HmG1nwm8ttWxfDIuv9xZVkQxKCB921rUqmcltxWH7p3tDyLuFyM4PxH0Cbkhdm6lEO6YmBYRVWHQCNW7DDOtYgmX6+tjBDIquUZJGv0F881wKiVUn+3ZlKWStiZNmKfceGHEDg62KyXzsQEZTpnZWI4FeHKeSrrt8jmwH6mhO6uIpUA7gruOVmQRmV5NmjNVJ8kS1xcfQazN2LqZn9CdjzB8Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHHFSMlBnYjyIEPvW89KjKWmstKiH2/dYzu7DymQvZ0vN53RYQd4E3tRM2lbNCNNESSWN9N7WPFl/9D8qKtpoA1UjWHCi3IP4eSb7dLj5b9JBsJ3xWi0A6m3fLGjr7aEvdXCdFV5lrg/BA41/bTR7abW00yVukxlwYLHj4/b7WalGtelrQ9trEnmQ2QcPIcDoFUvfdwchwU/F6WSVX7x51ubcZAsP2OHpAYICAa8o1Th0QbR601Gbh1SAT2Y0K4jvq0myhEIAmptglOba8oobnC1P6C0MMx9wtCxl5KMEEV1Pq3NXnBtrRnse04ItzwS4Ub1O7ESTob1sNbAbvgMRw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, "Deucher, Alexander" <Alexander.Deucher@xxxxxxx>, "Ragiadakou, Xenia" <Xenia.Ragiadakou@xxxxxxx>, "Stabellini, Stefano" <stefano.stabellini@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "Huang, Honglei1" <Honglei1.Huang@xxxxxxx>, "Zhang, Julia" <Julia.Zhang@xxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Tue, 12 Dec 2023 06:55:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaK4efi9v9r/9A7ES/pcP+ty7EpLCkPA2AgAGBxYA=
  • Thread-topic: [RFC XEN PATCH v3 3/3] libxl: Use gsi instead of irq for mapping pirq

On 2023/12/11 23:48, Roger Pau Monné wrote:
> On Mon, Dec 11, 2023 at 12:40:09AM +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>
>> Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
>> ---
>>  tools/libs/light/libxl_pci.c | 18 +++++++++---------
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
>> index 96cb4da079..9e75f0c263 100644
>> --- a/tools/libs/light/libxl_pci.c
>> +++ b/tools/libs/light/libxl_pci.c
>> @@ -1416,7 +1416,7 @@ static void pci_add_dm_done(libxl__egc *egc,
>>      char *sysfs_path;
>>      FILE *f;
>>      unsigned long long start, end, flags, size;
>> -    int irq, i;
>> +    int gsi, i;
>>      int r;
>>      uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
>>      uint32_t domainid = domid;
>> @@ -1439,7 +1439,7 @@ static void pci_add_dm_done(libxl__egc *egc,
>>                             pci->bus, pci->dev, pci->func);
>>      f = fopen(sysfs_path, "r");
>>      start = end = flags = size = 0;
>> -    irq = 0;
>> +    gsi = 0;
> 
> unsigned int (so it matches the fscanf format), and initialized at
> definition.
As what you said below, I need to use irq if there is no gsi sysfs. So, I think 
it is not necessary to change the name of this local variable.

> 
>>  
>>      if (f == NULL) {
>>          LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
>> @@ -1478,26 +1478,26 @@ 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);
> 
> You need to keep the fallback mechanism of reading the irq node, or
> else xl would stop working on any kernel that doesn't expose this
> sysfs node, you would break passthrough on all current Linux versions.
Yes, you are right. If there is no gsi sysfs, will still use irq, in next 
version. Thanks.

> 
> 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®.