Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1157363pxu; Fri, 27 Nov 2020 00:44:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSRcqgeRkSEmgywBSScwklsgl83YZjPMTJ10KuZ46gL/OksCIMcYGetN25jRsvZNSJmMF4 X-Received: by 2002:a17:907:7253:: with SMTP id ds19mr6974655ejc.166.1606466671459; Fri, 27 Nov 2020 00:44:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466671; cv=none; d=google.com; s=arc-20160816; b=VwYnZCwW7jwpY+M75wSLcPtxHkiO0mxuWUX/avbrocODbUWanQvcFAkkEcHF3QWI2G bssayIl1yLhDFZkbO43hKcKVPwuN7yzLb98eWxu9oWUxyzNHIHPP9WdUn9iIrFnVnQGs KtvPXFuptOKRIx19jC6TgGBiBK1M276oqb7p9zMDJuLRO5AkHfG5JzRclMZnDwTznvQN pz4SMn6S9Nn3vssU6xd71Op7pgwZo1IEzhCcY4WJZGXlr/8hkI3iAWKBLdYZuON9XwCV 9wjRNEDnTy+XHaTt4jymJwfo2rmImUuhOF5dLLYZE0EK0ITSvJFrozqAfSHZWuJv2gRh G/cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x8XMWKfae4q09gjVQz0Vnlnpd49+WO7LGPeK5Mj05BA=; b=rbynNezYQAUZAix+ZVCtpLnvMLWqrfj2yYbEFDwdYiUFAHZwTIv4nmdJnijgNBlUxF 5Rx6H+8cHh3DTQNT8usPAfHJFAT7IsqvtFFg+RTXiofrTRSplDhbubLSZB82mFBubZRZ FtuzhLsVsmxBCNFNV6WcnuHkEA7jHw3rV2BbvsAH7PZryW0fUqj7Ib7Yx6T5xd/5TZls MAG0gedSBYf50ohKTD9nLGzqelpuIt3mPM0aHiBJnyz/E8zHfegFkrVacHWqMxO6OPcj OLBmfmh9OVxkF5iASbju7PEvlSI4f50oXeCs+ihzEgbwdOFbAE2jIIymvz5fY6knNs7A Mgew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fbTz3I/q"; 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 k7si4762737eds.198.2020.11.27.00.44.08; Fri, 27 Nov 2020 00:44:31 -0800 (PST) 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="fbTz3I/q"; 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 S2391571AbgKZVG7 (ORCPT + 99 others); Thu, 26 Nov 2020 16:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391555AbgKZVGz (ORCPT ); Thu, 26 Nov 2020 16:06:55 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC9CC061A47 for ; Thu, 26 Nov 2020 13:06:55 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id 34so2561122pgp.10 for ; Thu, 26 Nov 2020 13:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x8XMWKfae4q09gjVQz0Vnlnpd49+WO7LGPeK5Mj05BA=; b=fbTz3I/qpwcxvV52RAsvvLQQZevOtz9VhXW25EGHAOpzNMCjFuwxo76I1WTc8+7aML a/oorM43+BNCWnb/wtw2r9o8FVs7pZL7uEEkFHvBvCL49EDkZGGoKSE5M5CiIsl1+Ard M/38ct3v15xJiLINM4Ay1w7igT92vnulFhqMbVc/cYUAC2y4W6P6Qw6Jg41idknkE2xM verAPI56HY8tcgdeMQTYps4WSuIlJ+QSgB59Ucg/tvuvyGyaXji8qhjeHZsJHdN0R+9L pEoKMN618zBApBbdfnmOSh4WMTaH6sKUN9Y2MQSiUAtjNX5po7hHxZLS+RNoYgKB0McK Uldg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x8XMWKfae4q09gjVQz0Vnlnpd49+WO7LGPeK5Mj05BA=; b=F76yNIvquajTHH42lQ2bQPHIdyi2upYreZj/4dbCFKCFKCKVkzJfUYJHmla25OlUIR 0rQ0X4tM/TpFGL76DqJVG1YUO+sIY6qLg0camE9cVzptDUmRglACiV3MKaOGxWLz63qo QI4+SgAr5HpzLG1mcJZTDLRC/tSZPJPqE4x3WjTolZbEpvb8Aybyr7zRZicQoCJpD8QY Fhc/kSiGf64WHWJBXBO90WvngD/W7z+UOULe1HKFT7P6x6CMazaBgtbPX/Kbszd/jeTa MO27eF06zceoB7f8NXadxYtANbjvYROYwCK0R9bbKxnAkkXblv12ZU9B4vjaQI0nsMaH HMcA== X-Gm-Message-State: AOAM533dE2AERi+U/YU3mUmnos7+cZSI9Ps8NI4baYAWW4hoqiSzyMum IoaqKcBp4BtHZg3GUp02qzWPHg== X-Received: by 2002:a17:90b:ec7:: with SMTP id gz7mr266535pjb.210.1606424814852; Thu, 26 Nov 2020 13:06:54 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c203sm5612676pfc.10.2020.11.26.13.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:54 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com Subject: [PATCH v3 11/15] remoteproc: Add return value to function rproc_shutdown() Date: Thu, 26 Nov 2020 14:06:38 -0700 Message-Id: <20201126210642.897302-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201126210642.897302-1-mathieu.poirier@linaro.org> References: <20201126210642.897302-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a return value to function rproc_shutdown() in order to properly deal with error conditions that may occur. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 19 ++++++++++++++----- include/linux/remoteproc.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index b54f60cc3cbd..51275107eb1f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1869,7 +1869,7 @@ EXPORT_SYMBOL(rproc_boot); * returns, and users can still use it with a subsequent rproc_boot(), if * needed. */ -void rproc_shutdown(struct rproc *rproc) +int rproc_shutdown(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1877,15 +1877,19 @@ void rproc_shutdown(struct rproc *rproc) ret = mutex_lock_interruptible(&rproc->lock); if (ret) { dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); - return; + return ret; } - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING) { + ret = -EPERM; goto out; + } /* if the remote proc is still needed, bail out */ - if (!atomic_dec_and_test(&rproc->power)) + if (!atomic_dec_and_test(&rproc->power)) { + ret = -EBUSY; goto out; + } ret = rproc_stop(rproc, false); if (ret) { @@ -1897,7 +1901,11 @@ void rproc_shutdown(struct rproc *rproc) rproc_resource_cleanup(rproc); /* release HW resources if needed */ - rproc_unprepare_device(rproc); + ret = rproc_unprepare_device(rproc); + if (ret) { + atomic_inc(&rproc->power); + goto out; + } rproc_disable_iommu(rproc); @@ -1907,6 +1915,7 @@ void rproc_shutdown(struct rproc *rproc) rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); + return ret; } EXPORT_SYMBOL(rproc_shutdown); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 329c1c071dcf..02312096d59f 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -655,7 +655,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, u32 da, const char *name, ...); int rproc_boot(struct rproc *rproc); -void rproc_shutdown(struct rproc *rproc); +int rproc_shutdown(struct rproc *rproc); int rproc_detach(struct rproc *rproc); int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); -- 2.25.1