Received: from mail.onstor.com ([66.201.51.107]) by onstor-exch02.onstor.net with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 27 Oct 2008 06:40:49 -0700
Received: from dalesmta2-2.messageone.com ([129.41.169.249]) by mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 27 Oct 2008 06:40:48 -0700
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])
	by dalesmta2-2.messageone.com (8.13.8/8.13.8) with ESMTP id m9RDekMr008749
	for <andy.sharp@onstor.com>; Mon, 27 Oct 2008 08:40:47 -0500
Received: from localhost.localdomain ([127.0.0.1]:20654 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP
	id S22502086AbYJ0Njj (ORCPT <rfc822;andy.sharp@onstor.com>);
	Mon, 27 Oct 2008 13:39:39 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 27 Oct 2008 13:39:22 +0000 (GMT)
Received: from mba.ocn.ne.jp ([122.1.235.107]:51155 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S22502083AbYJ0NjT (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 27 Oct 2008 13:39:19 +0000
Received: from localhost (p4040-ipad307funabasi.chiba.ocn.ne.jp [123.217.182.40])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id D26F4AA08; Mon, 27 Oct 2008 22:39:12 +0900 (JST)
Date: 	Mon, 27 Oct 2008 22:39:13 +0900 (JST)
Message-Id: <20081027.223913.128619425.anemo@mba.ocn.ne.jp>
To: linux-mips@linux-mips.org
Cc: linux-ide@vger.kernel.org, Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
        ralf@linux-mips.org, sshtylyov@ru.mvista.com
Subject: [PATCH 1/2] tx4938ide: Check minimum cycle time and SHWT range
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 21.4 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-archive-position: 20990
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: 	linux-mips
X-MessageOne-Virus-Version: vendor=fsecure engine=4.65.7400:2.4.4,1.2.40,4.0.164 definitions=2008-10-27_03:2008-10-10,2008-10-27,2008-10-27 signatures=0
X-MessageOne-Virus-Scanned: Clean
X-MessageOne-Envelope-Sender: linux-mips-bounce@linux-mips.org
X-MessageOne-Spam-Details: rule=m773emszm_notspam policy=m773emszm score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=3.1.0-0810130000 definitions=main-0810270063
X-MessageOne-Spam-Score: 0
X-MessageOne-Spam-Bar: 
Return-Path: linux-mips-bounce@linux-mips.org
X-OriginalArrivalTime: 27 Oct 2008 13:40:48.0739 (UTC) FILETIME=[9EECF330:01C93839]

SHWT value is used as address valid to -CSx assertion and -CSx to -DIOx
assertion setup time, and contrarywise, -DIOx to -CSx release and -CSx
release to address invalid hold time, so it actualy applies 4 times and
so constitutes -DIOx recovery time.  Check requirement of the recovery
time and cycle time.  Also check SHWT maximum value.

Suggested-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 drivers/ide/tx4938ide.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index fa660f9..7e4820e 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -39,10 +39,17 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch,
 	/* Address-valid to DIOR/DIOW setup */
 	shwt = DIV_ROUND_UP(t->setup, cycle);
 
+	/* -DIOx recovery time (SHWT * 4) and cycle time requirement */
+	while (shwt * cycle * 4 + t->act8b < t->cycle)
+		shwt++;
+	if (shwt > 7) {
+		pr_warning("tx4938ide: SHWT violation (%d)\n", shwt);
+		shwt = 7;
+	}
 	pr_debug("tx4938ide: ebus %d, bus cycle %dns, WT %d, SHWT %d\n",
 		 ebus_ch, cycle, wt, shwt);
 
-	__raw_writeq((cr & ~(0x3f007ull)) | (wt << 12) | shwt,
+	__raw_writeq((cr & ~0x3f007ull) | (wt << 12) | shwt,
 		     &tx4938_ebuscptr->cr[ebus_ch]);
 }
 
-- 
1.5.6.3

