Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: ath79: make use of raw_spinlock variants

The ath79 gpio driver currently implements an irq_chip for handling
interrupts; due to how irq_chip handling is done, it's necessary for the
irq_chip methods to be invoked from hardirq context, even on a a
real-time kernel. Because the spinlock_t type becomes a "sleeping"
spinlock w/ RT kernels, it is not suitable to be used with irq_chips.

A quick audit of the operations under the lock reveal that they do only
minimal, bounded work, and are therefore safe to do under a raw spinlock.

Signed-off-by: Julia Cartwright <julia@ni.com>
Acked-by: Aban Bedel <albeu@free.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Julia Cartwright and committed by
Linus Walleij
a080ce53 c69fcea5

+14 -14
+14 -14
drivers/gpio/gpio-ath79.c
··· 32 32 struct ath79_gpio_ctrl { 33 33 struct gpio_chip gc; 34 34 void __iomem *base; 35 - spinlock_t lock; 35 + raw_spinlock_t lock; 36 36 unsigned long both_edges; 37 37 }; 38 38 ··· 74 74 u32 mask = BIT(irqd_to_hwirq(data)); 75 75 unsigned long flags; 76 76 77 - spin_lock_irqsave(&ctrl->lock, flags); 77 + raw_spin_lock_irqsave(&ctrl->lock, flags); 78 78 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); 79 - spin_unlock_irqrestore(&ctrl->lock, flags); 79 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 80 80 } 81 81 82 82 static void ath79_gpio_irq_mask(struct irq_data *data) ··· 85 85 u32 mask = BIT(irqd_to_hwirq(data)); 86 86 unsigned long flags; 87 87 88 - spin_lock_irqsave(&ctrl->lock, flags); 88 + raw_spin_lock_irqsave(&ctrl->lock, flags); 89 89 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); 90 - spin_unlock_irqrestore(&ctrl->lock, flags); 90 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 91 91 } 92 92 93 93 static void ath79_gpio_irq_enable(struct irq_data *data) ··· 96 96 u32 mask = BIT(irqd_to_hwirq(data)); 97 97 unsigned long flags; 98 98 99 - spin_lock_irqsave(&ctrl->lock, flags); 99 + raw_spin_lock_irqsave(&ctrl->lock, flags); 100 100 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); 101 101 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); 102 - spin_unlock_irqrestore(&ctrl->lock, flags); 102 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 103 103 } 104 104 105 105 static void ath79_gpio_irq_disable(struct irq_data *data) ··· 108 108 u32 mask = BIT(irqd_to_hwirq(data)); 109 109 unsigned long flags; 110 110 111 - spin_lock_irqsave(&ctrl->lock, flags); 111 + raw_spin_lock_irqsave(&ctrl->lock, flags); 112 112 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); 113 113 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, 0); 114 - spin_unlock_irqrestore(&ctrl->lock, flags); 114 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 115 115 } 116 116 117 117 static int ath79_gpio_irq_set_type(struct irq_data *data, ··· 140 140 return -EINVAL; 141 141 } 142 142 143 - spin_lock_irqsave(&ctrl->lock, flags); 143 + raw_spin_lock_irqsave(&ctrl->lock, flags); 144 144 145 145 if (flow_type == IRQ_TYPE_EDGE_BOTH) { 146 146 ctrl->both_edges |= mask; ··· 165 165 ath79_gpio_update_bits( 166 166 ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); 167 167 168 - spin_unlock_irqrestore(&ctrl->lock, flags); 168 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 169 169 170 170 return 0; 171 171 } ··· 191 191 192 192 chained_irq_enter(irqchip, desc); 193 193 194 - spin_lock_irqsave(&ctrl->lock, flags); 194 + raw_spin_lock_irqsave(&ctrl->lock, flags); 195 195 196 196 pending = ath79_gpio_read(ctrl, AR71XX_GPIO_REG_INT_PENDING); 197 197 ··· 203 203 both_edges, ~state); 204 204 } 205 205 206 - spin_unlock_irqrestore(&ctrl->lock, flags); 206 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 207 207 208 208 if (pending) { 209 209 for_each_set_bit(irq, &pending, gc->ngpio) ··· 262 262 if (!ctrl->base) 263 263 return -ENOMEM; 264 264 265 - spin_lock_init(&ctrl->lock); 265 + raw_spin_lock_init(&ctrl->lock); 266 266 err = bgpio_init(&ctrl->gc, &pdev->dev, 4, 267 267 ctrl->base + AR71XX_GPIO_REG_IN, 268 268 ctrl->base + AR71XX_GPIO_REG_SET,