From patchwork Thu Feb 11 23:46:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381068 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496500jah; Thu, 11 Feb 2021 15:51:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJx59IpvET/NRRtks1QpRiNO/ue9PZ3w6jrbEbD2uF/s3Ia+UgJ9cYwhW2kdghJJGsxg1jun X-Received: by 2002:a17:906:cf86:: with SMTP id um6mr197125ejb.426.1613087495619; Thu, 11 Feb 2021 15:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087495; cv=none; d=google.com; s=arc-20160816; b=jP/3/Gc/vzDEZLRm1KOdQRuFMSiOTZOt/i8Q493WXhsr597M+6t5SuX5JsSnWnA/RL idsi36POgziC+laZyMTIksTxIlL6vZUBwnX48fNC2L/zA0pNrulFgeMJPf9y4yVn0Vhg mLzE0Gpry862M4WVVyKIrmI+guePJzJEFgBCDI2VTF+AbZ6aIILu/blyii/UqH7jPjkE 4/63LnsK/RFFnUE5DC9iQc1QOZI8eeSNy+OV2ZsqP6tLuogx3UZirvXLP+62SRXmbIon mj2P4q2zwqatGkOVMqJWLbOkUlnOP5XOrMGU8w+15dYUYl705+zlHVx2ZsObdGsMM7XJ 5rNQ== 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=P8ZgBr2dAQyxtUR61d2cd3HaOU57hXG+26qgFPCFdBI=; b=Wv7Au+dMSJxKfJQxVLpj6QyavPnJMEXQ03wWdSeTIx6sabIjCBnyKZpp0ldxFG6MW4 lZzRLq33lk3gNwfhqUrd7S4NrPatE8HeizxEVSIVgWlzLnpdbrIFsn3Du8lRiJ+YMRo+ BwGCDAoL6k3oFf9WCm/WbGKyUpOUfnQBOujWeXfNILKdgPDHWjpwjAuIPfTpNEyU5g74 il4yucKQz8PUN2Mj29ILUncgPkLGSmF/XnQ/qpRUK/1p//+xd+CVr400N+LcEbAW33hA amzu8bY9HJLadaxXOvfBkSrTqmxjrORgF5Qs/ZDfLPc75ZbZVNXhfE8gXGWt7yt+5wWg 853g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dl2LvQjP; 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 ch12si4550788edb.463.2021.02.11.15.51.35; Thu, 11 Feb 2021 15:51:35 -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=Dl2LvQjP; 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 S229944AbhBKXuM (ORCPT + 6 others); Thu, 11 Feb 2021 18:50:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbhBKXtK (ORCPT ); Thu, 11 Feb 2021 18:49:10 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D089C061BC3 for ; Thu, 11 Feb 2021 15:46:40 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id z6so4738060pfq.0 for ; Thu, 11 Feb 2021 15:46:40 -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=P8ZgBr2dAQyxtUR61d2cd3HaOU57hXG+26qgFPCFdBI=; b=Dl2LvQjPNpm6v5pNg/beWWjx3gn0Yx3N3EKYMuqSRq2/+Wms+YUUpCARpU7RRc13ps suzbkYzATDsQV2OWgYy7yVRgiODXzlyQCNqk+YkrM9+/F+uxFv8pHoaKAjcGZivKPROp o1Ex0bgngOJ6TDxgT/kfSVe+MmitK/+6qCyLh605rt6twllmfl7aXFiKOGO6GklcqoMT WxucP5W2wDMNQbI0qiKK+Rjm7bPKEWoX9t+bvbhXruBPSDJmF7i/AppsIDimmrxr+xfd k3Xa7nJF0Ah/BZ1x4tWRJEgVI9iK4zbPWoyViEJLr6lbtnEDiNh+ZpxLbhqENPQjdaKj O1eA== 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=P8ZgBr2dAQyxtUR61d2cd3HaOU57hXG+26qgFPCFdBI=; b=t/1TrRu1L3TotBSVeC5fo2D+34ySZUM0EJKd+q+T96Q9yOjt4a3x+XtWKnSMHYz1AR ahqZf2GNql4mtu2/Ac3LV0kOxc95m62xUhVesfACusmRUowRUbAJRHDoA0McpwC6yjC5 VB81ddc/cxx81Um47BFKVk9SdjN1suHGFQ7HBu54E3dH25XAKb2NC4JqLAcii3do7eQq wtHv0A33KhPeMja3aJxFgzH5DPTFZmc8WJItyhIsvtCGfeMu8kE/rSXJdEU7ZcPP0rHa kowqw6NNRY+NW+kEZtkhzqi0BKqiWU0obWwo4WUpORLYt5HO6OhW3BMezD8Zd4qjWhMe 8dGw== X-Gm-Message-State: AOAM530/7w+hvb5B4YzUdynEtOk117OTYOZbQFeIi7bniu7QVJ4Y3vHi J2BrQIpsBA8ojh7s6D+3UbuEoA== X-Received: by 2002:a62:7dc4:0:b029:1ba:765:3af with SMTP id y187-20020a627dc40000b02901ba076503afmr424252pfc.78.1613087199769; Thu, 11 Feb 2021 15:46:39 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:39 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 11/19] remoteproc: Introduce function __rproc_detach() Date: Thu, 11 Feb 2021 16:46:19 -0700 Message-Id: <20210211234627.2669674-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-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 --- New for V5: - Removed fancy error recovery when ops->detach() fails to replicate what is done in rproc->stop(). --- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5c52c612a7f0..b150138542d4 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1709,6 +1709,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