Page MenuHomeFreeBSD

Add a virtio-gpu 2D driver
AcceptedPublic

Authored by andrew on Sun, May 14, 8:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 26, 4:59 PM
Unknown Object (File)
Mon, May 22, 5:21 AM
Unknown Object (File)
Wed, May 17, 10:15 AM
Unknown Object (File)
Wed, May 17, 9:48 AM

Details

Reviewers
bryanv
dch
manu
Summary

Add a driver to connect vt to the VirtIO GPU device in 2D mode. This
provides a output on the display when a qemu virtio gpu device is
added, e.g. with -device virtio-gpu-pci.

Tested on qemu using UTM, and a Hetzner arm64 VM instance.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 51488
Build 48379: arc lint + arc unit

Event Timeline

dchagin added inline comments.
sys/dev/virtio/gpu/virtio_gpu.c
2

By 4d846d26 this clause is changed

jrtc27 added inline comments.
sys/dev/virtio/gpu/virtio_gpu.c
70

?

154

?

223

Why here?

227

Why not?

294

!= 0

295

Print error

302

!= 0

303

Print error

311

!= 0

312

Print error

325

!= 0

326

Print error

331

!= 0

332

Print error

338

!= 0

339

Print error

350

!= 0

364

Various attach error paths end up here with one or both not allocated yet

390

!= 0

396

Why here

430

?

451

Print error

457

Print error

462

Print error

477

If this is to avoid implicit padding you should probably be documenting that, maybe also with a CTASSERT

517

Ditto

552

[1]? Huh?

sys/dev/virtio/gpu/virtio_gpu.c
534

Uhh

572

Ditto

609

Ditto

645

Ditto

681

Ditto

sys/dev/virtio/gpu/virtio_gpu.c
135–138

What should happen for these functions when there's an error?..

344–347

These surely need to check for errors though?

sys/dev/virtio/gpu/virtio_gpu.c
35

Don't need that any more?

Thanks so much for this work! 1-2 years back I think there was an effort to port the full Linux DRM virito_gpu driver over, but I believe that work has stalled. This is great to have.

sys/dev/virtio/gpu/virtio_gpu.c
228

Yah while here, might as well add the currently defined feature bits: https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-3680003, so the probe/attach can print the feature names instead of hex values.

299

It looks like gpucfg isn't later used - I'm not sure if there is anything to gain though with the current code by using gpucfg.num_scanouts in vtgpu_get_display_info() instead of always MAX_SCANOUTS.

431

I think a strict reading of the spec requires this queue (so the guest presents 2 queues); actual devices may be lenient though. I believe this queue is guest -> host only so should be able to include it here but otherwise not actually use it; or did qemu have some error with this?

527

The RHS should be wrapped in the appropriate htoleXX() to ensure they're LE. Similarly, fields read from the responses will need leXXtoh(). The Virtio spec will denote these fields as le{16,32,64}. I don't believe the GPU device was ever a "legacy" (pre V1 spec) device, so there isn't a need to handle the pre-V1 guest endian stuff the other drivers do.

This revision is now accepted and ready to land.Fri, May 26, 3:19 AM

reminder: this driver needs a man page, and an entry in virtio(4)