• Home
  • Raw
  • Download

Lines Matching refs:drive

55 static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma)  in ide_tf_set_cmd()  argument
67 if (drive->mult_count) { in ide_tf_set_cmd()
81 static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, in __ide_do_rw_disk() argument
84 ide_hwif_t *hwif = drive->hwif; in __ide_do_rw_disk()
86 u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); in __ide_do_rw_disk()
87 u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); in __ide_do_rw_disk()
103 if (drive->dev_flags & IDE_DFLAG_LBA) { in __ide_do_rw_disk()
105 pr_debug("%s: LBA=0x%012llx\n", drive->name, in __ide_do_rw_disk()
135 track = (int)block / drive->sect; in __ide_do_rw_disk()
136 sect = (int)block % drive->sect + 1; in __ide_do_rw_disk()
137 head = track % drive->head; in __ide_do_rw_disk()
138 cyl = track / drive->head; in __ide_do_rw_disk()
140 pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect); in __ide_do_rw_disk()
154 ide_tf_set_cmd(drive, &cmd, dma); in __ide_do_rw_disk()
159 ide_map_sg(drive, &cmd); in __ide_do_rw_disk()
162 rc = do_rw_taskfile(drive, &cmd); in __ide_do_rw_disk()
167 ide_tf_set_cmd(drive, &cmd, 0); in __ide_do_rw_disk()
169 rc = do_rw_taskfile(drive, &cmd); in __ide_do_rw_disk()
181 static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, in ide_do_rw_disk() argument
184 ide_hwif_t *hwif = drive->hwif; in ide_do_rw_disk()
186 BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED); in ide_do_rw_disk()
192 drive->name, rq_data_dir(rq) == READ ? "read" : "writ", in ide_do_rw_disk()
196 hwif->rw_disk(drive, rq); in ide_do_rw_disk()
198 return __ide_do_rw_disk(drive, rq, block); in ide_do_rw_disk()
205 static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) in idedisk_read_native_max_address() argument
226 ide_no_data_taskfile(drive, &cmd); in idedisk_read_native_max_address()
239 static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) in idedisk_set_max_address() argument
270 ide_no_data_taskfile(drive, &cmd); in idedisk_set_max_address()
297 static u64 ide_disk_hpa_get_native_capacity(ide_drive_t *drive, int lba48) in ide_disk_hpa_get_native_capacity() argument
301 capacity = drive->capacity64; in ide_disk_hpa_get_native_capacity()
302 set_max = idedisk_read_native_max_address(drive, lba48); in ide_disk_hpa_get_native_capacity()
304 if (ide_in_drive_list(drive->id, hpa_list)) { in ide_disk_hpa_get_native_capacity()
316 static u64 ide_disk_hpa_set_capacity(ide_drive_t *drive, u64 set_max, int lba48) in ide_disk_hpa_set_capacity() argument
318 set_max = idedisk_set_max_address(drive, set_max, lba48); in ide_disk_hpa_set_capacity()
320 drive->capacity64 = set_max; in ide_disk_hpa_set_capacity()
325 static void idedisk_check_hpa(ide_drive_t *drive) in idedisk_check_hpa() argument
328 int lba48 = ata_id_lba48_enabled(drive->id); in idedisk_check_hpa()
330 capacity = drive->capacity64; in idedisk_check_hpa()
331 set_max = ide_disk_hpa_get_native_capacity(drive, lba48); in idedisk_check_hpa()
336 drive->probed_capacity = set_max; in idedisk_check_hpa()
341 drive->name, in idedisk_check_hpa()
345 if ((drive->dev_flags & IDE_DFLAG_NOHPA) == 0) in idedisk_check_hpa()
348 set_max = ide_disk_hpa_set_capacity(drive, set_max, lba48); in idedisk_check_hpa()
351 drive->name); in idedisk_check_hpa()
354 static int ide_disk_get_capacity(ide_drive_t *drive) in ide_disk_get_capacity() argument
356 u16 *id = drive->id; in ide_disk_get_capacity()
362 drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); in ide_disk_get_capacity()
366 drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY); in ide_disk_get_capacity()
370 drive->capacity64 = drive->cyl * drive->head * drive->sect; in ide_disk_get_capacity()
373 drive->probed_capacity = drive->capacity64; in ide_disk_get_capacity()
376 drive->dev_flags |= IDE_DFLAG_LBA; in ide_disk_get_capacity()
383 idedisk_check_hpa(drive); in ide_disk_get_capacity()
387 if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 && in ide_disk_get_capacity()
388 drive->capacity64 > 1ULL << 28) { in ide_disk_get_capacity()
391 drive->name, (unsigned long long)drive->capacity64, in ide_disk_get_capacity()
392 sectors_to_MB(drive->capacity64)); in ide_disk_get_capacity()
393 drive->probed_capacity = drive->capacity64 = 1ULL << 28; in ide_disk_get_capacity()
396 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && in ide_disk_get_capacity()
397 (drive->dev_flags & IDE_DFLAG_LBA48)) { in ide_disk_get_capacity()
398 if (drive->capacity64 > 1ULL << 28) { in ide_disk_get_capacity()
401 "> %u\n", drive->name, 1 << 28); in ide_disk_get_capacity()
403 drive->dev_flags &= ~IDE_DFLAG_LBA48; in ide_disk_get_capacity()
409 static void ide_disk_unlock_native_capacity(ide_drive_t *drive) in ide_disk_unlock_native_capacity() argument
411 u16 *id = drive->id; in ide_disk_unlock_native_capacity()
414 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 || in ide_disk_unlock_native_capacity()
422 if (!ide_disk_hpa_get_native_capacity(drive, lba48)) in ide_disk_unlock_native_capacity()
425 if (ide_disk_hpa_set_capacity(drive, drive->probed_capacity, lba48)) in ide_disk_unlock_native_capacity()
426 drive->dev_flags |= IDE_DFLAG_NOHPA; /* disable HPA on resume */ in ide_disk_unlock_native_capacity()
431 ide_drive_t *drive = q->queuedata; in idedisk_prep_fn() local
447 if (ata_id_flush_ext_enabled(drive->id) && in idedisk_prep_fn()
448 (drive->capacity64 >= (1UL << 28))) in idedisk_prep_fn()
469 static int set_multcount(ide_drive_t *drive, int arg) in set_multcount() argument
474 if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff)) in set_multcount()
477 if (drive->special_flags & IDE_SFLAG_SET_MULTMODE) in set_multcount()
480 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); in set_multcount()
483 drive->mult_req = arg; in set_multcount()
484 drive->special_flags |= IDE_SFLAG_SET_MULTMODE; in set_multcount()
485 error = blk_execute_rq(drive->queue, NULL, rq, 0); in set_multcount()
488 return (drive->mult_count == arg) ? 0 : -EIO; in set_multcount()
493 static int set_nowerr(ide_drive_t *drive, int arg) in set_nowerr() argument
499 drive->dev_flags |= IDE_DFLAG_NOWERR; in set_nowerr()
501 drive->dev_flags &= ~IDE_DFLAG_NOWERR; in set_nowerr()
503 drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT; in set_nowerr()
508 static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect) in ide_do_setfeature() argument
519 return ide_no_data_taskfile(drive, &cmd); in ide_do_setfeature()
522 static void update_flush(ide_drive_t *drive) in update_flush() argument
524 u16 *id = drive->id; in update_flush()
527 if (drive->dev_flags & IDE_DFLAG_WCACHE) { in update_flush()
538 capacity = ide_gd_capacity(drive); in update_flush()
540 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 && in update_flush()
541 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 || in update_flush()
546 drive->name, barrier ? "" : "not "); in update_flush()
550 blk_queue_prep_rq(drive->queue, idedisk_prep_fn); in update_flush()
554 blk_queue_write_cache(drive->queue, wc, false); in update_flush()
559 static int set_wcache(ide_drive_t *drive, int arg) in set_wcache() argument
566 if (ata_id_flush_enabled(drive->id)) { in set_wcache()
567 err = ide_do_setfeature(drive, in set_wcache()
571 drive->dev_flags |= IDE_DFLAG_WCACHE; in set_wcache()
573 drive->dev_flags &= ~IDE_DFLAG_WCACHE; in set_wcache()
577 update_flush(drive); in set_wcache()
582 static int do_idedisk_flushcache(ide_drive_t *drive) in do_idedisk_flushcache() argument
587 if (ata_id_flush_ext_enabled(drive->id)) in do_idedisk_flushcache()
594 return ide_no_data_taskfile(drive, &cmd); in do_idedisk_flushcache()
599 static int set_acoustic(ide_drive_t *drive, int arg) in set_acoustic() argument
604 ide_do_setfeature(drive, in set_acoustic()
607 drive->acoustic = arg; in set_acoustic()
620 static int set_addressing(ide_drive_t *drive, int arg) in set_addressing() argument
625 if (arg && ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) || in set_addressing()
626 ata_id_lba48_enabled(drive->id) == 0)) in set_addressing()
633 drive->dev_flags |= IDE_DFLAG_LBA48; in set_addressing()
635 drive->dev_flags &= ~IDE_DFLAG_LBA48; in set_addressing()
647 static int ide_disk_check(ide_drive_t *drive, const char *s) in ide_disk_check() argument
652 static void ide_disk_setup(ide_drive_t *drive) in ide_disk_setup() argument
654 struct ide_disk_obj *idkp = drive->driver_data; in ide_disk_setup()
655 struct request_queue *q = drive->queue; in ide_disk_setup()
656 ide_hwif_t *hwif = drive->hwif; in ide_disk_setup()
657 u16 *id = drive->id; in ide_disk_setup()
661 ide_proc_register_driver(drive, idkp->driver); in ide_disk_setup()
663 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) in ide_disk_setup()
666 if (drive->dev_flags & IDE_DFLAG_REMOVABLE) { in ide_disk_setup()
671 drive->dev_flags |= IDE_DFLAG_DOORLOCKING; in ide_disk_setup()
674 (void)set_addressing(drive, 1); in ide_disk_setup()
676 if (drive->dev_flags & IDE_DFLAG_LBA48) { in ide_disk_setup()
685 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, in ide_disk_setup()
694 ide_disk_get_capacity(drive); in ide_disk_setup()
700 capacity = ide_gd_capacity(drive); in ide_disk_setup()
702 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) { in ide_disk_setup()
703 if (ata_id_lba48_enabled(drive->id)) { in ide_disk_setup()
705 drive->bios_sect = 63; in ide_disk_setup()
706 drive->bios_head = 255; in ide_disk_setup()
709 if (drive->bios_sect && drive->bios_head) { in ide_disk_setup()
714 drive->bios_cyl = 65535; in ide_disk_setup()
716 cylsz = drive->bios_sect * drive->bios_head; in ide_disk_setup()
720 if (cyl > drive->bios_cyl) in ide_disk_setup()
721 drive->bios_cyl = cyl; in ide_disk_setup()
726 drive->name, capacity, sectors_to_MB(capacity)); in ide_disk_setup()
733 drive->bios_cyl, drive->bios_head, drive->bios_sect); in ide_disk_setup()
737 drive->dev_flags |= IDE_DFLAG_WCACHE; in ide_disk_setup()
739 set_wcache(drive, 1); in ide_disk_setup()
741 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 && in ide_disk_setup()
742 (drive->head == 0 || drive->head > 16)) { in ide_disk_setup()
744 drive->name, drive->head); in ide_disk_setup()
745 drive->dev_flags &= ~IDE_DFLAG_ATTACH; in ide_disk_setup()
747 drive->dev_flags |= IDE_DFLAG_ATTACH; in ide_disk_setup()
750 static void ide_disk_flush(ide_drive_t *drive) in ide_disk_flush() argument
752 if (ata_id_flush_enabled(drive->id) == 0 || in ide_disk_flush()
753 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) in ide_disk_flush()
756 if (do_idedisk_flushcache(drive)) in ide_disk_flush()
757 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); in ide_disk_flush()
760 static int ide_disk_init_media(ide_drive_t *drive, struct gendisk *disk) in ide_disk_init_media() argument
765 static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk, in ide_disk_set_doorlock() argument
771 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0) in ide_disk_set_doorlock()
779 ret = ide_no_data_taskfile(drive, &cmd); in ide_disk_set_doorlock()
782 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; in ide_disk_set_doorlock()