From 05774078857efeee341aa189bf315ed3a894af5e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 12 Dec 2024 12:07:33 +0100 Subject: [PATCH] 6.6-stable patches added patches: btrfs-add-cancellation-points-to-trim-loops.patch iio-invensense-fix-multiple-odr-switch-when-fifo-is-off.patch --- ...dd-cancellation-points-to-trim-loops.patch | 98 +++++++++++++++++++ ...multiple-odr-switch-when-fifo-is-off.patch | 92 +++++++++++++++++ queue-6.6/series | 4 +- 3 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 queue-6.6/btrfs-add-cancellation-points-to-trim-loops.patch create mode 100644 queue-6.6/iio-invensense-fix-multiple-odr-switch-when-fifo-is-off.patch diff --git a/queue-6.6/btrfs-add-cancellation-points-to-trim-loops.patch b/queue-6.6/btrfs-add-cancellation-points-to-trim-loops.patch new file mode 100644 index 00000000000..b3c2aa569f6 --- /dev/null +++ b/queue-6.6/btrfs-add-cancellation-points-to-trim-loops.patch @@ -0,0 +1,98 @@ +From 69313850dce33ce8c24b38576a279421f4c60996 Mon Sep 17 00:00:00 2001 +From: Luca Stefani +Date: Tue, 17 Sep 2024 22:33:05 +0200 +Subject: btrfs: add cancellation points to trim loops + +From: Luca Stefani + +commit 69313850dce33ce8c24b38576a279421f4c60996 upstream. + +There are reports that system cannot suspend due to running trim because +the task responsible for trimming the device isn't able to finish in +time, especially since we have a free extent discarding phase, which can +trim a lot of unallocated space. There are no limits on the trim size +(unlike the block group part). + +Since trime isn't a critical call it can be interrupted at any time, +in such cases we stop the trim, report the amount of discarded bytes and +return an error. + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=219180 +Link: https://bugzilla.suse.com/show_bug.cgi?id=1229737 +CC: stable@vger.kernel.org # 5.15+ +Signed-off-by: Luca Stefani +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/extent-tree.c | 7 ++++++- + fs/btrfs/free-space-cache.c | 4 ++-- + fs/btrfs/free-space-cache.h | 7 +++++++ + 3 files changed, 15 insertions(+), 3 deletions(-) + +--- a/fs/btrfs/extent-tree.c ++++ b/fs/btrfs/extent-tree.c +@@ -1319,6 +1319,11 @@ static int btrfs_issue_discard(struct bl + start += bytes_to_discard; + bytes_left -= bytes_to_discard; + *discarded_bytes += bytes_to_discard; ++ ++ if (btrfs_trim_interrupted()) { ++ ret = -ERESTARTSYS; ++ break; ++ } + } + + return ret; +@@ -6097,7 +6102,7 @@ static int btrfs_trim_free_extents(struc + start += len; + *trimmed += bytes; + +- if (fatal_signal_pending(current)) { ++ if (btrfs_trim_interrupted()) { + ret = -ERESTARTSYS; + break; + } +--- a/fs/btrfs/free-space-cache.c ++++ b/fs/btrfs/free-space-cache.c +@@ -3808,7 +3808,7 @@ next: + if (async && *total_trimmed) + break; + +- if (fatal_signal_pending(current)) { ++ if (btrfs_trim_interrupted()) { + ret = -ERESTARTSYS; + break; + } +@@ -3999,7 +3999,7 @@ next: + } + block_group->discard_cursor = start; + +- if (fatal_signal_pending(current)) { ++ if (btrfs_trim_interrupted()) { + if (start != offset) + reset_trimming_bitmap(ctl, offset); + ret = -ERESTARTSYS; +--- a/fs/btrfs/free-space-cache.h ++++ b/fs/btrfs/free-space-cache.h +@@ -6,6 +6,8 @@ + #ifndef BTRFS_FREE_SPACE_CACHE_H + #define BTRFS_FREE_SPACE_CACHE_H + ++#include ++ + /* + * This is the trim state of an extent or bitmap. + * +@@ -43,6 +45,11 @@ static inline bool btrfs_free_space_trim + return (info->trim_state == BTRFS_TRIM_STATE_TRIMMING); + } + ++static inline bool btrfs_trim_interrupted(void) ++{ ++ return fatal_signal_pending(current) || freezing(current); ++} ++ + /* + * Deltas are an effective way to populate global statistics. Give macro names + * to make it clear what we're doing. An example is discard_extents in diff --git a/queue-6.6/iio-invensense-fix-multiple-odr-switch-when-fifo-is-off.patch b/queue-6.6/iio-invensense-fix-multiple-odr-switch-when-fifo-is-off.patch new file mode 100644 index 00000000000..cf976cb0200 --- /dev/null +++ b/queue-6.6/iio-invensense-fix-multiple-odr-switch-when-fifo-is-off.patch @@ -0,0 +1,92 @@ +From ef5f5e7b6f73f79538892a8be3a3bee2342acc9f Mon Sep 17 00:00:00 2001 +From: Jean-Baptiste Maneyrol +Date: Mon, 21 Oct 2024 10:38:42 +0200 +Subject: iio: invensense: fix multiple odr switch when FIFO is off + +From: Jean-Baptiste Maneyrol + +commit ef5f5e7b6f73f79538892a8be3a3bee2342acc9f upstream. + +When multiple ODR switch happens during FIFO off, the change could +not be taken into account if you get back to previous FIFO on value. +For example, if you run sensor buffer at 50Hz, stop, change to +200Hz, then back to 50Hz and restart buffer, data will be timestamped +at 200Hz. This due to testing against mult and not new_mult. + +To prevent this, let's just run apply_odr automatically when FIFO is +off. It will also simplify driver code. + +Update inv_mpu6050 and inv_icm42600 to delete now useless apply_odr. + +Fixes: 95444b9eeb8c ("iio: invensense: fix odr switching to same value") +Cc: stable@vger.kernel.org +Signed-off-by: Jean-Baptiste Maneyrol +Link: https://patch.msgid.link/20241021-invn-inv-sensors-timestamp-fix-switch-fifo-off-v2-1-39ffd43edcc4@tdk.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 4 ++++ + drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 2 -- + drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 2 -- + drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 1 - + 4 files changed, 4 insertions(+), 5 deletions(-) + +--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c ++++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +@@ -70,6 +70,10 @@ int inv_sensors_timestamp_update_odr(str + if (mult != ts->mult) + ts->new_mult = mult; + ++ /* When FIFO is off, directly apply the new ODR */ ++ if (!fifo) ++ inv_sensors_timestamp_apply_odr(ts, 0, 0, 0); ++ + return 0; + } + EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_update_odr, IIO_INV_SENSORS_TIMESTAMP); +--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c ++++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +@@ -99,7 +99,6 @@ static int inv_icm42600_accel_update_sca + const unsigned long *scan_mask) + { + struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); +- struct inv_sensors_timestamp *ts = iio_priv(indio_dev); + struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT; + unsigned int fifo_en = 0; + unsigned int sleep_temp = 0; +@@ -127,7 +126,6 @@ static int inv_icm42600_accel_update_sca + } + + /* update data FIFO write */ +- inv_sensors_timestamp_apply_odr(ts, 0, 0, 0); + ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en); + + out_unlock: +--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c ++++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +@@ -99,7 +99,6 @@ static int inv_icm42600_gyro_update_scan + const unsigned long *scan_mask) + { + struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); +- struct inv_sensors_timestamp *ts = iio_priv(indio_dev); + struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT; + unsigned int fifo_en = 0; + unsigned int sleep_gyro = 0; +@@ -127,7 +126,6 @@ static int inv_icm42600_gyro_update_scan + } + + /* update data FIFO write */ +- inv_sensors_timestamp_apply_odr(ts, 0, 0, 0); + ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en); + + out_unlock: +--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c ++++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +@@ -111,7 +111,6 @@ int inv_mpu6050_prepare_fifo(struct inv_ + if (enable) { + /* reset timestamping */ + inv_sensors_timestamp_reset(&st->timestamp); +- inv_sensors_timestamp_apply_odr(&st->timestamp, 0, 0, 0); + /* reset FIFO */ + d = st->chip_config.user_ctrl | INV_MPU6050_BIT_FIFO_RST; + ret = regmap_write(st->map, st->reg->user_ctrl, d); diff --git a/queue-6.6/series b/queue-6.6/series index 6f79dc97715..276ae67ad3e 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -201,7 +201,6 @@ media-cx231xx-add-support-for-dexatek-usb-video-grab.patch mmc-core-add-sd-card-quirk-for-broken-poweroff-notif.patch mmc-sdhci-esdhc-imx-enable-quirks-sdhci_quirk_no_led.patch soc-imx8m-probe-the-soc-driver-as-platform-driver.patch -hid-bpf-fix-nkro-on-mistel-md770.patch regmap-maple-provide-lockdep-sub-class-for-maple-tre.patch selftests-resctrl-protect-against-array-overflow-whe.patch hid-magicmouse-apple-magic-trackpad-2-usb-c-driver-s.patch @@ -270,7 +269,6 @@ tracing-use-atomic64_inc_return-in-trace_clock_count.patch tools-rtla-fix-collision-with-glibc-sched_attr-sched.patch rtla-timerlat-make-timerlat_top_cpu-_count-unsigned-.patch scsi-hisi_sas-add-cond_resched-for-no-forced-preempt.patch -rtla-utils-add-idle-state-disabling-via-libcpupower.patch pinmux-use-sequential-access-to-access-desc-pinmux-d.patch scsi-ufs-core-make-dma-mask-configuration-more-flexi.patch bpf-put-bpf_link-s-program-when-link-is-safe-to-be-d.patch @@ -345,3 +343,5 @@ jffs2-prevent-rtime-decompress-memory-corruption.patch jffs2-fix-rtime-decompressor.patch mm-damon-vaddr-fix-issue-in-damon_va_evenly_split_region.patch xhci-dbc-fix-stall-transfer-event-handling.patch +iio-invensense-fix-multiple-odr-switch-when-fifo-is-off.patch +btrfs-add-cancellation-points-to-trim-loops.patch -- 2.47.3