Merge branch 'qed-fixes'

Denis Bolotin says:

====================
qed: Misc fixes in qed

This patch series fixes 2 potential bugs in qed.
Please consider applying to net.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2019-01-04 12:57:31 -08:00
commit ebdefe4656
2 changed files with 35 additions and 0 deletions

View File

@ -1619,6 +1619,10 @@ static void qed_ll2_post_rx_buffer_notify_fw(struct qed_hwfn *p_hwfn,
cq_prod = qed_chain_get_prod_idx(&p_rx->rcq_chain);
rx_prod.bd_prod = cpu_to_le16(bd_prod);
rx_prod.cqe_prod = cpu_to_le16(cq_prod);
/* Make sure chain element is updated before ringing the doorbell */
dma_wmb();
DIRECT_REG_WR(p_rx->set_prod_addr, *((u32 *)&rx_prod));
}

View File

@ -663,6 +663,37 @@ out:
static inline void qed_chain_set_prod(struct qed_chain *p_chain,
u32 prod_idx, void *p_prod_elem)
{
if (p_chain->mode == QED_CHAIN_MODE_PBL) {
u32 cur_prod, page_mask, page_cnt, page_diff;
cur_prod = is_chain_u16(p_chain) ? p_chain->u.chain16.prod_idx :
p_chain->u.chain32.prod_idx;
/* Assume that number of elements in a page is power of 2 */
page_mask = ~p_chain->elem_per_page_mask;
/* Use "cur_prod - 1" and "prod_idx - 1" since producer index
* reaches the first element of next page before the page index
* is incremented. See qed_chain_produce().
* Index wrap around is not a problem because the difference
* between current and given producer indices is always
* positive and lower than the chain's capacity.
*/
page_diff = (((cur_prod - 1) & page_mask) -
((prod_idx - 1) & page_mask)) /
p_chain->elem_per_page;
page_cnt = qed_chain_get_page_cnt(p_chain);
if (is_chain_u16(p_chain))
p_chain->pbl.c.u16.prod_page_idx =
(p_chain->pbl.c.u16.prod_page_idx -
page_diff + page_cnt) % page_cnt;
else
p_chain->pbl.c.u32.prod_page_idx =
(p_chain->pbl.c.u32.prod_page_idx -
page_diff + page_cnt) % page_cnt;
}
if (is_chain_u16(p_chain))
p_chain->u.chain16.prod_idx = (u16) prod_idx;
else