From nobody Mon Nov 25 04:54:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=flygoat.com ARC-Seal: i=1; a=rsa-sha256; t=1717553145; cv=none; d=zohomail.com; s=zohoarc; b=RwCZAhrT0Z8n0C0njjT1Zc/5KRIyjmERtDr07znkZPcCX9OhU/9XPkeJJ6qRh53tBXTa//CSDJx9b6D9igNQEIpmN8vMum9ywFu+HaGPPNDK0dm1V2O5cZvOhq4vlLHn7i2r1HK7cQaMVb6YEajhC6ng0oEUwOoPj6+mojcUZ2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717553145; h=Content-Type: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=8BoOtXANLPjK32koJXSR9lzQa8++o+mvTyKyLfnRK/E=; b=UcdfSh+YbXUkb9tAanY89+bGq3BCN9t4eLvZau6p7LyGYxUeIapuOOgmmtW9DUfvgFBaKjqf8vGhsP5SPTvUQlf27s6jLzTlQkdOqk+4/TtPSeL9xT/kUsfCeF9C+Iedi0MjMWZXxMt+LpxCBhj0YM2yEo9zj+W3KJWRpgnaU6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1717553145355557.9911823004203; Tue, 4 Jun 2024 19:05:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEg0x-0007Q4-Mh; Tue, 04 Jun 2024 22:04:35 -0400 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 1sEg0v-0007PJ-SJ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 22:04:33 -0400 Received: from fout1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEg0u-00077K-AP for qemu-devel@nongnu.org; Tue, 04 Jun 2024 22:04:33 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id CD27713801A7; Tue, 4 Jun 2024 22:04:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 04 Jun 2024 22:04:31 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jun 2024 22:04:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1717553071; x=1717639471; bh=8BoOtXANLPjK32koJXSR9lzQa8++o+mvTyKyLfnRK/E=; b= Fb5HjbnUsogYLneiXrGfZoMkz64JCOW+WOavN2oLBLDViLRnDDgrG3tNY/2TThZx Ek4rBVsWAVFwXlYt5JJylxaiXGu/OpLSoTSmRFuGw7cEPjA5gCabqpQFdtJTHcIp 8SQ8xU4aOKGK+l4qGpzRr6sg4w6q1M1tpdeqmRytBuWiytZQkWbUtZnLYhNKtc3O LT9pw7CY83d1m9QCXTdB0h1yLLr7D8gahTgXfIv+zeQDiIn93bqygwOVfuZguFPR i0/oJlcFbhNdmf8TnoONqnfJYL38zFPCCRAZCRlg26uxz/9emv3oKpEFnjTbEJhL FM8Z1P7rCQXfCrp6xjGtdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1717553071; x= 1717639471; bh=8BoOtXANLPjK32koJXSR9lzQa8++o+mvTyKyLfnRK/E=; b=o psL9Vhm4RCrhvGOhAz6Tcy4lYzrOLevzd4N0u/fN+NAOczYhRKNA6ivGc72dMVdA mUOy6xqGaRS34yGYtYbouF0TPqUAp24fu1liZPhjRCJ9HIB/YkclN0lWDK1EFnkf D1aIRpqD4NG0S3Kbynd4DyrSbcTH+xesIa982Vg9+oyv/DJfNOGBr8e1oFjA+86p bJEWFQKYgajBISyMKrF5Xwv3fAZvxpEhTjU6C9D9r5KoyP7QEZuRRTzL9c6ktJwd 3d9rFMRlgSkC1TZbq4R9VS+EB0+ZAZ2Mz9a78XhjSK4PIUFovHW+7ke3fKUHrMkA Hltkgzg721LCa2vL2e3eQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelhedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail From: Jiaxun Yang Date: Wed, 05 Jun 2024 03:04:27 +0100 Subject: [PATCH v2 4/4] hw/intc/loongson_ipi: Replace ipi_getcpu with cpu_by_arch_id MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240605-loongson3-ipi-v2-4-da26282e03a5@flygoat.com> References: <20240605-loongson3-ipi-v2-0-da26282e03a5@flygoat.com> In-Reply-To: <20240605-loongson3-ipi-v2-0-da26282e03a5@flygoat.com> To: qemu-devel@nongnu.org Cc: Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Song Gao , Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2400; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=1GSlxW6vjHxZTKXd3mA/53bv0nOkIChGbCQnRgdgOCg=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrT446vebCu16L/huXvBvbm1Szj+2nR4lon2t/VMFVu15 K/gwfnPOkpZGMS4GGTFFFlCBJT6NjReXHD9QdYfmDmsTCBDGLg4BWAiYeKMDLvNThacEv+4V/x3 buGc45dPt+qI3l+xaGFmUGiB/SFx700Mfzhb/Twq2fj/vZTLVn9vEbhTXHvaYyO7Vyw3FGrFPPq fsQAA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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=103.168.172.144; envelope-from=jiaxun.yang@flygoat.com; helo=fout1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-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 @flygoat.com) X-ZM-MESSAGEID: 1717553146297100001 cpu_by_arch_id is doing the same thing as our ipi_getcpu logic. Signed-off-by: jiaxun.yang@flygoat.com --- hw/intc/loongson_ipi.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index c8a25b4eb8e2..b3cda5972793 100644 --- a/hw/intc/loongson_ipi.c +++ b/hw/intc/loongson_ipi.c @@ -118,39 +118,6 @@ static MemTxResult send_ipi_data(CPUState *cpu, uint64= _t val, hwaddr addr, return MEMTX_OK; } =20 -static int archid_cmp(const void *a, const void *b) -{ - CPUArchId *archid_a =3D (CPUArchId *)a; - CPUArchId *archid_b =3D (CPUArchId *)b; - - return archid_a->arch_id - archid_b->arch_id; -} - -static CPUArchId *find_cpu_by_archid(MachineState *ms, uint32_t id) -{ - CPUArchId apic_id, *found_cpu; - - apic_id.arch_id =3D id; - found_cpu =3D bsearch(&apic_id, ms->possible_cpus->cpus, - ms->possible_cpus->len, sizeof(*ms->possible_cpus->cpus), - archid_cmp); - - return found_cpu; -} - -static CPUState *ipi_getcpu(int arch_id) -{ - MachineState *machine =3D MACHINE(qdev_get_machine()); - CPUArchId *archid; - - archid =3D find_cpu_by_archid(machine, arch_id); - if (archid) { - return CPU(archid->cpu); - } - - return NULL; -} - static MemTxResult mail_send(uint64_t val, MemTxAttrs attrs) { uint32_t cpuid; @@ -158,7 +125,7 @@ static MemTxResult mail_send(uint64_t val, MemTxAttrs a= ttrs) CPUState *cs; =20 cpuid =3D extract32(val, 16, 10); - cs =3D ipi_getcpu(cpuid); + cs =3D cpu_by_arch_id(cpuid); if (cs =3D=3D NULL) { return MEMTX_DECODE_ERROR; } @@ -176,7 +143,7 @@ static MemTxResult any_send(uint64_t val, MemTxAttrs at= trs) CPUState *cs; =20 cpuid =3D extract32(val, 16, 10); - cs =3D ipi_getcpu(cpuid); + cs =3D cpu_by_arch_id(cpuid); if (cs =3D=3D NULL) { return MEMTX_DECODE_ERROR; } @@ -227,7 +194,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaqu= e, hwaddr addr, cpuid =3D extract32(val, 16, 10); /* IPI status vector */ vector =3D extract8(val, 0, 5); - cs =3D ipi_getcpu(cpuid); + cs =3D cpu_by_arch_id(cpuid); if (cs =3D=3D NULL || cs->cpu_index >=3D ipi->num_cpu) { return MEMTX_DECODE_ERROR; } --=20 2.43.0