Skip to content

Commit

Permalink
net: cadence_gem: Fix Tx descriptor update
Browse files Browse the repository at this point in the history
The local variable "desc" was being used to read-modify-write the
first descriptor (of a multi-desc packet) upon packet completion.
desc however continues to be used by the code as the current
descriptor. Give this first desc RMW it's own local variable to
avoid trampling.

Signed-off-by: Peter Crosthwaite <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
pete128 authored and Michael Tokarev committed Jun 10, 2014
1 parent 3334e92 commit 6ab57a6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hw/net/cadence_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,16 @@ static void gem_transmit(GemState *s)

/* Last descriptor for this packet; hand the whole thing off */
if (tx_desc_get_last(desc)) {
unsigned desc_first[2];

/* Modify the 1st descriptor of this packet to be owned by
* the processor.
*/
cpu_physical_memory_read(s->tx_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
tx_desc_set_used(desc);
cpu_physical_memory_write(s->tx_desc_addr,
(uint8_t *)&desc[0], sizeof(desc));
cpu_physical_memory_read(s->tx_desc_addr, (uint8_t *)desc_first,
sizeof(desc_first));
tx_desc_set_used(desc_first);
cpu_physical_memory_write(s->tx_desc_addr, (uint8_t *)desc_first,
sizeof(desc_first));
/* Advance the hardare current descriptor past this packet */
if (tx_desc_get_wrap(desc)) {
s->tx_desc_addr = s->regs[GEM_TXQBASE];
Expand Down

0 comments on commit 6ab57a6

Please sign in to comment.