Skip to content

enable ASYNC_COMMIT on planes - #147

Open
henkwiedig wants to merge 1 commit into
OpenIPC:masterfrom
henkwiedig:async-commit
Open

henkwiedig wants to merge 1 commit into
OpenIPC:masterfrom
henkwiedig:async-commit

Conversation

@henkwiedig

Copy link
Copy Markdown
Collaborator

The MR enables rockchip's vendor specific ASYNC_COMMIT on the drm planes.
Should improve latency a bit.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add opt-in asynchronous DRM plane commits

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Adds an opt-in CLI flag for lower-latency Rockchip plane updates.
• Enables vendor ASYNC_COMMIT on supported video and OSD planes.
• Preserves compatibility by silently skipping drivers without the property.
Diagram

graph TD
  CLI["CLI option"] --> Flag["Runtime flag"] --> Video["Video modeset"] --> Prepare["Atomic request"] --> Plane[("DRM plane")]
  Flag --> OSD["OSD modeset"] --> Prepare
  Flag --> Restore["Plane restore"] --> Prepare
Loading
High-Level Assessment

The opt-in, capability-probed plane property is the appropriate approach because ASYNC_COMMIT is vendor-specific and may permit tearing. DRM_MODE_ATOMIC_NONBLOCK was reasonably dismissed because it only makes the ioctl return early rather than applying the plane update immediately.

Files changed (4) +47 / -13

Enhancement (4) +47 / -13
drm.cConditionally enable ASYNC_COMMIT during atomic preparation +28/-7

Conditionally enable ASYNC_COMMIT during atomic preparation

• Adds a silent plane-property capability check and sets Rockchip's ASYNC_COMMIT when requested. Propagates the option through initial modesets and plane restoration while retaining compatibility with drivers that lack the property.

src/drm.c

drm.hExpose asynchronous commit parameters in DRM APIs +3/-3

Expose asynchronous commit parameters in DRM APIs

• Extends the modeset, atomic preparation, and plane restoration declarations with an async-commit argument.

src/drm.h

main.cppAdd the asynchronous plane commit CLI option +14/-2

Add the asynchronous plane commit CLI option

• Introduces --async-commit-planes, documents its latency and tearing tradeoff, logs its state, and passes it into video initialization and cleanup restoration.

src/main.cpp

osd.cppApply asynchronous commit selection to OSD setup +2/-1

Apply asynchronous commit selection to OSD setup

• Passes the shared async-commit setting into the OSD plane's initial modeset.

src/osd.cpp

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Async state survives shutdown 🐞 Bug ≡ Correctness
Description
ASYNC_COMMIT is documented as persistent, but shutdown passes async_commit_planes into both
restore commits, reasserting 1 instead of restoring the planes' prior values. After one enabled
run exits, a later default run skips the setter and can therefore keep performing asynchronous,
tearing plane updates despite --async-commit-planes being absent.
Code

src/main.cpp[2019]

+	restore_planes_zpos(drm_fd, output_list, async_commit_planes);
Evidence
The new code itself states that ASYNC_COMMIT is persistent, only writes it when the option is true,
and then passes that same true value through cleanup immediately before destroying the DRM objects
and closing the fd. There is no commit that writes the property back to zero or to its startup
value.

src/drm.c[955-963]
src/drm.c[968-990]
src/main.cpp[2018-2033]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`ASYNC_COMMIT` is persistent plane state, but cleanup reasserts the enabled value and leaves it active for subsequent DRM users and later runs.

## Issue Context
Capture each selected plane's original `ASYNC_COMMIT` value before changing it. Apply the requested runtime value explicitly and restore the captured values during shutdown rather than passing the runtime enable flag through the z-position restore path.

## Fix Focus Areas
- src/drm.c[955-968]
- src/drm.c[973-990]
- src/main.cpp[2018-2033]
- src/drm.h[135-149]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Async setter failure ignored 🐞 Bug ☼ Reliability
Description
modeset_atomic_prepare_commit() ignores the result of adding ASYNC_COMMIT to the atomic request
and returns success even when that addition fails. Callers then report preparation as successful and
proceed without the requested behavior or encounter a less-specific commit failure.
Code

src/drm.c[R962-963]

+	if (async_commit && drm_object_has_property(plane, "ASYNC_COMMIT"))
+		set_drm_object_property(req, plane, "ASYNC_COMMIT", 1);
Evidence
The wrapper returns the result of drmModeAtomicAddProperty; all required properties in this
preparation routine check for a negative result, while the newly added async setter discards it and
the routine unconditionally returns zero.

