From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A7A5C982D0 for ; Sun, 20 Sep 2026 09:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=43bdx5rB27SpdAyWeQi2xQtsUVVn3YsawtJ1R15vvkY=; b=Df8HKJvgoQFTEOb3Med6MTTcMq MKpBpt98Nlwpn9nudGVLmuEjfJxKonCbNVg/xtULxUSDVigwg/L6u5i+j2Jvr+e7G4Kc/6yLzbXuK H17I7uS31GnmD2JAk07olp58BsPikpipWe4iikK9IGPj1wVHeQdtqOBPqLTsuJITB4CS4OliE26iv rGqpsbtELz0DkXL7tMfWMfpXXkB7+gsFwfoO1kxk+8wbqDoH81f3vR/6mqTRfyXf8GI2UTymjMtrD DJJ9QtBFZOFWLWiGBgdAkd2Qd0pvg3WqhbT295Il8gvR1oFlDKHpF/yCuPehbNQ2FQJX29CzUXBK4 t2FXyEiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8DkK-0000000HAW3-1Phd; Sun, 20 Sep 2026 09:22:04 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8Djo-0000000HA2t-0VZO for linux-arm-kernel@lists.infradead.org; Sun, 20 Sep 2026 09:21:34 +0000 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 EF3D01650; Sun, 20 Sep 2026 02:21:27 -0700 (PDT) Received: from pluto.fritz.box (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9234A3F59E; Sun, 20 Sep 2026 02:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1789896091; bh=HnEcRC1YRZYszSkF2yhcRqz//Sgrtd8Yokg4b6YTq58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVYscqX/oD8fcYPyMUWyaQiA0wnpuhETquewmMkgfn8SyjD3Xu8T2sGSj1RfIs4pG oweYH/8YtX3y33ZSob8Nx6OGnUEJ4+k33jlH9KD4D4uE4Mni8V06GkLPvFzj4bwC3e FMi6HfBFLNmX1WVLBjX3KbLPOXRPyqsxm0/Rkxkc= 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 v12 19/25] firmware: arm_scmi: Add un-managed methods to get/put protocols operations Date: Sun, 20 Sep 2026 10:19:22 +0100 Message-ID: <20260920091928.2014972-20-cristian.marussi@arm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260920091928.2014972-1-cristian.marussi@arm.com> References: <20260920091928.2014972-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260920_022132_250817_C405EBDD X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 f5aca46bc608..6838a1d5f80a 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 4b44c9f503bc..ebe3ee6e7aaa 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