From owner-svn-src-all@FreeBSD.ORG Mon Feb 16 06:10:18 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 84AB59A; Mon, 16 Feb 2015 06:10:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 704F8F0; Mon, 16 Feb 2015 06:10:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1G6AIZH017481; Mon, 16 Feb 2015 06:10:18 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1G6AIS4017480; Mon, 16 Feb 2015 06:10:18 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201502160610.t1G6AIS4017480@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Mon, 16 Feb 2015 06:10:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278838 - head/sys/dev/sfxge X-SVN-Group: head 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.18-1 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: Mon, 16 Feb 2015 06:10:18 -0000 Author: arybchik Date: Mon Feb 16 06:10:17 2015 New Revision: 278838 URL: https://svnweb.freebsd.org/changeset/base/278838 Log: sfxge: SYSCTL_IN/OUT should not be called with non-sleepable lock held The problem is found using WITNESS option enabled. Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor) Modified: head/sys/dev/sfxge/sfxge_port.c Modified: head/sys/dev/sfxge/sfxge_port.c ============================================================================== --- head/sys/dev/sfxge/sfxge_port.c Mon Feb 16 06:08:13 2015 (r278837) +++ head/sys/dev/sfxge/sfxge_port.c Mon Feb 16 06:10:17 2015 (r278838) @@ -91,16 +91,15 @@ sfxge_mac_stat_handler(SYSCTL_HANDLER_AR struct sfxge_softc *sc = arg1; unsigned int id = arg2; int rc; + uint64_t val; SFXGE_PORT_LOCK(&sc->port); - if ((rc = sfxge_mac_stat_update(sc)) != 0) - goto out; - - rc = SYSCTL_OUT(req, - (uint64_t *)sc->port.mac_stats.decode_buf + id, - sizeof(uint64_t)); -out: + if ((rc = sfxge_mac_stat_update(sc)) == 0) + val = ((uint64_t *)sc->port.mac_stats.decode_buf)[id]; SFXGE_PORT_UNLOCK(&sc->port); + + if (rc == 0) + rc = SYSCTL_OUT(req, &val, sizeof(val)); return (rc); } @@ -173,28 +172,29 @@ sfxge_port_wanted_fc_handler(SYSCTL_HAND sc = arg1; port = &sc->port; - SFXGE_PORT_LOCK(port); - if (req->newptr != NULL) { if ((error = SYSCTL_IN(req, &fcntl, sizeof(fcntl))) != 0) - goto out; - - if (port->wanted_fc == fcntl) - goto out; + return (error); - port->wanted_fc = fcntl; + SFXGE_PORT_LOCK(port); - if (port->init_state != SFXGE_PORT_STARTED) - goto out; + if (port->wanted_fc != fcntl) { + if (port->init_state == SFXGE_PORT_STARTED) + error = efx_mac_fcntl_set(sc->enp, + port->wanted_fc, + B_TRUE); + if (error == 0) + port->wanted_fc = fcntl; + } - error = efx_mac_fcntl_set(sc->enp, port->wanted_fc, B_TRUE); + SFXGE_PORT_UNLOCK(port); } else { - error = SYSCTL_OUT(req, &port->wanted_fc, - sizeof(port->wanted_fc)); - } + SFXGE_PORT_LOCK(port); + fcntl = port->wanted_fc; + SFXGE_PORT_UNLOCK(port); -out: - SFXGE_PORT_UNLOCK(port); + error = SYSCTL_OUT(req, &fcntl, sizeof(fcntl)); + } return (error); } @@ -205,7 +205,6 @@ sfxge_port_link_fc_handler(SYSCTL_HANDLE struct sfxge_softc *sc; struct sfxge_port *port; unsigned int wanted_fc, link_fc; - int error; sc = arg1; port = &sc->port; @@ -215,10 +214,9 @@ sfxge_port_link_fc_handler(SYSCTL_HANDLE efx_mac_fcntl_get(sc->enp, &wanted_fc, &link_fc); else link_fc = 0; - error = SYSCTL_OUT(req, &link_fc, sizeof(link_fc)); SFXGE_PORT_UNLOCK(port); - return (error); + return (SYSCTL_OUT(req, &link_fc, sizeof(link_fc))); } #endif /* SFXGE_HAVE_PAUSE_MEDIAOPTS */ @@ -499,16 +497,15 @@ sfxge_phy_stat_handler(SYSCTL_HANDLER_AR struct sfxge_softc *sc = arg1; unsigned int id = arg2; int rc; + uint32_t val; SFXGE_PORT_LOCK(&sc->port); - if ((rc = sfxge_phy_stat_update(sc)) != 0) - goto out; - - rc = SYSCTL_OUT(req, - (uint32_t *)sc->port.phy_stats.decode_buf + id, - sizeof(uint32_t)); -out: + if ((rc = sfxge_phy_stat_update(sc)) == 0) + val = ((uint32_t *)sc->port.phy_stats.decode_buf)[id]; SFXGE_PORT_UNLOCK(&sc->port); + + if (rc == 0) + rc = SYSCTL_OUT(req, &val, sizeof(val)); return (rc); }