• Home
  • Raw
  • Download

Lines Matching full:drive

44  *	generic_id		-	add a generic drive id
45 * @drive: drive to make an ID block for
47 * Add a fake id field to the drive we are passed. This allows
49 * and make drive properties unconditional outside of this file
52 static void generic_id(ide_drive_t *drive) in generic_id() argument
54 u16 *id = drive->id; in generic_id()
56 id[ATA_ID_CUR_CYLS] = id[ATA_ID_CYLS] = drive->cyl; in generic_id()
57 id[ATA_ID_CUR_HEADS] = id[ATA_ID_HEADS] = drive->head; in generic_id()
58 id[ATA_ID_CUR_SECTORS] = id[ATA_ID_SECTORS] = drive->sect; in generic_id()
61 static void ide_disk_init_chs(ide_drive_t *drive) in ide_disk_init_chs() argument
63 u16 *id = drive->id; in ide_disk_init_chs()
65 /* Extract geometry if we did not already have one for the drive */ in ide_disk_init_chs()
66 if (!drive->cyl || !drive->head || !drive->sect) { in ide_disk_init_chs()
67 drive->cyl = drive->bios_cyl = id[ATA_ID_CYLS]; in ide_disk_init_chs()
68 drive->head = drive->bios_head = id[ATA_ID_HEADS]; in ide_disk_init_chs()
69 drive->sect = drive->bios_sect = id[ATA_ID_SECTORS]; in ide_disk_init_chs()
72 /* Handle logical geometry translation by the drive */ in ide_disk_init_chs()
74 drive->cyl = id[ATA_ID_CUR_CYLS]; in ide_disk_init_chs()
75 drive->head = id[ATA_ID_CUR_HEADS]; in ide_disk_init_chs()
76 drive->sect = id[ATA_ID_CUR_SECTORS]; in ide_disk_init_chs()
80 if (drive->head > 16 && id[ATA_ID_HEADS] && id[ATA_ID_HEADS] <= 16) { in ide_disk_init_chs()
81 drive->cyl = id[ATA_ID_CYLS]; in ide_disk_init_chs()
82 drive->head = id[ATA_ID_HEADS]; in ide_disk_init_chs()
83 drive->sect = id[ATA_ID_SECTORS]; in ide_disk_init_chs()
87 static void ide_disk_init_mult_count(ide_drive_t *drive) in ide_disk_init_mult_count() argument
89 u16 *id = drive->id; in ide_disk_init_mult_count()
98 drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; in ide_disk_init_mult_count()
100 if (drive->mult_req) in ide_disk_init_mult_count()
101 drive->special_flags |= IDE_SFLAG_SET_MULTMODE; in ide_disk_init_mult_count()
105 static void ide_classify_ata_dev(ide_drive_t *drive) in ide_classify_ata_dev() argument
107 u16 *id = drive->id; in ide_classify_ata_dev()
113 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_ata_dev()
115 drive->media = ide_disk; in ide_classify_ata_dev()
117 if (!ata_id_has_unload(drive->id)) in ide_classify_ata_dev()
118 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; in ide_classify_ata_dev()
120 printk(KERN_INFO "%s: %s, %s DISK drive\n", drive->name, m, in ide_classify_ata_dev()
124 static void ide_classify_atapi_dev(ide_drive_t *drive) in ide_classify_atapi_dev() argument
126 u16 *id = drive->id; in ide_classify_atapi_dev()
130 printk(KERN_INFO "%s: %s, ATAPI ", drive->name, m); in ide_classify_atapi_dev()
138 if (drive->media != ide_cdrom) { in ide_classify_atapi_dev()
140 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_atapi_dev()
148 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_atapi_dev()
164 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_atapi_dev()
171 printk(KERN_CONT " drive\n"); in ide_classify_atapi_dev()
172 drive->media = type; in ide_classify_atapi_dev()
174 drive->ready_stat = 0; in ide_classify_atapi_dev()
176 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; in ide_classify_atapi_dev()
177 drive->dev_flags |= IDE_DFLAG_DOORLOCKING; in ide_classify_atapi_dev()
179 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; in ide_classify_atapi_dev()
183 * do_identify - identify a drive
184 * @drive: drive to identify
188 * Called when we have issued a drive identify command to
193 static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id) in do_identify() argument
195 ide_hwif_t *hwif = drive->hwif; in do_identify()
203 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); in do_identify()
206 drive->dev_flags |= IDE_DFLAG_ID_READ; in do_identify()
208 printk(KERN_INFO "%s: dumping identify data\n", drive->name); in do_identify()
233 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in do_identify()
235 drive->dev_flags |= IDE_DFLAG_PRESENT; in do_identify()
240 * @drive: drive to identify
245 * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response.
252 int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id, int irq_ctx) in ide_dev_read_id() argument
254 ide_hwif_t *hwif = drive->hwif; in ide_dev_read_id()
282 drive->name, s, a); in ide_dev_read_id()
296 tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE); in ide_dev_read_id()
299 /* ask drive for ID */ in ide_dev_read_id()
306 rc = __ide_wait_stat(drive, ATA_DRQ, BAD_R_STAT, timeout, &s); in ide_dev_read_id()
310 rc = ide_busy_sleep(drive, timeout, use_altstatus); in ide_dev_read_id()
319 /* drive returned ID */ in ide_dev_read_id()
320 do_identify(drive, cmd, id); in ide_dev_read_id()
321 /* drive responded with ID */ in ide_dev_read_id()
323 /* clear drive IRQ */ in ide_dev_read_id()
326 /* drive refused ID */ in ide_dev_read_id()
332 int ide_busy_sleep(ide_drive_t *drive, unsigned long timeout, int altstatus) in ide_busy_sleep() argument
334 ide_hwif_t *hwif = drive->hwif; in ide_busy_sleep()
340 msleep(50); /* give drive a breather */ in ide_busy_sleep()
347 printk(KERN_ERR "%s: timeout in %s\n", drive->name, __func__); in ide_busy_sleep()
349 return 1; /* drive timed-out */ in ide_busy_sleep()
352 static u8 ide_read_device(ide_drive_t *drive) in ide_read_device() argument
356 drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE); in ide_read_device()
363 * @drive: drive to probe
366 * do_probe() has the difficult job of finding a drive if it exists,
370 * If a drive is "known" to exist (from CMOS or kernel parameters),
382 static int do_probe (ide_drive_t *drive, u8 cmd) in do_probe() argument
384 ide_hwif_t *hwif = drive->hwif; in do_probe()
386 u16 *id = drive->id; in do_probe()
388 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; in do_probe()
391 if (present && drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) in do_probe()
396 drive->name, present, drive->media, in do_probe()
404 tp_ops->dev_select(drive); in do_probe()
407 if (ide_read_device(drive) != drive->select && present == 0) { in do_probe()
408 if (drive->dn & 1) { in do_probe()
422 rc = ide_dev_read_id(drive, cmd, id, 0); in do_probe()
425 rc = ide_dev_read_id(drive, cmd, id, 0); in do_probe()
434 "resetting drive\n", drive->name, stat); in do_probe()
436 tp_ops->dev_select(drive); in do_probe()
439 (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0); in do_probe()
440 rc = ide_dev_read_id(drive, cmd, id, 0); in do_probe()
443 /* ensure drive IRQ is clear */ in do_probe()
448 drive->name, stat); in do_probe()
453 if (drive->dn & 1) { in do_probe()
457 /* ensure drive irq is clear */ in do_probe()
464 * probe_for_drives - upper level drive probe
465 * @drive: drive to probe for
467 * probe_for_drive() tests for existence of a given drive using do_probe()
475 static u8 probe_for_drive(ide_drive_t *drive) in probe_for_drive() argument
481 drive->dev_flags &= ~IDE_DFLAG_ID_READ; in probe_for_drive()
483 m = (char *)&drive->id[ATA_ID_PROD]; in probe_for_drive()
487 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { in probe_for_drive()
490 rc = do_probe(drive, cmd); in probe_for_drive()
494 rc = do_probe(drive, cmd); in probe_for_drive()
497 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in probe_for_drive()
501 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { in probe_for_drive()
502 if (drive->media == ide_disk) { in probe_for_drive()
503 printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", in probe_for_drive()
504 drive->name, drive->cyl, in probe_for_drive()
505 drive->head, drive->sect); in probe_for_drive()
506 } else if (drive->media == ide_cdrom) { in probe_for_drive()
507 printk(KERN_INFO "%s: ATAPI cdrom (?)\n", drive->name); in probe_for_drive()
510 … printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); in probe_for_drive()
511 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in probe_for_drive()
515 ide_classify_atapi_dev(drive); in probe_for_drive()
517 ide_classify_ata_dev(drive); in probe_for_drive()
521 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in probe_for_drive()
524 /* The drive wasn't being helpful. Add generic info only */ in probe_for_drive()
525 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { in probe_for_drive()
526 generic_id(drive); in probe_for_drive()
530 if (drive->media == ide_disk) { in probe_for_drive()
531 ide_disk_init_chs(drive); in probe_for_drive()
532 ide_disk_init_mult_count(drive); in probe_for_drive()
581 * the drive is still doing it's poweron-reset sequence, that
587 * - Some CD/DVD/Writer combo drives tend to drive the bus during
602 ide_drive_t *drive; in ide_port_wait_ready() local
620 ide_port_for_each_dev(i, drive, hwif) { in ide_port_wait_ready()
622 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || in ide_port_wait_ready()
623 (drive->dev_flags & IDE_DFLAG_PRESENT)) { in ide_port_wait_ready()
624 tp_ops->dev_select(drive); in ide_port_wait_ready()
632 drive->name); in ide_port_wait_ready()
647 * have the same drive viewed twice. This occurs with crap CF adapters
682 ide_drive_t *drive; in ide_probe_port() local
704 * Second drive should only exist if first drive was found, in ide_probe_port()
707 ide_port_for_each_dev(i, drive, hwif) { in ide_probe_port()
708 (void) probe_for_drive(drive); in ide_probe_port()
709 if (drive->dev_flags & IDE_DFLAG_PRESENT) in ide_probe_port()
726 ide_drive_t *drive; in ide_port_tune_devices() local
729 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
730 ide_check_nien_quirk_list(drive); in ide_port_tune_devices()
733 port_ops->quirkproc(drive); in ide_port_tune_devices()
736 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
737 ide_set_max_pio(drive); in ide_port_tune_devices()
739 drive->dev_flags |= IDE_DFLAG_NICE1; in ide_port_tune_devices()
742 ide_set_dma(drive); in ide_port_tune_devices()
763 static int ide_init_queue(ide_drive_t *drive) in ide_init_queue() argument
766 ide_hwif_t *hwif = drive->hwif; in ide_init_queue()
779 set = &drive->tag_set; in ide_init_queue()
798 q->queuedata = drive; in ide_init_queue()
820 /* assign drive queue */ in ide_init_queue()
821 drive->queue = q; in ide_init_queue()
829 * For any present drive:
834 ide_drive_t *drive; in ide_port_setup_devices() local
838 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_setup_devices()
839 if (ide_init_queue(drive)) { in ide_port_setup_devices()
841 drive->name); in ide_port_setup_devices()
842 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in ide_port_setup_devices()
915 ide_drive_t *drive = hwif->devices[unit]; in ata_probe() local
917 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in ata_probe()
920 if (drive->media == ide_disk) in ata_probe()
922 if (drive->media == ide_cdrom || drive->media == ide_optical) in ata_probe()
924 if (drive->media == ide_tape) in ata_probe()
926 if (drive->media == ide_floppy) in ata_probe()
964 void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) in ide_init_disk() argument
966 ide_hwif_t *hwif = drive->hwif; in ide_init_disk()
967 unsigned int unit = drive->dn & 1; in ide_init_disk()
972 disk->queue = drive->queue; in ide_init_disk()
979 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); in drive_release_dev() local
981 ide_proc_unregister_device(drive); in drive_release_dev()
983 if (drive->sense_rq) in drive_release_dev()
984 blk_mq_free_request(drive->sense_rq); in drive_release_dev()
986 blk_cleanup_queue(drive->queue); in drive_release_dev()
987 drive->queue = NULL; in drive_release_dev()
988 blk_mq_free_tag_set(&drive->tag_set); in drive_release_dev()
990 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in drive_release_dev()
992 complete(&drive->gendev_rel_comp); in drive_release_dev()
1035 ide_drive_t *drive; in hwif_register_devices() local
1038 ide_port_for_each_present_dev(i, drive, hwif) { in hwif_register_devices()
1039 struct device *dev = &drive->gendev; in hwif_register_devices()
1043 dev_set_drvdata(dev, drive); in hwif_register_devices()
1058 ide_drive_t *drive; in ide_port_init_devices() local
1061 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices()
1062 drive->dn = i + hwif->channel * 2; in ide_port_init_devices()
1065 drive->io_32bit = 1; in ide_port_init_devices()
1067 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; in ide_port_init_devices()
1069 drive->dev_flags |= IDE_DFLAG_UNMASK; in ide_port_init_devices()
1071 drive->dev_flags |= IDE_DFLAG_NO_UNMASK; in ide_port_init_devices()
1073 drive->pio_mode = XFER_PIO_0; in ide_port_init_devices()
1076 port_ops->init_dev(drive); in ide_port_init_devices()
1160 ide_drive_t *drive = container_of(work, ide_drive_t, rq_work); in drive_rq_insert_work() local
1161 ide_hwif_t *hwif = drive->hwif; in drive_rq_insert_work()
1166 blk_mq_quiesce_queue(drive->queue); in drive_rq_insert_work()
1170 while (!list_empty(&drive->rq_list)) { in drive_rq_insert_work()
1171 rq = list_first_entry(&drive->rq_list, struct request, queuelist); in drive_rq_insert_work()
1175 ret = ide_issue_rq(drive, rq, true); in drive_rq_insert_work()
1180 blk_mq_unquiesce_queue(drive->queue); in drive_rq_insert_work()
1183 kblockd_schedule_work(&drive->rq_work); in drive_rq_insert_work()
1192 ide_drive_t *drive; in ide_port_init_devices_data() local
1195 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices_data()
1197 u16 *saved_id = drive->id; in ide_port_init_devices_data()
1199 memset(drive, 0, sizeof(*drive)); in ide_port_init_devices_data()
1201 drive->id = saved_id; in ide_port_init_devices_data()
1203 drive->media = ide_disk; in ide_port_init_devices_data()
1204 drive->select = (i << 4) | ATA_DEVICE_OBS; in ide_port_init_devices_data()
1205 drive->hwif = hwif; in ide_port_init_devices_data()
1206 drive->ready_stat = ATA_DRDY; in ide_port_init_devices_data()
1207 drive->bad_wstat = BAD_W_STAT; in ide_port_init_devices_data()
1208 drive->special_flags = IDE_SFLAG_RECALIBRATE | in ide_port_init_devices_data()
1210 drive->name[0] = 'h'; in ide_port_init_devices_data()
1211 drive->name[1] = 'd'; in ide_port_init_devices_data()
1212 drive->name[2] = 'a' + j; in ide_port_init_devices_data()
1213 drive->max_failures = IDE_DEFAULT_MAX_FAILURES; in ide_port_init_devices_data()
1215 INIT_LIST_HEAD(&drive->list); in ide_port_init_devices_data()
1216 init_completion(&drive->gendev_rel_comp); in ide_port_init_devices_data()
1218 INIT_WORK(&drive->rq_work, drive_rq_insert_work); in ide_port_init_devices_data()
1219 INIT_LIST_HEAD(&drive->rq_list); in ide_port_init_devices_data()
1305 ide_drive_t *drive; in ide_port_free_devices() local
1308 ide_port_for_each_dev(i, drive, hwif) { in ide_port_free_devices()
1309 kfree(drive->id); in ide_port_free_devices()
1310 kfree(drive); in ide_port_free_devices()
1316 ide_drive_t *drive; in ide_port_alloc_devices() local
1320 drive = kzalloc_node(sizeof(*drive), GFP_KERNEL, node); in ide_port_alloc_devices()
1321 if (drive == NULL) in ide_port_alloc_devices()
1332 drive->id = kzalloc_node(SECTOR_SIZE, GFP_KERNEL, node); in ide_port_alloc_devices()
1333 if (drive->id == NULL) in ide_port_alloc_devices()
1336 hwif->devices[i] = drive; in ide_port_alloc_devices()
1341 kfree(drive); in ide_port_alloc_devices()
1560 ide_drive_t *drive; in __ide_port_unregister_devices() local
1563 ide_port_for_each_present_dev(i, drive, hwif) { in __ide_port_unregister_devices()
1564 device_unregister(&drive->gendev); in __ide_port_unregister_devices()
1565 wait_for_completion(&drive->gendev_rel_comp); in __ide_port_unregister_devices()