Lines Matching refs:drive
57 int ide_end_rq(ide_drive_t *drive, struct request *rq, blk_status_t error,
64 if ((drive->dev_flags & IDE_DFLAG_DMA_PIO_RETRY) &&
65 drive->retry_pio <= 3) {
66 drive->dev_flags &= ~IDE_DFLAG_DMA_PIO_RETRY;
67 ide_dma_on(drive);
71 if (rq == drive->sense_rq) {
72 drive->sense_rq = NULL;
73 drive->sense_rq_active = false;
84 void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
86 const struct ide_tp_ops *tp_ops = drive->hwif->tp_ops;
97 tp_ops->input_data(drive, cmd, data, 2);
103 ide_tf_readback(drive, cmd);
109 drive->name);
110 ide_tf_dump(drive->name, cmd);
112 drive->dev_flags |= IDE_DFLAG_PARKED;
125 int ide_complete_rq(ide_drive_t *drive, blk_status_t error, unsigned int nr_bytes)
127 ide_hwif_t *hwif = drive->hwif;
138 rc = ide_end_rq(drive, rq, error, nr_bytes);
146 void ide_kill_rq(ide_drive_t *drive, struct request *rq)
149 u8 media = drive->media;
151 drive->failed_pc = NULL;
162 ide_complete_rq(drive, BLK_STS_IOERR, blk_rq_bytes(rq));
165 static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
167 tf->nsect = drive->sect;
168 tf->lbal = drive->sect;
169 tf->lbam = drive->cyl;
170 tf->lbah = drive->cyl >> 8;
171 tf->device = (drive->head - 1) | drive->select;
175 static void ide_tf_set_restore_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
177 tf->nsect = drive->sect;
181 static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
183 tf->nsect = drive->mult_req;
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)
200 printk(KERN_DEBUG "%s: %s: 0x%02x\n", drive->name, __func__,
201 drive->special_flags);
203 if (drive->media != ide_disk) {
204 drive->special_flags = 0;
205 drive->mult_req = 0;
212 if (drive->special_flags & IDE_SFLAG_SET_GEOMETRY) {
213 drive->special_flags &= ~IDE_SFLAG_SET_GEOMETRY;
214 ide_tf_set_specify_cmd(drive, &cmd.tf);
215 } else if (drive->special_flags & IDE_SFLAG_RECALIBRATE) {
216 drive->special_flags &= ~IDE_SFLAG_RECALIBRATE;
217 ide_tf_set_restore_cmd(drive, &cmd.tf);
218 } else if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) {
219 drive->special_flags &= ~IDE_SFLAG_SET_MULTMODE;
220 ide_tf_set_setmult_cmd(drive, &cmd.tf);
228 do_rw_taskfile(drive, &cmd);
233 void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd)
235 ide_hwif_t *hwif = drive->hwif;
239 cmd->sg_nents = __blk_rq_map_sg(drive->queue, rq, sg, &last_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,
274 ide_map_sg(drive, cmd);
277 return do_rw_taskfile(drive, cmd);
285 printk("%s: DRIVE_CMD (null)\n", drive->name);
288 ide_complete_rq(drive, BLK_STS_OK, blk_rq_bytes(rq));
293 static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
300 return ide_do_park_unpark(drive, rq);
302 return ide_do_devset(drive, rq);
304 return ide_do_reset(drive);
319 static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
325 drive->hwif->name, (unsigned long) rq);
329 if (drive->max_failures && (drive->failures > drive->max_failures)) {
334 if (drive->prep_rq && !drive->prep_rq(drive, rq))
338 ide_check_pm_state(drive, rq);
340 drive->hwif->tp_ops->dev_select(drive);
341 if (ide_wait_stat(&startstop, drive, drive->ready_stat,
343 printk(KERN_ERR "%s: drive not ready for command\n", drive->name);
347 if (drive->special_flags == 0) {
351 * We reset the drive so we need to issue a SETFEATURES.
354 if (drive->current_speed == 0xff)
355 ide_config_drive_speed(drive, drive->desired_speed);
358 return execute_drive_cmd(drive, rq);
363 drive->name, pm->pm_step);
365 startstop = ide_start_power_step(drive, rq);
368 ide_complete_pm_rq(drive, rq);
379 return ide_special_rq(drive, rq);
383 return drv->do_request(drive, rq, blk_rq_pos(rq));
385 return do_special(drive);
387 ide_kill_rq(drive, rq);
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)
404 drive->sleep = timeout + jiffies;
405 drive->dev_flags |= IDE_DFLAG_SLEEPING;
447 void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq)
449 struct request_queue *q = drive->queue;
459 blk_status_t ide_issue_rq(ide_drive_t *drive, struct request *rq,
462 ide_hwif_t *hwif = drive->hwif;
485 if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
486 time_after(drive->sleep, jiffies)) {
508 hwif->cur_dev = drive;
509 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);
519 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
531 startstop = start_request(drive, rq);
545 list_add(&rq->queuelist, &drive->rq_list);
549 ide_requeue_and_plug(drive, rq);
566 ide_drive_t *drive = hctx->queue->queuedata;
567 ide_hwif_t *hwif = drive->hwif;
570 if (drive->sense_rq_active) {
577 return ide_issue_rq(drive, bd->rq, false);
580 static int drive_is_ready(ide_drive_t *drive)
582 ide_hwif_t *hwif = drive->hwif;
585 if (drive->waiting_for_dma)
586 return hwif->dma_ops->dma_test_irq(drive);
596 /* drive busy: definitely not interrupting */
599 /* drive ready: *might* be interrupting */
607 * An IDE command has timed out before the expected drive return
612 * invoking the handler and checking the drive DMA status. We
620 ide_drive_t *drive;
642 drive = hwif->cur_dev;
645 wait = expiry(drive);
667 startstop = handler(drive);
668 } else if (drive_is_ready(drive)) {
669 if (drive->waiting_for_dma)
670 hwif->dma_ops->dma_lost_irq(drive);
672 hwif->port_ops->clear_irq(drive);
675 drive->name);
676 startstop = handler(drive);
678 if (drive->waiting_for_dma)
679 startstop = ide_dma_timeout_retry(drive, wait);
681 startstop = ide_error(drive, "irq timeout",
698 ide_requeue_and_plug(drive, rq_in_flight);
713 * the drive enters "idle", "standby", or "sleep" mode, so if the status
724 * the drive is ready to accept one, in which case we know the drive is
726 * before completing the issuance of any new drive command, so we will not
760 * a command. hwif->cur_dev is the drive and hwif->handler is
778 ide_drive_t *drive;
801 * Not expecting an interrupt from this drive.
805 * or (2) a drive just entered sleep or standby mode,
828 drive = hwif->cur_dev;
830 if (!drive_is_ready(drive))
847 hwif->port_ops->clear_irq(drive);
849 if (drive->dev_flags & IDE_DFLAG_UNMASK)
853 startstop = handler(drive);
876 ide_requeue_and_plug(drive, rq_in_flight);
883 void ide_pad_transfer(ide_drive_t *drive, int write, int len)
885 ide_hwif_t *hwif = drive->hwif;
890 hwif->tp_ops->output_data(drive, NULL, buf, min(4, len));
892 hwif->tp_ops->input_data(drive, NULL, buf, min(4, len));
898 void ide_insert_request_head(ide_drive_t *drive, struct request *rq)
900 drive->sense_rq_active = true;
901 list_add_tail(&rq->queuelist, &drive->rq_list);
902 kblockd_schedule_work(&drive->rq_work);