Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7939429pxb; Fri, 19 Feb 2021 03:24:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4ULfqXpmrevZN2oe0ZTNoLATrhNKIpSa8/uUzxSr4xJ7YZxRO+VPa7HF5x56JpsdiUUKt X-Received: by 2002:a05:6402:1854:: with SMTP id v20mr8567435edy.56.1613733882239; Fri, 19 Feb 2021 03:24:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613733882; cv=none; d=google.com; s=arc-20160816; b=GLacNo0il/73NFBNtrqwya02VVQ8K/WPaKjaDpIAKhLVxnWcjtjkX6yY6EjDNl6fZZ OmMzCuSwNPkugrWc6aAvH1TyxdbTp0Hz2gp0Ot/5WAipk1EeYeZYEP7AUH6I94no4aqX oSmgDQ7XwaR836IZxPrePl1ApN5fsbdefHLT9P5bey8MILY6keVbZ+NByE3TCJPkS824 2jQoN+aryM/wAnJaXDRVNsk7EYPyH+wmObv5p2BYqDJ+HXsY2rG4UihqKiXsJRMvDbUv x2yttr08uTHAeHKcbp/8sN/a+YA8zzBBMvljCfvCICAUqFiNpRG0+zgi6Faz4EKy13xt KeNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5/5ztwEi6vNBYmfGVztdGKdMNwulPVy/4Aq1/ukOfu0=; b=dzmYhrP5ZmZiFYeEufuCelPBVtYKSD1ivkpodQ3k1pmvk5c1+df1E/GcyC3jJ9rAED J8UGMsgFgD22d33TknHJ6n28gD+nfw+xc6WvceLySiAdXZU9fEEfIY3k/lKzx9TXkvEs djzPUUhsEWV3uzDnsRoPJpiJxFzunpzMA/LsCg5d2rcLz59vT8glqIKsdRzkJoXJ3zd8 eoQWIfcqzCxPHKNN+tkU1qibCtynih6uvvhYLn9l0fjTYAYbkqsk9mjLmzfcUgbUhAlX /Bwmz6dnTXAN/0m4OlH7DsxjlkSwAlbKJ0kUWzs54FKhj2qt15lcivTgnQEIDp8gFUJh 44YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ZfWBkXmj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si5756345ejy.191.2021.02.19.03.24.18; Fri, 19 Feb 2021 03:24:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ZfWBkXmj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbhBSLXs (ORCPT + 99 others); Fri, 19 Feb 2021 06:23:48 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52826 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230419AbhBSLT4 (ORCPT ); Fri, 19 Feb 2021 06:19:56 -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 11JBHiIN009043; Fri, 19 Feb 2021 12:19: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=5/5ztwEi6vNBYmfGVztdGKdMNwulPVy/4Aq1/ukOfu0=; b=ZfWBkXmjZU14ip43UPHZdBEbrBJiiV+6Om/sQkBRfULvQAK/LxA+J+3SaZJQt8rb9CaU 1VwA4ewNSwCESG3s8tySXHP4E5p0DDmGJ4Vr+GzFwDZqDtgpxOYaZXBCpdSyxqg2Smso 1Crqr4+V1GkE9k69Bmu3prTCQjvEZNJ8EB/P8X8UX5elM2rVsEJAcAgMkewGKtBktpah vcVDrAzbs05nLn7TbfAg0670IzfXZfkRct9Jm4eCHh/FE5X+6Ak8Ro1AQn0cm1XI5YRn aMnRpPRkby3TSP6DtpfSGZH7X3BUqP4g4jqmJujkXPm58GmU4fL4uLiySLaJ5N8XCwgD dQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p6hq5583-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19: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 BB99B10002A; Fri, 19 Feb 2021 12:19: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 AD94B221760; Fri, 19 Feb 2021 12:19:08 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:19:08 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 12/16] rpmsg: ctrl: introduce RPMSG_CREATE_DEV_IOCTL Date: Fri, 19 Feb 2021 12:14:57 +0100 Message-ID: <20210219111501.14261-13-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_04:2021-02-18,2021-02-19 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the RPMSG_CREATE_DEV_IOCTL to allow the user application to initiate a communication through a new RPMsg channel. This Ioctl can be used to instantiate a local RPMsg device. Depending on the back-end implementation, a NS announcement can be sent to the remote processor. Suggested-by: Mathieu Poirier Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ctrl.c | 21 +++++++++++++++++---- include/uapi/linux/rpmsg.h | 5 +++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 2e43b4096aa8..78c13816bfc6 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -70,9 +70,7 @@ static long rpmsg_ctrl_ioctl(struct file *fp, unsigned int cmd, unsigned long ar void __user *argp = (void __user *)arg; struct rpmsg_endpoint_info eptinfo; struct rpmsg_channel_info chinfo; - - if (cmd != RPMSG_CREATE_EPT_IOCTL) - return -EINVAL; + struct rpmsg_device *newch; if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) return -EFAULT; @@ -82,7 +80,22 @@ static long rpmsg_ctrl_ioctl(struct file *fp, unsigned int cmd, unsigned long ar chinfo.src = eptinfo.src; chinfo.dst = eptinfo.dst; - return rpmsg_chrdev_create_eptdev(ctrldev->rpdev, &ctrldev->dev, chinfo); + switch (cmd) { + case RPMSG_CREATE_EPT_IOCTL: + return rpmsg_chrdev_create_eptdev(ctrldev->rpdev, &ctrldev->dev, chinfo); + + case RPMSG_CREATE_DEV_IOCTL: + newch = rpmsg_create_channel(ctrldev->rpdev, &chinfo); + if (!newch) { + dev_err(&ctrldev->dev, "rpmsg_create_channel failed\n"); + return -ENXIO; + } + return 0; + + default: + return -EINVAL; + } + }; static const struct file_operations rpmsg_ctrl_fops = { diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index f5ca8740f3fb..f9d5a74e7801 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -33,4 +33,9 @@ struct rpmsg_endpoint_info { */ #define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2) +/** + * Instantiate a rpmsg service device. + */ +#define RPMSG_CREATE_DEV_IOCTL _IOW(0xb5, 0x3, struct rpmsg_endpoint_info) + #endif -- 2.17.1