From patchwork Thu Nov 26 21:06:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FB9DC83014 for ; Thu, 26 Nov 2020 21:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E89B20643 for ; Thu, 26 Nov 2020 21:07:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P4PfmXE+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733277AbgKZVGq (ORCPT ); Thu, 26 Nov 2020 16:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733088AbgKZVGp (ORCPT ); Thu, 26 Nov 2020 16:06:45 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CEA3C061A47 for ; Thu, 26 Nov 2020 13:06:45 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id q10so2639587pfn.0 for ; Thu, 26 Nov 2020 13:06:45 -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=b8dSpVOpxPRkH7Ii5MIpuEJbpdKoro7QaAmsugruQCw=; b=P4PfmXE+FyQXDHy7FgUHIsP5Zo1vGXgGcprWj5PB8cHTbClbTLHEi1OyxOAboyn1li UGdIfos4P/stI6PNO6eh333PBp7DupwMLj5qpZjiNbCU5QYrFTXJK7iMkCAwRLzjUis2 JkUnprHv5osDdjPK3iaQvipXGPnbkACZ8lE44zJLGy6KMKpxWj+cg23jKpvYnC7D+Pz7 KA1pmb0JW09uAluqEE/mmr6hHVVyZ+dgkCXOGEV7tjTSYy0InNz909L+DGT90b/vpnIx mzw6jQdyXneVb8u7SHkkrnloKV8FRa11JJ3EwqN0s4J/xJFb6Y1mhqORAkhNXfck3kVM 7nSQ== 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=b8dSpVOpxPRkH7Ii5MIpuEJbpdKoro7QaAmsugruQCw=; b=c/BJMBD+he7oTCvfaQonEnG9kMXfUmxNqPK12q6gIpOAhuLOID+X0ySsVb2FUFo+6l A4NxfJS5Gxmg9hPPbsxO4JYUE0RsqIByoqgSPp+X8aKCr8LFoNzlTpCDjUSEVP2tHSKr defXS/Y5xHjfHtcxpvY2O3y4DcbQkfOF2kPTxp8cJhD6coPOQWTjzhuuA6S5+d13bJ40 s+d89mVF3mrCpE4+bToXusL8die74CYjT8N8icYnhwl/iYJQo5jHllzCE4JX4IFYtCYi NQOTSQcPS/WCXv3p+GrfGImrLOnmTXgb7/O/b5xWF0W4KGC22C6dZfvXhA01UC3QzWqw Behw== X-Gm-Message-State: AOAM532xGgGsGzTXjxl7isX+/fPSqAuGgaySPXxz4xA0h7ZK9mxYOsgk zo+Fnyqa26BWvPpdrYxMALgeNQ== X-Google-Smtp-Source: ABdhPJyLy0T5HMCS0PiytpdYdYbOO1InxoG7sEnAYMH/+Vu63BhfR4ArQGA3dOHVMbwpVqehSA8Tmg== X-Received: by 2002:a63:1704:: with SMTP id x4mr3933109pgl.65.1606424804717; Thu, 26 Nov 2020 13:06:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:44 -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 01/15] dt-bindings: remoteproc: Add bindind to support autonomous processors Date: Thu, 26 Nov 2020 14:06:28 -0700 Message-Id: <20201126210642.897302-2-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: linux-remoteproc@vger.kernel.org This patch adds a binding to guide the remoteproc core on how to deal with remote processors in two cases: 1) When an application holding a reference to a remote processor character device interface crashes. 2) when the platform driver for a remote processor is removed. In both cases if "autonomous-on-core-reboot" is specified in the remote processor DT node, the remoteproc core will detach the remote processor rather than switching it off. Signed-off-by: Mathieu Poirier --- .../bindings/remoteproc/remoteproc-core.yaml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml diff --git a/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml b/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml new file mode 100644 index 000000000000..3032734f42a3 --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/remoteproc/remoteproc-core.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Binding for the remoteproc core applicable to all remote processors + +maintainers: + - Bjorn Andersson + - Mathieu Poirier + +description: + This document defines the binding recognised by the remoteproc core that can + be used by any remote processor in the subsystem. + +properties: + autonomous-on-core-reboot: + $ref: /schemas/types.yaml#/definitions/flag + description: + Used in two situations, i.e when a user space application releases the + handle it has on the remote processor's character driver interface and + when a remote processor's platform driver is being removed. If defined, + this flag instructs the remoteproc core to detach the remote processor + rather than turning it off. From patchwork Thu Nov 26 21:06:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3129C83013 for ; Thu, 26 Nov 2020 21:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DEF9207BC for ; Thu, 26 Nov 2020 21:07:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EJgU0yrf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391194AbgKZVHa (ORCPT ); Thu, 26 Nov 2020 16:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732947AbgKZVGq (ORCPT ); Thu, 26 Nov 2020 16:06:46 -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 276B7C0617A7 for ; Thu, 26 Nov 2020 13:06:46 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id k11so2593546pgq.2 for ; Thu, 26 Nov 2020 13:06:46 -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=Tgn2hTBqiW955JL5NPKA45JX/FzuG4XGgD1c5/FNO0E=; b=EJgU0yrfDUi8K8TBrpgjT/nsXFo2NQQXZN2x+vJPCyzkDxYqwcmziQyyjhr9ttVojI AonHYDAz2+W26V4stIv19k1UcMmylcC4/I9CgGet6RwL6Kyy2UAtfKTl0qfAIytXLqhX I80mt//amPrYAPJ30mKrzEQPvBJ7rmm1yEpGk/nEnef0VfU7s/1Qc42Z/Kl40xpDoJSd dESiphWO7uhj9Tb281SsmB4OmaJfa/D19zZLoG7bYC+c7eHkgt3LYYrudLSvRQDvTFIg OIkAC1WD33FWh0WsP8pEYguuVyKOJASEoFcHEDb+d5Lgd0MUj99UTtwvtWAFsePNQ3Z7 T1uA== 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=Tgn2hTBqiW955JL5NPKA45JX/FzuG4XGgD1c5/FNO0E=; b=H9c3ZIvxUudY4XtIfzWHf7H+jemOAwgP9ANUxXDaIczSwabS9NHASJiDJ6PTy37ee6 5cw4AnWqeGQXVivqsSOHEbXup/h+meenJYRZOi/trJkwuLkI6M/05Zo6fovkrLK/chb3 26s1grjb9pRZUY6LcbSUz0J4YGS2y4x+u93keyafvBVboNBUHy/X79UGsZRc/evgzEQu 0fjUKInZpPRVqswD0kMkXiDGAYqoyhXgARb/hJbFQ/Ojs6e9t16O5AYddWjJoHZBFfYp KV/mZLjTkhQZjURDjOOfVBoGWddfFEgvA9tFA88jGD5BrgoUz88nOQUwRP4WZTXNQylh YtlQ== X-Gm-Message-State: AOAM531z/bm/SntQ4Y/bTCMivMrt7CwFAcpdTz99lMm43kr+dKrQXQSC F8384E2j7AWEoqbOMEtyOv5fNg== X-Google-Smtp-Source: ABdhPJxxRX5T2XVObUhBwNopitD5QOQ5LaEDrJ75ibgn4vFqyaiYk50I+mOWW6AvrfKpk1GEYX69Jg== X-Received: by 2002:a63:3309:: with SMTP id z9mr3796396pgz.243.1606424805726; Thu, 26 Nov 2020 13:06:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:45 -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 02/15] remoteproc: Re-check state in rproc_shutdown() Date: Thu, 26 Nov 2020 14:06:29 -0700 Message-Id: <20201126210642.897302-3-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: linux-remoteproc@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(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 46c2937ebea9..e8b901f34c91 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; From patchwork Thu Nov 26 21:06:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11CD1C64E7A for ; Thu, 26 Nov 2020 21:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4B1B20643 for ; Thu, 26 Nov 2020 21:07:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sbYeOUWm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388418AbgKZVGs (ORCPT ); Thu, 26 Nov 2020 16:06:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388256AbgKZVGr (ORCPT ); Thu, 26 Nov 2020 16:06:47 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36AD1C061A47 for ; Thu, 26 Nov 2020 13:06:47 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id b63so2591596pfg.12 for ; Thu, 26 Nov 2020 13:06:47 -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=h359vTbVwJlGrgkdHmv3KMar/l3F6onVc2vwd4+bMoM=; b=sbYeOUWmzzujt1T3Ghu7+LmmnBe3sUsp1le+rTdJX/snuOxA+fsT2eX9h7sYesj/Ga Ut79lCP2xNmRLwkKDupPvx13q/bJFwjdWkeX0WBfwDO2c06litT2gemYS0eu1MNSxVjd cZc4iqYF7KD2Bx+VwKRlVUsaoWVojMmmiu5UAUVbJlfaW6rUIL4Ylv09ej9847yLAelJ XKKtJGlgNN5pm5k37MhiHVI1aLdQc0DWATdSW9BF7ZIvv9VGh+8WlD8dPZ+msbTjf7wU V+m5KtCIW1jBWJiCgk9leRGR0BwYEUh6zVnPsf11l/tKQI7oMvhBrLtN83fvreFpqcaT pZhA== 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=h359vTbVwJlGrgkdHmv3KMar/l3F6onVc2vwd4+bMoM=; b=NHB4nupbDNzU+BMJ+U+oaiHeRwQ2MXwUcG6kv0Jo1xo6s5CEwijLRhM8r0Z0e0WMkm m64j60dBjbEuw+kWWRQE+ZGQSVQ8nLq5UIF1cps/5ZFDKRw/5TM7/i2A8X0QijklDrVW ikmu8ru3KuMWEqAJ7MV+LbTDBa2w7td3In5CO/kmfMc09PpNkyqi8jHyNNcpaYFFyxl1 SC+bSIro6V/Bf2/9f8VOupk+CMpQhmIl4CIcu3gT5FuLXJtRk3o3aNO1OfLhAkflkeNo IVWkuQO1/gLyzB7nx3rlWtH8W6F9OTlkVLD60bFtUCAng0suWXT9HMquZZ2cYIkYMDwm a4rg== X-Gm-Message-State: AOAM532pErPX9QWdmwDzJMmQe/g/XUZpC+rgnuLXvsJvSFdhldBkiNS+ sGKaZ8Qu6GV98j+XjXr2iQEvMg== X-Google-Smtp-Source: ABdhPJwzqu4sZRBg0AdcUdRbfqQZkeSOut+3MNHPvc3f5lLV4/sVzanhL0SJ0OQqsf4lZjbh7mnVWA== X-Received: by 2002:a63:5418:: with SMTP id i24mr3841679pgb.165.1606424806763; Thu, 26 Nov 2020 13:06:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:46 -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 03/15] remoteproc: Remove useless check in rproc_del() Date: Thu, 26 Nov 2020 14:06:30 -0700 Message-Id: <20201126210642.897302-4-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: linux-remoteproc@vger.kernel.org Whether started at probe() time or thereafter from the command line, a remote processor needs to be shutdown before the final cleanup phases can happen. Otherwise the system may be left in an unpredictable state where the remote processor is expecting the remoteproc core to be providing services when in fact it no longer exist. Invariably calling rproc_shutdown() is fine since it will return immediately if the remote processor has already been switched off. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e8b901f34c91..a2b9cd541315 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2346,10 +2346,8 @@ int rproc_del(struct rproc *rproc) if (!rproc) return -EINVAL; - /* if rproc is marked always-on, rproc_add() booted it */ /* TODO: make sure this works with rproc->power > 1 */ - if (rproc->auto_boot) - rproc_shutdown(rproc); + rproc_shutdown(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; From patchwork Thu Nov 26 21:06:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8B49C6379D for ; Thu, 26 Nov 2020 21:07:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58CA3221F9 for ; Thu, 26 Nov 2020 21:07:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DloWhdhc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390570AbgKZVGs (ORCPT ); Thu, 26 Nov 2020 16:06:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388414AbgKZVGs (ORCPT ); Thu, 26 Nov 2020 16:06:48 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32EA1C0613D4 for ; Thu, 26 Nov 2020 13:06:48 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id w4so2553648pgg.13 for ; Thu, 26 Nov 2020 13:06:48 -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=0+MlVHgmuEHbWu07QK81WMbFykiKW5F7ZX5m3RIClPg=; b=DloWhdhcF0VY/YJfNe8pyQgAA5g3RvjuT+ZivsFLlFJmc1DSt12brBDYYF6K2S9vRs bIG3P7cpKQxO95k+uLifbKHxhmdb0bIfmKZcvGM7/JATGLZp7ZROtLA6pBKb0IlKjcF5 odJYvK/aOenHncUuNuMMAfaNV2SnFWTj7Kl0Q17u//Fa9nLgP4wQ9+nlCS4Y3ImdCr+E n0W8QMbll7ZgoZHTFnqjyN+B/KkkPpcU8iBOG0ohtbov03/RPor0xmkKEW6QscjMs2FL pkbXBUdL/yHdH4HMo8Mwq1ghyQYshLkyrwWIg5MVTd/47eixwMWfjPjegoRwLKoL3Mdm IucQ== 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=0+MlVHgmuEHbWu07QK81WMbFykiKW5F7ZX5m3RIClPg=; b=jpmnKXTFN/7FYT3CB3U2P3kSGZYQ3LT57ZExhSN0VXuwKzcxC2+xrNIicDsAtsjwEJ kgehMGaS1ung4rBmiv1AOdk1+Q3+VA9ECMbFqhDSKsnneXhSZWVeeBxuiGS52Mac4APm ev+4eFfV30ZJfSaWzC/kDCoM4UPXdJgmKZdAbLAR6MrFbLWyfMUksjORjlxsmkxA8/YC y9Vhr2gEQWMZrLWSsWoUltH5zNIaAIIWRQBpFM0LYDqVm88MuGDy0k1nwSrrNWWpS2cR ij2vefZjqK9/eFTVWcR3jGndRvKsVDJ2va987gKS9YpBkIIlD6d+eeoQdk+4Y1vM+LSD 21Hw== X-Gm-Message-State: AOAM530td37/XkhqqagNAvXAj8LQQGm1X3tkygVh5a4mm3G/7ApXc8jn k0QQXxWfrOMB9OG/rR5GjA+eAw== X-Google-Smtp-Source: ABdhPJyWc2vH0J0kxI/PS5ohEzjOtAqAqTB+pwudnVkaIBTw5ila8JTaF/nhtFVMlQY6WuulXbfdUA== X-Received: by 2002:a63:5322:: with SMTP id h34mr3777724pgb.95.1606424807829; Thu, 26 Nov 2020 13:06:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:47 -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 04/15] remoteproc: Add new RPROC_ATTACHED state Date: Thu, 26 Nov 2020 14:06:31 -0700 Message-Id: <20201126210642.897302-5-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: linux-remoteproc@vger.kernel.org Add a new RPROC_ATTACHED state to take into account scenarios where the remoteproc core needs to attach to a remote processor that is booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 1dbef895e65e..4b4aab0d4c4b 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -172,6 +172,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e8ac041c64d9..71d531c64dfd 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -403,6 +403,8 @@ struct rproc_ops { * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery * @RPROC_DELETED: device is deleted + * @RPROC_ATTACHED: device has been booted by another entity and the core + * has attached to it * @RPROC_DETACHED: device has been booted by another entity and waiting * for the core to attach to it * @RPROC_LAST: just keep this one at the end @@ -419,8 +421,9 @@ enum rproc_state { RPROC_RUNNING = 2, RPROC_CRASHED = 3, RPROC_DELETED = 4, - RPROC_DETACHED = 5, - RPROC_LAST = 6, + RPROC_ATTACHED = 5, + RPROC_DETACHED = 6, + RPROC_LAST = 7, }; /** From patchwork Thu Nov 26 21:06:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE9B1C64E8A for ; Thu, 26 Nov 2020 21:07:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9181120643 for ; Thu, 26 Nov 2020 21:07:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YTsABqRp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391251AbgKZVGv (ORCPT ); Thu, 26 Nov 2020 16:06:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391089AbgKZVGv (ORCPT ); Thu, 26 Nov 2020 16:06:51 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46ED0C061A04 for ; Thu, 26 Nov 2020 13:06:49 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id l1so1667823pld.5 for ; Thu, 26 Nov 2020 13:06:49 -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=6EKfnma+mEUF1GkkphP1W+oWnMIfOL5ijPUv2Gueq0k=; b=YTsABqRpBrUv2wTyqkbRbGotHKiTQSVNuZBn8ukO/QiQQn8xGaBmh0QOMY2qkJMbQr 0vm9xEg/eLR2ZhfX4gyM81acRWTDiD87VSkos2fuLG2Zv6gips0iOCbTBbJkBKOscKNl lqMB/FoC5kLVhyabqytksx9DD3JHscoxAss/n3sHtVeKo+qdPXebpvZxlQdBbw6Q1ELe VdPB0/kfEY/8YPnyQzvRzsDPHglvWEdRG04zrjdPXr1NUd4PG0so2IDZ9ef8lAYjWAgP 5VsuDPu59bkBTXXbc06j5vQGfpl4QmCWEL985TbtwjZWvnFDj/C8MePmfqIBgpsgQMNN rZeA== 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=6EKfnma+mEUF1GkkphP1W+oWnMIfOL5ijPUv2Gueq0k=; b=aP6jpn1t3gSR/KIbvGYCgrVkaozyHhVaELdPkivpyIMe1EtQZdOK+6XyOQ8SZVmCiy 8/Uv5S9zWB4QIAiGBAX+GPXr9oLyBfRR0VUZzwRdQyL0UTNNNXfH/Le2WlIbI6JF/wCl 9DzKftKPLhXNrePYe89vwdoNq6sp4Dp+fbGAusH8XE6W+mh67r8vMqMUmDIASE2NMIo3 Dnec1S6KYYvpb3dhh20OVhs2FNNKrci0FUg2J51AV2wOZcVSLBQCTOfLcUR6Sro3OE+J 6nnbfVaRUUVx4Dcvr5BIGgAGTY7fZ2nEQm3gWzxOi4umc4PlL94w6jFBy4HE1LnjT7mZ QSvQ== X-Gm-Message-State: AOAM533jUp825FjYIv9H9cte9hwuan7EqAFJLMumuGXJudnRo/nqMmUH KPJPG48Mlo9vEzSMy/wlT6fSbw== X-Google-Smtp-Source: ABdhPJw2oM9EefnZctSpZvt4rZWHSZLeSrJbGgevPPmqTYn0mnqbaYSNnXqTJ4PFC+gXK1eFVgXekg== X-Received: by 2002:a17:902:9b85:b029:da:1684:cc82 with SMTP id y5-20020a1709029b85b02900da1684cc82mr4195605plp.41.1606424808820; Thu, 26 Nov 2020 13:06:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:48 -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 05/15] remoteproc: Properly represent the attached state Date: Thu, 26 Nov 2020 14:06:32 -0700 Message-Id: <20201126210642.897302-6-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: linux-remoteproc@vger.kernel.org There is a need to know when a remote processor has been attached to rather than booted by the remoteproc core. In order to avoid manipulating two variables, i.e rproc::autonomous and rproc::state, get rid of the former and simply use the newly introduced RPROC_ATTACHED state. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 20 +------------------- drivers/remoteproc/remoteproc_sysfs.c | 5 +---- include/linux/remoteproc.h | 2 -- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a2b9cd541315..300785a18f03 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1444,7 +1444,7 @@ static int rproc_attach(struct rproc *rproc) goto stop_rproc; } - rproc->state = RPROC_RUNNING; + rproc->state = RPROC_ATTACHED; dev_info(dev, "remote processor %s is now attached\n", rproc->name); @@ -1659,14 +1659,6 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->state = RPROC_OFFLINE; - /* - * The remote processor has been stopped and is now offline, which means - * that the next time it is brought back online the remoteproc core will - * be responsible to load its firmware. As such it is no longer - * autonomous. - */ - rproc->autonomous = false; - dev_info(dev, "stopped remote processor %s\n", rproc->name); return 0; @@ -2080,16 +2072,6 @@ int rproc_add(struct rproc *rproc) if (ret < 0) return ret; - /* - * Remind ourselves the remote processor has been attached to rather - * than booted by the remoteproc core. This is important because the - * RPROC_DETACHED state will be lost as soon as the remote processor - * has been attached to. Used in firmware_show() and reset in - * rproc_stop(). - */ - if (rproc->state == RPROC_DETACHED) - rproc->autonomous = true; - /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) { ret = rproc_trigger_auto_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 4b4aab0d4c4b..f9694def9b54 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -138,11 +138,8 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, * If the remote processor has been started by an external * entity we have no idea of what image it is running. As such * simply display a generic string rather then rproc->firmware. - * - * Here we rely on the autonomous flag because a remote processor - * may have been attached to and currently in a running state. */ - if (rproc->autonomous) + if (rproc->state == RPROC_ATTACHED) firmware = "unknown"; return sprintf(buf, "%s\n", firmware); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 71d531c64dfd..9be112b5c09d 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -510,7 +510,6 @@ struct rproc_dump_segment { * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU * @auto_boot: flag to indicate if remote processor should be auto-started - * @autonomous: true if an external entity has booted the remote processor * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc @@ -547,7 +546,6 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; - bool autonomous; struct list_head dump_segments; int nb_vdev; u8 elf_class; From patchwork Thu Nov 26 21:06:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DEACC64E7D for ; Thu, 26 Nov 2020 21:07:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3569120643 for ; Thu, 26 Nov 2020 21:07:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oKXhRb7r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391121AbgKZVGu (ORCPT ); Thu, 26 Nov 2020 16:06:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390945AbgKZVGu (ORCPT ); Thu, 26 Nov 2020 16:06:50 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46623C0617A7 for ; Thu, 26 Nov 2020 13:06:50 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id b10so1211867pfo.4 for ; Thu, 26 Nov 2020 13:06:50 -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=F0fzZSP3VuvALU3rn9jJyyj4XDT1VCM3xuR6CeVfSK4=; b=oKXhRb7rgRQ8Ff9EtJYzAcI9JIJBalQFImYaa+IHstrrVGKyeUsId9/pRSs7VBxEpM CfBW0UCgA0J5xT/t90eZ4Xjw4bhCzbfRoQefGUdC5tBNWIMDntsiRYprxSmapZ9Sh8qy b9RRPwP+M836Y8JOcTBdTyjCKDyBG5D7fAzODfc/mvellMd67kKcWmPKwM19l1Xjr5xU ZtDCWs4lknP6tZsneZH6ifkAPRzXx3PNAzhl16fufpW8yQpE2A+s0wPaKZ/HbHr3dD1U 6Q6IswulcAgUChgGeZ93HbyamFASpKZNNhKIMLDkZNInZVMxKTdrdoODNWfq1wi2Deio whcw== 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=F0fzZSP3VuvALU3rn9jJyyj4XDT1VCM3xuR6CeVfSK4=; b=iOhy/w1rEmTykwpLnA+ZqrBjJcr13E/LN69Muqc5ONWNJ/QlyH2ykStPPyAZ4+AOqO kQISzrf09gyms57Meist6gqUhckDuiGO8XXbHTId6yOpVfJcLoZ22KM2m9R6766wwXOd jn/uTQDaF97asVBtxRH3h58qiTg97Y8C4xLzsLtBWdov7qLJNVpFC+35lZuRBWEXXkZV EEUQbQl3RfX82k98Pf50NA8E4Zz5qTwyMHdxejTjn/LBHQS1KgiD2+WQpf/b6u9Eq5Oa fys/xxnQ3KfPGpFkkGwcQbs8GhpKmFZlXiLi9WMRQPfkk6LSTL9NoTUNXXoqhOtivHGo +OxA== X-Gm-Message-State: AOAM533NLVJpLW/pcHNnsk4CFpIdjkK18V77OkFooBk/6jd3oI7De5sC dvdO1sdTIKqq7sb5yahYGn102g== X-Google-Smtp-Source: ABdhPJzXTmqMXkaYZRrrfJKztyJYpaaqKcM7twnog64qKN3eoCQYY3b7rEjmGEl0B69DmTDuJVSKgA== X-Received: by 2002:a62:8448:0:b029:197:9ab7:9fdb with SMTP id k69-20020a6284480000b02901979ab79fdbmr4161012pfd.49.1606424809866; Thu, 26 Nov 2020 13:06:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:49 -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 06/15] remoteproc: Properly deal with a kernel panic when attached Date: Thu, 26 Nov 2020 14:06:33 -0700 Message-Id: <20201126210642.897302-7-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: linux-remoteproc@vger.kernel.org The panic handler operation of registered remote processors should also be called when remote processors have been attached to. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 300785a18f03..539667948bc8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2471,7 +2471,11 @@ static int rproc_panic_handler(struct notifier_block *nb, unsigned long event, rcu_read_lock(); list_for_each_entry_rcu(rproc, &rproc_list, node) { - if (!rproc->ops->panic || rproc->state != RPROC_RUNNING) + if (!rproc->ops->panic) + continue; + + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) continue; d = rproc->ops->panic(rproc); From patchwork Thu Nov 26 21:06:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EFD8C71155 for ; Thu, 26 Nov 2020 21:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD820207BC for ; Thu, 26 Nov 2020 21:07:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QlDvjkwi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391362AbgKZVGw (ORCPT ); Thu, 26 Nov 2020 16:06:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391161AbgKZVGv (ORCPT ); Thu, 26 Nov 2020 16:06:51 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44495C061A04 for ; Thu, 26 Nov 2020 13:06:51 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id w187so2619561pfd.5 for ; Thu, 26 Nov 2020 13:06:51 -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=Cn0y91qgOfL4w4qQFVTrLAkaEhIq3ZfS/ulvB63rzoI=; b=QlDvjkwik21FijsRtONm2P9qN6a6wBdU/grMzD2J2jiJj/XuQ/aKJmTAUuMakW93Ku fo7b+Ok97fnZqfQ+ev5uBT1A8xx/9Jtz83ZxwYRhlOW6YmmcGOBECeDGdS0DZRna4CPT IMwXyfPOOGmh29XJPBhfABvPhe7nxMuAfwPbY9JMPbtn814OSdyX6jnOhPlmPsqPsxvJ 8o43/+W39A6UN2V6CAgf+E+d1aWwiWeubG43kfSnxgCzouK05Ti6vhVugIN9FNGbajWt KZd5yKljQPLJ3dzJtPT5yJgTvomsjkm82sw+MnP5wq+YpGHI37Wo0gOD/yGHTqC+7vnm VX1A== 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=Cn0y91qgOfL4w4qQFVTrLAkaEhIq3ZfS/ulvB63rzoI=; b=iX93YgWIY2CszBoIjVevL/V6h9yIa31QhGRFASSM5pQEAMOVF45vBegOxQdXwkdIth mxc1MBpkiX4T5ZsEz0M1QvgJEQs5r5bjuH9lg0hofKhu1foHr4nq/8XFEYMST5FWQNjt Yv2uzcdSCHQtL8Kf6Dch4D/E9yFHRB9ZW26mwSHKAFi30QMCVBwbh0C4ArUxU5fV9drS H7rxQPNPbH/3xymIIgMnD8ygSM6qJ6aBxstrqjL1hTnvTqeT5aptMFA3f+vYizREZAjA skasJeYLYLVMn4R+PrTF5sfbRIgm3RIoj3CwCiOrY1cASGVpEWem5+ljofcGvTJY3atE qjgg== X-Gm-Message-State: AOAM531JzYqZiaHVxCRuvo+LT84ZOfW+39ytnfY53LOS0d8n+V/xx+EJ sOFdYMmr7mfxaQSxpnfj+29LWQ== X-Google-Smtp-Source: ABdhPJyhivsSapK8gAatVawYRRkUxIj9FAAt+9+tcM5ZiZGitUkHMEuc1SB7OPVJz2qznRoUzYy9kg== X-Received: by 2002:aa7:93b6:0:b029:197:db02:e31a with SMTP id x22-20020aa793b60000b0290197db02e31amr4049269pff.5.1606424810847; Thu, 26 Nov 2020 13:06:50 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:50 -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 07/15] remoteproc: Add new detach() remoteproc operation Date: Thu, 26 Nov 2020 14:06:34 -0700 Message-Id: <20201126210642.897302-8-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: linux-remoteproc@vger.kernel.org Add an new detach() operation in order to support scenarios where the remoteproc core is going away but the remote processor is kept operating. This could be the case when the system is rebooted or when the platform driver is removed. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- include/linux/remoteproc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 9be112b5c09d..da15b77583d3 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -361,6 +361,7 @@ enum rsc_handling_status { * @start: power on the device and boot it * @stop: power off the device * @attach: attach to a device that his already powered up + * @detach: detach from a device, leaving it powered up * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations * @parse_fw: parse firmware to extract information (e.g. resource table) @@ -382,6 +383,7 @@ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); int (*attach)(struct rproc *rproc); + int (*detach)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, size_t len); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); From patchwork Thu Nov 26 21:06:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF6EEC8300E for ; Thu, 26 Nov 2020 21:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7ECC3207BC for ; Thu, 26 Nov 2020 21:07:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Cny5LHKn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391011AbgKZVGy (ORCPT ); Thu, 26 Nov 2020 16:06:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391550AbgKZVGx (ORCPT ); Thu, 26 Nov 2020 16:06:53 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 482ECC061A04 for ; Thu, 26 Nov 2020 13:06:52 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id r2so1674325pls.3 for ; Thu, 26 Nov 2020 13:06:52 -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=wtAqiIL4OGNOjCOWpJIS67EUO5pm7/BCFlTCx9jyrY0=; b=Cny5LHKnxJRw0cPNWlSxQxJLAOqavXYkvssYv+komoercg8UQCRqLL1Dt7dN7w10mi /jK2HtPu8TjYHOvz6LNUomKVqNs56Aeu6E/keXOpMJPmGO4hnrVRc8Th++2ZHOWpI/9z KRcnuSvQkpZvQ1rZsaJjNGubmkPscveRVANqlUSvnzOU/y8VNfcRsxznJk2dQbZXLOLI OlLlLzprXxRgjI65ETsbLde3wmKcelqXo7ApjN07j5dgdWrUh8rupWQZ2+G8Q87vrCVl slY8OqOhgTS/ro3JbICqr1YtfZjJC3lgBJGgTLU4G0Ku3Vq5P79Hhpaqg8TID0lxIqnm p+Lw== 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=wtAqiIL4OGNOjCOWpJIS67EUO5pm7/BCFlTCx9jyrY0=; b=rvmjrG5OIHw6XngKgs7S82qU51+chS5nXL7GuiwuiFjFp7Ip2+XeAGiKbktZsiZsI5 6mnJQcUFgkOlkWzRSv51FModInM/wDHBtG1fufIgYqEYQYCRQVezPBYWOOsOnGp+I/+v 8BxR23KxPvpnXmC8XgPoi0lOlxWdVFb8gWl2hJ72VDG+Rn69VzQJDwwh9wiDUcfx6uqA BI/ljNrk6bay5foVPa/YXmJCHgJ1hEcyh5IuwnY7HMMW6HVM69zh2d7H/80MeSFg1k2K VvNV2G2KqcWXZVKS5318PPzuYeZytVgkulXpD8+NSXaGIzyIzmlI4zgU9Htkyy1D8pu0 6IGw== X-Gm-Message-State: AOAM532gYiNdk/ZWoGLW+LGJzamHbAqZU/cs840gpFti88UwwTQ4GmNM 2/cyKkspJDWMoP0PrBFvXnCkqA== X-Google-Smtp-Source: ABdhPJzXhimwa/OrmYJEQnvo5tzdCrzQIJZMyNWoA6mBeVghxJC2zkl1KMx7mnMTN/Z1vkrQ1d35Vw== X-Received: by 2002:a17:902:e9cc:b029:da:1d7a:f5fa with SMTP id 12-20020a170902e9ccb02900da1d7af5famr4151197plk.38.1606424811844; Thu, 26 Nov 2020 13:06:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:51 -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 08/15] remoteproc: Introduce function __rproc_detach() Date: Thu, 26 Nov 2020 14:06:35 -0700 Message-Id: <20201126210642.897302-9-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: linux-remoteproc@vger.kernel.org Introduce function __rproc_detach() to perform the same kind of operation as rproc_stop(), but instead of switching off the remote processor using rproc->ops->stop(), it uses rproc->ops->detach(). That way it is possible for the core to release the resources associated with a remote processor while the latter is kept operating. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 539667948bc8..928b3f975798 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1664,6 +1664,37 @@ static int rproc_stop(struct rproc *rproc, bool crashed) return 0; } +/* + * __rproc_detach(): Does the opposite of rproc_attach() + */ +static int __maybe_unused __rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + /* No need to continue if a detach() operation has not been provided */ + if (!rproc->ops->detach) + return -EINVAL; + + /* Stop any subdevices for the remote processor */ + rproc_stop_subdevices(rproc, false); + + /* Tell the remote processor the core isn't available anymore */ + ret = rproc->ops->detach(rproc); + if (ret) { + dev_err(dev, "can't detach from rproc: %d\n", ret); + rproc_start_subdevices(rproc); + return ret; + } + + rproc_unprepare_subdevices(rproc); + + rproc->state = RPROC_DETACHED; + + dev_info(dev, "detached remote processor %s\n", rproc->name); + + return 0; +} /** * rproc_trigger_recovery() - recover a remoteproc From patchwork Thu Nov 26 21:06:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECC56C63777 for ; Thu, 26 Nov 2020 21:07:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D2E320643 for ; Thu, 26 Nov 2020 21:07:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ih87xMcI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391670AbgKZVG7 (ORCPT ); Thu, 26 Nov 2020 16:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391551AbgKZVGy (ORCPT ); Thu, 26 Nov 2020 16:06:54 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 483AEC0613D4 for ; Thu, 26 Nov 2020 13:06:53 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id 62so2547886pgg.12 for ; Thu, 26 Nov 2020 13:06:53 -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=r9VIidoVcdPT6TG8AcEB1S8vzNlv34NcmaK246Tinnw=; b=ih87xMcIyK/CenH6KwgVXhbvvw8tPezLD0ZG78w3yD9cCn0wMR9rCfgslaLTF9Ulq/ tYVJG/TSS+V1TuxLocTHO8Vh8OAKEkV57y626AR0S2f98gKiWROj5QlKe88du0JyXGrE 3CcwCYNDqO+LdcgUR6QwSPgDyrZqQmmFtzydYY1GEuXeE5tYiijDI4x3bu4nAmdsaTTt FqSdF+lzXabkuDga5u45z9XBw9N39Nz65+7zuEsOExr3IrkC3Seod8e2cg/epPbPaQN8 SZXCv49SrMGqa+5xI7Qazg+ajGsOaFUBFi/kWoIPsnvGVGDJWACK/iiWli7UmaWOzRMD nM7A== 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=r9VIidoVcdPT6TG8AcEB1S8vzNlv34NcmaK246Tinnw=; b=GatZo+hb/PETwxzCfclrZDT9MOOZGvygAHGiGuUMyg7QdGXcnkHPGbl/VB3+dWL4yM O01o2JmTRh6y/XRh8dxcAlJzL2YQjeTn2BO8Or5ypMt8VFt8T9Uy4RoZIM8YMVLqgjKu /jwtFsce8TYaOUwJl0NfGiXDxOWHxP0+AhwupN/AS5sVBK0B/28kxcDz21qAhKQ3b82C 85LYGRCe3TG3DezHoyOXizFo5k09OK71owDs0zuKmN06FFjB/aKiMozid9w44afqemLp SBqahAM0B8egRzx3dOONUUCz1qqrgKaAU68xtRQ0Nnx85SsbeYKZmgK1fgEHqwX/wEh3 3a8Q== X-Gm-Message-State: AOAM530wUQpNbDrUly+UGe9B0/5O35azqvlBMdbkkW8BNcwUr+DQO8Pu xBA7tmahnR9cxZYfEDutOs618Q== X-Google-Smtp-Source: ABdhPJxjsck9xcTSumLUyPKiMxiLRjKVGzc1w5XgLDB6QXfXHxvTau2XHTPeZAWZIS5cf9Se1VNi3w== X-Received: by 2002:aa7:954e:0:b029:198:1a04:36a7 with SMTP id w14-20020aa7954e0000b02901981a0436a7mr4198372pfq.10.1606424812850; Thu, 26 Nov 2020 13:06:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:52 -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 09/15] remoteproc: Introduce function rproc_detach() Date: Thu, 26 Nov 2020 14:06:36 -0700 Message-Id: <20201126210642.897302-10-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: linux-remoteproc@vger.kernel.org Introduce function rproc_detach() to enable the remoteproc core to release the resources associated with a remote processor without stopping its operation. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 65 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 1 + 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 928b3f975798..f5adf05762e9 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1667,7 +1667,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed) /* * __rproc_detach(): Does the opposite of rproc_attach() */ -static int __maybe_unused __rproc_detach(struct rproc *rproc) +static int __rproc_detach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1910,6 +1910,69 @@ void rproc_shutdown(struct rproc *rproc) } EXPORT_SYMBOL(rproc_shutdown); +/** + * rproc_detach() - Detach the remote processor from the + * remoteproc core + * + * @rproc: the remote processor + * + * Detach a remote processor (previously attached to with rproc_actuate()). + * + * In case @rproc is still being used by an additional user(s), then + * this function will just decrement the power refcount and exit, + * without disconnecting the device. + * + * Function rproc_detach() calls __rproc_detach() in order to let a remote + * processor know that services provided by the application processor are + * no longer available. From there it should be possible to remove the + * platform driver and even power cycle the application processor (if the HW + * supports it) without needing to switch off the remote processor. + */ +int rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = mutex_lock_interruptible(&rproc->lock); + if (ret) { + dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); + return ret; + } + + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) { + ret = -EPERM; + goto out; + } + + /* if the remote proc is still needed, bail out */ + if (!atomic_dec_and_test(&rproc->power)) { + ret = -EBUSY; + goto out; + } + + ret = __rproc_detach(rproc); + if (ret) { + atomic_inc(&rproc->power); + goto out; + } + + /* clean up all acquired resources */ + rproc_resource_cleanup(rproc); + + rproc_disable_iommu(rproc); + + /* + * Set the remote processor's table pointer to NULL. Since mapping + * of the resource table to a virtual address is done in the platform + * driver, unmapping should also be done there. + */ + rproc->table_ptr = NULL; +out: + mutex_unlock(&rproc->lock); + return ret; +} +EXPORT_SYMBOL(rproc_detach); + /** * rproc_get_by_phandle() - find a remote processor by phandle * @phandle: phandle to the rproc diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index da15b77583d3..329c1c071dcf 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -656,6 +656,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, int rproc_boot(struct rproc *rproc); void 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); int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); From patchwork Thu Nov 26 21:06:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7EB7C71156 for ; Thu, 26 Nov 2020 21:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAF5420643 for ; Thu, 26 Nov 2020 21:07:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ROaGQAgM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391771AbgKZVHQ (ORCPT ); Thu, 26 Nov 2020 16:07:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391550AbgKZVGy (ORCPT ); Thu, 26 Nov 2020 16:06:54 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 493AEC061A49 for ; Thu, 26 Nov 2020 13:06:54 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id n137so2625811pfd.3 for ; Thu, 26 Nov 2020 13:06:54 -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=bQf9W2GrtRWRw1UMEUEbP7Yk66JacHQ8dUdbgr755jw=; b=ROaGQAgMsA/abXfS91CGQGGuQokMfOchYq5XVlU/8OU7aCMqmfxZCbQRQl7XA0eJ0e hNi8wP945LU5aw0+vIwQSKhLSZ2tN5y56TbEFyTNBdhLlIdX2MSApMNqqBGUZ4rGU7Ub m6eNo9+EKzc7PjAvaKUPmLPF6nQVZ02qw+0kyGA/ALcn4WkChxnwtrVpUKlUvNPlPhEw KmP8dEva90/SACGZjupGXY7E7Fc+SOunYw4CejxaRbEctkcJxukr0mgewUw6zfFcJazj lmMITQUkIby8vqYFAud7FL4iQWgHRwryKf7JYykGRf2Hb2N4jPpPYBxjOC+yDyba1N6j Xg4w== 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=bQf9W2GrtRWRw1UMEUEbP7Yk66JacHQ8dUdbgr755jw=; b=egJ8NHDA4CDif/R6vSt3gCPWp2F2Pqazod6XSwarfOGJx9y8/juQdInPmssmDQ/Bwo BURL3YtuO5SuE7Q111dNM4IpJ50R1Gfw9ktlfw0KzjWMH/oh1bcOSWZW1oQDCo50hefr 4H0ext7HNpdOzQqSJBlccnQJUatWUVyZhEt6CDmzuwuywjZXa4WMOQELW752gde8X8j2 MZ6lRAd118AbfU35Ee4oUeTNVs43ODeyrBeO8ugHIw1exX3Tz/vjDOMaANQOwPuVby0K J1NkEM7NKzJw5X9BAU5o1o9u99f3BRDXRPmF/h9fFYp/LgIAxYwZ+kjWFdtA4lFYUVW4 UD4g== X-Gm-Message-State: AOAM530PqRs68/tT4nt2eF0dexKzWAUO42afM/oBDbOQqT4yQRcYgYT3 r/jWXZYAFK436YZnxsA9VPOu5g== X-Google-Smtp-Source: ABdhPJyiqSrTkzqO02d3qgd65iKD/t0Xtvxw0gzJxg9grb6KMK9e1UcnP3SJhC57jSCTDfe9r6UesQ== X-Received: by 2002:a62:768b:0:b029:197:dea6:586e with SMTP id r133-20020a62768b0000b0290197dea6586emr4196300pfc.44.1606424813863; Thu, 26 Nov 2020 13:06:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:53 -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 10/15] remoteproc: Rename function rproc_actuate() Date: Thu, 26 Nov 2020 14:06:37 -0700 Message-Id: <20201126210642.897302-11-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: linux-remoteproc@vger.kernel.org Align what was done for rproc_detach() by renaming function rproc_actuate(). That way it is easier to figure out the opposite of each functions. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f5adf05762e9..b54f60cc3cbd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1416,7 +1416,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } -static int rproc_attach(struct rproc *rproc) +static int __rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1541,7 +1541,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. */ -static int rproc_actuate(struct rproc *rproc) +static int rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1581,7 +1581,7 @@ static int rproc_actuate(struct rproc *rproc) goto clean_up_resources; } - ret = rproc_attach(rproc); + ret = __rproc_attach(rproc); if (ret) goto clean_up_resources; @@ -1825,7 +1825,7 @@ int rproc_boot(struct rproc *rproc) if (rproc->state == RPROC_DETACHED) { dev_info(dev, "attaching to %s\n", rproc->name); - ret = rproc_actuate(rproc); + ret = rproc_attach(rproc); } else { dev_info(dev, "powering up %s\n", rproc->name); @@ -1916,7 +1916,7 @@ EXPORT_SYMBOL(rproc_shutdown); * * @rproc: the remote processor * - * Detach a remote processor (previously attached to with rproc_actuate()). + * Detach a remote processor (previously attached to with rproc_attach()). * * In case @rproc is still being used by an additional user(s), then * this function will just decrement the power refcount and exit, 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: 11934757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F354C83017 for ; Thu, 26 Nov 2020 21:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E68F1221FF for ; Thu, 26 Nov 2020 21:07:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fbTz3I/q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391585AbgKZVG7 (ORCPT ); Thu, 26 Nov 2020 16:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391571AbgKZVGz (ORCPT ); Thu, 26 Nov 2020 16:06:55 -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 4044CC061A51 for ; Thu, 26 Nov 2020 13:06:55 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id t3so2558484pgi.11 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=N1U8nXjZOC0ZurYXCXhO8VHoKw7UU2IOk2viCiLD3O2n5Yjv95Nc2+ttqOt4t2TzFa j5wQ8pma07KoPbwgj2TwHsJc3uTwVMrZWRCEPSnQnOlOICptZOl7zw7040kALu2lnjJ3 T/sPcGBYRFIpIuq8PWCfkfqoyZZbPITrbCmQoFBy8YazhsbMoFHx8q8vzLfJy9IhSh8y aR7pIXBwfadEZl+Od2xFYusI8XGGITooQbXAFMjCQr8mqwqTHDzudmEsMH2za1NjKEYe mkgB9NvjnIafHB2AYEykDoGgBi9QQE0fgqXI4DYOKDff2ydZudPtqBU6MK4vDOP65xmw KPPA== X-Gm-Message-State: AOAM5321Fy4ssUVcQVM8dkkrWBRjRBGt0h2d8Rd0RiTPm3uj/0PoNa0W d0pcRe75Gz7n2mkCOFypp5bZtQ== X-Google-Smtp-Source: ABdhPJwGUuAbOIzOOO6caRziz/LNMDGyQXSMWsKQ4a+/0WeKqn/59Q21S5oQRoIAY2+CWy4ggwSnoA== 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: linux-remoteproc@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(-) 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); From patchwork Thu Nov 26 21:06:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4945FC64E8A for ; Thu, 26 Nov 2020 21:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECE4D21D93 for ; Thu, 26 Nov 2020 21:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Dg+HdzxD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391639AbgKZVHM (ORCPT ); Thu, 26 Nov 2020 16:07:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391631AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7606EC061A54 for ; Thu, 26 Nov 2020 13:06:56 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id x24so2613332pfn.6 for ; Thu, 26 Nov 2020 13:06:56 -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=/KGOX9KkEX+n+yFMKTjakVzZosqRnFOWNvseTfllA6Q=; b=Dg+HdzxDV2YNawQ0UhBP6HdLS5ZVfu3mLkvXwyT6jnxsG2wu2G+m7UD0mOxya3fTN2 a9YMPlCBY/rXtrETa0IEBOpG/TCZKmhJsG1jozvA4SM9iuIVszkHSgf+Q9SPAx5DIGCW Pwh61Oz8jyJQb0BuXQy8+l1YJhUgNlq9j4tWrr/dqDZJiI8IVfWCzO5G50b2Usgzcv1W IvWXUq5805Wcj7MwD2WFiInSQL8+Ltpv5QL8ebWvwGCOPUNejoEmFYsIesO0NeSQbimY 1MlVtiFWwIm/l1LjWovvF+mF6BIdiCKp5xTS77fFQLxqNJ0g7M9vSZvDmKQ/9jsQnNsY 3XNw== 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=/KGOX9KkEX+n+yFMKTjakVzZosqRnFOWNvseTfllA6Q=; b=klCL/1gmItJKKDki1hHT274UgWrThstx1UAt+wSCdnC3w9il7f6rgZxTYe0D75sWbT Z1IlwzWuRX05HqiCAfH5JIbff5dWDtW3gvTucYODW/U2hY5K7IpxkL7spYEP4QfawE1Q vnEKmKi9czrrYZKXe0N1EA2z/cTGEayUZpF3KBMZ8z7WDSWJuw3PzjQGSGlBH7CpupiO hCvhqH2snGGQhjYMAlNujDjfMXBBd7Kx+cImkViLgQw0DERM/mQ6NkOWZIOpcuwqCDiG W+Gr2HMdblmMMWCJ7BvYoGyilCRTgwgSVpT4kUWWgZ0tlkgkiNG7NK0T5g2Q/VMOlsAh DYvQ== X-Gm-Message-State: AOAM531jc5jUHxa8lP8YCTfQraXDsRglyiJHkyQsH0adkFvm2r2DXsvc lIVRxQEGGQIr3KCk2FG3UiQ+sA== X-Google-Smtp-Source: ABdhPJzr8aZpx9HBvkaCPyAWEaw6iohIuja0Ntqlnm2c2SLjUUSlnTqjuSH7wdlhYHHiPjrfDzHPnw== X-Received: by 2002:a62:1d6:0:b029:197:f8a8:e6de with SMTP id 205-20020a6201d60000b0290197f8a8e6demr4133919pfb.38.1606424816035; Thu, 26 Nov 2020 13:06:56 -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:55 -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 12/15] remoteproc: Properly deal with a stop request when attached Date: Thu, 26 Nov 2020 14:06:39 -0700 Message-Id: <20201126210642.897302-13-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: linux-remoteproc@vger.kernel.org This patch introduces the capability to stop a remote processor that has been attached to by the remoteproc core. For that to happen a rproc::ops::stop() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 5 +++-- drivers/remoteproc/remoteproc_core.c | 6 +++++- drivers/remoteproc/remoteproc_sysfs.c | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b19ea3057bde..d06f8d4919c7 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -37,10 +37,11 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ ret = rproc_boot(rproc); } else if (!strncmp(cmd, "stop", len)) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); ret = -EINVAL; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 51275107eb1f..3d7d245edc4e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1642,6 +1642,10 @@ static int rproc_stop(struct rproc *rproc, bool crashed) struct device *dev = &rproc->dev; int ret; + /* No need to continue if a stop() operation has not been provided */ + if (!rproc->ops->stop) + return -EINVAL; + /* Stop any subdevices for the remote processor */ rproc_stop_subdevices(rproc, crashed); @@ -1880,7 +1884,7 @@ int rproc_shutdown(struct rproc *rproc) return ret; } - if (rproc->state != RPROC_RUNNING) { + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) { ret = -EPERM; goto out; } diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index f9694def9b54..3696f2ccc785 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -201,10 +201,11 @@ static ssize_t state_store(struct device *dev, if (ret) dev_err(&rproc->dev, "Boot failed: %d\n", ret); } else if (sysfs_streq(buf, "stop")) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Thu Nov 26 21:06:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9033C63777 for ; Thu, 26 Nov 2020 21:07:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D3BE2222C for ; Thu, 26 Nov 2020 21:07:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LlMmf89n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391640AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391620AbgKZVG5 (ORCPT ); Thu, 26 Nov 2020 16:06:57 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE01C0613D4 for ; Thu, 26 Nov 2020 13:06:57 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id q10so2639928pfn.0 for ; Thu, 26 Nov 2020 13:06:57 -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=1P3NOdCqAdCJq/BOuunpYV7qT3SyZVIkKnqupYZ7/no=; b=LlMmf89n/RaE6fIA2xiG8wudKfbZ9qECYcET3zyzPcMVC2R3jZQWZ8m0OZny6TMBzE kr1HA8Fzoz8eoyA3AEFca6Eup4zYcinQuC0FVbLBt3KavqxuptgPUXctZPzVYzcJ5QMV DjmN76HZIt5NJC35aU+IModI+fjoutBo/SGE38ZlQ0LgVoJYfQf+N+15ZPUFcn33WMDG dJ0QBHxlk0yOv1VYcbHEBAAcQy+8xRtzb+78uszO1Al2bmeARNAUbMAYZ6e2vEFqI5oQ svfPdXVQzFEwrgoZ2Whpc/bTJ4+Oxf7x0w8rfRQ62uCBYm5/nsAa7blYl6bYiQTqJqYA CkVQ== 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=1P3NOdCqAdCJq/BOuunpYV7qT3SyZVIkKnqupYZ7/no=; b=IZBd6RSe5P2n/g1lC5VVdbE2kymyrmYpH+O8h5TUBbfAugFTrBtFP6jmxVFOn1zHu9 1zdnbcleHC6PVZhDMjXzgksAH9LpSd4uHMdC/3hq1NsbAvSYBNfvlMNO1ce4HTT8Qb5G NmYYWUEuyeXHqTamsFPNwRUmwNm3w/YDcs445/Ms3B2fc3PfCamMlcYZx5KXEon333Bg vciwqBBmDn2VQn7JdkcJYF67DjyFafC6I97Ye/bTF6a7o9ndllzI3HIdgAgen1qwsVU2 +Zvzkcy5TtcvQ+fIiCuUKaiqv6AiB1tTHQBFfKP9Mcl96XXgAFqoTI4ZwV9Fxg5MmaFg 43Bg== X-Gm-Message-State: AOAM533GVFMaizP5EayifWIEYfvRaQlSHqNdiG83D7PBlcjcrobmD1z1 ncxcZEWYGpY2gJAuTeYBCpv4AQ== X-Google-Smtp-Source: ABdhPJzlp4aXFdip8MwMPU2FTh/7dRG0pw1BC7ipYUjOvGyLn9HOurFQaI4MihAN3LrFK1KK67A2qw== X-Received: by 2002:a17:90b:784:: with SMTP id l4mr5752881pjz.56.1606424817036; Thu, 26 Nov 2020 13:06:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:56 -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 13/15] remoteproc: Properly deal with a start request when attached Date: Thu, 26 Nov 2020 14:06:40 -0700 Message-Id: <20201126210642.897302-14-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: linux-remoteproc@vger.kernel.org This patch takes into account scenarios where a remote processor has been attached to when receiving a "start" command from sysfs. As with the "running" case, the command can't be carried out if the remote processor is already in operation. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index d06f8d4919c7..61541bc7d26c 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -32,7 +32,8 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EFAULT; if (!strncmp(cmd, "start", len)) { - if (rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING || + rproc->state == RPROC_ATTACHED) return -EBUSY; ret = rproc_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 3696f2ccc785..7d281cfe3e03 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -194,7 +194,8 @@ static ssize_t state_store(struct device *dev, int ret = 0; if (sysfs_streq(buf, "start")) { - if (rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING || + rproc->state == RPROC_ATTACHED) return -EBUSY; ret = rproc_boot(rproc); From patchwork Thu Nov 26 21:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0DE1C64E7A for ; Thu, 26 Nov 2020 21:07:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73D3A21D93 for ; Thu, 26 Nov 2020 21:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pBsQ3pXn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391757AbgKZVHL (ORCPT ); Thu, 26 Nov 2020 16:07:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391641AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77426C061A48 for ; Thu, 26 Nov 2020 13:06:58 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id l17so2597170pgk.1 for ; Thu, 26 Nov 2020 13:06:58 -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=BZKEoNhgpUCxk0BJFPhN8SyKdDsMxIN4bfJcnaCrMrQ=; b=pBsQ3pXncC41Q83qq1u3ofxVdrDRk/6O4wPSti+nnYcmiF/ZOJ+H5vqGvPmxtPWizc 8y3XwipOESsOriEGeSxOxbflSMQm4o+Zmj2Tk14XtK/OJ7+4S3LV6hNbruVNDcsVejL0 3I5CJZZVpoIcl5kia7yH3D5fKKpBOVfAHD5gSGFglaYzgTr6wT+ol0kdNyBvyKzWULPA 1zRpvcdUbIxHbgCWet60vwfVRlsnB0mCIl9fX6QZcSxbDEg2EytQI9J75p2Sg4/y79NQ fmRGRnv6MkGS1+KhY6nNhQJVg5BiNov4S0XYjDOjoH/haen8AIlWClVRPfxi/mft/PB+ GKxQ== 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=BZKEoNhgpUCxk0BJFPhN8SyKdDsMxIN4bfJcnaCrMrQ=; b=DDtJ/y009FxnDv5sFbNXCppzugkth3/ocA3Zi3ER5HEF3mLcPkkfIeQeNMF5P68LDo RSFJxstYt44pwEm+H/WP4TuN7JE06Euiiq5HcozSjJEpES0yYSF32NKqdSlLq/ntQaGW oTtEZz3AeOC1hXZtNDbRiOYEufRImIlDPdM7OMa6KPsYZqCnPt7IpaY03keXl4t1Hk8u NXwmJUqQ49p2xk8JceV8pKSV+Y/MoeZiojQpk3GQDjjM3wcxCY+CIbK5xQZW0s86xNAk Q/fdST4MflnSQX04S29OrS0kGf/oEHZ/ATDWQCvxcZnOewsK4/MqenBWI1rjgoAiLUdx lJZQ== X-Gm-Message-State: AOAM5337Xm0vDNsONvjDbp08iOtFshMVOZxbae5jDhrLVPTLcjcH6H3g 330fGCsjjQ1A7IfTXIL6g+/BRg== X-Google-Smtp-Source: ABdhPJx3to5KO+RDOFbdZsmC8iWcc6Tc9rvKooHi7wvnqs33TJvUOiEWWcUokQuvgrRVA0RKL78vtA== X-Received: by 2002:a62:fc4a:0:b029:19a:ad58:b015 with SMTP id e71-20020a62fc4a0000b029019aad58b015mr1116046pfh.77.1606424818052; Thu, 26 Nov 2020 13:06:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:57 -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 14/15] remoteproc: Properly deal with detach request Date: Thu, 26 Nov 2020 14:06:41 -0700 Message-Id: <20201126210642.897302-15-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: linux-remoteproc@vger.kernel.org This patch introduces the capability to detach a remote processor that has been attached to or booted by the remoteproc core. For that to happen a rproc::ops::detach() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 61541bc7d26c..f7645f289563 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -43,6 +43,12 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EINVAL; ret = rproc_shutdown(rproc); + } else if (!strncmp(cmd, "detach", len)) { + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); ret = -EINVAL; diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 7d281cfe3e03..5a239df5877e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -207,6 +207,12 @@ static ssize_t state_store(struct device *dev, return -EINVAL; ret = rproc_shutdown(rproc); + } else if (sysfs_streq(buf, "detach")) { + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Thu Nov 26 21:06:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11934759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 581ECC8301A for ; Thu, 26 Nov 2020 21:07:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05B93207BC for ; Thu, 26 Nov 2020 21:07:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dhODEkY7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391727AbgKZVHB (ORCPT ); Thu, 26 Nov 2020 16:07:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391725AbgKZVHB (ORCPT ); Thu, 26 Nov 2020 16:07:01 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87731C061A49 for ; Thu, 26 Nov 2020 13:06:59 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id b23so1652624pls.11 for ; Thu, 26 Nov 2020 13:06:59 -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=UzN8V164vVCPagQUl1vXLvqIdHPB6vICDyDiG0FXeQk=; b=dhODEkY7e25iR1VREZyGWflNm42VplRKLSKAzQqLjPvWmoR+oziwyu1lHO9za5VXtt RWXv30Cze/3Sce07DR1pqpeJIk0nEbW2rd/rnGWDDOprl0rM6i1al3mxI/NdJPCsN7g6 G+7qnmQQEn4+IwSoDwufkjy2o2qWQ/w2f2MHrMxMNtZn8A3oU0s0Jx+ShugNoRVPG3bm mESv7PczX40OIwTUdQLGnVu5i1Jcqwlq2GTK46kGyiISmTkgXA4bLEsSdwOrGeRh+Gto K50gzxDPoKjQ56K3P+pXbiV6lPpTnR6UlBFbBhH1IharaH6AeIzTlK/GD51vvw8fhg8l +ZHQ== 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=UzN8V164vVCPagQUl1vXLvqIdHPB6vICDyDiG0FXeQk=; b=aN4tSmO5LeOHHg92rcLvRHEQTU4WfOjwsu8/qUzVrmSfcB9Kc9CQl/ekg5jQAvCnpM KCO8Q7PeASPX3wrKr2NOg7rk3IXsIhPC1Tv3hZRG1O47xquCSM9RT5dsiwvo+zqZbMVj Rbjsng7BGsS9tylhrEq0Fz89suMMZQQIB+blJg3/sRz5BMWauPBBNsVayR5bnj8WLuyT AttiTyhhMsT0HRlk0o3gpl9XXEg5p1j4Z2QsIoWjLXbdUiwuCf3LkQelH1mSlMuspEye 1C10ooXp4eVo6vOiy43qcICasBARG5mPpEH04gAVBkgihPkMeOV0lyYJt7SYWL+VFTUw DCHw== X-Gm-Message-State: AOAM532UYfOP2zJpAxeQOuftHVHQXwXBK5d2JQj/RDyKlCXFvJj4IMeg xChfGPUPKechk+AsE1uJcUaAzw== X-Google-Smtp-Source: ABdhPJxxNOks0gg+1lBr4tfFpWk48fjnRO/zPBA/fCTy9l8CZRHMsrBL9px/uFMlVrQQp1eqiHuIGw== X-Received: by 2002:a17:902:e787:b029:d9:f88d:c32d with SMTP id cp7-20020a170902e787b02900d9f88dc32dmr4123620plb.79.1606424819073; Thu, 26 Nov 2020 13:06:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:58 -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 15/15] remoteproc: Refactor rproc delete and cdev release path Date: Thu, 26 Nov 2020 14:06:42 -0700 Message-Id: <20201126210642.897302-16-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: linux-remoteproc@vger.kernel.org Refactor function rproc_del() and rproc_cdev_release() to take into account the policy specified in the device tree. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_cdev.c | 13 +++++++++++- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++-- include/linux/remoteproc.h | 4 ++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index f7645f289563..3dfe555dfc07 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -88,7 +88,18 @@ static int rproc_cdev_release(struct inode *inode, struct file *filp) { struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev); - if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING) + if (!rproc->cdev_put_on_release) + return 0; + + /* + * The application has crashed or is releasing its file handle. Detach + * or shutdown the remote processor based on the policy specified in the + * DT. No need to check rproc->state right away, it will be done + * in either rproc_detach() or rproc_shutdown(). + */ + if (rproc->autonomous_on_core_shutdown) + rproc_detach(rproc); + else rproc_shutdown(rproc); return 0; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3d7d245edc4e..1a170103bf27 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2294,6 +2294,22 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops) return 0; } +static void rproc_set_automation_flags(struct rproc *rproc) +{ + struct device *dev = rproc->dev.parent; + struct device_node *np = dev->of_node; + bool core_shutdown; + + /* + * When function rproc_cdev_release() or rproc_del() are called and + * the remote processor has been attached to, it will be detached from + * (rather than turned off) if "autonomous-on-core-shutdown is specified + * in the DT. + */ + core_shutdown = of_property_read_bool(np, "autonomous-on-core-shutdown"); + rproc->autonomous_on_core_shutdown = core_shutdown; +} + /** * rproc_alloc() - allocate a remote processor handle * @dev: the underlying device @@ -2352,6 +2368,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, if (rproc_alloc_ops(rproc, ops)) goto put_device; + rproc_set_automation_flags(rproc); + /* Assign a unique device index and name */ rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL); if (rproc->index < 0) { @@ -2435,8 +2453,16 @@ int rproc_del(struct rproc *rproc) if (!rproc) return -EINVAL; - /* TODO: make sure this works with rproc->power > 1 */ - rproc_shutdown(rproc); + /* + * TODO: make sure this works with rproc->power > 1 + * + * No need to check rproc->state right away, it will be done in either + * rproc_detach() or rproc_shutdown(). + */ + if (rproc->autonomous_on_core_shutdown) + rproc_detach(rproc); + else + rproc_shutdown(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 02312096d59f..5702f630d810 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -516,6 +516,9 @@ struct rproc_dump_segment { * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release + * @autonomous_on_core_shutdown: true if the remote processor should be detached + * from (rather than turned off) when the remoteproc + * core goes away. */ struct rproc { struct list_head node; @@ -554,6 +557,7 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + bool autonomous_on_core_shutdown; }; /**