[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191022063028.9030-2-oshpigelman@habana.ai>
Date: Tue, 22 Oct 2019 06:30:36 +0000
From: Omer Shpigelman <oshpigelman@...ana.ai>
To: "oded.gabbay@...il.com" <oded.gabbay@...il.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 2/2] habanalabs: handle large memory on MMU
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@...ana.ai>
---
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 552a47126567..ed3976f2198d 100644
--- a/drivers/misc/habanalabs/memory.c
+++ b/drivers/misc/habanalabs/memory.c
@@ -1228,7 +1228,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;
@@ -1249,17 +1249,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
Powered by blists - more mailing lists