From owner-svn-src-stable-11@freebsd.org Fri Feb 9 03:07:13 2018 Return-Path: Delivered-To: svn-src-stable-11@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 6FFC6F1E193; Fri, 9 Feb 2018 03:07:13 +0000 (UTC) (envelope-from mav@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 25BBB6DA52; Fri, 9 Feb 2018 03:07:13 +0000 (UTC) (envelope-from mav@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 209821F1F3; Fri, 9 Feb 2018 03:07:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1937D91040188; Fri, 9 Feb 2018 03:07:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1937DVm040187; Fri, 9 Feb 2018 03:07:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201802090307.w1937DVm040187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 9 Feb 2018 03:07:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329057 - stable/11/sys/dev/ntb X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ntb X-SVN-Commit-Revision: 329057 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 03:07:13 -0000 Author: mav Date: Fri Feb 9 03:07:12 2018 New Revision: 329057 URL: https://svnweb.freebsd.org/changeset/base/329057 Log: MFC r328611: Try to preallocate receive memory early. We may not have enough contiguous memory later, when NTB connection get established. It is quite likely that NTB windows are symmetric and this allocation remain, but even if not, we will just reallocate it later. Modified: stable/11/sys/dev/ntb/ntb_transport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/11/sys/dev/ntb/ntb_transport.c Fri Feb 9 03:06:45 2018 (r329056) +++ stable/11/sys/dev/ntb/ntb_transport.c Fri Feb 9 03:07:12 2018 (r329057) @@ -332,7 +332,7 @@ ntb_transport_attach(device_t dev) struct ntb_transport_child **cpp = &nt->child; struct ntb_transport_child *nc; struct ntb_transport_mw *mw; - uint64_t db_bitmap; + uint64_t db_bitmap, size; int rc, i, db_count, spad_count, qp, qpu, qpo, qpt; char cfg[128] = ""; char buf[32]; @@ -383,6 +383,17 @@ ntb_transport_attach(device_t dev) rc = ntb_mw_set_wc(dev, i, VM_MEMATTR_WRITE_COMBINING); if (rc) ntb_printf(0, "Unable to set mw%d caching\n", i); + + /* + * Try to preallocate receive memory early, since there may + * be not enough contiguous memory later. It is quite likely + * that NTB windows are symmetric and this allocation remain, + * but even if not, we will just reallocate it later. + */ + size = mw->phys_size; + if (max_mw_size != 0 && size > max_mw_size) + size = max_mw_size; + ntb_set_mw(nt, i, size); } qpu = 0;