From: cov@codeaurora.org (Christopher Covington)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/4] ARM: arch_timers: enable the use of the virtual timer
Date: Mon, 16 Jul 2012 17:12:31 -0400 [thread overview]
Message-ID: <500483BF.704@codeaurora.org> (raw)
In-Reply-To: <1341566422-20368-2-git-send-email-marc.zyngier@arm.com>
Hi Marc,
On 07/06/2012 05:20 AM, Marc Zyngier wrote:
> 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 both the virtual timer, unless no
> interrupt is provided in the DT for it, in which case is falls
> back to the physical timer.
[...]
> @@ -44,7 +62,37 @@ static struct clock_event_device __percpu **arch_timer_evt;
> #define ARCH_TIMER_REG_FREQ 1
> #define ARCH_TIMER_REG_TVAL 2
>
> -static void arch_timer_reg_write(int reg, u32 val)
> +static inline void arch_timer_reg_write(int reg, u32 val)
Will GCC fail to inline without the hint?
> +{
> + (*__this_cpu_ptr(arch_timer_reg_ops))->reg_write(reg, val);
> +}
> +
> +static inline u32 arch_timer_reg_read(int reg)
> +{
> + return (*__this_cpu_ptr(arch_timer_reg_ops))->reg_read(reg);
> +}
> +
> +static inline cycle_t arch_timer_counter_read(void)
> +{
> + return (*__this_cpu_ptr(arch_timer_reg_ops))->counter_read();
> +}
> +
> +static u32 arch_timer_common_reg_read(int reg)
> +{
> + u32 val;
> +
> + switch (reg) {
> + case ARCH_TIMER_REG_FREQ:
> + asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (val));
> + break;
> + default:
> + BUG();
> + }
> +
> + return val;
> +}
> +
> +static void arch_timer_phys_reg_write(int reg, u32 val)
> {
> switch (reg) {
> case ARCH_TIMER_REG_CTRL:
[...]
> @@ -329,10 +443,24 @@ 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);
> + pr_info("arch_timer: found %s irqs ", np->name);
> +
> + for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) {
> + arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
> + if (!arch_timer_ppi[i]) {
> + /*
> + * No interrupt provided for virtual timer,
> + * we'll have to stick to the physical timer.
> + */
> + if (i == VIRT_PPI)
> + arch_timer_use_virtual = false;
> +
It seems like it would be more straightforward to set the
arch_timer_use_virtual variable outside of the loop, directly indexing
into the array of timer PPI's. On a trivial note you've also got
trailing whitespace here.
> + continue;
> + }
> + pr_cont("%d ", arch_timer_ppi[i]);
> + }
> +
> + pr_cont("\n");
>
> return arch_timer_register();
> }
> @@ -345,6 +473,6 @@ int __init arch_timer_sched_clock_init(void)
> if (err)
> return err;
>
> - setup_sched_clock(arch_counter_get_cntvct32, 32, arch_timer_rate);
> + setup_sched_clock(arch_counter_get_cnt32, 32, arch_timer_rate);
> return 0;
> }
Regards,
Christopher
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
next prev parent reply other threads:[~2012-07-16 21:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-06 9:20 [RFC PATCH 0/4] arch_timers patches to enable KVM support Marc Zyngier
2012-07-06 9:20 ` [RFC PATCH 1/4] ARM: arch_timers: enable the use of the virtual timer Marc Zyngier
2012-07-16 21:12 ` Christopher Covington [this message]
2012-07-17 16:41 ` Christopher Covington
2012-07-06 9:20 ` [RFC PATCH 2/4] ARM: arch_timers: register a time/cycle counter Marc Zyngier
2012-07-17 16:41 ` Christopher Covington
2012-07-06 9:20 ` [RFC PATCH 3/4] ARM: arch_timers: give the virtual timer its own interrupt handler Marc Zyngier
2012-07-17 16:57 ` Christopher Covington
2012-07-06 9:20 ` [RFC PATCH 4/4] ARM: arch_timers: dynamic switch to physical timer and virtual timer offloading Marc Zyngier
2012-07-17 19:02 ` Christopher Covington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=500483BF.704@codeaurora.org \
--to=cov@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).