Skip to contentSkip to conversation

atang tree: enhanced SSD detection

PATCH In review Bartlomiej Zolnierkiewicz 2 participants 3 messages Feb 21, 2010 – Feb 23, 2010 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 atang tree: enhanced SSD detection

DISCLAIMER: the fact of getting patches merged into atang tree means that from now on they will be getting updates for changes happening in atang tree and it should not be treated as an indication regarding decisions taken by 'upstream' kernel trees

Improve SSD detection so block layer optimizations can be applied to many more SSD devices.

The following changes since commit 17c619273d412ed7b6120e448f87b2329457fc90:
Bartlomiej Zolnierkiewicz (1):
pata_oldpiix: enable parallel scan

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/bart/misc.git atang-v4.7

Bartlomiej Zolnierkiewicz (1):
libata: enhanced SSD detection

 drivers/ata/libata-core.c |    3 +++
 drivers/ata/libata-scsi.c |   18 ++++++++++--------
 include/linux/libata.h    |    1 +
 3 files changed, 14 insertions(+), 8 deletions(-)

commit ded92e0d01fbb7f27bec7a35606847a2547e95e0

Author: Bartlomiej Zolnierkiewicz <[email protected]>
Date:   Sun Feb 21 18:31:18 2010 +0100

libata: enhanced SSD detection

Many SSD devices predate or just don't implement non-rotational media type advertisement through the word 217 of the id block so check also the product id for 'SSD' substring to automatically detect SSD devices and apply relevant block layer optimizations.

This is based on earlier Jeff Garzik's patch from April 2009:
http://lkml.org/lkml/2009/4/7/495

While at it:
- cleanup ata_scsi_dev_config() a bit

Tested with ASUS-PHISON SSD devices found in Asus Eee 901.

drivers/ata/libata-core.c +3 -0
index 984d7bc..743ac77 100644
@@ -2485,6 +2485,9 @@ int ata_dev_configure(struct ata_device *dev)
 					dev->multi_count = cnt;
 		}
 
+		if (strstr(modelbuf, "SSD"))
+			dev->flags |= ATA_DFLAG_NONROT;
+
 		if (ata_id_has_lba(id)) {
 			const char *lba_desc;
 			char ncq_desc[24];
drivers/ata/libata-scsi.c +10 -8
index 62e6b9e..df4a963 100644
@@ -1093,21 +1093,20 @@ static int atapi_drain_needed(struct request *rq)
 static int ata_scsi_dev_config(struct scsi_device *sdev,
 			       struct ata_device *dev)
 {
+	struct request_queue *q = sdev->request_queue;
+
 	if (!ata_id_has_unload(dev->id))
 		dev->flags |= ATA_DFLAG_NO_UNLOAD;
 
 	/* configure max sectors */
-	blk_queue_max_sectors(sdev->request_queue, dev->max_sectors);
+	blk_queue_max_sectors(q, dev->max_sectors);
 
 	if (dev->class == ATA_DEV_ATAPI) {
-		struct request_queue *q = sdev->request_queue;
 		void *buf;
 
 		/* set the min alignment and padding */
-		blk_queue_update_dma_alignment(sdev->request_queue,
-					       ATA_DMA_PAD_SZ - 1);
-		blk_queue_update_dma_pad(sdev->request_queue,
-					 ATA_DMA_PAD_SZ - 1);
+		blk_queue_update_dma_alignment(q, ATA_DMA_PAD_SZ - 1);
+		blk_queue_update_dma_pad(q, ATA_DMA_PAD_SZ - 1);
 
 		/* configure draining */
 		buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL);
@@ -1120,9 +1119,12 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
 		blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN);
 	} else {
 		/* ATA devices must be sector aligned */
-		blk_queue_update_dma_alignment(sdev->request_queue,
-					       ATA_SECT_SIZE - 1);
+		blk_queue_update_dma_alignment(q, ATA_SECT_SIZE - 1);
+
 		sdev->manage_start_stop = 1;
+
+		if (dev->flags & ATA_DFLAG_NONROT)
+			queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
 	}
 
 	if (dev->flags & ATA_DFLAG_AN)
