Matthew Garrett: Radeon reclocking
Alex released another set of Radeon power management patches over the weekend, and I've been adding my own code on top of that (Alex's patches go on top of drm-next, mine go on top of there). I've left it stress-testing for a couple of hours without it falling over, which tells me that it's stable enough that I can feel smug. This is a pleasing counterpoint to the previous experiences I've been having, which have been rife with a heady mixture of chip lockups or kernel deadlocks. It turns out that gpus are hard.There's a few things you need to know about gpus. The first is that if they're discrete devices they typically have their own memory controller and video memory. The second is that there's an impressive number of ways that you can end up touching that memory. The third is that they tend to get upset if something tries to touch that memory and the memory controller is in the middle of reclocking at the time.
The first and most obvious use of video memory is by the gpu itself. Accelerated operations on radeon are carried out by sending a command packet to the command processor. This is achieved by sharing a ring buffer between the cpu and the gpu, with the gpu reading packets out of that ring buffer and performing the operations contained within them. Many of these operations will touch video memory (that being the nature of most things you want a gpu to do), and if that happens bad things occur. Like the card locking up and potentially taking your PCI bus with it.
So, obviously, we don't want that to happen. The first thing we do is take a mutex that blocks any further accelerated operations from being submitted by userspace. Then we wait until we get an interrupt from the gpu telling us that the display engine has gone idle. The problem here is that we don't have a terribly good idea of how many more operations there are to complete and we don't know how long each of those operations is going to take, but this is less bad than some of the alternatives[1]. Jerome Glisse has some ideas on how to improve this to require less waiting, but the effects should still be pretty much invisible to the average user.
So we've stopped the command processor touching ram. Everything's good, right?
Well, not really. The obvious problem is that users typically want to display something, so there's a separate chunk of chip that's repeatedly copying video memory over to your monitor. That's got to go too. Thankfully, there's a convenient bit in the crtc registers that lets us turn that off, but the pretty unsurprising downside is that your screen goes blank while that's happening. So we don't want to do that. Instead, we try to perform the reclock while there's nothing being displayed on the screen - that is, while we're in the screen region where a crt's electron gun would be scanning back from the bottom of the screen to the top. It turns out that rather a lot of display assumptions depend on this happening even if there's no crt, no electron gun and no thick sheet of glass with a decent approximation of vacuum behind it, so we get to do this even if we're displaying to an LVDS. And we have about 400-500 microseconds to do it - an almost generous amount of time.
So we ask the hardware to generate an interrupt when we enter vblank and then we reclock. Except the hardware has an irritating habit of lying - sometimes we get the interrupt a line or two before vblank, sometimes we get it after we've already gone out the other side. Vexing, and not entirely solved yet - so sometimes you'll still get a single blank frame during reclock. But there are plans, and they'll probably even work.
At this point the acceleration hardware isn't touching the memory and the scanout hardware isn't touching the memory. Except it still crashes under some workloads. This one took me longer to track down, but the answer turned out to be pretty straightforward. Not all operations are accelerated. When they're not accelerated they have to be done in software. That means that the CPU has to write to the video memory itself. I'm sure you can see where this is going. This was fixed without too much trouble once I'd finished picking through the driver to work out every location where objects might be mapped into the CPU's address space, at which point it's a simple matter of unmapping them and blocking the fault handler from remapping them until the reclock is finished. Linux, thankfully, has lots of synchronisation primitives. And now everything works.
Except when it doesn't. This took a final period of head scratching, followed by the discovery that ttm (the memory allocator used by radeon) has a background thread that would occasionally fire to clean up objects. And by clean up objects, I mean change their mapping - which means updating their status in the gart, which means touching video memory. So, let's block that. And that tripped me off to the fact that even if it couldn't submit new commands, the CPU could still create or destroy objects - with the same consequences.
So, once all of these are blocked, video memory is quiescent and we can do what we want. And we do, at least once I'd sorted out the bits where I was taking locks in the wrong order and deadlocking. Depending on the powerplay tables available on your card we'll chose different rates and so your power savings will vary heavily depending on the values that your vendor provided, but the card I'm testing on sees a handy 30W drop at idle. Right now we're only changing clocks and not dropping voltage so there's potentially a little more to come.
While getting this stable was pretty miserable, the documented entry points for clock changing made a lot of this easier than it would otherwise have been. It's also probably worth noting that Intel's clock configuration registers are entirely missing from any public documentation and the dirver Intel submitted to make them work in their latest chips appeared to have been deliberately obfuscated, so thanks to AMD for making all of this possible.
[1] It's possible to insert various command packets that either indicate when they've passed or stall until a register value gets updated, but these either cause awkward problems with the cp locking or mean that the gui idle functionality never goes idle, so they're not ideal either.
... or as some fellow DD said, one year ago: "j'ai 1000 ans".
So what happened during last year, the DVCS way:
We've yesterday
I've asked the weavers to start
First, I was pleasantly surprised to discover that
Over the last few months 


