From patchwork Wed Oct 16 21:51:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 176528 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp44256ill; Wed, 16 Oct 2019 15:03:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPdQcLzrTW+oWU3Ec5v82jrDG5ib8qvoM1u9d4KfYE2X1SRoLYAaMUDt3PkubRN2R5hSiw X-Received: by 2002:a05:6402:7d2:: with SMTP id u18mr459933edy.23.1571263407429; Wed, 16 Oct 2019 15:03:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571263407; cv=none; d=google.com; s=arc-20160816; b=ylIdBIZxDqzY/+1RAJ4Xd2pd6FN5u2nYoqrWV/FDiPPkvO9U0X+vGuVWpdgIaYBv0/ 88CWyYstfhSaCc7bKpz9YSOs9BoeyxCYCIi0prCoOUj7AsYxdFrz3tW8BQkBbeZQtRFe 2168Eb4ifH5dYOGDJULFDFmf+eqtThGNBjyxduJjSuJF4byK07VE7ZfRpf7xMJQul/Qz Y9nuN45Biy7h5/h7Gy4xjJYaecRGy+6L/PFe4Erld+iLVbOaQjDyy7IsZzKYzu9rtgfT tT/m8K4xRznxjR1N/LTFoscMQC5ihxrb9LgK2bcd0Ju+2nYsNYry9eJ+/0vBL9ANaFEr JL8g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ydsM/WQmt0QAwBgY+Zh0kznwu6ljqL7j7Pz8u1wKYLU=; b=yz1rJELHfi/u5Wil7XR88BLaibn0uzGlWuHMl57zqYRrsk1PcYErnTSuhYcCnsXNdr c+wnE4Ks/8i4m8wXzxp0TBY148SrnX+ITHVW0IGOheL5ouT8LpZ9df/agJ2ekaoXIxKz h+jg1nfrXHaV4A134IXPiFlWQp2a5E2ayc9dQ2IpIIOhG9+LxjeXzjZfR/UC8xUk9E5t mCLsoA+EoPql4TXM9vtrZl/3dmmrJRdHuO97HsghN481aTU1o9vaArq7M3iXMq48dcsu YHy2mzadUiCdvQhCEOWJCUOC980ZUWYN5dhzNWVrurF6/BEv0Ud3mxLFm+6Q8PEVD/rC 6EfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xYyTB1aZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 z6si169284edr.443.2019.10.16.15.03.27; Wed, 16 Oct 2019 15:03:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xYyTB1aZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392248AbfJPWDY (ORCPT + 13 others); Wed, 16 Oct 2019 18:03:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:54208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438503AbfJPV70 (ORCPT ); Wed, 16 Oct 2019 17:59:26 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6F7C521D7D; Wed, 16 Oct 2019 21:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263165; bh=8k5n5IGq3TCysGLt78kdw+H9NEEsbkpbgbeqO7oSpnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xYyTB1aZpCkh0ffqKdaITcmhMZkvgDhFiVovj9TyBVIOLAMOYyX+pSvEU4bGDB8Qx v27Oq6k011aAbcxcNUMNTQpJHkagiSt6M/vpXfE7iKO7HsKA3alpr9v5zjHDD+j5X0 H8ERTK4iDq7a8UiNozI6sIRhoTtav/+KqB2oiitY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeremy Linton , Sudeep Holla , Robert Richter , "Rafael J. Wysocki" , Will Deacon , John Garry , Sasha Levin Subject: [PATCH 5.3 093/112] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Wed, 16 Oct 2019 14:51:25 -0700 Message-Id: <20191016214905.687553424@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jeremy Linton Commit bbd1b70639f785a970d998f35155c713f975e3ac upstream. ACPI 6.3 adds a flag to the CPU node to indicate whether the given PE is a thread. Add a function to return that information for a given linux logical CPU. Signed-off-by: Jeremy Linton Reviewed-by: Sudeep Holla Reviewed-by: Robert Richter Acked-by: Rafael J. Wysocki Signed-off-by: Will Deacon Signed-off-by: John Garry Signed-off-by: Sasha Levin --- drivers/acpi/pptt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 5 +++++ 2 files changed, 57 insertions(+) -- 2.20.1 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 1e7ac0bd0d3a0..9497298018a91 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -540,6 +540,44 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) return retval; } +/** + * check_acpi_cpu_flag() - Determine if CPU node has a flag set + * @cpu: Kernel logical CPU number + * @rev: The minimum PPTT revision defining the flag + * @flag: The flag itself + * + * Check the node representing a CPU for a given flag. + * + * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or + * the table revision isn't new enough. + * 1, any passed flag set + * 0, flag unset + */ +static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag) +{ + struct acpi_table_header *table; + acpi_status status; + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); + struct acpi_pptt_processor *cpu_node = NULL; + int ret = -ENOENT; + + status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); + if (ACPI_FAILURE(status)) { + acpi_pptt_warn_missing(); + return ret; + } + + if (table->revision >= rev) + cpu_node = acpi_find_processor_node(table, acpi_cpu_id); + + if (cpu_node) + ret = (cpu_node->flags & flag) != 0; + + acpi_put_table(table); + + return ret; +} + /** * acpi_find_last_cache_level() - Determines the number of cache levels for a PE * @cpu: Kernel logical CPU number @@ -604,6 +642,20 @@ int cache_setup_acpi(unsigned int cpu) return status; } +/** + * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread + * @cpu: Kernel logical CPU number + * + * Return: 1, a thread + * 0, not a thread + * -ENOENT ,if the PPTT doesn't exist, the CPU cannot be found or + * the table revision isn't new enough. + */ +int acpi_pptt_cpu_is_thread(unsigned int cpu) +{ + return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD); +} + /** * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU * @cpu: Kernel logical CPU number diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 9426b9aaed86f..9d0e20a2ac831 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1302,11 +1302,16 @@ static inline int lpit_read_residency_count_address(u64 *address) #endif #ifdef CONFIG_ACPI_PPTT +int acpi_pptt_cpu_is_thread(unsigned int cpu); int find_acpi_cpu_topology(unsigned int cpu, int level); int find_acpi_cpu_topology_package(unsigned int cpu); int find_acpi_cpu_topology_hetero_id(unsigned int cpu); int find_acpi_cpu_cache_topology(unsigned int cpu, int level); #else +static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) +{ + return -EINVAL; +} static inline int find_acpi_cpu_topology(unsigned int cpu, int level) { return -EINVAL;