From patchwork Mon Oct 14 11:56:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 176203 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4411656ill; Mon, 14 Oct 2019 04:59:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfX8w+fO8IcJJJuIb9uXs9CcydW8tpF5cVWHyxoGSIdKJsSNErfsvBp7yfpiXGQVXcV1Nm X-Received: by 2002:aa7:d8c7:: with SMTP id k7mr27740868eds.138.1571054360127; Mon, 14 Oct 2019 04:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571054360; cv=none; d=google.com; s=arc-20160816; b=KktW1X0ROKztAGndNz/mDgiCNcbnMLm3INkMWzOlZ5XOlAjPrxtKGfDtWX3ne9E1il 7HT6iwN2zO5cv5SrHY/xl3GA09jKw3XUvjMRCKdIlQXy7J4yo02q5E/nCiSTnX+CrBS6 iVRsv828TM75xkFNveiKTIeikSbjTUcaaXnfI4wgAO0l2MZnDd7Y2u5ysWy15I77oHKd b8ajmGu1/IR6SZaXM5ajFwSKXLXCuY+3DOg/gXK1gUuYKQBoQM4yaZfVKBELrPBehBwV +nbreM2Hf23n2940E1GouIZWgtkJxEDhVGS8GLrEcthxNcReevmvUS6mCfHUAw8N8xP2 omSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=1GJBlp9fqeZWMKei/o66iYBjYeBBD7mCnVqfrtASJ5U=; b=nbRccgaZ4FJdAkiQAPqoLsKJpXkdAzKf/hErI2KK53540xsWvfiUWpwjOcD0EF8Ie8 eTCdnoEJDVjInXmDyb2fgGKicc3iVc7/sbfp++Q2kQPANWhV2OPT66FDH+44WYI/NHea 5boMkMOKJ/di++QM7FwxazesNbNL2hKeFntOWsjbzkyq+IwKv1+4mPyLNrBPkTVnJBJ0 pw1BnaP/R3hZpwFSo7Dz33sWPS040CyaoK1tJSp7DOK2Lab9LRJFqzxFZHPGYPZFvSju wKYi5LBCB7by9tl1A3HTVZgF+1YlYxOczu4pmsADkfEa8VrEQ7Zj9jClm4gm8YphbH5C 5jqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26si10299213eju.87.2019.10.14.04.59.19; Mon, 14 Oct 2019 04:59:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730810AbfJNL7R (ORCPT + 7 others); Mon, 14 Oct 2019 07:59:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3709 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730314AbfJNL7O (ORCPT ); Mon, 14 Oct 2019 07:59:14 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7505F171767C03AD8FE1; Mon, 14 Oct 2019 19:59:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 14 Oct 2019 19:59:00 +0800 From: John Garry To: CC: , , , , , , , , , , , , , , John Garry Subject: [PATCH for-stable-5.3 2/2] arm64: topology: Use PPTT to determine if PE is a thread Date: Mon, 14 Oct 2019 19:56:02 +0800 Message-ID: <1571054162-71090-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571054162-71090-1-git-send-email-john.garry@huawei.com> References: <1571054162-71090-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Jeremy Linton Commit 98dc19902a0b2e5348e43d6a2c39a0a7d0fc639e upstream. ACPI 6.3 adds a thread flag to represent if a CPU/PE is actually a thread. Given that the MPIDR_MT bit may not represent this information consistently on homogeneous machines we should prefer the PPTT flag if its available. Signed-off-by: Jeremy Linton Reviewed-by: Sudeep Holla Reviewed-by: Robert Richter [will: made acpi_cpu_is_threaded() return 'bool'] Signed-off-by: Will Deacon Signed-off-by: John Garry --- arch/arm64/kernel/topology.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 0825c4a856e3..6106c49f84bc 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -340,17 +340,28 @@ void remove_cpu_topology(unsigned int cpu) } #ifdef CONFIG_ACPI +static bool __init acpi_cpu_is_threaded(int cpu) +{ + int is_threaded = acpi_pptt_cpu_is_thread(cpu); + + /* + * if the PPTT doesn't have thread information, assume a homogeneous + * machine and return the current CPU's thread state. + */ + if (is_threaded < 0) + is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; + + return !!is_threaded; +} + /* * Propagate the topology information of the processor_topology_node tree to the * cpu_topology array. */ static int __init parse_acpi_topology(void) { - bool is_threaded; int cpu, topology_id; - is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; - for_each_possible_cpu(cpu) { int i, cache_id; @@ -358,7 +369,7 @@ static int __init parse_acpi_topology(void) if (topology_id < 0) return topology_id; - if (is_threaded) { + if (acpi_cpu_is_threaded(cpu)) { cpu_topology[cpu].thread_id = topology_id; topology_id = find_acpi_cpu_topology(cpu, 1); cpu_topology[cpu].core_id = topology_id;