Repository navigation
feat(graphics): drove virtio-gpu's hardware cursor - #462
Merged
Merged
Conversation
virtio-gpu reported no cursor, so moving a pointer meant presenting a frame. Each picture is padded into one 64 by 64 resource, the only size the device draws, and every display only records a hidden cursor's move.
FlareCoding
force-pushed
the
pr/virtio-gpu-cursor
branch
from
October 25, 2026 22:03
3001327 to
0192977
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
virtio-gpu drives the device's hardware cursor (a small picture of up to 64 by 64 pixels that the device draws over what the scanout shows) for gfxfb's GFXFB_SET_CURSOR and GFXFB_MOVE_CURSOR, so a client can move a pointer without presenting a frame.
Changes
virtio_gpu_drivermakes one 64 by 64 cursor resource (the device's own copy of the cursor's picture) at attach, andset_cursor()pads each picture with transparent pixels into the resource's RAM, waits for the device to confirm the copy, then sends UPDATE_CURSOR on the device's cursor queue.move_cursor()sends MOVE_CURSOR naming the cursor resource, since QEMU's device hides the cursor on a move naming none.cursor_corner()holds the picture's top-left corner to at most 64 pixels left of or above the scanout, past which nothing shows.move_cursor()doc extends the move that only records the position from before any picture to after a hide as well, and virtio-gpu'smove_cursor()sends nothing while the cursor is hidden.answer_deadline()), as each command batch of a present is. An UPDATE_CURSOR or MOVE_CURSOR the device has not handed back by its deadline fails the display with a log line of its own.read_output()reports a 64 by 64 cursor maximum for each scanout, lit or dark, since the device has a cursor on each.attach()routes the cursor queue to the control queue's MSI-X vector, since every wait that sleeps on it holdsm_batch_lock.detach()freeing the cursor's RAM after a failed attach,ERR_REFUSED, "device stopped answering cursor commands" andanswer_deadline()'s minimum are checked by reading.Note
Medium Risk
Adds kernel display-driver paths (DMA, virtqueues, timeouts) on the lit scanout; failures can mark the device broken like unanswered present batches.
Overview
virtio-gpu now drives the device’s 64×64 hardware cursor for gfxfb’s
GFXFB_SET_CURSOR/GFXFB_MOVE_CURSOR, replacing the previousERR_UNSUPPORTEDstubs.At attach it sets up the cursor virtqueue, a dedicated B8G8R8A8 cursor resource, and MSI-X routing shared with the control queue.
set_cursor()pads images into that resource,TRANSFER_TO_HOST_2Don the control queue, thenUPDATE_CURSOR(hide uses resource id 0).move_cursor()issuesMOVE_CURSORonly when the cursor is visible; otherwise it only updates stored coordinates.cursor_corner()clamps position for hardware limits. Completion waiting is generalized viawait_for_used()andanswer_deadline()(same minimum wait as presents).read_output()advertises a 64×64 cursor on every scanout.gfxfb docs clarify that
move_cursor()while hidden—before any picture or after a hide—only records position; gfxfb_node comments note cursor calls never wait on present locks.Reviewed by Cursor Bugbot for commit 3001327. Bugbot is set up for automated code reviews on this repo. Configure here.