From: Sasha Levin Date: Fri, 23 Aug 2024 00:12:54 +0000 (-0400) Subject: Fixes for 6.1 X-Git-Tag: v6.1.107~80 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e9c3bed8958324d790b1ebd533f739cbffb6fdb;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.1 Signed-off-by: Sasha Levin --- diff --git a/queue-6.1/btrfs-replace-sb-s_blocksize-by-fs_info-sectorsize.patch b/queue-6.1/btrfs-replace-sb-s_blocksize-by-fs_info-sectorsize.patch new file mode 100644 index 00000000000..aeb49c45d0a --- /dev/null +++ b/queue-6.1/btrfs-replace-sb-s_blocksize-by-fs_info-sectorsize.patch @@ -0,0 +1,160 @@ +From 514146c4b1ddb20e237c3409193e510d7978c09b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Jan 2024 17:33:20 +0100 +Subject: btrfs: replace sb::s_blocksize by fs_info::sectorsize + +From: David Sterba + +[ Upstream commit 4e00422ee62663e31e611d7de4d2c4aa3f8555f2 ] + +The block size stored in the super block is used by subsystems outside +of btrfs and it's a copy of fs_info::sectorsize. Unify that to always +use our sectorsize, with the exception of mount where we first need to +use fixed values (4K) until we read the super block and can set the +sectorsize. + +Replace all uses, in most cases it's fewer pointer indirections. + +Reviewed-by: Josef Bacik +Reviewed-by: Anand Jain +Signed-off-by: David Sterba +Stable-dep-of: 46a6e10a1ab1 ("btrfs: send: allow cloning non-aligned extent if it ends at i_size") +Signed-off-by: Sasha Levin +--- + fs/btrfs/disk-io.c | 2 ++ + fs/btrfs/extent_io.c | 4 ++-- + fs/btrfs/inode.c | 2 +- + fs/btrfs/ioctl.c | 2 +- + fs/btrfs/reflink.c | 6 +++--- + fs/btrfs/send.c | 2 +- + fs/btrfs/super.c | 2 +- + 7 files changed, 11 insertions(+), 9 deletions(-) + +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c +index c17232659942d..9ebb7bb37a22e 100644 +--- a/fs/btrfs/disk-io.c ++++ b/fs/btrfs/disk-io.c +@@ -3130,6 +3130,7 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block + int ret; + + fs_info->sb = sb; ++ /* Temporary fixed values for block size until we read the superblock. */ + sb->s_blocksize = BTRFS_BDEV_BLOCKSIZE; + sb->s_blocksize_bits = blksize_bits(BTRFS_BDEV_BLOCKSIZE); + +@@ -3628,6 +3629,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device + sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super); + sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE); + ++ /* Update the values for the current filesystem. */ + sb->s_blocksize = sectorsize; + sb->s_blocksize_bits = blksize_bits(sectorsize); + memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE); +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c +index 5f923c9b773e0..72227c0b4b5a1 100644 +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -1748,7 +1748,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, + int ret = 0; + size_t pg_offset = 0; + size_t iosize; +- size_t blocksize = inode->i_sb->s_blocksize; ++ size_t blocksize = fs_info->sectorsize; + struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; + + ret = set_page_extent_mapped(page); +@@ -3348,7 +3348,7 @@ int extent_invalidate_folio(struct extent_io_tree *tree, + struct extent_state *cached_state = NULL; + u64 start = folio_pos(folio); + u64 end = start + folio_size(folio) - 1; +- size_t blocksize = folio->mapping->host->i_sb->s_blocksize; ++ size_t blocksize = btrfs_sb(folio->mapping->host->i_sb)->sectorsize; + + /* This function is only called for the btree inode */ + ASSERT(tree->owner == IO_TREE_BTREE_INODE_IO); +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c +index bd3388e1b532e..934e360d1aefa 100644 +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -9111,7 +9111,7 @@ static int btrfs_getattr(struct user_namespace *mnt_userns, + u64 delalloc_bytes; + u64 inode_bytes; + struct inode *inode = d_inode(path->dentry); +- u32 blocksize = inode->i_sb->s_blocksize; ++ u32 blocksize = btrfs_sb(inode->i_sb)->sectorsize; + u32 bi_flags = BTRFS_I(inode)->flags; + u32 bi_ro_flags = BTRFS_I(inode)->ro_flags; + +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c +index 64b37afb7c87f..31f7fe31b607a 100644 +--- a/fs/btrfs/ioctl.c ++++ b/fs/btrfs/ioctl.c +@@ -517,7 +517,7 @@ static noinline int btrfs_ioctl_fitrim(struct btrfs_fs_info *fs_info, + * block group is in the logical address space, which can be any + * sectorsize aligned bytenr in the range [0, U64_MAX]. + */ +- if (range.len < fs_info->sb->s_blocksize) ++ if (range.len < fs_info->sectorsize) + return -EINVAL; + + range.minlen = max(range.minlen, minlen); +diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c +index f50586ff85c84..fc6e428525781 100644 +--- a/fs/btrfs/reflink.c ++++ b/fs/btrfs/reflink.c +@@ -659,7 +659,7 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len, + struct inode *dst, u64 dst_loff) + { + struct btrfs_fs_info *fs_info = BTRFS_I(src)->root->fs_info; +- const u64 bs = fs_info->sb->s_blocksize; ++ const u64 bs = fs_info->sectorsize; + int ret; + + /* +@@ -726,7 +726,7 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src, + int ret; + int wb_ret; + u64 len = olen; +- u64 bs = fs_info->sb->s_blocksize; ++ u64 bs = fs_info->sectorsize; + + /* + * VFS's generic_remap_file_range_prep() protects us from cloning the +@@ -792,7 +792,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in, + { + struct inode *inode_in = file_inode(file_in); + struct inode *inode_out = file_inode(file_out); +- u64 bs = BTRFS_I(inode_out)->root->fs_info->sb->s_blocksize; ++ u64 bs = BTRFS_I(inode_out)->root->fs_info->sectorsize; + u64 wb_len; + int ret; + +diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c +index cc57a97860d8a..e311cc291fe45 100644 +--- a/fs/btrfs/send.c ++++ b/fs/btrfs/send.c +@@ -5910,7 +5910,7 @@ static int send_write_or_clone(struct send_ctx *sctx, + int ret = 0; + u64 offset = key->offset; + u64 end; +- u64 bs = sctx->send_root->fs_info->sb->s_blocksize; ++ u64 bs = sctx->send_root->fs_info->sectorsize; + + end = min_t(u64, btrfs_file_extent_end(path), sctx->cur_inode_size); + if (offset >= end) +diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c +index 6fc5fa18d1ee6..d063379a031dc 100644 +--- a/fs/btrfs/super.c ++++ b/fs/btrfs/super.c +@@ -2426,7 +2426,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) + buf->f_bavail = 0; + + buf->f_type = BTRFS_SUPER_MAGIC; +- buf->f_bsize = dentry->d_sb->s_blocksize; ++ buf->f_bsize = fs_info->sectorsize; + buf->f_namelen = BTRFS_NAME_LEN; + + /* We treat it as constant endianness (it doesn't matter _which_) +-- +2.43.0 + diff --git a/queue-6.1/btrfs-send-allow-cloning-non-aligned-extent-if-it-en.patch b/queue-6.1/btrfs-send-allow-cloning-non-aligned-extent-if-it-en.patch new file mode 100644 index 00000000000..fab5e2dfdb0 --- /dev/null +++ b/queue-6.1/btrfs-send-allow-cloning-non-aligned-extent-if-it-en.patch @@ -0,0 +1,192 @@ +From f11261091894c9c9f1a979d593c9dddc670bc515 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 12 Aug 2024 14:18:06 +0100 +Subject: btrfs: send: allow cloning non-aligned extent if it ends at i_size + +From: Filipe Manana + +[ Upstream commit 46a6e10a1ab16cc71d4a3cab73e79aabadd6b8ea ] + +If we a find that an extent is shared but its end offset is not sector +size aligned, then we don't clone it and issue write operations instead. +This is because the reflink (remap_file_range) operation does not allow +to clone unaligned ranges, except if the end offset of the range matches +the i_size of the source and destination files (and the start offset is +sector size aligned). + +While this is not incorrect because send can only guarantee that a file +has the same data in the source and destination snapshots, it's not +optimal and generates confusion and surprising behaviour for users. + +For example, running this test: + + $ cat test.sh + #!/bin/bash + + DEV=/dev/sdi + MNT=/mnt/sdi + + mkfs.btrfs -f $DEV + mount $DEV $MNT + + # Use a file size not aligned to any possible sector size. + file_size=$((1 * 1024 * 1024 + 5)) # 1MB + 5 bytes + dd if=/dev/random of=$MNT/foo bs=$file_size count=1 + cp --reflink=always $MNT/foo $MNT/bar + + btrfs subvolume snapshot -r $MNT/ $MNT/snap + rm -f /tmp/send-test + btrfs send -f /tmp/send-test $MNT/snap + + umount $MNT + mkfs.btrfs -f $DEV + mount $DEV $MNT + + btrfs receive -vv -f /tmp/send-test $MNT + + xfs_io -r -c "fiemap -v" $MNT/snap/bar + + umount $MNT + +Gives the following result: + + (...) + mkfile o258-7-0 + rename o258-7-0 -> bar + write bar - offset=0 length=49152 + write bar - offset=49152 length=49152 + write bar - offset=98304 length=49152 + write bar - offset=147456 length=49152 + write bar - offset=196608 length=49152 + write bar - offset=245760 length=49152 + write bar - offset=294912 length=49152 + write bar - offset=344064 length=49152 + write bar - offset=393216 length=49152 + write bar - offset=442368 length=49152 + write bar - offset=491520 length=49152 + write bar - offset=540672 length=49152 + write bar - offset=589824 length=49152 + write bar - offset=638976 length=49152 + write bar - offset=688128 length=49152 + write bar - offset=737280 length=49152 + write bar - offset=786432 length=49152 + write bar - offset=835584 length=49152 + write bar - offset=884736 length=49152 + write bar - offset=933888 length=49152 + write bar - offset=983040 length=49152 + write bar - offset=1032192 length=16389 + chown bar - uid=0, gid=0 + chmod bar - mode=0644 + utimes bar + utimes + BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=06d640da-9ca1-604c-b87c-3375175a8eb3, stransid=7 + /mnt/sdi/snap/bar: + EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS + 0: [0..2055]: 26624..28679 2056 0x1 + +There's no clone operation to clone extents from the file foo into file +bar and fiemap confirms there's no shared flag (0x2000). + +So update send_write_or_clone() so that it proceeds with cloning if the +source and destination ranges end at the i_size of the respective files. + +After this changes the result of the test is: + + (...) + mkfile o258-7-0 + rename o258-7-0 -> bar + clone bar - source=foo source offset=0 offset=0 length=1048581 + chown bar - uid=0, gid=0 + chmod bar - mode=0644 + utimes bar + utimes + BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=582420f3-ea7d-564e-bbe5-ce440d622190, stransid=7 + /mnt/sdi/snap/bar: + EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS + 0: [0..2055]: 26624..28679 2056 0x2001 + +A test case for fstests will also follow up soon. + +Link: https://github.com/kdave/btrfs-progs/issues/572#issuecomment-2282841416 +CC: stable@vger.kernel.org # 5.10+ +Reviewed-by: Qu Wenruo +Signed-off-by: Filipe Manana +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Sasha Levin +--- + fs/btrfs/send.c | 52 ++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 39 insertions(+), 13 deletions(-) + +diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c +index e311cc291fe45..030edc1a9591b 100644 +--- a/fs/btrfs/send.c ++++ b/fs/btrfs/send.c +@@ -5911,25 +5911,51 @@ static int send_write_or_clone(struct send_ctx *sctx, + u64 offset = key->offset; + u64 end; + u64 bs = sctx->send_root->fs_info->sectorsize; ++ struct btrfs_file_extent_item *ei; ++ u64 disk_byte; ++ u64 data_offset; ++ u64 num_bytes; ++ struct btrfs_inode_info info = { 0 }; + + end = min_t(u64, btrfs_file_extent_end(path), sctx->cur_inode_size); + if (offset >= end) + return 0; + +- if (clone_root && IS_ALIGNED(end, bs)) { +- struct btrfs_file_extent_item *ei; +- u64 disk_byte; +- u64 data_offset; ++ num_bytes = end - offset; + +- ei = btrfs_item_ptr(path->nodes[0], path->slots[0], +- struct btrfs_file_extent_item); +- disk_byte = btrfs_file_extent_disk_bytenr(path->nodes[0], ei); +- data_offset = btrfs_file_extent_offset(path->nodes[0], ei); +- ret = clone_range(sctx, path, clone_root, disk_byte, +- data_offset, offset, end - offset); +- } else { +- ret = send_extent_data(sctx, path, offset, end - offset); +- } ++ if (!clone_root) ++ goto write_data; ++ ++ if (IS_ALIGNED(end, bs)) ++ goto clone_data; ++ ++ /* ++ * If the extent end is not aligned, we can clone if the extent ends at ++ * the i_size of the inode and the clone range ends at the i_size of the ++ * source inode, otherwise the clone operation fails with -EINVAL. ++ */ ++ if (end != sctx->cur_inode_size) ++ goto write_data; ++ ++ ret = get_inode_info(clone_root->root, clone_root->ino, &info); ++ if (ret < 0) ++ return ret; ++ ++ if (clone_root->offset + num_bytes == info.size) ++ goto clone_data; ++ ++write_data: ++ ret = send_extent_data(sctx, path, offset, num_bytes); ++ sctx->cur_inode_next_write_offset = end; ++ return ret; ++ ++clone_data: ++ ei = btrfs_item_ptr(path->nodes[0], path->slots[0], ++ struct btrfs_file_extent_item); ++ disk_byte = btrfs_file_extent_disk_bytenr(path->nodes[0], ei); ++ data_offset = btrfs_file_extent_offset(path->nodes[0], ei); ++ ret = clone_range(sctx, path, clone_root, disk_byte, data_offset, offset, ++ num_bytes); + sctx->cur_inode_next_write_offset = end; + return ret; + } +-- +2.43.0 + diff --git a/queue-6.1/dm-suspend-return-erestartsys-instead-of-eintr.patch b/queue-6.1/dm-suspend-return-erestartsys-instead-of-eintr.patch new file mode 100644 index 00000000000..1ba72174b6c --- /dev/null +++ b/queue-6.1/dm-suspend-return-erestartsys-instead-of-eintr.patch @@ -0,0 +1,48 @@ +From 0652497734f827c173fa15f05f393836d3b4d10b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 13 Aug 2024 12:38:51 +0200 +Subject: dm suspend: return -ERESTARTSYS instead of -EINTR + +From: Mikulas Patocka + +[ Upstream commit 1e1fd567d32fcf7544c6e09e0e5bc6c650da6e23 ] + +This commit changes device mapper, so that it returns -ERESTARTSYS +instead of -EINTR when it is interrupted by a signal (so that the ioctl +can be restarted). + +The manpage signal(7) says that the ioctl function should be restarted if +the signal was handled with SA_RESTART. + +Signed-off-by: Mikulas Patocka +Cc: stable@vger.kernel.org +Signed-off-by: Sasha Levin +--- + drivers/md/dm.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/md/dm.c b/drivers/md/dm.c +index 29270f6f272f6..ddd44a7f79dbf 100644 +--- a/drivers/md/dm.c ++++ b/drivers/md/dm.c +@@ -2511,7 +2511,7 @@ static int dm_wait_for_bios_completion(struct mapped_device *md, unsigned int ta + break; + + if (signal_pending_state(task_state, current)) { +- r = -EINTR; ++ r = -ERESTARTSYS; + break; + } + +@@ -2536,7 +2536,7 @@ static int dm_wait_for_completion(struct mapped_device *md, unsigned int task_st + break; + + if (signal_pending_state(task_state, current)) { +- r = -EINTR; ++ r = -ERESTARTSYS; + break; + } + +-- +2.43.0 + diff --git a/queue-6.1/drm-amd-display-adjust-cursor-position.patch b/queue-6.1/drm-amd-display-adjust-cursor-position.patch new file mode 100644 index 00000000000..22dcb89ef78 --- /dev/null +++ b/queue-6.1/drm-amd-display-adjust-cursor-position.patch @@ -0,0 +1,46 @@ +From 426485ec435a86e85a2086e7a883a4606a862c82 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 1 Aug 2024 16:16:35 -0600 +Subject: drm/amd/display: Adjust cursor position + +From: Rodrigo Siqueira + +[ Upstream commit 56fb276d0244d430496f249335a44ae114dd5f54 ] + +[why & how] +When the commit 9d84c7ef8a87 ("drm/amd/display: Correct cursor position +on horizontal mirror") was introduced, it used the wrong calculation for +the position copy for X. This commit uses the correct calculation for that +based on the original patch. + +Fixes: 9d84c7ef8a87 ("drm/amd/display: Correct cursor position on horizontal mirror") +Cc: Mario Limonciello +Cc: Alex Deucher +Acked-by: Wayne Lin +Signed-off-by: Rodrigo Siqueira +Signed-off-by: Tom Chung +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +(cherry picked from commit 8f9b23abbae5ffcd64856facd26a86b67195bc2f) +Cc: stable@vger.kernel.org +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +index d6c5d48c878ec..416168c7dcc52 100644 +--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c ++++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +@@ -3633,7 +3633,7 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx) + (int)hubp->curs_attr.width || pos_cpy.x + <= (int)hubp->curs_attr.width + + pipe_ctx->plane_state->src_rect.x) { +- pos_cpy.x = 2 * viewport_width - temp_x; ++ pos_cpy.x = temp_x + viewport_width; + } + } + } else { +-- +2.43.0 + diff --git a/queue-6.1/i2c-tegra-allow-dvc-support-to-be-compiled-out.patch b/queue-6.1/i2c-tegra-allow-dvc-support-to-be-compiled-out.patch new file mode 100644 index 00000000000..7fe4f6f186d --- /dev/null +++ b/queue-6.1/i2c-tegra-allow-dvc-support-to-be-compiled-out.patch @@ -0,0 +1,110 @@ +From 15e8b7b3a415c876e111b298e66e3d7cb251eacc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 6 May 2023 23:19:01 +0200 +Subject: i2c: tegra: allow DVC support to be compiled out +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michał Mirosław + +[ Upstream commit a55efa7edf37dc428da7058b25c58a54dc9db4e4 ] + +Save a bit of code for newer Tegra platforms by compiling out +DVC's I2C mode support that's used only for Tegra2. + +$ size i2c-tegra.o + text data bss dec hex filename +- 11381 292 8 11681 2da1 i2c-tegra.o ++ 10193 292 8 10493 28fd i2c-tegra.o + +Signed-off-by: Michał Mirosław +Reviewed-by: Dmitry Osipenko +Signed-off-by: Wolfram Sang +Stable-dep-of: 14d069d92951 ("i2c: tegra: Do not mark ACPI devices as irq safe") +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-tegra.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c +index aa469b33ee2ee..cc9dfd4f6c362 100644 +--- a/drivers/i2c/busses/i2c-tegra.c ++++ b/drivers/i2c/busses/i2c-tegra.c +@@ -298,6 +298,8 @@ struct tegra_i2c_dev { + bool is_vi; + }; + ++#define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && (dev)->is_dvc) ++ + static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, + unsigned int reg) + { +@@ -315,7 +317,7 @@ static u32 dvc_readl(struct tegra_i2c_dev *i2c_dev, unsigned int reg) + */ + static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg) + { +- if (i2c_dev->is_dvc) ++ if (IS_DVC(i2c_dev)) + reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40; + else if (i2c_dev->is_vi) + reg = 0xc00 + (reg << 2); +@@ -639,7 +641,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) + + WARN_ON_ONCE(err); + +- if (i2c_dev->is_dvc) ++ if (IS_DVC(i2c_dev)) + tegra_dvc_init(i2c_dev); + + val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN | +@@ -703,7 +705,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) + return err; + } + +- if (!i2c_dev->is_dvc && !i2c_dev->is_vi) { ++ if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) { + u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); + + sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; +@@ -933,7 +935,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) + } + + i2c_writel(i2c_dev, status, I2C_INT_STATUS); +- if (i2c_dev->is_dvc) ++ if (IS_DVC(i2c_dev)) + dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); + + /* +@@ -972,7 +974,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) + + i2c_writel(i2c_dev, status, I2C_INT_STATUS); + +- if (i2c_dev->is_dvc) ++ if (IS_DVC(i2c_dev)) + dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); + + if (i2c_dev->dma_mode) { +@@ -1660,7 +1662,9 @@ static const struct of_device_id tegra_i2c_of_match[] = { + { .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, }, + { .compatible = "nvidia,tegra30-i2c", .data = &tegra30_i2c_hw, }, + { .compatible = "nvidia,tegra20-i2c", .data = &tegra20_i2c_hw, }, ++#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-i2c-dvc", .data = &tegra20_i2c_hw, }, ++#endif + {}, + }; + MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); +@@ -1675,7 +1679,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) + multi_mode = device_property_read_bool(i2c_dev->dev, "multi-master"); + i2c_dev->multimaster_mode = multi_mode; + +- if (of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) ++ if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && ++ of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) + i2c_dev->is_dvc = true; + + if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) +-- +2.43.0 + diff --git a/queue-6.1/i2c-tegra-allow-vi-support-to-be-compiled-out.patch b/queue-6.1/i2c-tegra-allow-vi-support-to-be-compiled-out.patch new file mode 100644 index 00000000000..b0d4260fe92 --- /dev/null +++ b/queue-6.1/i2c-tegra-allow-vi-support-to-be-compiled-out.patch @@ -0,0 +1,146 @@ +From 856e5bd0d84a02b1faef7015f6353c043e250739 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 6 May 2023 23:19:02 +0200 +Subject: i2c: tegra: allow VI support to be compiled out +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michał Mirosław + +[ Upstream commit 4f5d68c8591498c3955dc0228ed6606c1b138278 ] + +Save a bit of code for older Tegra platforms by compiling out +VI's I2C mode support that's used only for Tegra210. + +$ size i2c-tegra.o + text data bss dec hex filename + 11381 292 8 11681 2da1 i2c-tegra.o (full) + 10193 292 8 10493 28fd i2c-tegra.o (no-dvc) + 9145 292 8 9445 24e5 i2c-tegra.o (no-vi,no-dvc) + +Signed-off-by: Michał Mirosław +Reviewed-by: Dmitry Osipenko +Signed-off-by: Wolfram Sang +Stable-dep-of: 14d069d92951 ("i2c: tegra: Do not mark ACPI devices as irq safe") +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-tegra.c | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c +index cc9dfd4f6c362..3792531b7ab7f 100644 +--- a/drivers/i2c/busses/i2c-tegra.c ++++ b/drivers/i2c/busses/i2c-tegra.c +@@ -299,6 +299,7 @@ struct tegra_i2c_dev { + }; + + #define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && (dev)->is_dvc) ++#define IS_VI(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) && (dev)->is_vi) + + static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, + unsigned int reg) +@@ -319,7 +320,7 @@ static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg) + { + if (IS_DVC(i2c_dev)) + reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40; +- else if (i2c_dev->is_vi) ++ else if (IS_VI(i2c_dev)) + reg = 0xc00 + (reg << 2); + + return reg; +@@ -332,7 +333,7 @@ static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg) + /* read back register to make sure that register writes completed */ + if (reg != I2C_TX_FIFO) + readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); +- else if (i2c_dev->is_vi) ++ else if (IS_VI(i2c_dev)) + readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, I2C_INT_STATUS)); + } + +@@ -448,7 +449,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) + u32 *dma_buf; + int err; + +- if (i2c_dev->is_vi) ++ if (IS_VI(i2c_dev)) + return 0; + + if (i2c_dev->hw->has_apb_dma) { +@@ -653,7 +654,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) + i2c_writel(i2c_dev, val, I2C_CNFG); + i2c_writel(i2c_dev, 0, I2C_INT_MASK); + +- if (i2c_dev->is_vi) ++ if (IS_VI(i2c_dev)) + tegra_i2c_vi_init(i2c_dev); + + switch (t->bus_freq_hz) { +@@ -705,7 +706,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) + return err; + } + +- if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) { ++ if (!IS_DVC(i2c_dev) && !IS_VI(i2c_dev)) { + u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); + + sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; +@@ -848,7 +849,7 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) + i2c_dev->msg_buf_remaining = buf_remaining; + i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD; + +- if (i2c_dev->is_vi) ++ if (IS_VI(i2c_dev)) + i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); + else + i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); +@@ -1656,7 +1657,9 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = { + static const struct of_device_id tegra_i2c_of_match[] = { + { .compatible = "nvidia,tegra194-i2c", .data = &tegra194_i2c_hw, }, + { .compatible = "nvidia,tegra186-i2c", .data = &tegra186_i2c_hw, }, ++#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) + { .compatible = "nvidia,tegra210-i2c-vi", .data = &tegra210_i2c_hw, }, ++#endif + { .compatible = "nvidia,tegra210-i2c", .data = &tegra210_i2c_hw, }, + { .compatible = "nvidia,tegra124-i2c", .data = &tegra124_i2c_hw, }, + { .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, }, +@@ -1683,7 +1686,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) + of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) + i2c_dev->is_dvc = true; + +- if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) ++ if (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) && ++ of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) + i2c_dev->is_vi = true; + } + +@@ -1712,7 +1716,7 @@ static int tegra_i2c_init_clocks(struct tegra_i2c_dev *i2c_dev) + if (i2c_dev->hw == &tegra20_i2c_hw || i2c_dev->hw == &tegra30_i2c_hw) + i2c_dev->clocks[i2c_dev->nclocks++].id = "fast-clk"; + +- if (i2c_dev->is_vi) ++ if (IS_VI(i2c_dev)) + i2c_dev->clocks[i2c_dev->nclocks++].id = "slow"; + + err = devm_clk_bulk_get(i2c_dev->dev, i2c_dev->nclocks, +@@ -1830,7 +1834,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) + * VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't + * be used for atomic transfers. + */ +- if (!i2c_dev->is_vi) ++ if (!IS_VI(i2c_dev)) + pm_runtime_irq_safe(i2c_dev->dev); + + pm_runtime_enable(i2c_dev->dev); +@@ -1903,7 +1907,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) + * power ON/OFF during runtime PM resume/suspend, meaning that + * controller needs to be re-initialized after power ON. + */ +- if (i2c_dev->is_vi) { ++ if (IS_VI(i2c_dev)) { + err = tegra_i2c_init(i2c_dev); + if (err) + goto disable_clocks; +-- +2.43.0 + diff --git a/queue-6.1/i2c-tegra-do-not-mark-acpi-devices-as-irq-safe.patch b/queue-6.1/i2c-tegra-do-not-mark-acpi-devices-as-irq-safe.patch new file mode 100644 index 00000000000..17330843a7f --- /dev/null +++ b/queue-6.1/i2c-tegra-do-not-mark-acpi-devices-as-irq-safe.patch @@ -0,0 +1,63 @@ +From 8540fbae9f3d0ee6acb1d41c59c664129bf54727 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 13 Aug 2024 09:12:53 -0700 +Subject: i2c: tegra: Do not mark ACPI devices as irq safe + +From: Breno Leitao + +[ Upstream commit 14d069d92951a3e150c0a81f2ca3b93e54da913b ] + +On ACPI machines, the tegra i2c module encounters an issue due to a +mutex being called inside a spinlock. This leads to the following bug: + + BUG: sleeping function called from invalid context at kernel/locking/mutex.c:585 + ... + + Call trace: + __might_sleep + __mutex_lock_common + mutex_lock_nested + acpi_subsys_runtime_resume + rpm_resume + tegra_i2c_xfer + +The problem arises because during __pm_runtime_resume(), the spinlock +&dev->power.lock is acquired before rpm_resume() is called. Later, +rpm_resume() invokes acpi_subsys_runtime_resume(), which relies on +mutexes, triggering the error. + +To address this issue, devices on ACPI are now marked as not IRQ-safe, +considering the dependency of acpi_subsys_runtime_resume() on mutexes. + +Fixes: bd2fdedbf2ba ("i2c: tegra: Add the ACPI support") +Cc: # v5.17+ +Co-developed-by: Michael van der Westhuizen +Signed-off-by: Michael van der Westhuizen +Signed-off-by: Breno Leitao +Reviewed-by: Dmitry Osipenko +Reviewed-by: Andy Shevchenko +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-tegra.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c +index 3792531b7ab7f..f7b4977d66496 100644 +--- a/drivers/i2c/busses/i2c-tegra.c ++++ b/drivers/i2c/busses/i2c-tegra.c +@@ -1832,9 +1832,9 @@ static int tegra_i2c_probe(struct platform_device *pdev) + * domain. + * + * VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't +- * be used for atomic transfers. ++ * be used for atomic transfers. ACPI device is not IRQ safe also. + */ +- if (!IS_VI(i2c_dev)) ++ if (!IS_VI(i2c_dev) && !has_acpi_companion(i2c_dev->dev)) + pm_runtime_irq_safe(i2c_dev->dev); + + pm_runtime_enable(i2c_dev->dev); +-- +2.43.0 + diff --git a/queue-6.1/net-mana-fix-doorbell-out-of-order-violation-and-avo.patch b/queue-6.1/net-mana-fix-doorbell-out-of-order-violation-and-avo.patch new file mode 100644 index 00000000000..eed02fdbe77 --- /dev/null +++ b/queue-6.1/net-mana-fix-doorbell-out-of-order-violation-and-avo.patch @@ -0,0 +1,98 @@ +From 10148fb39e1886261ba1e7b8840fea12cd6176e1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 9 Aug 2024 08:58:58 -0700 +Subject: net: mana: Fix doorbell out of order violation and avoid unnecessary + doorbell rings + +From: Long Li + +[ Upstream commit 58a63729c957621f1990c3494c702711188ca347 ] + +After napi_complete_done() is called when NAPI is polling in the current +process context, another NAPI may be scheduled and start running in +softirq on another CPU and may ring the doorbell before the current CPU +does. When combined with unnecessary rings when there is no need to arm +the CQ, it triggers error paths in the hardware. + +This patch fixes this by calling napi_complete_done() after doorbell +rings. It limits the number of unnecessary rings when there is +no need to arm. MANA hardware specifies that there must be one doorbell +ring every 8 CQ wraparounds. This driver guarantees one doorbell ring as +soon as the number of consumed CQEs exceeds 4 CQ wraparounds. In practical +workloads, the 4 CQ wraparounds proves to be big enough that it rarely +exceeds this limit before all the napi weight is consumed. + +To implement this, add a per-CQ counter cq->work_done_since_doorbell, +and make sure the CQ is armed as soon as passing 4 wraparounds of the CQ. + +Cc: stable@vger.kernel.org +Fixes: e1b5683ff62e ("net: mana: Move NAPI from EQ to CQ") +Reviewed-by: Haiyang Zhang +Signed-off-by: Long Li +Link: https://patch.msgid.link/1723219138-29887-1-git-send-email-longli@linuxonhyperv.com +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/microsoft/mana/mana.h | 1 + + drivers/net/ethernet/microsoft/mana/mana_en.c | 24 ++++++++++++------- + 2 files changed, 16 insertions(+), 9 deletions(-) + +diff --git a/drivers/net/ethernet/microsoft/mana/mana.h b/drivers/net/ethernet/microsoft/mana/mana.h +index d58be64374c84..41c99eabf40a0 100644 +--- a/drivers/net/ethernet/microsoft/mana/mana.h ++++ b/drivers/net/ethernet/microsoft/mana/mana.h +@@ -262,6 +262,7 @@ struct mana_cq { + /* NAPI data */ + struct napi_struct napi; + int work_done; ++ int work_done_since_doorbell; + int budget; + }; + +diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c +index b751b03eddfb1..e7d1ce68f05e3 100644 +--- a/drivers/net/ethernet/microsoft/mana/mana_en.c ++++ b/drivers/net/ethernet/microsoft/mana/mana_en.c +@@ -1311,7 +1311,6 @@ static void mana_poll_rx_cq(struct mana_cq *cq) + static int mana_cq_handler(void *context, struct gdma_queue *gdma_queue) + { + struct mana_cq *cq = context; +- u8 arm_bit; + int w; + + WARN_ON_ONCE(cq->gdma_cq != gdma_queue); +@@ -1322,16 +1321,23 @@ static int mana_cq_handler(void *context, struct gdma_queue *gdma_queue) + mana_poll_tx_cq(cq); + + w = cq->work_done; +- +- if (w < cq->budget && +- napi_complete_done(&cq->napi, w)) { +- arm_bit = SET_ARM_BIT; +- } else { +- arm_bit = 0; ++ cq->work_done_since_doorbell += w; ++ ++ if (w < cq->budget) { ++ mana_gd_ring_cq(gdma_queue, SET_ARM_BIT); ++ cq->work_done_since_doorbell = 0; ++ napi_complete_done(&cq->napi, w); ++ } else if (cq->work_done_since_doorbell > ++ cq->gdma_cq->queue_size / COMP_ENTRY_SIZE * 4) { ++ /* MANA hardware requires at least one doorbell ring every 8 ++ * wraparounds of CQ even if there is no need to arm the CQ. ++ * This driver rings the doorbell as soon as we have exceeded ++ * 4 wraparounds. ++ */ ++ mana_gd_ring_cq(gdma_queue, 0); ++ cq->work_done_since_doorbell = 0; + } + +- mana_gd_ring_cq(gdma_queue, arm_bit); +- + return w; + } + +-- +2.43.0 + diff --git a/queue-6.1/platform-surface-aggregator-fix-warning-when-control.patch b/queue-6.1/platform-surface-aggregator-fix-warning-when-control.patch new file mode 100644 index 00000000000..c9ec1239e5e --- /dev/null +++ b/queue-6.1/platform-surface-aggregator-fix-warning-when-control.patch @@ -0,0 +1,65 @@ +From 5fc4ccab9891ecb1648f3041842fcca11f7fedbf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 11 Aug 2024 14:46:44 +0200 +Subject: platform/surface: aggregator: Fix warning when controller is + destroyed in probe +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Maximilian Luz + +[ Upstream commit bc923d594db21bee0ead128eb4bb78f7e77467a4 ] + +There is a small window in ssam_serial_hub_probe() where the controller +is initialized but has not been started yet. Specifically, between +ssam_controller_init() and ssam_controller_start(). Any failure in this +window, for example caused by a failure of serdev_device_open(), +currently results in an incorrect warning being emitted. + +In particular, any failure in this window results in the controller +being destroyed via ssam_controller_destroy(). This function checks the +state of the controller and, in an attempt to validate that the +controller has been cleanly shut down before we try and deallocate any +resources, emits a warning if that state is not SSAM_CONTROLLER_STOPPED. + +However, since we have only just initialized the controller and have not +yet started it, its state is SSAM_CONTROLLER_INITIALIZED. Note that this +is the only point at which the controller has this state, as it will +change after we start the controller with ssam_controller_start() and +never revert back. Further, at this point no communication has taken +place and the sender and receiver threads have not been started yet (and +we may not even have an open serdev device either). + +Therefore, it is perfectly safe to call ssam_controller_destroy() with a +state of SSAM_CONTROLLER_INITIALIZED. This, however, means that the +warning currently being emitted is incorrect. Fix it by extending the +check. + +Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem") +Signed-off-by: Maximilian Luz +Link: https://lore.kernel.org/r/20240811124645.246016-1-luzmaximilian@gmail.com +Reviewed-by: Ilpo Järvinen +Signed-off-by: Ilpo Järvinen +Signed-off-by: Sasha Levin +--- + drivers/platform/surface/aggregator/controller.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c +index 30cea324ff95f..a6a8f4b1836a6 100644 +--- a/drivers/platform/surface/aggregator/controller.c ++++ b/drivers/platform/surface/aggregator/controller.c +@@ -1354,7 +1354,8 @@ void ssam_controller_destroy(struct ssam_controller *ctrl) + if (ctrl->state == SSAM_CONTROLLER_UNINITIALIZED) + return; + +- WARN_ON(ctrl->state != SSAM_CONTROLLER_STOPPED); ++ WARN_ON(ctrl->state != SSAM_CONTROLLER_STOPPED && ++ ctrl->state != SSAM_CONTROLLER_INITIALIZED); + + /* + * Note: New events could still have been received after the previous +-- +2.43.0 + diff --git a/queue-6.1/series b/queue-6.1/series index b5286f8f201..523e5fac84e 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -211,3 +211,12 @@ drm-amdgpu-fix-dereference-null-return-value-for-the.patch hrtimer-prevent-queuing-of-hrtimer-without-a-functio.patch gtp-pull-network-headers-in-gtp_dev_xmit.patch media-solo6x10-replace-max-a-min-b-c-by-clamp-b-a-c.patch +i2c-tegra-allow-dvc-support-to-be-compiled-out.patch +i2c-tegra-allow-vi-support-to-be-compiled-out.patch +i2c-tegra-do-not-mark-acpi-devices-as-irq-safe.patch +dm-suspend-return-erestartsys-instead-of-eintr.patch +net-mana-fix-doorbell-out-of-order-violation-and-avo.patch +btrfs-replace-sb-s_blocksize-by-fs_info-sectorsize.patch +btrfs-send-allow-cloning-non-aligned-extent-if-it-en.patch +drm-amd-display-adjust-cursor-position.patch +platform-surface-aggregator-fix-warning-when-control.patch