public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6] ibmveth bug fixes 2/4
@ 2004-08-10 18:06 Santiago Leon
  2004-08-10 18:28 ` Dave Hansen
  0 siblings, 1 reply; 3+ messages in thread
From: Santiago Leon @ 2004-08-10 18:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel list

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

Andrew,

This patch fixes a race condition that would panic the kernel when 
replenishing a buffer pool.  Please apply.

Signed-off-by: Santiago Leon <santil@us.ibm.com>

-- 
Santiago A. Leon
Power Linux Development
IBM Linux Technology Center

[-- Attachment #2: ibmveth_race.patch --]
[-- Type: text/plain, Size: 946 bytes --]

===== drivers/net/ibmveth.c 1.14 vs edited =====
--- 1.14/drivers/net/ibmveth.c	Tue Aug 10 11:56:29 2004
+++ edited/drivers/net/ibmveth.c	Tue Aug 10 11:57:09 2004
@@ -219,6 +219,7 @@
 
 		dma_addr = vio_map_single(adapter->vdev, skb->data, pool->buff_size, DMA_FROM_DEVICE);
 
+               pool->free_map[free_index] = 0xffff;
 		pool->dma_addr[index] = dma_addr;
 		pool->skbuff[index] = skb;
 
@@ -233,6 +234,7 @@
 		lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc);
 		    
 		if(lpar_rc != H_Success) {
+                       pool->free_map[free_index] = index;
 			pool->skbuff[index] = NULL;
 			pool->consumer_index--;
 			vio_unmap_single(adapter->vdev, pool->dma_addr[index], pool->buff_size, DMA_FROM_DEVICE);
@@ -240,7 +242,6 @@
 			adapter->replenish_add_buff_failure++;
 			break;
 		} else {
-			pool->free_map[free_index] = 0xffff;
 			buffers_added++;
 			adapter->replenish_add_buff_success++;
 		}

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

* Re: [PATCH 2.6] ibmveth bug fixes 2/4
  2004-08-10 18:06 [PATCH 2.6] ibmveth bug fixes 2/4 Santiago Leon
@ 2004-08-10 18:28 ` Dave Hansen
  2004-08-10 19:02   ` Santiago Leon
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Hansen @ 2004-08-10 18:28 UTC (permalink / raw)
  To: Santiago A. Leon [imap]; +Cc: Andrew Morton, Linux Kernel list

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

On Tue, 2004-08-10 at 11:06, Santiago Leon wrote:
> This patch fixes a race condition that would panic the kernel when 
> replenishing a buffer pool.  Please apply.

How about something like this that doesn't add more magic numbers?

I'm not so sure about the type, though.  Is that (u16) cast OK?

-- Dave

[-- Attachment #2: ibmveth-invalid_map.patch --]
[-- Type: text/x-patch, Size: 1602 bytes --]

--- veth/drivers/net/ibmveth.h.orig	2004-08-10 11:34:05.000000000 -0700
+++ veth/drivers/net/ibmveth.h	2004-08-10 11:35:01.000000000 -0700
@@ -77,6 +77,8 @@
 #define IbmVethPool1DftCnt  256
 #define IbmVethPool2DftCnt  256
 
+#define IBM_VETH_INVALID_MAP ((u16)0xffff)
+
 struct ibmveth_buff_pool {
     u32 size;
     u32 index;
--- veth/drivers/net/ibmveth.c.orig	2004-08-10 11:35:17.000000000 -0700
+++ veth/drivers/net/ibmveth.c	2004-08-10 11:37:22.000000000 -0700
@@ -213,11 +213,12 @@ static void ibmveth_replenish_buffer_poo
 		free_index = pool->consumer_index++ % pool->size;
 		index = pool->free_map[free_index];
 	
-		ibmveth_assert(index != 0xffff);
+		ibmveth_assert(index != IBM_VETH_INVALID_MAP);
 		ibmveth_assert(pool->skbuff[index] == NULL);
 
 		dma_addr = vio_map_single(adapter->vdev, skb->data, pool->buff_size, DMA_FROM_DEVICE);
 
+		pool->free_map[free_index] = IBM_VETH_INVALID_MAP;
 		pool->dma_addr[index] = dma_addr;
 		pool->skbuff[index] = skb;
 
@@ -232,6 +233,7 @@ static void ibmveth_replenish_buffer_poo
 		lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc);
 		    
 		if(lpar_rc != H_Success) {
+			pool->free_map[free_index] = IBM_VETH_INVALID_MAP;
 			pool->skbuff[index] = NULL;
 			pool->consumer_index--;
 			vio_unmap_single(adapter->vdev, pool->dma_addr[index], pool->buff_size, DMA_FROM_DEVICE);
@@ -239,7 +241,6 @@ static void ibmveth_replenish_buffer_poo
 			adapter->replenish_add_buff_failure++;
 			break;
 		} else {
-			pool->free_map[free_index] = 0xffff;
 			buffers_added++;
 			adapter->replenish_add_buff_success++;
 		}

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

* Re: [PATCH 2.6] ibmveth bug fixes 2/4
  2004-08-10 18:28 ` Dave Hansen
@ 2004-08-10 19:02   ` Santiago Leon
  0 siblings, 0 replies; 3+ messages in thread
From: Santiago Leon @ 2004-08-10 19:02 UTC (permalink / raw)
  To: Dave Hansen; +Cc: Andrew Morton, Linux Kernel list

> How about something like this that doesn't add more magic numbers?
> 
> I'm not so sure about the type, though.  Is that (u16) cast OK?

Yep... Thanks Dave... no magic numbers is good... and the (u16) cast is 
ok...

Andrew... please apply Dave's patch...

-- 
Santiago A. Leon
Power Linux Development
IBM Linux Technology Center

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

end of thread, other threads:[~2004-08-10 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-10 18:06 [PATCH 2.6] ibmveth bug fixes 2/4 Santiago Leon
2004-08-10 18:28 ` Dave Hansen
2004-08-10 19:02   ` Santiago Leon

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