From owner-svn-src-head@freebsd.org Mon Aug 28 22:41:17 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3B06CE15593; Mon, 28 Aug 2017 22:41:17 +0000 (UTC) (envelope-from np@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 mx1.freebsd.org (Postfix) with ESMTPS id 15FE867656; Mon, 28 Aug 2017 22:41:17 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7SMfGa6084414; Mon, 28 Aug 2017 22:41:16 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7SMfGdS084413; Mon, 28 Aug 2017 22:41:16 GMT (envelope-from np@FreeBSD.org) Message-Id: <201708282241.v7SMfGdS084413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Mon, 28 Aug 2017 22:41:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322990 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 322990 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Aug 2017 22:41:17 -0000 Author: np Date: Mon Aug 28 22:41:15 2017 New Revision: 322990 URL: https://svnweb.freebsd.org/changeset/base/322990 Log: cxgbe(4): Do not access the mailbox without appropriate locks while creating hardware VIs. This fixes a bad race on systems with hw.cxgbe.num_vis > 1. Reported by: olivier@ MFC after: 1 week Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Mon Aug 28 22:28:41 2017 (r322989) +++ head/sys/dev/cxgbe/t4_main.c Mon Aug 28 22:41:15 2017 (r322990) @@ -2134,29 +2134,24 @@ vcxgbe_probe(device_t dev) } static int -vcxgbe_attach(device_t dev) +alloc_extra_vi(struct adapter *sc, struct port_info *pi, struct vi_info *vi) { - struct vi_info *vi; - struct port_info *pi; - struct adapter *sc; int func, index, rc; - u32 param, val; + uint32_t param, val; - vi = device_get_softc(dev); - pi = vi->pi; - sc = pi->adapter; + ASSERT_SYNCHRONIZED_OP(sc); index = vi - pi->vi; MPASS(index > 0); /* This function deals with _extra_ VIs only */ KASSERT(index < nitems(vi_mac_funcs), ("%s: VI %s doesn't have a MAC func", __func__, - device_get_nameunit(dev))); + device_get_nameunit(vi->dev))); func = vi_mac_funcs[index]; rc = t4_alloc_vi_func(sc, sc->mbox, pi->tx_chan, sc->pf, 0, 1, vi->hw_addr, &vi->rss_size, func, 0); if (rc < 0) { - device_printf(dev, "Failed to allocate virtual interface " - "for port %d: %d\n", pi->port_id, -rc); + device_printf(vi->dev, "failed to allocate virtual interface %d" + "for port %d: %d\n", index, pi->port_id, -rc); return (-rc); } vi->viid = rc; @@ -2165,6 +2160,19 @@ vcxgbe_attach(device_t dev) else vi->smt_idx = (rc & 0x7f); + if (vi->rss_size == 1) { + /* + * This VI didn't get a slice of the RSS table. Reduce the + * number of VIs being created (hw.cxgbe.num_vis) or modify the + * configuration file (nvi, rssnvi for this PF) if this is a + * problem. + */ + device_printf(vi->dev, "RSS table not available.\n"); + vi->rss_base = 0xffff; + + return (0); + } + param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_RSSINFO) | V_FW_PARAMS_PARAM_YZ(vi->viid); @@ -2172,9 +2180,32 @@ vcxgbe_attach(device_t dev) if (rc) vi->rss_base = 0xffff; else { - /* MPASS((val >> 16) == rss_size); */ + MPASS((val >> 16) == vi->rss_size); vi->rss_base = val & 0xffff; } + + return (0); +} + +static int +vcxgbe_attach(device_t dev) +{ + struct vi_info *vi; + struct port_info *pi; + struct adapter *sc; + int rc; + + vi = device_get_softc(dev); + pi = vi->pi; + sc = pi->adapter; + + rc = begin_synchronized_op(sc, vi, SLEEP_OK | INTR_OK, "t4via"); + if (rc) + return (rc); + rc = alloc_extra_vi(sc, pi, vi); + end_synchronized_op(sc, 0); + if (rc) + return (rc); rc = cxgbe_vi_attach(dev, vi); if (rc) {