mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 01:51:34 +00:00
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: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
parent
aa3766def7
commit
9a79e3e4a3
@ -1967,16 +1967,15 @@ err_dec_exporting_cnt:
|
||||
static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
|
||||
{
|
||||
struct hl_device *hdev = hpriv->hdev;
|
||||
struct hl_ctx *ctx = hpriv->ctx;
|
||||
u64 block_handle, device_addr = 0;
|
||||
struct hl_ctx *ctx = hpriv->ctx;
|
||||
u32 handle = 0, block_size;
|
||||
int rc, dmabuf_fd = -EBADF;
|
||||
int rc;
|
||||
|
||||
switch (args->in.op) {
|
||||
case HL_MEM_OP_ALLOC:
|
||||
if (args->in.alloc.mem_size == 0) {
|
||||
dev_err(hdev->dev,
|
||||
"alloc size must be larger than 0\n");
|
||||
dev_err(hdev->dev, "alloc size must be larger than 0\n");
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@ -1997,15 +1996,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
|
||||
|
||||
case HL_MEM_OP_MAP:
|
||||
if (args->in.flags & HL_MEM_USERPTR) {
|
||||
device_addr = args->in.map_host.host_virt_addr;
|
||||
rc = 0;
|
||||
dev_err(hdev->dev, "Failed to map host memory when MMU is disabled\n");
|
||||
rc = -EPERM;
|
||||
} else {
|
||||
rc = get_paddr_from_handle(ctx, &args->in,
|
||||
&device_addr);
|
||||
rc = get_paddr_from_handle(ctx, &args->in, &device_addr);
|
||||
memset(args, 0, sizeof(*args));
|
||||
args->out.device_virt_addr = device_addr;
|
||||
}
|
||||
|
||||
memset(args, 0, sizeof(*args));
|
||||
args->out.device_virt_addr = device_addr;
|
||||
break;
|
||||
|
||||
case HL_MEM_OP_UNMAP:
|
||||
@ -2013,20 +2011,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
|
||||
break;
|
||||
|
||||
case HL_MEM_OP_MAP_BLOCK:
|
||||
rc = map_block(hdev, args->in.map_block.block_addr,
|
||||
&block_handle, &block_size);
|
||||
rc = map_block(hdev, args->in.map_block.block_addr, &block_handle, &block_size);
|
||||
args->out.block_handle = block_handle;
|
||||
args->out.block_size = block_size;
|
||||
break;
|
||||
|
||||
case HL_MEM_OP_EXPORT_DMABUF_FD:
|
||||
rc = export_dmabuf_from_addr(ctx,
|
||||
args->in.export_dmabuf_fd.handle,
|
||||
args->in.export_dmabuf_fd.mem_size,
|
||||
args->in.flags,
|
||||
&dmabuf_fd);
|
||||
memset(args, 0, sizeof(*args));
|
||||
args->out.fd = dmabuf_fd;
|
||||
dev_err(hdev->dev, "Failed to export dma-buf object when MMU is disabled\n");
|
||||
rc = -EPERM;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user