From patchwork Thu Aug 11 21:52:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73820 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp322859qga; Thu, 11 Aug 2016 14:53:14 -0700 (PDT) X-Received: by 10.98.78.138 with SMTP id c132mr20903311pfb.67.1470952394077; Thu, 11 Aug 2016 14:53:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7si5034832pai.287.2016.08.11.14.53.08; Thu, 11 Aug 2016 14:53:14 -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 S932486AbcHKVw7 (ORCPT + 27 others); Thu, 11 Aug 2016 17:52:59 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:34189 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932404AbcHKVw4 (ORCPT ); Thu, 11 Aug 2016 17:52:56 -0400 Received: by mail-pa0-f47.google.com with SMTP id fi15so2242609pac.1 for ; Thu, 11 Aug 2016 14:52:56 -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; bh=LTTa2azvHaGsJJmIXbMoNbonogWdzKPicPCgyEfH5vc=; b=HTBC/Sw86JBFE0lKCDs17CfkxAik6ShqS0mGflSOg2VSRAf0k0JPTWbN4aKJR1XdT+ +8AK8dpRvcJP3Gff9y1Zuj/YaMeusbGzSxmw+pGmE2cGz/1DepF352QAtWl+g0VziP2H T6ygF1KTnSuHOvQQ4kzrv/3g7aJJMIzfMQsaQ= 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; bh=LTTa2azvHaGsJJmIXbMoNbonogWdzKPicPCgyEfH5vc=; b=Vsvksk4wouLiLB5N45hq9qz6hFKENFONNTAyFvPQWI7kRTL+yRg9J1NbeJBakq8ng7 cu5YPgdvDi3LvYgUGp1NepOzJjw6nDvwxrplC+zcSL5xxh/xxfFI9YzBwsza7mbr8cw0 0jbFnNBB6rWXHXCoCv7pvI3EJf91KjOTYHAczqQGyIMCeCHDRbx86a2bdD49Jn8u0KrJ ve7Lt80xpSBvUDjRF6BG620y10iLc84zn+u37nk8DzxxY490hoeeuXEBfceUOXDrfEPl Pt0fDTs6859oQWzr2kAbciFX9/TZZ9KMjSW2IML57mpNNALcI/hbZFlvsx4eYgMPVzH5 ddAQ== X-Gm-Message-State: AEkoouuX/WEarbe9zwx/GjJrX6KiouDhgCaG/69JrZN/uD/mlzgwki6Jeif58fZcZvJRnPqM X-Received: by 10.66.72.40 with SMTP id a8mr21424960pav.15.1470952375817; Thu, 11 Aug 2016 14:52:55 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 14:52:55 -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 1/4] remoteproc: Introduce auto-boot flag Date: Thu, 11 Aug 2016 14:52:50 -0700 Message-Id: <1470952373-4823-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce an "auto-boot" flag on rprocs to make it possible to flag remote processors without vdevs to automatically boot once the firmware is found. Preserve previous behavior of the wkup_m3 processor being explicitly booted by a consumer. Cc: Lee Jones Cc: Loic Pallardy Cc: Suman Anna Signed-off-by: Bjorn Andersson --- Changes since v1: - s/always_on/auto_boot/ - Fixed double increment of "power" in recover path - Marked wkup_m3 to not auto_boot drivers/remoteproc/remoteproc_core.c | 28 +++++++++++++++++++++++++++- drivers/remoteproc/remoteproc_virtio.c | 13 ------------- drivers/remoteproc/wkup_m3_rproc.c | 2 ++ include/linux/remoteproc.h | 1 + 4 files changed, 30 insertions(+), 14 deletions(-) -- 2.5.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fe0539ed9cb5..5ca98039e494 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -933,6 +933,10 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) /* 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); + out: release_firmware(fw); /* allow rproc_del() contexts, if any, to proceed */ @@ -978,11 +982,16 @@ 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); + /* shut down the remote */ + /* 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); @@ -993,7 +1002,18 @@ int rproc_trigger_recovery(struct rproc *rproc) /* Free the copy of the resource table */ kfree(rproc->cached_table); - return rproc_add_virtio_devices(rproc); + 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 + */ + if (!rproc->auto_boot) + rproc_boot(rproc); + + return 0; } /** @@ -1374,6 +1394,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, rproc->name = name; rproc->ops = ops; rproc->priv = &rproc[1]; + rproc->auto_boot = true; device_initialize(&rproc->dev); rproc->dev.parent = dev; @@ -1452,6 +1473,11 @@ int rproc_del(struct rproc *rproc) /* if rproc is just being registered, wait */ wait_for_completion(&rproc->firmware_loading_complete); + /* if rproc is marked always-on, rproc_add() booted it */ + /* TODO: make sure this works with rproc->power > 1 */ + if (rproc->auto_boot) + rproc_shutdown(rproc); + /* clean up remote vdev entries */ list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node) rproc_remove_virtio_dev(rvdev); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index cc91556313e1..574c90ce07f7 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -136,11 +136,6 @@ static void __rproc_virtio_del_vqs(struct virtio_device *vdev) static void rproc_virtio_del_vqs(struct virtio_device *vdev) { - struct rproc *rproc = vdev_to_rproc(vdev); - - /* power down the remote processor before deleting vqs */ - rproc_shutdown(rproc); - __rproc_virtio_del_vqs(vdev); } @@ -149,7 +144,6 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, vq_callback_t *callbacks[], const char * const names[]) { - struct rproc *rproc = vdev_to_rproc(vdev); int i, ret; for (i = 0; i < nvqs; ++i) { @@ -160,13 +154,6 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, } } - /* now that the vqs are all set, boot the remote processor */ - ret = rproc_boot_nowait(rproc); - if (ret) { - dev_err(&rproc->dev, "rproc_boot() failed %d\n", ret); - goto error; - } - return 0; error: diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c index 02d271d101b4..3811cb522af3 100644 --- a/drivers/remoteproc/wkup_m3_rproc.c +++ b/drivers/remoteproc/wkup_m3_rproc.c @@ -167,6 +167,8 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) goto err; } + rproc->auto_boot = false; + wkupm3 = rproc->priv; wkupm3->rproc = rproc; wkupm3->pdev = pdev; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 1c457a8dd5a6..76d936cabbf8 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -443,6 +443,7 @@ struct rproc { struct resource_table *cached_table; u32 table_csum; bool has_iommu; + bool auto_boot; }; /* we currently support only two vrings per rvdev */