Received: by 10.223.185.116 with SMTP id b49csp6165715wrg; Thu, 8 Mar 2018 02:59:59 -0800 (PST) X-Google-Smtp-Source: AG47ELtoZWeXL2LYwjAx00eCUI9yWZ+H/4a3PMVjhsbCkXF3A1sC5GF/anhThK3dfYqpfBcUgOUt X-Received: by 10.98.10.65 with SMTP id s62mr25827232pfi.234.1520506799810; Thu, 08 Mar 2018 02:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520506799; cv=none; d=google.com; s=arc-20160816; b=Ur17w1ZsYOGT3u3kMHNJdDTd3l+NIsKy0x6vwNn5gYrV0yjdrxA+hiXgf69uY87xsr c4jLY0u9MnHDVdl1LcIiA5N4XLq1FYpFysBPcNEBv5aBOkS21sGrSn9p7Et2rVCU1jE3 qH/9Pb4UlpYFT+X9BGs8lc61jp6HCK6Yj2suC+KWkrsSGnwYvPgxO8aTFMa6Mi99k1t+ Slii41r3V+C5t2e7efUOG2Iay7+3Ofq6FuRVaCG5Ga8ALMEDl8eaDDpBzv1OLp3loTha NEFqdFUvUgtQvVUzvseLhRiberdmXDcjwIcbkYnwf5eP2lBpOO4IBQRanbbcDW6zGPkP 7Zvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=QJepY5EdoonjZowhi6nTgZcbZuQxwWwg99XPuDQq7TM=; b=G+Hi8K1PjaDWob+aDtzkacZdxkvpKXrP3PgZllzHMOtUqjC84WEUT4ee5sBFhVWXyD 95Zu+/SxydWhBvjoI5mv1U+jIlEvnYNrZfLM/sAlkcS+/HGv3Y4TdOnISDmfdBE/U8tY zU9djCRSCy782OOZ+L/Wc3jKreeDrApTkcLTD9IvrmiPebUgMGUjSw/EKDsU7WrD/qCj NrN0zOtl58DkCbvwnoPSEfDKTAfSyJkowhJpgRFV0PuFQ8+abiOS5cqvp7vquKYknz21 zbTCvknPKHfCTcbi2nA1wHYJd/TpJsNskrSMoBtYG80rsYHvhWyQZu4Me8s0TH6g8fDZ GtRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=QQxtaAA4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x65si15748132pfj.354.2018.03.08.02.59.45; Thu, 08 Mar 2018 02:59:59 -0800 (PST) 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=@oracle.com header.s=corp-2017-10-26 header.b=QQxtaAA4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755772AbeCHK61 (ORCPT + 99 others); Thu, 8 Mar 2018 05:58:27 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46152 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751622AbeCHK6Z (ORCPT ); Thu, 8 Mar 2018 05:58:25 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w28AuUBx121471; Thu, 8 Mar 2018 10:58:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2017-10-26; bh=QJepY5EdoonjZowhi6nTgZcbZuQxwWwg99XPuDQq7TM=; b=QQxtaAA4D9MurZmglVyQEAsSnkOJkH9JgwuHvxZQS2WUfwpLK0JNqTxyUDg+1vC4G2ee uOyImt9X14Zr6FP+EF6fv6lV2VZYkHM/udu/4Ie33aNu3w14fnzGa1oBEF5tRsxMJ58K XmL51Z0Eu7mTtQ4dNQlL88dr63who7oLeCDbk6ziVL6QJQ4bFxgDPyiUW2GBtLywboKV CILiptD6OWKzfTA4K+CFWTWhMgiQA1BDxB+AbAf1Yvjv9CjHyHADx6x6j/yB+tNllhHi ufa0sg/89TjKLpPbtmjATgh1XQskloR2XADYf1R3njkMbjNtjvgeE109fpn8HqZgxPQP cQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2gk3ud00cm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Mar 2018 10:58:14 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w28AwDlZ001031 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Mar 2018 10:58:13 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w28AwCUk015741; Thu, 8 Mar 2018 10:58:12 GMT Received: from paddy.uk.oracle.com (/10.175.166.247) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Mar 2018 02:58:11 -0800 From: Joao Martins To: linux-kernel@vger.kernel.org Cc: Joao Martins , Boris Ostrovsky , Juergen Gross , "Rafael J. Wysocki" , Len Brown , Robert Moore , Erik Schmauss , xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, devel@acpica.org Subject: [PATCH v2] xen/acpi: upload _PSD info for non Dom0 CPUs too Date: Thu, 8 Mar 2018 10:57:51 +0000 Message-Id: <20180308105751.8176-1-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8825 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803080131 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All uploaded PM data from non-dom0 CPUs takes the info from vCPU 0 and changing only the acpi_id. For processors which P-state coordination type is HW_ALL (0xFD) it is OK to upload bogus P-state dependency information (_PSD), because Xen will ignore any cpufreq domains created for past CPUs. Albeit for platforms which expose coordination types as SW_ANY or SW_ALL, this will have some unintended side effects. Effectively, it will look at the P-state domain existence and *if it already exists* it will skip the acpi-cpufreq initialization and thus inherit the policy from the first CPU in the cpufreq domain. This will finally lead to the original cpu not changing target freq to P0 other than the first in the domain. Which will make turbo boost not getting enabled (e.g. for 'performance' governor) for all cpus. This patch fixes that, by also evaluating _PSD when enumerate all ACPI procesors and always uploading the correct info to Xen. We export acpi_processor_get_psd() to help with this purpose, but change signature to not assume the existence of a struct acpi_processor given that ACPI doesn't create an acpi_processor for non-dom0 CPUs. Signed-off-by: Joao Martins --- Changes since v1: (Comments from Boris) * Refactor acpi_processor_get_psd(), export and use that instead. * s/offline/non-dom0/ --- drivers/acpi/processor_perflib.c | 11 +++++------ drivers/xen/xen-acpi-processor.c | 37 +++++++++++++++++++++++++++++++++++++ include/acpi/processor.h | 2 ++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index c7cf48ad5cb9..a651ab3490d8 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -533,7 +533,7 @@ int acpi_processor_notify_smm(struct module *calling_module) EXPORT_SYMBOL(acpi_processor_notify_smm); -static int acpi_processor_get_psd(struct acpi_processor *pr) +int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain) { int result = 0; acpi_status status = AE_OK; @@ -541,9 +541,8 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"}; struct acpi_buffer state = {0, NULL}; union acpi_object *psd = NULL; - struct acpi_psd_package *pdomain; - status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer); + status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer); if (ACPI_FAILURE(status)) { return -ENODEV; } @@ -561,8 +560,6 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) goto end; } - pdomain = &(pr->performance->domain_info); - state.length = sizeof(struct acpi_psd_package); state.pointer = pdomain; @@ -597,6 +594,7 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) kfree(buffer.pointer); return result; } +EXPORT_SYMBOL(acpi_processor_get_psd); int acpi_processor_preregister_performance( struct acpi_processor_performance __percpu *performance) @@ -645,7 +643,8 @@ int acpi_processor_preregister_performance( pr->performance = per_cpu_ptr(performance, i); cpumask_set_cpu(i, pr->performance->shared_cpu_map); - if (acpi_processor_get_psd(pr)) { + pdomain = &(pr->performance->domain_info); + if (acpi_processor_get_psd(pr->handle, pdomain)) { retval = -EINVAL; continue; } diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c index 23e391d3ec01..e4f49d23a593 100644 --- a/drivers/xen/xen-acpi-processor.c +++ b/drivers/xen/xen-acpi-processor.c @@ -53,6 +53,10 @@ static unsigned long *acpi_ids_done; static unsigned long *acpi_id_present; /* And if there is an _CST definition (or a PBLK) for the ACPI IDs */ static unsigned long *acpi_id_cst_present; +/* And if there is an _PSD definition for the ACPI IDs */ +static unsigned long *acpi_id_psd_present; +/* Which ACPI P-State dependencies for a enumerated processor */ +static struct acpi_psd_package *acpi_psd; static int push_cxx_to_hypervisor(struct acpi_processor *_pr) { @@ -372,6 +376,15 @@ read_acpi_id(acpi_handle handle, u32 lvl, void *context, void **rv) pr_debug("ACPI CPU%u w/ PBLK:0x%lx\n", acpi_id, (unsigned long)pblk); + /* It has P-state dependencies */ + if (!acpi_processor_get_psd(handle, &acpi_psd[acpi_id])) { + __set_bit(acpi_id, acpi_id_psd_present); + + pr_debug("ACPI CPU%u w/ PST:coord_type = %llu domain = %llu\n", + acpi_id, acpi_psd[acpi_id].coord_type, + acpi_psd[acpi_id].domain); + } + status = acpi_evaluate_object(handle, "_CST", NULL, &buffer); if (ACPI_FAILURE(status)) { if (!pblk) @@ -405,6 +418,23 @@ static int check_acpi_ids(struct acpi_processor *pr_backup) return -ENOMEM; } + acpi_id_psd_present = kcalloc(BITS_TO_LONGS(nr_acpi_bits), + sizeof(unsigned long), GFP_KERNEL); + if (!acpi_id_psd_present) { + kfree(acpi_id_present); + kfree(acpi_id_cst_present); + return -ENOMEM; + } + + acpi_psd = kcalloc(nr_acpi_bits, sizeof(struct acpi_psd_package), + GFP_KERNEL); + if (!acpi_psd) { + kfree(acpi_id_present); + kfree(acpi_id_cst_present); + kfree(acpi_id_psd_present); + return -ENOMEM; + } + acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, read_acpi_id, NULL, NULL, NULL); @@ -417,6 +447,11 @@ static int check_acpi_ids(struct acpi_processor *pr_backup) pr_backup->acpi_id = i; /* Mask out C-states if there are no _CST or PBLK */ pr_backup->flags.power = test_bit(i, acpi_id_cst_present); + if (test_bit(i, acpi_id_psd_present)) { + memcpy(&pr_backup->performance->domain_info, + &acpi_psd[i], + sizeof(struct acpi_psd_package)); + } (void)upload_pm_data(pr_backup); } } @@ -566,6 +601,8 @@ static void __exit xen_acpi_processor_exit(void) kfree(acpi_ids_done); kfree(acpi_id_present); kfree(acpi_id_cst_present); + kfree(acpi_id_psd_present); + kfree(acpi_psd); for_each_possible_cpu(i) acpi_processor_unregister_performance(i); diff --git a/include/acpi/processor.h b/include/acpi/processor.h index d591bb77f592..40a916efd7c0 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -254,6 +254,8 @@ int acpi_processor_pstate_control(void); /* note: this locks both the calling module and the processor module if a _PPC object exists, rmmod is disallowed then */ int acpi_processor_notify_smm(struct module *calling_module); +int acpi_processor_get_psd(acpi_handle handle, + struct acpi_psd_package *pdomain); /* parsing the _P* objects. */ extern int acpi_processor_get_performance_info(struct acpi_processor *pr); -- 2.11.0