anolis: intel_th: replaces spin_lock with mutex_lock

ANBZ: #13367

Call Trace:
 <TASK>
 dump_stack_lvl+0x36/0x50
 __schedule_bug+0x52/0x60
 __schedule+0x5bb/0x700
 ? selinux_kernfs_init_security+0x5b/0x200
 schedule+0x5e/0xd0
 schedule_preempt_disabled+0x15/0x30
 rwsem_down_write_slowpath+0x208/0x4e0
 down_write+0x5b/0x60
 kernfs_add_one+0x38/0x150
 kernfs_create_link+0x64/0xb0
 sysfs_do_create_link_sd+0x63/0xe0
 bus_add_device+0x6c/0x140
 device_add+0x3b6/0x6f0
 intel_th_subdevice_alloc+0x1b8/0x320 [intel_th]
 ? rpm_suspend+0x687/0x6a0
 ? rwsem_wake.isra.0+0x69/0x90
 ? rpm_check_suspend_allowed+0x54/0xb0
 intel_th_alloc+0x1d6/0x350 [intel_th]
 intel_th_pci_probe+0x327/0x370 [intel_th_pci]
 local_pci_probe+0x42/0xa0
 p ci_call_probe+0x51/0x160
 pci_device_probe+0x83/0x100
 ? driver_sysfs_add+0x5d/0xc0
 really_probe+0x1ae/0x410
 ? __pfx___driver_attach+0x10/0x10
 __driver_probe_device+0x7b/0x160
 driver_probe_device+0x1f/0x90
 __driver_attach+0xd8/0x1d0
 bus_for_each_dev+0x74/0xc0
 bus_add_driver+0x115/0x240
 driver_register+0x59/0x100
 ? __pfx_intel_th_pci_driver_init+0x10/0x10 [intel_th_pci]
 do_one_initcall+0x47/0x300
 ? kmalloc_trace+0x2a/0xa0
 do_init_module+0x60/0x240
 init_module_from_file+0x86/0xc0
 idempotent_init_module+0x109/0x300
 __x64_sys_finit_module+0x5e/0xb0
 do_syscall_64+0x38/0x80
 entry_SYSCALL_64_after_hwframe+0x78/0xe2
RIP: 0033:0x7f5afb1ea9cd
RSP: 002b:00007fffbc3da6e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 000055711345d260 RCX: 00007f5afb1ea9cd
RDX: 0000000000000000 RSI: 00007f5afb6f283d RDI: 000000000000000f
RBP: 0000000000020000 R08: 0000000000000000 R09: 00007fffbc3da810
R10: 000000000000000f R11: 0000000000000246 R12: 00007f5afb6f283d
R13: 0000000000000000 R14: 000055711346e2c0 R15: 000055711345d260

Fixes: 203ec762ca ("anolis: intel_th: Fixing occasional device number duplication issue with intel_th driver.")
Signed-off-by: wangkaiyuan <wangkaiyuan@inspur.com>
Reviewed-by: Bitao Hu <yaoma@linux.alibaba.com>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/4757
This commit is contained in:
wangkaiyuan 2025-02-28 13:55:23 +08:00 committed by 小龙
parent 797aae63f0
commit 772fd766e9
1 changed files with 10 additions and 10 deletions

View File

@ -17,14 +17,14 @@
#include <linux/pci.h>
#include <linux/pm_runtime.h>
#include <linux/dma-mapping.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include "intel_th.h"
#include "debug.h"
static bool host_mode __read_mostly;
module_param(host_mode, bool, 0444);
static DEFINE_SPINLOCK(intel_th_lock);
static DEFINE_MUTEX(intel_th_lock);
static DEFINE_IDA(intel_th_ida);
@ -718,7 +718,7 @@ int intel_th_output_enable(struct intel_th *th, unsigned int otype)
{
struct intel_th_device *thdev;
int src = 0, dst = 0;
spin_lock(&intel_th_lock);
mutex_lock(&intel_th_lock);
for (src = 0, dst = 0; dst <= th->num_thdevs; src++, dst++) {
for (; src < ARRAY_SIZE(intel_th_subdevices); src++) {
if (intel_th_subdevices[src].type != INTEL_TH_OUTPUT)
@ -732,7 +732,7 @@ int intel_th_output_enable(struct intel_th *th, unsigned int otype)
/* no unallocated matching subdevices */
if (src == ARRAY_SIZE(intel_th_subdevices)) {
spin_unlock(&intel_th_lock);
mutex_unlock(&intel_th_lock);
return -ENODEV;
}
@ -753,18 +753,18 @@ int intel_th_output_enable(struct intel_th *th, unsigned int otype)
if (dst == th->num_thdevs)
goto found;
}
spin_unlock(&intel_th_lock);
mutex_unlock(&intel_th_lock);
return -ENODEV;
found:
thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]);
if (IS_ERR(thdev)) {
spin_unlock(&intel_th_lock);
mutex_unlock(&intel_th_lock);
return PTR_ERR(thdev);
}
th->thdev[th->num_thdevs++] = thdev;
spin_unlock(&intel_th_lock);
mutex_unlock(&intel_th_lock);
return 0;
}
EXPORT_SYMBOL_GPL(intel_th_output_enable);
@ -773,7 +773,7 @@ static int intel_th_populate(struct intel_th *th)
{
int src;
spin_lock(&intel_th_lock);
mutex_lock(&intel_th_lock);
/* create devices for each intel_th_subdevice */
for (src = 0; src < ARRAY_SIZE(intel_th_subdevices); src++) {
const struct intel_th_subdevice *subdev =
@ -799,14 +799,14 @@ static int intel_th_populate(struct intel_th *th)
/* ENODEV for individual subdevices is allowed */
if (PTR_ERR(thdev) == -ENODEV)
continue;
spin_unlock(&intel_th_lock);
mutex_unlock(&intel_th_lock);
return PTR_ERR(thdev);
}
th->thdev[th->num_thdevs++] = thdev;
}
spin_unlock(&intel_th_lock);
mutex_unlock(&intel_th_lock);
return 0;
}