From patchwork Mon Jan 8 14:01:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 186021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1037019dyq; Mon, 8 Jan 2024 06:03:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeo65PmVVyGPx7skeAs+AlEtIlkIj3cBB/aTP4OTrYhgZDMFQMhZqpuyG3d1+z7fErTG0r X-Received: by 2002:a05:6512:e81:b0:50e:9570:b34b with SMTP id bi1-20020a0565120e8100b0050e9570b34bmr1335159lfb.90.1704722610993; Mon, 08 Jan 2024 06:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704722610; cv=none; d=google.com; s=arc-20160816; b=WuqPEMMh7iGUzZbGVUOaD3GxV0dV+4Z8x+YVzenLlIegj7LK5MysTfyhFfGhnpTTMC D/ge4mz5R4r32dWMHrAs5C9vcnfdSGtAbnf4dSlvqmLMYtPcVFe1vh/qvZON3bsdsKzw wMoktvD6kOQj//4S3urZcQKFxLOKn2ndmrtZChFMhxuxPJ9KJTj5NknDT1khYYAcvsZ7 HOSNtIEU8y6WJ761puWXyAePX0GwsW7KC1s8AmSVvoooiEFhSUbNka6Yzito9buLI0mP YHGgxpOZ/OEW4QTxpRi9Z1cCBgjmQHRwv3Ikc52OkB9hWsuVNZbNr0gYSMXt23gWi3Yt T6SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1wSjxuT/iAH9PZBT3uHnE13TeuGmyWFfZuSvtiQEhYQ=; fh=a706d1HlX/DtAJdq5shvP4nqykvzEfxTrnpKk22EfFw=; b=U/zFpaTLspmpCUYbIGzxeRf9c4SxIW1diwSvBOZsmV45GLGjuKGZKeWFm4STCWUav+ KYzWKP9MgFJfgK1dboW8aw4mJdk7bEFRHD0eRHuQrj40gZ/qVk9OJ2v7f1BogvT7qn/f cgwSUTCB6Q5Px1HkHaxC3JuiftX3JUDFWno24vdr/gMT6jiyPpRlqm+dblt8V0xGjLPv kW1bKOaTwE7YmKbiRGEbDUMm/cwzBEobqDmKSw4diXyW4i1scQhycTPz/8kxnjUQUXKg gOQDWKjKXG9uI7xF/MyVz+MuPjq4nutRwbddSLHyX+BuDK3BpGJN4DXcTkBqW9pgXthd hpPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=i9kxvcAv; spf=pass (google.com: domain of linux-kernel+bounces-19666-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19666-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l11-20020a17090615cb00b00a2362fdcd72si3054241ejd.708.2024.01.08.06.03.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 06:03:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19666-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=i9kxvcAv; spf=pass (google.com: domain of linux-kernel+bounces-19666-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19666-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6CC1C1F23289 for ; Mon, 8 Jan 2024 14:03:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2600447A43; Mon, 8 Jan 2024 14:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="i9kxvcAv" X-Original-To: linux-kernel@vger.kernel.org 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 2C8994654D; Mon, 8 Jan 2024 14:02:28 +0000 (UTC) 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 408BgcYI015255; Mon, 8 Jan 2024 14:02:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=1wSjxuT/iAH9PZBT3uHn E13TeuGmyWFfZuSvtiQEhYQ=; b=i9kxvcAvG0mTt10sh3+3RTU06ZiRjCxLs5mu 9Bc+lN81S+Xcgx/SSPwJaPBfsPX0AujGESc8y8AY5YipYHk00y0yKXAu/yTHmO+S imBV/kIc4ZlezT74zW3PbAYlbVWmQsS7HlvyxMm0qQJeutwgiKsNrZr08EI0rFfv lnCPebOTqcMU+XmgM3MrLB6fly2saH2xXAsDpIt6ohPcEvRAGEYtXZ7L8fgqBZhc HjcYNCJe2+HgatIfi5SGFunbGk3bNyz9jdkCylAKHR10kLVtLLE9RrjXlZk2olKj NIU/DfRtT6V+34GyjpjWq6YQ9z4jhnknnXUWO1a0WZQ78wUD5A== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vg8n09738-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 14:02:19 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 408E1jql020970 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 8 Jan 2024 14:01:45 GMT Received: from blr-ubuntu-253.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; Mon, 8 Jan 2024 06:01:42 -0800 From: Sibi Sankar To: , , , CC: , , , , , Sibi Sankar Subject: [PATCH 2/3] firmware: arm_scmi: Add perf_opp_xlate interface Date: Mon, 8 Jan 2024 19:31:17 +0530 Message-ID: <20240108140118.1596-3-quic_sibis@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108140118.1596-1-quic_sibis@quicinc.com> References: <20240108140118.1596-1-quic_sibis@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-GUID: R5D3casVtRTZy-PqIhmC_qx1iFnJMUVd X-Proofpoint-ORIG-GUID: R5D3casVtRTZy-PqIhmC_qx1iFnJMUVd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401080120 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787531216505387699 X-GMAIL-MSGID: 1787531216505387699 Add a new perf_opp_xlate interface to the existing perf_ops to translate a given perf index to frequency. This can be used by the cpufreq driver and framework to determine the throttled frequency from a given perf index and apply HW pressure accordingly. Signed-off-by: Sibi Sankar --- drivers/firmware/arm_scmi/perf.c | 21 +++++++++++++++++++++ include/linux/scmi_protocol.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index c167bb5e3607..f26390924e1c 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -964,6 +964,26 @@ static int scmi_notify_support(const struct scmi_protocol_handle *ph, u32 domain return 0; } +static int scmi_perf_opp_xlate(const struct scmi_protocol_handle *ph, u32 domain, + int idx, unsigned long *freq) +{ + struct perf_dom_info *dom; + + dom = scmi_perf_domain_lookup(ph, domain); + if (IS_ERR(dom)) + return PTR_ERR(dom); + + if (idx >= dom->opp_count) + return -ERANGE; + + if (!dom->level_indexing_mode) + *freq = dom->opp[idx].perf * dom->mult_factor; + else + *freq = dom->opp[idx].indicative_freq * dom->mult_factor; + + return 0; +} + static const struct scmi_perf_proto_ops perf_proto_ops = { .num_domains_get = scmi_perf_num_domains_get, .info_get = scmi_perf_info_get, @@ -979,6 +999,7 @@ static const struct scmi_perf_proto_ops perf_proto_ops = { .fast_switch_possible = scmi_fast_switch_possible, .power_scale_get = scmi_power_scale_get, .perf_notify_support = scmi_notify_support, + .perf_opp_xlate = scmi_perf_opp_xlate, }; static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index b0947d004826..9c285ae89848 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -145,6 +145,7 @@ struct scmi_perf_notify_info { * @power_scale_mw_get: indicates if the power values provided are in milliWatts * or in some other (abstract) scale * @perf_notify_support: indicates if limit and level change notification is supported + * @perf_opp_xlate: translates the given perf index to frequency in Hz */ struct scmi_perf_proto_ops { int (*num_domains_get)(const struct scmi_protocol_handle *ph); @@ -173,6 +174,8 @@ struct scmi_perf_proto_ops { enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph); int (*perf_notify_support)(const struct scmi_protocol_handle *ph, u32 domain, struct scmi_perf_notify_info *info); + int (*perf_opp_xlate)(const struct scmi_protocol_handle *ph, u32 domain, + int idx, unsigned long *freq); }; /**