--- /dev/null
+From e7792b394be53b8a74918ef11b26e411496322aa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 29 Apr 2023 12:38:41 +0200
+Subject: ACPI: button: Add lid disable DMI quirk for Nextbook Ares 8A
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 4fd5556608bfa9c2bf276fc115ef04288331aded ]
+
+The LID0 device on the Nextbook Ares 8A tablet always reports lid
+closed causing userspace to suspend the device as soon as booting
+is complete.
+
+Add a DMI quirk to disable the broken lid functionality.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/button.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
+index 1f9b9a4c38c7d..d8b1481141385 100644
+--- a/drivers/acpi/button.c
++++ b/drivers/acpi/button.c
+@@ -77,6 +77,15 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
+ },
+ .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED,
+ },
++ {
++ /* Nextbook Ares 8A tablet, _LID device always reports lid closed */
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
++ DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
++ DMI_MATCH(DMI_BIOS_VERSION, "M882"),
++ },
++ .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED,
++ },
+ {
+ /*
+ * Lenovo Yoga 9 14ITL5, initial notification of the LID device
+--
+2.43.0
+
--- /dev/null
+From 51950d3be045230232c8de9170075b552cb3f166 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Nov 2023 12:10:08 +0200
+Subject: acpi: property: Let args be NULL in
+ __acpi_node_get_property_reference
+
+From: Sakari Ailus <sakari.ailus@linux.intel.com>
+
+[ Upstream commit bef52aa0f3de1b7d8c258c13b16e577361dabf3a ]
+
+fwnode_get_property_reference_args() may not be called with args argument
+NULL on ACPI, OF already supports this. Add the missing NULL checks and
+document this.
+
+The purpose is to be able to count the references.
+
+Fixes: 977d5ad39f3e ("ACPI: Convert ACPI reference args to generic fwnode reference args")
+Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Link: https://lore.kernel.org/r/20231109101010.1329587-2-sakari.ailus@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/property.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
+index 488915328646e..9ab7f7184343a 100644
+--- a/drivers/acpi/property.c
++++ b/drivers/acpi/property.c
+@@ -639,6 +639,7 @@ acpi_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
+ * @index: Index of the reference to return
+ * @num_args: Maximum number of arguments after each reference
+ * @args: Location to store the returned reference with optional arguments
++ * (may be NULL)
+ *
+ * Find property with @name, verifify that it is a package containing at least
+ * one object reference and if so, store the ACPI device object pointer to the
+@@ -697,6 +698,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
+ if (ret)
+ return ret == -ENODEV ? -EINVAL : ret;
+
++ if (!args)
++ return 0;
++
+ args->fwnode = acpi_fwnode_handle(device);
+ args->nargs = 0;
+ return 0;
+--
+2.43.0
+
--- /dev/null
+From c8ab57122ea0741a54adb7ea1d86b60312a47b43 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 15 Dec 2022 10:44:43 +0100
+Subject: ACPI: resource: Add Asus ExpertBook B2502 to Asus quirks
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 7203481fd12b1257938519efb2460ea02b9236ee ]
+
+The Asus ExpertBook B2502 has the same keyboard issue as Asus Vivobook
+K3402ZA/K3502ZA. The kernel overrides IRQ 1 to Edge_High when it
+should be Active_Low.
+
+This patch adds the ExpertBook B2502 model to the existing
+quirk list of Asus laptops with this issue.
+
+Fixes: b5f9223a105d ("ACPI: resource: Skip IRQ override on Asus Vivobook S5602ZA")
+Link: https://bugzilla.redhat.com/show_bug.cgi?id=2142574
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: 77c724888238 ("ACPI: resource: Skip IRQ override on Asus Expertbook B2402CBA")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/resource.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
+index 5f56839ed71df..a5d2a81902038 100644
+--- a/drivers/acpi/resource.c
++++ b/drivers/acpi/resource.c
+@@ -435,6 +435,13 @@ static const struct dmi_system_id asus_laptop[] = {
+ DMI_MATCH(DMI_BOARD_NAME, "S5602ZA"),
+ },
+ },
++ {
++ .ident = "Asus ExpertBook B2502",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
++ DMI_MATCH(DMI_BOARD_NAME, "B2502CBA"),
++ },
++ },
+ { }
+ };
+
+--
+2.43.0
+
--- /dev/null
+From a51d3846ddfc1d0a65432796f103b95cd002fc24 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 21 Sep 2022 10:24:22 -0700
+Subject: ACPI: resource: Add ASUS model S5402ZA to quirks
+
+From: Kellen Renshaw <kellen.renshaw@canonical.com>
+
+[ Upstream commit 6e5cbe7c4b41824e500acbb42411da692d1435f1 ]
+
+The Asus Vivobook S5402ZA has the same keyboard issue as Asus Vivobook
+K3402ZA/K3502ZA. The kernel overrides IRQ 1 to Edge_High when it
+should be Active_Low.
+
+This patch adds the S5402ZA model to the quirk list.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216158
+Tested-by: Kellen Renshaw <kellen.renshaw@canonical.com>
+Signed-off-by: Kellen Renshaw <kellen.renshaw@canonical.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/resource.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
+index 91628fb41ef85..4d1db2def7ae4 100644
+--- a/drivers/acpi/resource.c
++++ b/drivers/acpi/resource.c
+@@ -421,6 +421,13 @@ static const struct dmi_system_id asus_laptop[] = {
+ DMI_MATCH(DMI_BOARD_NAME, "K3502ZA"),
+ },
+ },
++ {
++ .ident = "Asus Vivobook S5402ZA",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
++ DMI_MATCH(DMI_BOARD_NAME, "S5402ZA"),
++ },
++ },
+ { }
+ };
+
+--
+2.43.0
+
--- /dev/null
+From 4e4aa29d71398eab15a3e17cb5166b1d8d5202b0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 30 Dec 2022 00:58:39 -0500
+Subject: ACPI: resource: Skip IRQ override on Asus Expertbook B2402CBA
+
+From: Tamim Khan <tamim@fusetak.com>
+
+[ Upstream commit 77c7248882385397cd7dffe9e1437f59f32ce2de ]
+
+Like the Asus Expertbook B2502CBA and various Asus Vivobook laptops,
+the Asus Expertbook B2402CBA has an ACPI DSDT table that describes IRQ 1
+as ActiveLow while the kernel overrides it to Edge_High. This prevents the
+keyboard from working. To fix this issue, add this laptop to the
+skip_override_table so that the kernel does not override IRQ 1.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216864
+Tested-by: zelenat <zelenat@gmail.com>
+Signed-off-by: Tamim Khan <tamim@fusetak.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/resource.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
+index a5d2a81902038..6c5873f552e5e 100644
+--- a/drivers/acpi/resource.c
++++ b/drivers/acpi/resource.c
+@@ -435,6 +435,13 @@ static const struct dmi_system_id asus_laptop[] = {
+ DMI_MATCH(DMI_BOARD_NAME, "S5602ZA"),
+ },
+ },
++ {
++ .ident = "Asus ExpertBook B2402CBA",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
++ DMI_MATCH(DMI_BOARD_NAME, "B2402CBA"),
++ },
++ },
+ {
+ .ident = "Asus ExpertBook B2502",
+ .matches = {
+--
+2.43.0
+
--- /dev/null
+From 11506e553f88f6574027cf8c206370793da68643 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Apr 2023 20:31:44 +0200
+Subject: ACPI: resource: Skip IRQ override on ASUS ExpertBook B1502CBA
+
+From: Paul Menzel <pmenzel@molgen.mpg.de>
+
+[ Upstream commit 05cda427126f30ce3fc8ffd82fd6f5196398d502 ]
+
+Like the ASUS ExpertBook B2502CBA and various ASUS Vivobook laptops, the
+ASUS ExpertBook B1502CBA has an ACPI DSDT table that describes IRQ 1 as
+ActiveLow while the kernel overrides it to Edge_High.
+
+ $ sudo dmesg | grep DMI
+ DMI: ASUSTeK COMPUTER INC. ASUS EXPERTBOOK B1502CBA_B1502CBA/B1502CBA, BIOS B1502CBA.300 01/18/2023
+ $ grep -A 40 PS2K dsdt.dsl | grep IRQ -A 1
+ IRQ (Level, ActiveLow, Exclusive, )
+ {1}
+
+This prevents the keyboard from working. To fix this issue, add this laptop
+to the skip_override_table so that the kernel does not override IRQ 1.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=217323
+Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/resource.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
+index 6c5873f552e5e..a364cb07c5578 100644
+--- a/drivers/acpi/resource.c
++++ b/drivers/acpi/resource.c
+@@ -435,6 +435,13 @@ static const struct dmi_system_id asus_laptop[] = {
+ DMI_MATCH(DMI_BOARD_NAME, "S5602ZA"),
+ },
+ },
++ {
++ .ident = "Asus ExpertBook B1502CBA",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
++ DMI_MATCH(DMI_BOARD_NAME, "B1502CBA"),
++ },
++ },
+ {
+ .ident = "Asus ExpertBook B2402CBA",
+ .matches = {
+--
+2.43.0
+
--- /dev/null
+From 691f63e99e15f484939459d1b22fd4ebb81e6d17 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 14 Oct 2022 01:19:31 -0400
+Subject: ACPI: resource: Skip IRQ override on Asus Vivobook S5602ZA
+
+From: Tamim Khan <tamim@fusetak.com>
+
+[ Upstream commit b5f9223a105d9b56954ad1ca3eace4eaf26c99ed ]
+
+Like the Asus Vivobook K3402ZA/K3502ZA/S5402ZA Asus Vivobook S5602ZA
+has an ACPI DSDT table the describes IRQ 1 as ActiveLow while the kernel
+overrides it to Edge_High. This prevents the keyboard on this laptop
+from working. To fix this add this laptop to the skip_override_table so
+that the kernel does not override IRQ 1.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216579
+Tested-by: Dzmitry <wrkedm@gmail.com>
+Signed-off-by: Tamim Khan <tamim@fusetak.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/resource.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
+index 4d1db2def7ae4..5f56839ed71df 100644
+--- a/drivers/acpi/resource.c
++++ b/drivers/acpi/resource.c
+@@ -428,6 +428,13 @@ static const struct dmi_system_id asus_laptop[] = {
+ DMI_MATCH(DMI_BOARD_NAME, "S5402ZA"),
+ },
+ },
++ {
++ .ident = "Asus Vivobook S5602ZA",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
++ DMI_MATCH(DMI_BOARD_NAME, "S5602ZA"),
++ },
++ },
+ { }
+ };
+
+--
+2.43.0
+
--- /dev/null
+From aaa8d427d2533d84c058631f53e7dbf0c622ce23 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 May 2023 11:23:58 +0200
+Subject: ACPI: video: Add backlight=native DMI quirk for Apple iMac11,3
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 48436f2e9834b46b47b038b605c8142a1c07bc85 ]
+
+Linux defaults to picking the non-working ACPI video backlight interface
+on the Apple iMac11,3 .
+
+Add a DMI quirk to pick the working native radeon_bl0 interface instead.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: bd5d93df86a7 ("ACPI: video: Add backlight=native DMI quirk for Lenovo ThinkPad X131e (3371 AMD version)")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/video_detect.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
+index 5afc42d52e49b..be923911e87c1 100644
+--- a/drivers/acpi/video_detect.c
++++ b/drivers/acpi/video_detect.c
+@@ -341,6 +341,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
+ DMI_MATCH(DMI_PRODUCT_NAME, "82BK"),
+ },
+ },
++ {
++ .callback = video_detect_force_native,
++ /* Apple iMac11,3 */
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
++ DMI_MATCH(DMI_PRODUCT_NAME, "iMac11,3"),
++ },
++ },
+ {
+ /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
+ .callback = video_detect_force_native,
+--
+2.43.0
+
--- /dev/null
+From 07e54ba1c4d2081f880954ac6fbc5c516a4801b5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 7 Aug 2023 11:44:08 +0200
+Subject: ACPI: video: Add backlight=native DMI quirk for Apple iMac12,1 and
+ iMac12,2
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 8cf04bb321f036dd2e523e993897e0789bd5265c ]
+
+Linux defaults to picking the non-working ACPI video backlight interface
+on the Apple iMac12,1 and iMac12,2.
+
+Add a DMI quirk to pick the working native radeon_bl0 interface instead.
+
+Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1838
+Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2753
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/video_detect.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
+index 28e816be4753e..a5cb9e1d48bcc 100644
+--- a/drivers/acpi/video_detect.c
++++ b/drivers/acpi/video_detect.c
+@@ -357,6 +357,24 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
+ DMI_MATCH(DMI_PRODUCT_NAME, "iMac11,3"),
+ },
+ },
++ {
++ /* https://gitlab.freedesktop.org/drm/amd/-/issues/1838 */
++ .callback = video_detect_force_native,
++ /* Apple iMac12,1 */
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
++ DMI_MATCH(DMI_PRODUCT_NAME, "iMac12,1"),
++ },
++ },
++ {
++ /* https://gitlab.freedesktop.org/drm/amd/-/issues/2753 */
++ .callback = video_detect_force_native,
++ /* Apple iMac12,2 */
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
++ DMI_MATCH(DMI_PRODUCT_NAME, "iMac12,2"),
++ },
++ },
+ {
+ /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
+ .callback = video_detect_force_native,
+--
+2.43.0
+
--- /dev/null
+From 0ab294e829cea44e5338f69157c7c6219ebd1b6f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 May 2023 11:23:59 +0200
+Subject: ACPI: video: Add backlight=native DMI quirk for Lenovo ThinkPad X131e
+ (3371 AMD version)
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit bd5d93df86a7ddf98a2a37e9c3751e3cb334a66c ]
+
+Linux defaults to picking the non-working ACPI video backlight interface
+on the Lenovo ThinkPad X131e (3371 AMD version).
+
+Add a DMI quirk to pick the working native radeon_bl0 interface instead.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/video_detect.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
+index be923911e87c1..28e816be4753e 100644
+--- a/drivers/acpi/video_detect.c
++++ b/drivers/acpi/video_detect.c
+@@ -341,6 +341,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
+ DMI_MATCH(DMI_PRODUCT_NAME, "82BK"),
+ },
+ },
++ {
++ .callback = video_detect_force_native,
++ /* Lenovo ThinkPad X131e (3371 AMD version) */
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++ DMI_MATCH(DMI_PRODUCT_NAME, "3371"),
++ },
++ },
+ {
+ .callback = video_detect_force_native,
+ /* Apple iMac11,3 */
+--
+2.43.0
+
--- /dev/null
+From 57eed83d20d2a5d6f285334431e2b408b8b1f4e9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 20 Sep 2021 16:10:23 +0200
+Subject: ARM: dts: BCM53573: Describe on-SoC BCM53125 rev 4 switch
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Rafał Miłecki <rafal@milecki.pl>
+
+[ Upstream commit 9fb90ae6cae7f8fe4fbf626945f32cd9da2c3892 ]
+
+BCM53573 family SoC have Ethernet switch connected to the first Ethernet
+controller (accessible over MDIO).
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/bcm53573.dtsi | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/arch/arm/boot/dts/bcm53573.dtsi b/arch/arm/boot/dts/bcm53573.dtsi
+index 85a23dc52423c..eed1a6147f0bf 100644
+--- a/arch/arm/boot/dts/bcm53573.dtsi
++++ b/arch/arm/boot/dts/bcm53573.dtsi
+@@ -181,6 +181,24 @@ ohci_port2: port@2 {
+
+ gmac0: ethernet@5000 {
+ reg = <0x5000 0x1000>;
++
++ mdio {
++ #address-cells = <1>;
++ #size-cells = <0>;
++
++ switch: switch@1e {
++ compatible = "brcm,bcm53125";
++ reg = <0x1e>;
++
++ status = "disabled";
++
++ /* ports are defined in board DTS */
++ ports {
++ #address-cells = <1>;
++ #size-cells = <0>;
++ };
++ };
++ };
+ };
+
+ gmac1: ethernet@b000 {
+--
+2.43.0
+
--- /dev/null
+From 67575443259c06492c64f54308b2460ec57d52d6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 7 Jul 2023 13:40:01 +0200
+Subject: ARM: dts: BCM53573: Drop nonexistent "default-off" LED trigger
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Rafał Miłecki <rafal@milecki.pl>
+
+[ Upstream commit be7e1e5b0f67c58ec4be0a54db23b6a4fa6e2116 ]
+
+There is no such trigger documented or implemented in Linux. It was a
+copy & paste mistake.
+
+This fixes:
+arch/arm/boot/dts/broadcom/bcm47189-luxul-xap-1440.dtb: leds: led-wlan:linux,default-trigger: 'oneOf' conditional failed, one must be fixed:
+ 'default-off' is not one of ['backlight', 'default-on', 'heartbeat', 'disk-activity', 'disk-read', 'disk-write', 'timer', 'pattern', 'audio-micmute', 'audio-mute', 'bluetooth-power', 'flash', 'kbd-capslock', 'mtd', 'nand-disk', 'none', 'torch', 'usb-gadget', 'usb-host', 'usbport']
+ 'default-off' does not match '^cpu[0-9]*$'
+ 'default-off' does not match '^hci[0-9]+-power$'
+ 'default-off' does not match '^mmc[0-9]+$'
+ 'default-off' does not match '^phy[0-9]+tx$'
+ From schema: Documentation/devicetree/bindings/leds/leds-gpio.yaml
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Link: https://lore.kernel.org/r/20230707114004.2740-1-zajec5@gmail.com
+Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/bcm47189-luxul-xap-1440.dts | 1 -
+ arch/arm/boot/dts/bcm47189-luxul-xap-810.dts | 2 --
+ 2 files changed, 3 deletions(-)
+
+diff --git a/arch/arm/boot/dts/bcm47189-luxul-xap-1440.dts b/arch/arm/boot/dts/bcm47189-luxul-xap-1440.dts
+index 00e688b45d981..5901160919dcd 100644
+--- a/arch/arm/boot/dts/bcm47189-luxul-xap-1440.dts
++++ b/arch/arm/boot/dts/bcm47189-luxul-xap-1440.dts
+@@ -26,7 +26,6 @@ leds {
+ wlan {
+ label = "bcm53xx:blue:wlan";
+ gpios = <&chipcommon 10 GPIO_ACTIVE_LOW>;
+- linux,default-trigger = "default-off";
+ };
+
+ system {
+diff --git a/arch/arm/boot/dts/bcm47189-luxul-xap-810.dts b/arch/arm/boot/dts/bcm47189-luxul-xap-810.dts
+index 78c80a5d3f4fa..8e7483272d47d 100644
+--- a/arch/arm/boot/dts/bcm47189-luxul-xap-810.dts
++++ b/arch/arm/boot/dts/bcm47189-luxul-xap-810.dts
+@@ -26,7 +26,6 @@ leds {
+ 5ghz {
+ label = "bcm53xx:blue:5ghz";
+ gpios = <&chipcommon 11 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "default-off";
+ };
+
+ system {
+@@ -42,7 +41,6 @@ pcie0_leds {
+ 2ghz {
+ label = "bcm53xx:blue:2ghz";
+ gpios = <&pcie0_chipcommon 3 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "default-off";
+ };
+ };
+
+--
+2.43.0
+
--- /dev/null
+From 95ddc56513cce03992e8b7f5adb1c8f91394b606 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 7 Jul 2023 13:40:02 +0200
+Subject: ARM: dts: BCM53573: Drop nonexistent #usb-cells
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Rafał Miłecki <rafal@milecki.pl>
+
+[ Upstream commit 05d2c3d552b8c92fc397377d9d1112fc58e2cd59 ]
+
+Such property simply doesn't exist (is not documented or used anywhere).
+
+This fixes:
+arch/arm/boot/dts/broadcom/bcm47189-luxul-xap-1440.dtb: usb@d000: Unevaluated properties are not allowed ('#usb-cells' was unexpected)
+ From schema: Documentation/devicetree/bindings/usb/generic-ohci.yaml
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Link: https://lore.kernel.org/r/20230707114004.2740-2-zajec5@gmail.com
+Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/bcm53573.dtsi | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/arch/arm/boot/dts/bcm53573.dtsi b/arch/arm/boot/dts/bcm53573.dtsi
+index 933b6a380c367..85a23dc52423c 100644
+--- a/arch/arm/boot/dts/bcm53573.dtsi
++++ b/arch/arm/boot/dts/bcm53573.dtsi
+@@ -159,8 +159,6 @@ ehci_port2: port@2 {
+ };
+
+ ohci: usb@d000 {
+- #usb-cells = <0>;
+-
+ compatible = "generic-ohci";
+ reg = <0xd000 0x1000>;
+ interrupt-parent = <&gic>;
+--
+2.43.0
+
--- /dev/null
+From b56461e3326c044c6f84bffa6c08592e866673dd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Jun 2021 20:12:55 +0200
+Subject: arm64: dts: rockchip: add ES8316 codec for ROCK Pi 4
+
+From: Alex Bee <knaerzche@gmail.com>
+
+[ Upstream commit 65bd2b8bdb3bddc37bea695789713916327e1c1f ]
+
+ROCK Pi 4 boards have the codec connected to i2s0 and it is accessible
+via i2c1 address 0x11.
+Add an audio-graph-card for it.
+
+Signed-off-by: Alex Bee <knaerzche@gmail.com>
+Link: https://lore.kernel.org/r/20210618181256.27992-5-knaerzche@gmail.com
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 28 +++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+index 203460d46f182..0af694540c1eb 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+@@ -36,6 +36,12 @@ sdio_pwrseq: sdio-pwrseq {
+ reset-gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>;
+ };
+
++ sound {
++ compatible = "audio-graph-card";
++ label = "Analog";
++ dais = <&i2s0_p0>;
++ };
++
+ vcc12v_dcin: dc-12v {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc12v_dcin";
+@@ -423,6 +429,20 @@ &i2c1 {
+ i2c-scl-rising-time-ns = <300>;
+ i2c-scl-falling-time-ns = <15>;
+ status = "okay";
++
++ es8316: codec@11 {
++ compatible = "everest,es8316";
++ reg = <0x11>;
++ clocks = <&cru SCLK_I2S_8CH_OUT>;
++ clock-names = "mclk";
++ #sound-dai-cells = <0>;
++
++ port {
++ es8316_p0_0: endpoint {
++ remote-endpoint = <&i2s0_p0_0>;
++ };
++ };
++ };
+ };
+
+ &i2c3 {
+@@ -442,6 +462,14 @@ &i2s0 {
+ rockchip,capture-channels = <2>;
+ rockchip,playback-channels = <2>;
+ status = "okay";
++
++ i2s0_p0: port {
++ i2s0_p0_0: endpoint {
++ dai-format = "i2s";
++ mclk-fs = <256>;
++ remote-endpoint = <&es8316_p0_0>;
++ };
++ };
+ };
+
+ &i2s1 {
+--
+2.43.0
+
--- /dev/null
+From de00fb997587dcfb4bbcfab25a14c03ae79cfb81 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Jun 2021 20:12:56 +0200
+Subject: arm64: dts: rockchip: add SPDIF node for ROCK Pi 4
+
+From: Alex Bee <knaerzche@gmail.com>
+
+[ Upstream commit 697dd494cb1cf56acfb764214a1e4788e4d1a983 ]
+
+Add a SPDIF audio-graph-card to ROCK Pi 4 device tree.
+
+It's not enabled by default since all dma channels are used by
+the (already) enabled i2s0/1/2 and the pin is muxed with GPIO4_C5
+which might be in use already.
+If enabled SPDIF_TX will be available at pin #15.
+
+Signed-off-by: Alex Bee <knaerzche@gmail.com>
+Link: https://lore.kernel.org/r/20210618181256.27992-6-knaerzche@gmail.com
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 26 +++++++++++++++++++
+ 1 file changed, 26 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+index 0af694540c1eb..382bb0734cb74 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+@@ -42,6 +42,23 @@ sound {
+ dais = <&i2s0_p0>;
+ };
+
++ sound-dit {
++ compatible = "audio-graph-card";
++ label = "SPDIF";
++ dais = <&spdif_p0>;
++ };
++
++ spdif-dit {
++ compatible = "linux,spdif-dit";
++ #sound-dai-cells = <0>;
++
++ port {
++ dit_p0_0: endpoint {
++ remote-endpoint = <&spdif_p0_0>;
++ };
++ };
++ };
++
+ vcc12v_dcin: dc-12v {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc12v_dcin";
+@@ -631,6 +648,15 @@ &sdhci {
+ status = "okay";
+ };
+
++&spdif {
++
++ spdif_p0: port {
++ spdif_p0_0: endpoint {
++ remote-endpoint = <&dit_p0_0>;
++ };
++ };
++};
++
+ &tcphy0 {
+ status = "okay";
+ };
+--
+2.43.0
+
--- /dev/null
+From eaa5bfb3ec3b5219917eeb3c0775fb588b43d920 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 9 Sep 2022 19:50:04 +0000
+Subject: arm64: dts: rockchip: fix regulator name on rk3399-rock-4
+
+From: FUKAUMI Naoki <naoki@radxa.com>
+
+[ Upstream commit 69448624b770aa88a71536a16900dd3cc6002919 ]
+
+fix regulator name
+
+ref:
+ https://dl.radxa.com/rockpi4/docs/hw/rockpi4/rockpi4_v13_sch_20181112.pdf
+
+Signed-off-by: FUKAUMI Naoki <naoki@radxa.com>
+Link: https://lore.kernel.org/r/20220909195006.127957-4-naoki@radxa.com
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../boot/dts/rockchip/rk3399-rock-pi-4.dtsi | 25 ++++++++++---------
+ 1 file changed, 13 insertions(+), 12 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+index 8b70e831aff23..203460d46f182 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dtsi
+@@ -98,24 +98,25 @@ vcc5v0_host: vcc5v0-host-regulator {
+ vin-supply = <&vcc5v0_sys>;
+ };
+
+- vcc5v0_typec: vcc5v0-typec-regulator {
++ vbus_typec: vbus-typec-regulator {
+ compatible = "regulator-fixed";
+ enable-active-high;
+ gpio = <&gpio1 RK_PA3 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&vcc5v0_typec_en>;
+- regulator-name = "vcc5v0_typec";
++ regulator-name = "vbus_typec";
+ regulator-always-on;
+ vin-supply = <&vcc5v0_sys>;
+ };
+
+- vcc_lan: vcc3v3-phy-regulator {
++ vcc3v3_lan: vcc3v3-lan-regulator {
+ compatible = "regulator-fixed";
+- regulator-name = "vcc_lan";
++ regulator-name = "vcc3v3_lan";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
++ vin-supply = <&vcc3v3_sys>;
+ };
+
+ vdd_log: vdd-log {
+@@ -162,7 +163,7 @@ &gmac {
+ assigned-clocks = <&cru SCLK_RMII_SRC>;
+ assigned-clock-parents = <&clkin_gmac>;
+ clock_in_out = "input";
+- phy-supply = <&vcc_lan>;
++ phy-supply = <&vcc3v3_lan>;
+ phy-mode = "rgmii";
+ pinctrl-names = "default";
+ pinctrl-0 = <&rgmii_pins>;
+@@ -267,8 +268,8 @@ regulator-state-mem {
+ };
+ };
+
+- vcc1v8_codec: LDO_REG1 {
+- regulator-name = "vcc1v8_codec";
++ vcca1v8_codec: LDO_REG1 {
++ regulator-name = "vcca1v8_codec";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <1800000>;
+@@ -278,8 +279,8 @@ regulator-state-mem {
+ };
+ };
+
+- vcc1v8_hdmi: LDO_REG2 {
+- regulator-name = "vcc1v8_hdmi";
++ vcca1v8_hdmi: LDO_REG2 {
++ regulator-name = "vcca1v8_hdmi";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <1800000>;
+@@ -336,8 +337,8 @@ regulator-state-mem {
+ };
+ };
+
+- vcc0v9_hdmi: LDO_REG7 {
+- regulator-name = "vcc0v9_hdmi";
++ vcca0v9_hdmi: LDO_REG7 {
++ regulator-name = "vcca0v9_hdmi";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <900000>;
+@@ -456,7 +457,7 @@ &io_domains {
+ status = "okay";
+
+ bt656-supply = <&vcc_3v0>;
+- audio-supply = <&vcc1v8_codec>;
++ audio-supply = <&vcca1v8_codec>;
+ sdmmc-supply = <&vcc_sdio>;
+ gpio1830-supply = <&vcc_3v0>;
+ };
+--
+2.43.0
+
--- /dev/null
+From 568d6c374f85dac74a01a3d4725dd1aa153b88b8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 15 Jun 2023 11:26:28 +0100
+Subject: arm64: mm: fix VA-range sanity check
+
+From: Mark Rutland <mark.rutland@arm.com>
+
+[ Upstream commit ab9b4008092c86dc12497af155a0901cc1156999 ]
+
+Both create_mapping_noalloc() and update_mapping_prot() sanity-check
+their 'virt' parameter, but the check itself doesn't make much sense.
+The condition used today appears to be a historical accident.
+
+The sanity-check condition:
+
+ if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
+ [ ... warning here ... ]
+ return;
+ }
+
+... can only be true for the KASAN shadow region or the module region,
+and there's no reason to exclude these specifically for creating and
+updateing mappings.
+
+When arm64 support was first upstreamed in commit:
+
+ c1cc1552616d0f35 ("arm64: MMU initialisation")
+
+... the condition was:
+
+ if (virt < VMALLOC_START) {
+ [ ... warning here ... ]
+ return;
+ }
+
+At the time, VMALLOC_START was the lowest kernel address, and this was
+checking whether 'virt' would be translated via TTBR1.
+
+Subsequently in commit:
+
+ 14c127c957c1c607 ("arm64: mm: Flip kernel VA space")
+
+... the condition was changed to:
+
+ if ((virt >= VA_START) && (virt < VMALLOC_START)) {
+ [ ... warning here ... ]
+ return;
+ }
+
+This appear to have been a thinko. The commit moved the linear map to
+the bottom of the kernel address space, with VMALLOC_START being at the
+halfway point. The old condition would warn for changes to the linear
+map below this, and at the time VA_START was the end of the linear map.
+
+Subsequently we cleaned up the naming of VA_START in commit:
+
+ 77ad4ce69321abbe ("arm64: memory: rename VA_START to PAGE_END")
+
+... keeping the erroneous condition as:
+
+ if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
+ [ ... warning here ... ]
+ return;
+ }
+
+Correct the condition to check against the start of the TTBR1 address
+space, which is currently PAGE_OFFSET. This simplifies the logic, and
+more clearly matches the "outside kernel range" message in the warning.
+
+Signed-off-by: Mark Rutland <mark.rutland@arm.com>
+Cc: Russell King <linux@armlinux.org.uk>
+Cc: Steve Capper <steve.capper@arm.com>
+Cc: Will Deacon <will@kernel.org>
+Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
+Link: https://lore.kernel.org/r/20230615102628.1052103-1-mark.rutland@arm.com
+Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm64/mm/mmu.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
+index 6680689242df3..fc86e7465df42 100644
+--- a/arch/arm64/mm/mmu.c
++++ b/arch/arm64/mm/mmu.c
+@@ -435,7 +435,7 @@ static phys_addr_t pgd_pgtable_alloc(int shift)
+ static void __init create_mapping_noalloc(phys_addr_t phys, unsigned long virt,
+ phys_addr_t size, pgprot_t prot)
+ {
+- if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
++ if (virt < PAGE_OFFSET) {
+ pr_warn("BUG: not creating mapping for %pa at 0x%016lx - outside kernel range\n",
+ &phys, virt);
+ return;
+@@ -462,7 +462,7 @@ void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
+ static void update_mapping_prot(phys_addr_t phys, unsigned long virt,
+ phys_addr_t size, pgprot_t prot)
+ {
+- if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
++ if (virt < PAGE_OFFSET) {
+ pr_warn("BUG: not updating mapping for %pa at 0x%016lx - outside kernel range\n",
+ &phys, virt);
+ return;
+--
+2.43.0
+
--- /dev/null
+From 6235d56c4d25176b8c30485192f44030bcc0a268 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 24 Apr 2023 10:04:36 +0900
+Subject: arm64: set __exception_irq_entry with __irq_entry as a default
+
+From: Youngmin Nam <youngmin.nam@samsung.com>
+
+[ Upstream commit f6794950f0e5ba37e3bbedda4d6ab0aad7395dd3 ]
+
+filter_irq_stacks() is supposed to cut entries which are related irq entries
+from its call stack.
+And in_irqentry_text() which is called by filter_irq_stacks()
+uses __irqentry_text_start/end symbol to find irq entries in callstack.
+
+But it doesn't work correctly as without "CONFIG_FUNCTION_GRAPH_TRACER",
+arm64 kernel doesn't include gic_handle_irq which is entry point of arm64 irq
+between __irqentry_text_start and __irqentry_text_end as we discussed in below link.
+https://lore.kernel.org/all/CACT4Y+aReMGLYua2rCLHgFpS9io5cZC04Q8GLs-uNmrn1ezxYQ@mail.gmail.com/#t
+
+This problem can makes unintentional deep call stack entries especially
+in KASAN enabled situation as below.
+
+[ 2479.383395]I[0:launcher-loader: 1719] Stack depot reached limit capacity
+[ 2479.383538]I[0:launcher-loader: 1719] WARNING: CPU: 0 PID: 1719 at lib/stackdepot.c:129 __stack_depot_save+0x464/0x46c
+[ 2479.385693]I[0:launcher-loader: 1719] pstate: 624000c5 (nZCv daIF +PAN -UAO +TCO -DIT -SSBS BTYPE=--)
+[ 2479.385724]I[0:launcher-loader: 1719] pc : __stack_depot_save+0x464/0x46c
+[ 2479.385751]I[0:launcher-loader: 1719] lr : __stack_depot_save+0x460/0x46c
+[ 2479.385774]I[0:launcher-loader: 1719] sp : ffffffc0080073c0
+[ 2479.385793]I[0:launcher-loader: 1719] x29: ffffffc0080073e0 x28: ffffffd00b78a000 x27: 0000000000000000
+[ 2479.385839]I[0:launcher-loader: 1719] x26: 000000000004d1dd x25: ffffff891474f000 x24: 00000000ca64d1dd
+[ 2479.385882]I[0:launcher-loader: 1719] x23: 0000000000000200 x22: 0000000000000220 x21: 0000000000000040
+[ 2479.385925]I[0:launcher-loader: 1719] x20: ffffffc008007440 x19: 0000000000000000 x18: 0000000000000000
+[ 2479.385969]I[0:launcher-loader: 1719] x17: 2065726568207475 x16: 000000000000005e x15: 2d2d2d2d2d2d2d20
+[ 2479.386013]I[0:launcher-loader: 1719] x14: 5d39313731203a72 x13: 00000000002f6b30 x12: 00000000002f6af8
+[ 2479.386057]I[0:launcher-loader: 1719] x11: 00000000ffffffff x10: ffffffb90aacf000 x9 : e8a74a6c16008800
+[ 2479.386101]I[0:launcher-loader: 1719] x8 : e8a74a6c16008800 x7 : 00000000002f6b30 x6 : 00000000002f6af8
+[ 2479.386145]I[0:launcher-loader: 1719] x5 : ffffffc0080070c8 x4 : ffffffd00b192380 x3 : ffffffd0092b313c
+[ 2479.386189]I[0:launcher-loader: 1719] x2 : 0000000000000001 x1 : 0000000000000004 x0 : 0000000000000022
+[ 2479.386231]I[0:launcher-loader: 1719] Call trace:
+[ 2479.386248]I[0:launcher-loader: 1719] __stack_depot_save+0x464/0x46c
+[ 2479.386273]I[0:launcher-loader: 1719] kasan_save_stack+0x58/0x70
+[ 2479.386303]I[0:launcher-loader: 1719] save_stack_info+0x34/0x138
+[ 2479.386331]I[0:launcher-loader: 1719] kasan_save_free_info+0x18/0x24
+[ 2479.386358]I[0:launcher-loader: 1719] ____kasan_slab_free+0x16c/0x170
+[ 2479.386385]I[0:launcher-loader: 1719] __kasan_slab_free+0x10/0x20
+[ 2479.386410]I[0:launcher-loader: 1719] kmem_cache_free+0x238/0x53c
+[ 2479.386435]I[0:launcher-loader: 1719] mempool_free_slab+0x1c/0x28
+[ 2479.386460]I[0:launcher-loader: 1719] mempool_free+0x7c/0x1a0
+[ 2479.386484]I[0:launcher-loader: 1719] bvec_free+0x34/0x80
+[ 2479.386514]I[0:launcher-loader: 1719] bio_free+0x60/0x98
+[ 2479.386540]I[0:launcher-loader: 1719] bio_put+0x50/0x21c
+[ 2479.386567]I[0:launcher-loader: 1719] f2fs_write_end_io+0x4ac/0x4d0
+[ 2479.386594]I[0:launcher-loader: 1719] bio_endio+0x2dc/0x300
+[ 2479.386622]I[0:launcher-loader: 1719] __dm_io_complete+0x324/0x37c
+[ 2479.386650]I[0:launcher-loader: 1719] dm_io_dec_pending+0x60/0xa4
+[ 2479.386676]I[0:launcher-loader: 1719] clone_endio+0xf8/0x2f0
+[ 2479.386700]I[0:launcher-loader: 1719] bio_endio+0x2dc/0x300
+[ 2479.386727]I[0:launcher-loader: 1719] blk_update_request+0x258/0x63c
+[ 2479.386754]I[0:launcher-loader: 1719] scsi_end_request+0x50/0x304
+[ 2479.386782]I[0:launcher-loader: 1719] scsi_io_completion+0x88/0x160
+[ 2479.386808]I[0:launcher-loader: 1719] scsi_finish_command+0x17c/0x194
+[ 2479.386833]I[0:launcher-loader: 1719] scsi_complete+0xcc/0x158
+[ 2479.386859]I[0:launcher-loader: 1719] blk_mq_complete_request+0x4c/0x5c
+[ 2479.386885]I[0:launcher-loader: 1719] scsi_done_internal+0xf4/0x1e0
+[ 2479.386910]I[0:launcher-loader: 1719] scsi_done+0x14/0x20
+[ 2479.386935]I[0:launcher-loader: 1719] ufshcd_compl_one_cqe+0x578/0x71c
+[ 2479.386963]I[0:launcher-loader: 1719] ufshcd_mcq_poll_cqe_nolock+0xc8/0x150
+[ 2479.386991]I[0:launcher-loader: 1719] ufshcd_intr+0x868/0xc0c
+[ 2479.387017]I[0:launcher-loader: 1719] __handle_irq_event_percpu+0xd0/0x348
+[ 2479.387044]I[0:launcher-loader: 1719] handle_irq_event_percpu+0x24/0x74
+[ 2479.387068]I[0:launcher-loader: 1719] handle_irq_event+0x74/0xe0
+[ 2479.387091]I[0:launcher-loader: 1719] handle_fasteoi_irq+0x174/0x240
+[ 2479.387118]I[0:launcher-loader: 1719] handle_irq_desc+0x7c/0x2c0
+[ 2479.387147]I[0:launcher-loader: 1719] generic_handle_domain_irq+0x1c/0x28
+[ 2479.387174]I[0:launcher-loader: 1719] gic_handle_irq+0x64/0x158
+[ 2479.387204]I[0:launcher-loader: 1719] call_on_irq_stack+0x2c/0x54
+[ 2479.387231]I[0:launcher-loader: 1719] do_interrupt_handler+0x70/0xa0
+[ 2479.387258]I[0:launcher-loader: 1719] el1_interrupt+0x34/0x68
+[ 2479.387283]I[0:launcher-loader: 1719] el1h_64_irq_handler+0x18/0x24
+[ 2479.387308]I[0:launcher-loader: 1719] el1h_64_irq+0x68/0x6c
+[ 2479.387332]I[0:launcher-loader: 1719] blk_attempt_bio_merge+0x8/0x170
+[ 2479.387356]I[0:launcher-loader: 1719] blk_mq_attempt_bio_merge+0x78/0x98
+[ 2479.387383]I[0:launcher-loader: 1719] blk_mq_submit_bio+0x324/0xa40
+[ 2479.387409]I[0:launcher-loader: 1719] __submit_bio+0x104/0x138
+[ 2479.387436]I[0:launcher-loader: 1719] submit_bio_noacct_nocheck+0x1d0/0x4a0
+[ 2479.387462]I[0:launcher-loader: 1719] submit_bio_noacct+0x618/0x804
+[ 2479.387487]I[0:launcher-loader: 1719] submit_bio+0x164/0x180
+[ 2479.387511]I[0:launcher-loader: 1719] f2fs_submit_read_bio+0xe4/0x1c4
+[ 2479.387537]I[0:launcher-loader: 1719] f2fs_mpage_readpages+0x888/0xa4c
+[ 2479.387563]I[0:launcher-loader: 1719] f2fs_readahead+0xd4/0x19c
+[ 2479.387587]I[0:launcher-loader: 1719] read_pages+0xb0/0x4ac
+[ 2479.387614]I[0:launcher-loader: 1719] page_cache_ra_unbounded+0x238/0x288
+[ 2479.387642]I[0:launcher-loader: 1719] do_page_cache_ra+0x60/0x6c
+[ 2479.387669]I[0:launcher-loader: 1719] page_cache_ra_order+0x318/0x364
+[ 2479.387695]I[0:launcher-loader: 1719] ondemand_readahead+0x30c/0x3d8
+[ 2479.387722]I[0:launcher-loader: 1719] page_cache_sync_ra+0xb4/0xc8
+[ 2479.387749]I[0:launcher-loader: 1719] filemap_read+0x268/0xd24
+[ 2479.387777]I[0:launcher-loader: 1719] f2fs_file_read_iter+0x1a0/0x62c
+[ 2479.387806]I[0:launcher-loader: 1719] vfs_read+0x258/0x34c
+[ 2479.387831]I[0:launcher-loader: 1719] ksys_pread64+0x8c/0xd0
+[ 2479.387857]I[0:launcher-loader: 1719] __arm64_sys_pread64+0x48/0x54
+[ 2479.387881]I[0:launcher-loader: 1719] invoke_syscall+0x58/0x158
+[ 2479.387909]I[0:launcher-loader: 1719] el0_svc_common+0xf0/0x134
+[ 2479.387935]I[0:launcher-loader: 1719] do_el0_svc+0x44/0x114
+[ 2479.387961]I[0:launcher-loader: 1719] el0_svc+0x2c/0x80
+[ 2479.387985]I[0:launcher-loader: 1719] el0t_64_sync_handler+0x48/0x114
+[ 2479.388010]I[0:launcher-loader: 1719] el0t_64_sync+0x190/0x194
+[ 2479.388038]I[0:launcher-loader: 1719] Kernel panic - not syncing: kernel: panic_on_warn set ...
+
+So let's set __exception_irq_entry with __irq_entry as a default.
+Applying this patch, we can see gic_hande_irq is included in Systemp.map as below.
+
+* Before
+ffffffc008010000 T __do_softirq
+ffffffc008010000 T __irqentry_text_end
+ffffffc008010000 T __irqentry_text_start
+ffffffc008010000 T __softirqentry_text_start
+ffffffc008010000 T _stext
+ffffffc00801066c T __softirqentry_text_end
+ffffffc008010670 T __entry_text_start
+
+* After
+ffffffc008010000 T __irqentry_text_start
+ffffffc008010000 T _stext
+ffffffc008010000 t gic_handle_irq
+ffffffc00801013c t gic_handle_irq
+ffffffc008010294 T __irqentry_text_end
+ffffffc008010298 T __do_softirq
+ffffffc008010298 T __softirqentry_text_start
+ffffffc008010904 T __softirqentry_text_end
+ffffffc008010908 T __entry_text_start
+
+Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
+Signed-off-by: SEO HOYOUNG <hy50.seo@samsung.com>
+Reviewed-by: Mark Rutland <mark.rutland@arm.com>
+Link: https://lore.kernel.org/r/20230424010436.779733-1-youngmin.nam@samsung.com
+Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm64/include/asm/exception.h | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h
+index 515ebe24fd44f..fe4aa233a90ed 100644
+--- a/arch/arm64/include/asm/exception.h
++++ b/arch/arm64/include/asm/exception.h
+@@ -8,16 +8,11 @@
+ #define __ASM_EXCEPTION_H
+
+ #include <asm/esr.h>
+-#include <asm/kprobes.h>
+ #include <asm/ptrace.h>
+
+ #include <linux/interrupt.h>
+
+-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ #define __exception_irq_entry __irq_entry
+-#else
+-#define __exception_irq_entry __kprobes
+-#endif
+
+ static inline unsigned long disr_to_esr(u64 disr)
+ {
+--
+2.43.0
+
--- /dev/null
+From ee4706eb6446339f077d4b8c9e9f0bfa0e561310 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 10 May 2023 21:37:48 -0700
+Subject: bpf: Address KCSAN report on bpf_lru_list
+
+From: Martin KaFai Lau <martin.lau@kernel.org>
+
+[ Upstream commit ee9fd0ac3017c4313be91a220a9ac4c99dde7ad4 ]
+
+KCSAN reported a data-race when accessing node->ref.
+Although node->ref does not have to be accurate,
+take this chance to use a more common READ_ONCE() and WRITE_ONCE()
+pattern instead of data_race().
+
+There is an existing bpf_lru_node_is_ref() and bpf_lru_node_set_ref().
+This patch also adds bpf_lru_node_clear_ref() to do the
+WRITE_ONCE(node->ref, 0) also.
+
+==================================================================
+BUG: KCSAN: data-race in __bpf_lru_list_rotate / __htab_lru_percpu_map_update_elem
+
+write to 0xffff888137038deb of 1 bytes by task 11240 on cpu 1:
+__bpf_lru_node_move kernel/bpf/bpf_lru_list.c:113 [inline]
+__bpf_lru_list_rotate_active kernel/bpf/bpf_lru_list.c:149 [inline]
+__bpf_lru_list_rotate+0x1bf/0x750 kernel/bpf/bpf_lru_list.c:240
+bpf_lru_list_pop_free_to_local kernel/bpf/bpf_lru_list.c:329 [inline]
+bpf_common_lru_pop_free kernel/bpf/bpf_lru_list.c:447 [inline]
+bpf_lru_pop_free+0x638/0xe20 kernel/bpf/bpf_lru_list.c:499
+prealloc_lru_pop kernel/bpf/hashtab.c:290 [inline]
+__htab_lru_percpu_map_update_elem+0xe7/0x820 kernel/bpf/hashtab.c:1316
+bpf_percpu_hash_update+0x5e/0x90 kernel/bpf/hashtab.c:2313
+bpf_map_update_value+0x2a9/0x370 kernel/bpf/syscall.c:200
+generic_map_update_batch+0x3ae/0x4f0 kernel/bpf/syscall.c:1687
+bpf_map_do_batch+0x2d9/0x3d0 kernel/bpf/syscall.c:4534
+__sys_bpf+0x338/0x810
+__do_sys_bpf kernel/bpf/syscall.c:5096 [inline]
+__se_sys_bpf kernel/bpf/syscall.c:5094 [inline]
+__x64_sys_bpf+0x43/0x50 kernel/bpf/syscall.c:5094
+do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
+entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+read to 0xffff888137038deb of 1 bytes by task 11241 on cpu 0:
+bpf_lru_node_set_ref kernel/bpf/bpf_lru_list.h:70 [inline]
+__htab_lru_percpu_map_update_elem+0x2f1/0x820 kernel/bpf/hashtab.c:1332
+bpf_percpu_hash_update+0x5e/0x90 kernel/bpf/hashtab.c:2313
+bpf_map_update_value+0x2a9/0x370 kernel/bpf/syscall.c:200
+generic_map_update_batch+0x3ae/0x4f0 kernel/bpf/syscall.c:1687
+bpf_map_do_batch+0x2d9/0x3d0 kernel/bpf/syscall.c:4534
+__sys_bpf+0x338/0x810
+__do_sys_bpf kernel/bpf/syscall.c:5096 [inline]
+__se_sys_bpf kernel/bpf/syscall.c:5094 [inline]
+__x64_sys_bpf+0x43/0x50 kernel/bpf/syscall.c:5094
+do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
+entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+value changed: 0x01 -> 0x00
+
+Reported by Kernel Concurrency Sanitizer on:
+CPU: 0 PID: 11241 Comm: syz-executor.3 Not tainted 6.3.0-rc7-syzkaller-00136-g6a66fdd29ea1 #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
+==================================================================
+
+Reported-by: syzbot+ebe648a84e8784763f82@syzkaller.appspotmail.com
+Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
+Acked-by: Yonghong Song <yhs@fb.com>
+Link: https://lore.kernel.org/r/20230511043748.1384166-1-martin.lau@linux.dev
+Signed-off-by: Alexei Starovoitov <ast@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/bpf/bpf_lru_list.c | 21 +++++++++++++--------
+ kernel/bpf/bpf_lru_list.h | 7 ++-----
+ 2 files changed, 15 insertions(+), 13 deletions(-)
+
+diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
+index d99e89f113c43..3dabdd137d102 100644
+--- a/kernel/bpf/bpf_lru_list.c
++++ b/kernel/bpf/bpf_lru_list.c
+@@ -41,7 +41,12 @@ static struct list_head *local_pending_list(struct bpf_lru_locallist *loc_l)
+ /* bpf_lru_node helpers */
+ static bool bpf_lru_node_is_ref(const struct bpf_lru_node *node)
+ {
+- return node->ref;
++ return READ_ONCE(node->ref);
++}
++
++static void bpf_lru_node_clear_ref(struct bpf_lru_node *node)
++{
++ WRITE_ONCE(node->ref, 0);
+ }
+
+ static void bpf_lru_list_count_inc(struct bpf_lru_list *l,
+@@ -89,7 +94,7 @@ static void __bpf_lru_node_move_in(struct bpf_lru_list *l,
+
+ bpf_lru_list_count_inc(l, tgt_type);
+ node->type = tgt_type;
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+ list_move(&node->list, &l->lists[tgt_type]);
+ }
+
+@@ -110,7 +115,7 @@ static void __bpf_lru_node_move(struct bpf_lru_list *l,
+ bpf_lru_list_count_inc(l, tgt_type);
+ node->type = tgt_type;
+ }
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+
+ /* If the moving node is the next_inactive_rotation candidate,
+ * move the next_inactive_rotation pointer also.
+@@ -353,7 +358,7 @@ static void __local_list_add_pending(struct bpf_lru *lru,
+ *(u32 *)((void *)node + lru->hash_offset) = hash;
+ node->cpu = cpu;
+ node->type = BPF_LRU_LOCAL_LIST_T_PENDING;
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+ list_add(&node->list, local_pending_list(loc_l));
+ }
+
+@@ -419,7 +424,7 @@ static struct bpf_lru_node *bpf_percpu_lru_pop_free(struct bpf_lru *lru,
+ if (!list_empty(free_list)) {
+ node = list_first_entry(free_list, struct bpf_lru_node, list);
+ *(u32 *)((void *)node + lru->hash_offset) = hash;
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+ __bpf_lru_node_move(l, node, BPF_LRU_LIST_T_INACTIVE);
+ }
+
+@@ -522,7 +527,7 @@ static void bpf_common_lru_push_free(struct bpf_lru *lru,
+ }
+
+ node->type = BPF_LRU_LOCAL_LIST_T_FREE;
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+ list_move(&node->list, local_free_list(loc_l));
+
+ raw_spin_unlock_irqrestore(&loc_l->lock, flags);
+@@ -568,7 +573,7 @@ static void bpf_common_lru_populate(struct bpf_lru *lru, void *buf,
+
+ node = (struct bpf_lru_node *)(buf + node_offset);
+ node->type = BPF_LRU_LIST_T_FREE;
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+ list_add(&node->list, &l->lists[BPF_LRU_LIST_T_FREE]);
+ buf += elem_size;
+ }
+@@ -594,7 +599,7 @@ static void bpf_percpu_lru_populate(struct bpf_lru *lru, void *buf,
+ node = (struct bpf_lru_node *)(buf + node_offset);
+ node->cpu = cpu;
+ node->type = BPF_LRU_LIST_T_FREE;
+- node->ref = 0;
++ bpf_lru_node_clear_ref(node);
+ list_add(&node->list, &l->lists[BPF_LRU_LIST_T_FREE]);
+ i++;
+ buf += elem_size;
+diff --git a/kernel/bpf/bpf_lru_list.h b/kernel/bpf/bpf_lru_list.h
+index 6b12f06ee18c3..9c12ee453c616 100644
+--- a/kernel/bpf/bpf_lru_list.h
++++ b/kernel/bpf/bpf_lru_list.h
+@@ -63,11 +63,8 @@ struct bpf_lru {
+
+ static inline void bpf_lru_node_set_ref(struct bpf_lru_node *node)
+ {
+- /* ref is an approximation on access frequency. It does not
+- * have to be very accurate. Hence, no protection is used.
+- */
+- if (!node->ref)
+- node->ref = 1;
++ if (!READ_ONCE(node->ref))
++ WRITE_ONCE(node->ref, 1);
+ }
+
+ int bpf_lru_init(struct bpf_lru *lru, bool percpu, u32 hash_offset,
+--
+2.43.0
+
--- /dev/null
+From 74bf049ba85604294577a84c7c9b65f8fd320b7e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 4 Apr 2023 00:06:02 +0200
+Subject: btrfs: add xxhash to fast checksum implementations
+
+From: David Sterba <dsterba@suse.com>
+
+[ Upstream commit efcfcbc6a36195c42d98e0ee697baba36da94dc8 ]
+
+The implementation of XXHASH is now CPU only but still fast enough to be
+considered for the synchronous checksumming, like non-generic crc32c.
+
+A userspace benchmark comparing it to various implementations (patched
+hash-speedtest from btrfs-progs):
+
+ Block size: 4096
+ Iterations: 1000000
+ Implementation: builtin
+ Units: CPU cycles
+
+ NULL-NOP: cycles: 73384294, cycles/i 73
+ NULL-MEMCPY: cycles: 228033868, cycles/i 228, 61664.320 MiB/s
+ CRC32C-ref: cycles: 24758559416, cycles/i 24758, 567.950 MiB/s
+ CRC32C-NI: cycles: 1194350470, cycles/i 1194, 11773.433 MiB/s
+ CRC32C-ADLERSW: cycles: 6150186216, cycles/i 6150, 2286.372 MiB/s
+ CRC32C-ADLERHW: cycles: 626979180, cycles/i 626, 22427.453 MiB/s
+ CRC32C-PCL: cycles: 466746732, cycles/i 466, 30126.699 MiB/s
+ XXHASH: cycles: 860656400, cycles/i 860, 16338.188 MiB/s
+
+Comparing purely software implementation (ref), current outdated
+accelerated using crc32q instruction (NI), optimized implementations by
+M. Adler (https://stackoverflow.com/questions/17645167/implementing-sse-4-2s-crc32c-in-software/17646775#17646775)
+and the best one that was taken from kernel using the PCLMULQDQ
+instruction (PCL).
+
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/disk-io.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
+index 9ae7c12668cda..c1dfde886b1e3 100644
+--- a/fs/btrfs/disk-io.c
++++ b/fs/btrfs/disk-io.c
+@@ -2338,6 +2338,9 @@ static int btrfs_init_csum_hash(struct btrfs_fs_info *fs_info, u16 csum_type)
+ if (!strstr(crypto_shash_driver_name(csum_shash), "generic"))
+ set_bit(BTRFS_FS_CSUM_IMPL_FAST, &fs_info->flags);
+ break;
++ case BTRFS_CSUM_TYPE_XXHASH:
++ set_bit(BTRFS_FS_CSUM_IMPL_FAST, &fs_info->flags);
++ break;
+ default:
+ break;
+ }
+--
+2.43.0
+
--- /dev/null
+From eaf067a66fa40cec64fd773d64319974da55e9eb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 9 Jun 2023 17:46:56 +0000
+Subject: cifs: add a warning when the in-flight count goes negative
+
+From: Shyam Prasad N <sprasad@microsoft.com>
+
+[ Upstream commit e4645cc2f1e2d6f268bb8dcfac40997c52432aed ]
+
+We've seen the in-flight count go into negative with some
+internal stress testing in Microsoft.
+
+Adding a WARN when this happens, in hope of understanding
+why this happens when it happens.
+
+Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
+Reviewed-by: Bharath SM <bharathsm@microsoft.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/smb2ops.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
+index a8f33e8261344..b725bd3144fb7 100644
+--- a/fs/cifs/smb2ops.c
++++ b/fs/cifs/smb2ops.c
+@@ -85,6 +85,7 @@ smb2_add_credits(struct TCP_Server_Info *server,
+ *val = 65000; /* Don't get near 64K credits, avoid srv bugs */
+ pr_warn_once("server overflowed SMB3 credits\n");
+ }
++ WARN_ON_ONCE(server->in_flight == 0);
+ server->in_flight--;
+ if (server->in_flight == 0 &&
+ ((optype & CIFS_OP_MASK) != CIFS_NEG_OP) &&
+--
+2.43.0
+
--- /dev/null
+From fdb417ca74c7d56ce0820b65cfbb121a361c60df Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 Aug 2022 16:08:34 -0300
+Subject: cifs: remove useless parameter 'is_fsctl' from SMB2_ioctl()
+
+From: Enzo Matsumiya <ematsumiya@suse.de>
+
+[ Upstream commit 400d0ad63b190895e29f43bc75b1260111d3fd34 ]
+
+SMB2_ioctl() is always called with is_fsctl = true, so doesn't make any
+sense to have it at all.
+
+Thus, always set SMB2_0_IOCTL_IS_FSCTL flag on the request.
+
+Also, as per MS-SMB2 3.3.5.15 "Receiving an SMB2 IOCTL Request", servers
+must fail the request if the request flags is zero anyway.
+
+Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
+Reviewed-by: Tom Talpey <tom@talpey.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/smb2file.c | 1 -
+ fs/cifs/smb2ops.c | 35 +++++++++++++----------------------
+ fs/cifs/smb2pdu.c | 20 +++++++++-----------
+ fs/cifs/smb2proto.h | 4 ++--
+ 4 files changed, 24 insertions(+), 36 deletions(-)
+
+diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
+index f5dcc4940b6da..9dfd2dd612c25 100644
+--- a/fs/cifs/smb2file.c
++++ b/fs/cifs/smb2file.c
+@@ -61,7 +61,6 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
+ nr_ioctl_req.Reserved = 0;
+ rc = SMB2_ioctl(xid, oparms->tcon, fid->persistent_fid,
+ fid->volatile_fid, FSCTL_LMR_REQUEST_RESILIENCY,
+- true /* is_fsctl */,
+ (char *)&nr_ioctl_req, sizeof(nr_ioctl_req),
+ CIFSMaxBufSize, NULL, NULL /* no return info */);
+ if (rc == -EOPNOTSUPP) {
+diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
+index 6f09e889e74d7..a8f33e8261344 100644
+--- a/fs/cifs/smb2ops.c
++++ b/fs/cifs/smb2ops.c
+@@ -647,7 +647,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
+ struct cifs_ses *ses = tcon->ses;
+
+ rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
+- FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */,
++ FSCTL_QUERY_NETWORK_INTERFACE_INFO,
+ NULL /* no data input */, 0 /* no data input */,
+ CIFSMaxBufSize, (char **)&out_buf, &ret_data_len);
+ if (rc == -EOPNOTSUPP) {
+@@ -1582,9 +1582,8 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
+ struct resume_key_req *res_key;
+
+ rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
+- FSCTL_SRV_REQUEST_RESUME_KEY, true /* is_fsctl */,
+- NULL, 0 /* no input */, CIFSMaxBufSize,
+- (char **)&res_key, &ret_data_len);
++ FSCTL_SRV_REQUEST_RESUME_KEY, NULL, 0 /* no input */,
++ CIFSMaxBufSize, (char **)&res_key, &ret_data_len);
+
+ if (rc == -EOPNOTSUPP) {
+ pr_warn_once("Server share %s does not support copy range\n", tcon->treeName);
+@@ -1726,7 +1725,7 @@ smb2_ioctl_query_info(const unsigned int xid,
+ rqst[1].rq_nvec = SMB2_IOCTL_IOV_SIZE;
+
+ rc = SMB2_ioctl_init(tcon, server, &rqst[1], COMPOUND_FID, COMPOUND_FID,
+- qi.info_type, true, buffer, qi.output_buffer_length,
++ qi.info_type, buffer, qi.output_buffer_length,
+ CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE -
+ MAX_SMB2_CLOSE_RESPONSE_SIZE);
+ free_req1_func = SMB2_ioctl_free;
+@@ -1902,9 +1901,8 @@ smb2_copychunk_range(const unsigned int xid,
+ retbuf = NULL;
+ rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
+ trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
+- true /* is_fsctl */, (char *)pcchunk,
+- sizeof(struct copychunk_ioctl), CIFSMaxBufSize,
+- (char **)&retbuf, &ret_data_len);
++ (char *)pcchunk, sizeof(struct copychunk_ioctl),
++ CIFSMaxBufSize, (char **)&retbuf, &ret_data_len);
+ if (rc == 0) {
+ if (ret_data_len !=
+ sizeof(struct copychunk_ioctl_rsp)) {
+@@ -2064,7 +2062,6 @@ static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,
+
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid, FSCTL_SET_SPARSE,
+- true /* is_fctl */,
+ &setsparse, 1, CIFSMaxBufSize, NULL, NULL);
+ if (rc) {
+ tcon->broken_sparse_sup = true;
+@@ -2147,7 +2144,6 @@ smb2_duplicate_extents(const unsigned int xid,
+ rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
+ trgtfile->fid.volatile_fid,
+ FSCTL_DUPLICATE_EXTENTS_TO_FILE,
+- true /* is_fsctl */,
+ (char *)&dup_ext_buf,
+ sizeof(struct duplicate_extents_to_file),
+ CIFSMaxBufSize, NULL,
+@@ -2182,7 +2178,6 @@ smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon,
+ return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid,
+ FSCTL_SET_INTEGRITY_INFORMATION,
+- true /* is_fsctl */,
+ (char *)&integr_info,
+ sizeof(struct fsctl_set_integrity_information_req),
+ CIFSMaxBufSize, NULL,
+@@ -2235,7 +2230,6 @@ smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon,
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid,
+ FSCTL_SRV_ENUMERATE_SNAPSHOTS,
+- true /* is_fsctl */,
+ NULL, 0 /* no input data */, max_response_size,
+ (char **)&retbuf,
+ &ret_data_len);
+@@ -2920,7 +2914,6 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
+ do {
+ rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
+ FSCTL_DFS_GET_REFERRALS,
+- true /* is_fsctl */,
+ (char *)dfs_req, dfs_req_size, CIFSMaxBufSize,
+ (char **)&dfs_rsp, &dfs_rsp_size);
+ if (!is_retryable_error(rc))
+@@ -3129,8 +3122,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
+
+ rc = SMB2_ioctl_init(tcon, server,
+ &rqst[1], fid.persistent_fid,
+- fid.volatile_fid, FSCTL_GET_REPARSE_POINT,
+- true /* is_fctl */, NULL, 0,
++ fid.volatile_fid, FSCTL_GET_REPARSE_POINT, NULL, 0,
+ CIFSMaxBufSize -
+ MAX_SMB2_CREATE_RESPONSE_SIZE -
+ MAX_SMB2_CLOSE_RESPONSE_SIZE);
+@@ -3310,8 +3302,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,
+
+ rc = SMB2_ioctl_init(tcon, server,
+ &rqst[1], COMPOUND_FID,
+- COMPOUND_FID, FSCTL_GET_REPARSE_POINT,
+- true /* is_fctl */, NULL, 0,
++ COMPOUND_FID, FSCTL_GET_REPARSE_POINT, NULL, 0,
+ CIFSMaxBufSize -
+ MAX_SMB2_CREATE_RESPONSE_SIZE -
+ MAX_SMB2_CLOSE_RESPONSE_SIZE);
+@@ -3587,7 +3578,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
+ fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
+
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+- cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, true,
++ cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
+ (char *)&fsctl_buf,
+ sizeof(struct file_zero_data_information),
+ 0, NULL, NULL);
+@@ -3648,7 +3639,7 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
+
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
+- true /* is_fctl */, (char *)&fsctl_buf,
++ (char *)&fsctl_buf,
+ sizeof(struct file_zero_data_information),
+ CIFSMaxBufSize, NULL, NULL);
+ filemap_invalidate_unlock(inode->i_mapping);
+@@ -3710,7 +3701,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
+ in_data.length = cpu_to_le64(len);
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid,
+- FSCTL_QUERY_ALLOCATED_RANGES, true,
++ FSCTL_QUERY_ALLOCATED_RANGES,
+ (char *)&in_data, sizeof(in_data),
+ 1024 * sizeof(struct file_allocated_range_buffer),
+ (char **)&out_data, &out_data_len);
+@@ -4022,7 +4013,7 @@ static loff_t smb3_llseek(struct file *file, struct cifs_tcon *tcon, loff_t offs
+
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid,
+- FSCTL_QUERY_ALLOCATED_RANGES, true,
++ FSCTL_QUERY_ALLOCATED_RANGES,
+ (char *)&in_data, sizeof(in_data),
+ sizeof(struct file_allocated_range_buffer),
+ (char **)&out_data, &out_data_len);
+@@ -4082,7 +4073,7 @@ static int smb3_fiemap(struct cifs_tcon *tcon,
+
+ rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
+ cfile->fid.volatile_fid,
+- FSCTL_QUERY_ALLOCATED_RANGES, true,
++ FSCTL_QUERY_ALLOCATED_RANGES,
+ (char *)&in_data, sizeof(in_data),
+ 1024 * sizeof(struct file_allocated_range_buffer),
+ (char **)&out_data, &out_data_len);
+diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
+index b2b35edd6a310..61b18f802048f 100644
+--- a/fs/cifs/smb2pdu.c
++++ b/fs/cifs/smb2pdu.c
+@@ -1152,7 +1152,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
+ }
+
+ rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
+- FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */,
++ FSCTL_VALIDATE_NEGOTIATE_INFO,
+ (char *)pneg_inbuf, inbuflen, CIFSMaxBufSize,
+ (char **)&pneg_rsp, &rsplen);
+ if (rc == -EOPNOTSUPP) {
+@@ -3013,7 +3013,7 @@ int
+ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+ struct smb_rqst *rqst,
+ u64 persistent_fid, u64 volatile_fid, u32 opcode,
+- bool is_fsctl, char *in_data, u32 indatalen,
++ char *in_data, u32 indatalen,
+ __u32 max_response_size)
+ {
+ struct smb2_ioctl_req *req;
+@@ -3088,10 +3088,8 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+ req->sync_hdr.CreditCharge =
+ cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size),
+ SMB2_MAX_BUFFER_SIZE));
+- if (is_fsctl)
+- req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL);
+- else
+- req->Flags = 0;
++ /* always an FSCTL (for now) */
++ req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL);
+
+ /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */
+ if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO)
+@@ -3118,9 +3116,9 @@ SMB2_ioctl_free(struct smb_rqst *rqst)
+ */
+ int
+ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
+- u64 volatile_fid, u32 opcode, bool is_fsctl,
+- char *in_data, u32 indatalen, u32 max_out_data_len,
+- char **out_data, u32 *plen /* returned data len */)
++ u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen,
++ u32 max_out_data_len, char **out_data,
++ u32 *plen /* returned data len */)
+ {
+ struct smb_rqst rqst;
+ struct smb2_ioctl_rsp *rsp = NULL;
+@@ -3162,7 +3160,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
+
+ rc = SMB2_ioctl_init(tcon, server,
+ &rqst, persistent_fid, volatile_fid, opcode,
+- is_fsctl, in_data, indatalen, max_out_data_len);
++ in_data, indatalen, max_out_data_len);
+ if (rc)
+ goto ioctl_exit;
+
+@@ -3244,7 +3242,7 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
+ cpu_to_le16(COMPRESSION_FORMAT_DEFAULT);
+
+ rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
+- FSCTL_SET_COMPRESSION, true /* is_fsctl */,
++ FSCTL_SET_COMPRESSION,
+ (char *)&fsctl_input /* data input */,
+ 2 /* in data len */, CIFSMaxBufSize /* max out data */,
+ &ret_data /* out data */, NULL);
+diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
+index 6c5a4d44b248a..ada1d7338f34f 100644
+--- a/fs/cifs/smb2proto.h
++++ b/fs/cifs/smb2proto.h
+@@ -144,13 +144,13 @@ extern int SMB2_open_init(struct cifs_tcon *tcon,
+ extern void SMB2_open_free(struct smb_rqst *rqst);
+ extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
+ u64 persistent_fid, u64 volatile_fid, u32 opcode,
+- bool is_fsctl, char *in_data, u32 indatalen, u32 maxoutlen,
++ char *in_data, u32 indatalen, u32 maxoutlen,
+ char **out_data, u32 *plen /* returned data len */);
+ extern int SMB2_ioctl_init(struct cifs_tcon *tcon,
+ struct TCP_Server_Info *server,
+ struct smb_rqst *rqst,
+ u64 persistent_fid, u64 volatile_fid, u32 opcode,
+- bool is_fsctl, char *in_data, u32 indatalen,
++ char *in_data, u32 indatalen,
+ __u32 max_response_size);
+ extern void SMB2_ioctl_free(struct smb_rqst *rqst);
+ extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
+--
+2.43.0
+
--- /dev/null
+From 0b2e3ce432bc6dd1ea0f08bc1f939452a3e29623 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 17:23:30 +0800
+Subject: clk: Honor CLK_OPS_PARENT_ENABLE in clk_core_is_enabled()
+
+From: Chen-Yu Tsai <wenst@chromium.org>
+
+[ Upstream commit 79200d5851c8e7179f68a4a6f162d8f1bde4986f ]
+
+In the previous commits that added CLK_OPS_PARENT_ENABLE, support for
+this flag was only added to rate change operations (rate setting and
+reparent) and disabling unused subtree. It was not added to the
+clock gate related operations. Any hardware driver that needs it for
+these operations will either see bogus results, or worse, hang.
+
+This has been seen on MT8192 and MT8195, where the imp_ii2_* clk
+drivers set this, but dumping debugfs clk_summary would cause it
+to hang.
+
+Prepare parent on prepare and enable parent on enable dependencies are
+already handled automatically by the core as part of its sequencing.
+Whether the case for "enable parent on prepare" should be supported by
+this flag or not is not clear, and thus ignored for now.
+
+This change solely fixes the handling of clk_core_is_enabled, i.e.
+enabling the parent clock when reading the hardware state. Unfortunately
+clk_core_is_enabled is called in a variety of places, sometimes with
+the enable clock already held. To avoid deadlocking, the core will
+ignore readouts and just return false if CLK_OPS_PARENT_ENABLE is set
+but the parent isn't currently enabled.
+
+Fixes: fc8726a2c021 ("clk: core: support clocks which requires parents enable (part 2)")
+Fixes: a4b3518d146f ("clk: core: support clocks which requires parents enable (part 1)")
+Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
+Link: https://lore.kernel.org/r/20230103092330.494102-1-wenst@chromium.org
+Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Signed-off-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/clk.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
+index b37af6b27e9c6..bf9057a8fbf06 100644
+--- a/drivers/clk/clk.c
++++ b/drivers/clk/clk.c
+@@ -251,6 +251,17 @@ static bool clk_core_is_enabled(struct clk_core *core)
+ }
+ }
+
++ /*
++ * This could be called with the enable lock held, or from atomic
++ * context. If the parent isn't enabled already, we can't do
++ * anything here. We can also assume this clock isn't enabled.
++ */
++ if ((core->flags & CLK_OPS_PARENT_ENABLE) && core->parent)
++ if (!clk_core_is_enabled(core->parent)) {
++ ret = false;
++ goto done;
++ }
++
+ ret = core->ops->is_enabled(core->hw);
+ done:
+ if (core->rpm_enabled)
+--
+2.43.0
+
--- /dev/null
+From bffc8d3a43222b3e798d5c141af5e077436f54f8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 4 Jan 2023 19:00:29 +0800
+Subject: clk: imx: avoid memory leak
+
+From: Peng Fan <peng.fan@nxp.com>
+
+[ Upstream commit f4419db4086e8c31821da14140e81498516a3c75 ]
+
+In case imx_register_uart_clocks return early, the imx_uart_clocks
+memory will be no freed. So execute kfree always to avoid memory leak.
+
+Fixes: 379c9a24cc23 ("clk: imx: Fix reparenting of UARTs not associated with stdout")
+Signed-off-by: Peng Fan <peng.fan@nxp.com>
+Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
+Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
+Link: https://lore.kernel.org/r/20230104110032.1220721-2-peng.fan@oss.nxp.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/imx/clk.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
+index 7cc669934253a..d4cf0c7045ab2 100644
+--- a/drivers/clk/imx/clk.c
++++ b/drivers/clk/imx/clk.c
+@@ -201,9 +201,10 @@ static int __init imx_clk_disable_uart(void)
+ clk_disable_unprepare(imx_uart_clocks[i]);
+ clk_put(imx_uart_clocks[i]);
+ }
+- kfree(imx_uart_clocks);
+ }
+
++ kfree(imx_uart_clocks);
++
+ return 0;
+ }
+ late_initcall_sync(imx_clk_disable_uart);
+--
+2.43.0
+
--- /dev/null
+From b499fce0dd9f41db846bd0a6819b6b227735ace4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 30 Sep 2022 22:54:22 +0800
+Subject: clk: imx: imx8mp: add shared clk gate for usb suspend clk
+
+From: Li Jun <jun.li@nxp.com>
+
+[ Upstream commit ed1f4ccfe947a3e1018a3bd7325134574c7ff9b3 ]
+
+32K usb suspend clock gate is shared with usb_root_clk, this
+shared clock gate was initially defined only for usb suspend
+clock, usb suspend clk is kept on while system is active or
+system sleep with usb wakeup enabled, so usb root clock is
+fine with this situation; with the commit cf7f3f4fa9e5
+("clk: imx8mp: fix usb_root_clk parent"), this clock gate is
+changed to be for usb root clock, but usb root clock will
+be off while usb is suspended, so usb suspend clock will be
+gated too, this cause some usb functionalities will not work,
+so define this clock to be a shared clock gate to conform with
+the real HW status.
+
+Fixes: 9c140d9926761 ("clk: imx: Add support for i.MX8MP clock driver")
+Cc: stable@vger.kernel.org # v5.19+
+Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Signed-off-by: Li Jun <jun.li@nxp.com>
+Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
+Link: https://lore.kernel.org/r/1664549663-20364-2-git-send-email-jun.li@nxp.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/imx/clk-imx8mp.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
+index 2f898c0bc867c..aeb611eaabd3b 100644
+--- a/drivers/clk/imx/clk-imx8mp.c
++++ b/drivers/clk/imx/clk-imx8mp.c
+@@ -17,6 +17,7 @@
+
+ static u32 share_count_nand;
+ static u32 share_count_media;
++static u32 share_count_usb;
+
+ static const char * const pll_ref_sels[] = { "osc_24m", "dummy", "dummy", "dummy", };
+ static const char * const audio_pll1_bypass_sels[] = {"audio_pll1", "audio_pll1_ref_sel", };
+@@ -667,7 +668,8 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
+ hws[IMX8MP_CLK_UART2_ROOT] = imx_clk_hw_gate4("uart2_root_clk", "uart2", ccm_base + 0x44a0, 0);
+ hws[IMX8MP_CLK_UART3_ROOT] = imx_clk_hw_gate4("uart3_root_clk", "uart3", ccm_base + 0x44b0, 0);
+ hws[IMX8MP_CLK_UART4_ROOT] = imx_clk_hw_gate4("uart4_root_clk", "uart4", ccm_base + 0x44c0, 0);
+- hws[IMX8MP_CLK_USB_ROOT] = imx_clk_hw_gate4("usb_root_clk", "hsio_axi", ccm_base + 0x44d0, 0);
++ hws[IMX8MP_CLK_USB_ROOT] = imx_clk_hw_gate2_shared2("usb_root_clk", "hsio_axi", ccm_base + 0x44d0, 0, &share_count_usb);
++ hws[IMX8MP_CLK_USB_SUSP] = imx_clk_hw_gate2_shared2("usb_suspend_clk", "osc_32k", ccm_base + 0x44d0, 0, &share_count_usb);
+ hws[IMX8MP_CLK_USB_PHY_ROOT] = imx_clk_hw_gate4("usb_phy_root_clk", "usb_phy_ref", ccm_base + 0x44f0, 0);
+ hws[IMX8MP_CLK_USDHC1_ROOT] = imx_clk_hw_gate4("usdhc1_root_clk", "usdhc1", ccm_base + 0x4510, 0);
+ hws[IMX8MP_CLK_USDHC2_ROOT] = imx_clk_hw_gate4("usdhc2_root_clk", "usdhc2", ccm_base + 0x4520, 0);
+--
+2.43.0
+
--- /dev/null
+From 8723cc765d8ce4f40aedc294406d2a0ff59d2ccb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 27 Apr 2022 18:21:31 +0200
+Subject: clk: imx8mp: add clkout1/2 support
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+[ Upstream commit 43896f56b59eeaf08687fa976257ae7083d01b41 ]
+
+clkout1 and clkout2 allow to supply clocks from the SoC to the board,
+which is used by some board designs to provide reference clocks.
+
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Reviewed-by: Abel Vesa <abel.vesa@nxp.com>
+Link: https://lore.kernel.org/r/20220427162131.3127303-1-l.stach@pengutronix.de
+Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
+Stable-dep-of: 5c1f7f109094 ("dt-bindings: clocks: imx8mp: Add ID for usb suspend clock")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/imx/clk-imx8mp.c | 14 ++++++++++++++
+ include/dt-bindings/clock/imx8mp-clock.h | 9 +++++++--
+ 2 files changed, 21 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
+index b1c83f9809123..cdeacdc143b5c 100644
+--- a/drivers/clk/imx/clk-imx8mp.c
++++ b/drivers/clk/imx/clk-imx8mp.c
+@@ -396,6 +396,11 @@ static const char * const imx8mp_sai7_sels[] = {"osc_24m", "audio_pll1_out", "au
+
+ static const char * const imx8mp_dram_core_sels[] = {"dram_pll_out", "dram_alt_root", };
+
++static const char * const imx8mp_clkout_sels[] = {"audio_pll1_out", "audio_pll2_out", "video_pll1_out",
++ "dummy", "dummy", "gpu_pll_out", "vpu_pll_out",
++ "arm_pll_out", "sys_pll1", "sys_pll2", "sys_pll3",
++ "dummy", "dummy", "osc_24m", "dummy", "osc_32k"};
++
+ static struct clk_hw **hws;
+ static struct clk_hw_onecell_data *clk_hw_data;
+
+@@ -514,6 +519,15 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
+ hws[IMX8MP_SYS_PLL2_500M] = imx_clk_hw_fixed_factor("sys_pll2_500m", "sys_pll2_500m_cg", 1, 2);
+ hws[IMX8MP_SYS_PLL2_1000M] = imx_clk_hw_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1);
+
++ hws[IMX8MP_CLK_CLKOUT1_SEL] = imx_clk_hw_mux2("clkout1_sel", anatop_base + 0x128, 4, 4,
++ imx8mp_clkout_sels, ARRAY_SIZE(imx8mp_clkout_sels));
++ hws[IMX8MP_CLK_CLKOUT1_DIV] = imx_clk_hw_divider("clkout1_div", "clkout1_sel", anatop_base + 0x128, 0, 4);
++ hws[IMX8MP_CLK_CLKOUT1] = imx_clk_hw_gate("clkout1", "clkout1_div", anatop_base + 0x128, 8);
++ hws[IMX8MP_CLK_CLKOUT2_SEL] = imx_clk_hw_mux2("clkout2_sel", anatop_base + 0x128, 20, 4,
++ imx8mp_clkout_sels, ARRAY_SIZE(imx8mp_clkout_sels));
++ hws[IMX8MP_CLK_CLKOUT2_DIV] = imx_clk_hw_divider("clkout2_div", "clkout2_sel", anatop_base + 0x128, 16, 4);
++ hws[IMX8MP_CLK_CLKOUT2] = imx_clk_hw_gate("clkout2", "clkout2_div", anatop_base + 0x128, 24);
++
+ hws[IMX8MP_CLK_A53_DIV] = imx8m_clk_hw_composite_core("arm_a53_div", imx8mp_a53_sels, ccm_base + 0x8000);
+ hws[IMX8MP_CLK_A53_SRC] = hws[IMX8MP_CLK_A53_DIV];
+ hws[IMX8MP_CLK_A53_CG] = hws[IMX8MP_CLK_A53_DIV];
+diff --git a/include/dt-bindings/clock/imx8mp-clock.h b/include/dt-bindings/clock/imx8mp-clock.h
+index 4fff3e57f460b..a02fd723168cc 100644
+--- a/include/dt-bindings/clock/imx8mp-clock.h
++++ b/include/dt-bindings/clock/imx8mp-clock.h
+@@ -318,10 +318,15 @@
+ #define IMX8MP_CLK_AUDIO_AXI 310
+ #define IMX8MP_CLK_HSIO_AXI 311
+ #define IMX8MP_CLK_MEDIA_ISP 312
+-
+ #define IMX8MP_CLK_MEDIA_DISP2_PIX 313
++#define IMX8MP_CLK_CLKOUT1_SEL 314
++#define IMX8MP_CLK_CLKOUT1_DIV 315
++#define IMX8MP_CLK_CLKOUT1 316
++#define IMX8MP_CLK_CLKOUT2_SEL 317
++#define IMX8MP_CLK_CLKOUT2_DIV 318
++#define IMX8MP_CLK_CLKOUT2 319
+
+-#define IMX8MP_CLK_END 314
++#define IMX8MP_CLK_END 320
+
+ #define IMX8MP_CLK_AUDIOMIX_SAI1_IPG 0
+ #define IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1 1
+--
+2.43.0
+
--- /dev/null
+From 886574b585823c11d39ee8c8059508eaeb9419ee Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 13 Mar 2022 13:39:49 +0100
+Subject: clk: imx8mp: Add DISP2 pixel clock
+
+From: Marek Vasut <marex@denx.de>
+
+[ Upstream commit 39772efd98adecbd5b8c6096d465d2fcbafbde6a ]
+
+Add pixel clock for second LCDIFv3 interface. Both LCDIFv3 interfaces use
+the same set of parent clock, so deduplicate imx8mp_media_disp1_pix_sels
+into common imx8mp_media_disp_pix_sels and use it for both.
+
+Signed-off-by: Marek Vasut <marex@denx.de>
+Cc: Abel Vesa <abel.vesa@nxp.com>
+Cc: Fabio Estevam <festevam@gmail.com>
+Cc: NXP Linux Team <linux-imx@nxp.com>
+Cc: Peng Fan <peng.fan@nxp.com>
+Cc: Shawn Guo <shawnguo@kernel.org>
+Reviewed-by: Abel Vesa <abel.vesa@nxp.com>
+Link: https://lore.kernel.org/r/20220313123949.207284-1-marex@denx.de
+Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
+Stable-dep-of: 5c1f7f109094 ("dt-bindings: clocks: imx8mp: Add ID for usb suspend clock")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/imx/clk-imx8mp.c | 5 +++--
+ include/dt-bindings/clock/imx8mp-clock.h | 4 +++-
+ 2 files changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
+index aeb611eaabd3b..b1c83f9809123 100644
+--- a/drivers/clk/imx/clk-imx8mp.c
++++ b/drivers/clk/imx/clk-imx8mp.c
+@@ -355,7 +355,7 @@ static const char * const imx8mp_media_mipi_phy1_ref_sels[] = {"osc_24m", "sys_p
+ "clk_ext2", "audio_pll2_out",
+ "video_pll1_out", };
+
+-static const char * const imx8mp_media_disp1_pix_sels[] = {"osc_24m", "video_pll1_out", "audio_pll2_out",
++static const char * const imx8mp_media_disp_pix_sels[] = {"osc_24m", "video_pll1_out", "audio_pll2_out",
+ "audio_pll1_out", "sys_pll1_800m",
+ "sys_pll2_1000m", "sys_pll3_out", "clk_ext4", };
+
+@@ -548,6 +548,7 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
+ hws[IMX8MP_CLK_AHB] = imx8m_clk_hw_composite_bus_critical("ahb_root", imx8mp_ahb_sels, ccm_base + 0x9000);
+ hws[IMX8MP_CLK_AUDIO_AHB] = imx8m_clk_hw_composite_bus("audio_ahb", imx8mp_audio_ahb_sels, ccm_base + 0x9100);
+ hws[IMX8MP_CLK_MIPI_DSI_ESC_RX] = imx8m_clk_hw_composite_bus("mipi_dsi_esc_rx", imx8mp_mipi_dsi_esc_rx_sels, ccm_base + 0x9200);
++ hws[IMX8MP_CLK_MEDIA_DISP2_PIX] = imx8m_clk_hw_composite("media_disp2_pix", imx8mp_media_disp_pix_sels, ccm_base + 0x9300);
+
+ hws[IMX8MP_CLK_IPG_ROOT] = imx_clk_hw_divider2("ipg_root", "ahb_root", ccm_base + 0x9080, 0, 1);
+
+@@ -609,7 +610,7 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
+ hws[IMX8MP_CLK_USDHC3] = imx8m_clk_hw_composite("usdhc3", imx8mp_usdhc3_sels, ccm_base + 0xbc80);
+ hws[IMX8MP_CLK_MEDIA_CAM1_PIX] = imx8m_clk_hw_composite("media_cam1_pix", imx8mp_media_cam1_pix_sels, ccm_base + 0xbd00);
+ hws[IMX8MP_CLK_MEDIA_MIPI_PHY1_REF] = imx8m_clk_hw_composite("media_mipi_phy1_ref", imx8mp_media_mipi_phy1_ref_sels, ccm_base + 0xbd80);
+- hws[IMX8MP_CLK_MEDIA_DISP1_PIX] = imx8m_clk_hw_composite("media_disp1_pix", imx8mp_media_disp1_pix_sels, ccm_base + 0xbe00);
++ hws[IMX8MP_CLK_MEDIA_DISP1_PIX] = imx8m_clk_hw_composite("media_disp1_pix", imx8mp_media_disp_pix_sels, ccm_base + 0xbe00);
+ hws[IMX8MP_CLK_MEDIA_CAM2_PIX] = imx8m_clk_hw_composite("media_cam2_pix", imx8mp_media_cam2_pix_sels, ccm_base + 0xbe80);
+ hws[IMX8MP_CLK_MEDIA_LDB] = imx8m_clk_hw_composite("media_ldb", imx8mp_media_ldb_sels, ccm_base + 0xbf00);
+ hws[IMX8MP_CLK_MEMREPAIR] = imx8m_clk_hw_composite_critical("mem_repair", imx8mp_memrepair_sels, ccm_base + 0xbf80);
+diff --git a/include/dt-bindings/clock/imx8mp-clock.h b/include/dt-bindings/clock/imx8mp-clock.h
+index 43927a1b9e940..4fff3e57f460b 100644
+--- a/include/dt-bindings/clock/imx8mp-clock.h
++++ b/include/dt-bindings/clock/imx8mp-clock.h
+@@ -319,7 +319,9 @@
+ #define IMX8MP_CLK_HSIO_AXI 311
+ #define IMX8MP_CLK_MEDIA_ISP 312
+
+-#define IMX8MP_CLK_END 313
++#define IMX8MP_CLK_MEDIA_DISP2_PIX 313
++
++#define IMX8MP_CLK_END 314
+
+ #define IMX8MP_CLK_AUDIOMIX_SAI1_IPG 0
+ #define IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1 1
+--
+2.43.0
+
--- /dev/null
+From ec3ca5a2370824f434aa4c877f7bba1624865734 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 30 Sep 2023 15:14:26 -0700
+Subject: clk: linux/clk-provider.h: fix kernel-doc warnings and typos
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+[ Upstream commit 84aefafe6b294041b7fa0757414c4a29c1bdeea2 ]
+
+Fix spelling of "Structure".
+
+Fix multiple kernel-doc warnings:
+
+clk-provider.h:269: warning: Function parameter or member 'recalc_rate' not described in 'clk_ops'
+clk-provider.h:468: warning: Function parameter or member 'parent_data' not described in 'clk_hw_register_fixed_rate_with_accuracy_parent_data'
+clk-provider.h:468: warning: Excess function parameter 'parent_name' description in 'clk_hw_register_fixed_rate_with_accuracy_parent_data'
+clk-provider.h:482: warning: Function parameter or member 'parent_data' not described in 'clk_hw_register_fixed_rate_parent_accuracy'
+clk-provider.h:482: warning: Excess function parameter 'parent_name' description in 'clk_hw_register_fixed_rate_parent_accuracy'
+clk-provider.h:687: warning: Function parameter or member 'flags' not described in 'clk_divider'
+clk-provider.h:1164: warning: Function parameter or member 'flags' not described in 'clk_fractional_divider'
+clk-provider.h:1164: warning: Function parameter or member 'approximation' not described in 'clk_fractional_divider'
+clk-provider.h:1213: warning: Function parameter or member 'flags' not described in 'clk_multiplier'
+
+Fixes: 9fba738a53dd ("clk: add duty cycle support")
+Fixes: b2476490ef11 ("clk: introduce the common clock framework")
+Fixes: 2d34f09e79c9 ("clk: fixed-rate: Add support for specifying parents via DT/pointers")
+Fixes: f5290d8e4f0c ("clk: asm9260: use parent index to link the reference clock")
+Fixes: 9d9f78ed9af0 ("clk: basic clock hardware types")
+Fixes: e2d0e90fae82 ("clk: new basic clk type for fractional divider")
+Fixes: f2e0a53271a4 ("clk: Add a basic multiplier clock")
+
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Cc: Michael Turquette <mturquette@baylibre.com>
+Cc: Stephen Boyd <sboyd@kernel.org>
+Cc: linux-clk@vger.kernel.org
+Link: https://lore.kernel.org/r/20230930221428.18463-1-rdunlap@infradead.org
+Signed-off-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/clk-provider.h | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
+index 6cace09ba63d0..7d5ca15ac66ba 100644
+--- a/include/linux/clk-provider.h
++++ b/include/linux/clk-provider.h
+@@ -61,7 +61,7 @@ struct clk_rate_request {
+ };
+
+ /**
+- * struct clk_duty - Struture encoding the duty cycle ratio of a clock
++ * struct clk_duty - Structure encoding the duty cycle ratio of a clock
+ *
+ * @num: Numerator of the duty cycle ratio
+ * @den: Denominator of the duty cycle ratio
+@@ -116,7 +116,7 @@ struct clk_duty {
+ * @restore_context: Restore the context of the clock after a restoration
+ * of power.
+ *
+- * @recalc_rate Recalculate the rate of this clock, by querying hardware. The
++ * @recalc_rate: Recalculate the rate of this clock, by querying hardware. The
+ * parent rate is an input parameter. It is up to the caller to
+ * ensure that the prepare_mutex is held across this call.
+ * Returns the calculated rate. Optional, but recommended - if
+@@ -442,7 +442,7 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
+ * clock with the clock framework
+ * @dev: device that is registering this clock
+ * @name: name of this clock
+- * @parent_name: name of clock's parent
++ * @parent_data: name of clock's parent
+ * @flags: framework-specific flags
+ * @fixed_rate: non-adjustable clock rate
+ * @fixed_accuracy: non-adjustable clock accuracy
+@@ -457,7 +457,7 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
+ * the clock framework
+ * @dev: device that is registering this clock
+ * @name: name of this clock
+- * @parent_name: name of clock's parent
++ * @parent_data: name of clock's parent
+ * @flags: framework-specific flags
+ * @fixed_rate: non-adjustable clock rate
+ */
+@@ -593,7 +593,7 @@ struct clk_div_table {
+ * Clock with an adjustable divider affecting its output frequency. Implements
+ * .recalc_rate, .set_rate and .round_rate
+ *
+- * Flags:
++ * @flags:
+ * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the
+ * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is
+ * the raw value read from the register, with the value of zero considered
+@@ -1023,11 +1023,12 @@ struct clk_hw *devm_clk_hw_register_fixed_factor(struct device *dev,
+ * @mwidth: width of the numerator bit field
+ * @nshift: shift to the denominator bit field
+ * @nwidth: width of the denominator bit field
++ * @approximation: clk driver's callback for calculating the divider clock
+ * @lock: register lock
+ *
+ * Clock with adjustable fractional divider affecting its output frequency.
+ *
+- * Flags:
++ * @flags:
+ * CLK_FRAC_DIVIDER_ZERO_BASED - by default the numerator and denominator
+ * is the value read from the register. If CLK_FRAC_DIVIDER_ZERO_BASED
+ * is set then the numerator and denominator are both the value read
+@@ -1086,7 +1087,7 @@ void clk_hw_unregister_fractional_divider(struct clk_hw *hw);
+ * Clock with an adjustable multiplier affecting its output frequency.
+ * Implements .recalc_rate, .set_rate and .round_rate
+ *
+- * Flags:
++ * @flags:
+ * CLK_MULTIPLIER_ZERO_BYPASS - By default, the multiplier is the value read
+ * from the register, with 0 being a valid value effectively
+ * zeroing the output clock rate. If CLK_MULTIPLIER_ZERO_BYPASS is
+--
+2.43.0
+
--- /dev/null
+From 12125997ada9c3f8da74a82a56b82e359108f4f8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 26 Dec 2022 06:21:43 +0200
+Subject: clk: qcom: gcc-qcs404: disable gpll[04]_out_aux parents
+
+From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+
+[ Upstream commit 712c64caf31374de57aa193a9dff57172b2f6f82 ]
+
+On the QCS404 platform the driver for the Global Clock Controller
+doens't define gpll0_out_aux and gpll4_out_aux clocks, so it's not
+possible to use them as parents. Remove entries for these clocks.
+
+Note: backporting this patch to earlier kernels would also require a
+previous patch which switches the gcc driver to use ARRAY_SIZE for
+parent data arrays.
+
+Fixes: 652f1813c113 ("clk: qcom: gcc: Add global clock controller driver for QCS404")
+Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+Signed-off-by: Bjorn Andersson <andersson@kernel.org>
+Link: https://lore.kernel.org/r/20221226042154.2666748-6-dmitry.baryshkov@linaro.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/qcom/gcc-qcs404.c | 16 ----------------
+ 1 file changed, 16 deletions(-)
+
+diff --git a/drivers/clk/qcom/gcc-qcs404.c b/drivers/clk/qcom/gcc-qcs404.c
+index 46d314d692505..4299fe8f19274 100644
+--- a/drivers/clk/qcom/gcc-qcs404.c
++++ b/drivers/clk/qcom/gcc-qcs404.c
+@@ -25,11 +25,9 @@ enum {
+ P_CORE_BI_PLL_TEST_SE,
+ P_DSI0_PHY_PLL_OUT_BYTECLK,
+ P_DSI0_PHY_PLL_OUT_DSICLK,
+- P_GPLL0_OUT_AUX,
+ P_GPLL0_OUT_MAIN,
+ P_GPLL1_OUT_MAIN,
+ P_GPLL3_OUT_MAIN,
+- P_GPLL4_OUT_AUX,
+ P_GPLL4_OUT_MAIN,
+ P_GPLL6_OUT_AUX,
+ P_HDMI_PHY_PLL_CLK,
+@@ -109,28 +107,24 @@ static const char * const gcc_parent_names_4[] = {
+ static const struct parent_map gcc_parent_map_5[] = {
+ { P_XO, 0 },
+ { P_DSI0_PHY_PLL_OUT_BYTECLK, 1 },
+- { P_GPLL0_OUT_AUX, 2 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+ static const char * const gcc_parent_names_5[] = {
+ "cxo",
+ "dsi0pll_byteclk_src",
+- "gpll0_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+ static const struct parent_map gcc_parent_map_6[] = {
+ { P_XO, 0 },
+ { P_DSI0_PHY_PLL_OUT_BYTECLK, 2 },
+- { P_GPLL0_OUT_AUX, 3 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+ static const char * const gcc_parent_names_6[] = {
+ "cxo",
+ "dsi0_phy_pll_out_byteclk",
+- "gpll0_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+@@ -139,7 +133,6 @@ static const struct parent_map gcc_parent_map_7[] = {
+ { P_GPLL0_OUT_MAIN, 1 },
+ { P_GPLL3_OUT_MAIN, 2 },
+ { P_GPLL6_OUT_AUX, 3 },
+- { P_GPLL4_OUT_AUX, 4 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+@@ -148,7 +141,6 @@ static const char * const gcc_parent_names_7[] = {
+ "gpll0_out_main",
+ "gpll3_out_main",
+ "gpll6_out_aux",
+- "gpll4_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+@@ -207,14 +199,12 @@ static const char * const gcc_parent_names_11[] = {
+ static const struct parent_map gcc_parent_map_12[] = {
+ { P_XO, 0 },
+ { P_DSI0_PHY_PLL_OUT_DSICLK, 1 },
+- { P_GPLL0_OUT_AUX, 2 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+ static const char * const gcc_parent_names_12[] = {
+ "cxo",
+ "dsi0pll_pclk_src",
+- "gpll0_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+@@ -237,40 +227,34 @@ static const char * const gcc_parent_names_13[] = {
+ static const struct parent_map gcc_parent_map_14[] = {
+ { P_XO, 0 },
+ { P_GPLL0_OUT_MAIN, 1 },
+- { P_GPLL4_OUT_AUX, 2 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+ static const char * const gcc_parent_names_14[] = {
+ "cxo",
+ "gpll0_out_main",
+- "gpll4_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+ static const struct parent_map gcc_parent_map_15[] = {
+ { P_XO, 0 },
+- { P_GPLL0_OUT_AUX, 2 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+ static const char * const gcc_parent_names_15[] = {
+ "cxo",
+- "gpll0_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+ static const struct parent_map gcc_parent_map_16[] = {
+ { P_XO, 0 },
+ { P_GPLL0_OUT_MAIN, 1 },
+- { P_GPLL0_OUT_AUX, 2 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+ };
+
+ static const char * const gcc_parent_names_16[] = {
+ "cxo",
+ "gpll0_out_main",
+- "gpll0_out_aux",
+ "core_bi_pll_test_se",
+ };
+
+--
+2.43.0
+
--- /dev/null
+From 6c62cc33f733d53d92a33ec89c5b103a11e1fbc2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 26 Dec 2022 06:21:44 +0200
+Subject: clk: qcom: gcc-qcs404: fix names of the DSI clocks used as parents
+
+From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+
+[ Upstream commit 47d94d30cd3dcc743241b4208b1eec7247610c84 ]
+
+The QCS404 uses 28nm LPM DSI PHY, which registers dsi0pll and
+dsi0pllbyte clocks. Fix all DSI PHY clock names used as parents inside
+the GCC driver.
+
+Fixes: 652f1813c113 ("clk: qcom: gcc: Add global clock controller driver for QCS404")
+Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
+Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+Signed-off-by: Bjorn Andersson <andersson@kernel.org>
+Link: https://lore.kernel.org/r/20221226042154.2666748-7-dmitry.baryshkov@linaro.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/qcom/gcc-qcs404.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/clk/qcom/gcc-qcs404.c b/drivers/clk/qcom/gcc-qcs404.c
+index 4299fe8f19274..a7a9884799cd3 100644
+--- a/drivers/clk/qcom/gcc-qcs404.c
++++ b/drivers/clk/qcom/gcc-qcs404.c
+@@ -112,7 +112,7 @@ static const struct parent_map gcc_parent_map_5[] = {
+
+ static const char * const gcc_parent_names_5[] = {
+ "cxo",
+- "dsi0pll_byteclk_src",
++ "dsi0pllbyte",
+ "core_bi_pll_test_se",
+ };
+
+@@ -124,7 +124,7 @@ static const struct parent_map gcc_parent_map_6[] = {
+
+ static const char * const gcc_parent_names_6[] = {
+ "cxo",
+- "dsi0_phy_pll_out_byteclk",
++ "dsi0pllbyte",
+ "core_bi_pll_test_se",
+ };
+
+@@ -167,7 +167,7 @@ static const struct parent_map gcc_parent_map_9[] = {
+ static const char * const gcc_parent_names_9[] = {
+ "cxo",
+ "gpll0_out_main",
+- "dsi0_phy_pll_out_dsiclk",
++ "dsi0pll",
+ "gpll6_out_aux",
+ "core_bi_pll_test_se",
+ };
+@@ -204,7 +204,7 @@ static const struct parent_map gcc_parent_map_12[] = {
+
+ static const char * const gcc_parent_names_12[] = {
+ "cxo",
+- "dsi0pll_pclk_src",
++ "dsi0pll",
+ "core_bi_pll_test_se",
+ };
+
+--
+2.43.0
+
--- /dev/null
+From 56c4c76f6bfcd2371123f52e5ae2eafc403fe93d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Feb 2023 19:23:04 +0200
+Subject: clk: qcom: gpucc-sc7180: fix clk_dis_wait being programmed for CX
+ GDSC
+
+From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+
+[ Upstream commit 658c82caffa042b351f5a1b6325819297a951a04 ]
+
+The gdsc_init() function will rewrite the CLK_DIS_WAIT field while
+registering the GDSC (writing the value 0x2 by default). This will
+override the setting done in the driver's probe function.
+
+Set cx_gdsc.clk_dis_wait_val to 8 to follow the intention of the probe
+function.
+
+Fixes: 745ff069a49c ("clk: qcom: Add graphics clock controller driver for SC7180")
+Reviewed-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
+Signed-off-by: Bjorn Andersson <andersson@kernel.org>
+Link: https://lore.kernel.org/r/20230201172305.993146-1-dmitry.baryshkov@linaro.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/qcom/gpucc-sc7180.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/drivers/clk/qcom/gpucc-sc7180.c b/drivers/clk/qcom/gpucc-sc7180.c
+index d738251cba17d..6839b4b71a2f4 100644
+--- a/drivers/clk/qcom/gpucc-sc7180.c
++++ b/drivers/clk/qcom/gpucc-sc7180.c
+@@ -21,8 +21,6 @@
+ #define CX_GMU_CBCR_SLEEP_SHIFT 4
+ #define CX_GMU_CBCR_WAKE_MASK 0xF
+ #define CX_GMU_CBCR_WAKE_SHIFT 8
+-#define CLK_DIS_WAIT_SHIFT 12
+-#define CLK_DIS_WAIT_MASK (0xf << CLK_DIS_WAIT_SHIFT)
+
+ enum {
+ P_BI_TCXO,
+@@ -160,6 +158,7 @@ static struct clk_branch gpu_cc_cxo_clk = {
+ static struct gdsc cx_gdsc = {
+ .gdscr = 0x106c,
+ .gds_hw_ctrl = 0x1540,
++ .clk_dis_wait_val = 8,
+ .pd = {
+ .name = "cx_gdsc",
+ },
+@@ -242,10 +241,6 @@ static int gpu_cc_sc7180_probe(struct platform_device *pdev)
+ value = 0xF << CX_GMU_CBCR_WAKE_SHIFT | 0xF << CX_GMU_CBCR_SLEEP_SHIFT;
+ regmap_update_bits(regmap, 0x1098, mask, value);
+
+- /* Configure clk_dis_wait for gpu_cx_gdsc */
+- regmap_update_bits(regmap, 0x106c, CLK_DIS_WAIT_MASK,
+- 8 << CLK_DIS_WAIT_SHIFT);
+-
+ return qcom_cc_really_probe(pdev, &gpu_cc_sc7180_desc, regmap);
+ }
+
+--
+2.43.0
+
--- /dev/null
+From afc08f9532a87590b0a0fae191aff17b173a5345 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Feb 2023 19:23:05 +0200
+Subject: clk: qcom: gpucc-sdm845: fix clk_dis_wait being programmed for CX
+ GDSC
+
+From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+
+[ Upstream commit cb81719e3c1165ef1bc33137dc628f750eed8ea4 ]
+
+The gdsc_init() function will rewrite the CLK_DIS_WAIT field while
+registering the GDSC (writing the value 0x2 by default). This will
+override the setting done in the driver's probe function.
+
+Set cx_gdsc.clk_dis_wait_val to 8 to follow the intention of the probe
+function.
+
+Fixes: 453361cdd757 ("clk: qcom: Add graphics clock controller driver for SDM845")
+Reviewed-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
+Signed-off-by: Bjorn Andersson <andersson@kernel.org>
+Link: https://lore.kernel.org/r/20230201172305.993146-2-dmitry.baryshkov@linaro.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/qcom/gpucc-sdm845.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/drivers/clk/qcom/gpucc-sdm845.c b/drivers/clk/qcom/gpucc-sdm845.c
+index 110b54401bc6d..970d7414bdf0e 100644
+--- a/drivers/clk/qcom/gpucc-sdm845.c
++++ b/drivers/clk/qcom/gpucc-sdm845.c
+@@ -22,8 +22,6 @@
+ #define CX_GMU_CBCR_SLEEP_SHIFT 4
+ #define CX_GMU_CBCR_WAKE_MASK 0xf
+ #define CX_GMU_CBCR_WAKE_SHIFT 8
+-#define CLK_DIS_WAIT_SHIFT 12
+-#define CLK_DIS_WAIT_MASK (0xf << CLK_DIS_WAIT_SHIFT)
+
+ enum {
+ P_BI_TCXO,
+@@ -121,6 +119,7 @@ static struct clk_branch gpu_cc_cxo_clk = {
+ static struct gdsc gpu_cx_gdsc = {
+ .gdscr = 0x106c,
+ .gds_hw_ctrl = 0x1540,
++ .clk_dis_wait_val = 0x8,
+ .pd = {
+ .name = "gpu_cx_gdsc",
+ },
+@@ -193,10 +192,6 @@ static int gpu_cc_sdm845_probe(struct platform_device *pdev)
+ value = 0xf << CX_GMU_CBCR_WAKE_SHIFT | 0xf << CX_GMU_CBCR_SLEEP_SHIFT;
+ regmap_update_bits(regmap, 0x1098, mask, value);
+
+- /* Configure clk_dis_wait for gpu_cx_gdsc */
+- regmap_update_bits(regmap, 0x106c, CLK_DIS_WAIT_MASK,
+- 8 << CLK_DIS_WAIT_SHIFT);
+-
+ return qcom_cc_really_probe(pdev, &gpu_cc_sdm845_desc, regmap);
+ }
+
+--
+2.43.0
+
--- /dev/null
+From 40b5aec7389fc7d6c026b789e695470090bdf5ea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Dec 2022 17:40:17 +0300
+Subject: clk: renesas: cpg-mssr: Fix use after free if cpg_mssr_common_init()
+ failed
+
+From: Alexey Khoroshilov <khoroshilov@ispras.ru>
+
+[ Upstream commit fbfd614aeaa2853c2c575299dfe2458db8eff67e ]
+
+If cpg_mssr_common_init() fails after assigning priv to global variable
+cpg_mssr_priv, it deallocates priv, but cpg_mssr_priv keeps dangling
+pointer that potentially can be used later.
+
+Found by Linux Verification Center (linuxtesting.org) with SVACE.
+
+Fixes: 1f7db7bbf031 ("clk: renesas: cpg-mssr: Add early clock support")
+Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
+Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Link: https://lore.kernel.org/r/1671806417-32623-1-git-send-email-khoroshilov@ispras.ru
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/renesas/renesas-cpg-mssr.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
+index 21f762aa21313..ed67b90fc1b0c 100644
+--- a/drivers/clk/renesas/renesas-cpg-mssr.c
++++ b/drivers/clk/renesas/renesas-cpg-mssr.c
+@@ -957,7 +957,6 @@ static int __init cpg_mssr_common_init(struct device *dev,
+ goto out_err;
+ }
+
+- cpg_mssr_priv = priv;
+ priv->num_core_clks = info->num_total_core_clks;
+ priv->num_mod_clks = info->num_hw_mod_clks;
+ priv->last_dt_core_clk = info->last_dt_core_clk;
+@@ -987,6 +986,8 @@ static int __init cpg_mssr_common_init(struct device *dev,
+ if (error)
+ goto out_err;
+
++ cpg_mssr_priv = priv;
++
+ return 0;
+
+ out_err:
+--
+2.43.0
+
--- /dev/null
+From faa74c085bbd05d2c19bdb1f7ecc50e698ffb196 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 11 Jan 2023 09:23:34 +0100
+Subject: clk: renesas: cpg-mssr: Remove superfluous check in resume code
+
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+
+[ Upstream commit 1c052043c79af5f70e80e2acd4dd70904ae08666 ]
+
+When the code flow arrives at printing the error message in
+cpg_mssr_resume_noirq(), we know for sure that we are not running on an
+RZ/A Soc, as the code checked for that before.
+
+Fixes: ace342097768e35f ("clk: renesas: cpg-mssr: Fix STBCR suspend/resume handling")
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Link: https://lore.kernel.org/r/144a3e66d748c0c17f3524ac8fa6ece5bf5b6f1e.1673425314.git.geert+renesas@glider.be
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/renesas/renesas-cpg-mssr.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
+index ed67b90fc1b0c..54c5d35fe2ae3 100644
+--- a/drivers/clk/renesas/renesas-cpg-mssr.c
++++ b/drivers/clk/renesas/renesas-cpg-mssr.c
+@@ -911,9 +911,8 @@ static int cpg_mssr_resume_noirq(struct device *dev)
+ }
+
+ if (!i)
+- dev_warn(dev, "Failed to enable %s%u[0x%x]\n",
+- priv->reg_layout == CLK_REG_LAYOUT_RZ_A ?
+- "STB" : "SMSTP", reg, oldval & mask);
++ dev_warn(dev, "Failed to enable SMSTP%u[0x%x]\n", reg,
++ oldval & mask);
+ }
+
+ return 0;
+--
+2.43.0
+
--- /dev/null
+From 441e5a55f0a79cda58bc3ac7cc2dc07a2b664303 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 7 Jun 2023 19:19:02 +0900
+Subject: debugobjects: Recheck debug_objects_enabled before reporting
+
+From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+
+[ Upstream commit 8b64d420fe2450f82848178506d3e3a0bd195539 ]
+
+syzbot is reporting false a positive ODEBUG message immediately after
+ODEBUG was disabled due to OOM.
+
+ [ 1062.309646][T22911] ODEBUG: Out of memory. ODEBUG disabled
+ [ 1062.886755][ T5171] ------------[ cut here ]------------
+ [ 1062.892770][ T5171] ODEBUG: assert_init not available (active state 0) object: ffffc900056afb20 object type: timer_list hint: process_timeout+0x0/0x40
+
+ CPU 0 [ T5171] CPU 1 [T22911]
+ -------------- --------------
+ debug_object_assert_init() {
+ if (!debug_objects_enabled)
+ return;
+ db = get_bucket(addr);
+ lookup_object_or_alloc() {
+ debug_objects_enabled = 0;
+ return NULL;
+ }
+ debug_objects_oom() {
+ pr_warn("Out of memory. ODEBUG disabled\n");
+ // all buckets get emptied here, and
+ }
+ lookup_object_or_alloc(addr, db, descr, false, true) {
+ // this bucket is already empty.
+ return ERR_PTR(-ENOENT);
+ }
+ // Emits false positive warning.
+ debug_print_object(&o, "assert_init");
+ }
+
+Recheck debug_object_enabled in debug_print_object() to avoid that.
+
+Reported-by: syzbot <syzbot+7937ba6a50bdd00fffdf@syzkaller.appspotmail.com>
+Suggested-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Link: https://lore.kernel.org/r/492fe2ae-5141-d548-ebd5-62f5fe2e57f7@I-love.SAKURA.ne.jp
+Closes: https://syzkaller.appspot.com/bug?extid=7937ba6a50bdd00fffdf
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ lib/debugobjects.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/lib/debugobjects.c b/lib/debugobjects.c
+index 09fddc0ea6d39..3972e2123e554 100644
+--- a/lib/debugobjects.c
++++ b/lib/debugobjects.c
+@@ -501,6 +501,15 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
+ const struct debug_obj_descr *descr = obj->descr;
+ static int limit;
+
++ /*
++ * Don't report if lookup_object_or_alloc() by the current thread
++ * failed because lookup_object_or_alloc()/debug_objects_oom() by a
++ * concurrent thread turned off debug_objects_enabled and cleared
++ * the hash buckets.
++ */
++ if (!debug_objects_enabled)
++ return;
++
+ if (limit < 5 && descr != descr_test) {
+ void *hint = descr->debug_hint ?
+ descr->debug_hint(obj->object) : NULL;
+--
+2.43.0
+
--- /dev/null
+From aafe8363ee2e4d9a6336e0cc8e3b17897bfb7500 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 15 Jun 2023 11:54:47 +0200
+Subject: devlink: report devlink_port_type_warn source device
+
+From: Petr Oros <poros@redhat.com>
+
+[ Upstream commit a52305a81d6bb74b90b400dfa56455d37872fe4b ]
+
+devlink_port_type_warn is scheduled for port devlink and warning
+when the port type is not set. But from this warning it is not easy
+found out which device (driver) has no devlink port set.
+
+[ 3709.975552] Type was not set for devlink port.
+[ 3709.975579] WARNING: CPU: 1 PID: 13092 at net/devlink/leftover.c:6775 devlink_port_type_warn+0x11/0x20
+[ 3709.993967] Modules linked in: openvswitch nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nfnetlink bluetooth rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs vhost_net vhost vhost_iotlb tap tun bridge stp llc qrtr intel_rapl_msr intel_rapl_common i10nm_edac nfit libnvdimm x86_pkg_temp_thermal mlx5_ib intel_powerclamp coretemp dell_wmi ledtrig_audio sparse_keymap ipmi_ssif kvm_intel ib_uverbs rfkill ib_core video kvm iTCO_wdt acpi_ipmi intel_vsec irqbypass ipmi_si iTCO_vendor_support dcdbas ipmi_devintf mei_me ipmi_msghandler rapl mei intel_cstate isst_if_mmio isst_if_mbox_pci dell_smbios intel_uncore isst_if_common i2c_i801 dell_wmi_descriptor wmi_bmof i2c_smbus intel_pch_thermal pcspkr acpi_power_meter xfs libcrc32c sd_mod sg nvme_tcp mgag200 i2c_algo_bit nvme_fabrics drm_shmem_helper drm_kms_helper nvme syscopyarea ahci sysfillrect sysimgblt nvme_core fb_sys_fops crct10dif_pclmul libahci mlx5_core sfc crc32_pclmul nvme_common drm
+[ 3709.994030] crc32c_intel mtd t10_pi mlxfw libata tg3 mdio megaraid_sas psample ghash_clmulni_intel pci_hyperv_intf wmi dm_multipath sunrpc dm_mirror dm_region_hash dm_log dm_mod be2iscsi bnx2i cnic uio cxgb4i cxgb4 tls libcxgbi libcxgb qla4xxx iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi fuse
+[ 3710.108431] CPU: 1 PID: 13092 Comm: kworker/1:1 Kdump: loaded Not tainted 5.14.0-319.el9.x86_64 #1
+[ 3710.108435] Hardware name: Dell Inc. PowerEdge R750/0PJ80M, BIOS 1.8.2 09/14/2022
+[ 3710.108437] Workqueue: events devlink_port_type_warn
+[ 3710.108440] RIP: 0010:devlink_port_type_warn+0x11/0x20
+[ 3710.108443] Code: 84 76 fe ff ff 48 c7 03 20 0e 1a ad 31 c0 e9 96 fd ff ff 66 0f 1f 44 00 00 0f 1f 44 00 00 48 c7 c7 18 24 4e ad e8 ef 71 62 ff <0f> 0b c3 cc cc cc cc 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 f6 87
+[ 3710.108445] RSP: 0018:ff3b6d2e8b3c7e90 EFLAGS: 00010282
+[ 3710.108447] RAX: 0000000000000000 RBX: ff366d6580127080 RCX: 0000000000000027
+[ 3710.108448] RDX: 0000000000000027 RSI: 00000000ffff86de RDI: ff366d753f41f8c8
+[ 3710.108449] RBP: ff366d658ff5a0c0 R08: ff366d753f41f8c0 R09: ff3b6d2e8b3c7e18
+[ 3710.108450] R10: 0000000000000001 R11: 0000000000000023 R12: ff366d753f430600
+[ 3710.108451] R13: ff366d753f436900 R14: 0000000000000000 R15: ff366d753f436905
+[ 3710.108452] FS: 0000000000000000(0000) GS:ff366d753f400000(0000) knlGS:0000000000000000
+[ 3710.108453] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[ 3710.108454] CR2: 00007f1c57bc74e0 CR3: 000000111d26a001 CR4: 0000000000773ee0
+[ 3710.108456] PKRU: 55555554
+[ 3710.108457] Call Trace:
+[ 3710.108458] <TASK>
+[ 3710.108459] process_one_work+0x1e2/0x3b0
+[ 3710.108466] ? rescuer_thread+0x390/0x390
+[ 3710.108468] worker_thread+0x50/0x3a0
+[ 3710.108471] ? rescuer_thread+0x390/0x390
+[ 3710.108473] kthread+0xdd/0x100
+[ 3710.108477] ? kthread_complete_and_exit+0x20/0x20
+[ 3710.108479] ret_from_fork+0x1f/0x30
+[ 3710.108485] </TASK>
+[ 3710.108486] ---[ end trace 1b4b23cd0c65d6a0 ]---
+
+After patch:
+[ 402.473064] ice 0000:41:00.0: Type was not set for devlink port.
+[ 402.473064] ice 0000:41:00.1: Type was not set for devlink port.
+
+Signed-off-by: Petr Oros <poros@redhat.com>
+Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
+Reviewed-by: Jakub Kicinski <kuba@kernel.org>
+Link: https://lore.kernel.org/r/20230615095447.8259-1-poros@redhat.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/devlink.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/net/core/devlink.c b/net/core/devlink.c
+index db76c55e1a6d7..7113ae79f5228 100644
+--- a/net/core/devlink.c
++++ b/net/core/devlink.c
+@@ -9055,7 +9055,10 @@ EXPORT_SYMBOL_GPL(devlink_free);
+
+ static void devlink_port_type_warn(struct work_struct *work)
+ {
+- WARN(true, "Type was not set for devlink port.");
++ struct devlink_port *port = container_of(to_delayed_work(work),
++ struct devlink_port,
++ type_warn_dw);
++ dev_warn(port->devlink->dev, "Type was not set for devlink port.");
+ }
+
+ static bool devlink_port_type_should_warn(struct devlink_port *devlink_port)
+--
+2.43.0
+
--- /dev/null
+From 704cf30bc7fdbf1cf65506ef65bcdc455c9f84de Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 28 Sep 2021 15:42:35 +0800
+Subject: drm/amdgpu: init iommu after amdkfd device init
+
+From: Yifan Zhang <yifan1.zhang@amd.com>
+
+[ Upstream commit 286826d7d976e7646b09149d9bc2899d74ff962b ]
+
+This patch is to fix clinfo failure in Raven/Picasso:
+
+Number of platforms: 1
+ Platform Profile: FULL_PROFILE
+ Platform Version: OpenCL 2.2 AMD-APP (3364.0)
+ Platform Name: AMD Accelerated Parallel Processing
+ Platform Vendor: Advanced Micro Devices, Inc.
+ Platform Extensions: cl_khr_icd cl_amd_event_callback
+
+ Platform Name: AMD Accelerated Parallel Processing Number of devices: 0
+
+Signed-off-by: Yifan Zhang <yifan1.zhang@amd.com>
+Reviewed-by: James Zhu <James.Zhu@amd.com>
+Tested-by: James Zhu <James.Zhu@amd.com>
+Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+index 5f6c32ec674d3..222a1d9ecf163 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+@@ -2487,10 +2487,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
+ if (r)
+ goto init_failed;
+
+- r = amdgpu_amdkfd_resume_iommu(adev);
+- if (r)
+- goto init_failed;
+-
+ r = amdgpu_device_ip_hw_init_phase1(adev);
+ if (r)
+ goto init_failed;
+@@ -2529,6 +2525,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
+ if (!adev->gmc.xgmi.pending_reset)
+ amdgpu_amdkfd_device_init(adev);
+
++ r = amdgpu_amdkfd_resume_iommu(adev);
++ if (r)
++ goto init_failed;
++
+ amdgpu_fru_get_product_info(adev);
+
+ init_failed:
+--
+2.43.0
+
--- /dev/null
+From 24ad5867ee01b3ba866e2e67bbc0a72015bab962 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 11 Feb 2022 08:29:33 +0800
+Subject: drm/i915/dg1: Update DMC_DEBUG3 register
+
+From: Chuansheng Liu <chuansheng.liu@intel.com>
+
+[ Upstream commit b60668cb4c57a7cc451de781ae49f5e9cc375eaf ]
+
+Current DMC_DEBUG3(_MMIO(0x101090)) address is for TGL,
+it is wrong for DG1. Just like commit 5bcc95ca382e
+("drm/i915/dg1: Update DMC_DEBUG register"), correct
+this issue for DG1 platform to avoid wrong register
+being read.
+
+BSpec: 49788
+
+v2: fix "not wrong" typo. (Jani)
+
+Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
+Cc: Jani Nikula <jani.nikula@intel.com>
+Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
+Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20220211002933.84240-1-chuansheng.liu@intel.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/i915/display/intel_display_debugfs.c | 4 ++--
+ drivers/gpu/drm/i915/i915_reg.h | 3 ++-
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
+index b136a0fc0963b..6b3e2e053f457 100644
+--- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c
++++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
+@@ -571,8 +571,8 @@ static int i915_dmc_info(struct seq_file *m, void *unused)
+ * reg for DC3CO debugging and validation,
+ * but TGL DMC f/w is using DMC_DEBUG3 reg for DC3CO counter.
+ */
+- seq_printf(m, "DC3CO count: %d\n",
+- intel_de_read(dev_priv, DMC_DEBUG3));
++ seq_printf(m, "DC3CO count: %d\n", intel_de_read(dev_priv, IS_DGFX(dev_priv) ?
++ DG1_DMC_DEBUG3 : TGL_DMC_DEBUG3));
+ } else {
+ dc5_reg = IS_BROXTON(dev_priv) ? BXT_DMC_DC3_DC5_COUNT :
+ SKL_DMC_DC3_DC5_COUNT;
+diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
+index 3c70aa5229e5a..906982d6370d0 100644
+--- a/drivers/gpu/drm/i915/i915_reg.h
++++ b/drivers/gpu/drm/i915/i915_reg.h
+@@ -7841,7 +7841,8 @@ enum {
+ #define TGL_DMC_DEBUG_DC6_COUNT _MMIO(0x101088)
+ #define DG1_DMC_DEBUG_DC5_COUNT _MMIO(0x134154)
+
+-#define DMC_DEBUG3 _MMIO(0x101090)
++#define TGL_DMC_DEBUG3 _MMIO(0x101090)
++#define DG1_DMC_DEBUG3 _MMIO(0x13415c)
+
+ /* Display Internal Timeout Register */
+ #define RM_TIMEOUT _MMIO(0x42060)
+--
+2.43.0
+
--- /dev/null
+From 252b974a0ea7e7bede2cb2674399fc5450ad01f6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 30 Sep 2022 22:54:21 +0800
+Subject: dt-bindings: clocks: imx8mp: Add ID for usb suspend clock
+
+From: Li Jun <jun.li@nxp.com>
+
+[ Upstream commit 5c1f7f1090947d494c30042123e0ec846f696336 ]
+
+usb suspend clock has a gate shared with usb_root_clk.
+
+Fixes: 9c140d9926761 ("clk: imx: Add support for i.MX8MP clock driver")
+Cc: stable@vger.kernel.org # v5.19+
+Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Signed-off-by: Li Jun <jun.li@nxp.com>
+Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
+Link: https://lore.kernel.org/r/1664549663-20364-1-git-send-email-jun.li@nxp.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/dt-bindings/clock/imx8mp-clock.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/include/dt-bindings/clock/imx8mp-clock.h b/include/dt-bindings/clock/imx8mp-clock.h
+index a02fd723168cc..5e872b01d5ab8 100644
+--- a/include/dt-bindings/clock/imx8mp-clock.h
++++ b/include/dt-bindings/clock/imx8mp-clock.h
+@@ -325,8 +325,9 @@
+ #define IMX8MP_CLK_CLKOUT2_SEL 317
+ #define IMX8MP_CLK_CLKOUT2_DIV 318
+ #define IMX8MP_CLK_CLKOUT2 319
++#define IMX8MP_CLK_USB_SUSP 320
+
+-#define IMX8MP_CLK_END 320
++#define IMX8MP_CLK_END 321
+
+ #define IMX8MP_CLK_AUDIOMIX_SAI1_IPG 0
+ #define IMX8MP_CLK_AUDIOMIX_SAI1_MCLK1 1
+--
+2.43.0
+
--- /dev/null
+From 6b678324962b37e715898cf9532bc689b6c210c2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 9 Nov 2022 13:50:22 +0800
+Subject: exfat: support dynamic allocate bh for exfat_entry_set_cache
+
+From: Yuezhang Mo <Yuezhang.Mo@sony.com>
+
+[ Upstream commit a3ff29a95fde16906304455aa8c0bd84eb770258 ]
+
+In special cases, a file or a directory may occupied more than 19
+directory entries, pre-allocating 3 bh is not enough. Such as
+ - Support vendor secondary directory entry in the future.
+ - Since file directory entry is damaged, the SecondaryCount
+ field is bigger than 18.
+
+So this commit supports dynamic allocation of bh.
+
+Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
+Reviewed-by: Andy Wu <Andy.Wu@sony.com>
+Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
+Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
+Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/exfat/dir.c | 15 +++++++++++++++
+ fs/exfat/exfat_fs.h | 5 ++++-
+ 2 files changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
+index f6dd4fc8eaf45..be7570d01ae1a 100644
+--- a/fs/exfat/dir.c
++++ b/fs/exfat/dir.c
+@@ -618,6 +618,10 @@ int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
+ bforget(es->bh[i]);
+ else
+ brelse(es->bh[i]);
++
++ if (IS_DYNAMIC_ES(es))
++ kfree(es->bh);
++
+ kfree(es);
+ return err;
+ }
+@@ -853,6 +857,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
+ /* byte offset in sector */
+ off = EXFAT_BLK_OFFSET(byte_offset, sb);
+ es->start_off = off;
++ es->bh = es->__bh;
+
+ /* sector offset in cluster */
+ sec = EXFAT_B_TO_BLK(byte_offset, sb);
+@@ -872,6 +877,16 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
+ es->num_entries = num_entries;
+
+ num_bh = EXFAT_B_TO_BLK_ROUND_UP(off + num_entries * DENTRY_SIZE, sb);
++ if (num_bh > ARRAY_SIZE(es->__bh)) {
++ es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_KERNEL);
++ if (!es->bh) {
++ brelse(bh);
++ kfree(es);
++ return NULL;
++ }
++ es->bh[0] = bh;
++ }
++
+ for (i = 1; i < num_bh; i++) {
+ /* get the next sector */
+ if (exfat_is_last_sector_in_cluster(sbi, sec)) {
+diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
+index db538709dafa0..58816ee3162c4 100644
+--- a/fs/exfat/exfat_fs.h
++++ b/fs/exfat/exfat_fs.h
+@@ -170,10 +170,13 @@ struct exfat_entry_set_cache {
+ bool modified;
+ unsigned int start_off;
+ int num_bh;
+- struct buffer_head *bh[DIR_CACHE_SIZE];
++ struct buffer_head *__bh[DIR_CACHE_SIZE];
++ struct buffer_head **bh;
+ unsigned int num_entries;
+ };
+
++#define IS_DYNAMIC_ES(es) ((es)->__bh != (es)->bh)
++
+ struct exfat_dir_entry {
+ struct exfat_chain dir;
+ int entry;
+--
+2.43.0
+
--- /dev/null
+From deb9c092838edb37446d8f263f28f7a0cfceabbc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 20 Mar 2022 23:11:18 +0800
+Subject: f2fs: don't set GC_FAILURE_PIN for background GC
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 642c0969916eaa4878cb74f36752108e590b0389 ]
+
+So that it can reduce the possibility that file be unpinned forcely by
+foreground GC due to .i_gc_failures[GC_FAILURE_PIN] exceeds threshold.
+
+Signed-off-by: Chao Yu <chao.yu@oppo.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/gc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
+index 7010440cb64c8..d016504fad4b9 100644
+--- a/fs/f2fs/gc.c
++++ b/fs/f2fs/gc.c
+@@ -1199,7 +1199,8 @@ static int move_data_block(struct inode *inode, block_t bidx,
+ }
+
+ if (f2fs_is_pinned_file(inode)) {
+- f2fs_pin_file_control(inode, true);
++ if (gc_type == FG_GC)
++ f2fs_pin_file_control(inode, true);
+ err = -EAGAIN;
+ goto out;
+ }
+--
+2.43.0
+
--- /dev/null
+From cbec888db6f1c04d06395d0f9f32fb5c4de3e470 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 29 Apr 2022 13:29:53 -0700
+Subject: f2fs: write checkpoint during FG_GC
+
+From: Byungki Lee <dominicus79@gmail.com>
+
+[ Upstream commit a9163b947ae8f7af7cb8d63606cd87b9facbfe74 ]
+
+If there's not enough free sections each of which consistis of large segments,
+we can hit no free section for upcoming section allocation. Let's reclaim some
+prefree segments by writing checkpoints.
+
+Signed-off-by: Byungki Lee <dominicus79@gmail.com>
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/gc.c | 38 +++++++++++++++++++++++---------------
+ 1 file changed, 23 insertions(+), 15 deletions(-)
+
+diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
+index d016504fad4b9..2c13f308c74e3 100644
+--- a/fs/f2fs/gc.c
++++ b/fs/f2fs/gc.c
+@@ -1782,23 +1782,31 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
+ if (sync)
+ goto stop;
+
+- if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
+- if (skipped_round <= MAX_SKIP_GC_COUNT ||
+- skipped_round * 2 < round) {
+- segno = NULL_SEGNO;
+- goto gc_more;
+- }
++ if (!has_not_enough_free_secs(sbi, sec_freed, 0))
++ goto stop;
+
+- if (first_skipped < last_skipped &&
+- (last_skipped - first_skipped) >
+- sbi->skipped_gc_rwsem) {
+- f2fs_drop_inmem_pages_all(sbi, true);
+- segno = NULL_SEGNO;
+- goto gc_more;
+- }
+- if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED))
++ if (skipped_round <= MAX_SKIP_GC_COUNT || skipped_round * 2 < round) {
++
++ /* Write checkpoint to reclaim prefree segments */
++ if (free_sections(sbi) < NR_CURSEG_PERSIST_TYPE &&
++ prefree_segments(sbi) &&
++ !is_sbi_flag_set(sbi, SBI_CP_DISABLED)) {
+ ret = f2fs_write_checkpoint(sbi, &cpc);
+- }
++ if (ret)
++ goto stop;
++ }
++ segno = NULL_SEGNO;
++ goto gc_more;
++ }
++ if (first_skipped < last_skipped &&
++ (last_skipped - first_skipped) >
++ sbi->skipped_gc_rwsem) {
++ f2fs_drop_inmem_pages_all(sbi, true);
++ segno = NULL_SEGNO;
++ goto gc_more;
++ }
++ if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED))
++ ret = f2fs_write_checkpoint(sbi, &cpc);
+ stop:
+ SIT_I(sbi)->last_victim[ALLOC_NEXT] = 0;
+ SIT_I(sbi)->last_victim[FLUSH_DEVICE] = init_segno;
+--
+2.43.0
+
--- /dev/null
+From 2ce1f1d27bfa7829100bccf9c0c4e0ddf66e76d9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 20 Jun 2023 10:47:32 -0700
+Subject: igb: Fix igb_down hung on surprise removal
+
+From: Ying Hsu <yinghsu@chromium.org>
+
+[ Upstream commit 004d25060c78fc31f66da0fa439c544dda1ac9d5 ]
+
+In a setup where a Thunderbolt hub connects to Ethernet and a display
+through USB Type-C, users may experience a hung task timeout when they
+remove the cable between the PC and the Thunderbolt hub.
+This is because the igb_down function is called multiple times when
+the Thunderbolt hub is unplugged. For example, the igb_io_error_detected
+triggers the first call, and the igb_remove triggers the second call.
+The second call to igb_down will block at napi_synchronize.
+Here's the call trace:
+ __schedule+0x3b0/0xddb
+ ? __mod_timer+0x164/0x5d3
+ schedule+0x44/0xa8
+ schedule_timeout+0xb2/0x2a4
+ ? run_local_timers+0x4e/0x4e
+ msleep+0x31/0x38
+ igb_down+0x12c/0x22a [igb 6615058754948bfde0bf01429257eb59f13030d4]
+ __igb_close+0x6f/0x9c [igb 6615058754948bfde0bf01429257eb59f13030d4]
+ igb_close+0x23/0x2b [igb 6615058754948bfde0bf01429257eb59f13030d4]
+ __dev_close_many+0x95/0xec
+ dev_close_many+0x6e/0x103
+ unregister_netdevice_many+0x105/0x5b1
+ unregister_netdevice_queue+0xc2/0x10d
+ unregister_netdev+0x1c/0x23
+ igb_remove+0xa7/0x11c [igb 6615058754948bfde0bf01429257eb59f13030d4]
+ pci_device_remove+0x3f/0x9c
+ device_release_driver_internal+0xfe/0x1b4
+ pci_stop_bus_device+0x5b/0x7f
+ pci_stop_bus_device+0x30/0x7f
+ pci_stop_bus_device+0x30/0x7f
+ pci_stop_and_remove_bus_device+0x12/0x19
+ pciehp_unconfigure_device+0x76/0xe9
+ pciehp_disable_slot+0x6e/0x131
+ pciehp_handle_presence_or_link_change+0x7a/0x3f7
+ pciehp_ist+0xbe/0x194
+ irq_thread_fn+0x22/0x4d
+ ? irq_thread+0x1fd/0x1fd
+ irq_thread+0x17b/0x1fd
+ ? irq_forced_thread_fn+0x5f/0x5f
+ kthread+0x142/0x153
+ ? __irq_get_irqchip_state+0x46/0x46
+ ? kthread_associate_blkcg+0x71/0x71
+ ret_from_fork+0x1f/0x30
+
+In this case, igb_io_error_detected detaches the network interface
+and requests a PCIE slot reset, however, the PCIE reset callback is
+not being invoked and thus the Ethernet connection breaks down.
+As the PCIE error in this case is a non-fatal one, requesting a
+slot reset can be avoided.
+This patch fixes the task hung issue and preserves Ethernet
+connection by ignoring non-fatal PCIE errors.
+
+Signed-off-by: Ying Hsu <yinghsu@chromium.org>
+Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
+Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Link: https://lore.kernel.org/r/20230620174732.4145155-1-anthony.l.nguyen@intel.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/intel/igb/igb_main.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
+index c01114cabbb09..7c42a99be5065 100644
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -9451,6 +9451,11 @@ static pci_ers_result_t igb_io_error_detected(struct pci_dev *pdev,
+ struct net_device *netdev = pci_get_drvdata(pdev);
+ struct igb_adapter *adapter = netdev_priv(netdev);
+
++ if (state == pci_channel_io_normal) {
++ dev_warn(&pdev->dev, "Non-correctable non-fatal error reported.\n");
++ return PCI_ERS_RESULT_CAN_RECOVER;
++ }
++
+ netif_device_detach(netdev);
+
+ if (state == pci_channel_io_perm_failure)
+--
+2.43.0
+
--- /dev/null
+From 049a75f6cf04997f3930d42b845108bca6330aa2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jan 2023 11:52:26 +0100
+Subject: Input: ads7846 - always set last command to PWRDOWN
+
+From: Luca Ellero <l.ellero@asem.it>
+
+[ Upstream commit 13f82ca3878db8284a70ef9711d7f710a31eb562 ]
+
+Controllers that report pressure (e.g. ADS7846) use 5 commands and the
+correct sequence is READ_X, READ_Y, READ_Z1, READ_Z2, PWRDOWN.
+
+Controllers that don't report pressure (e.g. ADS7845/ADS7843) use only 3
+commands and the correct sequence should be READ_X, READ_Y, PWRDOWN. But
+the sequence sent was incorrect: READ_X, READ_Y, READ_Z1.
+
+Fix this by setting the third (and last) command to PWRDOWN.
+
+Fixes: ffa458c1bd9b ("spi: ads7846 driver")
+Signed-off-by: Luca Ellero <l.ellero@asem.it>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20230126105227.47648-3-l.ellero@asem.it
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/touchscreen/ads7846.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
+index ef04988edf0c2..f416a4bcd72bf 100644
+--- a/drivers/input/touchscreen/ads7846.c
++++ b/drivers/input/touchscreen/ads7846.c
+@@ -1074,6 +1074,9 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
+ struct ads7846_buf_layout *l = &packet->l[cmd_idx];
+ unsigned int max_count;
+
++ if (cmd_idx == packet->cmds - 1)
++ cmd_idx = ADS7846_PWDOWN;
++
+ if (ads7846_cmd_need_settle(cmd_idx))
+ max_count = packet->count + packet->count_skip;
+ else
+@@ -1110,7 +1113,12 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
+
+ for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) {
+ struct ads7846_buf_layout *l = &packet->l[cmd_idx];
+- u8 cmd = ads7846_get_cmd(cmd_idx, vref);
++ u8 cmd;
++
++ if (cmd_idx == packet->cmds - 1)
++ cmd_idx = ADS7846_PWDOWN;
++
++ cmd = ads7846_get_cmd(cmd_idx, vref);
+
+ for (b = 0; b < l->count; b++)
+ packet->tx[l->offset + b].cmd = cmd;
+--
+2.43.0
+
--- /dev/null
+From 29cc791be466f52f9bd3e06cd0d43c7a4e7ccdab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jan 2023 11:52:27 +0100
+Subject: Input: ads7846 - don't check penirq immediately for 7845
+
+From: Luca Ellero <l.ellero@asem.it>
+
+[ Upstream commit fa9f4275b20ec7b2a8fb05c66362d10b36f9efec ]
+
+To discard false readings, one should use "ti,penirq-recheck-delay-usecs".
+Checking get_pendown_state() at the beginning, most of the time fails
+causing malfunctioning.
+
+Fixes: ffa458c1bd9b ("spi: ads7846 driver")
+Signed-off-by: Luca Ellero <l.ellero@asem.it>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20230126105227.47648-4-l.ellero@asem.it
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/touchscreen/ads7846.c | 8 +-------
+ 1 file changed, 1 insertion(+), 7 deletions(-)
+
+diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
+index f416a4bcd72bf..1db61185f7bec 100644
+--- a/drivers/input/touchscreen/ads7846.c
++++ b/drivers/input/touchscreen/ads7846.c
+@@ -851,14 +851,8 @@ static void ads7846_report_state(struct ads7846 *ts)
+ if (x == MAX_12BIT)
+ x = 0;
+
+- if (ts->model == 7843) {
++ if (ts->model == 7843 || ts->model == 7845) {
+ Rt = ts->pressure_max / 2;
+- } else if (ts->model == 7845) {
+- if (get_pendown_state(ts))
+- Rt = ts->pressure_max / 2;
+- else
+- Rt = 0;
+- dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt);
+ } else if (likely(x && z1)) {
+ /* compute touch pressure resistance using equation #2 */
+ Rt = z2;
+--
+2.43.0
+
--- /dev/null
+From 52eaada1883797a6a88ec296e44a78203960aba7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jan 2023 11:52:25 +0100
+Subject: Input: ads7846 - don't report pressure for ads7845
+
+From: Luca Ellero <l.ellero@asem.it>
+
+[ Upstream commit d50584d783313c8b05b84d0b07a2142f1bde46dd ]
+
+ADS7845 doesn't support pressure.
+Avoid the following error reported by libinput-list-devices:
+"ADS7845 Touchscreen: kernel bug: device has min == max on ABS_PRESSURE".
+
+Fixes: ffa458c1bd9b ("spi: ads7846 driver")
+Signed-off-by: Luca Ellero <l.ellero@asem.it>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20230126105227.47648-2-l.ellero@asem.it
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/touchscreen/ads7846.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
+index f113a27aeb1ef..ef04988edf0c2 100644
+--- a/drivers/input/touchscreen/ads7846.c
++++ b/drivers/input/touchscreen/ads7846.c
+@@ -1323,8 +1323,9 @@ static int ads7846_probe(struct spi_device *spi)
+ pdata->y_min ? : 0,
+ pdata->y_max ? : MAX_12BIT,
+ 0, 0);
+- input_set_abs_params(input_dev, ABS_PRESSURE,
+- pdata->pressure_min, pdata->pressure_max, 0, 0);
++ if (ts->model != 7845)
++ input_set_abs_params(input_dev, ABS_PRESSURE,
++ pdata->pressure_min, pdata->pressure_max, 0, 0);
+
+ /*
+ * Parse common framework properties. Must be done here to ensure the
+--
+2.43.0
+
--- /dev/null
+From 330a5cfa1787909a2a6ae09537770f260bf6bf08 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 11:59:12 -0600
+Subject: Input: iqs269a - configure device with a single block write
+
+From: Jeff LaBundy <jeff@labundy.com>
+
+[ Upstream commit 3689abfc4e369a643d758a02fb9ad0b2403d6d6d ]
+
+Unless it is being done as part of servicing a soft reset interrupt,
+configuring channels on-the-fly (as is the case when writing to the
+ati_trigger attribute) may cause GPIO3 (which reflects the state of
+touch for a selected channel) to be inadvertently asserted.
+
+To solve this problem, follow the vendor's recommendation and write
+all channel configuration as well as the REDO_ATI register field as
+part of a single block write. This ensures the device has been told
+to re-calibrate itself following an I2C stop condition, after which
+sensing resumes and GPIO3 may be asserted.
+
+Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
+Signed-off-by: Jeff LaBundy <jeff@labundy.com>
+Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
+Link: https://lore.kernel.org/r/Y7Rs8GyV7g0nF5Yy@nixie71
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/misc/iqs269a.c | 98 ++++++++++++++----------------------
+ 1 file changed, 39 insertions(+), 59 deletions(-)
+
+diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
+index ea3c97c5f764f..2124d08c55b79 100644
+--- a/drivers/input/misc/iqs269a.c
++++ b/drivers/input/misc/iqs269a.c
+@@ -96,8 +96,6 @@
+ #define IQS269_MISC_B_TRACKING_UI_ENABLE BIT(4)
+ #define IQS269_MISC_B_FILT_STR_SLIDER GENMASK(1, 0)
+
+-#define IQS269_CHx_SETTINGS 0x8C
+-
+ #define IQS269_CHx_ENG_A_MEAS_CAP_SIZE BIT(15)
+ #define IQS269_CHx_ENG_A_RX_GND_INACTIVE BIT(13)
+ #define IQS269_CHx_ENG_A_LOCAL_CAP_SIZE BIT(12)
+@@ -245,6 +243,18 @@ struct iqs269_ver_info {
+ u8 padding;
+ } __packed;
+
++struct iqs269_ch_reg {
++ u8 rx_enable;
++ u8 tx_enable;
++ __be16 engine_a;
++ __be16 engine_b;
++ __be16 ati_comp;
++ u8 thresh[3];
++ u8 hyst;
++ u8 assoc_select;
++ u8 assoc_weight;
++} __packed;
++
+ struct iqs269_sys_reg {
+ __be16 general;
+ u8 active;
+@@ -266,18 +276,7 @@ struct iqs269_sys_reg {
+ u8 timeout_swipe;
+ u8 thresh_swipe;
+ u8 redo_ati;
+-} __packed;
+-
+-struct iqs269_ch_reg {
+- u8 rx_enable;
+- u8 tx_enable;
+- __be16 engine_a;
+- __be16 engine_b;
+- __be16 ati_comp;
+- u8 thresh[3];
+- u8 hyst;
+- u8 assoc_select;
+- u8 assoc_weight;
++ struct iqs269_ch_reg ch_reg[IQS269_NUM_CH];
+ } __packed;
+
+ struct iqs269_flags {
+@@ -292,7 +291,6 @@ struct iqs269_private {
+ struct regmap *regmap;
+ struct mutex lock;
+ struct iqs269_switch_desc switches[ARRAY_SIZE(iqs269_events)];
+- struct iqs269_ch_reg ch_reg[IQS269_NUM_CH];
+ struct iqs269_sys_reg sys_reg;
+ struct input_dev *keypad;
+ struct input_dev *slider[IQS269_NUM_SL];
+@@ -307,6 +305,7 @@ struct iqs269_private {
+ static int iqs269_ati_mode_set(struct iqs269_private *iqs269,
+ unsigned int ch_num, unsigned int mode)
+ {
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ u16 engine_a;
+
+ if (ch_num >= IQS269_NUM_CH)
+@@ -317,12 +316,12 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269,
+
+ mutex_lock(&iqs269->lock);
+
+- engine_a = be16_to_cpu(iqs269->ch_reg[ch_num].engine_a);
++ engine_a = be16_to_cpu(ch_reg[ch_num].engine_a);
+
+ engine_a &= ~IQS269_CHx_ENG_A_ATI_MODE_MASK;
+ engine_a |= (mode << IQS269_CHx_ENG_A_ATI_MODE_SHIFT);
+
+- iqs269->ch_reg[ch_num].engine_a = cpu_to_be16(engine_a);
++ ch_reg[ch_num].engine_a = cpu_to_be16(engine_a);
+ iqs269->ati_current = false;
+
+ mutex_unlock(&iqs269->lock);
+@@ -333,13 +332,14 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269,
+ static int iqs269_ati_mode_get(struct iqs269_private *iqs269,
+ unsigned int ch_num, unsigned int *mode)
+ {
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ u16 engine_a;
+
+ if (ch_num >= IQS269_NUM_CH)
+ return -EINVAL;
+
+ mutex_lock(&iqs269->lock);
+- engine_a = be16_to_cpu(iqs269->ch_reg[ch_num].engine_a);
++ engine_a = be16_to_cpu(ch_reg[ch_num].engine_a);
+ mutex_unlock(&iqs269->lock);
+
+ engine_a &= IQS269_CHx_ENG_A_ATI_MODE_MASK;
+@@ -351,6 +351,7 @@ static int iqs269_ati_mode_get(struct iqs269_private *iqs269,
+ static int iqs269_ati_base_set(struct iqs269_private *iqs269,
+ unsigned int ch_num, unsigned int base)
+ {
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ u16 engine_b;
+
+ if (ch_num >= IQS269_NUM_CH)
+@@ -379,12 +380,12 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269,
+
+ mutex_lock(&iqs269->lock);
+
+- engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b);
++ engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
+
+ engine_b &= ~IQS269_CHx_ENG_B_ATI_BASE_MASK;
+ engine_b |= base;
+
+- iqs269->ch_reg[ch_num].engine_b = cpu_to_be16(engine_b);
++ ch_reg[ch_num].engine_b = cpu_to_be16(engine_b);
+ iqs269->ati_current = false;
+
+ mutex_unlock(&iqs269->lock);
+@@ -395,13 +396,14 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269,
+ static int iqs269_ati_base_get(struct iqs269_private *iqs269,
+ unsigned int ch_num, unsigned int *base)
+ {
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ u16 engine_b;
+
+ if (ch_num >= IQS269_NUM_CH)
+ return -EINVAL;
+
+ mutex_lock(&iqs269->lock);
+- engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b);
++ engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
+ mutex_unlock(&iqs269->lock);
+
+ switch (engine_b & IQS269_CHx_ENG_B_ATI_BASE_MASK) {
+@@ -429,6 +431,7 @@ static int iqs269_ati_base_get(struct iqs269_private *iqs269,
+ static int iqs269_ati_target_set(struct iqs269_private *iqs269,
+ unsigned int ch_num, unsigned int target)
+ {
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ u16 engine_b;
+
+ if (ch_num >= IQS269_NUM_CH)
+@@ -439,12 +442,12 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269,
+
+ mutex_lock(&iqs269->lock);
+
+- engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b);
++ engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
+
+ engine_b &= ~IQS269_CHx_ENG_B_ATI_TARGET_MASK;
+ engine_b |= target / 32;
+
+- iqs269->ch_reg[ch_num].engine_b = cpu_to_be16(engine_b);
++ ch_reg[ch_num].engine_b = cpu_to_be16(engine_b);
+ iqs269->ati_current = false;
+
+ mutex_unlock(&iqs269->lock);
+@@ -455,13 +458,14 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269,
+ static int iqs269_ati_target_get(struct iqs269_private *iqs269,
+ unsigned int ch_num, unsigned int *target)
+ {
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ u16 engine_b;
+
+ if (ch_num >= IQS269_NUM_CH)
+ return -EINVAL;
+
+ mutex_lock(&iqs269->lock);
+- engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b);
++ engine_b = be16_to_cpu(ch_reg[ch_num].engine_b);
+ mutex_unlock(&iqs269->lock);
+
+ *target = (engine_b & IQS269_CHx_ENG_B_ATI_TARGET_MASK) * 32;
+@@ -531,13 +535,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
+ if (fwnode_property_present(ch_node, "azoteq,slider1-select"))
+ iqs269->sys_reg.slider_select[1] |= BIT(reg);
+
+- ch_reg = &iqs269->ch_reg[reg];
+-
+- error = regmap_raw_read(iqs269->regmap,
+- IQS269_CHx_SETTINGS + reg * sizeof(*ch_reg) / 2,
+- ch_reg, sizeof(*ch_reg));
+- if (error)
+- return error;
++ ch_reg = &iqs269->sys_reg.ch_reg[reg];
+
+ error = iqs269_parse_mask(ch_node, "azoteq,rx-enable",
+ &ch_reg->rx_enable);
+@@ -1042,10 +1040,8 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269)
+
+ static int iqs269_dev_init(struct iqs269_private *iqs269)
+ {
+- struct iqs269_sys_reg *sys_reg = &iqs269->sys_reg;
+- struct iqs269_ch_reg *ch_reg;
+ unsigned int val;
+- int error, i;
++ int error;
+
+ mutex_lock(&iqs269->lock);
+
+@@ -1055,27 +1051,8 @@ static int iqs269_dev_init(struct iqs269_private *iqs269)
+ if (error)
+ goto err_mutex;
+
+- for (i = 0; i < IQS269_NUM_CH; i++) {
+- if (!(sys_reg->active & BIT(i)))
+- continue;
+-
+- ch_reg = &iqs269->ch_reg[i];
+-
+- error = regmap_raw_write(iqs269->regmap,
+- IQS269_CHx_SETTINGS + i *
+- sizeof(*ch_reg) / 2, ch_reg,
+- sizeof(*ch_reg));
+- if (error)
+- goto err_mutex;
+- }
+-
+- /*
+- * The REDO-ATI and ATI channel selection fields must be written in the
+- * same block write, so every field between registers 0x80 through 0x8B
+- * (inclusive) must be written as well.
+- */
+- error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg,
+- sizeof(*sys_reg));
++ error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS,
++ &iqs269->sys_reg, sizeof(iqs269->sys_reg));
+ if (error)
+ goto err_mutex;
+
+@@ -1349,6 +1326,7 @@ static ssize_t hall_bin_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ struct i2c_client *client = iqs269->client;
+ unsigned int val;
+ int error;
+@@ -1363,8 +1341,8 @@ static ssize_t hall_bin_show(struct device *dev,
+ if (error)
+ return error;
+
+- switch (iqs269->ch_reg[IQS269_CHx_HALL_ACTIVE].rx_enable &
+- iqs269->ch_reg[IQS269_CHx_HALL_INACTIVE].rx_enable) {
++ switch (ch_reg[IQS269_CHx_HALL_ACTIVE].rx_enable &
++ ch_reg[IQS269_CHx_HALL_INACTIVE].rx_enable) {
+ case IQS269_HALL_PAD_R:
+ val &= IQS269_CAL_DATA_A_HALL_BIN_R_MASK;
+ val >>= IQS269_CAL_DATA_A_HALL_BIN_R_SHIFT;
+@@ -1444,9 +1422,10 @@ static ssize_t rx_enable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+- iqs269->ch_reg[iqs269->ch_num].rx_enable);
++ ch_reg[iqs269->ch_num].rx_enable);
+ }
+
+ static ssize_t rx_enable_store(struct device *dev,
+@@ -1454,6 +1433,7 @@ static ssize_t rx_enable_store(struct device *dev,
+ size_t count)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
++ struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg;
+ unsigned int val;
+ int error;
+
+@@ -1466,7 +1446,7 @@ static ssize_t rx_enable_store(struct device *dev,
+
+ mutex_lock(&iqs269->lock);
+
+- iqs269->ch_reg[iqs269->ch_num].rx_enable = val;
++ ch_reg[iqs269->ch_num].rx_enable = val;
+ iqs269->ati_current = false;
+
+ mutex_unlock(&iqs269->lock);
+--
+2.43.0
+
--- /dev/null
+From 5bde09e64e35ca9aded2782b0ae49c37db1efac1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 11:59:35 -0600
+Subject: Input: iqs269a - do not poll during ATI
+
+From: Jeff LaBundy <jeff@labundy.com>
+
+[ Upstream commit b08134eb254db56e9ce8170d9b82f0d7a616b6f8 ]
+
+After initial start-up, the driver triggers ATI (calibration) with
+the newly loaded register configuration in place. Next, the driver
+polls a register field to ensure ATI completed in a timely fashion
+and that the device is ready to sense.
+
+However, communicating with the device over I2C while ATI is under-
+way may induce noise in the device and cause ATI to fail. As such,
+the vendor recommends not to poll the device during ATI.
+
+To solve this problem, let the device naturally signal to the host
+that ATI is complete by way of an interrupt. A completion prevents
+the device from successfully probing until this happens.
+
+As an added benefit, initial switch states are now reported in the
+interrupt handler at the same time ATI status is checked. As such,
+duplicate code that reports initial switch states has been removed
+from iqs269_input_init().
+
+The former logic that scaled ATI timeout and filter settling delay
+is not carried forward with the new implementation, as it produces
+overly conservative delays at the lower clock rate.
+
+Rather, a single timeout that covers both clock rates is used. The
+filter settling delay does not happen to be necessary and has been
+removed as well.
+
+Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
+Signed-off-by: Jeff LaBundy <jeff@labundy.com>
+Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
+Link: https://lore.kernel.org/r/Y7RtB2T7AF9rYMjK@nixie71
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/misc/iqs269a.c | 97 +++++++++++++++++-------------------
+ 1 file changed, 46 insertions(+), 51 deletions(-)
+
+diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
+index ff6cbc2f5d76c..f4c3aff3895bc 100644
+--- a/drivers/input/misc/iqs269a.c
++++ b/drivers/input/misc/iqs269a.c
+@@ -9,6 +9,7 @@
+ * axial sliders presented by the device.
+ */
+
++#include <linux/completion.h>
+ #include <linux/delay.h>
+ #include <linux/device.h>
+ #include <linux/err.h>
+@@ -144,10 +145,6 @@
+ #define IQS269_NUM_CH 8
+ #define IQS269_NUM_SL 2
+
+-#define IQS269_ATI_POLL_SLEEP_US (iqs269->delay_mult * 10000)
+-#define IQS269_ATI_POLL_TIMEOUT_US (iqs269->delay_mult * 500000)
+-#define IQS269_ATI_STABLE_DELAY_MS (iqs269->delay_mult * 150)
+-
+ #define iqs269_irq_wait() usleep_range(200, 250)
+
+ enum iqs269_local_cap_size {
+@@ -289,10 +286,10 @@ struct iqs269_private {
+ struct mutex lock;
+ struct iqs269_switch_desc switches[ARRAY_SIZE(iqs269_events)];
+ struct iqs269_sys_reg sys_reg;
++ struct completion ati_done;
+ struct input_dev *keypad;
+ struct input_dev *slider[IQS269_NUM_SL];
+ unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH];
+- unsigned int delay_mult;
+ unsigned int ch_num;
+ bool hall_enable;
+ bool ati_current;
+@@ -973,13 +970,8 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269)
+
+ general = be16_to_cpu(sys_reg->general);
+
+- if (device_property_present(&client->dev, "azoteq,clk-div")) {
++ if (device_property_present(&client->dev, "azoteq,clk-div"))
+ general |= IQS269_SYS_SETTINGS_CLK_DIV;
+- iqs269->delay_mult = 4;
+- } else {
+- general &= ~IQS269_SYS_SETTINGS_CLK_DIV;
+- iqs269->delay_mult = 1;
+- }
+
+ /*
+ * Configure the device to automatically switch between normal and low-
+@@ -1036,7 +1028,6 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269)
+
+ static int iqs269_dev_init(struct iqs269_private *iqs269)
+ {
+- unsigned int val;
+ int error;
+
+ mutex_lock(&iqs269->lock);
+@@ -1052,14 +1043,12 @@ static int iqs269_dev_init(struct iqs269_private *iqs269)
+ if (error)
+ goto err_mutex;
+
+- error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val,
+- !(val & IQS269_SYS_FLAGS_IN_ATI),
+- IQS269_ATI_POLL_SLEEP_US,
+- IQS269_ATI_POLL_TIMEOUT_US);
+- if (error)
+- goto err_mutex;
++ /*
++ * The following delay gives the device time to deassert its RDY output
++ * so as to prevent an interrupt from being serviced prematurely.
++ */
++ usleep_range(2000, 2100);
+
+- msleep(IQS269_ATI_STABLE_DELAY_MS);
+ iqs269->ati_current = true;
+
+ err_mutex:
+@@ -1071,10 +1060,8 @@ static int iqs269_dev_init(struct iqs269_private *iqs269)
+ static int iqs269_input_init(struct iqs269_private *iqs269)
+ {
+ struct i2c_client *client = iqs269->client;
+- struct iqs269_flags flags;
+ unsigned int sw_code, keycode;
+ int error, i, j;
+- u8 dir_mask, state;
+
+ iqs269->keypad = devm_input_allocate_device(&client->dev);
+ if (!iqs269->keypad)
+@@ -1087,23 +1074,7 @@ static int iqs269_input_init(struct iqs269_private *iqs269)
+ iqs269->keypad->name = "iqs269a_keypad";
+ iqs269->keypad->id.bustype = BUS_I2C;
+
+- if (iqs269->hall_enable) {
+- error = regmap_raw_read(iqs269->regmap, IQS269_SYS_FLAGS,
+- &flags, sizeof(flags));
+- if (error) {
+- dev_err(&client->dev,
+- "Failed to read initial status: %d\n", error);
+- return error;
+- }
+- }
+-
+ for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) {
+- dir_mask = flags.states[IQS269_ST_OFFS_DIR];
+- if (!iqs269_events[i].dir_up)
+- dir_mask = ~dir_mask;
+-
+- state = flags.states[iqs269_events[i].st_offs] & dir_mask;
+-
+ sw_code = iqs269->switches[i].code;
+
+ for (j = 0; j < IQS269_NUM_CH; j++) {
+@@ -1116,13 +1087,9 @@ static int iqs269_input_init(struct iqs269_private *iqs269)
+ switch (j) {
+ case IQS269_CHx_HALL_ACTIVE:
+ if (iqs269->hall_enable &&
+- iqs269->switches[i].enabled) {
++ iqs269->switches[i].enabled)
+ input_set_capability(iqs269->keypad,
+ EV_SW, sw_code);
+- input_report_switch(iqs269->keypad,
+- sw_code,
+- state & BIT(j));
+- }
+ fallthrough;
+
+ case IQS269_CHx_HALL_INACTIVE:
+@@ -1138,14 +1105,6 @@ static int iqs269_input_init(struct iqs269_private *iqs269)
+ }
+ }
+
+- input_sync(iqs269->keypad);
+-
+- error = input_register_device(iqs269->keypad);
+- if (error) {
+- dev_err(&client->dev, "Failed to register keypad: %d\n", error);
+- return error;
+- }
+-
+ for (i = 0; i < IQS269_NUM_SL; i++) {
+ if (!iqs269->sys_reg.slider_select[i])
+ continue;
+@@ -1205,6 +1164,9 @@ static int iqs269_report(struct iqs269_private *iqs269)
+ return error;
+ }
+
++ if (be16_to_cpu(flags.system) & IQS269_SYS_FLAGS_IN_ATI)
++ return 0;
++
+ error = regmap_raw_read(iqs269->regmap, IQS269_SLIDER_X, slider_x,
+ sizeof(slider_x));
+ if (error) {
+@@ -1267,6 +1229,12 @@ static int iqs269_report(struct iqs269_private *iqs269)
+
+ input_sync(iqs269->keypad);
+
++ /*
++ * The following completion signals that ATI has finished, any initial
++ * switch states have been reported and the keypad can be registered.
++ */
++ complete_all(&iqs269->ati_done);
++
+ return 0;
+ }
+
+@@ -1298,6 +1266,9 @@ static ssize_t counts_show(struct device *dev,
+ if (!iqs269->ati_current || iqs269->hall_enable)
+ return -EPERM;
+
++ if (!completion_done(&iqs269->ati_done))
++ return -EBUSY;
++
+ /*
+ * Unsolicited I2C communication prompts the device to assert its RDY
+ * pin, so disable the interrupt line until the operation is finished
+@@ -1554,7 +1525,9 @@ static ssize_t ati_trigger_show(struct device *dev,
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
+
+- return scnprintf(buf, PAGE_SIZE, "%u\n", iqs269->ati_current);
++ return scnprintf(buf, PAGE_SIZE, "%u\n",
++ iqs269->ati_current &&
++ completion_done(&iqs269->ati_done));
+ }
+
+ static ssize_t ati_trigger_store(struct device *dev,
+@@ -1574,6 +1547,7 @@ static ssize_t ati_trigger_store(struct device *dev,
+ return count;
+
+ disable_irq(client->irq);
++ reinit_completion(&iqs269->ati_done);
+
+ error = iqs269_dev_init(iqs269);
+
+@@ -1583,6 +1557,10 @@ static ssize_t ati_trigger_store(struct device *dev,
+ if (error)
+ return error;
+
++ if (!wait_for_completion_timeout(&iqs269->ati_done,
++ msecs_to_jiffies(2000)))
++ return -ETIMEDOUT;
++
+ return count;
+ }
+
+@@ -1641,6 +1619,7 @@ static int iqs269_probe(struct i2c_client *client)
+ }
+
+ mutex_init(&iqs269->lock);
++ init_completion(&iqs269->ati_done);
+
+ error = regmap_raw_read(iqs269->regmap, IQS269_VER_INFO, &ver_info,
+ sizeof(ver_info));
+@@ -1676,6 +1655,22 @@ static int iqs269_probe(struct i2c_client *client)
+ return error;
+ }
+
++ if (!wait_for_completion_timeout(&iqs269->ati_done,
++ msecs_to_jiffies(2000))) {
++ dev_err(&client->dev, "Failed to complete ATI\n");
++ return -ETIMEDOUT;
++ }
++
++ /*
++ * The keypad may include one or more switches and is not registered
++ * until ATI is complete and the initial switch states are read.
++ */
++ error = input_register_device(iqs269->keypad);
++ if (error) {
++ dev_err(&client->dev, "Failed to register keypad: %d\n", error);
++ return error;
++ }
++
+ error = devm_device_add_group(&client->dev, &iqs269_attr_group);
+ if (error)
+ dev_err(&client->dev, "Failed to add attributes: %d\n", error);
+--
+2.43.0
+
--- /dev/null
+From a61693dfb0a20328e0f7c019cfc9f371af96097c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 11:59:21 -0600
+Subject: Input: iqs269a - do not poll during suspend or resume
+
+From: Jeff LaBundy <jeff@labundy.com>
+
+[ Upstream commit 18ab69c8ca5678324efbeed874b707ce7b2feae1 ]
+
+Polling the device while it transitions from automatic to manual
+power mode switching may keep the device from actually finishing
+the transition. The process appears to time out depending on the
+polling rate and the device's core clock frequency.
+
+This is ultimately unnecessary in the first place; instead it is
+sufficient to write the desired mode during initialization, then
+disable automatic switching at suspend. This eliminates the need
+to ensure the device is prepared for a manual change and removes
+the 'suspend_mode' variable.
+
+Similarly, polling the device while it transitions from one mode
+to another under manual control may time out as well. This added
+step does not appear to be necessary either, so drop it.
+
+Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
+Signed-off-by: Jeff LaBundy <jeff@labundy.com>
+Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
+Link: https://lore.kernel.org/r/Y7Rs+eEXlRw4Vq57@nixie71
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/misc/iqs269a.c | 118 +++++++++--------------------------
+ 1 file changed, 31 insertions(+), 87 deletions(-)
+
+diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
+index 07eda05d783ef..ff6cbc2f5d76c 100644
+--- a/drivers/input/misc/iqs269a.c
++++ b/drivers/input/misc/iqs269a.c
+@@ -148,9 +148,6 @@
+ #define IQS269_ATI_POLL_TIMEOUT_US (iqs269->delay_mult * 500000)
+ #define IQS269_ATI_STABLE_DELAY_MS (iqs269->delay_mult * 150)
+
+-#define IQS269_PWR_MODE_POLL_SLEEP_US IQS269_ATI_POLL_SLEEP_US
+-#define IQS269_PWR_MODE_POLL_TIMEOUT_US IQS269_ATI_POLL_TIMEOUT_US
+-
+ #define iqs269_irq_wait() usleep_range(200, 250)
+
+ enum iqs269_local_cap_size {
+@@ -295,7 +292,6 @@ struct iqs269_private {
+ struct input_dev *keypad;
+ struct input_dev *slider[IQS269_NUM_SL];
+ unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH];
+- unsigned int suspend_mode;
+ unsigned int delay_mult;
+ unsigned int ch_num;
+ bool hall_enable;
+@@ -767,17 +763,6 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269)
+ iqs269->hall_enable = device_property_present(&client->dev,
+ "azoteq,hall-enable");
+
+- if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode",
+- &val)) {
+- if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) {
+- dev_err(&client->dev, "Invalid suspend mode: %u\n",
+- val);
+- return -EINVAL;
+- }
+-
+- iqs269->suspend_mode = val;
+- }
+-
+ error = regmap_raw_read(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg,
+ sizeof(*sys_reg));
+ if (error)
+@@ -1005,6 +990,17 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269)
+ general &= ~IQS269_SYS_SETTINGS_DIS_AUTO;
+ general &= ~IQS269_SYS_SETTINGS_PWR_MODE_MASK;
+
++ if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode",
++ &val)) {
++ if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) {
++ dev_err(&client->dev, "Invalid suspend mode: %u\n",
++ val);
++ return -EINVAL;
++ }
++
++ general |= (val << IQS269_SYS_SETTINGS_PWR_MODE_SHIFT);
++ }
++
+ if (!device_property_read_u32(&client->dev, "azoteq,ulp-update",
+ &val)) {
+ if (val > IQS269_SYS_SETTINGS_ULP_UPDATE_MAX) {
+@@ -1687,59 +1683,30 @@ static int iqs269_probe(struct i2c_client *client)
+ return error;
+ }
+
++static u16 iqs269_general_get(struct iqs269_private *iqs269)
++{
++ u16 general = be16_to_cpu(iqs269->sys_reg.general);
++
++ general &= ~IQS269_SYS_SETTINGS_REDO_ATI;
++ general &= ~IQS269_SYS_SETTINGS_ACK_RESET;
++
++ return general | IQS269_SYS_SETTINGS_DIS_AUTO;
++}
++
+ static int iqs269_suspend(struct device *dev)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
+ struct i2c_client *client = iqs269->client;
+- unsigned int val;
+ int error;
++ u16 general = iqs269_general_get(iqs269);
+
+- if (!iqs269->suspend_mode)
++ if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK))
+ return 0;
+
+ disable_irq(client->irq);
+
+- /*
+- * Automatic power mode switching must be disabled before the device is
+- * forced into any particular power mode. In this case, the device will
+- * transition into normal-power mode.
+- */
+- error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS,
+- IQS269_SYS_SETTINGS_DIS_AUTO, ~0);
+- if (error)
+- goto err_irq;
+-
+- /*
+- * The following check ensures the device has completed its transition
+- * into normal-power mode before a manual mode switch is performed.
+- */
+- error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val,
+- !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK),
+- IQS269_PWR_MODE_POLL_SLEEP_US,
+- IQS269_PWR_MODE_POLL_TIMEOUT_US);
+- if (error)
+- goto err_irq;
+-
+- error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS,
+- IQS269_SYS_SETTINGS_PWR_MODE_MASK,
+- iqs269->suspend_mode <<
+- IQS269_SYS_SETTINGS_PWR_MODE_SHIFT);
+- if (error)
+- goto err_irq;
+-
+- /*
+- * This last check ensures the device has completed its transition into
+- * the desired power mode to prevent any spurious interrupts from being
+- * triggered after iqs269_suspend has already returned.
+- */
+- error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val,
+- (val & IQS269_SYS_FLAGS_PWR_MODE_MASK)
+- == (iqs269->suspend_mode <<
+- IQS269_SYS_FLAGS_PWR_MODE_SHIFT),
+- IQS269_PWR_MODE_POLL_SLEEP_US,
+- IQS269_PWR_MODE_POLL_TIMEOUT_US);
++ error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, general);
+
+-err_irq:
+ iqs269_irq_wait();
+ enable_irq(client->irq);
+
+@@ -1750,43 +1717,20 @@ static int iqs269_resume(struct device *dev)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
+ struct i2c_client *client = iqs269->client;
+- unsigned int val;
+ int error;
++ u16 general = iqs269_general_get(iqs269);
+
+- if (!iqs269->suspend_mode)
++ if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK))
+ return 0;
+
+ disable_irq(client->irq);
+
+- error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS,
+- IQS269_SYS_SETTINGS_PWR_MODE_MASK, 0);
+- if (error)
+- goto err_irq;
+-
+- /*
+- * This check ensures the device has returned to normal-power mode
+- * before automatic power mode switching is re-enabled.
+- */
+- error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val,
+- !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK),
+- IQS269_PWR_MODE_POLL_SLEEP_US,
+- IQS269_PWR_MODE_POLL_TIMEOUT_US);
+- if (error)
+- goto err_irq;
+-
+- error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS,
+- IQS269_SYS_SETTINGS_DIS_AUTO, 0);
+- if (error)
+- goto err_irq;
+-
+- /*
+- * This step reports any events that may have been "swallowed" as a
+- * result of polling PWR_MODE (which automatically acknowledges any
+- * pending interrupts).
+- */
+- error = iqs269_report(iqs269);
++ error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS,
++ general & ~IQS269_SYS_SETTINGS_PWR_MODE_MASK);
++ if (!error)
++ error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS,
++ general & ~IQS269_SYS_SETTINGS_DIS_AUTO);
+
+-err_irq:
+ iqs269_irq_wait();
+ enable_irq(client->irq);
+
+--
+2.43.0
+
--- /dev/null
+From 7b7e08db622bb871634e1a9c6efb6e0873c78738 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 11:58:31 -0600
+Subject: Input: iqs269a - drop unused device node references
+
+From: Jeff LaBundy <jeff@labundy.com>
+
+[ Upstream commit 59bc9cb3b80abaa42643abede0d5db8477901d9c ]
+
+Each call to device/fwnode_get_named_child_node() must be matched
+with a call to fwnode_handle_put() once the corresponding node is
+no longer in use. This ensures a reference count remains balanced
+in the case of dynamic device tree support.
+
+Currently, the driver does not call fwnode_handle_put() on nested
+event nodes. This patch solves this problem by adding the missing
+instances of fwnode_handle_put().
+
+As part of this change, the logic which parses each channel's key
+code is gently refactored in order to reduce the number of places
+from which fwnode_handle_put() is called.
+
+Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
+Signed-off-by: Jeff LaBundy <jeff@labundy.com>
+Link: https://lore.kernel.org/r/Y7Rsx68k/gvDVXAt@nixie71
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/misc/iqs269a.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
+index a348247d3d38f..ea3c97c5f764f 100644
+--- a/drivers/input/misc/iqs269a.c
++++ b/drivers/input/misc/iqs269a.c
+@@ -694,6 +694,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
+ dev_err(&client->dev,
+ "Invalid channel %u threshold: %u\n",
+ reg, val);
++ fwnode_handle_put(ev_node);
+ return -EINVAL;
+ }
+
+@@ -707,6 +708,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
+ dev_err(&client->dev,
+ "Invalid channel %u hysteresis: %u\n",
+ reg, val);
++ fwnode_handle_put(ev_node);
+ return -EINVAL;
+ }
+
+@@ -721,8 +723,16 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
+ }
+ }
+
+- if (fwnode_property_read_u32(ev_node, "linux,code", &val))
++ error = fwnode_property_read_u32(ev_node, "linux,code", &val);
++ fwnode_handle_put(ev_node);
++ if (error == -EINVAL) {
+ continue;
++ } else if (error) {
++ dev_err(&client->dev,
++ "Failed to read channel %u code: %d\n", reg,
++ error);
++ return error;
++ }
+
+ switch (reg) {
+ case IQS269_CHx_HALL_ACTIVE:
+--
+2.43.0
+
--- /dev/null
+From 74300d9b8f7b3d9d31b226a6ee767db2e4fca2cc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 11:58:59 -0600
+Subject: Input: iqs269a - increase interrupt handler return delay
+
+From: Jeff LaBundy <jeff@labundy.com>
+
+[ Upstream commit e023cc4abde3c01b895660b0e5a8488deb36b8c1 ]
+
+The time the device takes to deassert its RDY output following an
+I2C stop condition scales with the core clock frequency.
+
+To prevent level-triggered interrupts from being reasserted after
+the interrupt handler returns, increase the time before returning
+to account for the worst-case delay (~140 us) plus margin.
+
+Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
+Signed-off-by: Jeff LaBundy <jeff@labundy.com>
+Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
+Link: https://lore.kernel.org/r/Y7Rs484ypy4dab5G@nixie71
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/misc/iqs269a.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
+index 2124d08c55b79..1530efd301c24 100644
+--- a/drivers/input/misc/iqs269a.c
++++ b/drivers/input/misc/iqs269a.c
+@@ -151,7 +151,7 @@
+ #define IQS269_PWR_MODE_POLL_SLEEP_US IQS269_ATI_POLL_SLEEP_US
+ #define IQS269_PWR_MODE_POLL_TIMEOUT_US IQS269_ATI_POLL_TIMEOUT_US
+
+-#define iqs269_irq_wait() usleep_range(100, 150)
++#define iqs269_irq_wait() usleep_range(200, 250)
+
+ enum iqs269_local_cap_size {
+ IQS269_LOCAL_CAP_SIZE_0,
+--
+2.43.0
+
--- /dev/null
+From fbe9dcd3e77d590cfe16a0d40ee7dcde61d8af22 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 2 Jan 2023 18:17:41 +0000
+Subject: Input: iqs269a - switch to DEFINE_SIMPLE_DEV_PM_OPS() and
+ pm_sleep_ptr()
+
+From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+
+[ Upstream commit 29eac950768a48651e2389f7d3f2ad597f6e58d1 ]
+
+SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
+against unused function warnings. The new combination of pm_sleep_ptr()
+and DEFINE_SIMPLE_DEV_PM_OPS() allows the compiler to see the functions,
+thus suppressing the warning, but still allowing the unused code to be
+removed. Thus also drop the __maybe_unused markings.
+
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Cc: Jeff LaBundy <jeff@labundy.com>
+Reviewed-by: Jeff LaBundy <jeff@labundy.com>
+Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
+Link: https://lore.kernel.org/r/20230102181842.718010-9-jic23@kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Stable-dep-of: 18ab69c8ca56 ("Input: iqs269a - do not poll during suspend or resume")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/misc/iqs269a.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
+index 1530efd301c24..07eda05d783ef 100644
+--- a/drivers/input/misc/iqs269a.c
++++ b/drivers/input/misc/iqs269a.c
+@@ -1687,7 +1687,7 @@ static int iqs269_probe(struct i2c_client *client)
+ return error;
+ }
+
+-static int __maybe_unused iqs269_suspend(struct device *dev)
++static int iqs269_suspend(struct device *dev)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
+ struct i2c_client *client = iqs269->client;
+@@ -1746,7 +1746,7 @@ static int __maybe_unused iqs269_suspend(struct device *dev)
+ return error;
+ }
+
+-static int __maybe_unused iqs269_resume(struct device *dev)
++static int iqs269_resume(struct device *dev)
+ {
+ struct iqs269_private *iqs269 = dev_get_drvdata(dev);
+ struct i2c_client *client = iqs269->client;
+@@ -1793,7 +1793,7 @@ static int __maybe_unused iqs269_resume(struct device *dev)
+ return error;
+ }
+
+-static SIMPLE_DEV_PM_OPS(iqs269_pm, iqs269_suspend, iqs269_resume);
++static DEFINE_SIMPLE_DEV_PM_OPS(iqs269_pm, iqs269_suspend, iqs269_resume);
+
+ static const struct of_device_id iqs269_of_match[] = {
+ { .compatible = "azoteq,iqs269a" },
+@@ -1805,7 +1805,7 @@ static struct i2c_driver iqs269_i2c_driver = {
+ .driver = {
+ .name = "iqs269a",
+ .of_match_table = iqs269_of_match,
+- .pm = &iqs269_pm,
++ .pm = pm_sleep_ptr(&iqs269_pm),
+ },
+ .probe_new = iqs269_probe,
+ };
+--
+2.43.0
+
--- /dev/null
+From eb50607f005e46dfdbb2af59099367ec64118857 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 7 Jan 2022 17:52:54 +0800
+Subject: kernel/sched: Remove dl_boosted flag comment
+
+From: Hui Su <suhui_kernel@163.com>
+
+[ Upstream commit 0e3872499de1a1230cef5221607d71aa09264bd5 ]
+
+since commit 2279f540ea7d ("sched/deadline: Fix priority
+inheritance with multiple scheduling classes"), we should not
+keep it here.
+
+Signed-off-by: Hui Su <suhui_kernel@163.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
+Link: https://lore.kernel.org/r/20220107095254.GA49258@localhost.localdomain
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/sched.h | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/include/linux/sched.h b/include/linux/sched.h
+index 7bfc2b45cd99b..9b3cfe685cb45 100644
+--- a/include/linux/sched.h
++++ b/include/linux/sched.h
+@@ -608,10 +608,6 @@ struct sched_dl_entity {
+ * task has to wait for a replenishment to be performed at the
+ * next firing of dl_timer.
+ *
+- * @dl_boosted tells if we are boosted due to DI. If so we are
+- * outside bandwidth enforcement mechanism (but only until we
+- * exit the critical section);
+- *
+ * @dl_yielded tells if task gave up the CPU before consuming
+ * all its available runtime during the last job.
+ *
+--
+2.43.0
+
--- /dev/null
+From c79fa4d8db67dafd453fe4a9bd78376d64824dbc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 May 2023 09:56:07 +0800
+Subject: md: fix data corruption for raid456 when reshape restart while grow
+ up
+
+From: Yu Kuai <yukuai3@huawei.com>
+
+[ Upstream commit 873f50ece41aad5c4f788a340960c53774b5526e ]
+
+Currently, if reshape is interrupted, echo "reshape" to sync_action will
+restart reshape from scratch, for example:
+
+echo frozen > sync_action
+echo reshape > sync_action
+
+This will corrupt data before reshape_position if the array is growing,
+fix the problem by continue reshape from reshape_position.
+
+Reported-by: Peter Neuwirth <reddunur@online.de>
+Link: https://lore.kernel.org/linux-raid/e2f96772-bfbc-f43b-6da1-f520e5164536@online.de/
+Signed-off-by: Yu Kuai <yukuai3@huawei.com>
+Signed-off-by: Song Liu <song@kernel.org>
+Link: https://lore.kernel.org/r/20230512015610.821290-3-yukuai1@huaweicloud.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/md/md.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/md/md.c b/drivers/md/md.c
+index ff65e5eddfa18..a17f2f725822a 100644
+--- a/drivers/md/md.c
++++ b/drivers/md/md.c
+@@ -4919,11 +4919,21 @@ action_store(struct mddev *mddev, const char *page, size_t len)
+ return -EINVAL;
+ err = mddev_lock(mddev);
+ if (!err) {
+- if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
++ if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) {
+ err = -EBUSY;
+- else {
++ } else if (mddev->reshape_position == MaxSector ||
++ mddev->pers->check_reshape == NULL ||
++ mddev->pers->check_reshape(mddev)) {
+ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
+ err = mddev->pers->start_reshape(mddev);
++ } else {
++ /*
++ * If reshape is still in progress, and
++ * md_check_recovery() can continue to reshape,
++ * don't restart reshape because data can be
++ * corrupted for raid456.
++ */
++ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
+ }
+ mddev_unlock(mddev);
+ }
+--
+2.43.0
+
--- /dev/null
+From 776470301835725d9b8e598726a72e238075bb5c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 May 2023 21:11:00 +0800
+Subject: md/raid10: prevent soft lockup while flush writes
+
+From: Yu Kuai <yukuai3@huawei.com>
+
+[ Upstream commit 010444623e7f4da6b4a4dd603a7da7469981e293 ]
+
+Currently, there is no limit for raid1/raid10 plugged bio. While flushing
+writes, raid1 has cond_resched() while raid10 doesn't, and too many
+writes can cause soft lockup.
+
+Follow up soft lockup can be triggered easily with writeback test for
+raid10 with ramdisks:
+
+watchdog: BUG: soft lockup - CPU#10 stuck for 27s! [md0_raid10:1293]
+Call Trace:
+ <TASK>
+ call_rcu+0x16/0x20
+ put_object+0x41/0x80
+ __delete_object+0x50/0x90
+ delete_object_full+0x2b/0x40
+ kmemleak_free+0x46/0xa0
+ slab_free_freelist_hook.constprop.0+0xed/0x1a0
+ kmem_cache_free+0xfd/0x300
+ mempool_free_slab+0x1f/0x30
+ mempool_free+0x3a/0x100
+ bio_free+0x59/0x80
+ bio_put+0xcf/0x2c0
+ free_r10bio+0xbf/0xf0
+ raid_end_bio_io+0x78/0xb0
+ one_write_done+0x8a/0xa0
+ raid10_end_write_request+0x1b4/0x430
+ bio_endio+0x175/0x320
+ brd_submit_bio+0x3b9/0x9b7 [brd]
+ __submit_bio+0x69/0xe0
+ submit_bio_noacct_nocheck+0x1e6/0x5a0
+ submit_bio_noacct+0x38c/0x7e0
+ flush_pending_writes+0xf0/0x240
+ raid10d+0xac/0x1ed0
+
+Fix the problem by adding cond_resched() to raid10 like what raid1 did.
+
+Note that unlimited plugged bio still need to be optimized, for example,
+in the case of lots of dirty pages writeback, this will take lots of
+memory and io will spend a long time in plug, hence io latency is bad.
+
+Signed-off-by: Yu Kuai <yukuai3@huawei.com>
+Signed-off-by: Song Liu <song@kernel.org>
+Link: https://lore.kernel.org/r/20230529131106.2123367-2-yukuai1@huaweicloud.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/md/raid10.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
+index 910e7db7d5736..ae84aaa1645c2 100644
+--- a/drivers/md/raid10.c
++++ b/drivers/md/raid10.c
+@@ -903,6 +903,7 @@ static void flush_pending_writes(struct r10conf *conf)
+ else
+ submit_bio_noacct(bio);
+ bio = next;
++ cond_resched();
+ }
+ blk_finish_plug(&plug);
+ } else
+@@ -1116,6 +1117,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
+ else
+ submit_bio_noacct(bio);
+ bio = next;
++ cond_resched();
+ }
+ kfree(plug);
+ }
+--
+2.43.0
+
--- /dev/null
+From 7abfe02b0575ed80b286b970dd04d1be42c5bc37 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 17 Feb 2023 12:07:49 -0800
+Subject: MIPS: SMP-CPS: fix build error when HOTPLUG_CPU not set
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+[ Upstream commit 6f02e39fa40f16c24e7a5c599a854c0d1682788d ]
+
+When MIPS_CPS=y, MIPS_CPS_PM is not set, HOTPLUG_CPU is not set, and
+KEXEC=y, cps_shutdown_this_cpu() attempts to call cps_pm_enter_state(),
+which is not built when MIPS_CPS_PM is not set.
+Conditionally execute the else branch based on CONFIG_HOTPLUG_CPU
+to remove the build error.
+This build failure is from a randconfig file.
+
+mips-linux-ld: arch/mips/kernel/smp-cps.o: in function `$L162':
+smp-cps.c:(.text.cps_kexec_nonboot_cpu+0x31c): undefined reference to `cps_pm_enter_state'
+
+Fixes: 1447864bee4c ("MIPS: kexec: CPS systems to halt nonboot CPUs")
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Cc: Dengcheng Zhu <dzhu@wavecomp.com>
+Cc: Paul Burton <paulburton@kernel.org>
+Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
+Cc: linux-mips@vger.kernel.org
+Cc: Sergei Shtylyov <sergei.shtylyov@gmail.com>
+Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/mips/kernel/smp-cps.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
+index bcd6a944b8397..f2df0cae1b4d9 100644
+--- a/arch/mips/kernel/smp-cps.c
++++ b/arch/mips/kernel/smp-cps.c
+@@ -424,9 +424,11 @@ static void cps_shutdown_this_cpu(enum cpu_death death)
+ wmb();
+ }
+ } else {
+- pr_debug("Gating power to core %d\n", core);
+- /* Power down the core */
+- cps_pm_enter_state(CPS_PM_POWER_GATED);
++ if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) {
++ pr_debug("Gating power to core %d\n", core);
++ /* Power down the core */
++ cps_pm_enter_state(CPS_PM_POWER_GATED);
++ }
+ }
+ }
+
+--
+2.43.0
+
--- /dev/null
+From 2290c353d0ae687ceb52667cba94ca8ad60f4702 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 19 Feb 2023 15:15:25 -0800
+Subject: MIPS: vpe-mt: drop physical_memsize
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+[ Upstream commit 91dc288f4edf0d768e46c2c6d33e0ab703403459 ]
+
+When neither LANTIQ nor MIPS_MALTA is set, 'physical_memsize' is not
+declared. This causes the build to fail with:
+
+mips-linux-ld: arch/mips/kernel/vpe-mt.o: in function `vpe_run':
+arch/mips/kernel/vpe-mt.c:(.text.vpe_run+0x280): undefined reference to `physical_memsize'
+
+LANTIQ is not using 'physical_memsize' and MIPS_MALTA's use of it is
+self-contained in mti-malta/malta-dtshim.c.
+Use of physical_memsize in vpe-mt.c appears to be unused, so eliminate
+this loader mode completely and require VPE programs to be compiled with
+DFLT_STACK_SIZE and DFLT_HEAP_SIZE defined.
+
+Fixes: 9050d50e2244 ("MIPS: lantiq: Set physical_memsize")
+Fixes: 1a2a6d7e8816 ("MIPS: APRP: Split VPE loader into separate files.")
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Reported-by: kernel test robot <lkp@intel.com>
+Link: https://lore.kernel.org/all/202302030625.2g3E98sY-lkp@intel.com/
+Cc: Dengcheng Zhu <dzhu@wavecomp.com>
+Cc: John Crispin <john@phrozen.org>
+Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
+Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
+Cc: "Steven J. Hill" <Steven.Hill@imgtec.com>
+Cc: Qais Yousef <Qais.Yousef@imgtec.com>
+Cc: Yang Yingliang <yangyingliang@huawei.com>
+Cc: Hauke Mehrtens <hauke@hauke-m.de>
+Cc: James Hogan <jhogan@kernel.org>
+Cc: linux-mips@vger.kernel.org
+Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/mips/include/asm/vpe.h | 1 -
+ arch/mips/kernel/vpe-mt.c | 7 +++----
+ arch/mips/lantiq/prom.c | 6 ------
+ 3 files changed, 3 insertions(+), 11 deletions(-)
+
+diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h
+index baa949a744cb4..ef7e078296079 100644
+--- a/arch/mips/include/asm/vpe.h
++++ b/arch/mips/include/asm/vpe.h
+@@ -102,7 +102,6 @@ struct vpe_control {
+ struct list_head tc_list; /* Thread contexts */
+ };
+
+-extern unsigned long physical_memsize;
+ extern struct vpe_control vpecontrol;
+ extern const struct file_operations vpe_fops;
+
+diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
+index 84a82b551ec35..223d6274f2e5b 100644
+--- a/arch/mips/kernel/vpe-mt.c
++++ b/arch/mips/kernel/vpe-mt.c
+@@ -92,12 +92,11 @@ int vpe_run(struct vpe *v)
+ write_tc_c0_tchalt(read_tc_c0_tchalt() & ~TCHALT_H);
+
+ /*
+- * The sde-kit passes 'memsize' to __start in $a3, so set something
+- * here... Or set $a3 to zero and define DFLT_STACK_SIZE and
+- * DFLT_HEAP_SIZE when you compile your program
++ * We don't pass the memsize here, so VPE programs need to be
++ * compiled with DFLT_STACK_SIZE and DFLT_HEAP_SIZE defined.
+ */
++ mttgpr(7, 0);
+ mttgpr(6, v->ntcs);
+- mttgpr(7, physical_memsize);
+
+ /* set up VPE1 */
+ /*
+diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c
+index bc9f58fcbdf94..86c743747e79a 100644
+--- a/arch/mips/lantiq/prom.c
++++ b/arch/mips/lantiq/prom.c
+@@ -22,12 +22,6 @@
+ DEFINE_SPINLOCK(ebu_lock);
+ EXPORT_SYMBOL_GPL(ebu_lock);
+
+-/*
+- * This is needed by the VPE loader code, just set it to 0 and assume
+- * that the firmware hardcodes this value to something useful.
+- */
+-unsigned long physical_memsize = 0L;
+-
+ /*
+ * this struct is filled by the soc specific detection code and holds
+ * information about the specific soc type, revision and name
+--
+2.43.0
+
--- /dev/null
+From 3e41c7e0044d19f4236098272f100350418a0097 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Dec 2021 00:21:01 +0000
+Subject: mmc: jz4740: Use the new PM macros
+
+From: Paul Cercueil <paul@crapouillou.net>
+
+[ Upstream commit e0d64ecc621715e9c7807e952b68475c62bbf630 ]
+
+ - Use DEFINE_SIMPLE_DEV_PM_OPS() instead of the SIMPLE_DEV_PM_OPS()
+ macro. This makes it possible to remove the __maybe_unused flags
+ on the callback functions.
+
+ - Since we only have callbacks for suspend/resume, we can conditionally
+ compile the dev_pm_ops structure for when CONFIG_PM_SLEEP is enabled;
+ so use the pm_sleep_ptr() macro instead of pm_ptr().
+
+Signed-off-by: Paul Cercueil <paul@crapouillou.net>
+Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: 18ab69c8ca56 ("Input: iqs269a - do not poll during suspend or resume")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/jz4740_mmc.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
+index 8586447d4b4f2..ef3fe837b49d2 100644
+--- a/drivers/mmc/host/jz4740_mmc.c
++++ b/drivers/mmc/host/jz4740_mmc.c
+@@ -1133,17 +1133,17 @@ static int jz4740_mmc_remove(struct platform_device *pdev)
+ return 0;
+ }
+
+-static int __maybe_unused jz4740_mmc_suspend(struct device *dev)
++static int jz4740_mmc_suspend(struct device *dev)
+ {
+ return pinctrl_pm_select_sleep_state(dev);
+ }
+
+-static int __maybe_unused jz4740_mmc_resume(struct device *dev)
++static int jz4740_mmc_resume(struct device *dev)
+ {
+ return pinctrl_select_default_state(dev);
+ }
+
+-static SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,
++DEFINE_SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,
+ jz4740_mmc_resume);
+
+ static struct platform_driver jz4740_mmc_driver = {
+@@ -1153,7 +1153,7 @@ static struct platform_driver jz4740_mmc_driver = {
+ .name = "jz4740-mmc",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ .of_match_table = of_match_ptr(jz4740_mmc_of_match),
+- .pm = pm_ptr(&jz4740_mmc_pm_ops),
++ .pm = pm_sleep_ptr(&jz4740_mmc_pm_ops),
+ },
+ };
+
+--
+2.43.0
+
--- /dev/null
+From a6f95fd4c6f845546887cba268df3eaf46b8feec Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Dec 2021 00:21:02 +0000
+Subject: mmc: mxc: Use the new PM macros
+
+From: Paul Cercueil <paul@crapouillou.net>
+
+[ Upstream commit 2cdbd92c2d1dff07ad56c39f5857ee644bbd2c8a ]
+
+Use DEFINE_SIMPLE_DEV_PM_OPS() instead of the SIMPLE_DEV_PM_OPS()
+macro, along with using pm_sleep_ptr() as this driver doesn't handle
+runtime PM.
+
+This makes it possible to remove the #ifdef CONFIG_PM guard around
+the suspend/resume functions.
+
+Signed-off-by: Paul Cercueil <paul@crapouillou.net>
+Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: 18ab69c8ca56 ("Input: iqs269a - do not poll during suspend or resume")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/mxcmmc.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
+index 97227ad717150..b5f65f39ced1c 100644
+--- a/drivers/mmc/host/mxcmmc.c
++++ b/drivers/mmc/host/mxcmmc.c
+@@ -1185,7 +1185,6 @@ static int mxcmci_remove(struct platform_device *pdev)
+ return 0;
+ }
+
+-#ifdef CONFIG_PM_SLEEP
+ static int mxcmci_suspend(struct device *dev)
+ {
+ struct mmc_host *mmc = dev_get_drvdata(dev);
+@@ -1212,9 +1211,8 @@ static int mxcmci_resume(struct device *dev)
+
+ return ret;
+ }
+-#endif
+
+-static SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
++DEFINE_SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
+
+ static struct platform_driver mxcmci_driver = {
+ .probe = mxcmci_probe,
+@@ -1222,7 +1220,7 @@ static struct platform_driver mxcmci_driver = {
+ .driver = {
+ .name = DRIVER_NAME,
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+- .pm = &mxcmci_pm_ops,
++ .pm = pm_sleep_ptr(&mxcmci_pm_ops),
+ .of_match_table = mxcmci_of_match,
+ }
+ };
+--
+2.43.0
+
--- /dev/null
+From 17c9f717b09f7dc705a1d4506c2a158b2b0977ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 29 Dec 2022 12:15:24 -0600
+Subject: mtd: rawnand: sunxi: Fix the size of the last OOB region
+
+From: Samuel Holland <samuel@sholland.org>
+
+[ Upstream commit 34569d869532b54d6e360d224a0254dcdd6a1785 ]
+
+The previous code assigned to the wrong structure member.
+
+Fixes: c66811e6d350 ("mtd: nand: sunxi: switch to mtd_ooblayout_ops")
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+Acked-By: Dhruva Gole <d-gole@ti.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20221229181526.53766-6-samuel@sholland.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
+index ea953e31933eb..e03dcdd8bd589 100644
+--- a/drivers/mtd/nand/raw/sunxi_nand.c
++++ b/drivers/mtd/nand/raw/sunxi_nand.c
+@@ -1609,7 +1609,7 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,
+ if (section < ecc->steps)
+ oobregion->length = 4;
+ else
+- oobregion->offset = mtd->oobsize - oobregion->offset;
++ oobregion->length = mtd->oobsize - oobregion->offset;
+
+ return 0;
+ }
+--
+2.43.0
+
--- /dev/null
+From 9317d281a2033af90902fae95bd96de5b6b845e6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 5 Jun 2023 20:21:59 +0800
+Subject: nbd: Add the maximum limit of allocated index in nbd_dev_add
+
+From: Zhong Jinghua <zhongjinghua@huawei.com>
+
+[ Upstream commit f12bc113ce904777fd6ca003b473b427782b3dde ]
+
+If the index allocated by idr_alloc greater than MINORMASK >> part_shift,
+the device number will overflow, resulting in failure to create a block
+device.
+
+Fix it by imiting the size of the max allocation.
+
+Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Link: https://lore.kernel.org/r/20230605122159.2134384-1-zhongjinghua@huaweicloud.com
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/block/nbd.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
+index e563aa407e888..d379a047d4273 100644
+--- a/drivers/block/nbd.c
++++ b/drivers/block/nbd.c
+@@ -1715,7 +1715,8 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
+ if (err == -ENOSPC)
+ err = -EEXIST;
+ } else {
+- err = idr_alloc(&nbd_index_idr, nbd, 0, 0, GFP_KERNEL);
++ err = idr_alloc(&nbd_index_idr, nbd, 0,
++ (MINORMASK >> part_shift) + 1, GFP_KERNEL);
+ if (err >= 0)
+ index = err;
+ }
+--
+2.43.0
+
--- /dev/null
+From 15c61757f25e09d23495ff8178ccba9fd741c5af Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Dec 2021 01:44:36 -0800
+Subject: net: ethernet: ti: add missing of_node_put before return
+
+From: Wang Qing <wangqing@vivo.com>
+
+[ Upstream commit be565ec71d1d59438bed0c7ed0a252a327e0b0ef ]
+
+Fix following coccicheck warning:
+WARNING: Function "for_each_child_of_node"
+should have of_node_put() before return.
+
+Early exits from for_each_child_of_node should decrement the
+node reference counter.
+
+Signed-off-by: Wang Qing <wangqing@vivo.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/ti/am65-cpsw-nuss.c | 29 ++++++++++++++++--------
+ 1 file changed, 20 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+index 1fa6f0dacd2de..f94d6d322df42 100644
+--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
++++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+@@ -1856,13 +1856,14 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
+ if (ret < 0) {
+ dev_err(dev, "%pOF error reading port_id %d\n",
+ port_np, ret);
+- return ret;
++ goto of_node_put;
+ }
+
+ if (!port_id || port_id > common->port_num) {
+ dev_err(dev, "%pOF has invalid port_id %u %s\n",
+ port_np, port_id, port_np->name);
+- return -EINVAL;
++ ret = -EINVAL;
++ goto of_node_put;
+ }
+
+ port = am65_common_get_port(common, port_id);
+@@ -1878,8 +1879,10 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
+ (AM65_CPSW_NU_FRAM_PORT_OFFSET * (port_id - 1));
+
+ port->slave.mac_sl = cpsw_sl_get("am65", dev, port->port_base);
+- if (IS_ERR(port->slave.mac_sl))
+- return PTR_ERR(port->slave.mac_sl);
++ if (IS_ERR(port->slave.mac_sl)) {
++ ret = PTR_ERR(port->slave.mac_sl);
++ goto of_node_put;
++ }
+
+ port->disabled = !of_device_is_available(port_np);
+ if (port->disabled) {
+@@ -1892,7 +1895,7 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
+ ret = PTR_ERR(port->slave.ifphy);
+ dev_err(dev, "%pOF error retrieving port phy: %d\n",
+ port_np, ret);
+- return ret;
++ goto of_node_put;
+ }
+
+ port->slave.mac_only =
+@@ -1901,10 +1904,12 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
+ /* get phy/link info */
+ if (of_phy_is_fixed_link(port_np)) {
+ ret = of_phy_register_fixed_link(port_np);
+- if (ret)
+- return dev_err_probe(dev, ret,
++ if (ret) {
++ ret = dev_err_probe(dev, ret,
+ "failed to register fixed-link phy %pOF\n",
+ port_np);
++ goto of_node_put;
++ }
+ port->slave.phy_node = of_node_get(port_np);
+ } else {
+ port->slave.phy_node =
+@@ -1914,14 +1919,15 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
+ if (!port->slave.phy_node) {
+ dev_err(dev,
+ "slave[%d] no phy found\n", port_id);
+- return -ENODEV;
++ ret = -ENODEV;
++ goto of_node_put;
+ }
+
+ ret = of_get_phy_mode(port_np, &port->slave.phy_if);
+ if (ret) {
+ dev_err(dev, "%pOF read phy-mode err %d\n",
+ port_np, ret);
+- return ret;
++ goto of_node_put;
+ }
+
+ ret = of_get_mac_address(port_np, port->slave.mac_addr);
+@@ -1944,6 +1950,11 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
+ }
+
+ return 0;
++
++of_node_put:
++ of_node_put(port_np);
++ of_node_put(node);
++ return ret;
+ }
+
+ static void am65_cpsw_pcpu_stats_free(void *data)
+--
+2.43.0
+
--- /dev/null
+From c0a45dd7eaf0d2d6f40c33a5f8e8d0bba12c9281 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 10 Jun 2023 20:30:15 -0700
+Subject: net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs
+
+From: Peilin Ye <peilin.ye@bytedance.com>
+
+[ Upstream commit 2d5f6a8d7aef7852a9ecc555f88c673a1c91754f ]
+
+Grafting ingress and clsact Qdiscs does not need a for-loop in
+qdisc_graft(). Refactor it. No functional changes intended.
+
+Tested-by: Pedro Tammela <pctammela@mojatatu.com>
+Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
+Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_api.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
+index fa79dbd3601fa..7fdc2c1f87561 100644
+--- a/net/sched/sch_api.c
++++ b/net/sched/sch_api.c
+@@ -1044,12 +1044,12 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
+
+ if (parent == NULL) {
+ unsigned int i, num_q, ingress;
++ struct netdev_queue *dev_queue;
+
+ ingress = 0;
+ num_q = dev->num_tx_queues;
+ if ((q && q->flags & TCQ_F_INGRESS) ||
+ (new && new->flags & TCQ_F_INGRESS)) {
+- num_q = 1;
+ ingress = 1;
+ if (!dev_ingress_queue(dev)) {
+ NL_SET_ERR_MSG(extack, "Device does not have an ingress queue");
+@@ -1065,18 +1065,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
+ if (new && new->ops->attach && !ingress)
+ goto skip;
+
+- for (i = 0; i < num_q; i++) {
+- struct netdev_queue *dev_queue = dev_ingress_queue(dev);
+-
+- if (!ingress)
++ if (!ingress) {
++ for (i = 0; i < num_q; i++) {
+ dev_queue = netdev_get_tx_queue(dev, i);
++ old = dev_graft_qdisc(dev_queue, new);
+
+- old = dev_graft_qdisc(dev_queue, new);
+- if (new && i > 0)
+- qdisc_refcount_inc(new);
+-
+- if (!ingress)
++ if (new && i > 0)
++ qdisc_refcount_inc(new);
+ qdisc_put(old);
++ }
++ } else {
++ dev_queue = dev_ingress_queue(dev);
++ old = dev_graft_qdisc(dev_queue, new);
+ }
+
+ skip:
+--
+2.43.0
+
--- /dev/null
+From e3ac677512b571f01e73a2a19c506d97927fd4e7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 26 Jul 2022 12:44:35 +0200
+Subject: netfilter: nf_tables: add rescheduling points during loop detection
+ walks
+
+From: Florian Westphal <fw@strlen.de>
+
+[ Upstream commit 81ea010667417ef3f218dfd99b69769fe66c2b67 ]
+
+Add explicit rescheduling points during ruleset walk.
+
+Switching to a faster algorithm is possible but this is a much
+smaller change, suitable for nf tree.
+
+Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1460
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_tables_api.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
+index 3ad2b22886ff0..361fbbd430ad8 100644
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -3442,6 +3442,8 @@ int nft_chain_validate(const struct nft_ctx *ctx, const struct nft_chain *chain)
+ if (err < 0)
+ return err;
+ }
++
++ cond_resched();
+ }
+
+ return 0;
+@@ -10041,9 +10043,13 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
+ break;
+ }
+ }
++
++ cond_resched();
+ }
+
+ list_for_each_entry(set, &ctx->table->sets, list) {
++ cond_resched();
++
+ if (!nft_is_active_next(ctx->net, set))
+ continue;
+ if (!(set->flags & NFT_SET_MAP) ||
+--
+2.43.0
+
--- /dev/null
+From dfc5eb9a62e11da54741bea3382ac934948736e6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 19 Jun 2021 10:09:08 -0300
+Subject: perf beauty: Update copy of linux/socket.h with the kernel sources
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+[ Upstream commit 6da2a45e15af4f706fed211f8eb57a40cc7abfc7 ]
+
+To pick the changes in:
+
+ 99ce45d5e7dbde39 ("mctp: Implement extended addressing")
+ 55c42fa7fa331f98 ("mptcp: add MPTCP_INFO getsockopt")
+
+That don't result in any changes in the tables generated from that
+header.
+
+A table generator for setsockopt is needed, probably will be done in the
+5.16 cycle.
+
+This silences this perf build warning:
+
+ Warning: Kernel ABI header at 'tools/perf/trace/beauty/include/linux/socket.h' differs from latest version at 'include/linux/socket.h'
+ diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
+
+Cc: David S. Miller <davem@davemloft.net>
+Cc: Florian Westphal <fw@strlen.de>
+Cc: Jeremy Kerr <jk@codeconstruct.com.au>
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/trace/beauty/include/linux/socket.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tools/perf/trace/beauty/include/linux/socket.h b/tools/perf/trace/beauty/include/linux/socket.h
+index 041d6032a3489..8ef26d89ef495 100644
+--- a/tools/perf/trace/beauty/include/linux/socket.h
++++ b/tools/perf/trace/beauty/include/linux/socket.h
+@@ -364,6 +364,8 @@ struct ucred {
+ #define SOL_KCM 281
+ #define SOL_TLS 282
+ #define SOL_XDP 283
++#define SOL_MPTCP 284
++#define SOL_MCTP 285
+
+ /* IPX options */
+ #define IPX_TYPE 1
+--
+2.43.0
+
--- /dev/null
+From 24c016d5f5685fb361fe42c8302f29513cac931a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 13 Aug 2022 10:25:04 +1200
+Subject: platform/x86: asus-wmi: Document the dgpu_disable sysfs attribute
+
+From: Luke D. Jones <luke@ljones.dev>
+
+[ Upstream commit 7e64c486e807c8edfbd3a0c8e44ad7a1896dbec8 ]
+
+The dgpu_disable attribute was not documented, this adds the
+required documentation.
+
+Fixes: 98829e84dc67 ("asus-wmi: Add dgpu disable method")
+Signed-off-by: Luke D. Jones <luke@ljones.dev>
+Link: https://lore.kernel.org/r/20220812222509.292692-2-luke@ljones.dev
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/ABI/testing/sysfs-platform-asus-wmi | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
+index 04885738cf156..0f8f0772d6f3b 100644
+--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
++++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
+@@ -57,3 +57,12 @@ Description:
+ * 0 - default,
+ * 1 - overboost,
+ * 2 - silent
++
++What: /sys/devices/platform/<platform>/dgpu_disable
++Date: Aug 2022
++KernelVersion: 5.17
++Contact: "Luke Jones" <luke@ljones.dev>
++Description:
++ Disable discrete GPU:
++ * 0 - Enable dGPU,
++ * 1 - Disable dGPU
+--
+2.43.0
+
--- /dev/null
+From 49c5084be681b0527616ebf32894fd467b073cd9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Dec 2021 00:21:00 +0000
+Subject: PM: core: Add new *_PM_OPS macros, deprecate old ones
+
+From: Paul Cercueil <paul@crapouillou.net>
+
+[ Upstream commit 1a3c7bb088266fa2db017be299f91f1c1894c857 ]
+
+This commit introduces the following macros:
+
+SYSTEM_SLEEP_PM_OPS()
+LATE_SYSTEM_SLEEP_PM_OPS()
+NOIRQ_SYSTEM_SLEEP_PM_OPS()
+RUNTIME_PM_OPS()
+
+These new macros are very similar to their SET_*_PM_OPS() equivalent.
+They however differ in the fact that the callbacks they set will always
+be seen as referenced by the compiler. This means that the callback
+functions don't need to be wrapped with a #ifdef CONFIG_PM guard, or
+tagged with __maybe_unused, to prevent the compiler from complaining
+about unused static symbols. The compiler will then simply evaluate at
+compile time whether or not these symbols are dead code.
+
+The callbacks that are only useful with CONFIG_PM_SLEEP is enabled, are
+now also wrapped with a new pm_sleep_ptr() macro, which is inspired from
+pm_ptr(). This is needed for drivers that use different callbacks for
+sleep and runtime PM, to handle the case where CONFIG_PM is set and
+CONFIG_PM_SLEEP is not.
+
+This commit also deprecates the following macros:
+
+SIMPLE_DEV_PM_OPS()
+UNIVERSAL_DEV_PM_OPS()
+
+And introduces the following macros:
+
+DEFINE_SIMPLE_DEV_PM_OPS()
+DEFINE_UNIVERSAL_DEV_PM_OPS()
+
+These macros are similar to the functions they were created to replace,
+with the following differences:
+
+ - They use the new macros introduced above, and as such always
+ reference the provided callback functions.
+
+ - They are not tagged with __maybe_unused. They are meant to be used
+ with pm_ptr() or pm_sleep_ptr() for DEFINE_UNIVERSAL_DEV_PM_OPS()
+ and DEFINE_SIMPLE_DEV_PM_OPS() respectively.
+
+ - They declare the symbol static, since every driver seems to do that
+ anyway; and if a non-static use-case is needed an indirection pointer
+ could be used.
+
+The point of this change, is to progressively switch from a code model
+where PM callbacks are all protected behind CONFIG_PM guards, to a code
+model where the PM callbacks are always seen by the compiler, but
+discarded if not used.
+
+Signed-off-by: Paul Cercueil <paul@crapouillou.net>
+Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: 18ab69c8ca56 ("Input: iqs269a - do not poll during suspend or resume")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/pm.h | 74 +++++++++++++++++++++++++++++++---------------
+ 1 file changed, 50 insertions(+), 24 deletions(-)
+
+diff --git a/include/linux/pm.h b/include/linux/pm.h
+index b88ac7dcf2a20..fc9691cb01b4f 100644
+--- a/include/linux/pm.h
++++ b/include/linux/pm.h
+@@ -300,47 +300,59 @@ struct dev_pm_ops {
+ int (*runtime_idle)(struct device *dev);
+ };
+
++#define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
++ .suspend = pm_sleep_ptr(suspend_fn), \
++ .resume = pm_sleep_ptr(resume_fn), \
++ .freeze = pm_sleep_ptr(suspend_fn), \
++ .thaw = pm_sleep_ptr(resume_fn), \
++ .poweroff = pm_sleep_ptr(suspend_fn), \
++ .restore = pm_sleep_ptr(resume_fn),
++
++#define LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
++ .suspend_late = pm_sleep_ptr(suspend_fn), \
++ .resume_early = pm_sleep_ptr(resume_fn), \
++ .freeze_late = pm_sleep_ptr(suspend_fn), \
++ .thaw_early = pm_sleep_ptr(resume_fn), \
++ .poweroff_late = pm_sleep_ptr(suspend_fn), \
++ .restore_early = pm_sleep_ptr(resume_fn),
++
++#define NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
++ .suspend_noirq = pm_sleep_ptr(suspend_fn), \
++ .resume_noirq = pm_sleep_ptr(resume_fn), \
++ .freeze_noirq = pm_sleep_ptr(suspend_fn), \
++ .thaw_noirq = pm_sleep_ptr(resume_fn), \
++ .poweroff_noirq = pm_sleep_ptr(suspend_fn), \
++ .restore_noirq = pm_sleep_ptr(resume_fn),
++
++#define RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
++ .runtime_suspend = suspend_fn, \
++ .runtime_resume = resume_fn, \
++ .runtime_idle = idle_fn,
++
+ #ifdef CONFIG_PM_SLEEP
+ #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+- .suspend = suspend_fn, \
+- .resume = resume_fn, \
+- .freeze = suspend_fn, \
+- .thaw = resume_fn, \
+- .poweroff = suspend_fn, \
+- .restore = resume_fn,
++ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+ #else
+ #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+ #endif
+
+ #ifdef CONFIG_PM_SLEEP
+ #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+- .suspend_late = suspend_fn, \
+- .resume_early = resume_fn, \
+- .freeze_late = suspend_fn, \
+- .thaw_early = resume_fn, \
+- .poweroff_late = suspend_fn, \
+- .restore_early = resume_fn,
++ LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+ #else
+ #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+ #endif
+
+ #ifdef CONFIG_PM_SLEEP
+ #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+- .suspend_noirq = suspend_fn, \
+- .resume_noirq = resume_fn, \
+- .freeze_noirq = suspend_fn, \
+- .thaw_noirq = resume_fn, \
+- .poweroff_noirq = suspend_fn, \
+- .restore_noirq = resume_fn,
++ NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+ #else
+ #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
+ #endif
+
+ #ifdef CONFIG_PM
+ #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+- .runtime_suspend = suspend_fn, \
+- .runtime_resume = resume_fn, \
+- .runtime_idle = idle_fn,
++ RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
+ #else
+ #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
+ #endif
+@@ -349,9 +361,9 @@ struct dev_pm_ops {
+ * Use this if you want to use the same suspend and resume callbacks for suspend
+ * to RAM and hibernation.
+ */
+-#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+-const struct dev_pm_ops __maybe_unused name = { \
+- SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
++#define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
++static const struct dev_pm_ops name = { \
++ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+ }
+
+ /*
+@@ -367,6 +379,19 @@ const struct dev_pm_ops __maybe_unused name = { \
+ * .resume_early(), to the same routines as .runtime_suspend() and
+ * .runtime_resume(), respectively (and analogously for hibernation).
+ */
++#define DEFINE_UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
++static const struct dev_pm_ops name = { \
++ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
++ RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
++}
++
++/* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
++#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
++const struct dev_pm_ops __maybe_unused name = { \
++ SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
++}
++
++/* Deprecated. Use DEFINE_UNIVERSAL_DEV_PM_OPS() instead. */
+ #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
+ const struct dev_pm_ops __maybe_unused name = { \
+ SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+@@ -374,6 +399,7 @@ const struct dev_pm_ops __maybe_unused name = { \
+ }
+
+ #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
++#define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
+
+ /*
+ * PM_EVENT_ messages
+--
+2.43.0
+
--- /dev/null
+From 01e70b48fd5fe002909de33f2ecf2281463a7b96 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Dec 2021 00:20:59 +0000
+Subject: PM: core: Redefine pm_ptr() macro
+
+From: Paul Cercueil <paul@crapouillou.net>
+
+[ Upstream commit c06ef740d401d0f4ab188882bf6f8d9cf0f75eaf ]
+
+The pm_ptr() macro was previously conditionally defined, according to
+the value of the CONFIG_PM option. This meant that the pointed structure
+was either referenced (if CONFIG_PM was set), or never referenced (if
+CONFIG_PM was not set), causing it to be detected as unused by the
+compiler.
+
+This worked fine, but required the __maybe_unused compiler attribute to
+be used to every symbol pointed to by a pointer wrapped with pm_ptr().
+
+We can do better. With this change, the pm_ptr() is now defined the
+same, independently of the value of CONFIG_PM. It now uses the (?:)
+ternary operator to conditionally resolve to its argument. Since the
+condition is known at compile time, the compiler will then choose to
+discard the unused symbols, which won't need to be tagged with
+__maybe_unused anymore.
+
+This pm_ptr() macro is usually used with pointers to dev_pm_ops
+structures created with SIMPLE_DEV_PM_OPS() or similar macros. These do
+use a __maybe_unused flag, which is now useless with this change, so it
+later can be removed. However in the meantime it causes no harm, and all
+the drivers still compile fine with the new pm_ptr() macro.
+
+Signed-off-by: Paul Cercueil <paul@crapouillou.net>
+Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Reviewed-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: 18ab69c8ca56 ("Input: iqs269a - do not poll during suspend or resume")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/pm.h | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/include/linux/pm.h b/include/linux/pm.h
+index 1d8209c09686c..b88ac7dcf2a20 100644
+--- a/include/linux/pm.h
++++ b/include/linux/pm.h
+@@ -373,11 +373,7 @@ const struct dev_pm_ops __maybe_unused name = { \
+ SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+ }
+
+-#ifdef CONFIG_PM
+-#define pm_ptr(_ptr) (_ptr)
+-#else
+-#define pm_ptr(_ptr) NULL
+-#endif
++#define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
+
+ /*
+ * PM_EVENT_ messages
+--
+2.43.0
+
--- /dev/null
+From 345c3aa17f2dd15b127c501199828e964db3d7df Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 7 Jan 2022 18:17:19 +0000
+Subject: PM: core: Remove static qualifier in DEFINE_SIMPLE_DEV_PM_OPS macro
+
+From: Paul Cercueil <paul@crapouillou.net>
+
+[ Upstream commit 52cc1d7f9786d2be44a3ab9b5b48416a7618e713 ]
+
+Keep this macro in line with the other ones. This makes it possible to
+use them in the cases where the underlying dev_pm_ops structure is
+exported.
+
+Restore the "static" qualifier in the two drivers where the
+DEFINE_SIMPLE_DEV_PM_OPS macro was used.
+
+Signed-off-by: Paul Cercueil <paul@crapouillou.net>
+Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Stable-dep-of: 18ab69c8ca56 ("Input: iqs269a - do not poll during suspend or resume")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/jz4740_mmc.c | 4 ++--
+ drivers/mmc/host/mxcmmc.c | 2 +-
+ include/linux/pm.h | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
+index ef3fe837b49d2..2254db44fb02c 100644
+--- a/drivers/mmc/host/jz4740_mmc.c
++++ b/drivers/mmc/host/jz4740_mmc.c
+@@ -1143,8 +1143,8 @@ static int jz4740_mmc_resume(struct device *dev)
+ return pinctrl_select_default_state(dev);
+ }
+
+-DEFINE_SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,
+- jz4740_mmc_resume);
++static DEFINE_SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,
++ jz4740_mmc_resume);
+
+ static struct platform_driver jz4740_mmc_driver = {
+ .probe = jz4740_mmc_probe,
+diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
+index b5f65f39ced1c..2e39b2cb1cafa 100644
+--- a/drivers/mmc/host/mxcmmc.c
++++ b/drivers/mmc/host/mxcmmc.c
+@@ -1212,7 +1212,7 @@ static int mxcmci_resume(struct device *dev)
+ return ret;
+ }
+
+-DEFINE_SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
++static DEFINE_SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
+
+ static struct platform_driver mxcmci_driver = {
+ .probe = mxcmci_probe,
+diff --git a/include/linux/pm.h b/include/linux/pm.h
+index fc9691cb01b4f..d1c19f5b1380f 100644
+--- a/include/linux/pm.h
++++ b/include/linux/pm.h
+@@ -362,7 +362,7 @@ struct dev_pm_ops {
+ * to RAM and hibernation.
+ */
+ #define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
+-static const struct dev_pm_ops name = { \
++const struct dev_pm_ops name = { \
+ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+ }
+
+--
+2.43.0
+
--- /dev/null
+From a802395eb2076fcacd6ab81ac9e42719bde6c144 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 1 Jun 2023 20:58:47 +0200
+Subject: posix-timers: Ensure timer ID search-loop limit is valid
+
+From: Thomas Gleixner <tglx@linutronix.de>
+
+[ Upstream commit 8ce8849dd1e78dadcee0ec9acbd259d239b7069f ]
+
+posix_timer_add() tries to allocate a posix timer ID by starting from the
+cached ID which was stored by the last successful allocation.
+
+This is done in a loop searching the ID space for a free slot one by
+one. The loop has to terminate when the search wrapped around to the
+starting point.
+
+But that's racy vs. establishing the starting point. That is read out
+lockless, which leads to the following problem:
+
+CPU0 CPU1
+posix_timer_add()
+ start = sig->posix_timer_id;
+ lock(hash_lock);
+ ... posix_timer_add()
+ if (++sig->posix_timer_id < 0)
+ start = sig->posix_timer_id;
+ sig->posix_timer_id = 0;
+
+So CPU1 can observe a negative start value, i.e. -1, and the loop break
+never happens because the condition can never be true:
+
+ if (sig->posix_timer_id == start)
+ break;
+
+While this is unlikely to ever turn into an endless loop as the ID space is
+huge (INT_MAX), the racy read of the start value caught the attention of
+KCSAN and Dmitry unearthed that incorrectness.
+
+Rewrite it so that all id operations are under the hash lock.
+
+Reported-by: syzbot+5c54bd3eb218bb595aa9@syzkaller.appspotmail.com
+Reported-by: Dmitry Vyukov <dvyukov@google.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Link: https://lore.kernel.org/r/87bkhzdn6g.ffs@tglx
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/sched/signal.h | 2 +-
+ kernel/time/posix-timers.c | 31 ++++++++++++++++++-------------
+ 2 files changed, 19 insertions(+), 14 deletions(-)
+
+diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
+index 5f0e8403e8ceb..9743f7d173a0b 100644
+--- a/include/linux/sched/signal.h
++++ b/include/linux/sched/signal.h
+@@ -125,7 +125,7 @@ struct signal_struct {
+ #ifdef CONFIG_POSIX_TIMERS
+
+ /* POSIX.1b Interval Timers */
+- int posix_timer_id;
++ unsigned int next_posix_timer_id;
+ struct list_head posix_timers;
+
+ /* ITIMER_REAL timer for the process */
+diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
+index ed3c4a9543982..2d6cf93ca370a 100644
+--- a/kernel/time/posix-timers.c
++++ b/kernel/time/posix-timers.c
+@@ -140,25 +140,30 @@ static struct k_itimer *posix_timer_by_id(timer_t id)
+ static int posix_timer_add(struct k_itimer *timer)
+ {
+ struct signal_struct *sig = current->signal;
+- int first_free_id = sig->posix_timer_id;
+ struct hlist_head *head;
+- int ret = -ENOENT;
++ unsigned int cnt, id;
+
+- do {
++ /*
++ * FIXME: Replace this by a per signal struct xarray once there is
++ * a plan to handle the resulting CRIU regression gracefully.
++ */
++ for (cnt = 0; cnt <= INT_MAX; cnt++) {
+ spin_lock(&hash_lock);
+- head = &posix_timers_hashtable[hash(sig, sig->posix_timer_id)];
+- if (!__posix_timers_find(head, sig, sig->posix_timer_id)) {
++ id = sig->next_posix_timer_id;
++
++ /* Write the next ID back. Clamp it to the positive space */
++ sig->next_posix_timer_id = (id + 1) & INT_MAX;
++
++ head = &posix_timers_hashtable[hash(sig, id)];
++ if (!__posix_timers_find(head, sig, id)) {
+ hlist_add_head_rcu(&timer->t_hash, head);
+- ret = sig->posix_timer_id;
++ spin_unlock(&hash_lock);
++ return id;
+ }
+- if (++sig->posix_timer_id < 0)
+- sig->posix_timer_id = 0;
+- if ((sig->posix_timer_id == first_free_id) && (ret == -ENOENT))
+- /* Loop over all possible ids completed */
+- ret = -EAGAIN;
+ spin_unlock(&hash_lock);
+- } while (ret == -ENOENT);
+- return ret;
++ }
++ /* POSIX return code when no timer ID could be allocated */
++ return -EAGAIN;
+ }
+
+ static inline void unlock_timer(struct k_itimer *timr, unsigned long flags)
+--
+2.43.0
+
--- /dev/null
+From 6fd3cfde0d31818b10f6c2b22c5f8e3fdd7eccc8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 16:26:49 +0530
+Subject: powerpc/eeh: Set channel state after notifying the drivers
+
+From: Ganesh Goudar <ganeshgr@linux.ibm.com>
+
+[ Upstream commit 9efcdaac36e1643a1b7f5337e6143ce142d381b1 ]
+
+When a PCI error is encountered 6th time in an hour we
+set the channel state to perm_failure and notify the
+driver about the permanent failure.
+
+However, after upstream commit 38ddc011478e ("powerpc/eeh:
+Make permanently failed devices non-actionable"), EEH handler
+stops calling any routine once the device is marked as
+permanent failure. This issue can lead to fatal consequences
+like kernel hang with certain PCI devices.
+
+Following log is observed with lpfc driver, with and without
+this change, Without this change kernel hangs, If PCI error
+is encountered 6 times for a device in an hour.
+
+Without the change
+
+ EEH: Beginning: 'error_detected(permanent failure)'
+ PCI 0132:60:00.0#600000: EEH: not actionable (1,1,1)
+ PCI 0132:60:00.1#600000: EEH: not actionable (1,1,1)
+ EEH: Finished:'error_detected(permanent failure)'
+
+With the change
+
+ EEH: Beginning: 'error_detected(permanent failure)'
+ EEH: Invoking lpfc->error_detected(permanent failure)
+ EEH: lpfc driver reports: 'disconnect'
+ EEH: Invoking lpfc->error_detected(permanent failure)
+ EEH: lpfc driver reports: 'disconnect'
+ EEH: Finished:'error_detected(permanent failure)'
+
+To fix the issue, set channel state to permanent failure after
+notifying the drivers.
+
+Fixes: 38ddc011478e ("powerpc/eeh: Make permanently failed devices non-actionable")
+Suggested-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
+Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230209105649.127707-1-ganeshgr@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/kernel/eeh_driver.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
+index cb3ac555c9446..665d847ef9b5a 100644
+--- a/arch/powerpc/kernel/eeh_driver.c
++++ b/arch/powerpc/kernel/eeh_driver.c
+@@ -1069,10 +1069,10 @@ void eeh_handle_normal_event(struct eeh_pe *pe)
+ eeh_slot_error_detail(pe, EEH_LOG_PERM);
+
+ /* Notify all devices that they're about to go down. */
+- eeh_set_channel_state(pe, pci_channel_io_perm_failure);
+ eeh_set_irq_state(pe, false);
+ eeh_pe_report("error_detected(permanent failure)", pe,
+ eeh_report_failure, NULL);
++ eeh_set_channel_state(pe, pci_channel_io_perm_failure);
+
+ /* Mark the PE to be removed permanently */
+ eeh_pe_state_mark(pe, EEH_PE_REMOVED);
+@@ -1189,10 +1189,10 @@ void eeh_handle_special_event(void)
+
+ /* Notify all devices to be down */
+ eeh_pe_state_clear(pe, EEH_PE_PRI_BUS, true);
+- eeh_set_channel_state(pe, pci_channel_io_perm_failure);
+ eeh_pe_report(
+ "error_detected(permanent failure)", pe,
+ eeh_report_failure, NULL);
++ eeh_set_channel_state(pe, pci_channel_io_perm_failure);
+
+ pci_lock_rescan_remove();
+ list_for_each_entry(hose, &hose_list, list_node) {
+--
+2.43.0
+
--- /dev/null
+From fe1f25a020e9206906ba516b84311f7ee54e4a7f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Oct 2021 18:06:27 +1100
+Subject: powerpc/eeh: Small refactor of eeh_handle_normal_event()
+
+From: Daniel Axtens <dja@axtens.net>
+
+[ Upstream commit 10b34ece132ee46dc4e6459c765d180c422a09fa ]
+
+The control flow of eeh_handle_normal_event() is a bit tricky.
+
+Break out one of the error handling paths - rather than be in an else
+block, we'll make it part of the regular body of the function and put a
+'goto out;' in the true limb of the if.
+
+Signed-off-by: Daniel Axtens <dja@axtens.net>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20211015070628.1331635-1-dja@axtens.net
+Stable-dep-of: 9efcdaac36e1 ("powerpc/eeh: Set channel state after notifying the drivers")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/kernel/eeh_driver.c | 69 ++++++++++++++++----------------
+ 1 file changed, 35 insertions(+), 34 deletions(-)
+
+diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
+index 3eff6a4888e79..cb3ac555c9446 100644
+--- a/arch/powerpc/kernel/eeh_driver.c
++++ b/arch/powerpc/kernel/eeh_driver.c
+@@ -1054,45 +1054,46 @@ void eeh_handle_normal_event(struct eeh_pe *pe)
+ }
+
+ pr_info("EEH: Recovery successful.\n");
+- } else {
+- /*
+- * About 90% of all real-life EEH failures in the field
+- * are due to poorly seated PCI cards. Only 10% or so are
+- * due to actual, failed cards.
+- */
+- pr_err("EEH: Unable to recover from failure from PHB#%x-PE#%x.\n"
+- "Please try reseating or replacing it\n",
+- pe->phb->global_number, pe->addr);
++ goto out;
++ }
+
+- eeh_slot_error_detail(pe, EEH_LOG_PERM);
++ /*
++ * About 90% of all real-life EEH failures in the field
++ * are due to poorly seated PCI cards. Only 10% or so are
++ * due to actual, failed cards.
++ */
++ pr_err("EEH: Unable to recover from failure from PHB#%x-PE#%x.\n"
++ "Please try reseating or replacing it\n",
++ pe->phb->global_number, pe->addr);
+
+- /* Notify all devices that they're about to go down. */
+- eeh_set_channel_state(pe, pci_channel_io_perm_failure);
+- eeh_set_irq_state(pe, false);
+- eeh_pe_report("error_detected(permanent failure)", pe,
+- eeh_report_failure, NULL);
++ eeh_slot_error_detail(pe, EEH_LOG_PERM);
+
+- /* Mark the PE to be removed permanently */
+- eeh_pe_state_mark(pe, EEH_PE_REMOVED);
++ /* Notify all devices that they're about to go down. */
++ eeh_set_channel_state(pe, pci_channel_io_perm_failure);
++ eeh_set_irq_state(pe, false);
++ eeh_pe_report("error_detected(permanent failure)", pe,
++ eeh_report_failure, NULL);
+
+- /*
+- * Shut down the device drivers for good. We mark
+- * all removed devices correctly to avoid access
+- * the their PCI config any more.
+- */
+- if (pe->type & EEH_PE_VF) {
+- eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);
+- eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
+- } else {
+- eeh_pe_state_clear(pe, EEH_PE_PRI_BUS, true);
+- eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
++ /* Mark the PE to be removed permanently */
++ eeh_pe_state_mark(pe, EEH_PE_REMOVED);
+
+- pci_lock_rescan_remove();
+- pci_hp_remove_devices(bus);
+- pci_unlock_rescan_remove();
+- /* The passed PE should no longer be used */
+- return;
+- }
++ /*
++ * Shut down the device drivers for good. We mark
++ * all removed devices correctly to avoid access
++ * the their PCI config any more.
++ */
++ if (pe->type & EEH_PE_VF) {
++ eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);
++ eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
++ } else {
++ eeh_pe_state_clear(pe, EEH_PE_PRI_BUS, true);
++ eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
++
++ pci_lock_rescan_remove();
++ pci_hp_remove_devices(bus);
++ pci_unlock_rescan_remove();
++ /* The passed PE should no longer be used */
++ return;
+ }
+
+ out:
+--
+2.43.0
+
--- /dev/null
+From 00627de1cad3a553f6bc547609398976bb2d2e3c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 12:41:50 -0600
+Subject: powerpc/perf/hv-24x7: add missing RTAS retry status handling
+
+From: Nathan Lynch <nathanl@linux.ibm.com>
+
+[ Upstream commit cc4b26eab1859fa1a70711872caaf6414809973f ]
+
+The ibm,get-system-parameter RTAS function may return -2 or 990x,
+which indicate that the caller should try again. read_24x7_sys_info()
+ignores this, allowing transient failures in reporting processor
+module information.
+
+Move the RTAS call into a coventional rtas_busy_delay()-based loop,
+along with the parsing of results on success.
+
+Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
+Fixes: 8ba214267382 ("powerpc/hv-24x7: Add rtas call in hv-24x7 driver to get processor details")
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-2-26929c8cce78@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/perf/hv-24x7.c | 42 ++++++++++++++++---------------------
+ 1 file changed, 18 insertions(+), 24 deletions(-)
+
+diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
+index 284ccc90fb11c..f68fa53f4b1a2 100644
+--- a/arch/powerpc/perf/hv-24x7.c
++++ b/arch/powerpc/perf/hv-24x7.c
+@@ -79,9 +79,8 @@ static u32 phys_coresperchip; /* Physical cores per chip */
+ */
+ void read_24x7_sys_info(void)
+ {
+- int call_status, len, ntypes;
+-
+- spin_lock(&rtas_data_buf_lock);
++ const s32 token = rtas_token("ibm,get-system-parameter");
++ int call_status;
+
+ /*
+ * Making system parameter: chips and sockets and cores per chip
+@@ -91,32 +90,27 @@ void read_24x7_sys_info(void)
+ phys_chipspersocket = 1;
+ phys_coresperchip = 1;
+
+- call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
+- NULL,
+- PROCESSOR_MODULE_INFO,
+- __pa(rtas_data_buf),
+- RTAS_DATA_BUF_SIZE);
++ do {
++ spin_lock(&rtas_data_buf_lock);
++ call_status = rtas_call(token, 3, 1, NULL, PROCESSOR_MODULE_INFO,
++ __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE);
++ if (call_status == 0) {
++ int ntypes = be16_to_cpup((__be16 *)&rtas_data_buf[2]);
++ int len = be16_to_cpup((__be16 *)&rtas_data_buf[0]);
++
++ if (len >= 8 && ntypes != 0) {
++ phys_sockets = be16_to_cpup((__be16 *)&rtas_data_buf[4]);
++ phys_chipspersocket = be16_to_cpup((__be16 *)&rtas_data_buf[6]);
++ phys_coresperchip = be16_to_cpup((__be16 *)&rtas_data_buf[8]);
++ }
++ }
++ spin_unlock(&rtas_data_buf_lock);
++ } while (rtas_busy_delay(call_status));
+
+ if (call_status != 0) {
+ pr_err("Error calling get-system-parameter %d\n",
+ call_status);
+- } else {
+- len = be16_to_cpup((__be16 *)&rtas_data_buf[0]);
+- if (len < 8)
+- goto out;
+-
+- ntypes = be16_to_cpup((__be16 *)&rtas_data_buf[2]);
+-
+- if (!ntypes)
+- goto out;
+-
+- phys_sockets = be16_to_cpup((__be16 *)&rtas_data_buf[4]);
+- phys_chipspersocket = be16_to_cpup((__be16 *)&rtas_data_buf[6]);
+- phys_coresperchip = be16_to_cpup((__be16 *)&rtas_data_buf[8]);
+ }
+-
+-out:
+- spin_unlock(&rtas_data_buf_lock);
+ }
+
+ /* Domains for which more than one result element are returned for each event. */
+--
+2.43.0
+
--- /dev/null
+From eb581814042be5d4ec96041fe0d9008662cf7c76 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 10:32:15 +0100
+Subject: powerpc/powernv/ioda: Skip unallocated resources when mapping to PE
+
+From: Frederic Barrat <fbarrat@linux.ibm.com>
+
+[ Upstream commit e64e71056f323a1e178dccf04d4c0f032d84436c ]
+
+pnv_ioda_setup_pe_res() calls opal to map a resource with a PE. However,
+the code assumes the resource is allocated and it uses the resource
+address to find out the segment(s) which need to be mapped to the
+PE. In the unlikely case where the resource hasn't been allocated, the
+computation for the segment number is garbage, which can lead to
+invalid memory access and potentially a kernel crash, such as:
+
+[ ] pci_bus 0002:02: Configuring PE for bus
+[ ] pci 0002:02 : [PE# fc] Secondary bus 0x0000000000000002..0x0000000000000002 associated with PE#fc
+[ ] BUG: Kernel NULL pointer dereference on write at 0x00000000
+[ ] Faulting instruction address: 0xc00000000005eac4
+[ ] Oops: Kernel access of bad area, sig: 7 [#1]
+[ ] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA PowerNV
+[ ] Modules linked in:
+[ ] CPU: 12 PID: 1 Comm: swapper/20 Not tainted 5.10.50-openpower1 #2
+[ ] NIP: c00000000005eac4 LR: c00000000005ea44 CTR: 0000000030061b9c
+[ ] REGS: c000200007383650 TRAP: 0300 Not tainted (5.10.50-openpower1)
+[ ] MSR: 9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 44000224 XER: 20040000
+[ ] CFAR: c00000000005eaa0 DAR: 0000000000000000 DSISR: 02080000 IRQMASK: 0
+[ ] GPR00: c00000000005dd98 c0002000073838e0 c00000000185de00 c000200fff018960
+[ ] GPR04: 00000000000000fc 0000000000000003 0000000000000000 0000000000000000
+[ ] GPR08: 0000000000000000 0000000000000000 0000000000000000 9000000000001033
+[ ] GPR12: 0000000031cb0000 c000000ffffe6a80 c000000000010a58 0000000000000000
+[ ] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+[ ] GPR20: 0000000000000000 0000000000000000 0000000000000000 c00000000711e200
+[ ] GPR24: 0000000000000100 c000200009501120 c00020000cee2800 00000000000003ff
+[ ] GPR28: c000200fff018960 0000000000000000 c000200ffcb7fd00 0000000000000000
+[ ] NIP [c00000000005eac4] pnv_ioda_setup_pe_res+0x94/0x1a0
+[ ] LR [c00000000005ea44] pnv_ioda_setup_pe_res+0x14/0x1a0
+[ ] Call Trace:
+[ ] [c0002000073838e0] [c00000000005eb98] pnv_ioda_setup_pe_res+0x168/0x1a0 (unreliable)
+[ ] [c000200007383970] [c00000000005dd98] pnv_pci_ioda_dma_dev_setup+0x43c/0x970
+[ ] [c000200007383a60] [c000000000032cdc] pcibios_bus_add_device+0x78/0x18c
+[ ] [c000200007383aa0] [c00000000028f2bc] pci_bus_add_device+0x28/0xbc
+[ ] [c000200007383b10] [c00000000028f3a0] pci_bus_add_devices+0x50/0x7c
+[ ] [c000200007383b50] [c00000000028f3c4] pci_bus_add_devices+0x74/0x7c
+[ ] [c000200007383b90] [c00000000028f3c4] pci_bus_add_devices+0x74/0x7c
+[ ] [c000200007383bd0] [c00000000069ad0c] pcibios_init+0xf0/0x104
+[ ] [c000200007383c50] [c0000000000106d8] do_one_initcall+0x84/0x1c4
+[ ] [c000200007383d20] [c0000000006910b8] kernel_init_freeable+0x264/0x268
+[ ] [c000200007383dc0] [c000000000010a68] kernel_init+0x18/0x138
+[ ] [c000200007383e20] [c00000000000cbfc] ret_from_kernel_thread+0x5c/0x80
+[ ] Instruction dump:
+[ ] 7f89e840 409d000c 7fbbf840 409c000c 38210090 4848f448 809c002c e95e0120
+[ ] 7ba91764 38a00003 57a7043e 38c00000 <7c8a492e> 5484043e e87e0018 4bff23bd
+
+Hitting the problem is not that easy. It was seen with a (semi-bogus)
+PCI device with a class code of 0. The generic PCI framework doesn't
+allocate resources in such a case.
+
+The patch is simply skipping resources which are still flagged with
+IORESOURCE_UNSET.
+
+We don't have the problem with 64-bit mem resources, as the address of
+the resource is checked to be within the range of the 64-bit mmio
+window. See pnv_ioda_reserve_dev_m64_pe() and pnv_pci_is_m64().
+
+Reported-by: Andrew Jeffery <andrew@aj.id.au>
+Fixes: 23e79425fe7c ("powerpc/powernv: Simplify pnv_ioda_setup_pe_seg()")
+Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230120093215.19496-1-fbarrat@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
+index 624822a810193..8cf9e9f29763c 100644
+--- a/arch/powerpc/platforms/powernv/pci-ioda.c
++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
+@@ -2334,7 +2334,8 @@ static void pnv_ioda_setup_pe_res(struct pnv_ioda_pe *pe,
+ int index;
+ int64_t rc;
+
+- if (!res || !res->flags || res->start > res->end)
++ if (!res || !res->flags || res->start > res->end ||
++ res->flags & IORESOURCE_UNSET)
+ return;
+
+ if (res->flags & IORESOURCE_IO) {
+--
+2.43.0
+
--- /dev/null
+From 396c2dd67f89a853d31b67626e382210df0c02f3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 12:41:51 -0600
+Subject: powerpc/pseries/lpar: add missing RTAS retry status handling
+
+From: Nathan Lynch <nathanl@linux.ibm.com>
+
+[ Upstream commit daa8ab59044610aa8ef2ee45a6c157b5e11635e9 ]
+
+The ibm,get-system-parameter RTAS function may return -2 or 990x,
+which indicate that the caller should try again.
+
+pseries_lpar_read_hblkrm_characteristics() ignores this, making it
+possible to incorrectly detect TLB block invalidation characteristics
+at boot.
+
+Move the RTAS call into a coventional rtas_busy_delay()-based loop.
+
+Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
+Fixes: 1211ee61b4a8 ("powerpc/pseries: Read TLB Block Invalidate Characteristics")
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-3-26929c8cce78@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/lpar.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
+index fce0237b07155..6c196b9413553 100644
+--- a/arch/powerpc/platforms/pseries/lpar.c
++++ b/arch/powerpc/platforms/pseries/lpar.c
+@@ -1434,22 +1434,22 @@ static inline void __init check_lp_set_hblkrm(unsigned int lp,
+
+ void __init pseries_lpar_read_hblkrm_characteristics(void)
+ {
++ const s32 token = rtas_token("ibm,get-system-parameter");
+ unsigned char local_buffer[SPLPAR_TLB_BIC_MAXLENGTH];
+ int call_status, len, idx, bpsize;
+
+ if (!firmware_has_feature(FW_FEATURE_BLOCK_REMOVE))
+ return;
+
+- spin_lock(&rtas_data_buf_lock);
+- memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE);
+- call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
+- NULL,
+- SPLPAR_TLB_BIC_TOKEN,
+- __pa(rtas_data_buf),
+- RTAS_DATA_BUF_SIZE);
+- memcpy(local_buffer, rtas_data_buf, SPLPAR_TLB_BIC_MAXLENGTH);
+- local_buffer[SPLPAR_TLB_BIC_MAXLENGTH - 1] = '\0';
+- spin_unlock(&rtas_data_buf_lock);
++ do {
++ spin_lock(&rtas_data_buf_lock);
++ memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE);
++ call_status = rtas_call(token, 3, 1, NULL, SPLPAR_TLB_BIC_TOKEN,
++ __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE);
++ memcpy(local_buffer, rtas_data_buf, SPLPAR_TLB_BIC_MAXLENGTH);
++ local_buffer[SPLPAR_TLB_BIC_MAXLENGTH - 1] = '\0';
++ spin_unlock(&rtas_data_buf_lock);
++ } while (rtas_busy_delay(call_status));
+
+ if (call_status != 0) {
+ pr_warn("%s %s Error calling get-system-parameter (0x%x)\n",
+--
+2.43.0
+
--- /dev/null
+From 44125a8845d7b8a742d70c8c2b0b37fcb3c4a465 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 12:41:52 -0600
+Subject: powerpc/pseries/lparcfg: add missing RTAS retry status handling
+
+From: Nathan Lynch <nathanl@linux.ibm.com>
+
+[ Upstream commit 5d08633e5f6564b60f1cbe09af3af40a74d66431 ]
+
+The ibm,get-system-parameter RTAS function may return -2 or 990x,
+which indicate that the caller should try again.
+
+lparcfg's parse_system_parameter_string() ignores this, making it
+possible to intermittently report incorrect SPLPAR characteristics.
+
+Move the RTAS call into a coventional rtas_busy_delay()-based loop.
+
+Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-4-26929c8cce78@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/lparcfg.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
+index 19503a8797823..a291b5a94d4da 100644
+--- a/arch/powerpc/platforms/pseries/lparcfg.c
++++ b/arch/powerpc/platforms/pseries/lparcfg.c
+@@ -322,6 +322,7 @@ static void parse_mpp_x_data(struct seq_file *m)
+ */
+ static void parse_system_parameter_string(struct seq_file *m)
+ {
++ const s32 token = rtas_token("ibm,get-system-parameter");
+ int call_status;
+
+ unsigned char *local_buffer = kmalloc(SPLPAR_MAXLENGTH, GFP_KERNEL);
+@@ -331,16 +332,15 @@ static void parse_system_parameter_string(struct seq_file *m)
+ return;
+ }
+
+- spin_lock(&rtas_data_buf_lock);
+- memset(rtas_data_buf, 0, SPLPAR_MAXLENGTH);
+- call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
+- NULL,
+- SPLPAR_CHARACTERISTICS_TOKEN,
+- __pa(rtas_data_buf),
+- RTAS_DATA_BUF_SIZE);
+- memcpy(local_buffer, rtas_data_buf, SPLPAR_MAXLENGTH);
+- local_buffer[SPLPAR_MAXLENGTH - 1] = '\0';
+- spin_unlock(&rtas_data_buf_lock);
++ do {
++ spin_lock(&rtas_data_buf_lock);
++ memset(rtas_data_buf, 0, SPLPAR_MAXLENGTH);
++ call_status = rtas_call(token, 3, 1, NULL, SPLPAR_CHARACTERISTICS_TOKEN,
++ __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE);
++ memcpy(local_buffer, rtas_data_buf, SPLPAR_MAXLENGTH);
++ local_buffer[SPLPAR_MAXLENGTH - 1] = '\0';
++ spin_unlock(&rtas_data_buf_lock);
++ } while (rtas_busy_delay(call_status));
+
+ if (call_status != 0) {
+ printk(KERN_INFO
+--
+2.43.0
+
--- /dev/null
+From 288255d4ff083a6544144418ed14bfbbfe444b33 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 12:41:54 -0600
+Subject: powerpc/rtas: ensure 4KB alignment for rtas_data_buf
+
+From: Nathan Lynch <nathanl@linux.ibm.com>
+
+[ Upstream commit 836b5b9fcc8e09cea7e8a59a070349a00e818308 ]
+
+Some RTAS functions that have work area parameters impose alignment
+requirements on the work area passed to them by the OS. Examples
+include:
+
+- ibm,configure-connector
+- ibm,update-nodes
+- ibm,update-properties
+
+4KB is the greatest alignment required by PAPR for such
+buffers. rtas_data_buf used to have a __page_aligned attribute in the
+arch/ppc64 days, but that was changed to __cacheline_aligned for
+unknown reasons by commit 033ef338b6e0 ("powerpc: Merge rtas.c into
+arch/powerpc/kernel"). That works out to 128-byte alignment
+on ppc64, which isn't right.
+
+This was found by inspection and I'm not aware of any real problems
+caused by this. Either current RTAS implementations don't enforce the
+alignment constraints, or rtas_data_buf is always being placed at a
+4KB boundary by accident (or both, perhaps).
+
+Use __aligned(SZ_4K) to ensure the rtas_data_buf has alignment
+appropriate for all users.
+
+Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
+Fixes: 033ef338b6e0 ("powerpc: Merge rtas.c into arch/powerpc/kernel")
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-6-26929c8cce78@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/kernel/rtas.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
+index 4da9baa0fbe8c..d01a0ad57e38e 100644
+--- a/arch/powerpc/kernel/rtas.c
++++ b/arch/powerpc/kernel/rtas.c
+@@ -70,7 +70,7 @@ EXPORT_SYMBOL(rtas);
+ DEFINE_SPINLOCK(rtas_data_buf_lock);
+ EXPORT_SYMBOL_GPL(rtas_data_buf_lock);
+
+-char rtas_data_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned;
++char rtas_data_buf[RTAS_DATA_BUF_SIZE] __aligned(SZ_4K);
+ EXPORT_SYMBOL_GPL(rtas_data_buf);
+
+ unsigned long rtas_rmo_buf;
+--
+2.43.0
+
--- /dev/null
+From ea7fadc04a8fdd56e9d1919700a2c2592c66c70f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Jan 2023 08:04:46 -0600
+Subject: powerpc/rtas: make all exports GPL
+
+From: Nathan Lynch <nathanl@linux.ibm.com>
+
+[ Upstream commit 9bce6243848dfd0ff7c2be6e8d82ab9b1e6c7858 ]
+
+The first symbol exports of RTAS functions and data came with the (now
+removed) scanlog driver in 2003:
+
+https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=f92e361842d5251e50562b09664082dcbd0548bb
+
+At the time this was applied, EXPORT_SYMBOL_GPL() was very new, and
+the exports of rtas_call() etc have remained non-GPL. As new APIs have
+been added to the RTAS subsystem, their symbol exports have followed
+the convention set by existing code.
+
+However, the historical evidence is that RTAS function exports have been
+added over time only to satisfy the needs of in-kernel users, and these
+clients must have fairly intimate knowledge of how the APIs work to use
+them safely. No out of tree users are known, and future ones seem
+unlikely.
+
+Arguably the default for RTAS symbols should have become
+EXPORT_SYMBOL_GPL once it was available. Let's make it so now, and
+exceptions can be evaluated as needed.
+
+Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
+Reviewed-by: Laurent Dufour <laurent.dufour@fr.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230124140448.45938-3-nathanl@linux.ibm.com
+Stable-dep-of: 836b5b9fcc8e ("powerpc/rtas: ensure 4KB alignment for rtas_data_buf")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/kernel/rtas.c | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
+index a4cd2484dbca2..4da9baa0fbe8c 100644
+--- a/arch/powerpc/kernel/rtas.c
++++ b/arch/powerpc/kernel/rtas.c
+@@ -68,10 +68,10 @@ struct rtas_t rtas = {
+ EXPORT_SYMBOL(rtas);
+
+ DEFINE_SPINLOCK(rtas_data_buf_lock);
+-EXPORT_SYMBOL(rtas_data_buf_lock);
++EXPORT_SYMBOL_GPL(rtas_data_buf_lock);
+
+ char rtas_data_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned;
+-EXPORT_SYMBOL(rtas_data_buf);
++EXPORT_SYMBOL_GPL(rtas_data_buf);
+
+ unsigned long rtas_rmo_buf;
+
+@@ -80,7 +80,7 @@ unsigned long rtas_rmo_buf;
+ * This is done like this so rtas_flash can be a module.
+ */
+ void (*rtas_flash_term_hook)(int);
+-EXPORT_SYMBOL(rtas_flash_term_hook);
++EXPORT_SYMBOL_GPL(rtas_flash_term_hook);
+
+ /* RTAS use home made raw locking instead of spin_lock_irqsave
+ * because those can be called from within really nasty contexts
+@@ -328,7 +328,7 @@ void rtas_progress(char *s, unsigned short hex)
+
+ spin_unlock(&progress_lock);
+ }
+-EXPORT_SYMBOL(rtas_progress); /* needed by rtas_flash module */
++EXPORT_SYMBOL_GPL(rtas_progress); /* needed by rtas_flash module */
+
+ int rtas_token(const char *service)
+ {
+@@ -338,7 +338,7 @@ int rtas_token(const char *service)
+ tokp = of_get_property(rtas.dev, service, NULL);
+ return tokp ? be32_to_cpu(*tokp) : RTAS_UNKNOWN_SERVICE;
+ }
+-EXPORT_SYMBOL(rtas_token);
++EXPORT_SYMBOL_GPL(rtas_token);
+
+ int rtas_service_present(const char *service)
+ {
+@@ -498,7 +498,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
+ }
+ return ret;
+ }
+-EXPORT_SYMBOL(rtas_call);
++EXPORT_SYMBOL_GPL(rtas_call);
+
+ /* For RTAS_BUSY (-2), delay for 1 millisecond. For an extended busy status
+ * code of 990n, perform the hinted delay of 10^n (last digit) milliseconds.
+@@ -533,7 +533,7 @@ unsigned int rtas_busy_delay(int status)
+
+ return ms;
+ }
+-EXPORT_SYMBOL(rtas_busy_delay);
++EXPORT_SYMBOL_GPL(rtas_busy_delay);
+
+ static int rtas_error_rc(int rtas_rc)
+ {
+@@ -579,7 +579,7 @@ int rtas_get_power_level(int powerdomain, int *level)
+ return rtas_error_rc(rc);
+ return rc;
+ }
+-EXPORT_SYMBOL(rtas_get_power_level);
++EXPORT_SYMBOL_GPL(rtas_get_power_level);
+
+ int rtas_set_power_level(int powerdomain, int level, int *setlevel)
+ {
+@@ -597,7 +597,7 @@ int rtas_set_power_level(int powerdomain, int level, int *setlevel)
+ return rtas_error_rc(rc);
+ return rc;
+ }
+-EXPORT_SYMBOL(rtas_set_power_level);
++EXPORT_SYMBOL_GPL(rtas_set_power_level);
+
+ int rtas_get_sensor(int sensor, int index, int *state)
+ {
+@@ -615,7 +615,7 @@ int rtas_get_sensor(int sensor, int index, int *state)
+ return rtas_error_rc(rc);
+ return rc;
+ }
+-EXPORT_SYMBOL(rtas_get_sensor);
++EXPORT_SYMBOL_GPL(rtas_get_sensor);
+
+ int rtas_get_sensor_fast(int sensor, int index, int *state)
+ {
+@@ -676,7 +676,7 @@ int rtas_set_indicator(int indicator, int index, int new_value)
+ return rtas_error_rc(rc);
+ return rc;
+ }
+-EXPORT_SYMBOL(rtas_set_indicator);
++EXPORT_SYMBOL_GPL(rtas_set_indicator);
+
+ /*
+ * Ignoring RTAS extended delay
+--
+2.43.0
+
--- /dev/null
+From 47f037ed42d9e8c5e21a72c054961c1e2104cb1b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 21 Aug 2023 21:32:53 +0800
+Subject: RDMA/siw: Balance the reference of cep->kref in the error path
+
+From: Guoqing Jiang <guoqing.jiang@linux.dev>
+
+[ Upstream commit b056327bee09e6b86683d3f709a438ccd6031d72 ]
+
+The siw_connect can go to err in below after cep is allocated successfully:
+
+1. If siw_cm_alloc_work returns failure. In this case socket is not
+assoicated with cep so siw_cep_put can't be called by siw_socket_disassoc.
+We need to call siw_cep_put twice since cep->kref is increased once after
+it was initialized.
+
+2. If siw_cm_queue_work can't find a work, which means siw_cep_get is not
+called in siw_cm_queue_work, so cep->kref is increased twice by siw_cep_get
+and when associate socket with cep after it was initialized. So we need to
+call siw_cep_put three times (one in siw_socket_disassoc).
+
+3. siw_send_mpareqrep returns error, this scenario is similar as 2.
+
+So we need to remove one siw_cep_put in the error path.
+
+Fixes: 6c52fdc244b5 ("rdma/siw: connection management")
+Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
+Link: https://lore.kernel.org/r/20230821133255.31111-2-guoqing.jiang@linux.dev
+Acked-by: Bernard Metzler <bmt@zurich.ibm.com>
+Signed-off-by: Leon Romanovsky <leon@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/sw/siw/siw_cm.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
+index ecd19a7408679..116f1c38384b6 100644
+--- a/drivers/infiniband/sw/siw/siw_cm.c
++++ b/drivers/infiniband/sw/siw/siw_cm.c
+@@ -1504,7 +1504,6 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params)
+
+ cep->cm_id = NULL;
+ id->rem_ref(id);
+- siw_cep_put(cep);
+
+ qp->cep = NULL;
+ siw_cep_put(cep);
+--
+2.43.0
+
--- /dev/null
+From 80b3f48e9f8de42951ca870ae3fdae13958e4ed4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 21 Aug 2023 21:32:54 +0800
+Subject: RDMA/siw: Correct wrong debug message
+
+From: Guoqing Jiang <guoqing.jiang@linux.dev>
+
+[ Upstream commit bee024d20451e4ce04ea30099cad09f7f75d288b ]
+
+We need to print num_sle first then pbl->max_buf per the condition.
+Also replace mem->pbl with pbl while at it.
+
+Fixes: 303ae1cdfdf7 ("rdma/siw: application interface")
+Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
+Link: https://lore.kernel.org/r/20230821133255.31111-3-guoqing.jiang@linux.dev
+Acked-by: Bernard Metzler <bmt@zurich.ibm.com>
+Signed-off-by: Leon Romanovsky <leon@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/sw/siw/siw_verbs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
+index 9c7fbda9e068a..124242e387a59 100644
+--- a/drivers/infiniband/sw/siw/siw_verbs.c
++++ b/drivers/infiniband/sw/siw/siw_verbs.c
+@@ -1492,7 +1492,7 @@ int siw_map_mr_sg(struct ib_mr *base_mr, struct scatterlist *sl, int num_sle,
+
+ if (pbl->max_buf < num_sle) {
+ siw_dbg_mem(mem, "too many SGE's: %d > %d\n",
+- mem->pbl->max_buf, num_sle);
++ num_sle, pbl->max_buf);
+ return -ENOMEM;
+ }
+ for_each_sg(sl, slp, num_sle, i) {
+--
+2.43.0
+
--- /dev/null
+From 727b2258c203f1365afc607b3005b2f204e1a1d1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Dec 2022 23:13:21 +0100
+Subject: RISC-V: fix funct4 definition for c.jalr in parse_asm.h
+
+From: Heiko Stuebner <heiko.stuebner@vrull.eu>
+
+[ Upstream commit a3775634f6da23f5511d0282d7e792cf606e5f3b ]
+
+The opcode definition for c.jalr is
+ c.jalr c_rs1_n0 1..0=2 15..13=4 12=1 6..2=0
+
+This means funct4 consisting of bit [15:12] is 1001b, so the value is 0x9.
+
+Fixes: edde5584c7ab ("riscv: Add SW single-step support for KDB")
+Reported-by: Andrew Jones <ajones@ventanamicro.com>
+Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
+Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
+Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
+Link: https://lore.kernel.org/r/20221223221332.4127602-2-heiko@sntech.de
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/riscv/include/asm/parse_asm.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/riscv/include/asm/parse_asm.h b/arch/riscv/include/asm/parse_asm.h
+index 3cd00332d70f5..ad254da85e615 100644
+--- a/arch/riscv/include/asm/parse_asm.h
++++ b/arch/riscv/include/asm/parse_asm.h
+@@ -128,7 +128,7 @@
+ #define FUNCT3_C_J 0xa000
+ #define FUNCT3_C_JAL 0x2000
+ #define FUNCT4_C_JR 0x8000
+-#define FUNCT4_C_JALR 0xf000
++#define FUNCT4_C_JALR 0x9000
+
+ #define FUNCT12_SRET 0x10200000
+
+--
+2.43.0
+
--- /dev/null
+From f8de57d4a3aa9ce22217c2404fcda1165645aea7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 30 May 2023 16:25:07 +0800
+Subject: sched/fair: Don't balance task to its current running CPU
+
+From: Yicong Yang <yangyicong@hisilicon.com>
+
+[ Upstream commit 0dd37d6dd33a9c23351e6115ae8cdac7863bc7de ]
+
+We've run into the case that the balancer tries to balance a migration
+disabled task and trigger the warning in set_task_cpu() like below:
+
+ ------------[ cut here ]------------
+ WARNING: CPU: 7 PID: 0 at kernel/sched/core.c:3115 set_task_cpu+0x188/0x240
+ Modules linked in: hclgevf xt_CHECKSUM ipt_REJECT nf_reject_ipv4 <...snip>
+ CPU: 7 PID: 0 Comm: swapper/7 Kdump: loaded Tainted: G O 6.1.0-rc4+ #1
+ Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V5.B221.01 12/09/2021
+ pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
+ pc : set_task_cpu+0x188/0x240
+ lr : load_balance+0x5d0/0xc60
+ sp : ffff80000803bc70
+ x29: ffff80000803bc70 x28: ffff004089e190e8 x27: ffff004089e19040
+ x26: ffff007effcabc38 x25: 0000000000000000 x24: 0000000000000001
+ x23: ffff80000803be84 x22: 000000000000000c x21: ffffb093e79e2a78
+ x20: 000000000000000c x19: ffff004089e19040 x18: 0000000000000000
+ x17: 0000000000001fad x16: 0000000000000030 x15: 0000000000000000
+ x14: 0000000000000003 x13: 0000000000000000 x12: 0000000000000000
+ x11: 0000000000000001 x10: 0000000000000400 x9 : ffffb093e4cee530
+ x8 : 00000000fffffffe x7 : 0000000000ce168a x6 : 000000000000013e
+ x5 : 00000000ffffffe1 x4 : 0000000000000001 x3 : 0000000000000b2a
+ x2 : 0000000000000b2a x1 : ffffb093e6d6c510 x0 : 0000000000000001
+ Call trace:
+ set_task_cpu+0x188/0x240
+ load_balance+0x5d0/0xc60
+ rebalance_domains+0x26c/0x380
+ _nohz_idle_balance.isra.0+0x1e0/0x370
+ run_rebalance_domains+0x6c/0x80
+ __do_softirq+0x128/0x3d8
+ ____do_softirq+0x18/0x24
+ call_on_irq_stack+0x2c/0x38
+ do_softirq_own_stack+0x24/0x3c
+ __irq_exit_rcu+0xcc/0xf4
+ irq_exit_rcu+0x18/0x24
+ el1_interrupt+0x4c/0xe4
+ el1h_64_irq_handler+0x18/0x2c
+ el1h_64_irq+0x74/0x78
+ arch_cpu_idle+0x18/0x4c
+ default_idle_call+0x58/0x194
+ do_idle+0x244/0x2b0
+ cpu_startup_entry+0x30/0x3c
+ secondary_start_kernel+0x14c/0x190
+ __secondary_switched+0xb0/0xb4
+ ---[ end trace 0000000000000000 ]---
+
+Further investigation shows that the warning is superfluous, the migration
+disabled task is just going to be migrated to its current running CPU.
+This is because that on load balance if the dst_cpu is not allowed by the
+task, we'll re-select a new_dst_cpu as a candidate. If no task can be
+balanced to dst_cpu we'll try to balance the task to the new_dst_cpu
+instead. In this case when the migration disabled task is not on CPU it
+only allows to run on its current CPU, load balance will select its
+current CPU as new_dst_cpu and later triggers the warning above.
+
+The new_dst_cpu is chosen from the env->dst_grpmask. Currently it
+contains CPUs in sched_group_span() and if we have overlapped groups it's
+possible to run into this case. This patch makes env->dst_grpmask of
+group_balance_mask() which exclude any CPUs from the busiest group and
+solve the issue. For balancing in a domain with no overlapped groups
+the behaviour keeps same as before.
+
+Suggested-by: Vincent Guittot <vincent.guittot@linaro.org>
+Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
+Link: https://lore.kernel.org/r/20230530082507.10444-1-yangyicong@huawei.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/sched/fair.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
+index fd8b5656641b7..b55d51b4105cd 100644
+--- a/kernel/sched/fair.c
++++ b/kernel/sched/fair.c
+@@ -10177,7 +10177,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
+ .sd = sd,
+ .dst_cpu = this_cpu,
+ .dst_rq = this_rq,
+- .dst_grpmask = sched_group_span(sd->groups),
++ .dst_grpmask = group_balance_mask(sd->groups),
+ .idle = idle,
+ .loop_break = sched_nr_migrate_break,
+ .cpus = cpus,
+--
+2.43.0
+
--- /dev/null
+From 849316f761522aa849ef3830031a980e72bcb389 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 13 Jun 2023 09:32:21 -0300
+Subject: selftests: net: vrf-xfrm-tests: change authentication and encryption
+ algos
+
+From: Magali Lemes <magali.lemes@canonical.com>
+
+[ Upstream commit cb43c60e64ca67fcc9d23bd08f51d2ab8209d9d7 ]
+
+The vrf-xfrm-tests tests use the hmac(md5) and cbc(des3_ede)
+algorithms for performing authentication and encryption, respectively.
+This causes the tests to fail when fips=1 is set, since these algorithms
+are not allowed in FIPS mode. Therefore, switch from hmac(md5) and
+cbc(des3_ede) to hmac(sha1) and cbc(aes), which are FIPS compliant.
+
+Fixes: 3f251d741150 ("selftests: Add tests for vrf and xfrms")
+Reviewed-by: David Ahern <dsahern@kernel.org>
+Signed-off-by: Magali Lemes <magali.lemes@canonical.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/net/vrf-xfrm-tests.sh | 32 +++++++++----------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/tools/testing/selftests/net/vrf-xfrm-tests.sh b/tools/testing/selftests/net/vrf-xfrm-tests.sh
+index 184da81f554ff..452638ae8aed8 100755
+--- a/tools/testing/selftests/net/vrf-xfrm-tests.sh
++++ b/tools/testing/selftests/net/vrf-xfrm-tests.sh
+@@ -264,60 +264,60 @@ setup_xfrm()
+ ip -netns host1 xfrm state add src ${HOST1_4} dst ${HOST2_4} \
+ proto esp spi ${SPI_1} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
+- enc 'cbc(des3_ede)' ${ENC_1} \
++ auth-trunc 'hmac(sha1)' ${AUTH_1} 96 \
++ enc 'cbc(aes)' ${ENC_1} \
+ sel src ${h1_4} dst ${h2_4} ${devarg}
+
+ ip -netns host2 xfrm state add src ${HOST1_4} dst ${HOST2_4} \
+ proto esp spi ${SPI_1} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
+- enc 'cbc(des3_ede)' ${ENC_1} \
++ auth-trunc 'hmac(sha1)' ${AUTH_1} 96 \
++ enc 'cbc(aes)' ${ENC_1} \
+ sel src ${h1_4} dst ${h2_4}
+
+
+ ip -netns host1 xfrm state add src ${HOST2_4} dst ${HOST1_4} \
+ proto esp spi ${SPI_2} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
+- enc 'cbc(des3_ede)' ${ENC_2} \
++ auth-trunc 'hmac(sha1)' ${AUTH_2} 96 \
++ enc 'cbc(aes)' ${ENC_2} \
+ sel src ${h2_4} dst ${h1_4} ${devarg}
+
+ ip -netns host2 xfrm state add src ${HOST2_4} dst ${HOST1_4} \
+ proto esp spi ${SPI_2} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
+- enc 'cbc(des3_ede)' ${ENC_2} \
++ auth-trunc 'hmac(sha1)' ${AUTH_2} 96 \
++ enc 'cbc(aes)' ${ENC_2} \
+ sel src ${h2_4} dst ${h1_4}
+
+
+ ip -6 -netns host1 xfrm state add src ${HOST1_6} dst ${HOST2_6} \
+ proto esp spi ${SPI_1} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
+- enc 'cbc(des3_ede)' ${ENC_1} \
++ auth-trunc 'hmac(sha1)' ${AUTH_1} 96 \
++ enc 'cbc(aes)' ${ENC_1} \
+ sel src ${h1_6} dst ${h2_6} ${devarg}
+
+ ip -6 -netns host2 xfrm state add src ${HOST1_6} dst ${HOST2_6} \
+ proto esp spi ${SPI_1} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
+- enc 'cbc(des3_ede)' ${ENC_1} \
++ auth-trunc 'hmac(sha1)' ${AUTH_1} 96 \
++ enc 'cbc(aes)' ${ENC_1} \
+ sel src ${h1_6} dst ${h2_6}
+
+
+ ip -6 -netns host1 xfrm state add src ${HOST2_6} dst ${HOST1_6} \
+ proto esp spi ${SPI_2} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
+- enc 'cbc(des3_ede)' ${ENC_2} \
++ auth-trunc 'hmac(sha1)' ${AUTH_2} 96 \
++ enc 'cbc(aes)' ${ENC_2} \
+ sel src ${h2_6} dst ${h1_6} ${devarg}
+
+ ip -6 -netns host2 xfrm state add src ${HOST2_6} dst ${HOST1_6} \
+ proto esp spi ${SPI_2} reqid 0 mode tunnel \
+ replay-window 4 replay-oseq 0x4 \
+- auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
+- enc 'cbc(des3_ede)' ${ENC_2} \
++ auth-trunc 'hmac(sha1)' ${AUTH_2} 96 \
++ enc 'cbc(aes)' ${ENC_2} \
+ sel src ${h2_6} dst ${h1_6}
+ }
+
+--
+2.43.0
+
--- /dev/null
+From 76b08ddc86c41dbfc913ad4fc0ab071127493a1c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 Jun 2022 13:04:33 +0300
+Subject: serial: 8250: Remove serial_rs485 sanitization from em485
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
+
+[ Upstream commit 84f2faa7852e1f55d89bb0c99b3a672b87b11f87 ]
+
+Serial core handles serial_rs485 sanitization.
+
+When em485 init fails, there are two possible paths of entry:
+
+ 1) uart_rs485_config (init path) that fully clears port->rs485 on
+ error.
+
+ 2) ioctl path with a pre-existing, valid port->rs485 unto which the
+ kernel falls back on error and port->rs485 should therefore be
+ kept untouched. The temporary rs485 struct is not returned to
+ userspace in case of error so its flag don't matter.
+
+...Thus SER_RS485_ENABLED clearing on error can/should be dropped.
+
+Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
+Link: https://lore.kernel.org/r/20220606100433.13793-37-ilpo.jarvinen@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/8250/8250_port.c | 18 ++----------------
+ 1 file changed, 2 insertions(+), 16 deletions(-)
+
+diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
+index 45a8f76f562e7..4fce318bc83ca 100644
+--- a/drivers/tty/serial/8250/8250_port.c
++++ b/drivers/tty/serial/8250/8250_port.c
+@@ -670,13 +670,6 @@ int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485)
+ rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
+ }
+
+- /* clamp the delays to [0, 100ms] */
+- rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
+- rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
+-
+- memset(rs485->padding, 0, sizeof(rs485->padding));
+- port->rs485 = *rs485;
+-
+ gpiod_set_value(port->rs485_term_gpio,
+ rs485->flags & SER_RS485_TERMINATE_BUS);
+
+@@ -684,15 +677,8 @@ int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485)
+ * Both serial8250_em485_init() and serial8250_em485_destroy()
+ * are idempotent.
+ */
+- if (rs485->flags & SER_RS485_ENABLED) {
+- int ret = serial8250_em485_init(up);
+-
+- if (ret) {
+- rs485->flags &= ~SER_RS485_ENABLED;
+- port->rs485.flags &= ~SER_RS485_ENABLED;
+- }
+- return ret;
+- }
++ if (rs485->flags & SER_RS485_ENABLED)
++ return serial8250_em485_init(up);
+
+ serial8250_em485_destroy(up);
+ return 0;
+--
+2.43.0
+
usb-roles-fix-null-pointer-issue-when-put-module-s-reference.patch
usb-roles-don-t-get-set_role-when-usb_role_switch-is-unregistered.patch
mptcp-fix-lockless-access-in-subflow-ulp-diag.patch
+clk-imx-imx8mp-add-shared-clk-gate-for-usb-suspend-c.patch
+clk-qcom-gcc-qcs404-disable-gpll-04-_out_aux-parents.patch
+clk-qcom-gcc-qcs404-fix-names-of-the-dsi-clocks-used.patch
+mtd-rawnand-sunxi-fix-the-size-of-the-last-oob-regio.patch
+risc-v-fix-funct4-definition-for-c.jalr-in-parse_asm.patch
+input-iqs269a-drop-unused-device-node-references.patch
+input-iqs269a-configure-device-with-a-single-block-w.patch
+input-iqs269a-increase-interrupt-handler-return-dela.patch
+clk-renesas-cpg-mssr-fix-use-after-free-if-cpg_mssr_.patch
+input-ads7846-don-t-report-pressure-for-ads7845.patch
+clk-renesas-cpg-mssr-remove-superfluous-check-in-res.patch
+clk-imx-avoid-memory-leak.patch
+input-ads7846-always-set-last-command-to-pwrdown.patch
+input-ads7846-don-t-check-penirq-immediately-for-784.patch
+powerpc-powernv-ioda-skip-unallocated-resources-when.patch
+clk-qcom-gpucc-sc7180-fix-clk_dis_wait-being-program.patch
+clk-qcom-gpucc-sdm845-fix-clk_dis_wait-being-program.patch
+clk-honor-clk_ops_parent_enable-in-clk_core_is_enabl.patch
+powerpc-pseries-lparcfg-add-missing-rtas-retry-statu.patch
+powerpc-perf-hv-24x7-add-missing-rtas-retry-status-h.patch
+powerpc-pseries-lpar-add-missing-rtas-retry-status-h.patch
+mips-smp-cps-fix-build-error-when-hotplug_cpu-not-se.patch
+mips-vpe-mt-drop-physical_memsize.patch
+vdpa-mlx5-don-t-clear-mr-struct-on-destroy-mr.patch
+selftests-net-vrf-xfrm-tests-change-authentication-a.patch
+arm-dts-bcm53573-drop-nonexistent-usb-cells.patch
+rdma-siw-balance-the-reference-of-cep-kref-in-the-er.patch
+rdma-siw-correct-wrong-debug-message.patch
+clk-linux-clk-provider.h-fix-kernel-doc-warnings-and.patch
+platform-x86-asus-wmi-document-the-dgpu_disable-sysf.patch
+acpi-property-let-args-be-null-in-__acpi_node_get_pr.patch
+arm-dts-bcm53573-drop-nonexistent-default-off-led-tr.patch
+tools-headers-uapi-sync-linux-fscrypt.h-with-the-ker.patch
+perf-beauty-update-copy-of-linux-socket.h-with-the-k.patch
+tools-virtio-fix-build.patch
+drm-amdgpu-init-iommu-after-amdkfd-device-init.patch
+f2fs-don-t-set-gc_failure_pin-for-background-gc.patch
+f2fs-write-checkpoint-during-fg_gc.patch
+drm-i915-dg1-update-dmc_debug3-register.patch
+kernel-sched-remove-dl_boosted-flag-comment.patch
+cifs-remove-useless-parameter-is_fsctl-from-smb2_ioc.patch
+serial-8250-remove-serial_rs485-sanitization-from-em.patch
+clk-imx8mp-add-disp2-pixel-clock.patch
+clk-imx8mp-add-clkout1-2-support.patch
+dt-bindings-clocks-imx8mp-add-id-for-usb-suspend-clo.patch
+net-ethernet-ti-add-missing-of_node_put-before-retur.patch
+powerpc-rtas-make-all-exports-gpl.patch
+powerpc-rtas-ensure-4kb-alignment-for-rtas_data_buf.patch
+powerpc-eeh-small-refactor-of-eeh_handle_normal_even.patch
+powerpc-eeh-set-channel-state-after-notifying-the-dr.patch
+pm-core-redefine-pm_ptr-macro.patch
+pm-core-add-new-_pm_ops-macros-deprecate-old-ones.patch
+mmc-jz4740-use-the-new-pm-macros.patch
+mmc-mxc-use-the-new-pm-macros.patch
+pm-core-remove-static-qualifier-in-define_simple_dev.patch
+input-iqs269a-switch-to-define_simple_dev_pm_ops-and.patch
+input-iqs269a-do-not-poll-during-suspend-or-resume.patch
+input-iqs269a-do-not-poll-during-ati.patch
+net-sched-refactor-qdisc_graft-for-ingress-and-clsac.patch
+netfilter-nf_tables-add-rescheduling-points-during-l.patch
+debugobjects-recheck-debug_objects_enabled-before-re.patch
+nbd-add-the-maximum-limit-of-allocated-index-in-nbd_.patch
+md-fix-data-corruption-for-raid456-when-reshape-rest.patch
+md-raid10-prevent-soft-lockup-while-flush-writes.patch
+posix-timers-ensure-timer-id-search-loop-limit-is-va.patch
+btrfs-add-xxhash-to-fast-checksum-implementations.patch
+acpi-button-add-lid-disable-dmi-quirk-for-nextbook-a.patch
+acpi-video-add-backlight-native-dmi-quirk-for-apple-.patch
+acpi-video-add-backlight-native-dmi-quirk-for-lenovo.patch
+arm64-set-__exception_irq_entry-with-__irq_entry-as-.patch
+arm64-mm-fix-va-range-sanity-check.patch
+sched-fair-don-t-balance-task-to-its-current-running.patch
+wifi-ath11k-fix-registration-of-6ghz-only-phy-withou.patch
+bpf-address-kcsan-report-on-bpf_lru_list.patch
+devlink-report-devlink_port_type_warn-source-device.patch
+wifi-wext-core-fix-wstringop-overflow-warning-in-ioc.patch
+igb-fix-igb_down-hung-on-surprise-removal.patch
+wifi-iwlwifi-mvm-avoid-baid-size-integer-overflow.patch
+exfat-support-dynamic-allocate-bh-for-exfat_entry_se.patch
+arm64-dts-rockchip-fix-regulator-name-on-rk3399-rock.patch
+arm64-dts-rockchip-add-es8316-codec-for-rock-pi-4.patch
+arm64-dts-rockchip-add-spdif-node-for-rock-pi-4.patch
+arm-dts-bcm53573-describe-on-soc-bcm53125-rev-4-swit.patch
+acpi-video-add-backlight-native-dmi-quirk-for-apple-.patch-17944
+acpi-resource-add-asus-model-s5402za-to-quirks.patch
+acpi-resource-skip-irq-override-on-asus-vivobook-s56.patch
+acpi-resource-add-asus-expertbook-b2502-to-asus-quir.patch
+acpi-resource-skip-irq-override-on-asus-expertbook-b.patch
+acpi-resource-skip-irq-override-on-asus-expertbook-b.patch-25193
+xhci-cleanup-xhci_hub_control-port-references.patch
+xhci-move-port-specific-items-such-as-state-completi.patch
+xhci-rename-resume_done-to-resume_timestamp.patch
+xhci-clear-usb2-resume-related-variables-in-one-plac.patch
+xhci-decouple-usb2-port-resume-and-get_port_status-r.patch
+xhci-track-port-suspend-state-correctly-in-unsuccess.patch
+cifs-add-a-warning-when-the-in-flight-count-goes-neg.patch
--- /dev/null
+From d5696661a7bd94a213e289a620e7ac82480fcc24 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 17 Dec 2020 14:58:51 -0300
+Subject: tools headers UAPI: Sync linux/fscrypt.h with the kernel sources
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+[ Upstream commit fabe0c61d842637b722344bcd49bfb1b76e2cc68 ]
+
+To pick the changes from:
+
+ 6b2a51ff03bf0c54 ("fscrypt: Add HCTR2 support for filename encryption")
+
+That don't result in any changes in tooling, just causes this to be
+rebuilt:
+
+ CC /tmp/build/perf-urgent/trace/beauty/sync_file_range.o
+ LD /tmp/build/perf-urgent/trace/beauty/perf-in.o
+
+addressing this perf build warning:
+
+ Warning: Kernel ABI header at 'tools/include/uapi/linux/fscrypt.h' differs from latest version at 'include/uapi/linux/fscrypt.h'
+ diff -u tools/include/uapi/linux/fscrypt.h include/uapi/linux/fscrypt.h
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Herbert Xu <herbert@gondor.apana.org.au>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Nathan Huckleberry <nhuck@google.com>
+Link: https://lore.kernel.org/lkml/Yvzl8C7O1b+hf9GS@kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/include/uapi/linux/fscrypt.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/include/uapi/linux/fscrypt.h b/tools/include/uapi/linux/fscrypt.h
+index 9f4428be3e362..a756b29afcc23 100644
+--- a/tools/include/uapi/linux/fscrypt.h
++++ b/tools/include/uapi/linux/fscrypt.h
+@@ -27,7 +27,8 @@
+ #define FSCRYPT_MODE_AES_128_CBC 5
+ #define FSCRYPT_MODE_AES_128_CTS 6
+ #define FSCRYPT_MODE_ADIANTUM 9
+-/* If adding a mode number > 9, update FSCRYPT_MODE_MAX in fscrypt_private.h */
++#define FSCRYPT_MODE_AES_256_HCTR2 10
++/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */
+
+ /*
+ * Legacy policy version; ad-hoc KDF and no key verification.
+--
+2.43.0
+
--- /dev/null
+From 85a1308369db6be838d77912bed894e17793d902 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 5 Jul 2022 09:22:49 +0200
+Subject: tools/virtio: fix build
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Stefano Garzarella <sgarzare@redhat.com>
+
+[ Upstream commit d650f830f38b19039958f3f4504ceeb2b5922da7 ]
+
+Fix the build caused by the following changes:
+- phys_addr_t is now defined in tools/include/linux/types.h
+- dev_warn_once() is used in drivers/virtio/virtio_ring.c
+- linux/uio.h included by vringh.h use INT_MAX defined in limits.h
+
+Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
+Message-Id: <20220705072249.7867-1-sgarzare@redhat.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Acked-by: Eugenio Pérez <eperezma@redhat.com>
+Signed-off-by: Peng Fan <peng.fan@nxp.com>
+Acked-by: Jason Wang <jasowang@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/virtio/linux/kernel.h | 2 +-
+ tools/virtio/linux/vringh.h | 1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
+index a4beb719d2174..8b877167933d1 100644
+--- a/tools/virtio/linux/kernel.h
++++ b/tools/virtio/linux/kernel.h
+@@ -30,7 +30,6 @@
+ #define READ 0
+ #define WRITE 1
+
+-typedef unsigned long long phys_addr_t;
+ typedef unsigned long long dma_addr_t;
+ typedef size_t __kernel_size_t;
+ typedef unsigned int __wsum;
+@@ -137,6 +136,7 @@ static inline void *krealloc_array(void *p, size_t new_n, size_t new_size, gfp_t
+ #endif
+ #define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
+ #define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
++#define dev_warn_once(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
+
+ #define min(x, y) ({ \
+ typeof(x) _min1 = (x); \
+diff --git a/tools/virtio/linux/vringh.h b/tools/virtio/linux/vringh.h
+index 9348957be56e4..e11c6aece7341 100644
+--- a/tools/virtio/linux/vringh.h
++++ b/tools/virtio/linux/vringh.h
+@@ -1 +1,2 @@
++#include <limits.h>
+ #include "../../../include/linux/vringh.h"
+--
+2.43.0
+
--- /dev/null
+From 117463e2b52c4d2eab184f057f3fe2ce3dc1a16e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 Feb 2023 14:19:56 +0200
+Subject: vdpa/mlx5: Don't clear mr struct on destroy MR
+
+From: Eli Cohen <elic@nvidia.com>
+
+[ Upstream commit aef24311bd2d8a6d39a80c34f278b0fd1692aed3 ]
+
+Clearing the mr struct erases the lock owner and causes warnings to be
+emitted. It is not required to clear the mr so remove the memset call.
+
+Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code")
+Signed-off-by: Eli Cohen <elic@nvidia.com>
+Message-Id: <20230206121956.1149356-1-elic@nvidia.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/vdpa/mlx5/core/mr.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c
+index ff010c6d0cd39..bdc7595fcb0e3 100644
+--- a/drivers/vdpa/mlx5/core/mr.c
++++ b/drivers/vdpa/mlx5/core/mr.c
+@@ -505,7 +505,6 @@ void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev)
+ else
+ destroy_dma_mr(mvdev, mr);
+
+- memset(mr, 0, sizeof(*mr));
+ mr->initialized = false;
+ out:
+ mutex_unlock(&mr->mkey_mtx);
+--
+2.43.0
+
--- /dev/null
+From 3c52486edf83d014b17cd663de032950a6982a2d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 Apr 2023 16:54:45 +0200
+Subject: wifi: ath11k: fix registration of 6Ghz-only phy without the full
+ channel range
+
+From: Maxime Bizon <mbizon@freebox.fr>
+
+[ Upstream commit e2ceb1de2f83aafd8003f0b72dfd4b7441e97d14 ]
+
+Because of what seems to be a typo, a 6Ghz-only phy for which the BDF
+does not allow the 7115Mhz channel will fail to register:
+
+ WARNING: CPU: 2 PID: 106 at net/wireless/core.c:907 wiphy_register+0x914/0x954
+ Modules linked in: ath11k_pci sbsa_gwdt
+ CPU: 2 PID: 106 Comm: kworker/u8:5 Not tainted 6.3.0-rc7-next-20230418-00549-g1e096a17625a-dirty #9
+ Hardware name: Freebox V7R Board (DT)
+ Workqueue: ath11k_qmi_driver_event ath11k_qmi_driver_event_work
+ pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
+ pc : wiphy_register+0x914/0x954
+ lr : ieee80211_register_hw+0x67c/0xc10
+ sp : ffffff800b123aa0
+ x29: ffffff800b123aa0 x28: 0000000000000000 x27: 0000000000000000
+ x26: 0000000000000000 x25: 0000000000000006 x24: ffffffc008d51418
+ x23: ffffffc008cb0838 x22: ffffff80176c2460 x21: 0000000000000168
+ x20: ffffff80176c0000 x19: ffffff80176c03e0 x18: 0000000000000014
+ x17: 00000000cbef338c x16: 00000000d2a26f21 x15: 00000000ad6bb85f
+ x14: 0000000000000020 x13: 0000000000000020 x12: 00000000ffffffbd
+ x11: 0000000000000208 x10: 00000000fffffdf7 x9 : ffffffc009394718
+ x8 : ffffff80176c0528 x7 : 000000007fffffff x6 : 0000000000000006
+ x5 : 0000000000000005 x4 : ffffff800b304284 x3 : ffffff800b304284
+ x2 : ffffff800b304d98 x1 : 0000000000000000 x0 : 0000000000000000
+ Call trace:
+ wiphy_register+0x914/0x954
+ ieee80211_register_hw+0x67c/0xc10
+ ath11k_mac_register+0x7c4/0xe10
+ ath11k_core_qmi_firmware_ready+0x1f4/0x570
+ ath11k_qmi_driver_event_work+0x198/0x590
+ process_one_work+0x1b8/0x328
+ worker_thread+0x6c/0x414
+ kthread+0x100/0x104
+ ret_from_fork+0x10/0x20
+ ---[ end trace 0000000000000000 ]---
+ ath11k_pci 0002:01:00.0: ieee80211 registration failed: -22
+ ath11k_pci 0002:01:00.0: failed register the radio with mac80211: -22
+ ath11k_pci 0002:01:00.0: failed to create pdev core: -22
+
+Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
+Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
+Link: https://lore.kernel.org/r/20230421145445.2612280-1-mbizon@freebox.fr
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/ath/ath11k/mac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
+index ae6e14fe03c72..c58fd836d4ade 100644
+--- a/drivers/net/wireless/ath/ath11k/mac.c
++++ b/drivers/net/wireless/ath/ath11k/mac.c
+@@ -6312,7 +6312,7 @@ static int ath11k_mac_setup_channels_rates(struct ath11k *ar,
+ }
+
+ if (supported_bands & WMI_HOST_WLAN_5G_CAP) {
+- if (reg_cap->high_5ghz_chan >= ATH11K_MAX_6G_FREQ) {
++ if (reg_cap->high_5ghz_chan >= ATH11K_MIN_6G_FREQ) {
+ channels = kmemdup(ath11k_6ghz_channels,
+ sizeof(ath11k_6ghz_channels), GFP_KERNEL);
+ if (!channels) {
+--
+2.43.0
+
--- /dev/null
+From c81d3cf30c8fe83aafccc2444c4933923b8456c2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 20 Jun 2023 13:04:02 +0300
+Subject: wifi: iwlwifi: mvm: avoid baid size integer overflow
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit 1a528ab1da324d078ec60283c34c17848580df24 ]
+
+Roee reported various hard-to-debug crashes with pings in
+EHT aggregation scenarios. Enabling KASAN showed that we
+access the BAID allocation out of bounds, and looking at
+the code a bit shows that since the reorder buffer entry
+(struct iwl_mvm_reorder_buf_entry) is 128 bytes if debug
+such as lockdep is enabled, then staring from an agg size
+512 we overflow the size calculation, and allocate a much
+smaller structure than we should, causing slab corruption
+once we initialize this.
+
+Fix this by simply using u32 instead of u16.
+
+Reported-by: Roee Goldfiner <roee.h.goldfiner@intel.com>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
+Link: https://lore.kernel.org/r/20230620125813.f428c856030d.I2c2bb808e945adb71bc15f5b2bac2d8957ea90eb@changeid
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+index 45dfee3ad8c60..2d1755598b475 100644
+--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
++++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+@@ -2544,7 +2544,7 @@ int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
+ }
+
+ if (iwl_mvm_has_new_rx_api(mvm) && start) {
+- u16 reorder_buf_size = buf_size * sizeof(baid_data->entries[0]);
++ u32 reorder_buf_size = buf_size * sizeof(baid_data->entries[0]);
+
+ /* sparse doesn't like the __align() so don't check */
+ #ifndef __CHECKER__
+--
+2.43.0
+
--- /dev/null
+From 570efecbaf26db9f1f1742f1e0d6530b98bb8537 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 15 Jun 2023 12:04:07 -0600
+Subject: wifi: wext-core: Fix -Wstringop-overflow warning in
+ ioctl_standard_iw_point()
+
+From: Gustavo A. R. Silva <gustavoars@kernel.org>
+
+[ Upstream commit 71e7552c90db2a2767f5c17c7ec72296b0d92061 ]
+
+-Wstringop-overflow is legitimately warning us about extra_size
+pontentially being zero at some point, hence potenially ending
+up _allocating_ zero bytes of memory for extra pointer and then
+trying to access such object in a call to copy_from_user().
+
+Fix this by adding a sanity check to ensure we never end up
+trying to allocate zero bytes of data for extra pointer, before
+continue executing the rest of the code in the function.
+
+Address the following -Wstringop-overflow warning seen when built
+m68k architecture with allyesconfig configuration:
+ from net/wireless/wext-core.c:11:
+In function '_copy_from_user',
+ inlined from 'copy_from_user' at include/linux/uaccess.h:183:7,
+ inlined from 'ioctl_standard_iw_point' at net/wireless/wext-core.c:825:7:
+arch/m68k/include/asm/string.h:48:25: warning: '__builtin_memset' writing 1 or more bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
+ 48 | #define memset(d, c, n) __builtin_memset(d, c, n)
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~
+include/linux/uaccess.h:153:17: note: in expansion of macro 'memset'
+ 153 | memset(to + (n - res), 0, res);
+ | ^~~~~~
+In function 'kmalloc',
+ inlined from 'kzalloc' at include/linux/slab.h:694:9,
+ inlined from 'ioctl_standard_iw_point' at net/wireless/wext-core.c:819:10:
+include/linux/slab.h:577:16: note: at offset 1 into destination object of size 0 allocated by '__kmalloc'
+ 577 | return __kmalloc(size, flags);
+ | ^~~~~~~~~~~~~~~~~~~~~~
+
+This help with the ongoing efforts to globally enable
+-Wstringop-overflow.
+
+Link: https://github.com/KSPP/linux/issues/315
+Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Link: https://lore.kernel.org/r/ZItSlzvIpjdjNfd8@work
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/wireless/wext-core.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
+index fe8765c4075d3..8a4b85f96a13a 100644
+--- a/net/wireless/wext-core.c
++++ b/net/wireless/wext-core.c
+@@ -799,6 +799,12 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
+ }
+ }
+
++ /* Sanity-check to ensure we never end up _allocating_ zero
++ * bytes of data for extra.
++ */
++ if (extra_size <= 0)
++ return -EFAULT;
++
+ /* kzalloc() ensures NULL-termination for essid_compat. */
+ extra = kzalloc(extra_size, GFP_KERNEL);
+ if (!extra)
+--
+2.43.0
+
--- /dev/null
+From 10cf29893a9ec5ba8d4838b0a899657cf2b5da43 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 17:04:59 +0200
+Subject: xhci: cleanup xhci_hub_control port references
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+[ Upstream commit faaae0190dcd1e230616c85bbc3b339f27ba5b81 ]
+
+Both port number and port structure of a port are referred to several
+times when handing hub requests in xhci.
+
+Use more suitable data types and readable names for these.
+Cleanup only, no functional changes
+
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20230202150505.618915-6-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: d7cdfc319b2b ("xhci: track port suspend state correctly in unsuccessful resume cases")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-hub.c | 123 ++++++++++++++++++------------------
+ 1 file changed, 63 insertions(+), 60 deletions(-)
+
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index b9754784161d7..3526665575af2 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -1194,11 +1194,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 test_mode = 0;
+ struct xhci_hub *rhub;
+ struct xhci_port **ports;
++ struct xhci_port *port;
++ int portnum1;
+
+ rhub = xhci_get_rhub(hcd);
+ ports = rhub->ports;
+ max_ports = rhub->num_ports;
+ bus_state = &rhub->bus_state;
++ portnum1 = wIndex & 0xff;
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ switch (typeReq) {
+@@ -1232,10 +1235,12 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return retval;
+ case GetPortStatus:
+- if (!wIndex || wIndex > max_ports)
++ if (!portnum1 || portnum1 > max_ports)
+ goto error;
++
+ wIndex--;
+- temp = readl(ports[wIndex]->addr);
++ port = ports[portnum1 - 1];
++ temp = readl(port->addr);
+ if (temp == ~(u32)0) {
+ xhci_hc_died(xhci);
+ retval = -ENODEV;
+@@ -1248,7 +1253,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ goto error;
+
+ xhci_dbg(xhci, "Get port status %d-%d read: 0x%x, return 0x%x",
+- hcd->self.busnum, wIndex + 1, temp, status);
++ hcd->self.busnum, portnum1, temp, status);
+
+ put_unaligned(cpu_to_le32(status), (__le32 *) buf);
+ /* if USB 3.1 extended port status return additional 4 bytes */
+@@ -1260,7 +1265,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ retval = -EINVAL;
+ break;
+ }
+- port_li = readl(ports[wIndex]->addr + PORTLI);
++ port_li = readl(port->addr + PORTLI);
+ status = xhci_get_ext_port_status(temp, port_li);
+ put_unaligned_le32(status, &buf[4]);
+ }
+@@ -1274,11 +1279,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ test_mode = (wIndex & 0xff00) >> 8;
+ /* The MSB of wIndex is the U1/U2 timeout */
+ timeout = (wIndex & 0xff00) >> 8;
++
+ wIndex &= 0xff;
+- if (!wIndex || wIndex > max_ports)
++ if (!portnum1 || portnum1 > max_ports)
+ goto error;
++
++ port = ports[portnum1 - 1];
+ wIndex--;
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ if (temp == ~(u32)0) {
+ xhci_hc_died(xhci);
+ retval = -ENODEV;
+@@ -1288,11 +1296,10 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ /* FIXME: What new port features do we need to support? */
+ switch (wValue) {
+ case USB_PORT_FEAT_SUSPEND:
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ if ((temp & PORT_PLS_MASK) != XDEV_U0) {
+ /* Resume the port to U0 first */
+- xhci_set_link_state(xhci, ports[wIndex],
+- XDEV_U0);
++ xhci_set_link_state(xhci, port, XDEV_U0);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ msleep(10);
+ spin_lock_irqsave(&xhci->lock, flags);
+@@ -1301,16 +1308,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ * a port unless the port reports that it is in the
+ * enabled (PED = ‘1’,PLS < ‘3’) state.
+ */
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
+ || (temp & PORT_PLS_MASK) >= XDEV_U3) {
+ xhci_warn(xhci, "USB core suspending port %d-%d not in U0/U1/U2\n",
+- hcd->self.busnum, wIndex + 1);
++ hcd->self.busnum, portnum1);
+ goto error;
+ }
+
+ slot_id = xhci_find_slot_id_by_port(hcd, xhci,
+- wIndex + 1);
++ portnum1);
+ if (!slot_id) {
+ xhci_warn(xhci, "slot_id is zero\n");
+ goto error;
+@@ -1320,21 +1327,21 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ xhci_stop_device(xhci, slot_id, 1);
+ spin_lock_irqsave(&xhci->lock, flags);
+
+- xhci_set_link_state(xhci, ports[wIndex], XDEV_U3);
++ xhci_set_link_state(xhci, port, XDEV_U3);
+
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ msleep(10); /* wait device to enter */
+ spin_lock_irqsave(&xhci->lock, flags);
+
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ bus_state->suspended_ports |= 1 << wIndex;
+ break;
+ case USB_PORT_FEAT_LINK_STATE:
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ /* Disable port */
+ if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
+ xhci_dbg(xhci, "Disable port %d-%d\n",
+- hcd->self.busnum, wIndex + 1);
++ hcd->self.busnum, portnum1);
+ temp = xhci_port_state_to_neutral(temp);
+ /*
+ * Clear all change bits, so that we get a new
+@@ -1343,18 +1350,17 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ temp |= PORT_CSC | PORT_PEC | PORT_WRC |
+ PORT_OCC | PORT_RC | PORT_PLC |
+ PORT_CEC;
+- writel(temp | PORT_PE, ports[wIndex]->addr);
+- temp = readl(ports[wIndex]->addr);
++ writel(temp | PORT_PE, port->addr);
++ temp = readl(port->addr);
+ break;
+ }
+
+ /* Put link in RxDetect (enable port) */
+ if (link_state == USB_SS_PORT_LS_RX_DETECT) {
+ xhci_dbg(xhci, "Enable port %d-%d\n",
+- hcd->self.busnum, wIndex + 1);
+- xhci_set_link_state(xhci, ports[wIndex],
+- link_state);
+- temp = readl(ports[wIndex]->addr);
++ hcd->self.busnum, portnum1);
++ xhci_set_link_state(xhci, port, link_state);
++ temp = readl(port->addr);
+ break;
+ }
+
+@@ -1384,11 +1390,10 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ }
+
+ xhci_dbg(xhci, "Enable compliance mode transition for port %d-%d\n",
+- hcd->self.busnum, wIndex + 1);
+- xhci_set_link_state(xhci, ports[wIndex],
+- link_state);
++ hcd->self.busnum, portnum1);
++ xhci_set_link_state(xhci, port, link_state);
+
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ break;
+ }
+ /* Port must be enabled */
+@@ -1399,8 +1404,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ /* Can't set port link state above '3' (U3) */
+ if (link_state > USB_SS_PORT_LS_U3) {
+ xhci_warn(xhci, "Cannot set port %d-%d link state %d\n",
+- hcd->self.busnum, wIndex + 1,
+- link_state);
++ hcd->self.busnum, portnum1, link_state);
+ goto error;
+ }
+
+@@ -1425,8 +1429,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ reinit_completion(&bus_state->u3exit_done[wIndex]);
+ }
+ if (pls <= XDEV_U3) /* U1, U2, U3 */
+- xhci_set_link_state(xhci, ports[wIndex],
+- USB_SS_PORT_LS_U0);
++ xhci_set_link_state(xhci, port, USB_SS_PORT_LS_U0);
+ if (!wait_u0) {
+ if (pls > XDEV_U3)
+ goto error;
+@@ -1436,16 +1439,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ if (!wait_for_completion_timeout(&bus_state->u3exit_done[wIndex],
+ msecs_to_jiffies(500)))
+ xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n",
+- hcd->self.busnum, wIndex + 1);
++ hcd->self.busnum, portnum1);
+ spin_lock_irqsave(&xhci->lock, flags);
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ break;
+ }
+
+ if (link_state == USB_SS_PORT_LS_U3) {
+ int retries = 16;
+ slot_id = xhci_find_slot_id_by_port(hcd, xhci,
+- wIndex + 1);
++ portnum1);
+ if (slot_id) {
+ /* unlock to execute stop endpoint
+ * commands */
+@@ -1454,16 +1457,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ xhci_stop_device(xhci, slot_id, 1);
+ spin_lock_irqsave(&xhci->lock, flags);
+ }
+- xhci_set_link_state(xhci, ports[wIndex], USB_SS_PORT_LS_U3);
++ xhci_set_link_state(xhci, port, USB_SS_PORT_LS_U3);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ while (retries--) {
+ usleep_range(4000, 8000);
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ if ((temp & PORT_PLS_MASK) == XDEV_U3)
+ break;
+ }
+ spin_lock_irqsave(&xhci->lock, flags);
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ bus_state->suspended_ports |= 1 << wIndex;
+ }
+ break;
+@@ -1478,39 +1481,38 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ break;
+ case USB_PORT_FEAT_RESET:
+ temp = (temp | PORT_RESET);
+- writel(temp, ports[wIndex]->addr);
++ writel(temp, port->addr);
+
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ xhci_dbg(xhci, "set port reset, actual port %d-%d status = 0x%x\n",
+- hcd->self.busnum, wIndex + 1, temp);
++ hcd->self.busnum, portnum1, temp);
+ break;
+ case USB_PORT_FEAT_REMOTE_WAKE_MASK:
+- xhci_set_remote_wake_mask(xhci, ports[wIndex],
+- wake_mask);
+- temp = readl(ports[wIndex]->addr);
++ xhci_set_remote_wake_mask(xhci, port, wake_mask);
++ temp = readl(port->addr);
+ xhci_dbg(xhci, "set port remote wake mask, actual port %d-%d status = 0x%x\n",
+- hcd->self.busnum, wIndex + 1, temp);
++ hcd->self.busnum, portnum1, temp);
+ break;
+ case USB_PORT_FEAT_BH_PORT_RESET:
+ temp |= PORT_WR;
+- writel(temp, ports[wIndex]->addr);
+- temp = readl(ports[wIndex]->addr);
++ writel(temp, port->addr);
++ temp = readl(port->addr);
+ break;
+ case USB_PORT_FEAT_U1_TIMEOUT:
+ if (hcd->speed < HCD_USB3)
+ goto error;
+- temp = readl(ports[wIndex]->addr + PORTPMSC);
++ temp = readl(port->addr + PORTPMSC);
+ temp &= ~PORT_U1_TIMEOUT_MASK;
+ temp |= PORT_U1_TIMEOUT(timeout);
+- writel(temp, ports[wIndex]->addr + PORTPMSC);
++ writel(temp, port->addr + PORTPMSC);
+ break;
+ case USB_PORT_FEAT_U2_TIMEOUT:
+ if (hcd->speed < HCD_USB3)
+ goto error;
+- temp = readl(ports[wIndex]->addr + PORTPMSC);
++ temp = readl(port->addr + PORTPMSC);
+ temp &= ~PORT_U2_TIMEOUT_MASK;
+ temp |= PORT_U2_TIMEOUT(timeout);
+- writel(temp, ports[wIndex]->addr + PORTPMSC);
++ writel(temp, port->addr + PORTPMSC);
+ break;
+ case USB_PORT_FEAT_TEST:
+ /* 4.19.6 Port Test Modes (USB2 Test Mode) */
+@@ -1526,13 +1528,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ goto error;
+ }
+ /* unblock any posted writes */
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ break;
+ case ClearPortFeature:
+- if (!wIndex || wIndex > max_ports)
++ if (!portnum1 || portnum1 > max_ports)
+ goto error;
++
++ port = ports[portnum1 - 1];
++
+ wIndex--;
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ if (temp == ~(u32)0) {
+ xhci_hc_died(xhci);
+ retval = -ENODEV;
+@@ -1542,7 +1547,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ temp = xhci_port_state_to_neutral(temp);
+ switch (wValue) {
+ case USB_PORT_FEAT_SUSPEND:
+- temp = readl(ports[wIndex]->addr);
++ temp = readl(port->addr);
+ xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n");
+ xhci_dbg(xhci, "PORTSC %04x\n", temp);
+ if (temp & PORT_RESET)
+@@ -1553,20 +1558,18 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+
+ set_bit(wIndex, &bus_state->resuming_ports);
+ usb_hcd_start_port_resume(&hcd->self, wIndex);
+- xhci_set_link_state(xhci, ports[wIndex],
+- XDEV_RESUME);
++ xhci_set_link_state(xhci, port, XDEV_RESUME);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ msleep(USB_RESUME_TIMEOUT);
+ spin_lock_irqsave(&xhci->lock, flags);
+- xhci_set_link_state(xhci, ports[wIndex],
+- XDEV_U0);
++ xhci_set_link_state(xhci, port, XDEV_U0);
+ clear_bit(wIndex, &bus_state->resuming_ports);
+ usb_hcd_end_port_resume(&hcd->self, wIndex);
+ }
+ bus_state->port_c_suspend |= 1 << wIndex;
+
+ slot_id = xhci_find_slot_id_by_port(hcd, xhci,
+- wIndex + 1);
++ portnum1);
+ if (!slot_id) {
+ xhci_dbg(xhci, "slot_id is zero\n");
+ goto error;
+@@ -1584,11 +1587,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ case USB_PORT_FEAT_C_PORT_LINK_STATE:
+ case USB_PORT_FEAT_C_PORT_CONFIG_ERROR:
+ xhci_clear_port_change_bit(xhci, wValue, wIndex,
+- ports[wIndex]->addr, temp);
++ port->addr, temp);
+ break;
+ case USB_PORT_FEAT_ENABLE:
+ xhci_disable_port(hcd, xhci, wIndex,
+- ports[wIndex]->addr, temp);
++ port->addr, temp);
+ break;
+ case USB_PORT_FEAT_POWER:
+ xhci_set_port_power(xhci, hcd, wIndex, false, &flags);
+--
+2.43.0
+
--- /dev/null
+From 3d927765e6352753e5103d5437604a9fb090bc1d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 17:05:04 +0200
+Subject: xhci: clear usb2 resume related variables in one place.
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+[ Upstream commit 0e6275452ce26d7ff274a5c1b15ed581a26f7986 ]
+
+Initially resume related USB2 variables were cleared once port
+successfully resumed to U0. Later code was added to clean up
+stale resume variables in case of port failed to resume to U0.
+
+Clear the variables in one place after port is no longer resuming
+or in suspended U3 state.
+
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20230202150505.618915-11-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: d7cdfc319b2b ("xhci: track port suspend state correctly in unsuccessful resume cases")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-hub.c | 38 ++++++++++++++++---------------------
+ 1 file changed, 16 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index d3d3dadaca10b..660a7d0f79a42 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -1071,7 +1071,6 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ struct xhci_bus_state *bus_state;
+ u32 link_state;
+ u32 portnum;
+- int ret;
+
+ bus_state = &port->rhub->bus_state;
+ link_state = portsc & PORT_PLS_MASK;
+@@ -1087,23 +1086,30 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ if (link_state == XDEV_U2)
+ *status |= USB_PORT_STAT_L1;
+ if (link_state == XDEV_U0) {
+- if (port->resume_timestamp)
+- usb_hcd_end_port_resume(&port->rhub->hcd->self,
+- portnum);
+- port->resume_timestamp = 0;
+- clear_bit(portnum, &bus_state->resuming_ports);
+ if (bus_state->suspended_ports & (1 << portnum)) {
+ bus_state->suspended_ports &= ~(1 << portnum);
+ bus_state->port_c_suspend |= 1 << portnum;
+ }
+ }
+ if (link_state == XDEV_RESUME) {
+- ret = xhci_handle_usb2_port_link_resume(port, status,
+- portsc, flags);
+- if (ret)
+- return;
++ xhci_handle_usb2_port_link_resume(port, status, portsc,
++ flags);
+ }
+ }
++
++ /*
++ * Clear usb2 resume signalling variables if port is no longer suspended
++ * or resuming. Port either resumed to U0/U1/U2, disconnected, or in a
++ * error state. Resume related variables should be cleared in all those cases.
++ */
++ if ((link_state != XDEV_U3 &&
++ link_state != XDEV_RESUME) &&
++ (port->resume_timestamp ||
++ test_bit(portnum, &bus_state->resuming_ports))) {
++ port->resume_timestamp = 0;
++ clear_bit(portnum, &bus_state->resuming_ports);
++ usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
++ }
+ }
+
+ /*
+@@ -1158,18 +1164,6 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
+ else
+ xhci_get_usb2_port_status(port, &status, raw_port_status,
+ flags);
+- /*
+- * Clear stale usb2 resume signalling variables in case port changed
+- * state during resume signalling. For example on error
+- */
+- if ((port->resume_timestamp ||
+- test_bit(wIndex, &bus_state->resuming_ports)) &&
+- (raw_port_status & PORT_PLS_MASK) != XDEV_U3 &&
+- (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) {
+- port->resume_timestamp = 0;
+- clear_bit(wIndex, &bus_state->resuming_ports);
+- usb_hcd_end_port_resume(&hcd->self, wIndex);
+- }
+
+ if (bus_state->port_c_suspend & (1 << wIndex))
+ status |= USB_PORT_STAT_C_SUSPEND << 16;
+--
+2.43.0
+
--- /dev/null
+From 65d2a522ce8210d32d2c79ddcf3a77ecdfc4cfd6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 17:05:05 +0200
+Subject: xhci: decouple usb2 port resume and get_port_status request handling
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+[ Upstream commit b0425784b942fffbbdb804896197f1dbccda37c5 ]
+
+The get port status hub request code in xhci-hub.c will complete usb2
+port resume signalling if signalling has been going on for long enough.
+
+The code that completes the resume signalling, and the code that returns
+the port status have gotten too intertwined, so separate them a bit.
+
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20230202150505.618915-12-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: d7cdfc319b2b ("xhci: track port suspend state correctly in unsuccessful resume cases")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-hub.c | 47 ++++++++++++++++++++-----------------
+ 1 file changed, 25 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index 660a7d0f79a42..56c600be272a6 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -905,7 +905,7 @@ static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status,
+ }
+
+ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+- u32 *status, u32 portsc,
++ u32 portsc,
+ unsigned long *flags)
+ {
+ struct xhci_bus_state *bus_state;
+@@ -920,7 +920,6 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ wIndex = port->hcd_portnum;
+
+ if ((portsc & PORT_RESET) || !(portsc & PORT_PE)) {
+- *status = 0xffffffff;
+ return -EINVAL;
+ }
+ /* did port event handler already start resume timing? */
+@@ -954,6 +953,8 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+
+ port->resume_timestamp = 0;
+ clear_bit(wIndex, &bus_state->resuming_ports);
++
++ reinit_completion(&port->rexit_done);
+ port->rexit_active = true;
+
+ xhci_test_and_clear_bit(xhci, port, PORT_PLC);
+@@ -970,7 +971,6 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ wIndex + 1);
+ if (!slot_id) {
+ xhci_dbg(xhci, "slot_id is zero\n");
+- *status = 0xffffffff;
+ return -ENODEV;
+ }
+ xhci_ring_device(xhci, slot_id);
+@@ -979,22 +979,19 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+
+ xhci_warn(xhci, "Port resume timed out, port %d-%d: 0x%x\n",
+ hcd->self.busnum, wIndex + 1, port_status);
+- *status |= USB_PORT_STAT_SUSPEND;
+- port->rexit_active = false;
++ /*
++ * keep rexit_active set if U0 transition failed so we
++ * know to report PORT_STAT_SUSPEND status back to
++ * usbcore. It will be cleared later once the port is
++ * out of RESUME/U3 state
++ */
+ }
+
+ usb_hcd_end_port_resume(&hcd->self, wIndex);
+ bus_state->port_c_suspend |= 1 << wIndex;
+ bus_state->suspended_ports &= ~(1 << wIndex);
+- } else {
+- /*
+- * The resume has been signaling for less than
+- * USB_RESUME_TIME. Report the port status as SUSPEND,
+- * let the usbcore check port status again and clear
+- * resume signaling later.
+- */
+- *status |= USB_PORT_STAT_SUSPEND;
+ }
++
+ return 0;
+ }
+
+@@ -1071,6 +1068,7 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ struct xhci_bus_state *bus_state;
+ u32 link_state;
+ u32 portnum;
++ int err;
+
+ bus_state = &port->rhub->bus_state;
+ link_state = portsc & PORT_PLS_MASK;
+@@ -1092,8 +1090,12 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ }
+ }
+ if (link_state == XDEV_RESUME) {
+- xhci_handle_usb2_port_link_resume(port, status, portsc,
+- flags);
++ err = xhci_handle_usb2_port_link_resume(port, portsc,
++ flags);
++ if (err < 0)
++ *status = 0xffffffff;
++ else if (port->resume_timestamp || port->rexit_active)
++ *status |= USB_PORT_STAT_SUSPEND;
+ }
+ }
+
+@@ -1102,13 +1104,14 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ * or resuming. Port either resumed to U0/U1/U2, disconnected, or in a
+ * error state. Resume related variables should be cleared in all those cases.
+ */
+- if ((link_state != XDEV_U3 &&
+- link_state != XDEV_RESUME) &&
+- (port->resume_timestamp ||
+- test_bit(portnum, &bus_state->resuming_ports))) {
+- port->resume_timestamp = 0;
+- clear_bit(portnum, &bus_state->resuming_ports);
+- usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
++ if (link_state != XDEV_U3 && link_state != XDEV_RESUME) {
++ if (port->resume_timestamp ||
++ test_bit(portnum, &bus_state->resuming_ports)) {
++ port->resume_timestamp = 0;
++ clear_bit(portnum, &bus_state->resuming_ports);
++ usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
++ }
++ port->rexit_active = 0;
+ }
+ }
+
+--
+2.43.0
+
--- /dev/null
+From 3ac1034cc15d99b5de894f10639cb779d2c9b13e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 17:05:01 +0200
+Subject: xhci: move port specific items such as state completions to port
+ structure
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+[ Upstream commit 2996e9fc00c378987c18ecbafe5624581b18c0d6 ]
+
+Now that we have a port structure for each port it makes sense to
+move per port variables, timestamps and completions there.
+Get rid of storing bitfileds and arrays of port specific items per bus.
+
+Move
+unsigned long resume_done;
+insigned long rexit_ports
+struct completion rexit_done;
+struct completion u3exit_done;
+
+Rename rexit_ports to rexit_active, and remove a redundant hcd
+speed check while checking if rexit_active is set.
+
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20230202150505.618915-8-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: d7cdfc319b2b ("xhci: track port suspend state correctly in unsuccessful resume cases")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-hub.c | 31 +++++++++++++++----------------
+ drivers/usb/host/xhci-mem.c | 10 +++-------
+ drivers/usb/host/xhci-ring.c | 13 ++++++-------
+ drivers/usb/host/xhci.h | 9 ++++-----
+ 4 files changed, 28 insertions(+), 35 deletions(-)
+
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index 3526665575af2..7f0c9176b4951 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -924,7 +924,7 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ return -EINVAL;
+ }
+ /* did port event handler already start resume timing? */
+- if (!bus_state->resume_done[wIndex]) {
++ if (!port->resume_done) {
+ /* If not, maybe we are in a host initated resume? */
+ if (test_bit(wIndex, &bus_state->resuming_ports)) {
+ /* Host initated resume doesn't time the resume
+@@ -941,28 +941,27 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ msecs_to_jiffies(USB_RESUME_TIMEOUT);
+
+ set_bit(wIndex, &bus_state->resuming_ports);
+- bus_state->resume_done[wIndex] = timeout;
++ port->resume_done = timeout;
+ mod_timer(&hcd->rh_timer, timeout);
+ usb_hcd_start_port_resume(&hcd->self, wIndex);
+ }
+ /* Has resume been signalled for USB_RESUME_TIME yet? */
+- } else if (time_after_eq(jiffies, bus_state->resume_done[wIndex])) {
++ } else if (time_after_eq(jiffies, port->resume_done)) {
+ int time_left;
+
+ xhci_dbg(xhci, "resume USB2 port %d-%d\n",
+ hcd->self.busnum, wIndex + 1);
+
+- bus_state->resume_done[wIndex] = 0;
++ port->resume_done = 0;
+ clear_bit(wIndex, &bus_state->resuming_ports);
+-
+- set_bit(wIndex, &bus_state->rexit_ports);
++ port->rexit_active = true;
+
+ xhci_test_and_clear_bit(xhci, port, PORT_PLC);
+ xhci_set_link_state(xhci, port, XDEV_U0);
+
+ spin_unlock_irqrestore(&xhci->lock, *flags);
+ time_left = wait_for_completion_timeout(
+- &bus_state->rexit_done[wIndex],
++ &port->rexit_done,
+ msecs_to_jiffies(XHCI_MAX_REXIT_TIMEOUT_MS));
+ spin_lock_irqsave(&xhci->lock, *flags);
+
+@@ -981,7 +980,7 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ xhci_warn(xhci, "Port resume timed out, port %d-%d: 0x%x\n",
+ hcd->self.busnum, wIndex + 1, port_status);
+ *status |= USB_PORT_STAT_SUSPEND;
+- clear_bit(wIndex, &bus_state->rexit_ports);
++ port->rexit_active = false;
+ }
+
+ usb_hcd_end_port_resume(&hcd->self, wIndex);
+@@ -1088,10 +1087,10 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ if (link_state == XDEV_U2)
+ *status |= USB_PORT_STAT_L1;
+ if (link_state == XDEV_U0) {
+- if (bus_state->resume_done[portnum])
++ if (port->resume_done)
+ usb_hcd_end_port_resume(&port->rhub->hcd->self,
+ portnum);
+- bus_state->resume_done[portnum] = 0;
++ port->resume_done = 0;
+ clear_bit(portnum, &bus_state->resuming_ports);
+ if (bus_state->suspended_ports & (1 << portnum)) {
+ bus_state->suspended_ports &= ~(1 << portnum);
+@@ -1163,11 +1162,11 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
+ * Clear stale usb2 resume signalling variables in case port changed
+ * state during resume signalling. For example on error
+ */
+- if ((bus_state->resume_done[wIndex] ||
++ if ((port->resume_done ||
+ test_bit(wIndex, &bus_state->resuming_ports)) &&
+ (raw_port_status & PORT_PLS_MASK) != XDEV_U3 &&
+ (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) {
+- bus_state->resume_done[wIndex] = 0;
++ port->resume_done = 0;
+ clear_bit(wIndex, &bus_state->resuming_ports);
+ usb_hcd_end_port_resume(&hcd->self, wIndex);
+ }
+@@ -1426,7 +1425,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ pls == XDEV_RESUME ||
+ pls == XDEV_RECOVERY) {
+ wait_u0 = true;
+- reinit_completion(&bus_state->u3exit_done[wIndex]);
++ reinit_completion(&port->u3exit_done);
+ }
+ if (pls <= XDEV_U3) /* U1, U2, U3 */
+ xhci_set_link_state(xhci, port, USB_SS_PORT_LS_U0);
+@@ -1436,7 +1435,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ break;
+ }
+ spin_unlock_irqrestore(&xhci->lock, flags);
+- if (!wait_for_completion_timeout(&bus_state->u3exit_done[wIndex],
++ if (!wait_for_completion_timeout(&port->u3exit_done,
+ msecs_to_jiffies(500)))
+ xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n",
+ hcd->self.busnum, portnum1);
+@@ -1675,8 +1674,8 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
+
+ if ((temp & mask) != 0 ||
+ (bus_state->port_c_suspend & 1 << i) ||
+- (bus_state->resume_done[i] && time_after_eq(
+- jiffies, bus_state->resume_done[i]))) {
++ (ports[i]->resume_done && time_after_eq(
++ jiffies, ports[i]->resume_done))) {
+ buf[(i + 1) / 8] |= 1 << (i + 1) % 8;
+ status = 1;
+ }
+diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
+index 6444aef33cf08..f9e3aed40984b 100644
+--- a/drivers/usb/host/xhci-mem.c
++++ b/drivers/usb/host/xhci-mem.c
+@@ -2318,6 +2318,9 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
+ xhci->hw_ports[i].addr = &xhci->op_regs->port_status_base +
+ NUM_PORT_REGS * i;
+ xhci->hw_ports[i].hw_portnum = i;
++
++ init_completion(&xhci->hw_ports[i].rexit_done);
++ init_completion(&xhci->hw_ports[i].u3exit_done);
+ }
+
+ xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags,
+@@ -2587,13 +2590,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
+ */
+ for (i = 0; i < MAX_HC_SLOTS; i++)
+ xhci->devs[i] = NULL;
+- for (i = 0; i < USB_MAXCHILDREN; i++) {
+- xhci->usb2_rhub.bus_state.resume_done[i] = 0;
+- xhci->usb3_rhub.bus_state.resume_done[i] = 0;
+- /* Only the USB 2.0 completions will ever be used. */
+- init_completion(&xhci->usb2_rhub.bus_state.rexit_done[i]);
+- init_completion(&xhci->usb3_rhub.bus_state.u3exit_done[i]);
+- }
+
+ if (scratchpad_alloc(xhci, flags))
+ goto fail;
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
+index 945ed5f3e8588..8038dced215c7 100644
+--- a/drivers/usb/host/xhci-ring.c
++++ b/drivers/usb/host/xhci-ring.c
+@@ -1987,7 +1987,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
+ goto cleanup;
+ } else if (!test_bit(hcd_portnum, &bus_state->resuming_ports)) {
+ xhci_dbg(xhci, "resume HS port %d\n", port_id);
+- bus_state->resume_done[hcd_portnum] = jiffies +
++ port->resume_done = jiffies +
+ msecs_to_jiffies(USB_RESUME_TIMEOUT);
+ set_bit(hcd_portnum, &bus_state->resuming_ports);
+ /* Do the rest in GetPortStatus after resume time delay.
+@@ -1996,7 +1996,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
+ */
+ set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+ mod_timer(&hcd->rh_timer,
+- bus_state->resume_done[hcd_portnum]);
++ port->resume_done);
+ usb_hcd_start_port_resume(&hcd->self, hcd_portnum);
+ bogus_port_status = true;
+ }
+@@ -2008,7 +2008,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
+ (portsc & PORT_PLS_MASK) == XDEV_U1 ||
+ (portsc & PORT_PLS_MASK) == XDEV_U2)) {
+ xhci_dbg(xhci, "resume SS port %d finished\n", port_id);
+- complete(&bus_state->u3exit_done[hcd_portnum]);
++ complete(&port->u3exit_done);
+ /* We've just brought the device into U0/1/2 through either the
+ * Resume state after a device remote wakeup, or through the
+ * U3Exit state after a host-initiated resume. If it's a device
+@@ -2033,10 +2033,9 @@ static void handle_port_status(struct xhci_hcd *xhci,
+ * RExit to a disconnect state). If so, let the the driver know it's
+ * out of the RExit state.
+ */
+- if (!DEV_SUPERSPEED_ANY(portsc) && hcd->speed < HCD_USB3 &&
+- test_and_clear_bit(hcd_portnum,
+- &bus_state->rexit_ports)) {
+- complete(&bus_state->rexit_done[hcd_portnum]);
++ if (hcd->speed < HCD_USB3 && port->rexit_active) {
++ complete(&port->rexit_done);
++ port->rexit_active = false;
+ bogus_port_status = true;
+ goto cleanup;
+ }
+diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
+index 64278cd77f988..22ffbeaa51eb6 100644
+--- a/drivers/usb/host/xhci.h
++++ b/drivers/usb/host/xhci.h
+@@ -1708,13 +1708,8 @@ struct xhci_bus_state {
+ u32 port_c_suspend;
+ u32 suspended_ports;
+ u32 port_remote_wakeup;
+- unsigned long resume_done[USB_MAXCHILDREN];
+ /* which ports have started to resume */
+ unsigned long resuming_ports;
+- /* Which ports are waiting on RExit to U0 transition. */
+- unsigned long rexit_ports;
+- struct completion rexit_done[USB_MAXCHILDREN];
+- struct completion u3exit_done[USB_MAXCHILDREN];
+ };
+
+
+@@ -1738,6 +1733,10 @@ struct xhci_port {
+ struct xhci_hub *rhub;
+ struct xhci_port_cap *port_cap;
+ unsigned int lpm_incapable:1;
++ unsigned long resume_done;
++ bool rexit_active;
++ struct completion rexit_done;
++ struct completion u3exit_done;
+ };
+
+ struct xhci_hub {
+--
+2.43.0
+
--- /dev/null
+From f646a5d44241e6fa54eb2be897bdb6306c612489 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 17:05:03 +0200
+Subject: xhci: rename resume_done to resume_timestamp
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+[ Upstream commit a909d629ae77b97b6288bc3cfe68560454bf79c6 ]
+
+resume_done is just a timestamp, avoid confusing it with completions
+related to port state transitions that are named *_done
+
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20230202150505.618915-10-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: d7cdfc319b2b ("xhci: track port suspend state correctly in unsuccessful resume cases")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-hub.c | 20 ++++++++++----------
+ drivers/usb/host/xhci-ring.c | 4 ++--
+ drivers/usb/host/xhci.h | 2 +-
+ 3 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index 7f0c9176b4951..d3d3dadaca10b 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -924,7 +924,7 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ return -EINVAL;
+ }
+ /* did port event handler already start resume timing? */
+- if (!port->resume_done) {
++ if (!port->resume_timestamp) {
+ /* If not, maybe we are in a host initated resume? */
+ if (test_bit(wIndex, &bus_state->resuming_ports)) {
+ /* Host initated resume doesn't time the resume
+@@ -941,18 +941,18 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
+ msecs_to_jiffies(USB_RESUME_TIMEOUT);
+
+ set_bit(wIndex, &bus_state->resuming_ports);
+- port->resume_done = timeout;
++ port->resume_timestamp = timeout;
+ mod_timer(&hcd->rh_timer, timeout);
+ usb_hcd_start_port_resume(&hcd->self, wIndex);
+ }
+ /* Has resume been signalled for USB_RESUME_TIME yet? */
+- } else if (time_after_eq(jiffies, port->resume_done)) {
++ } else if (time_after_eq(jiffies, port->resume_timestamp)) {
+ int time_left;
+
+ xhci_dbg(xhci, "resume USB2 port %d-%d\n",
+ hcd->self.busnum, wIndex + 1);
+
+- port->resume_done = 0;
++ port->resume_timestamp = 0;
+ clear_bit(wIndex, &bus_state->resuming_ports);
+ port->rexit_active = true;
+
+@@ -1087,10 +1087,10 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ if (link_state == XDEV_U2)
+ *status |= USB_PORT_STAT_L1;
+ if (link_state == XDEV_U0) {
+- if (port->resume_done)
++ if (port->resume_timestamp)
+ usb_hcd_end_port_resume(&port->rhub->hcd->self,
+ portnum);
+- port->resume_done = 0;
++ port->resume_timestamp = 0;
+ clear_bit(portnum, &bus_state->resuming_ports);
+ if (bus_state->suspended_ports & (1 << portnum)) {
+ bus_state->suspended_ports &= ~(1 << portnum);
+@@ -1162,11 +1162,11 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
+ * Clear stale usb2 resume signalling variables in case port changed
+ * state during resume signalling. For example on error
+ */
+- if ((port->resume_done ||
++ if ((port->resume_timestamp ||
+ test_bit(wIndex, &bus_state->resuming_ports)) &&
+ (raw_port_status & PORT_PLS_MASK) != XDEV_U3 &&
+ (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) {
+- port->resume_done = 0;
++ port->resume_timestamp = 0;
+ clear_bit(wIndex, &bus_state->resuming_ports);
+ usb_hcd_end_port_resume(&hcd->self, wIndex);
+ }
+@@ -1674,8 +1674,8 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
+
+ if ((temp & mask) != 0 ||
+ (bus_state->port_c_suspend & 1 << i) ||
+- (ports[i]->resume_done && time_after_eq(
+- jiffies, ports[i]->resume_done))) {
++ (ports[i]->resume_timestamp && time_after_eq(
++ jiffies, ports[i]->resume_timestamp))) {
+ buf[(i + 1) / 8] |= 1 << (i + 1) % 8;
+ status = 1;
+ }
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
+index 8038dced215c7..aa12da0796d2d 100644
+--- a/drivers/usb/host/xhci-ring.c
++++ b/drivers/usb/host/xhci-ring.c
+@@ -1987,7 +1987,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
+ goto cleanup;
+ } else if (!test_bit(hcd_portnum, &bus_state->resuming_ports)) {
+ xhci_dbg(xhci, "resume HS port %d\n", port_id);
+- port->resume_done = jiffies +
++ port->resume_timestamp = jiffies +
+ msecs_to_jiffies(USB_RESUME_TIMEOUT);
+ set_bit(hcd_portnum, &bus_state->resuming_ports);
+ /* Do the rest in GetPortStatus after resume time delay.
+@@ -1996,7 +1996,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
+ */
+ set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+ mod_timer(&hcd->rh_timer,
+- port->resume_done);
++ port->resume_timestamp);
+ usb_hcd_start_port_resume(&hcd->self, hcd_portnum);
+ bogus_port_status = true;
+ }
+diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
+index 22ffbeaa51eb6..8ae33db1e4bcc 100644
+--- a/drivers/usb/host/xhci.h
++++ b/drivers/usb/host/xhci.h
+@@ -1733,7 +1733,7 @@ struct xhci_port {
+ struct xhci_hub *rhub;
+ struct xhci_port_cap *port_cap;
+ unsigned int lpm_incapable:1;
+- unsigned long resume_done;
++ unsigned long resume_timestamp;
+ bool rexit_active;
+ struct completion rexit_done;
+ struct completion u3exit_done;
+--
+2.43.0
+
--- /dev/null
+From 5a5834b6e35afa4e79b994e6d344b5e60353ce11 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Sep 2023 17:31:06 +0300
+Subject: xhci: track port suspend state correctly in unsuccessful resume cases
+
+From: Mathias Nyman <mathias.nyman@linux.intel.com>
+
+[ Upstream commit d7cdfc319b2bcf6899ab0a05eec0958bc802a9a1 ]
+
+xhci-hub.c tracks suspended ports in a suspended_port bitfield.
+This is checked when responding to a Get_Status(PORT) request to see if a
+port in running U0 state was recently resumed, and adds the required
+USB_PORT_STAT_C_SUSPEND change bit in those cases.
+
+The suspended_port bit was left uncleared if a device is disconnected
+during suspend. The bit remained set even when a new device was connected
+and enumerated. The set bit resulted in a incorrect Get_Status(PORT)
+response with a bogus USB_PORT_STAT_C_SUSPEND change
+bit set once the new device reached U0 link state.
+
+USB_PORT_STAT_C_SUSPEND change bit is only used for USB2 ports, but
+xhci-hub keeps track of both USB2 and USB3 suspended ports.
+
+Cc: stable@vger.kernel.org
+Reported-by: Wesley Cheng <quic_wcheng@quicinc.com>
+Closes: https://lore.kernel.org/linux-usb/d68aa806-b26a-0e43-42fb-b8067325e967@quicinc.com/
+Fixes: 1d5810b6923c ("xhci: Rework port suspend structures for limited ports.")
+Tested-by: Wesley Cheng <quic_wcheng@quicinc.com>
+Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
+Link: https://lore.kernel.org/r/20230915143108.1532163-3-mathias.nyman@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-hub.c | 19 ++++++++++---------
+ 1 file changed, 10 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index 56c600be272a6..723201394eaa8 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -1043,19 +1043,19 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
+ *status |= USB_PORT_STAT_C_CONFIG_ERROR << 16;
+
+ /* USB3 specific wPortStatus bits */
+- if (portsc & PORT_POWER) {
++ if (portsc & PORT_POWER)
+ *status |= USB_SS_PORT_STAT_POWER;
+- /* link state handling */
+- if (link_state == XDEV_U0)
+- bus_state->suspended_ports &= ~(1 << portnum);
+- }
+
+- /* remote wake resume signaling complete */
+- if (bus_state->port_remote_wakeup & (1 << portnum) &&
++ /* no longer suspended or resuming */
++ if (link_state != XDEV_U3 &&
+ link_state != XDEV_RESUME &&
+ link_state != XDEV_RECOVERY) {
+- bus_state->port_remote_wakeup &= ~(1 << portnum);
+- usb_hcd_end_port_resume(&hcd->self, portnum);
++ /* remote wake resume signaling complete */
++ if (bus_state->port_remote_wakeup & (1 << portnum)) {
++ bus_state->port_remote_wakeup &= ~(1 << portnum);
++ usb_hcd_end_port_resume(&hcd->self, portnum);
++ }
++ bus_state->suspended_ports &= ~(1 << portnum);
+ }
+
+ xhci_hub_report_usb3_link_state(xhci, status, portsc);
+@@ -1112,6 +1112,7 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
+ usb_hcd_end_port_resume(&port->rhub->hcd->self, portnum);
+ }
+ port->rexit_active = 0;
++ bus_state->suspended_ports &= ~(1 << portnum);
+ }
+ }
+
+--
+2.43.0
+