From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, hch@lst.de
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 2/6] libata: Report supported TRIM payload size
Date: Thu, 19 Aug 2010 11:48:57 -0400 [thread overview]
Message-ID: <1282232941-9910-3-git-send-email-martin.petersen@oracle.com> (raw)
In-Reply-To: <1282232941-9910-1-git-send-email-martin.petersen@oracle.com>
ATA IDENTIFY DEVICE word 105 contains the number of 512-byte blocks of
TRIM payload information the device can accept in one command. Use this
value to enable payloads > 512 bytes.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/ata/libata-scsi.c | 7 ++++++-
include/linux/ata.h | 9 +++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e280ae6..145f099 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2152,7 +2152,12 @@ static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf)
* with the unmap bit set.
*/
if (ata_id_has_trim(args->id)) {
- put_unaligned_be32(65535 * 512 / 8, &rbuf[20]);
+ unsigned int blocks;
+
+ /* Default to 1 if unspecified in word 105. Cap at 1 page. */
+ blocks = clamp(ata_id_trim_range_blocks(args->id), 1U, 8U);
+
+ put_unaligned_be32(65535 * 512 / 8 * blocks, &rbuf[20]);
put_unaligned_be32(1, &rbuf[28]);
}
diff --git a/include/linux/ata.h b/include/linux/ata.h
index fe6e681..5584356 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -88,6 +88,7 @@ enum {
ATA_ID_HW_CONFIG = 93,
ATA_ID_SPG = 98,
ATA_ID_LBA_CAPACITY_2 = 100,
+ ATA_ID_TRIM_RANGE_BLKS = 105,
ATA_ID_SECTOR_SIZE = 106,
ATA_ID_LAST_LUN = 126,
ATA_ID_DLF = 128,
@@ -827,6 +828,14 @@ static inline int ata_id_has_zero_after_trim(const u16 *id)
return 0;
}
+static inline unsigned int ata_id_trim_range_blocks(const u16 *id)
+{
+ if (ata_id_has_trim(id))
+ return id[ATA_ID_TRIM_RANGE_BLKS];
+
+ return 0;
+}
+
static inline int ata_id_current_chs_valid(const u16 *id)
{
/* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
--
1.7.2.1
next prev parent reply other threads:[~2010-08-19 15:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-19 15:48 Discard/trim/thin provisioning update Martin K. Petersen
2010-08-19 15:48 ` [PATCH 1/6] libata: Signal that our SATL supports WRITE SAME(16) with UNMAP Martin K. Petersen
2010-08-19 16:15 ` James Bottomley
2010-08-19 16:20 ` Martin K. Petersen
2010-08-23 8:32 ` Tejun Heo
2010-08-23 18:22 ` Douglas Gilbert
2010-08-23 18:29 ` Douglas Gilbert
2010-08-23 19:11 ` Martin K. Petersen
2010-08-19 15:48 ` Martin K. Petersen [this message]
2010-08-19 17:27 ` [PATCH 2/6] libata: Report supported TRIM payload size Greg Freemyer
2010-08-19 18:05 ` Martin K. Petersen
2010-08-19 21:08 ` Greg Freemyer
2010-08-19 21:50 ` Mark Lord
2010-08-20 8:58 ` Christoph Hellwig
2010-08-20 13:53 ` Mark Lord
2010-08-20 17:13 ` Greg Freemyer
2010-08-20 18:28 ` Mark Lord
2010-08-23 13:50 ` Christoph Hellwig
2010-08-23 18:56 ` Martin K. Petersen
2010-08-19 15:48 ` [PATCH 3/6] block: Make max_discard_sectors sector_t Martin K. Petersen
2010-08-20 8:59 ` Christoph Hellwig
2010-08-19 15:48 ` [PATCH 4/6] scsi: Fix VPD page wrapper Martin K. Petersen
2010-08-19 15:49 ` [PATCH 5/6] scsi_debug: Update thin provisioning support Martin K. Petersen
2010-08-23 16:37 ` Douglas Gilbert
2010-08-19 15:49 ` [PATCH 6/6] sd: " Martin K. Petersen
2010-08-20 9:00 ` Christoph Hellwig
2010-08-23 19:06 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282232941-9910-3-git-send-email-martin.petersen@oracle.com \
--to=martin.petersen@oracle.com \
--cc=hch@lst.de \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).