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: 71429 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp754871qgy; Wed, 6 Jul 2016 01:55:36 -0700 (PDT) X-Received: by 10.98.157.135 with SMTP id a7mr40443538pfk.117.1467795336355; Wed, 06 Jul 2016 01:55:36 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si3112558paf.153.2016.07.06.01.55.36; Wed, 06 Jul 2016 01:55:36 -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 S1753758AbcGFIze (ORCPT + 30 others); Wed, 6 Jul 2016 04:55:34 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36114 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753594AbcGFIzJ (ORCPT ); Wed, 6 Jul 2016 04:55:09 -0400 Received: by mail-wm0-f51.google.com with SMTP id f126so165221766wma.1 for ; Wed, 06 Jul 2016 01:55:09 -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=NQ82Alz6u9erWt0RTN01RfXN+QD2crtIXORhD+GB4+L1ik+4x8ev+HVeIVpanrcW7m R7oZ2wF51VV4zHAeoXEt4CD1Wr+VI8kGELPyhxgsOG2hIBnm+nortcG94jy3EINvwqaL kJJZTV+ZmyJ7cLKBtxfXy8/J46frle54z+L7ceLjpkxHRQjmCnvHTMMlkatLEOHxkVAr Fih2vWmenmJn2NKNwvlwIZ47iRDubwPaJbHXVtnBXHIabM9JBrHozTCGIH9/emxgKjUI hAoHqZ/xL2aV7iPjBNIavp0eKVs6SjIkbcMQQnEAN6SW0T/ExCPE9bqhtmhnlWWe4VM+ WYiQ== X-Gm-Message-State: ALyK8tI6NUAzAG2/i62+9axHrTliT4QSfgmTvbucdte9LN7IvL+aPdOp3OkVaNphvx0PmP1k 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 Cc: peter.griffin@linaro.org, lee.jones@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.9.1 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);