From patchwork Fri Jul 31 12:10:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694799 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17DDE722 for ; Fri, 31 Jul 2020 12:12:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E91AA2245C for ; Fri, 31 Jul 2020 12:12:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="q8GOR9mp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733082AbgGaML6 (ORCPT ); Fri, 31 Jul 2020 08:11:58 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4514 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732886AbgGaMLG (ORCPT ); Fri, 31 Jul 2020 08:11:06 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC7cQn011783; Fri, 31 Jul 2020 14:11:02 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=cVheV20ZNKPxcFr0xDJ7TW1uuXFbr75eOpa/Iq2uNJ8=; b=q8GOR9mpzUsC3ATCIQiAiPYdCDBfrnecGzKrKzS6TKjRfqHwORQXWt/T6+hSfUfTLgOa WPCc/YCPR123dRFwOf654hQcj8oarmxRrQyWbY6OZf9wSV4BHIUUJXFeLNOI1BSTFS7s O86a4bBV1Lg376VG73M7ozfO7A3KSehy2Y2L9XQb26Y/uc5usNPamwsUmUPKGp+W1lId wDg3nBQe1m14hesq0T/Rsm03jsx7WSVWFpmMRsPYcerBFit+78bjAY5kQkChYdgjj3+x w6L5YaTzXFaVPQMvfNjbYPpJtxH+AfgRKnFMp3DfJeIRWaTaqFXwYghHQZLDa4C9TvDu FA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32g9v9xku7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:02 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A5E7110002A; Fri, 31 Jul 2020 14:11:01 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 96BEA2AE6DD; Fri, 31 Jul 2020 14:11:01 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:00 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 01/13] rpmsg: introduce rpmsg raw driver Date: Fri, 31 Jul 2020 14:10:31 +0200 Message-ID: <20200731121043.24199-2-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org This driver is a copy past of the rpmsg_char driver with following update: - The control part has been removed. - The rpmsg class has been removed because the information already available in /sys/bus. - The device is now an RPMsg device probed by a RPMsg bus driver. - The associated endpoint is now created by the bus not on the fs open. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/Kconfig | 9 + drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_raw.c | 347 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_raw.c diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 0143c9864c45..900ec8f54081 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -23,6 +23,15 @@ config RPMSG_NS channel that probes the associate RPMsg device on remote endpoint service announcement. +config RPMSG_RAW + tristate "RPMSG raw service driver" + depends on RPMSG + depends on NET + help + Say Y here to export rpmsg endpoints as char device files, found + in /dev. They make it possible for user-space programs to send and + receive rpmsg packets through a basic char device. + config RPMSG_MTK_SCP tristate "MediaTek SCP" depends on MTK_SCP diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index 8d452656f0ee..d75f0a65e71d 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o obj-$(CONFIG_RPMSG_QCOM_SMD) += qcom_smd.o obj-$(CONFIG_RPMSG_VIRTIO) += virtio_rpmsg_bus.o +obj-$(CONFIG_RPMSG_RAW) += rpmsg_raw.o diff --git a/drivers/rpmsg/rpmsg_raw.c b/drivers/rpmsg/rpmsg_raw.c new file mode 100644 index 000000000000..8684a78ab4d1 --- /dev/null +++ b/drivers/rpmsg/rpmsg_raw.c @@ -0,0 +1,347 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) STMicroelectronics 2020 - All Rights Reserved + * + * Based on rpmsg_char driver. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rpmsg_internal.h" + +#define RPMSG_DEV_MAX (MINORMASK + 1) + +#define dev_to_eptdev(dev) container_of(dev, struct rpmsg_raw, dev) +#define cdev_to_eptdev(i_cdev) container_of(i_cdev, struct rpmsg_raw, cdev) + +static dev_t rpmsg_raw_major; + +static DEFINE_IDA(rpmsg_minor_ida); +static DEFINE_IDA(rpmsg_ept_ida); + +/** + * struct rpmsg_raw - endpoint device context + * @dev: endpoint device + * @cdev: cdev for the endpoint device + * @rpdev: underlaying rpmsg device + * @ept_lock: synchronization of @ept modifications + * @queue_lock: synchronization of @queue operations + * @queue: incoming message queue + * @readq: wait object for incoming queue + */ +struct rpmsg_raw { + struct device dev; + struct cdev cdev; + struct rpmsg_device *rpdev; + struct mutex ept_lock; + spinlock_t queue_lock; + struct sk_buff_head queue; + wait_queue_head_t readq; +}; + +static int rpmsg_raw_cb(struct rpmsg_device *rpdev, void *buf, int len, + void *priv, u32 addr) +{ + struct rpmsg_raw *eptdev = dev_get_drvdata(&rpdev->dev); + struct sk_buff *skb; + + skb = alloc_skb(len, GFP_ATOMIC); + if (!skb) + return -ENOMEM; + + skb_put_data(skb, buf, len); + + spin_lock(&eptdev->queue_lock); + skb_queue_tail(&eptdev->queue, skb); + spin_unlock(&eptdev->queue_lock); + + /* wake up any blocking processes, waiting for new data */ + wake_up_interruptible(&eptdev->readq); + + return 0; +} + +static int rpmsg_raw_open(struct inode *inode, struct file *filp) +{ + struct rpmsg_raw *eptdev = cdev_to_eptdev(inode->i_cdev); + struct device *dev = &eptdev->dev; + + get_device(dev); + + filp->private_data = eptdev; + + return 0; +} + +static int rpmsg_raw_release(struct inode *inode, struct file *filp) +{ + struct rpmsg_raw *eptdev = cdev_to_eptdev(inode->i_cdev); + + /* Discard all SKBs */ + skb_queue_purge(&eptdev->queue); + + put_device(&eptdev->dev); + + return 0; +} + +static ssize_t rpmsg_raw_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + struct file *filp = iocb->ki_filp; + struct rpmsg_raw *eptdev = filp->private_data; + unsigned long flags; + struct sk_buff *skb; + int use; + + if (!eptdev->rpdev->ept) + return -EPIPE; + + spin_lock_irqsave(&eptdev->queue_lock, flags); + + /* Wait for data in the queue */ + if (skb_queue_empty(&eptdev->queue)) { + spin_unlock_irqrestore(&eptdev->queue_lock, flags); + + if (filp->f_flags & O_NONBLOCK) + return -EAGAIN; + + /* Wait until we get data or the endpoint goes away */ + if (wait_event_interruptible(eptdev->readq, + !skb_queue_empty(&eptdev->queue) || + !eptdev->rpdev->ept)) + return -ERESTARTSYS; + + /* We lost the endpoint while waiting */ + if (!eptdev->rpdev->ept) + return -EPIPE; + + spin_lock_irqsave(&eptdev->queue_lock, flags); + } + + skb = skb_dequeue(&eptdev->queue); + spin_unlock_irqrestore(&eptdev->queue_lock, flags); + if (!skb) + return -EFAULT; + + use = min_t(size_t, iov_iter_count(to), skb->len); + if (copy_to_iter(skb->data, use, to) != use) + use = -EFAULT; + + kfree_skb(skb); + + return use; +} + +static ssize_t rpmsg_raw_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + struct file *filp = iocb->ki_filp; + struct rpmsg_raw *eptdev = filp->private_data; + size_t len = iov_iter_count(from); + void *kbuf; + int ret; + + kbuf = kzalloc(len, GFP_KERNEL); + if (!kbuf) + return -ENOMEM; + + if (!copy_from_iter_full(kbuf, len, from)) { + ret = -EFAULT; + goto free_kbuf; + } + + if (mutex_lock_interruptible(&eptdev->ept_lock)) { + ret = -ERESTARTSYS; + goto free_kbuf; + } + + if (!eptdev->rpdev->ept) { + ret = -EPIPE; + goto unlock_eptdev; + } + + if (filp->f_flags & O_NONBLOCK) + ret = rpmsg_trysend(eptdev->rpdev->ept, kbuf, len); + else + ret = rpmsg_send(eptdev->rpdev->ept, kbuf, len); + +unlock_eptdev: + mutex_unlock(&eptdev->ept_lock); + +free_kbuf: + kfree(kbuf); + return ret < 0 ? ret : len; +} + +static __poll_t rpmsg_raw_poll(struct file *filp, poll_table *wait) +{ + struct rpmsg_raw *eptdev = filp->private_data; + __poll_t mask = 0; + + if (!eptdev->rpdev->ept) + return EPOLLERR; + + poll_wait(filp, &eptdev->readq, wait); + + if (!skb_queue_empty(&eptdev->queue)) + mask |= EPOLLIN | EPOLLRDNORM; + + mask |= rpmsg_poll(eptdev->rpdev->ept, filp, wait); + + return mask; +} + +static void rpmsg_raw_release_device(struct device *dev) +{ + struct rpmsg_raw *eptdev = dev_to_eptdev(dev); + + ida_simple_remove(&rpmsg_ept_ida, dev->id); + ida_simple_remove(&rpmsg_minor_ida, MINOR(eptdev->dev.devt)); + cdev_del(&eptdev->cdev); + kfree(eptdev); +} + +static const struct file_operations rpmsg_raw_fops = { + .owner = THIS_MODULE, + .open = rpmsg_raw_open, + .release = rpmsg_raw_release, + .read_iter = rpmsg_raw_read_iter, + .write_iter = rpmsg_raw_write_iter, + .poll = rpmsg_raw_poll, +}; + +static int rpmsg_raw_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_raw *eptdev; + struct device *dev; + int ret; + + eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL); + if (!eptdev) + return -ENOMEM; + + dev = &eptdev->dev; + eptdev->rpdev = rpdev; + + mutex_init(&eptdev->ept_lock); + spin_lock_init(&eptdev->queue_lock); + skb_queue_head_init(&eptdev->queue); + init_waitqueue_head(&eptdev->readq); + + device_initialize(dev); + dev->parent = &rpdev->dev; + dev_set_drvdata(dev, eptdev); + + cdev_init(&eptdev->cdev, &rpmsg_raw_fops); + eptdev->cdev.owner = THIS_MODULE; + + ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); + if (ret < 0) { + dev_err(dev, "failed to get IDA (%d)\n", ret); + goto free_eptdev; + } + + dev->devt = MKDEV(MAJOR(rpmsg_raw_major), ret); + + ret = ida_simple_get(&rpmsg_ept_ida, 0, 0, GFP_KERNEL); + if (ret < 0) + goto free_minor_ida; + dev->id = ret; + dev_set_name(dev, "rpmsg%d", dev->id); + + ret = cdev_add(&eptdev->cdev, dev->devt, 1); + if (ret) { + ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); + 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_raw_release_device; + + ret = device_add(dev); + if (ret) { + dev_err(dev, "device_add failed: %d\n", ret); + put_device(dev); + } + + dev_set_drvdata(&rpdev->dev, eptdev); + + return ret; + +free_ept_ida: + ida_simple_remove(&rpmsg_ept_ida, dev->id); +free_minor_ida: + ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); +free_eptdev: + put_device(dev); + kfree(eptdev); + + return ret; +} + +static void rpmsg_raw_remove(struct rpmsg_device *rpdev) +{ + struct rpmsg_raw *eptdev = dev_get_drvdata(&rpdev->dev); + + /* wake up any blocked readers */ + wake_up_interruptible(&eptdev->readq); + + device_del(&eptdev->dev); + + put_device(&eptdev->dev); +} + +static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = { + { .name = "rpmsg-raw" }, + { }, +}; +MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_sample_id_table); + +static struct rpmsg_driver rpmsg_raw_client = { + .drv.name = KBUILD_MODNAME, + .id_table = rpmsg_driver_sample_id_table, + .probe = rpmsg_raw_probe, + .callback = rpmsg_raw_cb, + .remove = rpmsg_raw_remove, +}; + +static int rpmsg_raw_init(void) +{ + int ret; + + ret = alloc_chrdev_region(&rpmsg_raw_major, 0, RPMSG_DEV_MAX, + "rpmsg"); + if (ret < 0) { + pr_err("rpmsg: failed to allocate char dev region\n"); + return ret; + } + + ret = register_rpmsg_driver(&rpmsg_raw_client); + if (ret < 0) + unregister_chrdev_region(rpmsg_raw_major, RPMSG_DEV_MAX); + + return ret; +} +module_init(rpmsg_raw_init); + +static void rpmsg_raw_exit(void) +{ + unregister_rpmsg_driver(&rpmsg_raw_client); + unregister_chrdev_region(rpmsg_raw_major, RPMSG_DEV_MAX); +} +module_exit(rpmsg_raw_exit); + +MODULE_DESCRIPTION("RPMSG raw service driver"); +MODULE_AUTHOR("Arnaud Pouliquen "); +MODULE_ALIAS("rpmsg_raw"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Jul 31 12:10:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43731722 for ; Fri, 31 Jul 2020 12:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2681E2245C for ; Fri, 31 Jul 2020 12:11:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="GKSmPWTm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732980AbgGaMLH (ORCPT ); Fri, 31 Jul 2020 08:11:07 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11182 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732873AbgGaMLG (ORCPT ); Fri, 31 Jul 2020 08:11:06 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC7eJT011790; Fri, 31 Jul 2020 14:11:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=GC42Txzu7YDXAQKZYf6iSbzEby/I1QhEBTt8f1fNlOE=; b=GKSmPWTmxu07Q6Up4AwoOM8j4Wbp4dyQmLhrFb2Zl0/fnz0i7/GFkRuILplbMqe01WSp EIf1ULLqIWwdQqarNy/4pNZh6xb8yJAmulIYxBShp4Ojr1kHqR6/5gtg1tZGuUtW1huA K2N4P5n8xEBcuLWEFofikPQELMed78xEd14vRFY4qz2jK6uNz4aJ+738lEsdCYCFFlrm Jh91+asLbdNZPuQNGwM26aZEyDyrrk2pWrvLm8qvIHKp7MKunSE4q0XNhNCuK+1D21u3 MlqnMaN3tqbXgDU5yzT8OL8w0M0AEJzYJpJmXQOSuatHDQ+XMljZ3We+LB0I0TyZFV3u LA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32g9v9xku9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:03 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D69E910002A; Fri, 31 Jul 2020 14:11:02 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id CACE02AE6DE; Fri, 31 Jul 2020 14:11:02 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:02 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 02/13] rpmsg: introduce rpmsg_control driver for channel creation Date: Fri, 31 Jul 2020 14:10:32 +0200 Message-ID: <20200731121043.24199-3-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG4NODE2.st.com (10.75.127.11) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Create a RPMsg driver that will offer to the userspace applications an ioctl to manage channels. 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 | 209 +++++++++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_ctrl.c diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 900ec8f54081..c5afbf24e793 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -23,6 +23,14 @@ config RPMSG_NS channel that probes the associate 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 name service announcement + channel that probe the associate RPMsg device on remote endpoint + service announcement. + config RPMSG_RAW tristate "RPMSG raw service driver" depends on RPMSG diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index d75f0a65e71d..dc5228022dac 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..d31b1ba51fa7 --- /dev/null +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -0,0 +1,209 @@ +// 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 = { + .probe = rpmsg_ctrl_probe, + .remove = rpmsg_ctrl_remove, + .drv = { + .name = "rpmsg_ctrl", + }, +}; + +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: failed to allocate char dev region\n"); + return ret; + } + + ret = register_rpmsg_driver(&rpmsg_ctrl_driver); + if (ret < 0) { + pr_err("rpmsgchr: 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_ctl"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Jul 31 12:10:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC008722 for ; Fri, 31 Jul 2020 12:11:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92A402245C for ; Fri, 31 Jul 2020 12:11:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="aJLcM/L2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733037AbgGaMLK (ORCPT ); Fri, 31 Jul 2020 08:11:10 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:17078 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732982AbgGaMLJ (ORCPT ); Fri, 31 Jul 2020 08:11:09 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC8lRO011696; Fri, 31 Jul 2020 14:11:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=r3Fr7E2Nwh5fWVqRp/WlTVtWnlE9hWQvD5zYY4LBV2Q=; b=aJLcM/L2Iujja5Md5rNFoY0NanhMnoMkF1wWH7XO3xllozGhEIGFH+sPvHyl+e18IEX3 +wsJ7UZ4XHlHZM4+1JWxzsBNQKbAI32nadjhxfBAahTtWahrfEa9uqTQW0ZunOeZmRQ0 YDxGt07AfFBj/7tPLM/CjPHejsifva9jHgkBF47bKtd4VvBRNUTxYDP4fMnQ4E3sd/kh pTwMSuNfF3HuDPVUCZJdaa0sEOGQUKYZd7OjqX8oXbP352+wPHshacyXL/MlA14MN/H1 Rx9wcoXvt/aV/EQKdG/4/PPFm17OkViDRPhbvMJ7G9vFjk+oTmpx5BRdjaAZgVNP+tk1 rw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72dcaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:04 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CB73C10002A; Fri, 31 Jul 2020 14:11:03 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C10CC2AE6DD; Fri, 31 Jul 2020 14:11:03 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:03 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 03/13] rpmsg: add helper to create the rpmsg ctrl device Date: Fri, 31 Jul 2020 14:10:33 +0200 Message-ID: <20200731121043.24199-4-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE1.st.com (10.75.127.19) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org This function creates the rpmsg_ctl device using the driver_override to link device to the driver. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_internal.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index d1549e5cb607..811d6e27a720 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -119,6 +119,21 @@ static inline int rpmsg_ns_register_device(struct rpmsg_device *rpdev) return rpmsg_register_device(rpdev); } +/** + * 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. + */ +static inline int rpmsg_ctl_register_device(struct rpmsg_device *rpdev) +{ + strcpy(rpdev->id.name, "rpmsg_ctrl"); + rpdev->driver_override = "rpmsg_ctrl"; + + return rpmsg_register_device(rpdev); +} + int rpmsg_ns_announce_create(struct rpmsg_device *rpdev); int rpmsg_ns_announce_destroy(struct rpmsg_device *rpdev); From patchwork Fri Jul 31 12:10:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694775 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61EF8722 for ; Fri, 31 Jul 2020 12:11:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 495ED208E4 for ; Fri, 31 Jul 2020 12:11:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="wvzNeOJI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733003AbgGaMLI (ORCPT ); Fri, 31 Jul 2020 08:11:08 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:38512 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732864AbgGaMLI (ORCPT ); Fri, 31 Jul 2020 08:11:08 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC6YX4009383; Fri, 31 Jul 2020 14:11:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=6xOYA1gdR0TmB1u+RP4AoS6Lu6qul1dz3yzld4Wf3OE=; b=wvzNeOJIyN2GyCRyJvt3vqPLTR/EiInmqkfUEM7RimtxeRSgMhhSw5XSeuumSaxZKor8 QTdqi+XWO2J/cmN5KuJ6OiL+cdHTA3biL1EddUpLZ6SUSmgj1SlzA0vg67TBVhaT850/ o/R7qvnYSNXaNDaFTkWNg1Op0oPofTx4XAYzljK+6k8/jB3vPAvukeuw3OfbeNr/Dc4i p4brKxVCBKGO6ns06rab08dKOAGbTLf6AC63zrhcdELjB3v19F0gu67KFxnXHMHTleCo 7CU0VXnmfSMMFBdnBmQiutLFb24N1h4BSDwjis9uJ6f9FK2j53EGIqdcMm4/Uv27ULx2 cg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32gbmgp98b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:05 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E8BAE10002A; Fri, 31 Jul 2020 14:11:04 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DE33C2AE6DD; Fri, 31 Jul 2020 14:11:04 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:04 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 04/13] rpmsg: virtio: probe the rpmsg_ctrl device Date: Fri, 31 Jul 2020 14:10:34 +0200 Message-ID: <20200731121043.24199-5-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Probe the rpmsg_ctrl driver on virtio rpmsg bus creation. This provides the possibility to expose an ioctrl to create RPMsg channels. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/virtio_rpmsg_bus.c | 36 +++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 3c771a6392be..eaeaefdabf18 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -771,6 +771,36 @@ static void rpmsg_xmit_done(struct virtqueue *svq) wake_up_interruptible(&vrp->sendq); } +static struct rpmsg_device *rpmsg_virtio_add_ctrl_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_w_nsa_ops; + + rpdev_ctrl->dev.parent = &vrp->vdev->dev; + rpdev_ctrl->dev.release = virtio_rpmsg_release_device; + + err = rpmsg_ctl_register_device(rpdev_ctrl); + if (err) { + kfree(vch); + 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 }; @@ -778,7 +808,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; @@ -852,6 +882,10 @@ static int rpmsg_probe(struct virtio_device *vdev) vdev->priv = vrp; + rpdev_ctrl = rpmsg_virtio_add_ctrl_dev(vdev); + if (IS_ERR(rpdev_ctrl)) + goto free_coherent; + /* if supported by the remote processor, enable the name service */ if (virtio_has_feature(vdev, VIRTIO_RPMSG_F_NS)) { vch = kzalloc(sizeof(*vch), GFP_KERNEL); From patchwork Fri Jul 31 12:10:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694777 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 420FD138A for ; Fri, 31 Jul 2020 12:11:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27B5D2245C for ; Fri, 31 Jul 2020 12:11:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="oM8FtIIa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733053AbgGaMLM (ORCPT ); Fri, 31 Jul 2020 08:11:12 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:17084 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732873AbgGaMLL (ORCPT ); Fri, 31 Jul 2020 08:11:11 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC8jY3011686; Fri, 31 Jul 2020 14:11:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=OZnA7Vh3xkosB30guDpBIGnTonRyj7uk9V403xtYngQ=; b=oM8FtIIasffy9rSAsUIXHpVy6J08DS5qMNveO8tOlpdle2xahIwhc76JTE7Nv/pXp8vL 2h8LHQczCfF7FEqJAfmo80TNI43X3HnwkPnLKV6VWud445nsgSTQcUnNXhNORy48rB8s 6jCgU3DqANV60yBKCc4yCyiM6NQ8wPiBXX0PW4pYyppn46T2Ncik6dYU3wYVuBVkuFka sRLiZ/vHkPzeAtkkmL5BjXroNSibOQX+TjM9erxNWImyGH68JJUhzkGsEsRs8vPS7o22 TrfjZA0qM1DfFir69QPvQcu7C8f7KsM6e05Bo0mWzYLD4IXmtFQhJ3S7heJajHkjH5KO 3Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72dcb0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:06 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E7EE310002A; Fri, 31 Jul 2020 14:11:05 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DD2F32AE6DD; Fri, 31 Jul 2020 14:11:05 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:05 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 05/13] rpmsg: uapi: add service param for create destroy ioctls Date: Fri, 31 Jul 2020 14:10:35 +0200 Message-ID: <20200731121043.24199-6-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org To allow to associate an endpoint creation to a service, add a new parameter in rpmsg_endpoint_info struct. For each RPMsg service driver that want to support the ioctl interface a new service will have to be added. The RPMSG_START_PRIVATE_SERVICES is used to allow developer to add is own services with ID higher or equal to 1024. Signed-off-by: Arnaud Pouliquen --- include/uapi/linux/rpmsg.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index e14c6dab4223..2ccc10ffacd4 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -9,16 +9,32 @@ #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 * @src: local address * @dst: destination address + * @service: associated RPMsg service */ struct rpmsg_endpoint_info { char name[32]; __u32 src; __u32 dst; + __u32 service; }; #define RPMSG_CREATE_EPT_IOCTL _IOW(0xb5, 0x1, struct rpmsg_endpoint_info) From patchwork Fri Jul 31 12:10:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694779 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73ADD13B6 for ; Fri, 31 Jul 2020 12:11:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5282422BF3 for ; Fri, 31 Jul 2020 12:11:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="BRg4UNR1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733056AbgGaMLM (ORCPT ); Fri, 31 Jul 2020 08:11:12 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:22308 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733004AbgGaMLL (ORCPT ); Fri, 31 Jul 2020 08:11:11 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC85s9026417; Fri, 31 Jul 2020 14:11:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=Zev07XZF6gQYZQsYDyxnZ6yZusIc9M6Jp3/EdDM79V8=; b=BRg4UNR1l0Yewsw5dRHDTp0KvjZ4Bm/5mS7vrZF4EUCSbvT3ph5c7ZYCJqK5Af9mowkw G9lwTg50lFZfdagNhep5EwDnKupev64/1NB4etceFB1+ZIU5z4VJkLDeGoKl4tnyYhg5 g2gvvaABeS5MwtcgOARp9NtoJAsL1LYYdmuH1dC6lPGmOpa6trOFVbcGKOQNCMwD3TXs FtSpkSIFFzNqr/xeDIhGa9S8LpvieijrUYebEzp94sezzoISGcWcLiTve0vCcXFPTn4p zdfCbCNZK6cOsxkEopETEyowXU8l5aZxVe/nLIRpHgQvw/9bppFPFQq/0ejlSvUpm48K 5A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32gagvnd0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:07 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E2A4B10002A; Fri, 31 Jul 2020 14:11:06 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D809C2AE6DD; Fri, 31 Jul 2020 14:11:06 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:06 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 06/13] rpmsg: add RPMsg control info structure Date: Fri, 31 Jul 2020 14:10:36 +0200 Message-ID: <20200731121043.24199-7-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add new structure for RPMsg driver registration. This structure will be used to link a service to its driver. Signed-off-by: Arnaud Pouliquen --- include/linux/rpmsg.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 5496d27c6f8c..ef8d1b987d38 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -34,6 +34,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 From patchwork Fri Jul 31 12:10:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694781 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D87C722 for ; Fri, 31 Jul 2020 12:11:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 058E62245C for ; Fri, 31 Jul 2020 12:11:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="o2m6ryJv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733063AbgGaMLN (ORCPT ); Fri, 31 Jul 2020 08:11:13 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:35937 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733039AbgGaMLM (ORCPT ); Fri, 31 Jul 2020 08:11:12 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC8lRP011696; Fri, 31 Jul 2020 14:11:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=MW+7nWJ04Sd41Z+BeSZdAvkoYyBFJeWchj90EDOmFnA=; b=o2m6ryJv56EgNxkohyRRVl3C2qf4K96z3XNsSjtYwKID3KQTctfZVA+fmkW9qxY5+beG j7OdPKW69+IwggbsZ8X3NhxayFadzUh7ZHbBXZnuD6yNGtbzsME1JnKhsPi49ltheEqs LGWKiJFr7rfx+0CApOMYvCmdM2qo8MvpLCqP33iA8zbS/n9DZ/2mGQR0lD30w7d7EA0f 4B5LXTPPz+dhUVuWut2KtckFphFubk8R3jcj5F1v+r+A2XLA6phxYMfNdiJS7Npqoi7C GZMGAL669IsfDBZB4rNoeL1xlmpyoH0LOoECVJnM28ge7awVr9WLnVmAzjT0H1OAugh1 Eg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72dcb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:08 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0F8FE10002A; Fri, 31 Jul 2020 14:11:08 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0543F2AE6DD; Fri, 31 Jul 2020 14:11:08 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:07 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 07/13] rpmsg: control: add driver registration API Date: Fri, 31 Jul 2020 14:10:37 +0200 Message-ID: <20200731121043.24199-8-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add API for RPMsg driver to register the supported service. This API has to be called during RPMsg driver init to declare the service. Then the RPMsg control will be able to instantiate associated device. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 57 ++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 3 ++ 2 files changed, 60 insertions(+) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index d31b1ba51fa7..8773c8395401 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -26,6 +26,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); @@ -176,6 +190,49 @@ static struct rpmsg_driver rpmsg_ctrl_driver = { }, }; +/** + * 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/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 811d6e27a720..2f22ad45cb18 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -137,4 +137,7 @@ static inline int rpmsg_ctl_register_device(struct rpmsg_device *rpdev) int rpmsg_ns_announce_create(struct rpmsg_device *rpdev); int rpmsg_ns_announce_destroy(struct rpmsg_device *rpdev); +int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl); +void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl); + #endif From patchwork Fri Jul 31 12:10:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC952722 for ; Fri, 31 Jul 2020 12:11:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B40D92245C for ; Fri, 31 Jul 2020 12:11:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="yDugJ9ha" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733156AbgGaMLt (ORCPT ); Fri, 31 Jul 2020 08:11:49 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:35923 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733054AbgGaMLO (ORCPT ); Fri, 31 Jul 2020 08:11:14 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC8fuX011305; Fri, 31 Jul 2020 14:11:09 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=VkOlCxczALyBGyhK0x3jjVQY6384tdF2+bl3dLOk1VU=; b=yDugJ9hasKAJgsud6QlBjPHtuqquAH3tqYNNZZcW39WVwNPOxC4/V7Ow7G0MlS0qxQNA QbxINUKyjoCeVwpxz5+iVJs3KbqZEwr8XD2Cg/HmsxM18PG0DPZEBjBSYLskz7tnEIxM MmRl5eRIqKCbC91rXGxRrEQLe/zJvx93wlphJKQAAt0EteJlMRHOBF1lBF8KpHu5k2Jr wrw+6oWsF9cJaA/gNVY1HktpkhOR8z9S/xUAmrwBR1Sff3Kn60MPg0Q3VaNT+T6SurJA L9U3aC0PR3gPbvKc+FyjLtYmVjHiVCkkooY1fwqgomcrbpWHhaWdMzFTnxgaGwurZD11 3g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72dcba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:09 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2919F10002A; Fri, 31 Jul 2020 14:11:09 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 1E01C2AE6DD; Fri, 31 Jul 2020 14:11:09 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:08 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 08/13] rpmsg: raw: register service to the rpmsg control Date: Fri, 31 Jul 2020 14:10:38 +0200 Message-ID: <20200731121043.24199-9-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG4NODE2.st.com (10.75.127.11) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Register the RPMSG_RAW_SERVICE service to the RPMsg control Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_raw.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/rpmsg_raw.c b/drivers/rpmsg/rpmsg_raw.c index 8684a78ab4d1..117da0c566ed 100644 --- a/drivers/rpmsg/rpmsg_raw.c +++ b/drivers/rpmsg/rpmsg_raw.c @@ -315,6 +315,11 @@ static struct rpmsg_driver rpmsg_raw_client = { .remove = rpmsg_raw_remove, }; +const struct rpmsg_drv_ctrl_info rpmsg_raw_ctl_info = { + .drv_name = KBUILD_MODNAME, + .service = RPMSG_RAW_SERVICE, +}; + static int rpmsg_raw_init(void) { int ret; @@ -328,7 +333,18 @@ static int rpmsg_raw_init(void) ret = register_rpmsg_driver(&rpmsg_raw_client); if (ret < 0) - unregister_chrdev_region(rpmsg_raw_major, RPMSG_DEV_MAX); + goto free_region; + + ret = rpmsg_ctrl_register_ctl(&rpmsg_raw_ctl_info); + if (ret < 0) + goto free_rpmsg; + + return 0; + +free_rpmsg: + unregister_rpmsg_driver(&rpmsg_raw_client); +free_region: + unregister_chrdev_region(rpmsg_raw_major, RPMSG_DEV_MAX); return ret; } @@ -336,6 +352,7 @@ module_init(rpmsg_raw_init); static void rpmsg_raw_exit(void) { + rpmsg_ctrl_unregister_ctl(&rpmsg_raw_ctl_info); unregister_rpmsg_driver(&rpmsg_raw_client); unregister_chrdev_region(rpmsg_raw_major, RPMSG_DEV_MAX); } From patchwork Fri Jul 31 12:10:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A49F722 for ; Fri, 31 Jul 2020 12:11:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08A892245C for ; Fri, 31 Jul 2020 12:11:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="yZ/04ioG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733003AbgGaMLc (ORCPT ); Fri, 31 Jul 2020 08:11:32 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:36287 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733069AbgGaMLR (ORCPT ); Fri, 31 Jul 2020 08:11:17 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC8lRR011696; Fri, 31 Jul 2020 14:11:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=6k232TKbN5dNjWvgqQw/NJsbYH973zbfMgFlgm/6cZc=; b=yZ/04ioG4+TpcjljEmaW7cRvGxqZvTgUvi0Z9D+R9WiLu6GR4dHzrTAjhxo4J9ugD1cO d+oLwNxggEqxcu+Nq63yR6+36DIzQ5r5eIH6s7zJTzFwPbA2efNbsIkpBgduJjbI52bv VVICfP09SEKGnrPuCi6xXkThtAyleqRiqFtLpq2er32Mdv69PQJ3R9MF/gaaNGIv1FOv kwD10Fh9D/QXYHQIKR4vRuKLgRxXPeUdo94gmyHlOPnWNstKuJRk+TE67BV8P1P39y29 Q1C/woX8m98WBh51aCkn5G9OTEzXpu5prfAnjsnNGdoWlb7PCxI94VmlmjZ0j3TBpeMo Iw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72dcbd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:10 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 352B410002A; Fri, 31 Jul 2020 14:11:10 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 27EA22AE6DD; Fri, 31 Jul 2020 14:11:10 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:09 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 09/13] rpmsg: add override field in channel info Date: Fri, 31 Jul 2020 14:10:39 +0200 Message-ID: <20200731121043.24199-10-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The override field is already used in the rpmsg_device. This allows to force a service name to be associated to a RPMsg service driver. 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 ef8d1b987d38..4a34a8ea330f 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -52,11 +52,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 Fri Jul 31 12:10:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EF7413B6 for ; Fri, 31 Jul 2020 12:11:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44D132245C for ; Fri, 31 Jul 2020 12:11:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="dVuZGPfm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733090AbgGaMLc (ORCPT ); Fri, 31 Jul 2020 08:11:32 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:17276 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733073AbgGaMLR (ORCPT ); Fri, 31 Jul 2020 08:11:17 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC8lRS011696; Fri, 31 Jul 2020 14:11:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=Pb04KRp/CHv7AubmM5WkWb6DmIPNpc8iKS6+GMia3j0=; b=dVuZGPfmA8OnN77TPjYb1baQvnuZUQ0IeqACwuZCQKpMp4hImQxhS+BuL1CM9KHFV4wB W5KiMogmqvGhke10FrnNYhZOpqsvAhKV5xNwYGjyAtWcerKRS9uU2hNvkJDhznem2w9e xMiPHOw0zy/yTtdpW5dgKBp07yI89dFTwnAUoiMtQTT8bdSVJ+wHPso0zWvSNDcW9d1c WzcSBgvS3Akjci7XSED7aXuv4HcbmIjbjY2sMNEbSmFNX3MKjj6q8zQBTmehfHpq3bMQ s+Pr+QEnI/tGsAspQZcvJhEAUUyZqA6rGnEF4Xl74sAIpefjAU/BpqmO/YH50pxnJxAy bw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72dcbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:11 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 318B310002A; Fri, 31 Jul 2020 14:11:11 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 264252AE6DD; Fri, 31 Jul 2020 14:11:11 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:10 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 10/13] rpmsg: ns: initialize channel info override field Date: Fri, 31 Jul 2020 14:10:40 +0200 Message-ID: <20200731121043.24199-11-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@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 b478e2b55213..ace237854f88 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -103,6 +103,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 = le32_to_cpu(msg->addr); + chinfo.driver_override = NULL; dev_info(dev, "%sing channel %s addr 0x%x\n", flags & RPMSG_NS_DESTROY ? "destroy" : "creat", From patchwork Fri Jul 31 12:10:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694785 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34381138A for ; Fri, 31 Jul 2020 12:11:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C7D72245C for ; Fri, 31 Jul 2020 12:11:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="ojg+vD+b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733100AbgGaMLS (ORCPT ); Fri, 31 Jul 2020 08:11:18 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:64718 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732900AbgGaMLQ (ORCPT ); Fri, 31 Jul 2020 08:11:16 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC85sD026417; Fri, 31 Jul 2020 14:11:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=3bVmdSQZoibo9S9FlUXnSsJ3rzj/FWcrjccFH12J5Yo=; b=ojg+vD+bR8CDiIuZQZ/xJ6nm1cZkbjYCs08gaxKz5F82rtCGE+hBCrftvPUmuP2xJDmx iwg2cLhgFAh0v8VxxHKgU22yDqerocDUwCagqfRqPsC+0O4PUY4otSoJQJigCOL0lRBh FLu3BMc0b/aIQNBEo19WDgs986TyS3O8dPGFirXY/MCAI5B1BbIass7UKKUHanvQ+aGr zr5R4+hdiAT81ZU9lpOHVv5hd2oAfTjnly0kcIXXUCF5kVEueFmGqNytslaYVvO5/bGs fvyMKO+CQiEY8QDXvZGy1MOH3zBU/EpWF7wM2WU2EaNApZ9k7ZjKpNk7r5LDsJHNBLHG pA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32gagvnd1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:12 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3F8D110002A; Fri, 31 Jul 2020 14:11:12 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 3587F2AE6DD; Fri, 31 Jul 2020 14:11:12 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:11 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 11/13] rpmsg: virtio: use the driver_override in channel creation Date: Fri, 31 Jul 2020 14:10:41 +0200 Message-ID: <20200731121043.24199-12-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Use the override information from the channel info structure to set the rpdev override and so link 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 eaeaefdabf18..dbf7a597ae74 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -352,6 +352,7 @@ __rpmsg_create_channel(struct virtproc_info *vrp, rpdev = &vch->rpdev; rpdev->src = chinfo->src; rpdev->dst = chinfo->dst; + rpdev->driver_override = (char *)chinfo->driver_override; if (virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) rpdev->ops = &virtio_rpmsg_w_nsa_ops; else From patchwork Fri Jul 31 12:10:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DE96138A for ; Fri, 31 Jul 2020 12:11:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7146F208E4 for ; Fri, 31 Jul 2020 12:11:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="08LbaMDn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732860AbgGaMLb (ORCPT ); Fri, 31 Jul 2020 08:11:31 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:38550 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733081AbgGaMLR (ORCPT ); Fri, 31 Jul 2020 08:11:17 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC6YNX009379; Fri, 31 Jul 2020 14:11:14 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=7rSky8J/GLIf+EHvfA+pSMdQZv7hy7gixNL5RCvSGqs=; b=08LbaMDnfDx0Uc9V7+QkFjCyL6T6mxE6tTMRGik1yuiaMSpH4unF348V3+HN006hp1Yl p9eVM4ox4BpWQrpdXOWvzJvQTLi2qU4taHK4ddmZR/mTjcVQqNKy5CTWYXAAxOAc3KpX zvs3wzSZImh+b852IxJGh7s4ZXes0YZPnr54190n4a6BwsU1hvZMdrogvKg9KioTawtR EaActcYEwwTcZeAWag4pvZynacW55Npg7QFjG5IWppJlXTbEZkrDVFFNohzG5Tyf021f y9ly15vJq9uIFdeAQmnFZyeavarAK97vsoL26ClXwFSdmnMVszJDwdKMBq8EQhLGRgIJ 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 32gbmgp98w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:13 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7389B10002A; Fri, 31 Jul 2020 14:11:13 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 68FA32AE6DD; Fri, 31 Jul 2020 14:11:13 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:12 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 12/13] rpmsg: control: implement the ioctrl function to create device Date: Fri, 31 Jul 2020 14:10:42 +0200 Message-ID: <20200731121043.24199-13-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Implement the ioctrl function that parses the list of rpmsg drivers registered to create an associated device. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 8773c8395401..d2a6dbb8798f 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -55,12 +55,47 @@ 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; + + chinfo.driver_override = rpmsg_ctrl_get_drv_name(eptinfo.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 Fri Jul 31 12:10:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694783 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85A02722 for ; Fri, 31 Jul 2020 12:11:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C28D2245C for ; Fri, 31 Jul 2020 12:11:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="0TGt8XX/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733110AbgGaMLU (ORCPT ); Fri, 31 Jul 2020 08:11:20 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11274 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733090AbgGaMLS (ORCPT ); Fri, 31 Jul 2020 08:11:18 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VC7bie011768; Fri, 31 Jul 2020 14:11:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=z/FPnRPNTGOl2B/1fOLQu51Ns64FIJlkJ28q5n8hoPw=; b=0TGt8XX/8AWTuQyZX0botExlIyNJJeu/ZfyEktWXM7yxXaYPjcL67Oyin2NnlGaAyC1P qjCnPf9s7BvL/CUD2c6Lq/xPQitvefx8YZ6Xp/H4jw+g4PdWSigP2KcYxLirYbzSdS1h ADR5wgswWCU32/wTmS5RHZ7n22PLxqvDHNozNVL0hDrPeQaUfToyDqgyxei+TBHJEBTu UWvehEb7LAEQ7/m2VOLoUUvvWlGnadpQN/oSIrVDzvFzikn6jN8JaZVyCVQZElBHAdXS DFuJUJB+rtZttGGRUTGOjzh5M3mGRuXwHwJi8a6KN4hv15hd3ZDDVbk4Q0A0o5Mb/qZw Jw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32g9v9xkvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 14:11:15 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 89DC810002A; Fri, 31 Jul 2020 14:11:14 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7F96D2AE6DD; Fri, 31 Jul 2020 14:11:14 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 14:11:13 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 13/13] rpmsg: ctrl: add support of the endpoints release Date: Fri, 31 Jul 2020 14:10:43 +0200 Message-ID: <20200731121043.24199-14-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com> References: <20200731121043.24199-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add the support of the release of an endpoint using the ioctl interface. The endpoint is identified using its name, its source address and is destination address. To support legacy a new ioctl ioctl is created instead of updating RPMSG_DESTROY_EPT_IOCTL. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 35 ++++++++++++++++++++++++----------- include/uapi/linux/rpmsg.h | 1 + 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index d2a6dbb8798f..d696247970c2 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -75,26 +75,39 @@ static long rpmsg_ctrl_dev_ioctl(struct file *fp, unsigned int cmd, struct rpmsg_channel_info chinfo; struct rpmsg_endpoint_info eptinfo; struct rpmsg_device *newch; - - if (cmd != RPMSG_CREATE_EPT_IOCTL) - return -EINVAL; + int ret; if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) return -EFAULT; - chinfo.driver_override = rpmsg_ctrl_get_drv_name(eptinfo.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; + switch (cmd) { + case RPMSG_CREATE_EPT_IOCTL: + chinfo.driver_override = + rpmsg_ctrl_get_drv_name(eptinfo.service); + if (!chinfo.driver_override) + return -ENODEV; + + newch = rpmsg_create_channel(ctrldev->rpdev, &chinfo); + if (!newch) { + dev_err(&ctrldev->dev, "rpmsg_create_channel failed\n"); + return -ENXIO; + } + break; + case RPMSG_RELEASE_EPT_IOCTL: + ret = rpmsg_release_channel(ctrldev->rpdev, &chinfo); + if (ret) { + dev_err(&ctrldev->dev, + "rpmsg_release_channel failed: %d\n", ret); + return ret; + } + break; + default: + return -EINVAL; } return 0; diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index 2ccc10ffacd4..74d821ee5f8c 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -39,5 +39,6 @@ struct rpmsg_endpoint_info { #define RPMSG_CREATE_EPT_IOCTL _IOW(0xb5, 0x1, struct rpmsg_endpoint_info) #define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2) +#define RPMSG_RELEASE_EPT_IOCTL _IOW(0xb5, 0x3, struct rpmsg_endpoint_info) #endif