From ea01d569176e1d1f562af32e9e6f8168eaecbb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Schmidt?= Date: Mon, 25 Aug 2003 07:59:50 +0000 Subject: [PATCH] Only call FLUSH_CACHE on devices that say they can. This will get rid of the warnings issued at shutdown (that seems to worry alot of users), but will also no flush cache on lots of devices that can, but doesn't set the right support bits... --- sys/dev/ata/ata-all.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 6f938586ffd..0a66ec287a5 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -196,12 +196,14 @@ ata_detach(device_t dev) mtx_unlock(&ch->queue_mtx); if (ch->device[MASTER].param) { - ata_controlcmd(&ch->device[MASTER], ATA_FLUSHCACHE, 0, 0, 0); + if (ch->device[MASTER].param->support.command2 & ATA_SUPPORT_FLUSHCACHE) + ata_controlcmd(&ch->device[MASTER], ATA_FLUSHCACHE, 0, 0, 0); free(ch->device[MASTER].param, M_ATA); ch->device[MASTER].param = NULL; } if (ch->device[SLAVE].param) { - ata_controlcmd(&ch->device[SLAVE], ATA_FLUSHCACHE, 0, 0, 0); + if (ch->device[SLAVE].param->support.command2 & ATA_SUPPORT_FLUSHCACHE) + ata_controlcmd(&ch->device[SLAVE], ATA_FLUSHCACHE, 0, 0, 0); free(ch->device[SLAVE].param, M_ATA); ch->device[SLAVE].param = NULL; } @@ -303,9 +305,11 @@ ata_shutdown(void *arg, int howto) for (ctlr = 0; ctlr < devclass_get_maxunit(ata_devclass); ctlr++) { if (!(ch = devclass_get_softc(ata_devclass, ctlr))) continue; - if (ch->device[MASTER].param) + if (ch->device[MASTER].param && + ch->device[MASTER].param->support.command2 & ATA_SUPPORT_FLUSHCACHE) ata_controlcmd(&ch->device[MASTER], ATA_FLUSHCACHE, 0, 0, 0); - if (ch->device[SLAVE].param) + if (ch->device[SLAVE].param && + ch->device[SLAVE].param->support.command2 & ATA_SUPPORT_FLUSHCACHE) ata_controlcmd(&ch->device[SLAVE], ATA_FLUSHCACHE, 0, 0, 0); } }