From owner-freebsd-arm@freebsd.org Wed Jul 29 16:19:45 2015 Return-Path: Delivered-To: freebsd-arm@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 345F69AEBA9 for ; Wed, 29 Jul 2015 16:19:45 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (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 B921FA4C for ; Wed, 29 Jul 2015 16:19:44 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 67FE01FE022; Wed, 29 Jul 2015 18:19:43 +0200 (CEST) Message-ID: <55B8FD75.2000202@selasky.org> Date: Wed, 29 Jul 2015 18:21:09 +0200 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Svatopluk Kraus CC: Jia-Shiun Li , "freebsd-arm@freebsd.org" Subject: Re: [RPI-B] [HEADS UP] DWC OTG TX path optimisation for 11-current References: <55A7D8CE.4020809@selasky.org> <55B23276.8090703@selasky.org> <55B73113.2020308@selasky.org> <55B8AB76.7030603@selasky.org> <55B8B297.1010008@selasky.org> In-Reply-To: Content-Type: multipart/mixed; boundary="------------020909020306000305050501" X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2015 16:19:45 -0000 This is a multi-part message in MIME format. --------------020909020306000305050501 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 07/29/15 13:52, Svatopluk Kraus wrote: > smsc0: warning: MII is busy > smsc0: warning: Failed to write register 0x114 > smsc0: warning: Failed to read register 0x114 > smsc0: warning: MII is busy > smsc0: warning: Failed to read register 0x118 > smsc0: warning: Failed to write register 0x114 > smsc0: warning: Failed to read register 0x114 > smsc0: warning: MII is busy > smsc0: warning: Failed to write register 0x114 > smsc0: warning: Failed to read register 0x114 > smsc0: warning: MII is busy > smsc0: warning: Failed to read register 0x114 > smsc0: warning: MII is busy > smsc0: warning: Failed to read register 0x114 > smsc0: warning: MII is busy > smsc0: warning: Failed to write register 0x114 > smsc0: warning: Failed to read register 0x114 Does the attached patch make any difference? --HPS --------------020909020306000305050501 Content-Type: text/x-diff; name="smsc.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="smsc.diff" Index: sys/dev/usb/net/if_smsc.c =================================================================== --- sys/dev/usb/net/if_smsc.c (revision 286002) +++ sys/dev/usb/net/if_smsc.c (working copy) @@ -418,6 +418,21 @@ return (err); } +static void +smsc_miibus_wait_ready(struct smsc_softc *sc) +{ + while (sc->sc_flags & SMSC_FLAG_MIIBUSY) + cv_wait(&sc->sc_cv, &sc->sc_mtx); + sc->sc_flags |= SMSC_FLAG_MIIBUSY; +} + +static void +smsc_miibus_clear_busy(struct smsc_softc *sc) +{ + sc->sc_flags &= ~SMSC_FLAG_MIIBUSY; + cv_signal(&sc->sc_cv); +} + /** * smsc_miibus_readreg - Reads a MII/MDIO register * @dev: usb ether device @@ -445,6 +460,8 @@ if (!locked) SMSC_LOCK(sc); + smsc_miibus_wait_ready(sc); + if (smsc_wait_for_bits(sc, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) { smsc_warn_printf(sc, "MII is busy\n"); goto done; @@ -458,8 +475,9 @@ smsc_read_reg(sc, SMSC_MII_DATA, &val); val = le32toh(val); - + done: + smsc_miibus_clear_busy(sc); if (!locked) SMSC_UNLOCK(sc); @@ -495,6 +513,8 @@ if (!locked) SMSC_LOCK(sc); + smsc_miibus_wait_ready(sc); + if (smsc_wait_for_bits(sc, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) { smsc_warn_printf(sc, "MII is busy\n"); goto done; @@ -510,6 +530,7 @@ smsc_warn_printf(sc, "MII write timeout\n"); done: + smsc_miibus_clear_busy(sc); if (!locked) SMSC_UNLOCK(sc); return (0); @@ -1777,6 +1798,7 @@ device_set_usb_desc(dev); mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); + cv_init(&sc->sc_cv, "SMSC-MIIBUS"); /* Setup the endpoints for the SMSC LAN95xx device(s) */ iface_index = SMSC_IFACE_IDX; @@ -1820,6 +1842,7 @@ usbd_transfer_unsetup(sc->sc_xfer, SMSC_N_TRANSFER); uether_ifdetach(ue); + cv_destroy(&sc->sc_cv); mtx_destroy(&sc->sc_mtx); return (0); Index: sys/dev/usb/net/if_smscreg.h =================================================================== --- sys/dev/usb/net/if_smscreg.h (revision 286002) +++ sys/dev/usb/net/if_smscreg.h (working copy) @@ -258,6 +258,7 @@ struct smsc_softc { struct usb_ether sc_ue; struct mtx sc_mtx; + struct cv sc_cv; struct usb_xfer *sc_xfer[SMSC_N_TRANSFER]; int sc_phyno; @@ -267,6 +268,7 @@ uint32_t sc_flags; #define SMSC_FLAG_LINK 0x0001 +#define SMSC_FLAG_MIIBUSY 0x0002 #define SMSC_FLAG_LAN9514 0x1000 /* LAN9514 */ }; --------------020909020306000305050501--