summaryrefslogtreecommitdiff
path: root/sys/dev/ata
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ata')
-rw-r--r--sys/dev/ata/atascsi.c15
-rw-r--r--sys/dev/ata/atascsi.h10
2 files changed, 20 insertions, 5 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c
index b8ae4c31d84..f0ca3666503 100644
--- a/sys/dev/ata/atascsi.c
+++ b/sys/dev/ata/atascsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atascsi.c,v 1.83 2010/04/29 22:28:39 krw Exp $ */
+/* $OpenBSD: atascsi.c,v 1.84 2010/05/05 11:33:26 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -880,6 +880,7 @@ atascsi_disk_capacity16(struct scsi_xfer *xs)
struct atascsi_port *ap = as->as_ports[link->target];
struct scsi_read_cap_data_16 rcd;
u_int align;
+ u_int16_t lowest_aligned = 0;
bzero(&rcd, sizeof(rcd));
@@ -888,7 +889,17 @@ atascsi_disk_capacity16(struct scsi_xfer *xs)
rcd.logical_per_phys = ata_identify_block_l2p_exp(&ap->ap_identify);
align = ata_identify_block_logical_align(&ap->ap_identify);
if (align > 0)
- _lto2b((1 << rcd.logical_per_phys) - align, rcd.lowest_aligned);
+ lowest_aligned = (1 << rcd.logical_per_phys) - align;
+
+ if (ISSET(letoh16(ap->ap_identify.data_set_mgmt),
+ ATA_ID_DATA_SET_MGMT_TRIM)) {
+ SET(lowest_aligned, READ_CAP_16_TPE);
+
+ if (ISSET(letoh16(ap->ap_identify.add_support),
+ ATA_ID_ADD_SUPPORT_DRT))
+ SET(lowest_aligned, READ_CAP_16_TPRZ);
+ }
+ _lto2b(lowest_aligned, rcd.lowest_aligned);
bcopy(&rcd, xs->data, MIN(sizeof(rcd), xs->datalen));
diff --git a/sys/dev/ata/atascsi.h b/sys/dev/ata/atascsi.h
index e9d4be3fd2a..4cb869131fc 100644
--- a/sys/dev/ata/atascsi.h
+++ b/sys/dev/ata/atascsi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atascsi.h,v 1.40 2010/04/22 00:58:32 dlg Exp $ */
+/* $OpenBSD: atascsi.h,v 1.41 2010/05/05 11:33:26 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -79,7 +79,9 @@ struct ata_identify {
u_int16_t recmwdma; /* 66 */
u_int16_t minpio; /* 67 */
u_int16_t minpioflow; /* 68 */
- u_int16_t reserved4[2]; /* 69 */
+ u_int16_t add_support; /* 69 */
+#define ATA_ID_ADD_SUPPORT_DRT 0x4000
+ u_int16_t reserved4; /* 70 */
u_int16_t typtime[2]; /* 71 */
u_int16_t reserved5[2]; /* 73 */
u_int16_t qdepth; /* 75 */
@@ -133,7 +135,9 @@ struct ata_identify {
u_int16_t padding3[8]; /* 160 */
u_int16_t form; /* 168 */
#define ATA_ID_FORM_MASK 0x000f
- u_int16_t padding4[7]; /* 169 */
+ u_int16_t data_set_mgmt; /* 169 */
+#define ATA_ID_DATA_SET_MGMT_TRIM 0x0001
+ u_int16_t padding4[6]; /* 170 */
u_int16_t curmedser[30]; /* 176 */
u_int16_t sctsupport; /* 206 */
u_int16_t rpm; /* 207 */