From 369491262f39daed6422fa6417ccada4ef2b2904 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 4 Mar 2024 07:22:14 -0500 Subject: [PATCH] Fixes for 5.15 Signed-off-by: Sasha Levin --- ...le-output-pins-after-registers-are-r.patch | 57 +++++++++++++++++++ ...source-unwinding-order-in-error-path.patch | 54 ++++++++++++++++++ ...error-path-order-in-gpiochip_add_dat.patch | 40 +++++++++++++ queue-5.15/series | 3 + 4 files changed, 154 insertions(+) create mode 100644 queue-5.15/gpio-74x164-enable-output-pins-after-registers-are-r.patch create mode 100644 queue-5.15/gpio-fix-resource-unwinding-order-in-error-path.patch create mode 100644 queue-5.15/gpiolib-fix-the-error-path-order-in-gpiochip_add_dat.patch diff --git a/queue-5.15/gpio-74x164-enable-output-pins-after-registers-are-r.patch b/queue-5.15/gpio-74x164-enable-output-pins-after-registers-are-r.patch new file mode 100644 index 00000000000..5938c85f20e --- /dev/null +++ b/queue-5.15/gpio-74x164-enable-output-pins-after-registers-are-r.patch @@ -0,0 +1,57 @@ +From 367f3f442e8ce057425497ac08510bf8e5a6eb4b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 1 Mar 2024 09:12:04 +0200 +Subject: gpio: 74x164: Enable output pins after registers are reset + +From: Arturas Moskvinas + +[ Upstream commit 530b1dbd97846b110ea8a94c7cc903eca21786e5 ] + +Chip outputs are enabled[1] before actual reset is performed[2] which might +cause pin output value to flip flop if previous pin value was set to 1. +Fix that behavior by making sure chip is fully reset before all outputs are +enabled. + +Flip-flop can be noticed when module is removed and inserted again and one of +the pins was changed to 1 before removal. 100 microsecond flipping is +noticeable on oscilloscope (100khz SPI bus). + +For a properly reset chip - output is enabled around 100 microseconds (on 100khz +SPI bus) later during probing process hence should be irrelevant behavioral +change. + +Fixes: 7ebc194d0fd4 (gpio: 74x164: Introduce 'enable-gpios' property) +Link: https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130 [1] +Link: https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150 [2] +Signed-off-by: Arturas Moskvinas +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpio-74x164.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c +index 4a55cdf089d62..ebfa0a8e57dec 100644 +--- a/drivers/gpio/gpio-74x164.c ++++ b/drivers/gpio/gpio-74x164.c +@@ -127,8 +127,6 @@ static int gen_74x164_probe(struct spi_device *spi) + if (IS_ERR(chip->gpiod_oe)) + return PTR_ERR(chip->gpiod_oe); + +- gpiod_set_value_cansleep(chip->gpiod_oe, 1); +- + spi_set_drvdata(spi, chip); + + chip->gpio_chip.label = spi->modalias; +@@ -153,6 +151,8 @@ static int gen_74x164_probe(struct spi_device *spi) + goto exit_destroy; + } + ++ gpiod_set_value_cansleep(chip->gpiod_oe, 1); ++ + ret = gpiochip_add_data(&chip->gpio_chip, chip); + if (!ret) + return 0; +-- +2.43.0 + diff --git a/queue-5.15/gpio-fix-resource-unwinding-order-in-error-path.patch b/queue-5.15/gpio-fix-resource-unwinding-order-in-error-path.patch new file mode 100644 index 00000000000..ac3a6a741d7 --- /dev/null +++ b/queue-5.15/gpio-fix-resource-unwinding-order-in-error-path.patch @@ -0,0 +1,54 @@ +From c5ed2d5f1638c1a35ed4fbbe663328c8f62f446b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 29 Feb 2024 18:25:49 +0100 +Subject: gpio: fix resource unwinding order in error path + +From: Bartosz Golaszewski + +[ Upstream commit ec5c54a9d3c4f9c15e647b049fea401ee5258696 ] + +Hogs are added *after* ACPI so should be removed *before* in error path. + +Fixes: a411e81e61df ("gpiolib: add hogs support for machine code") +Signed-off-by: Bartosz Golaszewski +Reviewed-by: Andy Shevchenko +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c +index 4245ece1acb60..34a061b4becdb 100644 +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -774,11 +774,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, + + ret = gpiochip_irqchip_init_valid_mask(gc); + if (ret) +- goto err_remove_acpi_chip; ++ goto err_free_hogs; + + ret = gpiochip_irqchip_init_hw(gc); + if (ret) +- goto err_remove_acpi_chip; ++ goto err_remove_irqchip_mask; + + ret = gpiochip_add_irqchip(gc, lock_key, request_key); + if (ret) +@@ -803,11 +803,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, + gpiochip_irqchip_remove(gc); + err_remove_irqchip_mask: + gpiochip_irqchip_free_valid_mask(gc); +-err_remove_acpi_chip: ++err_free_hogs: ++ gpiochip_free_hogs(gc); + acpi_gpiochip_remove(gc); + gpiochip_remove_pin_ranges(gc); + err_remove_of_chip: +- gpiochip_free_hogs(gc); + of_gpiochip_remove(gc); + err_free_gpiochip_mask: + gpiochip_free_valid_mask(gc); +-- +2.43.0 + diff --git a/queue-5.15/gpiolib-fix-the-error-path-order-in-gpiochip_add_dat.patch b/queue-5.15/gpiolib-fix-the-error-path-order-in-gpiochip_add_dat.patch new file mode 100644 index 00000000000..8db120e5a4b --- /dev/null +++ b/queue-5.15/gpiolib-fix-the-error-path-order-in-gpiochip_add_dat.patch @@ -0,0 +1,40 @@ +From 190360f1cef69c45bf4b1c0e2f273cae29057f8e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 21 Feb 2024 21:28:46 +0200 +Subject: gpiolib: Fix the error path order in gpiochip_add_data_with_key() + +From: Andy Shevchenko + +[ Upstream commit e4aec4daa8c009057b5e063db1b7322252c92dc8 ] + +After shuffling the code, error path wasn't updated correctly. +Fix it here. + +Fixes: 2f4133bb5f14 ("gpiolib: No need to call gpiochip_remove_pin_ranges() twice") +Signed-off-by: Andy Shevchenko +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c +index f9fdd117c654c..4245ece1acb60 100644 +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -805,11 +805,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, + gpiochip_irqchip_free_valid_mask(gc); + err_remove_acpi_chip: + acpi_gpiochip_remove(gc); ++ gpiochip_remove_pin_ranges(gc); + err_remove_of_chip: + gpiochip_free_hogs(gc); + of_gpiochip_remove(gc); + err_free_gpiochip_mask: +- gpiochip_remove_pin_ranges(gc); + gpiochip_free_valid_mask(gc); + if (gdev->dev.release) { + /* release() has been registered by gpiochip_setup_dev() */ +-- +2.43.0 + diff --git a/queue-5.15/series b/queue-5.15/series index d8cb3a303f8..adbaf8db0a6 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -72,3 +72,6 @@ cachefiles-fix-memory-leak-in-cachefiles_add_cache.patch fs-hugetlb-fix-null-pointer-dereference-in-hugetlbs_fill_super.patch revert-drm-bridge-lt8912b-register-and-attach-our-dsi-device-at-probe.patch af_unix-drop-oob_skb-ref-before-purging-queue-in-gc.patch +gpio-74x164-enable-output-pins-after-registers-are-r.patch +gpiolib-fix-the-error-path-order-in-gpiochip_add_dat.patch +gpio-fix-resource-unwinding-order-in-error-path.patch -- 2.47.3