Skip to content

Commit 97a48d1

Browse files
committed
Merge tag 'media/v7.0-5' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab: - rkvdec: fix stack usage with clang and improve handling missing short/long term RPS - synopsys: fix a Kconfig issue and an out-of-bounds check - verisilicon: Fix kernel panic due to __initconst misuse - media core: serialize REINIT and REQBUFS with req_queue_mutex * tag 'media/v7.0-5' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: verisilicon: Fix kernel panic due to __initconst misuse media: rkvdec: reduce stack usage in rkvdec_init_v4l2_vp9_count_tbl() media: rkvdec: reduce excessive stack usage in assemble_hw_pps() media: rkvdec: Improve handling missing short/long term RPS media: mc, v4l2: serialize REINIT and REQBUFS with req_queue_mutex media: synopsys: csi2rx: add missing kconfig dependency media: synopsys: csi2rx: fix out-of-bounds check for formats array
2 parents a012435 + e8d97c2 commit 97a48d1

8 files changed

Lines changed: 44 additions & 28 deletions

File tree

drivers/media/mc/mc-request.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,24 @@ static long media_request_ioctl_reinit(struct media_request *req)
192192
struct media_device *mdev = req->mdev;
193193
unsigned long flags;
194194

195+
mutex_lock(&mdev->req_queue_mutex);
196+
195197
spin_lock_irqsave(&req->lock, flags);
196198
if (req->state != MEDIA_REQUEST_STATE_IDLE &&
197199
req->state != MEDIA_REQUEST_STATE_COMPLETE) {
198200
dev_dbg(mdev->dev,
199201
"request: %s not in idle or complete state, cannot reinit\n",
200202
req->debug_str);
201203
spin_unlock_irqrestore(&req->lock, flags);
204+
mutex_unlock(&mdev->req_queue_mutex);
202205
return -EBUSY;
203206
}
204207
if (req->access_count) {
205208
dev_dbg(mdev->dev,
206209
"request: %s is being accessed, cannot reinit\n",
207210
req->debug_str);
208211
spin_unlock_irqrestore(&req->lock, flags);
212+
mutex_unlock(&mdev->req_queue_mutex);
209213
return -EBUSY;
210214
}
211215
req->state = MEDIA_REQUEST_STATE_CLEANING;
@@ -216,6 +220,7 @@ static long media_request_ioctl_reinit(struct media_request *req)
216220
spin_lock_irqsave(&req->lock, flags);
217221
req->state = MEDIA_REQUEST_STATE_IDLE;
218222
spin_unlock_irqrestore(&req->lock, flags);
223+
mutex_unlock(&mdev->req_queue_mutex);
219224

220225
return 0;
221226
}

drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,15 @@ void rkvdec_hevc_run_preamble(struct rkvdec_ctx *ctx,
500500
ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
501501
V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS);
502502
run->ext_sps_st_rps = ctrl ? ctrl->p_cur.p : NULL;
503+
} else {
504+
run->ext_sps_st_rps = NULL;
503505
}
504506
if (ctx->has_sps_lt_rps) {
505507
ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
506508
V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS);
507509
run->ext_sps_lt_rps = ctrl ? ctrl->p_cur.p : NULL;
510+
} else {
511+
run->ext_sps_lt_rps = NULL;
508512
}
509513

510514
rkvdec_run_preamble(ctx, &run->base);

drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-h264.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct rkvdec_h264_ctx {
130130
struct vdpu383_regs_h26x regs;
131131
};
132132

