Skip to content

Commit

Permalink
wl12xx: handle wrap-around overflow in released Tx blocks FW counter
Browse files Browse the repository at this point in the history
When the FW Tx released blocks counter wraps around, we should correct
our calculation of released blocks. Otherwise we add a large negative
figure to our driver freed blocks counter

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
  • Loading branch information
Arik Nemtsov authored and Luciano Coelho committed Aug 22, 2011
1 parent 742246f commit bdf91cf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/net/wireless/wl12xx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,15 @@ static void wl12xx_fw_status(struct wl1271 *wl,
wl->tx_pkts_freed[i] = status->tx_released_pkts[i];
}

freed_blocks = le32_to_cpu(status->total_released_blks) -
wl->tx_blocks_freed;
/* prevent wrap-around in total blocks counter */
if (likely(wl->tx_blocks_freed <=
le32_to_cpu(status->total_released_blks)))
freed_blocks = le32_to_cpu(status->total_released_blks) -
wl->tx_blocks_freed;
else
freed_blocks = 0x100000000LL - wl->tx_blocks_freed +
le32_to_cpu(status->total_released_blks);

wl->tx_blocks_freed = le32_to_cpu(status->total_released_blks);

wl->tx_allocated_blocks -= freed_blocks;
Expand Down

0 comments on commit bdf91cf

Please sign in to comment.