From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id D6D1CA04C6;
	Thu, 14 Nov 2019 15:10:50 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 74D0B2BC8;
	Thu, 14 Nov 2019 15:10:49 +0100 (CET)
Received: from EUR03-DB5-obe.outbound.protection.outlook.com
 (mail-eopbgr40072.outbound.protection.outlook.com [40.107.4.72])
 by dpdk.org (Postfix) with ESMTP id E927DA69;
 Thu, 14 Nov 2019 15:10:47 +0100 (CET)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=QMAs/f5VvsheYHYjs4ZSlP3G2ofrmHCqch3/+QgFtCsDU+DBE8FczR46rbGuQgr392TH4nfPkRTBck7H2XsF+u0vfTM7ELNZY7rQ0yBXSLO7NaZiWxrajxteGiR07BOwGiTEDtA2HmxPWbcoSNx1r8qDGsbvcngVf+8vg6koUXjs3uMLPrshas1o02igyJeSVJ3Um+QWyfa/e+6mXv2huwDLJ5/zZWcNP2O83zCNhjRNWWIlQPdW6rMUB7tECVAkKEqgUV1Ia0ZEor9o4kvbdh05vU451DsULL825WvG04T/fu11gHr5Bf54zdgJcu5OxW3jT62U32spxdkYlW2vIg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=jWjJ5cKoeZCM84gadVI2wYH8gfnqYP2zH+JFdRai53E=;
 b=ffCcuI1bapPtjoiab1tm8w04hMQyRAyGvbnL/bqvJV/K9YGOWUqVWMqaCzf2ksa56FNIcvxpi3NU3thXxdEfoVgLnUNTVUmgwuTNYqf3yGyObbv2vy3y4JYiZaD+6lR5YY39pU9Er81Rf2S8oUeAsIXZm/EvDppEFFo3IP/DGIZzoFrN/ow3aMtbP0XEDQ1eJocmE9GBK9QdjF1wXE3FnMnhimP1kBxeKaqh3WNgPTY4w8nhdr+KT9XvgNiI7Za25IKo9fuS9bzusraU3jYEfLc1oTMvY1YXQXKdU8vcIEbvbP3uy/yQ39TyBWdOT9XfS04YOs7okZQqmLs6Wz3+bQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com;
 dmarc=pass (p=reject sp=none pct=100) action=none header.from=ericsson.com;
 dkim=none (message not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=jWjJ5cKoeZCM84gadVI2wYH8gfnqYP2zH+JFdRai53E=;
 b=IW7y7/7YfqS22Yp81Wbr1j1PYAkurnXRMXqTqqOwfmflwIsojPRQWkwfhK8rwPc/UjZ4WOpCzcR/m6YiQuSkDcq2UJRMFCAxbACRz8ZFRURfOGG+Bm8EivK7B2DoW0n20KsxogKOAsK7+A/8BTRu59RX119HVCO7tTe1/YW4B34=
Received: from DB6PR07CA0181.eurprd07.prod.outlook.com (2603:10a6:6:42::11) by
 HE1PR07MB3513.eurprd07.prod.outlook.com (2603:10a6:7:2c::32) with
 Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.2451.21; Thu, 14 Nov 2019 14:10:46 +0000
Received: from HE1EUR02FT041.eop-EUR02.prod.protection.outlook.com
 (2a01:111:f400:7e05::201) by DB6PR07CA0181.outlook.office365.com
 (2603:10a6:6:42::11) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.7 via Frontend
 Transport; Thu, 14 Nov 2019 14:10:46 +0000
Authentication-Results: spf=pass (sender IP is 192.176.1.74)
 smtp.mailfrom=ericsson.com; dpdk.org; dkim=none (message not signed)
 header.d=none;dpdk.org; dmarc=pass action=none header.from=ericsson.com;
Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates
 192.176.1.74 as permitted sender)
 receiver=protection.outlook.com; 
 client-ip=192.176.1.74; helo=oa.msg.ericsson.com;
Received: from oa.msg.ericsson.com (192.176.1.74) by
 HE1EUR02FT041.mail.protection.outlook.com (10.152.11.146) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id
 15.20.2451.23 via Frontend Transport; Thu, 14 Nov 2019 14:10:46 +0000
Received: from ESESBMB504.ericsson.se (153.88.183.171) by
 ESESBMR506.ericsson.se (153.88.183.202) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id
 15.1.1713.5; Thu, 14 Nov 2019 15:10:45 +0100
Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by
 smtp.internal.ericsson.com (153.88.183.187) with Microsoft SMTP Server id
 15.1.1713.5 via Frontend Transport; Thu, 14 Nov 2019 15:10:45 +0100
Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se
 [150.132.109.241])
 by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id
 xAEEAjvE001286; Thu, 14 Nov 2019 15:10:45 +0100 (CET)
