From patchwork Fri Jan 19 11:10:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13523629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9239C47DAF for ; Fri, 19 Jan 2024 11:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KX2HAk8toKuyc+3VT7yZc78CGZq7si1HAcJqJgrBuLM=; b=WL0hR2rHZ4ruWJ 8p2+2f8lHIInCamCK1HBzLwkPTI+Q4735lNnKzq0cbKDL4L8hq9bVvsLsSkz7UhOjd8Mbz8gRrmmd WdybbyhsV/8z9oWtz8Rt5R/wHNZPw6DvVkP/JKMb5JQa7QYqqxUg6VOfJXdqaRPH1z3a59FTCdVcn 0xW7nNR3yPLCUIh+3YO5HNKyMx39yQIAkUmw0w0rLMvIlgZBs7ygPK3wQWoZsEWrHtC9EPVH8z0Ga 9goNazKMm6gv0sA2XAbo3/apazHcoJUOEBaG6XAoM932gOQuCnFy+vR0vUOUitLnJIvhX35e9LaSd MZdbf8gne764ghQFdcEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQmlt-005BlJ-2C; Fri, 19 Jan 2024 11:10:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQmlp-005BkW-29 for linux-arm-kernel@lists.infradead.org; Fri, 19 Jan 2024 11:10:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91EB51042; Fri, 19 Jan 2024 03:11:22 -0800 (PST) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C06AE3F5A1; Fri, 19 Jan 2024 03:10:35 -0800 (PST) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Pierre Gondois , Cristian Marussi Subject: [PATCH] firmware: arm_scmi: Warn if domain frequency multiplier is 0 or rounded off Date: Fri, 19 Jan 2024 11:10:33 +0000 Message-ID: <20240119111033.3011853-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240119_031045_861319_8C8C5C01 X-CRM114-Status: GOOD ( 10.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When (sustained_freq_khz * 1000) is less than sustained_perf_level, the multiplier will be less than 1 and hence rounded down as 0. Similarly if it is not multiple of sustained_perf_level the dom_info->mult_factor will contain rounded down value and will end up impacting all the frequency calculations done using it. Add warning if and when the domain frequency multiplier is 0 or rounded down so that it gives a clue to get the firmware tables fixed. Suggested-by: Pierre Gondois Cc: Cristian Marussi Signed-off-by: Sudeep Holla Reviewed-by: Pierre Gondois Reviewed-by: Cristian Marussi --- drivers/firmware/arm_scmi/perf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 8ea2a7b3d35d..5a7358e89d6f 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -272,13 +272,21 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, le32_to_cpu(attr->sustained_perf_level); if (!dom_info->sustained_freq_khz || !dom_info->sustained_perf_level || - dom_info->level_indexing_mode) + dom_info->level_indexing_mode) { /* CPUFreq converts to kHz, hence default 1000 */ dom_info->mult_factor = 1000; - else + } else { dom_info->mult_factor = (dom_info->sustained_freq_khz * 1000UL) / dom_info->sustained_perf_level; + if ((dom_info->sustained_freq_khz * 1000UL) % + dom_info->sustained_perf_level) + pr_warn("mult_factor of domain %d is rounded\n", + dom_info->id); + } + if (!dom_info->mult_factor) + pr_warn("Incorrect sustained perf level or freq kHz\n"); + strscpy(dom_info->info.name, attr->name, SCMI_SHORT_NAME_MAX_SIZE); }