: sparc64: Add Niagara2 RNG driver.
PATCH 2/2 : sparc64: Add Niagara2 RNG driver.
--- drivers/char/hw_random/Kconfig | 13 + drivers/char/hw_random/Makefile | 2 + drivers/char/hw_random/n2-asm.S | 93 +++++ drivers/char/hw_random/n2-drv.c | 771 +++++++++++++++++++++++++++++++++++++++ drivers/char/hw_random/n2rng.h | 118 ++++++ 5 files changed, 997 insertions(+), 0 deletions(-) create mode 100644 drivers/char/hw_random/n2-asm.S create mode 100644 drivers/char/hw_random/n2-drv.c create mode 100644 drivers/char/hw_random/n2rng.h
drivers/char/hw_random/Kconfig +13 -0
@@ -59,6 +59,19 @@ config HW_RANDOM_GEODE If unsure, say Y. +config HW_RANDOM_N2RNG + tristate "Niagara2 Random Number Generator support" + depends on HW_RANDOM && SPARC64 + default HW_RANDOM + ---help--- + This driver provides kernel-side support for the Random Number + Generator hardware found on Niagara2 cpus. + + To compile this driver as a module, choose M here: the + module will be called n2-rng. + + If unsure, say Y. + config HW_RANDOM_VIA tristate "VIA HW Random Number Generator support" depends on HW_RANDOM && X86_32
drivers/char/hw_random/Makefile +2 -0
@@ -7,6 +7,8 @@ rng-core-y := core.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o +obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o +n2-rng-objs := n2-drv.o n2-asm.o obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o
drivers/char/hw_random/n2-asm.S new file +93 -0
93 lines not on this page · raw message
drivers/char/hw_random/n2-drv.c new file +770 -0
770 lines not on this page · raw message
drivers/char/hw_random/n2rng.h new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
1.5.5.1.57.g5909c
Hi David.
Small nitpick..
drivers/char/hw_random/Makefile rng-core-y := core.o · line 11
Quoted 10 lines
drivers/char/hw_random/Makefile +2
-0@@ -7,6 +7,8 @@ rng-core-y := core.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o +obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o +n2-rng-objs := n2-drv.o n2-asm.o
These days the preferred syntax is:
n2-rng-y := n2-drv.o n2-asm.o
Following this scheme in general allows us to easily introduce:
n2-rng-$(CONFIG_FOO) += foo.o
I do not assume your n2-rng will need this,
but doing so in general is a win.
Quoted 9 lines
drivers/char/hw_random/Makefile +0
-0obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.odrivers/char/hw_random/n2-asm.S new file +0
-0
drivers/char/hw_random/n2-asm.S line 8
Quoted 8 lines
drivers/char/hw_random/n2-asm.S new file +8
-0@@ -0,0 +1,93 @@ +/* n2-asm.S: Niagara2 RNG hypervisor call assembler. + * + * Copyright (C) 2008 David S. Miller <[email protected]> + */ +#include <asm/hypervisor.h> +#include "n2rng.h" + + .text
I had expected:
.section .text, "aw"
here??
(Maybe init.h should define a __TEXT macro)..
drivers/char/hw_random/n2-asm.S line 16
Quoted 8 lines
drivers/char/hw_random/n2-asm.S new file +8
-0+ .globl sun4v_rng_get_diag_ctl + .type sun4v_rng_get_diag_ctl,#function +sun4v_rng_get_diag_ctl: + mov HV_FAST_RNG_GET_DIAG_CTL, %o5 + ta HV_FAST_TRAP + retl + nop + .size sun4v_rng_get_diag_ctl,.-sun4v_rng_get_diag_ctl
Any specific reason why you do not use:
ENTRY(sun4v_rng_get_diag_ctl)
mov HV_FAST_RNG_GET_DIAG_CTL, %o5
ta HV_FAST_TRAP
retl
nopENDPROC(sun4v_rng_get_diag_ctl)
I see these uses in other places and it
do the .globl, .type, .size and the label: stuff for you.
This is a general comment for all the 'functions' in this file.
Only browsed the rest - looked good.
Sam
From: Sam Ravnborg <[email protected]>
Date: Sat, 17 May 2008 08:54:37 +0200
Quoted 13 lines
drivers/char/hw_random/Makefile rng-core-y := core.o · line 11
Quoted 10 lines
drivers/char/hw_random/Makefile +2
-0@@ -7,6 +7,8 @@ rng-core-y := core.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o +obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o +n2-rng-objs := n2-drv.o n2-asm.oThese days the preferred syntax is:
Quoted 5 lines
n2-rng-y := n2-drv.o n2-asm.o
Following this scheme in general allows us to easily introduce:
n2-rng-$(CONFIG_FOO) += foo.o
Thanks I've fixed this.
Quoted 10 lines
drivers/char/hw_random/Makefile rng-core-y := core.o
Quoted 4 lines
drivers/char/hw_random/Makefile +4
-0+#include <asm/hypervisor.h> +#include "n2rng.h" + + .textI had expected:
.section .text, "aw"
here??
".text" is used consistently for this in the first 5 assembler files I tossed into my editor (arch/x86/kernel/head_{32,64}, arch/x86/kernel/entry_{32,64}.S, arch/powerpc/kernel/head_64.S) I don't see any value in using the expanded version, especially is "aw" is not the default on some platform for some reason, that detail is hidden in the assembler's implementation of ".text"
Quoted 11 lines
drivers/char/hw_random/Makefile
Quoted 8 lines
drivers/char/hw_random/Makefile +8
-0+ .globl sun4v_rng_get_diag_ctl + .type sun4v_rng_get_diag_ctl,#function +sun4v_rng_get_diag_ctl: + mov HV_FAST_RNG_GET_DIAG_CTL, %o5 + ta HV_FAST_TRAP + retl + nop + .size sun4v_rng_get_diag_ctl,.-sun4v_rng_get_diag_ctlAny specific reason why you do not use:
Quoted 6 lines
ENTRY(sun4v_rng_get_diag_ctl)
movHV_FAST_RNG_GET_DIAG_CTL, %o5
taHV_FAST_TRAP
retl
nopENDPROC(sun4v_rng_get_diag_ctl)
I simply didn't know they existed and were usable. :-) I've changed the assembler code to use them, thanks.
Longer term I'll need to define __ALIGN et al. on sparc so that a more appropriate fill constant is used. It should be a NOP in sections that should contain instructions and 0x90 is not a NOP on sparc :-)
But it's harmless to use what's there now, so there is no need for me to define a specific __ALIGN before using ENTRY and ENDPROC.
Thanks for your feedback.