From owner-dev-commits-src-all@freebsd.org Thu Jan 21 23:20:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 80F1F4E33C3; Thu, 21 Jan 2021 23:20:50 +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 4DMJKZ1StNz3LKv; Thu, 21 Jan 2021 23:20:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 F0B31145E9; Thu, 21 Jan 2021 23:20:49 +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 10LNKnjQ071859; Thu, 21 Jan 2021 23:20:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10LNKnuF071858; Thu, 21 Jan 2021 23:20:49 GMT (envelope-from git) Date: Thu, 21 Jan 2021 23:20:49 GMT Message-Id: <202101212320.10LNKnuF071858@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marius Strobl Subject: git: 2dcbf0462e17 - main - sym(4): handle mixed tagged/untagged commands gracefully MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: marius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2dcbf0462e17db1b0a8cc99d1f95a7b0ba6437b2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jan 2021 23:20:51 -0000 The branch main has been updated by marius: URL: https://cgit.FreeBSD.org/src/commit/?id=2dcbf0462e17db1b0a8cc99d1f95a7b0ba6437b2 commit 2dcbf0462e17db1b0a8cc99d1f95a7b0ba6437b2 Author: Marius Strobl AuthorDate: 2021-01-21 22:48:08 +0000 Commit: Marius Strobl CommitDate: 2021-01-21 23:18:39 +0000 sym(4): handle mixed tagged/untagged commands gracefully Handle the case of a tagged command arriving when there's an untagged one still outstanding gracefully instead of panicing. While at it: - Replace fancy arithmetics with a simple assignment as busy_itl can only ever be either 0 or 1. - Fix a comment typo in sym_free_ccb(). --- sys/dev/sym/sym_hipd.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index f1c058f75c52..61104f75fd92 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -6291,13 +6291,12 @@ static ccb_p sym_get_ccb (hcb_p np, u_char tn, u_char ln, u_char tag_order) goto out_free; } else { /* - * If we have been asked for a tagged command. + * If we have been asked for a tagged command, refuse + * to overlap with an existing untagged one. */ if (tag_order) { - /* - * Debugging purpose. - */ - assert(lp->busy_itl == 0); + if (lp->busy_itl != 0) + goto out_free; /* * Allocate resources for tags if not yet. */ @@ -6330,22 +6329,17 @@ static ccb_p sym_get_ccb (hcb_p np, u_char tn, u_char ln, u_char tag_order) * one, refuse to overlap this untagged one. */ else { - /* - * Debugging purpose. - */ - assert(lp->busy_itl == 0 && lp->busy_itlq == 0); + if (lp->busy_itlq != 0 || lp->busy_itl != 0) + goto out_free; /* * Count this nexus for this LUN. * Set up the CCB bus address for reselection. * Toggle reselect path to untagged. */ - if (++lp->busy_itl == 1) { - lp->head.itl_task_sa = cpu_to_scr(cp->ccb_ba); - lp->head.resel_sa = - cpu_to_scr(SCRIPTA_BA (np, resel_no_tag)); - } - else - goto out_free; + lp->busy_itl = 1; + lp->head.itl_task_sa = cpu_to_scr(cp->ccb_ba); + lp->head.resel_sa = + cpu_to_scr(SCRIPTA_BA (np, resel_no_tag)); } } /* @@ -6391,7 +6385,7 @@ static void sym_free_ccb(hcb_p np, ccb_p cp) */ if (lp) { /* - * If tagged, release the tag, set the relect path + * If tagged, release the tag, set the reselect path. */ if (cp->tag != NO_TAG) { /* @@ -6412,7 +6406,7 @@ static void sym_free_ccb(hcb_p np, ccb_p cp) * and uncount this CCB. */ lp->head.itl_task_sa = cpu_to_scr(np->bad_itl_ba); - --lp->busy_itl; + lp->busy_itl = 0; } /* * If no JOB active, make the LUN reselect path invalid.