linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Albert Lee <albertcc@tw.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Linux IDE <linux-ide@vger.kernel.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Doug Maxey <dwm@maxeymade.com>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH 2/3] libata-dev: pdc2027x mdelay() problem fix for power5 micro-partitioning
Date: Fri, 05 Aug 2005 01:34:58 +0800	[thread overview]
Message-ID: <42F251C2.8090409@tw.ibm.com> (raw)
In-Reply-To: <42F24DBE.0@tw.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

Jeff,

Patch 2/3: pdc2027x mdelay() problem fix for micro-partitioning

Description:
   The mdelay(100) does not delay exactly 100 ms on IBM power5 machines when the power5 CPU micro-partitioning feature is turned on.
Ex. If micro-partitioning is set to use 0.1 of the CPU time, mdelay(100) will delay about 1 sec instead of 100ms.

Changes:
  - Use do_gettimeofday() to measure the actual elapsed time.
  According to the documentation, do_gettimeofday() works on most platforms
except some old M68K machines. There are no PCI slots on M68K machines,
so using do_gettimeofday() seems to be safe here.

  - Change the counter data type from "unsigned long" to "long".
     Since the counter value is only 30-bit, "long" should be big enough.
     This change is not related to the mdelay() problem, just for beautification.

Patch tested OK on x86, power4 and power5 machines.

For your review, thanks.

Albert

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>


[-- Attachment #2: pdc2.diff --]
[-- Type: text/plain, Size: 1718 bytes --]

--- 01_pdc_mmio/drivers/scsi/pata_pdc2027x.c	2005-08-03 15:43:19.000000000 +0800
+++ 02_pdc_micro/drivers/scsi/pata_pdc2027x.c	2005-08-03 15:44:16.000000000 +0800
@@ -29,7 +29,7 @@
 #include <asm/io.h>
 
 #define DRV_NAME	"pata_pdc2027x"
-#define DRV_VERSION	"0.70"
+#define DRV_VERSION	"0.71"
 #undef PDC_DEBUG
 
 #ifdef PDC_DEBUG
@@ -481,9 +481,9 @@
  * @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)
 {
-	unsigned long counter;
+	long counter;
 	int retry = 1;
 	u32 bccrl, bccrh, bccrlv, bccrhv;
 
@@ -612,11 +612,13 @@
 static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent) 
 {
 	u32 scr;
-	unsigned long start_count, end_count;
+	long start_count, end_count, usec_elapsed;
+	struct timeval start_time, end_time;
 	long pll_clock;
 
 	/* Read current counter value */
 	start_count = pdc_read_counter(probe_ent);
+	do_gettimeofday(&start_time);
 
 	/* Start the test mode */
 	scr = readl(probe_ent->mmio_base + PDC_SYS_CTL);
@@ -629,6 +631,7 @@
 
 	/* Read the counter values again */
 	end_count = pdc_read_counter(probe_ent);
+	do_gettimeofday(&end_time);
 
 	/* Stop the test mode */
 	scr = readl(probe_ent->mmio_base + PDC_SYS_CTL);
@@ -637,7 +640,9 @@
 	wmb();
 
 	/* 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);

  parent reply	other threads:[~2005-08-04 17:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-04 17:17 [PATCH 0/3] libata-dev: pdc2027x fixes Albert Lee
2005-08-04 17:32 ` [PATCH 1/3] libata-dev: Convert pdc2027x from PIO to MMIO Albert Lee
2005-08-04 19:40   ` Brett Russ
2005-08-09 11:04     ` Albert Lee
2005-08-11  2:37     ` Jeff Garzik
2005-08-11  3:03   ` Jeff Garzik
2005-08-11  9:49     ` Albert Lee
2005-08-11 17:49       ` Jeff Garzik
2005-08-04 17:34 ` Albert Lee [this message]
2005-08-07  9:18   ` [PATCH 2/3] libata-dev: pdc2027x mdelay() problem fix for power5 micro-partitioning Benjamin Herrenschmidt
2005-08-11  3:04   ` Jeff Garzik
2005-08-11  8:36     ` Benjamin Herrenschmidt
2005-08-11  9:52       ` Albert Lee
2005-08-04 17:39 ` [PATCH 3/3] libata-dev: Fix pdc2027x ATAPI DMA lost irq problem Albert Lee
2005-08-04 18:41   ` Doug Maxey
2005-08-11  3:05   ` Jeff Garzik

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=42F251C2.8090409@tw.ibm.com \
    --to=albertcc@tw.ibm.com \
    --cc=benh@kernel.crashing.org \
    --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 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).