Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp762666rdh; Wed, 14 Feb 2024 10:31:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXkuzMKLe5VwKFbER7mr1ey/pwJNr3FxxgcYVqZ8XIbEctEwYtiNu3WbxTEaIRKGiudRVGBrRX6HtckCtGS0VhFJ/BpxVHK6CmljbAD7A== X-Google-Smtp-Source: AGHT+IGW3zmm90RE8Qt1QApIpUXTKVNkF6Cs9CRsSJuwWOXCCmojTk8nvi8+k+JAbWs4qArGPHmb X-Received: by 2002:aa7:db46:0:b0:560:eaa8:9654 with SMTP id n6-20020aa7db46000000b00560eaa89654mr2668444edt.12.1707935472169; Wed, 14 Feb 2024 10:31:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707935472; cv=pass; d=google.com; s=arc-20160816; b=PiDeXFFe5CPO2k3sFPhdK1oCtkKVtn66+qZUf2r8yBJqJ+qpTw/oEFEaGYAS8yMj9v YiqIW/Vzp0lSk5J2tIL7sC/iNEa0GQ3hRwfNOK5zhyDMwfigtlSyopCYCGagVB4IblUF HUAlyWL7piZg4FpXQnGHHQfMvZNVNPKID/XOoN/yBQCretUbiigtDUI1dZfrISJG46Mc zWMLviaBk2M22KJeehRGJHQTQDYesPSqn8SxWTqvJRT5skZBEBJ7SLaO8/Pd42Horp8h pE7J7sIPmX5QICYm2SRBtVBW1jkLEbOKcOGCnUwb1yM+VsrK6IaXKNDFjqeGJFsWhgEf 6/VQ== 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=WXDnbGi9F3B2ucfCWhmjznBbiq3sXZAqnFYeUxtvpVw=; fh=EArfneAS60bVqPKET87O0ypQvSAuNe9ZkXaXsbTbxnc=; b=gqZj4RgFeCyd3Htxewm44A0QopAzZFot5ziXM1Ht0n642vIuLx/bp03Tq2f7bMEZlA NFE1vu7rQ16pOksmgHa3Zaiikz/tqecPJR11rw+v1cMxbLkvnhxvKtycK8dA0qxwrkqV piasOUP9qzga3BNOX00uNqF/wxpcnwCTIJaPRjgOOmzOTTC2CNdO/7wUrXKsVUg+3iPL IIQ5kQE1EUFvg/fnVcHB1fjzX8/lRVi1WWJywRySxrWBXh9h3s1FgX9aDQDcJOFvuH+M bvjPYYwVDyGIem0ILjUemGVnome5fh90zpkyx2CxgDvWiQ0CGaPdaLhqNXJCbnMursSG ZIBg==; 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-65807-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65807-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; AJvYcCXSnDn8x04cFtCMECX6lAKj5OgluvVJhHbIpAR7X4ZPGFNbo/qzozMvhj2W5iHU14xn67QHtp4d4bqJtO2SGg82wCa8LjUek65a0NKm4g== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g37-20020a056402322500b0056384d51a22si650744eda.610.2024.02.14.10.31.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 10:31:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65807-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-65807-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65807-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D3EAD1F29950 for ; Wed, 14 Feb 2024 18:31:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1CF512CDA8; Wed, 14 Feb 2024 18:30:39 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DA4812BF38 for ; Wed, 14 Feb 2024 18:30:37 +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=1707935439; cv=none; b=Lrcu6tXW2Jiua/+jVKwSWGbHU31O8qTaKukeGMj90Xg1MuoqPgiQatbfv/biByt2rFg2ba9G7Zez9ECNwW6TMrFOG/3QerH+NLzMS6GfxW8bptanJm8SFW2ipen/r9Fa3t5UVtj1UzOqxQqRcLQw95Y/kUCSkEw3wq53QlvaDSw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707935439; c=relaxed/simple; bh=kKN6YUR8GBEY6aJ6XdGiwTYMxulxghywt7sHCnYQMJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oTADOTT4g4IncfrsqfTvzF8ph8+/ugNDt31rDsudK0l740OLqC5OAQ7Rjn4A6kSk+hJbuM87UuX58OUF6jIjwEEzXIu53XczWHMsc3e+oD0pwWtSf6CyitHH7SjYebhaAFhTFy6+Ttu9qKYxQHuMoScc59UBhfYXSuNx+6sakT8= 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 A678E1FB; Wed, 14 Feb 2024 10:31:17 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CD7EB3F7B4; Wed, 14 Feb 2024 10:30:34 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, f.fainelli@gmail.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 3/7] firmware: arm_scmi: Add Clock check for extended config support Date: Wed, 14 Feb 2024 18:30:02 +0000 Message-ID: <20240214183006.3403207-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214183006.3403207-1-cristian.marussi@arm.com> References: <20240214183006.3403207-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 SCMI v3.2 added support to set/get Clock custom OEM types; such support is conditionally present, though, depending on an extended config attribute bit possibly advertised by the platform server on a per-domain base. Add a check to verify if OEM types are supported before allowing any kind of OEM-specific get/set operation and also a check around all Clock v3.2 features. Signed-off-by: Cristian Marussi --- base-commit: 7dd3d11f4dac301e958f00e18db4901a35cefc70 --- drivers/firmware/arm_scmi/clock.c | 33 +++++++++++++++++++++++++------ include/linux/scmi_protocol.h | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 959e48aba1b5..9d80ad95b467 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -54,6 +54,7 @@ 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 SUPPORTS_EXTENDED_CONFIG(x) ((x) & BIT(27)) #define SUPPORTS_GET_PERMISSIONS(x) ((x) & BIT(1)) u8 name[SCMI_SHORT_NAME_MAX_SIZE]; __le32 clock_enable_latency; @@ -372,10 +373,14 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, clk->rate_changed_notifications = true; if (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); - if (SUPPORTS_GET_PERMISSIONS(attributes)) - scmi_clock_get_permissions(ph, clk_id, clk); + if (PROTOCOL_REV_MAJOR(version) >= 0x3) { + if (SUPPORTS_PARENT_CLOCK(attributes)) + scmi_clock_possible_parents(ph, clk_id, clk); + if (SUPPORTS_GET_PERMISSIONS(attributes)) + scmi_clock_get_permissions(ph, clk_id, clk); + if (SUPPORTS_EXTENDED_CONFIG(attributes)) + clk->extended_config = true; + } } return ret; @@ -684,7 +689,7 @@ scmi_clock_get_parent(const struct scmi_protocol_handle *ph, u32 clk_id, return ret; } -/* For SCMI clock v2.1 and onwards */ +/* For SCMI clock v3.0 and onwards */ static int scmi_clock_config_set_v2(const struct scmi_protocol_handle *ph, u32 clk_id, enum clk_state state, u8 oem_type, u32 oem_val, @@ -757,7 +762,7 @@ static int scmi_clock_disable(const struct scmi_protocol_handle *ph, u32 clk_id, NULL_OEM_TYPE, 0, atomic); } -/* For SCMI clock v2.1 and onwards */ +/* For SCMI clock v3.0 and onwards */ static int scmi_clock_config_get_v2(const struct scmi_protocol_handle *ph, u32 clk_id, u8 oem_type, u32 *attributes, bool *enabled, @@ -844,6 +849,14 @@ static int scmi_clock_config_oem_set(const struct scmi_protocol_handle *ph, bool atomic) { struct clock_info *ci = ph->get_priv(ph); + struct scmi_clock_info *clk; + + clk = scmi_clock_domain_lookup(ci, clk_id); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + if (!clk->extended_config) + return -EOPNOTSUPP; return ci->clock_config_set(ph, clk_id, CLK_STATE_UNCHANGED, oem_type, oem_val, atomic); @@ -854,6 +867,14 @@ static int scmi_clock_config_oem_get(const struct scmi_protocol_handle *ph, u32 *attributes, bool atomic) { struct clock_info *ci = ph->get_priv(ph); + struct scmi_clock_info *clk; + + clk = scmi_clock_domain_lookup(ci, clk_id); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + if (!clk->extended_config) + return -EOPNOTSUPP; return ci->clock_config_get(ph, clk_id, oem_type, attributes, NULL, oem_val, atomic); diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 0cc40af5519a..caeca3f51be2 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -50,6 +50,7 @@ struct scmi_clock_info { bool state_ctrl_forbidden; bool rate_ctrl_forbidden; bool parent_ctrl_forbidden; + bool extended_config; union { struct { int num_rates; -- 2.43.0