dma-direct: always align allocation size in dma_direct_alloc_pages()
authorDavid Rientjes <rientjes@google.com>
Thu, 11 Jun 2020 19:20:28 +0000 (12:20 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 17 Jun 2020 07:29:38 +0000 (09:29 +0200)
commit633d5fce78a61e8727674467944939f55b0bcfab
treedabc0f82a9fdd62067b6d22b7d49eaeb4bd1bacf
parent26749b3201ab05e288fbf78fbc8585dfa2da3218
dma-direct: always align allocation size in dma_direct_alloc_pages()

dma_alloc_contiguous() does size >> PAGE_SHIFT and set_memory_decrypted()
works at page granularity.  It's necessary to page align the allocation
size in dma_direct_alloc_pages() for consistent behavior.

This also fixes an issue when arch_dma_prep_coherent() is called on an
unaligned allocation size for dma_alloc_need_uncached() when
CONFIG_DMA_DIRECT_REMAP is disabled but CONFIG_ARCH_HAS_DMA_SET_UNCACHED
is enabled.

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/direct.c