dwc: Setup desc addresses in the dma init function.

This commit is contained in:
Emmanuel Vadot 2023-10-03 18:46:56 +02:00
parent 29776aa436
commit f0a7dd7703
2 changed files with 11 additions and 11 deletions

View File

@ -605,10 +605,18 @@ int
dma1000_init(struct dwc_softc *sc)
{
struct mbuf *m;
uint32_t reg;
int error;
int nidx;
int idx;
/*
* DMA must be stop while changing descriptor list addresses.
*/
reg = READ4(sc, OPERATION_MODE);
reg &= ~(MODE_ST | MODE_SR);
WRITE4(sc, OPERATION_MODE, reg);
/*
* Set up TX descriptor ring, descriptors, and dma maps.
*/
@ -684,6 +692,8 @@ dma1000_init(struct dwc_softc *sc)
for (idx = 0; idx < TX_DESC_COUNT; idx++)
dwc_setup_txdesc(sc, idx, 0, 0, 0, false, false);
WRITE4(sc, TX_DESCR_LIST_ADDR, sc->txdesc_ring_paddr);
/*
* Set up RX descriptor ring, descriptors, dma maps, and mbufs.
*/
@ -758,6 +768,7 @@ dma1000_init(struct dwc_softc *sc)
goto out;
}
}
WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr);
out:
if (error != 0)

View File

@ -610,22 +610,11 @@ dwc_attach(device_t dev)
WRITE4(sc, BUS_MODE, reg);
/*
* DMA must be stop while changing descriptor list addresses.
*/
reg = READ4(sc, OPERATION_MODE);
reg &= ~(MODE_ST | MODE_SR);
WRITE4(sc, OPERATION_MODE, reg);
if (dma1000_init(sc)) {
bus_release_resources(dev, dwc_spec, sc->res);
return (ENXIO);
}
/* Setup addresses */
WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr);
WRITE4(sc, TX_DESCR_LIST_ADDR, sc->txdesc_ring_paddr);
mtx_init(&sc->mtx, device_get_nameunit(sc->dev),
MTX_NETWORK_LOCK, MTX_DEF);