From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C57A1A04DD for ; Wed, 28 Oct 2020 11:52:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BDAD9C9F6; Wed, 28 Oct 2020 11:52:11 +0100 (CET) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by dpdk.org (Postfix) with ESMTP id B3AD9C9F6 for ; Wed, 28 Oct 2020 11:52:09 +0100 (CET) Received: by mail-wm1-f50.google.com with SMTP id a72so4085907wme.5 for ; Wed, 28 Oct 2020 03:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OZtSdtPtyDTW5qcTmApidsQQmSstN/8Hz47iJ/brAvo=; b=GuixoUTDrjqOIWAw3WIKUrxhcbCuQFMT0Xma04x+PLxQhWUxT2ubnT7yTQqgYME9km +ENPlkCA1FL1FSufD+tI/Fe/hwF3TGno3R7eLPi+ej5hq8rIXpKjMkCyA9FsoxImKohf LBxv8HszxxggS4Vwj25oQAjRnSxxINpikZMYY6yShtkk5oCqwxlC4nlqE1c54Lgu7Udd z16PHdPM4UF/TEkRNU7fQJ+dl/Uuc/Ax4kbDsCUq19LAyRq2TPtL+IpXkGkp0Xm7IsDt buSmlxFLeqZ6+Xfh/ozMzWjO9Q3QuZnD/VxNryv0hp2J62T5p6JTKrkZjt+9uL2ZWItG ITRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OZtSdtPtyDTW5qcTmApidsQQmSstN/8Hz47iJ/brAvo=; b=OBfdKkgsMi7X5RhQGj5TX//22sSe+DD0GVLv4pD/r4AiiUWwR7gN/EPkoYvEAEsFF+ 5Xm5krYJaiaKnUX8sZY15SGwYizN8zFxFvMnDW8og3Gt3IfyehkvAc9bkdroRCjuKzpn 5FnWL0Tc6XmC9VNL4NEasBzuFOg4Pi/Hyh6rFQ+edEB51g1zl2bFJDO8aMWR6KbAl4jW X0J2C4HsBLaymu4VIkd+5FY+f8acVqOSw8mU2iccZf3i6fjLI8NoYydyBQFvFYOsT+Ft 4K4V9C2LKTK7AZa4UuX4F7t9iN2X+2YJOOGMwP3qkLJnok6mBfFywQf2SPMSv4NH6qeB vlUQ== X-Gm-Message-State: AOAM5315ohlNfyVYHTgKMEvg9KNVL/bjV4ahDl7nq80129P598CJ5MmS 6M+pCgiI2jMULa89pKSAirc= X-Google-Smtp-Source: ABdhPJzDHPZK+mzxbtmXtFpPvkq29CG1RZv+E4D/iKjesJTY7vYQ0kjsCjZP+AL/abRQOlJH9jjn9w== X-Received: by 2002:a1c:ddc4:: with SMTP id u187mr7419759wmg.156.1603882328419; Wed, 28 Oct 2020 03:52:08 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id x64sm6011187wmg.33.2020.10.28.03.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:52:07 -0700 (PDT) From: luca.boccassi@gmail.com To: Reshma Pattan Cc: Liang Ma , dpdk stable Date: Wed, 28 Oct 2020 10:44:32 +0000 Message-Id: <20201028104606.3504127-113-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'power: fix current frequency index' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/30/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 6e2760a68cd64d05b6cc82185b7ec00d3fb5b9d9 Mon Sep 17 00:00:00 2001 From: Reshma Pattan Date: Wed, 29 Jul 2020 14:58:53 +0100 Subject: [PATCH] power: fix current frequency index [ upstream commit a3f9cca718d75f2d60f5895be94f0f14e5fc4865 ] During power initialization the pstate cpufreq api is not setting the initial curr_idx of pstate_power_info to corresponding current frequency index. Without this the idx is always 0, which is causing the below check to pass and returns without setting the initial min/max frequency to system max frequency and this leads to incorrect frequency settings when power_pstate_cpufreq_set_freq() is called in the apps. set_freq_internal(struct pstate_power_info *pi, uint32_t idx) { ... /* Check if it is the same as current */ if (idx == pi->curr_idx) return 0; ... } scenario 1: If system has starting scaling min/max: 1000/1000, and want to set this to 2200/2200, the max frequency gets updated but not min. scenario 2: If system has starting scaling min/max: 2200/1000, and want to set to 2200/2200, the max, min frequency was not updated. Since no change in max that should be ok, but min was also ignored, which will be fixed now with the new changes. Fixes: e6c6dc0f ("power: add p-state driver compatibility") Signed-off-by: Reshma Pattan Reviewed-by: Liang Ma --- lib/librte_power/power_pstate_cpufreq.c | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 2d8a9499dc..fa16b44146 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -52,6 +52,9 @@ } \ } while (0) +/* macros used for rounding frequency to nearest 100000 */ +#define FREQ_ROUNDING_DELTA 50000 +#define ROUND_FREQ_TO_N_100000 100000 #define POWER_CONVERT_TO_DECIMAL 10 #define BUS_FREQ 100000 @@ -531,6 +534,57 @@ out: return ret; } +static int +power_get_cur_idx(struct pstate_power_info *pi) +{ + FILE *f_cur; + int ret = -1; + char *p_cur; + char buf_cur[BUFSIZ]; + char fullpath_cur[PATH_MAX]; + char *s_cur; + uint32_t sys_cur_freq = 0; + unsigned int i; + + snprintf(fullpath_cur, sizeof(fullpath_cur), + POWER_SYSFILE_CUR_FREQ, + pi->lcore_id); + f_cur = fopen(fullpath_cur, "r"); + FOPEN_OR_ERR_RET(f_cur, ret); + + /* initialize the cur_idx to matching current frequency freq index */ + s_cur = fgets(buf_cur, sizeof(buf_cur), f_cur); + FOPS_OR_NULL_GOTO(s_cur, fail); + + p_cur = strchr(buf_cur, '\n'); + if (p_cur != NULL) + *p_cur = 0; + sys_cur_freq = strtoul(buf_cur, &p_cur, POWER_CONVERT_TO_DECIMAL); + + /* convert the frequency to nearest 100000 value + * Ex: if sys_cur_freq=1396789 then freq_conv=1400000 + * Ex: if sys_cur_freq=800030 then freq_conv=800000 + * Ex: if sys_cur_freq=800030 then freq_conv=800000 + */ + unsigned int freq_conv = 0; + freq_conv = (sys_cur_freq + FREQ_ROUNDING_DELTA) + / ROUND_FREQ_TO_N_100000; + freq_conv = freq_conv * ROUND_FREQ_TO_N_100000; + + for (i = 0; i < pi->nb_freqs; i++) { + if (freq_conv == pi->freqs[i]) { + pi->curr_idx = i; + break; + } + } + + fclose(f_cur); + return 0; +fail: + fclose(f_cur); + return ret; +} + int power_pstate_cpufreq_init(unsigned int lcore_id) { @@ -571,6 +625,11 @@ power_pstate_cpufreq_init(unsigned int lcore_id) goto fail; } + if (power_get_cur_idx(pi) < 0) { + RTE_LOG(ERR, POWER, "Cannot get current frequency " + "index of lcore %u\n", lcore_id); + goto fail; + } /* Set freq to max by default */ if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:15.268005980 +0000 +++ 0113-power-fix-current-frequency-index.patch 2020-10-28 10:35:11.668832438 +0000 @@ -1,8 +1,10 @@ -From a3f9cca718d75f2d60f5895be94f0f14e5fc4865 Mon Sep 17 00:00:00 2001 +From 6e2760a68cd64d05b6cc82185b7ec00d3fb5b9d9 Mon Sep 17 00:00:00 2001 From: Reshma Pattan Date: Wed, 29 Jul 2020 14:58:53 +0100 Subject: [PATCH] power: fix current frequency index +[ upstream commit a3f9cca718d75f2d60f5895be94f0f14e5fc4865 ] + During power initialization the pstate cpufreq api is not setting the initial curr_idx of pstate_power_info to corresponding current frequency index. @@ -34,7 +36,6 @@ now with the new changes. Fixes: e6c6dc0f ("power: add p-state driver compatibility") -Cc: stable@dpdk.org Signed-off-by: Reshma Pattan Reviewed-by: Liang Ma @@ -43,10 +44,10 @@ 1 file changed, 59 insertions(+) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c -index e3126d3754..edf6328e5f 100644 +index 2d8a9499dc..fa16b44146 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c -@@ -51,6 +51,9 @@ +@@ -52,6 +52,9 @@ } \ } while (0) @@ -112,9 +113,9 @@ +} + int - power_pstate_cpufreq_check_supported(void) + power_pstate_cpufreq_init(unsigned int lcore_id) { -@@ -586,6 +640,11 @@ power_pstate_cpufreq_init(unsigned int lcore_id) +@@ -571,6 +625,11 @@ power_pstate_cpufreq_init(unsigned int lcore_id) goto fail; }