aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTomer Tayar <Tomer.Tayar@qlogic.com>2015-12-07 06:25:56 -0500
committerDavid S. Miller <davem@davemloft.net>2015-12-07 14:14:03 -0500
commit4639d60d2bfb7f5007b5d93788fd93c19b63f000 (patch)
tree700ce3b8225ff3fb235750875b8739956814a1c7 /include
parentethernet: aurora: AURORA_NB8800 should depend on HAS_DMA (diff)
downloadlinux-dev-4639d60d2bfb7f5007b5d93788fd93c19b63f000.tar.xz
linux-dev-4639d60d2bfb7f5007b5d93788fd93c19b63f000.zip
qed: Fix corner case for chain in-between pages
The amount of chain next pointer elements between the producer and the consumer indices depends on which pages they currently point to. The current calculation is based only on their difference, and it can lead to a number of free elements which is higher by 1 than the actual value. Signed-off-by: Tomer Tayar <Tomer.Tayar@qlogic.com> Signed-off-by: Manish Chopra <manish.chopra@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/qed/qed_chain.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
index b920c3605c46..41b9049b57e2 100644
--- a/include/linux/qed/qed_chain.h
+++ b/include/linux/qed/qed_chain.h
@@ -111,7 +111,8 @@ static inline u16 qed_chain_get_elem_left(struct qed_chain *p_chain)
used = ((u32)0x10000u + (u32)(p_chain->prod_idx)) -
(u32)p_chain->cons_idx;
if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR)
- used -= (used / p_chain->elem_per_page);
+ used -= p_chain->prod_idx / p_chain->elem_per_page -
+ p_chain->cons_idx / p_chain->elem_per_page;
return p_chain->capacity - used;
}