*

Mainline Explicit Fencing - Part 2

Gustavo Padovan avatar

Posted on 18/10/2016 by Gustavo Padovan

Share this post:

In the first article we covered the main concepts behind Explicit Synchronization for the Linux Kernel. Now in the second article of the series we are going to look to the Android Sync Framework, the first (out-of-tree) Explicit Fencing implementation for the Linux Kernel.

The Sync Framework was the Android solution to implement Explicit Fencing in AOSP. It uses file descriptors to communicate fencing information between userspace and kernel and between userspace process.

In the Sync Framework it all starts with the creation of a Sync Timeline, a struct created for each driver context to represent a monotonically increasing counter. It is the Sync Timeline who will guarantee the ordering between fences in the same Timeline. The driver contexts could be different GPU rings, or different Displays on your hardware.
 

Figure 1. Sync Timeline.

 

Then we have Sync Points(sync_pt), the name Android gave to fences, they represent a specific value in the Sync Timeline. When created the Sync Point is initialized in the Active state, and when it signals, i.e., the job it was associated to finishes, it transits to the Signaled state and informs the Sync Timeline to update the value of the last signaled Sync Point.
 

Figure 2. Sync Point.

 

To export and import Sync Points to/from userspace the Sync Fence struct is used. Under the hood the the Sync Fence is a Linux file and we use thte Sync Fence to store Sync Point information. To exported to userspace a unused file descriptor(fd) is associated to the Sync Fence file. Drivers can then use the file descriptor to pass the Sync Point information around.
 

Figure 3. Sync Fence.

 

The Sync Fence is usually created just after the Sync Point creation, it then travel through the pipeline, via userspace, until the driver that is going to wait for the Sync Fence to signal. The Sync Fence signal when the Sync Point inside it signals.

One of the most important features of the Android Sync Framework is the ability to merge Sync Fences into a new Sync Fence containing all Sync Points from both Sync Fences. It can contain as many Sync Points as your resource allows. A merged Sync Fence will only signal when all its Sync Points signals.
 

Figure 2. Sync Fence with Merged fences.

 

When it comes to userspace API the Sync Framework has implements three ioctl calls. The first one is to wait on sync_fence to signal. There is also a call to merge two sync_fences into a third and new sync_fence. And finally there is a also a call to grab information about the sync_fence and all its sync_points.

The Sync Fences fds are passed to/from the kernel in the calls to ask the kernel to render or display a buffer.

This was intended to be a overview of the Sync Framework as we will see some of these concepts on the next article where we will talk about the effort to add explict fencing on mainline kernel. If you want to learn more about the Sync Framework you can find more info here and here.

 

Original post

Comments (0)


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Latest Blog Posts

Bootstraping a minimal Arch Linux image

20/03/2019

In this tutorial, we'll look at how to create a functional and simple Arch Linux virtual machine image, that can have network access, display…

An overview of the Panfrost driver

13/03/2019

During the past few months significant progress has been made on the Open Source Arm Mali GPU driver front, culminating in the Panfrost…

Quick hack: Raspberry Pi meets Linux kernel mainline

12/03/2019

With just a few simple steps, you can compile and boot a Raspberry Pi using the Linux kernel mainline source code. Here's how.

News from the Debian Cloud Team

05/03/2019

Since the last Debian release, a number of changes have been made in the Debian Cloud Team, both on the technical & organisational level…

Panfrost update: A new kernel driver

04/03/2019

Following two months of work to develop a new kernel driver for Midgard and Bifrost GPUs, the kernel side of Panfrost is now in a form close…

Modern USB gadget on Linux & how to integrate it with systemd (Part 1)

18/02/2019

A look at how to implement USB gadget devices on Linux machines which have the necessary UDC hardware, automate the manual configfs process…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2019. All rights reserved. Website sitemap.