From: Ulrich Prinz <ulrich.prinz@googlemail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "Heiko Stübner" <heiko@sntech.de>,
"John Stultz" <john.stultz@linaro.org>,
"Jamie Iles" <jamie@jamieiles.com>,
"Dinh Nguyen" <dinguyen@altera.com>,
"Grant Likely" <grant.likely@linaro.org>,
linux-arm-kernel@lists.infradead.org,
"Rob Herring" <rob.herring@calxeda.com>,
devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org, "Arnd Bergmann" <arnd@arndb.de>,
"Olof Johansson" <olof@lixom.net>
Subject: Re: [PATCH 3/9] clocksource: dw_apb_timer: quirk for variants with 64bit counter
Date: Sat, 06 Jul 2013 22:19:14 +0200 [thread overview]
Message-ID: <51D87BC2.5060507@googlemail.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1307060129340.32106@ionos.tec.linutronix.de>
Hi Thomas,
sorry but it is my first release to the kernel and I was trained to take
as less as possible influence on existing code and reuse as much as
possible existing code.
Sometimes just two rules are to simple...
Am 06.07.2013 01:45, schrieb Thomas Gleixner:
> On Sat, 6 Jul 2013, Heiko Stübner wrote:
>
>> This adds a quirk for IP variants containing two load_count and value
>> registers that are used to provide 64bit accuracy on 32bit systems.
>>
>> The added accuracy is currently not used, the driver is only adapted to
>> handle the different register layout and make it work on affected devices.
>>
>> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
>> ---
>> drivers/clocksource/dw_apb_timer.c | 27 +++++++++++++++++++++++++++
>> include/linux/dw_apb_timer.h | 6 ++++++
>> 2 files changed, 33 insertions(+)
>>
>> diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c
>> index f5e7be8..bd45351 100644
>> --- a/drivers/clocksource/dw_apb_timer.c
>> +++ b/drivers/clocksource/dw_apb_timer.c
>> @@ -56,6 +56,17 @@ static void apbt_init_regs(struct dw_apb_timer *timer, int quirks)
>> timer->reg_control = APBTMR_N_CONTROL;
>> timer->reg_eoi = APBTMR_N_EOI;
>> timer->reg_int_status = APBTMR_N_INT_STATUS;
>> +
>> + /*
>> + * On variants with 64bit counters some registers are
>> + * moved further down.
>> + */
>> + if (quirks & APBTMR_QUIRK_64BIT_COUNTER) {
>> + timer->reg_current_value += 0x4;
>> + timer->reg_control += 0x8;
>> + timer->reg_eoi += 0x8;
>> + timer->reg_int_status += 0x8;
>> + }
>> }
>
> Oh, no. this is not how we handle these things.
>
> 1) We want proper constants for this 64bit IP block
ACK
>
> 2) This is not a quirk, it's a property of that particular IP block
Ok, noted and will be reworked.
>
> You already made the register offsets a part of the timer structure,
> so why don't you supply a proper structure filled with that values to
> the init function?
>
> That's what we do all over the place. Either we instantiate those
> structs at compile time or runtime fed by device tree or any other
> configuration mechanism.
>
Lesson learned, will be reworked. But taking the other comments and
remarks into account this leads to an integration into a single new
patch inheriting this new driver path.
>> static unsigned long apbt_readl(struct dw_apb_timer *timer, unsigned long offs)
>> @@ -145,6 +156,10 @@ static void apbt_set_mode(enum clock_event_mode mode,
>> udelay(1);
>> pr_debug("Setting clock period %lu for HZ %d\n", period, HZ);
>> apbt_writel(timer, period, timer->reg_load_count);
>> +
>> + if (timer->quirks & APBTMR_QUIRK_64BIT_COUNTER)
>> + apbt_writel(timer, 0, timer->reg_load_count + 0x4);
>> +
>
> No. We are not adding such conditional constructs when we can deal
> with them just by providing a proper set of function pointers. And
> definitely not with hardcoded magic 0x4 constants involved.
>
> timer->load_count(timer, value);
>
> Provide a 32 bit and a 64 bit version of that function and be done
> with it.
For the first version, 64bit will not be supported cause of lack of
information and testing. But is it an option to control the load of
functions by dtsi according this way:
dw-apb-timer-osc: will load standard function to load timer
rk3188-dw-apb-timer-osc: will load 32bit variant of 64bit registers
rk3188-dw-apb-timer64-osc: will load 64bit variant of 64bit registers
>
>
> Copy and paste is a conveniant thing, right? It just should have a pop
> up window assigned which asks at the second instance of copying the
> same thing whether you really thought about it.
We thought about and tested a lot. But the problem is that if you find a
bug in one copy of it, you (or anyone else inspecting the code) need to
find all the other copies. In such manor a c'n'p solution is always bad.
Regards,
Ulrich
next prev parent reply other threads:[~2013-07-06 20:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 22:51 [PATCH 0/9] clocksource: dw_apb_timer: support for timer variant used in rk3188 SoCs Heiko Stübner
2013-07-05 22:51 ` [PATCH 1/9] clocksource: dw_apb_timer: infrastructure to handle quirks Heiko Stübner
2013-07-05 22:52 ` [PATCH 2/9] clocksource: dw_apb_timer: flexible register addresses Heiko Stübner
2013-07-05 22:53 ` [PATCH 3/9] clocksource: dw_apb_timer: quirk for variants with 64bit counter Heiko Stübner
[not found] ` <201307060053.10182.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2013-07-05 23:45 ` Thomas Gleixner
2013-07-06 20:19 ` Ulrich Prinz [this message]
2013-07-05 22:53 ` [PATCH 4/9] clocksource: dw_apb_timer: use the eoi callback to clear pending interrupts Heiko Stübner
2013-07-05 22:59 ` Heiko Stübner
2013-07-05 22:54 ` [PATCH 5/9] clocksource: dw_apb_timer: quirk for variants without EOI register Heiko Stübner
[not found] ` <201307060054.07784.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2013-07-05 22:58 ` Heiko Stübner
2013-07-05 23:49 ` Thomas Gleixner
2013-07-05 22:54 ` [PATCH 6/9] clocksource: dw_apb_timer: quirk for inverted int mask Heiko Stübner
2013-07-05 22:58 ` Heiko Stübner
[not found] ` <201307060054.35996.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2013-07-05 23:51 ` Thomas Gleixner
[not found] ` <201307060051.09716.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2013-07-05 22:55 ` [PATCH 7/9] clocksource: dw_apb_timer: quirk for inverted timer mode setting Heiko Stübner
2013-07-05 22:56 ` [PATCH 8/9] clocksource: dw_apb_timer_of: add quirk handling Heiko Stübner
2013-07-05 22:56 ` [PATCH 9/9] clocksource: dw_apb_timer: special variant for rockchip rk3188 timers Heiko Stübner
[not found] ` <201307060056.29370.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2013-07-06 0:12 ` Thomas Gleixner
2013-07-06 20:28 ` Ulrich Prinz
[not found] ` <51D87E04.3060704-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2013-07-06 21:00 ` Thomas Gleixner
2013-07-11 22:44 ` Ulrich Prinz
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=51D87BC2.5060507@googlemail.com \
--to=ulrich.prinz@googlemail.com \
--cc=arnd@arndb.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dinguyen@altera.com \
--cc=grant.likely@linaro.org \
--cc=heiko@sntech.de \
--cc=jamie@jamieiles.com \
--cc=john.stultz@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rob.herring@calxeda.com \
--cc=tglx@linutronix.de \
/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).