From nobody Tue Jan 18 20:15:37 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 596341966D84; Tue, 18 Jan 2022 20:15:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jdg4p0HWfz57tW; Tue, 18 Jan 2022 20:15:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642536938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aZOqTOC28ga3Mph7amxREFyp9lrIV75QG5XrytKmoBI=; b=DJ3wOsCMRv+kXy5Wcu/BoAqi8Y0ycaYh46icvPUym+A6Sz0AeWEOXi28JbM0vOjk5ryO2/ qhDhS9EwyMagqUr0UQwnbU0V4FXacHUDvU6XJ/N7WbYuPRN9+Hop+tLpMf13pLZu4WhyD+ i3MQJomkrw8lfYJL/sWhm4lwBa0/m59V50kV65VzwZdFW+T8QY+sgNcrPRspzx+DSrCTeq QfSr77Lx9/3K1pkmhuYDZAiuUNeN41Y4McHEn/nuIyKJxS3HH+pWq893xhChjDpcokz8VL Pjs60wNmcq8X8ksLwwn9WGsyLykqX6aBUFq+ZiMskwaiKl3TGHQIHoq5rkB5RQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1922278E1; Tue, 18 Jan 2022 20:15:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20IKFbLm053972; Tue, 18 Jan 2022 20:15:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20IKFbGc053971; Tue, 18 Jan 2022 20:15:37 GMT (envelope-from git) Date: Tue, 18 Jan 2022 20:15:37 GMT Message-Id: <202201182015.20IKFbGc053971@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 89889ab470b9 - main - LinuxKPI: Allow wake_up to be executed within a critical section List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 89889ab470b9f1a1cd36913dd219b78efbf484df Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642536938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aZOqTOC28ga3Mph7amxREFyp9lrIV75QG5XrytKmoBI=; b=Gr+KwzC2yb2y5F3kZYX41sfgSsbyrXXlrPTkI+Ost/K6z9wC979uV5WXAPTdcgZRwXlQW/ S/aV9JtLRSYqul6wq6QEutjc+Qpqnm/OLxFV0ZEtR1X6zXflmqDbX3SCSRXCdhVXZp2Idg odxWMm/aY2am8f8KA39dRGfSPaxyTs0kySjdpadH3Eq6b5LKB9T/rkfgSvKNqCO6pbpcNA HyXLQXfX2ay5FtGkTogAdr7S5JPD1Bc6alp10ZIajPDKX3EUCldNM/gkSk31wFaZuv64hF lblalap0so1/Yb6XxHRLZt5eiNcW2HdDqL8Pur7Ehq4140H5ePi3fvlXjwo/yg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642536938; a=rsa-sha256; cv=none; b=HJpBOi2Agv81fMI76JoWzXnQaU/vzNhkoA47UjNjSAfOBarYg8RC5X0Gqni53Wm6LjMr6s R29nVgfLq5jRScceWZj2mn++rztiOL2P7Gwbny9hGllz1R7O5C3ZnIejqcIDFx7y8Y+Fsv Q1M9PKOF/Dqg+AVcDvCl47vTPBwnOZP6eJ34UEe9G6lVO3hUA1dcsxQqoBliq758YKBKQl vS61N4uw25tFxxVO2MgQ9OUDYHpE8jeUVHkh7NYrb7rzWVqr0mgZnwboIQOJdOt7SPzIKZ L72fVkz1XE1hIfCxQfYgpJqCFRwJX4ORhti3nE42+v570Eh4PW6+CgClkIze5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=89889ab470b9f1a1cd36913dd219b78efbf484df commit 89889ab470b9f1a1cd36913dd219b78efbf484df Author: Vladimir Kondratyev AuthorDate: 2022-01-18 20:14:13 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-01-18 20:14:13 +0000 LinuxKPI: Allow wake_up to be executed within a critical section by replaceing of spin_lock() call with spin_lock_irqsave() This fixes following panic in drm-kmod: panic: mi_switch: switch in a critical section cpuid = 2 time = 1636939794 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b vpanic() at vpanic+0x187 panic() at panic+0x43 mi_switch() at mi_switch+0x198 __mtx_lock_sleep() at __mtx_lock_sleep+0x1c9 __mtx_lock_flags() at __mtx_lock_flags+0xa2 linux_wake_up() at linux_wake_up+0x38 __active_retire() at __active_retire+0xb7 dma_fence_signal() at dma_fence_signal+0x100 dma_resv_add_shared_fence() at dma_resv_add_shared_fence+0x96 i915_gem_do_execbuffer() at i915_gem_do_execbuffer+0x11d0 i915_gem_execbuffer2_ioctl() at i915_gem_execbuffer2_ioctl+0x19a drm_ioctl_kernel() at drm_ioctl_kernel+0x72 drm_ioctl() at drm_ioctl+0x2c4 linux_file_ioctl() at linux_file_ioctl+0x297 kern_ioctl() at kern_ioctl+0x1dc sys_ioctl() at sys_ioctl+0x124 amd64_syscall() at amd64_syscall+0x124 fast_syscall_common() at fast_syscall_common+0xf8 --- syscall (54, FreeBSD ELF64, sys_ioctl) MFC after: 1 week Reviewed by: manu Reported by: Graham Perrin PR: 261166 Differential Revision: https://reviews.freebsd.org/D33888 --- sys/compat/linuxkpi/common/src/linux_schedule.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_schedule.c b/sys/compat/linuxkpi/common/src/linux_schedule.c index 656d8697d169..02074be8eb19 100644 --- a/sys/compat/linuxkpi/common/src/linux_schedule.c +++ b/sys/compat/linuxkpi/common/src/linux_schedule.c @@ -202,9 +202,11 @@ void linux_wake_up(wait_queue_head_t *wqh, unsigned int state, int nr, bool locked) { wait_queue_t *pos, *next; + unsigned long flags; if (!locked) - spin_lock(&wqh->lock); + spin_lock_irqsave(&wqh->lock, flags); + list_for_each_entry_safe(pos, next, &wqh->task_list, task_list) { if (pos->func == NULL) { if (wake_up_task(pos->private, state) != 0 && --nr == 0) @@ -215,7 +217,7 @@ linux_wake_up(wait_queue_head_t *wqh, unsigned int state, int nr, bool locked) } } if (!locked) - spin_unlock(&wqh->lock); + spin_unlock_irqrestore(&wqh->lock, flags); } void