Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dma-mapping: reduce dma_mapping_error inline bloat

Thanks to the nested inlining, all drivers correctly calling
dma_mapping_error() after a mapping a page or single buffer generate two
calls to get_arch_dma_ops() per callsite, which all adds up to a fair
old chunk of useless code, e.g. ~3KB for an arm64 defconfig plus extras:

text data bss dec hex filename
13051391 1503898 327768 14883057 e318f1 vmlinux.o.old
13050751 1503898 327768 14882417 e31671 vmlinux.o.new

Give the compiler a hand by making it clear we want the same ops.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

Robin Murphy and committed by
Christoph Hellwig
5237e95f ee7b1f31

+4 -3
+4 -3
include/linux/dma-mapping.h
··· 565 565 566 566 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 567 567 { 568 - debug_dma_mapping_error(dev, dma_addr); 568 + const struct dma_map_ops *ops = get_dma_ops(dev); 569 569 570 - if (get_dma_ops(dev)->mapping_error) 571 - return get_dma_ops(dev)->mapping_error(dev, dma_addr); 570 + debug_dma_mapping_error(dev, dma_addr); 571 + if (ops->mapping_error) 572 + return ops->mapping_error(dev, dma_addr); 572 573 return 0; 573 574 } 574 575