From patchwork Mon Feb 12 12:32:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396237dyd; Mon, 12 Feb 2024 04:34:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz4by5nI3DmAIZMlGOUDW6SeNUoxeEHnG6djTm+F2bSmoRp+QXSwy/T5UMKJFFm4En9PPb X-Received: by 2002:a92:d352:0:b0:363:acbc:c106 with SMTP id a18-20020a92d352000000b00363acbcc106mr8355747ilh.18.1707741243876; Mon, 12 Feb 2024 04:34:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741243; cv=pass; d=google.com; s=arc-20160816; b=JGKTrU/yDvRVrl6eESX49YD3rlWto64HX/QNur3tnzUMPIpFeiQjJolZugTmDnKDzq wyZve5f9SK0kRRMSLkkzZLCkYoAC8Dsq9oHuwCuQHOG6O5drfCm21Pjz9AqYOt1YRagY cARoXd/JX21GJ2swBzS5iHJ9LjfZvFxFi/lax92EwGROEf3Ucpal4mM6zZyc+MQkLgpR lLmg0gve4Bghmns/3l8Ih5wlimVP6nIFxkaWNdvGNdgkPxT5xcbUlXtemMFNqOSo2Elo rO2RVIQmqeVHniOpMJ4UH2HDSlwegQxF9U62w/EIyHpMewNC8jLSSdPcWvBmA5EdL0jZ 4fyw== 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=AYRlYkexLw48fkrZoqD3nit2XYTFuaprm95T34c+PGw=; fh=I83D+XcNN+JlEpeDQbNV4BkWbqwK72AMzTMvGzYt0og=; b=qRsVVUVAqoHTdfe/hYQYB0CpadBnwp8yV2iFjArSE4VTsK86WFlDSCt+wMs37surp7 w/V0oz1aKPhMzdU1hQ+oqw8MzZapzG2aUTXrXObfr4q0sloJdUq7x6RlmZjAVi8puiVl 8tZQO6g+lGc6Jqs8+gf/i2ISquXRIS7Yu2dl0CcbLzLeKutus9uf7gIqPkvqXmsRCSIF ZutL7laPPkJUhMSN/X6T51CDZfLIvx1yW9ZcROY+wjs4CW02yhYahWmRzDK9seuE4AXq oHga/DvzVcok9kQlkGpiQl5dsnD61Bc9AdLigzsxID1Whwr+6HyxpDr26juw0K7Gh/CY 5lyw==; 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-61550-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61550-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCWftbQoz/eDJsTZcMGeW0q5MfKzy7jMEUrXe0dtRFZkLUqGaNmMZucPPLvGfyYoGs7GK84VBaffgkoZ4TsXXzpzMxCynQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m185-20020a6326c2000000b005dc1330fadcsi186073pgm.6.2024.02.12.04.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:34:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61550-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-61550-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61550-ouuuleilei=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 9FE39287E25 for ; Mon, 12 Feb 2024 12:34:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EB93A8F0; Mon, 12 Feb 2024 12:33:10 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EBD43A1B2 for ; Mon, 12 Feb 2024 12:33:06 +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=1707741188; cv=none; b=XVIy+3IwOFiCKcZ7wIvXs7z9bDdQftDsWqy1CObDbuwe21F4f+CRfj19PrQcSP4ANE4R89CiaYFb+YoqHLOYtQ9i9urP++A25pwQlyd5fdDDuT2vuDKJDtGnipZ2o/If9PYXNRxMga72lOc6DnTi0+TSeAE+rRD4jdlazxjIaFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741188; c=relaxed/simple; bh=evkNOnm5oC5eo6hVIW+ZaWP1k6EADRqFYfcbNt8e4+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IqnjS9ZMFgga2C7cAi2zJaqtvZX9SdgwmNwbZQrfcwWxuHFjITpHJxf4JUpmQu6ETBdtFrisBx+olxrrb5ZTaTQUFwyA98yyL26QY34NbYKTu/hMXp21eSyabzIz/limN0b+12bYMi+qSZ8aSw+aF3WNR719c9YbIlayELvK/y8= 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 A6B2911FB; Mon, 12 Feb 2024 04:33:47 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7C1B3F7BD; Mon, 12 Feb 2024 04:33:04 -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 03/11] firmware: arm_scmi: Implement Perf .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:25 +0000 Message-ID: <20240212123233.1230090-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790696482555438893 X-GMAIL-MSGID: 1790696482555438893 Add a preliminary check to verify if Perf-related notify enable commands are supported at all by the running platform, and then provide the callback needed to allow the core SCMI notification subsytem to fine-grain check if a specific resource domain supports notifications. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/perf.c | 45 +++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 9e7b1ee94940..2627ace5b07f 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -182,6 +182,8 @@ struct scmi_perf_info { enum scmi_power_scale power_scale; u64 stats_addr; u32 stats_size; + bool notify_lvl_cmd; + bool notify_lim_cmd; struct perf_dom_info *dom_info; }; @@ -222,6 +224,15 @@ static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) { + if (!ph->hops->protocol_msg_check(ph, PERF_NOTIFY_LEVEL, NULL)) + pi->notify_lvl_cmd = true; + + if (!ph->hops->protocol_msg_check(ph, PERF_NOTIFY_LIMITS, NULL)) + pi->notify_lim_cmd = true; + } + return ret; } @@ -239,6 +250,7 @@ static void scmi_perf_xa_destroy(void *data) static int scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, struct perf_dom_info *dom_info, + bool notify_lim_cmd, bool notify_lvl_cmd, u32 version) { int ret; @@ -260,8 +272,12 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, dom_info->set_limits = SUPPORTS_SET_LIMITS(flags); dom_info->info.set_perf = SUPPORTS_SET_PERF_LVL(flags); - dom_info->perf_limit_notify = SUPPORTS_PERF_LIMIT_NOTIFY(flags); - dom_info->perf_level_notify = SUPPORTS_PERF_LEVEL_NOTIFY(flags); + if (notify_lim_cmd) + dom_info->perf_limit_notify = + SUPPORTS_PERF_LIMIT_NOTIFY(flags); + if (notify_lvl_cmd) + dom_info->perf_level_notify = + SUPPORTS_PERF_LEVEL_NOTIFY(flags); dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags); if (PROTOCOL_REV_MAJOR(version) >= 0x4) dom_info->level_indexing_mode = @@ -993,6 +1009,27 @@ static const struct scmi_perf_proto_ops perf_proto_ops = { .power_scale_get = scmi_power_scale_get, }; +static bool scmi_perf_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + bool supported; + struct perf_dom_info *dom; + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return false; + + dom = scmi_perf_domain_lookup(ph, src_id); + if (IS_ERR(dom)) + return false; + + if (evt_id == SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED) + supported = dom->perf_limit_notify; + else + supported = dom->perf_level_notify; + + return supported; +} + static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enable) { @@ -1082,6 +1119,7 @@ static const struct scmi_event perf_events[] = { }; static const struct scmi_event_ops perf_event_ops = { + .is_notify_supported = scmi_perf_notify_supported, .get_num_sources = scmi_perf_get_num_sources, .set_notify_enabled = scmi_perf_set_notify_enabled, .fill_custom_report = scmi_perf_fill_custom_report, @@ -1126,7 +1164,8 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph) struct perf_dom_info *dom = pinfo->dom_info + domain; dom->id = domain; - scmi_perf_domain_attributes_get(ph, dom, version); + scmi_perf_domain_attributes_get(ph, dom, pinfo->notify_lim_cmd, + pinfo->notify_lvl_cmd, version); scmi_perf_describe_levels_get(ph, dom, version); if (dom->perf_fastchannels)