From 2c4c6ba5d2c48b1da48968722e94667194c8297f Mon Sep 17 00:00:00 2001 From: YONETANI Tomokazu Date: Thu, 12 Oct 2006 04:02:37 +0000 Subject: [PATCH] Implement suspend method and wait for channels to be idle before going to suspended state. Taken-from: FreeBSD --- sys/dev/disk/ata/ata-all.c | 24 +++++++++++++++++++++++- sys/dev/disk/ata/ata-all.h | 3 ++- sys/dev/disk/ata/ata-isa.c | 3 ++- sys/dev/disk/ata/ata-pci.c | 3 ++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/sys/dev/disk/ata/ata-all.c b/sys/dev/disk/ata/ata-all.c index f24ac7aa15..a513bf3fee 100644 --- a/sys/dev/disk/ata/ata-all.c +++ b/sys/dev/disk/ata/ata-all.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/ata-all.c,v 1.50.2.45 2003/03/12 14:47:12 sos Exp $ - * $DragonFly: src/sys/dev/disk/ata/ata-all.c,v 1.30 2006/09/05 00:55:37 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-all.c,v 1.31 2006/10/12 04:02:37 y0netan1 Exp $ */ #include "opt_ata.h" @@ -302,6 +302,28 @@ ata_detach(device_t dev) } int +ata_suspend(device_t dev) +{ + struct ata_channel *ch; + + if (dev == NULL || (ch = device_get_softc(dev)) == NULL) + return ENXIO; + + /* wait for the channel to be IDLE or detached before suspending */ + while (ch->r_irq) { + crit_enter(); + if (ch->active == ATA_IDLE) { + ch->active = ATA_CONTROL; + crit_exit(); + break; + } + crit_exit(); + tsleep(ch, 0, "atasusp", hz / 10); + } + return 0; +} + +int ata_resume(device_t dev) { return ata_reinit(device_get_softc(dev)); diff --git a/sys/dev/disk/ata/ata-all.h b/sys/dev/disk/ata/ata-all.h index fa724701f0..dbc026e4e3 100644 --- a/sys/dev/disk/ata/ata-all.h +++ b/sys/dev/disk/ata/ata-all.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.26.2.12 2003/01/30 07:19:59 sos Exp $ - * $DragonFly: src/sys/dev/disk/ata/ata-all.h,v 1.7 2004/02/18 02:47:38 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-all.h,v 1.8 2006/10/12 04:02:37 y0netan1 Exp $ */ #ifndef _SYS_MPIPE_H_ @@ -262,6 +262,7 @@ int ata_probe(device_t); int ata_attach(device_t); int ata_detach(device_t); int ata_resume(device_t); +int ata_suspend(device_t); void ata_start(struct ata_channel *); void ata_reset(struct ata_channel *); diff --git a/sys/dev/disk/ata/ata-isa.c b/sys/dev/disk/ata/ata-isa.c index daedab514d..887e9a8b97 100644 --- a/sys/dev/disk/ata/ata-isa.c +++ b/sys/dev/disk/ata/ata-isa.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/ata-isa.c,v 1.4.2.1 2002/03/18 08:37:33 sos Exp $ - * $DragonFly: src/sys/dev/disk/ata/ata-isa.c,v 1.8 2004/08/24 08:15:22 joerg Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-isa.c,v 1.9 2006/10/12 04:02:37 y0netan1 Exp $ */ #include @@ -91,6 +91,7 @@ static device_method_t ata_isa_methods[] = { DEVMETHOD(device_probe, ata_isa_probe), DEVMETHOD(device_attach, ata_attach), DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_suspend), { 0, 0 } }; diff --git a/sys/dev/disk/ata/ata-pci.c b/sys/dev/disk/ata/ata-pci.c index f0530242c1..2a066ba93e 100644 --- a/sys/dev/disk/ata/ata-pci.c +++ b/sys/dev/disk/ata/ata-pci.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.32.2.15 2003/06/06 13:27:05 fjoe Exp $ - * $DragonFly: src/sys/dev/disk/ata/ata-pci.c,v 1.23 2006/09/05 00:55:37 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-pci.c,v 1.24 2006/10/12 04:02:37 y0netan1 Exp $ */ #include @@ -958,6 +958,7 @@ static device_method_t ata_pcisub_methods[] = { DEVMETHOD(device_attach, ata_attach), DEVMETHOD(device_detach, ata_detach), DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_suspend), { 0, 0 } }; -- 2.11.4.GIT