]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] relax scsi dma alignment
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Tue, 1 Jan 2008 16:00:10 +0000 (10:00 -0600)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Sat, 12 Jan 2008 00:29:22 +0000 (18:29 -0600)
This patch relaxes the default SCSI DMA alignment from 512 bytes to 4
bytes.  I remember from previous discussions that usb and firewire have
sector size alignment requirements, so I upped their alignments in the
respective slave allocs.

The reason for doing this is so that we don't get such a huge amount of
copy overhead in bio_copy_user() for udev.  (basically all inquiries it
issues can now be directly mapped).

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/ata/libata-scsi.c
drivers/firewire/fw-sbp2.c
drivers/ieee1394/sbp2.c
drivers/scsi/scsi_lib.c
drivers/usb/storage/scsiglue.c

index 264ae60e3fd8ae1a7e5ccb583545b1f6e6eac958..4bb268b9aaeb524baf7d1465f6f1d84f8c6c660e 100644 (file)
@@ -824,6 +824,9 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
         * requests.
         */
        sdev->max_device_blocked = 1;
+
+       /* set the min alignment */
+       blk_queue_update_dma_alignment(sdev->request_queue, ATA_DMA_PAD_SZ - 1);
 }
 
 static void ata_scsi_dev_config(struct scsi_device *sdev,
@@ -878,7 +881,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
        if (dev)
                ata_scsi_dev_config(sdev, dev);
 
-       return 0;       /* scsi layer doesn't check return value, sigh */
+       return 0;
 }
 
 /**
index 624ff3e082f68116f4efe158c80fcdd0c7f27a74..c2169d215bf7473d3fa2a983bd3852b8ab329a24 100644 (file)
@@ -1238,6 +1238,12 @@ static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
 
        sdev->allow_restart = 1;
 
+       /*
+        * Update the dma alignment (minimum alignment requirements for
+        * start and end of DMA transfers) to be a sector
+        */
+       blk_queue_update_dma_alignment(sdev->request_queue, 511);
+
        if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
                sdev->inquiry_len = 36;
 
index b83d254bc86edec605f1f78ba510a59566f2baef..1eda11abeb1e0b3cb912cb7e0c9bcac196b79810 100644 (file)
@@ -1963,6 +1963,12 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
        lu->sdev = sdev;
        sdev->allow_restart = 1;
 
+       /*
+        * Update the dma alignment (minimum alignment requirements for
+        * start and end of DMA transfers) to be a sector
+        */
+       blk_queue_update_dma_alignment(sdev->request_queue, 511);
+
        if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)
                sdev->inquiry_len = 36;
        return 0;
index db52222885b76f2267bf5ff3e22978843951885c..de601370c05b0a76ad5e8ddfedf4839259efb20c 100644 (file)
@@ -1668,6 +1668,14 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
 
        if (!shost->use_clustering)
                clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
+
+       /*
+        * set a reasonable default alignment on word boundaries: the
+        * host and device may alter it using
+        * blk_queue_update_dma_alignment() later.
+        */
+       blk_queue_dma_alignment(q, 0x03);
+
        return q;
 }
 EXPORT_SYMBOL(__scsi_alloc_queue);
index 7c9593b7b04e27da6c21577c18e6c3f907206f07..dd8b13ef2414b5996426cfe0989bb306ec114caa 100644 (file)
@@ -81,6 +81,16 @@ static int slave_alloc (struct scsi_device *sdev)
         */
        sdev->inquiry_len = 36;
 
+       /* Scatter-gather buffers (all but the last) must have a length
+        * divisible by the bulk maxpacket size.  Otherwise a data packet
+        * would end up being short, causing a premature end to the data
+        * transfer.  Since high-speed bulk pipes have a maxpacket size
+        * of 512, we'll use that as the scsi device queue's DMA alignment
+        * mask.  Guaranteeing proper alignment of the first buffer will
+        * have the desired effect because, except at the beginning and
+        * the end, scatter-gather buffers follow page boundaries. */
+       blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
+
        /*
         * The UFI spec treates the Peripheral Qualifier bits in an
         * INQUIRY result as reserved and requires devices to set them
@@ -100,16 +110,6 @@ static int slave_configure(struct scsi_device *sdev)
 {
        struct us_data *us = host_to_us(sdev->host);
 
-       /* Scatter-gather buffers (all but the last) must have a length
-        * divisible by the bulk maxpacket size.  Otherwise a data packet
-        * would end up being short, causing a premature end to the data
-        * transfer.  Since high-speed bulk pipes have a maxpacket size
-        * of 512, we'll use that as the scsi device queue's DMA alignment
-        * mask.  Guaranteeing proper alignment of the first buffer will
-        * have the desired effect because, except at the beginning and
-        * the end, scatter-gather buffers follow page boundaries. */
-       blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
-
        /* Many devices have trouble transfering more than 32KB at a time,
         * while others have trouble with more than 64K. At this time we
         * are limiting both to 32K (64 sectores).