firmware: cs_dsp: Use kvzalloc() to allocate control caches
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 27 Nov 2025 10:39:47 +0000 (10:39 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 27 Nov 2025 11:41:23 +0000 (11:41 +0000)
Use kvzalloc() instead of kzalloc() to allocate memory to cache the
content of a firmware control.

Most firmware controls are only small, typically a few bytes. But on
some firmware there can be much larger controls for coefficient or
model data.

The overhead of kvzalloc() is negligible because most control allocs
can be satisfied by the normal kmalloc() that kvzalloc() will try first.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20251127103947.1094934-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/firmware/cirrus/cs_dsp.c

index 216d298..60a2061 100644 (file)
@@ -989,7 +989,7 @@ static void cs_dsp_signal_event_controls(struct cs_dsp *dsp,
 
 static void cs_dsp_free_ctl_blk(struct cs_dsp_coeff_ctl *ctl)
 {
-       kfree(ctl->cache);
+       kvfree(ctl->cache);
        kfree(ctl->subname);
        kfree(ctl);
 }
@@ -1039,7 +1039,7 @@ static int cs_dsp_create_control(struct cs_dsp *dsp,
        ctl->type = type;
        ctl->offset = offset;
        ctl->len = len;
-       ctl->cache = kzalloc(ctl->len, GFP_KERNEL);
+       ctl->cache = kvzalloc(ctl->len, GFP_KERNEL);
        if (!ctl->cache) {
                ret = -ENOMEM;
                goto err_ctl_subname;
@@ -1057,7 +1057,7 @@ static int cs_dsp_create_control(struct cs_dsp *dsp,
 
 err_list_del:
        list_del(&ctl->list);
-       kfree(ctl->cache);
+       kvfree(ctl->cache);
 err_ctl_subname:
        kfree(ctl->subname);
 err_ctl: