From owner-svn-src-head@FreeBSD.ORG Tue Jul 23 14:02:39 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D26F3D12; Tue, 23 Jul 2013 14:02:39 +0000 (UTC) (envelope-from loos@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C35552021; Tue, 23 Jul 2013 14:02:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6NE2dUN032099; Tue, 23 Jul 2013 14:02:39 GMT (envelope-from loos@svn.freebsd.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6NE2dr2032094; Tue, 23 Jul 2013 14:02:39 GMT (envelope-from loos@svn.freebsd.org) Message-Id: <201307231402.r6NE2dr2032094@svn.freebsd.org> From: Luiz Otavio O Souza Date: Tue, 23 Jul 2013 14:02:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253570 - head/sys/dev/etherswitch/arswitch 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.14 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, 23 Jul 2013 14:02:40 -0000 Author: loos Date: Tue Jul 23 14:02:38 2013 New Revision: 253570 URL: http://svnweb.freebsd.org/changeset/base/253570 Log: Fix the arswitch instability problem. It turns out that the arswitch_writereg() routine was writing the registers in the wrong order. Revert -r241918 as the root problem is now fixed. Remove another workaround from arswitch_ar7240.c. Simplify and fix the code on arswitch_writephy() by using arswitch_writereg(). While here remove a redundant declaration from arswitchvar.h. Approved by: adrian (mentor) Modified: head/sys/dev/etherswitch/arswitch/arswitch_7240.c head/sys/dev/etherswitch/arswitch/arswitch_phy.c head/sys/dev/etherswitch/arswitch/arswitch_reg.c head/sys/dev/etherswitch/arswitch/arswitchvar.h Modified: head/sys/dev/etherswitch/arswitch/arswitch_7240.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch_7240.c Tue Jul 23 13:56:38 2013 (r253569) +++ head/sys/dev/etherswitch/arswitch/arswitch_7240.c Tue Jul 23 14:02:38 2013 (r253570) @@ -75,12 +75,6 @@ ar7240_hw_setup(struct arswitch_softc *s arswitch_writereg(sc->sc_dev, AR8X16_REG_CPU_PORT, AR8X16_CPU_PORT_EN | AR8X16_CPU_MIRROR_DIS); - /* - * Let things settle; probing PHY4 doesn't seem reliable - * without a litle delay. - */ - DELAY(1000); - return (0); } Modified: head/sys/dev/etherswitch/arswitch/arswitch_phy.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch_phy.c Tue Jul 23 13:56:38 2013 (r253569) +++ head/sys/dev/etherswitch/arswitch/arswitch_phy.c Tue Jul 23 14:02:38 2013 (r253570) @@ -127,16 +127,13 @@ arswitch_writephy(device_t dev, int phy, return (ENXIO); ARSWITCH_LOCK(sc); - err = arswitch_writereg_lsb(dev, AR8X16_REG_MDIO_CTRL, - (data & AR8X16_MDIO_CTRL_DATA_MASK)); - if (err != 0) - goto out; - err = arswitch_writereg_msb(dev, AR8X16_REG_MDIO_CTRL, + err = arswitch_writereg(dev, AR8X16_REG_MDIO_CTRL, AR8X16_MDIO_CTRL_BUSY | AR8X16_MDIO_CTRL_MASTER_EN | AR8X16_MDIO_CTRL_CMD_WRITE | (phy << AR8X16_MDIO_CTRL_PHY_ADDR_SHIFT) | - (reg << AR8X16_MDIO_CTRL_REG_ADDR_SHIFT)); + (reg << AR8X16_MDIO_CTRL_REG_ADDR_SHIFT) | + (data & AR8X16_MDIO_CTRL_DATA_MASK)); if (err != 0) goto out; for (timeout = 100; timeout--; ) { Modified: head/sys/dev/etherswitch/arswitch/arswitch_reg.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch_reg.c Tue Jul 23 13:56:38 2013 (r253569) +++ head/sys/dev/etherswitch/arswitch/arswitch_reg.c Tue Jul 23 14:02:38 2013 (r253570) @@ -72,17 +72,10 @@ arswitch_split_setpage(device_t dev, uin *phy = (((addr) >> 6) & 0x07) | 0x10; *reg = ((addr) >> 1) & 0x1f; - /* - * The earlier code would only switch the page - * over if the page were different. Experiments have - * shown that this is unstable. - * - * Hence, the page is always set here. - * - * See PR kern/172968 - */ - MDIO_WRITEREG(device_get_parent(dev), 0x18, 0, page); - sc->page = page; + if (sc->page != page) { + MDIO_WRITEREG(device_get_parent(dev), 0x18, 0, page); + sc->page = page; + } } /* @@ -171,8 +164,8 @@ arswitch_writereg(device_t dev, int addr { /* XXX Check the first write too? */ - arswitch_writereg_lsb(dev, addr, value); - return (arswitch_writereg_msb(dev, addr, value)); + arswitch_writereg_msb(dev, addr, value); + return (arswitch_writereg_lsb(dev, addr, value)); } int Modified: head/sys/dev/etherswitch/arswitch/arswitchvar.h ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitchvar.h Tue Jul 23 13:56:38 2013 (r253569) +++ head/sys/dev/etherswitch/arswitch/arswitchvar.h Tue Jul 23 14:02:38 2013 (r253570) @@ -42,8 +42,6 @@ typedef enum { #define AR8X16_IS_SWITCH(_sc, _type) \ (!!((_sc)->sc_switchtype == AR8X16_SWITCH_ ## _type)) -struct arswitch_softc; - struct arswitch_softc { struct mtx sc_mtx; /* serialize access to softc */ device_t sc_dev;