Lines Matching refs:rq

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