netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] qed: Misc fixes in qed
@ 2019-01-03 10:02 Denis Bolotin
  2019-01-03 10:02 ` [PATCH net 1/2] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Denis Bolotin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Denis Bolotin @ 2019-01-03 10:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: aelior, Denis Bolotin

Hi Dave,

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

Thanks,
Denis

Denis Bolotin (2):
  qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page
    count
  qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory
    barrier

 drivers/net/ethernet/qlogic/qed/qed_ll2.c |  4 ++++
 include/linux/qed/qed_chain.h             | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count
  2019-01-03 10:02 [PATCH net 0/2] qed: Misc fixes in qed Denis Bolotin
@ 2019-01-03 10:02 ` Denis Bolotin
  2019-01-03 10:02 ` [PATCH net 2/2] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Denis Bolotin
  2019-01-04 20:57 ` [PATCH net 0/2] qed: Misc fixes in qed David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Bolotin @ 2019-01-03 10:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: aelior, Denis Bolotin

In PBL chains with non power of 2 page count, the producer is not at the
beginning of the chain when index is 0 after a wrap. Therefore, after the
producer index wrap around, page index should be calculated more carefully.

Signed-off-by: Denis Bolotin <dbolotin@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
---
 include/linux/qed/qed_chain.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
index 59ddf9a..2dd0a9e 100644
--- a/include/linux/qed/qed_chain.h
+++ b/include/linux/qed/qed_chain.h
@@ -663,6 +663,37 @@ static inline void *qed_chain_get_last_elem(struct qed_chain *p_chain)
 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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier
  2019-01-03 10:02 [PATCH net 0/2] qed: Misc fixes in qed Denis Bolotin
  2019-01-03 10:02 ` [PATCH net 1/2] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Denis Bolotin
@ 2019-01-03 10:02 ` Denis Bolotin
  2019-01-04 20:57 ` [PATCH net 0/2] qed: Misc fixes in qed David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Bolotin @ 2019-01-03 10:02 UTC (permalink / raw)
  To: davem, netdev; +Cc: aelior, Denis Bolotin

Make sure chain element is updated before ringing the doorbell.

Signed-off-by: Denis Bolotin <dbolotin@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
---
 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 90afd51..d9237c6 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -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));
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] qed: Misc fixes in qed
  2019-01-03 10:02 [PATCH net 0/2] qed: Misc fixes in qed Denis Bolotin
  2019-01-03 10:02 ` [PATCH net 1/2] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Denis Bolotin
  2019-01-03 10:02 ` [PATCH net 2/2] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Denis Bolotin
@ 2019-01-04 20:57 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-01-04 20:57 UTC (permalink / raw)
  To: dbolotin; +Cc: netdev, aelior

From: Denis Bolotin <dbolotin@marvell.com>
Date: Thu, 3 Jan 2019 12:02:38 +0200

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

Series applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-04 20:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-03 10:02 [PATCH net 0/2] qed: Misc fixes in qed Denis Bolotin
2019-01-03 10:02 ` [PATCH net 1/2] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Denis Bolotin
2019-01-03 10:02 ` [PATCH net 2/2] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Denis Bolotin
2019-01-04 20:57 ` [PATCH net 0/2] qed: Misc fixes in qed David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).