From 9ee2b0168619b3e18ce76c1f47300685c876d0fd Mon Sep 17 00:00:00 2001 From: Ankur Pawar Date: Thu, 2 Oct 2025 16:26:12 +0000 Subject: [PATCH] Camera: fix kernel warning after VI timeout VI return timeout status when no frames are received from camera sensor. During the error recovery, the v4l2 buffers are set to VB2_BUF_STATE_ERROR, this causes kernel warning. As per the v4l2 framework correct buffer state for timeout is VB2_BUF_STATE_QUEUED. Bug 5512645 Change-Id: Iafc720b1ba74f04490d7d14e2e9014bd599b3cba Signed-off-by: Ankur Pawar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3463848 Tested-by: Jerry Chang Reviewed-by: Laxman Dewangan Reviewed-by: Jerry Chang GVS: buildbot_gerritrpt Reviewed-by: svcacv --- drivers/media/platform/tegra/camera/vi/vi5_fops.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/tegra/camera/vi/vi5_fops.c b/drivers/media/platform/tegra/camera/vi/vi5_fops.c index e458f33d..69d76521 100644 --- a/drivers/media/platform/tegra/camera/vi/vi5_fops.c +++ b/drivers/media/platform/tegra/camera/vi/vi5_fops.c @@ -617,11 +617,15 @@ static void vi5_capture_dequeue(struct tegra_channel *chan, uncorr_err: spin_lock_irqsave(&chan->capture_state_lock, flags); - chan->capture_state = CAPTURE_ERROR; + if (err == -ETIMEDOUT) { + chan->capture_state = CAPTURE_TIMEOUT; + buf->vb2_state = VB2_BUF_STATE_QUEUED; + } else { + chan->capture_state = CAPTURE_ERROR; + buf->vb2_state = VB2_BUF_STATE_ERROR; + } spin_unlock_irqrestore(&chan->capture_state_lock, flags); - buf->vb2_state = VB2_BUF_STATE_ERROR; - rel_buf: vi5_release_buffer(chan, buf); } @@ -683,7 +687,10 @@ static int vi5_channel_error_recover(struct tegra_channel *chan, buf = dequeue_dequeue_buffer(chan); if (!buf) break; - buf->vb2_state = VB2_BUF_STATE_ERROR; + if (chan->capture_state == CAPTURE_TIMEOUT) + buf->vb2_state = VB2_BUF_STATE_QUEUED; + else + buf->vb2_state = VB2_BUF_STATE_ERROR; vi5_capture_dequeue(chan, buf); }