diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2007-12-06 12:19:02 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2007-12-06 12:19:02 +0000 |
commit | fe91120c2180f5cdb7c49b510a26e847d79edd09 (patch) | |
tree | b44547cee5e4d011cb23fbeae13706496acfe6d1 | |
parent | e1f3657121e8490c48e61ba0d0a12528ea795f01 (diff) |
Ask for write cache and read look ahead to be turned
on if supported as per the wd changes. Some drives don't
do this for us and it helps performance by a large amount.
ok dlg@
-rw-r--r-- | sys/dev/ata/atascsi.c | 30 | ||||
-rw-r--r-- | sys/dev/ata/atascsi.h | 15 |
2 files changed, 43 insertions, 2 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c index 264166eaba2..4710e2a71f0 100644 --- a/sys/dev/ata/atascsi.c +++ b/sys/dev/ata/atascsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.c,v 1.51 2007/11/28 18:16:07 dlg Exp $ */ +/* $OpenBSD: atascsi.c,v 1.52 2007/12/06 12:19:01 jsg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -215,6 +215,34 @@ atascsi_probe(struct scsi_link *link) as->as_ports[port] = ap; + /* Enable write cache if supported */ + if (ap->ap_identify.cmdset82 & ATA_IDENTIFY_WRITECACHE) { + xa = ata_get_xfer(ap, 1); + if (xa == NULL) + panic("no free xfers on a new port"); + xa->fis->command = ATA_C_SET_FEATURES; + xa->fis->features = ATA_SF_WRITECACHE_EN; + xa->fis->flags = ATA_H2D_FLAGS_CMD; + xa->flags = ATA_F_READ | ATA_F_PIO | ATA_F_POLL; + xa->complete = ata_put_xfer; + xa->timeout = 1000; + ata_exec(as, xa); /* we dont care if this works or not */ + } + + /* Enable read lookahead if supported */ + if (ap->ap_identify.cmdset82 & ATA_IDENTIFY_LOOKAHEAD) { + xa = ata_get_xfer(ap, 1); + if (xa == NULL) + panic("no free xfers on a new port"); + xa->fis->command = ATA_C_SET_FEATURES; + xa->fis->features = ATA_SF_LOOKAHEAD_EN; + xa->fis->flags = ATA_H2D_FLAGS_CMD; + xa->flags = ATA_F_READ | ATA_F_PIO | ATA_F_POLL; + xa->complete = ata_put_xfer; + xa->timeout = 1000; + ata_exec(as, xa); /* we dont care if this works or not */ + } + /* * FREEZE LOCK the device so malicous users can't lock it on us. * As there is no harm in issuing this to devices that don't diff --git a/sys/dev/ata/atascsi.h b/sys/dev/ata/atascsi.h index bcef4da9f67..58de6156786 100644 --- a/sys/dev/ata/atascsi.h +++ b/sys/dev/ata/atascsi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.h,v 1.29 2007/11/28 18:16:08 dlg Exp $ */ +/* $OpenBSD: atascsi.h,v 1.30 2007/12/06 12:19:01 jsg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -33,8 +33,15 @@ struct atascsi; #define ATA_C_FLUSH_CACHE 0xe7 #define ATA_C_FLUSH_CACHE_EXT 0xea /* lba48 */ #define ATA_C_IDENTIFY 0xec +#define ATA_C_SET_FEATURES 0xef #define ATA_C_SEC_FREEZE_LOCK 0xf5 +/* + * ATA SET FEATURES subcommands + */ +#define ATA_SF_WRITECACHE_EN 0x02 +#define ATA_SF_LOOKAHEAD_EN 0xaa + struct ata_identify { u_int16_t config; /* 0 */ u_int16_t ncyls; /* 1 */ @@ -123,6 +130,12 @@ struct ata_identify { } __packed; /* + * IDENTIFY DEVICE data + */ +#define ATA_IDENTIFY_WRITECACHE (1 << 5) +#define ATA_IDENTIFY_LOOKAHEAD (1 << 6) + +/* * Frame Information Structures */ |