From: Albert Lee <albertcc@tw.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
Doug Maxey <dwm@maxeymade.com>,
Linux IDE <linux-ide@vger.kernel.org>
Subject: [PATCH 1/1] libata-dev-2.6: pdc2027x yet another PLL fix
Date: Fri, 29 Apr 2005 11:19:55 +0800 [thread overview]
Message-ID: <4271A7DB.9030202@tw.ibm.com> (raw)
In-Reply-To: <426F539D.3090605@tw.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 759 bytes --]
Hi Jeff,
Yet another pdc2027x PLL fix.
Problem:
The mdelay(100) does not delay exactly 100 ms on power5 machines
with the CPU micro-partitioning feature turned on.
Changes:
- Change the "unsigned long" counter data type to "long".
(Since the counter value is only 30-bit, "long" should be enough.)
- Add do_gettimeofday() to measure the elapsed time.
Patch tested OK on power4, power5 and x86 machines.
(According to the document, do_gettimeofday() works on most platforms
except some old M68K machines. There are no PCI slots on those machines,
using do_gettimeofday() seems to be safe here.)
Attached please find the patch against the libata-dev-2.6 tree
for your review. Thanks.
Albert
Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
[-- Attachment #2: pdc062.diff --]
[-- Type: text/plain, Size: 1808 bytes --]
--- linux-ori/drivers/scsi/pata_pdc2027x.c 2005-04-27 18:13:09.000000000 +0800
+++ linux/drivers/scsi/pata_pdc2027x.c 2005-04-28 16:34:36.000000000 +0800
@@ -29,7 +29,7 @@
#include <asm/io.h>
#define DRV_NAME "pata_pdc2027x"
-#define DRV_VERSION "0.61"
+#define DRV_VERSION "0.62"
#undef PDC_DEBUG
#ifdef PDC_DEBUG
@@ -472,10 +472,10 @@
* @probe_ent: for the port address
*/
-static unsigned long pdc_read_counter(struct ata_probe_ent *probe_ent)
+static long pdc_read_counter(struct ata_probe_ent *probe_ent)
{
u8 ctr0, ctr1, ctr2, ctr3;
- unsigned long counter;
+ long counter;
u8 ctr0v, ctr1v, ctr2v, ctr3v;
int retry = 1;
@@ -625,11 +625,13 @@
static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
{
u8 scr1;
- unsigned long start_count, end_count;
- long pll_clock;
+ long start_count, end_count;
+ struct timeval start_time, end_time;
+ long pll_clock, usec_elapsed;
/* Read current counter value */
start_count = pdc_read_counter(probe_ent);
+ do_gettimeofday(&start_time);
/* Start the test mode */
outb(0x01, probe_ent->port[0].bmdma_addr + 0x01);
@@ -642,6 +644,7 @@
/* Read the counter values again */
end_count = pdc_read_counter(probe_ent);
+ do_gettimeofday(&end_time);
/* Stop the test mode */
outb(0x01, probe_ent->port[0].bmdma_addr + 0x01);
@@ -650,7 +653,9 @@
outb(scr1 & 0xBF, probe_ent->port[0].bmdma_addr + 0x03);
/* calculate the input clock in Hz */
- pll_clock = (long) ((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[%lu] end[%lu] \n", start_count, end_count);
PDPRINTK("PLL input clock[%ld]Hz\n", pll_clock);
prev parent reply other threads:[~2005-04-29 3:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-11 9:57 [PATCH 0/4] libata-dev-2.6: pdc2027x PLL input clock detection fix, etc Albert Lee
2005-04-11 10:02 ` [PATCH 1/4] libata-dev-2.6: pdc2027x add ata_scsi_ioctl Albert Lee
2005-05-16 2:38 ` Jeff Garzik
2005-04-11 10:04 ` [PATCH 2/4] libata-dev-2.6: pdc2027x change comments Albert Lee
2005-04-11 10:06 ` [PATCH 3/4] libata-dev-2.6: pdc2027x move the PLL counter reading code Albert Lee
2005-04-11 10:11 ` [PATCH 0/4] libata-dev-2.6: pdc2027x PLL input clock detection fix, etc Albert Lee
2005-04-11 10:28 ` [PATCH 4/4] libata-dev-2.6: pdc2027x PLL input clock detection fix Albert Lee
2005-04-17 1:54 ` [PATCH 2.6.12-rc2 0/2] libata: add reporting of atapi errors Eric A. Cottrell
2005-04-19 6:08 ` [PATCH 1/1] libata-dev-2.6: pdc2027x ATAPI DMA fix Albert Lee
2005-04-27 8:55 ` Albert Lee
2005-04-29 3:19 ` Albert Lee [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=4271A7DB.9030202@tw.ibm.com \
--to=albertcc@tw.ibm.com \
--cc=bzolnier@gmail.com \
--cc=dwm@maxeymade.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.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.