libata: implement ata_qc_raw_nbytes()

Implement ata_qc_raw_nbytes() which determines the raw user-requested
size of a PC command.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik aacda375 cc7feea3

+18 -4
+11 -3
drivers/ata/libata-scsi.c
··· 527 return qc; 528 } 529 530 /** 531 * ata_dump_status - user friendly display of error info 532 * @id: id of the port in question ··· 2547 } 2548 2549 qc->tf.command = ATA_CMD_PACKET; 2550 - qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2551 2552 /* check whether ATAPI DMA is safe */ 2553 if (!using_pio && ata_check_atapi_dma(qc)) ··· 2558 * want to set it properly, and for DMA where it is 2559 * effectively meaningless. 2560 */ 2561 - nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024); 2562 2563 /* Most ATAPI devices which honor transfer chunk size don't 2564 * behave according to the spec when odd chunk size which ··· 2884 * TODO: find out if we need to do more here to 2885 * cover scatter/gather case. 2886 */ 2887 - qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2888 2889 /* request result TF and be quiet about device error */ 2890 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
··· 527 return qc; 528 } 529 530 + static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc) 531 + { 532 + struct scsi_cmnd *scmd = qc->scsicmd; 533 + 534 + qc->extrabytes = scmd->request->extra_len; 535 + qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes; 536 + } 537 + 538 /** 539 * ata_dump_status - user friendly display of error info 540 * @id: id of the port in question ··· 2539 } 2540 2541 qc->tf.command = ATA_CMD_PACKET; 2542 + ata_qc_set_pc_nbytes(qc); 2543 2544 /* check whether ATAPI DMA is safe */ 2545 if (!using_pio && ata_check_atapi_dma(qc)) ··· 2550 * want to set it properly, and for DMA where it is 2551 * effectively meaningless. 2552 */ 2553 + nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); 2554 2555 /* Most ATAPI devices which honor transfer chunk size don't 2556 * behave according to the spec when odd chunk size which ··· 2876 * TODO: find out if we need to do more here to 2877 * cover scatter/gather case. 2878 */ 2879 + ata_qc_set_pc_nbytes(qc); 2880 2881 /* request result TF and be quiet about device error */ 2882 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
+7 -1
include/linux/libata.h
··· 463 unsigned int sect_size; 464 465 unsigned int nbytes; 466 unsigned int curbytes; 467 468 struct scatterlist *cursg; ··· 1337 return NULL; 1338 } 1339 1340 static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) 1341 { 1342 memset(tf, 0, sizeof(*tf)); ··· 1360 qc->flags = 0; 1361 qc->cursg = NULL; 1362 qc->cursg_ofs = 0; 1363 - qc->nbytes = qc->curbytes = 0; 1364 qc->n_elem = 0; 1365 qc->err_mask = 0; 1366 qc->sect_size = ATA_SECT_SIZE;
··· 463 unsigned int sect_size; 464 465 unsigned int nbytes; 466 + unsigned int extrabytes; 467 unsigned int curbytes; 468 469 struct scatterlist *cursg; ··· 1336 return NULL; 1337 } 1338 1339 + static inline unsigned int ata_qc_raw_nbytes(struct ata_queued_cmd *qc) 1340 + { 1341 + return qc->nbytes - min(qc->extrabytes, qc->nbytes); 1342 + } 1343 + 1344 static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) 1345 { 1346 memset(tf, 0, sizeof(*tf)); ··· 1354 qc->flags = 0; 1355 qc->cursg = NULL; 1356 qc->cursg_ofs = 0; 1357 + qc->nbytes = qc->extrabytes = qc->curbytes = 0; 1358 qc->n_elem = 0; 1359 qc->err_mask = 0; 1360 qc->sect_size = ATA_SECT_SIZE;