2 * Copyright (C) STMicroelectronics SA 2015
3 * Authors: Yannick Fertre <yannick.fertre@st.com>
4 * Hugues Fruchet <hugues.fruchet@st.com>
5 * License terms: GNU General Public License (GPL), version 2
11 int hva_mem_alloc(struct hva_ctx *ctx, u32 size, const char *name,
12 struct hva_buffer **buf)
14 struct device *dev = ctx_to_dev(ctx);
19 b = devm_kzalloc(dev, sizeof(*b), GFP_KERNEL);
23 base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
24 DMA_ATTR_WRITE_COMBINE);
26 dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n",
27 ctx->name, __func__, name, size);
38 "%s allocate %d bytes of HW memory @(virt=%p, phy=%pad): %s\n",
39 ctx->name, size, b->vaddr, &b->paddr, b->name);
41 /* return hva buffer to user */
47 void hva_mem_free(struct hva_ctx *ctx, struct hva_buffer *buf)
49 struct device *dev = ctx_to_dev(ctx);
52 "%s free %d bytes of HW memory @(virt=%p, phy=%pad): %s\n",
53 ctx->name, buf->size, buf->vaddr, &buf->paddr, buf->name);
55 dma_free_attrs(dev, buf->size, buf->vaddr, buf->paddr,
56 DMA_ATTR_WRITE_COMBINE);