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 AA3E0C10F16 for ; Tue, 30 Apr 2024 04:26:36 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E64kiZAQQusZiqPJm0FxcuVH7AJ/1eTMEAHVfJTEnkE=; b=Z/29i9i8hYzDLI 30fv0nw8/2iKxzzw02pCxEQb0qwSvemetebhkq14J3JdxtZncD3zfJzqjtihOjPMCLlQtIruIa9Uq 8lxr761u6Sstfjbhm5hjrnG/ulapKC16udWo0Yx9ykFCbzBHRAVCle/yyWk2wZsyBeAz371fFRVNJ R1hhYoxk6N+2HgQdRPWNcRSHxCqkasdqGz55MLcQniUORgJ1OYF5qbe634hsHRtN+2nM9TcdXV4fP vt3IbDtiEmtzKonwENDOL0ZCXz5IJ3Ps3ZqpGyV2MIA1pI49uMg6piODQw6rI4UWdppKhL+z+oO39 9bYqCROH/+UMs9SRzDTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1f4V-000000051oH-0geL; Tue, 30 Apr 2024 04:26:27 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1f4S-000000051nY-01Ic for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2024 04:26:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714451182; 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=GJO84Ws04msNmbJilIaROLjMXpV12WR1ttG2ubDyNe1O2ZMQ5HagGLyREqhRaSKbsipjQ2 ZNcCPXEBEjXs2y3SqIbIT9PPg9Y0aLKy7n38Y+2IbD2r90g86A/tu5alBovMF21gXp/QS+ J4k4IOnrljbJ34Rd22dc0rnKULrSC2Y= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-0hsI878wPJiNMxRcTcXphA-1; Tue, 30 Apr 2024 00:26:19 -0400 X-MC-Unique: 0hsI878wPJiNMxRcTcXphA-1 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-5c65e666609so5696723a12.1 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=Et/LEs6/htePWaUW6SKh0CPd7wIPDIOGUTzoRAgw2jIncbzXV23p/kalnez5PVJIyi nGa2VrGXaNtuQNTRPgIT5E4dQX38okl/x6uJHx/IRjvZY+Per18oT46vHTA7gRdGFLCl 97E/urSqNHkgZU/LSmwY0vLTrmsW9GsOVpVCg4hGLZGvIkpC1z8wgWVJjB4II/BuXC1s +VNv6pxtpidZTIpbISw8vQBW1JMZoqVrXjxh6HI8Eat5M/rcU3wCrb2fWNEETNgN+kJr M5F1J9khAuMjZ2NOjIM+LSuIqOk0B755WidvqqFB64ihnxCsZPjn1IBWeSPfxWQt90Mn KWyA== X-Forwarded-Encrypted: i=1; AJvYcCVnFqrGPIbC8R3EpjDwIDPoX2UdDvQcUK9zebDPyDMHmB9GeGFisZCV4ckiFYSjNeRiXiUbPEPgQE3ToSEWYiuh/W3uUjHyWfh9VooveSl3/rHNsrk= X-Gm-Message-State: AOJu0YzMkUz5FYnTOoOF/UjS/VJQe2OZfucN4/BI975tD+sXXJJU7eoy O4Eo92LZbcEQE67w+B8AzJ40g5laSheXuQfwd/AUbyl56X6Y4kzL1J6qERYUXO5+/tTyArM0Hfo n15qtWJ5gdu2TrsQ9na3DOhsdBukLtJ/tVTzF34i95ZCDtGVMW+HgE0MJS6ajOV4EI+4TtQLb X-Received: by 2002:a05:6a20:43ab:b0:1af:597f:ffa4 with SMTP id i43-20020a056a2043ab00b001af597fffa4mr1773928pzl.14.1714451178647; Mon, 29 Apr 2024 21:26:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH07U3E59OEv3uasYAdnnN9/WYRlSaTmrz5sCzeoOlurs0CWJYXB3V+LTa+nYaZB59wKOeCng== 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 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 05/16] ACPI: processor: Add acpi_get_processor_handle() helper 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_212624_129419_49A0597E X-CRM114-Status: GOOD ( 18.10 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel