Skip to content

Commit f883675

Browse files
committed
Merge tag 'gpio-fixes-for-v6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: - fix a potential race condition and always set GPIOs used as interrupt source to input in gpio-mxc - fix a GPIO ACPI-related issue with system suspend on Clevo NL5xRU * tag 'gpio-fixes-for-v6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpiolib: acpi: Add a ignore wakeup quirk for Clevo NL5xRU gpiolib: acpi: Allow ignoring wake capability on pins that aren't in _AEI gpio: mxc: Always set GPIOs used as interrupt source to INPUT mode gpio: mxc: Protect GPIO irqchip RMW with bgpio spinlock
2 parents 4e31bad + 4cb7861 commit f883675

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

drivers/gpio/gpio-mxc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/module.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/slab.h>
21+
#include <linux/spinlock.h>
2122
#include <linux/syscore_ops.h>
2223
#include <linux/gpio/driver.h>
2324
#include <linux/of.h>
@@ -159,6 +160,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)
159160
{
160161
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
161162
struct mxc_gpio_port *port = gc->private;
163+
unsigned long flags;
162164
u32 bit, val;
163165
u32 gpio_idx = d->hwirq;
164166
int edge;
@@ -197,6 +199,8 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)
197199
return -EINVAL;
198200
}
199201

202+
raw_spin_lock_irqsave(&port->gc.bgpio_lock, flags);
203+
200204
if (GPIO_EDGE_SEL >= 0) {
201205
val = readl(port->base + GPIO_EDGE_SEL);
202206
if (edge == GPIO_INT_BOTH_EDGES)
@@ -217,15 +221,20 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)
217221
writel(1 << gpio_idx, port->base + GPIO_ISR);
218222
port->pad_type[gpio_idx] = type;
219223

220-
return 0;
224+
raw_spin_unlock_irqrestore(&port->gc.bgpio_lock, flags);
225+
226+
return port->gc.direction_input(&port->gc, gpio_idx);
221227
}
222228

223229
static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
224230
{
225231
void __iomem *reg = port->base;
232+
unsigned long flags;
226233
u32 bit, val;
227234
int edge;
228235

236+
raw_spin_lock_irqsave(&port->gc.bgpio_lock, flags);
237+
229238
reg += GPIO_ICR1 + ((gpio & 0x10) >> 2); /* lower or upper register */
230239
bit = gpio & 0xf;
231240
val = readl(reg);
@@ -243,6 +252,8 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
243252
return;
244253
}
245254
writel(val | (edge << (bit << 1)), reg);
255+
256+
raw_spin_unlock_irqrestore(&port->gc.bgpio_lock, flags);
246257
}
247258

248259
/* handle 32 interrupts in one status register */

drivers/gpio/gpiolib-acpi.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static bool acpi_gpio_in_ignore_list(const char *ignore_list, const char *contro
385385
}
386386

387387
static bool acpi_gpio_irq_is_wake(struct device *parent,
388-
struct acpi_resource_gpio *agpio)
388+
const struct acpi_resource_gpio *agpio)
389389
{
390390
unsigned int pin = agpio->pin_table[0];
391391

@@ -778,7 +778,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
778778
lookup->info.pin_config = agpio->pin_config;
779779
lookup->info.debounce = agpio->debounce_timeout;
780780
lookup->info.gpioint = gpioint;
781-
lookup->info.wake_capable = agpio->wake_capable == ACPI_WAKE_CAPABLE;
781+
lookup->info.wake_capable = acpi_gpio_irq_is_wake(&lookup->info.adev->dev, agpio);
782782

783783
/*
784784
* Polarity and triggering are only specified for GpioInt
@@ -1623,6 +1623,19 @@ static const struct dmi_system_id gpiolib_acpi_quirks[] __initconst = {
16231623
.ignore_interrupt = "AMDI0030:00@18",
16241624
},
16251625
},
1626+
{
1627+
/*
1628+
* Spurious wakeups from TP_ATTN# pin
1629+
* Found in BIOS 1.7.8
1630+
* https://gitlab.freedesktop.org/drm/amd/-/issues/1722#note_1720627
1631+
*/
1632+
.matches = {
1633+
DMI_MATCH(DMI_BOARD_NAME, "NL5xRU"),
1634+
},
1635+
.driver_data = &(struct acpi_gpiolib_dmi_quirk) {
1636+
.ignore_wake = "ELAN0415:00@9",
1637+
},
1638+
},
16261639
{} /* Terminating entry */
16271640
};
16281641

0 commit comments

Comments
 (0)