From cd24d38f3122d136ddfe60c299924ac0509fdd52 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 27 Jun 2024 10:07:03 -0400 Subject: [PATCH] Fixes for 5.15 Signed-off-by: Sasha Levin --- ...x-ili251x_read_touch_data-return-val.patch | 41 +++++++ ...lock-in-create_pinctrl-when-handling.patch | 48 ++++++++ ...-fix-pinmux-bits-for-rk3328-gpio2-b-.patch | 69 +++++++++++ ...-fix-pinmux-bits-for-rk3328-gpio3-b-.patch | 111 ++++++++++++++++++ ...-fix-pinmux-reset-in-rockchip_pmx_se.patch | 42 +++++++ ...-use-dedicated-pinctrl-type-for-rk33.patch | 77 ++++++++++++ queue-5.15/series | 6 + 7 files changed, 394 insertions(+) create mode 100644 queue-5.15/input-ili210x-fix-ili251x_read_touch_data-return-val.patch create mode 100644 queue-5.15/pinctrl-fix-deadlock-in-create_pinctrl-when-handling.patch create mode 100644 queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio2-b-.patch create mode 100644 queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio3-b-.patch create mode 100644 queue-5.15/pinctrl-rockchip-fix-pinmux-reset-in-rockchip_pmx_se.patch create mode 100644 queue-5.15/pinctrl-rockchip-use-dedicated-pinctrl-type-for-rk33.patch diff --git a/queue-5.15/input-ili210x-fix-ili251x_read_touch_data-return-val.patch b/queue-5.15/input-ili210x-fix-ili251x_read_touch_data-return-val.patch new file mode 100644 index 00000000000..d194406c0c4 --- /dev/null +++ b/queue-5.15/input-ili210x-fix-ili251x_read_touch_data-return-val.patch @@ -0,0 +1,41 @@ +From e21e6e4f6e19b261f3560544cf6ce437212f8aab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 23 May 2024 09:56:24 +0100 +Subject: Input: ili210x - fix ili251x_read_touch_data() return value + +From: John Keeping + +[ Upstream commit 9f0fad0382124e7e23b3c730fa78818c22c89c0a ] + +The caller of this function treats all non-zero values as an error, so +the return value of i2c_master_recv() cannot be returned directly. + +This fixes touch reporting when there are more than 6 active touches. + +Fixes: ef536abd3afd1 ("Input: ili210x - define and use chip operations structure") +Signed-off-by: John Keeping +Link: https://lore.kernel.org/r/20240523085624.2295988-1-jkeeping@inmusicbrands.com +Signed-off-by: Dmitry Torokhov +Signed-off-by: Sasha Levin +--- + drivers/input/touchscreen/ili210x.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c +index f437eefec94ad..9452a12ddb096 100644 +--- a/drivers/input/touchscreen/ili210x.c ++++ b/drivers/input/touchscreen/ili210x.c +@@ -231,8 +231,8 @@ static int ili251x_read_touch_data(struct i2c_client *client, u8 *data) + if (!error && data[0] == 2) { + error = i2c_master_recv(client, data + ILI251X_DATA_SIZE1, + ILI251X_DATA_SIZE2); +- if (error >= 0 && error != ILI251X_DATA_SIZE2) +- error = -EIO; ++ if (error >= 0) ++ error = error == ILI251X_DATA_SIZE2 ? 0 : -EIO; + } + + return error; +-- +2.43.0 + diff --git a/queue-5.15/pinctrl-fix-deadlock-in-create_pinctrl-when-handling.patch b/queue-5.15/pinctrl-fix-deadlock-in-create_pinctrl-when-handling.patch new file mode 100644 index 00000000000..eaa80110fb2 --- /dev/null +++ b/queue-5.15/pinctrl-fix-deadlock-in-create_pinctrl-when-handling.patch @@ -0,0 +1,48 @@ +From dbcf6bd7f7a598b051464145b4d073b8342a691d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 4 Jun 2024 08:58:38 +0000 +Subject: pinctrl: fix deadlock in create_pinctrl() when handling -EPROBE_DEFER + +From: Hagar Hemdan + +[ Upstream commit adec57ff8e66aee632f3dd1f93787c13d112b7a1 ] + +In create_pinctrl(), pinctrl_maps_mutex is acquired before calling +add_setting(). If add_setting() returns -EPROBE_DEFER, create_pinctrl() +calls pinctrl_free(). However, pinctrl_free() attempts to acquire +pinctrl_maps_mutex, which is already held by create_pinctrl(), leading to +a potential deadlock. + +This patch resolves the issue by releasing pinctrl_maps_mutex before +calling pinctrl_free(), preventing the deadlock. + +This bug was discovered and resolved using Coverity Static Analysis +Security Testing (SAST) by Synopsys, Inc. + +Fixes: 42fed7ba44e4 ("pinctrl: move subsystem mutex to pinctrl_dev struct") +Suggested-by: Maximilian Heyne +Signed-off-by: Hagar Hemdan +Link: https://lore.kernel.org/r/20240604085838.3344-1-hagarhem@amazon.com +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c +index 46a06067e9947..f567805cbde8e 100644 +--- a/drivers/pinctrl/core.c ++++ b/drivers/pinctrl/core.c +@@ -1092,8 +1092,8 @@ static struct pinctrl *create_pinctrl(struct device *dev, + * an -EPROBE_DEFER later, as that is the worst case. + */ + if (ret == -EPROBE_DEFER) { +- pinctrl_free(p, false); + mutex_unlock(&pinctrl_maps_mutex); ++ pinctrl_free(p, false); + return ERR_PTR(ret); + } + } +-- +2.43.0 + diff --git a/queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio2-b-.patch b/queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio2-b-.patch new file mode 100644 index 00000000000..6a4bae350d1 --- /dev/null +++ b/queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio2-b-.patch @@ -0,0 +1,69 @@ +From 770960f5d72571deb44b4db4b780a175f86d1a85 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 6 Jun 2024 20:57:52 +0800 +Subject: pinctrl: rockchip: fix pinmux bits for RK3328 GPIO2-B pins + +From: Huang-Huang Bao + +[ Upstream commit e8448a6c817c2aa6c6af785b1d45678bd5977e8d ] + +The pinmux bits for GPIO2-B0 to GPIO2-B6 actually have 2 bits width, +correct the bank flag for GPIO2-B. The pinmux bits for GPIO2-B7 is +recalculated so it remain unchanged. + +The pinmux bits for those pins are not explicitly specified in RK3328 +TRM, however we can get hint from pad name and its correspinding IOMUX +setting for pins in interface descriptions. The correspinding IOMIX +settings for GPIO2-B0 to GPIO2-B6 can be found in the same row next to +occurrences of following pad names in RK3328 TRM. + +GPIO2-B0: IO_SPIclkm0_GPIO2B0vccio5 +GPIO2-B1: IO_SPItxdm0_GPIO2B1vccio5 +GPIO2-B2: IO_SPIrxdm0_GPIO2B2vccio5 +GPIO2-B3: IO_SPIcsn0m0_GPIO2B3vccio5 +GPIO2-B4: IO_SPIcsn1m0_FLASHvol_sel_GPIO2B4vccio5 +GPIO2-B5: IO_ I2C2sda_TSADCshut_GPIO2B5vccio5 +GPIO2-B6: IO_ I2C2scl_GPIO2B6vccio5 + +This fix has been tested on NanoPi R2S for fixing confliting pinmux bits +between GPIO2-B7 with GPIO2-B5. + +Signed-off-by: Huang-Huang Bao +Reviewed-by: Heiko Stuebner +Fixes: 3818e4a7678e ("pinctrl: rockchip: Add rk3328 pinctrl support") +Link: https://lore.kernel.org/r/20240606125755.53778-2-i@eh5.me +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/pinctrl-rockchip.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index a6f4aca9c61c4..693a24eac9892 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -564,12 +564,6 @@ static struct rockchip_mux_recalced_data rk3308_mux_recalced_data[] = { + + static struct rockchip_mux_recalced_data rk3328_mux_recalced_data[] = { + { +- .num = 2, +- .pin = 12, +- .reg = 0x24, +- .bit = 8, +- .mask = 0x3 +- }, { + .num = 2, + .pin = 15, + .reg = 0x28, +@@ -3181,7 +3175,7 @@ static struct rockchip_pin_bank rk3328_pin_banks[] = { + PIN_BANK_IOMUX_FLAGS(0, 32, "gpio0", 0, 0, 0, 0), + PIN_BANK_IOMUX_FLAGS(1, 32, "gpio1", 0, 0, 0, 0), + PIN_BANK_IOMUX_FLAGS(2, 32, "gpio2", 0, +- IOMUX_WIDTH_3BIT, ++ 0, + IOMUX_WIDTH_3BIT, + 0), + PIN_BANK_IOMUX_FLAGS(3, 32, "gpio3", +-- +2.43.0 + diff --git a/queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio3-b-.patch b/queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio3-b-.patch new file mode 100644 index 00000000000..60429ba8598 --- /dev/null +++ b/queue-5.15/pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio3-b-.patch @@ -0,0 +1,111 @@ +From 86799e392b8f09ac11688d818ea6af76f3822d90 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 6 Jun 2024 20:57:53 +0800 +Subject: pinctrl: rockchip: fix pinmux bits for RK3328 GPIO3-B pins + +From: Huang-Huang Bao + +[ Upstream commit 5ef6914e0bf578357b4c906ffe6b26e7eedb8ccf ] + +The pinmux bits for GPIO3-B1 to GPIO3-B6 pins are not explicitly +specified in RK3328 TRM, however we can get hint from pad name and its +correspinding IOMUX setting for pins in interface descriptions. The +correspinding IOMIX settings for these pins can be found in the same +row next to occurrences of following pad names in RK3328 TRM. + +GPIO3-B1: IO_TSPd5m0_CIFdata5m0_GPIO3B1vccio6 +GPIO3-B2: IO_TSPd6m0_CIFdata6m0_GPIO3B2vccio6 +GPIO3-B3: IO_TSPd7m0_CIFdata7m0_GPIO3B3vccio6 +GPIO3-B4: IO_CARDclkm0_GPIO3B4vccio6 +GPIO3-B5: IO_CARDrstm0_GPIO3B5vccio6 +GPIO3-B6: IO_CARDdetm0_GPIO3B6vccio6 + +Add pinmux data to rk3328_mux_recalced_data as mux register offset for +these pins does not follow rockchip convention. + +Signed-off-by: Huang-Huang Bao +Reviewed-by: Heiko Stuebner +Fixes: 3818e4a7678e ("pinctrl: rockchip: Add rk3328 pinctrl support") +Link: https://lore.kernel.org/r/20240606125755.53778-3-i@eh5.me +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/pinctrl-rockchip.c | 51 ++++++++++++++++++++++++++++++ + 1 file changed, 51 insertions(+) + +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index 693a24eac9892..965482872646f 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -564,17 +564,68 @@ static struct rockchip_mux_recalced_data rk3308_mux_recalced_data[] = { + + static struct rockchip_mux_recalced_data rk3328_mux_recalced_data[] = { + { ++ /* gpio2_b7_sel */ + .num = 2, + .pin = 15, + .reg = 0x28, + .bit = 0, + .mask = 0x7 + }, { ++ /* gpio2_c7_sel */ + .num = 2, + .pin = 23, + .reg = 0x30, + .bit = 14, + .mask = 0x3 ++ }, { ++ /* gpio3_b1_sel */ ++ .num = 3, ++ .pin = 9, ++ .reg = 0x44, ++ .bit = 2, ++ .mask = 0x3 ++ }, { ++ /* gpio3_b2_sel */ ++ .num = 3, ++ .pin = 10, ++ .reg = 0x44, ++ .bit = 4, ++ .mask = 0x3 ++ }, { ++ /* gpio3_b3_sel */ ++ .num = 3, ++ .pin = 11, ++ .reg = 0x44, ++ .bit = 6, ++ .mask = 0x3 ++ }, { ++ /* gpio3_b4_sel */ ++ .num = 3, ++ .pin = 12, ++ .reg = 0x44, ++ .bit = 8, ++ .mask = 0x3 ++ }, { ++ /* gpio3_b5_sel */ ++ .num = 3, ++ .pin = 13, ++ .reg = 0x44, ++ .bit = 10, ++ .mask = 0x3 ++ }, { ++ /* gpio3_b6_sel */ ++ .num = 3, ++ .pin = 14, ++ .reg = 0x44, ++ .bit = 12, ++ .mask = 0x3 ++ }, { ++ /* gpio3_b7_sel */ ++ .num = 3, ++ .pin = 15, ++ .reg = 0x44, ++ .bit = 14, ++ .mask = 0x3 + }, + }; + +-- +2.43.0 + diff --git a/queue-5.15/pinctrl-rockchip-fix-pinmux-reset-in-rockchip_pmx_se.patch b/queue-5.15/pinctrl-rockchip-fix-pinmux-reset-in-rockchip_pmx_se.patch new file mode 100644 index 00000000000..6d5f93c4251 --- /dev/null +++ b/queue-5.15/pinctrl-rockchip-fix-pinmux-reset-in-rockchip_pmx_se.patch @@ -0,0 +1,42 @@ +From 2cb0167ad0539b1d3e7e8db02db7a7241bc7456c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 6 Jun 2024 20:57:55 +0800 +Subject: pinctrl: rockchip: fix pinmux reset in rockchip_pmx_set + +From: Huang-Huang Bao + +[ Upstream commit 4ea4d4808e342ddf89ba24b93ffa2057005aaced ] + +rockchip_pmx_set reset all pinmuxs in group to 0 in the case of error, +add missing bank data retrieval in that code to avoid setting mux on +unexpected pins. + +Fixes: 14797189b35e ("pinctrl: rockchip: add return value to rockchip_set_mux") +Reviewed-by: Heiko Stuebner +Signed-off-by: Huang-Huang Bao +Link: https://lore.kernel.org/r/20240606125755.53778-5-i@eh5.me +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/pinctrl-rockchip.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index 30e1dec1e2f68..4ff70527755a3 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -2206,8 +2206,10 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, + + if (ret) { + /* revert the already done pin settings */ +- for (cnt--; cnt >= 0; cnt--) ++ for (cnt--; cnt >= 0; cnt--) { ++ bank = pin_to_bank(info, pins[cnt]); + rockchip_set_mux(bank, pins[cnt] - bank->pin_base, 0); ++ } + + return ret; + } +-- +2.43.0 + diff --git a/queue-5.15/pinctrl-rockchip-use-dedicated-pinctrl-type-for-rk33.patch b/queue-5.15/pinctrl-rockchip-use-dedicated-pinctrl-type-for-rk33.patch new file mode 100644 index 00000000000..662bf3d224d --- /dev/null +++ b/queue-5.15/pinctrl-rockchip-use-dedicated-pinctrl-type-for-rk33.patch @@ -0,0 +1,77 @@ +From a4111d848d5c764317b74f0945052431918662c3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 6 Jun 2024 20:57:54 +0800 +Subject: pinctrl: rockchip: use dedicated pinctrl type for RK3328 + +From: Huang-Huang Bao + +[ Upstream commit 01b4b1d1cec48ef4c26616c2fc4600b2c9fec05a ] + +rk3328_pin_ctrl uses type of RK3288 which has a hack in +rockchip_pinctrl_suspend and rockchip_pinctrl_resume to restore GPIO6-C6 +at assume, the hack is not applicable to RK3328 as GPIO6 is not even +exist in it. So use a dedicated pinctrl type to skip this hack. + +Fixes: 3818e4a7678e ("pinctrl: rockchip: Add rk3328 pinctrl support") +Reviewed-by: Heiko Stuebner +Signed-off-by: Huang-Huang Bao +Link: https://lore.kernel.org/r/20240606125755.53778-4-i@eh5.me +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/pinctrl-rockchip.c | 5 ++++- + drivers/pinctrl/pinctrl-rockchip.h | 1 + + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index 965482872646f..30e1dec1e2f68 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -1936,6 +1936,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) + case RK3188: + case RK3288: + case RK3308: ++ case RK3328: + case RK3368: + case RK3399: + case RK3568: +@@ -1992,6 +1993,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, + case RK3188: + case RK3288: + case RK3308: ++ case RK3328: + case RK3368: + case RK3399: + case RK3568: +@@ -2252,6 +2254,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, + case RK3188: + case RK3288: + case RK3308: ++ case RK3328: + case RK3368: + case RK3399: + case RK3568: +@@ -3240,7 +3243,7 @@ static struct rockchip_pin_ctrl rk3328_pin_ctrl = { + .pin_banks = rk3328_pin_banks, + .nr_banks = ARRAY_SIZE(rk3328_pin_banks), + .label = "RK3328-GPIO", +- .type = RK3288, ++ .type = RK3328, + .grf_mux_offset = 0x0, + .iomux_recalced = rk3328_mux_recalced_data, + .niomux_recalced = ARRAY_SIZE(rk3328_mux_recalced_data), +diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h +index 59116e13758d0..d4a6e1276bab3 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.h ++++ b/drivers/pinctrl/pinctrl-rockchip.h +@@ -27,6 +27,7 @@ enum rockchip_pinctrl_type { + RK3188, + RK3288, + RK3308, ++ RK3328, + RK3368, + RK3399, + RK3568, +-- +2.43.0 + diff --git a/queue-5.15/series b/queue-5.15/series index ab6329c4e1d..fe9eaf4a374 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -290,3 +290,9 @@ acpi-x86-utils-add-picasso-to-the-list-for-forcing-s.patch acpi-x86-force-storaged3enable-on-more-products.patch gve-add-rx-context.patch gve-clear-napi-skb-before-dev_kfree_skb_any.patch +input-ili210x-fix-ili251x_read_touch_data-return-val.patch +pinctrl-fix-deadlock-in-create_pinctrl-when-handling.patch +pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio2-b-.patch +pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio3-b-.patch +pinctrl-rockchip-use-dedicated-pinctrl-type-for-rk33.patch +pinctrl-rockchip-fix-pinmux-reset-in-rockchip_pmx_se.patch -- 2.47.3