From nobody Tue Nov 18 06:04:49 2025 Delivered-To: importer@patchew.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=1607922419; cv=none; d=zohomail.com; s=zohoarc; b=eXOaXKXc81r7QeDC2wNCDO7x3QDWpYumMn4B71JKWBfIUsaq1+oj2CqFFxbQKaQtqvL4S2lBWM8OI9sTHW7FcN6XUwZ5XbQINc4APNYJxp2gFPv4IhbjqO3TqRYQbFONdgWVnshWHIzS9vbL6ebQzoP3iQWBwhIj28aAjXSKodE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607922419; 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=x4bUbFVbhwecfejRhChdT4F5NFiI2PXI+vMtz6mXErs=; b=fyYJUvcZd8HFkQXWNC6HGVK36sSCtQFf1AzkomnbRXa1FE0EukhOOXwb4tJLztyoXdqshf7lzHvhD5ybzgmAPSYH1Zzn0zQM0K5OclgKKdAVOBIFaWDMj4LEVuGE2QH5X5zHld+qzJEV2c7AoeS9V2G9IYCQq8677PTNgmGGA+M= 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 1607922419681285.3607554795466; Sun, 13 Dec 2020 21:06:59 -0800 (PST) Received: from localhost ([::1]:33608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kog4Y-0007IA-Kf for importer@patchew.org; Mon, 14 Dec 2020 00:06:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kofwP-0005Am-Ne; Sun, 13 Dec 2020 23:58:33 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:59759 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kofwN-0004qQ-W5; Sun, 13 Dec 2020 23:58:33 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4CvTfq61vQz9sVY; Mon, 14 Dec 2020 15:58:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607921891; bh=yEOgWNQIKYMwIVFpybJiMTX1nV9ThkAF1DQCANxBVZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jbQ/MQGS4L30/vN4TIk3+uR3tk1TWEAlwkcZCID4Sagrtr8HQZLo8pg6C043SGYdK maLBmzpFFq0hXlpVteqW+RKDKBCZMXF1awZvbQLfDZjgZjKft2mrUW4HrLT2E4S7AG Oi0nMxhkZ80rmpTcuVLg5t6M26Jtfv6Q5JtDgr6w= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 06/30] spapr: Do PHB hoplug sanity check at pre-plug Date: Mon, 14 Dec 2020 15:57:43 +1100 Message-Id: <20201214045807.41003-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214045807.41003-1-david@gibson.dropbear.id.au> References: <20201214045807.41003-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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, qemu-devel@nongnu.org, groug@kaod.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" From: Greg Kurz We currently detect that a PHB index is already in use at plug time. But this can be decteted at pre-plug in order to error out earlier. This allows to pass &error_abort to spapr_drc_attach() and to end up with a plug handler that doesn't need to report errors anymore. Signed-off-by: Greg Kurz Message-Id: <20201120234208.683521-8-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 28d266f7a7..ac115b0987 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3886,6 +3886,7 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); + SpaprDrc *drc; =20 if (dev->hotplugged && !smc->dr_phb_enabled) { error_setg(errp, "PHB hotplug not supported for this machine"); @@ -3897,6 +3898,12 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, return false; } =20 + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, sphb->index); + if (drc && drc->dev) { + error_setg(errp, "PHB %d already attached", sphb->index); + return false; + } + /* * This will check that sphb->index doesn't exceed the maximum number = of * PHBs for the current machine type. @@ -3910,8 +3917,7 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, errp); } =20 -static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); @@ -3927,9 +3933,8 @@ static void spapr_phb_plug(HotplugHandler *hotplug_de= v, DeviceState *dev, /* hotplug hooks should check it's enabled before getting this far */ assert(drc); =20 - if (!spapr_drc_attach(drc, dev, errp)) { - return; - } + /* spapr_phb_pre_plug() already checked the DRC is attachable */ + spapr_drc_attach(drc, dev, &error_abort); =20 if (hotplugged) { spapr_hotplug_req_add_by_index(drc); @@ -3997,7 +4002,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { - spapr_phb_plug(hotplug_dev, dev, errp); + spapr_phb_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) { spapr_tpm_proxy_plug(hotplug_dev, dev, errp); } --=20 2.29.2