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

[RFC QEMU PATCH v6 1/1] xen/pci: get gsi from irq for passthrough devices


  • To: <qemu-devel@xxxxxxxxxx>
  • From: Jiqian Chen <Jiqian.Chen@xxxxxxx>
  • Date: Fri, 19 Apr 2024 12:13:51 +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=9Iegew8C87PUBULbDOFADEVQbH+6F4VJbkJFD0Bu2N0=; b=g1Uo5KDfDTjDEX43xmAZ2MiuMnR11WaFZYTjKEyylvYvpfDHvTkNQpuZmKkQwA4ib9ZFgOUEOwhx8ypy/Yg7npIzvA3zxySRU65aq1YlZUeS/dACy8MqJpkRpIMqtPjftn69GfDAdMLbT2JizXJZa8Xn08N5A8AT6A7Q+HCiAzCObMMwtl1P+QRZr+MPXif4VMbSQHA/mDtPBTOY4VLjd+gT+LuKcNUG9js3THuKfARuRzbqHHrxd8kGy6JAvAaeW2wIauvK0ItW7aZzNDKvcMBs7d/jVKOZrcnReDNJvkGCrabp0jl0Mk1E9/MrTDJE48DTyL0cKM1djASPsAa3wg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=essMYa36UEEL2s0TK5CvDEm1HOTaNT7ZhnKAQHbXgkmE+M6KMaOjUb0GbPwbvPEnYkW9CwOAUkW87MbA4nZfnMjyo4tK/o92pgw7elbDcnHXy1wlfnQBu2CduY1WX0ItU8rkMLHym+Pq4j1pw4N3x/PQsWU8/FBUMihpVRPY3QrPNa2Eq6WoK1kazVtiASJXS13eegNXcEgX01qis6iS7rS6vmKl8OQtC3Kvz7Uq8gYXkVVKrmCIarvBKrjfBMhe4BmVCccn2Z2wFKaXInUMuDS7oOQfygoIggsO/YSR4duIU/NPn75kJn3v9vm0kt3UCeA5/ha1RWEC+Z3bn7zcDg==
  • 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, 19 Apr 2024 04:14:21 +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.

Translate irq to gsi by using new function supported by
Xen tools.

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

diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c
index 8c6e9a1716a2..5e9aa9679e3e 100644
--- a/hw/xen/xen-host-pci-device.c
+++ b/hw/xen/xen-host-pci-device.c
@@ -10,6 +10,7 @@
 #include "qapi/error.h"
 #include "qemu/cutils.h"
 #include "xen-host-pci-device.h"
+#include "hw/xen/xen_native.h"
 
 #define XEN_HOST_PCI_MAX_EXT_CAP \
     ((PCIE_CONFIG_SPACE_SIZE - PCI_CONFIG_SPACE_SIZE) / (PCI_CAP_SIZEOF + 4))
@@ -368,7 +369,11 @@ void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t 
domain,
     if (*errp) {
         goto error;
     }
-    d->irq = v;
+    d->irq = xc_physdev_gsi_from_irq(xen_xc, v);
+    /* if fail to get gsi, fallback to irq */
+    if (d->irq == -1) {
+        d->irq = v;
+    }
 
     xen_host_pci_get_hex_value(d, "class", &v, errp);
     if (*errp) {
-- 
2.34.1




 


Rackspace

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