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

[RFC QEMU PATCH v4 1/1] xen: Use gsi instead of irq for mapping pirq


  • To: <qemu-devel@xxxxxxxxxx>
  • From: Jiqian Chen <Jiqian.Chen@xxxxxxx>
  • Date: Fri, 5 Jan 2024 15:19:19 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=kYi3Wyegxmzc7EKOM+Ed9WYPUa0D9CsuJMsABf608SM=; b=eHQb57cVcUebcD9RgcrPksj1fhwtYaHl0ggtRTmp3ivI1FQ7AsxpHqFwqgWeGzLBTjO6dj72pLeEXe0dktr/fMcpAeG2ingPLixWEdfrU2mEs1aXgHmH9LzAj5VD2LZ3wuF3GN+ENox7U5kCcnZFxnoI75WWdT9m6ybovPq5+LLwlCop+euR7V/yKUy6SVLy9RwJjvWt2yadym6Lnb5Taa63QDL8UvcDV/G1GShxuDbIbBgxDzew2f/LERvlUPAHzNFNN+cL9s5TBVjUdah7eDGxUFbl5HZeVReRku5sVG1i/yr2xRDAnrhhIV9aFfwzPVyyANeSBk1B9HMzaJseXg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTAuZ/j+nsgq9fmtMqNnLUXRIy8V/hZOzfv1AChxlmmzo8jFULZ0tIsqZdRtzQ0tWTUiLGmJ0Qao2Tr8tY1Yk00mVCuRyki3W/6W0LAzqa0Oqvf4zdOEHeiZAB1Vgr8zaePThIOI1HMuEhAaqvrVNvh6+Fsu6xxIOqp+6c3DiT/Lbx5fOzO/HOLgf4tibqu/gFn7Q9SVJBqRbc+vmppzA12WYyHVT9FhYyxEHsPnHFijNFHj+jTRud/wH93/4INGVJy2vwN5X/MBwmYVvhEFp1AUs4RjpXNIUZacFU7S7xosMBOmcd3SXZCcZY6FdAQ6Wx0bhUYJScuJZIK3vb7qHw==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Huang Rui <Ray.Huang@xxxxxxx>, Jiqian Chen <Jiqian.Chen@xxxxxxx>, Huang Rui <ray.huang@xxxxxxx>
  • Delivery-date: Fri, 05 Jan 2024 07:19:52 +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, qemu wants to use
gsi to map pirq, xen_pt_realize->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.

Add gsi into XenHostPCIDevice and use gsi number that
read from gsi sysfs if it exists.

Co-developed-by: Huang Rui <ray.huang@xxxxxxx>
Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
---
 hw/xen/xen-host-pci-device.c | 7 +++++++
 hw/xen/xen-host-pci-device.h | 1 +
 hw/xen/xen_pt.c              | 6 +++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c
index 8c6e9a1716a2..5be3279aa25b 100644
--- a/hw/xen/xen-host-pci-device.c
+++ b/hw/xen/xen-host-pci-device.c
@@ -370,6 +370,13 @@ void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t 
domain,
     }
     d->irq = v;
 
+    xen_host_pci_get_dec_value(d, "gsi", &v, errp);
+    if (*errp) {
+        d->gsi = -1;
+    } else {
+        d->gsi = v;
+    }
+
     xen_host_pci_get_hex_value(d, "class", &v, errp);
     if (*errp) {
         goto error;
diff --git a/hw/xen/xen-host-pci-device.h b/hw/xen/xen-host-pci-device.h
index 4d8d34ecb024..74c552bb5548 100644
--- a/hw/xen/xen-host-pci-device.h
+++ b/hw/xen/xen-host-pci-device.h
@@ -27,6 +27,7 @@ typedef struct XenHostPCIDevice {
     uint16_t device_id;
     uint32_t class_code;
     int irq;
+    int gsi;
 
     XenHostPCIIORegion io_regions[PCI_NUM_REGIONS - 1];
     XenHostPCIIORegion rom;
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index 36e6f93c372f..d448f3a17306 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -839,7 +839,11 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
         goto out;
     }
 
-    machine_irq = s->real_device.irq;
+    if (s->real_device.gsi < 0) {
+        machine_irq = s->real_device.irq;
+    } else {
+        machine_irq = s->real_device.gsi;
+    }
     if (machine_irq == 0) {
         XEN_PT_LOG(d, "machine irq is 0\n");
         cmd |= PCI_COMMAND_INTX_DISABLE;
-- 
2.34.1




 


Rackspace

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