From: Arik Nemtsov Date: Sun, 14 Aug 2011 10:17:34 +0000 (+0300) Subject: wl12xx: handle wrap-around overflow in released Tx blocks FW counter X-Git-Tag: v3.2-rc1~129^2~287^2^2~87^2~5 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdf91cfae66dd76a093c75cac8f6ada12fd21b83;p=pandora-kernel.git wl12xx: handle wrap-around overflow in released Tx blocks FW counter 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 Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 027b6742a151..0fa3a2281ddb 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -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;