diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-02-19 05:36:56 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-02-19 05:36:56 -0500 |
commit | dde2020754aeb14e17052d61784dcb37f252aac2 (patch) | |
tree | 1b6d57c6eff2024fd13e4b3b115d0a6770d8cb80 /drivers/ata/libata-scsi.c | |
parent | db0a2e0099be3a1cff55879225881465f16c67d3 (diff) |
libata: eliminate the home grown dma padding in favour of
that provided by the block layer
ATA requires that all DMA transfers begin and end on word boundaries.
Because of this, a large amount of machinery grew up in ide to adjust
scatterlists on this basis. However, as of 2.5, the block layer has a
dma_alignment variable which ensures both the beginning and length of a
DMA transfer are aligned on the dma_alignment boundary. Although the
block layer does adjust the beginning of the transfer to ensure this
happens, it doesn't actually adjust the length, it merely makes sure
that space is allocated for transfers beyond the declared length. The
upshot of this is that scatterlists may be padded to any size between
the actual length and the length adjusted to the dma_alignment safely
knowing that memory is allocated in this region.
Right at the moment, SCSI takes the default dma_aligment which is on a
512 byte boundary. Note that this aligment only applies to transfers
coming in from user space. However, since all kernel allocations are
automatically aligned on a minimum of 32 byte boundaries, it is safe to
adjust them in this manner as well.
tj: * Adjusting sg after padding is done in block layer. Make libata
set queue alignment correctly for ATAPI devices and drop broken
sg mangling from ata_sg_setup().
* Use request->raw_data_len for ATAPI transfer chunk size.
* Killed qc->raw_nbytes.
* Separated out killing qc->n_iter.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r-- | drivers/ata/libata-scsi.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 1cea18f62abc..6e15c5ddae6d 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -832,24 +832,16 @@ static void ata_scsi_dev_config(struct scsi_device *sdev, | |||
832 | /* configure max sectors */ | 832 | /* configure max sectors */ |
833 | blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); | 833 | blk_queue_max_sectors(sdev->request_queue, dev->max_sectors); |
834 | 834 | ||
835 | /* SATA DMA transfers must be multiples of 4 byte, so | 835 | if (dev->class == ATA_DEV_ATAPI) |
836 | * we need to pad ATAPI transfers using an extra sg. | ||
837 | * Decrement max hw segments accordingly. | ||
838 | */ | ||
839 | if (dev->class == ATA_DEV_ATAPI) { | ||
840 | struct request_queue *q = sdev->request_queue; | ||
841 | blk_queue_max_hw_segments(q, q->max_hw_segments - 1); | ||
842 | |||
843 | /* set the min alignment */ | 836 | /* set the min alignment */ |
844 | blk_queue_update_dma_alignment(sdev->request_queue, | 837 | blk_queue_update_dma_alignment(sdev->request_queue, |
845 | ATA_DMA_PAD_SZ - 1); | 838 | ATA_DMA_PAD_SZ - 1); |
846 | } else | 839 | else { |
847 | /* ATA devices must be sector aligned */ | 840 | /* ATA devices must be sector aligned */ |
848 | blk_queue_update_dma_alignment(sdev->request_queue, | 841 | blk_queue_update_dma_alignment(sdev->request_queue, |
849 | ATA_SECT_SIZE - 1); | 842 | ATA_SECT_SIZE - 1); |
850 | |||
851 | if (dev->class == ATA_DEV_ATA) | ||
852 | sdev->manage_start_stop = 1; | 843 | sdev->manage_start_stop = 1; |
844 | } | ||
853 | 845 | ||
854 | if (dev->flags & ATA_DFLAG_AN) | 846 | if (dev->flags & ATA_DFLAG_AN) |
855 | set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events); | 847 | set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events); |
@@ -2500,7 +2492,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) | |||
2500 | * want to set it properly, and for DMA where it is | 2492 | * want to set it properly, and for DMA where it is |
2501 | * effectively meaningless. | 2493 | * effectively meaningless. |
2502 | */ | 2494 | */ |
2503 | nbytes = min(qc->nbytes, (unsigned int)63 * 1024); | 2495 | nbytes = min(scmd->request->raw_data_len, (unsigned int)63 * 1024); |
2504 | 2496 | ||
2505 | /* Most ATAPI devices which honor transfer chunk size don't | 2497 | /* Most ATAPI devices which honor transfer chunk size don't |
2506 | * behave according to the spec when odd chunk size which | 2498 | * behave according to the spec when odd chunk size which |
@@ -3555,7 +3547,7 @@ EXPORT_SYMBOL_GPL(ata_sas_port_alloc); | |||
3555 | * @ap: Port to initialize | 3547 | * @ap: Port to initialize |
3556 | * | 3548 | * |
3557 | * Called just after data structures for each port are | 3549 | * Called just after data structures for each port are |
3558 | * initialized. Allocates DMA pad. | 3550 | * initialized. |
3559 | * | 3551 | * |
3560 | * May be used as the port_start() entry in ata_port_operations. | 3552 | * May be used as the port_start() entry in ata_port_operations. |
3561 | * | 3553 | * |
@@ -3564,7 +3556,7 @@ EXPORT_SYMBOL_GPL(ata_sas_port_alloc); | |||
3564 | */ | 3556 | */ |
3565 | int ata_sas_port_start(struct ata_port *ap) | 3557 | int ata_sas_port_start(struct ata_port *ap) |
3566 | { | 3558 | { |
3567 | return ata_pad_alloc(ap, ap->dev); | 3559 | return 0; |
3568 | } | 3560 | } |
3569 | EXPORT_SYMBOL_GPL(ata_sas_port_start); | 3561 | EXPORT_SYMBOL_GPL(ata_sas_port_start); |
3570 | 3562 | ||
@@ -3572,8 +3564,6 @@ EXPORT_SYMBOL_GPL(ata_sas_port_start); | |||
3572 | * ata_port_stop - Undo ata_sas_port_start() | 3564 | * ata_port_stop - Undo ata_sas_port_start() |
3573 | * @ap: Port to shut down | 3565 | * @ap: Port to shut down |
3574 | * | 3566 | * |
3575 | * Frees the DMA pad. | ||
3576 | * | ||
3577 | * May be used as the port_stop() entry in ata_port_operations. | 3567 | * May be used as the port_stop() entry in ata_port_operations. |
3578 | * | 3568 | * |
3579 | * LOCKING: | 3569 | * LOCKING: |
@@ -3582,7 +3572,6 @@ EXPORT_SYMBOL_GPL(ata_sas_port_start); | |||
3582 | 3572 | ||
3583 | void ata_sas_port_stop(struct ata_port *ap) | 3573 | void ata_sas_port_stop(struct ata_port *ap) |
3584 | { | 3574 | { |
3585 | ata_pad_free(ap, ap->dev); | ||
3586 | } | 3575 | } |
3587 | EXPORT_SYMBOL_GPL(ata_sas_port_stop); | 3576 | EXPORT_SYMBOL_GPL(ata_sas_port_stop); |
3588 | 3577 | ||