Qianfeng Rong
2025-Aug-16 14:38 UTC
[PATCH 0/2] drm: Use vmalloc_array and vcalloc to simplify code
Remove array_size() calls and replace vmalloc() and vzalloc() with vmalloc_array() and vcalloc() respectively to simplify the code. vmalloc_array() is also optimized better, resulting in less instructions being used [1]. [1]: https://lore.kernel.org/lkml/abc66ec5-85a4-47e1-9759-2f60ab111971 at vivo.com/ Qianfeng Rong (2): drm/nouveau: Use vmalloc_array to simplify code drm/radeon: Use vmalloc_array and vcalloc to simplify code drivers/gpu/drm/nouveau/nv84_fence.c | 2 +- drivers/gpu/drm/radeon/radeon_gart.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.34.1
Qianfeng Rong
2025-Aug-16 14:38 UTC
[PATCH 1/2] drm/nouveau: Use vmalloc_array to simplify code
Use vmalloc_array() instead of vmalloc() to simplify the functions
nv84_fence_suspend().
vmalloc_array() is also optimized better, resulting in less instructions
being used.
Signed-off-by: Qianfeng Rong <rongqianfeng at vivo.com>
---
drivers/gpu/drm/nouveau/nv84_fence.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c
b/drivers/gpu/drm/nouveau/nv84_fence.c
index 1765b2cedaf9..63a477e631ae 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -158,7 +158,7 @@ nv84_fence_suspend(struct nouveau_drm *drm)
struct nv84_fence_priv *priv = drm->fence;
int i;
- priv->suspend = vmalloc(array_size(sizeof(u32), drm->chan_total));
+ priv->suspend = vmalloc_array(drm->chan_total, sizeof(u32));
if (priv->suspend) {
for (i = 0; i < drm->chan_total; i++)
priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4);
--
2.34.1