forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/sonic: Fix receive buffer replenishment
As soon as the driver is finished with a receive buffer it allocs a new one and overwrites the corresponding RRA entry with a new buffer pointer. Problem is, the buffer pointer is split across two word-sized registers. It can't be updated in one atomic store. So this operation races with the chip while it stores received packets and advances its RRP register. This could result in memory corruption by a DMA write. Avoid this problem by adding buffers only at the location given by the RWP register, in accordance with the National Semiconductor datasheet. Re-factor this code into separate functions to calculate a RRA pointer and to update the RWP. Fixes: efcce83 ("[PATCH] macsonic/jazzsonic network drivers update") Tested-by: Stan Johnson <[email protected]> Signed-off-by: Finn Thain <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
Showing
2 changed files
with
105 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,8 +314,6 @@ struct sonic_local { | |
u32 rda_laddr; /* logical DMA address of RDA */ | ||
dma_addr_t rx_laddr[SONIC_NUM_RRS]; /* logical DMA addresses of rx skbuffs */ | ||
dma_addr_t tx_laddr[SONIC_NUM_TDS]; /* logical DMA addresses of tx skbuffs */ | ||
unsigned int rra_end; | ||
unsigned int cur_rwp; | ||
unsigned int cur_rx; | ||
unsigned int cur_tx; /* first unacked transmit packet */ | ||
unsigned int eol_rx; | ||
|
@@ -450,6 +448,22 @@ static inline __u16 sonic_rra_get(struct net_device* dev, int entry, | |
(entry * SIZEOF_SONIC_RR) + offset); | ||
} | ||
|
||
static inline u16 sonic_rr_addr(struct net_device *dev, int entry) | ||
{ | ||
struct sonic_local *lp = netdev_priv(dev); | ||
|
||
return lp->rra_laddr + | ||
entry * SIZEOF_SONIC_RR * SONIC_BUS_SCALE(lp->dma_bitmode); | ||
} | ||
|
||
static inline u16 sonic_rr_entry(struct net_device *dev, u16 addr) | ||
{ | ||
struct sonic_local *lp = netdev_priv(dev); | ||
|
||
return (addr - (u16)lp->rra_laddr) / (SIZEOF_SONIC_RR * | ||
SONIC_BUS_SCALE(lp->dma_bitmode)); | ||
} | ||
|
||
static const char version[] = | ||
"sonic.c:v0.92 20.9.98 [email protected]\n"; | ||
|
||
|