]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Staging: sxg: Removed unnecessary checks while taking Transmit Locks
authorMithlesh Thukral <mithlesh@linsyssoft.com>
Fri, 6 Feb 2009 14:01:40 +0000 (19:31 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Apr 2009 21:53:12 +0000 (14:53 -0700)
Fix the locking issue of locks in transmit code path.
There was an unnecessary check for interrupt context in transmit code path.
Removed that.

Signed-off-by: LinSysSoft Sahara Team <saharaproj@linsyssoft.com>
Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/sxg/sxg.c
drivers/staging/sxg/sxg.h

index 951904320d9e615fc921e24b86cc5883b4e7ff99..75c4982d6a3ff6dfe9f32f09a983035b377640ac 100644 (file)
@@ -119,7 +119,7 @@ static int sxg_poll(struct napi_struct *napi, int budget);
 static int sxg_process_isr(struct adapter_t *adapter, u32 MessageId);
 static u32 sxg_process_event_queue(struct adapter_t *adapter, u32 RssId,
                         int *sxg_napi_continue, int *work_done, int budget);
-static void sxg_complete_slow_send(struct adapter_t *adapter, int irq_context);
+static void sxg_complete_slow_send(struct adapter_t *adapter);
 static struct sk_buff *sxg_slow_receive(struct adapter_t *adapter,
                                        struct sxg_event *Event);
 static void sxg_process_rcv_error(struct adapter_t *adapter, u32 ErrorStatus);
@@ -1274,7 +1274,7 @@ static int sxg_process_isr(struct adapter_t *adapter, u32 MessageId)
        }
        /* Slowpath send completions */
        if (Isr & SXG_ISR_SPSEND) {
-               sxg_complete_slow_send(adapter, 1);
+               sxg_complete_slow_send(adapter);
        }
        /* Dump */
        if (Isr & SXG_ISR_UPC) {
@@ -1477,11 +1477,10 @@ static u32 sxg_process_event_queue(struct adapter_t *adapter, u32 RssId,
  *
  * Arguments -
  *     adapter         - A pointer to our adapter structure
- *     irq_context     - An integer to denote if we are in interrupt context
  * Return
  *     None
  */
-static void sxg_complete_slow_send(struct adapter_t *adapter, int irq_context)
+static void sxg_complete_slow_send(struct adapter_t *adapter)
 {
        struct sxg_xmt_ring *XmtRing = &adapter->XmtRings[0];
        struct sxg_ring_info *XmtRingInfo = &adapter->XmtRingZeroInfo;
@@ -1496,12 +1495,7 @@ static void sxg_complete_slow_send(struct adapter_t *adapter, int irq_context)
         * This means two different processors can both be running/
         * through this loop. Be *very* careful.
         */
-       if(irq_context) {
-               if(!spin_trylock(&adapter->XmtZeroLock))
-                       goto lock_busy;
-       }
-       else
-               spin_lock_irqsave(&adapter->XmtZeroLock, flags);
+       spin_lock_irqsave(&adapter->XmtZeroLock, flags);
 
        SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "CmpSnds",
                  adapter, XmtRingInfo->Head, XmtRingInfo->Tail, 0);
@@ -1545,36 +1539,23 @@ static void sxg_complete_slow_send(struct adapter_t *adapter, int irq_context)
                                 * chimney send, which results in a double trip
                                 * in SxgTcpOuput
                                 */
-                               if(irq_context)
-                                       spin_unlock(&adapter->XmtZeroLock);
-                               else
-                                       spin_unlock_irqrestore(
-                                               &adapter->XmtZeroLock, flags);
+                               spin_unlock_irqrestore(
+                                       &adapter->XmtZeroLock, flags);
 
                                SxgSgl->DumbPacket = NULL;
                                SXG_COMPLETE_DUMB_SEND(adapter, skb,
                                                        FirstSgeAddress,
                                                        FirstSgeLength);
-                               SXG_FREE_SGL_BUFFER(adapter, SxgSgl, NULL,
-                                               irq_context);
+                               SXG_FREE_SGL_BUFFER(adapter, SxgSgl, NULL);
                                /* and reacquire.. */
-                               if(irq_context) {
-                                       if(!spin_trylock(&adapter->XmtZeroLock))
-                                               goto lock_busy;
-                               }
-                               else
-                                       spin_lock_irqsave(&adapter->XmtZeroLock, flags);
+                               spin_lock_irqsave(&adapter->XmtZeroLock, flags);
                        }
                        break;
                default:
                        ASSERT(0);
                }
        }
-       if(irq_context)
-               spin_unlock(&adapter->XmtZeroLock);
-       else
-               spin_unlock_irqrestore(&adapter->XmtZeroLock, flags);
-lock_busy:
+       spin_unlock_irqrestore(&adapter->XmtZeroLock, flags);
        SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "CmpSnd",
                  adapter, XmtRingInfo->Head, XmtRingInfo->Tail, 0);
 }
