mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jochen Voß" <jochen.voss@googlemail.com>
To: "Thomas Gleixner" <tglx@linutronix.de>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Ingo Molnar" <mingo@elte.hu>,
	"Venkatesch Pallipadi" <venkatesh.pallipadi@intel.com>
Subject: Re: [GIT pull] timer fixes for 2.6.27
Date: Sat, 6 Sep 2008 18:20:12 -0400	[thread overview]
Message-ID: <ef1cd66f0809061520scafdeb0w957322029273f7ee@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.1.10.0809061708240.3243@apollo.tec.linutronix.de>

Hi,

2008/9/6 Thomas Gleixner <tglx@linutronix.de>:
> Dominik Brodowski (2):
>      [...]
>      clocksource, acpi_pm.c: check for monotonicity
I made some comments about this patch which were never answered:

    http://lkml.org/lkml/2008/8/23/28

Not sure whether this was because they were irrelevant or overlooked.
Just to make sure, I replicate them below:

> diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
> index 5ca1d80..4eee533 100644
> --- a/drivers/clocksource/acpi_pm.c
> +++ b/drivers/clocksource/acpi_pm.c
> @@ -21,6 +21,7 @@
>  #include <linux/errno.h>
>  #include <linux/init.h>
>  #include <linux/pci.h>
> +#include <linux/delay.h>
>  #include <asm/io.h>
>
>  /*
> @@ -151,13 +152,13 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
>  */
>  static int verify_pmtmr_rate(void)
>  {
> -       u32 value1, value2;
> +       cycle_t value1, value2;
>        unsigned long count, delta;
>
>        mach_prepare_counter();
> -       value1 = read_pmtmr();
> +       value1 = clocksource_acpi_pm.read();
>        mach_countup(&count);
> -       value2 = read_pmtmr();
> +       value2 = clocksource_acpi_pm.read();
>        delta = (value2 - value1) & ACPI_PM_MASK;
>
>        /* Check that the PMTMR delta is within 5% of what we expect */
> @@ -175,10 +176,13 @@ static int verify_pmtmr_rate(void)
>  #define verify_pmtmr_rate() (0)
>  #endif
>
> +/* Number of monotonicity checks to perform during initialization */
> +#define ACPI_PM_MONOTONICITY_CHECKS 10
> +
>  static int __init init_acpi_pm_clocksource(void)
>  {
> -       u32 value1, value2;
> -       unsigned int i;
> +       cycle_t value1, value2;
> +       unsigned int i, j, good = 0;
>
>        if (!pmtmr_ioport)
>                return -ENODEV;
> @@ -187,24 +191,32 @@ static int __init init_acpi_pm_clocksource(void)
>                                                clocksource_acpi_pm.shift);
>
>        /* "verify" this timing source: */
> -       value1 = read_pmtmr();
> -       for (i = 0; i < 10000; i++) {
> -               value2 = read_pmtmr();
> -               if (value2 == value1)
> -                       continue;
> -               if (value2 > value1)
> -                       goto pm_good;
> -               if ((value2 < value1) && ((value2) < 0xFFF))
> -                       goto pm_good;
> -               printk(KERN_INFO "PM-Timer had inconsistent results:"
> -                       " 0x%#x, 0x%#x - aborting.\n", value1, value2);
> -               return -EINVAL;
> +       for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
> +               value1 = clocksource_acpi_pm.read();
> +               for (i = 0; i < 10000; i++) {
> +                       value2 = clocksource_acpi_pm.read();
> +                       if (value2 == value1)
> +                               continue;
> +                       if (value2 > value1)
> +                               good++;
> +                               break;
> +                       if ((value2 < value1) && ((value2) < 0xFFF))
The brackets arout value2 are not needed and look strange.

> +                               good++;
> +                               break;
> +                       printk(KERN_INFO "PM-Timer had inconsistent results:"
> +                              " 0x%#llx, 0x%#llx - aborting.\n",
> +                              value1, value2);
> +                       return -EINVAL;
> +               }
> +               udelay(300 * i);
300*10000 microseconds seems like a long time to me.  Is this the
intended maximal delay?

> +       }
> +
> +       if (good != ACPI_PM_MONOTONICITY_CHECKS) {
> +               printk(KERN_INFO "PM-Timer failed consistency check "
> +                      " (0x%#llx) - aborting.\n", value1);
> +               return -ENODEV;
If the inner loop runs out once, you alreay know that you will later
abort here.  Maybe move the check directly after the inner loop to
avoid the additional delay (10*10000*300 microseconds = 30 seconds) in
case of failure?

>        }
> -       printk(KERN_INFO "PM-Timer had no reasonable result:"
> -                       " 0x%#x - aborting.\n", value1);
> -       return -ENODEV;
>
> -pm_good:
>        if (verify_pmtmr_rate() != 0)
>                return -ENODEV;

I hope this helps,
Jochen
-- 
http://seehuhn.de/

      reply	other threads:[~2008-09-06 22:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-06 15:10 Thomas Gleixner
2008-09-06 22:20 ` Jochen Voß [this message]

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=ef1cd66f0809061520scafdeb0w957322029273f7ee@mail.gmail.com \
    --to=jochen.voss@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=venkatesh.pallipadi@intel.com \
    /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®