From patchwork Sun Feb 27 20:55:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12762135 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 5DE6EC433F5 for ; Sun, 27 Feb 2022 20:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Nzwj7qrPbUPlqYfP7/iVafWZmadkssmSgONDigqA7Ck=; b=OghHcZog7rA44J sfAVdkqI0P0BVzskBr2Uv7oxyySR+kiiqNuSpzNt6ZAPvsQWEsDBz90KLtTox+GbCZcZisaoD1vQj hb8HNtBQ0Wp4AFGnc/ybf2S7g8fFm6hMRaEvlVnGkzSbqXG85THRLhFeFjBA7jO7nntGTLYPDFuHv 0J8CoWyl3oVpqYklyXHcHxd1nX7LFjQKhAOJcpcE1J5VxZXf8+APwLjjNuCsy3g3bZtBBRHk3Tznl 6wc6sLDvFx2EbBwgsRjEwUw7sHfcgXwY+dlvKdcmWCq/gYoNzl9Ism5kLq8C9HvtG0OP/pdA54O9P DNxCu6RRKXD9inWHkvPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOQbK-00A7SA-Du; Sun, 27 Feb 2022 20:57:06 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOQah-00A7C3-QC for linux-arm-kernel@lists.infradead.org; Sun, 27 Feb 2022 20:56:29 +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 DEEEF12FC; Sun, 27 Feb 2022 12:56:26 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8359E3F66F; Sun, 27 Feb 2022 12:56:25 -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, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, peter.hilber@opensynergy.com, cristian.marussi@arm.com Subject: [RFC PATCH 03/16] firmware: arm_scmi: Add multiple protocols registration support Date: Sun, 27 Feb 2022 20:55:55 +0000 Message-Id: <20220227205608.30812-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220227205608.30812-1-cristian.marussi@arm.com> References: <20220227205608.30812-1-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_125627_973903_68DD9ED0 X-CRM114-Status: GOOD ( 15.49 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the capability for one SCMI driver to register with the core SCMI stack to use multiple SCMI protocols: in such a case the SCMI driver probe function will end up being called once for each registered protocol which have been also found as implemented on the platform. This is especially useful in testing scenarios. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/bus.c | 4 ++-- drivers/firmware/arm_scmi/common.h | 4 ++-- drivers/firmware/arm_scmi/driver.c | 24 ++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index f6fe723ab869..e417e84249f2 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -135,7 +135,7 @@ int scmi_driver_register(struct scmi_driver *driver, struct module *owner, if (!driver->probe) return -EINVAL; - retval = scmi_protocol_device_request(driver->id_table); + retval = scmi_protocol_table_register(driver->id_table); if (retval) return retval; @@ -155,7 +155,7 @@ EXPORT_SYMBOL_GPL(scmi_driver_register); void scmi_driver_unregister(struct scmi_driver *driver) { driver_unregister(&driver->driver); - scmi_protocol_device_unrequest(driver->id_table); + scmi_protocol_table_unregister(driver->id_table); } EXPORT_SYMBOL_GPL(scmi_driver_unregister); diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 4fda84bfab42..ffaf74a36b30 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -388,8 +388,8 @@ struct scmi_transport_ops { bool (*poll_done)(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer); }; -int scmi_protocol_device_request(const struct scmi_device_id *id_table); -void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table); +int scmi_protocol_table_register(const struct scmi_device_id *id_table); +void scmi_protocol_table_unregister(const struct scmi_device_id *id_table); struct scmi_device *scmi_child_dev_find(struct device *parent, int prot_id, const char *name); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 4cb9e0ad7af5..8d356d4da0bd 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1771,7 +1771,7 @@ static void scmi_create_protocol_devices(struct device_node *np, * * Return: 0 on Success */ -int scmi_protocol_device_request(const struct scmi_device_id *id_table) +static int scmi_protocol_device_request(const struct scmi_device_id *id_table) { int ret = 0; unsigned int id = 0; @@ -1882,6 +1882,17 @@ int scmi_protocol_device_request(const struct scmi_device_id *id_table) return ret; } +int scmi_protocol_table_register(const struct scmi_device_id *id_table) +{ + int ret = 0; + const struct scmi_device_id *entry; + + for (entry = id_table; entry->name && ret == 0; entry++) + ret = scmi_protocol_device_request(entry); + + return ret; +} + /** * scmi_protocol_device_unrequest - Helper to unrequest a device * @@ -1896,7 +1907,8 @@ int scmi_protocol_device_request(const struct scmi_device_id *id_table) * that cannot be safely destroyed till the whole SCMI stack is removed. * (unless adding further burden of refcounting.) */ -void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table) +static void +scmi_protocol_device_unrequest(const struct scmi_device_id *id_table) { struct list_head *phead; @@ -1925,6 +1937,14 @@ void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table) mutex_unlock(&scmi_requested_devices_mtx); } +void scmi_protocol_table_unregister(const struct scmi_device_id *id_table) +{ + const struct scmi_device_id *entry; + + for (entry = id_table; entry->name; entry++) + scmi_protocol_device_unrequest(entry); +} + static int scmi_cleanup_txrx_channels(struct scmi_info *info) { int ret;