summaryrefslogtreecommitdiff
path: root/sys/dev/ata/wd.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2007-11-26 23:59:02 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2007-11-26 23:59:02 +0000
commitdca8852d56cd2203f33a8f77ba4f004d89e56ed9 (patch)
tree1c752425fda4960d7b289601dfa065d22f1ff0d3 /sys/dev/ata/wd.c
parent7aae05c899a68701e362cdd21b91e57c19c8ae68 (diff)
Enable read ahead and write cache enable if supported by
the disk rather than depending on the disk to have it on. A bunch of people have suggested this should go in.
Diffstat (limited to 'sys/dev/ata/wd.c')
-rw-r--r--sys/dev/ata/wd.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index 45fb5a85aad..91910a54d28 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd.c,v 1.66 2007/06/20 18:15:46 deraadt Exp $ */
+/* $OpenBSD: wd.c,v 1.67 2007/11/26 23:59:01 jsg Exp $ */
/* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */
/*
@@ -224,12 +224,16 @@ wdattach(struct device *parent, struct device *self, void *aux)
struct wd_softc *wd = (void *)self;
struct ata_atapi_attach *aa_link= aux;
struct wdc_command wdc_c;
+ struct channel_softc *chp;
int i, blank;
+ u_int8_t drive;
char buf[41], c, *p, *q;
WDCDEBUG_PRINT(("wdattach\n"), DEBUG_FUNCS | DEBUG_PROBE);
wd->openings = aa_link->aa_openings;
wd->drvp = aa_link->aa_drv_data;
+ chp = wd->drvp->chnl_softc;
+ drive = wd->drvp->drive;
strlcpy(wd->drvp->drive_name, wd->sc_dev.dv_xname,
sizeof(wd->drvp->drive_name));
@@ -322,6 +326,15 @@ wdattach(struct device *parent, struct device *self, void *aux)
self->dv_xname, wd->sc_params.atap_dmatiming_mimi,
wd->sc_params.atap_dmatiming_recom), DEBUG_PROBE);
+ /* use read look ahead if supported */
+ if (wd->sc_params.atap_cmd_set1 & WDC_CMD1_AHEAD)
+ wdccommand(chp, drive, SET_FEATURES, 0, 0, 0, 0,
+ WDSF_READAHEAD_EN);
+ /* use write cache if supported */
+ if (wd->sc_params.atap_cmd_set1 & WDC_CMD1_CACHE)
+ wdccommand(chp, drive, SET_FEATURES, 0, 0, 0, 0,
+ WDSF_EN_WR_CACHE);
+
/*
* FREEZE LOCK the drive so malicous users can't lock it on us.
* As there is no harm in issuing this to drives that don't