From patchwork Fri May 3 23:24:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 163336 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1197950ill; Fri, 3 May 2019 16:24:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAG5fYnrL610qt9fx4BUeuc8QDkw0VWUGqfhYLctzhSHfAiz3WXbajrn2j53vepT6uT+2c X-Received: by 2002:a17:902:8b83:: with SMTP id ay3mr14128031plb.187.1556925869937; Fri, 03 May 2019 16:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556925869; cv=none; d=google.com; s=arc-20160816; b=S/Ojwlg1r3AjjYUsjuN2sXmxVGEr30xVsUkP3LBIiwYj0Ti6f1tfapvJ+k8DqcxGkd F/Q3MeKwaeZz9aJwV2jEINP1e+RRmnKBoT5AuOGPS2BPnoF0yiOYlYjaDFEMEa9s9I0i BkTwh4ozG/3qm471LFn4phcjkyJJT2UZdlKE+mDYhILFzeHMpp1S2LEG+g3K304o2NUr 6gfPZUaxQTsC6rCuyyzbWgp7WexGmNKrPb4TFtqSBJbAKFvKF6Ey1DJqXmrPshiYczJZ +ZAz2Ex0shuRVi+haBSecj7oOUObd1XHXwlQx/ucn5jHQ/a7r2XnEam8HNzWrlWVGPHD 20EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RomcoymDCgIywX8ChCYZ0qaza9Bn5HozL/WWX0MxphY=; b=Iq88eMmAulKTsQmHLRb3WoWsFBiPiaJXt99XX5XaOAx29xlyKZVZ9+nmkgLGMfnELD f3hY1/ow4hE/bqOho3Ct8ahZP8gQuIgK5HOikhv0Xhspl/xBzDpRAfotGJ3AauHnKfP2 ZuWVgtEVSJrIJK/El9u4TZr4cix8XTUPbNAAy1ewS06T95hFn2N9W8M313CIod3fgGfd iLvS7kEvGvbkJ22l5dmCjJ4IOVbcAPuJ4QAV9STFtBEvuRLs90PJAmcZkQBt0xkhR/mR IZ90uBiK62D9+iY4c5Fi92RluyjnlWnkLCZ9z60oMCUYgi3HKmiFcBtjG2GpRwKQMuhV FGXg== 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 x3si4677027plv.33.2019.05.03.16.24.29; Fri, 03 May 2019 16:24:29 -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 S1726376AbfECXY3 (ORCPT + 9 others); Fri, 3 May 2019 19:24:29 -0400 Received: from foss.arm.com ([217.140.101.70]:40222 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbfECXY3 (ORCPT ); Fri, 3 May 2019 19:24:29 -0400 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 85522165C; Fri, 3 May 2019 16:24:28 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EFCBC3F557; Fri, 3 May 2019 16:24:27 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linuxarm@huawei.com, john.garry@huawei.com, Jeremy Linton Subject: [PATCH v3 3/5] ACPI/PPTT: Modify node flag detection to find last IDENTICAL Date: Fri, 3 May 2019 18:24:05 -0500 Message-Id: <20190503232407.37195-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503232407.37195-1-jeremy.linton@arm.com> References: <20190503232407.37195-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The ACPI specification implies that the IDENTICAL flag should be set on all non leaf nodes where the children are identical. This means that we need to be searching for the last node with the identical flag set rather than the first one. Since this flag is also dependent on the table revision, we need to add a bit of extra code to verify the table revision, and the next node's state in the traversal. Since we want to avoid function pointers here, lets just special case the IDENTICAL flag. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) -- 2.21.0 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 1865515297ca..456e1c0a35ae 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -432,17 +432,39 @@ static void cache_setup_acpi_cpu(struct acpi_table_header *table, } } +static bool flag_identical(struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu) +{ + struct acpi_pptt_processor *next; + + /* heterogeneous machines must use PPTT revision > 1 */ + if (table_hdr->revision < 2) + return false; + + /* Locate the last node in the tree with IDENTICAL set */ + if (cpu->flags & ACPI_PPTT_ACPI_IDENTICAL) { + next = fetch_pptt_node(table_hdr, cpu->parent); + if (!(next && next->flags & ACPI_PPTT_ACPI_IDENTICAL)) + return true; + } + + return false; +} + /* Passing level values greater than this will result in search termination */ #define PPTT_ABORT_PACKAGE 0xFF -static struct acpi_pptt_processor *acpi_find_processor_package_id(struct acpi_table_header *table_hdr, +static struct acpi_pptt_processor *acpi_find_processor_tag_id(struct acpi_table_header *table_hdr, struct acpi_pptt_processor *cpu, int level, int flag) { struct acpi_pptt_processor *prev_node; while (cpu && level) { - if (cpu->flags & flag) + if (flag == ACPI_PPTT_ACPI_IDENTICAL) { + if (flag_identical(table_hdr, cpu)) + break; + } else if (cpu->flags & flag) break; pr_debug("level %d\n", level); prev_node = fetch_pptt_node(table_hdr, cpu->parent); @@ -480,7 +502,7 @@ static int topology_get_acpi_cpu_tag(struct acpi_table_header *table, cpu_node = acpi_find_processor_node(table, acpi_cpu_id); if (cpu_node) { - cpu_node = acpi_find_processor_package_id(table, cpu_node, + cpu_node = acpi_find_processor_tag_id(table, cpu_node, level, flag); /* * As per specification if the processor structure represents