From patchwork Tue Feb 23 23:35:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101075 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=-16.8 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 91D56C433DB for ; Tue, 23 Feb 2021 23:37:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5577D64FAE for ; Tue, 23 Feb 2021 23:37:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5577D64FAE 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HFPkm+ZZIuWV7HbavQ24bos7Xf2SiwyMQ1/5vkGs8/U=; b=LuxjBe4Pq3CE0cXaLJBXMrjxu M5/wU5ueTUhRN0IGsO0ZYUDyxHObDh7BhIRNtQZgWe/z1LybizbT0jHSa7tE9W2aBDXbzTI9nKVs/ lB2cM5elXDbtJSNNPNOi+lqEZ7I5s8G3+fZ4nLQuUEgH1tb0fmnJM20DK6FR9Xt7youjnpUZjVibc JoeKeL13bqNAl3uiFjIOue97hA2xrgC+jcCVK6aZRhiijVy6dyDg4ATWMtvpbfgWvVpNG3+AkBdtx JqMF+V1QeYDIBIE/4zHsZGPIvT9tVVhE/MsbLBbF4X48qf6HJpL8F1aXyFnUVQ826fWDwCm7ysVhf B/Dj6lgWg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDr-0003fE-7Z; Tue, 23 Feb 2021 23:36:07 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDF-0003US-5f for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:30 +0000 Received: by mail-pf1-x42c.google.com with SMTP id j24so65122pfi.2 for ; Tue, 23 Feb 2021 15:35:28 -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=ZQJKNkYdJD+3H3cXZ1fnXW9mmfT2GDRPmw5t76E+z4s=; b=ttJfPAO38DPwRk7QDxMpxEP4AkrTQ+bdqW821L2JbyNrPr+ztnhUsH9KLuRItEmDtw wjQCHPOaFFLXndgzQnwNsBRWQjbE7Nkv3yYhyyPiKSUF4zrOkf81EB7HH/CVMNKLReOl 40lPa9a7imYaNlA0rnzPsIxBHz9UH15WkcvPepLH//K3qI2oqRpyv+7m/k2trU8fH2hQ nCa+l/PeuYtT9ao0c9zxmD1+rbke6+GR9K6hp4Sg8uRsgpQCH/ava+wbb6iKyBePKvfY UbrZyzFTq9u9hpTsiLWuG/HWgK8cSyKRcwltNqNB6pOAUHD0w8vNeGX2ClFMu//8RtR/ V/0A== 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=ZQJKNkYdJD+3H3cXZ1fnXW9mmfT2GDRPmw5t76E+z4s=; b=s6dF+3VkajfSyUAezK/i+bd3pvj2vKtIdt8XpTl/9SwzSnPOOYiSv4QTCaovk0eihw L6dgz6luc+nfOyfcJSyNI3+NLIxW/26+s06rM/U1zzDtsz3DFVk/kv9dr7+zt7qU5VOT GjwxY9HlogD7cOqX5tvgYeKcOx7Kns7Y9ZFiPWMjmnNWQghWDC6nku9iqwHyf3QGjVAS 0a1HtU2gkynedJkTqK8Spoz1Z1dilKjrttzPAUoZFUXV1D3HKec6uaqjXQNIPgsq2ss7 cGdrCt5feQnItlC5jXh17QLdTYjutOZ2lhTx6iCx4iLLDtQ/vIfJi2hs7WPKLRmeV3UW 5cAQ== X-Gm-Message-State: AOAM5331sIztnMMjctR6TlYawNGSUeJiAWHcr2I190vP9/WA1iQoHbqV jVYyD7gKI9L8TWchhKKt9Zu9MA== X-Google-Smtp-Source: ABdhPJyEhqRX/KZWWyw75LLa3g9cesvmVpn7ESbIlO+bDp+Sw/fJGi8whC21vuhA6iI2rCtr8TkLzg== X-Received: by 2002:a05:6a00:9d:b029:1ed:c1d6:5042 with SMTP id c29-20020a056a00009db02901edc1d65042mr8009649pfj.71.1614123327093; Tue, 23 Feb 2021 15:35:27 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c24sm311999pfd.11.2021.02.23.15.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:26 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 09/16] remoteproc: Introduce function __rproc_detach() Date: Tue, 23 Feb 2021 16:35:08 -0700 Message-Id: <20210223233515.3468677-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210223233515.3468677-1-mathieu.poirier@linaro.org> References: <20210223233515.3468677-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-20210223_183529_280380_01BB8184 X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org 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 86572880c726..0f680b7ff8f1 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