aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r--drivers/ata/libata-scsi.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 14daf4848f09..3fd08201bef4 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -517,7 +517,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
517 qc->scsicmd = cmd; 517 qc->scsicmd = cmd;
518 qc->scsidone = done; 518 qc->scsidone = done;
519 519
520 qc->__sg = scsi_sglist(cmd); 520 qc->sg = scsi_sglist(cmd);
521 qc->n_elem = scsi_sg_count(cmd); 521 qc->n_elem = scsi_sg_count(cmd);
522 } else { 522 } else {
523 cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); 523 cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);
@@ -2210,7 +2210,7 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2210 2210
2211 /* sector size */ 2211 /* sector size */
2212 ATA_SCSI_RBUF_SET(6, ATA_SECT_SIZE >> 8); 2212 ATA_SCSI_RBUF_SET(6, ATA_SECT_SIZE >> 8);
2213 ATA_SCSI_RBUF_SET(7, ATA_SECT_SIZE); 2213 ATA_SCSI_RBUF_SET(7, ATA_SECT_SIZE & 0xff);
2214 } else { 2214 } else {
2215 /* sector count, 64-bit */ 2215 /* sector count, 64-bit */
2216 ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 7)); 2216 ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 7));
@@ -2224,7 +2224,7 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2224 2224
2225 /* sector size */ 2225 /* sector size */
2226 ATA_SCSI_RBUF_SET(10, ATA_SECT_SIZE >> 8); 2226 ATA_SCSI_RBUF_SET(10, ATA_SECT_SIZE >> 8);
2227 ATA_SCSI_RBUF_SET(11, ATA_SECT_SIZE); 2227 ATA_SCSI_RBUF_SET(11, ATA_SECT_SIZE & 0xff);
2228 } 2228 }
2229 2229
2230 return 0; 2230 return 0;
@@ -2331,7 +2331,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2331 DPRINTK("ATAPI request sense\n"); 2331 DPRINTK("ATAPI request sense\n");
2332 2332
2333 /* FIXME: is this needed? */ 2333 /* FIXME: is this needed? */
2334 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 2334 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
2335 2335
2336 ap->ops->tf_read(ap, &qc->tf); 2336 ap->ops->tf_read(ap, &qc->tf);
2337 2337
@@ -2341,7 +2341,9 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2341 2341
2342 ata_qc_reinit(qc); 2342 ata_qc_reinit(qc);
2343 2343
2344 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); 2344 /* setup sg table and init transfer direction */
2345 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
2346 ata_sg_init(qc, &qc->sgent, 1);
2345 qc->dma_dir = DMA_FROM_DEVICE; 2347 qc->dma_dir = DMA_FROM_DEVICE;
2346 2348
2347 memset(&qc->cdb, 0, qc->dev->cdb_len); 2349 memset(&qc->cdb, 0, qc->dev->cdb_len);
@@ -2352,10 +2354,10 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2352 qc->tf.command = ATA_CMD_PACKET; 2354 qc->tf.command = ATA_CMD_PACKET;
2353 2355
2354 if (ata_pio_use_silly(ap)) { 2356 if (ata_pio_use_silly(ap)) {
2355 qc->tf.protocol = ATA_PROT_ATAPI_DMA; 2357 qc->tf.protocol = ATAPI_PROT_DMA;
2356 qc->tf.feature |= ATAPI_PKT_DMA; 2358 qc->tf.feature |= ATAPI_PKT_DMA;
2357 } else { 2359 } else {
2358 qc->tf.protocol = ATA_PROT_ATAPI; 2360 qc->tf.protocol = ATAPI_PROT_PIO;
2359 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; 2361 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE;
2360 qc->tf.lbah = 0; 2362 qc->tf.lbah = 0;
2361 } 2363 }
@@ -2526,12 +2528,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2526 if (using_pio || nodata) { 2528 if (using_pio || nodata) {
2527 /* no data, or PIO data xfer */ 2529 /* no data, or PIO data xfer */
2528 if (nodata) 2530 if (nodata)
2529 qc->tf.protocol = ATA_PROT_ATAPI_NODATA; 2531 qc->tf.protocol = ATAPI_PROT_NODATA;
2530 else 2532 else
2531 qc->tf.protocol = ATA_PROT_ATAPI; 2533 qc->tf.protocol = ATAPI_PROT_PIO;
2532 } else { 2534 } else {
2533 /* DMA data xfer */ 2535 /* DMA data xfer */
2534 qc->tf.protocol = ATA_PROT_ATAPI_DMA; 2536 qc->tf.protocol = ATAPI_PROT_DMA;
2535 qc->tf.feature |= ATAPI_PKT_DMA; 2537 qc->tf.feature |= ATAPI_PKT_DMA;
2536 2538
2537 if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE)) 2539 if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE))
@@ -2690,6 +2692,24 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2690 if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN) 2692 if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN)
2691 goto invalid_fld; 2693 goto invalid_fld;
2692 2694
2695 /*
2696 * Filter TPM commands by default. These provide an
2697 * essentially uncontrolled encrypted "back door" between
2698 * applications and the disk. Set libata.allow_tpm=1 if you
2699 * have a real reason for wanting to use them. This ensures
2700 * that installed software cannot easily mess stuff up without
2701 * user intent. DVR type users will probably ship with this enabled
2702 * for movie content management.
2703 *
2704 * Note that for ATA8 we can issue a DCS change and DCS freeze lock
2705 * for this and should do in future but that it is not sufficient as
2706 * DCS is an optional feature set. Thus we also do the software filter
2707 * so that we comply with the TC consortium stated goal that the user
2708 * can turn off TC features of their system.
2709 */
2710 if (tf->command >= 0x5C && tf->command <= 0x5F && !libata_allow_tpm)
2711 goto invalid_fld;
2712
2693 /* We may not issue DMA commands if no DMA mode is set */ 2713 /* We may not issue DMA commands if no DMA mode is set */
2694 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) 2714 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2695 goto invalid_fld; 2715 goto invalid_fld;