<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Marc,<br>
      <br>
      On 9/4/2012 10:38 AM, Marc Zyngier wrote:<br>
    </div>
    <blockquote
      cite="mid:1346780329-14451-2-git-send-email-marc.zyngier@arm.com"
      type="cite">
      <pre wrap="">At the moment, the arch_timer driver only uses the physical timer,
which can cause problem if PL2 hasn't enabled PL1 access in CNTHCTL,
which is likely in a virtualized environment. Instead, the virtual
timer is always available.

This patch enables the use of the virtual timer, unless no
interrupt is provided in the DT for it, in which case it falls
back to the physical timer.

Signed-off-by: Marc Zyngier <a class="moz-txt-link-rfc2396E" href="mailto:marc.zyngier@arm.com"><marc.zyngier@arm.com></a>
---
 arch/arm/kernel/arch_timer.c | 343 ++++++++++++++++++++++++++++++-------------
 1 file changed, 241 insertions(+), 102 deletions(-)</pre>
    </blockquote>
    <snip><br>
    <blockquote
      cite="mid:1346780329-14451-2-git-send-email-marc.zyngier@arm.com"
      type="cite">
      <pre wrap="">
 
@@ -329,6 +449,7 @@ int __init arch_timer_of_register(void)
 {
        struct device_node *np;
        u32 freq;
+       int i;
 
        np = of_find_matching_node(NULL, arch_timer_of_match);
        if (!np) {
@@ -340,22 +461,40 @@ int __init arch_timer_of_register(void)
        if (!of_property_read_u32(np, "clock-frequency", &freq))
                arch_timer_rate = freq;
 
-       arch_timer_ppi = irq_of_parse_and_map(np, 0);
-       arch_timer_ppi2 = irq_of_parse_and_map(np, 1);
-       pr_info("arch_timer: found %s irqs %d %d\n",
-               np->name, arch_timer_ppi, arch_timer_ppi2);
+       for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
+               arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
+
+       /*
+        * If no interrupt provided for virtual timer, we'll have to
+        * stick to the physical timer. It'd better be accessible...
+        */
+       if (!arch_timer_ppi[VIRT_PPI]) {
+               arch_timer_use_virtual = false;
+
+               if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
+                   !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
+                       pr_warn("arch_timer: No interrupt available, giving up\n");
+                       return -EINVAL;</pre>
    </blockquote>
    <br>
    Should this be<br>
    <pre wrap="">if (!arch_timer_ppi[PHYS_SECURE_PPI] <b>&&</b>
                    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
...

</pre>
    <snip><br>
    <br>
    Also, I have based my next mm-arch_timer patch on this.<br>
    <pre class="moz-signature" cols="72">Thanks,
Rohit Vaswani

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation.
</pre>
  </body>
</html>