Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp224477rdb; Tue, 31 Oct 2023 06:03:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEP4Gqj2NI5WBdu5OzR/wirPy4X73OZzBLEIwKNa4KJbacN04RLpb6XD9rbJbBxj8GSsnc X-Received: by 2002:a05:6a20:938b:b0:15a:bf8:7dfc with SMTP id x11-20020a056a20938b00b0015a0bf87dfcmr13107071pzh.15.1698757403104; Tue, 31 Oct 2023 06:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698757403; cv=none; d=google.com; s=arc-20160816; b=wU/bnsNMvLjiO3fIab0ltmSSxzeQUUcBDFjtFk5LxPSk9mXfbLlB0JvZE19zKGq/Pq vxr35mcTbLB5ZnBSGJF4I/lmyAFmDnJoEr063dYS4bOufAtnWCFIFpQ36iGg1rXHph8f 9ipDP+zx1JxLVQ2J1LAZ22/WpbZfexRlqTtAMTC34cKqiDMW0d8Bj1zEgGH8U22LhUcz HUeHpiSXDkdwHbUNrlv78KDEXp7YW7YXt8/+GPN1uqfegbSRYypCXR4641JFPmXjr2g0 F8GQbZaiWVEo3+g3CG+I3nOPUWDhNUYfDxuOZj//IqfMEP3apKHeLK4kiE46uOQvjuOk Yhbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=K76uw1eYZDjjYo+VGDXm0FZ/RZAC8RcoybgoQI4pjIM=; fh=6qRDQPY+VQmRkAZ+fX1lwcKDzkY1EC0JtRDgSoSIESs=; b=Dbe4c0BRWzSndOn6kzW9QZCJgT5PrHfe05HS2kYssUwem/v6w3G2FiJCCzAI9NQ0+O eTIDkUyPy3AjDKfzcuQ15UDrmfAJN1/LXCBjv/veqheehjyc9iP6w4A7rs1EgxbGgNfY WhUNUxQVrYG3khj0/lsIDTi0a1P3d9ORhTN38G3rZDDXR57rc7KvflnXE0pbZHcAqzUO g1nHQk3wxFUFEzTCguA7VzzbEJtPnpd0z/UNVmdPWKrkd005JQIOZYQYOZd7D5MDqR2f 2zxZ6Emi6t6Fu40ZKyrf5RG0PvJa1kAOWP85Lwjgg3I2E8A3MKhbFuKEmcOzP7OIIYnK Nj0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b005b95ee3edb4si1026192pgb.621.2023.10.31.06.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 805A1801E859; Tue, 31 Oct 2023 06:03:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344437AbjJaNDP (ORCPT + 99 others); Tue, 31 Oct 2023 09:03:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344366AbjJaNDP (ORCPT ); Tue, 31 Oct 2023 09:03:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 12918DF; Tue, 31 Oct 2023 06:03:12 -0700 (PDT) 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 02A5EC15; Tue, 31 Oct 2023 06:03:53 -0700 (PDT) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6EC383F738; Tue, 31 Oct 2023 06:03:09 -0700 (PDT) Date: Tue, 31 Oct 2023 13:03:08 +0000 From: Cristian Marussi To: "Peng Fan (OSS)" Cc: sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, ranjani.vaidyanathan@nxp.com, glen.wienecke@nxp.com, nitin.garg@nxp.com, chuck.cannon@nxp.com, Souvik.Chakravarty@arm.com, Peng Fan Subject: Re: [PATCH V1] firmware: arm_scmi: clock: support clock denied flags Message-ID: References: <20231031122734.1371524-1-peng.fan@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231031122734.1371524-1-peng.fan@oss.nxp.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 06:03:17 -0700 (PDT) On Tue, Oct 31, 2023 at 08:27:34PM +0800, Peng Fan (OSS) wrote: > From: Peng Fan > > The firmware may export flags to indicate whether the clock > is allowed to set rate, set parent, enable/disable from the Agent. > > If Agent is not allowed to enable/disable, directly return success. ... even though, this success on deny built-in policy could be controversial...Have you tried the different approach of not registerig the enable/prepare callbacks in clk-scmi instead ? From the Clk framework code it seems could be handled gracefully. (I have not tried though...) Thanks, Cristian > If Agent is not allowed to set rate/parent, directly return -EACCES to > avoid SCMI RPC calls. > > Signed-off-by: Peng Fan > --- > > V1: > drop the changes in clock.c, add an attribute entry in clock info which > may be easy for extending new flag. > > SPEC still not have such support, this is for discussion > > drivers/firmware/arm_scmi/clock.c | 19 +++++++++++++++++++ > include/linux/scmi_protocol.h | 1 + > 2 files changed, 20 insertions(+) > > diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c > index 42b81c181d68..fad4329a21fc 100644 > --- a/drivers/firmware/arm_scmi/clock.c > +++ b/drivers/firmware/arm_scmi/clock.c > @@ -46,6 +46,9 @@ struct scmi_msg_resp_clock_attributes { > #define SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(x) ((x) & BIT(30)) > #define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(29)) > #define SUPPORTS_PARENT_CLOCK(x) ((x) & BIT(28)) > +#define SCMI_CLOCK_SET_ENABLE_DENIED BIT(15) > +#define SCMI_CLOCK_SET_RATE_DENIED BIT(14) > +#define SCMI_CLOCK_SET_PARENT_DENIED BIT(13) > u8 name[SCMI_SHORT_NAME_MAX_SIZE]; > __le32 clock_enable_latency; > }; > @@ -307,6 +310,7 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, > if (PROTOCOL_REV_MAJOR(version) >= 0x2) > latency = le32_to_cpu(attr->clock_enable_latency); > clk->enable_latency = latency ? : U32_MAX; > + clk->attributes = attributes; > } > > ph->xops->xfer_put(ph, t); > @@ -499,6 +503,10 @@ static int scmi_clock_rate_set(const struct scmi_protocol_handle *ph, > struct scmi_xfer *t; > struct scmi_clock_set_rate *cfg; > struct clock_info *ci = ph->get_priv(ph); > + struct scmi_clock_info *clk = ci->clk + clk_id; > + > + if (clk->attributes & SCMI_CLOCK_SET_RATE_DENIED) > + return -EACCES; > > ret = ph->xops->xfer_get_init(ph, CLOCK_RATE_SET, sizeof(*cfg), 0, &t); > if (ret) > @@ -585,6 +593,9 @@ scmi_clock_set_parent(const struct scmi_protocol_handle *ph, u32 clk_id, > if (parent_id >= clk->num_parents) > return -EINVAL; > > + if (clk->attributes & SCMI_CLOCK_SET_PARENT_DENIED) > + return -EACCES; > + > ret = ph->xops->xfer_get_init(ph, CLOCK_PARENT_SET, > sizeof(*cfg), 0, &t); > if (ret) > @@ -668,6 +679,10 @@ static int scmi_clock_enable(const struct scmi_protocol_handle *ph, u32 clk_id, > bool atomic) > { > struct clock_info *ci = ph->get_priv(ph); > + struct scmi_clock_info *clk = ci->clk + clk_id; > + > + if (clk->attributes & SCMI_CLOCK_SET_ENABLE_DENIED) > + return 0; > > return ci->clock_config_set(ph, clk_id, CLK_STATE_ENABLE, > NULL_OEM_TYPE, 0, atomic); > @@ -677,6 +692,10 @@ static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id, > bool atomic) > { > struct clock_info *ci = ph->get_priv(ph); > + struct scmi_clock_info *clk = ci->clk + clk_id; > + > + if (clk->attributes & SCMI_CLOCK_SET_ENABLE_DENIED) > + return 0; > > return ci->clock_config_set(ph, clk_id, CLK_STATE_DISABLE, > NULL_OEM_TYPE, 0, atomic); > diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h > index f2f05fb42d28..ddf5363c8cfd 100644 > --- a/include/linux/scmi_protocol.h > +++ b/include/linux/scmi_protocol.h > @@ -58,6 +58,7 @@ struct scmi_clock_info { > u64 step_size; > } range; > }; > + u32 attributes; > int num_parents; > u32 *parents; > }; > -- > 2.37.1 >