[Solved]GK20a driver got error running in non-secure world on jetson tk1

Hi all,
I’m porting a tee-based secure os to jetson tk1.
Now after the secure world worked, the l4t(r21.1) could start up console on ttys0 properly in non-secure world. But it can not start a desktop as there are always errors that gk20a driver crushed as:

[ 27.697037] mc-err: [mcerr] (gpu) csr_gpusrd: EMEM address decode error
[ 27.703641] mc-err: [mcerr] status = 0x20000058; addr = 0x00109000
[ 27.709807] mc-err: [mcerr] secure: no, access-type: read, SMMU fault: none
[ 27.717248] Unable to handle kernel NULL pointer dereference at virtual addre ss 00000000
[ 27.725367] pgd = c0004000
[ 27.728083] [00000000] *pgd=00000000
[ 27.731681] Internal error: Oops: 805 [#1] PREEMPT ARM
[ 27.736807] Modules linked in:
[ 27.739863] CPU: 0 PID: 59 Comm: irq/189-gk20a_s Not tainted 3.10.40-g6ed046f -dirty #31
[ 27.747850] task: eba215c0 ti: eba3c000 task.ti: eba3c000
[ 27.753244] PC is at __mutex_lock_slowpath+0x54/0x14c
[ 27.758287] LR is at gk20a_fifo_isr+0x3c/0x1bc
[ 27.762721] pc : [] lr : [] psr: a0000113
[ 27.762721] sp : eba3dee8 ip : 00000000 fp : 00000000
[ 27.774175] r10: eba3a0cc r9 : 00000000 r8 : c0b9890c
[ 27.779387] r7 : eba215c0 r6 : c0d39adc r5 : eba3a0c8 r4 : eba3c000
[ 27.785898] r3 : 00000000 r2 : eba3deec r1 : 00000000 r0 : eba3a0c8
[ 27.792412] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kern el
[ 27.799705] Control: 10c5387d Table: adcd8059 DAC: 00000015
[ 27.805437]
[ 27.805437] PC: 0xc07f0760:
[ 27.809695] 0760 ea0003d6 e92d4000 e8bd4000 e1902f9f e2822001 e1801f92 e3310 000 1afffffa
[ 27.817913] 0780 e3520000 c12fff1e eaffffdc e92d45f0 e24dd014 e92d4000 e8bd4

[ 28.651181] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 fffff ffd ffffffff
[ 28.659354] [] (__mutex_lock_slowpath+0x54/0x14c) from [] (gk20a_fifo_isr+0x3c/0x1bc)
[ 28.668913] [] (gk20a_fifo_isr+0x3c/0x1bc) from [] (gk20a _intr_thread_stall+0xe0/0x290)
[ 28.678645] [] (gk20a_intr_thread_stall+0xe0/0x290) from [] (irq_thread+0xd4/0x128)
[ 28.688029] [] (irq_thread+0xd4/0x128) from [] (kthread+0 xc4/0xd0)
[ 28.695940] [] (kthread+0xc4/0xd0) from [] (ret_from_fork +0x14/0x20)

Does the GK20a driver can not handle properly in non-secure world? Or I need some configuration in secure world?

Problem Solved, please refer to sysbre’s post below.

Hi extend_chen,

I have exactly the same problem.
I’m trying to run jetdroid in the unsecure world and unfortunately i’m facing the same issue…

Any idea ?

@ sysbre, till now I didn’t find any clue (I haven’t read gk20a manual before), but still keep going on it.
I’d like to update you if there some results.And please let me know if you made progress. Thanks.

Hi extend_chen
The problem is solved on my side.
It was due to the smmu configuration.
Some registers used to configure the smmu are Trustzone secured (see MC_register part in the documentation).

in the file drivers/iommu/tegra-smmu.c the following registers are used but cannot be R/W in non secure world:
0x70019010 SMMU_CONFIG
0x70019228 SMMU_TRANSLATION_ENABLE_0

this part of the configuration needs to be done by the secure world.

Regards,

@ sysbre, you just saved me, very appreciated! :)
After replace the read/write of those register with a secure version, L4t finally booted up.
Thanks again.

0x70019010 SMMU_CONFIG
0x70019228 SMMU_TRANSLATION_ENABLE_0
The two register how to Set up,thanks