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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "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>
  • From: Jiqian Chen <Jiqian.Chen@xxxxxxx>
  • Date: Mon, 11 Dec 2023 00:40:09 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=0UpkM/2hZ/hyd7VzUuA87GzjsofrR7iewcvgg+VyOL8=; b=LZkLlqR6S6olkzyfAhQsF+qmfvKaHtkVrAHBt/WjeEHr+IFeKf2WiYg3NBwFYhJ+IRPRMIG5FoH7uWBcMeSP0t1nH46hFx2bKX0BHsyeLg0bo2VkXwvRlrEMfy79RvuxzmSXAJLeS1zlAcb/nH1GdemofyP+6DaITykw7dlQKzPWp4NGr6+mYLDuSvmuuzhcxbA16msV+IH5Lm0cAMrHxJVvBOy940z9xxG/iBortA9d+cL8N+JV2LqX+8Ifbk9R6DhMT418vgQOP/JCD7XUPuYD2uK/OegwasWwUBt2RC2ERovadhCSdEzOGHOk4J+DB0X36iymjJRx21iXgySLAw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g/eR3SBaxHDNvF/KQoywjcPbxFRHxlhtRmf6v3+n+qx1hYPBmv9XafdA31vS1vkh9tJnD1Wyc+BXwmMIwi/UWbjDsYlPQcJ9eiyk6JgH7IPg4pkhNpHHtK3m2pYOpzFiYEBN9rWHOZnAjofz3C2ApVKsRg8Uk0+sWGlUUQTgdpr0Q3AW4qUJP/n5cptzc87Suo+lYcS2oP7gocZC+nXzsPeuySHzdX9zN7ggmQiSyTpJOtYzINRHEdIV/+xCK8VaiBUj6eh4/YDd2aLPml1l5Y4hvzoJOdT9nRlRjrfO1NwuqKU2dX1O8CCZku2hIILU6/ICtJIC8s1kuuQoSKyqUA==
  • Cc: Stewart Hildebrand <Stewart.Hildebrand@xxxxxxx>, Alex Deucher <Alexander.Deucher@xxxxxxx>, Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>, Huang Rui <Ray.Huang@xxxxxxx>, Honglei Huang <Honglei1.Huang@xxxxxxx>, Julia Zhang <Julia.Zhang@xxxxxxx>, Jiqian Chen <Jiqian.Chen@xxxxxxx>, Huang Rui <ray.huang@xxxxxxx>
  • Delivery-date: Sun, 10 Dec 2023 16:40:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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;
 
     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);
     f = fopen(sysfs_path, "r");
     if (f == NULL) {
         LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
         goto out_no_irq;
     }
-    if ((fscanf(f, "%u", &irq) == 1) && irq) {
-        r = xc_physdev_map_pirq(ctx->xch, domid, irq, &irq);
+    if ((fscanf(f, "%u", &gsi) == 1) && gsi) {
+        r = xc_physdev_map_pirq(ctx->xch, domid, gsi, &gsi);
         if (r < 0) {
-            LOGED(ERROR, domainid, "xc_physdev_map_pirq irq=%d (error=%d)",
-                  irq, r);
+            LOGED(ERROR, domainid, "xc_physdev_map_pirq gsi=%d (error=%d)",
+                  gsi, r);
             fclose(f);
             rc = ERROR_FAIL;
             goto out;
         }
-        r = xc_domain_irq_permission(ctx->xch, domid, irq, 1);
+        r = xc_domain_irq_permission(ctx->xch, domid, gsi, 1);
         if (r < 0) {
             LOGED(ERROR, domainid,
-                  "xc_domain_irq_permission irq=%d (error=%d)", irq, r);
+                  "xc_domain_irq_permission gsi=%d (error=%d)", gsi, r);
             fclose(f);
             rc = ERROR_FAIL;
             goto out;
-- 
2.34.1




 


Rackspace

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