ide: remove unnecessary writes to HOB taskfile registers

* Set taskfile flags for REQ_TYPE_ATA_TASKFILE requests before
  adding the request to the queue.

* Cleanup execute_drive_cmd().

* Remove unnecessary writes to HOB taskfile registers when using
  LBA48 disk for the following cases:

  - Power Management requests
    (WIN_FLUSH_CACHE[_EXT], WIN_STANDBYNOW1, WIN_IDLEIMMEDIATE commands)

  - special commands (WIN_SPECIFY, WIN_RESTORE, WIN_SETMULT)

  - Host Protected Area support (WIN_READ_NATIVE_MAX, WIN_SET_MAX)

  - /proc/ide/ SMART support (WIN_SMART with SMART_ENABLE,
    SMART_READ_VALUES and SMART_READ_THRESHOLDS subcommands)

  - write cache enabling/disabling in ide-disk
    (WIN_SETFEATURES with SETFEATURES_{EN,DIS}_WCACHE)

  - write cache flushing in ide-disk (WIN_FLUSH_CACHE[_EXT])

  - acoustic management in ide-disk
    (WIN_SETFEATURES with SETFEATURES_{EN,DIS}_AAM)

  - door (un)locking in ide-disk (WIN_DOORLOCK, WIN_DOORUNLOCK)

  - /proc/ide/hd?/identify support (WIN_IDENTIFY)

  - ACPI _GTF taskfiles
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 868e672a
...@@ -386,6 +386,7 @@ static int taskfile_load_raw(ide_drive_t *drive, ...@@ -386,6 +386,7 @@ static int taskfile_load_raw(ide_drive_t *drive,
/* convert gtf to IDE Taskfile */ /* convert gtf to IDE Taskfile */
memcpy(&args.tf_array[7], &gtf->tfa, 7); memcpy(&args.tf_array[7], &gtf->tfa, 7);
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
if (ide_noacpitfs) { if (ide_noacpitfs) {
DEBPRINT("_GTF execution disabled\n"); DEBPRINT("_GTF execution disabled\n");
......
...@@ -304,6 +304,9 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) ...@@ -304,6 +304,9 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)
else else
tf->command = WIN_READ_NATIVE_MAX; tf->command = WIN_READ_NATIVE_MAX;
tf->device = ATA_LBA; tf->device = ATA_LBA;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
if (lba48)
args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
/* submit command request */ /* submit command request */
ide_no_data_taskfile(drive, &args); ide_no_data_taskfile(drive, &args);
...@@ -349,6 +352,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) ...@@ -349,6 +352,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
tf->command = WIN_SET_MAX; tf->command = WIN_SET_MAX;
} }
tf->device |= ATA_LBA; tf->device |= ATA_LBA;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
if (lba48)
args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
/* submit command request */ /* submit command request */
ide_no_data_taskfile(drive, &args); ide_no_data_taskfile(drive, &args);
/* if OK, compute maximum address value */ /* if OK, compute maximum address value */
...@@ -497,6 +503,7 @@ static int smart_enable(ide_drive_t *drive) ...@@ -497,6 +503,7 @@ static int smart_enable(ide_drive_t *drive)
tf->lbam = SMART_LCYL_PASS; tf->lbam = SMART_LCYL_PASS;
tf->lbah = SMART_HCYL_PASS; tf->lbah = SMART_HCYL_PASS;
tf->command = WIN_SMART; tf->command = WIN_SMART;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
return ide_no_data_taskfile(drive, &args); return ide_no_data_taskfile(drive, &args);
} }
...@@ -511,6 +518,7 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) ...@@ -511,6 +518,7 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
tf->lbam = SMART_LCYL_PASS; tf->lbam = SMART_LCYL_PASS;
tf->lbah = SMART_HCYL_PASS; tf->lbah = SMART_HCYL_PASS;
tf->command = WIN_SMART; tf->command = WIN_SMART;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
args.command_type = IDE_DRIVE_TASK_IN; args.command_type = IDE_DRIVE_TASK_IN;
args.data_phase = TASKFILE_IN; args.data_phase = TASKFILE_IN;
args.handler = &task_in_intr; args.handler = &task_in_intr;
...@@ -690,6 +698,7 @@ static int write_cache(ide_drive_t *drive, int arg) ...@@ -690,6 +698,7 @@ static int write_cache(ide_drive_t *drive, int arg)
args.tf.feature = arg ? args.tf.feature = arg ?
SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE;
args.tf.command = WIN_SETFEATURES; args.tf.command = WIN_SETFEATURES;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
err = ide_no_data_taskfile(drive, &args); err = ide_no_data_taskfile(drive, &args);
if (err == 0) if (err == 0)
drive->wcache = arg; drive->wcache = arg;
...@@ -709,6 +718,7 @@ static int do_idedisk_flushcache (ide_drive_t *drive) ...@@ -709,6 +718,7 @@ static int do_idedisk_flushcache (ide_drive_t *drive)
args.tf.command = WIN_FLUSH_CACHE_EXT; args.tf.command = WIN_FLUSH_CACHE_EXT;
else else
args.tf.command = WIN_FLUSH_CACHE; args.tf.command = WIN_FLUSH_CACHE;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
return ide_no_data_taskfile(drive, &args); return ide_no_data_taskfile(drive, &args);
} }
...@@ -723,6 +733,7 @@ static int set_acoustic (ide_drive_t *drive, int arg) ...@@ -723,6 +733,7 @@ static int set_acoustic (ide_drive_t *drive, int arg)
args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM;
args.tf.nsect = arg; args.tf.nsect = arg;
args.tf.command = WIN_SETFEATURES; args.tf.command = WIN_SETFEATURES;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
ide_no_data_taskfile(drive, &args); ide_no_data_taskfile(drive, &args);
drive->acoustic = arg; drive->acoustic = arg;
return 0; return 0;
...@@ -985,6 +996,7 @@ static int idedisk_open(struct inode *inode, struct file *filp) ...@@ -985,6 +996,7 @@ static int idedisk_open(struct inode *inode, struct file *filp)
ide_task_t args; ide_task_t args;
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tf.command = WIN_DOORLOCK; args.tf.command = WIN_DOORLOCK;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
check_disk_change(inode->i_bdev); check_disk_change(inode->i_bdev);
/* /*
* Ignore the return code from door_lock, * Ignore the return code from door_lock,
...@@ -1010,6 +1022,7 @@ static int idedisk_release(struct inode *inode, struct file *filp) ...@@ -1010,6 +1022,7 @@ static int idedisk_release(struct inode *inode, struct file *filp)
ide_task_t args; ide_task_t args;
memset(&args, 0, sizeof(ide_task_t)); memset(&args, 0, sizeof(ide_task_t));
args.tf.command = WIN_DOORUNLOCK; args.tf.command = WIN_DOORUNLOCK;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) if (drive->doorlocking && ide_no_data_taskfile(drive, &args))
drive->doorlocking = 0; drive->doorlocking = 0;
} }
......
...@@ -233,8 +233,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * ...@@ -233,8 +233,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
out_do_tf: out_do_tf:
args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
if (drive->addressing == 1)
args->tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
args->command_type = IDE_DRIVE_TASK_NO_DATA; args->command_type = IDE_DRIVE_TASK_NO_DATA;
args->handler = task_no_data_intr; args->handler = task_no_data_intr;
return do_rw_taskfile(drive, args); return do_rw_taskfile(drive, args);
...@@ -711,8 +709,6 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) ...@@ -711,8 +709,6 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive)
} }
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
if (drive->addressing == 1)
args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
do_rw_taskfile(drive, &args); do_rw_taskfile(drive, &args);
...@@ -871,17 +867,9 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, ...@@ -871,17 +867,9 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
break; break;
} }
task->tf_flags |= IDE_TFLAG_OUT_DEVICE;
if (drive->addressing == 1)
task->tf_flags |= IDE_TFLAG_LBA48;
if (task->tf_flags & IDE_TFLAG_FLAGGED) if (task->tf_flags & IDE_TFLAG_FLAGGED)
return flagged_taskfile(drive, task); return flagged_taskfile(drive, task);
task->tf_flags |= IDE_TFLAG_OUT_TF;
if (task->tf_flags & IDE_TFLAG_LBA48)
task->tf_flags |= IDE_TFLAG_OUT_HOB;
return do_rw_taskfile(drive, task); return do_rw_taskfile(drive, task);
} }
......
...@@ -126,6 +126,7 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) ...@@ -126,6 +126,7 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
args.tf.command = WIN_IDENTIFY; args.tf.command = WIN_IDENTIFY;
else else
args.tf.command = WIN_PIDENTIFY; args.tf.command = WIN_PIDENTIFY;
args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
args.command_type = IDE_DRIVE_TASK_IN; args.command_type = IDE_DRIVE_TASK_IN;
args.data_phase = TASKFILE_IN; args.data_phase = TASKFILE_IN;
args.handler = &task_in_intr; args.handler = &task_in_intr;
...@@ -619,6 +620,10 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) ...@@ -619,6 +620,10 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
args.data_phase = req_task->data_phase; args.data_phase = req_task->data_phase;
args.command_type = req_task->req_cmd; args.command_type = req_task->req_cmd;
args.tf_flags = IDE_TFLAG_OUT_DEVICE;
if (drive->addressing == 1)
args.tf_flags |= IDE_TFLAG_LBA48;
if (req_task->out_flags.all) { if (req_task->out_flags.all) {
args.tf_flags |= IDE_TFLAG_FLAGGED; args.tf_flags |= IDE_TFLAG_FLAGGED;
...@@ -644,6 +649,10 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) ...@@ -644,6 +649,10 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
args.tf_flags |= IDE_TFLAG_OUT_LBAM; args.tf_flags |= IDE_TFLAG_OUT_LBAM;
if (req_task->out_flags.b.hcyl) if (req_task->out_flags.b.hcyl)
args.tf_flags |= IDE_TFLAG_OUT_LBAH; args.tf_flags |= IDE_TFLAG_OUT_LBAH;
} else {
args.tf_flags |= IDE_TFLAG_OUT_TF;
if (args.tf_flags & IDE_TFLAG_LBA48)
args.tf_flags |= IDE_TFLAG_OUT_HOB;
} }
drive->io_32bit = 0; drive->io_32bit = 0;
......
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