diff mbox

[v6,18/18] remoteproc: core: Retry rproc_fw_config_virtio() if !rproc->table_ptr

Message ID 1467795276-21725-19-git-send-email-peter.griffin@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Griffin July 6, 2016, 8:54 a.m. UTC
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 <peter.griffin@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c     | 25 +++++++++++++++++++------
 drivers/remoteproc/remoteproc_internal.h |  3 +++
 2 files changed, 22 insertions(+), 6 deletions(-)

Comments

kernel test robot July 7, 2016, 1:25 a.m. UTC | #1
Hi,

[auto build test WARNING on robh/for-next]
[also build test WARNING on v4.7-rc6 next-20160706]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Griffin/Add-support-for-FDMA-DMA-controller-and-slim-core-rproc-found-on-STi-chipsets/20160706-170304
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: openrisc-allyesconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=openrisc 

All warnings (new ones prefixed by >>):

>> drivers/remoteproc/remoteproc_internal.h:52:13: warning: 'rproc_fw_config_virtio_cb' declared 'static' but never defined
>> drivers/remoteproc/remoteproc_internal.h:53:13: warning: 'rproc_fw_config_virtio' declared 'static' but never defined
--
   drivers/remoteproc/st_slim_rproc.c: In function 'slim_rproc_alloc':
   drivers/remoteproc/st_slim_rproc.c:288:10: warning: assignment discards qualifiers from pointer target type
   drivers/remoteproc/st_slim_rproc.c: At top level:
>> drivers/remoteproc/remoteproc_internal.h:52:13: warning: 'rproc_fw_config_virtio_cb' declared 'static' but never defined
>> drivers/remoteproc/remoteproc_internal.h:53:13: warning: 'rproc_fw_config_virtio' declared 'static' but never defined

vim +52 drivers/remoteproc/remoteproc_internal.h

    46	};
    47	
    48	/* from remoteproc_core.c */
    49	void rproc_release(struct kref *kref);
    50	irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
    51	int rproc_boot_nowait(struct rproc *rproc);
  > 52	static void rproc_fw_config_virtio_cb(const struct firmware *fw, void *context);
  > 53	static void rproc_fw_config_virtio(const struct firmware *fw, struct rproc *rproc);
    54	
    55	
    56	/* from remoteproc_virtio.c */

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Peter Griffin July 7, 2016, 10:20 a.m. UTC | #2
Hi,

On Thu, 07 Jul 2016, kbuild test robot wrote:

> Hi,
> 
> [auto build test WARNING on robh/for-next]
> [also build test WARNING on v4.7-rc6 next-20160706]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Peter-Griffin/Add-support-for-FDMA-DMA-controller-and-slim-core-rproc-found-on-STi-chipsets/20160706-170304
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> config: openrisc-allyesconfig (attached as .config)
> compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=openrisc 
> 
> All warnings (new ones prefixed by >>):
> 
> >> drivers/remoteproc/remoteproc_internal.h:52:13: warning: 'rproc_fw_config_virtio_cb' declared 'static' but never defined
> >> drivers/remoteproc/remoteproc_internal.h:53:13: warning:
> >> 'rproc_fw_config_virtio' declared 'static' but never defined

Will fix this in next version.

regards,

Peter.
Lee Jones Aug. 5, 2016, 12:52 p.m. UTC | #3
On Wed, 06 Jul 2016, Peter Griffin wrote:

> 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 <peter.griffin@linaro.org>
> ---
>  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);

It's probably better to "hold that thought" on this patch, since we're
going to make resource tables optional.  I'm keen to tackle this
issue, but need to work a few other things before doing so.

Current task list:
 - Amend/supply new resource table from platform-specific drivers
 - Make resource tables optional
 - Obtain firmwares from the root file system
 - Lots more here including; co-proc DT support, co-proc console, etc

[...]
diff mbox

Patch

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);