drivers: staging: wilc1000: Replace message queue with standard Linux lists
PATCH 1/2 drivers: staging: wilc1000: Replace message queue with standard Linux lists
- The message queue is replaced with standard Linux linked list
- kmem_cache is used for list members
- A check for return value of receive method is added
- GFP_ATOMIC is changed to GFP_KERNEL
- A few other related minor changes
---
- Comments of Dan Carpenter are taken care
- If receive method return value not checked, case statement for previous message may get executed if not done
- Indication of usage of 'kmem_cache' is added to the description
- Memory allocation donw outside spin_lock; GFP_ATOMIC replaced with GFP_KERNEL
- spin_lock, spin_unlock are matched
- goto statements removed
- Unrelated changes moved to a different patch
- PRINT_ERR can be taken up in a seperate patch
drivers/staging/wilc1000/host_interface.c | 7 ++- drivers/staging/wilc1000/wilc_msgqueue.c | 73 +++++++++++++------------------ drivers/staging/wilc1000/wilc_platform.h | 5 ++- 3 files changed, 40 insertions(+), 45 deletions(-)
drivers/staging/wilc1000/host_interface.c +6 -1
@@ -4304,11 +4304,16 @@ static int hostIFthread(void *pvArg)u32 u32Ret;struct host_if_msg msg;tstrWILC_WFIDrv *pstrWFIDrv; +int ret;memset (&msg,0 ,sizeof (struct host_if_msg ));while (1 ) { -wilc_mq_recv (&gMsgQHostIF, &msg,sizeof (struct host_if_msg ), &u32Ret); + ret =wilc_mq_recv (&gMsgQHostIF, &msg, +sizeof (struct host_if_msg ), &u32Ret); +if (ret) +continue ; + pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;if (msg.id ==HOST_IF_MSG_EXIT ) {PRINT_D (GENERIC_DBG ,"THREAD: Exiting HostIfThread\n" );
drivers/staging/wilc1000/wilc_msgqueue.c +31 -42
142 lines not on this page · raw message
drivers/staging/wilc1000/wilc_platform.h +3 -2
@@ -20,7 +20,7 @@typedef struct __Message_struct {void *pvBuffer;u32 u32Length; -struct __Message_struct *pstrNext; +struct list_head link; }Message ; typedef struct __MessageQueue_struct {
@@ -28,7 +28,8 @@ typedef struct __MessageQueue_struct {spinlock_t strCriticalSection;bool bExiting;u32 u32ReceiversCount; -Message *pstrMessageList; +struct list_head msg_list_head; +struct kmem_cache *msg_cache; } WILC_MsgQueueHandle;
Signature · 1 line
2.1.4
PATCH 2/2 drivers: staging: wilc1000: wilc_msgqueue.c: Remove code that no effect
--- drivers/staging/wilc1000/wilc_msgqueue.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/staging/wilc1000/wilc_msgqueue.c +0 -5
@@ -133,11 +133,6 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,down (&pHandle->hSem);/* other non-timeout scenarios */ -if (result) { -PRINT_ER ("Non-timeout\n" ); -return result; - } -if (pHandle->bExiting) {PRINT_ER ("pHandle fail\n" );return -EFAULT ;
Signature · 1 line
2.1.4
PATCH 2/2 drivers: staging: wilc1000: wilc_msgqueue.c: Remove ineffective code
--- drivers/staging/wilc1000/wilc_msgqueue.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/staging/wilc1000/wilc_msgqueue.c +0 -5
@@ -133,11 +133,6 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,down (&pHandle->hSem);/* other non-timeout scenarios */ -if (result) { -PRINT_ER ("Non-timeout\n" ); -return result; - } -if (pHandle->bExiting) {PRINT_ER ("pHandle fail\n" );return -EFAULT ;
Signature · 1 line
2.1.4
Re: [PATCH 2/2] drivers: staging: wilc1000: wilc_msgqueue.c: Remove code that no effect
In reply to Chandra S GorentlaPlease do not review this. This is duplicate to -
[PATCH 2/2] drivers: staging: wilc1000: wilc_msgqueue.c: Remove ineffective code
Quoted 24 lines · Chandra S Gorentla
Signed-off-by Chandra S Gorentla <[email protected]>--- drivers/staging/wilc1000/wilc_msgqueue.c | 5 ----- 1 file changed, 5 deletions(-)drivers/staging/wilc1000/wilc_msgqueue.c +0
-5@@ -133,11 +133,6 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,down (&pHandle->hSem);/* other non-timeout scenarios */ -if (result) { -PRINT_ER ("Non-timeout\n" ); -return result; - } -if (pHandle->bExiting) {PRINT_ER ("pHandle fail\n" );return -EFAULT ;Signature · 1 line
2.1.4
Greg KH
maintainerRe: [PATCH 2/2] drivers: staging: wilc1000: wilc_msgqueue.c: Remove code that no effect
Quoted 2 lines · Chandra Gorentla
Please do not review this. This is duplicate to -
[PATCH 2/2] drivers: staging: wilc1000:wilc_msgqueue.c: Remove ineffective code
I don't understand, you sent 2 2/2 patches, which one do I look at?
Please just resend the whole series.
thanks,
greg k-h
Greg KH
maintainerQuoted 2 lines · Chandra S Gorentla
- The message queue is replaced with standard Linux linked list
-kmem_cacheis used for list members
Why?
Quoted 2 lines
- A check for return value of receive method is added
-GFP_ATOMICis changed toGFP_KERNEL
Why? Are you sure that is safe?
Quoted 1 line
- A few other related minor changes
Be specific please.
thanks,
greg k-h
Quoted 5 lines · Greg KH
Quoted 2 lines · Chandra S Gorentla
- The message queue is replaced with standard Linux linked list
-kmem_cacheis used for list membersWhy?
The list entires are of fixed type and repeatedly allocated and deallocated for messages.
Quoted 5 lines
Quoted 3 lines
- A check for return value of receive method is added
-GFP_ATOMICis changed toGFP_KERNELWhy? Are you sure that is safe?
The allocations are moved out of 'spin_lock_irqsave' and 'spin_unlock_irqrestore'. Hence they are safe.
Quoted 4 lines
Quoted 2 lines
- A few other related minor changes
Be specific please.
OK. I will try to send seperate patches.
Quoted 4 lines
thanks,
greg k-h
Thank you,
chandra
Quoted 5 lines · Chandra S Gorentla
- The message queue is replaced with standard Linux linked list
-kmem_cacheis used for list members
- A check for return value of receive method is added
-GFP_ATOMICis changed toGFP_KERNEL
- A few other related minor changes
These should be listed and explained.
drivers/staging/wilc1000/host_interface.c static int hostIFthread(void *pvArg) · line 4316
Quoted 8 lines
drivers/staging/wilc1000/host_interface.c +5
-1while (1 ) { -wilc_mq_recv (&gMsgQHostIF, &msg,sizeof (struct host_if_msg ), &u32Ret); + ret =wilc_mq_recv (&gMsgQHostIF, &msg, +sizeof (struct host_if_msg ), &u32Ret); +if (ret) +continue ; +
I asked before if this was a forever loop and never got a response. Also what does this have to do with list macros?
regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
Quoted 5 lines · Chandra S Gorentla
- The message queue is replaced with standard Linux linked list
-kmem_cacheis used for list members
- A check for return value of receive method is added
-GFP_ATOMICis changed toGFP_KERNEL
- A few other related minor changesThese should be listed and explained.
OK. I will try to send seperate patches.
Quoted 12 lines
drivers/staging/wilc1000/host_interface.c static int hostIFthread(void *pvArg) · line 4316
Quoted 9 lines
drivers/staging/wilc1000/host_interface.c +5
-1while (1 ) { -wilc_mq_recv (&gMsgQHostIF, &msg,sizeof (struct host_if_msg ), &u32Ret); + ret =wilc_mq_recv (&gMsgQHostIF, &msg, +sizeof (struct host_if_msg ), &u32Ret); +if (ret) +continue ; +I asked before if this was a forever loop and never got a response. Also what does this have to do with list macros?
The only exit condition of this loop is to receive a message 'HOST_IF_MSG_EXIT'. If this check is not there and 'wilc_mq_recv' returns an error, the switch case below it will be executed for the previously received message.
I will send this change in a different patch.
Quoted 3 lines
regards,
dan carpenter
Quoted 10 lines · Chandra Gorentla
Quoted 10 lines
drivers/staging/wilc1000/host_interface.c static int hostIFthread(void *pvArg) · line 4316
Quoted 7 lines
drivers/staging/wilc1000/host_interface.c +5
-1while (1 ) { -wilc_mq_recv (&gMsgQHostIF, &msg,sizeof (struct host_if_msg ), &u32Ret); + ret =wilc_mq_recv (&gMsgQHostIF, &msg, +sizeof (struct host_if_msg ), &u32Ret); +if (ret) +continue ; +I asked before if this was a forever loop and never got a response. Also what does this have to do with list macros?
Quoted 4 lines
The only exit condition of this loop is to receive a message '
HOST_IF_MSG_EXIT'. If this check is not there and 'wilc_mq_recv' returns an error, the switch case below it will be executed for the previously received message.
Oh, hm... It looks like wilc_mq_recv() can return -EFAULT, -EOVERFLOW or success here. If it returns -EFUALT is calling wilc_mq_recv() again really the right thing? I suspect we should break in that case. We should probably at least sleep for a bit intsead of looping so tightly if it returns -EOVERFLOW?
I'm not sure.
regards,
dan carpenter