soc: ti: keystone/k3 navigator queue/dma/ringacc cleanups
Nishanth Menon
maintainercover soc: ti: keystone/k3 navigator queue/dma/ringacc cleanups
Fix W=2 (clang/gcc), sparse, smatch and coccinelle warnings. No functional changes.
Tested: NFS boot (via nav subsystem) on k2l-evm, k2hk-evm and k2g-evm based on next-20260507:
https://gist.github.com/nmenon/6c4a4cae646462f2d3856fac5846098b
Nishanth Menon (11):
soc: ti: knav_qmss: Remove remaining redundant ENOMEM printks
soc: ti: knav_qmss: Rename global kdev to knav_qdev to fix -Wshadow
soc: ti: knav_qmss: Inline lockdep condition in for_each_handle_rcu
soc: ti: knav_qmss: Fix kernel-doc Return: tags
soc: ti: knav_qmss: Use %pe to print PTR_ERR()
soc: ti: knav_qmss: Fix __iomem annotations and __be32 type
soc: ti: knav_qmss_acc: Fix kernel-doc Return: tag
soc: ti: knav_dma: Remove unused DMA_PRIO_MASK macro
soc: ti: knav_dma: Remove dead check on unsigned args.args[0]
soc: ti: knav_dma: Use IOMEM_ERR_PTR() in pktdma_get_regs()
soc: ti: k3-ringacc: Use str_enabled_disabled() helper
drivers/soc/ti/k3-ringacc.c | 3 +- drivers/soc/ti/knav_dma.c | 8 +- drivers/soc/ti/knav_qmss_acc.c | 2 +- drivers/soc/ti/knav_qmss_queue.c | 148 +++++++++++++++---------------- 4 files changed, 74 insertions(+), 87 deletions(-)
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 1/11 soc: ti: knav_qmss: Remove remaining redundant ENOMEM printks
Commit 168d2fb78055 ("soc: ti: knav_qmss: Remove ENOMEM printks") removed redundant dev_err() calls after allocation failures in knav_queue_setup_regions, knav_queue_init_qmgrs and knav_queue_init_pdsps, but missed three further instances in knav_pool_create, knav_queue_setup_region and knav_setup_queue_range.
Remove the missed instances.
---
Cc: Krzysztof Kozlowski <[email protected]>
drivers/soc/ti/knav_qmss_queue.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/soc/ti/knav_qmss_queue.c +3 -9
@@ -769,10 +769,8 @@ void *knav_pool_create(const char *name,return ERR_PTR (-ENODEV ); pool =devm_kzalloc (kdev->dev,sizeof (*pool),GFP_KERNEL ); -if (!pool) { -dev_err (kdev->dev,"out of memory allocating pool\n" ); +if (!pool)return ERR_PTR (-ENOMEM ); - }for_each_region (kdev, reg_itr) {if (reg_itr->id != region_id)
@@ -1025,10 +1023,8 @@ static void knav_queue_setup_region(struct knav_device *kdev, region->dma_end = region->dma_start + size; pool =devm_kzalloc (kdev->dev,sizeof (*pool),GFP_KERNEL ); -if (!pool) { -dev_err (kdev->dev,"out of memory allocating dummy pool\n" ); +if (!pool) goto fail; - } pool->num_desc =0 ; pool->region_offset = region->num_desc;list_add (&pool->region_inst, ®ion->pools);
@@ -1211,10 +1207,8 @@ static int knav_setup_queue_range(struct knav_device *kdev,int ret, i; range =devm_kzalloc (dev,sizeof (*range),GFP_KERNEL ); -if (!range) { -dev_err (dev,"out of memory allocating range\n" ); +if (!range)return -ENOMEM ; - } range->kdev = kdev; range->name =knav_queue_find_name (node);
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 2/11 soc: ti: knav_qmss: Rename global kdev to knav_qdev to fix -Wshadow
In reply to Nishanth MenonBuilding with W=2 (clang, LLVM=1) produces 22 -Wshadow warnings in knav_qmss_queue.c because the file-scoped singleton 'kdev' is shadowed by a parameter of the same name in 21 internal functions and one local variable, e.g.:
knav_qmss_queue.c:194:49: warning: declaration shadows a variable in the global scope [-Wshadow]
194 | knav_queue_match_id_to_inst(struct knav_device *kdev, unsigned id)
Rename the global singleton from kdev to knav_qdev rather than renaming all ~21 function parameters, as this requires fewer changes and leaves function signatures, struct field accesses, and header macros in knav_qmss.h untouched.
--- drivers/soc/ti/knav_qmss_queue.c | 94 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 47 deletions(-)
drivers/soc/ti/knav_qmss_queue.c +47 -47
@@ -25,7 +25,7 @@#include "knav_qmss.h" -static struct knav_device *kdev; +static struct knav_device *knav_qdev;static DEFINE_MUTEX (knav_dev_lock);#define knav_dev_lock_held () \ lockdep_is_held(&knav_dev_lock)
@@ -205,10 +205,10 @@ knav_queue_match_id_to_inst(struct knav_device *kdev, unsigned id)static inline struct knav_queue_inst *knav_queue_find_by_id (int id) { -if (kdev->base_id <= id && - kdev->base_id + kdev->num_queues > id) { - id -= kdev->base_id; -return knav_queue_match_id_to_inst (kdev, id); +if (knav_qdev->base_id <= id && + knav_qdev->base_id + knav_qdev->num_queues > id) { + id -= knav_qdev->base_id; +return knav_queue_match_id_to_inst (knav_qdev, id); }return NULL ; }
@@ -296,7 +296,7 @@ static struct knav_queue *knav_queue_open_by_type(const char *name,mutex_lock (&knav_dev_lock); -for_each_instance (idx, inst, kdev) { +for_each_instance (idx, inst, knav_qdev) {if (knav_queue_is_reserved (inst))continue ;if (!knav_queue_match_type (inst, type))
@@ -469,9 +469,9 @@ static int knav_queue_debug_show(struct seq_file *s, void *v)mutex_lock (&knav_dev_lock);seq_printf (s,"%s: %u-%u\n" , -dev_name (kdev->dev), kdev->base_id, - kdev->base_id + kdev->num_queues -1 ); -for_each_instance (idx, inst, kdev) +dev_name (knav_qdev->dev), knav_qdev->base_id, + knav_qdev->base_id + knav_qdev->num_queues -1 ); +for_each_instance (idx, inst, knav_qdev)knav_queue_debug_show_instance (s, inst);mutex_unlock (&knav_dev_lock);
@@ -762,17 +762,17 @@ void *knav_pool_create(const char *name,unsigned last_offset;int ret; -if (!kdev) +if (!knav_qdev)return ERR_PTR (-EPROBE_DEFER ); -if (!kdev->dev) +if (!knav_qdev->dev)return ERR_PTR (-ENODEV ); - pool =devm_kzalloc (kdev->dev,sizeof (*pool),GFP_KERNEL ); + pool =devm_kzalloc (knav_qdev->dev,sizeof (*pool),GFP_KERNEL );if (!pool)return ERR_PTR (-ENOMEM ); -for_each_region (kdev, reg_itr) { +for_each_region (knav_qdev, reg_itr) {if (reg_itr->id != region_id)continue ; region = reg_itr;
@@ -780,14 +780,14 @@ void *knav_pool_create(const char *name, }if (!region) { -dev_err (kdev->dev,"region-id(%d) not found\n" , region_id); +dev_err (knav_qdev->dev,"region-id(%d) not found\n" , region_id); ret = -EINVAL ; goto err; } pool->queue =knav_queue_open (name,KNAV_QUEUE_GP ,0 );if (IS_ERR (pool->queue)) { -dev_err (kdev->dev, +dev_err (knav_qdev->dev,"failed to open queue for pool(%s), error %ld\n" , name,PTR_ERR (pool->queue)); ret =PTR_ERR (pool->queue);
@@ -795,13 +795,13 @@ void *knav_pool_create(const char *name, } pool->name =kstrndup (name,KNAV_NAME_SIZE -1 ,GFP_KERNEL ); - pool->kdev = kdev; - pool->dev = kdev->dev; + pool->kdev = knav_qdev; + pool->dev = knav_qdev->dev;mutex_lock (&knav_dev_lock);if (num_desc > (region->num_desc - region->used_desc)) { -dev_err (kdev->dev,"out of descs in region(%d) for pool(%s)\n" , +dev_err (knav_qdev->dev,"out of descs in region(%d) for pool(%s)\n" , region_id, name); ret = -ENOMEM ; goto err_unlock;
@@ -827,10 +827,10 @@ void *knav_pool_create(const char *name, pool->num_desc = num_desc; pool->region_offset = last_offset; region->used_desc += num_desc; -list_add_tail (&pool->list, &kdev->pools); +list_add_tail (&pool->list, &knav_qdev->pools);list_add_tail (&pool->region_inst, node); }else { -dev_err (kdev->dev,"pool(%s) create failed: fragmented desc pool in region(%d)\n" , +dev_err (knav_qdev->dev,"pool(%s) create failed: fragmented desc pool in region(%d)\n" , name, region_id); ret = -ENOMEM ; goto err_unlock;
@@ -844,7 +844,7 @@ void *knav_pool_create(const char *name,mutex_unlock (&knav_dev_lock); err:kfree (pool->name); -devm_kfree (kdev->dev, pool); +devm_kfree (knav_qdev->dev, pool);return ERR_PTR (ret); }EXPORT_SYMBOL_GPL (knav_pool_create);
@@ -872,7 +872,7 @@ void knav_pool_destroy(void *ph)mutex_unlock (&knav_dev_lock);kfree (pool->name); -devm_kfree (kdev->dev, pool); +devm_kfree (knav_qdev->dev, pool); }EXPORT_SYMBOL_GPL (knav_pool_destroy);
@@ -1683,7 +1683,7 @@ static inline struct knav_qmgr_info *knav_find_qmgr(unsigned id) {struct knav_qmgr_info *qmgr; -for_each_qmgr (kdev, qmgr) { +for_each_qmgr (knav_qdev, qmgr) {if ((id >= qmgr->start_queue) && (id < qmgr->start_queue + qmgr->num_queues))return qmgr;
@@ -1775,22 +1775,22 @@ static int knav_queue_probe(struct platform_device *pdev)return -ENODEV ; } - kdev =devm_kzalloc (dev,sizeof (struct knav_device ),GFP_KERNEL ); -if (!kdev) { + knav_qdev =devm_kzalloc (dev,sizeof (struct knav_device ),GFP_KERNEL ); +if (!knav_qdev) {dev_err (dev,"memory allocation failed\n" );return -ENOMEM ; }if (device_get_match_data (dev)) - kdev->version =QMSS_66AK2G ; + knav_qdev->version =QMSS_66AK2G ; -platform_set_drvdata (pdev, kdev); - kdev->dev = dev; -INIT_LIST_HEAD (&kdev->queue_ranges); -INIT_LIST_HEAD (&kdev->qmgrs); -INIT_LIST_HEAD (&kdev->pools); -INIT_LIST_HEAD (&kdev->regions); -INIT_LIST_HEAD (&kdev->pdsps); +platform_set_drvdata (pdev, knav_qdev); + knav_qdev->dev = dev; +INIT_LIST_HEAD (&knav_qdev->queue_ranges); +INIT_LIST_HEAD (&knav_qdev->qmgrs); +INIT_LIST_HEAD (&knav_qdev->pools); +INIT_LIST_HEAD (&knav_qdev->regions); +INIT_LIST_HEAD (&knav_qdev->pdsps);pm_runtime_enable (&pdev->dev); ret =pm_runtime_resume_and_get (&pdev->dev);
@@ -1805,31 +1805,31 @@ static int knav_queue_probe(struct platform_device *pdev) ret = -ENODEV ; goto err; } - kdev->base_id = temp[0 ]; - kdev->num_queues = temp[1 ]; + knav_qdev->base_id = temp[0 ]; + knav_qdev->num_queues = temp[1 ];/* Initialize queue managers using device tree configuration */ - ret =knav_queue_init_qmgrs (kdev, node); + ret =knav_queue_init_qmgrs (knav_qdev, node);if (ret) goto err;/* get pdsp configuration values from device tree */ - ret =knav_queue_setup_pdsps (kdev, node); + ret =knav_queue_setup_pdsps (knav_qdev, node);if (ret) goto err;/* get usable queue range values from device tree */ - ret =knav_setup_queue_pools (kdev, node); + ret =knav_setup_queue_pools (knav_qdev, node);if (ret) goto err; - ret =knav_get_link_ram (kdev,"linkram0" , &kdev->link_rams[0 ]); + ret =knav_get_link_ram (knav_qdev,"linkram0" , &knav_qdev->link_rams[0 ]);if (ret) { -dev_err (kdev->dev,"could not setup linking ram\n" ); +dev_err (knav_qdev->dev,"could not setup linking ram\n" ); goto err; } - ret =knav_get_link_ram (kdev,"linkram1" , &kdev->link_rams[1 ]); + ret =knav_get_link_ram (knav_qdev,"linkram1" , &knav_qdev->link_rams[1 ]);if (ret) {/* * nothing really, we have one linking ram already, so we just
@@ -1837,15 +1837,15 @@ static int knav_queue_probe(struct platform_device *pdev)*/ } - ret =knav_queue_setup_link_ram (kdev); + ret =knav_queue_setup_link_ram (knav_qdev);if (ret) goto err; - ret =knav_queue_setup_regions (kdev, node); + ret =knav_queue_setup_regions (knav_qdev, node);if (ret) goto err; - ret =knav_queue_init_queues (kdev); + ret =knav_queue_init_queues (knav_qdev);if (ret <0 ) {dev_err (dev,"hwqueue initialization failed\n" ); goto err;
@@ -1857,9 +1857,9 @@ static int knav_queue_probe(struct platform_device *pdev)return 0 ; err: -knav_queue_stop_pdsps (kdev); -knav_queue_free_regions (kdev); -knav_free_queue_ranges (kdev); +knav_queue_stop_pdsps (knav_qdev); +knav_queue_free_regions (knav_qdev); +knav_free_queue_ranges (knav_qdev);pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);return ret;
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 3/11 soc: ti: knav_qmss: Inline lockdep condition in for_each_handle_rcu
In reply to Nishanth Menonknav_dev_lock_held() is a single-use wrapper around lockdep_is_held(&knav_dev_lock), used only as the lockdep condition in for_each_handle_rcu. When CONFIG_LOCKDEP is disabled, list_for_each_entry_rcu() elides the condition argument entirely, causing clang to report the macro as unused with W=2:
knav_qmss_queue.c:30:9: warning: macro is not used [-Wunused-macros] 30 | #define knav_dev_lock_held() \
Remove the intermediate macro and open-code lockdep_is_held() directly in the for_each_handle_rcu definition.
--- drivers/soc/ti/knav_qmss_queue.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/soc/ti/knav_qmss_queue.c +1 -4
@@ -27,9 +27,6 @@static struct knav_device *knav_qdev;static DEFINE_MUTEX (knav_dev_lock); -#define knav_dev_lock_held () \ - lockdep_is_held(&knav_dev_lock) -/* Queue manager register indices in DTS */ #define KNAV_QUEUE_PEEK_REG_INDEX 0#define KNAV_QUEUE_STATUS_REG_INDEX 1
@@ -58,7 +55,7 @@ static DEFINE_MUTEX(knav_dev_lock);#define for_each_handle_rcu (qh, inst) \ list_for_each_entry_rcu(qh, &inst->handles, list, \ - knav_dev_lock_held()) + lockdep_is_held(&knav_dev_lock))#define for_each_instance (idx, inst, kdev) \ for (idx = 0, inst = kdev->instances; \
Signature · 1 line
2.47.0
Re: [PATCH 03/11] soc: ti: knav_qmss: Inline lockdep condition in for_each_handle_rcu
Quoted 3 lines · Nishanth Menon
knav_dev_lock_held()is a single-use wrapper aroundlockdep_is_held(&knav_dev_lock), used only as the lockdep condition infor_each_handle_rcu. WhenCONFIG_LOCKDEPis disabled,
Is it when CONFIG_LOCKDEP is disabled, or is it when CONFIG_PROVE_RCU_LIST is disabled the condition argument is ignored?
Anyway, good to zap this single-use macro, so
Quoted 37 lines
list_for_each_entry_rcu()elides the condition argument entirely, causing clang to report the macro as unused with W=2:knav_qmss_queue.c:30:9: warning: macro is not used [-Wunused-macros] 30 | #define
knav_dev_lock_held()\Remove the intermediate macro and open-code
lockdep_is_held()directly in thefor_each_handle_rcudefinition.Signed-off-by Nishanth Menon <[email protected]>--- drivers/soc/ti/knav_qmss_queue.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/soc/ti/knav_qmss_queue.c +1
-4@@ -27,9 +27,6 @@static struct knav_device *knav_qdev;static DEFINE_MUTEX (knav_dev_lock); -#define knav_dev_lock_held () \ - lockdep_is_held(&knav_dev_lock) -/* Queue manager register indices in DTS */ #define KNAV_QUEUE_PEEK_REG_INDEX 0#define KNAV_QUEUE_STATUS_REG_INDEX 1@@ -58,7 +55,7 @@ static DEFINE_MUTEX(knav_dev_lock);#define for_each_handle_rcu (qh, inst) \ list_for_each_entry_rcu(qh, &inst->handles, list, \ - knav_dev_lock_held()) + lockdep_is_held(&knav_dev_lock))#define for_each_instance (idx, inst, kdev) \ for (idx = 0, inst = kdev->instances; \
Nishanth Menon
maintainerRe: [PATCH 03/11] soc: ti: knav_qmss: Inline lockdep condition in for_each_handle_rcu
Quoted 7 lines · Andrew Davis
Quoted 3 lines · Nishanth Menon
knav_dev_lock_held()is a single-use wrapper aroundlockdep_is_held(&knav_dev_lock), used only as the lockdep condition infor_each_handle_rcu. WhenCONFIG_LOCKDEPis disabled,Is it when
CONFIG_LOCKDEPis disabled, or is it whenCONFIG_PROVE_RCU_LISTis disabled the condition argument is ignored?
Gaah, you are right.. CONFIG_PROVE_RCU_LIST.. will respin with the fix once all other patches have had a chance to cook in the list.
Thanks for catching, I miss took things there.
Signature · 4 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D https://ti.com/opensource
Nishanth Menon
maintainerPATCH 4/11 soc: ti: knav_qmss: Fix kernel-doc Return: tags
In reply to Nishanth MenonFix functions that use inline 'Returns ...' instead of 'Return:' kernel-doc comments, producing warnings with W=2:
knav_qmss_queue.c:524: No description found for return value of 'knav_queue_open'
---
Cc: Randy Dunlap <[email protected]>
drivers/soc/ti/knav_qmss_queue.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/soc/ti/knav_qmss_queue.c +11 -10
@@ -517,7 +517,7 @@ static int knav_queue_flush(struct knav_queue *qh)* Subsequent attempts to open a shared queue should * also have this flag. * -* Returns a handle to the open hardware queue if successful. Use IS_ERR() +* Return: handle to the open hardware queue on success. Use IS_ERR() * to check the returned value for error codes. */ void *knav_queue_open(const char *name, unsigned id,
@@ -573,7 +573,7 @@ EXPORT_SYMBOL_GPL(knav_queue_close);* @cmd: - control commands * @arg: - command argument * -* Returns 0 on success, errno otherwise. +* Return: 0 on success, errno otherwise. */ int knav_queue_device_control (void *qhandle,enum knav_queue_ctrl_cmd cmd,unsigned long arg)
@@ -625,7 +625,7 @@ EXPORT_SYMBOL_GPL(knav_queue_device_control);* @size: - size of data to push * @flags: - can be used to pass additional information * -* Returns 0 on success, errno otherwise. +* Return: 0 on success, errno otherwise. */ int knav_queue_push (void *qhandle,dma_addr_t dma,unsigned size,unsigned flags)
@@ -646,7 +646,7 @@ EXPORT_SYMBOL_GPL(knav_queue_push);* @qhandle: - hardware queue handle * @size: - (optional) size of the data pop'ed. * -* Returns a DMA address on success, 0 on failure. +* Return: DMA address on success, 0 on failure. */ dma_addr_t knav_queue_pop (void *qhandle,unsigned *size) {
@@ -747,8 +747,8 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_dma_to_virt);* @region_id: - QMSS region id from which the descriptors are to be * allocated. * -* Returns a pool handle on success. -* Use IS_ERR_OR_NULL() to identify error values on return. +* Return: pool handle on success. Use IS_ERR_OR_NULL() to identify +* error values on return. */ void *knav_pool_create (const char *name,int num_desc,int region_id)
@@ -878,7 +878,7 @@ EXPORT_SYMBOL_GPL(knav_pool_destroy);* knav_pool_desc_get() - Get a descriptor from the pool * @ph: - pool handle * -* Returns descriptor from the pool. +* Return: descriptor from the pool on success, error pointer otherwise. */ void *knav_pool_desc_get (void *ph) {
@@ -917,7 +917,7 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_put);* @dma: - DMA address return pointer * @dma_sz: - adjusted return pointer * -* Returns 0 on success, errno otherwise. +* Return: 0 on success, errno otherwise. */ int knav_pool_desc_map (void *ph,void *desc,unsigned size,dma_addr_t *dma,unsigned *dma_sz)
@@ -942,7 +942,7 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_map);* @dma: - DMA address of descriptor to unmap * @dma_sz: - size of descriptor to unmap * -* Returns descriptor address on success, Use IS_ERR_OR_NULL() to identify +* Return: descriptor address on success. Use IS_ERR_OR_NULL() to identify * error values on return. */ void *knav_pool_desc_unmap (void *ph,dma_addr_t dma,unsigned dma_sz)
@@ -962,7 +962,8 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_unmap);/** * knav_pool_count() - Get the number of descriptors in pool. * @ph: - pool handle -* Returns number of elements in the pool. +* +* Return: number of elements in the pool. */ int knav_pool_count (void *ph) {
Signature · 1 line
2.47.0
Re: [PATCH 04/11] soc: ti: knav_qmss: Fix kernel-doc Return: tags
Quoted 7 lines · Nishanth Menon
Fix functions that use inline 'Returns ...' instead of 'Return:' kernel-doc comments, producing warnings with W=2:
knav_qmss_queue.c:524: No description found for return value of '
knav_queue_open'Signed-off-by Nishanth Menon <[email protected]>
Thanks.
Quoted 94 lines
---
Cc: Randy Dunlap <[email protected]>drivers/soc/ti/knav_qmss_queue.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)drivers/soc/ti/knav_qmss_queue.c +11
-10@@ -517,7 +517,7 @@ static int knav_queue_flush(struct knav_queue *qh)* Subsequent attempts to open a shared queue should * also have this flag. * -* Returns a handle to the open hardware queue if successful. Use IS_ERR() +* Return: handle to the open hardware queue on success. Use IS_ERR() * to check the returned value for error codes. */ void *knav_queue_open(const char *name, unsigned id,@@ -573,7 +573,7 @@ EXPORT_SYMBOL_GPL(knav_queue_close);* @cmd: - control commands * @arg: - command argument * -* Returns 0 on success, errno otherwise. +* Return: 0 on success, errno otherwise. */ int knav_queue_device_control (void *qhandle,enum knav_queue_ctrl_cmd cmd,unsigned long arg)@@ -625,7 +625,7 @@ EXPORT_SYMBOL_GPL(knav_queue_device_control);* @size: - size of data to push * @flags: - can be used to pass additional information * -* Returns 0 on success, errno otherwise. +* Return: 0 on success, errno otherwise. */ int knav_queue_push (void *qhandle,dma_addr_t dma,unsigned size,unsigned flags)@@ -646,7 +646,7 @@ EXPORT_SYMBOL_GPL(knav_queue_push);* @qhandle: - hardware queue handle * @size: - (optional) size of the data pop'ed. * -* Returns a DMA address on success, 0 on failure. +* Return: DMA address on success, 0 on failure. */ dma_addr_t knav_queue_pop (void *qhandle,unsigned *size) {@@ -747,8 +747,8 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_dma_to_virt);* @region_id: - QMSS region id from which the descriptors are to be * allocated. * -* Returns a pool handle on success. -* Use IS_ERR_OR_NULL() to identify error values on return. +* Return: pool handle on success. Use IS_ERR_OR_NULL() to identify +* error values on return. */ void *knav_pool_create (const char *name,int num_desc,int region_id)@@ -878,7 +878,7 @@ EXPORT_SYMBOL_GPL(knav_pool_destroy);* knav_pool_desc_get() - Get a descriptor from the pool * @ph: - pool handle * -* Returns descriptor from the pool. +* Return: descriptor from the pool on success, error pointer otherwise. */ void *knav_pool_desc_get (void *ph) {@@ -917,7 +917,7 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_put);* @dma: - DMA address return pointer * @dma_sz: - adjusted return pointer * -* Returns 0 on success, errno otherwise. +* Return: 0 on success, errno otherwise. */ int knav_pool_desc_map (void *ph,void *desc,unsigned size,dma_addr_t *dma,unsigned *dma_sz)@@ -942,7 +942,7 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_map);* @dma: - DMA address of descriptor to unmap * @dma_sz: - size of descriptor to unmap * -* Returns descriptor address on success, Use IS_ERR_OR_NULL() to identify +* Return: descriptor address on success. Use IS_ERR_OR_NULL() to identify * error values on return. */ void *knav_pool_desc_unmap (void *ph,dma_addr_t dma,unsigned dma_sz)@@ -962,7 +962,8 @@ EXPORT_SYMBOL_GPL(knav_pool_desc_unmap);/** * knav_pool_count() - Get the number of descriptors in pool. * @ph: - pool handle -* Returns number of elements in the pool. +* +* Return: number of elements in the pool. */ int knav_pool_count (void *ph) {
Signature · 1 line
~Randy
Nishanth Menon
maintainerPATCH 5/11 soc: ti: knav_qmss: Use %pe to print PTR_ERR()
In reply to Nishanth MenonCoccinelle (scripts/coccinelle/misc/ptr_err_to_pe.cocci) flags the dev_err() call in knav_pool_create():
knav_qmss_queue.c:789:9-16: WARNING: Consider using %pe to print PTR_ERR()
Replace the %ld / PTR_ERR() pair with %pe and pass the error pointer directly to also print the symbolic error name.
--- drivers/soc/ti/knav_qmss_queue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/ti/knav_qmss_queue.c +2 -2
@@ -785,8 +785,8 @@ void *knav_pool_create(const char *name, pool->queue =knav_queue_open (name,KNAV_QUEUE_GP ,0 );if (IS_ERR (pool->queue)) {dev_err (knav_qdev->dev, -"failed to open queue for pool(%s), error %ld\n" , - name,PTR_ERR (pool->queue)); +"failed to open queue for pool(%s), error %pe\n" , + name, pool->queue); ret =PTR_ERR (pool->queue); goto err; }
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 6/11 soc: ti: knav_qmss: Fix __iomem annotations and __be32 type
In reply to Nishanth MenonFix several address-space and type annotation issues reported by sparse:
- Fix knav_queue_pdsp_wait() declaration: correct the parameter annotation from 'u32 * __iomem' (pointer-in-iomem-space) to 'u32 __iomem *' (pointer-to-iomem); use 'unsigned int' for the timeout parameter instead of bare 'unsigned'; fix the continuation- line alignment. Cast the void __iomem * argument at the call site that passes pdsp->command.
- Use IOMEM_ERR_PTR() in knav_queue_map_reg() instead of ERR_PTR() when returning an error as void __iomem * to avoid 'different address spaces' warnings.
- Annotate the firmware data array as 'const __be32 *' instead of 'u32 *', as be32_to_cpu() requires __be32 input.
--- drivers/soc/ti/knav_qmss_queue.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/soc/ti/knav_qmss_queue.c +6 -6
@@ -477,8 +477,8 @@ static int knav_queue_debug_show(struct seq_file *s, void *v)DEFINE_SHOW_ATTRIBUTE (knav_queue_debug); -static inline int knav_queue_pdsp_wait (u32 *__iomem addr,unsigned timeout, -u32 flags) +static inline int knav_queue_pdsp_wait (u32 __iomem *addr,unsigned int timeout, +u32 flags) {unsigned long end;u32 val =0 ;
@@ -1368,7 +1368,7 @@ static void __iomem *knav_queue_map_reg(struct knav_device *kdev,if (ret) {dev_err (kdev->dev,"Can't translate of node(%pOFn) address for index(%d)\n" , node, index); -return ERR_PTR (ret); +return IOMEM_ERR_PTR (ret); } regs =devm_ioremap_resource (kdev->dev, &res);
@@ -1556,7 +1556,7 @@ static int knav_queue_load_pdsp(struct knav_device *kdev,int i, ret, fwlen;const struct firmware *fw;bool found = false; -u32 *fwdata; +const __be32 *fwdata;for (i =0 ; i <ARRAY_SIZE (knav_acc_firmwares); i++) {if (knav_acc_firmwares[i]) {
@@ -1580,7 +1580,7 @@ static int knav_queue_load_pdsp(struct knav_device *kdev,writel_relaxed (pdsp->id +1 , pdsp->command +0x18 );/* download the firmware */ - fwdata = (u32 *)fw->data; + fwdata = (const __be32 *)fw->data; fwlen = (fw->size +sizeof (u32) -1 ) /sizeof (u32);for (i =0 ; i < fwlen; i++)writel_relaxed (be32_to_cpu (fwdata[i]), pdsp->iram + i);
@@ -1610,7 +1610,7 @@ static int knav_queue_start_pdsp(struct knav_device *kdev,writel_relaxed (val, &pdsp->regs->control);/* wait for command register to clear */ - ret =knav_queue_pdsp_wait (pdsp->command, timeout,0 ); + ret =knav_queue_pdsp_wait ((u32 __iomem *)pdsp->command, timeout,0 );if (ret <0 ) { dev_err(kdev->dev, "timed out on pdsp %s command register wait\n",
Signature · 1 line
2.47.0
Re: [PATCH 06/11] soc: ti: knav_qmss: Fix __iomem annotations and __be32 type
Quoted 62 lines · Nishanth Menon
Fix several address-space and type annotation issues reported by sparse:
- Fix
knav_queue_pdsp_wait()declaration: correct the parameter annotation from 'u32 *__iomem' (pointer-in-iomem-space) to 'u32__iomem*' (pointer-to-iomem); use 'unsigned int' for the timeout parameter instead of bare 'unsigned'; fix the continuation- line alignment. Cast the void__iomem* argument at the call site that passespdsp->command.
- UseIOMEM_ERR_PTR()inknav_queue_map_reg()instead ofERR_PTR()when returning an error as void__iomem* to avoid 'different address spaces' warnings.
- Annotate the firmware data array as 'const__be32*' instead of 'u32 *', asbe32_to_cpu()requires__be32input.Signed-off-by Nishanth Menon <[email protected]>--- drivers/soc/ti/knav_qmss_queue.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/soc/ti/knav_qmss_queue.c +5
-5@@ -477,8 +477,8 @@ static int knav_queue_debug_show(struct seq_file *s, void *v)DEFINE_SHOW_ATTRIBUTE (knav_queue_debug); -static inline int knav_queue_pdsp_wait (u32 *__iomem addr,unsigned timeout, -u32 flags) +static inline int knav_queue_pdsp_wait (u32 __iomem *addr,unsigned int timeout, +u32 flags) {unsigned long end;u32 val =0 ;@@ -1368,7 +1368,7 @@ static void __iomem *knav_queue_map_reg(struct knav_device *kdev,if (ret) {dev_err (kdev->dev,"Can't translate of node(%pOFn) address for index(%d)\n" , node, index); -return ERR_PTR (ret); +return IOMEM_ERR_PTR (ret); } regs =devm_ioremap_resource (kdev->dev, &res);@@ -1556,7 +1556,7 @@ static int knav_queue_load_pdsp(struct knav_device *kdev,int i, ret, fwlen;const struct firmware *fw;bool found = false; -u32 *fwdata; +const __be32 *fwdata;for (i =0 ; i <ARRAY_SIZE (knav_acc_firmwares); i++) {if (knav_acc_firmwares[i]) {@@ -1580,7 +1580,7 @@ static int knav_queue_load_pdsp(struct knav_device *kdev,writel_relaxed (pdsp->id +1 , pdsp->command +0x18 );/* download the firmware */ - fwdata = (u32 *)fw->data; + fwdata = (const __be32 *)fw->data; fwlen = (fw->size +sizeof (u32) -1 ) /sizeof (u32);for (i =0 ; i < fwlen; i++)writel_relaxed (be32_to_cpu (fwdata[i]), pdsp->iram + i);
drivers/soc/ti/knav_qmss_queue.c static int knav_queue_start_pdsp(struct knav_device *kdev, · line 1613
Quoted 5 lines
drivers/soc/ti/knav_qmss_queue.c +1
-1@@ -1610,7 +1610,7 @@ static int knav_queue_start_pdsp(struct knav_device *kdev,writel_relaxed (val, &pdsp->regs->control);/* wait for command register to clear */ - ret =knav_queue_pdsp_wait (pdsp->command, timeout,0 ); + ret =knav_queue_pdsp_wait ((u32 __iomem *)pdsp->command, timeout,0 );
Why not make command's type u32 __iomem * instead of casting it when used?
Andrew
Quoted 3 lines
drivers/soc/ti/knav_qmss_queue.c +0
-0if (ret <0 ) { dev_err(kdev->dev, "timed out on pdsp %s command register wait\n",
Nishanth Menon
maintainerRe: [PATCH 06/11] soc: ti: knav_qmss: Fix __iomem annotations and __be32 type
On 12:14-20260508, Andrew Davis wrote:
[...]
Quoted 6 lines
drivers/soc/ti/knav_qmss_queue.c static int knav_queue_start_pdsp(struct knav_device *kdev, · line 1613
Quoted 4 lines
writel_relaxed(val, &pdsp->regs->control); /* wait for command register to clear */drivers/soc/ti/knav_qmss_queue.c +1
-1- ret =knav_queue_pdsp_wait (pdsp->command, timeout,0 ); + ret =knav_queue_pdsp_wait ((u32 __iomem *)pdsp->command, timeout,0 );Why not make
command's typeu32 __iomem *instead of casting it when used?
pdsp->command is __iomem *, from what I see, from devm_io_remap_resource(), writel/readl_relaxed and other usage where void __iomem* is used with command, and arithmetic used across the code, __iomem * is intentional, except for this case. i did think of making knav_queue_pdsp_wait take iomem, but that'd weaken what the strict checking of a single u32 reg access it does.. this approach looked the better of the alternatives.
Signature · 4 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D https://ti.com/opensource
Re: [PATCH 06/11] soc: ti: knav_qmss: Fix __iomem annotations and __be32 type
Quoted 10 lines · Nishanth Menon
On 12:14-20260508, Andrew Davis wrote:
[...]Quoted 6 lines
drivers/soc/ti/knav_qmss_queue.c static int knav_queue_start_pdsp(struct knav_device *kdev, · line 1613
Quoted 4 lines
writel_relaxed(val, &pdsp->regs->control); /* wait for command register to clear */drivers/soc/ti/knav_qmss_queue.c +1
-1- ret =knav_queue_pdsp_wait (pdsp->command, timeout,0 ); + ret =knav_queue_pdsp_wait ((u32 __iomem *)pdsp->command, timeout,0 );Why not make
command's typeu32 __iomem *instead of casting it when used?
pdsp->commandis__iomem*, from what I see, from
It is a "void", should be "u32", that is why you are having to cast here, not the iomem part.
Andrew
Quoted 7 lines
devm_io_remap_resource(), writel/readl_relaxed and other usage where void __iomem* is used with command, and arithmetic used across the code,__iomem* is intentional, except for this case. i did think of makingknav_queue_pdsp_waittake iomem, but that'd weaken what the strict checking of a single u32 reg access it does.. this approach looked the better of the alternatives.
Nishanth Menon
maintainerPATCH 7/11 soc: ti: knav_qmss_acc: Fix kernel-doc Return: tag
In reply to Nishanth MenonFix knav_init_acc_range() use of 'Return ...' instead of 'Return:' kernel-doc comment, which produces a warning with W=2:
knav_qmss_acc.c:473: No description found for return value of 'knav_init_acc_range'
---
Cc: Randy Dunlap <[email protected]>
drivers/soc/ti/knav_qmss_acc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/ti/knav_qmss_acc.c +1 -1
@@ -466,7 +466,7 @@ static const struct knav_range_ops knav_acc_range_ops = {* @node: device node * @range: qmms range information * -* Return 0 on success or error +* Return: 0 on success, errno otherwise. */ int knav_init_acc_range(struct knav_device *kdev, struct device_node *node,
Signature · 1 line
2.47.0
Re: [PATCH 07/11] soc: ti: knav_qmss_acc: Fix kernel-doc Return: tag
Quoted 7 lines · Nishanth Menon
Fix
knav_init_acc_range()use of 'Return ...' instead of 'Return:' kernel-doc comment, which produces a warning with W=2:knav_qmss_acc.c:473: No description found for return value of '
knav_init_acc_range'Signed-off-by Nishanth Menon <[email protected]>
Thanks.
Quoted 19 lines
---
Cc: Randy Dunlap <[email protected]>drivers/soc/ti/knav_qmss_acc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/ti/knav_qmss_acc.c +1
-1@@ -466,7 +466,7 @@ static const struct knav_range_ops knav_acc_range_ops = {* @node: device node * @range: qmms range information * -* Return 0 on success or error +* Return: 0 on success, errno otherwise. */ int knav_init_acc_range(struct knav_device *kdev, struct device_node *node,
Signature · 1 line
~Randy
Nishanth Menon
maintainerPATCH 8/11 soc: ti: knav_dma: Remove unused DMA_PRIO_MASK macro
In reply to Nishanth MenonDMA_PRIO_MASK (GENMASK(3, 0)) is defined alongside the other priority macros but is never referenced in the code. tx_priority and rx_priority are only ever assigned DMA_PRIO_DEFAULT (0) and are never sourced from device tree or user-controlled input, so no out-of-range value is possible. W=2 builds report:
knav_dma.c:32:9: warning: macro is not used [-Wunused-macros]
32 | #define DMA_PRIO_MASK GENMASK(3, 0)
Remove the dead macro.
--- drivers/soc/ti/knav_dma.c | 1 - 1 file changed, 1 deletion(-)
drivers/soc/ti/knav_dma.c +0 -1
@@ -29,7 +29,6 @@#define DMA_TX_FILT_EINFO BIT(30)#define DMA_TX_PRIO_SHIFT 0#define DMA_RX_PRIO_SHIFT 16 -#define DMA_PRIO_MASK GENMASK(3, 0)#define DMA_PRIO_DEFAULT 0#define DMA_RX_TIMEOUT_DEFAULT 17500/* cycles */ #define DMA_RX_TIMEOUT_MASK GENMASK(16, 0)
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 9/11 soc: ti: knav_dma: Remove dead check on unsigned args.args[0]
In reply to Nishanth Menonsmatch warns:
knav_dma.c:390 of_channel_match_helper() warn: unsigned 'args.args[0]' is never less than zero.
of_phandle_args.args[] is uint32_t, so the 'args.args[0] < 0' check is always false. of_parse_phandle_with_fixed_args() already handles errors by returning a non-zero code, which is checked immediately above. Remove the dead check.
--- drivers/soc/ti/knav_dma.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/soc/ti/knav_dma.c +0 -5
@@ -387,11 +387,6 @@ static int of_channel_match_helper(struct device_node *np, const char *name,return -ENODEV ; } -if (args.args[0 ] <0 ) { -dev_err (kdev->dev,"Missing args for %s\n" , name); -return -ENODEV ; - } -return args.args[0 ]; }
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 10/11 soc: ti: knav_dma: Use IOMEM_ERR_PTR() in pktdma_get_regs()
In reply to Nishanth Menonpktdma_get_regs() returns a void __iomem * but uses ERR_PTR() on the error path, causing sparse to warn about an address space mismatch. Replace ERR_PTR() with IOMEM_ERR_PTR() to resolve the warning cleanly.
--- drivers/soc/ti/knav_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/ti/knav_dma.c +1 -1
@@ -520,7 +520,7 @@ static void __iomem *pktdma_get_regs(struct knav_dma_device *dma,if (ret) {dev_err (dev,"Can't translate of node(%pOFn) address for index(%d)\n" , node, index); -return ERR_PTR (ret); +return IOMEM_ERR_PTR (ret); } regs =devm_ioremap_resource (kdev->dev, &res);
Signature · 1 line
2.47.0
Nishanth Menon
maintainerPATCH 11/11 soc: ti: k3-ringacc: Use str_enabled_disabled() helper
In reply to Nishanth MenonCoccinelle (scripts/coccinelle/api/string_choices.cocci) flags an opportunity to replace the open-coded ternary expression in the probe dev_info() call:
k3-ringacc.c:1439:3-32: opportunity for str_enabled_disabled(ringacc->dma_ring_reset_quirk)
Replace the ternary with str_enabled_disabled() and add the required include for <linux/string_choices.h>.
--- drivers/soc/ti/k3-ringacc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soc/ti/k3-ringacc.c +2 -1
@@ -10,6 +10,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/string_choices.h> #include <linux/sys_soc.h> #include <linux/dma/ti-cppi5.h> #include <linux/soc/ti/k3-ringacc.h>
@@ -1436,7 +1437,7 @@ static int k3_ringacc_init(struct platform_device *pdev, ringacc->rm_gp_range->desc[0 ].num, ringacc->tisci_dev_id);dev_info (dev,"dma-ring-reset-quirk: %s\n" , - ringacc->dma_ring_reset_quirk ?"enabled" :"disabled" ); +str_enabled_disabled (ringacc->dma_ring_reset_quirk));dev_info (dev,"RA Proxy rev. %08x, num_proxies:%u\n" ,readl (&ringacc->proxy_gcfg->revision), ringacc->num_proxies);
Signature · 1 line
2.47.0