diff options
Diffstat (limited to 'drivers/parisc')
-rw-r--r-- | drivers/parisc/iommu-helpers.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/parisc/iommu-helpers.h b/drivers/parisc/iommu-helpers.h index 761e77bfce5d..e56f1569f6c3 100644 --- a/drivers/parisc/iommu-helpers.h +++ b/drivers/parisc/iommu-helpers.h | |||
@@ -104,7 +104,11 @@ iommu_coalesce_chunks(struct ioc *ioc, struct device *dev, | |||
104 | struct scatterlist *contig_sg; /* contig chunk head */ | 104 | struct scatterlist *contig_sg; /* contig chunk head */ |
105 | unsigned long dma_offset, dma_len; /* start/len of DMA stream */ | 105 | unsigned long dma_offset, dma_len; /* start/len of DMA stream */ |
106 | unsigned int n_mappings = 0; | 106 | unsigned int n_mappings = 0; |
107 | unsigned int max_seg_size = dma_get_max_seg_size(dev); | 107 | unsigned int max_seg_size = min(dma_get_max_seg_size(dev), |
108 | (unsigned)DMA_CHUNK_SIZE); | ||
109 | unsigned int max_seg_boundary = dma_get_seg_boundary(dev) + 1; | ||
110 | if (max_seg_boundary) /* check if the addition above didn't overflow */ | ||
111 | max_seg_size = min(max_seg_size, max_seg_boundary); | ||
108 | 112 | ||
109 | while (nents > 0) { | 113 | while (nents > 0) { |
110 | 114 | ||
@@ -138,14 +142,11 @@ iommu_coalesce_chunks(struct ioc *ioc, struct device *dev, | |||
138 | 142 | ||
139 | /* | 143 | /* |
140 | ** First make sure current dma stream won't | 144 | ** First make sure current dma stream won't |
141 | ** exceed DMA_CHUNK_SIZE if we coalesce the | 145 | ** exceed max_seg_size if we coalesce the |
142 | ** next entry. | 146 | ** next entry. |
143 | */ | 147 | */ |
144 | if(unlikely(ALIGN(dma_len + dma_offset + startsg->length, | 148 | if (unlikely(ALIGN(dma_len + dma_offset + startsg->length, IOVP_SIZE) > |
145 | IOVP_SIZE) > DMA_CHUNK_SIZE)) | 149 | max_seg_size)) |
146 | break; | ||
147 | |||
148 | if (startsg->length + dma_len > max_seg_size) | ||
149 | break; | 150 | break; |
150 | 151 | ||
151 | /* | 152 | /* |