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: 77201 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1405402qgf; Sun, 2 Oct 2016 17:41:49 -0700 (PDT) X-Received: by 10.98.23.68 with SMTP id 65mr10885096pfx.117.1475455308988; Sun, 02 Oct 2016 17:41:48 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uh1si33750330pab.215.2016.10.02.17.41.48; Sun, 02 Oct 2016 17:41:48 -0700 (PDT) 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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751764AbcJCAln (ORCPT + 27 others); Sun, 2 Oct 2016 20:41:43 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35839 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751621AbcJCAle (ORCPT ); Sun, 2 Oct 2016 20:41:34 -0400 Received: by mail-pf0-f172.google.com with SMTP id s13so57827514pfd.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=J9EDqWa7bhUEOlWeAz6UwFIgPICDXOaY0gq+OKz9+wmLhcIHpbX+mZiDCYBWkjdpQk pX8mM+J4TrUh50u0csWR5MSVz/PRcBk3TlYwfyiM75t1czO4bOFSMdShjvW+iyTWeS5d 0di+LdLIhr4T3TW1CSS3h1TwWd/4/HvnS53RR23xgDYeK/jm2DfEE39GKhJnNSeO+GWQ FjdLKknc3o9NGHQf/1M/V3sVm88krjuMN8pMnezdU2dZaa7hXpDPSyWWLnDLHfj8Z5nS G1VADc5g437sLp2B1PEJp+Xdv2Xji8eqtp6yJ1J/xkon/VXUBnkjWCxWBhmlYwBhgtir IdxQ== X-Gm-Message-State: AA6/9RltmLq5I1Hjn+UNusONJx/Szqd117jHVWmupBbGGrES7xAWpdzs2Q95M4ZjIRzOGF0T 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.5.0 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; }