From patchwork Tue Dec 7 08:08:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661265 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9085CC433FE for ; Tue, 7 Dec 2021 08:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42030 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229505AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B740hsf018633; Tue, 7 Dec 2021 09:08:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=7zsTBnorEjnmZcdGM+XPvc3la6MYGPR+Rw5pvL82FAI=; b=JwRv/QvOw4khR4XFOMTIIsLwAQl8co6Cts0qibLPJhVTZloIs6uxL20FBJ6R0xnqOH99 jqinwiKxArZMMGxBzXYb/BWIgz4DNmcg0RuczFmG8eZOK+lKzpJojP0NbeNmohLkHUC5 5jyBlpoi5sNq/iarLxgM3ZZo9W4fpu/b5odBCVVa2ZKa4ThOIIQrzISciyR2eyEE48M+ ejrJcxxPIDQM85XIjB74oLQY63SmRKxUN69AlY5rOouSckWr5eeXvmFzJ2za+ih4aYRx 9hJ/DlXuU3Q28Mbir9ph725I0ymc7siiq0JRW/0fV8SK7vn/OLYYj2W7+uCwQuqHeaHc aw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:54 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B42B7100034; Tue, 7 Dec 2021 09:08:53 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id A1DBC2220AF; Tue, 7 Dec 2021 09:08:53 +0100 (CET) Received: from localhost (10.75.127.49) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:53 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 01/13] rpmsg: char: Export eptdev create an destroy functions Date: Tue, 7 Dec 2021 09:08:31 +0100 Message-ID: <20211207080843.21222-2-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org To prepare the split of the code related to the control (ctrldev) and the endpoint (eptdev) devices in 2 separate files: - Rename and export the functions in rpmsg_char.h. - Suppress the dependency with the rpmsg_ctrldev struct in the rpmsg_eptdev_create function. Suggested-by: Mathieu Poirier Signed-off-by: Arnaud Pouliquen Reviewed-by: Bjorn Andersson --- Update vs previous revision: - suppress WARN_ON when CONFIG_RPMSG_CHAR not defined and return -ENXIO --- drivers/rpmsg/rpmsg_char.c | 18 +++++++++------ drivers/rpmsg/rpmsg_char.h | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 drivers/rpmsg/rpmsg_char.h diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index d6214cb66026..f7aa2dd302a5 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* + * Copyright (C) 2021, STMicroelectronics * Copyright (c) 2016, Linaro Ltd. * Copyright (c) 2012, Michal Simek * Copyright (c) 2012, PetaLogix @@ -25,6 +26,8 @@ #include #include +#include "rpmsg_char.h" + #define RPMSG_DEV_MAX (MINORMASK + 1) static dev_t rpmsg_major; @@ -79,7 +82,7 @@ struct rpmsg_eptdev { wait_queue_head_t readq; }; -static int rpmsg_eptdev_destroy(struct device *dev, void *data) +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) { struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev); @@ -98,6 +101,7 @@ static int rpmsg_eptdev_destroy(struct device *dev, void *data) return 0; } +EXPORT_SYMBOL(rpmsg_chrdev_eptdev_destroy); static int rpmsg_ept_cb(struct rpmsg_device *rpdev, void *buf, int len, void *priv, u32 addr) @@ -281,7 +285,7 @@ static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd, if (cmd != RPMSG_DESTROY_EPT_IOCTL) return -EINVAL; - return rpmsg_eptdev_destroy(&eptdev->dev, NULL); + return rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL); } static const struct file_operations rpmsg_eptdev_fops = { @@ -340,10 +344,9 @@ static void rpmsg_eptdev_release_device(struct device *dev) kfree(eptdev); } -static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, +int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, struct rpmsg_channel_info chinfo) { - struct rpmsg_device *rpdev = ctrldev->rpdev; struct rpmsg_eptdev *eptdev; struct device *dev; int ret; @@ -363,7 +366,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, device_initialize(dev); dev->class = rpmsg_class; - dev->parent = &ctrldev->dev; + dev->parent = parent; dev->groups = rpmsg_eptdev_groups; dev_set_drvdata(dev, eptdev); @@ -406,6 +409,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, return ret; } +EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) { @@ -445,7 +449,7 @@ static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, chinfo.src = eptinfo.src; chinfo.dst = eptinfo.dst; - return rpmsg_eptdev_create(ctrldev, chinfo); + return rpmsg_chrdev_eptdev_create(ctrldev->rpdev, &ctrldev->dev, chinfo); }; static const struct file_operations rpmsg_ctrldev_fops = { @@ -531,7 +535,7 @@ static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) int ret; /* Destroy all endpoints */ - ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_eptdev_destroy); + ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_chrdev_eptdev_destroy); if (ret) dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); diff --git a/drivers/rpmsg/rpmsg_char.h b/drivers/rpmsg/rpmsg_char.h new file mode 100644 index 000000000000..dd0a16f2acd1 --- /dev/null +++ b/drivers/rpmsg/rpmsg_char.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) STMicroelectronics 2021. + */ + +#ifndef __RPMSG_CHRDEV_H__ +#define __RPMSG_CHRDEV_H__ + +#if IS_ENABLED(CONFIG_RPMSG_CHAR) +/** + * rpmsg_chrdev_eptdev_create() - register char device based on an endpoint + * @rpdev: prepared rpdev to be used for creating endpoints + * @parent: parent device + * @chinfo: associated endpoint channel information. + * + * This function create a new rpmsg char endpoint device to instantiate a new + * endpoint based on chinfo information. + */ +int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, + struct rpmsg_channel_info chinfo); + +/** + * rpmsg_chrdev_eptdev_destroy() - destroy created char device endpoint. + * @data: private data associated to the endpoint device + * + * This function destroys a rpmsg char endpoint device created by the RPMSG_DESTROY_EPT_IOCTL + * control. + */ +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data); + +#else /*IS_ENABLED(CONFIG_RPMSG_CHAR) */ + +static inline int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, + struct rpmsg_channel_info chinfo) +{ + return -ENXIO; +} + +static inline int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) +{ + return -ENXIO; +} + +#endif /*IS_ENABLED(CONFIG_RPMSG_CHAR) */ + +#endif /*__RPMSG_CHRDEV_H__ */ From patchwork Tue Dec 7 08:08:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661267 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55026C433F5 for ; Tue, 7 Dec 2021 08:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbhLGIMj (ORCPT ); Tue, 7 Dec 2021 03:12:39 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40148 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230107AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B75RNPd021901; Tue, 7 Dec 2021 09:08:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=eshN3+K9TXtLzi8d6WwiLBLXYlbm6YlpUT5rkK6+HFs=; b=mnsJwCOp294xxTgYutBgF68k2TPGd05NOlfZB/sO7slFjI4SD07oTL5UcrNO0Ufm6gra sJt7001b4FFWJFujR5+PcaQJpsmQGo6ENo8WUNiBpgIyNWXpjtHYEmXr4WCspzgJLKPZ syDJwueWFOsEf7lK+E9l8uxwS7SlBMdxCJLib9UDIPCdPkRLUMzVfNZWm4t1Pgna3lwi cquiTTo8I/4FQNTrYLfTiPS0VGb0JueCVIxpeG28Lcqi+dcU78+9WT4GGA4K2V9xHSbq 64IuLP0RjAp2nQZvP2fMEua0JtlHc3yd1xlzluMAI4Ic95dbDgSflCFGEzonBTWZGD/f +A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3ct1fx8rfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:55 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 76122100038; Tue, 7 Dec 2021 09:08:54 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6AF012220AE; Tue, 7 Dec 2021 09:08:54 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:54 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 02/13] rpmsg: Create the rpmsg class in core instead of in rpmsg char Date: Tue, 7 Dec 2021 09:08:32 +0100 Message-ID: <20211207080843.21222-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Migrate the creation of the rpmsg class from the rpmsg_char to the core that the class is usable by the rpmsg_char and the future rpmsg_ctrl module. Suggested-by: Bjorn Andersson Signed-off-by: Arnaud Pouliquen Reviewed-by: Bjorn Andersson --- drivers/rpmsg/rpmsg_char.c | 11 +---------- drivers/rpmsg/rpmsg_core.c | 15 +++++++++++++-- drivers/rpmsg/rpmsg_internal.h | 2 ++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index f7aa2dd302a5..55f503aaf385 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -27,11 +27,11 @@ #include #include "rpmsg_char.h" +#include "rpmsg_internal.h" #define RPMSG_DEV_MAX (MINORMASK + 1) static dev_t rpmsg_major; -static struct class *rpmsg_class; static DEFINE_IDA(rpmsg_ctrl_ida); static DEFINE_IDA(rpmsg_ept_ida); @@ -561,17 +561,9 @@ static int rpmsg_chrdev_init(void) return ret; } - rpmsg_class = class_create(THIS_MODULE, "rpmsg"); - if (IS_ERR(rpmsg_class)) { - pr_err("failed to create rpmsg class\n"); - unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); - return PTR_ERR(rpmsg_class); - } - ret = register_rpmsg_driver(&rpmsg_chrdev_driver); if (ret < 0) { pr_err("failed to register rpmsg driver\n"); - class_destroy(rpmsg_class); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } @@ -582,7 +574,6 @@ postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { unregister_rpmsg_driver(&rpmsg_chrdev_driver); - class_destroy(rpmsg_class); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } module_exit(rpmsg_chrdev_exit); diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index f031b2b1b21c..d2129d3e6225 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -20,6 +20,9 @@ #include "rpmsg_internal.h" +struct class *rpmsg_class; +EXPORT_SYMBOL(rpmsg_class); + /** * rpmsg_create_channel() - create a new rpmsg channel * using its name and address info. @@ -650,10 +653,17 @@ static int __init rpmsg_init(void) { int ret; + rpmsg_class = class_create(THIS_MODULE, "rpmsg"); + if (IS_ERR(rpmsg_class)) { + pr_err("failed to create rpmsg class\n"); + return PTR_ERR(rpmsg_class); + } + ret = bus_register(&rpmsg_bus); - if (ret) + if (ret) { pr_err("failed to register rpmsg bus: %d\n", ret); - + class_destroy(rpmsg_class); + } return ret; } postcore_initcall(rpmsg_init); @@ -661,6 +671,7 @@ postcore_initcall(rpmsg_init); static void __exit rpmsg_fini(void) { bus_unregister(&rpmsg_bus); + class_destroy(rpmsg_class); } module_exit(rpmsg_fini); diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index b1245d3ed7c6..416316200bde 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -18,6 +18,8 @@ #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) +extern struct class *rpmsg_class; + /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations * @create_channel: create backend-specific channel, optional From patchwork Tue Dec 7 08:08:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661271 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5BAAC433FE for ; Tue, 7 Dec 2021 08:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbhLGIMk (ORCPT ); Tue, 7 Dec 2021 03:12:40 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42058 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231527AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B740hsh018633; Tue, 7 Dec 2021 09:08:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=2JwXvFsdkZviVM5jcAtXpSzgHpLjYYD6f5OGa7PXVIY=; b=N3rncEUMXnnNzsiuAnBTiI0QBM5BC7U64WyblXaKNqGon+Yb2jEgmxTZk4Nw3bhqNPQi ZZXLxA/3s5tfiponthSsjMoEw3tOJwz+Bpi/GwcTKf71mhTNqlqEQ18XVjyAkaSCF6st CEsXYyIDtKAboJ/WTCsMgtUVmCjkNLvc2zhlHZetqli9VnYsKcIRJVjHY7KBUMFRj2K8 HfBW5uDmbXii/5gwQBmKfRfSbhpj756pgat5BucMBoVLe44yGj2/ilEJpTf3/pSGdReD COsgaONJ0eoiJUl92Q95gPnBpCYJlNb4zmuhKKpzGaIZJgWT82NCMLJNFVDbI5XaXc05 3g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:57 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6666A10002A; Tue, 7 Dec 2021 09:08:55 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5EAFF2220AF; Tue, 7 Dec 2021 09:08:55 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:54 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 03/13] rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl Date: Tue, 7 Dec 2021 09:08:33 +0100 Message-ID: <20211207080843.21222-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Create the rpmsg_ctrl.c module and move the code related to the rpmsg_ctrldev device in this new module. Add the dependency between rpmsg_char and rpmsg_ctrl in the kconfig file: 1) RPMSG_CTRL can set as module or built-in if RPMSG=y || RPMSG_CHAR=y || RPMSG_CHAR=n 2) RPMSG_CTRL can not be set as built-in if RPMSG=m || RPMSG_CHAR=m Note that RPMGH_CHAR and RPMSG_CTRL can be activated separately. Therefore, the RPMSG_CTRL configuration must be set for backwards compatibility. Signed-off-by: Arnaud Pouliquen Reviewed-by: Bjorn Andersson --- drivers/rpmsg/Kconfig | 8 ++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_char.c | 167 +--------------------------- drivers/rpmsg/rpmsg_ctrl.c | 219 +++++++++++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+), 165 deletions(-) create mode 100644 drivers/rpmsg/rpmsg_ctrl.c diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 0b4407abdf13..d3795860f5c0 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -15,6 +15,14 @@ config RPMSG_CHAR in /dev. They make it possible for user-space programs to send and receive rpmsg packets. +config RPMSG_CTRL + tristate "RPMSG control interface" + depends on RPMSG && ( RPMSG_CHAR || RPMSG_CHAR=n ) + help + Say Y here to enable the support of the /dev/rpmsg_ctrlX API. This API + allows user-space programs to create endpoints with specific service name, + source and destination addresses. + config RPMSG_NS tristate "RPMSG name service announcement" depends on RPMSG diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index 8d452656f0ee..58e3b382e316 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_RPMSG) += rpmsg_core.o obj-$(CONFIG_RPMSG_CHAR) += rpmsg_char.o +obj-$(CONFIG_RPMSG_CTRL) += rpmsg_ctrl.o obj-$(CONFIG_RPMSG_NS) += rpmsg_ns.o obj-$(CONFIG_RPMSG_MTK_SCP) += mtk_rpmsg.o qcom_glink-objs := qcom_glink_native.o qcom_glink_ssr.o diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 55f503aaf385..fab42964bcbb 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -33,28 +33,12 @@ static dev_t rpmsg_major; -static DEFINE_IDA(rpmsg_ctrl_ida); static DEFINE_IDA(rpmsg_ept_ida); static DEFINE_IDA(rpmsg_minor_ida); #define dev_to_eptdev(dev) container_of(dev, struct rpmsg_eptdev, dev) #define cdev_to_eptdev(i_cdev) container_of(i_cdev, struct rpmsg_eptdev, cdev) -#define dev_to_ctrldev(dev) container_of(dev, struct rpmsg_ctrldev, dev) -#define cdev_to_ctrldev(i_cdev) container_of(i_cdev, struct rpmsg_ctrldev, cdev) - -/** - * struct rpmsg_ctrldev - control device for instantiating endpoint devices - * @rpdev: underlaying rpmsg device - * @cdev: cdev for the ctrl device - * @dev: device for the ctrl device - */ -struct rpmsg_ctrldev { - struct rpmsg_device *rpdev; - struct cdev cdev; - struct device dev; -}; - /** * struct rpmsg_eptdev - endpoint device context * @dev: endpoint device @@ -411,169 +395,22 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent } EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); -static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) -{ - struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); - - get_device(&ctrldev->dev); - filp->private_data = ctrldev; - - return 0; -} - -static int rpmsg_ctrldev_release(struct inode *inode, struct file *filp) -{ - struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); - - put_device(&ctrldev->dev); - - return 0; -} - -static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, - unsigned long arg) -{ - struct rpmsg_ctrldev *ctrldev = fp->private_data; - void __user *argp = (void __user *)arg; - struct rpmsg_endpoint_info eptinfo; - struct rpmsg_channel_info chinfo; - - if (cmd != RPMSG_CREATE_EPT_IOCTL) - return -EINVAL; - - if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) - return -EFAULT; - - memcpy(chinfo.name, eptinfo.name, RPMSG_NAME_SIZE); - chinfo.name[RPMSG_NAME_SIZE-1] = '\0'; - chinfo.src = eptinfo.src; - chinfo.dst = eptinfo.dst; - - return rpmsg_chrdev_eptdev_create(ctrldev->rpdev, &ctrldev->dev, chinfo); -}; - -static const struct file_operations rpmsg_ctrldev_fops = { - .owner = THIS_MODULE, - .open = rpmsg_ctrldev_open, - .release = rpmsg_ctrldev_release, - .unlocked_ioctl = rpmsg_ctrldev_ioctl, - .compat_ioctl = compat_ptr_ioctl, -}; - -static void rpmsg_ctrldev_release_device(struct device *dev) -{ - struct rpmsg_ctrldev *ctrldev = dev_to_ctrldev(dev); - - ida_simple_remove(&rpmsg_ctrl_ida, dev->id); - ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); - cdev_del(&ctrldev->cdev); - kfree(ctrldev); -} - -static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) -{ - struct rpmsg_ctrldev *ctrldev; - struct device *dev; - int ret; - - ctrldev = kzalloc(sizeof(*ctrldev), GFP_KERNEL); - if (!ctrldev) - return -ENOMEM; - - ctrldev->rpdev = rpdev; - - dev = &ctrldev->dev; - device_initialize(dev); - dev->parent = &rpdev->dev; - dev->class = rpmsg_class; - - cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops); - ctrldev->cdev.owner = THIS_MODULE; - - ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); - if (ret < 0) - goto free_ctrldev; - dev->devt = MKDEV(MAJOR(rpmsg_major), ret); - - ret = ida_simple_get(&rpmsg_ctrl_ida, 0, 0, GFP_KERNEL); - if (ret < 0) - goto free_minor_ida; - dev->id = ret; - dev_set_name(&ctrldev->dev, "rpmsg_ctrl%d", ret); - - ret = cdev_add(&ctrldev->cdev, dev->devt, 1); - if (ret) - goto free_ctrl_ida; - - /* We can now rely on the release function for cleanup */ - dev->release = rpmsg_ctrldev_release_device; - - ret = device_add(dev); - if (ret) { - dev_err(&rpdev->dev, "device_add failed: %d\n", ret); - put_device(dev); - } - - dev_set_drvdata(&rpdev->dev, ctrldev); - - return ret; - -free_ctrl_ida: - ida_simple_remove(&rpmsg_ctrl_ida, dev->id); -free_minor_ida: - ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); -free_ctrldev: - put_device(dev); - kfree(ctrldev); - - return ret; -} - -static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) -{ - struct rpmsg_ctrldev *ctrldev = dev_get_drvdata(&rpdev->dev); - int ret; - - /* Destroy all endpoints */ - ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_chrdev_eptdev_destroy); - if (ret) - dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); - - device_del(&ctrldev->dev); - put_device(&ctrldev->dev); -} - -static struct rpmsg_driver rpmsg_chrdev_driver = { - .probe = rpmsg_chrdev_probe, - .remove = rpmsg_chrdev_remove, - .drv = { - .name = "rpmsg_chrdev", - }, -}; - static int rpmsg_chrdev_init(void) { int ret; - ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg"); + ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg_char"); if (ret < 0) { pr_err("failed to allocate char dev region\n"); return ret; } - ret = register_rpmsg_driver(&rpmsg_chrdev_driver); - if (ret < 0) { - pr_err("failed to register rpmsg driver\n"); - unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); - } - - return ret; + return 0; } postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { - unregister_rpmsg_driver(&rpmsg_chrdev_driver); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } module_exit(rpmsg_chrdev_exit); diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c new file mode 100644 index 000000000000..33c38cbf2b83 --- /dev/null +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021, STMicroelectronics + * Copyright (c) 2016, Linaro Ltd. + * Copyright (c) 2012, Michal Simek + * Copyright (c) 2012, PetaLogix + * Copyright (c) 2011, Texas Instruments, Inc. + * Copyright (c) 2011, Google, Inc. + * + * Based on rpmsg performance statistics driver by Michal Simek, which in turn + * was based on TI & Google OMX rpmsg driver. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rpmsg_char.h" +#include "rpmsg_internal.h" + +#define RPMSG_DEV_MAX (MINORMASK + 1) + +static dev_t rpmsg_major; + +static DEFINE_IDA(rpmsg_ctrl_ida); +static DEFINE_IDA(rpmsg_minor_ida); + +#define dev_to_ctrldev(dev) container_of(dev, struct rpmsg_ctrldev, dev) +#define cdev_to_ctrldev(i_cdev) container_of(i_cdev, struct rpmsg_ctrldev, cdev) + +/** + * struct rpmsg_ctrldev - control device for instantiating endpoint devices + * @rpdev: underlaying rpmsg device + * @cdev: cdev for the ctrl device + * @dev: device for the ctrl device + */ +struct rpmsg_ctrldev { + struct rpmsg_device *rpdev; + struct cdev cdev; + struct device dev; +}; + +static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) +{ + struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); + + get_device(&ctrldev->dev); + filp->private_data = ctrldev; + + return 0; +} + +static int rpmsg_ctrldev_release(struct inode *inode, struct file *filp) +{ + struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); + + put_device(&ctrldev->dev); + + return 0; +} + +static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, + unsigned long arg) +{ + struct rpmsg_ctrldev *ctrldev = fp->private_data; + void __user *argp = (void __user *)arg; + struct rpmsg_endpoint_info eptinfo; + struct rpmsg_channel_info chinfo; + + if (cmd != RPMSG_CREATE_EPT_IOCTL) + return -EINVAL; + + if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) + return -EFAULT; + + memcpy(chinfo.name, eptinfo.name, RPMSG_NAME_SIZE); + chinfo.name[RPMSG_NAME_SIZE - 1] = '\0'; + chinfo.src = eptinfo.src; + chinfo.dst = eptinfo.dst; + + return rpmsg_chrdev_eptdev_create(ctrldev->rpdev, &ctrldev->dev, chinfo); +}; + +static const struct file_operations rpmsg_ctrldev_fops = { + .owner = THIS_MODULE, + .open = rpmsg_ctrldev_open, + .release = rpmsg_ctrldev_release, + .unlocked_ioctl = rpmsg_ctrldev_ioctl, + .compat_ioctl = compat_ptr_ioctl, +}; + +static void rpmsg_ctrldev_release_device(struct device *dev) +{ + struct rpmsg_ctrldev *ctrldev = dev_to_ctrldev(dev); + + ida_simple_remove(&rpmsg_ctrl_ida, dev->id); + ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); + cdev_del(&ctrldev->cdev); + kfree(ctrldev); +} + +static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_ctrldev *ctrldev; + struct device *dev; + int ret; + + ctrldev = kzalloc(sizeof(*ctrldev), GFP_KERNEL); + if (!ctrldev) + return -ENOMEM; + + ctrldev->rpdev = rpdev; + + dev = &ctrldev->dev; + device_initialize(dev); + dev->parent = &rpdev->dev; + dev->class = rpmsg_class; + + cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops); + ctrldev->cdev.owner = THIS_MODULE; + + ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); + if (ret < 0) + goto free_ctrldev; + dev->devt = MKDEV(MAJOR(rpmsg_major), ret); + + ret = ida_simple_get(&rpmsg_ctrl_ida, 0, 0, GFP_KERNEL); + if (ret < 0) + goto free_minor_ida; + dev->id = ret; + dev_set_name(&ctrldev->dev, "rpmsg_ctrl%d", ret); + + ret = cdev_add(&ctrldev->cdev, dev->devt, 1); + if (ret) + goto free_ctrl_ida; + + /* We can now rely on the release function for cleanup */ + dev->release = rpmsg_ctrldev_release_device; + + ret = device_add(dev); + if (ret) { + dev_err(&rpdev->dev, "device_add failed: %d\n", ret); + put_device(dev); + } + + dev_set_drvdata(&rpdev->dev, ctrldev); + + return ret; + +free_ctrl_ida: + ida_simple_remove(&rpmsg_ctrl_ida, dev->id); +free_minor_ida: + ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); +free_ctrldev: + put_device(dev); + kfree(ctrldev); + + return ret; +} + +static void rpmsg_ctrldev_remove(struct rpmsg_device *rpdev) +{ + struct rpmsg_ctrldev *ctrldev = dev_get_drvdata(&rpdev->dev); + int ret; + + /* Destroy all endpoints */ + ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_chrdev_eptdev_destroy); + if (ret) + dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); + + device_del(&ctrldev->dev); + put_device(&ctrldev->dev); +} + +static struct rpmsg_driver rpmsg_ctrldev_driver = { + .probe = rpmsg_ctrldev_probe, + .remove = rpmsg_ctrldev_remove, + .drv = { + .name = "rpmsg_chrdev", + }, +}; + +static int rpmsg_ctrldev_init(void) +{ + int ret; + + ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg_ctrl"); + if (ret < 0) { + pr_err("rpmsg: failed to allocate char dev region\n"); + return ret; + } + + ret = register_rpmsg_driver(&rpmsg_ctrldev_driver); + if (ret < 0) { + pr_err("rpmsg ctrl: failed to register rpmsg driver\n"); + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); + } + + return ret; +} +postcore_initcall(rpmsg_ctrldev_init); + +static void rpmsg_ctrldev_exit(void) +{ + unregister_rpmsg_driver(&rpmsg_ctrldev_driver); + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); +} +module_exit(rpmsg_ctrldev_exit); + +MODULE_DESCRIPTION("rpmsg control interface"); +MODULE_ALIAS("rpmsg:" KBUILD_MODNAME); +MODULE_LICENSE("GPL v2"); From patchwork Tue Dec 7 08:08:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661277 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73793C433EF for ; Tue, 7 Dec 2021 08:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbhLGIMv (ORCPT ); Tue, 7 Dec 2021 03:12:51 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42136 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232116AbhLGIMs (ORCPT ); Tue, 7 Dec 2021 03:12:48 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B740pnI018749; Tue, 7 Dec 2021 09:08:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=WVV3d8UaMvdSQRl6d9OtZ06ffGfZw5TE8gaN7pqT5gE=; b=5IYwRgNuM8xgjt4uEFyCZpygaLh+OUzl5iFZTdNwX00Ro3l/oUZhRQjLwD29+cecy6Js TG5rT5YTn2AUx+8y8kxFKCOyhUIQ/5Cu9Ss5nb1pvqynKO6r+8Sg2u9JihWcIFKvayS6 TwHgwrnlZCvGVCMPmr/y7oBf+Ivze8OfBP05rSIka9lR22/2eqjRwh9u+qlE6uXgPuK6 jqH0RmWBtSLY0PW/DdIepXfatXSbltBuDgk3/eILau6fv6o98BiIPeHnEKb3aYLvT8Jl devkhN6cvTdDEAhlqc5E41xTGzmUFpWDNzQ8aXIRBv6vSrxMELyjakRUIzfmE47P5++o Jg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:56 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 412E1100034; Tue, 7 Dec 2021 09:08:56 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 388F22220AF; Tue, 7 Dec 2021 09:08:56 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:55 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , , Subject: [PATCH v8 04/13] arm: configs: Configs that had RPMSG_CHAR now get RPMSG_CTRL Date: Tue, 7 Dec 2021 09:08:34 +0100 Message-ID: <20211207080843.21222-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org In the patch "rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl", we split the rpmsg_char driver in two. By default give everyone who had the old driver enabled the rpmsg_ctrl driver too. Signed-off-by: Arnaud Pouliquen cc: linux-arm-kernel@lists.infradead.org --- arch/arm/configs/qcom_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/qcom_defconfig b/arch/arm/configs/qcom_defconfig index 0daa9c0d298e..b76d2a2ea0a2 100644 --- a/arch/arm/configs/qcom_defconfig +++ b/arch/arm/configs/qcom_defconfig @@ -242,6 +242,7 @@ CONFIG_QCOM_Q6V5_PAS=y CONFIG_QCOM_Q6V5_PIL=y CONFIG_QCOM_WCNSS_PIL=y CONFIG_RPMSG_CHAR=y +CONFIG_RPMSG_CTRL=y CONFIG_RPMSG_QCOM_GLINK_SMEM=y CONFIG_RPMSG_QCOM_SMD=y CONFIG_QCOM_COMMAND_DB=y From patchwork Tue Dec 7 08:08:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661281 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FD3DC433FE for ; Tue, 7 Dec 2021 08:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbhLGIMx (ORCPT ); Tue, 7 Dec 2021 03:12:53 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42116 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232103AbhLGIMr (ORCPT ); Tue, 7 Dec 2021 03:12:47 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B749etT019774; Tue, 7 Dec 2021 09:08:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=1iFAiZpj3lcqsYiUsA/qSLmnf8mKGkPBOz81mbNrNmI=; b=hessX9aaSNEpvixfK1yGxrYrXtzHeOAf2A5Fz/5NlyjodnwoA0fbNCAyJOcYju45b//q TQswnHvn7Kbi+Z20p1vTmnsggydaG+o5eSQRB7bgAmt0hut9PqkhjVeYI1iY9ebwhWEs mR219JcKgN9TZ4We4OeZj42/Y9ggNnbUNR0SWao32vFkM6XCgUJn/zhoadWn01J9Y7sg x7Lp7FIYKQ+coN8awDNcVKN9sdfZtrT5NAuN30U2SETIB0uadVb6PR95JdDaYVocvmIa MXC0EoeUb/t0leiSXwS3xtqA/3e/7M/CW7PFKF7KttkUVGLAxelYT50CS3gyBQwoEQkM BA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:57 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 033D8100038; Tue, 7 Dec 2021 09:08:57 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id F13862220B0; Tue, 7 Dec 2021 09:08:56 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:56 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , , Subject: [PATCH v8 05/13] RISC-V: configs: Configs that had RPMSG_CHAR now get RPMSG_CTRL Date: Tue, 7 Dec 2021 09:08:35 +0100 Message-ID: <20211207080843.21222-6-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org In the patch "rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl", we split the rpmsg_char driver in two. By default give everyone who had the old driver enabled the rpmsg_ctrl driver too. Signed-off-by: Arnaud Pouliquen cc: linux-riscv@lists.infradead.org Reviewed-by: Anup Patel --- arch/riscv/configs/defconfig | 1 + arch/riscv/configs/rv32_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index c252fd5706d2..c0439d3ffb8c 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -97,6 +97,7 @@ CONFIG_VIRTIO_BALLOON=y CONFIG_VIRTIO_INPUT=y CONFIG_VIRTIO_MMIO=y CONFIG_RPMSG_CHAR=y +CONFIG_RPMSG_CTRL=y CONFIG_RPMSG_VIRTIO=y CONFIG_EXT4_FS=y CONFIG_EXT4_FS_POSIX_ACL=y diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv32_defconfig index 434ef5b64599..99eabad7ca0f 100644 --- a/arch/riscv/configs/rv32_defconfig +++ b/arch/riscv/configs/rv32_defconfig @@ -89,6 +89,7 @@ CONFIG_VIRTIO_BALLOON=y CONFIG_VIRTIO_INPUT=y CONFIG_VIRTIO_MMIO=y CONFIG_RPMSG_CHAR=y +CONFIG_RPMSG_CTRL=y CONFIG_RPMSG_VIRTIO=y CONFIG_EXT4_FS=y CONFIG_EXT4_FS_POSIX_ACL=y From patchwork Tue Dec 7 08:08:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661279 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23DABC433EF for ; Tue, 7 Dec 2021 08:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232199AbhLGIMw (ORCPT ); Tue, 7 Dec 2021 03:12:52 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42114 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232101AbhLGIMq (ORCPT ); Tue, 7 Dec 2021 03:12:46 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B749etU019774; Tue, 7 Dec 2021 09:08:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=qquEqQQfTwFJc/VbXxhf77Z3Tf2disQV9OX8y/t31G4=; b=JCXArjhX008JMNQToBJi4UskMsQLm6Bopisu+ELgneFINdo6zn+ntZyvTd316LHabsJF n4McfXM+w3m0o7eNjITSjVVmksLlEQWQjplyZKMpMOG7FRypmnPnRVzpJGNTzRD9uwsY ufekuxVKAQ/sk70W16av/vOg9AKJYf1NkEqM5BFzhAMoghYzCwbnkYmPAwUq0bXhbOV5 HwyU9SLhebx3kQNYlHFu6cCZf5wnfgw1sCtv5s+GVDhClV4poeU+V1gXthlMCN8nFweH G8TVFdno7tidCrztsVMIGXQj9pSlxUJeif9ZWwGJ+HQbmY4UU7URdMX64kxC41VLKrgC nw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:58 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B3A2E10002A; Tue, 7 Dec 2021 09:08:57 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id ABB0B2220B0; Tue, 7 Dec 2021 09:08:57 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:57 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , , Subject: [PATCH v8 06/13] arm64: defconfig: Config that had RPMSG_CHAR now gets RPMSG_CTRL Date: Tue, 7 Dec 2021 09:08:36 +0100 Message-ID: <20211207080843.21222-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org In the patch "rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl", we split the rpmsg_char driver in two. By default give everyone who had the old driver enabled the rpmsg_ctrl driver too. Signed-off-by: Arnaud Pouliquen cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index f2e2b9bdd702..34e721f1d561 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -1029,6 +1029,7 @@ CONFIG_QCOM_Q6V5_PAS=m CONFIG_QCOM_SYSMON=m CONFIG_QCOM_WCNSS_PIL=m CONFIG_RPMSG_CHAR=m +CONFIG_RPMSG_CTRL=m CONFIG_RPMSG_QCOM_GLINK_RPM=y CONFIG_RPMSG_QCOM_GLINK_SMEM=m CONFIG_RPMSG_QCOM_SMD=y From patchwork Tue Dec 7 08:08:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661269 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BC4FC43217 for ; Tue, 7 Dec 2021 08:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbhLGIMj (ORCPT ); Tue, 7 Dec 2021 03:12:39 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40154 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231319AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B75RNgu021902; Tue, 7 Dec 2021 09:08:59 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=nuURO2W1SWhsAI0sfv3vm7CocfSqChGxGc5QjbrslfA=; b=awLvh8qQICL/HqFha1BbUd6OI5hphEnErPEyteey9V5A3gf9i3jKnRWcFNLARzEEDPad obGX8fW+Jwd1M3Y3xo4QlyIxVhEZWReQO3DQW+Xe7hvegA2XmVCPpgZUVrBDpbhDibUA 5x2F0LHRLuSYM1MX1EIlBgR3GwInIQdEVCGLTdCHZJchLow4IsZ353K/uUKEdFmh2uhX LmF5J7YWkG8TBLEI9oRg1TeE9RYMm5Ua5OCsURX8O4cMNC7JgiCNJkKVH7EzxbRtnavL lhXWrE7M3JnkN4fwUGos3+scAJi5oV7Zb3Ixfd9WCvLrz1GELdNsVs+JfNS2cP3E4OLf 1A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3ct1fx8rgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:59 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8326F100038; Tue, 7 Dec 2021 09:08:58 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7B5E22220AE; Tue, 7 Dec 2021 09:08:58 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:58 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 07/13] rpmsg: Update rpmsg_chrdev_register_device function Date: Tue, 7 Dec 2021 09:08:37 +0100 Message-ID: <20211207080843.21222-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The rpmsg_chrdev driver has been replaced by the rpmsg_ctrl driver for the /dev/rpmsg_ctrlX devices management. The reference for the driver override is now the rpmsg_ctrl. Update the rpmsg_chrdev_register_device function to reflect the update, and rename the function to use the rpmsg_ctrldev prefix. The platform drivers are updated accordingly. Signed-off-by: Arnaud Pouliquen Reviewed-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 2 +- drivers/rpmsg/qcom_smd.c | 2 +- drivers/rpmsg/rpmsg_ctrl.c | 2 +- drivers/rpmsg/rpmsg_internal.h | 8 ++++---- drivers/rpmsg/virtio_rpmsg_bus.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 1030cfa80e04..cf2c057b738c 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1715,7 +1715,7 @@ static int qcom_glink_create_chrdev(struct qcom_glink *glink) rpdev->dev.parent = glink->dev; rpdev->dev.release = qcom_glink_device_release; - return rpmsg_chrdev_register_device(rpdev); + return rpmsg_ctrldev_register_device(rpdev); } struct qcom_glink *qcom_glink_native_probe(struct device *dev, diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 540e027f08c4..cd623e3e8aa9 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1113,7 +1113,7 @@ static int qcom_smd_create_chrdev(struct qcom_smd_edge *edge) qsdev->rpdev.dev.parent = &edge->dev; qsdev->rpdev.dev.release = qcom_smd_release_device; - return rpmsg_chrdev_register_device(&qsdev->rpdev); + return rpmsg_ctrldev_register_device(&qsdev->rpdev); } /* diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 33c38cbf2b83..59d2bd264fdb 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -183,7 +183,7 @@ static struct rpmsg_driver rpmsg_ctrldev_driver = { .probe = rpmsg_ctrldev_probe, .remove = rpmsg_ctrldev_remove, .drv = { - .name = "rpmsg_chrdev", + .name = "rpmsg_ctrl", }, }; diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 416316200bde..d4b23fd019a8 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -86,16 +86,16 @@ struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev, int rpmsg_release_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); /** - * rpmsg_chrdev_register_device() - register chrdev device based on rpdev + * rpmsg_ctrldev_register_device() - register a char device for control based on rpdev * @rpdev: prepared rpdev to be used for creating endpoints * * This function wraps rpmsg_register_device() preparing the rpdev for use as * basis for the rpmsg chrdev. */ -static inline int rpmsg_chrdev_register_device(struct rpmsg_device *rpdev) +static inline int rpmsg_ctrldev_register_device(struct rpmsg_device *rpdev) { - strcpy(rpdev->id.name, "rpmsg_chrdev"); - rpdev->driver_override = "rpmsg_chrdev"; + strcpy(rpdev->id.name, "rpmsg_ctrl"); + rpdev->driver_override = "rpmsg_ctrl"; return rpmsg_register_device(rpdev); } diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index c37451512835..7f786cc70df9 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -849,7 +849,7 @@ static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev rpdev_ctrl->dev.release = virtio_rpmsg_release_device; rpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev); - err = rpmsg_chrdev_register_device(rpdev_ctrl); + err = rpmsg_ctrldev_register_device(rpdev_ctrl); if (err) { kfree(vch); return ERR_PTR(err); From patchwork Tue Dec 7 08:08:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661275 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E311C433F5 for ; Tue, 7 Dec 2021 08:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230107AbhLGIMm (ORCPT ); Tue, 7 Dec 2021 03:12:42 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42060 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231543AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B743N6v019282; Tue, 7 Dec 2021 09:08:59 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=/8mhOl8RofCa/gcd5Sw/vgwh6rK5f5gsqSHmOrvc1JI=; b=MckttOhNGuy2Mg1eUcGv1aOfd/ptjUQpTiqawFGgQdXFrvMQ0DYumHPnTOXFqrYlQcq7 bizHiXtiuxpU8RH5tS7fPyV9WjzjDrMXfOQxChhyiTzoE/nOrSlETl9Fl1onEocM0rq7 /oXc49qJigQ+iLKM5TpEcZqnPmsOh046aHEYqpXSDvMJWV9KIYl0UqVhUOP78vQXI279 2suNHsxWKPf8fUvQuoVispgGTzeAkLYzezFOeIs93VEhfMSk8LHovom3X4GqQVPKcMzW nAie9vofB/aCjMrCjlma160yH76zwW+jXuj72QGaArGcqxD1l7R6Llf4WRghi9m1eHMY 1w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:59 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4ADA110002A; Tue, 7 Dec 2021 09:08:59 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 432312220B0; Tue, 7 Dec 2021 09:08:59 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:58 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 08/13] rpmsg: char: Refactor rpmsg_chrdev_eptdev_create function Date: Tue, 7 Dec 2021 09:08:38 +0100 Message-ID: <20211207080843.21222-9-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce the rpmsg_chrdev_eptdev_alloc and rpmsg_chrdev_eptdev_add internal function to split the allocation part from the device add. This patch prepares the introduction of a rpmsg channel device for the char device. An default endpoint will be created, referenced in the rpmsg_eptdev structure before adding the devices. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index fab42964bcbb..a39f19161cd6 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -328,20 +328,18 @@ static void rpmsg_eptdev_release_device(struct device *dev) kfree(eptdev); } -int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, - struct rpmsg_channel_info chinfo) +static struct rpmsg_eptdev *rpmsg_chrdev_eptdev_alloc(struct rpmsg_device *rpdev, + struct device *parent) { struct rpmsg_eptdev *eptdev; struct device *dev; - int ret; eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL); if (!eptdev) - return -ENOMEM; + return ERR_PTR(-ENOMEM); dev = &eptdev->dev; eptdev->rpdev = rpdev; - eptdev->chinfo = chinfo; mutex_init(&eptdev->ept_lock); spin_lock_init(&eptdev->queue_lock); @@ -357,6 +355,16 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent cdev_init(&eptdev->cdev, &rpmsg_eptdev_fops); eptdev->cdev.owner = THIS_MODULE; + return eptdev; +} + +static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_channel_info chinfo) +{ + struct device *dev = &eptdev->dev; + int ret; + + eptdev->chinfo = chinfo; + ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); if (ret < 0) goto free_eptdev; @@ -393,6 +401,21 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent return ret; } + +int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, + struct rpmsg_channel_info chinfo) +{ + struct rpmsg_eptdev *eptdev; + int ret; + + eptdev = rpmsg_chrdev_eptdev_alloc(rpdev, parent); + if (IS_ERR(eptdev)) + return PTR_ERR(eptdev); + + ret = rpmsg_chrdev_eptdev_add(eptdev, chinfo); + + return ret; +} EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); static int rpmsg_chrdev_init(void) From patchwork Tue Dec 7 08:08:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661273 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA39C4332F for ; Tue, 7 Dec 2021 08:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbhLGIMn (ORCPT ); Tue, 7 Dec 2021 03:12:43 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42062 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231181AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B740pnJ018749; Tue, 7 Dec 2021 09:09:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=S23BQfuWjC3JI4sYe7w7IBbRYjP4Miyc0PMhSA/fiqU=; b=I95lSol6/Y7xEcEVTUW985hC0YxmhXvl0tDsD9ODrgw3dkoqojkntJ6qDpzli5L0mTsI ByoGJSp07OF+XMC2mOIk7UMSv2z6i96BjDoFGezrXI6HVvbzoGKa799LU+Mml3otlCc0 Riv0GkvYPKsf32q6whYhKhyPAGl0ij9WL+YWNBa1gLMjhFnYyJUY6pQhLJk7fSDEyA3z 3+3f2d8QMR/vMFIl02XkdiArmh7LnN1DewZhHkrD9kxsbd7L4cULUJ3Z8n8w1iD4/2Mc 9TmgZ/5FOtW+jocLm4dZncxrfDVl6qBMm5W/9C2JHX3TAvyS1r2NVcm+dONRJQTIsQTu Pw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bc9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:09:00 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1FA37100034; Tue, 7 Dec 2021 09:09:00 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 16F5F2220B0; Tue, 7 Dec 2021 09:09:00 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:59 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 09/13] rpmsg: Introduce rpmsg_create_default_ept function Date: Tue, 7 Dec 2021 09:08:39 +0100 Message-ID: <20211207080843.21222-10-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org By providing a callback in the rpmsg_driver structure, the rpmsg devices can be probed with a default endpoint created. In this case, it is not possible to associated to this endpoint private data that could allow the driver to retrieve the context. This helper function allows rpmsg drivers to create a default endpoint on runtime with an associated private context. For example, a driver might create a context structure on the probe and want to provide that context as private data for the default rpmsg callback. Signed-off-by: Arnaud Pouliquen Reviewed-by: Mathieu Poirier Tested-by: Julien Massot --- drivers/rpmsg/rpmsg_core.c | 54 ++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 4 +++ 2 files changed, 58 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index d2129d3e6225..3f86512147e8 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -133,6 +133,60 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *ept) } EXPORT_SYMBOL(rpmsg_destroy_ept); +/** + * rpmsg_create_default_ept() - create a default rpmsg_endpoint for a rpmsg device + * @rpdev: rpmsg channel device + * @cb: rx callback handler + * @priv: private data for the driver's use + * @chinfo: channel_info with the local rpmsg address to bind with @cb + * + * On register_rpmsg_driver if no callback is provided in the rpmsg_driver structure, + * no endpoint is created when the device is probed by the rpmsg bus. + * + * This function returns a pointer to an endpoint created and assigned as the default + * endpoint of the rpmsg device. + * + * Drivers should provide their @rpdev channel (so the new endpoint would belong + * to the same remote processor their channel belongs to), an rx callback + * function, an optional private data (which is provided back when the + * rx callback is invoked), and an address they want to bind with the + * callback. If @addr is RPMSG_ADDR_ANY, then rpmsg_create_ept will + * dynamically assign them an available rpmsg address (drivers should have + * a very good reason why not to always use RPMSG_ADDR_ANY here). + * + * Return: a pointer to the endpoint on success, or NULL on error. + */ +struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, + rpmsg_rx_cb_t cb, void *priv, + struct rpmsg_channel_info chinfo) +{ + struct rpmsg_endpoint *ept; + + if (WARN_ON(!rpdev)) + return NULL; + + if (WARN_ON(rpdev->ept)) + return NULL; + + /* It does not make sense to create a default endpoint without a callback. */ + if (!cb) + return NULL; + + if (rpdev->ept) + return rpdev->ept; + + ept = rpdev->ops->create_ept(rpdev, cb, priv, chinfo); + if (!ept) + return NULL; + + /* Assign the new endpoint as default endpoint */ + rpdev->ept = ept; + rpdev->src = ept->addr; + + return ept; +} +EXPORT_SYMBOL(rpmsg_create_default_ept); + /** * rpmsg_send() - send a message across to the remote processor * @ept: the rpmsg endpoint diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index d4b23fd019a8..950d6aa4843f 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -100,4 +100,8 @@ static inline int rpmsg_ctrldev_register_device(struct rpmsg_device *rpdev) return rpmsg_register_device(rpdev); } +struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, + rpmsg_rx_cb_t cb, void *priv, + struct rpmsg_channel_info chinfo); + #endif From patchwork Tue Dec 7 08:08:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661287 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9023C433F5 for ; Tue, 7 Dec 2021 08:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232178AbhLGINp (ORCPT ); Tue, 7 Dec 2021 03:13:45 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58842 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232146AbhLGINl (ORCPT ); Tue, 7 Dec 2021 03:13:41 -0500 Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B71FB2a003535; Tue, 7 Dec 2021 09:10:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=mXiPNNbGuPxxED0nQioEMAy2JP59uV0ofbb8aTjGD5k=; b=Lhnod9sLgmxgRJUMQ56D5M1OyHFZXrqm/YzePZAYD061llKCd6d8OMksndSwHUctyp3M ZC0yQBNn56nFJiVIPvg2F6wi32UiEx4xxft5CcaBVafbTiivG+3jpaj9ZTJLa3AxtBaG qFZ1QpHBrCIgTAomBd6UStSzWIvgC6nHMVmNl8S8eALBbUzOPjZBTdzX+NJ3H7Fuomrm v4t5k9s/LvWpKoajFQ6TaqkwJ+0/Ms00WEpES7cmjCSw40zrFXfOyJNzMiWXvUC2YMaT Zq+fhXatQPew0rHOTFaE/owtSAZQseuNnHoz7h8Zo+hcZyxm7jEgAwT9xtxIue9vUA6X 0w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csmx0kp5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:10:02 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 973E8100034; Tue, 7 Dec 2021 09:10:01 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E81E221B526; Tue, 7 Dec 2021 09:10:00 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:10:00 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 10/13] rpmsg: char: Add possibility to use default endpoint of the rpmsg device. Date: Tue, 7 Dec 2021 09:08:40 +0100 Message-ID: <20211207080843.21222-11-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Current implementation create/destroy a new endpoint on each rpmsg_eptdev_open/rpmsg_eptdev_release calls. For a rpmsg device created by the NS announcement mechanism we need to use a unique static endpoint that is the default rpmsg device endpoint associated to the channel. This patch prepares the introduction of a rpmsg channel device for the char device. The rpmsg channel device will require a default endpoint to communicate to the remote processor. Add the default_ept field in rpmsg_eptdev structure.This pointer determines the behavior on rpmsg_eptdev_open and rpmsg_eptdev_release call. - If default_ept == NULL: Use the legacy behavior by creating a new endpoint each time rpmsg_eptdev_open is called and release it when rpmsg_eptdev_release is called on /dev/rpmsgX device open/close. - If default_ept is set: use the rpmsg device default endpoint for the communication. Address the update of _rpmsg_chrdev_eptdev_create in a separate patch for readability. Add protection in rpmsg_eptdev_ioctl to prevent to destroy a default endpoint. Signed-off-by: Arnaud Pouliquen --- Update vs previous revision: - fix comment in rpmsg_eptdev_open --- drivers/rpmsg/rpmsg_char.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index a39f19161cd6..cf97839f5833 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -50,6 +50,8 @@ static DEFINE_IDA(rpmsg_minor_ida); * @queue_lock: synchronization of @queue operations * @queue: incoming message queue * @readq: wait object for incoming queue + * @default_ept: set to channel default endpoint if the default endpoint should be re-used + * on device open to prevent endpoint address update. */ struct rpmsg_eptdev { struct device dev; @@ -60,10 +62,12 @@ struct rpmsg_eptdev { struct mutex ept_lock; struct rpmsg_endpoint *ept; + struct rpmsg_endpoint *default_ept; spinlock_t queue_lock; struct sk_buff_head queue; wait_queue_head_t readq; + }; int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) @@ -121,7 +125,15 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) get_device(dev); - ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); + /* + * If the default_ept is set, the rpmsg device default endpoint is used. + * Else a new endpoint is created on open that will be destroyed on release. + */ + if (eptdev->default_ept) + ept = eptdev->default_ept; + else + ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); + if (!ept) { dev_err(dev, "failed to open %s\n", eptdev->chinfo.name); put_device(dev); @@ -142,7 +154,8 @@ static int rpmsg_eptdev_release(struct inode *inode, struct file *filp) /* Close the endpoint, if it's not already destroyed by the parent */ mutex_lock(&eptdev->ept_lock); if (eptdev->ept) { - rpmsg_destroy_ept(eptdev->ept); + if (!eptdev->default_ept) + rpmsg_destroy_ept(eptdev->ept); eptdev->ept = NULL; } mutex_unlock(&eptdev->ept_lock); @@ -269,6 +282,10 @@ static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd, if (cmd != RPMSG_DESTROY_EPT_IOCTL) return -EINVAL; + /* Don't allow to destroy a default endpoint. */ + if (eptdev->default_ept) + return -EINVAL; + return rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL); } From patchwork Tue Dec 7 08:08:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661289 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF179C433F5 for ; Tue, 7 Dec 2021 08:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbhLGINs (ORCPT ); Tue, 7 Dec 2021 03:13:48 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:35008 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232195AbhLGINn (ORCPT ); Tue, 7 Dec 2021 03:13:43 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B71QLGN028789; Tue, 7 Dec 2021 09:10:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=7dwMWYSMdlELebKyY8Wrp74Lm64AOXgWkuA2NECH5CQ=; b=s6yuFvO1kNtBUqED75pfPHYzHLsQWlV9gU6zn2j1XK/AIzAz5KtMPuXYyGyUVMan0m+G 2vQXNa24Gva+TA3u3Ncy0D8KUBN+dosl1HYDzarlMxBU9ohxcXxA4VxmLYBDNxgcv3ic JFf0YgRgrtfRXVfrWR9R3eogF7rtzAvq73VSe3ZChP1/iAeYNusPsW5N6zUOTn0vr3Xj hlqG0jmH7aqBm1LTkIE2KM/KbceIs8jYZyr/KsLewPljVaQkISHw8Kx2oHIeFt5btVdu HSlj4zSUcvLtYfHByydXL+RmK4XdmR4ZqVWXxwmOcyjXDQWCgrHlX/uZmI+RLzG8pKH4 7Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csg5tnbcy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:10:02 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C11B1100039; Tue, 7 Dec 2021 09:10:01 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B5AF5217B7D; Tue, 7 Dec 2021 09:10:01 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:10:01 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 11/13] rpmsg: char: Introduce the "rpmsg-raw" channel Date: Tue, 7 Dec 2021 09:08:41 +0100 Message-ID: <20211207080843.21222-12-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Allows to probe the endpoint device on a remote name service announcement, by registering a rpmsg_driverfor the "rpmsg-raw" channel. With this patch the /dev/rpmsgX interface can be instantiated by the remote firmware. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 64 ++++++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_ctrl.c | 7 +++-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index cf97839f5833..92b44630e03a 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -435,6 +435,58 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent } EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_channel_info chinfo; + struct rpmsg_eptdev *eptdev; + struct device *dev = &rpdev->dev; + + memcpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); + chinfo.src = rpdev->src; + chinfo.dst = rpdev->dst; + + eptdev = rpmsg_chrdev_eptdev_alloc(rpdev, dev); + if (IS_ERR(eptdev)) + return PTR_ERR(eptdev); + + /* + * Create the default endpoint associated to the rpmsg device and provide rpmsg_eptdev + * structure as callback private data. + * Do not allow the creation and release of an endpoint on /dev/rpmsgX open and close, + * reuse the default endpoint instead + */ + eptdev->default_ept = rpmsg_create_default_ept(rpdev, rpmsg_ept_cb, eptdev, chinfo); + if (!eptdev->default_ept) { + dev_err(&rpdev->dev, "failed to create %s\n", chinfo.name); + put_device(dev); + kfree(eptdev); + return -EINVAL; + } + + return rpmsg_chrdev_eptdev_add(eptdev, chinfo); +} + +static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) +{ + int ret; + + ret = device_for_each_child(&rpdev->dev, NULL, rpmsg_chrdev_eptdev_destroy); + if (ret) + dev_warn(&rpdev->dev, "failed to destroy endpoints: %d\n", ret); +} + +static struct rpmsg_device_id rpmsg_chrdev_id_table[] = { + { .name = "rpmsg-raw" }, + { }, +}; + +static struct rpmsg_driver rpmsg_chrdev_driver = { + .probe = rpmsg_chrdev_probe, + .remove = rpmsg_chrdev_remove, + .id_table = rpmsg_chrdev_id_table, + .drv.name = "rpmsg_chrdev", +}; + static int rpmsg_chrdev_init(void) { int ret; @@ -445,12 +497,24 @@ static int rpmsg_chrdev_init(void) return ret; } + ret = register_rpmsg_driver(&rpmsg_chrdev_driver); + if (ret < 0) { + pr_err("rpmsg: failed to register rpmsg raw driver\n"); + goto free_region; + } + return 0; + +free_region: + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); + + return ret; } postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { + unregister_rpmsg_driver(&rpmsg_chrdev_driver); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } module_exit(rpmsg_chrdev_exit); diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 59d2bd264fdb..298e75dc7774 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -10,6 +10,9 @@ * Based on rpmsg performance statistics driver by Michal Simek, which in turn * was based on TI & Google OMX rpmsg driver. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -193,13 +196,13 @@ static int rpmsg_ctrldev_init(void) ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg_ctrl"); if (ret < 0) { - pr_err("rpmsg: failed to allocate char dev region\n"); + pr_err("failed to allocate char dev region\n"); return ret; } ret = register_rpmsg_driver(&rpmsg_ctrldev_driver); if (ret < 0) { - pr_err("rpmsg ctrl: failed to register rpmsg driver\n"); + pr_err("failed to register rpmsg driver\n"); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } From patchwork Tue Dec 7 08:08:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661285 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4808C433FE for ; Tue, 7 Dec 2021 08:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbhLGINp (ORCPT ); Tue, 7 Dec 2021 03:13:45 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58840 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232136AbhLGINl (ORCPT ); Tue, 7 Dec 2021 03:13:41 -0500 Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B71FB2b003535; Tue, 7 Dec 2021 09:10:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=YOXMnEgE0PBqohRgz/w+Cor88xWaieeK1tGjwcF9Q50=; b=xLjL6cDynsIsJN/b1hD5CfNi8FBP438sJ4ktJXsNb8t6JqjQ32X7xpIuL4+w0LfuYSvn gtwIIh9EmhcXb/Uo7R44Cz+Crm6WMR57JIyvRRebi+ONY1PE1v2FV9wKVi8Skp4YcYUR lPypl2+EiWQALCeULgV8d/UWnUAhBLGXL8ukXoQ/v480eIaeQyipofP/LCzdJHTVDvIh JQxl6BCWqhWZv2GyqU2ZAbhYyAHfpFbeIxzr4xD4SRxZC/mRx1wTo5NnOQBlvhFmR78d iHZ5Fr09DcSvbccR9zHg64iLFGaRS0hP28z3ss/Gm7Z5AkOPdeRqRRZUkMMdvFAK4s1+ 3g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csmx0kp5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:10:03 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6D132100034; Tue, 7 Dec 2021 09:10:02 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6532621FEAB; Tue, 7 Dec 2021 09:10:02 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:10:02 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 12/13] rpmsg: ctrl: Introduce new RPMSG_CREATE/RELEASE_DEV_IOCTL controls Date: Tue, 7 Dec 2021 09:08:42 +0100 Message-ID: <20211207080843.21222-13-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Allow the user space application to create and release an rpmsg device by adding RPMSG_CREATE_DEV_IOCTL and RPMSG_RELEASE_DEV_IOCTL ioctrls to the /dev/rpmsg_ctrl interface The RPMSG_CREATE_DEV_IOCTL Ioctl can be used to instantiate a local rpmsg device. Depending on the back-end implementation, the associated rpmsg driver is probed and a NS announcement can be sent to the remote processor. The RPMSG_RELEASE_DEV_IOCTL allows the user application to release a rpmsg device created either by the remote processor or with the RPMSG_CREATE_DEV_IOCTL call. Depending on the back-end implementation, the associated rpmsg driver is removed and a NS destroy rpmsg can be sent to the remote processor. Suggested-by: Mathieu Poirier Signed-off-by: Arnaud Pouliquen Reviewed-by: Mathieu Poirier --- drivers/rpmsg/rpmsg_ctrl.c | 36 ++++++++++++++++++++++++++++++++---- include/uapi/linux/rpmsg.h | 10 ++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 298e75dc7774..c5ccc5bedde2 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -43,11 +43,13 @@ static DEFINE_IDA(rpmsg_minor_ida); * @rpdev: underlaying rpmsg device * @cdev: cdev for the ctrl device * @dev: device for the ctrl device + * @ctrl_lock: serialize the ioctrls. */ struct rpmsg_ctrldev { struct rpmsg_device *rpdev; struct cdev cdev; struct device dev; + struct mutex ctrl_lock; }; static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) @@ -76,9 +78,8 @@ static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, void __user *argp = (void __user *)arg; struct rpmsg_endpoint_info eptinfo; struct rpmsg_channel_info chinfo; - - if (cmd != RPMSG_CREATE_EPT_IOCTL) - return -EINVAL; + struct rpmsg_device *rpdev; + int ret = 0; if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) return -EFAULT; @@ -88,7 +89,33 @@ static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, chinfo.src = eptinfo.src; chinfo.dst = eptinfo.dst; - return rpmsg_chrdev_eptdev_create(ctrldev->rpdev, &ctrldev->dev, chinfo); + mutex_lock(&ctrldev->ctrl_lock); + switch (cmd) { + case RPMSG_CREATE_EPT_IOCTL: + ret = rpmsg_chrdev_eptdev_create(ctrldev->rpdev, &ctrldev->dev, chinfo); + break; + + case RPMSG_CREATE_DEV_IOCTL: + rpdev = rpmsg_create_channel(ctrldev->rpdev, &chinfo); + if (!rpdev) { + dev_err(&ctrldev->dev, "failed to create %s channel\n", chinfo.name); + ret = -ENXIO; + } + break; + + case RPMSG_RELEASE_DEV_IOCTL: + ret = rpmsg_release_channel(ctrldev->rpdev, &chinfo); + if (ret) + dev_err(&ctrldev->dev, "failed to release %s channel (%d)\n", + chinfo.name, ret); + break; + + default: + ret = -EINVAL; + } + mutex_unlock(&ctrldev->ctrl_lock); + + return ret; }; static const struct file_operations rpmsg_ctrldev_fops = { @@ -126,6 +153,7 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev) dev->parent = &rpdev->dev; dev->class = rpmsg_class; + mutex_init(&ctrldev->ctrl_lock); cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops); ctrldev->cdev.owner = THIS_MODULE; diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index f5ca8740f3fb..1637e68177d9 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -33,4 +33,14 @@ struct rpmsg_endpoint_info { */ #define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2) +/** + * Instantiate a new local rpmsg service device. + */ +#define RPMSG_CREATE_DEV_IOCTL _IOW(0xb5, 0x3, struct rpmsg_endpoint_info) + +/** + * Release a local rpmsg device. + */ +#define RPMSG_RELEASE_DEV_IOCTL _IOW(0xb5, 0x4, struct rpmsg_endpoint_info) + #endif From patchwork Tue Dec 7 08:08:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661283 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 929BBC433F5 for ; Tue, 7 Dec 2021 08:10:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232131AbhLGINl (ORCPT ); Tue, 7 Dec 2021 03:13:41 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42870 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232241AbhLGINf (ORCPT ); Tue, 7 Dec 2021 03:13:35 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B740hsw018633; Tue, 7 Dec 2021 09:10:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=wPRFwNUvvvZvnP1yFH2bxx5PGqqknf2TcOuv8jRoCDs=; b=KdO+t4AMsinj9Cg/7HNbZpTaT7ghp6H46ALZDpy4smEx+cLpRrLScr5wpPIChaQnUef4 xq9ttt1qSH3Wlvf083Y3KPwsQt86uTY81GD5sk8w/DgRF0hcm38baNjByN7zZ0qTo3Na jIMTm5Ulq3K8V1PwgphljWVTYPCM7OJdMQsQqzafE7MvGvbFV1vkVtG+IzTqYbPr1LeD EdKmfucmg5Ju0oTO51tx8rNKNmtJ95Nwvu+LfYjod3aMK7DvYgekXcxXgfLYMpBbaWAh 1XcvXyFaQj8wOqAe8eXr/eiMMIYwbFZ4Tb+Antcz8qfBrTjLOuLPqyKvHxG1VDIuDc8X zQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3csp32bcgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:10:03 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 43EA2100039; Tue, 7 Dec 2021 09:10:03 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 3A1F021B526; Tue, 7 Dec 2021 09:10:03 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:10:02 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 13/13] rpmsg: core: Send a ns announcement when a default endpoint is created Date: Tue, 7 Dec 2021 09:08:43 +0100 Message-ID: <20211207080843.21222-14-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org When a channel is created by user space application with the RPMSG_CREATE_DEV_IOCTL controls, a ns announcement has to be sent (depending on backend) to inform the remote side that a new service is available. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 3f86512147e8..27aad6baf7c5 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -145,6 +145,9 @@ EXPORT_SYMBOL(rpmsg_destroy_ept); * * This function returns a pointer to an endpoint created and assigned as the default * endpoint of the rpmsg device. + * If we need to, we also announce about this channel to the remote + * processor. This announcement is needed in case the driver is exposing an rpmsg service that has + * been created locally. * * Drivers should provide their @rpdev channel (so the new endpoint would belong * to the same remote processor their channel belongs to), an rx callback @@ -161,6 +164,7 @@ struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, struct rpmsg_channel_info chinfo) { struct rpmsg_endpoint *ept; + int err; if (WARN_ON(!rpdev)) return NULL; @@ -183,6 +187,17 @@ struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, rpdev->ept = ept; rpdev->src = ept->addr; + if (rpdev->ops->announce_create) { + err = rpdev->ops->announce_create(rpdev); + if (err) { + rpmsg_destroy_ept(ept); + rpdev->ept = NULL; + rpdev->src = RPMSG_ADDR_ANY; + + return NULL; + } + } + return ept; } EXPORT_SYMBOL(rpmsg_create_default_ept);