Commit 35fca9f8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'dma-mapping-5.3-3' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping regression fixes from Christoph Hellwig:
 "Two related regression fixes for changes from this merge window to fix
  alignment issues introduced in the CMA allocation rework (Nicolin
  Chen)"

* tag 'dma-mapping-5.3-3' of git://git.infradead.org/users/hch/dma-mapping:
  dma-contiguous: page-align the size in dma_free_contiguous()
  dma-contiguous: do not overwrite align in dma_alloc_contiguous()
parents 1e78030e f46cc015
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -243,8 +243,9 @@ struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp)

	/* CMA can be used only in the context which permits sleeping */
	if (cma && gfpflags_allow_blocking(gfp)) {
		align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT);
		page = cma_alloc(cma, count, align, gfp & __GFP_NOWARN);
		size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT);

		page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN);
	}

	/* Fallback allocation of normal pages */
@@ -266,7 +267,8 @@ struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp)
 */
void dma_free_contiguous(struct device *dev, struct page *page, size_t size)
{
	if (!cma_release(dev_get_cma_area(dev), page, size >> PAGE_SHIFT))
	if (!cma_release(dev_get_cma_area(dev), page,
			 PAGE_ALIGN(size) >> PAGE_SHIFT))
		__free_pages(page, get_order(size));
}