include/linux/libata.h +1 -0
index d06e293..1e3b106 100644
@@ -146,6 +146,7 @@ enum {
 	ATA_DFLAG_SLEEPING	= (1 << 15), /* device is sleeping */
 	ATA_DFLAG_DUBIOUS_XFER	= (1 << 16), /* data transfer not verified */
 	ATA_DFLAG_NO_UNLOAD	= (1 << 17), /* device doesn't support unload */
+	ATA_DFLAG_NONROT        = (1 << 18), /* is non-rotational media, SSD */
 	ATA_DFLAG_INIT_MASK	= (1 << 24) - 1,
 
 	ATA_DFLAG_DETACH	= (1 << 24),
#1 lore raw
Quoted 41 lines · Bartlomiej Zolnierkiewicz

DISCLAIMER: the fact of getting patches merged into atang tree means that from now on they will be getting updates for changes happening in atang tree and it should not be treated as an indication regarding decisions taken by 'upstream' kernel trees

Improve SSD detection so block layer optimizations can be applied to many more SSD devices.

The following changes since commit 17c619273d412ed7b6120e448f87b2329457fc90:
Bartlomiej Zolnierkiewicz (1):
pata_oldpiix: enable parallel scan

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/bart/misc.git atang-v4.7

Bartlomiej Zolnierkiewicz (1):
libata: enhanced SSD detection

  drivers/ata/libata-core.c |    3 +++
  drivers/ata/libata-scsi.c |   18 ++++++++++--------
  include/linux/libata.h    |    1 +
  3 files changed, 14 insertions(+), 8 deletions(-)

commit ded92e0d01fbb7f27bec7a35606847a2547e95e0

Author: Bartlomiej Zolnierkiewicz<[email protected]>
Date:   Sun Feb 21 18:31:18 2010 +0100

libata: enhanced SSD detection

Many SSD devices predate or just don't implement non-rotational media type advertisement through the word 217 of the id block so check also the product id for 'SSD' substring to automatically detect SSD devices and apply relevant block layer optimizations.

This is based on earlier Jeff Garzik's patch from April 2009:
http://lkml.org/lkml/2009/4/7/495

Quoted 7 lines

While at it:
- cleanup ata_scsi_dev_config() a bit

Tested with ASUS-PHISON SSD devices found in Asus Eee 901.

Yes, I agree we need something like this. I will review for atang dependencies, and then make sure it gets applied to upstream.

The previous discussion of this approach concluded weakly with "poor heuristic", but a better approach did not materialize.

One question, though: why did you drop ata_id_is_ssd() test?

Jeff

#2 lore raw
Quoted 50 lines · Jeff Garzik
Quoted 41 lines · Bartlomiej Zolnierkiewicz

DISCLAIMER: the fact of getting patches merged into atang tree means that from now on they will be getting updates for changes happening in atang tree and it should not be treated as an indication regarding decisions taken by 'upstream' kernel trees

Improve SSD detection so block layer optimizations can be applied to many more SSD devices.

The following changes since commit 17c619273d412ed7b6120e448f87b2329457fc90:
Bartlomiej Zolnierkiewicz (1):
pata_oldpiix: enable parallel scan

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/bart/misc.git atang-v4.7

Bartlomiej Zolnierkiewicz (1):
libata: enhanced SSD detection

  drivers/ata/libata-core.c |    3 +++
  drivers/ata/libata-scsi.c |   18 ++++++++++--------
  include/linux/libata.h    |    1 +
  3 files changed, 14 insertions(+), 8 deletions(-)

commit ded92e0d01fbb7f27bec7a35606847a2547e95e0

Author: Bartlomiej Zolnierkiewicz<[email protected]>
Date:   Sun Feb 21 18:31:18 2010 +0100

libata: enhanced SSD detection

Many SSD devices predate or just don't implement non-rotational media type advertisement through the word 217 of the id block so check also the product id for 'SSD' substring to automatically detect SSD devices and apply relevant block layer optimizations.

This is based on earlier Jeff Garzik's patch from April 2009:
http://lkml.org/lkml/2009/4/7/495

Quoted 7 lines

While at it:
- cleanup ata_scsi_dev_config() a bit

Tested with ASUS-PHISON SSD devices found in Asus Eee 901.

Quoted 7 lines

Yes, I agree we need something like this. I will review for atang dependencies, and then make sure it gets applied to upstream.

The previous discussion of this approach concluded weakly with "poor heuristic", but a better approach did not materialize.

One question, though: why did you drop ata_id_is_ssd() test?

This test is not in the 'upstream' any longer as 'standard' detection is now handled through libata-scsi emulation layer (after SSD related SCSI changes made by Martin K. Petersen, commit f17259a etc).

--
Bartlomiej Zolnierkiewicz