From nobody Mon Nov 25 04:30:17 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=1717553822; cv=none; d=zohomail.com; s=zohoarc; b=CnenXVdBMv7nuQpwn0DqG3CZhWTQh6FcT/D9Yqp87ilAkJ4YTwGmHsiC+83+kzgqCebwhyxY2vjvq+MB+FdZ4pREqgPhiTS/LJuqckhfsSaa9GiFkyqwbxCZG1vnfk7O3IbJorTpux6I/lZJxkMxYT6OZ0XLtJ0PDlgHUESENdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717553822; 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=6zYI5XmAf6RQjBQ6bZ9aMqq7aDxYp0W8beC3GgKBVA4=; b=ChzVKZfEZhM8V8vZUc7WBGXiZL/wAE4SA4EQkvie74/DblVJFkNns5x654pv+08Eh2wJoTwQa+Xc+8tjsSPZeVFVfP+WmY4h4tW7QANvsZ9OsldDC17l+HGpG3SVTQb5i9ytSHx0BTozFklOSXWR7WHkfMIa7qKs1LhHZNcnmOk= 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 1717553822052574.9227449427702; Tue, 4 Jun 2024 19:17:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEgBX-00038x-El; Tue, 04 Jun 2024 22:15:31 -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 1sEgBU-00037l-Kk for qemu-devel@nongnu.org; Tue, 04 Jun 2024 22:15:28 -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 1sEgBJ-0001go-HS for qemu-devel@nongnu.org; Tue, 04 Jun 2024 22:15:28 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id F40221380114; Tue, 4 Jun 2024 22:15:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 04 Jun 2024 22:15:14 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jun 2024 22:15:14 -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=1717553714; x=1717640114; bh=6zYI5XmAf6RQjBQ6bZ9aMqq7aDxYp0W8beC3GgKBVA4=; b= AC/Xpr/wIVUJiFzVb6gK7Gxeag5X1InAma3FtCvQsTKcCCf43BqcT8Qai991Mi6+ lwBl16f2alW4aT+46s0Po+GtsPnusbDQM+wzcUBwtRzmUtGMrn+jzHAi0ZBPtyLK Ds+j01D3GrBQf4K+9wi97a05HLEktbQbwsf0sTPwDFtsMLmVpAPnTUwf5HQRbWqA oiMYKSHnVlba2fGADXj6KdFIoX/QQmwRZPrZp6botIb9qXslFP3HCbxiHhnxK23F Utn10i4/jzPVstKqYpneW89agtkYSwPaEfncrkvJf+6NIG/TGZrZrMuVhEaIWATI 5pm2ZyN0KwERqKrHvWcEbg== 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=1717553714; x= 1717640114; bh=6zYI5XmAf6RQjBQ6bZ9aMqq7aDxYp0W8beC3GgKBVA4=; b=G II5I5/3KZogb5FbiJA+rIEsUouM0XVmuokQg+jR4xLTw4RUVBOprLOdCYopcwZTl iWIfo1R2KwloBiDtD3G/vQpDnUZI6e9o8ZXut+z2FQVddCZPDSDzdPZJ0ZDRffKI RQnWqJy2X1eDVWaUBBrJYbDTjoK5Ze2oKymw/OO8ocEdtO2whNxj97CO7R0k7qwR BowDqDoFaa6Yfstu3H6q8mzLM8ZmdlWv8jaBqhzCrHKyZp5zU+bguyG4aMK6r9Rj k03DOy2W068hbgY8/oj9DFjoccPRCZcuhCU3X5ff3HLVXlqPpgK3KxCO/nmeYf2s 62gPoKqW6si+7m4ZR8+mg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelhedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail From: Jiaxun Yang Date: Wed, 05 Jun 2024 03:15:05 +0100 Subject: [PATCH v3 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-v3-4-ddd2c0e03fa3@flygoat.com> References: <20240605-loongson3-ipi-v3-0-ddd2c0e03fa3@flygoat.com> In-Reply-To: <20240605-loongson3-ipi-v3-0-ddd2c0e03fa3@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=hnXpsnXQTRb+LSXuPnTPlwPEXPAPRspcFsaf0+IprRM=; b=kA0DAAoWQ3EMfdd3KcMByyZiAGZfyi6hi+qGIs/HuFEuvyHWfNHdZOKdthVyVmMzDmju0SXy0 oh1BAAWCgAdFiEEVBAijrCB0aDX4Gr8Q3EMfdd3KcMFAmZfyi4ACgkQQ3EMfdd3KcNGHQD/XzBE +wMCySdrtQRzoDSN9gxYiwGG1MFU2VUhiXuQ1PwBAKKJZWyvVSliNAwIkExZJb7nVS/dSOmmYbE ZTTusUagO 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: 1717553823107100011 cpu_by_arch_id is doing the same thing as our ipi_getcpu logic. Signed-off-by: Jiaxun Yang Reviewed-by: Song Gao --- 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