From patchwork Fri Dec 18 17:32:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345483 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335833jai; Fri, 18 Dec 2020 09:35:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3hmMITT+vpl1sdITrHnm926IVM7J1NcMk3tSu58dAwHy1B81HDKuNtDMWJjMJCM8vidwO X-Received: by 2002:a17:906:f8d4:: with SMTP id lh20mr5046238ejb.442.1608312928857; Fri, 18 Dec 2020 09:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312928; cv=none; d=google.com; s=arc-20160816; b=pSj8I5jBLVbWcw0+Wtkzm6QtKnwS/R89gHyap96yWtywfF0O4LnTQJaQ0xCr/RUFi+ +5A5XfZPc+q6Pp5fjCcsyKgUPzDWCYrKLXZU9M7IlUz7qjYhI8yebMN73sLZzemCRy/X SLTCLhXwS2Qy0tiQ/sZVzOuJqtWN0SoT9RLYNoVkHSPNa7i9H9CWJA3yHEiFDO/YbYc4 zBZbIM0bvzLLEdx397RbijrC1eSk9Wp6ONt4O7j6SNPlTaTCAgfLCrEOCS955VFwe1jH kibXPsD2uIJhIXZD9i4zf4qXSNQx9xKVCpNFgMBT6iE9kC+UEYeqTV9onezDBeBW4lFT Lytw== 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=quv8FgGcrBfpjdUziX+s2dGLHCpcEJuuhEHyCnt0I9w=; b=iLB+OMuy/HZPdm8TI1fx3w9OhhZgp89WGmzg+28qtHk5ou3ubX2mXQCSz9v3Ff44Sr JnS9oc+2nA7g8TJwjjyhLFWKc0DpIMy6Gi1D02XyuHznrCbRJrgSr8i1L5xrrpOQ8NES MetmGrhfeObZahu+wJc9WQeOO5r0se0F9rxdN6akT6jKkD9f844q8gFJGGrkisW2WIrp psuaubW71X6vode6scT4J3NxIAZ47s5garXF60IBuk8yQgIbxlFPOrOSosNBA9rB6YWB rrhuI7jEPRgW8Ow84PMMf0zWeVVYZpwc44CiL+OzG77hCkhHTpZhvSXlmmMuTeNWWva9 2beg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hWjlKc/u"; 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 t20si4902939ejd.719.2020.12.18.09.35.28; Fri, 18 Dec 2020 09:35:28 -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="hWjlKc/u"; 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 S1728304AbgLRRfP (ORCPT + 7 others); Fri, 18 Dec 2020 12:35:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbgLRRdv (ORCPT ); Fri, 18 Dec 2020 12:33:51 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 189E0C0611C5 for ; Fri, 18 Dec 2020 09:32:33 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id x12so1746493plr.10 for ; Fri, 18 Dec 2020 09:32:33 -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=quv8FgGcrBfpjdUziX+s2dGLHCpcEJuuhEHyCnt0I9w=; b=hWjlKc/uj59tXupMihyRyk6/qf5jTxj733rtsaPMHcWwyas3HRGdNDFySCMQMFDsLw MsQlakPxeBYW7HiRi3L/5gQsrLigaJK2SrUEYK4IGL4m/B1h6Qm7zzO/+R+qU/dxUeAc Z3VHqNIuAwma/8vga8q8ugF0ZpNAe3i4KndKnvjUzkaMxntPyLVi4459FM8BfHpdtIT2 siJkUbRIB3rg+D0KZXSsl83hf6P7FheSxhm20Ku6OHJnK5lO7gXl8IvKhhroO3XgiRMb 7yMbAakrbxAtg16bQf1fPw8aGoMA1qfQACManxDa4k9GVQxH7fNUaf1pGaBM7CksN04V n4ww== 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=quv8FgGcrBfpjdUziX+s2dGLHCpcEJuuhEHyCnt0I9w=; b=BBzZM8yaf+RN1bRhyCBqs0kfecz98K1nI12xqip20Vg3xY2txs/keh0wJfFR11KpUO +voYOcn4E5CsyjUgL8tdYoLqKT2E9qAsZHCiOuAcwZ84lXQ1q6s2FHs4uizYYigW1kUp /GgF1VonSHeoK3zC8N+Ti9nRusSX/wYjy0tKdUdGp4iHBGoxgHtRYwA+8unX6ESaTjP6 EOiuI81n0aqzqXULpf3QYZgNj+UMOtx+TcvMcms6cNZF8KiC9UhJW/fq5bxZKlb6ivr9 AzPZlLHaL2uI4EZdLD8qLIQJHiyZG4ffSy+AOXa6vodR1ZInqUSx8N9TggQFwTDjRwp9 xPcw== X-Gm-Message-State: AOAM531mbqUIfvqc8AR3+Nx4vcMadg/3sz01aa4kvMX/QgF6M2t60dn4 UtlcyPmgJeORQPeUFpoCYDsRKQ== X-Received: by 2002:a17:90a:c8d:: with SMTP id v13mr5283889pja.75.1608312752706; Fri, 18 Dec 2020 09:32:32 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:32 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/17] remoteproc: Re-check state in rproc_shutdown() Date: Fri, 18 Dec 2020 10:32:13 -0700 Message-Id: <20201218173228.2277032-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-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 dab2c0f5caf0..e55568d1e7e2 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;