From patchwork Wed Jul 6 08:54:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 9215801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1BC9360572 for ; Wed, 6 Jul 2016 09:00:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09640285A8 for ; Wed, 6 Jul 2016 09:00:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0C90287A4; Wed, 6 Jul 2016 09:00:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5568285A8 for ; Wed, 6 Jul 2016 09:00:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bKif8-00075p-Lq; Wed, 06 Jul 2016 08:58:30 +0000 Received: from mail-wm0-f43.google.com ([74.125.82.43]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bKicE-000316-DN for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2016 08:55:32 +0000 Received: by mail-wm0-f43.google.com with SMTP id z126so103261817wme.0 for ; Wed, 06 Jul 2016 01:55:10 -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=/s1NCaBgaR1Mh4y4V4KzOLykG3kt4daVbxVk2mEUcfY=; b=U1bXaw4nZYvc9vl/8WNIntD41wT9Sd4mF1GO8Hp4OiINVMdtFPR0JWrnGy4jaF0tYt nnQcOu3AbfjLfg75ZJq9xEOjWc+h2Mzw6chLOEisfeVkG6KIQ7+k8jeY1vPzSD/fvWFt kVn2E8FmeJ9bVu9Ct+9BefLgamKGDhzKsqzdo= 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=/s1NCaBgaR1Mh4y4V4KzOLykG3kt4daVbxVk2mEUcfY=; b=N3yg9lYaXLC69FzbYzG4U0ZX1+TmGNMnXmRXOdVTyzuP8Nm9KskXxsguISXZzOLGvS tcqc+MB6GXKVrwiUqS7GylEXmxWnzUqxSx3U9dUEY3U9nnW5kYaaJ0heA4K4/5vUMG/c lo8sShjZ3EfgPZNsBraIAF2D3Fc2ZBAfOooWkmdrqsml5UiRuLFehVgdwOqts6s46ROu bf36C9xO/METroacZ4+XZq1GuZ5KxyzacHFxLyIRPapqkGZSESw0ZjjNEWQ21joH8H0h aOmAF/9YzBYz7QbzTL5wTha18lmcC6IFWrUw0XXQbrgo9ZL3YtX59RougVZFx1K+PzT5 9N3w== X-Gm-Message-State: ALyK8tK/PazqOQwJ5KwZCp2kXSPmoYrasCb7cws4qLklnSRaEPEw5f8KGvRSurDf9/5bqei7 X-Received: by 10.194.157.38 with SMTP id wj6mr14721145wjb.75.1467795308443; Wed, 06 Jul 2016 01:55:08 -0700 (PDT) Received: from localhost.localdomain (cpc84731-aztw28-2-0-cust112.18-1.cable.virginm.net. [82.37.67.113]) by smtp.gmail.com with ESMTPSA id 66sm5363803wmg.23.2016.07.06.01.55.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jul 2016 01:55:07 -0700 (PDT) From: Peter Griffin To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@stlinux.com, vinod.koul@intel.com, patrice.chotard@st.com, bjorn.andersson@linaro.org, ohad@wizery.com Subject: [PATCH v6 18/18] remoteproc: core: Retry rproc_fw_config_virtio() if !rproc->table_ptr Date: Wed, 6 Jul 2016 09:54:36 +0100 Message-Id: <1467795276-21725-19-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467795276-21725-1-git-send-email-peter.griffin@linaro.org> References: <1467795276-21725-1-git-send-email-peter.griffin@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160706_015530_702648_B773DE66 X-CRM114-Status: GOOD ( 16.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.griffin@linaro.org, dmaengine@vger.kernel.org, lee.jones@linaro.org, devicetree@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When rproc drivers are built-in the async firmware load done by rproc_add() can fail due to the firmware not being present. Subsqeuent calls to rproc_fw_boot() then fail, even though by this point firmware has been successfully obtained. This patch changes the behaviour to re-execute rproc_fw_config_virtio() in rproc_fw_boot() if it has previously failed, and we are sure it is now available. Signed-off-by: Peter Griffin --- drivers/remoteproc/remoteproc_core.c | 25 +++++++++++++++++++------ drivers/remoteproc/remoteproc_internal.h | 3 +++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index db3958b..749f261 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -801,8 +801,12 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) struct resource_table *table, *loaded_table; int ret, tablesz; + /* + * This can happen when built-in if initial async fw load fails. + * However we now have firmware available so retry. + */ if (!rproc->table_ptr) - return -ENOMEM; + rproc_fw_config_virtio(fw, rproc); ret = rproc_fw_sanity_check(rproc, fw); if (ret) @@ -895,9 +899,20 @@ clean_up: * to unregister the device. one other option is just to use kref here, * that might be cleaner). */ -static void rproc_fw_config_virtio(const struct firmware *fw, void *context) + +static void rproc_fw_config_virtio_cb(const struct firmware *fw, void *context) { struct rproc *rproc = context; + + rproc_fw_config_virtio(fw, rproc); + + release_firmware(fw); + /* allow rproc_del() contexts, if any, to proceed */ + complete_all(&rproc->firmware_loading_complete); +} + +static void rproc_fw_config_virtio(const struct firmware *fw, struct rproc *rproc) +{ struct resource_table *table; int ret, tablesz; @@ -934,9 +949,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) ret = rproc_handle_resources(rproc, tablesz, rproc_vdev_handler); out: - release_firmware(fw); - /* allow rproc_del() contexts, if any, to proceed */ - complete_all(&rproc->firmware_loading_complete); + return; } static int rproc_add_virtio_devices(struct rproc *rproc) @@ -956,7 +969,7 @@ static int rproc_add_virtio_devices(struct rproc *rproc) */ ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, rproc->firmware, &rproc->dev, GFP_KERNEL, - rproc, rproc_fw_config_virtio); + rproc, rproc_fw_config_virtio_cb); if (ret < 0) { dev_err(&rproc->dev, "request_firmware_nowait err: %d\n", ret); complete_all(&rproc->firmware_loading_complete); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 57e1de5..39916c1 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -49,6 +49,9 @@ struct rproc_fw_ops { void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); int rproc_boot_nowait(struct rproc *rproc); +static void rproc_fw_config_virtio_cb(const struct firmware *fw, void *context); +static void rproc_fw_config_virtio(const struct firmware *fw, struct rproc *rproc); + /* from remoteproc_virtio.c */ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);