vcio2 - Kernel driver to access Raspberry Pi VideoCore IV GPU without root privileges

When using Raspberry Pi's GPU from user space (e.g. gpu_fft) with the built vcio driver in the RPi kernel you need to have root privileges for every application.
The goal of the vcio2 driver is to come around this restriction. Furthermore vcio2 keeps track of the resources and performs a clean-up if the application is interrupted.

▼ Features, ▼ Limitations & problems ▼ Installation instructions, ▼ Using the driver, ▶ Sample code, ▶ Programming guide, ▶ API reference, ▼ Contact

Download & history

Download DKMS kernel module, an example and this documentation

V0.1
First public release.

Features

Installation instructions

Prerequisites

Build and install the driver

Normally this should build the kernel module using DKMS, install it for the currently running kernel, setup the driver for autostart and load the driver. So you are ready to use immediately.

If it does not work, have a look at the error messages on the screen as well as /var/dkms/vcio2/0.1/build/make.log and /val/log/syslog.

Remove the driver

This will unload the kernel module and uninstall it.

Using the driver

As soon as the driver is loaded successfully, two new devices appear in the /dev directory.

/dev/vcio
This is a device compatible to the one used by hello_fft. You can use a symbolic link to this device for the char_dev required by hello_fft instead of creating a character device with mknod. This enables you to run hello_fft from a remote file system.
Using this device does not offer the features of vcio2.
/dev/vcio2
This is the new device which offers new features. Using this device requires changes to the source code of the application. See the API reference and especially the migration guide.
You might want to grant access to this device to some group to prevent the need of root privileges to use the GPU. I.e. chmod 660 and chgrp. You might also set up a udev rule to set this permissions automatically. (Who knows how to do this?)
Note that access to this device is still a major security hole, suitable to gain root privileges. This is due to the fact that the GPU bypasses the MMU. The risk is comparable to a kernel debug permission.

See vcio2 programming guide for further details.

Patching the kernel

Since the driver is compatible to bcm2708_vcio, it could be used as replacement as part of the kernel. However, this would require you to compile your own kernel on each update. You do not want to compile this on the Raspberry, because it takes a whole day. Using a cross compiler will result in reasonable times.

In fact this was my first approach. But for now a DKMS driver is easier to use. If someone thinks that it should be part of the RPi kernel and knows how to contribute, let me know.

Limitations and known problems

Limitations

Bugs

TODOs

Contact

Comments, ideas, bugs, improvements to raspi at maazl dot de.