From patchwork Mon Aug 1 18:58:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73130 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp2849396qga; Mon, 1 Aug 2016 11:59:05 -0700 (PDT) X-Received: by 10.66.181.16 with SMTP id ds16mr99211679pac.102.1470077941012; Mon, 01 Aug 2016 11:59:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a192si36348851pfa.164.2016.08.01.11.59.00; Mon, 01 Aug 2016 11:59:01 -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 S1755074AbcHAS6n (ORCPT + 27 others); Mon, 1 Aug 2016 14:58:43 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33193 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754958AbcHAS6J (ORCPT ); Mon, 1 Aug 2016 14:58:09 -0400 Received: by mail-pa0-f46.google.com with SMTP id b2so2608129pat.0 for ; Mon, 01 Aug 2016 11:58:08 -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=Dw29xWIZssNN3WcITQQnVBOXBu5ZUpnWPUXP3HRQebs=; b=Wi0+hA9hiQHoTAMfde9UGD42RRFY3F67+Zr1g1zy0aN4wYyT+BqQLQbkgGruvDf3x3 ourUy58fAarm8zpeZO6ze1lmwQ7SRP8z0TU1dwuWtisOZLjq9AApZ9m9lV5vCFYckj0T 5Q0My8VYffmzx9jEXfn6QpGUvN8KpVkoK4uWo= 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=Dw29xWIZssNN3WcITQQnVBOXBu5ZUpnWPUXP3HRQebs=; b=ftjKiRPxsXlKv9SEeEZcKREhEBqGPkOT5mBUlw+CRlmaXKg6H9Gi79I23pmFGbjTC2 Z+4KOuxYn4YebagYbh54xYNhSgDliqeTCedBe9JOhpzwbhAXqGIHD7U6vY44HfXPCFnl 6IvQ29nICtI8WFP6yjJqL8f9nHE3MQ/DquAinWY6/xfMHYDIXPM27Fdomrc/9DCLoyUi 6TUK6+MzvdUL1DpKmriqWQkF1nsd/VtgnEiWyMbzvgDMd3JW2dHrJAyLmw5khf8DmxMv Yep83xVubdfKmOCUOwijIBcNqws2fr5XmkjG0SHL6RDxgcDr4jt5ZC6LrBsFFpHaDlGj KL2g== X-Gm-Message-State: AEkoouub9aExvvDbj4tIlCDJ1BZnoa6Rxl/YfbYDPEITzO0Wwfgs1y3hoqnM0R/vfZ9tYpz/ X-Received: by 10.66.185.228 with SMTP id ff4mr85262412pac.41.1470077888235; Mon, 01 Aug 2016 11:58:08 -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 s23sm47500241pfd.23.2016.08.01.11.58.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Aug 2016 11:58:07 -0700 (PDT) From: Bjorn Andersson To: linux-remoteproc@vger.kernel.org Cc: Ohad Ben-Cohen , linux-kernel@vger.kernel.org, Lee Jones , Loic Pallardy Subject: [PATCH 3/4] remoteproc: Move vdev handling to boot/shutdown Date: Mon, 1 Aug 2016 11:58:02 -0700 Message-Id: <1470077883-7419-3-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1470077883-7419-1-git-send-email-bjorn.andersson@linaro.org> References: <1470077883-7419-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 --- drivers/remoteproc/remoteproc_core.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) -- 2.5.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 084ebffdfc47..9d64409f3839 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->always_on) 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,23 +990,11 @@ 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, waiting for the async fw load to - * finish + * boot the remote processor up again */ rproc_boot(rproc);