Right; sorry, I'm tired. :) I was a bit sneaky with the ARM patch, since I'm using Android+fastboot with this kernel, as I think you are.

In particular, I modified Li Pengcheng's sysconf patch to also flip the bits that the ARM patch does. It seems that this works just as well (and is convenient, since that patch already ioremaps the region that the arm-tf patch writes to). New hi6220-sysconfig.c patch is attached.

I tried applying this patch to 4.9, as well. I was able to get the device to boot and recognize its ETMs, but perf dies seemingly because `sink_ops(sink)->alloc_buffer == NULL` (coresight-etm-perf.c; line 241ish). Trying to apply a patch to make that work gave me a build error, which I didn't look too much into; I'm perfectly fine with my kernel not being near AOSP's HEAD for the moment. :)

If you'd like, I'm happy to gather the hacks I made to make 4.11 play nicely with AOSP and put them in patch form tomorrow. It was mainly just me adding bits and pieces to Makefiles and crossing my fingers.

On Mon, May 22, 2017 at 10:42 PM, Sebastian Pop <sebpop@gmail.com> wrote:
Hi George,

On Tue, May 23, 2017 at 12:32 AM, George Burgess <gbiv@google.com> wrote:
> Looks like that ARM-TF patch was precisely what I was missing. :)
>
> When I set the bits that patch sets, I can now get Hikey to fully boot with
> OpenCSD's Linux branch 4.11+ETMs, and can capture perf traces like so:
> perf record -e cs_etm/@f6404000.etr/u --per-thread -- ./foo

Could you please send a patch or more explanations with what is needed?
I still have not figured out how to use the arm-tf patch that Leo pointed out.

Thanks,
Sebastian