mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>,
	<UNGLinuxDriver@microchip.com>, <andrew+netdev@lunn.ch>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] lan966x: Fix sleeping in atomic context
Date: Wed, 5 Nov 2025 14:38:42 -0800	[thread overview]
Message-ID: <a9d52718-0d4d-4d57-a00d-82b3e66e158a@intel.com> (raw)
In-Reply-To: <20251105074955.1766792-1-horatiu.vultur@microchip.com>


[-- Attachment #1.1: Type: text/plain, Size: 1983 bytes --]



On 11/4/2025 11:49 PM, Horatiu Vultur wrote:
> The following warning was seen when we try to connect using ssh to the device.
> 
> BUG: sleeping function called from invalid context at kernel/locking/mutex.c:575
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 104, name: dropbear
> preempt_count: 1, expected: 0
> INFO: lockdep is turned off.
> CPU: 0 UID: 0 PID: 104 Comm: dropbear Tainted: G        W           6.18.0-rc2-00399-g6f1ab1b109b9-dirty #530 NONE
> Tainted: [W]=WARN
> Hardware name: Generic DT based system
> Call trace:
>  unwind_backtrace from show_stack+0x10/0x14
>  show_stack from dump_stack_lvl+0x7c/0xac
>  dump_stack_lvl from __might_resched+0x16c/0x2b0
>  __might_resched from __mutex_lock+0x64/0xd34
>  __mutex_lock from mutex_lock_nested+0x1c/0x24
>  mutex_lock_nested from lan966x_stats_get+0x5c/0x558
>  lan966x_stats_get from dev_get_stats+0x40/0x43c
>  dev_get_stats from dev_seq_printf_stats+0x3c/0x184
>  dev_seq_printf_stats from dev_seq_show+0x10/0x30
>  dev_seq_show from seq_read_iter+0x350/0x4ec
>  seq_read_iter from seq_read+0xfc/0x194
>  seq_read from proc_reg_read+0xac/0x100
>  proc_reg_read from vfs_read+0xb0/0x2b0
>  vfs_read from ksys_read+0x6c/0xec
>  ksys_read from ret_fast_syscall+0x0/0x1c
> Exception stack(0xf0b11fa8 to 0xf0b11ff0)
> 1fa0:                   00000001 00001000 00000008 be9048d8 00001000 00000001
> 1fc0: 00000001 00001000 00000008 00000003 be905920 0000001e 00000000 00000001
> 1fe0: 0005404c be9048c0 00018684 b6ec2cd8
> 
> It seems that we are using a mutex in a atomic context which is wrong.
> Change the mutex with a spinlock.
> 

Its a bit hard from just the diff context to confirm that a spinlock is
ok. I checked all the uses of stats_lock and they appear to be covering
only simple register reads and counter accumulations. None of the blocks
looked terribly lock, so a spin lock is probably fine.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2025-11-05 22:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05  7:49 Horatiu Vultur
2025-11-05 22:38 ` Jacob Keller [this message]
2025-11-06 15:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9d52718-0d4d-4d57-a00d-82b3e66e158a@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®