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()
71 if (rq == drive->sense_rq) { in ide_end_rq()
72 drive->sense_rq = NULL; in ide_end_rq()
73 drive->sense_rq_active = false; in ide_end_rq()
84 void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err) in ide_complete_cmd() argument
86 const struct ide_tp_ops *tp_ops = drive->hwif->tp_ops; in ide_complete_cmd()
97 tp_ops->input_data(drive, cmd, data, 2); in ide_complete_cmd()
103 ide_tf_readback(drive, cmd); in ide_complete_cmd()
109 drive->name); in ide_complete_cmd()
110 ide_tf_dump(drive->name, cmd); in ide_complete_cmd()
112 drive->dev_flags |= IDE_DFLAG_PARKED; in ide_complete_cmd()
125 int ide_complete_rq(ide_drive_t *drive, blk_status_t error, unsigned int nr_bytes) in ide_complete_rq() argument
127 ide_hwif_t *hwif = drive->hwif; in ide_complete_rq()
138 rc = ide_end_rq(drive, rq, error, nr_bytes); in ide_complete_rq()
146 void ide_kill_rq(ide_drive_t *drive, struct request *rq) in ide_kill_rq() argument
149 u8 media = drive->media; in ide_kill_rq()
151 drive->failed_pc = NULL; in ide_kill_rq()
162 ide_complete_rq(drive, BLK_STS_IOERR, blk_rq_bytes(rq)); in ide_kill_rq()
165 static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) in ide_tf_set_specify_cmd() argument
167 tf->nsect = drive->sect; in ide_tf_set_specify_cmd()
168 tf->lbal = drive->sect; in ide_tf_set_specify_cmd()
169 tf->lbam = drive->cyl; in ide_tf_set_specify_cmd()
170 tf->lbah = drive->cyl >> 8; in ide_tf_set_specify_cmd()
171 tf->device = (drive->head - 1) | drive->select; in ide_tf_set_specify_cmd()
175 static void ide_tf_set_restore_cmd(ide_drive_t *drive, struct ide_taskfile *tf) in ide_tf_set_restore_cmd() argument
177 tf->nsect = drive->sect; in ide_tf_set_restore_cmd()
181 static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf) in ide_tf_set_setmult_cmd() argument
183 tf->nsect = drive->mult_req; in ide_tf_set_setmult_cmd()
189 * @drive: drive the command is for
192 * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive.
195 static ide_startstop_t do_special(ide_drive_t *drive) in do_special() argument
200 printk(KERN_DEBUG "%s: %s: 0x%02x\n", drive->name, __func__, in do_special()
201 drive->special_flags); in do_special()
203 if (drive->media != ide_disk) { in do_special()
204 drive->special_flags = 0; in do_special()
205 drive->mult_req = 0; in do_special()
212 if (drive->special_flags & IDE_SFLAG_SET_GEOMETRY) { in do_special()
213 drive->special_flags &= ~IDE_SFLAG_SET_GEOMETRY; in do_special()
214 ide_tf_set_specify_cmd(drive, &cmd.tf); in do_special()
215 } else if (drive->special_flags & IDE_SFLAG_RECALIBRATE) { in do_special()
216 drive->special_flags &= ~IDE_SFLAG_RECALIBRATE; in do_special()
217 ide_tf_set_restore_cmd(drive, &cmd.tf); in do_special()
218 } else if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) { in do_special()
219 drive->special_flags &= ~IDE_SFLAG_SET_MULTMODE; in do_special()
220 ide_tf_set_setmult_cmd(drive, &cmd.tf); in do_special()
228 do_rw_taskfile(drive, &cmd); in do_special()
233 void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd) in ide_map_sg() argument
235 ide_hwif_t *hwif = drive->hwif; in ide_map_sg()
239 cmd->sg_nents = __blk_rq_map_sg(drive->queue, rq, sg, &last_sg); in ide_map_sg()
255 * execute_drive_command - issue special drive command
256 * @drive: the drive to issue the command on
259 * execute_drive_cmd() issues a special drive command, usually
261 * command can be a drive command, drive task or taskfile
266 static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, in execute_drive_cmd() argument
274 ide_map_sg(drive, cmd); in execute_drive_cmd()
277 return do_rw_taskfile(drive, cmd); in execute_drive_cmd()
285 printk("%s: DRIVE_CMD (null)\n", drive->name); in execute_drive_cmd()
288 ide_complete_rq(drive, BLK_STS_OK, blk_rq_bytes(rq)); in execute_drive_cmd()
293 static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) in ide_special_rq() argument
300 return ide_do_park_unpark(drive, rq); in ide_special_rq()
302 return ide_do_devset(drive, rq); in ide_special_rq()
304 return ide_do_reset(drive); in ide_special_rq()
319 static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) in start_request() argument
325 drive->hwif->name, (unsigned long) rq); in start_request()
329 if (drive->max_failures && (drive->failures > drive->max_failures)) { in start_request()
334 if (drive->prep_rq && !drive->prep_rq(drive, rq)) in start_request()
338 ide_check_pm_state(drive, rq); in start_request()
340 drive->hwif->tp_ops->dev_select(drive); in start_request()
341 if (ide_wait_stat(&startstop, drive, drive->ready_stat, in start_request()
343 printk(KERN_ERR "%s: drive not ready for command\n", drive->name); in start_request()
347 if (drive->special_flags == 0) { in start_request()
351 * We reset the drive so we need to issue a SETFEATURES. in start_request()
354 if (drive->current_speed == 0xff) in start_request()
355 ide_config_drive_speed(drive, drive->desired_speed); in start_request()
358 return execute_drive_cmd(drive, rq); in start_request()
363 drive->name, pm->pm_step); in start_request()
365 startstop = ide_start_power_step(drive, rq); in start_request()
368 ide_complete_pm_rq(drive, rq); in start_request()
379 return ide_special_rq(drive, rq); in start_request()
383 return drv->do_request(drive, rq, blk_rq_pos(rq)); in start_request()
385 return do_special(drive); in start_request()
387 ide_kill_rq(drive, rq); in start_request()
393 * @drive: drive to stall
396 * ide_stall_queue() can be used by a drive to give excess bandwidth back
400 void ide_stall_queue (ide_drive_t *drive, unsigned long timeout) in ide_stall_queue() argument
404 drive->sleep = timeout + jiffies; in ide_stall_queue()
405 drive->dev_flags |= IDE_DFLAG_SLEEPING; in ide_stall_queue()
447 void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) in ide_requeue_and_plug() argument
449 struct request_queue *q = drive->queue; in ide_requeue_and_plug()
459 blk_status_t ide_issue_rq(ide_drive_t *drive, struct request *rq, in ide_issue_rq() argument
462 ide_hwif_t *hwif = drive->hwif; in ide_issue_rq()
485 if (drive->dev_flags & IDE_DFLAG_SLEEPING && in ide_issue_rq()
486 time_after(drive->sleep, jiffies)) { in ide_issue_rq()
508 hwif->cur_dev = drive; in ide_issue_rq()
509 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); in ide_issue_rq()
524 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && in ide_issue_rq()
536 startstop = start_request(drive, rq); in ide_issue_rq()
550 list_add(&rq->queuelist, &drive->rq_list); in ide_issue_rq()
554 ide_requeue_and_plug(drive, rq); in ide_issue_rq()
571 ide_drive_t *drive = hctx->queue->queuedata; in ide_queue_rq() local
572 ide_hwif_t *hwif = drive->hwif; in ide_queue_rq()
575 if (drive->sense_rq_active) { in ide_queue_rq()
582 return ide_issue_rq(drive, bd->rq, false); in ide_queue_rq()
585 static int drive_is_ready(ide_drive_t *drive) in drive_is_ready() argument
587 ide_hwif_t *hwif = drive->hwif; in drive_is_ready()
590 if (drive->waiting_for_dma) in drive_is_ready()
591 return hwif->dma_ops->dma_test_irq(drive); in drive_is_ready()
601 /* drive busy: definitely not interrupting */ in drive_is_ready()
604 /* drive ready: *might* be interrupting */ in drive_is_ready()
612 * An IDE command has timed out before the expected drive return
617 * invoking the handler and checking the drive DMA status. We
625 ide_drive_t *drive; in ide_timer_expiry() local
647 drive = hwif->cur_dev; in ide_timer_expiry()
650 wait = expiry(drive); in ide_timer_expiry()
672 startstop = handler(drive); in ide_timer_expiry()
673 } else if (drive_is_ready(drive)) { in ide_timer_expiry()
674 if (drive->waiting_for_dma) in ide_timer_expiry()
675 hwif->dma_ops->dma_lost_irq(drive); in ide_timer_expiry()
677 hwif->port_ops->clear_irq(drive); in ide_timer_expiry()
680 drive->name); in ide_timer_expiry()
681 startstop = handler(drive); in ide_timer_expiry()
683 if (drive->waiting_for_dma) in ide_timer_expiry()
684 startstop = ide_dma_timeout_retry(drive, wait); in ide_timer_expiry()
686 startstop = ide_error(drive, "irq timeout", in ide_timer_expiry()
703 ide_requeue_and_plug(drive, rq_in_flight); in ide_timer_expiry()
718 * the drive enters "idle", "standby", or "sleep" mode, so if the status
729 * the drive is ready to accept one, in which case we know the drive is
731 * before completing the issuance of any new drive command, so we will not
765 * a command. hwif->cur_dev is the drive and hwif->handler is
783 ide_drive_t *drive; in ide_intr() local
806 * Not expecting an interrupt from this drive. in ide_intr()
810 * or (2) a drive just entered sleep or standby mode, in ide_intr()
833 drive = hwif->cur_dev; in ide_intr()
835 if (!drive_is_ready(drive)) in ide_intr()
852 hwif->port_ops->clear_irq(drive); in ide_intr()
854 if (drive->dev_flags & IDE_DFLAG_UNMASK) in ide_intr()
858 startstop = handler(drive); in ide_intr()
881 ide_requeue_and_plug(drive, rq_in_flight); in ide_intr()
888 void ide_pad_transfer(ide_drive_t *drive, int write, int len) in ide_pad_transfer() argument
890 ide_hwif_t *hwif = drive->hwif; in ide_pad_transfer()
895 hwif->tp_ops->output_data(drive, NULL, buf, min(4, len)); in ide_pad_transfer()
897 hwif->tp_ops->input_data(drive, NULL, buf, min(4, len)); in ide_pad_transfer()
903 void ide_insert_request_head(ide_drive_t *drive, struct request *rq) in ide_insert_request_head() argument
905 drive->sense_rq_active = true; in ide_insert_request_head()
906 list_add_tail(&rq->queuelist, &drive->rq_list); in ide_insert_request_head()
907 kblockd_schedule_work(&drive->rq_work); in ide_insert_request_head()