diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2010-05-05 11:33:27 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2010-05-05 11:33:27 +0000 |
commit | ed6b0dd01e67f4f86ed999c2df2e704b885260f2 (patch) | |
tree | 5ef27f648094ffc5d8e04a840f3700f01036f731 /sys/dev/ata | |
parent | 33a40ab9a1bfd4e4306a94e8d89664e3c35608f8 (diff) |
map the ATA data set management stuff (ie, trim) to the SCSI thin
provisioning bits in read cap 16
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/atascsi.c | 15 | ||||
-rw-r--r-- | sys/dev/ata/atascsi.h | 10 |
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 */ |