Skip to content

Commit

Permalink
mt76: mt76u: use dedicated thread for status work
Browse files Browse the repository at this point in the history
Split tx and status path in mt76-usb module relying on mt76 workers APIs

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Dec 4, 2020
1 parent be83a7e commit 9daf27e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ struct mt76_usb {
u8 *data;
u16 data_len;

struct mt76_worker status_worker;
struct mt76_worker rx_worker;

struct work_struct stat_work;

u8 out_ep[__MT_EP_OUT_MAX];
Expand Down
20 changes: 15 additions & 5 deletions drivers/net/wireless/mediatek/mt76/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,10 @@ int mt76u_resume_rx(struct mt76_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76u_resume_rx);

static void mt76u_tx_worker(struct mt76_worker *w)
static void mt76u_status_worker(struct mt76_worker *w)
{
struct mt76_dev *dev = container_of(w, struct mt76_dev, tx_worker);
struct mt76_usb *usb = container_of(w, struct mt76_usb, status_worker);
struct mt76_dev *dev = container_of(usb, struct mt76_dev, usb);
struct mt76_queue_entry entry;
struct mt76_queue *q;
bool wake;
Expand All @@ -833,7 +834,7 @@ static void mt76u_tx_worker(struct mt76_worker *w)
if (!q->queued)
wake_up(&dev->tx_wait);

mt76_txq_schedule(&dev->phy, i);
mt76_worker_schedule(&dev->tx_worker);

if (dev->drv->tx_status_data &&
!test_and_set_bit(MT76_READING_STATS, &dev->phy.state))
Expand Down Expand Up @@ -877,7 +878,7 @@ static void mt76u_complete_tx(struct urb *urb)
dev_err(dev->dev, "tx urb failed: %d\n", urb->status);
e->done = true;

mt76_worker_schedule(&dev->tx_worker);
mt76_worker_schedule(&dev->usb.status_worker);
}

static int
Expand Down Expand Up @@ -1016,6 +1017,8 @@ static void mt76u_free_tx(struct mt76_dev *dev)
{
int i;

mt76_worker_teardown(&dev->usb.status_worker);

for (i = 0; i < IEEE80211_NUM_ACS; i++) {
struct mt76_queue *q;
int j;
Expand All @@ -1036,6 +1039,7 @@ void mt76u_stop_tx(struct mt76_dev *dev)
int ret;

mt76_worker_disable(&dev->tx_worker);
mt76_worker_disable(&dev->usb.status_worker);

ret = wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(&dev->phy),
HZ / 5);
Expand Down Expand Up @@ -1074,6 +1078,7 @@ void mt76u_stop_tx(struct mt76_dev *dev)
clear_bit(MT76_READING_STATS, &dev->phy.state);

mt76_worker_enable(&dev->tx_worker);
mt76_worker_enable(&dev->usb.status_worker);

mt76_tx_status_check(dev, NULL, true);
}
Expand Down Expand Up @@ -1124,7 +1129,6 @@ int mt76u_init(struct mt76_dev *dev,
mt76u_ops.rmw = ext ? mt76u_rmw_ext : mt76u_rmw;
mt76u_ops.write_copy = ext ? mt76u_copy_ext : mt76u_copy;

dev->tx_worker.fn = mt76u_tx_worker;
INIT_WORK(&usb->stat_work, mt76u_tx_status_data);

usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1);
Expand Down Expand Up @@ -1152,7 +1156,13 @@ int mt76u_init(struct mt76_dev *dev,
if (err)
return err;

err = mt76_worker_setup(dev->hw, &usb->status_worker,
mt76u_status_worker, "usb-status");
if (err)
return err;

sched_set_fifo_low(usb->rx_worker.task);
sched_set_fifo_low(usb->status_worker.task);

return 0;
}
Expand Down

0 comments on commit 9daf27e

Please sign in to comment.