Lines Matching refs:rq
96 static int cdrom_log_sense(ide_drive_t *drive, struct request *rq) in cdrom_log_sense() argument
101 if (!sense || !rq || (rq->cmd_flags & REQ_QUIET)) in cdrom_log_sense()
124 if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) in cdrom_log_sense()
210 static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) in ide_cd_complete_failed_rq() argument
218 struct request *failed = (struct request *)rq->special; in ide_cd_complete_failed_rq()
219 void *sense = bio_data(rq->bio); in ide_cd_complete_failed_rq()
229 failed->sense_len = rq->sense_len; in ide_cd_complete_failed_rq()
247 static int ide_cd_breathe(ide_drive_t *drive, struct request *rq) in ide_cd_breathe() argument
252 if (!rq->errors) in ide_cd_breathe()
255 rq->errors = 1; in ide_cd_breathe()
277 struct request *rq = hwif->rq; in cdrom_decode_status() local
286 rq->cmd[0], rq->cmd_type, err, stat); in cdrom_decode_status()
288 if (rq->cmd_type == REQ_TYPE_ATA_SENSE) { in cdrom_decode_status()
294 rq->cmd_flags |= REQ_FAILED; in cdrom_decode_status()
299 if (rq->cmd_type == REQ_TYPE_BLOCK_PC && !rq->errors) in cdrom_decode_status()
300 rq->errors = SAM_STAT_CHECK_CONDITION; in cdrom_decode_status()
302 if (blk_noretry_request(rq)) in cdrom_decode_status()
307 if (rq->cmd_type == REQ_TYPE_FS && rq_data_dir(rq) == WRITE) { in cdrom_decode_status()
308 if (ide_cd_breathe(drive, rq)) in cdrom_decode_status()
313 if (rq->cmd_type == REQ_TYPE_FS && in cdrom_decode_status()
314 !(rq->cmd_flags & REQ_QUIET)) in cdrom_decode_status()
323 if (rq->cmd_type != REQ_TYPE_FS) in cdrom_decode_status()
330 if (++rq->errors > ERROR_MAX) in cdrom_decode_status()
341 if (rq->cmd[0] == GPCMD_START_STOP_UNIT) in cdrom_decode_status()
349 if (!(rq->cmd_flags & REQ_QUIET)) in cdrom_decode_status()
358 if (!(rq->cmd_flags & REQ_QUIET)) in cdrom_decode_status()
365 if (!(rq->cmd_flags & REQ_QUIET)) in cdrom_decode_status()
371 if (rq->cmd_type != REQ_TYPE_FS) in cdrom_decode_status()
377 } else if (++rq->errors > ERROR_MAX) in cdrom_decode_status()
382 if (rq->cmd_type != REQ_TYPE_FS) { in cdrom_decode_status()
383 rq->cmd_flags |= REQ_FAILED; in cdrom_decode_status()
401 hwif->rq = NULL; in cdrom_decode_status()
402 return ide_queue_sense_rq(drive, rq) ? 2 : 1; in cdrom_decode_status()
409 struct request *rq = cmd->rq; in ide_cd_request_sense_fixup() local
411 ide_debug_log(IDE_DBG_FUNC, "rq->cmd[0]: 0x%x", rq->cmd[0]); in ide_cd_request_sense_fixup()
417 if (rq->cmd[0] == GPCMD_REQUEST_SENSE && in ide_cd_request_sense_fixup()
441 struct request *rq; in ide_cd_queue_pc() local
444 rq = blk_get_request(drive->queue, write, __GFP_RECLAIM); in ide_cd_queue_pc()
446 memcpy(rq->cmd, cmd, BLK_MAX_CDB); in ide_cd_queue_pc()
447 rq->cmd_type = REQ_TYPE_ATA_PC; in ide_cd_queue_pc()
448 rq->sense = sense; in ide_cd_queue_pc()
449 rq->cmd_flags |= cmd_flags; in ide_cd_queue_pc()
450 rq->timeout = timeout; in ide_cd_queue_pc()
452 error = blk_rq_map_kern(drive->queue, rq, buffer, in ide_cd_queue_pc()
455 blk_put_request(rq); in ide_cd_queue_pc()
460 error = blk_execute_rq(drive->queue, info->disk, rq, 0); in ide_cd_queue_pc()
463 *bufflen = rq->resid_len; in ide_cd_queue_pc()
465 flags = rq->cmd_flags; in ide_cd_queue_pc()
466 blk_put_request(rq); in ide_cd_queue_pc()
525 struct request *rq = hwif->rq; in cdrom_newpc_intr() local
528 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0; in cdrom_newpc_intr()
529 int sense = (rq->cmd_type == REQ_TYPE_ATA_SENSE); in cdrom_newpc_intr()
534 ide_debug_log(IDE_DBG_PC, "cmd: 0x%x, write: 0x%x", rq->cmd[0], write); in cdrom_newpc_intr()
572 thislen = (rq->cmd_type == REQ_TYPE_FS) ? len : cmd->nleft; in cdrom_newpc_intr()
581 if (rq->cmd_type == REQ_TYPE_FS) { in cdrom_newpc_intr()
592 rq->cmd_flags |= REQ_FAILED; in cdrom_newpc_intr()
595 } else if (rq->cmd_type != REQ_TYPE_BLOCK_PC) { in cdrom_newpc_intr()
610 rq->cmd_flags |= REQ_FAILED; in cdrom_newpc_intr()
615 rc = ide_check_ireason(drive, rq, len, ireason, write); in cdrom_newpc_intr()
623 rq->cmd_type, ireason); in cdrom_newpc_intr()
639 rq->sense_len += blen; in cdrom_newpc_intr()
644 if (rq->cmd_type != REQ_TYPE_FS || write == 0) in cdrom_newpc_intr()
649 blk_dump_rq_flags(rq, "cdrom_newpc_intr"); in cdrom_newpc_intr()
653 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { in cdrom_newpc_intr()
654 timeout = rq->timeout; in cdrom_newpc_intr()
657 if (rq->cmd_type != REQ_TYPE_FS) in cdrom_newpc_intr()
666 if (rq->cmd_type == REQ_TYPE_BLOCK_PC && rc == 0) { in cdrom_newpc_intr()
667 rq->resid_len = 0; in cdrom_newpc_intr()
668 blk_end_request_all(rq, 0); in cdrom_newpc_intr()
669 hwif->rq = NULL; in cdrom_newpc_intr()
672 ide_cd_complete_failed_rq(drive, rq); in cdrom_newpc_intr()
674 if (rq->cmd_type == REQ_TYPE_FS) { in cdrom_newpc_intr()
678 if (uptodate <= 0 && rq->errors == 0) in cdrom_newpc_intr()
679 rq->errors = -EIO; in cdrom_newpc_intr()
682 if (uptodate == 0 && rq->bio) in cdrom_newpc_intr()
687 if (rq->cmd_type != REQ_TYPE_FS) { in cdrom_newpc_intr()
688 rq->resid_len -= cmd->nbytes - cmd->nleft; in cdrom_newpc_intr()
690 rq->resid_len += cmd->last_xfer_len; in cdrom_newpc_intr()
693 ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq)); in cdrom_newpc_intr()
701 static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) in cdrom_start_rw() argument
705 int write = rq_data_dir(rq) == WRITE; in cdrom_start_rw()
711 rq->cmd[0], rq->cmd_flags, sectors_per_frame); in cdrom_start_rw()
722 q->prep_rq_fn(q, rq); in cdrom_start_rw()
726 if ((blk_rq_sectors(rq) & (sectors_per_frame - 1)) || in cdrom_start_rw()
727 (blk_rq_pos(rq) & (sectors_per_frame - 1))) in cdrom_start_rw()
736 rq->timeout = ATAPI_WAIT_PC; in cdrom_start_rw()
741 static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) in cdrom_do_block_pc() argument
745 rq->cmd[0], rq->cmd_type); in cdrom_do_block_pc()
747 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) in cdrom_do_block_pc()
748 rq->cmd_flags |= REQ_QUIET; in cdrom_do_block_pc()
750 rq->cmd_flags &= ~REQ_FAILED; in cdrom_do_block_pc()
755 if (rq->bio) { in cdrom_do_block_pc()
757 char *buf = bio_data(rq->bio); in cdrom_do_block_pc()
770 || blk_rq_bytes(rq) & q->dma_pad_mask in cdrom_do_block_pc()
776 static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, in ide_cd_do_request() argument
784 rq->cmd[0], (unsigned long long)block); in ide_cd_do_request()
787 blk_dump_rq_flags(rq, "ide_cd_do_request"); in ide_cd_do_request()
789 switch (rq->cmd_type) { in ide_cd_do_request()
791 if (cdrom_start_rw(drive, rq) == ide_stopped) in ide_cd_do_request()
797 if (!rq->timeout) in ide_cd_do_request()
798 rq->timeout = ATAPI_WAIT_PC; in ide_cd_do_request()
800 cdrom_do_block_pc(drive, rq); in ide_cd_do_request()
811 ide_prep_sense(drive, rq); in ide_cd_do_request()
815 if (rq_data_dir(rq)) in ide_cd_do_request()
818 cmd.rq = rq; in ide_cd_do_request()
820 if (rq->cmd_type == REQ_TYPE_FS || blk_rq_bytes(rq)) { in ide_cd_do_request()
821 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); in ide_cd_do_request()
827 nsectors = blk_rq_sectors(rq); in ide_cd_do_request()
1310 static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) in ide_cdrom_prep_fs() argument
1313 long block = (long)blk_rq_pos(rq) / (hard_sect >> 9); in ide_cdrom_prep_fs()
1314 unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9); in ide_cdrom_prep_fs()
1316 memset(rq->cmd, 0, BLK_MAX_CDB); in ide_cdrom_prep_fs()
1318 if (rq_data_dir(rq) == READ) in ide_cdrom_prep_fs()
1319 rq->cmd[0] = GPCMD_READ_10; in ide_cdrom_prep_fs()
1321 rq->cmd[0] = GPCMD_WRITE_10; in ide_cdrom_prep_fs()
1326 rq->cmd[2] = (block >> 24) & 0xff; in ide_cdrom_prep_fs()
1327 rq->cmd[3] = (block >> 16) & 0xff; in ide_cdrom_prep_fs()
1328 rq->cmd[4] = (block >> 8) & 0xff; in ide_cdrom_prep_fs()
1329 rq->cmd[5] = block & 0xff; in ide_cdrom_prep_fs()
1334 rq->cmd[7] = (blocks >> 8) & 0xff; in ide_cdrom_prep_fs()
1335 rq->cmd[8] = blocks & 0xff; in ide_cdrom_prep_fs()
1336 rq->cmd_len = 10; in ide_cdrom_prep_fs()
1344 static int ide_cdrom_prep_pc(struct request *rq) in ide_cdrom_prep_pc() argument
1346 u8 *c = rq->cmd; in ide_cdrom_prep_pc()
1357 rq->cmd_len = 10; in ide_cdrom_prep_pc()
1367 rq->errors = ILLEGAL_REQUEST; in ide_cdrom_prep_pc()
1374 static int ide_cdrom_prep_fn(struct request_queue *q, struct request *rq) in ide_cdrom_prep_fn() argument
1376 if (rq->cmd_type == REQ_TYPE_FS) in ide_cdrom_prep_fn()
1377 return ide_cdrom_prep_fs(q, rq); in ide_cdrom_prep_fn()
1378 else if (rq->cmd_type == REQ_TYPE_BLOCK_PC) in ide_cdrom_prep_fn()
1379 return ide_cdrom_prep_pc(rq); in ide_cdrom_prep_fn()