Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp358376imm; Wed, 3 Oct 2018 17:55:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VaGwCX/ZP9BZKIqh7mG9KfWYGWr1cldow/baF1PAWpPl39JGCJnCicuotl1gZ2xnhEkWU X-Received: by 2002:a17:902:b287:: with SMTP id u7-v6mr4039196plr.123.1538614535858; Wed, 03 Oct 2018 17:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538614535; cv=none; d=google.com; s=arc-20160816; b=eArvsd99yqWm4v3HiweqRa59svEP9Sj/DoSE5IzU8snobiLyeHSfFwBb5EALsklgYn RpCx8ik7T4qTo+hkisJbH04Ps7Pt65BbzmJfxAog2pEiyzxBZzeKt6yi8DBIHRWqBszZ lLu9Oz4Nbh+8UFwraL/zYvfnAXDUR+1xZ4Yzv/uvvBGEyBq3jNw/qDAV7E8Bkevw70dh NarNav8IaPjw/xOShxTUwoptkKrC+zyzKqOf2SbvVuAhL5322epweNhLHBrGFoBeg2j1 aqeOusyG3pHcshKpU2MJKRpiQEq0xcTd5ytfplSjxmpUEN4Tueg3wHABR/IzHjJQvAoS zWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ABMhAV/wQYAX7YsQXcF6ItaCBUorFc3bFz1Cdfn2xk0=; b=B95tOHg/294kVajO/1eWzswoKn7r4o9b9lR5r4rEXTExDR99No+eIY1ddfYtpaODy9 ISUCJD9VPspNeqAZtS50QPFq9SmiEUTOgdfihZjJpexAFGE7Byk6X8elKAaSJIve0ODJ PyWGm8ugTBcFDtHlzh79u3c0v0QVRdfy4nbZ4XgKsM2IU4uU7EIyXQvyt4VeuEV9sto5 zfXd6BMe2v2+0+ebyLCKcUYlEOW3CcnE+RwrOp77KgPWOoIEf3POz0x23uelstXNZGg4 eJsmF1F5J8QODMWZIEWoKPjMtsu9UrNa6LMHfgqyzhywV9SuazHjKyne4OJz1H4L+OVg 2GVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DYaz8iY5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si3269899pll.171.2018.10.03.17.54.51; Wed, 03 Oct 2018 17:55:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DYaz8iY5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727203AbeJDHpX (ORCPT + 99 others); Thu, 4 Oct 2018 03:45:23 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35846 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726209AbeJDHpX (ORCPT ); Thu, 4 Oct 2018 03:45:23 -0400 Received: by mail-pf1-f195.google.com with SMTP id b7-v6so2500129pfo.3 for ; Wed, 03 Oct 2018 17:54:36 -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:user-agent; bh=ABMhAV/wQYAX7YsQXcF6ItaCBUorFc3bFz1Cdfn2xk0=; b=DYaz8iY5Oh48w5HAxrgCKYHVOrOj5pw2nXHPXv+vmUZcgityBpYbbbotsTjwEAhJSB lMt+Spmoh9Vs7i0/K/dCCtdS9kHXX/V2Tt1eAUEKTeoFfKzz//LCnF76j9YgD137bFj4 r/6CXle/D6eaTG71rT78PY9FPJAe5o1YScEX8= 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:user-agent; bh=ABMhAV/wQYAX7YsQXcF6ItaCBUorFc3bFz1Cdfn2xk0=; b=GyYmTYNyrShfxVGVuoyfeJUqZMWVuNvhmLd6ZCAtInM/w6CtnoMVEpD3VSlMOGARnU alKdePLrEeYJSMOb6bE3Jj2Ee6wQ+LfB27IivbSOyZS8rZVwyLw1nA36iSRmCQ23ZtKu J7teSmsdQvCPYxd274TFyT+LqopS5twCJtjMvdairJtXl8/WNMmAbObRP9a99Q9o9PWW GPnnjvIqYFsyBR7Ki0Vk+RDMkqh8yj8GSsS5XFMXeOuP+tVeIKdSFcgaG64wU5jA2X7a qDkaqpFHYQiNHjyIDc2BF9Jb/Img4k6CCwQtJ1FPtuYteEyqAOXDKyLD6is1cCbN/G6A r+4Q== X-Gm-Message-State: ABuFfoi2B7wy06pFU4RtGE1yS9eDIKL+Ea0TSEmPb2jjHkq+GOfz8TEw MTTK1JDpu11+ShiLYuSNPEQxSYuGOoep9g== X-Received: by 2002:a63:904a:: with SMTP id a71-v6mr3653236pge.264.1538614476221; Wed, 03 Oct 2018 17:54:36 -0700 (PDT) Received: from minitux (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id s195-v6sm5533336pgs.76.2018.10.03.17.54.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 17:54:35 -0700 (PDT) Date: Wed, 3 Oct 2018 17:54:33 -0700 From: Bjorn Andersson To: Arun Kumar Neelakantam Cc: ohad@wizery.com, clew@codeaurora.org, sricharan@codeaurora.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] rpmsg: Add TIOCMGET/TIOCMSET ioctl support Message-ID: <20181004005433.GX2523@minitux> References: <1538566463-24627-1-git-send-email-aneela@codeaurora.org> <1538566463-24627-4-git-send-email-aneela@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1538566463-24627-4-git-send-email-aneela@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 03 Oct 04:34 PDT 2018, Arun Kumar Neelakantam wrote: > Add TICOMGET and TIOCMSET ioctl support for rpmsg char device nodes > to get/set the low level transport signals. > > Signed-off-by: Arun Kumar Neelakantam > --- > drivers/rpmsg/rpmsg_char.c | 54 +++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 51 insertions(+), 3 deletions(-) > > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c > index 86003d5..c983d6c 100644 > --- a/drivers/rpmsg/rpmsg_char.c > +++ b/drivers/rpmsg/rpmsg_char.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -274,15 +275,62 @@ static __poll_t rpmsg_eptdev_poll(struct file *filp, poll_table *wait) > return mask; > } > > +static int rpmsg_eptdev_tiocmset(struct file *fp, unsigned int cmd, > + unsigned long arg) Make arg type int __user * > +{ > + struct rpmsg_eptdev *eptdev = fp->private_data; > + u32 lsigs, rsigs, val; > + int ret; > + > + ret = get_user(val, (u32 *)arg); > + if (ret) > + return ret; > + > + ret = rpmsg_get_sigs(eptdev->ept, &lsigs, &rsigs); > + if (ret < 0) > + return ret; > + > + switch (cmd) { > + case TIOCMBIS: > + lsigs |= val; > + break; > + case TIOCMBIC: > + lsigs &= ~val; > + break; > + case TIOCMSET: > + lsigs = val; > + break; > + } > + > + ret = rpmsg_set_sigs(eptdev->ept, lsigs); This is racy, as the signals might change while we update them. Mimic tty_tiocmset() instead and make rpmsg_set_sigs() take a clear and set mask. And please do spell out rpmsg_set_signal() and rpmsg_get_signal(). > + return ret; return rpmsg_set_signals(); > +} > + > static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd, > unsigned long arg) > { > struct rpmsg_eptdev *eptdev = fp->private_data; > + u32 lsigs, rsigs; > + int ret; > > - if (cmd != RPMSG_DESTROY_EPT_IOCTL) > - return -EINVAL; > + switch (cmd) { > + case TIOCMGET: > + ret = rpmsg_get_sigs(eptdev->ept, &lsigs, &rsigs); > + if (!ret) > + ret = put_user(rsigs, (u32 *)arg); Cast to int __user * > + break; > + case TIOCMSET: > + case TIOCMBIS: > + case TIOCMBIC: > + ret = rpmsg_eptdev_tiocmset(fp, cmd, arg); > + break; > + case RPMSG_DESTROY_EPT_IOCTL: > + ret = rpmsg_eptdev_destroy(&eptdev->dev, NULL); > + default: > + ret = -EINVAL; > + } > > - return rpmsg_eptdev_destroy(&eptdev->dev, NULL); > + return ret; > } Regards, Bjorn