Commit 520bf00f authored by James Bottomley's avatar James Bottomley Committed by James Bottomley

scsi: scatter gather alignment constraints

Make sg and st respect any block alignment
constraints for the data.  Usb storage already
sets these to what it needs.

Also reset the default to 7 for other SCSI devices.
parent 2a80ee36
...@@ -1284,6 +1284,15 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) ...@@ -1284,6 +1284,15 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
blk_queue_max_sectors(q, shost->max_sectors); blk_queue_max_sectors(q, shost->max_sectors);
blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
blk_queue_segment_boundary(q, shost->dma_boundary); blk_queue_segment_boundary(q, shost->dma_boundary);
/*
* Set the queue's mask to require a mere 8-byte alignment for
* DMA buffers, rather than the default 512. This shouldn't
* inconvenience any user programs and should be okay for most
* host adapters. A host driver can alter this mask in its
* slave_alloc() or slave_configure() callback if necessary.
*/
blk_queue_dma_alignment(q, (8 - 1));
if (!shost->use_clustering) if (!shost->use_clustering)
clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
......
...@@ -1797,7 +1797,11 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len) ...@@ -1797,7 +1797,11 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len)
int sg_tablesize = sfp->parentdp->sg_tablesize; int sg_tablesize = sfp->parentdp->sg_tablesize;
struct scatterlist *sgl; struct scatterlist *sgl;
int mx_sc_elems, res; int mx_sc_elems, res;
struct scsi_device *sdev = sfp->parentdp->device;
if (((unsigned long)hp->dxferp &
queue_dma_alignment(sdev->request_queue)) != 0)
return 1;
mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize);
if (mx_sc_elems <= 0) { if (mx_sc_elems <= 0) {
return 1; return 1;
......
...@@ -1272,7 +1272,8 @@ static int setup_buffering(Scsi_Tape *STp, const char *buf, size_t count, int is ...@@ -1272,7 +1272,8 @@ static int setup_buffering(Scsi_Tape *STp, const char *buf, size_t count, int is
i = STp->try_dio && try_rdio; i = STp->try_dio && try_rdio;
else else
i = STp->try_dio && try_wdio; i = STp->try_dio && try_wdio;
if (i) { if (i && ((unsigned long)buf & queue_dma_alignment(
STp->device->request_queue)) == 0) {
i = st_map_user_pages(&(STbp->sg[0]), STbp->use_sg, i = st_map_user_pages(&(STbp->sg[0]), STbp->use_sg,
(unsigned long)buf, count, (is_read ? READ : WRITE), (unsigned long)buf, count, (is_read ? READ : WRITE),
STp->max_pfn); STp->max_pfn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment