Skip to content

nvidia-drm: Skip empty atomic commit in nv_drm_revoke_modeset_permission - #1397

Open
Himesh-Kundal wants to merge 1 commit into
NVIDIA:mainfrom
Himesh-Kundal:fix-drm-revoke-empty-commit
Open

Himesh-Kundal wants to merge 1 commit into
NVIDIA:mainfrom
Himesh-Kundal:fix-drm-revoke-empty-commit

Conversation

@Himesh-Kundal

@Himesh-Kundal Himesh-Kundal commented Sep 24, 2026 •

Copy link
Copy Markdown

Description

When any process holding an open DRM file descriptor closes it (such as client utilities, browsers, or Wayland sub-processes), nv_drm_revoke_modeset_permission() is called to revoke modeset permissions and disable associated connectors.

In the current implementation, if the closing file descriptor did not hold modesetting permissions on any connector, drm_atomic_commit(state) is still unconditionally called with an empty atomic state transaction.

Submitting an empty atomic commit:

  1. Incurs unnecessary hardware and modeset lock contention with active page flips and compositors.
  2. Triggers redundant DRM atomic check/commit pipeline execution.

Proposed Change

Introduce a flag (need_commit) during the connector iteration. Only invoke drm_atomic_commit(state) if at least one connector was actually modified/revoked. If no connector state was altered, the allocated state is simply freed via nv_drm_atomic_state_base_put(state).

This mirrors the existing conditional commit pattern used in nv_drm_plane_reset_input_colorspace() in the same file and follows NVIDIA's convention of using braces around single-statement control blocks in this driver.

Testing & Validation

Tested on a hybrid Intel UHD + NVIDIA GeForce RTX 4050 Mobile system driving an external 1440p display over direct HDMI under Wayland (Hyprland / Aquamarine):

  1. Non-modeset client teardown (need_commit == false):

    • Repeatedly opened and closed DRM file handles from non-modeset clients (monitoring utilities, hardware-accelerated browsers, and Vulkan compute clients).
    • Confirmed that nv_drm_revoke_modeset_permission() exits without submitting an empty atomic commit, freeing state cleanly with zero lock contention on active compositor page flips.
  2. Legitimate modeset revocation (need_commit == true):

    • Executed VT switches (chvt 1 / chvt 2) and compositor exits where DRM master permissions are actively relinquished.
    • Confirmed nv_drm_atomic_disable_connector() sets need_commit = true, and drm_atomic_commit(state) executes normally without regressions or connector state leaks.
  3. Selective revocation (dpyId != 0):

    • Verified that selective display revocation only marks need_commit = true when the specific display ID matches the closing file descriptor.

@CLAassistant

CLAassistant commented Sep 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

When a non-modesetting client (such as a browser or monitoring utility)
closes its DRM file descriptor, nv_drm_revoke_modeset_permission() is invoked.
If no connector was owned by the closing file descriptor, submitting an
empty atomic state commit to the hardware is unnecessary and risks contending
with active atomic page flips.

Only submit drm_atomic_commit() if at least one connector was actually
revoked and disabled.

Signed-off-by: Himesh-Kundal <infernoemperor@proton.me>
@Himesh-Kundal
Himesh-Kundal force-pushed the fix-drm-revoke-empty-commit branch from 4eec259 to 82ec20d Compare September 24, 2026 23:11
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.

2 participants