Deleted Added
full compact
30c30
< * $FreeBSD: head/sys/dev/fxp/if_fxp.c 66006 2000-09-17 22:01:21Z cp $
---
> * $FreeBSD: head/sys/dev/fxp/if_fxp.c 66007 2000-09-17 22:12:12Z dg $
223a224
> static __inline void fxp_dma_wait __P((volatile u_int16_t *, struct fxp_softc *sc));
293c294,297
< while (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) && --i);
---
> while (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) && --i)
> DELAY(2);
> if (i == 0)
> printf(FXP_FORMAT ": SCB timeout\n", FXP_ARGS(sc));
295a300,312
> static __inline void
> fxp_dma_wait(status, sc)
> volatile u_int16_t *status;
> struct fxp_softc *sc;
> {
> int i = 10000;
>
> while (!(*status & FXP_CB_STATUS_C) && --i)
> DELAY(2);
> if (i == 0)
> printf(FXP_FORMAT ": DMA timeout\n", FXP_ARGS(sc));
> }
>
689a707,777
> /*
> * Device suspend routine. Stop the interface and save some PCI
> * settings in case the BIOS doesn't restore them properly on
> * resume.
> */
> static int
> fxp_suspend(device_t dev)
> {
> struct fxp_softc *sc = device_get_softc(dev);
> int i, s;
>
> s = splimp();
>
> fxp_stop(sc);
>
> for (i=0; i<5; i++)
> sc->saved_maps[i] = pci_read_config(dev, PCIR_MAPS + i*4, 4);
> sc->saved_biosaddr = pci_read_config(dev, PCIR_BIOS, 4);
> sc->saved_intline = pci_read_config(dev, PCIR_INTLINE, 1);
> sc->saved_cachelnsz = pci_read_config(dev, PCIR_CACHELNSZ, 1);
> sc->saved_lattimer = pci_read_config(dev, PCIR_LATTIMER, 1);
>
> sc->suspended = 1;
>
> splx(s);
>
> return 0;
> }
>
> /*
> * Device resume routine. Restore some PCI settings in case the BIOS
> * doesn't, re-enable busmastering, and restart the interface if
> * appropriate.
> */
> static int
> fxp_resume(device_t dev)
> {
> struct fxp_softc *sc = device_get_softc(dev);
> struct ifnet *ifp = &sc->sc_if;
> u_int16_t pci_command;
> int i, s;
>
> s = splimp();
>
> /* better way to do this? */
> for (i=0; i<5; i++)
> pci_write_config(dev, PCIR_MAPS + i*4, sc->saved_maps[i], 4);
> pci_write_config(dev, PCIR_BIOS, sc->saved_biosaddr, 4);
> pci_write_config(dev, PCIR_INTLINE, sc->saved_intline, 1);
> pci_write_config(dev, PCIR_CACHELNSZ, sc->saved_cachelnsz, 1);
> pci_write_config(dev, PCIR_LATTIMER, sc->saved_lattimer, 1);
>
> /* reenable busmastering */
> pci_command = pci_read_config(dev, PCIR_COMMAND, 2);
> pci_command |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
> pci_write_config(dev, PCIR_COMMAND, pci_command, 2);
>
> CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET);
> DELAY(10);
>
> /* reinitialize interface if necessary */
> if (ifp->if_flags & IFF_UP)
> fxp_init(sc);
>
> sc->suspended = 0;
>
> splx(s);
>
> return 0;
> }
>
695a784,785
> DEVMETHOD(device_suspend, fxp_suspend),
> DEVMETHOD(device_resume, fxp_resume),
1129c1219
< while ((statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) {
---
> while (!sc->suspended && (statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) {
1366a1457,1459
> ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
> ifp->if_timer = 0;
>
1410,1411d1502
< ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
< ifp->if_timer = 0;
1529c1620
< while (!(cbp->cb_status & FXP_CB_STATUS_C));
---
> fxp_dma_wait(&cbp->cb_status, sc);
1553c1644
< while (!(cb_ias->cb_status & FXP_CB_STATUS_C));
---
> fxp_dma_wait(&cb_ias->cb_status, sc);
1992a2084
> int count;
2074a2167
> count = 100;
2076c2169,2174
< FXP_SCB_CUS_ACTIVE) ;
---
> FXP_SCB_CUS_ACTIVE && --count)
> DELAY(10);
> if (count == 0) {
> printf(FXP_FORMAT ": command queue timeout\n", FXP_ARGS(sc));
> return;
> }