From patchwork Thu Mar 26 05:40:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11459313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D3F8913 for ; Thu, 26 Mar 2020 05:42:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E87C7206E6 for ; Thu, 26 Mar 2020 05:42:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="TWtIMETV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E87C7206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLIA-0006aq-45 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Mar 2020 01:42:58 -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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 *sphb, void *fdt) } -void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset, - SpaprPhbState *sphb) +static bool is_nvgpu(PCIDevice *dev, SpaprPhbState *sphb, int *slot) { - int i, j; + int i; if (!sphb->nvgpus) { - return; + return false; } for (i = 0; i < sphb->nvgpus->num; ++i) { @@ -406,47 +405,91 @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset, if (!nvslot->gpdev) { continue; } + if (dev == nvslot->gpdev) { - uint32_t npus[nvslot->linknum]; + if (slot) { + *slot = i; + } + return true; + } + } - for (j = 0; j < nvslot->linknum; ++j) { - PCIDevice *npdev = nvslot->links[j].npdev; + return false; +} - npus[j] = 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 = 0; i < sphb->nvgpus->num; ++i) { + SpaprPhbPciNvGpuSlot *nvslot = &sphb->nvgpus->slots[i]; + + /* Skip "slot" without attached GPU */ + if (!nvslot->gpdev) { continue; } for (j = 0; j < nvslot->linknum; ++j) { - if (dev != nvslot->links[j].npdev) { - continue; + if (dev == nvslot->links[j].npdev) { + if (slot) { + *slot = i; + } + if (link) { + *link = j; + } + return true; } + } + } - _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 = ((sphb->nv2_gpa >> 42) & 0x1) << 42; - * gta |= ((sphb->nv2_gpa >> 45) & 0x3) << 43; - * gta |= ((sphb->nv2_gpa >> 49) & 0x3) << 45; - * gta |= 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 offset, + SpaprPhbState *sphb) +{ + int slot, link; + + if (is_nvgpu(dev, sphb, &slot)) { + SpaprPhbPciNvGpuSlot *nvslot = &sphb->nvgpus->slots[slot]; + uint32_t npus[nvslot->linknum]; + + for (link = 0; link < nvslot->linknum; ++link) { + PCIDevice *npdev = nvslot->links[link].npdev; + + npus[link] = 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 = &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 = ((sphb->nv2_gpa >> 42) & 0x1) << 42; + * gta |= ((sphb->nv2_gpa >> 45) & 0x3) << 43; + * gta |= ((sphb->nv2_gpa >> 49) & 0x3) << 45; + * gta |= 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)); } } From patchwork Thu Mar 26 05:40:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11459317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5FDA14B4 for ; Thu, 26 Mar 2020 05:44:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C2DF2070A for ; Thu, 26 Mar 2020 05:44:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="K9sdZRC0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C2DF2070A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLJn-00007P-NZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Mar 2020 01:44:39 -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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 *sphb, int *slot, int *link) return false; } +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 offset, 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_off, 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 offset, SpaprPhbState *sphb); #else From patchwork Thu Mar 26 05:40:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11459301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55828161F for ; Thu, 26 Mar 2020 05:41:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C7D5206E6 for ; Thu, 26 Mar 2020 05:41:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="abWvDedw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C7D5206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLGf-0004bb-CB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Mar 2020 01:41:25 -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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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, if (pc->is_bridge) { error_setg(errp, "PCI: Hot unplug of PCI bridges not supported"); + return; } /* ensure any other present functions are pending unplug */ From patchwork Thu Mar 26 05:40:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11459299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E96DD161F for ; Thu, 26 Mar 2020 05:41:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EACA206E6 for ; Thu, 26 Mar 2020 05:41:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="EjnYYDDJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EACA206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHLGR-0004Ef-8Q for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Mar 2020 01:41:11 -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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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; } + 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) == 0) { for (i = 1; i < 8; i++) {