Skip to contentSkip to conversation

mt76: usb: grab rx_page_lock for legacy mode in mt76u_refill_rx

PATCH In review Lorenzo Bianconi 3 participants 4 messages Feb 28, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Lorenzo Bianconi

author maintainer
#1 lore raw

PATCH 1/1 mt76: usb: grab rx_page_lock for legacy mode in mt76u_refill_rx

Grab rx_page_lock in mt76u_refill_rx allocating rx buffer for 'legacy' mode. Remove gfp from mt76u_refill_rx signature since we need to use GFP_ATOMIC

---
 drivers/net/wireless/mediatek/mt76/usb.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/usb.c +10 -9
index ae6ada370597..7ce3c7f9d5d8 100644
@@ -325,15 +325,17 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
 
 static int
 mt76u_refill_rx(struct mt76_dev *dev, struct mt76_queue *q,
-		struct mt76u_buf *buf, int nsgs, gfp_t gfp)
+		struct mt76u_buf *buf, int nsgs)
 {
-	if (dev->usb.sg_en) {
+	if (dev->usb.sg_en)
 		return mt76u_fill_rx_sg(dev, buf, nsgs, q->buf_size,
 					SKB_WITH_OVERHEAD(q->buf_size));
-	} else {
-		buf->buf = page_frag_alloc(&q->rx_page, q->buf_size, gfp);
-		return buf->buf ? 0 : -ENOMEM;
-	}
+
+	spin_lock_bh(&q->rx_page_lock);
+	buf->buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC);
+	spin_unlock_bh(&q->rx_page_lock);
+
+	return buf->buf ? 0 : -ENOMEM;
 }
 
 static int
@@ -358,7 +360,7 @@ mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf)
 		sg_init_table(buf->urb->sg, MT_SG_MAX_SIZE);
 	}
 
-	return mt76u_refill_rx(dev, q, buf, MT_SG_MAX_SIZE, GFP_KERNEL);
+	return mt76u_refill_rx(dev, q, buf, MT_SG_MAX_SIZE);
 }
 
 static void mt76u_buf_free(struct mt76u_buf *buf)
@@ -529,8 +531,7 @@ static void mt76u_rx_tasklet(unsigned long data)
 
 		count = mt76u_process_rx_entry(dev, buf);
 		if (count > 0) {
-			err = mt76u_refill_rx(dev, q, buf, count,
-					      GFP_ATOMIC);
+			err = mt76u_refill_rx(dev, q, buf, count);
 			if (err < 0)
 				break;
 		}
Signature · 1 line
2.20.1
#2 lore raw
Quoted 5 lines · Lorenzo Bianconi

Grab rx_page_lock in mt76u_refill_rx allocating rx buffer for 'legacy' mode. Remove gfp from mt76u_refill_rx signature since we need to use GFP_ATOMIC

I'm doing some cleanup/optimization work which amongs other things will remove rx_page_lock. Please drop this patch.

Stanislaw

#3 lore raw
Quoted 9 lines · Lorenzo Bianconi
Quoted 5 lines

Grab rx_page_lock in mt76u_refill_rx allocating rx buffer for 'legacy' mode. Remove gfp from mt76u_refill_rx signature since we need to use GFP_ATOMIC

I'm doing some cleanup/optimization work which amongs other things will remove rx_page_lock. Please drop this patch.

Oh, ok. IIRC we need rx_page_lock to fix this:
481bb0432414f790066205fe77226b7d1877385d. Is it still necessary? Moreover maybe we need this patch for 5.1 since net-next is almost close, no?

@Felix: are you planning to submit other patches for 5.1?

Regards,
Lorenzo

Quoted 2 lines

Stanislaw

#4 lore raw
Quoted 5 lines · Lorenzo Bianconi
Quoted 5 lines · Lorenzo Bianconi
Quoted 4 lines

Grab rx_page_lock in mt76u_refill_rx allocating rx buffer for 'legacy' mode. Remove gfp from mt76u_refill_rx signature since we need to use GFP_ATOMIC

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I'm doing some cleanup/optimization work which amongs other things will remove rx_page_lock. Please drop this patch.

Oh, ok. IIRC we need rx_page_lock to fix this:
481bb0432414f790066205fe77226b7d1877385d. Is it still necessary? Moreover maybe we need this patch for 5.1 since net-next is almost close, no?

It is not neccessery now in -next after removing concurrent access to mt76u_buf_alloc(), can be removed.

Stanislaw