Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4842093ybc; Fri, 15 Nov 2019 10:57:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwNyD456yfF59a+gCskl50O26vt0RJPKnKb5BGgB86qjrE+8H8FDJ6dnh4GEOMVad5wsHvV X-Received: by 2002:a1c:3d08:: with SMTP id k8mr15505152wma.119.1573844234111; Fri, 15 Nov 2019 10:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573844234; cv=none; d=google.com; s=arc-20160816; b=tnRf3zeoPuyIV4SDiCkyzwcRrOMbhARqLimsNDBNXLHXJaXlDGB4n34hwKzr5BSV2f dh4+QnJP2nFzWDKa4oFLQpsJq5blhfPQWlX02UzWuAWRbJB+xOy6u8FkKTEwoq6QPZzE Dq6UvhKH5UE9PDEo+J5w2u/O4gtqdl5wUVQBg5AYcMVMWYXGo1k8K2NcJDsFY85QlUlV XcbfVf2t53dwMMGxoM1KzNuez7za1LoyhS8fknBRung+Bhyx8tq7F+WgHhS3mpgdEkcr 36p1Bc43SWpnLdzcNVXYGChBU9QIG/ccpJFoDFfs3nGsWdBxzIpGC7pLOWoAzRXaNxBu MTyw== 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=5/DV9l5vjoy566bD7j+28Px5X64vcSjdjpGgZ+iBNys=; b=km11jnzj1vDJP0p64dkKb6uhuKgBBIk2riIH6BGv8jWQ6UVt8Url1IOVs3pNImeISX 2I7w8+Njl9YoLAAUN6OaQV6sfUWqVGoG/R85tIKLV84MDzfV4+xBwdOMbSBkfWA1KD7W 8NiwqOhy+FkeZD38SffpIdNlv6q57O0U712lIcrvO1pRa9NlAEmmmNRUpAGn5hB6B1oD VTj7ZTnQvqoWT7q6hMj8mPjEWzmJRpd/ndSwtDtAmVn7SwtX9LgSBYWcjoCrSPCpgoIE CZjqPudy1T2mxlsDCeQ24h2zuEH4wCta7O3mMieZ3jgx0sgeQnwiPxhZjqBNUflgxIw9 C2DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H/KXp98I"; 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 z16si7252268edd.314.2019.11.15.10.56.48; Fri, 15 Nov 2019 10:57:14 -0800 (PST) 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="H/KXp98I"; 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 S1726632AbfKOSzx (ORCPT + 99 others); Fri, 15 Nov 2019 13:55:53 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37335 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfKOSzx (ORCPT ); Fri, 15 Nov 2019 13:55:53 -0500 Received: by mail-pf1-f196.google.com with SMTP id p24so7118040pfn.4 for ; Fri, 15 Nov 2019 10:55:53 -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:user-agent; bh=5/DV9l5vjoy566bD7j+28Px5X64vcSjdjpGgZ+iBNys=; b=H/KXp98I7VNkHc8aGry+k4qMOXigEvqS5f48d8OiOYilQ4J2JwVhl6GgokzI6hyV62 XWkMKULwF03dKbwXHrV25fcvG4pFGGEMexDLJ+Yh3PK+hdPhnERKyqc4g3AzSJ3SGCJZ OyCkTZIxlmqlvqF1t+Fnyrlxhd1HP2fIBp/M5NcGjSuffzdMZKMyUk70LicNWBtTC9KY I3uBGnreTlwa5iuUJWIJvLlCr5Mbzk9WqyHIHjlGMetRB/9asxXqYDEDtQTGCPZIDZNb QWoUp0LtC4qbXAZ+ZD7roicUqYHW05JcJu8W8RRz9Xo7s6emVbzQ9YdMKkWyU+qHPNTs Oc1w== 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=5/DV9l5vjoy566bD7j+28Px5X64vcSjdjpGgZ+iBNys=; b=WYlXtBEuwG+Hw5tW/rAhGs74TBHPXqTqkc6jlikDMtgg8clQLwfi+c7c9NJK9TF9pY RvOd9kXoTM9RjG/5XDoeBHWMP6tU/hI6xlcdug632md9kuMFJPNsPpiw+JYkJVQOddIG fHnYqy631jZ43CrorakYfsPC1ataEles2v5KV1U8LETHzObwgP8USxWzUEiwsd2F1PaF eQDOHB/nRuNMZSMsMtPVlL2yzIjOWOLtpWWyvWAd7yrqAl8I9BhrNFkzv2ezLFqoRaVU 8j8Q6eaa4futT2F6sAT1JVhz9HOqotj7FPWU1ja0PJo+P0E9Vg5WBPlQmIaT3A+/pDyw kTOw== X-Gm-Message-State: APjAAAWyKDyYRyyhVDNXjxUujQON1FIhGs+liD8qyj/BGlt8UcRUAYTI Exuyzz1+sF+tLE+YArcgHgcMgQ== X-Received: by 2002:a63:d70e:: with SMTP id d14mr17742459pgg.10.1573844152375; Fri, 15 Nov 2019 10:55:52 -0800 (PST) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id l62sm10835645pgl.24.2019.11.15.10.55.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2019 10:55:51 -0800 (PST) Date: Fri, 15 Nov 2019 11:55:49 -0700 From: Mathieu Poirier To: Fabien Dessenne Cc: Maxime Coquelin , Alexandre Torgue , Ohad Ben-Cohen , Bjorn Andersson , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, Arnaud Pouliquen , Loic Pallardy Subject: Re: [PATCH v4] remoteproc: stm32: fix probe error case Message-ID: <20191115185549.GA17332@xps15> References: <1573812188-19842-1-git-send-email-fabien.dessenne@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1573812188-19842-1-git-send-email-fabien.dessenne@st.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Fabien, On Fri, Nov 15, 2019 at 11:03:08AM +0100, Fabien Dessenne wrote: > If the rproc driver is probed before the mailbox driver and if the rproc > Device Tree node has some mailbox properties, the rproc driver probe > shall be deferred instead of being probed without mailbox support. > > Signed-off-by: Fabien Dessenne > --- > Changes since v3: on error, free mailboxes from stm32_rproc_request_mbox() > Changes since v2: free other requested mailboxes after one request fails > Changes since v1: test IS_ERR() before checking PTR_ERR() > --- > drivers/remoteproc/stm32_rproc.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > index 2cf4b29..bcebb78 100644 > --- a/drivers/remoteproc/stm32_rproc.c > +++ b/drivers/remoteproc/stm32_rproc.c > @@ -310,11 +310,12 @@ static const struct stm32_mbox stm32_rproc_mbox[MBOX_NB_MBX] = { > } > }; > > -static void stm32_rproc_request_mbox(struct rproc *rproc) > +static int stm32_rproc_request_mbox(struct rproc *rproc) > { > struct stm32_rproc *ddata = rproc->priv; > struct device *dev = &rproc->dev; > unsigned int i; > + int j; > const unsigned char *name; > struct mbox_client *cl; > > @@ -329,10 +330,20 @@ static void stm32_rproc_request_mbox(struct rproc *rproc) > > ddata->mb[i].chan = mbox_request_channel_byname(cl, name); > if (IS_ERR(ddata->mb[i].chan)) { > + if (PTR_ERR(ddata->mb[i].chan) == -EPROBE_DEFER) > + goto err_probe; > dev_warn(dev, "cannot get %s mbox\n", name); > ddata->mb[i].chan = NULL; > } > } > + > + return 0; > + > +err_probe: > + for (j = i - 1; j >= 0; j--) > + if (ddata->mb[j].chan) > + mbox_free_channel(ddata->mb[j].chan); Do you need to set ddata->mb[i].chan to NULL as it is done in stm32_rproc_free_mbox? Also I'm wondering about the error path for this function. If something goes wrong in mbox_request_channel_byname() none of the previously allocated channels are freed and no further actions is taken. Should we simply abort the probing of the rproc if any of channels can't be probed? Regardless of the above and without surprise: Tested-by: Mathieu Poirier > + return -EPROBE_DEFER; > } > > static int stm32_rproc_set_hold_boot(struct rproc *rproc, bool hold) > @@ -596,7 +607,9 @@ static int stm32_rproc_probe(struct platform_device *pdev) > if (ret) > goto free_rproc; > > - stm32_rproc_request_mbox(rproc); > + ret = stm32_rproc_request_mbox(rproc); > + if (ret) > + goto free_rproc; > > ret = rproc_add(rproc); > if (ret) > -- > 2.7.4 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel