2021-12-27 15:05:51

by kernel test robot

[permalink] [raw]
Subject: [genirq/msi] 495c66aca3: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c



Greeting,

FYI, we noticed the following commit (built with gcc-9):

commit: 495c66aca3da704e063fa373fdbe371e71d3f4ee ("genirq/msi: Convert to new functions")
https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git irq/msi

in testcase: xfstests
version: xfstests-x86_64-972d710-1_20211221
with following parameters:

disk: 4HDD
fs: xfs
test: xfs-group-14
ucode: 0x21

test-description: xfstests is a regression test suite for xfs and other files ystems.
test-url: git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git


on test machine: 4 threads 1 sockets Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz with 8G memory

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):



If you fix the issue, kindly add following tag
Reported-by: kernel test robot <[email protected]>


kern :err : [ 126.209306] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:280
kern :err : [ 126.209308] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5183, name: ls
kern :err : [ 126.209311] preempt_count: 2, expected: 0
kern :warn : [ 126.209312] CPU: 2 PID: 5183 Comm: ls Not tainted 5.16.0-rc5-00091-g495c66aca3da #1
kern :warn : [ 126.209315] Hardware name: Hewlett-Packard HP Pro 3340 MT/17A1, BIOS 8.07 01/24/2013
kern :warn : [ 126.209316] Call Trace:
kern :warn : [ 126.209318] <TASK>
kern :warn : [ 126.209319] dump_stack_lvl (lib/dump_stack.c:107)
kern :warn : [ 126.209323] __might_resched.cold (kernel/sched/core.c:9539 kernel/sched/core.c:9492)
kern :warn : [ 126.209326] ? kasan_unpoison (mm/kasan/shadow.c:108 mm/kasan/shadow.c:142)
kern :warn : [ 126.209330] mutex_lock (kernel/locking/mutex.c:280)
kern :warn : [ 126.209335] ? __mutex_lock_slowpath (kernel/locking/mutex.c:279)
kern :warn : [ 126.209339] ? _raw_spin_lock_irqsave (arch/x86/include/asm/atomic.h:202 include/linux/atomic/atomic-instrumented.h:513 include/asm-generic/qspinlock.h:82 include/linux/spinlock.h:185 include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
kern :warn : [ 126.209342] ? _raw_read_unlock_irqrestore (kernel/locking/spinlock.c:161)
kern :warn : [ 126.209344] msi_get_virq (kernel/irq/msi.c:332)
kern :warn : [ 126.209349] pci_irq_vector (drivers/pci/msi/msi.c:1085 drivers/pci/msi/msi.c:1077)
kern :warn : [ 126.209354] rtl8169_netpoll (drivers/net/ethernet/realtek/r8169_main.c:4722)
kern :warn : [ 126.209358] netpoll_poll_dev (net/core/netpoll.c:166 net/core/netpoll.c:195)
kern :warn : [ 126.209363] netpoll_send_skb (net/core/netpoll.c:350 net/core/netpoll.c:376)
kern :warn : [ 126.209367] write_msg (drivers/net/netconsole.c:862 drivers/net/netconsole.c:836) netconsole
kern :warn : [ 126.209372] console_unlock (kernel/printk/printk.c:1929 kernel/printk/printk.c:2711)
kern :warn : [ 126.209375] ? do_syslog (kernel/printk/printk.c:2088)
kern :warn : [ 126.209378] ? prb_read_valid (kernel/printk/printk_ringbuffer.c:1928)
kern :warn : [ 126.209382] vprintk_emit (arch/x86/include/asm/preempt.h:85 kernel/printk/printk.c:2246)
kern :warn : [ 126.209384] ? unwind_next_frame (arch/x86/kernel/unwind_orc.c:600)
kern :warn : [ 126.209388] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.209502] _printk (kernel/printk/printk.c:2261)
kern :warn : [ 126.209505] ? record_print_text.cold (kernel/printk/printk.c:2261)
kern :warn : [ 126.209508] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.209621] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.209734] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.209851] ? __module_text_address (kernel/module.c:4768)
kern :warn : [ 126.209856] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.209968] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.210080] show_trace_log_lvl (arch/x86/kernel/dumpstack.c:284)
kern :warn : [ 126.210084] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.210197] ? xfs_dir2_sf_getdents+0x728/0xb40 xfs
kern :warn : [ 126.210309] dump_stack_lvl (lib/dump_stack.c:107)
kern :warn : [ 126.210313] xfs_corruption_error (fs/xfs/xfs_error.c:339 fs/xfs/xfs_error.c:324 fs/xfs/xfs_error.c:354) xfs
kern :warn : [ 126.210425] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.210536] ? __alloc_pages_slowpath+0x1f80/0x1f80
kern :warn : [ 126.210541] xfs_dir2_sf_getdents+0x728/0xb40 xfs
kern :warn : [ 126.210653] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.210764] ? __mod_memcg_lruvec_state (arch/x86/include/asm/atomic.h:95 include/linux/atomic/atomic-instrumented.h:182 mm/memcontrol.c:636 mm/memcontrol.c:632 mm/memcontrol.c:708)
kern :warn : [ 126.210769] xfs_readdir (fs/xfs/xfs_dir2_readdir.c:526) xfs
kern :warn : [ 126.210884] ? do_anonymous_page (mm/memory.c:3800)
kern :warn : [ 126.210889] ? xfs_dir3_get_dtype (fs/xfs/xfs_dir2_readdir.c:508) xfs
kern :warn : [ 126.211001] ? make_kgid (kernel/user_namespace.c:463)
kern :warn : [ 126.211006] ? xfs_vn_getattr (fs/xfs/xfs_iops.c:593) xfs
kern :warn : [ 126.211121] ? security_file_permission (arch/x86/include/asm/atomic64_64.h:22 include/linux/atomic/atomic-long.h:29 include/linux/atomic/atomic-instrumented.h:1184 include/linux/fsnotify.h:62 include/linux/fsnotify.h:99 include/linux/fsnotify.h:124 include/linux/fsnotify.h:103 security/security.c:1511)
kern :warn : [ 126.211125] iterate_dir (fs/readdir.c:65)
kern :warn : [ 126.211130] __x64_sys_getdents64 (fs/readdir.c:370 fs/readdir.c:354 fs/readdir.c:354)
kern :warn : [ 126.211133] ? filldir (fs/readdir.c:354)
kern :warn : [ 126.211135] ? handle_mm_fault (mm/memory.c:4784)
kern :warn : [ 126.211138] ? __ia32_sys_getdents64 (fs/readdir.c:312)
kern :warn : [ 126.211141] ? do_user_addr_fault (arch/x86/mm/fault.c:1423)
kern :warn : [ 126.211144] ? exit_to_user_mode_prepare (arch/x86/include/asm/entry-common.h:58 kernel/entry/common.c:209)
kern :warn : [ 126.211148] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
kern :warn : [ 126.211153] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:113)
kern :warn : [ 126.211156] RIP: 0033:0x7f82c632edd7
kern :warn : [ 126.211159] Code: 00 00 48 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 48 8b 47 20 c3 66 2e 0f 1f 84 00 00 00 00 00 90 b8 d9 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 89 90 0f 00 f7 d8 64 89 02 48
All code
========
0: 00 00 add %al,(%rax)
2: 48 83 c4 08 add $0x8,%rsp
6: 5b pop %rbx
7: 5d pop %rbp
8: c3 retq
9: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
10: 00 00 00
13: 48 8b 47 20 mov 0x20(%rdi),%rax
17: c3 retq
18: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
1f: 00 00 00
22: 90 nop
23: b8 d9 00 00 00 mov $0xd9,%eax
28: 0f 05 syscall
2a:* 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax <-- trapping instruction
30: 77 01 ja 0x33
32: c3 retq
33: 48 8b 15 89 90 0f 00 mov 0xf9089(%rip),%rdx # 0xf90c3
3a: f7 d8 neg %eax
3c: 64 89 02 mov %eax,%fs:(%rdx)
3f: 48 rex.W

Code starting with the faulting instruction
===========================================
0: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax
6: 77 01 ja 0x9
8: c3 retq
9: 48 8b 15 89 90 0f 00 mov 0xf9089(%rip),%rdx # 0xf9099
10: f7 d8 neg %eax
12: 64 89 02 mov %eax,%fs:(%rdx)
15: 48 rex.W
kern :warn : [ 126.211162] RSP: 002b:00007ffd9859b988 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
kern :warn : [ 126.211166] RAX: ffffffffffffffda RBX: 0000562c94087960 RCX: 00007f82c632edd7
kern :warn : [ 126.211168] RDX: 0000000000008000 RSI: 0000562c94087990 RDI: 0000000000000003
kern :warn : [ 126.211170] RBP: 0000562c94087990 R08: 0000000000000003 R09: 0000000000000078
kern :warn : [ 126.211172] R10: fffffffffffff5e9 R11: 0000000000000246 R12: fffffffffffffe98
kern :warn : [ 126.211174] R13: 0000000000000000 R14: 0000562c94087930 R15: 0000562c921bf8c1
kern :warn : [ 126.211176] </TASK>
kern :warn : [ 126.606948] ? __alloc_pages_slowpath+0x1f80/0x1f80
kern :warn : [ 126.613666] xfs_dir2_sf_getdents+0x728/0xb40 xfs
kern :warn : [ 126.620046] ? xfs_dir2_sf_getdents+0x6e1/0xb40 xfs
kern :warn : [ 126.626623] ? __mod_memcg_lruvec_state (arch/x86/include/asm/atomic.h:95 include/linux/atomic/atomic-instrumented.h:182 mm/memcontrol.c:636 mm/memcontrol.c:632 mm/memcontrol.c:708)
kern :warn : [ 126.632281] xfs_readdir (fs/xfs/xfs_dir2_readdir.c:526) xfs
kern :warn : [ 126.637258] ? do_anonymous_page (mm/memory.c:3800)
kern :warn : [ 126.642395] ? xfs_dir3_get_dtype (fs/xfs/xfs_dir2_readdir.c:508) xfs
kern :warn : [ 126.647995] ? make_kgid (kernel/user_namespace.c:463)
kern :warn : [ 126.652155] ? xfs_vn_getattr (fs/xfs/xfs_iops.c:593) xfs
kern :warn : [ 126.657573] ? security_file_permission (arch/x86/include/asm/atomic64_64.h:22 include/linux/atomic/atomic-long.h:29 include/linux/atomic/atomic-instrumented.h:1184 include/linux/fsnotify.h:62 include/linux/fsnotify.h:99 include/linux/fsnotify.h:124 include/linux/fsnotify.h:103 security/security.c:1511)
kern :warn : [ 126.663239] iterate_dir (fs/readdir.c:65)
kern :warn : [ 126.667598] __x64_sys_getdents64 (fs/readdir.c:370 fs/readdir.c:354 fs/readdir.c:354)
kern :warn : [ 126.672756] ? filldir (fs/readdir.c:354)
kern :warn : [ 126.676940] ? handle_mm_fault (mm/memory.c:4784)
kern :warn : [ 126.681806] ? __ia32_sys_getdents64 (fs/readdir.c:312)
kern :warn : [ 126.687177] ? do_user_addr_fault (arch/x86/mm/fault.c:1423)
kern :warn : [ 126.692697] ? exit_to_user_mode_prepare (arch/x86/include/asm/entry-common.h:58 kernel/entry/common.c:209)
kern :warn : [ 126.698444] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
kern :warn : [ 126.702804] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:113)
kern :warn : [ 126.708653] RIP: 0033:0x7f82c632edd7
kern :warn : [ 126.713002] Code: 00 00 48 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 48 8b 47 20 c3 66 2e 0f 1f 84 00 00 00 00 00 90 b8 d9 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 89 90 0f 00 f7 d8 64 89 02 48
All code
========
0: 00 00 add %al,(%rax)
2: 48 83 c4 08 add $0x8,%rsp
6: 5b pop %rbx
7: 5d pop %rbp
8: c3 retq
9: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
10: 00 00 00
13: 48 8b 47 20 mov 0x20(%rdi),%rax
17: c3 retq
18: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
1f: 00 00 00
22: 90 nop
23: b8 d9 00 00 00 mov $0xd9,%eax
28: 0f 05 syscall
2a:* 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax <-- trapping instruction
30: 77 01 ja 0x33
32: c3 retq
33: 48 8b 15 89 90 0f 00 mov 0xf9089(%rip),%rdx # 0xf90c3
3a: f7 d8 neg %eax
3c: 64 89 02 mov %eax,%fs:(%rdx)
3f: 48 rex.W

