Re: [PATCH 2/3] gpio: bcm-kona: Make sure GPIO bits are unlocked when requesting IRQ

From: Florian Fainelli
Date: Thu Jan 30 2025 - 17:07:26 EST


On 1/30/25 13:46, Artur Weber wrote:
On 30.01.2025 22:35, Florian Fainelli wrote:
On 1/30/25 09:10, Artur Weber wrote:
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 77bd4ec93a231472d7bc40db9d5db12d20bb1611..eeaa921df6f072129dbdf1c73d6da2bd7c1fe716 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
...
@@ -87,14 +103,25 @@ static void bcm_kona_gpio_lock_gpio(struct bcm_kona_gpio *kona_gpio,
      unsigned long flags;
      int bank_id = GPIO_BANK(gpio);
      int bit = GPIO_BIT(gpio);
+    struct bcm_kona_gpio_bank *bank = &kona_gpio->banks[bank_id];
-    raw_spin_lock_irqsave(&kona_gpio->lock, flags);
+    if (bank->gpio_unlock_count[bit] == 0) {
+        dev_err(kona_gpio->gpio_chip.parent,
+            "Unbalanced locks for GPIO %u\n", gpio);
+        return;

Don't you want to release &kona_gpio->lock here?


If you're talking about the "raw_spin_lock_irqsave" call above the if
condition - note that it has been removed and was actually moved below:

Oh my bad, my eye corrected that - to a + somehow.


+    if (bank->gpio_unlock_count[bit] == 0) {
+        raw_spin_lock_irqsave(&kona_gpio->lock, flags);
+
+        val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id));
+        val |= BIT(bit);
+        bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val);
+
+        raw_spin_unlock_irqrestore(&kona_gpio->lock, flags);
+    }

In general, the diff for this patch did not generate very well, sorry
about that. I'll see if there's anything I can do to improve that in the
future.

Nah that's fine, thanks!
--
Florian