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: 333054 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633917ilb; Thu, 26 Nov 2020 13:08:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzO2OKrBU2QQ9BmAL7UYlqyRfx9FLTyfsaxAABmg7qsrLYbL54E3tyCmadq+x8eyp/V13t X-Received: by 2002:a17:906:2756:: with SMTP id a22mr4235642ejd.81.1606424896325; Thu, 26 Nov 2020 13:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424896; cv=none; d=google.com; s=arc-20160816; b=i3nZUfZMtbtbNhL0ofRUbiNHeDWHzv0YJmZMFF2qbdSy9JMcmWPsjvMtFtUTIbzGeM roPq46EcAn1GjSOW6tzq7ij+JPq2IYkkSkkwaEhXCoQ30+7phy2W0xFz3AtxAVThZkju V8rxUu+UdA6xVYADRxceqS7NWFMTi0yu8ICf6j27GqLvS1RzydavNHLKuJZltWh4EV8O fireTWx1vHnnpFWUGqrXPDBMZS7UQaDcP+Fb0skp/OCMYDM10ArTv1/eeTi6P2I6oJcq Dfl3B06GPAO21voVQFoHsCJu0aGohmcWsANOS9LfwO6p1/ZJgQCOobWag2gQ8ygp7LHr 1sqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b8dSpVOpxPRkH7Ii5MIpuEJbpdKoro7QaAmsugruQCw=; b=0qsyIClaAr+0qXLQuSjIvIPpahdoz65zNYtZdDkgx2/SC4z+E6vFJP6FbpoUNld/uR qcfcD0tN6/fzpcu3G4Qwz6qYyshQbxhLlCz/21uX/9OQYBWHqvTRi/Rb+YEP5U8O+s2j 4zBZW7+9ECHG24v0wBGQ5AYmWmXUl3DAJybOEo4r0KgwH6Aa+6VgCeesgQEu+FgQKC+L DeRweSOEh5cRStF8OBF+/RX14FQ5RHl7EX9GlItSIoVdppxXeFICIO9cs0hXslBfF0iP TEiSLt9pXvwt0tzrKDxvtlveWe61K/8gDjwiEtZ5KyJkwpxnxanIqk/D63Bib9EzDLaT q5pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P4PfmXE+; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.16; Thu, 26 Nov 2020 13:08:16 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P4PfmXE+; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387510AbgKZVGq (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733135AbgKZVGp (ORCPT ); Thu, 26 Nov 2020 16:06:45 -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 3D845C061A48 for ; Thu, 26 Nov 2020 13:06:45 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id x24so2613008pfn.6 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=G0yWjhf5tkb1bip5SYMDhSs3fdFw2f/Wk1LrQAqo0LWq2zcfxrmnINt5+yzYbxAbhR Lij91y5uacP77vWPCH4QHQeCWDqFcI24gLjX89dgOTkM2DMytLS0hvndFPN/06yGLCiu ZD7lq0tj3x5pPdfQdAsRY/TvsO6PDjG0B7VdXFedsv5HJD4LH0Tpiltg1BQt6Rtf3soY 3bHLiZHsM7wcMAcprtT5FRbwcwEJkLS4uTf2BF3cld6OUTywpc4nBmc26+YCZGu2xYSJ jik7WJlonnIJvivTFdvC4xKtQ1sUlos1j+fvrfb0pJXqOfTEiThoLP8rtLi/ARHdReWk p+CA== X-Gm-Message-State: AOAM533lu+IBzk1c3cSjUp6iR+1wJ5P9KdsueOrMXO9liDitDOT7Kcvi uMN3AM6t9Pu0wW0l4H3lhIyivQ== 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: devicetree@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 -- 2.25.1 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: 333068 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634123ilb; Thu, 26 Nov 2020 13:08:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWfk9i/5oMbC9arkxIIGrZZ8+q6KgZ6UaoibIEbwkWtCqugcleZrUEC1QhpyQusUMdahm6 X-Received: by 2002:a50:ccdb:: with SMTP id b27mr4216239edj.253.1606424914640; Thu, 26 Nov 2020 13:08:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424914; cv=none; d=google.com; s=arc-20160816; b=reuszn8FBYfDP5huI9v7p7j24r4w38b2OIcOvMo01qWf2jH39vf9rIRPEIz7e9HghQ rw3Gs1xxTjAxiGvfzspJ9P+yLReoeBmUuYd0eN9pfvJDeRoPwo+WdGFm0wem9Fx07xPc Xp94g/8mVES/9cKLk45/l+hMAlTB8BYC0N6ztPy+JErrdsr9rrpbFGGmLMiUR9z0JHr0 QOP4r46HgsaC3fQoe5l9QHHpWxGGyicXWh9lwVR2usBTwIosOy+tib0Q+vlFSMhEnM6j JDBbYgF8ir7WYLMIpmGNcA905iqopcQd4vpJPrpiUbKYM4W6TPkuQOVf7T6N/txrZ1Zh PuVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tgn2hTBqiW955JL5NPKA45JX/FzuG4XGgD1c5/FNO0E=; b=rHH3wMWAWmOQdwcXFTIqJmlfS8fuECsmG8FmduPrVGFOsi/Ww9DgHH4Zd6QsVIRNic SUJHh53biQWXWbsg0gm7/kvSKSh6j51zTPR8+g7zB1g3DxaoaUAtP3LJOnNrHEDzbCgH sIkY1ZL9nG6IHlT5vhLQsiB08hWkpArr7YFXDxBSamnrrEVZgk/vc27wk4iZsnVS7Pd8 Fa921SdumOvMU87wkmQERoY+K8kv/XoiXHs9VoSjl3QJkADJlhWTCWcCRRkdKHSxln1w yq1FBx1cdmCXhuoMJCSjepzcdXr7VWsByliPR3MM24Cf5fkFu/XwrgNYMFlMXwDZlEDX MJ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EJgU0yrf; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.34; Thu, 26 Nov 2020 13:08:34 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EJgU0yrf; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388521AbgKZVGr (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388418AbgKZVGr (ORCPT ); Thu, 26 Nov 2020 16:06:47 -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 2765DC0613D4 for ; Thu, 26 Nov 2020 13:06:46 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id b6so2607725pfp.7 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=qOj6bTQiVHR41RfICSv230InunT+DOfjA/kErBtdMyfCTJjKFQKpMaMNz9e8FnGF/E nybFRcw2GDO67+xYrcx+zriU2oftV0FJBlC+Lt4zlsPoeAS3x64rLtHEIipVOEw3cMRy 483AaA+NQi2DNCureZVSDiDPl7oSeL7x0z+JygZwuySTB7i96a8pRxUk7UAqpolARIpd vHdPgh9+Ou/fSvCEbxkFOV3AY1QF1urjad827IDvEDj1WYlBTsOLBa83b5OKo9AuYoBC mZ/9bnTp4Wu8+b2pJU+4TRnwJsdIv+UNXniX7QFj8T7rt3Wa4bOkiORuSI0UxY2To0nS CUMw== X-Gm-Message-State: AOAM533W5VjIoYiK/rLEoJmjRGgMaz2a/J9l14Ly1vDXKPGIP490dJZ7 f5lrxyQjI6QeXspKzOxqDqG1Vw== 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: devicetree@vger.kernel.org The state of the remote processor may have changed between the time a call to rproc_shutdown() was made and the time it is executed. To avoid moving forward with an operation that may have been cancelled, recheck while holding the mutex. Cc: Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 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: 333066 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634103ilb; Thu, 26 Nov 2020 13:08:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0kWLYmEja5rhRt6XqQXEc41tnuZAe12TZXqs27fMBwF7wu3qoW0MBQQfeC+0SJ0h8LUbP X-Received: by 2002:aa7:da81:: with SMTP id q1mr4357167eds.14.1606424912434; Thu, 26 Nov 2020 13:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424912; cv=none; d=google.com; s=arc-20160816; b=fcg1X/iuM6/j6SeTfc6GLGDaOjTcbXRQ7Pqnt2NI4YEakBEnKmrTsxQaVvPz6N9xlc 9zwPDhRCaobJo1F+LftmeUEpRvwwlHRhbiEwkUx96/9rxLuBu8a/W0H34xt753IblYjo TUL60WgeL94F/CzWiyzHyVzEaHYPwsCb+LHlG+HdIHL+lM6JiiwPEtoRGo88f9tyddMS RVOrJHqFqP58UcW1jvowYsOEqPYZ2sV8yXWCMNLKIt2A4ihAhGl184G9GZXjXaIkhRtV nAEfIv7w5EF5Xm/jxnqmOMW/0MyJY2oO6V6r55ytIbK/6aov03CxIU8ZF7qaVZ6zhlSJ oRfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h359vTbVwJlGrgkdHmv3KMar/l3F6onVc2vwd4+bMoM=; b=FohpgdZke+nQRe4mU6R+6NEnvbUNlqvyUKKrDDsHbFGN8rjNCA0B3+8DUO/NLLy1xw tCk5zugqaPz37W1ghCRFnaFK2WeR+rLLHrNUp63BAoK78ePCgs4LsXSL8nNvCtwJcT4j 41RsgpyfF7FP+U1Gn2SQZ/7tYWhPL3EJ8JfJ+V6OvlD9YL9qROuny/EJxpGIprEMMy++ ZtM0moDm2JOeGDmlLMXzIxerlib9yrHElap4zJCPUrRrXWU/oJtXV5wdKn6kMd6T502N 35VCQ0q0FiCp6j0euZlnbmTn52RsDIO1t7VrqKYLqLIH4PskCogG5GaH8Fm5/KG5VJmt +alw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sbYeOUWm; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.32; Thu, 26 Nov 2020 13:08:32 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sbYeOUWm; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391780AbgKZVHT (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:19 -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 S2388414AbgKZVGs (ORCPT ); Thu, 26 Nov 2020 16:06:48 -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 3687EC0617A7 for ; Thu, 26 Nov 2020 13:06:47 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id l17so2596863pgk.1 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=hteJ2aupVbmKnB/mg1ekUdav/TsFh/+4nb/GWcDTJqut2iuFbE616oR3AtHQTrMW5H 0j5vjTNjv9jmXuEJbg+hMyC16Fq44OmBQ052xv3pQoX9/ShGekgsoasGIhGW6wpVS1mX 3Jk0LYZHA9cW5NWl6w5ob9WYgF+QpWiTc6CnhBhotQX774goTuJCd+V+CBEvjoRlcs5o +/sRq23GFjG53jnDhTyIq0cmbd5BBEu/z627qA4dyVWXxGaK3dd1UbADdY+dn288OYYm Y6h0Ja9r0vVvbv6SQATUWZmYViKs1J44douzdyleBM892P+XzJCh15+WT9LgP0ln5OEl 0qVA== X-Gm-Message-State: AOAM530ub9y4iuSBN5CWc2s3aPcfGt2YCep6qNpYrQLTt4PdSFPrHax5 /iZ623mzVA5HUvxCQZ1MYhHp+w== 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: devicetree@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(-) -- 2.25.1 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: 333067 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634109ilb; Thu, 26 Nov 2020 13:08:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJw385m0yYhHZ8EH6AZxNZraUpuPezuQvw5EXHeLVj1Z0zmiwq2b3+3yp8lzEuG4E2TuD0kX X-Received: by 2002:a17:906:38cc:: with SMTP id r12mr4383105ejd.277.1606424912865; Thu, 26 Nov 2020 13:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424912; cv=none; d=google.com; s=arc-20160816; b=tlrNspeAkruLiXZzT4Zxw+PHPxLPuY4Vm6HHHZFtvKyDwBhYhqpAJsy3CkFqea3n3f c1278hb75fbhhE/zlkxfMKwnOtoEc2goWv0SXu3Geqwc+NISxaw191pPFP89r9BVEZMP m9Gc9JSLoVjtH5yl8AS2sc4QCSerySJatv46tSxfmlFZ27meYgLzXOTkR7cFKcH+6cq6 OwckIZ+Ip/pcpx6FqpPCR+SjjofTlntVjckzBY++MfWuRzloPJjBDiH3hgWI0joWBwJD 98CutBXEpwbShUP2Va+ywmtey7brSbe3Z4Hxqo6t81fIQeQHNKd3NEna6S4FExqJ3+/S E8Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0+MlVHgmuEHbWu07QK81WMbFykiKW5F7ZX5m3RIClPg=; b=mJwQysp5yRijOU9Fvc9ekdvXRVqsGP5dKy3QyJ0Zo4lsL/nFMav9EBCq/Jjuhm2Z+u 0gyGT1SbgV8Fv12e5sjvxpuzbsRwCeSNVZPkqT8g90rMtUZDR5mz9z4YIbRc5AF+VIIj uDmxRox7IgDCuhQ0KzleKzxStLvuPOj2gXxMJyGblr5158Ob/BXPqGX/58Nhi3ZoI9ZN VBf7ICshguEDgY6cfwRB+CVqXDy2tCySoJ3lXFegWOYTcStsHbSBFQZNzuY1yTNvCsfc Bpzmru8gh3js3YpOVhKL2J9gm8U7SAY9M85sad1xzFFJTRLiA0tPiNCizQ6J+abaetmp sYGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DloWhdhc; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.32; Thu, 26 Nov 2020 13:08:32 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DloWhdhc; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391385AbgKZVHX (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:23 -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 S2390233AbgKZVGs (ORCPT ); Thu, 26 Nov 2020 16:06:48 -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 34515C061A04 for ; Thu, 26 Nov 2020 13:06:48 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id b63so2591623pfg.12 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=K4XHsGUly0NHuLb1j+l7xy8278WUjWiejnLPiOtCUZ6Gkzvy6Jz27sdEOLNRHzBDS+ QIj0HwYbETqu9ECm7LO9Ti8Ec7KO/1Tq/LjU5Lul5XDVwQs6cp1yfZ0BtpETWfw1IFB0 J6g8d0X45p04Ofop9bvsqh1x9DnNZ9ylMmZ0bT8ktvFGYxaSdMjWsUCnp9CfD/HuX0st e0jzSG5kAB+yUrtg6C5vLLc13F1gmkSh14gOYb14P/AW6KV2Ss7aV6Qjn3iwbmGCvRz8 R89Q+JWu/a5xsfY2/z2kRmPHEpNqmNmh8BiHmRKDxt8nwocxadcdshnaTuclizD8O7M4 1syw== X-Gm-Message-State: AOAM530BWOh9RmiXi+8VwnZYT67069rvSJr8Vrq0hzsDudzLScM2FyF+ dBL4PiJJzgzTICQNLIY/Yv/d0A== 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: devicetree@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(-) -- 2.25.1 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: 333055 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633931ilb; Thu, 26 Nov 2020 13:08:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxTq1oBSakzBO8ybicGaS5hR6degqFn1TVjCGMS7Hw3dKMuuQmMA7m3PXiP7BVNz9c063J X-Received: by 2002:a17:906:468d:: with SMTP id a13mr4448234ejr.253.1606424897690; Thu, 26 Nov 2020 13:08:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424897; cv=none; d=google.com; s=arc-20160816; b=Wt2VdkJysO7rqDPChtleXke63MUMEdVwclumIxDj5pOz4BNJ2tDbUia9FPLnbQP6Z2 1HWdh/oHDszShR3R+549+hQoIhTp+YmzXFEC8n9kDEVbTMG2bzCMi2S0K4Tssz3cdKcK UBUIrdVc1kceKpDOY7BPchf2IjD204DQ2sEWJCiQVE45eiuJQZJWytE6zJAWqpN++ULM QR5Nqi2bzCiRlwx/YRgYu60pVgLvS9fTHzAAQi+LzdOWmR+3wGqdaVCrKGxsHvk/EnzG rXxcurhFg605XO3GxQXbieAjgyVU3G8dyPNxA3NfhgXSNYYwM8rO3FPmD1F+UuP+CFgi 3lnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6EKfnma+mEUF1GkkphP1W+oWnMIfOL5ijPUv2Gueq0k=; b=g6B8lJ9HybDUf+xODHRdVDbItwyuQKWHWLIjgwMBy7j7sGUa1BPBvzY2NEaRnNzXvN jHjIcz0QuMG6V7BRlIT1H1WbX17h4ryoE+CkxLp7cjHUMZ0GT5skZRKWmczeQMO38Nd1 ZaoRQsnQxLiSbkoYFy62C+0ybhFEqV3FU1E/VakQ5rbytQtwrJ+a3ziyIOL3J27pmxOR uCRK7c0NgDW0TKixSAR462Vkmm4+8VWpt9sx1ulwg65kT5Wmpmin6cDcwBdWAZ6eHfGK l3N7wPAMMc+1beGFAdfF6YDaHC0LvGztvukJUi/e0WSjZGEaBqBMlaZTTaEojAerDds8 KhnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YTsABqRp; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.17; Thu, 26 Nov 2020 13:08:17 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YTsABqRp; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733136AbgKZVGt (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390945AbgKZVGt (ORCPT ); Thu, 26 Nov 2020 16:06:49 -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 46010C0617A7 for ; Thu, 26 Nov 2020 13:06:49 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id u2so1652275pls.10 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=WMuQN7sNXCL9/oySTfcm2WVs6O4g5ObwqQ+e12J1u0Eto7AdH3f2K9vIpKm9qDGKj4 T9GJRXjjnXuIcVuFrUH/pvc+e3YBlnftIOSvnTOMugZsAAjBX8xSPXcHJLlPPbh0S0qf bqBxom9ppYxARr4ZpKQ7l0D9xbT8EEyKnK1tptUI+o9wXvvntFRYoxjz/YSiaiAgc/SF 9NbubVMCZPQpRKW+mMuuLNA+TTFy15L9XFKJaA7yXfN3TdTV99Ga2+jdENwK99DSpmq2 txVTsOx0J8ZbGayN3DOPfKV0iNAIVaqeNbRpMU0PNu7nHcMdeBBu5QE2tc05loJCeUc8 Lh6Q== X-Gm-Message-State: AOAM5326ojY5OWx5dzDPg60GXtxcMPECw/XaXXj+e+UXZrh6ZuaFH+r8 9HsUb9LI3U4HN++ysFuk4CGygg== 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: devicetree@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(-) -- 2.25.1 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: 333059 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633982ilb; Thu, 26 Nov 2020 13:08:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyee2d7v9M0jQ/+1XfUNdXpjankoS671aLOi4btM91shk4/t7CVVo7u1PapryqxrQs6NsCh X-Received: by 2002:a17:906:a448:: with SMTP id cb8mr4238839ejb.365.1606424902218; Thu, 26 Nov 2020 13:08:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424902; cv=none; d=google.com; s=arc-20160816; b=XyGHi97olXwOlOn4pPWLyckTbqQcHy72HODGTagsBOHnDLkFw8YXw1e8P1/plIwj/a V3oY2FwH9KWk19wJgk/ZowVMTpz/aTTzGU26H4jVifMRRqUmMEmoApjiKA1SGqj4+QDj Oy5RIzTiweQ6g0kpl3K8QpLqEbVkXgR5DGO51kP1ZTRMNk1/ZbWmvNpp7GvEn0xgcYf5 vrGRDZMIJu+VOnBZ5rbv1jk1IuqQlP76fkBRHvgY53lfy+2yeL0yLexojCLBzsAMOqkm Zo71iJRi9tLYIvY5J55Dh0gBpqlFnqn1OeBbmxs4MS4fZm6ATiGFpAjz7YHmeWoFM27y w4Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F0fzZSP3VuvALU3rn9jJyyj4XDT1VCM3xuR6CeVfSK4=; b=shh+bISgkvipdsskE6EFa+xWqjJDnKx/3Y4kFSltRU40s2qsfUb/4l0MLJ7HnNWNap +6llMieD1OVdWxbYkT7JgJYTF/oP4vifwmzkjivD5QpUFPJBcxXSRv1Yaosdgvajcvel h/uiqi1VWHmAlLafupY6Mm37pQfbiWFCfZKsRDBlgBDWIzcG8qsfJRwEGYfhimIATbqs n0j0eNT02cl5s1ZLZxi1O8C6kmsesi/XrVzqgWIwb6Xg/QjLBDQUzaixo4iFaeFxhAnl aIa16+dGcUpXjrGVBILmJZDRUDe/KaRmZo+fJ3aCnBwH5cJEtOt19vivkk4q+3s2QBvm 6xzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oKXhRb7r; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.22; Thu, 26 Nov 2020 13:08:22 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oKXhRb7r; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390945AbgKZVGx (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391232AbgKZVGv (ORCPT ); Thu, 26 Nov 2020 16:06:51 -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 46C1AC061A47 for ; Thu, 26 Nov 2020 13:06:50 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id s63so2566651pgc.8 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=r7Bim69zFoyP09/eAEgcBaW+e4nWA+4IunJzypxtXaWSVjEX9X0jQ81GimyonmGVkW hMybJdHKBONp8UZo18IRN0PXxpsnIqhUMvtuBdys8V7B0/OTQgOtJEKgnpKDb5p7WCtd Hd1+p6195fAitkpuLq3e+NfnChgvRg599jLMbIWvSC+ODMpQ3ZRjNNH++rRzUB8QAkPr vi9KbJdb7JoykhFqgmAWWPm29CcI8mgiUXd3UL2Evttsn656JZOw5banngaGZO3aznRP 2LUD1CDPvHNILpnk42j2oSSt+XIlHK6I7KivYbeIxStqXaiPFCwgPkcWzkkQ9ZHJytpQ NMgA== X-Gm-Message-State: AOAM531rTOAv4F9oHVnOPJtv1dUePSxintEC+76T1LGvJ0RAy1T5jmI+ c4pD4+y7qX3dcgmbZl7leAvh977dOQahsr0o 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: devicetree@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(-) -- 2.25.1 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: 333056 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633955ilb; Thu, 26 Nov 2020 13:08:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm0Tbo1SCiE0meXSr2t61lejVhkK9gHHenD1QB2enm2I6IJY5UoolyWel2rNRaPDpj/Ex4 X-Received: by 2002:a17:906:a047:: with SMTP id bg7mr4391641ejb.30.1606424900188; Thu, 26 Nov 2020 13:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424900; cv=none; d=google.com; s=arc-20160816; b=fxlbCiR/phIfROchKO9cb6NBYCoMTBabZKsOMbG6yIDx3ii6ArZFPNKZU9BDWOnqyH xuB8IcHIoFX8L5SBA/mtOZLjJ3ZoLJtTCI290Jv12rNRY15RfpE5xUqmpy0v+PQPlIFH grqcL5uqHfMLHiJdiShvoCYX8OqzxxoL14755a/eaSITUQFDgecnHUz2qVjdCay743Kl +P3D5XM9zVHzwY7XNosJXd9KFbpDsBb06yFFCvma61QggpxxCBayUQ7KcEyu9XI858Y8 jJhskLWUGZ5Mf6En+uPXB8bQB4cZBheU9wAJvux8fOmS0NhWDbC4N0D59of/jV6Wmp3w /KiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cn0y91qgOfL4w4qQFVTrLAkaEhIq3ZfS/ulvB63rzoI=; b=Agcwv3Mr3kGVzPaPvPo+Ww+SEJLAJBODj+zEkOJKabVz9lRvZ9V5vCHma1tGj2d7Uo F+OcfXbAA0mcoU2D/iZRkDYDdkyrw3DPLFu3FZJFhK2jZghnQdwVJLuOLF58Xk/+9x0K fme8eJCESoetI02fQ4AZkzmuaKQOIapby/rUrCygVU6GvlEXCpVvklj6zNP4kRlDewAl 5gusjePEudFGncBK7nKeAuF8WTyFETj307d2GzeEmUm73a9by+qx/TwvM/Oz9zQIyAsA PIZCTAdxH2kwH2bLwvRSrxpiGj+N/kcgenMZzWe/YAX7YFTYCx7Xarm0fkfW0V9t6q5K rdsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QlDvjkwi; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.20; Thu, 26 Nov 2020 13:08:20 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QlDvjkwi; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391514AbgKZVGx (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391457AbgKZVGw (ORCPT ); Thu, 26 Nov 2020 16:06:52 -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 42D03C0617A7 for ; Thu, 26 Nov 2020 13:06:51 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id q10so2639756pfn.0 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=qp6N4QHZXHkRGqQ5NrbemwZbZBWD4waWC/SK6JmKkboT5klCflZbntu+CFQLnsV6cv LTgWBpgYNJ1HtCsm+jzoAtSjTFN/9Y8DWrMsU3zOsrEc+NHeBObgRRtjSaXswc48TT7d d0VdLR0VX8yuCVPyJegCfsXHoP5s60lFXjwKfbbv9YQX+8IixmBdEGj+yUJsAo/Ch2mV QrwroyLt+uVKNEmZizMCT2q0KJtYxcQRwHyQLrnACzaRsaXBBUOzsXkuaCiMPto9msZi grBpIXUIZxqHWK0AbxEOlizJCTwTg54a/LHl0kcC0TFqtvznqGIiN+m2D3m26YnHDkVx X6Ww== X-Gm-Message-State: AOAM5331p2oxqW1buSGEQfgUyyAMCZBoknLKZXePzCEmYA7Yq+Kt0x2i NKjyFd8gZdyFCiby2rEBDe4QpA== 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: devicetree@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 --- include/linux/remoteproc.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.25.1 Reviewed-by: Arnaud Pouliquen 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: 333057 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633969ilb; Thu, 26 Nov 2020 13:08:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOJ6F3/wdZiWs8YSnVgpsZ5a9Hz41PCNui89nmc0Mm9bhIs3H544cQ+VxDPGCYPM1bTN8c X-Received: by 2002:a17:906:138e:: with SMTP id f14mr4384897ejc.370.1606424901315; Thu, 26 Nov 2020 13:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424901; cv=none; d=google.com; s=arc-20160816; b=frIPgJoov1MTuvXteuOwiM6T19g4oslqRxQwJLWAMU70jtrn1rrabsjjddUrsfqee+ f+TZ0uvzpYOUj+3ps+n0Fa1eesTMBFtbgZSQGxJRzhQPRfqM1PEQSo2BMRqMPDVqshkU ZloVFhnueY9o5TMoY8dVvyH4gZ1zQWBAc2dVniauEnE2NMwMK2FNPuNTIqga/KIWfNVq WXUR3VHbzIdsMJ55Gw/qHeniEACKLZZcS0jkx0IesMknzDdUzQiQikVLBkCyg1nIVWay US+tRahnBvTAKmH59qZ1y2rutvh0gZT6iPPuzzWTai04DaVtNUvT3aAB5xQL5NpetD8z s9dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wtAqiIL4OGNOjCOWpJIS67EUO5pm7/BCFlTCx9jyrY0=; b=odNcet7IucZhyVKlLWv9dZ6Z7lLjSZVmUV8yOMUT3bfQDO+eh78ta1hEjSeNhZnIwi HPywg1UYtIU+LJY37M9NbxBgna5dXmL1NZTjgXSvfQ3vX8hO4h3KVoDEqFg/pA4SpHZT SKumvZJTEfx7a+MYnQqb3EmRZP6V7ll28ZJ203/LGTqT1/FQ5Y+akjwwRyAJT8qnWPxg PKS/eLNVlVMXH+RW7tWlgPIsy7V72rcscEKSWcqW1sZUbF/QcEqipCy3w9sfNgH8HtZ8 GoB6t0bTQ14nmG3JnscqyL/sKdj1JYeLWEGr494joHD92+HZYyozgZl1jrNS+nPjgFlc 6y9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cny5LHKn; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.21; Thu, 26 Nov 2020 13:08:21 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cny5LHKn; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388623AbgKZVGy (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391551AbgKZVGx (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 49312C061A47 for ; Thu, 26 Nov 2020 13:06:52 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id b23so1652471pls.11 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=R7PBnrRixsdHljB3F2X5u8biDTrxyeZGkWghNzFsnmpWJqx5DWlOrG5T3mkyVhOdi2 lJlFWIMfaJrmKMVJrE5xeq+uVwFqCIl7aX/zbzD+L6rkiqBUi3mckWcFVmlBj247YErT /RZPE+TP5pyyhky/eFuOYLZHP8NvsFnNQNn4CprJTM88l6uq3smEEU+TFHkw2PQudHt6 I4tU3pSlizo71nFKixKx1FHaIfaBhHQQTaUKO/e3JbxfxBrH0SDYTM+LGBjp4QxlcKe5 39ft5SWTh0FQhoQQreN/i/NpJC01WBCaZq2zjefa/Xjv8g95lJNApJiNLy5dZ1sjwXmx Qxpw== X-Gm-Message-State: AOAM5338wY+wUJVXi2tTLf+QyYwxMVJMp3exHFx1efvKiaxua0U2bP3h TKRlN9O5ZZXHXpwEuN9hmwFGAg== 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: devicetree@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(+) -- 2.25.1 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: 333062 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634057ilb; Thu, 26 Nov 2020 13:08:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJAXQUEA2GC2u7nuUp0U86rOwRRYAhnD8d7/dYeoBhBS/cdxiUOYchJv6KB1/vE0FuqQk+ X-Received: by 2002:a05:6402:22ab:: with SMTP id cx11mr4275319edb.98.1606424907784; Thu, 26 Nov 2020 13:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424907; cv=none; d=google.com; s=arc-20160816; b=wRlz7UphtK7DCXUK/+40ecWSpYocMTc+Ogk5UKzaxhLtIRSHMc1ptXoepZy5U82Tbp OaD3WxiL/eyLfzuc3BMHWmhgmHEAq+ze62NpCovUB4RrPvCo6kTFzqzKsBwyWybF/V+1 uB9T9SATgR7UquF9cG4qZ25sB3ryqovK48KJ4a4wt+JF4T/FuJho058zMuw0EEQq+N17 svTxQ4mDvlA6CtjZS5bQVjDmL8PtZ/46aWqozXuFvMjG23rkrRIM8XbTxvhSsEohbyie BPoeJMlis6y2NIHJwayfE0WIjsVOQHdPol9tnJSZVFhQry/s5JVCvvEz16mgDzRc6T7t 41Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r9VIidoVcdPT6TG8AcEB1S8vzNlv34NcmaK246Tinnw=; b=KqBbay/tQBeshH828Bedjrm8SDthRjK/lsK/eNgn2pK7ZwIOwReFnlC0YbFFMaITMk Qjv2XAuQl2OLqlzQJp7TmyeJcBNzC0pOdxe5XGrQn8L5BEC+Q+WjiaV24b9gundJJeKO UttnU0yzWNVzaDnz/1satUI1Glhd7PwVPfLMkPJuRDozRaH3y2vUNfqUp/VLZj1YkIko F2GTaDtgo+dyukK3Oim9CgLOg4S00YLXD+XHRu2TPK/Nn7K6eqTWIBhg+bw6JctBWOER PJ0uoMeeqUqJfwotLOifbzNL8bwMmt8tNnIytXxC3I5tosRl56iCr3oSxlhk2792+d7/ zoiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ih87xMcI; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.27; Thu, 26 Nov 2020 13:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ih87xMcI; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391665AbgKZVG7 (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391557AbgKZVGy (ORCPT ); Thu, 26 Nov 2020 16:06:54 -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 49126C061A48 for ; Thu, 26 Nov 2020 13:06:53 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id 34so2561068pgp.10 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=IDk1wbHPOJAog7xXtz6mxWHivVIUPMDUoM2wAiWladJbahsxOhofE52rLjYHQIIXo7 +d167oEs12+xz8jqCDgZeloLDKqhLnDBkMsKvFocmhSHGERiFf6uQBZCyhZp4dLTL5Sx NmGMJtNTVY/kdPSHoapiOQtxR0EDgj8U4cU4U026+WsKE8QAADLWjo8hVt80UHvPpjJo G/CfDpab990YmtNIC6e/nzM7Y1h46LIN0wGG2XHsVo3r3SrzchJb8DuvFA/N3vPV2SyY bJCSRztDQajYhIPbfUtg68sas5EqpxlBLvBtwGVGovTHXWElxQ4UB7yCzdv/hduKA7Pd 8frQ== X-Gm-Message-State: AOAM5333bDpZ5+/r1+PS1xPAg4QhtAfWx9NREPRRW71HTKlMrX9P5MX5 fpsJJugpNs/I4ljFVao+0TcBfA== 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: devicetree@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 --- drivers/remoteproc/remoteproc_core.c | 65 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 1 + 2 files changed, 65 insertions(+), 1 deletion(-) -- 2.25.1 Signed-off-by: Arnaud Pouliquen 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: 333058 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633975ilb; Thu, 26 Nov 2020 13:08:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDkHqyULBlpUms/l5CXHtFRt8CcgWEk4wk+g8VZvOS7fYKHxLZO6RIeZ01EQKoO7SreVZF X-Received: by 2002:a17:906:468d:: with SMTP id a13mr4448424ejr.253.1606424901748; Thu, 26 Nov 2020 13:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424901; cv=none; d=google.com; s=arc-20160816; b=fLxhGA+bqKk/P2GGG9U53iq8r+V2C8U7UTpOOsQtp5wNb4VDqoAZTOcs/JC9R6BOu+ C+HZVOG8L9iHEEMhvLndoMjdfOsayi5ZHTevpJO5hByP8Crnsjl+C1PTAjGCftPQcxXk Z+jcy78lz2sCk1R+MbAk8DTiVv8mZh0pgpdPDj3Ibbt1TQQpabsvOV/8qgvm1Tvy4VN3 oTCo5VlDdfSEKXyiaZbsdRWP+0XYGchfi7VItDkVCnGvA8PcWg2MBUoOAJHc2gkleVQb zCHOHMUlsORiwQ8FSgKbznUwGODshgxQAprz40wlJQK/35SF7bGomc4NsmODRYGf2J8o D07w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bQf9W2GrtRWRw1UMEUEbP7Yk66JacHQ8dUdbgr755jw=; b=vqi0+M3vKX0KJOnOOKBJi+1wrUwhiM7PTtLNAGeOF4GpUO7PJG+/9C/kbsN8CHUu0T gj9ryPWTFrZIWth0tZywCPxLaB8kpULbvr/GpeGkKA4VKhSUT+t2az9MLTR3gpp5WRU7 Vgqde/DTlwI9aBUopFXFFEEifwVPRZqnLJ9i4894CoHsgkIKZYlFCE/KAlVkcv4QrVxg RGDzyqJboiZmcTZU3Yj6gMlSA6oo5FTwxBL+8CuRVP9MlwFOBI/dQi/pWHoO7xFCS9I4 ssWJFUm+GqpGYrXYad4151Y0SPRcB6MpwmiYT9scbVrMvAYOz9LyPCZznhaoHHo1bOfy XWjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ROaGQAgM; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.21; Thu, 26 Nov 2020 13:08:21 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ROaGQAgM; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391565AbgKZVGz (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391555AbgKZVGy (ORCPT ); Thu, 26 Nov 2020 16:06:54 -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 464B5C061A47 for ; Thu, 26 Nov 2020 13:06:54 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id t8so2610217pfg.8 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=g0KyE3fit05VwEUI6ewtRxynEqI5+pFej1S4n9pZi7q28GU4bGtbkX/4l6NMUbhI2f IIDSlPbIAkPEtfcusPimJHTsTWUGUjIKca1MqYPcQ09lKtdc4Dh1qOlFJtjhG5KHi+34 Kasn2xevXQ41awASNDQns/YAbUa0W2+pkyoDl7KotZ3tH5IIpmR4ojwiXDDSN4JRlAVk DipORYcl9COap4LI7oTnIALtOfw2Zi4laEsBU5QkpqF1kkOjJlWogZdnAsQMeDSi4RLA 3nm/vfbGknONQpSF6zfgjxN5C5Nxi1MSCgFzHExwi/uOFQ39VLi9QkfBJ0Iy9UHN3ACZ 6iRQ== X-Gm-Message-State: AOAM532XvL97+uFpSQcS6bcIyP3iep/41mMb0NbzkQ8Vcdm04ET+z3kg /YVqaGaXbQ44oWfDECoz69p/Fuycql4cVxe1 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: devicetree@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(-) -- 2.25.1 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: 333060 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633996ilb; Thu, 26 Nov 2020 13:08:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfxEv/cW0HGxZ04OnI9Z7P0GpATTNr1bJ9zn+/3fNR/8QB0SLz4WE5IxPvUcWconf+EuO8 X-Received: by 2002:a17:906:c298:: with SMTP id r24mr4331972ejz.381.1606424903532; Thu, 26 Nov 2020 13:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424903; cv=none; d=google.com; s=arc-20160816; b=1BJKh22GeEELFdeUeXyjrl/owX8YE20bVfAsC0ij0vIbNtSEcDsK4JChA2vW+ban7r 7WSJjgZ62xDne2jgIGZs4mB1P8SCC3UO5Y68qwGZDFyhZ92vq4IE0QExOIGmJIezlh93 Xr80grpimNQ1DlzPj3eSKVvSUfQNw3UDy/30TqLdFswxh6D8CH74B/ug0AIt4Rmxq+KJ NW6mJUww31F/kGHvA3Vo5tBoePbnunKVji4Oky7P/1Aowt8GOBwYZD7shsD8DWIiYnNW xAPVkKE0ZgoOwlSdIenFeJ54xmrhmOWvuJ+M9cmFnPv9qcWgfsreH61Laoa2qNo1BxyQ XtQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x8XMWKfae4q09gjVQz0Vnlnpd49+WO7LGPeK5Mj05BA=; b=mQ2l1Xrto4LmO+pdhyE7G5UTHSFvbaPT4OVsstHi1R9xWjOkLeKvaaNFkD//HSgxB8 sxpCAk4Xarx4lWFp3VyrNwI9OWMBprapYc38Gler9TMWg4CjZAVSibnVAf8j9bNVLakW 9xptwG6h5yVT8kBYYzgZnCnH5xZVSQAL8nNOdNVVc8tvNsixB7pl2ytItUuR4LgMIARZ aoEkdGbAnYCPvfk6D5F4aPsO4k3h83/IPNn3bGlbR1/EtE/Q3BrvMkS6Tcti6iXpWcWr u2ZWvzZ1Sh8CpD0N4Og1Otp6LSLhDK+leJtEOffutPex+yIFZ88HSpr1fFseI0EIAJeW XOaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fbTz3I/q"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.23; Thu, 26 Nov 2020 13:08:23 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fbTz3I/q"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391643AbgKZVG6 (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391585AbgKZVG4 (ORCPT ); Thu, 26 Nov 2020 16:06:56 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F825C061A4F for ; Thu, 26 Nov 2020 13:06:55 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id w4so2553848pgg.13 for ; Thu, 26 Nov 2020 13:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x8XMWKfae4q09gjVQz0Vnlnpd49+WO7LGPeK5Mj05BA=; b=fbTz3I/qpwcxvV52RAsvvLQQZevOtz9VhXW25EGHAOpzNMCjFuwxo76I1WTc8+7aML a/oorM43+BNCWnb/wtw2r9o8FVs7pZL7uEEkFHvBvCL49EDkZGGoKSE5M5CiIsl1+Ard M/38ct3v15xJiLINM4Ay1w7igT92vnulFhqMbVc/cYUAC2y4W6P6Qw6Jg41idknkE2xM verAPI56HY8tcgdeMQTYps4WSuIlJ+QSgB59Ucg/tvuvyGyaXji8qhjeHZsJHdN0R+9L pEoKMN618zBApBbdfnmOSh4WMTaH6sKUN9Y2MQSiUAtjNX5po7hHxZLS+RNoYgKB0McK Uldg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x8XMWKfae4q09gjVQz0Vnlnpd49+WO7LGPeK5Mj05BA=; b=cwE8gG+T4puSgFoTMko8DmtKZ+8o/wDitxS2MOAoC44HihxBrlxxGpju76pi1dS7QR UTBLGrK2zPVtgZx1J3NccGOyC2edXAFpDNoIAXi7WgiR3ltLdYUDCmDzJIrMUOce0R3U Cz1mTzec8lEyty+Gyg884k2bDvC4QkRB0QlOsV4SXonuoq8qa0qgmROcnuVlF8ZHmMyX AD47tIIqcZ8Sk34VrrNTUdUArq/Vn6mswiAjMrB7aK5ufU+RcpkTd+qlTvts9EshVc1D Ykj14MJDGbjUPLIRqetGqrTNwKZTNNDreVgTF1mAOAy2VdIn1BGCZBmv9vIlqNpKqIX7 O5ug== X-Gm-Message-State: AOAM530Ut0CzL5Sd7pv3tqr3O1tuwXtSZIuy9qShVlVG7p612f1VdGWk X53tp8oAiLxFaHD/9UYum9fyj8af1lPHidP1 X-Received: by 2002:a17:90b:ec7:: with SMTP id gz7mr266535pjb.210.1606424814852; Thu, 26 Nov 2020 13:06:54 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c203sm5612676pfc.10.2020.11.26.13.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:54 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com Subject: [PATCH v3 11/15] remoteproc: Add return value to function rproc_shutdown() Date: Thu, 26 Nov 2020 14:06:38 -0700 Message-Id: <20201126210642.897302-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201126210642.897302-1-mathieu.poirier@linaro.org> References: <20201126210642.897302-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a return value to function rproc_shutdown() in order to properly deal with error conditions that may occur. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 19 ++++++++++++++----- include/linux/remoteproc.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) -- 2.25.1 Reviewed-by: Arnaud Pouliquen diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index b54f60cc3cbd..51275107eb1f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1869,7 +1869,7 @@ EXPORT_SYMBOL(rproc_boot); * returns, and users can still use it with a subsequent rproc_boot(), if * needed. */ -void rproc_shutdown(struct rproc *rproc) +int rproc_shutdown(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1877,15 +1877,19 @@ void rproc_shutdown(struct rproc *rproc) ret = mutex_lock_interruptible(&rproc->lock); if (ret) { dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); - return; + return ret; } - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING) { + ret = -EPERM; goto out; + } /* if the remote proc is still needed, bail out */ - if (!atomic_dec_and_test(&rproc->power)) + if (!atomic_dec_and_test(&rproc->power)) { + ret = -EBUSY; goto out; + } ret = rproc_stop(rproc, false); if (ret) { @@ -1897,7 +1901,11 @@ void rproc_shutdown(struct rproc *rproc) rproc_resource_cleanup(rproc); /* release HW resources if needed */ - rproc_unprepare_device(rproc); + ret = rproc_unprepare_device(rproc); + if (ret) { + atomic_inc(&rproc->power); + goto out; + } rproc_disable_iommu(rproc); @@ -1907,6 +1915,7 @@ void rproc_shutdown(struct rproc *rproc) rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); + return ret; } EXPORT_SYMBOL(rproc_shutdown); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 329c1c071dcf..02312096d59f 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -655,7 +655,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, u32 da, const char *name, ...); int rproc_boot(struct rproc *rproc); -void rproc_shutdown(struct rproc *rproc); +int rproc_shutdown(struct rproc *rproc); int rproc_detach(struct rproc *rproc); int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); 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: 333064 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634078ilb; Thu, 26 Nov 2020 13:08:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0WYGRN6gw0KniCa+dyEIeKYeDAZAKaE2OrlHZ51Fsu8REda7BhnRGy2tHR22GblElMtXj X-Received: by 2002:a50:fd8d:: with SMTP id o13mr4469367edt.248.1606424909761; Thu, 26 Nov 2020 13:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424909; cv=none; d=google.com; s=arc-20160816; b=1KdqsjTcoAV12J+Pyp6Wv4o2jCJHm0uykEnP/a8FOJWwdX4XL/rxL3B5wWRIdZR98N 6Ff7hVD7dH7NId6Gu9wNG0C/HL5UbntdElW9Ix+Afh8S7nM61CFBNhB5PxdY6ekxbdai wva5cU2MAYdtMaqWBsWHuHidRHFhoZFS0DbCiYlVbV0xpDe09V+sGgisgb6cjgOEvTi3 Smujdtpy2dgFNSI06cfPkY/55GYY3dXyDQsrknqGk+bpseKib8IJ4m4QNRsH81Z2cZ8F 7tfl6GgLZZR0B4Uq275lI3QGgZRod2y+lK4g+/Mvhuat55z+sEsrYCl42kIe8ovcQfv4 byHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/KGOX9KkEX+n+yFMKTjakVzZosqRnFOWNvseTfllA6Q=; b=pR7MItyrkSamhuoBZruiKVfbwXEsztpcpEzJbK7R++hHCOj2N5lBkgRhRUsoisN+w3 tmIXsn3z2TFfLSoUmanAFT+JMbhPDHwnl7nxi7qRYvg4BPTci3AzmxpgeMZeAsqkd7Bz jd0J+XmvnYx4NHusMUDlaGNbj3YPOmZELWOQHBvtfO/Ps9cG2JtGwzw6utds/1hOwq6p lVRxmKj1dpB7KNt66rxq4ECZdNTEZdGNXGt/W6Ff390pZPH1EmMrZg2dNTG+92dNqd9t ezObPP8+iU1+RfqPV7jz/Dlq5zxNODcpbcWLbswSrKgpAsZWADspZiO8LZvIVRltY408 2/hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dg+HdzxD; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.29; Thu, 26 Nov 2020 13:08:29 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dg+HdzxD; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391620AbgKZVHM (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:12 -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 S2391639AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -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 72247C061A52 for ; Thu, 26 Nov 2020 13:06:56 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id b6so2608035pfp.7 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=L15JhH7Gi0Ir+8w6v2kkp5nDEFQjXWHQlvQFxnEPvx6lvkzfl+/p1YET4CaM+SJbR6 BwL6u5cvGbhaPLhemzJkbW92e2lfXANQ6laZ1brjA+sZ9s0G1znNQJpjw3vTObLCGnTE R0ftFalnM7qJ9v2tm3LZ6ztxC7j0JdbueB4smTlwvi/cO+bl/usXvx8vUCzDIUHPADDy QpyU2hzK1RyFPJXKVuw1kq5kri7an40/sCYh5z9nqZb9UD/9bMLnnP/hXbiMyP8EqQU6 vgUkOSWnWoMDH3FuDLccYCUgRkTP4IUqMzRqAshhEEORrvrSXA8Z1f6thu3FIbjG8WzR /agA== X-Gm-Message-State: AOAM531UPA2ILDBQDTPHiPIyas2a2geGkxaR6rjLSwp3sDXV2fdnEMh7 hE3Eqbw6ALqqzIKWft3AiPP+TA== 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: devicetree@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(-) -- 2.25.1 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: 333065 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634084ilb; Thu, 26 Nov 2020 13:08:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhE26xX/NYla/kmt5Ppywrs+B/7P5O2CcW7diVoA3enFD7UJFgcnrXuu3BNR+rbGxd+gPb X-Received: by 2002:a17:907:d1f:: with SMTP id gn31mr4530012ejc.192.1606424910975; Thu, 26 Nov 2020 13:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424910; cv=none; d=google.com; s=arc-20160816; b=oclcBIrxE6Od3xwivp6hB3p0/Qs79pA29VBmQmCv0v/FOMhWZEQ5wNVCjtJrjRiahv oP7iqsH+1ihWRatpxVKXmz7ElmIKu+qhJbFxv8zzV1H0yEHTodqowi6KOkQD9LosIi7w Gu7s5RmC/u9erjiwzRGWOaUDQ+Z7veRLierAZmIQr+gptKYYRTbJgImIOGUwNN6wLQa+ TWo0qE7jOjv14Zo+qHVhuNtCVBVGOJLh4uWBJ8jFzBav4H1InQN/67pVVjVBc1+QR3YF GumEJvSlWscPND/u5HWUCERZ1jNq8K27sdF2EV7z3N3A5RXT9MntLfjXPg3QrgxDbGUu mILA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1P3NOdCqAdCJq/BOuunpYV7qT3SyZVIkKnqupYZ7/no=; b=lLtbvwkMawr+SEppimvbl3NyhOlABY7ngaT7CAa+dFQIze4oJuB1wcfiJo4bVoBuXQ M6AH6aHUpXPZ5w02nr1Mo/7ORHzZicUh4gddvD5uNc0d5OgaG4o8G46CbVkUKjj9zX/c w+fZ9p6IrVDC5PN0WW87wWuqPKkte4y8TRZzCk3y9oLrQR/tV/sFsd45z3L1WNsuOc2t rXRyt1xgDFPSAFFYO4i4ckNN46M4IN4GgeX1Wru5oH6Hf+R0MQm7UM/+1+9mmoRACJ70 wUV1AVzvDS/cIsH+VsFbuv7ls7KOXYsbxmnJdLy7elBFQh2tS3SY0riNem9mmdECyAQ5 WkAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LlMmf89n; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.30; Thu, 26 Nov 2020 13:08:30 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LlMmf89n; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391770AbgKZVHQ (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:16 -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 S2391621AbgKZVG5 (ORCPT ); Thu, 26 Nov 2020 16:06:57 -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 6D8E8C0617A7 for ; Thu, 26 Nov 2020 13:06:57 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id j19so2581148pgg.5 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=bp8u7CR5hBW0JBrXLnR7gjE6OoeNtLu9BTms6LLjmm8ZO8uIJJG2Yyr7l7jktxrp0S Z8F3U30doACvn8sPkJ/pBLOx5s3eZVSpxroUQkpog9A8a3GUb/6ifsXnkwKQ5IEgaR6X 6PK78RAdumlhl4FgJ5ici2lUZrygFrPSuEdms8l1fyXpuV3Wb1PtLZz0B/7B5tReN8dt PMq6OUwGkRLeQbR853+nQHX0HihAvRk36821uXLVy7CzDqj/Hp535XSDC+FoiZsEyePC MSbfuTsCRd/sdMwNDWsq5yQOaTwtJvnLgI42VjsdL6mzycUHTz78Lc/MBZD9Jkrgtvfe qqRg== X-Gm-Message-State: AOAM532hhHOf0SbJEitu6SU0Cmq/NDimVLxifF4WkKZ+YUKsXBjL/1dZ lEH3NLtTrwcRTcgsEbOBO6gOFA== 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: devicetree@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 --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.25.1 Reviewed-by: Arnaud Pouliquen 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: 333063 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634068ilb; Thu, 26 Nov 2020 13:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxX/CCOVMO4JMP/nlqzM3w3xhga/An/SUIvk+BmT7Lz10aJ0Ui5IHhroOnH//hq/th9vamp X-Received: by 2002:a17:906:7147:: with SMTP id z7mr4212288ejj.65.1606424908521; Thu, 26 Nov 2020 13:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424908; cv=none; d=google.com; s=arc-20160816; b=hNy4Pe8a80zHTcpKSmKrjf2ow78c4uSOqo6uvEbc9SgU/BVxhgV8rYZaTSTH3xIKpJ HJzLE/WM4Gy70cf2xeFc5/jurEuL2OtfDYrBhjbRThojRTWLcDDBPlRtxUeCDzfLbu5a NNLhB/6+M6QJv1oCT68PKIScabbePn8QeQU1pyLIVD6TUg6ayps/RFpy4BnAU4fpVUoA 3tNNRCd97RxLb56sbMoGc5t0Ks4vhbV8k5qNZQO17Z7HEqANIG3jhDRgGQTiYB2rGPKd CSeN32Tm3uHI/9fAdnRc9G085kJSi8KgSHcSMwEqs4DUX7mII+sSTyGC9vhVU7hsvq9E /FYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BZKEoNhgpUCxk0BJFPhN8SyKdDsMxIN4bfJcnaCrMrQ=; b=EI+F7woMwtN9/DKidxgCHsxYTHBPzz8+TzuAEXJZ6+1nAFzemtrT2nbyfOuzGof7R7 otrdNzwBmIDtG58RvXWlSvNV36xyB5oM6zwy7TNB23Zm6ufy5BYhd/3ake+LB7AlajXF pGBiOyWnb1jl5sQe4hqGWkYJpaifdqEmHro5GS8zZpBUymfvU59+J0c7DbXpOoQAn8LY uplRtNAs8wYfW/mLrcwuqrXSFrTSeByv6OjaU0F361uxJoCdfAKwZhoJHwpyMBCLuz8p Ij9/kdkoeJUtkPDa9I3riwnpsX8KmhODCVY34Jxr1WbbwMBFmGIEDcCYRKEnxex+VNis wMkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pBsQ3pXn; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.28; Thu, 26 Nov 2020 13:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pBsQ3pXn; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391758AbgKZVHL (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391620AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 773BFC061A47 for ; Thu, 26 Nov 2020 13:06:58 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id o4so306364pgj.0 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=A6Grh3HAA4fDnUImTlimcI2nLK0ZElltaG+5AXnSUa19Ej4xtTe5T3qpYfuW2duiGN umn5tGk0Uuhe5/JBWZB/VgzkPbPXLSt0ClJPPc+udUR284hUEmDiwTGBZ0Ep5wNeM0HA 0QwOUsCwmNc/pmz4O9h/V7vLI+y7rG4xoF7D+4zUfv52uPBXtUet+KPS7qGcecS9IYmP ibrXDMnBpgH1fxlVgA+yX0deeslCBdHlGRZoelaFHabUcOCMA+2qQevYtiBON1g9MjOc miqeXoyTBevgk+goMs/AK9EX7CsMS14n7K003dAwsjoU6IyNxthTZ4wnCTfhH57x0uEO OTIQ== X-Gm-Message-State: AOAM533R8d9tpoRCDiepf87Bz0Yo330SH/tSuLup/JKUOSY+LmzrEr6s BYJ7tnfIKe5CQ/Xf9WftOqLk66Bm3zN+tCQt 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: devicetree@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 --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) -- 2.25.1 Reviewed-by: Arnaud Pouliquen 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: 333061 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634042ilb; Thu, 26 Nov 2020 13:08:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1e7TXUV+RhjvNJqF9zTdjEQW8un6ndqDMbrdvsMEatBlMbYPePb7XO8teBi/WT9Amfvv5 X-Received: by 2002:a17:906:5182:: with SMTP id y2mr4446702ejk.471.1606424907061; Thu, 26 Nov 2020 13:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424907; cv=none; d=google.com; s=arc-20160816; b=x0S2LPDUZlb2HIETtmrewR+kKbQyMTbK32EwvLehSA7EI6MMSOEPHOyYchaD1Noi8C EB+CGQ2jUuX3lDo4l5qPYx5LCLsLCFYDoPvqdzf8SEWzBCdqhP+qSMieTL4LJhj8LOV5 MVW90nLDgl+wWY+Ve5RSKDTZg390J0h/KX4SpRtPpJ6pWtexTPCVchH/PTIhUtaqpof7 FcYa+MncgOA7WnnDthy6iZ6IIoUFxhWQMB5xJslxGGQ6HF/i/9aDDZA0gJXOLS8roNj1 5VewLOUOfPLtcRkm3IlfenDHr2v4oTJsFoFGqCSZpgc91NEpyoZa7sRXn1pt/xri/O6Q IEiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UzN8V164vVCPagQUl1vXLvqIdHPB6vICDyDiG0FXeQk=; b=bR+q+f3ISi7kRtiJwaVRmd2WWd42iK2VsL1eNlLKf35fH/Sf89TKEvzz8VGPUbDVWn 92gotNEzF3q7S37M1l34XJW82uoMDPJBdlIEy1HBes4WmxpoyMh+HArkIR3pF2S7VrOD wF17P0QuYXL/l8NnjfBcXEUrr0igsoVfXgEtGG42/aa1hh6IpvHvrXK3/X49dzK8t+NR C9JJNHlrHYvQDDFHyMcYtpZZpxCfr0caY75Fq11ger/JRiOnB4o5oIXQrySXcNpRNpl9 mehCAgR/qLpP3qgOEB+M9naCph7fxfLQ7asvJIZcai6pjqrmgzjQ6RQRVahwuYExWF1f Vp6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhODEkY7; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.26; Thu, 26 Nov 2020 13:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhODEkY7; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391682AbgKZVHH (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391685AbgKZVG7 (ORCPT ); Thu, 26 Nov 2020 16:06:59 -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 89479C061A51 for ; Thu, 26 Nov 2020 13:06:59 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id l1so1667985pld.5 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=g6ye6XXGWYFSFrfdp3BipJBJMMAsfnx1jIDcU+DAIl9aps+FQ58FKQw3mjyhRZfOkq 2HyW7hjQeig8IryDe0dQ3aNkyDS27gglYHCSUm/KI8iZwucIFx5m5m537HacucOU6zjj VMsrlkhQD8lfQveXUiXzi9qSybvzsRHMDbjZy6E8ol3UAc84yJpjJNvY3UeqgCNem0X/ diMIkYynwyZq26aQA1mE9PL3DQoXBjwTqyvxUujVgjeALwZ9/YVJLjLPY0Ui1+POk19k K9GCiq+daEvlc82hDI3r57r69vNwu5G1oZMve2xlq0zuUSvZOg5LUrxOEv88lVNs0jYW SXIA== X-Gm-Message-State: AOAM531fvSs/2iaJTLp2c4ieawyKQlpnTMA9bAwCxEPL+etc7A+J9NKU e6hF8VYmZa0fShJX17hRO2YI7g== 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: devicetree@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(-) -- 2.25.1 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; }; /**