133-
static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
133+
static noinline_for_stack void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_dpb_entry *dpb)
134134
{
135135
pps->top_field_order_cnt0 = dpb[0].top_field_order_cnt;
136136
pps->bot_field_order_cnt0 = dpb[0].bottom_field_order_cnt;
@@ -166,6 +166,31 @@ static void set_field_order_cnt(struct rkvdec_pps *pps, const struct v4l2_h264_d
166166
pps->bot_field_order_cnt15 = dpb[15].bottom_field_order_cnt;
167167
}
168168

169+
static noinline_for_stack void set_dec_params(struct rkvdec_pps *pps, const struct v4l2_ctrl_h264_decode_params *dec_params)
170+
{
171+
const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
172+
173+
for (int i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
174+
if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
175+
pps->is_longterm |= (1 << i);
176+
pps->ref_field_flags |=
177+
(!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
178+
pps->ref_colmv_use_flag |=
179+
(!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
180+
pps->ref_topfield_used |=
181+
(!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
182+
pps->ref_botfield_used |=
183+
(!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
184+
}
185+
pps->pic_field_flag =
186+
!!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
187+
pps->pic_associated_flag =
188+
!!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
189+
190+
pps->cur_top_field = dec_params->top_field_order_cnt;
191+
pps->cur_bot_field = dec_params->bottom_field_order_cnt;
192+
}
193+
169194
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
170195
struct rkvdec_h264_run *run)
171196
{
@@ -177,7 +202,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
177202
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
178203
struct rkvdec_sps_pps *hw_ps;
179204
u32 pic_width, pic_height;
180-
u32 i;
181205

182206
/*
183207
* HW read the SPS/PPS information from PPS packet index by PPS id.
@@ -261,28 +285,8 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
261285
!!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT);
262286

263287
set_field_order_cnt(&hw_ps->pps, dpb);
288+
set_dec_params(&hw_ps->pps, dec_params);
264289

265-
for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
266-
if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
267-
hw_ps->pps.is_longterm |= (1 << i);
268-
269-
hw_ps->pps.ref_field_flags |=
270-
(!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD)) << i;
271-
hw_ps->pps.ref_colmv_use_flag |=
272-
(!!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) << i;
273-
hw_ps->pps.ref_topfield_used |=
274-
(!!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF)) << i;
275-
hw_ps->pps.ref_botfield_used |=
276-
(!!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF)) << i;
277-
}
278-
279-
hw_ps->pps.pic_field_flag =
280-
!!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC);
281-
hw_ps->pps.pic_associated_flag =
282-
!!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD);
283-
284-
hw_ps->pps.cur_top_field = dec_params->top_field_order_cnt;
285-
hw_ps->pps.cur_bot_field = dec_params->bottom_field_order_cnt;
286290
}
287291

288292
static void rkvdec_write_regs(struct rkvdec_ctx *ctx)

drivers/media/platform/rockchip/rkvdec/rkvdec-vp9.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,8 @@ static void rkvdec_vp9_done(struct rkvdec_ctx *ctx,
893893
update_ctx_last_info(vp9_ctx);
894894
}
895895

896-
static void rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
896+
static noinline_for_stack void
897+
rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx)
897898
{
898899
struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv;
899900
struct rkvdec_vp9_intra_frame_symbol_counts *intra_cnts = vp9_ctx->count_tbl.cpu;

drivers/media/platform/synopsys/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config VIDEO_DW_MIPI_CSI2RX
77
depends on VIDEO_DEV
88
depends on V4L_PLATFORM_DRIVERS
99
depends on PM && COMMON_CLK
10+
select GENERIC_PHY_MIPI_DPHY
1011
select MEDIA_CONTROLLER
1112
select V4L2_FWNODE
1213
select VIDEO_V4L2_SUBDEV_API

drivers/media/platform/synopsys/dw-mipi-csi2rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ dw_mipi_csi2rx_enum_mbus_code(struct v4l2_subdev *sd,
301301

302302
return 0;
303303
case DW_MIPI_CSI2RX_PAD_SINK:
304-
if (code->index > csi2->formats_num)
304+
if (code->index >= csi2->formats_num)
305305
return -EINVAL;
306306

307307
code->code = csi2->formats[code->index].code;

drivers/media/platform/verisilicon/imx8m_vpu_hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const struct hantro_variant imx8mq_vpu_variant = {
343343
.num_regs = ARRAY_SIZE(imx8mq_reg_names)
344344
};
345345

346-
static const struct of_device_id imx8mq_vpu_shared_resources[] __initconst = {
346+
static const struct of_device_id imx8mq_vpu_shared_resources[] = {
347347
{ .compatible = "nxp,imx8mq-vpu-g1", },
348348
{ .compatible = "nxp,imx8mq-vpu-g2", },
349349
{ /* sentinel */ }

drivers/media/v4l2-core/v4l2-ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,13 +3082,14 @@ static long __video_do_ioctl(struct file *file,
30823082
}
30833083

30843084
/*
3085-
* We need to serialize streamon/off with queueing new requests.
3085+
* We need to serialize streamon/off/reqbufs with queueing new requests.
30863086
* These ioctls may trigger the cancellation of a streaming
30873087
* operation, and that should not be mixed with queueing a new
30883088
* request at the same time.
30893089
*/
30903090
if (v4l2_device_supports_requests(vfd->v4l2_dev) &&
3091-
(cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF)) {
3091+
(cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF ||
3092+
cmd == VIDIOC_REQBUFS)) {
30923093
req_queue_lock = &vfd->v4l2_dev->mdev->req_queue_mutex;
30933094

30943095
if (mutex_lock_interruptible(req_queue_lock))

0 commit comments

Comments
 (0)