Skip to content

Commit 4639d60

Browse files
Tomer Tayardavem330
authored andcommitted
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>
1 parent 4675390 commit 4639d60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/linux/qed/qed_chain.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ static inline u16 qed_chain_get_elem_left(struct qed_chain *p_chain)
111111
used = ((u32)0x10000u + (u32)(p_chain->prod_idx)) -
112112
(u32)p_chain->cons_idx;
113113
if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR)
114-
used -= (used / p_chain->elem_per_page);
114+
used -= p_chain->prod_idx / p_chain->elem_per_page -
115+
p_chain->cons_idx / p_chain->elem_per_page;
115116

116117
return p_chain->capacity - used;
117118
}

0 commit comments

Comments
 (0)