From patchwork Fri Dec 18 17:32:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345467 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2334343jai; Fri, 18 Dec 2020 09:33:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmVby6TmIRVUqX6N+qAjZwHAmdW8UZZk0KupQkbaTNPXkKLbA/qQhSmyvKad2LGP18wAFh X-Received: by 2002:aa7:d7d2:: with SMTP id e18mr5598604eds.256.1608312821498; Fri, 18 Dec 2020 09:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312821; cv=none; d=google.com; s=arc-20160816; b=gPnR3LCfzMLQ7flnrIfhXIKB2x1zmSRp9mtTJ6rLe0FzKAoyigpRrgSuY0gia0B095 pPKrP03WPZ2luo0OpPlcZiapFt/haVAtff2B+7fxjfZPS/k9rp+8aZRMPxK2KeUJGBWk lpjbe/G1jZui5v2ycIXo7uWfzhU0m9L2rBZtHqoM4OxuGnWKFxOVHAfsUuA6aMfAvT3P yvi9ifMisjmwB8g4DPubkvZqfhwQQ1rRRkXNKuD0WjAIpuwW/qF/fiIDXxFA8q4dRbjv 4yH0WmL3Bv9gkIusaa4siV25OBtrjM7jOgC3H4go/8CccRVWjgYMsFgxQCoHoSH5vX3P ijUA== 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=gRhRZVtQaTMtklLhGYfbei+QaPodzo2py0ncJTxvT/s=; b=VjUlbYzoB6i9Fd5dedeurjacXOWvG7sf84thrpbB0/EHtbx49cts5ylREimaSs+zH1 Q15fesW9jIIptth8xbrlQxFOsMBkrlYO4hZTEuTnrQfNwANpJXo9YIYto6mf7NZW5rD4 KnKA/TLfsKKkOi0TGFKWJ0LUicm6xIkKa0WQvcYuEl7iNr63yRemg1zwxYhvr0/uWkMV oS9TXAmrrlX1MMBjbgIRVl9V4bePJtL6dh1HKwYYjJigYVsfVB+Uz/3eplK3LL7GA1ZM uMuYdkk0AvOsVm7OQF+jTNNxIXhO57i4OM4sbu1bfY0Y/ndg2W7XywvCFwthOOWE53/N HDIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNpsREt+; 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 h14si5383818eje.325.2020.12.18.09.33.41; Fri, 18 Dec 2020 09:33:41 -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=tNpsREt+; 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 S1726680AbgLRRdN (ORCPT + 7 others); Fri, 18 Dec 2020 12:33:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732354AbgLRRdM (ORCPT ); Fri, 18 Dec 2020 12:33:12 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0662BC061285 for ; Fri, 18 Dec 2020 09:32:32 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id r4so1743742pls.11 for ; Fri, 18 Dec 2020 09:32:32 -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=gRhRZVtQaTMtklLhGYfbei+QaPodzo2py0ncJTxvT/s=; b=tNpsREt+XbPPv5QuoOhm9OqsITxalLxxOZfgF8GTLq+WJ8iOk5xzuavWPKfg58ioVE vBnZIyX/ncnJ2y40CyDTmSENMfPGcJewYu8oc3kJ5gXDZkQ35Pan0ThRHaPR4j8bNOFr dTa2k+0iXIbnE8vX66p/PMHDMBGHZkIVXf63lWQg4QHZsaFAbrdfmUqSzPgzV3SkxCiN cW227HbMVgiQ4M8uIXZeAKla3krZ6TzWemIzYMDGTUV1n5M6UZwJ8ZU3XQmivnqsNLFA EXNaCAd9JvVPPXBHFKQ7X9WuYH5XIhAaGzy5Z0igOM8Fo4zLsHKrqv0pq7vRF5UwrOUn I7lg== 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=gRhRZVtQaTMtklLhGYfbei+QaPodzo2py0ncJTxvT/s=; b=nvhJZxvUDDbpC8EYvy0LtPLU2a8dPr7lbW3mRul4bmeeaXcj9SARs5M+Y8Ycpc55Yq ThK/lDGbwcRk5T8HC58Bs3p71OU7Kz89uQDxFAJRD/UG02OqYRQ6yAfhEL7efbRbOmAt SAwkISXiG+CRF/nHYXTYAy1TeXOu5xIN21r6vLf6LcswrxEpUz1YoKrUIXIvF2w50jw7 e1tehaIkrObYY3JKgDM9TjMpuRWINRYd0cjLK1hh4B1MH8P1YDIlRjd00LA8QAIgDOwr kCP8UCE3WMUL6G8Fkrc0Xh8u+aqZC0OdRPPTIRDEsdqpJAqeM5zwOXEqkmtreMXvZGcL ROyQ== X-Gm-Message-State: AOAM530RgLQF3EyJFUUPTZ93N62aFQNTIRgUuFZN8CBIgq+7q1t1LOLD IU/FqAP8rvlMNpQ9v2hiPftpEg== X-Received: by 2002:a17:902:ed0d:b029:da:c83b:5f40 with SMTP id b13-20020a170902ed0db02900dac83b5f40mr5444448pld.20.1608312751595; Fri, 18 Dec 2020 09:32:31 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:30 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 01/17] dt-bindings: remoteproc: Add bindind to support autonomous processors Date: Fri, 18 Dec 2020 10:32:12 -0700 Message-Id: <20201218173228.2277032-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml -- 2.25.1 Reviewed-by: Rob Herring diff --git a/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml b/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml new file mode 100644 index 000000000000..e8bb8ef9031a --- /dev/null +++ b/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml @@ -0,0 +1,27 @@ +# 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(s) for a primary processor applicable to all ancillary + processors + +maintainers: + - Bjorn Andersson + - Mathieu Poirier + +description: + This document defines the bindings used by a primary processor to determine + the state it should leave an ancillary processor when the former is no longer + functioning. + +properties: + autonomous-on-core-reboot: + $ref: /schemas/types.yaml#/definitions/flag + description: + When specified the ancillary processor should be left operational when + the primary processor is no longer available. Otherwise the ancillary + processor should be made inoperative. + +additionalProperties: true From patchwork Fri Dec 18 17:32:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345483 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335833jai; Fri, 18 Dec 2020 09:35:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3hmMITT+vpl1sdITrHnm926IVM7J1NcMk3tSu58dAwHy1B81HDKuNtDMWJjMJCM8vidwO X-Received: by 2002:a17:906:f8d4:: with SMTP id lh20mr5046238ejb.442.1608312928857; Fri, 18 Dec 2020 09:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312928; cv=none; d=google.com; s=arc-20160816; b=pSj8I5jBLVbWcw0+Wtkzm6QtKnwS/R89gHyap96yWtywfF0O4LnTQJaQ0xCr/RUFi+ +5A5XfZPc+q6Pp5fjCcsyKgUPzDWCYrKLXZU9M7IlUz7qjYhI8yebMN73sLZzemCRy/X SLTCLhXwS2Qy0tiQ/sZVzOuJqtWN0SoT9RLYNoVkHSPNa7i9H9CWJA3yHEiFDO/YbYc4 zBZbIM0bvzLLEdx397RbijrC1eSk9Wp6ONt4O7j6SNPlTaTCAgfLCrEOCS955VFwe1jH kibXPsD2uIJhIXZD9i4zf4qXSNQx9xKVCpNFgMBT6iE9kC+UEYeqTV9onezDBeBW4lFT Lytw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=quv8FgGcrBfpjdUziX+s2dGLHCpcEJuuhEHyCnt0I9w=; b=iLB+OMuy/HZPdm8TI1fx3w9OhhZgp89WGmzg+28qtHk5ou3ubX2mXQCSz9v3Ff44Sr JnS9oc+2nA7g8TJwjjyhLFWKc0DpIMy6Gi1D02XyuHznrCbRJrgSr8i1L5xrrpOQ8NES MetmGrhfeObZahu+wJc9WQeOO5r0se0F9rxdN6akT6jKkD9f844q8gFJGGrkisW2WIrp psuaubW71X6vode6scT4J3NxIAZ47s5garXF60IBuk8yQgIbxlFPOrOSosNBA9rB6YWB rrhuI7jEPRgW8Ow84PMMf0zWeVVYZpwc44CiL+OzG77hCkhHTpZhvSXlmmMuTeNWWva9 2beg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hWjlKc/u"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.28; Fri, 18 Dec 2020 09:35:28 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hWjlKc/u"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728304AbgLRRfP (ORCPT + 7 others); Fri, 18 Dec 2020 12:35:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbgLRRdv (ORCPT ); Fri, 18 Dec 2020 12:33:51 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 189E0C0611C5 for ; Fri, 18 Dec 2020 09:32:33 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id x12so1746493plr.10 for ; Fri, 18 Dec 2020 09:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=quv8FgGcrBfpjdUziX+s2dGLHCpcEJuuhEHyCnt0I9w=; b=hWjlKc/uj59tXupMihyRyk6/qf5jTxj733rtsaPMHcWwyas3HRGdNDFySCMQMFDsLw MsQlakPxeBYW7HiRi3L/5gQsrLigaJK2SrUEYK4IGL4m/B1h6Qm7zzO/+R+qU/dxUeAc Z3VHqNIuAwma/8vga8q8ugF0ZpNAe3i4KndKnvjUzkaMxntPyLVi4459FM8BfHpdtIT2 siJkUbRIB3rg+D0KZXSsl83hf6P7FheSxhm20Ku6OHJnK5lO7gXl8IvKhhroO3XgiRMb 7yMbAakrbxAtg16bQf1fPw8aGoMA1qfQACManxDa4k9GVQxH7fNUaf1pGaBM7CksN04V n4ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=quv8FgGcrBfpjdUziX+s2dGLHCpcEJuuhEHyCnt0I9w=; b=BBzZM8yaf+RN1bRhyCBqs0kfecz98K1nI12xqip20Vg3xY2txs/keh0wJfFR11KpUO +voYOcn4E5CsyjUgL8tdYoLqKT2E9qAsZHCiOuAcwZ84lXQ1q6s2FHs4uizYYigW1kUp /GgF1VonSHeoK3zC8N+Ti9nRusSX/wYjy0tKdUdGp4iHBGoxgHtRYwA+8unX6ESaTjP6 EOiuI81n0aqzqXULpf3QYZgNj+UMOtx+TcvMcms6cNZF8KiC9UhJW/fq5bxZKlb6ivr9 AzPZlLHaL2uI4EZdLD8qLIQJHiyZG4ffSy+AOXa6vodR1ZInqUSx8N9TggQFwTDjRwp9 xPcw== X-Gm-Message-State: AOAM531mbqUIfvqc8AR3+Nx4vcMadg/3sz01aa4kvMX/QgF6M2t60dn4 UtlcyPmgJeORQPeUFpoCYDsRKQ== X-Received: by 2002:a17:90a:c8d:: with SMTP id v13mr5283889pja.75.1608312752706; Fri, 18 Dec 2020 09:32:32 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:32 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/17] remoteproc: Re-check state in rproc_shutdown() Date: Fri, 18 Dec 2020 10:32:13 -0700 Message-Id: <20201218173228.2277032-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The state of the remote processor may have changed between the time a call to rproc_shutdown() was made and the time it is executed. To avoid moving forward with an operation that may have been cancelled, recheck while holding the mutex. Cc: Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index dab2c0f5caf0..e55568d1e7e2 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1857,6 +1857,9 @@ void rproc_shutdown(struct rproc *rproc) return; } + if (rproc->state != RPROC_RUNNING) + goto out; + /* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test(&rproc->power)) goto out; From patchwork Fri Dec 18 17:32:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345482 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335829jai; Fri, 18 Dec 2020 09:35:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXhvHIR0fzC/LMv1Xxz8e6O9D1R0i2bsOmJQedOhCoNrFXM5TW9DItl/rP5yBRfgABnLUv X-Received: by 2002:aa7:cb10:: with SMTP id s16mr5485649edt.304.1608312928476; Fri, 18 Dec 2020 09:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312928; cv=none; d=google.com; s=arc-20160816; b=qeCLS0a6xQRhGrNr4m1Cw1zF9bAEzLwCKznZE+nw8taYv6HtQsmLvFUOOpV4NrTCCF l5OuC9xJGqb05hXSXTLXHHqBtbYfQjj+6LiPeRkbuOL3vfZsDolPUv/uXB6QnsRdriRA HVBaOYlAV35ppw0P1FZFGBr/gYG0l+eqrM8T8kIGoabowXlS1uTmSDlSAmyF2+dUdMIp Aj1QEohyoGNkkPMh2R1XbdrhWGUIXro5lrCwpCVWzNnBIet5NYUcRV7t1FCMWF1ml9x9 fUWpybSuzI6qtS5xR/nPU/AAig0gk5nPqFnmHicIC8/0GZ7bccbopcl2uq+IeHItz4iN DTCg== 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=Dhrgj6KlTsZx4Q0NhpQquJvgjz/fkM6eRvngZm9P8MI=; b=INaILiDWXyUL7kzPGy4o34AtsYrurxrOlZ/04JZAGYX7IjOzeUJGsOyV5XKhJxpa4O d/VP+qLagMb6Jo12qBBmcljeyioxHur1mpw9c371owD3xgMb2VqFXqOHB6fbx2kW/Z4U hqFA0bwVCRgd+tIix/xyK9mos1NytagfonjrSi7rNjtp2kpjFHXcAOsY0pVRb4OJ1+Yf uoYoHwDMfF7iGGt2B22LTLZa32tDFvayDeaaBUutaoN/qNoMzQ8TFuROmq7O0oRZOo0/ HFXK0NTypNc2alyuXGerTm0QzB5Iy0loSulGGnFZkSYKNpv52OFVACcBN9et+anROyIt ZdJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCTWyUnz; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.28; Fri, 18 Dec 2020 09:35:28 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCTWyUnz; 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 S1732497AbgLRRdw (ORCPT + 7 others); Fri, 18 Dec 2020 12:33:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732414AbgLRRdv (ORCPT ); Fri, 18 Dec 2020 12:33:51 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5B9C0611CC for ; Fri, 18 Dec 2020 09:32:34 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id iq13so1666143pjb.3 for ; Fri, 18 Dec 2020 09:32:34 -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=Dhrgj6KlTsZx4Q0NhpQquJvgjz/fkM6eRvngZm9P8MI=; b=CCTWyUnzE1ZanX60E/iLMHT0I8ZKWfPXwPWUJWfADUGe1anX5MYdsbtqq9PzKYM9/j n7OFo3P1s+0nskqFjWV2eOnXUxh+q3oIlb7YjcMN9vV5TS0FghgN1ctFHNf7Rs5OaNz0 a8foVoXrny67rmJYDx25RebAwa6Lrn/essn4udioOyBENIujDvSTMTEVSTk8Qvua6HIX F6eS1tPhvPc0tLr2Gt4TMUD4Gxhq6n9EZAt+jGOgvH+PUKd8fKp4GcO0SWVYVXMomcsO 94YO06VeiG0HGk4RyldO1QnAYqBw1oQ3vmmw06P0vDdLEFM5eh910MItWLsNhZOUaYT8 Lc9g== 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=Dhrgj6KlTsZx4Q0NhpQquJvgjz/fkM6eRvngZm9P8MI=; b=cYtxJBJlVKKYvM2WdeEtOjOpYKbAr2J+M4fQQo6muAJCTuT9QCzaZzbMKVSYojHNAa U2X4H9PEKFzn33cTSRut7t/XHmRbOdkIDIEj3CmmBfvzVEj0eWMzxNyz8KBT+GRwilIM tDsnC5NeEeeOCI/uiYv3QqNjrIGoc022mjPNb/OkkPSnSwWRJB4mhX+7yTRKeH8PJhGg W59u7n+Q7kB/94W5z9h0J2CNitbYj9/GW3ni5KWtrDfIRGj1gbpIW0X13HXz+eMK321Q GUqPPUqg2TtdwV1aRz4JQWqHJPYKqdV+zUjDMvBCrF3bdMP7LZ+1sHNITjM0BfdNvPdk H6WA== X-Gm-Message-State: AOAM530CElmV8yB/YizQwNMxu4aLIQm2FYdncq7D0Qq6C8+Ia7PKygf6 4+vQdv3b/ntEitooeKLBpe90tg== X-Received: by 2002:a17:902:e9c5:b029:db:d1ae:46ba with SMTP id 5-20020a170902e9c5b02900dbd1ae46bamr5424989plk.38.1608312753708; Fri, 18 Dec 2020 09:32:33 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:33 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 03/17] remoteproc: Remove useless check in rproc_del() Date: Fri, 18 Dec 2020 10:32:14 -0700 Message-Id: <20201218173228.2277032-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 e55568d1e7e2..f36786b47a4f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2283,10 +2283,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 Fri Dec 18 17:32:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345469 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335525jai; Fri, 18 Dec 2020 09:35:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+/DqpgDVUy/3MD/nyhoUt2mBioYHPVluQkBKIi5JSElq5zQgYCS0T2Q+mwMMj3tYQtYLP X-Received: by 2002:a50:cd9c:: with SMTP id p28mr5376891edi.83.1608312906717; Fri, 18 Dec 2020 09:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312906; cv=none; d=google.com; s=arc-20160816; b=tWGjwBCwgdYZIq1dRL7fjJ6cSOtcMRJHUJEgiF40mnMkcxg71RbZaQ2cmjsxkSeBH9 m8L1560lP6LldfPBEqXx2q7GPvm3+bKIEz7sLl/BsF/m5r70M91riJZLVbjXBCKrx8oT P6dZ7XwtkwT+lTelxE6hy7MOSCHKqCqT46TWgyF5uWnEGFUcpkJ8RX859OrPGrBPbtSv /JFF6lxwtNj0i+/fYrLm9GmsMSFgTo6H6Mht4eBqMxEWe9jEm4pqqUKYh1AS5ZCuyTbw M0XBgrZgCPjxcJsbN9weE7zm4TClnXPmuhY9pcJR00QuThVECST5ezSRm/AD2KpzK4hX wdyQ== 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=txg4LgzTONgLC7bOinTZzbCI37JS2siLcSWFwbF15Qk=; b=F+SDMSb1gb0FUHDnHkYd45SfTUiw9cKo6ueh2k42tNOOZveSaOB2YHHu7YvSyPkpy1 /cuRDxCsQssFYPVudle+LWkZdfwSMT2LN9neYfKxyf/qQNdxXQRFoqSmacc8tsYftGed lZ7f96axapML3BucSyecDzRuHFHxT7AnzRDTujuWADXf8VqF9aZKgeR5x9ge3Io9hlRQ mMOe/homwyvRqCI6RWKcodmIvDTbONS2Q94GkOkLgdDvb3+EXst6CVXxZYbRM4O9KiA0 Hy7uy55y/VItP+1MezVJkXllVfB3gkM9SLkjb0PBKu5ypC3vPROGsLPA9+nopHgHXv4d 7ElA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FT1wjtnm; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.06; Fri, 18 Dec 2020 09:35:06 -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=FT1wjtnm; 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 S1732580AbgLRRdx (ORCPT + 7 others); Fri, 18 Dec 2020 12:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732480AbgLRRdw (ORCPT ); Fri, 18 Dec 2020 12:33:52 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495E3C0611CF for ; Fri, 18 Dec 2020 09:32:35 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id w16so1736002pga.9 for ; Fri, 18 Dec 2020 09:32:35 -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=txg4LgzTONgLC7bOinTZzbCI37JS2siLcSWFwbF15Qk=; b=FT1wjtnmHCPECVPEQOVxWLN5IehXSRiI66FrjheH51idu4RnVyVuXK++01jSwEYClT KZcFQ0KFJhcsVGfoIH42EnumgM9kl6NEwU9q1v901FR335NFKd/uI3zQqmhFcU52+ZnU UrBN9FzQambsdleQEA8D+rYpufRq4QHqAZbw3u2I8hS4Ef79mMz71XebEFznG6UxpIN2 EKW/X23xQvlKzToX003uherA1MKSw08scJZVf8NMCxj1EVa/iXVQZ7+M7FUbWOoBQx5V bNimp0NbeQwOPco7XjifzHPkmZTafaMiWHnat4Mjv2WN1m2Z993yQZMHJGR4wx/4klCI C8QQ== 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=txg4LgzTONgLC7bOinTZzbCI37JS2siLcSWFwbF15Qk=; b=I3VJCLjxELXATrVoMTTKktAJm8bAmfqrTqNzhlq/BOS66HpNAkiPGUDaB/wbRCwkg/ H2HVqSANY2RhWPns4U43idx5jejPwp0cb0jHS23WVFLZTeKMJImtQxhXV1uGLjRbJZEr hSqEyNmLnzL4fsLVmSSuWHGqGF/0AvH2W6c7qX9XWpjDRj11f2gqVbFUkh6emW9ha/JF eSD9xVkuxZU31GYWxDZ4ouC71FmfoNitfE/f9xWiZZSuOnkxV5WzuEKr6GOyngLrH2/k IQAXbKbihj5FBpvMaDLtYlWMSbtw2NkpzbkhTpNz7QWVapElHizJJ2QaHFLSopcd/5V1 IOOQ== X-Gm-Message-State: AOAM531R1NRO4aLZoIgJW8244Knl5PjE6kGc3OVmGolRlNYIIYjmb+aE 6Abu8NyPEBE7wlKfH6Vb0l7xlg== X-Received: by 2002:a63:2060:: with SMTP id r32mr5077740pgm.129.1608312754801; Fri, 18 Dec 2020 09:32:34 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:34 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/17] remoteproc: Rename function rproc_actuate() Date: Fri, 18 Dec 2020 10:32:15 -0700 Message-Id: <20201218173228.2277032-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Rename function rproc_actuate() to rproc_attach(). That way it is easy to understand that it does the opposite of rproc_detach(). Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f36786b47a4f..d0f6b39b56f9 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; @@ -1802,7 +1802,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); From patchwork Fri Dec 18 17:32:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345468 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335494jai; Fri, 18 Dec 2020 09:35:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzD1TocFUeNXSh0ulBslpcOT8bWzocn7/6ppHhcAcdiNiM9sXwyimxkXoC3RprXrTn+dePS X-Received: by 2002:a17:906:ae43:: with SMTP id lf3mr4848062ejb.130.1608312904526; Fri, 18 Dec 2020 09:35:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312904; cv=none; d=google.com; s=arc-20160816; b=nqqIA1TDBhAnXfawog8NS/YeZzlgB7Mrp/Dvfac1UPZ/J04mHvsgPGz6Ci/jC1k+7l 3zSW/I7pEa2U/8BocYfv/C8uOFBfdnhQHSNYBPhUDngoYekouTRBM5kTGat6E70lGdUe AIAShgqUXABjNz2qVMHWJYQ4IA9OJ0bZWDhEuR4gxRTNyVfTgILehpQcVJ4CEDhlgcf8 9D83NO2AhQf68O0MbEAzGOmmfsT6zCZN1T8B/bCVoRVIJwKcPyNg1iRV1bw0NigUZBj8 LHS0muSiqdddgoMLJJc3ETPIi54BS0omTTVb2v3QWkmQWgTUVgcTnkntIr1APl7FbmOV MDdg== 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=veV/gWfMA9I6EK7puOMUDziv6Q4utmhzFu5s8pwfL6Y=; b=zLcHufXJQdm5iUT/ZTYsYaSg5FAivmSvstbQ8GAJJW1eEQF2WErDNQh7T6KSmuk+Mq 3/7VCuIXFOrZBfpQF/0MQXl+Rc7IO5Jy1d+Zza1pc5cyD3UNn/g1pZCJZx/15APKHtd8 GqMeVOJ8xVBnvuMLUxs2CudSTyOkIuvFK1BzTA5aJzcHJc90GfD1eQ/MZXlCU5vqohDL aaulOEzXj3Y2Y+J83c0P2uAzX44HxCAeYG3HaPbavBAIW10EfYOwnEwDx/wfYzB8gzPj irC+WNUNjpuvbC1MfuksZX273GSj9Jx8u6ooA/LP5Rb1JMP7xVSCeypwv5sK+dyPM2NE BVUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IsLC2tdb; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.04; Fri, 18 Dec 2020 09:35:04 -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=IsLC2tdb; 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 S1732311AbgLRRds (ORCPT + 7 others); Fri, 18 Dec 2020 12:33:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729999AbgLRRdr (ORCPT ); Fri, 18 Dec 2020 12:33:47 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D7EEC0611BB for ; Fri, 18 Dec 2020 09:32:36 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id z12so1670133pjn.1 for ; Fri, 18 Dec 2020 09:32:36 -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=veV/gWfMA9I6EK7puOMUDziv6Q4utmhzFu5s8pwfL6Y=; b=IsLC2tdb+Pf1zJzmBqdfU+7Lt9+J5U7obCdktnUBK+t6z1PscQocz5RbK7ptqQeZjh 69aoGazTQg7QNqyHvMLxy/ABKuxk9AgbBGPQNYMDymkMmlRzPg86LNJ1joQmNVaCdlgP g3w1obCYUxvM5RqGHIxQQMzCWI9CVpB4UvfmRhn1kpc+pRnEsU7xDo7EdhO4SPqhHle4 0hC5qeLZLQmoHqsR62Tjt1n6rFzv+0jyB/+ktGqldWh9wVVroMVkhLW6czNqzNSHOLXe W/4g2TJNzrN1P3SHIqN2FpEvfDWRqDJPIgIdT/bmTzzAeFqeuwhhze8+kFm6yPTSCDDR a8xg== 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=veV/gWfMA9I6EK7puOMUDziv6Q4utmhzFu5s8pwfL6Y=; b=IKrGpTOW1QJH2arZzlipLvHPxxPhDNDouQmSF0yh2OBfSWRtBajR3Ok1uyubF3G89x tvC+hdE6Lvz0I9PMVjBRI4490AU5pa3PojoyiRxu4GH9eH9Kc+rQiXiL4n6A2/kAIF8e 1u6L5PSLliBJ3YkYhdpDNwLEeYy3sLEwf1G+lt5whBqsTiGABIkg6JcpyNV6x9ZgOoUy te/9WH1/AUZc7suMwmspyDaWGIuR6L2hkPhQX2HDaKg+cZdfjNYW1UHoDejcZ4CH21GJ gGEAudm1CkKQ6YN39yYTD+N2MwQV5PQG4iJql/Rri4F1v1PfzLkwpDe/x15syFjYJwWM jKQg== X-Gm-Message-State: AOAM532r6ZFuVbk39IIZK5CX0suCRLQvJZVK6RC5QRrehVCDOUj/fV+v IpmlZE3GmdUPkHmojRj0SoDB+w== X-Received: by 2002:a17:90b:1249:: with SMTP id gx9mr5207245pjb.169.1608312755974; Fri, 18 Dec 2020 09:32:35 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:35 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 05/17] remoteproc: Add new get_loaded_rsc_table() remoteproc operation Date: Fri, 18 Dec 2020 10:32:16 -0700 Message-Id: <20201218173228.2277032-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add an new get_loaded_rsc_table() operation in order to support scenarios where the remoteproc core has booted a remote processor and detaches from it. When re-attaching to the remote processor, the core needs to know where the resource table has been placed in memory. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 6 ++++++ drivers/remoteproc/remoteproc_internal.h | 8 ++++++++ include/linux/remoteproc.h | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index d0f6b39b56f9..3d87c910aca7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1556,6 +1556,12 @@ static int rproc_attach(struct rproc *rproc) return ret; } + ret = rproc_get_loaded_rsc_table(rproc); + if (ret) { + dev_err(dev, "can't load resource table: %d\n", ret); + goto disable_iommu; + } + /* reset max_notifyid */ rproc->max_notifyid = -1; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index c34002888d2c..c48b301d6ad1 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -177,6 +177,14 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, return NULL; } +static inline int rproc_get_loaded_rsc_table(struct rproc *rproc) +{ + if (rproc->ops->get_loaded_rsc_table) + return rproc->ops->get_loaded_rsc_table(rproc); + + return 0; +} + static inline bool rproc_u64_fit_in_size_t(u64 val) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 3fa3ba6498e8..571615e77e6f 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -368,7 +368,9 @@ enum rsc_handling_status { * RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a * negative value on error * @load_rsc_table: load resource table from firmware image - * @find_loaded_rsc_table: find the loaded resouce table + * @find_loaded_rsc_table: find the loaded resource table from firmware image + * @get_loaded_rsc_table: get resource table installed in memory + * by external entity * @load: load firmware to memory, where the remote processor * expects to find it * @sanity_check: sanity check the fw image @@ -389,6 +391,7 @@ struct rproc_ops { int offset, int avail); struct resource_table *(*find_loaded_rsc_table)( struct rproc *rproc, const struct firmware *fw); + int (*get_loaded_rsc_table)(struct rproc *rproc); int (*load)(struct rproc *rproc, const struct firmware *fw); int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); From patchwork Fri Dec 18 17:32:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345476 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335662jai; Fri, 18 Dec 2020 09:35:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJziQ8D+o+pZgcf5lt6q1un3QBpsYWSHjxGqNyzrCJ42DlV2doxn5izaKkNxiwJOY9vAXHhN X-Received: by 2002:a17:907:2123:: with SMTP id qo3mr5029672ejb.543.1608312916922; Fri, 18 Dec 2020 09:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312916; cv=none; d=google.com; s=arc-20160816; b=ixH178SfM9s049R79xlaU7qx4srIG4NGTjQjoForIbPgOvwGL1ozO53xqmCKhPtF9z dFJ9DV88MeMLuvMT4KtegW1QE8NnPJA/ADgUWMKA7JGYqo/lcbMOYD+aJlmLrNfYw3Zb mDUbQSQircJhU1pCxqR1TEsoCMfYVbWNeDDaojKajKNYINnhELAtpRwo5PKTlSjWWrJV DLRNqTwR1JI2GpHjZOIhTcELDK8fbE7N86S49PtA+I6yeBKhOQ2maxdlsU5NIaBXj3OJ G4iK/FBUjbJg8quY086LA0zegoQGXfpb68tuDwOg/d7s502ZoB71pjeEPoI1MAHft9mV +wEQ== 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=g1R9Bq/TkbA5ZJxMb+U3jIOApLTRzPyrB4NxcI5os7I=; b=jlrxBr8UuT5qtTxapLe38D/QAr/y1U1VwwBUK2cGWtU87MSnJJt1YSarxwSyJjFJUt wCibbLa7/ysySneiSGoCSGnnEX8Vsk3+bOhvm87PRY2Oq5jz9PpBqdghxtS5ZXnVtEz/ JRwQGPv+hRYsIjx8Xwixf/qBaEO4vHxxRvcZgt6Qc0Z2+mQPX/ZNsdP6x0/ALQNADpwO tFBsGhMgQJkdtKQ5hysJ08+ouSqc4VVKg2R362O8nf7XpIMQ5rD4ewM6/taJ7Igi9YVk DGqKJDm8N3Tuh/TXPZ97leb1gtNnlhwUd17DOVB/Xn2cURmEsWB1jgWanvGqgKmwN8UL I6dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t5wRCamd; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.16; Fri, 18 Dec 2020 09:35: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=t5wRCamd; 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 S1732872AbgLRRe2 (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732869AbgLRRe2 (ORCPT ); Fri, 18 Dec 2020 12:34:28 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D0DDC0619D6 for ; Fri, 18 Dec 2020 09:32:37 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id q22so1917620pfk.12 for ; Fri, 18 Dec 2020 09:32:37 -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=g1R9Bq/TkbA5ZJxMb+U3jIOApLTRzPyrB4NxcI5os7I=; b=t5wRCamddvBbP1gidIz9qVvy3YaRueHBIcG8WR00lGkn2knegTeSlgbq5QlaM7VMJl LoOcQJ9rLi7XcIKluTKzOBWvB1hklOY/sFX/Q3J/uw7FWs5W8/Pl0pQ1IW9/fTcqCEln shYK9ZwSWbc64d1k1i9JO20A3s6BI2f7vUguLJFLhOr5PphEUXj/CQTssw7iJenbu4+R kfo1qvB8GiDiswP8UJ++4LiEJN57I/QnT+PG+ymdOYwyIn/vegZrq8Awq2EeSvzj56qB JzirrUAxmQeRZyMUEIUxyfVmfkj7Wu6SkJ0vRdTStTB44T70QDag4kqfbJjc8wyPA+b+ XkbQ== 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=g1R9Bq/TkbA5ZJxMb+U3jIOApLTRzPyrB4NxcI5os7I=; b=ebti3sITpIVtY1CUld8uTry3ONmj0WHC+mXlHqzYj0EOMBSqp07d2sJpkqf9wFPPk3 Fc8GUj6asNBj8+0eK2dwQyfn/hLVWBrRLUr6/9rHXy9wvtf2Sbdnf9w2vC3zq8T5SDRP 5UqFEdbYxvviiyRzMhsX1IYGEUHCK0FxCGGytP6XNvUWHDxGV6O7eHRWJaLZKUG3JddO ceat9kyPim5S50FqwouK6drvNpasW2JGhG3qZA1xAsTw/zx9qR9qHk4ul75inKGj0+cg XDEpi+h2MOwKtD9VdQp5jO36bxPQ348bYPdw66fzsocwmy0rsO/f4j5w+1Z9EPm2REPB kmmw== X-Gm-Message-State: AOAM531kIjnBXFb1MWoBVIiellUQlM5W3/QcBR4ndELRwMo+EfKEs1v3 QlH3LEiqV9KsrD2ry74BmDqskA== X-Received: by 2002:a63:5843:: with SMTP id i3mr849381pgm.209.1608312757099; Fri, 18 Dec 2020 09:32:37 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:36 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/17] remoteproc: stm32: Move resource table setup to rproc_ops Date: Fri, 18 Dec 2020 10:32:17 -0700 Message-Id: <20201218173228.2277032-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move the setting of the resource table installed by an external entity to rproc_ops::get_loaded_rsc_table(). This is to support scenarios where a remote processor has been started by the core but is detached at a later stage. To re-attach the remote processor, the address of the resource table needs to be available at a later time than the platform driver's probe() function. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/stm32_rproc.c | 147 ++++++++++++++++--------------- 1 file changed, 74 insertions(+), 73 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index d2414cc1d90d..c635f746e44a 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -541,6 +541,79 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid) } } +static int stm32_rproc_da_to_pa(struct rproc *rproc, + u64 da, phys_addr_t *pa) +{ + struct stm32_rproc *ddata = rproc->priv; + struct device *dev = rproc->dev.parent; + struct stm32_rproc_mem *p_mem; + unsigned int i; + + for (i = 0; i < ddata->nb_rmems; i++) { + p_mem = &ddata->rmems[i]; + + if (da < p_mem->dev_addr || + da >= p_mem->dev_addr + p_mem->size) + continue; + + *pa = da - p_mem->dev_addr + p_mem->bus_addr; + dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); + + return 0; + } + + dev_err(dev, "can't translate da %llx\n", da); + + return -EINVAL; +} + +static int stm32_rproc_get_loaded_rsc_table(struct rproc *rproc) +{ + struct stm32_rproc *ddata = rproc->priv; + struct device *dev = rproc->dev.parent; + phys_addr_t rsc_pa; + u32 rsc_da; + int err; + + /* The resource table has already been mapped, nothing to do */ + if (ddata->rsc_va) + goto done; + + err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da); + if (err) { + dev_err(dev, "failed to read rsc tbl addr\n"); + return err; + } + + if (!rsc_da) + /* no rsc table */ + return 0; + + err = stm32_rproc_da_to_pa(rproc, rsc_da, &rsc_pa); + if (err) + return err; + + ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE); + if (IS_ERR_OR_NULL(ddata->rsc_va)) { + dev_err(dev, "Unable to map memory region: %pa+%zx\n", + &rsc_pa, RSC_TBL_SIZE); + ddata->rsc_va = NULL; + return -ENOMEM; + } + +done: + /* + * The resource table is already loaded in device memory, no need + * to work with a cached table. + */ + rproc->cached_table = NULL; + /* Assuming the resource table fits in 1kB is fair */ + rproc->table_sz = RSC_TBL_SIZE; + rproc->table_ptr = (struct resource_table *)ddata->rsc_va; + + return 0; +} + static struct rproc_ops st_rproc_ops = { .start = stm32_rproc_start, .stop = stm32_rproc_stop, @@ -549,6 +622,7 @@ static struct rproc_ops st_rproc_ops = { .load = rproc_elf_load_segments, .parse_fw = stm32_rproc_parse_fw, .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .get_loaded_rsc_table = stm32_rproc_get_loaded_rsc_table, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr, }; @@ -692,75 +766,6 @@ static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata, return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); } -static int stm32_rproc_da_to_pa(struct platform_device *pdev, - struct stm32_rproc *ddata, - u64 da, phys_addr_t *pa) -{ - struct device *dev = &pdev->dev; - struct stm32_rproc_mem *p_mem; - unsigned int i; - - for (i = 0; i < ddata->nb_rmems; i++) { - p_mem = &ddata->rmems[i]; - - if (da < p_mem->dev_addr || - da >= p_mem->dev_addr + p_mem->size) - continue; - - *pa = da - p_mem->dev_addr + p_mem->bus_addr; - dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); - - return 0; - } - - dev_err(dev, "can't translate da %llx\n", da); - - return -EINVAL; -} - -static int stm32_rproc_get_loaded_rsc_table(struct platform_device *pdev, - struct rproc *rproc, - struct stm32_rproc *ddata) -{ - struct device *dev = &pdev->dev; - phys_addr_t rsc_pa; - u32 rsc_da; - int err; - - err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da); - if (err) { - dev_err(dev, "failed to read rsc tbl addr\n"); - return err; - } - - if (!rsc_da) - /* no rsc table */ - return 0; - - err = stm32_rproc_da_to_pa(pdev, ddata, rsc_da, &rsc_pa); - if (err) - return err; - - ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE); - if (IS_ERR_OR_NULL(ddata->rsc_va)) { - dev_err(dev, "Unable to map memory region: %pa+%zx\n", - &rsc_pa, RSC_TBL_SIZE); - ddata->rsc_va = NULL; - return -ENOMEM; - } - - /* - * The resource table is already loaded in device memory, no need - * to work with a cached table. - */ - rproc->cached_table = NULL; - /* Assuming the resource table fits in 1kB is fair */ - rproc->table_sz = RSC_TBL_SIZE; - rproc->table_ptr = (struct resource_table *)ddata->rsc_va; - - return 0; -} - static int stm32_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -800,10 +805,6 @@ static int stm32_rproc_probe(struct platform_device *pdev) ret = stm32_rproc_parse_memory_regions(rproc); if (ret) goto free_resources; - - ret = stm32_rproc_get_loaded_rsc_table(pdev, rproc, ddata); - if (ret) - goto free_resources; } rproc->has_iommu = false; From patchwork Fri Dec 18 17:32:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345480 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335779jai; Fri, 18 Dec 2020 09:35:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHk/EyyU1iaAKflLfv5sGn7H2jxyCo/487JORegdZiOO/Jgm33xXdV7HyCCrQcKqxbZsPv X-Received: by 2002:a17:906:495b:: with SMTP id f27mr4505323ejt.338.1608312925225; Fri, 18 Dec 2020 09:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312925; cv=none; d=google.com; s=arc-20160816; b=GjK6K0n01/LTXJxf8cJ+w+ZLXTkMKXum0IUzFQBvLQPmEQv3aRN0N33RlOB+Nhm7+n UTB2G0pGdnnRoLUC5ZzwoxmX3IzE9/+lYFphDRnHlc2gX8fvmLn7arQCqcJx43pgRF6p 2dqDzte7hQdfuH+eifPNU76ppC9hmB6ATlChhyvJQDZeqwW9lpx1ZF6q/L+SPHv82cND yE4K3/naT0pZZPTuxh4DilMQXspsfhwo2jCsl1bc25uiLKvWmQWTxmCgnris0NGrgfEg 4bzTXfT1dQZonjW5VjGVBdPgklFUeuwiez6OvIJZLRWqpS/ZnmmlAM4dP6h6i7I1uFA7 z+sw== 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=9CEMg8/C2aYpmWeg0E4atqdzCFaHxz28xvWGUTHAaOU=; b=eqZiA95qnfbTsW1zMe+aLtqqP9uPFYdb+PNML8cUAKqZLKDT19/H7OhmXvrd24IpgO IOV7EJV9MSdt6scSf+EMdAm+KTAWsyGFEcKaX8MBgObxBkeSiKrhKcPWt4FJl5XhhG+y 826eM/H8JG8TREN/KUfwqSsVYiG7Tp/LBzA+tqETz7yNAOx3xoxBKWDhRiPYGHR8axTh AfrdRgV0c9ClpgYzAMn54OrESr77AUC8pHT1obLLyilSAHGYLcCAaXZ/Th5EqrVcXnH9 J+VnVwuWBq3PBsRb7WjowyOk6F3VGNnZX6cf0ss6+wUfOHqDvkFXDSqDXGVTMUxK7ciV dmUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yGs7YdcF; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.25; Fri, 18 Dec 2020 09:35:25 -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=yGs7YdcF; 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 S1733007AbgLRReu (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732868AbgLRRec (ORCPT ); Fri, 18 Dec 2020 12:34:32 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEC1EC0619DA for ; Fri, 18 Dec 2020 09:32:38 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id 4so1760020plk.5 for ; Fri, 18 Dec 2020 09:32:38 -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=9CEMg8/C2aYpmWeg0E4atqdzCFaHxz28xvWGUTHAaOU=; b=yGs7YdcFnxcZHUhZKvzMEbe1PoyRwerMN9vB8qmQpIYY5RgBnNuhxZWwwwB5/lvtFg 9aJAr/2jeVGd5E7TkoiosCRVL+V2SC9ScrAd1I7lPVLdPTptBIB/4ja3BZ22oVY/H6AH wpHzqrnB2kie/SygjiVg0/5VGSkus9A0nJfBMGaQyoLUrvLjKQUk9NxGCznEYIopt5cf wk7hTGXGofPIP6g70XV74OnoSi7Zd8w+swDXnkXafAcUjM3MJz8BdJ9PsuxasooCH7X0 igKonz3VPr3d+M7++I1Xnr/DrGqjSSPU6VGBw0JHnNO72G74JFt7Deq3r0RBR+Adc/bY w0JA== 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=9CEMg8/C2aYpmWeg0E4atqdzCFaHxz28xvWGUTHAaOU=; b=YmLXRLOKUtmEJmLZXK8NhAIn8Turu+JCZfQfMxTwwD+MFfGSm5iIXXEw7AtQpBuLON umPkh8sIcHXqxLEyzZB+jQ+Qrp/1iLSvn5k0YYH9TzhwgrwfQNgEZx75PM/m4KlNtahy bRzin+ISQlHYuAImc6TFXSmGX0Ta9469IkHXMGP0Bd4xmz9sK3orRDfvbMuIBr7J6Plw pRjxn4lpnZCzdktxbW1rId8me+pk4uVnP0luGIUCtAl3ttg12Lhi6iblI16IFsJRMY/n /chIf9sF0PR9n3JR0lIguDOC06exBuYrEFMh/O/EeWANZ/tR8QTHsEe9bdjFtkBmXHEB HkkA== X-Gm-Message-State: AOAM533sxca94id4twLUgqS+ERYLpwDT+ZYzDEymfq8KzbYg0wZ7afzF pwmzg0yEbFxeEc1z9AsOBfqyCQ== X-Received: by 2002:a17:90a:e28a:: with SMTP id d10mr5142068pjz.77.1608312758354; Fri, 18 Dec 2020 09:32:38 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:37 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/17] remoteproc: Add new RPROC_ATTACHED state Date: Fri, 18 Dec 2020 10:32:18 -0700 Message-Id: <20201218173228.2277032-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 d1cf7bf277c4..1167adcf8741 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -201,6 +201,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 571615e77e6f..f02958a6c001 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -406,6 +406,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 @@ -422,8 +424,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 Fri Dec 18 17:32:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345471 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335569jai; Fri, 18 Dec 2020 09:35:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/g6gJsneAuJbesaOW8w4n0JLrj3Kz6HgougWj2ViyM7141XzmBSlhemfW6dfiI9HSpoqz X-Received: by 2002:a05:6402:1646:: with SMTP id s6mr5511251edx.319.1608312911116; Fri, 18 Dec 2020 09:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312911; cv=none; d=google.com; s=arc-20160816; b=NfPRypG4+K7yeLZHn4UrnUHB2QosdtWSiBYF1CJN1Kx+upKDfiR+nqb5f9ycbgUluh aThsfko42vWmVSnTUV0iek+adRd24mCuHCpnwgBPUcRzBTVut5vs7uZBaS5daZT23Sq+ 34wYD4fTU7yS4MzKHr+95q/P+FFJA3vKGMFnhRXZydi0twE/0lTAfLW8hC45aR7vexvT lLeFZ2lYHhFdUZX7qq16x8DahkNc8ViCFJAfQ9lqjZkmkkw3QSY2vZxjUMzgGGuE2MXW uwPt0ElG2kDTidTk4qILkcSfTy0LME+7A8RZqjBAd2RJfsJ+SlOgwas+TduAjwwVIg4g HX3w== 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=GfAYvBHbjdMUa8RWoEQi/iMGUW9VzhbWJlUDatd7jcU=; b=sFTw0TBCefCKyCRFfu1xy0cAAWh7zRiIxmbQ+0bvdOpEAdIeHDAtWKoimLxSrX6ONg zap+5Oy3JlykIYtcJUSTqX1xytgNzp7O5bRVWg32dR76wtXUvYqtQ6YKp/zxJkdPo70x CznwuloKIOId2TYfb2qMfdo6ZCU79M74mfgx/BNTuWOCbB5mmsqthegpLau4lGGIouHQ YLCqYGMvlHjhD4MhxcDYiR0CXcgCevu3EDxraHbU48xNAi6fobxMA5N8d6PFpH/zoXoa LvApo02Ittn0wxnpiYWzFNNCmDvq3eGgUT8mpBkRT/VXyzF5keBV6eMfpatlgpmodgq9 m8Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=prkzIuN9; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.10; Fri, 18 Dec 2020 09:35:11 -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=prkzIuN9; 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 S1732714AbgLRReI (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732686AbgLRReH (ORCPT ); Fri, 18 Dec 2020 12:34:07 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2617C0619DC for ; Fri, 18 Dec 2020 09:32:39 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id g18so1759233pgk.1 for ; Fri, 18 Dec 2020 09:32:39 -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=GfAYvBHbjdMUa8RWoEQi/iMGUW9VzhbWJlUDatd7jcU=; b=prkzIuN97+jNEpprDZ7gPj1HbaI732J7q4fHIF0k4XfYqWiNkOiy5j/hXbkunlilb2 gY5Z2ivhxKohvyOzzK4UOS7WX1imqUG1mpL8qHV5ZFcBDUZHXdqbwYiw9wNhy/yAEBdA g5+yW1w1R7HZpmhUAIAjVs7ceQYDBwCczyANRH1KDxABJs1B60hazMtOPJbB0eJfohhg vAEC5Ez0eIHHpxtVUHqfyLj5iSHZD+lhKR4+KsGnhVa1jZXKK3VEsbn09Yh9pZZqbJCD o9yp6hI2Z356ky++68fz7Q1gjr2tvzxdl77Nch9biWaLKVJ4BN7qbOMsQnSyint4wFvV U/OA== 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=GfAYvBHbjdMUa8RWoEQi/iMGUW9VzhbWJlUDatd7jcU=; b=OF6mJVNo3vAirXMn0E0B5/GpKakhU1vtGXyK3DdckhEK3nE9sCqBXeEHAcCHX0qwrB lBu7V+78cF0jmNurTcfudXzN0FVhP/+EwSftiJAxQKmc6vW7Nt213zsLfLk1MASh2Y5D ImM32hMWC116l0YRYhkprOnvJFfSxAqNBEF+P8+b/kxcdQE94XzAtmFXK8WnQ0y2HeXU T4PdKvZ5YzkiXf9FDoMa2/WQu8/XjNI0+oNXQNN/HGk6uWq/DkbQRHREmFUPczdnt2aO z1Bg4wH8aWI9YcYt7ttZYlX2gVGm/fjVg8mU1FIV1BuGWcDOmcWY1DzBPIK1xUz9qcPm 9p/g== X-Gm-Message-State: AOAM533D+b5Ew2Vbf76htyBrGElu34vb/XCgSJtPmHeWpBDbT3kHtHlF V6sP09uQVZ0hD/yq0eeTTTJq8Q== X-Received: by 2002:a63:b908:: with SMTP id z8mr5225658pge.396.1608312759574; Fri, 18 Dec 2020 09:32:39 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:38 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/17] remoteproc: Properly represent the attached state Date: Fri, 18 Dec 2020 10:32:19 -0700 Message-Id: <20201218173228.2277032-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 3d87c910aca7..19545b7925e2 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); @@ -1665,14 +1665,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; @@ -2023,16 +2015,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 1167adcf8741..99ff51fd9707 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 f02958a6c001..257a5005f93e 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -513,7 +513,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 @@ -550,7 +549,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 Fri Dec 18 17:32:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345481 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335807jai; Fri, 18 Dec 2020 09:35:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlp/rJqfj2LszYJbze111zVHURsRKeQMNtwESB693nc13+1e/UjrhoA8rh0T1sEsMCQizo X-Received: by 2002:a50:875b:: with SMTP id 27mr5620051edv.24.1608312926966; Fri, 18 Dec 2020 09:35:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312926; cv=none; d=google.com; s=arc-20160816; b=vFYSbBKHcAkEo+oTG6sRTkmnQWPzAveiFDMkwMxiDtuhoPnoyj5wW7kxq2Mw3WA9nW Wuvp8cRXt7tv+Kp6FBUwXtCOuZSyuVaCPEIUr7FDkr+aVp4y756AV8JKKSqCykt1T/+d hyKkeY4032GvPL4av3eSfhipndPqyKmT1Gvurb2cA+2U45KU8s5SypMphaTiq7CH32SG +i6k8xxQ7h2yJp0mvrV/b3KcqguILD37pL5DU02x0P36TEdf/PNUppF8qH/zc09fDwgF f2Xt/ols2mwBLUeZAwa8xYLpPf4SKFt9UadYs9eoc5xKPLLa9WMri9wCc6uZypLe/4M2 nJSw== 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=S1HgCKBSeYWceu/5Tsos67As2E/8FgrkAm9u2K2eWO4=; b=m6JRacTvgK0gPubh01oEF4dSHFJGI2YS9M9Fp+02EZneAsN50/hKIDZy8YXMSaw7ET 4oEoLzdslKhnOTfe3WN+qKhQtEHs8q8Bc4zMEK0P90N/K9EbhQK61H2Q8ErFfAj5jd3i X+Cfh937/zB14wBAgwWodggfIehBMPGSP5wfyN9m7gdwF1QM5rI186wb13gEidfhLKzN 09IHhqR9QhRrw5OZgGeQC0Zc07bu9XQo4uT5pP1WVBFAzCxb0ggdykTw7RU60dNF6vFm Uav1WhBv9JcbTx1BJQCrJeuDoTSVHnDW18EgJERv88gcu6A2tNQrh5e4M7ir+rfij1op VPhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K3x5/W+4"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.26; Fri, 18 Dec 2020 09:35:26 -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="K3x5/W+4"; 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 S1725932AbgLRRfG (ORCPT + 7 others); Fri, 18 Dec 2020 12:35:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732696AbgLRReH (ORCPT ); Fri, 18 Dec 2020 12:34:07 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 290B7C0619DF for ; Fri, 18 Dec 2020 09:32:41 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id g18so1759266pgk.1 for ; Fri, 18 Dec 2020 09:32:41 -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=S1HgCKBSeYWceu/5Tsos67As2E/8FgrkAm9u2K2eWO4=; b=K3x5/W+4ULJWJq8l1Xd1CrmV5GLr2egnactNfaaxBBudoYDP98hWuY9AKWADXn3sNo rg8GirM0BO7YfJ6Xx/jTtMdlMnhoP1HC1SMcRAlMtni21IomvYF98rQ9V5uYtB7P8fuw jK05p4Xz1+HGRGpohfJXxFPnqPXtoFsL2qlnqbf/diJ+x+XukYL95mfJNYxypHI2uybz VB0lkh1qPoU3TrgQXk8THBwebaCScTknt+tyZqOAar1y0PXPA9m+rb7hhm4ieF7vVO1W FOoHkIvQup28bX6TAzsW4LKjS/884fW9yO5LVDXkBrbfvRDWrspz/gugSNIaOkDb40I9 vdKg== 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=S1HgCKBSeYWceu/5Tsos67As2E/8FgrkAm9u2K2eWO4=; b=sqwEtZ0jan/qqVD1aKFsEkvgj3axoo8+Y9odJyDAmvvwBrXsJ5PC+D0mvVb6qcCZmX +6gcLaRS0g0OutTcLEZCtCpUm+UNU4wRzs81LupGT1+HB2NfiQtasM2AV+sWrapXbax/ W82OLDnBQ9jHl3shcwP0HGnBBZE432X2qPX27b9QXGP40dT9ferOR7N44cx6oE2XOfh1 rCj6n+gJ2GIncjBY7CsCGnlAkuHDFHNkGGumufSHEx/pZhkRbZZSNZlQmAKydsd7QAJ2 4sMwcnm1MTmFwfzKzsnfxtxv7jdq1JUY0SiwtEpjTa/bbDxl1H+Awv1kIgJuO6vNJZ7X RSow== X-Gm-Message-State: AOAM532LiPAzFKDgRUhI/JW3uddwPLc4uyk8SzDKKf3KvJ5Fj5XJofZL vG8vatHLDQo85ZBwFo+liqIhUw== X-Received: by 2002:a62:19cc:0:b029:19e:321b:a22e with SMTP id 195-20020a6219cc0000b029019e321ba22emr4824607pfz.73.1608312760748; Fri, 18 Dec 2020 09:32:40 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:40 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 09/17] remoteproc: Properly deal with a kernel panic when attached Date: Fri, 18 Dec 2020 10:32:20 -0700 Message-Id: <20201218173228.2277032-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The 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 19545b7925e2..fc28053c7f89 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2414,7 +2414,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 Fri Dec 18 17:32:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345477 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335684jai; Fri, 18 Dec 2020 09:35:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqaXmEvgg/bzzYxoohDkTorhHnuwKtXeNTXe8j9peBqID4FHJB21xRQ7pM5NJJvuIUuou/ X-Received: by 2002:a17:906:402:: with SMTP id d2mr5079063eja.35.1608312918757; Fri, 18 Dec 2020 09:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312918; cv=none; d=google.com; s=arc-20160816; b=yydNV7nx1vMlaA3mzPtZVSZmJ/hJt5Cu8Uy4+CDxqeh9y0o+U4vu8UQsv76a4bbWdL OZTF6rPzYsgmWpUBxuQ+BS7Kd3lWaStAXiKoHLCelmgxp8dCAdVzZJeluIh0G+OQCctl COs6Pl70SEIXIrwl3+WIDTD7P263wLK6Tb4pqG5VHH2ufr2F6GAOl4FQxjs6HM3IwJDQ 7WHMcnrStfA2Befw5q8gM8BPELy8o5so/xhQDPFluavIxm9rvER8HjkOimJ28ZnHMzMR dGba4C4PCFtPjyibFIy3PS9cwUl5F3QC+PEtBc1LcgvO0LTwwt5sJfSvF3M7N0kc7Deu MwMw== 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=UE369EIBZVX7NEKYpAqFRWbqVEboyiDmoTqg7mEP3ho=; b=LseUl0aYI7/FhlesGVRagXu8kgGltRhqHip1UKj8vqL43U65WxrVhfc7Z9o7CITosh ONTNO/2ySMIV6CgQi9Oewn4qDjLs8dnaK1vXIAkEfeOdNzYl5DCDLXlFK3sRVLCwcD6T 1KqtOJhAquTEDhN20wSsyBoeosooB8fOZg7PiY0B4PJxGMcnGbqTzBKWPQDIRHvYj1hb JOeuQF3beTiae0qshoIlJIHgm5rwTw0xbyA+KcQHg07YR7khID21VVUTZrRoAIjlAtgg bFNacaQSR0pdhD9UKi+IFi3HvS4I4mpZRHVZ1NlRGP/XMvtQFfYvCKWuJ5BPIO/GYAfG OuAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CjxlpfgF; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.18; Fri, 18 Dec 2020 09:35:18 -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=CjxlpfgF; 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 S1732912AbgLRRed (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732902AbgLRRec (ORCPT ); Fri, 18 Dec 2020 12:34:32 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7F2C0619E1 for ; Fri, 18 Dec 2020 09:32:42 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id f9so1922258pfc.11 for ; Fri, 18 Dec 2020 09:32:42 -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=UE369EIBZVX7NEKYpAqFRWbqVEboyiDmoTqg7mEP3ho=; b=CjxlpfgFxYohq4V6dQAABJ7LtWFo36J+n71FUwHVblWZg4woCWLtdlLVEda0nM+ykH LW8zzer3KscVhQHeDYXyEPQUjcaj8tsmHwlw6jOx9VeoUg9nt0Drmr8CISbSkuSmdght huZOgv0vSZ1Sr4JdC5la9BWhQcYL3pM1URaNJYb2eqeti+QiTEKvKQ0RWKcuOKrrxhBH X9R9+v2CoHxRjz6UEumU3MCNW8b1gynT1C7RoDlupJ6srcEKXGhuzz7U/vxGWjbNS699 ZOQE/C50/hIcZR6PgPhS6LWvlPIbxb3BOC11B3abtkswhHEfMniA7RW7Ov5O2WpAqD5v CGyw== 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=UE369EIBZVX7NEKYpAqFRWbqVEboyiDmoTqg7mEP3ho=; b=dD6sJbIQq5H5aaQJv/096kF11l1Sb9s5u5i8e1etfMfXGqNns69i5GYTnLQ7OzPOWb AndBu+JGMUmKiswwZD5m1NVnKXTqAge1et+SZui9W2tTTLnq6js5teGhF+IAjru/pX7k vt+Z7ha3n7jRVj09VCduSmekld2vX1mLFH7Oo+7zQvAW8xXrwLocP+x2rl3UFBF4sVrI 4Vssf5sv0EM2BFZwJQ5KnKXZVG5YxjwmfY3cx8xPu0kQ0ZsxDu/ih0QbyuTE7tqCTOwu yccxPGFUfjvaTgUG8Kdx4kyeIbultvuuwIx7MzG7bzz1ZFkjZ04JW2jGcVHu9RA2QF7g syRg== X-Gm-Message-State: AOAM530PN5JDxSZL4kUeACCrQNXXlPN/ot2yjxv52w+7imKSiT5oa7a+ 6EN8xacyV5zc2c22FIZlzupmNA== X-Received: by 2002:aa7:9312:0:b029:19d:fa90:3f42 with SMTP id 18-20020aa793120000b029019dfa903f42mr4887642pfj.18.1608312761769; Fri, 18 Dec 2020 09:32:41 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:41 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 10/17] remoteproc: Add new detach() remoteproc operation Date: Fri, 18 Dec 2020 10:32:21 -0700 Message-Id: <20201218173228.2277032-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add an new detach() operation in order to support scenarios where the remoteproc core is going away but the remote processor is kept operating. This could be the case when the system is rebooted or when the platform driver is removed. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- include/linux/remoteproc.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.25.1 diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 257a5005f93e..9bb34c3eb847 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) @@ -384,6 +385,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 Fri Dec 18 17:32:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345470 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335564jai; Fri, 18 Dec 2020 09:35:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9XF1xdDe+3wcT7TfIjSUIIEaZ9uBDexQPp5XGbqW3seUxl+zOfeW7l85pmoeEZNaEFWVs X-Received: by 2002:a17:907:210b:: with SMTP id qn11mr5156796ejb.41.1608312910764; Fri, 18 Dec 2020 09:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312910; cv=none; d=google.com; s=arc-20160816; b=SFxhIgKhKzIT/m1U2zPYVFkGIROtZvAd7UOdOgTaMA64k73aTVeeGHeL6mLKEXsrHG Z45dHNM3Ze/DU37reKQ7wYhPa36fhCP5/HyeSqaBT5MruTpi42t6+UTnfDeRhjGqpcBF 9DqrAaYfQNkM/gRfDIXNUM701PRB7SWrvfvWN2nuEzW263unruR3P+Fvi7sUAJtVbWRn ILQuJ4tyC/dlb7+ccZAps2Y6VpvyosIecJaeOvJ0X8wDr8Ngv0yNRulDD/HEDDIA6UvT xXnLy79a4+ENqWMa4qnSyWTTCRiP1+zAgO+WjjTsFSygRg6BQtQ5hFVsojF+AS6cBhDc fJXA== 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=kq/8af8gfyQHRLTjjFQpBmU8IlBKCx8ZUO1N7tlkmUM=; b=XRzz2K0s40Hm9j5srG33dKO9yy81B2CMEF7BIBmXAFjOzm6RohCrnKMmIFkuKqeY5X 2c0ATcgffoS3YNU9qOsaplcZX+YFoJiMomcormUtnjSufvVB9lJLXzINiYHxwKbe373t atsjGUsSasQHwClx7xZR2pOkW8h3ct5qq8+FphxluB4lhZj0PZhiExL0x2iL0H40YvYv r/SvfayFxspZmVhWhdztfvRDhwgzFys9V46lvcFQD0ipws+hfNUx8+vFjfMlLJAo/HLV BUAAJzdJCC8S2rVG40Hj+CSzsQ4ycv1AF4W8eSwGaiL87Ex7yJVZN1b1o22+uMUOtWD6 AQCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xqy5A3cJ; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.10; Fri, 18 Dec 2020 09:35:10 -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=Xqy5A3cJ; 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 S1732652AbgLRReL (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732712AbgLRReI (ORCPT ); Fri, 18 Dec 2020 12:34:08 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE71C061142 for ; Fri, 18 Dec 2020 09:32:43 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id i7so1744370pgc.8 for ; Fri, 18 Dec 2020 09:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kq/8af8gfyQHRLTjjFQpBmU8IlBKCx8ZUO1N7tlkmUM=; b=Xqy5A3cJrzblGn7kkF9K33fBX2hXDtOtmwTf+9wvM8bXNE3G4KFPGZ4lqjziYwxJIC 5pultxhG4IXdogclYCM3/RVu9w30nQ/ynI67lOSHfm5G4XPPb38I8BW7JhrBs9rMQr/o 8o7UCO+zUhE7aAlHdIwfSKBUs0ZqhWLPGpTB4a0Yu2Iww1eDG7BWSDr3a5xLqDhLrR3S rfDZ1zIn0jnkJTo5E45UmQkGvHRlFQ23IcYsUKGDddXxRQeG9GFO2hL4kg/gWvOgD0m5 breNaRghLvch90zF8EyPek85TkUj+UKKdQcvx3Yc/G4WFsilC6wDe0YE8WxWeilNvFKN iUHw== 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=kq/8af8gfyQHRLTjjFQpBmU8IlBKCx8ZUO1N7tlkmUM=; b=HrVoPX7DSLZuuzSxi5PKbMnOQL9+nbBhfJyBkVNJWeZowq4IhfRu5kcs0jOAcCYLse wbfK67Uu7MLBUq7O3v8x+Xuhhn5OdNI2B4Gu7MenDlD0ftzQW2g0vSQgTBXAOXDNfHC4 zuJJIFRclw6Y60ffQ1W3bjz4ohiwHwis1haW0R0JYu6BptBsSEW1C5FKJl+K5wXv2lmx 5krJ747mAh1Xk/1NSpTwHprou1kdnBO2FtZP+GlGP0X94eWXk6uzxWWlGeyT2M/J8r56 K/iRpZa9c/gp1Af7h3LB1mzCfti1b8O3eJL2cHGi/867+ZIm4bMeC+C6vfkiPINAWlZ2 NRPg== X-Gm-Message-State: AOAM5309zwNls0zj+6OEPAeReZjWwZ6Muw+ivDeYVsVGWHze4ylfLhc2 kBXTwhRPtK/1BYLudhROoph5kQ== X-Received: by 2002:aa7:9f09:0:b029:19e:cb56:e124 with SMTP id g9-20020aa79f090000b029019ecb56e124mr5253730pfr.38.1608312762797; Fri, 18 Dec 2020 09:32:42 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:42 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/17] remoteproc: Introduce function __rproc_detach() Date: Fri, 18 Dec 2020 10:32:22 -0700 Message-Id: <20201218173228.2277032-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fc28053c7f89..e665ed4776c3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1670,6 +1670,48 @@ 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); + + /* + * If the remote processors was started by the core then a cached_table + * is present and we must follow the same cleanup sequence as we would + * for a shutdown(). As it is in rproc_stop(), use the cached resource + * table for the rest of the detach process since ->table_ptr will + * become invalid as soon as carveouts are released in + * rproc_resource_cleanup(). + */ + if (rproc->cached_table) + rproc->table_ptr = rproc->cached_table; + + /* 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 Fri Dec 18 17:32:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345472 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335610jai; Fri, 18 Dec 2020 09:35:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxK6Tv7hxVQJcOl0D3ekdmlGxQScMJLQQZNUVc8C7cR+vDUwL9rvhdhbqCthPiuyHQrEwly X-Received: by 2002:a05:6402:229b:: with SMTP id cw27mr5419334edb.23.1608312914280; Fri, 18 Dec 2020 09:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312914; cv=none; d=google.com; s=arc-20160816; b=E5Pn3PuaGwYnZXOhNQyTuKiy77CK079rSjgdZ9jegIdCmOIWe7asyR2Ft3g0dhFoCs txMXYc1ONjw/P8Gk3J2lJU9cQ9RWw6pRNCaBmX15UVO9d2412BvmZP/rkLYSQ01W8/eo hxoZp4Ln/kKU0jgc+TAmpbXA1MKAK5S68Iw5wa6S7+HYLeG/zTcXj1nvkHes5F7dTnEs Rfn0X1VcVlaIt0lwM+Hp8t2oJhq7P0jD2pNvE27tfimd4X6+69LRbD4JMUkulAVWeP5F +Rbm34rhHPca+fXtz3OT+5lxWJ5hnp1ifcASTp0et90uweQMtsRYwgX/9H+QbMGNhPms gekA== 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=H4g2ghZevAZZMEldVnDmhvjfkN3XHebraEOrSS89kQg=; b=HOSOl8Mr3B5p9lGEoWJJjJSR80yglrLn8nUt16kPIX5Fm8XwidNYxlPqIwqiFiIkec IPUGW3k17vzZlBD0ZcOluxs8SvVRQHxXWItBdkrrqcffAs/L4HVXKp5m2i26R+lXo3HJ lGXLIvkBC8+cyd8KRxKrmLHF3cBUeTHzA9zeOmLQNcnrIBAfqc64XwWW5HQ6vb71fXFJ Qcfhr9BYf79GStSyJHmv0gWx87J1V8VhIH9L7XHiyb93FSjrb9ppAf+Og5+TckuzEQW+ PKYLK8oDu7cTOpK+Q18Qv1lRH2IJrJwOoJbYIqEFAU2eTgQDyWc9cb88S5q0QM2AJejU 9W2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PiGtjane; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.14; Fri, 18 Dec 2020 09:35:14 -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=PiGtjane; 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 S1732843AbgLRReX (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732798AbgLRReW (ORCPT ); Fri, 18 Dec 2020 12:34:22 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 640DEC061A04 for ; Fri, 18 Dec 2020 09:32:44 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id lj6so1679124pjb.0 for ; Fri, 18 Dec 2020 09:32:44 -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=H4g2ghZevAZZMEldVnDmhvjfkN3XHebraEOrSS89kQg=; b=PiGtjane3hJdt4Yln3JhdBS07fwTZhgAKnMXQnHbOJg02WrEZY4pz3YJ6hr/Ztqkiw FsL0ZJomtWNko8fzcpuOOhFObhAwJMmucvfWrG32NYCh5SaQKS0jl2WOdtNykfh3LIsl gqj47HipepBxZM0Ahsq44RoEEdyquekivZtMsSTDX55neWf+4V0s3M4SmRAzJ/sLTf1a +bVuL+hPj0R0jQOWmWOqyiwk5iOBSJKJyvr47O6WdYhxY5lA9e8lSfLHOvklMPNAzivZ DEej6VIJ6XM3KakaIPcXrn7hN87taHfBENbmlBGkcmDJMlVdzOtS7dCfy82Wr53Ty6GX DI9Q== 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=H4g2ghZevAZZMEldVnDmhvjfkN3XHebraEOrSS89kQg=; b=hRHZjXHyQ/kzDn5kB0KAdu9zMKOOXhj6g0qP5UOuChNPC6JtF9WXu12ow8ySr5bM3/ lHIcpR+D+qxq1gsgw2so/7gsXSkN4lok3FiWjnx+HrShgMitiTtjCBzmITWPIyDuims5 kSLAO8JSsUCou7+NEu8p5x5BfOPskmDxdO9NHQjLvoTfsvJGqOBRPS5pl6/35Uh+Rezh yts0OQPbHWewHhvvr3uczxg+9RZKowwuoP8nDpK5SBDzau20dbvIIROTtAddpl5VtW2r GmG4LgEM46pNJc2ZjO4eJVPeiZC/RmdROHg7fv1TxpcYhBe9yuIkN2tL9dsmtABkODfw 2rCw== X-Gm-Message-State: AOAM5312MKfq6fayD35pLubmL/OuRnzrvtOqzZ0MkDhW9ny0oTUAzlZc k5V89PiEmqgXmtfjW6RqzHcaml3HGyzt8wdk X-Received: by 2002:a17:90a:d790:: with SMTP id z16mr5371190pju.88.1608312763918; Fri, 18 Dec 2020 09:32:43 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:43 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 12/17] remoteproc: Introduce function rproc_detach() Date: Fri, 18 Dec 2020 10:32:23 -0700 Message-Id: <20201218173228.2277032-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 | 71 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 2 + 2 files changed, 72 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e665ed4776c3..ece3f15070b9 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1673,7 +1673,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; @@ -1927,6 +1927,75 @@ 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); + + /* + * If the remote processor was booted by the core the cached table needs + * to be freed and ->table_ptr set to NULL because it will be + * invalidated by rproc_resource_cleanup(). If the remote processor was + * attached to ->cached_table is NULL and kfree() returns right away. + * + * In either case ->table_ptr has to be set to NULL. It will be set + * again when the remote processor is re-attached to. + */ + kfree(rproc->cached_table); + rproc->cached_table = NULL; + 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 9bb34c3eb847..65ece6f177b7 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -659,6 +659,8 @@ 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); int rproc_coredump_add_custom_segment(struct rproc *rproc, From patchwork Fri Dec 18 17:32:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345474 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335648jai; Fri, 18 Dec 2020 09:35:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYClHLro16Nut63c2GT/YxbVhWteUed2tvyTXUcP55bx79r+OPl3Xn9eWEaiFszSH2ydfd X-Received: by 2002:a17:906:f8d4:: with SMTP id lh20mr5045382ejb.442.1608312916161; Fri, 18 Dec 2020 09:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312916; cv=none; d=google.com; s=arc-20160816; b=fTQwh0QzMOOxoR9KlQu8+hOs7mlSnZQ6L1zy3W2AnbDgPUbDkUvxeeaFrpNaO6SW3z V+hLU2+TMnAtbXsLU99Z6K6DNQdAo6d1dU2V3Wa2bEYZt4tuyzYtDz1wuJIt8gNR25dq rFfjNv1UJMszbm48MYjWUU85JunaJ7kfjmwwqB56xlV2AaZlvF7zZxPRQWtadLSAOMBL 5/oT/X10MWcBPfV8+cNtr3vhcTULsYrXa95ck8qdcIymk/wQ285jP2zbT2Sq62oMqWAF +Ujaax/WBxmVSotXlxnmnu16ctYdbiAA4ZapS1C4XAmthWdxuLma1Y7q+g+rzfEGzsBm fXdA== 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=uKSTphgWknohNFtSvHeL9OjdtOYRpK15kmrAWNQQraE=; b=fKH6UQs6zXa9QyhRkT3jPeaUYhYuj5T1XcCzVODK8neiTiy8jO7Jxmibau5HtLBIyH m0NemP/sCh5m2pmGuzjNj9jkE0g9EpbEEkrAK+YTrXOx8SW1duuqoSjk56FNgCk5YMmA zH857LLdzdn/deZd9KOP05uShW2esm52iyhXhq/qecYYMYZ4XIQmzY0LAV4mfCGHylOo fDX9AhGp1p1yL+wYSq2jhk9hlY+hJCujFj4xVYehVWqP2SRnFH/CHv+I8dT+ffKnNfXJ erHrawuUoSXjJfDhSeH+P2XAsVAcOHIcKzc8agyDkgutWZTope3eWaxx6cent3nlh68G 2Txg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sgu23wLr; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.16; Fri, 18 Dec 2020 09:35: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=Sgu23wLr; 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 S1732837AbgLRReY (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732831AbgLRReW (ORCPT ); Fri, 18 Dec 2020 12:34:22 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABDE6C061A48 for ; Fri, 18 Dec 2020 09:32:45 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id g18so1759405pgk.1 for ; Fri, 18 Dec 2020 09:32: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=uKSTphgWknohNFtSvHeL9OjdtOYRpK15kmrAWNQQraE=; b=Sgu23wLrVw115S9/YyqCMr2Y0KfHFTxj1vMq0A1WmMhO7T3Z3IYbXsGL9fZ9vZpWV+ NwvwjEizp4EZgh5DHKkTO+7opKvFbblxnzEKwtbWFxMdGkeSl34oRCksoIWEySV1QSXW XOMLxcxDPy/6TNC6cCL1lYiaRLXsjbb7O9Ubco0yEr39D99u5hoXsmke5LvldHNQhp46 YLb9nLKZFhQPXwmBCeLkmU6u2ZzV+25hq7ODVyshWIYIjNS+F5/bkEq/Ms+icIF0ismk 0Xb6XXvH1CH9opA0XIjWOq2BrhSF0Cs6RBbq4RUU2KLCUBFedI0ujuavSJ51FAex/r7V 3JNw== 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=uKSTphgWknohNFtSvHeL9OjdtOYRpK15kmrAWNQQraE=; b=MUetgUzsY4+qC/qYp8KV9VM5QyzEsVqjwP42lH2GNYtPfGektdfxZ/hUB1PcTF5HAw KHYJOvKGPmB7WmqkBG7fbK2HmrOEoN7GAG2MdRIfkBYLdIWFEzpoD9c8tlMatXcEJkYW zi2EOGDaXrROJ3bjgu8cHRa/9jl4ekgi1JmmjXwM8caRtoXn9EbVLc2E1FxmG+gTsFjd lcgiEcOtdCvibVRWTvXEyD9U9pGD6XLzWuqbl6fY/Tk70kQX6WSG0+jt0khO2BjpE2hn ErOzl367pzyrTVliQPGk+uYnfsopEc2kbY/A3GOz0634QKwG/MIvG30UVfH/hYah+ZKp AfxQ== X-Gm-Message-State: AOAM531VRcz51Udxh5iBCaNZqSLJYXGmUYj4ACpCjQj6M0l/5Z0f0hfA qACvYb7mAWpPEwfICug41QO2T5jUmWGt/8Hl X-Received: by 2002:a62:1749:0:b029:19d:960c:1bb8 with SMTP id 70-20020a6217490000b029019d960c1bb8mr5302964pfx.63.1608312765271; Fri, 18 Dec 2020 09:32:45 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:44 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/17] remoteproc: Add return value to function rproc_shutdown() Date: Fri, 18 Dec 2020 10:32:24 -0700 Message-Id: <20201218173228.2277032-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a return value to function rproc_shutdown() in order to properly deal with error conditions that may occur. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 19 ++++++++++++++----- include/linux/remoteproc.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ece3f15070b9..90057ad1bb6c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1886,7 +1886,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; @@ -1894,15 +1894,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) { @@ -1914,7 +1918,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); @@ -1924,6 +1932,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 65ece6f177b7..aa5bceb72015 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -658,7 +658,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 Fri Dec 18 17:32:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345473 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335630jai; Fri, 18 Dec 2020 09:35:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwE6kMZC0uo9xXeVUmPSm2a+GkUgFe99EmiBOlzElSpN+i/WwwX4/OOtn1GkdCvGBm8UJPK X-Received: by 2002:a17:907:210b:: with SMTP id qn11mr5157112ejb.41.1608312915317; Fri, 18 Dec 2020 09:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312915; cv=none; d=google.com; s=arc-20160816; b=keATTMsRVAn39g+mvz7rqDYGkDIfFbFMlSC/Bk9K+n4rXwX/vB3SOiN4aWD6W78yZk 2x1GjCWcP6qfnEDXII9KEILMUAcsYmEfJAiS07rkDs7ZrAaD2r4Px6TdKeBu3qDS2fT2 f7Ufw725zdOMWTTFNeZTw93mGbi+RpYH9a/bLCA0682y+RojhKJIloL6RDGIIVfGxOw2 us8HVGxVUHb+rgJcKn8kfWiZ6lDzDUtfRX0XOJPIaZJm4Se51OYKnCBjmlzJ2XcGAnyF VJu0j1IeFMOiAyOC5wSIl1aAeOJnYz3f/2nxSJdqYjJJtfsHygzxa0Vo1K4BVEOaE0eV BzNw== 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=mdgob6jb0rUl30rfuLBWyS6H4rN7qpxnzyGATQ2xIt0=; b=KhURj5AisCeFrXsEfMG4GFlfXK5bn1LfWv3kNJiwbP3v0IR69rD28lxUz+bBg6ax64 iK9O1wZ7QRfY+nc7W+Avh/S0RYjPwVNsuSd2fAXJBMSmvlBYlTFS8Bhy6SGytsRhMMIW YHlEEUHpPGLIcIZ/ZNQSrpxakYvlmkKIxV63fmylw0xvfxReLs4RRXn2oGjsJmmOBHtO odM6HmxVxYAq9ukYijZrGvrZ6XghjLSmCY4RAkUsRDCLYZnpP/RajPMtMJ85uK5wl9eg ddbyj0HKL01rMvElmmWGBV5tkHZ463ISpLaJLWutJNrDye5g28MwvsmHBEsPe4uVCiSt 5FKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z/bCGb66"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.15; Fri, 18 Dec 2020 09:35:15 -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="Z/bCGb66"; 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 S1732839AbgLRReY (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732837AbgLRReW (ORCPT ); Fri, 18 Dec 2020 12:34:22 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEB70C061A4A for ; Fri, 18 Dec 2020 09:32:46 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id 15so1745272pgx.7 for ; Fri, 18 Dec 2020 09:32: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=mdgob6jb0rUl30rfuLBWyS6H4rN7qpxnzyGATQ2xIt0=; b=Z/bCGb665F1fxnTF+3LEJAjTLAyRytVrF5nB84gRSWFkw9pBOTDRyaetGJaVASDVf6 +nCf5Bzq1+bCfC0ZehUxmqVXTSEF7Ox4nPgslBlQKHFo2pX4hZzlnMxfuMhnTpEIy2t3 QX1JabKmP8D2ajzElTIJHWwsg0XxZf+Sdj4mOaaDI0x1Zf6hS/8e4LAS3GjSgbVQsycU uXtaDQOOvuGn6B9+d41ZrH+ckbZzv5tgX7LMEi7WxfusAahQEnVXcCvdEODCIMX6ulCo P3yNhh4uYuuNmDcUhd8xzicCX0lfgBiSzor5WZTOjIfdU4Pf4pHUCtMsPZ0nMFbppxC9 2IOQ== 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=mdgob6jb0rUl30rfuLBWyS6H4rN7qpxnzyGATQ2xIt0=; b=CIH2hU7Y8qjM5eNmAhyXWT8VRslkH16V6X7fIgSWtB1Fl79r/pQEc3YzXUwJ7v9st8 Kfb9VtlxIU1Y35vj5Tu/+VM2y8/VYNR63eZkCpWnZ9eL/gcMekr7l+1SXELXQEnvS0dh cHtn7G3DlDt/EehFywlyvEb71xwI+HKohvFT9n5h4687ryEp4//mnpYUV+/+9XiTtSe4 lFBYsx6Qd5weXWsz7j+WxfGMnqaw+OVLk/2Wh+AzzZxVB0IouuLcwVsKKRvsLvTdpA1v /D0mvkaX5xSmvvBlF0cwSqf/MAeIp0n5zvrinjx1ypW6Egs1VEmQYTF/j+b4JRTEkVwG f/xA== X-Gm-Message-State: AOAM530xwKXfU+v4z1jK3goix/ZNN28cojFCKWSE85GtbySS9+bbt04d 5xb4YXOA2dSTHC8TRPmHPuJRCg== X-Received: by 2002:a63:2fc5:: with SMTP id v188mr4987089pgv.243.1608312766353; Fri, 18 Dec 2020 09:32:46 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:45 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 14/17] remoteproc: Properly deal with a stop request when attached Date: Fri, 18 Dec 2020 10:32:25 -0700 Message-Id: <20201218173228.2277032-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 90057ad1bb6c..2fe42ac7ca89 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1648,6 +1648,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); @@ -1897,7 +1901,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 99ff51fd9707..96751c087585 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -230,10 +230,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 Fri Dec 18 17:32:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345475 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335672jai; Fri, 18 Dec 2020 09:35:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLnZdylGFP+A2fKp2D0v0mPwJJoDvu7BFXJB1bz2xj8gK/y/55+AAJVO3/8Do4sI2Bjrsa X-Received: by 2002:aa7:d6d8:: with SMTP id x24mr5550009edr.105.1608312917273; Fri, 18 Dec 2020 09:35:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312917; cv=none; d=google.com; s=arc-20160816; b=jQaTZ6LdVOdpWcQmsnz4GKs6o3UOxgpPQKOK7xtse8lkLjsyGI+7nLy2nzUT1bkqBX +O9l0Cek+1ONqKttET4fx+YjFPlDwRJUrIfLpXty+yZjNpL92A3x54Xs8276nStvtIxY LbeCJVRwMxeo4+hyocpcGN2hoOrG/WcyXvALLKDvFOYaJN2Vc3e7h8qq1lqLJpfth0ty bkC8OEVQTiSiRRSS9en3I6kYPf9x5Xa2Qzemcs0z/fe6q+Ot+aLT98vJrm5kEojwCHva yXeyYaZRhbY7/Nh/lBryK021cw+r8oO0ZCwUqU1JczZ30FAA6aQRA1BUaOKhbpGey/AX dA5Q== 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=vutdwpz2dUDTweVlb30ERc0HCxLnN2+/Hjzz5Y0E1bI=; b=w8QHc1U01bXOYPBOIYtRvspKl9OWWCOaEs00eUVURDqcO3IRpBH7uhULAGBMFD32FC maL0vEhHnHrVfWGq0mwmjYav5OSf7FSOPvN780O7/zGz3yRv2aXhV5PJOPqAj940z0y+ YQoQSXe7QCIE4NmR0bNglLeyJBk/9i9IIUkKgVNETm4tNcmOqX3ql2QAqDwS+wWloXw3 +nRe62VRPOLqYPvoqLLc8pHr90WgJ07aI9NHBJEFmjp9+9BgltqtYtuSSL8Y7aIQXiwQ 60/zO1TTY6vVrOGwz+I4+rI2N6r85mi5Jptll3dlKwite/uMs5H6dtB5hXK08RJqAeWo 020w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BKXSrxbX; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.17; Fri, 18 Dec 2020 09:35: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=BKXSrxbX; 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 S1732869AbgLRRe3 (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgLRRe2 (ORCPT ); Fri, 18 Dec 2020 12:34:28 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17644C0610ED for ; Fri, 18 Dec 2020 09:32:48 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id p18so1735407pgm.11 for ; Fri, 18 Dec 2020 09:32: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=vutdwpz2dUDTweVlb30ERc0HCxLnN2+/Hjzz5Y0E1bI=; b=BKXSrxbXnh6d2zRd2aZGKoJTdugQUWnvySJCEm8scXWnxe9+TXu4/81oD7MQ7cAa17 gBO+juB3m0O1fJjMKmtwbmlZgSx+e0JTk0c0HSQxxX0PtJqu1sIPMrzlHOrooOtCcSlV jBWWe3U8wAgF2HAAPUjjDl3dn+tkcgA2TspNkWMz0iMrwWGEqpVYwi9SA/2ycdhEX7EB ZroR/ixb5Fa5kmAWWEgaoiZgosqZ7gUGLmayhcP9HTnP7Q9Xz3hklPJzJNnEk/sy635S mZImmX9q2aaGbnoKtTFr/Lu2XDsdDRBFlAnGqEILryiXq7xAUF5u33LS7NVbe1lAjHJ7 TgaQ== 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=vutdwpz2dUDTweVlb30ERc0HCxLnN2+/Hjzz5Y0E1bI=; b=oTJoIjPctd8w/oA3smMozIasKmHGeCmgNv3d/OL3lpnzUsLZI8+GACnmg9SJ5yrJEy 38BN04HSwoWWUXTGv3JT25VDPZDwcOK2ukvaFv9dsIUDeauuqDoS7NFnt5/IxBlmlhH9 dFk8U4td6ihkn0nRs1Th34nZltaZNGMMv0PapAZTKDE0vfcb9MbZhOsmFrO6uSnl0876 e7CzZ/lRyglgGOT1bxtDN/kAP/YkP0FRbGqYd5f0Ou+cabGjnL24+WO896WjkSHqVvf8 WgsGhSIok3BQXeRJjk1GR+Uf3OsnXjP4lSfP7UMkXtNj48OeKz9Vz6e+n9nYxkmqv8JK nd9A== X-Gm-Message-State: AOAM532ubhXU2HtotZJhYQgY1W8AcW2reTvMJddjheC/mScabv7K5O/S tMUSXx/erqTyGoI3pZythwKnOg== X-Received: by 2002:a65:4c4b:: with SMTP id l11mr1097792pgr.177.1608312767705; Fri, 18 Dec 2020 09:32:47 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:46 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 15/17] remoteproc: Properly deal with a start request when attached Date: Fri, 18 Dec 2020 10:32:26 -0700 Message-Id: <20201218173228.2277032-16-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch takes into account scenarios where a remote processor has been attached to when receiving a "start" command from sysfs. As with the "running" case, the command can't be carried out if the remote processor is already in operation. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.25.1 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 96751c087585..298052c9d068 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -223,7 +223,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 Fri Dec 18 17:32:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345478 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335709jai; Fri, 18 Dec 2020 09:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd5sLTRN9IzPkhnp5bzX6hr4fBVysZx7Nc/wySKU2Y3QoPbSVhqthrPxSV/XzBSOAyMSWc X-Received: by 2002:aa7:d6d8:: with SMTP id x24mr5550228edr.105.1608312920328; Fri, 18 Dec 2020 09:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312920; cv=none; d=google.com; s=arc-20160816; b=Epa69yFmARYBbEhiDZ3sE8F4SP0lE/TRf99ajua7JYPofoESITa6cDC1SLRDcbBWXp q03wKzAHIGdZoyulW5xm8LISx19IsIsWaUxMsuwO5wZ6GaY2aXhYxX6Z0GoBtbomKqwb 9EQES2DaCS4jRr8ylVg3T6WiAmoYkSz94OLty7ZUYUD0VzIUuit9evjpH/UblyFp20lf BFn02veRscYt7AyA9b66JLvlgITjAjjyXeJ1OIyHtQHYwY1h3DbFGptYIdSyRWRdM7sy zvCrqGgAm8qOW9UNQ9scxzh+lZ0JzqJ1jIchpkuVOM0k6XuVzsa0rVvZ47p34koFmc5w HZtA== 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=r4WpCps/dmzg/nEPpmlNW78KzWKD4Zyq8EXXFVytS5s=; b=sddFLhF459+YMEXi5tP2cSJ2Hu3HDNLrk0W/3mI8uO35r49BtEuNke4ya8AIVNtiIZ W5AVS1FZDsu+fJDXalUDLmT40rrf6ez75n1UbFJYDKhaSZQiz3kxvMWyHH5T4jBnE73n 9lOXSitpEJtiQqKZ5OMUXsBm4BkdhwT6JafzuXRPAn75vh+gQpELed/ujcoox6v04o+c o/LJ+LTx2djEwB2HFd/gUj5if2hw41TZ+sDhcpsTRRYw14AfOZkS05i4Vdx2Dqm+Zzmw t7N7t+oBFbLIphichDhbAlj/gVVxVUigd3MuWWPKNrYYbt3GH8C2jE7U4OLrG58a+JjC AJmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qmmI9vTp; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.19; Fri, 18 Dec 2020 09:35: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=qmmI9vTp; 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 S1726570AbgLRRei (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732901AbgLRReh (ORCPT ); Fri, 18 Dec 2020 12:34:37 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 448E3C0610F2 for ; Fri, 18 Dec 2020 09:32:49 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id w6so1961434pfu.1 for ; Fri, 18 Dec 2020 09:32: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=r4WpCps/dmzg/nEPpmlNW78KzWKD4Zyq8EXXFVytS5s=; b=qmmI9vTp0A2LE/Vso7i2ivHcoYnFAy8QizlK1mNtLII2LdbDpKQg5kY27MrV9Ls3/Y JyNb4oQdv0aiQJnfE7G98FhNqpRsASuQI4IUzozKulAKGc6DiVsC3QuqAAW5MXtF10AJ WCvAlTsla+IZKPRiE6zc4BtjDc+6oag1IFC/7zvuQixp0Mbed8knKsbd8iD0Lio97L1E b5jyOCsr9zHZakNUZPDatWU+lKkkv8Vtojlt04oZy+yT40wy9jLIV73vRf8G9GiNwIwJ JZcIZjeywEqZ3Rchhzf43yBx8HFDCqgL61qhetW/1KdZGja12BnDKd5GQuqzXo23D5/g rAlA== 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=r4WpCps/dmzg/nEPpmlNW78KzWKD4Zyq8EXXFVytS5s=; b=RMkOjQ+7gRiCqB/HJUHlDMYrYlf4WCwy+lPzXV7QmDCyDj7JFHfLYg6+18izsiKjnL M1Io0kvFz7SYSfqyJF4nly2Ez3Z2XEe2OD9qr+5DZ2jdN4+zmmf8G17zbxNVeIbxU0uV Hnm1YXejb+KWwNnJpLl35mFs/zno+svllyalUE2Rwpi0ciWWj6niy+hCjE7nnCwpFlic JupKsiJx+C7btEhMUYmhPVl9wkzXH00bHn6c8gJ3Usnb95XyyT7rIGIWJi27KAfqn05h lB0frYS4Al7U+Nb6HNqYPRkcJEMnUwmARKBYb0sutMNCND1+j5wfg+jSzSBiW/FMtqvQ pTGw== X-Gm-Message-State: AOAM5319jcsBkP6XpeXvSEMT2VP9jcmDV42wzq/Gg6nWur3sOldc+LQQ uV4ewkPgQe266Bjy+yM9Mylfig== X-Received: by 2002:a63:5c18:: with SMTP id q24mr5026246pgb.411.1608312768810; Fri, 18 Dec 2020 09:32:48 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:48 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 16/17] remoteproc: Properly deal with detach request Date: Fri, 18 Dec 2020 10:32:27 -0700 Message-Id: <20201218173228.2277032-17-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch introduces the capability to detach a remote processor that has been attached to or booted by the remoteproc core. For that to happen a rproc::ops::detach() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) -- 2.25.1 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 298052c9d068..ea7b067fe89a 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -236,6 +236,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 Fri Dec 18 17:32: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: 345479 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335727jai; Fri, 18 Dec 2020 09:35:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzO2QROydqavjt1BF/fUEzKWI5/qfLlC2nzM2D76TrMrJNVFIJHURPUBX95orMk/nQ1PraO X-Received: by 2002:a17:906:6c94:: with SMTP id s20mr5170794ejr.0.1608312921480; Fri, 18 Dec 2020 09:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312921; cv=none; d=google.com; s=arc-20160816; b=ZXV0QRTD/0rDxHna7pbFIT/y28KexZSRIfLvCnxcjHuT5Qr3o7cmZ8uOJhafFAa+Pa fs+8UIDmzl14dUugAtsTcHxx63QsO3PiiZz7rBpw2+pIp75xG0WWCF/sF/vFAxzZAIaY P0J+Ep8Gj0tKZknW8Loxu+NiIIXyT8gfTLdqYwvNpJRMRBE/JmvUH1jVGqs/clHkkYWG +n2JzogUdSaGgj/8QMeifPNi/l+PBKB18fiaWcbQOqlmL83sUmTAp3ZqQxoWW+8Up2bA qmE2JJo8k5hO0CJXklQxUU0goKuKpQipDFpParYlTmBDAU42HO2dFK1OKh0YsCiBspLM cjJg== 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=rkR5KGw6lOHFw7kU5pTdY0IIWw0NKqkih0SELdkxmb8=; b=NW/0DmpHkVtlMrrxEYwBVez9/IaVd4+T+iwEpzscDSAhPy04eOyzFJc2mxio3tazoa MsHAM/mzOvUbmEikNcXfjI7zXpRajI7Nw9WDRgxybO5IJvfPWW0/wNtyEqpEFdOcaKb7 91uwK7raVBlLJb8WM1GuFHF5rtWxndJTjqAQbg7zjImAhm6vBP35NyAMDa8LGEVQaO7K R2q0MV1D5rSd56PcO2iGGYREsAOnPMistU+9f9mQC/ykykHMHPlS75IqZXKtSfwB48ME j5BW9CCeyEMSCpjo12iuC0NaMWnskCiu3PsvdqonQ+di+/lNnSRm33BlDs2CKMGj2leB /T9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DBREPFrF; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si4902939ejd.719.2020.12.18.09.35.21; Fri, 18 Dec 2020 09:35: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=DBREPFrF; 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 S1732959AbgLRRej (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732951AbgLRRei (ORCPT ); Fri, 18 Dec 2020 12:34:38 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98133C0610FB for ; Fri, 18 Dec 2020 09:32:50 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id c79so1955845pfc.2 for ; Fri, 18 Dec 2020 09:32: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=rkR5KGw6lOHFw7kU5pTdY0IIWw0NKqkih0SELdkxmb8=; b=DBREPFrFapCRqxKi8Q28381Uyq/Fj1Onz03ghAXR2urPxaEBt9myvb9C0ocMNAy/Rc nGenVzOCiuo6H9D+eFvdspI79dNwAvFPo437qhVdXkd7mP0qKfvJsUgMFWnCpl8B5TV6 jfSFuc3ZZ3Byz3Big60B/+a/8g3e0LAexUoBy0AZ1IOWevGhUOeP6a/9caskPtCraAvU rW5zgUZv6uO6A7RZy9ozBboq3SM3T64QBy7b6OOKkEVgKvPEq/VrCmMZgFLD9q3hj3RI T/6L+qXNepkj2Ey9qDGc4hZ7OPnywF9yBAWw6u/bUHbzHJdtouLJh8ctqSK+sqaleKpw 4/uQ== 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=rkR5KGw6lOHFw7kU5pTdY0IIWw0NKqkih0SELdkxmb8=; b=HEUyKFLPaqprwENHPp4Yx2P2brC47vRQ8Lrhak6ZPLf9tVkxOvGy4T3whDf9l1pT7B 8lxDUM4Ocnd7cvJYbPtI5NIm6SG/P2HJlhjo6tXGKG7i+N2ryu/bxLJaiHjHlU7SkhqM iYyFZz+RjYaXkXxVQO05oAA8dQFmZ+0kFOQbhdjO7vuziktKC4TBZ9z4KFkpW4McWE4r n5Fes7zorO2OrXNjT0cRTCfh9b6y3r54vOHieXLFVZvyHky9PLaphQwjZznTqBsgZyPm 6D48htep1GXzbnH1jXN2gVH5IS5XvGhJ4NLZfcbIN1gQPJ1MGH0sO9sjXmrkmCtpG8t/ r2Bw== X-Gm-Message-State: AOAM533uqcLqhy0P+cnYcBn4BFeEQSKjmnihXg/QYOQ9n1SOXFDHswCa ATijGriipN/MenDmZC01kuP5Ag== X-Received: by 2002:a63:fb49:: with SMTP id w9mr4988534pgj.403.1608312770144; Fri, 18 Dec 2020 09:32:50 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:49 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 17/17] remoteproc: Refactor rproc delete and cdev release path Date: Fri, 18 Dec 2020 10:32:28 -0700 Message-Id: <20201218173228.2277032-18-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 | 18 +++++++++++--- drivers/remoteproc/remoteproc_core.c | 36 ++++++++++++++++++++++++---- include/linux/remoteproc.h | 4 ++++ 3 files changed, 51 insertions(+), 7 deletions(-) -- 2.25.1 Reviewed-by: Arnaud Pouliquen diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index f7645f289563..9b2fb6fbf8e7 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -87,11 +87,23 @@ static long rproc_device_ioctl(struct file *filp, unsigned int ioctl, unsigned l static int rproc_cdev_release(struct inode *inode, struct file *filp) { struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev); + int ret; - if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING) - rproc_shutdown(rproc); + if (!rproc->cdev_put_on_release) + return 0; - 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) + ret = rproc_detach(rproc); + else + ret = rproc_shutdown(rproc); + + return ret; } static const struct file_operations rproc_fops = { diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2fe42ac7ca89..9f47a4ec0ec6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2254,6 +2254,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 @@ -2312,6 +2328,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) { @@ -2388,15 +2406,25 @@ EXPORT_SYMBOL(rproc_put); * of the outstanding reference created by rproc_alloc. To decrement that * one last refcount, one still needs to call rproc_free(). * - * Returns 0 on success and -EINVAL if @rproc isn't valid. + * Returns 0 on success and a negative error code on failure. */ int rproc_del(struct rproc *rproc) { + int ret; + 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) + ret = rproc_detach(rproc); + else + ret = rproc_shutdown(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; @@ -2415,7 +2443,7 @@ int rproc_del(struct rproc *rproc) device_del(&rproc->dev); - return 0; + return ret; } EXPORT_SYMBOL(rproc_del); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index aa5bceb72015..012bebbd324b 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -519,6 +519,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; @@ -557,6 +560,7 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + bool autonomous_on_core_shutdown; }; /**