[rt2x00-users] [RFC 2/9] rt2x00: convert to threaded interrupts
Ivo Van Doorn
ivdoorn at gmail.com
Mon Jul 5 17:08:57 UTC 2010
On Mon, Jul 5, 2010 at 6:20 PM, Helmut Schaa
<helmut.schaa at googlemail.com> wrote:
> Convert all rt2x00 pci drivers to threaded interrupts. This has several
> generic advantages:
> - The time we spend in hard irq context is reduced
> - We can use non atomic mac80211 functions for rx/tx
>
> This patch is also needed for implementing proper broad- and multicast
> buffering in AP mode and proper beacon updating during the pre tbtt
> interrupt.
>
> Signed-off-by: Helmut Schaa <helmut.schaa at googlemail.com>
> ---
> drivers/net/wireless/rt2x00/rt2400pci.c | 52 ++++++++++++++++-------
> drivers/net/wireless/rt2x00/rt2500pci.c | 52 ++++++++++++++++-------
> drivers/net/wireless/rt2x00/rt2800pci.c | 46 +++++++++++++++-----
> drivers/net/wireless/rt2x00/rt2x00.h | 11 +++++
> drivers/net/wireless/rt2x00/rt2x00dev.c | 6 +-
> drivers/net/wireless/rt2x00/rt2x00pci.c | 6 ++-
> drivers/net/wireless/rt2x00/rt61pci.c | 71 ++++++++++++++++++++++--------
> 7 files changed, 178 insertions(+), 66 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
> index b627fdc..fcb1cce 100644
> --- a/drivers/net/wireless/rt2x00/rt2400pci.c
> +++ b/drivers/net/wireless/rt2x00/rt2400pci.c
> @@ -1231,23 +1231,10 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev,
> }
> }
>
> -static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance)
> +static irqreturn_t rt2400pci_interrupt_thread(int irq, void *dev_instance)
> {
> struct rt2x00_dev *rt2x00dev = dev_instance;
> - u32 reg;
> -
> - /*
> - * Get the interrupt sources & saved to local variable.
> - * Write register value back to clear pending interrupts.
> - */
> - rt2x00pci_register_read(rt2x00dev, CSR7, ®);
> - rt2x00pci_register_write(rt2x00dev, CSR7, reg);
> -
> - if (!reg)
> - return IRQ_NONE;
> -
> - if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
> - return IRQ_HANDLED;
> + u32 reg = rt2x00dev->irqvalue[0];
>
> /*
> * Handle interrupts, walk through all bits
> @@ -1285,9 +1272,43 @@ static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance)
> if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING))
> rt2400pci_txdone(rt2x00dev, QID_AC_BK);
>
> + /* Enable interrupts again. */
> + rt2x00pci_register_read(rt2x00dev, CSR8, ®);
> + reg &= ~rt2x00dev->irqmask[0];
> + rt2x00pci_register_write(rt2x00dev, CSR8, reg);
> +
Cant this be replaced with:
rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON)
That way we keep the IRQ changing code in one location,
and we keep the code clearer compared to using masks which
obscure the real action.
> return IRQ_HANDLED;
> }
>
> +static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance)
> +{
> + struct rt2x00_dev *rt2x00dev = dev_instance;
> + u32 reg;
> +
> + /*
> + * Get the interrupt sources & saved to local variable.
> + * Write register value back to clear pending interrupts.
> + */
> + rt2x00pci_register_read(rt2x00dev, CSR7, ®);
> + rt2x00pci_register_write(rt2x00dev, CSR7, reg);
> +
> + if (!reg)
> + return IRQ_NONE;
> +
> + if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
> + return IRQ_HANDLED;
> +
> + /* Store irqvalues for use in the interrupt thread. */
> + rt2x00dev->irqvalue[0] = reg;
> +
> + /* Disable interrupts, will be enabled again in the interrupt thread. */
> + rt2x00pci_register_read(rt2x00dev, CSR8, ®);
> + reg |= rt2x00dev->irqmask[0];
> + rt2x00pci_register_write(rt2x00dev, CSR8, reg);
Cant this be replaced with:
rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF)
> + return IRQ_WAKE_THREAD;
> +}
> +
> /*
> * Device probe functions.
> */
> @@ -1587,6 +1608,7 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
>
> static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
> .irq_handler = rt2400pci_interrupt,
> + .irq_handler_thread = rt2400pci_interrupt_thread,
> .probe_hw = rt2400pci_probe_hw,
> .initialize = rt2x00pci_initialize,
> .uninitialize = rt2x00pci_uninitialize,
Ivo
More information about the users
mailing list