Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4179362pxj; Mon, 21 Jun 2021 15:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwKeOGTS2zA9lAEAHCpapg2Q0sEutzaBJehac0jEs7qBMhD5AE+IHMJn+/7AGeDpjtuJvA X-Received: by 2002:a92:cc4c:: with SMTP id t12mr380079ilq.201.1624315407635; Mon, 21 Jun 2021 15:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624315407; cv=none; d=google.com; s=arc-20160816; b=BCRIH0WnJvnmN4kkrAUY63jVvh2XoqztKwqHumDGhK7+sUBMIFq/8ER7quk5t4fb1P wAbv1C/1nPQ+LITMt0mfmVwtSJgB8WtuaaMsWKi3ybHGDfGSj1RpCiWlY+AVIUEOY1N1 jYM5oUWABz9vzeOjTlUdlLNDSRI2CrNZLfiRUBDsFodm2lCyVzanxW8OpPTobH2SCumo DYvg6JiYV8/4dAWKJcQw5QsnfHAKiH4AFCGGoEv2+J5xrRsDJ0I8dKu7mczYu60OEI9y s868vLLheaJC/z4AhmO7HoZtZWVhORu2WxqmuKbm8BDWENCJxLNwSqyAtRn782Q7hbFa hZEg== 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=JCTSVkIytk/Hp0iEchwMobckKs7yA/n0NMw1lar0mLg=; b=K2mM2FInun/brfjf2rSu30EIsgo7z6YLJASZwVAXHTuyIHszkLZtFN4Tzolk/qRktf JIXWV52tqYWBR7BYRBObdkf32TNiXkIGpYtAu8fEIUlVv0P5ghSCRxBGWDwzQunovmvY Z4Tx8HnxovS2Rfxqvm2ZnQylf3X2SbjddZN4vZS59jSnI68tmhZZbIzIWUCov57c9b1T /Z1wiWh7gUwVEK1XRRB4gE9cqWO83VA8qKl2UJ/3pAJmve9ktpHC6gjHwGpMrVEugrMf oguxdEbOT3C5od3Wx/vKrCXKdVTPS6jrObNp2mZaJ7xf14COX8CASQzZzKP51ZM7w8Fz qnBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=heKd2Clb; 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 y4si12311558jas.26.2021.06.21.15.43.15; Mon, 21 Jun 2021 15:43:27 -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=heKd2Clb; 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 S232112AbhFUWoz (ORCPT + 99 others); Mon, 21 Jun 2021 18:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhFUWoy (ORCPT ); Mon, 21 Jun 2021 18:44:54 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC062C061756 for ; Mon, 21 Jun 2021 15:42:38 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id y21so3510814plb.4 for ; Mon, 21 Jun 2021 15:42:38 -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=JCTSVkIytk/Hp0iEchwMobckKs7yA/n0NMw1lar0mLg=; b=heKd2ClbKCDXRwF6fkwDkcbMHXcQwPByNrGsZHf/mglW82+G95Qrwyq4r4Cka9FXsV mnvwlivYWR8kVKPhO+ZEAmnjtUGzXUkU+h9ZeqGyFviJCYhufhjWDHmELeFYxihn3eNk 5I4bZvf3TkcyzPJh6ULTc39PaYMgtSOtSPneodBxPNI1CzdaC5WxWGsSG+5xfZAGNsOF z4OWXGBBdcV4xgIs/tnNP1UYKljQwTPqn9DFg3181EqFU3W+I4HuMcREzxOy8HThTRbl c81JnLUqTlujjre6zKxFS5b//u4mvRzwMGax3pc0C0fWSnjJTttrIIUu3L1HvWw8Dhdd 8tTA== 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=JCTSVkIytk/Hp0iEchwMobckKs7yA/n0NMw1lar0mLg=; b=SxuHkjNL0sMju56XCyCXIJ1PN3pS47HNklKl8g2BCUbCqGY4owN+eS6CnMe5AWLCg8 Ycy2dJBNA5l3XpBeS/5ZdnPl0g7o4EY8TUXWDiWHBrQASipK6QC1oOtxV9zVDr/Zopb8 pPMlj77ihYpcLFv4K1wak8zlawPu6Smhaz3AgGicbvQs0SAcWZqdBRKXHT+AUnVavIJY 9X36fev6hLG8GjpTqr/+7VllRFCAC8VuhipfkWbPL6Huq98UVGUYxXFxzcVIvd7RW09+ 3HYFxV8pTC3vPzEOP3TIxRug7f/JoUVx0jHIMHNCd9lEa7aLYdo+6Xpg5Pck2D3ozZ5X sOaw== X-Gm-Message-State: AOAM532PV0hWU2OyIwc32zCRFtbL+vtERRIHOdcJUJlJo9oBIFTCARQr XwCOJtYieGjKBzWtp4zyQZA01w== X-Received: by 2002:a17:90a:1b25:: with SMTP id q34mr499846pjq.163.1624315358306; Mon, 21 Jun 2021 15:42:38 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c5sm4584329pfv.47.2021.06.21.15.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:42:37 -0700 (PDT) Date: Mon, 21 Jun 2021 16:42:35 -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 1/4] rpmsg: Introduce rpmsg_create_default_ept function Message-ID: <20210621224235.GB980846@p14s> References: <20210607173032.30133-1-arnaud.pouliquen@foss.st.com> <20210607173032.30133-2-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210607173032.30133-2-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 07, 2021 at 07:30:29PM +0200, Arnaud Pouliquen wrote: > The rpmsg devices can be probed without default endpoint. This function > provides the capability for rpmsg drivers to create a default endpoint > on runtime. > > For example, a driver might want the rpmsg core dispatcher to drop its > messages until it is ready to process them. In this case, the driver will > create the default endpoint when the conditions are met to process the > messages. > > Signed-off-by: Arnaud Pouliquen > --- > drivers/rpmsg/rpmsg_core.c | 51 ++++++++++++++++++++++++++++++++++++++ > include/linux/rpmsg.h | 14 +++++++++++ > 2 files changed, 65 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. > + * > + * 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. */ > + 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..ab034061722c 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,17 @@ 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, Please move this to the previous line to match the definition in the other arm of the #if. > + 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 >