Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2422866rdb; Mon, 12 Feb 2024 04:38:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXs+la4EIf0WzWiB+MWodJj0mosTp54bp9mn4FAM4m5/ef8Cre50I5lLmczvlqNBBflQOxmyz3N7JJW8ucNAl5XS6AP/eWNCfA39Ir0oQ== X-Google-Smtp-Source: AGHT+IHZ6ZEprM6xOFygg+w9nNzPKIM+d29o1LrBqE+48IfC1fK0RO587vHvGDyztLj+VGG0kcIs X-Received: by 2002:a05:6a21:3941:b0:19c:64a5:2162 with SMTP id ac1-20020a056a21394100b0019c64a52162mr9021406pzc.20.1707741504226; Mon, 12 Feb 2024 04:38:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741504; cv=pass; d=google.com; s=arc-20160816; b=MEtiFLC2+yq3azedfc4iUY1gDPVD8vpFcGL17Rg0UCT8BCumQcFQaGIQhW0fMgw8VT 334ss8Ua1srpWk+88U4Fab67k69zZ2OheBeyBNwFqL036dwnizmppSf0jsImKmOs5L9X HVmPbiBTJ7GZZgtFPztc/Dyh1qn6jXaPiOMWPLV6m5nw5E2p3JArdRZkR4ugjJKMbFTF ZtiZP0y/UKEEh49gFS47wxMKTSBdDL1pM9bypY+V9n1BR+raz1eRxTnkk981/TnEU5mp GvRfok66iBpf9V3q+ZnlvHds0B6ND14V9J139BcwrNVTMZ3gl0mRzBn76Asbhw6IHp+E S7RQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=7BNqAQHUbs/omZNvLE7Yml10kLoDj2gTRisUZztZnsE=; fh=HvJXgAQenBZ43D7ga58dVACs1An1dylTIA1eulgijo4=; b=jleQLmm8YQR02CJAYK5poPL3Hxzp+GiwIgDVBwa2dXhc1PfL7I10duMj45xsU/1mu1 JNDnTb6cAmKD5fwDK8OpUPsskGIELvMHS+/G0cvLhsXL5iqvaNhLFSg9FlitiYJE+1Wy hKxKLcgduaH+4g5E1z9D23zNfSjYZs70+KqPqMBpn0s4B8ouYALr5RfJEoi1+n01rHah DKpTl/WTLH/+J6uEMimSijL7uNmKdMz6SZLGINNw4Y2j5Pfjc5F817M7dDqnUUBbT7b1 p7HmyfFmYPS24w6yU8UCZZrQZV00Y+1yJZOvQjCP4xSLcmfhyeDPQ8IU+hJu7X3kWHqn +ILA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61558-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61558-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCX1mEVAvLV92JfozpT6MlW7EcXytZIlC3LcoI558xykJ/PL7TNDmdpEi/5OaurlyuFv0HEe1iqvcGiAjho5dcvf+pj8AkUlg7N4DC3LxQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ei42-20020a056a0080ea00b006e04633bffbsi4857188pfb.262.2024.02.12.04.38.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:38:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61558-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61558-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61558-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 EDD172871C4 for ; Mon, 12 Feb 2024 12:35:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A13C13CF5C; Mon, 12 Feb 2024 12:33:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 793EA3C680 for ; Mon, 12 Feb 2024 12:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741202; cv=none; b=uah3FQ8G9TciA6DCmSjKNi85L2ZoF81cjUrBJrKhsoFthIrkZeo1yIlGpo019mAqg7d2TFV+sZZQcB+JRsbqK75/EWE2M3fFIkL5+Bae292YCWQQyjK4qF3P/Tc+fOrf/Lz27idRzAD+IqRtNtNnHbhUyX8IGur6A7I+PZkRTrg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741202; c=relaxed/simple; bh=Vq/13jyMTK0Hthb91RLpCC6/kQOlazmQH58gWq/rq14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QbLPJ42jchclUbziFNQaNWMc+pz1IKQvO+Ln4RJR+LzttDx4ohY5dxjDOqQkbHLE/wpqIM5J+FUXbiXXQ74fpaUGIkABj2cCxbHUgHVrvOVRtfpYXx9gs3wJ5JMais2d4D7HZx2Ktgif3jdoUpOt328ccIKGZ870UKt9ewVpiog= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 4FF1B139F; Mon, 12 Feb 2024 04:34:01 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 60AFF3F7BD; Mon, 12 Feb 2024 04:33:18 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, vincent.guittot@linaro.org, peng.fan@oss.nxp.com, michal.simek@amd.com, quic_sibis@quicinc.com, quic_nkela@quicinc.com, souvik.chakravarty@arm.com, Cristian Marussi Subject: [PATCH 11/11] firmware: arm_scmi: Report frequencies in Perf notifications Date: Mon, 12 Feb 2024 12:32:33 +0000 Message-ID: <20240212123233.1230090-12-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212123233.1230090-1-cristian.marussi@arm.com> References: <20240212123233.1230090-1-cristian.marussi@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Extend the Perf notification report to include pre-calculated frequencies corresponding to the reported limits/levels event; such frequencies are properly computed based on the stored known OPPs information taking into consideration if the current operating mode is level indexed or not. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/perf.c | 69 ++++++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 3 ++ 2 files changed, 72 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index e20d137a92f6..981e327e63e3 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -1055,18 +1055,47 @@ static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, return ret; } +static int +scmi_perf_xlate_opp_to_freq(struct perf_dom_info *dom, + unsigned int index, unsigned long *freq) +{ + struct scmi_opp *opp; + + if (!dom || !freq) + return -EINVAL; + + if (!dom->level_indexing_mode) { + opp = xa_load(&dom->opps_by_lvl, index); + if (!opp) + return -ENODEV; + + *freq = opp->perf * dom->mult_factor; + } else { + opp = xa_load(&dom->opps_by_idx, index); + if (!opp) + return -ENODEV; + + *freq = opp->indicative_freq * dom->mult_factor; + } + + return 0; +} + static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, u8 evt_id, ktime_t timestamp, const void *payld, size_t payld_sz, void *report, u32 *src_id) { + int ret; void *rep = NULL; + struct perf_dom_info *dom; switch (evt_id) { case SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED: { const struct scmi_perf_limits_notify_payld *p = payld; struct scmi_perf_limits_report *r = report; + unsigned long freq_min, freq_max; if (sizeof(*p) != payld_sz) break; @@ -1076,14 +1105,36 @@ static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, r->domain_id = le32_to_cpu(p->domain_id); r->range_max = le32_to_cpu(p->range_max); r->range_min = le32_to_cpu(p->range_min); + /* Check if the reported domain exist at all */ + dom = scmi_perf_domain_lookup(ph, r->domain_id); + if (IS_ERR(dom)) + break; + /* + * Event will be reported from this point on... + * ...even if, later, xlated frequencies were not retrieved. + */ *src_id = r->domain_id; rep = r; + + ret = scmi_perf_xlate_opp_to_freq(dom, r->range_max, &freq_max); + if (ret) + break; + + ret = scmi_perf_xlate_opp_to_freq(dom, r->range_min, &freq_min); + if (ret) + break; + + /* Report translated freqs ONLY if both available */ + r->range_max_freq = freq_max; + r->range_min_freq = freq_min; + break; } case SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED: { const struct scmi_perf_level_notify_payld *p = payld; struct scmi_perf_level_report *r = report; + unsigned long freq; if (sizeof(*p) != payld_sz) break; @@ -1091,9 +1142,27 @@ static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, r->timestamp = timestamp; r->agent_id = le32_to_cpu(p->agent_id); r->domain_id = le32_to_cpu(p->domain_id); + /* Report translated freqs ONLY if available */ r->performance_level = le32_to_cpu(p->performance_level); + /* Check if the reported domain exist at all */ + dom = scmi_perf_domain_lookup(ph, r->domain_id); + if (IS_ERR(dom)) + break; + /* + * Event will be reported from this point on... + * ...even if, later, xlated frequencies were not retrieved. + */ *src_id = r->domain_id; rep = r; + + /* Report translated freqs ONLY if available */ + ret = scmi_perf_xlate_opp_to_freq(dom, r->performance_level, + &freq); + if (ret) + break; + + r->performance_level_freq = freq; + break; } default: diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 0cc40af5519a..9b9351e07a11 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -956,6 +956,8 @@ struct scmi_perf_limits_report { unsigned int domain_id; unsigned int range_max; unsigned int range_min; + unsigned long range_max_freq; + unsigned long range_min_freq; }; struct scmi_perf_level_report { @@ -963,6 +965,7 @@ struct scmi_perf_level_report { unsigned int agent_id; unsigned int domain_id; unsigned int performance_level; + unsigned long performance_level_freq; }; struct scmi_sensor_trip_point_report { -- 2.43.0