From patchwork Wed Mar 10 21:10: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: 12129405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C101C433DB for ; Wed, 10 Mar 2021 21:12:47 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 32C3564FC4 for ; Wed, 10 Mar 2021 21:12:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32C3564FC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iQHgNCjXw2gbKvbggID3LDgVMQeIMTG2TBMC4+Kjkjg=; b=jQWCU61Oe4/8hMi5gIAgD5QiY EPzJmxYfnKMES+hAuv2YBNSHJhRKbjH9XPXPvNbaykKY6xKgsyzL0mLiHeRiU3Pm2V3WS2kEGdQGb L67TBz5DEJfIQPKLq8JhxaCQ+N4tds60oevaoK5EQhj32UVtGViVXg28Xbp83mAQWA3NXSrz1RLdh YBhckgf2fzfgD6zIcIZgBAwErsgbyWBajao7CILkAIUyRWaijg0pS/t3JIaW6sbJSuH+EAJR2P4GK 3aPBuHGQjHP+bzHKm4//F34L09sijOLwkhwcWyM/h9sPt2GvuN4U9H3AA42BTnWuk7pqx8qwL61e5 h+y6qPb9g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK66b-007jYw-23; Wed, 10 Mar 2021 21:10:57 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66A-007jQW-N5 for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:34 +0000 Received: by mail-pj1-x102e.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so2172286pjb.1 for ; Wed, 10 Mar 2021 13:10: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=2KkXz7Q+zlIq4fjTeJz23Qytt+RMPnrKFr7q6Kz46gw=; b=uxghajg9JyNe+viMY5CmPx45ytmcbsKjTjHHbDoN/ea5chNBMZkGesEQe2w9XtgjeB CVLg5EuWCvv7rhnSGVI/+Lls4kdjZrn0JlYogFmvZ/ER9GQdvqRzzQyLMiDrO8uI19kF XVbHP9D3FUS+7XMcEEjeRZnrNs64IbV5kd17yqH6tgIyGfCxha6umk5tBaur9NiITS0y f9bN7mpQKzYPMKJK+FaGaXUOFLJ4GsVR3o3rAQj8HDAJfJT8v9BTzUIWXDO2SLtDXazN BqZO+zTp1ZKx7DELLH83J5maAdF4AWcdS2r13jjL9hb9xIIVCAqOTtcxQMgw7cNSthmm yD0g== 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=2KkXz7Q+zlIq4fjTeJz23Qytt+RMPnrKFr7q6Kz46gw=; b=relowfaFm/2+Qu5wxse5WLXKuVgjP9TKjwk9hRBvhoFIjJy+Akl+oe+0n8JSSIbxsN /oiTMJRmYkmOGQwKnbnjAU02V2ofeibuRZsygPFU9CTKgFmZQ58NoKoFur6gEkkuP5Qg AvYCdXOgPP/f17Zi4VYhKIHK+7YrR0PDuJPWZ7/wjFDiRuSSQF0TK8LCINTuTwWfExku 12fYzfTsLKCj+emki8/G4zOzy2sVVwdqmtnFrpTYyKOjosLo/rIN1euGU/M/fyrikDqA XZuDN0yB8i8XjUygvKhB4No5oUHDB+UNsx1DhjCtNRbX0ByQIH/Oydg9bGtRR5e0aEG/ YzZw== X-Gm-Message-State: AOAM530CVQfLE+JzqrfGa4ISWJVzn4CrYCLswA3W1gP62c7N7CaikFaF 7M+sOyl38f6owGylHQucBUOxbw== X-Google-Smtp-Source: ABdhPJxpVSK/wCZdFiwxSc/jYo2GQZobozCzcsdExTvaG0N3ILT5bOh2mT/poVuSdphe5WV4A2rORA== X-Received: by 2002:a17:90a:8c84:: with SMTP id b4mr5333915pjo.21.1615410629004; Wed, 10 Mar 2021 13:10:29 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:28 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 01/17] remoteproc: Remove useless check in rproc_del() Date: Wed, 10 Mar 2021 14:10:09 -0700 Message-Id: <20210310211025.1084636-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211030_929171_5D6A75DA X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Whether started at probe() time or thereafter from the command line, a remote processor needs to be shut down before the final cleanup phases can happen. Otherwise the system may be left in an unpredictable state where the remote processor is expecting the remoteproc core to be providing services when in fact it no longer exist. Invariably calling rproc_shutdown() is fine since it will return immediately if the remote processor has already been switched off. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ab150765d124..d2704501b653 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2347,10 +2347,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 Wed Mar 10 21:10: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: 12129407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD311C433E6 for ; Wed, 10 Mar 2021 21:13:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 20AE464FC8 for ; Wed, 10 Mar 2021 21:13:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20AE464FC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hypLriGUX/1a4e7/L/y1/eipRTGbXJcIczcxJTu69Vc=; b=eqcaXo5v3GHxjFKdK3FhhIp1X 94EWzQVIXii9mezwjE84U5wEp/VD8Ev3pJ/02V+fwDtuDY3r55DJ1ciuSuSLpjwfkbHAN/t1VmpGx TuagoYhG4tYki8gBzx9MveO4XmGcuqkY2aKvQ3IK28xkCSLZuPiC7yeQLqnnGStcAki9RI4TmfMfo LrR+x8/qcfMk43jJIitHSCAmCrW/qeXeW8qdH2wpEoaR5VmA6H3ik/mk0IA5mCTTwkugWMr549AfQ Lha2ncljVQgBEEl8oyLI/UW6iGmDytTxk+l6656O5EINYqYeHkUPndWL1fdxd3CBIa03cw3pagfKg msVOPA6/A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK672-007jdY-In; Wed, 10 Mar 2021 21:11:24 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66C-007jQy-7K for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:35 +0000 Received: by mail-pl1-x634.google.com with SMTP id 30so4557229ple.4 for ; Wed, 10 Mar 2021 13:10: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=eI1kKtC7UxMHnJr2s3EPvhdO8fxk/LLGwiTP5XOosV0=; b=UBK4sB9rPqlGopn6Z5INCKpCrPpZzqDE+I4XbK7nThpRAvYlKYvf3tUmJmo+qNLft7 YEbmENwVcmoNpmuThUeSA66fABdXcBujiuxHZEPpA+IqXN5COkMH+bP1e84DJ9Rvk8zV NAdmN2K9aq5Tmi+2m/Y050H1+e3FtbhVLB7+NCUnn0p25IAeju0QiliJYJQFEkDIKVja psakErG2aFSIYt715LmTouU0MREfP0KYkWL4PgcZ4M90kwrZSi4Ex70mStUPAqJaFo8v bkd/Yd6wg9sis9/FaDXTVKnyAym3NHKxzbLk0HMjXfeFP7JBYOdS46A3WJCEzA+qdzDs uD+g== 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=eI1kKtC7UxMHnJr2s3EPvhdO8fxk/LLGwiTP5XOosV0=; b=CdQx9pxHsuXQ1jBQWO21Kry6j3g2My7MVQAhK7jmtQWaG3nezBV30n4tCVzKV+OX8d 9Qsn2v4rSvdYumw/MBdkPvjpwpCwQRcHo1oUospF2coK4fn6ibxX+Ku5trQiLf0gYlCJ VT7fGfV746O+WN6j5wyJFxgLo51nUbWPsN/91rUtmyjgcdO5DWKPTwow6lXtAr+8xgZz d+kq2vG5mfBbZWYlgvLXPMl2VPX0a+eTINJO5UsOyXpcory7VeO3KCqlWi2f5MEaRD/g vcOVgvVz6yXSlaaAxllKl2JVcWIr8j2KY+MGZq7y47Wy71fks/S804uim9E4fj01xWE5 wKaA== X-Gm-Message-State: AOAM530enk7a27nVnMIY3fcJldJnmj0Cc47RMJOkj1k5/4/77I6+Krr5 18pZqQbnVr2QfLvracCOhGhq7w== X-Google-Smtp-Source: ABdhPJy4lW4Frr82V0PylUcRUwzYr/y79yLaMzDeiCIpOzcFfrucwFzywRye98FeurtrRXubLxOEuQ== X-Received: by 2002:a17:90a:bd90:: with SMTP id z16mr5579736pjr.123.1615410630433; Wed, 10 Mar 2021 13:10:30 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:29 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 02/17] remoteproc: Rename function rproc_actuate() Date: Wed, 10 Mar 2021 14:10:10 -0700 Message-Id: <20210310211025.1084636-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211032_773815_B6495079 X-CRM114-Status: GOOD ( 13.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index d2704501b653..7b66e1e96e4a 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 Wed Mar 10 21:10: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: 12129409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 698C3C433E0 for ; Wed, 10 Mar 2021 21:13:40 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CA0C64F85 for ; Wed, 10 Mar 2021 21:13:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CA0C64F85 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4Ol2dtKPYpAMa6Rfv2rWFhjpKBdqBFZGHp/23479TEw=; b=c0lHLoT+y7Yok1ofuprG5Ttsp 978cHnf0tju+GXtSqgqy51Bvy9iFDKmEaxrfeiHgJg8I/77iLxB4vzUO4tMblozR+cMRWlRC0PLQC 0wB2ueDZRs/QMtcu7ZxtzqflYWt/6m2uB+xq+BkGxT27ms/0IQVb47pr16LBSi/36OuRw24Euv/Bs yzmM7cafYVqw4SoPAyTlbpRyp+jQx+MEWPVUYmrj0cMN3f2fxa8D2afW14IBet6FT3jc+d0o5KKTS uuZQvY9IcOIWuYgOFbNlX5anaMKcqXudS1bCYK9P+6Am1lX/m7VZ2fvuCtGgB9qNgsqrCgce6yj2v dC6aK5h5A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK67N-007jjg-02; Wed, 10 Mar 2021 21:11:45 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66D-007jRK-Ls for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:36 +0000 Received: by mail-pl1-x62b.google.com with SMTP id u18so9095686plc.12 for ; Wed, 10 Mar 2021 13:10: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=waytkFv28UuOXcaaNeh19CxfKAUzKWp03mnaFrOUKvo=; b=MV3MtVCfys36kxQjse/S+dduV1se8BJOpsCuwXqynbBzsVV007DjUIdgS8PAkz/DRW Ej/2xzVT48CGwzLBvCOE8zYFSEj0t5dx8YugIuy7KPnnJ3xAeP11GRahnIWyiRwGytsF i/AxAG17QYGhD25AGcRPdmcRJ2vE8t449jSBBxzbwcDjOc+tIzRq8M52JjlPapGl29ih Al7k/5/J177VSC7hiTV/T2Qv4rXaBm0nFBH9X2Y7RbGpwYnY4fkS80/2q7+VCM+bhUXW U+a5AD/m7Ub3Soj0YvDU4NrDWg2rNLEDIBf01Aq1+XOxF7QfCyBV2ggNilj/0N3g3bAF lZWA== 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=QnysRl72x5wviu5lJHLJ3AVtHaVYi786OFzxLXc/cBnTxGboz+1J8Xmpj8Dt8ldaqA 4EWc3fIWtRkxhmZ9GpFgyI3xglyFSK9G7zmchBHDFAuKLqFiMq6UVa3/fAlDMhMJYJap kwADWx8FkDYMFzEDrm+8lD5HibiG/+dhNbhvnAZjcdPCTqqeE8qCTJbaIXFECOE48A+L vlgF7lKT9fnSw1CpKosumV8c8JikCTXov3EhIcjBYz7k00D8SU5ulQpCrkRcHdR9CLCG trEi6aWrmrH+NOnsZTU8tYt0Lt4qH+P2uyY1ju/2bKHKwKOCU+bUC+aIlncbOUHUqhbA IBng== X-Gm-Message-State: AOAM533VLJqsEZdu3J2gzFYCxw7XOPJnWE2G+q7U5IePL7vsyLKKPr14 khEuFmbRwTDLQL6c76U7dpaD7A== X-Google-Smtp-Source: ABdhPJyDPbb3fF0VhrpzxyuHDuhvjr8vVzZyk1acPAGk3z1x97bv9KAVr5M1NrB8P17iQJ9udUkO8w== X-Received: by 2002:a17:90a:7e94:: with SMTP id j20mr5658408pjl.8.1615410632062; Wed, 10 Mar 2021 13:10:32 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:31 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 03/17] remoteproc: Add new RPROC_ATTACHED state Date: Wed, 10 Mar 2021 14:10:11 -0700 Message-Id: <20210310211025.1084636-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211034_456984_0DA8E719 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new RPROC_ATTACHED state to take into account scenarios where the remoteproc core needs to attach to a remote processor that is booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 1dbef895e65e..4b4aab0d4c4b 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -172,6 +172,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 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 Wed Mar 10 21:10: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: 12129411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58284C433DB for ; Wed, 10 Mar 2021 21:13:57 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 558B764FC5 for ; Wed, 10 Mar 2021 21:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 558B764FC5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nqyjUD8qeoCKFYACk1YaR37dyyQToyPSTssiyc82CcI=; b=Ys8CX+VpFld/LKBHpcVQjYmKR 6fyMTKfQs+qYj8Pp+cvA3t8+4spTfHzBxDG/SZp9AQ0HkjlMjo9pZqW3Ue0vCQNc5HR/HrDnwNDnw VABrGJMLbpE2Le0dg7KQkJYgxjGr7G4gXeeT2dlnS1Q50lW7BhdwAkSI5PxxrUwh2j1NzlrN0pcY2 +eokqQ5VpMy5LM2IImFkH3SBlc0W2beeHIXO+8vVs9eMae/Ak9QAlp2IMb8frlow0yhBuX9wKfLiy 8VVBnlWZbAVXpxMiRQnhF17+sqSRYgmur3MgAZJuhEn67V9RwS4yM8NbLRSCkBpfRQSYT38tft/BN LY/alvM+Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK67k-007joP-1F; Wed, 10 Mar 2021 21:12:08 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66E-007jRu-WA for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:37 +0000 Received: by mail-pj1-x1034.google.com with SMTP id ga23-20020a17090b0397b02900c0b81bbcd4so7939662pjb.0 for ; Wed, 10 Mar 2021 13:10: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=EmIttTOsgDNM++s8zt1RjF9fKLTZIPRgfTRmynUwSgM=; b=bp/hGieS85PxB0+VVvXDfnDdbQX5gAUgZelPh7wvgB2u3cAXvLUXmcYR5M2WpTVhRO evI4ag4pZMg3luw1wt2VUjk2lNWcTI7LZrnwjyBoJXKmMaZyH7TB2aKAg4bgXwjr/ObD y1LWcOGwRE8Axamz99zrWyZkcNWricL/1mAsuC99NRoTprSdGV9U55UtP/IAWQwqAzZZ QkkOh9NRqOd/ZntXT93RUoT27eBNtezLbsRVYPLCK2ohT9P77xKVO3LIijuaTzGXQ0BJ 8Lb/h+2YwR/9Dnbr4tnrT3laWpSTy904VimI7lqeL+vQEigRZRKM+wdjG/TuR6zZXh40 NjQA== 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=EmIttTOsgDNM++s8zt1RjF9fKLTZIPRgfTRmynUwSgM=; b=gtVMZo63+OSk5ma9P55wNIEnv149mQ0kVXk//6iO6gKiFjdvfdYyLDWFD9+ijR5xtd 8hEsvrw6j5kX2+hkj1w5It+lSqz24pjeewLoRFm1PQUMUsr9aAU/p0ObF/fh2y7vD7BG otRMhPQ1AUaE9P5WdFDYpqUhzD65elCPCxyPwN50pVPrrgTGJkdTkdsME/ikmsTAaibt 0fE4oLGjhUzAWto9Mu8XBdMLTslugv4ERiN+wH2ClHYU7yAZn/msITDSCXi0ri/BZKrJ ltSfKRoUt5H2hMdes99V+umnWIdokX9pvGtz7JDMJcfpNdSSedCQ3n547AeEr+VPL6pb jT6A== X-Gm-Message-State: AOAM532z51ng+RucR9KF2VU3Lu68rz66a9sLk+gh/MyMCwLwBUf6/Zbg DzCJEOtKrCY/7OYAMyyIMZum0w== X-Google-Smtp-Source: ABdhPJwmWUj2ahl3IaLDmj+AWISKVVSEf0f/KacnzanCP5vtlLzTbFJEMFYJlrWoypakCMr7zamK4w== X-Received: by 2002:a17:903:3093:b029:e4:7e03:d618 with SMTP id u19-20020a1709033093b02900e47e03d618mr4917120plc.54.1615410633436; Wed, 10 Mar 2021 13:10:33 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:32 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 04/17] remoteproc: Properly represent the attached state Date: Wed, 10 Mar 2021 14:10:12 -0700 Message-Id: <20210310211025.1084636-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211035_838349_75DBA5D3 X-CRM114-Status: GOOD ( 22.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a need to know when a remote processor has been attached to rather than booted by the remoteproc core. In order to avoid manipulating two variables, i.e rproc::autonomous and rproc::state, get rid of the former and simply use the newly introduced RPROC_ATTACHED state. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 20 +------------------- drivers/remoteproc/remoteproc_sysfs.c | 5 +---- include/linux/remoteproc.h | 2 -- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7b66e1e96e4a..8c7e9f1d50d7 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; @@ -2077,16 +2069,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 Wed Mar 10 21:10: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: 12129413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A74DC433DB for ; Wed, 10 Mar 2021 21:14:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 894C164ED6 for ; Wed, 10 Mar 2021 21:14:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 894C164ED6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UBR8HZJLX411WVaMk1uTcralPOB2ftHNxyWKwNRf+vY=; b=YKPfVgpePnCqTA0r8QeYU2BAp urUcHhV/LYboylysTjrLx3Y5FnCrmJJdIamNdGA3eGF8jB44Wujjkomr0crD102EcewHPtbb+l763 ACldLjoshjBMLL8AO530oYcoMN5x5GP1Vtv8mJSlxIDb8e056bDnkQFHBHYG+sDOWgdxAvuiVGQbX p5fzFczUxne+hpktHusNJSnDJBVmWydJeHQVXwABuMMlwpsA5WDWsBcABD5qV0AcohC5FZkjpnvbA ajK/zhLGxkZXTlApJXnKQNx58i9nKYa3hIYabj7u+fAnklozcMRRUh1P21E9Hbzbn9bPxhnlar8KF qLhITZXMg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK68F-007jvs-K3; Wed, 10 Mar 2021 21:12:40 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66G-007jSF-9p for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:39 +0000 Received: by mail-pl1-x629.google.com with SMTP id d8so9104610plg.10 for ; Wed, 10 Mar 2021 13:10: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=kdHxs7JLHKePLMQLEfdUiVSo/tj85hv+zhe9KF+ZdIk=; b=qGi/D7QC5NtGmud6by8caRgcVHDoPCtR1WR3JW6Wk2O1JsLn8ZBz8UFNhPJSbvEuQr jzV4pdvy1IYWZLz7iVN3HwpNfLcY5aPd1Gj8cgy/vSUVb+MUSII1F0M0pGUGj6sB162O SH4aBT6GsWDeveC6iJv1DDuWocqvhoX8tWHdSQn+Oq91YMaqqBtOABTMWrkIi3NaTuIK MPifJ3ENBnxiO+aduNrmRuokrpKV8HBLwW3UD13AJvqZDY4jDhcopoIrxBsWCiEbRRgB Te8/+k1CxUXBYkDuHtecNWKgQX0v3so/hocDzbnm0ZpMQVWwupZVtHIm+04AX6ZcA5yE ijkw== 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=kdHxs7JLHKePLMQLEfdUiVSo/tj85hv+zhe9KF+ZdIk=; b=BzsSWjFsf8XKWerTi87esAvX0mH3SvSEIdhOW4q/ZQd/sOBFUdEQwXLvY9ySvtPdvx qZRCZCD2rg4Mpk10L2vamBskUBXbQ+bsmUFBpRGfrqF0FvpLlgTf7aXcn3ee5yNPejF/ IKsPYp6OCJZ+EiBGFoC1BcnkE61v5yELfW1j6hl1ig7Im4D4dzxgA0hqTsNMHmcXTCy6 KxI94hytEZfHRwTPVBqx9Be4Fax8OUfLwFcv0hvvCM4KU1XYVepD+D94/1mD1eGcNJvU HsQJsgSUxUfVYWp5WqfMx7itF7nxPmVtlVVUGrp0csshFsH0Kwyh90Pa4kdkYUKUra78 Oj8w== X-Gm-Message-State: AOAM532/brtxhV+u6XhadjlYp94CEqva2ejCkoSrrl22lLQr2P52pOGa XpVin+fk/dGZombJqpIojEnMOA== X-Google-Smtp-Source: ABdhPJzgGxtP8iRK0o+bNkZzJwlNJpoCTWLZB2oCuCclCQxtb/AUHjJi2ZV24broslDNR7SvDA50Cg== X-Received: by 2002:a17:902:10a:b029:e2:e8f7:2988 with SMTP id 10-20020a170902010ab02900e2e8f72988mr4683891plb.4.1615410634845; Wed, 10 Mar 2021 13:10:34 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:34 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 05/17] remoteproc: Add new get_loaded_rsc_table() to rproc_ops Date: Wed, 10 Mar 2021 14:10:13 -0700 Message-Id: <20210310211025.1084636-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211036_816272_72D0E12B X-CRM114-Status: GOOD ( 19.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 32 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 10 ++++++++ include/linux/remoteproc.h | 6 ++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8c7e9f1d50d7..bf6f6d15b1c3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1537,6 +1537,32 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } +static int rproc_set_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 (!table_ptr) { + /* Not having a resource table is acceptable */ + return 0; + } + + if (IS_ERR(table_ptr)) { + ret = PTR_ERR(table_ptr); + dev_err(dev, "can't load resource table: %d\n", ret); + return ret; + } + + 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 +1582,12 @@ static int rproc_attach(struct rproc *rproc) return ret; } + ret = rproc_set_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 Wed Mar 10 21:10: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: 12129415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56A43C433E0 for ; Wed, 10 Mar 2021 21:14:45 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23DDC64ED6 for ; Wed, 10 Mar 2021 21:14:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23DDC64ED6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bhW3NfOQH2Zlb/K+QS6SbQgtCUv9mbAEjtiHKgH+jKU=; b=nYn0Hzs31zovkZapl6IfaEAS7 bDHAcXPu5CeQt+IcGCds/0Rj9RbJ1PM3uqLVErH8jHLIn2F5hrZbepN+EP/Dwx8MDqcBbNBfptLlp d3HtfrXbb3zF+tXLwe93GEmRrFwSijYitl+ipsv1EdrBdaSh7vtP1qb0f9ckCTFjbOiKGXhyz+AKS SCkd0xyAmSgCBNNp7CbexeItcteyl42pO9ogZNca8sF8kexbcGXz9olKgkvxRpXHU+yhs4+4aPhHz 0vc2WSvZjkG4e1RiZ6NSASXE4OaitMMip0lfXm1iSAbrqIDErCgRcSFS3zgRjXJZZ2p6UlSr456tZ Ba8cP5IrA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK68j-007k4X-JQ; Wed, 10 Mar 2021 21:13:10 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66H-007jT2-SM for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:40 +0000 Received: by mail-pf1-x42b.google.com with SMTP id 16so11471886pfn.5 for ; Wed, 10 Mar 2021 13:10: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=2jJc3BSjHAcYnbTw4MOaj/dDyMsPBuKZdItUtKx3Gk4=; b=JvSBNrOwT/BnAKgKpNhlkSTYvTD2OI+O7iOuY0PtlRoYcGrlCpK4sq78krhhcEhTHp 1cXlwwm2Tewq5r7I9Lvr7/gWNpWBL/T+BMlYqJOZ9kUDjSt7haJPxI9GCZi5hmlY1COr e6EnAT9eFeTJWkkOBweGALqhJHYKwV5xTF6i1uUKNmBA+zFUFvtjRnaN9oQZQlG0Ybhh Pi/275iyR1oLXihEmAeFGoBzmVwip9cOWzV/au6f0YPCiDU8Sz4B+nzv1R3Hdadb2BPL +xs/aET2+OMEubAoXqiTTaJBRXsaui8+9D45ZCiJl52pbqjpDxlMu5lqC7/HATnnSogC yO5Q== 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=2jJc3BSjHAcYnbTw4MOaj/dDyMsPBuKZdItUtKx3Gk4=; b=IOtPQKpjp3q04WhokKm/Etrw4oz9UM9LS8BhI9vxno4jtbh0zpUwXmIFDol2L26Jjo Zyiv5gDIDp17YZSmLRas2rk9TMztEctCJ7thZT7ZHjNK13EeCqMVvIOp3ZJLhRL+heTn tnSMfAIxIKUqIzlZIgi3sHO2ZWDsbVz6ris1r24+3cum9FnDV2ZqQMAAtcmLj+6HWele mWIbdqStxBz2tiuZ82pFFezdEgG/U47usHSCoTRbgSCSnQysObA8jAJ5k49iko8P5Qj7 qATJoUKNq7NUbivfRAGmLxXT0mXV8OfMpYozr4/QJabE2dFp3AJhUCIDfVr7MetE3Gni Vq5g== X-Gm-Message-State: AOAM533EkLLmmBCcTYyA1VJf/iDISbHAf7vbGf4Ol7cyvyKDeNQyo7b8 o1oQo0I6J4RBViOxBht7jqNhZw== X-Google-Smtp-Source: ABdhPJxCjM6eNHD957QdGJx0Bo2lwSN85QoCQx+w7kVxr/ItIg+w9o6F4fB0t29XQTlebrOLyo29vw== X-Received: by 2002:a65:5843:: with SMTP id s3mr4351714pgr.425.1615410636314; Wed, 10 Mar 2021 13:10:36 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:35 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 06/17] remoteproc: stm32: Move resource table setup to rproc_ops Date: Wed, 10 Mar 2021 14:10:14 -0700 Message-Id: <20210310211025.1084636-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211038_199554_C8F1FD86 X-CRM114-Status: GOOD ( 22.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 attached to 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 Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/stm32_rproc.c | 141 +++++++++++++++---------------- 1 file changed, 68 insertions(+), 73 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index ccb3c14a0023..f647e565014b 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -546,6 +546,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, @@ -554,6 +621,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, }; @@ -695,75 +763,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; @@ -803,10 +802,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 Wed Mar 10 21:10: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: 12129417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9B04C433E0 for ; Wed, 10 Mar 2021 21:15:16 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC06064ED6 for ; Wed, 10 Mar 2021 21:15:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC06064ED6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zmJUC2U0S5O0M3VVgtGM0PhErCeXXIEyEJDxm4stzJs=; b=YPosXA+TRp8IC0dyiC9YXnnMz CrhcH6QYl3buJLnBWDsGxdfFqSw8WNQeooaNvS4OYcgaSfJOArZzeLZ7thL5WKVxJV/YO58m5JMss fElTR+UV6RDGeM/73dUEhXJ1FaKeTfVgfTpTVs0a7HNbcVY57he+lXawZP7H5qULqEstvfwq1MzGw 6GrUpzJ4OlucGB4fw9NebvbY0DZyKOupApXGBcT/8ujc342xyI5gBfOTTd8OP3Rkj/lG8oIT6Ek4Q rA2d/7WLeh4beqIrP+py5ABgiIdULDdz2rEPU3XYZUY7OMa1IYsEJpX1XKytdO+XWqyJoDMNne7/K o/O4m3G8A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK69A-007kCH-FF; Wed, 10 Mar 2021 21:13:36 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66J-007jTb-Lz for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:42 +0000 Received: by mail-pf1-x429.google.com with SMTP id l7so13012166pfd.3 for ; Wed, 10 Mar 2021 13:10: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=V6QBix4Xk7mXD3k02J6NEnaLX2tt4w4cfwoG6OuF1xs=; b=XBOQZTyM8nIn5p7W3WoJQHNoDPEeTgJoCkbMRlrhihBOKSUUsGzsltCNK+Py2hDomH g8+uigl7mIc33oR4q22Q2aH7GKjhhGcAiucwQ6CyPctgKMJi1pWVcsvITWMv9OQhO3yQ 9B3QytYl2LqUQMwUomptLoJX/1KNynNGdB80fjwIE40jAw00EuNwr15ptC2egbZp1Oo+ fIEiHW7iDqlYvQnNMXaHhdSBbPUHoTRqz2MR2YePTFi9beO1Zlf8d53wORGPPMzQfiqQ U+hUnSOgXCQGez8/KgSt2UhQ3JLs6AzP81MqQ6yxvoHEh+tDsUJxcfwuIcQxHlXb9Ydg fY+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=V6QBix4Xk7mXD3k02J6NEnaLX2tt4w4cfwoG6OuF1xs=; b=U3Q2OVtndXyLBeohikcuJxomJSLxrEU2dl9zRj2SEd1sQbX0nJrL6ZwFcId1/SLWi0 ws+r6+q2XsVl7O0dmlCpWZt8Rc74qoKqebEFOvwzzkv4LRuL2V0yEGvUzCBAC3wxhOXG +mN7YjlLjC3Oz24skbDfy45g3ZE4CEyxJHM9oEOr/p66GSs6cvOIQbq7L/qIPi/k8mDX swxxPXbVRWMVuQYMSPNtQu7/TYMZWBnaStOrj5w2g4+HTEUmHgmA2UnZlZEntSJbw7O1 6oRpg6jjX9mivxwEMYaJheL8ID2BYyvKMvE1y4VDizysXX+ddGHm0N8JNUtu7JHFYb/G eMHw== X-Gm-Message-State: AOAM530vRKraHAJg+QP+KXX2qo5/bwjUzQYQg93lySfHRDIV8pnBP7H+ cbpcKvFJCs5sMFMpWKudxdYLHQ== X-Google-Smtp-Source: ABdhPJyAmEf/XfKnz3Gi0cec4cMSa5Bn9jpe1V+O6/dEF3XnsTcW6GJw8Q3ptmnrIEmEeCGclKBf0A== X-Received: by 2002:a63:4513:: with SMTP id s19mr4246505pga.229.1615410637808; Wed, 10 Mar 2021 13:10:37 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:37 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 07/17] remoteproc: stm32: Move memory parsing to rproc_ops Date: Wed, 10 Mar 2021 14:10:15 -0700 Message-Id: <20210310211025.1084636-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211039_906096_358E0A7F X-CRM114-Status: GOOD ( 18.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index bf6f6d15b1c3..1d8bb588d996 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1582,10 +1582,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_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 */ @@ -1602,7 +1609,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 */ @@ -1621,6 +1628,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 f647e565014b..3d45f51de4d0 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) @@ -614,6 +603,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, @@ -796,14 +786,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 Wed Mar 10 21:10: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: 12129419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0700FC433DB for ; Wed, 10 Mar 2021 21:15:55 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 533E464FC9 for ; Wed, 10 Mar 2021 21:15:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 533E464FC9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CzMzcgDaUMkUJnLc49ucteeFquGTfjxd5Xux9YG6up4=; b=TSSuKSPK8lVLFjHrb12x/b3yp wdQSsnqgLWHKKJ8ADWG9yjQNQdCGOmLdBd7iZdpbuG0LGFjVdCvP8InTC/j/VXxxUaEag7yINWNcz ZvKQu/wk5umB3L16Va5I6dxAspwPY3IB+GEA2qG0D/R69Gu/Pv8U9n2DLva0FPt/BWYLQ4WqhUunQ EWpZjGAifT14/x5js877RRGdO833eJoFKbqhEtyY+2qXqc6co6s4wALe7rAs8R6NjXa3GMFxAqtlC EVxh2IcRrWy6FN+3ZhgrnUZRggJMqHpWz/o2bDV5sT6Tp0y0d3/go719AyW9dKQvPQWFdhH/Bi8Ls SE6npX+5g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK69i-007kLY-GX; Wed, 10 Mar 2021 21:14:11 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66K-007jTj-SF for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:44 +0000 Received: by mail-pf1-x430.google.com with SMTP id x7so9542552pfi.7 for ; Wed, 10 Mar 2021 13:10: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=XYqKe5JHKTsf6qqgvmLT8SEOr6JSbsFQUrC6la75+Tk=; b=QN2KSeHTMIJVqStmupfWoNju+6b6lOBn7SeIpMOv7ikOVNn+APCCBDhoTdRY4ayYYa DptUaojNxDDqkPdyGwyoMDGjz8G//29zZ8+77VxB0lMNsAwpaK1Uc8xYwG7rasPF5M8+ qgL8IEYDPr3MgBl67MFqc6OHDjwO3uNRTituyHBHXX4jkZqdKnRnOpPkahGQp5/KW5Ml pHqZZhPKTuSjgNuhsmR5IzkA3tWw+kWOQA8768qsOYsSxdZH6ddNekUAxGYO5ATssmJb AIx5lNqpjNNxpKs03apoKVWtQGx2ezRAlySvHwEUTQZW3x3WPw+tKzBIJpF5HOBmydCv JhqQ== 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=lq5od4LALcHoatRu2bA6GdAgsE1MZl7inrelWnrSM18fA+K7l0RHk2gY8U2eqnnbt8 BdbiUSXyLhFGfCRobzwdd+TmZe+x3vq9YR4lDg7K3hK62ESkXtDTltXxd4xlF3QPIEoj rozbqNw799Pw21KdynodPB3BnpRufpMPLa/3cpxH9BuYfnxPcc1kRz4FeH6kyDZbcqq5 AHo2WEaEN3qy3cvCIU13hVetMXdAA27Znbq10DmXALWK99OXfxCNOLdGOd88ZpI19UsG g3MyXgbnWmp8BLuiF3K+LzPQIDRn21S4Lu0aFLgLOBCeBzAA9hNa6CuCoaqGglYcpuAT sg+Q== X-Gm-Message-State: AOAM531zL4ni4GuT04BWag7Kx9zAn6VpWFBVuSZjRLz53UUA0mnskQpo Tfv8Q7YZkotXZqxkRcXhzLBWyw== X-Google-Smtp-Source: ABdhPJxaedrB6VtJPtWrf+nVKEW4VUlYYGPU1Tty49X6jvAbuncswZMdOLZz5f7TNwJmX+0J7LY77Q== X-Received: by 2002:a65:584d:: with SMTP id s13mr4406136pgr.226.1615410639176; Wed, 10 Mar 2021 13:10:39 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:38 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 08/17] remoteproc: Add new detach() remoteproc operation Date: Wed, 10 Mar 2021 14:10:16 -0700 Message-Id: <20210310211025.1084636-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211041_471725_C612652A X-CRM114-Status: GOOD ( 13.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add an new detach() operation in order to support scenarios where the remoteproc core is going away but the remote processor is kept operating. This could be the case when the system is rebooted or when the platform driver is removed. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- include/linux/remoteproc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 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 Wed Mar 10 21:10: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: 12129421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BE4CC433E0 for ; Wed, 10 Mar 2021 21:16:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0677264FC8 for ; Wed, 10 Mar 2021 21:16:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0677264FC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=avZ34Byj/Yb5p0qm1xft+/Dh5BubYRaiabqGlelUpZs=; b=GNTD6bJftvj1WhqfDwp3Y0V9I Ed8bAUCN/7XdFApyPWrCdoQq8u5OOCn+AnGSHPaEMDB8YgSUnd1/34FI8zI955ki7qZhADvJZWSnL tRRro98T/jaQZRCKKM6LdukbYpAOjL0o3l6f13N3Pab1vA+ergTseUxWNfUoIxfDiIBePvQE+Qf1w 7g+AxCm9p7Jph3nhItCWtQ3czmeyHa8mshiYiVY0H56MNYEwA7SOL5bBc1Co6tWx5obzF6cN/ZlcQ 2zEqLpSCR1z4XlgdWhudQ9wlFcnviTQJqc8O44548Z3hAI5YFfW/aUuAoC29EtQXhn476XyOARhht VLGgn9F0Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6AF-007kWT-Ec; Wed, 10 Mar 2021 21:14:43 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66L-007jUB-Uv for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:45 +0000 Received: by mail-pj1-x1034.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so7941906pjc.2 for ; Wed, 10 Mar 2021 13:10: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=s41xNBSRWZdaT0/t4ukszEcW0OmYZRiq0VgJP9qHLTU=; b=TgPGKRgw0zWN4PXFvgXUQdU/40S0Ks7n4+rq6pW2M7PAP54UcKXhtM9IK017DB7lJ+ lBKbGwmoL2Uh2AxpL4Qn6iDoP2Ns0sTlc68d6lNGpzyjscr92FTLPtO8NrUmNZdkneFm wZaSlkOdKc1Aeg1dVwiACHbJNKqZmG5VnhHU+DnLNb62yY19snHuKaer3wwpiZSXuDdB rUnn4pyfOZf3HXFrGsLNY2ETsL5RijY/nE03gUl9EceNokxuTF6KEjHsj1zxxwDEaCZI sQY8I2VUxRafnh/pWps0EAbJWJ2jmBai4maDQwsLgeLHgcKi1SxFRNGS46AQAT0YWy/D 1ppw== 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=s41xNBSRWZdaT0/t4ukszEcW0OmYZRiq0VgJP9qHLTU=; b=AQi24KWEPtQPKUTo7J7m+IH6Zyz3bNXur9s2zFVCUMuC22H0cXDNjGk05hDjuKHCUN 6RT7pI9jbi64YglqoP37JV2iXhC4KYkW1gH25s+CCa2ForaDy5v+E2ARf7umkJvtf7Dy AtAZKeBD2qUIb0CPwgQto1YpZUaQx4DlD/nA/Qp9zCuyTNOLCx1Zn2VI74ocT6gdM1MQ brViPWB3BHTX9HqOZ45yODnUqhbDoMMK4PJHs2PoNdvp+FRvPnJgBc3XJPltoUum8VIJ sfI5oCI8vPiUi/aOaIhiTvgkQL9oFqsqQ5Kznx8ulumBh+RyLNrzVL4fyHQA+2ipeaKd DObg== X-Gm-Message-State: AOAM533pLhyq4LLDplP8/NGkRLsoKa+umhnjnPFVsr6N86XJ1nJxwr6G 3sAkKrV37CQ8qjxw3Qw+Wyejeg== X-Google-Smtp-Source: ABdhPJzVvblpqjI4h3tFnIATpn4Ats2D5h27o5cadIXa8bZv8udB1lR2xUlayBSrRlH4G9DjpXiwng== X-Received: by 2002:a17:90a:db01:: with SMTP id g1mr5481659pjv.127.1615410640454; Wed, 10 Mar 2021 13:10:40 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:39 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 09/17] remoteproc: Introduce function __rproc_detach() Date: Wed, 10 Mar 2021 14:10:17 -0700 Message-Id: <20210310211025.1084636-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211042_947505_32AA03D8 X-CRM114-Status: GOOD ( 15.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1d8bb588d996..f2a005eadfd5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1706,6 +1706,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 Wed Mar 10 21:10: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: 12129437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18622C433DB for ; Wed, 10 Mar 2021 21:17:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C295F64FCD for ; Wed, 10 Mar 2021 21:17:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C295F64FCD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=19It5UXB5ES/nrchBHADY3LIwg27qNYZ7omc3OBBtCI=; b=gHA8plXGPGBKd/Z0bqybrjrzg HW+3psrEIo1Evyhn3w01XpX04MyGOFRLpiG/6KbsAA1a7uISbGgPlUTjRVY6lV94WW1NGWLrqawpX GViMw1YnoSd5mRINAtv/jEHF1yw2RWNAf0wnRcUGnWfH+MBc+zC63S5Pfk5np+XSKIRGCcnr5wYCn xDqKu5Rh1XKxL2un4tdiVwlcI/3knTZrCI6TQUiBVTQwP+imA9jtlP4jSJod2JRPtYO5M/nJ7DIze uND3nWENz8sDr00pBdbzNkVBHIFlwzmPWM/9r1xEKo9pXSjor3bH1jncYD1c7nNsU2jlFHHi2gDYe aO735RX6w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6Ao-007khB-2W; Wed, 10 Mar 2021 21:15:18 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66N-007jUW-CF for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:47 +0000 Received: by mail-pl1-x62d.google.com with SMTP id c16so9136823ply.0 for ; Wed, 10 Mar 2021 13:10: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=WeMR2UtisGi6ZgniJxY2/huWWVqD2xtcqc6NMb4K8/0=; b=EBsvFLZQ6NnKS4jNzcTvZGULi3PGsqemoQp4ljvj8URM3uXP2TsOBwZPGWo71Jy6KS zfGni3MATLFQwbV5ozGEQ6cXWjA1bw09Sgit2MW0zikQrB//1Tt+KqGNwKlNtzrD4Lqe 4cx6cFQeUcindtmbc5WIn6pzzByBEKzLQalh+RPsnS0X89eya1hoBzG9hpk7UvHkPlbC 38iZqeu7I/IZEdF8DvtRsKdG7xS5LyffumFqp+aB3kg9dYnhm3CN6Fbr9TGOqOXHuA7F lXTEOMs+LvGJt4YZ4UYcD4ZX5CXHSCcnjGlhN69S9WQiCgV2UrcOR5+dRUPzo+b24BvI MRBA== 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=WeMR2UtisGi6ZgniJxY2/huWWVqD2xtcqc6NMb4K8/0=; b=gt31HvrTzCe4AM6PjbMXOgwUK4bpRSUjckcMjCSHk5+O+LP0UuYuCWic39vRT/ibB6 WwSGgv7id//wUCSVaywWZ0vMd8ShgW1NXCZkxMtP52nEkUhXaUHPjomjg/6Q1uN6UuON jfiElAexFxLLrALd0bW04m9uWz5rxkOW8XwXI9FPezo78Ef4iOCK3On6TtLA1jWgHghu ZPKbqwRliqonunbY5aXOaVgFEbeoH6L3A4atyiq+rI5726VvROd0C4gPSkOdp1N7iF74 SuB7fBs+IBxJbVrVIX4LfyY3nxEwGLqWbChDHAm+eQI7NzOeB0n0Uc9jJFnskDc0B62z 4zeg== X-Gm-Message-State: AOAM5308J3Tc26yM11pBeDGR6IBb6O/JGGqAFgumf1wzQS1YO6AN4lOC nhP0ZXOLsSjBnLDP8brC2H7Olw== X-Google-Smtp-Source: ABdhPJzq/rmanro2vntRy8ql8AqTUxkiU4CGYqHtOeENyBNAEbD34Tm2CqKNwh4+K3Qb1c1I4E9CaA== X-Received: by 2002:a17:90b:1202:: with SMTP id gl2mr5386326pjb.121.1615410641867; Wed, 10 Mar 2021 13:10:41 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:41 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 10/17] remoteproc: Introduce function rproc_detach() Date: Wed, 10 Mar 2021 14:10:18 -0700 Message-Id: <20210310211025.1084636-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211043_779520_5E52DAF9 X-CRM114-Status: GOOD ( 19.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce function rproc_detach() to enable the remoteproc core to release the resources associated with a remote processor without stopping its operation. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 58 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 1 + 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f2a005eadfd5..5eaa47c3ba92 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1709,7 +1709,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; @@ -1948,6 +1948,62 @@ 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 the remote proc is still needed, bail out */ + if (!atomic_dec_and_test(&rproc->power)) { + ret = 0; + 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); + + 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 Wed Mar 10 21:10: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: 12129439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36250C433DB for ; Wed, 10 Mar 2021 21:17:54 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5327064FCD for ; Wed, 10 Mar 2021 21:17:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5327064FCD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6kI31Mi0He0uHQU20uZH8JvbyYvPEvCha3JOiipX7u0=; b=f2DoG+0sVijR2Bgm6iW51mLqv i15Kjcw78/gV4JZ2sdBIfnJ2uwtXq8c4aa0wMONq4ogew/7SiMbZvytybjFMHgOo0pi2XfTwMBfCy UUPxRWzdTZiASBdidiMhg0LXvhpC1HaBRA1/1/rLuRzoaZop6MJ8YiOv7LhfaJoRp7G8NQdrklXJ+ f83O+OPdNr1RRwq++CNLDiw/tP8jmug/R7Hl9/TcIdDFxqF5BscDKkoFYKZlTbemMvUAag4dKGlcV aW1GqmhS9pn3a/lcB5lDADdmMT8MWWWRKlr2adXhLmMHWG8lPGneduehjR7EDIUMu6nzhNUk2AnEo jj5D7BUmQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6BM-007ksY-S3; Wed, 10 Mar 2021 21:15:53 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66P-007jVE-3n for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:50 +0000 Received: by mail-pj1-x102d.google.com with SMTP id q6-20020a17090a4306b02900c42a012202so8203653pjg.5 for ; Wed, 10 Mar 2021 13:10: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=NgkcddZSW1dB4vPCVOhwPlo4SCp68OIJoV00vCCYdd8=; b=CGxpuji4f0tpmJ5rlyPbf44gVJKvkmK0ivXehl4MCnWBRFTgmgkBbCGGxjO4+0z5Yv 0ynIAWfxSLM6asZxW9iLdx52OvWpnWBvHGiYIO3EbXRsXWFl8s1moHNTUmzL1id/uKwT wnaQkNpj03SVoF1N+fJ2Is8ElJYvQOIQHaKVH0Sp9ZRX2WTZwNH7te3IP13YBbDepFZK AzrK57ZikRP3h2d0/jS2SevbAmGnsmPZ/7WDzgldIw5C6HmzNuQkhkD7vHEpvFOGCZZj UGUapIU9NVEanhfe3PybaqcpyXtsUKbY1RvjqR8pNVSHcp/ndwcgGV8kw0CKYsgGYoZN 3Lew== 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=NgkcddZSW1dB4vPCVOhwPlo4SCp68OIJoV00vCCYdd8=; b=roAoeFQ/RKYdn7CFH6qr3wXUiZVhEeRb+vgyFKZhrpfR5BZnkNC2Y2/e8pznIfqpgg IqQY0MC57Dmx5LvViTjORpAbZDTq5XeGKRwLpF3PZRPkkODCxMMpa1gz1trYKJLI2E/n 0CN87OPfyh0wkwGekyDHRYKh+fs5c2lHsHTSrCfDdvo0oLo9qot7QYrMOj5I0W678ReC i7nXwBq0GHuGB9Y5FDVGhCQqLJbESoYWjaE5QliQJkjoid3eV4xdognJIHGH1psNt5RQ hptxjKV6YmB/dg0W93m4Psny1zPRL5nXd4EQ3xL/D05ncYn93mySyf9eNmLlq/3uSaif g6PQ== X-Gm-Message-State: AOAM532X6Qe75yi5D27dRw+lzxllVNDjPPnvR4sj/10yuwLPIugEt4Q8 CObM2eccdHS7sNmiPc624wAL7Q== X-Google-Smtp-Source: ABdhPJynKboIvbEIHwRWNjhMeBPiO5bDz8TYUQ4wPgPG0Nv5WvxMh9gXqNml1fe6rFyrYBm+FNKr4w== X-Received: by 2002:a17:90a:4604:: with SMTP id w4mr5414724pjg.56.1615410643311; Wed, 10 Mar 2021 13:10:43 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:42 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching Date: Wed, 10 Mar 2021 14:10:19 -0700 Message-Id: <20210310211025.1084636-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211046_991411_A8826045 X-CRM114-Status: GOOD ( 25.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- New for V7: New Patch, used to be part of 11/16 in V6. --- drivers/remoteproc/remoteproc_core.c | 77 ++++++++++++++++++++++++++++ include/linux/remoteproc.h | 3 ++ 2 files changed, 80 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5eaa47c3ba92..e9ea2558432d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1556,6 +1556,24 @@ static int rproc_set_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 + * + * Free'd in rproc_reset_rsc_table_on_detach() and + * rproc_reset_rsc_table_on_stop(). + */ + if (rproc->ops->detach) { + rproc->clean_table = kmemdup(table_ptr, table_sz, GFP_KERNEL); + if (!rproc->clean_table) + return -ENOMEM; + } else { + rproc->clean_table = NULL; + } + rproc->cached_table = NULL; rproc->table_ptr = table_ptr; rproc->table_sz = table_sz; @@ -1563,6 +1581,59 @@ static int rproc_set_rsc_table(struct rproc *rproc) return 0; } +static int rproc_reset_rsc_table_on_detach(struct rproc *rproc) +{ + struct resource_table *table_ptr; + + /* A resource table was never retrieved, nothing to do here */ + if (!rproc->table_ptr) + return 0; + + /* + * If we made it to this point a clean_table _must_ have been + * allocated in rproc_set_rsc_table(). If one isn't present + * something went really wrong and we must complain. + */ + if (WARN_ON(!rproc->clean_table)) + return -EINVAL; + + /* Remember where the external entity installed the resource table */ + table_ptr = rproc->table_ptr; + + /* + * If we made it here the remote processor was started by another + * entity and a cache table doesn't exist. As such make a copy of + * the resource table currently used by the remote processor and + * use that for the rest of the shutdown process. The memory + * allocated here is free'd in rproc_detach(). + */ + rproc->cached_table = kmemdup(rproc->table_ptr, + rproc->table_sz, GFP_KERNEL); + if (!rproc->cached_table) + return -ENOMEM; + + /* + * Use a copy of the resource table for the remainder of the + * shutdown process. + */ + rproc->table_ptr = rproc->cached_table; + + /* + * Reset the memory area where the firmware loaded the resource table + * to its original value. That way when we re-attach the remote + * processor the resource table is clean and ready to be used again. + */ + memcpy(table_ptr, rproc->clean_table, rproc->table_sz); + + /* + * The clean resource table is no longer needed. Allocated in + * rproc_set_rsc_table(). + */ + kfree(rproc->clean_table); + + return 0; +} + /* * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. @@ -1721,6 +1792,9 @@ static int __rproc_detach(struct rproc *rproc) /* Stop any subdevices for the remote processor */ rproc_stop_subdevices(rproc, false); + /* the installed resource table is no longer accessible */ + ret = rproc_reset_rsc_table_on_detach(rproc); + /* Tell the remote processor the core isn't available anymore */ ret = rproc->ops->detach(rproc); if (ret) { @@ -1997,6 +2071,9 @@ int rproc_detach(struct rproc *rproc) rproc_disable_iommu(rproc); + /* Free the copy of the resource table */ + kfree(rproc->cached_table); + rproc->cached_table = NULL; rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); 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 Wed Mar 10 21:10: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: 12129443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 340F9C433E0 for ; Wed, 10 Mar 2021 21:18:58 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 277B664FCD for ; Wed, 10 Mar 2021 21:18:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 277B664FCD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F6rzAsSNofjSFa5B6+tx6Br66htW9XOMqGW2J041sEI=; b=e4g2ktriIXfu3TNdSmg9GngOF 004+dVjb4y5TP5UmIs1Ro5MWyAH0FJDklmONiHtOrGfrN3zAKjsxLkOhc/t0525MqPaLpO0VFUZPr 6EJHo070xzCOp8i9aM1uLAHMnR+dAa/xQSfOrUKG375U1wh8IcrSWykNjXv+WHEj1PIoFEo3+CqaX Jrd/qmPAR3nWuZfmUapo0yk+t0QXpsvTE36h5bION47TE2k/67n4K5oEtBttES2Hg7SNYgVMrUjA1 1DBwqRGkqvwUFT59k0U5P2DmdhVJY34rm23qZXEKSkEp+HDExsg92kWaCMGH/xVd/5MZth7NwPhHc 4rccYwIWQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6CU-007lCI-GV; Wed, 10 Mar 2021 21:17:02 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66Q-007jVP-IE for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:53 +0000 Received: by mail-pg1-x530.google.com with SMTP id t26so12225036pgv.3 for ; Wed, 10 Mar 2021 13:10: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=1QQx7Pxxx+mjFZmngOFSgRWs39Wy/KkcCLmt4JFXcYU=; b=pbQ1RvOYSS9mMpaaqnGD602f1QyLBUTtYQ0Ud9mDz5HuiMsfCp8L6gW2bdhfR1FmhR 3oJlrbAduJI6RUlrT/YbHj4gilA7BS2Pb3SyTV8Y5zZuOqTiUBIrOyy29TFVl0BiPSV4 SNjRb0LX0dbl5pK+TWjdyBlfAYFppZYdy6iqQ/WVLlfZ5lwWywjgGgYdRcOd1QEiQTvV vD1K+TYfX9eK3v2fq9bTw/wnHByPMgKvmQDjzdXD6gTpHwwYwM4VLlpbQEvgk9vARfCR PtrRFD3dk+uxySXXd6ATSWKoGJL0HuwSJAS8FQ4trXCKiEUKwvl9htfR/XxMFiDOL4Hk DmNw== 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=1QQx7Pxxx+mjFZmngOFSgRWs39Wy/KkcCLmt4JFXcYU=; b=je31iAyDEba802GVQgK0ISAATSURKas0OP6NcUsa8BuZW7tlq6L+VEwhJS/qw97UEN cEQ650pWhSv+2HhsH7F4tG9JUKIPVmAwzSg772onfW5MMtAPIqxsn9q42kCzy4bzYJC9 U/kqV5GGGUKJdMnwyaBlLaSUVdlruCcg2QGyPCwpLrJgAZki8JiFDkZv+9MCLHRUdugJ 0FXJroJuEptLwzAfpmR2mjdF0qp4j9IOUk/YDr+mojBz2eCNshAlW07wPQ+Wb/WuXpRv u+u3np9//5GIT6z+Jo86ikOAlLQLVELpKVT4zjf9/BpTFm/s+hAAbv79O9tZdiqcDpjc KUNA== X-Gm-Message-State: AOAM532t6nSH/kk/ruAmJyd380vhDsKDeczZUTJiOYISJtRoiGB1Bkoy /8y9UJlMc8CodLsMLw2yjwG/vA== X-Google-Smtp-Source: ABdhPJzcnnEP/9C1ajt0OE4dPZUc+dynza0TgDIouMzYm24qatT8Y5KboL+6ejQrLMYrWp2BW5rLEg== X-Received: by 2002:a62:7ac3:0:b029:1f1:5d13:5ec6 with SMTP id v186-20020a627ac30000b02901f15d135ec6mr4671519pfc.14.1615410644837; Wed, 10 Mar 2021 13:10:44 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:44 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Date: Wed, 10 Mar 2021 14:10:20 -0700 Message-Id: <20210310211025.1084636-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211048_311916_9003A9DE X-CRM114-Status: GOOD ( 20.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When a remote processor that was attached to is stopped, special care must be taken to make sure the shutdown process is similar to what it would be had it been started by the remoteproc core. This patch takes care of that by making a copy of the resource table currently used by the remote processor. From that point on the copy is used, as if the remote processor had been started by the remoteproc core. Signed-off-by: Mathieu Poirier Reported-by: kernel test robot Reviewed-by: Arnaud Pouliquen --- New for V7: New Patch, used to be part of 11/16 in V6. --- drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e9ea2558432d..c488b1aa6119 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1634,6 +1634,52 @@ static int rproc_reset_rsc_table_on_detach(struct rproc *rproc) return 0; } +static int rproc_reset_rsc_table_on_stop(struct rproc *rproc) +{ + struct resource_table *table_ptr; + + /* A resource table was never retrieved, nothing to do here */ + if (!rproc->table_ptr) + return 0; + + /* + * If a cache table exists the remote processor was started by + * the remoteproc core. That cache table should be used for + * the rest of the shutdown process. + */ + if (rproc->cached_table) + goto out; + + /* Remember where the external entity installed the resource table */ + table_ptr = rproc->table_ptr; + + /* + * If we made it here the remote processor was started by another + * entity and a cache table doesn't exist. As such make a copy of + * the resource table currently used by the remote processor and + * use that for the rest of the shutdown process. The memory + * allocated here is free'd in rproc_shutdown(). + */ + rproc->cached_table = kmemdup(rproc->table_ptr, + rproc->table_sz, GFP_KERNEL); + if (!rproc->cached_table) + return -ENOMEM; + + /* + * Since the remote processor is being switched off the clean table + * won't be needed. Allocated in rproc_set_rsc_table(). + */ + kfree(rproc->clean_table); + +out: + /* + * Use a copy of the resource table for the remainder of the + * shutdown process. + */ + 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. @@ -1759,7 +1805,12 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc_stop_subdevices(rproc, crashed); /* the installed resource table is no longer accessible */ - rproc->table_ptr = rproc->cached_table; + ret = rproc_reset_rsc_table_on_stop(rproc); + if (ret) { + dev_err(dev, "can't reset resource table: %d\n", ret); + return ret; + } + /* power off the remote processor */ ret = rproc->ops->stop(rproc); From patchwork Wed Mar 10 21:10: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: 12129441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49EF7C433E0 for ; Wed, 10 Mar 2021 21:18:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 157FA64FCD for ; Wed, 10 Mar 2021 21:18:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 157FA64FCD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9us9mm1ePTuGgBWm6mjnlWc9/JfU+DVvx3EY7Pe9MaE=; b=R7wuT+G9JkBTa8fpyA/BBNbzc JwDobt6/JLSU33/aFqjJj9ZV3dNZ7zasuzpcK5cAGkMdy/izztOqRyA14khwQDIObqH4V0/t80pNT B1L6ZImb9FCOFMi2VvghdVwK0a/VFfjChhApqS9UD4WPIu92s3FEzk90CZ0eS+v49lg48PxY9Oy9O szj1WTcJmwINifS61Giz2YRTm/hI7mUiUv3pbLh4Pjffgj2B+1EoLFQoeM44ohckewCxC8MHzoqJY 6i245Z/H9cUO8R+aCECXvi2Nm/nj8slpC0yyislq4wF9ZpfzP8TTXWWFoVo65zw9ZGMBsgAyK+Byy NrPRF2Rbw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6Bt-007l29-7Q; Wed, 10 Mar 2021 21:16:25 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66R-007jVc-Vm for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:52 +0000 Received: by mail-pj1-x1031.google.com with SMTP id a22-20020a17090aa516b02900c1215e9b33so7936402pjq.5 for ; Wed, 10 Mar 2021 13:10:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=//t8ceQV9F1IbLzcb1N9QjBaVQNk+K1abKjB3CMSp5E=; b=rfkm0nJEZoMdLtilTXPgnGadhHuTtG+vM1fymP6gqGdeCnlKc4F3KB3Uaq/4o3K8Cj ZbaN+Ybje2iSv1GM27/q82Hn5SvEDzItHSyb+kYTu3LNsulPhcXzLF8IbMQU6oNEF/iu MHnF625jXIXo225Nhk2Sxzxb+v7XZFpIAjZkW0mPrhJJmmdtRblLANQC8+1TlbXuB9QQ Gk9OKYl5UgQWNKLC7vouDjdEgoSgeJaWR5hHGu81uIrXlhXaNmaKc9C45M8dT5cnJagu qa0+ylB5RwENeF6kWFLCSSgbJeUTBQK2LKrqLl/gwb1h/Xtpx6f1q0SPjmDGDEY5WV7t H3Mw== 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=//t8ceQV9F1IbLzcb1N9QjBaVQNk+K1abKjB3CMSp5E=; b=rwu3BaaQagBSSyQI7uEB6aHW5uczXXDdXnDdiHNzUtcYh508AQ6hxqWJwGW6nfSeYZ kMXfZtTA3uk/6+pAMUBUaROL+Ljke36DgUfbj/PP4EL6oLpwPQLVZ/HIPl83YI5dBh3K YPEjCVFePA9dU1BpGA7zA6BU6QyfDg1CUiFPWU6RlG7A5hSF1elhn8R6w1sQj4LyoLO3 bk0qSfSzXwwUByWZbVmY1vIkEnKkUjzB/H8Kc49oC4qlrluRAEAYfFKPwuQI7rj2gOi3 E//IVbSNb1np6E/eggHB5TlB1sC0SAQrRl1LRVu9Ph4xQmylk85yOl3tZRUsja/Y0nzj OJkw== X-Gm-Message-State: AOAM5308DjhOrjmYnFw6TpY4sgueGcuss6MUx2Si+/VL5Ci/7GGzWY9H 91SEFsQfOiyxSjL/SEU9BMk2Lw== X-Google-Smtp-Source: ABdhPJztCx1IRaiY8WWUM/s+nmMh+Th74pFv36zfIr1uIduR9+Qdsma6eynemzXDr+wNoGlEZmYNwg== X-Received: by 2002:a17:90a:86c9:: with SMTP id y9mr5427957pjv.205.1615410646372; Wed, 10 Mar 2021 13:10:46 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:45 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 13/17] remoteproc: Properly deal with a kernel panic when attached Date: Wed, 10 Mar 2021 14:10:21 -0700 Message-Id: <20210310211025.1084636-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211048_462802_366B21C8 X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The panic handler operation of registered remote processors should also be called when remote processors have been attached to. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c488b1aa6119..f6f0813dade5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2728,7 +2728,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 Wed Mar 10 21:10: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: 12129445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CF14C433DB for ; Wed, 10 Mar 2021 21:19:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A748364FCD for ; Wed, 10 Mar 2021 21:19:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A748364FCD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3DOR/bvveCPvpzhMTPu4C2uEPVXRKwPmdV2q56XiT7o=; b=O9vvunfDox+CBPnpspPlv7/2m vhZh1CL+Nb40x9WcyTlcD+qcpVMGBbM85icJusuRZT5UCLHSmczQjnmTqkvz36pDlaXMw0jc9JGnk ZkxQn9HUEoCs6jkRIonlB4TW1u+yLwciBv3qB1qZKlgQR7Nxqlmxs3S2SL4ismhNRLrcl78GKTDHI 5Ue582YsEY37WIWXA9L+h9q0dBMU1TS2tHgwMqN83ZIBRjZyqaeizXwHYHisgLtsxYYAfbZdgLIXR Psq+ofTN904NT4sprFMBMCCDEAiq2GYv2r/qWAq2/tNZsDVL8a0PwXjTeTfDB9O8bxLQnorL77Ybb v/sX1eTuA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6D3-007lNZ-PW; Wed, 10 Mar 2021 21:17:37 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66T-007jWP-7C for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:53 +0000 Received: by mail-pf1-x42f.google.com with SMTP id 18so12980494pfo.6 for ; Wed, 10 Mar 2021 13:10:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gj6WF/1oKuVocPkZDr0q35lcZZqhgtjB+hq21nBtWDQ=; b=DCemT085WWh7HRmlOaLcZsNEkgQDeuaeupj4twDJqjKQMYIBaQDdP4B3pYulTZxogm xKs8jVFDs0TwS2xzHbOm6tUFl8uSzVzZ2CcVDZY99hcKfe/B0jOaNGYw8Gw6O2fcMbo5 885qqJ8rL5U8VlgQAwBwBPIgP6Ez6XbRqFc1Jt2Ia40m5zvNcFI2W2SSeLsx601r05tv +/hPPYID+yt1kH6NWkR9Z4dYJhHdrOx2VOzw67BtM6ikWSlR4AdrnpovnkiAxPsWlh9T 2svoVz9KfinhKNXpxOZ0KVZmcBRVd6WhtjA6It2iFK5L43a7EIfMP/W+6cvdKYOJoP2R BV7A== 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=gj6WF/1oKuVocPkZDr0q35lcZZqhgtjB+hq21nBtWDQ=; b=DLdXk9t33hU0ke+wMgTAjDLXCMdlxNWT0b/eZGj2LQwI4Z1iDkJNqkn/TvpK02NrV/ 0bi3Bsf8P3kjymQ5gD+HMhJmMQ6md0UU3AvuQevoXN9UGa1HW/eKlknwR8XNTuGI+hsp MUlS62RZMQeq874BGo8PJ90XZ9f4r40MH30a0ujnYHZJBpMWUTyMHwBcItjibCVgWfUL m0eZHza/TVo5YhiLSgDmqkylIaW6hI/stqrDTaHcOkxU+rBPTtntDF4Tc/jRJ3Ltj3zK lUOJEBEuCAA2z2EdRpvHLK56ZOsmitrHGZgpbC5z0Y6kZ9pQ0N9cwTJcNBSNfG3Emzok 91QA== X-Gm-Message-State: AOAM533GqchPLUlEn4stI1zShsCJ7jtNIJlaZ/dd0bQ3BTFyYD3WYTwR ONo7/YFxGoWtohJ0qzEQmZWEdA== X-Google-Smtp-Source: ABdhPJwmSvQMeZv5nlUk6YGFMWVuo1FI15Bi7595b0pAlm3b0R0XMWk6pjErVCdzPlnE1EBqEBKZlQ== X-Received: by 2002:a63:531e:: with SMTP id h30mr4387018pgb.158.1615410647791; Wed, 10 Mar 2021 13:10:47 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:47 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 14/17] remoteproc: Properly deal with a start request when attached Date: Wed, 10 Mar 2021 14:10:22 -0700 Message-Id: <20210310211025.1084636-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211049_535030_77F8CE0F X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 case with the running state, the command can't be carried out if the remote processor is already in operation. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b19ea3057bde..b2cee9afb41b 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 f9694def9b54..66801e6fe5cd 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 Wed Mar 10 21:10: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: 12129447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73367C433DB for ; Wed, 10 Mar 2021 21:20:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6AA9E64FCA for ; Wed, 10 Mar 2021 21:20:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AA9E64FCA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uBnTUMya2NcM52QFgrHmqQaRf9r8XDILvkOsR3/J+gE=; b=KdJQDehXRXX3/vjO9zh5oBgXq nEFzltbko1sNnzPpd1YmuommbqhshxbTSrbmnzQs1JV9vycppFsFJpUTZIPYuGb0NEFdmXedNFLTM FNjv5+Y0z6FPzYl9Es1/IKgxFBbdM4zmkye2kjf6Pk1QDBNh2Ap+pMJUC7cFL3IbarwVM+nYrXVdt 5E6GjOLHs+ZwG0jPY8IktJs6lEKmlxWCgtR45elqgNrS2TErd5rlX6/LIkzRNIbDMUAQVl9u4HMpD wQzf+k0ymv2PlsvWbBzwFekzLgIrBbS44tvKcxD5D/xaxqZcQACdResADqEWD0ANngK5o8W7BF0lb aq81qEBzA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6Dd-007lVy-KW; Wed, 10 Mar 2021 21:18:13 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66U-007jX9-SA for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:54 +0000 Received: by mail-pj1-x102c.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so620407pjb.0 for ; Wed, 10 Mar 2021 13:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NUbHk8qwWGNZJmBhl2P7smbU6eLp7vR5JHjlqmfrEWU=; b=OpJIo3bJghziHJAhj7AXoBb2a+K141G0BdZoGZ/7MZzz2dpfMnOo2i6Muf0cvN32O3 Eu3rRRkYmRSrE8+0RitMnGpPHh3MyYFCDzqbLndfAHL3woFiBgu87NTytJdXKz3IdkSV Ah1EJsasCqPl3ajRID81RXz8NbxYI+f4TPrmZn8HAk3ihXZalq+9fKT/j+IkAj9is3+K nRgf6p4c69T8CRpe1ucPHGY6cW1XXACyHNZosYogAPfvWCXm/wNTmPysI2Fxa6TOUQHi XihBQ5WPr0mVcwoqD7KEyWVXZaBbp3t5oUsoCPpKu+2aO+eOD06YvM2EUaeuWd7l78NA rIXA== 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=NUbHk8qwWGNZJmBhl2P7smbU6eLp7vR5JHjlqmfrEWU=; b=eh9rYB0f5Z+IS+9+9F2ilxPJM8kbcQJVRH2h6NpoqNUbq8woKfi7JcxJcik+rTo/3R VwrN3PYmNkFft0GP/E409BzBSNgq0ltk+WplxlMQM1MYlpUlBPzMY+TE3qgY424YUDh4 EY/7CzFnREv7yyPhii4y+GqsuYtUQZSbV0EhdRDDss8kHAIoLnLaOqpi5pwpvk68VEYU tbTWvxE+ollTUqmteO/0vj/tBJy0fRmQHSOgXYZJ1KCq7ECJ7rl1WNNrwhxvV9SE6RTx HzGO+IBhN1H1HGwAnGPPGRgkPi58tTp9TVa8+9sCbE/ps5/wTbP9yUGdQteo7oedxWb3 Owow== X-Gm-Message-State: AOAM533cp9SP1XjITbr44r9fhEcpNMKq3K68pgrHMm5dhCWdEF3FdZxu YYN7CjUwO/y/gRUNPiEgI9Kf1A== X-Google-Smtp-Source: ABdhPJxZ8XGoEFuxacAuMUaLvjuRQGirFqHoWWOjzqKzwfTKllyZCkFZ2WZGETdJorG5/ObLa3IRpw== X-Received: by 2002:a17:90a:1463:: with SMTP id j90mr5468566pja.205.1615410649200; Wed, 10 Mar 2021 13:10:49 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:48 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 15/17] remoteproc: Properly deal with a stop request when attached Date: Wed, 10 Mar 2021 14:10:23 -0700 Message-Id: <20210310211025.1084636-16-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211051_175934_D12EE2D9 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow a remote processor that was started by another entity to be switched off by the remoteproc core. For that to happen a rproc::ops::stop() operation needs to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_core.c | 4 ++++ drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b2cee9afb41b..0249d8f6c3f8 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -38,7 +38,8 @@ 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); diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f6f0813dade5..3670b70390dd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1801,6 +1801,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); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 66801e6fe5cd..09eb700c5e7e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -202,7 +202,8 @@ 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); From patchwork Wed Mar 10 21:10: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: 12129449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17549C433DB for ; Wed, 10 Mar 2021 21:20:57 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4FC8664FCA for ; Wed, 10 Mar 2021 21:20:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FC8664FCA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pi6cYAAxHxC6xT5qapMI9sq6RTdxHgrzN+zcRrEY5ek=; b=RHBJbD2ZBBK+lEWSiZGokMhh3 IKCJfFV2WODxchcFJtC+UxCtcgM7pb192Q0ErgFmhJf62gt8wPA8a0mtuu1OyZeEvsM+Bej48QFh1 rLRV1E8JYaaIHsjZRuDBjN+N7EPHNuWYUAy6BltNgoTcrm4/NeNf0xNPBsWkVMIKkikDVEY9tsMet hq3A5ij3IJzSZ5p2wjXJgxVDdT1rzA42Kg+Hjn+kFzIsDmRwX4qJBX5QOO3eJNgxvnfPp5jMtbVxl jm1Rn/rGPmwqbovStrEndiMvLiL8BIrCJbIcgmRJFXCt71Twa1N6wH1S5Yd8aXj8Pb8rizissuTU5 FhfD0rIJQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6ED-007lfM-Rc; Wed, 10 Mar 2021 21:18:50 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66W-007jXQ-7A for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:55 +0000 Received: by mail-pf1-x42c.google.com with SMTP id j12so12865683pfj.12 for ; Wed, 10 Mar 2021 13:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NN7h66rSqKzczqrKUwACdy1DE0E9dT7gEJY334oVOV4=; b=YsAjFMkpkwep25SwkBMcSnhfdoVYmzl5QqEIPCJbSwI74cnvyGX4V5wUqrnUVokUaa Wwe0fGdh9p1WmI8zDIGi0H/2xW+uWaCGsKbpdYsHH0KuFkUC1ijJUlmk4fxphEx+69qg HTt1iNg6dk3TlCiNPQpdrB5SA98/PtH21zClh6HwbkMMgDTQK3H4LD/w9Xjtuel9L87Y wrcjU/4YeLVOjlmoYb7vCgcbhXxtXTpQlm8/kA7JA0FoWh3bqIps41ay7knAgYM7n8gK gZW8oXhs0XmuEBFUWkuoZCdNwRBivGpWiQbNUe3feoCqhkONqvUdtMWWYcxvHwXnZ6+t j3/w== 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=NN7h66rSqKzczqrKUwACdy1DE0E9dT7gEJY334oVOV4=; b=g5vNiytlOQeW24WGJigTE/Qy0RiCt8qKObw984hNbIp0nBLa+4VWCb25VKj6bKjflR SKPAGrAbXoZhtyNgRDsq2AMc+ouXY23mGAfhDtoDSTwBCZ4sACCHPSLa/z9r1dPVd+sb vinl+RdF2dcWVzpYnFYEGyndW0im53TU3OkH5qHJdL5aSD+egM6C+66zGYbErXho2A4a W5LGGrytU6CLLi8SWuL7fr5XulhVzETDDl0K6YX1YHcwkeeEBbkWgMaKIAMM/dNnjWIb TPwBVQOxQ6GlKUaxdnGnew61uB4CIOqK64Q4YO0iDyhHk12X79ZXGRdQxmUG7unKbJa8 1a5A== X-Gm-Message-State: AOAM530ulUK7jK3xelKWaoD9njHBqWShpjz7D8zS0Y9Labyq2XmpDJlU sYo0wHJ2KN0F/MA9ywXSYiME9A== X-Google-Smtp-Source: ABdhPJzs6qFZckDYQpoX8ZcZkgPLgiZxCtH5GIit2um4iAczXphI47IzrLx0Fu7OfibLOT1u5w3gIw== X-Received: by 2002:a65:4386:: with SMTP id m6mr4472767pgp.384.1615410650544; Wed, 10 Mar 2021 13:10:50 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:49 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 16/17] remoteproc: Properly deal with a detach request when attached Date: Wed, 10 Mar 2021 14:10:24 -0700 Message-Id: <20210310211025.1084636-17-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211052_613249_F6A555D6 X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch introduces the capability to detach a remote processor that has been attached to by the remoteproc core. For that to happen a rproc::ops::detach() operation needs to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 5 +++++ drivers/remoteproc/remoteproc_sysfs.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 0249d8f6c3f8..2db494816d5f 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -43,6 +43,11 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EINVAL; rproc_shutdown(rproc); + } else if (!strncmp(cmd, "detach", len)) { + if (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 09eb700c5e7e..ad3dd208024c 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -207,6 +207,11 @@ static ssize_t state_store(struct device *dev, return -EINVAL; rproc_shutdown(rproc); + } else if (sysfs_streq(buf, "detach")) { + if (rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Wed Mar 10 21:10: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: 12129451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EE6EC433E0 for ; Wed, 10 Mar 2021 21:21:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0656264FD9 for ; Wed, 10 Mar 2021 21:21:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0656264FD9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=niCHUZ8ZkG5V7Mzv01IBL8MPrBCNXBTp2hJzZjZ9fqs=; b=qKzQTiJsu/r1oCQhkgbUgNfAJ lpJyHhWBbtk1Avktpuczr4JE2fDMV/IkPz9RA13dhX9zk1XNYRpzoBwncsHfY1nWbC3gIyOlWO9d8 9/u/QQAKTyJCKEsdfvVuaJOWeU6CMWXdfM4jkO2v9YP77Sh/nqp4ljVtFkDlqqoPUilcp2RdbmlnQ oUNmPr4IaZ/NnEbP1u/RZ5jFREhpVM63NMwK/WG3OflEmmI06o8GwKZTjM4/ZHqdTEBMTaV4DEOUe hdPiujOoml/JCmnvzkWs7gyKp/X0LuCqKLrVodqv6TnN4Ua71ei0xF35+AKkptHfAvY0M1LdlRPsr bGpgdY33A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK6Ew-007lqh-Ea; Wed, 10 Mar 2021 21:19:35 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK66X-007jXp-3h for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 21:10:56 +0000 Received: by mail-pl1-x630.google.com with SMTP id ba1so9131181plb.1 for ; Wed, 10 Mar 2021 13:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BGL2ihK/psb3Syg4v822MS7bSYXQTTBjUBjeuGJcCyw=; b=Vb8k+1a9Xet0PbxpzdS19v+gh8mkgVMJGpJouQqrohu8j1rhefkJMCeyCKgo2iAkFp HGtHWaFWm000lW+mCa+MG4FwdJvucPutY370SC6gpN5cDSeZ4PGfIhRSv0PpPo/CecOM dpnQJ4+oMn6bUgrZLsRTijPoCS7bRaSvp6+tzEk1I8MgpFjSclrntDPW8UAUObZ1iVIs Z4PmsEh91nNNkPhUkri+RmFgRwJCXsFAA8K04ysQWMmd9i5j+VGYvvpELsPmxBI6oTli Hp9VoCooO8UraqRnoXzAi1NHDtmpUhFPhBOtF5mMLslvj2lmjzR64+xtR8Aatbkutl2w 9gMQ== 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=BGL2ihK/psb3Syg4v822MS7bSYXQTTBjUBjeuGJcCyw=; b=rKGgBCis31q1bKHFnognmZgjnLSNBQkVat/cJBGxTeNCSiZHqqRHaD8Wj2mK4dIXkn 3IR1WUXao9s58wAMGOyERs+CO1pLsRZGP+e6khzmKwi5O/GOYddof03tQ48DITXLVWj8 qXM0tnNGbzALvhrhOoGFkFYKKBCG62ilOa5uhgKhHAh2LiXcsULOykYZ5kIRc/ZhLNGC /T+ywFcupTm8ZXKUHjVu2j8h0CTLy3W5ltIuVSaETipwPViM+PJ2rf2LDu5A1RKq+NFL vRNxFKlrUMlzFVnHcXhDnA1wx/Qvt3mz100iCBjyEjqWvAYdYLZcFOjxuGsyG+INSgfG B23w== X-Gm-Message-State: AOAM533YxFtkmDoxhR8kScjkBT4SyKDGhWBtpxE7KxHgAoGFree5AYmW D1e4INJ5QhXLeOCFKxPyQ6oylEUawRshNg== X-Google-Smtp-Source: ABdhPJyerzZSSKv1SejSU2q89sYnoZLwH01Fg019P2oeq8CyLeDGQce8Y/7fgVFdmgxEyqqYTSgmiw== X-Received: by 2002:a17:90a:3902:: with SMTP id y2mr5532955pjb.202.1615410651845; Wed, 10 Mar 2021 13:10:51 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:51 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 17/17] remoteproc: Refactor function rproc_cdev_release() Date: Wed, 10 Mar 2021 14:10:25 -0700 Message-Id: <20210310211025.1084636-18-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_211053_575303_B0C80334 X-CRM114-Status: GOOD ( 16.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor function rproc_cdev_release() to take into account the current state of the remote processor when choosing the state to transition to. Signed-off-by: Mathieu Poirier --- New for V7: Keep the behavior of the shutdown operation in rproc_del() intact. --- drivers/remoteproc/remoteproc_cdev.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 2db494816d5f..0b8a84c04f76 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -86,11 +86,17 @@ 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 = 0; + + if (!rproc->cdev_put_on_release) + return 0; - if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING) rproc_shutdown(rproc); + else if (rproc->state == RPROC_ATTACHED) + ret = rproc_detach(rproc); - return 0; + return ret; } static const struct file_operations rproc_fops = {