Page MenuHomeFreeBSD

D61832.1795404222.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D61832.1795404222.diff

diff --git a/sys/dev/dwc/dwc1000_core.c b/sys/dev/dwc/dwc1000_core.c
--- a/sys/dev/dwc/dwc1000_core.c
+++ b/sys/dev/dwc/dwc1000_core.c
@@ -68,8 +68,6 @@
#include <dev/dwc/dwc1000_core.h>
#include <dev/dwc/dwc1000_dma.h>
-#include "if_dwc_if.h"
-
struct dwc_hash_maddr_ctx {
struct dwc_softc *sc;
uint32_t hash[8];
@@ -199,9 +197,6 @@
if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0)
reg |= dwc_pause_time << FLOW_CONTROL_PT_SHIFT;
WRITE4(sc, FLOW_CONTROL, reg);
-
- IF_DWC_SET_SPEED(dev, IFM_SUBTYPE(mii->mii_media_active));
-
}
void
diff --git a/sys/dev/dwc/dwc4_core.c b/sys/dev/dwc/dwc4_core.c
--- a/sys/dev/dwc/dwc4_core.c
+++ b/sys/dev/dwc/dwc4_core.c
@@ -55,8 +55,6 @@
#include <dev/dwc/dwc4_reg.h>
#include <dev/dwc/dwc4_dma.h>
-#include "if_dwc_if.h"
-
struct dwc_hash_maddr_ctx {
struct dwc_softc *sc;
uint32_t hash[8];
@@ -179,9 +177,6 @@
else
reg &= ~(MACCR_DM);
WRITE4(sc, ETH_MACCR, reg);
-
- IF_DWC_SET_SPEED(dev, IFM_SUBTYPE(mii->mii_media_active));
-
}
void
diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
--- a/sys/dev/dwc/if_dwc.c
+++ b/sys/dev/dwc/if_dwc.c
@@ -48,6 +48,7 @@
#include <sys/rman.h>
#include <sys/socket.h>
#include <sys/sockio.h>
+#include <sys/taskqueue.h>
#include <net/bpf.h>
#include <net/if.h>
@@ -89,6 +90,7 @@
static void dwc_stop_locked(struct dwc_softc *sc);
static void dwc_tick(void *arg);
+static void dwc_link_task(void *arg, int pending);
/*
* Media functions
@@ -662,6 +664,7 @@
MTX_NETWORK_LOCK, MTX_DEF);
callout_init_mtx(&sc->dwc_callout, &sc->mtx, 0);
+ TASK_INIT(&sc->link_task, 0, dwc_link_task, sc);
/* Setup interrupt handler. */
error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_NET | INTR_MPSAFE,
@@ -735,6 +738,7 @@
dwc_stop_locked(sc);
DWC_UNLOCK(sc);
callout_drain(&sc->dwc_callout);
+ taskqueue_drain(taskqueue_thread, &sc->link_task);
ether_ifdetach(sc->ifp);
}
@@ -772,6 +776,36 @@
return (sc->ops->core_miibus_write_reg(dev, phy, reg, val));
}
+/*
+ * Set the speed in the SoC specific code. It can sleep (it can change
+ * clocks), so it cannot be done from the media status change which holds
+ * the lock and can run from a callout. The link is declared up once it
+ * is done, unless the media changed again in the meantime.
+ */
+static void
+dwc_link_task(void *arg, int pending __unused)
+{
+ struct dwc_softc *sc;
+ u_int gen;
+ int speed;
+
+ sc = arg;
+
+ DWC_LOCK(sc);
+ gen = sc->link_gen;
+ speed = sc->link_speed;
+ DWC_UNLOCK(sc);
+
+ IF_DWC_SET_SPEED(sc->dev, speed);
+
+ DWC_LOCK(sc);
+ if (gen == sc->link_gen && !sc->is_detaching) {
+ sc->link_is_up = true;
+ dwc_txstart_locked(sc);
+ }
+ DWC_UNLOCK(sc);
+}
+
static void
dwc_miibus_statchg(device_t dev)
{
@@ -779,6 +813,13 @@
sc = device_get_softc(dev);
sc->ops->core_miibus_statchg(dev);
+
+ sc->link_gen++;
+ if (sc->link_is_up) {
+ sc->link_is_up = false;
+ sc->link_speed = IFM_SUBTYPE(sc->mii_softc->mii_media_active);
+ taskqueue_enqueue(taskqueue_thread, &sc->link_task);
+ }
}
static device_method_t dwc_methods[] = {
diff --git a/sys/dev/dwc/if_dwcvar.h b/sys/dev/dwc/if_dwcvar.h
--- a/sys/dev/dwc/if_dwcvar.h
+++ b/sys/dev/dwc/if_dwcvar.h
@@ -38,6 +38,8 @@
#ifndef __IF_DWCVAR_H__
#define __IF_DWCVAR_H__
+#include <sys/_task.h>
+
/*
* Driver data and defines.
*/
@@ -105,6 +107,9 @@
void * intr_cookie;
struct callout dwc_callout;
bool link_is_up;
+ struct task link_task;
+ int link_speed; /* IFM subtype to set */
+ u_int link_gen; /* Changed by every statchg */
bool is_attached;
bool is_detaching;
int tx_watchdog_count;

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 23, 3:23 AM (6 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41893656
Default Alt Text
D61832.1795404222.diff (3 KB)

Event Timeline