perf tools: Don't clone maps from parent when synthesizing forks
[linux/fpc-iii.git] / drivers / media / platform / sti / delta / delta-mem.c
blobaeccd50583da87862786dcd2c89b683e062367e7
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) STMicroelectronics SA 2015
4 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
5 */
7 #include "delta.h"
8 #include "delta-mem.h"
10 int hw_alloc(struct delta_ctx *ctx, u32 size, const char *name,
11 struct delta_buf *buf)
13 struct delta_dev *delta = ctx->dev;
14 dma_addr_t dma_addr;
15 void *addr;
16 unsigned long attrs = DMA_ATTR_WRITE_COMBINE;
18 addr = dma_alloc_attrs(delta->dev, size, &dma_addr,
19 GFP_KERNEL | __GFP_NOWARN, attrs);
20 if (!addr) {
21 dev_err(delta->dev,
22 "%s hw_alloc:dma_alloc_coherent failed for %s (size=%d)\n",
23 ctx->name, name, size);
24 ctx->sys_errors++;
25 return -ENOMEM;
28 buf->size = size;
29 buf->paddr = dma_addr;
30 buf->vaddr = addr;
31 buf->name = name;
32 buf->attrs = attrs;
34 dev_dbg(delta->dev,
35 "%s allocate %d bytes of HW memory @(virt=0x%p, phy=0x%pad): %s\n",
36 ctx->name, size, buf->vaddr, &buf->paddr, buf->name);
38 return 0;
41 void hw_free(struct delta_ctx *ctx, struct delta_buf *buf)
43 struct delta_dev *delta = ctx->dev;
45 dev_dbg(delta->dev,
46 "%s free %d bytes of HW memory @(virt=0x%p, phy=0x%pad): %s\n",
47 ctx->name, buf->size, buf->vaddr, &buf->paddr, buf->name);
49 dma_free_attrs(delta->dev, buf->size,
50 buf->vaddr, buf->paddr, buf->attrs);