From nobody Sun Feb 8 05:41:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554385269614518.1901451336149; Thu, 4 Apr 2019 06:41:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5CA05C079C49; Thu, 4 Apr 2019 13:41:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 199ED5D9CA; Thu, 4 Apr 2019 13:41:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 623E4181AC44; Thu, 4 Apr 2019 13:41:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34Df3Y7023226 for ; Thu, 4 Apr 2019 09:41:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0ECFE85736; Thu, 4 Apr 2019 13:41:03 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC5628572C; Thu, 4 Apr 2019 13:40:59 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ADDF305B16F; Thu, 4 Apr 2019 13:40:53 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id d13so3230105qth.5; Thu, 04 Apr 2019 06:40:53 -0700 (PDT) Received: from rekt.ibmmodules.com ([2804:431:f700:6702:8bc5:7364:e3c:ea55]) by smtp.gmail.com with ESMTPSA id p52sm13998355qta.37.2019.04.04.06.40.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2019 06:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jg3rFsK4p3qU7hPJc30BoDu73O15dUeVq1AOdvuKDI0=; b=dygguFPQmU5DcG10jhdvfm36wV9CH29TxqzplBSrYfOGOHlT+LBbco6AlloMiNXaC8 3PcXgUFuq/rTsEAf/TMBr+G2bVXdHYxwwdJX2/fnof0GWpog+zfSuvGzGTj2jOMn+Npb bknrnU6ivkV7u8yS7FvSNt+H68JpsWCq3Yh3Ioy5J+I4ARtGAwOG+ioN9gPmQUgny6sp WthKFcxx9HcT9rv0iZvLoPz5RmV6snUZOW/UI5dr9bn+sYfrAnF1wufTXXSFZLORQbRU fm1notS1zmLXQ4/xD6BETsxBhggp+hsLtsACPrZV3KPNaAFTXZTUmMwhdUTqLpNh6fa0 VicA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jg3rFsK4p3qU7hPJc30BoDu73O15dUeVq1AOdvuKDI0=; b=YjFc1kktLROFTbv4ExOtD3G96OYpWeV2q4aO7BUvlR8PvUNSOhlHcGK/iJhSK9MirI 6FyZTFNAT4GbL4ornVQFaVeWtxkV/gbxVp4kTYQk9TNkm56Q+yfldAcc7Q803mQUCaPx 7rU8mTyM/nyR4vyHeReObmeBC5XEDe4IabtWDGZNIvCU+GMtM7z1mQC2f6crGypZyHMo +/4DhQ5zi8DhxZBzO5W4u5nksasi/z9a51v8n8W8vVLr6mXyH3fd+8WFpmLIdoGMvmUW RmwYpWDFzU5Hgxs5kBIAWpObFVlWO6Tm0PZC+UuPUbNmsp8Ekmf5oJpL/aWrojmKuqQg Ru1w== X-Gm-Message-State: APjAAAXh6dRlanXmPXPQ7tG7c5BrXbZ3Z8nATKdWPf3zuPAnVkRueFwl IiOk75G5vCDSDb04b1iMRj2FTrDP X-Google-Smtp-Source: APXvYqzQfcCI4VnBFekWgwRJQfC7y9xc58cmNmWvAzT+VFnm9QkYL7SCut90yp3iQrFekxXFTU4PYA== X-Received: by 2002:a0c:8b4a:: with SMTP id d10mr4799586qvc.29.1554385252346; Thu, 04 Apr 2019 06:40:52 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 4 Apr 2019 10:40:38 -0300 Message-Id: <20190404134039.25849-2-danielhb413@gmail.com> In-Reply-To: <20190404134039.25849-1-danielhb413@gmail.com> References: <20190404134039.25849-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 04 Apr 2019 13:40:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 04 Apr 2019 13:40:53 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.142 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com, jtomko@redhat.com, eskultet@redhat.com, aik@ozlabs.ru, Daniel Henrique Barboza , pjaroszynski@nvidia.com, lagarcia@br.ibm.com Subject: [libvirt] [PATCH v5 1/2] qemu_domain: NVLink2 bridge detection function for PPC64 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 Apr 2019 13:41:09 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The NVLink2 support in QEMU implements the detection of NVLink2 capable devices by verifying the attributes of the VFIO mem region QEMU allocates for the NVIDIA GPUs. To properly allocate an adequate amount of memLock, Libvirt needs this information before a QEMU instance is even created, thus querying QEMU is not possible and opening a VFIO window is too much. An alternative is presented in this patch. Making the following assumptions: - if we want GPU RAM to be available in the guest, an NVLink2 bridge must be passed through; - an unknown PCI device can be classified as a NVLink2 bridge if its device tree node has 'ibm,gpu', 'ibm,nvlink', 'ibm,nvlink-speed' and 'memory-region'. This patch introduces a helper called @ppc64VFIODeviceIsNV2Bridge that checks the device tree node of a given PCI device and check if it meets the criteria to be a NVLink2 bridge. This new function will be used in a follow-up patch that, using the first assumption, will set up the rlimits of the guest accordingly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Erik Skultety --- src/qemu/qemu_domain.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c6188b38ce..b0f301e634 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10405,6 +10405,36 @@ qemuDomainUpdateCurrentMemorySize(virDomainObjPtr = vm) } =20 =20 +/** + * ppc64VFIODeviceIsNV2Bridge: + * @device: string with the PCI device address + * + * This function receives a string that represents a PCI device, + * such as '0004:04:00.0', and tells if the device is a NVLink2 + * bridge. + */ +static ATTRIBUTE_UNUSED bool +ppc64VFIODeviceIsNV2Bridge(const char *device) +{ + const char *nvlink2Files[] =3D {"ibm,gpu", "ibm,nvlink", + "ibm,nvlink-speed", "memory-region"}; + size_t i; + + for (i =3D 0; i < ARRAY_CARDINALITY(nvlink2Files); i++) { + VIR_AUTOFREE(char *) file =3D NULL; + + if ((virAsprintf(&file, "/sys/bus/pci/devices/%s/of_node/%s", + device, nvlink2Files[i])) < 0) + return false; + + if (!virFileExists(file)) + return false; + } + + return true; +} + + /** * getPPC64MemLockLimitBytes: * @def: domain definition --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list