From patchwork Fri Oct 5 15:02:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10628279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DEBA112B for ; Fri, 5 Oct 2018 15:06:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A451294EE for ; Fri, 5 Oct 2018 15:06:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1B3929560; Fri, 5 Oct 2018 15:05:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7AF412955D for ; Fri, 5 Oct 2018 15:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tmZU8h60kRi3PlqcPX+7Kt+Pymi/sc35vMI38kkme08=; b=MaWzkoW76CbEzQ QFj+PeBv6i3LkAJ37nhqgsou3pDZPMXLsmvo1Z4KtHS9oPu0X0SCkB7DwXJ/fTWJQTbK6lziXYc7z j6tUo6pHdATaQvcAUu9ACSCl1OP0EyCpyJ3/kCufUEOiX1y4MhbHpoiMQ3dpc3YilEp1YFdK5cKfO Z68o/njDAVkCmsduNxb8cpVU1dzdqpQ1YZMbfgDwvIbFRNMT58JvhGZxDAIBGS9qiSyncwuD4v05s NLlFOMQsxlvEKrAWXwo3MvdojAXknfR6nIbzp0YJ6BL3CTeG5vBM3znc5bCPzlie7U+r4O8bb5eIj r6sKmPM5ay7ozc1oex8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8Rfl-00058H-Tx; Fri, 05 Oct 2018 15:05:45 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8Rd3-0002nj-9w for linux-arm-kernel@lists.infradead.org; Fri, 05 Oct 2018 15:03:38 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AC50CED1; Fri, 5 Oct 2018 08:02:50 -0700 (PDT) Received: from melchizedek.Emea.Arm.com (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8611F3F5D3; Fri, 5 Oct 2018 08:02:48 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Subject: [RFC PATCH 1/2] ACPI / processor: Add helper to convert acpi_id to a phys_cpuid Date: Fri, 5 Oct 2018 16:02:34 +0100 Message-Id: <20181005150235.13846-2-james.morse@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181005150235.13846-1-james.morse@arm.com> References: <20181005150235.13846-1-james.morse@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181005_080257_384875_AC2BD8B3 X-CRM114-Status: GOOD ( 14.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vijaya Kumar K , Lorenzo Pieralisi , Jeffrey Hugo , Sudeep Holla , Jeremy Linton , Tomasz Nowicki , James Morse , Richard Ruigrok , Hanjun Guo , Xiongfeng Wang , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The PPTT parsing code only has access to an acpi_id, we need a hardware property, preferably the corresponding phys_cpuid_t. acpi_get_cpuid() requires us to have the acpi_handle, which would imply we already have the acpi_device or acpi_processor structure. This call is useful when the CPU may not have been mapped, e.g. when walking the namespace. The PPTT is parsed after CPUs have been discovered and mapped, add a helper to walk the possible CPUs and test whether the acpi_processor matches our acpi_id. Signed-off-by: James Morse --- I'm not entirely sure what 'mapping processors' is about, so may have the wrong end of the stick here. --- drivers/acpi/processor_core.c | 16 ++++++++++++++++ include/acpi/processor.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 8c0a54d50d0e..333547bf7845 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -9,7 +9,9 @@ * Yinghai Lu * Jiang Liu */ +#include #include +#include #include #include @@ -263,6 +265,20 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) } EXPORT_SYMBOL_GPL(acpi_get_cpuid); +phys_cpuid_t acpi_id_to_phys_cpuid(u32 acpi_id) +{ + int cpu; + struct acpi_processor *pr; + + for_each_possible_cpu(cpu) { + pr = per_cpu(processors, cpu); + if (pr && pr->acpi_id == acpi_id) + return pr->phys_id; + } + + return PHYS_CPUID_INVALID; +} + #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base, u64 *phys_addr, int *ioapic_id) diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 1194a4c78d55..9235b41a9d52 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -333,6 +333,7 @@ phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); phys_cpuid_t acpi_map_madt_entry(u32 acpi_id); int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id); int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); +phys_cpuid_t acpi_id_to_phys_cpuid(u32 acpi_id); #ifdef CONFIG_ACPI_CPPC_LIB extern int acpi_cppc_processor_probe(struct acpi_processor *pr);