Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Freakqency/ad7dcca7fd8b3a1a689abb8e4d2bdb74 to your computer and use it in GitHub Desktop.
Save Freakqency/ad7dcca7fd8b3a1a689abb8e4d2bdb74 to your computer and use it in GitHub Desktop.

Implementation of DRM ioctl and compat_netbsd32 DRM ioctls support for NetBSD kernel

This article was prepared by Surya P as a part of Google Summer of Code 19

To begin with where we left off last time, we were able to fix the suse131 package with this commit.This commit adds the gpu specific bits to the package. And with that we had direct rendering enabled and working.I tested it out with glxinfo and glxgears applications.

1

2

Testing

In order to make sure that the application does not break. I also tried out Libreoffice. And to no surprise everything ran as expected without any hiccups.

Then I had to make a choice between porting steam and implementing compat_netbsd32 but since steam had lot of dependencies which needed to be resolved and since implementation of compat_netbsd32 had much more priority I started with the implementation of compat_netbsd32.

Implementing compat_netbsd32 DRM ioctls - The Setup

For the Setup I downloaded i386 sets from the official Netbsd site and extracted it in the /emul directory. I ran some arbitrary programs like cat and ls from the emulated netbsd32 directory to make sure everything ran perfectly without any problems. I then tried running the 32bit glxinfo and glxgears application and to no surprise it kept segfaulting. I ktraced the application and identified the DRM ioctl that needed to be implemented.

Implementing compat_netbsd32 DRM ioctls - The Code

There were several functions which were required for the complete working of the compat_netbsd32 DRM ioctl. We implemented each and every function and had the code compiled. We then made sure that the code compiled both as a module and as well as a non module option with which the kernel can be built.I initially tested the code with 32bit glxinfo and glxgears , and the program didn't segfault and ran as expected.

Implementing compat_netbsd32 DRM ioctls - Testing

In order to test the code I built a test application leveraging the api's provided in libdrm. It is a very simple application which initializes the DRM connection, setup and draws a gradient on screen and exits. I initially ran it against the native amd64 architecture, but to my surprise the application didn't work as expected. After some hours of debugging I realized that there can be only one DRM master and X was already a master. After exiting the X session and running the application , everything ran perfectly for both amd64 as well as i386 architectures.

3 4

What is done

TODO

  • Create an ATF for the code and merge it into the tree
  • Read the code, look for bugs and clean it up
  • Port Steam and make it available in Netbsd

Conclusion

Completing the tasks listed in the TODO is of highest priority and would be carried over even if it exceeds the GSOC time period.

Last but not the least I would like to thank my mentor's @christos and @maya for helping me out and guiding me throughout the process and Google for providing me with such a wonderful opportunity to work with NetBSD community.

For more info checkout my previous report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment