The patch titled Subject: dma-mapping: tidy up dma_parms default handling has been added to the -mm tree. Its filename is dma-mapping-tidy-up-dma_parms-default-handling.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/dma-mapping-tidy-up-dma_parms-default-handling.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/dma-mapping-tidy-up-dma_parms-default-handling.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Robin Murphy <robin.murphy@xxxxxxx> Subject: dma-mapping: tidy up dma_parms default handling Many DMA controllers and other devices set max_segment_size to indicate their scatter-gather capability, but have no interest in segment_boundary_mask. However, the existence of a dma_parms structure precludes the use of any default value, leaving them as zeros (assuming a properly kzalloc'ed structure). If a well-behaved IOMMU (or SWIOTLB) then tries to respect this by ensuring a mapped segment does not cross a zero-byte boundary, hilarity ensues. Since zero is a nonsensical value for either parameter, treat it as an indicator for "default", as might be expected. In the process, clean up a bit by replacing the bare constants with slightly more meaningful macros and removing the superfluous "else" statements. Signed-off-by: Robin Murphy <robin.murphy@xxxxxxx> Reviewed-by: Sumit Semwal <sumit.semwal@xxxxxxxxxx> Acked-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Sakari Ailus <sakari.ailus@xxxxxx> Cc: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/dma-mapping.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff -puN include/linux/dma-mapping.h~dma-mapping-tidy-up-dma_parms-default-handling include/linux/dma-mapping.h --- a/include/linux/dma-mapping.h~dma-mapping-tidy-up-dma_parms-default-handling +++ a/include/linux/dma-mapping.h @@ -145,7 +145,9 @@ static inline void arch_teardown_dma_ops static inline unsigned int dma_get_max_seg_size(struct device *dev) { - return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536; + if (dev->dma_parms && dev->dma_parms->max_segment_size) + return dev->dma_parms->max_segment_size; + return SZ_64K; } static inline unsigned int dma_set_max_seg_size(struct device *dev, @@ -154,14 +156,15 @@ static inline unsigned int dma_set_max_s if (dev->dma_parms) { dev->dma_parms->max_segment_size = size; return 0; - } else - return -EIO; + } + return -EIO; } static inline unsigned long dma_get_seg_boundary(struct device *dev) { - return dev->dma_parms ? - dev->dma_parms->segment_boundary_mask : 0xffffffff; + if (dev->dma_parms && dev->dma_parms->segment_boundary_mask) + return dev->dma_parms->segment_boundary_mask; + return DMA_BIT_MASK(32); } static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) @@ -169,8 +172,8 @@ static inline int dma_set_seg_boundary(s if (dev->dma_parms) { dev->dma_parms->segment_boundary_mask = mask; return 0; - } else - return -EIO; + } + return -EIO; } #ifndef dma_max_pfn _ Patches currently in -mm which might be from robin.murphy@xxxxxxx are dmapool-fix-overflow-condition-in-pool_find_page.patch dma-mapping-tidy-up-dma_parms-default-handling.patch dma-debug-check-nents-in-dma_sync_sg.patch dma-debug-allow-poisoning-nonzero-allocations.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html