Lines Matching full:drive
57 int ide_end_rq(ide_drive_t *drive, struct request *rq, blk_status_t error, in ide_end_rq() argument
64 if ((drive->dev_flags & IDE_DFLAG_DMA_PIO_RETRY) && in ide_end_rq()
65 drive->retry_pio <= 3) { in ide_end_rq()
66 drive->dev_flags &= ~IDE_DFLAG_DMA_PIO_RETRY; in ide_end_rq()
67 ide_dma_on(drive); in ide_end_rq()
74 void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err) in ide_complete_cmd() argument
76 const struct ide_tp_ops *tp_ops = drive->hwif->tp_ops; in ide_complete_cmd()
87 tp_ops->input_data(drive, cmd, data, 2); in ide_complete_cmd()
93 ide_tf_readback(drive, cmd); in ide_complete_cmd()
99 drive->name); in ide_complete_cmd()
100 ide_tf_dump(drive->name, cmd); in ide_complete_cmd()
102 drive->dev_flags |= IDE_DFLAG_PARKED; in ide_complete_cmd()
115 int ide_complete_rq(ide_drive_t *drive, blk_status_t error, unsigned int nr_bytes) in ide_complete_rq() argument
117 ide_hwif_t *hwif = drive->hwif; in ide_complete_rq()
128 rc = ide_end_rq(drive, rq, error, nr_bytes); in ide_complete_rq()
136 void ide_kill_rq(ide_drive_t *drive, struct request *rq) in ide_kill_rq() argument
139 u8 media = drive->media; in ide_kill_rq()
141 drive->failed_pc = NULL; in ide_kill_rq()
152 ide_complete_rq(drive, BLK_STS_IOERR, blk_rq_bytes(rq)); in ide_kill_rq()
155 static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) in ide_tf_set_specify_cmd() argument
157 tf->nsect = drive->sect; in ide_tf_set_specify_cmd()
158 tf->lbal = drive->sect; in ide_tf_set_specify_cmd()
159 tf->lbam = drive->cyl; in ide_tf_set_specify_cmd()
160 tf->lbah = drive->cyl >> 8; in ide_tf_set_specify_cmd()
161 tf->device = (drive->head - 1) | drive->select; in ide_tf_set_specify_cmd()
165 static void ide_tf_set_restore_cmd(ide_drive_t *drive, struct ide_taskfile *tf) in ide_tf_set_restore_cmd() argument
167 tf->nsect = drive->sect; in ide_tf_set_restore_cmd()
171 static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf) in ide_tf_set_setmult_cmd() argument
173 tf->nsect = drive->mult_req; in ide_tf_set_setmult_cmd()
179 * @drive: drive the command is for
182 * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive.
185 static ide_startstop_t do_special(ide_drive_t *drive) in do_special() argument
190 printk(KERN_DEBUG "%s: %s: 0x%02x\n", drive->name, __func__, in do_special()
191 drive->special_flags); in do_special()
193 if (drive->media != ide_disk) { in do_special()
194 drive->special_flags = 0; in do_special()
195 drive->mult_req = 0; in do_special()
202 if (drive->special_flags & IDE_SFLAG_SET_GEOMETRY) { in do_special()
203 drive->special_flags &= ~IDE_SFLAG_SET_GEOMETRY; in do_special()
204 ide_tf_set_specify_cmd(drive, &cmd.tf); in do_special()
205 } else if (drive->special_flags & IDE_SFLAG_RECALIBRATE) { in do_special()
206 drive->special_flags &= ~IDE_SFLAG_RECALIBRATE; in do_special()
207 ide_tf_set_restore_cmd(drive, &cmd.tf); in do_special()
208 } else if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) { in do_special()
209 drive->special_flags &= ~IDE_SFLAG_SET_MULTMODE; in do_special()
210 ide_tf_set_setmult_cmd(drive, &cmd.tf); in do_special()
218 do_rw_taskfile(drive, &cmd); in do_special()
223 void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd) in ide_map_sg() argument
225 ide_hwif_t *hwif = drive->hwif; in ide_map_sg()
229 cmd->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); in ide_map_sg()
242 * execute_drive_command - issue special drive command
243 * @drive: the drive to issue the command on
246 * execute_drive_cmd() issues a special drive command, usually
248 * command can be a drive command, drive task or taskfile
253 static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, in execute_drive_cmd() argument
261 ide_map_sg(drive, cmd); in execute_drive_cmd()
264 return do_rw_taskfile(drive, cmd); in execute_drive_cmd()
272 printk("%s: DRIVE_CMD (null)\n", drive->name); in execute_drive_cmd()
275 ide_complete_rq(drive, BLK_STS_OK, blk_rq_bytes(rq)); in execute_drive_cmd()
280 static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) in ide_special_rq() argument
287 return ide_do_park_unpark(drive, rq); in ide_special_rq()
289 return ide_do_devset(drive, rq); in ide_special_rq()
291 return ide_do_reset(drive); in ide_special_rq()
306 static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) in start_request() argument
314 drive->hwif->name, (unsigned long) rq); in start_request()
318 if (drive->max_failures && (drive->failures > drive->max_failures)) { in start_request()
324 ide_check_pm_state(drive, rq); in start_request()
326 drive->hwif->tp_ops->dev_select(drive); in start_request()
327 if (ide_wait_stat(&startstop, drive, drive->ready_stat, in start_request()
329 printk(KERN_ERR "%s: drive not ready for command\n", drive->name); in start_request()
333 if (drive->special_flags == 0) { in start_request()
337 * We reset the drive so we need to issue a SETFEATURES. in start_request()
340 if (drive->current_speed == 0xff) in start_request()
341 ide_config_drive_speed(drive, drive->desired_speed); in start_request()
344 return execute_drive_cmd(drive, rq); in start_request()
349 drive->name, pm->pm_step); in start_request()
351 startstop = ide_start_power_step(drive, rq); in start_request()
354 ide_complete_pm_rq(drive, rq); in start_request()
365 return ide_special_rq(drive, rq); in start_request()
369 return drv->do_request(drive, rq, blk_rq_pos(rq)); in start_request()
371 return do_special(drive); in start_request()
373 ide_kill_rq(drive, rq); in start_request()
379 * @drive: drive to stall
382 * ide_stall_queue() can be used by a drive to give excess bandwidth back
386 void ide_stall_queue (ide_drive_t *drive, unsigned long timeout) in ide_stall_queue() argument
390 drive->sleep = timeout + jiffies; in ide_stall_queue()
391 drive->dev_flags |= IDE_DFLAG_SLEEPING; in ide_stall_queue()
443 void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) in ide_requeue_and_plug() argument
445 struct request_queue *q = drive->queue; in ide_requeue_and_plug()
458 ide_drive_t *drive = q->queuedata; in do_ide_request() local
459 ide_hwif_t *hwif = drive->hwif; in do_ide_request()
480 if (drive->dev_flags & IDE_DFLAG_SLEEPING && in do_ide_request()
481 time_after(drive->sleep, jiffies)) { in do_ide_request()
503 hwif->cur_dev = drive; in do_ide_request()
504 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); in do_ide_request()
513 rq = blk_fetch_request(drive->queue); in do_ide_request()
536 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && in do_ide_request()
548 startstop = start_request(drive, rq); in do_ide_request()
573 static int drive_is_ready(ide_drive_t *drive) in drive_is_ready() argument
575 ide_hwif_t *hwif = drive->hwif; in drive_is_ready()
578 if (drive->waiting_for_dma) in drive_is_ready()
579 return hwif->dma_ops->dma_test_irq(drive); in drive_is_ready()
589 /* drive busy: definitely not interrupting */ in drive_is_ready()
592 /* drive ready: *might* be interrupting */ in drive_is_ready()
600 * An IDE command has timed out before the expected drive return
605 * invoking the handler and checking the drive DMA status. We
613 ide_drive_t *uninitialized_var(drive); in ide_timer_expiry()
635 drive = hwif->cur_dev; in ide_timer_expiry()
638 wait = expiry(drive); in ide_timer_expiry()
660 startstop = handler(drive); in ide_timer_expiry()
661 } else if (drive_is_ready(drive)) { in ide_timer_expiry()
662 if (drive->waiting_for_dma) in ide_timer_expiry()
663 hwif->dma_ops->dma_lost_irq(drive); in ide_timer_expiry()
665 hwif->port_ops->clear_irq(drive); in ide_timer_expiry()
668 drive->name); in ide_timer_expiry()
669 startstop = handler(drive); in ide_timer_expiry()
671 if (drive->waiting_for_dma) in ide_timer_expiry()
672 startstop = ide_dma_timeout_retry(drive, wait); in ide_timer_expiry()
674 startstop = ide_error(drive, "irq timeout", in ide_timer_expiry()
691 ide_requeue_and_plug(drive, rq_in_flight); in ide_timer_expiry()
706 * the drive enters "idle", "standby", or "sleep" mode, so if the status
717 * the drive is ready to accept one, in which case we know the drive is
719 * before completing the issuance of any new drive command, so we will not
753 * a command. hwif->cur_dev is the drive and hwif->handler is
771 ide_drive_t *uninitialized_var(drive); in ide_intr()
794 * Not expecting an interrupt from this drive. in ide_intr()
798 * or (2) a drive just entered sleep or standby mode, in ide_intr()
821 drive = hwif->cur_dev; in ide_intr()
823 if (!drive_is_ready(drive)) in ide_intr()
840 hwif->port_ops->clear_irq(drive); in ide_intr()
842 if (drive->dev_flags & IDE_DFLAG_UNMASK) in ide_intr()
846 startstop = handler(drive); in ide_intr()
869 ide_requeue_and_plug(drive, rq_in_flight); in ide_intr()
876 void ide_pad_transfer(ide_drive_t *drive, int write, int len) in ide_pad_transfer() argument
878 ide_hwif_t *hwif = drive->hwif; in ide_pad_transfer()
883 hwif->tp_ops->output_data(drive, NULL, buf, min(4, len)); in ide_pad_transfer()
885 hwif->tp_ops->input_data(drive, NULL, buf, min(4, len)); in ide_pad_transfer()