All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] gpio: xilinx: Convert gpio_lock to raw spinlock" failed to apply to 6.1-stable tree
@ 2025-01-20 13:44 gregkh
  2025-01-21 18:41 ` [PATCH 6.1.y] gpio: xilinx: Convert gpio_lock to raw spinlock Sean Anderson
  0 siblings, 1 reply; 7+ messages in thread
From: gregkh @ 2025-01-20 13:44 UTC (permalink / raw)
  To: sean.anderson, bartosz.golaszewski; +Cc: stable


The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 9860370c2172704b6b4f0075a0c2a29fd84af96a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025012027-shaft-catalyst-2d69@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 9860370c2172704b6b4f0075a0c2a29fd84af96a Mon Sep 17 00:00:00 2001
From: Sean Anderson <sean.anderson@linux.dev>
Date: Fri, 10 Jan 2025 11:33:54 -0500
Subject: [PATCH] gpio: xilinx: Convert gpio_lock to raw spinlock

irq_chip functions may be called in raw spinlock context. Therefore, we
must also use a raw spinlock for our own internal locking.

This fixes the following lockdep splat:

[    5.349336] =============================
[    5.353349] [ BUG: Invalid wait context ]
[    5.357361] 6.13.0-rc5+ #69 Tainted: G        W
[    5.363031] -----------------------------
[    5.367045] kworker/u17:1/44 is trying to lock:
[    5.371587] ffffff88018b02c0 (&chip->gpio_lock){....}-{3:3}, at: xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
[    5.380079] other info that might help us debug this:
[    5.385138] context-{5:5}
[    5.387762] 5 locks held by kworker/u17:1/44:
[    5.392123] #0: ffffff8800014958 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3204)
[    5.402260] #1: ffffffc082fcbdd8 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3205)
[    5.411528] #2: ffffff880172c900 (&dev->mutex){....}-{4:4}, at: __device_attach (drivers/base/dd.c:1006)
[    5.419929] #3: ffffff88039c8268 (request_class#2){+.+.}-{4:4}, at: __setup_irq (kernel/irq/internals.h:156 kernel/irq/manage.c:1596)
[    5.428331] #4: ffffff88039c80c8 (lock_class#2){....}-{2:2}, at: __setup_irq (kernel/irq/manage.c:1614)
[    5.436472] stack backtrace:
[    5.439359] CPU: 2 UID: 0 PID: 44 Comm: kworker/u17:1 Tainted: G        W          6.13.0-rc5+ #69
[    5.448690] Tainted: [W]=WARN
[    5.451656] Hardware name: xlnx,zynqmp (DT)
[    5.455845] Workqueue: events_unbound deferred_probe_work_func
[    5.461699] Call trace:
[    5.464147] show_stack+0x18/0x24 C
[    5.467821] dump_stack_lvl (lib/dump_stack.c:123)
[    5.471501] dump_stack (lib/dump_stack.c:130)
[    5.474824] __lock_acquire (kernel/locking/lockdep.c:4828 kernel/locking/lockdep.c:4898 kernel/locking/lockdep.c:5176)
[    5.478758] lock_acquire (arch/arm64/include/asm/percpu.h:40 kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5851 kernel/locking/lockdep.c:5814)
[    5.482429] _raw_spin_lock_irqsave (include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
[    5.486797] xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
[    5.490737] irq_enable (kernel/irq/internals.h:236 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345)
[    5.494060] __irq_startup (kernel/irq/internals.h:241 kernel/irq/chip.c:180 kernel/irq/chip.c:250)
[    5.497645] irq_startup (kernel/irq/chip.c:270)
[    5.501143] __setup_irq (kernel/irq/manage.c:1807)
[    5.504728] request_threaded_irq (kernel/irq/manage.c:2208)

Fixes: a32c7caea292 ("gpio: gpio-xilinx: Add interrupt support")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250110163354.2012654-1-sean.anderson@linux.dev
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index c6a8f2c82680..792d94c49077 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -65,7 +65,7 @@ struct xgpio_instance {
 	DECLARE_BITMAP(state, 64);
 	DECLARE_BITMAP(last_irq_read, 64);
 	DECLARE_BITMAP(dir, 64);
-	spinlock_t gpio_lock;	/* For serializing operations */
+	raw_spinlock_t gpio_lock;	/* For serializing operations */
 	int irq;
 	DECLARE_BITMAP(enable, 64);
 	DECLARE_BITMAP(rising_edge, 64);
@@ -179,14 +179,14 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Write to GPIO signal and set its direction to output */
 	__assign_bit(bit, chip->state, val);
 
 	xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -210,7 +210,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 	bitmap_remap(hw_mask, mask, chip->sw_map, chip->hw_map, 64);
 	bitmap_remap(hw_bits, bits, chip->sw_map, chip->hw_map, 64);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	bitmap_replace(state, chip->state, hw_bits, hw_mask, 64);
 
@@ -218,7 +218,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 
 	bitmap_copy(chip->state, state, 64);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -236,13 +236,13 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Set the GPIO bit in shadow register and set direction as input */
 	__set_bit(bit, chip->dir);
 	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	return 0;
 }
@@ -265,7 +265,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Write state of GPIO signal */
 	__assign_bit(bit, chip->state, val);
@@ -275,7 +275,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	__clear_bit(bit, chip->dir);
 	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	return 0;
 }
@@ -398,7 +398,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
 	int bit = xgpio_to_bit(chip, irq_offset);
 	u32 mask = BIT(bit / 32), temp;
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	__clear_bit(bit, chip->enable);
 
@@ -408,7 +408,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
 		temp &= ~mask;
 		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp);
 	}
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	gpiochip_disable_irq(&chip->gc, irq_offset);
 }
@@ -428,7 +428,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
 
 	gpiochip_enable_irq(&chip->gc, irq_offset);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	__set_bit(bit, chip->enable);
 
@@ -447,7 +447,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
 		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val);
 	}
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -512,7 +512,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
 
 	chained_irq_enter(irqchip, desc);
 
-	spin_lock(&chip->gpio_lock);
+	raw_spin_lock(&chip->gpio_lock);
 
 	xgpio_read_ch_all(chip, XGPIO_DATA_OFFSET, all);
 
@@ -529,7 +529,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
 	bitmap_copy(chip->last_irq_read, all, 64);
 	bitmap_or(all, rising, falling, 64);
 
-	spin_unlock(&chip->gpio_lock);
+	raw_spin_unlock(&chip->gpio_lock);
 
 	dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling);
 
@@ -620,7 +620,7 @@ static int xgpio_probe(struct platform_device *pdev)
 	bitmap_set(chip->hw_map,  0, width[0]);
 	bitmap_set(chip->hw_map, 32, width[1]);
 
-	spin_lock_init(&chip->gpio_lock);
+	raw_spin_lock_init(&chip->gpio_lock);
 
 	chip->gc.base = -1;
 	chip->gc.ngpio = bitmap_weight(chip->hw_map, 64);


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6.1.y] gpio: xilinx: Convert gpio_lock to raw spinlock
  2025-01-20 13:44 FAILED: patch "[PATCH] gpio: xilinx: Convert gpio_lock to raw spinlock" failed to apply to 6.1-stable tree gregkh
@ 2025-01-21 18:41 ` Sean Anderson
  2025-01-21 19:27   ` Sean Anderson
  2025-01-21 19:32   ` [PATCH 6.1.y v2] " Sean Anderson
  0 siblings, 2 replies; 7+ messages in thread
From: Sean Anderson @ 2025-01-21 18:41 UTC (permalink / raw)
  To: stable; +Cc: Sean Anderson, Bartosz Golaszewski

[ Upstream commit c17ff476f53afb30f90bb3c2af77de069c81a622 ]

irq_chip functions may be called in raw spinlock context. Therefore, we
must also use a raw spinlock for our own internal locking.

This fixes the following lockdep splat:

[    5.349336] =============================
[    5.353349] [ BUG: Invalid wait context ]
[    5.357361] 6.13.0-rc5+ #69 Tainted: G        W
[    5.363031] -----------------------------
[    5.367045] kworker/u17:1/44 is trying to lock:
[    5.371587] ffffff88018b02c0 (&chip->gpio_lock){....}-{3:3}, at: xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
[    5.380079] other info that might help us debug this:
[    5.385138] context-{5:5}
[    5.387762] 5 locks held by kworker/u17:1/44:
[    5.392123] #0: ffffff8800014958 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3204)
[    5.402260] #1: ffffffc082fcbdd8 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3205)
[    5.411528] #2: ffffff880172c900 (&dev->mutex){....}-{4:4}, at: __device_attach (drivers/base/dd.c:1006)
[    5.419929] #3: ffffff88039c8268 (request_class#2){+.+.}-{4:4}, at: __setup_irq (kernel/irq/internals.h:156 kernel/irq/manage.c:1596)
[    5.428331] #4: ffffff88039c80c8 (lock_class#2){....}-{2:2}, at: __setup_irq (kernel/irq/manage.c:1614)
[    5.436472] stack backtrace:
[    5.439359] CPU: 2 UID: 0 PID: 44 Comm: kworker/u17:1 Tainted: G        W          6.13.0-rc5+ #69
[    5.448690] Tainted: [W]=WARN
[    5.451656] Hardware name: xlnx,zynqmp (DT)
[    5.455845] Workqueue: events_unbound deferred_probe_work_func
[    5.461699] Call trace:
[    5.464147] show_stack+0x18/0x24 C
[    5.467821] dump_stack_lvl (lib/dump_stack.c:123)
[    5.471501] dump_stack (lib/dump_stack.c:130)
[    5.474824] __lock_acquire (kernel/locking/lockdep.c:4828 kernel/locking/lockdep.c:4898 kernel/locking/lockdep.c:5176)
[    5.478758] lock_acquire (arch/arm64/include/asm/percpu.h:40 kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5851 kernel/locking/lockdep.c:5814)
[    5.482429] _raw_spin_lock_irqsave (include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
[    5.486797] xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
[    5.490737] irq_enable (kernel/irq/internals.h:236 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345)
[    5.494060] __irq_startup (kernel/irq/internals.h:241 kernel/irq/chip.c:180 kernel/irq/chip.c:250)
[    5.497645] irq_startup (kernel/irq/chip.c:270)
[    5.501143] __setup_irq (kernel/irq/manage.c:1807)
[    5.504728] request_threaded_irq (kernel/irq/manage.c:2208)

Fixes: a32c7caea292 ("gpio: gpio-xilinx: Add interrupt support")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250110163354.2012654-1-sean.anderson@linux.dev
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
[ resolved conflicts ]
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
 drivers/gpio/gpio-xilinx.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 2fc6b6ff7f16..58cbf763ee21 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -66,7 +66,7 @@ struct xgpio_instance {
 	DECLARE_BITMAP(state, 64);
 	DECLARE_BITMAP(last_irq_read, 64);
 	DECLARE_BITMAP(dir, 64);
-	spinlock_t gpio_lock;	/* For serializing operations */
+	raw_spinlock_t gpio_lock;	/* For serializing operations */
 	int irq;
 	struct irq_chip irqchip;
 	DECLARE_BITMAP(enable, 64);
@@ -181,14 +181,14 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Write to GPIO signal and set its direction to output */
 	__assign_bit(bit, chip->state, val);
 
 	xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -212,7 +212,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 	bitmap_remap(hw_mask, mask, chip->sw_map, chip->hw_map, 64);
 	bitmap_remap(hw_bits, bits, chip->sw_map, chip->hw_map, 64);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	bitmap_replace(state, chip->state, hw_bits, hw_mask, 64);
 
@@ -220,7 +220,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 
 	bitmap_copy(chip->state, state, 64);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -238,13 +238,13 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Set the GPIO bit in shadow register and set direction as input */
 	__set_bit(bit, chip->dir);
 	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	return 0;
 }
@@ -267,7 +267,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Write state of GPIO signal */
 	__assign_bit(bit, chip->state, val);
@@ -277,7 +277,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	__clear_bit(bit, chip->dir);
 	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	return 0;
 }
@@ -405,7 +405,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
 	int bit = xgpio_to_bit(chip, irq_offset);
 	u32 mask = BIT(bit / 32), temp;
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	__clear_bit(bit, chip->enable);
 
@@ -415,7 +415,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
 		temp &= ~mask;
 		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp);
 	}
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -431,7 +431,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
 	u32 old_enable = xgpio_get_value32(chip->enable, bit);
 	u32 mask = BIT(bit / 32), val;
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	__set_bit(bit, chip->enable);
 
@@ -450,7 +450,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
 		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val);
 	}
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -515,7 +515,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
 
 	chained_irq_enter(irqchip, desc);
 
-	spin_lock(&chip->gpio_lock);
+	raw_spin_lock(&chip->gpio_lock);
 
 	xgpio_read_ch_all(chip, XGPIO_DATA_OFFSET, all);
 
@@ -532,7 +532,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
 	bitmap_copy(chip->last_irq_read, all, 64);
 	bitmap_or(all, rising, falling, 64);
 
-	spin_unlock(&chip->gpio_lock);
+	raw_spin_unlock(&chip->gpio_lock);
 
 	dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling);
 
@@ -623,7 +623,7 @@ static int xgpio_probe(struct platform_device *pdev)
 	bitmap_set(chip->hw_map,  0, width[0]);
 	bitmap_set(chip->hw_map, 32, width[1]);
 
-	spin_lock_init(&chip->gpio_lock);
+	raw_spin_lock_init(&chip->gpio_lock);
 
 	chip->gc.base = -1;
 	chip->gc.ngpio = bitmap_weight(chip->hw_map, 64);
-- 
2.35.1.1320.gc452695387.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 6.1.y] gpio: xilinx: Convert gpio_lock to raw spinlock
  2025-01-21 18:41 ` [PATCH 6.1.y] gpio: xilinx: Convert gpio_lock to raw spinlock Sean Anderson
@ 2025-01-21 19:27   ` Sean Anderson
  2025-01-21 19:32   ` [PATCH 6.1.y v2] " Sean Anderson
  1 sibling, 0 replies; 7+ messages in thread
From: Sean Anderson @ 2025-01-21 19:27 UTC (permalink / raw)
  To: stable; +Cc: Bartosz Golaszewski

On 1/21/25 13:41, Sean Anderson wrote:
> [ Upstream commit c17ff476f53afb30f90bb3c2af77de069c81a622 ]

Whoops, wrong upstream commit

> 
> irq_chip functions may be called in raw spinlock context. Therefore, we
> must also use a raw spinlock for our own internal locking.
> 
> This fixes the following lockdep splat:
> 
> [    5.349336] =============================
> [    5.353349] [ BUG: Invalid wait context ]
> [    5.357361] 6.13.0-rc5+ #69 Tainted: G        W
> [    5.363031] -----------------------------
> [    5.367045] kworker/u17:1/44 is trying to lock:
> [    5.371587] ffffff88018b02c0 (&chip->gpio_lock){....}-{3:3}, at: xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
> [    5.380079] other info that might help us debug this:
> [    5.385138] context-{5:5}
> [    5.387762] 5 locks held by kworker/u17:1/44:
> [    5.392123] #0: ffffff8800014958 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3204)
> [    5.402260] #1: ffffffc082fcbdd8 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3205)
> [    5.411528] #2: ffffff880172c900 (&dev->mutex){....}-{4:4}, at: __device_attach (drivers/base/dd.c:1006)
> [    5.419929] #3: ffffff88039c8268 (request_class#2){+.+.}-{4:4}, at: __setup_irq (kernel/irq/internals.h:156 kernel/irq/manage.c:1596)
> [    5.428331] #4: ffffff88039c80c8 (lock_class#2){....}-{2:2}, at: __setup_irq (kernel/irq/manage.c:1614)
> [    5.436472] stack backtrace:
> [    5.439359] CPU: 2 UID: 0 PID: 44 Comm: kworker/u17:1 Tainted: G        W          6.13.0-rc5+ #69
> [    5.448690] Tainted: [W]=WARN
> [    5.451656] Hardware name: xlnx,zynqmp (DT)
> [    5.455845] Workqueue: events_unbound deferred_probe_work_func
> [    5.461699] Call trace:
> [    5.464147] show_stack+0x18/0x24 C
> [    5.467821] dump_stack_lvl (lib/dump_stack.c:123)
> [    5.471501] dump_stack (lib/dump_stack.c:130)
> [    5.474824] __lock_acquire (kernel/locking/lockdep.c:4828 kernel/locking/lockdep.c:4898 kernel/locking/lockdep.c:5176)
> [    5.478758] lock_acquire (arch/arm64/include/asm/percpu.h:40 kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5851 kernel/locking/lockdep.c:5814)
> [    5.482429] _raw_spin_lock_irqsave (include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
> [    5.486797] xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
> [    5.490737] irq_enable (kernel/irq/internals.h:236 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345)
> [    5.494060] __irq_startup (kernel/irq/internals.h:241 kernel/irq/chip.c:180 kernel/irq/chip.c:250)
> [    5.497645] irq_startup (kernel/irq/chip.c:270)
> [    5.501143] __setup_irq (kernel/irq/manage.c:1807)
> [    5.504728] request_threaded_irq (kernel/irq/manage.c:2208)
> 
> Fixes: a32c7caea292 ("gpio: gpio-xilinx: Add interrupt support")
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/20250110163354.2012654-1-sean.anderson@linux.dev
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> [ resolved conflicts ]
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> ---
>  drivers/gpio/gpio-xilinx.c | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
> index 2fc6b6ff7f16..58cbf763ee21 100644
> --- a/drivers/gpio/gpio-xilinx.c
> +++ b/drivers/gpio/gpio-xilinx.c
> @@ -66,7 +66,7 @@ struct xgpio_instance {
>  	DECLARE_BITMAP(state, 64);
>  	DECLARE_BITMAP(last_irq_read, 64);
>  	DECLARE_BITMAP(dir, 64);
> -	spinlock_t gpio_lock;	/* For serializing operations */
> +	raw_spinlock_t gpio_lock;	/* For serializing operations */
>  	int irq;
>  	struct irq_chip irqchip;
>  	DECLARE_BITMAP(enable, 64);
> @@ -181,14 +181,14 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
>  	struct xgpio_instance *chip = gpiochip_get_data(gc);
>  	int bit = xgpio_to_bit(chip, gpio);
>  
> -	spin_lock_irqsave(&chip->gpio_lock, flags);
> +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	/* Write to GPIO signal and set its direction to output */
>  	__assign_bit(bit, chip->state, val);
>  
>  	xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state);
>  
> -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
> +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
>  }
>  
>  /**
> @@ -212,7 +212,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
>  	bitmap_remap(hw_mask, mask, chip->sw_map, chip->hw_map, 64);
>  	bitmap_remap(hw_bits, bits, chip->sw_map, chip->hw_map, 64);
>  
> -	spin_lock_irqsave(&chip->gpio_lock, flags);
> +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	bitmap_replace(state, chip->state, hw_bits, hw_mask, 64);
>  
> @@ -220,7 +220,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
>  
>  	bitmap_copy(chip->state, state, 64);
>  
> -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
> +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
>  }
>  
>  /**
> @@ -238,13 +238,13 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>  	struct xgpio_instance *chip = gpiochip_get_data(gc);
>  	int bit = xgpio_to_bit(chip, gpio);
>  
> -	spin_lock_irqsave(&chip->gpio_lock, flags);
> +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	/* Set the GPIO bit in shadow register and set direction as input */
>  	__set_bit(bit, chip->dir);
>  	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
>  
> -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
> +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
>  
>  	return 0;
>  }
> @@ -267,7 +267,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
>  	struct xgpio_instance *chip = gpiochip_get_data(gc);
>  	int bit = xgpio_to_bit(chip, gpio);
>  
> -	spin_lock_irqsave(&chip->gpio_lock, flags);
> +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	/* Write state of GPIO signal */
>  	__assign_bit(bit, chip->state, val);
> @@ -277,7 +277,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
>  	__clear_bit(bit, chip->dir);
>  	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
>  
> -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
> +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
>  
>  	return 0;
>  }
> @@ -405,7 +405,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
>  	int bit = xgpio_to_bit(chip, irq_offset);
>  	u32 mask = BIT(bit / 32), temp;
>  
> -	spin_lock_irqsave(&chip->gpio_lock, flags);
> +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	__clear_bit(bit, chip->enable);
>  
> @@ -415,7 +415,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
>  		temp &= ~mask;
>  		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp);
>  	}
> -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
> +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
>  }
>  
>  /**
> @@ -431,7 +431,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
>  	u32 old_enable = xgpio_get_value32(chip->enable, bit);
>  	u32 mask = BIT(bit / 32), val;
>  
> -	spin_lock_irqsave(&chip->gpio_lock, flags);
> +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	__set_bit(bit, chip->enable);
>  
> @@ -450,7 +450,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
>  		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val);
>  	}
>  
> -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
> +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
>  }
>  
>  /**
> @@ -515,7 +515,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
>  
>  	chained_irq_enter(irqchip, desc);
>  
> -	spin_lock(&chip->gpio_lock);
> +	raw_spin_lock(&chip->gpio_lock);
>  
>  	xgpio_read_ch_all(chip, XGPIO_DATA_OFFSET, all);
>  
> @@ -532,7 +532,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
>  	bitmap_copy(chip->last_irq_read, all, 64);
>  	bitmap_or(all, rising, falling, 64);
>  
> -	spin_unlock(&chip->gpio_lock);
> +	raw_spin_unlock(&chip->gpio_lock);
>  
>  	dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling);
>  
> @@ -623,7 +623,7 @@ static int xgpio_probe(struct platform_device *pdev)
>  	bitmap_set(chip->hw_map,  0, width[0]);
>  	bitmap_set(chip->hw_map, 32, width[1]);
>  
> -	spin_lock_init(&chip->gpio_lock);
> +	raw_spin_lock_init(&chip->gpio_lock);
>  
>  	chip->gc.base = -1;
>  	chip->gc.ngpio = bitmap_weight(chip->hw_map, 64);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 6.1.y v2] gpio: xilinx: Convert gpio_lock to raw spinlock
  2025-01-21 18:41 ` [PATCH 6.1.y] gpio: xilinx: Convert gpio_lock to raw spinlock Sean Anderson
  2025-01-21 19:27   ` Sean Anderson
@ 2025-01-21 19:32   ` Sean Anderson
  2025-01-21 20:08     ` Sasha Levin
  2025-01-29  9:14     ` Greg KH
  1 sibling, 2 replies; 7+ messages in thread
