From patchwork Thu Nov 26 21:06:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 333057 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1633969ilb; Thu, 26 Nov 2020 13:08:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOJ6F3/wdZiWs8YSnVgpsZ5a9Hz41PCNui89nmc0Mm9bhIs3H544cQ+VxDPGCYPM1bTN8c X-Received: by 2002:a17:906:138e:: with SMTP id f14mr4384897ejc.370.1606424901315; Thu, 26 Nov 2020 13:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424901; cv=none; d=google.com; s=arc-20160816; b=frIPgJoov1MTuvXteuOwiM6T19g4oslqRxQwJLWAMU70jtrn1rrabsjjddUrsfqee+ f+TZ0uvzpYOUj+3ps+n0Fa1eesTMBFtbgZSQGxJRzhQPRfqM1PEQSo2BMRqMPDVqshkU ZloVFhnueY9o5TMoY8dVvyH4gZ1zQWBAc2dVniauEnE2NMwMK2FNPuNTIqga/KIWfNVq WXUR3VHbzIdsMJ55Gw/qHeniEACKLZZcS0jkx0IesMknzDdUzQiQikVLBkCyg1nIVWay US+tRahnBvTAKmH59qZ1y2rutvh0gZT6iPPuzzWTai04DaVtNUvT3aAB5xQL5NpetD8z s9dA== 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=wtAqiIL4OGNOjCOWpJIS67EUO5pm7/BCFlTCx9jyrY0=; b=odNcet7IucZhyVKlLWv9dZ6Z7lLjSZVmUV8yOMUT3bfQDO+eh78ta1hEjSeNhZnIwi HPywg1UYtIU+LJY37M9NbxBgna5dXmL1NZTjgXSvfQ3vX8hO4h3KVoDEqFg/pA4SpHZT SKumvZJTEfx7a+MYnQqb3EmRZP6V7ll28ZJ203/LGTqT1/FQ5Y+akjwwRyAJT8qnWPxg PKS/eLNVlVMXH+RW7tWlgPIsy7V72rcscEKSWcqW1sZUbF/QcEqipCy3w9sfNgH8HtZ8 GoB6t0bTQ14nmG3JnscqyL/sKdj1JYeLWEGr494joHD92+HZYyozgZl1jrNS+nPjgFlc 6y9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cny5LHKn; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si3567033ejg.330.2020.11.26.13.08.21; Thu, 26 Nov 2020 13:08:21 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cny5LHKn; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388623AbgKZVGy (ORCPT + 6 others); Thu, 26 Nov 2020 16:06:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391551AbgKZVGx (ORCPT ); Thu, 26 Nov 2020 16:06:53 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49312C061A47 for ; Thu, 26 Nov 2020 13:06:52 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id b23so1652471pls.11 for ; Thu, 26 Nov 2020 13:06: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=wtAqiIL4OGNOjCOWpJIS67EUO5pm7/BCFlTCx9jyrY0=; b=Cny5LHKnxJRw0cPNWlSxQxJLAOqavXYkvssYv+komoercg8UQCRqLL1Dt7dN7w10mi /jK2HtPu8TjYHOvz6LNUomKVqNs56Aeu6E/keXOpMJPmGO4hnrVRc8Th++2ZHOWpI/9z KRcnuSvQkpZvQ1rZsaJjNGubmkPscveRVANqlUSvnzOU/y8VNfcRsxznJk2dQbZXLOLI OlLlLzprXxRgjI65ETsbLde3wmKcelqXo7ApjN07j5dgdWrUh8rupWQZ2+G8Q87vrCVl slY8OqOhgTS/ro3JbICqr1YtfZjJC3lgBJGgTLU4G0Ku3Vq5P79Hhpaqg8TID0lxIqnm p+Lw== 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=wtAqiIL4OGNOjCOWpJIS67EUO5pm7/BCFlTCx9jyrY0=; b=R7PBnrRixsdHljB3F2X5u8biDTrxyeZGkWghNzFsnmpWJqx5DWlOrG5T3mkyVhOdi2 lJlFWIMfaJrmKMVJrE5xeq+uVwFqCIl7aX/zbzD+L6rkiqBUi3mckWcFVmlBj247YErT /RZPE+TP5pyyhky/eFuOYLZHP8NvsFnNQNn4CprJTM88l6uq3smEEU+TFHkw2PQudHt6 I4tU3pSlizo71nFKixKx1FHaIfaBhHQQTaUKO/e3JbxfxBrH0SDYTM+LGBjp4QxlcKe5 39ft5SWTh0FQhoQQreN/i/NpJC01WBCaZq2zjefa/Xjv8g95lJNApJiNLy5dZ1sjwXmx Qxpw== X-Gm-Message-State: AOAM5338wY+wUJVXi2tTLf+QyYwxMVJMp3exHFx1efvKiaxua0U2bP3h TKRlN9O5ZZXHXpwEuN9hmwFGAg== X-Received: by 2002:a17:902:e9cc:b029:da:1d7a:f5fa with SMTP id 12-20020a170902e9ccb02900da1d7af5famr4151197plk.38.1606424811844; Thu, 26 Nov 2020 13:06:51 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c203sm5612676pfc.10.2020.11.26.13.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:51 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com Subject: [PATCH v3 08/15] remoteproc: Introduce function __rproc_detach() Date: Thu, 26 Nov 2020 14:06:35 -0700 Message-Id: <20201126210642.897302-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201126210642.897302-1-mathieu.poirier@linaro.org> References: <20201126210642.897302-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Introduce function __rproc_detach() to perform the same kind of operation as rproc_stop(), but instead of switching off the remote processor using rproc->ops->stop(), it uses rproc->ops->detach(). That way it is possible for the core to release the resources associated with a remote processor while the latter is kept operating. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 539667948bc8..928b3f975798 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1664,6 +1664,37 @@ 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); + rproc_start_subdevices(rproc); + 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