difos/target/linux/bcm27xx/patches-6.12/950-0291-media-bcm2835-unicam-Correctly-handle-FS-FE-ISR-cond.patch
Álvaro Fernández Rojas 8f9e91ad03 bcm27xx: add 6.12 patches from RPi repo
These patches were generated from:
https://github.com/raspberrypi/linux/commits/rpi-6.12.y
With the following command:
git format-patch -N v6.12.27..HEAD
(HEAD -> 8d3206ee456a5ecdf9ddbfd8e5e231e4f0cd716e)

Exceptions:
- (def)configs patches
- github workflows patches
- applied & reverted patches
- readme patches
- wireless patches

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-05-21 11:32:18 +02:00

63 lines
2.3 KiB
Diff

From d9f2c98a2676748bb974486600919fb7343706ea Mon Sep 17 00:00:00 2001
From: Naushir Patuck <naush@raspberrypi.com>
Date: Mon, 8 Aug 2022 10:01:41 +0100
Subject: [PATCH] media: bcm2835-unicam: Correctly handle FS + FE ISR condtion
If we get a simultaneous FS + FE interrupt for the same frame, it cannot be
marked as completed and returned to userland as the framebuffer will be refilled
by Unicam on the next sensor frame. Additionally, the timestamp will be set to 0
as the FS interrupt handling code will not have run yet.
To avoid these problems, the frame is considered dropped in the FE handler,
and will be returned to userland on the subsequent sensor frame.
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
.../media/platform/bcm2835/bcm2835-unicam.c | 28 +++++++++++++------
1 file changed, 20 insertions(+), 8 deletions(-)
--- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
+++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
@@ -908,7 +908,9 @@ static irqreturn_t unicam_isr(int irq, v
* to use.
*/
for (i = 0; i < ARRAY_SIZE(unicam->node); i++) {
- if (!unicam->node[i].streaming)
+ struct unicam_node *node = &unicam->node[i];
+
+ if (!node->streaming)
continue;
/*
@@ -918,14 +920,24 @@ static irqreturn_t unicam_isr(int irq, v
* + FS + LS). In this case, we cannot signal the buffer
* as complete, as the HW will reuse that buffer.
*/
- if (unicam->node[i].cur_frm &&
- unicam->node[i].cur_frm != unicam->node[i].next_frm) {
- unicam_process_buffer_complete(&unicam->node[i],
- sequence);
- unicam->node[i].cur_frm = unicam->node[i].next_frm;
- unicam->node[i].next_frm = NULL;
+ if (node->cur_frm && node->cur_frm != node->next_frm) {
+ /*
+ * This condition checks if FE + FS for the same
+ * frame has occurred. In such cases, we cannot
+ * return out the frame, as no buffer handling
+ * or timestamping has yet been done as part of
+ * the FS handler.
+ */
+ if (!node->cur_frm->vb.vb2_buf.timestamp) {
+ unicam_dbg(2, unicam, "ISR: FE without FS, dropping frame\n");
+ continue;
+ }
+
+ unicam_process_buffer_complete(node, sequence);
+ node->cur_frm = node->next_frm;
+ node->next_frm = NULL;
} else {
- unicam->node[i].cur_frm = unicam->node[i].next_frm;
+ node->cur_frm = node->next_frm;
}
}
unicam->sequence++;