summaryrefslogtreecommitdiff
path: root/drivers/accel
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/accel
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.zip
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/accel')
-rw-r--r--drivers/accel/amdxdna/aie2_ctx.c4
-rw-r--r--drivers/accel/amdxdna/aie2_error.c2
-rw-r--r--drivers/accel/amdxdna/aie2_pci.c6
-rw-r--r--drivers/accel/amdxdna/aie2_solver.c4
-rw-r--r--drivers/accel/amdxdna/amdxdna_ctx.c6
-rw-r--r--drivers/accel/amdxdna/amdxdna_gem.c8
-rw-r--r--drivers/accel/amdxdna/amdxdna_mailbox.c2
-rw-r--r--drivers/accel/amdxdna/amdxdna_pci_drv.c2
-rw-r--r--drivers/accel/amdxdna/amdxdna_ubuf.c8
-rw-r--r--drivers/accel/ethosu/ethosu_drv.c3
-rw-r--r--drivers/accel/ethosu/ethosu_gem.c5
-rw-r--r--drivers/accel/ethosu/ethosu_job.c6
-rw-r--r--drivers/accel/habanalabs/common/command_buffer.c4
-rw-r--r--drivers/accel/habanalabs/common/command_submission.c27
-rw-r--r--drivers/accel/habanalabs/common/context.c8
-rw-r--r--drivers/accel/habanalabs/common/debugfs.c3
-rw-r--r--drivers/accel/habanalabs/common/decoder.c2
-rw-r--r--drivers/accel/habanalabs/common/device.c30
-rw-r--r--drivers/accel/habanalabs/common/firmware_if.c2
-rw-r--r--drivers/accel/habanalabs/common/habanalabs_drv.c4
-rw-r--r--drivers/accel/habanalabs/common/habanalabs_ioctl.c10
-rw-r--r--drivers/accel/habanalabs/common/hldio.c2
-rw-r--r--drivers/accel/habanalabs/common/hw_queue.c7
-rw-r--r--drivers/accel/habanalabs/common/hwmon.c6
-rw-r--r--drivers/accel/habanalabs/common/irq.c12
-rw-r--r--drivers/accel/habanalabs/common/memory.c24
-rw-r--r--drivers/accel/habanalabs/common/memory_mgr.c2
-rw-r--r--drivers/accel/habanalabs/common/mmu/mmu.c9
-rw-r--r--drivers/accel/habanalabs/common/security.c20
-rw-r--r--drivers/accel/habanalabs/common/state_dump.c2
-rw-r--r--drivers/accel/habanalabs/gaudi/gaudi.c11
-rw-r--r--drivers/accel/habanalabs/gaudi2/gaudi2.c21
-rw-r--r--drivers/accel/habanalabs/gaudi2/gaudi2_security.c3
-rw-r--r--drivers/accel/habanalabs/goya/goya.c11
-rw-r--r--drivers/accel/ivpu/ivpu_drv.c2
-rw-r--r--drivers/accel/ivpu/ivpu_gem_userptr.c4
-rw-r--r--drivers/accel/ivpu/ivpu_ipc.c2
-rw-r--r--drivers/accel/ivpu/ivpu_job.c6
-rw-r--r--drivers/accel/ivpu/ivpu_ms.c2
-rw-r--r--drivers/accel/qaic/qaic_control.c11
-rw-r--r--drivers/accel/qaic/qaic_data.c12
-rw-r--r--drivers/accel/qaic/qaic_drv.c2
-rw-r--r--drivers/accel/qaic/qaic_ras.c2
-rw-r--r--drivers/accel/qaic/qaic_ssr.c11
-rw-r--r--drivers/accel/qaic/qaic_timesync.c8
-rw-r--r--drivers/accel/rocket/rocket_drv.c4
-rw-r--r--drivers/accel/rocket/rocket_gem.c2
-rw-r--r--drivers/accel/rocket/rocket_job.c14
48 files changed, 182 insertions, 176 deletions
diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
index 37d05f2e986f..d4869f2fef02 100644
--- a/drivers/accel/amdxdna/aie2_ctx.c
+++ b/drivers/accel/amdxdna/aie2_ctx.c
@@ -464,7 +464,7 @@ static int aie2_alloc_resource(struct amdxdna_hwctx *hwctx)
return aie2_create_context(xdna->dev_handle, hwctx);
}
- xrs_req = kzalloc(sizeof(*xrs_req), GFP_KERNEL);
+ xrs_req = kzalloc_obj(*xrs_req, GFP_KERNEL);
if (!xrs_req)
return -ENOMEM;
@@ -559,7 +559,7 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx)
struct amdxdna_gem_obj *heap;
int i, ret;
- priv = kzalloc(sizeof(*hwctx->priv), GFP_KERNEL);
+ priv = kzalloc_obj(*hwctx->priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
hwctx->priv = priv;
diff --git a/drivers/accel/amdxdna/aie2_error.c b/drivers/accel/amdxdna/aie2_error.c
index 5e82df2b7cf6..a311231834f0 100644
--- a/drivers/accel/amdxdna/aie2_error.c
+++ b/drivers/accel/amdxdna/aie2_error.c
@@ -350,7 +350,7 @@ int aie2_error_async_events_alloc(struct amdxdna_dev_hdl *ndev)
struct async_events *events;
int i, ret;
- events = kzalloc(struct_size(events, event, total_col), GFP_KERNEL);
+ events = kzalloc_flex(*events, event, total_col, GFP_KERNEL);
if (!events)
return -ENOMEM;
diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
index f70ccf0f3c01..47346684bb75 100644
--- a/drivers/accel/amdxdna/aie2_pci.c
+++ b/drivers/accel/amdxdna/aie2_pci.c
@@ -653,7 +653,7 @@ static int aie2_get_aie_metadata(struct amdxdna_client *client,
int ret = 0;
ndev = xdna->dev_handle;
- meta = kzalloc(sizeof(*meta), GFP_KERNEL);
+ meta = kzalloc_obj(*meta, GFP_KERNEL);
if (!meta)
return -ENOMEM;
@@ -748,7 +748,7 @@ static int aie2_get_clock_metadata(struct amdxdna_client *client,
int ret = 0;
ndev = xdna->dev_handle;
- clock = kzalloc(sizeof(*clock), GFP_KERNEL);
+ clock = kzalloc_obj(*clock, GFP_KERNEL);
if (!clock)
return -ENOMEM;
@@ -775,7 +775,7 @@ static int aie2_hwctx_status_cb(struct amdxdna_hwctx *hwctx, void *arg)
if (!array_args->num_element)
return -EINVAL;
- tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
+ tmp = kzalloc_obj(*tmp, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
diff --git a/drivers/accel/amdxdna/aie2_solver.c b/drivers/accel/amdxdna/aie2_solver.c
index 2013d1f13aae..6154ef9f9e9d 100644
--- a/drivers/accel/amdxdna/aie2_solver.c
+++ b/drivers/accel/amdxdna/aie2_solver.c
@@ -197,7 +197,7 @@ static int get_free_partition(struct solver_state *xrs,
if (i == snode->cols_len)
return -ENODEV;
- pt_node = kzalloc(sizeof(*pt_node), GFP_KERNEL);
+ pt_node = kzalloc_obj(*pt_node, GFP_KERNEL);
if (!pt_node)
return -ENOMEM;
@@ -266,7 +266,7 @@ static struct solver_node *create_solver_node(struct solver_state *xrs,
struct solver_node *node;
int ret;
- node = kzalloc(struct_size(node, start_cols, cdop->cols_len), GFP_KERNEL);
+ node = kzalloc_flex(*node, start_cols, cdop->cols_len, GFP_KERNEL);
if (!node)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
index d17aef89a0ad..edbac9f4054c 100644
--- a/drivers/accel/amdxdna/amdxdna_ctx.c
+++ b/drivers/accel/amdxdna/amdxdna_ctx.c
@@ -50,7 +50,7 @@ static struct dma_fence *amdxdna_fence_create(struct amdxdna_hwctx *hwctx)
{
struct amdxdna_fence *fence;
- fence = kzalloc(sizeof(*fence), GFP_KERNEL);
+ fence = kzalloc_obj(*fence, GFP_KERNEL);
if (!fence)
return NULL;
@@ -161,7 +161,7 @@ int amdxdna_drm_create_hwctx_ioctl(struct drm_device *dev, void *data, struct dr
if (args->ext || args->ext_flags)
return -EINVAL;
- hwctx = kzalloc(sizeof(*hwctx), GFP_KERNEL);
+ hwctx = kzalloc_obj(*hwctx, GFP_KERNEL);
if (!hwctx)
return -ENOMEM;
@@ -436,7 +436,7 @@ int amdxdna_cmd_submit(struct amdxdna_client *client,
int ret, idx;
XDNA_DBG(xdna, "Command BO hdl %d, Arg BO count %d", cmd_bo_hdl, arg_bo_cnt);
- job = kzalloc(struct_size(job, bos, arg_bo_cnt), GFP_KERNEL);
+ job = kzalloc_flex(*job, bos, arg_bo_cnt, GFP_KERNEL);
if (!job)
return -ENOMEM;
diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index dfa916eeb2d9..d862d5fe5385 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -205,13 +205,13 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
if (!xdna->dev_info->ops->hmm_invalidate)
return 0;
- mapp = kzalloc(sizeof(*mapp), GFP_KERNEL);
+ mapp = kzalloc_obj(*mapp, GFP_KERNEL);
if (!mapp)
return -ENOMEM;
nr_pages = (PAGE_ALIGN(addr + len) - (addr & PAGE_MASK)) >> PAGE_SHIFT;
- mapp->range.hmm_pfns = kvcalloc(nr_pages, sizeof(*mapp->range.hmm_pfns),
- GFP_KERNEL);
+ mapp->range.hmm_pfns = kvzalloc_objs(*mapp->range.hmm_pfns, nr_pages,
+ GFP_KERNEL);
if (!mapp->range.hmm_pfns) {
ret = -ENOMEM;
goto free_map;
@@ -499,7 +499,7 @@ amdxdna_gem_create_obj(struct drm_device *dev, size_t size)
{
struct amdxdna_gem_obj *abo;
- abo = kzalloc(sizeof(*abo), GFP_KERNEL);
+ abo = kzalloc_obj(*abo, GFP_KERNEL);
if (!abo)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/accel/amdxdna/amdxdna_mailbox.c b/drivers/accel/amdxdna/amdxdna_mailbox.c
index 469242ed8224..04d1d30184ca 100644
--- a/drivers/accel/amdxdna/amdxdna_mailbox.c
+++ b/drivers/accel/amdxdna/amdxdna_mailbox.c
@@ -475,7 +475,7 @@ xdna_mailbox_create_channel(struct mailbox *mb,
return NULL;
}
- mb_chann = kzalloc(sizeof(*mb_chann), GFP_KERNEL);
+ mb_chann = kzalloc_obj(*mb_chann, GFP_KERNEL);
if (!mb_chann)
return NULL;
diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c b/drivers/accel/amdxdna/amdxdna_pci_drv.c
index fdefd9ec2066..86f46f59b9dc 100644
--- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
+++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
@@ -63,7 +63,7 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp)
struct amdxdna_client *client;
int ret;
- client = kzalloc(sizeof(*client), GFP_KERNEL);
+ client = kzalloc_obj(*client, GFP_KERNEL);
if (!client)
return -ENOMEM;
diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c
index 9e3b3b055caa..44db2cef40cb 100644
--- a/drivers/accel/amdxdna/amdxdna_ubuf.c
+++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
@@ -27,7 +27,7 @@ static struct sg_table *amdxdna_ubuf_map(struct dma_buf_attachment *attach,
struct sg_table *sg;
int ret;
- sg = kzalloc(sizeof(*sg), GFP_KERNEL);
+ sg = kzalloc_obj(*sg, GFP_KERNEL);
if (!sg)
return ERR_PTR(-ENOMEM);
@@ -147,7 +147,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
if (!can_do_mlock())
return ERR_PTR(-EPERM);
- ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL);
+ ubuf = kzalloc_obj(*ubuf, GFP_KERNEL);
if (!ubuf)
return ERR_PTR(-ENOMEM);
@@ -155,7 +155,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
ubuf->mm = current->mm;
mmgrab(ubuf->mm);
- va_ent = kvcalloc(num_entries, sizeof(*va_ent), GFP_KERNEL);
+ va_ent = kvzalloc_objs(*va_ent, num_entries, GFP_KERNEL);
if (!va_ent) {
ret = -ENOMEM;
goto free_ubuf;
@@ -189,7 +189,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
goto sub_pin_cnt;
}
- ubuf->pages = kvmalloc_array(ubuf->nr_pages, sizeof(*ubuf->pages), GFP_KERNEL);
+ ubuf->pages = kvmalloc_objs(*ubuf->pages, ubuf->nr_pages, GFP_KERNEL);
if (!ubuf->pages) {
ret = -ENOMEM;
goto sub_pin_cnt;
diff --git a/drivers/accel/ethosu/ethosu_drv.c b/drivers/accel/ethosu/ethosu_drv.c
index e05a69bf5574..ae5e6b15e7de 100644
--- a/drivers/accel/ethosu/ethosu_drv.c
+++ b/drivers/accel/ethosu/ethosu_drv.c
@@ -144,7 +144,8 @@ static int ethosu_open(struct drm_device *ddev, struct drm_file *file)
if (!try_module_get(THIS_MODULE))
return -EINVAL;
- struct ethosu_file_priv __free(kfree) *priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ struct ethosu_file_priv __free(kfree) *priv = kzalloc_obj(*priv,
+ GFP_KERNEL);
if (!priv) {
ret = -ENOMEM;
goto err_put_mod;
diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethosu_gem.c
index 473b5f5d7514..7a5405db5a6c 100644
--- a/drivers/accel/ethosu/ethosu_gem.c
+++ b/drivers/accel/ethosu/ethosu_gem.c
@@ -50,7 +50,7 @@ struct drm_gem_object *ethosu_gem_create_object(struct drm_device *ddev, size_t
{
struct ethosu_gem_object *obj;
- obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+ obj = kzalloc_obj(*obj, GFP_KERNEL);
if (!obj)
return ERR_PTR(-ENOMEM);
@@ -352,7 +352,8 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev,
struct ethosu_gem_object *bo,
u32 size)
{
- struct ethosu_validated_cmdstream_info __free(kfree) *info = kzalloc(sizeof(*info), GFP_KERNEL);
+ struct ethosu_validated_cmdstream_info __free(kfree) *info = kzalloc_obj(*info,
+ GFP_KERNEL);
struct ethosu_device *edev = to_ethosu_device(ddev);
u32 *bocmds = bo->base.vaddr;
struct cmd_state st;
diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
index 26e7a2f64d71..91d1b996852e 100644
--- a/drivers/accel/ethosu/ethosu_job.c
+++ b/drivers/accel/ethosu/ethosu_job.c
@@ -375,7 +375,7 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
if (edev->npu_info.sram_size < job->sram_size)
return -EINVAL;
- ejob = kzalloc(sizeof(*ejob), GFP_KERNEL);
+ ejob = kzalloc_obj(*ejob, GFP_KERNEL);
if (!ejob)
return -ENOMEM;
@@ -384,7 +384,7 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
ejob->dev = edev;
ejob->sram_size = job->sram_size;
- ejob->done_fence = kzalloc(sizeof(*ejob->done_fence), GFP_KERNEL);
+ ejob->done_fence = kzalloc_obj(*ejob->done_fence, GFP_KERNEL);
if (!ejob->done_fence) {
ret = -ENOMEM;
goto out_cleanup_job;
@@ -476,7 +476,7 @@ int ethosu_ioctl_submit(struct drm_device *dev, void *data, struct drm_file *fil
}
struct drm_ethosu_job __free(kvfree) *jobs =
- kvmalloc_array(args->job_count, sizeof(*jobs), GFP_KERNEL);
+ kvmalloc_objs(*jobs, args->job_count, GFP_KERNEL);
if (!jobs)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/command_buffer.c b/drivers/accel/habanalabs/common/command_buffer.c
index 0f0d295116e7..b27323afd12d 100644
--- a/drivers/accel/habanalabs/common/command_buffer.c
+++ b/drivers/accel/habanalabs/common/command_buffer.c
@@ -116,10 +116,10 @@ static struct hl_cb *hl_cb_alloc(struct hl_device *hdev, u32 cb_size,
* and must use GFP_ATOMIC for all memory allocations.
*/
if (ctx_id == HL_KERNEL_ASID_ID && !hdev->disabled)
- cb = kzalloc(sizeof(*cb), GFP_ATOMIC);
+ cb = kzalloc_obj(*cb, GFP_ATOMIC);
if (!cb)
- cb = kzalloc(sizeof(*cb), GFP_KERNEL);
+ cb = kzalloc_obj(*cb, GFP_KERNEL);
if (!cb)
return NULL;
diff --git a/drivers/accel/habanalabs/common/command_submission.c b/drivers/accel/habanalabs/common/command_submission.c
index dee487724918..f990d16f6c2f 100644
--- a/drivers/accel/habanalabs/common/command_submission.c
+++ b/drivers/accel/habanalabs/common/command_submission.c
@@ -907,9 +907,9 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
cntr = &hdev->aggregated_cs_counters;
- cs = kzalloc(sizeof(*cs), GFP_ATOMIC);
+ cs = kzalloc_obj(*cs, GFP_ATOMIC);
if (!cs)
- cs = kzalloc(sizeof(*cs), GFP_KERNEL);
+ cs = kzalloc_obj(*cs, GFP_KERNEL);
if (!cs) {
atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
@@ -936,9 +936,9 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
kref_init(&cs->refcount);
spin_lock_init(&cs->job_lock);
- cs_cmpl = kzalloc(sizeof(*cs_cmpl), GFP_ATOMIC);
+ cs_cmpl = kzalloc_obj(*cs_cmpl, GFP_ATOMIC);
if (!cs_cmpl)
- cs_cmpl = kzalloc(sizeof(*cs_cmpl), GFP_KERNEL);
+ cs_cmpl = kzalloc_obj(*cs_cmpl, GFP_KERNEL);
if (!cs_cmpl) {
atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
@@ -1302,9 +1302,9 @@ struct hl_cs_job *hl_cs_allocate_job(struct hl_device *hdev,
{
struct hl_cs_job *job;
- job = kzalloc(sizeof(*job), GFP_ATOMIC);
+ job = kzalloc_obj(*job, GFP_ATOMIC);
if (!job)
- job = kzalloc(sizeof(*job), GFP_KERNEL);
+ job = kzalloc_obj(*job, GFP_KERNEL);
if (!job)
return NULL;
@@ -1420,11 +1420,10 @@ static int hl_cs_copy_chunk_array(struct hl_device *hdev,
return -EINVAL;
}
- *cs_chunk_array = kmalloc_array(num_chunks, sizeof(**cs_chunk_array),
- GFP_ATOMIC);
+ *cs_chunk_array = kmalloc_objs(**cs_chunk_array, num_chunks, GFP_ATOMIC);
if (!*cs_chunk_array)
- *cs_chunk_array = kmalloc_array(num_chunks,
- sizeof(**cs_chunk_array), GFP_KERNEL);
+ *cs_chunk_array = kmalloc_objs(**cs_chunk_array, num_chunks,
+ GFP_KERNEL);
if (!*cs_chunk_array) {
atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
atomic64_inc(&hdev->aggregated_cs_counters.out_of_mem_drop_cnt);
@@ -2040,7 +2039,7 @@ static int cs_ioctl_reserve_signals(struct hl_fpriv *hpriv,
prop = &hdev->kernel_queues[q_idx].sync_stream_prop;
- handle = kzalloc(sizeof(*handle), GFP_KERNEL);
+ handle = kzalloc_obj(*handle, GFP_KERNEL);
if (!handle) {
rc = -ENOMEM;
goto out;
@@ -3053,7 +3052,7 @@ static int hl_multi_cs_wait_ioctl(struct hl_fpriv *hpriv, void *data)
}
/* allocate array for the fences */
- fence_arr = kmalloc_array(seq_arr_len, sizeof(struct hl_fence *), GFP_KERNEL);
+ fence_arr = kmalloc_objs(struct hl_fence *, seq_arr_len, GFP_KERNEL);
if (!fence_arr) {
rc = -ENOMEM;
goto free_seq_arr;
@@ -3412,7 +3411,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
goto put_cq_cb;
}
- pend = kzalloc(sizeof(*pend), GFP_KERNEL);
+ pend = kzalloc_obj(*pend, GFP_KERNEL);
if (!pend) {
rc = -ENOMEM;
goto put_cq_cb;
@@ -3521,7 +3520,7 @@ static int _hl_interrupt_wait_ioctl_user_addr(struct hl_device *hdev, struct hl_
hl_ctx_get(ctx);
- pend = kzalloc(sizeof(*pend), GFP_KERNEL);
+ pend = kzalloc_obj(*pend, GFP_KERNEL);
if (!pend) {
hl_ctx_put(ctx);
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/context.c b/drivers/accel/habanalabs/common/context.c
index 9f212b17611a..4d69a3f48616 100644
--- a/drivers/accel/habanalabs/common/context.c
+++ b/drivers/accel/habanalabs/common/context.c
@@ -155,7 +155,7 @@ int hl_ctx_create(struct hl_device *hdev, struct hl_fpriv *hpriv)
struct hl_ctx *ctx;
int rc;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
rc = -ENOMEM;
goto out_err;
@@ -209,9 +209,9 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)
spin_lock_init(&ctx->cs_lock);
atomic_set(&ctx->thread_ctx_switch_token, 1);
ctx->thread_ctx_switch_wait_token = 0;
- ctx->cs_pending = kcalloc(hdev->asic_prop.max_pending_cs,
- sizeof(struct hl_fence *),
- GFP_KERNEL);
+ ctx->cs_pending = kzalloc_objs(struct hl_fence *,
+ hdev->asic_prop.max_pending_cs,
+ GFP_KERNEL);
if (!ctx->cs_pending)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/debugfs.c b/drivers/accel/habanalabs/common/debugfs.c
index 5f0820b19ccb..05b1cc7918c5 100644
--- a/drivers/accel/habanalabs/common/debugfs.c
+++ b/drivers/accel/habanalabs/common/debugfs.c
@@ -2052,7 +2052,8 @@ int hl_debugfs_device_init(struct hl_device *hdev)
int count = ARRAY_SIZE(hl_debugfs_list);
dev_entry->hdev = hdev;
- dev_entry->entry_arr = kmalloc_array(count, sizeof(struct hl_debugfs_entry), GFP_KERNEL);
+ dev_entry->entry_arr = kmalloc_objs(struct hl_debugfs_entry, count,
+ GFP_KERNEL);
if (!dev_entry->entry_arr)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/decoder.c b/drivers/accel/habanalabs/common/decoder.c
index c03a6da45d00..602e53f963ca 100644
--- a/drivers/accel/habanalabs/common/decoder.c
+++ b/drivers/accel/habanalabs/common/decoder.c
@@ -98,7 +98,7 @@ int hl_dec_init(struct hl_device *hdev)
if (!prop->max_dec)
return 0;
- hdev->dec = kcalloc(prop->max_dec, sizeof(struct hl_dec), GFP_KERNEL);
+ hdev->dec = kzalloc_objs(struct hl_dec, prop->max_dec, GFP_KERNEL);
if (!hdev->dec)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/habanalabs/common/device.c
index 999c92d7036e..20ddf6617e02 100644
--- a/drivers/accel/habanalabs/common/device.c
+++ b/drivers/accel/habanalabs/common/device.c
@@ -722,7 +722,7 @@ static int device_init_cdev(struct hl_device *hdev, const struct class *class,
cdev_init(cdev, fops);
cdev->owner = THIS_MODULE;
- *dev = kzalloc(sizeof(**dev), GFP_KERNEL);
+ *dev = kzalloc_obj(**dev, GFP_KERNEL);
if (!*dev)
return -ENOMEM;
@@ -892,9 +892,9 @@ static int device_early_init(struct hl_device *hdev)
goto early_fini;
if (hdev->asic_prop.completion_queues_count) {
- hdev->cq_wq = kcalloc(hdev->asic_prop.completion_queues_count,
- sizeof(struct workqueue_struct *),
- GFP_KERNEL);
+ hdev->cq_wq = kzalloc_objs(struct workqueue_struct *,
+ hdev->asic_prop.completion_queues_count,
+ GFP_KERNEL);
if (!hdev->cq_wq) {
rc = -ENOMEM;
goto asid_fini;
@@ -945,7 +945,7 @@ static int device_early_init(struct hl_device *hdev)
goto free_ts_free_wq;
}
- hdev->hl_chip_info = kzalloc(sizeof(struct hwmon_chip_info), GFP_KERNEL);
+ hdev->hl_chip_info = kzalloc_obj(struct hwmon_chip_info, GFP_KERNEL);
if (!hdev->hl_chip_info) {
rc = -ENOMEM;
goto free_prefetch_wq;
@@ -1851,8 +1851,7 @@ kill_processes:
}
/* Allocate the kernel context */
- hdev->kernel_ctx = kzalloc(sizeof(*hdev->kernel_ctx),
- GFP_KERNEL);
+ hdev->kernel_ctx = kzalloc_obj(*hdev->kernel_ctx, GFP_KERNEL);
if (!hdev->kernel_ctx) {
rc = -ENOMEM;
hl_mmu_fini(hdev);
@@ -2159,8 +2158,9 @@ int hl_device_init(struct hl_device *hdev)
hdev->asic_prop.user_interrupt_count;
if (user_interrupt_cnt) {
- hdev->user_interrupt = kcalloc(user_interrupt_cnt, sizeof(*hdev->user_interrupt),
- GFP_KERNEL);
+ hdev->user_interrupt = kzalloc_objs(*hdev->user_interrupt,
+ user_interrupt_cnt,
+ GFP_KERNEL);
if (!hdev->user_interrupt) {
rc = -ENOMEM;
goto early_fini;
@@ -2226,9 +2226,8 @@ int hl_device_init(struct hl_device *hdev)
* passed as arguments to request_irq
*/
if (cq_cnt) {
- hdev->completion_queue = kcalloc(cq_cnt,
- sizeof(*hdev->completion_queue),
- GFP_KERNEL);
+ hdev->completion_queue = kzalloc_objs(*hdev->completion_queue,
+ cq_cnt, GFP_KERNEL);
if (!hdev->completion_queue) {
dev_err(hdev->dev,
@@ -2249,8 +2248,9 @@ int hl_device_init(struct hl_device *hdev)
hdev->completion_queue[i].cq_idx = i;
}
- hdev->shadow_cs_queue = kcalloc(hdev->asic_prop.max_pending_cs,
- sizeof(struct hl_cs *), GFP_KERNEL);
+ hdev->shadow_cs_queue = kzalloc_objs(struct hl_cs *,
+ hdev->asic_prop.max_pending_cs,
+ GFP_KERNEL);
if (!hdev->shadow_cs_queue) {
rc = -ENOMEM;
goto cq_fini;
@@ -2275,7 +2275,7 @@ int hl_device_init(struct hl_device *hdev)
}
/* Allocate the kernel context */
- hdev->kernel_ctx = kzalloc(sizeof(*hdev->kernel_ctx), GFP_KERNEL);
+ hdev->kernel_ctx = kzalloc_obj(*hdev->kernel_ctx, GFP_KERNEL);
if (!hdev->kernel_ctx) {
rc = -ENOMEM;
goto mmu_fini;
diff --git a/drivers/accel/habanalabs/common/firmware_if.c b/drivers/accel/habanalabs/common/firmware_if.c
index eeb6b2a80fc7..f6a2c48ad74e 100644
--- a/drivers/accel/habanalabs/common/firmware_if.c
+++ b/drivers/accel/habanalabs/common/firmware_if.c
@@ -2681,7 +2681,7 @@ static int hl_fw_dynamic_send_msg(struct hl_device *hdev,
struct lkd_msg_comms *msg;
int rc;
- msg = kzalloc(sizeof(*msg), GFP_KERNEL);
+ msg = kzalloc_obj(*msg, GFP_KERNEL);
if (!msg)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/habanalabs_drv.c b/drivers/accel/habanalabs/common/habanalabs_drv.c
index 0035748f3228..63b4a91e291c 100644
--- a/drivers/accel/habanalabs/common/habanalabs_drv.c
+++ b/drivers/accel/habanalabs/common/habanalabs_drv.c
@@ -181,7 +181,7 @@ int hl_device_open(struct drm_device *ddev, struct drm_file *file_priv)
struct hl_fpriv *hpriv;
int rc;
- hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
+ hpriv = kzalloc_obj(*hpriv, GFP_KERNEL);
if (!hpriv)
return -ENOMEM;
@@ -291,7 +291,7 @@ int hl_device_open_ctrl(struct inode *inode, struct file *filp)
return -ENXIO;
}
- hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
+ hpriv = kzalloc_obj(*hpriv, GFP_KERNEL);
if (!hpriv)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
index fdfdabc85e54..ace0aaa7b836 100644
--- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c
+++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
@@ -201,7 +201,7 @@ static int debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, struct hl
void *input = NULL, *output = NULL;
int rc;
- params = kzalloc(sizeof(*params), GFP_KERNEL);
+ params = kzalloc_obj(*params, GFP_KERNEL);
if (!params)
return -ENOMEM;
@@ -682,11 +682,11 @@ static int sec_attest_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
if ((!max_size) || (!out))
return -EINVAL;
- sec_attest_info = kmalloc(sizeof(*sec_attest_info), GFP_KERNEL);
+ sec_attest_info = kmalloc_obj(*sec_attest_info, GFP_KERNEL);
if (!sec_attest_info)
return -ENOMEM;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info) {
rc = -ENOMEM;
goto free_sec_attest_info;
@@ -731,11 +731,11 @@ static int dev_info_signed(struct hl_fpriv *hpriv, struct hl_info_args *args)
if ((!max_size) || (!out))
return -EINVAL;
- dev_info_signed = kzalloc(sizeof(*dev_info_signed), GFP_KERNEL);
+ dev_info_signed = kzalloc_obj(*dev_info_signed, GFP_KERNEL);
if (!dev_info_signed)
return -ENOMEM;
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info) {
rc = -ENOMEM;
goto free_dev_info_signed;
diff --git a/drivers/accel/habanalabs/common/hldio.c b/drivers/accel/habanalabs/common/hldio.c
index 083ae5610875..2cef50bbfa9b 100644
--- a/drivers/accel/habanalabs/common/hldio.c
+++ b/drivers/accel/habanalabs/common/hldio.c
@@ -308,7 +308,7 @@ int hl_dio_ssd2hl(struct hl_device *hdev, struct hl_ctx *ctx, int fd,
dev_dbg(hdev->dev, "SSD2HL fd=%d va=%#llx len=%#lx\n", fd, device_va, len_bytes);
- io = kzalloc(sizeof(*io), GFP_KERNEL);
+ io = kzalloc_obj(*io, GFP_KERNEL);
if (!io) {
rc = -ENOMEM;
goto out;
diff --git a/drivers/accel/habanalabs/common/hw_queue.c b/drivers/accel/habanalabs/common/hw_queue.c
index 3d04a7507cce..d499063a79ec 100644
--- a/drivers/accel/habanalabs/common/hw_queue.c
+++ b/drivers/accel/habanalabs/common/hw_queue.c
@@ -837,7 +837,8 @@ static int ext_and_cpu_queue_init(struct hl_device *hdev, struct hl_hw_queue *q,
q->kernel_address = p;
- q->shadow_queue = kmalloc_array(HL_QUEUE_LENGTH, sizeof(struct hl_cs_job *), GFP_KERNEL);
+ q->shadow_queue = kmalloc_objs(struct hl_cs_job *, HL_QUEUE_LENGTH,
+ GFP_KERNEL);
if (!q->shadow_queue) {
dev_err(hdev->dev,
"Failed to allocate shadow queue for H/W queue %d\n",
@@ -1082,8 +1083,8 @@ int hl_hw_queues_create(struct hl_device *hdev)
struct hl_hw_queue *q;
int i, rc, q_ready_cnt;
- hdev->kernel_queues = kcalloc(asic->max_queues,
- sizeof(*hdev->kernel_queues), GFP_KERNEL);
+ hdev->kernel_queues = kzalloc_objs(*hdev->kernel_queues,
+ asic->max_queues, GFP_KERNEL);
if (!hdev->kernel_queues) {
dev_err(hdev->dev, "Not enough memory for H/W queues\n");
diff --git a/drivers/accel/habanalabs/common/hwmon.c b/drivers/accel/habanalabs/common/hwmon.c
index 52d1e6bf10dc..a8b00a80fa10 100644
--- a/drivers/accel/habanalabs/common/hwmon.c
+++ b/drivers/accel/habanalabs/common/hwmon.c
@@ -195,15 +195,15 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev, struct cpucp_sensor *sen
curr_arr[sensors_by_type_next_index[type]++] = flags;
}
- channels_info = kcalloc(num_active_sensor_types + 1, sizeof(struct hwmon_channel_info *),
- GFP_KERNEL);
+ channels_info = kzalloc_objs(struct hwmon_channel_info *,
+ num_active_sensor_types + 1, GFP_KERNEL);
if (!channels_info) {
rc = -ENOMEM;
goto channels_info_array_err;
}
for (i = 0 ; i < num_active_sensor_types ; i++) {
- channels_info[i] = kzalloc(sizeof(*channels_info[i]), GFP_KERNEL);
+ channels_info[i] = kzalloc_obj(*channels_info[i], GFP_KERNEL);
if (!channels_info[i]) {
rc = -ENOMEM;
goto channel_info_err;
diff --git a/drivers/accel/habanalabs/common/irq.c b/drivers/accel/habanalabs/common/irq.c
index 7c9f2f6a2870..023dd3f1c82c 100644
--- a/drivers/accel/habanalabs/common/irq.c
+++ b/drivers/accel/habanalabs/common/irq.c
@@ -267,7 +267,7 @@ static int handle_registration_node(struct hl_device *hdev, struct hl_user_pendi
if (!(*free_list)) {
/* Alloc/Init the timestamp registration free objects list */
- *free_list = kmalloc(sizeof(struct list_head), GFP_ATOMIC);
+ *free_list = kmalloc_obj(struct list_head, GFP_ATOMIC);
if (!(*free_list))
return -ENOMEM;
@@ -283,14 +283,16 @@ static int handle_registration_node(struct hl_device *hdev, struct hl_user_pendi
intr->interrupt_id);
if (!(*dynamic_alloc_list)) {
- *dynamic_alloc_list = kmalloc(sizeof(struct list_head), GFP_ATOMIC);
+ *dynamic_alloc_list = kmalloc_obj(struct list_head,
+ GFP_ATOMIC);
if (!(*dynamic_alloc_list))
return -ENOMEM;
INIT_LIST_HEAD(*dynamic_alloc_list);
}
- free_node = kmalloc(sizeof(struct timestamp_reg_free_node), GFP_ATOMIC);
+ free_node = kmalloc_obj(struct timestamp_reg_free_node,
+ GFP_ATOMIC);
if (!free_node)
return -ENOMEM;
@@ -344,7 +346,7 @@ static void handle_user_interrupt_ts_list(struct hl_device *hdev, struct hl_user
* and move nodes hanged on the free list back to the interrupt ts list
* we always alloc the job of the WQ at the beginning.
*/
- job = kmalloc(sizeof(*job), GFP_ATOMIC);
+ job = kmalloc_obj(*job, GFP_ATOMIC);
if (!job)
return;
@@ -542,7 +544,7 @@ irqreturn_t hl_irq_handler_eq(int irq, void *arg)
goto skip_irq;
}
- handle_eqe_work = kmalloc(sizeof(*handle_eqe_work), GFP_ATOMIC);
+ handle_eqe_work = kmalloc_obj(*handle_eqe_work, GFP_ATOMIC);
if (handle_eqe_work) {
INIT_WORK(&handle_eqe_work->eq_work, irq_handle_eqe);
handle_eqe_work->hdev = hdev;
diff --git a/drivers/accel/habanalabs/common/memory.c b/drivers/accel/habanalabs/common/memory.c
index 633db4bff46f..8700e341ff94 100644
--- a/drivers/accel/habanalabs/common/memory.c
+++ b/drivers/accel/habanalabs/common/memory.c
@@ -125,7 +125,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
}
}
- phys_pg_pack = kzalloc(sizeof(*phys_pg_pack), GFP_KERNEL);
+ phys_pg_pack = kzalloc_obj(*phys_pg_pack, GFP_KERNEL);
if (!phys_pg_pack) {
rc = -ENOMEM;
goto pages_pack_err;
@@ -228,7 +228,7 @@ static int dma_map_host_va(struct hl_device *hdev, u64 addr, u64 size,
struct hl_userptr *userptr;
int rc;
- userptr = kzalloc(sizeof(*userptr), GFP_KERNEL);
+ userptr = kzalloc_obj(*userptr, GFP_KERNEL);
if (!userptr) {
rc = -ENOMEM;
goto userptr_err;
@@ -501,7 +501,7 @@ static int add_va_block_locked(struct hl_device *hdev,
res = va_block;
}
- va_block = kmalloc(sizeof(*va_block), GFP_KERNEL);
+ va_block = kmalloc_obj(*va_block, GFP_KERNEL);
if (!va_block)
return -ENOMEM;
@@ -850,7 +850,7 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx,
dma_addr_t dma_addr;
int rc, i, j;
- phys_pg_pack = kzalloc(sizeof(*phys_pg_pack), GFP_KERNEL);
+ phys_pg_pack = kzalloc_obj(*phys_pg_pack, GFP_KERNEL);
if (!phys_pg_pack)
return -ENOMEM;
@@ -1152,7 +1152,7 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args, u64 *device
goto shared_err;
}
- hnode = kzalloc(sizeof(*hnode), GFP_KERNEL);
+ hnode = kzalloc_obj(*hnode, GFP_KERNEL);
if (!hnode) {
rc = -ENOMEM;
goto hnode_err;
@@ -1482,7 +1482,7 @@ int hl_hw_block_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
return -EINVAL;
}
- lnode = kzalloc(sizeof(*lnode), GFP_KERNEL);
+ lnode = kzalloc_obj(*lnode, GFP_KERNEL);
if (!lnode)
return -ENOMEM;
@@ -1553,7 +1553,7 @@ static struct sg_table *alloc_sgt_from_device_pages(struct hl_device *hdev, u64
return ERR_PTR(-EINVAL);
}
- sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
+ sgt = kzalloc_obj(*sgt, GFP_KERNEL);
if (!sgt)
return ERR_PTR(-ENOMEM);
@@ -2046,7 +2046,7 @@ static int export_dmabuf_from_addr(struct hl_ctx *ctx, u64 addr, u64 size, u64 o
return -EINVAL;
}
- hl_dmabuf = kzalloc(sizeof(*hl_dmabuf), GFP_KERNEL);
+ hl_dmabuf = kzalloc_obj(*hl_dmabuf, GFP_KERNEL);
if (!hl_dmabuf)
return -ENOMEM;
@@ -2116,7 +2116,7 @@ static int hl_ts_alloc_buf(struct hl_mmap_mem_buf *buf, gfp_t gfp, void *args)
num_elements = *(u32 *)args;
- ts_buff = kzalloc(sizeof(*ts_buff), gfp);
+ ts_buff = kzalloc_obj(*ts_buff, gfp);
if (!ts_buff)
return -ENOMEM;
@@ -2323,7 +2323,7 @@ static int get_user_memory(struct hl_device *hdev, u64 addr, u64 size,
return -EFAULT;
}
- userptr->pages = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);
+ userptr->pages = kvmalloc_objs(struct page *, npages, GFP_KERNEL);
if (!userptr->pages)
return -ENOMEM;
@@ -2395,7 +2395,7 @@ int hl_pin_host_memory(struct hl_device *hdev, u64 addr, u64 size,
}
userptr->pid = current->pid;
- userptr->sgt = kzalloc(sizeof(*userptr->sgt), GFP_KERNEL);
+ userptr->sgt = kzalloc_obj(*userptr->sgt, GFP_KERNEL);
if (!userptr->sgt)
return -ENOMEM;
@@ -2611,7 +2611,7 @@ static int vm_ctx_init_with_ranges(struct hl_ctx *ctx,
for (i = 0 ; i < HL_VA_RANGE_TYPE_MAX ; i++) {
ctx->va_range[i] =
- kzalloc(sizeof(struct hl_va_range), GFP_KERNEL);
+ kzalloc_obj(struct hl_va_range, GFP_KERNEL);
if (!ctx->va_range[i]) {
rc = -ENOMEM;
goto free_va_range;
diff --git a/drivers/accel/habanalabs/common/memory_mgr.c b/drivers/accel/habanalabs/common/memory_mgr.c
index 4401beb99e42..9fdd34acf389 100644
--- a/drivers/accel/habanalabs/common/memory_mgr.c
+++ b/drivers/accel/habanalabs/common/memory_mgr.c
@@ -152,7 +152,7 @@ hl_mmap_mem_buf_alloc(struct hl_mem_mgr *mmg,
struct hl_mmap_mem_buf *buf;
int rc;
- buf = kzalloc(sizeof(*buf), gfp);
+ buf = kzalloc_obj(*buf, gfp);
if (!buf)
return NULL;
diff --git a/drivers/accel/habanalabs/common/mmu/mmu.c b/drivers/accel/habanalabs/common/mmu/mmu.c
index 79823facce7f..8a661408af20 100644
--- a/drivers/accel/habanalabs/common/mmu/mmu.c
+++ b/drivers/accel/habanalabs/common/mmu/mmu.c
@@ -697,7 +697,7 @@ int hl_mmu_prefetch_cache_range(struct hl_ctx *ctx, u32 flags, u32 asid, u64 va,
{
struct hl_prefetch_work *handle_prefetch_work;
- handle_prefetch_work = kmalloc(sizeof(*handle_prefetch_work), GFP_KERNEL);
+ handle_prefetch_work = kmalloc_obj(*handle_prefetch_work, GFP_KERNEL);
if (!handle_prefetch_work)
return -ENOMEM;
@@ -843,7 +843,8 @@ int hl_mmu_hr_init(struct hl_device *hdev, struct hl_mmu_hr_priv *hr_priv, u32 h
return -ENOMEM;
}
- hr_priv->mmu_asid_hop0 = kvcalloc(prop->max_asid, sizeof(struct pgt_info), GFP_KERNEL);
+ hr_priv->mmu_asid_hop0 = kvzalloc_objs(struct pgt_info, prop->max_asid,
+ GFP_KERNEL);
if (ZERO_OR_NULL_PTR(hr_priv->mmu_asid_hop0)) {
dev_err(hdev->dev, "Failed to allocate hr-mmu hop0 table\n");
rc = -ENOMEM;
@@ -1071,7 +1072,7 @@ struct pgt_info *hl_mmu_hr_alloc_hop(struct hl_ctx *ctx, struct hl_mmu_hr_priv *
void *virt_addr;
int i, retry = 1;
- pgt_info = kmalloc(sizeof(*pgt_info), GFP_KERNEL);
+ pgt_info = kmalloc_obj(*pgt_info, GFP_KERNEL);
if (!pgt_info)
return NULL;
@@ -1325,7 +1326,7 @@ u64 hl_mmu_dr_alloc_hop(struct hl_ctx *ctx)
struct pgt_info *pgt_info;
u64 phys_addr, shadow_addr;
- pgt_info = kmalloc(sizeof(*pgt_info), GFP_KERNEL);
+ pgt_info = kmalloc_obj(*pgt_info, GFP_KERNEL);
if (!pgt_info)
return ULLONG_MAX;
diff --git a/drivers/accel/habanalabs/common/security.c b/drivers/accel/habanalabs/common/security.c
index 5402a3cd0491..8a0da0194cab 100644
--- a/drivers/accel/habanalabs/common/security.c
+++ b/drivers/accel/habanalabs/common/security.c
@@ -312,9 +312,8 @@ int hl_init_pb_with_mask(struct hl_device *hdev, u32 num_dcores,
int i, j;
struct hl_block_glbl_sec *glbl_sec;
- glbl_sec = kcalloc(blocks_array_size,
- sizeof(struct hl_block_glbl_sec),
- GFP_KERNEL);
+ glbl_sec = kzalloc_objs(struct hl_block_glbl_sec, blocks_array_size,
+ GFP_KERNEL);
if (!glbl_sec)
return -ENOMEM;
@@ -393,9 +392,8 @@ int hl_init_pb_ranges_with_mask(struct hl_device *hdev, u32 num_dcores,
int i, j, rc = 0;
struct hl_block_glbl_sec *glbl_sec;
- glbl_sec = kcalloc(blocks_array_size,
- sizeof(struct hl_block_glbl_sec),
- GFP_KERNEL);
+ glbl_sec = kzalloc_objs(struct hl_block_glbl_sec, blocks_array_size,
+ GFP_KERNEL);
if (!glbl_sec)
return -ENOMEM;
@@ -476,9 +474,8 @@ int hl_init_pb_single_dcore(struct hl_device *hdev, u32 dcore_offset,
int i, rc = 0;
struct hl_block_glbl_sec *glbl_sec;
- glbl_sec = kcalloc(blocks_array_size,
- sizeof(struct hl_block_glbl_sec),
- GFP_KERNEL);
+ glbl_sec = kzalloc_objs(struct hl_block_glbl_sec, blocks_array_size,
+ GFP_KERNEL);
if (!glbl_sec)
return -ENOMEM;
@@ -524,9 +521,8 @@ int hl_init_pb_ranges_single_dcore(struct hl_device *hdev, u32 dcore_offset,
int i;
struct hl_block_glbl_sec *glbl_sec;
- glbl_sec = kcalloc(blocks_array_size,
- sizeof(struct hl_block_glbl_sec),
- GFP_KERNEL);
+ glbl_sec = kzalloc_objs(struct hl_block_glbl_sec, blocks_array_size,
+ GFP_KERNEL);
if (!glbl_sec)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/common/state_dump.c b/drivers/accel/habanalabs/common/state_dump.c
index 3a9931f24259..ec25d55d89e2 100644
--- a/drivers/accel/habanalabs/common/state_dump.c
+++ b/drivers/accel/habanalabs/common/state_dump.c
@@ -400,7 +400,7 @@ static int hl_state_dump_print_syncs(struct hl_device *hdev,
u32 index;
int rc = 0;
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (!map)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/gaudi/gaudi.c b/drivers/accel/habanalabs/gaudi/gaudi.c
index 34771d75da9d..e7dce0d57692 100644
--- a/drivers/accel/habanalabs/gaudi/gaudi.c
+++ b/drivers/accel/habanalabs/gaudi/gaudi.c
@@ -539,9 +539,8 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev)
int i;
prop->max_queues = GAUDI_QUEUE_ID_SIZE;
- prop->hw_queues_props = kcalloc(prop->max_queues,
- sizeof(struct hw_queue_properties),
- GFP_KERNEL);
+ prop->hw_queues_props = kzalloc_objs(struct hw_queue_properties,
+ prop->max_queues, GFP_KERNEL);
if (!prop->hw_queues_props)
return -ENOMEM;
@@ -1853,7 +1852,7 @@ static int gaudi_sw_init(struct hl_device *hdev)
int rc;
/* Allocate device structure */
- gaudi = kzalloc(sizeof(*gaudi), GFP_KERNEL);
+ gaudi = kzalloc_obj(*gaudi, GFP_KERNEL);
if (!gaudi)
return -ENOMEM;
@@ -4906,7 +4905,7 @@ static int gaudi_pin_memory_before_cs(struct hl_device *hdev,
parser->job_userptr_list, &userptr))
goto already_pinned;
- userptr = kzalloc(sizeof(*userptr), GFP_KERNEL);
+ userptr = kzalloc_obj(*userptr, GFP_KERNEL);
if (!userptr)
return -ENOMEM;
@@ -8843,7 +8842,7 @@ static int gaudi_add_sync_to_engine_map_entry(
reg_value -= lower_32_bits(CFG_BASE);
/* create a new hash entry */
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
entry->engine_type = engine_type;
diff --git a/drivers/accel/habanalabs/gaudi2/gaudi2.c b/drivers/accel/habanalabs/gaudi2/gaudi2.c
index b8c0689dba64..e6690698cde4 100644
--- a/drivers/accel/habanalabs/gaudi2/gaudi2.c
+++ b/drivers/accel/habanalabs/gaudi2/gaudi2.c
@@ -2762,8 +2762,8 @@ static int gaudi2_set_fixed_properties(struct hl_device *hdev)
int i, rc;
prop->max_queues = GAUDI2_QUEUE_ID_SIZE;
- prop->hw_queues_props = kcalloc(prop->max_queues, sizeof(struct hw_queue_properties),
- GFP_KERNEL);
+ prop->hw_queues_props = kzalloc_objs(struct hw_queue_properties,
+ prop->max_queues, GFP_KERNEL);
if (!prop->hw_queues_props)
return -ENOMEM;
@@ -3943,8 +3943,9 @@ static int gaudi2_special_blocks_config(struct hl_device *hdev)
/* Configure Special blocks */
prop->glbl_err_max_cause_num = GAUDI2_GLBL_ERR_MAX_CAUSE_NUM;
prop->num_of_special_blocks = ARRAY_SIZE(gaudi2_special_blocks);
- prop->special_blocks = kmalloc_array(prop->num_of_special_blocks,
- sizeof(*prop->special_blocks), GFP_KERNEL);
+ prop->special_blocks = kmalloc_objs(*prop->special_blocks,
+ prop->num_of_special_blocks,
+ GFP_KERNEL);
if (!prop->special_blocks)
return -ENOMEM;
@@ -3958,8 +3959,9 @@ static int gaudi2_special_blocks_config(struct hl_device *hdev)
if (ARRAY_SIZE(gaudi2_iterator_skip_block_types)) {
prop->skip_special_blocks_cfg.block_types =
- kmalloc_array(ARRAY_SIZE(gaudi2_iterator_skip_block_types),
- sizeof(gaudi2_iterator_skip_block_types[0]), GFP_KERNEL);
+ kmalloc_objs(gaudi2_iterator_skip_block_types[0],
+ ARRAY_SIZE(gaudi2_iterator_skip_block_types),
+ GFP_KERNEL);
if (!prop->skip_special_blocks_cfg.block_types) {
rc = -ENOMEM;
goto free_special_blocks;
@@ -3974,8 +3976,9 @@ static int gaudi2_special_blocks_config(struct hl_device *hdev)
if (ARRAY_SIZE(gaudi2_iterator_skip_block_ranges)) {
prop->skip_special_blocks_cfg.block_ranges =
- kmalloc_array(ARRAY_SIZE(gaudi2_iterator_skip_block_ranges),
- sizeof(gaudi2_iterator_skip_block_ranges[0]), GFP_KERNEL);
+ kmalloc_objs(gaudi2_iterator_skip_block_ranges[0],
+ ARRAY_SIZE(gaudi2_iterator_skip_block_ranges),
+ GFP_KERNEL);
if (!prop->skip_special_blocks_cfg.block_ranges) {
rc = -ENOMEM;
goto free_skip_special_blocks_types;
@@ -4054,7 +4057,7 @@ static int gaudi2_sw_init(struct hl_device *hdev)
int i, rc;
/* Allocate device structure */
- gaudi2 = kzalloc(sizeof(*gaudi2), GFP_KERNEL);
+ gaudi2 = kzalloc_obj(*gaudi2, GFP_KERNEL);
if (!gaudi2)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/gaudi2/gaudi2_security.c b/drivers/accel/habanalabs/gaudi2/gaudi2_security.c
index 307ccb912ccd..f4f8f9122f5c 100644
--- a/drivers/accel/habanalabs/gaudi2/gaudi2_security.c
+++ b/drivers/accel/habanalabs/gaudi2/gaudi2_security.c
@@ -2620,7 +2620,8 @@ static int gaudi2_init_pb_tpc(struct hl_device *hdev)
block_array_size = ARRAY_SIZE(gaudi2_pb_dcr0_tpc0);
- glbl_sec = kcalloc(block_array_size, sizeof(struct hl_block_glbl_sec), GFP_KERNEL);
+ glbl_sec = kzalloc_objs(struct hl_block_glbl_sec, block_array_size,
+ GFP_KERNEL);
if (!glbl_sec)
return -ENOMEM;
diff --git a/drivers/accel/habanalabs/goya/goya.c b/drivers/accel/habanalabs/goya/goya.c
index 84768e306269..fb37a2339f12 100644
--- a/drivers/accel/habanalabs/goya/goya.c
+++ b/drivers/accel/habanalabs/goya/goya.c
@@ -363,9 +363,8 @@ int goya_set_fixed_properties(struct hl_device *hdev)
int i;
prop->max_queues = GOYA_QUEUE_ID_SIZE;
- prop->hw_queues_props = kcalloc(prop->max_queues,
- sizeof(struct hw_queue_properties),
- GFP_KERNEL);
+ prop->hw_queues_props = kzalloc_objs(struct hw_queue_properties,
+ prop->max_queues, GFP_KERNEL);
if (!prop->hw_queues_props)
return -ENOMEM;
@@ -970,7 +969,7 @@ static int goya_sw_init(struct hl_device *hdev)
int rc;
/* Allocate device structure */
- goya = kzalloc(sizeof(*goya), GFP_KERNEL);
+ goya = kzalloc_obj(*goya, GFP_KERNEL);
if (!goya)
return -ENOMEM;
@@ -1031,7 +1030,7 @@ static int goya_sw_init(struct hl_device *hdev)
hdev->asic_funcs->set_pci_memory_regions(hdev);
- goya->goya_work = kmalloc(sizeof(struct goya_work_freq), GFP_KERNEL);
+ goya->goya_work = kmalloc_obj(struct goya_work_freq, GFP_KERNEL);
if (!goya->goya_work) {
rc = -ENOMEM;
goto free_cpu_accessible_dma_pool;
@@ -3336,7 +3335,7 @@ static int goya_pin_memory_before_cs(struct hl_device *hdev,
parser->job_userptr_list, &userptr))
goto already_pinned;
- userptr = kzalloc(sizeof(*userptr), GFP_KERNEL);
+ userptr = kzalloc_obj(*userptr, GFP_KERNEL);
if (!userptr)
return -ENOMEM;
diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
index 8ffda57459df..ab910d201e68 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -237,7 +237,7 @@ static int ivpu_open(struct drm_device *dev, struct drm_file *file)
if (!drm_dev_enter(dev, &idx))
return -ENODEV;
- file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
+ file_priv = kzalloc_obj(*file_priv, GFP_KERNEL);
if (!file_priv) {
ret = -ENOMEM;
goto err_dev_exit;
diff --git a/drivers/accel/ivpu/ivpu_gem_userptr.c b/drivers/accel/ivpu/ivpu_gem_userptr.c
index 25ba606164c0..7dcd127471bb 100644
--- a/drivers/accel/ivpu/ivpu_gem_userptr.c
+++ b/drivers/accel/ivpu/ivpu_gem_userptr.c
@@ -77,7 +77,7 @@ ivpu_create_userptr_dmabuf(struct ivpu_device *vdev, void __user *user_ptr,
if (!(flags & DRM_IVPU_BO_READ_ONLY))
gup_flags |= FOLL_WRITE;
- pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
+ pages = kvmalloc_objs(*pages, nr_pages, GFP_KERNEL);
if (!pages)
return ERR_PTR(-ENOMEM);
@@ -94,7 +94,7 @@ ivpu_create_userptr_dmabuf(struct ivpu_device *vdev, void __user *user_ptr,
goto unpin_pages;
}
- sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
+ sgt = kmalloc_obj(*sgt, GFP_KERNEL);
if (!sgt) {
ret = -ENOMEM;
goto unpin_pages;
diff --git a/drivers/accel/ivpu/ivpu_ipc.c b/drivers/accel/ivpu/ivpu_ipc.c
index 1f13bf95b2b3..f47df092bb0d 100644
--- a/drivers/accel/ivpu/ivpu_ipc.c
+++ b/drivers/accel/ivpu/ivpu_ipc.c
@@ -142,7 +142,7 @@ ivpu_ipc_rx_msg_add(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
lockdep_assert_held(&ipc->cons_lock);
- rx_msg = kzalloc(sizeof(*rx_msg), GFP_ATOMIC);
+ rx_msg = kzalloc_obj(*rx_msg, GFP_ATOMIC);
if (!rx_msg) {
ivpu_ipc_rx_mark_free(vdev, ipc_hdr, jsm_msg);
return;
diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
index 4f8564e2878a..cb478d946ae9 100644
--- a/drivers/accel/ivpu/ivpu_job.c
+++ b/drivers/accel/ivpu/ivpu_job.c
@@ -98,7 +98,7 @@ static struct ivpu_cmdq *ivpu_cmdq_alloc(struct ivpu_file_priv *file_priv)
struct ivpu_device *vdev = file_priv->vdev;
struct ivpu_cmdq *cmdq;
- cmdq = kzalloc(sizeof(*cmdq), GFP_KERNEL);
+ cmdq = kzalloc_obj(*cmdq, GFP_KERNEL);
if (!cmdq)
return NULL;
@@ -491,7 +491,7 @@ static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
{
struct ivpu_fence *fence;
- fence = kzalloc(sizeof(*fence), GFP_KERNEL);
+ fence = kzalloc_obj(*fence, GFP_KERNEL);
if (!fence)
return NULL;
@@ -525,7 +525,7 @@ ivpu_job_create(struct ivpu_file_priv *file_priv, u32 engine_idx, u32 bo_count)
struct ivpu_device *vdev = file_priv->vdev;
struct ivpu_job *job;
- job = kzalloc(struct_size(job, bos, bo_count), GFP_KERNEL);
+ job = kzalloc_flex(*job, bos, bo_count, GFP_KERNEL);
if (!job)
return NULL;
diff --git a/drivers/accel/ivpu/ivpu_ms.c b/drivers/accel/ivpu/ivpu_ms.c
index 1d9c1cb17924..f3468c9533ca 100644
--- a/drivers/accel/ivpu/ivpu_ms.c
+++ b/drivers/accel/ivpu/ivpu_ms.c
@@ -59,7 +59,7 @@ int ivpu_ms_start_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
goto unlock;
}
- ms = kzalloc(sizeof(*ms), GFP_KERNEL);
+ ms = kzalloc_obj(*ms, GFP_KERNEL);
if (!ms) {
ret = -ENOMEM;
goto unlock;
diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c
index 428d8f65bff3..517cd3a9cab2 100644
--- a/drivers/accel/qaic/qaic_control.c
+++ b/drivers/accel/qaic/qaic_control.c
@@ -423,7 +423,8 @@ static int find_and_map_user_pages(struct qaic_device *qdev,
nr_pages = need_pages;
while (1) {
- page_list = kmalloc_array(nr_pages, sizeof(*page_list), GFP_KERNEL | __GFP_NOWARN);
+ page_list = kmalloc_objs(*page_list, nr_pages,
+ GFP_KERNEL | __GFP_NOWARN);
if (!page_list) {
nr_pages = nr_pages / 2;
if (!nr_pages)
@@ -442,7 +443,7 @@ static int find_and_map_user_pages(struct qaic_device *qdev,
goto put_pages;
}
- sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
+ sgt = kmalloc_obj(*sgt, GFP_KERNEL);
if (!sgt) {
ret = -ENOMEM;
goto put_pages;
@@ -581,7 +582,7 @@ static int encode_dma(struct qaic_device *qdev, void *trans, struct wrapper_list
QAIC_MANAGE_WIRE_MSG_LENGTH)
return -ENOMEM;
- xfer = kmalloc(sizeof(*xfer), GFP_KERNEL);
+ xfer = kmalloc_obj(*xfer, GFP_KERNEL);
if (!xfer)
return -ENOMEM;
@@ -1165,7 +1166,7 @@ static struct wrapper_list *alloc_wrapper_list(void)
{
struct wrapper_list *wrappers;
- wrappers = kmalloc(sizeof(*wrappers), GFP_KERNEL);
+ wrappers = kmalloc_obj(*wrappers, GFP_KERNEL);
if (!wrappers)
return NULL;
INIT_LIST_HEAD(&wrappers->list);
@@ -1457,7 +1458,7 @@ void qaic_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_resu
return;
}
- resp = kmalloc(sizeof(*resp), GFP_ATOMIC);
+ resp = kmalloc_obj(*resp, GFP_ATOMIC);
if (!resp) {
kfree(msg);
return;
diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index 60cb4d65d48e..6405f849ad5f 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -213,7 +213,7 @@ static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_tabl
goto out;
}
- sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
+ sgt = kzalloc_obj(*sgt, GFP_KERNEL);
if (!sgt) {
ret = -ENOMEM;
goto out;
@@ -399,13 +399,13 @@ static int qaic_map_one_slice(struct qaic_device *qdev, struct qaic_bo *bo,
if (ret)
goto out;
- slice = kmalloc(sizeof(*slice), GFP_KERNEL);
+ slice = kmalloc_obj(*slice, GFP_KERNEL);
if (!slice) {
ret = -ENOMEM;
goto free_sgt;
}
- slice->reqs = kvcalloc(sgt->nents, sizeof(*slice->reqs), GFP_KERNEL);
+ slice->reqs = kvzalloc_objs(*slice->reqs, sgt->nents, GFP_KERNEL);
if (!slice->reqs) {
ret = -ENOMEM;
goto free_slice;
@@ -507,7 +507,7 @@ static int create_sgt(struct qaic_device *qdev, struct sg_table **sgt_out, u64 s
i++;
}
- sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
+ sgt = kmalloc_obj(*sgt, GFP_KERNEL);
if (!sgt) {
ret = -ENOMEM;
goto free_partial_alloc;
@@ -653,7 +653,7 @@ static struct sg_table *qaic_get_sg_table(struct drm_gem_object *obj)
sgt_in = bo->sgt;
- sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
+ sgt = kmalloc_obj(*sgt, GFP_KERNEL);
if (!sgt)
return ERR_PTR(-ENOMEM);
@@ -697,7 +697,7 @@ static struct qaic_bo *qaic_alloc_init_bo(void)
{
struct qaic_bo *bo;
- bo = kzalloc(sizeof(*bo), GFP_KERNEL);
+ bo = kzalloc_obj(*bo, GFP_KERNEL);
if (!bo)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c
index 4c70bd949d53..7127364068ae 100644
--- a/drivers/accel/qaic/qaic_drv.c
+++ b/drivers/accel/qaic/qaic_drv.c
@@ -152,7 +152,7 @@ static int qaic_open(struct drm_device *dev, struct drm_file *file)
goto dev_unlock;
}
- usr = kmalloc(sizeof(*usr), GFP_KERNEL);
+ usr = kmalloc_obj(*usr, GFP_KERNEL);
if (!usr) {
ret = -ENOMEM;
goto dev_unlock;
diff --git a/drivers/accel/qaic/qaic_ras.c b/drivers/accel/qaic/qaic_ras.c
index f1d52a710136..b488e6ef66c5 100644
--- a/drivers/accel/qaic/qaic_ras.c
+++ b/drivers/accel/qaic/qaic_ras.c
@@ -556,7 +556,7 @@ static int qaic_ras_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_devic
if (ret)
return ret;
- resp = kzalloc(sizeof(*resp), GFP_KERNEL);
+ resp = kzalloc_obj(*resp, GFP_KERNEL);
if (!resp) {
mhi_unprepare_from_transfer(mhi_dev);
return -ENOMEM;
diff --git a/drivers/accel/qaic/qaic_ssr.c b/drivers/accel/qaic/qaic_ssr.c
index 9b662d690371..77ac30498ad0 100644
--- a/drivers/accel/qaic/qaic_ssr.c
+++ b/drivers/accel/qaic/qaic_ssr.c
@@ -260,7 +260,7 @@ static int send_xfer_done(struct qaic_device *qdev, void *resp, u32 dbc_id)
struct ssr_debug_transfer_done *xfer_done;
int ret;
- xfer_done = kmalloc(sizeof(*xfer_done), GFP_KERNEL);
+ xfer_done = kmalloc_obj(*xfer_done, GFP_KERNEL);
if (!xfer_done) {
ret = -ENOMEM;
goto out;
@@ -450,14 +450,15 @@ static struct ssr_dump_info *alloc_dump_info(struct qaic_device *qdev,
}
/* Allocate SSR crashdump book keeping structure */
- dump_info = kzalloc(sizeof(*dump_info), GFP_KERNEL);
+ dump_info = kzalloc_obj(*dump_info, GFP_KERNEL);
if (!dump_info) {
ret = -ENOMEM;
goto out;
}
/* Buffer used to send MEMORY READ request to device via MHI */
- dump_info->read_buf_req = kzalloc(sizeof(*dump_info->read_buf_req), GFP_KERNEL);
+ dump_info->read_buf_req = kzalloc_obj(*dump_info->read_buf_req,
+ GFP_KERNEL);
if (!dump_info->read_buf_req) {
ret = -ENOMEM;
goto free_dump_info;
@@ -490,7 +491,7 @@ static int dbg_xfer_info_rsp(struct qaic_device *qdev, struct dma_bridge_chan *d
struct ssr_crashdump *ssr_crash = NULL;
int ret = 0, ret2;
- debug_rsp = kmalloc(sizeof(*debug_rsp), GFP_KERNEL);
+ debug_rsp = kmalloc_obj(*debug_rsp, GFP_KERNEL);
if (!debug_rsp)
return -ENOMEM;
@@ -640,7 +641,7 @@ static void ssr_worker(struct work_struct *work)
break;
}
- event_rsp = kmalloc(sizeof(*event_rsp), GFP_KERNEL);
+ event_rsp = kmalloc_obj(*event_rsp, GFP_KERNEL);
if (!event_rsp)
break;
diff --git a/drivers/accel/qaic/qaic_timesync.c b/drivers/accel/qaic/qaic_timesync.c
index 8af2475f4f36..b2400d6b2f4f 100644
--- a/drivers/accel/qaic/qaic_timesync.c
+++ b/drivers/accel/qaic/qaic_timesync.c
@@ -185,7 +185,7 @@ static int qaic_timesync_probe(struct mhi_device *mhi_dev, const struct mhi_devi
struct timer_list *timer;
int ret;
- mqtsdev = kzalloc(sizeof(*mqtsdev), GFP_KERNEL);
+ mqtsdev = kzalloc_obj(*mqtsdev, GFP_KERNEL);
if (!mqtsdev) {
ret = -ENOMEM;
goto out;
@@ -196,7 +196,7 @@ static int qaic_timesync_probe(struct mhi_device *mhi_dev, const struct mhi_devi
mqtsdev->qdev = qdev;
mqtsdev->dev = &qdev->pdev->dev;
- mqtsdev->sync_msg = kzalloc(sizeof(*mqtsdev->sync_msg), GFP_KERNEL);
+ mqtsdev->sync_msg = kzalloc_obj(*mqtsdev->sync_msg, GFP_KERNEL);
if (!mqtsdev->sync_msg) {
ret = -ENOMEM;
goto free_mqts_dev;
@@ -275,7 +275,7 @@ static void qaic_boot_timesync_worker(struct work_struct *work)
switch (data.hdr.msg_type) {
case QAIC_TS_CMD_TO_HOST:
- req = kzalloc(sizeof(*req), GFP_KERNEL);
+ req = kzalloc_obj(*req, GFP_KERNEL);
if (!req)
break;
@@ -304,7 +304,7 @@ static int qaic_boot_timesync_queue_resp(struct mhi_device *mhi_dev, struct qaic
struct qts_resp *resp;
int ret;
- resp = kzalloc(sizeof(*resp), GFP_KERNEL);
+ resp = kzalloc_obj(*resp, GFP_KERNEL);
if (!resp)
return -ENOMEM;
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
index e4cb2efeb55a..f09c3800ab31 100644
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -38,7 +38,7 @@ rocket_iommu_domain_destroy(struct kref *kref)
static struct rocket_iommu_domain*
rocket_iommu_domain_create(struct device *dev)
{
- struct rocket_iommu_domain *domain = kmalloc(sizeof(*domain), GFP_KERNEL);
+ struct rocket_iommu_domain *domain = kmalloc_obj(*domain, GFP_KERNEL);
void *err;
if (!domain)
@@ -79,7 +79,7 @@ rocket_open(struct drm_device *dev, struct drm_file *file)
if (!try_module_get(THIS_MODULE))
return -EINVAL;
- rocket_priv = kzalloc(sizeof(*rocket_priv), GFP_KERNEL);
+ rocket_priv = kzalloc_obj(*rocket_priv, GFP_KERNEL);
if (!rocket_priv) {
ret = -ENOMEM;
goto err_put_mod;
diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index 624c4ecf5a34..3808dfc97916 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -48,7 +48,7 @@ struct drm_gem_object *rocket_gem_create_object(struct drm_device *dev, size_t s
{
struct rocket_gem_object *obj;
- obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+ obj = kzalloc_obj(*obj, GFP_KERNEL);
if (!obj)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index acd606160dc9..518dd5779016 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -45,7 +45,7 @@ static struct dma_fence *rocket_fence_create(struct rocket_core *core)
{
struct dma_fence *fence;
- fence = kzalloc(sizeof(*fence), GFP_KERNEL);
+ fence = kzalloc_obj(*fence, GFP_KERNEL);
if (!fence)
return ERR_PTR(-ENOMEM);
@@ -71,7 +71,7 @@ rocket_copy_tasks(struct drm_device *dev,
if (!rjob->task_count)
return 0;
- rjob->tasks = kvmalloc_array(job->task_count, sizeof(*rjob->tasks), GFP_KERNEL);
+ rjob->tasks = kvmalloc_objs(*rjob->tasks, job->task_count, GFP_KERNEL);
if (!rjob->tasks) {
drm_dbg(dev, "Failed to allocate task array\n");
return -ENOMEM;
@@ -496,9 +496,9 @@ void rocket_job_fini(struct rocket_core *core)
int rocket_job_open(struct rocket_file_priv *rocket_priv)
{
struct rocket_device *rdev = rocket_priv->rdev;
- struct drm_gpu_scheduler **scheds = kmalloc_array(rdev->num_cores,
- sizeof(*scheds),
- GFP_KERNEL);
+ struct drm_gpu_scheduler **scheds = kmalloc_objs(*scheds,
+ rdev->num_cores,
+ GFP_KERNEL);
unsigned int core;
int ret;
@@ -543,7 +543,7 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
if (job->task_count == 0)
return -EINVAL;
- rjob = kzalloc(sizeof(*rjob), GFP_KERNEL);
+ rjob = kzalloc_obj(*rjob, GFP_KERNEL);
if (!rjob)
return -ENOMEM;
@@ -610,7 +610,7 @@ int rocket_ioctl_submit(struct drm_device *dev, void *data, struct drm_file *fil
return -EINVAL;
}
- jobs = kvmalloc_array(args->job_count, sizeof(*jobs), GFP_KERNEL);
+ jobs = kvmalloc_objs(*jobs, args->job_count, GFP_KERNEL);
if (!jobs) {
drm_dbg(dev, "Failed to allocate incoming job array\n");
return -ENOMEM;