Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp508614pxb; Thu, 14 Jan 2021 11:09:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOEJT2ZCinR5dZkYQ0Viil/2MbiIeJMdA1phmUhAoccex581JrwLFDdOMs33QVogVF0XQH X-Received: by 2002:a17:906:bfcc:: with SMTP id us12mr6216615ejb.163.1610651358910; Thu, 14 Jan 2021 11:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610651358; cv=none; d=google.com; s=arc-20160816; b=KFdhL0lIWf0UnyhVMCva9Yx/d+FXtvU3lO9bNDEemyV0dMTcVu2qcKdilZjkDmSW4C 4QvYNETj/XQswQZ3ljANEXOv5ac/xHtGm94cH7+lTjTChGhyHvLglYHVVMI3Is0UJ2wV P1NMet0C1nBHqh5cCM1QkI3JKqjxbmFFF5umn8Yj+NLgpSlSacJuY9DwPGiKS9g5RUCm jc8bdhiPMS+rEBuDdCVeWVdfR3cDGDvykqizh77jD3Y/D6ubpT5zGmc5DMmSOj/g4gtO I9/wIFN65StWeW6upHE0iiNOcz9W/85JIXdXKTzzqcTJoqDZKQNas+NrHbVldq44GHN7 Cq3A== 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=9eQpCXhKjCHwg9nJ0ZvUFOOkfeOuaFDT4T5heWosDRk=; b=0uY8/XDONXJ35pmaGiCo5/B9jSgJ3wstO8fEWJLEl3waLG8h1ruUeCZ1pAFs+PGeSi LbpjlLjGk/kC+n4JBMt+AB5ZcmR5lkGotIKwsZrHxKDa/hHUKAwY9CQrnuLBuyyMp9oC 9ILbrytMWgFTux5QLUVO64g0xBsfVzQw88si/6PHuCtL1keS3RSg64ptAyfqotlzK49E iZsm8mxs3rsFfaG0+ZMRalOUWNxVrKPG6/opeHHC20p2nq6VW3KIld2RSNjezOhUKVnB 6o2VZOZhyUWnBKDmQOsVHSsWSzbej3L8QSSSiDNcKL7KBy+xXXRV4+7zk0cXj153jd5L rCKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sqRjubUV; 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 30si3002349edq.533.2021.01.14.11.08.54; Thu, 14 Jan 2021 11:09:18 -0800 (PST) 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=sqRjubUV; 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 S1729282AbhANTG1 (ORCPT + 99 others); Thu, 14 Jan 2021 14:06:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbhANTG0 (ORCPT ); Thu, 14 Jan 2021 14:06:26 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53E54C061757 for ; Thu, 14 Jan 2021 11:05:46 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id c13so3891198pfi.12 for ; Thu, 14 Jan 2021 11:05:46 -0800 (PST) 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=9eQpCXhKjCHwg9nJ0ZvUFOOkfeOuaFDT4T5heWosDRk=; b=sqRjubUVFoI42sWF35FLYlG5wrhrTfG4ofY/KnCDSFr1CiweQKiYdOu+Y2g9Vkw1rB j7tJuC9H85ZI5gZGIIU0Mm0pdWrGni6WCcHB+VdhE2tw5zihK4JpZc3CFOZm2UWTUwvo DmYW8eIXE2s2a1Yhi6JaR5ZYDO5ykeGGQ+0I48muB+KYO1rEim4vfFR2jkcg7RhjsKYI LDIM4WFj0a5rXDo0jXymb8cAGEzd9ffnhKW/U0FletCAqcqQyh4QfZEHGvJHPBGpsjB+ pH+8We+T8OTCPqxvCCpb/DQ+Tzf5JXWQm7T8FBKtW0opDpEhrvqXH3Keaf09io5M3uVK YLag== 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=9eQpCXhKjCHwg9nJ0ZvUFOOkfeOuaFDT4T5heWosDRk=; b=uBjJWadP6PjfWO6h8yoRd1TU8Fcj2WVHWu6BQPugytglIJsCUqk4eysBLTmO08NJ2o MLmwAKocQC5GQ33kmEuJcN2Vgli7JlCXBR2DLcDJmHXdrFAkJW8REAKcxoppqrZFVzN0 6j96NYaR+89ZuLZ7/kZH+YSIL0N3prKTExza5GwM33kmRAlNpywh4Grqdh0b+c+yPEDW YBry+fbxEB8VsfNZ1nmdVPYMvVe+/KcyRInp33g0Nh3Jid7jzwV947VXR0ehBC+OPA7/ NcV9KBsfHvCKa0yHgxrrVxfSQKoKFB+kzu5RN3yDgcWS9S9yWohAwicWUxqlovTVlteZ izGQ== X-Gm-Message-State: AOAM531Ms2inhaYhDCvktVoptg2PzM6tehv2chOCQ4gBqZaLxQEJIDG7 Id2bfiWjJhkFI66753eJdUQ2DA== X-Received: by 2002:a63:7904:: with SMTP id u4mr8851614pgc.41.1610651145903; Thu, 14 Jan 2021 11:05:45 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id g30sm5504881pfr.152.2021.01.14.11.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 11:05:45 -0800 (PST) Date: Thu, 14 Jan 2021 12:05:43 -0700 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] rpmsg: char: return an error if device already open Message-ID: <20210114190543.GB255481@xps15> References: <20210106133714.9984-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210106133714.9984-1-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 06, 2021 at 02:37:14PM +0100, Arnaud Pouliquen wrote: > 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. > The fix consists in returning -EBUSY when device is already > opened. > > Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface") > 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 4bbbacdbf3bb..360a1ab0a9c4 100644 > --- a/drivers/rpmsg/rpmsg_char.c > +++ b/drivers/rpmsg/rpmsg_char.c > @@ -127,6 +127,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) > struct rpmsg_device *rpdev = eptdev->rpdev; > struct device *dev = &eptdev->dev; > > + if (eptdev->ept) > + return -EBUSY; > + I rarely had to work so hard to review a 2 line patch... As far as I can tell the actual code is doing the right thing. If user space is trying to open the same eptdev more than once function rpmsg_create_ept() should complain and the operation denied, wich is what the current code is doing. There is currently two customers for this API - SMD and GLINK. The SMD code is quite clear that if the channel is already open, the operation will be denied [1]. The GLINK code isn't as clear but the fact that it returns NULL on error conditions [2] is a good indication that things are working the same way. What kind of use case are you looking to address? Is there any way you can use rpdev->ops->create_ept() as it is currently done? Thanks, Mathieu [1]. https://elixir.bootlin.com/linux/v5.11-rc3/source/drivers/rpmsg/qcom_smd.c#L920 [2]. https://elixir.bootlin.com/linux/v5.11-rc3/source/drivers/rpmsg/qcom_glink_native.c#L1149 > get_device(dev); > > ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); > -- > 2.17.1 >