From patchwork Thu Aug 11 21:52:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73822 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp322960qga; Thu, 11 Aug 2016 14:53:34 -0700 (PDT) X-Received: by 10.98.11.86 with SMTP id t83mr21102265pfi.51.1470952414176; Thu, 11 Aug 2016 14:53:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5si5048222pay.255.2016.08.11.14.53.29; Thu, 11 Aug 2016 14:53:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932532AbcHKVxW (ORCPT + 27 others); Thu, 11 Aug 2016 17:53:22 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34620 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932426AbcHKVw6 (ORCPT ); Thu, 11 Aug 2016 17:52:58 -0400 Received: by mail-pf0-f175.google.com with SMTP id p64so2360545pfb.1 for ; Thu, 11 Aug 2016 14:52:58 -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; bh=xGqKq05nd+JXazH0ynJZzL/il5Z20kB0zqO4X8GxTNc=; b=GXXBBunhHJmgb9Wc9Mun/QXbZVHCeGLDCqOURWWMdmd+lnKRBc93ws4KHIw7GptGic 1xAtd7eypWZm/Dfrw0pXeKS736t14ZEX8divwrqL1x4gWhbpD6XOoxJro6qcYg4nm31e o0yKx4NfNWmJLg2t2D+OnIHe66wyEoNqhJxWQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xGqKq05nd+JXazH0ynJZzL/il5Z20kB0zqO4X8GxTNc=; b=TqdVRJpdVdzMnNvoyvU3lgUQhGNROoFsT/RKDEHec9JZ6A7FWRj9ybIna6ia93N287 d0eVrQ0GqFS7Bgt6FS/fwQaTGdBoKva1wCmVKqnJ21mMioomxjBtnQVtTUvKQPA1yL6S BTIjWZPEHwJ7I4vKI5amEAEzdcGTALe1ZXjmyrKBcIMBXfAjsNkghjSc2BYeFIWDzIjE lN90N8q75VPbXZuHLnlZeWoHOdpwATS0TCmqBgdem0BzpH61Juv/sbc//bnpbGA7BwE5 lOGoVsfgk5toWmMgAziTcsztF0CT6oiISFmOFv5npfyIizplC60r7sIL4jEuC3FYlyQ8 Zm3g== X-Gm-Message-State: AEkoousFOWHruF9VjVhW0ChMaEGCbyFnvWOL/Q2tug3XMaRSL2k0f7EK95zw/i0Yq5D8f4zU X-Received: by 10.98.157.12 with SMTP id i12mr21121550pfd.164.1470952377900; Thu, 11 Aug 2016 14:52:57 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id bx9sm7547908pab.17.2016.08.11.14.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 14:52:57 -0700 (PDT) From: Bjorn Andersson To: linux-remoteproc@vger.kernel.org Cc: Ohad Ben-Cohen , linux-kernel@vger.kernel.org, Suman Anna , Lee Jones , Loic Pallardy Subject: [PATCH v2 3/4] remoteproc: Move vdev handling to boot/shutdown Date: Thu, 11 Aug 2016 14:52:52 -0700 Message-Id: <1470952373-4823-3-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1470952373-4823-1-git-send-email-bjorn.andersson@linaro.org> References: <1470952373-4823-1-git-send-email-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The newly introduced "always-on" flag allows us to stop giving the vdevs special treatment. The ordering of resource allocation and life cycle of the remote processor is kept intact. This allows us to mark a remote processor with vdevs to not boot unless explicitly requested to do so by a client driver. Cc: Lee Jones Cc: Loic Pallardy Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/remoteproc/remoteproc_core.c | 37 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 22 deletions(-) -- 2.5.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f484e04810f3..e86200f978e2 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -753,6 +753,7 @@ static int rproc_handle_resources(struct rproc *rproc, int len, static void rproc_resource_cleanup(struct rproc *rproc) { struct rproc_mem_entry *entry, *tmp; + struct rproc_vdev *rvdev, *rvtmp; struct device *dev = &rproc->dev; /* clean up debugfs trace entries */ @@ -785,6 +786,10 @@ static void rproc_resource_cleanup(struct rproc *rproc) list_del(&entry->node); kfree(entry); } + + /* clean up remote vdev entries */ + list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) + rproc_remove_virtio_dev(rvdev); } /* @@ -835,6 +840,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) /* reset max_notifyid */ rproc->max_notifyid = -1; + /* look for virtio devices and register them */ + ret = rproc_handle_resources(rproc, tablesz, rproc_vdev_handler); + if (ret) { + dev_err(dev, "Failed to handle vdev resources: %d\n", ret); + goto clean_up; + } + /* handle fw resources which are required to boot rproc */ ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers); if (ret) { @@ -898,7 +910,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) { struct rproc *rproc = context; struct resource_table *table; - int ret, tablesz; + int tablesz; if (rproc_fw_sanity_check(rproc, fw) < 0) goto out; @@ -922,9 +934,6 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) rproc->table_ptr = rproc->cached_table; - /* look for virtio devices and register them */ - ret = rproc_handle_resources(rproc, tablesz, rproc_vdev_handler); - /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) rproc_boot_nowait(rproc); @@ -973,9 +982,6 @@ static int rproc_add_virtio_devices(struct rproc *rproc) */ int rproc_trigger_recovery(struct rproc *rproc) { - struct rproc_vdev *rvdev, *rvtmp; - int ret; - dev_err(&rproc->dev, "recovering %s\n", rproc->name); init_completion(&rproc->crash_comp); @@ -984,26 +990,13 @@ int rproc_trigger_recovery(struct rproc *rproc) /* TODO: make sure this works with rproc->power > 1 */ rproc_shutdown(rproc); - /* clean up remote vdev entries */ - list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) - rproc_remove_virtio_dev(rvdev); - /* wait until there is no more rproc users */ wait_for_completion(&rproc->crash_comp); - /* Free the copy of the resource table */ - kfree(rproc->cached_table); - - ret = rproc_add_virtio_devices(rproc); - if (ret) - return ret; - /* - * boot the remote processor up again, if the async firmware loader - * didn't do so already, waiting for the async fw load to finish + * boot the remote processor up again */ - if (!rproc->auto_boot) - rproc_boot(rproc); + rproc_boot(rproc); return 0; }