Commit 9a79e3e4 authored by Oded Gabbay's avatar Oded Gabbay

habanalabs: reject host map with mmu disabled

This is not something we can do a workaround. It is clearly an error
and we should notify the user that it is an error.
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent aa3766de
...@@ -1967,16 +1967,15 @@ static int export_dmabuf_from_handle(struct hl_ctx *ctx, u64 handle, int flags, ...@@ -1967,16 +1967,15 @@ static int export_dmabuf_from_handle(struct hl_ctx *ctx, u64 handle, int flags,
static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args) static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
{ {
struct hl_device *hdev = hpriv->hdev; struct hl_device *hdev = hpriv->hdev;
struct hl_ctx *ctx = hpriv->ctx;
u64 block_handle, device_addr = 0; u64 block_handle, device_addr = 0;
struct hl_ctx *ctx = hpriv->ctx;
u32 handle = 0, block_size; u32 handle = 0, block_size;
int rc, dmabuf_fd = -EBADF; int rc;
switch (args->in.op) { switch (args->in.op) {
case HL_MEM_OP_ALLOC: case HL_MEM_OP_ALLOC:
if (args->in.alloc.mem_size == 0) { if (args->in.alloc.mem_size == 0) {
dev_err(hdev->dev, dev_err(hdev->dev, "alloc size must be larger than 0\n");
"alloc size must be larger than 0\n");
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
...@@ -1997,15 +1996,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args) ...@@ -1997,15 +1996,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
case HL_MEM_OP_MAP: case HL_MEM_OP_MAP:
if (args->in.flags & HL_MEM_USERPTR) { if (args->in.flags & HL_MEM_USERPTR) {
device_addr = args->in.map_host.host_virt_addr; dev_err(hdev->dev, "Failed to map host memory when MMU is disabled\n");
rc = 0; rc = -EPERM;
} else { } else {
rc = get_paddr_from_handle(ctx, &args->in, rc = get_paddr_from_handle(ctx, &args->in, &device_addr);
&device_addr);
}
memset(args, 0, sizeof(*args)); memset(args, 0, sizeof(*args));
args->out.device_virt_addr = device_addr; args->out.device_virt_addr = device_addr;
}
break; break;
case HL_MEM_OP_UNMAP: case HL_MEM_OP_UNMAP:
...@@ -2013,20 +2011,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args) ...@@ -2013,20 +2011,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
break; break;
case HL_MEM_OP_MAP_BLOCK: case HL_MEM_OP_MAP_BLOCK:
rc = map_block(hdev, args->in.map_block.block_addr, rc = map_block(hdev, args->in.map_block.block_addr, &block_handle, &block_size);
&block_handle, &block_size);
args->out.block_handle = block_handle; args->out.block_handle = block_handle;
args->out.block_size = block_size; args->out.block_size = block_size;
break; break;
case HL_MEM_OP_EXPORT_DMABUF_FD: case HL_MEM_OP_EXPORT_DMABUF_FD:
rc = export_dmabuf_from_addr(ctx, dev_err(hdev->dev, "Failed to export dma-buf object when MMU is disabled\n");
args->in.export_dmabuf_fd.handle, rc = -EPERM;
args->in.export_dmabuf_fd.mem_size,
args->in.flags,
&dmabuf_fd);
memset(args, 0, sizeof(*args));
args->out.fd = dmabuf_fd;
break; break;
default: default:
......
Markdown is supported
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