Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp214279lqn; Thu, 11 Apr 2024 21:18:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgCedlvU8R/xyDzUHMwoQsagA06BkzOO90EF69YtuOXqHNmaUU/DsTxGsi+tzrKwWeNmQaxd5MPJRg/FOXQ6svocMsVHLWUZwt/UtkNQ== X-Google-Smtp-Source: AGHT+IGoQSmMeMeIZc+PlTfVyHeZlX/q9KzsYs+X5MruphtW8Rt561zNfhog8AfbxCMnjV7Ybi8F X-Received: by 2002:a17:906:80c7:b0:a52:1a78:e3ca with SMTP id a7-20020a17090680c700b00a521a78e3camr1209515ejx.6.1712895492166; Thu, 11 Apr 2024 21:18:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712895492; cv=pass; d=google.com; s=arc-20160816; b=EgzOuPdKviRA9dAmKziBc1gR7Lun9390i7Snh03Y93KADUK9CzirllUoqZ3PDGxD0A 4rSlgXBZZjOc23WAwed0M0AUs5F7+TuxAbPQ/wRQDQvbec9C/jisn8pKdWVru6tPKtVO W5vhUKDyn16jd26+zlPK2WaqU7Xu/q0twXIp5eeVbt28O9xHsmIUiYxQqAGbgnRtZrcC Nx+oQYNjUAGrUOC9rgn3KMnjyWTdD3adw1Cr+Oy1MZZJhtlu6Pa9AIijygu4jusiaV/V vz6PKMpVzJ5QKVDuxM2wzP21ftiBAsymOvp9PIloRsXkxrwyRnqEWYMZt+h5nhfFWSJr PK3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=BQFrO2b5rklXC647qjW/RPwlwiEaXVQMKm3g1wxKRek=; fh=J1hZ1pEiu0RzUx9R+fIpj8XrFTp1x2ESXfRuEjjLAcs=; b=BIMTxXVUOK5w9k2cLXcVUGOjCsO/q3EeDtQtRFdZ3RVu892UHtKWgb5EujH8xu+Bze 5tbpwSkt7p5AvsHtLo0OIQ3zY37dmYKs3y7Sl6qAyEn4KEAeBMFqFgvW5eKnuLbZfMHy N8gOOUW1o1+atnoOf3Wftw4vqUVL07Gj9gINqDsY42wDm24DDux85twcU3acq9NvmosE KJLgG9FEa8z1juBlRc3haeYmWlRpMSdMc6PrkyrXpjYhEqXIlG0CtEK/iSg5A/r4gMxm QtB+TzivQOUlmQkadmW0Xxk4jzgyo3xf1qmrtdkWUzSWPIa9NFNSpWNcAHcgq1ltO6h6 YyaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lUtBk9Kt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-141914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hs20-20020a1709073e9400b00a523636daaesi243434ejc.119.2024.04.11.21.18.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 21:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lUtBk9Kt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-141914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E14741F21947 for ; Fri, 12 Apr 2024 04:18:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D92EF182B1; Fri, 12 Apr 2024 04:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lUtBk9Kt" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E41621F5FF for ; Fri, 12 Apr 2024 04:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712895483; cv=none; b=cetJuOCXQPc2fpZKyY1OQPKaHK5tMUfe31IkEQS5IoMe57Vb5qAs+AGyLhBhep7TFzMgSMhU8Tp2yGQ/RwLC+IvlZshULce7ERdazF7Y5NXV7bKQn3oUQPNAbxKrmQoa1g5pLuB0gYgiqlHkqHupcoiIa3a3gB1nXsQUxogGX9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712895483; c=relaxed/simple; bh=Rs6KpGntHCw4Yqslf2bcFsD9oUEkwjTy3lZ29ZNks2w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=j8UUqaH1P4cF+Lw9tJ8DsAktg1FiXI9pO612zbaKmeZfuOmyy2GIMQGAYZL27reNkMO4dtjGttAJZL71LpgiimPfdKQmLpTf3tSnQQTJgNjMMYHxj1ak1LlMZkjLRrlrRqh2t04Y04jd0mjTK3+I71Sn2OrDm0IrMwzmx7QKMnQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lUtBk9Kt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 460F0C4AF08 for ; Fri, 12 Apr 2024 04:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712895482; bh=Rs6KpGntHCw4Yqslf2bcFsD9oUEkwjTy3lZ29ZNks2w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lUtBk9KtFqJI+UQlt0ApruN5aBNHlZbvkbOckd8ziZLXDZfNVgF7uC9qVaPnxLn2Y 8ehodt8dWSY+IoOUo2uUHnRuoVi1MD68nR8aLjRAJXYVp+Fhyrb7CBKz1GxtWkVrWW 04GtGTS+mcJLpoeCU5EcQk0d0kxMftVRHtXGyTOyUIeOzC0ZYFgCr22RmnsEwWc3lg CD+p4AvTR7rWmM7QEWVeRKzQ7VUboGq1QxICzqIfO0sTjGv4IH04HRtMJQdIRf96dR Y0dCiVMtbY4vAGZAt7YtZEV5TiPSZ88h1a6qk4DMCXT6yInwztRQiNyxFvjrJ/1rCn dmOKx0pA8uLDQ== Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a52223e004dso43867966b.2 for ; Thu, 11 Apr 2024 21:18:02 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWgH6nq8F4k8Ovubptfop1fxO7gMa+xNxs0/F1G5XDNMSOA+CF1DUFYQgyOGpc3ZSqStbiUR8gUDb6MkmrkwHjQaYAog7p8OKg/EBal X-Gm-Message-State: AOJu0YxicFzPt6Fd/75akB/BXp1igCYrPSed2EWuV5Kgj36y2iwILpic xBme5VzLCPC7CDRxeMnOpfg1OzVfPOWbleNeEuJQ4A6HkpyR2numOltOCXnu/7uX6t71fYGbFL4 hIRzMospoTKnJazS1ioCaFjCpXLk= X-Received: by 2002:a17:906:80c7:b0:a52:1a78:e3ca with SMTP id a7-20020a17090680c700b00a521a78e3camr1209261ejx.6.1712895480760; Thu, 11 Apr 2024 21:18:00 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240411010510.22135-1-yangtiezhu@loongson.cn> <20240411010510.22135-3-yangtiezhu@loongson.cn> In-Reply-To: <20240411010510.22135-3-yangtiezhu@loongson.cn> From: Huacai Chen Date: Fri, 12 Apr 2024 12:17:53 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/4] LoongArch: Refactor get_acpi_id_for_cpu() related code To: Tiezhu Yang Cc: Thomas Gleixner , Arnd Bergmann , Marc Zyngier , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Tiezhu, On Thu, Apr 11, 2024 at 9:05=E2=80=AFAM Tiezhu Yang wrote: > > Currently, cpu_logical_map(cpu) is defined as __cpu_logical_map[cpu] > in arch/loongarch/include/asm/smp.h and __cpu_logical_map[] is defined > in arch/loongarch/kernel/smp.c, that is to say, cpu_logical_map(cpu) is > vaild only under CONFIG_SMP, the implementation of get_acpi_id_for_cpu() > which calls cpu_logical_map(cpu) is not suitable for the case of non-SMP, > so refactor get_acpi_id_for_cpu() related code to make it work well for > both SMP and non-SMP. But you implement cpu_logical_map(cpu) for non-SMP in the 4th patch, right? Huacai > > Signed-off-by: Tiezhu Yang > --- > arch/loongarch/include/asm/acpi.h | 7 ++++++- > arch/loongarch/kernel/acpi.c | 9 ++++++++- > 2 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/a= sm/acpi.h > index 49e29b29996f..a4ad3f75bd60 100644 > --- a/arch/loongarch/include/asm/acpi.h > +++ b/arch/loongarch/include/asm/acpi.h > @@ -39,9 +39,14 @@ extern struct acpi_madt_core_pic acpi_core_pic[MAX_COR= E_PIC]; > > extern int __init parse_acpi_topology(void); > > +static inline struct acpi_madt_core_pic *acpi_cpu_get_core_pic(int cpu) > +{ > + return &acpi_core_pic[cpu]; > +} > + > static inline u32 get_acpi_id_for_cpu(unsigned int cpu) > { > - return acpi_core_pic[cpu_logical_map(cpu)].processor_id; > + return acpi_cpu_get_core_pic(cpu)->processor_id; > } > > #endif /* !CONFIG_ACPI */ > diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c > index 5cf59c617126..ccfa90faf0ea 100644 > --- a/arch/loongarch/kernel/acpi.c > +++ b/arch/loongarch/kernel/acpi.c > @@ -98,8 +98,15 @@ acpi_parse_processor(union acpi_subtable_headers *head= er, const unsigned long en > return -EINVAL; > > acpi_table_print_madt_entry(&header->common); > + > + /* > + * When CONFIG_SMP is disabled, mapping won't be created for all = cpus. > + * CPUs more than num_possible_cpus will be ignored. > + */ > + if (processor->core_id >=3D 0 && processor->core_id < num_possibl= e_cpus()) > + acpi_core_pic[processor->core_id] =3D *processor; > + > #ifdef CONFIG_SMP > - acpi_core_pic[processor->core_id] =3D *processor; > set_processor_mask(processor->core_id, processor->flags); > #endif > > -- > 2.42.0 >