From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EE8A4192EF; Sun, 6 Sep 2026 10:08:32 +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=1788689314; cv=none; b=iNlnQsBjw6vsCgdOjEQryqBNpv61bQLgZ4lhTPW3xd+JOeE50GdIwDlHPtEhoXVgcLg41DA22v7Rb4cxNzLaJJdKCtsKSc+g4wYMkUFBqaDlxjP3EzhlliC1RZ4cKcf0LzOoF97z7sNkdeiV5F58hs7dxKJts6DlLJo9BoEg1c0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788689314; c=relaxed/simple; bh=HosVhyEnqeogiOQ1LyQ11+JnZjQJD/MNZsBE5zbC9tI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=shKB1bQbazWGaMajphgD7G009Y1o6zodfsW9mIoNs1NS/fYavjUteP3S883OJ2SfsEFb5Rz92oN339pbaWgJMT4FEZc1hPBmIu68Pa1/KRkIsYHrvWl0sotGCCqTWF/NFRJiv4WLjUVoWFKIhJ+GmCy0Lg7h5DJUU1AEFGdTpnU= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Fg0DqYlF; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Fg0DqYlF" 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 59DF51BA8; Sun, 6 Sep 2026 03:08:28 -0700 (PDT) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E5973F7D8; Sun, 6 Sep 2026 03:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1788689312; bh=HosVhyEnqeogiOQ1LyQ11+JnZjQJD/MNZsBE5zbC9tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fg0DqYlFd42M6oBSr0BD4FaoNmYydZ3yT9vlje/IJf34OaU0Ul4PG0hcreEGNHhgI 1MdJHYN8ow7e6wL83KYduNKFMYA2RRYX003eEsXg5wCx18becJWZbrukv53NvUf+NF QaM7ctz2F3EHlW2U0Sme5dQbtIL9J/V0D1HF4sTc= From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org, linux-doc@vger.kernel.org Cc: sudeep.holla@kernel.org, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, etienne.carriere@st.com, peng.fan@oss.nxp.com, michal.simek@amd.com, d-gole@ti.com, jic23@kernel.org, elif.topuz@arm.com, lukasz.luba@arm.com, philip.radford@arm.com, david@kernel.org, souvik.chakravarty@arm.com, leitao@kernel.org, kas@kernel.org, puranjay@kernel.org, usama.arif@linux.dev, kernel-team@meta.com, Cristian Marussi Subject: [PATCH v11 19/25] firmware: arm_scmi: Add un-managed methods to get/put protocols operations Date: Sun, 6 Sep 2026 11:06:17 +0100 Message-ID: <20260906100623.3488327-20-cristian.marussi@arm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260906100623.3488327-1-cristian.marussi@arm.com> References: <20260906100623.3488327-1-cristian.marussi@arm.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a couple of simple common methods to be able to manually get and put protocol operations to address situation in which devres managed methods cannot be used. Signed-off-by: Cristian Marussi --- v10 --> v11 - fixed a few comments typos --- drivers/firmware/arm_scmi/driver.c | 39 ++++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 7 ++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index c003e7be7696..127df3abb131 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2571,6 +2571,31 @@ scmi_devm_protocol_get(struct scmi_device *sdev, u8 protocol_id, return pi->proto->ops; } +/** + * scmi_protocol_operations_get - UnManaged get protocol operations + * + * @handle: A reference to the SCMI platform instance. + * @protocol_id: The protocol being acquired. + * @ph: A pointer reference used to pass back the associated protocol handle. + */ +static const void __must_check * +scmi_protocol_operations_get(const struct scmi_handle *handle, u8 protocol_id, + struct scmi_protocol_handle **ph) +{ + struct scmi_protocol_instance *pi; + + if (!ph) + return ERR_PTR(-EINVAL); + + pi = scmi_get_protocol_instance(handle, protocol_id); + if (IS_ERR(pi)) + return pi; + + *ph = &pi->ph; + + return pi->proto->ops; +} + /** * scmi_devm_protocol_acquire - Devres managed helper to get hold of a protocol * @sdev: A reference to an scmi_device whose embedded struct device is to @@ -2627,6 +2652,18 @@ static void scmi_devm_protocol_put(struct scmi_device *sdev, u8 protocol_id) WARN_ON(ret); } +/** + * scmi_protocol_operations_put - UnManaged put protocol operations + * + * @handle: A reference to the SCMI platform instance. + * @protocol_id: The protocol being released. + */ +static void scmi_protocol_operations_put(const struct scmi_handle *handle, + u8 protocol_id) +{ + scmi_protocol_release(handle, protocol_id); +} + /** * scmi_is_transport_atomic - Method to check if underlying transport for an * SCMI instance is configured as atomic. @@ -3358,6 +3395,8 @@ static int scmi_probe(struct platform_device *pdev) handle->devm_protocol_acquire = scmi_devm_protocol_acquire; handle->devm_protocol_get = scmi_devm_protocol_get; handle->devm_protocol_put = scmi_devm_protocol_put; + handle->protocol_get = scmi_protocol_operations_get; + handle->protocol_put = scmi_protocol_operations_put; handle->is_transport_atomic = scmi_is_transport_atomic; /* Setup all channels described in the DT at first */ diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index a85c00bf72f2..11ed0b95536e 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -1137,6 +1137,9 @@ struct scmi_notify_ops { * @devm_protocol_get: devres managed method to acquire a protocol and get specific * operations and a dedicated protocol handler * @devm_protocol_put: devres managed method to release a protocol + * @protocol_get: unmanaged method to acquire a protocol and get specific + * operations and a dedicated protocol handler + * @protocol_put: unmanaged method to release a protocol * @is_transport_atomic: method to check if the underlying transport for this * instance handle is configured to support atomic * transactions for commands. @@ -1159,6 +1162,10 @@ struct scmi_handle { (*devm_protocol_get)(struct scmi_device *sdev, u8 proto, struct scmi_protocol_handle **ph); void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto); + const void __must_check * + (*protocol_get)(const struct scmi_handle *handle, u8 proto, + struct scmi_protocol_handle **ph); + void (*protocol_put)(const struct scmi_handle *handle, u8 proto); bool (*is_transport_atomic)(const struct scmi_handle *handle, unsigned int *atomic_threshold); const struct scmi_notify_ops *notify_ops; -- 2.54.0