[PATCH v2 18/23] media: iris: Fix buffer preparation failure during resolution change

Dikshita Agarwal posted 23 patches 9 months, 2 weeks ago
There is a newer version of this series
[PATCH v2 18/23] media: iris: Fix buffer preparation failure during resolution change
Posted by Dikshita Agarwal 9 months, 2 weeks ago
When the resolution changes, the driver internally updates the width and
height, but the client continue to queue buffers with the older
resolution until the last flag is received. This results in a mismatch
when the buffers are prepared, causing failure due to outdated size.

Introduce a check to prevent size validation during buffer preparation
if a resolution reconfiguration is in progress, to handle this.

Cc: stable@vger.kernel.org
Fixes: 17f2a485ca67 ("media: iris: implement vb2 ops for buf_queue and firmware response")
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
---
 drivers/media/platform/qcom/iris/iris_vb2.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
index 23473cbd0b2e..7671df0e1c69 100644
--- a/drivers/media/platform/qcom/iris/iris_vb2.c
+++ b/drivers/media/platform/qcom/iris/iris_vb2.c
@@ -259,13 +259,14 @@ int iris_vb2_buf_prepare(struct vb2_buffer *vb)
 			return -EINVAL;
 	}
 
-	if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
-	    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_OUTPUT))
-		return -EINVAL;
-	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
-	    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_INPUT))
-		return -EINVAL;
-
+	if (!inst->in_reconfig) {
+		if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
+		    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_OUTPUT))
+			return -EINVAL;
+		if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
+		    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_INPUT))
+			return -EINVAL;
+	}
 	return 0;
 }
 

-- 
2.34.1
Re: [PATCH v2 18/23] media: iris: Fix buffer preparation failure during resolution change
Posted by Vikash Garodia 9 months, 2 weeks ago
On 4/28/2025 2:59 PM, Dikshita Agarwal wrote:
> When the resolution changes, the driver internally updates the width and
> height, but the client continue to queue buffers with the older
> resolution until the last flag is received. This results in a mismatch
> when the buffers are prepared, causing failure due to outdated size.
> 
> Introduce a check to prevent size validation during buffer preparation
> if a resolution reconfiguration is in progress, to handle this.
> 
> Cc: stable@vger.kernel.org
> Fixes: 17f2a485ca67 ("media: iris: implement vb2 ops for buf_queue and firmware response")
> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
> ---
>  drivers/media/platform/qcom/iris/iris_vb2.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
> index 23473cbd0b2e..7671df0e1c69 100644
> --- a/drivers/media/platform/qcom/iris/iris_vb2.c
> +++ b/drivers/media/platform/qcom/iris/iris_vb2.c
> @@ -259,13 +259,14 @@ int iris_vb2_buf_prepare(struct vb2_buffer *vb)
>  			return -EINVAL;
>  	}
>  
> -	if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
> -	    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_OUTPUT))
> -		return -EINVAL;
> -	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
> -	    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_INPUT))
> -		return -EINVAL;
> -
> +	if (!inst->in_reconfig) {
Remove the flag and replace with state check. With that

Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>

> +		if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
> +		    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_OUTPUT))
> +			return -EINVAL;
> +		if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
> +		    vb2_plane_size(vb, 0) < iris_get_buffer_size(inst, BUF_INPUT))
> +			return -EINVAL;
> +	}
>  	return 0;
>  }
>  
>