Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp8038pxj; Fri, 7 May 2021 02:24:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpUglSzvuYiQ6ZIFRmYkIFbOoaLpPhE9edqkha0wozpWKXbuhir8HBNbKzrTQrP8AaGr7O X-Received: by 2002:a17:906:a20b:: with SMTP id r11mr9051012ejy.323.1620379460473; Fri, 07 May 2021 02:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620379460; cv=none; d=google.com; s=arc-20160816; b=hE9FfbDE3q1x3kAxfKn6k5M1hpYWwQCs80ezUkxewjSadqszogA07gpu5HXzYH6TK+ fA5ntB4L2gr6wHQgSwaxoZwcYhjADgkfSZ/5Fe2Lb2t0d0mqTv8+8s+KEiUDyUy3qLqN ltPgY3Q4N0Do0bhRo+9cu7WS7sVQixNkUAaGAaiFOOS/ZoKWMLDrRtTypGWdsvgpK/SN cB61zo1ca9vYo91KR6WoUWmDobQuZJoft56Zm6rxZXWb09aAtpmlYFDtVDl+LlhXCsq/ UuhTU3U+y7Mgso2LIeBYZbMIDsRiPG+aDRqsrFc9I8MAPkWDyEpLyQRdfOpljoUla35Z WI5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=vOiL5pdW+tmoprAzmKiGDKcT8zd1nbKFMEsR8wuMcZ4=; b=Vm9szz4WK23ZSgZbv0EfI5ZRfDfrrlyvO19ZO0GPg/I6zKeJPU5DuETFedXpsHiCwh uWeZAKixZ+Z9wxzXh9mFxg1lUXoaOOwGyUAon12H0bsZKvo8gBR3g1U0/ly2Wj7qnydQ vbdSv0bhia8wa0TIGtUqvKS4uoUYkAznq+z9Qp/mhmopUcWWsDSFJFhekQ89qAEujUxN g6EjtmySJJI5LgN+WmfeeTfXG5jy966UtrOZ+fEHNMgiPTWwroNYkCldnz0g5LZexlHX 2DAvhkG67j+b6p+BioWyiMaJJTHyW+4iikgONIfLn1LleT149o4NrAtaB/ZuRO5Kh/+W /knw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iot.bzh header.s=20180822 header.b=b67B7clE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=iot.bzh Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si5668957ede.2.2021.05.07.02.23.56; Fri, 07 May 2021 02:24:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@iot.bzh header.s=20180822 header.b=b67B7clE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=iot.bzh Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236093AbhEGI0M (ORCPT + 99 others); Fri, 7 May 2021 04:26:12 -0400 Received: from mail.iot.bzh ([51.75.236.24]:5167 "EHLO mail.iot.bzh" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233681AbhEGI0I (ORCPT ); Fri, 7 May 2021 04:26:08 -0400 X-Greylist: delayed 478 seconds by postgrey-1.27 at vger.kernel.org; Fri, 07 May 2021 04:26:07 EDT Received: from localhost.localdomain (lfbn-ren-1-2120-93.w92-167.abo.wanadoo.fr [92.167.199.93]) by mail.iot.bzh (Postfix) with ESMTPSA id 540E740081; Fri, 7 May 2021 10:17:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iot.bzh; s=20180822; t=1620375426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vOiL5pdW+tmoprAzmKiGDKcT8zd1nbKFMEsR8wuMcZ4=; b=b67B7clEPcGra/TVXtB6WSPhKHJINHZKOL/7vq1MudpY/sQhF20KzEuTJuJkNF8TckPE2k spgfXtNgc6phm0Veo3iAukOmLpyEJFBSY6ss8d29hH/eZ8P2SRGEWUYrks/CVRkLaAkmQS do5vKtX606hkdhCvyQIcfzGfGxfHBoUR6lBiPwR25r7/FiVw7SMqLg2+n9HKXznmCPuSu8 5COZHzxko+DHD2+BMuS/JAkRgB3rk7MBeB2pGd9Cxb8TCVtPlBfIs+L0nEwllfMAzWOmI7 GyUmhR6ycZoWVxSFxzqN5Hug7UFeFtJYreCPEIo+YyoIsjYwE4iwX19PKlrQJQ== Subject: Re: [PATCH v3 5/6] rpmsg: char: Introduce a rpmsg driver for the rpmsg char device To: Arnaud POULIQUEN , Mathieu Poirier Cc: Bjorn Andersson , Ohad Ben-Cohen , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com References: <20210429135507.8264-1-arnaud.pouliquen@foss.st.com> <20210429135507.8264-6-arnaud.pouliquen@foss.st.com> <20210505164159.GB1766375@xps15> <5a41e653-4d75-c5d5-a8e3-e247a50507f3@foss.st.com> From: Julien Massot Message-ID: Date: Fri, 7 May 2021 10:17:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <5a41e653-4d75-c5d5-a8e3-e247a50507f3@foss.st.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathieu, Arnaud, On 5/5/21 8:25 PM, Arnaud POULIQUEN wrote: > Hi Mathieu, > > On 5/5/21 6:41 PM, Mathieu Poirier wrote: >> Hi Arnaud, >> >> On Thu, Apr 29, 2021 at 03:55:06PM +0200, Arnaud Pouliquen wrote: >>> 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 >>> >>> --- >>> update from V1: >>> >>> - add missing unregister_rpmsg_driver call on module exit. >>> --- >>> drivers/rpmsg/rpmsg_char.c | 53 +++++++++++++++++++++++++++++++++++++- >>> 1 file changed, 52 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c >>> index 5c6a7da6e4d7..9166454c1310 100644 >>> --- a/drivers/rpmsg/rpmsg_char.c >>> +++ b/drivers/rpmsg/rpmsg_char.c >>> @@ -18,6 +18,8 @@ >>> >>> #include "rpmsg_char.h" >>> >>> +#define RPMSG_CHAR_DEVNAME "rpmsg-raw" >>> + >>> static dev_t rpmsg_major; >>> static struct class *rpmsg_class; >>> >>> @@ -413,6 +415,40 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent >>> } >>> EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); >>> >>> +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) >>> +{ >>> + struct rpmsg_channel_info chinfo; >>> + >>> + memcpy(chinfo.name, RPMSG_CHAR_DEVNAME, sizeof(RPMSG_CHAR_DEVNAME)); >>> + chinfo.src = rpdev->src; >>> + chinfo.dst = rpdev->dst; >>> + >>> + return __rpmsg_chrdev_eptdev_create(rpdev, &rpdev->dev, chinfo, true); >>> +} >>> + >>> +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, >>> + .drv = { >>> + .name = "rpmsg_chrdev", >>> + }, >>> +}; >> >> The sole purpose of doing this is to create instances of rpmsg_chrdevs from the >> name service - but is it really needed? Up to now and aside from GLINK and SMD, >> there asn't been other users of it so I'm wondering if it is worth going through >> all this trouble. > > It is a good point. > > Just as a reminder, the need of ST and, I assume, some other companies, is to > have a basic/generic communication channel to control a remote processor > application. > > Nothing generic exists today for a virtio transport based implementation. > Companies have to create their own driver. > > The purpose of my work is to allow our customer to use RPMsg without developing > a specific driver to control remote applications. > > The rpmsg_chrdev char is a good candidate for this. No protocol, just a simple > inter-processor link to send and receive data. The rpmsg_tty is another one. > > Focusing on the rpmsg_chrdev: > We did a part of the work with the first patch set that would be in 5.13. > But is it simple to use it for virtio transport based platforms? > If we don't implement the NS announcement support in rpmsg_chrdev, using > rpmsg_chrdev for a user application seems rather tricky. > How to instantiate the communication? > The application will probably has to scan the /sys/bus/rpmsg/devices/ folder to > determine the services and associated remote address. > > I don't think the QCOM drivers have the same problem because they seems to > initiate the communication and work directly with the RPMsg endpoints ( new > channel creation on endpoint creation) while Virtio works with the RPMsg channel. > > By introducing the ability to instantiate rpmsg_chrdevs through the NS > announcement, we make this easy for applications to use. > > And without rpmsg_chrdevs instantiation, It also means that we can't create an > RPMsg channel for the rpmsg_chrdevs using a new RPMSG_CREATE_DEV_IOCTL control, > right? > > That said, If we consider that the aim was only to extract the rpmsg_ctrl part, > I'm not against leaving the rpmsg_char in this state and switching to the > rpmsg_tty driver upstream including the work on the rpmsg_ctrl to create rpmsg > channels. > > We could come back on this if requested by someone else. I'm personnaly following this thread, our project is to be able to do RPC call from Linux to an RTOS (Zephyr). Our plan is to do that in userspace using the nameservice announcement from virtio/rpmsg. We did an hackish patch to do that internally: https://github.com/iotbzh/meta-rcar-zephyr/blob/master/recipes-kernel/linux/linux-renesas/0001-Add-device-driver-for-rcar-r7- rpmsg.patch That we will be really happy to drop by any cleaner solution. Thanks for your work ! Julien