Skip to content

drm/virtio: validate host modes and keep the console scanout - #124

Merged
FengHeting merged 3 commits into
ViudiraTech:developfrom
FengHeting:fix/drm-virtio
Nov 2, 2026
Merged

FengHeting merged 3 commits into
ViudiraTech:developfrom
FengHeting:fix/drm-virtio

Conversation

@FengHeting

Copy link
Copy Markdown
Contributor

Summary

  • EDID replies are validated before parsing, host scanout geometry outside 0..8192 is rejected, and the initial modeset tries the EDID preferred mode, the remaining EDID modes, the host scanout modes, the bootloader geometry and the configured default, in that order. The plane atomic check rejects modes and layouts the 2D scanout cannot scale or address, and a failed initial modeset now fails KMS init instead of leaving a half-configured pipeline.
  • Closing the last DRM client clears the client cursor and flips the console framebuffer back instead of disabling the host scanout. The console framebuffer is pinned so rmfb cannot free it, the flush hooks detach when KMS is torn down, and a console flush or a dirty update from the committed primary takes the scanout back if a client flipped its own buffer. Flip error paths report which step failed.
  • Control and cursor waits only use the wait queue when the scheduler is running, interrupts are enabled and the completion IRQ is available; otherwise they keep polling to the deadline. Each log reason also gets its own ratelimit state, fixing the five same-named static definitions that made virtgpu_vq.c fail to build with CONFIG_VIRTIO_GPU=y.

Dependencies

Stacked on the drm core PR: its three commits appear in this branch until that PR merges, after which this PR reduces to the three virtio commits.

Testing

Builds with CONFIG_VIRTIO=y, CONFIG_VIRTIO_PCI=y and CONFIG_VIRTIO_GPU=y.

The connector published whatever the host returned: a short or failed
EDID read was treated as an absent display, mode sizes were trusted up
to unbounded values, and the initial modeset only walked the connector
mode list in registration order, so a bogus host mode could be picked
over the monitor's preferred one.

Validate the EDID reply before parsing it, keep the EDID modes for the
boot chain with the preferred timing first, reject host scanout
geometry outside 0..8192, and order the initial modeset by EDID
preferred, remaining EDID modes, host scanout modes, the bootloader
geometry and finally the configured default.  The plane atomic check
rejects modes and layouts the 2D scanout cannot scale or address, and
a failed initial modeset now fails KMS init instead of leaving a
half-configured pipeline.

Signed-off-by: MicroFish <2609948707@qq.com>
Closing the last DRM client disabled the host scanout even though the
kernel console still draws into that framebuffer, leaving the display
blank until another modeset or flip put a scanout back.  The close path
now clears the client cursor and flips the console framebuffer back
onto the scanout instead of disabling it.

Pin the console framebuffer at the initial modeset so rmfb cannot free
the buffer the console draws into, detach the console flush hooks when
KMS is torn down, and let a console flush reclaim the scanout if a
client flipped its own buffer onto it.  A dirty update from the
committed primary framebuffer also takes the scanout back, and the flip
error paths report which step failed.

Signed-off-by: MicroFish <2609948707@qq.com>
The control and cursor wait loops took the wait-queue path whenever the
scheduler was up, even when interrupts were disabled or the completion
IRQ was unavailable.  The timed wait then has no timer tick or
completion IRQ left to wake it, so the caller can sleep with no wakeup
event instead of polling the queue.  Only defer to the wait queue when
the timer tick and the completion IRQ can both run, and only yield
between polls in that state; otherwise keep polling to the deadline.

Each log reason also declared a static ratelimit state with the same
name in the same switch scope, which is a redefinition.  Give every
reason its own state so the file builds with the driver enabled and
each failure keeps its own log budget.

Signed-off-by: MicroFish <2609948707@qq.com>
@FengHeting
FengHeting changed the base branch from master to develop November 2, 2026 20:15
@FengHeting
FengHeting merged commit d1f0090 into ViudiraTech:develop Nov 2, 2026
2 checks passed
@FengHeting
FengHeting deleted the fix/drm-virtio branch November 2, 2026 20:59
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