Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jul 2015 18:21:09 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Svatopluk Kraus <onwahe@gmail.com>
Cc:        Jia-Shiun Li <jiashiun@gmail.com>,  "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Subject:   Re: [RPI-B] [HEADS UP] DWC OTG TX path optimisation for 11-current
Message-ID:  <55B8FD75.2000202@selasky.org>
In-Reply-To: <CAFHCsPVGLs8j6LAV%2Bg4rP_ueTOd8pUOupYFGvmgC3XGcJC720Q@mail.gmail.com>
References:  <55A7D8CE.4020809@selasky.org>	<CAHNYxxMp9jGDbV-5=-cE6daR-O3eN5pdvO1s-=QfX=A9XYqYmA@mail.gmail.com>	<55B23276.8090703@selasky.org>	<CAHNYxxNc9uB62hHEv1PM9PcsGgUs=zsvNgatqLD0p%2BiiDA3Aiw@mail.gmail.com>	<55B73113.2020308@selasky.org>	<CAFHCsPVaPZpqXLS7OApa=Xz5VLnLjVpV5dYV8Pn2uHh1Lcz7Tg@mail.gmail.com>	<55B8AB76.7030603@selasky.org>	<CAFHCsPUMaYEwJsaGUFuw9yZi_5bmraSBsOYpRWvSeuebpXBJUA@mail.gmail.com>	<55B8B297.1010008@selasky.org> <CAFHCsPVGLs8j6LAV%2Bg4rP_ueTOd8pUOupYFGvmgC3XGcJC720Q@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55B8FD75.2000202>