diff options
author | Jianjun kong <jianjun@zeuux.org> | 2009-04-20 19:48:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-22 03:43:24 -0400 |
commit | 3f9738f73ad08ef770df64f145007bd27ac2fa16 (patch) | |
tree | 86b401379c1503486813914201ac78b55fdc55a2 /drivers/net/8139too.c | |
parent | 3fa6b5adbe46b3d665267dee0f879858ab464f44 (diff) |
8139too: fix HW initial flow
While ifconfig eth0 up kernel calls open() of 8139 driver(8139too.c).
In rtl8139_hw_start() of rtl8139_open(), 8139 driver enable RX before
setting up the DMA buffer address. In this interval where RX was
enabled and DMA buffer address is not yet set up, any incoming
broadcast packet would be send to a strange physical address:
0x003e8800 which is the default value of DMA buffer address.
Unfortunately, this address is used by Linux kernel. So kernel panics.
This patch fix it by setting up DMA buffer address before RX enabled
and everything is fine even under broadcast packets attack.
Signed-off-by: Jonathan Lin <jon.lin@vatics.com>
Signed-off-by: Amos Kong <jianjun@zeuux.org>
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/8139too.c')
-rw-r--r-- | drivers/net/8139too.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 29df398b7727..1fc45431a620 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c | |||
@@ -1383,6 +1383,11 @@ static void rtl8139_hw_start (struct net_device *dev) | |||
1383 | RTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); | 1383 | RTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); |
1384 | RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4))); | 1384 | RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4))); |
1385 | 1385 | ||
1386 | tp->cur_rx = 0; | ||
1387 | |||
1388 | /* init Rx ring buffer DMA address */ | ||
1389 | RTL_W32_F (RxBuf, tp->rx_ring_dma); | ||
1390 | |||
1386 | /* Must enable Tx/Rx before setting transfer thresholds! */ | 1391 | /* Must enable Tx/Rx before setting transfer thresholds! */ |
1387 | RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb); | 1392 | RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb); |
1388 | 1393 | ||
@@ -1390,8 +1395,6 @@ static void rtl8139_hw_start (struct net_device *dev) | |||
1390 | RTL_W32 (RxConfig, tp->rx_config); | 1395 | RTL_W32 (RxConfig, tp->rx_config); |
1391 | RTL_W32 (TxConfig, rtl8139_tx_config); | 1396 | RTL_W32 (TxConfig, rtl8139_tx_config); |
1392 | 1397 | ||
1393 | tp->cur_rx = 0; | ||
1394 | |||
1395 | rtl_check_media (dev, 1); | 1398 | rtl_check_media (dev, 1); |
1396 | 1399 | ||
1397 | if (tp->chipset >= CH_8139B) { | 1400 | if (tp->chipset >= CH_8139B) { |
@@ -1406,9 +1409,6 @@ static void rtl8139_hw_start (struct net_device *dev) | |||
1406 | /* Lock Config[01234] and BMCR register writes */ | 1409 | /* Lock Config[01234] and BMCR register writes */ |
1407 | RTL_W8 (Cfg9346, Cfg9346_Lock); | 1410 | RTL_W8 (Cfg9346, Cfg9346_Lock); |
1408 | 1411 | ||
1409 | /* init Rx ring buffer DMA address */ | ||
1410 | RTL_W32_F (RxBuf, tp->rx_ring_dma); | ||
1411 | |||
1412 | /* init Tx buffer DMA addresses */ | 1412 | /* init Tx buffer DMA addresses */ |
1413 | for (i = 0; i < NUM_TX_DESC; i++) | 1413 | for (i = 0; i < NUM_TX_DESC; i++) |
1414 | RTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] - tp->tx_bufs)); | 1414 | RTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] - tp->tx_bufs)); |