From nobody Wed Nov 27 04:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1701354787; cv=none; d=zohomail.com; s=zohoarc; b=ekqEuxtxjJHPD7c3q2igC3sD+SziRTS04eHM/37pwjzOdfohSx485ufNFb7NJ/p+MMq+7SiKTaSZxnY43HDlxGPEJ7izMnOaIPdxasnvk50Rgz15wVPbtQNvIzpUVqgV5bxmTWuBtfEPRZa5fqkD7gHa3yRhWIm9FYAO1l2TtYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701354787; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ihp/jx5seYg7c0g5X0s3RsUl526zGV7js1rt+zrZCHs=; b=Y1oUCxlwedlV9r4/WuD/aRDK6CP65oA4+928e7ZA7fnzd7uuCPcEyp6RrxpeRwtWJl/xAoQXJRGrKwWPUdbKSxuuKVH+AhxQNK4h2IXjJrNY7udMhgJAVSdfRaKfxMBeq5UIHxV8RXJeAY0Z4l/1939NK5vBencF7A3AltFN3kE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701354787317149.60619947760426; Thu, 30 Nov 2023 06:33:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8i5q-0002uo-MW; Thu, 30 Nov 2023 09:32:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8i5o-0002lI-5O; Thu, 30 Nov 2023 09:32:40 -0500 Received: from mgamail.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8i5m-00018C-Ff; Thu, 30 Nov 2023 09:32:39 -0500 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:32:17 -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:07 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701354758; x=1732890758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qW0hllcBGqseRYTHsmnEpW0X6HH9DmoP+0BU5Dr4Av4=; b=OWd4U0MN285ZMI0jhm1u6O/voRUZgeXxPDaArm2/dQWVEeNWFmMRPhJv dh1X4DD8oG9SmUCQVduTNbbz9ITX0zqOLy4KwTTDeSprzwLbw8R9d5edD P5aOnn0qdvtAjDuF/HD8fUXt9UVjUBs2SE/VsHuKiutzwKjSeznT9Qfv/ KRD3EjxUP8JYOTUoZM1cew2LoAZ57Q+EE2Go74s7qGKQM7P4PngYWiaAp VpGQSeV/0J2eXAia5QeAq3MLrMURqAmYnJyHisCXQBn2rmcopWVETDSRf 88AaxhWrzKXHWCAh4OnHMC/cejOVwqzg4vOsIzulj6J1NY0YdPeuLv0f9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="479531608" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="479531608" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="942729823" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="942729823" From: Zhao Liu To: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-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=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , David Gibson , Harsh Prateek Bora , Stefano Stabellini , Anthony Perard , Paul Durrant , Gerd Hoffmann , Peter Maydell , Alistair Francis , "Edgar E . Iglesias" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=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 11/41] hw/core/topo: Add virtual method to check topology child Date: Thu, 30 Nov 2023 22:41:33 +0800 Message-Id: <20231130144203.2307629-12-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 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: none client-ip=192.55.52.43; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1701354788502000002 Content-Type: text/plain; charset="utf-8" From: Zhao Liu When a new topology child is to be inserted into the topology tree, its parents (including non-direct parents) need to check if this child is supported. Add the virtual method to allow topology device to check the support for their topology children. Signed-off-by: Zhao Liu --- hw/core/cpu-topo.c | 22 ++++++++++++++++++++++ include/hw/core/cpu-topo.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/hw/core/cpu-topo.c b/hw/core/cpu-topo.c index e244f0a3564e..cba2dc747e74 100644 --- a/hw/core/cpu-topo.c +++ b/hw/core/cpu-topo.c @@ -168,6 +168,23 @@ static void cpu_topo_update_info(CPUTopoState *topo, b= ool is_realize) } } =20 +static void cpu_topo_check_support(CPUTopoState *topo, Error **errp) +{ + CPUTopoState *parent =3D topo->parent; + CPUTopoClass *tc; + + while (parent) { + tc =3D CPU_TOPO_GET_CLASS(parent); + if (tc->check_topo_child) { + tc->check_topo_child(parent, topo, errp); + if (*errp) { + return; + } + } + parent =3D parent->parent; + } +} + static void cpu_topo_set_parent(CPUTopoState *topo, Error **errp) { Object *obj =3D OBJECT(topo); @@ -191,6 +208,11 @@ static void cpu_topo_set_parent(CPUTopoState *topo, Er= ror **errp) } =20 if (topo->parent) { + cpu_topo_check_support(topo, errp); + if (*errp) { + return; + } + cpu_topo_build_hierarchy(topo, errp); if (*errp) { return; diff --git a/include/hw/core/cpu-topo.h b/include/hw/core/cpu-topo.h index 79cd8606feca..1ffdb0be6d38 100644 --- a/include/hw/core/cpu-topo.h +++ b/include/hw/core/cpu-topo.h @@ -46,6 +46,8 @@ OBJECT_DECLARE_TYPE(CPUTopoState, CPUTopoClass, CPU_TOPO) * @level: Topology level for this CPUTopoClass. * @update_topo_info: Method to update topology information statistics when * new child (including direct child and non-direct child) is added. + * @check_topo_child: Method to check the support for new child (including + * direct child and non-direct child) to be added. */ struct CPUTopoClass { /*< private >*/ @@ -55,6 +57,8 @@ struct CPUTopoClass { CPUTopoLevel level; void (*update_topo_info)(CPUTopoState *parent, CPUTopoState *child, bool is_realize); + void (*check_topo_child)(CPUTopoState *parent, CPUTopoState *child, + Error **errp); }; =20 /** --=20 2.34.1