From nobody Thu Apr 25 20:24:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1585201398; cv=none; d=zohomail.com; s=zohoarc; b=JQfu/pMrcZCdltCF9e7fhwJ/76FGOB+3Zwksuvi/ir+HFlvRpMifz8maIIm/n3fTikU8V1ztfwtYB93EYUxJUFUFKM7zGPh11LJpAdjyLPtj1Vx+RlV+EwHTxLAsFUEnwyL++8ScSGi19Ju93Qlb8n3sbTp4Kkb2dt0tV207tDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585201398; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dg8lsNiXOsTZSp/9ZwK2znNXG/O2EZ52crN1M9Xdtjo=; b=klER4VFoiuJSoDRrVK7Io5iCA/UdDXWqZ9OwBNmm+fJ9E80/gdWAmZWjFPGuJwJAVmvMcbfjqIz8dj8EEmD0Uk4pmiBdywJ1osxPMfIHzaChFFxxDH5RnES0vWuvVxmNXklfavtfsfz1/6mX91FMaxyxWMzKeDK+K01lKS1cH/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585201398824697.0136748499685; Wed, 25 Mar 2020 22:43:18 -0700 (PDT) Received: from localhost ([::1]:46798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLIT-0006aq-Er for importer@patchew.org; Thu, 26 Mar 2020 01:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46200) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLFc-0003AH-4D for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHLFa-0000pm-NH for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:20 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:41023 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHLFa-0000nT-18; Thu, 26 Mar 2020 01:40:18 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48nv2k50NFz9sRN; Thu, 26 Mar 2020 16:40:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1585201214; bh=HJM6J14MXwxAnCeEjdieEtsutKN/FoKlqgFsm3PZdCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWtIMETVxi8VH1mbflwoAM/xCmrNo9QGHp6PErnp8W33ByCZ32bE5soYFQzqT2oOA pmg24lNR92jjiYlBypOBd2hnXOY613IVpefXrvFGHH9Gyzk/qo48eQqROQQNeHEi6l ZB/kNDTJsOnMkQO/t1yXXt64AGmMx2h+cMZbTYBc= From: David Gibson To: aik@ozlabs.ru, groug@kaod.org Subject: [RFC for-5.1 1/4] spapr: Refactor locating NVLink2 devices for device tree creation Date: Thu, 26 Mar 2020 16:40:06 +1100 Message-Id: <20200326054009.454477-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326054009.454477-1-david@gibson.dropbear.id.au> References: <20200326054009.454477-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently spapr_phb_nvgpu_populate_pcidev_dt() works a little cryptically. It steps through all the NVLink2 GPUs and NPUs and if they match the device we're called for, we generate the relevant device tree information. Make this a little more obvious by introducing helpers to determine it a given PCI device is an NVLink2 GPU or NPU, returning the NVLink2 slot and link number information as well. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr_pci_nvlink2.c | 115 +++++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 36 deletions(-) diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 8332d5694e..7d3a685421 100644 --- a/hw/ppc/spapr_pci_nvlink2.c +++ b/hw/ppc/spapr_pci_nvlink2.c @@ -390,13 +390,12 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *s= phb, void *fdt) =20 } =20 -void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int off= set, - SpaprPhbState *sphb) +static bool is_nvgpu(PCIDevice *dev, SpaprPhbState *sphb, int *slot) { - int i, j; + int i; =20 if (!sphb->nvgpus) { - return; + return false; } =20 for (i =3D 0; i < sphb->nvgpus->num; ++i) { @@ -406,47 +405,91 @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *de= v, void *fdt, int offset, if (!nvslot->gpdev) { continue; } + if (dev =3D=3D nvslot->gpdev) { - uint32_t npus[nvslot->linknum]; + if (slot) { + *slot =3D i; + } + return true; + } + } =20 - for (j =3D 0; j < nvslot->linknum; ++j) { - PCIDevice *npdev =3D nvslot->links[j].npdev; + return false; +} =20 - npus[j] =3D cpu_to_be32(PHANDLE_PCIDEV(sphb, npdev)); - } - _FDT(fdt_setprop(fdt, offset, "ibm,npu", npus, - j * sizeof(npus[0]))); - _FDT((fdt_setprop_cell(fdt, offset, "phandle", - PHANDLE_PCIDEV(sphb, dev)))); +static bool is_nvnpu(PCIDevice *dev, SpaprPhbState *sphb, int *slot, int *= link) +{ + int i, j; + + if (!sphb->nvgpus) { + return false; + } + + for (i =3D 0; i < sphb->nvgpus->num; ++i) { + SpaprPhbPciNvGpuSlot *nvslot =3D &sphb->nvgpus->slots[i]; + + /* Skip "slot" without attached GPU */ + if (!nvslot->gpdev) { continue; } =20 for (j =3D 0; j < nvslot->linknum; ++j) { - if (dev !=3D nvslot->links[j].npdev) { - continue; + if (dev =3D=3D nvslot->links[j].npdev) { + if (slot) { + *slot =3D i; + } + if (link) { + *link =3D j; + } + return true; } + } + } =20 - _FDT((fdt_setprop_cell(fdt, offset, "phandle", - PHANDLE_PCIDEV(sphb, dev)))); - _FDT(fdt_setprop_cell(fdt, offset, "ibm,gpu", - PHANDLE_PCIDEV(sphb, nvslot->gpdev))); - _FDT((fdt_setprop_cell(fdt, offset, "ibm,nvlink", - PHANDLE_NVLINK(sphb, i, j)))); - /* - * If we ever want to emulate GPU RAM at the same location as = on - * the host - here is the encoding GPA->TGT: - * - * gta =3D ((sphb->nv2_gpa >> 42) & 0x1) << 42; - * gta |=3D ((sphb->nv2_gpa >> 45) & 0x3) << 43; - * gta |=3D ((sphb->nv2_gpa >> 49) & 0x3) << 45; - * gta |=3D sphb->nv2_gpa & ((1UL << 43) - 1); - */ - _FDT(fdt_setprop_cell(fdt, offset, "memory-region", - PHANDLE_GPURAM(sphb, i))); - _FDT(fdt_setprop_u64(fdt, offset, "ibm,device-tgt-addr", - nvslot->tgt)); - _FDT(fdt_setprop_cell(fdt, offset, "ibm,nvlink-speed", - nvslot->links[j].link_speed)); + return false; +} + +void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int off= set, + SpaprPhbState *sphb) +{ + int slot, link; + + if (is_nvgpu(dev, sphb, &slot)) { + SpaprPhbPciNvGpuSlot *nvslot =3D &sphb->nvgpus->slots[slot]; + uint32_t npus[nvslot->linknum]; + + for (link =3D 0; link < nvslot->linknum; ++link) { + PCIDevice *npdev =3D nvslot->links[link].npdev; + + npus[link] =3D cpu_to_be32(PHANDLE_PCIDEV(sphb, npdev)); } + _FDT(fdt_setprop(fdt, offset, "ibm,npu", npus, + link * sizeof(npus[0]))); + _FDT((fdt_setprop_cell(fdt, offset, "phandle", + PHANDLE_PCIDEV(sphb, dev)))); + } else if (is_nvnpu(dev, sphb, &slot, &link)) { + SpaprPhbPciNvGpuSlot *nvslot =3D &sphb->nvgpus->slots[slot]; + + _FDT((fdt_setprop_cell(fdt, offset, "phandle", + PHANDLE_PCIDEV(sphb, dev)))); + _FDT(fdt_setprop_cell(fdt, offset, "ibm,gpu", + PHANDLE_PCIDEV(sphb, nvslot->gpdev))); + _FDT((fdt_setprop_cell(fdt, offset, "ibm,nvlink", + PHANDLE_NVLINK(sphb, slot, link)))); + /* + * If we ever want to emulate GPU RAM at the same location as + * on the host - here is the encoding GPA->TGT: + * + * gta =3D ((sphb->nv2_gpa >> 42) & 0x1) << 42; + * gta |=3D ((sphb->nv2_gpa >> 45) & 0x3) << 43; + * gta |=3D ((sphb->nv2_gpa >> 49) & 0x3) << 45; + * gta |=3D sphb->nv2_gpa & ((1UL << 43) - 1); + */ + _FDT(fdt_setprop_cell(fdt, offset, "memory-region", + PHANDLE_GPURAM(sphb, slot))); + _FDT(fdt_setprop_u64(fdt, offset, "ibm,device-tgt-addr", + nvslot->tgt)); + _FDT(fdt_setprop_cell(fdt, offset, "ibm,nvlink-speed", + nvslot->links[link].link_speed)); } } --=20 2.25.1 From nobody Thu Apr 25 20:24:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1585201499; cv=none; d=zohomail.com; s=zohoarc; b=RAxWM8YESX8oBJ8/6Z9SNuC0pnweQZfysrLeIrtlPQ7CMeLldMh/BhLT79Fhv/MF/Rf/ddA3evb/Kcax0lj7D+cy3o2ddT9FQszhXK7mqKcMbUCKx1rS6EzLS1y23vXlh/2yw0o+3PTnVnrbNAztRpWJ68ShPsTi1QItS8LGgAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585201499; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kp5znXXyKquU1n7zOG/bAaReMaTu3HxQGHvDkpMque8=; b=aKwMcYyvxbQlDrhY13DJuOxekqZai15yECBMDZZ5WH+0sVuJqc5X1Na8gYQSOYaehJ/qGEgO9x2AA/YVyeVHDlq/VZWHo1Z8V/kB0NsMNCfqgas8YSDuwMzRcZo2Fkfk6hzbPNiTYkvgqkKyzCmLjVtALpVCEsyQzZKpG1CQV5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585201499852494.08909469504727; Wed, 25 Mar 2020 22:44:59 -0700 (PDT) Received: from localhost ([::1]:46814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLK6-00007P-Nd for importer@patchew.org; Thu, 26 Mar 2020 01:44:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46190) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLFb-00039s-OP for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHLFa-0000pt-Ny for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:19 -0400 Received: from ozlabs.org ([203.11.71.1]:51025) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHLFZ-0000nW-SX; Thu, 26 Mar 2020 01:40:18 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48nv2k5nlVz9sSM; Thu, 26 Mar 2020 16:40:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1585201214; bh=Xnj7Byw+xZ7EE+Dq9Ql9GDjnSE2VDcNynX+uZRnbRPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9sdZRC0LpsZlSYRBILHxE5EHaFwe3r7ljsn1XdIgPWfp+XsmFrL/NlEb0D7mqPHC 3H0+kZmNgKWipKclijGwVe7UfsOeXuIDVxioaejSjHDezea+LWpzTbxER7ay4cx0iE H/xKNYloFbs0Wa3moPm5l4+u4rWvJb7lbfGyrQYM= From: David Gibson To: aik@ozlabs.ru, groug@kaod.org Subject: [RFC for-5.1 2/4] spapr: Helper to determine if a device is NVLink2 related Date: Thu, 26 Mar 2020 16:40:07 +1100 Message-Id: <20200326054009.454477-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326054009.454477-1-david@gibson.dropbear.id.au> References: <20200326054009.454477-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This adds a simple exported helper function which determins if a given (supposedly) PCI device is actually an NVLink2 device, which has some special considerations. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr_pci_nvlink2.c | 5 +++++ include/hw/pci-host/spapr.h | 1 + 2 files changed, 6 insertions(+) diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c index 7d3a685421..0cec1ae02b 100644 --- a/hw/ppc/spapr_pci_nvlink2.c +++ b/hw/ppc/spapr_pci_nvlink2.c @@ -449,6 +449,11 @@ static bool is_nvnpu(PCIDevice *dev, SpaprPhbState *sp= hb, int *slot, int *link) return false; } =20 +bool spapr_phb_is_nvlink_dev(PCIDevice *dev, SpaprPhbState *sphb) +{ + return is_nvgpu(dev, sphb, NULL) || is_nvnpu(dev, sphb, NULL, NULL); +} + void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int off= set, SpaprPhbState *sphb) { diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 8877ff51fb..eaba4a5825 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -156,6 +156,7 @@ void spapr_phb_nvgpu_free(SpaprPhbState *sphb); void spapr_phb_nvgpu_populate_dt(SpaprPhbState *sphb, void *fdt, int bus_o= ff, Error **errp); void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb, void *fdt); +bool spapr_phb_is_nvlink_dev(PCIDevice *dev, SpaprPhbState *sphb); void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int off= set, SpaprPhbState *sphb); #else --=20 2.25.1 From nobody Thu Apr 25 20:24:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1585201303; cv=none; d=zohomail.com; s=zohoarc; b=f1ymzqWX4Rsz7Z605Phf5FjM6ORnal1x/6Y/1qzJDKLYbXMhRZhth0cbxCI3DhEdIUF3gJ0yGPwXyqPGM5Iff4OlBRgNopaS19NSc+OSshoxU3icgBV22csSrVrFoGJXAtcjRQM06qo4iaW9DZZSPuXOQUndkEBRQfxcbMQrYfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585201303; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W7tDdZWkf0thHsMEF9Z7nsz80xFlZFS2l+BeJR9g0zg=; b=OS/JNL3fjpAnpSP8nDweJ0L7UyW1q40Qtti+cgtEM2+SWzF2ZaTkiPjq5+mm6spHV5ubWvZqYQhtfW7b3kYI/N7NKe0P7dKSVxpYs9BOgtRI6Wflu6GrBTiSBgjUCv8kizMmwMqBY5BBa7pGZk34dso0OqLVeoqtJqJitePdrvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585201303679487.84073030784236; Wed, 25 Mar 2020 22:41:43 -0700 (PDT) Received: from localhost ([::1]:46780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLGw-0004bb-F4 for importer@patchew.org; Thu, 26 Mar 2020 01:41:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46212) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLFc-0003Af-Gd for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHLFb-0000qX-By for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:20 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:35897) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHLFb-0000nk-1b; Thu, 26 Mar 2020 01:40:19 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48nv2l0HFmz9sSN; Thu, 26 Mar 2020 16:40:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1585201215; bh=5zqp0BrSo+XTId26i2ES/dDzCNRx9VXm9kO8rq5wvko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abWvDedwz82reARhapOf2htJGZJtP1ees/pUhyK973xRViXTJUUoWZil4r44gLnHl vcTf3OoXK2mfvghPnJkvW058u6+mP0wALrzh5fxftvEU1HWi5AjNF8KfL04HBcevfP IaSxcPTzo8mFSnbBQpCVL/HhETT+0z2w/og0DtEk= From: David Gibson To: aik@ozlabs.ru, groug@kaod.org Subject: [RFC for-5.1 3/4] spapr: Fix failure path for attempting to hot unplug PCI bridges Date: Thu, 26 Mar 2020 16:40:08 +1100 Message-Id: <20200326054009.454477-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326054009.454477-1-david@gibson.dropbear.id.au> References: <20200326054009.454477-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" For various technical reasons we can't currently allow unplug a PCI to PCI bridge on the pseries machine. spapr_pci_unplug_request() correctly generates an error message if that's attempted. But.. if the given errp is not error_abort or error_fatal, it doesn't actually stop trying to unplug the bridge anyway. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 709a52780d..55ca9dee1e 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1663,6 +1663,7 @@ static void spapr_pci_unplug_request(HotplugHandler *= plug_handler, =20 if (pc->is_bridge) { error_setg(errp, "PCI: Hot unplug of PCI bridges not supported= "); + return; } =20 /* ensure any other present functions are pending unplug */ --=20 2.25.1 From nobody Thu Apr 25 20:24:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1585201286; cv=none; d=zohomail.com; s=zohoarc; b=fD2EOkfeqLaXfUgAk9f/hs02K8QV6yx725BC2ZSnTxSZT3v3VhgNrWnnHaSxRdep17imVHNboxobiN8CFvsA9Jc0Si9RmGlyaRm5gEsDGDAPRKzE6By4luyJIUbhto9gJPycFw9G7FzwgRCdHTr/e/quLRGsteXDn7DKQSh5M6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585201286; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uFUaYQ1BN+fMbWJBPEfYRn0N4OxxDuW4NuI5OxxIfsM=; b=IYiK/Lf3WfIDOVUrLN/PCdn3MvE+/DomqEpGEcxTOjrYj5AZrQ+ll5Ai7PLUhiudqpb8FlnZfTYvkwY/o2k0ZburnBDHHFrhxegPd40OOfJDDLtMIQWL+oFRjJYpzxHxykgxGv/FthwayvmgN3SW36pFhIqewJNqWq29M5fbVqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585201286047791.0955064353016; Wed, 25 Mar 2020 22:41:26 -0700 (PDT) Received: from localhost ([::1]:46778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLGe-0004Ef-QS for importer@patchew.org; Thu, 26 Mar 2020 01:41:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46188) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLFb-00039i-Nz for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHLFa-0000pb-JJ for qemu-devel@nongnu.org; Thu, 26 Mar 2020 01:40:19 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:44919 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHLFZ-0000o0-Vj; Thu, 26 Mar 2020 01:40:18 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 48nv2l1DcCz9sSQ; Thu, 26 Mar 2020 16:40:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1585201215; bh=fEyZvtCfABdffElGrSpl0Px+yuvrrBN6GboJ+tRarjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EjnYYDDJl98k1BqlP8LVfG14o+c8T/8qtrzsmDngBEa75nuQUz1NW63t5pDrz6EeJ HsL9bNBE/Y1o7Kx+l94ySJCHe/6S/yHMu1zYW5YIy3tZFKG9Z0kX1TPfeUNzKXBw4g TAh5cGhoSGP4AHx0gKEW+k9ozvW+AiLKLdC4e5sU= From: David Gibson To: aik@ozlabs.ru, groug@kaod.org Subject: [RFC for-5.1 4/4] spapr: Don't allow unplug of NVLink2 devices Date: Thu, 26 Mar 2020 16:40:09 +1100 Message-Id: <20200326054009.454477-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326054009.454477-1-david@gibson.dropbear.id.au> References: <20200326054009.454477-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently, we can't properly handle unplug of NVLink2 devices, because we don't have code to tear down their special memory resources. There's not a lot of impetus to implement that. Since hardware NVLink2 devices can't be hot unplugged, the guest side drivers don't usually support unplug anyway. Therefore, simply prevent unplug of NVLink2 devices. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr_pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 55ca9dee1e..5c8262413a 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1666,6 +1666,11 @@ static void spapr_pci_unplug_request(HotplugHandler = *plug_handler, return; } =20 + if (spapr_phb_is_nvlink_dev(pdev, phb)) { + error_setg(errp, "PCI: Cannot unplug NVLink2 devices"); + return; + } + /* ensure any other present functions are pending unplug */ if (PCI_FUNC(pdev->devfn) =3D=3D 0) { for (i =3D 1; i < 8; i++) { --=20 2.25.1