]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: amphion: Use kmalloc instead of vmalloc
authorMing Qian <ming.qian@oss.nxp.com>
Mon, 22 Dec 2025 08:49:10 +0000 (16:49 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 13 Jan 2026 08:41:59 +0000 (09:41 +0100)
commitd79c2165a48e87fc21136c323cb7822da69f8691
tree259b9ebebda0354d66e0d887e5c3a6d257e9d8e6
parentbb22847d1134723d6ed67ef0aaeb44c6af53e3da
media: amphion: Use kmalloc instead of vmalloc

Replace vmalloc/vfree with kmalloc/kfree for allocating small
driver structures (vpu_inst, vdec_t, venc_t, vpu_cmd_t, and
frame objects).

vmalloc() is designed for large memory allocations and incurs
unnecessary overhead for small objects due to virtual memory
mapping. kmalloc() is more appropriate as it allocates physically
contiguous memory with lower overhead.

ftrace measurements of vpu_alloc_cmd() show significant improvement:

  Before (vmalloc):  35-72 us   (avg ~45.7 us)
  After (kmalloc):   11-26 us   (avg ~16.8 us)

This reduces allocation time by approximately 63%.

No functional changes are intended.

Signed-off-by: Ming Qian <ming.qian@oss.nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/amphion/vdec.c
drivers/media/platform/amphion/venc.c
drivers/media/platform/amphion/vpu_cmds.c
drivers/media/platform/amphion/vpu_core.c