Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2420542rdb; Mon, 12 Feb 2024 04:33:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS6rlauAFDLa+uP79vaH8sVSXbb0KUSbllCwDF0gHdpLwMcg/BpRGVSSOnPVWooDzMdHYO X-Received: by 2002:a17:903:249:b0:1d9:8e37:56d6 with SMTP id j9-20020a170903024900b001d98e3756d6mr6876668plh.40.1707741232836; Mon, 12 Feb 2024 04:33:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741232; cv=pass; d=google.com; s=arc-20160816; b=e4gChNCe8kHB6s14Gvm96b96KWJ4/0y0Oey8jYAjHZT+9IlQOatA0XjSDhx3hu6OSN ujQ6bbQqQEZdkyJWBjcSDMVbyP63UfO7qyVLk5qPGtNoEcT7MfJLj4uTD7iiAYfSPxPN DLalh/7RKOfyeDHimSNUlQnSqlDuAZ5hJbV16po0kPeFYhn8BEtVrwwWxe+uQQP6stPp LOEheJc63zYwIG5ZoAyR9uNpqgNYawFjG14gKMJG3+x5XdEl19U0T3wNbmP5HQ5rEJe1 qefdxb4EQSGe9q68Yhv7zmyQusUwsgX9A9WrFcs9k3HaQ06EwYsUVZ1HgrDV9b01honp UtMw== 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=Cu3N5EeAuwzOQBGGifdxOTr7qeDdCCDzabDUC2ALnE0=; b=CtududqhUJtYiZP9EGGlE01xiLu35uobEADNvYEf5HDlAM+CkCXS5NUAD1EkN91CfZ 2q05cNAsORYhcG63gYEqxVBxdyYLK7M73Si9XZ2bTQab8QonhBH6o+hiIIeNvpa36n8c a92j0+Btr/pD7K9Iqlk4ySN+7yC8Tthu43+JeoT9bpXqrAaGQafbFiuhuitYIOZML335 d6aJ0ZN0O5Eo4P59fVOeLuQNBQMY4Uibg0d1cZZRk3FGEhmT2fes8jsvE+8287L9o0ew j2mX4buQduHxIfdcDf7qixi1yNJLqZY/6Kl4Mk0nLmTKQvwGP8oitPigEnUrfBCc2Szi 4x/g==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61550-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; AJvYcCVLCVGkGzMP3iPtNWDj1kZbEKVUaBmAtrgsN8HyoapFzlhN1Zz6iUdQIzAxehI6ZV+8G9ycN1EwAENiPbe4+WgrEHxxMFfaCn0UAyXyJA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id jg5-20020a17090326c500b001d717e60007si183757plb.397.2024.02.12.04.33.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:33:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61550-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61550-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 7FD36287E1B for ; Mon, 12 Feb 2024 12:33:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 527D33A8D5; Mon, 12 Feb 2024 12:33:09 +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 Content-Transfer-Encoding: 8bit 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) -- 2.43.0