Lines Matching +full:cpu +full:- +full:viewed

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 1994-1998 Linus Torvalds & authors (see below)
10 * and Andre Hedrick <andre@linux-ide.org>
16 * -- increase WAIT_PIDENTIFY to avoid CD-ROM locking at boot
44 * generic_id - add a generic drive id
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()
63 u16 *id = drive->id; 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()
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()
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()
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()
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()
133 if (!strstr(m, "CD-ROM")) { 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()
151 if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { in ide_classify_atapi_dev()
157 printk(KERN_CONT "CD/DVD-ROM"); in ide_classify_atapi_dev()
164 drive->dev_flags |= IDE_DFLAG_REMOVABLE; 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
195 ide_hwif_t *hwif = drive->hwif; in do_identify()
200 /* local CPU only; some systems need this */ 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()
214 * ATA_CMD_ID_ATA returns little-endian info, in do_identify()
215 * ATA_CMD_ID_ATAPI *usually* returns little-endian info. in do_identify()
230 m[ATA_ID_PROD_LEN - 1] = '\0'; in do_identify()
233 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in do_identify()
235 drive->dev_flags |= IDE_DFLAG_PRESENT; in do_identify()
239 * ide_dev_read_id - send ATA/ATAPI IDENTIFY command
248 * 1 device timed-out (no response to identify request)
254 ide_hwif_t *hwif = drive->hwif; in ide_dev_read_id()
255 struct ide_io_ports *io_ports = &hwif->io_ports; in ide_dev_read_id()
256 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_dev_read_id()
265 if (io_ports->ctl_addr) in ide_dev_read_id()
266 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); in ide_dev_read_id()
274 if (io_ports->ctl_addr && in ide_dev_read_id()
275 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { in ide_dev_read_id()
276 a = tp_ops->read_altstatus(hwif); in ide_dev_read_id()
277 s = tp_ops->read_status(hwif); in ide_dev_read_id()
282 drive->name, s, a); in ide_dev_read_id()
284 /* use non-intrusive polling */ in ide_dev_read_id()
296 tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE); in ide_dev_read_id()
300 tp_ops->exec_command(hwif, cmd); in ide_dev_read_id()
315 s = tp_ops->read_status(hwif); in ide_dev_read_id()
324 (void)tp_ops->read_status(hwif); in ide_dev_read_id()
334 ide_hwif_t *hwif = drive->hwif; in ide_busy_sleep()
341 stat = altstatus ? hwif->tp_ops->read_altstatus(hwif) in ide_busy_sleep()
342 : hwif->tp_ops->read_status(hwif); 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()
356 drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE); in ide_read_device()
362 * do_probe - probe an IDE device
376 * 1 device timed-out (no response to identify request)
384 ide_hwif_t *hwif = drive->hwif; in do_probe()
385 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 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()
410 tp_ops->dev_select(hwif->devices[0]); in do_probe()
414 /* no i/f present: mmm.. this should be a 4 -ml */ in do_probe()
418 stat = tp_ops->read_status(hwif); in do_probe()
427 stat = tp_ops->read_status(hwif); in do_probe()
434 "resetting drive\n", drive->name, stat); in do_probe()
436 tp_ops->dev_select(drive); in do_probe()
438 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); in do_probe()
444 stat = tp_ops->read_status(hwif); in do_probe()
448 drive->name, stat); in do_probe()
453 if (drive->dn & 1) { in do_probe()
455 tp_ops->dev_select(hwif->devices[0]); in do_probe()
458 (void)tp_ops->read_status(hwif); in do_probe()
464 * probe_for_drives - upper level drive probe
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()
488 /* if !(success||timed-out) */ 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()
521 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in probe_for_drive()
525 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { in probe_for_drive()
530 if (drive->media == ide_disk) { in probe_for_drive()
542 complete(&hwif->gendev_rel_comp); in hwif_release_dev()
550 dev_set_name(&hwif->gendev, "%s", hwif->name); in ide_register_port()
551 dev_set_drvdata(&hwif->gendev, hwif); in ide_register_port()
552 if (hwif->gendev.parent == NULL) in ide_register_port()
553 hwif->gendev.parent = hwif->dev; in ide_register_port()
554 hwif->gendev.release = hwif_release_dev; in ide_register_port()
556 ret = device_register(&hwif->gendev); in ide_register_port()
563 hwif->portdev = device_create(ide_port_class, &hwif->gendev, in ide_register_port()
564 MKDEV(0, 0), hwif, "%s", hwif->name); in ide_register_port()
565 if (IS_ERR(hwif->portdev)) { in ide_register_port()
566 ret = PTR_ERR(hwif->portdev); in ide_register_port()
567 device_unregister(&hwif->gendev); in ide_register_port()
574 * ide_port_wait_ready - wait for port to become ready
577 * This is needed on some PPCs and a bunch of BIOS-less embedded
580 * - The firmware hard reset the disk before booting the kernel,
581 * the drive is still doing it's poweron-reset sequence, that
584 * - The firmware does nothing (or no firmware), the device is
587 * - Some CD/DVD/Writer combo drives tend to drive the bus during
588 * their reset sequence even when they are non-selected slave
591 * Doing this wait-for-non-busy should not harm any existing
601 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_port_wait_ready()
605 printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); 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()
625 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_port_wait_ready()
632 drive->name); in ide_port_wait_ready()
637 tp_ops->dev_select(hwif->devices[0]); in ide_port_wait_ready()
643 * ide_undecoded_slave - look for bad CF adapters
647 * have the same drive viewed twice. This occurs with crap CF adapters
653 ide_drive_t *dev0 = dev1->hwif->devices[0]; in ide_undecoded_slave()
655 if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0) in ide_undecoded_slave()
659 if (strcmp((char *)&dev0->id[ATA_ID_PROD], in ide_undecoded_slave()
660 (char *)&dev1->id[ATA_ID_PROD])) in ide_undecoded_slave()
664 if (strncmp((char *)&dev0->id[ATA_ID_SERNO], in ide_undecoded_slave()
665 (char *)&dev1->id[ATA_ID_SERNO], ATA_ID_SERNO_LEN)) in ide_undecoded_slave()
669 if (*(char *)&dev0->id[ATA_ID_SERNO] == 0) in ide_undecoded_slave()
673 printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); in ide_undecoded_slave()
675 dev1->dev_flags &= ~IDE_DFLAG_PRESENT; in ide_undecoded_slave()
684 int i, rc = -ENODEV; in ide_probe_port()
686 BUG_ON(hwif->present); in ide_probe_port()
688 if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) && in ide_probe_port()
689 (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE)) in ide_probe_port()
690 return -EACCES; in ide_probe_port()
696 irqd = hwif->irq; in ide_probe_port()
698 disable_irq(hwif->irq); in ide_probe_port()
700 if (ide_port_wait_ready(hwif) == -EBUSY) in ide_probe_port()
701 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); in ide_probe_port()
709 if (drive->dev_flags & IDE_DFLAG_PRESENT) in ide_probe_port()
725 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_tune_devices()
732 if (port_ops && port_ops->quirkproc) in ide_port_tune_devices()
733 port_ops->quirkproc(drive); in ide_port_tune_devices()
739 drive->dev_flags |= IDE_DFLAG_NICE1; in ide_port_tune_devices()
741 if (hwif->dma_ops) in ide_port_tune_devices()
750 req->special = NULL; in ide_initialize_rq()
751 scsi_req_init(&req->sreq); in ide_initialize_rq()
752 req->sreq.sense = req->sense; in ide_initialize_rq()
766 ide_hwif_t *hwif = drive->hwif; in ide_init_queue()
779 set = &drive->tag_set; in ide_init_queue()
780 set->ops = &ide_mq_ops; in ide_init_queue()
781 set->nr_hw_queues = 1; in ide_init_queue()
782 set->queue_depth = 32; in ide_init_queue()
783 set->reserved_tags = 1; in ide_init_queue()
784 set->cmd_size = sizeof(struct ide_request); in ide_init_queue()
785 set->numa_node = hwif_to_node(hwif); in ide_init_queue()
786 set->flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; in ide_init_queue()
798 q->queuedata = drive; in ide_init_queue()
801 if (hwif->rqsize < max_sectors) in ide_init_queue()
802 max_sectors = hwif->rqsize; in ide_init_queue()
821 drive->queue = q; in ide_init_queue()
830 * - allocate the block device queue
841 drive->name); in ide_port_setup_devices()
842 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in ide_port_setup_devices()
863 hwif->tp_ops->read_status(hwif); in ide_host_enable_irqs()
866 if (hwif->io_ports.ctl_addr) in ide_host_enable_irqs()
867 hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_host_enable_irqs()
876 struct ide_io_ports *io_ports = &hwif->io_ports; in init_irq()
877 struct ide_host *host = hwif->host; in init_irq()
878 irq_handler_t irq_handler = host->irq_handler; in init_irq()
879 int sa = host->irq_flags; in init_irq()
884 if (!host->get_lock) in init_irq()
885 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) in init_irq()
889 printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, in init_irq()
890 io_ports->data_addr, io_ports->status_addr, in init_irq()
891 io_ports->ctl_addr, hwif->irq); in init_irq()
893 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, in init_irq()
894 io_ports->data_addr, hwif->irq); in init_irq()
896 if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) in init_irq()
915 ide_drive_t *drive = hwif->devices[unit]; in ata_probe()
917 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in ata_probe()
920 if (drive->media == ide_disk) in ata_probe()
921 request_module("ide-disk"); in ata_probe()
922 if (drive->media == ide_cdrom || drive->media == ide_optical) in ata_probe()
923 request_module("ide-cd"); in ata_probe()
924 if (drive->media == ide_tape) in ata_probe()
925 request_module("ide-tape"); in ata_probe()
926 if (drive->media == ide_floppy) in ata_probe()
927 request_module("ide-floppy"); in ata_probe()
935 *part &= (1 << PARTN_BITS) - 1; in exact_match()
936 return &disk_to_dev(p)->kobj; in exact_match()
944 return -1; in exact_lock()
950 blk_register_region(MKDEV(disk->major, disk->first_minor), in ide_register_region()
951 disk->minors, NULL, exact_match, exact_lock, disk); in ide_register_region()
958 blk_unregister_region(MKDEV(disk->major, disk->first_minor), in ide_unregister_region()
959 disk->minors); in ide_unregister_region()
966 ide_hwif_t *hwif = drive->hwif; in ide_init_disk()
967 unsigned int unit = drive->dn & 1; in ide_init_disk()
969 disk->major = hwif->major; in ide_init_disk()
970 disk->first_minor = unit << PARTN_BITS; in ide_init_disk()
971 sprintf(disk->disk_name, "hd%c", 'a' + hwif->index * MAX_DRIVES + unit); in ide_init_disk()
972 disk->queue = drive->queue; in ide_init_disk()
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()
997 if (!hwif->irq) { in hwif_init()
998 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); in hwif_init()
1002 if (register_blkdev(hwif->major, hwif->name)) in hwif_init()
1005 if (!hwif->sg_max_nents) in hwif_init()
1006 hwif->sg_max_nents = PRD_ENTRIES; in hwif_init()
1008 hwif->sg_table = kmalloc_array(hwif->sg_max_nents, in hwif_init()
1011 if (!hwif->sg_table) { in hwif_init()
1012 printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); in hwif_init()
1016 sg_init_table(hwif->sg_table, hwif->sg_max_nents); in hwif_init()
1020 hwif->name, hwif->irq); in hwif_init()
1024 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, in hwif_init()
1029 unregister_blkdev(hwif->major, hwif->name); in hwif_init()
1039 struct device *dev = &drive->gendev; in hwif_register_devices()
1042 dev_set_name(dev, "%u.%u", hwif->index, i); in hwif_register_devices()
1044 dev->parent = &hwif->gendev; in hwif_register_devices()
1045 dev->bus = &ide_bus_type; in hwif_register_devices()
1046 dev->release = drive_release_dev; in hwif_register_devices()
1057 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_init_devices()
1062 drive->dn = i + hwif->channel * 2; in ide_port_init_devices()
1064 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) in ide_port_init_devices()
1065 drive->io_32bit = 1; in ide_port_init_devices()
1066 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) in ide_port_init_devices()
1067 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; in ide_port_init_devices()
1068 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) in ide_port_init_devices()
1069 drive->dev_flags |= IDE_DFLAG_UNMASK; in ide_port_init_devices()
1070 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) 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()
1075 if (port_ops && port_ops->init_dev) in ide_port_init_devices()
1076 port_ops->init_dev(drive); in ide_port_init_devices()
1083 hwif->channel = port; in ide_init_port()
1085 hwif->chipset = d->chipset ? d->chipset : ide_pci; in ide_init_port()
1087 if (d->init_iops) in ide_init_port()
1088 d->init_iops(hwif); in ide_init_port()
1090 /* ->host_flags may be set by ->init_iops (or even earlier...) */ in ide_init_port()
1091 hwif->host_flags |= d->host_flags; in ide_init_port()
1092 hwif->pio_mask = d->pio_mask; in ide_init_port()
1094 if (d->tp_ops) in ide_init_port()
1095 hwif->tp_ops = d->tp_ops; in ide_init_port()
1097 /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ in ide_init_port()
1098 if ((hwif->host_flags & IDE_HFLAG_DTC2278) == 0 || hwif->channel == 0) in ide_init_port()
1099 hwif->port_ops = d->port_ops; in ide_init_port()
1101 hwif->swdma_mask = d->swdma_mask; in ide_init_port()
1102 hwif->mwdma_mask = d->mwdma_mask; in ide_init_port()
1103 hwif->ultra_mask = d->udma_mask; in ide_init_port()
1105 if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { in ide_init_port()
1108 hwif->dma_ops = d->dma_ops; in ide_init_port()
1110 if (d->init_dma) in ide_init_port()
1111 rc = d->init_dma(hwif, d); in ide_init_port()
1116 printk(KERN_INFO "%s: DMA disabled\n", hwif->name); in ide_init_port()
1118 hwif->dma_ops = NULL; in ide_init_port()
1119 hwif->dma_base = 0; in ide_init_port()
1120 hwif->swdma_mask = 0; in ide_init_port()
1121 hwif->mwdma_mask = 0; in ide_init_port()
1122 hwif->ultra_mask = 0; in ide_init_port()
1126 if ((d->host_flags & IDE_HFLAG_SERIALIZE) || in ide_init_port()
1127 ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) in ide_init_port()
1128 hwif->host->host_flags |= IDE_HFLAG_SERIALIZE; in ide_init_port()
1130 if (d->max_sectors) in ide_init_port()
1131 hwif->rqsize = d->max_sectors; in ide_init_port()
1133 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || in ide_init_port()
1134 (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) in ide_init_port()
1135 hwif->rqsize = 256; in ide_init_port()
1137 hwif->rqsize = 65536; in ide_init_port()
1141 if (d->init_hwif) in ide_init_port()
1142 d->init_hwif(hwif); in ide_init_port()
1147 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_cable_detect()
1149 if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { in ide_port_cable_detect()
1150 if (hwif->cbl != ATA_CBL_PATA40_SHORT) in ide_port_cable_detect()
1151 hwif->cbl = port_ops->cable_detect(hwif); in ide_port_cable_detect()
1161 ide_hwif_t *hwif = drive->hwif; in drive_rq_insert_work()
1166 blk_mq_quiesce_queue(drive->queue); in drive_rq_insert_work()
1169 spin_lock_irq(&hwif->lock); 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()
1172 list_del_init(&rq->queuelist); in drive_rq_insert_work()
1174 spin_unlock_irq(&hwif->lock); in drive_rq_insert_work()
1176 spin_lock_irq(&hwif->lock); in drive_rq_insert_work()
1178 spin_unlock_irq(&hwif->lock); 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()
1196 u8 j = (hwif->index * MAX_DRIVES) + i; in ide_port_init_devices_data()
1197 u16 *saved_id = drive->id; 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()
1225 /* fill in any non-zero initial values */ in ide_init_port_data()
1226 hwif->index = index; in ide_init_port_data()
1227 hwif->major = ide_hwif_to_major[index]; in ide_init_port_data()
1229 hwif->name[0] = 'i'; in ide_init_port_data()
1230 hwif->name[1] = 'd'; in ide_init_port_data()
1231 hwif->name[2] = 'e'; in ide_init_port_data()
1232 hwif->name[3] = '0' + index; in ide_init_port_data()
1234 spin_lock_init(&hwif->lock); in ide_init_port_data()
1236 timer_setup(&hwif->timer, ide_timer_expiry, 0); in ide_init_port_data()
1238 init_completion(&hwif->gendev_rel_comp); in ide_init_port_data()
1240 hwif->tp_ops = &default_tp_ops; in ide_init_port_data()
1247 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); in ide_init_port_hw()
1248 hwif->irq = hw->irq; in ide_init_port_hw()
1249 hwif->dev = hw->dev; in ide_init_port_hw()
1250 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; in ide_init_port_hw()
1251 hwif->config_data = hw->config; in ide_init_port_hw()
1257 * ide_find_port_slot - find free port slot
1260 * Return the new port slot index or -ENOENT if we are out of free slots.
1265 int idx = -ENOENT; in ide_find_port_slot()
1266 u8 bootable = (d && (d->host_flags & IDE_HFLAG_NON_BOOTABLE)) ? 0 : 1; in ide_find_port_slot()
1267 u8 i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0; in ide_find_port_slot()
1273 * just in case there's another interface yet-to-be-scanned in ide_find_port_slot()
1281 if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1) in ide_find_port_slot()
1284 if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1) in ide_find_port_slot()
1309 kfree(drive->id); in ide_port_free_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()
1344 return -ENOMEM; in ide_port_alloc_devices()
1351 struct device *dev = hws[0] ? hws[0]->dev : NULL; in ide_host_alloc()
1352 int node = dev ? dev_to_node(dev) : -1; in ide_host_alloc()
1378 d ? d->name : "ide"); in ide_host_alloc()
1386 hwif->host = host; in ide_host_alloc()
1388 host->ports[i] = hwif; in ide_host_alloc()
1389 host->n_ports++; in ide_host_alloc()
1392 if (host->n_ports == 0) { in ide_host_alloc()
1397 host->dev[0] = dev; in ide_host_alloc()
1400 host->init_chipset = d->init_chipset; in ide_host_alloc()
1401 host->get_lock = d->get_lock; in ide_host_alloc()
1402 host->release_lock = d->release_lock; in ide_host_alloc()
1403 host->host_flags = d->host_flags; in ide_host_alloc()
1404 host->irq_flags = d->irq_flags; in ide_host_alloc()
1414 ide_free_port_slot(hwif->index); in ide_port_free()
1420 struct ide_host *host = hwif->host; in ide_disable_port()
1423 printk(KERN_INFO "%s: disabling port\n", hwif->name); in ide_disable_port()
1426 if (host->ports[i] == hwif) { in ide_disable_port()
1427 host->ports[i] = NULL; in ide_disable_port()
1428 host->n_ports--; in ide_disable_port()
1442 "Report any missing HW support to linux-ide@vger.kernel.org\n"); in ide_host_register()
1454 hwif->mate = mate; in ide_host_register()
1455 mate->mate = hwif; in ide_host_register()
1463 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_host_register()
1473 hwif->present = 1; in ide_host_register()
1475 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_host_register()
1477 if ((hwif->host_flags & IDE_HFLAG_4DRIVES) == 0 || in ide_host_register()
1478 hwif->mate == NULL || hwif->mate->present == 0) { in ide_host_register()
1485 if (hwif->present) in ide_host_register()
1497 "interface\n", hwif->name); in ide_host_register()
1498 device_unregister(hwif->portdev); in ide_host_register()
1499 device_unregister(&hwif->gendev); in ide_host_register()
1504 if (hwif->present) in ide_host_register()
1506 hwif->present = 0; in ide_host_register()
1514 if (hwif->present) in ide_host_register()
1525 if (hwif->present) { in ide_host_register()
1531 return j ? 0 : -1; in ide_host_register()
1543 return -ENOMEM; in ide_host_add()
1564 device_unregister(&drive->gendev); in __ide_port_unregister_devices()
1565 wait_for_completion(&drive->gendev_rel_comp); in __ide_port_unregister_devices()
1573 hwif->present = 0; in ide_port_unregister_devices()
1580 * ide_unregister - free an IDE interface
1600 if (hwif->present) { in ide_unregister()
1602 hwif->present = 0; in ide_unregister()
1607 if (!hwif->host->get_lock) in ide_unregister()
1608 free_irq(hwif->irq, hwif); in ide_unregister()
1610 device_unregister(hwif->portdev); in ide_unregister()
1611 device_unregister(&hwif->gendev); in ide_unregister()
1612 wait_for_completion(&hwif->gendev_rel_comp); in ide_unregister()
1617 blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); in ide_unregister()
1618 kfree(hwif->sg_table); in ide_unregister()
1619 unregister_blkdev(hwif->major, hwif->name); in ide_unregister()
1661 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_port_scan()
1667 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_port_scan()
1672 hwif->present = 1; in ide_port_scan()