From patchwork Fri Dec 18 17:32:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 345470 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2335564jai; Fri, 18 Dec 2020 09:35:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9XF1xdDe+3wcT7TfIjSUIIEaZ9uBDexQPp5XGbqW3seUxl+zOfeW7l85pmoeEZNaEFWVs X-Received: by 2002:a17:907:210b:: with SMTP id qn11mr5156796ejb.41.1608312910764; Fri, 18 Dec 2020 09:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312910; cv=none; d=google.com; s=arc-20160816; b=SFxhIgKhKzIT/m1U2zPYVFkGIROtZvAd7UOdOgTaMA64k73aTVeeGHeL6mLKEXsrHG Z45dHNM3Ze/DU37reKQ7wYhPa36fhCP5/HyeSqaBT5MruTpi42t6+UTnfDeRhjGqpcBF 9DqrAaYfQNkM/gRfDIXNUM701PRB7SWrvfvWN2nuEzW263unruR3P+Fvi7sUAJtVbWRn ILQuJ4tyC/dlb7+ccZAps2Y6VpvyosIecJaeOvJ0X8wDr8Ngv0yNRulDD/HEDDIA6UvT xXnLy79a4+ENqWMa4qnSyWTTCRiP1+zAgO+WjjTsFSygRg6BQtQ5hFVsojF+AS6cBhDc fJXA== 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=kq/8af8gfyQHRLTjjFQpBmU8IlBKCx8ZUO1N7tlkmUM=; b=XRzz2K0s40Hm9j5srG33dKO9yy81B2CMEF7BIBmXAFjOzm6RohCrnKMmIFkuKqeY5X 2c0ATcgffoS3YNU9qOsaplcZX+YFoJiMomcormUtnjSufvVB9lJLXzINiYHxwKbe373t atsjGUsSasQHwClx7xZR2pOkW8h3ct5qq8+FphxluB4lhZj0PZhiExL0x2iL0H40YvYv r/SvfayFxspZmVhWhdztfvRDhwgzFys9V46lvcFQD0ipws+hfNUx8+vFjfMlLJAo/HLV BUAAJzdJCC8S2rVG40Hj+CSzsQ4ycv1AF4W8eSwGaiL87Ex7yJVZN1b1o22+uMUOtWD6 AQCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xqy5A3cJ; 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 t20si4902939ejd.719.2020.12.18.09.35.10; Fri, 18 Dec 2020 09:35:10 -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=Xqy5A3cJ; 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 S1732652AbgLRReL (ORCPT + 7 others); Fri, 18 Dec 2020 12:34:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732712AbgLRReI (ORCPT ); Fri, 18 Dec 2020 12:34:08 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE71C061142 for ; Fri, 18 Dec 2020 09:32:43 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id i7so1744370pgc.8 for ; Fri, 18 Dec 2020 09:32:43 -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=kq/8af8gfyQHRLTjjFQpBmU8IlBKCx8ZUO1N7tlkmUM=; b=Xqy5A3cJrzblGn7kkF9K33fBX2hXDtOtmwTf+9wvM8bXNE3G4KFPGZ4lqjziYwxJIC 5pultxhG4IXdogclYCM3/RVu9w30nQ/ynI67lOSHfm5G4XPPb38I8BW7JhrBs9rMQr/o 8o7UCO+zUhE7aAlHdIwfSKBUs0ZqhWLPGpTB4a0Yu2Iww1eDG7BWSDr3a5xLqDhLrR3S rfDZ1zIn0jnkJTo5E45UmQkGvHRlFQ23IcYsUKGDddXxRQeG9GFO2hL4kg/gWvOgD0m5 breNaRghLvch90zF8EyPek85TkUj+UKKdQcvx3Yc/G4WFsilC6wDe0YE8WxWeilNvFKN iUHw== 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=kq/8af8gfyQHRLTjjFQpBmU8IlBKCx8ZUO1N7tlkmUM=; b=HrVoPX7DSLZuuzSxi5PKbMnOQL9+nbBhfJyBkVNJWeZowq4IhfRu5kcs0jOAcCYLse wbfK67Uu7MLBUq7O3v8x+Xuhhn5OdNI2B4Gu7MenDlD0ftzQW2g0vSQgTBXAOXDNfHC4 zuJJIFRclw6Y60ffQ1W3bjz4ohiwHwis1haW0R0JYu6BptBsSEW1C5FKJl+K5wXv2lmx 5krJ747mAh1Xk/1NSpTwHprou1kdnBO2FtZP+GlGP0X94eWXk6uzxWWlGeyT2M/J8r56 K/iRpZa9c/gp1Af7h3LB1mzCfti1b8O3eJL2cHGi/867+ZIm4bMeC+C6vfkiPINAWlZ2 NRPg== X-Gm-Message-State: AOAM5309zwNls0zj+6OEPAeReZjWwZ6Muw+ivDeYVsVGWHze4ylfLhc2 kBXTwhRPtK/1BYLudhROoph5kQ== X-Received: by 2002:aa7:9f09:0:b029:19e:cb56:e124 with SMTP id g9-20020aa79f090000b029019ecb56e124mr5253730pfr.38.1608312762797; Fri, 18 Dec 2020 09:32:42 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:42 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/17] remoteproc: Introduce function __rproc_detach() Date: Fri, 18 Dec 2020 10:32:22 -0700 Message-Id: <20201218173228.2277032-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-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 | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fc28053c7f89..e665ed4776c3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1670,6 +1670,48 @@ 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); + + /* + * If the remote processors was started by the core then a cached_table + * is present and we must follow the same cleanup sequence as we would + * for a shutdown(). As it is in rproc_stop(), use the cached resource + * table for the rest of the detach process since ->table_ptr will + * become invalid as soon as carveouts are released in + * rproc_resource_cleanup(). + */ + if (rproc->cached_table) + rproc->table_ptr = rproc->cached_table; + + /* 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