I bought my current cell phone in mid January 2008, which means I have had it for ~830 days.
I tend not to lose sight of the few things I keep on me at all times - Keys, wallet and cell phone. In this 830 day period, I doubt I have forgotten my phone for more than three days. Ok, lets just add some extra five days, for times I have travelled without the phone charger, resulting in me not having a phone available. So, eight days out of 830 gives us that the probability for me accidentally not having access to my phone for a whole day is close to 0.01, or 1% P(stupid) 0.01.
I am not a heavy phone user. Far from it, I tend not to like using the phone. My calls are always kept to the minimum necessary, and I would not be surprised if I used my phone typically less than twice per week. However, there is a recurring event that makes my phone ring more often during certain very well defined periods of the year, with 1/365 probability. So, lets call this P(birthday) 0.00273.
Yesterday I spent the day with some good, very long time friends. We did the April Ciclot n - I biked for 42 very nice kilometers, they did 36 (as we met 8Km away from my home ;-) )... but yes, after a while, I left my phone at my friends' table.
So I guess today the phone will ring way more insistently than usual. At a table far away from home. With a probability of P(stupid birthday) 2.73 10 .
So I'm facing the enjoyment of a very improbable day!
A few hours ago, I sent the following to both the R development list and the informal R / GSoC list:
Earlier this month, I applied to the Mono Project (and the University of Washington, and Ubuntu, and Debian, and The Perl Foundation) requesting a mentor to get Perl6 hosted on the DLR.
Last Tuesday,
Some months ago I
Dear Gerhard,
one week after you have left us after your long fight and we payed one s last respects to you today, you hopefully may find your peace!
Thanks for all the things you have done for your family.
I d like to extend a warm welcome to our selected students for the 2010 Debian Google Summer of Code!
They should pop up on Debian Planet soon and you re welcome to come talk to them on #debian-soc on irc.debian.org
Aptitude Qt
by Piotr Galiszewski, mentored by Sune Vuorela
Qt GUI for aptitude. Currently, KDE users need to use Aptitude via the console interface, or install the newly developed GTK frontend, which does not fit well into KDE desktop. Making Qt frontend to Aptitude would solve this problem and bring an advanced and fully Debian-compliant graphical package manager to KDE.
Content-aware Config Files Upgrading
by Krzysztof Tyszecki, mentored by Dominique Dumont
When a package deliver configuration files, the problem of merging user data with new configuration instructions will arise during package upgrades on users systems. Sometimes merging can be done with 3 way merge, but this process does not insure that the resulting file is correct or even legal. This project intends to create standards, tools an heuristics to make the scary config file conflict resolution debconf prompt a thing of the past.
Debbugs Bug Reporting and Manipulation API
by David Wendt Jr., mentored by Bastian Venthur
Currently debbugs supports a SOAP interface for querying Debian s Bug Tracking System. Unfortunately this operation is read-only. This project would create an API for debbugs which supports sending and manipulating bug reports, without having to resort to email. This project does not intend to replace email as mean to manipulate the BTS but rather to enhance the BTS to allow other means of bug creation and manipulation.
Debian High Performance Computing on Clouds
by Dominique Belhachemi, mentored by Steffen Moeller
The project paves a way to combine the demands in high performance computing with the dynamics of compute clouds with Debian. Combining the Eucalyptus cloud computing infrastructure with the TORQUE resource manager and preparing the components for dynamically added and removed instances provides the user with a attractive high performance computing environment. Such a system allows users to share resources with large compute centers with minimal changes in their workflow and scripts.
Debian-Installer on Neo FreeRunner and Handheld Devices
by Thibaut Girka, mentored by Gaudenz Steinlin
This project aims to improve the installation experience of Debian on handheld devices by replacing ad-hoc install scripts by a full-blown and adapted Debian-Installer. The Neo FreeRunner is used as it is the most convenient and open device from a development standpoint, but other devices will also be explored.
Hurd port and de-Linux-ization of Debian-Installer
by J r mie Koenig, mentored by Samuel Thibault
The primary means of distributing the Hurd is through Debian GNU/Hurd. However, the installation CDs presently use an ancient, non-native installer. The goal of this project is to port the missing parts of Debian-Installer to Hurd. To achieve this, all problematic Linux-specific code in Debian-Installer will be replaced by less or non-kernel dependent code, paving the way for better support of other non-Linux ports of Debian.
Multi-Arch support in APT
by David Kalnischkies, mentored by Michael Vogt
Hardware like 64bit processors are perfectly able to execute 32bit opcode but until now this potentiality is disregard as the infrastructure tools like dpkg and APT are not able to install and/or solve dependencies across multiple architectures. The project therefore focuses on enabling APT to work out good solutions in a MultiArch aware environments without the need of hacky and partly working biarch packages currently in use.
Package Repository Analysis and Migration Automation
by Ricardo O Donell, mentored by Neil Williams
Emdebian uses a filter to select packages from the main Debian repositories that are considered useful to embedded devices, excluding the majority of packages. The results of processing the filter are automated but maintaining the filter list is manual. This project seeks to automate certain elements of the filtering process to cope with specific conditions. This project will also generalize to more elaborate and intelligent algorithms to improve the transitions of the main Debian archives.
Smart Upload Server for FTP Master
by Petr Jasek, mentored by Joerg Jaspert
Making packages upload smarter, more interactive and painless for uploaders by switching from anonymous FTP and Cron jobs to a robust protocol and modern package checking and processing daemon. This daemon would test early and report early, saving developers time.
Dear Lazyweb:
Can you suggest open source content management software that meets these criteria:
Last weekend, I went to the Grenslandhallen in Hasselt, to see
Belgium compete against Estonia in a Fed Cup tie of the World Group
playoffs. The winner of this tie would gain a seat in the top-tier World
Group next year, which opens the possibility of winning this
competition.
The Belgian team was the strongest possible one, with all four best
Belgian female tennis players Yanina Wickmayer, Kim Clijsters,
Justine Henin, and Kirsten Flipkens. On paper, the team should not have
had any problems beating the Estonian team.
Unfortunately, Justine fractured her pinky finger during practice on
wednesday; and while it did not make it impossible for her to play, it
did reduce her fitness somewhat, which meant that on Saturday, Kim and
Yanina had to defend the Belgian colors. They did and won, but then Kim
injured some muscle in her foot, which made it hard for her to walk on
Sunday, let alone play.
With only Justine, Yanina, and Kirsten available, coach Appelmans
chose to put Justine on the field. Though she made a valiant effort, she
unfortunately did not manage to beat an unleashed Kaia Kanepi,
who it must be said played a terrific match. As such, it
fell on Yanina to bring home the tie in the fourth singles rubber
against Maret Ani. Being a bit nervous in the start of the first set,
she made some unnecessary errors; but after a few games, she came
through and started to play much better. Unfortunately, by that time the
score was already at 5-1. Yanina won her first service game of the match
to bring it to 5-2, but it wasn't enough, and Ani won the first set
somewhat easily.
She couldn't put anything on the table against a storming Wickmayer,
however, and after two more sets, the outcome of the match and, by
extension, the tie was clear: a win for Belgium.
I can't help but note that Wickmayer has been a great player for the
Belgian fed cup team these past few years, however. Since her first Fed
Cup participation in 2007, she holds what is, given her ranking at the
time, a rather impressive 9-4 win-loss record in Fed Cup. If it wasn't
for Wickmayer, the Belgian team would not be where it is now. It was
Wickmayer who won her three matches against Canada, one as part of a
doubles team, to prevent demotion from world group II to the
Europe/Africa zone back in 2009, with a 3-2 score. It was Wickmayer who
won the crucial third rubber against higher-ranked Radwanska in February
to beat Poland, with the latter even holding the home field advantage.
And it's now been Wickmayer who won two of the three rubbers against
Estonia that were needed to win the tie.
So Congrats, Yanina!
Having my primary working Computer, a Lenovo Thinkpad, going into
repair at the end of December I finally got up to ordering on of those
I'm going to Debconf 10:
my current list of worked on RC bugs; not many for two weeks but I was on
vacation for almost a week ...
Even though I do not understand the whole European
campaign-period concept, I kept my mouth shut even
though it was at odds with trying to answer every
question, no matter how stupid. I give props to
Jeroen for his efforts in question-answering that
year, even though the electorate obviously never
cares about that.
I wanted to answer all questions directed to all
candidates (excluding replies for the same reason
that I only responded on-list to questions directed
explicitly at me), but did not.
Quite a bit of the encouragement I have received
after the fact has been from people who are not
DDs. I find this strange since most of what I
have said has been about the enfranchisement of
DDs, and nothing about non-DDs. I could
speculate about why this might be the case, but
I will refrain.
We now return you to your regular program.