From owner-svn-src-all@freebsd.org Tue Feb 6 06:55:55 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D7442ED91A0; Tue, 6 Feb 2018 06:55:55 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E14E79635; Tue, 6 Feb 2018 06:55:55 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 88DD71471C; Tue, 6 Feb 2018 06:55:55 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w166ttea076106; Tue, 6 Feb 2018 06:55:55 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w166ttPw076105; Tue, 6 Feb 2018 06:55:55 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201802060655.w166ttPw076105@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 6 Feb 2018 06:55:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328919 - head/sys/dev/mps X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: head/sys/dev/mps X-SVN-Commit-Revision: 328919 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 06:55:56 -0000 Author: scottl Date: Tue Feb 6 06:55:55 2018 New Revision: 328919 URL: https://svnweb.freebsd.org/changeset/base/328919 Log: Fix a case where a request frame can be composed that requires 2 or more SGList elements, but there's only enough space in the request frame for either 1 element or a chain frame pointer. Previously, the code would hit the wrong case, add the SGList element, but then fail to add the chain frame due to lack of space. Re-arrange the code to catch this case earlier and handle it. Sponsored by: Netflix Modified: head/sys/dev/mps/mps.c Modified: head/sys/dev/mps/mps.c ============================================================================== --- head/sys/dev/mps/mps.c Tue Feb 6 06:42:25 2018 (r328918) +++ head/sys/dev/mps/mps.c Tue Feb 6 06:55:55 2018 (r328919) @@ -2609,6 +2609,17 @@ mps_push_sge(struct mps_command *cm, void *sgep, size_ if (cm->cm_sglsize < MPS_SGC_SIZE) panic("MPS: Need SGE Error Code\n"); + if (segsleft >= 1 && cm->cm_sglsize < len + MPS_SGC_SIZE) { + /* + * 1 or more segment, enough room for only a chain. + * Hope the previous element wasn't a Simple entry + * that needed to be marked with + * MPI2_SGE_FLAGS_LAST_ELEMENT. Case (4). + */ + if ((error = mps_add_chain(cm)) != 0) + return (error); + } + if (segsleft >= 2 && cm->cm_sglsize < len + MPS_SGC_SIZE + MPS_SGE64_SIZE) { /* @@ -2631,17 +2642,6 @@ mps_push_sge(struct mps_command *cm, void *sgep, size_ bcopy(sgep, cm->cm_sge, len); cm->cm_sge = (MPI2_SGE_IO_UNION *)((uintptr_t)cm->cm_sge + len); return (mps_add_chain(cm)); - } - - if (segsleft >= 1 && cm->cm_sglsize < len + MPS_SGC_SIZE) { - /* - * 1 or more segment, enough room for only a chain. - * Hope the previous element wasn't a Simple entry - * that needed to be marked with - * MPI2_SGE_FLAGS_LAST_ELEMENT. Case (4). - */ - if ((error = mps_add_chain(cm)) != 0) - return (error); } #ifdef INVARIANTS