From patchwork Thu Feb 11 23:46:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381071 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496543jah; Thu, 11 Feb 2021 15:51:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPLhE6B00wa2ov7MhoCTn/V6AQprzeaE5vshXodhdCg9dD2NSvuhJkx461ja1Zg2if/HRO X-Received: by 2002:a05:6402:31a3:: with SMTP id dj3mr614859edb.172.1613087499643; Thu, 11 Feb 2021 15:51:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087499; cv=none; d=google.com; s=arc-20160816; b=QJMZL8h0TR++6fz50IxmymFfvfnciFxOtqKNAqJ+MhdcetvePfzDQtiHL74s6sP1OO nEjmt6S2LWvTc1309ZRWg5tO3mJk6S4ovdes5qSMjhIf4zJpt6l9IkWBRO2iiFQFpSmF de3/XEIkPjGboplaRygPbAW26T63yXo5zPHXvRq49O2fukYbTyJcmZGkFHpHSBipI3FC p/yvgFIrtwhalaUb4t5pnaSwlt0kEkN6NGI5NQpSnN7rfX3VYyEVxtE4EAklh0tNWHxS Ra8Fw3x+TaqeCHOVivN5Vm+h5hGzN26FfElOK89y9m8NqDtAoI0mOvu1DFYG+XR924TO akNg== 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=LDZKl3InJry2uc3BIzMNfTpvGwSU2yaFbHElAaRG5qQ=; b=IH0pfieYtDF/bz7m+fLJI/A12f4WwJxmxhB9aThrp/BsZI8oQ/+m/nNA6f+9rJUUDY 4RNVaSKoFt3w4vOYh+Fn9wQrola2jAxhHafdq3NSlOoNaxHXlJGRZEfVtEoju2erZAlO kKPA4nDhoFm+T3Jtn4Og9Z/zMM/oDiSZ0YnaiJyv/IEUkisWKk62uo5atfqrRwG6/NO4 uJUhus/bKUo72GQZq5Yo2Kup1CelGKFPgG38pFKEefzE+98lS2P2DAh1aIMV0yS+dSts sHjlUv0i6IXiUhSMeg1nbFs1tM3/vwNjE76ueBCA0z3IjIkC/pCghqMl2B81u61odfVo Wwzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVkVXmDn; 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 ch12si4550788edb.463.2021.02.11.15.51.39; Thu, 11 Feb 2021 15:51:39 -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=QVkVXmDn; 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 S230390AbhBKXvP (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbhBKXta (ORCPT ); Thu, 11 Feb 2021 18:49:30 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44ABFC0698C3 for ; Thu, 11 Feb 2021 15:46:43 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id z68so371960pgz.0 for ; Thu, 11 Feb 2021 15:46:43 -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=LDZKl3InJry2uc3BIzMNfTpvGwSU2yaFbHElAaRG5qQ=; b=QVkVXmDnViCOE4jMf8kqA4U6tgVMTUzDp7YWDf8qKVzsyuWdqJhID9SGoYxyf1TLZ3 IHn7iWfULllzfOiZU2OE5sTOID0KCZ2h6PKXRV+3DklKjnP4sHeZdYYKEkxTj/y3uvXh LhfbAerRSvBobO9kA/1bB/Z2FOz63FEGDPHD/ezqbvZ2CSdZTnOu8Wu3S3mEvvFLP2Pq UhuvTt1Kyp+gOMfJtzBwmUS5baknbeoC50+LBUhuX7YhZsDM/7RxSVQ+zkKDie2ZaZAC jKg8lNGUaa6UMh1k9OF6BfupyXjgnkq0HOanbxABWxSWU3KErERJDjX6zVV2t0SyJy9V DmFw== 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=LDZKl3InJry2uc3BIzMNfTpvGwSU2yaFbHElAaRG5qQ=; b=i86te/0nK0FFsXBoir49VGytVGLpj6/NJm3E67c6zaCIa8MnHDYMqmZCSBxzBRa/qS i/rACVcmOwdG7QXpUwW1z4e8yD1DyydL9D1HrTkffnN3rUn4hppZBgHAhx7tVQZ2DAiL FFFlrbXK2vzHaGuilrtJRUbWOVFQ1YBaOrGPYx/kammhueRJfSUmL5AEdmc1e7vfF44r 8jDUhdnwWZWk0n2adpO53QjmjZ1AZ7gHWaXsBjBAtm73O80ERqFS5FKhancHxt7ABHMk zPe8uaxw+GBMcu4r6zESPChc2roQmHVJCUk2vvHolXFfrMbw4+dH541nVYKODkZv7KV3 5+gg== X-Gm-Message-State: AOAM531vNKl8FcHUybJvMULz8jUuoiVz9fB55j06dTUuRQeiIZamAPTs FmagM917PPppB8HMeOEhe0PCoQ== X-Received: by 2002:a05:6a00:22d6:b029:1cb:35ac:d8e0 with SMTP id f22-20020a056a0022d6b02901cb35acd8e0mr408493pfj.17.1613087202720; Thu, 11 Feb 2021 15:46:42 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:42 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 14/19] remoteproc: Add return value to function rproc_shutdown() Date: Thu, 11 Feb 2021 16:46:22 -0700 Message-Id: <20210211234627.2669674-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-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 Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 19 ++++++++++++++----- include/linux/remoteproc.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9a77cb6d6470..62f708662052 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1966,7 +1966,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; @@ -1974,15 +1974,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) { @@ -1994,7 +1998,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); @@ -2007,6 +2015,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 e5f52a12a650..5b49c4018e90 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -664,7 +664,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);