From 4b0be5d855d1244f0438842caddbcfc4d54ee3f1 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 23:38:25 +1100 Subject: [PATCH] media: apple: avd: repair the VP9 host control fixture The VP9 decoder copies request controls under the V4L2 control lock. Provide lock and allocation shims so the standalone host test builds. Exercise the busy-bank check through avd_vp9_run() so it also checks the production cleanup path under the sanitizers. Signed-off-by: Ryan Murray --- .../platform/apple/avd/tests/vp9-test.py | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/apple/avd/tests/vp9-test.py b/drivers/media/platform/apple/avd/tests/vp9-test.py index c6ccf836b4636..0ea406aae1777 100644 --- a/drivers/media/platform/apple/avd/tests/vp9-test.py +++ b/drivers/media/platform/apple/avd/tests/vp9-test.py @@ -59,7 +59,7 @@ enum vb2_buffer_state { STATE_DUMMY }; #define dev_err(d,...) ((void)(d)) #define kzalloc(n,f) calloc(1,n) -#define kfree free +#define kfree(p) free((void *)(p)) static bool vp_feature = true; static bool avd_qfw_has_vp_done(const struct avd_dev *d) { return d->queued && vp_feature; } static bool avd_backend_is_open(const struct avd_dev *d) { return !d->queued; } @@ -72,6 +72,32 @@ static struct v4l2_ctrl_vp9_frame params; static struct v4l2_ctrl_vp9_compressed_hdr updates; static struct v4l2_ctrl frame_ctrl,update_ctrl; +static struct v4l2_ctrl *locked_ctrl; + +static void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl) +{ + assert(!locked_ctrl); + locked_ctrl = ctrl; +} + +static void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl) +{ + assert(locked_ctrl == ctrl); + locked_ctrl = NULL; +} + +static void *kmemdup(const void *source, size_t size, int flags) +{ + void *copy; + + (void)flags; + assert(locked_ctrl); + copy = malloc(size); + if (copy) + memcpy(copy, source, size); + return copy; +} + static struct v4l2_ctrl *v4l2_ctrl_find(void *h,u32 id) { (void)h;frame_ctrl.p_cur.p=¶ms;update_ctrl.p_cur.p=&updates; return id==V4L2_CID_STATELESS_VP9_FRAME?&frame_ctrl:&update_ctrl; @@ -184,8 +210,7 @@ def without_includes(s): assert(!memcmp(&adapted,&p->bank[1].probability_tables,sizeof(adapted))); write_program(argv[1],"vp9-adaptive-1",&frame); assert(!avd_vp9_ready(&ctx)); - struct avd_vp9_run attempt; - current_dst=&dst[2].base.vb;assert(avd_vp9_run_preamble(&ctx,&attempt)==-EBUSY);assert(!dst[2].bank); + current_dst=&dst[2].base.vb;assert(avd_vp9_run(&ctx)==-EBUSY);assert(!dst[2].bank); /* PP(0) retires while b points to bank 1: only bank 0 may be released. */ avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE); assert(!p->bank[0].busy&&p->bank[1].busy&&!dst[0].bank);