From patchwork Wed Feb 17 05:48:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 384191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC1AC433E6 for ; Wed, 17 Feb 2021 05:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82A4B64E2B for ; Wed, 17 Feb 2021 05:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbhBQFtt (ORCPT ); Wed, 17 Feb 2021 00:49:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbhBQFtq (ORCPT ); Wed, 17 Feb 2021 00:49:46 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCBA7C06174A for ; Tue, 16 Feb 2021 21:49:06 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d15so6848214plh.4 for ; Tue, 16 Feb 2021 21:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=emQXPuqsgdPSuXYNHs0efrSNIkqWhGSVKDhTTdUubPU=; b=UM0W1EROsKnnez2p5z5LslvgyTFdH1bXFYB4C/W/MIWfs5sSfuIwm/WsNV3THSjkC8 q08/e7CU00IjvLsa0Um4TNuhC2WI35K1v8PDQZoHRiWwA+SQV0hDiY61WRMG5swjNemb vOeuf8GHA0oSeQxmkCgWUXrH7Ow2l3icXf85rNkRJ2gvSk4YQT8IopwzMZBWEbiZnPas V5uampE4auaSsVj3MrM8bO5JzeQhsmJMCgNQuqcG+9gsMSxjap/t3SUBA3+VwonfJXzq 93E9Uq+D0fCW/2rauj5/kmF4o8Ois6HGwreVALPqYGj/fpvET1YZyP8nejLOsnEGBTDb 2MXw== 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:mime-version :content-transfer-encoding; bh=emQXPuqsgdPSuXYNHs0efrSNIkqWhGSVKDhTTdUubPU=; b=EWJwUN5Ppn8/g2oKIeG+Dy72mpXwOqFn6o/dyXu5fs3vrgua8MXsCGbeA1AAcsT9P2 QdFunwLrJSWNUW9w4dK4mEsSzipVJpS4UQxPLMmVehrn3ECpv1TrdMD9KY1yv089QY5R S3l6RSMiEtFS9XSC3P2w8lGWY4CUjtzMG94on8RlFlagc6xok7q8zHn4caUw6y16MmlG hLc0Z8myoGnCWhrTTIvYvDDVPyN1fKmP5LJ3IQDbLJKF9kz63GFyVSutQ5Hf8liIZP2b c/+Hk1XwAq+oEoMvM9kj+bDtobeSf+ashGFKo++YvNIFXPyB4AI+peZeFNaeem5Pxo2C XXOw== X-Gm-Message-State: AOAM531oH+UNBVJuLxYQLXOlGaP8ql0smieni9Ss6BSYqf1RCPRxG21K sNKjh+azunBg+Agi8L8rAk6ZWA== X-Google-Smtp-Source: ABdhPJzjKJf4FU20uEGFouwXC02tQlCg6j476G+w0mokmMJ5uCcC+odaB6FT6A4CpwEVlrVqbts2jw== X-Received: by 2002:a17:90a:ac09:: with SMTP id o9mr7946027pjq.191.1613540946178; Tue, 16 Feb 2021 21:49:06 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id j22sm803460pff.57.2021.02.16.21.49.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Feb 2021 21:49:05 -0800 (PST) From: Viresh Kumar To: Amit Daniel Kachhap , Daniel Lezcano , Viresh Kumar , Javi Merino , Zhang Rui , Amit Kucheria , "Peter Zijlstra (Intel)" , Ingo Molnar , Thara Gopinath Cc: Vincent Guittot , "v5 . 7+" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error Date: Wed, 17 Feb 2021 11:18:58 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org freq_qos_update_request() returns 1 if the effective constraint value has changed, 0 if the effective constraint value has not changed, or a negative error code on failures. The frequency constraints for CPUs can be set by different parts of the kernel. If the maximum frequency constraint set by other parts of the kernel are set at a lower value than the one corresponding to cooling state 0, then we will never be able to cool down the system as freq_qos_update_request() will keep on returning 0 and we will skip updating cpufreq_state and thermal pressure. Fix that by doing the updates even in the case where freq_qos_update_request() returns 0, as we have effectively set the constraint to a new value even if the consolidated value of the actual constraint is unchanged because of external factors. Cc: v5.7+ # v5.7+ Reported-by: Thara Gopinath Fixes: f12e4f66ab6a ("thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping") Signed-off-by: Viresh Kumar Reviewed-by: Lukasz Luba Tested-by: Lukasz Luba Reviewed-by: Rafael J. Wysocki Tested-by: Thara Gopinath --- Hi Guys, This needs to go in 5.12-rc. Thara, please give this a try and give your tested-by :). drivers/thermal/cpufreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index f5af2571f9b7..10af3341e5ea 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -485,7 +485,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, frequency = get_state_freq(cpufreq_cdev, state); ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency); - if (ret > 0) { + if (ret >= 0) { cpufreq_cdev->cpufreq_state = state; cpus = cpufreq_cdev->policy->cpus; max_capacity = arch_scale_cpu_capacity(cpumask_first(cpus));