Skip to content

Commit bdd5e2f

Browse files
Asmaa MnebhiSasha Levin
authored andcommitted
gpio: mlxbf3: Support shutdown() function
[ Upstream commit aad4183 ] During Linux graceful reboot, the GPIO interrupts are not disabled. Since the drivers are not removed during graceful reboot, the logic to call mlxbf3_gpio_irq_disable() is not triggered. Interrupts that remain enabled can cause issues on subsequent boots. For example, the mlxbf-gige driver contains PHY logic to bring up the link. If the gpio-mlxbf3 driver loads first, the mlxbf-gige driver will use a GPIO interrupt to bring up the link. Otherwise, it will use polling. The next time Linux boots and loads the drivers in this order, we encounter the issue: - mlxbf-gige loads first and uses polling while the GPIO10 interrupt is still enabled from the previous boot. So if the interrupt triggers, there is nothing to clear it. - gpio-mlxbf3 loads. - i2c-mlxbf loads. The interrupt doesn't trigger for I2C because it is shared with the GPIO interrupt line which was not cleared. The solution is to add a shutdown function to the GPIO driver to clear and disable all interrupts. Also clear the interrupt after disabling it in mlxbf3_gpio_irq_disable(). Fixes: 38a700e ("gpio: mlxbf3: Add gpio driver support") Signed-off-by: Asmaa Mnebhi <[email protected]> Reviewed-by: David Thompson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d09de8a commit bdd5e2f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/gpio/gpio-mlxbf3.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#define MLXBF_GPIO_CAUSE_OR_EVTEN0 0x14
4040
#define MLXBF_GPIO_CAUSE_OR_CLRCAUSE 0x18
4141

42+
#define MLXBF_GPIO_CLR_ALL_INTS GENMASK(31, 0)
43+
4244
struct mlxbf3_gpio_context {
4345
struct gpio_chip gc;
4446

@@ -82,6 +84,8 @@ static void mlxbf3_gpio_irq_disable(struct irq_data *irqd)
8284
val = readl(gs->gpio_cause_io + MLXBF_GPIO_CAUSE_OR_EVTEN0);
8385
val &= ~BIT(offset);
8486
writel(val, gs->gpio_cause_io + MLXBF_GPIO_CAUSE_OR_EVTEN0);
87+
88+
writel(BIT(offset), gs->gpio_cause_io + MLXBF_GPIO_CAUSE_OR_CLRCAUSE);
8589
raw_spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags);
8690

8791
gpiochip_disable_irq(gc, offset);
@@ -253,6 +257,15 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev)
253257
return 0;
254258
}
255259

260+
static void mlxbf3_gpio_shutdown(struct platform_device *pdev)
261+
{
262+
struct mlxbf3_gpio_context *gs = platform_get_drvdata(pdev);
263+
264+
/* Disable and clear all interrupts */
265+
writel(0, gs->gpio_cause_io + MLXBF_GPIO_CAUSE_OR_EVTEN0);
266+
writel(MLXBF_GPIO_CLR_ALL_INTS, gs->gpio_cause_io + MLXBF_GPIO_CAUSE_OR_CLRCAUSE);
267+
}
268+
256269
static const struct acpi_device_id mlxbf3_gpio_acpi_match[] = {
257270
{ "MLNXBF33", 0 },
258271
{}
@@ -265,6 +278,7 @@ static struct platform_driver mlxbf3_gpio_driver = {
265278
.acpi_match_table = mlxbf3_gpio_acpi_match,
266279
},
267280
.probe = mlxbf3_gpio_probe,
281+
.shutdown = mlxbf3_gpio_shutdown,
268282
};
269283
module_platform_driver(mlxbf3_gpio_driver);
270284

0 commit comments

Comments
 (0)