From owner-svn-src-head@freebsd.org Tue Jun 13 18:35:16 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 0A547BFB81B; Tue, 13 Jun 2017 18:35:16 +0000 (UTC) (envelope-from zbb@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 CDB4A207D; Tue, 13 Jun 2017 18:35:15 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5DIZFtc026620; Tue, 13 Jun 2017 18:35:15 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5DIZFLA026619; Tue, 13 Jun 2017 18:35:15 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201706131835.v5DIZFLA026619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Tue, 13 Jun 2017 18:35:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319906 - head/sys/dev/etherswitch/e6000sw X-SVN-Group: head 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: Tue, 13 Jun 2017 18:35:16 -0000 Author: zbb Date: Tue Jun 13 18:35:14 2017 New Revision: 319906 URL: https://svnweb.freebsd.org/changeset/base/319906 Log: Prevent multiple lock initialization in e6000sw probe r319886 ("Add the initial support for the Marvell 88E6141 and 88E6341 switches.") unveiled a problem with possible multiple lock creation. Move its initialization to the driver attach and for obtaining the switch ID create a temprorary one, which is immediately destroyed after the check. Submitted by: Zbigniew Bodek Marcin Wojtas Obtained from: Semihalf Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c ============================================================================== --- head/sys/dev/etherswitch/e6000sw/e6000sw.c Tue Jun 13 17:49:49 2017 (r319905) +++ head/sys/dev/etherswitch/e6000sw/e6000sw.c Tue Jun 13 18:35:14 2017 (r319906) @@ -217,11 +217,15 @@ e6000sw_probe(device_t dev) if (sc->sw_addr != 0 && (sc->sw_addr % 2) == 0) sc->multi_chip = true; - /* Lock is necessary due to assertions. */ - sx_init(&sc->sx, "e6000sw"); + /* + * Create temporary lock, just to satisfy assertions, + * when obtaining the switch ID. Destroy immediately afterwards. + */ + sx_init(&sc->sx, "e6000sw_tmp"); E6000SW_LOCK(sc); id = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID); E6000SW_UNLOCK(sc); + sx_destroy(&sc->sx); switch (id & 0xfff0) { case 0x3400: @@ -247,7 +251,6 @@ e6000sw_probe(device_t dev) sc->num_ports = 7; break; default: - sx_destroy(&sc->sx); device_printf(dev, "Unrecognized device, id 0x%x.\n", id); return (ENXIO); } @@ -354,6 +357,8 @@ e6000sw_attach(device_t dev) device_printf(dev, "multi-chip addressing mode\n"); else device_printf(dev, "single-chip addressing mode\n"); + + sx_init(&sc->sx, "e6000sw"); E6000SW_LOCK(sc); e6000sw_setup(dev, sc);