From patchwork Wed Feb 17 13:28:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091637 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 9AD5CC433DB for ; Wed, 17 Feb 2021 13:32:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EDC464E5B for ; Wed, 17 Feb 2021 13:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233055AbhBQNcL (ORCPT ); Wed, 17 Feb 2021 08:32:11 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:55890 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233056AbhBQNbg (ORCPT ); Wed, 17 Feb 2021 08:31:36 -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 11HDRUwM001315; Wed, 17 Feb 2021 14:30:48 +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=Eg4OKsTKzswaEDxBH77D2QEGSARCRjEDw0vkCFnM8gE=; b=PFW3kiwFfvh2DsWbGIkQhFFDJwnmAoqeP3/xPWjjStbfkgwByewGpdr8ehcEynS5gbVT d+V/PYGYnnJb8hztLSd9tXh94QQbO8WpnYg2skGYoUG1jAqKgzUi03oKyT165W/EriLT yx20q9LgDXbMPongS866AeesgZcUhAOeOcs5fWlUk0PzWcojqVIrZHHfQEsLemreuxxJ dKQ2SnlJkhSbUlTb5aoW3VVl1lnjFF07y7vY1tYY6lBJNH4RZgsvXCuWPBjuND/A8c2q A9KvW7Aw5fJU2o03su/Dct7dR4PqazgYNmCgBHeiz76pj0JI1Rl0dh1nvG+WLJwUDhY/ Og== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p6hpq0n3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:48 +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 0B5B4100034; Wed, 17 Feb 2021 14:30:48 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E82D52370C9; Wed, 17 Feb 2021 14:30:47 +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; Wed, 17 Feb 2021 14:30:47 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 01/16] rpmsg: char: rename rpmsg_char_init to rpmsg_chrdev_init Date: Wed, 17 Feb 2021 14:28:50 +0100 Message-ID: <20210217132905.1485-2-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org To be coherent with the other functions which are prefixed by rpmsg_chrdev, rename the rpmsg_char_init function. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 4bbbacdbf3bb..9e33b53bbf56 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -543,7 +543,7 @@ static struct rpmsg_driver rpmsg_chrdev_driver = { }, }; -static int rpmsg_char_init(void) +static int rpmsg_chrdev_init(void) { int ret; @@ -569,7 +569,7 @@ static int rpmsg_char_init(void) return ret; } -postcore_initcall(rpmsg_char_init); +postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { From patchwork Wed Feb 17 13:28:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091639 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=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 EC8BFC433DB for ; Wed, 17 Feb 2021 13:32:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3DC964E5F for ; Wed, 17 Feb 2021 13:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232996AbhBQNc0 (ORCPT ); Wed, 17 Feb 2021 08:32:26 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:55894 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233070AbhBQNbh (ORCPT ); Wed, 17 Feb 2021 08:31:37 -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 11HDRRcP001276; Wed, 17 Feb 2021 14:30:49 +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=FcW1J/setFwTwOH+VhdGFYbPkMfYg30KWwRW0YzViPA=; b=qWZTQbClAlnSPhjTjTdZTlkGkN+JsfLLO96J9mPfVADaeQ5ChTSpJ99AgSxXUl8/9kbK gAOeWw+Hldjtys4pCi2egSgiPsBFoliy/j70O3Y9zszF4zkdLGi7NIUOPfChJ3SUZ0E6 DHXW7Xw0fv/jgedSVlhgB5jt9/qKTg3tQECDfofKaIYb5NjWK3XeqZp8K+konRFH5evU k8PksxHOHwLkszBJVWqA2fY75+v8dbefRi3S0lCT+ASs4CABelDUVAxQSx0LBU7/zMyh dSJt4+w6kX9ON3l3jBhvRPyK7A4JyNG3sP2NrQmgR+CA0C9wpdIR+ZxFfcqk+L/iiel9 ow== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p6hpq0n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:49 +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 AB0B710002A; Wed, 17 Feb 2021 14:30:48 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9ECCB2370C9; Wed, 17 Feb 2021 14:30:48 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:30:48 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 02/16] rpmsg: move RPMSG_ADDR_ANY in user API Date: Wed, 17 Feb 2021 14:28:51 +0100 Message-ID: <20210217132905.1485-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org As the RPMSG_ADDR_ANY is a valid src or dst address that can be set by user applications, migrate its definition in user API. Signed-off-by: Arnaud Pouliquen --- include/linux/rpmsg.h | 3 +-- include/uapi/linux/rpmsg.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index a5db828b2420..d97dcd049f18 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -18,8 +18,7 @@ #include #include #include - -#define RPMSG_ADDR_ANY 0xFFFFFFFF +#include struct rpmsg_device; struct rpmsg_endpoint; diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index e14c6dab4223..5e00748da319 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -9,6 +9,8 @@ #include #include +#define RPMSG_ADDR_ANY 0xFFFFFFFF + /** * struct rpmsg_endpoint_info - endpoint info representation * @name: name of service From patchwork Wed Feb 17 13:28:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091633 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=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 D1ADBC43381 for ; Wed, 17 Feb 2021 13:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9992A64E4D for ; Wed, 17 Feb 2021 13:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232730AbhBQNcE (ORCPT ); Wed, 17 Feb 2021 08:32:04 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:55892 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233071AbhBQNbg (ORCPT ); Wed, 17 Feb 2021 08:31:36 -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 11HDRlRM001522; Wed, 17 Feb 2021 14:30:49 +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=mKgsjLlogOxxfmk/2dTML824956sXna54DFu9XWq3w4=; b=5ls5sjrpAfgNkfDGY2fZ1BQP1H8D/rkGkT4e9tbXLq91Ff+/d54G+qwErr9cJmTg7o3S DxbpioRpYy6zAv9TT0k3aI1vtAEuVJG3bqUY90OZT9eLE2dY+hD/MU3Rk08iXj39Nnhh OukoVDqsRM6W3axgapjA3QP9U9yo9yhggd+RnW491e1xX5MQEayTbaRTdKzuDT3M5Q+0 TQWgteHTuQCq9n6IElksdCpFhjbNSTwk+HElj/3MfKN7MlkQxErDaaj2G1fLpUqb48+Y 5lOq1ZHfVVsFHpsp6BAk7Kw38BDzf5EPXLqlZYqEJVCdn+xAPWJo5w2GEtFU7iSNtFdZ 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 36p6hpq0n6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:49 +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 69CA4100034; Wed, 17 Feb 2021 14:30:49 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5CB3D2370C9; Wed, 17 Feb 2021 14:30:49 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:30:49 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 03/16] rpmsg: add short description of the IOCTL defined in UAPI. Date: Wed, 17 Feb 2021 14:28:52 +0100 Message-ID: <20210217132905.1485-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a description of the IOCTL and provide information on the default value of the source and destination addresses. Signed-off-by: Arnaud Pouliquen --- include/uapi/linux/rpmsg.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index 5e00748da319..f5ca8740f3fb 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -14,8 +14,8 @@ /** * struct rpmsg_endpoint_info - endpoint info representation * @name: name of service - * @src: local address - * @dst: destination address + * @src: local address. To set to RPMSG_ADDR_ANY if not used. + * @dst: destination address. To set to RPMSG_ADDR_ANY if not used. */ struct rpmsg_endpoint_info { char name[32]; @@ -23,7 +23,14 @@ struct rpmsg_endpoint_info { __u32 dst; }; +/** + * Instantiate a new rmpsg char device endpoint. + */ #define RPMSG_CREATE_EPT_IOCTL _IOW(0xb5, 0x1, struct rpmsg_endpoint_info) + +/** + * Destroy a rpmsg char device endpoint created by the RPMSG_CREATE_EPT_IOCTL. + */ #define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2) #endif From patchwork Wed Feb 17 13:28:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091635 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 86EE4C433E9 for ; Wed, 17 Feb 2021 13:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5961164E5F for ; Wed, 17 Feb 2021 13:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233102AbhBQNcA (ORCPT ); Wed, 17 Feb 2021 08:32:00 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:14148 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233073AbhBQNbh (ORCPT ); Wed, 17 Feb 2021 08:31:37 -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 11HDSVIU001039; Wed, 17 Feb 2021 14:30:50 +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=eL8fdw48NUXLNEyAuslWK3wA6wxsb+gv6VUFyukuFOo=; b=RW0Z5bTwy8XCiqpWgX/mePZrYlKxC/7Um5fk2Y0FDJVq7Ra05c+2/fCyeBGaSDOTOrMT 7cS6h/zKFIWKBCCnSBO4HSNwg6LhqLUUb8Jg1FDMaLBLoS4I9qY3WGx3uCrlWsNRZjRC Z8BVQhVRjb2g2LgmTI2MwVJvoDsdIbhDrS0R8mR76zpKg3WIJ06qaLn9R8KRnRXROLR1 ZR9Ujxc7KpaWx+9HBR1g9CW9zYANoiIomKC5p7e023b9oWtJcKF3mnySgcqjqP6rWJT+ uivyKuDtRQFowkwC2erTm4KM6BM/m6v5RwXnpvYlrmJqBSKWTD/2W1vhOYVZ5KjPyfd+ Bg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p4sffbvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:50 +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 3391D100038; Wed, 17 Feb 2021 14:30:50 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 20B9E2370C9; Wed, 17 Feb 2021 14:30:50 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:30:49 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 04/16] rpmsg: char: export eptdev create an destroy functions Date: Wed, 17 Feb 2021 14:28:53 +0100 Message-ID: <20210217132905.1485-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org To prepare the split code related to the control and the endpoint devices in separate files: - suppress the dependency with the rpmsg_ctrldev struct, - rename and export the functions in rpmsg_char.h. Suggested-by: Mathieu Poirier Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 22 ++++++++++------ drivers/rpmsg/rpmsg_char.h | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 drivers/rpmsg/rpmsg_char.h diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 9e33b53bbf56..78a6d19fdf82 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* + * Copyright (C) 2021, STMicroelectronics * Copyright (c) 2016, Linaro Ltd. * Copyright (c) 2012, Michal Simek * Copyright (c) 2012, PetaLogix @@ -22,6 +23,7 @@ #include #include +#include "rpmsg_char.h" #include "rpmsg_internal.h" #define RPMSG_DEV_MAX (MINORMASK + 1) @@ -78,7 +80,7 @@ struct rpmsg_eptdev { wait_queue_head_t readq; }; -static int rpmsg_eptdev_destroy(struct device *dev, void *data) +static int rpmsg_eptdev_destroy(struct device *dev) { struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev); @@ -277,7 +279,7 @@ static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd, if (cmd != RPMSG_DESTROY_EPT_IOCTL) return -EINVAL; - return rpmsg_eptdev_destroy(&eptdev->dev, NULL); + return rpmsg_eptdev_destroy(&eptdev->dev); } static const struct file_operations rpmsg_eptdev_fops = { @@ -336,10 +338,15 @@ static void rpmsg_eptdev_release_device(struct device *dev) kfree(eptdev); } -static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) +{ + return rpmsg_eptdev_destroy(dev); +} +EXPORT_SYMBOL(rpmsg_chrdev_eptdev_destroy); + +int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent, struct rpmsg_channel_info chinfo) { - struct rpmsg_device *rpdev = ctrldev->rpdev; struct rpmsg_eptdev *eptdev; struct device *dev; int ret; @@ -359,7 +366,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, device_initialize(dev); dev->class = rpmsg_class; - dev->parent = &ctrldev->dev; + dev->parent = parent; dev->groups = rpmsg_eptdev_groups; dev_set_drvdata(dev, eptdev); @@ -402,6 +409,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, return ret; } +EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev); static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) { @@ -441,7 +449,7 @@ static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, chinfo.src = eptinfo.src; chinfo.dst = eptinfo.dst; - return rpmsg_eptdev_create(ctrldev, chinfo); + return rpmsg_chrdev_create_eptdev(ctrldev->rpdev, &ctrldev->dev, chinfo); }; static const struct file_operations rpmsg_ctrldev_fops = { @@ -527,7 +535,7 @@ static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) int ret; /* Destroy all endpoints */ - ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_eptdev_destroy); + ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_chrdev_eptdev_destroy); if (ret) dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); diff --git a/drivers/rpmsg/rpmsg_char.h b/drivers/rpmsg/rpmsg_char.h new file mode 100644 index 000000000000..0feb3ea9445c --- /dev/null +++ b/drivers/rpmsg/rpmsg_char.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (C) STMicroelectronics 2021. + */ + +#ifndef __RPMSG_CHRDEV_H__ +#define __RPMSG_CHRDEV_H__ + +#if IS_ENABLED(CONFIG_RPMSG_CHAR) +/** + * rpmsg_chrdev_create_eptdev() - register char device based on an endpoint + * @rpdev: prepared rpdev to be used for creating endpoints + * @parent: parent device + * @chinfo: assiated endpoint channel information. + * + * This function create a new rpmsg char endpoint device to instantiate a new + * endpoint based on chinfo information. + */ +int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent, + struct rpmsg_channel_info chinfo); + +/** + * rpmsg_chrdev_eptdev_destroy() - destroy created char device + * @data: parent device + * @chinfo: assiated endpoint channel information. + * + * This function create a new rpmsg char endpoint device to instantiate a new + * endpoint based on chinfo information. + */ +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data); + +#else /*IS_ENABLED(CONFIG_RPMSG_CHAR) */ + +static inline int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, + struct device *parent, + struct rpmsg_channel_info chinfo) +{ + return -EINVAL; +} + +static inline int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + +#endif /*IS_ENABLED(CONFIG_RPMSG_CHAR) */ + +#endif /*__RPMSG_CHRDEV_H__ */ From patchwork Wed Feb 17 13:28:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091641 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 C3967C433E6 for ; Wed, 17 Feb 2021 13:32:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8283B64E4D for ; Wed, 17 Feb 2021 13:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233076AbhBQNc3 (ORCPT ); Wed, 17 Feb 2021 08:32:29 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:39314 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233077AbhBQNbi (ORCPT ); Wed, 17 Feb 2021 08:31:38 -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 11HDQ2F0017925; Wed, 17 Feb 2021 14:30:51 +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=M1W7lnH3WVTrEg/mRlrlwrtBldl3psNcbgfNxLcMeWc=; b=5oEp4dFty/rj17KYD5JjY+d0TCSrz8NAo07al8jk7dsq+bmF+C6bNcFLl+lOS4CEcte3 +nOzPF0W8x9AcA0qd1z6MTD2ahMAqSbmCirH9BB5bBboDCMokeUlKLuE4+fMsqAzFrNc Da0HfhTFwgLZ2G1sZuhy2VRMIoj0WmY0rd3axnCn3mZJkAV+UmjhmfmlhvyUwwF11n5q ILU4JPpmYGWdb/DPj9vMdUZpDVfgpaK/FGIuhZNovBs1r4482pj3Ght9Ow4MbGoS8Yeg LQnIFWI2ssv38kQWn8qvOYTD1GLQr2VxbuEuBxklFeqoFmP0Can0zLlfyeB12ayxSc1l dw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p706nnbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:51 +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 CF55710002A; Wed, 17 Feb 2021 14:30:50 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C40E22370C9; Wed, 17 Feb 2021 14:30:50 +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; Wed, 17 Feb 2021 14:30:50 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 05/16] rpmsg: char: dissociate the control device from the rpmsg class Date: Wed, 17 Feb 2021 14:28:54 +0100 Message-ID: <20210217132905.1485-6-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The RPMsg control device is a RPMsg device, it is already referenced in the RPMsg bus. There is only an interest to reference the ept char devices in the rpmsg class. This patch prepares the code split of the control and end point devices in two separate files. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 78a6d19fdf82..23e369a00531 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -485,7 +485,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; From patchwork Wed Feb 17 13:28:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091651 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 AAEB6C433E6 for ; Wed, 17 Feb 2021 13:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69C7C64D5D for ; Wed, 17 Feb 2021 13:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233035AbhBQNdf (ORCPT ); Wed, 17 Feb 2021 08:33:35 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:39316 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233057AbhBQNbl (ORCPT ); Wed, 17 Feb 2021 08:31:41 -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 11HDQ5bt018515; Wed, 17 Feb 2021 14:30:52 +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=PALxylp6AUpTS7OZFEYPQXmfH/X+QyXLM1mRwWdH39Y=; b=aYcPeB4iIdvrOQtkbVKiyauTzTlEMhWI/m3+XY+KDkqjA/OCy5l/KPwdfvrpBqxyPxXN 4hkGmPVNaZWKN3GMpaVFTGCptAwcYzIvEuO61b0+msdFuQO6jGw2BFqdQB6gyghlVIIe t4V5k2fRfCTOH51QjFNQE4eGahB5qbzqXkHl0TsX7JCd2QzpdYfPty5bGTFIAh7+9tv0 9MH4GEchmXEDk8v8iKPummb0r1VWLvT0Y64MgGv5sKZwBm18NxWz4DiQNxsWoMKEMwdy HSBjEWoMIELtCpsbx9Q1cGCM+R1TXDioH5FTLo+egyivZL51kBJxrEhIbsc2AARxi6ze 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 36p706nnbu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:52 +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 AB832100034; Wed, 17 Feb 2021 14:30:51 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9CDF52370C9; Wed, 17 Feb 2021 14:30:51 +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; Wed, 17 Feb 2021 14:30:51 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 06/16] rpmsg: move the rpmsg control device from rpmsg_char to rpmsg_ctrl Date: Wed, 17 Feb 2021 14:28:55 +0100 Message-ID: <20210217132905.1485-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Move the code related to the rpmsg_ctrl char device to the new rpmsg_ctrl.c module. Manage the dependency in the kconfig. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/Kconfig | 9 ++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_char.c | 163 ---------------------------- drivers/rpmsg/rpmsg_ctrl.c | 216 +++++++++++++++++++++++++++++++++++++ 4 files changed, 226 insertions(+), 163 deletions(-) create mode 100644 drivers/rpmsg/rpmsg_ctrl.c diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index 0b4407abdf13..2d0cd7fdd710 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -10,11 +10,20 @@ config RPMSG_CHAR tristate "RPMSG device interface" depends on RPMSG depends on NET + select RPMSG_CTRL help Say Y here to export rpmsg endpoints as device files, usually found in /dev. They make it possible for user-space programs to send and receive rpmsg packets. +config RPMSG_CTRL + tristate "RPMSG control interface" + depends on RPMSG + help + Say Y here to enable the support of the /dev/rpmsg_ctlX API. This API + allows user-space programs to create endpoints with specific service name, + source and destination addresses. + config RPMSG_NS tristate "RPMSG name service announcement" depends on RPMSG diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index 8d452656f0ee..58e3b382e316 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_RPMSG) += rpmsg_core.o obj-$(CONFIG_RPMSG_CHAR) += rpmsg_char.o +obj-$(CONFIG_RPMSG_CTRL) += rpmsg_ctrl.o obj-$(CONFIG_RPMSG_NS) += rpmsg_ns.o obj-$(CONFIG_RPMSG_MTK_SCP) += mtk_rpmsg.o qcom_glink-objs := qcom_glink_native.o qcom_glink_ssr.o diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 23e369a00531..83c10b39b139 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -31,28 +31,12 @@ static dev_t rpmsg_major; static struct class *rpmsg_class; -static DEFINE_IDA(rpmsg_ctrl_ida); static DEFINE_IDA(rpmsg_ept_ida); static DEFINE_IDA(rpmsg_minor_ida); #define dev_to_eptdev(dev) container_of(dev, struct rpmsg_eptdev, dev) #define cdev_to_eptdev(i_cdev) container_of(i_cdev, struct rpmsg_eptdev, cdev) -#define dev_to_ctrldev(dev) container_of(dev, struct rpmsg_ctrldev, dev) -#define cdev_to_ctrldev(i_cdev) container_of(i_cdev, struct rpmsg_ctrldev, cdev) - -/** - * struct rpmsg_ctrldev - control device for instantiating endpoint devices - * @rpdev: underlaying rpmsg device - * @cdev: cdev for the ctrl device - * @dev: device for the ctrl device - */ -struct rpmsg_ctrldev { - struct rpmsg_device *rpdev; - struct cdev cdev; - struct device dev; -}; - /** * struct rpmsg_eptdev - endpoint device context * @dev: endpoint device @@ -411,145 +395,6 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent } EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev); -static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) -{ - struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); - - get_device(&ctrldev->dev); - filp->private_data = ctrldev; - - return 0; -} - -static int rpmsg_ctrldev_release(struct inode *inode, struct file *filp) -{ - struct rpmsg_ctrldev *ctrldev = cdev_to_ctrldev(inode->i_cdev); - - put_device(&ctrldev->dev); - - return 0; -} - -static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, - unsigned long arg) -{ - struct rpmsg_ctrldev *ctrldev = fp->private_data; - void __user *argp = (void __user *)arg; - struct rpmsg_endpoint_info eptinfo; - struct rpmsg_channel_info chinfo; - - if (cmd != RPMSG_CREATE_EPT_IOCTL) - return -EINVAL; - - if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) - return -EFAULT; - - memcpy(chinfo.name, eptinfo.name, RPMSG_NAME_SIZE); - chinfo.name[RPMSG_NAME_SIZE-1] = '\0'; - chinfo.src = eptinfo.src; - chinfo.dst = eptinfo.dst; - - return rpmsg_chrdev_create_eptdev(ctrldev->rpdev, &ctrldev->dev, chinfo); -}; - -static const struct file_operations rpmsg_ctrldev_fops = { - .owner = THIS_MODULE, - .open = rpmsg_ctrldev_open, - .release = rpmsg_ctrldev_release, - .unlocked_ioctl = rpmsg_ctrldev_ioctl, - .compat_ioctl = compat_ptr_ioctl, -}; - -static void rpmsg_ctrldev_release_device(struct device *dev) -{ - struct rpmsg_ctrldev *ctrldev = dev_to_ctrldev(dev); - - ida_simple_remove(&rpmsg_ctrl_ida, dev->id); - ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); - cdev_del(&ctrldev->cdev); - kfree(ctrldev); -} - -static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) -{ - struct rpmsg_ctrldev *ctrldev; - struct device *dev; - int ret; - - ctrldev = kzalloc(sizeof(*ctrldev), GFP_KERNEL); - if (!ctrldev) - return -ENOMEM; - - ctrldev->rpdev = rpdev; - - dev = &ctrldev->dev; - device_initialize(dev); - dev->parent = &rpdev->dev; - - cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops); - ctrldev->cdev.owner = THIS_MODULE; - - ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL); - if (ret < 0) - goto free_ctrldev; - dev->devt = MKDEV(MAJOR(rpmsg_major), ret); - - ret = ida_simple_get(&rpmsg_ctrl_ida, 0, 0, GFP_KERNEL); - if (ret < 0) - goto free_minor_ida; - dev->id = ret; - dev_set_name(&ctrldev->dev, "rpmsg_ctrl%d", ret); - - ret = cdev_add(&ctrldev->cdev, dev->devt, 1); - if (ret) - goto free_ctrl_ida; - - /* We can now rely on the release function for cleanup */ - dev->release = rpmsg_ctrldev_release_device; - - ret = device_add(dev); - if (ret) { - dev_err(&rpdev->dev, "device_add failed: %d\n", ret); - put_device(dev); - } - - dev_set_drvdata(&rpdev->dev, ctrldev); - - return ret; - -free_ctrl_ida: - ida_simple_remove(&rpmsg_ctrl_ida, dev->id); -free_minor_ida: - ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt)); -free_ctrldev: - put_device(dev); - kfree(ctrldev); - - return ret; -} - -static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) -{ - struct rpmsg_ctrldev *ctrldev = dev_get_drvdata(&rpdev->dev); - int ret; - - /* Destroy all endpoints */ - ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_chrdev_eptdev_destroy); - if (ret) - dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); - - device_del(&ctrldev->dev); - put_device(&ctrldev->dev); -} - -static struct rpmsg_driver rpmsg_chrdev_driver = { - .probe = rpmsg_chrdev_probe, - .remove = rpmsg_chrdev_remove, - .drv = { - .name = "rpmsg_chrdev", - }, -}; - static int rpmsg_chrdev_init(void) { int ret; @@ -567,20 +412,12 @@ static int rpmsg_chrdev_init(void) 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); - } - return ret; } postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { - unregister_rpmsg_driver(&rpmsg_chrdev_driver); class_destroy(rpmsg_class); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c new file mode 100644 index 000000000000..fa05b67d24da --- /dev/null +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021, STMicroelectronics + * Copyright (c) 2016, Linaro Ltd. + * Copyright (c) 2012, Michal Simek + * Copyright (c) 2012, PetaLogix + * Copyright (c) 2011, Texas Instruments, Inc. + * Copyright (c) 2011, Google, Inc. + * + * Based on rpmsg performance statistics driver by Michal Simek, which in turn + * was based on TI & Google OMX rpmsg driver. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rpmsg_char.h" +#include "rpmsg_internal.h" + +#define RPMSG_DEV_MAX (MINORMASK + 1) + +static dev_t rpmsg_major; + +static DEFINE_IDA(rpmsg_ctrl_ida); +static DEFINE_IDA(rpmsg_minor_ida); + +#define dev_to_ctrldev(dev) container_of(dev, struct rpmsg_ctrl, dev) +#define cdev_to_ctrldev(i_cdev) container_of(i_cdev, struct rpmsg_ctrl, cdev) + +/** + * struct rpmsg_ctrl - 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 { + struct rpmsg_device *rpdev; + struct cdev cdev; + struct device dev; +}; + +static int rpmsg_ctrl_open(struct inode *inode, struct file *filp) +{ + struct rpmsg_ctrl *ctrldev = cdev_to_ctrldev(inode->i_cdev); + + get_device(&ctrldev->dev); + filp->private_data = ctrldev; + + return 0; +} + +static int rpmsg_ctrl_release(struct inode *inode, struct file *filp) +{ + struct rpmsg_ctrl *ctrldev = cdev_to_ctrldev(inode->i_cdev); + + put_device(&ctrldev->dev); + + return 0; +} + +static long rpmsg_ctrl_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +{ + struct rpmsg_ctrl *ctrldev = fp->private_data; + void __user *argp = (void __user *)arg; + struct rpmsg_endpoint_info eptinfo; + struct rpmsg_channel_info chinfo; + + if (cmd != RPMSG_CREATE_EPT_IOCTL) + return -EINVAL; + + if (copy_from_user(&eptinfo, argp, sizeof(eptinfo))) + return -EFAULT; + + memcpy(chinfo.name, eptinfo.name, RPMSG_NAME_SIZE); + chinfo.name[RPMSG_NAME_SIZE - 1] = '\0'; + chinfo.src = eptinfo.src; + chinfo.dst = eptinfo.dst; + + return rpmsg_chrdev_create_eptdev(ctrldev->rpdev, &ctrldev->dev, chinfo); +}; + +static const struct file_operations rpmsg_ctrl_fops = { + .owner = THIS_MODULE, + .open = rpmsg_ctrl_open, + .release = rpmsg_ctrl_release, + .unlocked_ioctl = rpmsg_ctrl_ioctl, + .compat_ioctl = compat_ptr_ioctl, +}; + +static void rpmsg_ctrl_release_device(struct device *dev) +{ + struct rpmsg_ctrl *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_ctrl_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_ctrl *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_ctrl_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_ctrl_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_ctrl_remove(struct rpmsg_device *rpdev) +{ + struct rpmsg_ctrl *ctrldev = dev_get_drvdata(&rpdev->dev); + int ret; + + /* Destroy all endpoints */ + ret = device_for_each_child(&ctrldev->dev, NULL, + rpmsg_chrdev_eptdev_destroy); + if (ret) + dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); + + device_del(&ctrldev->dev); + put_device(&ctrldev->dev); +} + +static struct rpmsg_driver rpmsg_ctrl_driver = { + .probe = rpmsg_ctrl_probe, + .remove = rpmsg_ctrl_remove, + .drv = { + .name = "rpmsg_chrdev", + }, +}; + +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("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("rpmsg control interface"); +MODULE_ALIAS("rpmsg:" KBUILD_MODNAME); +MODULE_LICENSE("GPL v2"); From patchwork Wed Feb 17 13:28:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091645 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 BF3D9C433E0 for ; Wed, 17 Feb 2021 13:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8688764E5F for ; Wed, 17 Feb 2021 13:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbhBQNci (ORCPT ); Wed, 17 Feb 2021 08:32:38 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:29980 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233082AbhBQNbj (ORCPT ); Wed, 17 Feb 2021 08:31:39 -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 11HDS1TZ026013; Wed, 17 Feb 2021 14:30:52 +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=URjj4/CWQEc1LE55J3NoeR+Ycg2bTdbvye7fVRYzsh0=; b=8TDt4WC4xoRZQQJAvg+VF5w0ysiqeRnW5jE3sLClBUG/HKM60/lTZ3/64PG+KwIp6hTM fEqfpDzEcJRiWNfnYrijioPns5ntVI4uTn1mqFQPesDTc2IMrvENn0Wa/QxVSE/UUtVc e2h8Jhe95Wdcw0SO7RTUPOOlSmynGqxEAOvyujBQh1MzMgXqN5WwaGaaa/xPYJ5NVtCa zXmN4fvMAKBJ6tVTYRZgdKh/bjZpnSiu42obN7lx8DYkgswwiFYnmPWlTRDWXRpmNp0w /hnWRvlygraf0oxvMbrMAZTnVJLdRI5RNQV6QEnsyMPy7suA4QG7iyep2OCiccmlaQ8w 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 36p547p3qb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:52 +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 65EA010002A; Wed, 17 Feb 2021 14:30:52 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5874E2370C9; Wed, 17 Feb 2021 14:30:52 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:30:52 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 07/16] rpmsg: update rpmsg_chrdev_register_device function Date: Wed, 17 Feb 2021 14:28:56 +0100 Message-ID: <20210217132905.1485-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org As driver is now the rpmsg_ioctl, rename the function. In addition, initialize the rpdev addresses to RPMSG_ADDR_ANY as not defined. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/qcom_glink_native.c | 2 +- drivers/rpmsg/qcom_smd.c | 2 +- drivers/rpmsg/rpmsg_ctrl.c | 2 +- drivers/rpmsg/rpmsg_internal.h | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 27a05167c18c..d4e4dd482614 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1625,7 +1625,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_ctrl_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 19903de6268d..40a1c415c775 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1097,7 +1097,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_ctrl_register_device(&qsdev->rpdev); } /* diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index fa05b67d24da..2e43b4096aa8 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -180,7 +180,7 @@ static struct rpmsg_driver rpmsg_ctrl_driver = { .probe = rpmsg_ctrl_probe, .remove = rpmsg_ctrl_remove, .drv = { - .name = "rpmsg_chrdev", + .name = KBUILD_MODNAME, }, }; diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index a76c344253bf..7428f4465d17 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -82,16 +82,18 @@ struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev, int rpmsg_release_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); /** - * rpmsg_chrdev_register_device() - register chrdev device based on rpdev + * rpmsg_ctrl_register_device() - register a char device for control based on rpdev * @rpdev: prepared rpdev to be used for creating endpoints * * This function wraps rpmsg_register_device() preparing the rpdev for use as * basis for the rpmsg chrdev. */ -static inline int rpmsg_chrdev_register_device(struct rpmsg_device *rpdev) +static inline int rpmsg_ctrl_register_device(struct rpmsg_device *rpdev) { - strcpy(rpdev->id.name, "rpmsg_chrdev"); - rpdev->driver_override = "rpmsg_chrdev"; + strcpy(rpdev->id.name, "rpmsg_ctrl"); + rpdev->driver_override = "rpmsg_ctrl"; + rpdev->src = RPMSG_ADDR_ANY; + rpdev->dst = RPMSG_ADDR_ANY; return rpmsg_register_device(rpdev); } From patchwork Wed Feb 17 13:28:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091647 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 880EFC433DB for ; Wed, 17 Feb 2021 13:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EC7A64E62 for ; Wed, 17 Feb 2021 13:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbhBQNd2 (ORCPT ); Wed, 17 Feb 2021 08:33:28 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:48091 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233084AbhBQNbj (ORCPT ); Wed, 17 Feb 2021 08:31:39 -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 11HDS2lt026039; Wed, 17 Feb 2021 14:30:53 +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=cuI0QyzGfCE9A2PPLZ3Vi0BGYQWHZbe/HztsvrFJe24=; b=E4J5vO1LrVPxJsnK/HEMdc366xybaKh3Evna8avO1FuH4Pq/DNbvk+0uV8ip0DFQllpB F2LICXc8PTUSuygeC3dCtC6OXF114LgmlPYkbCllTkup2gaSpTNfSEQEhxtmePBzOZSg xlqm7t1hp6Y9/PkNgxGMe4b7NUEKyafjBkwP7gEQ1QdM2554frv9Ce8rzoUzN2c71Ym5 Btc86MbZOJRMfTcok4fNZ4s2oQfIm89Sx7AG/psmocraSM5DaY5sHE1uW/UHJt9YuRg3 vrYFoAu+NIubkYZwDjVRomgs0J0PB6rPb+eIUVewCyApe3cGd18rSBhhW6klhq0dhDM9 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 36p547p3qe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:53 +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 25D79100034; Wed, 17 Feb 2021 14:30:53 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 198822370C9; Wed, 17 Feb 2021 14:30:53 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:30:52 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 08/16] rpmsg: glink: add sendto and trysendto ops Date: Wed, 17 Feb 2021 14:28:57 +0100 Message-ID: <20210217132905.1485-9-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Implement the sendto ops to support the future rpmsg_char update for the vitio backend support. The use of sendto in rpmsg_char is needed as a destination address is requested at least by the virtio backend. The glink implementation does not need a destination address so ignores it. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/qcom_glink_native.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index d4e4dd482614..ae2c03b59c55 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1332,6 +1332,20 @@ static int qcom_glink_trysend(struct rpmsg_endpoint *ept, void *data, int len) return __qcom_glink_send(channel, data, len, false); } +static int qcom_glink_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) +{ + struct glink_channel *channel = to_glink_channel(ept); + + return __qcom_glink_send(channel, data, len, true); +} + +static int qcom_glink_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) +{ + struct glink_channel *channel = to_glink_channel(ept); + + return __qcom_glink_send(channel, data, len, false); +} + /* * Finds the device_node for the glink child interested in this channel. */ @@ -1364,7 +1378,9 @@ static const struct rpmsg_device_ops glink_device_ops = { static const struct rpmsg_endpoint_ops glink_endpoint_ops = { .destroy_ept = qcom_glink_destroy_ept, .send = qcom_glink_send, + .sendto = qcom_glink_sendto, .trysend = qcom_glink_trysend, + .trysendto = qcom_glink_trysendto, }; static void qcom_glink_rpdev_release(struct device *dev) From patchwork Wed Feb 17 13:28:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091649 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 09B85C4332D for ; Wed, 17 Feb 2021 13:33:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA1BF64D5D for ; Wed, 17 Feb 2021 13:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233094AbhBQNdn (ORCPT ); Wed, 17 Feb 2021 08:33:43 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:29954 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233086AbhBQNbj (ORCPT ); Wed, 17 Feb 2021 08:31:39 -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 11HDS14s026018; Wed, 17 Feb 2021 14:30:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=EK3CcO1sgQ2dyiUJB/DiEfQT2xQz3x3vXQzu8hqKjLk=; b=wot89PnsothtehapmPAAhw2uOntLEyLbqkN1ne2XI5+WIwCtJd7rcy7x37EdgHKRIG1i BNWHWdF2+JpAY1gp3hGc6rZT+jA2g7BVIAZ0KE/1fQ2jG6TUFyAl+tg2Iq6MrnHfojd+ wr7frgVNICoPuyrwrPnkMDdxrvCT8e5dp0XPh9nxmxeTzsfca3ujWFIS7h3dqzzY421t +49kcx1PfFTkE5pfzzYPvbegN/i+XIbbGw+Ty+9LfelhX+aWqvftUC4FraqVDmVrRvJc Ksq5FLEaSBAUqIwryoR6NKsO1IsIC9OxA5HIXpnBgeKx+Bim12L4geGUekQucF1Qe9m/ Og== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p547p3qg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:30:54 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CF3EA10002A; Wed, 17 Feb 2021 14:30:53 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C1AD82370C9; Wed, 17 Feb 2021 14:30:53 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:30:53 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 09/16] rpmsg: smd: add sendto and trysendto ops Date: Wed, 17 Feb 2021 14:28:58 +0100 Message-ID: <20210217132905.1485-10-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Implement the sendto ops to support the future rpmsg_char update for the vitio backend support. The use of sendto in rpmsg_char is needed as a destination address is requested at least by the virtio backend. The SMD implementation does not need a destination address so ignores it. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/qcom_smd.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 40a1c415c775..2d279c03a090 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -974,6 +974,20 @@ static int qcom_smd_trysend(struct rpmsg_endpoint *ept, void *data, int len) return __qcom_smd_send(qsept->qsch, data, len, false); } +static int qcom_smd_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) +{ + struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); + + return __qcom_smd_send(qsept->qsch, data, len, true); +} + +static int qcom_smd_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) +{ + struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); + + return __qcom_smd_send(qsept->qsch, data, len, false); +} + static __poll_t qcom_smd_poll(struct rpmsg_endpoint *ept, struct file *filp, poll_table *wait) { @@ -1038,7 +1052,9 @@ static const struct rpmsg_device_ops qcom_smd_device_ops = { static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = { .destroy_ept = qcom_smd_destroy_ept, .send = qcom_smd_send, + .sendto = qcom_smd_sendto, .trysend = qcom_smd_trysend, + .trysendto = qcom_smd_trysendto, .poll = qcom_smd_poll, }; From patchwork Wed Feb 17 13:28:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091659 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 449D1C433DB for ; Wed, 17 Feb 2021 13:34:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13F9C64D5D for ; Wed, 17 Feb 2021 13:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231683AbhBQNed (ORCPT ); Wed, 17 Feb 2021 08:34:33 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:39690 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233112AbhBQNcl (ORCPT ); Wed, 17 Feb 2021 08:32:41 -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 11HDQiL6019042; Wed, 17 Feb 2021 14:31:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=9otI8hBeC46Slwkg9Iec+E1E6ulCMz/xpbQrJjFhILA=; b=W2Ycckai3Uba1hsH8i7v8jWXOkKhuJZQxV2zl9TEO5UDcxLLSRca1b1E8d/zn6112IFp zfaZJWSS8uoPGiqDEvzqhMXP+MFQwMIl8yKYMWe9dIe8g806Oa/MevAbOR/MF+0Bp/2y yeXsuN+SUIT59KLIajo6ogfiNS/9oDT4HfEamKukr2rP3auamGyWB8Xak4pvjQuP9bKP H1/4v/f+4PPQ3u5bPbxX5OmYn2atHFTlnqYI+ZYFFgFvTLmTDJqQL4U2mpPdcCNJIAjp +dYvy4ZF4PEwOysSsvZqrkBDnPG28wVvlwLyVlKWdhvAkidUhbNTAv+3iy4jvq8xqzqp hA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p706nnhx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:55 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9C3DE10002A; Wed, 17 Feb 2021 14:31:54 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8D0F02370CD; Wed, 17 Feb 2021 14:31:54 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:31:54 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 10/16] rpmsg: char: use sendto to specify the message destination address Date: Wed, 17 Feb 2021 14:28:59 +0100 Message-ID: <20210217132905.1485-11-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org When the endpoint device is created by the application a destination address as been specified in the rpmsg_channel_info structure. Send the message to this address instead of the default one. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 83c10b39b139..09ae1304837c 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -225,9 +225,9 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb, } if (filp->f_flags & O_NONBLOCK) - ret = rpmsg_trysend(eptdev->ept, kbuf, len); + ret = rpmsg_trysendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst); else - ret = rpmsg_send(eptdev->ept, kbuf, len); + ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst); unlock_eptdev: mutex_unlock(&eptdev->ept_lock); From patchwork Wed Feb 17 13:29:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091655 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 579A8C433DB for ; Wed, 17 Feb 2021 13:34:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20CA864E4D for ; Wed, 17 Feb 2021 13:34:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233134AbhBQNd4 (ORCPT ); Wed, 17 Feb 2021 08:33:56 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:14348 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232967AbhBQNck (ORCPT ); Wed, 17 Feb 2021 08:32:40 -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 11HDSSkm000981; Wed, 17 Feb 2021 14:31:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=6z3VyblW4vdPr+7pCRXqS9Ch4EjY9Xj7v8l9KPmZHEU=; b=GW5EUxRfy4kKCLaH44/fuKloQ+S3PvWuwQOSPC6oEchnTD2oZwKCeqhJ9SXpQ+6RLbgM Ger8AJ9l+w3HYPUq/G7IbcCNya7y5ttKLteMypaD3kdIbt4uXmjfhg73CzEl9d5nX4Jd u0jynZr+AlRcak70M5ah+8GTpVhvpuaiz6gHfkkJhFQj6mDjQshJhOgLrjNSvFFVPi4J jpVXD1cu9pbp+OzQ9VOBi3ThT/cD69jJOt0iveKHnrdn7MwciMDL/I/B370XMNwCANyp 4xatJeE+WDrPx3WIUmTeI/FUkVNRav63R4+ip4QWmJpvX3116ujUxi2vOmBvmFapPuoH GQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p4sffc32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:55 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5CCC6100034; Wed, 17 Feb 2021 14:31:55 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4D2002370CE; Wed, 17 Feb 2021 14:31:55 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:31:55 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 11/16] rpmsg: virtio: register the rpmsg_ctrl device Date: Wed, 17 Feb 2021 14:29:00 +0100 Message-ID: <20210217132905.1485-12-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Instantiate the rpmsg_ioctl device on virtio RPMsg bus creation. This provides the possibility to expose the RPMSG_CREATE_EPT_IOCTL to create RPMsg chdev endpoints. Signed-off-by: Arnaud Pouliquen Reported-by: kernel test robot Reported-by: Dan Carpenter --- V3: Fix compilation issue Reported-by: kernel test robot Reported-by: Dan Carpenter warnings: drivers/rpmsg/virtio_rpmsg_bus.c:978 rpmsg_probe() error: uninitialized symbol 'vch'. drivers/rpmsg/virtio_rpmsg_bus.c:979 rpmsg_probe() error: uninitialized symbol 'rpdev_ctrl'. --- 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 e87d4cf926eb..5143fdeca306 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -813,6 +813,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 the 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_ctrl_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 }; @@ -820,7 +849,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 = NULL, *rpdev_ctrl = NULL; void *bufs_va; int err = 0, i; size_t total_buf_space; @@ -918,6 +947,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. @@ -941,6 +975,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 Wed Feb 17 13:29:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091653 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 3CB40C433E0 for ; Wed, 17 Feb 2021 13:34:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9A8664E4D for ; Wed, 17 Feb 2021 13:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233106AbhBQNdr (ORCPT ); Wed, 17 Feb 2021 08:33:47 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:30436 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233088AbhBQNcl (ORCPT ); Wed, 17 Feb 2021 08:32:41 -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 11HDS2AR026029; Wed, 17 Feb 2021 14:31:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=5/5ztwEi6vNBYmfGVztdGKdMNwulPVy/4Aq1/ukOfu0=; b=PAFaE01CCLIglFdIgKiP0C1jbK1Kg2Wr5bxsgfqqyaE/RroOU4littqGNlFK0yAtLMNl CJBsOrk1he2ZZpqqszx6Tnbc9s0mSs7NZ6xmDF08ztLzVEQ7fkbuNhLFEREK66vkb7g9 ul4ID1S23zx4Bo1cRBQIh50rsUBrr1VGz2sQsCCeuPSohfJgV+A9c7feGOZODmA+OtX1 z3332Blqd5dpZMXV8ZPQLyXR3t9b5ie5Z0L+TxOSFZka8XaEQxoDFnZQyiZW2xeGamjx qr6Q73pBkv0KOmv1jFSIJcakCLq7J9ZNK3KZ0lH69ePqqUsR0ZH/8//mJhqB9O/nKP6x 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 36p547p3w8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:56 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 14CA0100038; Wed, 17 Feb 2021 14:31:56 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0683F2370CE; Wed, 17 Feb 2021 14:31:56 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:31:55 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 12/16] rpmsg: ctrl: introduce RPMSG_CREATE_DEV_IOCTL Date: Wed, 17 Feb 2021 14:29:01 +0100 Message-ID: <20210217132905.1485-13-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@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 From patchwork Wed Feb 17 13:29:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091661 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 66465C433E0 for ; Wed, 17 Feb 2021 13:34:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33C7764E5F for ; Wed, 17 Feb 2021 13:34:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbhBQNei (ORCPT ); Wed, 17 Feb 2021 08:34:38 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:1567 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233092AbhBQNcm (ORCPT ); Wed, 17 Feb 2021 08:32:42 -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 11HDSS37000978; Wed, 17 Feb 2021 14:31:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=h8BuLQc6wA4LPMA6U4rmS0YJqMj4AsWKDTNSsFE26UI=; b=sYNxFKG1wsxRXh/aH+r9/BBv9aGDF8hDv7oG5/tP57SHKmFh1iIrZ6ISP+5ldPBYBWQB YutqLu2D1em+7s4GL64wgbpaAuV8eXR7v9utpLuXgPjScKGpF2knTFKnCDXmNB5OJ5pY pFdB6fOYSsyF2bCuqbX1FBy3QnVfqxV/FpoMYPIEzfukLKmpa0otzc/Fj59WQ4cvf5N6 LRZWC6uaTA+6vg/WgPGG1jlEAG8scpPDLe7jLhpqSKdY/sjMssjjfMIvWcgMLvEWsJ9c 66BepZoWRjtBJd/39HUUp5Ryg2i1/lcfZArNwfs8U+9+myqw4ndxfIJGCXWX+zjT/3BT 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 36p4sffc38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:57 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D07C610002A; Wed, 17 Feb 2021 14:31:56 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id BF5932370CD; Wed, 17 Feb 2021 14:31:56 +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; Wed, 17 Feb 2021 14:31:56 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 13/16] rpmsg: char: introduce __rpmsg_chrdev_create_eptdev function Date: Wed, 17 Feb 2021 14:29:02 +0100 Message-ID: <20210217132905.1485-14-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce the __rpmsg_chrdev_create_eptdev internal function that returns the rpmsg_eptdev context structure. This patch prepares the introduction of a RPMsg device for the char device. the RPMsg device will need a reference to the context. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 09ae1304837c..66dcb8845d6c 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -328,8 +328,9 @@ int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) } EXPORT_SYMBOL(rpmsg_chrdev_eptdev_destroy); -int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent, - struct rpmsg_channel_info chinfo) +static struct rpmsg_eptdev *__rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, + struct device *parent, + struct rpmsg_channel_info chinfo) { struct rpmsg_eptdev *eptdev; struct device *dev; @@ -337,7 +338,7 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL); if (!eptdev) - return -ENOMEM; + return ERR_PTR(-ENOMEM); dev = &eptdev->dev; eptdev->rpdev = rpdev; @@ -381,7 +382,7 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent put_device(dev); } - return ret; + return eptdev; free_ept_ida: ida_simple_remove(&rpmsg_ept_ida, dev->id); @@ -391,7 +392,19 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent put_device(dev); kfree(eptdev); - return ret; + return ERR_PTR(ret); +} + +int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent, + struct rpmsg_channel_info chinfo) +{ + struct rpmsg_eptdev *eptdev; + + eptdev = __rpmsg_chrdev_create_eptdev(rpdev, &rpdev->dev, chinfo); + if (IS_ERR(eptdev)) + return PTR_ERR(eptdev); + + return 0; } EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev); From patchwork Wed Feb 17 13:29:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091657 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 B7305C433DB for ; Wed, 17 Feb 2021 13:34:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D86864E5F for ; Wed, 17 Feb 2021 13:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233116AbhBQNe1 (ORCPT ); Wed, 17 Feb 2021 08:34:27 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:14360 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233113AbhBQNcm (ORCPT ); Wed, 17 Feb 2021 08:32:42 -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 11HDSVIZ001039; Wed, 17 Feb 2021 14:31:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=eGJzS9Xz7eIhHAVhC6Db4iXWGLF1aUvnd2LYJYUn1C0=; b=aW647A+YkXgQatLzTSh6a1Pw3rjED0sdX2MkN3gE83YaFNbJLq1jXd+jg+RHGZcr88cc Iou0hX4xxwh4jGUI16dshulxJO6QnoPXx9tIY9n/CACLWB/SDkR8qfFms42esq6LepY4 3L/57AdSstENyE/SIMqxnVqYZsknzyxp7pt3EeSLZlX/XPOs/a9+1e51Xgxp+5MsOE5d jLT8fh5sNIZlxZLg5SAOjItkRdBIXdL8gpAPVaJy3YtA2YfUb8y3ZqEnJNRbHAvNErtr cFNbiopgM/oLBxejobEcKs99noCGXF7OpHZF8Nu64usdg3ivSbJJb5JB4Jv++IRQmMwU 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 36p4sffc3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:58 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 82AC0100034; Wed, 17 Feb 2021 14:31:57 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7427F2370CD; Wed, 17 Feb 2021 14:31:57 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:31:57 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 14/16] rpmsg: char: introduce a RPMsg driver for the RPMsg char device Date: Wed, 17 Feb 2021 14:29:03 +0100 Message-ID: <20210217132905.1485-15-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org A RPMsg char device allows to probe the endpoint device on a remote name service announcement. With this patch the /dev/rpmsgX interface is created either by a user application or by the remote firmware. Signed-off-by: Arnaud Pouliquen Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/rpmsg/rpmsg_char.c | 63 +++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 66dcb8845d6c..d5aa874865f7 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -28,6 +28,8 @@ #define RPMSG_DEV_MAX (MINORMASK + 1) +#define RPMSG_CHAR_DEVNAME "rpmsg-raw" + static dev_t rpmsg_major; static struct class *rpmsg_class; @@ -408,6 +410,51 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent } EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev); +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_channel_info chinfo; + struct rpmsg_eptdev *eptdev; + + memcpy(chinfo.name, RPMSG_CHAR_DEVNAME, sizeof(RPMSG_CHAR_DEVNAME)); + chinfo.src = rpdev->src; + chinfo.dst = rpdev->dst; + + eptdev = __rpmsg_chrdev_create_eptdev(rpdev, &rpdev->dev, chinfo); + if (IS_ERR(eptdev) && rpdev->ept) { + rpmsg_destroy_ept(rpdev->ept); + return PTR_ERR(eptdev); + } + + /* Set the private field of the default endpoint to retrieve context on callback. */ + rpdev->ept->priv = eptdev; + + return 0; +} + +static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) +{ + int ret; + + ret = device_for_each_child(&rpdev->dev, NULL, rpmsg_chrdev_eptdev_destroy); + if (ret) + dev_warn(&rpdev->dev, "failed to destroy endpoints: %d\n", ret); +} + +static struct rpmsg_device_id rpmsg_chrdev_id_table[] = { + { .name = RPMSG_CHAR_DEVNAME }, + { }, +}; + +static struct rpmsg_driver rpmsg_chrdev_driver = { + .probe = rpmsg_chrdev_probe, + .remove = rpmsg_chrdev_remove, + .id_table = rpmsg_chrdev_id_table, + .callback = rpmsg_ept_cb, + .drv = { + .name = "rpmsg_chrdev", + }, +}; + static int rpmsg_chrdev_init(void) { int ret; @@ -422,9 +469,23 @@ static int rpmsg_chrdev_init(void) 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 = PTR_ERR(rpmsg_class); + goto free_region; } + ret = register_rpmsg_driver(&rpmsg_chrdev_driver); + if (ret < 0) { + pr_err("rpmsg raw: failed to register rpmsg driver\n"); + goto free_class; + } + + return 0; + +free_class: + class_destroy(rpmsg_class); +free_region: + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); + return ret; } postcore_initcall(rpmsg_chrdev_init); From patchwork Wed Feb 17 13:29:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091665 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 C7066C433DB for ; Wed, 17 Feb 2021 13:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9297064D73 for ; Wed, 17 Feb 2021 13:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233163AbhBQNe4 (ORCPT ); Wed, 17 Feb 2021 08:34:56 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:39710 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233114AbhBQNcq (ORCPT ); Wed, 17 Feb 2021 08:32:46 -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 11HDQ2Ra017869; Wed, 17 Feb 2021 14:31:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=MuyXJB7WjUr+M+1phw3VLrgCeO68qXJXMtTO20gRugM=; b=fpsscxz+F18JloUMSf7Qn00nmHr0u+qIYRxXXmkUHLCh3LJ3o8i/+9Xu7/iz0kr/DMkR emO6O0Xx4VeU55RNK7fgbqjf3VQwIouyeciO3q0LLUBlPz0fzIYydohyHhJChbS2Fcpf mffZmjsiF7yRNEEe7Tqo/m5wjfDo4//QmZ+fG2AFvr9WanVlie16egJ4+kLs6cS5AL98 HwKV2YXu58RtBj3+JaUJs/vlFAFkzf53IBVokar14pXV7FL965qDi8l7c8vCY/fZGOdv F4Tmotc0sfRYI1gpz1hRXUVkQiMFyPLXrOiXRBsNXb7kdyRdaHQ3m7/iubsJrBmHvRUI 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 36p706nnjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:58 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4D86210002A; Wed, 17 Feb 2021 14:31:58 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 3E1242370CD; Wed, 17 Feb 2021 14:31:58 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:31:57 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 15/16] rpmsg: char: no dynamic endpoint management for the default one Date: Wed, 17 Feb 2021 14:29:04 +0100 Message-ID: <20210217132905.1485-16-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Do not dynamically manage the default endpoint. The ept address must not change. This update is needed to manage the RPMSG_CREATE_DEV_IOCTL. In this case a default endpoint is used and it's address must not change or been reused by another service. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index d5aa874865f7..0b0a6b7c0c9a 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -114,14 +114,23 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) struct rpmsg_endpoint *ept; struct rpmsg_device *rpdev = eptdev->rpdev; struct device *dev = &eptdev->dev; + u32 addr = eptdev->chinfo.src; get_device(dev); - ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); - if (!ept) { - dev_err(dev, "failed to open %s\n", eptdev->chinfo.name); - put_device(dev); - return -EINVAL; + /* + * The ept device can has been created by a ns announcement. In this + * case a default endpoint has been created. Reuse it to avoid to manage + * a new address on each open close. + */ + ept = rpdev->ept; + if (!ept || addr != ept->addr) { + ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); + if (!ept) { + dev_err(dev, "failed to open %s\n", eptdev->chinfo.name); + put_device(dev); + return -EINVAL; + } } eptdev->ept = ept; @@ -133,12 +142,17 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) static int rpmsg_eptdev_release(struct inode *inode, struct file *filp) { struct rpmsg_eptdev *eptdev = cdev_to_eptdev(inode->i_cdev); + struct rpmsg_device *rpdev = eptdev->rpdev; struct device *dev = &eptdev->dev; - /* Close the endpoint, if it's not already destroyed by the parent */ + /* + * Close the endpoint, if it's not already destroyed by the parent and it is not the + * default one. + */ mutex_lock(&eptdev->ept_lock); if (eptdev->ept) { - rpmsg_destroy_ept(eptdev->ept); + if (eptdev->ept != rpdev->ept) + rpmsg_destroy_ept(eptdev->ept); eptdev->ept = NULL; } mutex_unlock(&eptdev->ept_lock); From patchwork Wed Feb 17 13:29:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12091663 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 49872C433DB for ; Wed, 17 Feb 2021 13:35:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EE6064E5B for ; Wed, 17 Feb 2021 13:35:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233070AbhBQNeu (ORCPT ); Wed, 17 Feb 2021 08:34:50 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:47119 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233115AbhBQNcr (ORCPT ); Wed, 17 Feb 2021 08:32: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 11HDS2Ze026032; Wed, 17 Feb 2021 14:31:59 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=CRnSbQdFwvKmyMc039keRokTHONUmSL8dsL/yTFkE0w=; b=DSef1EykTWXbQKXEkRUowgzcLAMtb/V4v2KJMScqU7BEvPVA+8zmBFbF/LDLxqcs+ID/ pvqjfVLszTMveOwN6hhaFD+4X1fgFO8IcCurctgaMXyAo1wJUEpeH8vwiGCc4EKtuj9D COwumNzXdbfNcaX4B0Cs8tBsQWblZLnQdrasw5fZBB7bbU0og4kXAmqUJuIujkMCdDyO SJECRr4+xex0omxWGW/zbATFpYfHUp0w6c9eILqxmIMjKW5fFjDXXBrOMg3Knp+2GszI ky7MWCSTpKW4LpNWdV1GZs/1no9HzjQzyipdulg4MDelOoyhpUZ14/Mj+89z/DcOt+vR 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 36p547p3wu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 14:31:59 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0C99710002A; Wed, 17 Feb 2021 14:31: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 F3F982370CE; Wed, 17 Feb 2021 14:31:58 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 17 Feb 2021 14:31:58 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v4 16/16] rpmsg: char: return an error if device already open Date: Wed, 17 Feb 2021 14:29:05 +0100 Message-ID: <20210217132905.1485-17-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> References: <20210217132905.1485-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] 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-17_11:2021-02-16,2021-02-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The rpmsg_create_ept function is invoked when the device is opened. As only one endpoint must be created per device. It is not possible to open the same device twice. But there is nothing to prevent multi open. Return -EBUSY when device is already opened to have a generic error instead of relying on the back-end to potentially detect the error. Without this patch for instance the GLINK driver return -EBUSY while the virtio bus return -ENOSPC. 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 0b0a6b7c0c9a..2eacddb83e29 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -116,6 +116,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) struct device *dev = &eptdev->dev; u32 addr = eptdev->chinfo.src; + if (eptdev->ept) + return -EBUSY; + get_device(dev); /*