[PATCH 2/2] habanalabs: handle large memory on MMU
From: Omer Shpigelman
Date: Thu Oct 10 2019 - 10:06:27 EST
This patch changes the allocation of the host memory pages array to use
vmalloc if needed. This in order to support mapping of large memory
chunks.
Signed-off-by: Omer Shpigelman <oshpigelman@xxxxxxxxx>
---
drivers/misc/habanalabs/memory.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/misc/habanalabs/memory.c b/drivers/misc/habanalabs/memory.c
index cec4155533af..0cce30922871 100644
--- a/drivers/misc/habanalabs/memory.c
+++ b/drivers/misc/habanalabs/memory.c
@@ -1224,7 +1224,7 @@ static int init_sg_list_for_vmalloc_memory(struct hl_device *hdev, u64 addr,
u64 tmp_addr;
int i, rc;
- pages = kmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);
+ pages = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);
if (!pages)
return -ENOMEM;
@@ -1245,17 +1245,11 @@ static int init_sg_list_for_vmalloc_memory(struct hl_device *hdev, u64 addr,
rc = sg_alloc_table_from_pages(sgt, pages, npages, offset, size,
GFP_KERNEL);
- if (rc < 0) {
+ if (rc < 0)
dev_err(hdev->dev, "failed to create SG table from pages\n");
- goto free_pages;
- }
-
- kfree(pages);
-
- return 0;
free_pages:
- kfree(pages);
+ kvfree(pages);
return rc;
}
--
2.17.1