powerpc/powernv: Use darn instruction for get_random_seed() on Power9
authorMatt Brown <matthew.brown.dev@gmail.com>
Fri, 4 Aug 2017 01:12:18 +0000 (11:12 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 8 Aug 2017 09:37:03 +0000 (19:37 +1000)
commite66ca3db5917f4bcad039d3a3df9f1003797c249
tree46b0b0ca669a0be0d4bac2e63ca175f0da703dba
parent64d0a506fbdd64906f168539bee32ac7dcabb521
powerpc/powernv: Use darn instruction for get_random_seed() on Power9

This adds powernv_get_random_darn() which utilises the darn instruction,
introduced in ISA v3.0/POWER9.

The darn instruction can potentially return an error, which is supported
by the get_random_seed() API, in normal usage if we see an error we just
return that to the caller.

However when detecting whether darn is functional at boot we try up to
10 times, before deciding that darn doesn't work and failing the
registration of get_random_seed(). That way an intermittent failure
at boot doesn't deprive the system of randomness until the next reboot.

Signed-off-by: Matt Brown <matthew.brown.dev@gmail.com>
[mpe: Move init into a function, tweak change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/ppc-opcode.h
arch/powerpc/platforms/powernv/rng.c