All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	linux-gpio@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 02/24] pinctrl: lynxpoint: Use raw_spinlock for locking
Date: Mon,  9 Dec 2019 15:09:04 +0200	[thread overview]
Message-ID: <20191209130926.86483-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20191209130926.86483-1-andriy.shevchenko@linux.intel.com>

The Intel Lynxpoint pinctrl driver implements irqchip callbacks which are
called with desc->lock raw_spinlock held. In mainline this is fine because
spinlock resolves to raw_spinlock. However, running the same code in -rt
we will get a BUG() asserted.

This is because in -rt spinlocks are preemptible so taking the driver
private spinlock in irqchip callbacks causes might_sleep() to trigger.

In order to keep -rt happy but at the same time make sure that register
accesses get serialized, convert the driver to use raw_spinlock instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-lynxpoint.c | 28 +++++++++++------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-lynxpoint.c b/drivers/pinctrl/intel/pinctrl-lynxpoint.c
index 490ce7bae25e..c30fd86846a7 100644
--- a/drivers/pinctrl/intel/pinctrl-lynxpoint.c
+++ b/drivers/pinctrl/intel/pinctrl-lynxpoint.c
@@ -47,7 +47,7 @@
 struct lp_gpio {
 	struct gpio_chip	chip;
 	struct platform_device	*pdev;
-	spinlock_t		lock;
+	raw_spinlock_t		lock;
 	unsigned long		reg_base;
 };
 
@@ -144,7 +144,7 @@ static int lp_irq_type(struct irq_data *d, unsigned type)
 	if (hwirq >= lg->chip.ngpio)
 		return -EINVAL;
 
-	spin_lock_irqsave(&lg->lock, flags);
+	raw_spin_lock_irqsave(&lg->lock, flags);
 	value = inl(reg);
 
 	/* set both TRIG_SEL and INV bits to 0 for rising edge */
@@ -170,7 +170,7 @@ static int lp_irq_type(struct irq_data *d, unsigned type)
 	else if (type & IRQ_TYPE_LEVEL_MASK)
 		irq_set_handler_locked(d, handle_level_irq);
 
-	spin_unlock_irqrestore(&lg->lock, flags);
+	raw_spin_unlock_irqrestore(&lg->lock, flags);
 
 	return 0;
 }
@@ -187,14 +187,14 @@ static void lp_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
 	unsigned long flags;
 
-	spin_lock_irqsave(&lg->lock, flags);
+	raw_spin_lock_irqsave(&lg->lock, flags);
 
 	if (value)
 		outl(inl(reg) | OUT_LVL_BIT, reg);
 	else
 		outl(inl(reg) & ~OUT_LVL_BIT, reg);
 
-	spin_unlock_irqrestore(&lg->lock, flags);
+	raw_spin_unlock_irqrestore(&lg->lock, flags);
 }
 
 static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -203,9 +203,9 @@ static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 	unsigned long reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
 	unsigned long flags;
 
-	spin_lock_irqsave(&lg->lock, flags);
+	raw_spin_lock_irqsave(&lg->lock, flags);
 	outl(inl(reg) | DIR_BIT, reg);
-	spin_unlock_irqrestore(&lg->lock, flags);
+	raw_spin_unlock_irqrestore(&lg->lock, flags);
 
 	return 0;
 }
@@ -219,9 +219,9 @@ static int lp_gpio_direction_output(struct gpio_chip *chip,
 
 	lp_gpio_set(chip, offset, value);
 
-	spin_lock_irqsave(&lg->lock, flags);
+	raw_spin_lock_irqsave(&lg->lock, flags);
 	outl(inl(reg) & ~DIR_BIT, reg);
-	spin_unlock_irqrestore(&lg->lock, flags);
+	raw_spin_unlock_irqrestore(&lg->lock, flags);
 
 	return 0;
 }
@@ -272,9 +272,9 @@ static void lp_irq_enable(struct irq_data *d)
 	unsigned long reg = lp_gpio_reg(&lg->chip, hwirq, LP_INT_ENABLE);
 	unsigned long flags;
 
