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);
25 base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
26 DMA_ATTR_WRITE_COMBINE);
28 dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n",
29 ctx->name, __func__, name, size);
41 "%s allocate %d bytes of HW memory @(virt=%p, phy=%pad): %s\n",
42 ctx->name, size, b->vaddr, &b->paddr, b->name);
44 /* return hva buffer to user */
50 void hva_mem_free(struct hva_ctx *ctx, struct hva_buffer *buf)
52 struct device *dev = ctx_to_dev(ctx);
55 "%s free %d bytes of HW memory @(virt=%p, phy=%pad): %s\n",
56 ctx->name, buf->size, buf->vaddr, &buf->paddr, buf->name);
58 dma_free_attrs(dev, buf->size, buf->vaddr, buf->paddr,
59 DMA_ATTR_WRITE_COMBINE);