Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp131644ybz; Fri, 24 Apr 2020 13:05:50 -0700 (PDT) X-Google-Smtp-Source: APiQypLRCEWpZ8WXsHRuuWaDnRrQNkDM9AXdNUMm9AWMxDmLiqC0zTPCQHvP91ZdwOI90P47SWT5 X-Received: by 2002:a50:ec0c:: with SMTP id g12mr9473601edr.140.1587758750470; Fri, 24 Apr 2020 13:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587758750; cv=none; d=google.com; s=arc-20160816; b=ZxUJDoo9FkXMDmBEw/+Y96bDaNmWpXzFfoXhSTTXygwc8AjbTVu96CExmWz9V64g+J 6TkTcOA5SDnqcIXb2pFn/f2CGS9KAxxlNbrpB4gfsGCe//CdL1bRdXkrOW8M7cXcQ73h k8oAks2y/XPHcTHuQOj1zSkisD1kwZdc0bF8E7/qwKWMmaJLU/w4DSj50u9echeGRqNM ebne7JnRrhtUOt8+A+wWguGODOgGvzvnwgWgZKfOd+Ts9RFcNyvmsiMZM4jrLC839575 cd2P6/13ygkUd5z5GRg2F1wTN3O6y1CcbaptWHaaStolwtm1CbQM+Ip/DNNtJMrljUo0 V2JQ== 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=thvt7ABu2oknElk6aMlYpSKsdaIxDnUq/lm1lGmYKAw=; b=ALZm6odkSvFgJBHWxmFglBFu+U9kHykFgsSQYEI7IO23FeLXWy3aDn3SC2Lx47Dmzq b4ufoxbFjn6x/PYKTbwu19P+V4wTEHni02XXIH03foarcnSvz/y2qz2Zew6h7YKx8zho f6eVLxa7c1oJfhsWXJsMSQAJp6O3/8B6VHln1uIkCCQhYOEWmFFU+CfDBNupn53fMtgL BsO5uEJtPxIYdWMaszfZ/DoNsIegXeu96ifbxna32ItFtHS56IVF6xDABen+qcnrXdII tghZuepXHqLmNkRJVAjqjRw2r/lcyIzdk6KAmSozXHYIRWn1l7ZKurXaxKrPEhI8WMWx TeQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OEce7CVY; 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 cm21si3803502edb.275.2020.04.24.13.05.22; Fri, 24 Apr 2020 13:05:50 -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=OEce7CVY; 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 S1729448AbgDXUBs (ORCPT + 99 others); Fri, 24 Apr 2020 16:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729422AbgDXUBo (ORCPT ); Fri, 24 Apr 2020 16:01:44 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E47C09B049 for ; Fri, 24 Apr 2020 13:01:43 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id h69so5120497pgc.8 for ; Fri, 24 Apr 2020 13:01:43 -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=thvt7ABu2oknElk6aMlYpSKsdaIxDnUq/lm1lGmYKAw=; b=OEce7CVYAQrD+2/fCQ7jAAUkpy1uaYWusDID0du7fpICLUzFqnf6/1vU0bUtxkf6vw aNOjg8KrkImP9oAqyhCCte3mkPwmu7Ykwimj3EuqY0HjMsKjw5kbjLt1SbiMWGDm7qQ7 US0tREGO3J5hUBiThXe/u8ffLLhBOB+lKPFkClNBWVftYk4Pu6TpAc4WzPmS+2UkGU4K 7fHt/V27b33sABBBZvhD+1nwXCDUvbIOIiSHakEwhIdNQiMGNW9NzBWy9OH3UP0hHrJM mpvXwr4yua+xFlFktoRHVNwY5rCQaiipj1NZx4rX/kBQ4st6hj6pm78MK1ZZZZf1Sit3 EXAg== 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=thvt7ABu2oknElk6aMlYpSKsdaIxDnUq/lm1lGmYKAw=; b=dOFGuH3H1oWDD9jhOrE6SV8/O0i5oO/G3QFYNHY++/U4B97y/H9pZ9DIxA1mY6lrQL ugohH5uyKjnkHKxEEzEKNsTHXavxM2gypIO1wQ1drD0zQvApwp0CYAgguHnJYpFYPMrG p7+OVODgofzi8e4XAN6xx9ndTPpXJdBN1E6XZOfvnP9JYvpkAGPaM/NFzyukWjGOdI39 DoSlZFbHBSNNWhE8RGDz1VOCGa+HpKlnzRkccLcFgiFozcii7Lyu/7IO9H3P4R2mRl7T Vfr4KiXYC2KDGafjgee5QRINSOOMSIdvKMgLK9MKJ6x6P8C+LcWTIhjbAg+1kbNttJ0W qbuA== X-Gm-Message-State: AGi0Pua7SBlXBsdjRyVM/5gp+Ka7VxZ3/sjMLCzpZ2xfx8mztQkyr+t7 03VGd3Hpp7RASFeOvm0kvWRdWA== X-Received: by 2002:a62:5ec7:: with SMTP id s190mr11118517pfb.130.1587758502506; Fri, 24 Apr 2020 13:01:42 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:41 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/14] remoteproc: Refactor function rproc_boot() Date: Fri, 24 Apr 2020 14:01:25 -0600 Message-Id: <20200424200135.28825-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 Refactoring function rproc_boot() in order to properly handle cases where the core needs to synchronise with a remote processor rather than booting it. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 25 ++++++++++++++++-------- drivers/remoteproc/remoteproc_internal.h | 5 +++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1b4756909584..a02593b75bec 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1762,7 +1762,9 @@ static void rproc_crash_handler_work(struct work_struct *work) * rproc_boot() - boot a remote processor * @rproc: handle of a remote processor * - * Boot a remote processor (i.e. load its firmware, power it on, ...). + * Boot or synchronise with a remote processor. In the former case the + * firmware is loaded and the remote processor powered on, in the latter + * those steps are simply skipped. * * If the remote processor is already powered on, this function immediately * returns (successfully). @@ -1771,8 +1773,9 @@ static void rproc_crash_handler_work(struct work_struct *work) */ int rproc_boot(struct rproc *rproc) { - const struct firmware *firmware_p; + const struct firmware *firmware_p = NULL; struct device *dev; + bool syncing; int ret; if (!rproc) { @@ -1788,6 +1791,8 @@ int rproc_boot(struct rproc *rproc) return ret; } + syncing = rproc_needs_syncing(rproc); + if (rproc->state == RPROC_DELETED) { ret = -ENODEV; dev_err(dev, "can't boot deleted rproc %s\n", rproc->name); @@ -1800,13 +1805,17 @@ int rproc_boot(struct rproc *rproc) goto unlock_mutex; } - dev_info(dev, "powering up %s\n", rproc->name); + dev_info(dev, "%s %s\n", + !syncing ? "powering up" : "syncing with", rproc->name); - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto downref_rproc; + + /* load firmware if not syncing with remote processor */ + if (!syncing) { + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + goto downref_rproc; + } } ret = rproc_fw_boot(rproc, firmware_p); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 59fc871743c7..47b500e40dd9 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -64,6 +64,11 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, struct rproc_mem_entry * rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); +static inline bool rproc_needs_syncing(struct rproc *rproc) +{ + return rproc->sync_with_rproc; +} + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { -- 2.20.1