Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp461050lqc; Fri, 8 Mar 2024 02:39:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUwJDr0J8zLH1PgsWVkAkPEB/YPv3Z2SwEz0bgAHiEids9fMtSGxxGYfwQZ+p9M9KxW0UKnnzlslTGTmonRLVUhuxQAuqlsjY5Q7ZXO4Q== X-Google-Smtp-Source: AGHT+IGKyniR+Zu9mD9U5M00RrfwpQ6+ve54BlwcIatQnnx+Wjd7RJoYM4QWXhOGlsb/p1x6OdOu X-Received: by 2002:a17:90a:9a8f:b0:29b:78fb:6183 with SMTP id e15-20020a17090a9a8f00b0029b78fb6183mr6972931pjp.8.1709894375357; Fri, 08 Mar 2024 02:39:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709894375; cv=pass; d=google.com; s=arc-20160816; b=A0GhMbKbZYBpkug11pAX9WM216kqA+4pDZsT8Kh94Ztdl3kFYYhp5oewt82IO3dbuM 7uD6i3UQ+gZv4PSXVV+iUuOxmdTO57ac121Q+/VbfSt4F4KboTWWCImiTOdMpvFVeJRU PFaS9mlBLCSfTDLXagXbswJE+F2n1JKhlJTi4Hb7KOsKtAacbKf+YUyVZislMIDEgZV4 oUJjp+uh8nWPo2afaF7GDE2WqhtL0B0BPX9RYRw2NROzNuw5HeoXHUMvZwBXs5oqjGQv DZtVNsUftoRIHq69tCpx95oq5+TSeCmoY3+g7z1NRz1cEtCfkIEKotL0bCVzIpa3qiRI VMcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=fOaAGlorcscPHZrP5cXo/S0ZQgVM5JGxqbGP2Yy7Gak=; fh=E+lnJhlIUp70VQJf7sOkzlUdZ0QdBAMtGxT5nBqDjkg=; b=WkHUIJe7J0ZjstbHekGE0IiJO3n2WCpxqpUYZwLJtRTfnkJQ8aw9cXL+VPHZkW3biz WfOefbMsPf8n8jtlYbO7Vwr3nFzJZaMfruHPxa0lCThtgB9BZxgLJuWYiImiNfypXJYU Cljrv+zVife5BmluKSa/3Vi0C22e03CSVyEA9Ln2HyRwZXVagUm1YATh5u47bwVyp8zF 2iTrCoajh0HQx3Cq2wumwbsq7kX8PuwUe9MfN7K8zvSJBPBOFGM95AQS2PPvVMos99N0 f4wh2IUg7l6kBeyg4X+cIpX8SKL2lOJnpN2C1nHo/V4ruI7rgY4CeEVo5ljxWC1TWm60 mWvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dMmPAl+l; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-96856-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t2-20020a17090a1c8200b00299303a935fsi3444469pjt.42.2024.03.08.02.39.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 02:39:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96856-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dMmPAl+l; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-96856-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0C9A92840FA for ; Fri, 8 Mar 2024 10:39:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26A5D5646D; Fri, 8 Mar 2024 10:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="dMmPAl+l" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E80FDF5B; Fri, 8 Mar 2024 10:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709894273; cv=none; b=WLv6VdHoP8mnqykjZjOWIsUHcsiuYyUHuyYweb/H6EJ5grx4H1DmL9Tn507Xw95u9Um6c+/pfeoPnP4e85l25+wzPvCUEaEp6R5tZYefYUALV49HB1h+F+/PTtmhFgPoFDL5LxPn1PJZ52+aqKTMXXC2BkLGRuJggWuiLHvSA78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709894273; c=relaxed/simple; bh=2OOYinqQguwiPejd5+g4NRefKtsTDeVSgMjb59dLdhs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=hRwrTwFAG3HIWILx8jDw+A40p4CQeUIXXo9DUbPM3DddpexrNX233d2y7fUINNhYF8ikAFtILPaRCfHD/B7yRJrvrFDQ9aogAVh80E9ASGNT6PpSPS45pJSzQUGFrhmdvfQAw38dg+v5nItirzoyr/Sa/qBZSI7mUZwGjJ8A98c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=dMmPAl+l; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4288TreX031056; Fri, 8 Mar 2024 10:37:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=fOaAGlo rcscPHZrP5cXo/S0ZQgVM5JGxqbGP2Yy7Gak=; b=dMmPAl+l/lxWYxkNXKdPa/u DsMS1qNQ/e3z5A+qsEcjQAKxD/AF2Qi5EGs8TqhUZUocO9IYZCCKfCI/rZxeDPVG kRQV/eSMFPij0zJcNiW81syi17O7VW2WXSYPx/9Bp0FSjFMelS+ASMuye+PT7obP JaQh5esYtbLBgKPr1xf+syInCKHrOOhN7qWiCJLrzgQIyB/ZRYVzl1+Y+atA0YxF TZPOMqdqprHBk3xMmHjUrli8DNA0VtL7PknjMInVPnNrQXrLgGQCtOXY34M0PnOi 5614jupznHc5b/YLJwFKHoRZ2N322hrwjqJvTiz/wwDBtPvcyI3uz3zPibJwL3w= = Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wqn8s1fnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Mar 2024 10:36:51 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 428AaoWT005454 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 8 Mar 2024 10:36:50 GMT Received: from hu-sibis-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 8 Mar 2024 02:36:45 -0800 From: Sibi Sankar To: , , , , CC: , , , , , , , Sibi Sankar Subject: [PATCH V2] cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw Date: Fri, 8 Mar 2024 16:06:30 +0530 Message-ID: <20240308103630.383371-1-quic_sibis@quicinc.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 7YvgX_hv4skigzOnySS8XvpEfAVqega5 X-Proofpoint-GUID: 7YvgX_hv4skigzOnySS8XvpEfAVqega5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_07,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 impostorscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403080084 In the existing code, per-policy flags doesn't have any impact i.e. if cpufreq_driver boost is enabled and one or more of the per-policy boost is disabled, the cpufreq driver will behave as if boost is enabled. Fix this by incorporating per-policy boost flag in the policy->max calculus used in cpufreq_frequency_table_cpuinfo and setting the default per-policy boost to mirror the cpufreq_driver boost flag. Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost") Reported-by: Dietmar Eggemann Signed-off-by: Sibi Sankar --- v2: * Enable per-policy boost flag in the core instead. [Viresh] * Add more details regarding the bug. [Viresh] * Drop cover-letter and patch 2. Logs reported-by Dietmar Eggemann: https://lore.kernel.org/lkml/265e5f2c-9b45-420f-89b1-44369aeb8418@arm.com/ drivers/cpufreq/cpufreq.c | 19 +++++++++++++------ drivers/cpufreq/freq_table.c | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f6f8d7f450e7..c04b2ba2993a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -653,14 +653,16 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy, if (policy->boost_enabled == enable) return count; + policy->boost_enabled = enable; + cpus_read_lock(); ret = cpufreq_driver->set_boost(policy, enable); cpus_read_unlock(); - if (ret) + if (ret) { + policy->boost_enabled = !policy->boost_enabled; return ret; - - policy->boost_enabled = enable; + } return count; } @@ -1428,6 +1430,10 @@ static int cpufreq_online(unsigned int cpu) goto out_free_policy; } + /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ + if (cpufreq_driver->boost_enabled) + policy->boost_enabled = policy_has_boost_freq(policy) ? true : false; + /* * The initialization has succeeded and the policy is online. * If there is a problem with its frequency table, take it @@ -2769,11 +2775,12 @@ int cpufreq_boost_trigger_state(int state) cpus_read_lock(); for_each_active_policy(policy) { + policy->boost_enabled = state; ret = cpufreq_driver->set_boost(policy, state); - if (ret) + if (ret) { + policy->boost_enabled = !policy->boost_enabled; goto err_reset_state; - - policy->boost_enabled = state; + } } cpus_read_unlock(); diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index c4d4643b6ca6..c17dc51a5a02 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, cpufreq_for_each_valid_entry(pos, table) { freq = pos->frequency; - if (!cpufreq_boost_enabled() + if ((!cpufreq_boost_enabled() || !policy->boost_enabled) && (pos->flags & CPUFREQ_BOOST_FREQ)) continue; -- 2.34.1