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