All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: "Santiago A. Leon [imap]" <santil@us.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6] ibmveth bug fixes 2/4
Date: Tue, 10 Aug 2004 11:28:57 -0700	[thread overview]
Message-ID: <1092162537.11212.27.camel@nighthawk> (raw)
In-Reply-To: <41190E8E.9050004@us.ibm.com>

[-- 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++;
 		}

  reply	other threads:[~2004-08-10 18:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-10 18:06 [PATCH 2.6] ibmveth bug fixes 2/4 Santiago Leon
2004-08-10 18:28 ` Dave Hansen [this message]
2004-08-10 19:02   ` Santiago Leon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1092162537.11212.27.camel@nighthawk \
    --to=haveblue@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=santil@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.