Re: [PATCH] drm/amdgpu: Move mutex_init(>message_lock) to smu_early_init()

2022-05-12 Thread Alex Deucher
Applied.  Thanks!

Alex

On Thu, May 12, 2022 at 4:45 PM Hans de Goede  wrote:
>
> Lockdep complains about the smu->message_lock mutex being used before
> it is initialized through the following call path:
>
> amdgpu_device_init()
>  amdgpu_dpm_mode2_reset()
>   smu_mode2_reset()
>smu_v12_0_mode2_reset()
> smu_cmn_send_smc_msg_with_param()
>
> Move the mutex_init() call to smu_early_init() to fix the mutex being
> used before it is initialized.
>
> This fixes the following lockdep splat:
>
> [3.867331] [ cut here ]
> [3.867335] fbcon: Taking over console
> [3.867338] DEBUG_LOCKS_WARN_ON(lock->magic != lock)
> [3.867340] WARNING: CPU: 14 PID: 491 at kernel/locking/mutex.c:579 
> __mutex_lock+0x44c/0x830
> [3.867349] Modules linked in: amdgpu(+) crct10dif_pclmul drm_ttm_helper 
> crc32_pclmul ttm crc32c_intel ghash_clmulni_intel hid_lg_g15 iommu_v2 
> sp5100_tco nvme gpu_sched drm_dp_helper nvme_core ccp wmi video 
> hid_logitech_dj ip6_tables ip_tables ipmi_devintf ipmi_msghandler fuse i2c_dev
> [3.867363] CPU: 14 PID: 491 Comm: systemd-udevd Tainted: G  I 
>   5.18.0-rc5+ #33
> [3.867366] Hardware name: Micro-Star International Co., Ltd. 
> MS-7C95/B550M PRO-VDH WIFI (MS-7C95), BIOS 2.90 12/23/2021
> [3.867369] RIP: 0010:__mutex_lock+0x44c/0x830
> [3.867372] Code: ff 85 c0 0f 84 33 fc ff ff 8b 0d b7 50 25 01 85 c9 0f 85 
> 25 fc ff ff 48 c7 c6 fb 41 82 99 48 c7 c7 6b 63 80 99 e8 88 2a f8 ff <0f> 0b 
> e9 0b fc ff ff f6 83 b9 0c 00 00 01 0f 85 64 ff ff ff 4c 89
> [3.867377] RSP: 0018:aef8c0fc79f0 EFLAGS: 00010286
> [3.867380] RAX: 0028 RBX:  RCX: 
> 0027
> [3.867382] RDX: 9ccc0dda0928 RSI: 0001 RDI: 
> 9ccc0dda0920
> [3.867384] RBP: aef8c0fc7a80 R08:  R09: 
> aef8c0fc7820
> [3.867386] R10: 0003 R11: 9ccc2a2fffe8 R12: 
> 0002
> [3.867388] R13: 9cc990808058 R14:  R15: 
> 9cc98bfc
> [3.867390] FS:  7fc4d830f580() GS:9ccc0dd8() 
> knlGS:
> [3.867394] CS:  0010 DS:  ES:  CR0: 80050033
> [3.867396] CR2: 560a77031410 CR3: 00010f522000 CR4: 
> 00750ee0
> [3.867398] PKRU: 5554
> [3.867399] Call Trace:
> [3.867401]  
> [3.867403]  ? smu_cmn_send_smc_msg_with_param+0x98/0x240 [amdgpu]
> [3.867533]  ? __mutex_lock+0x90/0x830
> [3.867535]  ? amdgpu_dpm_mode2_reset+0x37/0x60 [amdgpu]
> [3.867653]  ? smu_cmn_send_smc_msg_with_param+0x98/0x240 [amdgpu]
> [3.867758]  smu_cmn_send_smc_msg_with_param+0x98/0x240 [amdgpu]
> [3.867857]  smu_mode2_reset+0x2b/0x50 [amdgpu]
> [3.867953]  amdgpu_dpm_mode2_reset+0x46/0x60 [amdgpu]
> [3.868096]  amdgpu_device_init.cold+0x1069/0x1e78 [amdgpu]
> [3.868219]  ? _raw_spin_unlock_irqrestore+0x30/0x50
> [3.868222]  ? pci_conf1_read+0x9b/0xf0
> [3.868226]  amdgpu_driver_load_kms+0x15/0x110 [amdgpu]
> [3.868314]  amdgpu_pci_probe+0x1a9/0x3c0 [amdgpu]
> [3.868398]  local_pci_probe+0x41/0x80
> [3.868401]  pci_device_probe+0xab/0x200
> [3.868404]  really_probe+0x1a1/0x370
> [3.868407]  __driver_probe_device+0xfc/0x170
> [3.868410]  driver_probe_device+0x1f/0x90
> [3.868412]  __driver_attach+0xbf/0x1a0
> [3.868414]  ? __device_attach_driver+0xe0/0xe0
> [3.868416]  bus_for_each_dev+0x65/0x90
> [3.868419]  bus_add_driver+0x151/0x1f0
> [3.868421]  driver_register+0x89/0xd0
> [3.868423]  ? 0xc0bd4000
> [3.868425]  do_one_initcall+0x5d/0x300
> [3.868428]  ? do_init_module+0x22/0x240
> [3.868431]  ? rcu_read_lock_sched_held+0x3c/0x70
> [3.868434]  ? trace_kmalloc+0x30/0xe0
> [3.868437]  ? kmem_cache_alloc_trace+0x1e6/0x3a0
> [3.868440]  do_init_module+0x4a/0x240
> [3.868442]  __do_sys_finit_module+0x93/0xf0
> [3.868446]  do_syscall_64+0x5b/0x80
> [3.868449]  ? rcu_read_lock_sched_held+0x3c/0x70
> [3.868451]  ? lockdep_hardirqs_on_prepare+0xd9/0x180
> [3.868454]  ? do_syscall_64+0x67/0x80
> [3.868456]  ? do_syscall_64+0x67/0x80
> [3.868458]  ? do_syscall_64+0x67/0x80
> [3.868460]  ? do_syscall_64+0x67/0x80
> [3.868462]  entry_SYSCALL_64_after_hwframe+0x44/0xae
> [3.868465] RIP: 0033:0x7fc4d8ec1ced
> [3.868467] Code: 5d c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 
> f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 
> 01 f0 ff ff 73 01 c3 48 8b 0d fb 70 0e 00 f7 d8 64 89 01 48
> [3.868472] RSP: 002b:7fff687ae6b8 EFLAGS: 0246 ORIG_RAX: 
> 0139
> [3.868475] RAX: ffda RBX: 560a76fbca60 RCX: 
> 7fc4d8ec1ced
> [3.868477] RDX:  RSI: 7fc4d902343c RDI: 
> 0011
> [3.868479] RBP: 7fc4d902343c R08:  R09: 
> 560a76fb59c0
> [3.868481] R10: 0011 R11: 

[PATCH] drm/amdgpu: Move mutex_init(>message_lock) to smu_early_init()

2022-05-12 Thread Hans de Goede
Lockdep complains about the smu->message_lock mutex being used before
it is initialized through the following call path:

amdgpu_device_init()
 amdgpu_dpm_mode2_reset()
  smu_mode2_reset()
   smu_v12_0_mode2_reset()
smu_cmn_send_smc_msg_with_param()

Move the mutex_init() call to smu_early_init() to fix the mutex being
used before it is initialized.

This fixes the following lockdep splat:

[3.867331] [ cut here ]
[3.867335] fbcon: Taking over console
[3.867338] DEBUG_LOCKS_WARN_ON(lock->magic != lock)
[3.867340] WARNING: CPU: 14 PID: 491 at kernel/locking/mutex.c:579 
__mutex_lock+0x44c/0x830
[3.867349] Modules linked in: amdgpu(+) crct10dif_pclmul drm_ttm_helper 
crc32_pclmul ttm crc32c_intel ghash_clmulni_intel hid_lg_g15 iommu_v2 
sp5100_tco nvme gpu_sched drm_dp_helper nvme_core ccp wmi video hid_logitech_dj 
ip6_tables ip_tables ipmi_devintf ipmi_msghandler fuse i2c_dev
[3.867363] CPU: 14 PID: 491 Comm: systemd-udevd Tainted: G  I   
5.18.0-rc5+ #33
[3.867366] Hardware name: Micro-Star International Co., Ltd. MS-7C95/B550M 
PRO-VDH WIFI (MS-7C95), BIOS 2.90 12/23/2021
[3.867369] RIP: 0010:__mutex_lock+0x44c/0x830
[3.867372] Code: ff 85 c0 0f 84 33 fc ff ff 8b 0d b7 50 25 01 85 c9 0f 85 
25 fc ff ff 48 c7 c6 fb 41 82 99 48 c7 c7 6b 63 80 99 e8 88 2a f8 ff <0f> 0b e9 
0b fc ff ff f6 83 b9 0c 00 00 01 0f 85 64 ff ff ff 4c 89
[3.867377] RSP: 0018:aef8c0fc79f0 EFLAGS: 00010286
[3.867380] RAX: 0028 RBX:  RCX: 0027
[3.867382] RDX: 9ccc0dda0928 RSI: 0001 RDI: 9ccc0dda0920
[3.867384] RBP: aef8c0fc7a80 R08:  R09: aef8c0fc7820
[3.867386] R10: 0003 R11: 9ccc2a2fffe8 R12: 0002
[3.867388] R13: 9cc990808058 R14:  R15: 9cc98bfc
[3.867390] FS:  7fc4d830f580() GS:9ccc0dd8() 
knlGS:
[3.867394] CS:  0010 DS:  ES:  CR0: 80050033
[3.867396] CR2: 560a77031410 CR3: 00010f522000 CR4: 00750ee0
[3.867398] PKRU: 5554
[3.867399] Call Trace:
[3.867401]  
[3.867403]  ? smu_cmn_send_smc_msg_with_param+0x98/0x240 [amdgpu]
[3.867533]  ? __mutex_lock+0x90/0x830
[3.867535]  ? amdgpu_dpm_mode2_reset+0x37/0x60 [amdgpu]
[3.867653]  ? smu_cmn_send_smc_msg_with_param+0x98/0x240 [amdgpu]
[3.867758]  smu_cmn_send_smc_msg_with_param+0x98/0x240 [amdgpu]
[3.867857]  smu_mode2_reset+0x2b/0x50 [amdgpu]
[3.867953]  amdgpu_dpm_mode2_reset+0x46/0x60 [amdgpu]
[3.868096]  amdgpu_device_init.cold+0x1069/0x1e78 [amdgpu]
[3.868219]  ? _raw_spin_unlock_irqrestore+0x30/0x50
[3.868222]  ? pci_conf1_read+0x9b/0xf0
[3.868226]  amdgpu_driver_load_kms+0x15/0x110 [amdgpu]
[3.868314]  amdgpu_pci_probe+0x1a9/0x3c0 [amdgpu]
[3.868398]  local_pci_probe+0x41/0x80
[3.868401]  pci_device_probe+0xab/0x200
[3.868404]  really_probe+0x1a1/0x370
[3.868407]  __driver_probe_device+0xfc/0x170
[3.868410]  driver_probe_device+0x1f/0x90
[3.868412]  __driver_attach+0xbf/0x1a0
[3.868414]  ? __device_attach_driver+0xe0/0xe0
[3.868416]  bus_for_each_dev+0x65/0x90
[3.868419]  bus_add_driver+0x151/0x1f0
[3.868421]  driver_register+0x89/0xd0
[3.868423]  ? 0xc0bd4000
[3.868425]  do_one_initcall+0x5d/0x300
[3.868428]  ? do_init_module+0x22/0x240
[3.868431]  ? rcu_read_lock_sched_held+0x3c/0x70
[3.868434]  ? trace_kmalloc+0x30/0xe0
[3.868437]  ? kmem_cache_alloc_trace+0x1e6/0x3a0
[3.868440]  do_init_module+0x4a/0x240
[3.868442]  __do_sys_finit_module+0x93/0xf0
[3.868446]  do_syscall_64+0x5b/0x80
[3.868449]  ? rcu_read_lock_sched_held+0x3c/0x70
[3.868451]  ? lockdep_hardirqs_on_prepare+0xd9/0x180
[3.868454]  ? do_syscall_64+0x67/0x80
[3.868456]  ? do_syscall_64+0x67/0x80
[3.868458]  ? do_syscall_64+0x67/0x80
[3.868460]  ? do_syscall_64+0x67/0x80
[3.868462]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[3.868465] RIP: 0033:0x7fc4d8ec1ced
[3.868467] Code: 5d c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 
f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 
f0 ff ff 73 01 c3 48 8b 0d fb 70 0e 00 f7 d8 64 89 01 48
[3.868472] RSP: 002b:7fff687ae6b8 EFLAGS: 0246 ORIG_RAX: 
0139
[3.868475] RAX: ffda RBX: 560a76fbca60 RCX: 7fc4d8ec1ced
[3.868477] RDX:  RSI: 7fc4d902343c RDI: 0011
[3.868479] RBP: 7fc4d902343c R08:  R09: 560a76fb59c0
[3.868481] R10: 0011 R11: 0246 R12: 0002
[3.868484] R13: 560a76f8bfd0 R14:  R15: 560a76fc2d10
[3.868487]  
[3.868489] irq event stamp: 120617
[3.868490] hardirqs last  enabled at (120617): [] 
__up_console_sem+0x5e/0x70
[3.868494] hardirqs last