Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1784862lqa; Mon, 29 Apr 2024 21:28:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSDC6D9TR/HMGhWr0PXGjW80PV+hOASLCohHWnA3MkkhMHC8Fd1TgnyK9vd7WUnkuQXzRljlClTKV6pqfbEpVbuVrDSLrpeRP7cALqiA== X-Google-Smtp-Source: AGHT+IFtQmevOPGEJnLIjqEPWIZC/ifvOUKK/Wb7yVTrMHz3UlewyKwx6cVzl6l1Kjb//OY9wuW+ X-Received: by 2002:a17:902:76ca:b0:1eb:4c98:8b15 with SMTP id j10-20020a17090276ca00b001eb4c988b15mr1526727plt.61.1714451314357; Mon, 29 Apr 2024 21:28:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714451313; cv=pass; d=google.com; s=arc-20160816; b=AyBbxUI+OmjkZ/Q3Z3O/uyL2cSLYCIAhz4WZr5k8CJmkNB8Q6+VSRgW/KsZik1/Ao6 T3MNGJhgk/2qzEjFhEhBmkWLkPiUzhNHzX1t1NvACxmwafOWPeZFj6O5H6jptgFjbTND d1gSVdDO5XsLahCR//AyNUxtCmQhgWL1v3APyDnhFBL5iuJzxTDqwbXaN7nGyL+hqQu/ DSrk4++vXfC+wjr95ebdgKWMc26ktxtv3g2+b26yKLP/g6C3HF3SXzumkCI1Ks5lyDVB iPqKh6tTkzivLVMtePrFoJ5dQz5kCJej12Yj20qoLlPdZtG8MdXA7nvVqrlvzthctr/X bYxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=/j3/XOns0oFgwfO5bxhGBltITHmRiIbor4kORGQYrjA=; fh=V1bI8YXrMMn74K0OyScnqkGSR86SRG9lq9l5y18J/dk=; b=GpwPiamuvaEEjJDNybVgufivv0khUjHYXYIC/ADJDt6+XyGHCuyX2sHrdMsV1hHPIO /VpR18mvsFwELjdowrXJptP0hYkXCOgXwQOTSCn6dQXm5nH+W6ctjRsOFndxB9jZRQ3t lfoYDp3OtGPkQxPqFYzCo45khZwbMvtg2gPu8h8b/mGIL783K1yXdgQ7PJ/cw+pdBD4+ 64GxFk4Y+uqJKu501tKQavBBiqY4HXEXWKM1C+RrJ5/CHt3lWI7ApH+wmK//dqMDpjx0 ElahMV2Oq4PZjJO5MrXDTAahWASyKLuNXO1Jcm6Uk0GiZpMfCvkYnpy9E28GnmLkcOBG dyjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JosyabYK; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-163321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x5-20020a170902ec8500b001e913b8bc01si17926721plg.106.2024.04.29.21.28.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 21:28:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JosyabYK; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-163321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 65F26B2127B for ; Tue, 30 Apr 2024 04:26:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42BE8134B6; Tue, 30 Apr 2024 04:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JosyabYK" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 F2EBD12E47 for ; Tue, 30 Apr 2024 04:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714451185; cv=none; b=NJ3d9gY7FBpcamOHihEGPQZNDd5aG1+WhGryjoybDwhbGfMjGlj2oqcdl8m+vXbqMZNrjI94ytQkWEOrt04LTcLC/Nx336/2kKRABY6v1i9sgA+kMwllrJFO2+9mMTwv81AxWQNxY6vIl8ZOEvDJdoJ3sUgLKCJPJMFyjjhM30o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714451185; c=relaxed/simple; bh=7/LvDV66mDIzCX8Ki3ehENh2BWy+/8sMXmXZYQ9n3Gw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=otdMrf+o1aszHMBOSPB2uIaFWjoEmCIXmBcXBU3WYYt4Alm1vEyI1+V5/DEfOD0ySmgbwBBha8iscxgAIWV4M2rq1ED3jPAjiv3GGhbDLW9J3jeIiBoOfugBMm+cH+BktwWPEWmZnUoq/mg2JTswedPmOBPec47Aa2yqIS0B9Ao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JosyabYK; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714451183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/j3/XOns0oFgwfO5bxhGBltITHmRiIbor4kORGQYrjA=; b=JosyabYKWBB7JgkSX2dxfOPiRlu4cT/CIIwIhFb1RWyLRccf9DM1RFBRVlkgmQblQuE5Fa CM919Py2nIDzKstn9H/E8Ga1EZLsuiNjtk5U2r7MmGdLgkp8sy4mTHLbeyKKgvTxbXS4T3 oWwSfuqS1mQgOptV6vfBoQ7LRUmvFJk= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-htm8gXbRP6qRgx9hAcnbAQ-1; Tue, 30 Apr 2024 00:26:19 -0400 X-MC-Unique: htm8gXbRP6qRgx9hAcnbAQ-1 Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-604bad9b2e8so5691264a12.2 for ; Mon, 29 Apr 2024 21:26:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714451178; x=1715055978; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/j3/XOns0oFgwfO5bxhGBltITHmRiIbor4kORGQYrjA=; b=sEI9D1x+6SBT5WNoq7vx/Kv32QTr/Vw3AEg4E0a1cmZLJ3hST8SYZDTJxjpduMJZBX qUhHa83LTF+FX4EdKgaFjyCD4XRToM+DfwJ3t+zP9EnN2M3Xs+Vy/9g+nQYnejOc5/YL EueSN+CQ8HDlKGhGPpcV3e+2X97DdvsGi+pGe7mEmFLpjOJZSPVSjYpaPTljgjoKh6fg sqFBcE3SIB4eSjP01aZBEbZfFxnOETfKOl9ChM3bBtbNDB85ojlWyOTLwxg3aOJO+FAM nMu9sQ54DZAUHD/ypIq4HsN81u7SrYhQ2X5+H4A8XBz1zLPhZz0Ah83PCNGrKHsF2HAi PjsA== X-Forwarded-Encrypted: i=1; AJvYcCXv1KyPIBV8iwZzMTSF860wup4h5L7c9yxa3o3JwAZ5GcCUKG4O8R0oqvLAuqexxeDBlC1qkTLs10rieA3ZhWCk2EMTMRtPhOPMpmKp X-Gm-Message-State: AOJu0YwUYJG7hQwzV59dAtfNRKt5I98D17e9J4gcWKld1JZP8+ju6Ug6 QjyQUFdkgorVYGau8ckDDTUzJm1HZlc9Ew5nJwW7uYI3Cvone+ub8QjomXnAWoCIbkihGofhSdB 4OPZz1G4l4OIugGhdFS6gk+yiwh9w+1Z2E/38FdIFG+n+hPa0HGe0WeSv5vuhlA== X-Received: by 2002:a05:6a20:43ab:b0:1af:597f:ffa4 with SMTP id i43-20020a056a2043ab00b001af597fffa4mr1773941pzl.14.1714451178654; Mon, 29 Apr 2024 21:26:18 -0700 (PDT) X-Received: by 2002:a05:6a20:43ab:b0:1af:597f:ffa4 with SMTP id i43-20020a056a2043ab00b001af597fffa4mr1773917pzl.14.1714451178308; Mon, 29 Apr 2024 21:26:18 -0700 (PDT) Received: from [192.168.68.50] ([43.252.112.88]) by smtp.gmail.com with ESMTPSA id p2-20020a170902e74200b001e223b9eb25sm21272994plf.153.2024.04.29.21.26.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Apr 2024 21:26:17 -0700 (PDT) Message-ID: <63f7c71a-fa01-4604-8fc6-9f52b5b31d6b@redhat.com> Date: Tue, 30 Apr 2024 14:26:06 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 05/16] ACPI: processor: Add acpi_get_processor_handle() helper Content-Language: en-US To: Jonathan Cameron , Thomas Gleixner , Peter Zijlstra , linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon , Marc Zyngier , Hanjun Guo Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , linuxarm@huawei.com, justin.he@arm.com, jianyong.wu@arm.com, Lorenzo Pieralisi , Sudeep Holla References: <20240426135126.12802-1-Jonathan.Cameron@huawei.com> <20240426135126.12802-6-Jonathan.Cameron@huawei.com> From: Gavin Shan In-Reply-To: <20240426135126.12802-6-Jonathan.Cameron@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > 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. 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