Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp14608pxv; Wed, 30 Jun 2021 13:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVZQoqUDtRm3wzioYyMZJRwZVYkcWDyeEwchVsDJLR3YP6RmumthaT/rByvLl3Yzof/TIw X-Received: by 2002:a05:6638:279:: with SMTP id x25mr10705111jaq.33.1625085668559; Wed, 30 Jun 2021 13:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625085668; cv=none; d=google.com; s=arc-20160816; b=v4urjsHPOMiQchmDMe4Gn5g+YgGoSv1NDK32g7EzF4aw8f+Q4LZAD1UyyZSP2tHsAr tFXT6UvJsXOy7CbgpHViVnqqqnIYmG/jRyV/AhNd/E2zt+DVFTxNrYXJdpBm6pkNu24q Xnk839YFR0zJTVRbv5aNhjygBxxXWxhEvzx4wI+YW/gpWOCOqQGCUwV++zv27b6GJ7Jr 1mJn95iu1MXyiFV2RBZYWB5QMrjWdAa2jgSLwGFyHlnFRz8KkWPL1pZzf3UI3FUnOWgh iLI6TLAtpHspESQKiHdMVwribOZn39p3cGSgJy0yO7NoLNDkRp8L7uhJY260vYo5cS7v Q1SA== 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=29U3jHG7Pp1+7u6Mh/ME/IzDFz5tOMaeoDOJAA5iyCc=; b=KinVEnruDMPkoPuWZZ4kFRUFus8qiHkUl/IVVNoRwRSAf3Ye+4aaFaDszcS3HCJ7zv 3I5LPKtbR5RiGLTZLrejpv0d94z9d8CJDFpmsYm3m8EnFVvCP4nXXHPy6xURdmvuu32n tb2/sOM4oeSIX7h8fTVXwNyo1zWpaVBSvJFPMwdhSploKXOIsOkZa5y3b9IjU6zDHMjD uHtdaoMxPQzA5fsxPJP89tixUvaouM+s4n40dqvNFvwdY7nOhoIfrxxIWaj3FTRN8pIr kIzSh0lNKvD9xV8VGJGXlQacXPxQP5GBtjgpKq6UfWC6Orvp0zqAMh61q94wib6UnWnP UPVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LATc6+sH; 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 x6si26706020ilv.59.2021.06.30.13.40.56; Wed, 30 Jun 2021 13:41:08 -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=LATc6+sH; 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 S234482AbhF3Uky (ORCPT + 99 others); Wed, 30 Jun 2021 16:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbhF3Ukx (ORCPT ); Wed, 30 Jun 2021 16:40:53 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE87CC061756 for ; Wed, 30 Jun 2021 13:38:24 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so5164023pjb.5 for ; Wed, 30 Jun 2021 13:38:24 -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=29U3jHG7Pp1+7u6Mh/ME/IzDFz5tOMaeoDOJAA5iyCc=; b=LATc6+sHrVVjNkZ/A2Q4iru8qz4SPu0DPaZ030h0AfrsZqQR7E2wruOhIi2/igoRmB VXUVgpAx9PqQLsTyGd0l2CJFMX8Wg7DQPOSv2eu9hN+0koZUW0EtnLYMUiVPH8yJwQvf kDUUB0NbFWHYyyozUlpGS4pkc2qUCxbUr5t1kjAsjyMPDHXy9iOnqCjQO/1xu0fWvnve CEmh7WZgu+FV8Lu/L7MN3DZrmrGKWe+80/2XYRHoDEPyZgb/faX3Z3qX3blBQ0XpTkUl EgOxN7sQ0E5DODJ/ZR5lmyASuI+Hk889QyJ5J2RJg8Jc9FRvx9qKOlcnHlGMghFfqS3G IcYg== 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=29U3jHG7Pp1+7u6Mh/ME/IzDFz5tOMaeoDOJAA5iyCc=; b=l6V2/JCF+RNX5USMzTxt/zdBO8cXx/kmBGat4rxPkfW2/ZMR483lX2tt+BcMDjkTDa 1wL/QLa8w6nivZcoyMncxBdj/pG9gg4dbQcrLoXL8baL7DAIP7Tx2C9AdqjolefrKO0u LKXGLHGNIh6Mjz3VMS56Hrur/KJYLD9UMCQcVE6jmpO5SUjervpC1WUzUXuwuolDrzuh xf6pbLpoyEEPJ6q4u8KJCPcMLnE1MbK3lFuAEF0sfY+TcKsENO21Yic1DjHZOHwc6Dcg Btb/fyp2kgvbrJ7iHoAUUZmvT0GuOXdkLNapFc54A0SMeDhRx+fUqwNdpqFtaRO9Ihv5 kJ8w== X-Gm-Message-State: AOAM530DUMCPUzywgiPo3y3xR977LJob+EHWTo/3bpVjmeT82OUQ+k/F CQhv1i8Q3gzTvwNddDD1+cLS5nleoyp5AQ== X-Received: by 2002:a17:902:a981:b029:116:a139:6054 with SMTP id bh1-20020a170902a981b0290116a1396054mr33649783plb.60.1625085504194; Wed, 30 Jun 2021 13:38:24 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id p10sm22283464pfn.147.2021.06.30.13.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 13:38:23 -0700 (PDT) Date: Wed, 30 Jun 2021 14:38:21 -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, julien.massot@iot.bzh Subject: Re: [PATCH v2 1/4] rpmsg: Introduce rpmsg_create_default_ept function Message-ID: <20210630203821.GA1290178@p14s> References: <20210623150504.14450-1-arnaud.pouliquen@foss.st.com> <20210623150504.14450-2-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210623150504.14450-2-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 05:05:01PM +0200, Arnaud Pouliquen wrote: > By providing a callback in the rpmsg_driver structure, the rpmsg devices > can be probed with a default endpoint created. > > In this case, it is not possible to associated to this endpoint private data > that could allow the driver to retrieve the context. > > This helper function allows rpmsg drivers to create a default endpoint > on runtime with an associated private context. > > For example, a driver might create a context structure on the probe and > want to provide that context as private data for the default rpmsg > callback. > > Signed-off-by: Arnaud Pouliquen > --- > > update from V1: > - Minor: alignement of the function parameter to have homogenous function declaration. > --- > > drivers/rpmsg/rpmsg_core.c | 51 ++++++++++++++++++++++++++++++++++++++ > include/linux/rpmsg.h | 13 ++++++++++ > 2 files changed, 64 insertions(+) > > diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c > index e5daee4f9373..07b680bda61f 100644 > --- a/drivers/rpmsg/rpmsg_core.c > +++ b/drivers/rpmsg/rpmsg_core.c > @@ -115,6 +115,57 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev, > } > EXPORT_SYMBOL(rpmsg_create_ept); > > +/** > + * rpmsg_create_default_ept() - create a default rpmsg_endpoint for a rpmsg device > + * @rpdev: rpmsg channel device > + * @cb: rx callback handler > + * @priv: private data for the driver's use > + * @chinfo: channel_info with the local rpmsg address to bind with @cb > + * > + * On register_rpmsg_driver if no callback is provided in the rpmsg_driver structure, > + * no endpoint is created when the device is probed by the rpmsg bus. > + * > + * This function returns a pointer to the default endpoint if already created or creates > + * a endpoint and assign it as the default endpoint of the rpmsg device. s/"a endpoint"/"an endpoint" > + * > + * Drivers should provide their @rpdev channel (so the new endpoint would belong > + * to the same remote processor their channel belongs to), an rx callback > + * function, an optional private data (which is provided back when the > + * rx callback is invoked), and an address they want to bind with the > + * callback. If @addr is RPMSG_ADDR_ANY, then rpmsg_create_ept will > + * dynamically assign them an available rpmsg address (drivers should have > + * a very good reason why not to always use RPMSG_ADDR_ANY here). > + * > + * Returns a pointer to the endpoint on success, or NULL on error. > + */ > +struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, > + rpmsg_rx_cb_t cb, void *priv, > + struct rpmsg_channel_info chinfo) > +{ > + struct rpmsg_endpoint *ept; > + > + if (WARN_ON(!rpdev)) > + return NULL; > + > + /* It does not make sense to create a default endpoint without a callback. */ s/"default endppoint"/"default endpoint" Reviewed-by: Mathieu Poirier > + if (!cb) > + return NULL; > + > + if (rpdev->ept) > + return rpdev->ept; > + > + ept = rpdev->ops->create_ept(rpdev, cb, priv, chinfo); > + if (!ept) > + return NULL; > + > + /* Assign the new endpoint as default endpoint */ > + rpdev->ept = ept; > + rpdev->src = ept->addr; > + > + return ept; > +} > +EXPORT_SYMBOL(rpmsg_create_default_ept); > + > /** > * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint > * @ept: endpoing to destroy > diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h > index d97dcd049f18..11f473834e86 100644 > --- a/include/linux/rpmsg.h > +++ b/include/linux/rpmsg.h > @@ -172,6 +172,9 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *); > struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, > rpmsg_rx_cb_t cb, void *priv, > struct rpmsg_channel_info chinfo); > +struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, > + rpmsg_rx_cb_t cb, void *priv, > + struct rpmsg_channel_info chinfo); > > int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); > int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); > @@ -234,6 +237,16 @@ static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev > return ERR_PTR(-ENXIO); > } > > +static inline struct rpmsg_endpoint *rpmsg_create_default_ept(struct rpmsg_device *rpdev, > + rpmsg_rx_cb_t cb, void *priv, > + struct rpmsg_channel_info chinfo) > +{ > + /* This shouldn't be possible */ > + WARN_ON(1); > + > + return NULL; > +} > + > static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) > { > /* This shouldn't be possible */ > -- > 2.17.1 >