Lines Matching refs:disk
247 enum action (*func)(struct pd_unit *disk);
259 static inline int status_reg(struct pd_unit *disk) in status_reg() argument
261 return pi_read_regr(disk->pi, 1, 6); in status_reg()
264 static inline int read_reg(struct pd_unit *disk, int reg) in read_reg() argument
266 return pi_read_regr(disk->pi, 0, reg); in read_reg()
269 static inline void write_status(struct pd_unit *disk, int val) in write_status() argument
271 pi_write_regr(disk->pi, 1, 6, val); in write_status()
274 static inline void write_reg(struct pd_unit *disk, int reg, int val) in write_reg() argument
276 pi_write_regr(disk->pi, 0, reg, val); in write_reg()
279 static inline u8 DRIVE(struct pd_unit *disk) in DRIVE() argument
281 return 0xa0+0x10*disk->drive; in DRIVE()
286 static void pd_print_error(struct pd_unit *disk, char *msg, int status) in pd_print_error() argument
290 printk("%s: %s: status = 0x%x =", disk->name, msg, status); in pd_print_error()
297 static void pd_reset(struct pd_unit *disk) in pd_reset() argument
299 write_status(disk, 4); in pd_reset()
301 write_status(disk, 0); in pd_reset()
307 static int pd_wait_for(struct pd_unit *disk, int w, char *msg) in pd_wait_for() argument
313 r = status_reg(disk); in pd_wait_for()
319 e = (read_reg(disk, 1) << 8) + read_reg(disk, 7); in pd_wait_for()
323 pd_print_error(disk, msg, e); in pd_wait_for()
327 static void pd_send_command(struct pd_unit *disk, int n, int s, int h, int c0, int c1, int func) in pd_send_command() argument
329 write_reg(disk, 6, DRIVE(disk) + h); in pd_send_command()
330 write_reg(disk, 1, 0); /* the IDE task file */ in pd_send_command()
331 write_reg(disk, 2, n); in pd_send_command()
332 write_reg(disk, 3, s); in pd_send_command()
333 write_reg(disk, 4, c0); in pd_send_command()
334 write_reg(disk, 5, c1); in pd_send_command()
335 write_reg(disk, 7, func); in pd_send_command()
340 static void pd_ide_command(struct pd_unit *disk, int func, int block, int count) in pd_ide_command() argument
344 if (disk->can_lba) { in pd_ide_command()
350 s = (block % disk->sectors) + 1; in pd_ide_command()
351 h = (block /= disk->sectors) % disk->heads; in pd_ide_command()
352 c0 = (block /= disk->heads) % 256; in pd_ide_command()
355 pd_send_command(disk, count, s, h, c0, c1, func); in pd_ide_command()
399 struct gendisk *disk; in set_next_request() local
404 disk = pd[pd_queue].gd; in set_next_request()
405 q = disk ? disk->queue : NULL; in set_next_request()
409 struct pd_unit *disk = q->queuedata; in set_next_request() local
411 if (list_empty(&disk->rq_list)) in set_next_request()
414 pd_req = list_first_entry(&disk->rq_list, in set_next_request()
635 static void pd_init_dev_parms(struct pd_unit *disk) in pd_init_dev_parms() argument
637 pd_wait_for(disk, 0, DBMSG("before init_dev_parms")); in pd_init_dev_parms()
638 pd_send_command(disk, disk->sectors, 0, disk->heads - 1, 0, 0, in pd_init_dev_parms()
641 pd_wait_for(disk, 0, "Initialise device parameters"); in pd_init_dev_parms()
644 static enum action pd_door_lock(struct pd_unit *disk) in pd_door_lock() argument
646 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) { in pd_door_lock()
647 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORLOCK); in pd_door_lock()
648 pd_wait_for(disk, STAT_READY, "Lock done"); in pd_door_lock()
653 static enum action pd_door_unlock(struct pd_unit *disk) in pd_door_unlock() argument
655 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) { in pd_door_unlock()
656 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK); in pd_door_unlock()
657 pd_wait_for(disk, STAT_READY, "Lock done"); in pd_door_unlock()
662 static enum action pd_eject(struct pd_unit *disk) in pd_eject() argument
664 pd_wait_for(disk, 0, DBMSG("before unlock on eject")); in pd_eject()
665 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK); in pd_eject()
666 pd_wait_for(disk, 0, DBMSG("after unlock on eject")); in pd_eject()
667 pd_wait_for(disk, 0, DBMSG("before eject")); in pd_eject()
668 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_EJECT); in pd_eject()
669 pd_wait_for(disk, 0, DBMSG("after eject")); in pd_eject()
673 static enum action pd_media_check(struct pd_unit *disk) in pd_media_check() argument
675 int r = pd_wait_for(disk, STAT_READY, DBMSG("before media_check")); in pd_media_check()
677 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY); in pd_media_check()
678 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after READ_VRFY")); in pd_media_check()
680 disk->changed = 1; /* say changed if other error */ in pd_media_check()
682 disk->changed = 1; in pd_media_check()
683 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_ACKCHANGE); in pd_media_check()
684 pd_wait_for(disk, STAT_READY, DBMSG("RDY after ACKCHANGE")); in pd_media_check()
685 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY); in pd_media_check()
686 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after VRFY")); in pd_media_check()
691 static void pd_standby_off(struct pd_unit *disk) in pd_standby_off() argument
693 pd_wait_for(disk, 0, DBMSG("before STANDBY")); in pd_standby_off()
694 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_STANDBY); in pd_standby_off()
695 pd_wait_for(disk, 0, DBMSG("after STANDBY")); in pd_standby_off()
698 static enum action pd_identify(struct pd_unit *disk) in pd_identify() argument
709 if (disk->drive == 0) in pd_identify()
710 pd_reset(disk); in pd_identify()
712 write_reg(disk, 6, DRIVE(disk)); in pd_identify()
713 pd_wait_for(disk, 0, DBMSG("before IDENT")); in pd_identify()
714 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_IDENTIFY); in pd_identify()
716 if (pd_wait_for(disk, STAT_DRQ, DBMSG("IDENT DRQ")) & STAT_ERR) in pd_identify()
718 pi_read_block(disk->pi, pd_scratch, 512); in pd_identify()
719 disk->can_lba = pd_scratch[99] & 2; in pd_identify()
720 disk->sectors = le16_to_cpu(*(__le16 *) (pd_scratch + 12)); in pd_identify()
721 disk->heads = le16_to_cpu(*(__le16 *) (pd_scratch + 6)); in pd_identify()
722 disk->cylinders = le16_to_cpu(*(__le16 *) (pd_scratch + 2)); in pd_identify()
723 if (disk->can_lba) in pd_identify()
724 disk->capacity = le32_to_cpu(*(__le32 *) (pd_scratch + 120)); in pd_identify()
726 disk->capacity = disk->sectors * disk->heads * disk->cylinders; in pd_identify()
736 disk->removable = pd_scratch[0] & 0x80; in pd_identify()
739 disk->name, id, in pd_identify()
740 disk->drive ? "slave" : "master", in pd_identify()
741 disk->capacity, disk->capacity / 2048, in pd_identify()
742 disk->cylinders, disk->heads, disk->sectors, in pd_identify()
743 disk->removable ? "removable" : "fixed"); in pd_identify()
745 if (disk->capacity) in pd_identify()
746 pd_init_dev_parms(disk); in pd_identify()
747 if (!disk->standby) in pd_identify()
748 pd_standby_off(disk); in pd_identify()
758 struct pd_unit *disk = hctx->queue->queuedata; in pd_queue_rq() local
765 list_add_tail(&bd->rq->queuelist, &disk->rq_list); in pd_queue_rq()
772 static int pd_special_command(struct pd_unit *disk, in pd_special_command() argument
773 enum action (*func)(struct pd_unit *disk)) in pd_special_command() argument
778 rq = blk_get_request(disk->gd->queue, REQ_OP_DRV_IN, 0); in pd_special_command()
784 blk_execute_rq(disk->gd->queue, disk->gd, rq, 0); in pd_special_command()
793 struct pd_unit *disk = bdev->bd_disk->private_data; in pd_open() local
796 disk->access++; in pd_open()
798 if (disk->removable) { in pd_open()
799 pd_special_command(disk, pd_media_check); in pd_open()
800 pd_special_command(disk, pd_door_lock); in pd_open()
808 struct pd_unit *disk = bdev->bd_disk->private_data; in pd_getgeo() local
810 if (disk->alt_geom) { in pd_getgeo()
813 geo->cylinders = disk->capacity / (geo->heads * geo->sectors); in pd_getgeo()
815 geo->heads = disk->heads; in pd_getgeo()
816 geo->sectors = disk->sectors; in pd_getgeo()
817 geo->cylinders = disk->cylinders; in pd_getgeo()
826 struct pd_unit *disk = bdev->bd_disk->private_data; in pd_ioctl() local
831 if (disk->access == 1) in pd_ioctl()
832 pd_special_command(disk, pd_eject); in pd_ioctl()
842 struct pd_unit *disk = p->private_data; in pd_release() local
845 if (!--disk->access && disk->removable) in pd_release()
846 pd_special_command(disk, pd_door_unlock); in pd_release()
852 struct pd_unit *disk = p->private_data; in pd_check_events() local
854 if (!disk->removable) in pd_check_events()
856 pd_special_command(disk, pd_media_check); in pd_check_events()
857 r = disk->changed; in pd_check_events()
858 disk->changed = 0; in pd_check_events()
864 struct pd_unit *disk = p->private_data; in pd_revalidate() local
865 if (pd_special_command(disk, pd_identify) == 0) in pd_revalidate()
866 set_capacity(p, disk->capacity); in pd_revalidate()
889 static void pd_probe_drive(struct pd_unit *disk) in pd_probe_drive() argument
897 strcpy(p->disk_name, disk->name); in pd_probe_drive()
900 p->first_minor = (disk - pd) << PD_BITS; in pd_probe_drive()
902 disk->gd = p; in pd_probe_drive()
903 p->private_data = disk; in pd_probe_drive()
905 memset(&disk->tag_set, 0, sizeof(disk->tag_set)); in pd_probe_drive()
906 disk->tag_set.ops = &pd_mq_ops; in pd_probe_drive()
907 disk->tag_set.cmd_size = sizeof(struct pd_req); in pd_probe_drive()
908 disk->tag_set.nr_hw_queues = 1; in pd_probe_drive()
909 disk->tag_set.nr_maps = 1; in pd_probe_drive()
910 disk->tag_set.queue_depth = 2; in pd_probe_drive()
911 disk->tag_set.numa_node = NUMA_NO_NODE; in pd_probe_drive()
912 disk->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; in pd_probe_drive()
914 if (blk_mq_alloc_tag_set(&disk->tag_set)) in pd_probe_drive()
917 p->queue = blk_mq_init_queue(&disk->tag_set); in pd_probe_drive()
919 blk_mq_free_tag_set(&disk->tag_set); in pd_probe_drive()
924 p->queue->queuedata = disk; in pd_probe_drive()
928 if (disk->drive == -1) { in pd_probe_drive()
929 for (disk->drive = 0; disk->drive <= 1; disk->drive++) in pd_probe_drive()
930 if (pd_special_command(disk, pd_identify) == 0) in pd_probe_drive()
932 } else if (pd_special_command(disk, pd_identify) == 0) in pd_probe_drive()
934 disk->gd = NULL; in pd_probe_drive()
941 struct pd_unit *disk; in pd_detect() local
945 struct pd_unit *disk = pd + unit; in pd_detect() local
946 disk->pi = &disk->pia; in pd_detect()
947 disk->access = 0; in pd_detect()
948 disk->changed = 1; in pd_detect()
949 disk->capacity = 0; in pd_detect()
950 disk->drive = parm[D_SLV]; in pd_detect()
951 snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a'+unit); in pd_detect()
952 disk->alt_geom = parm[D_GEO]; in pd_detect()
953 disk->standby = parm[D_SBY]; in pd_detect()
956 INIT_LIST_HEAD(&disk->rq_list); in pd_detect()
966 disk = pd; in pd_detect()
967 if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch, in pd_detect()
968 PI_PD, verbose, disk->name)) { in pd_detect()
969 pd_probe_drive(disk); in pd_detect()
970 if (!disk->gd) in pd_detect()
971 pi_release(disk->pi); in pd_detect()
975 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { in pd_detect()
979 if (pi_init(disk->pi, 0, parm[D_PRT], parm[D_MOD], in pd_detect()
981 pd_scratch, PI_PD, verbose, disk->name)) { in pd_detect()
982 pd_probe_drive(disk); in pd_detect()
983 if (!disk->gd) in pd_detect()
984 pi_release(disk->pi); in pd_detect()
988 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { in pd_detect()
989 if (disk->gd) { in pd_detect()
990 set_capacity(disk->gd, disk->capacity); in pd_detect()
991 add_disk(disk->gd); in pd_detect()
1025 struct pd_unit *disk; in pd_exit() local
1028 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { in pd_exit()
1029 struct gendisk *p = disk->gd; in pd_exit()
1031 disk->gd = NULL; in pd_exit()
1034 blk_mq_free_tag_set(&disk->tag_set); in pd_exit()
1036 pi_release(disk->pi); in pd_exit()