From patchwork Mon Feb 12 12:32:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396567dyd; Mon, 12 Feb 2024 04:34:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVEzZ0GyWRyTaCWXuyq39D80hGAwOSaX8MNzHYLoWQ/GW0KbqG1otCnXlOI4ANdITM4tNGkh0+n76HqUEreR6fuQnDa6Q== X-Google-Smtp-Source: AGHT+IEI715ml77yktcg9OD/DRv60Qd5cyxXO8j+pK300ve7Zh/ybvILTyjstj/bSRWkwfYHuRmO X-Received: by 2002:a05:6808:e83:b0:3bf:dff4:7055 with SMTP id k3-20020a0568080e8300b003bfdff47055mr8594727oil.50.1707741281939; Mon, 12 Feb 2024 04:34:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741281; cv=pass; d=google.com; s=arc-20160816; b=giMFoJX9AgDUnv6vXHKK3a0rj3/I/ZcEM/AsXo2neVUytP2V8ocCnz0QimUXIgdrCd SuNUIIQ5G207yxT9QXGSnknwEgAE3S4z3rGcADxwnEuz9VXhvAvC2CL333mv4pTazKrm SbNOXJzoMoz+SO3HMf9gpCD1mU+KdQojB5Cgp6P45+t+IOT83v+pyOCZaqtaa/ibU2yK cjr867I72ANFmqUH4WZ0GAluPLWxKaR3p9bSEe/3k+CXD8xDSJ1IWXv7UmaQtSuO9XYC D7QGhFj5pSul260dXD6zb8s+JQOpa+KOneRbzdqsxbzZu5Et/oCHy9a9+YQxo7ZWFiMa Npzg== 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=UIXaQnYGuYn463J/HrrObW/VqGSjTYYl1K0SBunCh9c=; fh=7B3+aRCMcrCkp6CQ7eVC5cPy2yt7BzCxA6NebWMgk0A=; b=UcNNcJwX6xGsJefJBMo9hF3VTL/jHg8VZM5976qbwWPI+q+GZEfmtL8x/cXyHnDqpl 0aKXuzJ2O0zFEvXCZqiW/RZvE5Oq7B9OdD7SoI4KSOdW2o9FmKRcjLzf3ZMROxGVX8Zd D8Pgu2i6gPRVRhIqXmvNoYL3IyMTVbU/BQ/vvdJeQlLmT134IXdDk7M3M9BT8hga8t+X 17zABEiOGGn5fZeYnbyhzHEWCO1fOxSyCFbHDbOfAWoSHbmry8btBEgKNXg1Ljcjv8GQ lIQDEutEQ0rMi3QAiMsMh1XzF9rcVmlPyiC22r5H9k66915Ak/SGP3qsYR2OnwEQ3ZAy CQvQ==; 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-61553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61553-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXcxopHRup8erhsoy630rggnAZBdW2lfFYE4UuhcM5pPQreSeGX36+UeMb11UIxz6BPGMfCdW8Lg20d3OgreuFPMqN1nQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id az44-20020a05620a172c00b00785da900320si944529qkb.78.2024.02.12.04.34.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-61553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61553-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B4B051C2123C for ; Mon, 12 Feb 2024 12:34:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0ECA23B799; Mon, 12 Feb 2024 12:33:15 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C16BA3B199 for ; Mon, 12 Feb 2024 12:33:11 +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=1707741193; cv=none; b=r+VwA7q8iy3QZGofR3c9nG9QTvzhWqVn2Q1w0oK43jLOOS4Vp7swI7kZfApFuSNozU+6I7MbCRxweuyYaPoZdd60VwAcjEVHzDZF9epelslcvYZrRNX0N6xuweW9J069Jjdd+7g+ChKdo36dbfQNFc99YKN4uTbT/pyPtqIecHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741193; c=relaxed/simple; bh=0FGhoxplAJ+IDq58QH5NR/n1OkM218I0PRVsLtbpa/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ARN8KlSNkwOYZ8+jcDgw1jpOj9OugSoM2uxPsJgloeg9aHj4o4Cueoy7XDO/KD8vNvNeJuWep2mmccak3vjvhN7IWj/IQOMghGROrO2E0GTljQLM5D/0nWgW5Bj1V4WxfCeOvD1svn7RkzxZlUwuKpda9nPHBRNXbSh+X+krZ3o= 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 B5EC8FEC; Mon, 12 Feb 2024 04:33:52 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E72233F7BD; Mon, 12 Feb 2024 04:33:09 -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 06/11] firmware: arm_scmi: Implement Clock .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:28 +0000 Message-ID: <20240212123233.1230090-7-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: 1790696522605268175 X-GMAIL-MSGID: 1790696522605268175 Add a preliminary check to verify if Clock-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/clock.c | 47 ++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 959e48aba1b5..85eda5db40ba 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -158,6 +158,8 @@ struct clock_info { u32 version; int num_clocks; int max_async_req; + bool notify_rate_changed_cmd; + bool notify_rate_change_requested_cmd; atomic_t cur_async_req; struct scmi_clock_info *clk; int (*clock_config_set)(const struct scmi_protocol_handle *ph, @@ -204,6 +206,17 @@ scmi_clock_protocol_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) { + if (!ph->hops->protocol_msg_check(ph, CLOCK_RATE_NOTIFY, NULL)) + ci->notify_rate_changed_cmd = true; + + if (!ph->hops->protocol_msg_check(ph, + CLOCK_RATE_CHANGE_REQUESTED_NOTIFY, + NULL)) + ci->notify_rate_change_requested_cmd = true; + } + return ret; } @@ -329,13 +342,14 @@ scmi_clock_get_permissions(const struct scmi_protocol_handle *ph, u32 clk_id, } static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, - u32 clk_id, struct scmi_clock_info *clk, + u32 clk_id, struct clock_info *cinfo, u32 version) { int ret; u32 attributes; struct scmi_xfer *t; struct scmi_msg_resp_clock_attributes *attr; + struct scmi_clock_info *clk = cinfo->clk + clk_id; ret = ph->xops->xfer_get_init(ph, CLOCK_ATTRIBUTES, sizeof(clk_id), sizeof(*attr), &t); @@ -368,9 +382,11 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, NULL, clk->name, SCMI_MAX_STR_SIZE); - if (SUPPORTS_RATE_CHANGED_NOTIF(attributes)) + if (cinfo->notify_rate_changed_cmd && + SUPPORTS_RATE_CHANGED_NOTIF(attributes)) clk->rate_changed_notifications = true; - if (SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes)) + if (cinfo->notify_rate_change_requested_cmd && + SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes)) clk->rate_change_requested_notifications = true; if (SUPPORTS_PARENT_CLOCK(attributes)) scmi_clock_possible_parents(ph, clk_id, clk); @@ -896,6 +912,28 @@ static const struct scmi_clk_proto_ops clk_proto_ops = { .parent_get = scmi_clock_get_parent, }; +static bool scmi_clk_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + bool supported; + struct scmi_clock_info *clk; + struct clock_info *ci = ph->get_priv(ph); + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return false; + + clk = scmi_clock_domain_lookup(ci, src_id); + if (IS_ERR(clk)) + return false; + + if (evt_id == SCMI_EVENT_CLOCK_RATE_CHANGED) + supported = clk->rate_changed_notifications; + else + supported = clk->rate_change_requested_notifications; + + return supported; +} + static int scmi_clk_rate_notify(const struct scmi_protocol_handle *ph, u32 clk_id, int message_id, bool enable) { @@ -980,6 +1018,7 @@ static const struct scmi_event clk_events[] = { }; static const struct scmi_event_ops clk_event_ops = { + .is_notify_supported = scmi_clk_notify_supported, .get_num_sources = scmi_clk_get_num_sources, .set_notify_enabled = scmi_clk_set_notify_enabled, .fill_custom_report = scmi_clk_fill_custom_report, @@ -1021,7 +1060,7 @@ static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph) for (clkid = 0; clkid < cinfo->num_clocks; clkid++) { struct scmi_clock_info *clk = cinfo->clk + clkid; - ret = scmi_clock_attributes_get(ph, clkid, clk, version); + ret = scmi_clock_attributes_get(ph, clkid, cinfo, version); if (!ret) scmi_clock_describe_rates_get(ph, clkid, clk); }