From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8171FC4345F for ; Tue, 30 Apr 2024 11:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DXdoNp4FRZTnPZrLghZUF6YIOKQHJZ/6sPl3ZIMKb6Q=; b=FdP257ZaXp6BUf pnlt61Z3DxSG2d09OvqFu+7TgCwY+cuHAAlhhhNDh8wHwhHUerEvcsf8cCHje6nAPOIXUj1j+MxTQ 4AQTHN23i23jdSY3u4kVpT0AWU5r/+1X5V6C4n3rUL/ruEHHXD4YjUCw50J1FfYoEcExtXHyMsH+v 8FL6c/Y/lmQnqzhThWJvGOexxZ7OMD/jiyXqK26/5WzK2CgHcjUvdusEFsiQfZtqneRV2+rK8CBzL ts9mMuMe3Qek4pCEnrNVAkj9Ywv9jH6tfbJ0kwMoVrcqEwTP9KrCZSnm8zcy5DyICXOcEeS0IcwB1 Xh9duus4YzR0c5aQ1+5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1lKY-000000067bQ-1EoO; Tue, 30 Apr 2024 11:07:26 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1lKV-000000067YB-0lkm for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2024 11:07:25 +0000 Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VTHQW5wKlz6J6mX; Tue, 30 Apr 2024 19:04:35 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 34773140B2A; Tue, 30 Apr 2024 19:07:16 +0800 (CST) Received: from localhost (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 30 Apr 2024 12:07:15 +0100 Date: Tue, 30 Apr 2024 12:07:14 +0100 From: Jonathan Cameron To: Gavin Shan CC: Thomas Gleixner , Peter Zijlstra , , , , , , , , , Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , "Jean-Philippe Brucker" , Catalin Marinas , Will Deacon , Marc Zyngier , Hanjun Guo , Ingo Molnar , Borislav Petkov , Dave Hansen , , , , Lorenzo Pieralisi , "Sudeep Holla" Subject: Re: [PATCH v8 05/16] ACPI: processor: Add acpi_get_processor_handle() helper Message-ID: <20240430120714.00007ee3@huawei.com> In-Reply-To: <63f7c71a-fa01-4604-8fc6-9f52b5b31d6b@redhat.com> References: <20240426135126.12802-1-Jonathan.Cameron@huawei.com> <20240426135126.12802-6-Jonathan.Cameron@huawei.com> <63f7c71a-fa01-4604-8fc6-9f52b5b31d6b@redhat.com> Organization: Huawei Technologies R&D (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_040723_562786_F9DEB60F X-CRM114-Status: GOOD ( 20.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 30 Apr 2024 14:26:06 +1000 Gavin Shan wrote: > On 4/26/24 23:51, Jonathan Cameron wrote: > > If CONFIG_ACPI_PROCESSOR provide a helper to retrieve the > > acpi_handle for a given CPU allowing access to methods > > in DSDT. > > > > Tested-by: Miguel Luis > > Signed-off-by: Jonathan Cameron > > > > --- > > v8: Code simplification suggested by Rafael. > > Fixup ;; spotted by Gavin > > --- > > drivers/acpi/acpi_processor.c | 11 +++++++++++ > > include/linux/acpi.h | 7 +++++++ > > 2 files changed, 18 insertions(+) > > > > Reviewed-by: Gavin Shan > Thanks, > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > > index 3b180e21f325..ecc2721fecae 100644 > > --- a/drivers/acpi/acpi_processor.c > > +++ b/drivers/acpi/acpi_processor.c > > @@ -35,6 +35,17 @@ EXPORT_PER_CPU_SYMBOL(processors); > > struct acpi_processor_errata errata __read_mostly; > > EXPORT_SYMBOL_GPL(errata); > > > > +acpi_handle acpi_get_processor_handle(int cpu) > > +{ > > + struct acpi_processor *pr; > > + > > + pr = per_cpu(processors, cpu); > > + if (pr) > > + return pr->handle; > > + > > + return NULL; > > +} > > + > > Maybe it's worthy to have more check here, something like below. > However, it's also fine without the extra check. We could harden this, but for now the call sites are only int arch_(un)register_cpu() so if we get there with either of these failing something went very wrong. Maybe if it gets used more widely this defense would be wise. Jonathan > > if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) > return NULL; > > > static int acpi_processor_errata_piix4(struct pci_dev *dev) > > { > > u8 value1 = 0; > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > > index 34829f2c517a..9844a3f9c4e5 100644 > > --- a/include/linux/acpi.h > > +++ b/include/linux/acpi.h > > @@ -309,6 +309,8 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, > > int acpi_unmap_cpu(int cpu); > > #endif /* CONFIG_ACPI_HOTPLUG_CPU */ > > > > +acpi_handle acpi_get_processor_handle(int cpu); > > + > > #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC > > int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr); > > #endif > > @@ -1077,6 +1079,11 @@ static inline bool acpi_sleep_state_supported(u8 sleep_state) > > return false; > > } > > > > +static inline acpi_handle acpi_get_processor_handle(int cpu) > > +{ > > + return NULL; > > +} > > + > > #endif /* !CONFIG_ACPI */ > > > > extern void arch_post_acpi_subsys_init(void); > > Thanks, > Gavin > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel