FAILED: patch "[PATCH] gpio: vf610: add locking to gpio direction functions" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-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 <[email protected]>.
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.12.y
git checkout FETCH_HEAD
git cherry-pick -x 4e667a1968099c6deadee2313ecd648f8f0a8956
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025022409-subtotal-body-5242@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4e667a1968099c6deadee2313ecd648f8f0a8956 Mon Sep 17 00:00:00 2001
From: Johan Korsnes <[email protected]>
Date: Mon, 17 Feb 2025 10:16:43 +0100
Subject: [PATCH] gpio: vf610: add locking to gpio direction functions
Add locking to vf610_gpio_direction_input|output() functions. Without this locking, a race condition exists between concurrent calls to these functions, potentially leading to incorrect GPIO direction settings.
To verify the correctness of this fix, a trylock patch was applied, where after a couple of reboots the race was confirmed. I.e., one user had to wait before acquiring the lock. With this patch the race has not been encountered. It's worth mentioning that any type of debugging (printing, tracing, etc.) would "resolve"/hide the issue.
drivers/gpio/gpio-vf610.c +4 -0
@@ -36,6 +36,7 @@ struct vf610_gpio_port {struct clk *clk_port;struct clk *clk_gpio;int irq; +spinlock_t lock;/* protect gpio direction registers */ };#define GPIO_PDOR 0x00
@@ -124,6 +125,7 @@ static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)u32 val;if (port->sdata->have_paddr) { +guard (spinlock_irqsave)(&port->lock); val =vf610_gpio_readl (port->gpio_base +GPIO_PDDR ); val &= ~mask;vf610_gpio_writel (val, port->gpio_base +GPIO_PDDR );
@@ -142,6 +144,7 @@ static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned int gpiovf610_gpio_set (chip, gpio, value);if (port->sdata->have_paddr) { +guard (spinlock_irqsave)(&port->lock); val =vf610_gpio_readl (port->gpio_base +GPIO_PDDR ); val |= mask;vf610_gpio_writel (val, port->gpio_base +GPIO_PDDR );
@@ -297,6 +300,7 @@ static int vf610_gpio_probe(struct platform_device *pdev)return -ENOMEM ; port->sdata =device_get_match_data (dev); +spin_lock_init (&port->lock); dual_base = port->sdata->have_dual_base;