All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: rwheeler@redhat.com, snitzer@redhat.com, jeff@garzik.org,
	neilb@suse.de, James.Bottomley@hansenpartnership.com,
	dgilbert@interlog.com, jens.axboe@oracle.com,
	linux-ide@vger.kernel.org
Subject: [PATCH 8 of 8] libata: Report disk alignment and physical block size
Date: Thu, 23 Apr 2009 01:29:35 -0400	[thread overview]
Message-ID: <29bae7aef942a1709bb6.1240464575__47815.5637080365$1240465892$gmane$org@sermon.lab.mkp.net> (raw)
In-Reply-To: <patchbomb.1240464567@sermon.lab.mkp.net>

For disks with 4KB sectors, report the correct block size and alignment
when filling out the READ CAPACITY(16) response.

This patch is based upon code from Matthew Wilcox' 4KB ATA tree.  I
fixed the bug I reported a while back caused by ATA and SCSI using
different approaches to describing the alignment.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

---
1 file changed, 20 insertions(+)
drivers/ata/libata-scsi.c |   20 ++++++++++++++++++++



diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2376,7 +2376,22 @@ saving_not_supp:
  */
 static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf)
 {
+	struct ata_device *dev = args->dev;
 	u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */
+	u8 log_per_phys = 0;
+	u16 lowest_aligned_lba = 0;
+	u16 word_106 = dev->id[106];
+	u16 word_209 = dev->id[209];
+
+	if ((word_106 & 0xc000) == 0x4000) {
+		/* Number and offset of logical sectors per physical sector */
+		if (word_106 & (1 << 13))
+			log_per_phys = word_106 & 0xf;
+		if ((word_209 & 0xc000) == 0x4000)
+			lowest_aligned_lba =
+				((1 << log_per_phys) - (word_209 & 0x3fff))
+				% (1 << log_per_phys);
+	}
 
 	VPRINTK("ENTER\n");
 
@@ -2407,6 +2422,11 @@ static unsigned int ata_scsiop_read_cap(
 		/* sector size */
 		rbuf[10] = ATA_SECT_SIZE >> 8;
 		rbuf[11] = ATA_SECT_SIZE & 0xff;
+
+		rbuf[12] = 0;
+		rbuf[13] = log_per_phys;
+		rbuf[14] = (lowest_aligned_lba >> 8) & 0x3f;
+		rbuf[15] = lowest_aligned_lba;
 	}
 
 	return 0;



      parent reply	other threads:[~2009-04-23  5:49 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-23  5:29 [PATCH 0 of 8] I/O topology patch kit Martin K. Petersen
2009-04-23  5:29 ` [PATCH 1 of 8] block: Expose stacked device queues in sysfs Martin K. Petersen
2009-04-23  5:29 ` Martin K. Petersen
2009-04-23  5:29 ` [PATCH 2 of 8] block: Export I/O topology for block devices and partitions Martin K. Petersen
2009-04-23 10:51   ` Jens Axboe
2009-04-23 11:49     ` Matthew Wilcox
2009-04-23 11:55       ` Jens Axboe
2009-04-23 13:22         ` Matthew Wilcox
2009-04-23 13:30           ` Matthew Wilcox
2009-04-23 13:17     ` Martin K. Petersen
2009-04-23 18:13     ` Konrad Rzeszutek
2009-04-23 18:26       ` Ric Wheeler
2009-04-23 18:44         ` Matthew Wilcox
2009-04-23 18:34       ` Martin K. Petersen
2009-04-23  5:29 ` [PATCH 3 of 8] MD: Use new topology calls to indicate alignment and I/O sizes Martin K. Petersen
2009-04-23  5:29 ` [PATCH 4 of 8] sd: Physical block size and alignment support Martin K. Petersen
2009-04-23 16:37   ` Konrad Rzeszutek
2009-04-23 18:25     ` Martin K. Petersen
2009-04-23 18:44       ` Konrad Rzeszutek
2009-04-23 19:02         ` Martin K. Petersen
2009-04-23  5:29 ` Martin K. Petersen
2009-04-23  5:29 ` [PATCH 5 of 8] sd: Detect non-rotational devices Martin K. Petersen
2009-04-23 10:52   ` Jens Axboe
2009-04-23 11:09     ` Jeff Garzik
2009-04-23 11:13       ` Jens Axboe
2009-04-23 11:22         ` Jeff Garzik
2009-04-23 11:38       ` Matthew Wilcox
2009-04-23 11:58         ` Jeff Garzik
2009-04-23 12:03           ` Jens Axboe
2009-04-23 13:16         ` Martin K. Petersen
2009-04-23 13:33           ` Jeff Garzik
2009-04-23 14:10             ` James Bottomley
2009-04-23 14:16               ` Matthew Wilcox
2009-04-23 14:39                 ` Jeff Garzik
2009-04-23 17:25                   ` Matthew Wilcox
2009-04-23 17:37                     ` James Bottomley
2009-04-23  5:29 ` [PATCH 6 of 8] sd: Block limits VPD support Martin K. Petersen
2009-04-23  5:29 ` [PATCH 7 of 8] scsi_debug: Add support for physical block exponent and alignment Martin K. Petersen
2009-04-23  5:29 ` [PATCH 8 of 8] libata: Report disk alignment and physical block size Martin K. Petersen
2009-04-23 13:46   ` Matthew Wilcox
2009-04-23 14:05     ` Martin K. Petersen
2009-04-23  5:29 ` Martin K. Petersen [this message]

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='29bae7aef942a1709bb6.1240464575__47815.5637080365$1240465892$gmane$org@sermon.lab.mkp.net' \
    --to=martin.petersen@oracle.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dgilbert@interlog.com \
    --cc=jeff@garzik.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=rwheeler@redhat.com \
    --cc=snitzer@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.