@@ -2468,7 +2449,7 @@ static int sxg_dumb_sgl(struct sxg_x64_sgl *pSgl,
                 */
 
                spin_unlock_irqrestore(&adapter->XmtZeroLock, flags);
-               sxg_complete_slow_send(adapter, 0);
+               sxg_complete_slow_send(adapter);
                spin_lock_irqsave(&adapter->XmtZeroLock, flags);
                SXG_GET_CMD(XmtRing, XmtRingInfo, XmtCmd, SxgSgl);
                if (XmtCmd == NULL) {
@@ -3781,22 +3762,16 @@ static void sxg_allocate_sgl_buffer_complete(struct adapter_t *adapter,
        unsigned long sgl_flags;
        SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "AlSglCmp",
                  adapter, SxgSgl, Length, 0);
-       if(!in_irq())
-               spin_lock_irqsave(&adapter->SglQLock, sgl_flags);
-       else
-               spin_lock(&adapter->SglQLock);
+       spin_lock_irqsave(&adapter->SglQLock, sgl_flags);
        adapter->AllSglBufferCount++;
        /* PhysicalAddress; */
        SxgSgl->PhysicalAddress = PhysicalAddress;
        /* Initialize backpointer once */
        SxgSgl->adapter = adapter;
        InsertTailList(&adapter->AllSglBuffers, &SxgSgl->AllList);
-       if(!in_irq())
-               spin_unlock_irqrestore(&adapter->SglQLock, sgl_flags);
-       else
-               spin_unlock(&adapter->SglQLock);
+       spin_unlock_irqrestore(&adapter->SglQLock, sgl_flags);
        SxgSgl->State = SXG_BUFFER_BUSY;
-       SXG_FREE_SGL_BUFFER(adapter, SxgSgl, NULL, in_irq());
+       SXG_FREE_SGL_BUFFER(adapter, SxgSgl, NULL);
        SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "XAlSgl",
                  adapter, SxgSgl, Length, 0);
 }
index 81d16803169ef92d3d4c5f36849d0939e381c42d..e937d4b8e811904d86618e5cf38c19db79aa2595 100644 (file)
@@ -244,20 +244,14 @@ struct sxg_stats {
 }
 
 /* SGL macros */
-#define SXG_FREE_SGL_BUFFER(_pAdapt, _Sgl, _NB, _irq) {                                \
-       if(!_irq)                                                               \
-               spin_lock_irqsave(&(_pAdapt)->SglQLock, sgl_flags);             \
-       else                                                                    \
-               spin_lock(&(_pAdapt)->SglQLock);                                \
+#define SXG_FREE_SGL_BUFFER(_pAdapt, _Sgl, _NB) {                              \
+       spin_lock_irqsave(&(_pAdapt)->SglQLock, sgl_flags);                     \
        (_pAdapt)->FreeSglBufferCount++;                                        \
        ASSERT((_pAdapt)->AllSglBufferCount >= (_pAdapt)->FreeSglBufferCount);  \
        ASSERT(!((_Sgl)->State & SXG_BUFFER_FREE));                             \
        (_Sgl)->State = SXG_BUFFER_FREE;                                        \
        InsertTailList(&(_pAdapt)->FreeSglBuffers, &(_Sgl)->FreeList);          \
-       if(!_irq)                                                               \
-               spin_unlock_irqrestore(&(_pAdapt)->SglQLock, sgl_flags);        \
-       else                                                                    \
-               spin_unlock(&(_pAdapt)->SglQLock);                              \
+       spin_unlock_irqrestore(&(_pAdapt)->SglQLock, sgl_flags);                \
 }
 
 /*
@@ -280,7 +274,7 @@ struct sxg_stats {
        if(!_irq)                                                       \
                spin_lock_irqsave(&(_pAdapt)->SglQLock, sgl_flags);     \
        else                                                            \
-               spin_lock(&(_pAdapt)->SglQLock);                        \
+               spin_lock_irqsave(&(_pAdapt)->SglQLock, sgl_flags);     \
        if((_pAdapt)->FreeSglBufferCount) {                             \
                ASSERT(!(IsListEmpty(&(_pAdapt)->FreeSglBuffers)));     \
                _ple = RemoveHeadList(&(_pAdapt)->FreeSglBuffers);      \
@@ -294,7 +288,7 @@ struct sxg_stats {
        if(!_irq)                                                       \
                spin_unlock_irqrestore(&(_pAdapt)->SglQLock, sgl_flags);\
        else                                                            \
-               spin_unlock(&(_pAdapt)->SglQLock);                      \
+               spin_unlock_irqrestore(&(_pAdapt)->SglQLock, sgl_flags);\
 }
 
 /*