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()
433 pd_current = pd_req->q->disk->private_data; in run_fsm()
495 if (pd_block + pd_count > get_capacity(pd_req->q->disk)) in do_pd_io_start()
637 static void pd_init_dev_parms(struct pd_unit *disk) in pd_init_dev_parms() argument
639 pd_wait_for(disk, 0, DBMSG("before init_dev_parms")); in pd_init_dev_parms()
640 pd_send_command(disk, disk->sectors, 0, disk->heads - 1, 0, 0, in pd_init_dev_parms()
643 pd_wait_for(disk, 0, "Initialise device parameters"); in pd_init_dev_parms()
646 static enum action pd_door_lock(struct pd_unit *disk) in pd_door_lock() argument
648 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) { in pd_door_lock()
649 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORLOCK); in pd_door_lock()
650 pd_wait_for(disk, STAT_READY, "Lock done"); in pd_door_lock()
655 static enum action pd_door_unlock(struct pd_unit *disk) in pd_door_unlock() argument
657 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) { in pd_door_unlock()
658 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK); in pd_door_unlock()
659 pd_wait_for(disk, STAT_READY, "Lock done"); in pd_door_unlock()
664 static enum action pd_eject(struct pd_unit *disk) in pd_eject() argument
666 pd_wait_for(disk, 0, DBMSG("before unlock on eject")); in pd_eject()
667 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK); in pd_eject()
668 pd_wait_for(disk, 0, DBMSG("after unlock on eject")); in pd_eject()
669 pd_wait_for(disk, 0, DBMSG("before eject")); in pd_eject()
670 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_EJECT); in pd_eject()
671 pd_wait_for(disk, 0, DBMSG("after eject")); in pd_eject()
675 static enum action pd_media_check(struct pd_unit *disk) in pd_media_check() argument
677 int r = pd_wait_for(disk, STAT_READY, DBMSG("before media_check")); in pd_media_check()
679 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY); in pd_media_check()
680 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after READ_VRFY")); in pd_media_check()
682 disk->changed = 1; /* say changed if other error */ in pd_media_check()
684 disk->changed = 1; in pd_media_check()
685 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_ACKCHANGE); in pd_media_check()
686 pd_wait_for(disk, STAT_READY, DBMSG("RDY after ACKCHANGE")); in pd_media_check()
687 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY); in pd_media_check()
688 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after VRFY")); in pd_media_check()
693 static void pd_standby_off(struct pd_unit *disk) in pd_standby_off() argument
695 pd_wait_for(disk, 0, DBMSG("before STANDBY")); in pd_standby_off()
696 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_STANDBY); in pd_standby_off()
697 pd_wait_for(disk, 0, DBMSG("after STANDBY")); in pd_standby_off()
700 static enum action pd_identify(struct pd_unit *disk) in pd_identify() argument
711 if (disk->drive == 0) in pd_identify()
712 pd_reset(disk); in pd_identify()
714 write_reg(disk, 6, DRIVE(disk)); in pd_identify()
715 pd_wait_for(disk, 0, DBMSG("before IDENT")); in pd_identify()
716 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_IDENTIFY); in pd_identify()
718 if (pd_wait_for(disk, STAT_DRQ, DBMSG("IDENT DRQ")) & STAT_ERR) in pd_identify()
720 pi_read_block(disk->pi, pd_scratch, 512); in pd_identify()
721 disk->can_lba = pd_scratch[99] & 2; in pd_identify()
722 disk->sectors = le16_to_cpu(*(__le16 *) (pd_scratch + 12)); in pd_identify()
723 disk->heads = le16_to_cpu(*(__le16 *) (pd_scratch + 6)); in pd_identify()
724 disk->cylinders = le16_to_cpu(*(__le16 *) (pd_scratch + 2)); in pd_identify()
725 if (disk->can_lba) in pd_identify()
726 disk->capacity = le32_to_cpu(*(__le32 *) (pd_scratch + 120)); in pd_identify()
728 disk->capacity = disk->sectors * disk->heads * disk->cylinders; in pd_identify()
738 disk->removable = pd_scratch[0] & 0x80; in pd_identify()
741 disk->name, id, in pd_identify()
742 disk->drive ? "slave" : "master", in pd_identify()
743 disk->capacity, disk->capacity / 2048, in pd_identify()
744 disk->cylinders, disk->heads, disk->sectors, in pd_identify()
745 disk->removable ? "removable" : "fixed"); in pd_identify()
747 if (disk->capacity) in pd_identify()
748 pd_init_dev_parms(disk); in pd_identify()
749 if (!disk->standby) in pd_identify()
750 pd_standby_off(disk); in pd_identify()
760 struct pd_unit *disk = hctx->queue->queuedata; in pd_queue_rq() local
767 list_add_tail(&bd->rq->queuelist, &disk->rq_list); in pd_queue_rq()
774 static int pd_special_command(struct pd_unit *disk, in pd_special_command() argument
775 enum action (*func)(struct pd_unit *disk)) in pd_special_command() argument
780 rq = blk_mq_alloc_request(disk->gd->queue, REQ_OP_DRV_IN, 0); in pd_special_command()
795 struct pd_unit *disk = bdev->bd_disk->private_data; in pd_open() local
798 disk->access++; in pd_open()
800 if (disk->removable) { in pd_open()
801 pd_special_command(disk, pd_media_check); in pd_open()
802 pd_special_command(disk, pd_door_lock); in pd_open()
810 struct pd_unit *disk = bdev->bd_disk->private_data; in pd_getgeo() local
812 if (disk->alt_geom) { in pd_getgeo()
815 geo->cylinders = disk->capacity / (geo->heads * geo->sectors); in pd_getgeo()
817 geo->heads = disk->heads; in pd_getgeo()
818 geo->sectors = disk->sectors; in pd_getgeo()
819 geo->cylinders = disk->cylinders; in pd_getgeo()
828 struct pd_unit *disk = bdev->bd_disk->private_data; in pd_ioctl() local
833 if (disk->access == 1) in pd_ioctl()
834 pd_special_command(disk, pd_eject); in pd_ioctl()
844 struct pd_unit *disk = p->private_data; in pd_release() local
847 if (!--disk->access && disk->removable) in pd_release()
848 pd_special_command(disk, pd_door_unlock); in pd_release()
854 struct pd_unit *disk = p->private_data; in pd_check_events() local
856 if (!disk->removable) in pd_check_events()
858 pd_special_command(disk, pd_media_check); in pd_check_events()
859 r = disk->changed; in pd_check_events()
860 disk->changed = 0; in pd_check_events()
880 static int pd_probe_drive(struct pd_unit *disk, int autoprobe, int port, in pd_probe_drive() argument
883 int index = disk - pd; in pd_probe_drive()
888 disk->pi = &disk->pia; in pd_probe_drive()
889 disk->access = 0; in pd_probe_drive()
890 disk->changed = 1; in pd_probe_drive()
891 disk->capacity = 0; in pd_probe_drive()
892 disk->drive = parm[D_SLV]; in pd_probe_drive()
893 snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a' + index); in pd_probe_drive()
894 disk->alt_geom = parm[D_GEO]; in pd_probe_drive()
895 disk->standby = parm[D_SBY]; in pd_probe_drive()
896 INIT_LIST_HEAD(&disk->rq_list); in pd_probe_drive()
898 if (!pi_init(disk->pi, autoprobe, port, mode, unit, protocol, delay, in pd_probe_drive()
899 pd_scratch, PI_PD, verbose, disk->name)) in pd_probe_drive()
902 memset(&disk->tag_set, 0, sizeof(disk->tag_set)); in pd_probe_drive()
903 disk->tag_set.ops = &pd_mq_ops; in pd_probe_drive()
904 disk->tag_set.cmd_size = sizeof(struct pd_req); in pd_probe_drive()
905 disk->tag_set.nr_hw_queues = 1; in pd_probe_drive()
906 disk->tag_set.nr_maps = 1; in pd_probe_drive()
907 disk->tag_set.queue_depth = 2; in pd_probe_drive()
908 disk->tag_set.numa_node = NUMA_NO_NODE; in pd_probe_drive()
909 disk->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; in pd_probe_drive()
910 ret = blk_mq_alloc_tag_set(&disk->tag_set); in pd_probe_drive()
914 p = blk_mq_alloc_disk(&disk->tag_set, disk); in pd_probe_drive()
919 disk->gd = p; in pd_probe_drive()
921 strcpy(p->disk_name, disk->name); in pd_probe_drive()
924 p->first_minor = (disk - pd) << PD_BITS; in pd_probe_drive()
927 p->private_data = disk; in pd_probe_drive()
931 if (disk->drive == -1) { in pd_probe_drive()
932 for (disk->drive = 0; disk->drive <= 1; disk->drive++) { in pd_probe_drive()
933 ret = pd_special_command(disk, pd_identify); in pd_probe_drive()
938 ret = pd_special_command(disk, pd_identify); in pd_probe_drive()
942 set_capacity(disk->gd, disk->capacity); in pd_probe_drive()
943 ret = add_disk(disk->gd); in pd_probe_drive()
948 put_disk(disk->gd); in pd_probe_drive()
951 disk->gd = NULL; in pd_probe_drive()
953 blk_mq_free_tag_set(&disk->tag_set); in pd_probe_drive()
955 pi_release(disk->pi); in pd_probe_drive()
962 struct pd_unit *disk; in pd_init() local
990 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { in pd_init()
994 if (!pd_probe_drive(disk, 0, parm[D_PRT], parm[D_MOD], in pd_init()
1015 struct pd_unit *disk; in pd_exit() local
1018 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { in pd_exit()
1019 struct gendisk *p = disk->gd; in pd_exit()
1021 disk->gd = NULL; in pd_exit()
1024 blk_mq_free_tag_set(&disk->tag_set); in pd_exit()
1025 pi_release(disk->pi); in pd_exit()