All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@domain.hid>
To: niklaus.giger@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] Problem with periodic timer on PPC40x solved
Date: Sun, 24 Sep 2006 23:07:38 +0200	[thread overview]
Message-ID: <4516F39A.7040603@domain.hid> (raw)
In-Reply-To: <200609242247.57024.niklaus.giger@domain.hid>

Niklaus Giger wrote:
> Am Samstag, 23. September 2006 22:55 schrieb Wolfgang Grandegger:
>> Hi Niklaus,
>>
>> Niklaus Giger wrote:
> <..>
>>          if (flags & IPIPE_RESET_TIMER)
>>                  ticks = tb_ticks_per_jiffy;
>>          else {
>>                  ticks = ns * tb_ticks_per_jiffy / (1000000000 / HZ);
>>   		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>                  if (ticks > tb_ticks_per_jiffy)
>>                          return -EINVAL;
> <..>
>> Does replacing the calculation of ticks with
>>
>>          ticks = ns * (tb_ticks_per_jiffy / 10000) / (100000 / HZ);
>>
>> help. A proper calculation might use mulhwu or rthal_imuldiv.
> Yes. I does. There are two occurrences fixed with the attached patch (+ one 
> small ifdef to eliminate a compiler warning in the PPC40x case).
> Timing is okay as tested with a small vxworks test program.
> 
> Could someone please apply it?
> 
> Thanks for your cooperation. 
> 
> Best regards
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: ksrc/arch/powerpc/patches/adeos-ipipe-2.6.14-ppc-1.4-00.patch
> ===================================================================
> --- ksrc/arch/powerpc/patches/adeos-ipipe-2.6.14-ppc-1.4-00.patch	(Revision 1650)
> +++ ksrc/arch/powerpc/patches/adeos-ipipe-2.6.14-ppc-1.4-00.patch	(Arbeitskopie)
> @@ -3595,7 +3595,7 @@
>  +	if (flags & IPIPE_RESET_TIMER)
>  +		ticks = tb_ticks_per_jiffy;
>  +	else {
> -+		ticks = ns * tb_ticks_per_jiffy / (1000000000 / HZ);
> ++		ticks = ns * (tb_ticks_per_jiffy / 10000) / (100000 / HZ);
>  +
>  +		if (ticks > tb_ticks_per_jiffy)
>  +			return -EINVAL;
> Index: ksrc/arch/powerpc/hal.c
> ===================================================================
> --- ksrc/arch/powerpc/hal.c	(Revision 1650)
> +++ ksrc/arch/powerpc/hal.c	(Arbeitskopie)
> @@ -81,7 +81,9 @@
>   */
>  static void rthal_set_local_cpu_timer(void)
>  {
> +#ifndef CONFIG_40x
>      long ticks;
> +#endif
>      rthal_declare_cpuid;
>  
>      rthal_load_cpuid();
> @@ -110,7 +112,7 @@
>      if (ns == 0)
>          ticks = tb_ticks_per_jiffy;
>      else {
> -        ticks = ns * tb_ticks_per_jiffy / (1000000000 / HZ);
> +	ticks = ns * (tb_ticks_per_jiffy / 10000) / (100000 / HZ);
>  
>          if (ticks > tb_ticks_per_jiffy) {
>              DBG("rthal_set_cpu_timers_unsafe: -EINVAL (%lu)\n", ticks);

My suggested fix was just to locate the source of the problem. As 
Philippe suggested, we should use mulhwu (or mulhwu_scale_factor). Have 
a look to arch/ppc/kernel/time.c for further information.

Wolfgang.


  reply	other threads:[~2006-09-24 21:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23 18:13 [Xenomai-core] Problem with periodic timer on PPC40x identified Niklaus Giger
2006-09-23 20:55 ` Wolfgang Grandegger
2006-09-23 21:33   ` Philippe Gerum
2006-09-24 20:47   ` [Xenomai-core] Problem with periodic timer on PPC40x solved Niklaus Giger
2006-09-24 21:07     ` Wolfgang Grandegger [this message]
2006-09-25 15:57       ` Philippe Gerum
2006-09-25 20:29         ` Niklaus Giger
2006-09-25 20:59           ` Philippe Gerum
2006-09-25 21:15             ` Niklaus Giger
2006-09-26  6:59               ` Philippe Gerum
2006-09-26 14:21               ` Philippe Gerum
2006-09-26 18:39                 ` Niklaus Giger
2006-09-26 19:34               ` Niklaus Giger
2006-09-26 19:48                 ` Philippe Gerum
2006-09-26  6:47           ` Wolfgang Grandegger
  -- strict thread matches above, loose matches on Subject: below --
2006-09-26 14:56 gilles.chanteperdrix
2006-09-26 16:10 ` Philippe Gerum
2006-09-26 16:28   ` Wolfgang Grandegger
2006-09-26 16:38     ` Philippe Gerum
2006-09-26 16:57       ` Wolfgang Grandegger
2006-09-26 18:56     ` Niklaus Giger
2006-09-26 20:23       ` Wolfgang Grandegger
2006-09-26 21:26         ` Niklaus Giger
2006-09-27 10:13           ` Wolfgang Grandegger
2006-09-27 18:19             ` Wolfgang Grandegger
2006-09-28  6:02               ` Niklaus Giger
2006-09-28  7:59                 ` Wolfgang Grandegger

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=4516F39A.7040603@domain.hid \
    --to=wg@domain.hid \
    --cc=niklaus.giger@domain.hid \
    --cc=xenomai@xenomai.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.