@@ -258,11 +258,22 @@ static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
258
258
/*
259
259
* take a breather
260
260
*/
261
- blk_delay_queue (drive -> queue , 1 );
261
+ blk_mq_requeue_request (rq , false);
262
+ blk_mq_delay_kick_requeue_list (drive -> queue , 1 );
262
263
return 1 ;
263
264
}
264
265
}
265
266
267
+ static void ide_cd_free_sense (ide_drive_t * drive )
268
+ {
269
+ if (!drive -> sense_rq )
270
+ return ;
271
+
272
+ blk_mq_free_request (drive -> sense_rq );
273
+ drive -> sense_rq = NULL ;
274
+ drive -> sense_rq_armed = false;
275
+ }
276
+
266
277
/**
267
278
* Returns:
268
279
* 0: if the request should be continued.
@@ -516,6 +527,82 @@ static bool ide_cd_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd)
516
527
return false;
517
528
}
518
529
530
+ /* standard prep_rq_fn that builds 10 byte cmds */
531
+ static int ide_cdrom_prep_fs (struct request_queue * q , struct request * rq )
532
+ {
533
+ int hard_sect = queue_logical_block_size (q );
534
+ long block = (long )blk_rq_pos (rq ) / (hard_sect >> 9 );
535
+ unsigned long blocks = blk_rq_sectors (rq ) / (hard_sect >> 9 );
536
+ struct scsi_request * req = scsi_req (rq );
537
+
538
+ if (rq_data_dir (rq ) == READ )
539
+ req -> cmd [0 ] = GPCMD_READ_10 ;
540
+ else
541
+ req -> cmd [0 ] = GPCMD_WRITE_10 ;
542
+
543
+ /*
544
+ * fill in lba
545
+ */
546
+ req -> cmd [2 ] = (block >> 24 ) & 0xff ;
547
+ req -> cmd [3 ] = (block >> 16 ) & 0xff ;
548
+ req -> cmd [4 ] = (block >> 8 ) & 0xff ;
549
+ req -> cmd [5 ] = block & 0xff ;
550
+
551
+ /*
552
+ * and transfer length
553
+ */
554
+ req -> cmd [7 ] = (blocks >> 8 ) & 0xff ;
555
+ req -> cmd [8 ] = blocks & 0xff ;
556
+ req -> cmd_len = 10 ;
557
+ return BLKPREP_OK ;
558
+ }
559
+
560
+ /*
561
+ * Most of the SCSI commands are supported directly by ATAPI devices.
562
+ * This transform handles the few exceptions.
563
+ */
564
+ static int ide_cdrom_prep_pc (struct request * rq )
565
+ {
566
+ u8 * c = scsi_req (rq )-> cmd ;
567
+
568
+ /* transform 6-byte read/write commands to the 10-byte version */
569
+ if (c [0 ] == READ_6 || c [0 ] == WRITE_6 ) {
570
+ c [8 ] = c [4 ];
571
+ c [5 ] = c [3 ];
572
+ c [4 ] = c [2 ];
573
+ c [3 ] = c [1 ] & 0x1f ;
574
+ c [2 ] = 0 ;
575
+ c [1 ] &= 0xe0 ;
576
+ c [0 ] += (READ_10 - READ_6 );
577
+ scsi_req (rq )-> cmd_len = 10 ;
578
+ return BLKPREP_OK ;
579
+ }
580
+
581
+ /*
582
+ * it's silly to pretend we understand 6-byte sense commands, just
583
+ * reject with ILLEGAL_REQUEST and the caller should take the
584
+ * appropriate action
585
+ */
586
+ if (c [0 ] == MODE_SENSE || c [0 ] == MODE_SELECT ) {
587
+ scsi_req (rq )-> result = ILLEGAL_REQUEST ;
588
+ return BLKPREP_KILL ;
589
+ }
590
+
591
+ return BLKPREP_OK ;
592
+ }
593
+
594
+ static int ide_cdrom_prep_fn (ide_drive_t * drive , struct request * rq )
595
+ {
596
+ if (!blk_rq_is_passthrough (rq )) {
597
+ scsi_req_init (scsi_req (rq ));
598
+
599
+ return ide_cdrom_prep_fs (drive -> queue , rq );
600
+ } else if (blk_rq_is_scsi (rq ))
601
+ return ide_cdrom_prep_pc (rq );
602
+
603
+ return 0 ;
604
+ }
605
+
519
606
static ide_startstop_t cdrom_newpc_intr (ide_drive_t * drive )
520
607
{
521
608
ide_hwif_t * hwif = drive -> hwif ;
@@ -675,7 +762,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
675
762
out_end :
676
763
if (blk_rq_is_scsi (rq ) && rc == 0 ) {
677
764
scsi_req (rq )-> resid_len = 0 ;
678
- blk_end_request_all (rq , BLK_STS_OK );
765
+ blk_mq_end_request (rq , BLK_STS_OK );
679
766
hwif -> rq = NULL ;
680
767
} else {
681
768
if (sense && uptodate )
@@ -705,6 +792,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
705
792
if (sense && rc == 2 )
706
793
ide_error (drive , "request sense failure" , stat );
707
794
}
795
+
796
+ ide_cd_free_sense (drive );
708
797
return ide_stopped ;
709
798
}
710
799
@@ -729,7 +818,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
729
818
* We may be retrying this request after an error. Fix up any
730
819
* weirdness which might be present in the request packet.
731
820
*/
732
- q -> prep_rq_fn ( q , rq );
821
+ ide_cdrom_prep_fn ( drive , rq );
733
822
}
734
823
735
824
/* fs requests *must* be hardware frame aligned */
@@ -1323,82 +1412,6 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1323
1412
return nslots ;
1324
1413
}
1325
1414
1326
- /* standard prep_rq_fn that builds 10 byte cmds */
1327
- static int ide_cdrom_prep_fs (struct request_queue * q , struct request * rq )
1328
- {
1329
- int hard_sect = queue_logical_block_size (q );
1330
- long block = (long )blk_rq_pos (rq ) / (hard_sect >> 9 );
1331
- unsigned long blocks = blk_rq_sectors (rq ) / (hard_sect >> 9 );
1332
- struct scsi_request * req = scsi_req (rq );
1333
-
1334
- q -> initialize_rq_fn (rq );
1335
-
1336
- if (rq_data_dir (rq ) == READ )
1337
- req -> cmd [0 ] = GPCMD_READ_10 ;
1338
- else
1339
- req -> cmd [0 ] = GPCMD_WRITE_10 ;
1340
-
1341
- /*
1342
- * fill in lba
1343
- */
1344
- req -> cmd [2 ] = (block >> 24 ) & 0xff ;
1345
- req -> cmd [3 ] = (block >> 16 ) & 0xff ;
1346
- req -> cmd [4 ] = (block >> 8 ) & 0xff ;
1347
- req -> cmd [5 ] = block & 0xff ;
1348
-
1349
- /*
1350
- * and transfer length
1351
- */
1352
- req -> cmd [7 ] = (blocks >> 8 ) & 0xff ;
1353
- req -> cmd [8 ] = blocks & 0xff ;
1354
- req -> cmd_len = 10 ;
1355
- return BLKPREP_OK ;
1356
- }
1357
-
1358
- /*
1359
- * Most of the SCSI commands are supported directly by ATAPI devices.
1360
- * This transform handles the few exceptions.
1361
- */
1362
- static int ide_cdrom_prep_pc (struct request * rq )
1363
- {
1364
- u8 * c = scsi_req (rq )-> cmd ;
1365
-
1366
- /* transform 6-byte read/write commands to the 10-byte version */
1367
- if (c [0 ] == READ_6 || c [0 ] == WRITE_6 ) {
1368
- c [8 ] = c [4 ];
1369
- c [5 ] = c [3 ];
1370
- c [4 ] = c [2 ];
1371
- c [3 ] = c [1 ] & 0x1f ;
1372
- c [2 ] = 0 ;
1373
- c [1 ] &= 0xe0 ;
1374
- c [0 ] += (READ_10 - READ_6 );
1375
- scsi_req (rq )-> cmd_len = 10 ;
1376
- return BLKPREP_OK ;
1377
- }
1378
-
1379
- /*
1380
- * it's silly to pretend we understand 6-byte sense commands, just
1381
- * reject with ILLEGAL_REQUEST and the caller should take the
1382
- * appropriate action
1383
- */
1384
- if (c [0 ] == MODE_SENSE || c [0 ] == MODE_SELECT ) {
1385
- scsi_req (rq )-> result = ILLEGAL_REQUEST ;
1386
- return BLKPREP_KILL ;
1387
- }
1388
-
1389
- return BLKPREP_OK ;
1390
- }
1391
-
1392
- static int ide_cdrom_prep_fn (struct request_queue * q , struct request * rq )
1393
- {
1394
- if (!blk_rq_is_passthrough (rq ))
1395
- return ide_cdrom_prep_fs (q , rq );
1396
- else if (blk_rq_is_scsi (rq ))
1397
- return ide_cdrom_prep_pc (rq );
1398
-
1399
- return 0 ;
1400
- }
1401
-
1402
1415
struct cd_list_entry {
1403
1416
const char * id_model ;
1404
1417
const char * id_firmware ;
@@ -1508,7 +1521,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1508
1521
1509
1522
ide_debug_log (IDE_DBG_PROBE , "enter" );
1510
1523
1511
- blk_queue_prep_rq ( q , ide_cdrom_prep_fn ) ;
1524
+ drive -> prep_rq = ide_cdrom_prep_fn ;
1512
1525
blk_queue_dma_alignment (q , 31 );
1513
1526
blk_queue_update_dma_pad (q , 15 );
1514
1527
@@ -1569,7 +1582,7 @@ static void ide_cd_release(struct device *dev)
1569
1582
if (devinfo -> handle == drive )
1570
1583
unregister_cdrom (devinfo );
1571
1584
drive -> driver_data = NULL ;
1572
- blk_queue_prep_rq ( drive -> queue , NULL ) ;
1585
+ drive -> prep_rq = NULL ;
1573
1586
g -> private_data = NULL ;
1574
1587
put_disk (g );
1575
1588
kfree (info );
0 commit comments