From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>
To: <david.hunt@intel.com>
CC: <dev@dpdk.org>, <alan.carew@intel.com>, <liang.j.ma@intel.com>,
 =?UTF-8?q?Mattias=20R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>,
 <stable@dpdk.org>
Date: Thu, 14 Nov 2019 15:10:36 +0100
Message-ID: <20191114141036.31317-1-mattias.ronnblom@ericsson.com>
X-Mailer: git-send-email 2.17.1
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-EOPAttributedMessage: 0
X-Forefront-Antispam-Report: CIP:192.176.1.74; IPV:NLI; CTRY:SE; EFV:NLI;
 SFV:NSPM;
 SFS:(10009020)(4636009)(376002)(39860400002)(136003)(346002)(396003)(199004)(189003)(36756003)(246002)(50226002)(356004)(6666004)(8936002)(86362001)(106002)(23676004)(2906002)(8676002)(5820100001)(2870700001)(47776003)(26005)(316002)(50466002)(54906003)(186003)(478600001)(305945005)(70586007)(70206006)(7636002)(6916009)(2616005)(486006)(2351001)(476003)(66574012)(1076003)(126002)(5660300002)(4326008)(14444005)(956004)(336012);
 DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR07MB3513; H:oa.msg.ericsson.com; FPR:;
 SPF:Pass; LANG:en; PTR:office365.se.ericsson.net; A:1; MX:1; 
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: ea5d6d6b-c125-43ff-61ee-08d7690c7188
X-MS-TrafficTypeDiagnostic: HE1PR07MB3513:
X-Microsoft-Antispam-PRVS: <HE1PR07MB35134165D9E3507DBA71DE6EE1710@HE1PR07MB3513.eurprd07.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:7691;
X-Forefront-PRVS: 02213C82F8
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: cVKTHfv6DRNPlZpla6KRfxjJ5WspIUw55EJ+B36FniBNfHvff4KeEq57azlwJsS3215tFHwXyvw9WtecTsREEz409gYFT6gw/EWeJc4amT5wAviQ/Ras8hdjT5rKpxPcOCHVHaMzmOBfWk1ZygxXY5wIDAe34vrdRB0jWktP+szHs0rALK4p0OKu2I1JduEvn6zACn7AFjRn1bcCqDC2CdHERp57TYfyEDOThITfrclJOTUoPs+8cFUsEAlNbd6YGte295YUCY2PEen4TwNvL6OQhUShPh87j57flQMnFks/ENAls4EbNwUfbJIiBJAySH9KLTs51zciFLIjmvCc77+OeMDnUxggxPp8x7/hxVt8gor9z+7njVKF2O9kxMeId7iv5mUEOQoNTPrNvagf+9b3JD6/o7TygwFXGWBDA38dgS10z5EnVarh6JXuipP+
X-OriginatorOrg: ericsson.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2019 14:10:46.1161 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: ea5d6d6b-c125-43ff-61ee-08d7690c7188
X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74];
 Helo=[oa.msg.ericsson.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR07MB3513
Subject: [dpdk-dev] [PATCH] power: handle frequency increase with turbo
	disabled
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Calling pstate's or acpi's rte_power_freq_up() when on the highest
non-turbo frequency results in an error, if turbo is disabled. The
error is in the form of a return code and a RTE_LOG() entry on the ERR
level.

According to the API documentation, the frequency is scaled up
"according to the available frequencies". In case turbo is disabled,
that frequency is not available. This patch's rte_power_freq_up()
behaviour is also consistent with how rte_power_freq_max() is
implemented (i.e. the highest non-turbo frequency is set, in case
turbo is disabled).

Fixes: 445c6528b55f ("power: common interface for guest and host")
Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility")
Cc: stable@dpdk.org

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 lib/librte_power/power_acpi_cpufreq.c   | 3 ++-
 lib/librte_power/power_pstate_cpufreq.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c
index 7c386f891..6ea9c640e 100644
--- a/lib/librte_power/power_acpi_cpufreq.c
+++ b/lib/librte_power/power_acpi_cpufreq.c
@@ -515,7 +515,8 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id)
 	}
 
 	pi = &lcore_power_info[lcore_id];
-	if (pi->curr_idx == 0)
+	if (pi->curr_idx == 0 ||
+	    (pi->curr_idx == 1 && pi->turbo_available && !pi->turbo_enable))
 		return 0;
 
 	/* Frequencies in the array are from high to low. */
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index ecbcb3ac9..7bdc595cf 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -696,7 +696,8 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id)
 	}
 
 	pi = &lcore_power_info[lcore_id];
-	if (pi->curr_idx == 0)
+	if (pi->curr_idx == 0 ||
+	    (pi->curr_idx == 1 && pi->turbo_available && !pi->turbo_enable))
 		return 0;
 
 	/* Frequencies in the array are from high to low. */
-- 
2.17.1