NetBSD Problem Report #54664
From www@netbsd.org Wed Oct 30 17:55:02 2019
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C3D937A1D3
for <gnats-bugs@gnats.NetBSD.org>; Wed, 30 Oct 2019 17:55:02 +0000 (UTC)
Message-Id: <20191030175501.4AD167A25B@mollari.NetBSD.org>
Date: Wed, 30 Oct 2019 17:55:01 +0000 (UTC)
From: tnn@nygren.pp.se
Reply-To: tnn@nygren.pp.se
To: gnats-bugs@NetBSD.org
Subject: fdtbus_regulator_acquire lockdebug error
X-Send-Pr-Version: www-1.0
>Number: 54664
>Category: port-evbarm
>Synopsis: fdtbus_regulator_acquire lockdebug error
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: jmcneill
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 30 18:00:00 +0000 2019
>Closed-Date: Sun Aug 08 15:24:29 +0000 2021
>Last-Modified: Sun Aug 08 15:25:01 +0000 2021
>Originator: Tobias Nygren
>Release: 9.99.17
>Organization:
>Environment:
>Description:
lock address : 0x0000000090eba31c type : spin
initialized : 0x000000008003c210
shared holds : 0 exclusive: 1
shares wanted: 0 exclusive: 0
current cpu : 0 last held: 0
current lwp : 0x000000008078b700 last held: 0x000000008078b700
last locked* : 0x000000008003cb00 unlocked : 0x000000008003cce8
owner field : 0x0000000000010500 wait/spin: 0/1
panic: LOCKDEBUG: Mutex error: assert_sleepable,70: spin lock held
cpu0: Begin traceback...
0x80aed9fc: netbsd:db_panic+0x14
0x80aeda14: netbsd:vpanic+0x194
0x80aeda2c: netbsd:snprintf
0x80aeda6c: netbsd:lockdebug_more
0x80aeda9c: netbsd:lockdebug_barrier+0xd0
0x80aedac4: netbsd:assert_sleepable+0x40
0x80aedb14: netbsd:pool_cache_get_paddr+0x1bc
0x80aedb3c: netbsd:kmem_intr_alloc+0x68
0x80aedb5c: netbsd:kmem_alloc+0x5c
0x80aedb74: netbsd:fdtbus_regulator_acquire+0x6c
0x80aedbec: netbsd:sunxi_pinctrl_set_config+0x2d4
0x80aedc24: netbsd:fdtbus_pinctrl_set_config_index+0xcc
0x80aedc44: netbsd:fdtbus_pinctrl_set_config+0x40
0x80aedc64: netbsd:fdt_pre_attach+0x64
0x80aeddcc: netbsd:fdt_scan+0x174
0x80aeddec: netbsd:fdt_rescan+0x5c
0x80aede24: netbsd:config_attach_loc+0x1b4
0x80aede54: netbsd:config_found_sm_loc+0x54
0x80aede6c: netbsd:config_found+0x2c
0x80aedea4: netbsd:arm_fdt_attach+0x68
0x80aededc: netbsd:config_attach_loc+0x1b4
0x80aedf04: netbsd:config_rootfound+0x48
0x80aedf24: netbsd:cpu_configure+0x58
0x80aedf9c: netbsd:main+0x2e0
0x80aedfac: netbsd:kernel_text+0x50
cpu0: End traceback...
>How-To-Repeat:
Boot LOCKDEBUG kernel on sunxi.
>Fix:
The problem is that sunxi_pinctrl_set_config() calls fdtbus_regulator_acquire() with spin mutex sunxi_gpio_softc.sc_lock held, but fdtbus_regulator_acquire() calls kmem_alloc with flag KM_SLEEP. That's not permitted.
Either make fdtbus_regulator_acquire() use KM_NOSLEEP or refactor it's callers to not hold spin mutexes.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-evbarm-maintainer->jmcneill
Responsible-Changed-By: jmcneill@NetBSD.org
Responsible-Changed-When: Sun, 08 Aug 2021 15:24:29 +0000
Responsible-Changed-Why:
take
State-Changed-From-To: open->closed
State-Changed-By: jmcneill@NetBSD.org
State-Changed-When: Sun, 08 Aug 2021 15:24:29 +0000
State-Changed-Why:
Fixed
From: "Jared D. McNeill" <jmcneill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54664 CVS commit: src/sys/dev/fdt
Date: Sun, 8 Aug 2021 15:23:42 +0000
Module Name: src
Committed By: jmcneill
Date: Sun Aug 8 15:23:42 UTC 2021
Modified Files:
src/sys/dev/fdt: fdt_regulator.c
Log Message:
fdt: regulator: pre-allocate regulator handle
Workaround for PR# port-evbarm/54664
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/fdt/fdt_regulator.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.