Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4287052ybc; Fri, 15 Nov 2019 02:07:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxczCz2PHTaUAIPJlZtL0VASEE8BwWNrcDw17m4aPvDk5YHxyFn3XF8HfLvGBT3AMMzp1WP X-Received: by 2002:a17:906:4dd5:: with SMTP id f21mr12695086ejw.203.1573812421197; Fri, 15 Nov 2019 02:07:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573812421; cv=none; d=google.com; s=arc-20160816; b=P4k5rsAhHaUc9TjKZgC9iRNyRu0a4c08WqExyH87Mk+eTE5cYP71EoSlPjlKCKNeti T6uj+N23zSHx9Sc7tJaszCC2jWQxMA0eikx+/4QGFdBJ/frt741wXIuh+yjCAhA6b1Rb CFOZmjqmOn+O1emFxaQnyjj1sUyiEOkYiV5F3QByB8E+alycxzgPqRjFbDkr2WlYZWyX +uBxhDGah5KjD1Q//dWlkqOaC5RPQr2HUzsDO/Ul8KSPcFvcvCb4AbiL/teBaUMxxqoh eGcd+uHA3PaBazrzgKf+p/HPUbCBYgeNjNyhVvJKqH6uH2O4/9XrT/gtvqYBZLb0DRBF 22tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=7gCFVo1c3feoHsazY70FKsMn5zRITBygco7FGXQsWm0=; b=aD0pNT+1ogP9bXiTYEQDWpPre5P/vFGXuuBsC0SSbl5A36X9umuRxANZGnvs+J1abL uL8p90BOsZ11G/HGjDk+xKKiStLvdBxCJAebKK9KvuDCJNNYkopa7Cm/TzUwYa0fH9md vnpgKU1MeVvbErXJFTcQKfVZZ1E2TIFaO0LuuUs/DBBboByXXPwhLOFuJ0ztLMpUkHho 3cb/egTURUj2g7Y+N8L5Sb1jHqJogm086wLYQxiPg9m7DHeL0x6iidt3PjAz+yhdGk3w 8ZN/lJJ0s80+fwmd077x65E0qqVGHkGZLXB1vU045Ppl7bwP5J4GCEUPCPB80rCwOz2y iNNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=zEKBpL15; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k35si6361290edb.84.2019.11.15.02.06.36; Fri, 15 Nov 2019 02:07:01 -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=@st.com header.s=STMicroelectronics header.b=zEKBpL15; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727210AbfKOKD1 (ORCPT + 99 others); Fri, 15 Nov 2019 05:03:27 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:43758 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726920AbfKOKD1 (ORCPT ); Fri, 15 Nov 2019 05:03:27 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAFA2jj5028719; Fri, 15 Nov 2019 11:03:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=7gCFVo1c3feoHsazY70FKsMn5zRITBygco7FGXQsWm0=; b=zEKBpL150QmvwnsFu7TMaV8SIS07qJ3LT1foyO0sA4n/tyHJlD16P8/cFAgzPq3hu9fk 7jdJ5kkF7X99XG4QQrLDCS5YN6lKJx2jpsIcLdQD1aRByDZotv1DangvGCbHL1M3NpCj 1B2ICn1Xa8JGZxXjHmNRj83XmRIkTQM3DpFfFURcdOPsY0intlCxt8hDB1YmMWeYvCY9 cpgsmdj+TrIQJLNe1KLKkQzEwCzdoKGxaU9GLArCQq+ytbLX6wm/85BXy8bvEVyn6XaK raLpNasCa2H6Dsjrsz0cDOSmp6l3krFiQRBdEe1Oqo3P+9s55te9K5P26A4XDbD8Bf6I ug== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2w7psubc95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Nov 2019 11:03:16 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7E740100038; Fri, 15 Nov 2019 11:03:14 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6D5EA2B1887; Fri, 15 Nov 2019 11:03:14 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 15 Nov 2019 11:03:13 +0100 From: Fabien Dessenne To: Maxime Coquelin , Alexandre Torgue , Ohad Ben-Cohen , Bjorn Andersson , , , , CC: Fabien Dessenne , Loic Pallardy , Arnaud Pouliquen Subject: [PATCH v4] remoteproc: stm32: fix probe error case Date: Fri, 15 Nov 2019 11:03:08 +0100 Message-ID: <1573812188-19842-1-git-send-email-fabien.dessenne@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-15_02:2019-11-15,2019-11-15 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + 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