From patchwork Thu Feb 11 23:46:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381058 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495600jah; Thu, 11 Feb 2021 15:49:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxU0Ge0RPuG7MdX1++B0VuCNRzhT8KnybwKhZNSN2829mX7jSTF4ZF/wxl1s/BKJRTiNWz X-Received: by 2002:a50:cf02:: with SMTP id c2mr565281edk.333.1613087369027; Thu, 11 Feb 2021 15:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087369; cv=none; d=google.com; s=arc-20160816; b=Hzcnqz/LXxTPqPe42E7XD7XuEWE5KRqv5V0E5gCscpgnZ7eb0kmZ2LMOTy/1WjiuNA eKObhe6BkklgCfYvJqZT2HVC/ASE/ByZxJZPuVNunViFtzOl6AKB/AG7MNtXGf1XL//u 6rEoa3U8vozcj6P4E3p9HgJrAjDuVea31ot2RMqbFJiZQi89uPnYQchTIS30XodovrPS JMsW4AZlGwfS991gZwBMmYKoGjoNRBA3363onzxwnT8cZAVGNjd5Mn7dEjhRBdvMk4jW aHasatywMgr5LHP/GefprAdbeGJ2aNAFiWTfMO3PlYBCBOpaTcTS+6D+zo0il3gf3TVY Q77w== 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=Gwpmc0x1+3eFyR/7BUUjdFio04J+RxJRu7OO5iEL6OM=; b=s9AHZYnw87zS3VGd8uZkbPuuVLq8HkDhxtw4j5lbou1/Vso7IDB346BENd97+DLcX+ H7sCDxsjNyRB7q69RcALYLkoMArM36z6GsVZmY1fSR+Cq/xpFddTICMVXEmgkI0TOuHt TXnCQ42x0R6nDiAvs0poedhlRm02RYklWIi2E8frrZxLyiK0rc3SKawKzT8mF6oOm9Xz PsYTDHR1vi+IzgLGvgTi5bfoGIzfNH3kAfQjN+FUOpMmjx9wEbqwShgkdlvJTZS/UxPo J2Zjd+ZIbnUYWYElbiraf+sz8pTn5GSuIaMs8VQscUKtZglTKJKKkEkTnfjEkOCnMXl2 HBIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WO0wSo3j; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.28; Thu, 11 Feb 2021 15:49:29 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WO0wSo3j; 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 S230337AbhBKXsQ (ORCPT + 6 others); Thu, 11 Feb 2021 18:48:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbhBKXrN (ORCPT ); Thu, 11 Feb 2021 18:47:13 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E04C06178A for ; Thu, 11 Feb 2021 15:46:30 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id t11so5056513pgu.8 for ; Thu, 11 Feb 2021 15:46:30 -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=Gwpmc0x1+3eFyR/7BUUjdFio04J+RxJRu7OO5iEL6OM=; b=WO0wSo3j+XaM9YaYHbZhCBQTUA7k48YCAkeLLXG/SjngCPEgOa+wAvMxV2TPCD/qvh 0fkme8eCctnok0ahmPDDDgxEkD+RW1+4aJueNg1Y3ZPvt3IjOHEnKDID7ewATFrq9zpo fSj9BxnHyc7QZOdKJlXLnF4keh6RIAzIl5WS07h44J9qG26IR4DBd5uNzHeFwbXP/puE B29RUK5RkBKvLKNJulOKT0aSt7EiuqK3kMRDlrR2pmEDpTJPC9AM+ocTJZltBa1sQNhQ wV8C90YueHgfVHmAI9NIue9ErJ0P0DgASlEgwmEyfS+qbuKRuY3vqs8gub33yAtz94wp y5kg== 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=Gwpmc0x1+3eFyR/7BUUjdFio04J+RxJRu7OO5iEL6OM=; b=HA1fRk3zGsOXJx6D2DDFPTDawnSF67W1NkAcWgQhq64icOyUwBNkMT/1/BPLIFQ1Ru xccaa4W8mqvKsELfBQ2CcoS806NEJo9iCASLcij0s9Vb335YvWdLpqhhIM99FV+JMcPV Nmg37ylus/sbj5HKzvQczOHF+oWx3E6fEDNziikL3AMwH+Z8HoDzuyXAr7BLmVEDxACZ ozxj61jH9mTC7i7EYs9eWeWx7BTWAnMRCKDMTfAw/y8smG82gJjdZCwExbV+p13bYSsY yHJSSWU6DBmToTWtPq0gn6sxC6/84m9e3SITGzu9qkYXki5Jcy8pbPpabXVILGFuh0Nd gVFQ== X-Gm-Message-State: AOAM531IA1EDCRfNMJRVXEwqAlj0F+3HOvW6/8640YVS5C1BQsA+gjbK gTk/IpDPA6cytY97e1md74qHJA== X-Received: by 2002:a63:43c6:: with SMTP id q189mr505041pga.245.1613087190012; Thu, 11 Feb 2021 15:46:30 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:29 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 01/19] dt-bindings: remoteproc: Add bindind to support autonomous processors Date: Thu, 11 Feb 2021 16:46:09 -0700 Message-Id: <20210211234627.2669674-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 Reviewed-by: Rob Herring --- .../bindings/remoteproc/remoteproc-core.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml -- 2.25.1 diff --git a/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml b/Documentation/devicetree/bindings/remoteproc/remoteproc-core.yaml new file mode 100644 index 000000000000..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 Thu Feb 11 23:46:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381059 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495605jah; Thu, 11 Feb 2021 15:49:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKTgz3OpqS/5twV42JoQ46JoNA+NKkT3ccxyJ4Fm8o6uCKmq0hXTevsMnKfZ/J7JG5QWGD X-Received: by 2002:a17:906:2583:: with SMTP id m3mr129930ejb.499.1613087369819; Thu, 11 Feb 2021 15:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087369; cv=none; d=google.com; s=arc-20160816; b=cRNEt9/X0ekpjPcNkjArcGKNX+1Gwo2CSKWRZ+NqnF5Okw8uodQlt2A8wcWVVhGtPP bCS6aTYy+8WlGQCJ+a7VfELvA9w7QyTa3ecQsu57fqKkF09SUAKSGG2aPGhA0Qj+INUz gJ02Fsf7sh+yw7xlN0pbylTmLRAS7eggO6STYlJ7VHngzXNtpXvlaQOTJ7f6RBCXiN6f gky0PNTy8FXLJfzA8YUts92uMTCDfnIrikqB4TzieqdiXlfSEWzS9FoZ1h82yZn9Kdy8 p3npFHxK/r2BZjQl/vbmU4wJ/rYTvNE+XHv28TktCTriV61Qr+MfDhilrUFaX894DQRo JM/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2KYl68Dz1gSnngZXwIN4sqByIS0YQQztG8qhw3LioGM=; b=lZql8E0V+qrOWma0ANIU1lzvTqKJs93gQdeyfWFU7lfBOQtxvroY4mHflm87rBSwGC SXgvXoLxU2n6Qr+5IqqMvZMxk2zPb7s9ikgAlOyjX3RTlDE0aLFsX7I42K5i2dbOEdhI 4pS6jbbCU8wHXUV70i7aG+oboDPCGmHllH7JU0e6GUmX6qOkT08YNrxEEvaO//LuS7/s kqNbYnz11kcVs3aZP493MCdMv3Mvp1DbApwPyM0FZdmpDmzm5kpcyENlUK5I5gMHebpr 5w9YiAKFw4JUpWpgS14kyRrq9jPcAPZzZxyhPmG4dCuej0BOd+ZEtLzHYMQC52yGF2Tr IelA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zIatSa7C; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.29; Thu, 11 Feb 2021 15:49:29 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zIatSa7C; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbhBKXse (ORCPT + 6 others); Thu, 11 Feb 2021 18:48:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbhBKXrN (ORCPT ); Thu, 11 Feb 2021 18:47:13 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1FD6C061793 for ; Thu, 11 Feb 2021 15:46:31 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id t25so5073132pga.2 for ; Thu, 11 Feb 2021 15:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2KYl68Dz1gSnngZXwIN4sqByIS0YQQztG8qhw3LioGM=; b=zIatSa7CJYFApIdlA+4ilgXNyRLDat4ml/F/f4McziCPqJX/qShgyLX1ikZm1Hx8L9 ogLgeKsFhOGJqUsy/9s7dsqrPpsb58CdyJtW4xpXr4AHoqgsOOVhKDGUJ2GWAF4jNRHS SFy2Qm8eNeRt0gF6tugmbnUwJOHDorASZOeV11ZeoqIep9k8QOlPN4bEnWpu0nEM+jag h/dJCsLpRCCXnAf+QYGOxitC4pyrYUUXIt6Qpb/03n37zjB5ZdfVMDHNX+TPNV7wANH8 FO5sPFiNQoLsIBIaiHBzjSGH64MyFuqyKxIY+mWI7cHXP6QXVuCOFHCZdGVHYRrLbX3F aH5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2KYl68Dz1gSnngZXwIN4sqByIS0YQQztG8qhw3LioGM=; b=K3vhnY6mUxgnPHdlFtig6PHubmFqonbwq5bqJ/PvzqKdaHyljEKnw9oAaYP6t8z9Fd InpIW4AxNwnoJeH/Hy1fYLQIFQPwzjZLv9AnPzxc3V0JxNIBpTWCYLYIcbYzDA9aisgS q63Et7OzVEA3/qGG6t3kk4PguOzUgb1iFpuhsSWO4vgO+IGMIhx3K4woH7z8F+G16fSu +SalpnFNs6pW53MsAoOk2PNCS4ksP47WwZLzESsyEk7kM3+jrs83LeQrE/kIm5LB22ho I/ls9/sKrooTYWTcGNadkY/hCd0xecB2M8bD4vukIXKXNjz93FbOgECcc9EPBU9IGkyS Ki/w== X-Gm-Message-State: AOAM531QUbmlFia5VR5mV/eac2Q39hMAsq8ePNX1Lvbj+g7JFJ/WHf+W 4OfErktPpMQQgDLpAgBVwtqkug== X-Received: by 2002:a63:f95b:: with SMTP id q27mr567144pgk.82.1613087190926; Thu, 11 Feb 2021 15:46:30 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:30 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 02/19] remoteproc: Re-check state in rproc_shutdown() Date: Thu, 11 Feb 2021 16:46:10 -0700 Message-Id: <20210211234627.2669674-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The state of the remote processor may have changed between the time a call to rproc_shutdown() was made and the time it is executed. To avoid moving forward with an operation that may have been cancelled, recheck while holding the mutex. Cc: Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2394eef383e3..f1c097572e01 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1857,6 +1857,9 @@ void rproc_shutdown(struct rproc *rproc) return; } + if (rproc->state != RPROC_RUNNING) + goto out; + /* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test(&rproc->power)) goto out; From patchwork Thu Feb 11 23:46:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381061 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495622jah; Thu, 11 Feb 2021 15:49:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJynz8B2cHNWdT86IwOVgfT1i4R9R0ctTXDY+dd0jHEfo2dl7cX3a4DT5/CQgwtiK19N1m1T X-Received: by 2002:a17:906:b50:: with SMTP id v16mr191536ejg.298.1613087371658; Thu, 11 Feb 2021 15:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087371; cv=none; d=google.com; s=arc-20160816; b=nbAoTQG0QMoeT3lRK99Y7YHKH40C6FbxclVekWCZdtbPCI3HPiSIYhz2V+5pCWzaZQ KBKxWyQgwFygNJ13unoisu0EUseYk5QeN6s0tQtMO42t8AHncMZuo8dQPXCsfslLxMM5 z7+9kwO1p4SlFYWo1Yv25TZgQTJfKR1dQUlrI8USQUkVi6nyC0H9DD6rweOualrB8gK7 CZfNaPtIRa+GNq1LzbF/DSBPfCI5vM2sJoPJ/x0hvawV7PGHTVheYtpygjnjNM6F33xG jk5MJ6/B4W1r1A44IfZSmpSRNQ+2FaTqAJckGMEf8PCBP8vIAw3sIIYIFx5hGf9/n7OT PXYg== 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=yDRxGrQMToW3Vor3njhDmnUs8pFP7mgJszB9Khz+OuE=; b=z1IiqWTeE6tRf2mh+685XttPWduKSnwyiLJ1bBqoM5G2JocxPShYSReYeF061Dfq6H VzEkMV3hQFny5IsFAs+n2dIJp1O7BsI8ntWuWuICrFPB7NFIK2ucq9UJ4N2Vxmq6ZBfN PictdjYMTeeWFurawdVcInWRAAzKROBx538NGLhLItocZcVrQkzJJs/MuYTe02I8l1pn jviH+M2x5no30urA3wezCIGPwkqb2J7QwuPlmhBfVMvO73VUYdqodVZeGY5VZnh6RNAz MhfHIDtRUPt1P5Vb0PniKU8he26p4qqb4aHn9Y3pdxhQIkkgNvFwAsbtZhYXcCjJwQzL UGpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pZyDs0Bt; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.31; Thu, 11 Feb 2021 15:49:31 -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=pZyDs0Bt; 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 S230259AbhBKXsm (ORCPT + 6 others); Thu, 11 Feb 2021 18:48:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbhBKXr3 (ORCPT ); Thu, 11 Feb 2021 18:47:29 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D65E9C061225 for ; Thu, 11 Feb 2021 15:46:34 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id nm1so4367996pjb.3 for ; Thu, 11 Feb 2021 15:46: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=yDRxGrQMToW3Vor3njhDmnUs8pFP7mgJszB9Khz+OuE=; b=pZyDs0BtrY8aWl00bxfY7/rUW4h0wlDAGZF0GeV3Qjiz2SqmaEQrAI4QSlfRj8N+9t PoVI/WLAZ3NDxNM5hkalhv6HF2k3fvD7jDtXfybSOhTpY4bDRLir4Cf1R2adpqvrhGQy 5khsgwhoFSfmPZcXdo7/JDewtBmkZAk1IYQdDFq2cTDIxiiUEkd9nye2qvckKooNB/X2 QJ+5nOWUGzNlS5whigrKloP656FOAc5MvLSt0LX1/X4B2rtoZN04Ktd/b0f5gVc669ws TQHICqjLS0U3PlKZMtwHKwDQIusCVq0qcEa4zKMWQwM1hLfrNnCcIOmKkw+mH/c/EZev jddg== 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=yDRxGrQMToW3Vor3njhDmnUs8pFP7mgJszB9Khz+OuE=; b=YsfMpE2IBLdBQgYaSN//x1F5XVLdT2GSdRdY2GBJs3ISN9yefF2vKzReJMFTfq0bW9 PHV6OqnFzrpKl5dcvzfr8hKY87QnT21AXl+Onv8nvZEtSCEhmqLlTUg8Zmbt2Fi6cJ4U TeQQ3nkQ6/e00yThmI02NBhAP2fanCnIRlkHsHpexgS/dF06ojjQ3i55CTwK4xvwaMnl WcQzd2z1TjK9VaSMjN+H0c2beYcQUS5x1grdrsxXP47g+T57Jmmm3JELpTmQD1ZReo+b +N5eUBpdGbPUctVabQWjwuj9JaoLCUC9HrQ3hHSSJwOv3+6cwzidKPkb8NY0K5BiJd4v dVvw== X-Gm-Message-State: AOAM532D8sptj6UQ5hD/38kl9uXfw8RQ0YwK8QLFI/2FdMfKLBS0lDAF XL3e3UEJCZWKxtXXkLmHNXG7KA== X-Received: by 2002:a17:90b:945:: with SMTP id dw5mr186517pjb.34.1613087191843; Thu, 11 Feb 2021 15:46:31 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:31 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 03/19] remoteproc: Remove useless check in rproc_del() Date: Thu, 11 Feb 2021 16:46:11 -0700 Message-Id: <20210211234627.2669674-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 f1c097572e01..86bd66955060 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2350,10 +2350,8 @@ int rproc_del(struct rproc *rproc) if (!rproc) return -EINVAL; - /* if rproc is marked always-on, rproc_add() booted it */ /* TODO: make sure this works with rproc->power > 1 */ - if (rproc->auto_boot) - rproc_shutdown(rproc); + rproc_shutdown(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; From patchwork Thu Feb 11 23:46:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381062 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495655jah; Thu, 11 Feb 2021 15:49:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLxBswLKAk/RQ2B1D0aQYfZLgT3c945lOnxtM0M02dsjY1ve0vUz4QoTdSuD/Vzzj49VRn X-Received: by 2002:a17:906:5d15:: with SMTP id g21mr145519ejt.373.1613087375337; Thu, 11 Feb 2021 15:49:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087375; cv=none; d=google.com; s=arc-20160816; b=sxg5olC4a66WQy/DiMcAUKbIeW3mU6RwcaW4SFU38ICEKnx+tEbIitQZqcGZLxpgo3 u+CnIwBYFw18xlAj/6Ki8nkYwWJrxz6YuHH2S0MSeDbhpfSnvRKVEuLVzLnYg1lOJL7t nHWJg8LT3Y03fILT/I4sDvuIP/sCEO7BrBmRcRT6GMb9RmnBhtP3bak5pKQJKtjManMl 2FMVCvIhZsTZPSatTsdQrDLZAEg0wwSM6J2koEQtIANWEodoOTL936E28eo2cv+AIvKO i8tc500OeJ44+rjVH4SQDrdwWtV1OUpaECIPHLO9jb/O0RKQSwWo+eddpyp9UutxqP/W kKJQ== 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=YVwpD5CH0CelKEAwKMStpJEFTfFplMOWTWmoESYAzz8=; b=ulhy5F+x5gSwWeJCH/jEmE/peoCOuMkyXlmQumz+bDKNSuhTnbST6JM/5B2FLqPTyi YVdTtm6YDUIYEwyXKK+YKpFRj4ZpctK7ggoyH9BGu5Pp1pfAZE3eMBo9IZdgyI1s+qj2 /7yOspiD20fewU7l9AIAWPGahqoCRTifZcsea4ePMI/7bIs/mUTJIN4fyQdc1xkFNxvZ A0zT9latXQmln3F1SgMdHMhM4TGXcDunK6m6/9r7NC/5dN4t9oQxXUQ0MQiIxHMe2siD a9CvkLMK3SbsLy7nFQz0EyJ5ZQqy7l+PaXPypj2I8nMWSFeynQMqZZvEVaVL33zK2TBm 4J/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DGff/4uu"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.35; Thu, 11 Feb 2021 15:49:35 -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="DGff/4uu"; 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 S230289AbhBKXtA (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbhBKXrw (ORCPT ); Thu, 11 Feb 2021 18:47: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 5195EC0617A9 for ; Thu, 11 Feb 2021 15:46:33 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id z68so371735pgz.0 for ; Thu, 11 Feb 2021 15:46: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=YVwpD5CH0CelKEAwKMStpJEFTfFplMOWTWmoESYAzz8=; b=DGff/4uueqBV64J8FXV9C0ktQMhytE8fE22awY+TatRLv7FtkrA9Kc4tsYtLKKxuGP o+R4IYpmLgqG8eKjOJNHvNKlvg+61tr7X7z8xJJm4J9NsxD4vK1cDtG/ZOQNnEUvUrea crEz+54bwN5hndjqALVOZNbtmdr8F3iltsshLoIn+XQoXgE6G7lQy54ZHGf8IdCfSurQ 8tXivkh3iagEJK2EatWZb9OH197Z36fRCzCk1UhXswAPCteM+Nja+5jdSmHsly0y/coo loDLJUJicOHvHdV14lDI/MB7ot7io9PYT/gcK5V9HBvaFSQ/Zkd7K6EMJGJKohCLr6QQ P2IA== 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=YVwpD5CH0CelKEAwKMStpJEFTfFplMOWTWmoESYAzz8=; b=N2Mj7GY16ZnnzTXbrOXpXLMNUqXkxHUGxKO+CktC3d6JKzaqkcWBK9ZNKThK3z/EEU oDBy6X1esv29caJ/Z7FdiuxQ4C4l21HTAIw+dzYb0wHVTPbd+vxCN93n6NW22zSp5wef W/dweio5/HQ9OwqSnFFGfEnMarrZvv4mvEKeWtGrQix+jtR4xquPzRwjamRRKvkY8TSL 6LNC7S+JBB9aKhlcUfvRAJhqvzaIs8qqIDLPQpwW4uSZM5b6u0okTvceF5hc3xMernh7 7O7ZY/glwsPVCttp35CKmcJYY2nB46BZBC1VLKQag8L2MP5oeDa2gf70vdq5V3kXB0z+ s9RQ== X-Gm-Message-State: AOAM530Hd+ZIeltePzuGLjQoenDWgztCVv5NmnJK730pYi2erb3GpYa8 MapYYfXIjOrA3Nx03/olOkJg6A== X-Received: by 2002:a65:4788:: with SMTP id e8mr542190pgs.72.1613087192761; Thu, 11 Feb 2021 15:46:32 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:32 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 04/19] remoteproc: Rename function rproc_actuate() Date: Thu, 11 Feb 2021 16:46:12 -0700 Message-Id: <20210211234627.2669674-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 86bd66955060..8afc7e1bd28a 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 Thu Feb 11 23:46:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381060 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495611jah; Thu, 11 Feb 2021 15:49:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmS6rH3tg/EHesux7mDaxgxaSQvHoKFo+gnaE81CrgSYHmIkOMT+WsiLVzvDkr+G844e5r X-Received: by 2002:aa7:c944:: with SMTP id h4mr574536edt.233.1613087370538; Thu, 11 Feb 2021 15:49:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087370; cv=none; d=google.com; s=arc-20160816; b=ivAMlGB7W82sIZ4uh2w/8Hg4hci7PhKwBX166yXITDwREJSqObXjDTIB1xqpl+qN2w US/Ss722SW3SaWQRT1C6F6jqCDn+4BPol0cub1s2T+yaxnNsaZ+XbMuPlo7OBern/o1j raZFQZGryEp64RD4bEhiHNOqe4xi81Lm0m55NC+MtIaiBcrtolCa2yfCgcQB0k+G+IHC yvBSAJyCj1u2NT81QvOC+SahyK3qRt4L2VlQ1HFJ4lZRRLlRZrQa0ntUH2TqWGlD3dqf P2BJJbBA/mZdTWmx3XkcmWl0+4Xj0rFZ5t3txT1GgoMEdtzZdsvTc5JQw/KPmAd/LwJd dHZw== 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=waytkFv28UuOXcaaNeh19CxfKAUzKWp03mnaFrOUKvo=; b=kXfWLPUZwQHyfBSucnBLanvPhMW7HlRw4SPx50SG5zhUqM1RXaFDsxO/vwfpSkT5Ea fRbYlBe6iC6m5KrUoSmtLEYHUpq3VXYN9LAgNAuWV+8y2Lueijn1EtBOMyZ4mCJ59Nf5 zRln+hJ4D/769f/Wa4oQoymhcqDNGBOcrNmV8NS2CIOS+17jdQS+7UZgtcU2TyYgP6JC sIP+NfbNPKCoLodc8/QuGgi4CQIREogfgWh+GrTevU62oV3cB/45mcrD+0xFaIzgLjig FmMSQtGZ+jsDZ4zMzDahq1rPpl+/RalX7xLdrI1lTwvToL967tJmCB7zR68ezmLHl2Kb WiNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KbxKOZQM; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.30; Thu, 11 Feb 2021 15:49:30 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KbxKOZQM; 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 S230357AbhBKXsm (ORCPT + 6 others); Thu, 11 Feb 2021 18:48:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbhBKXr2 (ORCPT ); Thu, 11 Feb 2021 18:47:28 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ED1FC0617AB for ; Thu, 11 Feb 2021 15:46:34 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id k22so4197288pll.6 for ; Thu, 11 Feb 2021 15:46: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=waytkFv28UuOXcaaNeh19CxfKAUzKWp03mnaFrOUKvo=; b=KbxKOZQMaAycIE18CAf5wu1OBlPfG0cR5mApGKP4RfLjOjDlL2D8/lfvVD2porDZvx 3JE2qjSISKthcDCRBzqSBcMX/6J8CzaGauhuZSTT97bOWs6xYNxRZqwsML2SG1SY1HB3 7lWsIaKBt3xqQxFEMnxZpiHo6O2PYgIW38f3VhXqHdzUndeexhx32Gz7YhZ6qrXh1QTV zocoRY+IWe0I9PqLTuhfLY/7548FvGTFz2TvfBDCMw4LbMtHh3/YyVN4qUBujIYrzvHd 7AtWEaUtPOutyioGfaValaT4vO+t6OEm/FhoUmewhPAA5v5jgh3qHCmM4VlAtwqmarX5 tgEQ== 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=waytkFv28UuOXcaaNeh19CxfKAUzKWp03mnaFrOUKvo=; b=NQYmTuHjuu2g522X0ZvhFrMSELBxdL6+tf3bRKdzib+RaS30bUMKj1b6sRoPBZXKrr XBxr7gyXwcFzAn0Pmi3V2m8FRjLxHB9HnkvMBeDUghMYAcmmJ4QG8UR8LmRtakbMkU8T d+OueiInKvpQ+Y1Hs/2gxYE/BZwX+/LCZqRghVtL2coeve4oMkfCGzliYqsElGfH9UB4 TVkJUMg4esOwa7pDDPf/96sqRINaDuhEj6HlZKqY8FagMLnF1+XkyUXeyv4RLLgak1JO MxL6lFyRZbx//B4D6o8F8h9JHh9NueHFLYWRfYKwGjs1ZjUhTX5wOfjgPIOnVTrK/+fT GXkQ== X-Gm-Message-State: AOAM532QuEeGU14vLP14MtuHe8MKv0RxA/8igOkxSoRn11Z6OeEodf8N gHhNGPS9GtTnpa/kryZ3MXk85WEL+alKeQ== X-Received: by 2002:a17:90a:c08d:: with SMTP id o13mr128236pjs.149.1613087193787; Thu, 11 Feb 2021 15:46:33 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:33 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 05/19] remoteproc: Add new RPROC_ATTACHED state Date: Thu, 11 Feb 2021 16:46:13 -0700 Message-Id: <20210211234627.2669674-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a new RPROC_ATTACHED state to take into account scenarios where the remoteproc core needs to attach to a remote processor that is booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 1dbef895e65e..4b4aab0d4c4b 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -172,6 +172,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index f28ee75d1005..b0a57ff73849 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -405,6 +405,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 @@ -421,8 +423,9 @@ enum rproc_state { RPROC_RUNNING = 2, RPROC_CRASHED = 3, RPROC_DELETED = 4, - RPROC_DETACHED = 5, - RPROC_LAST = 6, + RPROC_ATTACHED = 5, + RPROC_DETACHED = 6, + RPROC_LAST = 7, }; /** From patchwork Thu Feb 11 23:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381063 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495662jah; Thu, 11 Feb 2021 15:49:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCSn3c86bUB+qsvXWQECgSV2WtDE3ykg/6f2VVCm1bSm5pMIGFaEMFjRDafp2IvO6iUELR X-Received: by 2002:a05:6402:c7:: with SMTP id i7mr617327edu.328.1613087377037; Thu, 11 Feb 2021 15:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087377; cv=none; d=google.com; s=arc-20160816; b=gC9AAD2UImzGEhoRw2N2cbbkQI9+cHYu4gG5Yo01DAiD2su2KUNQGcMeH3OJe1vblP 6sQC9ZevO/A6lNoKivMu3uDlzptqh4LPpuKrqvW5yoccEn7XFhmSH8pTDfO4pCIxB4OU Rw+VWx7xEMsvX6rjPBfRKCWm8+C74UDGUTOZFSLyRR3i6trmSkwg7FQ8kY4wbHpZUfVN AFHk1df/6Mr+E+6hNo3ODyAh9CQZ4oMkifBcfDw/YW0lL7LlIm2N8clw+QmQaqdBg5j1 yVrWDIwhYtaQ4Jd4iSflCj27EDwKtncSiWRKlchHIOaJUndwNiZQH4KSUZdLe8jrSqt2 AOwg== 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=0Iy9CzlHfitoEfgTXPac8pcqQPI0KYVgBprjbFY0v+o=; b=PMOdVxmELInKxhtABfKN/7XaKr1yvCXEB9pO4/hcyiSc+hNbo70FHgQjhV+qpOVrvm vu9NMkCZppJnnCO0vDqO3KkajOBRUT6ObD/tn0Pd2b8yZfygCxa25yHBWfmnp+A/1VB0 v3K9DaL/7GG4ZAWEzcUODL4d5S2YD30w/xqDduSD6RiQsCnn9UCFMqJULl98s/notuLL xbsUSoaB7XXzNYqB76YkFxkGyDfbaeLMuhYRbU4ZfP+pNGMdlame1ml0LrhaZTuHHIqj 8UIL7Kfg/pSfemR7UpCTg6UpgwBg8SybOBSES+NTeS2P8pJtpS3iEsuQu+gBQs2ZKFj9 RAzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f2fKdG75; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.36; Thu, 11 Feb 2021 15:49:37 -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=f2fKdG75; 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 S230019AbhBKXtL (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230228AbhBKXr5 (ORCPT ); Thu, 11 Feb 2021 18:47:57 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F437C0611C2 for ; Thu, 11 Feb 2021 15:46:35 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id w18so4716252pfu.9 for ; Thu, 11 Feb 2021 15:46: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=0Iy9CzlHfitoEfgTXPac8pcqQPI0KYVgBprjbFY0v+o=; b=f2fKdG75VecpW4vnKLQDkn2QIEdUZf51EfSvwdt7+SHwY5Wez/fyZq05XcUZNkdW4D T5+6xG58xVGkgkeb93Zfz4v0BWqyQOZQqe4TRatXqtNqzO2/WVmzZMIHsP6flILM2WMt w8IiQVx56w20ido3l49l0fMlw4ygABhhabUarmLrNNCeN4PcnWoa2GMvGZ3EX77fnYwx r3wrUFa8450sZ0/Z22YojRqWHzRnS4d0fGbiQ+HKvIJl/n6IlFEl/nsZBbzL5dsFS1pP +18I6/LqXFMHUtnXcysIT+zFPPfsTfzBP3ohUfx6QxfkfTM6wm8kJ/2A9krd0RArNU7a LtMA== 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=0Iy9CzlHfitoEfgTXPac8pcqQPI0KYVgBprjbFY0v+o=; b=AZL70D3+Tm/CelLpicBs/JJf8EmNLochiKPar9ld1dq9jWsWeKvsFUaU9KeAiPB0Bm yu2hj7n9B5LrW2565/XSVrZzZYiS80THfofWm7P0J5K+82w+U/sesWOCxOE6gpK3AjID Dl0H1ZBBiX9o8dGpyLEb6qB/j4b1VqFFiewRi3sEEHTWm2n45H7hJws/SgHbrYgw5clO xtBB6a715oBXUULw9XN2d0YCo7uPy72kb4z34C45JyooZutx1n98+ZkwqObbapbjgLEH AvxMr6FK8hqIW//Z0gebi+MdxB7zBmTGtI7/VitgVKsDZRIdCV1EqyK9vpidMio8q4Pk OvUw== X-Gm-Message-State: AOAM532WWZdwOuIFiACcmYHAAob022OaHbz0atKmKzZ+0XmlzDFUQBJD GCHEgJk+ZSyU/2ZSiyzlbfgIpA== X-Received: by 2002:a62:644f:0:b029:1d3:b559:fe7a with SMTP id y76-20020a62644f0000b02901d3b559fe7amr342270pfb.21.1613087194736; Thu, 11 Feb 2021 15:46:34 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:34 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 06/19] remoteproc: Properly represent the attached state Date: Thu, 11 Feb 2021 16:46:14 -0700 Message-Id: <20210211234627.2669674-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 8afc7e1bd28a..e6606d10a4c8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1444,7 +1444,7 @@ static int __rproc_attach(struct rproc *rproc) goto stop_rproc; } - rproc->state = RPROC_RUNNING; + rproc->state = RPROC_ATTACHED; dev_info(dev, "remote processor %s is now attached\n", rproc->name); @@ -1659,14 +1659,6 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->state = RPROC_OFFLINE; - /* - * The remote processor has been stopped and is now offline, which means - * that the next time it is brought back online the remoteproc core will - * be responsible to load its firmware. As such it is no longer - * autonomous. - */ - rproc->autonomous = false; - dev_info(dev, "stopped remote processor %s\n", rproc->name); return 0; @@ -2080,16 +2072,6 @@ int rproc_add(struct rproc *rproc) if (ret < 0) return ret; - /* - * Remind ourselves the remote processor has been attached to rather - * than booted by the remoteproc core. This is important because the - * RPROC_DETACHED state will be lost as soon as the remote processor - * has been attached to. Used in firmware_show() and reset in - * rproc_stop(). - */ - if (rproc->state == RPROC_DETACHED) - rproc->autonomous = true; - /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) { ret = rproc_trigger_auto_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 4b4aab0d4c4b..f9694def9b54 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -138,11 +138,8 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, * If the remote processor has been started by an external * entity we have no idea of what image it is running. As such * simply display a generic string rather then rproc->firmware. - * - * Here we rely on the autonomous flag because a remote processor - * may have been attached to and currently in a running state. */ - if (rproc->autonomous) + if (rproc->state == RPROC_ATTACHED) firmware = "unknown"; return sprintf(buf, "%s\n", firmware); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b0a57ff73849..6b0a0ed30a03 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -512,7 +512,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 @@ -549,7 +548,6 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; - bool autonomous; struct list_head dump_segments; int nb_vdev; u8 elf_class; From patchwork Thu Feb 11 23:46:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381064 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495665jah; Thu, 11 Feb 2021 15:49:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV4Rjigh/xesV/AhTVf7VYqnkWg8Cx31u+eh/RpfsYswAhNjyNc7g7bg70Wvl1Z4g2MPup X-Received: by 2002:a17:906:354b:: with SMTP id s11mr185563eja.460.1613087377775; Thu, 11 Feb 2021 15:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087377; cv=none; d=google.com; s=arc-20160816; b=iSMASPjKcIlygw97+6HgM/Ozkmk4GiSa+CMVBObX9DyPik7LzhN/g5h76W1oGfc12z dXs7k2d0USBZ+OQvxPOZdtSDgA7lhQ5t8oGKC8lNGm7OBFCxfJ65VC9qn9gPCdb6SfE1 tPirKAz4e5AV93lc3ooOcEzmDx5qlKb2C3WQ/Piq86GwfVG72Q0AtyIVyXbVCPsyhTOk CtIT0h9UJYVxfK+qnAhl8QsmXQV8KygmJg83l7U2+WpC95zi/+zbsDvbO5VVCQSL/3p0 Bkz/90o2QSoKcsL/GZTbGhd1z/JlIs1GD1vidJVl/8/7CXJYESlWLiz3ib96y5gG7El4 5loQ== 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=XjKeOWv1WVtqn5LKvVIAlwdEfxyFn3LtrrnIbVEzukU=; b=VYeEWq6lgjkDi+IpOeKgJknXKeB9LF+uw5tNf1NOeJGzzwj+MKYJql/QXDi6/EKaSA 7MC1URntR4NnjaMqfrFWZ5tDheUpkDwNAmdp2V8IhVSFecyy9j8cLZTqnAlZhW1c8ebC MTfRnWKuEfSGGdEVHCw11BxBrDH8SSOBo+ubXiwuXh7fwP+2/xw2JmMbZKZ2kYi3akrD 5T8Y4D+NNJeZ7rri6k7ccQghjhkE81L6HhqKgkPCmy1t/xxnXmpCTwlesPVVkxEhj/VG GH5zM+EJh0f0+Lct6mRw/7HfL/TLljBaPwAntf7Ay82RCIl6wgxHMT2hS2ixhrGg9XaQ eOwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U+DLUx/Q"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.37; Thu, 11 Feb 2021 15:49:37 -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="U+DLUx/Q"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbhBKXtQ (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhBKXsX (ORCPT ); Thu, 11 Feb 2021 18:48:23 -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 3B7D3C061A27 for ; Thu, 11 Feb 2021 15:46:36 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id u15so4206870plf.1 for ; Thu, 11 Feb 2021 15:46: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=XjKeOWv1WVtqn5LKvVIAlwdEfxyFn3LtrrnIbVEzukU=; b=U+DLUx/QopuyNheHO2UCHO7/xLXrvIszWDmLeqmOguZUdlT/kVvjb214y+6t7it85i Kft61Sm9oIRp1b9nGu3cp4sbQCRQgqhe7NEDXunEnU5zfpAMALY4FJn74Jm7+VnMPI14 unik1HW+1YnQgZa+tVm73J2t64/dqBR5HHqfHSSklELINwsf6HzeOP86RNFK7FDDMuPG hLN/s/07DQayqfST124ldLHU09W8o6rDET+ShZA1UjMYtZ2dmt0Y0IsbA60C99/JMril A1YfZ6eiDeNKtfOeboCqvg2FaOmJINtg6I9sf4HiorlqESphn1/rCRNQ+K5UJ83iUeNd 746A== 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=XjKeOWv1WVtqn5LKvVIAlwdEfxyFn3LtrrnIbVEzukU=; b=uVTVyWrxG0Sq1k0hYDEL+UDY7mVeWbdGogJhm7pLULl/eTQIv+eHzoIecplba5ezHy 0Vq8HRle+0klPXo4cNRDy0Pv9zE+HpIlrBkoBzRtpCfp0+Ys4EpHF9oCU4v5psv10RLK MGpxKX1uf61jY02JTGTtmserL8ta82n7HwWbfolwNbQ8ObxgPggeKfznQrK+0OUoxkH9 /v55bQ1jUQfTFRenq0q1IaMGSrAIc6mRQqQY5xrUmnjAv9vRXxJD/ZMRI2cSSDpAMuEv RTFtLQhoSUkWhQ7zIN8nddRg2smXpLb2FQRrkOSEUYRHsVR3Ehe8AUD+lUHJwyZjmh7f jXGg== X-Gm-Message-State: AOAM533Kxe1yN+ELf6gvpvbN5VuSSAf22VjA27CTNxTPiAAoR/iJUSpH fFiIr3UR7eLg23WurGu1AOHtOg== X-Received: by 2002:a17:90a:1109:: with SMTP id d9mr169277pja.94.1613087195768; Thu, 11 Feb 2021 15:46:35 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:35 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 07/19] remoteproc: Add new get_loaded_rsc_table() to rproc_ops Date: Thu, 11 Feb 2021 16:46:15 -0700 Message-Id: <20210211234627.2669674-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a 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 --- New for V5: - Added function rproc_set_loaded_rsc_table() to keep rproc_attach() clean. - Setting ->cached_table, ->table_ptr and ->table_sz in the remoteproc core rather than the platform drivers. --- drivers/remoteproc/remoteproc_core.c | 35 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 10 +++++++ include/linux/remoteproc.h | 6 +++- 3 files changed, 50 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e6606d10a4c8..741bc20de437 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1537,6 +1537,35 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } +static int rproc_set_loaded_rsc_table(struct rproc *rproc) +{ + struct resource_table *table_ptr; + struct device *dev = &rproc->dev; + size_t table_sz; + int ret; + + table_ptr = rproc_get_loaded_rsc_table(rproc, &table_sz); + if (IS_ERR_OR_NULL(table_ptr)) { + if (!table_ptr) + ret = -EINVAL; + else + ret = PTR_ERR(table_ptr); + + dev_err(dev, "can't load resource table: %d\n", ret); + return ret; + } + + /* + * The resource table is already loaded in device memory, no need + * to work with a cached table. + */ + rproc->cached_table = NULL; + rproc->table_ptr = table_ptr; + rproc->table_sz = table_sz; + + return 0; +} + /* * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. @@ -1556,6 +1585,12 @@ static int rproc_attach(struct rproc *rproc) return ret; } + ret = rproc_set_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..4f73aac7e60d 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -177,6 +177,16 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, return NULL; } +static inline +struct resource_table *rproc_get_loaded_rsc_table(struct rproc *rproc, + size_t *size) +{ + if (rproc->ops->get_loaded_rsc_table) + return rproc->ops->get_loaded_rsc_table(rproc, size); + + return NULL; +} + static inline bool rproc_u64_fit_in_size_t(u64 val) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 6b0a0ed30a03..51538a7d120d 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 @@ -390,6 +392,8 @@ struct rproc_ops { int offset, int avail); struct resource_table *(*find_loaded_rsc_table)( struct rproc *rproc, const struct firmware *fw); + struct resource_table *(*get_loaded_rsc_table)( + struct rproc *rproc, size_t *size); 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 Thu Feb 11 23:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381065 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495830jah; Thu, 11 Feb 2021 15:49:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy79MMUMH1PpbaRIlPzyrBk4JAbsU8+2j08ErIihe5yF0/CkC/90HeYUSwfg9ImBkiISmvA X-Received: by 2002:aa7:c58e:: with SMTP id g14mr609877edq.362.1613087395884; Thu, 11 Feb 2021 15:49:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087395; cv=none; d=google.com; s=arc-20160816; b=xRMywu6T4tSJyscmapwslpY3KJJJk2v2bWYFYgchBF753bdQsFS+Et8tAdELMlRL7u /ToJOkc6gugs/iEtsWLtLudsgE/0kQqKfjE8oV1SAtIjosXytfs7rMoPDaQJTzK6Ro/C iVLA8nK3KS8Fx6OZwRPExR2jTLBRDgcQKmBwNe3TbALu8C7sHIl/jqfdHurvrBEkRTYq uvcDg7plN23GMk6BcazmY/KqHtBbzXztAeTGlSrcGBwwHlUjmPuzfLCSLRH7zDUBk5R8 wqHVex0AQYPWKqxMif1QlqO79BnspdyBiLuDa9zs0Gj6O+t7RSbsq6jJw+oSdIa/Kkpp aHFg== 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=tgj/edDkEdxRhIM+wgjO9M5oMofNW86OJezP/GK0ahs=; b=mJiGZFFVuCGM1b0gv/vA2rOgPbyH9zyGznApvxDuAVP2As56DmIDg0uSEsyvntaqEB nSe/Sj3ga2p4L0lI3vUMB1PMPO9Znq20HPj2aKfXoUbUxPWsj/AGD+/cULNMC5YbL9wK F73UACph9/KunI1Cn3okyrQnnEZc4jCEPTpkfrw8iv334ij1MyOMad61VhoDzhDyMthp RCBtir9wnB0j25Ryii3m3ERAnGTcKixWlMHM0sOGbkYSnkjzugDIrb1ogoDClf+4zBC6 k3Akggk8SxzeTk+qN0qwNpbw8+7/5L2xOpN14RMRYeFnWMj1GPEhtbKkFWZNGJOFA4W7 7CCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tHoROy0Z; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.55; Thu, 11 Feb 2021 15:49:55 -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=tHoROy0Z; 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 S230292AbhBKXtw (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbhBKXs3 (ORCPT ); Thu, 11 Feb 2021 18:48:29 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 436A3C061A2A for ; Thu, 11 Feb 2021 15:46:37 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id j5so5049925pgb.11 for ; Thu, 11 Feb 2021 15:46: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=tgj/edDkEdxRhIM+wgjO9M5oMofNW86OJezP/GK0ahs=; b=tHoROy0ZBJibDn2Qqw0ubJ5sF9B8braEhy6lRyzWgXr3EpwW0qQYoWp+Zbrht7G7uv 4cNiCfhTHwoV4givIOfoimydEvmIMyV4eJjHD6yDoNO2YDJaT3iZlr2fF/HJv59lP0y8 w2nEuhlU3Vf+iMOPH2CLHZebGHi00KdIGoCMas2RP6WifJdcObdP7Ib1FuU64SqvnSeH EGEyBmFuNQ46DgHbOd+crIbuvkIagiBxPseDjcdkyVGMuL/8cq3Qz3sM/iJ/ZGfONfMA /eUlZYGTNuh+WfzCohR4Adk9+Oih6wIJdaUUKyDzw3hMNGDRLuKJ8S6APfyZLpcdPfag 9gJw== 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=tgj/edDkEdxRhIM+wgjO9M5oMofNW86OJezP/GK0ahs=; b=e3Agfiz+evDBodjMMYYlLxCYD9lNE8AldjvkBkvjKg49aJnBXFjfAh4MK/t4TgCw0u lYmp+MKY3fm7X1WpnSjPdoXFSGlRUhkMyAOtT7HqNBB7GVnde/ODWKmsVT/X4qV8Q05t 2Y/3hSDyDYNARfOAju8mO9LAAbSFyzq0X2JoTNY4TWC64iARYYpEPOh+BzuqX98oGCVn dj8z5NLsa5TGdZaMvwkMrD+TAx1WYtt5uN6BN4uHFviJA41+oEO6r6OSNoym4OLjiCfh 9f5fP3JLyu+HnR+ZtEyfhzujYWrLpmcQ4s03suCSqphIQ48ef5srpLpHKQNe+xP8fNnt CDgg== X-Gm-Message-State: AOAM533hwAWPo87xGkn1CWKDMU2h82XJDaMHRA4kNrWCDAotLN5QVnEs MXioS3PDWKDVzXsyxjv7A445pg== X-Received: by 2002:a63:347:: with SMTP id 68mr554653pgd.164.1613087196808; Thu, 11 Feb 2021 15:46:36 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:36 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 08/19] remoteproc: stm32: Move resource table setup to rproc_ops Date: Thu, 11 Feb 2021 16:46:16 -0700 Message-Id: <20210211234627.2669674-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- New for V5: - stm32_rproc_get_loaded_rsc_table() now returns a resource table pointer. --- drivers/remoteproc/stm32_rproc.c | 141 +++++++++++++++---------------- 1 file changed, 68 insertions(+), 73 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index a180aeae9675..826cb7a045df 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -541,6 +541,73 @@ 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 struct resource_table * +stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz) +{ + 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_PTR(-EINVAL); + } + + if (!rsc_da) + /* no rsc table */ + return ERR_PTR(-ENOENT); + + err = stm32_rproc_da_to_pa(rproc, rsc_da, &rsc_pa); + if (err) + return ERR_PTR(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 ERR_PTR(-ENOMEM); + } + +done: + /* Assuming the resource table fits in 1kB is fair */ + *table_sz = RSC_TBL_SIZE; + return (struct resource_table *)ddata->rsc_va; +} + static const struct rproc_ops st_rproc_ops = { .start = stm32_rproc_start, .stop = stm32_rproc_stop, @@ -549,6 +616,7 @@ static const 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 +760,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 +799,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 Thu Feb 11 23:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381066 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495845jah; Thu, 11 Feb 2021 15:49:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUogjk2dKGOsu698TF6w1nnH7VzirBpa3OEzVXuZr/PM+l5iSQJyge6gpSl/74vwNw1vcx X-Received: by 2002:a17:907:728b:: with SMTP id dt11mr145284ejc.321.1613087398344; Thu, 11 Feb 2021 15:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087398; cv=none; d=google.com; s=arc-20160816; b=DkP1cKBL2CmLljt3h4hyAEiCn4dEWO2tTD+tLPwrLT4bIRwodE25hL6on8dEXB6piL 90SdqBJuKwNXwAO9AiIMBgddpO62Mb87BYWMMUK9S2OUT+t59Jya+pkZVhCv74l7Z822 7hyqYczjTIB0IKyGpLdXcnSBsfikMEpcqpzlvWtx3CgmcHmvFjmbPKuQn6ETHOteatWw sYEtl9pbP3qwgX4EL0DQVejcI3ZvtG+lL+5y7CRkjwO2mctikH0cK6VfzcWQ/oWvv62J 5WFY9xY/aZHkB02y7xbFGsPKkqQuw8GSrpuaxgaHxaZ2MxXfQluATuxOciLuWI5PO1dz 4S/g== 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=52raNE6Ip4exp7Y9/K/NcM7vSGzuAdV+HOuZ1MCv9VM=; b=bciP4CS9KmZ3sCHQBfG3P80lEP/Sml8CIMrBT1d5FF/ZNDaZlk7Ko44acBt3gcvnxJ QXN3d8YTWmzhFZzAGsv219/MGFbz7M1k7R48/wzTD39MMWWan1mCeVnmvVDKKhmgw4Cc AUWVY0JwCh7q1p7CoN3+TEeFuv8RJDbw1DR4nDIY5uRx6rneEXWT1cfOUzbPeoGOIHO6 7MoorHciuKxhX83OQmZL0F6PpSKSfiuuphzehNVTch/dGidyzKIB0DGznCtTXw3zZBQ8 udfCPdoFNQQ26Iha4pKz7a7I8JEDP+KilijrpEqcZGDxDFVtzRUJhf96y9ysv5bBdIiU xyCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P1J/bRhy"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.49.58; Thu, 11 Feb 2021 15:49:58 -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="P1J/bRhy"; 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 S230349AbhBKXtx (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbhBKXsp (ORCPT ); Thu, 11 Feb 2021 18:48:45 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D883C061A2D for ; Thu, 11 Feb 2021 15:46:38 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id fa16so4377246pjb.1 for ; Thu, 11 Feb 2021 15:46: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=52raNE6Ip4exp7Y9/K/NcM7vSGzuAdV+HOuZ1MCv9VM=; b=P1J/bRhyIkT1K7cKFoh+2BHP2oo6M/1O3Ec5B1QZogBLNdi4iWNqnLXlPvAF2WwIgM vsLEcoGS0So63cj2Nrdtf5Fvjzq4sU+97ecNOi0WSo5EcW+9WxycBRL2QSA3cD2Yxypw /4UmefrsH0MWX0WRLJvIWy++JVaJgDekpX/XeZkyhLf6LQngxfiBTxjliCGTxh1kJbf1 r+nq6s0YM8i/4cYl+GZkAwmfUQr7uH7VhnfSy9+XHwtfJQsyreZ0WlYq6GqDOICo6rDT IWtw+dsu+rsJ+lsKOJXw3tbQMgGFcXrW34S378Ilrgy49bkcjVAihx1KKSgrI/VLETK5 /X4A== 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=52raNE6Ip4exp7Y9/K/NcM7vSGzuAdV+HOuZ1MCv9VM=; b=jIX1RspMyCX4ZDbXck0LWZwUunccfcECGcwbtExsAy5er9wNq4AM4IS7Wc6wzvcjIb GLyGcEbCgmf8i2RjhA+UWpzcNNTTHAN/tk9Q4TR7ia30xJ/lSaDaE+UoedbRKugXgWnz 305rHEgwsqzWfj2rRBIF9a6a5HIrozKknTI1by+tG1o6eOI5FV9QBjDzkUW78tfc/xM5 Xsf8WVdUlSWzVifz9vvyOdvObOErDotURpmBBzsZOep8SOM/lTtu5sjz2fQ5RrXiLRCA EEs0Omw4JkpfFQeNaNtgAD6jM057pmEIVdd4CQJNeS/xI8sYX2dzjfnaPFqVDkZyqdAD aJjw== X-Gm-Message-State: AOAM533O5rCkdfkaZCXvmCVdp03HxINCmoTGmWxMvAtA3FzqGDEx1RPv a6LhD6tZm1pTzufxVTfF8qMJzg== X-Received: by 2002:a17:902:e752:b029:df:c991:8c4f with SMTP id p18-20020a170902e752b02900dfc9918c4fmr422611plf.52.1613087197818; Thu, 11 Feb 2021 15:46:37 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:37 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 09/19] remoteproc: stm32: Move memory parsing to rproc_ops Date: Thu, 11 Feb 2021 16:46:17 -0700 Message-Id: <20210211234627.2669674-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Arnaud POULIQUEN Some actions such as memory resources reallocation are needed when trying to reattach a co-processor. Use the prepare() operation for these actions. Co-developed-by: Mathieu Poirier Signed-off-by: Mathieu Poirier Signed-off-by: Arnaud POULIQUEN --- drivers/remoteproc/remoteproc_core.c | 14 ++++++++++++-- drivers/remoteproc/stm32_rproc.c | 27 ++++++--------------------- 2 files changed, 18 insertions(+), 23 deletions(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 741bc20de437..5c52c612a7f0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1585,10 +1585,17 @@ static int rproc_attach(struct rproc *rproc) return ret; } + /* Do anything that is needed to boot the remote processor */ + ret = rproc_prepare_device(rproc); + if (ret) { + dev_err(dev, "can't prepare rproc %s: %d\n", rproc->name, ret); + goto disable_iommu; + } + ret = rproc_set_loaded_rsc_table(rproc); if (ret) { dev_err(dev, "can't load resource table: %d\n", ret); - goto disable_iommu; + goto unprepare_device; } /* reset max_notifyid */ @@ -1605,7 +1612,7 @@ static int rproc_attach(struct rproc *rproc) ret = rproc_handle_resources(rproc, rproc_loading_handlers); if (ret) { dev_err(dev, "Failed to process resources: %d\n", ret); - goto disable_iommu; + goto unprepare_device; } /* Allocate carveout resources associated to rproc */ @@ -1624,6 +1631,9 @@ static int rproc_attach(struct rproc *rproc) clean_up_resources: rproc_resource_cleanup(rproc); +unprepare_device: + /* release HW resources if needed */ + rproc_unprepare_device(rproc); disable_iommu: rproc_disable_iommu(rproc); return ret; diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 826cb7a045df..6f0bb54dec15 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -207,16 +207,7 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name) return -EINVAL; } -static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc, - const struct firmware *fw) -{ - if (rproc_elf_load_rsc_table(rproc, fw)) - dev_warn(&rproc->dev, "no resource table found for this firmware\n"); - - return 0; -} - -static int stm32_rproc_parse_memory_regions(struct rproc *rproc) +static int stm32_rproc_prepare(struct rproc *rproc) { struct device *dev = rproc->dev.parent; struct device_node *np = dev->of_node; @@ -274,12 +265,10 @@ static int stm32_rproc_parse_memory_regions(struct rproc *rproc) static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) { - int ret = stm32_rproc_parse_memory_regions(rproc); - - if (ret) - return ret; + if (rproc_elf_load_rsc_table(rproc, fw)) + dev_warn(&rproc->dev, "no resource table found for this firmware\n"); - return stm32_rproc_elf_load_rsc_table(rproc, fw); + return 0; } static irqreturn_t stm32_rproc_wdg(int irq, void *data) @@ -609,6 +598,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz) } static const struct rproc_ops st_rproc_ops = { + .prepare = stm32_rproc_prepare, .start = stm32_rproc_start, .stop = stm32_rproc_stop, .attach = stm32_rproc_attach, @@ -793,14 +783,9 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_rproc; - if (state == M4_STATE_CRUN) { + if (state == M4_STATE_CRUN) rproc->state = RPROC_DETACHED; - ret = stm32_rproc_parse_memory_regions(rproc); - if (ret) - goto free_resources; - } - rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); if (!ddata->workqueue) { From patchwork Thu Feb 11 23:46:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381067 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2495879jah; Thu, 11 Feb 2021 15:50:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx20y6HRLLVeDAtDDO3XlYLnrfygJ5FPSJ8po6DTVGaqB8SnagMkTNKjwVAgkW6XTvFN7cm X-Received: by 2002:a05:6402:5:: with SMTP id d5mr598749edu.121.1613087403030; Thu, 11 Feb 2021 15:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087403; cv=none; d=google.com; s=arc-20160816; b=k8f/P8Ux6vL3+scwHMgPkoWKCli5kBcKP1c67h+wARdYwiEZq9aWHJf3hh/6dzJarT Hi1k2uclPHXis0RYKzPPmxZw9t/yTmd/G0HkkcHq6ZfQlHN9MQpd1Q8AZBQQLLtbyzHi kNZLA0UX6jXyRwkWBDMXGPvqt+t1R+JdDNrE7u79iCdkng+gVsh9Nz+cHmRvOpRG9zzc yYjfraF4azOgWNVlso0+epqFKV/KN4z9BjZnQf5FcWbYXBJQ1LFyEPfrvjrx2Icjt+ik MutsIuj7HJYvhLGdMJTQZIGL0wIflArE8UXvEo0Nl/iW4QmzS7S5gC+WSqgN2BfNb8Gh gkfw== 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=XYqKe5JHKTsf6qqgvmLT8SEOr6JSbsFQUrC6la75+Tk=; b=bsWK7A6Z15Ct+X1JKRFLtdhnywOzgK6zR7Mx7oGS4OiNiT+vy5ZQVS58a1VnZgRHG7 kvB/P1qZAHb2OfiBiPL4Vn7nT+i0OPWlFLCQn2gxyTxUVi0e8O6RvP0en9ykSW/Hhcm9 qB87L7K9e9nJPKoDrLzOgoY29Qt6B+Ja7N2EZdYSBeo0Lx4CK6iCs8dCxUjTFHiDVrvb LS4S3oIli68CyFJKM627+aZ/VNaCZuO/9wjUDBw6YFrJ37tNwHdBEKKWFNzyUtbf4iTx 0hxG4JsGGqcEb4IcowBgaI585lCz0BLc+VQHDVdVOQ95BMYiS+I8I3PpK9BUXWW5WM8C U+bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JdchHoa7; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si4969638ejb.88.2021.02.11.15.50.02; Thu, 11 Feb 2021 15:50:03 -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=JdchHoa7; 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 S230363AbhBKXt6 (ORCPT + 6 others); Thu, 11 Feb 2021 18:49:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhBKXs4 (ORCPT ); Thu, 11 Feb 2021 18:48:56 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4177DC061A31 for ; Thu, 11 Feb 2021 15:46:39 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gb24so4368636pjb.4 for ; Thu, 11 Feb 2021 15:46: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=XYqKe5JHKTsf6qqgvmLT8SEOr6JSbsFQUrC6la75+Tk=; b=JdchHoa7ZVlV5+MdQYZdmvDbjBv5SZjvgzlftSjTAhzph9zIe1p3ew7E3tWtnmAOCq lGFo9sYQDG5tnaXPXoZoXsJxuAle5HmFzbLqhh5pCtluiiaK/nbN+MUixIqVYE1eRGEi s//hd0GCI6nxFs6WVeTc6uH8o7x8Utj9y18AWzaus3ak/KiN0BCqKInCWbXLoN0saB/Q 7pU7ki04U0wtCaOK8bWw4dxnxDblsoe+jjI6+AA9VDTHoH/s1R3Joa3bhSsR9Z0MWlG7 5+gNu0rtYfxoa5iH/WSEg6d4ZrebBa+a7T4Zg2pg01qVMSMJgBVdiUvOlVKwmkMcUU7L zTpg== 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=XYqKe5JHKTsf6qqgvmLT8SEOr6JSbsFQUrC6la75+Tk=; b=f0JZo0YniA2MuMkQHXUPewugKv5w6nqsOU8AxKSCNu8LGgiwLLmzP+MuUVYxeM8GU5 PonCisiF3y49OSORZxi0lRTGOglOt2/A4KKL1HulqpsffQQW0W5ZNqUldcmM991Y8TQV JVtRV2wSPpYKpAXU6M8fJEwE5+042nCOGN4vb0b9wC+KcXpCIS4pDrmCwuYnJUghiNab 1fcIkXvSM0cpHzP4CVQJYosyv1bwzBK7atijlcpxU9vd+mMTMUuVaFS//VsBqDGnykrF li6mP3xeqA5eEH70xtOTP4mGuQVewhVWa8AO3Wsn/Cc0rCV2TldIcqho6CJPpOR/8yz9 6tjQ== X-Gm-Message-State: AOAM532sqZpcL2CjEdWhKXWWhD0fnVDh2OWrM+tCb2Qiih6LP2ogRg8J 8px1RPfUguBoRvZPsCt7un1/Sw== X-Received: by 2002:a17:902:8c8f:b029:e0:1663:fd34 with SMTP id t15-20020a1709028c8fb02900e01663fd34mr489602plo.84.1613087198802; Thu, 11 Feb 2021 15:46:38 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:38 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 10/19] remoteproc: Add new detach() remoteproc operation Date: Thu, 11 Feb 2021 16:46:18 -0700 Message-Id: <20210211234627.2669674-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 51538a7d120d..eff55ec72e80 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) @@ -385,6 +386,7 @@ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); int (*attach)(struct rproc *rproc); + int (*detach)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, size_t len); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); From patchwork Thu Feb 11 23:46:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381068 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496500jah; Thu, 11 Feb 2021 15:51:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJx59IpvET/NRRtks1QpRiNO/ue9PZ3w6jrbEbD2uF/s3Ia+UgJ9cYwhW2kdghJJGsxg1jun X-Received: by 2002:a17:906:cf86:: with SMTP id um6mr197125ejb.426.1613087495619; Thu, 11 Feb 2021 15:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087495; cv=none; d=google.com; s=arc-20160816; b=jP/3/Gc/vzDEZLRm1KOdQRuFMSiOTZOt/i8Q493WXhsr597M+6t5SuX5JsSnWnA/RL idsi36POgziC+laZyMTIksTxIlL6vZUBwnX48fNC2L/zA0pNrulFgeMJPf9y4yVn0Vhg mLzE0Gpry862M4WVVyKIrmI+guePJzJEFgBCDI2VTF+AbZ6aIILu/blyii/UqH7jPjkE 4/63LnsK/RFFnUE5DC9iQc1QOZI8eeSNy+OV2ZsqP6tLuogx3UZirvXLP+62SRXmbIon mj2P4q2zwqatGkOVMqJWLbOkUlnOP5XOrMGU8w+15dYUYl705+zlHVx2ZsObdGsMM7XJ 5rNQ== 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=P8ZgBr2dAQyxtUR61d2cd3HaOU57hXG+26qgFPCFdBI=; b=Wv7Au+dMSJxKfJQxVLpj6QyavPnJMEXQ03wWdSeTIx6sabIjCBnyKZpp0ldxFG6MW4 lZzRLq33lk3gNwfhqUrd7S4NrPatE8HeizxEVSIVgWlzLnpdbrIFsn3Du8lRiJ+YMRo+ BwGCDAoL6k3oFf9WCm/WbGKyUpOUfnQBOujWeXfNILKdgPDHWjpwjAuIPfTpNEyU5g74 il4yucKQz8PUN2Mj29ILUncgPkLGSmF/XnQ/qpRUK/1p//+xd+CVr400N+LcEbAW33hA amzu8bY9HJLadaxXOvfBkSrTqmxjrORgF5Qs/ZDfLPc75ZbZVNXhfE8gXGWt7yt+5wWg 853g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dl2LvQjP; 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 ch12si4550788edb.463.2021.02.11.15.51.35; Thu, 11 Feb 2021 15:51:35 -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=Dl2LvQjP; 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 S229944AbhBKXuM (ORCPT + 6 others); Thu, 11 Feb 2021 18:50:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbhBKXtK (ORCPT ); Thu, 11 Feb 2021 18:49:10 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D089C061BC3 for ; Thu, 11 Feb 2021 15:46:40 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id z6so4738060pfq.0 for ; Thu, 11 Feb 2021 15:46:40 -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=P8ZgBr2dAQyxtUR61d2cd3HaOU57hXG+26qgFPCFdBI=; b=Dl2LvQjPNpm6v5pNg/beWWjx3gn0Yx3N3EKYMuqSRq2/+Wms+YUUpCARpU7RRc13ps suzbkYzATDsQV2OWgYy7yVRgiODXzlyQCNqk+YkrM9+/F+uxFv8pHoaKAjcGZivKPROp o1Ex0bgngOJ6TDxgT/kfSVe+MmitK/+6qCyLh605rt6twllmfl7aXFiKOGO6GklcqoMT WxucP5W2wDMNQbI0qiKK+Rjm7bPKEWoX9t+bvbhXruBPSDJmF7i/AppsIDimmrxr+xfd k3Xa7nJF0Ah/BZ1x4tWRJEgVI9iK4zbPWoyViEJLr6lbtnEDiNh+ZpxLbhqENPQjdaKj O1eA== 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=P8ZgBr2dAQyxtUR61d2cd3HaOU57hXG+26qgFPCFdBI=; b=t/1TrRu1L3TotBSVeC5fo2D+34ySZUM0EJKd+q+T96Q9yOjt4a3x+XtWKnSMHYz1AR ahqZf2GNql4mtu2/Ac3LV0kOxc95m62xUhVesfACusmRUowRUbAJRHDoA0McpwC6yjC5 VB81ddc/cxx81Um47BFKVk9SdjN1suHGFQ7HBu54E3dH25XAKb2NC4JqLAcii3do7eQq wtHv0A33KhPeMja3aJxFgzH5DPTFZmc8WJItyhIsvtCGfeMu8kE/rSXJdEU7ZcPP0rHa kowqw6NNRY+NW+kEZtkhzqi0BKqiWU0obWwo4WUpORLYt5HO6OhW3BMezD8Zd4qjWhMe 8dGw== X-Gm-Message-State: AOAM530/7w+hvb5B4YzUdynEtOk117OTYOZbQFeIi7bniu7QVJ4Y3vHi J2BrQIpsBA8ojh7s6D+3UbuEoA== X-Received: by 2002:a62:7dc4:0:b029:1ba:765:3af with SMTP id y187-20020a627dc40000b02901ba076503afmr424252pfc.78.1613087199769; Thu, 11 Feb 2021 15:46:39 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:39 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 11/19] remoteproc: Introduce function __rproc_detach() Date: Thu, 11 Feb 2021 16:46:19 -0700 Message-Id: <20210211234627.2669674-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- New for V5: - Removed fancy error recovery when ops->detach() fails to replicate what is done in rproc->stop(). --- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5c52c612a7f0..b150138542d4 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1709,6 +1709,36 @@ static int rproc_stop(struct rproc *rproc, bool crashed) return 0; } +/* + * __rproc_detach(): Does the opposite of __rproc_attach() + */ +static int __maybe_unused __rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + /* No need to continue if a detach() operation has not been provided */ + if (!rproc->ops->detach) + return -EINVAL; + + /* Stop any subdevices for the remote processor */ + rproc_stop_subdevices(rproc, false); + + /* Tell the remote processor the core isn't available anymore */ + ret = rproc->ops->detach(rproc); + if (ret) { + dev_err(dev, "can't detach from rproc: %d\n", ret); + return ret; + } + + rproc_unprepare_subdevices(rproc); + + rproc->state = RPROC_DETACHED; + + dev_info(dev, "detached remote processor %s\n", rproc->name); + + return 0; +} /** * rproc_trigger_recovery() - recover a remoteproc From patchwork Thu Feb 11 23:46:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381069 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496512jah; Thu, 11 Feb 2021 15:51:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+zYuDAwiexQBXYraGaQfF63cxARHntQezzf/r+fCqwg9/kmM9lz6rRfIq581IpUzSThKg X-Received: by 2002:a17:906:9ad3:: with SMTP id ah19mr177988ejc.37.1613087496814; Thu, 11 Feb 2021 15:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087496; cv=none; d=google.com; s=arc-20160816; b=CV2Pk+bIYWS9Cb7tybQTmN+3+apDQ3ouLl3bLo7uAVYzt4xj/Sk1e0FTdDUq4S13dK FU8EeBB3eN1eFK9l+0Kd91LQ/MzGDVz2sDOSPD5DcdOcBslHfScxoNyJr8XphNCTCKxz rO3LoZ2I3Y12s8ku+aJZqA/yFjtVPl3mL2QMlF8OCGmEU18+iHfGP1sTa71GNAGhKfUX OMhpi+BjRyTqToj6Lu5dNWx/faHka6W3WrHnHtxWpyul5siZLcx81dvwl3o8qsAFkgFQ JMp8knFXpxAGXn79orcjSOdVnrZuGNyJX28wisBFPMNQ3F+WIqTl14h1GN20I/rIWfhy EBhg== 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=j+pNLbToLgdx106AOvWt9gZCfAGYBlkdberppemoXB8=; b=TrHu2/SBeLXVJVaWLsMaQVP0w7ABAklM7189UUrbPUCTvp6ewX+wTkVzpznmaJUs9N x8XqnUljZ8gQePliNGhDoLUyCdVY6mCwfYepnCmVqZBNmt6F7v2cWZYxo+b2kGF9w6n6 8W0WUK2p61kiAzbKA/wdD3mirQHAw8gbSxQwfPmLfpRXAYmphIWBMnOo+sjMKdcokusa AC9UCdxGNj+WHD6kVimv5p6IAoZMVljlmcsGBskA9uacdxE7+x8BjilA9jb35e/NmV4w rzoCPERH7BKd4lyqRuBLultIpqO2vj/zLo+jnXtkLuGuk8DdgITMfE089NpZb8n46L0q o1rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PgBkrZ6S; 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 ch12si4550788edb.463.2021.02.11.15.51.36; Thu, 11 Feb 2021 15:51:36 -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=PgBkrZ6S; 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 S230452AbhBKXuq (ORCPT + 6 others); Thu, 11 Feb 2021 18:50:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbhBKXtO (ORCPT ); Thu, 11 Feb 2021 18:49:14 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36490C061D7D for ; Thu, 11 Feb 2021 15:46:41 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id a24so2270525plm.11 for ; Thu, 11 Feb 2021 15:46: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=j+pNLbToLgdx106AOvWt9gZCfAGYBlkdberppemoXB8=; b=PgBkrZ6S9QNd1c222EuU5tDZ/KFOvbSt54l9FrE03eoiKhAFyfbxglppQkIBdDQ+sh cMGQmIG4Gd6H/PXQnTSw1HXhQk6OlJqooOE8viz0zLSvon8hPRcXfeSj/j8yPya+uv61 +ZFHiWIwnRAnVG9mb/W0n2PuvyXZCD6tuMbpkhKCn+E/cBdgifw7+q66Hvy9HBTc6WFs Oc2M6h65eY7SN64Lb9ckO/4O2AqlemuqbJFTDIc9SlCc3M/QmGLIKWE0ACrt98vgpgiU SucdRGHwGC01TXNDppm6UEwQ/Kn8exbpEbsDOEdvHEhb7jSojnKYG6GezIk/9UQQfMGQ RgNg== 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=j+pNLbToLgdx106AOvWt9gZCfAGYBlkdberppemoXB8=; b=AiZxnKXbHwZB30t64fCfvbegJjk1W1k7RCnrXxNwvD4b+p2IrpphRRzJIb/Vq2YEod iGAz749CF6FYX71JkGN8gFpoJivnh+at2eqxweQ4MWBAMpLeLBVGaKXWt6hFYtUrIqW+ QqK96lTUBWlNmLu52164IXHvwdj1rbx+XejS2pNepxPsw2KiLiGfLGErR/IwbWud6sz+ eedmoPy6jjqc311neJuLS8riirMEHxh6HtZcWN4pNqlVldVR9VpPYEUBQz75oLl90yIU BHVZ9ucA4948KHfZkN/duGmzFWK8Jc9snC99JMh9ses1sOvfnlIEbYO4aiQgmqd9V7uW F0kA== X-Gm-Message-State: AOAM530d7RSxwQT9epStUcPwGtnbm1AuwfKbMWppMCcO+UFmDaDxuiH+ wPWCH0zI//kl9tM8ZIwD4mhBKQ== X-Received: by 2002:a17:902:8d95:b029:e2:c956:f085 with SMTP id v21-20020a1709028d95b02900e2c956f085mr271805plo.35.1613087200695; Thu, 11 Feb 2021 15:46:40 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:40 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 12/19] remoteproc: Introduce function rproc_detach() Date: Thu, 11 Feb 2021 16:46:20 -0700 Message-Id: <20210211234627.2669674-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- New for V5: - Fixed comment about rproc_actuate() that no longer exists. - Added call to rproc_unprepare_device() to balance rproc_prepare_device() in function rproc_attach(). - Removed RB from Peng and Arnaud because of the above. --- drivers/remoteproc/remoteproc_core.c | 66 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 1 + 2 files changed, 66 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index b150138542d4..660dcc002ff6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1712,7 +1712,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; @@ -1954,6 +1954,70 @@ 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_attach()). + * + * 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); + + /* release HW resources if needed */ + rproc_unprepare_device(rproc); + + rproc_disable_iommu(rproc); + + /* Follow the same sequence as in rproc_shutdown() */ + 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 eff55ec72e80..e1c843c19cc6 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -662,6 +662,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); +int rproc_detach(struct rproc *rproc); int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); void rproc_coredump_using_sections(struct rproc *rproc); From patchwork Thu Feb 11 23:46:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381070 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496540jah; Thu, 11 Feb 2021 15:51:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQjTun40PTn6NasFI4xDa+di5F4y0l4ruw+bFEoR+oreBPjV9Jbur0+W9P+hU702bF099p X-Received: by 2002:a17:907:20f2:: with SMTP id rh18mr202921ejb.350.1613087499304; Thu, 11 Feb 2021 15:51:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087499; cv=none; d=google.com; s=arc-20160816; b=AeHP7EgqUBoxsWP/y0rCHyDZ6SZ4rAd4IvkagKpPbmVh4LH/8AepbrutbJTrEtsg2j GfvTQ8ICsdBHpU9Sw3taJhT+Qx+KkRBd/jwunap4+LVWaD3HN7lBbHsS6S98MRDr1qjI ZvRyKYVFjc9ivkGwwLV3v3rqFxIcOFUG49LiPRAJ0AyG937+0TY6DE5zAUL6Kr7KxTk/ oZTADixawBtxnQdimfDdnhk/fjRS2rtmdzyn7n9KfTp6wHpqr0QFvj3wfMKm6o1GFuMb Bf5ZFNvx6aJeS/YQNxVVaM0ZnDtUAuGHIbKi+Kxq1rCmshzxt+a44nO6s5VMgAgVeeN6 gE5A== 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=WxlO1VydolRynfSEzFoSB43uI6cZiPrHzyGFZeYXbiQ=; b=0sg6wJabxAkl8p5QNQK3TwspNphCok7euGm4xWmtiYAxYXPWv4Tw97u9NsYgknAWEQ Ygr5kQqRlYUxkU/KrSh89Hu1ZVl97FfcotvW2kLnkEVYnI+gPhYVwf1rM9VkMnCpGwf8 cqV/Kf2oPdK/1VoKe7PHlEHytwTuuCQkAckILx/3qj3OQ1rf91L5UZ6Y3WfibYo79bGt b0AUxIi2qNiC26ob8js7yUczQ/zqbvprx09YYlFe8qdIKXL8yAE0L5f/FafUxVQ6HsXK du0b+Unb+RADiTdxF04ncJONy/F83L55AA2JmVREROc4AGjMFROoHM3LR9fMLI0+ltSs ccsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jhUZ/keN"; 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 ch12si4550788edb.463.2021.02.11.15.51.39; Thu, 11 Feb 2021 15:51:39 -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="jhUZ/keN"; 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 S230281AbhBKXvM (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230395AbhBKXtZ (ORCPT ); Thu, 11 Feb 2021 18:49:25 -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 36EBCC0698C0 for ; Thu, 11 Feb 2021 15:46:42 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id s15so4192975plr.9 for ; Thu, 11 Feb 2021 15:46: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=WxlO1VydolRynfSEzFoSB43uI6cZiPrHzyGFZeYXbiQ=; b=jhUZ/keN7h7x6UsBjtoZBshOgO4cbRIr+Bi88FURz5l/iyJbJGX31HPdjjR46X0vSi svjhP0gNQZHJ1U3ccf4xwn+ySM0K0xoO6vRtUkFJN+cEbYXUEF3P4znvXeQPA3SMmrW3 7//YzfwBz5QykLOieoYcKjvtARdGoTYKI2C62YFsxNHCSnssGfF4cn166o6S+WuYUAn8 g7quyV0JqppJm2YRwLvd5FL7CTqq89jyMAFmFL2o3LgRK6evxAjK+IcXDCYjpBebqkjs V5HxkLNQgVJAXFQKOJDwj7c/xPAx+j0StJtr+oQ45UYzWVjcIp6I8VuUOJHTHVl7+DzU 07aA== 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=WxlO1VydolRynfSEzFoSB43uI6cZiPrHzyGFZeYXbiQ=; b=sN51uOt943pTEQu9qUm0LAYABNVuFbMajnZa769N78E6s52XVCZNm+znBiQyJgGJxH JRAk0NKEii0+rd7PEnbWHslUBtFW+p3WfgGuYDiGLmlaxKvvzrjl9ZyYKBIGb+D89VFy aSgd6ezSuvBgJSraoQdURF+6RzvHPkPYWkxwWyRvtj8c4s0ROG6XNbmzbRbDClvT8nPT 1IiFW7uFHiaTNJnrnQQF3JCZ332SvnB6+1J72x3WyhDipAQdxRTqKE70pcwRl49LxR4v qMDE9++TRdl+d1zPh/Dj8zAQiOm69QG8mbaPruysOjI8SyuZ/QQFd7LAUAre8a+s105C xc8Q== X-Gm-Message-State: AOAM531eOd/gf5si8NSb2dDbA2T/HqOfJ+Pq1wOfYGKX6tNrTd5vX4BR t00mSEd4EPJgSwCFJABpX/nxtQ== X-Received: by 2002:a17:902:bd85:b029:e3:11d0:367f with SMTP id q5-20020a170902bd85b02900e311d0367fmr495813pls.12.1613087201715; Thu, 11 Feb 2021 15:46:41 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:41 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 13/19] remoteproc: Properly deal with the resource table Date: Thu, 11 Feb 2021 16:46:21 -0700 Message-Id: <20210211234627.2669674-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org If it is possible to detach the remote processor, keep an untouched copy of the resource table. That way we can start from the same resource table without having to worry about original values or what elements the startup code has changed when re-attaching to the remote processor. Reported-by: Arnaud POULIQUEN Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 70 ++++++++++++++++++++++ drivers/remoteproc/remoteproc_elf_loader.c | 24 +++++++- include/linux/remoteproc.h | 3 + 3 files changed, 95 insertions(+), 2 deletions(-) -- 2.25.1 Reported-by: kernel test robot Reported-by: Dan Carpenter diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 660dcc002ff6..9a77cb6d6470 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1527,7 +1527,9 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) clean_up_resources: rproc_resource_cleanup(rproc); kfree(rproc->cached_table); + kfree(rproc->clean_table); rproc->cached_table = NULL; + rproc->clean_table = NULL; rproc->table_ptr = NULL; unprepare_rproc: /* release HW resources if needed */ @@ -1555,6 +1557,23 @@ static int rproc_set_loaded_rsc_table(struct rproc *rproc) return ret; } + /* + * If it is possible to detach the remote processor, keep an untouched + * copy of the resource table. That way we can start fresh again when + * the remote processor is re-attached, that is: + * + * DETACHED -> ATTACHED -> DETACHED -> ATTACHED + * + * A clean copy of the table is also taken in rproc_elf_load_rsc_table() + * for cases where the remote processor is booted by the remoteproc + * core and later detached from. + */ + if (rproc->ops->detach) { + rproc->clean_table = kmemdup(table_ptr, table_sz, GFP_KERNEL); + if (!rproc->clean_table) + return -ENOMEM; + } + /* * The resource table is already loaded in device memory, no need * to work with a cached table. @@ -1566,6 +1585,40 @@ static int rproc_set_loaded_rsc_table(struct rproc *rproc) return 0; } +static int rproc_reset_loaded_rsc_table(struct rproc *rproc) +{ + /* + * In order to detach() from a remote processor a clean resource table + * _must_ have been allocated at boot time, either from rproc_fw_boot() + * or from rproc_attach(). If one isn't present something went really + * wrong and we must complain. + */ + if (WARN_ON(!rproc->clean_table)) + return -EINVAL; + + /* + * Install the clean resource table where the firmware, i.e + * rproc_get_loaded_rsc_table(), expects it. + */ + memcpy(rproc->table_ptr, rproc->clean_table, rproc->table_sz); + + /* + * 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 the remote processor was started by an external entity the + * cached_table is NULL and the rest of the cleanup code in + * rproc_free_vring() can deal with that. + */ + rproc->table_ptr = rproc->cached_table; + + return 0; +} + /* * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. @@ -1947,7 +2000,10 @@ void rproc_shutdown(struct rproc *rproc) /* Free the copy of the resource table */ kfree(rproc->cached_table); + /* Free the clean resource table */ + kfree(rproc->clean_table); rproc->cached_table = NULL; + rproc->clean_table = NULL; rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); @@ -2000,6 +2056,16 @@ int rproc_detach(struct rproc *rproc) goto out; } + /* + * Install a clean resource table for re-attach while + * rproc->table_ptr is still valid. + */ + ret = rproc_reset_loaded_rsc_table(rproc); + if (ret) { + atomic_inc(&rproc->power); + goto out; + } + /* clean up all acquired resources */ rproc_resource_cleanup(rproc); @@ -2008,10 +2074,14 @@ int rproc_detach(struct rproc *rproc) rproc_disable_iommu(rproc); + /* Free the copy of the resource table */ + kfree(rproc->cached_table); /* Follow the same sequence as in rproc_shutdown() */ kfree(rproc->cached_table); rproc->cached_table = NULL; + rproc->clean_table = NULL; rproc->table_ptr = NULL; + out: mutex_unlock(&rproc->lock); return ret; diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index df68d87752e4..aa09782c932d 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -17,10 +17,11 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ -#include +#include #include +#include #include -#include +#include #include "remoteproc_internal.h" #include "remoteproc_elf_helpers.h" @@ -338,6 +339,25 @@ int rproc_elf_load_rsc_table(struct rproc *rproc, const struct firmware *fw) if (!rproc->cached_table) return -ENOMEM; + /* + * If it is possible to detach the remote processor, keep an untouched + * copy of the resource table. That way we can start fresh again when + * the remote processor is re-attached, that is: + * + * OFFLINE -> RUNNING -> DETACHED -> ATTACHED + * + * A clean copy of the table is also taken in + * rproc_set_loaded_rsc_table() for cases where the remote processor is + * booted by an external entity and later detached from. + */ + if (rproc->ops->detach) { + rproc->clean_table = kmemdup(table, tablesz, GFP_KERNEL); + if (!rproc->clean_table) { + kfree(rproc->cached_table); + return -ENOMEM; + } + } + rproc->table_ptr = rproc->cached_table; rproc->table_sz = tablesz; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e1c843c19cc6..e5f52a12a650 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -514,6 +514,8 @@ struct rproc_dump_segment { * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id. * @table_ptr: pointer to the resource table in effect + * @clean_table: copy of the resource table without modifications. Used + * when a remote processor is attached or detached from the core * @cached_table: copy of the resource table * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU @@ -550,6 +552,7 @@ struct rproc { bool recovery_disabled; int max_notifyid; struct resource_table *table_ptr; + struct resource_table *clean_table; struct resource_table *cached_table; size_t table_sz; bool has_iommu; From patchwork Thu Feb 11 23:46:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381071 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496543jah; Thu, 11 Feb 2021 15:51:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPLhE6B00wa2ov7MhoCTn/V6AQprzeaE5vshXodhdCg9dD2NSvuhJkx461ja1Zg2if/HRO X-Received: by 2002:a05:6402:31a3:: with SMTP id dj3mr614859edb.172.1613087499643; Thu, 11 Feb 2021 15:51:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087499; cv=none; d=google.com; s=arc-20160816; b=QJMZL8h0TR++6fz50IxmymFfvfnciFxOtqKNAqJ+MhdcetvePfzDQtiHL74s6sP1OO nEjmt6S2LWvTc1309ZRWg5tO3mJk6S4ovdes5qSMjhIf4zJpt6l9IkWBRO2iiFQFpSmF de3/XEIkPjGboplaRygPbAW26T63yXo5zPHXvRq49O2fukYbTyJcmZGkFHpHSBipI3FC p/yvgFIrtwhalaUb4t5pnaSwlt0kEkN6NGI5NQpSnN7rfX3VYyEVxtE4EAklh0tNWHxS Ra8Fw3x+TaqeCHOVivN5Vm+h5hGzN26FfElOK89y9m8NqDtAoI0mOvu1DFYG+XR924TO akNg== 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=LDZKl3InJry2uc3BIzMNfTpvGwSU2yaFbHElAaRG5qQ=; b=IH0pfieYtDF/bz7m+fLJI/A12f4WwJxmxhB9aThrp/BsZI8oQ/+m/nNA6f+9rJUUDY 4RNVaSKoFt3w4vOYh+Fn9wQrola2jAxhHafdq3NSlOoNaxHXlJGRZEfVtEoju2erZAlO kKPA4nDhoFm+T3Jtn4Og9Z/zMM/oDiSZ0YnaiJyv/IEUkisWKk62uo5atfqrRwG6/NO4 uJUhus/bKUo72GQZq5Yo2Kup1CelGKFPgG38pFKEefzE+98lS2P2DAh1aIMV0yS+dSts sHjlUv0i6IXiUhSMeg1nbFs1tM3/vwNjE76ueBCA0z3IjIkC/pCghqMl2B81u61odfVo Wwzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVkVXmDn; 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 ch12si4550788edb.463.2021.02.11.15.51.39; Thu, 11 Feb 2021 15:51:39 -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=QVkVXmDn; 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 S230390AbhBKXvP (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbhBKXta (ORCPT ); Thu, 11 Feb 2021 18:49:30 -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 44ABFC0698C3 for ; Thu, 11 Feb 2021 15:46:43 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id z68so371960pgz.0 for ; Thu, 11 Feb 2021 15:46: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=LDZKl3InJry2uc3BIzMNfTpvGwSU2yaFbHElAaRG5qQ=; b=QVkVXmDnViCOE4jMf8kqA4U6tgVMTUzDp7YWDf8qKVzsyuWdqJhID9SGoYxyf1TLZ3 IHn7iWfULllzfOiZU2OE5sTOID0KCZ2h6PKXRV+3DklKjnP4sHeZdYYKEkxTj/y3uvXh LhfbAerRSvBobO9kA/1bB/Z2FOz63FEGDPHD/ezqbvZ2CSdZTnOu8Wu3S3mEvvFLP2Pq UhuvTt1Kyp+gOMfJtzBwmUS5baknbeoC50+LBUhuX7YhZsDM/7RxSVQ+zkKDie2ZaZAC jKg8lNGUaa6UMh1k9OF6BfupyXjgnkq0HOanbxABWxSWU3KErERJDjX6zVV2t0SyJy9V DmFw== 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=LDZKl3InJry2uc3BIzMNfTpvGwSU2yaFbHElAaRG5qQ=; b=i86te/0nK0FFsXBoir49VGytVGLpj6/NJm3E67c6zaCIa8MnHDYMqmZCSBxzBRa/qS i/rACVcmOwdG7QXpUwW1z4e8yD1DyydL9D1HrTkffnN3rUn4hppZBgHAhx7tVQZ2DAiL FFFlrbXK2vzHaGuilrtJRUbWOVFQ1YBaOrGPYx/kammhueRJfSUmL5AEdmc1e7vfF44r 8jDUhdnwWZWk0n2adpO53QjmjZ1AZ7gHWaXsBjBAtm73O80ERqFS5FKhancHxt7ABHMk zPe8uaxw+GBMcu4r6zESPChc2roQmHVJCUk2vvHolXFfrMbw4+dH541nVYKODkZv7KV3 5+gg== X-Gm-Message-State: AOAM531vNKl8FcHUybJvMULz8jUuoiVz9fB55j06dTUuRQeiIZamAPTs FmagM917PPppB8HMeOEhe0PCoQ== X-Received: by 2002:a05:6a00:22d6:b029:1cb:35ac:d8e0 with SMTP id f22-20020a056a0022d6b02901cb35acd8e0mr408493pfj.17.1613087202720; Thu, 11 Feb 2021 15:46:42 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:42 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 14/19] remoteproc: Add return value to function rproc_shutdown() Date: Thu, 11 Feb 2021 16:46:22 -0700 Message-Id: <20210211234627.2669674-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 9a77cb6d6470..62f708662052 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1966,7 +1966,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; @@ -1974,15 +1974,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) { @@ -1994,7 +1998,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); @@ -2007,6 +2015,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 e5f52a12a650..5b49c4018e90 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -664,7 +664,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, u32 da, const char *name, ...); int rproc_boot(struct rproc *rproc); -void rproc_shutdown(struct rproc *rproc); +int rproc_shutdown(struct rproc *rproc); int rproc_detach(struct rproc *rproc); int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); From patchwork Thu Feb 11 23:46:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381072 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496549jah; Thu, 11 Feb 2021 15:51:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJynsxB8x8/hL6j4uia8POXPKcoteXIHq+e16Lpd5MLhSghQf2FvNv++U8/n3h235cWmWXFa X-Received: by 2002:a05:6402:1151:: with SMTP id g17mr645215edw.48.1613087500041; Thu, 11 Feb 2021 15:51:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087500; cv=none; d=google.com; s=arc-20160816; b=U09MJpRnjW/xt86w6WOg1kzsz70Viys452QzPazWOm/DraZf7pwRHKg+HXiH/9we3A Akf6W5m8/KOaYhQewwv8nGRNml4raQFemh4P+xmTuvtCbfJrbK6+fQh5JNpu46Asq+yJ 7dRV/a9g7vvhhmAZNq4GmsP7fSRtVkSUCQTkCsLIA7ZJbdvy0nBBa+X2cMiS1MiCEZ6Q ZC7Y5m23GMvVQCGRtyJpn4f5d0qoKV6TmvEDPDFoLdmsViJfDfc3DZhWuDVNudh62ptt KagO8U/EX3LXo1ZX0nbTsA46YDDwXSXY3ibAZ7V+FusiMXGmfWDeM/D5/fWDOt40Nfl0 zq9g== 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=Mp+mWSDpsQpj9MF3x3T5H2fS4e1Av4X97/izXSyp1vI=; b=LADvU+C5c/V9WXOEpnoehX/GA3jD2n9UYO76dSHht15Quysc4CJ4P4pq0lC/WAsqyB ajDmw3trGq4vRi+mWqPX6YpPPWVz+3R5/n8PjaA5mtV/SeqhvBUGI1Pb2Gm9yb1XBw/M whmU9nacsfldtSPOkncb/qSvrAdx7BaCKxgCbVm0zhtM5LWWUHeO0o8KBq5xLSghhOWF XPQIs79qq7QbAchtDA0FAIYIpFr0gF4iVqITAV7e80tJQ8GqxkIxB7g2LNEy/YPcfdtK Q2yN6Y50kWBI9G4Aay9GxWgmMBnOLkd5+R4RCprkR9epUZy20aZrUbgkHCMIMylVFU+p 4uug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IuMH+Xl3; 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 ch12si4550788edb.463.2021.02.11.15.51.39; Thu, 11 Feb 2021 15:51:40 -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=IuMH+Xl3; 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 S230396AbhBKXvR (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbhBKXuF (ORCPT ); Thu, 11 Feb 2021 18:50:05 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33FA7C0698C4 for ; Thu, 11 Feb 2021 15:46:44 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id b21so5069348pgk.7 for ; Thu, 11 Feb 2021 15:46: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=Mp+mWSDpsQpj9MF3x3T5H2fS4e1Av4X97/izXSyp1vI=; b=IuMH+Xl3+C4gUMMxtAllS7ZPSyGIoYf2rMe0IufQxwt52j9zVpYi7Q3JUk8+OxWzM3 PvpHM5+brzjn0zNVXbpwOTW6Fr/Sphi34Y+Rvf4XaNv4qvbVCuVST2bvyBMNbXSy8a2O cefrrkXqEPkTtXSPRfrSIYYPiFexWCuzTM7gVdqpFmeWvFgI7gDGsq2XFJ3t5jph5Pt9 xjrSqVy1afVFI63asEptOugavONzuOBGj2UtNCaJqtu6Kjw4P04eiojQ+/1Txmthy8PW PLREL70UwzlmOeiYrHjsXjEoQKJQxrAe6rZoEkPScppHQGdzJu74eD8haECB6A9poH/Q N/pw== 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=Mp+mWSDpsQpj9MF3x3T5H2fS4e1Av4X97/izXSyp1vI=; b=nAM3VIzM/fVeiv0KQzv2nIgH41hq5T2+Cz+LCVRCF2XQbcuutMa9dUJlckDnV56YT3 DAJBb1nw3193ZlIhAKMIopjJTO4BUPIrADAuWoWRtlk8QoETytFkAWh9U/d9esObHPWK nAEj+3hoBBwZr4ku14e9NYq2Kw5uSukZoyJAIX4pgHkJ+nVMj67W8HXoUgzxX0bsRb5x m1Q0fvuVifxpu9q/BxAnEHn+M8R277UfVKBK/BlDYf17XKqAxqwJhdfDljxkkGHo4G+q beTaUtKnPX4Y3KPVOMb8Hyla2KRrD9oJ3rqhG+xkPwYlAUTyUeMW3mu0SPT9CEFu0Ydy CC5Q== X-Gm-Message-State: AOAM533BiKETaW7CJqoW5i/gSxe3aIb5hpfpa5aTJg8xgHfWQrwGlCk4 liTDy1UEOMyplTMKHddfaNKwng== X-Received: by 2002:aa7:92d9:0:b029:1bb:b6de:c872 with SMTP id k25-20020aa792d90000b02901bbb6dec872mr427305pfa.68.1613087203698; Thu, 11 Feb 2021 15:46:43 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:43 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 15/19] remoteproc: Properly deal with a kernel panic when attached Date: Thu, 11 Feb 2021 16:46:23 -0700 Message-Id: <20210211234627.2669674-16-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The 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 62f708662052..0dd9f02f52b6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2693,7 +2693,11 @@ static int rproc_panic_handler(struct notifier_block *nb, unsigned long event, rcu_read_lock(); list_for_each_entry_rcu(rproc, &rproc_list, node) { - if (!rproc->ops->panic || rproc->state != RPROC_RUNNING) + if (!rproc->ops->panic) + continue; + + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) continue; d = rproc->ops->panic(rproc); From patchwork Thu Feb 11 23:46:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381073 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496561jah; Thu, 11 Feb 2021 15:51:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyPzZuOik3vwl9DAVndmNoBoIAT+PsYUG8yQYuebIYt+F38KXfAVpmfORPR/F1J3QhRtmX X-Received: by 2002:a05:6402:1914:: with SMTP id e20mr600025edz.89.1613087501288; Thu, 11 Feb 2021 15:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087501; cv=none; d=google.com; s=arc-20160816; b=x3oh3lcURZiCi8zhL7rGrltZ3VDcgdxMyGGQwFdUVVzS/lbtHt/lMh0FVYH7GqxrMj ah2uv8Y4HLvRUgnLBEsA1h9la94AhUyqobOSt4tpg1mAzUniHTQwUIvx+ufoXQg7UT0o x/RNbGXT8sY+D/X6FEroybOY8gXgiZjenYzxx/V86ZtMCfkZwNNkUloEYMyx14MMgwMK Oa7l2AKfToDuBhbm1K4Istwv4QgzT8fn7LCaakWhYZysiHNwmB4Dugpc1Towr3KgxjHX b6DtmfUkWERNnhxCk4eg6WBg+NhbeA6s6UYtV/A3Gmt9qbUD9n2hi63CUTiae3OFxx3w s5Yg== 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=JUKRbtXS9Mr9gnhKh7QWVFErht5px8OG4XwmxGU2Xok=; b=ax4hlgz498pSAj5ECHUr9FPKM6iSTPNFUhP1C5hn6XJKzfs9D7+H/EgUm8UNfzyndT GLOAX/lZxXC4+8y3PXSve6Um87aN4sa3GjizwnarC/CQ3tVc6O9WX/DPWrXDCX+4hAfG MizQXt8FtoUnZ+LQwl94QWwTv7UlEI8+vmke0+xFqNli3QE83D7tc74VFfyAvGNJWTau d5/TLBIwduR/aqZn5/3122m/lj7GpwnizMnooyPfNGcECyScm5HknunYkgd+Or555tvq idfBTQqPhupx260JgT6aiFjWEuX9pz3p62l1Rnhqbdg3FBK99vAJqGXHyhquXytossM3 UgYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ja9OFZ5S; 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 ch12si4550788edb.463.2021.02.11.15.51.41; Thu, 11 Feb 2021 15:51: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=ja9OFZ5S; 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 S230233AbhBKXvV (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbhBKXuH (ORCPT ); Thu, 11 Feb 2021 18:50:07 -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 23F64C0698C6 for ; Thu, 11 Feb 2021 15:46:46 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id t11so5056908pgu.8 for ; Thu, 11 Feb 2021 15:46: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=JUKRbtXS9Mr9gnhKh7QWVFErht5px8OG4XwmxGU2Xok=; b=ja9OFZ5S7rJunmDwqE98g/+VHmWIS2v0SVgAJcyyLVL9YfenhvW0b1SJablX0yX31/ Du0RidCR/3xix84ILBIbpDpiNLPUz0oBRg5bRLsMg1wTaPbjeMACmdhD87AZBMoQsn0L zVLqam8Osu/OIvprLTn+9aCc8AZwM/U9A/BYNNX6rRa9JRvSMyBB6oOcj+ZuT8c51vFo Bwa7e0+ubOL0zXIVKEyK+z4eBkxzTocc4xRygVIovDhOtvqIT3CChf989mHJCKyVlCcC tG5RaZ0AHepQrHgm5QdfhBoSQL9fM2U1h9wtR4NZwP4P/HAxjClaLxQBXuMs4P54cPNm fuPA== 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=JUKRbtXS9Mr9gnhKh7QWVFErht5px8OG4XwmxGU2Xok=; b=TI7sO7Q4CC5uvTv7Tc7dk+ZNg7aw5ouytz8b1g9GLhXCfz/lwSzGyIfVsYknT5iqGw R23X7500RU+B6s2uZGM9Qqa/jP3lJEeTduvWddOz3jM6wNflgs8d7fmBOdUSUpKbw/wT AArqS0VUVha0a65bajNkSyjAdbopM2rOv/Og4KDzZNPvaczPLaB9ITYzNMj0qxSeGFXX 8AKsyfHmhTd/5Fy6NI3DI9Qsylkbt1jb79d9RKlIAINA2Q4aIG/Kd81yPNgF0iSdgUul LE1UzrQyy9of6Z+0OvgVUVr2635kDNyJ9wTIGR3Pxj/hDrsuTf+7k7gG5VK33LNByaCH trNA== X-Gm-Message-State: AOAM530FW/hi616n778UKBA3aD4kdUhOJ6uojqdZWMckDrMCZhHXigVj tdt0IkkvRcp7Z87kPU+Ap50ftA== X-Received: by 2002:a62:1c86:0:b029:1e0:cacb:8447 with SMTP id c128-20020a621c860000b02901e0cacb8447mr531680pfc.16.1613087204748; Thu, 11 Feb 2021 15:46:44 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:44 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 16/19] remoteproc: Properly deal with a stop request when attached Date: Thu, 11 Feb 2021 16:46:24 -0700 Message-Id: <20210211234627.2669674-17-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 0dd9f02f52b6..12bd177aa8cd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1740,6 +1740,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); @@ -1977,7 +1981,7 @@ int rproc_shutdown(struct rproc *rproc) return ret; } - if (rproc->state != RPROC_RUNNING) { + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) { ret = -EPERM; goto out; } diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index f9694def9b54..3696f2ccc785 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -201,10 +201,11 @@ static ssize_t state_store(struct device *dev, if (ret) dev_err(&rproc->dev, "Boot failed: %d\n", ret); } else if (sysfs_streq(buf, "stop")) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Thu Feb 11 23:46:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381074 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496577jah; Thu, 11 Feb 2021 15:51:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJymHQUi8Xd58ZUbZy87ox46HPMf7gdYjrkYeEz30iIzbCJ/qcI1/LdXA/sICitmh2Kh8wqN X-Received: by 2002:a17:907:20f2:: with SMTP id rh18mr203104ejb.350.1613087502473; Thu, 11 Feb 2021 15:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087502; cv=none; d=google.com; s=arc-20160816; b=XA4dhHRMbHFT5FNqIeWQaJR1T+W4U5gAjFjp/1LgCt4m3YibAJWFJaSMBcID42H+qY IRq9x3Azz3eznCMN5nqVF0YqDB9cf5HNcVmH7BL4yx+1a+Lzxdji2BK1UEl7abVKQ3T/ 5stzyeCEDllUIPBa0W2COQHN+vBB8SGK5jviBlf4CtJE3KM7XJ9SH5kf0K8+grWF+OKq mRGuleArwFKBc0WxGA07uwbeuhN5i9eyM5gBGxAvAxiLWgx5+ghOlcaj0kGjvAxKZdkQ dYb4NzkKgksrEqptZXFdVJXvBsQRFU3WJq8ik3R2gP3Qy2z5pdCqofT0xQElAHpi/M1h DELg== 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=nWH3imbAeMw4n5RIWv9Jygevt+XepgJ5nBh82nrQrzU=; b=QXBDNDbII+TYm7u/7Kz6zr1T+OljCF7assjl9jvU7Q3XuqVu4el3z17UXGtf8TrkPB sTVEBgb96LUJesbwo2H26GCTpOIxE6ihqlKlDAexlsmNglw60TFtpCn3RuMObzFosOtb JImHJtD1TZf5IYqu14ikJJhQQQc2sSLrw5oeQ19zJCiifzi1oUqIrXKMIPy5rj8GgDxj uwMWnfnpSduJTsvG64oByoZFCrWXwftele3oJ1U7G5BnI9F6Q124K1NG1ApiWSksps/4 QkZAfDZcKZUW2HbD5m4kFJJtsjt0W8PXyL6VSwxfjGO84KvYL72W+LGaFL67xLwpCets QGRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OsUt7nvV; 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 ch12si4550788edb.463.2021.02.11.15.51.42; Thu, 11 Feb 2021 15:51:42 -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=OsUt7nvV; 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 S230381AbhBKXvY (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbhBKXuI (ORCPT ); Thu, 11 Feb 2021 18:50:08 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3330C0698C9 for ; Thu, 11 Feb 2021 15:46:46 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id b21so5069412pgk.7 for ; Thu, 11 Feb 2021 15:46: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=nWH3imbAeMw4n5RIWv9Jygevt+XepgJ5nBh82nrQrzU=; b=OsUt7nvVzjq1BmdRnvM0Ryju3WLLiLSgarJPlpzD0x4jyGi1rgG2Dth57tK5d5PltX BBXdHFgDZGzqkqeVy+teyQXKuSz+TWhYZDPUuflpgghbp8lhbB/SczBEnUUtr2le14/A t9SW0oYT9SOAnQhh5DKGyQ5/pfmxrYxHfNOfvqVaCrNHfnkFTqHE67UoFcdOA//BhyIY 7Kiwbjcmnf2XrZrviU0YRaG5l7ocRaXq18bMVaH1O+d0T1YoN3gRWbDEK3JsxHIyuBOI CD738Gw4bs+Wl05rHHJkZYYwuNjh7f8WgcWP3WT80dYw7F7lKb3uzot+dzAWgF/KIGMv dM/Q== 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=nWH3imbAeMw4n5RIWv9Jygevt+XepgJ5nBh82nrQrzU=; b=oqAOjCqW3X6SnZ9TFxSCVz7W2yqAw6hRhOBRw/QAl3XrTuiDzoyp+HSoEUiGzFchKj 2Ixadc8Q8n82Hny51b1WAV3F7F+oHwuLTf0uBbR0sfPVt63e7Uv/M5cHFc/LGELtLsOY GUasG7w1et7gbVB6Tn50gRh1AogA4kV/11PbdZWZJ6h8GZkiRrb6QHRjApPyQCjpdpTm +W0clkkV9sJd0JZLEuZcJDmp0X8ZiRtca5tBfJJlg1F91jTESnqHVeT2If4T76eJXw/v EIp3Ls30jx+enOLFZu62XrISBEYrgClT6WQMK8xpcyknsn+Jgvi/khdgFiaHl36Il/Oq QD3g== X-Gm-Message-State: AOAM533Y42TX2XqpeBNXcE8ToW9odQ0jFpPEWQ2YBkpU2EHAMDqc9CoM j1MHhE547oc7AMaQQx5Xx1N0wZDjEglXqQ== X-Received: by 2002:a62:187:0:b029:1da:e323:a96b with SMTP id 129-20020a6201870000b02901dae323a96bmr386865pfb.28.1613087206129; Thu, 11 Feb 2021 15:46:46 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:45 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 17/19] remoteproc: Properly deal with a start request when attached Date: Thu, 11 Feb 2021 16:46:25 -0700 Message-Id: <20210211234627.2669674-18-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 3696f2ccc785..7d281cfe3e03 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -194,7 +194,8 @@ static ssize_t state_store(struct device *dev, int ret = 0; if (sysfs_streq(buf, "start")) { - if (rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING || + rproc->state == RPROC_ATTACHED) return -EBUSY; ret = rproc_boot(rproc); From patchwork Thu Feb 11 23:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381076 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496741jah; Thu, 11 Feb 2021 15:52:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJybiHB2MUBySYUJh9XvPmKA5zb02FKoxLlO0D3gl5PEEiqAtUOeor8NvE7WAmbKa818rBD3 X-Received: by 2002:a17:906:660b:: with SMTP id b11mr200241ejp.458.1613087520965; Thu, 11 Feb 2021 15:52:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087520; cv=none; d=google.com; s=arc-20160816; b=stmKHd0bOwyx9KsoNo4y7U91KgK5pvzBL6MquOfx7om+lBYY7JpQcpEqDj4dOb8Q94 5g5pLoourEwU58UUyF8xIyR2dd8VTYAAU7kpadrywabQ1H6QgHAKsyEn+PIvlYSbsnJq fdRJmz+DV/X3qgTmzwK/XUX7VCTo2wsKQqbGikao3eP+Oym6jPV7TBvDjIyLiQ1m3QB8 CSANdoF5N7Ks1Yhvqa9MOBp8w/zFosxvpinYh+kNtCUhbHHj/NQZdeRCBijND8FdBbzP joxogxMeyF9DwL4ldlYwKI1SJNXSClsCr2hIfTw48LB/W/E+d6+00+eYdxcjYdI0B5qf 8miw== 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=5LiQ+DrqaiKdtyOZ0qd9/kmr3OB05MnkkmAeFHXfjc4=; b=ldTM8NR9hp2gbJu/N+1hiayge7mStuDxtTvzATSOYfAvJqTsUJ7lUDT2Z/dV1YjzL9 /xXCtwdAnY+Mh5Rzzxho2qjMQegiacnwsSHnIPOiD10gicgjYOiKVRLcrZY0ik07WgcN q9vBnmJa6MGSQNRZAXVNF202U/FbzqQfwpVe44ZNV1L60TQ/dCKhYf8FsOO77JRyDvLj 13Hd8xF8NNaMANBNVA3ORg6t4I+3gWINpLGjz5wSaweJaG35gyXgONDbGKnI0WHLgodE cNvEr7QxpLZHCTDzU/Gn6BGG5md+ScAPdOU3Ges1vZEHvyYqpLWRXO1p/EeZK/jJ7nB4 C6Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SSYN+Wgn; 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 ch12si4550788edb.463.2021.02.11.15.52.00; Thu, 11 Feb 2021 15:52:00 -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=SSYN+Wgn; 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 S230444AbhBKXv4 (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbhBKXu6 (ORCPT ); Thu, 11 Feb 2021 18:50:58 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E58C0698D0 for ; Thu, 11 Feb 2021 15:47:10 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id c11so4713237pfp.10 for ; Thu, 11 Feb 2021 15:47:10 -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=5LiQ+DrqaiKdtyOZ0qd9/kmr3OB05MnkkmAeFHXfjc4=; b=SSYN+WgnLbG2ER/GI4pl0JRTRnaR3bgiGuZH/zBXNJZUmCGM0XYF8bs9ogCJw+gBVx zbB61u8+Cx51rvtIkimeNIFskk843o6zkUeplK2mfz34bO/1ixUfEHUwXl45K8bXMRqZ PiI34g01DanreaBh1mVooQr1Lpny4gggo0Ecs3FnrYgdmSL/ItczbJy6TG1e8Vgvxw0T rrjx1CYGbvcHO7WdTREskkiCOB8ou3LOZSK2NggZV+LFMfPrQt8GBf31ZTih+xC3h0aZ JCBRUV5kUczsw4Ca0W+M8C5KkNx8ZljR2rhjpbx4WQgVNq21v//Hc4GIhAYMAmYfXSEq 65tw== 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=5LiQ+DrqaiKdtyOZ0qd9/kmr3OB05MnkkmAeFHXfjc4=; b=CuB5CQUnJnbwCceRdT9Hobc5hBVYOVZoRYOvs9SkFRGu4eiGSJ84bg+vhbbLcI384Q mK0Ykzh26u6W3Tjt20hvG++4gxhr0+LjsrPr6AwZSMrkwmgQMsHwCGw2nMvOYOKglnsn U1j5YDs8ClRP/w0lgC8A3ib7jWxkdP1aMVZde/+X5mIEmMRYpdVAH7yFyf7KnMlXxiuM Q39NjrjpXoA5/iW/6NWoB0y3cipWse8JUuiWy4LyokWEa58hxbCTN3vKCmYLdQsX7HZi Q+K2OkSuPXKFtRcTsWfA0x4eqyQwP95ssRX7gKxQJ883UPi/hJwJHT0k2FdRVnfSgJBp QGDg== X-Gm-Message-State: AOAM530xJBd9KrNawWXb0+Dz/iR7xycwdNqz9Vhlks7lDs4Yf/1p7JRw rIArexg3+Z2NfMrdBzFDkUaEEA== X-Received: by 2002:a63:343:: with SMTP id 64mr556316pgd.232.1613087207742; Thu, 11 Feb 2021 15:46:47 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:46 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 18/19] remoteproc: Properly deal with detach request Date: Thu, 11 Feb 2021 16:46:26 -0700 Message-Id: <20210211234627.2669674-19-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 7d281cfe3e03..5a239df5877e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -207,6 +207,12 @@ static ssize_t state_store(struct device *dev, return -EINVAL; ret = rproc_shutdown(rproc); + } else if (sysfs_streq(buf, "detach")) { + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Thu Feb 11 23:46:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381075 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496702jah; Thu, 11 Feb 2021 15:51:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPepbNjUWdH8DQ/OkQt3ZInEJDKcO00GOgBe9hi1YqAWPUQ6Qe1nQH7wsBO3usOSkwosSx X-Received: by 2002:aa7:d297:: with SMTP id w23mr603049edq.173.1613087516312; Thu, 11 Feb 2021 15:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087516; cv=none; d=google.com; s=arc-20160816; b=09rVi9SooKwPNh0x5urMqeeNziDnLmSsCO9I0aFLbEwxseMIwUUo050ZpAJVS33xiK woqpISNTLBGOOISwGLqDG6SKUo4RvTOa/DMpKU31gLg7qNfqI6BW94aHt9/fDGWo8U7i YfqIIJ/YdmstM9ErlzrrW3O9uQ598Uw7P2DVFVMcYtUsdqa2K3y1Tev70ZBpcSSjvIu0 VnhkvjMnLR0bHog8w9XzkMWBTaAWIlM6SiBsSuo1GHiwIlqizYrxtXjAubJkRcVpyq6Y bEo4Te78oj1FfzVTex1jIRciCCW9cySNL575ZtrWItFCqQuOhRM1V/CtxVWMQHl63voG kJsw== 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=+0I2FxbDSsv8cQH5eSoJMFXvbpy5lOFWxMK2CkAG6co=; b=lJtBdh4KETBluFuPJFYzcHYR8SmOO6pYVi4zQyd0uUA806I/uXvTwjqv5BlbvHjVmz R1NhZvqPpFeRo64JFi/4hNpp6bvPvU+QmeKBHyFiG6SJ6HxVFf532+KBYaoKbrlZZhtG 2t11or/Qt5R+RBNhgMLn2cnMCrsNASxKa//IVdYoHFbEa2pWhhUt6tDcbuoOA+bWj23k 1KYA0LVvVyB8qpiQvOYaT6i09AK8EHjFMYIAgHMi8bMXWUNkuwXhoIQyDVrdTbmv6FIq +pFfWN7BMI0W6fanISpYXsVeLQLT3misOi2f5qrD3JWRylFQ0igGgxYg5Gj7hs0nAMzT c5WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCIeixkz; 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 ch12si4550788edb.463.2021.02.11.15.51.56; Thu, 11 Feb 2021 15:51:56 -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=bCIeixkz; 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 S230320AbhBKXvv (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230345AbhBKXue (ORCPT ); Thu, 11 Feb 2021 18:50:34 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A5BEC0698CE for ; Thu, 11 Feb 2021 15:46:59 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id 18so4731855pfz.3 for ; Thu, 11 Feb 2021 15:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+0I2FxbDSsv8cQH5eSoJMFXvbpy5lOFWxMK2CkAG6co=; b=bCIeixkzJNEwVKPQsDrd499M79NaeE/5Qcm8AI5oQBm3ldjySTUXAI2Yb/sB8Az5KO doVYzyeXIzSQscA7IcfTX6pqSTsG3UzH5xq4y4IDFSYxckfc5zbkYFNFqSbw81BDqN3L DJQA1lArwqCBBC/3eTbYQX+QZ0OAiw7/JRCyRg2RU4nNjdyj9uk7sO56xiTRtcU6gDxN eBTuifKnwUKvCjQxcFxfkj1Ao0A1lf0yyijzVZhzjYslwrmfNQngmRJb55aIZxitGS/f vUw9efVAkFB5qXuBj8soe1CF+xGaUG74HAMBEc7h+3vo+/GyDGNZDsAbM1fmin0eVsvA acyg== 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=+0I2FxbDSsv8cQH5eSoJMFXvbpy5lOFWxMK2CkAG6co=; b=lsCx25YzI/2+uYjNGl1bwOPefiJorRQcAPIFwfTQ3mSeBU39qnRTW594EgggyQba0p bURZ42gBCGKDaC6rw9p/qOEfKhPEjrfeq6KqtvebT/ISLpDMRy+GbYhROXRe7wdB83yU xhWfX/95CXdXNudT813BLIrErBhSDKkehlMKXhsfwklTvw1jlTmrRaUn8FW7PNZtCsVM Ts7dPG6v3qp4sb1e9CCOlAsya4+43S63LkJSRyLG2zOfggSXuR76Gnz9fd6j4TfZfjkb U05xPO1h3NP1ybDhCwK/oy+wGi67sZrtXqzqfJxLedPL/dliXPVrRKGEyfQcNiKDvPqB mFrA== X-Gm-Message-State: AOAM53015gw4AD8Z/aBstag94FMSRL9ojb8uA9Q0P+bT0VcgyKJ8rBGZ m+sOyzdbFEDCH9QfqMlXZyIr2Q== X-Received: by 2002:aa7:9ab2:0:b029:1e3:c753:acd8 with SMTP id x18-20020aa79ab20000b02901e3c753acd8mr370600pfi.44.1613087218700; Thu, 11 Feb 2021 15:46:58 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:58 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 19/19] remoteproc: Refactor rproc delete and cdev release path Date: Thu, 11 Feb 2021 16:46:27 -0700 Message-Id: <20210211234627.2669674-20-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Refactor function rproc_del() and rproc_cdev_release() to take into account the policy specified in the device tree. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- 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 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 12bd177aa8cd..36b3592caf34 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2413,6 +2413,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 @@ -2471,6 +2487,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) { @@ -2547,15 +2565,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; @@ -2574,7 +2602,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 5b49c4018e90..bd3ac6a47e47 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -524,6 +524,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; @@ -563,6 +566,7 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + bool autonomous_on_core_shutdown; }; /**