Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp157737pxb; Tue, 23 Feb 2021 21:34:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkR05v0Odl5qQu8LDdlje8zi2R3wqKFzQJewqiy9VL7iiljDr+bwkEvkpTCiiu9y8jmLbN X-Received: by 2002:a17:907:9688:: with SMTP id hd8mr28604830ejc.528.1614144883412; Tue, 23 Feb 2021 21:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614144883; cv=none; d=google.com; s=arc-20160816; b=B/qG8EQrH51M2kZh5DKx5VFh9wJZg/B0qjgMIdltzhFrKy1Y0KFrrkUxKQrDgnHW73 06VzWfhx9Xa36GfEF+01fNVU07H4rnyil9Ql57SqexwVlegAPBNuWIVBuXg2AYgdhwbg 2IbxkggibodM6p7Hm+qOObU3yVUm9zVhOUwt2+wI/031z26FGJLCrbETEruACvXsL6ZR uN5XA+vW4TfCjN9Bz615Viod3cgYylCMon/CFrsXDG1YaKwL8DOCkdbHZtjwEEE4CEX4 wAan9GLf3+Y9Ua3RVwtzDlqobpjOUg3S70slKvMIz06Q8cppPLeJjBJqC3z2tZcOSisJ MvmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZQJKNkYdJD+3H3cXZ1fnXW9mmfT2GDRPmw5t76E+z4s=; b=FjnivxC4dyONEdHNOHOAB1x4yPv+YcC84ZTmGPz72IPV8kLY44eNmZe3U5ET+b27EV F2xlGU3R+gpzPza6Tw37GgVSoexg0lz4cEKNp+kjFb7k+HPOsNyeso61LP42gCa7Sz59 mlraU5Azo/UwEC0KvTikF97sSPj/o+Nw3yYlKODt3n8D3m2cCtLTse57bZcr38CKrv8l AoyCA/ChRMrm0N9qvcXK8paA19+vuKViPC7sI6Zq7wfoNLhwBTGGaD2SGo0IOqMY0vKz oYtWTxpnBJ6GWIy7QXgKqeHhsjxFaTBMduwEawTtVtfSnhq2rAjFnMLobbxkLGt5SKYY NuoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ttJfPAO3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o15si662782ejr.527.2021.02.23.21.34.19; Tue, 23 Feb 2021 21:34:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ttJfPAO3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234836AbhBXAU6 (ORCPT + 99 others); Tue, 23 Feb 2021 19:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233690AbhBWXkI (ORCPT ); Tue, 23 Feb 2021 18:40:08 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DBDCC061222 for ; Tue, 23 Feb 2021 15:35:27 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id m6so68227pfk.1 for ; Tue, 23 Feb 2021 15:35:27 -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=n+WygfJCPp4Qu696pS1XQd7UkFwRBWZBijTBblQdXgUhXHCCYj5bn4qaQgVMO5ixRs 4nG1T0vv6Yvgeep/s3RDqF7YTVm7jaLeV91vW8/5vstXSg8dMzATGc0JQ3PY6xpLhU4p VPh32eo6Rp5o27cdPKxBrMTlvI5v2QP12XjPVFd7XgCEqe9OLB0HSCK5VFqqJWnaRXoO DIW/1WCVuW1at9CirdGD7Cd4ohJcW/bJF0wj02ELL+uml30oaLxodVU+fJLuxox5Bivm DlvEXgVlcFjBR5uX79Z/N/xEgt0c9USJ8UDn4P5ig7W7hluR6m/wdCRG7TgmMoQ/dp5a Kakg== X-Gm-Message-State: AOAM530OaMLs0WjqQRRaHSgWjA0ImG7vB9ogtneOLKj6V6RMCFSaLGkR 1n0xVbppmpgj1GnWqxpLe8gqzA== 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 Cc: 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 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce function __rproc_detach() to perform the same kind of operation as rproc_stop(), but instead of switching off the remote processor using rproc->ops->stop(), it uses rproc->ops->detach(). That way it is possible for the core to release the resources associated with a remote processor while the latter is kept operating. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 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 -- 2.25.1