ide: fix HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices

Add IDE_DFLAG_LBA device flag and use it instead of ->select.b.lba.

Since ->tf_load uses ->select.all for ATA Device/Head register this
fixes HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent c67c216d
...@@ -162,7 +162,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, ...@@ -162,7 +162,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
memset(&task, 0, sizeof(task)); memset(&task, 0, sizeof(task));
task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
if (drive->select.b.lba) { if (drive->dev_flags & IDE_DFLAG_LBA) {
if (lba48) { if (lba48) {
pr_debug("%s: LBA=0x%012llx\n", drive->name, pr_debug("%s: LBA=0x%012llx\n", drive->name,
(unsigned long long)block); (unsigned long long)block);
...@@ -187,6 +187,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, ...@@ -187,6 +187,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
tf->lbah = block >>= 8; tf->lbah = block >>= 8;
tf->device = (block >> 8) & 0xf; tf->device = (block >> 8) & 0xf;
} }
tf->device |= ATA_LBA;
} else { } else {
unsigned int sect, head, cyl, track; unsigned int sect, head, cyl, track;
...@@ -384,28 +386,32 @@ static void idedisk_check_hpa(ide_drive_t *drive) ...@@ -384,28 +386,32 @@ static void idedisk_check_hpa(ide_drive_t *drive)
static void init_idedisk_capacity(ide_drive_t *drive) static void init_idedisk_capacity(ide_drive_t *drive)
{ {
u16 *id = drive->id; u16 *id = drive->id;
/* int lba;
* If this drive supports the Host Protected Area feature set,
* then we may need to change our opinion about the drive's capacity.
*/
int hpa = ata_id_hpa_enabled(id);
if (ata_id_lba48_enabled(id)) { if (ata_id_lba48_enabled(id)) {
/* drive speaks 48-bit LBA */ /* drive speaks 48-bit LBA */
drive->select.b.lba = 1; lba = 1;
drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
if (hpa)
idedisk_check_hpa(drive);
} else if (ata_id_has_lba(id) && ata_id_is_lba_capacity_ok(id)) { } else if (ata_id_has_lba(id) && ata_id_is_lba_capacity_ok(id)) {
/* drive speaks 28-bit LBA */ /* drive speaks 28-bit LBA */
drive->select.b.lba = 1; lba = 1;
drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY); drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
if (hpa)
idedisk_check_hpa(drive);
} else { } else {
/* drive speaks boring old 28-bit CHS */ /* drive speaks boring old 28-bit CHS */
lba = 0;
drive->capacity64 = drive->cyl * drive->head * drive->sect; drive->capacity64 = drive->cyl * drive->head * drive->sect;
} }
if (lba) {
drive->dev_flags |= IDE_DFLAG_LBA;
/*
* If this device supports the Host Protected Area feature set,
* then we may need to change our opinion about its capacity.
*/
if (ata_id_hpa_enabled(id))
idedisk_check_hpa(drive);
}
} }
static sector_t idedisk_capacity(ide_drive_t *drive) static sector_t idedisk_capacity(ide_drive_t *drive)
...@@ -1110,7 +1116,8 @@ static int ide_disk_probe(ide_drive_t *drive) ...@@ -1110,7 +1116,8 @@ static int ide_disk_probe(ide_drive_t *drive)
drive->driver_data = idkp; drive->driver_data = idkp;
idedisk_setup(drive); idedisk_setup(drive);
if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 &&
(drive->head == 0 || drive->head > 16)) {
printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n",
drive->name, drive->head); drive->name, drive->head);
drive->dev_flags &= ~IDE_DFLAG_ATTACH; drive->dev_flags &= ~IDE_DFLAG_ATTACH;
......
...@@ -383,7 +383,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 ...@@ -383,7 +383,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
} else if (stat & ATA_ERR) { } else if (stat & ATA_ERR) {
/* err has different meaning on cdrom and tape */ /* err has different meaning on cdrom and tape */
if (err == ATA_ABORTED) { if (err == ATA_ABORTED) {
if (drive->select.b.lba && if ((drive->dev_flags & IDE_DFLAG_LBA) &&
/* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */
hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS) hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS)
return ide_stopped; return ide_stopped;
...@@ -513,7 +513,7 @@ static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) ...@@ -513,7 +513,7 @@ static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
tf->lbal = drive->sect; tf->lbal = drive->sect;
tf->lbam = drive->cyl; tf->lbam = drive->cyl;
tf->lbah = drive->cyl >> 8; tf->lbah = drive->cyl >> 8;
tf->device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; tf->device = (drive->head - 1) | drive->select.all;
tf->command = ATA_CMD_INIT_DEV_PARAMS; tf->command = ATA_CMD_INIT_DEV_PARAMS;
} }
......
...@@ -502,6 +502,7 @@ enum { ...@@ -502,6 +502,7 @@ enum {
IDE_DFLAG_NOWERR = (1 << 24), IDE_DFLAG_NOWERR = (1 << 24),
/* retrying in PIO */ /* retrying in PIO */
IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), IDE_DFLAG_DMA_PIO_RETRY = (1 << 25),
IDE_DFLAG_LBA = (1 << 26),
}; };
struct ide_drive_s { struct ide_drive_s {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment