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.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 14daf4848f09..c02c490122dc 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);
@@ -839,7 +839,14 @@ static void ata_scsi_dev_config(struct scsi_device *sdev,
839 if (dev->class == ATA_DEV_ATAPI) { 839 if (dev->class == ATA_DEV_ATAPI) {
840 struct request_queue *q = sdev->request_queue; 840 struct request_queue *q = sdev->request_queue;
841 blk_queue_max_hw_segments(q, q->max_hw_segments - 1); 841 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
842 } 842
843 /* set the min alignment */
844 blk_queue_update_dma_alignment(sdev->request_queue,
845 ATA_DMA_PAD_SZ - 1);
846 } else
847 /* ATA devices must be sector aligned */
848 blk_queue_update_dma_alignment(sdev->request_queue,
849 ATA_SECT_SIZE - 1);
843 850
844 if (dev->class == ATA_DEV_ATA) 851 if (dev->class == ATA_DEV_ATA)
845 sdev->manage_start_stop = 1; 852 sdev->manage_start_stop = 1;
@@ -878,7 +885,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
878 if (dev) 885 if (dev)
879 ata_scsi_dev_config(sdev, dev); 886 ata_scsi_dev_config(sdev, dev);
880 887
881 return 0; /* scsi layer doesn't check return value, sigh */ 888 return 0;
882} 889}
883 890
884/** 891/**
@@ -2210,7 +2217,7 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2210 2217
2211 /* sector size */ 2218 /* sector size */
2212 ATA_SCSI_RBUF_SET(6, ATA_SECT_SIZE >> 8); 2219 ATA_SCSI_RBUF_SET(6, ATA_SECT_SIZE >> 8);
2213 ATA_SCSI_RBUF_SET(7, ATA_SECT_SIZE); 2220 ATA_SCSI_RBUF_SET(7, ATA_SECT_SIZE & 0xff);
2214 } else { 2221 } else {
2215 /* sector count, 64-bit */ 2222 /* sector count, 64-bit */
2216 ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 7)); 2223 ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 7));
@@ -2224,7 +2231,7 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2224 2231
2225 /* sector size */ 2232 /* sector size */
2226 ATA_SCSI_RBUF_SET(10, ATA_SECT_SIZE >> 8); 2233 ATA_SCSI_RBUF_SET(10, ATA_SECT_SIZE >> 8);
2227 ATA_SCSI_RBUF_SET(11, ATA_SECT_SIZE); 2234 ATA_SCSI_RBUF_SET(11, ATA_SECT_SIZE & 0xff);
2228 } 2235 }
2229 2236
2230 return 0; 2237 return 0;
@@ -2331,7 +2338,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2331 DPRINTK("ATAPI request sense\n"); 2338 DPRINTK("ATAPI request sense\n");
2332 2339
2333 /* FIXME: is this needed? */ 2340 /* FIXME: is this needed? */
2334 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 2341 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
2335 2342
2336 ap->ops->tf_read(ap, &qc->tf); 2343 ap->ops->tf_read(ap, &qc->tf);
2337 2344
@@ -2341,7 +2348,9 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2341 2348
2342 ata_qc_reinit(qc); 2349 ata_qc_reinit(qc);
2343 2350
2344 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); 2351 /* setup sg table and init transfer direction */
2352 sg_init_one(&qc->sgent, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
2353 ata_sg_init(qc, &qc->sgent, 1);
2345 qc->dma_dir = DMA_FROM_DEVICE; 2354 qc->dma_dir = DMA_FROM_DEVICE;
2346 2355
2347 memset(&qc->cdb, 0, qc->dev->cdb_len); 2356 memset(&qc->cdb, 0, qc->dev->cdb_len);
@@ -2352,10 +2361,10 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2352 qc->tf.command = ATA_CMD_PACKET; 2361 qc->tf.command = ATA_CMD_PACKET;
2353 2362
2354 if (ata_pio_use_silly(ap)) { 2363 if (ata_pio_use_silly(ap)) {
2355 qc->tf.protocol = ATA_PROT_ATAPI_DMA; 2364 qc->tf.protocol = ATAPI_PROT_DMA;
2356 qc->tf.feature |= ATAPI_PKT_DMA; 2365 qc->tf.feature |= ATAPI_PKT_DMA;
2357 } else { 2366 } else {
2358 qc->tf.protocol = ATA_PROT_ATAPI; 2367 qc->tf.protocol = ATAPI_PROT_PIO;
2359 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE; 2368 qc->tf.lbam = SCSI_SENSE_BUFFERSIZE;
2360 qc->tf.lbah = 0; 2369 qc->tf.lbah = 0;
2361 } 2370 }
@@ -2526,12 +2535,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2526 if (using_pio || nodata) { 2535 if (using_pio || nodata) {
2527 /* no data, or PIO data xfer */ 2536 /* no data, or PIO data xfer */
2528 if (nodata) 2537 if (nodata)
2529 qc->tf.protocol = ATA_PROT_ATAPI_NODATA; 2538 qc->tf.protocol = ATAPI_PROT_NODATA;
2530 else 2539 else
2531 qc->tf.protocol = ATA_PROT_ATAPI; 2540 qc->tf.protocol = ATAPI_PROT_PIO;
2532 } else { 2541 } else {
2533 /* DMA data xfer */ 2542 /* DMA data xfer */
2534 qc->tf.protocol = ATA_PROT_ATAPI_DMA; 2543 qc->tf.protocol = ATAPI_PROT_DMA;
2535 qc->tf.feature |= ATAPI_PKT_DMA; 2544 qc->tf.feature |= ATAPI_PKT_DMA;
2536 2545
2537 if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE)) 2546 if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE))
@@ -2690,6 +2699,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) 2699 if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN)
2691 goto invalid_fld; 2700 goto invalid_fld;
2692 2701
2702 /*
2703 * Filter TPM commands by default. These provide an
2704 * essentially uncontrolled encrypted "back door" between
2705 * applications and the disk. Set libata.allow_tpm=1 if you
2706 * have a real reason for wanting to use them. This ensures
2707 * that installed software cannot easily mess stuff up without
2708 * user intent. DVR type users will probably ship with this enabled
2709 * for movie content management.
2710 *
2711 * Note that for ATA8 we can issue a DCS change and DCS freeze lock
2712 * for this and should do in future but that it is not sufficient as
2713 * DCS is an optional feature set. Thus we also do the software filter
2714 * so that we comply with the TC consortium stated goal that the user
2715 * can turn off TC features of their system.
2716 */
2717 if (tf->command >= 0x5C && tf->command <= 0x5F && !libata_allow_tpm)
2718 goto invalid_fld;
2719
2693 /* We may not issue DMA commands if no DMA mode is set */ 2720 /* We may not issue DMA commands if no DMA mode is set */
2694 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) 2721 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2695 goto invalid_fld; 2722 goto invalid_fld;