Author: avg
Date: Thu May  3 15:33:18 2018
New Revision: 333212
URL: https://svnweb.freebsd.org/changeset/base/333212

Log:
  amdsbwd: add suspend and resume methods
  
  Without the suspend method the watchdog may fire in S1 state.  Without
  the resume method the watchdog is not re-enabled after returning from S3
  state.  I observe this on one of my systems.
  
  Not sure if watchdog(4) should participate in the suspend actions.
  Right now everything is up to individual drivers.
  
  MFC after:    2 weeks

Modified:
  head/sys/dev/amdsbwd/amdsbwd.c

Modified: head/sys/dev/amdsbwd/amdsbwd.c
==============================================================================
--- head/sys/dev/amdsbwd/amdsbwd.c      Thu May  3 15:01:27 2018        
(r333211)
+++ head/sys/dev/amdsbwd/amdsbwd.c      Thu May  3 15:33:18 2018        
(r333212)
@@ -104,12 +104,16 @@ static void       amdsbwd_identify(driver_t *driver, 
device_
 static int     amdsbwd_probe(device_t dev);
 static int     amdsbwd_attach(device_t dev);
 static int     amdsbwd_detach(device_t dev);
+static int     amdsbwd_suspend(device_t dev);
+static int     amdsbwd_resume(device_t dev);
 
 static device_method_t amdsbwd_methods[] = {
        DEVMETHOD(device_identify,      amdsbwd_identify),
        DEVMETHOD(device_probe,         amdsbwd_probe),
        DEVMETHOD(device_attach,        amdsbwd_attach),
        DEVMETHOD(device_detach,        amdsbwd_detach),
+       DEVMETHOD(device_suspend,       amdsbwd_suspend),
+       DEVMETHOD(device_resume,        amdsbwd_resume),
 #if 0
        DEVMETHOD(device_shutdown,      amdsbwd_detach),
 #endif
@@ -553,3 +557,30 @@ amdsbwd_detach(device_t dev)
        return (0);
 }
 
+static int
+amdsbwd_suspend(device_t dev)
+{
+       struct amdsbwd_softc *sc;
+       uint32_t val;
+
+       sc = device_get_softc(dev);
+       val = wdctrl_read(sc);
+       val &= ~AMDSB_WD_RUN;
+       wdctrl_write(sc, val);
+       return (0);
+}
+
+static int
+amdsbwd_resume(device_t dev)
+{
+       struct amdsbwd_softc *sc;
+
+       sc = device_get_softc(dev);
+       wdctrl_write(sc, AMDSB_WD_FIRED);
+       if (sc->active) {
+               amdsbwd_tmr_set(sc, sc->timeout);
+               amdsbwd_tmr_enable(sc);
+               amdsbwd_tmr_reload(sc);
+       }
+       return (0);
+}
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to