From patchwork Mon Oct 3 00:41:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9359851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 931C660459 for ; Mon, 3 Oct 2016 00:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C40528A45 for ; Mon, 3 Oct 2016 00:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7672D28A59; Mon, 3 Oct 2016 00:41:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5B7728A45 for ; Mon, 3 Oct 2016 00:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbcJCAlf (ORCPT ); Sun, 2 Oct 2016 20:41:35 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:35839 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbcJCAle (ORCPT ); Sun, 2 Oct 2016 20:41:34 -0400 Received: by mail-pf0-f171.google.com with SMTP id s13so57827513pfd.2 for ; Sun, 02 Oct 2016 17:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=KUd0OQ+QavblLXyp49Rpact+SMb2Dw17panF5AVMJ/g=; b=C+abvJW5Yw/ax1mHTCG5gbB7B6E8iyZlm9udPmW+zL9VWbw2kTXMVUYh50urZitXUC hn393LbjN19FzDFlhEL7fpAnqVmbMW/T1Jpx3cRc/AJzch+5Pp25agD4XWNwL/lx+XkN LjpndUc/eJgpjPZZ8Mor19BtjSBP5//xOkHqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KUd0OQ+QavblLXyp49Rpact+SMb2Dw17panF5AVMJ/g=; b=YLhu1Wft60dTMFG1amwD+6xQbknlEwonm905AZrQCQZDOnzBAsj2f7QXtAWVHTJs8a npgRSYHTCzn8irFtgztx6EHfla6yLns9AFxlOmQrPeL3H8KNk/0FO/ElszGDbJ8mbYj9 jLrzRFfVoZ3bTkfVDxdPf3Zd5VajkKCXCgsKAH6KFs/nZK4StgkT2kVy1yrCqBXjWO1I 7+5onEhFmQBTVyYc5y5K8l3AIiGQT3n6deJThmQ0T+Xv6OGZ9JPl+suBxOfrWg5CGLFW Vkd2QJrIOdQm5LqyWZBTC5WOcOnHz69tnyuNm15MP+ehrGgYsiUiZE49Awrp8rWpXgrY KAuA== X-Gm-Message-State: AA6/9RkYonem5OoOQta1kJMa0zQm7U44NhojMd+MAI+wzxYde5AYbvg4Drqi7xIGwwMKRks2 X-Received: by 10.98.158.211 with SMTP id f80mr18470930pfk.122.1475455293581; Sun, 02 Oct 2016 17:41:33 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id m82sm42347232pfk.64.2016.10.02.17.41.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Oct 2016 17:41:31 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] remoteproc: Correct resource handling upon boot failure Date: Sun, 2 Oct 2016 17:41:29 -0700 Message-Id: <1475455289-28375-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The freeing of resources will attempt to clear values previously set in the cached resource table, so make sure to free the table after we have cleaned up the resources. Fixes: 988d204cdaf6 ("remoteproc: Move handling of cached table to boot/shutdown") Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 92a1037c1b2e..3da566b0d437 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -847,14 +847,14 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers); if (ret) { dev_err(dev, "Failed to process resources: %d\n", ret); - goto clean_up; + goto clean_up_resources; } /* load the ELF segments to memory */ ret = rproc_load_segments(rproc, fw); if (ret) { dev_err(dev, "Failed to load program segments: %d\n", ret); - goto clean_up; + goto clean_up_resources; } /* @@ -875,7 +875,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ret = rproc->ops->start(rproc); if (ret) { dev_err(dev, "can't start rproc %s: %d\n", rproc->name, ret); - goto clean_up; + goto clean_up_resources; } rproc->state = RPROC_RUNNING; @@ -884,12 +884,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return 0; +clean_up_resources: + rproc_resource_cleanup(rproc); clean_up: kfree(rproc->cached_table); rproc->cached_table = NULL; rproc->table_ptr = NULL; - rproc_resource_cleanup(rproc); rproc_disable_iommu(rproc); return ret; }