From patchwork Thu Feb 11 23:46:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381059 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495605jah; Thu, 11 Feb 2021 15:49:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKTgz3OpqS/5twV42JoQ46JoNA+NKkT3ccxyJ4Fm8o6uCKmq0hXTevsMnKfZ/J7JG5QWGD X-Received: by 2002:a17:906:2583:: with SMTP id m3mr129930ejb.499.1613087369819; Thu, 11 Feb 2021 15:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087369; cv=none; d=google.com; s=arc-20160816; b=cRNEt9/X0ekpjPcNkjArcGKNX+1Gwo2CSKWRZ+NqnF5Okw8uodQlt2A8wcWVVhGtPP bCS6aTYy+8WlGQCJ+a7VfELvA9w7QyTa3ecQsu57fqKkF09SUAKSGG2aPGhA0Qj+INUz gJ02Fsf7sh+yw7xlN0pbylTmLRAS7eggO6STYlJ7VHngzXNtpXvlaQOTJ7f6RBCXiN6f gky0PNTy8FXLJfzA8YUts92uMTCDfnIrikqB4TzieqdiXlfSEWzS9FoZ1h82yZn9Kdy8 p3npFHxK/r2BZjQl/vbmU4wJ/rYTvNE+XHv28TktCTriV61Qr+MfDhilrUFaX894DQRo JM/w== 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=2KYl68Dz1gSnngZXwIN4sqByIS0YQQztG8qhw3LioGM=; b=lZql8E0V+qrOWma0ANIU1lzvTqKJs93gQdeyfWFU7lfBOQtxvroY4mHflm87rBSwGC SXgvXoLxU2n6Qr+5IqqMvZMxk2zPb7s9ikgAlOyjX3RTlDE0aLFsX7I42K5i2dbOEdhI 4pS6jbbCU8wHXUV70i7aG+oboDPCGmHllH7JU0e6GUmX6qOkT08YNrxEEvaO//LuS7/s kqNbYnz11kcVs3aZP493MCdMv3Mvp1DbApwPyM0FZdmpDmzm5kpcyENlUK5I5gMHebpr 5w9YiAKFw4JUpWpgS14kyRrq9jPcAPZzZxyhPmG4dCuej0BOd+ZEtLzHYMQC52yGF2Tr IelA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zIatSa7C; 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 ot7si4969638ejb.88.2021.02.11.15.49.29; Thu, 11 Feb 2021 15:49:29 -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=zIatSa7C; 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 S230353AbhBKXse (ORCPT + 6 others); Thu, 11 Feb 2021 18:48:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbhBKXrN (ORCPT ); Thu, 11 Feb 2021 18:47:13 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1FD6C061793 for ; Thu, 11 Feb 2021 15:46:31 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id t25so5073132pga.2 for ; Thu, 11 Feb 2021 15:46:31 -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=2KYl68Dz1gSnngZXwIN4sqByIS0YQQztG8qhw3LioGM=; b=zIatSa7CJYFApIdlA+4ilgXNyRLDat4ml/F/f4McziCPqJX/qShgyLX1ikZm1Hx8L9 ogLgeKsFhOGJqUsy/9s7dsqrPpsb58CdyJtW4xpXr4AHoqgsOOVhKDGUJ2GWAF4jNRHS SFy2Qm8eNeRt0gF6tugmbnUwJOHDorASZOeV11ZeoqIep9k8QOlPN4bEnWpu0nEM+jag h/dJCsLpRCCXnAf+QYGOxitC4pyrYUUXIt6Qpb/03n37zjB5ZdfVMDHNX+TPNV7wANH8 FO5sPFiNQoLsIBIaiHBzjSGH64MyFuqyKxIY+mWI7cHXP6QXVuCOFHCZdGVHYRrLbX3F aH5Q== 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=2KYl68Dz1gSnngZXwIN4sqByIS0YQQztG8qhw3LioGM=; b=K3vhnY6mUxgnPHdlFtig6PHubmFqonbwq5bqJ/PvzqKdaHyljEKnw9oAaYP6t8z9Fd InpIW4AxNwnoJeH/Hy1fYLQIFQPwzjZLv9AnPzxc3V0JxNIBpTWCYLYIcbYzDA9aisgS q63Et7OzVEA3/qGG6t3kk4PguOzUgb1iFpuhsSWO4vgO+IGMIhx3K4woH7z8F+G16fSu +SalpnFNs6pW53MsAoOk2PNCS4ksP47WwZLzESsyEk7kM3+jrs83LeQrE/kIm5LB22ho I/ls9/sKrooTYWTcGNadkY/hCd0xecB2M8bD4vukIXKXNjz93FbOgECcc9EPBU9IGkyS Ki/w== X-Gm-Message-State: AOAM531QUbmlFia5VR5mV/eac2Q39hMAsq8ePNX1Lvbj+g7JFJ/WHf+W 4OfErktPpMQQgDLpAgBVwtqkug== X-Received: by 2002:a63:f95b:: with SMTP id q27mr567144pgk.82.1613087190926; Thu, 11 Feb 2021 15:46:30 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:30 -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 02/19] remoteproc: Re-check state in rproc_shutdown() Date: Thu, 11 Feb 2021 16:46:10 -0700 Message-Id: <20210211234627.2669674-3-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 The state of the remote processor may have changed between the time a call to rproc_shutdown() was made and the time it is executed. To avoid moving forward with an operation that may have been cancelled, recheck while holding the mutex. Cc: Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2394eef383e3..f1c097572e01 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1857,6 +1857,9 @@ void rproc_shutdown(struct rproc *rproc) return; } + if (rproc->state != RPROC_RUNNING) + goto out; + /* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test(&rproc->power)) goto out;