From 686c8d6af1bc97cdf2ea2ce0920c508f72f519b5 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Tue, 4 Oct 2005 08:46:51 -0400 Subject: [PATCH] --- yaml --- r: 9599 b: refs/heads/master c: c187c4b58a9caff660a4c8ae39d0def88cc449af h: refs/heads/master i: 9597: ea88bd889b0beb78ac480b75c3d95040c8d2f601 9595: d4a1c780d155ab88bbff47ecacc879295ffaed88 9591: b30c4bc6e01172acd9703a8f3ca7c4776df737bc 9583: 4bc0faf0ff891833ed16bc3988509c4e7a6b396f 9567: 8e3ddb8c2e9d87a4c7d553276a88334a8a44388f 9535: f96761dbcf4a13e4af95e7b141c48b4ba8bddd52 9471: 4661b396524078461edecbb155322d744ee91987 v: v3 --- [refs] | 2 +- trunk/drivers/scsi/libata-scsi.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 238840e52c02..8fabd8300638 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 47a8659380d40d5c0786ddb62a89b3f7f1392430 +refs/heads/master: c187c4b58a9caff660a4c8ae39d0def88cc449af diff --git a/trunk/drivers/scsi/libata-scsi.c b/trunk/drivers/scsi/libata-scsi.c index 03b7a6dd95fe..d67c3fc98f7b 100644 --- a/trunk/drivers/scsi/libata-scsi.c +++ b/trunk/drivers/scsi/libata-scsi.c @@ -589,7 +589,8 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) head = track % dev->heads; sect = (u32)block % dev->sectors + 1; - DPRINTK("block[%u] track[%u] cyl[%u] head[%u] sect[%u] \n", (u32)block, track, cyl, head, sect); + DPRINTK("block %u track %u cyl %u head %u sect %u\n", + (u32)block, track, cyl, head, sect); /* Check whether the converted CHS can fit. Cylinder: 0-65535 @@ -665,6 +666,10 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) block |= ((u64)scsicmd[3]); n_block |= ((u32)scsicmd[4]); + + /* for 6-byte r/w commands, transfer length 0 + * means 256 blocks of data, not 0 block. + */ if (!n_block) n_block = 256; @@ -692,7 +697,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) /* Check and compose ATA command */ if (!n_block) - /* In ATA, sector count 0 means 256 or 65536 sectors, not 0 sectors. */ + /* For 10-byte and 16-byte SCSI R/W commands, transfer + * length 0 means transfer 0 block of data. + * However, for ATA R/W commands, sector count 0 means + * 256 or 65536 sectors, not 0 sectors as in SCSI. + */ return 1; if (lba) { @@ -715,7 +724,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) tf->device |= (block >> 24) & 0xf; } - + qc->nsect = n_block; tf->nsect = n_block & 0xff; @@ -731,23 +740,23 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) /* The request -may- be too large for CHS addressing. */ if ((block >> 28) || (n_block > 256)) return 1; - + /* Convert LBA to CHS */ track = (u32)block / dev->sectors; cyl = track / dev->heads; head = track % dev->heads; sect = (u32)block % dev->sectors + 1; - DPRINTK("block[%u] track[%u] cyl[%u] head[%u] sect[%u] \n", + DPRINTK("block %u track %u cyl %u head %u sect %u\n", (u32)block, track, cyl, head, sect); - + /* Check whether the converted CHS can fit. Cylinder: 0-65535 Head: 0-15 Sector: 1-255*/ - if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) + if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) return 1; - + qc->nsect = n_block; tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ tf->lbal = sect;