.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
---|
3 | 4 | * Copyright (C) 2005, 2007 Bartlomiej Zolnierkiewicz |
---|
.. | .. |
---|
142 | 143 | } |
---|
143 | 144 | /* Early cdrom models used zero */ |
---|
144 | 145 | type = ide_cdrom; |
---|
145 | | - /* fall through */ |
---|
| 146 | + fallthrough; |
---|
146 | 147 | case ide_cdrom: |
---|
147 | 148 | drive->dev_flags |= IDE_DFLAG_REMOVABLE; |
---|
148 | 149 | #ifdef CONFIG_PPC |
---|
.. | .. |
---|
746 | 747 | { |
---|
747 | 748 | struct ide_request *req = blk_mq_rq_to_pdu(rq); |
---|
748 | 749 | |
---|
| 750 | + req->special = NULL; |
---|
749 | 751 | scsi_req_init(&req->sreq); |
---|
750 | 752 | req->sreq.sense = req->sense; |
---|
751 | 753 | } |
---|
| 754 | + |
---|
| 755 | +static const struct blk_mq_ops ide_mq_ops = { |
---|
| 756 | + .queue_rq = ide_queue_rq, |
---|
| 757 | + .initialize_rq_fn = ide_initialize_rq, |
---|
| 758 | +}; |
---|
752 | 759 | |
---|
753 | 760 | /* |
---|
754 | 761 | * init request queue |
---|
.. | .. |
---|
759 | 766 | ide_hwif_t *hwif = drive->hwif; |
---|
760 | 767 | int max_sectors = 256; |
---|
761 | 768 | int max_sg_entries = PRD_ENTRIES; |
---|
| 769 | + struct blk_mq_tag_set *set; |
---|
762 | 770 | |
---|
763 | 771 | /* |
---|
764 | 772 | * Our default set up assumes the normal IDE case, |
---|
.. | .. |
---|
767 | 775 | * limits and LBA48 we could raise it but as yet |
---|
768 | 776 | * do not. |
---|
769 | 777 | */ |
---|
770 | | - q = blk_alloc_queue_node(GFP_KERNEL, hwif_to_node(hwif), NULL); |
---|
771 | | - if (!q) |
---|
| 778 | + |
---|
| 779 | + set = &drive->tag_set; |
---|
| 780 | + set->ops = &ide_mq_ops; |
---|
| 781 | + set->nr_hw_queues = 1; |
---|
| 782 | + set->queue_depth = 32; |
---|
| 783 | + set->reserved_tags = 1; |
---|
| 784 | + set->cmd_size = sizeof(struct ide_request); |
---|
| 785 | + set->numa_node = hwif_to_node(hwif); |
---|
| 786 | + set->flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; |
---|
| 787 | + if (blk_mq_alloc_tag_set(set)) |
---|
772 | 788 | return 1; |
---|
773 | 789 | |
---|
774 | | - q->request_fn = do_ide_request; |
---|
775 | | - q->initialize_rq_fn = ide_initialize_rq; |
---|
776 | | - q->cmd_size = sizeof(struct ide_request); |
---|
777 | | - blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, q); |
---|
778 | | - if (blk_init_allocated_queue(q) < 0) { |
---|
779 | | - blk_cleanup_queue(q); |
---|
| 790 | + q = blk_mq_init_queue(set); |
---|
| 791 | + if (IS_ERR(q)) { |
---|
| 792 | + blk_mq_free_tag_set(set); |
---|
780 | 793 | return 1; |
---|
781 | 794 | } |
---|
| 795 | + |
---|
| 796 | + blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, q); |
---|
782 | 797 | |
---|
783 | 798 | q->queuedata = drive; |
---|
784 | 799 | blk_queue_segment_boundary(q, 0xffff); |
---|
.. | .. |
---|
965 | 980 | |
---|
966 | 981 | ide_proc_unregister_device(drive); |
---|
967 | 982 | |
---|
| 983 | + if (drive->sense_rq) |
---|
| 984 | + blk_mq_free_request(drive->sense_rq); |
---|
| 985 | + |
---|
968 | 986 | blk_cleanup_queue(drive->queue); |
---|
969 | 987 | drive->queue = NULL; |
---|
| 988 | + blk_mq_free_tag_set(&drive->tag_set); |
---|
970 | 989 | |
---|
971 | 990 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
---|
972 | 991 | |
---|
.. | .. |
---|
1133 | 1152 | } |
---|
1134 | 1153 | } |
---|
1135 | 1154 | |
---|
| 1155 | +/* |
---|
| 1156 | + * Deferred request list insertion handler |
---|
| 1157 | + */ |
---|
| 1158 | +static void drive_rq_insert_work(struct work_struct *work) |
---|
| 1159 | +{ |
---|
| 1160 | + ide_drive_t *drive = container_of(work, ide_drive_t, rq_work); |
---|
| 1161 | + ide_hwif_t *hwif = drive->hwif; |
---|
| 1162 | + struct request *rq; |
---|
| 1163 | + blk_status_t ret; |
---|
| 1164 | + LIST_HEAD(list); |
---|
| 1165 | + |
---|
| 1166 | + blk_mq_quiesce_queue(drive->queue); |
---|
| 1167 | + |
---|
| 1168 | + ret = BLK_STS_OK; |
---|
| 1169 | + spin_lock_irq(&hwif->lock); |
---|
| 1170 | + while (!list_empty(&drive->rq_list)) { |
---|
| 1171 | + rq = list_first_entry(&drive->rq_list, struct request, queuelist); |
---|
| 1172 | + list_del_init(&rq->queuelist); |
---|
| 1173 | + |
---|
| 1174 | + spin_unlock_irq(&hwif->lock); |
---|
| 1175 | + ret = ide_issue_rq(drive, rq, true); |
---|
| 1176 | + spin_lock_irq(&hwif->lock); |
---|
| 1177 | + } |
---|
| 1178 | + spin_unlock_irq(&hwif->lock); |
---|
| 1179 | + |
---|
| 1180 | + blk_mq_unquiesce_queue(drive->queue); |
---|
| 1181 | + |
---|
| 1182 | + if (ret != BLK_STS_OK) |
---|
| 1183 | + kblockd_schedule_work(&drive->rq_work); |
---|
| 1184 | +} |
---|
| 1185 | + |
---|
1136 | 1186 | static const u8 ide_hwif_to_major[] = |
---|
1137 | 1187 | { IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, IDE4_MAJOR, |
---|
1138 | 1188 | IDE5_MAJOR, IDE6_MAJOR, IDE7_MAJOR, IDE8_MAJOR, IDE9_MAJOR }; |
---|
.. | .. |
---|
1145 | 1195 | ide_port_for_each_dev(i, drive, hwif) { |
---|
1146 | 1196 | u8 j = (hwif->index * MAX_DRIVES) + i; |
---|
1147 | 1197 | u16 *saved_id = drive->id; |
---|
1148 | | - struct request *saved_sense_rq = drive->sense_rq; |
---|
1149 | 1198 | |
---|
1150 | 1199 | memset(drive, 0, sizeof(*drive)); |
---|
1151 | 1200 | memset(saved_id, 0, SECTOR_SIZE); |
---|
1152 | 1201 | drive->id = saved_id; |
---|
1153 | | - drive->sense_rq = saved_sense_rq; |
---|
1154 | 1202 | |
---|
1155 | 1203 | drive->media = ide_disk; |
---|
1156 | 1204 | drive->select = (i << 4) | ATA_DEVICE_OBS; |
---|
.. | .. |
---|
1166 | 1214 | |
---|
1167 | 1215 | INIT_LIST_HEAD(&drive->list); |
---|
1168 | 1216 | init_completion(&drive->gendev_rel_comp); |
---|
| 1217 | + |
---|
| 1218 | + INIT_WORK(&drive->rq_work, drive_rq_insert_work); |
---|
| 1219 | + INIT_LIST_HEAD(&drive->rq_list); |
---|
1169 | 1220 | } |
---|
1170 | 1221 | } |
---|
1171 | 1222 | |
---|
.. | .. |
---|
1255 | 1306 | int i; |
---|
1256 | 1307 | |
---|
1257 | 1308 | ide_port_for_each_dev(i, drive, hwif) { |
---|
1258 | | - kfree(drive->sense_rq); |
---|
1259 | 1309 | kfree(drive->id); |
---|
1260 | 1310 | kfree(drive); |
---|
1261 | 1311 | } |
---|
.. | .. |
---|
1283 | 1333 | if (drive->id == NULL) |
---|
1284 | 1334 | goto out_free_drive; |
---|
1285 | 1335 | |
---|
1286 | | - drive->sense_rq = kmalloc(sizeof(struct request) + |
---|
1287 | | - sizeof(struct ide_request), GFP_KERNEL); |
---|
1288 | | - if (!drive->sense_rq) |
---|
1289 | | - goto out_free_id; |
---|
1290 | | - |
---|
1291 | 1336 | hwif->devices[i] = drive; |
---|
1292 | 1337 | } |
---|
1293 | 1338 | return 0; |
---|
1294 | 1339 | |
---|
1295 | | -out_free_id: |
---|
1296 | | - kfree(drive->id); |
---|
1297 | 1340 | out_free_drive: |
---|
1298 | 1341 | kfree(drive); |
---|
1299 | 1342 | out_nomem: |
---|
.. | .. |
---|
1395 | 1438 | ide_hwif_t *hwif, *mate = NULL; |
---|
1396 | 1439 | int i, j = 0; |
---|
1397 | 1440 | |
---|
| 1441 | + pr_warn("legacy IDE will be removed in 2021, please switch to libata\n" |
---|
| 1442 | + "Report any missing HW support to linux-ide@vger.kernel.org\n"); |
---|
| 1443 | + |
---|
1398 | 1444 | ide_host_for_each_port(i, hwif, host) { |
---|
1399 | 1445 | if (hwif == NULL) { |
---|
1400 | 1446 | mate = NULL; |
---|