summaryrefslogtreecommitdiffstats
path: root/drivers/parisc
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-01-04 16:25:34 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-04 16:25:34 +0100
commit7e935c7ca1e6c398f11edac5beabfc4348e3b3a4 (patch)
tree86da864ba6341bd86b5f5450c611f918722237b2 /drivers/parisc
parent[mips] switch pvc_proc_cleanup() to remove_proc_subtree() (diff)
parentnew helper: memdup_user_nul() (diff)
downloadlinux-7e935c7ca1e6c398f11edac5beabfc4348e3b3a4.tar.xz
linux-7e935c7ca1e6c398f11edac5beabfc4348e3b3a4.zip
Merge branch 'memdup_user_nul' into work.misc
Diffstat (limited to 'drivers/parisc')
-rw-r--r--drivers/parisc/iommu-helpers.h15
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,
struct scatterlist *contig_sg; /* contig chunk head */
unsigned long dma_offset, dma_len; /* start/len of DMA stream */
unsigned int n_mappings = 0;
- unsigned int max_seg_size = dma_get_max_seg_size(dev);
+ unsigned int max_seg_size = min(dma_get_max_seg_size(dev),
+ (unsigned)DMA_CHUNK_SIZE);
+ unsigned int max_seg_boundary = dma_get_seg_boundary(dev) + 1;
+ if (max_seg_boundary) /* check if the addition above didn't overflow */
+ max_seg_size = min(max_seg_size, max_seg_boundary);
while (nents > 0) {
@@ -138,14 +142,11 @@ iommu_coalesce_chunks(struct ioc *ioc, struct device *dev,
/*
** First make sure current dma stream won't
- ** exceed DMA_CHUNK_SIZE if we coalesce the
+ ** exceed max_seg_size if we coalesce the
** next entry.
*/
- if(unlikely(ALIGN(dma_len + dma_offset + startsg->length,
- IOVP_SIZE) > DMA_CHUNK_SIZE))
- break;
-
- if (startsg->length + dma_len > max_seg_size)
+ if (unlikely(ALIGN(dma_len + dma_offset + startsg->length, IOVP_SIZE) >
+ max_seg_size))
break;
/*