Hi Angelo, Thanks for your suggestion. On Tue, 2022-12-13 at 10:09 +0100, AngeloGioacchino Del Regno wrote: > Il 10/12/22 08:32, Yunfei Dong ha scritto: > > Using lat_buf to share decoder information between lat and core > > work > > queue, adding params to record the buf count. > > > > Fixes: 365e4ba01df4 ("media: mtk-vcodec: Add work queue for core > > hardware decode") > > Signed-off-by: Yunfei Dong <yunfei.dong@xxxxxxxxxxxx> > > --- > > .../platform/mediatek/vcodec/vdec_msg_queue.c | 32 > > ++++++++++++++++++- > > .../platform/mediatek/vcodec/vdec_msg_queue.h | 9 ++++++ > > 2 files changed, 40 insertions(+), 1 deletion(-) > > > > diff --git > > a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c > > b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c > > index dc2004790a47..af7ddba1923a 100644 > > --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c > > +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c > > @@ -52,6 +52,30 @@ static struct list_head *vdec_get_buf_list(int > > hardware_index, struct vdec_lat_b > > } > > } > > > > +static void vdec_msg_queue_inc(struct vdec_msg_queue *msg_queue, > > int hardware_index) > > +{ > > + mutex_lock(&msg_queue->list_cnt_mutex); > > I doubt that you need to use this mutex, as you're using atomics... > Can be removed. > > + > > + if (hardware_index == MTK_VDEC_CORE) > > + atomic_inc(&msg_queue->core_list_cnt); > > + else > > + atomic_inc(&msg_queue->lat_list_cnt); > > + > > This branch (with the relevant appropriate changes) can be simplified > as > > atomic_inc(&msg_queue->list_cnt[hardware_index]); > > ...where list_cnt is an array, and hardware_index is an enumeration. > Only use lat and core, no need to using a array for every hardware. Best Regards, Yunfei Dong > > + mutex_unlock(&msg_queue->list_cnt_mutex); > > +} > > + > > +static void vdec_msg_queue_dec(struct vdec_msg_queue *msg_queue, > > int hardware_index) > > +{ > > + mutex_lock(&msg_queue->list_cnt_mutex); > > + > > + if (hardware_index == MTK_VDEC_CORE) > > + atomic_dec(&msg_queue->core_list_cnt); > > + else > > + atomic_dec(&msg_queue->lat_list_cnt); > > Same here. > > > + > > + mutex_unlock(&msg_queue->list_cnt_mutex); > > +} > > + > > Regards, > Angelo >