Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6119023pxb; Tue, 16 Feb 2021 17:11:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYI4bVgX9f3LTO9V0RVzivHQ04tU40nGOGpMuPupNdxaJMoXcIwmTHIr2yEsMiutfjZ7SU X-Received: by 2002:a17:906:444d:: with SMTP id i13mr22811385ejp.170.1613524286978; Tue, 16 Feb 2021 17:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613524286; cv=none; d=google.com; s=arc-20160816; b=OExrVa5/jnVegEU2YQ2SMFkhLiKXZXAHo3bPX2J6Ux0KwBKnUts4ThU7w7ESTH4K/P zF/6kVRcvcC4eGutV1JMLR7QSqOrMhUMSBhq6SpXKzVplNj/nC9P71SfJoui8nmDxiJk inNIabR/SMyLwj7XbPxi+32Iiwplp6DEqYFIK5zVmYHDtZJM+cRCCtnPMzKvqVDl4O/W Fr3qLE0ad1I1IvzxaAMjUqxL27AKFj8a7ot1sTpxD3DBVZxykDnSJsuC6Stp5H2huBGq vq7RQxgKeEls0oZFydp0ZLu5Dirs7zmBf1Ko0AhpDcKbBMRL8VZV2ySkbOzN5JiJyK81 I57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7pgxfLYtB4b4dqlNRuCkDcBYdwrqTW32/gAXyaE8lXM=; b=AhSlI8ZNT3WSdWmtKj63omqUYdcK3xAQBgApjRTyLSwC8653OcBceTVTYzlblHxKWH N98dgzfpjdgMUAqSrlM+A2d2hFeiKYRq3sDErgMpPjGAmilTkbiTZDlN+hP6e6IRyuLt wSpiDcEnAPWBAWgVtXMXOS8c1fxF0PbVZgMe6htCV0oPOsFBZIGcuIE20wEE1Oxk+mB8 TaeF9KF3E6dURjJFeMoEevTBBf7jDppNiP+HDNt/Po2YifvjQr4VhE9cJMT2YouMbAkt KnACiCvb04b5x0kR0iCnHCgPGv8oqhxzbqGxHQvWEUuV4xbiYrHxu1SJaB2LQjFtXEeX yjvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i2C77GrE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si425389ejb.368.2021.02.16.17.11.03; Tue, 16 Feb 2021 17:11:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i2C77GrE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbhBQAA5 (ORCPT + 99 others); Tue, 16 Feb 2021 19:00:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbhBQAAz (ORCPT ); Tue, 16 Feb 2021 19:00:55 -0500 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F903C061756 for ; Tue, 16 Feb 2021 16:00:15 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id t62so11241513qke.7 for ; Tue, 16 Feb 2021 16:00:15 -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=7pgxfLYtB4b4dqlNRuCkDcBYdwrqTW32/gAXyaE8lXM=; b=i2C77GrEYhmSVsDSIlvbowp1+1tIWUO2pPflB6TfUO8/UZuZTeEOCS0o0LAV6JxHUz JO6YOis2IlNULxuxeACG5HlZwd0bXumgAgC2u7sFkVwlOeCuaofn+dBSRezXRLb1iPRf gvvXlFUs75h56CtGgoG2PHUdJOZmPvfPUKQyB5Qhp2d6Bit6nJsjSjWa8fxkA4t81ZEO oJJgV0rM+midM4o+RxU57dzfgmjSeNEumY5/TskkrCz4pGTCW1suJUN+JAH3KbbRnkai dMazmQgMxWmwRUwtKLvIt0tN4EsQP0ZiKLzAIiirrNre3dQKNBxCxZozHYRJ0CuMFJhc Hm5g== 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=7pgxfLYtB4b4dqlNRuCkDcBYdwrqTW32/gAXyaE8lXM=; b=iX6NyNvFYcuA6aqlJp5JEfr+z2ZUzhaX0cZQ3toADa5HoRcXeBtckaqiaWlaC5cE4D Y5z23EETMjHZ6iRvUgkQuaxVgtSWgSQHETqP1Z0QKGWeWY8xDSfD/nSf06GEN+U1xLhz 60OtqADidFv+241Fy9llKrFAiUy5f2Xj0IjNK4Pn/wYaEYKLqLaQ9ZAQOLjN76a9ddlw G+vSjmcoA307qnD48kLNG8jnfDDSK1ogWK2RK6S12rQ2TcRB4vRRT6oOI2Tq4nSd4rdN 4AVNc4SXybQr5p/QRSPBTnfagH1mjE31iY9rDfyKSqLk6e7OmUxnGwmW4YlryOxegiU2 XkVg== X-Gm-Message-State: AOAM532jpoGhE9J6giSRnSSm6EwbroQugpQyE+Em86irm7m6rQCyBy73 acKDlo688oMtJq/I4MdBfiEcPw== X-Received: by 2002:a05:620a:1435:: with SMTP id k21mr17977868qkj.289.1613520014253; Tue, 16 Feb 2021 16:00:14 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id g21sm94091qtv.68.2021.02.16.16.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 16:00:13 -0800 (PST) From: Thara Gopinath To: rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: bjorn.andersson@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] cpufreq: exclude boost frequencies from valid count if not enabled Date: Tue, 16 Feb 2021 19:00:13 -0500 Message-Id: <20210217000013.4063289-1-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a fix for a regression observed on db845 platforms with 5.7-rc11 kernel. On these platforms running stress tests with 5.11-rc7 kernel causes big cpus to overheat and ultimately shutdown the system due to hitting critical temperature (thermal throttling does not happen and cur_state of cpufreq cooling device for big cpus remain stuck at 0 or max frequency). This platform has boost opp defined for big cpus but boost mode itself is disabled in the cpufreq driver. Hence the initial max frequency request from cpufreq cooling device(cur_state) for big cpus is for boost frequency(2803200) where as initial max frequency request from cpufreq driver itself is for the highest non boost frequency (2649600). qos framework collates these two requests and puts the max frequency of big cpus to 2649600 which the thermal framework is unaware of. Now during an over heat event, with step-wise policy governor, thermal framework tries to throttle the cpu and places a restriction on max frequency of the cpu to cur_state - 1 which in this case 2649600. qos framework in turn tells the cpufreq cooling device that max frequency of the cpu is already at 2649600 and the cooling device driver returns doing nothing(cur_state of the cooling device remains unchanged). Thus thermal remains stuck in a loop and never manages to actually throttle the cpu frequency. This ultimately leads to system shutdown in case of a thermal overheat event on big cpus. There are multiple possible fixes for this issue. Fundamentally,it is wrong for cpufreq driver and cpufreq cooling device driver to show different maximum possible state/frequency for a cpu. Hence fix this issue by ensuring that the max state of cpufreq cooling device is in sync with the maximum frequency of the cpu in cpufreq driver. cpufreq_table_count_valid_entries is used to retrieve max level/max frequency of a cpu by cpufreq_cooling_device during initialization. Add check in this api to ignore boost frequencies if boost mode is not enabled thus keeping the max state of cpufreq cooling device in sync with the maximum frequency of the cpu in cpufreq driver. cpufreq_frequency_table_cpuinfo that calculates the maximum frequency of a cpu for cpufreq driver already has such a check in place. Signed-off-by: Thara Gopinath --- include/linux/cpufreq.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9c8b7437b6cd..fe52892e0812 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -1006,8 +1006,11 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy if (unlikely(!policy->freq_table)) return 0; - cpufreq_for_each_valid_entry(pos, policy->freq_table) + cpufreq_for_each_valid_entry(pos, policy->freq_table) { + if (!cpufreq_boost_enabled() && (pos->flags & CPUFREQ_BOOST_FREQ)) + continue; count++; + } return count; } -- 2.25.1