From patchwork Tue Dec 22 10:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FBACC433E6 for ; Tue, 22 Dec 2020 11:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 459312310D for ; Tue, 22 Dec 2020 11:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725785AbgLVK6s (ORCPT ); Tue, 22 Dec 2020 05:58:48 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:60534 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbgLVK6r (ORCPT ); Tue, 22 Dec 2020 05:58:47 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAv8qB017308; Tue, 22 Dec 2020 11:58: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=SW6rkfmrRTc6+NkBZszJEQdtfxV4dOOJDB9c4RqrY0w=; b=y+5kV2mzPk0Al9hlLlXmHXhWdQE3W5Z3KEJ0ojV3GHN0yweUp7/dZUB55XaqqlJeqlsc IerUqYgeemjMT8aki8DvPuU/1ocMOQo8cmEsr8qdTL+bugVrNUzC7l0vtBwSh5e4nQnG oQTYZSGStv9OOcf6mM23RX4MfAItCcHoscpxbpOkh9a5a+L9+5RWJk9zIGQdr6NcPg32 EcznobaSkd9pSTjwyxm4t9nCWE5tdAtaHHJWXd5c5nABgW95B99cDLe7Iha38RB94NeH zTP0HPzt0YEbnWHY/PaUfYXgAY9uJy95LT7eyWiw9puduFqcpZB+QwFsA4BNl/PlvmT6 kA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k7vva3gv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58: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 DD13910002A; Tue, 22 Dec 2020 11:57:59 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C832E231601; Tue, 22 Dec 2020 11:57:59 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:57:59 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 01/16] rpmsg: introduce RPMsg control driver for channel creation Date: Tue, 22 Dec 2020 11:57:11 +0100 Message-ID: <20201222105726.16906-2-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The RPMsg_ctrl driver is a duplication of the ioctrl part of the rpmsg_char driver to make generic the ioctl to manage channels by the userspace applications. As a first step, this driver just creates the /dev/rpmsg_ctl ( is the instance value). The ioctl is not implemented. Notice that this driver is associated to a RPMsg device with no endpoint. Instantiating this device as an RPMsg device allows to retrieve the associated RPMsg backend. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/Kconfig | 8 ++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_ctrl.c | 208 +++++++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_ctrl.c diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 0b4407abdf13..c9e602016c3b 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -23,6 +23,14 @@ config RPMSG_NS channel that probes the associated RPMsg device on remote endpoint service announcement. +config RPMSG_CTRL + tristate "RPMSG control interface" + depends on RPMSG + help + Say Y here to enable the support of the /dev/rpmsg_ctl API. this API + allows user-space programs to create channels with specific name, + source and destination addresses. + config RPMSG_MTK_SCP tristate "MediaTek SCP" depends on MTK_SCP diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index 8d452656f0ee..3c1bce9d0228 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_RPMSG) += rpmsg_core.o obj-$(CONFIG_RPMSG_CHAR) += rpmsg_char.o obj-$(CONFIG_RPMSG_NS) += rpmsg_ns.o +obj-$(CONFIG_RPMSG_CTRL) += rpmsg_ctrl.o obj-$(CONFIG_RPMSG_MTK_SCP) += mtk_rpmsg.o qcom_glink-objs := qcom_glink_native.o qcom_glink_ssr.o obj-$(CONFIG_RPMSG_QCOM_GLINK) += qcom_glink.o diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c new file mode 100644 index 000000000000..425c3e32ada4 --- /dev/null +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) STMicroelectronics 2020 + */ + +#include +#include +#include +#include +#include "rpmsg_internal.h" +#include + +#define RPMSG_DEV_MAX (MINORMASK + 1) + +#define dev_to_ctrldev(dev) container_of(dev, struct rpmsg_ctrl_dev, dev) +#define cdev_to_ctrldev(i_cdev) container_of(i_cdev, struct rpmsg_ctrl_dev, cdev) + +/** + * struct rpmsg_ctrl_dev - control device for instantiating endpoint devices + * @rpdev: underlaying rpmsg device + * @cdev: cdev for the ctrl device + * @dev: device for the ctrl device + */ +struct rpmsg_ctrl_dev { + struct rpmsg_device *rpdev; + struct cdev cdev; + struct device dev; +}; + +static DEFINE_IDA(rpmsg_ctrl_ida); +static DEFINE_IDA(rpmsg_minor_ida); + +static dev_t rpmsg_major; + +static int rpmsg_ctrl_dev_open(struct inode *inode, struct file *filp) +{ + struct rpmsg_ctrl_dev *ctrldev = cdev_to_ctrldev(inode->i_cdev); + + get_device(&ctrldev->dev); + filp->private_data = ctrldev; + + return 0; +} + +static long rpmsg_ctrl_dev_ioctl(struct file *fp, unsigned int cmd, + unsigned long arg) +{ + struct rpmsg_ctrl_dev *ctrldev = fp->private_data; + + dev_info(&ctrldev->dev, "Control not yet implemented\n"); + + return 0; +}; + +static int rpmsg_ctrl_dev_release(struct inode *inode, struct file *filp) +{ + struct rpmsg_ctrl_dev *ctrldev = cdev_to_ctrldev(inode->i_cdev); + + put_device(&ctrldev->dev); + + return 0; +} + +static void rpmsg_ctrl_dev_release_device(struct device *dev) +{ + struct rpmsg_ctrl_dev *ctrldev = dev_to_ctrldev(dev); + + dev_err(dev, "%s\n", __func__); + + ida_simple_remove(&rpmsg_ctrl_ida, dev->id); + ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); + cdev_del(&ctrldev->cdev); + kfree(ctrldev); +} + +static const struct file_operations rpmsg_ctrl_fops = { + .owner = THIS_MODULE, + .open = rpmsg_ctrl_dev_open, + .release = rpmsg_ctrl_dev_release, + .unlocked_ioctl = rpmsg_ctrl_dev_ioctl, + .compat_ioctl = compat_ptr_ioctl, +}; + +static int rpmsg_ctrl_add_control(struct rpmsg_ctrl_dev *ctrldev) +{ + struct device *dev = &ctrldev->dev; + int ret; + + cdev_init(&ctrldev->cdev, &rpmsg_ctrl_fops); + ctrldev->cdev.owner = THIS_MODULE; + + ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); + if (ret < 0) + return ret; + dev->devt = MKDEV(MAJOR(rpmsg_major), ret); + + dev_set_name(dev, "rpmsg_ctrl%d", dev->id); + + ret = cdev_add(&ctrldev->cdev, dev->devt, 1); + if (ret) + goto free_minor_ida; + + dev_info(dev, "add %s control for %s driver\n", + dev_name(dev), dev_name(dev->parent)); + + return 0; + +free_minor_ida: + ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); + + return ret; +} + +static int rpmsg_ctrl_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_ctrl_dev *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; + + ret = ida_simple_get(&rpmsg_ctrl_ida, 0, 0, GFP_KERNEL); + if (ret < 0) + goto free_ctrldev; + + dev->id = ret; + + ret = rpmsg_ctrl_add_control(ctrldev); + if (ret < 0) + goto free_ctrl_ida; + + /* We can now rely on the release function for cleanup */ + dev->release = rpmsg_ctrl_dev_release_device; + + ret = device_add(dev); + if (ret) { + dev_err(&rpdev->dev, "device_add failed: %d\n", ret); + put_device(dev); + goto free_ctrl_ida; + } + + dev_set_drvdata(dev, ctrldev); + dev_set_drvdata(&rpdev->dev, ctrldev); + + return 0; + +free_ctrl_ida: + ida_simple_remove(&rpmsg_ctrl_ida, dev->id); +free_ctrldev: + put_device(dev); + kfree(ctrldev); + + return ret; +} + +static void rpmsg_ctrl_remove(struct rpmsg_device *rpdev) +{ + struct rpmsg_ctrl_dev *ctrldev = dev_get_drvdata(&rpdev->dev); + + device_del(&ctrldev->dev); + put_device(&ctrldev->dev); +} + +static struct rpmsg_driver rpmsg_ctrl_driver = { + .drv.name = KBUILD_MODNAME, + .probe = rpmsg_ctrl_probe, + .remove = rpmsg_ctrl_remove, +}; + +static int rpmsg_ctrl_init(void) +{ + int ret; + + ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg"); + if (ret < 0) { + pr_err("rpmsg_ctrl: failed to allocate char dev region\n"); + return ret; + } + + ret = register_rpmsg_driver(&rpmsg_ctrl_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_ctrl_init); + +static void rpmsg_ctrl_exit(void) +{ + unregister_rpmsg_driver(&rpmsg_ctrl_driver); + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); +} +module_exit(rpmsg_ctrl_exit); + +MODULE_DESCRIPTION("ioctl rpmsg driver"); +MODULE_AUTHOR("Arnaud Pouliquen "); +MODULE_ALIAS("rpmsg:" KBUILD_MODNAME); +MODULE_LICENSE("GPL v2"); From patchwork Tue Dec 22 10:57:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C65A9C433DB for ; Tue, 22 Dec 2020 10:59:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ED7923105 for ; Tue, 22 Dec 2020 10:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726612AbgLVK6w (ORCPT ); Tue, 22 Dec 2020 05:58:52 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:7620 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726472AbgLVK6w (ORCPT ); Tue, 22 Dec 2020 05:58:52 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw6QE012870; Tue, 22 Dec 2020 11:58:06 +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=a5kQ5Np6UsVy5bkTQ0gOe+8K4aMl8RM3spGtSWwiTos=; b=7fL6zE5oFRT2KXN95V1A9Ypt0f+6TUAY4TuR9H0lwFJq5CtohzWa3n/46Eg2UUX+R2c/ WC35wmhsmNciMvZgF6/vnRLKYiJ2uFXsHVSpCMh03Le7pOSmRDWXXTJkcOyokqM1Tx26 AVs/kuMvl6wzfmaN3OEqivlSt5ppuKU+SNoC0UX+VeDCfMTd8+3w3yvgUIAtzlQ0Q3o+ b7BVbykRnaM1I4VxpUlU6/5mQAaRcAIhqDHVxAYZS+BduOcw+rFv1098GktYHAj5WfjN /HetKXbUUYxp95NhrGp5NxaxixpeYTvZ1LdxAGDeeTKdJsMHSxuhOr55fPZ+61cHp06F zw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0eb3xbc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:06 +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 8C8B5100034; Tue, 22 Dec 2020 11:58:00 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7D39E231603; Tue, 22 Dec 2020 11:58:00 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:57:59 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 02/16] rpmsg: add RPMsg control API to register service Date: Tue, 22 Dec 2020 11:57:12 +0100 Message-ID: <20201222105726.16906-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add API to register a RPMsg service to the control device. The rpmsg_drv_ctrl_info structure links a service to its driver. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 57 ++++++++++++++++++++++++++++++++++++++ include/linux/rpmsg.h | 31 +++++++++++++++++++++ include/uapi/linux/rpmsg.h | 14 ++++++++++ 3 files changed, 102 insertions(+) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 425c3e32ada4..065e2e304019 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -27,6 +27,20 @@ struct rpmsg_ctrl_dev { struct device dev; }; +/** + * struct rpmsg_ctl_info - control info list node + * @ctrl: control driver info + * @node: list node + * + * This structure is used by rpmsg_ctl to list the registered drivers services + */ +struct rpmsg_ctl_info { + const struct rpmsg_drv_ctrl_info *ctrl; + struct list_head node; +}; + +static LIST_HEAD(rpmsg_drv_list); + static DEFINE_IDA(rpmsg_ctrl_ida); static DEFINE_IDA(rpmsg_minor_ida); @@ -175,6 +189,49 @@ static struct rpmsg_driver rpmsg_ctrl_driver = { .remove = rpmsg_ctrl_remove, }; +/** + * rpmsg_ctrl_register_ctl() -register control for the associated service + * @ctrl: rpmsg driver information + * + * This function is called by the rpmsg driver to register a service that will + * be exposed to be instantiate by the application. + */ +int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl) +{ + struct rpmsg_ctl_info *drv_info; + + drv_info = kzalloc(sizeof(*drv_info), GFP_KERNEL); + if (!drv_info) + return -ENOMEM; + + drv_info->ctrl = ctrl; + + list_add_tail(&drv_info->node, &rpmsg_drv_list); + + return 0; +} +EXPORT_SYMBOL(rpmsg_ctrl_register_ctl); + +/** + * rpmsg_ctrl_unregister_ctl() -unregister control for the associated service + * @ctrl: the rpmsg control information + * + * This function is called by the rpmsg driver to unregister the associated + * service. + */ +void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl) +{ + struct rpmsg_ctl_info *drv_info, *tmp; + + list_for_each_entry_safe(drv_info, tmp, &rpmsg_drv_list, node) { + if (drv_info->ctrl == ctrl) { + list_del(&drv_info->node); + kfree(drv_info); + } + } +} +EXPORT_SYMBOL(rpmsg_ctrl_unregister_ctl); + static int rpmsg_ctrl_init(void) { int ret; diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index a5db828b2420..5d64704c2346 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -26,6 +26,19 @@ struct rpmsg_endpoint; struct rpmsg_device_ops; struct rpmsg_endpoint_ops; +/** + * struct rpmsg_drv_ctrl_info - rpmsg ctrl structure + * @drv_name: name of the associated driver + * @service: the associated rpmsg service listed in @rpmsg_services + * + * This structure is used by rpmsg_ctl to link the endpoint creation to the + * service rpmsg driver. + */ +struct rpmsg_drv_ctrl_info { + const char *drv_name; + u32 service; +}; + /** * struct rpmsg_channel_info - channel info representation * @name: name of service @@ -315,4 +328,22 @@ static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, module_driver(__rpmsg_driver, register_rpmsg_driver, \ unregister_rpmsg_driver) +#if IS_ENABLED(CONFIG_RPMSG_CTRL) + +int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl); +void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl); + +#else + +static inline int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl) +{ + return 0; +} + +static inline void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl) +{ +} + +#endif /* IS_ENABLED(CONFIG_RPMSG_CTRL) */ + #endif /* _LINUX_RPMSG_H */ diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index e14c6dab4223..0b0cb028e0b3 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -9,6 +9,20 @@ #include #include +/** + * enum rpmsg_services - list of supported RPMsg services + * + * @RPMSG_RAW_SERVICE: char device RPMSG service + * @RPMSG_START_PRIVATE_SERVICES: private services have to be declared after. + */ +enum rpmsg_services { + /* Reserved services */ + RPMSG_RAW_SERVICE = 0, + + /* Private services */ + RPMSG_START_PRIVATE_SERVICES = 1024, +}; + /** * struct rpmsg_endpoint_info - endpoint info representation * @name: name of service From patchwork Tue Dec 22 10:57:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9C46C432C3 for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87E2C2310D for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbgLVK6t (ORCPT ); Tue, 22 Dec 2020 05:58:49 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:7228 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgLVK6s (ORCPT ); Tue, 22 Dec 2020 05:58:48 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAvYlk004475; Tue, 22 Dec 2020 11:58: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=Q34Pt7mQM73+LJGSyan1A/A1z8hmgrrHq/rT3Ow5ST8=; b=TY3glY+k2ggVKlL2hzeWpqarQZ0UeaVjNUSrcpXIkke9FO8uscDeIYkG0MN/vk23bcxL UYMbyHtoISl1NvJZbN82l5dRGysM1oh8hRAfO/g8mub7TJzof4QZMe5lO5xdfRbm4sm3 0wRuFO0U51NPT+QQAjIfPdP6fuPOvbdaix5A8N7swNhkwbskRluJRpRlvnPWQZOZtXfo I9u70irWPH+fuLNkQEVfy6aY3Hx1rFvKlwCiMchjhuEfjWrSHqSstC9PZbZgl5M78gt1 x5YVXJG3L0+MJQF4astLce+ehUQvYJoAz8gyQk1UtYsKf2zds5bpeMGNMKL+3bY7rcKT eQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0d1bjth-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58: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 5F43110002A; Tue, 22 Dec 2020 11:58:01 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 430EF231603; Tue, 22 Dec 2020 11:58:01 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:00 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 03/16] rpmsg: add override field in channel info Date: Tue, 22 Dec 2020 11:57:13 +0100 Message-ID: <20201222105726.16906-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The override field is already used in the rpmsg_device. Adding this field in the channel info allows to force the channel creation with a specified RPMsg service driver. Signed-off-by: Arnaud Pouliquen --- include/linux/rpmsg.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 5d64704c2346..5681c585e235 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -44,11 +44,13 @@ struct rpmsg_drv_ctrl_info { * @name: name of service * @src: local address * @dst: destination address + * @driver_override: driver name to force a match */ struct rpmsg_channel_info { char name[RPMSG_NAME_SIZE]; u32 src; u32 dst; + const char *driver_override; }; /** From patchwork Tue Dec 22 10:57:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F195C433DB for ; Tue, 22 Dec 2020 11:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3125523105 for ; Tue, 22 Dec 2020 11:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727036AbgLVK7r (ORCPT ); Tue, 22 Dec 2020 05:59:47 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:60546 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbgLVK6s (ORCPT ); Tue, 22 Dec 2020 05:58:48 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAv6qd017298; Tue, 22 Dec 2020 11:58: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=14ixMlR3u345kc7IjufikRjZjTnNfAABnHJSVaxqAF8=; b=gL3JGK2phKWIhN8aEiqTBKP5nA+qfnkwhzrNNCtqNdzdC10HVT1HrEaP3ohxnwGwEPHH VfbXloCHO36ZInpAtcvRm0Yf2uWOt/h4QfUr+ahyJq1VfiT18qXiYkO3LNBVokvysdr6 vokQ4tDiK3gDohIc8+X5omsZgj5SBCO+Abir+a0qJ4SEnXAh0h2j7aI2Xn7dNp4iFT/w 5eGVa5lNTCVr09MasmN68UT/6pjiDBNeic57rI6VnLy3nTeRpEboNZ1qLu+DyS8hR74+ R9kJ5Xhbllwm+5TrfVA68bOOe2xCwuD5zB10Dig8yFVepxjGFHNeykv7PNEeWeYtf/Jw 6Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k7vva3gy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58: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 0364910003A; Tue, 22 Dec 2020 11:58:02 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E9E76231603; Tue, 22 Dec 2020 11:58:01 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:01 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 04/16] rpmsg: ctrl: implement the ioctl function to create device Date: Tue, 22 Dec 2020 11:57:14 +0100 Message-ID: <20201222105726.16906-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Implement the ioctl function that parses the list of rpmsg drivers registered to create an associated device. To be ISO user API, in a first step, the driver_override is only allowed for the RPMsg raw service, supported by the rpmsg_char driver. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 065e2e304019..8381b5b2b794 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -56,12 +56,51 @@ static int rpmsg_ctrl_dev_open(struct inode *inode, struct file *filp) return 0; } +static const char *rpmsg_ctrl_get_drv_name(u32 service) +{ + struct rpmsg_ctl_info *drv_info; + + list_for_each_entry(drv_info, &rpmsg_drv_list, node) { + if (drv_info->ctrl->service == service) + return drv_info->ctrl->drv_name; + } + + return NULL; +} + static long rpmsg_ctrl_dev_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { struct rpmsg_ctrl_dev *ctrldev = fp->private_data; - - dev_info(&ctrldev->dev, "Control not yet implemented\n"); + void __user *argp = (void __user *)arg; + struct rpmsg_channel_info chinfo; + struct rpmsg_endpoint_info eptinfo; + struct rpmsg_device *newch; + + if (cmd != RPMSG_CREATE_EPT_IOCTL) + return -EINVAL; + + if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) + return -EFAULT; + + /* + * In a frst step only the rpmsg_raw service is supported. + * The override is foorced to RPMSG_RAW_SERVICE + */ + chinfo.driver_override = rpmsg_ctrl_get_drv_name(RPMSG_RAW_SERVICE); + if (!chinfo.driver_override) + return -ENODEV; + + memcpy(chinfo.name, eptinfo.name, RPMSG_NAME_SIZE); + chinfo.name[RPMSG_NAME_SIZE - 1] = '\0'; + chinfo.src = eptinfo.src; + chinfo.dst = eptinfo.dst; + + newch = rpmsg_create_channel(ctrldev->rpdev, &chinfo); + if (!newch) { + dev_err(&ctrldev->dev, "rpmsg_create_channel failed\n"); + return -ENXIO; + } return 0; }; From patchwork Tue Dec 22 10:57:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C331C433E9 for ; Tue, 22 Dec 2020 11:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A40523103 for ; Tue, 22 Dec 2020 11:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbgLVK7x (ORCPT ); Tue, 22 Dec 2020 05:59:53 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:54011 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbgLVK6r (ORCPT ); Tue, 22 Dec 2020 05:58:47 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAvLIs004367; Tue, 22 Dec 2020 11:58: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=5eMiDoWgwQvikTXRS1GkDala9j21tGpEhMxUXtCgE/U=; b=uhMqA30nMSmMCno86N7IhNPG/zo6D6bW4SVAjBo0jQv4JnEXX4DC557VJdSV59mCRp0R UIXt0f2nuAT8D3GeNoQHuZgyxlHul308lH0xf8GrxP/Jnzh9zeaGOx0SD8/IXJf3hKch t1h4+y/0SQuvzLqEoD5o955I3I3e3s7bn3QNaeBAI1h7LhNOhvMfmIbFAdTI49GO8vSw 7+EvN7/nfzXoDAU2oToTgnyu5m384XhRBoivLxWHNl0HV4Pq//v4UhLPgdjyNvAlhi77 jXE6kazijozbY8LJOJz7FlMdk76l4CJkmddC2X9nUU1rbCbRLwQTNmdcWR7SSZu+vJm1 8g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0d1bjtm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58: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 C07FB10002A; Tue, 22 Dec 2020 11:58:02 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B0285231603; Tue, 22 Dec 2020 11:58:02 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:02 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 05/16] rpmsg: ns: initialize channel info override field Date: Tue, 22 Dec 2020 11:57:15 +0100 Message-ID: <20201222105726.16906-6-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org By default driver_override should be 0 to avoid to force the channel creation with a specified name.The local variable is not initialized. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ns.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c index 762ff1ae279f..a526bff62947 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -55,6 +55,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, strncpy(chinfo.name, msg->name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; chinfo.dst = rpmsg32_to_cpu(rpdev, msg->addr); + chinfo.driver_override = NULL; dev_info(dev, "%sing channel %s addr 0x%x\n", rpmsg32_to_cpu(rpdev, msg->flags) & RPMSG_NS_DESTROY ? From patchwork Tue Dec 22 10:57:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73AD2C43332 for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BEE423130 for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbgLVK6v (ORCPT ); Tue, 22 Dec 2020 05:58:51 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39062 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726288AbgLVK6u (ORCPT ); Tue, 22 Dec 2020 05:58:50 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw5bP004484; Tue, 22 Dec 2020 11:58:05 +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=UPiHBdbTHBNY7dOfvc0ufFTBldl3o20yeOxrHUfL6kA=; b=aFPViVI0NW7dADKfDwovSbcpRfZr3rzSvb4GZ+NwE8AGTBgHtY2hDk09ztV0zoAYWYaI NlveXdKspUPgA7dDEl2nBvneCfetq056cn8lBXKJ+zYvRSVOjiBAnv31uqmbor5rxT5o pnshpAd7q2ybPFnxY/T1vKuf1MeJgBBOyoOHwqGYyUDchLRzgEID0COpxfxEBXCFWx3H SH3a1q6m74wbAfSuxBKa7u5TFGwtL1w1QqfSWyToZ6ab/pKGgR4vmuYSPmVJrgqUDaPi c6Wi1xgRUFIl92Q0UBOSZZn5qRapV+/cR3hF6gteW6e5sXEKKp4kfD4cMGu7SgdjrYeL Uw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0cgky50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:05 +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 7E65810002A; Tue, 22 Dec 2020 11:58:04 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6FC4A2073FA; Tue, 22 Dec 2020 11:58:03 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:02 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 06/16] rpmsg: add helper to register the rpmsg ctrl device Date: Tue, 22 Dec 2020 11:57:16 +0100 Message-ID: <20201222105726.16906-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This function registers a rpmsg_ctl device and its associated /dev/rpmsg_ctrl interface. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 16 ++++++++++++++++ include/linux/rpmsg.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 8381b5b2b794..e4b0ca6dffe3 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -271,6 +271,22 @@ void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl) } EXPORT_SYMBOL(rpmsg_ctrl_unregister_ctl); +/** + * rpmsg_ctl_register_device() - register control device based on rpdev + * @rpdev: prepared rpdev to be used for creating endpoints + * + * This function wraps rpmsg_register_device() preparing the rpdev for use as + * a control rpmsg driver forcing the channel name. + */ +int rpmsg_ctl_register_device(struct rpmsg_device *rpdev) +{ + strcpy(rpdev->id.name, KBUILD_MODNAME); + rpdev->driver_override = KBUILD_MODNAME; + + return rpmsg_register_device(rpdev); +} +EXPORT_SYMBOL(rpmsg_ctl_register_device); + static int rpmsg_ctrl_init(void) { int ret; diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 5681c585e235..86540528325f 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -335,6 +335,8 @@ static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl); void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl); +int rpmsg_ctl_register_device(struct rpmsg_device *rpdev); + #else static inline int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl) @@ -346,6 +348,11 @@ static inline void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *c { } +static inline int rpmsg_ctl_register_device(struct rpmsg_device *rpdev) +{ + return 0; +} + #endif /* IS_ENABLED(CONFIG_RPMSG_CTRL) */ #endif /* _LINUX_RPMSG_H */ From patchwork Tue Dec 22 10:57:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68725C4332E for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C58123103 for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbgLVK6v (ORCPT ); Tue, 22 Dec 2020 05:58:51 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:53971 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbgLVK6u (ORCPT ); Tue, 22 Dec 2020 05:58:50 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAvYll004475; Tue, 22 Dec 2020 11:58:04 +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=7xL1+xV/M7LvsjtW9KV2yCRgG/ihHMpqTb/fq0HOeZo=; b=KSpeNhkwYIBUgu/AThq0j7BjHh7v59Q0zcWxja7oE4/WfqbsVOqC9KnCesZV3mFuUahC Zad+wclsps3yXRrp1piSxMrcaPKRnfxQowtCzKFP+C0cZZRoMUORItDlp9E0Utugq41t KhwKaKE9jd/g0Rs/1ZqKYIkNbx7HSP97p647vyRfdpdCwaXJ3Vz/b2wqXHKXOCNMCGdX HxlzwP6/8eM5BqEd2P4frURkGRQU4XdeHkxXklUwEZIsRRPZ9WpabJupYArNwUR+JDjV xQgZJ80RRzt3z+eP1IzphhH7yZxGw7pa6YxzAcRojvPDtbHHTBhxek9t1b0gzcIeiZ2V jA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0d1bjtq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:04 +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 8B00D100038; Tue, 22 Dec 2020 11:58:04 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 743A920B86C; Tue, 22 Dec 2020 11:58:04 +0100 (CET) Received: from localhost (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:03 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 07/16] rpmsg: char: clean up rpmsg class Date: Tue, 22 Dec 2020 11:57:17 +0100 Message-ID: <20201222105726.16906-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG4NODE3.st.com (10.75.127.12) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Suppress the management of the rpmsg class as attribute. It is already handled in /sys/bus rpmsg as specified in documentation/ABI/testing/sysfs-bus-rpmsg. This patch prepares the migration of the control device in rpmsg_ctrl. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 48 -------------------------------------- 1 file changed, 48 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 4bbbacdbf3bb..732f5caf068a 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -27,7 +27,6 @@ #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); @@ -291,41 +290,6 @@ static const struct file_operations rpmsg_eptdev_fops = { .compat_ioctl = compat_ptr_ioctl, }; -static ssize_t name_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct rpmsg_eptdev *eptdev = dev_get_drvdata(dev); - - return sprintf(buf, "%s\n", eptdev->chinfo.name); -} -static DEVICE_ATTR_RO(name); - -static ssize_t src_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct rpmsg_eptdev *eptdev = dev_get_drvdata(dev); - - return sprintf(buf, "%d\n", eptdev->chinfo.src); -} -static DEVICE_ATTR_RO(src); - -static ssize_t dst_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct rpmsg_eptdev *eptdev = dev_get_drvdata(dev); - - return sprintf(buf, "%d\n", eptdev->chinfo.dst); -} -static DEVICE_ATTR_RO(dst); - -static struct attribute *rpmsg_eptdev_attrs[] = { - &dev_attr_name.attr, - &dev_attr_src.attr, - &dev_attr_dst.attr, - NULL -}; -ATTRIBUTE_GROUPS(rpmsg_eptdev); - static void rpmsg_eptdev_release_device(struct device *dev) { struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev); @@ -358,9 +322,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, init_waitqueue_head(&eptdev->readq); device_initialize(dev); - dev->class = rpmsg_class; dev->parent = &ctrldev->dev; - dev->groups = rpmsg_eptdev_groups; dev_set_drvdata(dev, eptdev); cdev_init(&eptdev->cdev, &rpmsg_eptdev_fops); @@ -477,7 +439,6 @@ static int rpmsg_chrdev_probe(struct rpmsg_device *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; @@ -553,17 +514,9 @@ static int rpmsg_char_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("rpmsgchr: failed to register rpmsg driver\n"); - class_destroy(rpmsg_class); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } @@ -574,7 +527,6 @@ postcore_initcall(rpmsg_char_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); From patchwork Tue Dec 22 10:57:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B259C4332D for ; Tue, 22 Dec 2020 10:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0477723103 for ; Tue, 22 Dec 2020 10:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbgLVK7b (ORCPT ); Tue, 22 Dec 2020 05:59:31 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:53815 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgLVK6w (ORCPT ); Tue, 22 Dec 2020 05:58:52 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAvIUK004003; Tue, 22 Dec 2020 11:58:05 +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=i5G4OSHl8Y/N2J/A+l3Tj+VqlW43Rc+ecwFsHG5sGFg=; b=WRUUuuJxXrs9jPatrCFblGqbnxRgHzHkmzdi8Fyq9pxGTQ8KkdQSVr9JTcBl9Dg1GU4A MfwGiJ6Rw6jcBtVkGYx+JECaZcnw3L5C9TJZPZkBcFI1xg3sd8EGiiexnRdnGxNpxcJA qkD7y795cVPjGE6/czZ+X/fAvcfN74mMD/iOauqKVtshUdtEyFEftMpvsBZWm8W5AHoT V4fCGOwcUuQacUxRT//xnqOisUDEdY6uCUrK/lqI1l5pp67VZw4OGfV4FCM9iEqjeCX0 AzCmpbcmsmnfwOZnxM6rYs9sCq3d4+4NJu0sIApu9HmYfjMmxa0hquoWpS5sga2qL55U aw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0d1bjts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:05 +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 887BE10002A; Tue, 22 Dec 2020 11:58:05 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id F02A721BD81; Tue, 22 Dec 2020 11:58:04 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:04 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 08/16] rpmsg: char: make char rpmsg a rpmsg device without the control part Date: Tue, 22 Dec 2020 11:57:18 +0100 Message-ID: <20201222105726.16906-9-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG4NODE3.st.com (10.75.127.12) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The RPMsg control part is migrated to the rpmsg_ctrl.c. Clean up the code associated to the support of the /dev/rpmsgctrl0 and update the driver to only manage the char devices as a RPMsg generic service. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 166 +++++++------------------------------ 1 file changed, 28 insertions(+), 138 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 732f5caf068a..3d77f4d5fc32 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -28,16 +28,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 @@ -300,10 +296,8 @@ static void rpmsg_eptdev_release_device(struct device *dev) kfree(eptdev); } -static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, - struct rpmsg_channel_info chinfo) +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) { - struct rpmsg_device *rpdev = ctrldev->rpdev; struct rpmsg_eptdev *eptdev; struct device *dev; int ret; @@ -314,7 +308,9 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, dev = &eptdev->dev; eptdev->rpdev = rpdev; - eptdev->chinfo = chinfo; + strncpy(eptdev->chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); + eptdev->chinfo.src = rpdev->src; + eptdev->chinfo.dst = rpdev->dst; mutex_init(&eptdev->ept_lock); spin_lock_init(&eptdev->queue_lock); @@ -322,15 +318,18 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, init_waitqueue_head(&eptdev->readq); device_initialize(dev); - dev->parent = &ctrldev->dev; + dev->parent = &rpdev->dev; dev_set_drvdata(dev, eptdev); cdev_init(&eptdev->cdev, &rpmsg_eptdev_fops); eptdev->cdev.owner = THIS_MODULE; ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); - if (ret < 0) + if (ret < 0) { + dev_err(dev, "failed to get IDA (%d)\n", ret); goto free_eptdev; + } + dev->devt = MKDEV(MAJOR(rpmsg_major), ret); ret = ida_simple_get(&rpmsg_ept_ida, 0, 0, GFP_KERNEL); @@ -340,8 +339,10 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, dev_set_name(dev, "rpmsg%d", ret); ret = cdev_add(&eptdev->cdev, dev->devt, 1); - if (ret) + if (ret) { + dev_err(&rpdev->dev, "failed to add char device(%d)\n", ret); goto free_ept_ida; + } /* We can now rely on the release function for cleanup */ dev->release = rpmsg_eptdev_release_device; @@ -352,6 +353,8 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, put_device(dev); } + dev_set_drvdata(&rpdev->dev, eptdev); + return ret; free_ept_ida: @@ -365,138 +368,25 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, return ret; } -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) +static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) { - struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); + struct rpmsg_eptdev *eptdev = dev_get_drvdata(&rpdev->dev); - put_device(&ctrldev->dev); + /* Wake up any blocked readers */ + wake_up_interruptible(&eptdev->readq); - return 0; + device_del(&eptdev->dev); + put_device(&eptdev->dev); } -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_eptdev_create(ctrldev, chinfo); +static struct rpmsg_device_id rpmsg_chrdev_id_table[] = { + { .name = "rpmsg-raw" }, + { }, }; - -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; - - 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_eptdev_destroy); - if (ret) - dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); - - device_del(&ctrldev->dev); - put_device(&ctrldev->dev); -} +MODULE_DEVICE_TABLE(rpmsg, rpmsg_chrdev_id_table); static struct rpmsg_driver rpmsg_chrdev_driver = { + .id_table = rpmsg_chrdev_id_table, .probe = rpmsg_chrdev_probe, .remove = rpmsg_chrdev_remove, .drv = { @@ -504,7 +394,7 @@ static struct rpmsg_driver rpmsg_chrdev_driver = { }, }; -static int rpmsg_char_init(void) +static int rpmsg_chrdev_init(void) { int ret; @@ -516,13 +406,13 @@ static int rpmsg_char_init(void) ret = register_rpmsg_driver(&rpmsg_chrdev_driver); if (ret < 0) { - pr_err("rpmsgchr: failed to register rpmsg driver\n"); + pr_err("rpmsg: failed to register rpmsg chrdev driver\n"); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } return ret; } -postcore_initcall(rpmsg_char_init); +postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { From patchwork Tue Dec 22 10:57:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C790C43219 for ; Tue, 22 Dec 2020 10:59:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BB1B23103 for ; Tue, 22 Dec 2020 10:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbgLVK6y (ORCPT ); Tue, 22 Dec 2020 05:58:54 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:60576 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbgLVK6x (ORCPT ); Tue, 22 Dec 2020 05:58:53 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAv8qC017308; Tue, 22 Dec 2020 11:58:06 +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=a62gM3orD3nqincVNUEbPtqfMSCUDzJOCYWC7XKQ9Vk=; b=QQn8J9j5woiZ1m0pKpdr2gfQd+Z0q48wWQnsdHo8Y8/eZINFYgjVIR40RUwD065opNJ0 i9Q5hRe1em4LPQzH81KIPcxJ8p0AbJnxV1UJg++8SzsVN20DqZa1CiK6vYFcTlOz6aTw aOmx7raG23JVxbd7oTx3GLjKJuHrC1cAmIjslhkdRQ0xh+3NMPcOLPUeICnqtQkWoGR3 1cb9oD2Nlrxa0ZKimukaUXpwgZR+/HiC+wKGA/oveFqqi5vC/OiZPoYCXfVqwk7O98WI dgPN3zUDaK3yPRj8yh3m3lXCkUMWAaLEfu6E/XkXBe3/+HXrrBBZdUYfU9MA1pgc9441 UA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k7vva3ha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:06 +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 13A53100038; Tue, 22 Dec 2020 11:58:06 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B81B021BD81; Tue, 22 Dec 2020 11:58:05 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:05 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 09/16] rpmsg: char: register RPMsg raw service to the ioctl interface. Date: Tue, 22 Dec 2020 11:57:19 +0100 Message-ID: <20201222105726.16906-10-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Associate the RPMsg char to the RPMSG_RAW_SERVICE, by registering it to the RPMsg Control. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 3d77f4d5fc32..66e01b979e72 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -394,6 +394,11 @@ static struct rpmsg_driver rpmsg_chrdev_driver = { }, }; +const struct rpmsg_drv_ctrl_info rpmsg_chrdev_ctrl = { + .drv_name = "rpmsg_chrdev", + .service = RPMSG_RAW_SERVICE, +}; + static int rpmsg_chrdev_init(void) { int ret; @@ -407,15 +412,27 @@ static int rpmsg_chrdev_init(void) ret = register_rpmsg_driver(&rpmsg_chrdev_driver); if (ret < 0) { pr_err("rpmsg: failed to register rpmsg chrdev driver\n"); - unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); + goto free_region; } + ret = rpmsg_ctrl_register_ctl(&rpmsg_chrdev_ctrl); + if (ret < 0) + goto free_rpmsg; + + return 0; + +free_rpmsg: + unregister_rpmsg_driver(&rpmsg_chrdev_driver); +free_region: + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); + return ret; } postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { + rpmsg_ctrl_unregister_ctl(&rpmsg_chrdev_ctrl); unregister_rpmsg_driver(&rpmsg_chrdev_driver); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } From patchwork Tue Dec 22 10:57:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F0BDC4332D for ; Tue, 22 Dec 2020 10:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 440EF23428 for ; Tue, 22 Dec 2020 10:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgLVK6y (ORCPT ); Tue, 22 Dec 2020 05:58:54 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39096 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726475AbgLVK6x (ORCPT ); Tue, 22 Dec 2020 05:58:53 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw5bQ004484; Tue, 22 Dec 2020 11:58:07 +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=dvvXlfzm0tzQLnZ/koaGqjFe70fZMQECn12d7ShvXeY=; b=Auf47oorCjoi4zwl3e1NglH2aw+d1y/G2f4VD6PUxFPRyklsD6MVpC43AsCIcPHOL75I uxF9UtGmyJGbOxZwQfZnKjjLoXBNKeA/wXNqfR0oL+h8zvST5Yv8AxXG5LZ4hqkPqj79 y2PJsSwJFWXLScitpwEhgTcz+QVGNnvqzNfCD3oPhXCB84HdhB/6lNIfKSK3JLpXLHZX ZSNHOU3uNL6ihLHCzA76VSdrUC0mXD5msIorfuARyKPdSjlxUzbsUDNL66ct8ALEqcDt HkIEdnViyJWMMVruBxdhJlakdHmHnvcB0WJTW0NZJ0MIvzQy+oi8V0/7GTjZhT3Sy4mQ NQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0cgky56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:07 +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 A6E9710002A; Tue, 22 Dec 2020 11:58:06 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9925022ECB0; Tue, 22 Dec 2020 11:58:06 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:06 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 10/16] rpmsg: char: allow only one endpoint per device Date: Tue, 22 Dec 2020 11:57:20 +0100 Message-ID: <20201222105726.16906-11-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Only one endpoint can be created per device, prevent from multi open. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 66e01b979e72..4b0674a2e3e9 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -122,6 +122,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) struct rpmsg_device *rpdev = eptdev->rpdev; struct device *dev = &eptdev->dev; + if (eptdev->ept) + return -EBUSY; + get_device(dev); ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); From patchwork Tue Dec 22 10:57:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3435C433E6 for ; Tue, 22 Dec 2020 10:59:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5BB22310D for ; Tue, 22 Dec 2020 10:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbgLVK6y (ORCPT ); Tue, 22 Dec 2020 05:58:54 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:10208 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726558AbgLVK6x (ORCPT ); Tue, 22 Dec 2020 05:58:53 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw6be012877; Tue, 22 Dec 2020 11:58:07 +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=kDkn3Ch/ijKh7T5HcklMbiVwxsHO7ZaypNzAx6hkCrs=; b=ctsYdK2/hB54QI+hF2dR3CgMnDFRg+t/F69zvtv22DiyDdVc+6UM2ac1tbuDE3qz01nn XbEtBjB/spm0W0XlFDK6uu88RM/CZDj16aeWvhUZaXGP/chIG8k1TCJCp6kUAn8J403T UcL8c6XITqDZYU2JiFUiSUp70rv/Uz8m4w5w9xM0u7RoRsBIOmAlTIAu8Lc5RXJ+ByA3 bBD5BU7L6RuaXutnb8WFy+SAPKnCillTTxQ14TZyeY1rBOjyara+4RoZ70KNVlQ4n33l NBSlTnUfIpr6y0PSgjg4ohNyPrOUyXp8xoUJ/hYvL0K9EmTfXmTNtdaewGBl/MmQOM27 MQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0eb3xbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:07 +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 76CB7100034; Tue, 22 Dec 2020 11:58:07 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6A3BB22ECB4; Tue, 22 Dec 2020 11:58:07 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:06 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 11/16] rpmsg: char: check destination address is not null Date: Tue, 22 Dec 2020 11:57:21 +0100 Message-ID: <20201222105726.16906-12-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The name service announcement is not sent if no endpoint is created by default. If the destination address is not precised by the application when creating the device (thanks to the RPMsg CTRL interface), it is not possible to have a valid RPMsg channel. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 4b0674a2e3e9..8b1928594d10 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -305,6 +305,16 @@ static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) struct device *dev; int ret; + /* There is not ept created by default. As consequence there is not NS + * announcement and the destination address has to be set. + * this limitation could be solved in future by adding a helper in + * rpmsg_ns. + */ + if (rpdev->dst == RPMSG_ADDR_ANY) { + dev_err(dev, "destination address invalid (%d)\n", rpdev->dst); + return -EINVAL; + } + eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL); if (!eptdev) return -ENOMEM; From patchwork Tue Dec 22 10:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EF61C43333 for ; Tue, 22 Dec 2020 10:59:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D056723103 for ; Tue, 22 Dec 2020 10:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbgLVK6y (ORCPT ); Tue, 22 Dec 2020 05:58:54 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39106 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725847AbgLVK6y (ORCPT ); Tue, 22 Dec 2020 05:58:54 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw7bS004508; Tue, 22 Dec 2020 11:58:08 +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=FvUUYLv2sdHQDAD6TMTnFsgYR6QnR4DXZXkL8+B6VwY=; b=1oQB3pCeIgtSu1zbzjQT5Xa6VlRLXfLAvy93JORdtgYpHD2lrxw5oGxy5Z+AoO7OBoYF lk5sJmAmPxeJGQcZmxNslbXW0yxXZ0CyfO3Ot37ww4YfL2SdIB2zr67gY5cRDuXXMal2 r4cXDJ62RQcF62ZVN93J+Ymdw8wJyJy/GHw01lXI0YOR+dXWGhJR5JmZqgOcSo8gTyS4 tukQKhRn1mwNw+X80FOAhzhCtK99y06S70Ff5CcxkHq/JsqA65tLLyb6LWk6z1K3oUrw 2kj4KDi68tbGVaf0KbO0W/8N+YBCbgNRFq3ls1aRmLAU63X6YkJMCqEP83w48yoD+Zd6 Fw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0cgky5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:08 +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 2CC1110002A; Tue, 22 Dec 2020 11:58:08 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2038122ECB4; Tue, 22 Dec 2020 11:58:08 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:07 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 12/16] rpmsg: virtio: use the driver_override in channel creation ops Date: Tue, 22 Dec 2020 11:57:22 +0100 Message-ID: <20201222105726.16906-13-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Use the override information from the channel info structure to set the rpdev override and so links the channel to a specific driver. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/virtio_rpmsg_bus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index e87d4cf926eb..c1d4bc08b2a5 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -416,6 +416,7 @@ static struct rpmsg_device *__rpmsg_create_channel(struct virtproc_info *vrp, rpdev->dst = chinfo->dst; rpdev->ops = &virtio_rpmsg_ops; rpdev->little_endian = virtio_is_little_endian(vrp->vdev); + rpdev->driver_override = (char *)chinfo->driver_override; /* * rpmsg server channels has predefined local address (for now), From patchwork Tue Dec 22 10:57:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 936CFC4332E for ; Tue, 22 Dec 2020 10:59:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71AFF23105 for ; Tue, 22 Dec 2020 10:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbgLVK7T (ORCPT ); Tue, 22 Dec 2020 05:59:19 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39112 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726472AbgLVK6z (ORCPT ); Tue, 22 Dec 2020 05:58:55 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw9pW004543; Tue, 22 Dec 2020 11:58:09 +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=c2XvvSMgDCCnTaAY3jbSmk9uGPUA2xW5xqLUmTInDws=; b=C6kLm2urh/nNP2rHpTyJquSyFfD/bhecqA2xfmCpcsduiLLQt1uR9/liJJIYPGqnQhQ6 2knMTojgTIJ91Lmvv4dSbSiIlUi6J53E0BXIExXVcv9iZmMAH8FugTG0mo0CxdxFTXEz R3cE1cn/+Z+eM+lXwCKvzb2sIjZlWTHvkHpjjLWWDoezlZz19divlGrBaPp8e45vJnM7 JFOxc4DswdQpZrAFlx0KsuAQ1jEcgH9njGB4A+BVsRZJW3vhTK9CKZh9CstSydHbHZzv gfYqsB7m9nbjj6iPuY+O+9AI8reFUmztSBPC/FkJ+LNu8OPNgFw3mZCcFyDY3GfSNMYj jg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0cgky5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:09 +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 03781100034; Tue, 22 Dec 2020 11:58:09 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E9A4022ECB4; Tue, 22 Dec 2020 11:58:08 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:08 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 13/16] rpmsg: virtio: probe the rpmsg_ctl device Date: Tue, 22 Dec 2020 11:57:23 +0100 Message-ID: <20201222105726.16906-14-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Probe the rpmsg_ctl driver on virtio rpmsg bus creation. This provides the possibility to expose an ioctrl to create RPMsg channels. Signed-off-by: Arnaud Pouliquen Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/rpmsg/virtio_rpmsg_bus.c | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index c1d4bc08b2a5..e8caccb2d298 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -814,6 +814,35 @@ static void rpmsg_xmit_done(struct virtqueue *svq) wake_up_interruptible(&vrp->sendq); } +static struct rpmsg_device *rpmsg_virtio_add_char_dev(struct virtio_device *vdev) +{ + struct virtproc_info *vrp = vdev->priv; + struct virtio_rpmsg_channel *vch; + struct rpmsg_device *rpdev_ctrl; + int err = 0; + + vch = kzalloc(sizeof(*vch), GFP_KERNEL); + if (!vch) + return ERR_PTR(-ENOMEM); + + /* Link the channel to our vrp */ + vch->vrp = vrp; + + /* Assign public information to the rpmsg_device */ + rpdev_ctrl = &vch->rpdev; + rpdev_ctrl->ops = &virtio_rpmsg_ops; + + rpdev_ctrl->dev.parent = &vrp->vdev->dev; + rpdev_ctrl->dev.release = virtio_rpmsg_release_device; + rpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev); + + err = rpmsg_ctl_register_device(rpdev_ctrl); + if (err) + return ERR_PTR(err); + + return rpdev_ctrl; +} + static int rpmsg_probe(struct virtio_device *vdev) { vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done }; @@ -821,7 +850,7 @@ static int rpmsg_probe(struct virtio_device *vdev) struct virtqueue *vqs[2]; struct virtproc_info *vrp; struct virtio_rpmsg_channel *vch; - struct rpmsg_device *rpdev_ns; + struct rpmsg_device *rpdev_ns, *rpdev_ctrl; void *bufs_va; int err = 0, i; size_t total_buf_space; @@ -919,6 +948,11 @@ static int rpmsg_probe(struct virtio_device *vdev) goto free_coherent; } + rpdev_ctrl = rpmsg_virtio_add_char_dev(vdev); + if (IS_ERR(rpdev_ctrl)) { + err = PTR_ERR(rpdev_ctrl); + goto free_coherent; + } /* * Prepare to kick but don't notify yet - we can't do this before * device is ready. @@ -942,6 +976,7 @@ static int rpmsg_probe(struct virtio_device *vdev) free_coherent: kfree(vch); + kfree(to_virtio_rpmsg_channel(rpdev_ctrl)); dma_free_coherent(vdev->dev.parent, total_buf_space, bufs_va, vrp->bufs_dma); vqs_del: From patchwork Tue Dec 22 10:57:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2917C432C3 for ; Tue, 22 Dec 2020 10:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F70E2313C for ; Tue, 22 Dec 2020 10:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725847AbgLVK64 (ORCPT ); Tue, 22 Dec 2020 05:58:56 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:10238 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726666AbgLVK64 (ORCPT ); Tue, 22 Dec 2020 05:58:56 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAw87T012890; Tue, 22 Dec 2020 11:58:10 +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=9YJwuMmhvQjiQZdfwPozN0/SAPH4XLa1zY4sMK1+Xeg=; b=LeAUFUX7Ip/yc7kvLlcHnK+5FhabePxZma6STCdwPaRczv/OYzqvNyKBXq1FAZEV//xT kGnmaZ20KVgX1YxFkgtRqc4p64lipOqivFYKl8pg4DgiKOqDjQuYMyOheRqe3XcYJo6t iIXgsIqhOzVVcSyPlACyFo5lywcEGVjkCzG+czalBomy3+pbEGCbq5hS+U8G8pZARuTX dPoyhidDxg/vC8ADIKmZlF4nif61MA/hHvP10wYcJNCWhnLiwCOfF9PJaor65VmdZAlh aNA0D6G3C5vRy7iS669Ir8LjGBT05c3oojSEe37uLBsjTZI62usn1h05y5lRKvQ2PZqc IQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0eb3xc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:10 +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 C270810002A; Tue, 22 Dec 2020 11:58:09 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B51FB22ECB4; Tue, 22 Dec 2020 11:58:09 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:09 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 14/16] rpmsg: glink: add create and release rpmsg channel ops Date: Tue, 22 Dec 2020 11:57:24 +0100 Message-ID: <20201222105726.16906-15-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add the new ops introduced by the rpmsg_ns series and used by the rpmsg_ctrl driver to instantiate a new rpmsg channel. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/qcom_glink_native.c | 94 ++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 19 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 27a05167c18c..d74c338de077 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -205,6 +205,9 @@ static const struct rpmsg_endpoint_ops glink_endpoint_ops; #define GLINK_FEATURE_INTENTLESS BIT(1) static void qcom_glink_rx_done_work(struct work_struct *work); +static struct rpmsg_device * +qcom_glink_create_rpdev(struct qcom_glink *glink, + struct rpmsg_channel_info *chinfo); static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink, const char *name) @@ -1203,6 +1206,37 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev) return 0; } +static struct rpmsg_device * +qcom_glink_create_channel(struct rpmsg_device *rp_parent, + struct rpmsg_channel_info *chinfo) +{ + struct glink_channel *channel = to_glink_channel(rp_parent->ept); + struct qcom_glink *glink = channel->glink; + struct rpmsg_device *rpdev; + const char *name = chinfo->name; + + channel = qcom_glink_alloc_channel(glink, name); + if (IS_ERR(channel)) + return ERR_PTR(PTR_ERR(channel)); + + rpdev = qcom_glink_create_rpdev(glink, chinfo); + if (!IS_ERR(rpdev)) { + rpdev->ept = &channel->ept; + channel->rpdev = rpdev; + } + + return rpdev; +} + +static int qcom_glink_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + struct glink_channel *channel = to_glink_channel(rpdev->ept); + struct qcom_glink *glink = channel->glink; + + return rpmsg_unregister_device(glink->dev, chinfo); +} + static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept) { struct glink_channel *channel = to_glink_channel(ept); @@ -1359,6 +1393,8 @@ static struct device_node *qcom_glink_match_channel(struct device_node *node, static const struct rpmsg_device_ops glink_device_ops = { .create_ept = qcom_glink_create_ept, .announce_create = qcom_glink_announce_create, + .create_channel = qcom_glink_create_channel, + .release_channel = qcom_glink_release_channel, }; static const struct rpmsg_endpoint_ops glink_endpoint_ops = { @@ -1376,13 +1412,45 @@ static void qcom_glink_rpdev_release(struct device *dev) kfree(rpdev); } +static struct rpmsg_device * +qcom_glink_create_rpdev(struct qcom_glink *glink, + struct rpmsg_channel_info *chinfo) +{ + struct rpmsg_device *rpdev; + struct device_node *node; + int ret; + + rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL); + if (!rpdev) + return ERR_PTR(-ENOMEM); + + strncpy(rpdev->id.name, chinfo->name, RPMSG_NAME_SIZE); + rpdev->src = chinfo->src; + rpdev->dst = chinfo->dst; + rpdev->ops = &glink_device_ops; + + node = qcom_glink_match_channel(glink->dev->of_node, chinfo->name); + rpdev->dev.of_node = node; + rpdev->dev.parent = glink->dev; + rpdev->dev.release = qcom_glink_rpdev_release; + rpdev->driver_override = (char *)chinfo->driver_override; + + ret = rpmsg_register_device(rpdev); + if (ret) { + kfree(rpdev); + return ERR_PTR(ret); + } + + return rpdev; +} + static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid, char *name) { struct glink_channel *channel; struct rpmsg_device *rpdev; bool create_device = false; - struct device_node *node; + struct rpmsg_channel_info chinfo; int lcid; int ret; unsigned long flags; @@ -1416,27 +1484,15 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid, complete_all(&channel->open_req); if (create_device) { - rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL); - if (!rpdev) { - ret = -ENOMEM; + strncpy(chinfo.name, channel->name, sizeof(chinfo.name)); + chinfo.src = RPMSG_ADDR_ANY; + chinfo.dst = RPMSG_ADDR_ANY; + rpdev = qcom_glink_create_rpdev(glink, &chinfo); + if (IS_ERR(rpdev)) { + ret = PTR_ERR(rpdev); goto rcid_remove; } - rpdev->ept = &channel->ept; - strncpy(rpdev->id.name, name, RPMSG_NAME_SIZE); - rpdev->src = RPMSG_ADDR_ANY; - rpdev->dst = RPMSG_ADDR_ANY; - rpdev->ops = &glink_device_ops; - - node = qcom_glink_match_channel(glink->dev->of_node, name); - rpdev->dev.of_node = node; - rpdev->dev.parent = glink->dev; - rpdev->dev.release = qcom_glink_rpdev_release; - - ret = rpmsg_register_device(rpdev); - if (ret) - goto rcid_remove; - channel->rpdev = rpdev; } From patchwork Tue Dec 22 10:57:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 175F2C433DB for ; Tue, 22 Dec 2020 10:59:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC45023105 for ; Tue, 22 Dec 2020 10:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgLVK65 (ORCPT ); Tue, 22 Dec 2020 05:58:57 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:60602 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726681AbgLVK64 (ORCPT ); Tue, 22 Dec 2020 05:58:56 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAvKvC017379; Tue, 22 Dec 2020 11:58:11 +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=hSH+H/5k2tLr+GOxs0FZsD8RmN2qSemTHcqXNWMd+Kk=; b=akxDJVmAlcc8vCZTooD8MGXAmwVlQPkX5n52kvzCdN9l/knVvzjLf2eb5AHtvxrpa1P6 Z4aD3KF+Oxf1MOHAgKBH1H9+DvhIlQP43aq30zqiEHfM2Pdj4ndsFeI2mgW00gV7Rg0h /X9Z27iO8PElu5FZ0dKnNwmRhNWxweNulPgU+34oVPM0hQt0myDZOYno7vHm5uHeg6y7 wQMTWvOcJ1WRSLFRZdtUItIUtTH6OAleMCof8n1wlieSTC8cpdHMpJEf7vTAEhLczrst aXVovvAbU0goo92Qe9dNNDii28wvgxdoLiWFs3SYAsR6sYzGBqA9KoZkgMo+xj0awMMX SA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k7vva3hq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:10 +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 934F5100034; Tue, 22 Dec 2020 11:58:10 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8663622ECB4; Tue, 22 Dec 2020 11:58:10 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:10 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 15/16] rpmsg: smd: add create and release rpmsg channel ops Date: Tue, 22 Dec 2020 11:57:25 +0100 Message-ID: <20201222105726.16906-16-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-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 SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add the new ops introduced by the rpmsg_ns series and used by the rpmsg_ctrl driver to instantiate a new rpmsg channel. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/qcom_smd.c | 57 ++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 19903de6268d..40853702f54f 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -67,6 +67,7 @@ struct smd_channel_info_word; struct smd_channel_info_word_pair; static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops; +static const struct rpmsg_device_ops qcom_smd_device_ops; #define SMD_ALLOC_TBL_COUNT 2 #define SMD_ALLOC_TBL_SIZE 64 @@ -1013,6 +1014,52 @@ static struct device_node *qcom_smd_match_channel(struct device_node *edge_node, return NULL; } +static void qcom_smd_release_device(struct device *dev) +{ + struct rpmsg_device *rpdev = to_rpmsg_device(dev); + struct qcom_smd_device *qsdev = to_smd_device(rpdev); + + kfree(qsdev); +} + +static struct rpmsg_device * +qcom_smd_create_rpmsg_ch(struct rpmsg_device *rp_parent, + struct rpmsg_channel_info *chinfo) +{ + struct qcom_smd_device *qsdev, *qspdev = to_smd_device(rp_parent); + struct qcom_smd_edge *edge = qspdev->edge; + int ret; + + qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL); + if (!qsdev) + return ERR_PTR(-ENOMEM); + + qsdev->edge = edge; + strncpy(qsdev->rpdev.id.name, chinfo->name, RPMSG_NAME_SIZE); + qsdev->rpdev.src = chinfo->src; + qsdev->rpdev.dst = chinfo->dst; + qsdev->rpdev.ops = &qcom_smd_device_ops; + qsdev->rpdev.dev.parent = &edge->dev; + qsdev->rpdev.dev.release = qcom_smd_release_device; + qsdev->rpdev.driver_override = (char *)chinfo->driver_override; + + ret = rpmsg_register_device(&qsdev->rpdev); + if (ret) { + kfree(qsdev); + return ERR_PTR(ret); + } + + return &qsdev->rpdev; +} + +static int qcom_smd_release_rpmsg_ch(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + struct qcom_smd_device *qsdev = to_smd_device(rpdev); + + return rpmsg_unregister_device(&qsdev->edge->dev, chinfo); +} + static int qcom_smd_announce_create(struct rpmsg_device *rpdev) { struct qcom_smd_endpoint *qept = to_smd_endpoint(rpdev->ept); @@ -1033,6 +1080,8 @@ static int qcom_smd_announce_create(struct rpmsg_device *rpdev) static const struct rpmsg_device_ops qcom_smd_device_ops = { .create_ept = qcom_smd_create_ept, .announce_create = qcom_smd_announce_create, + .create_channel = qcom_smd_create_rpmsg_ch, + .release_channel = qcom_smd_release_rpmsg_ch, }; static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = { @@ -1042,14 +1091,6 @@ static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = { .poll = qcom_smd_poll, }; -static void qcom_smd_release_device(struct device *dev) -{ - struct rpmsg_device *rpdev = to_rpmsg_device(dev); - struct qcom_smd_device *qsdev = to_smd_device(rpdev); - - kfree(qsdev); -} - /* * Create a smd client device for channel that is being opened. */ From patchwork Tue Dec 22 10:57:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11986325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27052C43603 for ; Tue, 22 Dec 2020 10:59:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 116CE23435 for ; Tue, 22 Dec 2020 10:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726904AbgLVK7C (ORCPT ); Tue, 22 Dec 2020 05:59:02 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:10140 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726719AbgLVK65 (ORCPT ); Tue, 22 Dec 2020 05:58:57 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BMAwBBe013253; Tue, 22 Dec 2020 11:58:11 +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=GnrvcVYo8oknBArAITI8FeTCO3KM0M394BJS3J15Epo=; b=BHrc2VHic7TUD5dltTYTaZbMQF7jV1XKLn2r2nODsU5u4R3MrqogouJSdh53H1yUDImt 3pqZ7M7XHRB5f2TqlZloMyouONCkXdAEzdg5wHXq2RF/dhQDHgeA0sdT+wuUVe7Go5o6 hCVgA80S18nGpAfCG92bx3WOhqI0kC8yEA14mro4r3Dd6j4aor/DG6YaY8vteqbOIsGl 61vcs1qUUw1ux2nxkQe5kRHpo7snOy65zYW2jksgbswe76yngFBDw7MQ2aR2Ie0IkN7T 70FF1XcKFM2VhChS+0sVmDFN7OG+6TWv2kJVOjg0u81fG6iKoZiVxSuBj8kgslaw+kQB yQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35k0eb3xca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 11:58:11 +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 5308710002A; Tue, 22 Dec 2020 11:58:11 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 457F222ECBD; Tue, 22 Dec 2020 11:58:11 +0100 (CET) Received: from localhost (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 22 Dec 2020 11:58:10 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v2 16/16] rpmsg: replace rpmsg_chrdev_register_device use Date: Tue, 22 Dec 2020 11:57:26 +0100 Message-ID: <20201222105726.16906-17-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_04:2020-12-21,2020-12-22 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Replace rpmsg_chrdev_register_device by the new helper rpmsg_ctl_register_device to probe the new IOCTL interface. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/qcom_glink_native.c | 2 +- drivers/rpmsg/qcom_smd.c | 2 +- drivers/rpmsg/rpmsg_internal.h | 14 -------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index d74c338de077..6c7bb84f7da9 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1681,7 +1681,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_ctl_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 40853702f54f..a39457c57705 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1138,7 +1138,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_ctl_register_device(&qsdev->rpdev); } /* diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index a76c344253bf..c81dfb374b64 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -81,19 +81,5 @@ struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); int rpmsg_release_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); -/** - * rpmsg_chrdev_register_device() - register chrdev device 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) -{ - strcpy(rpdev->id.name, "rpmsg_chrdev"); - rpdev->driver_override = "rpmsg_chrdev"; - - return rpmsg_register_device(rpdev); -} #endif