Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1521137pxb; Thu, 4 Feb 2021 15:33:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJycOtBvRzuMS6WK4psjghipAtZ1VwjYbznLICzcaXiwo/YWbabDmHQS5Eh1n4LJ8o5HU6ow X-Received: by 2002:aa7:d5c1:: with SMTP id d1mr886265eds.359.1612481609702; Thu, 04 Feb 2021 15:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612481609; cv=none; d=google.com; s=arc-20160816; b=jf1jD5CV5+t40bBTL0FzmoL5hRoTpLnFfvYgOnq076rczmbuoGoyk2/fbitS6H7rqe oMkuUvKGGj06ydRcTQ5V5G67umbmDVSP4W+TvFZb9LTSrA2LUHqFk6tdGPJKHBoptkUy OUgfawQkvUnqU5xIvOTLKqDaTqpcaL/wW4zOwcK1eoj5H+swRrq6VVCqq5LiPK+Mw3EF UTA/+SrerJqXyvJAiTbdq8R5z6VHzT9f5why59i11FNd3s3Go146jeSxTw8uIe1frJww R4eWmcJ+gAV6HbUjXMgzYSBgXNsp3IY5K+ZO+bX+ACRweicuploQIuq8mX0K7P8yoaY5 dguw== 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=g3f4EnvpuMSLmWxWkeuvGNAFMa0zr9x6GcQDbKUDAIA=; b=Fpud/9CuM+iv9e+Lto6/2r61v2fkrzo4mUJDeO1ErIqLf/kBTM1VEV/3LtTM0UXl9S GGPeZXZigkUj+Vddk2k7022AsyIr6JMorU/O2tyWtreWMsHszdO6//Cnk3f6Ro57GMGn lETU5S1DwHhVocoiOtEJiz3c4klHxMBvw4cSGeePZyHOW8WIqEsWaenNYjGppxL4NYjp RGleJuJVN4gCgJSpvYJcThtjpPal9O3sBI+1EjXq6HamTac9R4Om4hM1c18dgO2anGJG lYmmcuITH2QjtdcmOAR54jYcGV8P+zQy0DL7suoInqq0xbLMH981857cDxolOBV6j1Y6 DOkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=MWwuWuji; 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 i10si4622995ejd.325.2021.02.04.15.33.05; Thu, 04 Feb 2021 15:33:29 -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=MWwuWuji; 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 S235171AbhBDIrc (ORCPT + 99 others); Thu, 4 Feb 2021 03:47:32 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:7642 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235148AbhBDIrT (ORCPT ); Thu, 4 Feb 2021 03:47:19 -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 1148gwgH000414; Thu, 4 Feb 2021 09:46:33 +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=g3f4EnvpuMSLmWxWkeuvGNAFMa0zr9x6GcQDbKUDAIA=; b=MWwuWujiH8Bo8hE+Xhw7wpo9mHIUZ/BbwPKNhbYl9q+9m6/ZrmTD30Lah5WcpgDfI0/L UpEHh95luUsQ5kPyedM4CeKEjkXIv+UhbCll8NefLrfdsG988uvaASVP2ymEd2UI4jro oXvdtZ+VXGFDlkBH+QNA1dPzm+8OuqMwcyUntIL6UqbCus7eGDU7KRfH5jBe1uiXsCZJ fAekRLIpT5tObmnfSdq8l67k5pd16ZaDWFIpPTulrL/7DfvSj5KjozTT6oUpxG01SEdA mSxaiUCP/txRdr10hOyhB5WdoG/r2Nhht0/A47vGrRkLATlC8Sj6P8mOol1dRHPYUlp9 mg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36d0ns6pvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 09:46:33 +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 5BCAC100034; Thu, 4 Feb 2021 09:46:33 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4F91922AE50; Thu, 4 Feb 2021 09:46:33 +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; Thu, 4 Feb 2021 09:46:33 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v3 11/15] rpmsg: ctrl: introduce RPMSG_CREATE_DEV_IOCTL Date: Thu, 4 Feb 2021 09:45:30 +0100 Message-ID: <20210204084534.10516-12-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> References: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain 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.369,18.0.737 definitions=2021-02-04_03:2021-02-04,2021-02-04 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 f9b90e927fff..88eae475ef33 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