From: Sean Anderson @ 2025-01-21 19:32 UTC (permalink / raw)
  To: stable, gregkh; +Cc: bartosz.golaszewski, Sean Anderson

[ Upstream commit 9860370c2172704b6b4f0075a0c2a29fd84af96a ]

irq_chip functions may be called in raw spinlock context. Therefore, we
must also use a raw spinlock for our own internal locking.

This fixes the following lockdep splat:

[    5.349336] =============================
[    5.353349] [ BUG: Invalid wait context ]
[    5.357361] 6.13.0-rc5+ #69 Tainted: G        W
[    5.363031] -----------------------------
[    5.367045] kworker/u17:1/44 is trying to lock:
[    5.371587] ffffff88018b02c0 (&chip->gpio_lock){....}-{3:3}, at: xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
[    5.380079] other info that might help us debug this:
[    5.385138] context-{5:5}
[    5.387762] 5 locks held by kworker/u17:1/44:
[    5.392123] #0: ffffff8800014958 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3204)
[    5.402260] #1: ffffffc082fcbdd8 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work (kernel/workqueue.c:3205)
[    5.411528] #2: ffffff880172c900 (&dev->mutex){....}-{4:4}, at: __device_attach (drivers/base/dd.c:1006)
[    5.419929] #3: ffffff88039c8268 (request_class#2){+.+.}-{4:4}, at: __setup_irq (kernel/irq/internals.h:156 kernel/irq/manage.c:1596)
[    5.428331] #4: ffffff88039c80c8 (lock_class#2){....}-{2:2}, at: __setup_irq (kernel/irq/manage.c:1614)
[    5.436472] stack backtrace:
[    5.439359] CPU: 2 UID: 0 PID: 44 Comm: kworker/u17:1 Tainted: G        W          6.13.0-rc5+ #69
[    5.448690] Tainted: [W]=WARN
[    5.451656] Hardware name: xlnx,zynqmp (DT)
[    5.455845] Workqueue: events_unbound deferred_probe_work_func
[    5.461699] Call trace:
[    5.464147] show_stack+0x18/0x24 C
[    5.467821] dump_stack_lvl (lib/dump_stack.c:123)
[    5.471501] dump_stack (lib/dump_stack.c:130)
[    5.474824] __lock_acquire (kernel/locking/lockdep.c:4828 kernel/locking/lockdep.c:4898 kernel/locking/lockdep.c:5176)
[    5.478758] lock_acquire (arch/arm64/include/asm/percpu.h:40 kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5851 kernel/locking/lockdep.c:5814)
[    5.482429] _raw_spin_lock_irqsave (include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
[    5.486797] xgpio_irq_unmask (drivers/gpio/gpio-xilinx.c:433 (discriminator 8))
[    5.490737] irq_enable (kernel/irq/internals.h:236 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345)
[    5.494060] __irq_startup (kernel/irq/internals.h:241 kernel/irq/chip.c:180 kernel/irq/chip.c:250)
[    5.497645] irq_startup (kernel/irq/chip.c:270)
[    5.501143] __setup_irq (kernel/irq/manage.c:1807)
[    5.504728] request_threaded_irq (kernel/irq/manage.c:2208)

Fixes: a32c7caea292 ("gpio: gpio-xilinx: Add interrupt support")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250110163354.2012654-1-sean.anderson@linux.dev
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
[ resolved conflicts ]
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---

Changes in v2:
- Fix incorrect upstream commit

 drivers/gpio/gpio-xilinx.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 2fc6b6ff7f16..58cbf763ee21 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -66,7 +66,7 @@ struct xgpio_instance {
 	DECLARE_BITMAP(state, 64);
 	DECLARE_BITMAP(last_irq_read, 64);
 	DECLARE_BITMAP(dir, 64);
-	spinlock_t gpio_lock;	/* For serializing operations */
+	raw_spinlock_t gpio_lock;	/* For serializing operations */
 	int irq;
 	struct irq_chip irqchip;
 	DECLARE_BITMAP(enable, 64);
@@ -181,14 +181,14 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Write to GPIO signal and set its direction to output */
 	__assign_bit(bit, chip->state, val);
 
 	xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -212,7 +212,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 	bitmap_remap(hw_mask, mask, chip->sw_map, chip->hw_map, 64);
 	bitmap_remap(hw_bits, bits, chip->sw_map, chip->hw_map, 64);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	bitmap_replace(state, chip->state, hw_bits, hw_mask, 64);
 
@@ -220,7 +220,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 
 	bitmap_copy(chip->state, state, 64);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -238,13 +238,13 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Set the GPIO bit in shadow register and set direction as input */
 	__set_bit(bit, chip->dir);
 	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	return 0;
 }
@@ -267,7 +267,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	int bit = xgpio_to_bit(chip, gpio);
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	/* Write state of GPIO signal */
 	__assign_bit(bit, chip->state, val);
@@ -277,7 +277,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	__clear_bit(bit, chip->dir);
 	xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 
 	return 0;
 }
