Skip to content

Commit

Permalink
Merge tag 'dma-mapping-5.3-3' of git://git.infradead.org/users/hch/dm…
Browse files Browse the repository at this point in the history
…a-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()
  • Loading branch information
Linus Torvalds committed Aug 2, 2019
2 parents 1e78030 + f46cc01 commit 35fca9f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/dma/contiguous.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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));
}

Expand Down

0 comments on commit 35fca9f

Please sign in to comment.