From nobody Mon Oct 14 05:41:02 2024 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 4XRmL75Jklz5ZCw1; Mon, 14 Oct 2024 05:41:03 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XRmL72FN2z40ww; Mon, 14 Oct 2024 05:41:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728884463; 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=NkN+LiHHiPd5+BkbIsvbp2aWArPAZnVbi+Gp9lgDsRA=; b=PYLplp2JGHEQdhqBdu73hs06LfdqYyPwo3WLss7QeD2oUHs9SxLhQskjB9IKVErIuHvKlX S8WgGfEQN4evuHXYgOpkrGXoTtPNnvhYaBncfRAz8NxiS+2OBL6ld/Sgd5ti1cc05WPytP eNw3VEoZun+N82B8mrGZ1+8HkNTgKjVcGswMdG4vZyMqyCNCWINfA8QF41OzBQV7U+shOc XMV9ypRggzePhdLbY5oH03eQ55GT02HCeHz1bSG2t4HdA8ev0BmAFSeJRCZP6kdsB8EeW7 ZqFS/bBmY/Lan2yb8yPIqfatTXGOLwhaer15//yDA53UeaGCaVH/n+XcGnBbhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728884463; 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=NkN+LiHHiPd5+BkbIsvbp2aWArPAZnVbi+Gp9lgDsRA=; b=s+DLwiQxTnYnyx9K625vv6yUQ6ICHks7Um6kFPsR4QbuOxfqDihJDAPvJ58G8E5dkdQMpM Jhfi4jgtMsBVXGLdk+SdB5IyHkMbAcEO760mQAzuZHgMfkTlmOLKBsUumpk238drsBrur2 fjEJHSNpV2qBebis6lGOhlb2UCf//NwqB+/q6EhNYv/r5eFSNFgCyH/2y+QPAqHlb5nsUN sffLBCm1NqRGsiUykXReY2hfRkcn0Tqb1u9/hkJdO2c+sLMJ0VmV7OLVDz0ctNdWbQB2WI xA98jJt0DoJdjL7uRE+Hblx72wNrXSlgIOvWCCKjs36R1TKUP3ycr0hKK0Hy5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728884463; a=rsa-sha256; cv=none; b=GHZZhzcYIWSXNclv9Ir06ZIawIKBjcxYwZu+S19JznvdjwHQKpIsWcaP57OeDSR/WmqhW2 3ptZMOilQx0DJ/2ODt3KF5aRHlnR8WOQ6ly4QifIIJ4Fht1SGGriOMqt3830TIeSUnarPA TTYeeylBuZwmIWSC7u1cCVjqJwYUuDi5Bw3SPdiu+AJ5G2QVSpb5N2u04iWLV3yyGpjCt2 L4P8hzmd42wViMRLjfofYA4ZDaJFC4bKdvrqMq5EgrkaMceHF72UuWbWAFCBEZpQSd+LMp 1nr0Pby/XnS3waznLIDxRyv7xlr8cfOX0uM2IUaa8YDg47PNqqXGFHH4gj39Jw== 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 4XRmL70T0dzQXJ; Mon, 14 Oct 2024 05:41:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49E5f2u2089790; Mon, 14 Oct 2024 05:41:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49E5f22t089787; Mon, 14 Oct 2024 05:41:02 GMT (envelope-from git) Date: Mon, 14 Oct 2024 05:41:02 GMT Message-Id: <202410140541.49E5f22t089787@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: b339ab149105 - main - ciss: Don't panic on null CR ciss_dequeue_notify 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b339ab1491055d89415f85b6d1a03423193178f9 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b339ab1491055d89415f85b6d1a03423193178f9 commit b339ab1491055d89415f85b6d1a03423193178f9 Author: Peter Eriksson AuthorDate: 2024-10-14 04:01:33 +0000 Commit: Warner Losh CommitDate: 2024-10-14 05:37:46 +0000 ciss: Don't panic on null CR ciss_dequeue_notify Apparently, sometimes on hot plug/unplug, a null cr comes back from ciss_dequeue_notify. This is clearly a bug, and by ignoring it we're papering over that bug. We only ever wake the thread after enqueing a notification or setting a bit about killing the thread, so once we check the bit isn't the cause, cr can't be NULL unless something else has dequeued it. Ideally, this would be fixed, rather than papered over, but this makes a very old card somewhat more useable for external enclosures. I suspect it's a race when we set CISS_THREAD_SHUT and another flag (the latter w/o ciss_mtx held), but I don't see it and w/o hardware to reproduce it would be hard to know for sure. PR: 246279 Reviewed by: imp Tested by: Marek Zarychta Differential Revision: https://reviews.freebsd.org/D25155 --- sys/dev/ciss/ciss.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index d4786302d928..d4ede91f6b35 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -4207,8 +4207,20 @@ ciss_notify_thread(void *arg) cr = ciss_dequeue_notify(sc); - if (cr == NULL) - panic("cr null"); + if (cr == NULL) { + /* + * We get a NULL message sometimes when unplugging/replugging + * stuff But this indicates a bug, since we only wake this thread + * when we (a) set the THREAD_SHUT flag, or (b) we have enqueued + * something. Since it's reported around errors, it may be a + * locking bug related to ciss_flags being modified in multiple + * threads some without ciss_mtx held. Or there's some other + * way we either fail to sleep or corrupt the ciss_flags. + */ + ciss_printf(sc, "Driver bug: NULL notify event received\n"); + continue; + } + cn = (struct ciss_notify *)cr->cr_data; switch (cn->class) {