Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13443270rwl; Wed, 4 Jan 2023 08:13:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXt5UD0S5g7V5zZKx9TNm1FmjR/MnBn0hoH5accFO845o0dkZ6Qtq6R9dkV91xqZQcky8n00 X-Received: by 2002:a05:6402:291a:b0:48b:c8de:9d1a with SMTP id ee26-20020a056402291a00b0048bc8de9d1amr13530262edb.37.1672848819716; Wed, 04 Jan 2023 08:13:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672848819; cv=none; d=google.com; s=arc-20160816; b=EvxDniyGU5JNWXQuklJnZ64yQc0+HNFU3FVQ4doJRJLHUBoZYTQBumWVgBtMHDyUWM 8EDDvcJRNZiHCKDdNK+Qs6qrfWlMVqGlG23ywnCMPNqcQxoFzU0bi8ZgYk8C88MmJKDt 9NxSnQexdKuX/Pvqtf31+FaGYPeFPZdUQq6NEI5L4jp7AvIQaP2sz5rKWvr6YsFqeH4L +cRPDtCuwItHxq/Zj9VCi4M9E9w4Qsh2ZT6WB0GvzdT3l1tGlQ6TMWSZgzPMUH1lBoCc esWxdoHenFckcN6vMAQiEenJjvFMPGBPkbez0s7Epymts4M9BLiLq7KqKXM1GgohXGG6 Qc3Q== 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=gAa41dO5JTsgJp0Hp3adnKAdM10Sw8Hk+IpD6kW/8Q8=; b=UbDdYGMzqn1SLULHCB7RWcpzgiTJ4hMWBPILzWmr0FKcNmzXhOoxRZufYBuRjabhrE C/h7lgEbJBgOxwZTdrRgrOGsEeF1bumocJsutPdee49vGoB7OuAAId8rG/r3g8TKrQCF 7X08tTonc92MgT/GTBiIQJ0oLkuzLy94YkC0GevqPKEYFHeRcBKPqE5QkVOJvRXmWWVD 81co6FrNfkVdtWdy2okbs3cJkvxkTHtoZxgxpposCMiu7atUTqLUK958upCrsW8U0Qkp uTS4e4E/69DX20myPgklRNxLxwucDZC5699t+ei8bUYujASx1lPcsWYvMC9pX7g9qvDu 2ohg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uqWdfQbv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a05640211cf00b0046abe52aca7si35911862edw.486.2023.01.04.08.13.25; Wed, 04 Jan 2023 08:13:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uqWdfQbv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235317AbjADQDl (ORCPT + 57 others); Wed, 4 Jan 2023 11:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235151AbjADQDi (ORCPT ); Wed, 4 Jan 2023 11:03:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3B0B86; Wed, 4 Jan 2023 08:03:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C6C5AB815C9; Wed, 4 Jan 2023 16:03:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B69C433D2; Wed, 4 Jan 2023 16:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672848214; bh=qwVm6Ey+pId0r7wPricoXhTqRlRKCe/YHgGXKdhvpjU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uqWdfQbvRSOxXRhuVMlJTNvvt0WYb25FBVMeIk2cde4zbaEhsbT5WoTdZLqY7HRTY k7mG9BQu5gHKhhtyGIY/deZmcT8B8HewKtl3U2CN12xLPOsnOp6Mqnq15MsnXEA+7g Xy0tXkDSsIEgbrYk30d1CjEk3Y4DmmF2qXttRHlIuSsRoPd9IuWHAo6VcnxmnMSGNH lbOhCPsba4FISM0vdZvkWV6pg8sGmXpon1gOrFfzV3MIHFNmpfPLLUeWcvOFFUiGp9 f/4tpm1REe52ZWvwbraRL1d0Ccwu/A8V4Aqf/YrT4j9Zy3a6YQm1QycNX30AgFvnNJ faLWT0jz4fXuA== Date: Wed, 4 Jan 2023 10:03:31 -0600 From: Bjorn Andersson To: Arnaud POULIQUEN Cc: Sarannya S , quic_bjorande@quicinc.com, swboyd@chromium.org, quic_clew@quicinc.com, mathieu.poirier@linaro.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Deepak Kumar Singh Subject: Re: [PATCH V4 3/3] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Message-ID: <20230104160331.w2sicwlqiygr42hl@builder.lan> References: <1670418258-11502-1-git-send-email-quic_sarannya@quicinc.com> <1670418258-11502-4-git-send-email-quic_sarannya@quicinc.com> <12f53ff1-a358-7129-c9ed-9b9fd7dad7e7@foss.st.com> <20221227155641.xlkel7uhk7jr4qru@builder.lan> <45444451-26e3-c203-bdeb-59170b6cc5ba@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45444451-26e3-c203-bdeb-59170b6cc5ba@foss.st.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 03, 2023 at 03:50:10PM +0100, Arnaud POULIQUEN wrote: > On 12/27/22 16:56, Bjorn Andersson wrote: > > On Wed, Dec 21, 2022 at 05:28:16PM +0100, Arnaud POULIQUEN wrote: > >> > >> > >> On 12/7/22 14:04, Sarannya S wrote: [..] > >>> struct rpmsg_eptdev *eptdev = fp->private_data; > >>> > >>> - if (cmd != RPMSG_DESTROY_EPT_IOCTL) > >>> - return -EINVAL; > >>> - > >>> - /* Don't allow to destroy a default endpoint. */ > >>> - if (eptdev->default_ept) > >>> - return -EINVAL; > >>> + bool set; > >>> + u32 val; > >>> + int ret; > >>> + > >>> + switch (cmd) { > >>> + case TIOCMGET: > >>> + eptdev->signals_pending = false; > >>> + ret = put_user(eptdev->remote_signals, (int __user *)arg); > >>> + break; > >>> + case TIOCMSET: > >>> + ret = get_user(val, (int __user *)arg); > >>> + if (ret) > >>> + break; > >>> + set = (val & (TIOCM_DTR | TIOCM_RTS)) ? true : false; > >>> + ret = rpmsg_set_flow_control(eptdev->ept, set, 0); > >>> + break; > >> > >> I still wonder if it makes sense to implement serial IOCTRL in rpmsg_char. > > > > I've thinking about this since v1 as well... > > > >> I think it is quite dangerous to have such kind of mixed interface. > >> User application would want to use the serial interface should use the tty > >> interface. > >> > > > > Can you please elaborate on this statement, because I have a hard time > > to state why the user space application must use the tty interface > > instead of rpmsg_char. > > > > And in particular, I don't think this is a question for the "user > > application", but rather for the system configuration. > > > > In order to move an application that works with rpmsg_char to the tty > > driver ("because it's the right thing to do..."?) means that the system > > needs to be reconfigured, such that the given rpmsg channel is exposed > > through the tty driver instead. > > > > This in turn either implies that the firmware needs to be changed to > > expose these channels with the name "rpmsg-tty" - and the application > > taught how to figure out which ttyRPMSGn to open - or the rpmsg_ctrl > > interface needs to be extended to allow the Linux side to request a > > particular channel to be exposed as rpmsg_char vs rpmsg-tty... > > > > You are right, it can be not straightforward to migrate to rpmsg_tty. That's why > it also makes sense to implement flow control in the rpmsg char. > > What I try to highlight is the use of the RS232 signaling(e.g TIOCM_DTR) and > TIOCMGET/TIOCMSE terminal IOCTL in this patch. > Please tell me if I wrong, but seems to me that such interface is dedicated to > the serial/TTY frameworks [1]. > So does it make sense to reuse this interface for the rpmsg char? > We're in understanding of the usefulness and the question about the validity of reusing the tty's TIOCM{GET,SET} ioctl here. I don't know the answer to the latter, and haven't pushed on this point. > [1]https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/ioctls.h#L8 > > Instead we could have generic RPMSG IOCTLs that can be implemented on different > rpmsg clients whatever the rpmsg channel (so not only the rpmsg char). This is > the proposal below. > Using a new pair of rpmsg_char ioctls for "set/get flow enable/disable" would, IMHO, be easier to understand and it would avoid assumptions inherited about all the other bits in the TIOCMSET ioctl. Regards, Bjorn > Regards, > Arnaud > > >> For the rpmsg char, I would be in favor of creating a specific RPMSG IOCTRLs > >> to avoid confusion. > >> > >> For instance: > >> > >> - RPMSG_GET_SIGN_IOCTRL > >> - RPMSG_SET_SIGN_IOCTRL > >> > > > > Again, we're talking "flow control" at this level. So either we follow > > the standard IOCTL and make it easy for existing applications to use > > rpmsg_char, or we provide a _good_ explanation why they must use the > > tty interface instead (and if so solve above mentioned problems). > > > > Regards, > > Bjorn > > > >> With associated parameter corresponding to the bitmap proposed in my comment of > >> your patch 1/4. > >> > >> Of course, this is only a suggestion, I let Bjorn and Mathieu comment. > >> > >> Regards, > >> Arnaud > >> > >> > >>> + case RPMSG_DESTROY_EPT_IOCTL: > >>> + /* Don't allow to destroy a default endpoint. */ > >>> + if (eptdev->default_ept) { > >>> + ret = -EINVAL; > >>> + break; > >>> + } > >>> + ret = rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL); > >>> + break; > >>> + default: > >>> + ret = -EINVAL; > >>> + } > >>> > >>> - return rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL); > >>> + return ret; > >>> } > >>> > >>> static const struct file_operations rpmsg_eptdev_fops = {