Code starting with the faulting instruction
===========================================
0: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax
6: 77 01 ja 0x9
8: c3 retq
9: 48 8b 15 89 90 0f 00 mov 0xf9089(%rip),%rdx # 0xf9099
10: f7 d8 neg %eax
12: 64 89 02 mov %eax,%fs:(%rdx)
15: 48 rex.W


To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
sudo bin/lkp install job.yaml # job file is attached in this email
bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run
sudo bin/lkp run generated-yaml-file

# if come across any failure that blocks the test,
# please remove ~/.lkp and /lkp dir to run from a clean state.



---
0DAY/LKP+ Test Infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation

Thanks,
Oliver Sang


Attachments:
(No filename) (12.15 kB)
config-5.16.0-rc5-00091-g495c66aca3da (173.67 kB)
job-script (5.73 kB)
kmsg.xz (27.25 kB)
xfstests (1.65 kB)
job.yaml (4.78 kB)
reproduce (884.00 B)
Download all attachments

2021-12-28 18:40:15

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [genirq/msi] 495c66aca3: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c

On Mon, Dec 27 2021 at 23:05, kernel test robot wrote:
>
> FYI, we noticed the following commit (built with gcc-9):
>
> commit: 495c66aca3da704e063fa373fdbe371e71d3f4ee ("genirq/msi: Convert to new functions")
> https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git irq/msi
> kern :err : [ 126.209306] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:280
> kern :err : [ 126.209308] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5183, name: ls
> kern :err : [ 126.209311] preempt_count: 2, expected: 0
> kern :warn : [ 126.209312] CPU: 2 PID: 5183 Comm: ls Not tainted 5.16.0-rc5-00091-g495c66aca3da #1
> kern :warn : [ 126.209315] Hardware name: Hewlett-Packard HP Pro 3340 MT/17A1, BIOS 8.07 01/24/2013
> kern :warn : [ 126.209316] Call Trace:
> kern :warn : [ 126.209318] <TASK>
> kern :warn : [ 126.209319] dump_stack_lvl (lib/dump_stack.c:107)
> kern :warn : [ 126.209323] __might_resched.cold (kernel/sched/core.c:9539 kernel/sched/core.c:9492)
> kern :warn : [ 126.209326] ? kasan_unpoison (mm/kasan/shadow.c:108 mm/kasan/shadow.c:142)
> kern :warn : [ 126.209330] mutex_lock (kernel/locking/mutex.c:280)
> kern :warn : [ 126.209335] ? __mutex_lock_slowpath (kernel/locking/mutex.c:279)
> kern :warn : [ 126.209339] ? _raw_spin_lock_irqsave (arch/x86/include/asm/atomic.h:202 include/linux/atomic/atomic-instrumented.h:513 include/asm-generic/qspinlock.h:82 include/linux/spinlock.h:185 include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
> kern :warn : [ 126.209342] ? _raw_read_unlock_irqrestore (kernel/locking/spinlock.c:161)
> kern :warn : [ 126.209344] msi_get_virq (kernel/irq/msi.c:332)
> kern :warn : [ 126.209349] pci_irq_vector (drivers/pci/msi/msi.c:1085 drivers/pci/msi/msi.c:1077)
> kern :warn : [ 126.209354] rtl8169_netpoll (drivers/net/ethernet/realtek/r8169_main.c:4722)
> kern :warn : [ 126.209358] netpoll_poll_dev (net/core/netpoll.c:166 net/core/netpoll.c:195)
> kern :warn : [ 126.209363] netpoll_send_skb (net/core/netpoll.c:350 net/core/netpoll.c:376)
> kern :warn : [ 126.209367] write_msg (drivers/net/netconsole.c:862 drivers/net/netconsole.c:836) netconsole

Fix below.

Thanks,

tglx
---
drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -615,6 +615,7 @@ struct rtl8169_private {
struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */
u16 cp_cmd;
u32 irq_mask;
+ int irq;
struct clk *clk;

struct {
@@ -4698,7 +4699,7 @@ static int rtl8169_close(struct net_devi

cancel_work_sync(&tp->wk.work);

- free_irq(pci_irq_vector(pdev, 0), tp);
+ free_irq(tp->irq, tp);

phy_disconnect(tp->phydev);

@@ -4719,7 +4720,7 @@ static void rtl8169_netpoll(struct net_d
{
struct rtl8169_private *tp = netdev_priv(dev);

- rtl8169_interrupt(pci_irq_vector(tp->pci_dev, 0), tp);
+ rtl8169_interrupt(tp->irq, tp);
}
#endif

@@ -4753,8 +4754,7 @@ static int rtl_open(struct net_device *d
rtl_request_firmware(tp);

irqflags = pci_dev_msi_enabled(pdev) ? IRQF_NO_THREAD : IRQF_SHARED;
- retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
- irqflags, dev->name, tp);
+ retval = request_irq(tp->irq, rtl8169_interrupt, irqflags, dev->name, tp);
if (retval < 0)
goto err_release_fw_2;

@@ -4771,7 +4771,7 @@ static int rtl_open(struct net_device *d
return retval;

err_free_irq:
- free_irq(pci_irq_vector(pdev, 0), tp);
+ free_irq(tp->irq, tp);
err_release_fw_2:
rtl_release_firmware(tp);
rtl8169_rx_clear(tp);
@@ -5341,6 +5341,7 @@ static int rtl_init_one(struct pci_dev *
dev_err(&pdev->dev, "Can't allocate interrupt\n");
return rc;
}
+ tp->irq = pci_irq_vector(pdev, 0);

INIT_WORK(&tp->wk.work, rtl_task);

@@ -5416,8 +5417,7 @@ static int rtl_init_one(struct pci_dev *
return rc;

netdev_info(dev, "%s, %pM, XID %03x, IRQ %d\n",
- rtl_chip_infos[chipset].name, dev->dev_addr, xid,
- pci_irq_vector(pdev, 0));
+ rtl_chip_infos[chipset].name, dev->dev_addr, xid, tp->irq);

if (jumbo_max)
netdev_info(dev, "jumbo features [frames: %d bytes, tx checksumming: %s]\n",

2021-12-28 19:26:05

by Heiner Kallweit

[permalink] [raw]
Subject: Re: [genirq/msi] 495c66aca3: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c

On 28.12.2021 19:40, Thomas Gleixner wrote:
> On Mon, Dec 27 2021 at 23:05, kernel test robot wrote:
>>
>> FYI, we noticed the following commit (built with gcc-9):
>>
>> commit: 495c66aca3da704e063fa373fdbe371e71d3f4ee ("genirq/msi: Convert to new functions")
>> https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git irq/msi
>> kern :err : [ 126.209306] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:280
>> kern :err : [ 126.209308] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5183, name: ls
>> kern :err : [ 126.209311] preempt_count: 2, expected: 0
>> kern :warn : [ 126.209312] CPU: 2 PID: 5183 Comm: ls Not tainted 5.16.0-rc5-00091-g495c66aca3da #1
>> kern :warn : [ 126.209315] Hardware name: Hewlett-Packard HP Pro 3340 MT/17A1, BIOS 8.07 01/24/2013
>> kern :warn : [ 126.209316] Call Trace:
>> kern :warn : [ 126.209318] <TASK>
>> kern :warn : [ 126.209319] dump_stack_lvl (lib/dump_stack.c:107)
>> kern :warn : [ 126.209323] __might_resched.cold (kernel/sched/core.c:9539 kernel/sched/core.c:9492)
>> kern :warn : [ 126.209326] ? kasan_unpoison (mm/kasan/shadow.c:108 mm/kasan/shadow.c:142)
>> kern :warn : [ 126.209330] mutex_lock (kernel/locking/mutex.c:280)
>> kern :warn : [ 126.209335] ? __mutex_lock_slowpath (kernel/locking/mutex.c:279)
>> kern :warn : [ 126.209339] ? _raw_spin_lock_irqsave (arch/x86/include/asm/atomic.h:202 include/linux/atomic/atomic-instrumented.h:513 include/asm-generic/qspinlock.h:82 include/linux/spinlock.h:185 include/linux/spinlock_api_smp.h:111 kernel/locking/spinlock.c:162)
>> kern :warn : [ 126.209342] ? _raw_read_unlock_irqrestore (kernel/locking/spinlock.c:161)
>> kern :warn : [ 126.209344] msi_get_virq (kernel/irq/msi.c:332)
>> kern :warn : [ 126.209349] pci_irq_vector (drivers/pci/msi/msi.c:1085 drivers/pci/msi/msi.c:1077)
>> kern :warn : [ 126.209354] rtl8169_netpoll (drivers/net/ethernet/realtek/r8169_main.c:4722)
>> kern :warn : [ 126.209358] netpoll_poll_dev (net/core/netpoll.c:166 net/core/netpoll.c:195)
>> kern :warn : [ 126.209363] netpoll_send_skb (net/core/netpoll.c:350 net/core/netpoll.c:376)
>> kern :warn : [ 126.209367] write_msg (drivers/net/netconsole.c:862 drivers/net/netconsole.c:836) netconsole
>
> Fix below.
>
> Thanks,
>
> tglx
> ---
> drivers/net/ethernet/realtek/r8169_main.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -615,6 +615,7 @@ struct rtl8169_private {
> struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */
> u16 cp_cmd;
> u32 irq_mask;
> + int irq;
> struct clk *clk;
>
> struct {
> @@ -4698,7 +4699,7 @@ static int rtl8169_close(struct net_devi
>
> cancel_work_sync(&tp->wk.work);
>
> - free_irq(pci_irq_vector(pdev, 0), tp);
> + free_irq(tp->irq, tp);
>
> phy_disconnect(tp->phydev);
>
> @@ -4719,7 +4720,7 @@ static void rtl8169_netpoll(struct net_d
> {
> struct rtl8169_private *tp = netdev_priv(dev);
>
> - rtl8169_interrupt(pci_irq_vector(tp->pci_dev, 0), tp);
> + rtl8169_interrupt(tp->irq, tp);
> }
> #endif
>
> @@ -4753,8 +4754,7 @@ static int rtl_open(struct net_device *d
> rtl_request_firmware(tp);
>
> irqflags = pci_dev_msi_enabled(pdev) ? IRQF_NO_THREAD : IRQF_SHARED;
> - retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
> - irqflags, dev->name, tp);
> + retval = request_irq(tp->irq, rtl8169_interrupt, irqflags, dev->name, tp);
> if (retval < 0)
> goto err_release_fw_2;
>
> @@ -4771,7 +4771,7 @@ static int rtl_open(struct net_device *d
> return retval;
>
> err_free_irq:
> - free_irq(pci_irq_vector(pdev, 0), tp);
> + free_irq(tp->irq, tp);
> err_release_fw_2:
> rtl_release_firmware(tp);
> rtl8169_rx_clear(tp);
> @@ -5341,6 +5341,7 @@ static int rtl_init_one(struct pci_dev *
> dev_err(&pdev->dev, "Can't allocate interrupt\n");
> return rc;
> }
> + tp->irq = pci_irq_vector(pdev, 0);
>
> INIT_WORK(&tp->wk.work, rtl_task);
>
> @@ -5416,8 +5417,7 @@ static int rtl_init_one(struct pci_dev *
> return rc;
>
> netdev_info(dev, "%s, %pM, XID %03x, IRQ %d\n",
> - rtl_chip_infos[chipset].name, dev->dev_addr, xid,
> - pci_irq_vector(pdev, 0));
> + rtl_chip_infos[chipset].name, dev->dev_addr, xid, tp->irq);
>
> if (jumbo_max)
> netdev_info(dev, "jumbo features [frames: %d bytes, tx checksumming: %s]\n",

Thanks for the patch, I'll submit it with your SoB.

Apart from pci_irq_vector() incl. underlying msi_get_virq(), are there more functions
that must not be called from atomic context any longer? Maybe the new constraint
should be added to kernel-doc of affected functions?

2022-01-10 20:43:42

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [genirq/msi] 495c66aca3: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c

On Tue, Dec 28 2021 at 20:25, Heiner Kallweit wrote:
> On 28.12.2021 19:40, Thomas Gleixner wrote:
>> if (jumbo_max)
>> netdev_info(dev, "jumbo features [frames: %d bytes, tx checksumming: %s]\n",
>
> Thanks for the patch, I'll submit it with your SoB.

Thank you!

> Apart from pci_irq_vector() incl. underlying msi_get_virq(), are there
> more functions that must not be called from atomic context any longer?

I don't think so. The allocation/free functions were always restricted
to preemptible context.

> Maybe the new constraint should be added to kernel-doc of affected
> functions?

Probably.

Thanks,

tglx