|
|
9c6c51 |
From 8996236421b4adf090ac721e8d525953deb9687a Mon Sep 17 00:00:00 2001
|
|
|
9c6c51 |
Message-Id: <8996236421b4adf090ac721e8d525953deb9687a@dist-git>
|
|
|
9c6c51 |
From: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
9c6c51 |
Date: Fri, 3 May 2019 13:54:52 +0200
|
|
|
9c6c51 |
Subject: [PATCH] qemu_domain: NVLink2 bridge detection function for PPC64
|
|
|
9c6c51 |
|
|
|
9c6c51 |
The NVLink2 support in QEMU implements the detection of NVLink2
|
|
|
9c6c51 |
capable devices by verifying the attributes of the VFIO mem region
|
|
|
9c6c51 |
QEMU allocates for the NVIDIA GPUs. To properly allocate an
|
|
|
9c6c51 |
adequate amount of memLock, Libvirt needs this information before
|
|
|
9c6c51 |
a QEMU instance is even created, thus querying QEMU is not
|
|
|
9c6c51 |
possible and opening a VFIO window is too much.
|
|
|
9c6c51 |
|
|
|
9c6c51 |
An alternative is presented in this patch. Making the following
|
|
|
9c6c51 |
assumptions:
|
|
|
9c6c51 |
|
|
|
9c6c51 |
- if we want GPU RAM to be available in the guest, an NVLink2 bridge
|
|
|
9c6c51 |
must be passed through;
|
|
|
9c6c51 |
|
|
|
9c6c51 |
- an unknown PCI device can be classified as a NVLink2 bridge
|
|
|
9c6c51 |
if its device tree node has 'ibm,gpu', 'ibm,nvlink',
|
|
|
9c6c51 |
'ibm,nvlink-speed' and 'memory-region'.
|
|
|
9c6c51 |
|
|
|
9c6c51 |
This patch introduces a helper called @ppc64VFIODeviceIsNV2Bridge
|
|
|
9c6c51 |
that checks the device tree node of a given PCI device and
|
|
|
9c6c51 |
check if it meets the criteria to be a NVLink2 bridge. This
|
|
|
9c6c51 |
new function will be used in a follow-up patch that, using the
|
|
|
9c6c51 |
first assumption, will set up the rlimits of the guest
|
|
|
9c6c51 |
accordingly.
|
|
|
9c6c51 |
|
|
|
9c6c51 |
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
9c6c51 |
(cherry picked from commit cc9f03801c2618102027ddc4a988193ae290b651)
|
|
|
9c6c51 |
|
|
|
9c6c51 |
https: //bugzilla.redhat.com/show_bug.cgi?id=1505998
|
|
|
9c6c51 |
Signed-off-by: Erik Skultety <eskultet@redhat.com>
|
|
|
9c6c51 |
Message-Id: <99efa386adcf68789b7c8cffda2ef24f5f47f0c4.1556884443.git.eskultet@redhat.com>
|
|
|
9c6c51 |
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
9c6c51 |
---
|
|
|
9c6c51 |
src/qemu/qemu_domain.c | 30 ++++++++++++++++++++++++++++++
|
|
|
9c6c51 |
1 file changed, 30 insertions(+)
|
|
|
9c6c51 |
|
|
|
9c6c51 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
9c6c51 |
index f91de0b743..a8bc618389 100644
|
|
|
9c6c51 |
--- a/src/qemu/qemu_domain.c
|
|
|
9c6c51 |
+++ b/src/qemu/qemu_domain.c
|
|
|
9c6c51 |
@@ -9805,6 +9805,36 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
|
|
|
9c6c51 |
}
|
|
|
9c6c51 |
|
|
|
9c6c51 |
|
|
|
9c6c51 |
+/**
|
|
|
9c6c51 |
+ * ppc64VFIODeviceIsNV2Bridge:
|
|
|
9c6c51 |
+ * @device: string with the PCI device address
|
|
|
9c6c51 |
+ *
|
|
|
9c6c51 |
+ * This function receives a string that represents a PCI device,
|
|
|
9c6c51 |
+ * such as '0004:04:00.0', and tells if the device is a NVLink2
|
|
|
9c6c51 |
+ * bridge.
|
|
|
9c6c51 |
+ */
|
|
|
9c6c51 |
+static ATTRIBUTE_UNUSED bool
|
|
|
9c6c51 |
+ppc64VFIODeviceIsNV2Bridge(const char *device)
|
|
|
9c6c51 |
+{
|
|
|
9c6c51 |
+ const char *nvlink2Files[] = {"ibm,gpu", "ibm,nvlink",
|
|
|
9c6c51 |
+ "ibm,nvlink-speed", "memory-region"};
|
|
|
9c6c51 |
+ size_t i;
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+ for (i = 0; i < ARRAY_CARDINALITY(nvlink2Files); i++) {
|
|
|
9c6c51 |
+ VIR_AUTOFREE(char *) file = NULL;
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+ if ((virAsprintf(&file, "/sys/bus/pci/devices/%s/of_node/%s",
|
|
|
9c6c51 |
+ device, nvlink2Files[i])) < 0)
|
|
|
9c6c51 |
+ return false;
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+ if (!virFileExists(file))
|
|
|
9c6c51 |
+ return false;
|
|
|
9c6c51 |
+ }
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+ return true;
|
|
|
9c6c51 |
+}
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
/**
|
|
|
9c6c51 |
* getPPC64MemLockLimitBytes:
|
|
|
9c6c51 |
* @def: domain definition
|
|
|
9c6c51 |
--
|
|
|
9c6c51 |
2.21.0
|
|
|
9c6c51 |
|