Since the beginning of May 2018, I have been diving into the DRM subsystem. In the beginning, nothing made sense to me, and I had to fight hard to understand how things work. Fortunately, I was not alone, and I had great support from Gustavo Padovan, Daniel Vetter, Haneen Mohammed, and the entire community. Recently, I finally delivered a new feature for VKMS: the infrastructure for Vblank and page flip events.
At this moment, VKMS have regular Vblank events simulated through hrtimers (see
drm-misc-next), which is a feature required by VKMS to mimic real hardware
[1]. The development approach was entirely
driven by the tests provided by IGT, more specifically the kms_flip. I modified
IGT to read a module name via command line and force the use of it, instead of
using only the modules defined in the code (patch submitted to IGT, see [2]).
With this modification in the IGT, my development process to add a Vblank
infrastructure to VKMS had three main steps as described in the below figure:
Firstly, I focused only on the subtest “basic-plain-flip” from IGT and after
each execution of the test I checked the failure messages. Secondly, I tried to
write the required code to make the test pass; it is essential to highlight
that this phase, sometimes, took me days to understand the problem and implement
the fix. Finally, after I overcome the failure, I just put an additional effort
to improve the implementation. As can be seen in the patchset send to add the
Vblank support [3], the first set of
patches was not directly related to the Vblank itself, but it was a necessary
infrastructure required for kms_flip to work.
After an extended period of work to make VKMS pass in the basic-plain-flip, I
finally achieved it thanks to all the support that I received from the DRM
community. Next, I started to work on the subtest wf_vblank-ts-check, and
here I spent a lot of time debugging problems. My issue here was due to the
stochastic test behavior, sometimes it passed and other, it fails, and I
supposed the problem was related to the accumulation of errors during the page
flip step. As a result, I put a considerable effort to make the timer in the
page flip precise, I end up with a patch that calculates the exact moment for
the next period [4]. Nevertheless, after I submitted the patch, Chris
Wilson highlighted that I was reinventing the wheel since hrtimer already did
the required calculations [5]; he was
100% right, after his comment I looked line by line of hrtimer_forward, and I
concluded that I implemented the same algorithm. I lost some days recreating
something that is not useful in the end; however, it was really valuable for me
since I learned how hrtimer works and also expanded my comprehension about
Vblank. Finally, Daniel Vetter precisely pointed out a series of problems in
the patch [6] that not only improved the tests,
but also made most of the tests in the kms_flip pass.
In conclusion, adding the infrastructure for Vblank and page flip events in vkms was an exciting feature for VKMS, but also it was an important task to teach me how things work in the DRM. I am still focused on this part of the VKMS, but now, I am starting to think how can I add virtual hardware which does not support Vblank interrupt. Finally, I want to write a detailed blog post on how I implemented the Vblank support in the VKMS and another post about timers (users and kernel space); I believe this sort of post could be helpful for someone that is just starting in the DRM subsystem.
Thanks for all the DRM community that is always kind and provide great help for a newcomer like me :)
References
[1] “DRM misc-next”. URL: https://cgit.freedesktop.org/drm/drm-misc/. ⤴
[2] “Force option in IGT”. URL: https://www.spinics.net/lists/intel-gfx/msg170670.html. ⤴
[3] “Adding infrastructure for Vblank and page flip events in vkms”. URL: https://www.spinics.net/lists/dri-devel/msg182903.html. ⤴
[4] “Calculating the period”. URL: https://www.spinics.net/lists/dri-devel/msg182037.html. ⤴
[5] “Chris Wilson comments about hrtimer”. URL: https://www.spinics.net/lists/dri-devel/msg182037.html. ⤴
[6] “Daniel Vetter comments in V2”. URL: https://www.spinics.net/lists/dri-devel/msg182037.html. ⤴
Articles from blogs I follow around the net
Status update, November 2025
Hi! This month a lot of new features have added to the Goguma mobile IRC client. Hubert Hirtz has implemented drafts so that unsent text gets saved and network disconnections don’t disrupt users typing a message. He also enabled replying to one’s own messages…
via emersion November 16, 2025Kworkflow at Kernel Recipes 2025
This was the first year I attended Kernel Recipes and I have nothing but say how much I enjoyed it and how grateful I’m for the opportunity to talk more about kworkflow to very experienced kernel developers. What I mostly like about Kernel Recipes is its inti…
via Wen.onweb November 3, 2025October/November Conference News
The last part of October brings us a whole pile of events, with many of them featuring talks by Igalians. After the month ends, we’re looking forward to a couple of events in November. Here’s where we’ll be presenting talks: RISC-V Summit North America, O…
via Igalia October 22, 2025Generated by openring
