From patchwork Fri Feb 19 11:14:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12095049 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,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 41CC5C433E6 for ; Fri, 19 Feb 2021 11:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E996564E33 for ; Fri, 19 Feb 2021 11:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbhBSLSz (ORCPT ); Fri, 19 Feb 2021 06:18:55 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4574 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230071AbhBSLSs (ORCPT ); Fri, 19 Feb 2021 06:18:48 -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 11JBGiBf016593; Fri, 19 Feb 2021 12:18:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=Eg4OKsTKzswaEDxBH77D2QEGSARCRjEDw0vkCFnM8gE=; b=GcY54TPYLVHHjWyWXlvV7blNjRpVqjnB/w5nWrEjQGTggqBB6x2ZPJeX4KusEePQplvq RCr01iMocpmqocIb7Sja8MvvD+Yu33S3dTLL+keFuKWIP8etqLWIyaPKrLo8nAClpy9k uU94mMmrCF7Yb5xQEHWjVWL2U76e+VFVpJx/6h0HGa4LSKc1fQSwfmJP3QB4iTp+hj8U geOvPEjd/jJTubD/R2YgkwZzePMUzp6TUbCJX/CdbXbYXpFTjTp0RYCo5zt3vjJfWv02 Q5+8kTXenQ4cvR7CIokLrgCCC2Ai5yqQ39DEVVKmYqxjRmjYObKgHx7uhRAMyX6N2EW6 Cg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sse3xh39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:00 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AA767100038; Fri, 19 Feb 2021 12:17: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 9D52B2266D7; Fri, 19 Feb 2021 12:17:59 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:17:59 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 01/16] rpmsg: char: rename rpmsg_char_init to rpmsg_chrdev_init Date: Fri, 19 Feb 2021 12:14:46 +0100 Message-ID: <20210219111501.14261-2-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_04:2021-02-18,2021-02-19 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-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 Fri Feb 19 11:14:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12095055 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,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 7DF14C43331 for ; Fri, 19 Feb 2021 11:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A17864ED2 for ; Fri, 19 Feb 2021 11:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbhBSLTO (ORCPT ); Fri, 19 Feb 2021 06:19:14 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:57818 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbhBSLSt (ORCPT ); Fri, 19 Feb 2021 06:18:49 -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 11JBGJqW030398; Fri, 19 Feb 2021 12:18:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=FcW1J/setFwTwOH+VhdGFYbPkMfYg30KWwRW0YzViPA=; b=MaTOl+P7eVOuQD8KnmZu5oBmWfZhVKLWtFHWqZDQyGxedBlq+y27KUuwbPS9zEm8vXHb OOYeG9zJm1tWgvThMvH3doGzbDILlE3zrkHHDonAaEFmBlMLZ7C/Bn47yrARbJqxQXmb zDp28xTjejaP8Roaq6LcymxA1VXP2fQGY+G++0p/q5qnx04ziV51diyOrKsqYAe6SM7Z 5ejTIpyk1dGrrRFygFiyno6X3oQPDlPHTtsTwEZqDvkIB9yhlrJrYsdCYHTQknjMRs1A JlHVR5e9lSIbJDJvDKub0eQXxw7aMUh1CTzklrmgo/EBg26VUCsXPAmCvSsiYZkFllZX 5A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p7072str-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:00 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8983110002A; Fri, 19 Feb 2021 12:18:00 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7F19E2266D7; Fri, 19 Feb 2021 12:18:00 +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; Fri, 19 Feb 2021 12:18:00 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 02/16] rpmsg: move RPMSG_ADDR_ANY in user API Date: Fri, 19 Feb 2021 12:14:47 +0100 Message-ID: <20210219111501.14261-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12095051 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,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 45F3CC433E0 for ; Fri, 19 Feb 2021 11:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6567E64EC4 for ; Fri, 19 Feb 2021 11:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230308AbhBSLTE (ORCPT ); Fri, 19 Feb 2021 06:19:04 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11218 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230237AbhBSLSs (ORCPT ); Fri, 19 Feb 2021 06:18:48 -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 11JBGiLP016601; Fri, 19 Feb 2021 12:18:01 +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=HlLmImPULDUQ/sfrHW2wdCgpXLkZ9WIoQooYS8z4a/WG2aqHFu9FcL+QdiPGO8pzxf9h jODQG1oWG87M9zdOeG25FYsEETqJ+P/ahEm1BW8QhZWI4C3iyQR7jfJBl8vZ0M3EdQQZ OEqXZKQY+6ri9OuFFeUIKRnjLoU4L/iMwrRFuAx6heF7Sxax6e6+QifZKSVa/WM/3N0G I3QrCz6qMtrP/8jV6LjS2oWxqmayPND7u1gd3IyrWoWhY7xJAnniLYj1kfJvEidxnJ3m 2kvlwygLAenhcMHyMfuRulmuqW+DJi/cTNqrNx3nHEpLwDb8EhYbEnUjOdEgRA4F1mES xg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sse3xh3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:01 +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 5259A10002A; Fri, 19 Feb 2021 12:18:01 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 409902266D7; Fri, 19 Feb 2021 12:18:01 +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; Fri, 19 Feb 2021 12:18:00 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 03/16] rpmsg: add short description of the IOCTL defined in UAPI. Date: Fri, 19 Feb 2021 12:14:48 +0100 Message-ID: <20210219111501.14261-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12095059 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,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 10D75C433E0 for ; Fri, 19 Feb 2021 11:19:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B82A264EC0 for ; Fri, 19 Feb 2021 11:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbhBSLTW (ORCPT ); Fri, 19 Feb 2021 06:19:22 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:57826 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbhBSLSt (ORCPT ); Fri, 19 Feb 2021 06:18:49 -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 11JBGJ6x030425; Fri, 19 Feb 2021 12:18:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=eL8fdw48NUXLNEyAuslWK3wA6wxsb+gv6VUFyukuFOo=; b=aRZnhjCV7fCqPryW5dpMpBHXoY+zxjJTokMDgdgwwgFWXtz7GteAgBaT2dsksWuPIMfb SPRanWrbQMXktm+gFdLTtURPQ7YLmZQUBaG6m7044NpWgUF7ZLOGM8/3MJrxABS9/t/M ItblN4H8nI5fzuSxdznwOJnsNqafR6G/t03WKGTrgqPzybV9EYCPSg76biJfpGCqNl++ yfMDj325GxVGKHfnqplZ0Lh1vBo+ryNDyNZ1Cq1aT9EmhFCTy8IjSFkr33v2nnTnEs6T pPZb5ZhluRnCuoaP1ESXhBmlcQx12dYntumWNVORNqWvYZne8F9QezTQ6o7pEjFhML4d CA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p7072su4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:02 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 30DF110003B; Fri, 19 Feb 2021 12:18:02 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 23A4B2266D8; Fri, 19 Feb 2021 12:18:02 +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; Fri, 19 Feb 2021 12:18:01 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 04/16] rpmsg: char: export eptdev create an destroy functions Date: Fri, 19 Feb 2021 12:14:49 +0100 Message-ID: <20210219111501.14261-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095057 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,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 352C9C433E0 for ; Fri, 19 Feb 2021 11:19:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E393564E92 for ; Fri, 19 Feb 2021 11:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbhBSLTT (ORCPT ); Fri, 19 Feb 2021 06:19:19 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52504 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230240AbhBSLSt (ORCPT ); Fri, 19 Feb 2021 06:18:49 -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 11JBHiIC009043; Fri, 19 Feb 2021 12:18:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=M1W7lnH3WVTrEg/mRlrlwrtBldl3psNcbgfNxLcMeWc=; b=1IsBstxw8knpA34Oop7yxABZlKXc8V+Ad5rQPD2Gd8MElQ60lAfyOw5J8C98xwAHwq2p HYkWpWwHbcdomraj96ib+4v/bzlCci8jFgMFlAR8ek7T4dJ8tL5OoFHjXg9FL86wDx9L Cc3ZnY1tM4xWOU1hFW2pR+PHUCnOohpnZPD8du1R9lvcMIQu5fOStOVPwuDLRVtwG6rv LfgUP+AN6p7ksb+PnifiKZkI+alZVwGBsKJxDR/IqvRwqXPAw0GQNQATXysurBe9T3L0 mL82nGvocNirU99/jggsyEcsANjSHbd0Xb2HXrqfrVUor3WoZrQB23jS2fN/TncXqgjt mw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p6hq550k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:03 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0684C10002A; Fri, 19 Feb 2021 12:18:03 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E9B812266D7; Fri, 19 Feb 2021 12:18:02 +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; Fri, 19 Feb 2021 12:18:02 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 05/16] rpmsg: char: dissociate the control device from the rpmsg class Date: Fri, 19 Feb 2021 12:14:50 +0100 Message-ID: <20210219111501.14261-6-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095065 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,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 86902C433E6 for ; Fri, 19 Feb 2021 11:20:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44A7064EE0 for ; Fri, 19 Feb 2021 11:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230393AbhBSLTo (ORCPT ); Fri, 19 Feb 2021 06:19:44 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4582 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230263AbhBSLSv (ORCPT ); Fri, 19 Feb 2021 06:18:51 -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 11JBGiRE016623; Fri, 19 Feb 2021 12:18:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=PALxylp6AUpTS7OZFEYPQXmfH/X+QyXLM1mRwWdH39Y=; b=vi+1sghareycgI9NNLko3kZldxKEOBLojalVAN+m9yh2vYTkgkP/uesSdvXuejOaNPps cfZTb7KUi0XWgUo3hMj6T7XaWq/6rXOTXuHklQ4d+a2zqXvuzOXh3nqIEsIgQ3LUPKzd HVnzg7QEWEGMfRnK6OvC6J5Dm4zKebb2fzTkG/Jw5XwwaC560+y9VbG/+GDEF2ybE9i3 VgI8HWXGUOup0b4MVybYXordnjwBGbKMfBY1OPDQ8BnPvAPm3/3/yCNjl3DpvlIC4UE1 ql4ByyjjRIT8mr+Ng5DLskW9MgT6FOKjh8hJZ3+GQVoeChES49s8H6kjifP2UaUgqwZZ pQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sse3xh43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:04 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D7C68100034; Fri, 19 Feb 2021 12:18:03 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id CA4F42266D7; Fri, 19 Feb 2021 12:18:03 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:18:03 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 06/16] rpmsg: move the rpmsg control device from rpmsg_char to rpmsg_ctrl Date: Fri, 19 Feb 2021 12:14:51 +0100 Message-ID: <20210219111501.14261-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095061 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,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 5DFB5C433DB for ; Fri, 19 Feb 2021 11:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A07F64EC0 for ; Fri, 19 Feb 2021 11:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbhBSLT2 (ORCPT ); Fri, 19 Feb 2021 06:19:28 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52516 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230261AbhBSLSu (ORCPT ); Fri, 19 Feb 2021 06:18:50 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JBHl8q009458; Fri, 19 Feb 2021 12:18:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=URjj4/CWQEc1LE55J3NoeR+Ycg2bTdbvye7fVRYzsh0=; b=zAvyEVjIakpNDzahe/iuJcl8LWQEYRrFj991JDJrStLG4DaaIQk4jEIzd6GnIKf9kz5U hz4dFLwWTegqvG8bY3Q4x+H3A6088gpg5x4ViptIMk17vOyyxhZSDaO6FV6ENQJe9RKz taORj6gqPX1E2ixNBVyhdVAA86Z1GjoQBEAlM8KXgr3oKjBPK6dkk2G3GhbE3SHp0Lno TmLfOSUls5A9ak+mJceZCP5X7IIPL/DUH5s/5krAXfFgBg27Iqf9aa96e5Nspvrf4hRk oyAs44WXsAPXIjn9qBq3JUmkIbBItVOYmNua7xNsZPthT9gROxD6dhBxL50zz747n+PS Mw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p6hq550t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:05 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A581B10002A; Fri, 19 Feb 2021 12:18:04 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 994202266D7; Fri, 19 Feb 2021 12:18:04 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:18:04 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 07/16] rpmsg: update rpmsg_chrdev_register_device function Date: Fri, 19 Feb 2021 12:14:52 +0100 Message-ID: <20210219111501.14261-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095063 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,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 BD6B0C43381 for ; Fri, 19 Feb 2021 11:20:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9660864EE0 for ; Fri, 19 Feb 2021 11:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbhBSLTr (ORCPT ); Fri, 19 Feb 2021 06:19:47 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:57866 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbhBSLSw (ORCPT ); Fri, 19 Feb 2021 06:18:52 -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 11JBGJCb030410; Fri, 19 Feb 2021 12:18:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=cuI0QyzGfCE9A2PPLZ3Vi0BGYQWHZbe/HztsvrFJe24=; b=3P4NPOjUUnLZjDaresCGlDxD1sXjZHpHMZETxJiTnq/RJQpagaIdkzUyhJkJtgbb1fK8 rAGDS4vibG0OvqXv6qF3jZPdKGD16WrJhc4KzPcqdoz0H44RVzHAX8NDPyjZKiSLP24G 6QjDO98h2Ph3fRECo9Okt9DLhxoFn7uGPBRGbwTFZtB9SPcduMMTEaLOQBDfUUeKyrEt UeTnrqAMkPfYI2dIDUIv5gFWJ0ZgJA9BqUyOMzjEWLvX3eq5lWoFVe3qZwOok0cXHddB rlVA1HS4CI2qGLklnARanpDGxdQw4mPlU/KJC87zLE0VkjbLEb9t1Eem1Vt8VyeBh5G7 Gg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p7072sud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:05 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 667C0100034; Fri, 19 Feb 2021 12:18:05 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5A86B2266D7; Fri, 19 Feb 2021 12:18:05 +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; Fri, 19 Feb 2021 12:18:05 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 08/16] rpmsg: glink: add sendto and trysendto ops Date: Fri, 19 Feb 2021 12:14:53 +0100 Message-ID: <20210219111501.14261-9-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095067 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,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 1B938C4332E for ; Fri, 19 Feb 2021 11:20:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E11B964E92 for ; Fri, 19 Feb 2021 11:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbhBSLTw (ORCPT ); Fri, 19 Feb 2021 06:19:52 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58859 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbhBSLSw (ORCPT ); Fri, 19 Feb 2021 06:18:52 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JBCEXQ008790; Fri, 19 Feb 2021 12:18:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=EK3CcO1sgQ2dyiUJB/DiEfQT2xQz3x3vXQzu8hqKjLk=; b=2mdM/vN8sOJdnOU7LEpJ2BODafUjoLn0ZRZZA1MaN2HiobBrn0St0pITjBrgdhfvR69Y 0zbkTwFMcdE/czow90mPN1fp/LQTYZF/FMhxCWEBw1Yv8+U9+0kpeOr1xpw2Rb5vrvB6 Vu35KdlD1ifIZZsxAQiLe2Q+cAntANdsqkBNm4OF+wmqchxpwP0r02JPUtcehDc//+8x rMy92Wmcwr7fpCpN1FdetiYJLMdphikvY+nN9OTzD2AAtNdW9V4G8W7x1gS/Erf04x1D l1ZLMKYdhxLHPG58q/4LSp9Mzuu2/JqbZiciQU+u6YnOV4j+WjebdYXTnUJMVF/JxKXs UA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sqadeynu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:06 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 581DB10002A; Fri, 19 Feb 2021 12:18:06 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 491712266D7; Fri, 19 Feb 2021 12:18:06 +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; Fri, 19 Feb 2021 12:18:05 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 09/16] rpmsg: smd: add sendto and trysendto ops Date: Fri, 19 Feb 2021 12:14:54 +0100 Message-ID: <20210219111501.14261-10-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095071 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,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 004E1C433E0 for ; Fri, 19 Feb 2021 11:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DCF064E67 for ; Fri, 19 Feb 2021 11:20:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbhBSLUY (ORCPT ); Fri, 19 Feb 2021 06:20:24 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:57955 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbhBSLTx (ORCPT ); Fri, 19 Feb 2021 06:19:53 -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 11JBIH3O024160; Fri, 19 Feb 2021 12:19:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=9otI8hBeC46Slwkg9Iec+E1E6ulCMz/xpbQrJjFhILA=; b=nfbXS3sy4uWQ0xrA03klZDh0wq+a+D69/LixFP3MUJ36WSHERVi7XabcR2IhyLVjtEZt S/XwHheSen3Y7FhtMcJDtylF3mSYTPf8gdm3MZhKwMUyBesHv2Y9JATHw7ZtS7FWlr6W TnY7wel/dBScZEpOTVW7W+8HinC3mafVsD6CdbdGF46h954/KJKmxrEZXc6GH+LEHBQk B100oCGvQ6fzrF2efgbI0o7hYbKyaJVzL8mr2v6yLPTrsCX+8e6GM0mzMVqpXwYk7wMC l2Vj6TtnBdmyQZW0bjKjtjTMSM58ane6p5OjKDo2Ycd2D9VkmFLnt3Jrep7dpi9ZTAUw bA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sqadeyvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:07 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2C88A10002A; Fri, 19 Feb 2021 12:19:07 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 1FEF7221760; Fri, 19 Feb 2021 12:19:07 +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; Fri, 19 Feb 2021 12:19:06 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 10/16] rpmsg: char: use sendto to specify the message destination address Date: Fri, 19 Feb 2021 12:14:55 +0100 Message-ID: <20210219111501.14261-11-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095069 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,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 D176CC433E0 for ; Fri, 19 Feb 2021 11:20:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85AAF64E76 for ; Fri, 19 Feb 2021 11:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbhBSLUU (ORCPT ); Fri, 19 Feb 2021 06:20:20 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11592 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230408AbhBSLTx (ORCPT ); Fri, 19 Feb 2021 06:19:53 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JBGjGH016690; Fri, 19 Feb 2021 12:19:08 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=f6gGwgoPcV2gF5we9bLFFlVpDk5mfORKVkwS1Bo2ZdU=; b=L+fEw+Ht0wXiDyCDTfnCiJAuxFIuoVi9Gidq9+vaxfZnUuh7S8qvUSw9hBGn8qglaWyF EemwYgm6Itq29S5LsZL+dLWI6i/LiB0xUQ609Rbo6YEq83UZrJSDWTx+pW3UyKzR8DpG FpetGWWUD5FjiCAmIpIKzCBfuizpcWQFmmyFvs+QFcxaSjLFApEqroeVOpxzk8EsHaO2 p8otiskykkBYlcSE0MojUoUczsgUHFjGehIRp8rGyBKj2hGpUUL6a9eKyHLf7q0+qUJ6 mk4VJae70e6bUqsj4Z65dPdxcKep+aeNZPJhzhVdY5t4byU0jcMBbX29UliJV6zJ4FbL PA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sse3xhbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:08 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E53B110002A; Fri, 19 Feb 2021 12:19:07 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D80F0221760; Fri, 19 Feb 2021 12:19:07 +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; Fri, 19 Feb 2021 12:19:07 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 11/16] rpmsg: virtio: register the rpmsg_ctrl device Date: Fri, 19 Feb 2021 12:14:56 +0100 Message-ID: <20210219111501.14261-12-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] 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-19_04:2021-02-18,2021-02-19 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 --- V5: Fix compilation issue Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/rpmsg/virtio_rpmsg_bus.c | 57 +++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index e87d4cf926eb..2e6b34084012 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -813,14 +813,52 @@ static void rpmsg_xmit_done(struct virtqueue *svq) wake_up_interruptible(&vrp->sendq); } +static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev) +{ + struct virtproc_info *vrp = vdev->priv; + struct virtio_rpmsg_channel *vch; + struct rpmsg_device *rpdev_ctrl; + int err = 0; + + vch = kzalloc(sizeof(*vch), GFP_KERNEL); + if (!vch) + return ERR_PTR(-ENOMEM); + + /* Link the channel to 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) { + kfree(vch); + return ERR_PTR(err); + } + + return rpdev_ctrl; +} + +static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl) +{ + if (!rpdev_ctrl) + return; + kfree(to_virtio_rpmsg_channel(rpdev_ctrl)); +} + static int rpmsg_probe(struct virtio_device *vdev) { vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done }; static const char * const names[] = { "input", "output" }; struct virtqueue *vqs[2]; struct virtproc_info *vrp; - struct virtio_rpmsg_channel *vch; - struct rpmsg_device *rpdev_ns; + struct virtio_rpmsg_channel *vch = NULL; + struct rpmsg_device *rpdev_ns = NULL, *rpdev_ctrl; void *bufs_va; int err = 0, i; size_t total_buf_space; @@ -894,12 +932,18 @@ static int rpmsg_probe(struct virtio_device *vdev) vdev->priv = vrp; + rpdev_ctrl = rpmsg_virtio_add_ctrl_dev(vdev); + if (IS_ERR(rpdev_ctrl)) { + err = PTR_ERR(rpdev_ctrl); + goto free_coherent; + } + /* if supported by the remote processor, enable the name service */ if (virtio_has_feature(vdev, VIRTIO_RPMSG_F_NS)) { vch = kzalloc(sizeof(*vch), GFP_KERNEL); if (!vch) { err = -ENOMEM; - goto free_coherent; + goto free_ctrldev; } /* Link the channel to our vrp */ @@ -915,7 +959,7 @@ static int rpmsg_probe(struct virtio_device *vdev) err = rpmsg_ns_register_device(rpdev_ns); if (err) - goto free_coherent; + goto free_vch; } /* @@ -939,8 +983,11 @@ static int rpmsg_probe(struct virtio_device *vdev) return 0; -free_coherent: +free_vch: kfree(vch); +free_ctrldev: + rpmsg_virtio_del_ctrl_dev(rpdev_ctrl); +free_coherent: dma_free_coherent(vdev->dev.parent, total_buf_space, bufs_va, vrp->bufs_dma); vqs_del: From patchwork Fri Feb 19 11:14: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: 12095073 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,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 599D5C433E0 for ; Fri, 19 Feb 2021 11:20:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0920F64E67 for ; Fri, 19 Feb 2021 11:20:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbhBSLU0 (ORCPT ); Fri, 19 Feb 2021 06:20:26 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52826 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230419AbhBSLT4 (ORCPT ); Fri, 19 Feb 2021 06:19:56 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JBHiIN009043; Fri, 19 Feb 2021 12:19:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=5/5ztwEi6vNBYmfGVztdGKdMNwulPVy/4Aq1/ukOfu0=; b=ZfWBkXmjZU14ip43UPHZdBEbrBJiiV+6Om/sQkBRfULvQAK/LxA+J+3SaZJQt8rb9CaU 1VwA4ewNSwCESG3s8tySXHP4E5p0DDmGJ4Vr+GzFwDZqDtgpxOYaZXBCpdSyxqg2Smso 1Crqr4+V1GkE9k69Bmu3prTCQjvEZNJ8EB/P8X8UX5elM2rVsEJAcAgMkewGKtBktpah vcVDrAzbs05nLn7TbfAg0670IzfXZfkRct9Jm4eCHh/FE5X+6Ak8Ro1AQn0cm1XI5YRn aMnRpPRkby3TSP6DtpfSGZH7X3BUqP4g4jqmJujkXPm58GmU4fL4uLiySLaJ5N8XCwgD dQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p6hq5583-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:09 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BB99B10002A; Fri, 19 Feb 2021 12:19:08 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AD94B221760; Fri, 19 Feb 2021 12:19:08 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:19:08 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 12/16] rpmsg: ctrl: introduce RPMSG_CREATE_DEV_IOCTL Date: Fri, 19 Feb 2021 12:14:57 +0100 Message-ID: <20210219111501.14261-13-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_04:2021-02-18,2021-02-19 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-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 Fri Feb 19 11:14: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: 12095075 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,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 29AD3C433E6 for ; Fri, 19 Feb 2021 11:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBA7064EC4 for ; Fri, 19 Feb 2021 11:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbhBSLUa (ORCPT ); Fri, 19 Feb 2021 06:20:30 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11608 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230417AbhBSLT4 (ORCPT ); Fri, 19 Feb 2021 06:19:56 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JBGj2b016646; Fri, 19 Feb 2021 12:19:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=h8BuLQc6wA4LPMA6U4rmS0YJqMj4AsWKDTNSsFE26UI=; b=ud6971nua46E71EYJn31gu365Wv97tmg+PhXBfb6ZGrWmQLs2h4sYWXfqpgpPYoZYDqJ h+BUzkOGZDAMcFfk0u6ACHBwLYi5NOnk8VqsvJhub/Izvb26MOTOi3k5TBDhKzY8zfux o9gLUdaO6Q1hbD06NY+X3GbyaNt6elGyZKNlE6aJGgqHHliqIqm+2duBLmEW0rJZ8bh6 LKljJz2Qs8AVyVPpELL0R8NE6EBJlFXHw+bu+0avCuTcjxTK4+gRG22zks5OVyzs0rZ3 +vJO0DJ2jsiN2H21/cpRu5suwf7fPswCTH4DVWXgctic5Zv2uGm2uO3F01/KiJRmPkMu gg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sse3xhbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:10 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8E15A100034; Fri, 19 Feb 2021 12:19:09 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 80B9B221760; Fri, 19 Feb 2021 12:19:09 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:19:09 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 13/16] rpmsg: char: introduce __rpmsg_chrdev_create_eptdev function Date: Fri, 19 Feb 2021 12:14:58 +0100 Message-ID: <20210219111501.14261-14-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 Fri Feb 19 11:14: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: 12095077 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,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 4E29DC433E0 for ; Fri, 19 Feb 2021 11:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F148564EC0 for ; Fri, 19 Feb 2021 11:20:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbhBSLUn (ORCPT ); Fri, 19 Feb 2021 06:20:43 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:11642 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbhBSLT5 (ORCPT ); Fri, 19 Feb 2021 06:19:57 -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 11JBIKr3024229; Fri, 19 Feb 2021 12:19:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=npnCdg9P84ZC4R2qY5iUG26l9krhi70nLlkWTe/TIss=; b=zYiVq2tJSfgSXvjKPSOKHfuRDHFXsKkZwbfN8OSDlLykawsYFzSh7DaVw7fOkkm0RBjx S9NVgo4iE4PDv3zj0a7e0tg1qyVrJks6x39PHNW8BlgDWowS/yyr5DaAh906HF98HNMZ +0wlq6LKjho+LdpLolp7x1PoubR/Qpq589Zt4CFXSPJLF7Xxt0PBt8LwN3gJmL7bTp67 yToKaXgB1WbXlu/QKo/7SOzChP6icn3swU6+kCX8mxD34bl7GC/jbzbw8nQ7ezostVXL qfYLLhtJKvg0mNBiA+2BPZlAVWM4ZVuPoHu4PZDTVL++wEnkhyo1LIIcgIwMZIPmRcYe Ig== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sqadeyw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:10 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 75FC210002A; Fri, 19 Feb 2021 12:19:10 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 675EF221760; Fri, 19 Feb 2021 12:19:10 +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; Fri, 19 Feb 2021 12:19:10 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 14/16] rpmsg: char: introduce a RPMsg driver for the RPMsg char device Date: Fri, 19 Feb 2021 12:14:59 +0100 Message-ID: <20210219111501.14261-15-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 --- drivers/rpmsg/rpmsg_char.c | 65 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 66dcb8845d6c..c98b0e69679b 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,52 @@ 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; + + if (!rpdev->ept) + return -EINVAL; + + 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)) + 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; @@ -421,10 +469,23 @@ static int rpmsg_chrdev_init(void) rpmsg_class = class_create(THIS_MODULE, "rpmsg"); if (IS_ERR(rpmsg_class)) { pr_err("failed to create rpmsg class\n"); - unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); - return PTR_ERR(rpmsg_class); + ret = PTR_ERR(rpmsg_class); + goto free_region; } + ret = register_rpmsg_driver(&rpmsg_chrdev_driver); + if (ret < 0) { + pr_err("rpmsg: failed to register rpmsg raw 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 Fri Feb 19 11:15: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: 12095079 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,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 9268BC433DB for ; Fri, 19 Feb 2021 11:21:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FB8C64EC4 for ; Fri, 19 Feb 2021 11:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbhBSLU4 (ORCPT ); Fri, 19 Feb 2021 06:20:56 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58279 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbhBSLT5 (ORCPT ); Fri, 19 Feb 2021 06:19:57 -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 11JBILXl024274; Fri, 19 Feb 2021 12:19:11 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=vvNAyI9ruMSPKPHLlkuNsluMR8Afys++5OiV9+LgOgg=; b=UZ73H0lOyhNxPzMHFJIGTNr0iv0hHMWbojSCd66muagxu9omG7Zp4Y/DyyoIaazgsA83 KrpKmWVKEAWE+m12OE2zxaNTFB7D3TtGaqnnupIhy2WC1iPy7Eyp0Ry/2Y8zAoLcB0L5 M79kQOmRCQnt6T4l/GtLZKvUf4KZ89eOhwTde9ovxNkeupHssb5qg6HC3uh7qPAbdpuR EH+G4WS0SNeKJKnCnIL8HyiPbh5K7k6vr8c7OQ8jyoeSi7xwcUOC2qmT1XzeFz1PVUM5 dUbGs1ZQzijCtlxQaema0WIhfi+hXtmDyHvIXgoXNRogElZhoWs6I0zuj3aknowRt4nR Hg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sqadeywc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:11 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3AD49100034; Fri, 19 Feb 2021 12:19:11 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2D054221760; Fri, 19 Feb 2021 12:19:11 +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; Fri, 19 Feb 2021 12:19:10 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 15/16] rpmsg: char: no dynamic endpoint management for the default one Date: Fri, 19 Feb 2021 12:15:00 +0100 Message-ID: <20210219111501.14261-16-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] 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-19_04:2021-02-18,2021-02-19 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 c98b0e69679b..8d3f9d6c20ad 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 RPMsg 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 Fri Feb 19 11:15: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: 12095081 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,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 1CF35C433E6 for ; Fri, 19 Feb 2021 11:21:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCA0564EC4 for ; Fri, 19 Feb 2021 11:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbhBSLVK (ORCPT ); Fri, 19 Feb 2021 06:21:10 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58216 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbhBSLT6 (ORCPT ); Fri, 19 Feb 2021 06:19:58 -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 11JBGJ77030425; Fri, 19 Feb 2021 12:19:12 +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=wGwoKvrJtrrbxP1r0sguXRpKiD1qux0aLuHD61EaIT8=; b=orAiuPhFbVUnDVPQabeWm2vaA+hsIA/beNuc7AP73vJPn3Jv9mZde6U9LnqBmYqnl+eR X1yrBgOz8aX9+CjrO9vuke4gygIQ4189sQzsv2bCnlL6qg1vgKr5i5Q6PcJCf2xKcuYn KsGVdcY2y5LxmlzJ2BGGxsN8OWWxzqJqUufpsUZctdMIOhAp2m7f45cHJTHMo2u4oVBl Psdk5ian+2zglQIbIt0hDuxTi3xGwlcT9m503uNzwgKy7SHITbDEptN//NJRVTDezPjT r+chVxgaY2d6toXx6KLdZd2kYPrXKJPKpNI0oDSQ9Hw5NW2iqwQvatcnMBZfAxw7CawK Pw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p7072t39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:12 +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 F333810002A; Fri, 19 Feb 2021 12:19:11 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E64C5221760; Fri, 19 Feb 2021 12:19:11 +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; Fri, 19 Feb 2021 12:19:11 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 16/16] rpmsg: char: return an error if device already open Date: Fri, 19 Feb 2021 12:15:01 +0100 Message-ID: <20210219111501.14261-17-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 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-19_04:2021-02-18,2021-02-19 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 8d3f9d6c20ad..4cd5b79559f0 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); /*