Index: ata-disk.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ata/ata-disk.c,v retrieving revision 1.90 diff -u -r1.90 ata-disk.c --- ata-disk.c 2001/01/10 19:19:47 1.90 +++ ata-disk.c 2001/01/20 03:54:03 @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,9 @@ /* experimental cache flush on BIO_ORDERED */ #define ATA_FLUSHCACHE_ON +int ad_wce = 1; /* default: ON (NOTE: NOT FFS/SOFTUPDATES SAFE!) */ +SYSCTL_INT(_hw, OID_AUTO, ad_wce, CTLFLAG_RW, &ad_wce, 0, ""); + void ad_attach(struct ata_softc *scp, int device) { @@ -135,8 +139,10 @@ printf("ad%d: enabling readahead cache failed\n", adp->lun); if (ata_command(adp->controller, adp->unit, ATA_C_SETFEATURES, - 0, 0, 0, 0, ATA_C_F_ENAB_WCACHE, ATA_WAIT_INTR)) - printf("ad%d: enabling write cache failed\n", adp->lun); + 0, 0, 0, 0, ad_wce ? ATA_C_F_ENAB_WCACHE : + ATA_C_F_DIS_WCACHE, ATA_WAIT_INTR)); + printf("ad%d: %sabling write cache failed\n", adp->lun, + ad_wce ? "en" : "dis"); /* use DMA if drive & controller supports it */ ata_dmainit(adp->controller, adp->unit, @@ -328,6 +334,15 @@ struct bio *bp = bioq_first(&adp->queue); struct ad_request *request; int tag = 0; + + if (adp->wce != ad_wce) { + printf("ad%d: %sabling write cache\n", adp->lun, ad_wce ? "en":"dis"); + ata_command(adp->controller, adp->unit, ATA_C_SETFEATURES, + 0, 0, 0, 0, ad_wce ? ATA_C_F_ENAB_WCACHE : + ATA_C_F_DIS_WCACHE, ATA_IMMEDIATE); + adp->wce = ad_wce; + return; + } if (!bp) return; Index: ata-disk.h =================================================================== RCS file: /home/ncvs/src/sys/dev/ata/ata-disk.h,v retrieving revision 1.31 diff -u -r1.31 ata-disk.h --- ata-disk.h 2001/01/10 19:19:47 1.31 +++ ata-disk.h 2001/01/20 03:54:03 @@ -71,6 +71,7 @@ struct ad_request *tags[32]; /* tag array of requests */ int outstanding; /* tags not serviced yet */ + int wce; struct bio_queue_head queue; /* head of request queue */ struct devstat stats; /* devstat entry */ struct disk disk; /* disklabel/slice stuff */