Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp383400pxj; Fri, 7 May 2021 10:39:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvEzBGxYAcgzlQ8Yx6WdB9iUwSESltvS6QlSObE+LT4mm2zcEkLeofGb0t/FmdQAwMDCr+ X-Received: by 2002:a50:fd0f:: with SMTP id i15mr2988504eds.278.1620409146710; Fri, 07 May 2021 10:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620409146; cv=none; d=google.com; s=arc-20160816; b=V4V+FtLBcQTYKb2HwYEERMNu0CtvC716aY6eM7bEpM0AsReVXN1scvEB4Va7rTYAOK KhXQPd6BvR3zc4H8TV8EBRcx4paoW1hqK+GHxQuctx0hajkEqS5Q2C9w5cJxInfZcbMa iKAg9tUa0QOxTVnwTNQFQMh4yl8NKgaZIy6ywywoiSR8QpfTjFk6NlkECNEWz1p+/Mz6 FdX+NDSWWBsgAFG86zCRP08lkZHsS3/A+P2e5uuFo0Z97ziBGeKxgG/NulPF96F2Jdsu SbAu0LnuDw2iuNGnJdYzZfA3OsbdlpF/iwK1t9mVxHwF4gN51vvA6BIWN66eIv4ejtqW tvtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HxZXfF2As+eDvZX4IPOHpLk+onOyi+bLU1+HvtvNhj0=; b=rktUnbRP8UZxX5U3E3Q2uAOMeNlEGwAk7OFKQtZMw4hjsAQaJLEOLdAX9yB2+4nczD S4Oivg3zFCLA7hOKmPrAxcFLz4TCYJ+YS1FyTpsl47yS87IUubd8KY+LkAfrXOesTIw7 vHUQjK4aTvp8Y7gZQbK++v1BLPksPpFLSZmIKgJovLWhRCbInYwlOZmFdF0DO5XLYBHS 6X6BNmhVMiR74qyPiJjyoTn9Ez55GvnoKhZ8vbGA8TYqIYKEnfgR36AlIEdLqDCLQ22x +A+Ar7E+5G7WUmCQtm9Sqpe4/vNT4no89KC85irsVFP6Yfj5yANF0AEUCPaGiDvKHXV4 6/Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c85kcT42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qo11si5677775ejb.530.2021.05.07.10.38.41; Fri, 07 May 2021 10:39:06 -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=@linaro.org header.s=google header.b=c85kcT42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238211AbhEGQcY (ORCPT + 99 others); Fri, 7 May 2021 12:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238201AbhEGQcR (ORCPT ); Fri, 7 May 2021 12:32:17 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B743BC061574 for ; Fri, 7 May 2021 09:31:16 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id x7-20020a17090a5307b02901589d39576eso2889610pjh.0 for ; Fri, 07 May 2021 09:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HxZXfF2As+eDvZX4IPOHpLk+onOyi+bLU1+HvtvNhj0=; b=c85kcT421OS8ZWNi6vChvzlN1WJFDqVwroT7W8LRD+ZLdqQ8JpTqkelkCuQl6LVfk4 fKs6GGwylzbo5swluZb+vbDX+nvkJac8ndigf3dmkq3Anmalc2+5MNBJ2hmXxTY+dyha I02axC2Ad6v8OOa33y/pcMygDCi7DMjJ4X9nKyHJ9tPYIKSXPBHc52P/EIqilaK0Y8mQ mJrO1NEdyUq4dMTJnpB+RSmhir0ricvyyDe5flxPlgk8Gl6BWOQ0dsmanudVR0Rsm2ax 2Xzllj65jc0YB/m8xHuJhdxiEuP9IpO4n/QtALMGCdCWo0RGk0vDWaqxVGEix78YxGIw k3iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HxZXfF2As+eDvZX4IPOHpLk+onOyi+bLU1+HvtvNhj0=; b=LbyDdjpfDR/KazcCk3PUEiYRqBQe91pJdzYe4vuDn4XeSqOE7nJpHHPtuiRruzzs8T dGOAHihtyvrZZrs8MacPe56/ROfnYOgx4usRoTItb9Zfb1L+bduKQilhO/rO51ZH4J1c /it2f5fkpHr0WCbaqDQkVWBeTVP0eL18mOSqsAZXrlR4TjKjSXd8Mo4fxODKcgPr978n LUjCxKJSeAzLZYQCxc3ckQ+ujex9KBvWOHn39lYVZA1lAGu6ljap7R38v1yWBBkrZ1KF v89DovmUfzJvJi5C5PyheRk+p3Jvq7ejK8GiwKzauC2smwcmoGEH2TApA5xNu+Uj88O0 wYQw== X-Gm-Message-State: AOAM530a21z3s2TpPobDrgnJK3ouyOFrs9gIxFxbL5OqWLk1yjFOyPkM 3Dn93yW7X1bqfF3v9Ie3h47OjTC50OpzHA== X-Received: by 2002:a17:90a:7605:: with SMTP id s5mr23289699pjk.166.1620405075931; Fri, 07 May 2021 09:31:15 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id b6sm4882069pjk.13.2021.05.07.09.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 09:31:15 -0700 (PDT) Date: Fri, 7 May 2021 10:31:13 -0600 From: Mathieu Poirier To: Arnaud POULIQUEN Cc: Bjorn Andersson , Ohad Ben-Cohen , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH v3 5/6] rpmsg: char: Introduce a rpmsg driver for the rpmsg char device Message-ID: <20210507163113.GA1907885@xps15> 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> <20210506161125.GA1804623@xps15> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Good morning, On Fri, May 07, 2021 at 11:30:30AM +0200, Arnaud POULIQUEN wrote: > Hi Mathieu, > > On 5/6/21 6:11 PM, Mathieu Poirier wrote: > > Good day, > > > > On Wed, May 05, 2021 at 08:25:24PM +0200, 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? > > > > Since we already have /dev/rpmsg_ctrlX user space can instantiate an > > using that interface, which is how things are done in the GLINK/SMD world. > > > > Wouldn't that cover the usecases you had in mind? > > I have in mind that to make RPMsg easy to use, we need a generic driver with a > basic user interface to send end receive data, that supports the NS announcement: > - remote side could instantiate it. > - an instantiation of the device by a Linux application generates a NS > announcement sent to the remote side (for instance to create a channel for debug > trace). > The communication using a rpmsg_chrdev should be happening in two different ways, i.e RPMSG_CREATE_EPT_IOCTL and RPMSG_CREATE_DEV_IOCTL (as you had in a previous patchset). From user space communication using a rpmsg_chrdev should be initiated in two different ways, i.e RPMSG_CREATE_EPT_IOCTL and RPMSG_CREATE_DEV_IOCTL (as you had in a previous patchset). Regarding RPMSG_CREATE_EPT_IOCTL, patches 1, 2 and 3 take care of the legacy compatibility and I am quite happy with that. In this case the driver works the same way regardless of the transport mechanism - virtio, GLINK or SMD. Then there is instantiation with RPMSG_CREATE_DEV_IOCTL. That creates a new channel (with endpoint) when coming from /dev/rpmsg_ctrlX. When we have that functionality we can make the rpmsg_chrdev available from the name service, making sure the end result is the same regardless of source of the request (remote processor or user space). I was under the impression that functionality would be part of an upcoming patchset. Unless I'm missing parts of the story, proceeding this way should cover all the requirements we talked about. > On the other side, the initial work requested by Bjorn seems to be reached: > de-correlate the control part to be able to reuse it for other rpmsg devices. > > I just have the feeling that we are stay in the middle of the road without the > patches 4,5 and 6 to have a first basic interface relying on RPMsg. > > > > > As you pointed out above rpmsg_chrdev should be light and simple - eliminating > > patches 4, 5 and 6 would yield that. > > > > My concern here is more about the complexity of using it by application, for > platforms that rely on virtio rpmsg transport. For instance applications need to > know the notion of local and remote RPMsg addressing. > > Based on your feeling, here is my proposition for next steps: > 1- resend a version a version with only patch 1,2 3 + the patch to clean-up the > #include in rpmsg_char > 2- switch back to the RPMsg TTY upstream. > 3- extend rpmsg_ctrl IOCTLs to allow instantiate RPMSG_TTY from Linux userland. > Introducing RPMSG_TTY makes sense if a serial controller is only accessible from the remote processor. On the flip side it is an overkill if we just want a raw message passing mechanism. For that the rpmsg_chrdev driver, with the above extention, should be used. > > Then, we can come back to patches 4, 5 and 6 depending on the feedback from the > users. > > Does this proposition would be OK for you? > > Thanks, > Arnaud > > > >> 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. > >> > >> Thanks, > >> Arnaud > >> > >>> > >>> As such I suggest we don't go out of our way to expose rpmsg_chrdevs to the name > >>> service. That way patches 4, 5 and 6 of this set can be dropped. > >>> > >>> Thanks, > >>> Mathieu > >>> > >>>> + > >>>> static int rpmsg_chrdev_init(void) > >>>> { > >>>> int ret; > >>>> @@ -427,15 +463,30 @@ static int rpmsg_chrdev_init(void) > >>>> if (IS_ERR(rpmsg_class)) { > >>>> pr_err("failed to create rpmsg class\n"); > >>>> unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); > >>>> - return PTR_ERR(rpmsg_class); > >>>> + ret = PTR_ERR(rpmsg_class); > >>>> + goto free_region; > >>>> + } > >>>> + > >>>> + ret = register_rpmsg_driver(&rpmsg_chrdev_driver); > >>>> + if (ret < 0) { > >>>> + pr_err("rpmsg: 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); > >>>> > >>>> static void rpmsg_chrdev_exit(void) > >>>> { > >>>> + unregister_rpmsg_driver(&rpmsg_chrdev_driver); > >>>> class_destroy(rpmsg_class); > >>>> unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); > >>>> } > >>>> -- > >>>> 2.17.1 > >>>>