-	spin_lock_irqsave(&lg->lock, flags);
+	raw_spin_lock_irqsave(&lg->lock, flags);
 	outl(inl(reg) | BIT(hwirq % 32), reg);
-	spin_unlock_irqrestore(&lg->lock, flags);
+	raw_spin_unlock_irqrestore(&lg->lock, flags);
 }
 
 static void lp_irq_disable(struct irq_data *d)
@@ -285,9 +285,9 @@ static void lp_irq_disable(struct irq_data *d)
 	unsigned long reg = lp_gpio_reg(&lg->chip, hwirq, LP_INT_ENABLE);
 	unsigned long flags;
 
-	spin_lock_irqsave(&lg->lock, flags);
+	raw_spin_lock_irqsave(&lg->lock, flags);
 	outl(inl(reg) & ~BIT(hwirq % 32), reg);
-	spin_unlock_irqrestore(&lg->lock, flags);
+	raw_spin_unlock_irqrestore(&lg->lock, flags);
 }
 
 static struct irq_chip lp_irqchip = {
@@ -351,7 +351,7 @@ static int lp_gpio_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
-	spin_lock_init(&lg->lock);
+	raw_spin_lock_init(&lg->lock);
 
 	gc = &lg->chip;
 	gc->label = dev_name(dev);
-- 
2.24.0


  parent reply	other threads:[~2019-12-09 13:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 13:09 [PATCH v2 00/24] pinctrl: intel: Move Lynxpoint to pin control umbrella Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 01/24] pinctrl: lynxpoint: Move GPIO driver to pin controller folder Andy Shevchenko
2019-12-09 13:09 ` Andy Shevchenko [this message]
2019-12-09 13:09 ` [PATCH v2 03/24] pinctrl: lynxpoint: Correct amount of pins Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 04/24] pinctrl: lynxpoint: Drop useless assignment Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 05/24] pinctrl: lynxpoint: Use %pR to print IO resource Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 06/24] pinctrl: lynxpoint: Use standard pattern for memory allocation Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 07/24] pinctrl: lynxpoint: Assume 2 bits for mode selector Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 08/24] pinctrl: lynxpoint: Relax GPIO request rules Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 09/24] pinctrl: lynxpoint: Keep pointer to struct device instead of its container Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 10/24] pinctrl: lynxpoint: Switch to memory mapped IO accessors Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 11/24] pinctrl: lynxpoint: Convert unsigned to unsigned int Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 12/24] pinctrl: lynxpoint: Extract lp_gpio_acpi_use() for future use Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 13/24] pinctrl: lynxpoint: Move ->remove closer to ->probe() Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 14/24] pinctrl: lynxpoint: Move lp_irq_type() closer to IRQ related routines Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 15/24] pinctrl: lynxpoint: Move ownership check to IRQ chip Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 16/24] pinctrl: lynxpoint: Implement ->irq_ack() callback Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 17/24] pinctrl: lynxpoint: Implement intel_gpio_get_direction callback Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 18/24] pinctrl: lynxpoint: Add pin control data structures Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 19/24] pinctrl: lynxpoint: Reuse struct intel_pinctrl in the driver Andy Shevchenko
2019-12-10  5:26   ` kbuild test robot
2019-12-10 13:46     ` Andy Shevchenko
2019-12-10 13:47       ` Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 20/24] pinctrl: lynxpoint: Add pin control operations Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 21/24] pinctrl: lynxpoint: Implement ->pin_dbg_show() Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 22/24] pinctrl: lynxpoint: Add GPIO <-> pin mapping ranges via callback Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 23/24] pinctrl: lynxpoint: Switch to pin control API Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 24/24] pinctrl: lynxpoint: Update summary in the driver Andy Shevchenko
2019-12-11 13:19 ` [PATCH v2 00/24] pinctrl: intel: Move Lynxpoint to pin control umbrella Mika Westerberg
2019-12-13 13:36 ` Linus Walleij
2019-12-13 14:44   ` Andy Shevchenko
2019-12-16 10:19     ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191209130926.86483-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.