From: Sasha Levin Date: Wed, 4 Sep 2024 17:42:42 +0000 (-0400) Subject: Fixes for 5.15 X-Git-Tag: v6.1.109~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec18cd75a36d09a41eda33749b5c6216d47ef9f5;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.15 Signed-off-by: Sasha Levin --- diff --git a/queue-5.15/apparmor-fix-possible-null-pointer-dereference.patch b/queue-5.15/apparmor-fix-possible-null-pointer-dereference.patch new file mode 100644 index 00000000000..c0414d76e7a --- /dev/null +++ b/queue-5.15/apparmor-fix-possible-null-pointer-dereference.patch @@ -0,0 +1,107 @@ +From dbb2f794b9f8395ba1c61a0294ddad25d36a6251 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 May 2024 01:12:29 +0900 +Subject: apparmor: fix possible NULL pointer dereference + +From: Leesoo Ahn + +[ Upstream commit 3dd384108d53834002be5630132ad5c3f32166ad ] + +profile->parent->dents[AAFS_PROF_DIR] could be NULL only if its parent is made +from __create_missing_ancestors(..) and 'ent->old' is NULL in +aa_replace_profiles(..). +In that case, it must return an error code and the code, -ENOENT represents +its state that the path of its parent is not existed yet. + +BUG: kernel NULL pointer dereference, address: 0000000000000030 +PGD 0 P4D 0 +PREEMPT SMP PTI +CPU: 4 PID: 3362 Comm: apparmor_parser Not tainted 6.8.0-24-generic #24 +Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 +RIP: 0010:aafs_create.constprop.0+0x7f/0x130 +Code: 4c 63 e0 48 83 c4 18 4c 89 e0 5b 41 5c 41 5d 41 5e 41 5f 5d 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 c3 cc cc cc cc <4d> 8b 55 30 4d 8d ba a0 00 00 00 4c 89 55 c0 4c 89 ff e8 7a 6a ae +RSP: 0018:ffffc9000b2c7c98 EFLAGS: 00010246 +RAX: 0000000000000000 RBX: 00000000000041ed RCX: 0000000000000000 +RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 +RBP: ffffc9000b2c7cd8 R08: 0000000000000000 R09: 0000000000000000 +R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82baac10 +R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 +FS: 00007be9f22cf740(0000) GS:ffff88817bc00000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 0000000000000030 CR3: 0000000134b08000 CR4: 00000000000006f0 +Call Trace: + + ? show_regs+0x6d/0x80 + ? __die+0x24/0x80 + ? page_fault_oops+0x99/0x1b0 + ? kernelmode_fixup_or_oops+0xb2/0x140 + ? __bad_area_nosemaphore+0x1a5/0x2c0 + ? find_vma+0x34/0x60 + ? bad_area_nosemaphore+0x16/0x30 + ? do_user_addr_fault+0x2a2/0x6b0 + ? exc_page_fault+0x83/0x1b0 + ? asm_exc_page_fault+0x27/0x30 + ? aafs_create.constprop.0+0x7f/0x130 + ? aafs_create.constprop.0+0x51/0x130 + __aafs_profile_mkdir+0x3d6/0x480 + aa_replace_profiles+0x83f/0x1270 + policy_update+0xe3/0x180 + profile_load+0xbc/0x150 + ? rw_verify_area+0x47/0x140 + vfs_write+0x100/0x480 + ? __x64_sys_openat+0x55/0xa0 + ? syscall_exit_to_user_mode+0x86/0x260 + ksys_write+0x73/0x100 + __x64_sys_write+0x19/0x30 + x64_sys_call+0x7e/0x25c0 + do_syscall_64+0x7f/0x180 + entry_SYSCALL_64_after_hwframe+0x78/0x80 +RIP: 0033:0x7be9f211c574 +Code: c7 00 16 00 00 00 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 80 3d d5 ea 0e 00 00 74 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 55 48 89 e5 48 83 ec 20 48 89 +RSP: 002b:00007ffd26f2b8c8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 +RAX: ffffffffffffffda RBX: 00005d504415e200 RCX: 00007be9f211c574 +RDX: 0000000000001fc1 RSI: 00005d504418bc80 RDI: 0000000000000004 +RBP: 0000000000001fc1 R08: 0000000000001fc1 R09: 0000000080000000 +R10: 0000000000000000 R11: 0000000000000202 R12: 00005d504418bc80 +R13: 0000000000000004 R14: 00007ffd26f2b9b0 R15: 00007ffd26f2ba30 + +Modules linked in: snd_seq_dummy snd_hrtimer qrtr snd_hda_codec_generic snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device i2c_i801 snd_timer i2c_smbus qxl snd soundcore drm_ttm_helper lpc_ich ttm joydev input_leds serio_raw mac_hid binfmt_misc msr parport_pc ppdev lp parport efi_pstore nfnetlink dmi_sysfs qemu_fw_cfg ip_tables x_tables autofs4 hid_generic usbhid hid ahci libahci psmouse virtio_rng xhci_pci xhci_pci_renesas +CR2: 0000000000000030 +---[ end trace 0000000000000000 ]--- +RIP: 0010:aafs_create.constprop.0+0x7f/0x130 +Code: 4c 63 e0 48 83 c4 18 4c 89 e0 5b 41 5c 41 5d 41 5e 41 5f 5d 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 c3 cc cc cc cc <4d> 8b 55 30 4d 8d ba a0 00 00 00 4c 89 55 c0 4c 89 ff e8 7a 6a ae +RSP: 0018:ffffc9000b2c7c98 EFLAGS: 00010246 +RAX: 0000000000000000 RBX: 00000000000041ed RCX: 0000000000000000 +RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 +RBP: ffffc9000b2c7cd8 R08: 0000000000000000 R09: 0000000000000000 +R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82baac10 +R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 +FS: 00007be9f22cf740(0000) GS:ffff88817bc00000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 0000000000000030 CR3: 0000000134b08000 CR4: 00000000000006f0 + +Signed-off-by: Leesoo Ahn +Signed-off-by: John Johansen +Signed-off-by: Sasha Levin +--- + security/apparmor/apparmorfs.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c +index 8c7719108d7f..c70b86f17124 100644 +--- a/security/apparmor/apparmorfs.c ++++ b/security/apparmor/apparmorfs.c +@@ -1679,6 +1679,10 @@ int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent) + struct aa_profile *p; + p = aa_deref_parent(profile); + dent = prof_dir(p); ++ if (!dent) { ++ error = -ENOENT; ++ goto fail2; ++ } + /* adding to parent that previously didn't have children */ + dent = aafs_create_dir("profiles", dent); + if (IS_ERR(dent)) +-- +2.43.0 + diff --git a/queue-5.15/block-remove-the-blk_flush_integrity-call-in-blk_int.patch b/queue-5.15/block-remove-the-blk_flush_integrity-call-in-blk_int.patch new file mode 100644 index 00000000000..d80f39b8f6b --- /dev/null +++ b/queue-5.15/block-remove-the-blk_flush_integrity-call-in-blk_int.patch @@ -0,0 +1,44 @@ +From 1bafac3ef8dcb523c2a0addb87e79a99e31c74c8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 13 Jun 2024 10:48:16 +0200 +Subject: block: remove the blk_flush_integrity call in + blk_integrity_unregister + +From: Christoph Hellwig + +[ Upstream commit e8bc14d116aeac8f0f133ec8d249acf4e0658da7 ] + +Now that there are no indirect calls for PI processing there is no +way to dereference a NULL pointer here. Additionally drivers now always +freeze the queue (or in case of stacking drivers use their internal +equivalent) around changing the integrity profile. + +This is effectively a revert of commit 3df49967f6f1 ("block: flush the +integrity workqueue in blk_integrity_unregister"). + +Signed-off-by: Christoph Hellwig +Reviewed-by: Martin K. Petersen +Reviewed-by: Hannes Reinecke +Link: https://lore.kernel.org/r/20240613084839.1044015-7-hch@lst.de +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + block/blk-integrity.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/block/blk-integrity.c b/block/blk-integrity.c +index 16d5d5338392..85edf6614b97 100644 +--- a/block/blk-integrity.c ++++ b/block/blk-integrity.c +@@ -431,8 +431,6 @@ void blk_integrity_unregister(struct gendisk *disk) + if (!bi->profile) + return; + +- /* ensure all bios are off the integrity workqueue */ +- blk_flush_integrity(); + blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue); + memset(bi, 0, sizeof(*bi)); + } +-- +2.43.0 + diff --git a/queue-5.15/cpufreq-scmi-avoid-overflow-of-target_freq-in-fast-s.patch b/queue-5.15/cpufreq-scmi-avoid-overflow-of-target_freq-in-fast-s.patch new file mode 100644 index 00000000000..86eb277bfa1 --- /dev/null +++ b/queue-5.15/cpufreq-scmi-avoid-overflow-of-target_freq-in-fast-s.patch @@ -0,0 +1,41 @@ +From 14b27a38d2e5f432ad3e1a1f620609f507350fdb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 May 2024 12:07:32 +0530 +Subject: cpufreq: scmi: Avoid overflow of target_freq in fast switch + +From: Jagadeesh Kona + +[ Upstream commit 074cffb5020ddcaa5fafcc55655e5da6ebe8c831 ] + +Conversion of target_freq to HZ in scmi_cpufreq_fast_switch() +can lead to overflow if the multiplied result is greater than +UINT_MAX, since type of target_freq is unsigned int. Avoid this +overflow by assigning target_freq to unsigned long variable for +converting it to HZ. + +Signed-off-by: Jagadeesh Kona +Signed-off-by: Viresh Kumar +Signed-off-by: Sasha Levin +--- + drivers/cpufreq/scmi-cpufreq.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c +index c24e6373d341..eb3f1952f986 100644 +--- a/drivers/cpufreq/scmi-cpufreq.c ++++ b/drivers/cpufreq/scmi-cpufreq.c +@@ -61,9 +61,9 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, + unsigned int target_freq) + { + struct scmi_data *priv = policy->driver_data; ++ unsigned long freq = target_freq; + +- if (!perf_ops->freq_set(ph, priv->domain_id, +- target_freq * 1000, true)) ++ if (!perf_ops->freq_set(ph, priv->domain_id, freq * 1000, true)) + return target_freq; + + return 0; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-amdgpu-check-tbo-resource-pointer.patch b/queue-5.15/drm-amd-amdgpu-check-tbo-resource-pointer.patch new file mode 100644 index 00000000000..27c859b3399 --- /dev/null +++ b/queue-5.15/drm-amd-amdgpu-check-tbo-resource-pointer.patch @@ -0,0 +1,40 @@ +From 8533d5a55f42bbf119dad97ba09afdfa30e7b010 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Apr 2024 02:26:55 +0800 +Subject: drm/amd/amdgpu: Check tbo resource pointer +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Asad Kamal + +[ Upstream commit 6cd2b872643bb29bba01a8ac739138db7bd79007 ] + +Validate tbo resource pointer, skip if NULL + +Signed-off-by: Asad Kamal +Reviewed-by: Christian König +Reviewed-by: Lijo Lazar +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +index 300d3b236bb3..042f27af6856 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +@@ -4406,7 +4406,8 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev) + shadow = vmbo->shadow; + + /* No need to recover an evicted BO */ +- if (shadow->tbo.resource->mem_type != TTM_PL_TT || ++ if (!shadow->tbo.resource || ++ shadow->tbo.resource->mem_type != TTM_PL_TT || + shadow->tbo.resource->start == AMDGPU_BO_INVALID_OFFSET || + shadow->parent->tbo.resource->mem_type != TTM_PL_VRAM) + continue; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-add-array-index-check-for-hdcp-ddc-a.patch b/queue-5.15/drm-amd-display-add-array-index-check-for-hdcp-ddc-a.patch new file mode 100644 index 00000000000..b2bab3cb925 --- /dev/null +++ b/queue-5.15/drm-amd-display-add-array-index-check-for-hdcp-ddc-a.patch @@ -0,0 +1,95 @@ +From 4eeea55394fc85637417276b0c44d4f24fedb222 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Apr 2024 10:09:31 -0400 +Subject: drm/amd/display: Add array index check for hdcp ddc access + +From: Hersen Wu + +[ Upstream commit 4e70c0f5251c25885c31ee84a31f99a01f7cf50e ] + +[Why] +Coverity reports OVERRUN warning. Do not check if array +index valid. + +[How] +Check msg_id valid and valid array index. + +Reviewed-by: Alex Hung +Acked-by: Tom Chung +Signed-off-by: Hersen Wu +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + .../drm/amd/display/modules/hdcp/hdcp_ddc.c | 28 ++++++++++++++++--- + 1 file changed, 24 insertions(+), 4 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c +index 8e9caae7c955..1b2df97226a3 100644 +--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c ++++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c +@@ -156,11 +156,16 @@ static enum mod_hdcp_status read(struct mod_hdcp *hdcp, + uint32_t cur_size = 0; + uint32_t data_offset = 0; + +- if (msg_id == MOD_HDCP_MESSAGE_ID_INVALID) { ++ if (msg_id == MOD_HDCP_MESSAGE_ID_INVALID || ++ msg_id >= MOD_HDCP_MESSAGE_ID_MAX) + return MOD_HDCP_STATUS_DDC_FAILURE; +- } + + if (is_dp_hdcp(hdcp)) { ++ int num_dpcd_addrs = sizeof(hdcp_dpcd_addrs) / ++ sizeof(hdcp_dpcd_addrs[0]); ++ if (msg_id >= num_dpcd_addrs) ++ return MOD_HDCP_STATUS_DDC_FAILURE; ++ + while (buf_len > 0) { + cur_size = MIN(buf_len, HDCP_MAX_AUX_TRANSACTION_SIZE); + success = hdcp->config.ddc.funcs.read_dpcd(hdcp->config.ddc.handle, +@@ -175,6 +180,11 @@ static enum mod_hdcp_status read(struct mod_hdcp *hdcp, + data_offset += cur_size; + } + } else { ++ int num_i2c_offsets = sizeof(hdcp_i2c_offsets) / ++ sizeof(hdcp_i2c_offsets[0]); ++ if (msg_id >= num_i2c_offsets) ++ return MOD_HDCP_STATUS_DDC_FAILURE; ++ + success = hdcp->config.ddc.funcs.read_i2c( + hdcp->config.ddc.handle, + HDCP_I2C_ADDR, +@@ -219,11 +229,16 @@ static enum mod_hdcp_status write(struct mod_hdcp *hdcp, + uint32_t cur_size = 0; + uint32_t data_offset = 0; + +- if (msg_id == MOD_HDCP_MESSAGE_ID_INVALID) { ++ if (msg_id == MOD_HDCP_MESSAGE_ID_INVALID || ++ msg_id >= MOD_HDCP_MESSAGE_ID_MAX) + return MOD_HDCP_STATUS_DDC_FAILURE; +- } + + if (is_dp_hdcp(hdcp)) { ++ int num_dpcd_addrs = sizeof(hdcp_dpcd_addrs) / ++ sizeof(hdcp_dpcd_addrs[0]); ++ if (msg_id >= num_dpcd_addrs) ++ return MOD_HDCP_STATUS_DDC_FAILURE; ++ + while (buf_len > 0) { + cur_size = MIN(buf_len, HDCP_MAX_AUX_TRANSACTION_SIZE); + success = hdcp->config.ddc.funcs.write_dpcd( +@@ -239,6 +254,11 @@ static enum mod_hdcp_status write(struct mod_hdcp *hdcp, + data_offset += cur_size; + } + } else { ++ int num_i2c_offsets = sizeof(hdcp_i2c_offsets) / ++ sizeof(hdcp_i2c_offsets[0]); ++ if (msg_id >= num_i2c_offsets) ++ return MOD_HDCP_STATUS_DDC_FAILURE; ++ + hdcp->buf[0] = hdcp_i2c_offsets[msg_id]; + memmove(&hdcp->buf[1], buf, buf_len); + success = hdcp->config.ddc.funcs.write_i2c( +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-added-null-check-at-start-of-dc_vali.patch b/queue-5.15/drm-amd-display-added-null-check-at-start-of-dc_vali.patch new file mode 100644 index 00000000000..4e80f2e18f4 --- /dev/null +++ b/queue-5.15/drm-amd-display-added-null-check-at-start-of-dc_vali.patch @@ -0,0 +1,43 @@ +From b696861409d0da093e08f89812e5bd570e68bbe6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 27 May 2024 08:51:19 -0400 +Subject: drm/amd/display: added NULL check at start of dc_validate_stream + +From: winstang + +[ Upstream commit 26c56049cc4f1705b498df013949427692a4b0d5 ] + +[Why] +prevent invalid memory access + +[How] +check if dc and stream are NULL + +Co-authored-by: winstang +Reviewed-by: Alvin Lee +Acked-by: Zaeem Mohamed +Signed-off-by: winstang +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +index 42432af34db2..df84f3b521e2 100644 +--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c ++++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +@@ -2872,6 +2872,9 @@ void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream, + + enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream) + { ++ if (dc == NULL || stream == NULL) ++ return DC_ERROR_UNEXPECTED; ++ + struct dc_link *link = stream->link; + struct timing_generator *tg = dc->res_pool->timing_generators[0]; + enum dc_status res = DC_OK; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-assign-linear_pitch_alignment-even-f.patch b/queue-5.15/drm-amd-display-assign-linear_pitch_alignment-even-f.patch new file mode 100644 index 00000000000..9dbe8611566 --- /dev/null +++ b/queue-5.15/drm-amd-display-assign-linear_pitch_alignment-even-f.patch @@ -0,0 +1,38 @@ +From 2fd7d06053ce8c2241f5aa39983b391595101954 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Apr 2024 14:42:18 -0400 +Subject: drm/amd/display: Assign linear_pitch_alignment even for VM + +From: Alvin Lee + +[ Upstream commit 984debc133efa05e62f5aa1a7a1dd8ca0ef041f4 ] + +[Description] +Assign linear_pitch_alignment so we don't cause a divide by 0 +error in VM environments + +Reviewed-by: Sohaib Nadeem +Acked-by: Wayne Lin +Signed-off-by: Alvin Lee +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/core/dc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c +index ef151a1bc31c..12e4beca5e84 100644 +--- a/drivers/gpu/drm/amd/display/dc/core/dc.c ++++ b/drivers/gpu/drm/amd/display/dc/core/dc.c +@@ -1107,6 +1107,7 @@ struct dc *dc_create(const struct dc_init_data *init_params) + return NULL; + + if (init_params->dce_environment == DCE_ENV_VIRTUAL_HW) { ++ dc->caps.linear_pitch_alignment = 64; + if (!dc_construct_ctx(dc, init_params)) + goto destruct_dc; + } else { +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-check-gpio_id-before-used-as-array-i.patch b/queue-5.15/drm-amd-display-check-gpio_id-before-used-as-array-i.patch new file mode 100644 index 00000000000..e16bd1e4cd9 --- /dev/null +++ b/queue-5.15/drm-amd-display-check-gpio_id-before-used-as-array-i.patch @@ -0,0 +1,80 @@ +From 7fee3ce3c2e74469657103686c06f1e092d869a2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Apr 2024 16:40:00 -0600 +Subject: drm/amd/display: Check gpio_id before used as array index + +From: Alex Hung + +[ Upstream commit 2a5626eeb3b5eec7a36886f9556113dd93ec8ed6 ] + +[WHY & HOW] +GPIO_ID_UNKNOWN (-1) is not a valid value for array index and therefore +should be checked in advance. + +This fixes 5 OVERRUN issues reported by Coverity. + +Reviewed-by: Harry Wentland +Acked-by: Tom Chung +Signed-off-by: Alex Hung +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +index dae8e489c8cf..a7c92c64490c 100644 +--- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c ++++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +@@ -241,6 +241,9 @@ static bool is_pin_busy( + enum gpio_id id, + uint32_t en) + { ++ if (id == GPIO_ID_UNKNOWN) ++ return false; ++ + return service->busyness[id][en]; + } + +@@ -249,6 +252,9 @@ static void set_pin_busy( + enum gpio_id id, + uint32_t en) + { ++ if (id == GPIO_ID_UNKNOWN) ++ return; ++ + service->busyness[id][en] = true; + } + +@@ -257,6 +263,9 @@ static void set_pin_free( + enum gpio_id id, + uint32_t en) + { ++ if (id == GPIO_ID_UNKNOWN) ++ return; ++ + service->busyness[id][en] = false; + } + +@@ -265,7 +274,7 @@ enum gpio_result dal_gpio_service_lock( + enum gpio_id id, + uint32_t en) + { +- if (!service->busyness[id]) { ++ if (id != GPIO_ID_UNKNOWN && !service->busyness[id]) { + ASSERT_CRITICAL(false); + return GPIO_RESULT_OPEN_FAILED; + } +@@ -279,7 +288,7 @@ enum gpio_result dal_gpio_service_unlock( + enum gpio_id id, + uint32_t en) + { +- if (!service->busyness[id]) { ++ if (id != GPIO_ID_UNKNOWN && !service->busyness[id]) { + ASSERT_CRITICAL(false); + return GPIO_RESULT_OPEN_FAILED; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-check-msg_id-before-processing-trans.patch b/queue-5.15/drm-amd-display-check-msg_id-before-processing-trans.patch new file mode 100644 index 00000000000..57129b1dba5 --- /dev/null +++ b/queue-5.15/drm-amd-display-check-msg_id-before-processing-trans.patch @@ -0,0 +1,68 @@ +From 972019a3ca6a7c6ae734a711f5cda1bbe41070d4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Apr 2024 16:47:42 -0600 +Subject: drm/amd/display: Check msg_id before processing transcation + +From: Alex Hung + +[ Upstream commit fa71face755e27dc44bc296416ebdf2c67163316 ] + +[WHY & HOW] +HDCP_MESSAGE_ID_INVALID (-1) is not a valid msg_id nor is it a valid +array index, and it needs checking before used. + +This fixes 4 OVERRUN issues reported by Coverity. + +Reviewed-by: Harry Wentland +Acked-by: Tom Chung +Signed-off-by: Alex Hung +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c b/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c +index 4233955e3c47..c9851492ec84 100644 +--- a/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c ++++ b/drivers/gpu/drm/amd/display/dc/hdcp/hdcp_msg.c +@@ -131,13 +131,21 @@ static bool hdmi_14_process_transaction( + const uint8_t hdcp_i2c_addr_link_primary = 0x3a; /* 0x74 >> 1*/ + const uint8_t hdcp_i2c_addr_link_secondary = 0x3b; /* 0x76 >> 1*/ + struct i2c_command i2c_command; +- uint8_t offset = hdcp_i2c_offsets[message_info->msg_id]; ++ uint8_t offset; + struct i2c_payload i2c_payloads[] = { +- { true, 0, 1, &offset }, ++ { true, 0, 1, 0 }, + /* actual hdcp payload, will be filled later, zeroed for now*/ + { 0 } + }; + ++ if (message_info->msg_id == HDCP_MESSAGE_ID_INVALID) { ++ DC_LOG_ERROR("%s: Invalid message_info msg_id - %d\n", __func__, message_info->msg_id); ++ return false; ++ } ++ ++ offset = hdcp_i2c_offsets[message_info->msg_id]; ++ i2c_payloads[0].data = &offset; ++ + switch (message_info->link) { + case HDCP_LINK_SECONDARY: + i2c_payloads[0].address = hdcp_i2c_addr_link_secondary; +@@ -311,6 +319,11 @@ static bool dp_11_process_transaction( + struct dc_link *link, + struct hdcp_protection_message *message_info) + { ++ if (message_info->msg_id == HDCP_MESSAGE_ID_INVALID) { ++ DC_LOG_ERROR("%s: Invalid message_info msg_id - %d\n", __func__, message_info->msg_id); ++ return false; ++ } ++ + return dpcd_access_helper( + link, + message_info->length, +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-check-num_valid_sets-before-accessin.patch b/queue-5.15/drm-amd-display-check-num_valid_sets-before-accessin.patch new file mode 100644 index 00000000000..d1e8814521d --- /dev/null +++ b/queue-5.15/drm-amd-display-check-num_valid_sets-before-accessin.patch @@ -0,0 +1,43 @@ +From a0bcf6d9b180f9c4295f1abf7275f97418d00cd1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Apr 2024 16:22:35 -0600 +Subject: drm/amd/display: Check num_valid_sets before accessing + reader_wm_sets[] + +From: Alex Hung + +[ Upstream commit b38a4815f79b87efb196cd5121579fc51e29a7fb ] + +[WHY & HOW] +num_valid_sets needs to be checked to avoid a negative index when +accessing reader_wm_sets[num_valid_sets - 1]. + +This fixes an OVERRUN issue reported by Coverity. + +Reviewed-by: Harry Wentland +Acked-by: Tom Chung +Signed-off-by: Alex Hung +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c +index 6185f9475fa2..afce8f3bc67a 100644 +--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c ++++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c +@@ -489,7 +489,8 @@ static void build_watermark_ranges(struct clk_bw_params *bw_params, struct pp_sm + ranges->reader_wm_sets[num_valid_sets].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; + + /* Modify previous watermark range to cover up to max */ +- ranges->reader_wm_sets[num_valid_sets - 1].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; ++ if (num_valid_sets > 0) ++ ranges->reader_wm_sets[num_valid_sets - 1].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; + } + num_valid_sets++; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-fix-coverity-integer_overflow-within.patch b/queue-5.15/drm-amd-display-fix-coverity-integer_overflow-within.patch new file mode 100644 index 00000000000..f954a99bdea --- /dev/null +++ b/queue-5.15/drm-amd-display-fix-coverity-integer_overflow-within.patch @@ -0,0 +1,52 @@ +From a4f4601b577a37321b538908b3feb46882615649 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Apr 2024 11:58:11 -0400 +Subject: drm/amd/display: Fix Coverity INTEGER_OVERFLOW within + dal_gpio_service_create + +From: Hersen Wu + +[ Upstream commit c6077aa66fa230d12f37fef01161ef080d13b726 ] + +[Why] +For subtraction, coverity reports integer overflow +warning message when variable type is uint32_t. + +[How] +Change variable type to int32_t. + +Reviewed-by: Harry Wentland +Acked-by: Tom Chung +Signed-off-by: Hersen Wu +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +index a7c92c64490c..a5de27908914 100644 +--- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c ++++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +@@ -58,7 +58,7 @@ struct gpio_service *dal_gpio_service_create( + struct dc_context *ctx) + { + struct gpio_service *service; +- uint32_t index_of_id; ++ int32_t index_of_id; + + service = kzalloc(sizeof(struct gpio_service), GFP_KERNEL); + +@@ -114,7 +114,7 @@ struct gpio_service *dal_gpio_service_create( + return service; + + failure_2: +- while (index_of_id) { ++ while (index_of_id > 0) { + --index_of_id; + kfree(service->busyness[index_of_id]); + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-skip-wbscl_set_scaler_filter-if-filt.patch b/queue-5.15/drm-amd-display-skip-wbscl_set_scaler_filter-if-filt.patch new file mode 100644 index 00000000000..35631cdf706 --- /dev/null +++ b/queue-5.15/drm-amd-display-skip-wbscl_set_scaler_filter-if-filt.patch @@ -0,0 +1,41 @@ +From 1d47ae3b703878611b89ee0530fb3ee53ba51dc1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 3 Jun 2024 10:47:37 -0600 +Subject: drm/amd/display: Skip wbscl_set_scaler_filter if filter is null + +From: Alex Hung + +[ Upstream commit c4d31653c03b90e51515b1380115d1aedad925dd ] + +Callers can pass null in filter (i.e. from returned from the function +wbscl_get_filter_coeffs_16p) and a null check is added to ensure that is +not the case. + +This fixes 4 NULL_RETURNS issues reported by Coverity. + +Reviewed-by: Harry Wentland +Acked-by: Hamza Mahfooz +Signed-off-by: Alex Hung +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c +index 880954ac0b02..1b3cba5b1d74 100644 +--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c ++++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb_scl.c +@@ -690,6 +690,9 @@ static void wbscl_set_scaler_filter( + int pair; + uint16_t odd_coef, even_coef; + ++ if (!filter) ++ return; ++ + for (phase = 0; phase < (NUM_PHASES / 2 + 1); phase++) { + for (pair = 0; pair < tap_pairs; pair++) { + even_coef = filter[phase * taps + 2 * pair]; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-display-stop-amdgpu_dm-initialize-when-strea.patch b/queue-5.15/drm-amd-display-stop-amdgpu_dm-initialize-when-strea.patch new file mode 100644 index 00000000000..57569c2adb2 --- /dev/null +++ b/queue-5.15/drm-amd-display-stop-amdgpu_dm-initialize-when-strea.patch @@ -0,0 +1,46 @@ +From 7b19c32f05f4bfd09af1ae286cc768332c75adfa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Apr 2024 16:00:19 -0400 +Subject: drm/amd/display: Stop amdgpu_dm initialize when stream nums greater + than 6 + +From: Hersen Wu + +[ Upstream commit 84723eb6068c50610c5c0893980d230d7afa2105 ] + +[Why] +Coverity reports OVERRUN warning. Should abort amdgpu_dm +initialize. + +[How] +Return failure to amdgpu_dm_init. + +Reviewed-by: Harry Wentland +Acked-by: Tom Chung +Signed-off-by: Hersen Wu +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +index 333be0541893..b4ae90c3ed23 100644 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +@@ -4211,7 +4211,10 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) + + /* There is one primary plane per CRTC */ + primary_planes = dm->dc->caps.max_streams; +- ASSERT(primary_planes <= AMDGPU_MAX_PLANES); ++ if (primary_planes > AMDGPU_MAX_PLANES) { ++ DRM_ERROR("DM: Plane nums out of 6 planes\n"); ++ return -EINVAL; ++ } + + /* + * Initialize primary planes, implicit planes for legacy IOCTLS. +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-pm-check-negtive-return-for-table-entries.patch b/queue-5.15/drm-amd-pm-check-negtive-return-for-table-entries.patch new file mode 100644 index 00000000000..fb1aae254bd --- /dev/null +++ b/queue-5.15/drm-amd-pm-check-negtive-return-for-table-entries.patch @@ -0,0 +1,61 @@ +From 5d1d60de3beb0f4b31107e604a616579bfc862a9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 13 May 2024 16:01:23 +0800 +Subject: drm/amd/pm: check negtive return for table entries + +From: Jesse Zhang + +[ Upstream commit f76059fe14395b37ba8d997eb0381b1b9e80a939 ] + +Function hwmgr->hwmgr_func->get_num_of_pp_table_entries(hwmgr) returns a negative number + +Signed-off-by: Jesse Zhang +Suggested-by: Tim Huang +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +index 1d829402cd2e..59b18395983a 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +@@ -30,9 +30,8 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) + { + int result; + unsigned int i; +- unsigned int table_entries; + struct pp_power_state *state; +- int size; ++ int size, table_entries; + + if (hwmgr->hwmgr_func->get_num_of_pp_table_entries == NULL) + return 0; +@@ -40,15 +39,19 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) + if (hwmgr->hwmgr_func->get_power_state_size == NULL) + return 0; + +- hwmgr->num_ps = table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries(hwmgr); ++ table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries(hwmgr); + +- hwmgr->ps_size = size = hwmgr->hwmgr_func->get_power_state_size(hwmgr) + ++ size = hwmgr->hwmgr_func->get_power_state_size(hwmgr) + + sizeof(struct pp_power_state); + +- if (table_entries == 0 || size == 0) { ++ if (table_entries <= 0 || size == 0) { + pr_warn("Please check whether power state management is supported on this asic\n"); ++ hwmgr->num_ps = 0; ++ hwmgr->ps_size = 0; + return 0; + } ++ hwmgr->num_ps = table_entries; ++ hwmgr->ps_size = size; + + hwmgr->ps = kcalloc(table_entries, size, GFP_KERNEL); + if (hwmgr->ps == NULL) +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-pm-check-specific-index-for-aldebaran.patch b/queue-5.15/drm-amd-pm-check-specific-index-for-aldebaran.patch new file mode 100644 index 00000000000..6f3c3f3b166 --- /dev/null +++ b/queue-5.15/drm-amd-pm-check-specific-index-for-aldebaran.patch @@ -0,0 +1,37 @@ +From c2a51d6468ab51eb9ceae1aa020600bc89df4889 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 May 2024 17:13:28 +0800 +Subject: drm/amd/pm: check specific index for aldebaran + +From: Jesse Zhang + +[ Upstream commit 0ce8ef2639c112ae203c985b758389e378630aac ] + +Check for specific indexes that may be invalid values. + +Signed-off-by: Jesse Zhang +Reviewed-by: Yang Wang +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +index d0c6b864d00a..31846510c1a9 100644 +--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c ++++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +@@ -1775,7 +1775,8 @@ static int aldebaran_mode2_reset(struct smu_context *smu) + + index = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_MSG, + SMU_MSG_GfxDeviceDriverReset); +- ++ if (index < 0 ) ++ return -EINVAL; + mutex_lock(&smu->message_lock); + if (smu_version >= 0x00441400) { + ret = smu_cmn_send_msg_without_waiting(smu, (uint16_t)index, SMU_RESET_MODE_2); +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-pm-fix-the-out-of-bounds-read-warning.patch b/queue-5.15/drm-amd-pm-fix-the-out-of-bounds-read-warning.patch new file mode 100644 index 00000000000..cd6525384de --- /dev/null +++ b/queue-5.15/drm-amd-pm-fix-the-out-of-bounds-read-warning.patch @@ -0,0 +1,39 @@ +From 0910885fa45aadbef9c4014bd855fca1c593a72a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 30 Apr 2024 10:29:08 +0800 +Subject: drm/amd/pm: fix the Out-of-bounds read warning + +From: Jesse Zhang + +[ Upstream commit 12c6967428a099bbba9dfd247bb4322a984fcc0b ] + +using index i - 1U may beyond element index +for mc_data[] when i = 0. + +Signed-off-by: Jesse Zhang +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +index f503e61faa60..cc3b62f73394 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +@@ -73,8 +73,9 @@ static int atomctrl_retrieve_ac_timing( + j++; + } else if ((table->mc_reg_address[i].uc_pre_reg_data & + LOW_NIBBLE_MASK) == DATA_EQU_PREV) { +- table->mc_reg_table_entry[num_ranges].mc_data[i] = +- table->mc_reg_table_entry[num_ranges].mc_data[i-1]; ++ if (i) ++ table->mc_reg_table_entry[num_ranges].mc_data[i] = ++ table->mc_reg_table_entry[num_ranges].mc_data[i-1]; + } + } + num_ranges++; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-pm-fix-uninitialized-variable-warning-for-sm.patch b/queue-5.15/drm-amd-pm-fix-uninitialized-variable-warning-for-sm.patch new file mode 100644 index 00000000000..1c4123cdb17 --- /dev/null +++ b/queue-5.15/drm-amd-pm-fix-uninitialized-variable-warning-for-sm.patch @@ -0,0 +1,87 @@ +From c71851fe6d9f0dc0a59c878f820471935e4a284b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Apr 2024 12:52:45 +0800 +Subject: drm/amd/pm: fix uninitialized variable warning for smu8_hwmgr +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Tim Huang + +[ Upstream commit 86df36b934640866eb249a4488abb148b985a0d9 ] + +Clear warnings that using uninitialized value level when fails +to get the value from SMU. + +Signed-off-by: Tim Huang +Reviewed-by: Christian König +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + .../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +index f0f8ebffd9f2..c1887c21c7ab 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +@@ -584,6 +584,7 @@ static int smu8_init_uvd_limit(struct pp_hwmgr *hwmgr) + hwmgr->dyn_state.uvd_clock_voltage_dependency_table; + unsigned long clock = 0; + uint32_t level; ++ int ret; + + if (NULL == table || table->count <= 0) + return -EINVAL; +@@ -591,7 +592,9 @@ static int smu8_init_uvd_limit(struct pp_hwmgr *hwmgr) + data->uvd_dpm.soft_min_clk = 0; + data->uvd_dpm.hard_min_clk = 0; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxUvdLevel, &level); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxUvdLevel, &level); ++ if (ret) ++ return ret; + + if (level < table->count) + clock = table->entries[level].vclk; +@@ -611,6 +614,7 @@ static int smu8_init_vce_limit(struct pp_hwmgr *hwmgr) + hwmgr->dyn_state.vce_clock_voltage_dependency_table; + unsigned long clock = 0; + uint32_t level; ++ int ret; + + if (NULL == table || table->count <= 0) + return -EINVAL; +@@ -618,7 +622,9 @@ static int smu8_init_vce_limit(struct pp_hwmgr *hwmgr) + data->vce_dpm.soft_min_clk = 0; + data->vce_dpm.hard_min_clk = 0; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxEclkLevel, &level); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxEclkLevel, &level); ++ if (ret) ++ return ret; + + if (level < table->count) + clock = table->entries[level].ecclk; +@@ -638,6 +644,7 @@ static int smu8_init_acp_limit(struct pp_hwmgr *hwmgr) + hwmgr->dyn_state.acp_clock_voltage_dependency_table; + unsigned long clock = 0; + uint32_t level; ++ int ret; + + if (NULL == table || table->count <= 0) + return -EINVAL; +@@ -645,7 +652,9 @@ static int smu8_init_acp_limit(struct pp_hwmgr *hwmgr) + data->acp_dpm.soft_min_clk = 0; + data->acp_dpm.hard_min_clk = 0; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxAclkLevel, &level); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxAclkLevel, &level); ++ if (ret) ++ return ret; + + if (level < table->count) + clock = table->entries[level].acpclk; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-pm-fix-uninitialized-variable-warnings-for-v.patch b/queue-5.15/drm-amd-pm-fix-uninitialized-variable-warnings-for-v.patch new file mode 100644 index 00000000000..1e74ddceff4 --- /dev/null +++ b/queue-5.15/drm-amd-pm-fix-uninitialized-variable-warnings-for-v.patch @@ -0,0 +1,180 @@ +From 743c453e4d4fc13b3709fdc6d91007a9a6ca1037 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 28 Apr 2024 12:41:42 +0800 +Subject: drm/amd/pm: fix uninitialized variable warnings for vega10_hwmgr + +From: Tim Huang + +[ Upstream commit 5fa7d540d95d97ddc021a74583f6b3da4df9c93a ] + +Clear warnings that using uninitialized variable when fails +to get the valid value from SMU. + +Signed-off-by: Tim Huang +Reviewed-by: Yang Wang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + .../drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 46 ++++++++++++++----- + .../amd/pm/powerplay/smumgr/vega10_smumgr.c | 6 ++- + 2 files changed, 39 insertions(+), 13 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +index 6a0933a78c9d..fadceaba031e 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +@@ -355,13 +355,13 @@ static int vega10_odn_initial_default_setting(struct pp_hwmgr *hwmgr) + return 0; + } + +-static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) ++static int vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) + { + struct vega10_hwmgr *data = hwmgr->backend; +- int i; + uint32_t sub_vendor_id, hw_revision; + uint32_t top32, bottom32; + struct amdgpu_device *adev = hwmgr->adev; ++ int ret, i; + + vega10_initialize_power_tune_defaults(hwmgr); + +@@ -486,9 +486,12 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) + if (data->registry_data.vr0hot_enabled) + data->smu_features[GNLD_VR0HOT].supported = true; + +- smum_send_msg_to_smc(hwmgr, ++ ret = smum_send_msg_to_smc(hwmgr, + PPSMC_MSG_GetSmuVersion, + &hwmgr->smu_version); ++ if (ret) ++ return ret; ++ + /* ACG firmware has major version 5 */ + if ((hwmgr->smu_version & 0xff000000) == 0x5000000) + data->smu_features[GNLD_ACG].supported = true; +@@ -506,10 +509,16 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) + data->smu_features[GNLD_PCC_LIMIT].supported = true; + + /* Get the SN to turn into a Unique ID */ +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32); +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32); ++ if (ret) ++ return ret; ++ ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32); ++ if (ret) ++ return ret; + + adev->unique_id = ((uint64_t)bottom32 << 32) | top32; ++ return 0; + } + + #ifdef PPLIB_VEGA10_EVV_SUPPORT +@@ -883,7 +892,9 @@ static int vega10_hwmgr_backend_init(struct pp_hwmgr *hwmgr) + + vega10_set_features_platform_caps(hwmgr); + +- vega10_init_dpm_defaults(hwmgr); ++ result = vega10_init_dpm_defaults(hwmgr); ++ if (result) ++ return result; + + #ifdef PPLIB_VEGA10_EVV_SUPPORT + /* Get leakage voltage based on leakage ID. */ +@@ -3884,11 +3895,14 @@ static int vega10_get_gpu_power(struct pp_hwmgr *hwmgr, + uint32_t *query) + { + uint32_t value; ++ int ret; + + if (!query) + return -EINVAL; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrPkgPwr, &value); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrPkgPwr, &value); ++ if (ret) ++ return ret; + + /* SMC returning actual watts, keep consistent with legacy asics, low 8 bit as 8 fractional bits */ + *query = value << 8; +@@ -4643,14 +4657,16 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr, + uint32_t gen_speed, lane_width, current_gen_speed, current_lane_width; + PPTable_t *pptable = &(data->smc_state_table.pp_table); + +- int i, now, size = 0, count = 0; ++ int i, ret, now, size = 0, count = 0; + + switch (type) { + case PP_SCLK: + if (data->registry_data.sclk_dpm_key_disabled) + break; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentGfxclkIndex, &now); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentGfxclkIndex, &now); ++ if (ret) ++ break; + + if (hwmgr->pp_one_vf && + (hwmgr->dpm_level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)) +@@ -4666,7 +4682,9 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr, + if (data->registry_data.mclk_dpm_key_disabled) + break; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentUclkIndex, &now); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentUclkIndex, &now); ++ if (ret) ++ break; + + for (i = 0; i < mclk_table->count; i++) + size += sprintf(buf + size, "%d: %uMhz %s\n", +@@ -4677,7 +4695,9 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr, + if (data->registry_data.socclk_dpm_key_disabled) + break; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentSocclkIndex, &now); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetCurrentSocclkIndex, &now); ++ if (ret) ++ break; + + for (i = 0; i < soc_table->count; i++) + size += sprintf(buf + size, "%d: %uMhz %s\n", +@@ -4688,8 +4708,10 @@ static int vega10_print_clock_levels(struct pp_hwmgr *hwmgr, + if (data->registry_data.dcefclk_dpm_key_disabled) + break; + +- smum_send_msg_to_smc_with_parameter(hwmgr, ++ ret = smum_send_msg_to_smc_with_parameter(hwmgr, + PPSMC_MSG_GetClockFreqMHz, CLK_DCEFCLK, &now); ++ if (ret) ++ break; + + for (i = 0; i < dcef_table->count; i++) + size += sprintf(buf + size, "%d: %uMhz %s\n", +diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/vega10_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/vega10_smumgr.c +index a70d73896649..f9c0f117725d 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/vega10_smumgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/vega10_smumgr.c +@@ -130,13 +130,17 @@ int vega10_get_enabled_smc_features(struct pp_hwmgr *hwmgr, + uint64_t *features_enabled) + { + uint32_t enabled_features; ++ int ret; + + if (features_enabled == NULL) + return -EINVAL; + +- smum_send_msg_to_smc(hwmgr, ++ ret = smum_send_msg_to_smc(hwmgr, + PPSMC_MSG_GetEnabledSmuFeatures, + &enabled_features); ++ if (ret) ++ return ret; ++ + *features_enabled = enabled_features; + + return 0; +-- +2.43.0 + diff --git a/queue-5.15/drm-amd-pm-fix-warning-using-uninitialized-value-of-.patch b/queue-5.15/drm-amd-pm-fix-warning-using-uninitialized-value-of-.patch new file mode 100644 index 00000000000..d638b6f1650 --- /dev/null +++ b/queue-5.15/drm-amd-pm-fix-warning-using-uninitialized-value-of-.patch @@ -0,0 +1,41 @@ +From 0b14da14aee579bd4f7c377336745621f8f63746 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 29 Apr 2024 15:26:25 +0800 +Subject: drm/amd/pm: fix warning using uninitialized value of max_vid_step + +From: Jesse Zhang + +[ Upstream commit 17e3bea65cdc453695b2fe4ff26d25d17f5339e9 ] + +Check the return of pp_atomfwctrl_get_Voltage_table_v4 +as it may fail to initialize max_vid_step +V2: change the check condition (Tim Huang) + +Signed-off-by: Jesse Zhang +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +index aba8904ac75f..6a0933a78c9d 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +@@ -2575,8 +2575,11 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr) + } + } + +- pp_atomfwctrl_get_voltage_table_v4(hwmgr, VOLTAGE_TYPE_VDDC, ++ result = pp_atomfwctrl_get_voltage_table_v4(hwmgr, VOLTAGE_TYPE_VDDC, + VOLTAGE_OBJ_SVID2, &voltage_table); ++ PP_ASSERT_WITH_CODE(!result, ++ "Failed to get voltage table!", ++ return result); + pp_table->MaxVidStep = voltage_table.max_vid_step; + + pp_table->GfxDpmVoltageMode = +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-avoid-reading-vf2pf-info-size-from-fb.patch b/queue-5.15/drm-amdgpu-avoid-reading-vf2pf-info-size-from-fb.patch new file mode 100644 index 00000000000..3a47a26d0d9 --- /dev/null +++ b/queue-5.15/drm-amdgpu-avoid-reading-vf2pf-info-size-from-fb.patch @@ -0,0 +1,37 @@ +From f61187bbb779cc04820deb2743be80b1cf5742f5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Apr 2024 16:35:14 -0400 +Subject: drm/amdgpu: avoid reading vf2pf info size from FB + +From: Zhigang Luo + +[ Upstream commit 3bcc0ee14768d886cedff65da72d83d375a31a56 ] + +VF can't access FB when host is doing mode1 reset. Using sizeof to get +vf2pf info size, instead of reading it from vf2pf header stored in FB. + +Signed-off-by: Zhigang Luo +Reviewed-by: Hawking Zhang +Reviewed-by: Lijo Lazar +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +index 8d9bdec2b700..76fc0e8dcf9c 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +@@ -586,7 +586,7 @@ static int amdgpu_virt_write_vf2pf_data(struct amdgpu_device *adev) + + vf2pf_info->checksum = + amd_sriov_msg_checksum( +- vf2pf_info, vf2pf_info->header.size, 0, 0); ++ vf2pf_info, sizeof(*vf2pf_info), 0, 0); + + return 0; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-mc_data-out-of-bounds-read-warning.patch b/queue-5.15/drm-amdgpu-fix-mc_data-out-of-bounds-read-warning.patch new file mode 100644 index 00000000000..7727c06db76 --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-mc_data-out-of-bounds-read-warning.patch @@ -0,0 +1,35 @@ +From dc94abb293c0fb102c57467dff6b6fbb824c236b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 6 May 2024 16:30:01 +0800 +Subject: drm/amdgpu: fix mc_data out-of-bounds read warning + +From: Tim Huang + +[ Upstream commit 51dfc0a4d609fe700750a62f41447f01b8c9ea50 ] + +Clear warning that read mc_data[i-1] may out-of-bounds. + +Signed-off-by: Tim Huang +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +index 96b7bb13a2dd..07b1d2460a85 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +@@ -1475,6 +1475,8 @@ int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev, + (u32)le32_to_cpu(*((u32 *)reg_data + j)); + j++; + } else if ((reg_table->mc_reg_address[i].pre_reg_data & LOW_NIBBLE_MASK) == DATA_EQU_PREV) { ++ if (i == 0) ++ continue; + reg_table->mc_reg_table_entry[num_ranges].mc_data[i] = + reg_table->mc_reg_table_entry[num_ranges].mc_data[i - 1]; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-out-of-bounds-read-of-df_v1_7_channel.patch b/queue-5.15/drm-amdgpu-fix-out-of-bounds-read-of-df_v1_7_channel.patch new file mode 100644 index 00000000000..63b1139a318 --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-out-of-bounds-read-of-df_v1_7_channel.patch @@ -0,0 +1,36 @@ +From 1220d8afe510fde08741959f5b50e411c6118d2f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 7 May 2024 09:29:33 +0800 +Subject: drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number + +From: Ma Jun + +[ Upstream commit d768394fa99467bcf2703bde74ddc96eeb0b71fa ] + +Check the fb_channel_number range to avoid the array out-of-bounds +read error + +Signed-off-by: Ma Jun +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/df_v1_7.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c +index 2d01ac0d4c11..2f5af5ddc5ca 100644 +--- a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c ++++ b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c +@@ -70,6 +70,8 @@ static u32 df_v1_7_get_hbm_channel_number(struct amdgpu_device *adev) + int fb_channel_number; + + fb_channel_number = adev->df.funcs->get_fb_channel_number(adev); ++ if (fb_channel_number >= ARRAY_SIZE(df_v1_7_channel_number)) ++ fb_channel_number = 0; + + return df_v1_7_channel_number[fb_channel_number]; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-out-of-bounds-write-warning.patch b/queue-5.15/drm-amdgpu-fix-out-of-bounds-write-warning.patch new file mode 100644 index 00000000000..b694a158697 --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-out-of-bounds-write-warning.patch @@ -0,0 +1,40 @@ +From 9e116a2c887fc8ac74fdfebdbc4ce2e79bf4462c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 Apr 2024 14:00:17 +0800 +Subject: drm/amdgpu: Fix out-of-bounds write warning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ma Jun + +[ Upstream commit be1684930f5262a622d40ce7a6f1423530d87f89 ] + +Check the ring type value to fix the out-of-bounds +write warning + +Signed-off-by: Ma Jun +Suggested-by: Christian König +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +index 294ad2929485..de05b7f864f2 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +@@ -263,7 +263,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, + ring->max_dw = max_dw; + ring->hw_prio = hw_prio; + +- if (!ring->no_scheduler) { ++ if (!ring->no_scheduler && ring->funcs->type < AMDGPU_HW_IP_NUM) { + hw_ip = ring->funcs->type; + num_sched = &adev->gpu_sched[hw_ip][hw_prio].num_scheds; + adev->gpu_sched[hw_ip][hw_prio].sched[(*num_sched)++] = +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-overflowed-array-index-read-warning.patch b/queue-5.15/drm-amdgpu-fix-overflowed-array-index-read-warning.patch new file mode 100644 index 00000000000..e1d52d40ec3 --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-overflowed-array-index-read-warning.patch @@ -0,0 +1,41 @@ +From 27b88faafd37ede0e4758ccd0576ca93fb387838 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 Apr 2024 13:15:27 +0800 +Subject: drm/amdgpu: fix overflowed array index read warning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Tim Huang + +[ Upstream commit ebbc2ada5c636a6a63d8316a3408753768f5aa9f ] + +Clear overflowed array index read warning by cast operation. + +Signed-off-by: Tim Huang +Reviewed-by: Alex Deucher +Reviewed-by: Christian König +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +index 0554576d3695..294ad2929485 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +@@ -367,8 +367,9 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf, + size_t size, loff_t *pos) + { + struct amdgpu_ring *ring = file_inode(f)->i_private; +- int r, i; + uint32_t value, result, early[3]; ++ loff_t i; ++ int r; + + if (*pos & 3 || size & 3) + return -EINVAL; +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-the-waring-dereferencing-hive.patch b/queue-5.15/drm-amdgpu-fix-the-waring-dereferencing-hive.patch new file mode 100644 index 00000000000..40fd220dbe7 --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-the-waring-dereferencing-hive.patch @@ -0,0 +1,36 @@ +From 320047fec7c475fbc2ac4330e1e04b65c04bd57c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 May 2024 16:20:49 +0800 +Subject: drm/amdgpu: fix the waring dereferencing hive + +From: Jesse Zhang + +[ Upstream commit 1940708ccf5aff76de4e0b399f99267c93a89193 ] + +Check the amdgpu_hive_info *hive that maybe is NULL. + +Signed-off-by: Jesse Zhang +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +index f305a0f8e9b9..a8b7f0aeacf8 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +@@ -1178,6 +1178,9 @@ static void psp_xgmi_reflect_topology_info(struct psp_context *psp, + uint8_t dst_num_links = node_info.num_links; + + hive = amdgpu_get_xgmi_hive(psp->adev); ++ if (WARN_ON(!hive)) ++ return; ++ + list_for_each_entry(mirror_adev, &hive->device_list, gmc.xgmi.head) { + struct psp_xgmi_topology_info *mirror_top_info; + int j; +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-ucode-out-of-bounds-read-warning.patch b/queue-5.15/drm-amdgpu-fix-ucode-out-of-bounds-read-warning.patch new file mode 100644 index 00000000000..b6cd56cd10c --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-ucode-out-of-bounds-read-warning.patch @@ -0,0 +1,36 @@ +From 43811aba0d47b86746fa35ba96b0163b4a6c3156 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 6 May 2024 16:21:00 +0800 +Subject: drm/amdgpu: fix ucode out-of-bounds read warning + +From: Tim Huang + +[ Upstream commit 8944acd0f9db33e17f387fdc75d33bb473d7936f ] + +Clear warning that read ucode[] may out-of-bounds. + +Signed-off-by: Tim Huang +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +index f1a050379190..682de88cf91f 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +@@ -213,6 +213,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, + struct amdgpu_firmware_info *ucode; + + id = fw_type_convert(cgs_device, type); ++ if (id >= AMDGPU_UCODE_ID_MAXIMUM) ++ return -EINVAL; ++ + ucode = &adev->firmware.ucode[id]; + if (ucode->fw == NULL) + return -EINVAL; +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-uninitialized-scalar-variable-warning.patch b/queue-5.15/drm-amdgpu-fix-uninitialized-scalar-variable-warning.patch new file mode 100644 index 00000000000..b4ea3ef0000 --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-uninitialized-scalar-variable-warning.patch @@ -0,0 +1,38 @@ +From e53e215abbf6b780ed7e5074240782586a30a75a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Apr 2024 08:43:30 +0800 +Subject: drm/amdgpu: fix uninitialized scalar variable warning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Tim Huang + +[ Upstream commit 9a5f15d2a29d06ce5bd50919da7221cda92afb69 ] + +Clear warning that uses uninitialized value fw_size. + +Signed-off-by: Tim Huang +Reviewed-by: Christian König +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +index b508126a9738..8d9bdec2b700 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +@@ -410,6 +410,8 @@ static void amdgpu_virt_add_bad_page(struct amdgpu_device *adev, + uint64_t retired_page; + uint32_t bp_idx, bp_cnt; + ++ memset(&bp, 0, sizeof(bp)); ++ + if (bp_block_size) { + bp_cnt = bp_block_size / sizeof(uint64_t); + for (bp_idx = 0; bp_idx < bp_cnt; bp_idx++) { +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-fix-uninitialized-variable-warning-in-amd.patch b/queue-5.15/drm-amdgpu-fix-uninitialized-variable-warning-in-amd.patch new file mode 100644 index 00000000000..e844eb3a85f --- /dev/null +++ b/queue-5.15/drm-amdgpu-fix-uninitialized-variable-warning-in-amd.patch @@ -0,0 +1,35 @@ +From 2fb322a0f20f829334964ccf2c221241d8168fe5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Apr 2024 10:50:54 +0800 +Subject: drm/amdgpu: Fix uninitialized variable warning in amdgpu_afmt_acr + +From: Ma Jun + +[ Upstream commit c0d6bd3cd209419cc46ac49562bef1db65d90e70 ] + +Assign value to clock to fix the warning below: +"Using uninitialized value res. Field res.clock is uninitialized" + +Signed-off-by: Ma Jun +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c +index a4d65973bf7c..80771b1480ff 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.c +@@ -100,6 +100,7 @@ struct amdgpu_afmt_acr amdgpu_afmt_acr(uint32_t clock) + amdgpu_afmt_calc_cts(clock, &res.cts_32khz, &res.n_32khz, 32000); + amdgpu_afmt_calc_cts(clock, &res.cts_44_1khz, &res.n_44_1khz, 44100); + amdgpu_afmt_calc_cts(clock, &res.cts_48khz, &res.n_48khz, 48000); ++ res.clock = clock; + + return res; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-pm-check-input-value-for-custom-profile-m.patch b/queue-5.15/drm-amdgpu-pm-check-input-value-for-custom-profile-m.patch new file mode 100644 index 00000000000..0f90a9ca60e --- /dev/null +++ b/queue-5.15/drm-amdgpu-pm-check-input-value-for-custom-profile-m.patch @@ -0,0 +1,65 @@ +From a9f7f7140460556d9dbeacec799d285fb27ea901 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 10 May 2024 10:05:21 +0800 +Subject: drm/amdgpu/pm: Check input value for CUSTOM profile mode setting on + legacy SOCs + +From: Ma Jun + +[ Upstream commit df0a9bd92fbbd3fcafcb2bce6463c9228a3e6868 ] + +Check the input value for CUSTOM profile mode setting on legacy +SOCs. Otherwise we may use uninitalized value of input[] + +Signed-off-by: Ma Jun +Reviewed-by: Yang Wang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 2 +- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 8 ++++++-- + 2 files changed, 7 insertions(+), 3 deletions(-) + +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 9c7c3c06327d..2d1f37aefdbd 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +@@ -5597,7 +5597,7 @@ static int smu7_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint + mode = input[size]; + switch (mode) { + case PP_SMC_POWER_PROFILE_CUSTOM: +- if (size < 8 && size != 0) ++ if (size != 8 && size != 0) + return -EINVAL; + /* If only CUSTOM is passed in, use the saved values. Check + * that we actually have a CUSTOM profile by ensuring that +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +index b000a213a033..b55a68ce7238 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +@@ -4109,9 +4109,11 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui + if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { + struct vega20_hwmgr *data = + (struct vega20_hwmgr *)(hwmgr->backend); +- if (size == 0 && !data->is_custom_profile_set) ++ ++ if (size != 10 && size != 0) + return -EINVAL; +- if (size < 10 && size != 0) ++ ++ if (size == 0 && !data->is_custom_profile_set) + return -EINVAL; + + result = vega20_get_activity_monitor_coeff(hwmgr, +@@ -4173,6 +4175,8 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, ui + activity_monitor.Fclk_PD_Data_error_coeff = input[8]; + activity_monitor.Fclk_PD_Data_error_rate_coeff = input[9]; + break; ++ default: ++ return -EINVAL; + } + + result = vega20_set_activity_monitor_coeff(hwmgr, +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-pm-check-the-return-value-of-smum_send_ms.patch b/queue-5.15/drm-amdgpu-pm-check-the-return-value-of-smum_send_ms.patch new file mode 100644 index 00000000000..5b0b7b746e5 --- /dev/null +++ b/queue-5.15/drm-amdgpu-pm-check-the-return-value-of-smum_send_ms.patch @@ -0,0 +1,49 @@ +From 0b2eb4e69a38f49d0b0da4610d545424ba0a5a62 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Apr 2024 14:38:04 +0800 +Subject: drm/amdgpu/pm: Check the return value of smum_send_msg_to_smc + +From: Ma Jun + +[ Upstream commit 579f0c21baec9e7506b6bb3f60f0a9b6d07693b4 ] + +Check the return value of smum_send_msg_to_smc, otherwise +we might use an uninitialized variable "now" + +Signed-off-by: Ma Jun +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +index cf74621f94a7..8b46214fc6fe 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +@@ -1026,7 +1026,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr, + + switch (type) { + case PP_SCLK: +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now); ++ if (ret) ++ return ret; + + /* driver only know min/max gfx_clk, Add level 1 for all other gfx clks */ + if (now == data->gfx_max_freq_limit/100) +@@ -1047,7 +1049,9 @@ static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr, + i == 2 ? "*" : ""); + break; + case PP_MCLK: +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now); ++ if (ret) ++ return ret; + + for (i = 0; i < mclk_table->count; i++) + size += sprintf(buf + size, "%d: %uMhz %s\n", +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-pm-fix-uninitialized-variable-agc_btc_res.patch b/queue-5.15/drm-amdgpu-pm-fix-uninitialized-variable-agc_btc_res.patch new file mode 100644 index 00000000000..e32b4e32d74 --- /dev/null +++ b/queue-5.15/drm-amdgpu-pm-fix-uninitialized-variable-agc_btc_res.patch @@ -0,0 +1,50 @@ +From e343a21f5819b14cc813525565afa9518ffb0b80 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 28 Apr 2024 14:41:38 +0800 +Subject: drm/amdgpu/pm: Fix uninitialized variable agc_btc_response + +From: Ma Jun + +[ Upstream commit df4409d8a04dd39d7f2aa0c5f528a56b99eaaa13 ] + +Assign an default value to agc_btc_response in failed case + +Signed-off-by: Ma Jun +Acked-by: Alex Deucher +Reviewed-by: Yang Wang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +index fadceaba031e..81fd79a5fd7d 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +@@ -2365,15 +2365,20 @@ static int vega10_acg_enable(struct pp_hwmgr *hwmgr) + { + struct vega10_hwmgr *data = hwmgr->backend; + uint32_t agc_btc_response; ++ int ret; + + if (data->smu_features[GNLD_ACG].supported) { + if (0 == vega10_enable_smc_features(hwmgr, true, + data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_bitmap)) + data->smu_features[GNLD_DPM_PREFETCHER].enabled = true; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_InitializeAcg, NULL); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_InitializeAcg, NULL); ++ if (ret) ++ return ret; + +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_RunAcgBtc, &agc_btc_response); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_RunAcgBtc, &agc_btc_response); ++ if (ret) ++ agc_btc_response = 0; + + if (1 == agc_btc_response) { + if (1 == data->acg_loop_state) +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-pm-fix-uninitialized-variable-warning-for.patch b/queue-5.15/drm-amdgpu-pm-fix-uninitialized-variable-warning-for.patch new file mode 100644 index 00000000000..d1fa7752ed2 --- /dev/null +++ b/queue-5.15/drm-amdgpu-pm-fix-uninitialized-variable-warning-for.patch @@ -0,0 +1,185 @@ +From 1a4b122bdc92f2270004a46194a2bd0d3737cfa2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Apr 2024 17:46:08 +0800 +Subject: drm/amdgpu/pm: Fix uninitialized variable warning for smu10 + +From: Ma Jun + +[ Upstream commit 336c8f558d596699d3d9814a45600139b2f23f27 ] + +Check return value of smum_send_msg_to_smc to fix +uninitialized variable varning + +Signed-off-by: Ma Jun +Acked-by: Alex Deucher +Reviewed-by: Yang Wang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + .../drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 21 +++++++++++++---- + .../drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c | 20 ++++++++++++---- + .../drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 23 ++++++++++++++----- + 3 files changed, 48 insertions(+), 16 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +index 8b46214fc6fe..0a216b4fd185 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +@@ -1551,7 +1551,10 @@ static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr, + } + + if (input[0] == 0) { +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq); ++ if (ret) ++ return ret; ++ + if (input[1] < min_freq) { + pr_err("Fine grain setting minimum sclk (%ld) MHz is less than the minimum allowed (%d) MHz\n", + input[1], min_freq); +@@ -1559,7 +1562,10 @@ static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr, + } + smu10_data->gfx_actual_soft_min_freq = input[1]; + } else if (input[0] == 1) { +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq); ++ if (ret) ++ return ret; ++ + if (input[1] > max_freq) { + pr_err("Fine grain setting maximum sclk (%ld) MHz is greater than the maximum allowed (%d) MHz\n", + input[1], max_freq); +@@ -1574,10 +1580,15 @@ static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr, + pr_err("Input parameter number not correct\n"); + return -EINVAL; + } +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq); +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq); +- ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq); ++ if (ret) ++ return ret; + smu10_data->gfx_actual_soft_min_freq = min_freq; ++ ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq); ++ if (ret) ++ return ret; ++ + smu10_data->gfx_actual_soft_max_freq = max_freq; + } else if (type == PP_OD_COMMIT_DPM_TABLE) { + if (size != 0) { +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c +index a2f4d6773d45..95ef9419c83e 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c +@@ -294,12 +294,12 @@ static int vega12_set_features_platform_caps(struct pp_hwmgr *hwmgr) + return 0; + } + +-static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr) ++static int vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr) + { + struct vega12_hwmgr *data = (struct vega12_hwmgr *)(hwmgr->backend); + struct amdgpu_device *adev = hwmgr->adev; + uint32_t top32, bottom32; +- int i; ++ int i, ret; + + data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id = + FEATURE_DPM_PREFETCHER_BIT; +@@ -365,10 +365,16 @@ static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr) + } + + /* Get the SN to turn into a Unique ID */ +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32); +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32); ++ if (ret) ++ return ret; ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32); ++ if (ret) ++ return ret; + + adev->unique_id = ((uint64_t)bottom32 << 32) | top32; ++ ++ return 0; + } + + static int vega12_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr) +@@ -411,7 +417,11 @@ static int vega12_hwmgr_backend_init(struct pp_hwmgr *hwmgr) + + vega12_set_features_platform_caps(hwmgr); + +- vega12_init_dpm_defaults(hwmgr); ++ result = vega12_init_dpm_defaults(hwmgr); ++ if (result) { ++ pr_err("%s failed\n", __func__); ++ return result; ++ } + + /* Parse pptable data read from VBIOS */ + vega12_set_private_data_based_on_pptable(hwmgr); +diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +index 299b5c838bf7..b000a213a033 100644 +--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c ++++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +@@ -329,12 +329,12 @@ static int vega20_set_features_platform_caps(struct pp_hwmgr *hwmgr) + return 0; + } + +-static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr) ++static int vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr) + { + struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); + struct amdgpu_device *adev = hwmgr->adev; + uint32_t top32, bottom32; +- int i; ++ int i, ret; + + data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id = + FEATURE_DPM_PREFETCHER_BIT; +@@ -405,10 +405,17 @@ static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr) + } + + /* Get the SN to turn into a Unique ID */ +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32); +- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32); ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32); ++ if (ret) ++ return ret; ++ ++ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32); ++ if (ret) ++ return ret; + + adev->unique_id = ((uint64_t)bottom32 << 32) | top32; ++ ++ return 0; + } + + static int vega20_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr) +@@ -428,6 +435,7 @@ static int vega20_hwmgr_backend_init(struct pp_hwmgr *hwmgr) + { + struct vega20_hwmgr *data; + struct amdgpu_device *adev = hwmgr->adev; ++ int result; + + data = kzalloc(sizeof(struct vega20_hwmgr), GFP_KERNEL); + if (data == NULL) +@@ -453,8 +461,11 @@ static int vega20_hwmgr_backend_init(struct pp_hwmgr *hwmgr) + + vega20_set_features_platform_caps(hwmgr); + +- vega20_init_dpm_defaults(hwmgr); +- ++ result = vega20_init_dpm_defaults(hwmgr); ++ if (result) { ++ pr_err("%s failed\n", __func__); ++ return result; ++ } + /* Parse pptable data read from VBIOS */ + vega20_set_private_data_based_on_pptable(hwmgr); + +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-the-warning-dereferencing-obj-for-nbio_v7.patch b/queue-5.15/drm-amdgpu-the-warning-dereferencing-obj-for-nbio_v7.patch new file mode 100644 index 00000000000..d4ecb4f3193 --- /dev/null +++ b/queue-5.15/drm-amdgpu-the-warning-dereferencing-obj-for-nbio_v7.patch @@ -0,0 +1,36 @@ +From 5b57eccafe4219f4d4de8a6ac7b1c97db3fe159f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 13 May 2024 15:22:42 +0800 +Subject: drm/amdgpu: the warning dereferencing obj for nbio_v7_4 + +From: Jesse Zhang + +[ Upstream commit d190b459b2a4304307c3468ed97477b808381011 ] + +if ras_manager obj null, don't print NBIO err data + +Signed-off-by: Jesse Zhang +Suggested-by: Tim Huang +Reviewed-by: Tim Huang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +index 74cd7543729b..af1ca5cbc2fa 100644 +--- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c ++++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +@@ -370,7 +370,7 @@ static void nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device + else + WREG32_SOC15(NBIO, 0, mmBIF_DOORBELL_INT_CNTL, bif_doorbell_intr_cntl); + +- if (!ras->disable_ras_err_cnt_harvest) { ++ if (ras && !ras->disable_ras_err_cnt_harvest && obj) { + /* + * clear error status after ras_controller_intr + * according to hw team and count ue number +-- +2.43.0 + diff --git a/queue-5.15/drm-amdgpu-update-type-of-buf-size-to-u32-for-eeprom.patch b/queue-5.15/drm-amdgpu-update-type-of-buf-size-to-u32-for-eeprom.patch new file mode 100644 index 00000000000..39d8514dbea --- /dev/null +++ b/queue-5.15/drm-amdgpu-update-type-of-buf-size-to-u32-for-eeprom.patch @@ -0,0 +1,71 @@ +From c9c43e302028069648fae5dece45a987ba4e810e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 17 May 2024 18:04:26 +0800 +Subject: drm/amdgpu: update type of buf size to u32 for eeprom functions + +From: Tao Zhou + +[ Upstream commit 2aadb520bfacec12527effce3566f8df55e5d08e ] + +Avoid overflow issue. + +Signed-off-by: Tao Zhou +Reviewed-by: Yang Wang +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 6 +++--- + drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +index 4d9eb0137f8c..48652c2a17cc 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c +@@ -177,7 +177,7 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr, + * Returns the number of bytes read/written; -errno on error. + */ + static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr, +- u8 *eeprom_buf, u16 buf_size, bool read) ++ u8 *eeprom_buf, u32 buf_size, bool read) + { + const struct i2c_adapter_quirks *quirks = i2c_adap->quirks; + u16 limit; +@@ -224,7 +224,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr, + + int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap, + u32 eeprom_addr, u8 *eeprom_buf, +- u16 bytes) ++ u32 bytes) + { + return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes, + true); +@@ -232,7 +232,7 @@ int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap, + + int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap, + u32 eeprom_addr, u8 *eeprom_buf, +- u16 bytes) ++ u32 bytes) + { + return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes, + false); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h +index 6935adb2be1f..8083b8253ef4 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h +@@ -28,10 +28,10 @@ + + int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap, + u32 eeprom_addr, u8 *eeprom_buf, +- u16 bytes); ++ u32 bytes); + + int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap, + u32 eeprom_addr, u8 *eeprom_buf, +- u16 bytes); ++ u32 bytes); + + #endif +-- +2.43.0 + diff --git a/queue-5.15/drm-amdkfd-reconcile-the-definition-and-use-of-oem_i.patch b/queue-5.15/drm-amdkfd-reconcile-the-definition-and-use-of-oem_i.patch new file mode 100644 index 00000000000..4993e0413d0 --- /dev/null +++ b/queue-5.15/drm-amdkfd-reconcile-the-definition-and-use-of-oem_i.patch @@ -0,0 +1,71 @@ +From e65d1ef03e671b2bc445c0c99ce61b1d4c398be8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 May 2024 15:31:08 -0400 +Subject: drm/amdkfd: Reconcile the definition and use of oem_id in struct + kfd_topology_device + +From: Michael Chen + +[ Upstream commit 10f624ef239bd136cdcc5bbc626157a57b938a31 ] + +Currently oem_id is defined as uint8_t[6] and casted to uint64_t* +in some use case. This would lead code scanner to complain about +access beyond. Re-define it in union to enforce 8-byte size and +alignment to avoid potential issue. + +Signed-off-by: Michael Chen +Reviewed-by: Felix Kuehling +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 -- + drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +-- + drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 5 ++++- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h +index d54ceebd346b..30c70b3ab17f 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h +@@ -42,8 +42,6 @@ + #define CRAT_OEMTABLEID_LENGTH 8 + #define CRAT_RESERVED_LENGTH 6 + +-#define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1) +- + /* Compute Unit flags */ + #define COMPUTE_UNIT_CPU (1 << 0) /* Create Virtual CRAT for CPU */ + #define COMPUTE_UNIT_GPU (1 << 1) /* Create Virtual CRAT for GPU */ +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +index 98cca5f2b27f..59e7ca0e8470 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +@@ -910,8 +910,7 @@ static void kfd_update_system_properties(void) + dev = list_last_entry(&topology_device_list, + struct kfd_topology_device, list); + if (dev) { +- sys_props.platform_id = +- (*((uint64_t *)dev->oem_id)) & CRAT_OEMID_64BIT_MASK; ++ sys_props.platform_id = dev->oem_id64; + sys_props.platform_oem = *((uint64_t *)dev->oem_table_id); + sys_props.platform_rev = dev->oem_revision; + } +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h +index a8db017c9b8e..c2dbd75b9161 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h +@@ -184,7 +184,10 @@ struct kfd_topology_device { + struct attribute attr_gpuid; + struct attribute attr_name; + struct attribute attr_props; +- uint8_t oem_id[CRAT_OEMID_LENGTH]; ++ union { ++ uint8_t oem_id[CRAT_OEMID_LENGTH]; ++ uint64_t oem_id64; ++ }; + uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH]; + uint32_t oem_revision; + }; +-- +2.43.0 + diff --git a/queue-5.15/drm-bridge-tc358767-check-if-fully-initialized-befor.patch b/queue-5.15/drm-bridge-tc358767-check-if-fully-initialized-befor.patch new file mode 100644 index 00000000000..12d48151a8c --- /dev/null +++ b/queue-5.15/drm-bridge-tc358767-check-if-fully-initialized-befor.patch @@ -0,0 +1,39 @@ +From 6a4ebef8f0fc5a6b8968355f7625e0b27171ce78 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 31 May 2024 22:33:12 +0200 +Subject: drm/bridge: tc358767: Check if fully initialized before signalling + HPD event via IRQ + +From: Marek Vasut + +[ Upstream commit 162e48cb1d84c2c966b649b8ac5c9d4f75f6d44f ] + +Make sure the connector is fully initialized before signalling any +HPD events via drm_kms_helper_hotplug_event(), otherwise this may +lead to NULL pointer dereference. + +Signed-off-by: Marek Vasut +Reviewed-by: Robert Foss +Signed-off-by: Robert Foss +Link: https://patchwork.freedesktop.org/patch/msgid/20240531203333.277476-1-marex@denx.de +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/bridge/tc358767.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c +index 4c6f3052156b..3436d39c90b4 100644 +--- a/drivers/gpu/drm/bridge/tc358767.c ++++ b/drivers/gpu/drm/bridge/tc358767.c +@@ -1527,7 +1527,7 @@ static irqreturn_t tc_irq_handler(int irq, void *arg) + dev_err(tc->dev, "syserr %x\n", stat); + } + +- if (tc->hpd_pin >= 0 && tc->bridge.dev) { ++ if (tc->hpd_pin >= 0 && tc->bridge.dev && tc->aux.drm_dev) { + /* + * H is triggered when the GPIO goes high. + * +-- +2.43.0 + diff --git a/queue-5.15/drm-drm-bridge-drop-conditionals-around-of_node-poin.patch b/queue-5.15/drm-drm-bridge-drop-conditionals-around-of_node-poin.patch new file mode 100644 index 00000000000..54e26233e6a --- /dev/null +++ b/queue-5.15/drm-drm-bridge-drop-conditionals-around-of_node-poin.patch @@ -0,0 +1,47 @@ +From 94cb9d558173ecebcbee756b0f2f0fb89a3cf7bc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 May 2024 02:00:00 +0800 +Subject: drm/drm-bridge: Drop conditionals around of_node pointers + +From: Sui Jingfeng + +[ Upstream commit ad3323a6ccb7d43bbeeaa46d5311c43d5d361fc7 ] + +Having conditional around the of_node pointer of the drm_bridge structure +is not necessary, since drm_bridge structure always has the of_node as its +member. + +Let's drop the conditional to get a better looks, please also note that +this is following the already accepted commitments. see commit d8dfccde2709 +("drm/bridge: Drop conditionals around of_node pointers") for reference. + +Signed-off-by: Sui Jingfeng +Reviewed-by: Laurent Pinchart +Signed-off-by: Robert Foss +Link: https://patchwork.freedesktop.org/patch/msgid/20240507180001.1358816-1-sui.jingfeng@linux.dev +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/drm_bridge.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c +index 78bc315b0b73..08bee5fc2c5d 100644 +--- a/drivers/gpu/drm/drm_bridge.c ++++ b/drivers/gpu/drm/drm_bridge.c +@@ -226,13 +226,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, + bridge->encoder = NULL; + list_del(&bridge->chain_node); + +-#ifdef CONFIG_OF + DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n", + bridge->of_node, encoder->name, ret); +-#else +- DRM_ERROR("failed to attach bridge to encoder %s: %d\n", +- encoder->name, ret); +-#endif + + return ret; + } +-- +2.43.0 + diff --git a/queue-5.15/drm-meson-plane-add-error-handling.patch b/queue-5.15/drm-meson-plane-add-error-handling.patch new file mode 100644 index 00000000000..de030acc755 --- /dev/null +++ b/queue-5.15/drm-meson-plane-add-error-handling.patch @@ -0,0 +1,63 @@ +From d058ebc85b4a0a126cf917435a3eb68f51875fd5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Nov 2023 03:34:05 -0800 +Subject: drm/meson: plane: Add error handling + +From: Haoran Liu + +[ Upstream commit 3c28b239620e249b68beeca17f429e317fa6b8d4 ] + +This patch adds robust error handling to the meson_plane_create +function in drivers/gpu/drm/meson/meson_plane.c. The function +previously lacked proper handling for potential failure scenarios +of the drm_universal_plane_init call. + +Signed-off-by: Haoran Liu +Reviewed-by: Neil Armstrong +Link: https://lore.kernel.org/r/20231129113405.33057-1-liuhaoran14@163.com +[narmstrong: fixe the commit subject] +Signed-off-by: Neil Armstrong +Link: https://patchwork.freedesktop.org/patch/msgid/20231129113405.33057-1-liuhaoran14@163.com +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/meson/meson_plane.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c +index 44aa52629443..c17abaf9b54d 100644 +--- a/drivers/gpu/drm/meson/meson_plane.c ++++ b/drivers/gpu/drm/meson/meson_plane.c +@@ -533,6 +533,7 @@ int meson_plane_create(struct meson_drm *priv) + struct meson_plane *meson_plane; + struct drm_plane *plane; + const uint64_t *format_modifiers = format_modifiers_default; ++ int ret; + + meson_plane = devm_kzalloc(priv->drm->dev, sizeof(*meson_plane), + GFP_KERNEL); +@@ -547,12 +548,16 @@ int meson_plane_create(struct meson_drm *priv) + else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) + format_modifiers = format_modifiers_afbc_g12a; + +- drm_universal_plane_init(priv->drm, plane, 0xFF, +- &meson_plane_funcs, +- supported_drm_formats, +- ARRAY_SIZE(supported_drm_formats), +- format_modifiers, +- DRM_PLANE_TYPE_PRIMARY, "meson_primary_plane"); ++ ret = drm_universal_plane_init(priv->drm, plane, 0xFF, ++ &meson_plane_funcs, ++ supported_drm_formats, ++ ARRAY_SIZE(supported_drm_formats), ++ format_modifiers, ++ DRM_PLANE_TYPE_PRIMARY, "meson_primary_plane"); ++ if (ret) { ++ devm_kfree(priv->drm->dev, meson_plane); ++ return ret; ++ } + + drm_plane_helper_add(plane, &meson_plane_helper_funcs); + +-- +2.43.0 + diff --git a/queue-5.15/fsnotify-clear-parent_watched-flags-lazily.patch b/queue-5.15/fsnotify-clear-parent_watched-flags-lazily.patch new file mode 100644 index 00000000000..8a8be81c038 --- /dev/null +++ b/queue-5.15/fsnotify-clear-parent_watched-flags-lazily.patch @@ -0,0 +1,208 @@ +From 16218c71c9772a38dff6334ed8867abbd201ce66 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 12 May 2024 13:30:07 +0200 +Subject: fsnotify: clear PARENT_WATCHED flags lazily + +From: Amir Goldstein + +[ Upstream commit 172e422ffea20a89bfdc672741c1aad6fbb5044e ] + +In some setups directories can have many (usually negative) dentries. +Hence __fsnotify_update_child_dentry_flags() function can take a +significant amount of time. Since the bulk of this function happens +under inode->i_lock this causes a significant contention on the lock +when we remove the watch from the directory as the +__fsnotify_update_child_dentry_flags() call from fsnotify_recalc_mask() +races with __fsnotify_update_child_dentry_flags() calls from +__fsnotify_parent() happening on children. This can lead upto softlockup +reports reported by users. + +Fix the problem by calling fsnotify_update_children_dentry_flags() to +set PARENT_WATCHED flags only when parent starts watching children. + +When parent stops watching children, clear false positive PARENT_WATCHED +flags lazily in __fsnotify_parent() for each accessed child. + +Suggested-by: Jan Kara +Signed-off-by: Amir Goldstein +Signed-off-by: Stephen Brennan +Signed-off-by: Jan Kara +Signed-off-by: Sasha Levin +--- + fs/notify/fsnotify.c | 31 +++++++++++++++++++++---------- + fs/notify/fsnotify.h | 2 +- + fs/notify/mark.c | 32 +++++++++++++++++++++++++++++--- + include/linux/fsnotify_backend.h | 8 +++++--- + 4 files changed, 56 insertions(+), 17 deletions(-) + +diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c +index 7974e91ffe13..b5d8f238fce4 100644 +--- a/fs/notify/fsnotify.c ++++ b/fs/notify/fsnotify.c +@@ -103,17 +103,13 @@ void fsnotify_sb_delete(struct super_block *sb) + * parent cares. Thus when an event happens on a child it can quickly tell + * if there is a need to find a parent and send the event to the parent. + */ +-void __fsnotify_update_child_dentry_flags(struct inode *inode) ++void fsnotify_set_children_dentry_flags(struct inode *inode) + { + struct dentry *alias; +- int watched; + + if (!S_ISDIR(inode->i_mode)) + return; + +- /* determine if the children should tell inode about their events */ +- watched = fsnotify_inode_watches_children(inode); +- + spin_lock(&inode->i_lock); + /* run all of the dentries associated with this inode. Since this is a + * directory, there damn well better only be one item on this list */ +@@ -129,10 +125,7 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode) + continue; + + spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED); +- if (watched) +- child->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; +- else +- child->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED; ++ child->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; + spin_unlock(&child->d_lock); + } + spin_unlock(&alias->d_lock); +@@ -140,6 +133,24 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode) + spin_unlock(&inode->i_lock); + } + ++/* ++ * Lazily clear false positive PARENT_WATCHED flag for child whose parent had ++ * stopped watching children. ++ */ ++static void fsnotify_clear_child_dentry_flag(struct inode *pinode, ++ struct dentry *dentry) ++{ ++ spin_lock(&dentry->d_lock); ++ /* ++ * d_lock is a sufficient barrier to prevent observing a non-watched ++ * parent state from before the fsnotify_set_children_dentry_flags() ++ * or fsnotify_update_flags() call that had set PARENT_WATCHED. ++ */ ++ if (!fsnotify_inode_watches_children(pinode)) ++ dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED; ++ spin_unlock(&dentry->d_lock); ++} ++ + /* Are inode/sb/mount interested in parent and name info with this event? */ + static bool fsnotify_event_needs_parent(struct inode *inode, struct mount *mnt, + __u32 mask) +@@ -208,7 +219,7 @@ int __fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data, + p_inode = parent->d_inode; + p_mask = fsnotify_inode_watches_children(p_inode); + if (unlikely(parent_watched && !p_mask)) +- __fsnotify_update_child_dentry_flags(p_inode); ++ fsnotify_clear_child_dentry_flag(p_inode, dentry); + + /* + * Include parent/name in notification either if some notification +diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h +index fde74eb333cc..2b4267de86e6 100644 +--- a/fs/notify/fsnotify.h ++++ b/fs/notify/fsnotify.h +@@ -74,7 +74,7 @@ static inline void fsnotify_clear_marks_by_sb(struct super_block *sb) + * update the dentry->d_flags of all of inode's children to indicate if inode cares + * about events that happen to its children. + */ +-extern void __fsnotify_update_child_dentry_flags(struct inode *inode); ++extern void fsnotify_set_children_dentry_flags(struct inode *inode); + + extern struct kmem_cache *fsnotify_mark_connector_cachep; + +diff --git a/fs/notify/mark.c b/fs/notify/mark.c +index c74ef947447d..4be6e883d492 100644 +--- a/fs/notify/mark.c ++++ b/fs/notify/mark.c +@@ -176,6 +176,24 @@ static void *__fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) + return fsnotify_update_iref(conn, want_iref); + } + ++static bool fsnotify_conn_watches_children( ++ struct fsnotify_mark_connector *conn) ++{ ++ if (conn->type != FSNOTIFY_OBJ_TYPE_INODE) ++ return false; ++ ++ return fsnotify_inode_watches_children(fsnotify_conn_inode(conn)); ++} ++ ++static void fsnotify_conn_set_children_dentry_flags( ++ struct fsnotify_mark_connector *conn) ++{ ++ if (conn->type != FSNOTIFY_OBJ_TYPE_INODE) ++ return; ++ ++ fsnotify_set_children_dentry_flags(fsnotify_conn_inode(conn)); ++} ++ + /* + * Calculate mask of events for a list of marks. The caller must make sure + * connector and connector->obj cannot disappear under us. Callers achieve +@@ -184,15 +202,23 @@ static void *__fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) + */ + void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) + { ++ bool update_children; ++ + if (!conn) + return; + + spin_lock(&conn->lock); ++ update_children = !fsnotify_conn_watches_children(conn); + __fsnotify_recalc_mask(conn); ++ update_children &= fsnotify_conn_watches_children(conn); + spin_unlock(&conn->lock); +- if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) +- __fsnotify_update_child_dentry_flags( +- fsnotify_conn_inode(conn)); ++ /* ++ * Set children's PARENT_WATCHED flags only if parent started watching. ++ * When parent stops watching, we clear false positive PARENT_WATCHED ++ * flags lazily in __fsnotify_parent(). ++ */ ++ if (update_children) ++ fsnotify_conn_set_children_dentry_flags(conn); + } + + /* Free all connectors queued for freeing once SRCU period ends */ +diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h +index d7d96c806bff..096b79e4373f 100644 +--- a/include/linux/fsnotify_backend.h ++++ b/include/linux/fsnotify_backend.h +@@ -563,12 +563,14 @@ static inline __u32 fsnotify_parent_needed_mask(__u32 mask) + + static inline int fsnotify_inode_watches_children(struct inode *inode) + { ++ __u32 parent_mask = READ_ONCE(inode->i_fsnotify_mask); ++ + /* FS_EVENT_ON_CHILD is set if the inode may care */ +- if (!(inode->i_fsnotify_mask & FS_EVENT_ON_CHILD)) ++ if (!(parent_mask & FS_EVENT_ON_CHILD)) + return 0; + /* this inode might care about child events, does it care about the + * specific set of events that can happen on a child? */ +- return inode->i_fsnotify_mask & FS_EVENTS_POSS_ON_CHILD; ++ return parent_mask & FS_EVENTS_POSS_ON_CHILD; + } + + /* +@@ -582,7 +584,7 @@ static inline void fsnotify_update_flags(struct dentry *dentry) + /* + * Serialisation of setting PARENT_WATCHED on the dentries is provided + * by d_lock. If inotify_inode_watched changes after we have taken +- * d_lock, the following __fsnotify_update_child_dentry_flags call will ++ * d_lock, the following fsnotify_set_children_dentry_flags call will + * find our entry, so it will spin until we complete here, and update + * us with the new state. + */ +-- +2.43.0 + diff --git a/queue-5.15/hwspinlock-introduce-hwspin_lock_bust.patch b/queue-5.15/hwspinlock-introduce-hwspin_lock_bust.patch new file mode 100644 index 00000000000..87078c577e7 --- /dev/null +++ b/queue-5.15/hwspinlock-introduce-hwspin_lock_bust.patch @@ -0,0 +1,137 @@ +From ac5858e562a6fc800ec02e17139594b08c3a74a6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 May 2024 11:09:55 -0700 +Subject: hwspinlock: Introduce hwspin_lock_bust() + +From: Richard Maina + +[ Upstream commit 7c327d56597d8de1680cf24e956b704270d3d84a ] + +When a remoteproc crashes or goes down unexpectedly this can result in +a state where locks held by the remoteproc will remain locked possibly +resulting in deadlock. This new API hwspin_lock_bust() allows +hwspinlock implementers to define a bust operation for freeing previously +acquired hwspinlocks after verifying ownership of the acquired lock. + +Signed-off-by: Richard Maina +Reviewed-by: Bjorn Andersson +Signed-off-by: Chris Lew +Link: https://lore.kernel.org/r/20240529-hwspinlock-bust-v3-1-c8b924ffa5a2@quicinc.com +Signed-off-by: Bjorn Andersson +Signed-off-by: Sasha Levin +--- + Documentation/locking/hwspinlock.rst | 11 ++++++++++ + drivers/hwspinlock/hwspinlock_core.c | 28 ++++++++++++++++++++++++ + drivers/hwspinlock/hwspinlock_internal.h | 3 +++ + include/linux/hwspinlock.h | 6 +++++ + 4 files changed, 48 insertions(+) + +diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/hwspinlock.rst +index 6f03713b7003..2ffaa3cbd63f 100644 +--- a/Documentation/locking/hwspinlock.rst ++++ b/Documentation/locking/hwspinlock.rst +@@ -85,6 +85,17 @@ is already free). + + Should be called from a process context (might sleep). + ++:: ++ ++ int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id); ++ ++After verifying the owner of the hwspinlock, release a previously acquired ++hwspinlock; returns 0 on success, or an appropriate error code on failure ++(e.g. -EOPNOTSUPP if the bust operation is not defined for the specific ++hwspinlock). ++ ++Should be called from a process context (might sleep). ++ + :: + + int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout); +diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c +index fd5f5c5a5244..425597151dd3 100644 +--- a/drivers/hwspinlock/hwspinlock_core.c ++++ b/drivers/hwspinlock/hwspinlock_core.c +@@ -302,6 +302,34 @@ void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) + } + EXPORT_SYMBOL_GPL(__hwspin_unlock); + ++/** ++ * hwspin_lock_bust() - bust a specific hwspinlock ++ * @hwlock: a previously-acquired hwspinlock which we want to bust ++ * @id: identifier of the remote lock holder, if applicable ++ * ++ * This function will bust a hwspinlock that was previously acquired as ++ * long as the current owner of the lock matches the id given by the caller. ++ * ++ * Context: Process context. ++ * ++ * Returns: 0 on success, or -EINVAL if the hwspinlock does not exist, or ++ * the bust operation fails, and -EOPNOTSUPP if the bust operation is not ++ * defined for the hwspinlock. ++ */ ++int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id) ++{ ++ if (WARN_ON(!hwlock)) ++ return -EINVAL; ++ ++ if (!hwlock->bank->ops->bust) { ++ pr_err("bust operation not defined\n"); ++ return -EOPNOTSUPP; ++ } ++ ++ return hwlock->bank->ops->bust(hwlock, id); ++} ++EXPORT_SYMBOL_GPL(hwspin_lock_bust); ++ + /** + * of_hwspin_lock_simple_xlate - translate hwlock_spec to return a lock id + * @bank: the hwspinlock device bank +diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/hwspinlock_internal.h +index 29892767bb7a..f298fc0ee5ad 100644 +--- a/drivers/hwspinlock/hwspinlock_internal.h ++++ b/drivers/hwspinlock/hwspinlock_internal.h +@@ -21,6 +21,8 @@ struct hwspinlock_device; + * @trylock: make a single attempt to take the lock. returns 0 on + * failure and true on success. may _not_ sleep. + * @unlock: release the lock. always succeed. may _not_ sleep. ++ * @bust: optional, platform-specific bust handler, called by hwspinlock ++ * core to bust a specific lock. + * @relax: optional, platform-specific relax handler, called by hwspinlock + * core while spinning on a lock, between two successive + * invocations of @trylock. may _not_ sleep. +@@ -28,6 +30,7 @@ struct hwspinlock_device; + struct hwspinlock_ops { + int (*trylock)(struct hwspinlock *lock); + void (*unlock)(struct hwspinlock *lock); ++ int (*bust)(struct hwspinlock *lock, unsigned int id); + void (*relax)(struct hwspinlock *lock); + }; + +diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h +index bfe7c1f1ac6d..f0231dbc4777 100644 +--- a/include/linux/hwspinlock.h ++++ b/include/linux/hwspinlock.h +@@ -68,6 +68,7 @@ int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int, + int __hwspin_trylock(struct hwspinlock *, int, unsigned long *); + void __hwspin_unlock(struct hwspinlock *, int, unsigned long *); + int of_hwspin_lock_get_id_byname(struct device_node *np, const char *name); ++int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id); + int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); + struct hwspinlock *devm_hwspin_lock_request(struct device *dev); + struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, +@@ -127,6 +128,11 @@ void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) + { + } + ++static inline int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id) ++{ ++ return 0; ++} ++ + static inline int of_hwspin_lock_get_id(struct device_node *np, int index) + { + return 0; +-- +2.43.0 + diff --git a/queue-5.15/ionic-fix-potential-irq-name-truncation.patch b/queue-5.15/ionic-fix-potential-irq-name-truncation.patch new file mode 100644 index 00000000000..e60a47487a7 --- /dev/null +++ b/queue-5.15/ionic-fix-potential-irq-name-truncation.patch @@ -0,0 +1,38 @@ +From ca77b9d728492655e802014169f492667381df83 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 28 May 2024 17:02:53 -0700 +Subject: ionic: fix potential irq name truncation + +From: Shannon Nelson + +[ Upstream commit 3eb76e71b16e8ba5277bf97617aef51f5e64dbe4 ] + +Address a warning about potential string truncation based on the +string buffer sizes. We can add some hints to the string format +specifier to set limits on the resulting possible string to +squelch the complaints. + +Signed-off-by: Shannon Nelson +Link: https://lore.kernel.org/r/20240529000259.25775-2-shannon.nelson@amd.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/pensando/ionic/ionic_lif.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c +index b791fba82c2f..910d8973a4b0 100644 +--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c ++++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c +@@ -221,7 +221,7 @@ static int ionic_request_irq(struct ionic_lif *lif, struct ionic_qcq *qcq) + name = dev_name(dev); + + snprintf(intr->name, sizeof(intr->name), +- "%s-%s-%s", IONIC_DRV_NAME, name, q->name); ++ "%.5s-%.16s-%.8s", IONIC_DRV_NAME, name, q->name); + + return devm_request_irq(dev, intr->vector, ionic_isr, + 0, intr->name, &qcq->napi); +-- +2.43.0 + diff --git a/queue-5.15/media-uvcvideo-enforce-alignment-of-frame-and-interv.patch b/queue-5.15/media-uvcvideo-enforce-alignment-of-frame-and-interv.patch new file mode 100644 index 00000000000..a30a78daa97 --- /dev/null +++ b/queue-5.15/media-uvcvideo-enforce-alignment-of-frame-and-interv.patch @@ -0,0 +1,68 @@ +From f8c2a65ecc297a9652be744b5c551e16e1b14ee7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Apr 2024 17:56:18 +0000 +Subject: media: uvcvideo: Enforce alignment of frame and interval + +From: Ricardo Ribalda + +[ Upstream commit c8931ef55bd325052ec496f242aea7f6de47dc9c ] + +Struct uvc_frame and interval (u32*) are packaged together on +streaming->formats on a single contiguous allocation. + +Right now they are allocated right after uvc_format, without taking into +consideration their required alignment. + +This is working fine because both structures have a field with a +pointer, but it will stop working when the sizeof() of any of those +structs is not a multiple of the sizeof(void*). + +Enforce that alignment during the allocation. + +Signed-off-by: Ricardo Ribalda +Reviewed-by: Laurent Pinchart +Link: https://lore.kernel.org/r/20240404-uvc-align-v2-1-9e104b0ecfbd@chromium.org +Signed-off-by: Laurent Pinchart +Signed-off-by: Sasha Levin +--- + drivers/media/usb/uvc/uvc_driver.c | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c +index b19c75a6f595..ef5788899503 100644 +--- a/drivers/media/usb/uvc/uvc_driver.c ++++ b/drivers/media/usb/uvc/uvc_driver.c +@@ -936,16 +936,26 @@ static int uvc_parse_streaming(struct uvc_device *dev, + goto error; + } + +- size = nformats * sizeof(*format) + nframes * sizeof(*frame) ++ /* ++ * Allocate memory for the formats, the frames and the intervals, ++ * plus any required padding to guarantee that everything has the ++ * correct alignment. ++ */ ++ size = nformats * sizeof(*format); ++ size = ALIGN(size, __alignof__(*frame)) + nframes * sizeof(*frame); ++ size = ALIGN(size, __alignof__(*interval)) + + nintervals * sizeof(*interval); ++ + format = kzalloc(size, GFP_KERNEL); +- if (format == NULL) { ++ if (!format) { + ret = -ENOMEM; + goto error; + } + +- frame = (struct uvc_frame *)&format[nformats]; +- interval = (u32 *)&frame[nframes]; ++ frame = (void *)format + nformats * sizeof(*format); ++ frame = PTR_ALIGN(frame, __alignof__(*frame)); ++ interval = (void *)frame + nframes * sizeof(*frame); ++ interval = PTR_ALIGN(interval, __alignof__(*interval)); + + streaming->format = format; + streaming->nformats = 0; +-- +2.43.0 + diff --git a/queue-5.15/pci-al-check-ioresource_bus-existence-during-probe.patch b/queue-5.15/pci-al-check-ioresource_bus-existence-during-probe.patch new file mode 100644 index 00000000000..bb553ee377f --- /dev/null +++ b/queue-5.15/pci-al-check-ioresource_bus-existence-during-probe.patch @@ -0,0 +1,85 @@ +From d1108fe6ee55b4447aae19b1d410680e4bca705f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 May 2024 15:57:05 +0300 +Subject: PCI: al: Check IORESOURCE_BUS existence during probe +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Aleksandr Mishin + +[ Upstream commit a9927c2cac6e9831361e43a14d91277818154e6a ] + +If IORESOURCE_BUS is not provided in Device Tree it will be fabricated in +of_pci_parse_bus_range(), so NULL pointer dereference should not happen +here. + +But that's hard to verify, so check for NULL anyway. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Link: https://lore.kernel.org/linux-pci/20240503125705.46055-1-amishin@t-argos.ru +Suggested-by: Bjorn Helgaas +Signed-off-by: Aleksandr Mishin +Signed-off-by: Krzysztof Wilczyński +[bhelgaas: commit log] +Signed-off-by: Bjorn Helgaas +Signed-off-by: Sasha Levin +--- + drivers/pci/controller/dwc/pcie-al.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c +index e8afa50129a8..60a0d59a533f 100644 +--- a/drivers/pci/controller/dwc/pcie-al.c ++++ b/drivers/pci/controller/dwc/pcie-al.c +@@ -242,18 +242,24 @@ static struct pci_ops al_child_pci_ops = { + .write = pci_generic_config_write, + }; + +-static void al_pcie_config_prepare(struct al_pcie *pcie) ++static int al_pcie_config_prepare(struct al_pcie *pcie) + { + struct al_pcie_target_bus_cfg *target_bus_cfg; + struct pcie_port *pp = &pcie->pci->pp; + unsigned int ecam_bus_mask; ++ struct resource_entry *ft; + u32 cfg_control_offset; ++ struct resource *bus; + u8 subordinate_bus; + u8 secondary_bus; + u32 cfg_control; + u32 reg; +- struct resource *bus = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS)->res; + ++ ft = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS); ++ if (!ft) ++ return -ENODEV; ++ ++ bus = ft->res; + target_bus_cfg = &pcie->target_bus_cfg; + + ecam_bus_mask = (pcie->ecam_size >> PCIE_ECAM_BUS_SHIFT) - 1; +@@ -287,6 +293,8 @@ static void al_pcie_config_prepare(struct al_pcie *pcie) + FIELD_PREP(CFG_CONTROL_SEC_BUS_MASK, secondary_bus); + + al_pcie_controller_writel(pcie, cfg_control_offset, reg); ++ ++ return 0; + } + + static int al_pcie_host_init(struct pcie_port *pp) +@@ -305,7 +313,9 @@ static int al_pcie_host_init(struct pcie_port *pp) + if (rc) + return rc; + +- al_pcie_config_prepare(pcie); ++ rc = al_pcie_config_prepare(pcie); ++ if (rc) ++ return rc; + + return 0; + } +-- +2.43.0 + diff --git a/queue-5.15/rcu-nocb-remove-buggy-bypass-lock-contention-mitigat.patch b/queue-5.15/rcu-nocb-remove-buggy-bypass-lock-contention-mitigat.patch new file mode 100644 index 00000000000..e8f401206bb --- /dev/null +++ b/queue-5.15/rcu-nocb-remove-buggy-bypass-lock-contention-mitigat.patch @@ -0,0 +1,140 @@ +From e882d62e2032f7ed54f1e1c2c7381ff2108057f5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 Apr 2024 16:18:35 +0200 +Subject: rcu/nocb: Remove buggy bypass lock contention mitigation + +From: Frederic Weisbecker + +[ Upstream commit e4f78057291608f6968a6789c5ebb3bde7d95504 ] + +The bypass lock contention mitigation assumes there can be at most +2 contenders on the bypass lock, following this scheme: + +1) One kthread takes the bypass lock +2) Another one spins on it and increment the contended counter +3) A third one (a bypass enqueuer) sees the contended counter on and + busy loops waiting on it to decrement. + +However this assumption is wrong. There can be only one CPU to find the +lock contended because call_rcu() (the bypass enqueuer) is the only +bypass lock acquire site that may not already hold the NOCB lock +beforehand, all the other sites must first contend on the NOCB lock. +Therefore step 2) is impossible. + +The other problem is that the mitigation assumes that contenders all +belong to the same rdp CPU, which is also impossible for a raw spinlock. +In theory the warning could trigger if the enqueuer holds the bypass +lock and another CPU flushes the bypass queue concurrently but this is +prevented from all flush users: + +1) NOCB kthreads only flush if they successfully _tried_ to lock the + bypass lock. So no contention management here. + +2) Flush on callbacks migration happen remotely when the CPU is offline. + No concurrency against bypass enqueue. + +3) Flush on deoffloading happen either locally with IRQs disabled or + remotely when the CPU is not yet online. No concurrency against + bypass enqueue. + +4) Flush on barrier entrain happen either locally with IRQs disabled or + remotely when the CPU is offline. No concurrency against + bypass enqueue. + +For those reasons, the bypass lock contention mitigation isn't needed +and is even wrong. Remove it but keep the warning reporting a contended +bypass lock on a remote CPU, to keep unexpected contention awareness. + +Signed-off-by: Frederic Weisbecker +Signed-off-by: Paul E. McKenney +Signed-off-by: Sasha Levin +--- + kernel/rcu/tree.h | 1 - + kernel/rcu/tree_nocb.h | 32 ++++++-------------------------- + 2 files changed, 6 insertions(+), 27 deletions(-) + +diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h +index 2da96d8b894a..f27d3e3fe4ed 100644 +--- a/kernel/rcu/tree.h ++++ b/kernel/rcu/tree.h +@@ -205,7 +205,6 @@ struct rcu_data { + struct swait_queue_head nocb_state_wq; /* For offloading state changes */ + struct task_struct *nocb_gp_kthread; + raw_spinlock_t nocb_lock; /* Guard following pair of fields. */ +- atomic_t nocb_lock_contended; /* Contention experienced. */ + int nocb_defer_wakeup; /* Defer wakeup of nocb_kthread. */ + struct timer_list nocb_timer; /* Enforce finite deferral. */ + unsigned long nocb_gp_adv_time; /* Last call_rcu() CB adv (jiffies). */ +diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h +index 8fdf44f8523f..d170dc1f3719 100644 +--- a/kernel/rcu/tree_nocb.h ++++ b/kernel/rcu/tree_nocb.h +@@ -88,8 +88,7 @@ module_param(nocb_nobypass_lim_per_jiffy, int, 0); + + /* + * Acquire the specified rcu_data structure's ->nocb_bypass_lock. If the +- * lock isn't immediately available, increment ->nocb_lock_contended to +- * flag the contention. ++ * lock isn't immediately available, perform minimal sanity check. + */ + static void rcu_nocb_bypass_lock(struct rcu_data *rdp) + __acquires(&rdp->nocb_bypass_lock) +@@ -97,29 +96,12 @@ static void rcu_nocb_bypass_lock(struct rcu_data *rdp) + lockdep_assert_irqs_disabled(); + if (raw_spin_trylock(&rdp->nocb_bypass_lock)) + return; +- atomic_inc(&rdp->nocb_lock_contended); ++ /* ++ * Contention expected only when local enqueue collide with ++ * remote flush from kthreads. ++ */ + WARN_ON_ONCE(smp_processor_id() != rdp->cpu); +- smp_mb__after_atomic(); /* atomic_inc() before lock. */ + raw_spin_lock(&rdp->nocb_bypass_lock); +- smp_mb__before_atomic(); /* atomic_dec() after lock. */ +- atomic_dec(&rdp->nocb_lock_contended); +-} +- +-/* +- * Spinwait until the specified rcu_data structure's ->nocb_lock is +- * not contended. Please note that this is extremely special-purpose, +- * relying on the fact that at most two kthreads and one CPU contend for +- * this lock, and also that the two kthreads are guaranteed to have frequent +- * grace-period-duration time intervals between successive acquisitions +- * of the lock. This allows us to use an extremely simple throttling +- * mechanism, and further to apply it only to the CPU doing floods of +- * call_rcu() invocations. Don't try this at home! +- */ +-static void rcu_nocb_wait_contended(struct rcu_data *rdp) +-{ +- WARN_ON_ONCE(smp_processor_id() != rdp->cpu); +- while (WARN_ON_ONCE(atomic_read(&rdp->nocb_lock_contended))) +- cpu_relax(); + } + + /* +@@ -457,7 +439,6 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, + } + + // We need to use the bypass. +- rcu_nocb_wait_contended(rdp); + rcu_nocb_bypass_lock(rdp); + ncbs = rcu_cblist_n_cbs(&rdp->nocb_bypass); + rcu_segcblist_inc_len(&rdp->cblist); /* Must precede enqueue. */ +@@ -1361,12 +1342,11 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) + + sprintf(bufw, "%ld", rsclp->gp_seq[RCU_WAIT_TAIL]); + sprintf(bufr, "%ld", rsclp->gp_seq[RCU_NEXT_READY_TAIL]); +- pr_info(" CB %d^%d->%d %c%c%c%c%c%c F%ld L%ld C%d %c%c%s%c%s%c%c q%ld %c CPU %d%s\n", ++ pr_info(" CB %d^%d->%d %c%c%c%c%c F%ld L%ld C%d %c%c%s%c%s%c%c q%ld %c CPU %d%s\n", + rdp->cpu, rdp->nocb_gp_rdp->cpu, + rdp->nocb_next_cb_rdp ? rdp->nocb_next_cb_rdp->cpu : -1, + "kK"[!!rdp->nocb_cb_kthread], + "bB"[raw_spin_is_locked(&rdp->nocb_bypass_lock)], +- "cC"[!!atomic_read(&rdp->nocb_lock_contended)], + "lL"[raw_spin_is_locked(&rdp->nocb_lock)], + "sS"[!!rdp->nocb_cb_sleep], + ".W"[swait_active(&rdp->nocb_cb_wq)], +-- +2.43.0 + diff --git a/queue-5.15/rdma-efa-properly-handle-unexpected-aq-completions.patch b/queue-5.15/rdma-efa-properly-handle-unexpected-aq-completions.patch new file mode 100644 index 00000000000..8b172a13570 --- /dev/null +++ b/queue-5.15/rdma-efa-properly-handle-unexpected-aq-completions.patch @@ -0,0 +1,112 @@ +From 58754785dde0ccab3cde04b21ee786ca3d654ac2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 13 May 2024 06:46:30 +0000 +Subject: RDMA/efa: Properly handle unexpected AQ completions + +From: Michael Margolin + +[ Upstream commit 2d0e7ba468eae365f3c4bc9266679e1f8dd405f0 ] + +Do not try to handle admin command completion if it has an unexpected +command id and print a relevant error message. + +Reviewed-by: Firas Jahjah +Reviewed-by: Yehuda Yitschak +Signed-off-by: Michael Margolin +Link: https://lore.kernel.org/r/20240513064630.6247-1-mrgolin@amazon.com +Reviewed-by: Gal Pressman +Signed-off-by: Leon Romanovsky +Signed-off-by: Sasha Levin +--- + drivers/infiniband/hw/efa/efa_com.c | 30 ++++++++++++++++------------- + 1 file changed, 17 insertions(+), 13 deletions(-) + +diff --git a/drivers/infiniband/hw/efa/efa_com.c b/drivers/infiniband/hw/efa/efa_com.c +index 0d523ad736c7..462908022091 100644 +--- a/drivers/infiniband/hw/efa/efa_com.c ++++ b/drivers/infiniband/hw/efa/efa_com.c +@@ -1,6 +1,6 @@ + // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause + /* +- * Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved. ++ * Copyright 2018-2024 Amazon.com, Inc. or its affiliates. All rights reserved. + */ + + #include "efa_com.h" +@@ -398,8 +398,8 @@ static struct efa_comp_ctx *efa_com_submit_admin_cmd(struct efa_com_admin_queue + return comp_ctx; + } + +-static void efa_com_handle_single_admin_completion(struct efa_com_admin_queue *aq, +- struct efa_admin_acq_entry *cqe) ++static int efa_com_handle_single_admin_completion(struct efa_com_admin_queue *aq, ++ struct efa_admin_acq_entry *cqe) + { + struct efa_comp_ctx *comp_ctx; + u16 cmd_id; +@@ -408,11 +408,11 @@ static void efa_com_handle_single_admin_completion(struct efa_com_admin_queue *a + EFA_ADMIN_ACQ_COMMON_DESC_COMMAND_ID); + + comp_ctx = efa_com_get_comp_ctx(aq, cmd_id, false); +- if (!comp_ctx) { ++ if (comp_ctx->status != EFA_CMD_SUBMITTED) { + ibdev_err(aq->efa_dev, +- "comp_ctx is NULL. Changing the admin queue running state\n"); +- clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state); +- return; ++ "Received completion with unexpected command id[%d], sq producer: %d, sq consumer: %d, cq consumer: %d\n", ++ cmd_id, aq->sq.pc, aq->sq.cc, aq->cq.cc); ++ return -EINVAL; + } + + comp_ctx->status = EFA_CMD_COMPLETED; +@@ -420,14 +420,17 @@ static void efa_com_handle_single_admin_completion(struct efa_com_admin_queue *a + + if (!test_bit(EFA_AQ_STATE_POLLING_BIT, &aq->state)) + complete(&comp_ctx->wait_event); ++ ++ return 0; + } + + static void efa_com_handle_admin_completion(struct efa_com_admin_queue *aq) + { + struct efa_admin_acq_entry *cqe; + u16 queue_size_mask; +- u16 comp_num = 0; ++ u16 comp_cmds = 0; + u8 phase; ++ int err; + u16 ci; + + queue_size_mask = aq->depth - 1; +@@ -445,10 +448,12 @@ static void efa_com_handle_admin_completion(struct efa_com_admin_queue *aq) + * phase bit was validated + */ + dma_rmb(); +- efa_com_handle_single_admin_completion(aq, cqe); ++ err = efa_com_handle_single_admin_completion(aq, cqe); ++ if (!err) ++ comp_cmds++; + ++ aq->cq.cc++; + ci++; +- comp_num++; + if (ci == aq->depth) { + ci = 0; + phase = !phase; +@@ -457,10 +462,9 @@ static void efa_com_handle_admin_completion(struct efa_com_admin_queue *aq) + cqe = &aq->cq.entries[ci]; + } + +- aq->cq.cc += comp_num; + aq->cq.phase = phase; +- aq->sq.cc += comp_num; +- atomic64_add(comp_num, &aq->stats.completed_cmd); ++ aq->sq.cc += comp_cmds; ++ atomic64_add(comp_cmds, &aq->stats.completed_cmd); + } + + static int efa_com_comp_status_to_errno(u8 comp_status) +-- +2.43.0 + diff --git a/queue-5.15/series b/queue-5.15/series index 47073f8f634..b4d98a36cee 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -4,3 +4,53 @@ alsa-hda-conexant-mute-speakers-at-suspend-shutdown.patch i2c-fix-conditional-for-substituting-empty-acpi-func.patch dma-debug-avoid-deadlock-between-dma-debug-vs-printk.patch net-usb-qmi_wwan-add-meig-smart-srm825l.patch +drm-amdgpu-fix-uninitialized-variable-warning-in-amd.patch +drm-amd-display-assign-linear_pitch_alignment-even-f.patch +drm-amdgpu-fix-overflowed-array-index-read-warning.patch +drm-amdgpu-pm-check-the-return-value-of-smum_send_ms.patch +drm-amd-pm-fix-uninitialized-variable-warning-for-sm.patch +drm-amd-pm-fix-warning-using-uninitialized-value-of-.patch +drm-amd-pm-fix-the-out-of-bounds-read-warning.patch +drm-amdgpu-fix-uninitialized-scalar-variable-warning.patch +drm-amd-pm-fix-uninitialized-variable-warnings-for-v.patch +drm-amdgpu-avoid-reading-vf2pf-info-size-from-fb.patch +drm-amd-display-check-gpio_id-before-used-as-array-i.patch +drm-amd-display-stop-amdgpu_dm-initialize-when-strea.patch +drm-amd-display-add-array-index-check-for-hdcp-ddc-a.patch +drm-amd-display-check-num_valid_sets-before-accessin.patch +drm-amd-display-check-msg_id-before-processing-trans.patch +drm-amd-display-fix-coverity-integer_overflow-within.patch +drm-amd-amdgpu-check-tbo-resource-pointer.patch +drm-drm-bridge-drop-conditionals-around-of_node-poin.patch +drm-amdgpu-pm-fix-uninitialized-variable-warning-for.patch +drm-amdgpu-pm-fix-uninitialized-variable-agc_btc_res.patch +drm-amdgpu-fix-out-of-bounds-write-warning.patch +drm-amdgpu-fix-out-of-bounds-read-of-df_v1_7_channel.patch +drm-amdgpu-fix-ucode-out-of-bounds-read-warning.patch +drm-amdgpu-fix-mc_data-out-of-bounds-read-warning.patch +drm-amdkfd-reconcile-the-definition-and-use-of-oem_i.patch +apparmor-fix-possible-null-pointer-dereference.patch +drm-amdgpu-pm-check-input-value-for-custom-profile-m.patch +drm-amdgpu-fix-the-waring-dereferencing-hive.patch +drm-amd-pm-check-specific-index-for-aldebaran.patch +drm-amdgpu-the-warning-dereferencing-obj-for-nbio_v7.patch +drm-amd-pm-check-negtive-return-for-table-entries.patch +drm-amdgpu-update-type-of-buf-size-to-u32-for-eeprom.patch +wifi-iwlwifi-remove-fw_running-op.patch +cpufreq-scmi-avoid-overflow-of-target_freq-in-fast-s.patch +pci-al-check-ioresource_bus-existence-during-probe.patch +hwspinlock-introduce-hwspin_lock_bust.patch +rdma-efa-properly-handle-unexpected-aq-completions.patch +ionic-fix-potential-irq-name-truncation.patch +rcu-nocb-remove-buggy-bypass-lock-contention-mitigat.patch +usbip-don-t-submit-special-requests-twice.patch +usb-typec-ucsi-fix-null-pointer-dereference-in-trace.patch +fsnotify-clear-parent_watched-flags-lazily.patch +smack-tcp-ipv4-fix-incorrect-labeling.patch +drm-meson-plane-add-error-handling.patch +drm-bridge-tc358767-check-if-fully-initialized-befor.patch +wifi-cfg80211-make-hash-table-duplicates-more-surviv.patch +block-remove-the-blk_flush_integrity-call-in-blk_int.patch +drm-amd-display-added-null-check-at-start-of-dc_vali.patch +drm-amd-display-skip-wbscl_set_scaler_filter-if-filt.patch +media-uvcvideo-enforce-alignment-of-frame-and-interv.patch diff --git a/queue-5.15/smack-tcp-ipv4-fix-incorrect-labeling.patch b/queue-5.15/smack-tcp-ipv4-fix-incorrect-labeling.patch new file mode 100644 index 00000000000..dd40c3da867 --- /dev/null +++ b/queue-5.15/smack-tcp-ipv4-fix-incorrect-labeling.patch @@ -0,0 +1,69 @@ +From 95ea9cda11f125e247eab23474c476a52dd19a37 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 5 Jun 2024 15:41:50 -0700 +Subject: smack: tcp: ipv4, fix incorrect labeling + +From: Casey Schaufler + +[ Upstream commit 2fe209d0ad2e2729f7e22b9b31a86cc3ff0db550 ] + +Currently, Smack mirrors the label of incoming tcp/ipv4 connections: +when a label 'foo' connects to a label 'bar' with tcp/ipv4, +'foo' always gets 'foo' in returned ipv4 packets. So, +1) returned packets are incorrectly labeled ('foo' instead of 'bar') +2) 'bar' can write to 'foo' without being authorized to write. + +Here is a scenario how to see this: + +* Take two machines, let's call them C and S, + with active Smack in the default state + (no settings, no rules, no labeled hosts, only builtin labels) + +* At S, add Smack rule 'foo bar w' + (labels 'foo' and 'bar' are instantiated at S at this moment) + +* At S, at label 'bar', launch a program + that listens for incoming tcp/ipv4 connections + +* From C, at label 'foo', connect to the listener at S. + (label 'foo' is instantiated at C at this moment) + Connection succeedes and works. + +* Send some data in both directions. +* Collect network traffic of this connection. + +All packets in both directions are labeled with the CIPSO +of the label 'foo'. Hence, label 'bar' writes to 'foo' without +being authorized, and even without ever being known at C. + +If anybody cares: exactly the same happens with DCCP. + +This behavior 1st manifested in release 2.6.29.4 (see Fixes below) +and it looks unintentional. At least, no explanation was provided. + +I changed returned packes label into the 'bar', +to bring it into line with the Smack documentation claims. + +Signed-off-by: Konstantin Andreev +Signed-off-by: Casey Schaufler +Signed-off-by: Sasha Levin +--- + security/smack/smack_lsm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c +index e9d2ef3deccd..25c46b56fae8 100644 +--- a/security/smack/smack_lsm.c ++++ b/security/smack/smack_lsm.c +@@ -4225,7 +4225,7 @@ static int smack_inet_conn_request(const struct sock *sk, struct sk_buff *skb, + rcu_read_unlock(); + + if (hskp == NULL) +- rc = netlbl_req_setattr(req, &skp->smk_netlabel); ++ rc = netlbl_req_setattr(req, &ssp->smk_out->smk_netlabel); + else + netlbl_req_delattr(req); + +-- +2.43.0 + diff --git a/queue-5.15/usb-typec-ucsi-fix-null-pointer-dereference-in-trace.patch b/queue-5.15/usb-typec-ucsi-fix-null-pointer-dereference-in-trace.patch new file mode 100644 index 00000000000..d760ca46f69 --- /dev/null +++ b/queue-5.15/usb-typec-ucsi-fix-null-pointer-dereference-in-trace.patch @@ -0,0 +1,44 @@ +From 3a47a2a9659785354be9e09344fb082af12f9c0a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 10 May 2024 20:12:41 +0000 +Subject: usb: typec: ucsi: Fix null pointer dereference in trace + +From: Abhishek Pandit-Subedi + +[ Upstream commit 99516f76db48e1a9d54cdfed63c1babcee4e71a5 ] + +ucsi_register_altmode checks IS_ERR for the alt pointer and treats +NULL as valid. When CONFIG_TYPEC_DP_ALTMODE is not enabled, +ucsi_register_displayport returns NULL which causes a NULL pointer +dereference in trace. Rather than return NULL, call +typec_port_register_altmode to register DisplayPort alternate mode +as a non-controllable mode when CONFIG_TYPEC_DP_ALTMODE is not enabled. + +Reviewed-by: Benson Leung +Reviewed-by: Heikki Krogerus +Signed-off-by: Abhishek Pandit-Subedi +Signed-off-by: Jameson Thies +Reviewed-by: Dmitry Baryshkov +Link: https://lore.kernel.org/r/20240510201244.2968152-2-jthies@google.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/typec/ucsi/ucsi.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h +index 3dc3da8dbbdf..656a53ccd891 100644 +--- a/drivers/usb/typec/ucsi/ucsi.h ++++ b/drivers/usb/typec/ucsi/ucsi.h +@@ -368,7 +368,7 @@ ucsi_register_displayport(struct ucsi_connector *con, + bool override, int offset, + struct typec_altmode_desc *desc) + { +- return NULL; ++ return typec_port_register_altmode(con->port, desc); + } + + static inline void +-- +2.43.0 + diff --git a/queue-5.15/usbip-don-t-submit-special-requests-twice.patch b/queue-5.15/usbip-don-t-submit-special-requests-twice.patch new file mode 100644 index 00000000000..3c4bd28afa7 --- /dev/null +++ b/queue-5.15/usbip-don-t-submit-special-requests-twice.patch @@ -0,0 +1,183 @@ +From 688908a91f92be2026772fb014ba12197c4b28c6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 19 May 2024 16:15:38 +0200 +Subject: usbip: Don't submit special requests twice + +From: Simon Holesch + +[ Upstream commit 8b6b386f9aa936ed0c190446c71cf59d4a507690 ] + +Skip submitting URBs, when identical requests were already sent in +tweak_special_requests(). Instead call the completion handler directly +to return the result of the URB. + +Even though submitting those requests twice should be harmless, there +are USB devices that react poorly to some duplicated requests. + +One example is the ChipIdea controller implementation in U-Boot: The +second SET_CONFIGURATION request makes U-Boot disable and re-enable all +endpoints. Re-enabling an endpoint in the ChipIdea controller, however, +was broken until U-Boot commit b272c8792502 ("usb: ci: Fix gadget +reinit"). + +Signed-off-by: Simon Holesch +Acked-by: Shuah Khan +Reviewed-by: Hongren Zheng +Tested-by: Hongren Zheng +Link: https://lore.kernel.org/r/20240519141922.171460-1-simon@holesch.de +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/usbip/stub_rx.c | 77 ++++++++++++++++++++++++------------- + 1 file changed, 50 insertions(+), 27 deletions(-) + +diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c +index 5dd41e8215e0..bb34d647cf13 100644 +--- a/drivers/usb/usbip/stub_rx.c ++++ b/drivers/usb/usbip/stub_rx.c +@@ -144,53 +144,62 @@ static int tweak_set_configuration_cmd(struct urb *urb) + if (err && err != -ENODEV) + dev_err(&sdev->udev->dev, "can't set config #%d, error %d\n", + config, err); +- return 0; ++ return err; + } + + static int tweak_reset_device_cmd(struct urb *urb) + { + struct stub_priv *priv = (struct stub_priv *) urb->context; + struct stub_device *sdev = priv->sdev; ++ int err; + + dev_info(&urb->dev->dev, "usb_queue_reset_device\n"); + +- if (usb_lock_device_for_reset(sdev->udev, NULL) < 0) { ++ err = usb_lock_device_for_reset(sdev->udev, NULL); ++ if (err < 0) { + dev_err(&urb->dev->dev, "could not obtain lock to reset device\n"); +- return 0; ++ return err; + } +- usb_reset_device(sdev->udev); ++ err = usb_reset_device(sdev->udev); + usb_unlock_device(sdev->udev); + +- return 0; ++ return err; + } + + /* + * clear_halt, set_interface, and set_configuration require special tricks. ++ * Returns 1 if request was tweaked, 0 otherwise. + */ +-static void tweak_special_requests(struct urb *urb) ++static int tweak_special_requests(struct urb *urb) + { ++ int err; ++ + if (!urb || !urb->setup_packet) +- return; ++ return 0; + + if (usb_pipetype(urb->pipe) != PIPE_CONTROL) +- return; ++ return 0; + + if (is_clear_halt_cmd(urb)) + /* tweak clear_halt */ +- tweak_clear_halt_cmd(urb); ++ err = tweak_clear_halt_cmd(urb); + + else if (is_set_interface_cmd(urb)) + /* tweak set_interface */ +- tweak_set_interface_cmd(urb); ++ err = tweak_set_interface_cmd(urb); + + else if (is_set_configuration_cmd(urb)) + /* tweak set_configuration */ +- tweak_set_configuration_cmd(urb); ++ err = tweak_set_configuration_cmd(urb); + + else if (is_reset_device_cmd(urb)) +- tweak_reset_device_cmd(urb); +- else ++ err = tweak_reset_device_cmd(urb); ++ else { + usbip_dbg_stub_rx("no need to tweak\n"); ++ return 0; ++ } ++ ++ return !err; + } + + /* +@@ -468,6 +477,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, + int support_sg = 1; + int np = 0; + int ret, i; ++ int is_tweaked; + + if (pipe == -1) + return; +@@ -580,8 +590,11 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, + priv->urbs[i]->pipe = pipe; + priv->urbs[i]->complete = stub_complete; + +- /* no need to submit an intercepted request, but harmless? */ +- tweak_special_requests(priv->urbs[i]); ++ /* ++ * all URBs belong to a single PDU, so a global is_tweaked flag is ++ * enough ++ */ ++ is_tweaked = tweak_special_requests(priv->urbs[i]); + + masking_bogus_flags(priv->urbs[i]); + } +@@ -594,22 +607,32 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, + + /* urb is now ready to submit */ + for (i = 0; i < priv->num_urbs; i++) { +- ret = usb_submit_urb(priv->urbs[i], GFP_KERNEL); ++ if (!is_tweaked) { ++ ret = usb_submit_urb(priv->urbs[i], GFP_KERNEL); + +- if (ret == 0) +- usbip_dbg_stub_rx("submit urb ok, seqnum %u\n", +- pdu->base.seqnum); +- else { +- dev_err(&udev->dev, "submit_urb error, %d\n", ret); +- usbip_dump_header(pdu); +- usbip_dump_urb(priv->urbs[i]); ++ if (ret == 0) ++ usbip_dbg_stub_rx("submit urb ok, seqnum %u\n", ++ pdu->base.seqnum); ++ else { ++ dev_err(&udev->dev, "submit_urb error, %d\n", ret); ++ usbip_dump_header(pdu); ++ usbip_dump_urb(priv->urbs[i]); + ++ /* ++ * Pessimistic. ++ * This connection will be discarded. ++ */ ++ usbip_event_add(ud, SDEV_EVENT_ERROR_SUBMIT); ++ break; ++ } ++ } else { + /* +- * Pessimistic. +- * This connection will be discarded. ++ * An identical URB was already submitted in ++ * tweak_special_requests(). Skip submitting this URB to not ++ * duplicate the request. + */ +- usbip_event_add(ud, SDEV_EVENT_ERROR_SUBMIT); +- break; ++ priv->urbs[i]->status = 0; ++ stub_complete(priv->urbs[i]); + } + } + +-- +2.43.0 + diff --git a/queue-5.15/wifi-cfg80211-make-hash-table-duplicates-more-surviv.patch b/queue-5.15/wifi-cfg80211-make-hash-table-duplicates-more-surviv.patch new file mode 100644 index 00000000000..e22b85da01c --- /dev/null +++ b/queue-5.15/wifi-cfg80211-make-hash-table-duplicates-more-surviv.patch @@ -0,0 +1,131 @@ +From 418ed8854f55d8cf1b62f4b0c77effc44d6a0b79 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 7 Jun 2024 20:17:17 +0200 +Subject: wifi: cfg80211: make hash table duplicates more survivable + +From: Johannes Berg + +[ Upstream commit 7f12e26a194d0043441f870708093d9c2c3bad7d ] + +Jiazi Li reported that they occasionally see hash table duplicates +as evidenced by the WARN_ON() in rb_insert_bss() in this code. It +isn't clear how that happens, nor have I been able to reproduce it, +but if it does happen, the kernel crashes later, when it tries to +unhash the entry that's now not hashed. + +Try to make this situation more survivable by removing the BSS from +the list(s) as well, that way it's fully leaked here (as had been +the intent in the hash insert error path), and no longer reachable +through the list(s) so it shouldn't be unhashed again later. + +Link: https://lore.kernel.org/r/20231026013528.GA24122@Jiazi.Li +Signed-off-by: Johannes Berg +Link: https://msgid.link/20240607181726.36835-2-johannes@sipsolutions.net +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + net/wireless/scan.c | 46 +++++++++++++++++++++++++++++++++------------ + 1 file changed, 34 insertions(+), 12 deletions(-) + +diff --git a/net/wireless/scan.c b/net/wireless/scan.c +index a444eb84d621..b8e28025710d 100644 +--- a/net/wireless/scan.c ++++ b/net/wireless/scan.c +@@ -1517,7 +1517,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, + } + EXPORT_SYMBOL(cfg80211_get_bss); + +-static void rb_insert_bss(struct cfg80211_registered_device *rdev, ++static bool rb_insert_bss(struct cfg80211_registered_device *rdev, + struct cfg80211_internal_bss *bss) + { + struct rb_node **p = &rdev->bss_tree.rb_node; +@@ -1533,7 +1533,7 @@ static void rb_insert_bss(struct cfg80211_registered_device *rdev, + + if (WARN_ON(!cmp)) { + /* will sort of leak this BSS */ +- return; ++ return false; + } + + if (cmp < 0) +@@ -1544,6 +1544,7 @@ static void rb_insert_bss(struct cfg80211_registered_device *rdev, + + rb_link_node(&bss->rbn, parent, p); + rb_insert_color(&bss->rbn, &rdev->bss_tree); ++ return true; + } + + static struct cfg80211_internal_bss * +@@ -1570,6 +1571,34 @@ rb_find_bss(struct cfg80211_registered_device *rdev, + return NULL; + } + ++static void cfg80211_insert_bss(struct cfg80211_registered_device *rdev, ++ struct cfg80211_internal_bss *bss) ++{ ++ lockdep_assert_held(&rdev->bss_lock); ++ ++ if (!rb_insert_bss(rdev, bss)) ++ return; ++ list_add_tail(&bss->list, &rdev->bss_list); ++ rdev->bss_entries++; ++} ++ ++static void cfg80211_rehash_bss(struct cfg80211_registered_device *rdev, ++ struct cfg80211_internal_bss *bss) ++{ ++ lockdep_assert_held(&rdev->bss_lock); ++ ++ rb_erase(&bss->rbn, &rdev->bss_tree); ++ if (!rb_insert_bss(rdev, bss)) { ++ list_del(&bss->list); ++ if (!list_empty(&bss->hidden_list)) ++ list_del_init(&bss->hidden_list); ++ if (!list_empty(&bss->pub.nontrans_list)) ++ list_del_init(&bss->pub.nontrans_list); ++ rdev->bss_entries--; ++ } ++ rdev->bss_generation++; ++} ++ + static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev, + struct cfg80211_internal_bss *new) + { +@@ -1845,9 +1874,7 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev, + bss_ref_get(rdev, pbss); + } + +- list_add_tail(&new->list, &rdev->bss_list); +- rdev->bss_entries++; +- rb_insert_bss(rdev, new); ++ cfg80211_insert_bss(rdev, new); + found = new; + } + +@@ -2712,10 +2739,7 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, + if (!WARN_ON(!__cfg80211_unlink_bss(rdev, new))) + rdev->bss_generation++; + } +- +- rb_erase(&cbss->rbn, &rdev->bss_tree); +- rb_insert_bss(rdev, cbss); +- rdev->bss_generation++; ++ cfg80211_rehash_bss(rdev, cbss); + + list_for_each_entry_safe(nontrans_bss, tmp, + &cbss->pub.nontrans_list, +@@ -2723,9 +2747,7 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, + bss = container_of(nontrans_bss, + struct cfg80211_internal_bss, pub); + bss->pub.channel = chan; +- rb_erase(&bss->rbn, &rdev->bss_tree); +- rb_insert_bss(rdev, bss); +- rdev->bss_generation++; ++ cfg80211_rehash_bss(rdev, bss); + } + + done: +-- +2.43.0 + diff --git a/queue-5.15/wifi-iwlwifi-remove-fw_running-op.patch b/queue-5.15/wifi-iwlwifi-remove-fw_running-op.patch new file mode 100644 index 00000000000..de401cf78f3 --- /dev/null +++ b/queue-5.15/wifi-iwlwifi-remove-fw_running-op.patch @@ -0,0 +1,80 @@ +From 35f4267aec4d0a6cb100f86d7ea9cb49a648741e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 10 May 2024 17:06:40 +0300 +Subject: wifi: iwlwifi: remove fw_running op + +From: Shahar S Matityahu + +[ Upstream commit 37733bffda3285d18bd1d72c14b3a1cf39c56a5e ] + +fw_running assumes that memory can be retrieved only after alive. +This assumption is no longer true as we support dump before alive. +To avoid invalid access to the NIC, check that STATUS_DEVICE_ENABLED +bit in trans status is set before dumping instead of the prior check. + +Signed-off-by: Shahar S Matityahu +Reviewed-by: Luciano Coelho +Signed-off-by: Emmanuel Grumbach +Signed-off-by: Miri Korenblit +Link: https://msgid.link/20240510170500.ca07138cedeb.I090e31d3eaeb4ba19f5f84aba997ccd36927e9ac@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/intel/iwlwifi/fw/debugfs.c | 3 +-- + drivers/net/wireless/intel/iwlwifi/fw/runtime.h | 1 - + drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 6 ------ + 3 files changed, 1 insertion(+), 9 deletions(-) + +diff --git a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c +index 6419fbfec5ac..6da3934b8e9a 100644 +--- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c ++++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c +@@ -252,8 +252,7 @@ static ssize_t iwl_dbgfs_send_hcmd_write(struct iwl_fw_runtime *fwrt, char *buf, + .data = { NULL, }, + }; + +- if (fwrt->ops && fwrt->ops->fw_running && +- !fwrt->ops->fw_running(fwrt->ops_ctx)) ++ if (!iwl_trans_fw_running(fwrt->trans)) + return -EIO; + + if (count < header_size + 1 || count > 1024 * 4) +diff --git a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h +index 35af85a5430b..297ff92de928 100644 +--- a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h ++++ b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h +@@ -18,7 +18,6 @@ + struct iwl_fw_runtime_ops { + int (*dump_start)(void *ctx); + void (*dump_end)(void *ctx); +- bool (*fw_running)(void *ctx); + int (*send_hcmd)(void *ctx, struct iwl_host_cmd *host_cmd); + bool (*d3_debug_enable)(void *ctx); + }; +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +index 01f65c9789e7..0b0022dabc7b 100644 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +@@ -653,11 +653,6 @@ static void iwl_mvm_fwrt_dump_end(void *ctx) + mutex_unlock(&mvm->mutex); + } + +-static bool iwl_mvm_fwrt_fw_running(void *ctx) +-{ +- return iwl_mvm_firmware_running(ctx); +-} +- + static int iwl_mvm_fwrt_send_hcmd(void *ctx, struct iwl_host_cmd *host_cmd) + { + struct iwl_mvm *mvm = (struct iwl_mvm *)ctx; +@@ -678,7 +673,6 @@ static bool iwl_mvm_d3_debug_enable(void *ctx) + static const struct iwl_fw_runtime_ops iwl_mvm_fwrt_ops = { + .dump_start = iwl_mvm_fwrt_dump_start, + .dump_end = iwl_mvm_fwrt_dump_end, +- .fw_running = iwl_mvm_fwrt_fw_running, + .send_hcmd = iwl_mvm_fwrt_send_hcmd, + .d3_debug_enable = iwl_mvm_d3_debug_enable, + }; +-- +2.43.0 +