2022-05-18 03:51:58

by Smitha T Murthy

[permalink] [raw]
Subject: [PATCH 15/20] media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF

This patch allows allocation of DPB buffers based
on MFC requirement so codec buffers allocations
has been moved after state MFCINST_HEAD_PRODUCED.
And it is taken care that codec buffer allocation
is performed in process context from userspace IOCTL
call.

Cc: [email protected]
Signed-off-by: Smitha T Murthy <[email protected]>
---
.../platform/samsung/s5p-mfc/s5p_mfc_enc.c | 17 ++---------------
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 9 ++++++++-
2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index 57b4397f2b03..95e18f1cabb0 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1339,7 +1339,6 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_enc_params *p = &ctx->enc_params;
struct s5p_mfc_buf *dst_mb;
- unsigned int enc_pb_count;

if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) {
if (!list_empty(&ctx->dst_queue)) {
@@ -1361,10 +1360,8 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
set_work_bit_irqsave(ctx);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
} else {
- enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops,
+ ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops,
get_enc_dpb_count, dev);
- if (ctx->pb_count < enc_pb_count)
- ctx->pb_count = enc_pb_count;
if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) {
ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
get_e_min_scratch_buf_size, dev);
@@ -1729,14 +1726,6 @@ static int vidioc_reqbufs(struct file *file, void *priv,
}
ctx->capture_state = QUEUE_BUFS_REQUESTED;

- ret = s5p_mfc_hw_call(ctx->dev->mfc_ops,
- alloc_codec_buffers, ctx);
- if (ret) {
- mfc_err("Failed to allocate encoding buffers\n");
- reqbufs->count = 0;
- ret = vb2_reqbufs(&ctx->vq_dst, reqbufs);
- return -ENOMEM;
- }
} else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
if (reqbufs->count == 0) {
mfc_debug(2, "Freeing buffers\n");
@@ -1752,15 +1741,13 @@ static int vidioc_reqbufs(struct file *file, void *priv,
return -EINVAL;
}

- if (IS_MFCV6_PLUS(dev)) {
+ if (IS_MFCV6_PLUS(dev) && (!IS_MFCV12(dev))) {
/* Check for min encoder buffers */
if (ctx->pb_count &&
(reqbufs->count < ctx->pb_count)) {
reqbufs->count = ctx->pb_count;
mfc_debug(2, "Minimum %d output buffers needed\n",
ctx->pb_count);
- } else {
- ctx->pb_count = reqbufs->count;
}
}

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 2b6d6259a209..44058827eaa3 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -388,7 +388,6 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
default:
break;
}
-
/* Allocate only if memory from bank 1 is necessary */
if (ctx->bank1.size > 0) {
ret = s5p_mfc_alloc_generic_buf(dev, BANK_L_CTX, &ctx->bank1);
@@ -2266,6 +2265,14 @@ static inline int s5p_mfc_run_init_enc_buffers(struct s5p_mfc_ctx *ctx)
struct s5p_mfc_dev *dev = ctx->dev;
int ret;

+ ret = s5p_mfc_hw_call(ctx->dev->mfc_ops,
+ alloc_codec_buffers, ctx);
+ if (ret) {
+ mfc_err("Failed to allocate encoding buffers\n");
+ return -ENOMEM;
+ }
+ mfc_debug(2, "Allocated Internal Encoding Buffers\n");
+
dev->curr_ctx = ctx->num;
ret = s5p_mfc_set_enc_ref_buffer_v6(ctx);
if (ret) {
--
2.17.1



2022-05-18 04:04:00

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 15/20] media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF

On 17/05/2022 14:55, Smitha T Murthy wrote:
> This patch allows allocation of DPB buffers based
> on MFC requirement so codec buffers allocations
> has been moved after state MFCINST_HEAD_PRODUCED.
> And it is taken care that codec buffer allocation
> is performed in process context from userspace IOCTL
> call.

Please wrap your commit messages according to Linux coding style:
https://elixir.bootlin.com/linux/v5.18-rc4/source/Documentation/process/submitting-patches.rst#L586


Best regards,
Krzysztof

2022-07-05 11:57:34

by Smitha T Murthy

[permalink] [raw]
Subject: RE: [PATCH 15/20] media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF



> -----Original Message-----
> From: Krzysztof Kozlowski [mailto:[email protected]]
> Sent: Tuesday, May 17, 2022 7:30 PM
> To: Smitha T Murthy <[email protected]>; linux-arm-
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Cc: [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH 15/20] media: s5p-mfc: DPB Count Independent of
> VIDIOC_REQBUF
>
> On 17/05/2022 14:55, Smitha T Murthy wrote:
> > This patch allows allocation of DPB buffers based on MFC requirement
> > so codec buffers allocations has been moved after state
> > MFCINST_HEAD_PRODUCED.
> > And it is taken care that codec buffer allocation is performed in
> > process context from userspace IOCTL call.
>
> Please wrap your commit messages according to Linux coding style:
> https://protect2.fireeye.com/v1/url?k=7a17dde8-1b9cc8cd-7a1656a7-
> 74fe485cbff6-4e2dc61728e47c8b&q=1&e=5c8a7957-5da6-466f-b2c7-
> b905451fd24c&u=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.18-
> rc4%2Fsource%2FDocumentation%2Fprocess%2Fsubmitting-
> patches.rst%23L586
>
>
> Best regards,
> Krzysztof

Ok I will change this.

Regards,
Smitha