From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: albertl@mail.com
Cc: Jeff Garzik <jeff@garzik.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Sergei Shtylyov <sshtylyov@ru.mvista.com>,
Bahadir Balban <bahadir.balban@gmail.com>,
linux-ide@vger.kernel.org, Mikael Pettersson <mikpe@it.uu.se>,
Doug Maxey <dwm@enoyolf.org>
Subject: Re: [PATCH 1/1] libata: pata_pdc2027x PLL input clock fix
Date: Mon, 2 Jul 2007 20:13:04 +0200 [thread overview]
Message-ID: <200707022013.04383.bzolnier@gmail.com> (raw)
In-Reply-To: <4680A773.2020009@tw.ibm.com>
Hi,
Could you also fix pdc202xx_new driver?
"buggy" code should be very similar if not identical...
On Tuesday 26 June 2007, Albert Lee wrote:
> Recently the PLL input clock of pata_pdc2027x is sometimes detected
> higer than expected (e.g. 20.027 MHz compared to 16.714 MHz).
> It seems sometimes the mdelay() function is not as precise as it
> used to be. Per Alan's advice, HT or power management might affect
> the precision of mdelay().
>
> This patch calls gettimeofday() to mesure the time elapsed and
> calculate the PLL input clock accordingly.
>
> Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> ---
>
> Did more test. For mdelay(100) the usec_elapsed is usually 99287.
> However, sometimes the usec_elapsed is 118934, longer than expected.
>
> Jun 26 12:12:29 p4ht-s kernel: [ 9156.490991] ACPI: PCI Interrupt 0000:02:05.0[A] -> Link [LNK1] -> GSI 10 (level, low) -> IRQ 10
> Jun 26 12:12:29 p4ht-s kernel: [ 9156.610175] usec_elapsed[118934]
> Jun 26 12:12:29 p4ht-s kernel: [ 9156.610511] pata_pdc2027x 0000:02:05.0: PLL input clock 16817 kHz
>
> After the patch, the PLL input clock detected looks more accurate.
> For your review, thanks.
>
> diff -Nrup 00_libata-dev/drivers/ata/pata_pdc2027x.c 01_gettimeofday/drivers/ata/pata_pdc2027x.c
> --- 00_libata-dev/drivers/ata/pata_pdc2027x.c 2007-06-01 12:08:21.000000000 +0800
> +++ 01_gettimeofday/drivers/ata/pata_pdc2027x.c 2007-06-26 13:08:34.000000000 +0800
> @@ -689,10 +689,12 @@ static long pdc_detect_pll_input_clock(s
> void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR];
> u32 scr;
> long start_count, end_count;
> - long pll_clock;
> + struct timeval start_time, end_time;
> + long pll_clock, usec_elapsed;
>
> /* Read current counter value */
> start_count = pdc_read_counter(host);
> + do_gettimeofday(&start_time);
>
> /* Start the test mode */
> scr = readl(mmio_base + PDC_SYS_CTL);
> @@ -705,6 +707,7 @@ static long pdc_detect_pll_input_clock(s
>
> /* Read the counter values again */
> end_count = pdc_read_counter(host);
> + do_gettimeofday(&end_time);
>
> /* Stop the test mode */
> scr = readl(mmio_base + PDC_SYS_CTL);
> @@ -713,7 +716,11 @@ static long pdc_detect_pll_input_clock(s
> readl(mmio_base + PDC_SYS_CTL); /* flush */
>
> /* calculate the input clock in Hz */
> - pll_clock = (start_count - end_count) * 10;
> + usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 +
> + (end_time.tv_usec - start_time.tv_usec);
> +
> + pll_clock = (start_count - end_count) / 100 *
> + (100000000 / usec_elapsed);
>
> PDPRINTK("start[%ld] end[%ld] \n", start_count, end_count);
> PDPRINTK("PLL input clock[%ld]Hz\n", pll_clock);
next prev parent reply other threads:[~2007-07-02 17:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-21 11:47 ide/dma not working from 2.6.19 to 2.6.21 Bahadir Balban
2007-06-21 15:28 ` Sergei Shtylyov
2007-06-21 18:17 ` Sergei Shtylyov
2007-06-25 5:22 ` Albert Lee
2007-06-25 9:10 ` Alan Cox
2007-06-26 5:05 ` Albert Lee
2007-06-26 5:43 ` [PATCH 1/1] libata: pata_pdc2027x PLL input clock fix Albert Lee
2007-07-02 14:14 ` Jeff Garzik
2007-07-02 18:13 ` Bartlomiej Zolnierkiewicz [this message]
2007-07-02 18:00 ` Sergei Shtylyov
2007-07-03 5:21 ` [PATCH 1/1] ide: pdc202xx_new " Albert Lee
2007-07-03 14:24 ` Sergei Shtylyov
2007-07-03 18:59 ` Bartlomiej Zolnierkiewicz
2007-07-03 20:36 ` Sergei Shtylyov
2007-07-04 8:20 ` Albert Lee
2007-07-03 18:57 ` Bartlomiej Zolnierkiewicz
2007-07-20 14:38 ` Bahadir Balban
-- strict thread matches above, loose matches on Subject: below --
2007-07-09 23:04 [PATCH 1/1] libata: pata_pdc2027x " Mikael Pettersson
2007-07-10 3:52 ` Albert Lee
2007-08-16 19:11 ` Jeff Garzik
2007-08-16 20:19 ` Alan Cox
2007-07-10 23:14 Mikael Pettersson
2007-07-11 2:45 ` Albert Lee
2007-07-11 10:26 Mikael Pettersson
2007-07-16 9:12 ` Albert Lee
2007-08-17 20:51 Mikael Pettersson
2007-10-14 17:31 ` Jeff Garzik
2007-10-14 18:33 Mikael Pettersson
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=200707022013.04383.bzolnier@gmail.com \
--to=bzolnier@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=albertl@mail.com \
--cc=bahadir.balban@gmail.com \
--cc=dwm@enoyolf.org \
--cc=jeff@garzik.org \
--cc=linux-ide@vger.kernel.org \
--cc=mikpe@it.uu.se \
--cc=sshtylyov@ru.mvista.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;
as well as URLs for NNTP newsgroup(s).