All of lore.kernel.org
 help / color / mirror / Atom feed
From: heiko@sntech.de (Heiko Stübner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv4 2/2] clocksource: dw_apb_timer_of: Fix read_sched_clock
Date: Wed, 18 Sep 2013 13:32:31 +0200	[thread overview]
Message-ID: <201309181332.31561.heiko@sntech.de> (raw)
In-Reply-To: <20130918110159.GA32005@amd.pavel.ucw.cz>

Am Mittwoch, 18. September 2013, 13:01:59 schrieb Pavel Machek:
> On Wed 2013-09-18 00:42:36, Thomas Gleixner wrote:
> > On Tue, 17 Sep 2013, dinguyen at altera.com wrote:
> And now we can't get the code fixed so that it at least works on our
> hardware, because, guess what, you noticed upstream merged the gem
> below, and you don't like it?
> 
> > static int num_called;
> > static void __init dw_apb_timer_init(struct device_node *timer)
> > {
> > 
> >         switch (num_called) {
> >         
> >         case 0:
> >                 pr_debug("%s: found clockevent timer\n", __func__);
> >                 add_clockevent(timer);
> >                 of_node_put(timer);
> >                 break;
> >         
> >         case 1:
> >                 pr_debug("%s: found clocksource timer\n", __func__);
> >                 add_clocksource(timer);
> >                 of_node_put(timer);
> >                 init_sched_clock();
> >                 break;
> >         
> >         default:
> >                 break;
> >         
> >         }
> >         
> >         num_called++;
> > 
> > }
> > 
> > So if you can use different nodes for clockevent and clocksource, why
> > is that supposed to be dependent on the ordering? That's not how DT is
> > supposed to be used. DT provides a clear description of the hardware,
> > not some ordering dependent magic amended by utterly useless pr_debug()
> > constructs.
> 
> You already had non-ugly version in your tree.
> 
> Alternatively, tell us what you want done. These boards have 2 to 4
> identical timers, that can serve as both clockevent and
> clocksource. We'd like to use one as clockevent and one as
> clocksource.

I would also be interested in the "right" way to do this.

As Pavel already said, the hardware is identical for all N separate timer 
blocks, so as the DT should be describing the hardware only, there is no way 
to specifiy one for the clockevent and another for the clocksource there.

At first I kept using the non-standard init which required it being called from 
platform code, but got the request to convert the driver to use 
CLOCKSOURCE_OF_DECLARE to remove the need for separate call.

As you will know CLOCKSOURCE_OF_DECLARE calls the init function for each found 
dt node for a matching device, resulting in N calls to dw_apb_timer_init.
So my solution was to just grab the first one as clockevent and second one as 
clocksource.

Therefore I'm all ears for how to solve this in a better way :-)


Heiko

  reply	other threads:[~2013-09-18 11:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 22:02 [PATCHv4 1/2] clocksource: dw_apb_timer: Move timer defines to header file dinguyen at altera.com
2013-09-17 22:02 ` [PATCHv4 2/2] clocksource: dw_apb_timer_of: Fix read_sched_clock dinguyen at altera.com
2013-09-17 22:42   ` Thomas Gleixner
2013-09-18 11:01     ` Pavel Machek
2013-09-18 11:32       ` Heiko Stübner [this message]
2013-09-23 15:58         ` Dinh Nguyen
2013-10-07 16:28           ` Daniel Lezcano

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=201309181332.31561.heiko@sntech.de \
    --to=heiko@sntech.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.