mips: cavium-octeon: remove cmd queue state and related typedefs
PATCH 1/1 mips: cavium-octeon: remove cmd queue state and related typedefs
This change removes the cmd queue state typedefs to work towards the "code cleanup" task in the staging's TODO, and aligns the codebase further with the Linux Kernel Code Style.
The following structs are affected:
- __cvmx_cmd_queue_state_t (now struct __cvmx_cmd_queue_state)
- __cvmx_cmd_queue_all_state_t (now struct __cvmx_cmd_queue_all_state)
In addition, the global exported pointer __cvmx_cmd_queue_state_ptr has also been updated to use the new names, and its extern statement in cvmx-cmd-queue.h has been moved to the top of the file to satisfy the requirements for EXPORT_SYMBOL_GPL.
---
note: This patch is a part of a continued effort to remove abiguous typedefs across the cavium-octeon/octeon codebase.
.../cavium-octeon/executive/cvmx-cmd-queue.c | 8 ++--- arch/mips/include/asm/octeon/cvmx-cmd-queue.h | 32 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-)
arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c +4 -4
@@ -46,7 +46,7 @@* This application uses this pointer to access the global queue * state. It points to a bootmem named block. */ -__cvmx_cmd_queue_all_state_t *__cvmx_cmd_queue_state_ptr; +struct __cvmx_cmd_queue_all_state *__cvmx_cmd_queue_state_ptr;EXPORT_SYMBOL_GPL (__cvmx_cmd_queue_state_ptr);/*
@@ -109,7 +109,7 @@ cvmx_cmd_queue_result_t cvmx_cmd_queue_initialize(cvmx_cmd_queue_id_t queue_id, int max_depth, int fpa_pool, int pool_size) { - __cvmx_cmd_queue_state_t *qstate; + struct __cvmx_cmd_queue_state *qstate;cvmx_cmd_queue_result_t result =__cvmx_cmd_queue_init_state_ptr ();if (result !=CVMX_CMD_QUEUE_SUCCESS )return result;
@@ -202,7 +202,7 @@ cvmx_cmd_queue_result_t cvmx_cmd_queue_initialize(cvmx_cmd_queue_id_t queue_id,*/ cvmx_cmd_queue_result_t cvmx_cmd_queue_shutdown (cvmx_cmd_queue_id_t queue_id) { -__cvmx_cmd_queue_state_t *qptr =__cvmx_cmd_queue_get_state (queue_id); +struct __cvmx_cmd_queue_state *qptr =__cvmx_cmd_queue_get_state (queue_id);if (qptr ==NULL ) {cvmx_dprintf ("ERROR: cvmx_cmd_queue_shutdown: Unable to " "get queue information.\n" );
@@ -295,7 +295,7 @@ int cvmx_cmd_queue_length(cvmx_cmd_queue_id_t queue_id)*/ void *cvmx_cmd_queue_buffer (cvmx_cmd_queue_id_t queue_id) { -__cvmx_cmd_queue_state_t *qptr =__cvmx_cmd_queue_get_state (queue_id); +struct __cvmx_cmd_queue_state *qptr =__cvmx_cmd_queue_get_state (queue_id);if (qptr && qptr->base_ptr_div128)return cvmx_phys_to_ptr ((uint64_t ) qptr->base_ptr_div128 <<7 );else
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +18 -14
@@ -71,6 +71,12 @@* */ +/* Global pointer to the state of command the queues +* Moved here to satisfy requirements in cvmx-cmd-queue.c for EXPORT_SYMBOL_GPL +*/ +extern struct __cvmx_cmd_queue_all_state + *__cvmx_cmd_queue_state_ptr; +#ifndef __CVMX_CMD_QUEUE_H__#define __CVMX_CMD_QUEUE_H__
@@ -125,7 +131,7 @@ typedef enum {CVMX_CMD_QUEUE_ALREADY_SETUP =-4 , } cvmx_cmd_queue_result_t; -typedef struct { +struct __cvmx_cmd_queue_state {/* You have lock when this is your ticket */ uint8_t now_serving;uint64_t unused1:24 ;
@@ -140,7 +146,7 @@ typedef struct { uint64_t pool_size_m1:13;/* Number of commands already used in buffer */ uint64_t index:13; -} __cvmx_cmd_queue_state_t; +};/** * This structure contains the global state of all command queues.
@@ -150,10 +156,10 @@ typedef struct {* ll/sc used to get a ticket. If this is not the case, the update * of queue state causes the ll/sc to fail quite often. */ -typedef struct { +struct __cvmx_cmd_queue_all_state {uint64_t ticket[(CVMX_CMD_QUEUE_END >>16 ) *256 ]; -__cvmx_cmd_queue_state_t state[(CVMX_CMD_QUEUE_END >>16 ) *256 ]; -}__cvmx_cmd_queue_all_state_t ; +struct __cvmx_cmd_queue_state state[(CVMX_CMD_QUEUE_END >>16 ) *256 ]; +};/** * Initialize a command queue for use. The initial FPA buffer is
@@ -234,10 +240,8 @@ static inline int __cvmx_cmd_queue_get_index(cvmx_cmd_queue_id_t queue_id)* @qptr: Pointer to the queue's global state */ static inline void __cvmx_cmd_queue_lock (cvmx_cmd_queue_id_t queue_id, -__cvmx_cmd_queue_state_t *qptr) +struct __cvmx_cmd_queue_state *qptr) { -extern __cvmx_cmd_queue_all_state_t - *__cvmx_cmd_queue_state_ptr;int tmp;int my_ticket;prefetch (qptr);
@@ -286,7 +290,7 @@ static inline void __cvmx_cmd_queue_lock(cvmx_cmd_queue_id_t queue_id,* * @qptr: Queue to unlock */ -static inline void __cvmx_cmd_queue_unlock (__cvmx_cmd_queue_state_t *qptr) +static inline void __cvmx_cmd_queue_unlock (struct __cvmx_cmd_queue_state *qptr) { qptr->now_serving++;CVMX_SYNCWS ;
@@ -299,10 +303,10 @@ static inline void __cvmx_cmd_queue_unlock(__cvmx_cmd_queue_state_t *qptr)* * Returns Queue structure or NULL on failure */ -static inline __cvmx_cmd_queue_state_t +static inline struct __cvmx_cmd_queue_state *__cvmx_cmd_queue_get_state (cvmx_cmd_queue_id_t queue_id) { -extern __cvmx_cmd_queue_all_state_t +extern struct __cvmx_cmd_queue_all_state *__cvmx_cmd_queue_state_ptr;return &__cvmx_cmd_queue_state_ptr-> state[__cvmx_cmd_queue_get_index (queue_id)];
@@ -329,7 +333,7 @@ static inline cvmx_cmd_queue_result_t cvmx_cmd_queue_write(cvmx_cmd_queue_id_tint cmd_count, uint64_t *cmds) { - __cvmx_cmd_queue_state_t *qptr = __cvmx_cmd_queue_get_state(queue_id); + struct __cvmx_cmd_queue_state *qptr = __cvmx_cmd_queue_get_state(queue_id);/* Make sure nobody else is updating the same queue */ if (likely (use_locking))
@@ -427,7 +431,7 @@ static inline cvmx_cmd_queue_result_t cvmx_cmd_queue_write2(cvmx_cmd_queue_id_t uint64_t cmd1, uint64_t cmd2) { -__cvmx_cmd_queue_state_t *qptr =__cvmx_cmd_queue_get_state (queue_id); +struct __cvmx_cmd_queue_state *qptr =__cvmx_cmd_queue_get_state (queue_id);/* Make sure nobody else is updating the same queue */ if (likely (use_locking))
@@ -528,7 +532,7 @@ static inline cvmx_cmd_queue_result_t cvmx_cmd_queue_write3(cvmx_cmd_queue_id_t uint64_t cmd2, uint64_t cmd3) { -__cvmx_cmd_queue_state_t *qptr =__cvmx_cmd_queue_get_state (queue_id); +struct __cvmx_cmd_queue_state *qptr =__cvmx_cmd_queue_get_state (queue_id);/* Make sure nobody else is updating the same queue */ if (likely (use_locking))
Signature · 1 line
2.53.0
Quoted 6 lines · Maxwell Doose
This change removes the cmd queue state typedefs to work towards the "code cleanup" task in the staging's TODO, and aligns the codebase further with the Linux Kernel Code Style.
The following structs are affected:
Quoted 8 lines
-
__cvmx_cmd_queue_state_t(now struct__cvmx_cmd_queue_state)
-__cvmx_cmd_queue_all_state_t(now struct__cvmx_cmd_queue_all_state)In addition, the global exported pointer
__cvmx_cmd_queue_state_ptrhas also been updated to use the new names, and its extern statement incvmx-cmd-queue.hhas been moved to the top of the file to satisfy the requirements forEXPORT_SYMBOL_GPL.
This should be two different patches. Is there no way to move the variable declarations around first and then get rid of the typedef?
regards,
dan carpenter
Quoted 7 lines · Dan Carpenter
This should be two different patches. Is there no way to move the variable declarations around first and then get rid of the typedef?
regards,
dan carpenter
When I was test-compiling the patch yesterday, sparse raised a "should it be static?" error, and that was resolved by moving the extern for the __cvmx_queue_state_ptr in the header to the top of the file.
best regards,
maxwell doose
Quoted 5 lines · Maxwell Doose
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +0
-0
arch/mips/include/asm/octeon/cvmx-cmd-queue.h line 79
Quoted 9 lines
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +6
-0@@ -71,6 +71,12 @@* */ +/* Global pointer to the state of command the queues +* Moved here to satisfy requirements in cvmx-cmd-queue.c for EXPORT_SYMBOL_GPL +*/ +extern struct __cvmx_cmd_queue_all_state + *__cvmx_cmd_queue_state_ptr; +
This is arch/mips/ and that's a different tree from staging with different maintainers. Generally, the rest of the kernel doesn't like churn so I probably wouldn't send patches like this one for arch/mips/.
This comment isn't accurate. This is a Sparse thing and nothing to do with EXPORT_SYMBOL_GPL.
Normally we would decare variables like this in a header file, sure. I guess the original authors wanted make absolutely sure no one ever used this variable so they declared as an extern in __cvmx_cmd_queue_state_ptr() __cvmx_cmd_queue_get_state(). It's unusual and paranoid but I can't think of another reason why they would do it. Generally, outside of staging, you just go along with whatever the original author wanted. They did the work after all, so they get to decide.
This patch removes the declaration in __cvmx_cmd_queue_state_ptr() but leaves it in __cvmx_cmd_queue_get_state(). We definitely can't do that. And we can't mix this in with a remove typedefs patch.
regards,
dan carpenter
arch/mips/include/asm/octeon/cvmx-cmd-queue.h static inline int __cvmx_cmd_queue_get_index(cvmx_cmd_queue_id_t queue_id) · line 240
Quoted 9 lines
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +1
-3@@ -234,10 +240,8 @@ static inline int __cvmx_cmd_queue_get_index(cvmx_cmd_queue_id_t queue_id)* @qptr: Pointer to the queue's global state */ static inline void __cvmx_cmd_queue_lock (cvmx_cmd_queue_id_t queue_id, -__cvmx_cmd_queue_state_t *qptr) +struct __cvmx_cmd_queue_state *qptr) { -extern __cvmx_cmd_queue_all_state_t - *__cvmx_cmd_queue_state_ptr;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 3 lines
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +0
-0int tmp;int my_ticket;prefetch (qptr);
[ snip]
arch/mips/include/asm/octeon/cvmx-cmd-queue.h static inline void __cvmx_cmd_queue_unlock(__cvmx_cmd_queue_state_t *qptr) · line 310
Quoted 11 lines
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +2
-2@@ -299,10 +303,10 @@ static inline void __cvmx_cmd_queue_unlock(__cvmx_cmd_queue_state_t *qptr)* * Returns Queue structure or NULL on failure */ -static inline __cvmx_cmd_queue_state_t +static inline struct __cvmx_cmd_queue_state *__cvmx_cmd_queue_get_state (cvmx_cmd_queue_id_t queue_id) { -extern __cvmx_cmd_queue_all_state_t +extern struct __cvmx_cmd_queue_all_state *__cvmx_cmd_queue_state_ptr;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines
arch/mips/include/asm/octeon/cvmx-cmd-queue.h +0
-0return &__cvmx_cmd_queue_state_ptr-> state[__cvmx_cmd_queue_get_index (queue_id)];
Quoted 4 lines · Dan Carpenter
Generally, outside of staging, you just go along with whatever the original author wanted. They did the work after all, so they get to decide.
Sorry about that, still figuring out the workflow. I agree, the way they did this is...interesting, to say the least, but if I try this again I'll drop the extern move.
Quoted 3 lines
This patch removes the declaration in
__cvmx_cmd_queue_state_ptr()but leaves it in__cvmx_cmd_queue_get_state(). We definitely can't do that. And we can't mix this in with a remove typedefs patch.
Thanks for pointing that out, I must've missed it. If I try again I'll fix it but given that this is mips and this stuff is usually for staging, it's going to be unlikely unless a maintainer wants it.
thanks,
maxwell