From patchwork Thu Nov 30 14:41:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 13474557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B67B6C10DAA for ; Thu, 30 Nov 2023 14:39:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.644777.1006314 (Exim 4.92) (envelope-from ) id 1r8iCA-0004J1-8m; Thu, 30 Nov 2023 14:39:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 644777.1006314; Thu, 30 Nov 2023 14:39:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8iC9-0004F4-NJ; Thu, 30 Nov 2023 14:39:13 +0000 Received: by outflank-mailman (input) for mailman id 644777; Thu, 30 Nov 2023 14:33:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8i6F-0007mE-2p for xen-devel@lists.xenproject.org; Thu, 30 Nov 2023 14:33:07 +0000 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5f5c980a-8f8d-11ee-98e4-6d05b1d4d9a1; Thu, 30 Nov 2023 15:33:06 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2023 06:33:04 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga005.jf.intel.com with ESMTP; 30 Nov 2023 06:32:54 -0800 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5f5c980a-8f8d-11ee-98e4-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701354786; x=1732890786; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/4XB1+0XSfZXJW6ggYvVG8+UQ24RT1LIudOfD5YSaJw=; b=YSr/jK4XqQrYYeOvNbkGBNgSH+43/b7ldoAlj546+/mrr9L0Gp4ofx5H 4HsY11KahN2S5+bsxyMG3hPJcFlshVamQlCY5ldcL4I8ZLyuhDqUxCstr KUmONaw8vy8PXZxgtX3R9W4G+gZW0/9DJYQKTJ3wkVtB+38WoBLHqgQvI 4I4qXsP4IHqfMHBItXbHiReVSVheK8JAwTeMz+cAWASmonoVOuIDqyIta Kl//ijrYIiHsjfT/2KQLOVVMgkEfeaH3yhQJfTS8EPIbLtvdlIspqHU3W RCfzSlqelWWt/RrLpYs1D1O5OedD4avABd44Ru0xkQPY0Vg+NmzqLGbeC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="479531853" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="479531853" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="942729971" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="942729971" From: Zhao Liu To: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Richard Henderson , "Michael S . Tsirkin" , Jason Wang , Nicholas Piggin , Daniel Henrique Barboza , Igor Mammedov , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?b?RnLDqWTDqXJp?= =?utf-8?b?YyBCYXJyYXQ=?= , David Gibson , Harsh Prateek Bora , Stefano Stabellini , Anthony Perard , Paul Durrant , Gerd Hoffmann , Peter Maydell , Alistair Francis , "Edgar E . Iglesias" , =?utf-8?q?Daniel_P_=2E_Ber?= =?utf-8?q?rang=C3=A9?= , Bin Meng , Palmer Dabbelt , Weiwei Li , Liu Zhiwei , qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-ppc@nongnu.org, xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Cc: Nina Schoetterl-Glausch , Thomas Huth , Zhiyuan Lv , Zhenyu Wang , Yongwei Ma , Zhao Liu Subject: [RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal Date: Thu, 30 Nov 2023 22:41:38 +0800 Message-Id: <20231130144203.2307629-17-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130144203.2307629-1-zhao1.liu@linux.intel.com> References: <20231130144203.2307629-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 From: Zhao Liu PPC supports CPU hotplug at core granularity, thus ppc-core only accepts all CPUs in a core are plugged. Check if plugged_threads and nr_threads are equal when ppc-core realizes. Signed-off-by: Zhao Liu --- hw/ppc/ppc_core.c | 18 ++++++++++++++++++ include/hw/ppc/ppc_core.h | 1 + 2 files changed, 19 insertions(+) diff --git a/hw/ppc/ppc_core.c b/hw/ppc/ppc_core.c index 4433b54af506..3857f3150052 100644 --- a/hw/ppc/ppc_core.c +++ b/hw/ppc/ppc_core.c @@ -53,20 +53,38 @@ static void powerpc_core_prop_set_core_id(Object *obj, Visitor *v, core->core_id = value; } +static void powerpc_core_realize(DeviceState *dev, Error **errp) +{ + CPUCore *core = CPU_CORE(dev); + PowerPCCoreClass *ppc_class = POWERPC_CORE_GET_CLASS(dev); + + if (core->plugged_threads != -1 && + core->nr_threads != core->plugged_threads) { + error_setg(errp, "nr_threads and plugged-threads must be equal"); + return; + } + + ppc_class->parent_realize(dev, errp); +} + static void powerpc_core_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); + PowerPCCoreClass *ppc_class = POWERPC_CORE_CLASS(oc); object_class_property_add(oc, "core-id", "int", powerpc_core_prop_get_core_id, powerpc_core_prop_set_core_id, NULL, NULL); + device_class_set_parent_realize(dc, powerpc_core_realize, + &ppc_class->parent_realize); } static const TypeInfo powerpc_core_type_info = { .name = TYPE_POWERPC_CORE, .parent = TYPE_CPU_CORE, .abstract = true, + .class_size = sizeof(PowerPCCoreClass), .class_init = powerpc_core_class_init, .instance_size = sizeof(PowerPCCore), }; diff --git a/include/hw/ppc/ppc_core.h b/include/hw/ppc/ppc_core.h index bcc83e426e3f..1207d220872a 100644 --- a/include/hw/ppc/ppc_core.h +++ b/include/hw/ppc/ppc_core.h @@ -34,6 +34,7 @@ struct PowerPCCoreClass { CPUCoreClass parent_class; /*< public >*/ + DeviceRealize parent_realize; }; struct PowerPCCore {