OMAP3 ROM Random Number Generator support
Hi Pali,
Yep, the code looks almost identical, I guess with some tweaks all SMC code from that patch could be removed and instead used the one from SMC PPA API.
What I don't get, is why one needs to disable/enable fiqs/irqs:
+static int call_sec_rom(u32 appl_id, u32 proc_id, u32 flag, ...) +{
+ va_list ap;
+ u32 ret;
+ u32 val;
+
+ va_start(ap, flag);
+ val = *(u32 *) ≈
+ local_irq_disable();
+ local_fiq_disable();
+ ret = omap3_rom_rng_call(appl_id, proc_id, flag,
+ (u32) virt_to_phys((void *) val));
+ local_fiq_enable();
+ local_irq_enable();
+ va_end(ap);
+
+ return ret;
+}
Do you have any idea why is that needed? Any other code I've ever seen to call SM, does not disable fiqs/irqs, is RNG SMC somehow special? I know this is Nokia's code, but still, if we can get some understanding...
Regards,
Ivo
Quoted 87 lines
-------- Оригинално писмо --------
От: Pali Rohár
Относно: Re: [PATCH] OMAP3 ROM Random Number Generator support До: Tony Lindgren
Изпратено на: Неделя, 2013, Март 31 12:28:12 EESTQuoted 30 lines · On Thursday 28 March 2013 22:44:11 Tony Lindgren wrote:
Quoted 29 lines · Pali Rohár
Here is new version of patch:
arch/arm/mach-omap2/devices.c +1
-0@@ -486,6 +486,23 @@ static void omap_init_mcspi(void)static inline void omap_init_mcspi (void ) {}#endif +extern u32 *omap3_rom_rng_call(u32 id, u32 proc, u32 flags,u32
va_ptr); +arch/arm/mach-omap2/devices.c +11
-0+static struct platform_device omap3_rom_rng_device = { + .name = "omap3-rom-rng", + .id = -1, + .dev = { + .platform_data = omap3_rom_rng_call, + }, +}; + +static void omap_init_rom_rng(void) +{ + if (!cpu_is_omap34xx() || omap_type() ==
OMAP2_DEVICE_TYPE_GP) + return;arch/arm/mach-omap2/devices.c +3
-0+ platform_device_register(&omap3_rom_rng_device); +} +/** Quoted 8 lines
Quoted 2 lines
*
omap_init_rng- bind the RNG hwmod to the RNG
omap_device*This driver probably only works on Nokia boards because of the different SMC call numbering. Until it's been verified on some other HS omap34xx, I'd probably register this only from the Nokia board-*.c file.
Freemangordon, can you look at this smc and errara 430973 code if they could be merged? Really
omap3_rom_rng_callfunction looks like n900 specific.Quoted 24 lines
Quoted 10 lines
drivers/char/hw_random/omap3-rom-rng.c new file +1
-0+static int omap3_rom_rng_probe(struct platform_device*pdev) +{
drivers/char/hw_random/omap3-rom-rng.c new file +1
-0+ printk(KERN_INFO "%s: initializing\n",
omap3_rom_rng_name); +drivers/char/hw_random/omap3-rom-rng.c new file +4
-0+ omap3_rom_rng_call = pdev->dev.platform_data; +if (!omap3_rom_rng_call) { + printk(KERN_ERR "%s: omap3_rom_rng_call is NULL\n", + omap3_rom_rng_name);drivers/char/hw_random/omap3-rom-rng.c
Quoted 10 lines
drivers/char/hw_random/omap3-rom-rng.c new file +10
-0+return -EINVAL ; + } + + setup_timer(&idle_timer, omap3_rom_idle_rng, 0); + rng_clk = clk_get_sys("omap_rng", "ick"); +if (IS_ERR (rng_clk)) { + printk(KERN_ERR "%s: unable to get RNG clock\n", + omap3_rom_rng_name); +return IS_ERR (rng_clk); + }You can use regular
clk_getif you add the alias to structomap_clkomap3xxx_clkstable.Quoted 3 lines
Regards,
Tony
Tony, can you show me how?
Signature · 2 lines
Pali Rohár [email protected]
Quoted 28 lines · On Sunday 31 March 2013 14:05:42 Ивайло Димитров wrote:
Hi Pali,
Yep, the code looks almost identical, I guess with some tweaks all SMC code from that patch could be removed and instead used the one from SMC PPA API.
What I don't get, is why one needs to disable/enable fiqs/irqs:
+static int
call_sec_rom(u32 appl_id, u32 proc_id, u32 flag, ...)+{(quoted diff) +16
-0+ va_list ap; + u32 ret; + u32 val; + + va_start(ap, flag); + val = *(u32 *) ≈ + local_irq_disable(); + local_fiq_disable(); + ret = omap3_rom_rng_call(appl_id, proc_id, flag, + (u32) virt_to_phys((void *) val)); + local_fiq_enable(); + local_irq_enable(); + va_end(ap); + + return ret; +}
Quoted 7 lines
Do you have any idea why is that needed? Any other code I've ever seen to call SM, does not disable fiqs/irqs, is RNG SMC somehow special? I know this is Nokia's code, but still, if we can get some understanding...
Regards,
Ivo
This driver is written by Juha Yrjola and is part of maemo 2.6.28 kernel.
Juha Yrjola, are you still around?
Signature · 2 lines
Pali Rohár [email protected]
Quoted 26 lines · Ивайло Димитров
Hi Pali,
Yep, the code looks almost identical, I guess with some tweaks all SMC code from that patch could be removed and instead used the one from SMC PPA API.
What I don't get, is why one needs to disable/enable fiqs/irqs:
(quoted diff) +18
-0+static int call_sec_rom(u32 appl_id, u32 proc_id, u32 flag, ...) +{ + va_list ap; + u32 ret; + u32 val; + + va_start(ap, flag); + val = *(u32 *) ≈ + local_irq_disable(); + local_fiq_disable(); + ret = omap3_rom_rng_call(appl_id, proc_id, flag, + (u32) virt_to_phys((void *) val)); + local_fiq_enable(); + local_irq_enable(); + va_end(ap); + + return ret; +}
Quoted 1 line
Do you have any idea why is that needed? Any other code I've ever seen to call SM, does not disable fiqs/irqs, is RNG SMC somehow special? I know this is Nokia's code, but still, if we can get some understanding...
Sounds like the fiq handling can be dropped based on what the TI guys posted recently about FIQs only be available in the secure mode starting with omap2.
Regards,
Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 5 lines · Ивайло Димитров
Yep, the code looks almost identical, I guess with some tweaks all SMC code from that patch could be removed and instead used the one from SMC PPA API.
What I don't get, is why one needs to disable/enable fiqs/irqs:
[..]
Quoted 3 lines
Do you have any idea why is that needed? Any other code I've ever seen to call SM, does not disable fiqs/irqs, is RNG SMC somehow special? I know this is Nokia's code, but still, if we can get some understanding...
I think without disabling irqs you may suffer some strange crashes when heavily stressing the RNG... that's why you also have cache flushes before and after the SMC. With proper test suite you could probably verify this. How are you testing this driver?
A.