@@ -405,7 +405,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
 	int bit = xgpio_to_bit(chip, irq_offset);
 	u32 mask = BIT(bit / 32), temp;
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	__clear_bit(bit, chip->enable);
 
@@ -415,7 +415,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
 		temp &= ~mask;
 		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp);
 	}
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -431,7 +431,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
 	u32 old_enable = xgpio_get_value32(chip->enable, bit);
 	u32 mask = BIT(bit / 32), val;
 
-	spin_lock_irqsave(&chip->gpio_lock, flags);
+	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
 
 	__set_bit(bit, chip->enable);
 
@@ -450,7 +450,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
 		xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val);
 	}
 
-	spin_unlock_irqrestore(&chip->gpio_lock, flags);
+	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
 }
 
 /**
@@ -515,7 +515,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
 
 	chained_irq_enter(irqchip, desc);
 
-	spin_lock(&chip->gpio_lock);
+	raw_spin_lock(&chip->gpio_lock);
 
 	xgpio_read_ch_all(chip, XGPIO_DATA_OFFSET, all);
 
@@ -532,7 +532,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
 	bitmap_copy(chip->last_irq_read, all, 64);
 	bitmap_or(all, rising, falling, 64);
 
-	spin_unlock(&chip->gpio_lock);
+	raw_spin_unlock(&chip->gpio_lock);
 
 	dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling);
 
@@ -623,7 +623,7 @@ static int xgpio_probe(struct platform_device *pdev)
 	bitmap_set(chip->hw_map,  0, width[0]);
 	bitmap_set(chip->hw_map, 32, width[1]);
 
-	spin_lock_init(&chip->gpio_lock);
+	raw_spin_lock_init(&chip->gpio_lock);
 
 	chip->gc.base = -1;
 	chip->gc.ngpio = bitmap_weight(chip->hw_map, 64);
-- 
2.35.1.1320.gc452695387.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 6.1.y v2] gpio: xilinx: Convert gpio_lock to raw spinlock
  2025-01-21 19:32   ` [PATCH 6.1.y v2] " Sean Anderson
@ 2025-01-21 20:08     ` Sasha Levin
  2025-01-29  9:14     ` Greg KH
  1 sibling, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2025-01-21 20:08 UTC (permalink / raw)
  To: stable; +Cc: Sean Anderson, Sasha Levin

[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: 9860370c2172704b6b4f0075a0c2a29fd84af96a


Status in newer kernel trees:
6.12.y | Not found
6.6.y | Not found
6.1.y | Not found

Note: The patch differs from the upstream commit:
---
1:  9860370c21727 ! 1:  849f99ff428f2 gpio: xilinx: Convert gpio_lock to raw spinlock
    @@ Metadata
      ## Commit message ##
         gpio: xilinx: Convert gpio_lock to raw spinlock
     
    +    [ Upstream commit 9860370c2172704b6b4f0075a0c2a29fd84af96a ]
    +
         irq_chip functions may be called in raw spinlock context. Therefore, we
         must also use a raw spinlock for our own internal locking.
     
    @@ Commit message
         Cc: stable@vger.kernel.org
         Link: https://lore.kernel.org/r/20250110163354.2012654-1-sean.anderson@linux.dev
         Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    +    [ resolved conflicts ]
    +    Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
     
      ## drivers/gpio/gpio-xilinx.c ##
     @@ drivers/gpio/gpio-xilinx.c: struct xgpio_instance {
    @@ drivers/gpio/gpio-xilinx.c: struct xgpio_instance {
     -	spinlock_t gpio_lock;	/* For serializing operations */
     +	raw_spinlock_t gpio_lock;	/* For serializing operations */
      	int irq;
    + 	struct irq_chip irqchip;
      	DECLARE_BITMAP(enable, 64);
    - 	DECLARE_BITMAP(rising_edge, 64);
     @@ drivers/gpio/gpio-xilinx.c: static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
      	struct xgpio_instance *chip = gpiochip_get_data(gc);
      	int bit = xgpio_to_bit(chip, gpio);
    @@ drivers/gpio/gpio-xilinx.c: static void xgpio_irq_mask(struct irq_data *irq_data
      	}
     -	spin_unlock_irqrestore(&chip->gpio_lock, flags);
     +	raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
    - 
    - 	gpiochip_disable_irq(&chip->gc, irq_offset);
      }
    -@@ drivers/gpio/gpio-xilinx.c: static void xgpio_irq_unmask(struct irq_data *irq_data)
      
    - 	gpiochip_enable_irq(&chip->gc, irq_offset);
    + /**
    +@@ drivers/gpio/gpio-xilinx.c: static void xgpio_irq_unmask(struct irq_data *irq_data)
    + 	u32 old_enable = xgpio_get_value32(chip->enable, bit);
    + 	u32 mask = BIT(bit / 32), val;
      
     -	spin_lock_irqsave(&chip->gpio_lock, flags);
     +	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y        |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 6.1.y v2] gpio: xilinx: Convert gpio_lock to raw spinlock
  2025-01-21 19:32   ` [PATCH 6.1.y v2] " Sean Anderson
  2025-01-21 20:08     ` Sasha Levin
@ 2025-01-29  9:14     ` Greg KH
  2025-01-30 16:01       ` Sean Anderson
  1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2025-01-29  9:14 UTC (permalink / raw)
  To: Sean Anderson; +Cc: stable, bartosz.golaszewski

On Tue, Jan 21, 2025 at 02:32:06PM -0500, Sean Anderson wrote:
> [ Upstream commit 9860370c2172704b6b4f0075a0c2a29fd84af96a ]

For obvious reasons we can't take patches just for older trees because
if you update to a newer stable/lts version, you will have a regression.
Please submit backports for all relevant versions and then we will be
glad to queue them up.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 6.1.y v2] gpio: xilinx: Convert gpio_lock to raw spinlock
  2025-01-29  9:14     ` Greg KH
@ 2025-01-30 16:01       ` Sean Anderson
  0 siblings, 0 replies; 7+ messages in thread
From: Sean Anderson @ 2025-01-30 16:01 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, bartosz.golaszewski

Hi Greg,

On 1/29/25 04:14, Greg KH wrote:
> On Tue, Jan 21, 2025 at 02:32:06PM -0500, Sean Anderson wrote:
>> [ Upstream commit 9860370c2172704b6b4f0075a0c2a29fd84af96a ]
> 
> For obvious reasons we can't take patches just for older trees because
> if you update to a newer stable/lts version, you will have a regression.
> Please submit backports for all relevant versions and then we will be
> glad to queue them up.

The upstream commit is in 6.13 [1]. Additionally, you have posted patches
for 6.12 [2] and 6.6 [2]. This just fixes the patch for 6.1 [4].

--Sean

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9860370c2172704b6b4f0075a0c2a29fd84af96a
[2] https://lore.kernel.org/stable/20250121174536.648642765@linuxfoundation.org/
[3] https://lore.kernel.org/stable/20250121174525.472060737@linuxfoundation.org/
[4] https://lore.kernel.org/stable/2025012027-shaft-catalyst-2d69@gregkh/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-30 16:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 13:44 FAILED: patch "[PATCH] gpio: xilinx: Convert gpio_lock to raw spinlock" failed to apply to 6.1-stable tree gregkh
2025-01-21 18:41 ` [PATCH 6.1.y] gpio: xilinx: Convert gpio_lock to raw spinlock Sean Anderson
2025-01-21 19:27   ` Sean Anderson
2025-01-21 19:32   ` [PATCH 6.1.y v2] " Sean Anderson
2025-01-21 20:08     ` Sasha Levin
2025-01-29  9:14     ` Greg KH
2025-01-30 16:01       ` Sean Anderson

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.