src/drm.c[121-139]
src/drm.c[907-942]
src/drm.c[962-965]
src/drm.c[846-866]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Failure to add `ASYNC_COMMIT` to the atomic request is discarded, so preparation can falsely report success.

## Issue Context
The required setters in the same function return immediately on failure. Preserve the optional behavior for an absent property, but once the property has been found, propagate or clearly handle a failed `set_drm_object_property()` call.

## Fix Focus Areas
- src/drm.c[962-965]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. Packaged option documentation missing 🐞 Bug ⚙ Maintainability
Description
The new --async-commit-planes switch is parsed and shown in built-in help but is absent from the
maintained Debian manpage. Users of the packaged manual cannot discover the latency/tearing option
or its vendor-kernel restriction there.
Code

src/main.cpp[R1568-1571]

+	__OnArgument("--async-commit-planes") {
+		async_commit_planes = true;
+		continue;
+	}
Evidence
The parser and built-in help define the new option, while the manpage's option list proceeds
directly from --disable-vsync to --screen-mode-list.

src/main.cpp[1300-1303]
src/main.cpp[1568-1571]
debian/manpage.md[80-90]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new command-line option is missing from the packaged Debian manual.

## Issue Context
Mirror the built-in help text, including the Rockchip BSP requirement, silent unsupported-driver behavior, latency benefit, and tearing tradeoff.

## Fix Focus Areas
- debian/manpage.md[80-90]
- src/main.cpp[1300-1303]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/main.cpp

////////////////////////////////////////////// DRM CLEANUP
restore_planes_zpos(drm_fd, output_list);
restore_planes_zpos(drm_fd, output_list, async_commit_planes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Async state survives shutdown 🐞 Bug ≡ Correctness

ASYNC_COMMIT is documented as persistent, but shutdown passes async_commit_planes into both
restore commits, reasserting 1 instead of restoring the planes' prior values. After one enabled
run exits, a later default run skips the setter and can therefore keep performing asynchronous,
tearing plane updates despite --async-commit-planes being absent.
Agent Prompt
## Issue description
`ASYNC_COMMIT` is persistent plane state, but cleanup reasserts the enabled value and leaves it active for subsequent DRM users and later runs.

## Issue Context
Capture each selected plane's original `ASYNC_COMMIT` value before changing it. Apply the requested runtime value explicitly and restore the captured values during shutdown rather than passing the runtime enable flag through the z-position restore path.

## Fix Focus Areas
- src/drm.c[955-968]
- src/drm.c[973-990]
- src/main.cpp[2018-2033]
- src/drm.h[135-149]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread src/drm.c
Comment on lines +962 to +963
if (async_commit && drm_object_has_property(plane, "ASYNC_COMMIT"))
set_drm_object_property(req, plane, "ASYNC_COMMIT", 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Async setter failure ignored 🐞 Bug ☼ Reliability

modeset_atomic_prepare_commit() ignores the result of adding ASYNC_COMMIT to the atomic request
and returns success even when that addition fails. Callers then report preparation as successful and
proceed without the requested behavior or encounter a less-specific commit failure.
Agent Prompt
## Issue description
Failure to add `ASYNC_COMMIT` to the atomic request is discarded, so preparation can falsely report success.

## Issue Context
The required setters in the same function return immediately on failure. Preserve the optional behavior for an absent property, but once the property has been found, propagate or clearly handle a failed `set_drm_object_property()` call.

## Fix Focus Areas
- src/drm.c[962-965]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread src/main.cpp
Comment on lines +1568 to +1571
__OnArgument("--async-commit-planes") {
async_commit_planes = true;
continue;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informational

3. Packaged option documentation missing 🐞 Bug ⚙ Maintainability

The new --async-commit-planes switch is parsed and shown in built-in help but is absent from the
maintained Debian manpage. Users of the packaged manual cannot discover the latency/tearing option
or its vendor-kernel restriction there.
Agent Prompt
## Issue description
The new command-line option is missing from the packaged Debian manual.

## Issue Context
Mirror the built-in help text, including the Rockchip BSP requirement, silent unsupported-driver behavior, latency benefit, and tearing tradeoff.

## Fix Focus Areas
- debian/manpage.md[80-90]
- src/main.cpp[1300-1303]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant