pinctrl: samsung: use raw_spinlock for locking
authorChanho Park <chanho61.park@samsung.com>
Thu, 21 Jan 2021 03:00:09 +0000 (12:00 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 23 Jan 2021 22:33:35 +0000 (23:33 +0100)
This patch converts spin_[lock|unlock] functions of pin bank to
raw_spinlock to support preempt-rt. This can avoid BUG() assertion when
irqchip callbacks are triggerred. Spinlocks can be converted rt_mutex
which is preemptible when we apply preempt-rt patches.

According to "Documentation/driver-api/gpio/driver.rst",

"Realtime considerations: a realtime compliant GPIO driver should not
use spinlock_t or any sleepable APIs (like PM runtime) as part of its
irqchip implementation.

- spinlock_t should be replaced with raw_spinlock_t.[1]
"

Cc: Tomasz Figa <tomasz.figa@gmail.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20210121030009.25673-1-chanho61.park@samsung.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/samsung/pinctrl-exynos.c
drivers/pinctrl/samsung/pinctrl-s3c24xx.c
drivers/pinctrl/samsung/pinctrl-samsung.c
drivers/pinctrl/samsung/pinctrl-samsung.h

index b9ea09fabf8409c3960c4289641b6569dc677cc4..0cd7f33cdf25711e6281908a75c13977b458ca7d 100644 (file)
@@ -58,13 +58,13 @@ static void exynos_irq_mask(struct irq_data *irqd)
        unsigned long mask;
        unsigned long flags;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        mask = readl(bank->eint_base + reg_mask);
        mask |= 1 << irqd->hwirq;
        writel(mask, bank->eint_base + reg_mask);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 }
 
 static void exynos_irq_ack(struct irq_data *irqd)
@@ -97,13 +97,13 @@ static void exynos_irq_unmask(struct irq_data *irqd)
        if (irqd_get_trigger_type(irqd) & IRQ_TYPE_LEVEL_MASK)
                exynos_irq_ack(irqd);
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        mask = readl(bank->eint_base + reg_mask);
        mask &= ~(1 << irqd->hwirq);
        writel(mask, bank->eint_base + reg_mask);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 }
 
 static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type)
@@ -169,14 +169,14 @@ static int exynos_irq_request_resources(struct irq_data *irqd)
        shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC];
        mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        con = readl(bank->pctl_base + reg_con);
        con &= ~(mask << shift);
        con |= EXYNOS_PIN_FUNC_EINT << shift;
        writel(con, bank->pctl_base + reg_con);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 
        return 0;
 }
@@ -192,14 +192,14 @@ static void exynos_irq_release_resources(struct irq_data *irqd)
        shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC];
        mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        con = readl(bank->pctl_base + reg_con);
        con &= ~(mask << shift);
        con |= EXYNOS_PIN_FUNC_INPUT << shift;
        writel(con, bank->pctl_base + reg_con);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 
        gpiochip_unlock_as_irq(&bank->gpio_chip, irqd->hwirq);
 }
index 2223ead5bd721a081474bdc59d84fb6ac820ca7d..00d77d6946b53d55b9900a1739db59203ed87111 100644 (file)
@@ -145,14 +145,14 @@ static void s3c24xx_eint_set_function(struct samsung_pinctrl_drv_data *d,
        shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC];
        mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        val = readl(reg);
        val &= ~(mask << shift);
        val |= bank->eint_func << shift;
        writel(val, reg);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 }
 
 static int s3c24xx_eint_type(struct irq_data *data, unsigned int type)
index 608eb5a07248ed01b228e93e3319a9536d7615e9..376876bd66058190b95af705609e83c3a354eafd 100644 (file)
@@ -400,14 +400,14 @@ static void samsung_pinmux_setup(struct pinctrl_dev *pctldev, unsigned selector,
                reg += 4;
        }
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        data = readl(reg + type->reg_offset[PINCFG_TYPE_FUNC]);
        data &= ~(mask << shift);
        data |= func->val << shift;
        writel(data, reg + type->reg_offset[PINCFG_TYPE_FUNC]);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 }
 
 /* enable a specified pinmux by writing to registers */
@@ -451,7 +451,7 @@ static int samsung_pinconf_rw(struct pinctrl_dev *pctldev, unsigned int pin,
        width = type->fld_width[cfg_type];
        cfg_reg = type->reg_offset[cfg_type];
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
 
        mask = (1 << width) - 1;
        shift = pin_offset * width;
@@ -468,7 +468,7 @@ static int samsung_pinconf_rw(struct pinctrl_dev *pctldev, unsigned int pin,
                *config = PINCFG_PACK(cfg_type, data);
        }
 
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 
        return 0;
 }
@@ -561,9 +561,9 @@ static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
        struct samsung_pin_bank *bank = gpiochip_get_data(gc);
        unsigned long flags;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
        samsung_gpio_set_value(gc, offset, value);
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 }
 
 /* gpiolib gpio_get callback function */
@@ -626,9 +626,9 @@ static int samsung_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
        unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
        ret = samsung_gpio_set_direction(gc, offset, true);
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
        return ret;
 }
 
@@ -640,10 +640,10 @@ static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
        unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&bank->slock, flags);
+       raw_spin_lock_irqsave(&bank->slock, flags);
        samsung_gpio_set_value(gc, offset, value);
        ret = samsung_gpio_set_direction(gc, offset, false);
-       spin_unlock_irqrestore(&bank->slock, flags);
+       raw_spin_unlock_irqrestore(&bank->slock, flags);
 
        return ret;
 }
@@ -1057,7 +1057,7 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
                bank->eint_offset = bdata->eint_offset;
                bank->name = bdata->name;
 
-               spin_lock_init(&bank->slock);
+               raw_spin_lock_init(&bank->slock);
                bank->drvdata = d;
                bank->pin_base = d->nr_pins;
                d->nr_pins += bank->nr_pins;
index 379f34a9a4828536791be8db62fde406d89f8266..de44f8ec330b0b9959e0566375495d0b68bf486d 100644 (file)
@@ -171,7 +171,7 @@ struct samsung_pin_bank {
        struct gpio_chip gpio_chip;
        struct pinctrl_gpio_range grange;
        struct exynos_irq_chip *irq_chip;
-       spinlock_t slock;
+       raw_spinlock_t slock;
 
        u32 pm_save[PINCFG_TYPE_NUM + 1]; /* +1 to handle double CON registers*/
 };