--- /dev/null
+From d9cd70b32d438acfe63a77de50676970903e08e7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 16 Nov 2018 15:31:10 +0530
+Subject: ARM: dts: exynos: Add all CPUs in cooling maps
+
+From: Viresh Kumar <viresh.kumar@linaro.org>
+
+[ Upstream commit 670734f5581023a2e695e82ea662e4d603fd3e8a ]
+
+Each CPU can (and does) participate in cooling down the system but the
+DT only captures a handful of them, normally CPU0, in the cooling maps.
+Things work by chance currently as under normal circumstances its the
+first CPU of each cluster which is used by the operating systems to
+probe the cooling devices. But as soon as this CPU ordering changes and
+any other CPU is used to bring up the cooling device, we will start
+seeing failures.
+
+Also the DT is rather incomplete when we list only one CPU in the
+cooling maps, as the hardware doesn't have any such limitations.
+
+Update cooling maps to include all devices affected by individual trip
+points.
+
+Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Stable-dep-of: 33e2c595e2e4 ("ARM: dts: exynos: correct TMU phandle in Exynos5250")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos3250-artik5.dtsi | 6 +-
+ arch/arm/boot/dts/exynos3250-monk.dts | 6 +-
+ arch/arm/boot/dts/exynos3250-rinato.dts | 6 +-
+ arch/arm/boot/dts/exynos4210-trats.dts | 4 +-
+ arch/arm/boot/dts/exynos4210.dtsi | 2 +-
+ .../boot/dts/exynos4412-itop-scp-core.dtsi | 8 +-
+ arch/arm/boot/dts/exynos4412-midas.dtsi | 8 +-
+ .../boot/dts/exynos4412-odroid-common.dtsi | 8 +-
+ arch/arm/boot/dts/exynos4412-odroidu3.dts | 18 ++-
+ arch/arm/boot/dts/exynos4412.dtsi | 6 +-
+ arch/arm/boot/dts/exynos5250.dtsi | 7 +-
+ arch/arm/boot/dts/exynos5422-odroidhc1.dts | 106 +++++++++++-------
+ .../boot/dts/exynos5422-odroidxu3-common.dtsi | 106 +++++++++++-------
+ 13 files changed, 178 insertions(+), 113 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos3250-artik5.dtsi b/arch/arm/boot/dts/exynos3250-artik5.dtsi
+index 6e30db644c83a..86aa0956b2d3b 100644
+--- a/arch/arm/boot/dts/exynos3250-artik5.dtsi
++++ b/arch/arm/boot/dts/exynos3250-artik5.dtsi
+@@ -36,11 +36,13 @@
+ cooling-maps {
+ map0 {
+ /* Corresponds to 500MHz */
+- cooling-device = <&cpu0 5 5>;
++ cooling-device = <&cpu0 5 5>,
++ <&cpu1 5 5>;
+ };
+ map1 {
+ /* Corresponds to 200MHz */
+- cooling-device = <&cpu0 8 8>;
++ cooling-device = <&cpu0 8 8>,
++ <&cpu1 8 8>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos3250-monk.dts b/arch/arm/boot/dts/exynos3250-monk.dts
+index d343dc13ceecd..c9b6fb65d6861 100644
+--- a/arch/arm/boot/dts/exynos3250-monk.dts
++++ b/arch/arm/boot/dts/exynos3250-monk.dts
+@@ -121,11 +121,13 @@
+ cooling-maps {
+ map0 {
+ /* Correspond to 500MHz at freq_table */
+- cooling-device = <&cpu0 5 5>;
++ cooling-device = <&cpu0 5 5>,
++ <&cpu1 5 5>;
+ };
+ map1 {
+ /* Correspond to 200MHz at freq_table */
+- cooling-device = <&cpu0 8 8>;
++ cooling-device = <&cpu0 8 8>,
++ <&cpu1 8 8>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts b/arch/arm/boot/dts/exynos3250-rinato.dts
+index e398604b2ce0f..4eb5f79b1c3b2 100644
+--- a/arch/arm/boot/dts/exynos3250-rinato.dts
++++ b/arch/arm/boot/dts/exynos3250-rinato.dts
+@@ -116,11 +116,13 @@
+ cooling-maps {
+ map0 {
+ /* Corresponds to 500MHz */
+- cooling-device = <&cpu0 5 5>;
++ cooling-device = <&cpu0 5 5>,
++ <&cpu1 5 5>;
+ };
+ map1 {
+ /* Corresponds to 200MHz */
+- cooling-device = <&cpu0 8 8>;
++ cooling-device = <&cpu0 8 8>,
++ <&cpu1 8 8>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
+index 6f1d76cb79515..230969556e1ce 100644
+--- a/arch/arm/boot/dts/exynos4210-trats.dts
++++ b/arch/arm/boot/dts/exynos4210-trats.dts
+@@ -138,11 +138,11 @@
+ cooling-maps {
+ map0 {
+ /* Corresponds to 800MHz at freq_table */
+- cooling-device = <&cpu0 2 2>;
++ cooling-device = <&cpu0 2 2>, <&cpu1 2 2>;
+ };
+ map1 {
+ /* Corresponds to 200MHz at freq_table */
+- cooling-device = <&cpu0 4 4>;
++ cooling-device = <&cpu0 4 4>, <&cpu1 4 4>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
+index 24bea84034af2..b7b6edbc0499e 100644
+--- a/arch/arm/boot/dts/exynos4210.dtsi
++++ b/arch/arm/boot/dts/exynos4210.dtsi
+@@ -51,7 +51,7 @@
+ #cooling-cells = <2>; /* min followed by max */
+ };
+
+- cpu@901 {
++ cpu1: cpu@901 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a9";
+ reg = <0x901>;
+diff --git a/arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi b/arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi
+index ab7affab7f1c0..4ca05599ee2ac 100644
+--- a/arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi
++++ b/arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi
+@@ -45,11 +45,15 @@
+ cooling-maps {
+ map0 {
+ /* Corresponds to 800MHz at freq_table */
+- cooling-device = <&cpu0 7 7>;
++ cooling-device = <&cpu0 7 7>, <&cpu1 7 7>,
++ <&cpu2 7 7>, <&cpu3 7 7>;
+ };
+ map1 {
+ /* Corresponds to 200MHz at freq_table */
+- cooling-device = <&cpu0 13 13>;
++ cooling-device = <&cpu0 13 13>,
++ <&cpu1 13 13>,
++ <&cpu2 13 13>,
++ <&cpu3 13 13>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos4412-midas.dtsi b/arch/arm/boot/dts/exynos4412-midas.dtsi
+index 93c8918e599bd..047240a32097a 100644
+--- a/arch/arm/boot/dts/exynos4412-midas.dtsi
++++ b/arch/arm/boot/dts/exynos4412-midas.dtsi
+@@ -267,11 +267,15 @@
+ cooling-maps {
+ map0 {
+ /* Corresponds to 800MHz at freq_table */
+- cooling-device = <&cpu0 7 7>;
++ cooling-device = <&cpu0 7 7>, <&cpu1 7 7>,
++ <&cpu2 7 7>, <&cpu3 7 7>;
+ };
+ map1 {
+ /* Corresponds to 200MHz at freq_table */
+- cooling-device = <&cpu0 13 13>;
++ cooling-device = <&cpu0 13 13>,
++ <&cpu1 13 13>,
++ <&cpu2 13 13>,
++ <&cpu3 13 13>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+index dbca8eeefae13..e269818668bb1 100644
+--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
++++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+@@ -72,11 +72,15 @@
+ cooling-maps {
+ cooling_map0: map0 {
+ /* Corresponds to 800MHz at freq_table */
+- cooling-device = <&cpu0 7 7>;
++ cooling-device = <&cpu0 7 7>, <&cpu1 7 7>,
++ <&cpu2 7 7>, <&cpu3 7 7>;
+ };
+ cooling_map1: map1 {
+ /* Corresponds to 200MHz at freq_table */
+- cooling-device = <&cpu0 13 13>;
++ cooling-device = <&cpu0 13 13>,
++ <&cpu1 13 13>,
++ <&cpu2 13 13>,
++ <&cpu3 13 13>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
+index 459919b65df81..2bdf899df4366 100644
+--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
++++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
+@@ -45,24 +45,22 @@
+ cooling-maps {
+ map0 {
+ trip = <&cpu_alert1>;
+- cooling-device = <&cpu0 9 9>;
++ cooling-device = <&cpu0 9 9>, <&cpu1 9 9>,
++ <&cpu2 9 9>, <&cpu3 9 9>,
++ <&fan0 1 2>;
+ };
+ map1 {
+ trip = <&cpu_alert2>;
+- cooling-device = <&cpu0 15 15>;
++ cooling-device = <&cpu0 15 15>,
++ <&cpu1 15 15>,
++ <&cpu2 15 15>,
++ <&cpu3 15 15>,
++ <&fan0 2 3>;
+ };
+ map2 {
+ trip = <&cpu_alert0>;
+ cooling-device = <&fan0 0 1>;
+ };
+- map3 {
+- trip = <&cpu_alert1>;
+- cooling-device = <&fan0 1 2>;
+- };
+- map4 {
+- trip = <&cpu_alert2>;
+- cooling-device = <&fan0 2 3>;
+- };
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
+index 51f72f0327e52..cd04bb4aea5f8 100644
+--- a/arch/arm/boot/dts/exynos4412.dtsi
++++ b/arch/arm/boot/dts/exynos4412.dtsi
+@@ -45,7 +45,7 @@
+ #cooling-cells = <2>; /* min followed by max */
+ };
+
+- cpu@a01 {
++ cpu1: cpu@a01 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a9";
+ reg = <0xA01>;
+@@ -55,7 +55,7 @@
+ #cooling-cells = <2>; /* min followed by max */
+ };
+
+- cpu@a02 {
++ cpu2: cpu@a02 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a9";
+ reg = <0xA02>;
+@@ -65,7 +65,7 @@
+ #cooling-cells = <2>; /* min followed by max */
+ };
+
+- cpu@a03 {
++ cpu3: cpu@a03 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a9";
+ reg = <0xA03>;
+diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
+index b85527faa6ea4..e6b1a8a9b832c 100644
+--- a/arch/arm/boot/dts/exynos5250.dtsi
++++ b/arch/arm/boot/dts/exynos5250.dtsi
+@@ -59,7 +59,7 @@
+ operating-points-v2 = <&cpu0_opp_table>;
+ #cooling-cells = <2>; /* min followed by max */
+ };
+- cpu@1 {
++ cpu1: cpu@1 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a15";
+ reg = <1>;
+@@ -1066,11 +1066,12 @@
+ cooling-maps {
+ map0 {
+ /* Corresponds to 800MHz at freq_table */
+- cooling-device = <&cpu0 9 9>;
++ cooling-device = <&cpu0 9 9>, <&cpu1 9 9>;
+ };
+ map1 {
+ /* Corresponds to 200MHz at freq_table */
+- cooling-device = <&cpu0 15 15>;
++ cooling-device = <&cpu0 15 15>,
++ <&cpu1 15 15>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos5422-odroidhc1.dts b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
+index abc6fb7d27259..fce5a4579693e 100644
+--- a/arch/arm/boot/dts/exynos5422-odroidhc1.dts
++++ b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
+@@ -56,24 +56,30 @@
+ */
+ map0 {
+ trip = <&cpu0_alert0>;
+- cooling-device = <&cpu0 0 2>;
+- };
+- map1 {
+- trip = <&cpu0_alert0>;
+- cooling-device = <&cpu4 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ /*
+ * When reaching cpu0_alert1, reduce CPU
+ * further, down to 600 MHz (12 steps for big,
+ * 7 steps for LITTLE).
+ */
+- map2 {
+- trip = <&cpu0_alert1>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map3 {
++ map1 {
+ trip = <&cpu0_alert1>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+@@ -99,19 +105,25 @@
+ cooling-maps {
+ map0 {
+ trip = <&cpu1_alert0>;
+- cooling-device = <&cpu0 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ map1 {
+- trip = <&cpu1_alert0>;
+- cooling-device = <&cpu4 0 2>;
+- };
+- map2 {
+- trip = <&cpu1_alert1>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map3 {
+ trip = <&cpu1_alert1>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+@@ -137,19 +149,25 @@
+ cooling-maps {
+ map0 {
+ trip = <&cpu2_alert0>;
+- cooling-device = <&cpu0 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ map1 {
+- trip = <&cpu2_alert0>;
+- cooling-device = <&cpu4 0 2>;
+- };
+- map2 {
+- trip = <&cpu2_alert1>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map3 {
+ trip = <&cpu2_alert1>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+@@ -175,19 +193,25 @@
+ cooling-maps {
+ map0 {
+ trip = <&cpu3_alert0>;
+- cooling-device = <&cpu0 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ map1 {
+- trip = <&cpu3_alert0>;
+- cooling-device = <&cpu4 0 2>;
+- };
+- map2 {
+- trip = <&cpu3_alert1>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map3 {
+ trip = <&cpu3_alert1>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+index 96e281c0a118a..264651141d688 100644
+--- a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
++++ b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+@@ -113,24 +113,30 @@
+ */
+ map3 {
+ trip = <&cpu0_alert3>;
+- cooling-device = <&cpu0 0 2>;
+- };
+- map4 {
+- trip = <&cpu0_alert3>;
+- cooling-device = <&cpu4 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ /*
+ * When reaching cpu0_alert4, reduce CPU
+ * further, down to 600 MHz (12 steps for big,
+ * 7 steps for LITTLE).
+ */
+- map5 {
+- trip = <&cpu0_alert4>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map6 {
++ map4 {
+ trip = <&cpu0_alert4>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+@@ -185,19 +191,25 @@
+ };
+ map3 {
+ trip = <&cpu1_alert3>;
+- cooling-device = <&cpu0 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ map4 {
+- trip = <&cpu1_alert3>;
+- cooling-device = <&cpu4 0 2>;
+- };
+- map5 {
+- trip = <&cpu1_alert4>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map6 {
+ trip = <&cpu1_alert4>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+@@ -252,19 +264,25 @@
+ };
+ map3 {
+ trip = <&cpu2_alert3>;
+- cooling-device = <&cpu0 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ map4 {
+- trip = <&cpu2_alert3>;
+- cooling-device = <&cpu4 0 2>;
+- };
+- map5 {
+- trip = <&cpu2_alert4>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map6 {
+ trip = <&cpu2_alert4>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+@@ -319,19 +337,25 @@
+ };
+ map3 {
+ trip = <&cpu3_alert3>;
+- cooling-device = <&cpu0 0 2>;
++ cooling-device = <&cpu0 0 2>,
++ <&cpu1 0 2>,
++ <&cpu2 0 2>,
++ <&cpu3 0 2>,
++ <&cpu4 0 2>,
++ <&cpu5 0 2>,
++ <&cpu6 0 2>,
++ <&cpu7 0 2>;
+ };
+ map4 {
+- trip = <&cpu3_alert3>;
+- cooling-device = <&cpu4 0 2>;
+- };
+- map5 {
+- trip = <&cpu3_alert4>;
+- cooling-device = <&cpu0 3 7>;
+- };
+- map6 {
+ trip = <&cpu3_alert4>;
+- cooling-device = <&cpu4 3 12>;
++ cooling-device = <&cpu0 3 7>,
++ <&cpu1 3 7>,
++ <&cpu2 3 7>,
++ <&cpu3 3 7>,
++ <&cpu4 3 12>,
++ <&cpu5 3 12>,
++ <&cpu6 3 12>,
++ <&cpu7 3 12>;
+ };
+ };
+ };
+--
+2.39.2
+
--- /dev/null
+From 469b0ec84785f515bd03b948b71cb018796a06e0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 21 Jan 2020 08:05:10 +0100
+Subject: ARM: dts: exynos: Add GPU thermal zone cooling maps for Odroid
+ XU3/XU4/HC1
+
+From: Marek Szyprowski <m.szyprowski@samsung.com>
+
+[ Upstream commit 1c651356f482ff08f6acef197a362f2e71d55a98 ]
+
+Add trip points and cooling maps for GPU thermal zone for Odroid
+XU3/XU4/HC1 boards. Trip points are based on the CPU thermal zone for the
+those boards.
+
+Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Stable-dep-of: 2e3d0e20d845 ("ARM: dts: exynos: correct TMU phandle in Odroid HC1")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos5422-odroidhc1.dts | 30 ++++++++++
+ .../boot/dts/exynos5422-odroidxu3-common.dtsi | 59 +++++++++++++++++++
+ 2 files changed, 89 insertions(+)
+
+diff --git a/arch/arm/boot/dts/exynos5422-odroidhc1.dts b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
+index fce5a4579693e..3235d7a27e042 100644
+--- a/arch/arm/boot/dts/exynos5422-odroidhc1.dts
++++ b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
+@@ -215,6 +215,36 @@
+ };
+ };
+ };
++ gpu_thermal: gpu-thermal {
++ thermal-sensors = <&tmu_gpu 0>;
++ trips {
++ gpu_alert0: gpu-alert-0 {
++ temperature = <70000>;
++ hysteresis = <10000>;
++ type = "active";
++ };
++ gpu_alert1: gpu-alert-1 {
++ temperature = <85000>;
++ hysteresis = <10000>;
++ type = "active";
++ };
++ gpu_crit0: gpu-crit-0 {
++ temperature = <120000>;
++ hysteresis = <0>;
++ type = "critical";
++ };
++ };
++ cooling-maps {
++ map0 {
++ trip = <&gpu_alert0>;
++ cooling-device = <&gpu 0 2>;
++ };
++ map1 {
++ trip = <&gpu_alert1>;
++ cooling-device = <&gpu 3 6>;
++ };
++ };
++ };
+ };
+
+ };
+diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+index 264651141d688..402d69877fd97 100644
+--- a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
++++ b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+@@ -359,6 +359,65 @@
+ };
+ };
+ };
++ gpu_thermal: gpu-thermal {
++ thermal-sensors = <&tmu_gpu 0>;
++ polling-delay-passive = <250>;
++ polling-delay = <0>;
++ trips {
++ gpu_alert0: gpu-alert-0 {
++ temperature = <50000>;
++ hysteresis = <5000>;
++ type = "active";
++ };
++ gpu_alert1: gpu-alert-1 {
++ temperature = <60000>;
++ hysteresis = <5000>;
++ type = "active";
++ };
++ gpu_alert2: gpu-alert-2 {
++ temperature = <70000>;
++ hysteresis = <5000>;
++ type = "active";
++ };
++ gpu_crit0: gpu-crit-0 {
++ temperature = <120000>;
++ hysteresis = <0>;
++ type = "critical";
++ };
++ gpu_alert3: gpu-alert-3 {
++ temperature = <70000>;
++ hysteresis = <10000>;
++ type = "passive";
++ };
++ gpu_alert4: gpu-alert-4 {
++ temperature = <85000>;
++ hysteresis = <10000>;
++ type = "passive";
++ };
++ };
++ cooling-maps {
++ map0 {
++ trip = <&gpu_alert0>;
++ cooling-device = <&fan0 0 1>;
++ };
++ map1 {
++ trip = <&gpu_alert1>;
++ cooling-device = <&fan0 1 2>;
++ };
++ map2 {
++ trip = <&gpu_alert2>;
++ cooling-device = <&fan0 2 3>;
++ };
++ map3 {
++ trip = <&gpu_alert3>;
++ cooling-device = <&gpu 0 2>;
++ };
++ map4 {
++ trip = <&gpu_alert4>;
++ cooling-device = <&gpu 3 6>;
++ };
++ };
++ };
+ };
+ };
+
+--
+2.39.2
+
--- /dev/null
+From 7fd595cc9228be7aa82860d3122dc81e890481e2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 11:58:37 +0100
+Subject: ARM: dts: exynos: correct TMU phandle in Exynos4210
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+[ Upstream commit 408ab6786dbf6dd696488054c9559681112ef994 ]
+
+TMU node uses 0 as thermal-sensor-cells, thus thermal zone referencing
+it must not have an argument to phandle. Since thermal-sensors property is
+already defined in included exynos4-cpu-thermal.dtsi, drop it from
+exynos4210.dtsi to fix the error and remoev redundancy.
+
+Fixes: 9843a2236003 ("ARM: dts: Provide dt bindings identical for Exynos TMU")
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20230209105841.779596-2-krzysztof.kozlowski@linaro.org
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos4210.dtsi | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
+index 2ec6c01550564..24bea84034af2 100644
+--- a/arch/arm/boot/dts/exynos4210.dtsi
++++ b/arch/arm/boot/dts/exynos4210.dtsi
+@@ -387,7 +387,6 @@
+ &cpu_thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+- thermal-sensors = <&tmu 0>;
+ };
+
+ &gic {
+--
+2.39.2
+
--- /dev/null
+From 0ffc2afdbdd2b023b1395a53f5ef720f53bec6cf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 11:58:38 +0100
+Subject: ARM: dts: exynos: correct TMU phandle in Exynos5250
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+[ Upstream commit 33e2c595e2e4016991ead44933a29d1ef93d5f26 ]
+
+TMU node uses 0 as thermal-sensor-cells, thus thermal zone referencing
+it must not have an argument to phandle.
+
+Cc: <stable@vger.kernel.org>
+Fixes: 9843a2236003 ("ARM: dts: Provide dt bindings identical for Exynos TMU")
+Link: https://lore.kernel.org/r/20230209105841.779596-3-krzysztof.kozlowski@linaro.org
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos5250.dtsi | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
+index 1883b8c2cd7b9..c6b0e6413c683 100644
+--- a/arch/arm/boot/dts/exynos5250.dtsi
++++ b/arch/arm/boot/dts/exynos5250.dtsi
+@@ -1061,7 +1061,7 @@
+ &cpu_thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+- thermal-sensors = <&tmu 0>;
++ thermal-sensors = <&tmu>;
+
+ cooling-maps {
+ map0 {
+--
+2.39.2
+
--- /dev/null
+From 4855ea12ed452e3e87aa8fcb6c9e22f4c35c0eea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 11:58:40 +0100
+Subject: ARM: dts: exynos: correct TMU phandle in Odroid HC1
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+[ Upstream commit 2e3d0e20d8456f876607a8af61fdb83dfbf98cb6 ]
+
+TMU node uses 0 as thermal-sensor-cells, thus thermal zone referencing
+it must not have an argument to phandle. This was not critical before,
+but since rework of thermal Devicetree initialization in the
+commit 3fd6d6e2b4e8 ("thermal/of: Rework the thermal device tree
+initialization"), this leads to errors registering thermal zones other
+than first one:
+
+ thermal_sys: cpu0-thermal: Failed to read thermal-sensors cells: -2
+ thermal_sys: Failed to find thermal zone for tmu id=0
+ exynos-tmu 10064000.tmu: Failed to register sensor: -2
+ exynos-tmu: probe of 10064000.tmu failed with error -2
+
+Fixes: 1ac49427b566 ("ARM: dts: exynos: Add support for Hardkernel's Odroid HC1 board")
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20230209105841.779596-5-krzysztof.kozlowski@linaro.org
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos5422-odroidhc1.dts | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos5422-odroidhc1.dts b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
+index 3235d7a27e042..b423cea4c0e99 100644
+--- a/arch/arm/boot/dts/exynos5422-odroidhc1.dts
++++ b/arch/arm/boot/dts/exynos5422-odroidhc1.dts
+@@ -29,7 +29,7 @@
+
+ thermal-zones {
+ cpu0_thermal: cpu0-thermal {
+- thermal-sensors = <&tmu_cpu0 0>;
++ thermal-sensors = <&tmu_cpu0>;
+ trips {
+ cpu0_alert0: cpu-alert-0 {
+ temperature = <70000>; /* millicelsius */
+@@ -84,7 +84,7 @@
+ };
+ };
+ cpu1_thermal: cpu1-thermal {
+- thermal-sensors = <&tmu_cpu1 0>;
++ thermal-sensors = <&tmu_cpu1>;
+ trips {
+ cpu1_alert0: cpu-alert-0 {
+ temperature = <70000>;
+@@ -128,7 +128,7 @@
+ };
+ };
+ cpu2_thermal: cpu2-thermal {
+- thermal-sensors = <&tmu_cpu2 0>;
++ thermal-sensors = <&tmu_cpu2>;
+ trips {
+ cpu2_alert0: cpu-alert-0 {
+ temperature = <70000>;
+@@ -172,7 +172,7 @@
+ };
+ };
+ cpu3_thermal: cpu3-thermal {
+- thermal-sensors = <&tmu_cpu3 0>;
++ thermal-sensors = <&tmu_cpu3>;
+ trips {
+ cpu3_alert0: cpu-alert-0 {
+ temperature = <70000>;
+@@ -216,7 +216,7 @@
+ };
+ };
+ gpu_thermal: gpu-thermal {
+- thermal-sensors = <&tmu_gpu 0>;
++ thermal-sensors = <&tmu_gpu>;
+ trips {
+ gpu_alert0: gpu-alert-0 {
+ temperature = <70000>;
+--
+2.39.2
+
--- /dev/null
+From 8b5793dfb041672ca78d92341260463a2d4fb0db Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 11:58:41 +0100
+Subject: ARM: dts: exynos: correct TMU phandle in Odroid XU3 family
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+[ Upstream commit a3583e92d188ec6c58c7f603ac5e72dd8a11c21a ]
+
+TMU node uses 0 as thermal-sensor-cells, thus thermal zone referencing
+it must not have an argument to phandle. This was not critical before,
+but since rework of thermal Devicetree initialization in the
+commit 3fd6d6e2b4e8 ("thermal/of: Rework the thermal device tree
+initialization"), this leads to errors registering thermal zones other
+than first one:
+
+ thermal_sys: cpu0-thermal: Failed to read thermal-sensors cells: -2
+ thermal_sys: Failed to find thermal zone for tmu id=0
+ exynos-tmu 10064000.tmu: Failed to register sensor: -2
+ exynos-tmu: probe of 10064000.tmu failed with error -2
+
+Fixes: f1722d7dd8b8 ("ARM: dts: Define default thermal-zones for exynos5422")
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20230209105841.779596-6-krzysztof.kozlowski@linaro.org
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+index 402d69877fd97..86f64db15a3dd 100644
+--- a/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
++++ b/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi
+@@ -52,7 +52,7 @@
+
+ thermal-zones {
+ cpu0_thermal: cpu0-thermal {
+- thermal-sensors = <&tmu_cpu0 0>;
++ thermal-sensors = <&tmu_cpu0>;
+ polling-delay-passive = <250>;
+ polling-delay = <0>;
+ trips {
+@@ -141,7 +141,7 @@
+ };
+ };
+ cpu1_thermal: cpu1-thermal {
+- thermal-sensors = <&tmu_cpu1 0>;
++ thermal-sensors = <&tmu_cpu1>;
+ polling-delay-passive = <250>;
+ polling-delay = <0>;
+ trips {
+@@ -214,7 +214,7 @@
+ };
+ };
+ cpu2_thermal: cpu2-thermal {
+- thermal-sensors = <&tmu_cpu2 0>;
++ thermal-sensors = <&tmu_cpu2>;
+ polling-delay-passive = <250>;
+ polling-delay = <0>;
+ trips {
+@@ -287,7 +287,7 @@
+ };
+ };
+ cpu3_thermal: cpu3-thermal {
+- thermal-sensors = <&tmu_cpu3 0>;
++ thermal-sensors = <&tmu_cpu3>;
+ polling-delay-passive = <250>;
+ polling-delay = <0>;
+ trips {
+@@ -360,7 +360,7 @@
+ };
+ };
+ gpu_thermal: gpu-thermal {
+- thermal-sensors = <&tmu_gpu 0>;
++ thermal-sensors = <&tmu_gpu>;
+ polling-delay-passive = <250>;
+ polling-delay = <0>;
+ trips {
+--
+2.39.2
+
--- /dev/null
+From a9791b54725cf8c5054b41421193012efb76ac99 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 18 Jun 2019 21:07:32 +0200
+Subject: ARM: dts: exynos: Fix language typo and indentation
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit c31b11c3eb4d41df4038b0441b15f3f0b2fca5d4 ]
+
+Correct language typo and wrong indentation.
+
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Stable-dep-of: 408ab6786dbf ("ARM: dts: exynos: correct TMU phandle in Exynos4210")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos4210.dtsi | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
+index b6091c27f155d..0ed9ef75075bc 100644
+--- a/arch/arm/boot/dts/exynos4210.dtsi
++++ b/arch/arm/boot/dts/exynos4210.dtsi
+@@ -8,7 +8,7 @@
+ * www.linaro.org
+ *
+ * Samsung's Exynos4210 SoC device nodes are listed in this file. Exynos4210
+- * based board files can include this file and provide values for board specfic
++ * based board files can include this file and provide values for board specific
+ * bindings.
+ *
+ * Note: This file does not include device nodes for all the controllers in
+@@ -379,13 +379,13 @@
+
+ trips {
+ cpu_alert0: cpu-alert-0 {
+- temperature = <85000>; /* millicelsius */
++ temperature = <85000>; /* millicelsius */
+ };
+ cpu_alert1: cpu-alert-1 {
+- temperature = <100000>; /* millicelsius */
++ temperature = <100000>; /* millicelsius */
+ };
+ cpu_alert2: cpu-alert-2 {
+- temperature = <110000>; /* millicelsius */
++ temperature = <110000>; /* millicelsius */
+ };
+ };
+ };
+--
+2.39.2
+
--- /dev/null
+From c732800feec8ea9f551d804ee788ef5b3a356f6f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 15 Apr 2019 20:05:07 +0200
+Subject: ARM: dts: exynos: Move pmu and timer nodes out of soc
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit be00300147ae3c0b2fa4dbc5f00d4332a8d00fac ]
+
+The ARM PMU and ARM architected timer nodes are part of ARM CPU design
+therefore they should not be inside the soc node. This also fixes DTC
+W=1 warnings like:
+
+ arch/arm/boot/dts/exynos3250.dtsi:106.21-135.5:
+ Warning (simple_bus_reg): /soc/fixed-rate-clocks: missing or empty reg/ranges property
+ arch/arm/boot/dts/exynos3250.dtsi:676.7-680.5:
+ Warning (simple_bus_reg): /soc/pmu: missing or empty reg/ranges property
+
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Stable-dep-of: 33e2c595e2e4 ("ARM: dts: exynos: correct TMU phandle in Exynos5250")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos3250.dtsi | 12 +++++-----
+ arch/arm/boot/dts/exynos4.dtsi | 12 +++++-----
+ arch/arm/boot/dts/exynos5250.dtsi | 40 +++++++++++++++----------------
+ arch/arm/boot/dts/exynos54xx.dtsi | 38 ++++++++++++++---------------
+ 4 files changed, 51 insertions(+), 51 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
+index 5892a9f7622fa..af54b306204b8 100644
+--- a/arch/arm/boot/dts/exynos3250.dtsi
++++ b/arch/arm/boot/dts/exynos3250.dtsi
+@@ -97,6 +97,12 @@
+ };
+ };
+
++ pmu {
++ compatible = "arm,cortex-a7-pmu";
++ interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
++ <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
++ };
++
+ soc: soc {
+ compatible = "simple-bus";
+ #address-cells = <1>;
+@@ -673,12 +679,6 @@
+ status = "disabled";
+ };
+
+- pmu {
+- compatible = "arm,cortex-a7-pmu";
+- interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
+- <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
+- };
+-
+ ppmu_dmc0: ppmu_dmc0@106a0000 {
+ compatible = "samsung,exynos-ppmu";
+ reg = <0x106a0000 0x2000>;
+diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
+index 3f7488833745d..33eb2810cdaa2 100644
+--- a/arch/arm/boot/dts/exynos4.dtsi
++++ b/arch/arm/boot/dts/exynos4.dtsi
+@@ -51,6 +51,12 @@
+ serial3 = &serial_3;
+ };
+
++ pmu: pmu {
++ compatible = "arm,cortex-a9-pmu";
++ interrupt-parent = <&combiner>;
++ interrupts = <2 2>, <3 2>;
++ };
++
+ soc: soc {
+ compatible = "simple-bus";
+ #address-cells = <1>;
+@@ -169,12 +175,6 @@
+ reg = <0x10440000 0x1000>;
+ };
+
+- pmu: pmu {
+- compatible = "arm,cortex-a9-pmu";
+- interrupt-parent = <&combiner>;
+- interrupts = <2 2>, <3 2>;
+- };
+-
+ sys_reg: syscon@10010000 {
+ compatible = "samsung,exynos4-sysreg", "syscon";
+ reg = <0x10010000 0x400>;
+diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
+index e6b1a8a9b832c..59e5f0016b862 100644
+--- a/arch/arm/boot/dts/exynos5250.dtsi
++++ b/arch/arm/boot/dts/exynos5250.dtsi
+@@ -157,6 +157,12 @@
+ };
+ };
+
++ pmu {
++ compatible = "arm,cortex-a15-pmu";
++ interrupt-parent = <&combiner>;
++ interrupts = <1 2>, <22 4>;
++ };
++
+ soc: soc {
+ sysram@2020000 {
+ compatible = "mmio-sram";
+@@ -227,20 +233,6 @@
+ power-domains = <&pd_mau>;
+ };
+
+- timer {
+- compatible = "arm,armv7-timer";
+- interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+- <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+- <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+- <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+- /*
+- * Unfortunately we need this since some versions
+- * of U-Boot on Exynos don't set the CNTFRQ register,
+- * so we need the value from DT.
+- */
+- clock-frequency = <24000000>;
+- };
+-
+ mct@101c0000 {
+ compatible = "samsung,exynos4210-mct";
+ reg = <0x101C0000 0x800>;
+@@ -265,12 +257,6 @@
+ };
+ };
+
+- pmu {
+- compatible = "arm,cortex-a15-pmu";
+- interrupt-parent = <&combiner>;
+- interrupts = <1 2>, <22 4>;
+- };
+-
+ pinctrl_0: pinctrl@11400000 {
+ compatible = "samsung,exynos5250-pinctrl";
+ reg = <0x11400000 0x1000>;
+@@ -1076,6 +1062,20 @@
+ };
+ };
+ };
++
++ timer {
++ compatible = "arm,armv7-timer";
++ interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
++ <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
++ <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
++ <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
++ /*
++ * Unfortunately we need this since some versions
++ * of U-Boot on Exynos don't set the CNTFRQ register,
++ * so we need the value from DT.
++ */
++ clock-frequency = <24000000>;
++ };
+ };
+
+ &dp {
+diff --git a/arch/arm/boot/dts/exynos54xx.dtsi b/arch/arm/boot/dts/exynos54xx.dtsi
+index de26e5ee0d2de..ae866bcc30c4e 100644
+--- a/arch/arm/boot/dts/exynos54xx.dtsi
++++ b/arch/arm/boot/dts/exynos54xx.dtsi
+@@ -25,27 +25,27 @@
+ usbdrdphy1 = &usbdrd_phy1;
+ };
+
+- soc: soc {
+- arm_a7_pmu: arm-a7-pmu {
+- compatible = "arm,cortex-a7-pmu";
+- interrupt-parent = <&gic>;
+- interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
+- <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
+- <GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
+- <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>;
+- status = "disabled";
+- };
++ arm_a7_pmu: arm-a7-pmu {
++ compatible = "arm,cortex-a7-pmu";
++ interrupt-parent = <&gic>;
++ interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
++ <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
++ <GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
++ <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>;
++ status = "disabled";
++ };
+
+- arm_a15_pmu: arm-a15-pmu {
+- compatible = "arm,cortex-a15-pmu";
+- interrupt-parent = <&combiner>;
+- interrupts = <1 2>,
+- <7 0>,
+- <16 6>,
+- <19 2>;
+- status = "disabled";
+- };
++ arm_a15_pmu: arm-a15-pmu {
++ compatible = "arm,cortex-a15-pmu";
++ interrupt-parent = <&combiner>;
++ interrupts = <1 2>,
++ <7 0>,
++ <16 6>,
++ <19 2>;
++ status = "disabled";
++ };
+
++ soc: soc {
+ sysram@2020000 {
+ compatible = "mmio-sram";
+ reg = <0x02020000 0x54000>;
+--
+2.39.2
+
--- /dev/null
+From bc0918e731fbc8330d3f0c9546993ac88cbe2049 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 30 Aug 2020 15:51:43 +0200
+Subject: ARM: dts: exynos: Override thermal by label in Exynos4210
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit 1708f56081e239a29ed8646aa7fde6853235d93f ]
+
+Using full paths to extend or override a device tree node is error prone
+since if there was a typo error, a new node will be created instead of
+extending the node as it was desired. This will lead to run-time errors
+that could be hard to detect.
+
+A mistyped label on the other hand, will cause a dtc compile error
+(during build time).
+
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Link: https://lore.kernel.org/r/20200830135200.24304-16-krzk@kernel.org
+Stable-dep-of: 408ab6786dbf ("ARM: dts: exynos: correct TMU phandle in Exynos4210")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos4210.dtsi | 36 +++++++++++++++----------------
+ 1 file changed, 17 insertions(+), 19 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
+index 0ed9ef75075bc..2ec6c01550564 100644
+--- a/arch/arm/boot/dts/exynos4210.dtsi
++++ b/arch/arm/boot/dts/exynos4210.dtsi
+@@ -370,26 +370,24 @@
+ };
+ };
+ };
++};
+
+- thermal-zones {
+- cpu_thermal: cpu-thermal {
+- polling-delay-passive = <0>;
+- polling-delay = <0>;
+- thermal-sensors = <&tmu 0>;
+-
+- trips {
+- cpu_alert0: cpu-alert-0 {
+- temperature = <85000>; /* millicelsius */
+- };
+- cpu_alert1: cpu-alert-1 {
+- temperature = <100000>; /* millicelsius */
+- };
+- cpu_alert2: cpu-alert-2 {
+- temperature = <110000>; /* millicelsius */
+- };
+- };
+- };
+- };
++&cpu_alert0 {
++ temperature = <85000>; /* millicelsius */
++};
++
++&cpu_alert1 {
++ temperature = <100000>; /* millicelsius */
++};
++
++&cpu_alert2 {
++ temperature = <110000>; /* millicelsius */
++};
++
++&cpu_thermal {
++ polling-delay-passive = <0>;
++ polling-delay = <0>;
++ thermal-sensors = <&tmu 0>;
+ };
+
+ &gic {
+--
+2.39.2
+
--- /dev/null
+From 896485715713d64b1a805dd59cd3342a30a93bc4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 1 Sep 2020 09:54:11 +0200
+Subject: ARM: dts: exynos: Override thermal by label in Exynos5250
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit 7e86ef5cc89609cbad8b9dd2f476789c638dbb92 ]
+
+Using full paths to extend or override a device tree node is error prone
+since if there was a typo error, a new node will be created instead of
+extending the node as it was desired. This will lead to run-time errors
+that could be hard to detect.
+
+A mistyped label on the other hand, will cause a dtc compile error
+(during build time).
+
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Link: https://lore.kernel.org/r/20200901075417.22481-8-krzk@kernel.org
+Stable-dep-of: 33e2c595e2e4 ("ARM: dts: exynos: correct TMU phandle in Exynos5250")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/exynos5250.dtsi | 38 +++++++++++++++----------------
+ 1 file changed, 18 insertions(+), 20 deletions(-)
+
+diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
+index 59e5f0016b862..1883b8c2cd7b9 100644
+--- a/arch/arm/boot/dts/exynos5250.dtsi
++++ b/arch/arm/boot/dts/exynos5250.dtsi
+@@ -1043,26 +1043,6 @@
+ };
+ };
+
+- thermal-zones {
+- cpu_thermal: cpu-thermal {
+- polling-delay-passive = <0>;
+- polling-delay = <0>;
+- thermal-sensors = <&tmu 0>;
+-
+- cooling-maps {
+- map0 {
+- /* Corresponds to 800MHz at freq_table */
+- cooling-device = <&cpu0 9 9>, <&cpu1 9 9>;
+- };
+- map1 {
+- /* Corresponds to 200MHz at freq_table */
+- cooling-device = <&cpu0 15 15>,
+- <&cpu1 15 15>;
+- };
+- };
+- };
+- };
+-
+ timer {
+ compatible = "arm,armv7-timer";
+ interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
+@@ -1078,6 +1058,24 @@
+ };
+ };
+
++&cpu_thermal {
++ polling-delay-passive = <0>;
++ polling-delay = <0>;
++ thermal-sensors = <&tmu 0>;
++
++ cooling-maps {
++ map0 {
++ /* Corresponds to 800MHz at freq_table */
++ cooling-device = <&cpu0 9 9>, <&cpu1 9 9>;
++ };
++ map1 {
++ /* Corresponds to 200MHz at freq_table */
++ cooling-device = <&cpu0 15 15>,
++ <&cpu1 15 15>;
++ };
++ };
++};
++
+ &dp {
+ power-domains = <&pd_disp1>;
+ clocks = <&clock CLK_DP>;
+--
+2.39.2
+
--- /dev/null
+From 71f0d42274ce9c8e45691969889cdd3b8b2663d2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 May 2021 15:08:45 -0400
+Subject: fs: dlm: add union in dlm header for lockspace id
+
+From: Alexander Aring <aahringo@redhat.com>
+
+[ Upstream commit 8e2e40860c7f67c0b19b13d92cfea03a19232ce2 ]
+
+This patch adds union inside the lockspace id to handle it also for
+another use case for a different dlm command.
+
+Signed-off-by: Alexander Aring <aahringo@redhat.com>
+Signed-off-by: David Teigland <teigland@redhat.com>
+Stable-dep-of: aad633dc0cf9 ("fs: dlm: start midcomms before scand")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/dlm/dlm_internal.h | 5 ++++-
+ fs/dlm/lock.c | 8 ++++----
+ fs/dlm/rcom.c | 4 ++--
+ fs/dlm/util.c | 6 ++++--
+ 4 files changed, 14 insertions(+), 9 deletions(-)
+
+diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
+index cb287df13a7aa..0418fd4e316f7 100644
+--- a/fs/dlm/dlm_internal.h
++++ b/fs/dlm/dlm_internal.h
+@@ -379,7 +379,10 @@ static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
+
+ struct dlm_header {
+ uint32_t h_version;
+- uint32_t h_lockspace;
++ union {
++ /* for DLM_MSG and DLM_RCOM */
++ uint32_t h_lockspace;
++ } u;
+ uint32_t h_nodeid; /* nodeid of sender */
+ uint16_t h_length;
+ uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */
+diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
+index d4e204473e76b..0e2a92b1829e5 100644
+--- a/fs/dlm/lock.c
++++ b/fs/dlm/lock.c
+@@ -3550,7 +3550,7 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
+ ms = (struct dlm_message *) mb;
+
+ ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
+- ms->m_header.h_lockspace = ls->ls_global_id;
++ ms->m_header.u.h_lockspace = ls->ls_global_id;
+ ms->m_header.h_nodeid = dlm_our_nodeid();
+ ms->m_header.h_length = mb_len;
+ ms->m_header.h_cmd = DLM_MSG;
+@@ -5054,16 +5054,16 @@ void dlm_receive_buffer(union dlm_packet *p, int nodeid)
+
+ if (hd->h_nodeid != nodeid) {
+ log_print("invalid h_nodeid %d from %d lockspace %x",
+- hd->h_nodeid, nodeid, hd->h_lockspace);
++ hd->h_nodeid, nodeid, hd->u.h_lockspace);
+ return;
+ }
+
+- ls = dlm_find_lockspace_global(hd->h_lockspace);
++ ls = dlm_find_lockspace_global(hd->u.h_lockspace);
+ if (!ls) {
+ if (dlm_config.ci_log_debug) {
+ printk_ratelimited(KERN_DEBUG "dlm: invalid lockspace "
+ "%u from %d cmd %d type %d\n",
+- hd->h_lockspace, nodeid, hd->h_cmd, type);
++ hd->u.h_lockspace, nodeid, hd->h_cmd, type);
+ }
+
+ if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS)
+diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c
+index 70c625999d368..b3fb808df1d4b 100644
+--- a/fs/dlm/rcom.c
++++ b/fs/dlm/rcom.c
+@@ -48,7 +48,7 @@ static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
+ rc = (struct dlm_rcom *) mb;
+
+ rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
+- rc->rc_header.h_lockspace = ls->ls_global_id;
++ rc->rc_header.u.h_lockspace = ls->ls_global_id;
+ rc->rc_header.h_nodeid = dlm_our_nodeid();
+ rc->rc_header.h_length = mb_len;
+ rc->rc_header.h_cmd = DLM_RCOM;
+@@ -469,7 +469,7 @@ int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
+ rc = (struct dlm_rcom *) mb;
+
+ rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR);
+- rc->rc_header.h_lockspace = rc_in->rc_header.h_lockspace;
++ rc->rc_header.u.h_lockspace = rc_in->rc_header.u.h_lockspace;
+ rc->rc_header.h_nodeid = dlm_our_nodeid();
+ rc->rc_header.h_length = mb_len;
+ rc->rc_header.h_cmd = DLM_RCOM;
+diff --git a/fs/dlm/util.c b/fs/dlm/util.c
+index af9d9cbb8ff47..be773e539599d 100644
+--- a/fs/dlm/util.c
++++ b/fs/dlm/util.c
+@@ -25,7 +25,8 @@
+ void header_out(struct dlm_header *hd)
+ {
+ hd->h_version = cpu_to_le32(hd->h_version);
+- hd->h_lockspace = cpu_to_le32(hd->h_lockspace);
++ /* does it for others u32 in union as well */
++ hd->u.h_lockspace = cpu_to_le32(hd->u.h_lockspace);
+ hd->h_nodeid = cpu_to_le32(hd->h_nodeid);
+ hd->h_length = cpu_to_le16(hd->h_length);
+ }
+@@ -33,7 +34,8 @@ void header_out(struct dlm_header *hd)
+ void header_in(struct dlm_header *hd)
+ {
+ hd->h_version = le32_to_cpu(hd->h_version);
+- hd->h_lockspace = le32_to_cpu(hd->h_lockspace);
++ /* does it for others u32 in union as well */
++ hd->u.h_lockspace = le32_to_cpu(hd->u.h_lockspace);
+ hd->h_nodeid = le32_to_cpu(hd->h_nodeid);
+ hd->h_length = le16_to_cpu(hd->h_length);
+ }
+--
+2.39.2
+
--- /dev/null
+From b569fecd69ead40b00737c8f53506aef842d01ff Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 27 Oct 2022 16:45:26 -0400
+Subject: fs: dlm: fix log of lowcomms vs midcomms
+
+From: Alexander Aring <aahringo@redhat.com>
+
+[ Upstream commit 3e54c9e80e68b765d8877023d93f1eea1b9d1c54 ]
+
+This patch will fix a small issue when printing out that
+dlm_midcomms_start() failed to start and it was printing out that the
+dlm subcomponent lowcomms was failed but lowcomms is behind the midcomms
+layer.
+
+Signed-off-by: Alexander Aring <aahringo@redhat.com>
+Signed-off-by: David Teigland <teigland@redhat.com>
+Stable-dep-of: aad633dc0cf9 ("fs: dlm: start midcomms before scand")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/dlm/lockspace.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
+index 244b87e4dfe7f..7cb72aa84bb01 100644
+--- a/fs/dlm/lockspace.c
++++ b/fs/dlm/lockspace.c
+@@ -403,7 +403,7 @@ static int threads_start(void)
+ /* Thread for sending/receiving messages for all lockspace's */
+ error = dlm_lowcomms_start();
+ if (error) {
+- log_print("cannot start dlm lowcomms %d", error);
++ log_print("cannot start dlm midcomms %d", error);
+ goto scand_fail;
+ }
+
+--
+2.39.2
+
--- /dev/null
+From d75e83d4553e024af51f76454be634136b23e8b9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 May 2021 15:08:40 -0400
+Subject: fs: dlm: public header in out utility
+
+From: Alexander Aring <aahringo@redhat.com>
+
+[ Upstream commit 6fb5cf9d4206f2cdccb05be1bf2307dab4e5babe ]
+
+This patch allows to use header_out() and header_in() outside of dlm
+util functionality.
+
+Signed-off-by: Alexander Aring <aahringo@redhat.com>
+Signed-off-by: David Teigland <teigland@redhat.com>
+Stable-dep-of: aad633dc0cf9 ("fs: dlm: start midcomms before scand")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/dlm/util.c | 4 ++--
+ fs/dlm/util.h | 2 ++
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/fs/dlm/util.c b/fs/dlm/util.c
+index e36520af7cc0e..af9d9cbb8ff47 100644
+--- a/fs/dlm/util.c
++++ b/fs/dlm/util.c
+@@ -22,7 +22,7 @@
+ #define DLM_ERRNO_ETIMEDOUT 110
+ #define DLM_ERRNO_EINPROGRESS 115
+
+-static void header_out(struct dlm_header *hd)
++void header_out(struct dlm_header *hd)
+ {
+ hd->h_version = cpu_to_le32(hd->h_version);
+ hd->h_lockspace = cpu_to_le32(hd->h_lockspace);
+@@ -30,7 +30,7 @@ static void header_out(struct dlm_header *hd)
+ hd->h_length = cpu_to_le16(hd->h_length);
+ }
+
+-static void header_in(struct dlm_header *hd)
++void header_in(struct dlm_header *hd)
+ {
+ hd->h_version = le32_to_cpu(hd->h_version);
+ hd->h_lockspace = le32_to_cpu(hd->h_lockspace);
+diff --git a/fs/dlm/util.h b/fs/dlm/util.h
+index 2b25915161c02..c805a916b29f5 100644
+--- a/fs/dlm/util.h
++++ b/fs/dlm/util.h
+@@ -17,6 +17,8 @@ void dlm_message_out(struct dlm_message *ms);
+ void dlm_message_in(struct dlm_message *ms);
+ void dlm_rcom_out(struct dlm_rcom *rc);
+ void dlm_rcom_in(struct dlm_rcom *rc);
++void header_out(struct dlm_header *hd);
++void header_in(struct dlm_header *hd);
+
+ #endif
+
+--
+2.39.2
+
--- /dev/null
+From 09f75e4c4591af8ea05f768fafa7016312544e64 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 6 Aug 2019 19:03:21 +0900
+Subject: kbuild: fix false-positive need-builtin calculation
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+[ Upstream commit d9f78edfd81b9e484423534360350ef7253cc888 ]
+
+The current implementation of need-builtin is false-positive,
+for example, in the following Makefile:
+
+ obj-m := foo/
+ obj-y := foo/bar/
+
+..., where foo/built-in.a is not required.
+
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Stable-dep-of: 2e3d0e20d845 ("ARM: dts: exynos: correct TMU phandle in Odroid HC1")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ scripts/Makefile.build | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/Makefile.build b/scripts/Makefile.build
+index 64fac0ad32d6b..7635cc05fcfa3 100644
+--- a/scripts/Makefile.build
++++ b/scripts/Makefile.build
+@@ -541,7 +541,8 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
+
+ PHONY += $(subdir-ym)
+ $(subdir-ym):
+- $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1)
++ $(Q)$(MAKE) $(build)=$@ \
++ need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1)
+
+ # Add FORCE to the prequisites of a target to force it to be always rebuilt.
+ # ---------------------------------------------------------------------------
+--
+2.39.2
+
--- /dev/null
+From fc882994f8c047cd5cd6b8a9050be628b8f6aa3a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 6 Aug 2019 19:03:22 +0900
+Subject: kbuild: generate modules.order only in directories visited by obj-y/m
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+[ Upstream commit 4f2c8f3089f538f556c86f26603a062865e4aa94 ]
+
+The modules.order files in directories visited by the chain of obj-y
+or obj-m are merged to the upper-level ones, and become parts of the
+top-level modules.order. On the other hand, there is no need to
+generate modules.order in directories visited by subdir-y or subdir-m
+since they would become orphan anyway.
+
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Stable-dep-of: 2e3d0e20d845 ("ARM: dts: exynos: correct TMU phandle in Odroid HC1")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ scripts/Makefile.build | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/Makefile.build b/scripts/Makefile.build
+index 7635cc05fcfa3..97f59fa3e0ed9 100644
+--- a/scripts/Makefile.build
++++ b/scripts/Makefile.build
+@@ -542,7 +542,8 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
+ PHONY += $(subdir-ym)
+ $(subdir-ym):
+ $(Q)$(MAKE) $(build)=$@ \
+- need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1)
++ need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \
++ need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
+
+ # Add FORCE to the prequisites of a target to force it to be always rebuilt.
+ # ---------------------------------------------------------------------------
+--
+2.39.2
+
--- /dev/null
+From c9dc1d71195527f1e0f9da9ed5569b4cd78e9a5b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 21 Jul 2020 16:23:54 +0800
+Subject: KVM: Using macros instead of magic values
+
+From: Haiwei Li <lihaiwei@tencent.com>
+
+[ Upstream commit 9c2475f3e46a1de22bcae3b2c98c398937261c8a ]
+
+Instead of using magic values, use macros.
+
+Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
+Message-Id: <4c072161-80dd-b7ed-7adb-02acccaa0701@gmail.com>
+Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Stable-dep-of: ba5838abb053 ("KVM: x86: Inject #GP if WRMSR sets reserved bits in APIC Self-IPI")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/kvm/lapic.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
+index 027941e3df682..81801b0c24e9a 100644
+--- a/arch/x86/kvm/lapic.c
++++ b/arch/x86/kvm/lapic.c
+@@ -1921,7 +1921,8 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
+
+ case APIC_SELF_IPI:
+ if (apic_x2apic_mode(apic)) {
+- kvm_lapic_reg_write(apic, APIC_ICR, 0x40000 | (val & 0xff));
++ kvm_lapic_reg_write(apic, APIC_ICR,
++ APIC_DEST_SELF | (val & APIC_VECTOR_MASK));
+ } else
+ ret = 1;
+ break;
+--
+2.39.2
+
--- /dev/null
+From 1013ff7442f5bb83000ba62161d5b8fdb1342023 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 24 Feb 2022 09:53:36 -0500
+Subject: KVM: x86: Do not change ICR on write to APIC_SELF_IPI
+
+From: Paolo Bonzini <pbonzini@redhat.com>
+
+[ Upstream commit d22a81b304a27fca6124174a8e842e826c193466 ]
+
+Emulating writes to SELF_IPI with a write to ICR has an unwanted side effect:
+the value of ICR in vAPIC page gets changed. The lists SELF_IPI as write-only,
+with no associated MMIO offset, so any write should have no visible side
+effect in the vAPIC page.
+
+Reported-by: Chao Gao <chao.gao@intel.com>
+Reviewed-by: Sean Christopherson <seanjc@google.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Stable-dep-of: ba5838abb053 ("KVM: x86: Inject #GP if WRMSR sets reserved bits in APIC Self-IPI")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/kvm/lapic.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
+index 81801b0c24e9a..47d25a696588e 100644
+--- a/arch/x86/kvm/lapic.c
++++ b/arch/x86/kvm/lapic.c
+@@ -1920,10 +1920,9 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
+ break;
+
+ case APIC_SELF_IPI:
+- if (apic_x2apic_mode(apic)) {
+- kvm_lapic_reg_write(apic, APIC_ICR,
+- APIC_DEST_SELF | (val & APIC_VECTOR_MASK));
+- } else
++ if (apic_x2apic_mode(apic))
++ kvm_apic_send_ipi(apic, APIC_DEST_SELF | (val & APIC_VECTOR_MASK), 0);
++ else
+ ret = 1;
+ break;
+ default:
+--
+2.39.2
+
--- /dev/null
+From 9385d1c7aeff25710c0423b0e63cd659cd755daf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 12 Jan 2023 04:05:59 -0500
+Subject: riscv: ftrace: Reduce the detour code size to half
+
+From: Guo Ren <guoren@linux.alibaba.com>
+
+[ Upstream commit 6724a76cff85ee271bbbff42ac527e4643b2ec52 ]
+
+Use a temporary register to reduce the size of detour code from 16 bytes to
+8 bytes. The previous implementation is from 'commit afc76b8b8011 ("riscv:
+Using PATCHABLE_FUNCTION_ENTRY instead of MCOUNT")'.
+
+Before the patch:
+<func_prolog>:
+ 0: REG_S ra, -SZREG(sp)
+ 4: auipc ra, ?
+ 8: jalr ?(ra)
+12: REG_L ra, -SZREG(sp)
+ (func_boddy)
+
+After the patch:
+<func_prolog>:
+ 0: auipc t0, ?
+ 4: jalr t0, ?(t0)
+ (func_boddy)
+
+This patch not just reduces the size of detour code, but also fixes an
+important issue:
+
+An Ftrace callback registered with FTRACE_OPS_FL_IPMODIFY flag can
+actually change the instruction pointer, e.g. to "replace" the given
+kernel function with a new one, which is needed for livepatching, etc.
+
+In this case, the trampoline (ftrace_regs_caller) would not return to
+<func_prolog+12> but would rather jump to the new function. So, "REG_L
+ra, -SZREG(sp)" would not run and the original return address would not
+be restored. The kernel is likely to hang or crash as a result.
+
+This can be easily demonstrated if one tries to "replace", say,
+cmdline_proc_show() with a new function with the same signature using
+instruction_pointer_set(&fregs->regs, new_func_addr) in the Ftrace
+callback.
+
+Link: https://lore.kernel.org/linux-riscv/20221122075440.1165172-1-suagrfillet@gmail.com/
+Link: https://lore.kernel.org/linux-riscv/d7d5730b-ebef-68e5-5046-e763e1ee6164@yadro.com/
+Co-developed-by: Song Shuai <suagrfillet@gmail.com>
+Signed-off-by: Song Shuai <suagrfillet@gmail.com>
+Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
+Signed-off-by: Guo Ren <guoren@kernel.org>
+Cc: Evgenii Shatokhin <e.shatokhin@yadro.com>
+Reviewed-by: Evgenii Shatokhin <e.shatokhin@yadro.com>
+Link: https://lore.kernel.org/r/20230112090603.1295340-4-guoren@kernel.org
+Cc: stable@vger.kernel.org
+Fixes: 10626c32e382 ("riscv/ftrace: Add basic support")
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/riscv/Makefile | 4 +-
+ arch/riscv/include/asm/ftrace.h | 50 +++++++++++++++++++------
+ arch/riscv/kernel/ftrace.c | 65 ++++++++++-----------------------
+ arch/riscv/kernel/mcount-dyn.S | 42 ++++++++-------------
+ 4 files changed, 75 insertions(+), 86 deletions(-)
+
+diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
+index fbc3c9adca70a..f241cbdd45bd4 100644
+--- a/arch/riscv/Makefile
++++ b/arch/riscv/Makefile
+@@ -14,9 +14,9 @@ ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
+ LDFLAGS_vmlinux := --no-relax
+ KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
+ ifeq ($(CONFIG_RISCV_ISA_C),y)
+- CC_FLAGS_FTRACE := -fpatchable-function-entry=8
+-else
+ CC_FLAGS_FTRACE := -fpatchable-function-entry=4
++else
++ CC_FLAGS_FTRACE := -fpatchable-function-entry=2
+ endif
+ endif
+ KBUILD_AFLAGS_MODULE += -fPIC
+diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
+index 693c3839a7dfe..21c1aaf9fd3d7 100644
+--- a/arch/riscv/include/asm/ftrace.h
++++ b/arch/riscv/include/asm/ftrace.h
+@@ -39,6 +39,14 @@ struct dyn_arch_ftrace {
+ * 2) jalr: setting low-12 offset to ra, jump to ra, and set ra to
+ * return address (original pc + 4)
+ *
++ *<ftrace enable>:
++ * 0: auipc t0/ra, 0x?
++ * 4: jalr t0/ra, ?(t0/ra)
++ *
++ *<ftrace disable>:
++ * 0: nop
++ * 4: nop
++ *
+ * Dynamic ftrace generates probes to call sites, so we must deal with
+ * both auipc and jalr at the same time.
+ */
+@@ -49,25 +57,43 @@ struct dyn_arch_ftrace {
+ #define AUIPC_OFFSET_MASK (0xfffff000)
+ #define AUIPC_PAD (0x00001000)
+ #define JALR_SHIFT 20
+-#define JALR_BASIC (0x000080e7)
+-#define AUIPC_BASIC (0x00000097)
++#define JALR_RA (0x000080e7)
++#define AUIPC_RA (0x00000097)
++#define JALR_T0 (0x000282e7)
++#define AUIPC_T0 (0x00000297)
+ #define NOP4 (0x00000013)
+
+-#define make_call(caller, callee, call) \
++#define to_jalr_t0(offset) \
++ (((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_T0)
++
++#define to_auipc_t0(offset) \
++ ((offset & JALR_SIGN_MASK) ? \
++ (((offset & AUIPC_OFFSET_MASK) + AUIPC_PAD) | AUIPC_T0) : \
++ ((offset & AUIPC_OFFSET_MASK) | AUIPC_T0))
++
++#define make_call_t0(caller, callee, call) \
+ do { \
+- call[0] = to_auipc_insn((unsigned int)((unsigned long)callee - \
+- (unsigned long)caller)); \
+- call[1] = to_jalr_insn((unsigned int)((unsigned long)callee - \
+- (unsigned long)caller)); \
++ unsigned int offset = \
++ (unsigned long) callee - (unsigned long) caller; \
++ call[0] = to_auipc_t0(offset); \
++ call[1] = to_jalr_t0(offset); \
+ } while (0)
+
+-#define to_jalr_insn(offset) \
+- (((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_BASIC)
++#define to_jalr_ra(offset) \
++ (((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_RA)
+
+-#define to_auipc_insn(offset) \
++#define to_auipc_ra(offset) \
+ ((offset & JALR_SIGN_MASK) ? \
+- (((offset & AUIPC_OFFSET_MASK) + AUIPC_PAD) | AUIPC_BASIC) : \
+- ((offset & AUIPC_OFFSET_MASK) | AUIPC_BASIC))
++ (((offset & AUIPC_OFFSET_MASK) + AUIPC_PAD) | AUIPC_RA) : \
++ ((offset & AUIPC_OFFSET_MASK) | AUIPC_RA))
++
++#define make_call_ra(caller, callee, call) \
++do { \
++ unsigned int offset = \
++ (unsigned long) callee - (unsigned long) caller; \
++ call[0] = to_auipc_ra(offset); \
++ call[1] = to_jalr_ra(offset); \
++} while (0)
+
+ /*
+ * Let auipc+jalr be the basic *mcount unit*, so we make it 8 bytes here.
+diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
+index c9b97f8f165c6..3c91330ec2fb6 100644
+--- a/arch/riscv/kernel/ftrace.c
++++ b/arch/riscv/kernel/ftrace.c
+@@ -42,13 +42,16 @@ static int ftrace_check_current_call(unsigned long hook_pos,
+ }
+
+ static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target,
+- bool enable)
++ bool enable, bool ra)
+ {
+ unsigned int call[2];
+ unsigned int nops[2] = {NOP4, NOP4};
+ int ret = 0;
+
+- make_call(hook_pos, target, call);
++ if (ra)
++ make_call_ra(hook_pos, target, call);
++ else
++ make_call_t0(hook_pos, target, call);
+
+ /* replace the auipc-jalr pair at once */
+ ret = probe_kernel_write((void *)hook_pos, enable ? call : nops,
+@@ -63,42 +66,13 @@ static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target,
+ return 0;
+ }
+
+-/*
+- * Put 5 instructions with 16 bytes at the front of function within
+- * patchable function entry nops' area.
+- *
+- * 0: REG_S ra, -SZREG(sp)
+- * 1: auipc ra, 0x?
+- * 2: jalr -?(ra)
+- * 3: REG_L ra, -SZREG(sp)
+- *
+- * So the opcodes is:
+- * 0: 0xfe113c23 (sd)/0xfe112e23 (sw)
+- * 1: 0x???????? -> auipc
+- * 2: 0x???????? -> jalr
+- * 3: 0xff813083 (ld)/0xffc12083 (lw)
+- */
+-#if __riscv_xlen == 64
+-#define INSN0 0xfe113c23
+-#define INSN3 0xff813083
+-#elif __riscv_xlen == 32
+-#define INSN0 0xfe112e23
+-#define INSN3 0xffc12083
+-#endif
+-
+-#define FUNC_ENTRY_SIZE 16
+-#define FUNC_ENTRY_JMP 4
+-
+ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
+ {
+- unsigned int call[4] = {INSN0, 0, 0, INSN3};
+- unsigned long target = addr;
+- unsigned long caller = rec->ip + FUNC_ENTRY_JMP;
++ unsigned int call[2];
+
+- call[1] = to_auipc_insn((unsigned int)(target - caller));
+- call[2] = to_jalr_insn((unsigned int)(target - caller));
++ make_call_t0(rec->ip, addr, call);
+
+- if (patch_text_nosync((void *)rec->ip, call, FUNC_ENTRY_SIZE))
++ if (patch_text_nosync((void *)rec->ip, call, MCOUNT_INSN_SIZE))
+ return -EPERM;
+
+ return 0;
+@@ -107,15 +81,14 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
+ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
+ unsigned long addr)
+ {
+- unsigned int nops[4] = {NOP4, NOP4, NOP4, NOP4};
++ unsigned int nops[2] = {NOP4, NOP4};
+
+- if (patch_text_nosync((void *)rec->ip, nops, FUNC_ENTRY_SIZE))
++ if (patch_text_nosync((void *)rec->ip, nops, MCOUNT_INSN_SIZE))
+ return -EPERM;
+
+ return 0;
+ }
+
+-
+ /*
+ * This is called early on, and isn't wrapped by
+ * ftrace_arch_code_modify_{prepare,post_process}() and therefor doesn't hold
+@@ -137,10 +110,10 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
+ int ftrace_update_ftrace_func(ftrace_func_t func)
+ {
+ int ret = __ftrace_modify_call((unsigned long)&ftrace_call,
+- (unsigned long)func, true);
++ (unsigned long)func, true, true);
+ if (!ret) {
+ ret = __ftrace_modify_call((unsigned long)&ftrace_regs_call,
+- (unsigned long)func, true);
++ (unsigned long)func, true, true);
+ }
+
+ return ret;
+@@ -157,16 +130,16 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
+ unsigned long addr)
+ {
+ unsigned int call[2];
+- unsigned long caller = rec->ip + FUNC_ENTRY_JMP;
++ unsigned long caller = rec->ip;
+ int ret;
+
+- make_call(caller, old_addr, call);
++ make_call_t0(caller, old_addr, call);
+ ret = ftrace_check_current_call(caller, call);
+
+ if (ret)
+ return ret;
+
+- return __ftrace_modify_call(caller, addr, true);
++ return __ftrace_modify_call(caller, addr, true, false);
+ }
+ #endif
+
+@@ -201,12 +174,12 @@ int ftrace_enable_ftrace_graph_caller(void)
+ int ret;
+
+ ret = __ftrace_modify_call((unsigned long)&ftrace_graph_call,
+- (unsigned long)&prepare_ftrace_return, true);
++ (unsigned long)&prepare_ftrace_return, true, true);
+ if (ret)
+ return ret;
+
+ return __ftrace_modify_call((unsigned long)&ftrace_graph_regs_call,
+- (unsigned long)&prepare_ftrace_return, true);
++ (unsigned long)&prepare_ftrace_return, true, true);
+ }
+
+ int ftrace_disable_ftrace_graph_caller(void)
+@@ -214,12 +187,12 @@ int ftrace_disable_ftrace_graph_caller(void)
+ int ret;
+
+ ret = __ftrace_modify_call((unsigned long)&ftrace_graph_call,
+- (unsigned long)&prepare_ftrace_return, false);
++ (unsigned long)&prepare_ftrace_return, false, true);
+ if (ret)
+ return ret;
+
+ return __ftrace_modify_call((unsigned long)&ftrace_graph_regs_call,
+- (unsigned long)&prepare_ftrace_return, false);
++ (unsigned long)&prepare_ftrace_return, false, true);
+ }
+ #endif /* CONFIG_DYNAMIC_FTRACE */
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+diff --git a/arch/riscv/kernel/mcount-dyn.S b/arch/riscv/kernel/mcount-dyn.S
+index d171eca623b6f..125de818d1bab 100644
+--- a/arch/riscv/kernel/mcount-dyn.S
++++ b/arch/riscv/kernel/mcount-dyn.S
+@@ -13,8 +13,8 @@
+
+ .text
+
+-#define FENTRY_RA_OFFSET 12
+-#define ABI_SIZE_ON_STACK 72
++#define FENTRY_RA_OFFSET 8
++#define ABI_SIZE_ON_STACK 80
+ #define ABI_A0 0
+ #define ABI_A1 8
+ #define ABI_A2 16
+@@ -23,10 +23,10 @@
+ #define ABI_A5 40
+ #define ABI_A6 48
+ #define ABI_A7 56
+-#define ABI_RA 64
++#define ABI_T0 64
++#define ABI_RA 72
+
+ .macro SAVE_ABI
+- addi sp, sp, -SZREG
+ addi sp, sp, -ABI_SIZE_ON_STACK
+
+ REG_S a0, ABI_A0(sp)
+@@ -37,6 +37,7 @@
+ REG_S a5, ABI_A5(sp)
+ REG_S a6, ABI_A6(sp)
+ REG_S a7, ABI_A7(sp)
++ REG_S t0, ABI_T0(sp)
+ REG_S ra, ABI_RA(sp)
+ .endm
+
+@@ -49,24 +50,18 @@
+ REG_L a5, ABI_A5(sp)
+ REG_L a6, ABI_A6(sp)
+ REG_L a7, ABI_A7(sp)
++ REG_L t0, ABI_T0(sp)
+ REG_L ra, ABI_RA(sp)
+
+ addi sp, sp, ABI_SIZE_ON_STACK
+- addi sp, sp, SZREG
+ .endm
+
+ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+ .macro SAVE_ALL
+- addi sp, sp, -SZREG
+ addi sp, sp, -PT_SIZE_ON_STACK
+
+- REG_S x1, PT_EPC(sp)
+- addi sp, sp, PT_SIZE_ON_STACK
+- REG_L x1, (sp)
+- addi sp, sp, -PT_SIZE_ON_STACK
++ REG_S t0, PT_EPC(sp)
+ REG_S x1, PT_RA(sp)
+- REG_L x1, PT_EPC(sp)
+-
+ REG_S x2, PT_SP(sp)
+ REG_S x3, PT_GP(sp)
+ REG_S x4, PT_TP(sp)
+@@ -100,15 +95,11 @@
+ .endm
+
+ .macro RESTORE_ALL
++ REG_L t0, PT_EPC(sp)
+ REG_L x1, PT_RA(sp)
+- addi sp, sp, PT_SIZE_ON_STACK
+- REG_S x1, (sp)
+- addi sp, sp, -PT_SIZE_ON_STACK
+- REG_L x1, PT_EPC(sp)
+ REG_L x2, PT_SP(sp)
+ REG_L x3, PT_GP(sp)
+ REG_L x4, PT_TP(sp)
+- REG_L x5, PT_T0(sp)
+ REG_L x6, PT_T1(sp)
+ REG_L x7, PT_T2(sp)
+ REG_L x8, PT_S0(sp)
+@@ -137,17 +128,16 @@
+ REG_L x31, PT_T6(sp)
+
+ addi sp, sp, PT_SIZE_ON_STACK
+- addi sp, sp, SZREG
+ .endm
+ #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
+
+ ENTRY(ftrace_caller)
+ SAVE_ABI
+
+- addi a0, ra, -FENTRY_RA_OFFSET
++ addi a0, t0, -FENTRY_RA_OFFSET
+ la a1, function_trace_op
+ REG_L a2, 0(a1)
+- REG_L a1, ABI_SIZE_ON_STACK(sp)
++ mv a1, ra
+ mv a3, sp
+
+ ftrace_call:
+@@ -155,8 +145,8 @@ ftrace_call:
+ call ftrace_stub
+
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- addi a0, sp, ABI_SIZE_ON_STACK
+- REG_L a1, ABI_RA(sp)
++ addi a0, sp, ABI_RA
++ REG_L a1, ABI_T0(sp)
+ addi a1, a1, -FENTRY_RA_OFFSET
+ #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+ mv a2, s0
+@@ -166,17 +156,17 @@ ftrace_graph_call:
+ call ftrace_stub
+ #endif
+ RESTORE_ABI
+- ret
++ jr t0
+ ENDPROC(ftrace_caller)
+
+ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+ ENTRY(ftrace_regs_caller)
+ SAVE_ALL
+
+- addi a0, ra, -FENTRY_RA_OFFSET
++ addi a0, t0, -FENTRY_RA_OFFSET
+ la a1, function_trace_op
+ REG_L a2, 0(a1)
+- REG_L a1, PT_SIZE_ON_STACK(sp)
++ mv a1, ra
+ mv a3, sp
+
+ ftrace_regs_call:
+@@ -196,6 +186,6 @@ ftrace_graph_regs_call:
+ #endif
+
+ RESTORE_ALL
+- ret
++ jr t0
+ ENDPROC(ftrace_regs_caller)
+ #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
+--
+2.39.2
+
--- /dev/null
+From 2bb876ceceeb443eb49400f1e7222c467e6f858f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 12 Jan 2023 04:05:58 -0500
+Subject: riscv: ftrace: Remove wasted nops for !RISCV_ISA_C
+
+From: Guo Ren <guoren@linux.alibaba.com>
+
+[ Upstream commit 409c8fb20c66df7150e592747412438c04aeb11f ]
+
+When CONFIG_RISCV_ISA_C=n, -fpatchable-function-entry=8 would generate
+more nops than we expect. Because it treat nop opcode as 0x00000013
+instead of 0x0001.
+
+Dump of assembler code for function dw_pcie_free_msi:
+ 0xffffffff806fce94 <+0>: sd ra,-8(sp)
+ 0xffffffff806fce98 <+4>: auipc ra,0xff90f
+ 0xffffffff806fce9c <+8>: jalr -684(ra) # 0xffffffff8000bbec
+<ftrace_caller>
+ 0xffffffff806fcea0 <+12>: ld ra,-8(sp)
+ 0xffffffff806fcea4 <+16>: nop /* wasted */
+ 0xffffffff806fcea8 <+20>: nop /* wasted */
+ 0xffffffff806fceac <+24>: nop /* wasted */
+ 0xffffffff806fceb0 <+28>: nop /* wasted */
+ 0xffffffff806fceb4 <+0>: addi sp,sp,-48
+ 0xffffffff806fceb8 <+4>: sd s0,32(sp)
+ 0xffffffff806fcebc <+8>: sd s1,24(sp)
+ 0xffffffff806fcec0 <+12>: sd s2,16(sp)
+ 0xffffffff806fcec4 <+16>: sd s3,8(sp)
+ 0xffffffff806fcec8 <+20>: sd ra,40(sp)
+ 0xffffffff806fcecc <+24>: addi s0,sp,48
+
+Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
+Signed-off-by: Guo Ren <guoren@kernel.org>
+Link: https://lore.kernel.org/r/20230112090603.1295340-3-guoren@kernel.org
+Cc: stable@vger.kernel.org
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/riscv/Makefile | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
+index 7de9ce876f404..fbc3c9adca70a 100644
+--- a/arch/riscv/Makefile
++++ b/arch/riscv/Makefile
+@@ -13,7 +13,11 @@ LDFLAGS_vmlinux :=
+ ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
+ LDFLAGS_vmlinux := --no-relax
+ KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
++ifeq ($(CONFIG_RISCV_ISA_C),y)
+ CC_FLAGS_FTRACE := -fpatchable-function-entry=8
++else
++ CC_FLAGS_FTRACE := -fpatchable-function-entry=4
++endif
+ endif
+ KBUILD_AFLAGS_MODULE += -fPIC
+ KBUILD_CFLAGS_MODULE += -fPIC
+--
+2.39.2
+
--- /dev/null
+From abf571023a017240202a094778d26e61ee6d0ce2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 17 Dec 2020 16:01:41 +0000
+Subject: riscv: Using PATCHABLE_FUNCTION_ENTRY instead of MCOUNT
+
+From: Guo Ren <guoren@linux.alibaba.com>
+
+[ Upstream commit afc76b8b80112189b6f11e67e19cf58301944814 ]
+
+This patch changes the current detour mechanism of dynamic ftrace
+which has been discussed during LPC 2020 RISCV-MC [1].
+
+Before the patch, we used mcount for detour:
+<funca>:
+ addi sp,sp,-16
+ sd ra,8(sp)
+ sd s0,0(sp)
+ addi s0,sp,16
+ mv a5,ra
+ mv a0,a5
+ auipc ra,0x0 -> nop
+ jalr -296(ra) <_mcount@plt> ->nop
+ ...
+
+After the patch, we use nop call site area for detour:
+<funca>:
+ nop -> REG_S ra, -SZREG(sp)
+ nop -> auipc ra, 0x?
+ nop -> jalr ?(ra)
+ nop -> REG_L ra, -SZREG(sp)
+ ...
+
+The mcount mechanism is mixed with gcc function prologue which is
+not very clear. The patchable function entry just put 16 bytes nop
+before the front of the function prologue which could be filled
+with a separated detour mechanism.
+
+[1] https://www.linuxplumbersconf.org/event/7/contributions/807/
+
+Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
+Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
+Stable-dep-of: 409c8fb20c66 ("riscv: ftrace: Remove wasted nops for !RISCV_ISA_C")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/riscv/Makefile | 2 +
+ arch/riscv/kernel/ftrace.c | 95 ++++-----
+ arch/riscv/kernel/mcount-dyn.S | 342 +++++++++++++++------------------
+ 3 files changed, 204 insertions(+), 235 deletions(-)
+
+diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
+index a374e255336b3..7de9ce876f404 100644
+--- a/arch/riscv/Makefile
++++ b/arch/riscv/Makefile
+@@ -12,6 +12,8 @@ OBJCOPYFLAGS := -O binary
+ LDFLAGS_vmlinux :=
+ ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
+ LDFLAGS_vmlinux := --no-relax
++ KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
++ CC_FLAGS_FTRACE := -fpatchable-function-entry=8
+ endif
+ KBUILD_AFLAGS_MODULE += -fPIC
+ KBUILD_CFLAGS_MODULE += -fPIC
+diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
+index fa8530f05ed4f..c9b97f8f165c6 100644
+--- a/arch/riscv/kernel/ftrace.c
++++ b/arch/riscv/kernel/ftrace.c
+@@ -63,29 +63,56 @@ static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target,
+ return 0;
+ }
+
++/*
++ * Put 5 instructions with 16 bytes at the front of function within
++ * patchable function entry nops' area.
++ *
++ * 0: REG_S ra, -SZREG(sp)
++ * 1: auipc ra, 0x?
++ * 2: jalr -?(ra)
++ * 3: REG_L ra, -SZREG(sp)
++ *
++ * So the opcodes is:
++ * 0: 0xfe113c23 (sd)/0xfe112e23 (sw)
++ * 1: 0x???????? -> auipc
++ * 2: 0x???????? -> jalr
++ * 3: 0xff813083 (ld)/0xffc12083 (lw)
++ */
++#if __riscv_xlen == 64
++#define INSN0 0xfe113c23
++#define INSN3 0xff813083
++#elif __riscv_xlen == 32
++#define INSN0 0xfe112e23
++#define INSN3 0xffc12083
++#endif
++
++#define FUNC_ENTRY_SIZE 16
++#define FUNC_ENTRY_JMP 4
++
+ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
+ {
+- int ret = ftrace_check_current_call(rec->ip, NULL);
++ unsigned int call[4] = {INSN0, 0, 0, INSN3};
++ unsigned long target = addr;
++ unsigned long caller = rec->ip + FUNC_ENTRY_JMP;
+
+- if (ret)
+- return ret;
++ call[1] = to_auipc_insn((unsigned int)(target - caller));
++ call[2] = to_jalr_insn((unsigned int)(target - caller));
+
+- return __ftrace_modify_call(rec->ip, addr, true);
++ if (patch_text_nosync((void *)rec->ip, call, FUNC_ENTRY_SIZE))
++ return -EPERM;
++
++ return 0;
+ }
+
+ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
+ unsigned long addr)
+ {
+- unsigned int call[2];
+- int ret;
++ unsigned int nops[4] = {NOP4, NOP4, NOP4, NOP4};
+
+- make_call(rec->ip, addr, call);
+- ret = ftrace_check_current_call(rec->ip, call);
+-
+- if (ret)
+- return ret;
++ if (patch_text_nosync((void *)rec->ip, nops, FUNC_ENTRY_SIZE))
++ return -EPERM;
+
+- return __ftrace_modify_call(rec->ip, addr, false);
++ return 0;
+ }
+
+
+@@ -130,15 +157,16 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
+ unsigned long addr)
+ {
+ unsigned int call[2];
++ unsigned long caller = rec->ip + FUNC_ENTRY_JMP;
+ int ret;
+
+- make_call(rec->ip, old_addr, call);
+- ret = ftrace_check_current_call(rec->ip, call);
++ make_call(caller, old_addr, call);
++ ret = ftrace_check_current_call(caller, call);
+
+ if (ret)
+ return ret;
+
+- return __ftrace_modify_call(rec->ip, addr, true);
++ return __ftrace_modify_call(caller, addr, true);
+ }
+ #endif
+
+@@ -167,53 +195,30 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
+
+ #ifdef CONFIG_DYNAMIC_FTRACE
+ extern void ftrace_graph_call(void);
++extern void ftrace_graph_regs_call(void);
+ int ftrace_enable_ftrace_graph_caller(void)
+ {
+- unsigned int call[2];
+- static int init_graph = 1;
+ int ret;
+
+- make_call(&ftrace_graph_call, &ftrace_stub, call);
+-
+- /*
+- * When enabling graph tracer for the first time, ftrace_graph_call
+- * should contains a call to ftrace_stub. Once it has been disabled,
+- * the 8-bytes at the position becomes NOPs.
+- */
+- if (init_graph) {
+- ret = ftrace_check_current_call((unsigned long)&ftrace_graph_call,
+- call);
+- init_graph = 0;
+- } else {
+- ret = ftrace_check_current_call((unsigned long)&ftrace_graph_call,
+- NULL);
+- }
+-
++ ret = __ftrace_modify_call((unsigned long)&ftrace_graph_call,
++ (unsigned long)&prepare_ftrace_return, true);
+ if (ret)
+ return ret;
+
+- return __ftrace_modify_call((unsigned long)&ftrace_graph_call,
++ return __ftrace_modify_call((unsigned long)&ftrace_graph_regs_call,
+ (unsigned long)&prepare_ftrace_return, true);
+ }
+
+ int ftrace_disable_ftrace_graph_caller(void)
+ {
+- unsigned int call[2];
+ int ret;
+
+- make_call(&ftrace_graph_call, &prepare_ftrace_return, call);
+-
+- /*
+- * This is to make sure that ftrace_enable_ftrace_graph_caller
+- * did the right thing.
+- */
+- ret = ftrace_check_current_call((unsigned long)&ftrace_graph_call,
+- call);
+-
++ ret = __ftrace_modify_call((unsigned long)&ftrace_graph_call,
++ (unsigned long)&prepare_ftrace_return, false);
+ if (ret)
+ return ret;
+
+- return __ftrace_modify_call((unsigned long)&ftrace_graph_call,
++ return __ftrace_modify_call((unsigned long)&ftrace_graph_regs_call,
+ (unsigned long)&prepare_ftrace_return, false);
+ }
+ #endif /* CONFIG_DYNAMIC_FTRACE */
+diff --git a/arch/riscv/kernel/mcount-dyn.S b/arch/riscv/kernel/mcount-dyn.S
+index 35a6ed76cb8b7..d171eca623b6f 100644
+--- a/arch/riscv/kernel/mcount-dyn.S
++++ b/arch/riscv/kernel/mcount-dyn.S
+@@ -13,224 +13,186 @@
+
+ .text
+
+- .macro SAVE_ABI_STATE
+-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- addi sp, sp, -48
+- sd s0, 32(sp)
+- sd ra, 40(sp)
+- addi s0, sp, 48
+- sd t0, 24(sp)
+- sd t1, 16(sp)
+-#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+- sd t2, 8(sp)
+-#endif
+-#else
+- addi sp, sp, -16
+- sd s0, 0(sp)
+- sd ra, 8(sp)
+- addi s0, sp, 16
+-#endif
++#define FENTRY_RA_OFFSET 12
++#define ABI_SIZE_ON_STACK 72
++#define ABI_A0 0
++#define ABI_A1 8
++#define ABI_A2 16
++#define ABI_A3 24
++#define ABI_A4 32
++#define ABI_A5 40
++#define ABI_A6 48
++#define ABI_A7 56
++#define ABI_RA 64
++
++ .macro SAVE_ABI
++ addi sp, sp, -SZREG
++ addi sp, sp, -ABI_SIZE_ON_STACK
++
++ REG_S a0, ABI_A0(sp)
++ REG_S a1, ABI_A1(sp)
++ REG_S a2, ABI_A2(sp)
++ REG_S a3, ABI_A3(sp)
++ REG_S a4, ABI_A4(sp)
++ REG_S a5, ABI_A5(sp)
++ REG_S a6, ABI_A6(sp)
++ REG_S a7, ABI_A7(sp)
++ REG_S ra, ABI_RA(sp)
+ .endm
+
+- .macro RESTORE_ABI_STATE
+-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- ld s0, 32(sp)
+- ld ra, 40(sp)
+- addi sp, sp, 48
+-#else
+- ld ra, 8(sp)
+- ld s0, 0(sp)
+- addi sp, sp, 16
+-#endif
++ .macro RESTORE_ABI
++ REG_L a0, ABI_A0(sp)
++ REG_L a1, ABI_A1(sp)
++ REG_L a2, ABI_A2(sp)
++ REG_L a3, ABI_A3(sp)
++ REG_L a4, ABI_A4(sp)
++ REG_L a5, ABI_A5(sp)
++ REG_L a6, ABI_A6(sp)
++ REG_L a7, ABI_A7(sp)
++ REG_L ra, ABI_RA(sp)
++
++ addi sp, sp, ABI_SIZE_ON_STACK
++ addi sp, sp, SZREG
+ .endm
+
+- .macro RESTORE_GRAPH_ARGS
+- ld a0, 24(sp)
+- ld a1, 16(sp)
+-#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+- ld a2, 8(sp)
+-#endif
++#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
++ .macro SAVE_ALL
++ addi sp, sp, -SZREG
++ addi sp, sp, -PT_SIZE_ON_STACK
++
++ REG_S x1, PT_EPC(sp)
++ addi sp, sp, PT_SIZE_ON_STACK
++ REG_L x1, (sp)
++ addi sp, sp, -PT_SIZE_ON_STACK
++ REG_S x1, PT_RA(sp)
++ REG_L x1, PT_EPC(sp)
++
++ REG_S x2, PT_SP(sp)
++ REG_S x3, PT_GP(sp)
++ REG_S x4, PT_TP(sp)
++ REG_S x5, PT_T0(sp)
++ REG_S x6, PT_T1(sp)
++ REG_S x7, PT_T2(sp)
++ REG_S x8, PT_S0(sp)
++ REG_S x9, PT_S1(sp)
++ REG_S x10, PT_A0(sp)
++ REG_S x11, PT_A1(sp)
++ REG_S x12, PT_A2(sp)
++ REG_S x13, PT_A3(sp)
++ REG_S x14, PT_A4(sp)
++ REG_S x15, PT_A5(sp)
++ REG_S x16, PT_A6(sp)
++ REG_S x17, PT_A7(sp)
++ REG_S x18, PT_S2(sp)
++ REG_S x19, PT_S3(sp)
++ REG_S x20, PT_S4(sp)
++ REG_S x21, PT_S5(sp)
++ REG_S x22, PT_S6(sp)
++ REG_S x23, PT_S7(sp)
++ REG_S x24, PT_S8(sp)
++ REG_S x25, PT_S9(sp)
++ REG_S x26, PT_S10(sp)
++ REG_S x27, PT_S11(sp)
++ REG_S x28, PT_T3(sp)
++ REG_S x29, PT_T4(sp)
++ REG_S x30, PT_T5(sp)
++ REG_S x31, PT_T6(sp)
+ .endm
+
+-ENTRY(ftrace_graph_caller)
+- addi sp, sp, -16
+- sd s0, 0(sp)
+- sd ra, 8(sp)
+- addi s0, sp, 16
+-ftrace_graph_call:
+- .global ftrace_graph_call
+- /*
+- * Calling ftrace_enable/disable_ftrace_graph_caller would overwrite the
+- * call below. Check ftrace_modify_all_code for details.
+- */
+- call ftrace_stub
+- ld ra, 8(sp)
+- ld s0, 0(sp)
+- addi sp, sp, 16
+- ret
+-ENDPROC(ftrace_graph_caller)
++ .macro RESTORE_ALL
++ REG_L x1, PT_RA(sp)
++ addi sp, sp, PT_SIZE_ON_STACK
++ REG_S x1, (sp)
++ addi sp, sp, -PT_SIZE_ON_STACK
++ REG_L x1, PT_EPC(sp)
++ REG_L x2, PT_SP(sp)
++ REG_L x3, PT_GP(sp)
++ REG_L x4, PT_TP(sp)
++ REG_L x5, PT_T0(sp)
++ REG_L x6, PT_T1(sp)
++ REG_L x7, PT_T2(sp)
++ REG_L x8, PT_S0(sp)
++ REG_L x9, PT_S1(sp)
++ REG_L x10, PT_A0(sp)
++ REG_L x11, PT_A1(sp)
++ REG_L x12, PT_A2(sp)
++ REG_L x13, PT_A3(sp)
++ REG_L x14, PT_A4(sp)
++ REG_L x15, PT_A5(sp)
++ REG_L x16, PT_A6(sp)
++ REG_L x17, PT_A7(sp)
++ REG_L x18, PT_S2(sp)
++ REG_L x19, PT_S3(sp)
++ REG_L x20, PT_S4(sp)
++ REG_L x21, PT_S5(sp)
++ REG_L x22, PT_S6(sp)
++ REG_L x23, PT_S7(sp)
++ REG_L x24, PT_S8(sp)
++ REG_L x25, PT_S9(sp)
++ REG_L x26, PT_S10(sp)
++ REG_L x27, PT_S11(sp)
++ REG_L x28, PT_T3(sp)
++ REG_L x29, PT_T4(sp)
++ REG_L x30, PT_T5(sp)
++ REG_L x31, PT_T6(sp)
++
++ addi sp, sp, PT_SIZE_ON_STACK
++ addi sp, sp, SZREG
++ .endm
++#endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
+
+ ENTRY(ftrace_caller)
+- /*
+- * a0: the address in the caller when calling ftrace_caller
+- * a1: the caller's return address
+- * a2: the address of global variable function_trace_op
+- */
+- ld a1, -8(s0)
+- addi a0, ra, -MCOUNT_INSN_SIZE
+- la t5, function_trace_op
+- ld a2, 0(t5)
++ SAVE_ABI
+
+-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- /*
+- * the graph tracer (specifically, prepare_ftrace_return) needs these
+- * arguments but for now the function tracer occupies the regs, so we
+- * save them in temporary regs to recover later.
+- */
+- addi t0, s0, -8
+- mv t1, a0
+-#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+- ld t2, -16(s0)
+-#endif
+-#endif
++ addi a0, ra, -FENTRY_RA_OFFSET
++ la a1, function_trace_op
++ REG_L a2, 0(a1)
++ REG_L a1, ABI_SIZE_ON_STACK(sp)
++ mv a3, sp
+
+- SAVE_ABI_STATE
+ ftrace_call:
+ .global ftrace_call
+- /*
+- * For the dynamic ftrace to work, here we should reserve at least
+- * 8 bytes for a functional auipc-jalr pair. The following call
+- * serves this purpose.
+- *
+- * Calling ftrace_update_ftrace_func would overwrite the nops below.
+- * Check ftrace_modify_all_code for details.
+- */
+ call ftrace_stub
+
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- RESTORE_GRAPH_ARGS
+- call ftrace_graph_caller
++ addi a0, sp, ABI_SIZE_ON_STACK
++ REG_L a1, ABI_RA(sp)
++ addi a1, a1, -FENTRY_RA_OFFSET
++#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
++ mv a2, s0
+ #endif
+-
+- RESTORE_ABI_STATE
++ftrace_graph_call:
++ .global ftrace_graph_call
++ call ftrace_stub
++#endif
++ RESTORE_ABI
+ ret
+ ENDPROC(ftrace_caller)
+
+ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+- .macro SAVE_ALL
+- addi sp, sp, -(PT_SIZE_ON_STACK+16)
+- sd s0, (PT_SIZE_ON_STACK)(sp)
+- sd ra, (PT_SIZE_ON_STACK+8)(sp)
+- addi s0, sp, (PT_SIZE_ON_STACK+16)
+-
+- sd x1, PT_RA(sp)
+- sd x2, PT_SP(sp)
+- sd x3, PT_GP(sp)
+- sd x4, PT_TP(sp)
+- sd x5, PT_T0(sp)
+- sd x6, PT_T1(sp)
+- sd x7, PT_T2(sp)
+- sd x8, PT_S0(sp)
+- sd x9, PT_S1(sp)
+- sd x10, PT_A0(sp)
+- sd x11, PT_A1(sp)
+- sd x12, PT_A2(sp)
+- sd x13, PT_A3(sp)
+- sd x14, PT_A4(sp)
+- sd x15, PT_A5(sp)
+- sd x16, PT_A6(sp)
+- sd x17, PT_A7(sp)
+- sd x18, PT_S2(sp)
+- sd x19, PT_S3(sp)
+- sd x20, PT_S4(sp)
+- sd x21, PT_S5(sp)
+- sd x22, PT_S6(sp)
+- sd x23, PT_S7(sp)
+- sd x24, PT_S8(sp)
+- sd x25, PT_S9(sp)
+- sd x26, PT_S10(sp)
+- sd x27, PT_S11(sp)
+- sd x28, PT_T3(sp)
+- sd x29, PT_T4(sp)
+- sd x30, PT_T5(sp)
+- sd x31, PT_T6(sp)
+- .endm
+-
+- .macro RESTORE_ALL
+- ld x1, PT_RA(sp)
+- ld x2, PT_SP(sp)
+- ld x3, PT_GP(sp)
+- ld x4, PT_TP(sp)
+- ld x5, PT_T0(sp)
+- ld x6, PT_T1(sp)
+- ld x7, PT_T2(sp)
+- ld x8, PT_S0(sp)
+- ld x9, PT_S1(sp)
+- ld x10, PT_A0(sp)
+- ld x11, PT_A1(sp)
+- ld x12, PT_A2(sp)
+- ld x13, PT_A3(sp)
+- ld x14, PT_A4(sp)
+- ld x15, PT_A5(sp)
+- ld x16, PT_A6(sp)
+- ld x17, PT_A7(sp)
+- ld x18, PT_S2(sp)
+- ld x19, PT_S3(sp)
+- ld x20, PT_S4(sp)
+- ld x21, PT_S5(sp)
+- ld x22, PT_S6(sp)
+- ld x23, PT_S7(sp)
+- ld x24, PT_S8(sp)
+- ld x25, PT_S9(sp)
+- ld x26, PT_S10(sp)
+- ld x27, PT_S11(sp)
+- ld x28, PT_T3(sp)
+- ld x29, PT_T4(sp)
+- ld x30, PT_T5(sp)
+- ld x31, PT_T6(sp)
+-
+- ld s0, (PT_SIZE_ON_STACK)(sp)
+- ld ra, (PT_SIZE_ON_STACK+8)(sp)
+- addi sp, sp, (PT_SIZE_ON_STACK+16)
+- .endm
+-
+- .macro RESTORE_GRAPH_REG_ARGS
+- ld a0, PT_T0(sp)
+- ld a1, PT_T1(sp)
+-#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+- ld a2, PT_T2(sp)
+-#endif
+- .endm
+-
+-/*
+- * Most of the contents are the same as ftrace_caller.
+- */
+ ENTRY(ftrace_regs_caller)
+- /*
+- * a3: the address of all registers in the stack
+- */
+- ld a1, -8(s0)
+- addi a0, ra, -MCOUNT_INSN_SIZE
+- la t5, function_trace_op
+- ld a2, 0(t5)
+- addi a3, sp, -(PT_SIZE_ON_STACK+16)
+-
+-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- addi t0, s0, -8
+- mv t1, a0
+-#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
+- ld t2, -16(s0)
+-#endif
+-#endif
+ SAVE_ALL
+
++ addi a0, ra, -FENTRY_RA_OFFSET
++ la a1, function_trace_op
++ REG_L a2, 0(a1)
++ REG_L a1, PT_SIZE_ON_STACK(sp)
++ mv a3, sp
++
+ ftrace_regs_call:
+ .global ftrace_regs_call
+ call ftrace_stub
+
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+- RESTORE_GRAPH_REG_ARGS
+- call ftrace_graph_caller
++ addi a0, sp, PT_RA
++ REG_L a1, PT_EPC(sp)
++ addi a1, a1, -FENTRY_RA_OFFSET
++#ifdef HAVE_FUNCTION_GRAPH_FP_TEST
++ mv a2, s0
++#endif
++ftrace_graph_regs_call:
++ .global ftrace_graph_regs_call
++ call ftrace_stub
+ #endif
+
+ RESTORE_ALL
+--
+2.39.2
+
--- /dev/null
+From 20e507b8c7b7b393e7c1139c3f9ba730f936e909 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 12:52:00 -0800
+Subject: scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
+
+From: Bart Van Assche <bvanassche@acm.org>
+
+[ Upstream commit fc663711b94468f4e1427ebe289c9f05669699c9 ]
+
+Remove the /proc/scsi/${proc_name} directory earlier to fix a race
+condition between unloading and reloading kernel modules. This fixes a bug
+introduced in 2009 by commit 77c019768f06 ("[SCSI] fix /proc memory leak in
+the SCSI core").
+
+Fix the following kernel warning:
+
+proc_dir_entry 'scsi/scsi_debug' already registered
+WARNING: CPU: 19 PID: 27986 at fs/proc/generic.c:376 proc_register+0x27d/0x2e0
+Call Trace:
+ proc_mkdir+0xb5/0xe0
+ scsi_proc_hostdir_add+0xb5/0x170
+ scsi_host_alloc+0x683/0x6c0
+ sdebug_driver_probe+0x6b/0x2d0 [scsi_debug]
+ really_probe+0x159/0x540
+ __driver_probe_device+0xdc/0x230
+ driver_probe_device+0x4f/0x120
+ __device_attach_driver+0xef/0x180
+ bus_for_each_drv+0xe5/0x130
+ __device_attach+0x127/0x290
+ device_initial_probe+0x17/0x20
+ bus_probe_device+0x110/0x130
+ device_add+0x673/0xc80
+ device_register+0x1e/0x30
+ sdebug_add_host_helper+0x1a7/0x3b0 [scsi_debug]
+ scsi_debug_init+0x64f/0x1000 [scsi_debug]
+ do_one_initcall+0xd7/0x470
+ do_init_module+0xe7/0x330
+ load_module+0x122a/0x12c0
+ __do_sys_finit_module+0x124/0x1a0
+ __x64_sys_finit_module+0x46/0x50
+ do_syscall_64+0x38/0x80
+ entry_SYSCALL_64_after_hwframe+0x46/0xb0
+
+Link: https://lore.kernel.org/r/20230210205200.36973-3-bvanassche@acm.org
+Cc: Alan Stern <stern@rowland.harvard.edu>
+Cc: Yi Zhang <yi.zhang@redhat.com>
+Cc: stable@vger.kernel.org
+Fixes: 77c019768f06 ("[SCSI] fix /proc memory leak in the SCSI core")
+Reported-by: Yi Zhang <yi.zhang@redhat.com>
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/scsi/hosts.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
+index b3d6ea92b4f7c..2ffc2e15d822b 100644
+--- a/drivers/scsi/hosts.c
++++ b/drivers/scsi/hosts.c
+@@ -178,6 +178,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
+ scsi_forget_host(shost);
+ mutex_unlock(&shost->scan_mutex);
+ scsi_proc_host_rm(shost);
++ scsi_proc_hostdir_rm(shost->hostt);
+
+ spin_lock_irqsave(shost->host_lock, flags);
+ if (scsi_host_set_state(shost, SHOST_DEL))
+@@ -329,6 +330,7 @@ static void scsi_host_dev_release(struct device *dev)
+ struct Scsi_Host *shost = dev_to_shost(dev);
+ struct device *parent = dev->parent;
+
++ /* In case scsi_remove_host() has not been called. */
+ scsi_proc_hostdir_rm(shost->hostt);
+
+ /* Wait for functions invoked through call_rcu(&shost->rcu, ...) */
+--
+2.39.2
+
ext4-fix-warning-in-ext4_update_inline_data.patch
ext4-zero-i_disksize-when-initializing-the-bootloader-inode.patch
nfc-change-order-inside-nfc_se_io-error-path.patch
+udf-explain-handling-of-load_nls-failure.patch
+udf-reduce-leakage-of-blocks-related-to-named-stream.patch
+udf-remove-pointless-union-in-udf_inode_info.patch
+udf-preserve-link-count-of-system-files.patch
+udf-detect-system-inodes-linked-into-directory-hiera.patch
+fs-dlm-public-header-in-out-utility.patch
+fs-dlm-add-union-in-dlm-header-for-lockspace-id.patch
+fs-dlm-fix-log-of-lowcomms-vs-midcomms.patch
+kvm-using-macros-instead-of-magic-values.patch
+kvm-x86-do-not-change-icr-on-write-to-apic_self_ipi.patch
+usb-dwc3-pci-id-for-tiger-lake-cpu.patch
+riscv-using-patchable_function_entry-instead-of-mcou.patch
+arm-dts-exynos-fix-language-typo-and-indentation.patch
+riscv-ftrace-remove-wasted-nops-for-riscv_isa_c.patch
+arm-dts-exynos-override-thermal-by-label-in-exynos42.patch
+riscv-ftrace-reduce-the-detour-code-size-to-half.patch
+arm-dts-exynos-correct-tmu-phandle-in-exynos4210.patch
+arm-dts-exynos-add-all-cpus-in-cooling-maps.patch
+arm-dts-exynos-move-pmu-and-timer-nodes-out-of-soc.patch
+arm-dts-exynos-override-thermal-by-label-in-exynos52.patch
+arm-dts-exynos-correct-tmu-phandle-in-exynos5250.patch
+kbuild-fix-false-positive-need-builtin-calculation.patch
+kbuild-generate-modules.order-only-in-directories-vi.patch
+arm-dts-exynos-add-gpu-thermal-zone-cooling-maps-for.patch
+arm-dts-exynos-correct-tmu-phandle-in-odroid-hc1.patch
+arm-dts-exynos-correct-tmu-phandle-in-odroid-xu3-fam.patch
+scsi-core-remove-the-proc-scsi-proc_name-directory-e.patch
--- /dev/null
+From e6119fc629561cd13f22a86c155244384ebd1dc5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 10:03:35 +0100
+Subject: udf: Detect system inodes linked into directory hierarchy
+
+From: Jan Kara <jack@suse.cz>
+
+[ Upstream commit 85a37983ec69cc9fcd188bc37c4de15ee326355a ]
+
+When UDF filesystem is corrupted, hidden system inodes can be linked
+into directory hierarchy which is an avenue for further serious
+corruption of the filesystem and kernel confusion as noticed by syzbot
+fuzzed images. Refuse to access system inodes linked into directory
+hierarchy and vice versa.
+
+CC: stable@vger.kernel.org
+Reported-by: syzbot+38695a20b8addcbc1084@syzkaller.appspotmail.com
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/udf/inode.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/fs/udf/inode.c b/fs/udf/inode.c
+index 7436337914b19..77421e65623a1 100644
+--- a/fs/udf/inode.c
++++ b/fs/udf/inode.c
+@@ -1871,8 +1871,13 @@ struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino,
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+
+- if (!(inode->i_state & I_NEW))
++ if (!(inode->i_state & I_NEW)) {
++ if (UDF_I(inode)->i_hidden != hidden_inode) {
++ iput(inode);
++ return ERR_PTR(-EFSCORRUPTED);
++ }
+ return inode;
++ }
+
+ memcpy(&UDF_I(inode)->i_location, ino, sizeof(struct kernel_lb_addr));
+ err = udf_read_inode(inode, hidden_inode);
+--
+2.39.2
+
--- /dev/null
+From 5f0df85dbac02885d8788d43db7a2a9e2c8db0f3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 19 Mar 2019 09:48:59 +0100
+Subject: udf: Explain handling of load_nls() failure
+
+From: Jan Kara <jack@suse.cz>
+
+[ Upstream commit a768a9abc625d554f7b6428517089c193fcb5962 ]
+
+Add comment explaining that load_nls() failure gets handled back in
+udf_fill_super() to avoid false impression that it is unhandled.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Stable-dep-of: fc8033a34a3c ("udf: Preserve link count of system files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/udf/super.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/fs/udf/super.c b/fs/udf/super.c
+index b7fb7cd35d89a..5d179616578cf 100644
+--- a/fs/udf/super.c
++++ b/fs/udf/super.c
+@@ -572,6 +572,11 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
+ if (!remount) {
+ if (uopt->nls_map)
+ unload_nls(uopt->nls_map);
++ /*
++ * load_nls() failure is handled later in
++ * udf_fill_super() after all options are
++ * parsed.
++ */
+ uopt->nls_map = load_nls(args[0].from);
+ uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
+ }
+--
+2.39.2
+
--- /dev/null
+From d049b6a59f26d33616961a0959d90babf0549a19 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Jan 2023 09:56:56 +0100
+Subject: udf: Preserve link count of system files
+
+From: Jan Kara <jack@suse.cz>
+
+[ Upstream commit fc8033a34a3ca7d23353e645e6dde5d364ac5f12 ]
+
+System files in UDF filesystem have link count 0. To not confuse VFS we
+fudge the link count to be 1 when reading such inodes however we forget
+to restore the link count of 0 when writing such inodes. Fix that.
+
+CC: stable@vger.kernel.org
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/udf/inode.c | 9 +++++++--
+ fs/udf/super.c | 1 +
+ fs/udf/udf_i.h | 3 ++-
+ 3 files changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/fs/udf/inode.c b/fs/udf/inode.c
+index 415f1186d250f..7436337914b19 100644
+--- a/fs/udf/inode.c
++++ b/fs/udf/inode.c
+@@ -1375,6 +1375,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ ret = -EIO;
+ goto out;
+ }
++ iinfo->i_hidden = hidden_inode;
+ iinfo->i_unique = 0;
+ iinfo->i_lenEAttr = 0;
+ iinfo->i_lenExtents = 0;
+@@ -1694,8 +1695,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
+
+ if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0)
+ fe->fileLinkCount = cpu_to_le16(inode->i_nlink - 1);
+- else
+- fe->fileLinkCount = cpu_to_le16(inode->i_nlink);
++ else {
++ if (iinfo->i_hidden)
++ fe->fileLinkCount = cpu_to_le16(0);
++ else
++ fe->fileLinkCount = cpu_to_le16(inode->i_nlink);
++ }
+
+ fe->informationLength = cpu_to_le64(inode->i_size);
+
+diff --git a/fs/udf/super.c b/fs/udf/super.c
+index cdaef406f3899..bce48a07790cb 100644
+--- a/fs/udf/super.c
++++ b/fs/udf/super.c
+@@ -151,6 +151,7 @@ static struct inode *udf_alloc_inode(struct super_block *sb)
+ ei->i_next_alloc_goal = 0;
+ ei->i_strat4096 = 0;
+ ei->i_streamdir = 0;
++ ei->i_hidden = 0;
+ init_rwsem(&ei->i_data_sem);
+ ei->cached_extent.lstart = -1;
+ spin_lock_init(&ei->i_extent_cache_lock);
+diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
+index 2a4731314d51f..b77bf713a1b68 100644
+--- a/fs/udf/udf_i.h
++++ b/fs/udf/udf_i.h
+@@ -43,7 +43,8 @@ struct udf_inode_info {
+ unsigned i_use : 1; /* unallocSpaceEntry */
+ unsigned i_strat4096 : 1;
+ unsigned i_streamdir : 1;
+- unsigned reserved : 25;
++ unsigned i_hidden : 1; /* hidden system inode */
++ unsigned reserved : 24;
+ __u8 *i_data;
+ struct kernel_lb_addr i_locStreamdir;
+ __u64 i_lenStreams;
+--
+2.39.2
+
--- /dev/null
+From 49a0903134a308bb97f4238e807a117458ddd2fe Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 14 Aug 2019 07:50:02 -0500
+Subject: udf: reduce leakage of blocks related to named streams
+
+From: Steven J. Magnani <steve.magnani@digidescorp.com>
+
+[ Upstream commit ab9a3a737284b3d9e1d2ba43a0ef31b3ef2e2417 ]
+
+Windows is capable of creating UDF files having named streams.
+One example is the "Zone.Identifier" stream attached automatically
+to files downloaded from a network. See:
+ https://msdn.microsoft.com/en-us/library/dn392609.aspx
+
+Modification of a file having one or more named streams in Linux causes
+the stream directory to become detached from the file, essentially leaking
+all blocks pertaining to the file's streams.
+
+Fix by saving off information about an inode's streams when reading it,
+for later use when its on-disk data is updated.
+
+Link: https://lore.kernel.org/r/20190814125002.10869-1-steve@digidescorp.com
+Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Stable-dep-of: fc8033a34a3c ("udf: Preserve link count of system files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/udf/inode.c | 24 +++++++++++++++++++++++-
+ fs/udf/super.c | 2 ++
+ fs/udf/udf_i.h | 5 ++++-
+ 3 files changed, 29 insertions(+), 2 deletions(-)
+
+diff --git a/fs/udf/inode.c b/fs/udf/inode.c
+index af1180104e560..99d297b667ce1 100644
+--- a/fs/udf/inode.c
++++ b/fs/udf/inode.c
+@@ -1470,6 +1470,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
+ iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs);
+ iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint);
++ iinfo->i_streamdir = 0;
++ iinfo->i_lenStreams = 0;
+ } else {
+ inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
+ (inode->i_sb->s_blocksize_bits - 9);
+@@ -1483,6 +1485,16 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
+ iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs);
+ iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint);
++
++ /* Named streams */
++ iinfo->i_streamdir = (efe->streamDirectoryICB.extLength != 0);
++ iinfo->i_locStreamdir =
++ lelb_to_cpu(efe->streamDirectoryICB.extLocation);
++ iinfo->i_lenStreams = le64_to_cpu(efe->objectSize);
++ if (iinfo->i_lenStreams >= inode->i_size)
++ iinfo->i_lenStreams -= inode->i_size;
++ else
++ iinfo->i_lenStreams = 0;
+ }
+ inode->i_generation = iinfo->i_unique;
+
+@@ -1745,9 +1757,19 @@ static int udf_update_inode(struct inode *inode, int do_sync)
+ iinfo->i_ext.i_data,
+ inode->i_sb->s_blocksize -
+ sizeof(struct extendedFileEntry));
+- efe->objectSize = cpu_to_le64(inode->i_size);
++ efe->objectSize =
++ cpu_to_le64(inode->i_size + iinfo->i_lenStreams);
+ efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
+
++ if (iinfo->i_streamdir) {
++ struct long_ad *icb_lad = &efe->streamDirectoryICB;
++
++ icb_lad->extLocation =
++ cpu_to_lelb(iinfo->i_locStreamdir);
++ icb_lad->extLength =
++ cpu_to_le32(inode->i_sb->s_blocksize);
++ }
++
+ udf_adjust_time(iinfo, inode->i_atime);
+ udf_adjust_time(iinfo, inode->i_mtime);
+ udf_adjust_time(iinfo, inode->i_ctime);
+diff --git a/fs/udf/super.c b/fs/udf/super.c
+index 5d179616578cf..ec082b27e9fba 100644
+--- a/fs/udf/super.c
++++ b/fs/udf/super.c
+@@ -146,9 +146,11 @@ static struct inode *udf_alloc_inode(struct super_block *sb)
+
+ ei->i_unique = 0;
+ ei->i_lenExtents = 0;
++ ei->i_lenStreams = 0;
+ ei->i_next_alloc_block = 0;
+ ei->i_next_alloc_goal = 0;
+ ei->i_strat4096 = 0;
++ ei->i_streamdir = 0;
+ init_rwsem(&ei->i_data_sem);
+ ei->cached_extent.lstart = -1;
+ spin_lock_init(&ei->i_extent_cache_lock);
+diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
+index 2ef0e212f08a3..00d773d1b7cf0 100644
+--- a/fs/udf/udf_i.h
++++ b/fs/udf/udf_i.h
+@@ -42,12 +42,15 @@ struct udf_inode_info {
+ unsigned i_efe : 1; /* extendedFileEntry */
+ unsigned i_use : 1; /* unallocSpaceEntry */
+ unsigned i_strat4096 : 1;
+- unsigned reserved : 26;
++ unsigned i_streamdir : 1;
++ unsigned reserved : 25;
+ union {
+ struct short_ad *i_sad;
+ struct long_ad *i_lad;
+ __u8 *i_data;
+ } i_ext;
++ struct kernel_lb_addr i_locStreamdir;
++ __u64 i_lenStreams;
+ struct rw_semaphore i_data_sem;
+ struct udf_ext_cache cached_extent;
+ /* Spinlock for protecting extent cache */
+--
+2.39.2
+
--- /dev/null
+From 700935e070d59f14b272abd6a613de9a3a8349f8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 25 Sep 2020 12:29:54 +0200
+Subject: udf: Remove pointless union in udf_inode_info
+
+From: Jan Kara <jack@suse.cz>
+
+[ Upstream commit 382a2287bf9cd283206764572f66ab12657218aa ]
+
+We use only a single member out of the i_ext union in udf_inode_info.
+Just remove the pointless union.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Stable-dep-of: fc8033a34a3c ("udf: Preserve link count of system files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/udf/directory.c | 2 +-
+ fs/udf/file.c | 7 +++----
+ fs/udf/ialloc.c | 14 +++++++-------
+ fs/udf/inode.c | 36 +++++++++++++++++-------------------
+ fs/udf/misc.c | 6 +++---
+ fs/udf/namei.c | 7 +++----
+ fs/udf/partition.c | 2 +-
+ fs/udf/super.c | 4 ++--
+ fs/udf/symlink.c | 2 +-
+ fs/udf/udf_i.h | 6 +-----
+ 10 files changed, 39 insertions(+), 47 deletions(-)
+
+diff --git a/fs/udf/directory.c b/fs/udf/directory.c
+index d9523013096f9..73720320f0ab7 100644
+--- a/fs/udf/directory.c
++++ b/fs/udf/directory.c
+@@ -34,7 +34,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
+ fibh->soffset = fibh->eoffset;
+
+ if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+- fi = udf_get_fileident(iinfo->i_ext.i_data -
++ fi = udf_get_fileident(iinfo->i_data -
+ (iinfo->i_efe ?
+ sizeof(struct extendedFileEntry) :
+ sizeof(struct fileEntry)),
+diff --git a/fs/udf/file.c b/fs/udf/file.c
+index 88b7fb8e9998c..8fff7ffc33a81 100644
+--- a/fs/udf/file.c
++++ b/fs/udf/file.c
+@@ -50,7 +50,7 @@ static void __udf_adinicb_readpage(struct page *page)
+ * So just sample it once and use the same value everywhere.
+ */
+ kaddr = kmap_atomic(page);
+- memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, isize);
++ memcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr, isize);
+ memset(kaddr + isize, 0, PAGE_SIZE - isize);
+ flush_dcache_page(page);
+ SetPageUptodate(page);
+@@ -76,8 +76,7 @@ static int udf_adinicb_writepage(struct page *page,
+ BUG_ON(!PageLocked(page));
+
+ kaddr = kmap_atomic(page);
+- memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr,
+- i_size_read(inode));
++ memcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, i_size_read(inode));
+ SetPageUptodate(page);
+ kunmap_atomic(kaddr);
+ mark_inode_dirty(inode);
+@@ -213,7 +212,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ return put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg);
+ case UDF_GETEABLOCK:
+ return copy_to_user((char __user *)arg,
+- UDF_I(inode)->i_ext.i_data,
++ UDF_I(inode)->i_data,
+ UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0;
+ default:
+ return -ENOIOCTLCMD;
+diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
+index f8e5872f7cc27..cdaa86e077b29 100644
+--- a/fs/udf/ialloc.c
++++ b/fs/udf/ialloc.c
+@@ -67,16 +67,16 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
+ iinfo->i_efe = 1;
+ if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
+ sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
+- iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
+- sizeof(struct extendedFileEntry),
+- GFP_KERNEL);
++ iinfo->i_data = kzalloc(inode->i_sb->s_blocksize -
++ sizeof(struct extendedFileEntry),
++ GFP_KERNEL);
+ } else {
+ iinfo->i_efe = 0;
+- iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
+- sizeof(struct fileEntry),
+- GFP_KERNEL);
++ iinfo->i_data = kzalloc(inode->i_sb->s_blocksize -
++ sizeof(struct fileEntry),
++ GFP_KERNEL);
+ }
+- if (!iinfo->i_ext.i_data) {
++ if (!iinfo->i_data) {
+ iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
+diff --git a/fs/udf/inode.c b/fs/udf/inode.c
+index 99d297b667ce1..415f1186d250f 100644
+--- a/fs/udf/inode.c
++++ b/fs/udf/inode.c
+@@ -150,8 +150,8 @@ void udf_evict_inode(struct inode *inode)
+ truncate_inode_pages_final(&inode->i_data);
+ invalidate_inode_buffers(inode);
+ clear_inode(inode);
+- kfree(iinfo->i_ext.i_data);
+- iinfo->i_ext.i_data = NULL;
++ kfree(iinfo->i_data);
++ iinfo->i_data = NULL;
+ udf_clear_extent_cache(inode);
+ if (want_delete) {
+ udf_free_inode(inode);
+@@ -278,14 +278,14 @@ int udf_expand_file_adinicb(struct inode *inode)
+ kaddr = kmap_atomic(page);
+ memset(kaddr + iinfo->i_lenAlloc, 0x00,
+ PAGE_SIZE - iinfo->i_lenAlloc);
+- memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr,
++ memcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr,
+ iinfo->i_lenAlloc);
+ flush_dcache_page(page);
+ SetPageUptodate(page);
+ kunmap_atomic(kaddr);
+ }
+ down_write(&iinfo->i_data_sem);
+- memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0x00,
++ memset(iinfo->i_data + iinfo->i_lenEAttr, 0x00,
+ iinfo->i_lenAlloc);
+ iinfo->i_lenAlloc = 0;
+ if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
+@@ -303,8 +303,7 @@ int udf_expand_file_adinicb(struct inode *inode)
+ lock_page(page);
+ down_write(&iinfo->i_data_sem);
+ kaddr = kmap_atomic(page);
+- memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr,
+- inode->i_size);
++ memcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, inode->i_size);
+ kunmap_atomic(kaddr);
+ unlock_page(page);
+ iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
+@@ -392,8 +391,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
+ }
+ mark_buffer_dirty_inode(dbh, inode);
+
+- memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0,
+- iinfo->i_lenAlloc);
++ memset(iinfo->i_data + iinfo->i_lenEAttr, 0, iinfo->i_lenAlloc);
+ iinfo->i_lenAlloc = 0;
+ eloc.logicalBlockNum = *block;
+ eloc.partitionReferenceNum =
+@@ -1241,7 +1239,7 @@ int udf_setsize(struct inode *inode, loff_t newsize)
+ if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+ down_write(&iinfo->i_data_sem);
+ udf_clear_extent_cache(inode);
+- memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr + newsize,
++ memset(iinfo->i_data + iinfo->i_lenEAttr + newsize,
+ 0x00, bsize - newsize -
+ udf_file_entry_alloc_offset(inode));
+ iinfo->i_lenAlloc = newsize;
+@@ -1390,7 +1388,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ sizeof(struct extendedFileEntry));
+ if (ret)
+ goto out;
+- memcpy(iinfo->i_ext.i_data,
++ memcpy(iinfo->i_data,
+ bh->b_data + sizeof(struct extendedFileEntry),
+ bs - sizeof(struct extendedFileEntry));
+ } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) {
+@@ -1399,7 +1397,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ ret = udf_alloc_i_data(inode, bs - sizeof(struct fileEntry));
+ if (ret)
+ goto out;
+- memcpy(iinfo->i_ext.i_data,
++ memcpy(iinfo->i_data,
+ bh->b_data + sizeof(struct fileEntry),
+ bs - sizeof(struct fileEntry));
+ } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) {
+@@ -1412,7 +1410,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ sizeof(struct unallocSpaceEntry));
+ if (ret)
+ goto out;
+- memcpy(iinfo->i_ext.i_data,
++ memcpy(iinfo->i_data,
+ bh->b_data + sizeof(struct unallocSpaceEntry),
+ bs - sizeof(struct unallocSpaceEntry));
+ return 0;
+@@ -1591,8 +1589,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
+ static int udf_alloc_i_data(struct inode *inode, size_t size)
+ {
+ struct udf_inode_info *iinfo = UDF_I(inode);
+- iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL);
+- if (!iinfo->i_ext.i_data)
++ iinfo->i_data = kmalloc(size, GFP_KERNEL);
++ if (!iinfo->i_data)
+ return -ENOMEM;
+ return 0;
+ }
+@@ -1666,7 +1664,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
+
+ use->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc);
+ memcpy(bh->b_data + sizeof(struct unallocSpaceEntry),
+- iinfo->i_ext.i_data, inode->i_sb->s_blocksize -
++ iinfo->i_data, inode->i_sb->s_blocksize -
+ sizeof(struct unallocSpaceEntry));
+ use->descTag.tagIdent = cpu_to_le16(TAG_IDENT_USE);
+ crclen = sizeof(struct unallocSpaceEntry);
+@@ -1735,7 +1733,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
+
+ if (iinfo->i_efe == 0) {
+ memcpy(bh->b_data + sizeof(struct fileEntry),
+- iinfo->i_ext.i_data,
++ iinfo->i_data,
+ inode->i_sb->s_blocksize - sizeof(struct fileEntry));
+ fe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
+
+@@ -1754,7 +1752,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
+ crclen = sizeof(struct fileEntry);
+ } else {
+ memcpy(bh->b_data + sizeof(struct extendedFileEntry),
+- iinfo->i_ext.i_data,
++ iinfo->i_data,
+ inode->i_sb->s_blocksize -
+ sizeof(struct extendedFileEntry));
+ efe->objectSize =
+@@ -2050,7 +2048,7 @@ void udf_write_aext(struct inode *inode, struct extent_position *epos,
+ struct udf_inode_info *iinfo = UDF_I(inode);
+
+ if (!epos->bh)
+- ptr = iinfo->i_ext.i_data + epos->offset -
++ ptr = iinfo->i_data + epos->offset -
+ udf_file_entry_alloc_offset(inode) +
+ iinfo->i_lenEAttr;
+ else
+@@ -2142,7 +2140,7 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
+ if (!epos->bh) {
+ if (!epos->offset)
+ epos->offset = udf_file_entry_alloc_offset(inode);
+- ptr = iinfo->i_ext.i_data + epos->offset -
++ ptr = iinfo->i_data + epos->offset -
+ udf_file_entry_alloc_offset(inode) +
+ iinfo->i_lenEAttr;
+ alen = udf_file_entry_alloc_offset(inode) +
+diff --git a/fs/udf/misc.c b/fs/udf/misc.c
+index 853bcff51043f..1614d308d0f06 100644
+--- a/fs/udf/misc.c
++++ b/fs/udf/misc.c
+@@ -52,9 +52,9 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
+ uint16_t crclen;
+ struct udf_inode_info *iinfo = UDF_I(inode);
+
+- ea = iinfo->i_ext.i_data;
++ ea = iinfo->i_data;
+ if (iinfo->i_lenEAttr) {
+- ad = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
++ ad = iinfo->i_data + iinfo->i_lenEAttr;
+ } else {
+ ad = ea;
+ size += sizeof(struct extendedAttrHeaderDesc);
+@@ -153,7 +153,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
+ uint32_t offset;
+ struct udf_inode_info *iinfo = UDF_I(inode);
+
+- ea = iinfo->i_ext.i_data;
++ ea = iinfo->i_data;
+
+ if (iinfo->i_lenEAttr) {
+ struct extendedAttrHeaderDesc *eahd;
+diff --git a/fs/udf/namei.c b/fs/udf/namei.c
+index ef251622da137..05dd1f45ba90b 100644
+--- a/fs/udf/namei.c
++++ b/fs/udf/namei.c
+@@ -478,8 +478,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
+ if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+ block = dinfo->i_location.logicalBlockNum;
+ fi = (struct fileIdentDesc *)
+- (dinfo->i_ext.i_data +
+- fibh->soffset -
++ (dinfo->i_data + fibh->soffset -
+ udf_ext0_offset(dir) +
+ dinfo->i_lenEAttr);
+ } else {
+@@ -962,7 +961,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
+ mark_buffer_dirty_inode(epos.bh, inode);
+ ea = epos.bh->b_data + udf_ext0_offset(inode);
+ } else
+- ea = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
++ ea = iinfo->i_data + iinfo->i_lenEAttr;
+
+ eoffset = sb->s_blocksize - udf_ext0_offset(inode);
+ pc = (struct pathComponent *)ea;
+@@ -1142,7 +1141,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
+ retval = -EIO;
+ if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+ dir_fi = udf_get_fileident(
+- old_iinfo->i_ext.i_data -
++ old_iinfo->i_data -
+ (old_iinfo->i_efe ?
+ sizeof(struct extendedFileEntry) :
+ sizeof(struct fileEntry)),
+diff --git a/fs/udf/partition.c b/fs/udf/partition.c
+index 090baff83990a..4cbf40575965e 100644
+--- a/fs/udf/partition.c
++++ b/fs/udf/partition.c
+@@ -65,7 +65,7 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
+ }
+
+ if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+- loc = le32_to_cpu(((__le32 *)(iinfo->i_ext.i_data +
++ loc = le32_to_cpu(((__le32 *)(iinfo->i_data +
+ vdata->s_start_offset))[block]);
+ goto translate;
+ }
+diff --git a/fs/udf/super.c b/fs/udf/super.c
+index ec082b27e9fba..cdaef406f3899 100644
+--- a/fs/udf/super.c
++++ b/fs/udf/super.c
+@@ -174,7 +174,7 @@ static void init_once(void *foo)
+ {
+ struct udf_inode_info *ei = (struct udf_inode_info *)foo;
+
+- ei->i_ext.i_data = NULL;
++ ei->i_data = NULL;
+ inode_init_once(&ei->vfs_inode);
+ }
+
+@@ -1207,7 +1207,7 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
+ vat20 = (struct virtualAllocationTable20 *)bh->b_data;
+ } else {
+ vat20 = (struct virtualAllocationTable20 *)
+- vati->i_ext.i_data;
++ vati->i_data;
+ }
+
+ map->s_type_specific.s_virtual.s_start_offset =
+diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
+index 6023c97c6da2f..aef3e4d9014d2 100644
+--- a/fs/udf/symlink.c
++++ b/fs/udf/symlink.c
+@@ -122,7 +122,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
+
+ down_read(&iinfo->i_data_sem);
+ if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+- symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
++ symlink = iinfo->i_data + iinfo->i_lenEAttr;
+ } else {
+ bh = sb_bread(inode->i_sb, pos);
+
+diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
+index 00d773d1b7cf0..2a4731314d51f 100644
+--- a/fs/udf/udf_i.h
++++ b/fs/udf/udf_i.h
+@@ -44,11 +44,7 @@ struct udf_inode_info {
+ unsigned i_strat4096 : 1;
+ unsigned i_streamdir : 1;
+ unsigned reserved : 25;
+- union {
+- struct short_ad *i_sad;
+- struct long_ad *i_lad;
+- __u8 *i_data;
+- } i_ext;
++ __u8 *i_data;
+ struct kernel_lb_addr i_locStreamdir;
+ __u64 i_lenStreams;
+ struct rw_semaphore i_data_sem;
+--
+2.39.2
+
--- /dev/null
+From 5f0936918321976a2b0d659c1b1fded12391b931 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Jan 2021 12:49:13 +0300
+Subject: usb: dwc3: pci: ID for Tiger Lake CPU
+
+From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+
+[ Upstream commit 73203bde3a95a48f27b2454dc6b955280c641afe ]
+
+Tiger Lake SOC (the versions of it that have integrated USB4
+controller) may have two DWC3 controllers. One is part of
+the PCH (Platform Controller Hub, i.e. the chipset) as
+usual, and the other is inside the actual CPU block.
+
+On all Intel platforms that have the two separate DWC3
+controllers, the one inside the CPU handles USB3 and only
+USB3 traffic, while the PCH version handles USB2 and USB2
+alone. The reason for splitting the two busses like this is
+to allow easy USB3 tunneling over USB4 connections. As USB2
+is not tunneled over USB4, it has dedicated USB controllers
+(both xHCI and DWC3).
+
+Acked-by: Felipe Balbi <balbi@kernel.org>
+Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Link: https://lore.kernel.org/r/20210115094914.88401-4-heikki.krogerus@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: 8e5248c3a877 ("usb: dwc3: pci: add support for the Intel Meteor Lake-M")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/dwc3/dwc3-pci.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
+index 955bf820f4102..30bfbeb331ad4 100644
+--- a/drivers/usb/dwc3/dwc3-pci.c
++++ b/drivers/usb/dwc3/dwc3-pci.c
+@@ -41,6 +41,7 @@
+ #define PCI_DEVICE_ID_INTEL_TGPH 0x43ee
+ #define PCI_DEVICE_ID_INTEL_JSP 0x4dee
+ #define PCI_DEVICE_ID_INTEL_ADLS 0x7ae1
++#define PCI_DEVICE_ID_INTEL_TGL 0x9a15
+
+ #define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
+ #define PCI_INTEL_BXT_FUNC_PMU_PWR 4
+@@ -372,6 +373,9 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
+ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLS),
+ (kernel_ulong_t) &dwc3_pci_intel_properties, },
+
++ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGL),
++ (kernel_ulong_t) &dwc3_pci_intel_swnode, },
++
+ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NL_USB),
+ (kernel_ulong_t) &dwc3_pci_amd_properties, },
+ { } /* Terminating Entry */
+--
+2.39.2
+