From patchwork Wed Dec 2 20:39:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 11947051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D43C64E7B for ; Wed, 2 Dec 2020 20:42:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D42D8205F4 for ; Wed, 2 Dec 2020 20:42:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D42D8205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=45UhFJB++flMFiTr3oOMegSE4odrRFL9Bz0U6lnAKno=; b=Cw3HQPyP6ewtjPxW8XpE2esRcg hln298Y9BhoeHeb+VVrkKvHxG/qEAmHwZKNCcstCEp/XzY+QwRhut+OmiKbZ7FBg8AqYzl4bl6dD5 Yi3NnETSj5Fb15DaxrF12hk7snFV2wq1Jlq7ofhMlO6DCfP8qjVytH9JBPD7PHVzJUhekkPCe2na7 vt8kZqTO2elF0jC+5jzWnmE6DBBDhOsV6pG9w8BJj+ROSPctB7Kgee6Y2S41y9Wsoi/rp7KcII7dN r5suyDqmLe71TZgvBecEOkrUDGuB6dpeAuiAjdf1fikJodT0rhN8u3xoD5T1VklgcJSUmS6UrhNKl vrp0mzpg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkYvs-0002Sa-DO; Wed, 02 Dec 2020 20:41:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkYvR-0002JX-F6 for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2020 20:40:35 +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 705071424; Wed, 2 Dec 2020 12:40:32 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BDD633F575; Wed, 2 Dec 2020 12:40:30 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 04/37] [RFC] firmware: arm_scmi: introduce bare get/put protocols ops Date: Wed, 2 Dec 2020 20:39:36 +0000 Message-Id: <20201202204009.32073-5-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201202204009.32073-1-cristian.marussi@arm.com> References: <20201202204009.32073-1-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201202_154033_802374_68E13054 X-CRM114-Status: GOOD ( 17.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, vincent.guittot@linaro.org, sudeep.holla@arm.com, thara.gopinath@linaro.org, Cristian Marussi , james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, souvik.chakravarty@arm.com, etienne.carriere@linaro.org, lukasz.luba@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Expose to the SCMI drivers a non managed version of a common protocols API based on generic get/put methods and protocol handles. All drivers still keep using the old API, no functional change. Signed-off-by: Cristian Marussi --- These non devres methods are probably not needed, given the devm_ ones are already provided and any SCMI driver (user of the API) has surely available an scmi_device reference to use in the devm_ flavour...so the RFC --- drivers/firmware/arm_scmi/driver.c | 34 ++++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 8 +++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index fbc3ba1b69f6..e6e760501587 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -710,6 +710,38 @@ void scmi_release_protocol(struct scmi_handle *handle, u8 protocol_id) mutex_unlock(&info->protocols_mtx); } +/** + * scmi_get_protocol_operations - Get protocol operations + * @handle: A reference to the SCMI platform instance. + * @protocol_id: The protocol being requested. + * @ph: A pointer reference used to pass back the associated protocol handle. + * + * Get hold of a protocol accounting for its usage, eventually triggering its + * initialization, and returning the protocol specific operations and related + * protocol handle which will be used as first argument in most of the protocols + * operations methods. + * + * Return: A reference to the requested protocol operations or error. + * Must be checked for errors by caller. + */ +static const void __must_check * +scmi_get_protocol_operations(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; +} + void scmi_setup_protocol_implemented(const struct scmi_handle *handle, u8 *prot_imp) { @@ -1078,6 +1110,8 @@ static int scmi_probe(struct platform_device *pdev) handle->version = &info->version; handle->devm_get_ops = scmi_devm_get_protocol_ops; handle->devm_put_ops = scmi_devm_put_protocol_ops; + handle->get_ops = scmi_get_protocol_operations; + handle->put_ops = scmi_release_protocol; ret = scmi_txrx_setup(info, dev, SCMI_PROTOCOL_BASE); if (ret) diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index b9bdb3f1d562..6a25054c3e7d 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -597,6 +597,9 @@ struct scmi_notify_ops { * @devm_get_ops: devres managed method to acquire a protocol and get specific * operations and a dedicated protocol handler * @devm_put_ops: devres managed method to release a protocol + * @get_ops: method to acquire a protocol and get specific operations and a + * dedicated protocol handler + * @put_ops: method to release a protocol * @notify_ops: pointer to set of notifications related operations * @perf_priv: pointer to private data structure specific to performance * protocol(for internal use only) @@ -628,6 +631,11 @@ struct scmi_handle { struct scmi_protocol_handle **ph); void (*devm_put_ops)(struct scmi_device *sdev, u8 proto); + const void __must_check * + (*get_ops)(struct scmi_handle *handle, u8 proto, + struct scmi_protocol_handle **ph); + void (*put_ops)(struct scmi_handle *handle, u8 proto); + const struct scmi_notify_ops *notify_ops; /* for protocol internal use */ void *perf_priv;