From: Thomas Gleixner <tglx@linutronix.de>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
John Stultz <john.stultz@linaro.org>,
Mark Rutland <mark.rutland@arm.com>,
Marc Zyngier <Marc.Zyngier@arm.com>,
Rob Herring <robherring2@gmail.com>
Subject: Re: [PATCHv3/RESEND 4/4] clocksource: arch_timer: Add support for memory mapped timers
Date: Fri, 21 Jun 2013 23:18:26 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1306212304480.4013@ionos.tec.linutronix.de> (raw)
In-Reply-To: <1371836361-20574-5-git-send-email-sboyd@codeaurora.org>
On Fri, 21 Jun 2013, Stephen Boyd wrote:
> /*
> * Architected system timer support.
> @@ -46,13 +73,69 @@ static bool arch_timer_use_virtual = true;
> static inline void arch_timer_reg_write(int access, int reg, u32 val,
> struct clock_event_device *clk)
> {
> - arch_timer_reg_write_cp15(access, reg, val);
> + if (access == ARCH_TIMER_MEM_PHYS_ACCESS) {
> + struct arch_timer *timer = to_arch_timer(clk);
> + switch (reg) {
> + case ARCH_TIMER_REG_CTRL:
> + writel_relaxed(val, timer->base + CNTP_CTL);
> + break;
> + case ARCH_TIMER_REG_TVAL:
> + writel_relaxed(val, timer->base + CNTP_TVAL);
> + break;
> + default:
> + BUILD_BUG();
So you are relying on the compiler cleverness to identify a caller
which calls that inline with a not supported reg value.
How does that work, when the compiler decides not to inline that?
enum without a default case emits at least a reliable warning.
> + }
> + } else if (access == ARCH_TIMER_MEM_VIRT_ACCESS) {
> + struct arch_timer *timer = to_arch_timer(clk);
> + switch (reg) {
> + case ARCH_TIMER_REG_CTRL:
> + writel_relaxed(val, timer->base + CNTV_CTL);
> + break;
> + case ARCH_TIMER_REG_TVAL:
> + writel_relaxed(val, timer->base + CNTV_TVAL);
> + break;
> + default:
> + BUILD_BUG();
> + }
> + } else {
> + arch_timer_reg_write_cp15(access, reg, val);
> + }
> }
Something in my little brain yells: function pointer
You can't be serious about hacking nested if/else/switch constructs
into a hot path.
Why not making your cpu data:
struct arch_timer {
struct clock_event_device evt;
....
void (*write_ctrl)(val, timer);
void (*write_tval)(val, timer);
....
}
and get rid of all that conditionals?
Thanks,
tglx
next prev parent reply other threads:[~2013-06-21 21:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 17:39 [PATCHv3/RESEND 0/4] Memory mapped architected timers Stephen Boyd
2013-06-21 17:39 ` [PATCHv3/RESEND 1/4] Documentation: Add memory mapped ARM architected timer binding Stephen Boyd
2013-06-21 17:39 ` [PATCHv3/RESEND 2/4] clocksource: arch_timer: Pass clock event to set_mode callback Stephen Boyd
2013-06-21 17:39 ` [PATCHv3/RESEND 3/4] clocksource: arch_timer: Push the read/write wrappers deeper Stephen Boyd
2013-06-21 17:39 ` [PATCHv3/RESEND 4/4] clocksource: arch_timer: Add support for memory mapped timers Stephen Boyd
2013-06-21 21:18 ` Thomas Gleixner [this message]
2013-06-21 23:01 ` Stephen Boyd
2013-06-21 23:13 ` Thomas Gleixner
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=alpine.DEB.2.02.1306212304480.4013@ionos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=Marc.Zyngier@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=john.stultz@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robherring2@gmail.com \
--cc=sboyd@codeaurora.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
all inboxes | Powered by JetHome®