* [PATCH v2 0/2] media: cedrus: allocation failure and capture payload fixes
@ 2026-11-28 17:35 Arun Iyengar via B4 Relay
2026-11-28 17:35 ` [PATCH v2 1/2] media: cedrus: fail buffer allocations that do not fit with -ENOMEM Arun Iyengar via B4 Relay
2026-11-28 17:35 ` [PATCH v2 2/2] media: cedrus: report only the picture as capture payload Arun Iyengar via B4 Relay
0 siblings, 2 replies; 4+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 17:35 UTC (permalink / raw)
To: Maxime Ripard, Paul Kocialkowski, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Hans Verkuil
Cc: linux-media, linux-staging, linux-arm-kernel, linux-sunxi,
linux-kernel, Arun Iyengar
Two cedrus fixes, found on an Orange Pi Zero2 (H616) and reproduced on
media-committers next. Patch 2 concerns the private plane of Jernej
Skrabec's 10-bit HEVC support.
Tested on H616 only: 17 x 64 MiB REQBUFS gives 12 buffers and no OOM
kill (next: five processes killed); 10-bit H.265 bytesused 12441600
(next: 15552000); v4l2-compliance 49/49; MPEG-2, H.264 and H.265
bit-exact.
Developed with Claude (Anthropic) as a coding assistant, which wrote
the code and the commit messages. I reviewed and tested them.
---
Changes in v2:
- 1/2: commit message: only the IOMMU path is affected (Jernej).
- 2/2: add Jernej's Reviewed-by.
- Rebase on media-committers next.
- Link to v1: https://patch.msgid.link/20261119-b4-cedrus-generic-fixes-v1-0-f9f50812c85b@gmail.com
---
Arun Iyengar (2):
media: cedrus: fail buffer allocations that do not fit with -ENOMEM
media: cedrus: report only the picture as capture payload
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
base-commit: fb8b2c10a588f1384b98280b1c32307da9db4747
change-id: 20261114-b4-cedrus-generic-fixes-8ce71c2dafd5
Best regards,
--
Arun Iyengar <aiyengar1990@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 1/2] media: cedrus: fail buffer allocations that do not fit with -ENOMEM
2026-11-28 17:35 [PATCH v2 0/2] media: cedrus: allocation failure and capture payload fixes Arun Iyengar via B4 Relay
@ 2026-11-28 17:35 ` Arun Iyengar via B4 Relay
2026-11-28 18:30 ` Jernej Škrabec
2026-11-28 17:35 ` [PATCH v2 2/2] media: cedrus: report only the picture as capture payload Arun Iyengar via B4 Relay
1 sibling, 1 reply; 4+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 17:35 UTC (permalink / raw)
To: Maxime Ripard, Paul Kocialkowski, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Hans Verkuil
Cc: linux-media, linux-staging, linux-arm-kernel, linux-sunxi,
linux-kernel, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
Behind an IOMMU, vb2-dma-contig builds buffers from GFP_KERNEL pages,
so a buffer pool that does not fit in memory invokes the OOM killer.
CMA allocations fail directly and are not affected.
Set __GFP_RETRY_MAYFAIL on both queues: the request then returns fewer
buffers or -ENOMEM.
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index ad4ec3490775..9b2d24e77fdb 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -602,6 +602,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->dev = ctx->dev->dev;
src_vq->supports_requests = true;
src_vq->requires_requests = true;
+ src_vq->gfp_flags = __GFP_RETRY_MAYFAIL;
ret = vb2_queue_init(src_vq);
if (ret)
@@ -616,6 +617,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->dev->dev_mutex;
dst_vq->dev = ctx->dev->dev;
+ dst_vq->gfp_flags = __GFP_RETRY_MAYFAIL;
return vb2_queue_init(dst_vq);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] media: cedrus: fail buffer allocations that do not fit with -ENOMEM
2026-11-28 17:35 ` [PATCH v2 1/2] media: cedrus: fail buffer allocations that do not fit with -ENOMEM Arun Iyengar via B4 Relay
@ 2026-11-28 18:30 ` Jernej Škrabec
0 siblings, 0 replies; 4+ messages in thread
From: Jernej Škrabec @ 2026-11-28 18:30 UTC (permalink / raw)
To: Maxime Ripard, Paul Kocialkowski, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Chen-Yu Tsai, Samuel Holland, Hans Verkuil,
aiyengar1990
Cc: linux-media, linux-staging, linux-arm-kernel, linux-sunxi,
linux-kernel, Arun Iyengar
Dne sobota, 28. november 2026 ob 18:35:52 Srednjeevropski standardni čas je Arun Iyengar via B4 Relay napisal(a):
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> Behind an IOMMU, vb2-dma-contig builds buffers from GFP_KERNEL pages,
> so a buffer pool that does not fit in memory invokes the OOM killer.
> CMA allocations fail directly and are not affected.
>
> Set __GFP_RETRY_MAYFAIL on both queues: the request then returns fewer
> buffers or -ENOMEM.
>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
> ---
> drivers/staging/media/sunxi/cedrus/cedrus_video.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> index ad4ec3490775..9b2d24e77fdb 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> @@ -602,6 +602,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->dev = ctx->dev->dev;
> src_vq->supports_requests = true;
> src_vq->requires_requests = true;
> + src_vq->gfp_flags = __GFP_RETRY_MAYFAIL;
>
> ret = vb2_queue_init(src_vq);
> if (ret)
> @@ -616,6 +617,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
> dst_vq->lock = &ctx->dev->dev_mutex;
> dst_vq->dev = ctx->dev->dev;
> + dst_vq->gfp_flags = __GFP_RETRY_MAYFAIL;
>
> return vb2_queue_init(dst_vq);
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] media: cedrus: report only the picture as capture payload
2026-11-28 17:35 [PATCH v2 0/2] media: cedrus: allocation failure and capture payload fixes Arun Iyengar via B4 Relay
2026-11-28 17:35 ` [PATCH v2 1/2] media: cedrus: fail buffer allocations that do not fit with -ENOMEM Arun Iyengar via B4 Relay
@ 2026-11-28 17:35 ` Arun Iyengar via B4 Relay
1 sibling, 0 replies; 4+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 17:35 UTC (permalink / raw)
To: Maxime Ripard, Paul Kocialkowski, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Hans Verkuil
Cc: linux-media, linux-staging, linux-arm-kernel, linux-sunxi,
linux-kernel, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
For 10-bit H.265 the driver appends the low 2 bits of every sample to
the capture buffer and counts them in sizeimage (extra_cap_size).
buf_prepare reports the whole sizeimage as bytesused, so userspace that
copies the payload gets the private plane as part of the picture.
Report only the picture; sizeimage stays the allocation size.
Fixes: 65429ba82572 ("media: cedrus: h265: Support decoding 10-bit frames")
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index 9b2d24e77fdb..b7e0cbe548e6 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -511,8 +511,15 @@ static int cedrus_buf_prepare(struct vb2_buffer *vb)
* (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets
* it to buffer length).
*/
- if (V4L2_TYPE_IS_CAPTURE(vq->type))
- vb2_set_plane_payload(vb, 0, pix_fmt->sizeimage);
+ if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
+ unsigned int payload = pix_fmt->sizeimage;
+
+ if (ctx->current_codec->extra_cap_size)
+ payload -= ctx->current_codec->extra_cap_size(ctx,
+ pix_fmt);
+
+ vb2_set_plane_payload(vb, 0, payload);
+ }
return 0;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-28 18:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 17:35 [PATCH v2 0/2] media: cedrus: allocation failure and capture payload fixes Arun Iyengar via B4 Relay
2026-11-28 17:35 ` [PATCH v2 1/2] media: cedrus: fail buffer allocations that do not fit with -ENOMEM Arun Iyengar via B4 Relay
2026-11-28 18:30 ` Jernej Škrabec
2026-11-28 17:35 ` [PATCH v2 2/2] media: cedrus: report only the picture as capture payload Arun Iyengar via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox