Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1347778ybp; Thu, 17 Oct 2019 11:24:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxHCwrwY7DI8skc3e6veO1SnHBumaFRsOK8f+s/2NR9MsNzQheOu9qN9XeiTLA3O4Gtlyz X-Received: by 2002:a05:6402:170e:: with SMTP id y14mr5370824edu.82.1571336672535; Thu, 17 Oct 2019 11:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336672; cv=none; d=google.com; s=arc-20160816; b=wpvojZD3ENf/eOep86lhstXeKNCzYWZIPy79ctNmBMQHgeX2nBi9BPBhuuChwfYJQj 1jykLt2BiXM4BvSkGXbznGyeXBCjE2i84DPF+YhId6t5A0UjhKdFr8H8NnpJ8xNFfEv/ Pyb7LbBwzsEb2HJc2bZirUkvrJlYxdQ3sBr9XRdktmAK3kuJ1SRfWiHWHsQc1a6KP8ux /QSH9x/pUupTzyV4vXr+z9Nlx2i23iJg9bbezOtkymAwd/ok1fg5mlg2Fqw0OFwaYLxI 9BSVzUMa8XDhM8RXlUTK+FVwyWsGEAcn5Bjqv708bPG70UfWLQMEa6Jf6/0DWpTOLojB Tu8w== 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=JCCSVxY1wy9L3MmRoZ8RqlCRjdY8NAHKWx56tIgW8Wsl0P8UohlVKGs+Td3cZTIJC9 dZ75rRZZlYTHMz9hO+7xKWYvji1onjk8PRrhcyFsW1JyhL6kmff/oMfIOVxG27TF9PwQ CIxI8e+uXKqMJZMS7h5/AdQLuzrATmqcK3NvI6trlK+xyBCplPLFpHwkwmY4rFf4lmCI YLWrwCPPkH687yecrQnJxGzeQFa2kDeoziCqd56GrVq794KXKHIiBQm45adFnLWj3LFN kw8OVJNbxchKsNZi+K3K7tFVFugvbzebz07rfTqNrgxNGzhd978p3hdHF45MJUQ68Aex v9dQ== 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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 v3si2154921edc.404.2019.10.17.11.24.09; Thu, 17 Oct 2019 11:24:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406814AbfJPWD2 (ORCPT + 99 others); Wed, 16 Oct 2019 18:03:28 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(+) 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; -- 2.20.1