]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Aug 2024 12:09:37 +0000 (14:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Aug 2024 12:09:37 +0000 (14:09 +0200)
added patches:
power-supply-axp288_charger-fix-constant_charge_voltage-writes.patch
power-supply-axp288_charger-round-constant_charge_voltage-writes-down.patch
tracing-fix-overflow-in-get_free_elt.patch
x86-mtrr-check-if-fixed-mtrrs-exist-before-saving-them.patch

queue-4.19/power-supply-axp288_charger-fix-constant_charge_voltage-writes.patch [new file with mode: 0644]
queue-4.19/power-supply-axp288_charger-round-constant_charge_voltage-writes-down.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/tracing-fix-overflow-in-get_free_elt.patch [new file with mode: 0644]
queue-4.19/x86-mtrr-check-if-fixed-mtrrs-exist-before-saving-them.patch [new file with mode: 0644]

diff --git a/queue-4.19/power-supply-axp288_charger-fix-constant_charge_voltage-writes.patch b/queue-4.19/power-supply-axp288_charger-fix-constant_charge_voltage-writes.patch
new file mode 100644 (file)
index 0000000..031ca7c
--- /dev/null
@@ -0,0 +1,39 @@
+From b34ce4a59cfe9cd0d6f870e6408e8ec88a964585 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Wed, 17 Jul 2024 22:03:32 +0200
+Subject: power: supply: axp288_charger: Fix constant_charge_voltage writes
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit b34ce4a59cfe9cd0d6f870e6408e8ec88a964585 upstream.
+
+info->max_cv is in millivolts, divide the microvolt value being written
+to constant_charge_voltage by 1000 *before* clamping it to info->max_cv.
+
+Before this fix the code always tried to set constant_charge_voltage
+to max_cv / 1000 = 4 millivolt, which ends up in setting it to 4.1V
+which is the lowest supported value.
+
+Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
+Cc: stable@vger.kernel.org
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20240717200333.56669-1-hdegoede@redhat.com
+Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/power/supply/axp288_charger.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/power/supply/axp288_charger.c
++++ b/drivers/power/supply/axp288_charger.c
+@@ -378,8 +378,8 @@ static int axp288_charger_usb_set_proper
+                       dev_warn(&info->pdev->dev, "set charge current failed\n");
+               break;
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
+-              scaled_val = min(val->intval, info->max_cv);
+-              scaled_val = DIV_ROUND_CLOSEST(scaled_val, 1000);
++              scaled_val = DIV_ROUND_CLOSEST(val->intval, 1000);
++              scaled_val = min(scaled_val, info->max_cv);
+               ret = axp288_charger_set_cv(info, scaled_val);
+               if (ret < 0)
+                       dev_warn(&info->pdev->dev, "set charge voltage failed\n");
diff --git a/queue-4.19/power-supply-axp288_charger-round-constant_charge_voltage-writes-down.patch b/queue-4.19/power-supply-axp288_charger-round-constant_charge_voltage-writes-down.patch
new file mode 100644 (file)
index 0000000..658be1f
--- /dev/null
@@ -0,0 +1,56 @@
+From 81af7f2342d162e24ac820c10e68684d9f927663 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Wed, 17 Jul 2024 22:03:33 +0200
+Subject: power: supply: axp288_charger: Round constant_charge_voltage writes down
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+commit 81af7f2342d162e24ac820c10e68684d9f927663 upstream.
+
+Round constant_charge_voltage writes down to the first supported lower
+value, rather then rounding them up to the first supported higher value.
+
+This fixes e.g. writing 4250000 resulting in a value of 4350000 which
+might be dangerous, instead writing 4250000 will now result in a safe
+4200000 value.
+
+Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
+Cc: stable@vger.kernel.org
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20240717200333.56669-2-hdegoede@redhat.com
+Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/power/supply/axp288_charger.c |   18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/drivers/power/supply/axp288_charger.c
++++ b/drivers/power/supply/axp288_charger.c
+@@ -175,18 +175,18 @@ static inline int axp288_charger_set_cv(
+       u8 reg_val;
+       int ret;
+-      if (cv <= CV_4100MV) {
+-              reg_val = CHRG_CCCV_CV_4100MV;
+-              cv = CV_4100MV;
+-      } else if (cv <= CV_4150MV) {
+-              reg_val = CHRG_CCCV_CV_4150MV;
+-              cv = CV_4150MV;
+-      } else if (cv <= CV_4200MV) {
++      if (cv >= CV_4350MV) {
++              reg_val = CHRG_CCCV_CV_4350MV;
++              cv = CV_4350MV;
++      } else if (cv >= CV_4200MV) {
+               reg_val = CHRG_CCCV_CV_4200MV;
+               cv = CV_4200MV;
++      } else if (cv >= CV_4150MV) {
++              reg_val = CHRG_CCCV_CV_4150MV;
++              cv = CV_4150MV;
+       } else {
+-              reg_val = CHRG_CCCV_CV_4350MV;
+-              cv = CV_4350MV;
++              reg_val = CHRG_CCCV_CV_4100MV;
++              cv = CV_4100MV;
+       }
+       reg_val = reg_val << CHRG_CCCV_CV_BIT_POS;
index ea5f25bbf1d2d0973871e45eb9c9027cb81c8e87..13bfb535b2a918952677102883b81129ce503dfc 100644 (file)
@@ -179,3 +179,7 @@ ntp-clamp-maxerror-and-esterror-to-operating-range.patch
 driver-core-fix-uevent_show-vs-driver-detach-race.patch
 ntp-safeguard-against-time_constant-overflow.patch
 serial-core-check-uartclk-for-zero-to-avoid-divide-by-zero.patch
+power-supply-axp288_charger-fix-constant_charge_voltage-writes.patch
+power-supply-axp288_charger-round-constant_charge_voltage-writes-down.patch
+tracing-fix-overflow-in-get_free_elt.patch
+x86-mtrr-check-if-fixed-mtrrs-exist-before-saving-them.patch
diff --git a/queue-4.19/tracing-fix-overflow-in-get_free_elt.patch b/queue-4.19/tracing-fix-overflow-in-get_free_elt.patch
new file mode 100644 (file)
index 0000000..f2adf30
--- /dev/null
@@ -0,0 +1,65 @@
+From bcf86c01ca4676316557dd482c8416ece8c2e143 Mon Sep 17 00:00:00 2001
+From: Tze-nan Wu <Tze-nan.Wu@mediatek.com>
+Date: Mon, 5 Aug 2024 13:59:22 +0800
+Subject: tracing: Fix overflow in get_free_elt()
+
+From: Tze-nan Wu <Tze-nan.Wu@mediatek.com>
+
+commit bcf86c01ca4676316557dd482c8416ece8c2e143 upstream.
+
+"tracing_map->next_elt" in get_free_elt() is at risk of overflowing.
+
+Once it overflows, new elements can still be inserted into the tracing_map
+even though the maximum number of elements (`max_elts`) has been reached.
+Continuing to insert elements after the overflow could result in the
+tracing_map containing "tracing_map->max_size" elements, leaving no empty
+entries.
+If any attempt is made to insert an element into a full tracing_map using
+`__tracing_map_insert()`, it will cause an infinite loop with preemption
+disabled, leading to a CPU hang problem.
+
+Fix this by preventing any further increments to "tracing_map->next_elt"
+once it reaches "tracing_map->max_elt".
+
+Cc: stable@vger.kernel.org
+Cc: Masami Hiramatsu <mhiramat@kernel.org>
+Fixes: 08d43a5fa063e ("tracing: Add lock-free tracing_map")
+Co-developed-by: Cheng-Jui Wang <cheng-jui.wang@mediatek.com>
+Link: https://lore.kernel.org/20240805055922.6277-1-Tze-nan.Wu@mediatek.com
+Signed-off-by: Cheng-Jui Wang <cheng-jui.wang@mediatek.com>
+Signed-off-by: Tze-nan Wu <Tze-nan.Wu@mediatek.com>
+Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/trace/tracing_map.c |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/kernel/trace/tracing_map.c
++++ b/kernel/trace/tracing_map.c
+@@ -454,7 +454,7 @@ static struct tracing_map_elt *get_free_
+       struct tracing_map_elt *elt = NULL;
+       int idx;
+-      idx = atomic_inc_return(&map->next_elt);
++      idx = atomic_fetch_add_unless(&map->next_elt, 1, map->max_elts);
+       if (idx < map->max_elts) {
+               elt = *(TRACING_MAP_ELT(map->elts, idx));
+               if (map->ops && map->ops->elt_init)
+@@ -699,7 +699,7 @@ void tracing_map_clear(struct tracing_ma
+ {
+       unsigned int i;
+-      atomic_set(&map->next_elt, -1);
++      atomic_set(&map->next_elt, 0);
+       atomic64_set(&map->hits, 0);
+       atomic64_set(&map->drops, 0);
+@@ -783,7 +783,7 @@ struct tracing_map *tracing_map_create(u
+       map->map_bits = map_bits;
+       map->max_elts = (1 << map_bits);
+-      atomic_set(&map->next_elt, -1);
++      atomic_set(&map->next_elt, 0);
+       map->map_size = (1 << (map_bits + 1));
+       map->ops = ops;
diff --git a/queue-4.19/x86-mtrr-check-if-fixed-mtrrs-exist-before-saving-them.patch b/queue-4.19/x86-mtrr-check-if-fixed-mtrrs-exist-before-saving-them.patch
new file mode 100644 (file)
index 0000000..a490540
--- /dev/null
@@ -0,0 +1,44 @@
+From 919f18f961c03d6694aa726c514184f2311a4614 Mon Sep 17 00:00:00 2001
+From: Andi Kleen <ak@linux.intel.com>
+Date: Wed, 7 Aug 2024 17:02:44 -0700
+Subject: x86/mtrr: Check if fixed MTRRs exist before saving them
+
+From: Andi Kleen <ak@linux.intel.com>
+
+commit 919f18f961c03d6694aa726c514184f2311a4614 upstream.
+
+MTRRs have an obsolete fixed variant for fine grained caching control
+of the 640K-1MB region that uses separate MSRs. This fixed variant has
+a separate capability bit in the MTRR capability MSR.
+
+So far all x86 CPUs which support MTRR have this separate bit set, so it
+went unnoticed that mtrr_save_state() does not check the capability bit
+before accessing the fixed MTRR MSRs.
+
+Though on a CPU that does not support the fixed MTRR capability this
+results in a #GP.  The #GP itself is harmless because the RDMSR fault is
+handled gracefully, but results in a WARN_ON().
+
+Add the missing capability check to prevent this.
+
+Fixes: 2b1f6278d77c ("[PATCH] x86: Save the MTRRs of the BSP before booting an AP")
+Signed-off-by: Andi Kleen <ak@linux.intel.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/all/20240808000244.946864-1-ak@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/kernel/cpu/mtrr/mtrr.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/x86/kernel/cpu/mtrr/mtrr.c
++++ b/arch/x86/kernel/cpu/mtrr/mtrr.c
+@@ -819,7 +819,7 @@ void mtrr_save_state(void)
+ {
+       int first_cpu;
+-      if (!mtrr_enabled())
++      if (!mtrr_enabled() || !mtrr_state.have_fixed)
+               return;
+       first_cpu = cpumask_first(cpu_online_mask);