Commit d74fda4c authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt76s: move status processing in txrx wq

As it has been done for tx and rx processing, move tx/rx status
processing into mt76s_txrx_wq workqueue
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 3e5f374d
...@@ -446,12 +446,12 @@ struct mt76_usb { ...@@ -446,12 +446,12 @@ struct mt76_usb {
}; };
struct mt76_sdio { struct mt76_sdio {
struct task_struct *kthread;
struct work_struct stat_work;
struct workqueue_struct *txrx_wq; struct workqueue_struct *txrx_wq;
struct work_struct tx_work; struct work_struct tx_work;
struct work_struct rx_work; struct work_struct rx_work;
struct work_struct work;
struct work_struct stat_work;
unsigned long state; unsigned long state;
......
...@@ -212,7 +212,7 @@ void mt7663s_tx_work(struct work_struct *work) ...@@ -212,7 +212,7 @@ void mt7663s_tx_work(struct work_struct *work)
if (nframes) if (nframes)
queue_work(sdio->txrx_wq, &sdio->tx_work); queue_work(sdio->txrx_wq, &sdio->tx_work);
wake_up_process(sdio->kthread); queue_work(sdio->txrx_wq, &sdio->work);
} }
void mt7663s_rx_work(struct work_struct *work) void mt7663s_rx_work(struct work_struct *work)
...@@ -233,7 +233,7 @@ void mt7663s_rx_work(struct work_struct *work) ...@@ -233,7 +233,7 @@ void mt7663s_rx_work(struct work_struct *work)
if (intr.isr & WHIER_RX0_DONE_INT_EN) { if (intr.isr & WHIER_RX0_DONE_INT_EN) {
ret = mt7663s_rx_run_queue(dev, 0, &intr); ret = mt7663s_rx_run_queue(dev, 0, &intr);
if (ret > 0) { if (ret > 0) {
wake_up_process(sdio->kthread); queue_work(sdio->txrx_wq, &sdio->work);
nframes += ret; nframes += ret;
} }
} }
...@@ -241,7 +241,7 @@ void mt7663s_rx_work(struct work_struct *work) ...@@ -241,7 +241,7 @@ void mt7663s_rx_work(struct work_struct *work)
if (intr.isr & WHIER_RX1_DONE_INT_EN) { if (intr.isr & WHIER_RX1_DONE_INT_EN) {
ret = mt7663s_rx_run_queue(dev, 1, &intr); ret = mt7663s_rx_run_queue(dev, 1, &intr);
if (ret > 0) { if (ret > 0) {
wake_up_process(sdio->kthread); queue_work(sdio->txrx_wq, &sdio->work);
nframes += ret; nframes += ret;
} }
} }
......
...@@ -70,6 +70,7 @@ void mt76s_stop_txrx(struct mt76_dev *dev) ...@@ -70,6 +70,7 @@ void mt76s_stop_txrx(struct mt76_dev *dev)
cancel_work_sync(&sdio->tx_work); cancel_work_sync(&sdio->tx_work);
cancel_work_sync(&sdio->rx_work); cancel_work_sync(&sdio->rx_work);
cancel_work_sync(&sdio->work);
cancel_work_sync(&sdio->stat_work); cancel_work_sync(&sdio->stat_work);
clear_bit(MT76_READING_STATS, &dev->phy.state); clear_bit(MT76_READING_STATS, &dev->phy.state);
...@@ -282,41 +283,29 @@ static const struct mt76_queue_ops sdio_queue_ops = { ...@@ -282,41 +283,29 @@ static const struct mt76_queue_ops sdio_queue_ops = {
.tx_queue_skb_raw = mt76s_tx_queue_skb_raw, .tx_queue_skb_raw = mt76s_tx_queue_skb_raw,
}; };
static int mt76s_kthread_run(void *data) static void mt76s_txrx_work(struct work_struct *work)
{ {
struct mt76_dev *dev = data; struct mt76_sdio *sdio = container_of(work, struct mt76_sdio, work);
struct mt76_phy *mphy = &dev->phy; struct mt76_dev *dev = container_of(sdio, struct mt76_dev, sdio);
int i;
while (!kthread_should_stop()) {
int i, nframes = 0;
cond_resched();
/* rx processing */
local_bh_disable();
rcu_read_lock();
mt76_for_each_q_rx(dev, i)
nframes += mt76s_process_rx_queue(dev, &dev->q_rx[i]);
rcu_read_unlock(); /* rx processing */
local_bh_enable(); local_bh_disable();
rcu_read_lock();
/* tx processing */ mt76_for_each_q_rx(dev, i)
for (i = 0; i < MT_TXQ_MCU_WA; i++) mt76s_process_rx_queue(dev, &dev->q_rx[i]);
nframes += mt76s_process_tx_queue(dev, i);
if (dev->drv->tx_status_data && rcu_read_unlock();
!test_and_set_bit(MT76_READING_STATS, &mphy->state)) local_bh_enable();
queue_work(dev->wq, &dev->sdio.stat_work);
if (!nframes || !test_bit(MT76_STATE_RUNNING, &mphy->state)) { /* tx processing */
set_current_state(TASK_INTERRUPTIBLE); for (i = 0; i < MT_TXQ_MCU_WA; i++)
schedule(); mt76s_process_tx_queue(dev, i);
}
}
return 0; if (dev->drv->tx_status_data &&
!test_and_set_bit(MT76_READING_STATS, &dev->phy.state))
queue_work(dev->wq, &dev->sdio.stat_work);
} }
void mt76s_deinit(struct mt76_dev *dev) void mt76s_deinit(struct mt76_dev *dev)
...@@ -324,9 +313,7 @@ void mt76s_deinit(struct mt76_dev *dev) ...@@ -324,9 +313,7 @@ void mt76s_deinit(struct mt76_dev *dev)
struct mt76_sdio *sdio = &dev->sdio; struct mt76_sdio *sdio = &dev->sdio;
int i; int i;
kthread_stop(sdio->kthread);
mt76s_stop_txrx(dev); mt76s_stop_txrx(dev);
if (sdio->txrx_wq) { if (sdio->txrx_wq) {
destroy_workqueue(sdio->txrx_wq); destroy_workqueue(sdio->txrx_wq);
sdio->txrx_wq = NULL; sdio->txrx_wq = NULL;
...@@ -364,11 +351,8 @@ int mt76s_init(struct mt76_dev *dev, struct sdio_func *func, ...@@ -364,11 +351,8 @@ int mt76s_init(struct mt76_dev *dev, struct sdio_func *func,
if (!sdio->txrx_wq) if (!sdio->txrx_wq)
return -ENOMEM; return -ENOMEM;
sdio->kthread = kthread_create(mt76s_kthread_run, dev, "mt76s");
if (IS_ERR(sdio->kthread))
return PTR_ERR(sdio->kthread);
INIT_WORK(&sdio->stat_work, mt76s_tx_status_data); INIT_WORK(&sdio->stat_work, mt76s_tx_status_data);
INIT_WORK(&sdio->work, mt76s_txrx_work);
mutex_init(&sdio->sched.lock); mutex_init(&sdio->sched.lock);
dev->queue_ops = &sdio_queue_ops; dev->queue_ops = &sdio_queue_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment