1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) STMicroelectronics SA 2015
4 * Author: Hugues Fruchet <hugues.fruchet@st.com> for STMicroelectronics.
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
;
16 unsigned long attrs
= DMA_ATTR_WRITE_COMBINE
;
18 addr
= dma_alloc_attrs(delta
->dev
, size
, &dma_addr
,
19 GFP_KERNEL
| __GFP_NOWARN
, attrs
);
22 "%s hw_alloc:dma_alloc_coherent failed for %s (size=%d)\n",
23 ctx
->name
, name
, size
);
29 buf
->paddr
= dma_addr
;
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
);
41 void hw_free(struct delta_ctx
*ctx
, struct delta_buf
*buf
)
43 struct delta_dev
*delta
= ctx
->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
);