Commit a013578b authored by Jens Korinth's avatar Jens Korinth
Browse files

tlkm: bugfix for missing DMA mgmt init/deinit

parent 2f77d60b
......@@ -4,6 +4,7 @@
#include "tlkm_types.h"
#include "zynq_device.h"
#include "zynq_irq.h"
#include "zynq_dmamgmt.h"
#include "zynq_platform.h"
static struct zynq_device _zynq_dev;
......@@ -89,6 +90,11 @@ int zynq_device_init(struct tlkm_device_inst *inst)
inst->private_data = (void *)&_zynq_dev;
_zynq_dev.dev_id = inst->dev_id;
if ((ret = zynq_dmamgmt_init())) {
DEVERR(inst->dev_id, "could not initialize DMA management: %d", ret);
goto err_dmamgmt;
}
if ((ret = init_iomapping())) {
DEVERR(inst->dev_id, "could not initialize I/O-mapping: %d", ret);
goto err_iomapping;
......@@ -105,6 +111,8 @@ int zynq_device_init(struct tlkm_device_inst *inst)
err_irq:
exit_iomapping();
err_iomapping:
zynq_dmamgmt_exit();
err_dmamgmt:
return ret;
}
......@@ -119,5 +127,6 @@ void zynq_device_exit(struct tlkm_device_inst *inst)
zynq_irq_exit(&_zynq_dev);
exit_iomapping();
inst->private_data = NULL;
zynq_dmamgmt_exit();
DEVLOG(_zynq_dev.dev_id, TLKM_LF_DEVICE, "zynq device exited");
}
......@@ -69,9 +69,8 @@ void zynq_dmamgmt_exit()
dma_addr_t zynq_dmamgmt_alloc(size_t const len, handle_t *hid)
{
fsp_idx_t id;
LOG(TLKM_LF_DMAMGMT, "len = %zu", len);
id = dmabuf_fsp_get(&_dmabuf);
LOG(TLKM_LF_DMAMGMT, "id = %u", id);
LOG(TLKM_LF_DMAMGMT, "len = %zu, id = %u", len, id);
if (id == INVALID_IDX) {
WRN("internal pool depleted: could not allocate a buffer!");
return 0;
......@@ -94,7 +93,6 @@ dma_addr_t zynq_dmamgmt_alloc(size_t const len, handle_t *hid)
int zynq_dmamgmt_dealloc(handle_t const id)
{
LOG(TLKM_LF_DMAMGMT, "id = %lu", (unsigned long)id);
if (id < ZYNQ_DMAMGMT_POOLSZ && _dmabuf.elems[id].kvirt_addr) {
LOG(TLKM_LF_DMAMGMT, "id = %llu, len = %zd, kvirt_addr = 0x%08lx, dma_addr = 0x%08lx",
id, _dmabuf.elems[id].len,
......
......@@ -53,13 +53,13 @@ long zynq_ioctl_alloc(struct tlkm_device_inst *inst, struct tlkm_mm_cmd *cmd)
return -EINVAL;
}
dma_addr = zynq_dmamgmt_alloc(cmd->sz, &cmd->dev_addr);
DEVLOG(inst->dev_id, TLKM_LF_IOCTL, "alloc: len = %zu, dma = 0x%08lx, id = %ld",
cmd->sz, (unsigned long) dma_addr, (long)cmd->dev_addr);
dma_addr = zynq_dmamgmt_alloc(cmd->sz, NULL);
if (! dma_addr) {
DEVWRN(inst->dev_id, "allocation failed");
DEVWRN(inst->dev_id, "allocation failed: len = %zu", cmd->sz);
return -ENOMEM;
}
DEVLOG(inst->dev_id, TLKM_LF_IOCTL, "alloc: len = %zu, dma = 0x%08lx", cmd->sz, (unsigned long) dma_addr);
cmd->dev_addr = dma_addr;
tlkm_perfc_total_alloced_mem_add(inst->dev_id, cmd->sz);
return 0;
}
......@@ -67,10 +67,10 @@ long zynq_ioctl_alloc(struct tlkm_device_inst *inst, struct tlkm_mm_cmd *cmd)
static inline
long zynq_ioctl_free(struct tlkm_device_inst *inst, struct tlkm_mm_cmd *cmd)
{
DEVLOG(inst->dev_id, TLKM_LF_IOCTL, "free: len = %zu, id = %ld", cmd->sz, (long)cmd->dev_addr);
DEVLOG(inst->dev_id, TLKM_LF_IOCTL, "free: len = %zu, dma = 0x%08lx", cmd->sz, (unsigned long)cmd->dev_addr);
if (cmd->dev_addr >= 0) {
zynq_dmamgmt_dealloc(cmd->dev_addr);
cmd->dev_addr = -1;
zynq_dmamgmt_dealloc_dma(cmd->dev_addr);
cmd->dev_addr = 0;
tlkm_perfc_total_freed_mem_add(inst->dev_id, cmd->sz);
}
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment