From patchwork Tue Aug 15 01:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liao Chang X-Patchwork-Id: 135612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp161226vqo; Mon, 14 Aug 2023 19:37:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3/RmTlmRR08BrokR9OnCszo0KQ7vJSm0heKuAYQEbxP8woSP2UDYT4QglW8pLqcG2Dwx1 X-Received: by 2002:a17:907:6e0d:b0:988:8efc:54fa with SMTP id sd13-20020a1709076e0d00b009888efc54famr649273ejc.37.1692067034037; Mon, 14 Aug 2023 19:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692067034; cv=none; d=google.com; s=arc-20160816; b=OrsHjKhJy7sDNq8hZEkIBekvpJiHZ2ki3/fQwp33dchlEKSUMlywJkWo6PKvIvS7a4 +ZWohaOCnSvhPIhYSVfQuflV+w3E7wXEM2by1Y+wrr5B3mdEYSWW80lWZce03oclfTY6 4FivG6oMyl35lx1cXCRllP7lWJXoiNnRGE3Qrx4jX3Ds680KlFIliHfFSYWQVrixvEUL oPDJYlQEmcepl6+n+oro3q6Nc5P4Sc7YC2jzEfkVa7916dOsYZ8NXcOSXzvkxTh2nHBM 5zrZUA6e85ULKgEX6myujkJhI84b31HP+Mh9zCaqeD2UZPD6EEvrYdqO0oEyo59cUsV1 SHdg== 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; bh=uaBUlxiq8W1x8P27CeaNwm/QAPlunedkPJbWzZjw7KY=; fh=MkjW1f1ixasRiKuzf2PaYxsdrg4RoFahP+0zEUjLGHA=; b=k7Dijha+s499Dr74RQuuz0KMw3ec1+dyLRV9+bj4mEKZIDrJVo+6dWGsR942T76U1r 7Icnw6G5onVbjO+sHnuaiOKVmTZVjU7P+/lD7GkSwZ47HDOvpWNQOUiGCAqLGjpVGRmE ZZP/rAy4U4xjrcQKDHCpZIdpEpt6/6Sghf1dHckgTn5UM7aPBlLO0b3wn7Awnfv0zY/S 51GXufH6eThOKDKTDmr/4VIQCwq+fNRkkOo9F3zcLslOUwDJ21EpYRFrWwL0voEdPFdp kaFiTWyrFsOMxMiiLqFgWkEAwmzcgtutSp0W/mnmj8Cq7yscws4FNdeRYC3MFVoJ3Bz/ doAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot19-20020a170906ccd300b00992550ccfa2si8563162ejb.273.2023.08.14.19.36.44; Mon, 14 Aug 2023 19:37:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232523AbjHOBlG (ORCPT + 99 others); Mon, 14 Aug 2023 21:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231590AbjHOBkm (ORCPT ); Mon, 14 Aug 2023 21:40:42 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E692EE7; Mon, 14 Aug 2023 18:40:41 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RPv7s0MXlzrSNL; Tue, 15 Aug 2023 09:39:21 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 09:40:39 +0800 From: Liao Chang To: , CC: , Subject: [PATCH 2/2] cpufreq: cppc: cppc_cpufreq_get_rate() returns zero in all error cases. Date: Tue, 15 Aug 2023 09:40:17 +0800 Message-ID: <20230815014018.4132350-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774260881882235670 X-GMAIL-MSGID: 1774260881882235670 The cpufreq framework used to use the zero of return value to reflect the cppc_cpufreq_get_rate() had failed to get current frequecy and treat all positive integer to be succeed. Since cppc_get_perf_ctrs() returns a negative integer in error case, so it is better to convert the value to zero as the return value of cppc_cpufreq_get_rate(). Signed-off-by: Liao Chang --- drivers/cpufreq/cppc_cpufreq.c | 4 ++-- include/linux/cpufreq.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 796bc3e19f77..1cdef2da1ea4 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -854,13 +854,13 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t0); if (ret) - return ret; + return 0; udelay(2); /* 2usec delay between sampling */ ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t1); if (ret) - return ret; + return 0; delivered_perf = cppc_perf_from_fbctrs(cpu_data, &fb_ctrs_t0, &fb_ctrs_t1); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 172ff51c1b2a..99da27466b8f 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -370,7 +370,7 @@ struct cpufreq_driver { int (*target_intermediate)(struct cpufreq_policy *policy, unsigned int index); - /* should be defined, if possible */ + /* should be defined, if possible, return 0 on error */ unsigned int (*get)(unsigned int cpu); /* Called to update policy limits on firmware notifications. */