public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs
@ 2026-04-17  2:36 Maxwell Doose
  2026-04-17  5:25 ` Dan Carpenter
  2026-04-17 14:02 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Maxwell Doose @ 2026-04-17  2:36 UTC (permalink / raw)
  To: tsbogend; +Cc: gregkh, linux-mips, linux-kernel, linux-staging

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.

Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
 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(-)

diff --git a/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
index 042a6bc44b5c..4cf4060df48c 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
@@ -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
diff --git a/arch/mips/include/asm/octeon/cvmx-cmd-queue.h b/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
index 67e1b2162b19..faef98173a4f 100644
--- a/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
+++ b/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
@@ -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_t
 							   int 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))
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs
  2026-04-17  2:36 [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs Maxwell Doose
@ 2026-04-17  5:25 ` Dan Carpenter
  2026-04-17 13:16   ` Maxwell Doose
  2026-04-17 14:02 ` Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2026-04-17  5:25 UTC (permalink / raw)
  To: Maxwell Doose; +Cc: tsbogend, gregkh, linux-mips, linux-kernel, linux-staging

On Thu, Apr 16, 2026 at 09:36:02PM -0500, Maxwell Doose wrote:
> 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.
> 

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs
  2026-04-17  5:25 ` Dan Carpenter
@ 2026-04-17 13:16   ` Maxwell Doose
  0 siblings, 0 replies; 5+ messages in thread
From: Maxwell Doose @ 2026-04-17 13:16 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: tsbogend, gregkh, linux-mips, linux-kernel, linux-staging

On Fri, Apr 17, 2026 at 12:25 AM Dan Carpenter <error27@gmail.com> wrote:
>
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs
  2026-04-17  2:36 [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs Maxwell Doose
  2026-04-17  5:25 ` Dan Carpenter
@ 2026-04-17 14:02 ` Dan Carpenter
  2026-04-17 14:45   ` Maxwell Doose
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2026-04-17 14:02 UTC (permalink / raw)
  To: Maxwell Doose; +Cc: tsbogend, gregkh, linux-mips, linux-kernel, linux-staging

On Thu, Apr 16, 2026 at 09:36:02PM -0500, Maxwell Doose wrote:
> diff --git a/arch/mips/include/asm/octeon/cvmx-cmd-queue.h b/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
> index 67e1b2162b19..faef98173a4f 100644
> --- a/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
> +++ b/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
> @@ -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

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

[ snip]

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs
  2026-04-17 14:02 ` Dan Carpenter
@ 2026-04-17 14:45   ` Maxwell Doose
  0 siblings, 0 replies; 5+ messages in thread
From: Maxwell Doose @ 2026-04-17 14:45 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: tsbogend, gregkh, linux-mips, linux-kernel, linux-staging

On Fri, Apr 17, 2026 at 9:02 AM Dan Carpenter <error27@gmail.com> wrote:
>
> 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.

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-17 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17  2:36 [PATCH] mips: cavium-octeon: remove cmd queue state and related typedefs Maxwell Doose
2026-04-17  5:25 ` Dan Carpenter
2026-04-17 13:16   ` Maxwell Doose
2026-04-17 14:02 ` Dan Carpenter
2026-04-17 14:45   ` Maxwell Doose

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox