Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754867AbYJHQO3 (ORCPT ); Wed, 8 Oct 2008 12:14:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754135AbYJHQOR (ORCPT ); Wed, 8 Oct 2008 12:14:17 -0400 Received: from ffm.saftware.de ([83.141.3.46]:45157 "EHLO ffm.saftware.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754110AbYJHQOQ (ORCPT ); Wed, 8 Oct 2008 12:14:16 -0400 Message-ID: <48ECDC58.1020603@linuxtv.org> Date: Wed, 08 Oct 2008 18:14:16 +0200 From: Andreas Oberritter User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: Ben Hutchings CC: Jeff Garzik , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] 8139too: move wmb before TX DMA start References: <48EC64E1.5070806@linuxtv.org> <20081008101558.GH7331@solarflare.com> In-Reply-To: <20081008101558.GH7331@solarflare.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1354 Lines: 39 From: Andreas Oberritter The write barrier should be used before starting a DMA transfer. This fixes a problem, where almost all packets received on another machine had garbled content. Tested with an RTL8100C on a MIPS machine. Signed-off-by: Andreas Oberritter --- Added a comment on Ben's request explaining the reason for the barrier. diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 53bd903..3c5fac6 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -1716,13 +1716,18 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) } spin_lock_irqsave(&tp->lock, flags); + /* + * Writing to TxStatus triggers a DMA transfer of the data + * copied to tp->tx_buf[entry] above. Use a memory barrier + * to make sure that the device sees the updated data. + */ + wmb(); RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); dev->trans_start = jiffies; tp->cur_tx++; - wmb(); if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx) netif_stop_queue (dev); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/