tools: add intel_residency

After the recent discussions regarding the effects of the vblank
disabling policies on PC state residencies, I started running some
experiments to reevaluate some non-intuitive conclusions I had
reached. In order to help me do this, I decided to write this tool.

The idea is very simple: the tool puts the system on an screen-on idle
state, checks which PC state residency is the deepest we can reach,
measures its residency, then does some not-so-idle tests and measures
the residencies. You can use the tool to compare different Kernel
trees and you can also use the tool to compare enabled vs disabled
features.

It's obvious that these cases do not represent real-world use cases of
our driver, but they are already enough to highlight differences
between the many patches I wrote. I was even able to catch a bug in
one of my patches by spotting an unexpected regression in the
residencies.

I've been using this tool for FBC, but I expect it to also be useful
for PSR, DRRS and similar features. I've been measuring the effects of
different optimizations I wrote, and I've also been measuring the FBC
vs no-FBC cases.

It is also important to highlight that if your system is not properly
configured for efficient power savings the tool may not be able to
show differences between the results. On my Broadwell machine, for
example, if I don't run "powertop --auto-tune" before running the
tool, I get PC2 as the deepest state, and 90%+ residency for every
workload. After properly configuring the machine, I get PC7 as the
deepest state, which is the expected.

So far I only tested this tool on BDW and SKL, and it may hit some
unexpected assertions for older platforms.

I only implemented the cases that are immediately useful for me, but
we may also expand the tool in the future. We can add more important
workloads. We can add support for screen-off cases, so we can compare
the effects of runtime PM and other screen-off features. There's a lot
we can do, but none of this is on my current priority list.

And remember: /usr/bin/paste is your friend when comparing results.

v2:
  - Be more idle at setup_idle().
  - Improve printing for /usr/bin/paste usage.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
diff --git a/tools/Makefile.sources b/tools/Makefile.sources
index 5c6dc93..5d5958d 100644
--- a/tools/Makefile.sources
+++ b/tools/Makefile.sources
@@ -29,6 +29,7 @@
 	intel_panel_fitter		\
 	intel_perf_counters		\
 	intel_reg_checker 		\
+	intel_residency			\
 	intel_stepping 			\
 	intel_watermark