Received: from mail.onstor.com ([66.201.51.107]) by onstor-exch02.onstor.net with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 25 Aug 2008 23:55:56 -0700
Received: from chiesmta2-2.messageone.com ([216.203.30.55]) by mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 25 Aug 2008 23:55:56 -0700
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])
	by chiesmta2-2.messageone.com (8.13.8/8.13.8) with ESMTP id m7Q6tt6J014127
	for <andy.sharp@onstor.com>; Tue, 26 Aug 2008 01:55:55 -0500
Received: from localhost.localdomain ([127.0.0.1]:7347 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP
	id S20022207AbYHZGzp (ORCPT <rfc822;andy.sharp@onstor.com>);
	Tue, 26 Aug 2008 07:55:45 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 26 Aug 2008 07:55:28 +0100 (BST)
Received: from smtp1.dnsmadeeasy.com ([205.234.170.134]:10215 "EHLO
	smtp1.dnsmadeeasy.com") by ftp.linux-mips.org with ESMTP
	id S20025457AbYHZGzZ (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 26 Aug 2008 07:55:25 +0100
Received: from smtp1.dnsmadeeasy.com (localhost [127.0.0.1])
	by smtp1.dnsmadeeasy.com (Postfix) with ESMTP id 517363207D1;
	Tue, 26 Aug 2008 06:55:17 +0000 (UTC)
X-Authenticated-Name: js.dnsmadeeasy
X-Transit-System: In case of SPAM please contact abuse@dnsmadeeasy.com
Received: from avtrex.com (unknown [173.8.135.205])
	by smtp1.dnsmadeeasy.com (Postfix) with ESMTP;
	Tue, 26 Aug 2008 06:55:17 +0000 (UTC)
Received: from silver64.hq2.avtrex.com ([192.168.7.226]) by avtrex.com with Microsoft SMTPSVC(6.0.3790.1830);
	 Mon, 25 Aug 2008 23:55:13 -0700
Message-ID: <48B3A8D0.2040108@avtrex.com>
Date: 	Mon, 25 Aug 2008 23:55:12 -0700
From: David Daney <ddaney@avtrex.com>
User-Agent: Thunderbird 2.0.0.16 (X11/20080723)
MIME-Version: 1.0
To: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org
Cc: linux-mips <linux-mips@linux-mips.org>
Subject: [PATCH] e100: Add missing dma sync for proper operation with non-coherent
 caches.
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 26 Aug 2008 06:55:13.0337 (UTC) FILETIME=[B048CA90:01C90748]
X-archive-position: 20350
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@avtrex.com
Precedence: bulk
X-list: 	linux-mips
X-MessageOne-Virus-Version: vendor=fsecure engine=4.65.7161:2.4.4,1.2.40,4.0.164 definitions=2008-08-26_03:2008-08-25,2008-08-26,2008-08-25 signatures=0
X-MessageOne-Virus-Scanned: Clean
X-MessageOne-Envelope-Sender: linux-mips-bounce@linux-mips.org
X-MessageOne-Spam-Details: rule=m773emszm_notspam policy=m773emszm score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=3.1.0-0805090000 definitions=main-0808250287
X-MessageOne-Spam-Score: 0
X-MessageOne-Spam-Bar: 
Return-Path: linux-mips-bounce@linux-mips.org

I am running the e100 driver on a MIPS 4KEc system (32 bit mips with
non-coherent DMA).  There was a problem where received packets would
get 'stuck' for several seconds at a time and then be released all at
once.

The cause was that if an interrupt were received when no RX packets
were available, the status for the receive buffer would be stuck in
the cache, so when the next interrupt arrived the old status value was
read (indicating no packets available) instead of the new value.

The fix is to call pci_dma_sync_single_for_device on the RX if the
packet is not available to invalidate the cache so that at the next
interrupt valid status is returned.

The driver currently calls pci_dma_sync_single_for_cpu before reading
the status, and this is indeed needed for cases like the R10000 CPU
where the cache can be polluted by speculative execution, but for most
machines it is a nop.

The patch was tested on 2.6.17-rc4 on a MIPS 4KEc.

Signed-off-by: David Daney <ddaney@avtrex.com>
---
 drivers/net/e100.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 19d32a2..fb8d551 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1840,6 +1840,11 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 
 			if (readb(&nic->csr->scb.status) & rus_no_res)
 				nic->ru_running = RU_SUSPENDED;
+		/* We are done looking at the buffer.  Prepare it for
+		 * more DMA.  */
+		pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr,
+					       sizeof(struct rfd),
+					       PCI_DMA_FROMDEVICE);
 		return -ENODATA;
 	}
 
-- 
1.5.5.1


