--- /dev/null
+From d9f54aaa3fb75a788335bd84b8b2e95279502892 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 16:03:38 -0700
+Subject: blk-mq: allow 4x BLK_MAX_REQUEST_COUNT at blk_plug for
+ multiple_queues
+
+From: Song Liu <songliubraving@fb.com>
+
+[ Upstream commit 7f2a6a69f7ced6db8220298e0497cf60482a9d4b ]
+
+Limiting number of request to BLK_MAX_REQUEST_COUNT at blk_plug hurts
+performance for large md arrays. [1] shows resync speed of md array drops
+for md array with more than 16 HDDs.
+
+Fix this by allowing more request at plug queue. The multiple_queue flag
+is used to only apply higher limit to multiple queue cases.
+
+[1] https://lore.kernel.org/linux-raid/CAFDAVznS71BXW8Jxv6k9dXc2iR3ysX3iZRBww_rzA8WifBFxGg@mail.gmail.com/
+Tested-by: Marcin Wanat <marcin.wanat@gmail.com>
+Signed-off-by: Song Liu <songliubraving@fb.com>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ block/blk-mq.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/block/blk-mq.c b/block/blk-mq.c
+index 9e3fedbaa644..6dcb86c1c985 100644
+--- a/block/blk-mq.c
++++ b/block/blk-mq.c
+@@ -2109,6 +2109,18 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)
+ }
+ }
+
++/*
++ * Allow 4x BLK_MAX_REQUEST_COUNT requests on plug queue for multiple
++ * queues. This is important for md arrays to benefit from merging
++ * requests.
++ */
++static inline unsigned short blk_plug_max_rq_count(struct blk_plug *plug)
++{
++ if (plug->multiple_queues)
++ return BLK_MAX_REQUEST_COUNT * 4;
++ return BLK_MAX_REQUEST_COUNT;
++}
++
+ /**
+ * blk_mq_submit_bio - Create and send a request to block device.
+ * @bio: Bio pointer.
+@@ -2202,7 +2214,7 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
+ else
+ last = list_entry_rq(plug->mq_list.prev);
+
+- if (request_count >= BLK_MAX_REQUEST_COUNT || (last &&
++ if (request_count >= blk_plug_max_rq_count(plug) || (last &&
+ blk_rq_bytes(last) >= BLK_PLUG_FLUSH_SIZE)) {
+ blk_flush_plug_list(plug, false);
+ trace_block_plug(q);
+--
+2.33.0
+
--- /dev/null
+From 84b5256444d05cfefc18dc5789b76868024c0c81 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:12:42 +0800
+Subject: blk-throttle: fix UAF by deleteing timer in blk_throtl_exit()
+
+From: Li Jinlin <lijinlin3@huawei.com>
+
+[ Upstream commit 884f0e84f1e3195b801319c8ec3d5774e9bf2710 ]
+
+The pending timer has been set up in blk_throtl_init(). However, the
+timer is not deleted in blk_throtl_exit(). This means that the timer
+handler may still be running after freeing the timer, which would
+result in a use-after-free.
+
+Fix by calling del_timer_sync() to delete the timer in blk_throtl_exit().
+
+Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
+Link: https://lore.kernel.org/r/20210907121242.2885564-1-lijinlin3@huawei.com
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ block/blk-throttle.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/block/blk-throttle.c b/block/blk-throttle.c
+index 63e9d00a0832..c53a254171a2 100644
+--- a/block/blk-throttle.c
++++ b/block/blk-throttle.c
+@@ -2452,6 +2452,7 @@ int blk_throtl_init(struct request_queue *q)
+ void blk_throtl_exit(struct request_queue *q)
+ {
+ BUG_ON(!q->td);
++ del_timer_sync(&q->td->service_queue.pending_timer);
+ throtl_shutdown_wq(q);
+ blkcg_deactivate_policy(q, &blkcg_policy_throtl);
+ free_percpu(q->td->latency_buckets[READ]);
+--
+2.33.0
+
--- /dev/null
+From dc52485b0860117a5000de04b9bffabaf339d233 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Aug 2021 09:21:28 +0800
+Subject: btrfs: fix lockdep warning while mounting sprout fs
+
+From: Anand Jain <anand.jain@oracle.com>
+
+[ Upstream commit c124706900c20dee70f921bb3a90492431561a0a ]
+
+Following test case reproduces lockdep warning.
+
+ Test case:
+
+ $ mkfs.btrfs -f <dev1>
+ $ btrfstune -S 1 <dev1>
+ $ mount <dev1> <mnt>
+ $ btrfs device add <dev2> <mnt> -f
+ $ umount <mnt>
+ $ mount <dev2> <mnt>
+ $ umount <mnt>
+
+The warning claims a possible ABBA deadlock between the threads
+initiated by [#1] btrfs device add and [#0] the mount.
+
+ [ 540.743122] WARNING: possible circular locking dependency detected
+ [ 540.743129] 5.11.0-rc7+ #5 Not tainted
+ [ 540.743135] ------------------------------------------------------
+ [ 540.743142] mount/2515 is trying to acquire lock:
+ [ 540.743149] ffffa0c5544c2ce0 (&fs_devs->device_list_mutex){+.+.}-{4:4}, at: clone_fs_devices+0x6d/0x210 [btrfs]
+ [ 540.743458] but task is already holding lock:
+ [ 540.743461] ffffa0c54a7932b8 (btrfs-chunk-00){++++}-{4:4}, at: __btrfs_tree_read_lock+0x32/0x200 [btrfs]
+ [ 540.743541] which lock already depends on the new lock.
+ [ 540.743543] the existing dependency chain (in reverse order) is:
+
+ [ 540.743546] -> #1 (btrfs-chunk-00){++++}-{4:4}:
+ [ 540.743566] down_read_nested+0x48/0x2b0
+ [ 540.743585] __btrfs_tree_read_lock+0x32/0x200 [btrfs]
+ [ 540.743650] btrfs_read_lock_root_node+0x70/0x200 [btrfs]
+ [ 540.743733] btrfs_search_slot+0x6c6/0xe00 [btrfs]
+ [ 540.743785] btrfs_update_device+0x83/0x260 [btrfs]
+ [ 540.743849] btrfs_finish_chunk_alloc+0x13f/0x660 [btrfs] <--- device_list_mutex
+ [ 540.743911] btrfs_create_pending_block_groups+0x18d/0x3f0 [btrfs]
+ [ 540.743982] btrfs_commit_transaction+0x86/0x1260 [btrfs]
+ [ 540.744037] btrfs_init_new_device+0x1600/0x1dd0 [btrfs]
+ [ 540.744101] btrfs_ioctl+0x1c77/0x24c0 [btrfs]
+ [ 540.744166] __x64_sys_ioctl+0xe4/0x140
+ [ 540.744170] do_syscall_64+0x4b/0x80
+ [ 540.744174] entry_SYSCALL_64_after_hwframe+0x44/0xa9
+
+ [ 540.744180] -> #0 (&fs_devs->device_list_mutex){+.+.}-{4:4}:
+ [ 540.744184] __lock_acquire+0x155f/0x2360
+ [ 540.744188] lock_acquire+0x10b/0x5c0
+ [ 540.744190] __mutex_lock+0xb1/0xf80
+ [ 540.744193] mutex_lock_nested+0x27/0x30
+ [ 540.744196] clone_fs_devices+0x6d/0x210 [btrfs]
+ [ 540.744270] btrfs_read_chunk_tree+0x3c7/0xbb0 [btrfs]
+ [ 540.744336] open_ctree+0xf6e/0x2074 [btrfs]
+ [ 540.744406] btrfs_mount_root.cold.72+0x16/0x127 [btrfs]
+ [ 540.744472] legacy_get_tree+0x38/0x90
+ [ 540.744475] vfs_get_tree+0x30/0x140
+ [ 540.744478] fc_mount+0x16/0x60
+ [ 540.744482] vfs_kern_mount+0x91/0x100
+ [ 540.744484] btrfs_mount+0x1e6/0x670 [btrfs]
+ [ 540.744536] legacy_get_tree+0x38/0x90
+ [ 540.744537] vfs_get_tree+0x30/0x140
+ [ 540.744539] path_mount+0x8d8/0x1070
+ [ 540.744541] do_mount+0x8d/0xc0
+ [ 540.744543] __x64_sys_mount+0x125/0x160
+ [ 540.744545] do_syscall_64+0x4b/0x80
+ [ 540.744547] entry_SYSCALL_64_after_hwframe+0x44/0xa9
+
+ [ 540.744551] other info that might help us debug this:
+ [ 540.744552] Possible unsafe locking scenario:
+
+ [ 540.744553] CPU0 CPU1
+ [ 540.744554] ---- ----
+ [ 540.744555] lock(btrfs-chunk-00);
+ [ 540.744557] lock(&fs_devs->device_list_mutex);
+ [ 540.744560] lock(btrfs-chunk-00);
+ [ 540.744562] lock(&fs_devs->device_list_mutex);
+ [ 540.744564]
+ *** DEADLOCK ***
+
+ [ 540.744565] 3 locks held by mount/2515:
+ [ 540.744567] #0: ffffa0c56bf7a0e0 (&type->s_umount_key#42/1){+.+.}-{4:4}, at: alloc_super.isra.16+0xdf/0x450
+ [ 540.744574] #1: ffffffffc05a9628 (uuid_mutex){+.+.}-{4:4}, at: btrfs_read_chunk_tree+0x63/0xbb0 [btrfs]
+ [ 540.744640] #2: ffffa0c54a7932b8 (btrfs-chunk-00){++++}-{4:4}, at: __btrfs_tree_read_lock+0x32/0x200 [btrfs]
+ [ 540.744708]
+ stack backtrace:
+ [ 540.744712] CPU: 2 PID: 2515 Comm: mount Not tainted 5.11.0-rc7+ #5
+
+But the device_list_mutex in clone_fs_devices() is redundant, as
+explained below. Two threads [1] and [2] (below) could lead to
+clone_fs_device().
+
+ [1]
+ open_ctree <== mount sprout fs
+ btrfs_read_chunk_tree()
+ mutex_lock(&uuid_mutex) <== global lock
+ read_one_dev()
+ open_seed_devices()
+ clone_fs_devices() <== seed fs_devices
+ mutex_lock(&orig->device_list_mutex) <== seed fs_devices
+
+ [2]
+ btrfs_init_new_device() <== sprouting
+ mutex_lock(&uuid_mutex); <== global lock
+ btrfs_prepare_sprout()
+ lockdep_assert_held(&uuid_mutex)
+ clone_fs_devices(seed_fs_device) <== seed fs_devices
+
+Both of these threads hold uuid_mutex which is sufficient to protect
+getting the seed device(s) freed while we are trying to clone it for
+sprouting [2] or mounting a sprout [1] (as above). A mounted seed device
+can not free/write/replace because it is read-only. An unmounted seed
+device can be freed by btrfs_free_stale_devices(), but it needs
+uuid_mutex. So this patch removes the unnecessary device_list_mutex in
+clone_fs_devices(). And adds a lockdep_assert_held(&uuid_mutex) in
+clone_fs_devices().
+
+Reported-by: Su Yue <l@damenly.su>
+Tested-by: Su Yue <l@damenly.su>
+Signed-off-by: Anand Jain <anand.jain@oracle.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/volumes.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
+index 994ec44fc597..509811aabb3f 100644
+--- a/fs/btrfs/volumes.c
++++ b/fs/btrfs/volumes.c
+@@ -568,6 +568,8 @@ static int btrfs_free_stale_devices(const char *path,
+ struct btrfs_device *device, *tmp_device;
+ int ret = 0;
+
++ lockdep_assert_held(&uuid_mutex);
++
+ if (path)
+ ret = -ENOENT;
+
+@@ -999,11 +1001,12 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
+ struct btrfs_device *orig_dev;
+ int ret = 0;
+
++ lockdep_assert_held(&uuid_mutex);
++
+ fs_devices = alloc_fs_devices(orig->fsid, NULL);
+ if (IS_ERR(fs_devices))
+ return fs_devices;
+
+- mutex_lock(&orig->device_list_mutex);
+ fs_devices->total_devices = orig->total_devices;
+
+ list_for_each_entry(orig_dev, &orig->devices, dev_list) {
+@@ -1035,10 +1038,8 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
+ device->fs_devices = fs_devices;
+ fs_devices->num_devices++;
+ }
+- mutex_unlock(&orig->device_list_mutex);
+ return fs_devices;
+ error:
+- mutex_unlock(&orig->device_list_mutex);
+ free_fs_devices(fs_devices);
+ return ERR_PTR(ret);
+ }
+--
+2.33.0
+
--- /dev/null
+From 24d13edf410c911c2fcf1c34de039500695cfd03 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 27 Jul 2021 17:01:16 -0400
+Subject: btrfs: update the bdev time directly when closing
+
+From: Josef Bacik <josef@toxicpanda.com>
+
+[ Upstream commit 8f96a5bfa1503e0a5f3c78d51e993a1794d4aff1 ]
+
+We update the ctime/mtime of a block device when we remove it so that
+blkid knows the device changed. However we do this by re-opening the
+block device and calling filp_update_time. This is more correct because
+it'll call the inode->i_op->update_time if it exists, but the block dev
+inodes do not do this. Instead call generic_update_time() on the
+bd_inode in order to avoid the blkdev_open path and get rid of the
+following lockdep splat:
+
+======================================================
+WARNING: possible circular locking dependency detected
+5.14.0-rc2+ #406 Not tainted
+------------------------------------------------------
+losetup/11596 is trying to acquire lock:
+ffff939640d2f538 ((wq_completion)loop0){+.+.}-{0:0}, at: flush_workqueue+0x67/0x5e0
+
+but task is already holding lock:
+ffff939655510c68 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x660 [loop]
+
+which lock already depends on the new lock.
+
+the existing dependency chain (in reverse order) is:
+
+-> #4 (&lo->lo_mutex){+.+.}-{3:3}:
+ __mutex_lock+0x7d/0x750
+ lo_open+0x28/0x60 [loop]
+ blkdev_get_whole+0x25/0xf0
+ blkdev_get_by_dev.part.0+0x168/0x3c0
+ blkdev_open+0xd2/0xe0
+ do_dentry_open+0x161/0x390
+ path_openat+0x3cc/0xa20
+ do_filp_open+0x96/0x120
+ do_sys_openat2+0x7b/0x130
+ __x64_sys_openat+0x46/0x70
+ do_syscall_64+0x38/0x90
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+-> #3 (&disk->open_mutex){+.+.}-{3:3}:
+ __mutex_lock+0x7d/0x750
+ blkdev_get_by_dev.part.0+0x56/0x3c0
+ blkdev_open+0xd2/0xe0
+ do_dentry_open+0x161/0x390
+ path_openat+0x3cc/0xa20
+ do_filp_open+0x96/0x120
+ file_open_name+0xc7/0x170
+ filp_open+0x2c/0x50
+ btrfs_scratch_superblocks.part.0+0x10f/0x170
+ btrfs_rm_device.cold+0xe8/0xed
+ btrfs_ioctl+0x2a31/0x2e70
+ __x64_sys_ioctl+0x80/0xb0
+ do_syscall_64+0x38/0x90
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+-> #2 (sb_writers#12){.+.+}-{0:0}:
+ lo_write_bvec+0xc2/0x240 [loop]
+ loop_process_work+0x238/0xd00 [loop]
+ process_one_work+0x26b/0x560
+ worker_thread+0x55/0x3c0
+ kthread+0x140/0x160
+ ret_from_fork+0x1f/0x30
+
+-> #1 ((work_completion)(&lo->rootcg_work)){+.+.}-{0:0}:
+ process_one_work+0x245/0x560
+ worker_thread+0x55/0x3c0
+ kthread+0x140/0x160
+ ret_from_fork+0x1f/0x30
+
+-> #0 ((wq_completion)loop0){+.+.}-{0:0}:
+ __lock_acquire+0x10ea/0x1d90
+ lock_acquire+0xb5/0x2b0
+ flush_workqueue+0x91/0x5e0
+ drain_workqueue+0xa0/0x110
+ destroy_workqueue+0x36/0x250
+ __loop_clr_fd+0x9a/0x660 [loop]
+ block_ioctl+0x3f/0x50
+ __x64_sys_ioctl+0x80/0xb0
+ do_syscall_64+0x38/0x90
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+other info that might help us debug this:
+
+Chain exists of:
+ (wq_completion)loop0 --> &disk->open_mutex --> &lo->lo_mutex
+
+ Possible unsafe locking scenario:
+
+ CPU0 CPU1
+ ---- ----
+ lock(&lo->lo_mutex);
+ lock(&disk->open_mutex);
+ lock(&lo->lo_mutex);
+ lock((wq_completion)loop0);
+
+ *** DEADLOCK ***
+
+1 lock held by losetup/11596:
+ #0: ffff939655510c68 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x41/0x660 [loop]
+
+stack backtrace:
+CPU: 1 PID: 11596 Comm: losetup Not tainted 5.14.0-rc2+ #406
+Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
+Call Trace:
+ dump_stack_lvl+0x57/0x72
+ check_noncircular+0xcf/0xf0
+ ? stack_trace_save+0x3b/0x50
+ __lock_acquire+0x10ea/0x1d90
+ lock_acquire+0xb5/0x2b0
+ ? flush_workqueue+0x67/0x5e0
+ ? lockdep_init_map_type+0x47/0x220
+ flush_workqueue+0x91/0x5e0
+ ? flush_workqueue+0x67/0x5e0
+ ? verify_cpu+0xf0/0x100
+ drain_workqueue+0xa0/0x110
+ destroy_workqueue+0x36/0x250
+ __loop_clr_fd+0x9a/0x660 [loop]
+ ? blkdev_ioctl+0x8d/0x2a0
+ block_ioctl+0x3f/0x50
+ __x64_sys_ioctl+0x80/0xb0
+ do_syscall_64+0x38/0x90
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+Reviewed-by: Anand Jain <anand.jain@oracle.com>
+Signed-off-by: Josef Bacik <josef@toxicpanda.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/volumes.c | 18 ++++++++++--------
+ 1 file changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
+index b4fcc48f255b..994ec44fc597 100644
+--- a/fs/btrfs/volumes.c
++++ b/fs/btrfs/volumes.c
+@@ -1855,15 +1855,17 @@ out:
+ * Function to update ctime/mtime for a given device path.
+ * Mainly used for ctime/mtime based probe like libblkid.
+ */
+-static void update_dev_time(const char *path_name)
++static void update_dev_time(struct block_device *bdev)
+ {
+- struct file *filp;
++ struct inode *inode = bdev->bd_inode;
++ struct timespec64 now;
+
+- filp = filp_open(path_name, O_RDWR, 0);
+- if (IS_ERR(filp))
++ /* Shouldn't happen but just in case. */
++ if (!inode)
+ return;
+- file_update_time(filp);
+- filp_close(filp, NULL);
++
++ now = current_time(inode);
++ generic_update_time(inode, &now, S_MTIME | S_CTIME);
+ }
+
+ static int btrfs_rm_dev_item(struct btrfs_device *device)
+@@ -2038,7 +2040,7 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
+ btrfs_kobject_uevent(bdev, KOBJ_CHANGE);
+
+ /* Update ctime/mtime for device path for libblkid */
+- update_dev_time(device_path);
++ update_dev_time(bdev);
+ }
+
+ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
+@@ -2681,7 +2683,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
+ btrfs_forget_devices(device_path);
+
+ /* Update ctime/mtime for blkid or udev */
+- update_dev_time(device_path);
++ update_dev_time(bdev);
+
+ return ret;
+
+--
+2.33.0
+
--- /dev/null
+From b29182059f166bdac02925185d42f5f0deb99b49 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 9 Jun 2021 14:09:52 -0400
+Subject: ceph: allow ceph_put_mds_session to take NULL or ERR_PTR
+
+From: Jeff Layton <jlayton@kernel.org>
+
+[ Upstream commit 7e65624d32b6e0429b1d3559e5585657f34f74a1 ]
+
+...to simplify some error paths.
+
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Reviewed-by: Luis Henriques <lhenriques@suse.de>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ceph/dir.c | 3 +--
+ fs/ceph/inode.c | 6 ++----
+ fs/ceph/mds_client.c | 6 ++++--
+ fs/ceph/metric.c | 3 +--
+ 4 files changed, 8 insertions(+), 10 deletions(-)
+
+diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
+index a4d48370b2b3..f63c1a090139 100644
+--- a/fs/ceph/dir.c
++++ b/fs/ceph/dir.c
+@@ -1797,8 +1797,7 @@ static void ceph_d_release(struct dentry *dentry)
+ dentry->d_fsdata = NULL;
+ spin_unlock(&dentry->d_lock);
+
+- if (di->lease_session)
+- ceph_put_mds_session(di->lease_session);
++ ceph_put_mds_session(di->lease_session);
+ kmem_cache_free(ceph_dentry_cachep, di);
+ }
+
+diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
+index 57cd78e942c0..63e781e4f7e4 100644
+--- a/fs/ceph/inode.c
++++ b/fs/ceph/inode.c
+@@ -1121,8 +1121,7 @@ static inline void update_dentry_lease(struct inode *dir, struct dentry *dentry,
+ __update_dentry_lease(dir, dentry, lease, session, from_time,
+ &old_lease_session);
+ spin_unlock(&dentry->d_lock);
+- if (old_lease_session)
+- ceph_put_mds_session(old_lease_session);
++ ceph_put_mds_session(old_lease_session);
+ }
+
+ /*
+@@ -1167,8 +1166,7 @@ static void update_dentry_lease_careful(struct dentry *dentry,
+ from_time, &old_lease_session);
+ out_unlock:
+ spin_unlock(&dentry->d_lock);
+- if (old_lease_session)
+- ceph_put_mds_session(old_lease_session);
++ ceph_put_mds_session(old_lease_session);
+ }
+
+ /*
+diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
+index 816cea497537..8cbbb611e0ca 100644
+--- a/fs/ceph/mds_client.c
++++ b/fs/ceph/mds_client.c
+@@ -661,6 +661,9 @@ struct ceph_mds_session *ceph_get_mds_session(struct ceph_mds_session *s)
+
+ void ceph_put_mds_session(struct ceph_mds_session *s)
+ {
++ if (IS_ERR_OR_NULL(s))
++ return;
++
+ dout("mdsc put_session %p %d -> %d\n", s,
+ refcount_read(&s->s_ref), refcount_read(&s->s_ref)-1);
+ if (refcount_dec_and_test(&s->s_ref)) {
+@@ -1435,8 +1438,7 @@ static void __open_export_target_sessions(struct ceph_mds_client *mdsc,
+
+ for (i = 0; i < mi->num_export_targets; i++) {
+ ts = __open_export_target_session(mdsc, mi->export_targets[i]);
+- if (!IS_ERR(ts))
+- ceph_put_mds_session(ts);
++ ceph_put_mds_session(ts);
+ }
+ }
+
+diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
+index fee4c4778313..3b2ef8ee544e 100644
+--- a/fs/ceph/metric.c
++++ b/fs/ceph/metric.c
+@@ -233,8 +233,7 @@ void ceph_metric_destroy(struct ceph_client_metric *m)
+
+ cancel_delayed_work_sync(&m->delayed_work);
+
+- if (m->session)
+- ceph_put_mds_session(m->session);
++ ceph_put_mds_session(m->session);
+ }
+
+ static inline void __update_latency(ktime_t *totalp, ktime_t *lsump,
+--
+2.33.0
+
--- /dev/null
+From c75b58ba4b65df1324953f7d2482b17c6e8c917c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 27 Jul 2021 15:47:12 -0400
+Subject: ceph: cancel delayed work instead of flushing on mdsc teardown
+
+From: Jeff Layton <jlayton@kernel.org>
+
+[ Upstream commit b4002173b7989588b6feaefc42edaf011b596782 ]
+
+The first thing metric_delayed_work does is check mdsc->stopping,
+and then return immediately if it's set. That's good since we would
+have already torn down the metric structures at this point, otherwise,
+but there is no locking around mdsc->stopping.
+
+It's possible that the ceph_metric_destroy call could race with the
+delayed_work, in which case we could end up with the delayed_work
+accessing destroyed percpu variables.
+
+At this point in the mdsc teardown, the "stopping" flag has already been
+set, so there's no benefit to flushing the work. Move the work
+cancellation in ceph_metric_destroy ahead of the percpu variable
+destruction, and eliminate the flush_delayed_work call in
+ceph_mdsc_destroy.
+
+Fixes: 18f473b384a6 ("ceph: periodically send perf metrics to MDSes")
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Reviewed-by: Xiubo Li <xiubli@redhat.com>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ceph/mds_client.c | 1 -
+ fs/ceph/metric.c | 4 ++--
+ 2 files changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
+index 8cbbb611e0ca..46606fb5b886 100644
+--- a/fs/ceph/mds_client.c
++++ b/fs/ceph/mds_client.c
+@@ -4859,7 +4859,6 @@ void ceph_mdsc_destroy(struct ceph_fs_client *fsc)
+
+ ceph_metric_destroy(&mdsc->metric);
+
+- flush_delayed_work(&mdsc->metric.delayed_work);
+ fsc->mdsc = NULL;
+ kfree(mdsc);
+ dout("mdsc_destroy %p done\n", mdsc);
+diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c
+index 3b2ef8ee544e..9e0a0e26294e 100644
+--- a/fs/ceph/metric.c
++++ b/fs/ceph/metric.c
+@@ -224,6 +224,8 @@ void ceph_metric_destroy(struct ceph_client_metric *m)
+ if (!m)
+ return;
+
++ cancel_delayed_work_sync(&m->delayed_work);
++
+ percpu_counter_destroy(&m->total_inodes);
+ percpu_counter_destroy(&m->opened_inodes);
+ percpu_counter_destroy(&m->i_caps_mis);
+@@ -231,8 +233,6 @@ void ceph_metric_destroy(struct ceph_client_metric *m)
+ percpu_counter_destroy(&m->d_lease_mis);
+ percpu_counter_destroy(&m->d_lease_hit);
+
+- cancel_delayed_work_sync(&m->delayed_work);
+-
+ ceph_put_mds_session(m->session);
+ }
+
+--
+2.33.0
+
--- /dev/null
+From 1ca7c5223ee43c4bd4b2db49d1c1c65536aff904 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Sep 2021 08:31:03 -0400
+Subject: ceph: lockdep annotations for try_nonblocking_invalidate
+
+From: Jeff Layton <jlayton@kernel.org>
+
+[ Upstream commit 3eaf5aa1cfa8c97c72f5824e2e9263d6cc977b03 ]
+
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ceph/caps.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
+index f303e0d87c3f..48ea95b81df8 100644
+--- a/fs/ceph/caps.c
++++ b/fs/ceph/caps.c
+@@ -1868,6 +1868,8 @@ static u64 __mark_caps_flushing(struct inode *inode,
+ * try to invalidate mapping pages without blocking.
+ */
+ static int try_nonblocking_invalidate(struct inode *inode)
++ __releases(ci->i_ceph_lock)
++ __acquires(ci->i_ceph_lock)
+ {
+ struct ceph_inode_info *ci = ceph_inode(inode);
+ u32 invalidating_gen = ci->i_rdcache_gen;
+--
+2.33.0
+
--- /dev/null
+From 41acbd57a8523b76fee3332cc402c5effb37ea36 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 25 Aug 2021 21:45:43 +0800
+Subject: ceph: remove the capsnaps when removing caps
+
+From: Xiubo Li <xiubli@redhat.com>
+
+[ Upstream commit a6d37ccdd240e80f26aaea0e62cda310e0e184d7 ]
+
+capsnaps will take inode references via ihold when queueing to flush.
+When force unmounting, the client will just close the sessions and
+may never get a flush reply, causing a leak and inode ref leak.
+
+Fix this by removing the capsnaps for an inode when removing the caps.
+
+URL: https://tracker.ceph.com/issues/52295
+Signed-off-by: Xiubo Li <xiubli@redhat.com>
+Reviewed-by: Jeff Layton <jlayton@kernel.org>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ceph/caps.c | 68 +++++++++++++++++++++++++++++++++-----------
+ fs/ceph/mds_client.c | 31 +++++++++++++++++++-
+ fs/ceph/super.h | 6 ++++
+ 3 files changed, 87 insertions(+), 18 deletions(-)
+
+diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
+index 678dac8365ed..f303e0d87c3f 100644
+--- a/fs/ceph/caps.c
++++ b/fs/ceph/caps.c
+@@ -3169,7 +3169,16 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
+ break;
+ }
+ }
+- BUG_ON(!found);
++
++ if (!found) {
++ /*
++ * The capsnap should already be removed when removing
++ * auth cap in the case of a forced unmount.
++ */
++ WARN_ON_ONCE(ci->i_auth_cap);
++ goto unlock;
++ }
++
+ capsnap->dirty_pages -= nr;
+ if (capsnap->dirty_pages == 0) {
+ complete_capsnap = true;
+@@ -3191,6 +3200,7 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
+ complete_capsnap ? " (complete capsnap)" : "");
+ }
+
++unlock:
+ spin_unlock(&ci->i_ceph_lock);
+
+ if (last) {
+@@ -3657,6 +3667,43 @@ out:
+ iput(inode);
+ }
+
++void __ceph_remove_capsnap(struct inode *inode, struct ceph_cap_snap *capsnap,
++ bool *wake_ci, bool *wake_mdsc)
++{
++ struct ceph_inode_info *ci = ceph_inode(inode);
++ struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
++ bool ret;
++
++ lockdep_assert_held(&ci->i_ceph_lock);
++
++ dout("removing capsnap %p, inode %p ci %p\n", capsnap, inode, ci);
++
++ list_del_init(&capsnap->ci_item);
++ ret = __detach_cap_flush_from_ci(ci, &capsnap->cap_flush);
++ if (wake_ci)
++ *wake_ci = ret;
++
++ spin_lock(&mdsc->cap_dirty_lock);
++ if (list_empty(&ci->i_cap_flush_list))
++ list_del_init(&ci->i_flushing_item);
++
++ ret = __detach_cap_flush_from_mdsc(mdsc, &capsnap->cap_flush);
++ if (wake_mdsc)
++ *wake_mdsc = ret;
++ spin_unlock(&mdsc->cap_dirty_lock);
++}
++
++void ceph_remove_capsnap(struct inode *inode, struct ceph_cap_snap *capsnap,
++ bool *wake_ci, bool *wake_mdsc)
++{
++ struct ceph_inode_info *ci = ceph_inode(inode);
++
++ lockdep_assert_held(&ci->i_ceph_lock);
++
++ WARN_ON_ONCE(capsnap->dirty_pages || capsnap->writing);
++ __ceph_remove_capsnap(inode, capsnap, wake_ci, wake_mdsc);
++}
++
+ /*
+ * Handle FLUSHSNAP_ACK. MDS has flushed snap data to disk and we can
+ * throw away our cap_snap.
+@@ -3694,23 +3741,10 @@ static void handle_cap_flushsnap_ack(struct inode *inode, u64 flush_tid,
+ capsnap, capsnap->follows);
+ }
+ }
+- if (flushed) {
+- WARN_ON(capsnap->dirty_pages || capsnap->writing);
+- dout(" removing %p cap_snap %p follows %lld\n",
+- inode, capsnap, follows);
+- list_del(&capsnap->ci_item);
+- wake_ci |= __detach_cap_flush_from_ci(ci, &capsnap->cap_flush);
+-
+- spin_lock(&mdsc->cap_dirty_lock);
+-
+- if (list_empty(&ci->i_cap_flush_list))
+- list_del_init(&ci->i_flushing_item);
+-
+- wake_mdsc |= __detach_cap_flush_from_mdsc(mdsc,
+- &capsnap->cap_flush);
+- spin_unlock(&mdsc->cap_dirty_lock);
+- }
++ if (flushed)
++ ceph_remove_capsnap(inode, capsnap, &wake_ci, &wake_mdsc);
+ spin_unlock(&ci->i_ceph_lock);
++
+ if (flushed) {
+ ceph_put_snap_context(capsnap->context);
+ ceph_put_cap_snap(capsnap);
+diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
+index 46606fb5b886..0f57b7d09457 100644
+--- a/fs/ceph/mds_client.c
++++ b/fs/ceph/mds_client.c
+@@ -1587,14 +1587,39 @@ out:
+ return ret;
+ }
+
++static int remove_capsnaps(struct ceph_mds_client *mdsc, struct inode *inode)
++{
++ struct ceph_inode_info *ci = ceph_inode(inode);
++ struct ceph_cap_snap *capsnap;
++ int capsnap_release = 0;
++
++ lockdep_assert_held(&ci->i_ceph_lock);
++
++ dout("removing capsnaps, ci is %p, inode is %p\n", ci, inode);
++
++ while (!list_empty(&ci->i_cap_snaps)) {
++ capsnap = list_first_entry(&ci->i_cap_snaps,
++ struct ceph_cap_snap, ci_item);
++ __ceph_remove_capsnap(inode, capsnap, NULL, NULL);
++ ceph_put_snap_context(capsnap->context);
++ ceph_put_cap_snap(capsnap);
++ capsnap_release++;
++ }
++ wake_up_all(&ci->i_cap_wq);
++ wake_up_all(&mdsc->cap_flushing_wq);
++ return capsnap_release;
++}
++
+ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
+ void *arg)
+ {
+ struct ceph_fs_client *fsc = (struct ceph_fs_client *)arg;
++ struct ceph_mds_client *mdsc = fsc->mdsc;
+ struct ceph_inode_info *ci = ceph_inode(inode);
+ LIST_HEAD(to_remove);
+ bool dirty_dropped = false;
+ bool invalidate = false;
++ int capsnap_release = 0;
+
+ dout("removing cap %p, ci is %p, inode is %p\n",
+ cap, ci, &ci->vfs_inode);
+@@ -1602,7 +1627,6 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
+ __ceph_remove_cap(cap, false);
+ if (!ci->i_auth_cap) {
+ struct ceph_cap_flush *cf;
+- struct ceph_mds_client *mdsc = fsc->mdsc;
+
+ if (READ_ONCE(fsc->mount_state) == CEPH_MOUNT_SHUTDOWN) {
+ if (inode->i_data.nrpages > 0)
+@@ -1666,6 +1690,9 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
+ list_add(&ci->i_prealloc_cap_flush->i_list, &to_remove);
+ ci->i_prealloc_cap_flush = NULL;
+ }
++
++ if (!list_empty(&ci->i_cap_snaps))
++ capsnap_release = remove_capsnaps(mdsc, inode);
+ }
+ spin_unlock(&ci->i_ceph_lock);
+ while (!list_empty(&to_remove)) {
+@@ -1682,6 +1709,8 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
+ ceph_queue_invalidate(inode);
+ if (dirty_dropped)
+ iput(inode);
++ while (capsnap_release--)
++ iput(inode);
+ return 0;
+ }
+
+diff --git a/fs/ceph/super.h b/fs/ceph/super.h
+index a8c460393b01..9362eeb5812d 100644
+--- a/fs/ceph/super.h
++++ b/fs/ceph/super.h
+@@ -1134,6 +1134,12 @@ extern void ceph_put_cap_refs_no_check_caps(struct ceph_inode_info *ci,
+ int had);
+ extern void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
+ struct ceph_snap_context *snapc);
++extern void __ceph_remove_capsnap(struct inode *inode,
++ struct ceph_cap_snap *capsnap,
++ bool *wake_ci, bool *wake_mdsc);
++extern void ceph_remove_capsnap(struct inode *inode,
++ struct ceph_cap_snap *capsnap,
++ bool *wake_ci, bool *wake_mdsc);
+ extern void ceph_flush_snaps(struct ceph_inode_info *ci,
+ struct ceph_mds_session **psession);
+ extern bool __ceph_should_report_size(struct ceph_inode_info *ci);
+--
+2.33.0
+
--- /dev/null
+From 31f84b7a243fa5eb1d0a5d67df8508f995149e8a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 11 Aug 2021 06:40:42 -0400
+Subject: ceph: request Fw caps before updating the mtime in ceph_write_iter
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Jeff Layton <jlayton@kernel.org>
+
+[ Upstream commit b11ed50346683a749632ea664959b28d524d7395 ]
+
+The current code will update the mtime and then try to get caps to
+handle the write. If we end up having to request caps from the MDS, then
+the mtime in the cap grant will clobber the updated mtime and it'll be
+lost.
+
+This is most noticable when two clients are alternately writing to the
+same file. Fw caps are continually being granted and revoked, and the
+mtime ends up stuck because the updated mtimes are always being
+overwritten with the old one.
+
+Fix this by changing the order of operations in ceph_write_iter to get
+the caps before updating the times. Also, make sure we check the pool
+full conditions before even getting any caps or uninlining.
+
+URL: https://tracker.ceph.com/issues/46574
+Reported-by: Jozef Kováč <kovac@firma.zoznam.sk>
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Reviewed-by: Xiubo Li <xiubli@redhat.com>
+Reviewed-by: Luis Henriques <lhenriques@suse.de>
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ceph/file.c | 32 +++++++++++++++++---------------
+ 1 file changed, 17 insertions(+), 15 deletions(-)
+
+diff --git a/fs/ceph/file.c b/fs/ceph/file.c
+index 3d2e3dd4ee01..f1895f78ab45 100644
+--- a/fs/ceph/file.c
++++ b/fs/ceph/file.c
+@@ -1723,32 +1723,26 @@ retry_snap:
+ goto out;
+ }
+
+- err = file_remove_privs(file);
+- if (err)
++ down_read(&osdc->lock);
++ map_flags = osdc->osdmap->flags;
++ pool_flags = ceph_pg_pool_flags(osdc->osdmap, ci->i_layout.pool_id);
++ up_read(&osdc->lock);
++ if ((map_flags & CEPH_OSDMAP_FULL) ||
++ (pool_flags & CEPH_POOL_FLAG_FULL)) {
++ err = -ENOSPC;
+ goto out;
++ }
+
+- err = file_update_time(file);
++ err = file_remove_privs(file);
+ if (err)
+ goto out;
+
+- inode_inc_iversion_raw(inode);
+-
+ if (ci->i_inline_version != CEPH_INLINE_NONE) {
+ err = ceph_uninline_data(file, NULL);
+ if (err < 0)
+ goto out;
+ }
+
+- down_read(&osdc->lock);
+- map_flags = osdc->osdmap->flags;
+- pool_flags = ceph_pg_pool_flags(osdc->osdmap, ci->i_layout.pool_id);
+- up_read(&osdc->lock);
+- if ((map_flags & CEPH_OSDMAP_FULL) ||
+- (pool_flags & CEPH_POOL_FLAG_FULL)) {
+- err = -ENOSPC;
+- goto out;
+- }
+-
+ dout("aio_write %p %llx.%llx %llu~%zd getting caps. i_size %llu\n",
+ inode, ceph_vinop(inode), pos, count, i_size_read(inode));
+ if (fi->fmode & CEPH_FILE_MODE_LAZY)
+@@ -1761,6 +1755,12 @@ retry_snap:
+ if (err < 0)
+ goto out;
+
++ err = file_update_time(file);
++ if (err)
++ goto out_caps;
++
++ inode_inc_iversion_raw(inode);
++
+ dout("aio_write %p %llx.%llx %llu~%zd got cap refs on %s\n",
+ inode, ceph_vinop(inode), pos, count, ceph_cap_string(got));
+
+@@ -1844,6 +1844,8 @@ retry_snap:
+ }
+
+ goto out_unlocked;
++out_caps:
++ ceph_put_cap_refs(ci, got);
+ out:
+ if (direct_lock)
+ ceph_end_io_direct(inode);
+--
+2.33.0
+
--- /dev/null
+From fec85ccd6a2feafbfc6791fc7058824708a1aaba Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Sep 2021 14:49:11 +0200
+Subject: dma-buf: DMABUF_MOVE_NOTIFY should depend on DMA_SHARED_BUFFER
+
+From: Geert Uytterhoeven <geert@linux-m68k.org>
+
+[ Upstream commit c4f3a3460a5daebc772d9263500e4099b11e7300 ]
+
+Move notify between drivers is an option of DMA-BUF. Enabling
+DMABUF_MOVE_NOTIFY without DMA_SHARED_BUFFER does not have any impact,
+as drivers/dma-buf/ is not entered during the build when
+DMA_SHARED_BUFFER is disabled.
+
+Fixes: bb42df4662a44765 ("dma-buf: add dynamic DMA-buf handling v15")
+Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Link: https://patchwork.freedesktop.org/patch/msgid/20210902124913.2698760-2-geert@linux-m68k.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma-buf/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig
+index 4f8224a6ac95..3ca7de37dd8f 100644
+--- a/drivers/dma-buf/Kconfig
++++ b/drivers/dma-buf/Kconfig
+@@ -42,6 +42,7 @@ config UDMABUF
+ config DMABUF_MOVE_NOTIFY
+ bool "Move notify between drivers (EXPERIMENTAL)"
+ default n
++ depends on DMA_SHARED_BUFFER
+ help
+ Don't pin buffers if the dynamic DMA-buf interface is available on
+ both the exporter as well as the importer. This fixes a security
+--
+2.33.0
+
--- /dev/null
+From 4aeb9203326561e0d782c0a515f96986c7dc1a23 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 25 Jun 2021 10:38:10 +0200
+Subject: dmaengine: idxd: depends on !UML
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit b2296eeac91555bd13f774efa7ab7d4b12fb71ef ]
+
+Now that UML has PCI support, this driver must depend also on
+!UML since it pokes at X86_64 architecture internals that don't
+exist on ARCH=um.
+
+Reported-by: kernel test robot <lkp@intel.com>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Acked-by: Dave Jiang <dave.jiang@intel.com>
+Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
+Link: https://lore.kernel.org/r/20210625103810.fe877ae0aef4.If240438e3f50ae226f3f755fc46ea498c6858393@changeid
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
+index f28bb2334e74..3a745e8a0f42 100644
+--- a/drivers/dma/Kconfig
++++ b/drivers/dma/Kconfig
+@@ -285,7 +285,7 @@ config INTEL_IDMA64
+
+ config INTEL_IDXD
+ tristate "Intel Data Accelerators support"
+- depends on PCI && X86_64
++ depends on PCI && X86_64 && !UML
+ depends on PCI_MSI
+ depends on SBITMAP
+ select DMA_ENGINE
+--
+2.33.0
+
--- /dev/null
+From d9c240b65c6a7d3e000db6b64f674f0dddb42c10 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 22 Jul 2021 10:54:10 -0700
+Subject: dmaengine: idxd: fix wq slot allocation index check
+
+From: Dave Jiang <dave.jiang@intel.com>
+
+[ Upstream commit 673d812d30be67942762bb9e8548abb26a3ba4a7 ]
+
+The sbitmap wait and allocate routine checks the index that is returned
+from sbitmap_queue_get(). It should be idxd >= 0 as 0 is also a valid
+index. This fixes issue where submission path hangs when WQ size is 1.
+
+Fixes: 0705107fcc80 ("dmaengine: idxd: move submission to sbitmap_queue")
+Signed-off-by: Dave Jiang <dave.jiang@intel.com>
+Link: https://lore.kernel.org/r/162697645067.3478714.506720687816951762.stgit@djiang5-desk3.ch.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/idxd/submit.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/idxd/submit.c b/drivers/dma/idxd/submit.c
+index 417048e3c42a..0368c5490788 100644
+--- a/drivers/dma/idxd/submit.c
++++ b/drivers/dma/idxd/submit.c
+@@ -45,7 +45,7 @@ struct idxd_desc *idxd_alloc_desc(struct idxd_wq *wq, enum idxd_op_type optype)
+ if (signal_pending_state(TASK_INTERRUPTIBLE, current))
+ break;
+ idx = sbitmap_queue_get(sbq, &cpu);
+- if (idx > 0)
++ if (idx >= 0)
+ break;
+ schedule();
+ }
+--
+2.33.0
+
--- /dev/null
+From b0c26e8198eef03ca7221ce66e25bfa40a9ecbea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 9 Aug 2021 11:24:09 +0200
+Subject: dmaengine: ioat: depends on !UML
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit bbac7a92a46f0876e588722ebe552ddfe6fd790f ]
+
+Now that UML has PCI support, this driver must depend also on
+!UML since it pokes at X86_64 architecture internals that don't
+exist on ARCH=um.
+
+Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Acked-by: Dave Jiang <dave.jiang@intel.com>
+Link: https://lore.kernel.org/r/20210809112409.a3a0974874d2.I2ffe3d11ed37f735da2f39884a74c953b258b995@changeid
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
+index 3a745e8a0f42..08013345d1f2 100644
+--- a/drivers/dma/Kconfig
++++ b/drivers/dma/Kconfig
+@@ -299,7 +299,7 @@ config INTEL_IDXD
+
+ config INTEL_IOATDMA
+ tristate "Intel I/OAT DMA support"
+- depends on PCI && X86_64
++ depends on PCI && X86_64 && !UML
+ select DMA_ENGINE
+ select DMA_ENGINE_RAID
+ select DCA
+--
+2.33.0
+
--- /dev/null
+From 13514cc3d9f0d8e7f6f0a7a483f8db4808f3a2db Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 4 May 2021 10:22:57 +0800
+Subject: dmaengine: sprd: Add missing MODULE_DEVICE_TABLE
+
+From: Zou Wei <zou_wei@huawei.com>
+
+[ Upstream commit 4faee8b65ec32346f8096e64c5fa1d5a73121742 ]
+
+This patch adds missing MODULE_DEVICE_TABLE definition which generates
+correct modalias for automatic loading of this driver when it is built
+as an external module.
+
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Zou Wei <zou_wei@huawei.com>
+Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
+Link: https://lore.kernel.org/r/1620094977-70146-1-git-send-email-zou_wei@huawei.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/sprd-dma.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
+index 0ef5ca81ba4d..4357d2395e6b 100644
+--- a/drivers/dma/sprd-dma.c
++++ b/drivers/dma/sprd-dma.c
+@@ -1265,6 +1265,7 @@ static const struct of_device_id sprd_dma_match[] = {
+ { .compatible = "sprd,sc9860-dma", },
+ {},
+ };
++MODULE_DEVICE_TABLE(of, sprd_dma_match);
+
+ static int __maybe_unused sprd_dma_runtime_suspend(struct device *dev)
+ {
+--
+2.33.0
+
--- /dev/null
+From 568c1f420b7ce7e44af43fb1c12941d570712096 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 19 Aug 2021 14:28:48 +0530
+Subject: dmaengine: xilinx_dma: Set DMA mask for coherent APIs
+
+From: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
+
+[ Upstream commit aac6c0f90799d66b8989be1e056408f33fd99fe6 ]
+
+The xilinx dma driver uses the consistent allocations, so for correct
+operation also set the DMA mask for coherent APIs. It fixes the below
+kernel crash with dmatest client when DMA IP is configured with 64-bit
+address width and linux is booted from high (>4GB) memory.
+
+Call trace:
+[ 489.531257] dma_alloc_from_pool+0x8c/0x1c0
+[ 489.535431] dma_direct_alloc+0x284/0x330
+[ 489.539432] dma_alloc_attrs+0x80/0xf0
+[ 489.543174] dma_pool_alloc+0x160/0x2c0
+[ 489.547003] xilinx_cdma_prep_memcpy+0xa4/0x180
+[ 489.551524] dmatest_func+0x3cc/0x114c
+[ 489.555266] kthread+0x124/0x130
+[ 489.558486] ret_from_fork+0x10/0x3c
+[ 489.562051] ---[ end trace 248625b2d596a90a ]---
+
+Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
+Reviewed-by: Harini Katakam <harini.katakam@xilinx.com>
+Link: https://lore.kernel.org/r/1629363528-30347-1-git-send-email-radhey.shyam.pandey@xilinx.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/xilinx/xilinx_dma.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
+index 9ffdbeec436b..cab4719e4cf9 100644
+--- a/drivers/dma/xilinx/xilinx_dma.c
++++ b/drivers/dma/xilinx/xilinx_dma.c
+@@ -3070,7 +3070,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
+ xdev->ext_addr = false;
+
+ /* Set the dma mask bits */
+- dma_set_mask(xdev->dev, DMA_BIT_MASK(addr_width));
++ dma_set_mask_and_coherent(xdev->dev, DMA_BIT_MASK(addr_width));
+
+ /* Initialize the DMA engine */
+ xdev->common.dev = &pdev->dev;
+--
+2.33.0
+
--- /dev/null
+From c70b020616e5560bed5c343a7510a6c22126a330 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Aug 2021 13:48:34 +0200
+Subject: drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION()
+
+From: Thomas Gleixner <tglx@linutronix.de>
+
+[ Upstream commit 4b92d4add5f6dcf21275185c997d6ecb800054cd ]
+
+DEFINE_SMP_CALL_CACHE_FUNCTION() was usefel before the CPU hotplug rework
+to ensure that the cache related functions are called on the upcoming CPU
+because the notifier itself could run on any online CPU.
+
+The hotplug state machine guarantees that the callbacks are invoked on the
+upcoming CPU. So there is no need to have this SMP function call
+obfuscation. That indirection was missed when the hotplug notifiers were
+converted.
+
+This also solves the problem of ARM64 init_cache_level() invoking ACPI
+functions which take a semaphore in that context. That's invalid as SMP
+function calls run with interrupts disabled. Running it just from the
+callback in context of the CPU hotplug thread solves this.
+
+Fixes: 8571890e1513 ("arm64: Add support for ACPI based firmware tables")
+Reported-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Tested-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Will Deacon <will@kernel.org>
+Acked-by: Peter Zijlstra <peterz@infradead.org>
+Link: https://lore.kernel.org/r/871r69ersb.ffs@tglx
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm64/kernel/cacheinfo.c | 7 ++-----
+ arch/mips/kernel/cacheinfo.c | 7 ++-----
+ arch/riscv/kernel/cacheinfo.c | 7 ++-----
+ arch/x86/kernel/cpu/cacheinfo.c | 7 ++-----
+ include/linux/cacheinfo.h | 18 ------------------
+ 5 files changed, 8 insertions(+), 38 deletions(-)
+
+diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c
+index 7fa6828bb488..587543c6c51c 100644
+--- a/arch/arm64/kernel/cacheinfo.c
++++ b/arch/arm64/kernel/cacheinfo.c
+@@ -43,7 +43,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
+ this_leaf->type = type;
+ }
+
+-static int __init_cache_level(unsigned int cpu)
++int init_cache_level(unsigned int cpu)
+ {
+ unsigned int ctype, level, leaves, fw_level;
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+@@ -78,7 +78,7 @@ static int __init_cache_level(unsigned int cpu)
+ return 0;
+ }
+
+-static int __populate_cache_leaves(unsigned int cpu)
++int populate_cache_leaves(unsigned int cpu)
+ {
+ unsigned int level, idx;
+ enum cache_type type;
+@@ -97,6 +97,3 @@ static int __populate_cache_leaves(unsigned int cpu)
+ }
+ return 0;
+ }
+-
+-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
+-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
+diff --git a/arch/mips/kernel/cacheinfo.c b/arch/mips/kernel/cacheinfo.c
+index 47312c529410..529dab855aac 100644
+--- a/arch/mips/kernel/cacheinfo.c
++++ b/arch/mips/kernel/cacheinfo.c
+@@ -17,7 +17,7 @@ do { \
+ leaf++; \
+ } while (0)
+
+-static int __init_cache_level(unsigned int cpu)
++int init_cache_level(unsigned int cpu)
+ {
+ struct cpuinfo_mips *c = ¤t_cpu_data;
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+@@ -69,7 +69,7 @@ static void fill_cpumask_cluster(int cpu, cpumask_t *cpu_map)
+ cpumask_set_cpu(cpu1, cpu_map);
+ }
+
+-static int __populate_cache_leaves(unsigned int cpu)
++int populate_cache_leaves(unsigned int cpu)
+ {
+ struct cpuinfo_mips *c = ¤t_cpu_data;
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+@@ -98,6 +98,3 @@ static int __populate_cache_leaves(unsigned int cpu)
+
+ return 0;
+ }
+-
+-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
+-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
+diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c
+index d86781357044..90deabfe63ea 100644
+--- a/arch/riscv/kernel/cacheinfo.c
++++ b/arch/riscv/kernel/cacheinfo.c
+@@ -113,7 +113,7 @@ static void fill_cacheinfo(struct cacheinfo **this_leaf,
+ }
+ }
+
+-static int __init_cache_level(unsigned int cpu)
++int init_cache_level(unsigned int cpu)
+ {
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+ struct device_node *np = of_cpu_device_node_get(cpu);
+@@ -155,7 +155,7 @@ static int __init_cache_level(unsigned int cpu)
+ return 0;
+ }
+
+-static int __populate_cache_leaves(unsigned int cpu)
++int populate_cache_leaves(unsigned int cpu)
+ {
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+ struct cacheinfo *this_leaf = this_cpu_ci->info_list;
+@@ -187,6 +187,3 @@ static int __populate_cache_leaves(unsigned int cpu)
+
+ return 0;
+ }
+-
+-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
+-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
+diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
+index f9ac682e75e7..b458b0fd98bf 100644
+--- a/arch/x86/kernel/cpu/cacheinfo.c
++++ b/arch/x86/kernel/cpu/cacheinfo.c
+@@ -985,7 +985,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
+ this_leaf->priv = base->nb;
+ }
+
+-static int __init_cache_level(unsigned int cpu)
++int init_cache_level(unsigned int cpu)
+ {
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+
+@@ -1014,7 +1014,7 @@ static void get_cache_id(int cpu, struct _cpuid4_info_regs *id4_regs)
+ id4_regs->id = c->apicid >> index_msb;
+ }
+
+-static int __populate_cache_leaves(unsigned int cpu)
++int populate_cache_leaves(unsigned int cpu)
+ {
+ unsigned int idx, ret;
+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+@@ -1033,6 +1033,3 @@ static int __populate_cache_leaves(unsigned int cpu)
+
+ return 0;
+ }
+-
+-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
+-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
+diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
+index 4f72b47973c3..2f909ed084c6 100644
+--- a/include/linux/cacheinfo.h
++++ b/include/linux/cacheinfo.h
+@@ -79,24 +79,6 @@ struct cpu_cacheinfo {
+ bool cpu_map_populated;
+ };
+
+-/*
+- * Helpers to make sure "func" is executed on the cpu whose cache
+- * attributes are being detected
+- */
+-#define DEFINE_SMP_CALL_CACHE_FUNCTION(func) \
+-static inline void _##func(void *ret) \
+-{ \
+- int cpu = smp_processor_id(); \
+- *(int *)ret = __##func(cpu); \
+-} \
+- \
+-int func(unsigned int cpu) \
+-{ \
+- int ret; \
+- smp_call_function_single(cpu, _##func, &ret, true); \
+- return ret; \
+-}
+-
+ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu);
+ int init_cache_level(unsigned int cpu);
+ int populate_cache_leaves(unsigned int cpu);
+--
+2.33.0
+
--- /dev/null
+From 3bfb9dfd79a2998115fa441bb5da827eaec98fbd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Aug 2021 10:02:00 +0800
+Subject: drm/amdgpu: Disable PCIE_DPM on Intel RKL Platform
+
+From: Koba Ko <koba.ko@canonical.com>
+
+[ Upstream commit b3dc549986eb7b38eba4a144e979dc93f386751f ]
+
+Due to high latency in PCIE clock switching on RKL platforms,
+switching the PCIE clock dynamically at runtime can lead to HDMI/DP
+audio problems. On newer asics this is handled in the SMU firmware.
+For SMU7-based asics, disable PCIE clock switching to avoid the issue.
+
+AMD provide a parameter to disable PICE_DPM.
+
+modprobe amdgpu ppfeaturemask=0xfff7bffb
+
+It's better to contorl PCIE_DPM in amd gpu driver,
+switch PCI_DPM by determining intel RKL platform for SMU7-based asics.
+
+Fixes: 1a31474cdb48 ("drm/amd/pm: workaround for audio noise issue")
+Ref: https://lists.freedesktop.org/archives/amd-gfx/2021-August/067413.html
+Signed-off-by: Koba Ko <koba.ko@canonical.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+index b76425164e29..7931528bc864 100644
+--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+@@ -27,6 +27,9 @@
+ #include <linux/pci.h>
+ #include <linux/slab.h>
+ #include <asm/div64.h>
++#if IS_ENABLED(CONFIG_X86_64)
++#include <asm/intel-family.h>
++#endif
+ #include <drm/amdgpu_drm.h>
+ #include "ppatomctrl.h"
+ #include "atombios.h"
+@@ -1606,6 +1609,17 @@ static int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
+ return result;
+ }
+
++static bool intel_core_rkl_chk(void)
++{
++#if IS_ENABLED(CONFIG_X86_64)
++ struct cpuinfo_x86 *c = &cpu_data(0);
++
++ return (c->x86 == 6 && c->x86_model == INTEL_FAM6_ROCKETLAKE);
++#else
++ return false;
++#endif
++}
++
+ static void smu7_init_dpm_defaults(struct pp_hwmgr *hwmgr)
+ {
+ struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
+@@ -1629,7 +1643,8 @@ static void smu7_init_dpm_defaults(struct pp_hwmgr *hwmgr)
+
+ data->mclk_dpm_key_disabled = hwmgr->feature_mask & PP_MCLK_DPM_MASK ? false : true;
+ data->sclk_dpm_key_disabled = hwmgr->feature_mask & PP_SCLK_DPM_MASK ? false : true;
+- data->pcie_dpm_key_disabled = hwmgr->feature_mask & PP_PCIE_DPM_MASK ? false : true;
++ data->pcie_dpm_key_disabled =
++ intel_core_rkl_chk() || !(hwmgr->feature_mask & PP_PCIE_DPM_MASK);
+ /* need to set voltage control types before EVV patching */
+ data->voltage_control = SMU7_VOLTAGE_CONTROL_NONE;
+ data->vddci_control = SMU7_VOLTAGE_CONTROL_NONE;
+--
+2.33.0
+
--- /dev/null
+From 671089e25c4f90c30d214b7c25589e25e9c356ec Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 20 Jul 2021 09:16:05 +0300
+Subject: habanalabs: add validity check for event ID received from F/W
+
+From: Ofir Bitton <obitton@habana.ai>
+
+[ Upstream commit a6c849012b0f51c674f52384bd9a4f3dc0a33c31 ]
+
+Currently there is no validity check for event ID received from F/W,
+Thus exposing driver to memory overrun.
+
+Signed-off-by: Ofir Bitton <obitton@habana.ai>
+Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
+Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/misc/habanalabs/gaudi/gaudi.c | 6 ++++++
+ drivers/misc/habanalabs/goya/goya.c | 6 ++++++
+ 2 files changed, 12 insertions(+)
+
+diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
+index 37edd663603f..ebac53a73bd1 100644
+--- a/drivers/misc/habanalabs/gaudi/gaudi.c
++++ b/drivers/misc/habanalabs/gaudi/gaudi.c
+@@ -5723,6 +5723,12 @@ static void gaudi_handle_eqe(struct hl_device *hdev,
+ u8 cause;
+ bool reset_required;
+
++ if (event_type >= GAUDI_EVENT_SIZE) {
++ dev_err(hdev->dev, "Event type %u exceeds maximum of %u",
++ event_type, GAUDI_EVENT_SIZE - 1);
++ return;
++ }
++
+ gaudi->events_stat[event_type]++;
+ gaudi->events_stat_aggregate[event_type]++;
+
+diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
+index 5b5d6275c249..c8023b4428c5 100644
+--- a/drivers/misc/habanalabs/goya/goya.c
++++ b/drivers/misc/habanalabs/goya/goya.c
+@@ -4623,6 +4623,12 @@ void goya_handle_eqe(struct hl_device *hdev, struct hl_eq_entry *eq_entry)
+ >> EQ_CTL_EVENT_TYPE_SHIFT);
+ struct goya_device *goya = hdev->asic_specific;
+
++ if (event_type >= GOYA_ASYNC_EVENT_ID_SIZE) {
++ dev_err(hdev->dev, "Event type %u exceeds maximum of %u",
++ event_type, GOYA_ASYNC_EVENT_ID_SIZE - 1);
++ return;
++ }
++
+ goya->events_stat[event_type]++;
+ goya->events_stat_aggregate[event_type]++;
+
+--
+2.33.0
+
--- /dev/null
+From fa54a5364eb98b8a2d7364555cd728da21230b36 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Aug 2021 15:29:55 -0500
+Subject: iommu/amd: Relocate GAMSup check to early_enable_iommus
+
+From: Wei Huang <wei.huang2@amd.com>
+
+[ Upstream commit c3811a50addd23b9bb5a36278609ee1638debcf6 ]
+
+Currently, iommu_init_ga() checks and disables IOMMU VAPIC support
+(i.e. AMD AVIC support in IOMMU) when GAMSup feature bit is not set.
+However it forgets to clear IRQ_POSTING_CAP from the previously set
+amd_iommu_irq_ops.capability.
+
+This triggers an invalid page fault bug during guest VM warm reboot
+if AVIC is enabled since the irq_remapping_cap(IRQ_POSTING_CAP) is
+incorrectly set, and crash the system with the following kernel trace.
+
+ BUG: unable to handle page fault for address: 0000000000400dd8
+ RIP: 0010:amd_iommu_deactivate_guest_mode+0x19/0xbc
+ Call Trace:
+ svm_set_pi_irte_mode+0x8a/0xc0 [kvm_amd]
+ ? kvm_make_all_cpus_request_except+0x50/0x70 [kvm]
+ kvm_request_apicv_update+0x10c/0x150 [kvm]
+ svm_toggle_avic_for_irq_window+0x52/0x90 [kvm_amd]
+ svm_enable_irq_window+0x26/0xa0 [kvm_amd]
+ vcpu_enter_guest+0xbbe/0x1560 [kvm]
+ ? avic_vcpu_load+0xd5/0x120 [kvm_amd]
+ ? kvm_arch_vcpu_load+0x76/0x240 [kvm]
+ ? svm_get_segment_base+0xa/0x10 [kvm_amd]
+ kvm_arch_vcpu_ioctl_run+0x103/0x590 [kvm]
+ kvm_vcpu_ioctl+0x22a/0x5d0 [kvm]
+ __x64_sys_ioctl+0x84/0xc0
+ do_syscall_64+0x33/0x40
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+Fixes by moving the initializing of AMD IOMMU interrupt remapping mode
+(amd_iommu_guest_ir) earlier before setting up the
+amd_iommu_irq_ops.capability with appropriate IRQ_POSTING_CAP flag.
+
+[joro: Squashed the two patches and limited
+ check_features_on_all_iommus() to CONFIG_IRQ_REMAP
+ to fix a compile warning.]
+
+Signed-off-by: Wei Huang <wei.huang2@amd.com>
+Co-developed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
+Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
+Link: https://lore.kernel.org/r/20210820202957.187572-2-suravee.suthikulpanit@amd.com
+Link: https://lore.kernel.org/r/20210820202957.187572-3-suravee.suthikulpanit@amd.com
+Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log")
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iommu/amd/init.c | 31 ++++++++++++++++++++++++-------
+ 1 file changed, 24 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
+index fa57986c2309..28de889aa516 100644
+--- a/drivers/iommu/amd/init.c
++++ b/drivers/iommu/amd/init.c
+@@ -298,6 +298,22 @@ int amd_iommu_get_num_iommus(void)
+ return amd_iommus_present;
+ }
+
++#ifdef CONFIG_IRQ_REMAP
++static bool check_feature_on_all_iommus(u64 mask)
++{
++ bool ret = false;
++ struct amd_iommu *iommu;
++
++ for_each_iommu(iommu) {
++ ret = iommu_feature(iommu, mask);
++ if (!ret)
++ return false;
++ }
++
++ return true;
++}
++#endif
++
+ /*
+ * For IVHD type 0x11/0x40, EFR is also available via IVHD.
+ * Default to IVHD EFR since it is available sooner
+@@ -854,13 +870,6 @@ static int iommu_init_ga(struct amd_iommu *iommu)
+ int ret = 0;
+
+ #ifdef CONFIG_IRQ_REMAP
+- /* Note: We have already checked GASup from IVRS table.
+- * Now, we need to make sure that GAMSup is set.
+- */
+- if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) &&
+- !iommu_feature(iommu, FEATURE_GAM_VAPIC))
+- amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA;
+-
+ ret = iommu_init_ga_log(iommu);
+ #endif /* CONFIG_IRQ_REMAP */
+
+@@ -2396,6 +2405,14 @@ static void early_enable_iommus(void)
+ }
+
+ #ifdef CONFIG_IRQ_REMAP
++ /*
++ * Note: We have already checked GASup from IVRS table.
++ * Now, we need to make sure that GAMSup is set.
++ */
++ if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) &&
++ !check_feature_on_all_iommus(FEATURE_GAM_VAPIC))
++ amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA;
++
+ if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
+ amd_iommu_irq_ops.capability |= (1 << IRQ_POSTING_CAP);
+ #endif
+--
+2.33.0
+
--- /dev/null
+From 9d7f4ca11b077f9e7fbc5ca4a0d4bbe1e4a6e19a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:47 -0700
+Subject: Kconfig.debug: drop selecting non-existing HARDLOCKUP_DETECTOR_ARCH
+
+From: Lukas Bulwahn <lukas.bulwahn@gmail.com>
+
+[ Upstream commit 6fe26259b4884b657cbc233fb9cdade9d704976e ]
+
+Commit 05a4a9527931 ("kernel/watchdog: split up config options") adds a
+new config HARDLOCKUP_DETECTOR, which selects the non-existing config
+HARDLOCKUP_DETECTOR_ARCH.
+
+Hence, ./scripts/checkkconfigsymbols.py warns:
+
+HARDLOCKUP_DETECTOR_ARCH Referencing files: lib/Kconfig.debug
+
+Simply drop selecting the non-existing HARDLOCKUP_DETECTOR_ARCH.
+
+Link: https://lkml.kernel.org/r/20210806115618.22088-1-lukas.bulwahn@gmail.com
+Fixes: 05a4a9527931 ("kernel/watchdog: split up config options")
+Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
+Cc: Nicholas Piggin <npiggin@gmail.com>
+Cc: Masahiro Yamada <masahiroy@kernel.org>
+Cc: Babu Moger <babu.moger@oracle.com>
+Cc: Don Zickus <dzickus@redhat.com>
+Cc: Randy Dunlap <rdunlap@infradead.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ lib/Kconfig.debug | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
+index bf174798afcb..95f909540587 100644
+--- a/lib/Kconfig.debug
++++ b/lib/Kconfig.debug
+@@ -981,7 +981,6 @@ config HARDLOCKUP_DETECTOR
+ depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_ARCH
+ select LOCKUP_DETECTOR
+ select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF
+- select HARDLOCKUP_DETECTOR_ARCH if HAVE_HARDLOCKUP_DETECTOR_ARCH
+ help
+ Say Y here to enable the kernel to act as a watchdog to detect
+ hard lockups.
+--
+2.33.0
+
--- /dev/null
+From 8b02fa2fed11108b9d57bea63096f4ab108158f4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:15 -0700
+Subject: nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group
+
+From: Nanyong Sun <sunnanyong@huawei.com>
+
+[ Upstream commit 24f8cb1ed057c840728167dab33b32e44147c86f ]
+
+If kobject_init_and_add return with error, kobject_put() is needed here to
+avoid memory leak, because kobject_init_and_add may return error without
+freeing the memory associated with the kobject it allocated.
+
+Link: https://lkml.kernel.org/r/20210629022556.3985106-4-sunnanyong@huawei.com
+Link: https://lkml.kernel.org/r/1625651306-10829-4-git-send-email-konishi.ryusuke@gmail.com
+Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
+Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nilfs2/sysfs.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
+index 43f660beb9b4..5dc468ff5903 100644
+--- a/fs/nilfs2/sysfs.c
++++ b/fs/nilfs2/sysfs.c
+@@ -92,8 +92,8 @@ static int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \
+ err = kobject_init_and_add(kobj, &nilfs_##name##_ktype, parent, \
+ #name); \
+ if (err) \
+- return err; \
+- return 0; \
++ kobject_put(kobj); \
++ return err; \
+ } \
+ static void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \
+ { \
+--
+2.33.0
+
--- /dev/null
+From 5929ccedca8c5009d5028f7402380f21b46bdffa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:09 -0700
+Subject: nilfs2: fix memory leak in nilfs_sysfs_create_device_group
+
+From: Nanyong Sun <sunnanyong@huawei.com>
+
+[ Upstream commit 5f5dec07aca7067216ed4c1342e464e7307a9197 ]
+
+Patch series "nilfs2: fix incorrect usage of kobject".
+
+This patchset from Nanyong Sun fixes memory leak issues and a NULL
+pointer dereference issue caused by incorrect usage of kboject in nilfs2
+sysfs implementation.
+
+This patch (of 6):
+
+Reported by syzkaller:
+
+ BUG: memory leak
+ unreferenced object 0xffff888100ca8988 (size 8):
+ comm "syz-executor.1", pid 1930, jiffies 4294745569 (age 18.052s)
+ hex dump (first 8 bytes):
+ 6c 6f 6f 70 31 00 ff ff loop1...
+ backtrace:
+ kstrdup+0x36/0x70 mm/util.c:60
+ kstrdup_const+0x35/0x60 mm/util.c:83
+ kvasprintf_const+0xf1/0x180 lib/kasprintf.c:48
+ kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289
+ kobject_add_varg lib/kobject.c:384 [inline]
+ kobject_init_and_add+0xc9/0x150 lib/kobject.c:473
+ nilfs_sysfs_create_device_group+0x150/0x7d0 fs/nilfs2/sysfs.c:986
+ init_nilfs+0xa21/0xea0 fs/nilfs2/the_nilfs.c:637
+ nilfs_fill_super fs/nilfs2/super.c:1046 [inline]
+ nilfs_mount+0x7b4/0xe80 fs/nilfs2/super.c:1316
+ legacy_get_tree+0x105/0x210 fs/fs_context.c:592
+ vfs_get_tree+0x8e/0x2d0 fs/super.c:1498
+ do_new_mount fs/namespace.c:2905 [inline]
+ path_mount+0xf9b/0x1990 fs/namespace.c:3235
+ do_mount+0xea/0x100 fs/namespace.c:3248
+ __do_sys_mount fs/namespace.c:3456 [inline]
+ __se_sys_mount fs/namespace.c:3433 [inline]
+ __x64_sys_mount+0x14b/0x1f0 fs/namespace.c:3433
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+If kobject_init_and_add return with error, then the cleanup of kobject
+is needed because memory may be allocated in kobject_init_and_add
+without freeing.
+
+And the place of cleanup_dev_kobject should use kobject_put to free the
+memory associated with the kobject. As the section "Kobject removal" of
+"Documentation/core-api/kobject.rst" says, kobject_del() just makes the
+kobject "invisible", but it is not cleaned up. And no more cleanup will
+do after cleanup_dev_kobject, so kobject_put is needed here.
+
+Link: https://lkml.kernel.org/r/1625651306-10829-1-git-send-email-konishi.ryusuke@gmail.com
+Link: https://lkml.kernel.org/r/1625651306-10829-2-git-send-email-konishi.ryusuke@gmail.com
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Link: https://lkml.kernel.org/r/20210629022556.3985106-2-sunnanyong@huawei.com
+Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
+Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nilfs2/sysfs.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
+index 9c6c0e2e5880..b6a48492fed2 100644
+--- a/fs/nilfs2/sysfs.c
++++ b/fs/nilfs2/sysfs.c
+@@ -999,7 +999,7 @@ int nilfs_sysfs_create_device_group(struct super_block *sb)
+ err = kobject_init_and_add(&nilfs->ns_dev_kobj, &nilfs_dev_ktype, NULL,
+ "%s", sb->s_id);
+ if (err)
+- goto free_dev_subgroups;
++ goto cleanup_dev_kobject;
+
+ err = nilfs_sysfs_create_mounted_snapshots_group(nilfs);
+ if (err)
+@@ -1036,9 +1036,7 @@ delete_mounted_snapshots_group:
+ nilfs_sysfs_delete_mounted_snapshots_group(nilfs);
+
+ cleanup_dev_kobject:
+- kobject_del(&nilfs->ns_dev_kobj);
+-
+-free_dev_subgroups:
++ kobject_put(&nilfs->ns_dev_kobj);
+ kfree(nilfs->ns_dev_subgroups);
+
+ failed_create_device_group:
+--
+2.33.0
+
--- /dev/null
+From 26dfc48e7e3e9d3ca7a5dbb7b93746d891bb1751 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:21 -0700
+Subject: nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group
+
+From: Nanyong Sun <sunnanyong@huawei.com>
+
+[ Upstream commit b2fe39c248f3fa4bbb2a20759b4fdd83504190f7 ]
+
+If kobject_init_and_add returns with error, kobject_put() is needed here
+to avoid memory leak, because kobject_init_and_add may return error
+without freeing the memory associated with the kobject it allocated.
+
+Link: https://lkml.kernel.org/r/20210629022556.3985106-6-sunnanyong@huawei.com
+Link: https://lkml.kernel.org/r/1625651306-10829-6-git-send-email-konishi.ryusuke@gmail.com
+Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
+Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nilfs2/sysfs.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
+index 34893a57a7b9..44b9ad70a564 100644
+--- a/fs/nilfs2/sysfs.c
++++ b/fs/nilfs2/sysfs.c
+@@ -208,9 +208,9 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)
+ }
+
+ if (err)
+- return err;
++ kobject_put(&root->snapshot_kobj);
+
+- return 0;
++ return err;
+ }
+
+ void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *root)
+--
+2.33.0
+
--- /dev/null
+From f6303b9d9945f40823fb903bcb11eef68787216b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:18 -0700
+Subject: nilfs2: fix memory leak in nilfs_sysfs_delete_##name##_group
+
+From: Nanyong Sun <sunnanyong@huawei.com>
+
+[ Upstream commit a3e181259ddd61fd378390977a1e4e2316853afa ]
+
+The kobject_put() should be used to cleanup the memory associated with the
+kobject instead of kobject_del. See the section "Kobject removal" of
+"Documentation/core-api/kobject.rst".
+
+Link: https://lkml.kernel.org/r/20210629022556.3985106-5-sunnanyong@huawei.com
+Link: https://lkml.kernel.org/r/1625651306-10829-5-git-send-email-konishi.ryusuke@gmail.com
+Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
+Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nilfs2/sysfs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
+index 5dc468ff5903..34893a57a7b9 100644
+--- a/fs/nilfs2/sysfs.c
++++ b/fs/nilfs2/sysfs.c
+@@ -97,7 +97,7 @@ static int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \
+ } \
+ static void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \
+ { \
+- kobject_del(&nilfs->ns_##parent_name##_subgroups->sg_##name##_kobj); \
++ kobject_put(&nilfs->ns_##parent_name##_subgroups->sg_##name##_kobj); \
+ }
+
+ /************************************************************************
+--
+2.33.0
+
--- /dev/null
+From c88bbe84cd0bbe14fcca5679a5771f26dd592394 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:23 -0700
+Subject: nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group
+
+From: Nanyong Sun <sunnanyong@huawei.com>
+
+[ Upstream commit 17243e1c3072b8417a5ebfc53065d0a87af7ca77 ]
+
+kobject_put() should be used to cleanup the memory associated with the
+kobject instead of kobject_del(). See the section "Kobject removal" of
+"Documentation/core-api/kobject.rst".
+
+Link: https://lkml.kernel.org/r/20210629022556.3985106-7-sunnanyong@huawei.com
+Link: https://lkml.kernel.org/r/1625651306-10829-7-git-send-email-konishi.ryusuke@gmail.com
+Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
+Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nilfs2/sysfs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
+index 44b9ad70a564..57afd06db62d 100644
+--- a/fs/nilfs2/sysfs.c
++++ b/fs/nilfs2/sysfs.c
+@@ -215,7 +215,7 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)
+
+ void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *root)
+ {
+- kobject_del(&root->snapshot_kobj);
++ kobject_put(&root->snapshot_kobj);
+ }
+
+ /************************************************************************
+--
+2.33.0
+
--- /dev/null
+From 2e1cd768ff086aa28ed78bd1222838148672693c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Sep 2021 20:00:12 -0700
+Subject: nilfs2: fix NULL pointer in nilfs_##name##_attr_release
+
+From: Nanyong Sun <sunnanyong@huawei.com>
+
+[ Upstream commit dbc6e7d44a514f231a64d9d5676e001b660b6448 ]
+
+In nilfs_##name##_attr_release, kobj->parent should not be referenced
+because it is a NULL pointer. The release() method of kobject is always
+called in kobject_put(kobj), in the implementation of kobject_put(), the
+kobj->parent will be assigned as NULL before call the release() method.
+So just use kobj to get the subgroups, which is more efficient and can fix
+a NULL pointer reference problem.
+
+Link: https://lkml.kernel.org/r/20210629022556.3985106-3-sunnanyong@huawei.com
+Link: https://lkml.kernel.org/r/1625651306-10829-3-git-send-email-konishi.ryusuke@gmail.com
+Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
+Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nilfs2/sysfs.c | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
+index b6a48492fed2..43f660beb9b4 100644
+--- a/fs/nilfs2/sysfs.c
++++ b/fs/nilfs2/sysfs.c
+@@ -64,11 +64,9 @@ static const struct sysfs_ops nilfs_##name##_attr_ops = { \
+ #define NILFS_DEV_INT_GROUP_TYPE(name, parent_name) \
+ static void nilfs_##name##_attr_release(struct kobject *kobj) \
+ { \
+- struct nilfs_sysfs_##parent_name##_subgroups *subgroups; \
+- struct the_nilfs *nilfs = container_of(kobj->parent, \
+- struct the_nilfs, \
+- ns_##parent_name##_kobj); \
+- subgroups = nilfs->ns_##parent_name##_subgroups; \
++ struct nilfs_sysfs_##parent_name##_subgroups *subgroups = container_of(kobj, \
++ struct nilfs_sysfs_##parent_name##_subgroups, \
++ sg_##name##_kobj); \
+ complete(&subgroups->sg_##name##_kobj_unregister); \
+ } \
+ static struct kobj_type nilfs_##name##_ktype = { \
+--
+2.33.0
+
--- /dev/null
+From 2995b54e8dddb8579245895d3a4a8d2fb73b92f7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Sep 2021 08:30:41 -0700
+Subject: parisc: Move pci_dev_is_behind_card_dino to where it is used
+
+From: Guenter Roeck <linux@roeck-us.net>
+
+[ Upstream commit 907872baa9f1538eed02ec737b8e89eba6c6e4b9 ]
+
+parisc build test images fail to compile with the following error.
+
+drivers/parisc/dino.c:160:12: error:
+ 'pci_dev_is_behind_card_dino' defined but not used
+
+Move the function just ahead of its only caller to avoid the error.
+
+Fixes: 5fa1659105fa ("parisc: Disable HP HSC-PCI Cards to prevent kernel crash")
+Cc: Helge Deller <deller@gmx.de>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/parisc/dino.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
+index 889d7ce282eb..952a92504df6 100644
+--- a/drivers/parisc/dino.c
++++ b/drivers/parisc/dino.c
+@@ -156,15 +156,6 @@ static inline struct dino_device *DINO_DEV(struct pci_hba_data *hba)
+ return container_of(hba, struct dino_device, hba);
+ }
+
+-/* Check if PCI device is behind a Card-mode Dino. */
+-static int pci_dev_is_behind_card_dino(struct pci_dev *dev)
+-{
+- struct dino_device *dino_dev;
+-
+- dino_dev = DINO_DEV(parisc_walk_tree(dev->bus->bridge));
+- return is_card_dino(&dino_dev->hba.dev->id);
+-}
+-
+ /*
+ * Dino Configuration Space Accessor Functions
+ */
+@@ -447,6 +438,15 @@ static void quirk_cirrus_cardbus(struct pci_dev *dev)
+ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_6832, quirk_cirrus_cardbus );
+
+ #ifdef CONFIG_TULIP
++/* Check if PCI device is behind a Card-mode Dino. */
++static int pci_dev_is_behind_card_dino(struct pci_dev *dev)
++{
++ struct dino_device *dino_dev;
++
++ dino_dev = DINO_DEV(parisc_walk_tree(dev->bus->bridge));
++ return is_card_dino(&dino_dev->hba.dev->id);
++}
++
+ static void pci_fixup_tulip(struct pci_dev *dev)
+ {
+ if (!pci_dev_is_behind_card_dino(dev))
+--
+2.33.0
+
--- /dev/null
+From 36f0c409c803adbdbb6796740611cf7c39da2c04 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Aug 2021 11:00:50 -0700
+Subject: platform/chrome: cros_ec_trace: Fix format warnings
+
+From: Gwendal Grignou <gwendal@chromium.org>
+
+[ Upstream commit 4665584888ad2175831c972c004115741ec799e9 ]
+
+Fix printf format issues in new tracing events.
+
+Fixes: 814318242687 ("platform/chrome: cros_ec_trace: Add fields to command traces")
+
+Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
+Link: https://lore.kernel.org/r/20210830180050.2077261-1-gwendal@chromium.org
+Signed-off-by: Benson Leung <bleung@chromium.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/chrome/cros_ec_trace.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/platform/chrome/cros_ec_trace.h b/drivers/platform/chrome/cros_ec_trace.h
+index f50b9f9b8610..7e7cfc98657a 100644
+--- a/drivers/platform/chrome/cros_ec_trace.h
++++ b/drivers/platform/chrome/cros_ec_trace.h
+@@ -92,7 +92,7 @@ TRACE_EVENT(cros_ec_sensorhub_timestamp,
+ __entry->current_time = current_time;
+ __entry->delta = current_timestamp - current_time;
+ ),
+- TP_printk("ec_ts: %12lld, ec_fifo_ts: %12lld, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
++ TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
+ __entry->ec_sample_timestamp,
+ __entry->ec_fifo_timestamp,
+ __entry->fifo_timestamp,
+@@ -122,7 +122,7 @@ TRACE_EVENT(cros_ec_sensorhub_data,
+ __entry->current_time = current_time;
+ __entry->delta = current_timestamp - current_time;
+ ),
+- TP_printk("ec_num: %4d, ec_fifo_ts: %12lld, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
++ TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
+ __entry->ec_sensor_num,
+ __entry->ec_fifo_timestamp,
+ __entry->fifo_timestamp,
+@@ -153,7 +153,7 @@ TRACE_EVENT(cros_ec_sensorhub_filter,
+ __entry->x = state->x_offset;
+ __entry->y = state->y_offset;
+ ),
+- TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %d x: %12lld y: %12lld",
++ TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
+ __entry->dx,
+ __entry->dy,
+ __entry->median_m,
+--
+2.33.0
+
--- /dev/null
+From 4dda4cc8ff4c2cb99fa1563ef2cd3da7abe2929f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 May 2021 17:57:33 -0700
+Subject: platform/chrome: sensorhub: Add trace events for sample
+
+From: Gwendal Grignou <gwendal@chromium.org>
+
+[ Upstream commit d453ceb6549af8798913de6a20444cb7200fdb69 ]
+
+Add trace event to report samples and their timestamp coming from the
+EC. It allows to check if the timestamps are correct and the filter is
+working correctly without introducing too much latency.
+
+To enable these events:
+
+cd /sys/kernel/debug/tracing/
+echo 1 > events/cros_ec/enable
+echo 0 > events/cros_ec/cros_ec_request_start/enable
+echo 0 > events/cros_ec/cros_ec_request_done/enable
+echo 1 > tracing_on
+cat trace_pipe
+Observe event flowing:
+irq/105-chromeo-95 [000] .... 613.659758: cros_ec_sensorhub_timestamp: ...
+irq/105-chromeo-95 [000] .... 613.665219: cros_ec_sensorhub_filter: dx: ...
+
+Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
+Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/chrome/Makefile | 2 +-
+ .../platform/chrome/cros_ec_sensorhub_ring.c | 14 +++
+ drivers/platform/chrome/cros_ec_trace.h | 94 +++++++++++++++++++
+ 3 files changed, 109 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile
+index 41baccba033f..f901d2e43166 100644
+--- a/drivers/platform/chrome/Makefile
++++ b/drivers/platform/chrome/Makefile
+@@ -20,7 +20,7 @@ obj-$(CONFIG_CROS_EC_CHARDEV) += cros_ec_chardev.o
+ obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o
+ obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
+ obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o
+-cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o
++cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o
+ obj-$(CONFIG_CROS_EC_SENSORHUB) += cros-ec-sensorhub.o
+ obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o
+ obj-$(CONFIG_CROS_USBPD_LOGGER) += cros_usbpd_logger.o
+diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+index 8921f24e83ba..98e37080f760 100644
+--- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
++++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+@@ -17,6 +17,8 @@
+ #include <linux/sort.h>
+ #include <linux/slab.h>
+
++#include "cros_ec_trace.h"
++
+ /* Precision of fixed point for the m values from the filter */
+ #define M_PRECISION BIT(23)
+
+@@ -291,6 +293,7 @@ cros_ec_sensor_ring_ts_filter_update(struct cros_ec_sensors_ts_filter_state
+ state->median_m = 0;
+ state->median_error = 0;
+ }
++ trace_cros_ec_sensorhub_filter(state, dx, dy);
+ }
+
+ /**
+@@ -427,6 +430,11 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
+ if (new_timestamp - *current_timestamp > 0)
+ *current_timestamp = new_timestamp;
+ }
++ trace_cros_ec_sensorhub_timestamp(in->timestamp,
++ fifo_info->timestamp,
++ fifo_timestamp,
++ *current_timestamp,
++ now);
+ }
+
+ if (in->flags & MOTIONSENSE_SENSOR_FLAG_ODR) {
+@@ -460,6 +468,12 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
+
+ /* Regular sample */
+ out->sensor_id = in->sensor_num;
++ trace_cros_ec_sensorhub_data(in->sensor_num,
++ fifo_info->timestamp,
++ fifo_timestamp,
++ *current_timestamp,
++ now);
++
+ if (*current_timestamp - now > 0) {
+ /*
+ * This fix is needed to overcome the timestamp filter putting
+diff --git a/drivers/platform/chrome/cros_ec_trace.h b/drivers/platform/chrome/cros_ec_trace.h
+index f744b21bc655..f50b9f9b8610 100644
+--- a/drivers/platform/chrome/cros_ec_trace.h
++++ b/drivers/platform/chrome/cros_ec_trace.h
+@@ -15,6 +15,7 @@
+ #include <linux/types.h>
+ #include <linux/platform_data/cros_ec_commands.h>
+ #include <linux/platform_data/cros_ec_proto.h>
++#include <linux/platform_data/cros_ec_sensorhub.h>
+
+ #include <linux/tracepoint.h>
+
+@@ -70,6 +71,99 @@ TRACE_EVENT(cros_ec_request_done,
+ __entry->retval)
+ );
+
++TRACE_EVENT(cros_ec_sensorhub_timestamp,
++ TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
++ s64 current_timestamp, s64 current_time),
++ TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
++ current_time),
++ TP_STRUCT__entry(
++ __field(u32, ec_sample_timestamp)
++ __field(u32, ec_fifo_timestamp)
++ __field(s64, fifo_timestamp)
++ __field(s64, current_timestamp)
++ __field(s64, current_time)
++ __field(s64, delta)
++ ),
++ TP_fast_assign(
++ __entry->ec_sample_timestamp = ec_sample_timestamp;
++ __entry->ec_fifo_timestamp = ec_fifo_timestamp;
++ __entry->fifo_timestamp = fifo_timestamp;
++ __entry->current_timestamp = current_timestamp;
++ __entry->current_time = current_time;
++ __entry->delta = current_timestamp - current_time;
++ ),
++ TP_printk("ec_ts: %12lld, ec_fifo_ts: %12lld, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
++ __entry->ec_sample_timestamp,
++ __entry->ec_fifo_timestamp,
++ __entry->fifo_timestamp,
++ __entry->current_timestamp,
++ __entry->current_time,
++ __entry->delta
++ )
++);
++
++TRACE_EVENT(cros_ec_sensorhub_data,
++ TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
++ s64 current_timestamp, s64 current_time),
++ TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
++ TP_STRUCT__entry(
++ __field(u32, ec_sensor_num)
++ __field(u32, ec_fifo_timestamp)
++ __field(s64, fifo_timestamp)
++ __field(s64, current_timestamp)
++ __field(s64, current_time)
++ __field(s64, delta)
++ ),
++ TP_fast_assign(
++ __entry->ec_sensor_num = ec_sensor_num;
++ __entry->ec_fifo_timestamp = ec_fifo_timestamp;
++ __entry->fifo_timestamp = fifo_timestamp;
++ __entry->current_timestamp = current_timestamp;
++ __entry->current_time = current_time;
++ __entry->delta = current_timestamp - current_time;
++ ),
++ TP_printk("ec_num: %4d, ec_fifo_ts: %12lld, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
++ __entry->ec_sensor_num,
++ __entry->ec_fifo_timestamp,
++ __entry->fifo_timestamp,
++ __entry->current_timestamp,
++ __entry->current_time,
++ __entry->delta
++ )
++);
++
++TRACE_EVENT(cros_ec_sensorhub_filter,
++ TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
++ TP_ARGS(state, dx, dy),
++ TP_STRUCT__entry(
++ __field(s64, dx)
++ __field(s64, dy)
++ __field(s64, median_m)
++ __field(s64, median_error)
++ __field(s64, history_len)
++ __field(s64, x)
++ __field(s64, y)
++ ),
++ TP_fast_assign(
++ __entry->dx = dx;
++ __entry->dy = dy;
++ __entry->median_m = state->median_m;
++ __entry->median_error = state->median_error;
++ __entry->history_len = state->history_len;
++ __entry->x = state->x_offset;
++ __entry->y = state->y_offset;
++ ),
++ TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %d x: %12lld y: %12lld",
++ __entry->dx,
++ __entry->dy,
++ __entry->median_m,
++ __entry->median_error,
++ __entry->history_len,
++ __entry->x,
++ __entry->y
++ )
++);
++
+
+ #endif /* _CROS_EC_TRACE_H_ */
+
+--
+2.33.0
+
--- /dev/null
+From 1c3c98b70abb8ba942e02c2f87a5c5737e24d064 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 7 Jul 2021 18:27:51 +0200
+Subject: pwm: img: Don't modify HW state in .remove() callback
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+
+[ Upstream commit c68eb29c8e9067c08175dd0414f6984f236f719d ]
+
+A consumer is expected to disable a PWM before calling pwm_put(). And if
+they didn't there is hopefully a good reason (or the consumer needs
+fixing). Also if disabling an enabled PWM was the right thing to do,
+this should better be done in the framework instead of in each low level
+driver.
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-img.c | 16 ----------------
+ 1 file changed, 16 deletions(-)
+
+diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
+index 22c002e685b3..37f9b688661d 100644
+--- a/drivers/pwm/pwm-img.c
++++ b/drivers/pwm/pwm-img.c
+@@ -329,23 +329,7 @@ err_pm_disable:
+ static int img_pwm_remove(struct platform_device *pdev)
+ {
+ struct img_pwm_chip *pwm_chip = platform_get_drvdata(pdev);
+- u32 val;
+- unsigned int i;
+- int ret;
+-
+- ret = pm_runtime_get_sync(&pdev->dev);
+- if (ret < 0) {
+- pm_runtime_put(&pdev->dev);
+- return ret;
+- }
+-
+- for (i = 0; i < pwm_chip->chip.npwm; i++) {
+- val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);
+- val &= ~BIT(i);
+- img_pwm_writel(pwm_chip, PWM_CTRL_CFG, val);
+- }
+
+- pm_runtime_put(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+ if (!pm_runtime_status_suspended(&pdev->dev))
+ img_pwm_runtime_suspend(&pdev->dev);
+--
+2.33.0
+
--- /dev/null
+From 91f5779036481875f3d299b4c2658e2fc5203dc6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 7 Jul 2021 18:27:52 +0200
+Subject: pwm: rockchip: Don't modify HW state in .remove() callback
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+
+[ Upstream commit 9d768cd7fd42bb0be16f36aec48548fca5260759 ]
+
+A consumer is expected to disable a PWM before calling pwm_put(). And if
+they didn't there is hopefully a good reason (or the consumer needs
+fixing). Also if disabling an enabled PWM was the right thing to do,
+this should better be done in the framework instead of in each low level
+driver.
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-rockchip.c | 14 --------------
+ 1 file changed, 14 deletions(-)
+
+diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
+index 3b8da7b0091b..1f3079562b38 100644
+--- a/drivers/pwm/pwm-rockchip.c
++++ b/drivers/pwm/pwm-rockchip.c
+@@ -382,20 +382,6 @@ static int rockchip_pwm_remove(struct platform_device *pdev)
+ {
+ struct rockchip_pwm_chip *pc = platform_get_drvdata(pdev);
+
+- /*
+- * Disable the PWM clk before unpreparing it if the PWM device is still
+- * running. This should only happen when the last PWM user left it
+- * enabled, or when nobody requested a PWM that was previously enabled
+- * by the bootloader.
+- *
+- * FIXME: Maybe the core should disable all PWM devices in
+- * pwmchip_remove(). In this case we'd only have to call
+- * clk_unprepare() after pwmchip_remove().
+- *
+- */
+- if (pwm_is_enabled(pc->chip.pwms))
+- clk_disable(pc->clk);
+-
+ clk_unprepare(pc->pclk);
+ clk_unprepare(pc->clk);
+
+--
+2.33.0
+
--- /dev/null
+From 12a4567ab7837af23679be3e65227c565e2c2e79 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 7 Jul 2021 18:27:53 +0200
+Subject: pwm: stm32-lp: Don't modify HW state in .remove() callback
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+
+[ Upstream commit d44084c93427bb0a9261432db1a8ca76a42d805e ]
+
+A consumer is expected to disable a PWM before calling pwm_put(). And if
+they didn't there is hopefully a good reason (or the consumer needs
+fixing). Also if disabling an enabled PWM was the right thing to do,
+this should better be done in the framework instead of in each low level
+driver.
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-stm32-lp.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
+index 134c14621ee0..945a8b2b8564 100644
+--- a/drivers/pwm/pwm-stm32-lp.c
++++ b/drivers/pwm/pwm-stm32-lp.c
+@@ -225,8 +225,6 @@ static int stm32_pwm_lp_remove(struct platform_device *pdev)
+ {
+ struct stm32_pwm_lp *priv = platform_get_drvdata(pdev);
+
+- pwm_disable(&priv->chip.pwms[0]);
+-
+ return pwmchip_remove(&priv->chip);
+ }
+
+--
+2.33.0
+
--- /dev/null
+From b54790a7782d810e0ae03bf37381356ea905db6c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Aug 2021 13:25:32 +0800
+Subject: rtc: rx8010: select REGMAP_I2C
+
+From: Yu-Tung Chang <mtwget@gmail.com>
+
+[ Upstream commit 0c45d3e24ef3d3d87c5e0077b8f38d1372af7176 ]
+
+The rtc-rx8010 uses the I2C regmap but doesn't select it in Kconfig so
+depending on the configuration the build may fail. Fix it.
+
+Signed-off-by: Yu-Tung Chang <mtwget@gmail.com>
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+Link: https://lore.kernel.org/r/20210830052532.40356-1-mtwget@gmail.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/rtc/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
+index 33e4ecd6c665..54cf5ec8f401 100644
+--- a/drivers/rtc/Kconfig
++++ b/drivers/rtc/Kconfig
+@@ -624,6 +624,7 @@ config RTC_DRV_FM3130
+
+ config RTC_DRV_RX8010
+ tristate "Epson RX8010SJ"
++ select REGMAP_I2C
+ help
+ If you say yes here you get support for the Epson RX8010SJ RTC
+ chip.
+--
+2.33.0
+
--- /dev/null
+From 3e19ed3f459fff638ee21be56287df5d567a3a93 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 Sep 2021 13:30:34 +0200
+Subject: sched/idle: Make the idle timer expire in hard interrupt context
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+[ Upstream commit 9848417926353daa59d2b05eb26e185063dbac6e ]
+
+The intel powerclamp driver will setup a per-CPU worker with RT
+priority. The worker will then invoke play_idle() in which it remains in
+the idle poll loop until it is stopped by the timer it started earlier.
+
+That timer needs to expire in hard interrupt context on PREEMPT_RT.
+Otherwise the timer will expire in ksoftirqd as a SOFT timer but that task
+won't be scheduled on the CPU because its priority is lower than the
+priority of the worker which is in the idle loop.
+
+Always expire the idle timer in hard interrupt context.
+
+Reported-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Link: https://lore.kernel.org/r/20210906113034.jgfxrjdvxnjqgtmc@linutronix.de
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/sched/idle.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
+index 36b545f17206..2593a733c084 100644
+--- a/kernel/sched/idle.c
++++ b/kernel/sched/idle.c
+@@ -372,10 +372,10 @@ void play_idle_precise(u64 duration_ns, u64 latency_ns)
+ cpuidle_use_deepest_state(latency_ns);
+
+ it.done = 0;
+- hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
++ hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
+ it.timer.function = idle_inject_timer_fn;
+ hrtimer_start(&it.timer, ns_to_ktime(duration_ns),
+- HRTIMER_MODE_REL_PINNED);
++ HRTIMER_MODE_REL_PINNED_HARD);
+
+ while (!READ_ONCE(it.done))
+ do_idle();
+--
+2.33.0
+
pm-sleep-core-avoid-setting-power.must_resume-to-false.patch
pwm-lpc32xx-don-t-modify-hw-state-in-.probe-after-the-pwm-chip-was-registered.patch
pwm-mxs-don-t-modify-hw-state-in-.probe-after-the-pwm-chip-was-registered.patch
+dmaengine-idxd-fix-wq-slot-allocation-index-check.patch
+platform-chrome-sensorhub-add-trace-events-for-sampl.patch
+platform-chrome-cros_ec_trace-fix-format-warnings.patch
+ceph-allow-ceph_put_mds_session-to-take-null-or-err_.patch
+ceph-cancel-delayed-work-instead-of-flushing-on-mdsc.patch
+kconfig.debug-drop-selecting-non-existing-hardlockup.patch
+tools-bootconfig-fix-tracing_on-option-checking-in-f.patch
+thermal-core-fix-thermal_cooling_device_register-pro.patch
+drm-amdgpu-disable-pcie_dpm-on-intel-rkl-platform.patch
+drivers-base-cacheinfo-get-rid-of-define_smp_call_ca.patch
+dma-buf-dmabuf_move_notify-should-depend-on-dma_shar.patch
+parisc-move-pci_dev_is_behind_card_dino-to-where-it-.patch
+iommu-amd-relocate-gamsup-check-to-early_enable_iomm.patch
+dmaengine-idxd-depends-on-uml.patch
+dmaengine-sprd-add-missing-module_device_table.patch
+dmaengine-ioat-depends-on-uml.patch
+dmaengine-xilinx_dma-set-dma-mask-for-coherent-apis.patch
+ceph-request-fw-caps-before-updating-the-mtime-in-ce.patch
+ceph-remove-the-capsnaps-when-removing-caps.patch
+ceph-lockdep-annotations-for-try_nonblocking_invalid.patch
+btrfs-update-the-bdev-time-directly-when-closing.patch
+btrfs-fix-lockdep-warning-while-mounting-sprout-fs.patch
+nilfs2-fix-memory-leak-in-nilfs_sysfs_create_device_.patch
+nilfs2-fix-null-pointer-in-nilfs_-name-_attr_release.patch
+nilfs2-fix-memory-leak-in-nilfs_sysfs_create_-name-_.patch
+nilfs2-fix-memory-leak-in-nilfs_sysfs_delete_-name-_.patch
+nilfs2-fix-memory-leak-in-nilfs_sysfs_create_snapsho.patch
+nilfs2-fix-memory-leak-in-nilfs_sysfs_delete_snapsho.patch
+habanalabs-add-validity-check-for-event-id-received-.patch
+pwm-img-don-t-modify-hw-state-in-.remove-callback.patch
+pwm-rockchip-don-t-modify-hw-state-in-.remove-callba.patch
+pwm-stm32-lp-don-t-modify-hw-state-in-.remove-callba.patch
+blk-throttle-fix-uaf-by-deleteing-timer-in-blk_throt.patch
+blk-mq-allow-4x-blk_max_request_count-at-blk_plug-fo.patch
+rtc-rx8010-select-regmap_i2c.patch
+sched-idle-make-the-idle-timer-expire-in-hard-interr.patch
--- /dev/null
+From 3175dceb0f222e5cebe4149abb797a1cd6f3e397 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 22 Jul 2021 11:06:44 +0200
+Subject: thermal/core: Fix thermal_cooling_device_register() prototype
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit fb83610762dd5927212aa62a468dd3b756b57a88 ]
+
+There are two pairs of declarations for thermal_cooling_device_register()
+and thermal_of_cooling_device_register(), and only one set was changed
+in a recent patch, so the other one now causes a compile-time warning:
+
+drivers/net/wireless/mediatek/mt76/mt7915/init.c: In function 'mt7915_thermal_init':
+drivers/net/wireless/mediatek/mt76/mt7915/init.c:134:48: error: passing argument 1 of 'thermal_cooling_device_register' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
+ 134 | cdev = thermal_cooling_device_register(wiphy_name(wiphy), phy,
+ | ^~~~~~~~~~~~~~~~~
+In file included from drivers/net/wireless/mediatek/mt76/mt7915/init.c:7:
+include/linux/thermal.h:407:39: note: expected 'char *' but argument is of type 'const char *'
+ 407 | thermal_cooling_device_register(char *type, void *devdata,
+ | ~~~~~~^~~~
+
+Change the dummy helper functions to have the same arguments as the
+normal version.
+
+Fixes: f991de53a8ab ("thermal: make device_register's type argument const")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Link: https://lore.kernel.org/r/20210722090717.1116748-1-arnd@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/thermal.h | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/include/linux/thermal.h b/include/linux/thermal.h
+index d07ea27e72a9..176d9454e8f3 100644
+--- a/include/linux/thermal.h
++++ b/include/linux/thermal.h
+@@ -410,12 +410,13 @@ static inline void thermal_zone_device_unregister(
+ struct thermal_zone_device *tz)
+ { }
+ static inline struct thermal_cooling_device *
+-thermal_cooling_device_register(char *type, void *devdata,
++thermal_cooling_device_register(const char *type, void *devdata,
+ const struct thermal_cooling_device_ops *ops)
+ { return ERR_PTR(-ENODEV); }
+ static inline struct thermal_cooling_device *
+ thermal_of_cooling_device_register(struct device_node *np,
+- char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
++ const char *type, void *devdata,
++ const struct thermal_cooling_device_ops *ops)
+ { return ERR_PTR(-ENODEV); }
+ static inline struct thermal_cooling_device *
+ devm_thermal_of_cooling_device_register(struct device *dev,
+--
+2.33.0
+
--- /dev/null
+From 8c90c54e6c7605a550c2c1284da2ecc51abd383a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 5 Sep 2021 00:54:31 +0900
+Subject: tools/bootconfig: Fix tracing_on option checking in ftrace2bconf.sh
+
+From: Masami Hiramatsu <mhiramat@kernel.org>
+
+[ Upstream commit 32ba9f0fb027cc43074e3ea26fcf831adeee8e03 ]
+
+Since tracing_on indicates only "1" (default) or "0", ftrace2bconf.sh
+only need to check the value is "0".
+
+Link: https://lkml.kernel.org/r/163077087144.222577.6888011847727968737.stgit@devnote2
+
+Fixes: 55ed4560774d ("tools/bootconfig: Add tracing_on support to helper scripts")
+Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/bootconfig/scripts/ftrace2bconf.sh | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tools/bootconfig/scripts/ftrace2bconf.sh b/tools/bootconfig/scripts/ftrace2bconf.sh
+index a0c3bcc6da4f..fb201d5afe2c 100755
+--- a/tools/bootconfig/scripts/ftrace2bconf.sh
++++ b/tools/bootconfig/scripts/ftrace2bconf.sh
+@@ -222,8 +222,8 @@ instance_options() { # [instance-name]
+ emit_kv $PREFIX.cpumask = $val
+ fi
+ val=`cat $INSTANCE/tracing_on`
+- if [ `echo $val | sed -e s/f//g`x != x ]; then
+- emit_kv $PREFIX.tracing_on = $val
++ if [ "$val" = "0" ]; then
++ emit_kv $PREFIX.tracing_on = 0
+ fi
+
+ val=
+--
+2.33.0
+