Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp655941ybg; Mon, 1 Jun 2020 10:55:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvsN+QJsui/Xh7Kf/ohyI6xgvdpF1E0gb3gy+4NERDKM/RlJHsgSl0sR7igwPrr82iHY3X X-Received: by 2002:a17:906:b04b:: with SMTP id bj11mr15796095ejb.516.1591034111491; Mon, 01 Jun 2020 10:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591034111; cv=none; d=google.com; s=arc-20160816; b=nVs5w9zmAhS19caAQChiy7y+7hmuCvMPmOwzOC6GFQXDK/cQ0soCdLxjK5eBzUzygB ucyAQ6/SHbZNbG60oXLMsBUycp+fQNhTazNegLCrC/Sum/8NJ2CZXjmeiMNCqkVUYbHy 4GhZbuwsE2YjocRM73yhfqLYj7Jmf71HQhKletRkIsfAkjnebteNtJ8YWGBE99LKC1XZ S4oB8gRMKlMocrBUDzPn1Gv+Z2GZmdQ56a83IqHMBvK36lPY9NqizQyBcqZc1K+qbOYN 0sdVpxACl2VoNeWnm4DOar8ouptRNbMCAomBZr5tIL1oqPRc2Q/0oq162vvYBQ/csCJr IqLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FItOKgdj0uldhq4ThGfwK1TNrUS2A/jMnQRmSCeHCgM=; b=069YLvdwPRwkWsSIlJ0xpITFhfPOHCHb7zaw3yuyP1Z76sUcwJWEbeo31DJbCPICf9 MS1A6Xx1iFSgzRZ0QofVZH6hLszSSy3wxOg9xP5q/LKO7/rsQAT1/uPmkI1AB7Iz6egT Ig4PikxIQrIXJUMh8SM2OtQTlAfHErD9TfYZ0SBW9kgMPM7gxoMkTjfMlaAZD1po3/Da cK4LA5wjTcbY5NrHO8arJVLdTVQ+MIjQUN/l50RpjTIIglBii5AQxqVx4HsFHPhVxgdL yf9a2WDoosTw+bzlxMkhzktY+lxZEhnwzGY4+FF0z7qMIdApJEyRfYFQAkkINl09LCvX eKGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lg+3hcJ4; 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 u24si105867ejo.396.2020.06.01.10.54.48; Mon, 01 Jun 2020 10:55:11 -0700 (PDT) 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=lg+3hcJ4; 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 S1728056AbgFARvq (ORCPT + 99 others); Mon, 1 Jun 2020 13:51:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbgFARvo (ORCPT ); Mon, 1 Jun 2020 13:51:44 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB75C08C5C0 for ; Mon, 1 Jun 2020 10:51:44 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id t16so245729plo.7 for ; Mon, 01 Jun 2020 10:51:44 -0700 (PDT) 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=FItOKgdj0uldhq4ThGfwK1TNrUS2A/jMnQRmSCeHCgM=; b=lg+3hcJ4uWV77YK1218h714AN6E1Y48qGMiFQ6RgI3YGMxx4yf+DSbsdjFIU6DI4VB v2uks0KMjYfjzc+VGgdeGxpwmNX9fbhjtG9jG5nUzbfYx6BO5uHZtMxpT9JgBEvYf0Yd zbOgym5mr+oJMp7CFoj8jTWHWJfbavzYE3HjDvsorp5GVn5UXh7tx6+pRHxB5/rhGT+3 8uVl5Yl8xjf+s518G/KLq5Gvmbf5NUDn3wcERtZLIzDCkzTpMPFI4qwAkdpCTpNTpEmk KQpZeGsEjcBAL8I5qmGUzKSn2wYhdkcVN9allh6etYaUUM62K0v1e1bQUdUfCa+QxpcL O4iA== 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=FItOKgdj0uldhq4ThGfwK1TNrUS2A/jMnQRmSCeHCgM=; b=ixhr51PSSDuRyywVc3RRdA6UtCtE8NoG2KWIFVZmXqmDKYq4ma53Ut2B+jAkmKgnvo ccTN3SEEFD9/9LQlbQe35sXnBZBQgg9zAvOsOt5z6AQImzXdYu8/kLY8qujpA876QqsC fZ2K2CWiMvvCUD7JjGc2KKbOvJts5FuMWJV9R+y+dnYOXVJ1izPxncbWlvsMy50St6PO bIBijCTv42y98sJFv3nGQ2bQTJvkvWrSOr8YTm9+LsWV2d6sYKKwmgdI3qvIpVmOYO/X OwHAFbpFpDdq2HtpzinLXEs4fbz9ebgdWCCRR3F4Hs2boQr4yG7J27oIN4jHJagEV6/J GskQ== X-Gm-Message-State: AOAM532x6SXIF/q39L2EwTm9IA8XawxF+4g7YWADEbodGMA2MYJxKtvd f+VNOKoY39Tm2RzLaKTMhouF6Q== X-Received: by 2002:a17:902:b484:: with SMTP id y4mr21539701plr.21.1591033904237; Mon, 01 Jun 2020 10:51:44 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:43 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 3/9] remoteproc: Introducing function rproc_attach() Date: Mon, 1 Jun 2020 11:51:33 -0600 Message-Id: <20200601175139.22097-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introducing function rproc_attach() to enact the same actions as rproc_start(), but without the steps related to the handling of a firmware image. That way we can properly deal with scenarios where the remoteproc core needs to attach with a remote processsor that has been booted by another entity. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9f04c30c4aaf..0b323f6b554b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1370,6 +1370,48 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } +static int __maybe_unused rproc_attach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = rproc_prepare_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to prepare subdevices for %s: %d\n", + rproc->name, ret); + goto out; + } + + /* Attach to the remote processor */ + ret = rproc_attach_device(rproc); + if (ret) { + dev_err(dev, "can't attach to rproc %s: %d\n", + rproc->name, ret); + goto unprepare_subdevices; + } + + /* Start any subdevices for the remote processor */ + ret = rproc_start_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to probe subdevices for %s: %d\n", + rproc->name, ret); + goto stop_rproc; + } + + rproc->state = RPROC_RUNNING; + + dev_info(dev, "remote processor %s is now attached\n", rproc->name); + + return 0; + +stop_rproc: + rproc->ops->stop(rproc); +unprepare_subdevices: + rproc_unprepare_subdevices(rproc); +out: + return ret; +} + /* * take a firmware and boot a remote processor with it. */ -- 2.20.1