From patchwork Thu Nov 26 21:06:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 333060 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633996ilb; Thu, 26 Nov 2020 13:08:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfxEv/cW0HGxZ04OnI9Z7P0GpATTNr1bJ9zn+/3fNR/8QB0SLz4WE5IxPvUcWconf+EuO8 X-Received: by 2002:a17:906:c298:: with SMTP id r24mr4331972ejz.381.1606424903532; Thu, 26 Nov 2020 13:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424903; cv=none; d=google.com; s=arc-20160816; b=1BJKh22GeEELFdeUeXyjrl/owX8YE20bVfAsC0ij0vIbNtSEcDsK4JChA2vW+ban7r 7WSJjgZ62xDne2jgIGZs4mB1P8SCC3UO5Y68qwGZDFyhZ92vq4IE0QExOIGmJIezlh93 Xr80grpimNQ1DlzPj3eSKVvSUfQNw3UDy/30TqLdFswxh6D8CH74B/ug0AIt4Rmxq+KJ NW6mJUww31F/kGHvA3Vo5tBoePbnunKVji4Oky7P/1Aowt8GOBwYZD7shsD8DWIiYnNW xAPVkKE0ZgoOwlSdIenFeJ54xmrhmOWvuJ+M9cmFnPv9qcWgfsreH61Laoa2qNo1BxyQ XtQg== 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=mQ2l1Xrto4LmO+pdhyE7G5UTHSFvbaPT4OVsstHi1R9xWjOkLeKvaaNFkD//HSgxB8 sxpCAk4Xarx4lWFp3VyrNwI9OWMBprapYc38Gler9TMWg4CjZAVSibnVAf8j9bNVLakW 9xptwG6h5yVT8kBYYzgZnCnH5xZVSQAL8nNOdNVVc8tvNsixB7pl2ytItUuR4LgMIARZ aoEkdGbAnYCPvfk6D5F4aPsO4k3h83/IPNn3bGlbR1/EtE/Q3BrvMkS6Tcti6iXpWcWr u2ZWvzZ1Sh8CpD0N4Og1Otp6LSLhDK+leJtEOffutPex+yIFZ88HSpr1fFseI0EIAJeW XOaA== 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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 k11si3567033ejg.330.2020.11.26.13.08.23; Thu, 26 Nov 2020 13:08:23 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S2391643AbgKZVG6 (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391585AbgKZVG4 (ORCPT ); Thu, 26 Nov 2020 16:06:56 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F825C061A4F for ; Thu, 26 Nov 2020 13:06:55 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id w4so2553848pgg.13 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=cwE8gG+T4puSgFoTMko8DmtKZ+8o/wDitxS2MOAoC44HihxBrlxxGpju76pi1dS7QR UTBLGrK2zPVtgZx1J3NccGOyC2edXAFpDNoIAXi7WgiR3ltLdYUDCmDzJIrMUOce0R3U Cz1mTzec8lEyty+Gyg884k2bDvC4QkRB0QlOsV4SXonuoq8qa0qgmROcnuVlF8ZHmMyX AD47tIIqcZ8Sk34VrrNTUdUArq/Vn6mswiAjMrB7aK5ufU+RcpkTd+qlTvts9EshVc1D Ykj14MJDGbjUPLIRqetGqrTNwKZTNNDreVgTF1mAOAy2VdIn1BGCZBmv9vIlqNpKqIX7 O5ug== X-Gm-Message-State: AOAM530Ut0CzL5Sd7pv3tqr3O1tuwXtSZIuy9qShVlVG7p612f1VdGWk X53tp8oAiLxFaHD/9UYum9fyj8af1lPHidP1 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@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(-) -- 2.25.1 Reviewed-by: Arnaud Pouliquen 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);