Uninterruptible host1x syncpoint wait for Tegra video capture
Subsystems (6)
cover Uninterruptible host1x syncpoint wait for Tegra video capture
The Tegra20 video capture path runs in a kernel thread and waits on host1x syncpoints with host1x_syncpt_wait(), which is unconditionally
interruptible: any signal aborts the wait with -ERESTARTSYS. At high resolutions and framerates these spurious failures are common, so the driver wraps both waits in do/while retry loops, with a TODO asking for an uninterruptible variant of the wait.
This series proposes one: patch 1 refactors host1x_syncpt_wait() so the interruptible behavior is preserved exactly for existing callers (including two DRM ioctls that are userspace ABI and must stay interruptible) and adds host1x_syncpt_wait_uninterruptible() for in-kernel users. Patch 2 converts the Tegra20 capture waits and drops the retry loops and the TODO.
This is sent as an RFC because the API shape and the scope need agreement before a final series:
1. Is a separate _uninterruptible() variant the shape host1x wants, or would the maintainers prefer something else (for example an internal helper with a flag, or a different name)?
2. Tegra210's two waits (tegra210.c) have no retry loop: a spurious -ERESTARTSYS currently fails the buffer. Should they convert to the uninterruptible wait as well, or is failing on signal intentional there?
3. drivers/crypto/tegra/tegra-se-main.c also waits with MAX_SCHEDULE_TIMEOUT; left out of scope here, but flagging in case its maintainer wants the same treatment.
drivers/staging/media/tegra-video with VIDEO_TEGRA=m, zero warnings). The tegra20.c change itself has no compile coverage here: that object builds only for 32-bit ARM (ARCH_TEGRA_2x_SOC/_3x_SOC) and no ARM toolchain is available, and there is no Tegra hardware for runtime testing. Hardware testing help is needed before any final series.
Testing: compile-tested only (arm64: drivers/gpu/host1x and
---
DelaySystem (2):
gpu: host1x: add uninterruptible syncpoint wait variant
staging: media: tegra-video: uninterruptible syncpt wait for tegra20
drivers/gpu/host1x/syncpt.c | 46 ++++++++++++++++++++++------- drivers/staging/media/tegra-video/tegra20.c | 37 +++++++---------------- include/linux/host1x.h | 2 ++ 3 files changed, 48 insertions(+), 37 deletions(-)
---
base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
change-id: 20261107-batch1-b1-host1x-wait-3cb3b92e9199
Best regards,
Signature · 1 line
DelaySystem <[email protected]>
RFC PATCH 1/2 gpu: host1x: add uninterruptible syncpoint wait variant
host1x_syncpt_wait() is unconditionally interruptible: any signal aborts the wait with -ERESTARTSYS. Kernel threads that wait on syncpoints, such as the Tegra video capture threads, then need retry loops to survive spurious wakeups.
Refactor the implementation into __host1x_syncpt_wait() with an interruptible flag, keep host1x_syncpt_wait() behavior-identical for its existing callers (including two DRM ioctls that must stay interruptible), and add host1x_syncpt_wait_uninterruptible() for in-kernel users that must not fail spuriously. The wait stays bounded by the caller's timeout in both cases.
--- drivers/gpu/host1x/syncpt.c | 46 +++++++++++++++++++++++++++++++++++---------- include/linux/host1x.h | 2 ++ 2 files changed, 38 insertions(+), 10 deletions(-)
drivers/gpu/host1x/syncpt.c +36 -10
@@ -215,15 +215,8 @@ int host1x_syncpt_incr(struct host1x_syncpt *sp) }EXPORT_SYMBOL (host1x_syncpt_incr); -/** -* host1x_syncpt_wait() - wait for a syncpoint to reach a given value -* @sp: host1x syncpoint -* @thresh: threshold -* @timeout: maximum time to wait for the syncpoint to reach the given value -* @value: return location for the syncpoint value -*/ -int host1x_syncpt_wait (struct host1x_syncpt *sp,u32 thresh,long timeout, -u32 *value) +static int __host1x_syncpt_wait (struct host1x_syncpt *sp,u32 thresh, +long timeout,u32 *value,bool intr) {struct dma_fence *fence;long wait_err;
@@ -246,7 +239,7 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,if (IS_ERR (fence))return PTR_ERR (fence); - wait_err =dma_fence_wait_timeout (fence, true, timeout); + wait_err =dma_fence_wait_timeout (fence, intr, timeout);if (wait_err ==0 )host1x_fence_cancel (fence);dma_fence_put (fence);
@@ -271,8 +264,41 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,return 0 ; } } + +/** +* host1x_syncpt_wait() - wait for a syncpoint to reach a given value +* @sp: host1x syncpoint +* @thresh: threshold +* @timeout: maximum time to wait for the syncpoint to reach the given value +* @value: return location for the syncpoint value +* +* The wait is interruptible: a signal aborts it with -ERESTARTSYS. +*/ +int host1x_syncpt_wait (struct host1x_syncpt *sp,u32 thresh,long timeout, +u32 *value) +{ +return __host1x_syncpt_wait (sp, thresh, timeout, value, true); +}EXPORT_SYMBOL (host1x_syncpt_wait); +/** +* host1x_syncpt_wait_uninterruptible() - wait for a syncpoint, uninterruptibly +* @sp: host1x syncpoint +* @thresh: threshold +* @timeout: maximum time to wait for the syncpoint to reach the given value +* @value: return location for the syncpoint value +* +* Like host1x_syncpt_wait(), but signals do not abort the wait. For use by +* kernel threads that must not fail spuriously with -ERESTARTSYS, such as +* the Tegra video capture threads. The wait is still bounded by @timeout. +*/ +int host1x_syncpt_wait_uninterruptible (struct host1x_syncpt *sp,u32 thresh, +long timeout,u32 *value) +{ +return __host1x_syncpt_wait (sp, thresh, timeout, value, false); +} +EXPORT_SYMBOL (host1x_syncpt_wait_uninterruptible); +/* * Returns true if syncpoint is expired, false if we may need to wait */
include/linux/host1x.h +2 -0
@@ -221,6 +221,8 @@ int host1x_syncpt_incr(struct host1x_syncpt *sp);u32 host1x_syncpt_incr_max (struct host1x_syncpt *sp,u32 incrs);int host1x_syncpt_wait (struct host1x_syncpt *sp,u32 thresh,long timeout,u32 *value); +int host1x_syncpt_wait_uninterruptible (struct host1x_syncpt *sp,u32 thresh, +long timeout,u32 *value);struct host1x_syncpt *host1x_syncpt_request (struct host1x_client *client,unsigned long flags);void host1x_syncpt_put (struct host1x_syncpt *sp);
Signature · 1 line
2.34.1
RFC PATCH 2/2 staging: media: tegra-video: uninterruptible syncpt wait for tegra20
In reply to DelaySystemThe Tegra20 capture path runs in a kernel thread and retries host1x_syncpt_wait() in a do/while loop to survive the -ERESTARTSYS its unconditionally interruptible wait returns spuriously at high resolutions and framerates.
Now that host1x provides host1x_syncpt_wait_uninterruptible(), use it for both the frame-start and MW-ACK waits and drop the retry loops, fulfilling the TODO above the frame-start wait. Timeouts still fail the capture as before; only the spurious signal failures go away.
--- drivers/staging/media/tegra-video/tegra20.c | 37 ++++++++--------------------- 1 file changed, 10 insertions(+), 27 deletions(-)
drivers/staging/media/tegra-video/tegra20.c +10 -27
@@ -589,28 +589,14 @@ static int tegra20_channel_capture_frame(struct tegra_vi_channel *chan,CSI_PP_START_MARKER_FRAME_MAX (0xf ) | CSI_PP_SINGLE_SHOT | CSI_PP_ENABLE); -/* -* ERESTARTSYS workaround for syncpoints is used because host1x_syncpt_wait -* is unconditionally interruptible. This is not an issue with single shots -* or low resolution capture, but -ERESTARTSYS occurs quite often with high -* resolution or high framerate captures and if not addressed here will -* cause capture to fail entirely. -* -* TODO: once uninterruptible version of host1x_syncpt_wait is available, -* host1x_syncpt_wait should be swapped and ERESTARTSYS workaround can be -* removed. -*/ - val =host1x_syncpt_read (chan->frame_start_sp[0 ]); -do { - err =host1x_syncpt_wait (chan->frame_start_sp[0 ], - val +1 ,TEGRA_VI_SYNCPT_WAIT_TIMEOUT ,NULL ); - }while (err == -ERESTARTSYS ); - + err =host1x_syncpt_wait_uninterruptible (chan->frame_start_sp[0 ], + val +1 , +TEGRA_VI_SYNCPT_WAIT_TIMEOUT , +NULL );if (err) { -if (err != -ERESTARTSYS ) -dev_err_ratelimited (&chan->video.dev, -"frame start syncpt timeout: %d\n" , err); +dev_err_ratelimited (&chan->video.dev, +"frame start syncpt timeout: %d\n" , err);tegra20_csi_write (csi_chan,TEGRA_CSI_PIXEL_STREAM_PP_COMMAND (port),CSI_PP_START_MARKER_FRAME_MAX (0xf ) |CSI_PP_RESET );
@@ -625,14 +611,11 @@ static int tegra20_channel_capture_frame(struct tegra_vi_channel *chan, } val =host1x_syncpt_read (chan->mw_ack_sp[0 ]); -do { - err =host1x_syncpt_wait (chan->mw_ack_sp[0 ], val +1 , -TEGRA_VI_SYNCPT_WAIT_TIMEOUT ,NULL ); - }while (err == -ERESTARTSYS ); - + err =host1x_syncpt_wait_uninterruptible (chan->mw_ack_sp[0 ], val +1 , +TEGRA_VI_SYNCPT_WAIT_TIMEOUT , +NULL );if (err) { -if (err != -ERESTARTSYS ) -dev_err_ratelimited (&chan->video.dev,"mw ack syncpt timeout: %d\n" , err); +dev_err_ratelimited (&chan->video.dev,"mw ack syncpt timeout: %d\n" , err); goto exit; }
Signature · 1 line
2.34.1
Quoted 29 lines · On Sunday, November 8, 2026 2:21 PM DelaySystem via B4 Relay wrote:
Signed-off-by DelaySystem <[email protected]>The Tegra20 video capture path runs in a kernel thread and waits on host1x syncpoints with
host1x_syncpt_wait(), which is unconditionally
interruptible: any signal aborts the wait with-ERESTARTSYS. At high resolutions and framerates these spurious failures are common, so the driver wraps both waits in do/while retry loops, with a TODO asking for an uninterruptible variant of the wait.This series proposes one: patch 1 refactors
host1x_syncpt_wait()so the interruptible behavior is preserved exactly for existing callers (including two DRM ioctls that are userspace ABI and must stay interruptible) and addshost1x_syncpt_wait_uninterruptible()for in-kernel users. Patch 2 converts the Tegra20 capture waits and drops the retry loops and the TODO.This is sent as an RFC because the API shape and the scope need agreement before a final series:
1. Is a separate
_uninterruptible()variant the shape host1x wants, or would the maintainers prefer something else (for example an internal helper with a flag, or a different name)?
2. Tegra210's two waits (tegra210.c) have no retry loop: a spurious-ERESTARTSYScurrently fails the buffer. Should they convert to the uninterruptible wait as well, or is failing on signal intentional there?
3.drivers/crypto/tegra/tegra-se-main.calso waits withMAX_SCHEDULE_TIMEOUT; left out of scope here, but flagging in case its maintainer wants the same treatment.
Quoted 5 lines
drivers/staging/media/tegra-videowith VIDEO_TEGRA=m, zero warnings). Thetegra20.cchange itself has no compile coverage here: that object builds only for 32-bit ARM (ARCH_TEGRA_2x_SOC/_3x_SOC) and no ARM toolchain is available, and there is no Tegra hardware for runtime testing. Hardware testing help is needed before any final series.
nak
Quoted 21 lines
Testing: compile-tested only (arm64:
drivers/gpu/host1xand
---
DelaySystem (2):
gpu: host1x: add uninterruptible syncpoint wait variant
staging: media: tegra-video: uninterruptible syncpt wait for tegra20drivers/gpu/host1x/syncpt.c | 46 ++++++++++++++++++++++------- drivers/staging/media/tegra-video/tegra20.c | 37 +++++++---------------- include/linux/host1x.h | 2 ++ 3 files changed, 48 insertions(+), 37 deletions(-)---
base-commit:fa4ad798f6f681031775266044ba1b0cf3c670bd
change-id: 20261107-batch1-b1-host1x-wait-3cb3b92e9199Best regards,
Signature · 1 line
DelaySystem <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
ср, 18 лист. 2026 р. о 02:06 Maximo Manriquez Lizarraga <[email protected]> пише:
Quoted 13 lines
Hi Mikko,
Thanks for looking at the RFC.
My name is Maximo Manriquez Lizarraga -- I previously posted as "DelaySystem", apologies for the confusion. Future mail will use my real name.
Your nak is noted, but with no rationale I don't know what sank it:
is it the_uninterruptible()API shape, the tegra20-only scope, the approach itself, or something else? If you can spare a line on what needs to change, I will revise the series or drop it accordingly.
Quoted 5 lines
Sorry for the noise either way.
Best regards,
Maximo
Quote:
Quoted 4 lines
The
tegra20.cchange itself has no compile coverage here: that object builds only for 32-bit ARM (ARCH_TEGRA_2x_SOC/_3x_SOC) and no ARM toolchain is available, and there is no Tegra hardware for runtime testing. Hardware testing help is needed before any final series.