From 89970d28cb3fd1c678f769d62d077c10ec5340e1 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sun, 30 Jun 2013 11:07:13 +0300 Subject: remoteproc: fix error return code in rproc_fw_boot() Set 'ret' to -EINVAL when needed, so a sensible return value is returned on errors. Signed-off-by: Wei Yongjun [fix additional instances of this bug as well, update commit log] Signed-off-by: Ohad Ben-Cohen --- drivers/remoteproc/remoteproc_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 022dc635d01e..7e33536b5c2b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -815,18 +815,17 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) } rproc->bootaddr = rproc_get_boot_addr(rproc, fw); + ret = -EINVAL; /* look for the resource table */ table = rproc_find_rsc_table(rproc, fw, &tablesz); if (!table) { - ret = -EINVAL; goto clean_up; } /* Verify that resource table in loaded fw is unchanged */ if (rproc->table_csum != crc32(0, table, tablesz)) { dev_err(dev, "resource checksum failed, fw changed?\n"); - ret = -EINVAL; goto clean_up; } @@ -852,8 +851,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) * copy this information to device memory. */ loaded_table = rproc_find_loaded_rsc_table(rproc, fw); - if (!loaded_table) + if (!loaded_table) { + ret = -EINVAL; goto clean_up; + } memcpy(loaded_table, rproc->cached_table, tablesz); -- cgit v1.2.3 From 57971159208757a37d44356764911703468a7ca3 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Sun, 30 Jun 2013 11:33:05 +0300 Subject: remoteproc: fix checkpatch errors in remoteproc code This patch fixes relevant checkpatch errors and warnings in the remoteproc source files. Signed-off-by: Suman Anna [drop 80-char-lines checkpatch fixes and update commit log accordingly] Signed-off-by: Ohad Ben-Cohen --- drivers/remoteproc/remoteproc_debugfs.c | 3 +-- drivers/remoteproc/remoteproc_internal.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c index 157a57309601..9d30809bb407 100644 --- a/drivers/remoteproc/remoteproc_debugfs.c +++ b/drivers/remoteproc/remoteproc_debugfs.c @@ -248,6 +248,5 @@ void __init rproc_init_debugfs(void) void __exit rproc_exit_debugfs(void) { - if (rproc_dbg) - debugfs_remove(rproc_dbg); + debugfs_remove(rproc_dbg); } diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 157e762c1571..70701a50ddfa 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -107,12 +107,12 @@ struct resource_table *rproc_find_rsc_table(struct rproc *rproc, static inline struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, - const struct firmware *fw) + const struct firmware *fw) { if (rproc->fw_ops->find_loaded_rsc_table) return rproc->fw_ops->find_loaded_rsc_table(rproc, fw); - return NULL; + return NULL; } extern const struct rproc_fw_ops rproc_elf_fw_ops; -- cgit v1.2.3 From e4760363ea14b7b707ba68ab780c8ecf98a84c15 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 1 Jul 2013 15:30:51 +0300 Subject: remoteproc/omap: fix a sparse warning This patch fixes a sparse warning in the omap remoteproc code when OMAP_REMOTEPROC is disabled. include/linux/platform_data/remoteproc-omap.h:76:13: warning: symbol 'omap_rproc_reserve_cma' was not declared. Should it be static? Signed-off-by: Suman Anna Signed-off-by: Ohad Ben-Cohen --- include/linux/platform_data/remoteproc-omap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/platform_data/remoteproc-omap.h b/include/linux/platform_data/remoteproc-omap.h index 3c1c6444ec4b..bfbd12b41162 100644 --- a/include/linux/platform_data/remoteproc-omap.h +++ b/include/linux/platform_data/remoteproc-omap.h @@ -50,7 +50,7 @@ void __init omap_rproc_reserve_cma(void); #else -void __init omap_rproc_reserve_cma(void) +static inline void __init omap_rproc_reserve_cma(void) { } -- cgit v1.2.3 From b6356a013a0933e42556c2def806f06caf459acf Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 1 Jul 2013 17:01:56 +0300 Subject: remoteproc: free carveout memories only after unmapping them It is not preferable to have the allocated pages for carveout memories freed before they are unmapped. The code that deals with the cleanup of carveout memories is therefore moved after the corresponding mapping entries were cleaned up. This is mostly a no-op since the remote processors are already stopped when the cleanup function is called, but this will make the cleanup code follow the exact reverse path of allocation. Signed-off-by: Suman Anna Signed-off-by: Ohad Ben-Cohen --- drivers/remoteproc/remoteproc_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7e33536b5c2b..9fef20022ab4 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -762,13 +762,6 @@ static void rproc_resource_cleanup(struct rproc *rproc) kfree(entry); } - /* clean up carveout allocations */ - list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { - dma_free_coherent(dev->parent, entry->len, entry->va, entry->dma); - list_del(&entry->node); - kfree(entry); - } - /* clean up iommu mapping entries */ list_for_each_entry_safe(entry, tmp, &rproc->mappings, node) { size_t unmapped; @@ -783,6 +776,13 @@ static void rproc_resource_cleanup(struct rproc *rproc) list_del(&entry->node); kfree(entry); } + + /* clean up carveout allocations */ + list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { + dma_free_coherent(dev->parent, entry->len, entry->va, entry->dma); + list_del(&entry->node); + kfree(entry); + } } /* -- cgit v1.2.3 From 95cee62cb4776a65229a6b6d5969be56589d95c1 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Mon, 1 Jul 2013 17:23:58 +0300 Subject: remoteproc: Cocci spatch "memdup.spatch" Use kmemdup instead of kmalloc + memcpy. Signed-off-by: Thomas Meyer Signed-off-by: Ohad Ben-Cohen --- drivers/remoteproc/remoteproc_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9fef20022ab4..3cd85a638afa 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -914,11 +914,10 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) * will be stored in the cached_table. Before the device is started, * cached_table will be copied into devic memory. */ - rproc->cached_table = kmalloc(tablesz, GFP_KERNEL); + rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); if (!rproc->cached_table) goto out; - memcpy(rproc->cached_table, table, tablesz); rproc->table_ptr = rproc->cached_table; /* count the number of notify-ids */ -- cgit v1.2.3