]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.10
authorSasha Levin <sashal@kernel.org>
Thu, 30 May 2024 18:48:14 +0000 (14:48 -0400)
committerSasha Levin <sashal@kernel.org>
Thu, 30 May 2024 18:48:14 +0000 (14:48 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
59 files changed:
queue-5.10/dmaengine-idma64-add-check-for-dma_set_max_seg_size.patch [new file with mode: 0644]
queue-5.10/docs-driver-api-fpga-avoid-using-utf-8-chars.patch [new file with mode: 0644]
queue-5.10/extcon-max8997-select-irq_domain-instead-of-dependin.patch [new file with mode: 0644]
queue-5.10/f2fs-add-compress_mode-mount-option.patch [new file with mode: 0644]
queue-5.10/f2fs-add-cp_error-check-in-f2fs_write_compressed_pag.patch [new file with mode: 0644]
queue-5.10/f2fs-compress-clean-up-parameter-of-__f2fs_cluster_b.patch [new file with mode: 0644]
queue-5.10/f2fs-compress-don-t-allow-unaligned-truncation-on-re.patch [new file with mode: 0644]
queue-5.10/f2fs-compress-fix-to-cover-reserve-release-_compress.patch [new file with mode: 0644]
queue-5.10/f2fs-compress-fix-to-relocate-check-condition-in-f2f.patch [new file with mode: 0644]
queue-5.10/f2fs-compress-remove-unneeded-preallocation.patch [new file with mode: 0644]
queue-5.10/f2fs-compress-support-chksum.patch [new file with mode: 0644]
queue-5.10/f2fs-do-not-allow-partial-truncation-on-pinned-file.patch [new file with mode: 0644]
queue-5.10/f2fs-fix-to-check-pinfile-flag-in-f2fs_move_file_ran.patch [new file with mode: 0644]
queue-5.10/f2fs-fix-to-force-keeping-write-barrier-for-strict-f.patch [new file with mode: 0644]
queue-5.10/f2fs-fix-to-release-node-block-count-in-error-path-o.patch [new file with mode: 0644]
queue-5.10/f2fs-fix-to-relocate-check-condition-in-f2fs_falloca.patch [new file with mode: 0644]
queue-5.10/f2fs-fix-to-wait-on-page-writeback-in-__clone_blkadd.patch [new file with mode: 0644]
queue-5.10/f2fs-fix-typos-in-comments.patch [new file with mode: 0644]
queue-5.10/f2fs-introduce-fi_compress_released-instead-of-using.patch [new file with mode: 0644]
queue-5.10/firmware-dmi-id-add-a-release-callback-function.patch [new file with mode: 0644]
queue-5.10/fpga-region-add-owner-module-and-take-its-refcount.patch [new file with mode: 0644]
queue-5.10/fpga-region-change-fpga-indirect-article-to-an.patch [new file with mode: 0644]
queue-5.10/fpga-region-rename-dev-to-parent-for-parent-device.patch [new file with mode: 0644]
queue-5.10/fpga-region-use-standard-dev_release-for-class-drive.patch [new file with mode: 0644]
queue-5.10/greybus-arche-ctrl-move-device-table-to-its-right-lo.patch [new file with mode: 0644]
queue-5.10/greybus-lights-check-return-of-get_channel_from_mode.patch [new file with mode: 0644]
queue-5.10/iio-pressure-dps310-support-negative-temperature-val.patch [new file with mode: 0644]
queue-5.10/libsubcmd-fix-parse-options-memory-leak.patch [new file with mode: 0644]
queue-5.10/microblaze-remove-early-printk-call-from-cpuinfo-sta.patch [new file with mode: 0644]
queue-5.10/microblaze-remove-gcc-flag-for-non-existing-early_pr.patch [new file with mode: 0644]
queue-5.10/ovl-remove-upper-umask-handling-from-ovl_create_uppe.patch [new file with mode: 0644]
queue-5.10/pci-edr-align-edr_port_dpc_enable_dsm-with-pci-firmw.patch [new file with mode: 0644]
queue-5.10/pci-edr-align-edr_port_locate_dsm-with-pci-firmware-.patch [new file with mode: 0644]
queue-5.10/perf-annotate-add-demangle-and-demangle-kernel.patch [new file with mode: 0644]
queue-5.10/perf-annotate-get-rid-of-duplicate-group-option-item.patch [new file with mode: 0644]
queue-5.10/perf-bench-internals-inject-build-id-fix-trap-divide.patch [new file with mode: 0644]
queue-5.10/perf-evlist-use-the-right-prefix-for-struct-evlist-s.patch [new file with mode: 0644]
queue-5.10/perf-intel-pt-fix-unassigned-instruction-op-discover.patch [new file with mode: 0644]
queue-5.10/perf-probe-add-missing-libgen.h-header-needed-for-us.patch [new file with mode: 0644]
queue-5.10/perf-record-delete-session-after-stopping-sideband-t.patch [new file with mode: 0644]
queue-5.10/perf-report-avoid-segv-in-report__setup_sample_type.patch [new file with mode: 0644]
queue-5.10/perf-stat-don-t-display-metric-header-for-non-leader.patch [new file with mode: 0644]
queue-5.10/perf-top-fix-tui-exit-screen-refresh-race-condition.patch [new file with mode: 0644]
queue-5.10/perf-ui-browser-avoid-segv-on-title.patch [new file with mode: 0644]
queue-5.10/perf-ui-browser-don-t-save-pointer-to-stack-memory.patch [new file with mode: 0644]
queue-5.10/perf-ui-update-use-of-pthread-mutex.patch [new file with mode: 0644]
queue-5.10/ppdev-add-an-error-check-in-register_device.patch [new file with mode: 0644]
queue-5.10/ppdev-remove-usage-of-the-deprecated-ida_simple_xx-a.patch [new file with mode: 0644]
queue-5.10/s390-ipl-fix-incorrect-initialization-of-len-fields-.patch [new file with mode: 0644]
queue-5.10/s390-ipl-fix-incorrect-initialization-of-nvme-dump-b.patch [new file with mode: 0644]
queue-5.10/serial-max3100-fix-bitwise-types.patch [new file with mode: 0644]
queue-5.10/serial-max3100-lock-port-lock-when-calling-uart_hand.patch [new file with mode: 0644]
queue-5.10/serial-max3100-update-uart_driver_registered-on-driv.patch [new file with mode: 0644]
queue-5.10/serial-sc16is7xx-add-proper-sched.h-include-for-sche.patch [new file with mode: 0644]
queue-5.10/serial-sh-sci-protect-invalidating-rxdma-on-shutdown.patch [new file with mode: 0644]
queue-5.10/series
queue-5.10/soundwire-cadence-fix-invalid-pdi-offset.patch [new file with mode: 0644]
queue-5.10/stm-class-fix-a-double-free-in-stm_register_device.patch [new file with mode: 0644]
queue-5.10/usb-gadget-u_audio-clear-uac-pointer-when-freed.patch [new file with mode: 0644]

diff --git a/queue-5.10/dmaengine-idma64-add-check-for-dma_set_max_seg_size.patch b/queue-5.10/dmaengine-idma64-add-check-for-dma_set_max_seg_size.patch
new file mode 100644 (file)
index 0000000..7554889
--- /dev/null
@@ -0,0 +1,40 @@
+From 0b5bd41295c69adb51894c9768c9e9787d4fd1af Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Apr 2024 02:49:32 +0000
+Subject: dmaengine: idma64: Add check for dma_set_max_seg_size
+
+From: Chen Ni <nichen@iscas.ac.cn>
+
+[ Upstream commit 2b1c1cf08a0addb6df42f16b37133dc7a351de29 ]
+
+As the possible failure of the dma_set_max_seg_size(), it should be
+better to check the return value of the dma_set_max_seg_size().
+
+Fixes: e3fdb1894cfa ("dmaengine: idma64: set maximum allowed segment size for DMA")
+Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
+Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20240403024932.3342606-1-nichen@iscas.ac.cn
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/idma64.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/dma/idma64.c b/drivers/dma/idma64.c
+index db506e1f7ef4e..0f065ba844c00 100644
+--- a/drivers/dma/idma64.c
++++ b/drivers/dma/idma64.c
+@@ -594,7 +594,9 @@ static int idma64_probe(struct idma64_chip *chip)
+       idma64->dma.dev = chip->sysdev;
+-      dma_set_max_seg_size(idma64->dma.dev, IDMA64C_CTLH_BLOCK_TS_MASK);
++      ret = dma_set_max_seg_size(idma64->dma.dev, IDMA64C_CTLH_BLOCK_TS_MASK);
++      if (ret)
++              return ret;
+       ret = dma_async_device_register(&idma64->dma);
+       if (ret)
+-- 
+2.43.0
+
diff --git a/queue-5.10/docs-driver-api-fpga-avoid-using-utf-8-chars.patch b/queue-5.10/docs-driver-api-fpga-avoid-using-utf-8-chars.patch
new file mode 100644 (file)
index 0000000..7b0d62b
--- /dev/null
@@ -0,0 +1,141 @@
+From fc24630edf1f5519c3b2fef5987d4439b439eff2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 10 May 2021 12:26:25 +0200
+Subject: docs: driver-api: fpga: avoid using UTF-8 chars
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+
+[ Upstream commit 758f74674bcb82e1ed1a0b5a56980f295183b546 ]
+
+While UTF-8 characters can be used at the Linux documentation,
+the best is to use them only when ASCII doesn't offer a good replacement.
+So, replace the occurences of the following UTF-8 characters:
+
+       - U+2014 ('—'): EM DASH
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+Signed-off-by: Moritz Fischer <mdf@kernel.org>
+Stable-dep-of: b7c0e1ecee40 ("fpga: region: add owner module and take its refcount")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/driver-api/fpga/fpga-bridge.rst | 10 +++++-----
+ Documentation/driver-api/fpga/fpga-mgr.rst    | 12 +++++------
+ .../driver-api/fpga/fpga-programming.rst      |  8 ++++----
+ Documentation/driver-api/fpga/fpga-region.rst | 20 +++++++++----------
+ 4 files changed, 25 insertions(+), 25 deletions(-)
+
+diff --git a/Documentation/driver-api/fpga/fpga-bridge.rst b/Documentation/driver-api/fpga/fpga-bridge.rst
+index 198aadafd3e7d..8d650b4e2ce6d 100644
+--- a/Documentation/driver-api/fpga/fpga-bridge.rst
++++ b/Documentation/driver-api/fpga/fpga-bridge.rst
+@@ -4,11 +4,11 @@ FPGA Bridge
+ API to implement a new FPGA bridge
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-* struct fpga_bridge — The FPGA Bridge structure
+-* struct fpga_bridge_ops — Low level Bridge driver ops
+-* devm_fpga_bridge_create() — Allocate and init a bridge struct
+-* fpga_bridge_register() — Register a bridge
+-* fpga_bridge_unregister() — Unregister a bridge
++* struct fpga_bridge - The FPGA Bridge structure
++* struct fpga_bridge_ops - Low level Bridge driver ops
++* devm_fpga_bridge_create() - Allocate and init a bridge struct
++* fpga_bridge_register() - Register a bridge
++* fpga_bridge_unregister() - Unregister a bridge
+ .. kernel-doc:: include/linux/fpga/fpga-bridge.h
+    :functions: fpga_bridge
+diff --git a/Documentation/driver-api/fpga/fpga-mgr.rst b/Documentation/driver-api/fpga/fpga-mgr.rst
+index 917ee22db429d..4d926b452cb35 100644
+--- a/Documentation/driver-api/fpga/fpga-mgr.rst
++++ b/Documentation/driver-api/fpga/fpga-mgr.rst
+@@ -101,12 +101,12 @@ in state.
+ API for implementing a new FPGA Manager driver
+ ----------------------------------------------
+-* ``fpga_mgr_states`` —  Values for :c:expr:`fpga_manager->state`.
+-* struct fpga_manager —  the FPGA manager struct
+-* struct fpga_manager_ops —  Low level FPGA manager driver ops
+-* devm_fpga_mgr_create() —  Allocate and init a manager struct
+-* fpga_mgr_register() —  Register an FPGA manager
+-* fpga_mgr_unregister() —  Unregister an FPGA manager
++* ``fpga_mgr_states`` -  Values for :c:expr:`fpga_manager->state`.
++* struct fpga_manager -  the FPGA manager struct
++* struct fpga_manager_ops -  Low level FPGA manager driver ops
++* devm_fpga_mgr_create() -  Allocate and init a manager struct
++* fpga_mgr_register() -  Register an FPGA manager
++* fpga_mgr_unregister() -  Unregister an FPGA manager
+ .. kernel-doc:: include/linux/fpga/fpga-mgr.h
+    :functions: fpga_mgr_states
+diff --git a/Documentation/driver-api/fpga/fpga-programming.rst b/Documentation/driver-api/fpga/fpga-programming.rst
+index 002392dab04f7..fb4da4240e961 100644
+--- a/Documentation/driver-api/fpga/fpga-programming.rst
++++ b/Documentation/driver-api/fpga/fpga-programming.rst
+@@ -84,10 +84,10 @@ will generate that list.  Here's some sample code of what to do next::
+ API for programming an FPGA
+ ---------------------------
+-* fpga_region_program_fpga() —  Program an FPGA
+-* fpga_image_info() —  Specifies what FPGA image to program
+-* fpga_image_info_alloc() —  Allocate an FPGA image info struct
+-* fpga_image_info_free() —  Free an FPGA image info struct
++* fpga_region_program_fpga() -  Program an FPGA
++* fpga_image_info() -  Specifies what FPGA image to program
++* fpga_image_info_alloc() -  Allocate an FPGA image info struct
++* fpga_image_info_free() -  Free an FPGA image info struct
+ .. kernel-doc:: drivers/fpga/fpga-region.c
+    :functions: fpga_region_program_fpga
+diff --git a/Documentation/driver-api/fpga/fpga-region.rst b/Documentation/driver-api/fpga/fpga-region.rst
+index 363a8171ab0a5..2636a27c11b24 100644
+--- a/Documentation/driver-api/fpga/fpga-region.rst
++++ b/Documentation/driver-api/fpga/fpga-region.rst
+@@ -45,19 +45,19 @@ An example of usage can be seen in the probe function of [#f2]_.
+ API to add a new FPGA region
+ ----------------------------
+-* struct fpga_region — The FPGA region struct
+-* devm_fpga_region_create() — Allocate and init a region struct
+-* fpga_region_register() —  Register an FPGA region
+-* fpga_region_unregister() —  Unregister an FPGA region
++* struct fpga_region - The FPGA region struct
++* devm_fpga_region_create() - Allocate and init a region struct
++* fpga_region_register() -  Register an FPGA region
++* fpga_region_unregister() -  Unregister an FPGA region
+ The FPGA region's probe function will need to get a reference to the FPGA
+ Manager it will be using to do the programming.  This usually would happen
+ during the region's probe function.
+-* fpga_mgr_get() — Get a reference to an FPGA manager, raise ref count
+-* of_fpga_mgr_get() —  Get a reference to an FPGA manager, raise ref count,
++* fpga_mgr_get() - Get a reference to an FPGA manager, raise ref count
++* of_fpga_mgr_get() -  Get a reference to an FPGA manager, raise ref count,
+   given a device node.
+-* fpga_mgr_put() — Put an FPGA manager
++* fpga_mgr_put() - Put an FPGA manager
+ The FPGA region will need to specify which bridges to control while programming
+ the FPGA.  The region driver can build a list of bridges during probe time
+@@ -66,11 +66,11 @@ the list of bridges to program just before programming
+ (:c:expr:`fpga_region->get_bridges`).  The FPGA bridge framework supplies the
+ following APIs to handle building or tearing down that list.
+-* fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a
++* fpga_bridge_get_to_list() - Get a ref of an FPGA bridge, add it to a
+   list
+-* of_fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a
++* of_fpga_bridge_get_to_list() - Get a ref of an FPGA bridge, add it to a
+   list, given a device node
+-* fpga_bridges_put() — Given a list of bridges, put them
++* fpga_bridges_put() - Given a list of bridges, put them
+ .. kernel-doc:: include/linux/fpga/fpga-region.h
+    :functions: fpga_region
+-- 
+2.43.0
+
diff --git a/queue-5.10/extcon-max8997-select-irq_domain-instead-of-dependin.patch b/queue-5.10/extcon-max8997-select-irq_domain-instead-of-dependin.patch
new file mode 100644 (file)
index 0000000..a4091f0
--- /dev/null
@@ -0,0 +1,47 @@
+From 400a72aad8490f74e35ea741abb06a5d3ba752de Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 12 Feb 2024 22:00:28 -0800
+Subject: extcon: max8997: select IRQ_DOMAIN instead of depending on it
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+[ Upstream commit b1781d0a1458070d40134e4f3412ec9d70099bec ]
+
+IRQ_DOMAIN is a hidden (not user visible) symbol. Users cannot set
+it directly thru "make *config", so drivers should select it instead
+of depending on it if they need it.
+Relying on it being set for a dependency is risky.
+
+Consistently using "select" or "depends on" can also help reduce
+Kconfig circular dependency issues.
+
+Therefore, change EXTCON_MAX8997's use of "depends on" for
+IRQ_DOMAIN to "select".
+
+Link: https://lore.kernel.org/lkml/20240213060028.9744-1-rdunlap@infradead.org/
+Fixes: dca1a71e4108 ("extcon: Add support irq domain for MAX8997 muic")
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/extcon/Kconfig | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
+index aac507bff135c..09485803280ef 100644
+--- a/drivers/extcon/Kconfig
++++ b/drivers/extcon/Kconfig
+@@ -121,7 +121,8 @@ config EXTCON_MAX77843
+ config EXTCON_MAX8997
+       tristate "Maxim MAX8997 EXTCON Support"
+-      depends on MFD_MAX8997 && IRQ_DOMAIN
++      depends on MFD_MAX8997
++      select IRQ_DOMAIN
+       help
+         If you say yes here you get support for the MUIC device of
+         Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-add-compress_mode-mount-option.patch b/queue-5.10/f2fs-add-compress_mode-mount-option.patch
new file mode 100644 (file)
index 0000000..c3faa6a
--- /dev/null
@@ -0,0 +1,255 @@
+From 7b9e309ebcce8952526a97a525d3aa0f7ffacbad Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 1 Dec 2020 13:08:02 +0900
+Subject: f2fs: add compress_mode mount option
+
+From: Daeho Jeong <daehojeong@google.com>
+
+[ Upstream commit 602a16d58e9aab3c423bcf051033ea6c9e8a6d37 ]
+
+We will add a new "compress_mode" mount option to control file
+compression mode. This supports "fs" and "user". In "fs" mode (default),
+f2fs does automatic compression on the compression enabled files.
+In "user" mode, f2fs disables the automaic compression and gives the
+user discretion of choosing the target file and the timing. It means
+the user can do manual compression/decompression on the compression
+enabled files using ioctls.
+
+Signed-off-by: Daeho Jeong <daehojeong@google.com>
+Reviewed-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 7c5dffb3d90c ("f2fs: compress: fix to relocate check condition in f2fs_{release,reserve}_compress_blocks()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/filesystems/f2fs.rst | 35 ++++++++++++++++++++++++++++++
+ fs/f2fs/compress.c                 |  2 +-
+ fs/f2fs/data.c                     |  2 +-
+ fs/f2fs/f2fs.h                     | 30 +++++++++++++++++++++++++
+ fs/f2fs/segment.c                  |  2 +-
+ fs/f2fs/super.c                    | 23 ++++++++++++++++++++
+ 6 files changed, 91 insertions(+), 3 deletions(-)
+
+diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
+index 3d21a9e86995f..de2bacc418fee 100644
+--- a/Documentation/filesystems/f2fs.rst
++++ b/Documentation/filesystems/f2fs.rst
+@@ -261,6 +261,13 @@ compress_extension=%s      Support adding specified extension, so that f2fs can enab
+                        Note that, there is one reserved special extension '*', it
+                        can be set to enable compression for all files.
+ compress_chksum                Support verifying chksum of raw data in compressed cluster.
++compress_mode=%s       Control file compression mode. This supports "fs" and "user"
++                       modes. In "fs" mode (default), f2fs does automatic compression
++                       on the compression enabled files. In "user" mode, f2fs disables
++                       the automaic compression and gives the user discretion of
++                       choosing the target file and the timing. The user can do manual
++                       compression/decompression on the compression enabled files using
++                       ioctls.
+ inlinecrypt            When possible, encrypt/decrypt the contents of encrypted
+                        files using the blk-crypto framework rather than
+                        filesystem-layer encryption. This allows the use of
+@@ -811,6 +818,34 @@ Compress metadata layout::
+       | data length | data chksum | reserved |      compressed data       |
+       +-------------+-------------+----------+----------------------------+
++Compression mode
++--------------------------
++
++f2fs supports "fs" and "user" compression modes with "compression_mode" mount option.
++With this option, f2fs provides a choice to select the way how to compress the
++compression enabled files (refer to "Compression implementation" section for how to
++enable compression on a regular inode).
++
++1) compress_mode=fs
++This is the default option. f2fs does automatic compression in the writeback of the
++compression enabled files.
++
++2) compress_mode=user
++This disables the automaic compression and gives the user discretion of choosing the
++target file and the timing. The user can do manual compression/decompression on the
++compression enabled files using F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE
++ioctls like the below.
++
++To decompress a file,
++
++fd = open(filename, O_WRONLY, 0);
++ret = ioctl(fd, F2FS_IOC_DECOMPRESS_FILE);
++
++To compress a file,
++
++fd = open(filename, O_WRONLY, 0);
++ret = ioctl(fd, F2FS_IOC_COMPRESS_FILE);
++
+ NVMe Zoned Namespace devices
+ ----------------------------
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index c87020afda51f..6c870b741cfe5 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -929,7 +929,7 @@ int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index)
+ static bool cluster_may_compress(struct compress_ctx *cc)
+ {
+-      if (!f2fs_compressed_file(cc->inode))
++      if (!f2fs_need_compress_data(cc->inode))
+               return false;
+       if (f2fs_is_atomic_file(cc->inode))
+               return false;
+diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
+index e0533cffbb076..fc6c88e80cf4f 100644
+--- a/fs/f2fs/data.c
++++ b/fs/f2fs/data.c
+@@ -3222,7 +3222,7 @@ static inline bool __should_serialize_io(struct inode *inode,
+       if (IS_NOQUOTA(inode))
+               return false;
+-      if (f2fs_compressed_file(inode))
++      if (f2fs_need_compress_data(inode))
+               return true;
+       if (wbc->sync_mode != WB_SYNC_ALL)
+               return true;
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
+index 6dfefbf54917d..6a9f4dcea06d6 100644
+--- a/fs/f2fs/f2fs.h
++++ b/fs/f2fs/f2fs.h
+@@ -150,6 +150,7 @@ struct f2fs_mount_info {
+       unsigned char compress_log_size;        /* cluster log size */
+       bool compress_chksum;                   /* compressed data chksum */
+       unsigned char compress_ext_cnt;         /* extension count */
++      int compress_mode;                      /* compression mode */
+       unsigned char extensions[COMPRESS_EXT_NUM][F2FS_EXTENSION_LEN]; /* extensions */
+ };
+@@ -681,6 +682,7 @@ enum {
+       FI_COMPRESSED_FILE,     /* indicate file's data can be compressed */
+       FI_COMPRESS_CORRUPT,    /* indicate compressed cluster is corrupted */
+       FI_MMAP_FILE,           /* indicate file was mmapped */
++      FI_ENABLE_COMPRESS,     /* enable compression in "user" compression mode */
+       FI_MAX,                 /* max flag, never be used */
+ };
+@@ -1255,6 +1257,18 @@ enum fsync_mode {
+       FSYNC_MODE_NOBARRIER,   /* fsync behaves nobarrier based on posix */
+ };
++enum {
++      COMPR_MODE_FS,          /*
++                               * automatically compress compression
++                               * enabled files
++                               */
++      COMPR_MODE_USER,        /*
++                               * automatical compression is disabled.
++                               * user can control the file compression
++                               * using ioctls
++                               */
++};
++
+ /*
+  * this value is set in page as a private data which indicate that
+  * the page is atomically written, and it is in inmem_pages list.
+@@ -2795,6 +2809,22 @@ static inline int f2fs_compressed_file(struct inode *inode)
+               is_inode_flag_set(inode, FI_COMPRESSED_FILE);
+ }
++static inline bool f2fs_need_compress_data(struct inode *inode)
++{
++      int compress_mode = F2FS_OPTION(F2FS_I_SB(inode)).compress_mode;
++
++      if (!f2fs_compressed_file(inode))
++              return false;
++
++      if (compress_mode == COMPR_MODE_FS)
++              return true;
++      else if (compress_mode == COMPR_MODE_USER &&
++                      is_inode_flag_set(inode, FI_ENABLE_COMPRESS))
++              return true;
++
++      return false;
++}
++
+ static inline unsigned int addrs_per_inode(struct inode *inode)
+ {
+       unsigned int addrs = CUR_ADDRS_PER_INODE(inode) -
+diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
+index a27a934292715..ad30908ac99f3 100644
+--- a/fs/f2fs/segment.c
++++ b/fs/f2fs/segment.c
+@@ -3296,7 +3296,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
+                       else
+                               return CURSEG_COLD_DATA;
+               }
+-              if (file_is_cold(inode) || f2fs_compressed_file(inode))
++              if (file_is_cold(inode) || f2fs_need_compress_data(inode))
+                       return CURSEG_COLD_DATA;
+               if (file_is_hot(inode) ||
+                               is_inode_flag_set(inode, FI_HOT_DATA) ||
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
+index 065aa01958e95..1281b59da6a2a 100644
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -147,6 +147,7 @@ enum {
+       Opt_compress_log_size,
+       Opt_compress_extension,
+       Opt_compress_chksum,
++      Opt_compress_mode,
+       Opt_atgc,
+       Opt_err,
+ };
+@@ -216,6 +217,7 @@ static match_table_t f2fs_tokens = {
+       {Opt_compress_log_size, "compress_log_size=%u"},
+       {Opt_compress_extension, "compress_extension=%s"},
+       {Opt_compress_chksum, "compress_chksum"},
++      {Opt_compress_mode, "compress_mode=%s"},
+       {Opt_atgc, "atgc"},
+       {Opt_err, NULL},
+ };
+@@ -979,11 +981,26 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
+               case Opt_compress_chksum:
+                       F2FS_OPTION(sbi).compress_chksum = true;
+                       break;
++              case Opt_compress_mode:
++                      name = match_strdup(&args[0]);
++                      if (!name)
++                              return -ENOMEM;
++                      if (!strcmp(name, "fs")) {
++                              F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
++                      } else if (!strcmp(name, "user")) {
++                              F2FS_OPTION(sbi).compress_mode = COMPR_MODE_USER;
++                      } else {
++                              kfree(name);
++                              return -EINVAL;
++                      }
++                      kfree(name);
++                      break;
+ #else
+               case Opt_compress_algorithm:
+               case Opt_compress_log_size:
+               case Opt_compress_extension:
+               case Opt_compress_chksum:
++              case Opt_compress_mode:
+                       f2fs_info(sbi, "compression options not supported");
+                       break;
+ #endif
+@@ -1571,6 +1588,11 @@ static inline void f2fs_show_compress_options(struct seq_file *seq,
+       if (F2FS_OPTION(sbi).compress_chksum)
+               seq_puts(seq, ",compress_chksum");
++
++      if (F2FS_OPTION(sbi).compress_mode == COMPR_MODE_FS)
++              seq_printf(seq, ",compress_mode=%s", "fs");
++      else if (F2FS_OPTION(sbi).compress_mode == COMPR_MODE_USER)
++              seq_printf(seq, ",compress_mode=%s", "user");
+ }
+ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
+@@ -1720,6 +1742,7 @@ static void default_options(struct f2fs_sb_info *sbi)
+       F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4;
+       F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE;
+       F2FS_OPTION(sbi).compress_ext_cnt = 0;
++      F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
+       F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
+       sbi->sb->s_flags &= ~SB_INLINECRYPT;
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-add-cp_error-check-in-f2fs_write_compressed_pag.patch b/queue-5.10/f2fs-add-cp_error-check-in-f2fs_write_compressed_pag.patch
new file mode 100644 (file)
index 0000000..4ef4626
--- /dev/null
@@ -0,0 +1,40 @@
+From 655611d1e3aacbb2a1b7997e87505c4157e1aa8e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 27 Apr 2021 11:07:30 +0800
+Subject: f2fs: add cp_error check in f2fs_write_compressed_pages
+
+From: Chao Yu <yuchao0@huawei.com>
+
+[ Upstream commit ee68d27181f060fab29e60d1d31aab6a42703dd4 ]
+
+This patch adds cp_error check in f2fs_write_compressed_pages() like we did
+in f2fs_write_single_data_page()
+
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 278a6253a673 ("f2fs: fix to relocate check condition in f2fs_fallocate()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/compress.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index be6f2988ac7fc..9dc2e09f0a60d 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -1161,6 +1161,12 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
+       loff_t psize;
+       int i, err;
++      /* we should bypass data pages to proceed the kworkder jobs */
++      if (unlikely(f2fs_cp_error(sbi))) {
++              mapping_set_error(cc->rpages[0]->mapping, -EIO);
++              goto out_free;
++      }
++
+       if (IS_NOQUOTA(inode)) {
+               /*
+                * We need to wait for node_write to avoid block allocation during
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-compress-clean-up-parameter-of-__f2fs_cluster_b.patch b/queue-5.10/f2fs-compress-clean-up-parameter-of-__f2fs_cluster_b.patch
new file mode 100644 (file)
index 0000000..eae0db7
--- /dev/null
@@ -0,0 +1,101 @@
+From eb33bc29306f32b950a62a315d64aedfe2415d27 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 12 May 2021 17:52:57 +0800
+Subject: f2fs: compress: clean up parameter of __f2fs_cluster_blocks()
+
+From: Chao Yu <yuchao0@huawei.com>
+
+[ Upstream commit 91f0fb6903ed30370135381f10c02a10c7872cdc ]
+
+Previously, in order to reuse __f2fs_cluster_blocks(),
+f2fs_is_compressed_cluster() assigned a compress_ctx type variable,
+which is used to pass few parameters (cc.inode, cc.cluster_size,
+cc.cluster_idx), it's wasteful to allocate such large space in stack.
+
+Let's clean up parameters of __f2fs_cluster_blocks() to avoid that.
+
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 7c5dffb3d90c ("f2fs: compress: fix to relocate check condition in f2fs_{release,reserve}_compress_blocks()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/compress.c | 33 +++++++++++++--------------------
+ 1 file changed, 13 insertions(+), 20 deletions(-)
+
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index 6c870b741cfe5..04b6de1a58744 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -866,14 +866,17 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
+       return true;
+ }
+-static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr)
++static int __f2fs_cluster_blocks(struct inode *inode,
++                              unsigned int cluster_idx, bool compr)
+ {
+       struct dnode_of_data dn;
++      unsigned int cluster_size = F2FS_I(inode)->i_cluster_size;
++      unsigned int start_idx = cluster_idx <<
++                              F2FS_I(inode)->i_log_cluster_size;
+       int ret;
+-      set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
+-      ret = f2fs_get_dnode_of_data(&dn, start_idx_of_cluster(cc),
+-                                                      LOOKUP_NODE);
++      set_new_dnode(&dn, inode, NULL, NULL, 0);
++      ret = f2fs_get_dnode_of_data(&dn, start_idx, LOOKUP_NODE);
+       if (ret) {
+               if (ret == -ENOENT)
+                       ret = 0;
+@@ -884,7 +887,7 @@ static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr)
+               int i;
+               ret = 1;
+-              for (i = 1; i < cc->cluster_size; i++) {
++              for (i = 1; i < cluster_size; i++) {
+                       block_t blkaddr;
+                       blkaddr = data_blkaddr(dn.inode,
+@@ -906,25 +909,15 @@ static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr)
+ /* return # of compressed blocks in compressed cluster */
+ static int f2fs_compressed_blocks(struct compress_ctx *cc)
+ {
+-      return __f2fs_cluster_blocks(cc, true);
++      return __f2fs_cluster_blocks(cc->inode, cc->cluster_idx, true);
+ }
+ /* return # of valid blocks in compressed cluster */
+-static int f2fs_cluster_blocks(struct compress_ctx *cc)
+-{
+-      return __f2fs_cluster_blocks(cc, false);
+-}
+-
+ int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index)
+ {
+-      struct compress_ctx cc = {
+-              .inode = inode,
+-              .log_cluster_size = F2FS_I(inode)->i_log_cluster_size,
+-              .cluster_size = F2FS_I(inode)->i_cluster_size,
+-              .cluster_idx = index >> F2FS_I(inode)->i_log_cluster_size,
+-      };
+-
+-      return f2fs_cluster_blocks(&cc);
++      return __f2fs_cluster_blocks(inode,
++              index >> F2FS_I(inode)->i_log_cluster_size,
++              false);
+ }
+ static bool cluster_may_compress(struct compress_ctx *cc)
+@@ -975,7 +968,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
+       bool prealloc;
+ retry:
+-      ret = f2fs_cluster_blocks(cc);
++      ret = f2fs_is_compressed_cluster(cc->inode, start_idx);
+       if (ret <= 0)
+               return ret;
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-compress-don-t-allow-unaligned-truncation-on-re.patch b/queue-5.10/f2fs-compress-don-t-allow-unaligned-truncation-on-re.patch
new file mode 100644 (file)
index 0000000..f2bfb60
--- /dev/null
@@ -0,0 +1,65 @@
+From ae9c80e3aaa9e2361297972e49e4851e2bbe02e8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 May 2024 11:33:39 +0800
+Subject: f2fs: compress: don't allow unaligned truncation on released compress
+ inode
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 29ed2b5dd521ce7c5d8466cd70bf0cc9d07afeee ]
+
+f2fs image may be corrupted after below testcase:
+- mkfs.f2fs -O extra_attr,compression -f /dev/vdb
+- mount /dev/vdb /mnt/f2fs
+- touch /mnt/f2fs/file
+- f2fs_io setflags compression /mnt/f2fs/file
+- dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=4
+- f2fs_io release_cblocks /mnt/f2fs/file
+- truncate -s 8192 /mnt/f2fs/file
+- umount /mnt/f2fs
+- fsck.f2fs /dev/vdb
+
+[ASSERT] (fsck_chk_inode_blk:1256)  --> ino: 0x5 has i_blocks: 0x00000002, but has 0x3 blocks
+[FSCK] valid_block_count matching with CP             [Fail] [0x4, 0x5]
+[FSCK] other corrupted bugs                           [Fail]
+
+The reason is: partial truncation assume compressed inode has reserved
+blocks, after partial truncation, valid block count may change w/o
+.i_blocks and .total_valid_block_count update, result in corruption.
+
+This patch only allow cluster size aligned truncation on released
+compress inode for fixing.
+
+Fixes: c61404153eb6 ("f2fs: introduce FI_COMPRESS_RELEASED instead of using IMMUTABLE bit")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index c858118a3927e..50514962771a1 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -891,9 +891,14 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
+                                 ATTR_GID | ATTR_TIMES_SET))))
+               return -EPERM;
+-      if ((attr->ia_valid & ATTR_SIZE) &&
+-              !f2fs_is_compress_backend_ready(inode))
+-              return -EOPNOTSUPP;
++      if ((attr->ia_valid & ATTR_SIZE)) {
++              if (!f2fs_is_compress_backend_ready(inode))
++                      return -EOPNOTSUPP;
++              if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) &&
++                      !IS_ALIGNED(attr->ia_size,
++                      F2FS_BLK_TO_BYTES(F2FS_I(inode)->i_cluster_size)))
++                      return -EINVAL;
++      }
+       err = setattr_prepare(dentry, attr);
+       if (err)
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-compress-fix-to-cover-reserve-release-_compress.patch b/queue-5.10/f2fs-compress-fix-to-cover-reserve-release-_compress.patch
new file mode 100644 (file)
index 0000000..2b6d848
--- /dev/null
@@ -0,0 +1,75 @@
+From 2378a289ea86d71a772f7ec489b110c3de5eafd1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 May 2024 18:41:39 +0800
+Subject: f2fs: compress: fix to cover {reserve,release}_compress_blocks() w/
+ cp_rwsem lock
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 0a4ed2d97cb6d044196cc3e726b6699222b41019 ]
+
+It needs to cover {reserve,release}_compress_blocks() w/ cp_rwsem lock
+to avoid racing with checkpoint, otherwise, filesystem metadata including
+blkaddr in dnode, inode fields and .total_valid_block_count may be
+corrupted after SPO case.
+
+Fixes: ef8d563f184e ("f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS")
+Fixes: c75488fb4d82 ("f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index f66959ae01636..c858118a3927e 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -3596,9 +3596,12 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
+               struct dnode_of_data dn;
+               pgoff_t end_offset, count;
++              f2fs_lock_op(sbi);
++
+               set_new_dnode(&dn, inode, NULL, NULL, 0);
+               ret = f2fs_get_dnode_of_data(&dn, page_idx, LOOKUP_NODE);
+               if (ret) {
++                      f2fs_unlock_op(sbi);
+                       if (ret == -ENOENT) {
+                               page_idx = f2fs_get_next_page_offset(&dn,
+                                                               page_idx);
+@@ -3616,6 +3619,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
+               f2fs_put_dnode(&dn);
++              f2fs_unlock_op(sbi);
++
+               if (ret < 0)
+                       break;
+@@ -3758,9 +3763,12 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
+               struct dnode_of_data dn;
+               pgoff_t end_offset, count;
++              f2fs_lock_op(sbi);
++
+               set_new_dnode(&dn, inode, NULL, NULL, 0);
+               ret = f2fs_get_dnode_of_data(&dn, page_idx, LOOKUP_NODE);
+               if (ret) {
++                      f2fs_unlock_op(sbi);
+                       if (ret == -ENOENT) {
+                               page_idx = f2fs_get_next_page_offset(&dn,
+                                                               page_idx);
+@@ -3778,6 +3786,8 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
+               f2fs_put_dnode(&dn);
++              f2fs_unlock_op(sbi);
++
+               if (ret < 0)
+                       break;
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-compress-fix-to-relocate-check-condition-in-f2f.patch b/queue-5.10/f2fs-compress-fix-to-relocate-check-condition-in-f2f.patch
new file mode 100644 (file)
index 0000000..aa7e095
--- /dev/null
@@ -0,0 +1,70 @@
+From 62a67681c1963720987a3c68467394221d4e6918 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 7 Apr 2024 15:26:03 +0800
+Subject: f2fs: compress: fix to relocate check condition in
+ f2fs_{release,reserve}_compress_blocks()
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 7c5dffb3d90c5921b91981cc663e02757d90526e ]
+
+Compress flag should be checked after inode lock held to avoid
+racing w/ f2fs_setflags_common(), fix it.
+
+Fixes: 4c8ff7095bef ("f2fs: support data compression")
+Reported-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
+Closes: https://lore.kernel.org/linux-f2fs-devel/CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.com
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 12 ++++--------
+ 1 file changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index cdd2630f4860f..9023083a98a64 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -3533,9 +3533,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
+       if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
+               return -EOPNOTSUPP;
+-      if (!f2fs_compressed_file(inode))
+-              return -EINVAL;
+-
+       if (f2fs_readonly(sbi->sb))
+               return -EROFS;
+@@ -3554,7 +3551,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
+               goto out;
+       }
+-      if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
++      if (!f2fs_compressed_file(inode) ||
++              is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+               ret = -EINVAL;
+               goto out;
+       }
+@@ -3712,9 +3710,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
+       if (!f2fs_sb_has_compression(F2FS_I_SB(inode)))
+               return -EOPNOTSUPP;
+-      if (!f2fs_compressed_file(inode))
+-              return -EINVAL;
+-
+       if (f2fs_readonly(sbi->sb))
+               return -EROFS;
+@@ -3729,7 +3724,8 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
+       inode_lock(inode);
+-      if (!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
++      if (!f2fs_compressed_file(inode) ||
++              !is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+               ret = -EINVAL;
+               goto unlock_inode;
+       }
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-compress-remove-unneeded-preallocation.patch b/queue-5.10/f2fs-compress-remove-unneeded-preallocation.patch
new file mode 100644 (file)
index 0000000..f8e0dde
--- /dev/null
@@ -0,0 +1,109 @@
+From 4e149c5681a0af1ad118008c1cd752e7a2e13b43 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 12 May 2021 17:52:58 +0800
+Subject: f2fs: compress: remove unneeded preallocation
+
+From: Chao Yu <yuchao0@huawei.com>
+
+[ Upstream commit 8f1d49832636d514e949b29ce64370ebebf6d6d2 ]
+
+We will reserve iblocks for compression saved, so during compressed
+cluster overwrite, we don't need to preallocate blocks for later
+write.
+
+In addition, it adds a bug_on to detect wrong reserved iblock number
+in __f2fs_cluster_blocks().
+
+Bug fix in the original patch by Jaegeuk:
+If we released compressed blocks having an immutable bit, we can see less
+number of compressed block addresses. Let's fix wrong BUG_ON.
+
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 7c5dffb3d90c ("f2fs: compress: fix to relocate check condition in f2fs_{release,reserve}_compress_blocks()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/compress.c | 27 +++------------------------
+ fs/f2fs/file.c     |  4 ----
+ 2 files changed, 3 insertions(+), 28 deletions(-)
+
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index 04b6de1a58744..388ed7052d9b6 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -900,6 +900,9 @@ static int __f2fs_cluster_blocks(struct inode *inode,
+                                       ret++;
+                       }
+               }
++
++              f2fs_bug_on(F2FS_I_SB(inode),
++                      !compr && ret != cluster_size && !IS_IMMUTABLE(inode));
+       }
+ fail:
+       f2fs_put_dnode(&dn);
+@@ -960,21 +963,16 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
+       struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode);
+       struct address_space *mapping = cc->inode->i_mapping;
+       struct page *page;
+-      struct dnode_of_data dn;
+       sector_t last_block_in_bio;
+       unsigned fgp_flag = FGP_LOCK | FGP_WRITE | FGP_CREAT;
+       pgoff_t start_idx = start_idx_of_cluster(cc);
+       int i, ret;
+-      bool prealloc;
+ retry:
+       ret = f2fs_is_compressed_cluster(cc->inode, start_idx);
+       if (ret <= 0)
+               return ret;
+-      /* compressed case */
+-      prealloc = (ret < cc->cluster_size);
+-
+       ret = f2fs_init_compress_ctx(cc);
+       if (ret)
+               return ret;
+@@ -1032,25 +1030,6 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
+               }
+       }
+-      if (prealloc) {
+-              f2fs_do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, true);
+-
+-              set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
+-
+-              for (i = cc->cluster_size - 1; i > 0; i--) {
+-                      ret = f2fs_get_block(&dn, start_idx + i);
+-                      if (ret) {
+-                              i = cc->cluster_size;
+-                              break;
+-                      }
+-
+-                      if (dn.data_blkaddr != NEW_ADDR)
+-                              break;
+-              }
+-
+-              f2fs_do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false);
+-      }
+-
+       if (likely(!ret)) {
+               *fsdata = cc->rpages;
+               *pagep = cc->rpages[offset_in_cluster(cc, index)];
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 678d72a870259..8b136f2dc2d22 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -81,10 +81,6 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
+                       err = ret;
+                       goto err;
+               } else if (ret) {
+-                      if (ret < F2FS_I(inode)->i_cluster_size) {
+-                              err = -EAGAIN;
+-                              goto err;
+-                      }
+                       need_alloc = false;
+               }
+       }
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-compress-support-chksum.patch b/queue-5.10/f2fs-compress-support-chksum.patch
new file mode 100644 (file)
index 0000000..0160e00
--- /dev/null
@@ -0,0 +1,228 @@
+From 30737be08e62e5b994581b698b3b556f6d6cff7f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Nov 2020 18:32:09 +0800
+Subject: f2fs: compress: support chksum
+
+From: Chao Yu <yuchao0@huawei.com>
+
+[ Upstream commit b28f047b28c51d0b9864c34b097bb0b221ea7247 ]
+
+This patch supports to store chksum value with compressed
+data, and verify the integrality of compressed data while
+reading the data.
+
+The feature can be enabled through specifying mount option
+'compress_chksum'.
+
+Signed-off-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 7c5dffb3d90c ("f2fs: compress: fix to relocate check condition in f2fs_{release,reserve}_compress_blocks()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/filesystems/f2fs.rst |  1 +
+ fs/f2fs/compress.c                 | 23 +++++++++++++++++++++++
+ fs/f2fs/f2fs.h                     | 16 ++++++++++++++--
+ fs/f2fs/inode.c                    |  3 +++
+ fs/f2fs/super.c                    |  9 +++++++++
+ include/linux/f2fs_fs.h            |  2 +-
+ 6 files changed, 51 insertions(+), 3 deletions(-)
+
+diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
+index 8c0fbdd8ce6fb..3d21a9e86995f 100644
+--- a/Documentation/filesystems/f2fs.rst
++++ b/Documentation/filesystems/f2fs.rst
+@@ -260,6 +260,7 @@ compress_extension=%s       Support adding specified extension, so that f2fs can enab
+                        For other files, we can still enable compression via ioctl.
+                        Note that, there is one reserved special extension '*', it
+                        can be set to enable compression for all files.
++compress_chksum                Support verifying chksum of raw data in compressed cluster.
+ inlinecrypt            When possible, encrypt/decrypt the contents of encrypted
+                        files using the blk-crypto framework rather than
+                        filesystem-layer encryption. This allows the use of
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index a94e102d15866..c87020afda51f 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -589,6 +589,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
+                               f2fs_cops[fi->i_compress_algorithm];
+       unsigned int max_len, new_nr_cpages;
+       struct page **new_cpages;
++      u32 chksum = 0;
+       int i, ret;
+       trace_f2fs_compress_pages_start(cc->inode, cc->cluster_idx,
+@@ -642,6 +643,11 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
+       cc->cbuf->clen = cpu_to_le32(cc->clen);
++      if (fi->i_compress_flag & 1 << COMPRESS_CHKSUM)
++              chksum = f2fs_crc32(F2FS_I_SB(cc->inode),
++                                      cc->cbuf->cdata, cc->clen);
++      cc->cbuf->chksum = cpu_to_le32(chksum);
++
+       for (i = 0; i < COMPRESS_DATA_RESERVED_SIZE; i++)
+               cc->cbuf->reserved[i] = cpu_to_le32(0);
+@@ -777,6 +783,23 @@ void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
+       ret = cops->decompress_pages(dic);
++      if (!ret && fi->i_compress_flag & 1 << COMPRESS_CHKSUM) {
++              u32 provided = le32_to_cpu(dic->cbuf->chksum);
++              u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
++
++              if (provided != calculated) {
++                      if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) {
++                              set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT);
++                              printk_ratelimited(
++                                      "%sF2FS-fs (%s): checksum invalid, nid = %lu, %x vs %x",
++                                      KERN_INFO, sbi->sb->s_id, dic->inode->i_ino,
++                                      provided, calculated);
++                      }
++                      set_sbi_flag(sbi, SBI_NEED_FSCK);
++                      WARN_ON_ONCE(1);
++              }
++      }
++
+ out_vunmap_cbuf:
+       vm_unmap_ram(dic->cbuf, dic->nr_cpages);
+ out_vunmap_rbuf:
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
+index 83ebc860508b0..6dfefbf54917d 100644
+--- a/fs/f2fs/f2fs.h
++++ b/fs/f2fs/f2fs.h
+@@ -147,7 +147,8 @@ struct f2fs_mount_info {
+       /* For compression */
+       unsigned char compress_algorithm;       /* algorithm type */
+-      unsigned compress_log_size;             /* cluster log size */
++      unsigned char compress_log_size;        /* cluster log size */
++      bool compress_chksum;                   /* compressed data chksum */
+       unsigned char compress_ext_cnt;         /* extension count */
+       unsigned char extensions[COMPRESS_EXT_NUM][F2FS_EXTENSION_LEN]; /* extensions */
+ };
+@@ -678,6 +679,7 @@ enum {
+       FI_ATOMIC_REVOKE_REQUEST, /* request to drop atomic data */
+       FI_VERITY_IN_PROGRESS,  /* building fs-verity Merkle tree */
+       FI_COMPRESSED_FILE,     /* indicate file's data can be compressed */
++      FI_COMPRESS_CORRUPT,    /* indicate compressed cluster is corrupted */
+       FI_MMAP_FILE,           /* indicate file was mmapped */
+       FI_MAX,                 /* max flag, never be used */
+ };
+@@ -736,6 +738,7 @@ struct f2fs_inode_info {
+       atomic_t i_compr_blocks;                /* # of compressed blocks */
+       unsigned char i_compress_algorithm;     /* algorithm type */
+       unsigned char i_log_cluster_size;       /* log of cluster size */
++      unsigned short i_compress_flag;         /* compress flag */
+       unsigned int i_cluster_size;            /* cluster size */
+ };
+@@ -1281,9 +1284,15 @@ enum compress_algorithm_type {
+       COMPRESS_MAX,
+ };
+-#define COMPRESS_DATA_RESERVED_SIZE           5
++enum compress_flag {
++      COMPRESS_CHKSUM,
++      COMPRESS_MAX_FLAG,
++};
++
++#define COMPRESS_DATA_RESERVED_SIZE           4
+ struct compress_data {
+       __le32 clen;                    /* compressed data size */
++      __le32 chksum;                  /* compressed data chksum */
+       __le32 reserved[COMPRESS_DATA_RESERVED_SIZE];   /* reserved */
+       u8 cdata[];                     /* compressed data */
+ };
+@@ -3925,6 +3934,9 @@ static inline void set_compress_context(struct inode *inode)
+                       F2FS_OPTION(sbi).compress_algorithm;
+       F2FS_I(inode)->i_log_cluster_size =
+                       F2FS_OPTION(sbi).compress_log_size;
++      F2FS_I(inode)->i_compress_flag =
++                      F2FS_OPTION(sbi).compress_chksum ?
++                              1 << COMPRESS_CHKSUM : 0;
+       F2FS_I(inode)->i_cluster_size =
+                       1 << F2FS_I(inode)->i_log_cluster_size;
+       F2FS_I(inode)->i_flags |= F2FS_COMPR_FL;
+diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
+index 87752550f78c8..3e98551f4186d 100644
+--- a/fs/f2fs/inode.c
++++ b/fs/f2fs/inode.c
+@@ -455,6 +455,7 @@ static int do_read_inode(struct inode *inode)
+                                       le64_to_cpu(ri->i_compr_blocks));
+                       fi->i_compress_algorithm = ri->i_compress_algorithm;
+                       fi->i_log_cluster_size = ri->i_log_cluster_size;
++                      fi->i_compress_flag = le16_to_cpu(ri->i_compress_flag);
+                       fi->i_cluster_size = 1 << fi->i_log_cluster_size;
+                       set_inode_flag(inode, FI_COMPRESSED_FILE);
+               }
+@@ -633,6 +634,8 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
+                                       &F2FS_I(inode)->i_compr_blocks));
+                       ri->i_compress_algorithm =
+                               F2FS_I(inode)->i_compress_algorithm;
++                      ri->i_compress_flag =
++                              cpu_to_le16(F2FS_I(inode)->i_compress_flag);
+                       ri->i_log_cluster_size =
+                               F2FS_I(inode)->i_log_cluster_size;
+               }
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
+index 9a74d60f61dba..065aa01958e95 100644
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -146,6 +146,7 @@ enum {
+       Opt_compress_algorithm,
+       Opt_compress_log_size,
+       Opt_compress_extension,
++      Opt_compress_chksum,
+       Opt_atgc,
+       Opt_err,
+ };
+@@ -214,6 +215,7 @@ static match_table_t f2fs_tokens = {
+       {Opt_compress_algorithm, "compress_algorithm=%s"},
+       {Opt_compress_log_size, "compress_log_size=%u"},
+       {Opt_compress_extension, "compress_extension=%s"},
++      {Opt_compress_chksum, "compress_chksum"},
+       {Opt_atgc, "atgc"},
+       {Opt_err, NULL},
+ };
+@@ -974,10 +976,14 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
+                       F2FS_OPTION(sbi).compress_ext_cnt++;
+                       kfree(name);
+                       break;
++              case Opt_compress_chksum:
++                      F2FS_OPTION(sbi).compress_chksum = true;
++                      break;
+ #else
+               case Opt_compress_algorithm:
+               case Opt_compress_log_size:
+               case Opt_compress_extension:
++              case Opt_compress_chksum:
+                       f2fs_info(sbi, "compression options not supported");
+                       break;
+ #endif
+@@ -1562,6 +1568,9 @@ static inline void f2fs_show_compress_options(struct seq_file *seq,
+               seq_printf(seq, ",compress_extension=%s",
+                       F2FS_OPTION(sbi).extensions[i]);
+       }
++
++      if (F2FS_OPTION(sbi).compress_chksum)
++              seq_puts(seq, ",compress_chksum");
+ }
+ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
+diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
+index a5dbb57a687fb..7dc2a06cf19a1 100644
+--- a/include/linux/f2fs_fs.h
++++ b/include/linux/f2fs_fs.h
+@@ -273,7 +273,7 @@ struct f2fs_inode {
+                       __le64 i_compr_blocks;  /* # of compressed blocks */
+                       __u8 i_compress_algorithm;      /* compress algorithm */
+                       __u8 i_log_cluster_size;        /* log of cluster size */
+-                      __le16 i_padding;               /* padding */
++                      __le16 i_compress_flag;         /* compress flag */
+                       __le32 i_extra_end[0];  /* for attribute size calculation */
+               } __packed;
+               __le32 i_addr[DEF_ADDRS_PER_INODE];     /* Pointers to data blocks */
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-do-not-allow-partial-truncation-on-pinned-file.patch b/queue-5.10/f2fs-do-not-allow-partial-truncation-on-pinned-file.patch
new file mode 100644 (file)
index 0000000..cb76a95
--- /dev/null
@@ -0,0 +1,40 @@
+From 35ec8a45d85cfb1f32fda83713c827945d168e31 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 7 Jan 2022 20:08:45 -0800
+Subject: f2fs: do not allow partial truncation on pinned file
+
+From: Jaegeuk Kim <jaegeuk@kernel.org>
+
+[ Upstream commit 5fed0be8583f08c1548b4dcd9e5ee0d1133d0730 ]
+
+If the pinned file has a hole by partial truncation, application that has
+the block map will be broken.
+
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 278a6253a673 ("f2fs: fix to relocate check condition in f2fs_fallocate()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 02971d6b347e0..e88d4c0f71e3e 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -1745,7 +1745,11 @@ static long f2fs_fallocate(struct file *file, int mode,
+               (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
+               return -EOPNOTSUPP;
+-      if (f2fs_compressed_file(inode) &&
++      /*
++       * Pinned file should not support partial trucation since the block
++       * can be used by applications.
++       */
++      if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
+               (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
+                       FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)))
+               return -EOPNOTSUPP;
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-fix-to-check-pinfile-flag-in-f2fs_move_file_ran.patch b/queue-5.10/f2fs-fix-to-check-pinfile-flag-in-f2fs_move_file_ran.patch
new file mode 100644 (file)
index 0000000..9b55298
--- /dev/null
@@ -0,0 +1,37 @@
+From f629a9d9412131f597820d0cfa595c79c46aaabe Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Apr 2024 22:24:20 +0800
+Subject: f2fs: fix to check pinfile flag in f2fs_move_file_range()
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit e07230da0500e0919a765037c5e81583b519be2c ]
+
+ioctl(F2FS_IOC_MOVE_RANGE) can truncate or punch hole on pinned file,
+fix to disallow it.
+
+Fixes: 5fed0be8583f ("f2fs: do not allow partial truncation on pinned file")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 9cf04b9d3ad8e..f66959ae01636 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -2835,7 +2835,8 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
+                       goto out;
+       }
+-      if (f2fs_compressed_file(src) || f2fs_compressed_file(dst)) {
++      if (f2fs_compressed_file(src) || f2fs_compressed_file(dst) ||
++              f2fs_is_pinned_file(src) || f2fs_is_pinned_file(dst)) {
+               ret = -EOPNOTSUPP;
+               goto out_unlock;
+       }
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-fix-to-force-keeping-write-barrier-for-strict-f.patch b/queue-5.10/f2fs-fix-to-force-keeping-write-barrier-for-strict-f.patch
new file mode 100644 (file)
index 0000000..0fc7059
--- /dev/null
@@ -0,0 +1,66 @@
+From 17b19b515470838e347eaec1c9e74a091c46af1c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 20 Jul 2021 09:03:29 +0800
+Subject: f2fs: fix to force keeping write barrier for strict fsync mode
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 2787991516468bfafafb9bf2b45a848e6b202e7c ]
+
+[1] https://www.mail-archive.com/linux-f2fs-devel@lists.sourceforge.net/msg15126.html
+
+As [1] reported, if lower device doesn't support write barrier, in below
+case:
+
+- write page #0; persist
+- overwrite page #0
+- fsync
+ - write data page #0 OPU into device's cache
+ - write inode page into device's cache
+ - issue flush
+
+If SPO is triggered during flush command, inode page can be persisted
+before data page #0, so that after recovery, inode page can be recovered
+with new physical block address of data page #0, however there may
+contains dummy data in new physical block address.
+
+Then what user will see is: after overwrite & fsync + SPO, old data in
+file was corrupted, if any user do care about such case, we can suggest
+user to use STRICT fsync mode, in this mode, we will force to use atomic
+write sematics to keep write order in between data/node and last node,
+so that it avoids potential data corruption during fsync().
+
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 278a6253a673 ("f2fs: fix to relocate check condition in f2fs_fallocate()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 9023083a98a64..02971d6b347e0 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -297,6 +297,18 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
+                               f2fs_exist_written_data(sbi, ino, UPDATE_INO))
+                       goto flush_out;
+               goto out;
++      } else {
++              /*
++               * for OPU case, during fsync(), node can be persisted before
++               * data when lower device doesn't support write barrier, result
++               * in data corruption after SPO.
++               * So for strict fsync mode, force to use atomic write sematics
++               * to keep write order in between data/node and last node to
++               * avoid potential data corruption.
++               */
++              if (F2FS_OPTION(sbi).fsync_mode ==
++                              FSYNC_MODE_STRICT && !atomic)
++                      atomic = true;
+       }
+ go_write:
+       /*
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-fix-to-release-node-block-count-in-error-path-o.patch b/queue-5.10/f2fs-fix-to-release-node-block-count-in-error-path-o.patch
new file mode 100644 (file)
index 0000000..a1718d6
--- /dev/null
@@ -0,0 +1,44 @@
+From 41e7c4858ae480fac574014133e96a6c9cf8d27b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 May 2024 11:31:00 +0800
+Subject: f2fs: fix to release node block count in error path of
+ f2fs_new_node_page()
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 0fa4e57c1db263effd72d2149d4e21da0055c316 ]
+
+It missed to call dec_valid_node_count() to release node block count
+in error path, fix it.
+
+Fixes: 141170b759e0 ("f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page()")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/node.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
+index 02cb1c806c3ed..348ad1d6199ff 100644
+--- a/fs/f2fs/node.c
++++ b/fs/f2fs/node.c
+@@ -1242,6 +1242,7 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
+       }
+       if (unlikely(new_ni.blk_addr != NULL_ADDR)) {
+               err = -EFSCORRUPTED;
++              dec_valid_node_count(sbi, dn->inode, !ofs);
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               goto fail;
+       }
+@@ -1267,7 +1268,6 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
+       if (ofs == 0)
+               inc_valid_inode_count(sbi);
+       return page;
+-
+ fail:
+       clear_node_page_dirty(page);
+       f2fs_put_page(page, 1);
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-fix-to-relocate-check-condition-in-f2fs_falloca.patch b/queue-5.10/f2fs-fix-to-relocate-check-condition-in-f2fs_falloca.patch
new file mode 100644 (file)
index 0000000..4c54529
--- /dev/null
@@ -0,0 +1,62 @@
+From 1a86dd46b65db59bad790e955b1c0f6bf7698216 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Apr 2024 22:24:19 +0800
+Subject: f2fs: fix to relocate check condition in f2fs_fallocate()
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit 278a6253a673611dbc8ab72a3b34b151a8e75822 ]
+
+compress and pinfile flag should be checked after inode lock held to
+avoid race condition, fix it.
+
+Fixes: 4c8ff7095bef ("f2fs: support data compression")
+Fixes: 5fed0be8583f ("f2fs: do not allow partial truncation on pinned file")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 20 +++++++++++---------
+ 1 file changed, 11 insertions(+), 9 deletions(-)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 367b19f059f3c..9cf04b9d3ad8e 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -1745,15 +1745,6 @@ static long f2fs_fallocate(struct file *file, int mode,
+               (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
+               return -EOPNOTSUPP;
+-      /*
+-       * Pinned file should not support partial truncation since the block
+-       * can be used by applications.
+-       */
+-      if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
+-              (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
+-                      FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)))
+-              return -EOPNOTSUPP;
+-
+       if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
+                       FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
+                       FALLOC_FL_INSERT_RANGE))
+@@ -1761,6 +1752,17 @@ static long f2fs_fallocate(struct file *file, int mode,
+       inode_lock(inode);
++      /*
++       * Pinned file should not support partial truncation since the block
++       * can be used by applications.
++       */
++      if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
++              (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
++                      FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) {
++              ret = -EOPNOTSUPP;
++              goto out;
++      }
++
+       ret = file_modified(file);
+       if (ret)
+               goto out;
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-fix-to-wait-on-page-writeback-in-__clone_blkadd.patch b/queue-5.10/f2fs-fix-to-wait-on-page-writeback-in-__clone_blkadd.patch
new file mode 100644 (file)
index 0000000..8234ef8
--- /dev/null
@@ -0,0 +1,52 @@
+From 82eb297061d598a9c8ae3ef977a83dd823b27db0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 26 Mar 2024 19:28:45 +0800
+Subject: f2fs: fix to wait on page writeback in __clone_blkaddrs()
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit d3876e34e7e789e2cbdd782360fef2a777391082 ]
+
+In below race condition, dst page may become writeback status
+in __clone_blkaddrs(), it needs to wait writeback before update,
+fix it.
+
+Thread A                               GC Thread
+- f2fs_move_file_range
+  - filemap_write_and_wait_range(dst)
+                                       - gc_data_segment
+                                        - f2fs_down_write(dst)
+                                        - move_data_page
+                                         - set_page_writeback(dst_page)
+                                         - f2fs_submit_page_write
+                                        - f2fs_up_write(dst)
+  - f2fs_down_write(dst)
+  - __exchange_data_block
+   - __clone_blkaddrs
+    - f2fs_get_new_data_page
+    - memcpy_page
+
+Fixes: 0a2aa8fbb969 ("f2fs: refactor __exchange_data_block for speed up")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 40e805014f719..678d72a870259 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -1253,6 +1253,8 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
+                               f2fs_put_page(psrc, 1);
+                               return PTR_ERR(pdst);
+                       }
++                      f2fs_wait_on_page_writeback(pdst, DATA, true, true);
++
+                       f2fs_copy_page(psrc, pdst);
+                       set_page_dirty(pdst);
+                       f2fs_put_page(pdst, 1);
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-fix-typos-in-comments.patch b/queue-5.10/f2fs-fix-typos-in-comments.patch
new file mode 100644 (file)
index 0000000..ac11c7e
--- /dev/null
@@ -0,0 +1,183 @@
+From bf0a557e216b0c04fdc3a6bec9fb397c02048213 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 Feb 2023 20:56:00 +0900
+Subject: f2fs: fix typos in comments
+
+From: Jinyoung CHOI <j-young.choi@samsung.com>
+
+[ Upstream commit 146949defda868378992171b9e42318b06fcd482 ]
+
+This patch is to fix typos in f2fs files.
+
+Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 278a6253a673 ("f2fs: fix to relocate check condition in f2fs_fallocate()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/checkpoint.c   | 4 ++--
+ fs/f2fs/compress.c     | 2 +-
+ fs/f2fs/data.c         | 8 ++++----
+ fs/f2fs/extent_cache.c | 4 ++--
+ fs/f2fs/file.c         | 6 +++---
+ fs/f2fs/namei.c        | 2 +-
+ fs/f2fs/segment.c      | 2 +-
+ 7 files changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
+index 8ca549cc975e4..f4ab9b313e4f5 100644
+--- a/fs/f2fs/checkpoint.c
++++ b/fs/f2fs/checkpoint.c
+@@ -776,7 +776,7 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
+        */
+       head = &im->ino_list;
+-      /* loop for each orphan inode entry and write them in Jornal block */
++      /* loop for each orphan inode entry and write them in journal block */
+       list_for_each_entry(orphan, head, list) {
+               if (!page) {
+                       page = f2fs_grab_meta_page(sbi, start_blk++);
+@@ -1109,7 +1109,7 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type,
+       } else {
+               /*
+                * We should submit bio, since it exists several
+-               * wribacking dentry pages in the freeing inode.
++               * writebacking dentry pages in the freeing inode.
+                */
+               f2fs_submit_merged_write(sbi, DATA);
+               cond_resched();
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index 9dc2e09f0a60d..6fb875c8cf28d 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -1161,7 +1161,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
+       loff_t psize;
+       int i, err;
+-      /* we should bypass data pages to proceed the kworkder jobs */
++      /* we should bypass data pages to proceed the kworker jobs */
+       if (unlikely(f2fs_cp_error(sbi))) {
+               mapping_set_error(cc->rpages[0]->mapping, -EIO);
+               goto out_free;
+diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
+index fc6c88e80cf4f..1b764f70b70ed 100644
+--- a/fs/f2fs/data.c
++++ b/fs/f2fs/data.c
+@@ -2431,7 +2431,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
+ #ifdef CONFIG_F2FS_FS_COMPRESSION
+               if (f2fs_compressed_file(inode)) {
+-                      /* there are remained comressed pages, submit them */
++                      /* there are remained compressed pages, submit them */
+                       if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
+                               ret = f2fs_read_multi_pages(&cc, &bio,
+                                                       max_nr_pages,
+@@ -2807,7 +2807,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
+       trace_f2fs_writepage(page, DATA);
+-      /* we should bypass data pages to proceed the kworkder jobs */
++      /* we should bypass data pages to proceed the kworker jobs */
+       if (unlikely(f2fs_cp_error(sbi))) {
+               mapping_set_error(page->mapping, -EIO);
+               /*
+@@ -2933,7 +2933,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
+ redirty_out:
+       redirty_page_for_writepage(wbc, page);
+       /*
+-       * pageout() in MM traslates EAGAIN, so calls handle_write_error()
++       * pageout() in MM translates EAGAIN, so calls handle_write_error()
+        * -> mapping_set_error() -> set_bit(AS_EIO, ...).
+        * file_write_and_wait_range() will see EIO error, which is critical
+        * to return value of fsync() followed by atomic_write failure to user.
+@@ -2967,7 +2967,7 @@ static int f2fs_write_data_page(struct page *page,
+ }
+ /*
+- * This function was copied from write_cche_pages from mm/page-writeback.c.
++ * This function was copied from write_cache_pages from mm/page-writeback.c.
+  * The major change is making write step of cold data page separately from
+  * warm/hot data page.
+  */
+diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
+index ad0b83a412268..01f93fae56297 100644
+--- a/fs/f2fs/extent_cache.c
++++ b/fs/f2fs/extent_cache.c
+@@ -112,7 +112,7 @@ struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
+  * @prev_ex: extent before ofs
+  * @next_ex: extent after ofs
+  * @insert_p: insert point for new extent at ofs
+- * in order to simpfy the insertion after.
++ * in order to simplify the insertion after.
+  * tree must stay unchanged between lookup and insertion.
+  */
+ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root,
+@@ -572,7 +572,7 @@ static void f2fs_update_extent_tree_range(struct inode *inode,
+       if (!en)
+               en = next_en;
+-      /* 2. invlidate all extent nodes in range [fofs, fofs + len - 1] */
++      /* 2. invalidate all extent nodes in range [fofs, fofs + len - 1] */
+       while (en && en->ei.fofs < end) {
+               unsigned int org_end;
+               int parts = 0;  /* # of parts current extent split into */
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index e88d4c0f71e3e..367b19f059f3c 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -302,7 +302,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
+                * for OPU case, during fsync(), node can be persisted before
+                * data when lower device doesn't support write barrier, result
+                * in data corruption after SPO.
+-               * So for strict fsync mode, force to use atomic write sematics
++               * So for strict fsync mode, force to use atomic write semantics
+                * to keep write order in between data/node and last node to
+                * avoid potential data corruption.
+                */
+@@ -1746,7 +1746,7 @@ static long f2fs_fallocate(struct file *file, int mode,
+               return -EOPNOTSUPP;
+       /*
+-       * Pinned file should not support partial trucation since the block
++       * Pinned file should not support partial truncation since the block
+        * can be used by applications.
+        */
+       if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
+@@ -1796,7 +1796,7 @@ static long f2fs_fallocate(struct file *file, int mode,
+ static int f2fs_release_file(struct inode *inode, struct file *filp)
+ {
+       /*
+-       * f2fs_relase_file is called at every close calls. So we should
++       * f2fs_release_file is called at every close calls. So we should
+        * not drop any inmemory pages by close called by other process.
+        */
+       if (!(filp->f_mode & FMODE_WRITE) ||
+diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
+index 99e4ec48d2a46..56d23bc254353 100644
+--- a/fs/f2fs/namei.c
++++ b/fs/f2fs/namei.c
+@@ -937,7 +937,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
+       /*
+        * If new_inode is null, the below renaming flow will
+-       * add a link in old_dir which can conver inline_dir.
++       * add a link in old_dir which can convert inline_dir.
+        * After then, if we failed to get the entry due to other
+        * reasons like ENOMEM, we had to remove the new entry.
+        * Instead of adding such the error handling routine, let's
+diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
+index ad30908ac99f3..134a78179e6ff 100644
+--- a/fs/f2fs/segment.c
++++ b/fs/f2fs/segment.c
+@@ -3688,7 +3688,7 @@ void f2fs_wait_on_page_writeback(struct page *page,
+               /* submit cached LFS IO */
+               f2fs_submit_merged_write_cond(sbi, NULL, page, 0, type);
+-              /* sbumit cached IPU IO */
++              /* submit cached IPU IO */
+               f2fs_submit_merged_ipu_write(sbi, NULL, page);
+               if (ordered) {
+                       wait_on_page_writeback(page);
+-- 
+2.43.0
+
diff --git a/queue-5.10/f2fs-introduce-fi_compress_released-instead-of-using.patch b/queue-5.10/f2fs-introduce-fi_compress_released-instead-of-using.patch
new file mode 100644 (file)
index 0000000..ba1aa8d
--- /dev/null
@@ -0,0 +1,156 @@
+From 434dd093827ca34a78abb248dcb598dd4a7256a7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 25 May 2021 11:39:35 -0700
+Subject: f2fs: introduce FI_COMPRESS_RELEASED instead of using IMMUTABLE bit
+
+From: Jaegeuk Kim <jaegeuk@kernel.org>
+
+[ Upstream commit c61404153eb683da9c35aad133131554861ed561 ]
+
+Once we release compressed blocks, we used to set IMMUTABLE bit. But it turned
+out it disallows every fs operations which we don't need for compression.
+
+Let's just prevent writing data only.
+
+Reviewed-by: Chao Yu <yuchao0@huawei.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: 7c5dffb3d90c ("f2fs: compress: fix to relocate check condition in f2fs_{release,reserve}_compress_blocks()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/compress.c      |  3 ++-
+ fs/f2fs/f2fs.h          |  6 ++++++
+ fs/f2fs/file.c          | 18 ++++++++++++------
+ include/linux/f2fs_fs.h |  1 +
+ 4 files changed, 21 insertions(+), 7 deletions(-)
+
+diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
+index 388ed7052d9b6..be6f2988ac7fc 100644
+--- a/fs/f2fs/compress.c
++++ b/fs/f2fs/compress.c
+@@ -902,7 +902,8 @@ static int __f2fs_cluster_blocks(struct inode *inode,
+               }
+               f2fs_bug_on(F2FS_I_SB(inode),
+-                      !compr && ret != cluster_size && !IS_IMMUTABLE(inode));
++                      !compr && ret != cluster_size &&
++                      !is_inode_flag_set(inode, FI_COMPRESS_RELEASED));
+       }
+ fail:
+       f2fs_put_dnode(&dn);
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
+index 6a9f4dcea06d6..4380df9b2d70a 100644
+--- a/fs/f2fs/f2fs.h
++++ b/fs/f2fs/f2fs.h
+@@ -683,6 +683,7 @@ enum {
+       FI_COMPRESS_CORRUPT,    /* indicate compressed cluster is corrupted */
+       FI_MMAP_FILE,           /* indicate file was mmapped */
+       FI_ENABLE_COMPRESS,     /* enable compression in "user" compression mode */
++      FI_COMPRESS_RELEASED,   /* compressed blocks were released */
+       FI_MAX,                 /* max flag, never be used */
+ };
+@@ -2650,6 +2651,7 @@ static inline void __mark_inode_dirty_flag(struct inode *inode,
+       case FI_DATA_EXIST:
+       case FI_INLINE_DOTS:
+       case FI_PIN_FILE:
++      case FI_COMPRESS_RELEASED:
+               f2fs_mark_inode_dirty_sync(inode, true);
+       }
+ }
+@@ -2771,6 +2773,8 @@ static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri)
+               set_bit(FI_EXTRA_ATTR, fi->flags);
+       if (ri->i_inline & F2FS_PIN_FILE)
+               set_bit(FI_PIN_FILE, fi->flags);
++      if (ri->i_inline & F2FS_COMPRESS_RELEASED)
++              set_bit(FI_COMPRESS_RELEASED, fi->flags);
+ }
+ static inline void set_raw_inline(struct inode *inode, struct f2fs_inode *ri)
+@@ -2791,6 +2795,8 @@ static inline void set_raw_inline(struct inode *inode, struct f2fs_inode *ri)
+               ri->i_inline |= F2FS_EXTRA_ATTR;
+       if (is_inode_flag_set(inode, FI_PIN_FILE))
+               ri->i_inline |= F2FS_PIN_FILE;
++      if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED))
++              ri->i_inline |= F2FS_COMPRESS_RELEASED;
+ }
+ static inline int f2fs_has_extra_attr(struct inode *inode)
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 8b136f2dc2d22..cdd2630f4860f 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -63,6 +63,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
+       if (unlikely(IS_IMMUTABLE(inode)))
+               return VM_FAULT_SIGBUS;
++      if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED))
++              return VM_FAULT_SIGBUS;
++
+       if (unlikely(f2fs_cp_error(sbi))) {
+               err = -EIO;
+               goto err;
+@@ -3551,7 +3554,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
+               goto out;
+       }
+-      if (IS_IMMUTABLE(inode)) {
++      if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+               ret = -EINVAL;
+               goto out;
+       }
+@@ -3560,8 +3563,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
+       if (ret)
+               goto out;
+-      F2FS_I(inode)->i_flags |= F2FS_IMMUTABLE_FL;
+-      f2fs_set_inode_flags(inode);
++      set_inode_flag(inode, FI_COMPRESS_RELEASED);
+       inode->i_ctime = current_time(inode);
+       f2fs_mark_inode_dirty_sync(inode, true);
+@@ -3727,7 +3729,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
+       inode_lock(inode);
+-      if (!IS_IMMUTABLE(inode)) {
++      if (!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+               ret = -EINVAL;
+               goto unlock_inode;
+       }
+@@ -3772,8 +3774,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
+       up_write(&F2FS_I(inode)->i_mmap_sem);
+       if (ret >= 0) {
+-              F2FS_I(inode)->i_flags &= ~F2FS_IMMUTABLE_FL;
+-              f2fs_set_inode_flags(inode);
++              clear_inode_flag(inode, FI_COMPRESS_RELEASED);
+               inode->i_ctime = current_time(inode);
+               f2fs_mark_inode_dirty_sync(inode, true);
+       }
+@@ -4130,6 +4131,11 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
+               goto unlock;
+       }
++      if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
++              ret = -EPERM;
++              goto unlock;
++      }
++
+       ret = generic_write_checks(iocb, from);
+       if (ret > 0) {
+               bool preallocated = false;
+diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
+index 7dc2a06cf19a1..9a6082c572199 100644
+--- a/include/linux/f2fs_fs.h
++++ b/include/linux/f2fs_fs.h
+@@ -229,6 +229,7 @@ struct f2fs_extent {
+ #define F2FS_INLINE_DOTS      0x10    /* file having implicit dot dentries */
+ #define F2FS_EXTRA_ATTR               0x20    /* file having extra attribute */
+ #define F2FS_PIN_FILE         0x40    /* file should not be gced */
++#define F2FS_COMPRESS_RELEASED        0x80    /* file released compressed blocks */
+ struct f2fs_inode {
+       __le16 i_mode;                  /* file mode */
+-- 
+2.43.0
+
diff --git a/queue-5.10/firmware-dmi-id-add-a-release-callback-function.patch b/queue-5.10/firmware-dmi-id-add-a-release-callback-function.patch
new file mode 100644 (file)
index 0000000..e2f083c
--- /dev/null
@@ -0,0 +1,50 @@
+From 583fb4b715ff99b53d9818f80227e51eed428033 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 8 Apr 2024 09:34:24 +0200
+Subject: firmware: dmi-id: add a release callback function
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit cf770af5645a41a753c55a053fa1237105b0964a ]
+
+dmi_class uses kfree() as the .release function, but that now causes
+a warning with clang-16 as it violates control flow integrity (KCFI)
+rules:
+
+drivers/firmware/dmi-id.c:174:17: error: cast from 'void (*)(const void *)' to 'void (*)(struct device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
+  174 |         .dev_release = (void(*)(struct device *)) kfree,
+
+Add an explicit function to call kfree() instead.
+
+Fixes: 4f5c791a850e ("DMI-based module autoloading")
+Link: https://lore.kernel.org/lkml/20240213100238.456912-1-arnd@kernel.org/
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Jean Delvare <jdelvare@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/firmware/dmi-id.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
+index 86d71b0212b1b..0cfc60cc267d4 100644
+--- a/drivers/firmware/dmi-id.c
++++ b/drivers/firmware/dmi-id.c
+@@ -164,9 +164,14 @@ static int dmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
+       return 0;
+ }
++static void dmi_dev_release(struct device *dev)
++{
++      kfree(dev);
++}
++
+ static struct class dmi_class = {
+       .name = "dmi",
+-      .dev_release = (void(*)(struct device *)) kfree,
++      .dev_release = dmi_dev_release,
+       .dev_uevent = dmi_dev_uevent,
+ };
+-- 
+2.43.0
+
diff --git a/queue-5.10/fpga-region-add-owner-module-and-take-its-refcount.patch b/queue-5.10/fpga-region-add-owner-module-and-take-its-refcount.patch
new file mode 100644 (file)
index 0000000..2cf2fc0
--- /dev/null
@@ -0,0 +1,210 @@
+From 503fe6d84e3cde8bf2eb08cd9ef33a3645e4e70e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 19 Apr 2024 10:35:59 +0200
+Subject: fpga: region: add owner module and take its refcount
+
+From: Marco Pagani <marpagan@redhat.com>
+
+[ Upstream commit b7c0e1ecee403a43abc89eb3e75672b01ff2ece9 ]
+
+The current implementation of the fpga region assumes that the low-level
+module registers a driver for the parent device and uses its owner pointer
+to take the module's refcount. This approach is problematic since it can
+lead to a null pointer dereference while attempting to get the region
+during programming if the parent device does not have a driver.
+
+To address this problem, add a module owner pointer to the fpga_region
+struct and use it to take the module's refcount. Modify the functions for
+registering a region to take an additional owner module parameter and
+rename them to avoid conflicts. Use the old function names for helper
+macros that automatically set the module that registers the region as the
+owner. This ensures compatibility with existing low-level control modules
+and reduces the chances of registering a region without setting the owner.
+
+Also, update the documentation to keep it consistent with the new interface
+for registering an fpga region.
+
+Fixes: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA")
+Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Suggested-by: Xu Yilun <yilun.xu@intel.com>
+Reviewed-by: Russ Weight <russ.weight@linux.dev>
+Signed-off-by: Marco Pagani <marpagan@redhat.com>
+Acked-by: Xu Yilun <yilun.xu@intel.com>
+Link: https://lore.kernel.org/r/20240419083601.77403-1-marpagan@redhat.com
+Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/driver-api/fpga/fpga-region.rst | 13 ++++++----
+ drivers/fpga/fpga-region.c                    | 24 +++++++++++--------
+ include/linux/fpga/fpga-region.h              | 13 +++++++---
+ 3 files changed, 32 insertions(+), 18 deletions(-)
+
+diff --git a/Documentation/driver-api/fpga/fpga-region.rst b/Documentation/driver-api/fpga/fpga-region.rst
+index dc55d60a0b4a5..2d03b5fb76575 100644
+--- a/Documentation/driver-api/fpga/fpga-region.rst
++++ b/Documentation/driver-api/fpga/fpga-region.rst
+@@ -46,13 +46,16 @@ API to add a new FPGA region
+ ----------------------------
+ * struct fpga_region - The FPGA region struct
+-* struct fpga_region_info - Parameter structure for fpga_region_register_full()
+-* fpga_region_register_full() -  Create and register an FPGA region using the
++* struct fpga_region_info - Parameter structure for __fpga_region_register_full()
++* __fpga_region_register_full() -  Create and register an FPGA region using the
+   fpga_region_info structure to provide the full flexibility of options
+-* fpga_region_register() -  Create and register an FPGA region using standard
++* __fpga_region_register() -  Create and register an FPGA region using standard
+   arguments
+ * fpga_region_unregister() -  Unregister an FPGA region
++Helper macros ``fpga_region_register()`` and ``fpga_region_register_full()``
++automatically set the module that registers the FPGA region as the owner.
++
+ The FPGA region's probe function will need to get a reference to the FPGA
+ Manager it will be using to do the programming.  This usually would happen
+ during the region's probe function.
+@@ -82,10 +85,10 @@ following APIs to handle building or tearing down that list.
+    :functions: fpga_region_info
+ .. kernel-doc:: drivers/fpga/fpga-region.c
+-   :functions: fpga_region_register_full
++   :functions: __fpga_region_register_full
+ .. kernel-doc:: drivers/fpga/fpga-region.c
+-   :functions: fpga_region_register
++   :functions: __fpga_region_register
+ .. kernel-doc:: drivers/fpga/fpga-region.c
+    :functions: fpga_region_unregister
+diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
+index b0ac18de4885d..d73daea579ac7 100644
+--- a/drivers/fpga/fpga-region.c
++++ b/drivers/fpga/fpga-region.c
+@@ -52,7 +52,7 @@ static struct fpga_region *fpga_region_get(struct fpga_region *region)
+       }
+       get_device(dev);
+-      if (!try_module_get(dev->parent->driver->owner)) {
++      if (!try_module_get(region->ops_owner)) {
+               put_device(dev);
+               mutex_unlock(&region->mutex);
+               return ERR_PTR(-ENODEV);
+@@ -74,7 +74,7 @@ static void fpga_region_put(struct fpga_region *region)
+       dev_dbg(dev, "put\n");
+-      module_put(dev->parent->driver->owner);
++      module_put(region->ops_owner);
+       put_device(dev);
+       mutex_unlock(&region->mutex);
+ }
+@@ -180,14 +180,16 @@ static struct attribute *fpga_region_attrs[] = {
+ ATTRIBUTE_GROUPS(fpga_region);
+ /**
+- * fpga_region_register_full - create and register an FPGA Region device
++ * __fpga_region_register_full - create and register an FPGA Region device
+  * @parent: device parent
+  * @info: parameters for FPGA Region
++ * @owner: module containing the get_bridges function
+  *
+  * Return: struct fpga_region or ERR_PTR()
+  */
+ struct fpga_region *
+-fpga_region_register_full(struct device *parent, const struct fpga_region_info *info)
++__fpga_region_register_full(struct device *parent, const struct fpga_region_info *info,
++                          struct module *owner)
+ {
+       struct fpga_region *region;
+       int id, ret = 0;
+@@ -212,6 +214,7 @@ fpga_region_register_full(struct device *parent, const struct fpga_region_info *
+       region->compat_id = info->compat_id;
+       region->priv = info->priv;
+       region->get_bridges = info->get_bridges;
++      region->ops_owner = owner;
+       mutex_init(&region->mutex);
+       INIT_LIST_HEAD(&region->bridge_list);
+@@ -240,13 +243,14 @@ fpga_region_register_full(struct device *parent, const struct fpga_region_info *
+       return ERR_PTR(ret);
+ }
+-EXPORT_SYMBOL_GPL(fpga_region_register_full);
++EXPORT_SYMBOL_GPL(__fpga_region_register_full);
+ /**
+- * fpga_region_register - create and register an FPGA Region device
++ * __fpga_region_register - create and register an FPGA Region device
+  * @parent: device parent
+  * @mgr: manager that programs this region
+  * @get_bridges: optional function to get bridges to a list
++ * @owner: module containing the get_bridges function
+  *
+  * This simple version of the register function should be sufficient for most users.
+  * The fpga_region_register_full() function is available for users that need to
+@@ -255,17 +259,17 @@ EXPORT_SYMBOL_GPL(fpga_region_register_full);
+  * Return: struct fpga_region or ERR_PTR()
+  */
+ struct fpga_region *
+-fpga_region_register(struct device *parent, struct fpga_manager *mgr,
+-                   int (*get_bridges)(struct fpga_region *))
++__fpga_region_register(struct device *parent, struct fpga_manager *mgr,
++                     int (*get_bridges)(struct fpga_region *), struct module *owner)
+ {
+       struct fpga_region_info info = { 0 };
+       info.mgr = mgr;
+       info.get_bridges = get_bridges;
+-      return fpga_region_register_full(parent, &info);
++      return __fpga_region_register_full(parent, &info, owner);
+ }
+-EXPORT_SYMBOL_GPL(fpga_region_register);
++EXPORT_SYMBOL_GPL(__fpga_region_register);
+ /**
+  * fpga_region_unregister - unregister an FPGA region
+diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h
+index 3b87f232425c9..1c446c2ce2f9c 100644
+--- a/include/linux/fpga/fpga-region.h
++++ b/include/linux/fpga/fpga-region.h
+@@ -36,6 +36,7 @@ struct fpga_region_info {
+  * @mgr: FPGA manager
+  * @info: FPGA image info
+  * @compat_id: FPGA region id for compatibility check.
++ * @ops_owner: module containing the get_bridges function
+  * @priv: private data
+  * @get_bridges: optional function to get bridges to a list
+  */
+@@ -46,6 +47,7 @@ struct fpga_region {
+       struct fpga_manager *mgr;
+       struct fpga_image_info *info;
+       struct fpga_compat_id *compat_id;
++      struct module *ops_owner;
+       void *priv;
+       int (*get_bridges)(struct fpga_region *region);
+ };
+@@ -58,12 +60,17 @@ struct fpga_region *fpga_region_class_find(
+ int fpga_region_program_fpga(struct fpga_region *region);
++#define fpga_region_register_full(parent, info) \
++      __fpga_region_register_full(parent, info, THIS_MODULE)
+ struct fpga_region *
+-fpga_region_register_full(struct device *parent, const struct fpga_region_info *info);
++__fpga_region_register_full(struct device *parent, const struct fpga_region_info *info,
++                          struct module *owner);
++#define fpga_region_register(parent, mgr, get_bridges) \
++      __fpga_region_register(parent, mgr, get_bridges, THIS_MODULE)
+ struct fpga_region *
+-fpga_region_register(struct device *parent, struct fpga_manager *mgr,
+-                   int (*get_bridges)(struct fpga_region *));
++__fpga_region_register(struct device *parent, struct fpga_manager *mgr,
++                     int (*get_bridges)(struct fpga_region *), struct module *owner);
+ void fpga_region_unregister(struct fpga_region *region);
+ #endif /* _FPGA_REGION_H */
+-- 
+2.43.0
+
diff --git a/queue-5.10/fpga-region-change-fpga-indirect-article-to-an.patch b/queue-5.10/fpga-region-change-fpga-indirect-article-to-an.patch
new file mode 100644 (file)
index 0000000..45e7b74
--- /dev/null
@@ -0,0 +1,84 @@
+From c120350a3d65e540db49516bf1a4fd961f0d083e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 8 Jun 2021 14:23:47 -0700
+Subject: fpga: region: change FPGA indirect article to an
+
+From: Tom Rix <trix@redhat.com>
+
+[ Upstream commit 011c49e3703854e52c0fb88f22cf38aca1d4d514 ]
+
+Change use of 'a fpga' to 'an fpga'
+
+Signed-off-by: Tom Rix <trix@redhat.com>
+Link: https://lore.kernel.org/r/20210608212350.3029742-10-trix@redhat.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: b7c0e1ecee40 ("fpga: region: add owner module and take its refcount")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/fpga/fpga-region.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
+index c3134b89c3fe5..c5c55d2f20b92 100644
+--- a/drivers/fpga/fpga-region.c
++++ b/drivers/fpga/fpga-region.c
+@@ -33,14 +33,14 @@ struct fpga_region *fpga_region_class_find(
+ EXPORT_SYMBOL_GPL(fpga_region_class_find);
+ /**
+- * fpga_region_get - get an exclusive reference to a fpga region
++ * fpga_region_get - get an exclusive reference to an fpga region
+  * @region: FPGA Region struct
+  *
+  * Caller should call fpga_region_put() when done with region.
+  *
+  * Return fpga_region struct if successful.
+  * Return -EBUSY if someone already has a reference to the region.
+- * Return -ENODEV if @np is not a FPGA Region.
++ * Return -ENODEV if @np is not an FPGA Region.
+  */
+ static struct fpga_region *fpga_region_get(struct fpga_region *region)
+ {
+@@ -234,7 +234,7 @@ struct fpga_region
+ EXPORT_SYMBOL_GPL(fpga_region_create);
+ /**
+- * fpga_region_free - free a FPGA region created by fpga_region_create()
++ * fpga_region_free - free an FPGA region created by fpga_region_create()
+  * @region: FPGA region
+  */
+ void fpga_region_free(struct fpga_region *region)
+@@ -257,7 +257,7 @@ static void devm_fpga_region_release(struct device *dev, void *res)
+  * @mgr: manager that programs this region
+  * @get_bridges: optional function to get bridges to a list
+  *
+- * This function is intended for use in a FPGA region driver's probe function.
++ * This function is intended for use in an FPGA region driver's probe function.
+  * After the region driver creates the region struct with
+  * devm_fpga_region_create(), it should register it with fpga_region_register().
+  * The region driver's remove function should call fpga_region_unregister().
+@@ -291,7 +291,7 @@ struct fpga_region
+ EXPORT_SYMBOL_GPL(devm_fpga_region_create);
+ /**
+- * fpga_region_register - register a FPGA region
++ * fpga_region_register - register an FPGA region
+  * @region: FPGA region
+  *
+  * Return: 0 or -errno
+@@ -303,10 +303,10 @@ int fpga_region_register(struct fpga_region *region)
+ EXPORT_SYMBOL_GPL(fpga_region_register);
+ /**
+- * fpga_region_unregister - unregister a FPGA region
++ * fpga_region_unregister - unregister an FPGA region
+  * @region: FPGA region
+  *
+- * This function is intended for use in a FPGA region driver's remove function.
++ * This function is intended for use in an FPGA region driver's remove function.
+  */
+ void fpga_region_unregister(struct fpga_region *region)
+ {
+-- 
+2.43.0
+
diff --git a/queue-5.10/fpga-region-rename-dev-to-parent-for-parent-device.patch b/queue-5.10/fpga-region-rename-dev-to-parent-for-parent-device.patch
new file mode 100644 (file)
index 0000000..eb713a8
--- /dev/null
@@ -0,0 +1,92 @@
+From 236c5d278ffeca62c1848f52b7d4a69fffbb3c69 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 14 Jun 2021 10:09:06 -0700
+Subject: fpga: region: Rename dev to parent for parent device
+
+From: Russ Weight <russell.h.weight@intel.com>
+
+[ Upstream commit 5e77886d0aa9a882424f6a4ccb3eca4dca43b4a0 ]
+
+Rename variable "dev" to "parent" in cases where it represents the parent
+device.
+
+Signed-off-by: Russ Weight <russell.h.weight@intel.com>
+Reviewed-by: Xu Yilun <yilun.xu@intel.com>
+Signed-off-by: Moritz Fischer <mdf@kernel.org>
+Link: https://lore.kernel.org/r/20210614170909.232415-6-mdf@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: b7c0e1ecee40 ("fpga: region: add owner module and take its refcount")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/fpga/fpga-region.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
+index c5c55d2f20b92..a4838715221ff 100644
+--- a/drivers/fpga/fpga-region.c
++++ b/drivers/fpga/fpga-region.c
+@@ -181,7 +181,7 @@ ATTRIBUTE_GROUPS(fpga_region);
+ /**
+  * fpga_region_create - alloc and init a struct fpga_region
+- * @dev: device parent
++ * @parent: device parent
+  * @mgr: manager that programs this region
+  * @get_bridges: optional function to get bridges to a list
+  *
+@@ -192,7 +192,7 @@ ATTRIBUTE_GROUPS(fpga_region);
+  * Return: struct fpga_region or NULL
+  */
+ struct fpga_region
+-*fpga_region_create(struct device *dev,
++*fpga_region_create(struct device *parent,
+                   struct fpga_manager *mgr,
+                   int (*get_bridges)(struct fpga_region *))
+ {
+@@ -214,8 +214,8 @@ struct fpga_region
+       device_initialize(&region->dev);
+       region->dev.class = fpga_region_class;
+-      region->dev.parent = dev;
+-      region->dev.of_node = dev->of_node;
++      region->dev.parent = parent;
++      region->dev.of_node = parent->of_node;
+       region->dev.id = id;
+       ret = dev_set_name(&region->dev, "region%d", id);
+@@ -253,7 +253,7 @@ static void devm_fpga_region_release(struct device *dev, void *res)
+ /**
+  * devm_fpga_region_create - create and initialize a managed FPGA region struct
+- * @dev: device parent
++ * @parent: device parent
+  * @mgr: manager that programs this region
+  * @get_bridges: optional function to get bridges to a list
+  *
+@@ -268,7 +268,7 @@ static void devm_fpga_region_release(struct device *dev, void *res)
+  * Return: struct fpga_region or NULL
+  */
+ struct fpga_region
+-*devm_fpga_region_create(struct device *dev,
++*devm_fpga_region_create(struct device *parent,
+                        struct fpga_manager *mgr,
+                        int (*get_bridges)(struct fpga_region *))
+ {
+@@ -278,12 +278,12 @@ struct fpga_region
+       if (!ptr)
+               return NULL;
+-      region = fpga_region_create(dev, mgr, get_bridges);
++      region = fpga_region_create(parent, mgr, get_bridges);
+       if (!region) {
+               devres_free(ptr);
+       } else {
+               *ptr = region;
+-              devres_add(dev, ptr);
++              devres_add(parent, ptr);
+       }
+       return region;
+-- 
+2.43.0
+
diff --git a/queue-5.10/fpga-region-use-standard-dev_release-for-class-drive.patch b/queue-5.10/fpga-region-use-standard-dev_release-for-class-drive.patch
new file mode 100644 (file)
index 0000000..7198f22
--- /dev/null
@@ -0,0 +1,394 @@
+From 69e4ed8dc9a4f35659c221635393c15a38252916 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Nov 2021 17:55:53 -0800
+Subject: fpga: region: Use standard dev_release for class driver
+
+From: Russ Weight <russell.h.weight@intel.com>
+
+[ Upstream commit 8886a579744fbfa53e69aa453ed10ae3b1f9abac ]
+
+The FPGA region class driver data structure is being treated as a
+managed resource instead of using the standard dev_release call-back
+function to release the class data structure. This change removes the
+managed resource code and combines the create() and register()
+functions into a single register() or register_full() function.
+
+The register_full() function accepts an info data structure to provide
+flexibility in passing optional parameters. The register() function
+supports the current parameter list for users that don't require the
+use of optional parameters.
+
+Signed-off-by: Russ Weight <russell.h.weight@intel.com>
+Reviewed-by: Xu Yilun <yilun.xu@intel.com>
+Acked-by: Xu Yilun <yilun.xu@intel.com>
+Signed-off-by: Moritz Fischer <mdf@kernel.org>
+Stable-dep-of: b7c0e1ecee40 ("fpga: region: add owner module and take its refcount")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/driver-api/fpga/fpga-region.rst |  12 +-
+ drivers/fpga/dfl-fme-region.c                 |  17 ++-
+ drivers/fpga/dfl.c                            |  12 +-
+ drivers/fpga/fpga-region.c                    | 119 +++++++-----------
+ drivers/fpga/of-fpga-region.c                 |  10 +-
+ include/linux/fpga/fpga-region.h              |  36 ++++--
+ 6 files changed, 95 insertions(+), 111 deletions(-)
+
+diff --git a/Documentation/driver-api/fpga/fpga-region.rst b/Documentation/driver-api/fpga/fpga-region.rst
+index 2636a27c11b24..dc55d60a0b4a5 100644
+--- a/Documentation/driver-api/fpga/fpga-region.rst
++++ b/Documentation/driver-api/fpga/fpga-region.rst
+@@ -46,8 +46,11 @@ API to add a new FPGA region
+ ----------------------------
+ * struct fpga_region - The FPGA region struct
+-* devm_fpga_region_create() - Allocate and init a region struct
+-* fpga_region_register() -  Register an FPGA region
++* struct fpga_region_info - Parameter structure for fpga_region_register_full()
++* fpga_region_register_full() -  Create and register an FPGA region using the
++  fpga_region_info structure to provide the full flexibility of options
++* fpga_region_register() -  Create and register an FPGA region using standard
++  arguments
+ * fpga_region_unregister() -  Unregister an FPGA region
+ The FPGA region's probe function will need to get a reference to the FPGA
+@@ -75,8 +78,11 @@ following APIs to handle building or tearing down that list.
+ .. kernel-doc:: include/linux/fpga/fpga-region.h
+    :functions: fpga_region
++.. kernel-doc:: include/linux/fpga/fpga-region.h
++   :functions: fpga_region_info
++
+ .. kernel-doc:: drivers/fpga/fpga-region.c
+-   :functions: devm_fpga_region_create
++   :functions: fpga_region_register_full
+ .. kernel-doc:: drivers/fpga/fpga-region.c
+    :functions: fpga_region_register
+diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c
+index 1eeb42af10122..4aebde0a7f1c3 100644
+--- a/drivers/fpga/dfl-fme-region.c
++++ b/drivers/fpga/dfl-fme-region.c
+@@ -30,6 +30,7 @@ static int fme_region_get_bridges(struct fpga_region *region)
+ static int fme_region_probe(struct platform_device *pdev)
+ {
+       struct dfl_fme_region_pdata *pdata = dev_get_platdata(&pdev->dev);
++      struct fpga_region_info info = { 0 };
+       struct device *dev = &pdev->dev;
+       struct fpga_region *region;
+       struct fpga_manager *mgr;
+@@ -39,20 +40,18 @@ static int fme_region_probe(struct platform_device *pdev)
+       if (IS_ERR(mgr))
+               return -EPROBE_DEFER;
+-      region = devm_fpga_region_create(dev, mgr, fme_region_get_bridges);
+-      if (!region) {
+-              ret = -ENOMEM;
++      info.mgr = mgr;
++      info.compat_id = mgr->compat_id;
++      info.get_bridges = fme_region_get_bridges;
++      info.priv = pdata;
++      region = fpga_region_register_full(dev, &info);
++      if (IS_ERR(region)) {
++              ret = PTR_ERR(region);
+               goto eprobe_mgr_put;
+       }
+-      region->priv = pdata;
+-      region->compat_id = mgr->compat_id;
+       platform_set_drvdata(pdev, region);
+-      ret = fpga_region_register(region);
+-      if (ret)
+-              goto eprobe_mgr_put;
+-
+       dev_dbg(dev, "DFL FME FPGA Region probed\n");
+       return 0;
+diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
+index eb8a6e329af9b..ae220365fc04f 100644
+--- a/drivers/fpga/dfl.c
++++ b/drivers/fpga/dfl.c
+@@ -1400,19 +1400,15 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info)
+       if (!cdev)
+               return ERR_PTR(-ENOMEM);
+-      cdev->region = devm_fpga_region_create(info->dev, NULL, NULL);
+-      if (!cdev->region) {
+-              ret = -ENOMEM;
+-              goto free_cdev_exit;
+-      }
+-
+       cdev->parent = info->dev;
+       mutex_init(&cdev->lock);
+       INIT_LIST_HEAD(&cdev->port_dev_list);
+-      ret = fpga_region_register(cdev->region);
+-      if (ret)
++      cdev->region = fpga_region_register(info->dev, NULL, NULL);
++      if (IS_ERR(cdev->region)) {
++              ret = PTR_ERR(cdev->region);
+               goto free_cdev_exit;
++      }
+       /* create and init build info for enumeration */
+       binfo = devm_kzalloc(info->dev, sizeof(*binfo), GFP_KERNEL);
+diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
+index a4838715221ff..b0ac18de4885d 100644
+--- a/drivers/fpga/fpga-region.c
++++ b/drivers/fpga/fpga-region.c
+@@ -180,39 +180,42 @@ static struct attribute *fpga_region_attrs[] = {
+ ATTRIBUTE_GROUPS(fpga_region);
+ /**
+- * fpga_region_create - alloc and init a struct fpga_region
++ * fpga_region_register_full - create and register an FPGA Region device
+  * @parent: device parent
+- * @mgr: manager that programs this region
+- * @get_bridges: optional function to get bridges to a list
+- *
+- * The caller of this function is responsible for freeing the resulting region
+- * struct with fpga_region_free().  Using devm_fpga_region_create() instead is
+- * recommended.
++ * @info: parameters for FPGA Region
+  *
+- * Return: struct fpga_region or NULL
++ * Return: struct fpga_region or ERR_PTR()
+  */
+-struct fpga_region
+-*fpga_region_create(struct device *parent,
+-                  struct fpga_manager *mgr,
+-                  int (*get_bridges)(struct fpga_region *))
++struct fpga_region *
++fpga_region_register_full(struct device *parent, const struct fpga_region_info *info)
+ {
+       struct fpga_region *region;
+       int id, ret = 0;
++      if (!info) {
++              dev_err(parent,
++                      "Attempt to register without required info structure\n");
++              return ERR_PTR(-EINVAL);
++      }
++
+       region = kzalloc(sizeof(*region), GFP_KERNEL);
+       if (!region)
+-              return NULL;
++              return ERR_PTR(-ENOMEM);
+       id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL);
+-      if (id < 0)
++      if (id < 0) {
++              ret = id;
+               goto err_free;
++      }
++
++      region->mgr = info->mgr;
++      region->compat_id = info->compat_id;
++      region->priv = info->priv;
++      region->get_bridges = info->get_bridges;
+-      region->mgr = mgr;
+-      region->get_bridges = get_bridges;
+       mutex_init(&region->mutex);
+       INIT_LIST_HEAD(&region->bridge_list);
+-      device_initialize(&region->dev);
+       region->dev.class = fpga_region_class;
+       region->dev.parent = parent;
+       region->dev.of_node = parent->of_node;
+@@ -222,6 +225,12 @@ struct fpga_region
+       if (ret)
+               goto err_remove;
++      ret = device_register(&region->dev);
++      if (ret) {
++              put_device(&region->dev);
++              return ERR_PTR(ret);
++      }
++
+       return region;
+ err_remove:
+@@ -229,76 +238,32 @@ struct fpga_region
+ err_free:
+       kfree(region);
+-      return NULL;
+-}
+-EXPORT_SYMBOL_GPL(fpga_region_create);
+-
+-/**
+- * fpga_region_free - free an FPGA region created by fpga_region_create()
+- * @region: FPGA region
+- */
+-void fpga_region_free(struct fpga_region *region)
+-{
+-      ida_simple_remove(&fpga_region_ida, region->dev.id);
+-      kfree(region);
+-}
+-EXPORT_SYMBOL_GPL(fpga_region_free);
+-
+-static void devm_fpga_region_release(struct device *dev, void *res)
+-{
+-      struct fpga_region *region = *(struct fpga_region **)res;
+-
+-      fpga_region_free(region);
++      return ERR_PTR(ret);
+ }
++EXPORT_SYMBOL_GPL(fpga_region_register_full);
+ /**
+- * devm_fpga_region_create - create and initialize a managed FPGA region struct
++ * fpga_region_register - create and register an FPGA Region device
+  * @parent: device parent
+  * @mgr: manager that programs this region
+  * @get_bridges: optional function to get bridges to a list
+  *
+- * This function is intended for use in an FPGA region driver's probe function.
+- * After the region driver creates the region struct with
+- * devm_fpga_region_create(), it should register it with fpga_region_register().
+- * The region driver's remove function should call fpga_region_unregister().
+- * The region struct allocated with this function will be freed automatically on
+- * driver detach.  This includes the case of a probe function returning error
+- * before calling fpga_region_register(), the struct will still get cleaned up.
++ * This simple version of the register function should be sufficient for most users.
++ * The fpga_region_register_full() function is available for users that need to
++ * pass additional, optional parameters.
+  *
+- * Return: struct fpga_region or NULL
++ * Return: struct fpga_region or ERR_PTR()
+  */
+-struct fpga_region
+-*devm_fpga_region_create(struct device *parent,
+-                       struct fpga_manager *mgr,
+-                       int (*get_bridges)(struct fpga_region *))
++struct fpga_region *
++fpga_region_register(struct device *parent, struct fpga_manager *mgr,
++                   int (*get_bridges)(struct fpga_region *))
+ {
+-      struct fpga_region **ptr, *region;
+-
+-      ptr = devres_alloc(devm_fpga_region_release, sizeof(*ptr), GFP_KERNEL);
+-      if (!ptr)
+-              return NULL;
++      struct fpga_region_info info = { 0 };
+-      region = fpga_region_create(parent, mgr, get_bridges);
+-      if (!region) {
+-              devres_free(ptr);
+-      } else {
+-              *ptr = region;
+-              devres_add(parent, ptr);
+-      }
++      info.mgr = mgr;
++      info.get_bridges = get_bridges;
+-      return region;
+-}
+-EXPORT_SYMBOL_GPL(devm_fpga_region_create);
+-
+-/**
+- * fpga_region_register - register an FPGA region
+- * @region: FPGA region
+- *
+- * Return: 0 or -errno
+- */
+-int fpga_region_register(struct fpga_region *region)
+-{
+-      return device_add(&region->dev);
++      return fpga_region_register_full(parent, &info);
+ }
+ EXPORT_SYMBOL_GPL(fpga_region_register);
+@@ -316,6 +281,10 @@ EXPORT_SYMBOL_GPL(fpga_region_unregister);
+ static void fpga_region_dev_release(struct device *dev)
+ {
++      struct fpga_region *region = to_fpga_region(dev);
++
++      ida_simple_remove(&fpga_region_ida, region->dev.id);
++      kfree(region);
+ }
+ /**
+diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c
+index e405309baadc1..466e083654ae1 100644
+--- a/drivers/fpga/of-fpga-region.c
++++ b/drivers/fpga/of-fpga-region.c
+@@ -405,16 +405,12 @@ static int of_fpga_region_probe(struct platform_device *pdev)
+       if (IS_ERR(mgr))
+               return -EPROBE_DEFER;
+-      region = devm_fpga_region_create(dev, mgr, of_fpga_region_get_bridges);
+-      if (!region) {
+-              ret = -ENOMEM;
++      region = fpga_region_register(dev, mgr, of_fpga_region_get_bridges);
++      if (IS_ERR(region)) {
++              ret = PTR_ERR(region);
+               goto eprobe_mgr_put;
+       }
+-      ret = fpga_region_register(region);
+-      if (ret)
+-              goto eprobe_mgr_put;
+-
+       of_platform_populate(np, fpga_region_of_match, NULL, &region->dev);
+       platform_set_drvdata(pdev, region);
+diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h
+index 27cb706275dba..3b87f232425c9 100644
+--- a/include/linux/fpga/fpga-region.h
++++ b/include/linux/fpga/fpga-region.h
+@@ -7,6 +7,27 @@
+ #include <linux/fpga/fpga-mgr.h>
+ #include <linux/fpga/fpga-bridge.h>
++struct fpga_region;
++
++/**
++ * struct fpga_region_info - collection of parameters an FPGA Region
++ * @mgr: fpga region manager
++ * @compat_id: FPGA region id for compatibility check.
++ * @priv: fpga region private data
++ * @get_bridges: optional function to get bridges to a list
++ *
++ * fpga_region_info contains parameters for the register_full function.
++ * These are separated into an info structure because they some are optional
++ * others could be added to in the future. The info structure facilitates
++ * maintaining a stable API.
++ */
++struct fpga_region_info {
++      struct fpga_manager *mgr;
++      struct fpga_compat_id *compat_id;
++      void *priv;
++      int (*get_bridges)(struct fpga_region *region);
++};
++
+ /**
+  * struct fpga_region - FPGA Region structure
+  * @dev: FPGA Region device
+@@ -37,15 +58,12 @@ struct fpga_region *fpga_region_class_find(
+ int fpga_region_program_fpga(struct fpga_region *region);
+-struct fpga_region
+-*fpga_region_create(struct device *dev, struct fpga_manager *mgr,
+-                  int (*get_bridges)(struct fpga_region *));
+-void fpga_region_free(struct fpga_region *region);
+-int fpga_region_register(struct fpga_region *region);
+-void fpga_region_unregister(struct fpga_region *region);
++struct fpga_region *
++fpga_region_register_full(struct device *parent, const struct fpga_region_info *info);
+-struct fpga_region
+-*devm_fpga_region_create(struct device *dev, struct fpga_manager *mgr,
+-                      int (*get_bridges)(struct fpga_region *));
++struct fpga_region *
++fpga_region_register(struct device *parent, struct fpga_manager *mgr,
++                   int (*get_bridges)(struct fpga_region *));
++void fpga_region_unregister(struct fpga_region *region);
+ #endif /* _FPGA_REGION_H */
+-- 
+2.43.0
+
diff --git a/queue-5.10/greybus-arche-ctrl-move-device-table-to-its-right-lo.patch b/queue-5.10/greybus-arche-ctrl-move-device-table-to-its-right-lo.patch
new file mode 100644 (file)
index 0000000..1c93c69
--- /dev/null
@@ -0,0 +1,66 @@
+From aa995dd8a1a7b150b700b4a625de386df239d737 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Apr 2024 10:06:35 +0200
+Subject: greybus: arche-ctrl: move device table to its right location
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit 6a0b8c0da8d8d418cde6894a104cf74e6098ddfa ]
+
+The arche-ctrl has two platform drivers and three of_device_id tables,
+but one table is only used for the the module loader, while the other
+two seem to be associated with their drivers.
+
+This leads to a W=1 warning when the driver is built-in:
+
+drivers/staging/greybus/arche-platform.c:623:34: error: 'arche_combined_id' defined but not used [-Werror=unused-const-variable=]
+  623 | static const struct of_device_id arche_combined_id[] = {
+
+Drop the extra table and register both tables that are actually
+used as the ones for the module loader instead.
+
+Fixes: 7b62b61c752a ("greybus: arche-ctrl: Don't expose driver internals to arche-platform driver")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Link: https://lore.kernel.org/r/20240403080702.3509288-18-arnd@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/staging/greybus/arche-apb-ctrl.c | 1 +
+ drivers/staging/greybus/arche-platform.c | 9 +--------
+ 2 files changed, 2 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c
+index bbf3ba744fc44..c7383c6c6094d 100644
+--- a/drivers/staging/greybus/arche-apb-ctrl.c
++++ b/drivers/staging/greybus/arche-apb-ctrl.c
+@@ -468,6 +468,7 @@ static const struct of_device_id arche_apb_ctrl_of_match[] = {
+       { .compatible = "usbffff,2", },
+       { },
+ };
++MODULE_DEVICE_TABLE(of, arche_apb_ctrl_of_match);
+ static struct platform_driver arche_apb_ctrl_device_driver = {
+       .probe          = arche_apb_ctrl_probe,
+diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
+index eebf0deb39f50..02a700f720e6d 100644
+--- a/drivers/staging/greybus/arche-platform.c
++++ b/drivers/staging/greybus/arche-platform.c
+@@ -622,14 +622,7 @@ static const struct of_device_id arche_platform_of_match[] = {
+       { .compatible = "google,arche-platform", },
+       { },
+ };
+-
+-static const struct of_device_id arche_combined_id[] = {
+-      /* Use PID/VID of SVC device */
+-      { .compatible = "google,arche-platform", },
+-      { .compatible = "usbffff,2", },
+-      { },
+-};
+-MODULE_DEVICE_TABLE(of, arche_combined_id);
++MODULE_DEVICE_TABLE(of, arche_platform_of_match);
+ static struct platform_driver arche_platform_device_driver = {
+       .probe          = arche_platform_probe,
+-- 
+2.43.0
+
diff --git a/queue-5.10/greybus-lights-check-return-of-get_channel_from_mode.patch b/queue-5.10/greybus-lights-check-return-of-get_channel_from_mode.patch
new file mode 100644 (file)
index 0000000..31e7182
--- /dev/null
@@ -0,0 +1,59 @@
+From c0a7dd9f85b0b00eeaab583e271ea0331b0ed416 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 25 Mar 2024 22:09:55 +0000
+Subject: greybus: lights: check return of get_channel_from_mode
+
+From: Rui Miguel Silva <rmfrfs@gmail.com>
+
+[ Upstream commit a1ba19a1ae7cd1e324685ded4ab563e78fe68648 ]
+
+If channel for the given node is not found we return null from
+get_channel_from_mode. Make sure we validate the return pointer
+before using it in two of the missing places.
+
+This was originally reported in [0]:
+Found by Linux Verification Center (linuxtesting.org) with SVACE.
+
+[0] https://lore.kernel.org/all/20240301190425.120605-1-m.lobanov@rosalinux.ru
+
+Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
+Reported-by: Mikhail Lobanov <m.lobanov@rosalinux.ru>
+Suggested-by: Mikhail Lobanov <m.lobanov@rosalinux.ru>
+Suggested-by: Alex Elder <elder@ieee.org>
+Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
+Link: https://lore.kernel.org/r/20240325221549.2185265-1-rmfrfs@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/staging/greybus/light.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
+index e59bb27236b9f..7352d7deb8ba0 100644
+--- a/drivers/staging/greybus/light.c
++++ b/drivers/staging/greybus/light.c
+@@ -147,6 +147,9 @@ static int __gb_lights_flash_brightness_set(struct gb_channel *channel)
+               channel = get_channel_from_mode(channel->light,
+                                               GB_CHANNEL_MODE_TORCH);
++      if (!channel)
++              return -EINVAL;
++
+       /* For not flash we need to convert brightness to intensity */
+       intensity = channel->intensity_uA.min +
+                       (channel->intensity_uA.step * channel->led->brightness);
+@@ -550,7 +553,10 @@ static int gb_lights_light_v4l2_register(struct gb_light *light)
+       }
+       channel_flash = get_channel_from_mode(light, GB_CHANNEL_MODE_FLASH);
+-      WARN_ON(!channel_flash);
++      if (!channel_flash) {
++              dev_err(dev, "failed to get flash channel from mode\n");
++              return -EINVAL;
++      }
+       fled = &channel_flash->fled;
+-- 
+2.43.0
+
diff --git a/queue-5.10/iio-pressure-dps310-support-negative-temperature-val.patch b/queue-5.10/iio-pressure-dps310-support-negative-temperature-val.patch
new file mode 100644 (file)
index 0000000..7d6335b
--- /dev/null
@@ -0,0 +1,67 @@
+From 8e6057cf8c94e2d2aa73f34256cac9b2dbdf884c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 15 Apr 2024 12:50:27 +0200
+Subject: iio: pressure: dps310: support negative temperature values
+
+From: Thomas Haemmerle <thomas.haemmerle@leica-geosystems.com>
+
+[ Upstream commit 9dd6b32e76ff714308964cd9ec91466a343dcb8b ]
+
+The current implementation interprets negative values returned from
+`dps310_calculate_temp` as error codes.
+This has a side effect that when negative temperature values are
+calculated, they are interpreted as error.
+
+Fix this by using the return value only for error handling and passing a
+pointer for the value.
+
+Fixes: ba6ec48e76bc ("iio: Add driver for Infineon DPS310")
+Signed-off-by: Thomas Haemmerle <thomas.haemmerle@leica-geosystems.com>
+Link: https://lore.kernel.org/r/20240415105030.1161770-2-thomas.haemmerle@leica-geosystems.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/pressure/dps310.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
+index 1b6b9530f1662..7fdc7a0147f0e 100644
+--- a/drivers/iio/pressure/dps310.c
++++ b/drivers/iio/pressure/dps310.c
+@@ -730,7 +730,7 @@ static int dps310_read_pressure(struct dps310_data *data, int *val, int *val2,
+       }
+ }
+-static int dps310_calculate_temp(struct dps310_data *data)
++static int dps310_calculate_temp(struct dps310_data *data, int *val)
+ {
+       s64 c0;
+       s64 t;
+@@ -746,7 +746,9 @@ static int dps310_calculate_temp(struct dps310_data *data)
+       t = c0 + ((s64)data->temp_raw * (s64)data->c1);
+       /* Convert to milliCelsius and scale the temperature */
+-      return (int)div_s64(t * 1000LL, kt);
++      *val = (int)div_s64(t * 1000LL, kt);
++
++      return 0;
+ }
+ static int dps310_read_temp(struct dps310_data *data, int *val, int *val2,
+@@ -768,11 +770,10 @@ static int dps310_read_temp(struct dps310_data *data, int *val, int *val2,
+               if (rc)
+                       return rc;
+-              rc = dps310_calculate_temp(data);
+-              if (rc < 0)
++              rc = dps310_calculate_temp(data, val);
++              if (rc)
+                       return rc;
+-              *val = rc;
+               return IIO_VAL_INT;
+       case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
+-- 
+2.43.0
+
diff --git a/queue-5.10/libsubcmd-fix-parse-options-memory-leak.patch b/queue-5.10/libsubcmd-fix-parse-options-memory-leak.patch
new file mode 100644 (file)
index 0000000..6047a7b
--- /dev/null
@@ -0,0 +1,61 @@
+From 6525c2f48901707146f03c80925ff0f7d40f87bd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 May 2024 22:20:15 -0700
+Subject: libsubcmd: Fix parse-options memory leak
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 230a7a71f92212e723fa435d4ca5922de33ec88a ]
+
+If a usage string is built in parse_options_subcommand, also free it.
+
+Fixes: 901421a5bdf605d2 ("perf tools: Remove subcmd dependencies on strbuf")
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Josh Poimboeuf <jpoimboe@kernel.org>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: https://lore.kernel.org/r/20240509052015.1914670-1-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/lib/subcmd/parse-options.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
+index 39ebf6192016d..e799d35cba434 100644
+--- a/tools/lib/subcmd/parse-options.c
++++ b/tools/lib/subcmd/parse-options.c
+@@ -633,11 +633,10 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o
+                       const char *const subcommands[], const char *usagestr[], int flags)
+ {
+       struct parse_opt_ctx_t ctx;
++      char *buf = NULL;
+       /* build usage string if it's not provided */
+       if (subcommands && !usagestr[0]) {
+-              char *buf = NULL;
+-
+               astrcatf(&buf, "%s %s [<options>] {", subcmd_config.exec_name, argv[0]);
+               for (int i = 0; subcommands[i]; i++) {
+@@ -679,7 +678,10 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o
+                       astrcatf(&error_buf, "unknown switch `%c'", *ctx.opt);
+               usage_with_options(usagestr, options);
+       }
+-
++      if (buf) {
++              usagestr[0] = NULL;
++              free(buf);
++      }
+       return parse_options_end(&ctx);
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/microblaze-remove-early-printk-call-from-cpuinfo-sta.patch b/queue-5.10/microblaze-remove-early-printk-call-from-cpuinfo-sta.patch
new file mode 100644 (file)
index 0000000..8e16178
--- /dev/null
@@ -0,0 +1,37 @@
+From aef55aaa57efc2b2865a2219ad6b5cd6a4b5e05f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 11 Apr 2024 10:27:21 +0200
+Subject: microblaze: Remove early printk call from cpuinfo-static.c
+
+From: Michal Simek <michal.simek@amd.com>
+
+[ Upstream commit 58d647506c92ccd3cfa0c453c68ddd14f40bf06f ]
+
+Early printk has been removed already that's why also remove calling it.
+Similar change has been done in cpuinfo-pvr-full.c by commit cfbd8d1979af
+("microblaze: Remove early printk setup").
+
+Fixes: 96f0e6fcc9ad ("microblaze: remove redundant early_printk support")
+Signed-off-by: Michal Simek <michal.simek@amd.com>
+Link: https://lore.kernel.org/r/2f10db506be8188fa07b6ec331caca01af1b10f8.1712824039.git.michal.simek@amd.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/microblaze/kernel/cpu/cpuinfo-static.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/microblaze/kernel/cpu/cpuinfo-static.c b/arch/microblaze/kernel/cpu/cpuinfo-static.c
+index 85dbda4a08a81..03da36dc6d9c9 100644
+--- a/arch/microblaze/kernel/cpu/cpuinfo-static.c
++++ b/arch/microblaze/kernel/cpu/cpuinfo-static.c
+@@ -18,7 +18,7 @@ static const char family_string[] = CONFIG_XILINX_MICROBLAZE0_FAMILY;
+ static const char cpu_ver_string[] = CONFIG_XILINX_MICROBLAZE0_HW_VER;
+ #define err_printk(x) \
+-      early_printk("ERROR: Microblaze " x "-different for kernel and DTS\n");
++      pr_err("ERROR: Microblaze " x "-different for kernel and DTS\n");
+ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)
+ {
+-- 
+2.43.0
+
diff --git a/queue-5.10/microblaze-remove-gcc-flag-for-non-existing-early_pr.patch b/queue-5.10/microblaze-remove-gcc-flag-for-non-existing-early_pr.patch
new file mode 100644 (file)
index 0000000..91fbc00
--- /dev/null
@@ -0,0 +1,36 @@
+From dda0fd4a2936e9168be8c2e6b007aace61081fbe Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 11 Apr 2024 10:21:44 +0200
+Subject: microblaze: Remove gcc flag for non existing early_printk.c file
+
+From: Michal Simek <michal.simek@amd.com>
+
+[ Upstream commit edc66cf0c4164aa3daf6cc55e970bb94383a6a57 ]
+
+early_printk support for removed long time ago but compilation flag for
+ftrace still points to already removed file that's why remove that line
+too.
+
+Fixes: 96f0e6fcc9ad ("microblaze: remove redundant early_printk support")
+Signed-off-by: Michal Simek <michal.simek@amd.com>
+Link: https://lore.kernel.org/r/5493467419cd2510a32854e2807bcd263de981a0.1712823702.git.michal.simek@amd.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/microblaze/kernel/Makefile | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile
+index dd71637437f4f..8b9d52b194cb4 100644
+--- a/arch/microblaze/kernel/Makefile
++++ b/arch/microblaze/kernel/Makefile
+@@ -7,7 +7,6 @@ ifdef CONFIG_FUNCTION_TRACER
+ # Do not trace early boot code and low level code
+ CFLAGS_REMOVE_timer.o = -pg
+ CFLAGS_REMOVE_intc.o = -pg
+-CFLAGS_REMOVE_early_printk.o = -pg
+ CFLAGS_REMOVE_ftrace.o = -pg
+ CFLAGS_REMOVE_process.o = -pg
+ endif
+-- 
+2.43.0
+
diff --git a/queue-5.10/ovl-remove-upper-umask-handling-from-ovl_create_uppe.patch b/queue-5.10/ovl-remove-upper-umask-handling-from-ovl_create_uppe.patch
new file mode 100644 (file)
index 0000000..3b775a5
--- /dev/null
@@ -0,0 +1,39 @@
+From 730dc47c2c52ae70aa724aaafe8eb36b2032f7e7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 May 2024 20:35:57 +0200
+Subject: ovl: remove upper umask handling from ovl_create_upper()
+
+From: Miklos Szeredi <mszeredi@redhat.com>
+
+[ Upstream commit 096802748ea1dea8b476938e0a8dc16f4bd2f1ad ]
+
+This is already done by vfs_prepare_mode() when creating the upper object
+by vfs_create(), vfs_mkdir() and vfs_mknod().
+
+No regressions have been observed in xfstests run with posix acls turned
+off for the upper filesystem.
+
+Fixes: 1639a49ccdce ("fs: move S_ISGID stripping into the vfs_*() helpers")
+Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/overlayfs/dir.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
+index a7021c87bfcb0..470ff30851b4d 100644
+--- a/fs/overlayfs/dir.c
++++ b/fs/overlayfs/dir.c
+@@ -323,9 +323,6 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
+       struct dentry *newdentry;
+       int err;
+-      if (!attr->hardlink && !IS_POSIXACL(udir))
+-              attr->mode &= ~current_umask();
+-
+       inode_lock_nested(udir, I_MUTEX_PARENT);
+       newdentry = ovl_create_real(udir,
+                                   lookup_one_len(dentry->d_name.name,
+-- 
+2.43.0
+
diff --git a/queue-5.10/pci-edr-align-edr_port_dpc_enable_dsm-with-pci-firmw.patch b/queue-5.10/pci-edr-align-edr_port_dpc_enable_dsm-with-pci-firmw.patch
new file mode 100644 (file)
index 0000000..36c43c7
--- /dev/null
@@ -0,0 +1,71 @@
+From 4cb7c50083316a5598bea0b5f715a52ecc8f0751 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 May 2024 02:25:43 +0000
+Subject: PCI/EDR: Align EDR_PORT_DPC_ENABLE_DSM with PCI Firmware r3.3
+
+From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
+
+[ Upstream commit f24ba846133d0edec785ac6430d4daf6e9c93a09 ]
+
+The "Downstream Port Containment related Enhancements" ECN of Jan 28, 2019
+(document 12888 below), defined the EDR_PORT_DPC_ENABLE_DSM function with
+Revision ID 5 with Arg3 being an integer.  But when the ECN was integrated
+into PCI Firmware r3.3, sec 4.6.12, it was defined as Revision ID 6 with
+Arg3 being a package containing an integer.
+
+The implementation in acpi_enable_dpc() supplies a package as Arg3 (arg4 in
+the code), but it previously specified Revision ID 5.  Align this with PCI
+Firmware r3.3 by using Revision ID 6.
+
+If firmware implemented per the ECN, its Revision 5 function would receive
+a package as Arg3 when it expects an integer, so acpi_enable_dpc() would
+likely fail.  If such firmware exists and lacks a Revision 6 function that
+expects a package, we may have to add support for Revision 5.
+
+Link: https://lore.kernel.org/r/20240501022543.1626025-1-sathyanarayanan.kuppuswamy@linux.intel.com
+Link: https://members.pcisig.com/wg/PCI-SIG/document/12888
+Fixes: ac1c8e35a326 ("PCI/DPC: Add Error Disconnect Recover (EDR) support")
+Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
+[bhelgaas: split into two patches, update commit log]
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Tested-by: Satish Thatchanamurthy <Satish.Thatchanamurt@Dell.com> # one platform
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/pcie/edr.c | 13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/pci/pcie/edr.c b/drivers/pci/pcie/edr.c
+index 87734e4c3c204..5b5a502363c00 100644
+--- a/drivers/pci/pcie/edr.c
++++ b/drivers/pci/pcie/edr.c
+@@ -32,10 +32,10 @@ static int acpi_enable_dpc(struct pci_dev *pdev)
+       int status = 0;
+       /*
+-       * Behavior when calling unsupported _DSM functions is undefined,
+-       * so check whether EDR_PORT_DPC_ENABLE_DSM is supported.
++       * Per PCI Firmware r3.3, sec 4.6.12, EDR_PORT_DPC_ENABLE_DSM is
++       * optional. Return success if it's not implemented.
+        */
+-      if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
++      if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 6,
+                           1ULL << EDR_PORT_DPC_ENABLE_DSM))
+               return 0;
+@@ -46,12 +46,7 @@ static int acpi_enable_dpc(struct pci_dev *pdev)
+       argv4.package.count = 1;
+       argv4.package.elements = &req;
+-      /*
+-       * Per Downstream Port Containment Related Enhancements ECN to PCI
+-       * Firmware Specification r3.2, sec 4.6.12, EDR_PORT_DPC_ENABLE_DSM is
+-       * optional.  Return success if it's not implemented.
+-       */
+-      obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
++      obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, 6,
+                               EDR_PORT_DPC_ENABLE_DSM, &argv4);
+       if (!obj)
+               return 0;
+-- 
+2.43.0
+
diff --git a/queue-5.10/pci-edr-align-edr_port_locate_dsm-with-pci-firmware-.patch b/queue-5.10/pci-edr-align-edr_port_locate_dsm-with-pci-firmware-.patch
new file mode 100644 (file)
index 0000000..c28a2c7
--- /dev/null
@@ -0,0 +1,65 @@
+From 64f5625e466ddea7ccbcb62852fccc52e6515768 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 May 2024 14:31:38 -0500
+Subject: PCI/EDR: Align EDR_PORT_LOCATE_DSM with PCI Firmware r3.3
+
+From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
+
+[ Upstream commit e2e78a294a8a863898b781dbcf90e087eda3155d ]
+
+The "Downstream Port Containment related Enhancements" ECN of Jan 28, 2019
+(document 12888 below), defined the EDR_PORT_LOCATE_DSM function with
+Revision ID 5 with a return value encoding (Bits 2:0 = Function, Bits 7:3 =
+Device, Bits 15:8 = Bus).  When the ECN was integrated into PCI Firmware
+r3.3, sec 4.6.13, Bit 31 was added to indicate success or failure.
+
+Check Bit 31 for failure in acpi_dpc_port_get().
+
+Link: https://lore.kernel.org/r/20240501022543.1626025-1-sathyanarayanan.kuppuswamy@linux.intel.com
+Link: https://members.pcisig.com/wg/PCI-SIG/document/12888
+Fixes: ac1c8e35a326 ("PCI/DPC: Add Error Disconnect Recover (EDR) support")
+Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
+[bhelgaas: split into two patches, update commit log]
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Tested-by: Satish Thatchanamurthy <Satish.Thatchanamurt@Dell.com> # one platform
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/pcie/edr.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/pci/pcie/edr.c b/drivers/pci/pcie/edr.c
+index 5b5a502363c00..35210007602c5 100644
+--- a/drivers/pci/pcie/edr.c
++++ b/drivers/pci/pcie/edr.c
+@@ -80,8 +80,9 @@ static struct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev)
+       u16 port;
+       /*
+-       * Behavior when calling unsupported _DSM functions is undefined,
+-       * so check whether EDR_PORT_DPC_ENABLE_DSM is supported.
++       * If EDR_PORT_LOCATE_DSM is not implemented under the target of
++       * EDR, the target is the port that experienced the containment
++       * event (PCI Firmware r3.3, sec 4.6.13).
+        */
+       if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
+                           1ULL << EDR_PORT_LOCATE_DSM))
+@@ -98,6 +99,16 @@ static struct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev)
+               return NULL;
+       }
++      /*
++       * Bit 31 represents the success/failure of the operation. If bit
++       * 31 is set, the operation failed.
++       */
++      if (obj->integer.value & BIT(31)) {
++              ACPI_FREE(obj);
++              pci_err(pdev, "Locate Port _DSM failed\n");
++              return NULL;
++      }
++
+       /*
+        * Firmware returns DPC port BDF details in following format:
+        *      15:8 = bus
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-annotate-add-demangle-and-demangle-kernel.patch b/queue-5.10/perf-annotate-add-demangle-and-demangle-kernel.patch
new file mode 100644 (file)
index 0000000..04dc5b2
--- /dev/null
@@ -0,0 +1,62 @@
+From 5c4f71950a66fe00f105ee3cf400a58c5508034e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 30 Mar 2021 20:33:55 +0200
+Subject: perf annotate: Add --demangle and --demangle-kernel
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Martin Liška <mliska@suse.cz>
+
+[ Upstream commit 3406ac5347dbf64ab9f7b137ed25a18493f5ea2d ]
+
+'perf annotate' supports --symbol but it's impossible to filter a C++
+symbol. With --no-demangle one can filter easily by mangled function
+name.
+
+Signed-off-by: Martin Liška <mliska@suse.cz>
+Link: http://lore.kernel.org/lkml/c3c7e959-9f7f-18e2-e795-f604275cbac3@suse.cz
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 374af9f1f06b ("perf annotate: Get rid of duplicate --group option item")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/Documentation/perf-annotate.txt | 7 +++++++
+ tools/perf/builtin-annotate.c              | 4 ++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
+index 1b5042f134a86..80c1be5d566cb 100644
+--- a/tools/perf/Documentation/perf-annotate.txt
++++ b/tools/perf/Documentation/perf-annotate.txt
+@@ -124,6 +124,13 @@ OPTIONS
+ --group::
+       Show event group information together
++--demangle::
++      Demangle symbol names to human readable form. It's enabled by default,
++      disable with --no-demangle.
++
++--demangle-kernel::
++      Demangle kernel symbol names to human readable form (for C++ kernels).
++
+ --percent-type::
+       Set annotation percent type from following choices:
+         global-period, local-period, global-hits, local-hits
+diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
+index 4940d10074c3e..8059cf12cce86 100644
+--- a/tools/perf/builtin-annotate.c
++++ b/tools/perf/builtin-annotate.c
+@@ -538,6 +538,10 @@ int cmd_annotate(int argc, const char **argv)
+                   "Strip first N entries of source file path name in programs (with --prefix)"),
+       OPT_STRING(0, "objdump", &annotate.opts.objdump_path, "path",
+                  "objdump binary to use for disassembly and annotations"),
++      OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
++                  "Enable symbol demangling"),
++      OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
++                  "Enable kernel symbol demangling"),
+       OPT_BOOLEAN(0, "group", &symbol_conf.event_group,
+                   "Show event group information together"),
+       OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-annotate-get-rid-of-duplicate-group-option-item.patch b/queue-5.10/perf-annotate-get-rid-of-duplicate-group-option-item.patch
new file mode 100644 (file)
index 0000000..0fbb10a
--- /dev/null
@@ -0,0 +1,48 @@
+From 70ad563333c47fe171be973657fae186560e9fbb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 22 Mar 2024 15:43:12 -0700
+Subject: perf annotate: Get rid of duplicate --group option item
+
+From: Namhyung Kim <namhyung@kernel.org>
+
+[ Upstream commit 374af9f1f06b5e991c810d2e4983d6f58df32136 ]
+
+The options array in cmd_annotate() has duplicate --group options.  It
+only needs one and let's get rid of the other.
+
+  $ perf annotate -h 2>&1 | grep group
+        --group           Show event group information together
+        --group           Show event group information together
+
+Fixes: 7ebaf4890f63eb90 ("perf annotate: Support '--group' option")
+Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
+Signed-off-by: Namhyung Kim <namhyung@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Jin Yao <yao.jin@linux.intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: https://lore.kernel.org/r/20240322224313.423181-1-namhyung@kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/builtin-annotate.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
+index 8059cf12cce86..d8e8359c97a15 100644
+--- a/tools/perf/builtin-annotate.c
++++ b/tools/perf/builtin-annotate.c
+@@ -542,8 +542,6 @@ int cmd_annotate(int argc, const char **argv)
+                   "Enable symbol demangling"),
+       OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
+                   "Enable kernel symbol demangling"),
+-      OPT_BOOLEAN(0, "group", &symbol_conf.event_group,
+-                  "Show event group information together"),
+       OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
+                   "Show a column with the sum of periods"),
+       OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-bench-internals-inject-build-id-fix-trap-divide.patch b/queue-5.10/perf-bench-internals-inject-build-id-fix-trap-divide.patch
new file mode 100644 (file)
index 0000000..365ddc1
--- /dev/null
@@ -0,0 +1,55 @@
+From 954de3a31c3ebb3d0b512edd437f3d46adc2b494 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 May 2024 14:50:26 +0800
+Subject: perf bench internals inject-build-id: Fix trap divide when collecting
+ just one DSO
+
+From: He Zhe <zhe.he@windriver.com>
+
+[ Upstream commit d9180e23fbfa3875424d3a6b28b71b072862a52a ]
+
+'perf bench internals inject-build-id' suffers from the following error when
+only one DSO is collected.
+
+  # perf bench internals inject-build-id -v
+    Collected 1 DSOs
+  traps: internals-injec[2305] trap divide error
+  ip:557566ba6394 sp:7ffd4de97fe0 error:0 in perf[557566b2a000+23d000]
+    Build-id injection benchmark
+    Iteration #1
+  Floating point exception
+
+This patch removes the unnecessary minus one from the divisor which also
+corrects the randomization range.
+
+Signed-off-by: He Zhe <zhe.he@windriver.com>
+Fixes: 0bf02a0d80427f26 ("perf bench: Add build-id injection benchmark")
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Link: https://lore.kernel.org/r/20240507065026.2652929-1-zhe.he@windriver.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/bench/inject-buildid.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/perf/bench/inject-buildid.c b/tools/perf/bench/inject-buildid.c
+index f4ec01da8da68..922b3c3837642 100644
+--- a/tools/perf/bench/inject-buildid.c
++++ b/tools/perf/bench/inject-buildid.c
+@@ -361,7 +361,7 @@ static int inject_build_id(struct bench_data *data, u64 *max_rss)
+               return -1;
+       for (i = 0; i < nr_mmaps; i++) {
+-              int idx = rand() % (nr_dsos - 1);
++              int idx = rand() % nr_dsos;
+               struct bench_dso *dso = &dsos[idx];
+               u64 timestamp = rand() % 1000000;
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-evlist-use-the-right-prefix-for-struct-evlist-s.patch b/queue-5.10/perf-evlist-use-the-right-prefix-for-struct-evlist-s.patch
new file mode 100644 (file)
index 0000000..c69444a
--- /dev/null
@@ -0,0 +1,144 @@
+From d6856c4a1a34386a80b784789774a285afb3080a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Nov 2020 09:40:10 -0300
+Subject: perf evlist: Use the right prefix for 'struct evlist' sideband thread
+ methods
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+[ Upstream commit 08c83997ca87f9e162563a59ea43eabadc9e4231 ]
+
+perf_evlist__ is for 'struct perf_evlist' methods, in tools/lib/perf/,
+go on completing this split.
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 88ce0106a1f6 ("perf record: Delete session after stopping sideband thread")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/builtin-record.c       |  4 ++--
+ tools/perf/builtin-top.c          |  4 ++--
+ tools/perf/util/bpf-event.c       |  2 +-
+ tools/perf/util/evlist.h          | 11 ++++-------
+ tools/perf/util/sideband_evlist.c |  8 ++++----
+ 5 files changed, 13 insertions(+), 16 deletions(-)
+
+diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
+index 167cd8d3b7a21..a7d9f00382d9f 100644
+--- a/tools/perf/builtin-record.c
++++ b/tools/perf/builtin-record.c
+@@ -1548,7 +1548,7 @@ static int record__setup_sb_evlist(struct record *rec)
+               }
+       }
+ #endif
+-      if (perf_evlist__start_sb_thread(rec->sb_evlist, &rec->opts.target)) {
++      if (evlist__start_sb_thread(rec->sb_evlist, &rec->opts.target)) {
+               pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n");
+               opts->no_bpf_event = true;
+       }
+@@ -2066,7 +2066,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
+       perf_session__delete(session);
+       if (!opts->no_bpf_event)
+-              perf_evlist__stop_sb_thread(rec->sb_evlist);
++              evlist__stop_sb_thread(rec->sb_evlist);
+       return status;
+ }
+diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
+index ee30372f77133..2cf4791290263 100644
+--- a/tools/perf/builtin-top.c
++++ b/tools/perf/builtin-top.c
+@@ -1763,7 +1763,7 @@ int cmd_top(int argc, const char **argv)
+       }
+ #endif
+-      if (perf_evlist__start_sb_thread(top.sb_evlist, target)) {
++      if (evlist__start_sb_thread(top.sb_evlist, target)) {
+               pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n");
+               opts->no_bpf_event = true;
+       }
+@@ -1771,7 +1771,7 @@ int cmd_top(int argc, const char **argv)
+       status = __cmd_top(&top);
+       if (!opts->no_bpf_event)
+-              perf_evlist__stop_sb_thread(top.sb_evlist);
++              evlist__stop_sb_thread(top.sb_evlist);
+ out_delete_evlist:
+       evlist__delete(top.evlist);
+diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
+index c50d2c7a264fe..fccc4bf20c74f 100644
+--- a/tools/perf/util/bpf-event.c
++++ b/tools/perf/util/bpf-event.c
+@@ -530,7 +530,7 @@ int evlist__add_bpf_sb_event(struct evlist *evlist, struct perf_env *env)
+        */
+       attr.wakeup_watermark = 1;
+-      return perf_evlist__add_sb_event(evlist, &attr, bpf_event__sb_cb, env);
++      return evlist__add_sb_event(evlist, &attr, bpf_event__sb_cb, env);
+ }
+ void __bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
+diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
+index 9298fce53ea31..8b00e9a7c0fe2 100644
+--- a/tools/perf/util/evlist.h
++++ b/tools/perf/util/evlist.h
+@@ -112,14 +112,11 @@ int __evlist__add_default_attrs(struct evlist *evlist,
+ int evlist__add_dummy(struct evlist *evlist);
+-int perf_evlist__add_sb_event(struct evlist *evlist,
+-                            struct perf_event_attr *attr,
+-                            evsel__sb_cb_t cb,
+-                            void *data);
++int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr,
++                       evsel__sb_cb_t cb, void *data);
+ void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data);
+-int perf_evlist__start_sb_thread(struct evlist *evlist,
+-                               struct target *target);
+-void perf_evlist__stop_sb_thread(struct evlist *evlist);
++int evlist__start_sb_thread(struct evlist *evlist, struct target *target);
++void evlist__stop_sb_thread(struct evlist *evlist);
+ int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler);
+diff --git a/tools/perf/util/sideband_evlist.c b/tools/perf/util/sideband_evlist.c
+index ded9ced027973..90ed016bb3489 100644
+--- a/tools/perf/util/sideband_evlist.c
++++ b/tools/perf/util/sideband_evlist.c
+@@ -12,8 +12,8 @@
+ #include <sched.h>
+ #include <stdbool.h>
+-int perf_evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr,
+-                            evsel__sb_cb_t cb, void *data)
++int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr,
++                       evsel__sb_cb_t cb, void *data)
+ {
+       struct evsel *evsel;
+@@ -94,7 +94,7 @@ void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data)
+       }
+ }
+-int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target)
++int evlist__start_sb_thread(struct evlist *evlist, struct target *target)
+ {
+       struct evsel *counter;
+@@ -138,7 +138,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target)
+       return -1;
+ }
+-void perf_evlist__stop_sb_thread(struct evlist *evlist)
++void evlist__stop_sb_thread(struct evlist *evlist)
+ {
+       if (!evlist)
+               return;
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-intel-pt-fix-unassigned-instruction-op-discover.patch b/queue-5.10/perf-intel-pt-fix-unassigned-instruction-op-discover.patch
new file mode 100644 (file)
index 0000000..804508d
--- /dev/null
@@ -0,0 +1,73 @@
+From 4ae1c79165b270be6efbd6758a5fb9175072b10d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 26 Mar 2024 10:32:23 +0200
+Subject: perf intel-pt: Fix unassigned instruction op (discovered by
+ MemorySanitizer)
+
+From: Adrian Hunter <adrian.hunter@intel.com>
+
+[ Upstream commit e101a05f79fd4ee3e89d2f3fb716493c33a33708 ]
+
+MemorySanitizer discovered instances where the instruction op value was
+not assigned.:
+
+  WARNING: MemorySanitizer: use-of-uninitialized-value
+    #0 0x5581c00a76b3 in intel_pt_sample_flags tools/perf/util/intel-pt.c:1527:17
+  Uninitialized value was stored to memory at
+    #0 0x5581c005ddf8 in intel_pt_walk_insn tools/perf/util/intel-pt-decoder/intel-pt-decoder.c:1256:25
+
+The op value is used to set branch flags for branch instructions
+encountered when walking the code, so fix by setting op to
+INTEL_PT_OP_OTHER in other cases.
+
+Fixes: 4c761d805bb2d2ea ("perf intel-pt: Fix intel_pt_fup_event() assumptions about setting state type")
+Reported-by: Ian Rogers <irogers@google.com>
+Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
+Tested-by: Ian Rogers <irogers@google.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Closes: https://lore.kernel.org/linux-perf-users/20240320162619.1272015-1-irogers@google.com/
+Link: https://lore.kernel.org/r/20240326083223.10883-1-adrian.hunter@intel.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 ++
+ tools/perf/util/intel-pt.c                          | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+index 48fda1a19ab5b..6cbd4b4973042 100644
+--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+@@ -1118,6 +1118,8 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder)
+       bool ret = false;
+       decoder->state.type &= ~INTEL_PT_BRANCH;
++      decoder->state.insn_op = INTEL_PT_OP_OTHER;
++      decoder->state.insn_len = 0;
+       if (decoder->set_fup_tx_flags) {
+               decoder->set_fup_tx_flags = false;
+diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
+index 453773ce6f455..32192b7ac79e8 100644
+--- a/tools/perf/util/intel-pt.c
++++ b/tools/perf/util/intel-pt.c
+@@ -574,6 +574,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
+       bool one_map = true;
+       intel_pt_insn->length = 0;
++      intel_pt_insn->op = INTEL_PT_OP_OTHER;
+       if (to_ip && *ip == to_ip)
+               goto out_no_cache;
+@@ -649,6 +650,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
+                       if (to_ip && *ip == to_ip) {
+                               intel_pt_insn->length = 0;
++                              intel_pt_insn->op = INTEL_PT_OP_OTHER;
+                               goto out_no_cache;
+                       }
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-probe-add-missing-libgen.h-header-needed-for-us.patch b/queue-5.10/perf-probe-add-missing-libgen.h-header-needed-for-us.patch
new file mode 100644 (file)
index 0000000..382aecd
--- /dev/null
@@ -0,0 +1,53 @@
+From 6d5643a7bf0a6e537809f389caf6e2d102ca64ff Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 21 Mar 2024 11:13:30 -0300
+Subject: perf probe: Add missing libgen.h header needed for using basename()
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+[ Upstream commit 581037151910126a7934e369e4b6ac70eda9a703 ]
+
+This prototype is obtained indirectly, by luck, from some other header
+in probe-event.c in most systems, but recently exploded on alpine:edge:
+
+   8    13.39 alpine:edge                   : FAIL gcc version 13.2.1 20240309 (Alpine 13.2.1_git20240309)
+    util/probe-event.c: In function 'convert_exec_to_group':
+    util/probe-event.c:225:16: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration]
+      225 |         ptr1 = basename(exec_copy);
+          |                ^~~~~~~~
+    util/probe-event.c:225:14: error: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
+      225 |         ptr1 = basename(exec_copy);
+          |              ^
+    cc1: all warnings being treated as errors
+    make[3]: *** [/git/perf-6.8.0/tools/build/Makefile.build:158: util] Error 2
+
+Fix it by adding the libgen.h header where basename() is prototyped.
+
+Fixes: fb7345bbf7fad9bf ("perf probe: Support basic dwarf-based operations on uprobe events")
+Cc: Masami Hiramatsu <mhiramat@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Link: https://lore.kernel.org/lkml/
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/util/probe-event.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
+index 97e2a72bd6f5e..42ba3046f25ec 100644
+--- a/tools/perf/util/probe-event.c
++++ b/tools/perf/util/probe-event.c
+@@ -11,6 +11,7 @@
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <errno.h>
++#include <libgen.h>
+ #include <stdio.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-record-delete-session-after-stopping-sideband-t.patch b/queue-5.10/perf-record-delete-session-after-stopping-sideband-t.patch
new file mode 100644 (file)
index 0000000..0069d78
--- /dev/null
@@ -0,0 +1,83 @@
+From 58503fdef7614ef8ce8380e09d0a5e0c25541408 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 29 Feb 2024 23:46:36 -0800
+Subject: perf record: Delete session after stopping sideband thread
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 88ce0106a1f603bf360cb397e8fe293f8298fabb ]
+
+The session has a header in it which contains a perf env with
+bpf_progs. The bpf_progs are accessed by the sideband thread and so
+the sideband thread must be stopped before the session is deleted, to
+avoid a use after free.  This error was detected by AddressSanitizer
+in the following:
+
+  ==2054673==ERROR: AddressSanitizer: heap-use-after-free on address 0x61d000161e00 at pc 0x55769289de54 bp 0x7f9df36d4ab0 sp 0x7f9df36d4aa8
+  READ of size 8 at 0x61d000161e00 thread T1
+      #0 0x55769289de53 in __perf_env__insert_bpf_prog_info util/env.c:42
+      #1 0x55769289dbb1 in perf_env__insert_bpf_prog_info util/env.c:29
+      #2 0x557692bbae29 in perf_env__add_bpf_info util/bpf-event.c:483
+      #3 0x557692bbb01a in bpf_event__sb_cb util/bpf-event.c:512
+      #4 0x5576928b75f4 in perf_evlist__poll_thread util/sideband_evlist.c:68
+      #5 0x7f9df96a63eb in start_thread nptl/pthread_create.c:444
+      #6 0x7f9df9726a4b in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
+
+  0x61d000161e00 is located 384 bytes inside of 2136-byte region [0x61d000161c80,0x61d0001624d8)
+  freed by thread T0 here:
+      #0 0x7f9dfa6d7288 in __interceptor_free libsanitizer/asan/asan_malloc_linux.cpp:52
+      #1 0x557692978d50 in perf_session__delete util/session.c:319
+      #2 0x557692673959 in __cmd_record tools/perf/builtin-record.c:2884
+      #3 0x55769267a9f0 in cmd_record tools/perf/builtin-record.c:4259
+      #4 0x55769286710c in run_builtin tools/perf/perf.c:349
+      #5 0x557692867678 in handle_internal_command tools/perf/perf.c:402
+      #6 0x557692867a40 in run_argv tools/perf/perf.c:446
+      #7 0x557692867fae in main tools/perf/perf.c:562
+      #8 0x7f9df96456c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
+
+Fixes: 657ee5531903339b ("perf evlist: Introduce side band thread")
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
+Cc: Christian Brauner <brauner@kernel.org>
+Cc: Disha Goel <disgoel@linux.ibm.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: James Clark <james.clark@arm.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kajol Jain <kjain@linux.ibm.com>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: K Prateek Nayak <kprateek.nayak@amd.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Song Liu <songliubraving@fb.com>
+Cc: Tim Chen <tim.c.chen@linux.intel.com>
+Cc: Yicong Yang <yangyicong@hisilicon.com>
+Link: https://lore.kernel.org/r/20240301074639.2260708-1-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/builtin-record.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
+index a7d9f00382d9f..44bd12aa0e062 100644
+--- a/tools/perf/builtin-record.c
++++ b/tools/perf/builtin-record.c
+@@ -2063,10 +2063,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
+               close(done_fd);
+ #endif
+       zstd_fini(&session->zstd_data);
+-      perf_session__delete(session);
+-
+       if (!opts->no_bpf_event)
+               evlist__stop_sb_thread(rec->sb_evlist);
++
++      perf_session__delete(session);
+       return status;
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-report-avoid-segv-in-report__setup_sample_type.patch b/queue-5.10/perf-report-avoid-segv-in-report__setup_sample_type.patch
new file mode 100644 (file)
index 0000000..da3340b
--- /dev/null
@@ -0,0 +1,47 @@
+From e31d1a015908f4ff68479cdf8f1a3e85e53365ea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 May 2024 20:53:00 -0700
+Subject: perf report: Avoid SEGV in report__setup_sample_type()
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 45b4f402a6b782352c4bafcff682bfb01da9ca05 ]
+
+In some cases evsel->name is lazily initialized in evsel__name(). If not
+initialized passing NULL to strstr() leads to a SEGV.
+
+Fixes: ccb17caecfbd542f ("perf report: Set PERF_SAMPLE_DATA_SRC bit for Arm SPE event")
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: James Clark <james.clark@arm.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: Leo Yan <leo.yan@linux.dev>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: https://lore.kernel.org/r/20240508035301.1554434-4-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/builtin-report.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
+index b55ee073c2f72..6283c2d10d27d 100644
+--- a/tools/perf/builtin-report.c
++++ b/tools/perf/builtin-report.c
+@@ -401,7 +401,7 @@ static int report__setup_sample_type(struct report *rep)
+                * compatibility, set the bit if it's an old perf data file.
+                */
+               evlist__for_each_entry(session->evlist, evsel) {
+-                      if (strstr(evsel->name, "arm_spe") &&
++                      if (strstr(evsel__name(evsel), "arm_spe") &&
+                               !(sample_type & PERF_SAMPLE_DATA_SRC)) {
+                               evsel->core.attr.sample_type |= PERF_SAMPLE_DATA_SRC;
+                               sample_type |= PERF_SAMPLE_DATA_SRC;
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-stat-don-t-display-metric-header-for-non-leader.patch b/queue-5.10/perf-stat-don-t-display-metric-header-for-non-leader.patch
new file mode 100644 (file)
index 0000000..9bb30ba
--- /dev/null
@@ -0,0 +1,90 @@
+From f177112505abf499d10c2c692409fbc6c06922ea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 May 2024 22:13:09 -0700
+Subject: perf stat: Don't display metric header for non-leader uncore events
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 193a9e30207f54777ff42d0d8be8389edc522277 ]
+
+On an Intel tigerlake laptop a metric like:
+
+    {
+        "BriefDescription": "Test",
+        "MetricExpr": "imc_free_running@data_read@ + imc_free_running@data_write@",
+        "MetricGroup": "Test",
+        "MetricName": "Test",
+        "ScaleUnit": "6.103515625e-5MiB"
+    },
+
+Will have 4 events:
+
+  uncore_imc_free_running_0/data_read/
+  uncore_imc_free_running_0/data_write/
+  uncore_imc_free_running_1/data_read/
+  uncore_imc_free_running_1/data_write/
+
+If aggregration is disabled with metric-only 2 column headers are
+needed:
+
+  $ perf stat -M test --metric-only -A -a sleep 1
+
+   Performance counter stats for 'system wide':
+
+                    MiB  Test            MiB  Test
+  CPU0                 1821.0               1820.5
+
+But when not, the counts aggregated in the metric leader and only 1
+column should be shown:
+
+  $ perf stat -M test --metric-only -a sleep 1
+   Performance counter stats for 'system wide':
+
+              MiB  Test
+                5909.4
+
+         1.001258915 seconds time elapsed
+
+Achieve this by skipping events that aren't metric leaders when
+printing column headers and aggregation isn't disabled.
+
+The bug is long standing, the fixes tag is set to a refactor as that
+is as far back as is reasonable to backport.
+
+Fixes: 088519f318be3a41 ("perf stat: Move the display functions to stat-display.c")
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kaige Ye <ye@kaige.org>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: K Prateek Nayak <kprateek.nayak@amd.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Yicong Yang <yangyicong@hisilicon.com>
+Link: https://lore.kernel.org/r/20240510051309.2452468-1-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/util/stat-display.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
+index 971fd77bd3e61..8c2da9a3f953c 100644
+--- a/tools/perf/util/stat-display.c
++++ b/tools/perf/util/stat-display.c
+@@ -939,6 +939,9 @@ static void print_metric_headers(struct perf_stat_config *config,
+       /* Print metrics headers only */
+       evlist__for_each_entry(evlist, counter) {
++              if (config->aggr_mode != AGGR_NONE && counter->metric_leader != counter)
++                      continue;
++
+               os.evsel = counter;
+               out.ctx = &os;
+               out.print_metric = print_metric_header;
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-top-fix-tui-exit-screen-refresh-race-condition.patch b/queue-5.10/perf-top-fix-tui-exit-screen-refresh-race-condition.patch
new file mode 100644 (file)
index 0000000..5731714
--- /dev/null
@@ -0,0 +1,75 @@
+From cf4c6c3a9f2737f0748968d7f630e2057752f495 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 29 Dec 2021 16:55:19 +0800
+Subject: perf top: Fix TUI exit screen refresh race condition
+
+From: yaowenbin <yaowenbin1@huawei.com>
+
+[ Upstream commit 64f18d2d043015b3f835ce4c9f3beb97cfd19b6e ]
+
+When the following command is executed several times, a coredump file is
+generated.
+
+       $ timeout -k 9 5 perf top -e task-clock
+       *******
+       *******
+       *******
+       0.01%  [kernel]                  [k] __do_softirq
+       0.01%  libpthread-2.28.so        [.] __pthread_mutex_lock
+       0.01%  [kernel]                  [k] __ll_sc_atomic64_sub_return
+       double free or corruption (!prev) perf top --sort comm,dso
+       timeout: the monitored command dumped core
+
+When we terminate "perf top" using sending signal method,
+SLsmg_reset_smg() called. SLsmg_reset_smg() resets the SLsmg screen
+management routines by freeing all memory allocated while it was active.
+
+However SLsmg_reinit_smg() maybe be called by another thread.
+
+SLsmg_reinit_smg() will free the same memory accessed by
+SLsmg_reset_smg(), thus it results in a double free.
+
+SLsmg_reinit_smg() is called already protected by ui__lock, so we fix
+the problem by adding pthread_mutex_trylock of ui__lock when calling
+SLsmg_reset_smg().
+
+Signed-off-by: Wenyu Liu <liuwenyu7@huawei.com>
+Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: wuxu.wu@huawei.com
+Link: http://lore.kernel.org/lkml/a91e3943-7ddc-f5c0-a7f5-360f073c20e6@huawei.com
+Signed-off-by: Hewenliang <hewenliang4@huawei.com>
+Signed-off-by: yaowenbin <yaowenbin1@huawei.com>
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 769e6a1e15bd ("perf ui browser: Don't save pointer to stack memory")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/ui/tui/setup.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
+index e9bfe856a5dee..b1be59b4e2a4f 100644
+--- a/tools/perf/ui/tui/setup.c
++++ b/tools/perf/ui/tui/setup.c
+@@ -170,9 +170,11 @@ void ui__exit(bool wait_for_ok)
+                                   "Press any key...", 0);
+       SLtt_set_cursor_visibility(1);
+-      SLsmg_refresh();
+-      SLsmg_reset_smg();
++      if (!pthread_mutex_trylock(&ui__lock)) {
++              SLsmg_refresh();
++              SLsmg_reset_smg();
++              pthread_mutex_unlock(&ui__lock);
++      }
+       SLang_reset_tty();
+-
+       perf_error__unregister(&perf_tui_eops);
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-ui-browser-avoid-segv-on-title.patch b/queue-5.10/perf-ui-browser-avoid-segv-on-title.patch
new file mode 100644 (file)
index 0000000..c1ad6c4
--- /dev/null
@@ -0,0 +1,46 @@
+From efa5a0eb2d3591944a8590ee00f1deda451ae6eb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 May 2024 20:52:58 -0700
+Subject: perf ui browser: Avoid SEGV on title
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 90f01afb0dfafbc9b094bb61e61a4ac297d9d0d2 ]
+
+If the title is NULL then it can lead to a SEGV.
+
+Fixes: 769e6a1e15bdbbaf ("perf ui browser: Don't save pointer to stack memory")
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: James Clark <james.clark@arm.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: Leo Yan <leo.yan@linux.dev>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Link: https://lore.kernel.org/r/20240508035301.1554434-2-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/ui/browser.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
+index 6fa4f123d5ff7..b84b87b939573 100644
+--- a/tools/perf/ui/browser.c
++++ b/tools/perf/ui/browser.c
+@@ -203,7 +203,7 @@ void ui_browser__refresh_dimensions(struct ui_browser *browser)
+ void ui_browser__handle_resize(struct ui_browser *browser)
+ {
+       ui__refresh_dimensions(false);
+-      ui_browser__show(browser, browser->title, ui_helpline__current);
++      ui_browser__show(browser, browser->title ?: "", ui_helpline__current);
+       ui_browser__refresh(browser);
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-ui-browser-don-t-save-pointer-to-stack-memory.patch b/queue-5.10/perf-ui-browser-don-t-save-pointer-to-stack-memory.patch
new file mode 100644 (file)
index 0000000..7474cc1
--- /dev/null
@@ -0,0 +1,143 @@
+From b26165fddc621219e8f039d3bf6df17c8e81c0e2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 May 2024 11:35:38 -0700
+Subject: perf ui browser: Don't save pointer to stack memory
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 769e6a1e15bdbbaf2b0d2f37c24f2c53268bd21f ]
+
+ui_browser__show() is capturing the input title that is stack allocated
+memory in hist_browser__run().
+
+Avoid a use after return by strdup-ing the string.
+
+Committer notes:
+
+Further explanation from Ian Rogers:
+
+My command line using tui is:
+$ sudo bash -c 'rm /tmp/asan.log*; export
+ASAN_OPTIONS="log_path=/tmp/asan.log"; /tmp/perf/perf mem record -a
+sleep 1; /tmp/perf/perf mem report'
+I then go to the perf annotate view and quit. This triggers the asan
+error (from the log file):
+```
+==1254591==ERROR: AddressSanitizer: stack-use-after-return on address
+0x7f2813331920 at pc 0x7f28180
+65991 bp 0x7fff0a21c750 sp 0x7fff0a21bf10
+READ of size 80 at 0x7f2813331920 thread T0
+    #0 0x7f2818065990 in __interceptor_strlen
+../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:461
+    #1 0x7f2817698251 in SLsmg_write_wrapped_string
+(/lib/x86_64-linux-gnu/libslang.so.2+0x98251)
+    #2 0x7f28176984b9 in SLsmg_write_nstring
+(/lib/x86_64-linux-gnu/libslang.so.2+0x984b9)
+    #3 0x55c94045b365 in ui_browser__write_nstring ui/browser.c:60
+    #4 0x55c94045c558 in __ui_browser__show_title ui/browser.c:266
+    #5 0x55c94045c776 in ui_browser__show ui/browser.c:288
+    #6 0x55c94045c06d in ui_browser__handle_resize ui/browser.c:206
+    #7 0x55c94047979b in do_annotate ui/browsers/hists.c:2458
+    #8 0x55c94047fb17 in evsel__hists_browse ui/browsers/hists.c:3412
+    #9 0x55c940480a0c in perf_evsel_menu__run ui/browsers/hists.c:3527
+    #10 0x55c940481108 in __evlist__tui_browse_hists ui/browsers/hists.c:3613
+    #11 0x55c9404813f7 in evlist__tui_browse_hists ui/browsers/hists.c:3661
+    #12 0x55c93ffa253f in report__browse_hists tools/perf/builtin-report.c:671
+    #13 0x55c93ffa58ca in __cmd_report tools/perf/builtin-report.c:1141
+    #14 0x55c93ffaf159 in cmd_report tools/perf/builtin-report.c:1805
+    #15 0x55c94000c05c in report_events tools/perf/builtin-mem.c:374
+    #16 0x55c94000d96d in cmd_mem tools/perf/builtin-mem.c:516
+    #17 0x55c9400e44ee in run_builtin tools/perf/perf.c:350
+    #18 0x55c9400e4a5a in handle_internal_command tools/perf/perf.c:403
+    #19 0x55c9400e4e22 in run_argv tools/perf/perf.c:447
+    #20 0x55c9400e53ad in main tools/perf/perf.c:561
+    #21 0x7f28170456c9 in __libc_start_call_main
+../sysdeps/nptl/libc_start_call_main.h:58
+    #22 0x7f2817045784 in __libc_start_main_impl ../csu/libc-start.c:360
+    #23 0x55c93ff544c0 in _start (/tmp/perf/perf+0x19a4c0) (BuildId:
+84899b0e8c7d3a3eaa67b2eb35e3d8b2f8cd4c93)
+
+Address 0x7f2813331920 is located in stack of thread T0 at offset 32 in frame
+    #0 0x55c94046e85e in hist_browser__run ui/browsers/hists.c:746
+
+  This frame has 1 object(s):
+    [32, 192) 'title' (line 747) <== Memory access at offset 32 is
+inside this variable
+HINT: this may be a false positive if your program uses some custom
+stack unwind mechanism, swapcontext or vfork
+```
+hist_browser__run isn't on the stack so the asan error looks legit.
+There's no clean init/exit on struct ui_browser so I may be trading a
+use-after-return for a memory leak, but that seems look a good trade
+anyway.
+
+Fixes: 05e8b0804ec4 ("perf ui browser: Stop using 'self'")
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
+Cc: Ben Gainey <ben.gainey@arm.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: James Clark <james.clark@arm.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kajol Jain <kjain@linux.ibm.com>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: K Prateek Nayak <kprateek.nayak@amd.com>
+Cc: Li Dong <lidong@vivo.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Oliver Upton <oliver.upton@linux.dev>
+Cc: Paran Lee <p4ranlee@gmail.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Ravi Bangoria <ravi.bangoria@amd.com>
+Cc: Sun Haiyong <sunhaiyong@loongson.cn>
+Cc: Tim Chen <tim.c.chen@linux.intel.com>
+Cc: Yanteng Si <siyanteng@loongson.cn>
+Cc: Yicong Yang <yangyicong@hisilicon.com>
+Link: https://lore.kernel.org/r/20240507183545.1236093-2-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/ui/browser.c | 4 +++-
+ tools/perf/ui/browser.h | 2 +-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
+index 9dc808020e824..6fa4f123d5ff7 100644
+--- a/tools/perf/ui/browser.c
++++ b/tools/perf/ui/browser.c
+@@ -287,7 +287,8 @@ int ui_browser__show(struct ui_browser *browser, const char *title,
+       mutex_lock(&ui__lock);
+       __ui_browser__show_title(browser, title);
+-      browser->title = title;
++      free(browser->title);
++      browser->title = strdup(title);
+       zfree(&browser->helpline);
+       va_start(ap, helpline);
+@@ -304,6 +305,7 @@ void ui_browser__hide(struct ui_browser *browser)
+       mutex_lock(&ui__lock);
+       ui_helpline__pop();
+       zfree(&browser->helpline);
++      zfree(&browser->title);
+       mutex_unlock(&ui__lock);
+ }
+diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
+index 3678eb88f119c..815e6bf7ee531 100644
+--- a/tools/perf/ui/browser.h
++++ b/tools/perf/ui/browser.h
+@@ -21,7 +21,7 @@ struct ui_browser {
+       u8            extra_title_lines;
+       int           current_color;
+       void          *priv;
+-      const char    *title;
++      char          *title;
+       char          *helpline;
+       const char    *no_samples_msg;
+       void          (*refresh_dimensions)(struct ui_browser *browser);
+-- 
+2.43.0
+
diff --git a/queue-5.10/perf-ui-update-use-of-pthread-mutex.patch b/queue-5.10/perf-ui-update-use-of-pthread-mutex.patch
new file mode 100644 (file)
index 0000000..e581ced
--- /dev/null
@@ -0,0 +1,382 @@
+From 04eea64658853043f722950968b7688b3447aa86 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 26 Aug 2022 09:42:33 -0700
+Subject: perf ui: Update use of pthread mutex
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 82aff6cc070417f26f9b02b26e63c17ff43b4044 ]
+
+Switch to the use of mutex wrappers that provide better error checking.
+
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Alexandre Truong <alexandre.truong@arm.com>
+Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Andres Freund <andres@anarazel.de>
+Cc: Andrii Nakryiko <andrii@kernel.org>
+Cc: André Almeida <andrealmeid@igalia.com>
+Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
+Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+Cc: Colin Ian King <colin.king@intel.com>
+Cc: Dario Petrillo <dario.pk1@gmail.com>
+Cc: Darren Hart <dvhart@infradead.org>
+Cc: Dave Marchevsky <davemarchevsky@fb.com>
+Cc: Davidlohr Bueso <dave@stgolabs.net>
+Cc: Fangrui Song <maskray@google.com>
+Cc: Hewenliang <hewenliang4@huawei.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: James Clark <james.clark@arm.com>
+Cc: Jason Wang <wangborong@cdjrlc.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kajol Jain <kjain@linux.ibm.com>
+Cc: Kim Phillips <kim.phillips@amd.com>
+Cc: Leo Yan <leo.yan@linaro.org>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Martin Liška <mliska@suse.cz>
+Cc: Masami Hiramatsu <mhiramat@kernel.org>
+Cc: Nathan Chancellor <nathan@kernel.org>
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Quentin Monnet <quentin@isovalent.com>
+Cc: Ravi Bangoria <ravi.bangoria@amd.com>
+Cc: Remi Bernon <rbernon@codeweavers.com>
+Cc: Riccardo Mancini <rickyman7@gmail.com>
+Cc: Song Liu <songliubraving@fb.com>
+Cc: Stephane Eranian <eranian@google.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: Thomas Richter <tmricht@linux.ibm.com>
+Cc: Tom Rix <trix@redhat.com>
+Cc: Weiguo Li <liwg06@foxmail.com>
+Cc: Wenyu Liu <liuwenyu7@huawei.com>
+Cc: William Cohen <wcohen@redhat.com>
+Cc: Zechuan Chen <chenzechuan1@huawei.com>
+Cc: bpf@vger.kernel.org
+Cc: llvm@lists.linux.dev
+Cc: yaowenbin <yaowenbin1@huawei.com>
+Link: https://lore.kernel.org/r/20220826164242.43412-10-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 769e6a1e15bd ("perf ui browser: Don't save pointer to stack memory")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/ui/browser.c           | 20 ++++++++++----------
+ tools/perf/ui/browsers/annotate.c |  2 +-
+ tools/perf/ui/setup.c             |  5 +++--
+ tools/perf/ui/tui/helpline.c      |  5 ++---
+ tools/perf/ui/tui/progress.c      |  8 ++++----
+ tools/perf/ui/tui/setup.c         |  8 ++++----
+ tools/perf/ui/tui/util.c          | 18 +++++++++---------
+ tools/perf/ui/ui.h                |  4 ++--
+ 8 files changed, 35 insertions(+), 35 deletions(-)
+
+diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
+index 781afe42e90e0..9dc808020e824 100644
+--- a/tools/perf/ui/browser.c
++++ b/tools/perf/ui/browser.c
+@@ -268,9 +268,9 @@ void __ui_browser__show_title(struct ui_browser *browser, const char *title)
+ void ui_browser__show_title(struct ui_browser *browser, const char *title)
+ {
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       __ui_browser__show_title(browser, title);
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+ }
+ int ui_browser__show(struct ui_browser *browser, const char *title,
+@@ -284,7 +284,7 @@ int ui_browser__show(struct ui_browser *browser, const char *title,
+       browser->refresh_dimensions(browser);
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       __ui_browser__show_title(browser, title);
+       browser->title = title;
+@@ -295,16 +295,16 @@ int ui_browser__show(struct ui_browser *browser, const char *title,
+       va_end(ap);
+       if (err > 0)
+               ui_helpline__push(browser->helpline);
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+       return err ? 0 : -1;
+ }
+ void ui_browser__hide(struct ui_browser *browser)
+ {
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       ui_helpline__pop();
+       zfree(&browser->helpline);
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+ }
+ static void ui_browser__scrollbar_set(struct ui_browser *browser)
+@@ -352,9 +352,9 @@ static int __ui_browser__refresh(struct ui_browser *browser)
+ int ui_browser__refresh(struct ui_browser *browser)
+ {
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       __ui_browser__refresh(browser);
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+       return 0;
+ }
+@@ -390,10 +390,10 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs)
+       while (1) {
+               off_t offset;
+-              pthread_mutex_lock(&ui__lock);
++              mutex_lock(&ui__lock);
+               err = __ui_browser__refresh(browser);
+               SLsmg_refresh();
+-              pthread_mutex_unlock(&ui__lock);
++              mutex_unlock(&ui__lock);
+               if (err < 0)
+                       break;
+diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
+index bd77825fd5a15..7083dbb9a0af9 100644
+--- a/tools/perf/ui/browsers/annotate.c
++++ b/tools/perf/ui/browsers/annotate.c
+@@ -8,11 +8,11 @@
+ #include "../../util/hist.h"
+ #include "../../util/sort.h"
+ #include "../../util/map.h"
++#include "../../util/mutex.h"
+ #include "../../util/symbol.h"
+ #include "../../util/evsel.h"
+ #include "../../util/evlist.h"
+ #include <inttypes.h>
+-#include <pthread.h>
+ #include <linux/kernel.h>
+ #include <linux/string.h>
+ #include <linux/zalloc.h>
+diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
+index 700335cde6180..25ded88801a3d 100644
+--- a/tools/perf/ui/setup.c
++++ b/tools/perf/ui/setup.c
+@@ -1,5 +1,4 @@
+ // SPDX-License-Identifier: GPL-2.0
+-#include <pthread.h>
+ #include <dlfcn.h>
+ #include <unistd.h>
+@@ -8,7 +7,7 @@
+ #include "../util/hist.h"
+ #include "ui.h"
+-pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
++struct mutex ui__lock;
+ void *perf_gtk_handle;
+ int use_browser = -1;
+@@ -76,6 +75,7 @@ int stdio__config_color(const struct option *opt __maybe_unused,
+ void setup_browser(bool fallback_to_pager)
+ {
++      mutex_init(&ui__lock);
+       if (use_browser < 2 && (!isatty(1) || dump_trace))
+               use_browser = 0;
+@@ -118,4 +118,5 @@ void exit_browser(bool wait_for_ok)
+       default:
+               break;
+       }
++      mutex_destroy(&ui__lock);
+ }
+diff --git a/tools/perf/ui/tui/helpline.c b/tools/perf/ui/tui/helpline.c
+index 298d6af82fddd..db4952f5990bd 100644
+--- a/tools/perf/ui/tui/helpline.c
++++ b/tools/perf/ui/tui/helpline.c
+@@ -2,7 +2,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <pthread.h>
+ #include <linux/kernel.h>
+ #include <linux/string.h>
+@@ -33,7 +32,7 @@ static int tui_helpline__show(const char *format, va_list ap)
+       int ret;
+       static int backlog;
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       ret = vscnprintf(ui_helpline__last_msg + backlog,
+                       sizeof(ui_helpline__last_msg) - backlog, format, ap);
+       backlog += ret;
+@@ -45,7 +44,7 @@ static int tui_helpline__show(const char *format, va_list ap)
+               SLsmg_refresh();
+               backlog = 0;
+       }
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+       return ret;
+ }
+diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
+index 3d74af5a7ece6..71b6c8d9474fb 100644
+--- a/tools/perf/ui/tui/progress.c
++++ b/tools/perf/ui/tui/progress.c
+@@ -45,7 +45,7 @@ static void tui_progress__update(struct ui_progress *p)
+       }
+       ui__refresh_dimensions(false);
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       y = SLtt_Screen_Rows / 2 - 2;
+       SLsmg_set_color(0);
+       SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
+@@ -56,7 +56,7 @@ static void tui_progress__update(struct ui_progress *p)
+       bar = ((SLtt_Screen_Cols - 2) * p->curr) / p->total;
+       SLsmg_fill_region(y, 1, 1, bar, ' ');
+       SLsmg_refresh();
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+ }
+ static void tui_progress__finish(void)
+@@ -67,12 +67,12 @@ static void tui_progress__finish(void)
+               return;
+       ui__refresh_dimensions(false);
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       y = SLtt_Screen_Rows / 2 - 2;
+       SLsmg_set_color(0);
+       SLsmg_fill_region(y, 0, 3, SLtt_Screen_Cols, ' ');
+       SLsmg_refresh();
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+ }
+ static struct ui_progress_ops tui_progress__ops = {
+diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
+index b1be59b4e2a4f..a3b8c397c24d5 100644
+--- a/tools/perf/ui/tui/setup.c
++++ b/tools/perf/ui/tui/setup.c
+@@ -29,10 +29,10 @@ void ui__refresh_dimensions(bool force)
+ {
+       if (force || ui__need_resize) {
+               ui__need_resize = 0;
+-              pthread_mutex_lock(&ui__lock);
++              mutex_lock(&ui__lock);
+               SLtt_get_screen_size();
+               SLsmg_reinit_smg();
+-              pthread_mutex_unlock(&ui__lock);
++              mutex_unlock(&ui__lock);
+       }
+ }
+@@ -170,10 +170,10 @@ void ui__exit(bool wait_for_ok)
+                                   "Press any key...", 0);
+       SLtt_set_cursor_visibility(1);
+-      if (!pthread_mutex_trylock(&ui__lock)) {
++      if (mutex_trylock(&ui__lock)) {
+               SLsmg_refresh();
+               SLsmg_reset_smg();
+-              pthread_mutex_unlock(&ui__lock);
++              mutex_unlock(&ui__lock);
+       }
+       SLang_reset_tty();
+       perf_error__unregister(&perf_tui_eops);
+diff --git a/tools/perf/ui/tui/util.c b/tools/perf/ui/tui/util.c
+index 0f562e2cb1e88..3c5174854ac8b 100644
+--- a/tools/perf/ui/tui/util.c
++++ b/tools/perf/ui/tui/util.c
+@@ -95,7 +95,7 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
+               t = sep + 1;
+       }
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       max_len += 2;
+       nr_lines += 8;
+@@ -125,17 +125,17 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
+       SLsmg_write_nstring((char *)exit_msg, max_len);
+       SLsmg_refresh();
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+       x += 2;
+       len = 0;
+       key = ui__getch(delay_secs);
+       while (key != K_TIMER && key != K_ENTER && key != K_ESC) {
+-              pthread_mutex_lock(&ui__lock);
++              mutex_lock(&ui__lock);
+               if (key == K_BKSPC) {
+                       if (len == 0) {
+-                              pthread_mutex_unlock(&ui__lock);
++                              mutex_unlock(&ui__lock);
+                               goto next_key;
+                       }
+                       SLsmg_gotorc(y, x + --len);
+@@ -147,7 +147,7 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
+               }
+               SLsmg_refresh();
+-              pthread_mutex_unlock(&ui__lock);
++              mutex_unlock(&ui__lock);
+               /* XXX more graceful overflow handling needed */
+               if (len == sizeof(buf) - 1) {
+@@ -215,19 +215,19 @@ void __ui__info_window(const char *title, const char *text, const char *exit_msg
+ void ui__info_window(const char *title, const char *text)
+ {
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       __ui__info_window(title, text, NULL);
+       SLsmg_refresh();
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+ }
+ int ui__question_window(const char *title, const char *text,
+                       const char *exit_msg, int delay_secs)
+ {
+-      pthread_mutex_lock(&ui__lock);
++      mutex_lock(&ui__lock);
+       __ui__info_window(title, text, exit_msg);
+       SLsmg_refresh();
+-      pthread_mutex_unlock(&ui__lock);
++      mutex_unlock(&ui__lock);
+       return ui__getch(delay_secs);
+ }
+diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
+index 9b6fdf06e1d2f..99f8d2fe9bc55 100644
+--- a/tools/perf/ui/ui.h
++++ b/tools/perf/ui/ui.h
+@@ -2,11 +2,11 @@
+ #ifndef _PERF_UI_H_
+ #define _PERF_UI_H_ 1
+-#include <pthread.h>
++#include "../util/mutex.h"
+ #include <stdbool.h>
+ #include <linux/compiler.h>
+-extern pthread_mutex_t ui__lock;
++extern struct mutex ui__lock;
+ extern void *perf_gtk_handle;
+ extern int use_browser;
+-- 
+2.43.0
+
diff --git a/queue-5.10/ppdev-add-an-error-check-in-register_device.patch b/queue-5.10/ppdev-add-an-error-check-in-register_device.patch
new file mode 100644 (file)
index 0000000..d75e920
--- /dev/null
@@ -0,0 +1,72 @@
+From e0923408d1aa54232cbf59aad7226c2c6e6a31bd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 Apr 2024 16:38:40 +0800
+Subject: ppdev: Add an error check in register_device
+
+From: Huai-Yuan Liu <qq810974084@gmail.com>
+
+[ Upstream commit fbf740aeb86a4fe82ad158d26d711f2f3be79b3e ]
+
+In register_device, the return value of ida_simple_get is unchecked,
+in witch ida_simple_get will use an invalid index value.
+
+To address this issue, index should be checked after ida_simple_get. When
+the index value is abnormal, a warning message should be printed, the port
+should be dropped, and the value should be recorded.
+
+Fixes: 9a69645dde11 ("ppdev: fix registering same device name")
+Signed-off-by: Huai-Yuan Liu <qq810974084@gmail.com>
+Link: https://lore.kernel.org/r/20240412083840.234085-1-qq810974084@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/char/ppdev.c | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
+index f6024d97fe70b..a97edbf7455a6 100644
+--- a/drivers/char/ppdev.c
++++ b/drivers/char/ppdev.c
+@@ -296,28 +296,35 @@ static int register_device(int minor, struct pp_struct *pp)
+       if (!port) {
+               pr_warn("%s: no associated port!\n", name);
+               rc = -ENXIO;
+-              goto err;
++              goto err_free_name;
+       }
+       index = ida_alloc(&ida_index, GFP_KERNEL);
++      if (index < 0) {
++              pr_warn("%s: failed to get index!\n", name);
++              rc = index;
++              goto err_put_port;
++      }
++
+       memset(&ppdev_cb, 0, sizeof(ppdev_cb));
+       ppdev_cb.irq_func = pp_irq;
+       ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
+       ppdev_cb.private = pp;
+       pdev = parport_register_dev_model(port, name, &ppdev_cb, index);
+-      parport_put_port(port);
+       if (!pdev) {
+               pr_warn("%s: failed to register device!\n", name);
+               rc = -ENXIO;
+               ida_free(&ida_index, index);
+-              goto err;
++              goto err_put_port;
+       }
+       pp->pdev = pdev;
+       pp->index = index;
+       dev_dbg(&pdev->dev, "registered pardevice\n");
+-err:
++err_put_port:
++      parport_put_port(port);
++err_free_name:
+       kfree(name);
+       return rc;
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/ppdev-remove-usage-of-the-deprecated-ida_simple_xx-a.patch b/queue-5.10/ppdev-remove-usage-of-the-deprecated-ida_simple_xx-a.patch
new file mode 100644 (file)
index 0000000..761cc65
--- /dev/null
@@ -0,0 +1,57 @@
+From 9269ec3edab7d3d853a0124537c3c4df482a1aa6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 19 Dec 2023 06:01:47 +0100
+Subject: ppdev: Remove usage of the deprecated ida_simple_xx() API
+
+From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+
+[ Upstream commit d8407f71ebeaeb6f50bd89791837873e44609708 ]
+
+ida_alloc() and ida_free() should be preferred to the deprecated
+ida_simple_get() and ida_simple_remove().
+
+This is less verbose.
+
+Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+Link: https://lore.kernel.org/r/ba9da12fdd5cdb2c28180b7160af5042447d803f.1702962092.git.christophe.jaillet@wanadoo.fr
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: fbf740aeb86a ("ppdev: Add an error check in register_device")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/char/ppdev.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
+index 38b46c7d17371..f6024d97fe70b 100644
+--- a/drivers/char/ppdev.c
++++ b/drivers/char/ppdev.c
+@@ -299,7 +299,7 @@ static int register_device(int minor, struct pp_struct *pp)
+               goto err;
+       }
+-      index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
++      index = ida_alloc(&ida_index, GFP_KERNEL);
+       memset(&ppdev_cb, 0, sizeof(ppdev_cb));
+       ppdev_cb.irq_func = pp_irq;
+       ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
+@@ -310,7 +310,7 @@ static int register_device(int minor, struct pp_struct *pp)
+       if (!pdev) {
+               pr_warn("%s: failed to register device!\n", name);
+               rc = -ENXIO;
+-              ida_simple_remove(&ida_index, index);
++              ida_free(&ida_index, index);
+               goto err;
+       }
+@@ -750,7 +750,7 @@ static int pp_release(struct inode *inode, struct file *file)
+       if (pp->pdev) {
+               parport_unregister_device(pp->pdev);
+-              ida_simple_remove(&ida_index, pp->index);
++              ida_free(&ida_index, pp->index);
+               pp->pdev = NULL;
+               pr_debug(CHRDEV "%x: unregistered pardevice\n", minor);
+       }
+-- 
+2.43.0
+
diff --git a/queue-5.10/s390-ipl-fix-incorrect-initialization-of-len-fields-.patch b/queue-5.10/s390-ipl-fix-incorrect-initialization-of-len-fields-.patch
new file mode 100644 (file)
index 0000000..bfe7062
--- /dev/null
@@ -0,0 +1,42 @@
+From ed196b17608f43bacb9ab5d944cc34dee19606a2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 May 2024 12:41:25 +0200
+Subject: s390/ipl: Fix incorrect initialization of len fields in nvme reipl
+ block
+
+From: Alexander Egorenkov <egorenar@linux.ibm.com>
+
+[ Upstream commit 9c922b73acaf39f867668d9cbe5dc69c23511f84 ]
+
+Use correct symbolic constants IPL_BP_NVME_LEN and IPL_BP0_NVME_LEN
+to initialize nvme reipl block when 'scp_data' sysfs attribute is
+being updated. This bug had not been detected before because
+the corresponding fcp and nvme symbolic constants are equal.
+
+Fixes: 23a457b8d57d ("s390: nvme reipl")
+Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
+Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
+Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/s390/kernel/ipl.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
+index c469e8848d659..ab23742088d05 100644
+--- a/arch/s390/kernel/ipl.c
++++ b/arch/s390/kernel/ipl.c
+@@ -832,8 +832,8 @@ static ssize_t reipl_nvme_scpdata_write(struct file *filp, struct kobject *kobj,
+               scpdata_len += padding;
+       }
+-      reipl_block_nvme->hdr.len = IPL_BP_FCP_LEN + scpdata_len;
+-      reipl_block_nvme->nvme.len = IPL_BP0_FCP_LEN + scpdata_len;
++      reipl_block_nvme->hdr.len = IPL_BP_NVME_LEN + scpdata_len;
++      reipl_block_nvme->nvme.len = IPL_BP0_NVME_LEN + scpdata_len;
+       reipl_block_nvme->nvme.scp_data_len = scpdata_len;
+       return count;
+-- 
+2.43.0
+
diff --git a/queue-5.10/s390-ipl-fix-incorrect-initialization-of-nvme-dump-b.patch b/queue-5.10/s390-ipl-fix-incorrect-initialization-of-nvme-dump-b.patch
new file mode 100644 (file)
index 0000000..44642b7
--- /dev/null
@@ -0,0 +1,43 @@
+From a34a3617d735b4fb393e5363a31980444f261714 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 May 2024 12:41:26 +0200
+Subject: s390/ipl: Fix incorrect initialization of nvme dump block
+
+From: Alexander Egorenkov <egorenar@linux.ibm.com>
+
+[ Upstream commit 7faacaeaf6ce12fae78751de5ad869d8f1e1cd7a ]
+
+Initialize the correct fields of the nvme dump block.
+This bug had not been detected before because first, the fcp and nvme fields
+of struct ipl_parameter_block are part of the same union and, therefore,
+overlap in memory and second, they are identical in structure and size.
+
+Fixes: d70e38cb1dee ("s390: nvme dump support")
+Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
+Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
+Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/s390/kernel/ipl.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
+index ab23742088d05..939ceec83048f 100644
+--- a/arch/s390/kernel/ipl.c
++++ b/arch/s390/kernel/ipl.c
+@@ -1602,9 +1602,9 @@ static int __init dump_nvme_init(void)
+       }
+       dump_block_nvme->hdr.len = IPL_BP_NVME_LEN;
+       dump_block_nvme->hdr.version = IPL_PARM_BLOCK_VERSION;
+-      dump_block_nvme->fcp.len = IPL_BP0_NVME_LEN;
+-      dump_block_nvme->fcp.pbt = IPL_PBT_NVME;
+-      dump_block_nvme->fcp.opt = IPL_PB0_NVME_OPT_DUMP;
++      dump_block_nvme->nvme.len = IPL_BP0_NVME_LEN;
++      dump_block_nvme->nvme.pbt = IPL_PBT_NVME;
++      dump_block_nvme->nvme.opt = IPL_PB0_NVME_OPT_DUMP;
+       dump_capabilities |= DUMP_TYPE_NVME;
+       return 0;
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/serial-max3100-fix-bitwise-types.patch b/queue-5.10/serial-max3100-fix-bitwise-types.patch
new file mode 100644 (file)
index 0000000..8ffe5f6
--- /dev/null
@@ -0,0 +1,53 @@
+From 832355740d898ca0c4c5113241d181ff68bdc2d4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 2 Apr 2024 22:50:30 +0300
+Subject: serial: max3100: Fix bitwise types
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+[ Upstream commit e60955dbecb97f080848a57524827e2db29c70fd ]
+
+Sparse is not happy about misuse of bitwise types:
+
+  .../max3100.c:194:13: warning: incorrect type in assignment (different base types)
+  .../max3100.c:194:13:    expected unsigned short [addressable] [usertype] etx
+  .../max3100.c:194:13:    got restricted __be16 [usertype]
+  .../max3100.c:202:15: warning: cast to restricted __be16
+
+Fix this by choosing proper types for the respective variables.
+
+Fixes: 7831d56b0a35 ("tty: MAX3100")
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20240402195306.269276-4-andriy.shevchenko@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/max3100.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
+index c1ee88f530334..17b6f4a872d6a 100644
+--- a/drivers/tty/serial/max3100.c
++++ b/drivers/tty/serial/max3100.c
+@@ -45,6 +45,9 @@
+ #include <linux/freezer.h>
+ #include <linux/tty.h>
+ #include <linux/tty_flip.h>
++#include <linux/types.h>
++
++#include <asm/unaligned.h>
+ #include <linux/serial_max3100.h>
+@@ -191,7 +194,7 @@ static void max3100_timeout(struct timer_list *t)
+ static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx)
+ {
+       struct spi_message message;
+-      u16 etx, erx;
++      __be16 etx, erx;
+       int status;
+       struct spi_transfer tran = {
+               .tx_buf = &etx,
+-- 
+2.43.0
+
diff --git a/queue-5.10/serial-max3100-lock-port-lock-when-calling-uart_hand.patch b/queue-5.10/serial-max3100-lock-port-lock-when-calling-uart_hand.patch
new file mode 100644 (file)
index 0000000..cc5d9ff
--- /dev/null
@@ -0,0 +1,66 @@
+From 64c18c82d7e9ae8bcba7b76586f0af2f43117919 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 2 Apr 2024 22:50:28 +0300
+Subject: serial: max3100: Lock port->lock when calling
+ uart_handle_cts_change()
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+[ Upstream commit 77ab53371a2066fdf9b895246505f5ef5a4b5d47 ]
+
+uart_handle_cts_change() has to be called with port lock taken,
+Since we run it in a separate work, the lock may not be taken at
+the time of running. Make sure that it's taken by explicitly doing
+that. Without it we got a splat:
+
+  WARNING: CPU: 0 PID: 10 at drivers/tty/serial/serial_core.c:3491 uart_handle_cts_change+0xa6/0xb0
+  ...
+  Workqueue: max3100-0 max3100_work [max3100]
+  RIP: 0010:uart_handle_cts_change+0xa6/0xb0
+  ...
+   max3100_handlerx+0xc5/0x110 [max3100]
+   max3100_work+0x12a/0x340 [max3100]
+
+Fixes: 7831d56b0a35 ("tty: MAX3100")
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/20240402195306.269276-2-andriy.shevchenko@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/max3100.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
+index 371569a0fd00a..915d7753eec2f 100644
+--- a/drivers/tty/serial/max3100.c
++++ b/drivers/tty/serial/max3100.c
+@@ -213,7 +213,7 @@ static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx)
+       return 0;
+ }
+-static int max3100_handlerx(struct max3100_port *s, u16 rx)
++static int max3100_handlerx_unlocked(struct max3100_port *s, u16 rx)
+ {
+       unsigned int ch, flg, status = 0;
+       int ret = 0, cts;
+@@ -253,6 +253,17 @@ static int max3100_handlerx(struct max3100_port *s, u16 rx)
+       return ret;
+ }
++static int max3100_handlerx(struct max3100_port *s, u16 rx)
++{
++      unsigned long flags;
++      int ret;
++
++      uart_port_lock_irqsave(&s->port, &flags);
++      ret = max3100_handlerx_unlocked(s, rx);
++      uart_port_unlock_irqrestore(&s->port, flags);
++      return ret;
++}
++
+ static void max3100_work(struct work_struct *w)
+ {
+       struct max3100_port *s = container_of(w, struct max3100_port, work);
+-- 
+2.43.0
+
diff --git a/queue-5.10/serial-max3100-update-uart_driver_registered-on-driv.patch b/queue-5.10/serial-max3100-update-uart_driver_registered-on-driv.patch
new file mode 100644 (file)
index 0000000..7466048
--- /dev/null
@@ -0,0 +1,73 @@
+From a7e824623d347b0939c6a96347f12805d8297138 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 2 Apr 2024 22:50:29 +0300
+Subject: serial: max3100: Update uart_driver_registered on driver removal
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+[ Upstream commit 712a1fcb38dc7cac6da63ee79a88708fbf9c45ec ]
+
+The removal of the last MAX3100 device triggers the removal of
+the driver. However, code doesn't update the respective global
+variable and after insmod — rmmod — insmod cycle the kernel
+oopses:
+
+  max3100 spi-PRP0001:01: max3100_probe: adding port 0
+  BUG: kernel NULL pointer dereference, address: 0000000000000408
+  ...
+  RIP: 0010:serial_core_register_port+0xa0/0x840
+  ...
+   max3100_probe+0x1b6/0x280 [max3100]
+   spi_probe+0x8d/0xb0
+
+Update the actual state so next time UART driver will be registered
+again.
+
+Hugo also noticed, that the error path in the probe also affected
+by having the variable set, and not cleared. Instead of clearing it
+move the assignment after the successfull uart_register_driver() call.
+
+Fixes: 7831d56b0a35 ("tty: MAX3100")
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Reviewed-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+Link: https://lore.kernel.org/r/20240402195306.269276-3-andriy.shevchenko@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/max3100.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
+index 915d7753eec2f..c1ee88f530334 100644
+--- a/drivers/tty/serial/max3100.c
++++ b/drivers/tty/serial/max3100.c
+@@ -754,13 +754,14 @@ static int max3100_probe(struct spi_device *spi)
+       mutex_lock(&max3100s_lock);
+       if (!uart_driver_registered) {
+-              uart_driver_registered = 1;
+               retval = uart_register_driver(&max3100_uart_driver);
+               if (retval) {
+                       printk(KERN_ERR "Couldn't register max3100 uart driver\n");
+                       mutex_unlock(&max3100s_lock);
+                       return retval;
+               }
++
++              uart_driver_registered = 1;
+       }
+       for (i = 0; i < MAX_MAX3100; i++)
+@@ -846,6 +847,7 @@ static int max3100_remove(struct spi_device *spi)
+               }
+       pr_debug("removing max3100 driver\n");
+       uart_unregister_driver(&max3100_uart_driver);
++      uart_driver_registered = 0;
+       mutex_unlock(&max3100s_lock);
+       return 0;
+-- 
+2.43.0
+
diff --git a/queue-5.10/serial-sc16is7xx-add-proper-sched.h-include-for-sche.patch b/queue-5.10/serial-sc16is7xx-add-proper-sched.h-include-for-sche.patch
new file mode 100644 (file)
index 0000000..d47cd55
--- /dev/null
@@ -0,0 +1,44 @@
+From a6c55f1461af4bd715432d94d0cb201b470374cd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 9 Apr 2024 11:42:49 -0400
+Subject: serial: sc16is7xx: add proper sched.h include for sched_set_fifo()
+
+From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+
+[ Upstream commit 2a8e4ab0c93fad30769479f86849e22d63cd0e12 ]
+
+Replace incorrect include with the proper one for sched_set_fifo()
+declaration.
+
+Fixes: 28d2f209cd16 ("sched,serial: Convert to sched_set_fifo()")
+Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+Link: https://lore.kernel.org/r/20240409154253.3043822-2-hugo@hugovil.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/sc16is7xx.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
+index 29f05db0d49ba..d751f8ce5cf6d 100644
+--- a/drivers/tty/serial/sc16is7xx.c
++++ b/drivers/tty/serial/sc16is7xx.c
+@@ -18,6 +18,7 @@
+ #include <linux/module.h>
+ #include <linux/property.h>
+ #include <linux/regmap.h>
++#include <linux/sched.h>
+ #include <linux/serial_core.h>
+ #include <linux/serial.h>
+ #include <linux/tty.h>
+@@ -25,7 +26,6 @@
+ #include <linux/spi/spi.h>
+ #include <linux/uaccess.h>
+ #include <linux/units.h>
+-#include <uapi/linux/sched/types.h>
+ #define SC16IS7XX_NAME                        "sc16is7xx"
+ #define SC16IS7XX_MAX_DEVS            8
+-- 
+2.43.0
+
diff --git a/queue-5.10/serial-sh-sci-protect-invalidating-rxdma-on-shutdown.patch b/queue-5.10/serial-sh-sci-protect-invalidating-rxdma-on-shutdown.patch
new file mode 100644 (file)
index 0000000..5107451
--- /dev/null
@@ -0,0 +1,47 @@
+From d18e3eec565befda285521b12021ae07f8c55e68 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 May 2024 13:40:17 +0200
+Subject: serial: sh-sci: protect invalidating RXDMA on shutdown
+
+From: Wolfram Sang <wsa+renesas@sang-engineering.com>
+
+[ Upstream commit aae20f6e34cd0cbd67a1d0e5877561c40109a81b ]
+
+The to-be-fixed commit removed locking when invalidating the DMA RX
+descriptors on shutdown. It overlooked that there is still a rx_timer
+running which may still access the protected data. So, re-add the
+locking.
+
+Reported-by: Dirk Behme <dirk.behme@de.bosch.com>
+Closes: https://lore.kernel.org/r/ee6c9e16-9f29-450e-81da-4a8dceaa8fc7@de.bosch.com
+Fixes: 2c4ee23530ff ("serial: sh-sci: Postpone DMA release when falling back to PIO")
+Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
+Link: https://lore.kernel.org/r/20240506114016.30498-7-wsa+renesas@sang-engineering.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/sh-sci.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
+index a7c28543c6f72..71cf9a7329f91 100644
+--- a/drivers/tty/serial/sh-sci.c
++++ b/drivers/tty/serial/sh-sci.c
+@@ -1257,9 +1257,14 @@ static void sci_dma_rx_chan_invalidate(struct sci_port *s)
+ static void sci_dma_rx_release(struct sci_port *s)
+ {
+       struct dma_chan *chan = s->chan_rx_saved;
++      struct uart_port *port = &s->port;
++      unsigned long flags;
++      uart_port_lock_irqsave(port, &flags);
+       s->chan_rx_saved = NULL;
+       sci_dma_rx_chan_invalidate(s);
++      uart_port_unlock_irqrestore(port, flags);
++
+       dmaengine_terminate_sync(chan);
+       dma_free_coherent(chan->device->dev, s->buf_len_rx * 2, s->rx_buf[0],
+                         sg_dma_address(&s->sg_rx[0]));
+-- 
+2.43.0
+
index 9b1e231f94e457f099d01b9c0152baec87e680f1..83c08a3962af27bf571910394475861943ff22b3 100644 (file)
@@ -133,3 +133,61 @@ net-qrtr-ns-fix-module-refcnt.patch
 netrom-fix-possible-dead-lock-in-nr_rt_ioctl.patch
 af_packet-do-not-call-packet_read_pending-from-tpack.patch
 sched-fair-allow-disabling-sched_balance_newidle-wit.patch
+perf-evlist-use-the-right-prefix-for-struct-evlist-s.patch
+perf-record-delete-session-after-stopping-sideband-t.patch
+perf-probe-add-missing-libgen.h-header-needed-for-us.patch
+greybus-lights-check-return-of-get_channel_from_mode.patch
+f2fs-fix-to-wait-on-page-writeback-in-__clone_blkadd.patch
+perf-annotate-add-demangle-and-demangle-kernel.patch
+perf-annotate-get-rid-of-duplicate-group-option-item.patch
+soundwire-cadence-fix-invalid-pdi-offset.patch
+dmaengine-idma64-add-check-for-dma_set_max_seg_size.patch
+firmware-dmi-id-add-a-release-callback-function.patch
+serial-max3100-lock-port-lock-when-calling-uart_hand.patch
+serial-max3100-update-uart_driver_registered-on-driv.patch
+serial-max3100-fix-bitwise-types.patch
+greybus-arche-ctrl-move-device-table-to-its-right-lo.patch
+serial-sc16is7xx-add-proper-sched.h-include-for-sche.patch
+f2fs-compress-support-chksum.patch
+f2fs-add-compress_mode-mount-option.patch
+f2fs-compress-clean-up-parameter-of-__f2fs_cluster_b.patch
+f2fs-compress-remove-unneeded-preallocation.patch
+f2fs-introduce-fi_compress_released-instead-of-using.patch
+f2fs-compress-fix-to-relocate-check-condition-in-f2f.patch
+f2fs-add-cp_error-check-in-f2fs_write_compressed_pag.patch
+f2fs-fix-to-force-keeping-write-barrier-for-strict-f.patch
+f2fs-do-not-allow-partial-truncation-on-pinned-file.patch
+f2fs-fix-typos-in-comments.patch
+f2fs-fix-to-relocate-check-condition-in-f2fs_falloca.patch
+f2fs-fix-to-check-pinfile-flag-in-f2fs_move_file_ran.patch
+iio-pressure-dps310-support-negative-temperature-val.patch
+fpga-region-change-fpga-indirect-article-to-an.patch
+fpga-region-rename-dev-to-parent-for-parent-device.patch
+docs-driver-api-fpga-avoid-using-utf-8-chars.patch
+fpga-region-use-standard-dev_release-for-class-drive.patch
+fpga-region-add-owner-module-and-take-its-refcount.patch
+microblaze-remove-gcc-flag-for-non-existing-early_pr.patch
+microblaze-remove-early-printk-call-from-cpuinfo-sta.patch
+perf-intel-pt-fix-unassigned-instruction-op-discover.patch
+ovl-remove-upper-umask-handling-from-ovl_create_uppe.patch
+usb-gadget-u_audio-clear-uac-pointer-when-freed.patch
+stm-class-fix-a-double-free-in-stm_register_device.patch
+ppdev-remove-usage-of-the-deprecated-ida_simple_xx-a.patch
+ppdev-add-an-error-check-in-register_device.patch
+perf-bench-internals-inject-build-id-fix-trap-divide.patch
+perf-top-fix-tui-exit-screen-refresh-race-condition.patch
+perf-ui-update-use-of-pthread-mutex.patch
+perf-ui-browser-don-t-save-pointer-to-stack-memory.patch
+extcon-max8997-select-irq_domain-instead-of-dependin.patch
+pci-edr-align-edr_port_dpc_enable_dsm-with-pci-firmw.patch
+pci-edr-align-edr_port_locate_dsm-with-pci-firmware-.patch
+perf-ui-browser-avoid-segv-on-title.patch
+perf-report-avoid-segv-in-report__setup_sample_type.patch
+f2fs-compress-fix-to-cover-reserve-release-_compress.patch
+f2fs-fix-to-release-node-block-count-in-error-path-o.patch
+f2fs-compress-don-t-allow-unaligned-truncation-on-re.patch
+serial-sh-sci-protect-invalidating-rxdma-on-shutdown.patch
+libsubcmd-fix-parse-options-memory-leak.patch
+perf-stat-don-t-display-metric-header-for-non-leader.patch
+s390-ipl-fix-incorrect-initialization-of-len-fields-.patch
+s390-ipl-fix-incorrect-initialization-of-nvme-dump-b.patch
diff --git a/queue-5.10/soundwire-cadence-fix-invalid-pdi-offset.patch b/queue-5.10/soundwire-cadence-fix-invalid-pdi-offset.patch
new file mode 100644 (file)
index 0000000..8bee8f5
--- /dev/null
@@ -0,0 +1,48 @@
+From 483003b302b308808bf1e6e9b4ae7e8476f96cd2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 26 Mar 2024 09:01:16 +0000
+Subject: soundwire: cadence: fix invalid PDI offset
+
+From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+
+[ Upstream commit 8ee1b439b1540ae543149b15a2a61b9dff937d91 ]
+
+For some reason, we add an offset to the PDI, presumably to skip the
+PDI0 and PDI1 which are reserved for BPT.
+
+This code is however completely wrong and leads to an out-of-bounds
+access. We were just lucky so far since we used only a couple of PDIs
+and remained within the PDI array bounds.
+
+A Fixes: tag is not provided since there are no known platforms where
+the out-of-bounds would be accessed, and the initial code had problems
+as well.
+
+A follow-up patch completely removes this useless offset.
+
+Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Reviewed-by: Rander Wang <rander.wang@intel.com>
+Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
+Link: https://lore.kernel.org/r/20240326090122.1051806-2-yung-chuan.liao@linux.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/soundwire/cadence_master.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
+index 18e7d158fcca4..d3e9cd3faadfd 100644
+--- a/drivers/soundwire/cadence_master.c
++++ b/drivers/soundwire/cadence_master.c
+@@ -1698,7 +1698,7 @@ struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
+       /* check if we found a PDI, else find in bi-directional */
+       if (!pdi)
+-              pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd,
++              pdi = cdns_find_pdi(cdns, 0, stream->num_bd, stream->bd,
+                                   dai_id);
+       if (pdi) {
+-- 
+2.43.0
+
diff --git a/queue-5.10/stm-class-fix-a-double-free-in-stm_register_device.patch b/queue-5.10/stm-class-fix-a-double-free-in-stm_register_device.patch
new file mode 100644 (file)
index 0000000..c8e8082
--- /dev/null
@@ -0,0 +1,57 @@
+From ce740c3ad93163ab8ff616d0db13d97ebd2fefca Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 Apr 2024 16:01:05 +0300
+Subject: stm class: Fix a double free in stm_register_device()
+
+From: Dan Carpenter <dan.carpenter@linaro.org>
+
+[ Upstream commit 3df463865ba42b8f88a590326f4c9ea17a1ce459 ]
+
+The put_device(&stm->dev) call will trigger stm_device_release() which
+frees "stm" so the vfree(stm) on the next line is a double free.
+
+Fixes: 389b6699a2aa ("stm class: Fix stm device initialization order")
+Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
+Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Link: https://lore.kernel.org/r/20240429130119.1518073-2-alexander.shishkin@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hwtracing/stm/core.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
+index 2712e699ba08c..ae9ea3a1fa2aa 100644
+--- a/drivers/hwtracing/stm/core.c
++++ b/drivers/hwtracing/stm/core.c
+@@ -868,8 +868,11 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
+               return -ENOMEM;
+       stm->major = register_chrdev(0, stm_data->name, &stm_fops);
+-      if (stm->major < 0)
+-              goto err_free;
++      if (stm->major < 0) {
++              err = stm->major;
++              vfree(stm);
++              return err;
++      }
+       device_initialize(&stm->dev);
+       stm->dev.devt = MKDEV(stm->major, 0);
+@@ -913,10 +916,8 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
+ err_device:
+       unregister_chrdev(stm->major, stm_data->name);
+-      /* matches device_initialize() above */
++      /* calls stm_device_release() */
+       put_device(&stm->dev);
+-err_free:
+-      vfree(stm);
+       return err;
+ }
+-- 
+2.43.0
+
diff --git a/queue-5.10/usb-gadget-u_audio-clear-uac-pointer-when-freed.patch b/queue-5.10/usb-gadget-u_audio-clear-uac-pointer-when-freed.patch
new file mode 100644 (file)
index 0000000..db9f4ff
--- /dev/null
@@ -0,0 +1,40 @@
+From 22c242736eaf0923aade1fc8a13b84b649d654c6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 Apr 2024 15:20:20 +0000
+Subject: usb: gadget: u_audio: Clear uac pointer when freed.
+
+From: Chris Wulff <Chris.Wulff@biamp.com>
+
+[ Upstream commit a2cf936ebef291ef7395172b9e2f624779fb6dc0 ]
+
+This prevents use of a stale pointer if functions are called after
+g_cleanup that shouldn't be. This doesn't fix any races, but converts
+a possibly silent kernel memory corruption into an obvious NULL pointer
+dereference report.
+
+Fixes: eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
+Signed-off-by: Chris Wulff <chris.wulff@biamp.com>
+Link: https://lore.kernel.org/stable/CO1PR17MB54194226DA08BFC9EBD8C163E1172%40CO1PR17MB5419.namprd17.prod.outlook.com
+Link: https://lore.kernel.org/r/CO1PR17MB54194226DA08BFC9EBD8C163E1172@CO1PR17MB5419.namprd17.prod.outlook.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/function/u_audio.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
+index 6c8b8f5b7e0f5..a387ff2c8b730 100644
+--- a/drivers/usb/gadget/function/u_audio.c
++++ b/drivers/usb/gadget/function/u_audio.c
+@@ -611,6 +611,8 @@ void g_audio_cleanup(struct g_audio *g_audio)
+               return;
+       uac = g_audio->uac;
++      g_audio->uac = NULL;
++
+       card = uac->card;
+       if (card)
+               snd_card_free_when_closed(card);
+-- 
+2.43.0
+