mirror of https://gitee.com/openkylin/linux.git
rt2x00: Fix PCI interrupt processing race on SMP systems
When toggle_irq is called for PCI devices to disable device interrupts it used tasklet_disable to wait for a possibly running tasklet to finish. However, on SMP systems the tasklet might still be scheduled on another CPU. Instead, use tasklet_kill to ensure that all scheduled tasklets are finished before returning from toggle_irq. Furthermore, it was possible that a tasklet reenabled its interrupt even though interrupts have been disabled already. Fix this by checking the DEVICE_STATE_ENABLED_RADIO flag before reenabling single interrupts during tasklet processing. While at it also enable/kill the TBTT and PRETBTT tasklets in the toggle_irq callback and only use tasklet_kill in stop_queue to wait for a currently scheduled beacon update before returning. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
c3ccb3341e
commit
abc1199411
|
@ -645,11 +645,6 @@ static void rt2400pci_start_queue(struct data_queue *queue)
|
|||
rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
|
||||
break;
|
||||
case QID_BEACON:
|
||||
/*
|
||||
* Allow the tbtt tasklet to be scheduled.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->tbtt_tasklet);
|
||||
|
||||
rt2x00pci_register_read(rt2x00dev, CSR14, ®);
|
||||
rt2x00_set_field32(®, CSR14_TSF_COUNT, 1);
|
||||
rt2x00_set_field32(®, CSR14_TBCN, 1);
|
||||
|
@ -715,7 +710,7 @@ static void rt2400pci_stop_queue(struct data_queue *queue)
|
|||
/*
|
||||
* Wait for possibly running tbtt tasklets.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -982,12 +977,6 @@ static void rt2400pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
if (state == STATE_RADIO_IRQ_ON) {
|
||||
rt2x00pci_register_read(rt2x00dev, CSR7, ®);
|
||||
rt2x00pci_register_write(rt2x00dev, CSR7, reg);
|
||||
|
||||
/*
|
||||
* Enable tasklets.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_enable(&rt2x00dev->rxdone_tasklet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1011,8 +1000,9 @@ static void rt2400pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
* Ensure that all tasklets are finished before
|
||||
* disabling the interrupts.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_disable(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_kill(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_kill(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1347,6 +1337,7 @@ static void rt2400pci_txstatus_tasklet(unsigned long data)
|
|||
/*
|
||||
* Enable all TXDONE interrupts again.
|
||||
*/
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) {
|
||||
spin_lock_irq(&rt2x00dev->irqmask_lock);
|
||||
|
||||
rt2x00pci_register_read(rt2x00dev, CSR8, ®);
|
||||
|
@ -1356,12 +1347,14 @@ static void rt2400pci_txstatus_tasklet(unsigned long data)
|
|||
rt2x00pci_register_write(rt2x00dev, CSR8, reg);
|
||||
|
||||
spin_unlock_irq(&rt2x00dev->irqmask_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void rt2400pci_tbtt_tasklet(unsigned long data)
|
||||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt2x00lib_beacondone(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2400pci_enable_interrupt(rt2x00dev, CSR8_TBCN_EXPIRE);
|
||||
}
|
||||
|
||||
|
@ -1370,7 +1363,7 @@ static void rt2400pci_rxdone_tasklet(unsigned long data)
|
|||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
if (rt2x00pci_rxdone(rt2x00dev))
|
||||
tasklet_schedule(&rt2x00dev->rxdone_tasklet);
|
||||
else
|
||||
else if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2400pci_enable_interrupt(rt2x00dev, CSR8_RXDONE);
|
||||
}
|
||||
|
||||
|
|
|
@ -735,11 +735,6 @@ static void rt2500pci_start_queue(struct data_queue *queue)
|
|||
rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
|
||||
break;
|
||||
case QID_BEACON:
|
||||
/*
|
||||
* Allow the tbtt tasklet to be scheduled.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->tbtt_tasklet);
|
||||
|
||||
rt2x00pci_register_read(rt2x00dev, CSR14, ®);
|
||||
rt2x00_set_field32(®, CSR14_TSF_COUNT, 1);
|
||||
rt2x00_set_field32(®, CSR14_TBCN, 1);
|
||||
|
@ -805,7 +800,7 @@ static void rt2500pci_stop_queue(struct data_queue *queue)
|
|||
/*
|
||||
* Wait for possibly running tbtt tasklets.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1137,12 +1132,6 @@ static void rt2500pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
if (state == STATE_RADIO_IRQ_ON) {
|
||||
rt2x00pci_register_read(rt2x00dev, CSR7, ®);
|
||||
rt2x00pci_register_write(rt2x00dev, CSR7, reg);
|
||||
|
||||
/*
|
||||
* Enable tasklets.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_enable(&rt2x00dev->rxdone_tasklet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1165,8 +1154,9 @@ static void rt2500pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
/*
|
||||
* Ensure that all tasklets are finished.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_disable(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_kill(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_kill(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1479,6 +1469,7 @@ static void rt2500pci_txstatus_tasklet(unsigned long data)
|
|||
/*
|
||||
* Enable all TXDONE interrupts again.
|
||||
*/
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) {
|
||||
spin_lock_irq(&rt2x00dev->irqmask_lock);
|
||||
|
||||
rt2x00pci_register_read(rt2x00dev, CSR8, ®);
|
||||
|
@ -1488,12 +1479,14 @@ static void rt2500pci_txstatus_tasklet(unsigned long data)
|
|||
rt2x00pci_register_write(rt2x00dev, CSR8, reg);
|
||||
|
||||
spin_unlock_irq(&rt2x00dev->irqmask_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void rt2500pci_tbtt_tasklet(unsigned long data)
|
||||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt2x00lib_beacondone(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2500pci_enable_interrupt(rt2x00dev, CSR8_TBCN_EXPIRE);
|
||||
}
|
||||
|
||||
|
@ -1502,7 +1495,7 @@ static void rt2500pci_rxdone_tasklet(unsigned long data)
|
|||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
if (rt2x00pci_rxdone(rt2x00dev))
|
||||
tasklet_schedule(&rt2x00dev->rxdone_tasklet);
|
||||
else
|
||||
else if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2500pci_enable_interrupt(rt2x00dev, CSR8_RXDONE);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,13 +200,6 @@ static void rt2800pci_start_queue(struct data_queue *queue)
|
|||
rt2x00pci_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
|
||||
break;
|
||||
case QID_BEACON:
|
||||
/*
|
||||
* Allow beacon tasklets to be scheduled for periodic
|
||||
* beacon updates.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_enable(&rt2x00dev->pretbtt_tasklet);
|
||||
|
||||
rt2x00pci_register_read(rt2x00dev, BCN_TIME_CFG, ®);
|
||||
rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1);
|
||||
rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1);
|
||||
|
@ -269,10 +262,13 @@ static void rt2800pci_stop_queue(struct data_queue *queue)
|
|||
rt2x00pci_register_write(rt2x00dev, INT_TIMER_EN, reg);
|
||||
|
||||
/*
|
||||
* Wait for tbtt tasklets to finish.
|
||||
* Wait for current invocation to finish. The tasklet
|
||||
* won't be scheduled anymore afterwards since we disabled
|
||||
* the TBTT and PRE TBTT timer.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_disable(&rt2x00dev->pretbtt_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_kill(&rt2x00dev->pretbtt_tasklet);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -437,14 +433,6 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
if (state == STATE_RADIO_IRQ_ON) {
|
||||
rt2x00pci_register_read(rt2x00dev, INT_SOURCE_CSR, ®);
|
||||
rt2x00pci_register_write(rt2x00dev, INT_SOURCE_CSR, reg);
|
||||
|
||||
/*
|
||||
* Enable tasklets. The beacon related tasklets are
|
||||
* enabled when the beacon queue is started.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_enable(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_enable(&rt2x00dev->autowake_tasklet);
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&rt2x00dev->irqmask_lock, flags);
|
||||
|
@ -472,12 +460,13 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
|
||||
if (state == STATE_RADIO_IRQ_OFF) {
|
||||
/*
|
||||
* Ensure that all tasklets are finished before
|
||||
* disabling the interrupts.
|
||||
* Wait for possibly running tasklets to finish.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_disable(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_disable(&rt2x00dev->autowake_tasklet);
|
||||
tasklet_kill(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_kill(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_kill(&rt2x00dev->autowake_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_kill(&rt2x00dev->pretbtt_tasklet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -813,6 +802,7 @@ static void rt2800pci_pretbtt_tasklet(unsigned long data)
|
|||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt2x00lib_pretbtt(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2800pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_PRE_TBTT);
|
||||
}
|
||||
|
||||
|
@ -820,6 +810,7 @@ static void rt2800pci_tbtt_tasklet(unsigned long data)
|
|||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt2x00lib_beacondone(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2800pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_TBTT);
|
||||
}
|
||||
|
||||
|
@ -828,7 +819,7 @@ static void rt2800pci_rxdone_tasklet(unsigned long data)
|
|||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
if (rt2x00pci_rxdone(rt2x00dev))
|
||||
tasklet_schedule(&rt2x00dev->rxdone_tasklet);
|
||||
else
|
||||
else if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2800pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_RX_DONE);
|
||||
}
|
||||
|
||||
|
@ -836,6 +827,7 @@ static void rt2800pci_autowake_tasklet(unsigned long data)
|
|||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt2800pci_wakeup(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt2800pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_AUTO_WAKEUP);
|
||||
}
|
||||
|
||||
|
|
|
@ -946,7 +946,6 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
|
|||
tasklet_init(&rt2x00dev->taskletname, \
|
||||
rt2x00dev->ops->lib->taskletname, \
|
||||
(unsigned long)rt2x00dev); \
|
||||
tasklet_disable(&rt2x00dev->taskletname); \
|
||||
}
|
||||
|
||||
RT2X00_TASKLET_INIT(txstatus_tasklet);
|
||||
|
|
|
@ -1142,11 +1142,6 @@ static void rt61pci_start_queue(struct data_queue *queue)
|
|||
rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
|
||||
break;
|
||||
case QID_BEACON:
|
||||
/*
|
||||
* Allow the tbtt tasklet to be scheduled.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->tbtt_tasklet);
|
||||
|
||||
rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, ®);
|
||||
rt2x00_set_field32(®, TXRX_CSR9_TSF_TICKING, 1);
|
||||
rt2x00_set_field32(®, TXRX_CSR9_TBTT_ENABLE, 1);
|
||||
|
@ -1230,7 +1225,7 @@ static void rt61pci_stop_queue(struct data_queue *queue)
|
|||
/*
|
||||
* Wait for possibly running tbtt tasklets.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->tbtt_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1731,13 +1726,6 @@ static void rt61pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
|
||||
rt2x00pci_register_read(rt2x00dev, MCU_INT_SOURCE_CSR, ®);
|
||||
rt2x00pci_register_write(rt2x00dev, MCU_INT_SOURCE_CSR, reg);
|
||||
|
||||
/*
|
||||
* Enable tasklets.
|
||||
*/
|
||||
tasklet_enable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_enable(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_enable(&rt2x00dev->autowake_tasklet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1772,9 +1760,10 @@ static void rt61pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
|
|||
/*
|
||||
* Ensure that all tasklets are finished.
|
||||
*/
|
||||
tasklet_disable(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_disable(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_disable(&rt2x00dev->autowake_tasklet);
|
||||
tasklet_kill(&rt2x00dev->txstatus_tasklet);
|
||||
tasklet_kill(&rt2x00dev->rxdone_tasklet);
|
||||
tasklet_kill(&rt2x00dev->autowake_tasklet);
|
||||
tasklet_kill(&rt2x00dev->tbtt_tasklet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2300,6 +2289,7 @@ static void rt61pci_txstatus_tasklet(unsigned long data)
|
|||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt61pci_txdone(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt61pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_TXDONE);
|
||||
}
|
||||
|
||||
|
@ -2307,6 +2297,7 @@ static void rt61pci_tbtt_tasklet(unsigned long data)
|
|||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
rt2x00lib_beacondone(rt2x00dev);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt61pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_BEACON_DONE);
|
||||
}
|
||||
|
||||
|
@ -2314,8 +2305,8 @@ static void rt61pci_rxdone_tasklet(unsigned long data)
|
|||
{
|
||||
struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
|
||||
if (rt2x00pci_rxdone(rt2x00dev))
|
||||
rt2x00pci_rxdone(rt2x00dev);
|
||||
else
|
||||
tasklet_schedule(&rt2x00dev->rxdone_tasklet);
|
||||
else if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt61pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_RXDONE);
|
||||
}
|
||||
|
||||
|
@ -2325,6 +2316,7 @@ static void rt61pci_autowake_tasklet(unsigned long data)
|
|||
rt61pci_wakeup(rt2x00dev);
|
||||
rt2x00pci_register_write(rt2x00dev,
|
||||
M2H_CMD_DONE_CSR, 0xffffffff);
|
||||
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
||||
rt61pci_enable_mcu_interrupt(rt2x00dev, MCU_INT_MASK_CSR_TWAKEUP);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue