From tsbogend@alpha.franken.de Thu May  1 17:33:18 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 01 May 2008 17:33:21 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:17880 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S36902744AbYEAQdS (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 1 May 2008 17:33:18 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1Jrbif-0006pR-00
	for linux-mips@linux-mips.org; Thu, 01 May 2008 18:33:17 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 5366CC2A8A; Thu,  1 May 2008 18:33:14 +0200 (CEST)
Date:	Thu, 1 May 2008 18:33:14 +0200
To:	linux-mips@linux-mips.org
Subject: Breakage in arch/mips/kernel/traps.c for 64bit
Message-ID: <20080501163314.GA9955@alpha.franken.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.13 (2006-08-11)
From:	tsbogend@alpha.franken.de (Thomas Bogendoerfer)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19065
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips

Hi,

it would be nice, if people started thinking before supplying such
crappy^Winteresting code:

arch/mips/kernel/traps.c:

#define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)

Kills every 64bit kernel build...

Why is this needed at all ?

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

From giuseppe@eppesuigoccas.homedns.org Thu May  1 19:13:01 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 01 May 2008 19:13:04 +0100 (BST)
Received: from host194-211-dynamic.20-79-r.retail.telecomitalia.it ([79.20.211.194]:28576
	"EHLO eppesuigoccas.homedns.org") by ftp.linux-mips.org with ESMTP
	id S62064043AbYEASNB (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 1 May 2008 19:13:01 +0100
Received: from casa ([192.168.2.34])
	by eppesuigoccas.homedns.org with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16)
	(Exim 4.63)
	(envelope-from <giuseppe@eppesuigoccas.homedns.org>)
	id 1JrdGz-0001mx-80; Thu, 01 May 2008 20:12:52 +0200
Subject: Re: undefined reference to `copy_siginfo_from_user32'
From:	Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
To:	Christoph Hellwig <hch@lst.de>
Cc:	linux-mips@linux-mips.org
In-Reply-To: <20080429090039.GA16616@lst.de>
References: <20080428212327.47c703b6.giuseppe@eppesuigoccas.homedns.org>
	 <20080429090039.GA16616@lst.de>
Content-Type: text/plain
Date:	Thu, 01 May 2008 20:11:52 +0200
Message-Id: <1209665512.5605.0.camel@casa>
Mime-Version: 1.0
X-Mailer: Evolution 2.6.3 
Content-Transfer-Encoding: 7bit
Return-Path: <giuseppe@eppesuigoccas.homedns.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19067
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: giuseppe@eppesuigoccas.homedns.org
Precedence: bulk
X-list: linux-mips
Content-Length: 667
Lines: 17

Il giorno mar, 29/04/2008 alle 11.00 +0200, Christoph Hellwig ha
scritto:
> On Mon, Apr 28, 2008 at 09:23:27PM +0200, Giuseppe Sacco wrote:
> > Hi list,
> > since a few days, whenever I try to recompile the latest kernel (from git) it always print this error message:
> 
> This should be fixed in mainline.  But the right fix would be to switch
> mips to the generic compat_ptrace.  And untested (and in fact even
> uncompiled) patch ontop of the copy_siginfo_to_user32 posted to the list
> a while ago is below to sketch how this should look like:

I cannot apply this patch to the latest kernel from git. Could you
provide a new one?

Thanks a lot,
Giuseppe Sacco


From macro@linux-mips.org Thu May  1 22:01:25 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 01 May 2008 22:01:28 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:6127 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20033234AbYEAVBZ (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 1 May 2008 22:01:25 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m41L1FBq008191;
	Thu, 1 May 2008 23:01:15 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m41L1E81008187;
	Thu, 1 May 2008 22:01:15 +0100
Date:	Thu, 1 May 2008 22:01:13 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
cc:	linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
In-Reply-To: <20080501163314.GA9955@alpha.franken.de>
Message-ID: <Pine.LNX.4.55.0805012150130.6145@cliff.in.clinika.pl>
References: <20080501163314.GA9955@alpha.franken.de>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19068
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 818
Lines: 23

On Thu, 1 May 2008, Thomas Bogendoerfer wrote:

> it would be nice, if people started thinking before supplying such
> crappy^Winteresting code:
> 
> arch/mips/kernel/traps.c:
> 
> #define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
> 
> Kills every 64bit kernel build...

 Not everybody tests 64-bit stuff as some people limit themselves to
32-bit systems only.  It looks like a step backwards, but there you go.

> Why is this needed at all ?

 It looks like an attempt to avoid TLB exceptions for the stack dump -- if
that is the case, then obviously a piece of code like one in
arch/mips/lib/uncached.c should be used to check for CKSEG0/1 and XKPHYS.  
If there are two uses of this code, then it should be wrapped in an inline
function and put in a header; <asm/addrspace.h>, perhaps.

  Maciej

From ralf@linux-mips.org Fri May  2 11:11:18 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 11:11:21 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:11245 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S62077927AbYEBKLS (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 11:11:18 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42ABDN0002904;
	Fri, 2 May 2008 11:11:13 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42ABDPh002903;
	Fri, 2 May 2008 11:11:13 +0100
Date:	Fri, 2 May 2008 11:11:13 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc:	linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
Message-ID: <20080502101113.GA24408@linux-mips.org>
References: <20080501163314.GA9955@alpha.franken.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080501163314.GA9955@alpha.franken.de>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19069
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1721
Lines: 59

On Thu, May 01, 2008 at 06:33:14PM +0200, Thomas Bogendoerfer wrote:

> it would be nice, if people started thinking before supplying such
> crappy^Winteresting code:
> 
> arch/mips/kernel/traps.c:
> 
> #define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
> 
> Kills every 64bit kernel build...
> 
> Why is this needed at all ?

It came as part of 39b8d5254246ac56342b72f812255c8f7a74dca9 which is a
patch amalgated from several other patches.  Below is the original patch
it came with.  I think the idea of the patch is valid but the idea needs a
bit of mending.

From: Chris Dearman <chris@mips.com>
Date: Wed, 3 Oct 2007 10:19:18 +0100
Subject: [PATCH] Skip raw backtrace for non KSEG stack addresses
 This is to avoid recursive stackdumps as the kernel kernel falls off
 of the user stack.

Signed-off-by: Chris Dearman <chris@mips.com>

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 2948b86..3d56171 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -79,19 +79,22 @@ void (*board_bind_eic_interrupt)(int irq, int regset);
 
 static void show_raw_backtrace(unsigned long reg29)
 {
-	unsigned long *sp = (unsigned long *)reg29;
+	unsigned long *sp = (unsigned long *)(reg29 & ~3);
 	unsigned long addr;
 
 	printk("Call Trace:");
 #ifdef CONFIG_KALLSYMS
 	printk("\n");
 #endif
-	while (!kstack_end(sp)) {
-		addr = *sp++;
-		if (__kernel_text_address(addr))
-			print_ip_sym(addr);
+#define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
+	if (IS_KVA01(sp)) {
+		while (!kstack_end(sp)) {
+			addr = *sp++;
+			if (__kernel_text_address(addr))
+				print_ip_sym(addr);
+		}
+		printk("\n");
 	}
-	printk("\n");
 }
 
 #ifdef CONFIG_KALLSYMS

From ilpo.jarvinen@helsinki.fi Fri May  2 12:08:26 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 12:08:28 +0100 (BST)
Received: from courier.cs.helsinki.fi ([128.214.9.1]:59268 "EHLO
	mail.cs.helsinki.fi") by ftp.linux-mips.org with ESMTP
	id S62082810AbYEBLI0 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 12:08:26 +0100
Received: from wrl-59.cs.helsinki.fi (wrl-59.cs.helsinki.fi [128.214.166.179])
  (AUTH: PLAIN cs-relay, TLS: TLSv1/SSLv3,256bits,AES256-SHA)
  by mail.cs.helsinki.fi with esmtp; Fri, 02 May 2008 14:08:22 +0300
  id 000680FA.481AF626.00000986
Received: by wrl-59.cs.helsinki.fi (Postfix, from userid 50795)
	id 98E1EA0098; Fri,  2 May 2008 14:08:22 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by wrl-59.cs.helsinki.fi (Postfix) with ESMTP id 967BAA0097;
	Fri,  2 May 2008 14:08:22 +0300 (EEST)
Date:	Fri, 2 May 2008 14:08:20 +0300 (EEST)
From:	"=?ISO-8859-1?Q?Ilpo_J=E4rvinen?=" <ilpo.jarvinen@helsinki.fi>
X-X-Sender: ijjarvin@wrl-59.cs.helsinki.fi
To:	ralf@linux-mips.org
cc:	linux-mips@linux-mips.org
Subject: [PATCH] [MIPS]: if() in pte_mkyoung seems to be missing braces
Message-ID: <Pine.LNX.4.64.0805021400481.30402@wrl-59.cs.helsinki.fi>
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="-696208474-1766178569-1209726500=:30402"
Return-Path: <ilpo.jarvinen@helsinki.fi>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19070
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: ilpo.jarvinen@helsinki.fi
Precedence: bulk
X-list: linux-mips
Content-Length: 1138
Lines: 36

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---696208474-1766178569-1209726500=:30402
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT

In case this is a genuine bug, somebody else more familiar
with that stuff should evaluate it's effects (I just found it
by some shell pipeline and it seems suspicious looking).

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
 include/asm-mips/pgtable.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index 17a7703..fc6e98b 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -232,9 +232,10 @@ static inline pte_t pte_mkdirty(pte_t pte)
 static inline pte_t pte_mkyoung(pte_t pte)
 {
 	pte.pte_low |= _PAGE_ACCESSED;
-	if (pte.pte_low & _PAGE_READ)
+	if (pte.pte_low & _PAGE_READ) {
 		pte.pte_low  |= _PAGE_SILENT_READ;
 		pte.pte_high |= _PAGE_SILENT_READ;
+	}
 	return pte;
 }
 #else
-- 
1.5.2.2

---696208474-1766178569-1209726500=:30402--

From ralf@linux-mips.org Fri May  2 21:24:47 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:24:51 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:46540 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28801439AbYEBUYr (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:24:47 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KOjda001692;
	Fri, 2 May 2008 21:24:45 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KOio2001679;
	Fri, 2 May 2008 21:24:44 +0100
Date:	Fri, 2 May 2008 21:24:44 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 1/11] Alchemy common headers style cleanup
Message-ID: <20080502202444.GA1552@linux-mips.org>
References: <200804302318.35039.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302318.35039.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19071
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 300
Lines: 10

On Wed, Apr 30, 2008 at 11:18:35PM +0400, Sergei Shtylyov wrote:
> From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
> Date: Wed, 30 Apr 2008 23:18:35 +0400
> To: ralf@linux-mips.org
> Cc: linux-mips@linux-mips.org
> Subject: [PATCH 1/11] Alchemy common headers style cleanup

Applied, thanks.

  Ralf

From ralf@linux-mips.org Fri May  2 21:25:37 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:25:40 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:47820 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28801450AbYEBUZh (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:25:37 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KPYbs002004;
	Fri, 2 May 2008 21:25:34 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KPYxv002002;
	Fri, 2 May 2008 21:25:34 +0100
Date:	Fri, 2 May 2008 21:25:34 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 2/11] Alchemy common code style cleanup
Message-ID: <20080502202534.GB1552@linux-mips.org>
References: <200804302318.41380.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302318.41380.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19072
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 55
Lines: 4


Applied after fixing a minor reject.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:26:00 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:26:04 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:49100 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28801459AbYEBU0A (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:26:00 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KPvxC002156;
	Fri, 2 May 2008 21:25:57 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KPvOC002155;
	Fri, 2 May 2008 21:25:57 +0100
Date:	Fri, 2 May 2008 21:25:57 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 3/11] Alchemy PCI code style cleanup
Message-ID: <20080502202557.GC1552@linux-mips.org>
References: <200804302323.27714.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302323.27714.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19073
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:26:19 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:26:23 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:49868 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28801468AbYEBU0P (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:26:15 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KQDgn002255;
	Fri, 2 May 2008 21:26:13 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KQDNa002254;
	Fri, 2 May 2008 21:26:13 +0100
Date:	Fri, 2 May 2008 21:26:13 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 4/11] DBAu1xx0 code style cleanup
Message-ID: <20080502202613.GD1552@linux-mips.org>
References: <200804302325.04753.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302325.04753.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19074
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 25
Lines: 3

Applied, thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:27:02 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:27:04 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:51660 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S30617659AbYEBU1C (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:27:02 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KR1Dx002577;
	Fri, 2 May 2008 21:27:01 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KR1F3002576;
	Fri, 2 May 2008 21:27:01 +0100
Date:	Fri, 2 May 2008 21:27:01 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 5/11] Pb1000 code style cleanup
Message-ID: <20080502202701.GE1552@linux-mips.org>
References: <200804302325.55147.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302325.55147.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19075
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 98
Lines: 4

Applied after fixing up a major reject.  You probably want to verify
the result.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:27:20 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:27:22 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:52428 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S30618576AbYEBU1R (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:27:17 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KRHIr002680;
	Fri, 2 May 2008 21:27:17 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KRH2C002679;
	Fri, 2 May 2008 21:27:17 +0100
Date:	Fri, 2 May 2008 21:27:17 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 5/11] Pb1100 code style cleanup
Message-ID: <20080502202717.GF1552@linux-mips.org>
References: <200804302326.28167.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302326.28167.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19076
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:27:38 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:27:40 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:53196 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S36920189AbYEBU1b (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:27:31 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KRU3Y002826;
	Fri, 2 May 2008 21:27:30 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KRUCG002825;
	Fri, 2 May 2008 21:27:30 +0100
Date:	Fri, 2 May 2008 21:27:30 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 7/11] Pb1500 code style cleanup
Message-ID: <20080502202730.GG1552@linux-mips.org>
References: <200804302327.20153.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302327.20153.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19077
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:27:55 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:27:58 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:8065 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S23859457AbYEBU1p (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:27:45 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KRi4c002920;
	Fri, 2 May 2008 21:27:44 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KRirm002919;
	Fri, 2 May 2008 21:27:44 +0100
Date:	Fri, 2 May 2008 21:27:44 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 8/11] Pb1550 code style cleanup
Message-ID: <20080502202744.GH1552@linux-mips.org>
References: <200804302328.17457.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302328.17457.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19078
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:28:13 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:28:15 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:8833 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S23859514AbYEBU16 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:27:58 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KRvUk003009;
	Fri, 2 May 2008 21:27:57 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KRvBD003008;
	Fri, 2 May 2008 21:27:57 +0100
Date:	Fri, 2 May 2008 21:27:57 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 7/11] Pb1200/DBAu1200 code style cleanup
Message-ID: <20080502202757.GI1552@linux-mips.org>
References: <200804302329.04189.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302329.04189.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19079
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:28:31 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:28:34 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:10625 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S23859543AbYEBU2Q (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:28:16 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KSFPw003138;
	Fri, 2 May 2008 21:28:15 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KSFIP003137;
	Fri, 2 May 2008 21:28:15 +0100
Date:	Fri, 2 May 2008 21:28:15 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 10/11] MTX-1 code style cleanup
Message-ID: <20080502202815.GJ1552@linux-mips.org>
References: <200804302330.12345.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302330.12345.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19080
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri May  2 21:28:49 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:28:52 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:11393 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S23865801AbYEBU20 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 2 May 2008 21:28:26 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m42KSPNp003212;
	Fri, 2 May 2008 21:28:25 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m42KSPO2003211;
	Fri, 2 May 2008 21:28:25 +0100
Date:	Fri, 2 May 2008 21:28:25 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 11/11] XXS1500 code style cleanup
Message-ID: <20080502202825.GK1552@linux-mips.org>
References: <200804302331.03586.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200804302331.03586.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19081
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 26
Lines: 3

Applied.  Thanks,

  Ralf

From sshtylyov@ru.mvista.com Fri May  2 21:42:15 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 02 May 2008 21:42:18 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:52784 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20052459AbYEBUmP (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 2 May 2008 21:42:15 +0100
Received: from acerfa265979ef (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with SMTP
	id 672CB3EC9; Fri,  2 May 2008 13:42:11 -0700 (PDT)
Message-ID: <04f101c8ac94$fe27d620$5205a8c0@acerfa265979ef>
From:	"Sergei Shtylyov" <sshtylyov@ru.mvista.com>
To:	"Ralf Baechle" <ralf@linux-mips.org>
Cc:	<linux-mips@linux-mips.org>
References: <200804302325.55147.sshtylyov@ru.mvista.com> <20080502202701.GE1552@linux-mips.org>
Subject: Re: [PATCH 5/11] Pb1000 code style cleanup
Date:	Sat, 3 May 2008 00:42:08 +0400
MIME-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="iso-8859-1";
	reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19082
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 309
Lines: 20

Hello.

> Applied after fixing up a major reject.

   That's because you've missed appied ""Pb1000: bury the remnants of the 
PCI code (part 2) I psoted the day before the patchset... :-/

> You probably want to verify the result.

   Looked OK.

> Thanks,

   Thanks for applying it.

>  Ralf

WBR, Sergei



From macro@linux-mips.org Sat May  3 00:49:13 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 00:49:16 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:55293 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S28801513AbYEBXtN (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 00:49:13 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m42Nn4Sg015763;
	Sat, 3 May 2008 01:49:04 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m42Nmkbo015759;
	Sat, 3 May 2008 00:48:47 +0100
Date:	Sat, 3 May 2008 00:48:45 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Ralf Baechle <ralf@linux-mips.org>
cc:	Daniel Jacobowitz <drow@false.org>, linux-mips@linux-mips.org
Subject: [PATCH] Bring the SWARM defconfig up to date
Message-ID: <Pine.LNX.4.55.0805030008280.12296@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19083
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 29362
Lines: 1242

 The SWARM defconfig file has not been regenerated for over a year now.
Here is a patch to bring the file up to date.  Additionally some important
and sometimes confusing changes happened meanwhile.  Here is the list of 
notable corresponding updates to the configuration:

1. CPU_SB1_PASS_2_2 is now selected rather than CPU_SB1_PASS_1.  The
   latter requires a non-standard -msb1-pass1-workarounds option to be
   supported by GCC and I am told is quite rare anyway.

2. PHYLIB and BROADCOM_PHY are both built in and NETDEV_1000 enabled as 
   required by SB1250_MAC.

3. USB and USB_OHCI_HCD are enabled as there is an OHCI chip onboard.

4. TMPFS is enabled, because I use it. ;-)

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 Anybody please let me know if there is something notable that should be 
changed.

 The configuration builds successfully; it even boots on my box. :-)  
Ralf, please apply.

  Maciej

patch-mips-2.6.25-20080422-swarm-defconfig-3
diff -up --recursive --new-file linux-mips-2.6.25-20080422.macro/arch/mips/configs/sb1250-swarm_defconfig linux-mips-2.6.25-20080422/arch/mips/configs/sb1250-swarm_defconfig
--- linux-mips-2.6.25-20080422.macro/arch/mips/configs/sb1250-swarm_defconfig	2008-02-05 05:55:18.000000000 +0000
+++ linux-mips-2.6.25-20080422/arch/mips/configs/sb1250-swarm_defconfig	2008-05-02 23:38:11.000000000 +0000
@@ -1,67 +1,58 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.20
-# Tue Feb 20 21:47:40 2007
+# Linux kernel version: 2.6.25
+# Sat May  3 00:38:11 2008
 #
 CONFIG_MIPS=y
 
 #
 # Machine selection
 #
-CONFIG_ZONE_DMA=y
-# CONFIG_MIPS_MTX1 is not set
-# CONFIG_MIPS_BOSPORUS is not set
-# CONFIG_MIPS_PB1000 is not set
-# CONFIG_MIPS_PB1100 is not set
-# CONFIG_MIPS_PB1500 is not set
-# CONFIG_MIPS_PB1550 is not set
-# CONFIG_MIPS_PB1200 is not set
-# CONFIG_MIPS_DB1000 is not set
-# CONFIG_MIPS_DB1100 is not set
-# CONFIG_MIPS_DB1500 is not set
-# CONFIG_MIPS_DB1550 is not set
-# CONFIG_MIPS_DB1200 is not set
-# CONFIG_MIPS_MIRAGE is not set
+# CONFIG_MACH_ALCHEMY is not set
 # CONFIG_BASLER_EXCITE is not set
+# CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
+# CONFIG_LASAT is not set
+# CONFIG_LEMOTE_FULONG is not set
 # CONFIG_MIPS_ATLAS is not set
 # CONFIG_MIPS_MALTA is not set
 # CONFIG_MIPS_SEAD is not set
-# CONFIG_WR_PPMC is not set
 # CONFIG_MIPS_SIM is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_MIPS_XXS1500 is not set
+# CONFIG_MARKEINS is not set
+# CONFIG_MACH_VR41XX is not set
 # CONFIG_PNX8550_JBS is not set
 # CONFIG_PNX8550_STB810 is not set
-# CONFIG_MACH_VR41XX is not set
+# CONFIG_PMC_MSP is not set
 # CONFIG_PMC_YOSEMITE is not set
-# CONFIG_MARKEINS is not set
 # CONFIG_SGI_IP22 is not set
 # CONFIG_SGI_IP27 is not set
+# CONFIG_SGI_IP28 is not set
 # CONFIG_SGI_IP32 is not set
-# CONFIG_SIBYTE_BIGSUR is not set
-CONFIG_SIBYTE_SWARM=y
-# CONFIG_SIBYTE_SENTOSA is not set
-# CONFIG_SIBYTE_RHONE is not set
-# CONFIG_SIBYTE_CARMEL is not set
-# CONFIG_SIBYTE_LITTLESUR is not set
 # CONFIG_SIBYTE_CRHINE is not set
+# CONFIG_SIBYTE_CARMEL is not set
 # CONFIG_SIBYTE_CRHONE is not set
+# CONFIG_SIBYTE_RHONE is not set
+CONFIG_SIBYTE_SWARM=y
+# CONFIG_SIBYTE_LITTLESUR is not set
+# CONFIG_SIBYTE_SENTOSA is not set
+# CONFIG_SIBYTE_BIGSUR is not set
 # CONFIG_SNI_RM is not set
 # CONFIG_TOSHIBA_JMR3927 is not set
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
+# CONFIG_WR_PPMC is not set
 CONFIG_SIBYTE_SB1250=y
 CONFIG_SIBYTE_SB1xxx_SOC=y
-CONFIG_CPU_SB1_PASS_1=y
+# CONFIG_CPU_SB1_PASS_1 is not set
 # CONFIG_CPU_SB1_PASS_2_1250 is not set
-# CONFIG_CPU_SB1_PASS_2_2 is not set
+CONFIG_CPU_SB1_PASS_2_2=y
 # CONFIG_CPU_SB1_PASS_4 is not set
 # CONFIG_CPU_SB1_PASS_2_112x is not set
 # CONFIG_CPU_SB1_PASS_3 is not set
 CONFIG_SIBYTE_HAS_LDT=y
+CONFIG_SIBYTE_ENABLE_LDT_IF_PCI=y
 # CONFIG_SIMULATION is not set
 # CONFIG_SB1_CEX_ALWAYS_FATAL is not set
 # CONFIG_SB1_CERR_STALL is not set
@@ -69,20 +60,32 @@ CONFIG_SIBYTE_CFE=y
 # CONFIG_SIBYTE_CFE_CONSOLE is not set
 # CONFIG_SIBYTE_BUS_WATCHER is not set
 # CONFIG_SIBYTE_TBPROF is not set
+CONFIG_SIBYTE_HAS_ZBUS_PROFILING=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_SUPPORTS_OPROFILE=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_CLOCKEVENTS=y
 CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
 CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 # CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set
+CONFIG_CEVT_SB1250=y
+CONFIG_CSRC_SB1250=y
+CONFIG_CFE=y
 CONFIG_DMA_COHERENT=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+# CONFIG_HOTPLUG_CPU is not set
+# CONFIG_NO_IOPORT is not set
 CONFIG_CPU_BIG_ENDIAN=y
 # CONFIG_CPU_LITTLE_ENDIAN is not set
 CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
 CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_IRQ_CPU=y
 CONFIG_SWAP_IO_SPACE=y
 CONFIG_BOOT_ELF32=y
 CONFIG_MIPS_L1_CACHE_SHIFT=5
@@ -90,6 +93,7 @@ CONFIG_MIPS_L1_CACHE_SHIFT=5
 #
 # CPU selection
 #
+# CONFIG_CPU_LOONGSON2 is not set
 # CONFIG_CPU_MIPS32_R1 is not set
 # CONFIG_CPU_MIPS32_R2 is not set
 # CONFIG_CPU_MIPS64_R1 is not set
@@ -130,8 +134,7 @@ CONFIG_CPU_HAS_PREFETCH=y
 CONFIG_MIPS_MT_DISABLED=y
 # CONFIG_MIPS_MT_SMP is not set
 # CONFIG_MIPS_MT_SMTC is not set
-# CONFIG_MIPS_VPE_LOADER is not set
-CONFIG_SB1_PASS_1_WORKAROUNDS=y
+CONFIG_SB1_PASS_2_WORKAROUNDS=y
 CONFIG_CPU_HAS_LLSC=y
 CONFIG_CPU_HAS_SYNC=y
 CONFIG_GENERIC_HARDIRQS=y
@@ -140,6 +143,7 @@ CONFIG_IRQ_PER_CPU=y
 CONFIG_CPU_SUPPORTS_HIGHMEM=y
 CONFIG_SYS_SUPPORTS_HIGHMEM=y
 CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
 CONFIG_SELECT_MEMORY_MODEL=y
 CONFIG_FLATMEM_MANUAL=y
 # CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -147,13 +151,19 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
 CONFIG_RESOURCES_64BIT=y
-CONFIG_ZONE_DMA_FLAG=1
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
 CONFIG_SMP=y
 CONFIG_SYS_SUPPORTS_SMP=y
 CONFIG_NR_CPUS_DEFAULT_2=y
 CONFIG_NR_CPUS=2
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
 # CONFIG_HZ_48 is not set
 # CONFIG_HZ_100 is not set
 # CONFIG_HZ_128 is not set
@@ -166,38 +176,49 @@ CONFIG_HZ=1000
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-CONFIG_PREEMPT_BKL=y
 # CONFIG_KEXEC is not set
+CONFIG_SECCOMP=y
 CONFIG_LOCKDEP_SUPPORT=y
 CONFIG_STACKTRACE_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
-# Code maturity level options
+# General setup
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
-# CONFIG_IPC_NS is not set
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
-# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
 # CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=15
 CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+# CONFIG_CGROUP_NS is not set
 CONFIG_CPUSETS=y
-CONFIG_SYSFS_DEPRECATED=y
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+CONFIG_CGROUP_CPUACCT=y
+# CONFIG_RESOURCE_COUNTERS is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+# CONFIG_PROC_PID_CPUSET is not set
 CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_IPC_NS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SYSCTL=y
@@ -209,20 +230,29 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 CONFIG_ELF_CORE=y
+# CONFIG_COMPAT_BRK is not set
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
-CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_HAVE_KPROBES is not set
+# CONFIG_HAVE_KRETPROBES is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
-# CONFIG_SLOB is not set
-
-#
-# Loadable module support
-#
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
@@ -230,12 +260,10 @@ CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_KMOD=y
 CONFIG_STOP_MACHINE=y
-
-#
-# Block layer
-#
 CONFIG_BLOCK=y
 # CONFIG_BLK_DEV_IO_TRACE is not set
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLOCK_COMPAT=y
 
 #
 # IO Schedulers
@@ -249,22 +277,19 @@ CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="anticipatory"
+CONFIG_CLASSIC_RCU=y
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
 #
 CONFIG_HW_HAS_PCI=y
 CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCI_LEGACY is not set
 CONFIG_MMU=y
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
+CONFIG_ZONE_DMA32=y
 # CONFIG_PCCARD is not set
-
-#
-# PCI Hotplug Support
-#
 # CONFIG_HOTPLUG_PCI is not set
 
 #
@@ -272,7 +297,6 @@ CONFIG_MMU=y
 #
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
-# CONFIG_BUILD_ELF64 is not set
 CONFIG_MIPS32_COMPAT=y
 CONFIG_COMPAT=y
 CONFIG_SYSVIPC_COMPAT=y
@@ -286,7 +310,6 @@ CONFIG_BINFMT_ELF32=y
 CONFIG_PM=y
 # CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
-# CONFIG_PM_SYSFS_DEPRECATED is not set
 
 #
 # Networking
@@ -296,7 +319,6 @@ CONFIG_NET=y
 #
 # Networking options
 #
-# CONFIG_NETDEBUG is not set
 CONFIG_PACKET=y
 CONFIG_PACKET_MMAP=y
 CONFIG_UNIX=y
@@ -304,6 +326,7 @@ CONFIG_XFRM=y
 CONFIG_XFRM_USER=m
 # CONFIG_XFRM_SUB_POLICY is not set
 CONFIG_XFRM_MIGRATE=y
+# CONFIG_XFRM_STATISTICS is not set
 CONFIG_NET_KEY=y
 CONFIG_NET_KEY_MIGRATE=y
 CONFIG_INET=y
@@ -326,6 +349,7 @@ CONFIG_IP_PNP_BOOTP=y
 CONFIG_INET_XFRM_MODE_TRANSPORT=m
 CONFIG_INET_XFRM_MODE_TUNNEL=m
 CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=m
 CONFIG_INET_DIAG=y
 CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
@@ -333,24 +357,15 @@ CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 CONFIG_TCP_MD5SIG=y
 # CONFIG_IPV6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
 CONFIG_NETWORK_SECMARK=y
 # CONFIG_NETFILTER is not set
-
-#
-# DCCP Configuration (EXPERIMENTAL)
-#
 # CONFIG_IP_DCCP is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-
-#
-# TIPC Configuration (EXPERIMENTAL)
-#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
@@ -363,26 +378,52 @@ CONFIG_NETWORK_SECMARK=y
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
 # CONFIG_NET_SCHED is not set
+CONFIG_NET_SCH_FIFO=y
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
 CONFIG_IEEE80211=m
 # CONFIG_IEEE80211_DEBUG is not set
 CONFIG_IEEE80211_CRYPT_WEP=m
 CONFIG_IEEE80211_CRYPT_CCMP=m
-CONFIG_IEEE80211_SOFTMAC=m
-# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
-CONFIG_WIRELESS_EXT=y
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_RFKILL=m
+# CONFIG_NET_9P is not set
 
 #
 # Device Drivers
@@ -391,34 +432,15 @@ CONFIG_WIRELESS_EXT=y
 #
 # Generic Driver Options
 #
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 CONFIG_FW_LOADER=m
 # CONFIG_SYS_HYPERVISOR is not set
-
-#
-# Connector - unified userspace <-> kernelspace linker
-#
 CONFIG_CONNECTOR=m
-
-#
-# Memory Technology Devices (MTD)
-#
 # CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
 # CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNPACPI is not set
-
-#
-# Block devices
-#
+CONFIG_BLK_DEV=y
 # CONFIG_BLK_CPQ_DA is not set
 # CONFIG_BLK_CPQ_CISS_DA is not set
 # CONFIG_BLK_DEV_DAC960 is not set
@@ -427,49 +449,77 @@ CONFIG_CONNECTOR=m
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=9220
-CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
-CONFIG_BLK_DEV_INITRD=y
+# CONFIG_BLK_DEV_XIP is not set
 CONFIG_CDROM_PKTCDVD=m
 CONFIG_CDROM_PKTCDVD_BUFFERS=8
 # CONFIG_CDROM_PKTCDVD_WCACHE is not set
 CONFIG_ATA_OVER_ETH=m
-
-#
-# Misc devices
-#
+CONFIG_MISC_DEVICES=y
+# CONFIG_PHANTOM is not set
+# CONFIG_EEPROM_93CX6 is not set
 CONFIG_SGI_IOC4=m
 # CONFIG_TIFM_CORE is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
+# CONFIG_ENCLOSURE_SERVICES is not set
+CONFIG_HAVE_IDE=y
 CONFIG_IDE=y
 CONFIG_IDE_MAX_HWIFS=4
 CONFIG_BLK_DEV_IDE=y
 
 #
-# Please see Documentation/ide.txt for help/info on IDE drives
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
 #
 # CONFIG_BLK_DEV_IDE_SATA is not set
 CONFIG_BLK_DEV_IDEDISK=y
 # CONFIG_IDEDISK_MULTI_MODE is not set
 CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
 CONFIG_BLK_DEV_IDETAPE=y
 CONFIG_BLK_DEV_IDEFLOPPY=y
 # CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
 
 #
 # IDE chipset support/bugfixes
 #
-CONFIG_IDE_GENERIC=y
-# CONFIG_BLK_DEV_IDEPCI is not set
+# CONFIG_IDE_GENERIC is not set
+# CONFIG_BLK_DEV_PLATFORM is not set
+
+#
+# PCI IDE chipsets support
+#
+# CONFIG_BLK_DEV_GENERIC is not set
+# CONFIG_BLK_DEV_OPTI621 is not set
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_JMICRON is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_IT8213 is not set
+# CONFIG_BLK_DEV_IT821X is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_BLK_DEV_TC86C001 is not set
 CONFIG_BLK_DEV_IDE_SWARM=y
-# CONFIG_IDE_ARM is not set
 # CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_IDEDMA_AUTO is not set
+# CONFIG_BLK_DEV_HD_ONLY is not set
 # CONFIG_BLK_DEV_HD is not set
 
 #
@@ -477,89 +527,68 @@ CONFIG_BLK_DEV_IDE_SWARM=y
 #
 CONFIG_RAID_ATTRS=m
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
 # CONFIG_SCSI_NETLINK is not set
-
-#
-# Serial ATA (prod) and Parallel ATA (experimental) drivers
-#
 # CONFIG_ATA is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
 # CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
 # CONFIG_FUSION is not set
 
 #
 # IEEE 1394 (FireWire) support
 #
+# CONFIG_FIREWIRE is not set
 # CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
 # CONFIG_I2O is not set
-
-#
-# Network device support
-#
 CONFIG_NETDEVICES=y
+CONFIG_NETDEVICES_MULTIQUEUE=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
+CONFIG_MACVLAN=m
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
+# CONFIG_VETH is not set
 # CONFIG_ARCNET is not set
-
-#
-# PHY device support
-#
-CONFIG_PHYLIB=m
+CONFIG_PHYLIB=y
 
 #
 # MII PHY device drivers
 #
-CONFIG_MARVELL_PHY=m
-CONFIG_DAVICOM_PHY=m
-CONFIG_QSEMI_PHY=m
-CONFIG_LXT_PHY=m
-CONFIG_CICADA_PHY=m
-CONFIG_VITESSE_PHY=m
-CONFIG_SMSC_PHY=m
-# CONFIG_BROADCOM_PHY is not set
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+CONFIG_BROADCOM_PHY=y
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
 # CONFIG_FIXED_PHY is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
+# CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
+# CONFIG_AX88796 is not set
 # CONFIG_HAPPYMEAL is not set
 # CONFIG_SUNGEM is not set
 # CONFIG_CASSINI is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_DM9000 is not set
-
-#
-# Tulip family network device support
-#
 # CONFIG_NET_TULIP is not set
 # CONFIG_HP100 is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
 # CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
+# CONFIG_B44 is not set
+CONFIG_NETDEV_1000=y
 # CONFIG_ACENIC is not set
 # CONFIG_DL2K is not set
 # CONFIG_E1000 is not set
+# CONFIG_E1000E is not set
+# CONFIG_E1000E_ENABLED is not set
+# CONFIG_IP1000 is not set
+# CONFIG_IGB is not set
 # CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
@@ -568,53 +597,70 @@ CONFIG_SB1250_MAC=y
 # CONFIG_SIS190 is not set
 # CONFIG_SKGE is not set
 # CONFIG_SKY2 is not set
-# CONFIG_SK98LIN is not set
+# CONFIG_VIA_VELOCITY is not set
 # CONFIG_TIGON3 is not set
 # CONFIG_BNX2 is not set
-CONFIG_QLA3XXX=m
+# CONFIG_QLA3XXX is not set
 # CONFIG_ATL1 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
+CONFIG_NETDEV_10000=y
 # CONFIG_CHELSIO_T1 is not set
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
+# CONFIG_IXGBE is not set
 # CONFIG_IXGB is not set
 # CONFIG_S2IO is not set
 # CONFIG_MYRI10GE is not set
-CONFIG_NETXEN_NIC=m
-
-#
-# Token Ring devices
-#
+# CONFIG_NETXEN_NIC is not set
+# CONFIG_NIU is not set
+# CONFIG_MLX4_CORE is not set
+# CONFIG_TEHUTI is not set
+# CONFIG_BNX2X is not set
 # CONFIG_TR is not set
 
 #
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
+# Wireless LAN
 #
+# CONFIG_WLAN_PRE80211 is not set
+CONFIG_WLAN_80211=y
+# CONFIG_IPW2100 is not set
+# CONFIG_IPW2200 is not set
+# CONFIG_LIBERTAS is not set
+# CONFIG_HERMES is not set
+# CONFIG_ATMEL is not set
+# CONFIG_PRISM54 is not set
+# CONFIG_USB_ZD1201 is not set
+# CONFIG_USB_NET_RNDIS_WLAN is not set
+# CONFIG_RTL8180 is not set
+# CONFIG_RTL8187 is not set
+# CONFIG_ADM8211 is not set
+# CONFIG_P54_COMMON is not set
+# CONFIG_ATH5K is not set
+# CONFIG_IWLCORE is not set
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWL4965 is not set
+# CONFIG_IWL3945 is not set
+# CONFIG_HOSTAP is not set
+# CONFIG_B43 is not set
+# CONFIG_B43LEGACY is not set
+# CONFIG_ZD1211RW is not set
+# CONFIG_RT2X00 is not set
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
 # CONFIG_WAN is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
 # CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
 # CONFIG_PHONE is not set
 
 #
@@ -637,24 +683,8 @@ CONFIG_SERIO_RAW=m
 # Character devices
 #
 # CONFIG_VT is not set
-CONFIG_SERIAL_NONSTANDARD=y
-# CONFIG_COMPUTONE is not set
-# CONFIG_ROCKETPORT is not set
-# CONFIG_CYCLADES is not set
-# CONFIG_DIGIEPCA is not set
-# CONFIG_MOXA_INTELLIO is not set
-# CONFIG_MOXA_SMARTIO is not set
-CONFIG_MOXA_SMARTIO_NEW=m
-# CONFIG_ISI is not set
-# CONFIG_SYNCLINKMP is not set
-# CONFIG_SYNCLINK_GT is not set
-# CONFIG_N_HDLC is not set
-# CONFIG_SPECIALIX is not set
-# CONFIG_SX is not set
-# CONFIG_RIO is not set
-# CONFIG_STALDRV is not set
-CONFIG_SERIAL_SB1250_DUART=y
-CONFIG_SERIAL_SB1250_DUART_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_NOZOMI is not set
 
 #
 # Serial drivers
@@ -664,37 +694,22 @@ CONFIG_SERIAL_SB1250_DUART_CONSOLE=y
 #
 # Non-8250 serial port support
 #
+CONFIG_SERIAL_SB1250_DUART=y
+CONFIG_SERIAL_SB1250_DUART_CONSOLE=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=256
-
-#
-# IPMI
-#
 # CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
 # CONFIG_HW_RANDOM is not set
 # CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
-# CONFIG_DRM is not set
 # CONFIG_RAW_DRIVER is not set
-
-#
-# TPM devices
-#
 # CONFIG_TCG_TPM is not set
-
-#
-# I2C support
-#
+CONFIG_DEVPORT=y
 # CONFIG_I2C is not set
 
 #
@@ -702,109 +717,139 @@ CONFIG_LEGACY_PTY_COUNT=256
 #
 # CONFIG_SPI is not set
 # CONFIG_SPI_MASTER is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
 
 #
-# Dallas's 1-wire bus
+# Sonics Silicon Backplane
 #
-# CONFIG_W1 is not set
+CONFIG_SSB_POSSIBLE=y
+# CONFIG_SSB is not set
 
 #
-# Hardware Monitoring support
+# Multifunction device drivers
 #
-# CONFIG_HWMON is not set
-# CONFIG_HWMON_VID is not set
+# CONFIG_MFD_SM501 is not set
 
 #
 # Multimedia devices
 #
 # CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
+# CONFIG_DVB_CORE is not set
+# CONFIG_DAB is not set
 
 #
 # Graphics support
 #
-# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_DRM is not set
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
 # CONFIG_FB is not set
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
-# Sound
+# Display device support
 #
-# CONFIG_SOUND is not set
+# CONFIG_DISPLAY_SUPPORT is not set
 
 #
-# USB support
+# Sound
 #
+# CONFIG_SOUND is not set
+CONFIG_USB_SUPPORT=y
 CONFIG_USB_ARCH_HAS_HCD=y
 CONFIG_USB_ARCH_HAS_OHCI=y
 CONFIG_USB_ARCH_HAS_EHCI=y
-# CONFIG_USB is not set
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
 
 #
-# USB Gadget Support
+# Miscellaneous USB options
 #
-# CONFIG_USB_GADGET is not set
+CONFIG_USB_DEVICEFS=y
+CONFIG_USB_DEVICE_CLASS=y
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_PERSIST is not set
+# CONFIG_USB_OTG is not set
 
 #
-# MMC/SD Card support
+# USB Host Controller Drivers
 #
-# CONFIG_MMC is not set
+# CONFIG_USB_EHCI_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_UHCI_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
 
 #
-# LED devices
+# USB Device Class drivers
 #
-# CONFIG_NEW_LEDS is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
 
 #
-# LED drivers
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
 #
 
 #
-# LED Triggers
+# may also be needed; see USB_STORAGE Help for more information
 #
+# CONFIG_USB_LIBUSUAL is not set
 
 #
-# InfiniBand support
+# USB Imaging devices
 #
-# CONFIG_INFINIBAND is not set
+# CONFIG_USB_MDC800 is not set
+CONFIG_USB_MON=y
 
 #
-# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+# USB port drivers
 #
+# CONFIG_USB_SERIAL is not set
 
 #
-# Real Time Clock
+# USB Miscellaneous drivers
 #
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGET is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_GADGET is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_INFINIBAND is not set
+CONFIG_RTC_LIB=y
 # CONFIG_RTC_CLASS is not set
 
 #
-# DMA Engine support
-#
-# CONFIG_DMA_ENGINE is not set
-
-#
-# DMA Clients
-#
-
-#
-# DMA Devices
-#
-
-#
-# Auxiliary Display support
-#
-
-#
-# Virtualization
+# Userspace I/O
 #
+# CONFIG_UIO is not set
 
 #
 # File systems
@@ -823,15 +868,14 @@ CONFIG_FS_POSIX_ACL=y
 # CONFIG_XFS_FS is not set
 # CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
+CONFIG_DNOTIFY=y
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
-CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
 
 #
 # CD-ROM/DVD Filesystems
@@ -853,9 +897,9 @@ CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-# CONFIG_TMPFS is not set
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
 # CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
 CONFIG_CONFIGFS_FS=m
 
 #
@@ -871,14 +915,13 @@ CONFIG_CONFIGFS_FS=m
 # CONFIG_EFS_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
+CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
 # CONFIG_NFS_V3_ACL is not set
@@ -890,6 +933,7 @@ CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
+# CONFIG_SUNRPC_BIND34 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
@@ -897,45 +941,29 @@ CONFIG_SUNRPC=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
 # CONFIG_NLS is not set
-
-#
-# Distributed Lock Manager
-#
 CONFIG_DLM=m
-CONFIG_DLM_TCP=y
-# CONFIG_DLM_SCTP is not set
 # CONFIG_DLM_DEBUG is not set
 
 #
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
 # Kernel hacking
 #
 CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 # CONFIG_DEBUG_FS is not set
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_LOG_BUF_SHIFT=15
-CONFIG_CROSSCOMPILE=y
+# CONFIG_SAMPLES is not set
 CONFIG_CMDLINE=""
 CONFIG_SYS_SUPPORTS_KGDB=y
 # CONFIG_SB1XXX_CORELIS is not set
@@ -946,13 +974,12 @@ CONFIG_SYS_SUPPORTS_KGDB=y
 CONFIG_KEYS=y
 CONFIG_KEYS_DEBUG_PROC_KEYS=y
 # CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=y
 CONFIG_CRYPTO_MANAGER=y
 CONFIG_CRYPTO_HMAC=y
@@ -970,6 +997,11 @@ CONFIG_CRYPTO_ECB=m
 CONFIG_CRYPTO_CBC=m
 CONFIG_CRYPTO_PCBC=m
 CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_CRYPTD=m
 CONFIG_CRYPTO_DES=m
 CONFIG_CRYPTO_FCRYPT=m
 CONFIG_CRYPTO_BLOWFISH=m
@@ -983,15 +1015,16 @@ CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_ARC4=m
 CONFIG_CRYPTO_KHAZAD=m
 CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SALSA20=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=m
 CONFIG_CRYPTO_CAMELLIA=m
 # CONFIG_CRYPTO_TEST is not set
-
-#
-# Hardware crypto devices
-#
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_LZO=m
+# CONFIG_CRYPTO_HW is not set
 
 #
 # Library routines
@@ -999,10 +1032,15 @@ CONFIG_CRYPTO_CAMELLIA=m
 CONFIG_BITREVERSE=y
 # CONFIG_CRC_CCITT is not set
 CONFIG_CRC16=m
+# CONFIG_CRC_ITU_T is not set
 CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
 CONFIG_LIBCRC32C=m
 CONFIG_ZLIB_INFLATE=m
 CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
 CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y

From ralf@linux-mips.org Sat May  3 07:44:28 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 07:44:31 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:30430 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28575714AbYECGo2 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 3 May 2008 07:44:28 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m436iO8I004096;
	Sat, 3 May 2008 07:44:25 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m436iOZs004088;
	Sat, 3 May 2008 07:44:24 +0100
Date:	Sat, 3 May 2008 07:44:24 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Daniel Jacobowitz <drow@false.org>, linux-mips@linux-mips.org
Subject: Re: [PATCH] Bring the SWARM defconfig up to date
Message-ID: <20080503064424.GA15574@linux-mips.org>
References: <Pine.LNX.4.55.0805030008280.12296@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.55.0805030008280.12296@cliff.in.clinika.pl>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19084
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 707
Lines: 15

On Sat, May 03, 2008 at 12:48:45AM +0100, Maciej W. Rozycki wrote:

>  The SWARM defconfig file has not been regenerated for over a year now.
> Here is a patch to bring the file up to date.  Additionally some important
> and sometimes confusing changes happened meanwhile.  Here is the list of 
> notable corresponding updates to the configuration:
> 
> 1. CPU_SB1_PASS_2_2 is now selected rather than CPU_SB1_PASS_1.  The
>    latter requires a non-standard -msb1-pass1-workarounds option to be
>    supported by GCC and I am told is quite rare anyway.

Farely rare is a nice way to express it.  The option exists in MV's
gcc 3.0 and as you know gcc 3.0 is no longer suitable to build a kernel ...

  Ralf

From kevink@mips.com Sat May  3 15:24:01 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 15:24:04 +0100 (BST)
Received: from mx.mips.com ([63.167.95.198]:34986 "EHLO dns0.mips.com")
	by ftp.linux-mips.org with ESMTP id S28586771AbYECOYB (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 15:24:01 +0100
Received: from mercury.mips.com (mercury [192.168.64.101])
	by dns0.mips.com (8.12.11/8.12.11) with ESMTP id m43EMjQ9024475
	for <linux-mips@linux-mips.org>; Sat, 3 May 2008 07:22:46 -0700 (PDT)
Received: from [192.168.236.12] (cthulhu [192.168.236.12])
	by mercury.mips.com (8.13.5/8.13.5) with ESMTP id m43ENgX3029794
	for <linux-mips@linux-mips.org>; Sat, 3 May 2008 07:23:44 -0700 (PDT)
Message-ID: <481C756E.4070806@mips.com>
Date:	Sat, 03 May 2008 16:23:42 +0200
From:	"Kevin D. Kissell" <kevink@mips.com>
User-Agent: Thunderbird 2.0.0.12 (X11/20080226)
MIME-Version: 1.0
To:	Linux MIPS Org <linux-mips@linux-mips.org>
Subject: Patch to APRP ELF Loader
Content-Type: multipart/mixed;
 boundary="------------000005000500030307010207"
Return-Path: <kevink@mips.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19085
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: kevink@mips.com
Precedence: bulk
X-list: linux-mips
Content-Length: 652
Lines: 20

This is a multi-part message in MIME format.
--------------000005000500030307010207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Please find attached a patch to the APRP ELF loader (vpe.c)
for the MIPS 34K which provides several requested/needed
fixes and enhancements, most notably in allowing large
stripped ELF binaries to be launched on the RP.

	Regards,

	Kevin K.

--------------000005000500030307010207
Content-Type: text/x-patch;
 name="0001-Rewrite-of-APRP-VPE-ELF-Loader.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0001-Rewrite-of-APRP-VPE-ELF-Loader.patch"

From a6b323949e3ca692c5c32003ee62601cb3bd297e Mon Sep 17 00:00:00 2001
From: Kevin D. Kissell <kevink@mips.com>
Date: Sat, 3 May 2008 16:03:51 +0200
Subject: [PATCH] Rewrite of APRP VPE ELF Loader
Content-Length: 20482
Lines: 698

Re-implemented as state machine driven by writes to vpe pseudo-device.
Load-time linking of relocatable binaries has same functionality and
restrictions as before, but for pre-linked ELF binaries:
- Program size restrictions due to intermediate copy in vmalloc buffer
  are eliminated.  Program segments are copied directly from input
  stream to target memory.
- Programs no longer need to be linked to exactly the top of memory
  known to the kernel. They need only be linked to an address that
  is no less than the kernel's memory size limit (max_low_pfn).
- Programs may be stripped of the __start symbol, as the ELF header
  entry point is used if __start is unavailable.  "vpe_shared" symbol
  must be retained if the rtlx I/O services are to be used.
- Protection added against binaries linked to addresses that overlay
  kernel or user addresses.
---
 arch/mips/kernel/vpe.c |  510 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 453 insertions(+), 57 deletions(-)

diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 4515f1e..49471f2 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -77,13 +77,10 @@ static const int minor = 1;	/* fixed for now  */
 static int kspd_events_reqd = 0;
 #endif
 
-/* grab the likely amount of memory we will need. */
-#ifdef CONFIG_MIPS_VPE_LOADER_TOM
-#define P_SIZE (2 * 1024 * 1024)
-#else
-/* add an overhead to the max kmalloc size for non-striped symbols/etc */
+/*
+ * Size of private kernel buffer for ELF headers and sections
+ */
 #define P_SIZE (256 * 1024)
-#endif
 
 extern unsigned long physical_memsize;
 
@@ -103,6 +100,16 @@ enum tc_state {
 	TC_STATE_DYNAMIC
 };
 
+enum load_state {
+	LOAD_STATE_EHDR,
+	LOAD_STATE_PHDR,
+	LOAD_STATE_SHDR,
+	LOAD_STATE_PIMAGE,
+	LOAD_STATE_TRAILER,
+	LOAD_STATE_DONE,
+	LOAD_STATE_ERROR
+};
+
 struct vpe {
 	enum vpe_state state;
 
@@ -110,10 +117,25 @@ struct vpe {
 	int minor;
 
 	/* elfloader stuff */
+	unsigned long offset; /* File offset into input stream */
 	void *load_addr;
-	unsigned long len;
+	unsigned long copied;
 	char *pbuffer;
-	unsigned long plen;
+	unsigned long pbsize;
+	/* Program loading state */
+	enum load_state l_state;
+	Elf_Ehdr *l_ehdr;
+	struct elf_phdr *l_phdr;
+	unsigned int l_phlen;
+	Elf_Shdr *l_shdr;
+	unsigned int l_shlen;
+	int *l_phsort;	/* Sorted index list of program headers */
+	int l_segoff;	/* Offset into current program segment */
+	int l_cur_seg;	/* Indirect index of segment currently being loaded */
+	unsigned int l_progminad;
+	unsigned int l_progmaxad;
+	unsigned int l_trailer;
+
 	unsigned int uid, gid;
 	char cwd[VPE_PATH_MAX];
 
@@ -132,6 +154,7 @@ struct vpe {
 	struct list_head notify;
 
 	unsigned int ntcs;
+
 };
 
 struct tc {
@@ -261,22 +284,37 @@ void dump_mtregs(void)
 }
 
 /* Find some VPE program space  */
-static void *alloc_progmem(unsigned long len)
+static void *alloc_progmem(void *requested, unsigned long len)
 {
 	void *addr;
 
 #ifdef CONFIG_MIPS_VPE_LOADER_TOM
 	/*
 	 * This means you must tell Linux to use less memory than you
-	 * physically have, for example by passing a mem= boot argument.
+	 * physically have, for example by passing a memsize= boot argument.
 	 */
-	addr = pfn_to_kaddr(max_pfn);
-	memset(addr, 0, len);
+	addr = pfn_to_kaddr(max_low_pfn);
+	if (requested != 0) {
+		if (requested >= addr)
+			addr = requested;
+		else
+			addr = 0;
+	}
+	if (addr != 0)
+		memset(addr, 0, len);
 #else
-	/* simple grab some mem for now */
-	addr = kzalloc(len, GFP_KERNEL);
+	if (requested != 0) {
+		/* If we have a target in mind, grab a 2x slice and hope... */
+		addr = kzalloc(len*2, GFP_KERNEL);
+		if ((requested >= addr) && (requested < (addr + len)))
+			addr = requested;
+		else
+			addr = 0;
+	} else {
+		/* simply grab some mem for now */
+		addr = kzalloc(len, GFP_KERNEL);
+	}
 #endif
-
 	return addr;
 }
 
@@ -841,13 +879,12 @@ static int vpe_elfload(struct vpe * v)
 	memset(&mod, 0, sizeof(struct module));
 	strcpy(mod.name, "VPE loader");
 
-	hdr = (Elf_Ehdr *) v->pbuffer;
-	len = v->plen;
+	hdr = v->l_ehdr;
+	len = v->pbsize;
 
 	/* Sanity checks against insmoding binaries or wrong arch,
 	   weird elf version */
-	if (memcmp(hdr->e_ident, ELFMAG, 4) != 0
-	    || (hdr->e_type != ET_REL && hdr->e_type != ET_EXEC)
+	if ((hdr->e_type != ET_REL && hdr->e_type != ET_EXEC)
 	    || !elf_check_arch(hdr)
 	    || hdr->e_shentsize != sizeof(*sechdrs)) {
 		printk(KERN_WARNING
@@ -859,9 +896,8 @@ static int vpe_elfload(struct vpe * v)
 	if (hdr->e_type == ET_REL)
 		relocate = 1;
 
-	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr)) {
-		printk(KERN_ERR "VPE loader: program length %u truncated\n",
-		       len);
+	if (len < v->l_phlen + v->l_shlen) {
+		printk(KERN_ERR "VPE loader: Headers exceed %u bytes\n", len);
 
 		return -ENOEXEC;
 	}
@@ -895,13 +931,17 @@ static int vpe_elfload(struct vpe * v)
 			}
 		}
 		layout_sections(&mod, hdr, sechdrs, secstrings);
+		/*
+		 * Non-relocatable loads should have already done their
+		 * allocates, based on program header table.
+		 */
+		v->load_addr = alloc_progmem(NULL, mod.core_size);
 	}
 
-	v->load_addr = alloc_progmem(mod.core_size);
 	if (!v->load_addr)
 		return -ENOMEM;
 
-	pr_info("VPE loader: loading to %p\n", v->load_addr);
+	printk(KERN_INFO "VPE loader: loaded/loading to %p\n", v->load_addr);
 
 	if (relocate) {
 		for (i = 0; i < hdr->e_shnum; i++) {
@@ -949,18 +989,10 @@ static int vpe_elfload(struct vpe * v)
  				return err;
 
   		}
-  	} else {
-		struct elf_phdr *phdr = (struct elf_phdr *) ((char *)hdr + hdr->e_phoff);
-
-		for (i = 0; i < hdr->e_phnum; i++) {
-		    if (phdr->p_type == PT_LOAD) {
-			memcpy((void *)phdr->p_paddr, 
-				(char *)hdr + phdr->p_offset, phdr->p_filesz);
-			memset((void *)phdr->p_paddr + phdr->p_filesz, 
-				0, phdr->p_memsz - phdr->p_filesz);
-		    }
-		    phdr++;
-		}
+	} else {
+		/*
+		 * Program image is already in memory.
+		 */
 
 		for (i = 0; i < hdr->e_shnum; i++) {
  			/* Internal symbols and strings. */
@@ -978,7 +1010,7 @@ static int vpe_elfload(struct vpe * v)
 
 	/* make sure it's physically written out */
 	flush_icache_range((unsigned long)v->load_addr,
-			   (unsigned long)v->load_addr + v->len);
+			   (unsigned long)v->load_addr + v->copied);
 
 	if ((find_vpe_symbols(v, sechdrs, symindex, strtab, &mod)) < 0) {
 		if (v->__start == 0) {
@@ -993,7 +1025,7 @@ static int vpe_elfload(struct vpe * v)
 			       " Unable to use AMVP (AP/SP) facilities.\n");
 	}
 
-	printk(" elf loaded\n");
+	printk(KERN_INFO "APRP VPE loader: elf loaded\n");
 	return 0;
 }
 
@@ -1058,6 +1090,10 @@ static int vpe_open(struct inode *inode, struct file *filp)
 		return -ENODEV;
 	}
 
+	/*
+	 * This treats the tclimit command line configuration input
+	 * as a minor device indication, which is probably unwholesome.
+	 */
 	if ((v = get_vpe(tclimit)) == NULL) {
 		printk(KERN_WARNING "VPE loader: unable to get vpe\n");
 		return -ENODEV;
@@ -1077,9 +1113,14 @@ static int vpe_open(struct inode *inode, struct file *filp)
 
 	/* this of-course trashes what was there before... */
 	v->pbuffer = vmalloc(P_SIZE);
-	v->plen = P_SIZE;
+	v->pbsize = P_SIZE;
 	v->load_addr = NULL;
-	v->len = 0;
+	v->copied = 0;
+	v->offset = 0;
+	v->l_state = LOAD_STATE_EHDR;
+	v->l_ehdr = NULL;
+	v->l_phdr = NULL;
+	v->l_shdr = NULL;
 
 	v->uid = filp->f_uid;
 	v->gid = filp->f_gid;
@@ -1106,23 +1147,26 @@ static int vpe_open(struct inode *inode, struct file *filp)
 static int vpe_release(struct inode *inode, struct file *filp)
 {
 	struct vpe *v;
-	Elf_Ehdr *hdr;
 	int ret = 0;
 
 	v = get_vpe(tclimit);
 	if (v == NULL)
 		return -ENODEV;
 
-	hdr = (Elf_Ehdr *) v->pbuffer;
-	if (memcmp(hdr->e_ident, ELFMAG, 4) == 0) {
-		if (vpe_elfload(v) >= 0) {
-			vpe_run(v);
-		} else {
- 			printk(KERN_WARNING "VPE loader: ELF load failed.\n");
-			ret = -ENOEXEC;
-		}
+	/*
+	 * If image load had no errors, massage program/section tables
+	 * to reflect movement of program/section data into VPE program
+	 * memory.
+	 */
+	if (v->l_state != LOAD_STATE_DONE) {
+		printk(KERN_WARNING "VPE Release after incomplete load\n");
+		return(-ENOEXEC);
+	}
+
+	if (vpe_elfload(v) >= 0) {
+		vpe_run(v);
 	} else {
- 		printk(KERN_WARNING "VPE loader: only elf files are supported\n");
+		printk(KERN_WARNING "VPE loader: ELF load failed.\n");
 		ret = -ENOEXEC;
 	}
 
@@ -1137,15 +1181,62 @@ static int vpe_release(struct inode *inode, struct file *filp)
 	// cleanup any temp buffers
 	if (v->pbuffer)
 		vfree(v->pbuffer);
-	v->plen = 0;
+	v->pbsize = 0;
 	return ret;
 }
 
+/*
+ * A sort of insertion sort to generate list of program header indices
+ * in order of their file offsets.
+ */
+
+static void indexort(struct elf_phdr *phdr, int nph, int *index)
+{
+	int i, j, t;
+	unsigned int toff;
+
+	/* Create initial mapping */
+	for (i = 0; i < nph; i++) index[i] = i;
+	/* Do the indexed insert sort */
+	for (i = 1; i < nph; i++) {
+		j = i;
+		t = index[j];
+		toff = phdr[t].p_offset;
+		while ((j > 0) && (phdr[index[j-1]].p_offset > toff)) {
+			index[j] = index[j-1];
+			j--;
+		}
+		index[j] = t;
+	}
+}
+
+
+/*
+ * This function has to convert the ELF file image being sequentially
+ * streamed to the pseudo-device into the binary image, symbol, and
+ * string information, which the ELF format allows to be in some degree
+ * of disorder.
+ *
+ * The ELF header and, if present, program header table, are copied into
+ * a temporary buffer.  Loadable program segments, if present, are copied
+ * into the RP program memory at the addresses specified by the program
+ * header table.
+ *
+ * Sections not specified by the program header table are loaded into
+ * memory following the program segments if they are "allocated", or
+ * into the temporary buffer if they are not. The section header
+ * table is loaded into the temporary buffer.???
+ */
+#define CURPHDR v->l_phdr[v->l_phsort[v->l_cur_seg]]
+
 static ssize_t vpe_write(struct file *file, const char __user * buffer,
 			 size_t count, loff_t * ppos)
 {
 	size_t ret = count;
 	struct vpe *v;
+	int tocopy, uncopied;
+	int i;
+	unsigned int progmemlen;
 
 	if (iminor(file->f_path.dentry->d_inode) != minor)
 		return -ENODEV;
@@ -1159,17 +1250,320 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
 		return -ENOMEM;
 	}
 
-	if ((count + v->len) > v->plen) {
+	if ((count + v->copied) > v->pbsize) {
 		printk(KERN_WARNING
 		       "VPE loader: elf size too big. Perhaps strip uneeded symbols\n");
 		return -ENOMEM;
 	}
 
-	count -= copy_from_user(v->pbuffer + v->len, buffer, count);
-	if (!count)
-		return -EFAULT;
+	while (count) {
+		switch (v->l_state) {
+		case LOAD_STATE_EHDR:
+			/* Loading ELF Header into scratch buffer */
+			tocopy = min((unsigned long)count,
+			    sizeof(Elf_Ehdr) - v->offset);
+			uncopied = copy_from_user(v->pbuffer + v->copied,
+			    buffer, tocopy);
+			count -= tocopy - uncopied;
+			v->copied += tocopy - uncopied;
+			v->offset += tocopy - uncopied;
+			buffer += tocopy - uncopied;
+			if (v->copied == sizeof(Elf_Ehdr)) {
+			    v->l_ehdr = (Elf_Ehdr *)v->pbuffer;
+			    if (memcmp(v->l_ehdr->e_ident, ELFMAG, 4) != 0) {
+				printk(KERN_WARNING "VPE loader: %s\n",
+					"non-ELF file image");
+				ret = -ENOEXEC;
+				v->l_state = LOAD_STATE_ERROR;
+				break;
+			    }
+			    if (v->l_ehdr->e_phoff != 0) {
+				v->l_phdr = (struct elf_phdr *)
+					(v->pbuffer + v->l_ehdr->e_phoff);
+				v->l_phlen = v->l_ehdr->e_phentsize
+					* v->l_ehdr->e_phnum;
+				v->l_state = LOAD_STATE_PHDR;
+				/*
+				 * Program headers generally indicate
+				 * linked executable with possibly
+				 * valid entry point.
+				 */
+				v->__start = v->l_ehdr->e_entry;
+			    } else  if (v->l_ehdr->e_shoff != 0) {
+				/*
+				 * No program headers, but a section
+				 * header table.  A relocatable binary.
+				 * We need to load the works into the
+				 * kernel temp buffer to compute the
+				 * RP program image.  That limits our
+				 * binary size, but at least we're no
+				 * worse off than the original APRP
+				 * prototype.
+				 */
+				v->l_shlen = v->l_ehdr->e_shentsize
+					* v->l_ehdr->e_shnum;
+				v->l_state = LOAD_STATE_SHDR;
+			    } else {
+				/*
+				 * If neither program nor section tables,
+				 * we don't know what to do.
+				 */
+				v->l_state = LOAD_STATE_ERROR;
+				return(-ENOEXEC);
+			    }
+			}
+			break;
+		case LOAD_STATE_PHDR:
+			/* Loading Program Headers into scratch */
+			tocopy = min((unsigned long)count,
+			    v->l_ehdr->e_phoff + v->l_phlen - v->copied);
+			uncopied = copy_from_user(v->pbuffer + v->copied,
+			    buffer, tocopy);
+			count -= tocopy - uncopied;
+			v->copied += tocopy - uncopied;
+			v->offset += tocopy - uncopied;
+			buffer += tocopy - uncopied;
+
+			if (v->copied == v->l_ehdr->e_phoff + v->l_phlen) {
+			    /*
+			     * It's legal for the program headers to be
+			     * out of order with respect to the file layout.
+			     * Generate a list of indices, sorted by file
+			     * offset.
+			     */
+			    v->l_phsort = kmalloc(v->l_ehdr->e_phnum
+				* sizeof(int), GFP_KERNEL);
+			    if (!v->l_phsort) {
+				/* Preposterous, but... */
+				return(-ENOMEM);
+			    }
+			    indexort(v->l_phdr, v->l_ehdr->e_phnum,
+				v->l_phsort);
+
+			    v->l_progminad = (unsigned int)-1;
+			    v->l_progmaxad = 0;
+			    progmemlen = 0;
+			    for (i = 0; i < v->l_ehdr->e_phnum; i++) {
+				if (v->l_phdr[v->l_phsort[i]].p_type
+				    == PT_LOAD) {
+				    /* Unstripped .reginfo sections are bad */
+				    if (v->l_phdr[v->l_phsort[i]].p_vaddr
+					< __UA_LIMIT) {
+					printk(KERN_WARNING "%s%s%s\n",
+					    "VPE loader: ",
+					    "User-mode p_vaddr, ",
+					    "skipping program segment,");
+					printk(KERN_WARNING "%s%s%s\n",
+					    "VPE loader: ",
+					    "strip .reginfo from binary ",
+					    "if necessary.");
+					continue;
+				    }
+				    if (v->l_phdr[v->l_phsort[i]].p_vaddr
+					< v->l_progminad) {
+					    v->l_progminad =
+					      v->l_phdr[v->l_phsort[i]].p_vaddr;
+				    }
+				    if ((v->l_phdr[v->l_phsort[i]].p_vaddr
+					+ v->l_phdr[v->l_phsort[i]].p_memsz)
+					> v->l_progmaxad) {
+					    v->l_progmaxad =
+					     v->l_phdr[v->l_phsort[i]].p_vaddr +
+					     v->l_phdr[v->l_phsort[i]].p_memsz;
+				    }
+				}
+			    }
+			    printk(KERN_INFO "APRP RP program 0x%x to 0x%x\n",
+				v->l_progminad, v->l_progmaxad);
+			    v->load_addr = alloc_progmem((void *)v->l_progminad,
+				v->l_progmaxad - v->l_progminad);
+			    if (!v->load_addr)
+				return -ENOMEM;
+			    if ((unsigned int)v->load_addr
+				> v->l_progminad) {
+				release_progmem(v->load_addr);
+				return(-ENOMEM);
+			    }
+			    /* Find first segment with loadable content */
+			    for (i = 0; i < v->l_ehdr->e_phnum; i++) {
+				if (v->l_phdr[v->l_phsort[i]].p_type
+				    == PT_LOAD) {
+				    if (v->l_phdr[v->l_phsort[i]].p_vaddr
+					< __UA_LIMIT) {
+					/* Skip userspace segments */
+					continue;
+				    }
+				    v->l_cur_seg = i;
+				    break;
+				}
+			    }
+			    if (i == v->l_ehdr->e_phnum) {
+				/* No loadable program segment?  Bogus file. */
+				printk(KERN_WARNING "Bad ELF file for APRP\n");
+				return(-ENOEXEC);
+			    }
+			    v->l_segoff = 0;
+			    v->l_state = LOAD_STATE_PIMAGE;
+			}
+			break;
+		case LOAD_STATE_PIMAGE:
+			/*
+			 * Skip through input stream until
+			 * first program segment. Would be
+			 * better to have loaded up to here
+			 * into the temp buffer, but for now
+			 * we simply rule out "interesting"
+			 * sections prior to the last program
+			 * segment in an executable file.
+			 */
+			if (v->offset < CURPHDR.p_offset) {
+			    uncopied = CURPHDR.p_offset - v->offset;
+			    if (uncopied > count)
+				uncopied = count;
+			    count -= uncopied;
+			    buffer += uncopied;
+			    v->offset += uncopied;
+			    /* Go back through the "while" */
+			    break;
+			}
+			/*
+			 * Having dispensed with any unlikely fluff,
+			 * copy from user I/O buffer to program segment.
+			 */
+			tocopy = min(count, CURPHDR.p_filesz - v->l_segoff);
+
+			/* Loading image into RP memory */
+			uncopied = copy_from_user((char *)CURPHDR.p_vaddr
+			    + v->l_segoff, buffer, tocopy);
+			count -= tocopy - uncopied;
+			v->offset += tocopy - uncopied;
+			v->l_segoff += tocopy - uncopied;
+			buffer += tocopy - uncopied;
+			if (v->l_segoff >= CURPHDR.p_filesz) {
+			    /* Finished current segment load */
+			    /* Zero out non-file-sourced image */
+			    uncopied = CURPHDR.p_memsz - CURPHDR.p_filesz;
+			    if (uncopied > 0) {
+				memset((char *)CURPHDR.p_vaddr + v->l_segoff,
+				    0, uncopied);
+			    }
+			    /* Advance to next segment */
+			    for (i = v->l_cur_seg + 1;
+				i < v->l_ehdr->e_phnum; i++) {
+				if (v->l_phdr[v->l_phsort[i]].p_type
+				    == PT_LOAD) {
+				    if (v->l_phdr[v->l_phsort[i]].p_vaddr
+					< __UA_LIMIT) {
+					/* Skip userspace segments */
+					continue;
+				    }
+				    v->l_cur_seg = i;
+				    break;
+				}
+			    }
+			    /* If none left, prepare to load section headers */
+			    if (i == v->l_ehdr->e_phnum) {
+				if (v->l_ehdr->e_shoff != 0) {
+				/* Copy to where we left off in temp buffer */
+				    v->l_shlen = v->l_ehdr->e_shentsize
+					* v->l_ehdr->e_shnum;
+				    v->l_state = LOAD_STATE_SHDR;
+				    break;
+				}
+			    } else {
+				/* reset offset for new program segment */
+				v->l_segoff = 0;
+			    }
+			}
+			break;
+		case LOAD_STATE_SHDR:
+			/*
+			 * Read stream into private buffer up
+			 * through and including the section header
+			 * table.
+			 */
 
-	v->len += count;
+			tocopy = min((unsigned long)count,
+			    v->l_ehdr->e_shoff + v->l_shlen - v->offset);
+			if (tocopy) {
+			    uncopied = copy_from_user(v->pbuffer + v->copied,
+			    buffer, tocopy);
+			    count -= tocopy - uncopied;
+			    v->copied += tocopy - uncopied;
+			    v->offset += tocopy - uncopied;
+			    buffer += tocopy - uncopied;
+			}
+			/* Finished? */
+			if (v->offset == v->l_ehdr->e_shoff + v->l_shlen) {
+			    unsigned int offset_delta = v->offset - v->copied;
+
+			    v->l_shdr = (Elf_Shdr *)(v->pbuffer
+				+ v->l_ehdr->e_shoff - offset_delta);
+			    /*
+			     * Check for sections after the section table,
+			     * which for gcc MIPS binaries includes
+			     * the symbol table. Do any other processing
+			     * that requires value within stream, and
+			     * normalize offsets to be relative to
+			     * the header-only layout of temp buffer.
+			     */
+
+			    /* Assume no trailer until we detect one */
+			    v->l_trailer = 0;
+			    v->l_state = LOAD_STATE_DONE;
+			    for (i = 0; i < v->l_ehdr->e_shnum; i++) {
+				   if (v->l_shdr[i].sh_offset
+					> v->l_ehdr->e_shoff) {
+					v->l_state = LOAD_STATE_TRAILER;
+					/* Track trailing data length */
+					if (v->l_trailer
+					    < (v->l_shdr[i].sh_offset
+					    + v->l_shdr[i].sh_size)
+					    - (v->l_ehdr->e_shoff
+					    + v->l_shlen)) {
+						v->l_trailer =
+						    (v->l_shdr[i].sh_offset
+						    + v->l_shdr[i].sh_size)
+						    - (v->l_ehdr->e_shoff
+						    + v->l_shlen);
+					}
+				    }
+				    /* Adjust section offset if necessary */
+				    v->l_shdr[i].sh_offset -= offset_delta;
+				}
+
+				/* Fix up offsets in ELF header */
+				v->l_ehdr->e_shoff = (unsigned int)v->l_shdr
+				    - (unsigned int)v->pbuffer;
+			}
+			break;
+		case LOAD_STATE_TRAILER:
+			/*
+			 * Symbol and string tables follow section headers
+			 * in gcc binaries for MIPS. Copy into temp buffer.
+			 */
+			if (v->l_trailer) {
+			    tocopy = min(count, v->l_trailer);
+			    uncopied = copy_from_user(v->pbuffer + v->copied,
+			    buffer, tocopy);
+			    count -= tocopy - uncopied;
+			    v->l_trailer -= tocopy - uncopied;
+			    v->copied += tocopy - uncopied;
+			    v->offset += tocopy - uncopied;
+			    buffer += tocopy - uncopied;
+			}
+			if (!v->l_trailer)
+			    v->l_state = LOAD_STATE_DONE;
+			break;
+		case LOAD_STATE_DONE:
+			if (count)
+				count = 0;
+			break;
+		case LOAD_STATE_ERROR:
+		default:
+			return(-EINVAL);
+		}
+	}
 	return ret;
 }
 
@@ -1204,7 +1598,9 @@ int vpe_start(vpe_handle vpe, unsigned long start)
 {
 	struct vpe *v = vpe;
 
-	v->__start = start;
+	/* Null start address means use value from ELF file */
+	if (start)
+		v->__start = start;
 	return vpe_run(v);
 }
 
-- 
1.5.3.3


--------------000005000500030307010207--

From anemo@mba.ocn.ne.jp Sat May  3 17:16:32 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 17:16:40 +0100 (BST)
Received: from mba.ocn.ne.jp ([122.1.235.107]:10441 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S28776308AbYECQPt (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 17:15:49 +0100
Received: from localhost (p2071-ipad306funabasi.chiba.ocn.ne.jp [123.217.172.71])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 30A21ADBC; Sun,  4 May 2008 01:15:41 +0900 (JST)
Date:	Sun, 04 May 2008 01:16:47 +0900 (JST)
Message-Id: <20080504.011647.93019265.anemo@mba.ocn.ne.jp>
To:	ralf@linux-mips.org
Cc:	tsbogend@alpha.franken.de, linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <20080502101113.GA24408@linux-mips.org>
References: <20080501163314.GA9955@alpha.franken.de>
	<20080502101113.GA24408@linux-mips.org>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19086
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
Content-Length: 1555
Lines: 47

On Fri, 2 May 2008 11:11:13 +0100, Ralf Baechle <ralf@linux-mips.org> wrote:
> It came as part of 39b8d5254246ac56342b72f812255c8f7a74dca9 which is a
> patch amalgated from several other patches.  Below is the original patch
> it came with.  I think the idea of the patch is valid but the idea needs a
> bit of mending.

Then how about this fix?

---------------------------------------------------------------------
Subject: [PATCH] Fix detection of kernel segment on 64-bit

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index cb8b0e2..7893bb3 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -78,6 +78,19 @@ void (*board_nmi_handler_setup)(void);
 void (*board_ejtag_handler_setup)(void);
 void (*board_bind_eic_interrupt)(int irq, int regset);
 
+static inline int kernel_unmapped_seg(void *addr)
+{
+	unsigned long a = (unsigned long)addr;
+
+#ifdef CONFIG_32BIT
+	/* KSEG0 or KSEG1 */
+	return (a & 0xc0000000) == KSEG0;
+#else
+	/* CKSEG0, CKSEG1 or XKPHYS  */
+	return ((a & 0xffffffffc0000000L) == CKSEG0) ||
+		((a & 0xc000000000000000L) == XKPHYS);
+#endif
+}
 
 static void show_raw_backtrace(unsigned long reg29)
 {
@@ -88,8 +101,7 @@ static void show_raw_backtrace(unsigned long reg29)
 #ifdef CONFIG_KALLSYMS
 	printk("\n");
 #endif
-#define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
-	if (IS_KVA01(sp)) {
+	if (kernel_unmapped_seg(sp)) {
 		while (!kstack_end(sp)) {
 			addr = *sp++;
 			if (__kernel_text_address(addr))

From ralf@linux-mips.org Sat May  3 18:39:46 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 18:39:53 +0100 (BST)
Received: from oss.sgi.com ([192.48.170.157]:35477 "EHLO oss.sgi.com")
	by ftp.linux-mips.org with ESMTP id S28641845AbYECRjq (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 18:39:46 +0100
Received: from dl5rb.ham-radio-op.net (localhost [127.0.0.1])
	by oss.sgi.com (8.12.11.20060308/8.12.11/SuSE Linux 0.7) with ESMTP id m43HcqrV016504
	for <linux-mips@linux-mips.org>; Sat, 3 May 2008 10:38:53 -0700
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m43HdTs3010586;
	Sat, 3 May 2008 18:39:29 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m43HdSVV010579;
	Sat, 3 May 2008 18:39:28 +0100
Date:	Sat, 3 May 2008 18:39:28 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	tsbogend@alpha.franken.de, linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
Message-ID: <20080503173927.GA19925@linux-mips.org>
References: <20080501163314.GA9955@alpha.franken.de> <20080502101113.GA24408@linux-mips.org> <20080504.011647.93019265.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080504.011647.93019265.anemo@mba.ocn.ne.jp>
User-Agent: Mutt/1.5.17 (2007-11-01)
X-Virus-Scanned: ClamAV 0.91.2/6021/Wed Feb 27 15:55:48 2008 on oss.sgi.com
X-Virus-Status:	Clean
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19087
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1009
Lines: 33

On Sun, May 04, 2008 at 01:16:47AM +0900, Atsushi Nemoto wrote:

> Then how about this fix?
> 
> ---------------------------------------------------------------------
> Subject: [PATCH] Fix detection of kernel segment on 64-bit
> 
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index cb8b0e2..7893bb3 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -78,6 +78,19 @@ void (*board_nmi_handler_setup)(void);
>  void (*board_ejtag_handler_setup)(void);
>  void (*board_bind_eic_interrupt)(int irq, int regset);
>  
> +static inline int kernel_unmapped_seg(void *addr)
> +{
> +	unsigned long a = (unsigned long)addr;
> +
> +#ifdef CONFIG_32BIT
> +	/* KSEG0 or KSEG1 */
> +	return (a & 0xc0000000) == KSEG0;

Slightly cleaner:

  return KSEGX(a) == KSEG0;

Unfortunately there is no such macro for the 64-bit segments nor does
the existing KSEGX() work correctly for non-CKSEGx 64-bit addresses.

  Ralf

From drepper@redhat.com Sat May  3 19:01:07 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 19:01:14 +0100 (BST)
Received: from mx1.redhat.com ([66.187.233.31]:33503 "EHLO mx1.redhat.com")
	by ftp.linux-mips.org with ESMTP id S28663761AbYECSBH (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 19:01:07 +0100
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254])
	by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m43I11JY009472;
	Sat, 3 May 2008 14:01:01 -0400
Received: from file.rdu.redhat.com (file.rdu.redhat.com [10.11.255.147])
	by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m43I10RY011340;
	Sat, 3 May 2008 14:01:00 -0400
Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [10.10.36.72])
	by file.rdu.redhat.com (8.13.1/8.13.1) with ESMTP id m43I10pp000694;
	Sat, 3 May 2008 14:01:00 -0400
Received: from devserv.devel.redhat.com (localhost.localdomain [127.0.0.1])
	by devserv.devel.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id m43I10uV032244;
	Sat, 3 May 2008 14:01:00 -0400
Received: (from drepper@localhost)
	by devserv.devel.redhat.com (8.12.11.20060308/8.12.11/Submit) id m43I109q032242;
	Sat, 3 May 2008 14:01:00 -0400
Date:	Sat, 3 May 2008 14:01:00 -0400
From:	Ulrich Drepper <drepper@redhat.com>
Message-Id: <200805031801.m43I109q032242@devserv.devel.redhat.com>
To:	linux-kernel@vger.kernel.org
Subject: [PATCH v2] unify sys_pipe implementation
Cc:	akpm@linux-foundation.org, linux-mips@linux-mips.org,
	sparclinux@vger.kernel.org, torvalds@linux-foundation.org
X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254
Return-Path: <drepper@redhat.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19088
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: drepper@redhat.com
Precedence: bulk
X-list: linux-mips
Content-Length: 21454
Lines: 725

The second version of this patch with Linus' comments addressed.  I've
changed the code for a few architectures to use a new name (<arch>_pipe
instead of sys_pipe) as per Linus' suggestion.  I haven't touched MIPS
and Sparc, they use too much magic in this area.  Should be easy enough
for the arch maintainer to clean up.  sys_pipe is now unconditionally
created in fs/pipe.c and they will lead to link errors in case the
arch code isn't cleaned up.

Some arch maintainers might want to take a look at their remaining
special versions.  The cris version, for instance, only differs from
the generic version in that it takes the BKL.  Is this still needed
these days?


 arch/alpha/kernel/entry.S         |    8 ++++----
 arch/alpha/kernel/systbls.S       |    2 +-
 arch/arm/kernel/sys_arm.c         |   17 -----------------
 arch/avr32/kernel/sys_avr32.c     |   13 -------------
 arch/blackfin/kernel/sys_bfin.c   |   17 -----------------
 arch/cris/arch-v10/kernel/entry.S |    2 +-
 arch/cris/arch-v32/kernel/entry.S |    2 +-
 arch/cris/kernel/sys_cris.c       |    4 ++--
 arch/frv/kernel/sys_frv.c         |   17 -----------------
 arch/h8300/kernel/sys_h8300.c     |   17 -----------------
 arch/ia64/kernel/entry.S          |    2 +-
 arch/ia64/kernel/sys_ia64.c       |    2 +-
 arch/m32r/kernel/sys_m32r.c       |    4 ++--
 arch/m32r/kernel/syscall_table.S  |    2 +-
 arch/m68k/kernel/sys_m68k.c       |   17 -----------------
 arch/m68knommu/kernel/sys_m68k.c  |   17 -----------------
 arch/mn10300/kernel/sys_mn10300.c |   17 -----------------
 arch/parisc/kernel/sys_parisc.c   |   13 -------------
 arch/powerpc/kernel/syscalls.c    |   17 -----------------
 arch/s390/kernel/entry.h          |    1 -
 arch/s390/kernel/sys_s390.c       |   17 -----------------
 arch/sh/kernel/sys_sh32.c         |    4 ++--
 arch/sh/kernel/sys_sh64.c         |   17 -----------------
 arch/sh/kernel/syscalls_32.S      |    2 +-
 arch/um/kernel/syscall.c          |   17 -----------------
 arch/v850/kernel/syscalls.c       |   17 -----------------
 arch/x86/kernel/sys_i386_32.c     |   17 -----------------
 arch/x86/kernel/sys_x86_64.c      |   17 -----------------
 fs/pipe.c                         |   17 +++++++++++++++++
 include/asm-ia64/unistd.h         |    2 +-
 include/asm-powerpc/syscalls.h    |    2 +-
 31 files changed, 36 insertions(+), 284 deletions(-)


Signed-off-by: Ulrich Drepper <drepper@redhat.com>

diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index 5fc61e2..c7a72a5 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -894,9 +894,9 @@ sys_getxpid:
 .end sys_getxpid
 
 	.align	4
-	.globl	sys_pipe
-	.ent	sys_pipe
-sys_pipe:
+	.globl	alpha_pipe
+	.ent	alpha_pipe
+alpha_pipe:
 	lda	$sp, -16($sp)
 	stq	$26, 0($sp)
 	.prologue 0
@@ -914,7 +914,7 @@ sys_pipe:
 	stq	$1, 80+16($sp)
 1:	lda	$sp, 16($sp)
 	ret
-.end sys_pipe
+.end alpha_pipe
 
 	.align	4
 	.globl	sys_execve
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index ba914af..863f23a 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -52,7 +52,7 @@ sys_call_table:
 	.quad sys_setpgid
 	.quad alpha_ni_syscall			/* 40 */
 	.quad sys_dup
-	.quad sys_pipe
+	.quad alpha_pipe
 	.quad osf_set_program_attributes
 	.quad alpha_ni_syscall
 	.quad sys_open				/* 45 */
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 9bd1870..0128687 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -34,23 +34,6 @@ extern unsigned long do_mremap(unsigned long addr, unsigned long old_len,
 			       unsigned long new_len, unsigned long flags,
 			       unsigned long new_addr);
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 /* common code for old and new mmaps */
 inline long do_mmap2(
 	unsigned long addr, unsigned long len,
diff --git a/arch/avr32/kernel/sys_avr32.c b/arch/avr32/kernel/sys_avr32.c
index 8deb600..8e8911e 100644
--- a/arch/avr32/kernel/sys_avr32.c
+++ b/arch/avr32/kernel/sys_avr32.c
@@ -14,19 +14,6 @@
 #include <asm/mman.h>
 #include <asm/uaccess.h>
 
-asmlinkage int sys_pipe(unsigned long __user *filedes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(filedes, fd, sizeof(fd)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
 			  unsigned long prot, unsigned long flags,
 			  unsigned long fd, off_t offset)
diff --git a/arch/blackfin/kernel/sys_bfin.c b/arch/blackfin/kernel/sys_bfin.c
index efb7b25..fce49d7 100644
--- a/arch/blackfin/kernel/sys_bfin.c
+++ b/arch/blackfin/kernel/sys_bfin.c
@@ -45,23 +45,6 @@
 #include <asm/cacheflush.h>
 #include <asm/dma.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2 * sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 /* common code for old and new mmaps */
 static inline long
 do_mmap2(unsigned long addr, unsigned long len,
diff --git a/arch/cris/arch-v10/kernel/entry.S b/arch/cris/arch-v10/kernel/entry.S
index 3a65f32..c0811c7 100644
--- a/arch/cris/arch-v10/kernel/entry.S
+++ b/arch/cris/arch-v10/kernel/entry.S
@@ -644,7 +644,7 @@ sys_call_table:
 	.long sys_mkdir
 	.long sys_rmdir		/* 40 */
 	.long sys_dup
-	.long sys_pipe
+	.long cris_pipe
 	.long sys_times
 	.long sys_ni_syscall	/* old prof syscall holder */
 	.long sys_brk		/* 45 */
diff --git a/arch/cris/arch-v32/kernel/entry.S b/arch/cris/arch-v32/kernel/entry.S
index eebbaba..adbc57a 100644
--- a/arch/cris/arch-v32/kernel/entry.S
+++ b/arch/cris/arch-v32/kernel/entry.S
@@ -567,7 +567,7 @@ sys_call_table:
 	.long sys_mkdir
 	.long sys_rmdir		/* 40 */
 	.long sys_dup
-	.long sys_pipe
+	.long cris_pipe
 	.long sys_times
 	.long sys_ni_syscall	/* old prof syscall holder */
 	.long sys_brk		/* 45 */
diff --git a/arch/cris/kernel/sys_cris.c b/arch/cris/kernel/sys_cris.c
index 8b99841..0e7f220 100644
--- a/arch/cris/kernel/sys_cris.c
+++ b/arch/cris/kernel/sys_cris.c
@@ -28,10 +28,10 @@
 #include <asm/segment.h>
 
 /*
- * sys_pipe() is the normal C calling standard for creating
+ * cris_pipe() is the normal C calling standard for creating
  * a pipe. It's not the way Unix traditionally does this, though.
  */
-asmlinkage int sys_pipe(unsigned long __user * fildes)
+asmlinkage int cris_pipe(unsigned long __user * fildes)
 {
         int fd[2];
         int error;
diff --git a/arch/frv/kernel/sys_frv.c b/arch/frv/kernel/sys_frv.c
index 04c6b16..49b2cf2 100644
--- a/arch/frv/kernel/sys_frv.c
+++ b/arch/frv/kernel/sys_frv.c
@@ -28,23 +28,6 @@
 #include <asm/setup.h>
 #include <asm/uaccess.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage long sys_pipe(unsigned long __user * fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
 			  unsigned long prot, unsigned long flags,
 			  unsigned long fd, unsigned long pgoff)
diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c
index 00608be..2745656 100644
--- a/arch/h8300/kernel/sys_h8300.c
+++ b/arch/h8300/kernel/sys_h8300.c
@@ -27,23 +27,6 @@
 #include <asm/traps.h>
 #include <asm/unistd.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long * fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 /* common code for old and new mmaps */
 static inline long do_mmap2(
 	unsigned long addr, unsigned long len,
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index e49ad8c..f567bcc 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1402,7 +1402,7 @@ sys_call_table:
 	data8 sys_mkdir				// 1055
 	data8 sys_rmdir
 	data8 sys_dup
-	data8 sys_pipe
+	data8 ia64_pipe
 	data8 sys_times
 	data8 ia64_brk				// 1060
 	data8 sys_setgid
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
index 1eda194..6070826 100644
--- a/arch/ia64/kernel/sys_ia64.c
+++ b/arch/ia64/kernel/sys_ia64.c
@@ -154,7 +154,7 @@ out:
  * and r9) as this is faster than doing a copy_to_user().
  */
 asmlinkage long
-sys_pipe (void)
+ia64_pipe (void)
 {
 	struct pt_regs *regs = task_pt_regs(current);
 	int fd[2];
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
index 6d7a80f..7475510 100644
--- a/arch/m32r/kernel/sys_m32r.c
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -77,11 +77,11 @@ asmlinkage int sys_tas(int __user *addr)
 }
 
 /*
- * sys_pipe() is the normal C calling standard for creating
+ * m32r_pipe() is the normal C calling standard for creating
  * a pipe. It's not the way Unix traditionally does this, though.
  */
 asmlinkage int
-sys_pipe(unsigned long r0, unsigned long r1, unsigned long r2,
+m32r_pipe(unsigned long r0, unsigned long r1, unsigned long r2,
 	unsigned long r3, unsigned long r4, unsigned long r5,
 	unsigned long r6, struct pt_regs regs)
 {
diff --git a/arch/m32r/kernel/syscall_table.S b/arch/m32r/kernel/syscall_table.S
index aa3bf4c..911913d 100644
--- a/arch/m32r/kernel/syscall_table.S
+++ b/arch/m32r/kernel/syscall_table.S
@@ -41,7 +41,7 @@ ENTRY(sys_call_table)
 	.long sys_mkdir
 	.long sys_rmdir			/* 40 */
 	.long sys_dup
-	.long sys_pipe
+	.long m32r_pipe
 	.long sys_times
 	.long sys_ni_syscall		/* old prof syscall holder */
 	.long sys_brk			/* 45 */
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index e892f17..7f54efa 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -30,23 +30,6 @@
 #include <asm/page.h>
 #include <asm/unistd.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long __user * fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 /* common code for old and new mmaps */
 static inline long do_mmap2(
 	unsigned long addr, unsigned long len,
diff --git a/arch/m68knommu/kernel/sys_m68k.c b/arch/m68knommu/kernel/sys_m68k.c
index 65f7a95..7002816 100644
--- a/arch/m68knommu/kernel/sys_m68k.c
+++ b/arch/m68knommu/kernel/sys_m68k.c
@@ -28,23 +28,6 @@
 #include <asm/cacheflush.h>
 #include <asm/unistd.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long * fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 /* common code for old and new mmaps */
 static inline long do_mmap2(
 	unsigned long addr, unsigned long len,
diff --git a/arch/mn10300/kernel/sys_mn10300.c b/arch/mn10300/kernel/sys_mn10300.c
index 5f17a1e..bca5a84 100644
--- a/arch/mn10300/kernel/sys_mn10300.c
+++ b/arch/mn10300/kernel/sys_mn10300.c
@@ -29,23 +29,6 @@
 #define MIN_MAP_ADDR	PAGE_SIZE	/* minimum fixed mmap address */
 
 /*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way Unix traditionally does this, though.
- */
-asmlinkage long sys_pipe(unsigned long __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2 * sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
-/*
  * memory mapping syscall
  */
 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 4f58921..71b3195 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -33,19 +33,6 @@
 #include <linux/utsname.h>
 #include <linux/personality.h>
 
-int sys_pipe(int __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
 {
 	struct vm_area_struct *vma;
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index e722a4e..4fe69ca 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -136,23 +136,6 @@ int sys_ipc(uint call, int first, unsigned long second, long third,
 	return ret;
 }
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-int sys_pipe(int __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 static inline unsigned long do_mmap2(unsigned long addr, size_t len,
 			unsigned long prot, unsigned long flags,
 			unsigned long fd, unsigned long off, int shift)
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index 6b18963..9febc89 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -30,7 +30,6 @@ struct fadvise64_64_args;
 struct old_sigaction;
 struct sel_arg_struct;
 
-long sys_pipe(unsigned long __user *fildes);
 long sys_mmap2(struct mmap_arg_struct __user  *arg);
 long old_mmap(struct mmap_arg_struct __user *arg);
 long sys_ipc(uint call, int first, unsigned long second,
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index 988d0d6..5fdb799 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -32,23 +32,6 @@
 #include <asm/uaccess.h>
 #include "entry.h"
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way Unix traditionally does this, though.
- */
-asmlinkage long sys_pipe(unsigned long __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 /* common code for old and new mmaps */
 static inline long do_mmap2(
 	unsigned long addr, unsigned long len,
diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c
index 125e493..da25089 100644
--- a/arch/sh/kernel/sys_sh32.c
+++ b/arch/sh/kernel/sys_sh32.c
@@ -18,10 +18,10 @@
 #include <asm/unistd.h>
 
 /*
- * sys_pipe() is the normal C calling standard for creating
+ * sh32_pipe() is the normal C calling standard for creating
  * a pipe. It's not the way Unix traditionally does this, though.
  */
-asmlinkage int sys_pipe(unsigned long r4, unsigned long r5,
+asmlinkage int sh32_pipe(unsigned long r4, unsigned long r5,
 	unsigned long r6, unsigned long r7,
 	struct pt_regs __regs)
 {
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c
index 578004d..91fb844 100644
--- a/arch/sh/kernel/sys_sh64.c
+++ b/arch/sh/kernel/sys_sh64.c
@@ -31,23 +31,6 @@
 #include <asm/unistd.h>
 
 /*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way Unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long * fildes)
-{
-        int fd[2];
-        int error;
-
-        error = do_pipe(fd);
-        if (!error) {
-                if (copy_to_user(fildes, fd, 2*sizeof(int)))
-                        error = -EFAULT;
-        }
-        return error;
-}
-
-/*
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
  */
diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S
index a46cc3a..b17cef2 100644
--- a/arch/sh/kernel/syscalls_32.S
+++ b/arch/sh/kernel/syscalls_32.S
@@ -58,7 +58,7 @@ ENTRY(sys_call_table)
 	.long sys_mkdir
 	.long sys_rmdir		/* 40 */
 	.long sys_dup
-	.long sys_pipe
+	.long sh32_pipe
 	.long sys_times
 	.long sys_ni_syscall	/* old prof syscall holder */
 	.long sys_brk		/* 45 */
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index 9cffc62..128ee85 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -73,23 +73,6 @@ long old_mmap(unsigned long addr, unsigned long len,
  out:
 	return err;
 }
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-long sys_pipe(unsigned long __user * fildes)
-{
-	int fd[2];
-	long error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, sizeof(fd)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 
 long sys_uname(struct old_utsname __user * name)
 {
diff --git a/arch/v850/kernel/syscalls.c b/arch/v850/kernel/syscalls.c
index 003db9c..1a83daf 100644
--- a/arch/v850/kernel/syscalls.c
+++ b/arch/v850/kernel/syscalls.c
@@ -132,23 +132,6 @@ sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
 	return ret;
 }
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way unix traditionally does this, though.
- */
-int sys_pipe (int *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe (fd);
-	if (!error) {
-		if (copy_to_user (fildes, fd, 2*sizeof (int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 static inline unsigned long
 do_mmap2 (unsigned long addr, size_t len,
 	 unsigned long prot, unsigned long flags,
diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
index a86d26f..d2ab52c 100644
--- a/arch/x86/kernel/sys_i386_32.c
+++ b/arch/x86/kernel/sys_i386_32.c
@@ -22,23 +22,6 @@
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way Unix traditionally does this, though.
- */
-asmlinkage int sys_pipe(unsigned long __user * fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
 			  unsigned long prot, unsigned long flags,
 			  unsigned long fd, unsigned long pgoff)
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index bd802a5..3b360ef 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -17,23 +17,6 @@
 #include <asm/uaccess.h>
 #include <asm/ia32.h>
 
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way Unix traditionally does this, though.
- */
-asmlinkage long sys_pipe(int __user *fildes)
-{
-	int fd[2];
-	int error;
-
-	error = do_pipe(fd);
-	if (!error) {
-		if (copy_to_user(fildes, fd, 2*sizeof(int)))
-			error = -EFAULT;
-	}
-	return error;
-}
-
 asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
 	unsigned long fd, unsigned long off)
 {
diff --git a/fs/pipe.c b/fs/pipe.c
index f73492b..8400ebf 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1076,6 +1076,23 @@ int do_pipe(int *fd)
 }
 
 /*
+ * sys_pipe() is the normal C calling standard for creating
+ * a pipe. It's not the way Unix traditionally does this, though.
+ */
+asmlinkage long sys_pipe(int __user *fildes)
+{
+	int fd[2];
+	int error;
+
+	error = do_pipe(fd);
+	if (!error) {
+		if (copy_to_user(fildes, fd, sizeof(fd)))
+			error = -EFAULT;
+	}
+	return error;
+}
+
+/*
  * pipefs should _never_ be mounted by userland - too much of security hassle,
  * no real gain from having the whole whorehouse mounted. So we don't need
  * any operations on the root directory. However, we need a non-trivial
diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
index e603147..74350b2 100644
--- a/include/asm-ia64/unistd.h
+++ b/include/asm-ia64/unistd.h
@@ -357,7 +357,7 @@ struct pt_regs;
 struct sigaction;
 long sys_execve(char __user *filename, char __user * __user *argv,
 			   char __user * __user *envp, struct pt_regs *regs);
-asmlinkage long sys_pipe(void);
+asmlinkage long ia64_pipe(void);
 asmlinkage long sys_rt_sigaction(int sig,
 				 const struct sigaction __user *act,
 				 struct sigaction __user *oact,
diff --git a/include/asm-powerpc/syscalls.h b/include/asm-powerpc/syscalls.h
index b3ca41f..2b8a458 100644
--- a/include/asm-powerpc/syscalls.h
+++ b/include/asm-powerpc/syscalls.h
@@ -30,7 +30,7 @@ asmlinkage int sys_fork(unsigned long p1, unsigned long p2,
 asmlinkage int sys_vfork(unsigned long p1, unsigned long p2,
 		unsigned long p3, unsigned long p4, unsigned long p5,
 		unsigned long p6, struct pt_regs *regs);
-asmlinkage int sys_pipe(int __user *fildes);
+asmlinkage long sys_pipe(int __user *fildes);
 asmlinkage long sys_rt_sigaction(int sig,
 		const struct sigaction __user *act,
 		struct sigaction __user *oact, size_t sigsetsize);

From torvalds@linux-foundation.org Sat May  3 19:41:00 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 19:41:08 +0100 (BST)
Received: from smtp1.linux-foundation.org ([140.211.169.13]:31920 "EHLO
	smtp1.linux-foundation.org") by ftp.linux-mips.org with ESMTP
	id S28791051AbYECSlA (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 3 May 2008 19:41:00 +0100
Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55])
	by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id m43IeKJ0001044
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 3 May 2008 11:40:22 -0700
Received: from localhost (localhost [127.0.0.1])
	by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id m43IeIqL026803;
	Sat, 3 May 2008 11:40:19 -0700
Date:	Sat, 3 May 2008 11:40:18 -0700 (PDT)
From:	Linus Torvalds <torvalds@linux-foundation.org>
To:	Ulrich Drepper <drepper@redhat.com>
cc:	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org, sparclinux@vger.kernel.org
Subject: Re: [PATCH v2] unify sys_pipe implementation
In-Reply-To: <200805031801.m43I109q032242@devserv.devel.redhat.com>
Message-ID: <alpine.LFD.1.10.0805031138450.5994@woody.linux-foundation.org>
References: <200805031801.m43I109q032242@devserv.devel.redhat.com>
User-Agent: Alpine 1.10 (LFD 962 2008-03-14)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-MIMEDefang-Filter: lf$Revision: 1.188 $
X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13
Return-Path: <torvalds@linux-foundation.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19089
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: torvalds@linux-foundation.org
Precedence: bulk
X-list: linux-mips
Content-Length: 609
Lines: 19



On Sat, 3 May 2008, Ulrich Drepper wrote:
> 
> Some arch maintainers might want to take a look at their remaining
> special versions.  The cris version, for instance, only differs from
> the generic version in that it takes the BKL.  Is this still needed
> these days?

No, definitely not.

That said, I think that in order to not break other architectures, and to 
make it even easier to do this transformation, how about we just mark the 
generic version with __weak?

That way, odd architectures can just continue to call their own versions 
"sys_pipe()", and we don't break them unnecessarily.

		Linus

From bunk@kernel.org Sat May  3 20:27:24 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 20:27:32 +0100 (BST)
Received: from smtp5.pp.htv.fi ([213.243.153.39]:8126 "EHLO smtp5.pp.htv.fi")
	by ftp.linux-mips.org with ESMTP id S20035143AbYECT1Y (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 20:27:24 +0100
Received: from cs181133002.pp.htv.fi (cs181133002.pp.htv.fi [82.181.133.2])
	by smtp5.pp.htv.fi (Postfix) with ESMTP id B78B05BC02E;
	Sat,  3 May 2008 22:27:18 +0300 (EEST)
Date:	Sat, 3 May 2008 22:26:17 +0300
From:	Adrian Bunk <bunk@kernel.org>
To:	"H. Peter Anvin" <hpa@zytor.com>,
	Ralf Baechle <ralf@linux-mips.org>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [2.6 patch] fix asm-mips/types.h syntax error
Message-ID: <20080503192617.GQ5838@cs181133002.pp.htv.fi>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
Return-Path: <bunk@kernel.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19090
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: bunk@kernel.org
Precedence: bulk
X-list: linux-mips
Content-Length: 941
Lines: 33

This patch fixes the following compile error caused by
commit 23cf11ddb5099f8c7f7cb3eb154bff0faf31cae9
(mips: types: use <asm-generic/int-*.h> for the mips architecture):

<--  snip  -->

...
  CC      kernel/bounds.s
In file included from /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/types.h:12,
                 from /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/page-flags.h:8,
                 from /home/bunk/linux/kernel-2.6/git/linux-2.6/kernel/bounds.c:9:
include2/asm/types.h:56:2: error: #endif without #if
make[2]: *** [kernel/bounds.s] Error 1

<--  snip  -->

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---
5de735b6b9037ad6b8a30ef51f4bd8e011954144 diff --git a/include/asm-mips/types.h b/include/asm-mips/types.h
index 7a2ee4f..bcbb8d6 100644
--- a/include/asm-mips/types.h
+++ b/include/asm-mips/types.h
@@ -19,8 +19,6 @@
 
 typedef unsigned short umode_t;
 
-#endif
-
 #endif /* __ASSEMBLY__ */
 
 /*


From hpa@zytor.com Sat May  3 20:37:09 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 20:37:13 +0100 (BST)
Received: from terminus.zytor.com ([198.137.202.10]:45797 "EHLO
	terminus.zytor.com") by ftp.linux-mips.org with ESMTP
	id S20022455AbYECThJ (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 3 May 2008 20:37:09 +0100
Received: from mail.hos.anvin.org (c-98-210-181-100.hsd1.ca.comcast.net [98.210.181.100])
	(authenticated bits=0)
	by terminus.zytor.com (8.14.2/8.14.1) with ESMTP id m43JaOJQ013923
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sat, 3 May 2008 12:36:24 -0700
Received: from tazenda.hos.anvin.org (tazenda.hos.anvin.org [172.27.0.16])
	by mail.hos.anvin.org (8.14.2/8.13.8) with ESMTP id m43JaNu3030247;
	Sat, 3 May 2008 12:36:23 -0700
Received: from tazenda.hos.anvin.org (localhost.localdomain [127.0.0.1])
	by tazenda.hos.anvin.org (8.14.2/8.13.6) with ESMTP id m43JaLEa021939;
	Sat, 3 May 2008 12:36:22 -0700
Message-ID: <481CBEB5.803@zytor.com>
Date:	Sat, 03 May 2008 12:36:21 -0700
From:	"H. Peter Anvin" <hpa@zytor.com>
User-Agent: Thunderbird 2.0.0.12 (X11/20080226)
MIME-Version: 1.0
To:	Adrian Bunk <bunk@kernel.org>
CC:	Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [2.6 patch] fix asm-mips/types.h syntax error
References: <20080503192617.GQ5838@cs181133002.pp.htv.fi>
In-Reply-To: <20080503192617.GQ5838@cs181133002.pp.htv.fi>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: ClamAV 0.92.1/7015/Sat May  3 04:57:16 2008 on terminus.zytor.com
X-Virus-Status:	Clean
Return-Path: <hpa@zytor.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19091
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: hpa@zytor.com
Precedence: bulk
X-list: linux-mips
Content-Length: 850
Lines: 26

Adrian Bunk wrote:
> This patch fixes the following compile error caused by
> commit 23cf11ddb5099f8c7f7cb3eb154bff0faf31cae9
> (mips: types: use <asm-generic/int-*.h> for the mips architecture):
> 
> <--  snip  -->
> 
> ...
>   CC      kernel/bounds.s
> In file included from /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/types.h:12,
>                  from /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/page-flags.h:8,
>                  from /home/bunk/linux/kernel-2.6/git/linux-2.6/kernel/bounds.c:9:
> include2/asm/types.h:56:2: error: #endif without #if
> make[2]: *** [kernel/bounds.s] Error 1
> 
> <--  snip  -->
> 
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
> 

Acked-by: H. Peter Anvin <hpa@zytor.com>

Went through the other patches, too, to verify none of the other 
architectures were similarly affected.

	-hpa

From macro@linux-mips.org Sat May  3 20:57:19 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 20:57:21 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:3832 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S28583755AbYECT5T (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 20:57:19 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m43JvDs2021039;
	Sat, 3 May 2008 21:57:13 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m43Jv4mB021032;
	Sat, 3 May 2008 20:57:04 +0100
Date:	Sat, 3 May 2008 20:57:04 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Ralf Baechle <ralf@linux-mips.org>
cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, tsbogend@alpha.franken.de,
	linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
In-Reply-To: <20080503173927.GA19925@linux-mips.org>
Message-ID: <Pine.LNX.4.55.0805032051010.20206@cliff.in.clinika.pl>
References: <20080501163314.GA9955@alpha.franken.de> <20080502101113.GA24408@linux-mips.org>
 <20080504.011647.93019265.anemo@mba.ocn.ne.jp> <20080503173927.GA19925@linux-mips.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19092
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 536
Lines: 21

On Sat, 3 May 2008, Ralf Baechle wrote:

> Slightly cleaner:
> 
>   return KSEGX(a) == KSEG0;

 You mean:

return KSEGX(a) == KSEG0 || KSEGX(a) == KSEG1;

right?

> Unfortunately there is no such macro for the 64-bit segments nor does
> the existing KSEGX() work correctly for non-CKSEGx 64-bit addresses.

 As I mentioned there is suitable code doing exactly this in
arch/mips/lib/uncached.c and it can be extracted to an inline function to
be put in <asm/addrspace.h> to be reused here and in the future possibly
elsewhere.

  Maciej

From tsbogend@alpha.franken.de Sat May  3 23:25:08 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 23:25:10 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:6379 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20025348AbYECWZI (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 23:25:08 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JsQAF-0004mp-00; Sun, 04 May 2008 00:25:07 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 52F3BFAB11; Sun,  4 May 2008 00:25:02 +0200 (CEST)
From:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Subject: [PATCH] Fix __fls for non mips32/mips64 cpus
To:	linux-mips@linux-mips.org
cc:	ralf@linux-mips.org
Message-Id: <20080503222502.52F3BFAB11@solo.franken.de>
Date:	Sun,  4 May 2008 00:25:02 +0200 (CEST)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19093
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 1270
Lines: 40

Only MIPS32 and MIPS64 CPUs implement clz/dclz. Therefore don't
export __ilog2() for non MIPS32/MIPS64 cpus and use generic
__fls bitop code for these cpus.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---

 include/asm-mips/bitops.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index c2bd126..5e1f590 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -558,6 +558,8 @@ static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *
 	__clear_bit(nr, addr);
 }
 
+#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
+
 /*
  * Return the bit position (0..63) of the most significant 1 bit in a word
  * Returns -1 if no 1 bit exists
@@ -596,8 +598,6 @@ static inline unsigned long __fls(unsigned long x)
 	return __ilog2(x);
 }
 
-#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
-
 /*
  * __ffs - find first bit in word.
  * @word: The word to search
@@ -654,6 +654,7 @@ static inline int ffs(int word)
 #else
 
 #include <asm-generic/bitops/__ffs.h>
+#include <asm-generic/bitops/__fls.h>
 #include <asm-generic/bitops/ffs.h>
 #include <asm-generic/bitops/fls.h>
 #include <asm-generic/bitops/fls64.h>

From tsbogend@alpha.franken.de Sat May  3 23:49:22 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 03 May 2008 23:49:25 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:18156 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S28584060AbYECWtU (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 3 May 2008 23:49:20 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JsQXe-0000Po-00; Sun, 04 May 2008 00:49:18 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 7CCC3FAB11; Sun,  4 May 2008 00:48:49 +0200 (CEST)
Date:	Sun, 4 May 2008 00:48:49 +0200
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
Message-ID: <20080503224849.GA2314@alpha.franken.de>
References: <20080501163314.GA9955@alpha.franken.de> <20080502101113.GA24408@linux-mips.org> <20080504.011647.93019265.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080504.011647.93019265.anemo@mba.ocn.ne.jp>
User-Agent: Mutt/1.5.13 (2006-08-11)
From:	tsbogend@alpha.franken.de (Thomas Bogendoerfer)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19094
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 2107
Lines: 65

On Sun, May 04, 2008 at 01:16:47AM +0900, Atsushi Nemoto wrote:
> On Fri, 2 May 2008 11:11:13 +0100, Ralf Baechle <ralf@linux-mips.org> wrote:
> > It came as part of 39b8d5254246ac56342b72f812255c8f7a74dca9 which is a
> > patch amalgated from several other patches.  Below is the original patch
> > it came with.  I think the idea of the patch is valid but the idea needs a
> > bit of mending.
> 
> Then how about this fix?

hmm, why not simply use __get_user() when accessing the stack content ?
show_stacktrace() already does it for stack dumping ? This would
avoid any work for whatever sick stack mappings. Below is a patch,
which does this.

Thomas.

The newly added check for valid stack pointer address breaks at least for
64bit kernels.  Use __get_user() for accessing stack content to avoid crashes,
when doing the backtrace.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---

 arch/mips/kernel/traps.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index cb8b0e2..c9ce8d6 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -81,22 +81,22 @@ void (*board_bind_eic_interrupt)(int irq, int regset);
 
 static void show_raw_backtrace(unsigned long reg29)
 {
-	unsigned long *sp = (unsigned long *)(reg29 & ~3);
+	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
 	unsigned long addr;
 
 	printk("Call Trace:");
 #ifdef CONFIG_KALLSYMS
 	printk("\n");
 #endif
-#define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
-	if (IS_KVA01(sp)) {
-		while (!kstack_end(sp)) {
-			addr = *sp++;
-			if (__kernel_text_address(addr))
-				print_ip_sym(addr);
+	while (!kstack_end(sp)) {
+		if (__get_user(addr, sp++)) {
+			printk(" (Bad stack address)");
+			break;
 		}
-		printk("\n");
+		if (__kernel_text_address(addr))
+			print_ip_sym(addr);
 	}
+	printk("\n");
 }
 
 #ifdef CONFIG_KALLSYMS

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

From anemo@mba.ocn.ne.jp Sun May  4 14:38:44 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 14:38:46 +0100 (BST)
Received: from mba.ocn.ne.jp ([122.1.235.107]:16368 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S20025744AbYEDNio (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 4 May 2008 14:38:44 +0100
Received: from localhost (p4020-ipad208funabasi.chiba.ocn.ne.jp [60.43.105.20])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 61F80A846; Sun,  4 May 2008 22:38:37 +0900 (JST)
Date:	Sun, 04 May 2008 22:39:44 +0900 (JST)
Message-Id: <20080504.223944.41198532.anemo@mba.ocn.ne.jp>
To:	tsbogend@alpha.franken.de
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <20080503224849.GA2314@alpha.franken.de>
References: <20080502101113.GA24408@linux-mips.org>
	<20080504.011647.93019265.anemo@mba.ocn.ne.jp>
	<20080503224849.GA2314@alpha.franken.de>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19095
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
Content-Length: 711
Lines: 21

On Sun, 4 May 2008 00:48:49 +0200, tsbogend@alpha.franken.de (Thomas Bogendoerfer) wrote:
> hmm, why not simply use __get_user() when accessing the stack content ?
> show_stacktrace() already does it for stack dumping ? This would
> avoid any work for whatever sick stack mappings. Below is a patch,
> which does this.

I like this patch.  One minor request:

> +	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
...
> +	while (!kstack_end(sp)) {
> +		if (__get_user(addr, sp++)) {

This will leads a sparse warning since an argument for kstack_end is 'void *'.

	while (!kstack_end((void *)(unsigned long)sp)) {

will make this part sparse-free, though it seems a bit ugly.

---
Atsushi Nemoto

From bunk@kernel.org Sun May  4 18:00:06 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 18:00:09 +0100 (BST)
Received: from smtp4.pp.htv.fi ([213.243.153.38]:470 "EHLO smtp4.pp.htv.fi")
	by ftp.linux-mips.org with ESMTP id S20046280AbYEDRAG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 4 May 2008 18:00:06 +0100
Received: from cs181133002.pp.htv.fi (cs181133002.pp.htv.fi [82.181.133.2])
	by smtp4.pp.htv.fi (Postfix) with ESMTP id 1B7865BC034;
	Sun,  4 May 2008 19:59:59 +0300 (EEST)
Date:	Sun, 4 May 2008 19:58:54 +0300
From:	Adrian Bunk <bunk@kernel.org>
To:	Roman Zippel <zippel@linux-m68k.org>, ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: [2.6 patch] mips/emma2rh/markeins/setup.c build fix
Message-ID: <20080504165850.GM5838@cs181133002.pp.htv.fi>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
Return-Path: <bunk@kernel.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19096
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: bunk@kernel.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1518
Lines: 44

This patch fixes the following build errror caused by
commit 7dffa3c673fbcf835cd7be80bb4aec8ad3f51168
(ntp: handle leap second via timer):

<--  snip  -->

...
  CC      arch/mips/emma2rh/markeins/setup.o
/home/bunk/linux/kernel-2.6/git/linux-2.6/arch/mips/emma2rh/markeins/setup.c:79: error: conflicting types for 'clock'
/home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/clocksource.h:96: error: previous declaration of 'clock' was here
make[2]: *** [arch/mips/emma2rh/markeins/setup.o] Error 1

<--  snip  -->

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---

 arch/mips/emma2rh/markeins/setup.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

139244b9f3cd31793da682da14c67e38836bec36 diff --git a/arch/mips/emma2rh/markeins/setup.c b/arch/mips/emma2rh/markeins/setup.c
index 82f9e90..487cac5 100644
--- a/arch/mips/emma2rh/markeins/setup.c
+++ b/arch/mips/emma2rh/markeins/setup.c
@@ -76,7 +76,7 @@ static void markeins_machine_power_off(void)
 	while (1) ;
 }
 
-static unsigned long clock[4] = { 166500000, 187312500, 199800000, 210600000 };
+static unsigned long emma2rh_clock[4] = { 166500000, 187312500, 199800000, 210600000 };
 
 static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
 {
@@ -85,7 +85,7 @@ static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
 	/* detect from boot strap */
 	reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0);
 	reg = (reg >> 4) & 0x3;
-	return clock[reg];
+	return emma2rh_clock[reg];
 }
 
 void __init plat_time_init(void)


From matteo@openwrt.org Sun May  4 18:04:30 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 18:04:33 +0100 (BST)
Received: from smtp-out112.alice.it ([85.37.17.112]:46597 "EHLO
	smtp-out112.alice.it") by ftp.linux-mips.org with ESMTP
	id S20030712AbYEDREa (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 4 May 2008 18:04:30 +0100
Received: from FBCMMO01.fbc.local ([192.168.68.195]) by smtp-out112.alice.it with Microsoft SMTPSVC(6.0.3790.1830);
	 Sun, 4 May 2008 19:04:24 +0200
Received: from FBCMCL01B03.fbc.local ([192.168.69.84]) by FBCMMO01.fbc.local with Microsoft SMTPSVC(6.0.3790.1830);
	 Sun, 4 May 2008 19:04:24 +0200
Received: from raver.lan ([87.3.113.52]) by FBCMCL01B03.fbc.local with Microsoft SMTPSVC(6.0.3790.1830);
	 Sun, 4 May 2008 19:04:22 +0200
From:	Matteo Croce <matteo@openwrt.org>
To:	Andrew Morton <akpm@linux-foundation.org>,
	Jeff Garzik <jgarzik@pobox.com>
Subject: [PATCH]: cpmac bugfixes and enhancements
Date:	Sun, 4 May 2008 19:04:22 +0200
User-Agent: KMail/1.9.9
X-Face:	0AUq?,0sKh2O65+R5#[nTCS'~}"m)9|g3Tsi=g7A9q69S+=M!BY)Zdmwo2u!i\Uylx&'D+
	[7u&z1's~[?+$'wO6+"'WWcr5Jy,]}8namg8NP:9<E,o^21xGB~/HRhB(u^@ZB.XLP0swe
	r9M~L<b1=^'4cv*_N1tNJ$`9Ot*KL/;8oXFdrT@r|-Ki2wCQI"R(X(73r:;mnNPoA2a]~Z
	2n2sUh,B|bt;ys*hv.QR>a]{m
Cc:	Ralf Baechle <ralf@linux-mips.org>,
	Felix Fietkau <nbd@openwrt.org>,
	Eugene Konev <ejka@imfi.kspu.ru>, linux-mips@linux-mips.org,
	netdev@vger.kernel.org
MIME-Version: 1.0
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200805041904.22726.matteo@openwrt.org>
X-OriginalArrivalTime: 04 May 2008 17:04:23.0230 (UTC) FILETIME=[E6A05DE0:01C8AE08]
Return-Path: <matteo@openwrt.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19097
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: matteo@openwrt.org
Precedence: bulk
X-list: linux-mips
Content-Length: 13723
Lines: 444

This patch fixes an IRQ storm, a locking issues, moves platform code in the right sections
and other small fixes.

please apply

Signed-off-by: Matteo Croce <matteo@openwrt.org>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 2b5740b..b1dfd85 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -38,11 +38,11 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <asm/gpio.h>
+#include <asm/atomic.h>
 
 MODULE_AUTHOR("Eugene Konev <ejka@imfi.kspu.ru>");
 MODULE_DESCRIPTION("TI AR7 ethernet driver (CPMAC)");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:cpmac");
 
 static int debug_level = 8;
 static int dumb_switch;
@@ -187,6 +187,7 @@ struct cpmac_desc {
 #define CPMAC_EOQ			0x1000
 	struct sk_buff *skb;
 	struct cpmac_desc *next;
+	struct cpmac_desc *prev;
 	dma_addr_t mapping;
 	dma_addr_t data_mapping;
 };
@@ -208,6 +209,7 @@ struct cpmac_priv {
 	struct work_struct reset_work;
 	struct platform_device *pdev;
 	struct napi_struct napi;
+	atomic_t reset_pending;
 };
 
 static irqreturn_t cpmac_irq(int, void *);
@@ -241,6 +243,16 @@ static void cpmac_dump_desc(struct net_device *dev, struct cpmac_desc *desc)
 	printk("\n");
 }
 
+static void cpmac_dump_all_desc(struct net_device *dev)
+{
+        struct cpmac_priv *priv = netdev_priv(dev);
+        struct cpmac_desc *dump = priv->rx_head;
+        do {
+                cpmac_dump_desc(dev, dump);
+                dump = dump->next;
+        } while (dump != priv->rx_head);
+}
+
 static void cpmac_dump_skb(struct net_device *dev, struct sk_buff *skb)
 {
 	int i;
@@ -412,21 +424,40 @@ static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv,
 static int cpmac_poll(struct napi_struct *napi, int budget)
 {
 	struct sk_buff *skb;
-	struct cpmac_desc *desc;
-	int received = 0;
+	struct cpmac_desc *desc, *restart;
 	struct cpmac_priv *priv = container_of(napi, struct cpmac_priv, napi);
+	int received = 0, processed = 0;
 
 	spin_lock(&priv->rx_lock);
 	if (unlikely(!priv->rx_head)) {
 		if (netif_msg_rx_err(priv) && net_ratelimit())
 			printk(KERN_WARNING "%s: rx: polling, but no queue\n",
 			       priv->dev->name);
+		spin_unlock(&priv->rx_lock);
 		netif_rx_complete(priv->dev, napi);
 		return 0;
 	}
 
 	desc = priv->rx_head;
+	restart = NULL;
 	while (((desc->dataflags & CPMAC_OWN) == 0) && (received < budget)) {
+		processed++;
+		
+		if ((desc->dataflags & CPMAC_EOQ) != 0) {
+			/* The last update to eoq->hw_next didn't happen soon enough, and the
+			* receiver stopped here. Remember this descriptor so we can restart
+			* the receiver after freeing some space.
+			*/
+			if (unlikely(restart)) {
+				if (netif_msg_rx_err(priv))
+					printk(KERN_ERR "%s: poll found a duplicate EOQ: %p and %p\n",
+						priv->dev->name, restart, desc);
+				goto fatal_error;
+			}
+			
+			restart = desc->next;
+		}
+
 		skb = cpmac_rx_one(priv, desc);
 		if (likely(skb)) {
 			netif_receive_skb(skb);
@@ -435,19 +466,81 @@ static int cpmac_poll(struct napi_struct *napi, int budget)
 		desc = desc->next;
 	}
 
+	if (desc != priv->rx_head) {
+		/* We freed some buffers, but not the whole ring, add what we did free to the rx list */ 
+		desc->prev->hw_next = (u32)0;
+		priv->rx_head->prev->hw_next = priv->rx_head->mapping;
+	}
+
+	/* Optimization: If we did not actually process an EOQ (perhaps because of 
+	* quota limits), check to see if the tail of the queue has EOQ set. We
+	* should immediately restart in that case so that the receiver can restart
+	* and run in parallel with more packet processing. This lets us handle slightly
+	* larger bursts before running out of ring space (assuming dev->weight < ring_size)
+	*/
+	if (!restart &&
+	     (priv->rx_head->prev->dataflags & (CPMAC_OWN|CPMAC_EOQ)) == CPMAC_EOQ &&
+	     (priv->rx_head->dataflags & CPMAC_OWN) != 0) {
+		/* reset EOQ so the poll loop (above) doesn't try to restart this when it
+		* eventually gets to this descriptor.
+		*/
+		priv->rx_head->prev->dataflags &= ~CPMAC_EOQ;
+		restart = priv->rx_head;
+	}
+
+	if (restart) {
+		priv->dev->stats.rx_errors++;
+		priv->dev->stats.rx_fifo_errors++;
+		if (netif_msg_rx_err(priv) && net_ratelimit())
+			printk(KERN_WARNING "%s: rx dma ring overrun\n", priv->dev->name);
+
+		if (unlikely((restart->dataflags & CPMAC_OWN) == 0)) {
+			if (netif_msg_drv(priv))
+				printk(KERN_ERR "%s: cpmac_poll is trying to restart rx from a descriptor that's not free: %p\n",
+					priv->dev->name, restart);
+				goto fatal_error;
+		}
+
+		cpmac_write(priv->regs, CPMAC_RX_PTR(0), restart->mapping);
+	}
+
 	priv->rx_head = desc;
 	spin_unlock(&priv->rx_lock);
 	if (unlikely(netif_msg_rx_status(priv)))
 		printk(KERN_DEBUG "%s: poll processed %d packets\n",
 		       priv->dev->name, received);
-	if (desc->dataflags & CPMAC_OWN) {
+	if (processed == 0) {
+		/* we ran out of packets to read, revert to interrupt-driven mode */ 
 		netif_rx_complete(priv->dev, napi);
-		cpmac_write(priv->regs, CPMAC_RX_PTR(0), (u32)desc->mapping);
 		cpmac_write(priv->regs, CPMAC_RX_INT_ENABLE, 1);
 		return 0;
 	}
 
 	return 1;
+
+fatal_error:
+	/* Something went horribly wrong. Reset hardware to try to recover rather than wedging. */ 
+	
+	if (netif_msg_drv(priv)) {
+		printk(KERN_ERR "%s: cpmac_poll is confused. Resetting hardware\n", priv->dev->name);
+		cpmac_dump_all_desc(priv->dev);
+		printk(KERN_DEBUG "%s: RX_PTR(0)=0x%08x RX_ACK(0)=0x%08x\n",
+			priv->dev->name,
+			cpmac_read(priv->regs, CPMAC_RX_PTR(0)),
+			cpmac_read(priv->regs, CPMAC_RX_ACK(0)));
+	}
+
+	spin_unlock(&priv->rx_lock);
+	netif_rx_complete(priv->dev, napi);
+	netif_stop_queue(priv->dev);
+	napi_disable(&priv->napi);
+	
+	atomic_inc(&priv->reset_pending);
+	cpmac_hw_stop(priv->dev);
+	if (!schedule_work(&priv->reset_work))
+		atomic_dec(&priv->reset_pending);
+	return 0;
+ 
 }
 
 static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -456,6 +549,9 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	struct cpmac_desc *desc;
 	struct cpmac_priv *priv = netdev_priv(dev);
 
+	if (unlikely(atomic_read(&priv->reset_pending)))
+		return NETDEV_TX_BUSY;
+
 	if (unlikely(skb_padto(skb, ETH_ZLEN)))
 		return NETDEV_TX_OK;
 
@@ -621,8 +717,10 @@ static void cpmac_clear_rx(struct net_device *dev)
 			desc->dataflags = CPMAC_OWN;
 			dev->stats.rx_dropped++;
 		}
+		desc->hw_next = desc->next->mapping;
 		desc = desc->next;
 	}
+	priv->rx_head->prev->hw_next = 0;
 }
 
 static void cpmac_clear_tx(struct net_device *dev)
@@ -635,14 +733,14 @@ static void cpmac_clear_tx(struct net_device *dev)
 		priv->desc_ring[i].dataflags = 0;
 		if (priv->desc_ring[i].skb) {
 			dev_kfree_skb_any(priv->desc_ring[i].skb);
-			if (netif_subqueue_stopped(dev, i))
-			    netif_wake_subqueue(dev, i);
+			priv->desc_ring[i].skb = NULL;
 		}
 	}
 }
 
 static void cpmac_hw_error(struct work_struct *work)
 {
+	int i;
 	struct cpmac_priv *priv =
 		container_of(work, struct cpmac_priv, reset_work);
 
@@ -651,8 +749,47 @@ static void cpmac_hw_error(struct work_struct *work)
 	spin_unlock(&priv->rx_lock);
 	cpmac_clear_tx(priv->dev);
 	cpmac_hw_start(priv->dev);
-	napi_enable(&priv->napi);
-	netif_start_queue(priv->dev);
+	barrier();
+	atomic_dec(&priv->reset_pending);
+	
+	for (i = 0; i < CPMAC_QUEUES; i++) {
+		netif_wake_subqueue(priv->dev, i);
+	}
+	netif_wake_queue(priv->dev);
+	cpmac_write(priv->regs, CPMAC_MAC_INT_ENABLE, 3);
+}
+
+static void cpmac_check_status(struct net_device *dev)
+{
+	struct cpmac_priv *priv = netdev_priv(dev);
+
+	u32 macstatus = cpmac_read(priv->regs, CPMAC_MAC_STATUS);
+	int rx_channel = (macstatus >> 8) & 7;
+	int rx_code = (macstatus >> 12) & 15;
+	int tx_channel = (macstatus >> 16) & 7;
+	int tx_code = (macstatus >> 20) & 15;
+
+	if (rx_code || tx_code) {
+		if (netif_msg_drv(priv) && net_ratelimit()) {
+			/* Can't find any documentation on what these error codes actually are.
+			 * So just log them and hope..
+			 */
+			if (rx_code)
+				printk(KERN_WARNING "%s: host error %d on rx channel %d (macstatus %08x), resetting\n",
+				       dev->name, rx_code, rx_channel, macstatus);
+			if (tx_code)
+				printk(KERN_WARNING "%s: host error %d on tx channel %d (macstatus %08x), resetting\n",
+				       dev->name, tx_code, tx_channel, macstatus);
+		}
+		
+		netif_stop_queue(dev);
+		cpmac_hw_stop(dev);
+		if (schedule_work(&priv->reset_work))
+			atomic_inc(&priv->reset_pending);
+		if (unlikely(netif_msg_hw(priv)))
+			cpmac_dump_regs(dev);
+	}
+	cpmac_write(priv->regs, CPMAC_MAC_INT_CLEAR, 0xff);
 }
 
 static irqreturn_t cpmac_irq(int irq, void *dev_id)
@@ -683,49 +820,33 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id)
 
 	cpmac_write(priv->regs, CPMAC_MAC_EOI_VECTOR, 0);
 
-	if (unlikely(status & (MAC_INT_HOST | MAC_INT_STATUS))) {
-		if (netif_msg_drv(priv) && net_ratelimit())
-			printk(KERN_ERR "%s: hw error, resetting...\n",
-			       dev->name);
-		netif_stop_queue(dev);
-		napi_disable(&priv->napi);
-		cpmac_hw_stop(dev);
-		schedule_work(&priv->reset_work);
-		if (unlikely(netif_msg_hw(priv)))
-			cpmac_dump_regs(dev);
-	}
+	if (unlikely(status & (MAC_INT_HOST | MAC_INT_STATUS)))
+		cpmac_check_status(dev);
 
 	return IRQ_HANDLED;
 }
 
 static void cpmac_tx_timeout(struct net_device *dev)
 {
-	struct cpmac_priv *priv = netdev_priv(dev);
 	int i;
+	struct cpmac_priv *priv = netdev_priv(dev);
 
 	spin_lock(&priv->lock);
 	dev->stats.tx_errors++;
 	spin_unlock(&priv->lock);
 	if (netif_msg_tx_err(priv) && net_ratelimit())
 		printk(KERN_WARNING "%s: transmit timeout\n", dev->name);
-	/* 
-	 * FIXME: waking up random queue is not the best thing to
-	 * do... on the other hand why we got here at all?
-	 */
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
-	for (i = 0; i < CPMAC_QUEUES; i++)
-		if (priv->desc_ring[i].skb) {
-			priv->desc_ring[i].dataflags = 0;
-			dev_kfree_skb_any(priv->desc_ring[i].skb);
-			netif_wake_subqueue(dev, i);
-			break;
-		}
-#else
-	priv->desc_ring[0].dataflags = 0;
-	if (priv->desc_ring[0].skb)
-		dev_kfree_skb_any(priv->desc_ring[0].skb);
-	netif_wake_queue(dev);
-#endif
+
+	atomic_inc(&priv->reset_pending);
+	barrier();
+	cpmac_clear_tx(dev);
+	barrier();
+	atomic_dec(&priv->reset_pending);
+
+	netif_wake_queue(priv->dev);
+	for (i = 0; i < CPMAC_QUEUES; i++) {
+		netif_wake_subqueue(dev, i);
+	}
 }
 
 static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
@@ -815,7 +936,8 @@ static void cpmac_adjust_link(struct net_device *dev)
 	int new_state = 0;
 
 	spin_lock(&priv->lock);
-	if (priv->phy->link) {
+	if (1 /* priv->phy->link */ ) {
+		netif_carrier_on(dev);
 		netif_start_queue(dev);
 		if (priv->phy->duplex != priv->oldduplex) {
 			new_state = 1;
@@ -827,11 +949,11 @@ static void cpmac_adjust_link(struct net_device *dev)
 			priv->oldspeed = priv->phy->speed;
 		}
 
-		if (!priv->oldlink) {
+		/*if (!priv->oldlink) {
 			new_state = 1;
-			priv->oldlink = 1;
+			priv->oldlink = 1;*/
 			netif_schedule(dev);
-		}
+		/*}*/
 	} else if (priv->oldlink) {
 		netif_stop_queue(dev);
 		new_state = 1;
@@ -901,9 +1023,12 @@ static int cpmac_open(struct net_device *dev)
 		desc->buflen = CPMAC_SKB_SIZE;
 		desc->dataflags = CPMAC_OWN;
 		desc->next = &priv->rx_head[(i + 1) % priv->ring_size];
+		desc->next->prev = desc;
 		desc->hw_next = (u32)desc->next->mapping;
 	}
 
+	priv->rx_head->prev->hw_next = (u32)0;
+
 	if ((res = request_irq(dev->irq, cpmac_irq, IRQF_SHARED,
 			       dev->name, dev))) {
 		if (netif_msg_drv(priv))
@@ -912,6 +1037,7 @@ static int cpmac_open(struct net_device *dev)
 		goto fail_irq;
 	}
 
+	atomic_set(&priv->reset_pending, 0);
 	INIT_WORK(&priv->reset_work, cpmac_hw_error);
 	cpmac_hw_start(dev);
 
@@ -988,7 +1114,7 @@ static int external_switch;
 static int __devinit cpmac_probe(struct platform_device *pdev)
 {
 	int rc, phy_id, i;
-	char *mdio_bus_id = "0";
+	int mdio_bus_id = cpmac_mii.id;
 	struct resource *mem;
 	struct cpmac_priv *priv;
 	struct net_device *dev;
@@ -1007,21 +1133,10 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 
 	if (phy_id == PHY_MAX_ADDR) {
 		if (external_switch || dumb_switch) {
-			struct fixed_phy_status status = {};
-
-			/*
-			 * FIXME: this should be in the platform code!
-			 * Since there is not platform code at all (that is,
-			 * no mainline users of that driver), place it here
-			 * for now.
-			 */
-			phy_id = 0;
-			status.link = 1;
-			status.duplex = 1;
-			status.speed = 100;
-			fixed_phy_add(PHY_POLL, phy_id, &status);
+			mdio_bus_id = 0; /* fixed phys bus */
+			phy_id = pdev->id;
 		} else {
-			printk(KERN_ERR "cpmac: no PHY present\n");
+			dev_err(&pdev->dev, "no PHY present\n");
 			return -ENODEV;
 		}
 	}
@@ -1064,9 +1179,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 	priv->msg_enable = netif_msg_init(debug_level, 0xff);
 	memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
 
-	snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
-
-	priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
+	priv->phy = phy_connect(dev, cpmac_mii.phy_map[phy_id]->dev.bus_id, &cpmac_adjust_link, 0,
 				PHY_INTERFACE_MODE_MII);
 	if (IS_ERR(priv->phy)) {
 		if (netif_msg_drv(priv))
@@ -1104,7 +1217,6 @@ static int __devexit cpmac_remove(struct platform_device *pdev)
 
 static struct platform_driver cpmac_driver = {
 	.driver.name = "cpmac",
-	.driver.owner = THIS_MODULE,
 	.probe = cpmac_probe,
 	.remove = __devexit_p(cpmac_remove),
 };
@@ -1143,7 +1255,6 @@ int __devinit cpmac_init(void)
 	}
 
 	cpmac_mii.phy_mask = ~(mask | 0x80000000);
-	snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "0");
 
 	res = mdiobus_register(&cpmac_mii);
 	if (res)

From ralf@linux-mips.org Sun May  4 18:14:11 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 18:14:14 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:54923 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28584756AbYEDROL (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 4 May 2008 18:14:11 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m44HE5Um001617;
	Sun, 4 May 2008 18:14:05 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m44HE3xe001604;
	Sun, 4 May 2008 18:14:03 +0100
Date:	Sun, 4 May 2008 18:14:03 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Matteo Croce <matteo@openwrt.org>
Cc:	Andrew Morton <akpm@linux-foundation.org>,
	Jeff Garzik <jgarzik@pobox.com>,
	Felix Fietkau <nbd@openwrt.org>,
	Eugene Konev <ejka@imfi.kspu.ru>, linux-mips@linux-mips.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH]: cpmac bugfixes and enhancements
Message-ID: <20080504171403.GB30417@linux-mips.org>
References: <200805041904.22726.matteo@openwrt.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200805041904.22726.matteo@openwrt.org>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19098
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 263
Lines: 12

On Sun, May 04, 2008 at 07:04:22PM +0200, Matteo Croce wrote:

> and other small fixes.
> 
> please apply
> 
> Signed-off-by: Matteo Croce <matteo@openwrt.org>
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf

From ralf@linux-mips.org Sun May  4 18:15:56 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 18:15:59 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:23275 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28598133AbYEDRPz (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 4 May 2008 18:15:55 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m44HFiPf002304;
	Sun, 4 May 2008 18:15:44 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m44HFiwi002297;
	Sun, 4 May 2008 18:15:44 +0100
Date:	Sun, 4 May 2008 18:15:44 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Adrian Bunk <bunk@kernel.org>
Cc:	Roman Zippel <zippel@linux-m68k.org>, linux-mips@linux-mips.org,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [2.6 patch] mips/emma2rh/markeins/setup.c build fix
Message-ID: <20080504171544.GC30417@linux-mips.org>
References: <20080504165850.GM5838@cs181133002.pp.htv.fi>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080504165850.GM5838@cs181133002.pp.htv.fi>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19099
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 442
Lines: 12

On Sun, May 04, 2008 at 07:58:54PM +0300, Adrian Bunk wrote:
> From: Adrian Bunk <bunk@kernel.org>
> Date: Sun, 4 May 2008 19:58:54 +0300
> To: Roman Zippel <zippel@linux-m68k.org>, ralf@linux-mips.org
> Cc: linux-mips@linux-mips.org, Andrew Morton <akpm@linux-foundation.org>,
> 	linux-kernel@vger.kernel.org
> Subject: [2.6 patch] mips/emma2rh/markeins/setup.c build fix
> Content-Type: text/plain; charset=utf-8

Thanks, applied.

   Ralf

From ralf@linux-mips.org Sun May  4 22:58:44 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 22:58:46 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:57805 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20048428AbYEDV6o (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 4 May 2008 22:58:44 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m44LwcAr011294;
	Sun, 4 May 2008 22:58:38 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m44LwbMO011293;
	Sun, 4 May 2008 22:58:37 +0100
Date:	Sun, 4 May 2008 22:58:37 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH] Fix __fls for non mips32/mips64 cpus
Message-ID: <20080504215837.GA10198@linux-mips.org>
References: <20080503222502.52F3BFAB11@solo.franken.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080503222502.52F3BFAB11@solo.franken.de>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19100
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 380
Lines: 11

On Sun, May 04, 2008 at 12:25:02AM +0200, Thomas Bogendoerfer wrote:

> Only MIPS32 and MIPS64 CPUs implement clz/dclz. Therefore don't
> export __ilog2() for non MIPS32/MIPS64 cpus and use generic
> __fls bitop code for these cpus.
> 
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

Applied, thanks.  I committed a followup patch to get rid of __ilog2.

  Ralf

From tsbogend@alpha.franken.de Sun May  4 23:08:13 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 04 May 2008 23:08:16 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:1713 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S28585233AbYEDWIN (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 4 May 2008 23:08:13 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JsmNO-0002ZB-00; Mon, 05 May 2008 00:08:10 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 2F928C2BE5; Mon,  5 May 2008 00:08:04 +0200 (CEST)
Date:	Mon, 5 May 2008 00:08:04 +0200
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
Message-ID: <20080504220804.GA13442@alpha.franken.de>
References: <20080502101113.GA24408@linux-mips.org> <20080504.011647.93019265.anemo@mba.ocn.ne.jp> <20080503224849.GA2314@alpha.franken.de> <20080504.223944.41198532.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080504.223944.41198532.anemo@mba.ocn.ne.jp>
User-Agent: Mutt/1.5.13 (2006-08-11)
From:	tsbogend@alpha.franken.de (Thomas Bogendoerfer)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19101
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 673
Lines: 20

On Sun, May 04, 2008 at 10:39:44PM +0900, Atsushi Nemoto wrote:
> > +	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
> ...
> > +	while (!kstack_end(sp)) {
> > +		if (__get_user(addr, sp++)) {
> 
> This will leads a sparse warning since an argument for kstack_end is 'void *'.
> 
> 	while (!kstack_end((void *)(unsigned long)sp)) {
> 
> will make this part sparse-free, though it seems a bit ugly.

hmm, would leaving sp as unsigned long * and casting it for __get_user()
make sparse happy ?

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

From dm.n9107@gmail.com Mon May  5 09:30:26 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 05 May 2008 09:30:29 +0100 (BST)
Received: from yw-out-1718.google.com ([74.125.46.154]:27189 "EHLO
	yw-out-1718.google.com") by ftp.linux-mips.org with ESMTP
	id S28577966AbYEEIa0 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 5 May 2008 09:30:26 +0100
Received: by yw-out-1718.google.com with SMTP id 9so1222490ywk.24
        for <linux-mips@linux-mips.org>; Mon, 05 May 2008 01:30:14 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        bh=1vNwkNd0nYp80jvMF7wkf5IzXiIWL5OfoM0OUPtffOY=;
        b=LW2i4fqiGK0gDCkGKjTOsbBU+Dwt8Fk/Puzc3G3d+TuAFzVNSNkDvOUW3ljxGS0bD4lvTN9BQOd3llDmkw6JpgldgBPoDd2diPHrUmFrl58o7YPqzl7FBr1QHh/AYeY8mPUc4HxjGwlnKYpJz/lx3JG0kCa59Da38YXkuGcxxYU=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        b=BlZwLZDhJ5raNDFiSkTgDB/awo0JiLN32gBHWuJQe3aT3Y9IDI28CKeeb5iFJZ0+Qo0d82CJr1Jy55dYyWaBhYUlWppdyTfT/11R1T28fXMf/Pzb8hp6TTPbd+cljYrson/oULp/4V4fmo8n81+vA/Aay08Hg1bx44tYIJLGuH0=
Received: by 10.150.12.3 with SMTP id 3mr5778656ybl.17.1209976214383;
        Mon, 05 May 2008 01:30:14 -0700 (PDT)
Received: by 10.150.158.7 with HTTP; Mon, 5 May 2008 01:30:09 -0700 (PDT)
Message-ID: <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>
Date:	Mon, 5 May 2008 10:30:09 +0200
From:	DM <dm.n9107@gmail.com>
To:	"Ulrich Drepper" <drepper@redhat.com>
Subject: Re: [PATCH v2] unify sys_pipe implementation
Cc:	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org, sparclinux@vger.kernel.org,
	torvalds@linux-foundation.org
In-Reply-To: <200805031801.m43I109q032242@devserv.devel.redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <200805031801.m43I109q032242@devserv.devel.redhat.com>
Return-Path: <dm.n9107@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19102
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: dm.n9107@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 652
Lines: 26

On Sat, May 3, 2008 at 8:01 PM, Ulrich Drepper <drepper@redhat.com> wrote:
[...]
>   /*
>  + * sys_pipe() is the normal C calling standard for creating
>  + * a pipe. It's not the way Unix traditionally does this, though.
>  + */
>  +asmlinkage long sys_pipe(int __user *fildes)
>  +{
>  +       int fd[2];
>  +       int error;
>  +
>  +       error = do_pipe(fd);
>  +       if (!error) {
>  +               if (copy_to_user(fildes, fd, sizeof(fd)))
>  +                       error = -EFAULT;
>  +       }
>  +       return error;
>  +}
>  +
[...]

I realize this code is old, but wouldn't file descriptors leak if
copy_to_user fails?

BR,
dm.n9107

From mtk.linux.lists@gmail.com Mon May  5 10:15:57 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 05 May 2008 10:16:01 +0100 (BST)
Received: from fg-out-1718.google.com ([72.14.220.155]:19386 "EHLO
	fg-out-1718.google.com") by ftp.linux-mips.org with ESMTP
	id S20036616AbYEEJP5 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 5 May 2008 10:15:57 +0100
Received: by fg-out-1718.google.com with SMTP id d23so91195fga.32
        for <linux-mips@linux-mips.org>; Mon, 05 May 2008 02:15:53 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth;
        bh=yJHrhUWPm80nO9pg3l7+5CF9in2efx8o1cL5G3M2aIY=;
        b=TuVUwDepvr/y/ngeebB1kLyhvXWma1TBCDXyAnouPsHVXd8/alZw4h/eeOdfEVwfM1OXSKk9hqa1dQm3cV4Xh1HBFexb6DuptfByR/t1dNAR7VnjeqB0sOmDpz8OQTl6ih9LweabwEZUMC7Zux3YlWrhgxDuFZLdwnTObqzbXBQ=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth;
        b=kMGZpkyX+ewQQ2eYahy7WrEm2zS69ON+UQRxAa7Y7S/2hmm7yz5qF15E7eJKJOyRVJi1Y5tZMRIlt6O/WLtPa48g3w1iL0Bj64i6WvydC9kOmR8R7O0MIZFne6HJvzYzr2eDx14ePQBYc6DypZiRRFHfhF+PG/7U9Lx4yZoqGQI=
Received: by 10.86.90.13 with SMTP id n13mr10192966fgb.64.1209978953407;
        Mon, 05 May 2008 02:15:53 -0700 (PDT)
Received: by 10.86.71.16 with HTTP; Mon, 5 May 2008 02:15:53 -0700 (PDT)
Message-ID: <517f3f820805050215s689ae274yf8a4ad270cb5981c@mail.gmail.com>
Date:	Mon, 5 May 2008 11:15:53 +0200
From:	"Michael Kerrisk" <mtk.manpages@gmail.com>
To:	DM <dm.n9107@gmail.com>
Subject: Re: [PATCH v2] unify sys_pipe implementation
Cc:	"Ulrich Drepper" <drepper@redhat.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org, sparclinux@vger.kernel.org,
	torvalds@linux-foundation.org
In-Reply-To: <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <200805031801.m43I109q032242@devserv.devel.redhat.com>
	 <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>
X-Google-Sender-Auth: 4e80ca2b3fe2a603
Return-Path: <mtk.linux.lists@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19103
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: mtk.manpages@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 940
Lines: 33

On 5/5/08, DM <dm.n9107@gmail.com> wrote:
> On Sat, May 3, 2008 at 8:01 PM, Ulrich Drepper <drepper@redhat.com> wrote:
>  [...]
>
> >   /*
>  >  + * sys_pipe() is the normal C calling standard for creating
>  >  + * a pipe. It's not the way Unix traditionally does this, though.
>  >  + */
>  >  +asmlinkage long sys_pipe(int __user *fildes)
>  >  +{
>  >  +       int fd[2];
>  >  +       int error;
>  >  +
>  >  +       error = do_pipe(fd);
>  >  +       if (!error) {
>  >  +               if (copy_to_user(fildes, fd, sizeof(fd)))
>  >  +                       error = -EFAULT;
>  >  +       }
>  >  +       return error;
>  >  +}
>  >  +
>
> [...]
>
>  I realize this code is old, but wouldn't file descriptors leak if
>  copy_to_user fails?

Yes, it does -- I just tested this.

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

From ralf@linux-mips.org Mon May  5 11:18:22 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 05 May 2008 11:18:25 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:21146 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S28774040AbYEEKSW (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 5 May 2008 11:18:22 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m45AIAKV024516;
	Mon, 5 May 2008 11:18:10 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m45AI98a024509;
	Mon, 5 May 2008 11:18:09 +0100
Date:	Mon, 5 May 2008 11:18:09 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	DM <dm.n9107@gmail.com>
Cc:	Ulrich Drepper <drepper@redhat.com>, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, linux-mips@linux-mips.org,
	sparclinux@vger.kernel.org, torvalds@linux-foundation.org
Subject: Re: [PATCH v2] unify sys_pipe implementation
Message-ID: <20080505101809.GA14547@linux-mips.org>
References: <200805031801.m43I109q032242@devserv.devel.redhat.com> <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <5eeb9ad90805050130i39ae791dwe599c12fc08fb8ec@mail.gmail.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19104
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 819
Lines: 29

On Mon, May 05, 2008 at 10:30:09AM +0200, DM wrote:

> >  + * sys_pipe() is the normal C calling standard for creating
> >  + * a pipe. It's not the way Unix traditionally does this, though.
> >  + */
> >  +asmlinkage long sys_pipe(int __user *fildes)
> >  +{
> >  +       int fd[2];
> >  +       int error;
> >  +
> >  +       error = do_pipe(fd);
> >  +       if (!error) {
> >  +               if (copy_to_user(fildes, fd, sizeof(fd)))
> >  +                       error = -EFAULT;
> >  +       }
> >  +       return error;
> >  +}
> >  +
> [...]
> 
> I realize this code is old, but wouldn't file descriptors leak if
> copy_to_user fails?

The MIPS implementation doesn't have this problem; it returns the
file descriptors in the result registers $v0 and $v1.

But an interesting catch after so many years!

  Ralf

From sshtylyov@ru.mvista.com Mon May  5 11:40:45 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 05 May 2008 11:40:47 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:56467 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20040923AbYEEKkp (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 5 May 2008 11:40:45 +0100
Received: from [192.168.1.234] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id A87A53EC9; Mon,  5 May 2008 03:40:39 -0700 (PDT)
Message-ID: <481EE407.9080707@ru.mvista.com>
Date:	Mon, 05 May 2008 14:40:07 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH] Pb1000: bury the remnants of the PCI code
References: <200804052259.29959.sshtylyov@ru.mvista.com> <48176D09.7030308@ru.mvista.com> <20080429185333.GB14609@linux-mips.org>
In-Reply-To: <20080429185333.GB14609@linux-mips.org>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19105
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 600
Lines: 21

Hello.

Ralf Baechle wrote:

>>>PCI support for the Pb1000 board was ectomized by Pete Popov four years ago.
>>>Unfortunately,  the header file  wasn't cleansed, so the remnants still get
>>>in the way of the kernel build (due to macro redefinitions).

>>>Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

>>   Hm looks like I have somehow missed the remanants in 
>>arch/mips/au1000/pb1000/board_setup.c... too bad that this patch has been 
>>long merged. :-/

> New patch, new luck ;-)

    I have posted the new patch but the luck (or lack thereof) is the same. ;-)

>   Ralf

WBR, Sergei

From anemo@mba.ocn.ne.jp Mon May  5 15:57:25 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 05 May 2008 15:57:28 +0100 (BST)
Received: from mba.ocn.ne.jp ([122.1.235.107]:45791 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S28776895AbYEEO5Z (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 5 May 2008 15:57:25 +0100
Received: from localhost (p6218-ipad309funabasi.chiba.ocn.ne.jp [123.217.200.218])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 42B93AD48; Mon,  5 May 2008 23:57:19 +0900 (JST)
Date:	Mon, 05 May 2008 23:58:27 +0900 (JST)
Message-Id: <20080505.235827.93020396.anemo@mba.ocn.ne.jp>
To:	tsbogend@alpha.franken.de
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <20080504220804.GA13442@alpha.franken.de>
References: <20080503224849.GA2314@alpha.franken.de>
	<20080504.223944.41198532.anemo@mba.ocn.ne.jp>
	<20080504220804.GA13442@alpha.franken.de>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19106
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
Content-Length: 2547
Lines: 64

On Mon, 5 May 2008 00:08:04 +0200, tsbogend@alpha.franken.de (Thomas Bogendoerfer) wrote:
> > 	while (!kstack_end((void *)(unsigned long)sp)) {
> > 
> > will make this part sparse-free, though it seems a bit ugly.
> 
> hmm, would leaving sp as unsigned long * and casting it for __get_user()
> make sparse happy ?

Well, not as expected...  Here is some warning patterns.

1.	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
	...
	while (!kstack_end(sp)) {
		if (__get_user(addr, sp++)) {

linux/arch/mips/kernel/traps.c:91:21: warning: incorrect type in argument 1 (different address spaces)
linux/arch/mips/kernel/traps.c:91:21:    expected void *addr
linux/arch/mips/kernel/traps.c:91:21:    got unsigned long [noderef] <asn:1>*sp

2.	unsigned long *sp = (unsigned long *)(reg29 & ~3);
	...
	while (!kstack_end(sp)) {
		if (__get_user(addr, (unsigned long __user *)sp++)) {

linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to expression (<asn:1>)

3.	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
	...
	while (!kstack_end((void *)(unsigned long)sp)) {
		if (__get_user(addr, sp++)) {

No warnings.

4.	unsigned long *sp = (unsigned long *)(reg29 & ~3);
	...
	while (!kstack_end(sp)) {
		unsigned long __user *p = (unsigned long __user *)sp++;
		if (__get_user(addr, p)) {

linux/arch/mips/kernel/traps.c:92:30: warning: cast adds address space to expression (<asn:1>)

4.	unsigned long *sp = (unsigned long *)(reg29 & ~3);
	...
	while (!kstack_end(sp)) {
		unsigned long __user *p =
			(unsigned long __user *)(unsigned long)sp++;
		if (__get_user(addr, p)) {

No warnings.


I think the "cast adds address space to expression" sparse warning is
not worth to handle so seriously.  So I'm OK with any of (2) to (4).

---
Atsushi Nemoto

From akpm@linux-foundation.org Tue May  6 00:17:23 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 00:17:26 +0100 (BST)
Received: from smtp1.linux-foundation.org ([140.211.169.13]:62096 "EHLO
	smtp1.linux-foundation.org") by ftp.linux-mips.org with ESMTP
	id S20022420AbYEEXRX (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 6 May 2008 00:17:23 +0100
Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55])
	by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id m45NGaKq031412
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Mon, 5 May 2008 16:16:37 -0700
Received: from akpm.corp.google.com (localhost [127.0.0.1])
	by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with SMTP id m45NGY4K010330;
	Mon, 5 May 2008 16:16:34 -0700
Date:	Mon, 5 May 2008 16:16:34 -0700
From:	Andrew Morton <akpm@linux-foundation.org>
To:	Matteo Croce <matteo@openwrt.org>
Cc:	jgarzik@pobox.com, ralf@linux-mips.org, nbd@openwrt.org,
	ejka@imfi.kspu.ru, linux-mips@linux-mips.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH]: cpmac bugfixes and enhancements
Message-Id: <20080505161634.6964d46b.akpm@linux-foundation.org>
In-Reply-To: <200805041904.22726.matteo@openwrt.org>
References: <200805041904.22726.matteo@openwrt.org>
X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.20; i486-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-MIMEDefang-Filter: lf$Revision: 1.188 $
X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13
Return-Path: <akpm@linux-foundation.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19107
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: akpm@linux-foundation.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1632
Lines: 50

On Sun, 4 May 2008 19:04:22 +0200
Matteo Croce <matteo@openwrt.org> wrote:

> This patch fixes an IRQ storm, a locking issues, moves platform code in the right sections
> and other small fixes.
> 

Please feed this patch (and all future ones) through scripts/checkpatch.pl.
It picks up rather a lot of simple problems which there is no reason for
us to retain.

>
> ...
>
> +	spin_unlock(&priv->rx_lock);
> +	netif_rx_complete(priv->dev, napi);
> +	netif_stop_queue(priv->dev);
> +	napi_disable(&priv->napi);
> +	
> +	atomic_inc(&priv->reset_pending);
> +	cpmac_hw_stop(priv->dev);
> +	if (!schedule_work(&priv->reset_work))
> +		atomic_dec(&priv->reset_pending);
> +	return 0;
> + 
>  }
>  
>  static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
> @@ -456,6 +549,9 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	struct cpmac_desc *desc;
>  	struct cpmac_priv *priv = netdev_priv(dev);
>  
> +	if (unlikely(atomic_read(&priv->reset_pending)))
> +		return NETDEV_TX_BUSY;
> +

This looks a bit strange.  schedule_work() will return zero if the work was
already scheduled, in which case we arrange for cpmac_start_xmit() to abort
early.

But if schedule_work() *doesn't* return zero, there is a time window in
which the reset is still pending.  Because it takes time for keventd to be
awoken and to run the work function.

I would have thought that we would want to prevent cpmac_start_xmit() from
running within that time window also?


But that's just a guess - the text which you used to describe your work is
missing much information, so I don't have a lot to work with here.

From ths@networkno.de Tue May  6 11:21:25 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 11:21:29 +0100 (BST)
Received: from relay01.mx.bawue.net ([193.7.176.67]:39392 "EHLO
	relay01.mx.bawue.net") by ftp.linux-mips.org with ESMTP
	id S28591803AbYEFKVZ (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 6 May 2008 11:21:25 +0100
Received: from lagash (88-106-226-17.dynamic.dsl.as9105.com [88.106.226.17])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	by relay01.mx.bawue.net (Postfix) with ESMTP id 848DE48916;
	Tue,  6 May 2008 12:21:23 +0200 (CEST)
Received: from ths by lagash with local (Exim 4.69)
	(envelope-from <ths@networkno.de>)
	id 1JtKIU-0002WH-5E; Tue, 06 May 2008 11:21:22 +0100
Date:	Tue, 6 May 2008 11:21:22 +0100
From:	Thiemo Seufer <ths@networkno.de>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org
Subject: fix warning message on SMP kernels
Message-ID: <20080506102122.GE22413@networkno.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
Return-Path: <ths@networkno.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19108
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: ths@networkno.de
Precedence: bulk
X-list: linux-mips
Content-Length: 609
Lines: 20

This patch fixes a (harmless) warning message.


Signed-off-by: Thiemo Seufer <ths@networkno.de>

Index: linux.git/arch/mips/kernel/smp.c
===================================================================
--- linux.git.orig/arch/mips/kernel/smp.c	2008-05-06 11:06:07.000000000 +0100
+++ linux.git/arch/mips/kernel/smp.c	2008-05-06 11:15:02.000000000 +0100
@@ -87,8 +87,8 @@
 
 __cpuinit void register_smp_ops(struct plat_smp_ops *ops)
 {
-	if (ops)
-		printk(KERN_WARNING "Overriding previous set SMP ops\n");
+	if (mp_ops)
+		printk(KERN_WARNING "Overriding previously set SMP ops\n");
 
 	mp_ops = ops;
 }

From ths@networkno.de Tue May  6 11:23:37 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 11:23:40 +0100 (BST)
Received: from relay01.mx.bawue.net ([193.7.176.67]:57574 "EHLO
	relay01.mx.bawue.net") by ftp.linux-mips.org with ESMTP
	id S20024637AbYEFKXh (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 6 May 2008 11:23:37 +0100
Received: from lagash (88-106-226-17.dynamic.dsl.as9105.com [88.106.226.17])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	by relay01.mx.bawue.net (Postfix) with ESMTP id 902CA48916;
	Tue,  6 May 2008 12:23:34 +0200 (CEST)
Received: from ths by lagash with local (Exim 4.69)
	(envelope-from <ths@networkno.de>)
	id 1JtKKb-0002Wi-QO; Tue, 06 May 2008 11:23:33 +0100
Date:	Tue, 6 May 2008 11:23:33 +0100
From:	Thiemo Seufer <ths@networkno.de>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org
Subject: Fix build failure in mips oprofile code
Message-ID: <20080506102333.GF22413@networkno.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
Return-Path: <ths@networkno.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19109
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: ths@networkno.de
Precedence: bulk
X-list: linux-mips
Content-Length: 1196
Lines: 37

This patch fixes a warning-as-error induced build failure of
64bit mips kernels.


Signed-off-by: Thiemo Seufer <ths@networkno.de>

Index: linux.git/arch/mips/oprofile/op_model_mipsxx.c
===================================================================
--- linux.git.orig/arch/mips/oprofile/op_model_mipsxx.c	2008-05-06 11:06:07.000000000 +0100
+++ linux.git/arch/mips/oprofile/op_model_mipsxx.c	2008-05-06 11:15:32.000000000 +0100
@@ -281,7 +281,7 @@
 
 static void reset_counters(void *arg)
 {
-	int counters = (int)arg;
+	int counters = (int)(long)arg;
 	switch (counters) {
 	case 4:
 		w_c0_perfctrl3(0);
@@ -313,7 +313,7 @@
 	if (!cpu_has_mipsmt_pertccounters)
 		counters = counters_total_to_per_cpu(counters);
 #endif
-	on_each_cpu(reset_counters, (void *)counters, 0, 1);
+	on_each_cpu(reset_counters, (void *)(long)counters, 0, 1);
 
 	op_model_mipsxx_ops.num_counters = counters;
 	switch (current_cpu_type()) {
@@ -382,7 +382,7 @@
 	int counters = op_model_mipsxx_ops.num_counters;
 
 	counters = counters_per_cpu_to_total(counters);
-	on_each_cpu(reset_counters, (void *)counters, 0, 1);
+	on_each_cpu(reset_counters, (void *)(long)counters, 0, 1);
 
 	perf_irq = save_perf_irq;
 }

From mano@roarinelk.homelinux.net Tue May  6 19:15:06 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 19:15:09 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:1433 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20024837AbYEFSPG (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 6 May 2008 19:15:06 +0100
Received: (qmail 9356 invoked by uid 1000); 6 May 2008 20:15:04 +0200
Date:	Tue, 6 May 2008 20:15:04 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org
Subject: [RFT] au1xmmc: remove board-specific code
Message-ID: <20080506181504.GA9294@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19110
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 623
Lines: 18

Hello,

I received a new Au1200 based toy on which the current driver-implemented
SD card-detect scheme doesn't work.  However since this toy does have a 
dedicated SD carddetect IRQ and card status bits, I took the opportunity
to get rid of the DB1200 specific parts in the driver and added callbacks
for platform/board-specific carddetect and voltage setting methods.

What I need is feedback from testers with access to db1200/pb1200 boards:
The patch below (+ boardstuff) works on my board but I'm not sure if
I got the carddetect poll timer for the db1200 right.

Please test and comment!

Thanks!
	Manuel Lauss

--- 

From fd0021032494ad61f36558f1760391f715c05e97 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mano@scarran.local>
Date: Tue, 6 May 2008 20:03:24 +0200
Subject: [PATCH] au1xmmc updates
Content-Length: 35915
Lines: 1313

- export get_au1x00_speed() for modules
- move DB/PB1200 specific functions out of the driver to the board code,
  wrap them in a structure and pass them to the driver via platform_data.
- code style changes
- hook up the SDIO irq
---
 arch/mips/au1000/common/clocks.c          |    2 +-
 arch/mips/au1000/common/platform.c        |   32 --
 arch/mips/au1000/pb1200/platform.c        |  127 +++++++-
 drivers/mmc/host/au1xmmc.c                |  573 +++++++++++++++++------------
 drivers/mmc/host/au1xmmc.h                |   96 -----
 include/asm-mips/mach-au1x00/au1100_mmc.h |   43 ++-
 6 files changed, 501 insertions(+), 372 deletions(-)
 delete mode 100644 drivers/mmc/host/au1xmmc.h

diff --git a/arch/mips/au1000/common/clocks.c b/arch/mips/au1000/common/clocks.c
index 3ce6cac..6dbc87a 100644
--- a/arch/mips/au1000/common/clocks.c
+++ b/arch/mips/au1000/common/clocks.c
@@ -46,7 +46,7 @@ unsigned int get_au1x00_speed(void)
 {
 	return au1x00_clock;
 }
-
+EXPORT_SYMBOL(get_au1x00_speed);
 
 
 /*
diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
index 31d2a22..08a5900 100644
--- a/arch/mips/au1000/common/platform.c
+++ b/arch/mips/au1000/common/platform.c
@@ -162,24 +162,6 @@ static struct resource au1xxx_usb_gdt_resources[] = {
 	},
 };
 
-static struct resource au1xxx_mmc_resources[] = {
-	[0] = {
-		.start          = SD0_PHYS_ADDR,
-		.end            = SD0_PHYS_ADDR + 0x40,
-		.flags          = IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= SD1_PHYS_ADDR,
-		.end 		= SD1_PHYS_ADDR + 0x40,
-		.flags		= IORESOURCE_MEM,
-	},
-	[2] = {
-		.start          = AU1200_SD_INT,
-		.end            = AU1200_SD_INT,
-		.flags          = IORESOURCE_IRQ,
-	}
-};
-
 static u64 udc_dmamask = ~(u32)0;
 
 static struct platform_device au1xxx_usb_gdt_device = {
@@ -245,19 +227,6 @@ static struct platform_device au1200_lcd_device = {
 	.num_resources  = ARRAY_SIZE(au1200_lcd_resources),
 	.resource       = au1200_lcd_resources,
 };
-
-static u64 au1xxx_mmc_dmamask =  ~(u32)0;
-
-static struct platform_device au1xxx_mmc_device = {
-	.name = "au1xxx-mmc",
-	.id = 0,
-	.dev = {
-		.dma_mask               = &au1xxx_mmc_dmamask,
-		.coherent_dma_mask      = 0xffffffff,
-	},
-	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
-	.resource       = au1xxx_mmc_resources,
-};
 #endif /* #ifdef CONFIG_SOC_AU1200 */
 
 static struct platform_device au1x00_pcmcia_device = {
@@ -295,7 +264,6 @@ static struct platform_device *au1xxx_platform_devices[] __initdata = {
 	&au1xxx_usb_gdt_device,
 	&au1xxx_usb_otg_device,
 	&au1200_lcd_device,
-	&au1xxx_mmc_device,
 #endif
 #ifdef SMBUS_PSC_BASE
 	&pbdb_smbus_device,
diff --git a/arch/mips/au1000/pb1200/platform.c b/arch/mips/au1000/pb1200/platform.c
index 5930110..bee2bf7 100644
--- a/arch/mips/au1000/pb1200/platform.c
+++ b/arch/mips/au1000/pb1200/platform.c
@@ -20,8 +20,17 @@
 
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/mmc/host.h>
 
 #include <asm/mach-au1x00/au1xxx.h>
+#include <asm/mach-au1x00/au1xxx_dbdma.h>
+#include <asm/mach-au1x00/au1100_mmc.h>
+
+#if defined(CONFIG_MIPS_PB1200)
+#include <asm/mach-pb1x00/pb1200.h>
+#elif defined(CONFIG_MIPS_DB1200)
+#include <asm/mach-db1x00/db1200.h>
+#endif
 
 static struct resource ide_resources[] = {
 	[0] = {
@@ -70,9 +79,125 @@ static struct platform_device smc91c111_device = {
 	.resource	= smc91c111_resources
 };
 
+
+static const struct {
+	u16 bcsrpwr;
+	u16 bcsrstatus;
+	u16 wpstatus;
+} au1xmmc_card_table[] = {
+	{ BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
+#ifndef CONFIG_MIPS_DB1200
+	{ BCSR_BOARD_SD1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
+#endif
+};
+
+static void pb1200mmc_set_power(void *mmc_host, int state)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
+
+	bcsr->board &= ~val;
+	if (state)
+		bcsr->board |= val;
+
+	au_sync_delay(1);
+}
+
+static int pb1200mmc_card_readonly(void *mmc_host)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus) ? 1 : 0;
+}
+
+static int pb1200mmc_card_inserted(void *mmc_host)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
+		? 1 : 0;
+}
+
+static struct au1xmmc_platdata db1xmmcpd = {
+	.set_power	= pb1200mmc_set_power,
+	.card_inserted	= pb1200mmc_card_inserted,
+	.card_readonly	= pb1200mmc_card_readonly,
+	.cd_setup	= NULL,		/* use poll-timer in driver */
+};
+
+static u64 au1xxx_mmc_dmamask =  ~(u32)0;
+
+struct resource au1200sd0_res[] = {
+	[0] = {
+		.start	= CPHYSADDR(SD0_BASE),
+		.end	= CPHYSADDR(SD0_BASE) + 0x40,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AU1200_SD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[3] = {
+		.start	= DSCR_CMD0_SDMS_TX0,
+		.flags	= IORESOURCE_DMA,
+	},
+	[4] = {
+		.start	= DSCR_CMD0_SDMS_RX0,
+		.flags	= IORESOURCE_DMA,
+	},
+};
+
+static struct platform_device au1xxx_sd0_device = {
+	.name = "au1xxx-mmc",
+	.id = 0,	/* index into au1xmmc_card_table[] */
+	.dev = {
+		.dma_mask               = &au1xxx_mmc_dmamask,
+		.coherent_dma_mask      = 0xffffffff,
+		.platform_data		= &db1xmmcpd,
+	},
+	.num_resources  = ARRAY_SIZE(au1200sd0_res),
+	.resource       = au1200sd0_res,
+};
+
+#ifndef CONFIG_MIPS_DB1200
+struct resource au1200sd1_res[] = {
+	[0] = {
+		.start	= CPHYSADDR(SD1_BASE),
+		.end	= CPHYSADDR(SD1_BASE) + 0xff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AU1200_SD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[3] = {
+		.start	= DSCR_CMD0_SDMS_TX1,
+		.flags	= IORESOURCE_DMA,
+	},
+	[4] = {
+		.start	= DSCR_CMD0_SDMS_RX1,
+		.flags	= IORESOURCE_DMA,
+	},
+};
+
+static struct platform_device au1xxx_sd1_device = {
+	.name = "au1xxx-mmc",
+	.id = 1,	/* index into au1xmmc_card_table[] */
+	.dev = {
+		.dma_mask               = &au1xxx_mmc_dmamask,
+		.coherent_dma_mask      = 0xffffffff,
+		.platform_data		= &db1xmmcpd,
+	},
+	.num_resources  = ARRAY_SIZE(au1200sd1_res),
+	.resource       = au1200sd1_res,
+};
+#endif
+
 static struct platform_device *board_platform_devices[] __initdata = {
 	&ide_device,
-	&smc91c111_device
+	&smc91c111_device,
+	&au1xxx_sd0_device,
+#ifndef CONFIG_MIPS_DB1200
+	&au1xxx_sd1_device,
+#endif
 };
 
 static int __init board_register_devices(void)
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index cc5f7bc..da62bd2 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -49,7 +49,6 @@
 #include <asm/mach-au1x00/au1100_mmc.h>
 
 #include <au1xxx.h>
-#include "au1xmmc.h"
 
 #define DRIVER_NAME "au1xxx-mmc"
 
@@ -61,31 +60,71 @@
 #define DBG(fmt, idx, args...)
 #endif
 
-const struct {
-	u32 iobase;
-	u32 tx_devid, rx_devid;
-	u16 bcsrpwr;
-	u16 bcsrstatus;
-	u16 wpstatus;
-} au1xmmc_card_table[] = {
-	{ SD0_BASE, DSCR_CMD0_SDMS_TX0, DSCR_CMD0_SDMS_RX0,
-	  BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
-#ifndef CONFIG_MIPS_DB1200
-	{ SD1_BASE, DSCR_CMD0_SDMS_TX1, DSCR_CMD0_SDMS_RX1,
-	  BCSR_BOARD_DS1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
+#define AU1XMMC_DESCRIPTOR_COUNT 1
+#define AU1XMMC_DESCRIPTOR_SIZE  2048
+
+#define AU1XMMC_OCR ( MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
+		      MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
+		      MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
+
+/* Easy access macros */
+
+#define HOST_STATUS(h)	((h)->iobase + SD_STATUS)
+#define HOST_CONFIG(h)	((h)->iobase + SD_CONFIG)
+#define HOST_ENABLE(h)	((h)->iobase + SD_ENABLE)
+#define HOST_TXPORT(h)	((h)->iobase + SD_TXPORT)
+#define HOST_RXPORT(h)	((h)->iobase + SD_RXPORT)
+#define HOST_CMDARG(h)	((h)->iobase + SD_CMDARG)
+#define HOST_BLKSIZE(h)	((h)->iobase + SD_BLKSIZE)
+#define HOST_CMD(h)	((h)->iobase + SD_CMD)
+#define HOST_CONFIG2(h)	((h)->iobase + SD_CONFIG2)
+#define HOST_TIMEOUT(h)	((h)->iobase + SD_TIMEOUT)
+#define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
+
+#define DMA_CHANNEL(h) \
+	( ((h)->flags & HOST_F_XMIT) ? (h)->dma.tx_chan : (h)->dma.rx_chan)
+
+/* This gives us a hard value for the stop command that we can write directly
+ * to the command register
+ */
+
+#define STOP_CMD (SD_CMD_RT_1B|SD_CMD_CT_7|(0xC << SD_CMD_CI_SHIFT)|SD_CMD_GO)
+
+/* This is the set of interrupts that we configure by default */
+
+#if 0
+#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | SD_CONFIG_DD | \
+		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
 #endif
-};
 
-#define AU1XMMC_CONTROLLER_COUNT (ARRAY_SIZE(au1xmmc_card_table))
+#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | \
+		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
+/* The poll event (looking for insert/remove events runs twice a second */
+#define AU1XMMC_DETECT_TIMEOUT (HZ/2)
+
+/* Status flags used by the host structure */
+#define HOST_F_XMIT   0x0001
+#define HOST_F_RECV   0x0002
+#define HOST_F_DMA    0x0010
+#define HOST_F_ACTIVE 0x0100
+#define HOST_F_STOP   0x1000
+
+#define HOST_S_IDLE   0x0001
+#define HOST_S_CMD    0x0002
+#define HOST_S_DATA   0x0003
+#define HOST_S_STOP   0x0004
 
-/* This array stores pointers for the hosts (used by the IRQ handler) */
-struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
 static int dma = 1;
 
-#ifdef MODULE
 module_param(dma, bool, 0);
 MODULE_PARM_DESC(dma, "Use DMA engine for data transfers (0 = disabled)");
-#endif
+
+/* 8bit memory device */
+static dbdev_tab_t au1xmmc_mem_dbdev = {
+	DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 8, 0x00000000, 0, 0
+};
+static int memid = 0;
+
 
 static inline void IRQ_ON(struct au1xmmc_host *host, u32 mask)
 {
@@ -119,14 +158,13 @@ static inline void IRQ_OFF(struct au1xmmc_host *host, u32 mask)
 
 static inline void SEND_STOP(struct au1xmmc_host *host)
 {
-
-	/* We know the value of CONFIG2, so avoid a read we don't need */
-	u32 mask = SD_CONFIG2_EN;
+	u32 config2;
 
 	WARN_ON(host->status != HOST_S_DATA);
 	host->status = HOST_S_STOP;
 
-	au_writel(mask | SD_CONFIG2_DF, HOST_CONFIG2(host));
+	config2 = au_readl(HOST_CONFIG2(host));
+	au_writel(config2 | SD_CONFIG2_DF, HOST_CONFIG2(host));
 	au_sync();
 
 	/* Send the stop commmand */
@@ -135,31 +173,37 @@ static inline void SEND_STOP(struct au1xmmc_host *host)
 
 static void au1xmmc_set_power(struct au1xmmc_host *host, int state)
 {
-
-	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
-
-	bcsr->board &= ~val;
-	if (state) bcsr->board |= val;
-
-	au_sync_delay(1);
+	if (host->platdata && host->platdata->set_power)
+		host->platdata->set_power(host->mmc, state);
 }
 
-static inline int au1xmmc_card_inserted(struct au1xmmc_host *host)
+static int au1xmmc_card_inserted(struct au1xmmc_host *host)
 {
-	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
-		? 1 : 0;
+	int ret;
+
+	if (host->platdata && host->platdata->card_inserted)
+		ret = host->platdata->card_readonly(host->mmc);
+	else
+		ret = 1;	/* assume there is a card */
+
+	return ret;
 }
 
 static int au1xmmc_card_readonly(struct mmc_host *mmc)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
-	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus)
-		? 1 : 0;
+	int ret;
+
+	if (host->platdata && host->platdata->card_readonly)
+		ret = host->platdata->card_readonly(mmc);
+	else
+		ret = 1;	/* assume card is read-only */
+
+	return ret;
 }
 
 static void au1xmmc_finish_request(struct au1xmmc_host *host)
 {
-
 	struct mmc_request *mrq = host->mrq;
 
 	host->mrq = NULL;
@@ -174,14 +218,12 @@ static void au1xmmc_finish_request(struct au1xmmc_host *host)
 
 	host->status = HOST_S_IDLE;
 
-	bcsr->disk_leds |= (1 << 8);
-
 	mmc_request_done(host->mmc, mrq);
 }
 
 static void au1xmmc_tasklet_finish(unsigned long param)
 {
-	struct au1xmmc_host *host = (struct au1xmmc_host *) param;
+	struct au1xmmc_host *host = (struct au1xmmc_host *)param;
 	au1xmmc_finish_request(host);
 }
 
@@ -235,18 +277,16 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
 	au_sync();
 
 	/* Wait for the command to go on the line */
-
-	while(1) {
+	while (1) {
 		if (!(au_readl(HOST_CMD(host)) & SD_CMD_GO))
 			break;
 	}
 
 	/* Wait for the command to come back */
-
 	if (wait) {
 		u32 status = au_readl(HOST_STATUS(host));
 
-		while(!(status & SD_STATUS_CR))
+		while (!(status & SD_STATUS_CR))
 			status = au_readl(HOST_STATUS(host));
 
 		/* Clear the CR status */
@@ -260,7 +300,6 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
 
 static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 {
-
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_data *data;
 	u32 crc;
@@ -276,15 +315,13 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 		status = au_readl(HOST_STATUS(host));
 
 	/* The transaction is really over when the SD_STATUS_DB bit is clear */
-
-	while((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB))
+	while ((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB))
 		status = au_readl(HOST_STATUS(host));
 
 	data->error = 0;
 	dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma.dir);
 
         /* Process any errors */
-
 	crc = (status & (SD_STATUS_WC | SD_STATUS_RC));
 	if (host->flags & HOST_F_XMIT)
 		crc |= ((status & 0x07) == 0x02) ? 0 : 1;
@@ -304,8 +341,7 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 			chan_tab_t *c = *((chan_tab_t **) chan);
 			au1x_dma_chan_t *cp = c->chan_ptr;
 			data->bytes_xfered = cp->ddma_bytecnt;
-		}
-		else
+		} else
 			data->bytes_xfered =
 				(data->blocks * data->blksz) -
 				host->pio.len;
@@ -326,10 +362,9 @@ static void au1xmmc_tasklet_data(unsigned long param)
 
 static void au1xmmc_send_pio(struct au1xmmc_host *host)
 {
-
 	struct mmc_data *data = 0;
 	int sg_len, max, count = 0;
-	unsigned char *sg_ptr;
+	unsigned char *sg_ptr, val;
 	u32 status = 0;
 	struct scatterlist *sg;
 
@@ -350,11 +385,8 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
 	max = (sg_len > host->pio.len) ? host->pio.len : sg_len;
 	if (max > AU1XMMC_MAX_TRANSFER) max = AU1XMMC_MAX_TRANSFER;
 
-	for(count = 0; count < max; count++ ) {
-		unsigned char val;
-
+	for (count = 0; count < max; count++ ) {
 		status = au_readl(HOST_STATUS(host));
-
 		if (!(status & SD_STATUS_TH))
 			break;
 
@@ -384,7 +416,6 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
 
 static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 {
-
 	struct mmc_data *data = 0;
 	int sg_len = 0, max = 0, count = 0;
 	unsigned char *sg_ptr = 0;
@@ -412,7 +443,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 	if (max > AU1XMMC_MAX_TRANSFER)
 		max = AU1XMMC_MAX_TRANSFER;
 
-	for(count = 0; count < max; count++ ) {
+	for (count = 0; count < max; count++ ) {
 		u32 val;
 		status = au_readl(HOST_STATUS(host));
 
@@ -468,7 +499,6 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 
 static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 {
-
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_command *cmd;
 	int trans;
@@ -493,7 +523,6 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 			 * we only got 120 bytes, but the engine expects
 			 * 128 bits, so we have to shift things up
 			 */
-
 			for(i = 0; i < 4; i++) {
 				cmd->resp[i] = (r[i] & 0x00FFFFFF) << 8;
 				if (i != 3)
@@ -512,14 +541,12 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 	}
 
         /* Figure out errors */
-
 	if (status & (SD_STATUS_SC | SD_STATUS_WC | SD_STATUS_RC))
 		cmd->error = -EILSEQ;
 
 	trans = host->flags & (HOST_F_XMIT | HOST_F_RECV);
 
 	if (!trans || cmd->error) {
-
 		IRQ_OFF(host, SD_CONFIG_TH | SD_CONFIG_RA|SD_CONFIG_RF);
 		tasklet_schedule(&host->finish_task);
 		return;
@@ -531,21 +558,18 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 		u32 channel = DMA_CHANNEL(host);
 
 		/* Start the DMA as soon as the buffer gets something in it */
-
 		if (host->flags & HOST_F_RECV) {
 			u32 mask = SD_STATUS_DB | SD_STATUS_NE;
 
-			while((status & mask) != mask)
+			while ((status & mask) != mask)
 				status = au_readl(HOST_STATUS(host));
 		}
-
 		au1xxx_dbdma_start(channel);
 	}
 }
 
 static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
 {
-
 	unsigned int pbus = get_au1x00_speed();
 	unsigned int divisor;
 	u32 config;
@@ -571,7 +595,6 @@ static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
 static int
 au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 {
-
 	int datalen = data->blocks * data->blksz;
 
 	if (dma != 0)
@@ -646,10 +669,6 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 	return -ETIMEDOUT;
 }
 
-/* static void au1xmmc_request
-   This actually starts a command or data transaction
-*/
-
 static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 {
 
@@ -663,8 +682,6 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 	host->mrq = mrq;
 	host->status = HOST_S_CMD;
 
-	bcsr->disk_leds &= ~(1 << 8);
-
 	if (mrq->data) {
 		FLUSH_FIFO(host);
 		flags = mrq->data->flags;
@@ -682,7 +699,6 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 
 static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 {
-
 	/* Apply the clock */
 	au_writel(SD_ENABLE_CE, HOST_ENABLE(host));
         au_sync_delay(1);
@@ -711,10 +727,10 @@ static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 	au_sync();
 }
 
-
-static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
+static void au1xmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
+	u32 config;
 
 	if (ios->power_mode == MMC_POWER_OFF)
 		au1xmmc_set_power(host, 0);
@@ -726,14 +742,25 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 		au1xmmc_set_clock(host, ios->clock);
 		host->clock = ios->clock;
 	}
+
+	config = au_readl(HOST_CONFIG2(host));
+	switch (ios->bus_width) {
+	case MMC_BUS_WIDTH_4:
+		config |= (1 << 8);
+		break;
+	case MMC_BUS_WIDTH_1:
+		config &= ~(1 << 8);
+		break;
+	}
+	au_writel(config, HOST_CONFIG2(host));
+	au_sync();
 }
 
 static void au1xmmc_dma_callback(int irq, void *dev_id)
 {
-	struct au1xmmc_host *host = (struct au1xmmc_host *) dev_id;
+	struct au1xmmc_host *host = (struct au1xmmc_host *)dev_id;
 
 	/* Avoid spurious interrupts */
-
 	if (!host->mrq)
 		return;
 
@@ -749,118 +776,90 @@ static void au1xmmc_dma_callback(int irq, void *dev_id)
 
 static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 {
-
+	struct au1xmmc_host *host = dev_id;
 	u32 status;
-	int i, ret = 0;
 
-	disable_irq(AU1100_SD_IRQ);
+	status = au_readl(HOST_STATUS(host));
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct au1xmmc_host * host = au1xmmc_hosts[i];
-		u32 handled = 1;
+	if (!(status & (1<<15)))
+		return IRQ_NONE;	/* not ours */
 
-		status = au_readl(HOST_STATUS(host));
-
-		if (host->mrq && (status & STATUS_TIMEOUT)) {
-			if (status & SD_STATUS_RAT)
-				host->mrq->cmd->error = -ETIMEDOUT;
-
-			else if (status & SD_STATUS_DT)
-				host->mrq->data->error = -ETIMEDOUT;
+	if (host->mrq && (status & STATUS_TIMEOUT)) {
+		if (status & SD_STATUS_RAT)
+			host->mrq->cmd->error = -ETIMEDOUT;
+		else if (status & SD_STATUS_DT)
+			host->mrq->data->error = -ETIMEDOUT;
 
-			/* In PIO mode, interrupts might still be enabled */
-			IRQ_OFF(host, SD_CONFIG_NE | SD_CONFIG_TH);
+		/* In PIO mode, interrupts might still be enabled */
+		IRQ_OFF(host, SD_CONFIG_NE | SD_CONFIG_TH);
 
-			//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
-			tasklet_schedule(&host->finish_task);
-		}
+		//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
+		tasklet_schedule(&host->finish_task);
+	}
 #if 0
-		else if (status & SD_STATUS_DD) {
-
-			/* Sometimes we get a DD before a NE in PIO mode */
-
-			if (!(host->flags & HOST_F_DMA) &&
-					(status & SD_STATUS_NE))
-				au1xmmc_receive_pio(host);
-			else {
-				au1xmmc_data_complete(host, status);
-				//tasklet_schedule(&host->data_task);
-			}
+	else if (status & SD_STATUS_DD) {
+		/* Sometimes we get a DD before a NE in PIO mode */
+		if (!(host->flags & HOST_F_DMA) && (status & SD_STATUS_NE))
+			au1xmmc_receive_pio(host);
+		else {
+			au1xmmc_data_complete(host, status);
+			//tasklet_schedule(&host->data_task);
 		}
+	}
 #endif
-		else if (status & (SD_STATUS_CR)) {
-			if (host->status == HOST_S_CMD)
-				au1xmmc_cmd_complete(host,status);
-		}
-		else if (!(host->flags & HOST_F_DMA)) {
-			if ((host->flags & HOST_F_XMIT) &&
-			    (status & STATUS_DATA_OUT))
-				au1xmmc_send_pio(host);
-			else if ((host->flags & HOST_F_RECV) &&
-			    (status & STATUS_DATA_IN))
-				au1xmmc_receive_pio(host);
-		}
-		else if (status & 0x203FBC70) {
-			DBG("Unhandled status %8.8x\n", host->id, status);
-			handled = 0;
-		}
-
-		au_writel(status, HOST_STATUS(host));
-		au_sync();
+	else if (status & (SD_STATUS_CR)) {
+		if (host->status == HOST_S_CMD)
+			au1xmmc_cmd_complete(host,status);
 
-		ret |= handled;
-	}
+	} else if (!(host->flags & HOST_F_DMA)) {
+		if ((host->flags & HOST_F_XMIT) && (status & STATUS_DATA_OUT))
+			au1xmmc_send_pio(host);
+		else if ((host->flags & HOST_F_RECV) && (status & STATUS_DATA_IN))
+			au1xmmc_receive_pio(host);
 
-	enable_irq(AU1100_SD_IRQ);
-	return ret;
-}
+	} else if (status & 0x80000000) {
+		mmc_signal_sdio_irq(host->mmc);
 
-static void au1xmmc_poll_event(unsigned long arg)
-{
-	struct au1xmmc_host *host = (struct au1xmmc_host *) arg;
-
-	int card = au1xmmc_card_inserted(host);
-        int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
-
-	if (card != controller) {
-		host->flags &= ~HOST_F_ACTIVE;
-		if (card) host->flags |= HOST_F_ACTIVE;
-		mmc_detect_change(host->mmc, 0);
+	} else if (status & 0x203FBC70) {
+			DBG("Unhandled status %8.8x\n", host->id, status);
 	}
 
-	if (host->mrq != NULL) {
-		u32 status = au_readl(HOST_STATUS(host));
-		DBG("PENDING - %8.8x\n", host->id, status);
-	}
+	au_writel(status, HOST_STATUS(host));
+	au_sync();
 
-	mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT);
+	return IRQ_HANDLED;
 }
 
-static dbdev_tab_t au1xmmc_mem_dbdev =
+static int au1xmmc_init_dma(struct au1xmmc_host *host)
 {
-	DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 8, 0x00000000, 0, 0
-};
-
-static void au1xmmc_init_dma(struct au1xmmc_host *host)
-{
-
+	struct resource *res;
 	u32 rxchan, txchan;
+	int txid, rxid;
 
-	int txid = au1xmmc_card_table[host->id].tx_devid;
-	int rxid = au1xmmc_card_table[host->id].rx_devid;
+	res = platform_get_resource(host->pdev, IORESOURCE_DMA, 0);
+	if (!res)
+		return -ENODEV;
+	txid = res->start;
 
-	/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
-	   of 8 bits.  And since devices are shared, we need to create
-	   our own to avoid freaking out other devices
-	*/
-
-	int memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
+	res = platform_get_resource(host->pdev, IORESOURCE_DMA, 1);
+	if (!res)
+		return -ENODEV;
+	rxid = res->start;
 
 	txchan = au1xxx_dbdma_chan_alloc(memid, txid,
-					 au1xmmc_dma_callback, (void *) host);
+				au1xmmc_dma_callback, (void *)host);
+	if (!txchan) {
+		dev_err(&host->pdev->dev, "cannot allocate TX DMA\n");
+		return -ENODEV;
+	}
 
 	rxchan = au1xxx_dbdma_chan_alloc(rxid, memid,
-					 au1xmmc_dma_callback, (void *) host);
+				au1xmmc_dma_callback, (void *)host);
+	if (!rxchan) {
+		dev_err(&host->pdev->dev, "cannot allocate RX DMA\n");
+		au1xxx_dbdma_chan_free(txchan);
+		return -ENODEV;
+	}
 
 	au1xxx_dbdma_set_devwidth(txchan, 8);
 	au1xxx_dbdma_set_devwidth(rxchan, 8);
@@ -868,126 +867,219 @@ static void au1xmmc_init_dma(struct au1xmmc_host *host)
 	au1xxx_dbdma_ring_alloc(txchan, AU1XMMC_DESCRIPTOR_COUNT);
 	au1xxx_dbdma_ring_alloc(rxchan, AU1XMMC_DESCRIPTOR_COUNT);
 
-	host->tx_chan = txchan;
-	host->rx_chan = rxchan;
+	host->dma.tx_chan = txchan;
+	host->dma.rx_chan = rxchan;
+
+	return 0;
+}
+
+static void au1xmmc_enable_sdio_irq(struct mmc_host *mmc, int en)
+{
+	struct au1xmmc_host *host = mmc_priv(mmc);
+
+	if (en)
+		IRQ_ON(host, (1<<31));
+	else
+		IRQ_OFF(host, (1<<31));
 }
 
 static const struct mmc_host_ops au1xmmc_ops = {
 	.request	= au1xmmc_request,
 	.set_ios	= au1xmmc_set_ios,
 	.get_ro		= au1xmmc_card_readonly,
+	.enable_sdio_irq= au1xmmc_enable_sdio_irq,
 };
 
-static int __devinit au1xmmc_probe(struct platform_device *pdev)
+static void au1xmmc_poll_event(unsigned long arg)
 {
+	struct au1xmmc_host *host = (struct au1xmmc_host *)arg;
+	u32 status;
 
-	int i, ret = 0;
+	int card = au1xmmc_card_inserted(host);
+        int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
 
-	/* THe interrupt is shared among all controllers */
-	ret = request_irq(AU1100_SD_IRQ, au1xmmc_irq, IRQF_DISABLED, "MMC", 0);
+	if (card != controller) {
+		host->flags &= ~HOST_F_ACTIVE;
+		if (card)
+			host->flags |= HOST_F_ACTIVE;
+		mmc_detect_change(host->mmc, 0);
+	}
 
-	if (ret) {
-		printk(DRIVER_NAME "ERROR: Couldn't get int %d: %d\n",
-				AU1100_SD_IRQ, ret);
-		return -ENXIO;
+	if (host->mrq != NULL) {
+		status = au_readl(HOST_STATUS(host));
+		DBG("PENDING - %8.8x\n", host->id, status);
 	}
 
-	disable_irq(AU1100_SD_IRQ);
+	mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT);
+}
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct mmc_host *mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
-		struct au1xmmc_host *host = 0;
+static void au1xmmc_init_cd_poll_timer(struct au1xmmc_host *host)
+{
+	init_timer(&host->timer);
+	host->timer.function = au1xmmc_poll_event;
+	host->timer.data = (unsigned long)host;
+	host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT;
+	add_timer(&host->timer);
+}
 
-		if (!mmc) {
-			printk(DRIVER_NAME "ERROR: no mem for host %d\n", i);
-			au1xmmc_hosts[i] = 0;
-			continue;
-		}
+static int __devinit au1xmmc_probe(struct platform_device *pdev)
+{
+	struct mmc_host *mmc;
+	struct au1xmmc_host *host;
+	struct resource *r;
+	int ret;
+
+	mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
+	if (!mmc) {
+		dev_err(&pdev->dev, "no memory for mmc host\n");
+		ret = -ENOMEM;
+		goto out0;
+	}
 
-		mmc->ops = &au1xmmc_ops;
+	host = mmc_priv(mmc);
+	host->mmc = mmc;
+	host->platdata = pdev->dev.platform_data;
+	host->pdev = pdev;
 
-		mmc->f_min =   450000;
-		mmc->f_max = 24000000;
+	ret = -ENODEV;
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "no mmio defined\n");
+		goto out1;
+	}
+	host->iobase = (unsigned long)ioremap(r->start, 0xff);
+	if (!host->iobase) {
+		dev_err(&pdev->dev, "cannot remap mmio\n");
+		goto out1;
+	}
 
-		mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
-		mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
+	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "no IRQ defined\n");
+		goto out2;
+	}
 
-		mmc->max_blk_size = 2048;
-		mmc->max_blk_count = 512;
+	host->irq = r->start;
+	/* IRQ is shared among both SD controllers */
+	ret = request_irq(host->irq, au1xmmc_irq, IRQF_SHARED,
+			  DRIVER_NAME, host);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot grab IRQ\n");
+		goto out2;
+	}
 
-		mmc->ocr_avail = AU1XMMC_OCR;
+	mmc->ops = &au1xmmc_ops;
 
-		host = mmc_priv(mmc);
-		host->mmc = mmc;
+	mmc->f_min =   450000;
+	mmc->f_max = 24000000;
 
-		host->id = i;
-		host->iobase = au1xmmc_card_table[host->id].iobase;
-		host->clock = 0;
-		host->power_mode = MMC_POWER_OFF;
+	mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
+	mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
 
-		host->flags = au1xmmc_card_inserted(host) ? HOST_F_ACTIVE : 0;
-		host->status = HOST_S_IDLE;
+	mmc->max_blk_size = 2048;
+	mmc->max_blk_count = 512;
 
-		init_timer(&host->timer);
+	mmc->ocr_avail = AU1XMMC_OCR;
+	mmc->caps = MMC_CAP_SDIO_IRQ /* | MMC_CAP_4_BIT_DATA borked */;
 
-		host->timer.function = au1xmmc_poll_event;
-		host->timer.data = (unsigned long) host;
-		host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT;
+	host->clock = 0;
+	host->id = pdev->id;
+	host->status = HOST_S_IDLE;
 
-		tasklet_init(&host->data_task, au1xmmc_tasklet_data,
-				(unsigned long) host);
+	/* board-specific carddetect setup, if any */
+	if (host->platdata && host->platdata->cd_setup) {
+		ret = host->platdata->cd_setup(mmc, 1);
+		if (ret) {
+			dev_err(&pdev->dev, "board CD setup failed\n");
+			goto out3;
+		}
+	} else {
+		/* poll the board-specific card-is-in-socket method */
+		au1xmmc_init_cd_poll_timer(host);
+		host->flags = au1xmmc_card_inserted(host) ? HOST_F_ACTIVE : 0;
+	}
 
-		tasklet_init(&host->finish_task, au1xmmc_tasklet_finish,
-				(unsigned long) host);
+	tasklet_init(&host->data_task, au1xmmc_tasklet_data,
+			(unsigned long)host);
 
-		spin_lock_init(&host->lock);
+	tasklet_init(&host->finish_task, au1xmmc_tasklet_finish,
+			(unsigned long)host);
 
-		if (dma != 0)
-			au1xmmc_init_dma(host);
+	if (dma) {
+		ret = au1xmmc_init_dma(host);
+		if (ret)
+			goto out4;
+	}
 
-		au1xmmc_reset_controller(host);
+	au1xmmc_reset_controller(host);
 
-		mmc_add_host(mmc);
-		au1xmmc_hosts[i] = host;
+	ret = mmc_add_host(mmc);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot add mmc host\n");
+		goto out5;
+	}
 
-		add_timer(&host->timer);
+	platform_set_drvdata(pdev, mmc);
 
-		printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X (mode=%s)\n",
-		       host->id, host->iobase, dma ? "dma" : "pio");
-	}
+	printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X (mode=%s)\n",
+		       pdev->id, host->iobase, dma ? "dma" : "pio");
 
-	enable_irq(AU1100_SD_IRQ);
+	return 0;	/* all ok */
 
-	return 0;
+out5:
+	if (dma) {
+		au1xxx_dbdma_chan_free(host->dma.tx_chan);
+		au1xxx_dbdma_chan_free(host->dma.rx_chan);
+	}
+out4:
+	tasklet_kill(&host->data_task);
+	tasklet_kill(&host->finish_task);
+
+	if (host->platdata && host->platdata->cd_setup)
+		host->platdata->cd_setup(mmc, 0);
+	else
+		del_timer_sync(&host->timer);
+out3:
+	free_irq(host->irq, host);
+out2:
+	iounmap((void *)host->iobase);
+out1:
+	mmc_free_host(mmc);
+out0:
+	return ret;
 }
 
 static int __devexit au1xmmc_remove(struct platform_device *pdev)
 {
+	struct mmc_host *mmc = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host;
 
-	int i;
-
-	disable_irq(AU1100_SD_IRQ);
+	if (mmc) {
+		host  = mmc_priv(mmc);
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct au1xmmc_host *host = au1xmmc_hosts[i];
-		if (!host) continue;
+		au_writel(0, HOST_ENABLE(host));
+		au_writel(0, HOST_CONFIG(host));
+		au_sync();
 
 		tasklet_kill(&host->data_task);
 		tasklet_kill(&host->finish_task);
 
-		del_timer_sync(&host->timer);
+		if (host->platdata && host->platdata->cd_setup)
+			host->platdata->cd_setup(mmc, 0);
+		else
+			del_timer_sync(&host->timer);
+
 		au1xmmc_set_power(host, 0);
 
-		mmc_remove_host(host->mmc);
+		free_irq(host->irq, host);
 
-		au1xxx_dbdma_chan_free(host->tx_chan);
-		au1xxx_dbdma_chan_free(host->rx_chan);
+		mmc_remove_host(host->mmc);
 
-		au_writel(0x0, HOST_ENABLE(host));
-		au_sync();
+		if (dma) {
+			au1xxx_dbdma_chan_free(host->dma.tx_chan);
+			au1xxx_dbdma_chan_free(host->dma.rx_chan);
+		}
 	}
-
-	free_irq(AU1100_SD_IRQ, 0);
 	return 0;
 }
 
@@ -1004,6 +1096,18 @@ static struct platform_driver au1xmmc_driver = {
 
 static int __init au1xmmc_init(void)
 {
+	if (dma) {
+		/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
+		   of 8 bits.  And since devices are shared, we need to create
+		   our own to avoid freaking out other devices
+		 */
+		if (!memid)
+			memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
+		if (!memid) {
+			printk(KERN_ERR "au1xmmc: cannot add memory dma dev\n");
+			return -ENODEV;
+		}
+	}
 	return platform_driver_register(&au1xmmc_driver);
 }
 
@@ -1015,10 +1119,7 @@ static void __exit au1xmmc_exit(void)
 module_init(au1xmmc_init);
 module_exit(au1xmmc_exit);
 
-#ifdef MODULE
 MODULE_AUTHOR("Advanced Micro Devices, Inc");
 MODULE_DESCRIPTION("MMC/SD driver for the Alchemy Au1XXX");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:au1xxx-mmc");
-#endif
-
diff --git a/drivers/mmc/host/au1xmmc.h b/drivers/mmc/host/au1xmmc.h
deleted file mode 100644
index 341cbdf..0000000
--- a/drivers/mmc/host/au1xmmc.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef _AU1XMMC_H_
-#define _AU1XMMC_H_
-
-/* Hardware definitions */
-
-#define AU1XMMC_DESCRIPTOR_COUNT 1
-#define AU1XMMC_DESCRIPTOR_SIZE  2048
-
-#define AU1XMMC_OCR ( MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
-		      MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
-		      MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
-
-/* Easy access macros */
-
-#define HOST_STATUS(h)	((h)->iobase + SD_STATUS)
-#define HOST_CONFIG(h)	((h)->iobase + SD_CONFIG)
-#define HOST_ENABLE(h)	((h)->iobase + SD_ENABLE)
-#define HOST_TXPORT(h)	((h)->iobase + SD_TXPORT)
-#define HOST_RXPORT(h)	((h)->iobase + SD_RXPORT)
-#define HOST_CMDARG(h)	((h)->iobase + SD_CMDARG)
-#define HOST_BLKSIZE(h)	((h)->iobase + SD_BLKSIZE)
-#define HOST_CMD(h)	((h)->iobase + SD_CMD)
-#define HOST_CONFIG2(h)	((h)->iobase + SD_CONFIG2)
-#define HOST_TIMEOUT(h)	((h)->iobase + SD_TIMEOUT)
-#define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
-
-#define DMA_CHANNEL(h) \
-	( ((h)->flags & HOST_F_XMIT) ? (h)->tx_chan : (h)->rx_chan)
-
-/* This gives us a hard value for the stop command that we can write directly
- * to the command register
- */
-
-#define STOP_CMD (SD_CMD_RT_1B|SD_CMD_CT_7|(0xC << SD_CMD_CI_SHIFT)|SD_CMD_GO)
-
-/* This is the set of interrupts that we configure by default */
-
-#if 0
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | SD_CONFIG_DD | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-#endif
-
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-/* The poll event (looking for insert/remove events runs twice a second */
-#define AU1XMMC_DETECT_TIMEOUT (HZ/2)
-
-struct au1xmmc_host {
-  struct mmc_host *mmc;
-  struct mmc_request *mrq;
-
-  u32 id;
-
-  u32 flags;
-  u32 iobase;
-  u32 clock;
-  u32 bus_width;
-  u32 power_mode;
-
-  int status;
-
-   struct {
-	   int len;
-	   int dir;
-  } dma;
-
-   struct {
-	   int index;
-	   int offset;
-	   int len;
-  } pio;
-
-  u32 tx_chan;
-  u32 rx_chan;
-
-  struct timer_list timer;
-  struct tasklet_struct finish_task;
-  struct tasklet_struct data_task;
-
-  spinlock_t lock;
-};
-
-/* Status flags used by the host structure */
-
-#define HOST_F_XMIT   0x0001
-#define HOST_F_RECV   0x0002
-#define HOST_F_DMA    0x0010
-#define HOST_F_ACTIVE 0x0100
-#define HOST_F_STOP   0x1000
-
-#define HOST_S_IDLE   0x0001
-#define HOST_S_CMD    0x0002
-#define HOST_S_DATA   0x0003
-#define HOST_S_STOP   0x0004
-
-#endif
diff --git a/include/asm-mips/mach-au1x00/au1100_mmc.h b/include/asm-mips/mach-au1x00/au1100_mmc.h
index 9e0028f..6474fac 100644
--- a/include/asm-mips/mach-au1x00/au1100_mmc.h
+++ b/include/asm-mips/mach-au1x00/au1100_mmc.h
@@ -38,15 +38,46 @@
 #ifndef __ASM_AU1100_MMC_H
 #define __ASM_AU1100_MMC_H
 
-
-#define NUM_AU1100_MMC_CONTROLLERS	2
-
-#if defined(CONFIG_SOC_AU1100)
-#define AU1100_SD_IRQ	AU1100_SD_INT
-#elif defined(CONFIG_SOC_AU1200)
-#define AU1100_SD_IRQ	AU1200_SD_INT
-#endif
-
+struct au1xmmc_platdata {
+	int(*cd_setup)(void *mmc_host, int on);
+	int(*card_inserted)(void *mmc_host);
+	int(*card_readonly)(void *mmc_host);
+	void(*set_power)(void *mmc_host, int state);
+};
+
+struct au1xmmc_host {
+	struct mmc_host *mmc;
+	struct mmc_request *mrq;
+
+	u32 id;
+
+	u32 flags;
+	u32 iobase;
+	u32 clock;
+
+	int status;
+
+	struct {
+		int len;
+		int dir;
+		u32 tx_chan;
+		u32 rx_chan;
+	} dma;
+
+	struct {
+		int index;
+		int offset;
+		int len;
+	} pio;
+
+	struct timer_list timer;
+	struct tasklet_struct finish_task;
+	struct tasklet_struct data_task;
+
+	struct platform_device *pdev;
+	struct au1xmmc_platdata *platdata;
+	int irq;
+};
 
 #define SD0_BASE	0xB0600000
 #define SD1_BASE	0xB0680000
-- 
1.5.5.1



From ralf@linux-mips.org Tue May  6 22:29:25 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 22:29:28 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:46007 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20031993AbYEFV3Z (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 6 May 2008 22:29:25 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m46LTOa8018388;
	Tue, 6 May 2008 22:29:24 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m46LTOxm018387;
	Tue, 6 May 2008 22:29:24 +0100
Date:	Tue, 6 May 2008 22:29:24 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Thiemo Seufer <ths@networkno.de>
Cc:	linux-mips@linux-mips.org
Subject: Re: fix warning message on SMP kernels
Message-ID: <20080506212924.GA15547@linux-mips.org>
References: <20080506102122.GE22413@networkno.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080506102122.GE22413@networkno.de>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19111
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 89
Lines: 5

On Tue, May 06, 2008 at 11:21:22AM +0100, Thiemo Seufer wrote:

Thanks, applied.

  Ralf

From ralf@linux-mips.org Tue May  6 22:29:44 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 22:29:47 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:46775 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20032012AbYEFV3f (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 6 May 2008 22:29:35 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m46LTXDj018448;
	Tue, 6 May 2008 22:29:33 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m46LTXHt018447;
	Tue, 6 May 2008 22:29:33 +0100
Date:	Tue, 6 May 2008 22:29:33 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Thiemo Seufer <ths@networkno.de>
Cc:	linux-mips@linux-mips.org
Subject: Re: Fix build failure in mips oprofile code
Message-ID: <20080506212933.GB15547@linux-mips.org>
References: <20080506102333.GF22413@networkno.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080506102333.GF22413@networkno.de>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19112
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 88
Lines: 5

On Tue, May 06, 2008 at 11:23:33AM +0100, Thiemo Seufer wrote:

Thanks, applied

  Ralf

From paulius.zaleckas@teltonika.lt Tue May  6 22:32:27 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2008 22:32:31 +0100 (BST)
Received: from mailhub.zebra.lt ([212.59.31.77]:16132 "EHLO mh.zebra.lt")
	by ftp.linux-mips.org with ESMTP id S20032213AbYEFVc1 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 6 May 2008 22:32:27 +0100
Received: from localhost (localhost [127.0.0.1])
	by mh.zebra.lt (Postfix) with ESMTP id 83F86118AE3;
	Wed,  7 May 2008 00:31:11 +0300 (EEST)
X-Virus-Scanned: amavisd-new at takas.lt
Received: from mh.zebra.lt ([127.0.0.1])
	by localhost (ispmailfe123.internal.takas.lt [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id vd1r-G0F4f4P; Wed,  7 May 2008 00:31:11 +0300 (EEST)
Received: from mailhub.zebra.lt (unknown [192.168.3.104])
	by mh.zebra.lt (Postfix) with ESMTP id 2BDB8118B8E;
	Wed,  7 May 2008 00:31:11 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mailhub.zebra.lt (Postfix) with ESMTP id 4BD90279DA7;
	Wed,  7 May 2008 00:32:21 +0300 (EEST)
X-Virus-Scanned: amavisd-new at takas.lt
Received: from mailhub.zebra.lt ([127.0.0.1])
	by localhost (ispmailfe104.internal.takas.lt [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ULoOfR-3KQoX; Wed,  7 May 2008 00:32:20 +0300 (EEST)
Received: from paulius.dzuku (78-62-85-225.static.zebra.lt [78.62.85.225])
	by mailhub.zebra.lt (Postfix) with ESMTP id 7A708279DB3;
	Wed,  7 May 2008 00:32:20 +0300 (EEST)
Message-ID: <4820CE63.7050505@teltonika.lt>
Date:	Wed, 07 May 2008 00:32:19 +0300
From:	Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
User-Agent: Thunderbird 2.0.0.12 (X11/20080226)
MIME-Version: 1.0
Newsgroups: gmane.linux.irda.general,gmane.linux.network
CC:	linux-mips@linux-mips.org, ppopov@mvista.com
Subject: [PATCH] au1k_ir: use netstats in net_device structure
Content-Type: multipart/mixed;
 boundary="------------030305010008050208030004"
To:	unlisted-recipients:; (no To-header on input)
Return-Path: <paulius.zaleckas@teltonika.lt>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19113
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: paulius.zaleckas@teltonika.lt
Precedence: bulk
X-list: linux-mips
Content-Length: 3176
Lines: 95

This is a multi-part message in MIME format.
--------------030305010008050208030004
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Use net_device_stats from net_device structure instead of local.
Kill au1k_irda_stats function, because by default it is used
identical internal_stats function from net/core/dev.c

Haven't tried to compile it. Need ack from MIPS people!

Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>

--------------030305010008050208030004
Content-Type: text/x-patch;
 name="au1k_ir_netstats.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="au1k_ir_netstats.patch"

diff --git a/drivers/net/irda/au1000_ircc.h b/drivers/net/irda/au1000_ircc.h
index 7a31d46..1ed665a 100644
--- a/drivers/net/irda/au1000_ircc.h
+++ b/drivers/net/irda/au1000_ircc.h
@@ -107,7 +107,6 @@ struct au1k_private {
 	iobuff_t rx_buff;
 
 	struct net_device *netdev;
-	struct net_device_stats stats;
 	
 	struct timeval stamp;
 	struct timeval now;
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index a1e4508..f4e639b 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -53,7 +53,6 @@ static int au1k_irda_hard_xmit(struct sk_buff *, struct net_device *);
 static int au1k_irda_rx(struct net_device *);
 static void au1k_irda_interrupt(int, void *);
 static void au1k_tx_timeout(struct net_device *);
-static struct net_device_stats *au1k_irda_stats(struct net_device *);
 static int au1k_irda_ioctl(struct net_device *, struct ifreq *, int);
 static int au1k_irda_set_speed(struct net_device *dev, int speed);
 
@@ -213,7 +212,6 @@ static int au1k_irda_net_init(struct net_device *dev)
 	dev->open = au1k_irda_start;
 	dev->hard_start_xmit = au1k_irda_hard_xmit;
 	dev->stop = au1k_irda_stop;
-	dev->get_stats = au1k_irda_stats;
 	dev->do_ioctl = au1k_irda_ioctl;
 	dev->tx_timeout = au1k_tx_timeout;
 
@@ -421,7 +419,7 @@ static inline void
 update_tx_stats(struct net_device *dev, u32 status, u32 pkt_len)
 {
 	struct au1k_private *aup = netdev_priv(dev);
-	struct net_device_stats *ps = &aup->stats;
+	struct net_device_stats *ps = &dev->stats;
 
 	ps->tx_packets++;
 	ps->tx_bytes += pkt_len;
@@ -557,7 +555,7 @@ static inline void
 update_rx_stats(struct net_device *dev, u32 status, u32 count)
 {
 	struct au1k_private *aup = netdev_priv(dev);
-	struct net_device_stats *ps = &aup->stats;
+	struct net_device_stats *ps = &dev->stats;
 
 	ps->rx_packets++;
 
@@ -596,7 +594,7 @@ static int au1k_irda_rx(struct net_device *dev)
 			update_rx_stats(dev, flags, count);
 			skb=alloc_skb(count+1,GFP_ATOMIC);
 			if (skb == NULL) {
-				aup->stats.rx_dropped++;
+				dev->stats.rx_dropped++;
 				continue;
 			}
 			skb_reserve(skb, 1);
@@ -833,13 +831,6 @@ au1k_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
 	return ret;
 }
 
-
-static struct net_device_stats *au1k_irda_stats(struct net_device *dev)
-{
-	struct au1k_private *aup = netdev_priv(dev);
-	return &aup->stats;
-}
-
 MODULE_AUTHOR("Pete Popov <ppopov@mvista.com>");
 MODULE_DESCRIPTION("Au1000 IrDA Device Driver");
 

--------------030305010008050208030004--

From macro@linux-mips.org Wed May  7 01:41:13 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 01:41:17 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:54517 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20021897AbYEGAlN (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 01:41:13 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m470eHHi020411;
	Wed, 7 May 2008 02:40:17 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m470dxAf020402;
	Wed, 7 May 2008 01:40:00 +0100
Date:	Wed, 7 May 2008 01:39:59 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 0/4] RTC: Use class devices as a persistent clock
Message-ID: <Pine.LNX.4.55.0805062333390.16173@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19114
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3219
Lines: 56

Hello,

 While investigating why Linux on the MIPS64 Broadcom BCM91250A board (the
SWARM, based on the SiByte BCM1250A SOC) does not support an RTC device
anymore I discovered the "wiring" of code to access /dev/rtc to the RTC
device driver got removed with some changes that happened a while ago.  
The board uses the ST M41T81 I2C chip with a driver buried within the
architecture code.  There is a standard driver for this chip in our tree
already, which is called rtc-m41t80, and which as a part of the RTC driver
suite provides the necessary "wiring" to /dev/rtc.

 I decided to remove the platform driver as redundant and unportable -- it
groups together knowledge about the M41T81 and the BCM1250A onchip I2C
controller.  This revealed a couple of problems which this patch set
addresses.  I'd like to skip the discussion of hardware-specific bits
here, which I think are rather obvious and which I will cover with the
individual patches.

 My point here is whether we want to switch over to the RTC suite in
preference to legacy RTC drivers (like drivers/char/rtc.c) and perhaps
more importantly platform RTC drivers which are often buried in a mixture
of header files and arch C code for the purpose of timekeeping.  The API
in question are the read_persistent_clock() and update_persistent_clock()  
functions used mostly by the NTP support code.

 The notable gain is the removal of the additional burden from platform
code -- all that has be implemented is support for the RTC chip the
platform has.  I have added the rtc_read_persistent_clock() and
rtc_update_persistent_clock() functions to the RTC suite that can serve as
the implementation of the API and work the same (hardware implementation
permitting) regardless of the exact RTC chip used.  There is even support
for the ubiquitous derivatives of the MC146818 available as a class device
already.  Additionally, if there is more than one RTC chip in a given
system, the user can select which of the chips to use.

 The drawback is some implementations behind these functions may sleep,
for example because hardware is slow to access.  The current calling
context of update_persistent_clock() (which is the softirq) does not
permit the function to sleep.  To rectify I have moved the call into the
process context, but it now means the latency between getnstimeofday() and
the writeback into the RTC will be yet less predictable and potentially
higher.  This should not matter in practice, because the RTC generally
cannot guarantee suitable precision to be a reliable sub-second resolution
device for providing time while the NTP daemon is not running and one who
cares about timekeeping will run NTP during normal system operation anyway
which will correct any inaccuracy gathered from the RTC.  I am mentioning
it though as I think it should be noted.

 Individual patches follow, feedback is welcome.  All have been
successfully tested at the run time with a big-endian 64-bit MIPS
configuration, using the usual SMP vs non-SMP and PREEMPT vs non-PREEMPT
configurations, with spinlock, etc. debugging on; no checkpatch.pl nor
sparse problems either.  They have been successfully built for a 32-bit
x86 and Alpha configuration as well.

  Maciej

From macro@linux-mips.org Wed May  7 01:41:33 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 01:41:36 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:54773 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022305AbYEGAlO (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 01:41:14 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m470eS0d020427;
	Wed, 7 May 2008 02:40:28 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m470eRNt020423;
	Wed, 7 May 2008 01:40:27 +0100
Date:	Wed, 7 May 2008 01:40:27 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19115
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 6105
Lines: 152

 The standard rtc-m41t80.c driver cannot be used with the SWARM as it is,
because the board does not provide setup information for the I2C core.  
As a result the bus and the address to probe for the M41T80 chip is not
known.

 Here is a set of changes that fix the problem:

1. i2c-swarm.c -- SWARM I2C board setup, currently for the M41T80 chip on 
   the bus #1 only.

2. The i2c-sibyte.c BCM1250A SMBus controller driver now registers its 
   buses as numbered so that board setup is correctly applied.  Plus minor 
   corrections.

3. SWARM platform library is now built as an object to include i2c-swarm.c 
   which is only used as an initcall and does not provide any symbols that 
   would pull the file from an archive.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
patch-2.6.26-rc1-20080505-swarm-i2c-15
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/Makefile linux-2.6.26-rc1-20080505/arch/mips/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/Makefile	2008-05-05 02:55:23.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/Makefile	2008-05-05 21:10:50.000000000 +0000
@@ -538,19 +538,19 @@ cflags-$(CONFIG_SIBYTE_BCM1x80)	+= -Iinc
 # Sibyte SWARM board
 # Sibyte BCM91x80 (BigSur) board
 #
-libs-$(CONFIG_SIBYTE_CARMEL)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_CARMEL)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_CARMEL)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_CRHINE)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_CRHINE)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_CRHINE)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_CRHONE)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_CRHONE)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_CRHONE)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_RHONE)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_RHONE)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_RHONE)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_SENTOSA)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_SENTOSA)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_SENTOSA)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_SWARM)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_SWARM)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_SWARM)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_BIGSUR)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_BIGSUR)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_BIGSUR)	:= 0xffffffff80100000
 
 #
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2004-01-29 04:57:05.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
@@ -1,3 +1,4 @@
-lib-y				= setup.o rtc_xicor1241.o rtc_m41t81.o
+obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
 
-lib-$(CONFIG_KGDB)		+= dbg_io.o
+obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-swarm.o
+obj-$(CONFIG_KGDB)		+= dbg_io.o
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/i2c-swarm.c linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/i2c-swarm.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/i2c-swarm.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/i2c-swarm.c	2008-05-06 23:51:34.000000000 +0000
@@ -0,0 +1,37 @@
+/*
+ *	arch/mips/sibyte/swarm/i2c-swarm.c
+ *
+ *	Broadcom BCM91250A (SWARM), etc. I2C platform setup.
+ *
+ *	Copyright (c) 2008  Maciej W. Rozycki
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License
+ *	as published by the Free Software Foundation; either version
+ *	2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+
+
+static struct i2c_board_info swarm_i2c_info1[] __initdata = {
+	{
+		I2C_BOARD_INFO("m41t81", 0x68),
+	},
+};
+
+static int __init swarm_i2c_init(void)
+{
+	int err;
+
+	err = i2c_register_board_info(1, swarm_i2c_info1,
+				      ARRAY_SIZE(swarm_i2c_info1));
+	if (err < 0)
+		printk(KERN_ERR
+		       "i2c-swarm: cannot register board I2C devices\n");
+	return err;
+}
+
+arch_initcall(swarm_i2c_init);
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c
--- linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c	2008-05-05 02:55:25.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c	2008-05-06 23:45:32.000000000 +0000
@@ -2,6 +2,7 @@
  * Copyright (C) 2004 Steven J. Hill
  * Copyright (C) 2001,2002,2003 Broadcom Corporation
  * Copyright (C) 1995-2000 Simon G. Vogl
+ * Copyright (C) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -132,18 +133,18 @@ static const struct i2c_algorithm i2c_si
 /*
  * registering functions to load algorithms at runtime
  */
-int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
+static int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
 {
 	struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
 
-	/* register new adapter to i2c module... */
+	/* Register new adapter to i2c module...  */
 	i2c_adap->algo = &i2c_sibyte_algo;
 
-	/* Set the frequency to 100 kHz */
+	/* Set the requested frequency.  */
 	csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
 	csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
 
-	return i2c_add_adapter(i2c_adap);
+	return i2c_add_numbered_adapter(i2c_adap);
 }
 
 
@@ -159,6 +160,7 @@ static struct i2c_adapter sibyte_board_a
 		.class		= I2C_CLASS_HWMON,
 		.algo		= NULL,
 		.algo_data	= &sibyte_board_data[0],
+		.nr		= 0,
 		.name		= "SiByte SMBus 0",
 	},
 	{
@@ -167,6 +169,7 @@ static struct i2c_adapter sibyte_board_a
 		.class		= I2C_CLASS_HWMON,
 		.algo		= NULL,
 		.algo_data	= &sibyte_board_data[1],
+		.nr		= 1,
 		.name		= "SiByte SMBus 1",
 	},
 };

From macro@linux-mips.org Wed May  7 01:41:52 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 01:41:55 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:55285 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20021904AbYEGAlP (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 01:41:15 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m470eNCM020419;
	Wed, 7 May 2008 02:40:23 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m470eNj2020415;
	Wed, 7 May 2008 01:40:23 +0100
Date:	Wed, 7 May 2008 01:40:22 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 1/4] RTC: Class device support for persistent clock
Message-ID: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19116
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 9441
Lines: 270

 This is a generic implementation of rtc_read_persistent_clock() and
rtc_update_persistent_clock() suitable for platforms to be used for
read_persistent_clock() and update_persistent_clock() calls.  An RTC
device selected by the user with the RTC_HCTOSYS_DEVICE option is used.  

 As rtc_read_persistent_clock() is not available at the time
timekeeping_init() is called, it will now be disabled if the class device
is to be used as a reference.  In this case rtc_hctosys(), already
present, will be used to set up the system time at the late initcall time.  
This call has now been rewritten to make use of
rtc_read_persistent_clock().

 As rtc_set_mmss() used by rtc_update_persistent_clock() may sleep for 
some hardware, the call is now made from a work queue scheduled by the 
timer originally used for the entire function.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
patch-2.6.26-rc1-20080505-rtc-persistent-clock-11
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/Kconfig linux-2.6.26-rc1-20080505/drivers/rtc/Kconfig
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/Kconfig	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/Kconfig	2008-05-05 21:41:34.000000000 +0000
@@ -21,24 +21,30 @@ menuconfig RTC_CLASS
 if RTC_CLASS
 
 config RTC_HCTOSYS
-	bool "Set system time from RTC on startup and resume"
+	bool "Use time from RTC as a reference for the system time"
 	depends on RTC_CLASS = y
 	default y
 	help
-	  If you say yes here, the system time (wall clock) will be set using
-	  the value read from a specified RTC device. This is useful to avoid
-	  unnecessary fsck runs at boot time, and to network better.
+	  If you say yes here, the specified RTC device will be used
+	  as a reference to the system time (wall clock).  The device
+	  will be used to set the system time as required during
+	  startup, suspend and, for platforms that support such usage,
+	  for NTP timekeeping.
+
+	  This is useful to avoid unnecessary fsck runs at boot time,
+	  and to network better.
 
 config RTC_HCTOSYS_DEVICE
-	string "RTC used to set the system time"
+	string "RTC used as a reference for the system time"
 	depends on RTC_HCTOSYS = y
 	default "rtc0"
 	help
-	  The RTC device that will be used to (re)initialize the system
+	  The RTC device that will be used as a reference for the system
 	  clock, usually rtc0.  Initialization is done when the system
-	  starts up, and when it resumes from a low power state.  This
-	  device should record time in UTC, since the kernel won't do
-	  timezone correction.
+	  starts up, and when it resumes from a low power state.  Also,
+	  if supported by the platform, NTP timekeeping uses this device
+	  to record the system time periodically.  This device should
+	  record time in UTC, since the kernel won't do timezone correction.
 
 	  The driver for this RTC device must be loaded before late_initcall
 	  functions run, so it must usually be statically linked.
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/hctosys.c linux-2.6.26-rc1-20080505/drivers/rtc/hctosys.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/hctosys.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/hctosys.c	2008-05-05 21:10:50.000000000 +0000
@@ -1,8 +1,9 @@
 /*
- * RTC subsystem, initialize system time on startup
+ * RTC subsystem, persistent clock and startup initialization support
  *
  * Copyright (C) 2005 Tower Technologies
  * Author: Alessandro Zummo <a.zummo@towertech.it>
+ * Copyright (C) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -22,46 +23,85 @@
  * the best guess is to add 0.5s.
  */
 
-static int __init rtc_hctosys(void)
+/*
+ * Note the unusual API:
+ * zero returned means a failure, anything else is seconds from epoch.
+ */
+unsigned long rtc_read_persistent_clock(void)
 {
-	int err;
-	struct rtc_time tm;
 	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+	struct rtc_time tm;
+	unsigned long time = 0;
 
 	if (rtc == NULL) {
-		printk("%s: unable to open rtc device (%s)\n",
-			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
-		return -ENODEV;
+		printk(KERN_ERR "hctosys: unable to open rtc device (%s)\n",
+		       CONFIG_RTC_HCTOSYS_DEVICE);
+		goto out;
+	}
+	if (rtc_read_time(rtc, &tm) < 0) {
+		dev_err(rtc->dev.parent,
+			"hctosys: unable to read the hardware clock\n");
+		goto out_close;
 	}
+	if (rtc_valid_tm(&tm) < 0) {
+		dev_err(rtc->dev.parent, "hctosys: invalid date/time\n");
+		goto out_close;
+	}
+
+	rtc_tm_to_time(&tm, &time);
 
-	err = rtc_read_time(rtc, &tm);
-	if (err == 0) {
-		err = rtc_valid_tm(&tm);
-		if (err == 0) {
-			struct timespec tv;
-
-			tv.tv_nsec = NSEC_PER_SEC >> 1;
-
-			rtc_tm_to_time(&tm, &tv.tv_sec);
-
-			do_settimeofday(&tv);
-
-			dev_info(rtc->dev.parent,
-				"setting system clock to "
-				"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
-				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-				tm.tm_hour, tm.tm_min, tm.tm_sec,
-				(unsigned int) tv.tv_sec);
-		}
-		else
-			dev_err(rtc->dev.parent,
-				"hctosys: invalid date/time\n");
+out_close:
+	rtc_class_close(rtc);
+out:
+	return time;
+}
+
+int rtc_update_persistent_clock(struct timespec now)
+{
+	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+	int err;
+
+	if (rtc == NULL) {
+		printk(KERN_ERR "hctosys: unable to open rtc device (%s)\n",
+		       CONFIG_RTC_HCTOSYS_DEVICE);
+		err = -ENXIO;
+		goto out;
 	}
-	else
+	err = rtc_set_mmss(rtc, now.tv_sec);
+	if (err < 0) {
 		dev_err(rtc->dev.parent,
-			"hctosys: unable to read the hardware clock\n");
+			"hctosys: unable to set the hardware clock\n");
+		goto out_close;
+	}
 
+	err = 0;
+
+out_close:
 	rtc_class_close(rtc);
+out:
+	return err;
+}
+
+static int __init rtc_hctosys(void)
+{
+	struct rtc_time tm;
+	struct timespec tv;
+	unsigned long time;
+
+	time = rtc_read_persistent_clock();
+	if (!time)
+		return -ENODEV;
+
+	tv.tv_nsec = NSEC_PER_SEC >> 1;
+	tv.tv_sec = time;
+	do_settimeofday(&tv);
+
+	rtc_time_to_tm(time, &tm);
+	pr_info("%s: setting system clock to "
+		"%d-%02d-%02d %02d:%02d:%02d UTC (%lu)\n",
+		CONFIG_RTC_HCTOSYS_DEVICE,
+		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+		tm.tm_hour, tm.tm_min, tm.tm_sec, (unsigned long)tv.tv_sec);
 
 	return 0;
 }
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/include/linux/rtc.h linux-2.6.26-rc1-20080505/include/linux/rtc.h
--- linux-2.6.26-rc1-20080505.macro/include/linux/rtc.h	2008-05-05 02:55:59.000000000 +0000
+++ linux-2.6.26-rc1-20080505/include/linux/rtc.h	2008-05-05 21:10:50.000000000 +0000
@@ -200,6 +200,9 @@ extern int rtc_irq_set_state(struct rtc_
 extern int rtc_irq_set_freq(struct rtc_device *rtc,
 				struct rtc_task *task, int freq);
 
+extern unsigned long rtc_read_persistent_clock(void);
+extern int rtc_update_persistent_clock(struct timespec now);
+
 typedef struct rtc_task {
 	void (*func)(void *private_data);
 	void *private_data;
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/kernel/time/ntp.c linux-2.6.26-rc1-20080505/kernel/time/ntp.c
--- linux-2.6.26-rc1-20080505.macro/kernel/time/ntp.c	2008-05-05 02:56:03.000000000 +0000
+++ linux-2.6.26-rc1-20080505/kernel/time/ntp.c	2008-05-05 21:10:50.000000000 +0000
@@ -3,6 +3,8 @@
  *
  * NTP state machine interfaces and logic.
  *
+ * Copyright (c) 2008  Maciej W. Rozycki
+ *
  * This code was mainly moved from kernel/timer.c and kernel/time.c
  * Please see those files for relevant copyright info and historical
  * changelogs.
@@ -17,6 +19,7 @@
 #include <linux/capability.h>
 #include <linux/math64.h>
 #include <linux/clocksource.h>
+#include <linux/workqueue.h>
 #include <asm/timex.h>
 
 /*
@@ -218,11 +221,13 @@ void second_overflow(void)
 /* Disable the cmos update - used by virtualization and embedded */
 int no_sync_cmos_clock  __read_mostly;
 
-static void sync_cmos_clock(unsigned long dummy);
+static void sync_cmos_clock(unsigned long data);
+static void do_sync_cmos_clock(struct work_struct *work);
 
 static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0);
+static DECLARE_WORK(sync_cmos_work, do_sync_cmos_clock);
 
-static void sync_cmos_clock(unsigned long dummy)
+static void do_sync_cmos_clock(struct work_struct *work)
 {
 	struct timespec now, next;
 	int fail = 1;
@@ -261,6 +266,12 @@ static void sync_cmos_clock(unsigned lon
 	mod_timer(&sync_cmos_timer, jiffies + timespec_to_jiffies(&next));
 }
 
+static void sync_cmos_clock(unsigned long data)
+{
+	/* Some implementations of update_persistent_clock() may sleep.  */
+	schedule_work(&sync_cmos_work);
+}
+
 static void notify_cmos_timer(void)
 {
 	if (!no_sync_cmos_clock)
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/kernel/time/timekeeping.c linux-2.6.26-rc1-20080505/kernel/time/timekeeping.c
--- linux-2.6.26-rc1-20080505.macro/kernel/time/timekeeping.c	2008-05-05 02:56:03.000000000 +0000
+++ linux-2.6.26-rc1-20080505/kernel/time/timekeeping.c	2008-05-05 21:10:50.000000000 +0000
@@ -242,7 +242,11 @@ unsigned long __attribute__((weak)) read
 void __init timekeeping_init(void)
 {
 	unsigned long flags;
-	unsigned long sec = read_persistent_clock();
+	unsigned long sec = 0;
+
+#ifndef CONFIG_RTC_HCTOSYS
+	sec = read_persistent_clock();
+#endif
 
 	write_seqlock_irqsave(&xtime_lock, flags);
 

From macro@linux-mips.org Wed May  7 01:42:11 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 01:42:15 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:56565 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022231AbYEGAlZ (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 01:41:25 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m470eZ14020435;
	Wed, 7 May 2008 02:40:36 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m470eZ2u020431;
	Wed, 7 May 2008 01:40:35 +0100
Date:	Wed, 7 May 2008 01:40:35 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 3/4] RTC: SWARM class device persistent clock support
Message-ID: <Pine.LNX.4.55.0805070054440.16173@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19117
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 12014
Lines: 371

 This is a set of changes removing the SWARM platform driver for the
M41T81 and "wiring" the class RTC driver for the persistent clock instead.  
The Xicor clock is unaffected as we have no class driver for this device.
Weak variations of the rtc_read_persistent_clock() and 
rtc_update_persistent_clock() calls are provided as the default -- to be 
overridden by the RTC driver.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 If there is interest and a volunteer to test changes is found, then I can
write a driver for the Xicor clock to complement this change and tidy up.  
It would however require substantial changes to the I2C core as it uses
16-bit commands and an extended SMBus mode of operation of the BCM1250A
controller would have to be used.

 Please note this patch trivially depends on
patch-2.6.26-rc1-20080505-swarm-i2c-15 -- 2/4 of this set.

  Maciej

patch-2.6.26-rc1-20080505-swarm-m41t80-11
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/kernel/time.c linux-2.6.26-rc1-20080505/arch/mips/kernel/time.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/kernel/time.c	2008-05-05 02:55:23.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/kernel/time.c	2008-05-05 21:10:50.000000000 +0000
@@ -44,7 +44,7 @@ int __weak rtc_mips_set_mmss(unsigned lo
 	return rtc_mips_set_time(nowtime);
 }
 
-int update_persistent_clock(struct timespec now)
+int __weak update_persistent_clock(struct timespec now)
 {
 	return rtc_mips_set_mmss(now.tv_sec);
 }
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:25:40.000000000 +0000
@@ -1,4 +1,4 @@
-obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
+obj-y				:= setup.o rtc_xicor1241.o
 
 obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-swarm.o
 obj-$(CONFIG_KGDB)		+= dbg_io.o
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/rtc_m41t81.c linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/rtc_m41t81.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/rtc_m41t81.c	2007-10-11 04:56:52.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/rtc_m41t81.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2000, 2001 Broadcom Corporation
- *
- * Copyright (C) 2002 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- *
- * This program is free software; you can redistribute	it and/or modify it
- * under  the terms of	the GNU General	 Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-#include <linux/bcd.h>
-#include <linux/types.h>
-#include <linux/time.h>
-
-#include <asm/time.h>
-#include <asm/addrspace.h>
-#include <asm/io.h>
-
-#include <asm/sibyte/sb1250.h>
-#include <asm/sibyte/sb1250_regs.h>
-#include <asm/sibyte/sb1250_smbus.h>
-
-
-/* M41T81 definitions */
-
-/*
- * Register bits
- */
-
-#define M41T81REG_SC_ST		0x80		/* stop bit */
-#define M41T81REG_HR_CB		0x40		/* century bit */
-#define M41T81REG_HR_CEB	0x80		/* century enable bit */
-#define M41T81REG_CTL_S		0x20		/* sign bit */
-#define M41T81REG_CTL_FT	0x40		/* frequency test bit */
-#define M41T81REG_CTL_OUT	0x80		/* output level */
-#define M41T81REG_WD_RB0	0x01		/* watchdog resolution bit 0 */
-#define M41T81REG_WD_RB1	0x02		/* watchdog resolution bit 1 */
-#define M41T81REG_WD_BMB0	0x04		/* watchdog multiplier bit 0 */
-#define M41T81REG_WD_BMB1	0x08		/* watchdog multiplier bit 1 */
-#define M41T81REG_WD_BMB2	0x10		/* watchdog multiplier bit 2 */
-#define M41T81REG_WD_BMB3	0x20		/* watchdog multiplier bit 3 */
-#define M41T81REG_WD_BMB4	0x40		/* watchdog multiplier bit 4 */
-#define M41T81REG_AMO_ABE	0x20		/* alarm in "battery back-up mode" enable bit */
-#define M41T81REG_AMO_SQWE	0x40		/* square wave enable */
-#define M41T81REG_AMO_AFE	0x80		/* alarm flag enable flag */
-#define M41T81REG_ADT_RPT5	0x40		/* alarm repeat mode bit 5 */
-#define M41T81REG_ADT_RPT4	0x80		/* alarm repeat mode bit 4 */
-#define M41T81REG_AHR_RPT3	0x80		/* alarm repeat mode bit 3 */
-#define M41T81REG_AHR_HT	0x40		/* halt update bit */
-#define M41T81REG_AMN_RPT2	0x80		/* alarm repeat mode bit 2 */
-#define M41T81REG_ASC_RPT1	0x80		/* alarm repeat mode bit 1 */
-#define M41T81REG_FLG_AF	0x40		/* alarm flag (read only) */
-#define M41T81REG_FLG_WDF	0x80		/* watchdog flag (read only) */
-#define M41T81REG_SQW_RS0	0x10		/* sqw frequency bit 0 */
-#define M41T81REG_SQW_RS1	0x20		/* sqw frequency bit 1 */
-#define M41T81REG_SQW_RS2	0x40		/* sqw frequency bit 2 */
-#define M41T81REG_SQW_RS3	0x80		/* sqw frequency bit 3 */
-
-
-/*
- * Register numbers
- */
-
-#define M41T81REG_TSC	0x00		/* tenths/hundredths of second */
-#define M41T81REG_SC	0x01		/* seconds */
-#define M41T81REG_MN	0x02		/* minute */
-#define M41T81REG_HR	0x03		/* hour/century */
-#define M41T81REG_DY	0x04		/* day of week */
-#define M41T81REG_DT	0x05		/* date of month */
-#define M41T81REG_MO	0x06		/* month */
-#define M41T81REG_YR	0x07		/* year */
-#define M41T81REG_CTL	0x08		/* control */
-#define M41T81REG_WD	0x09		/* watchdog */
-#define M41T81REG_AMO	0x0A		/* alarm: month */
-#define M41T81REG_ADT	0x0B		/* alarm: date */
-#define M41T81REG_AHR	0x0C		/* alarm: hour */
-#define M41T81REG_AMN	0x0D		/* alarm: minute */
-#define M41T81REG_ASC	0x0E		/* alarm: second */
-#define M41T81REG_FLG	0x0F		/* flags */
-#define M41T81REG_SQW	0x13		/* square wave register */
-
-#define M41T81_CCR_ADDRESS	0x68
-
-#define SMB_CSR(reg)	IOADDR(A_SMB_REGISTER(1, reg))
-
-static int m41t81_read(uint8_t addr)
-{
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	__raw_writeq(addr & 0xff, SMB_CSR(R_SMB_CMD));
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_WR1BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_RD1BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	if (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_ERROR) {
-		/* Clear error bit by writing a 1 */
-		__raw_writeq(M_SMB_ERROR, SMB_CSR(R_SMB_STATUS));
-		return -1;
-	}
-
-	return (__raw_readq(SMB_CSR(R_SMB_DATA)) & 0xff);
-}
-
-static int m41t81_write(uint8_t addr, int b)
-{
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	__raw_writeq(addr & 0xff, SMB_CSR(R_SMB_CMD));
-	__raw_writeq(b & 0xff, SMB_CSR(R_SMB_DATA));
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_WR2BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	if (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_ERROR) {
-		/* Clear error bit by writing a 1 */
-		__raw_writeq(M_SMB_ERROR, SMB_CSR(R_SMB_STATUS));
-		return -1;
-	}
-
-	/* read the same byte again to make sure it is written */
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_RD1BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	return 0;
-}
-
-int m41t81_set_time(unsigned long t)
-{
-	struct rtc_time tm;
-	unsigned long flags;
-
-	/* Note we don't care about the century */
-	rtc_time_to_tm(t, &tm);
-
-	/*
-	 * Note the write order matters as it ensures the correctness.
-	 * When we write sec, 10th sec is clear.  It is reasonable to
-	 * believe we should finish writing min within a second.
-	 */
-
-	spin_lock_irqsave(&rtc_lock, flags);
-	tm.tm_sec = BIN2BCD(tm.tm_sec);
-	m41t81_write(M41T81REG_SC, tm.tm_sec);
-
-	tm.tm_min = BIN2BCD(tm.tm_min);
-	m41t81_write(M41T81REG_MN, tm.tm_min);
-
-	tm.tm_hour = BIN2BCD(tm.tm_hour);
-	tm.tm_hour = (tm.tm_hour & 0x3f) | (m41t81_read(M41T81REG_HR) & 0xc0);
-	m41t81_write(M41T81REG_HR, tm.tm_hour);
-
-	/* tm_wday starts from 0 to 6 */
-	if (tm.tm_wday == 0) tm.tm_wday = 7;
-	tm.tm_wday = BIN2BCD(tm.tm_wday);
-	m41t81_write(M41T81REG_DY, tm.tm_wday);
-
-	tm.tm_mday = BIN2BCD(tm.tm_mday);
-	m41t81_write(M41T81REG_DT, tm.tm_mday);
-
-	/* tm_mon starts from 0, *ick* */
-	tm.tm_mon ++;
-	tm.tm_mon = BIN2BCD(tm.tm_mon);
-	m41t81_write(M41T81REG_MO, tm.tm_mon);
-
-	/* we don't do century, everything is beyond 2000 */
-	tm.tm_year %= 100;
-	tm.tm_year = BIN2BCD(tm.tm_year);
-	m41t81_write(M41T81REG_YR, tm.tm_year);
-	spin_unlock_irqrestore(&rtc_lock, flags);
-
-	return 0;
-}
-
-unsigned long m41t81_get_time(void)
-{
-	unsigned int year, mon, day, hour, min, sec;
-	unsigned long flags;
-
-	/*
-	 * min is valid if two reads of sec are the same.
-	 */
-	for (;;) {
-		spin_lock_irqsave(&rtc_lock, flags);
-		sec = m41t81_read(M41T81REG_SC);
-		min = m41t81_read(M41T81REG_MN);
-		if (sec == m41t81_read(M41T81REG_SC)) break;
-		spin_unlock_irqrestore(&rtc_lock, flags);
-	}
-	hour = m41t81_read(M41T81REG_HR) & 0x3f;
-	day = m41t81_read(M41T81REG_DT);
-	mon = m41t81_read(M41T81REG_MO);
-	year = m41t81_read(M41T81REG_YR);
-	spin_unlock_irqrestore(&rtc_lock, flags);
-
-	sec = BCD2BIN(sec);
-	min = BCD2BIN(min);
-	hour = BCD2BIN(hour);
-	day = BCD2BIN(day);
-	mon = BCD2BIN(mon);
-	year = BCD2BIN(year);
-
-	year += 2000;
-
-	return mktime(year, mon, day, hour, min, sec);
-}
-
-int m41t81_probe(void)
-{
-	unsigned int tmp;
-
-	/* enable chip if it is not enabled yet */
-	tmp = m41t81_read(M41T81REG_SC);
-	m41t81_write(M41T81REG_SC, tmp & 0x7f);
-
-	return (m41t81_read(M41T81REG_SC) != -1);
-}
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/setup.c linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/setup.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/setup.c	2007-10-23 02:55:20.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/setup.c	2008-05-05 21:10:50.000000000 +0000
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
  * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
+ * Copyright (C) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -29,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/screen_info.h>
 #include <linux/initrd.h>
+#include <linux/rtc.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
@@ -60,10 +62,6 @@ extern int xicor_probe(void);
 extern int xicor_set_time(unsigned long);
 extern unsigned long xicor_get_time(void);
 
-extern int m41t81_probe(void);
-extern int m41t81_set_time(unsigned long);
-extern unsigned long m41t81_get_time(void);
-
 const char *get_system_type(void)
 {
 	return "SiByte " SIBYTE_BOARD_NAME;
@@ -82,38 +80,41 @@ int swarm_be_handler(struct pt_regs *reg
 enum swarm_rtc_type {
 	RTC_NONE,
 	RTC_XICOR,
-	RTC_M4LT81
 };
 
 enum swarm_rtc_type swarm_rtc_type;
 
+unsigned long __weak rtc_read_persistent_clock(void)
+{
+	return mktime(2000, 1, 1, 0, 0, 0);
+}
+
+int __weak rtc_update_persistent_clock(struct timespec now)
+{
+	return 0;
+}
+
 unsigned long read_persistent_clock(void)
 {
 	switch (swarm_rtc_type) {
 	case RTC_XICOR:
 		return xicor_get_time();
 
-	case RTC_M4LT81:
-		return m41t81_get_time();
-
 	case RTC_NONE:
 	default:
-		return mktime(2000, 1, 1, 0, 0, 0);
+		return rtc_read_persistent_clock();
 	}
 }
 
-int rtc_mips_set_time(unsigned long sec)
+int update_persistent_clock(struct timespec now)
 {
 	switch (swarm_rtc_type) {
 	case RTC_XICOR:
-		return xicor_set_time(sec);
-
-	case RTC_M4LT81:
-		return m41t81_set_time(sec);
+		return xicor_set_time(now.tv_sec);
 
 	case RTC_NONE:
 	default:
-		return -1;
+		return rtc_update_persistent_clock(now);
 	}
 }
 
@@ -133,8 +134,6 @@ void __init plat_mem_setup(void)
 
 	if (xicor_probe())
 		swarm_rtc_type = RTC_XICOR;
-	if (m41t81_probe())
-		swarm_rtc_type = RTC_M4LT81;
 
 	printk("This kernel optimized for "
 #ifdef CONFIG_SIMULATION

From macro@linux-mips.org Wed May  7 01:42:36 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 01:42:40 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:57333 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20021860AbYEGAlb (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 01:41:31 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m470efYf020443;
	Wed, 7 May 2008 02:40:41 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m470efeR020439;
	Wed, 7 May 2008 01:40:41 +0100
Date:	Wed, 7 May 2008 01:40:41 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80, etc. driver
Message-ID: <Pine.LNX.4.55.0805070102460.16173@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19118
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 18373
Lines: 624

 The BCM1250A SOC which is used on the SWARM board utilising an M41T81
chip only supports pure I2C in the raw bit-banged mode.  Nobody sane
really wants to use it unless absolutely necessary and the M41T80, etc.  
chips work just fine with an SMBus controller which is what the standard
mode of operation of the BCM1250A.  The only drawback of byte accesses
with the M41T80 is the chip only latches clock data registers for the
duration of an I2C transaction which works fine with a block transfers,
but not byte-wise accesses.

 The driver currently requires an I2C controller providing both SMBus and
pure I2C access.  This is a set of changes to make it work with either,
with a preference to pure I2C.  The problem of unlatched clock data if
SMBus transactions are used is resolved in the standard way.

 Whether a choice between SMBus and pure I2C access is possible is 
obviously device dependent.  If the code proved useful for other I2C 
devices, then it could be moved to a more generic place.  It is a code
simplification regardless -- similar I2C packet definitions are not 
scattered throughout the driver anymore.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 Please note I have no means to test these changes with a pure I2C 
controller -- anybody interested, please help.

  Maciej

patch-2.6.26-rc1-20080505-m41t80-smbus-12
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-06 18:15:42.000000000 +0000
@@ -6,6 +6,7 @@
  * Based on m41t00.c by Mark A. Greer <mgreer@mvista.com>
  *
  * 2006 (c) mycable GmbH
+ * Copyright (c) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -13,36 +14,39 @@
  *
  */
 
-#include <linux/module.h>
+#include <linux/bcd.h>
+#include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rtc.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/i2c.h>
-#include <linux/rtc.h>
-#include <linux/bcd.h>
 #ifdef CONFIG_RTC_DRV_M41T80_WDT
-#include <linux/miscdevice.h>
-#include <linux/watchdog.h>
-#include <linux/reboot.h>
 #include <linux/fs.h>
 #include <linux/ioctl.h>
+#include <linux/miscdevice.h>
+#include <linux/reboot.h>
+#include <linux/watchdog.h>
 #endif
 
-#define M41T80_REG_SSEC	0
-#define M41T80_REG_SEC	1
-#define M41T80_REG_MIN	2
-#define M41T80_REG_HOUR	3
-#define M41T80_REG_WDAY	4
-#define M41T80_REG_DAY	5
-#define M41T80_REG_MON	6
-#define M41T80_REG_YEAR	7
+#define M41T80_REG_SSEC		0
+#define M41T80_REG_SEC		1
+#define M41T80_REG_MIN		2
+#define M41T80_REG_HOUR		3
+#define M41T80_REG_WDAY		4
+#define M41T80_REG_DAY		5
+#define M41T80_REG_MON		6
+#define M41T80_REG_YEAR		7
+#define M41T80_REG_CONTROL	8
+#define M41T80_REG_WATCHDOG	9
 #define M41T80_REG_ALARM_MON	0xa
 #define M41T80_REG_ALARM_DAY	0xb
 #define M41T80_REG_ALARM_HOUR	0xc
 #define M41T80_REG_ALARM_MIN	0xd
 #define M41T80_REG_ALARM_SEC	0xe
 #define M41T80_REG_FLAGS	0xf
-#define M41T80_REG_SQW	0x13
+#define M41T80_REG_SQW		0x13
 
 #define M41T80_DATETIME_REG_SIZE	(M41T80_REG_YEAR + 1)
 #define M41T80_ALARM_REG_SIZE	\
@@ -58,7 +62,7 @@
 #define M41T80_FEATURE_HT	(1 << 0)
 #define M41T80_FEATURE_BL	(1 << 1)
 
-#define DRV_VERSION "0.05"
+#define DRV_VERSION "0.06"
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t80", 0 },
@@ -78,31 +82,108 @@ struct m41t80_data {
 	struct rtc_device *rtc;
 };
 
-static int m41t80_get_datetime(struct i2c_client *client,
-			       struct rtc_time *tm)
+
+static int m41t80_i2c_transfer(struct i2c_client *client, int write,
+			       u8 reg, u8 num, u8 *buf)
 {
-	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
 	struct i2c_msg msgs[] = {
 		{
 			.addr	= client->addr,
 			.flags	= 0,
 			.len	= 1,
-			.buf	= dt_addr,
+			.buf	= &reg,
 		},
 		{
 			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
+			.flags	= write ? 0 : I2C_M_RD,
+			.len	= num,
+			.buf	= buf,
 		},
 	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
-		dev_err(&client->dev, "read error\n");
-		return -EIO;
+	return i2c_transfer(client->adapter, msgs, 2);
+}
+
+static int m41t80_read_byte_data(struct i2c_client *client, u8 reg)
+{
+	int rc;
+	u8 val;
+
+	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		rc = m41t80_i2c_transfer(client, 0, reg, 1, &val);
+		if (rc < 0)
+			return rc;
+		else
+			return val;
+	} else
+		return i2c_smbus_read_byte_data(client, reg);
+}
+
+static int m41t80_write_byte_data(struct i2c_client *client, u8 reg, u8 val)
+{
+	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+		return m41t80_i2c_transfer(client, 1, reg, 1, &val);
+	else
+		return i2c_smbus_write_byte_data(client, reg, val);
+}
+
+static int m41t80_transfer(struct i2c_client *client, int write,
+			   u8 reg, u8 num, u8 *buf)
+{
+	int i, rc;
+
+	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+		return m41t80_i2c_transfer(client, write, reg, num, buf);
+	else if (write) {
+		for (i = 0; i < num; i++) {
+			rc = i2c_smbus_write_byte_data(client, reg + i,
+						       buf[i]);
+			if (rc < 0)
+				return rc;
+		}
+		return 0;
+	} else {
+		for (i = 0; i < num; i++) {
+			rc = i2c_smbus_read_byte_data(client, reg + i);
+			if (rc < 0)
+				return rc;
+			buf[i] = rc;
+		}
+		return 0;
 	}
+}
+
+static int m41t80_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+	u8 buf[M41T80_DATETIME_REG_SIZE];
+	int loops = 2;
+	int sec0, sec1;
+
+	/*
+	 * Time registers are latched by this chip if an I2C block
+	 * transfer is used, but with SMBus-style byte accesses
+	 * this is not the case, so check seconds for a wraparound.
+	 */
+	do {
+		if (m41t80_transfer(client, 0, M41T80_REG_SEC,
+				    M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+				    buf + M41T80_REG_SEC)) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+		sec0 = buf[M41T80_REG_SEC];
+
+		sec1 = m41t80_read_byte_data(client, M41T80_REG_SEC);
+		if (sec1 < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
 
-	tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f);
+		sec0 = BCD2BIN(sec0 & 0x7f);
+		sec1 = BCD2BIN(sec1 & 0x7f);
+	} while (sec1 < sec0 && --loops);
+
+	tm->tm_sec = sec1;
 	tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f);
 	tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f);
 	tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f);
@@ -117,39 +198,16 @@ static int m41t80_get_datetime(struct i2
 /* Sets the given date and time to the real time clock. */
 static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-	u8 wbuf[1 + M41T80_DATETIME_REG_SIZE];
-	u8 *buf = &wbuf[1];
-	u8 dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_DATETIME_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
+	u8 buf[M41T80_DATETIME_REG_SIZE];
 
 	/* Read current reg values into buf[1..7] */
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_SEC,
+			    M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+			    buf + M41T80_REG_SEC)) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
 
-	wbuf[0] = 0; /* offset into rtc's regs */
 	/* Merge time-data and register flags into buf[0..7] */
 	buf[M41T80_REG_SSEC] = 0;
 	buf[M41T80_REG_SEC] =
@@ -167,7 +225,8 @@ static int m41t80_set_datetime(struct i2
 	/* assume 20YY not 19YY */
 	buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_transfer(client, 1, M41T80_REG_SSEC,
+			    M41T80_DATETIME_REG_SIZE, buf)) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -182,7 +241,7 @@ static int m41t80_rtc_proc(struct device
 	u8 reg;
 
 	if (clientdata->features & M41T80_FEATURE_BL) {
-		reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
+		reg = m41t80_read_byte_data(client, M41T80_REG_FLAGS);
 		seq_printf(seq, "battery\t\t: %s\n",
 			   (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok");
 	}
@@ -217,7 +276,7 @@ m41t80_rtc_ioctl(struct device *dev, uns
 		return -ENOIOCTLCMD;
 	}
 
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON);
+	rc = m41t80_read_byte_data(client, M41T80_REG_ALARM_MON);
 	if (rc < 0)
 		goto err;
 	switch (cmd) {
@@ -228,7 +287,7 @@ m41t80_rtc_ioctl(struct device *dev, uns
 		rc |= M41T80_ALMON_AFE;
 		break;
 	}
-	if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, rc) < 0)
+	if (m41t80_write_byte_data(client, M41T80_REG_ALARM_MON, rc) < 0)
 		goto err;
 	return 0;
 err:
@@ -241,34 +300,11 @@ err:
 static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 wbuf[1 + M41T80_ALARM_REG_SIZE];
-	u8 *buf = &wbuf[1];
+	u8 buf[M41T80_ALARM_REG_SIZE];
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE,
-			.buf	= buf,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_ALARM_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
 
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE, buf)) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -278,7 +314,6 @@ static int m41t80_rtc_set_alarm(struct d
 	reg[M41T80_REG_ALARM_MIN] = 0;
 	reg[M41T80_REG_ALARM_SEC] = 0;
 
-	wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */
 	reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ?
 		BIN2BCD(t->time.tm_sec) : 0x80;
 	reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ?
@@ -292,15 +327,16 @@ static int m41t80_rtc_set_alarm(struct d
 	else
 		reg[M41T80_REG_ALARM_DAY] |= 0x40;
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_transfer(client, 1, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE, buf)) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
 
 	if (t->enabled) {
 		reg[M41T80_REG_ALARM_MON] |= M41T80_ALMON_AFE;
-		if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
-					      reg[M41T80_REG_ALARM_MON]) < 0) {
+		if (m41t80_write_byte_data(client, M41T80_REG_ALARM_MON,
+					   reg[M41T80_REG_ALARM_MON]) < 0) {
 			dev_err(&client->dev, "write error\n");
 			return -EIO;
 		}
@@ -311,25 +347,11 @@ static int m41t80_rtc_set_alarm(struct d
 static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 buf[M41T80_ALARM_REG_SIZE + 1]; /* all alarm regs and flags */
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
+	u8 buf[M41T80_ALARM_REG_SIZE + 1];	/* all alarm regs and flags */
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE + 1,
-			.buf	= buf,
-		},
-	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE + 1, buf)) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -373,7 +395,7 @@ static ssize_t m41t80_sysfs_show_flags(s
 	struct i2c_client *client = to_i2c_client(dev);
 	int val;
 
-	val = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
+	val = m41t80_read_byte_data(client, M41T80_REG_FLAGS);
 	if (val < 0)
 		return -EIO;
 	return sprintf(buf, "%#x\n", val);
@@ -386,7 +408,7 @@ static ssize_t m41t80_sysfs_show_sqwfreq
 	struct i2c_client *client = to_i2c_client(dev);
 	int val;
 
-	val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW);
+	val = m41t80_read_byte_data(client, M41T80_REG_SQW);
 	if (val < 0)
 		return -EIO;
 	val = (val >> 4) & 0xf;
@@ -421,19 +443,19 @@ static ssize_t m41t80_sysfs_set_sqwfreq(
 			return -EINVAL;
 	}
 	/* disable SQW, set SQW frequency & re-enable */
-	almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON);
+	almon = m41t80_read_byte_data(client, M41T80_REG_ALARM_MON);
 	if (almon < 0)
 		return -EIO;
-	sqw = i2c_smbus_read_byte_data(client, M41T80_REG_SQW);
+	sqw = m41t80_read_byte_data(client, M41T80_REG_SQW);
 	if (sqw < 0)
 		return -EIO;
 	sqw = (sqw & 0x0f) | (val << 4);
-	if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
-				      almon & ~M41T80_ALMON_SQWE) < 0 ||
-	    i2c_smbus_write_byte_data(client, M41T80_REG_SQW, sqw) < 0)
+	if (m41t80_write_byte_data(client, M41T80_REG_ALARM_MON,
+				   almon & ~M41T80_ALMON_SQWE) < 0 ||
+	    m41t80_write_byte_data(client, M41T80_REG_SQW, sqw) < 0)
 		return -EIO;
-	if (val && i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON,
-					     almon | M41T80_ALMON_SQWE) < 0)
+	if (val && m41t80_write_byte_data(client, M41T80_REG_ALARM_MON,
+					  almon | M41T80_ALMON_SQWE) < 0)
 		return -EIO;
 	return count;
 }
@@ -488,26 +510,16 @@ static int boot_flag;
  */
 static void wdt_ping(void)
 {
-	unsigned char i2c_data[2];
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-	i2c_data[0] = 0x09;		/* watchdog register */
+	u8 wdt = 0x80;				/* WDS = 1 (0x80)  */
 
 	if (wdt_margin > 31)
-		i2c_data[1] = (wdt_margin & 0xFC) | 0x83; /* resolution = 4s */
+		/* mulitplier = WD_TIMO / 4, resolution = 4s (0x3)  */
+		wdt |= (wdt_margin & 0xfc) | 0x3;
 	else
-		/*
-		 * WDS = 1 (0x80), mulitplier = WD_TIMO, resolution = 1s (0x02)
-		 */
-		i2c_data[1] = wdt_margin<<2 | 0x82;
+		/* mulitplier = WD_TIMO, resolution = 1s (0x2)  */
+		wdt |= wdt_margin << 2 | 0x2;
 
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	m41t80_write_byte_data(save_client, M41T80_REG_WATCHDOG, wdt);
 }
 
 /**
@@ -517,36 +529,8 @@ static void wdt_ping(void)
  */
 static void wdt_disable(void)
 {
-	unsigned char i2c_data[2], i2c_buf[0x10];
-	struct i2c_msg msgs0[2] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= i2c_data,
-		},
-		{
-			.addr	= save_client->addr,
-			.flags	= I2C_M_RD,
-			.len	= 1,
-			.buf	= i2c_buf,
-		},
-	};
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-
-	i2c_data[0] = 0x09;
-	i2c_transfer(save_client->adapter, msgs0, 2);
-
-	i2c_data[0] = 0x09;
-	i2c_data[1] = 0x00;
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	m41t80_read_byte_data(save_client, M41T80_REG_WATCHDOG);
+	m41t80_write_byte_data(save_client, M41T80_REG_WATCHDOG, 0);
 }
 
 /**
@@ -629,14 +613,12 @@ static int wdt_ioctl(struct inode *inode
 			return -EFAULT;
 
 		if (rv & WDIOS_DISABLECARD) {
-			printk(KERN_INFO
-			       "rtc-m41t80: disable watchdog\n");
+			pr_info("rtc-m41t80: disable watchdog\n");
 			wdt_disable();
 		}
 
 		if (rv & WDIOS_ENABLECARD) {
-			printk(KERN_INFO
-			       "rtc-m41t80: enable watchdog\n");
+			pr_info("rtc-m41t80: enable watchdog\n");
 			wdt_ping();
 		}
 
@@ -732,19 +714,28 @@ static struct notifier_block wdt_notifie
 static int m41t80_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
-	int rc = 0;
 	struct rtc_device *rtc = NULL;
 	struct rtc_time tm;
 	struct m41t80_data *clientdata = NULL;
+	int rc = 0;
+	int reg;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
-				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
+	if ((i2c_get_functionality(client->adapter) &
+	     (I2C_FUNC_I2C | I2C_FUNC_SMBUS_BYTE_DATA)) == 0) {
 		rc = -ENODEV;
 		goto exit;
 	}
 
+	/* Trivially check it's there; keep the result for the HT check.  */
+	reg = m41t80_read_byte_data(client, M41T80_REG_ALARM_HOUR);
+	if (reg < 0) {
+		rc = -ENXIO;
+		goto exit;
+	}
+
 	dev_info(&client->dev,
-		 "chip found, driver version " DRV_VERSION "\n");
+		 "%s chip found, driver version " DRV_VERSION "\n",
+		 client->name);
 
 	clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL);
 	if (!clientdata) {
@@ -765,11 +756,7 @@ static int m41t80_probe(struct i2c_clien
 	i2c_set_clientdata(client, clientdata);
 
 	/* Make sure HT (Halt Update) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
-	if (rc < 0)
-		goto ht_err;
-
-	if (rc & M41T80_ALHOUR_HT) {
+	if (reg & M41T80_ALHOUR_HT) {
 		if (clientdata->features & M41T80_FEATURE_HT) {
 			m41t80_get_datetime(client, &tm);
 			dev_info(&client->dev, "HT bit was set!\n");
@@ -780,20 +767,19 @@ static int m41t80_probe(struct i2c_clien
 				 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
 				 tm.tm_min, tm.tm_sec);
 		}
-		if (i2c_smbus_write_byte_data(client,
-					      M41T80_REG_ALARM_HOUR,
-					      rc & ~M41T80_ALHOUR_HT) < 0)
+		if (m41t80_write_byte_data(client, M41T80_REG_ALARM_HOUR,
+					   reg & ~M41T80_ALHOUR_HT) < 0)
 			goto ht_err;
 	}
 
 	/* Make sure ST (stop) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
-	if (rc < 0)
+	reg = m41t80_read_byte_data(client, M41T80_REG_SEC);
+	if (reg < 0)
 		goto st_err;
 
-	if (rc & M41T80_SEC_ST) {
-		if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
-					      rc & ~M41T80_SEC_ST) < 0)
+	if (reg & M41T80_SEC_ST) {
+		if (m41t80_write_byte_data(client, M41T80_REG_SEC,
+					   reg & ~M41T80_SEC_ST) < 0)
 			goto st_err;
 	}
 
@@ -803,6 +789,7 @@ static int m41t80_probe(struct i2c_clien
 
 #ifdef CONFIG_RTC_DRV_M41T80_WDT
 	if (clientdata->features & M41T80_FEATURE_HT) {
+		save_client = client;
 		rc = misc_register(&wdt_dev);
 		if (rc)
 			goto exit;
@@ -811,7 +798,6 @@ static int m41t80_probe(struct i2c_clien
 			misc_deregister(&wdt_dev);
 			goto exit;
 		}
-		save_client = client;
 	}
 #endif
 	return 0;

From alessandro.zummo@towertech.it Wed May  7 07:57:42 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 07:57:45 +0100 (BST)
Received: from mx0.towertech.it ([213.215.222.73]:58349 "HELO mx0.towertech.it")
	by ftp.linux-mips.org with SMTP id S20044493AbYEGG5m (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 07:57:42 +0100
Received: (qmail 5386 invoked from network); 7 May 2008 08:57:40 +0200
Received: from unknown (HELO i1501.lan.towertech.it) (81.208.60.204)
  by mx0.towertech.it with SMTP; 7 May 2008 08:57:40 +0200
Date:	Wed, 7 May 2008 08:57:39 +0200
From:	Alessandro Zummo <alessandro.zummo@towertech.it>
To:	rtc-linux@googlegroups.com
Cc:	macro@linux-mips.org, Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [rtc-linux] [RFC][PATCH 0/4] RTC: Use class devices as a
 persistent clock
Message-ID: <20080507085739.4f538d2e@i1501.lan.towertech.it>
In-Reply-To: <Pine.LNX.4.55.0805062333390.16173@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805062333390.16173@cliff.in.clinika.pl>
Organization: Tower Technologies
X-Mailer: Sylpheed
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <alessandro.zummo@towertech.it>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19119
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: alessandro.zummo@towertech.it
Precedence: bulk
X-list: linux-mips
Content-Length: 985
Lines: 34

On Wed, 7 May 2008 01:39:59 +0100 (BST)
"Maciej W. Rozycki" <macro@linux-mips.org> wrote:

> 
> Hello,
> 
>  While investigating why Linux on the MIPS64 Broadcom BCM91250A board (the
> SWARM, based on the SiByte BCM1250A SOC) does not support an RTC device
> anymore I discovered the "wiring" of code to access /dev/rtc to the RTC
> device driver got removed with some changes that happened a while ago.  
> The board uses the ST M41T81 I2C chip with a driver buried within the
> architecture code.  There is a standard driver for this chip in our tree
> already, which is called rtc-m41t80, and which as a part of the RTC driver
> suite provides the necessary "wiring" to /dev/rtc.

 [...]


 Hi Maciej,

   you did a great work. you have my Acked-by on the rtc/ntp code, but
 I think we'd need some reports from current users of the m41t81 driver
 before pushing that one in.


-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


From khali@linux-fr.org Wed May  7 08:00:06 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 08:00:10 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:20552 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20044497AbYEGHAG (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 08:00:06 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JteZQ-0003ty-I5
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Wed, 07 May 2008 10:00:12 +0200
Date:	Wed, 7 May 2008 08:59:53 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080507085953.2c08b854@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19120
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2642
Lines: 78

Hi Maciej,

On Wed, 7 May 2008 01:40:27 +0100 (BST), Maciej W. Rozycki wrote:
> (...)
> 2. The i2c-sibyte.c BCM1250A SMBus controller driver now registers its 
>    buses as numbered so that board setup is correctly applied.  Plus minor 
>    corrections.

Minor corrections which would ideally belong to a separate patch
(there's a whole lot more cleanups that could be done in that driver,
BTW...)

> (...)
> --- linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c	2008-05-05 02:55:25.000000000 +0000
> +++ linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c	2008-05-06 23:45:32.000000000 +0000
> @@ -2,6 +2,7 @@
>   * Copyright (C) 2004 Steven J. Hill
>   * Copyright (C) 2001,2002,2003 Broadcom Corporation
>   * Copyright (C) 1995-2000 Simon G. Vogl
> + * Copyright (C) 2008  Maciej W. Rozycki

I don't think that the minor changes below are enough for you to claim
copyright on that driver.

>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -132,18 +133,18 @@ static const struct i2c_algorithm i2c_si
>  /*
>   * registering functions to load algorithms at runtime
>   */
> -int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
> +static int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
>  {
>  	struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
>  
> -	/* register new adapter to i2c module... */
> +	/* Register new adapter to i2c module...  */
>  	i2c_adap->algo = &i2c_sibyte_algo;
>  
> -	/* Set the frequency to 100 kHz */
> +	/* Set the requested frequency.  */

Why do you double the space and the end of comments? Never seen that
before, and I can't see the idea.

>  	csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
>  	csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
>  
> -	return i2c_add_adapter(i2c_adap);
> +	return i2c_add_numbered_adapter(i2c_adap);
>  }
>  
>  
> @@ -159,6 +160,7 @@ static struct i2c_adapter sibyte_board_a
>  		.class		= I2C_CLASS_HWMON,
>  		.algo		= NULL,
>  		.algo_data	= &sibyte_board_data[0],
> +		.nr		= 0,
>  		.name		= "SiByte SMBus 0",
>  	},
>  	{
> @@ -167,6 +169,7 @@ static struct i2c_adapter sibyte_board_a
>  		.class		= I2C_CLASS_HWMON,
>  		.algo		= NULL,
>  		.algo_data	= &sibyte_board_data[1],
> +		.nr		= 1,
>  		.name		= "SiByte SMBus 1",
>  	},
>  };

I'm not sure how you intend to push these changes upstream. I would
take a patch only touching drivers/i2c/busses/i2c-sibyte.c in my i2c
tree, however a patch also touching arch code, must be handled be the
maintainer for that architecture or platform.

-- 
Jean Delvare

From khali@linux-fr.org Wed May  7 08:05:29 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 08:05:33 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:4899 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20044581AbYEGHF3 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 08:05:29 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Jteeb-0004uz-ID
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Wed, 07 May 2008 10:05:34 +0200
Date:	Wed, 7 May 2008 09:05:14 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080507090514.3a86cf4b@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19121
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1214
Lines: 29

Oh, BTW...

On Wed, 7 May 2008 01:40:27 +0100 (BST), Maciej W. Rozycki wrote:
> (...)
> 1. i2c-swarm.c -- SWARM I2C board setup, currently for the M41T80 chip on 
>    the bus #1 only.
> (...)
> --- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2004-01-29 04:57:05.000000000 +0000
> +++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
> @@ -1,3 +1,4 @@
> -lib-y				= setup.o rtc_xicor1241.o rtc_m41t81.o
> +obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
>  
> -lib-$(CONFIG_KGDB)		+= dbg_io.o
> +obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-swarm.o
> +obj-$(CONFIG_KGDB)		+= dbg_io.o
> (...)
> --- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/i2c-swarm.c	1970-01-01 00:00:00.000000000 +0000
> +++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/i2c-swarm.c	2008-05-06 23:51:34.000000000 +0000

i2c-foo.c is consistently used for i2c bus driver themselves so far.
It's somewhat confusing to see you name platform code that way. It's
also redundant, given that the file lives in the swarm platform
directory. May I suggest naming this file just
arch/mips/sibyte/swarm/i2c.c? Other architectures (cris, arm) are doing
this already.

-- 
Jean Delvare

From akpm@linux-foundation.org Wed May  7 08:09:54 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 08:09:56 +0100 (BST)
Received: from smtp1.linux-foundation.org ([140.211.169.13]:13026 "EHLO
	smtp1.linux-foundation.org") by ftp.linux-mips.org with ESMTP
	id S20044702AbYEGHJy (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 08:09:54 +0100
Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55])
	by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id m4778vLt010021
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Wed, 7 May 2008 00:08:59 -0700
Received: from y.localdomain (localhost [127.0.0.1])
	by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with SMTP id m4778r74017104;
	Wed, 7 May 2008 00:08:55 -0700
Date:	Wed, 7 May 2008 00:08:53 -0700
From:	Andrew Morton <akpm@linux-foundation.org>
To:	Jean Delvare <khali@linux-fr.org>
Cc:	"Maciej W. Rozycki" <macro@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-Id: <20080507000853.17f1316b.akpm@linux-foundation.org>
In-Reply-To: <20080507085953.2c08b854@hyperion.delvare>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
	<20080507085953.2c08b854@hyperion.delvare>
X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-MIMEDefang-Filter: lf$Revision: 1.188 $
X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13
Return-Path: <akpm@linux-foundation.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19122
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: akpm@linux-foundation.org
Precedence: bulk
X-list: linux-mips
Content-Length: 604
Lines: 14

On Wed, 7 May 2008 08:59:53 +0200 Jean Delvare <khali@linux-fr.org> wrote:

> I'm not sure how you intend to push these changes upstream. I would
> take a patch only touching drivers/i2c/busses/i2c-sibyte.c in my i2c
> tree, however a patch also touching arch code, must be handled be the
> maintainer for that architecture or platform.

Not "must".  The arch maintainer could ask you to merge it or you could ask
the arch maintainer to merge it.

It's some little one-line change like this one appeared to be, it's
fair to assume the arch maintainer won't care much about it.  View it as an
i2c patch?


From geert@linux-m68k.org Wed May  7 08:37:12 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 08:37:15 +0100 (BST)
Received: from winston.telenet-ops.be ([195.130.137.75]:41863 "EHLO
	winston.telenet-ops.be") by ftp.linux-mips.org with ESMTP
	id S20029177AbYEGHhM (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 08:37:12 +0100
Received: from localhost (localhost.localdomain [127.0.0.1])
	by winston.telenet-ops.be (Postfix) with SMTP id 6815BA0042;
	Wed,  7 May 2008 09:37:11 +0200 (CEST)
Received: from anakin.of.borg (78-21-204-88.access.telenet.be [78.21.204.88])
	by winston.telenet-ops.be (Postfix) with ESMTP id D5C48A0051;
	Wed,  7 May 2008 09:37:06 +0200 (CEST)
Received: from anakin.of.borg (localhost [127.0.0.1])
	by anakin.of.borg (8.14.2/8.14.2/Debian-4) with ESMTP id m477b4G0011576
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
	Wed, 7 May 2008 09:37:04 +0200
Received: from localhost (geert@localhost)
	by anakin.of.borg (8.14.2/8.14.2/Submit) with ESMTP id m477b38o011573;
	Wed, 7 May 2008 09:37:03 +0200
X-Authentication-Warning: anakin.of.borg: geert owned process doing -bs
Date:	Wed, 7 May 2008 09:37:01 +0200 (CEST)
From:	Geert Uytterhoeven <geert@linux-m68k.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	"Maciej W. Rozycki" <macro@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080507090514.3a86cf4b@hyperion.delvare>
Message-ID: <Pine.LNX.4.64.0805070936060.6341@anakin>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507090514.3a86cf4b@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <geert@linux-m68k.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19123
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: geert@linux-m68k.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1726
Lines: 41

On Wed, 7 May 2008, Jean Delvare wrote:
> Oh, BTW...
> 
> On Wed, 7 May 2008 01:40:27 +0100 (BST), Maciej W. Rozycki wrote:
> > (...)
> > 1. i2c-swarm.c -- SWARM I2C board setup, currently for the M41T80 chip on 
> >    the bus #1 only.
> > (...)
> > --- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2004-01-29 04:57:05.000000000 +0000
> > +++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
> > @@ -1,3 +1,4 @@
> > -lib-y				= setup.o rtc_xicor1241.o rtc_m41t81.o
> > +obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
> >  
> > -lib-$(CONFIG_KGDB)		+= dbg_io.o
> > +obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-swarm.o
> > +obj-$(CONFIG_KGDB)		+= dbg_io.o
> > (...)
> > --- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/i2c-swarm.c	1970-01-01 00:00:00.000000000 +0000
> > +++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/i2c-swarm.c	2008-05-06 23:51:34.000000000 +0000
> 
> i2c-foo.c is consistently used for i2c bus driver themselves so far.
> It's somewhat confusing to see you name platform code that way. It's
> also redundant, given that the file lives in the swarm platform
> directory. May I suggest naming this file just
> arch/mips/sibyte/swarm/i2c.c? Other architectures (cris, arm) are doing
> this already.

Is there any chance CONFIG_I2C_BOARDINFO could become tristate?
If yes, it's problematic if you have multiple modules called i2c.ko.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

From khali@linux-fr.org Wed May  7 08:43:56 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 08:43:59 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:25374 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20022427AbYEGHn4 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 08:43:56 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JtfFq-0002DV-NC
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Wed, 07 May 2008 10:44:02 +0200
Date:	Wed, 7 May 2008 09:43:43 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	Geert Uytterhoeven <geert@linux-m68k.org>
Cc:	"Maciej W. Rozycki" <macro@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080507094343.25f279b9@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.64.0805070936060.6341@anakin>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
	<20080507090514.3a86cf4b@hyperion.delvare>
	<Pine.LNX.4.64.0805070936060.6341@anakin>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19124
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1658
Lines: 39

Hi Geert,

On Wed, 7 May 2008 09:37:01 +0200 (CEST), Geert Uytterhoeven wrote:
> On Wed, 7 May 2008, Jean Delvare wrote:
> > Oh, BTW...
> > 
> > On Wed, 7 May 2008 01:40:27 +0100 (BST), Maciej W. Rozycki wrote:
> > > (...)
> > > 1. i2c-swarm.c -- SWARM I2C board setup, currently for the M41T80 chip on 
> > >    the bus #1 only.
> > > (...)
> > > --- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2004-01-29 04:57:05.000000000 +0000
> > > +++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
> > > @@ -1,3 +1,4 @@
> > > -lib-y				= setup.o rtc_xicor1241.o rtc_m41t81.o
> > > +obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
> > >  
> > > -lib-$(CONFIG_KGDB)		+= dbg_io.o
> > > +obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-swarm.o
> > > +obj-$(CONFIG_KGDB)		+= dbg_io.o
> > > (...)
> > > --- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/i2c-swarm.c	1970-01-01 00:00:00.000000000 +0000
> > > +++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/i2c-swarm.c	2008-05-06 23:51:34.000000000 +0000
> > 
> > i2c-foo.c is consistently used for i2c bus driver themselves so far.
> > It's somewhat confusing to see you name platform code that way. It's
> > also redundant, given that the file lives in the swarm platform
> > directory. May I suggest naming this file just
> > arch/mips/sibyte/swarm/i2c.c? Other architectures (cris, arm) are doing
> > this already.
> 
> Is there any chance CONFIG_I2C_BOARDINFO could become tristate?
> If yes, it's problematic if you have multiple modules called i2c.ko.

No, CONFIG_I2C_BOARDINFO is boolean by nature, it will never become
tristate.

-- 
Jean Delvare

From SRS0+9d6426c59dd8b4fa22d3+1718+infradead.org+dwmw2@pentafluge.srs.infradead.org Wed May  7 09:24:23 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 09:24:25 +0100 (BST)
Received: from pentafluge.infradead.org ([213.146.154.40]:14309 "EHLO
	pentafluge.infradead.org") by ftp.linux-mips.org with ESMTP
	id S20024817AbYEGIYX (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 09:24:23 +0100
Received: from pmac.infradead.org ([2001:8b0:10b:1:20d:93ff:fe7a:3f2c])
	by pentafluge.infradead.org with esmtpsa (Exim 4.68 #1 (Red Hat Linux))
	id 1Jtewi-0000k9-Iy; Wed, 07 May 2008 08:24:16 +0000
Subject: Re: [rtc-linux] [RFC][PATCH 1/4] RTC: Class device support for
	persistent clock
From:	David Woodhouse <dwmw2@infradead.org>
To:	rtc-linux@googlegroups.com
Cc:	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
In-Reply-To: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
Content-Type: text/plain
Date:	Wed, 07 May 2008 09:24:15 +0100
Message-Id: <1210148655.25560.825.camel@pmac.infradead.org>
Mime-Version: 1.0
X-Mailer: Evolution 2.22.1 (2.22.1-1.fc9) 
Content-Transfer-Encoding: 7bit
X-SRS-Rewrite: SMTP reverse-path rewritten from <dwmw2@infradead.org> by pentafluge.infradead.org
	See http://www.infradead.org/rpr.html
Return-Path: <SRS0+9d6426c59dd8b4fa22d3+1718+infradead.org+dwmw2@pentafluge.srs.infradead.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19125
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: dwmw2@infradead.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2233
Lines: 62

On Wed, 2008-05-07 at 01:40 +0100, Maciej W. Rozycki wrote:
> 
> +int rtc_update_persistent_clock(struct timespec now)
> +{
> +       struct rtc_device *rtc =
> rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
> +       int err;
> +
> +       if (rtc == NULL) {
> +               printk(KERN_ERR "hctosys: unable to open rtc device (%
> s)\n",
> +                      CONFIG_RTC_HCTOSYS_DEVICE);
> +               err = -ENXIO;
> +               goto out;
>         }
> -       else
> +       err = rtc_set_mmss(rtc, now.tv_sec);
> +       if (err < 0) {
>                 dev_err(rtc->dev.parent,
> -                       "hctosys: unable to read the hardware clock
> \n");
> +                       "hctosys: unable to set the hardware clock
> \n");
> +               goto out_close;
> +       }
>  
> +       err = 0;
> +
> +out_close:
>         rtc_class_close(rtc);
> +out:
> +       return err;
> +}

Ooh, shiny -- you saved me the trouble of doing this (and hopefully also
the trouble of looking through it to check whether all the callers of
read_persistent_clock() can sleep, etc.?)

One thing I was going to do in rtc_update_persistent_clock() was make it
use mutex_trylock() for grabbing rtc->lock. We go to great lengths to
make sure we're updating the clock at the correct time -- we don't want
to be doing things which delay the update. So we should probably just
use mutex_trylock() and abort the update (this time) if it fails.

I was also thinking of holding the RTC_HCTOSYS device open all the time,
too. If it's a problem that you then couldn't unload the module, perhaps
a sysfs interface to set/change/clear which device is used for this?

When we discussed it last week, Alessandro was concerned that the
'update at precisely 500ms past the second' rule was not universal to
all RTC devices, although I'm not entirely sure. It might be worth
moving that logic into a 'default' NTP-sync routine provided by the RTC
class, so that if any strange devices exist which require different
treatment, they can override that.

I wouldn't worry too much about leaving the old
update_persistent_clock() and read_persistent_clock() -- I hope we can
plan to remove those entirely in favour of the RTC class methods.

-- 
dwmw2


From alessandro.zummo@towertech.it Wed May  7 12:49:34 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 12:49:36 +0100 (BST)
Received: from mx0.towertech.it ([213.215.222.73]:56025 "HELO mx0.towertech.it")
	by ftp.linux-mips.org with SMTP id S20034930AbYEGLte (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 12:49:34 +0100
Received: (qmail 16733 invoked from network); 7 May 2008 13:49:31 +0200
Received: from unknown (HELO i1501.lan.towertech.it) (81.208.60.204)
  by mx0.towertech.it with SMTP; 7 May 2008 13:49:31 +0200
Date:	Wed, 7 May 2008 13:49:30 +0200
From:	Alessandro Zummo <alessandro.zummo@towertech.it>
To:	rtc-linux@googlegroups.com
Cc:	dwmw2@infradead.org, Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [rtc-linux] Re: [RFC][PATCH 1/4] RTC: Class device support for
 persistent clock
Message-ID: <20080507134930.47d5ed6d@i1501.lan.towertech.it>
In-Reply-To: <1210148655.25560.825.camel@pmac.infradead.org>
References: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
	<1210148655.25560.825.camel@pmac.infradead.org>
Organization: Tower Technologies
X-Mailer: Sylpheed
X-This-Is-A-Real-Message: Yes
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <alessandro.zummo@towertech.it>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19126
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: alessandro.zummo@towertech.it
Precedence: bulk
X-list: linux-mips
Content-Length: 1104
Lines: 35

On Wed, 07 May 2008 09:24:15 +0100
David Woodhouse <dwmw2@infradead.org> wrote:


> Ooh, shiny -- you saved me the trouble of doing this (and hopefully also
> the trouble of looking through it to check whether all the callers of
> read_persistent_clock() can sleep, etc.?)

 I knew you would have liked that patch :)
 
> One thing I was going to do in rtc_update_persistent_clock() was make it
> use mutex_trylock() for grabbing rtc->lock. We go to great lengths to
> make sure we're updating the clock at the correct time -- we don't want
> to be doing things which delay the update. So we should probably just
> use mutex_trylock() and abort the update (this time) if it fails.

 agreable. 
 
> I was also thinking of holding the RTC_HCTOSYS device open all the time,
> too. If it's a problem that you then couldn't unload the module, perhaps
> a sysfs interface to set/change/clear which device is used for this?

 mm.. let's keep it easy. the chances the rtc is in use
 are usually real low.
 

-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


From yoichi_yuasa@tripeaks.co.jp Wed May  7 15:38:24 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 15:38:27 +0100 (BST)
Received: from mo31.po.2iij.NET ([210.128.50.54]:44104 "EHLO mo31.po.2iij.net")
	by ftp.linux-mips.org with ESMTP id S20021411AbYEGOiY (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 15:38:24 +0100
Received: by mo.po.2iij.net (mo31) id m47EcKZR007823; Wed, 7 May 2008 23:38:20 +0900 (JST)
Received: from delta (61.25.30.125.dy.iij4u.or.jp [125.30.25.61])
	by mbox.po.2iij.net (po-mbox305) id m47EcGLo020945
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
	Wed, 7 May 2008 23:38:16 +0900
Date:	Wed, 7 May 2008 23:38:15 +0900
From:	Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	yoichi_yuasa@tripeaks.co.jp, linux-mips <linux-mips@linux-mips.org>
Subject: [PATCH][MIPS] fix divide by zero error in build_clear_page and
 build_copy_page
Message-Id: <20080507233815.e6de28da.yoichi_yuasa@tripeaks.co.jp>
Organization: TriPeaks Corporation
X-Mailer: Sylpheed 2.4.5 (GTK+ 2.12.0; i486-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <yoichi_yuasa@tripeaks.co.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19127
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: yoichi_yuasa@tripeaks.co.jp
Precedence: bulk
X-list: linux-mips
Content-Length: 1496
Lines: 35

Fix divide by zero error in build_clear_page() and build_copy_page()

Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>

diff -pruN -X /home/yuasa/Memo/dontdiff linux-orig/arch/mips/mm/page.c linux/arch/mips/mm/page.c
--- linux-orig/arch/mips/mm/page.c	2008-05-07 10:28:03.732151097 +0900
+++ linux/arch/mips/mm/page.c	2008-05-07 23:27:00.212977534 +0900
@@ -310,8 +310,8 @@ void __cpuinit build_clear_page(void)
 	if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
 		uasm_i_lui(&buf, AT, 0xa000);
 
-	off = min(8, pref_bias_clear_store / cache_line_size) *
-	      cache_line_size;
+	off = cache_line_size ? min(8, pref_bias_clear_store / cache_line_size)
+	                        * cache_line_size : 0;
 	while (off) {
 		build_clear_pref(&buf, -off);
 		off -= cache_line_size;
@@ -454,12 +454,14 @@ void __cpuinit build_copy_page(void)
 	if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
 		uasm_i_lui(&buf, AT, 0xa000);
 
-	off = min(8, pref_bias_copy_load / cache_line_size) * cache_line_size;
+	off = cache_line_size ? min(8, pref_bias_copy_load / cache_line_size) *
+	                        cache_line_size : 0;
 	while (off) {
 		build_copy_load_pref(&buf, -off);
 		off -= cache_line_size;
 	}
-	off = min(8, pref_bias_copy_store / cache_line_size) * cache_line_size;
+	off = cache_line_size ? min(8, pref_bias_copy_load / cache_line_size) *
+	                        cache_line_size : 0;
 	while (off) {
 		build_copy_store_pref(&buf, -off);
 		off -= cache_line_size;

From mano@roarinelk.homelinux.net Wed May  7 17:02:00 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:02:04 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:23220 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022109AbYEGQCA (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:02:00 +0100
Received: (qmail 17885 invoked by uid 1000); 7 May 2008 18:01:54 +0200
Date:	Wed, 7 May 2008 18:01:54 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/7] au1xmmc updates
Message-ID: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19128
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 192
Lines: 10

Hello,

The following patches update the au1xmmc driver with new
features and a few cleanups.

Testers (especially with db1200 and pb1200 boards) and comments
 welcome!

Thanks!
	Manuel Lauss

From mano@roarinelk.homelinux.net Wed May  7 17:02:46 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:02:49 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:2492 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022020AbYEGQCq (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:02:46 +0100
Received: (qmail 17895 invoked by uid 1000); 7 May 2008 18:02:40 +0200
Date:	Wed, 7 May 2008 18:02:40 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/7] Alchemy: export get_au1x00_speed for modules
Message-ID: <20080507160240.GB17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19129
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From e441a70bfa420f1cef86597a5ef23dfa440ba25e Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 13:42:55 +0200
Subject: [PATCH] Alchemy: export get_au1x00_speed for modules
Content-Length: 546
Lines: 23

au1xmmc.c driver depends on it, so export it for modules.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/au1000/common/clocks.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mips/au1000/common/clocks.c b/arch/mips/au1000/common/clocks.c
index 3ce6cac..6dbc87a 100644
--- a/arch/mips/au1000/common/clocks.c
+++ b/arch/mips/au1000/common/clocks.c
@@ -46,7 +46,7 @@ unsigned int get_au1x00_speed(void)
 {
 	return au1x00_clock;
 }
-
+EXPORT_SYMBOL(get_au1x00_speed);
 
 
 /*
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Wed May  7 17:04:02 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:04:07 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:33724 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022145AbYEGQEC (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:04:02 +0100
Received: (qmail 17913 invoked by uid 1000); 7 May 2008 18:03:58 +0200
Date:	Wed, 7 May 2008 18:03:58 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] Alchemy: dbdma: add api to delete custom ddma devices
Message-ID: <20080507160358.GC17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19130
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 54c63c0bbf48673e5550b62d3ca4272dd0a1bedf Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 13:45:23 +0200
Subject: [PATCH] Alchemy: dbdma: add API to delete custom DDMA device ids.
Content-Length: 1516
Lines: 46

Add API to delete custom DDMA device ids created with
au1xxx_ddma_device_add(), to avoid filling the ddma id table by repeatedly
loading/unloading a module using this function.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/au1000/common/dbdma.c             |   10 ++++++++++
 include/asm-mips/mach-au1x00/au1xxx_dbdma.h |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/mips/au1000/common/dbdma.c b/arch/mips/au1000/common/dbdma.c
index 53377df..69171c6 100644
--- a/arch/mips/au1000/common/dbdma.c
+++ b/arch/mips/au1000/common/dbdma.c
@@ -220,6 +220,16 @@ au1xxx_ddma_add_device(dbdev_tab_t *dev)
 }
 EXPORT_SYMBOL(au1xxx_ddma_add_device);
 
+void au1xxx_ddma_del_device(u32 devid)
+{
+	dbdev_tab_t *p = find_dbdev_id(devid);
+	if (p != NULL) {
+		memset(p, 0, sizeof(dbdev_tab_t));
+		p->dev_id = ~0;
+	}
+}
+EXPORT_SYMBOL(au1xxx_ddma_del_device);
+
 /* Allocate a channel and return a non-zero descriptor if successful.
 */
 u32
diff --git a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
index 93d507c..5e33ff0 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
@@ -367,6 +367,7 @@ void au1xxx_dbdma_dump(u32 chanid);
 u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr );
 
 u32 au1xxx_ddma_add_device( dbdev_tab_t *dev );
+void au1xxx_ddma_del_device(u32 devid);
 void * au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp);
 
 /*
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Wed May  7 17:05:47 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:05:51 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:28813 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022187AbYEGQFr (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:05:47 +0100
Received: (qmail 17935 invoked by uid 1000); 7 May 2008 18:05:40 +0200
Date:	Wed, 7 May 2008 18:05:40 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] au1xmmc: remove db1x00 specific functions and platform
	device conversion
Message-ID: <20080507160540.GD17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19131
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 8dc23d568939c8c12c358ee063fd38e8093d3c6f Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 14:57:01 +0200
Subject: [PATCH] au1xmmc: remove db1x00 board-specific functions from driver
Content-Length: 22871
Lines: 841

Remove the DB1200 board-specific functions (card present, read-only
methods) and instead add platform data which is passed to the driver.

With the board-specific stuff gone, the driver no longer needs to know
how many physical controllers the silicon actually has; every device
can be registered as needed,  update the code as necessary.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c                |  494 ++++++++++++++++++-----------
 drivers/mmc/host/au1xmmc.h                |   96 ------
 include/asm-mips/mach-au1x00/au1100_mmc.h |   43 +++-
 3 files changed, 338 insertions(+), 295 deletions(-)
 delete mode 100644 drivers/mmc/host/au1xmmc.h

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index cc5f7bc..17870cd 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -49,7 +49,6 @@
 #include <asm/mach-au1x00/au1100_mmc.h>
 
 #include <au1xxx.h>
-#include "au1xmmc.h"
 
 #define DRIVER_NAME "au1xxx-mmc"
 
@@ -61,31 +60,71 @@
 #define DBG(fmt, idx, args...)
 #endif
 
-const struct {
-	u32 iobase;
-	u32 tx_devid, rx_devid;
-	u16 bcsrpwr;
-	u16 bcsrstatus;
-	u16 wpstatus;
-} au1xmmc_card_table[] = {
-	{ SD0_BASE, DSCR_CMD0_SDMS_TX0, DSCR_CMD0_SDMS_RX0,
-	  BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
-#ifndef CONFIG_MIPS_DB1200
-	{ SD1_BASE, DSCR_CMD0_SDMS_TX1, DSCR_CMD0_SDMS_RX1,
-	  BCSR_BOARD_DS1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
+#define AU1XMMC_DESCRIPTOR_COUNT 1
+#define AU1XMMC_DESCRIPTOR_SIZE  4096
+
+#define AU1XMMC_OCR ( MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
+		      MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
+		      MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
+
+/* Easy access macros */
+
+#define HOST_STATUS(h)	((h)->iobase + SD_STATUS)
+#define HOST_CONFIG(h)	((h)->iobase + SD_CONFIG)
+#define HOST_ENABLE(h)	((h)->iobase + SD_ENABLE)
+#define HOST_TXPORT(h)	((h)->iobase + SD_TXPORT)
+#define HOST_RXPORT(h)	((h)->iobase + SD_RXPORT)
+#define HOST_CMDARG(h)	((h)->iobase + SD_CMDARG)
+#define HOST_BLKSIZE(h)	((h)->iobase + SD_BLKSIZE)
+#define HOST_CMD(h)	((h)->iobase + SD_CMD)
+#define HOST_CONFIG2(h)	((h)->iobase + SD_CONFIG2)
+#define HOST_TIMEOUT(h)	((h)->iobase + SD_TIMEOUT)
+#define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
+
+#define DMA_CHANNEL(h) \
+	( ((h)->flags & HOST_F_XMIT) ? (h)->dma.tx_chan : (h)->dma.rx_chan)
+
+/* This gives us a hard value for the stop command that we can write directly
+ * to the command register
+ */
+
+#define STOP_CMD (SD_CMD_RT_1B|SD_CMD_CT_7|(0xC << SD_CMD_CI_SHIFT)|SD_CMD_GO)
+
+/* This is the set of interrupts that we configure by default */
+
+#if 0
+#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | SD_CONFIG_DD | \
+		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
 #endif
-};
 
-#define AU1XMMC_CONTROLLER_COUNT (ARRAY_SIZE(au1xmmc_card_table))
+#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | \
+		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
+/* The poll event (looking for insert/remove events runs twice a second */
+#define AU1XMMC_DETECT_TIMEOUT (HZ/2)
+
+/* Status flags used by the host structure */
+#define HOST_F_XMIT   0x0001
+#define HOST_F_RECV   0x0002
+#define HOST_F_DMA    0x0010
+#define HOST_F_ACTIVE 0x0100
+#define HOST_F_STOP   0x1000
+
+#define HOST_S_IDLE   0x0001
+#define HOST_S_CMD    0x0002
+#define HOST_S_DATA   0x0003
+#define HOST_S_STOP   0x0004
 
-/* This array stores pointers for the hosts (used by the IRQ handler) */
-struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
 static int dma = 1;
 
-#ifdef MODULE
 module_param(dma, bool, 0);
 MODULE_PARM_DESC(dma, "Use DMA engine for data transfers (0 = disabled)");
-#endif
+
+/* 8bit memory device */
+static dbdev_tab_t au1xmmc_mem_dbdev = {
+	DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 8, 0x00000000, 0, 0
+};
+static int memid;
+
 
 static inline void IRQ_ON(struct au1xmmc_host *host, u32 mask)
 {
@@ -135,31 +174,37 @@ static inline void SEND_STOP(struct au1xmmc_host *host)
 
 static void au1xmmc_set_power(struct au1xmmc_host *host, int state)
 {
-
-	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
-
-	bcsr->board &= ~val;
-	if (state) bcsr->board |= val;
-
-	au_sync_delay(1);
+	if (host->platdata && host->platdata->set_power)
+		host->platdata->set_power(host->mmc, state);
 }
 
-static inline int au1xmmc_card_inserted(struct au1xmmc_host *host)
+static int au1xmmc_card_inserted(struct au1xmmc_host *host)
 {
-	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
-		? 1 : 0;
+	int ret;
+
+	if (host->platdata && host->platdata->card_inserted)
+		ret = host->platdata->card_inserted(host->mmc);
+	else
+		ret = 1;	/* assume there is a card */
+
+	return ret;
 }
 
 static int au1xmmc_card_readonly(struct mmc_host *mmc)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
-	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus)
-		? 1 : 0;
+	int ret;
+
+	if (host->platdata && host->platdata->card_readonly)
+		ret = host->platdata->card_readonly(mmc);
+	else
+		ret = 1;	/* assume card is read-only */
+
+	return ret;
 }
 
 static void au1xmmc_finish_request(struct au1xmmc_host *host)
 {
-
 	struct mmc_request *mrq = host->mrq;
 
 	host->mrq = NULL;
@@ -174,8 +219,6 @@ static void au1xmmc_finish_request(struct au1xmmc_host *host)
 
 	host->status = HOST_S_IDLE;
 
-	bcsr->disk_leds |= (1 << 8);
-
 	mmc_request_done(host->mmc, mrq);
 }
 
@@ -663,7 +706,9 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 	host->mrq = mrq;
 	host->status = HOST_S_CMD;
 
-	bcsr->disk_leds &= ~(1 << 8);
+	au_writel(0, HOST_STATUS(host));
+	au_sync();
+	FLUSH_FIFO(host);
 
 	if (mrq->data) {
 		FLUSH_FIFO(host);
@@ -749,118 +794,87 @@ static void au1xmmc_dma_callback(int irq, void *dev_id)
 
 static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 {
-
+	struct au1xmmc_host *host = dev_id;
 	u32 status;
-	int i, ret = 0;
-
-	disable_irq(AU1100_SD_IRQ);
-
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct au1xmmc_host * host = au1xmmc_hosts[i];
-		u32 handled = 1;
 
-		status = au_readl(HOST_STATUS(host));
+	status = au_readl(HOST_STATUS(host));
 
-		if (host->mrq && (status & STATUS_TIMEOUT)) {
-			if (status & SD_STATUS_RAT)
-				host->mrq->cmd->error = -ETIMEDOUT;
+	if (!(status & (1<<15)))
+		return IRQ_NONE;	/* not ours */
 
-			else if (status & SD_STATUS_DT)
-				host->mrq->data->error = -ETIMEDOUT;
+	if (host->mrq && (status & STATUS_TIMEOUT)) {
+		if (status & SD_STATUS_RAT)
+			host->mrq->cmd->error = -ETIMEDOUT;
+		else if (status & SD_STATUS_DT)
+			host->mrq->data->error = -ETIMEDOUT;
 
-			/* In PIO mode, interrupts might still be enabled */
-			IRQ_OFF(host, SD_CONFIG_NE | SD_CONFIG_TH);
+		/* In PIO mode, interrupts might still be enabled */
+		IRQ_OFF(host, SD_CONFIG_NE | SD_CONFIG_TH);
 
-			//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
-			tasklet_schedule(&host->finish_task);
-		}
+		//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
+		tasklet_schedule(&host->finish_task);
+	}
 #if 0
-		else if (status & SD_STATUS_DD) {
-
-			/* Sometimes we get a DD before a NE in PIO mode */
-
-			if (!(host->flags & HOST_F_DMA) &&
-					(status & SD_STATUS_NE))
-				au1xmmc_receive_pio(host);
-			else {
-				au1xmmc_data_complete(host, status);
-				//tasklet_schedule(&host->data_task);
-			}
-		}
-#endif
-		else if (status & (SD_STATUS_CR)) {
-			if (host->status == HOST_S_CMD)
-				au1xmmc_cmd_complete(host,status);
-		}
-		else if (!(host->flags & HOST_F_DMA)) {
-			if ((host->flags & HOST_F_XMIT) &&
-			    (status & STATUS_DATA_OUT))
-				au1xmmc_send_pio(host);
-			else if ((host->flags & HOST_F_RECV) &&
-			    (status & STATUS_DATA_IN))
-				au1xmmc_receive_pio(host);
-		}
-		else if (status & 0x203FBC70) {
-			DBG("Unhandled status %8.8x\n", host->id, status);
-			handled = 0;
+	else if (status & SD_STATUS_DD) {
+		/* Sometimes we get a DD before a NE in PIO mode */
+		if (!(host->flags & HOST_F_DMA) && (status & SD_STATUS_NE))
+			au1xmmc_receive_pio(host);
+		else {
+			au1xmmc_data_complete(host, status);
+			//tasklet_schedule(&host->data_task);
 		}
-
-		au_writel(status, HOST_STATUS(host));
-		au_sync();
-
-		ret |= handled;
 	}
+#endif
+	else if (status & (SD_STATUS_CR)) {
+		if (host->status == HOST_S_CMD)
+			au1xmmc_cmd_complete(host,status);
 
-	enable_irq(AU1100_SD_IRQ);
-	return ret;
-}
-
-static void au1xmmc_poll_event(unsigned long arg)
-{
-	struct au1xmmc_host *host = (struct au1xmmc_host *) arg;
-
-	int card = au1xmmc_card_inserted(host);
-        int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
+	} else if (!(host->flags & HOST_F_DMA)) {
+		if ((host->flags & HOST_F_XMIT) && (status & STATUS_DATA_OUT))
+			au1xmmc_send_pio(host);
+		else if ((host->flags & HOST_F_RECV) && (status & STATUS_DATA_IN))
+			au1xmmc_receive_pio(host);
 
-	if (card != controller) {
-		host->flags &= ~HOST_F_ACTIVE;
-		if (card) host->flags |= HOST_F_ACTIVE;
-		mmc_detect_change(host->mmc, 0);
+	} else if (status & 0x203FBC70) {
+			DBG("Unhandled status %8.8x\n", host->id, status);
 	}
 
-	if (host->mrq != NULL) {
-		u32 status = au_readl(HOST_STATUS(host));
-		DBG("PENDING - %8.8x\n", host->id, status);
-	}
+	au_writel(status, HOST_STATUS(host));
+	au_sync();
 
-	mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT);
+	return IRQ_HANDLED;
 }
 
-static dbdev_tab_t au1xmmc_mem_dbdev =
-{
-	DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 8, 0x00000000, 0, 0
-};
-
-static void au1xmmc_init_dma(struct au1xmmc_host *host)
+static int au1xmmc_init_dma(struct au1xmmc_host *host)
 {
-
+	struct resource *res;
 	u32 rxchan, txchan;
+	int txid, rxid;
 
-	int txid = au1xmmc_card_table[host->id].tx_devid;
-	int rxid = au1xmmc_card_table[host->id].rx_devid;
-
-	/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
-	   of 8 bits.  And since devices are shared, we need to create
-	   our own to avoid freaking out other devices
-	*/
+	res = platform_get_resource(host->pdev, IORESOURCE_DMA, 0);
+	if (!res)
+		return -ENODEV;
+	txid = res->start;
 
-	int memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
+	res = platform_get_resource(host->pdev, IORESOURCE_DMA, 1);
+	if (!res)
+		return -ENODEV;
+	rxid = res->start;
 
 	txchan = au1xxx_dbdma_chan_alloc(memid, txid,
-					 au1xmmc_dma_callback, (void *) host);
+				au1xmmc_dma_callback, (void *)host);
+	if (!txchan) {
+		dev_err(&host->pdev->dev, "cannot allocate TX DMA\n");
+		return -ENODEV;
+	}
 
 	rxchan = au1xxx_dbdma_chan_alloc(rxid, memid,
-					 au1xmmc_dma_callback, (void *) host);
+				au1xmmc_dma_callback, (void *)host);
+	if (!rxchan) {
+		dev_err(&host->pdev->dev, "cannot allocate RX DMA\n");
+		au1xxx_dbdma_chan_free(txchan);
+		return -ENODEV;
+	}
 
 	au1xxx_dbdma_set_devwidth(txchan, 8);
 	au1xxx_dbdma_set_devwidth(rxchan, 8);
@@ -868,8 +882,10 @@ static void au1xmmc_init_dma(struct au1xmmc_host *host)
 	au1xxx_dbdma_ring_alloc(txchan, AU1XMMC_DESCRIPTOR_COUNT);
 	au1xxx_dbdma_ring_alloc(rxchan, AU1XMMC_DESCRIPTOR_COUNT);
 
-	host->tx_chan = txchan;
-	host->rx_chan = rxchan;
+	host->dma.tx_chan = txchan;
+	host->dma.rx_chan = rxchan;
+
+	return 0;
 }
 
 static const struct mmc_host_ops au1xmmc_ops = {
@@ -878,116 +894,197 @@ static const struct mmc_host_ops au1xmmc_ops = {
 	.get_ro		= au1xmmc_card_readonly,
 };
 
-static int __devinit au1xmmc_probe(struct platform_device *pdev)
+static void au1xmmc_poll_event(unsigned long arg)
 {
+	struct au1xmmc_host *host = (struct au1xmmc_host *)arg;
 
-	int i, ret = 0;
+	int card = au1xmmc_card_inserted(host);
+	int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
 
-	/* THe interrupt is shared among all controllers */
-	ret = request_irq(AU1100_SD_IRQ, au1xmmc_irq, IRQF_DISABLED, "MMC", 0);
+	if (card != controller) {
+		host->flags &= ~HOST_F_ACTIVE;
+		if (card)
+			host->flags |= HOST_F_ACTIVE;
+		mmc_detect_change(host->mmc, 0);
+	}
 
-	if (ret) {
-		printk(DRIVER_NAME "ERROR: Couldn't get int %d: %d\n",
-				AU1100_SD_IRQ, ret);
-		return -ENXIO;
+#if 0
+	if (host->mrq != NULL) {
+		u32 status = au_readl(HOST_STATUS(host));
+		DBG("PENDING - %8.8x\n", host->id, status);
 	}
+#endif
+	mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT);
+}
 
-	disable_irq(AU1100_SD_IRQ);
+static void au1xmmc_init_cd_poll_timer(struct au1xmmc_host *host)
+{
+	init_timer(&host->timer);
+	host->timer.function = au1xmmc_poll_event;
+	host->timer.data = (unsigned long)host;
+	host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT;
+}
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct mmc_host *mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
-		struct au1xmmc_host *host = 0;
+static int __devinit au1xmmc_probe(struct platform_device *pdev)
+{
+	struct mmc_host *mmc;
+	struct au1xmmc_host *host;
+	struct resource *r;
+	int ret;
+
+	mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
+	if (!mmc) {
+		dev_err(&pdev->dev, "no memory for mmc host\n");
+		ret = -ENOMEM;
+		goto out0;
+	}
 
-		if (!mmc) {
-			printk(DRIVER_NAME "ERROR: no mem for host %d\n", i);
-			au1xmmc_hosts[i] = 0;
-			continue;
-		}
+	host = mmc_priv(mmc);
+	host->mmc = mmc;
+	host->platdata = pdev->dev.platform_data;
+	host->pdev = pdev;
 
-		mmc->ops = &au1xmmc_ops;
+	ret = -ENODEV;
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "no mmio defined\n");
+		goto out1;
+	}
+	host->iobase = (unsigned long)ioremap(r->start, 0xff);
+	if (!host->iobase) {
+		dev_err(&pdev->dev, "cannot remap mmio\n");
+		goto out1;
+	}
 
-		mmc->f_min =   450000;
-		mmc->f_max = 24000000;
+	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "no IRQ defined\n");
+		goto out2;
+	}
 
-		mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
-		mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
+	host->irq = r->start;
+	/* IRQ is shared among both SD controllers */
+	ret = request_irq(host->irq, au1xmmc_irq, IRQF_SHARED,
+			  DRIVER_NAME, host);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot grab IRQ\n");
+		goto out2;
+	}
 
-		mmc->max_blk_size = 2048;
-		mmc->max_blk_count = 512;
+	mmc->ops = &au1xmmc_ops;
 
-		mmc->ocr_avail = AU1XMMC_OCR;
+	mmc->f_min =   450000;
+	mmc->f_max = 24000000;
 
-		host = mmc_priv(mmc);
-		host->mmc = mmc;
+	mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
+	mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
 
-		host->id = i;
-		host->iobase = au1xmmc_card_table[host->id].iobase;
-		host->clock = 0;
-		host->power_mode = MMC_POWER_OFF;
+	mmc->max_blk_size = 2048;
+	mmc->max_blk_count = 512;
 
-		host->flags = au1xmmc_card_inserted(host) ? HOST_F_ACTIVE : 0;
-		host->status = HOST_S_IDLE;
+	mmc->ocr_avail = AU1XMMC_OCR;
+	mmc->caps = 0;
 
-		init_timer(&host->timer);
+	host->id = pdev->id;
+	host->status = HOST_S_IDLE;
 
-		host->timer.function = au1xmmc_poll_event;
-		host->timer.data = (unsigned long) host;
-		host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT;
+	/* board-specific carddetect setup, if any */
+	if (host->platdata && host->platdata->cd_setup) {
+		ret = host->platdata->cd_setup(mmc, 1);
+		if (ret) {
+			dev_err(&pdev->dev, "board CD setup failed\n");
+			goto out3;
+		}
+	} else {
+		/* poll the board-specific card-is-in-socket method */
+		au1xmmc_init_cd_poll_timer(host);
+	}
 
-		tasklet_init(&host->data_task, au1xmmc_tasklet_data,
-				(unsigned long) host);
+	tasklet_init(&host->data_task, au1xmmc_tasklet_data,
+			(unsigned long)host);
 
-		tasklet_init(&host->finish_task, au1xmmc_tasklet_finish,
-				(unsigned long) host);
+	tasklet_init(&host->finish_task, au1xmmc_tasklet_finish,
+			(unsigned long)host);
 
-		spin_lock_init(&host->lock);
+	if (dma) {
+		ret = au1xmmc_init_dma(host);
+		if (ret)
+			goto out4;
+	}
 
-		if (dma != 0)
-			au1xmmc_init_dma(host);
+	au1xmmc_reset_controller(host);
 
-		au1xmmc_reset_controller(host);
+	ret = mmc_add_host(mmc);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot add mmc host\n");
+		goto out5;
+	}
 
-		mmc_add_host(mmc);
-		au1xmmc_hosts[i] = host;
+	platform_set_drvdata(pdev, mmc);
 
+	/* start the carddetect poll timer */
+	if (!(host->platdata && host->platdata->cd_setup))
 		add_timer(&host->timer);
 
-		printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X (mode=%s)\n",
-		       host->id, host->iobase, dma ? "dma" : "pio");
-	}
+	printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X (mode=%s)\n",
+		       pdev->id, host->iobase, dma ? "dma" : "pio");
 
-	enable_irq(AU1100_SD_IRQ);
+	return 0;	/* all ok */
 
-	return 0;
+out5:
+	if (dma) {
+		au1xxx_dbdma_chan_free(host->dma.tx_chan);
+		au1xxx_dbdma_chan_free(host->dma.rx_chan);
+	}
+out4:
+	tasklet_kill(&host->data_task);
+	tasklet_kill(&host->finish_task);
+
+	if (host->platdata && host->platdata->cd_setup)
+		host->platdata->cd_setup(mmc, 0);
+out3:
+	free_irq(host->irq, host);
+out2:
+	iounmap((void *)host->iobase);
+out1:
+	mmc_free_host(mmc);
+out0:
+	return ret;
 }
 
 static int __devexit au1xmmc_remove(struct platform_device *pdev)
 {
+	struct mmc_host *mmc = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host;
 
-	int i;
+	if (mmc) {
+		host  = mmc_priv(mmc);
 
-	disable_irq(AU1100_SD_IRQ);
+		if (host->platdata && host->platdata->cd_setup)
+			host->platdata->cd_setup(mmc, 0);
+		else
+			del_timer_sync(&host->timer);
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct au1xmmc_host *host = au1xmmc_hosts[i];
-		if (!host) continue;
+		au_writel(0, HOST_ENABLE(host));
+		au_writel(0, HOST_CONFIG(host));
+		au_sync();
 
 		tasklet_kill(&host->data_task);
 		tasklet_kill(&host->finish_task);
 
-		del_timer_sync(&host->timer);
 		au1xmmc_set_power(host, 0);
 
-		mmc_remove_host(host->mmc);
+		free_irq(host->irq, host);
 
-		au1xxx_dbdma_chan_free(host->tx_chan);
-		au1xxx_dbdma_chan_free(host->rx_chan);
+		mmc_remove_host(mmc);
 
-		au_writel(0x0, HOST_ENABLE(host));
-		au_sync();
-	}
+		if (dma) {
+			au1xxx_dbdma_chan_free(host->dma.tx_chan);
+			au1xxx_dbdma_chan_free(host->dma.rx_chan);
+		}
 
-	free_irq(AU1100_SD_IRQ, 0);
+		mmc_free_host(mmc);
+	}
 	return 0;
 }
 
@@ -1004,21 +1101,32 @@ static struct platform_driver au1xmmc_driver = {
 
 static int __init au1xmmc_init(void)
 {
+	if (dma) {
+		/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
+		   of 8 bits.  And since devices are shared, we need to create
+		   our own to avoid freaking out other devices
+		 */
+		if (!memid)
+			memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
+		if (!memid) {
+			printk(KERN_ERR "au1xmmc: cannot add memory dma dev\n");
+			return -ENODEV;
+		}
+	}
 	return platform_driver_register(&au1xmmc_driver);
 }
 
 static void __exit au1xmmc_exit(void)
 {
+	if (dma && memid)
+		au1xxx_ddma_del_device(memid);
 	platform_driver_unregister(&au1xmmc_driver);
 }
 
 module_init(au1xmmc_init);
 module_exit(au1xmmc_exit);
 
-#ifdef MODULE
 MODULE_AUTHOR("Advanced Micro Devices, Inc");
 MODULE_DESCRIPTION("MMC/SD driver for the Alchemy Au1XXX");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:au1xxx-mmc");
-#endif
-
diff --git a/drivers/mmc/host/au1xmmc.h b/drivers/mmc/host/au1xmmc.h
deleted file mode 100644
index 341cbdf..0000000
--- a/drivers/mmc/host/au1xmmc.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef _AU1XMMC_H_
-#define _AU1XMMC_H_
-
-/* Hardware definitions */
-
-#define AU1XMMC_DESCRIPTOR_COUNT 1
-#define AU1XMMC_DESCRIPTOR_SIZE  2048
-
-#define AU1XMMC_OCR ( MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
-		      MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
-		      MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
-
-/* Easy access macros */
-
-#define HOST_STATUS(h)	((h)->iobase + SD_STATUS)
-#define HOST_CONFIG(h)	((h)->iobase + SD_CONFIG)
-#define HOST_ENABLE(h)	((h)->iobase + SD_ENABLE)
-#define HOST_TXPORT(h)	((h)->iobase + SD_TXPORT)
-#define HOST_RXPORT(h)	((h)->iobase + SD_RXPORT)
-#define HOST_CMDARG(h)	((h)->iobase + SD_CMDARG)
-#define HOST_BLKSIZE(h)	((h)->iobase + SD_BLKSIZE)
-#define HOST_CMD(h)	((h)->iobase + SD_CMD)
-#define HOST_CONFIG2(h)	((h)->iobase + SD_CONFIG2)
-#define HOST_TIMEOUT(h)	((h)->iobase + SD_TIMEOUT)
-#define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
-
-#define DMA_CHANNEL(h) \
-	( ((h)->flags & HOST_F_XMIT) ? (h)->tx_chan : (h)->rx_chan)
-
-/* This gives us a hard value for the stop command that we can write directly
- * to the command register
- */
-
-#define STOP_CMD (SD_CMD_RT_1B|SD_CMD_CT_7|(0xC << SD_CMD_CI_SHIFT)|SD_CMD_GO)
-
-/* This is the set of interrupts that we configure by default */
-
-#if 0
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | SD_CONFIG_DD | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-#endif
-
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-/* The poll event (looking for insert/remove events runs twice a second */
-#define AU1XMMC_DETECT_TIMEOUT (HZ/2)
-
-struct au1xmmc_host {
-  struct mmc_host *mmc;
-  struct mmc_request *mrq;
-
-  u32 id;
-
-  u32 flags;
-  u32 iobase;
-  u32 clock;
-  u32 bus_width;
-  u32 power_mode;
-
-  int status;
-
-   struct {
-	   int len;
-	   int dir;
-  } dma;
-
-   struct {
-	   int index;
-	   int offset;
-	   int len;
-  } pio;
-
-  u32 tx_chan;
-  u32 rx_chan;
-
-  struct timer_list timer;
-  struct tasklet_struct finish_task;
-  struct tasklet_struct data_task;
-
-  spinlock_t lock;
-};
-
-/* Status flags used by the host structure */
-
-#define HOST_F_XMIT   0x0001
-#define HOST_F_RECV   0x0002
-#define HOST_F_DMA    0x0010
-#define HOST_F_ACTIVE 0x0100
-#define HOST_F_STOP   0x1000
-
-#define HOST_S_IDLE   0x0001
-#define HOST_S_CMD    0x0002
-#define HOST_S_DATA   0x0003
-#define HOST_S_STOP   0x0004
-
-#endif
diff --git a/include/asm-mips/mach-au1x00/au1100_mmc.h b/include/asm-mips/mach-au1x00/au1100_mmc.h
index 9e0028f..6474fac 100644
--- a/include/asm-mips/mach-au1x00/au1100_mmc.h
+++ b/include/asm-mips/mach-au1x00/au1100_mmc.h
@@ -38,15 +38,46 @@
 #ifndef __ASM_AU1100_MMC_H
 #define __ASM_AU1100_MMC_H
 
-
-#define NUM_AU1100_MMC_CONTROLLERS	2
-
-#if defined(CONFIG_SOC_AU1100)
-#define AU1100_SD_IRQ	AU1100_SD_INT
-#elif defined(CONFIG_SOC_AU1200)
-#define AU1100_SD_IRQ	AU1200_SD_INT
-#endif
-
+struct au1xmmc_platdata {
+	int(*cd_setup)(void *mmc_host, int on);
+	int(*card_inserted)(void *mmc_host);
+	int(*card_readonly)(void *mmc_host);
+	void(*set_power)(void *mmc_host, int state);
+};
+
+struct au1xmmc_host {
+	struct mmc_host *mmc;
+	struct mmc_request *mrq;
+
+	u32 id;
+
+	u32 flags;
+	u32 iobase;
+	u32 clock;
+
+	int status;
+
+	struct {
+		int len;
+		int dir;
+		u32 tx_chan;
+		u32 rx_chan;
+	} dma;
+
+	struct {
+		int index;
+		int offset;
+		int len;
+	} pio;
+
+	struct timer_list timer;
+	struct tasklet_struct finish_task;
+	struct tasklet_struct data_task;
+
+	struct platform_device *pdev;
+	struct au1xmmc_platdata *platdata;
+	int irq;
+};
 
 #define SD0_BASE	0xB0600000
 #define SD1_BASE	0xB0680000
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Wed May  7 17:06:38 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:06:42 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:21934 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022201AbYEGQGi (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:06:38 +0100
Received: (qmail 17948 invoked by uid 1000); 7 May 2008 18:06:34 +0200
Date:	Wed, 7 May 2008 18:06:34 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platform device
	and board specific functions
Message-ID: <20080507160634.GE17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19132
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 94bfedb777443b33abd62fde48940db0fab36d80 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 14:59:45 +0200
Subject: [PATCH] Alchemy: register mmc platform device for db1200/pb1200 boards
Content-Length: 5785
Lines: 218

register the mmc platform device for db1200/pb1200 boards, with
board-specific card detect/readonly facilities wrapped in platform data.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/au1000/common/platform.c |   32 ---------
 arch/mips/au1000/pb1200/platform.c |  127 +++++++++++++++++++++++++++++++++++-
 2 files changed, 126 insertions(+), 33 deletions(-)

diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
index 31d2a22..08a5900 100644
--- a/arch/mips/au1000/common/platform.c
+++ b/arch/mips/au1000/common/platform.c
@@ -162,24 +162,6 @@ static struct resource au1xxx_usb_gdt_resources[] = {
 	},
 };
 
-static struct resource au1xxx_mmc_resources[] = {
-	[0] = {
-		.start          = SD0_PHYS_ADDR,
-		.end            = SD0_PHYS_ADDR + 0x40,
-		.flags          = IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= SD1_PHYS_ADDR,
-		.end 		= SD1_PHYS_ADDR + 0x40,
-		.flags		= IORESOURCE_MEM,
-	},
-	[2] = {
-		.start          = AU1200_SD_INT,
-		.end            = AU1200_SD_INT,
-		.flags          = IORESOURCE_IRQ,
-	}
-};
-
 static u64 udc_dmamask = ~(u32)0;
 
 static struct platform_device au1xxx_usb_gdt_device = {
@@ -245,19 +227,6 @@ static struct platform_device au1200_lcd_device = {
 	.num_resources  = ARRAY_SIZE(au1200_lcd_resources),
 	.resource       = au1200_lcd_resources,
 };
-
-static u64 au1xxx_mmc_dmamask =  ~(u32)0;
-
-static struct platform_device au1xxx_mmc_device = {
-	.name = "au1xxx-mmc",
-	.id = 0,
-	.dev = {
-		.dma_mask               = &au1xxx_mmc_dmamask,
-		.coherent_dma_mask      = 0xffffffff,
-	},
-	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
-	.resource       = au1xxx_mmc_resources,
-};
 #endif /* #ifdef CONFIG_SOC_AU1200 */
 
 static struct platform_device au1x00_pcmcia_device = {
@@ -295,7 +264,6 @@ static struct platform_device *au1xxx_platform_devices[] __initdata = {
 	&au1xxx_usb_gdt_device,
 	&au1xxx_usb_otg_device,
 	&au1200_lcd_device,
-	&au1xxx_mmc_device,
 #endif
 #ifdef SMBUS_PSC_BASE
 	&pbdb_smbus_device,
diff --git a/arch/mips/au1000/pb1200/platform.c b/arch/mips/au1000/pb1200/platform.c
index 5930110..bee2bf7 100644
--- a/arch/mips/au1000/pb1200/platform.c
+++ b/arch/mips/au1000/pb1200/platform.c
@@ -20,8 +20,17 @@
 
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/mmc/host.h>
 
 #include <asm/mach-au1x00/au1xxx.h>
+#include <asm/mach-au1x00/au1xxx_dbdma.h>
+#include <asm/mach-au1x00/au1100_mmc.h>
+
+#if defined(CONFIG_MIPS_PB1200)
+#include <asm/mach-pb1x00/pb1200.h>
+#elif defined(CONFIG_MIPS_DB1200)
+#include <asm/mach-db1x00/db1200.h>
+#endif
 
 static struct resource ide_resources[] = {
 	[0] = {
@@ -70,9 +79,125 @@ static struct platform_device smc91c111_device = {
 	.resource	= smc91c111_resources
 };
 
+
+static const struct {
+	u16 bcsrpwr;
+	u16 bcsrstatus;
+	u16 wpstatus;
+} au1xmmc_card_table[] = {
+	{ BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
+#ifndef CONFIG_MIPS_DB1200
+	{ BCSR_BOARD_SD1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
+#endif
+};
+
+static void pb1200mmc_set_power(void *mmc_host, int state)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
+
+	bcsr->board &= ~val;
+	if (state)
+		bcsr->board |= val;
+
+	au_sync_delay(1);
+}
+
+static int pb1200mmc_card_readonly(void *mmc_host)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus) ? 1 : 0;
+}
+
+static int pb1200mmc_card_inserted(void *mmc_host)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
+		? 1 : 0;
+}
+
+static struct au1xmmc_platdata db1xmmcpd = {
+	.set_power	= pb1200mmc_set_power,
+	.card_inserted	= pb1200mmc_card_inserted,
+	.card_readonly	= pb1200mmc_card_readonly,
+	.cd_setup	= NULL,		/* use poll-timer in driver */
+};
+
+static u64 au1xxx_mmc_dmamask =  ~(u32)0;
+
+struct resource au1200sd0_res[] = {
+	[0] = {
+		.start	= CPHYSADDR(SD0_BASE),
+		.end	= CPHYSADDR(SD0_BASE) + 0x40,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AU1200_SD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[3] = {
+		.start	= DSCR_CMD0_SDMS_TX0,
+		.flags	= IORESOURCE_DMA,
+	},
+	[4] = {
+		.start	= DSCR_CMD0_SDMS_RX0,
+		.flags	= IORESOURCE_DMA,
+	},
+};
+
+static struct platform_device au1200_sd0_device = {
+	.name = "au1xxx-mmc",
+	.id = 0,	/* index into au1xmmc_card_table[] */
+	.dev = {
+		.dma_mask               = &au1xxx_mmc_dmamask,
+		.coherent_dma_mask      = 0xffffffff,
+		.platform_data		= &db1xmmcpd,
+	},
+	.num_resources  = ARRAY_SIZE(au1200sd0_res),
+	.resource       = au1200sd0_res,
+};
+
+#ifndef CONFIG_MIPS_DB1200
+struct resource au1200sd1_res[] = {
+	[0] = {
+		.start	= CPHYSADDR(SD1_BASE),
+		.end	= CPHYSADDR(SD1_BASE) + 0xff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AU1200_SD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[3] = {
+		.start	= DSCR_CMD0_SDMS_TX1,
+		.flags	= IORESOURCE_DMA,
+	},
+	[4] = {
+		.start	= DSCR_CMD0_SDMS_RX1,
+		.flags	= IORESOURCE_DMA,
+	},
+};
+
+static struct platform_device au1200_sd1_device = {
+	.name = "au1xxx-mmc",
+	.id = 1,	/* index into au1xmmc_card_table[] */
+	.dev = {
+		.dma_mask               = &au1xxx_mmc_dmamask,
+		.coherent_dma_mask      = 0xffffffff,
+		.platform_data		= &db1xmmcpd,
+	},
+	.num_resources  = ARRAY_SIZE(au1200sd1_res),
+	.resource       = au1200sd1_res,
+};
+#endif
+
 static struct platform_device *board_platform_devices[] __initdata = {
 	&ide_device,
-	&smc91c111_device
+	&smc91c111_device,
+	&au1200_sd0_device,
+#ifndef CONFIG_MIPS_DB1200
+	&au1200_sd1_device,
+#endif
 };
 
 static int __init board_register_devices(void)
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Wed May  7 17:07:13 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:07:16 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:22965 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022201AbYEGQHN (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:07:13 +0100
Received: (qmail 17956 invoked by uid 1000); 7 May 2008 18:07:05 +0200
Date:	Wed, 7 May 2008 18:07:05 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] au1xmmc: 4 bit transfer mode
Message-ID: <20080507160705.GF17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19133
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From c3bf4d3ee34ecaa3d3ee13d843677ed25da8ca6e Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 15:04:51 +0200
Subject: [PATCH] au1xmmc: 4 bit transfer mode
Content-Length: 1933
Lines: 67

Add 4 Bit transfer mode support.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 17870cd..8ee7640 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -159,13 +159,13 @@ static inline void IRQ_OFF(struct au1xmmc_host *host, u32 mask)
 static inline void SEND_STOP(struct au1xmmc_host *host)
 {
 
-	/* We know the value of CONFIG2, so avoid a read we don't need */
-	u32 mask = SD_CONFIG2_EN;
+	u32 config2;
 
 	WARN_ON(host->status != HOST_S_DATA);
 	host->status = HOST_S_STOP;
 
-	au_writel(mask | SD_CONFIG2_DF, HOST_CONFIG2(host));
+	config2 = au_readl(HOST_CONFIG2(host));
+	au_writel(config2 | SD_CONFIG2_DF, HOST_CONFIG2(host));
 	au_sync();
 
 	/* Send the stop commmand */
@@ -760,6 +760,7 @@ static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
+	u32 config;
 
 	if (ios->power_mode == MMC_POWER_OFF)
 		au1xmmc_set_power(host, 0);
@@ -771,6 +772,18 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 		au1xmmc_set_clock(host, ios->clock);
 		host->clock = ios->clock;
 	}
+
+	config = au_readl(HOST_CONFIG2(host));
+	switch (ios->bus_width) {
+	case MMC_BUS_WIDTH_4:
+		config |= (1 << 8);
+		break;
+	case MMC_BUS_WIDTH_1:
+		config &= ~(1 << 8);
+		break;
+	}
+	au_writel(config, HOST_CONFIG2(host));
+	au_sync();
 }
 
 static void au1xmmc_dma_callback(int irq, void *dev_id)
@@ -983,7 +996,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
 	mmc->max_blk_count = 512;
 
 	mmc->ocr_avail = AU1XMMC_OCR;
-	mmc->caps = 0;
+	mmc->caps = MMC_CAP_4_BIT_DATA;
 
 	host->id = pdev->id;
 	host->status = HOST_S_IDLE;
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Wed May  7 17:08:17 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:08:20 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:38867 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022220AbYEGQIR (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:08:17 +0100
Received: (qmail 17974 invoked by uid 1000); 7 May 2008 18:08:10 +0200
Date:	Wed, 7 May 2008 18:08:10 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] au1xmmc: wire up SDIO interrupt
Message-ID: <20080507160810.GG17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19134
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 629e40951cb1c4c6ddcdc89a69af85c30f3bea3b Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 15:18:14 +0200
Subject: [PATCH] au1xmmc: wire up SDIO interrupt
Content-Length: 1596
Lines: 57

The silicon supports SDIO irqs.

Untested since I don't have any SDIO hardware.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 8ee7640..513937a 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -848,6 +848,9 @@ static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 		else if ((host->flags & HOST_F_RECV) && (status & STATUS_DATA_IN))
 			au1xmmc_receive_pio(host);
 
+	} else if (status & 0x80000000) {
+		mmc_signal_sdio_irq(host->mmc);
+
 	} else if (status & 0x203FBC70) {
 			DBG("Unhandled status %8.8x\n", host->id, status);
 	}
@@ -901,10 +904,21 @@ static int au1xmmc_init_dma(struct au1xmmc_host *host)
 	return 0;
 }
 
+static void au1xmmc_enable_sdio_irq(struct mmc_host *mmc, int en)
+{
+	struct au1xmmc_host *host = mmc_priv(mmc);
+
+	if (en)
+		IRQ_ON(host, (1<<31));
+	else
+		IRQ_OFF(host, (1<<31));
+}
+
 static const struct mmc_host_ops au1xmmc_ops = {
 	.request	= au1xmmc_request,
 	.set_ios	= au1xmmc_set_ios,
 	.get_ro		= au1xmmc_card_readonly,
+	.enable_sdio_irq = au1xmmc_enable_sdio_irq,
 };
 
 static void au1xmmc_poll_event(unsigned long arg)
@@ -996,7 +1010,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
 	mmc->max_blk_count = 512;
 
 	mmc->ocr_avail = AU1XMMC_OCR;
-	mmc->caps = MMC_CAP_4_BIT_DATA;
+	mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
 
 	host->id = pdev->id;
 	host->status = HOST_S_IDLE;
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Wed May  7 17:09:12 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:09:16 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:31953 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022226AbYEGQJM (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 17:09:12 +0100
Received: (qmail 17988 invoked by uid 1000); 7 May 2008 18:09:07 +0200
Date:	Wed, 7 May 2008 18:09:07 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/7] au1xmmc: codingstyle tidying
Message-ID: <20080507160907.GH17806@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080507160154.GA17806@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19135
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From fc2578032bfc08799ab4766513d8f04674397166 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 15:30:14 +0200
Subject: [PATCH] au1xmmc: codingstyle tidying
Content-Length: 13397
Lines: 449

Make the driver source a bit easier on the eyes;
no functional changes.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c |  160 ++++++++++++++++---------------------------
 1 files changed, 60 insertions(+), 100 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 513937a..ea9f7ec 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -63,9 +63,9 @@
 #define AU1XMMC_DESCRIPTOR_COUNT 1
 #define AU1XMMC_DESCRIPTOR_SIZE  4096
 
-#define AU1XMMC_OCR ( MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
-		      MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
-		      MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
+#define AU1XMMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
+		     MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
+		     MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
 
 /* Easy access macros */
 
@@ -82,24 +82,19 @@
 #define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
 
 #define DMA_CHANNEL(h) \
-	( ((h)->flags & HOST_F_XMIT) ? (h)->dma.tx_chan : (h)->dma.rx_chan)
+	(((h)->flags & HOST_F_XMIT) ? (h)->dma.tx_chan : (h)->dma.rx_chan)
 
 /* This gives us a hard value for the stop command that we can write directly
  * to the command register
  */
-
-#define STOP_CMD (SD_CMD_RT_1B|SD_CMD_CT_7|(0xC << SD_CMD_CI_SHIFT)|SD_CMD_GO)
+#define STOP_CMD (SD_CMD_RT_1B | SD_CMD_CT_7 |		\
+		  (0xC << SD_CMD_CI_SHIFT) | SD_CMD_GO)
 
 /* This is the set of interrupts that we configure by default */
-
-#if 0
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | SD_CONFIG_DD | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-#endif
-
 #define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | \
 		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-/* The poll event (looking for insert/remove events runs twice a second */
+
+/* The poll event (looking for insert/remove events) runs twice a second */
 #define AU1XMMC_DETECT_TIMEOUT (HZ/2)
 
 /* Status flags used by the host structure */
@@ -158,7 +153,6 @@ static inline void IRQ_OFF(struct au1xmmc_host *host, u32 mask)
 
 static inline void SEND_STOP(struct au1xmmc_host *host)
 {
-
 	u32 config2;
 
 	WARN_ON(host->status != HOST_S_DATA);
@@ -278,18 +272,14 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
 	au_sync();
 
 	/* Wait for the command to go on the line */
-
-	while(1) {
-		if (!(au_readl(HOST_CMD(host)) & SD_CMD_GO))
-			break;
-	}
+	while (au_readl(HOST_CMD(host)) & SD_CMD_GO)
+		/* nop */;
 
 	/* Wait for the command to come back */
-
 	if (wait) {
 		u32 status = au_readl(HOST_STATUS(host));
 
-		while(!(status & SD_STATUS_CR))
+		while (!(status & SD_STATUS_CR))
 			status = au_readl(HOST_STATUS(host));
 
 		/* Clear the CR status */
@@ -303,12 +293,11 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
 
 static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 {
-
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_data *data;
 	u32 crc;
 
-	WARN_ON(host->status != HOST_S_DATA && host->status != HOST_S_STOP);
+	WARN_ON((host->status != HOST_S_DATA) && (host->status != HOST_S_STOP));
 
 	if (host->mrq == NULL)
 		return;
@@ -319,15 +308,13 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 		status = au_readl(HOST_STATUS(host));
 
 	/* The transaction is really over when the SD_STATUS_DB bit is clear */
-
-	while((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB))
+	while ((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB))
 		status = au_readl(HOST_STATUS(host));
 
 	data->error = 0;
 	dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma.dir);
 
         /* Process any errors */
-
 	crc = (status & (SD_STATUS_WC | SD_STATUS_RC));
 	if (host->flags & HOST_F_XMIT)
 		crc |= ((status & 0x07) == 0x02) ? 0 : 1;
@@ -344,11 +331,10 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 		if (host->flags & HOST_F_DMA) {
 			u32 chan = DMA_CHANNEL(host);
 
-			chan_tab_t *c = *((chan_tab_t **) chan);
+			chan_tab_t *c = *((chan_tab_t **)chan);
 			au1x_dma_chan_t *cp = c->chan_ptr;
 			data->bytes_xfered = cp->ddma_bytecnt;
-		}
-		else
+		} else
 			data->bytes_xfered =
 				(data->blocks * data->blksz) -
 				host->pio.len;
@@ -359,7 +345,7 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 
 static void au1xmmc_tasklet_data(unsigned long param)
 {
-	struct au1xmmc_host *host = (struct au1xmmc_host *) param;
+	struct au1xmmc_host *host = (struct au1xmmc_host *)param;
 
 	u32 status = au_readl(HOST_STATUS(host));
 	au1xmmc_data_complete(host, status);
@@ -369,11 +355,10 @@ static void au1xmmc_tasklet_data(unsigned long param)
 
 static void au1xmmc_send_pio(struct au1xmmc_host *host)
 {
-
-	struct mmc_data *data = 0;
-	int sg_len, max, count = 0;
-	unsigned char *sg_ptr;
-	u32 status = 0;
+	struct mmc_data *data;
+	int sg_len, max, count;
+	unsigned char *sg_ptr, val;
+	u32 status;
 	struct scatterlist *sg;
 
 	data = host->mrq->data;
@@ -388,22 +373,19 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
 	/* This is the space left inside the buffer */
 	sg_len = data->sg[host->pio.index].length - host->pio.offset;
 
-	/* Check to if we need less then the size of the sg_buffer */
-
+	/* Check if we need less than the size of the sg_buffer */
 	max = (sg_len > host->pio.len) ? host->pio.len : sg_len;
-	if (max > AU1XMMC_MAX_TRANSFER) max = AU1XMMC_MAX_TRANSFER;
-
-	for(count = 0; count < max; count++ ) {
-		unsigned char val;
+	if (max > AU1XMMC_MAX_TRANSFER)
+		max = AU1XMMC_MAX_TRANSFER;
 
+	for (count = 0; count < max; count++) {
 		status = au_readl(HOST_STATUS(host));
-
 		if (!(status & SD_STATUS_TH))
 			break;
 
 		val = *sg_ptr++;
 
-		au_writel((unsigned long) val, HOST_TXPORT(host));
+		au_writel((unsigned long)val, HOST_TXPORT(host));
 		au_sync();
 	}
 
@@ -427,11 +409,10 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
 
 static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 {
-
-	struct mmc_data *data = 0;
-	int sg_len = 0, max = 0, count = 0;
-	unsigned char *sg_ptr = 0;
-	u32 status = 0;
+	struct mmc_data *data;
+	int sg_len = 0, max, count;
+	unsigned char *sg_ptr = NULL;
+	u32 status;
 	struct scatterlist *sg;
 
 	data = host->mrq->data;
@@ -449,13 +430,14 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 		sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset;
 
 		/* Check to if we need less then the size of the sg_buffer */
-		if (sg_len < max) max = sg_len;
+		if (sg_len < max)
+			max = sg_len;
 	}
 
 	if (max > AU1XMMC_MAX_TRANSFER)
 		max = AU1XMMC_MAX_TRANSFER;
 
-	for(count = 0; count < max; count++ ) {
+	for (count = 0; count < max; count++) {
 		u32 val;
 		status = au_readl(HOST_STATUS(host));
 
@@ -472,8 +454,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 			DBG("RX Overrun [%d + %d]\n", host->id,
 					host->pio.len, count);
 			break;
-		}
-		else if (status & SD_STATUS_RU) {
+		} else if (status & SD_STATUS_RU) {
 			DBG("RX Underrun [%d + %d]\n", host->id,
 					host->pio.len,	count);
 			break;
@@ -488,13 +469,13 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 	host->pio.len -= count;
 	host->pio.offset += count;
 
-	if (sg_len && count == sg_len) {
+	if (sg_len && (count == sg_len)) {
 		host->pio.index++;
 		host->pio.offset = 0;
 	}
 
 	if (host->pio.len == 0) {
-		//IRQ_OFF(host, SD_CONFIG_RA | SD_CONFIG_RF);
+		/* IRQ_OFF(host, SD_CONFIG_RA | SD_CONFIG_RF); */
 		IRQ_OFF(host, SD_CONFIG_NE);
 
 		if (host->flags & HOST_F_STOP)
@@ -504,14 +485,11 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 	}
 }
 
-/* static void au1xmmc_cmd_complete
-   This is called when a command has been completed - grab the response
-   and check for errors.  Then start the data transfer if it is indicated.
-*/
-
+/* This is called when a command has been completed - grab the response
+ * and check for errors.  Then start the data transfer if it is indicated.
+ */
 static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 {
-
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_command *cmd;
 	int trans;
@@ -536,7 +514,6 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 			 * we only got 120 bytes, but the engine expects
 			 * 128 bits, so we have to shift things up
 			 */
-
 			for(i = 0; i < 4; i++) {
 				cmd->resp[i] = (r[i] & 0x00FFFFFF) << 8;
 				if (i != 3)
@@ -555,15 +532,13 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 	}
 
         /* Figure out errors */
-
 	if (status & (SD_STATUS_SC | SD_STATUS_WC | SD_STATUS_RC))
 		cmd->error = -EILSEQ;
 
 	trans = host->flags & (HOST_F_XMIT | HOST_F_RECV);
 
 	if (!trans || cmd->error) {
-
-		IRQ_OFF(host, SD_CONFIG_TH | SD_CONFIG_RA|SD_CONFIG_RF);
+		IRQ_OFF(host, SD_CONFIG_TH | SD_CONFIG_RA | SD_CONFIG_RF);
 		tasklet_schedule(&host->finish_task);
 		return;
 	}
@@ -574,29 +549,25 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 		u32 channel = DMA_CHANNEL(host);
 
 		/* Start the DMA as soon as the buffer gets something in it */
-
 		if (host->flags & HOST_F_RECV) {
 			u32 mask = SD_STATUS_DB | SD_STATUS_NE;
 
-			while((status & mask) != mask)
+			while ((status & mask) != mask)
 				status = au_readl(HOST_STATUS(host));
 		}
-
 		au1xxx_dbdma_start(channel);
 	}
 }
 
 static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
 {
-
 	unsigned int pbus = get_au1x00_speed();
 	unsigned int divisor;
 	u32 config;
 
 	/* From databook:
-	   divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1
-	*/
-
+	 * divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1
+	 */
 	pbus /= ((au_readl(SYS_POWERCTRL) & 0x3) + 2);
 	pbus /= 2;
 
@@ -614,7 +585,6 @@ static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
 static int
 au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 {
-
 	int datalen = data->blocks * data->blksz;
 
 	if (dma != 0)
@@ -645,32 +615,31 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 		au1xxx_dbdma_stop(channel);
 
 		for(i = 0; i < host->dma.len; i++) {
-			u32 ret = 0, flags = DDMA_FLAGS_NOIE;
+			u32 ret, flags;
 			struct scatterlist *sg = &data->sg[i];
 			int sg_len = sg->length;
 
 			int len = (datalen > sg_len) ? sg_len : datalen;
 
-			if (i == host->dma.len - 1)
+			if (i == (host->dma.len - 1))
 				flags = DDMA_FLAGS_IE;
-
-    			if (host->flags & HOST_F_XMIT){
-      				ret = au1xxx_dbdma_put_source_flags(channel,
-					(void *) sg_virt(sg), len, flags);
-			}
-    			else {
-      				ret = au1xxx_dbdma_put_dest_flags(channel,
-					(void *) sg_virt(sg),
-					len, flags);
+			else
+				flags = DDMA_FLAGS_NOIE;
+
+			if (host->flags & HOST_F_XMIT){
+				ret = au1xxx_dbdma_put_source_flags(channel,
+					(void *)sg_virt(sg), len, flags);
+			} else {
+				ret = au1xxx_dbdma_put_dest_flags(channel,
+					(void *)sg_virt(sg), len, flags);
 			}
 
-    			if (!ret)
+			if (!ret)
 				goto dataerr;
 
 			datalen -= len;
 		}
-	}
-	else {
+	} else {
 		host->pio.index = 0;
 		host->pio.offset = 0;
 		host->pio.len = datalen;
@@ -679,25 +648,19 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 			IRQ_ON(host, SD_CONFIG_TH);
 		else
 			IRQ_ON(host, SD_CONFIG_NE);
-			//IRQ_ON(host, SD_CONFIG_RA|SD_CONFIG_RF);
+			/* IRQ_ON(host, SD_CONFIG_RA|SD_CONFIG_RF); */
 	}
 
 	return 0;
 
- dataerr:
+dataerr:
 	dma_unmap_sg(mmc_dev(host->mmc),data->sg,data->sg_len,host->dma.dir);
 	return -ETIMEDOUT;
 }
 
-/* static void au1xmmc_request
-   This actually starts a command or data transaction
-*/
-
 static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 {
-
 	struct au1xmmc_host *host = mmc_priv(mmc);
-	unsigned int flags = 0;
 	int ret = 0;
 
 	WARN_ON(irqs_disabled());
@@ -712,7 +675,6 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 
 	if (mrq->data) {
 		FLUSH_FIFO(host);
-		flags = mrq->data->flags;
 		ret = au1xmmc_prepare_data(host, mrq->data);
 	}
 
@@ -727,7 +689,6 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 
 static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 {
-
 	/* Apply the clock */
 	au_writel(SD_ENABLE_CE, HOST_ENABLE(host));
         au_sync_delay(1);
@@ -757,7 +718,7 @@ static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 }
 
 
-static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
+static void au1xmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
 	u32 config;
@@ -788,10 +749,9 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 
 static void au1xmmc_dma_callback(int irq, void *dev_id)
 {
-	struct au1xmmc_host *host = (struct au1xmmc_host *) dev_id;
+	struct au1xmmc_host *host = (struct au1xmmc_host *)dev_id;
 
 	/* Avoid spurious interrupts */
-
 	if (!host->mrq)
 		return;
 
@@ -840,7 +800,7 @@ static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 #endif
 	else if (status & (SD_STATUS_CR)) {
 		if (host->status == HOST_S_CMD)
-			au1xmmc_cmd_complete(host,status);
+			au1xmmc_cmd_complete(host, status);
 
 	} else if (!(host->flags & HOST_F_DMA)) {
 		if ((host->flags & HOST_F_XMIT) && (status & STATUS_DATA_OUT))
-- 
1.5.5.1


From macro@linux-mips.org Wed May  7 17:14:34 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 17:14:37 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:17403 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022388AbYEGQOe (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 17:14:34 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m47GEWMO027659;
	Wed, 7 May 2008 18:14:32 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m47GEMYH027655;
	Wed, 7 May 2008 17:14:32 +0100
Date:	Wed, 7 May 2008 17:14:22 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
cc:	Ralf Baechle <ralf@linux-mips.org>,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and
 build_copy_page
In-Reply-To: <20080507233815.e6de28da.yoichi_yuasa@tripeaks.co.jp>
Message-ID: <Pine.LNX.4.55.0805071712520.25644@cliff.in.clinika.pl>
References: <20080507233815.e6de28da.yoichi_yuasa@tripeaks.co.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19136
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 257
Lines: 8

On Wed, 7 May 2008, Yoichi Yuasa wrote:

> Fix divide by zero error in build_clear_page() and build_copy_page()

 Why would ever cache_line_size be zero in this place?  Are you trying to 
support a cacheless CPU?  If not, it should be a BUG_ON().

  Maciej

From macro@linux-mips.org Wed May  7 21:04:57 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 21:05:00 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:62966 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20034048AbYEGUE5 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 21:04:57 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m47K425v029903;
	Wed, 7 May 2008 22:04:02 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m47K3Wmk029899;
	Wed, 7 May 2008 21:03:41 +0100
Date:	Wed, 7 May 2008 21:03:31 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <alessandro.zummo@towertech.it>
cc:	rtc-linux@googlegroups.com, Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [rtc-linux] [RFC][PATCH 0/4] RTC: Use class devices as a persistent
 clock
In-Reply-To: <20080507085739.4f538d2e@i1501.lan.towertech.it>
Message-ID: <Pine.LNX.4.55.0805072055010.25644@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805062333390.16173@cliff.in.clinika.pl>
 <20080507085739.4f538d2e@i1501.lan.towertech.it>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19137
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 529
Lines: 13

Hi Alessandro,

>    you did a great work. you have my Acked-by on the rtc/ntp code, but
>  I think we'd need some reports from current users of the m41t81 driver
>  before pushing that one in.

 Thanks for appreciation.  You are right about the driver -- I have
explicitly asked for help to test it with the patch submission.  Actually
the only other user right now is a D-Link DNS-323 ARM-based system.  I
meant to cc the maintainer of the platform, but in the end I forgot.  
I'll do it now -- thanks for the point.

  Maciej

From macro@linux-mips.org Wed May  7 21:44:40 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 21:44:42 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:53496 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022994AbYEGUok (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 21:44:40 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m47Ki3Ws030259;
	Wed, 7 May 2008 22:44:03 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m47Khrtt030247;
	Wed, 7 May 2008 21:44:02 +0100
Date:	Wed, 7 May 2008 21:43:53 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	David Woodhouse <dwmw2@infradead.org>
cc:	rtc-linux@googlegroups.com,
	Alessandro Zummo <a.zummo@towertech.it>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [rtc-linux] [RFC][PATCH 1/4] RTC: Class device support for
 persistent clock
In-Reply-To: <1210148655.25560.825.camel@pmac.infradead.org>
Message-ID: <Pine.LNX.4.55.0805072109090.25644@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
 <1210148655.25560.825.camel@pmac.infradead.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19138
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3817
Lines: 75

On Wed, 7 May 2008, David Woodhouse wrote:

> Ooh, shiny -- you saved me the trouble of doing this (and hopefully also
> the trouble of looking through it to check whether all the callers of
> read_persistent_clock() can sleep, etc.?)

 :-)

 Yes, the generic callers of read_persistent_clock() seem to be fine.  I
have not dug into various pieces of platform code to check there though.  
I do hope platform maintainers enable these debugging checks from time to
time -- I mean especially those taking care of all these more or less
exotic systems and boards residing one level below generic architecture
support... ;-)

> One thing I was going to do in rtc_update_persistent_clock() was make it
> use mutex_trylock() for grabbing rtc->lock. We go to great lengths to
> make sure we're updating the clock at the correct time -- we don't want
> to be doing things which delay the update. So we should probably just
> use mutex_trylock() and abort the update (this time) if it fails.

 Good idea.

> I was also thinking of holding the RTC_HCTOSYS device open all the time,
> too. If it's a problem that you then couldn't unload the module, perhaps
> a sysfs interface to set/change/clear which device is used for this?

 I have thought of this and recognised the concern about modules.  I think
another possibility that could work with modules might be opening and
closing the device on demand.  But still it is just an optimisation, which
can certainly be done gradually on top of these changes without even
changing the interface.

 From the code structure's point of view it is certainly cleaner to open
and close the device each time it is used and I think as such it is a good
starting point -- let's spoil it later. ;-)

> When we discussed it last week, Alessandro was concerned that the
> 'update at precisely 500ms past the second' rule was not universal to
> all RTC devices, although I'm not entirely sure. It might be worth
> moving that logic into a 'default' NTP-sync routine provided by the RTC
> class, so that if any strange devices exist which require different
> treatment, they can override that.

 Even better than that -- some devices may have better precision and 
require no strange handling.  For example this very M41T81 chip I am 
working with supports resolution up to .01s -- which means there is little 
point in trying to work out delays, etc. to get the clock written back at 
the right point, where we can easily obtain two levels of magnitude better 
a resolution by simply not discarding the sub-second part of a timestamp.  

 Of course for sub-second resolution of the RTC the interface of
read_persistent_clock() would have to be modified to return a struct
timespec; contrarily update_persistent_clock() is ready for that, but then
struct rtc_time plus rtc_read_time(), rtc_set_mmss() and rtc_set_time()  
will still have to be updated accordingly.

 BTW, this chip is even better than that, because it can be disciplined --
there is a five-bit calibration register that lets one add or remove
oscillator ticks to/from the input at a certain stage of the divider chain
-- that could be used by the NTP daemon or tools like `hwclock --adjust'
somehow.  It's just an idea -- I have not investigated it further.

> I wouldn't worry too much about leaving the old
> update_persistent_clock() and read_persistent_clock() -- I hope we can
> plan to remove those entirely in favour of the RTC class methods.

 Yes, that I would consider a reasonable long-term plan, but it will take
at least a short while during which it might not be a good idea to break
all the platforms that have not got converted yet.  Especially as, however
unbelievable it may sound, unlike myself I think most people do not
consider the Broadcom SWARM the most obvious platform to use and/or
support.

  Maciej

From macro@linux-mips.org Wed May  7 22:14:11 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 22:14:13 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:29434 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20021985AbYEGVOL (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 22:14:11 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m47LDP36030542;
	Wed, 7 May 2008 23:13:25 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m47LDNto030538;
	Wed, 7 May 2008 22:13:24 +0100
Date:	Wed, 7 May 2008 22:13:23 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>
cc:	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080507085953.2c08b854@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507085953.2c08b854@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19139
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3068
Lines: 62

Hi Jean,

> Minor corrections which would ideally belong to a separate patch
> (there's a whole lot more cleanups that could be done in that driver,
> BTW...)

 Not suprising, as usually with most pieces of code for the SWARM and the 
SiByte SOC.  That can be done gradually, but mixing a driver overhaul with 
functional changes usually only results in confusion later on.

> I don't think that the minor changes below are enough for you to claim
> copyright on that driver.

 Well, I decide whether or not to add one based on how important changes
are from the piece's of code point of view.  In this case the change is
essential for new-style client drivers to work at all, which I think is
more important than e.g. a lot of cosmetical changes throughout would be.  
But I do not insist on keeping it -- if you think I misjudged on this
occasion, I see no problem with discarding it.

> Why do you double the space and the end of comments? Never seen that
> before, and I can't see the idea.

 This is mostly habitual -- this is what the GNU Coding Standard specifies
for comments and which is enforced for GNU software which I have dealt a
lot with.  I think the idea is it improves readability and I tend to
agree.  The same goes for using a capital at the beginning and a full stop
at the end of sentences in comments -- it improves readability and
(together with a good style of code itself) makes the result look more
professional.  Certainly well-formatted code is easier to comprehend for 
someone looking at it for the first time.

 I do not insist on the extraneous space if you have a strong opinion 
against though.

> I'm not sure how you intend to push these changes upstream. I would
> take a patch only touching drivers/i2c/busses/i2c-sibyte.c in my i2c
> tree, however a patch also touching arch code, must be handled be the
> maintainer for that architecture or platform.

 Andrew has spoken (thank you, Andrew) and I would only like to add an
explanation why I have not split this change further.  Certainly it is
functionally consistent.  Then adding i2c-swarm.c only breaks things as
the onchip buses suddenly get the numbers 2 and 3.  On the other hand, if
adding the i2c-sibyte.c change only, it will take a while until it
propagates back to the MIPS tree and without that as it is there is no
single way to use the whole set of changes as the clock device will not be
seen.

 If you are scared off by the MIPS-specific Makefile (lib vs obj) changes,
then I think they should be reasonably easy to sort out separately in a
couple of days as functionally not changing anything.  The only other file
in the affected subdirectory that depends on a config option uses
CONFIG_KGDB which does not seem to rely on being pulled implicitly by the
linker.  But such a mechanical change by itself would make little sense 
(don't fix what isn't broken), so I have not pushed it without a 
reasonable justification.

 Ralf -- what do you think about the Makefile changes?  I can send you a 
separate patch which will reduce the span of this one.

  Maciej

From johnstul.lkml@gmail.com Wed May  7 22:18:03 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 22:18:06 +0100 (BST)
Received: from wx-out-0506.google.com ([66.249.82.235]:46401 "EHLO
	wx-out-0506.google.com") by ftp.linux-mips.org with ESMTP
	id S20022046AbYEGVSD (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 7 May 2008 22:18:03 +0100
Received: by wx-out-0506.google.com with SMTP id s13so471779wxc.21
        for <linux-mips@linux-mips.org>; Wed, 07 May 2008 14:18:01 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth;
        bh=vYUxK9X2VZYS2ZwSs+l6TPTDDkrGQ6bbLsBl/iyXVIM=;
        b=ffFR2fD9Q4qjfkuznU11MlLAiDtzvaE7PIlyaMSK1YWulGwqZNDE9XcB2EmZg+Z5TBB7TeXvwvPiGDneNa74OkOBUgkk2ZQr5UGgjrj6pLmoflebNHsK5xw+y5O2tO3vKiU0UlUoEUcESwbuseYqlfXw+aHqFVJgFPGjvTSbeaM=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth;
        b=ttJn/Jx5mARiaEaz6swkHzKI/iD15Bf53CCBNt6wOARWvvaL2ThvMS4ra1OAGI44S6oLNwjclwT8WT8rzFDlDj5xNxmUQCDDCUg4KDCF3kl47JTZuRf0NoE9sUHEmAoyd6fMe68elmitdU05Y6bUghKk29esmUf1FdhirEy8cfQ=
Received: by 10.90.31.8 with SMTP id e8mr3584641age.22.1210195081778;
        Wed, 07 May 2008 14:18:01 -0700 (PDT)
Received: by 10.90.92.13 with HTTP; Wed, 7 May 2008 14:18:01 -0700 (PDT)
Message-ID: <1f1b08da0805071418q365680bexafb1996dcc77ebb0@mail.gmail.com>
Date:	Wed, 7 May 2008 14:18:01 -0700
From:	"john stultz" <johnstul@us.ibm.com>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: [RFC][PATCH 1/4] RTC: Class device support for persistent clock
Cc:	"Alessandro Zummo" <a.zummo@towertech.it>,
	"Jean Delvare" <khali@linux-fr.org>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
In-Reply-To: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <Pine.LNX.4.55.0805070015360.16173@cliff.in.clinika.pl>
X-Google-Sender-Auth: 590bf975fa113a09
Return-Path: <johnstul.lkml@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19140
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: johnstul@us.ibm.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1430
Lines: 30

On Tue, May 6, 2008 at 5:40 PM, Maciej W. Rozycki <macro@linux-mips.org> wrote:
>  This is a generic implementation of rtc_read_persistent_clock() and
>  rtc_update_persistent_clock() suitable for platforms to be used for
>  read_persistent_clock() and update_persistent_clock() calls.  An RTC
>  device selected by the user with the RTC_HCTOSYS_DEVICE option is used.
>
>   As rtc_read_persistent_clock() is not available at the time
>  timekeeping_init() is called, it will now be disabled if the class device
>  is to be used as a reference.  In this case rtc_hctosys(), already
>  present, will be used to set up the system time at the late initcall time.
>  This call has now been rewritten to make use of
>  rtc_read_persistent_clock().

Hrmm. So how is this going to work with suspend and resume?

Ideally, on resume we want to update the clock before interrupts are
reenabled so we don't get stale time values post-resume.  For systems
that sleep on reading the persistent clock, I'm open to having them
fix it up as best they can later (partly why the code can handle
read_persistent_clock() not returning anything), but unless I'm
misreading this, it seems you're proposing to make systems that do
have a safe persistent clock have to have the window where code may
see the pre-suspend time after resume.

Am I missing something here?

thanks
-john

Maciej: Sorry for the dup, I forgot to reply to all on my first mail.

From macro@linux-mips.org Wed May  7 22:26:11 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 22:26:13 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:63994 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022007AbYEGV0L (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 22:26:11 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m47LPKLW030660;
	Wed, 7 May 2008 23:25:20 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m47LP8Ag030656;
	Wed, 7 May 2008 22:25:08 +0100
Date:	Wed, 7 May 2008 22:25:08 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	Geert Uytterhoeven <geert@linux-m68k.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080507094343.25f279b9@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805072214090.25644@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507090514.3a86cf4b@hyperion.delvare> <Pine.LNX.4.64.0805070936060.6341@anakin>
 <20080507094343.25f279b9@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19141
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1486
Lines: 32

Hi Jean,

> > > i2c-foo.c is consistently used for i2c bus driver themselves so far.
> > > It's somewhat confusing to see you name platform code that way. It's
> > > also redundant, given that the file lives in the swarm platform
> > > directory. May I suggest naming this file just
> > > arch/mips/sibyte/swarm/i2c.c? Other architectures (cris, arm) are doing
> > > this already.
> > 
> > Is there any chance CONFIG_I2C_BOARDINFO could become tristate?
> > If yes, it's problematic if you have multiple modules called i2c.ko.
> 
> No, CONFIG_I2C_BOARDINFO is boolean by nature, it will never become
> tristate.

 I can do that and I have considered it while preparing the change.  What
convinced me not to use a name that is already present elsewhere in the
tree is the confusion that it sometimes causes.  For example during a
debugging session GDB only reports the file name and not the leading
pathname (and some people do run GDB over the kernel).  Of course the
actual file can still be chased with some `find' and `grep' scriptery, but
why to create a problem in the first place?

 I consider repeated file names throughout a tree of a single program a 
namespace pollution similar to one with repeated static symbol names.  
While syntactically valid and working, it asks for unnecessary confusion.

 This is my point of view, but I can see others may not necessarily follow
it.  I am fine with changing the name to i2c.c as it is unlikely I will
run GDB over it. ;-)

  Maciej

From yoichi_yuasa@tripeaks.co.jp Wed May  7 23:38:10 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 07 May 2008 23:38:13 +0100 (BST)
Received: from mo30.po.2iij.net ([210.128.50.53]:27923 "EHLO mo30.po.2iij.net")
	by ftp.linux-mips.org with ESMTP id S20022078AbYEGWiK (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 7 May 2008 23:38:10 +0100
Received: by mo.po.2iij.net (mo30) id m47Mc43M052245; Thu, 8 May 2008 07:38:04 +0900 (JST)
Received: from rally.tripeaks.co.jp (65.126.232.202.bf.2iij.net [202.232.126.65])
	by mbox.po.2iij.net (po-mbox303) id m47MbxbZ022160
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
	Thu, 8 May 2008 07:38:01 +0900
Message-Id: <200805072238.m47MbxbZ022160@po-mbox303.hop.2iij.net>
Date:	Thu, 8 May 2008 07:38:08 +0900
From:	Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	yoichi_yuasa@tripeaks.co.jp, Ralf Baechle <ralf@linux-mips.org>,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and
 build_copy_page
In-Reply-To: <Pine.LNX.4.55.0805071712520.25644@cliff.in.clinika.pl>
References: <20080507233815.e6de28da.yoichi_yuasa@tripeaks.co.jp>
	<Pine.LNX.4.55.0805071712520.25644@cliff.in.clinika.pl>
Organization: TriPeaks Corporation
X-Mailer: Sylpheed version 2.3.0beta5 (GTK+ 2.8.20; x86_64-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <yoichi_yuasa@tripeaks.co.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19142
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: yoichi_yuasa@tripeaks.co.jp
Precedence: bulk
X-list: linux-mips
Content-Length: 505
Lines: 15

On Wed, 7 May 2008 17:14:22 +0100 (BST)
"Maciej W. Rozycki" <macro@linux-mips.org> wrote:

> On Wed, 7 May 2008, Yoichi Yuasa wrote:
> 
> > Fix divide by zero error in build_clear_page() and build_copy_page()
> 
>  Why would ever cache_line_size be zero in this place?  Are you trying to 
> support a cacheless CPU?  If not, it should be a BUG_ON().
> 

When CPU has no prefetch, no cache cdex_s and no caache cdex_p, cache_line_size is zero.
I confirmed it with Nevada(Cobalt server) and VR41xx.

Yoichi

From macro@linux-mips.org Thu May  8 00:05:02 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 00:05:05 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:1007 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20023276AbYEGXFC (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 00:05:02 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m47N4xai031430;
	Thu, 8 May 2008 01:04:59 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m47N4td5031425;
	Thu, 8 May 2008 00:04:59 +0100
Date:	Thu, 8 May 2008 00:04:54 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
cc:	Ralf Baechle <ralf@linux-mips.org>,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and
 build_copy_page
In-Reply-To: <200805072238.m47MbxbZ022160@po-mbox303.hop.2iij.net>
Message-ID: <Pine.LNX.4.55.0805080003120.31409@cliff.in.clinika.pl>
References: <20080507233815.e6de28da.yoichi_yuasa@tripeaks.co.jp>
 <Pine.LNX.4.55.0805071712520.25644@cliff.in.clinika.pl>
 <200805072238.m47MbxbZ022160@po-mbox303.hop.2iij.net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19143
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 525
Lines: 14

On Thu, 8 May 2008, Yoichi Yuasa wrote:

> >  Why would ever cache_line_size be zero in this place?  Are you trying to 
> > support a cacheless CPU?  If not, it should be a BUG_ON().
> > 
> 
> When CPU has no prefetch, no cache cdex_s and no caache cdex_p, cache_line_size is zero.
> I confirmed it with Nevada(Cobalt server) and VR41xx.

 Fair enough.  I confused the variable with some others used to store the
actual line size of each of the caches.  Your change is correct, thank you
and sorry about the noise.

  Maciej

From dvomlehn@cisco.com Thu May  8 00:50:12 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 00:50:19 +0100 (BST)
Received: from sj-iport-2.cisco.com ([171.71.176.71]:54148 "EHLO
	sj-iport-2.cisco.com") by ftp.linux-mips.org with ESMTP
	id S20021484AbYEGXuM (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 00:50:12 +0100
Received: from sj-dkim-1.cisco.com ([171.71.179.21])
  by sj-iport-2.cisco.com with ESMTP; 07 May 2008 16:49:54 -0700
Received: from sj-core-1.cisco.com (sj-core-1.cisco.com [171.71.177.237])
	by sj-dkim-1.cisco.com (8.12.11/8.12.11) with ESMTP id m47NnsSG003249
	for <linux-mips@linux-mips.org>; Wed, 7 May 2008 16:49:54 -0700
Received: from cliff.cisco.com (cliff.cisco.com [171.69.11.141])
	by sj-core-1.cisco.com (8.13.8/8.13.8) with ESMTP id m47NnsSC004582
	for <linux-mips@linux-mips.org>; Wed, 7 May 2008 23:49:54 GMT
Received: from cuplxvomd02.corp.sa.net ([64.101.20.155]) by cliff.cisco.com (8.6.12/8.6.5) with ESMTP id XAA05289 for <linux-mips@linux-mips.org>; Wed, 7 May 2008 23:49:53 GMT
Message-ID: <48224021.7050306@cisco.com>
Date:	Wed, 07 May 2008 16:49:53 -0700
From:	David VomLehn <dvomlehn@cisco.com>
Reply-To: dvomlehn@cisco.com
User-Agent: Thunderbird 2.0.0.12 (X11/20080226)
MIME-Version: 1.0
To:	linux-mips@linux-mips.org
Subject: [RFC] [PATCH 1/1] [MIPS] Advanced Kernel Stack Backtrace
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
DKIM-Signature:	v=1; a=rsa-sha256; q=dns/txt; l=136334; t=1210204194; x=1211068194;
	c=relaxed/simple; s=sjdkim1004;
	h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version;
	d=cisco.com; i=dvomlehn@cisco.com;
	z=From:=20David=20VomLehn=20<dvomlehn@cisco.com>
	|Subject:=20[RFC]=20[PATCH=201/1]=20[MIPS]=20Advanced=20Ker
	nel=20Stack=20Backtrace
	|Sender:=20;
	bh=yHozLPhZjtVuLhbdyLNAuQlyehi66tUOyO5WCA6glr4=;
	b=BfYw76kjmYlIKwyBNgZcExIeinX6mBozPu/BOGdutRRWnONOE+ozEFrrx1
	ZHckZHgH+E1YACfBYCldgpVunQ62o/tGhXyi8HfYv7tqRpWfQ3/VS2eGGkGv
	uVtCDVEf2t/6N3AEpTVTeSfwws/QWxMT0JZ0mNc3LZU+Fu2fxj8f8=;
Authentication-Results:	sj-dkim-1; header.From=dvomlehn@cisco.com; dkim=pass (
	sig from cisco.com/sjdkim1004 verified; ); 
Return-Path: <dvomlehn@cisco.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19144
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: dvomlehn@cisco.com
Precedence: bulk
X-list: linux-mips
Content-Length: 132137
Lines: 4197

This patch contains the kernel stack backtrace code we've been running 
for about a year on our MIPS-based settop box. It is considerably larger 
than the existing backtrace implementation and so is configurable in the 
Kernel Hacking section.  It also requires that KALLSYMS be enabled. In 
return, I think it offers some advantages over the existing backtrace code:

o It will backtrace over nested interrupts and exceptions, allowing 
detailed analysis of was going on when it was invoked.
o It handles a number of corner cases involving instructions in branch 
delay slots.
o It is very careful to use __get_user when fetching stack data and 
instructions, meaning that it will fail gracefully even in the presence 
of stack corruption.
o It identifies whether the $sp register or another register is being 
used as the frame pointer. Assuming people are happy with this 
submission, there is a small subsequent patch I'll submit that dumps the 
frame pointer value as part of the backtrace.
o It segregates the backtrace code into a subdirectory of 
arch/mips/kernel rather than cluttering up traps.c or the kernel directory.

The main reason I am submitting this as a request for comments rather 
than as a normal patch is that, though I wrote it with 64-bit systems in 
mind, I don't have access to a 64-bit system on which to test it. I am 
happy to merge any 64-bit-specific changes. For 32-bit systems, I'll 
claim it's ready to go.

The other reason is that this is an RFC is that it is such a large, 
single chunk of code that there are certainly lots of comments that 
people will have. I'm not naive enough to think it's really ready 
without more review.

[Note: for anyone who was at the MIPS backtrace session at the CELF 
Conference, this is the code I was talking about.]

Signed-off-by: David VomLehn <dvomlehn@cisco.com>
--
diff -urN linux-2.6.25.1/arch/mips/Kconfig.debug 
linux-t/arch/mips/Kconfig.debug
--- linux-2.6.25.1/arch/mips/Kconfig.debug	2008-05-01 14:45:25.000000000 
-0700
+++ linux-t/arch/mips/Kconfig.debug	2008-05-06 18:21:45.000000000 -0700
@@ -73,6 +73,17 @@
  	  include/asm-mips/debug.h for debuging macros.
  	  If unsure, say N.

+config MIPS_ADVANCED_BACKTRACE
+	bool "More sophisticated backtrace code"
+	default n
+	depends on KALLSYMS
+	help
+	  Use backtrace code that more completely handles the various
+	  complexities of the MIPS processors, including branch delay
+	  slots. This is substantially larger than the standard backtrace
+	  code. Using this also prints the frame pointer for each function
+	  in the call stack.
+
  config MIPS_UNCACHED
  	bool "Run uncached"
  	depends on DEBUG_KERNEL && !SMP && !SGI_IP27
diff -urN linux-2.6.25.1/arch/mips/kernel/backtrace/kernel-backtrace.c 
linux-t/arch/mips/kernel/backtrace/kernel-backtrace.c
--- linux-2.6.25.1/arch/mips/kernel/backtrace/kernel-backtrace.c 
1969-12-31 16:00:00.000000000 -0800
+++ linux-t/arch/mips/kernel/backtrace/kernel-backtrace.c	2008-05-06 
18:38:48.000000000 -0700
@@ -0,0 +1,978 @@
+/*
+ *				kernel-backtrace.c
+ *
+ * Perform backtrace in the kernel. This means that, besides handling 
signals
+ * (which can happen to kernel threads, too), it must handle 
backtracing over
+ * exceptions and interrupts.
+ *
+ * Copyright (C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#include <linux/irq.h>
+#include <linux/kallsyms.h>
+#include <linux/module.h>
+#include <asm/system.h>
+#include <asm/mipsregs.h>
+#include <asm/uaccess.h>
+#include <asm/asm-offsets.h>
+#include <asm/kernel-backtrace.h>
+#include <asm/kernel-backtrace-symbols.h>
+
+#ifndef	numberof
+#define	numberof(a)	(sizeof(a) / sizeof((a) [0]))
+#endif
+
+/* Offsets and sizes in the exception vector */
+#define	TLB_REFILL_OFFSET	0
+#define	TLB_REFILL_SIZE		0x80
+#define	GEN_EX_OFFSET		0x180
+#define	GEN_EX_SIZE		0x80
+#define	INTERRUPT_OFFSET	0x200
+#define	INTERRUPT_SIZE		(NR_IRQS * vectorspacing())
+#define	UNEXPECTED_OFFSET	0x80
+#define	UNEXPECTED_SIZE		0x100
+
+static int in_exception_vector(reg_t pc, unsigned start, unsigned size);
+static const struct kern_special_sym *special_symbol(reg_t pc, reg_t 
*start,
+	reg_t *size);
+static int pop_k0_k1_only_frame(struct kernel_bt *bt);
+static int pop_save_some_frame(struct kernel_bt *bt);
+static int pop_save_all_frame(struct kernel_bt *bt);
+static int pop_save_some_or_all_frame(struct kernel_bt *bt);
+static int pop_save_static_frame(struct kernel_bt *bt);
+static int pop_glue_frame(struct kernel_bt *bt);
+static int pop_restore_some_frame(struct kernel_bt *bt);
+static int pop_exception(struct kernel_bt *bt);
+static int do_kernel_backtrace(struct kernel_bt *bt,
+	process_kernel_frame_t process, void *arg);
+static int update_saved_registers(struct kernel_bt *bt, reg_t ip,
+	reg_t ptr);
+static int update_saved_register(struct kernel_bt *bt, reg_t ptr,
+	reg_offset_t offset);
+static int read_pt_regs(struct kernel_bt *bt);
+static int get_op(reg_t ip, opcode_t *op);
+static int get_reg(reg_t rp, reg_t *reg);
+static int symbol_lookup(reg_t ip, reg_t *start, reg_t *size);
+static int get_sc_reg(reg_t rp, reg_t *reg);
+
+static const struct thread_bt_config tb_config = {
+	{SIMPLE_BACKTRACE_LOOKUP_FUNC, get_op, get_reg, symbol_lookup},
+	get_sc_reg
+};
+
+/*
+ * Returns the number of bytes in each entry of the interrupt vector.
+ */
+static unsigned vectorspacing(void)
+{
+	const unsigned	M_VS = 0x000003e0;
+	const unsigned	S_VS = 0;
+
+	return(read_c0_intctl() & M_VS) >> S_VS;
+}
+
+/*
+ * Perform a stack backtrace from the values in a struct pt_regs object.
+ * Params:	regs	Pointer to a struct pt_regs object with the initial
+ *			register values to be used for the backtrace
+ *		process	Function that processes a stack frame
+ *		arg	Argument passed to the function that processes a
+ *			stack frame
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+int kernel_backtrace_pt_regs(const struct pt_regs *regs,
+	process_kernel_frame_t process, void *arg)
+{
+	struct kernel_bt	bt;
+	enum reg_num		i;
+
+	thread_backtrace_init(&bt.tbt, &tb_config);
+
+	for (i = REG_AT; i < REG_ALL; i ++) {
+		bt.tbt.sbt.gprs [i] = regs->regs [i];
+		bt.tbt.sbt.gpr_saved [i] = 1;
+	}
+
+	bt.tbt.sbt.pc = regs->cp0_epc;
+
+	bt.cp0_epc = regs->cp0_epc;
+	bt.cp0_status = regs->cp0_status;
+	bt.type = KERNEL_FRAME_SIMPLE;
+
+	return do_kernel_backtrace(&bt, process, arg);
+}
+EXPORT_SYMBOL(kernel_backtrace_pt_regs);
+
+/*
+ * Backtrace for a process the current function, including handling of
+ * signal frames.
+ * Params:	process	Function that will process each stack frame.
+ *		arg	Argument to passed to the processing function.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+int kernel_backtrace(process_kernel_frame_t process, void *arg)
+{
+	struct kernel_bt	bt;
+
+	thread_backtrace_init_here(&bt.tbt, &tb_config);
+
+	bt.cp0_epc = read_c0_epc();
+	bt.cp0_status = read_c0_status();
+	bt.type = KERNEL_FRAME_SIMPLE;
+
+	return do_kernel_backtrace(&bt, process, arg);
+}
+EXPORT_SYMBOL(kernel_backtrace);
+
+/*
+ * This performs a kernel backtrace.
+ * Params:	bt	Pointer to initialized kernel backtrace information
+ * 		process	Function that will process each stack frame.
+ *		arg	Argument to passed to the processing function.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int do_kernel_backtrace(struct kernel_bt *bt,
+	process_kernel_frame_t process, void *arg)
+{
+	int	result;
+
+	for (result = kernel_backtrace_first(bt);
+		result == 0;
+		result = kernel_backtrace_next(bt)) {
+
+		/* If $pc is a return address, i.e. an address stored in $ra
+		 * by a jalr instruction, adjust it to point to the jalr
+		 * because, in some sense, that instruction is not yet
+		 * complete. */
+		if (bt->tbt.pc_is_return_address) {
+			bt->tbt.sbt.pc -= 2 * OPCODE_SIZE;
+			bt_dbg(2, "$pc is return address, adjusted to 0x%lx\n",
+				bt->tbt.sbt.pc);
+		}
+
+		result = process(arg, bt);
+
+		/* If we adjusted the pc to point to a jalr instruction,
+		 * restore it */
+		if (bt->tbt.pc_is_return_address)
+			bt->tbt.sbt.pc += 2 * OPCODE_SIZE;
+
+		if (result != 0)
+			break;
+	}
+
+	/* If we got a return value of -ENOSYS, the $pc and $sp values are
+	 * good, but we can't continue the backtrace. Call the function to
+	 * process the last frame. */
+
+	if (result == -ENOSYS) {
+		(void) process(arg, bt);
+		result = 0;
+	}
+
+	/* The result could be zero because we internally determined that
+	 * the stack backtrace is done, or because the process function
+	 * passed back KERNEL_BACKTRACE_END to indicate that the backtrace
+	 * is done. Either case is normal, so adjust the result to indicate
+	 * a normal termination. */
+	if (result > 0) {
+		bt_dbg(2, "Adjusting positive return code %d to zero", result);
+		result = 0;
+	}
+
+	return result;
+}
+
+/*
+ * Gets the first stack frame.
+ * Params:	bt	Pointer struct kernel_bt object
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ *
+ */
+int kernel_backtrace_first(struct kernel_bt *bt)
+{
+	int	result;
+
+	result = kernel_backtrace_analyze_frame(bt);
+
+	return result;
+}
+
+/*
+ * This handles getting the next kernel stackframe. It checks to see if 
we are
+ * in an exception or interrupt frame. If not, we just pass it along to the
+ * process backtracing.
+ * Params:	bt	Pointer to the struct kernel_bt object
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+int kernel_backtrace_next(struct kernel_bt *bt)
+{
+	int	result;
+
+	result = kernel_backtrace_pop_frame(bt);
+
+	if (result == 0)
+		result = kernel_backtrace_analyze_frame(bt);
+
+	return result;
+}
+
+/*
+ * This determines the type of the current frame. This is done by 
looking at
+ * the $pc register and seeing whether it is in some sort of interrupt or
+ * exception frame. If not, it passes the analysis on to the 
thread_backtrace
+ * code.
+ * Params:	bt	Pointer to a struct kernel_bt object.
+ * Returns:	Zero if it was able to determine the frame type, or a negative
+ *		errno value if an error occurred during processing.
+ */
+int kernel_backtrace_analyze_frame(struct kernel_bt *bt)
+{
+	int			result = 0;	/* Assume success */
+	reg_t			pc;
+	const struct kern_special_sym	*symbol;
+
+	bt->tbt.sbt.frame_size = 0;
+	pc = bt->tbt.sbt.pc;
+
+	/* The kernel is kind enough to arrange things so that the return
+	 * address is NULL if we have reached the end of a kernel stack, so
+	 * if we see that case, we are done. */
+	if (pc == NULL_REG)
+		result = KERNEL_BACKTRACE_DONE;
+
+	else {
+		symbol = special_symbol(pc, &bt->start, &bt->size);
+
+		if (symbol != NULL) {
+			bt->tbt.pc_is_return_address = 0;
+			bt->type = symbol->type;
+		}
+
+		else if (in_exception_vector(pc, TLB_REFILL_OFFSET,
+			TLB_REFILL_SIZE)) {
+			bt->tbt.pc_is_return_address = 0;
+			bt->type = KERNEL_FRAME_TLB_REFILL;
+			bt->start = ebase + TLB_REFILL_OFFSET;
+			bt->size = TLB_REFILL_SIZE;
+		}
+
+		else if (in_exception_vector(pc, GEN_EX_OFFSET, GEN_EX_SIZE)) {
+			bt->tbt.pc_is_return_address = 0;
+			bt->type = KERNEL_FRAME_GENERAL_EXCEPTION;
+			bt->start = ebase + GEN_EX_OFFSET;
+			bt->size = GEN_EX_SIZE;
+		}
+
+		else if (in_exception_vector(pc, INTERRUPT_OFFSET,
+			INTERRUPT_SIZE)) {
+			unsigned	offset, irq, spacing;
+			bt->tbt.pc_is_return_address = 0;
+			bt->type = KERNEL_FRAME_INTERRUPT;
+
+			/* Since we are using the exception vector for handling
+			 * interrupts, i.e. the CP0 Config3 register has VEIC
+			 * or VI set and the CP0 Cause register has the IV bit
+			 * set, we subtract ebase + INTERRUPT_OFFSET from $pc
+			 * to get the offset into the interrupt vector portion.
+			 * We divide this by the space of the interrupt vector
+			 * entries to get the interrupt number. Then the start
+			 * of the entry for this interrupt is computed by
+			 * multiplying the interrupt number by the spacing and
+			 * adding ebase and INTERRUPT_OFFSET back in. The size
+			 * of the entry is given by the spacing of the
+			 * interrupt vector entries. */
+			spacing = vectorspacing();
+			offset = pc - (ebase + INTERRUPT_OFFSET);
+			irq = offset / spacing;
+			bt->start = ebase + INTERRUPT_OFFSET + irq * spacing;
+			bt->size = spacing;
+		}
+
+		else if (in_exception_vector(pc, UNEXPECTED_OFFSET,
+			UNEXPECTED_SIZE)) {
+			bt->tbt.pc_is_return_address = 0;
+			bt->type = KERNEL_FRAME_UNEXPECTED;
+			bt->start = ebase + UNEXPECTED_OFFSET;
+			bt->size = UNEXPECTED_SIZE;
+		}
+
+		else {
+			result = thread_backtrace_analyze_frame(&bt->tbt);
+			bt->type = bt->tbt.type;
+		}
+	}
+
+	return result;
+}
+
+/*
+ * Advances to the next frame based on the analysis of the current frame
+ * done by kernel_backtrace_analyze_frame().
+ * Params:	bt	Pointer to struct struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+int kernel_backtrace_pop_frame(struct kernel_bt *bt)
+{
+	int	result;
+
+	switch (bt->type) {
+	case KERNEL_FRAME_SIMPLE:
+	case KERNEL_FRAME_SIGNAL:
+	case KERNEL_FRAME_RT_SIGNAL: result =
+			thread_backtrace_pop_frame(&bt->tbt);
+		break;
+
+	case KERNEL_FRAME_TLB_REFILL:
+	case KERNEL_FRAME_GENERAL_EXCEPTION:
+	case KERNEL_FRAME_K0_K1_ONLY: result = pop_k0_k1_only_frame(bt);
+		break;
+
+	case KERNEL_FRAME_INTERRUPT:
+	case KERNEL_FRAME_SAVE_SOME: result = pop_save_some_frame(bt);
+		break;
+
+	case KERNEL_FRAME_SAVE_STATIC: result = pop_save_static_frame(bt);
+		break;
+
+	case KERNEL_FRAME_SAVE_ALL: result = pop_save_all_frame(bt);
+		break;
+
+	case KERNEL_FRAME_GLUE: result = pop_glue_frame(bt);
+		break;
+
+	case KERNEL_FRAME_RESTORE_SOME: result = pop_restore_some_frame(bt);
+		break;
+
+	case KERNEL_FRAME_UNEXPECTED: result = KERNEL_BACKTRACE_DONE;
+		break;
+
+	default: result = -EINVAL;	/* Internal failure: Shouldn't happen */
+		bt_dbg(1, "Unexpected frame type: %d\n", bt->type);
+		break;
+	}
+
+	return result;
+}
+
+/*
+ * Function that determines whether we are in some section of the exception
+ * vector. If no exception vector has been set up, which we determine
+ * by seeing whether ebase has yet been set, we can't be in the exception
+ * vector code.
+ * Params:	pc	Current program counter
+ *		start	Offset of the start of the section from ebase
+ *		size	Size of the section.
+ * Returns:	Non-zero if we are in the given section, zero otherwise.
+ */
+static int in_exception_vector(reg_t pc, unsigned start, unsigned size)
+{
+	int			result;
+
+	if (ebase == 0)
+		result = 0;
+
+	else {
+		reg_t	offset;
+
+		offset = pc - ebase;
+		result = (offset >= start && offset < size);
+	}
+
+	return result;
+}
+
+/*
+ * This looks for the given pc value in the list of pieces of code that 
must
+ * be handled specially for backtrace purposes. If found, it will store the
+ * symbol start and size.
+ * Params:	pc	Value of pc to look for
+ *		start	Address of the start of the code section.
+ *		size	Number of bytes in the code section.
+ * Returns:	A pointer to the entry in the table of special symbols
+ *		corresponding to pc if it could be found, NULL if not.
+ */
+static const struct kern_special_sym *special_symbol(reg_t pc, reg_t 
*start,
+	reg_t *size)
+{
+	const struct kern_special_sym	*result;
+	unsigned long		symbolsize;
+	unsigned long		offset;
+
+	/* We could look up each symbol and then see whether it contained the
+	 * pc, but a faster way is to look up the symbol corresponding to the
+	 * pc, then just quickly go through the table looking for it. This
+	 * could be even faster if the table were sorted by address because
+	 * we would be able to do a binary search of the table, but this is
+	 * simpler and only rarely done. */
+
+	/* Find the symbol corresponding to the pc */
+	if (!kallsyms_lookup_size_offset((unsigned long) pc, &symbolsize,
+		&offset))
+		result = NULL;
+
+	else {
+		size_t		i;
+		opcode_t	*symbol_start;
+
+		/* Search for the address within our table of special symbols.
+		 * We do a simple linear search, now, but if the table were
+		 * sorted we could use a faster binary search. Ah, someday when
+		 * we have time... */
+		symbol_start = (opcode_t *) (pc - offset);
+
+		for (i = 0;
+			i < kernel_backtrace_symbols_size &&
+				symbol_start !=
+					kernel_backtrace_symbols [i].start;
+			i ++)
+			;
+
+		if (i == kernel_backtrace_symbols_size)
+			result = NULL;
+
+		else {
+			result = &kernel_backtrace_symbols [i];
+			*start = (reg_t) symbol_start;
+			*size = symbolsize;
+		}
+	}
+
+	return result;
+}
+
+/*
+ * Loads the next register values for code that uses the $k0 and $k1
+ * registers only. In this case, the $pc value is in the CP0 EPC register
+ * and all other registers still have their original values.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_k0_k1_only_frame(struct kernel_bt *bt)
+{
+	int	result = 0;		/* Assume success */
+
+	bt->tbt.sbt.pc = bt->cp0_epc;
+	result = pop_exception(bt);
+
+	return result;
+}
+
+/*
+ * Loads the next register values for code that uses the SAVE_SOME macro.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_save_some_frame(struct kernel_bt *bt)
+{
+	return pop_save_some_or_all_frame(bt);
+}
+
+/*
+ * Loads the next register values for code that uses the SAVE_ALL 
macro. The
+ * SAVE_ALL macro starts by using the SAVE_SOME macro, then saves 
additional
+ * registers. We could simply have used pop_save_some_or_all_frame 
directly,
+ * but this extra, tiny, function allows a more directly mapping from what
+ * appears in the kernel code to the way we break things down here.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_save_all_frame(struct kernel_bt *bt)
+{
+	return pop_save_some_or_all_frame(bt);
+}
+
+/*
+ * This handles a code section that starts with use of a SAVE_SOME 
macro and
+ * which *may* then save additional registers using macros like 
SAVE_STATIC,
+ * etc.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_save_some_or_all_frame(struct kernel_bt *bt)
+{
+	int		result = 0;	/* Assume success */
+	enum		{OLD_SP_IN_SP, OLD_SP_IN_K0, OLD_SP_ON_STACK} sp_loc;
+	reg_t		ip;
+	opcode_t	op;
+
+	/* First, loop until the old stack pointer gets stored on the
+	 * stack. No other registers get stored in the struct pt_regs
+	 * object on the stack until after the stack pointer gets
+	 * stored. */
+
+	for (ip = bt->start, sp_loc = OLD_SP_IN_SP; ;
+		ip = ip_next(ip)) {
+		/* If we reach the current execution point or we have stored
+		 * the old SP on the stack, we are done. */
+		if (ip == bt->tbt.sbt.pc ||
+			sp_loc == OLD_SP_ON_STACK)
+			break;
+		result = get_op(ip, &op);
+		if (result != 0)
+			break;
+
+		if (is_move(op, REG_K0, REG_SP))
+			sp_loc = OLD_SP_IN_K0;
+
+		else if (sp_loc == OLD_SP_IN_K0 &&
+			is_sw(op, REG_K0, REG_SP))
+			sp_loc = OLD_SP_ON_STACK;
+	}
+
+	switch (sp_loc) {
+	case OLD_SP_IN_SP:		/* Nothing to do */
+		break;
+	case OLD_SP_IN_K0: bt->tbt.sbt.gprs [REG_SP] =
+			bt->tbt.sbt.gprs [REG_K0];
+		bt->tbt.sbt.gpr_saved [REG_SP] = 1;
+		break;
+	case OLD_SP_ON_STACK: result = update_saved_registers(bt, ip,
+			bt->tbt.sbt.gprs [REG_SP]);
+		break;
+	default: result = -EINVAL;	/* Internal failure: shouldn't happen */
+		bt_dbg(1, "Unexpected sp_loc value: %d\n", sp_loc);
+		break;
+	}
+
+	if (result == 0)
+		result = pop_exception(bt);
+
+	return result;
+}
+
+/*
+ * Loads the next register values for code that uses the SAVE_STATIC macro.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_save_static_frame(struct kernel_bt *bt)
+{
+	int	result;
+	reg_t	pt_regs_ptr;
+
+	pt_regs_ptr = bt->tbt.sbt.gprs [REG_SP];
+
+	/* We must have already completed a SAVE_SOME macro in some previous
+	 * section of code, which has saved general purpose registers zero,
+	 * v0-v1, a0-a3, t9, gp, sp, and ra(r0, r2-r7, r25, r28, r29, r31),
+	 * and CP0 registers Cause, EPC, and Status. We can read these values
+	 * from their place on the stack. */
+	update_saved_register(bt, pt_regs_ptr, PT_R0);		/* zero */
+	update_saved_register(bt, pt_regs_ptr, PT_R2);		/* v0 */
+	update_saved_register(bt, pt_regs_ptr, PT_R3);		/* v1 */
+	update_saved_register(bt, pt_regs_ptr, PT_R4);		/* a0 */
+	update_saved_register(bt, pt_regs_ptr, PT_R5);		/* a1 */
+	update_saved_register(bt, pt_regs_ptr, PT_R6);		/* a2 */
+	update_saved_register(bt, pt_regs_ptr, PT_R7);		/* a3 */
+	update_saved_register(bt, pt_regs_ptr, PT_R25);		/* a4 */
+	update_saved_register(bt, pt_regs_ptr, PT_R28);		/* gp */
+	update_saved_register(bt, pt_regs_ptr, PT_R29);		/* sp */
+	update_saved_register(bt, pt_regs_ptr, PT_R31);		/* ra */
+	update_saved_register(bt, pt_regs_ptr, PT_EPC);		/* CP0 EPC */
+	update_saved_register(bt, pt_regs_ptr, PT_STATUS);	/* CP0 Status */
+	update_saved_register(bt, pt_regs_ptr, PT_CAUSE);	/* CP0 Cause */
+
+	/* Now read the registers which have been saved so far in this
+	 * section of code */
+	result = update_saved_registers(bt, bt->start, pt_regs_ptr);
+
+	if (result == 0)
+		result = pop_exception(bt);
+
+	return result;
+}
+
+/*
+ * At this point the SAVE_SOME or SAVE_STATIC macro has started to save
+ * register values into a struct pt_regs object. We run through the current
+ * code looking for stores relative to the $sp register and restore values
+ * from there.
+ * Params:	bt	Pointer to the struct kernel_bt object
+ *		ip	Pointer to the first instruction to examine to see if
+ *			it is a store.
+ *		ptr	Pointer to the struct pt_regs object in which values
+ *			are stored.
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static int update_saved_registers(struct kernel_bt *bt, reg_t ip,
+	reg_t ptr)
+{
+	int		result = 0;	/* Assume success */
+	opcode_t	op;
+
+
+	for (;
+		ip != bt->tbt.sbt.pc &&
+		(result = get_op(ip, &op)) == 0 &&
+			!is_basic_block_end(op);
+		ip = ip_next(ip)) {
+
+		/* If this is a save, we use the offset to determine which
+		 * register is being saved. Since all we want to do is to
+		 * restore the register value, the offset is all we need to
+		 * determine which register is to be restored. */
+		if (is_frame_save(op, REG_SP))
+			result = update_saved_register(bt, ptr,
+				frame_save_offset(op));
+	}
+
+	return result;
+}
+
+/*
+ * Gets a given general purpose register from the given memory location.
+ * Params:	bt	Pointer to the struct kernel_bt object in which
+ *			to store the value.
+ *		reg_num	The particular register to store.
+ *		ptr	Location of the value
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static inline int get_pt_gpr(struct kernel_bt *bt, enum reg_num reg_num,
+	reg_t ptr)
+{
+	return get_reg(ptr, &bt->tbt.sbt.gprs [reg_num]);
+}
+
+/*
+ * The current instruction is a save through the frame pointer. Retrieve
+ * the value that was saved. The offset tells us which register to 
retrieve,
+ * as well as being the offset in the struct pt_regs from which to 
retrieve it.
+ * Params:	bt	Pointer to the struct kernel_bt object
+ *		ptr	Pointer to the memory location where the struct
+ *			pt_regs object is stored.
+ *		offset	Offset from the pointer to the value for the
+ *			register we want to read
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static int update_saved_register(struct kernel_bt *bt, reg_t ptr,
+	reg_offset_t offset)
+{
+	int	result = 0;		/* Assume success */
+	reg_t	cp0_status;
+	reg_t	where;
+
+	where = ptr + offset;
+
+	/* The comment by each line indicates whether the register is saved
+	 * by the SAVE_SOME or SAVE_STATIC macro */
+	switch (offset) {
+	case PT_R0: result = get_pt_gpr(bt, REG_ZERO, where); /* SAVE_SOME*/
+		break;
+	case PT_R2: result = get_pt_gpr(bt, REG_V0, where);	/* SAVE_SOME*/
+		break;
+	case PT_R3: result = get_pt_gpr(bt, REG_V1, where);	/* SAVE_SOME*/
+		break;
+	case PT_R4: result = get_pt_gpr(bt, REG_A0, where);	/* SAVE_SOME*/
+		break;
+	case PT_R5: result = get_pt_gpr(bt, REG_A1, where);	/* SAVE_SOME*/
+		break;
+	case PT_R6: result = get_pt_gpr(bt, REG_A2, where);	/* SAVE_SOME*/
+		break;
+	case PT_R7: result = get_pt_gpr(bt, REG_A3, where);	/* SAVE_SOME*/
+		break;
+	case PT_R16: result = get_pt_gpr(bt, REG_S0, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R17: result = get_pt_gpr(bt, REG_S1, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R18: result = get_pt_gpr(bt, REG_S2, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R19: result = get_pt_gpr(bt, REG_S3, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R20: result = get_pt_gpr(bt, REG_S4, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R21: result = get_pt_gpr(bt, REG_S5, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R22: result = get_pt_gpr(bt, REG_S6, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R23: result = get_pt_gpr(bt, REG_S7, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R25: result = get_pt_gpr(bt, REG_T9, where);	/* SAVE_SOME */
+		break;
+	case PT_R28: result = get_pt_gpr(bt, REG_GP, where);	/* SAVE_SOME */
+		break;
+	case PT_R29: result = get_pt_gpr(bt, REG_SP, where);	/* SAVE_SOME */
+		break;
+	case PT_R30: result = get_pt_gpr(bt, REG_S8, where);	/* SAVE_STATIC*/
+		break;
+	case PT_R31: result = get_pt_gpr(bt, REG_RA, where);	/* SAVE_SOME */
+		break;
+	case PT_EPC: result = get_reg(where, &bt->cp0_epc);	/* SAVE_SOME */
+		break;
+	case PT_STATUS: result = get_reg(where, &cp0_status);	/* SAVE_SOME */
+		if (result == 0)
+			bt->cp0_status = cp0_status;
+		break;
+	}
+
+	return result;
+}
+/*
+ * Loads the next register values for glue code that is used after 
SAVE_SOME
+ * and SAVE_STATIC have been called and before RESTORE_SOME is called. This
+ * means that the values for the previous frame are all in a struct pt_regs
+ * object pointed to by $sp.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_glue_frame(struct kernel_bt *bt)
+{
+	int		result;
+
+	result = read_pt_regs(bt);
+
+	if (result == 0)
+		result = pop_exception(bt);
+
+	return result;
+}
+
+/*
+ * Loads the next register values for code that uses the RESTORE_SOME 
macro.
+ * Until we reach the eret instruction, the $sp register points to a struct
+ * pt_regs object from which the values can be fetched. When we get to the
+ * eret, all registers except $pc have been loaded and we get the next $pc
+ * value from the CP0_EPC register.
+ * Params:	bt	Pointer to the current struct kernel_bt object.
+ * Returns:	KERNEL_BACKTRACE_DONE	The backtrace should stop because the
+ *					next frame is from user mode.
+ *		Zero			This is a good frame.
+ *		A negative errno value	The backtrace should stop because an
+ *					error has occurred.
+ */
+static int pop_restore_some_frame(struct kernel_bt *bt)
+{
+	int		result;
+	opcode_t	op;
+
+	/* Check to see whether we got to the eret instruction. If
+	 * not, use the stack pointer to get to the save values.
+	 * Otherwise, use the ones we have. */
+	result = get_op(bt->start, &op);
+
+	if (result == 0) {
+		if (!is_eret(op))
+			result = read_pt_regs(bt);
+	}
+
+	if (result == 0)
+		result = pop_exception(bt);
+
+	return result;
+}
+
+/* This is called when all of the registers, except for the $pc register,
+ * have been restored to their state prior to the exception. The 
pre-exception
+ * value of the $pc register is stored in the CP0 EPC register. This 
function
+ * checks the CP0 Status register's CU0 bit to find out whether we were
+ * executing kernel or user mode code before the exception. CU0 is set 
if we
+ * were previously executing in user mode, clear if in user mode. If we 
were
+ * executing user code, we are done. Otherwise, we need to restore the $pc
+ * value from the CP0 EPC register, and keep backtracing.
+ * Params:	bt	Pointer to struct kernel_bt object
+ * Return:	KERNEL_BACKTRACE_DONE if we would have returned to user mode,
+ *		otherwise zero.
+ */
+static int pop_exception(struct kernel_bt *bt)
+{
+	int	result;
+
+	if ((bt->cp0_status & ST0_CU0) == 0)
+		result = KERNEL_BACKTRACE_DONE;
+
+	else {
+		/* The next address executed would be that stored in
+		 * the CP0 EPC register. All other registers are
+		 * restored */
+		bt->tbt.sbt.pc = bt->cp0_epc;
+		result = 0;
+	}
+
+	return result;
+}
+
+/*
+ * Read new values of the register from the struct pt_regs object to 
which the
+ * current stack pointer points.
+ * Params:	bt	Points to the struct kernel_bt object to update.
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static int read_pt_regs(struct kernel_bt *bt)
+{
+	int		result;
+	reg_t		pt_regs;
+	enum reg_num	i;
+	reg_t		cp0_status;
+
+	pt_regs = bt->tbt.sbt.gprs [REG_SP];
+
+	result = get_reg(pt_regs + offsetof(struct pt_regs, cp0_status),
+			&cp0_status);
+	if (result == 0) {
+		bt->cp0_status = cp0_status;
+		result = get_reg(pt_regs + offsetof(struct pt_regs, cp0_epc),
+				&bt->cp0_epc);
+	}
+
+	for (i = REG_AT; result == 0 && i < REG_ALL; i ++) {
+		result = get_reg(pt_regs + offsetof(struct pt_regs,
+			regs [i]), &bt->tbt.sbt.gprs [i]);
+		if (result == 0)
+			bt->tbt.sbt.gpr_saved [i] = 1;
+	}
+
+	return result;
+}
+
+/*
+ * Functions that are required by the simple-backtrace.c code but which 
must
+ * be supplied by users of that code.
+ * ip_lookup - Look up the symbol start and size, given an address
+ * get_op - Get an opcode-sized element.
+ * get-reg - Get a register-sized element.
+ */
+
+/*
+ * Use kallsyms_lookup to find the symbol corresponding to a given address.
+ * All we care about for backtracing is where the section of code starts
+ * and the number of bytes in it.
+ * Params:	ip	Address for which to find the symbol
+ *		start	Pointer to location in which to store the starting
+ *			address for the symbol.
+ *		size	Pointer to location in which to store the size of the
+ *			symbol.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int symbol_lookup(reg_t ip, reg_t *start, reg_t *size)
+{
+	int		result;
+	const char	*symname;
+	unsigned long	symbolsize;
+	unsigned long	offset;
+	char		*modname;
+	char		namebuf [KSYM_NAME_LEN + 1];
+
+	symname = kallsyms_lookup((unsigned long) ip, &symbolsize,
+		&offset, &modname, namebuf);
+
+	/* Perhaps, if we couldn't find the symbol, it is a two-instruction
+	 * signal trampoline. It won't hurt to pretend because everything
+	 * validates that the address from which it fetches instructions. */
+	if (symname == NULL) {
+		result = 0;
+		*start = ip;
+		*size = 2 * OPCODE_SIZE;
+	}
+
+	else {
+		result = 0;
+		*start = ip - offset;
+		*size = symbolsize;
+	}
+
+	return result;
+}
+
+/*
+ * Read an opcode-sized piece of data.
+ * Params:	ip	Address from which to read the opcode
+ *		op	Location in which to store the opcode once it has
+ *			been read.
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static int get_op(reg_t ip, opcode_t *op)
+{
+	int		result;
+
+	result = __get_user(*op, (opcode_t *) ip);
+
+	return result;
+}
+
+/*
+ * Read an general purpose register-sized piece of data.
+ * Params:	rp	Address from which to read the data
+ *		reg	Location in which to store the value once it has
+ *			been read.
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static int get_reg(reg_t rp, reg_t *reg)
+{
+	int		result;
+
+	result = __get_user(*reg, (reg_t *) rp);
+
+	return result;
+}
+
+/*
+ * Read an piece of data as big as is used in the struct sigcontext 
registers.
+ * Params:	rp	Address from which to read the data
+ *		reg	Location in which to store the value once it has
+ *			been read.
+ * Returns:	Zero on success, a negative errno value otherwise.
+ */
+static int get_sc_reg(reg_t rp, reg_t *reg)
+{
+	int			result;
+	unsigned long long	sc_reg;
+
+	result = __get_user(sc_reg, (unsigned long long *) rp);
+
+	if (result == 0)
+		*reg = sc_reg;
+
+	return result;
+}
diff -urN 
linux-2.6.25.1/arch/mips/kernel/backtrace/kernel-backtrace-symbols.c 
linux-t/arch/mips/kernel/backtrace/kernel-backtrace-symbols.c
--- 
linux-2.6.25.1/arch/mips/kernel/backtrace/kernel-backtrace-symbols.c 
1969-12-31 16:00:00.000000000 -0800
+++ linux-t/arch/mips/kernel/backtrace/kernel-backtrace-symbols.c 
2008-05-06 17:30:09.000000000 -0700
@@ -0,0 +1,44 @@
+/*
+ *			kernel-backtrace-symbols.c
+ *
+ * Array with backtrace symbols for the kernel;
+ *
+ * Copyright (C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#ifndef	numberof
+#define	numberof(a)	(sizeof (a) / sizeof ((a) [0]))
+#endif
+
+/* Generate external references for the symbols that correspond to pieces
+ * of code that should be handled specially in order to do a proper kernel
+ * backtrace. */
+#define	SPECIAL_SYMBOL(name, type) extern opcode_t	name [];
+#include <asm/kernel-backtrace-symbols.h>
+#undef SPECIAL_SYMBOL
+
+/* Now generate the table for the symbols that we handle specially */
+#define	SPECIAL_SYMBOL(name, type) 	{name, type},
+
+const struct kern_special_sym kernel_backtrace_symbols [] = {
+#include <asm/kernel-backtrace-symbols.h>
+};
+#undef SPECIAL_SYMBOL
+
+unsigned kernel_backtrace_symbols_size = 
numberof(kernel_backtrace_symbols);
diff -urN linux-2.6.25.1/arch/mips/kernel/backtrace/Makefile 
linux-t/arch/mips/kernel/backtrace/Makefile
--- linux-2.6.25.1/arch/mips/kernel/backtrace/Makefile	1969-12-31 
16:00:00.000000000 -0800
+++ linux-t/arch/mips/kernel/backtrace/Makefile	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,4 @@
+# Makefile for Linux/MIPS advanced backtrace code
+
+obj-y	+= kernel-backtrace.o kernel-backtrace-symbols.o \
+	   simple-backtrace.o thread-backtrace.o
diff -urN linux-2.6.25.1/arch/mips/kernel/backtrace/simple-backtrace.c 
linux-t/arch/mips/kernel/backtrace/simple-backtrace.c
--- linux-2.6.25.1/arch/mips/kernel/backtrace/simple-backtrace.c 
1969-12-31 16:00:00.000000000 -0800
+++ linux-t/arch/mips/kernel/backtrace/simple-backtrace.c	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,1236 @@
+/*
+ *				simple-backtrace.c
+ *
+ * Implement an analysis and backtrace of stackframes. It only supports
+ * processing a single frame as multiple frame backtracing requires 
operating
+ * system-depending things like signal frames and/or exception handling.
+ * It knows how to handle "o32" ABI-conformant backtraces and backtraces
+ * where a function start and size may be determined.
+ *
+ * Though this has been designed with some thought towards working in a 
64-bit
+ * environment, only the 32-bit implementation is complete.
+ *
+ * Since this completely implements the ABI rules for processing a stack
+ * backtrace, without any OS dependencies, keeping this file a separate 
entity
+ * will allow reuse in other situations.
+ *
+ * Copyright(C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#include <asm/simple-backtrace.h>
+
+#ifndef	numberof
+#define	numberof(a)	(sizeof(a) / sizeof((a) [0]))
+#endif
+
+/* Pointers to functions to analyze the current function. This depends on
+ * the value of the struct simple_btype_t passed to the stack frame
+ * analysis functions */
+struct bt_ops {
+	int(*start_frame) (struct simple_bt *bt, reg_t ip);
+	int(*find_return) (struct simple_bt *bt);
+};
+
+static int read_reg_if_saved(struct simple_bt *bt, opcode_t op, reg_t fp);
+static int read_saved_reg(struct simple_bt *bt, opcode_t op, reg_t fp);
+static int read_saved_registers(struct simple_bt *bt, reg_t fp);
+static int start_frame(struct simple_bt *bt);
+static int find_sf_allocation(struct simple_bt *bt);
+static int analyze_procedure_prelude(struct simple_bt *bt);
+static void analyze_procedure_prelude_op(struct simple_bt *bt, opcode_t 
op);
+static int analyze_return_block(struct simple_bt *bt);
+static void analyze_return_block_op(struct simple_bt *bt, reg_t ip,
+	opcode_t op);
+static void complete_analysis(struct simple_bt *bt);
+
+static int start_frame_abi(struct simple_bt *bt, reg_t ip);
+static int back_up_from_sp_decrement(struct simple_bt *bt, reg_t ip);
+static int find_return_abi(struct simple_bt *bt);
+
+static int start_frame_lookup(struct simple_bt *bt, reg_t ip);
+static int find_return_lookup(struct simple_bt *bt);
+static int find_return_lookup_bounded(struct simple_bt *bt, reg_t start,
+	reg_t end);
+
+/* Array, indexed by a struct simple_btype_t value, that holds the
+ * function analysis function pointers. */
+static struct bt_ops ops [] = {
+	{start_frame_abi, find_return_abi},
+	{start_frame_lookup, find_return_lookup},
+};
+
+#if	BACKTRACE_DEBUG
+static const char *backtrace_type [] = {
+	"o32 ABI", "lookup"
+};
+#endif
+
+/*
+ * Look for a return from the current function. The search starts with the
+ * current location so that, later on, we can determine whether we are
+ * executing in a basic block that ends with a return. If there isn't
+ * a return in the current function that follows the current location, the
+ * search should look for a return before the current location.
+ *
+ * If successful, bt->fn_return will be set to the address of the
+ * "jr ra" instruction used to do the return.
+ * Params:	bt	Pointer to a struct simple_bt object.
+ * Returns: Zero on success, otherwise a negative errno value.
+ */
+static inline int find_return(struct simple_bt *bt)
+{
+	return ops [bt->config->type].find_return(bt);
+}
+
+/*
+ * Get an opcode_t-sized object from memory.
+ * Params:	bt	Pointer to the struct simple_bt object
+ *		ip	Address of the opcode.
+ *		op	Location in which to store the opcode
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static inline int get_op(struct simple_bt *bt, reg_t ip, opcode_t *op)
+{
+	return bt->config->get_op(ip, op);
+}
+
+/*
+ * Get a register-sized(reg_t-sized) object from memory.
+ * Params:	bt	Pointer to the struct simple_bt object
+ *		rp		Address of the value.
+ *		reg		Location in which to store the value.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static inline int get_reg(struct simple_bt *bt, reg_t rp, reg_t *reg)
+{
+	return bt->config->get_reg(rp, reg);
+}
+
+/*
+ * Lookup a symbol's starting address and the size of the object, given an
+ * address within the symbol.
+ * Params:	bt	Pointer to the struct simple_bt object
+ *		addr		Address to look up
+ *		symbolstart	Starting address of the symbol
+ *		symbolsize	Number of bytes in the memory represented by
+ *				the symbol.
+ * Returns:	Zero on success, otherwise a negative errno value. If the 
symbol
+ *		couldn't be found, the value returned should be -ESRCH.
+ */
+static inline int symbol_lookup(struct simple_bt *bt, reg_t addr,
+	reg_t *symbolstart, reg_t *symbolsize)
+{
+	return bt->config->symbol_lookup(addr, symbolstart, symbolsize);
+}
+
+/*
+ * Functions that determine whether the opcode falls into a class of
+ * instructions.
+ */
+/* Is this a move to a register from the stack pointer? This could be
+ * initializing a frame pointer. */
+static inline int is_move_to_framepointer(opcode_t inst)
+{
+	struct r_format	*op_p = (struct r_format *) &inst;
+	return is_addu_noreg(inst) &&
+		op_p->rs == REG_SP && op_p->rt == REG_ZERO;
+}
+
+/* Is this a move from a register to the stack pointer? If so, it's a 
restore
+ * of the stack pointer from a frame pointer. */
+static inline int is_move_from_framepointer(opcode_t inst)
+{
+	struct r_format	*op_p = (struct r_format *) &inst;
+	return is_addu_noreg(inst) &&
+		op_p->rt == REG_ZERO && op_p->rd == REG_SP;
+}
+
+/* Is this a decrement of the stack pointer register? */
+static inline int is_sp_decrement(opcode_t op)
+{
+	struct i_format *op_p = (struct i_format *) &op;
+	return is_addiu(op, REG_SP, REG_SP) &&
+		op_p->simmediate < 0;
+}
+
+/* Is this an increment of the stack pointer register? */
+static inline int is_sp_increment(opcode_t op)
+{
+	struct i_format *op_p = (struct i_format *) &op;
+	return is_addiu(op, REG_SP, REG_SP) &&
+		op_p->simmediate > 0;
+}
+
+/* Is this a jump through the return register $ra? */
+static inline int is_return(opcode_t op)
+{
+	return is_jr(op, REG_RA);
+}
+
+/* Is this a branch or jump instruction? This would mark the end of a basic
+ * block. Note that no coprocessor branch instructions are decoded. */
+int is_basic_block_end(opcode_t op)
+{
+	int			result;
+	struct any_format	*op_p = (struct any_format *) &op;
+	struct r_format		*op_p_r;
+	struct i_format		*op_p_i;
+	struct eret_format	*op_p_eret;
+
+	switch (op_p->opcode) {
+	case j_op:
+	case beq_op:
+	case bne_op:
+	case blez_op:
+	case bgtz_op:
+	case beql_op:
+	case bnel_op:
+	case blezl_op:
+	case bgtzl_op:
+		result = 1;
+		break;
+
+	case spec_op:
+		op_p_r = (struct r_format *) &op;
+		result = (op_p_r->func == jr_op &&
+			op_p_r->rt == 0 && op_p_r->rd == 0);
+		break;
+
+	case bcond_op:
+		op_p_i = (struct i_format *) &op;
+		switch (op_p_i->rt) {
+		case bltz_op:
+		case bgez_op:
+		case bltzl_op:
+		case bgezl_op:
+			result = 1;
+			break;
+
+		default:
+			result = 0;
+			break;
+		}
+		break;
+
+	case cop0_op:
+		op_p_eret = (struct eret_format *) &op;
+		result = (op_p_eret->func == eret_op &&
+			op_p_eret->co == 1 && op_p_eret->zero == 0);
+		break;
+
+
+	default: result = 0;
+		break;
+	}
+
+	return result;
+}
+
+/*
+ * Given an instruction that ends a basic block, as determined by the
+ * is_basic_block_end function, indicates whether the instruction has a
+ * branch delay slot or not.
+ * Params:	op	Instruction that ended the basic block
+ * Returns:	Non-zero if the instruction has a branch delay slot and
+ *		zero if it does.
+ */
+int basic_block_end_uses_BDS(opcode_t op)
+{
+	return !is_eret(op);
+}
+
+/*
+ * Initialize the given struct simple_bt object for going down the
+ * stack frames.
+ * Params:	bt	Pointer to the struct simple_bt object to initialize
+ *		config	Pointer to the configuration to use for the backtrace
+ */
+void simple_backtrace_init(struct simple_bt *bt,
+	const struct simple_bt_config *config)
+{
+	simple_backtrace_clear_saved(bt);
+	bt->config = config;
+}
+EXPORT_SYMBOL(simple_backtrace_init);
+
+/*
+ * Clear the saved bits for all general purpose registers.
+ * Params:	bt	Pointer to the struct simple_bt object.
+ */
+void simple_backtrace_clear_saved(struct simple_bt *bt)
+{
+	enum reg_num	i;
+
+	for (i = 0; i < numberof(bt->gpr_saved); i ++)
+		bt->gpr_saved [i] = 0;
+}
+EXPORT_SYMBOL(simple_backtrace_clear_saved);
+
+/*
+ * Process the first stack frame. The register values must be set by this
+ * call.
+ * Params:	bt	Pointer to struct simple_bt object.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ *		A value of -ENOSYS indicates that the $pc and $sp are valid
+ *		but we can't continue the backtrace.
+ */
+int simple_backtrace_first(struct simple_bt *bt)
+{
+	int	result;
+
+	result = simple_backtrace_analyze_frame(bt);
+
+	return result;
+}
+EXPORT_SYMBOL(simple_backtrace_first);
+
+/*
+ * Process one stack frame. The given register values will be updated
+ * based on the processing of the stack frame.
+ * Params:	bt	Pointer to copies of the register values that
+ *			apply for this frame.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ *		A value of -ENOSYS indicates that the $pc and $sp are valid
+ *		but we can't continue the backtrace.
+ */
+
+int simple_backtrace_next(struct simple_bt *bt)
+{
+	int	result;
+
+	result = simple_backtrace_pop_frame(bt);
+
+	if (result == 0)
+		result = simple_backtrace_analyze_frame(bt);
+
+	return result;
+}
+EXPORT_SYMBOL(simple_backtrace_next);
+
+/*
+ * Gather information about the current stack frame.
+ * Params:	bt	Pointer to the struct simple_bt object.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+int simple_backtrace_analyze_frame(struct simple_bt *bt)
+{
+	int	result = 0;	/* Assume good backtrace */
+
+	bt_dbg(1, "type \"%s\" $pc 0x%lx $sp 0x%lx\n",
+		backtrace_type [bt->config->type], bt->pc,
+		bt->gprs [REG_SP]);
+	/* Initialize for the analysis of the current stack frame */
+	start_frame(bt);
+	simple_backtrace_clear_saved(bt);
+	bt->framepointer = REG_SP; /* Default frame pointer is $sp */
+
+	/* Find the place where we allocate the stack fame, if any */
+	result = find_sf_allocation(bt);
+
+	/* If we have not allocated a stack frame, the current stack pointer
+	 * is for the caller's stack frame and the return address is still
+	 * in $ra. In that case, we are done with the analysis. Otherwise,
+	 * let's see whether we are using a stack frame pointer */
+	if (result == 0 && bt->frame_size != 0) {
+		result = find_return(bt);
+
+		switch (result) {
+		case 0: result = analyze_return_block(bt);
+			if (result == 0) {
+				result = analyze_procedure_prelude(bt);
+				if (result == 0)
+					complete_analysis(bt);
+			}
+			break;
+
+		case -ENOSYS: bt_dbg(1,
+				"No return found, applying heuristic\n");
+			bt->possible_framepointer = REG_S8;
+			result = analyze_procedure_prelude(bt);
+			break;
+
+		default:			/* Leave the result unchanged */
+			break;
+		}
+	}
+
+	return result;
+}
+EXPORT_SYMBOL(simple_backtrace_analyze_frame);
+
+/*
+ * Locates the first instruction in the current function. We start by
+ * finding the function containing the instruction to which $pc points. 
Recall
+ * that $pc is actually the return address from a call. It will normally
+ * point to the same function that contains the call, except in the case
+ * where the call is the last thing in the current function. In that 
special
+ * case, $pc will actually point to the first instruction in the function
+ * after the current function. This arises when the last thing the current
+ * function did was to call a function defined with __attribute__ 
((noreturn)).
+ *
+ * To detect this special case, note that there are two ways that we can
+ * be doing a stack backtrace with $pc pointing to the first instruction of
+ * a function:
+ * 1.	We got a signal, exception, or interrupt just before executing the
+ *	first instruction of a function.
+ * 2.	We called a function, with a jal or jalr instruction, that, with the
+ *	instruction in its branch delay slot, immediately preceeds the
+ *	function.
+ * In the first case, we called the function from somewhere else and the
+ * value in the the ra register will be something other than the value of
+ * the $pc register. In the second case, however, the ra and $pc register
+ * values will be the same. In that case, the current function is the
+ * function in which the jal or jalr instruction is located, which is two
+ * instructions before the current value of the $pc register.
+ * Params:	bt	Points to the struct simple_bt object. The start
+ *			field will be set to the result.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int start_frame(struct simple_bt *bt)
+{
+	int	result;
+
+	result = ops [bt->config->type].start_frame(bt, bt->pc);
+
+	if (result == 0) {
+		bt_dbg(2, "Comparing $pc 0x%lx with function start 0x%lx and "
+			"ra 0x%lx\n", bt->pc, bt->func_start,
+			bt->gprs [REG_RA]);
+		if (bt->pc == bt->func_start &&
+			bt->pc == bt->gprs [REG_RA]) {
+			bt_dbg(2, "Detected call in previous function with "
+				"pc 0x%lx\n", bt->pc);
+			result = ops [bt->config->type].start_frame(bt,
+				ip_add(bt->pc, -2 * OPCODE_SIZE));
+		}
+	}
+
+	bt_dbg(1, "Function start detected at 0x%lx\n", bt->func_start);
+
+	return result;
+}
+
+/*
+ * Sets the state to indicate that no stack frame has been allocated.
+ * Params:	bt	Points to the struct simple_bt object to set
+ */
+static inline void set_no_sf_allocation(struct simple_bt *bt)
+{
+	bt->sf_allocation = NULL_REG;
+	bt->frame_size = 0;
+}
+
+/*
+ * Sets the state that records where the stack frame is allocated and
+ * the frame size.
+ * Params:	bt	Points to the struct simple_bt object to set
+ *		ip	Location where the stack frame is allocated
+ *		op	Opcode used to allocate the stack frame, from which
+ *			the size will be taken.
+ */
+static inline void set_sf_allocation(struct simple_bt *bt, reg_t ip,
+	opcode_t op)
+{
+	struct i_format *op_p;
+
+	bt->sf_allocation = ip;
+	op_p = (struct i_format *) &op;
+	bt->frame_size = -op_p->simmediate;
+	bt_dbg(2, "Found frame allocation for %d bytes at 0x%lx\n",
+		bt->frame_size, ip);
+}
+
+
+/*
+ * Finds the location where the stack frame is allocated. If one was found,
+ * the location is stored in sf_allocation, otherwise sf_allocation is set
+ * to NULL_REG.
+ * Params:	bt	Points to the struct simple_bt object. The start
+ *			field will be set to the result.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int find_sf_allocation(struct simple_bt *bt)
+{
+	int		result = 0;
+	reg_t		ip;
+	opcode_t	op;
+
+	/* Scan forwards from the start of the function until one of the
+	 * following:
+	 * 1.	We reach the current execution location, in which case
+	 *	no stack frame has been allocated,
+	 * 2.	We fail to read an opcode, which is an error,
+	 * 3.	We see a stack frame decrement instruction, which is how
+	 *	the stack frame is allocated, or
+	 * 4.	We reach an instruction marking the end of a basic block,
+	 *	in which the function does not allocate a stack frame at all.
+	 */
+	for (ip = bt->func_start; ; ip = ip_next(ip)) {
+		if (ip == bt->pc)
+			break;
+
+		result = get_op(bt, ip, &op);
+
+		if (result != 0 ||
+			is_sp_decrement(op) ||
+			is_basic_block_end(op))
+			break;
+
+		bt_dbg(3, "Looked at 0x%lx, opcode 0x%x\n", ip, op);
+	}
+
+	if (ip == bt->pc)
+		set_no_sf_allocation(bt);
+
+	else if (result == 0) {
+		if (is_sp_decrement(op))
+			set_sf_allocation(bt, ip, op);
+
+		else {
+			/* We exited the loop because we found the end of
+			 * the basic block. If the instruction that marked
+			 * the end of the basic block uses a branch delay
+			 * slot, we need to examine that instruction to see
+			 * if it allocated a stack frame. */
+
+			ip = ip_next(ip);	/* Adv. to branch delay slot */
+			result = get_op(bt, ip, &op);
+
+			if (result == 0) {
+				if (is_sp_decrement(op))
+					set_sf_allocation(bt, ip, op);
+
+				else
+					set_no_sf_allocation(bt);
+			}
+		}
+	}
+
+	return result;
+}
+
+/*
+ * This function analyzes a basic block ending with the function return
+ * at fn_return. We do a backwards scan, starting with the "jr ra" 
instruction
+ * until we reach the end of the previous basic block, or the stack frame
+ * allocation, whichever comes first.
+ * Params:	bt	Pointer to the struct simple_bt object.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int analyze_return_block(struct simple_bt *bt)
+{
+	int		result;
+	reg_t		ip;
+	opcode_t	op;
+
+	bt->possible_framepointer = REG_SP;
+	bt->fp_restore = NULL_REG;
+	bt->sf_deallocation = NULL_REG;
+
+	/* Doing this analysis is a bit complicated because of branch delay
+	 * slots. The first complication is that the first instruction in
+	 * our backwards scan is the one after the "jr ra" instruction. The
+	 * next complication is that the $pc value associated with instruction
+	 * in the branch delay slot is actually that of the "jr ra"
+	 * instruction. Either they are both executed or neither are
+	 * executed. */
+	ip = bt->fn_return;
+	result = get_op(bt, ip_next(ip), &op);
+
+	if (result == 0) {
+		opcode_t	prev_op;
+		reg_t		prev_ip;
+
+		analyze_return_block_op(bt, ip, op);
+
+		/* The next complication in the backwards scan is that we
+		 * don't want to evaluate the instruction after the one that
+		 * marks the end of the previous block if it is in a branch
+		 * delay slot. So, we start by getting an opcode, which we
+		 * refer to as the current op code. Then, until:
+		 * 1.	We have reached the instruction where the stack
+		 *	frame was allocated,
+		 * 2.	We failed to read the next opcode, and
+		 * 3.	The opcode we got marks the end of a basic block,
+		 * we analyze the current opcode. After analyzing the current
+		 * opcode, the next opcode becomes the current opcode and
+		 * we loop again. */
+		result = get_op(bt, bt->fn_return, &op);
+
+		if (result == 0) {
+			for (prev_ip = ip_prev(ip); ; prev_ip = ip_prev(ip)) {
+				if (prev_ip == bt->sf_allocation)
+					break;
+
+				result = get_op(bt, prev_ip, &prev_op);
+
+				if (result != 0 ||
+					is_basic_block_end(prev_op))
+					break;
+
+				analyze_return_block_op(bt, ip, op);
+				ip = prev_ip;
+				op = prev_op;
+			}
+
+			/* If we stopped because prev_op was the instruction
+			 * that marked the end of the previous block, and that
+			 * instruction does not have a branch delay slot, we
+			 * still have to analyze the current instruction */
+			if (prev_ip == bt->sf_allocation ||
+				(result == 0 && is_basic_block_end(prev_op) &&
+					!basic_block_end_uses_BDS(prev_op)))
+				analyze_return_block_op(bt, ip, op);
+		}
+	}
+
+	if (result == 0 && bt->sf_deallocation == NULL_REG) {
+		bt_dbg(1, "Stack frame not deallocated\n");
+		result = -ENOSYS;
+	}
+
+	return result;
+}
+
+/*
+ * This looks at the given opcode, which comes from the given address, 
to see
+ * if it is a move to the stack pointer or a stack pointer increment. 
If so,
+ * it records that information.
+ *
+ * We assume that the basic block that includes the function return 
instruction
+ * can have only one move to the $sp register, but don't check for that
+ * fact. We also don't check that the frame pointer restore preceeds the
+ * stack frame deallocation.
+ *
+ * This may set the following struct simple_bt fields:
+ *	possible_framepointer	Register number used in "move sp, rx"
+ *				instruction.
+ *	fp_restore		Address of the "move sp, rx" instruction
+ *	sf_deallocation		Address of "addiu sp, sp, framesize" instruction
+ *
+ * Params:	bt	Pointer to the struct simple_bt object.
+ *		ip	Address of the instruction being analyzed
+ *		op	Instruction to analyze
+ */
+static void analyze_return_block_op(struct simple_bt *bt, reg_t ip,
+	opcode_t op)
+{
+	bt_dbg(3, "analyze opcode 0x%08x at 0x%lx\n", op, ip);
+
+	if (is_move_from_framepointer(op)) {
+		struct r_format	*op_p = (struct r_format *) &op;
+		bt->possible_framepointer = op_p->rs;
+		bt->fp_restore = ip;
+		bt_dbg(3, "possible frame pointer $r%d at 0x%lx\n",
+			bt->possible_framepointer, ip);
+	}
+
+	else if (is_sp_increment(op)) {
+		bt->sf_deallocation = ip;
+		bt_dbg(2, "frame deallocation at 0x%lx\n", ip);
+	}
+}
+
+/*
+ * This function analyzes the procedure prelude, which is the first basic
+ * in the function, to see if a frame pointer has been established. It 
stops
+ * when it sees a frame pointer established, it reaches the end of the 
basic
+ * block, or when when it reaches $pc. This function assumes that the
+ * framepointer element of the struct simple_bt has already been set to
+ * REG_SP.
+ * Params:	bt	Pointer to the struct simple_bt object.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int analyze_procedure_prelude(struct simple_bt *bt)
+{
+	int		result = 0;	/* Assume good result */
+	reg_t		ip;
+	opcode_t	op;
+
+	/* Starting at the instruction after the allocation of the stack
+	 * frame, look at each opcode to see if a frame pointer has been
+	 * established. Continue looking until:
+	 * 1.	We have reached the instruction about to be executed,
+	 * 2.	We have established a frame pointer,
+	 * 3.	We aren't able to read the next opcode, and
+	 * 4.	The opcode we read marks the end of a basic block. */
+	for (ip = ip_next(bt->sf_allocation); ; ip = ip_next(ip)) {
+		if (ip == bt->pc ||
+			bt->framepointer != REG_SP)
+			break;
+		result = get_op(bt, ip, &op);
+		if (result != 0 ||
+			is_basic_block_end(op))
+			break;
+		bt_dbg(3, "analyze opcode 0x%08x at 0x%lx\n", op, ip);
+		analyze_procedure_prelude_op(bt, op);
+	}
+
+	/* If we did not reach the current executation address, have not
+	 * yet found a frame pointer established, are at the end of the
+	 * basic block and the instruction that ended the basic block has
+	 * a branch delay slot, then we need to look at the instruction in
+	 * the branch delay slot to see whether it establishes a frame
+	 * pointer. */
+	if (ip != bt->pc && bt->framepointer == REG_SP &&
+		is_basic_block_end(op) && basic_block_end_uses_BDS(op)) {
+		ip = ip_next(ip);
+		result = get_op(bt, ip, &op);
+
+		if (result == 0) {
+			bt_dbg(3, "analyze opcode 0x%08x at 0x%lx\n", op, ip);
+			analyze_procedure_prelude_op(bt, op);
+		}
+	}
+
+
+	return result;
+}
+
+/*
+ * This looks at the given opcode, which comes from the given address, 
to see
+ * if it is a move from the stack pointer to another register. If this 
matches
+ * a move from the same register to the stack pointer in the return block,
+ * this must be initialization of a frame pointer.
+ *
+ * This might set the following struct simple_bt fields:
+ *	framepointer	Register being used as a frame pointer.
+ *
+ * Params:	bt	Pointer to struct simple_bt object
+ *		op	Instruction to examine.
+ */
+static void analyze_procedure_prelude_op(struct simple_bt *bt, opcode_t op)
+{
+	if (is_move_to_framepointer(op)) {
+		enum reg_num	rd;
+		struct r_format	*op_p = (struct r_format *) &op;
+		rd = op_p->rd;
+		bt_dbg(3, "Checking $r%d to see if is a frame pointer\n", rd);
+		if (rd == bt->possible_framepointer) {
+			bt_dbg(2, "Confirmed frame pointer $r%d\n", rd);
+			bt->framepointer = rd;
+		}
+	}
+}
+
+/*
+ * This finishes the analysis of this stack frame, based on the analysis
+ * that has already been done. It assumes that:
+ * o	The stack frame size is correct, if one has been allocated, or zero
+ *	if one has not been allocated.
+ * o	A basic block ending with a function return instruction, "jr ra", has
+ *	been found, the stack frame deallocation has been located, and, if
+ *	a stack frame pointer is in use, the location where it is transferred
+ *	to $sp has been found.
+ * Params:	bt	Pointer to the struct simple_bt object used to keep
+ *			track of the analysis.
+ */
+static void complete_analysis(struct simple_bt *bt)
+{
+	if (bt->frame_size != 0) {
+		/* If a stack frame pointer has been allocated, have we
+		 * executed the instruction where it is moved back to $sp
+		 * on the way to executing a return? */
+		if (bt->framepointer != REG_SP &&
+			bt->pc > bt->fp_restore &&
+			bt->pc <= bt->fn_return) {
+			bt_dbg(2, "After stack frame restored to $sp\n");
+			bt->framepointer = REG_SP;
+		}
+
+		/* If we have passed the point where the stack frame is
+		 * deallocated on our way to a return from the function,
+		 * the frame size is now effectively zero. */
+		if (bt->pc > bt->sf_deallocation &&
+			bt->pc <= bt->fn_return) {
+			bt_dbg(2, "After stack frame deallocated\n");
+			bt->frame_size = 0;
+		}
+	}
+}
+
+/*
+ * Updates the $pc and $sp registers, given the current values of the
+ * $ra register and the size of the stack frame.
+ * Params:	bt	Pointer to the struct simple_bt object.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+int simple_backtrace_pop_frame(struct simple_bt *bt)
+{
+	int	result = 0;	/* Assume success */
+	reg_t	new_sp;
+	reg_t	fp;
+
+	bt_dbg(2, "Popping %d-byte frame\n", bt->frame_size);
+	/* Assuming we successfully retrieved the saved register
+	 * values, the new stack pointer value is the frame pointer
+	 * plus the size of the stack frame. */
+	bt_dbg(3, "framepointer in $r%d = 0x%lx\n", bt->framepointer,
+		bt->gprs [bt->framepointer]);
+	fp = bt->gprs [bt->framepointer];
+	new_sp = fp + bt->frame_size;
+
+	/* If we allocated a stack frame, read the saved registers */
+	if (bt->frame_size != 0)
+		result = read_saved_registers(bt, fp);
+
+	if (result == 0) {
+		bt->gprs [REG_SP] = new_sp;
+
+		/* Set the pc to the address of the next instruction to
+		 * execute. Note that this is two instructions beyond the
+		 * 'jalr' instruction used to call the function for this
+		 * frame. */
+		bt->pc = bt->gprs [REG_RA];
+	}
+
+	return result;
+}
+EXPORT_SYMBOL(simple_backtrace_pop_frame);
+
+/*
+ * Update all of the registers saved within the current basic block. We
+ * go from the starting location up to the last instruction executed.
+ * Params:	bt	Pointer to the object in which values will be held.
+ *		fp	Location of the stack frame
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int read_saved_registers(struct simple_bt *bt, reg_t fp)
+{
+	int		result = 0;	/* No errors so far */
+	opcode_t	op;
+	reg_t		ip;
+
+	/* Loop through the code, starting with the first instruction after
+	 * the stack frame allocation, and each time a register is saved
+	 * in the stack frame, read its value into the array with the
+	 * general purpose register values. We keep doing this until:
+	 * 1.	We have reached the instruction we are about to execute,
+	 * 2.	We can't read the next opcode, and
+	 * 3.	The opcode we read marks the end of a basic block. */
+	for (ip = ip_next(bt->sf_allocation); ; ip = ip_next(ip)) {
+		if (result != 0 ||
+			ip == bt->pc)
+			break;
+		result = get_op(bt, ip, &op);
+		if (result != 0 ||
+			is_basic_block_end(op))
+			break;
+		bt_dbg(3, "Check 0x%lx for register save\n", ip);
+		result = read_reg_if_saved(bt, op, fp);
+	}
+
+	/* If we reached the end of the basic block without error, and
+	 * the instruction that marked the end of the basic block uses
+	 * a branch delay slot, check the instruction in the branch delay
+	 * slot. */
+	if (result == 0 &&
+		ip != bt->pc &&
+		basic_block_end_uses_BDS(op)) {
+		ip = ip_next(ip);
+		result = get_op(bt, ip, &op);
+
+		if (result == 0) {
+			bt_dbg(3, "Check 0x%lx for register save\n", ip);
+			result = read_reg_if_saved(bt, op, fp);
+		}
+	}
+
+	return result;
+}
+
+/*
+ * Look at the given op code and, if it is a save of a register through
+ * the frame pointer, get the value. This is only done the first time
+ * the save occurs. Subsequent stores can't be a save of the value with
+ * which we were called.
+ * Params:	bt	Pointer to struct simple_bt object
+ *		op	Opcode to analyze.
+ *		fp	Value of frame pointer to use.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ *
+ */
+static int read_reg_if_saved(struct simple_bt *bt, opcode_t op, reg_t fp)
+{
+	int			result = 0;	/* No errors so far */
+
+	/* If the given instruction is a save through the
+	 * frame pointer, retrieve the value from the stack.
+	 *
+	 * Note: the o32 ABI says that the registers will be
+	 * saved through the frame pointer, but the reality is
+	 * that they are saved through the stack pointer.
+	 * Accomodate both. */
+
+	if (is_frame_save(op, bt->framepointer))
+		result = read_saved_reg(bt, op, fp);
+
+	else if (is_frame_save(op, REG_SP))
+		result = read_saved_reg(bt, op, fp);
+
+	return result;
+}
+
+/*
+ * If the register is a saved register, read the value from the stack 
frame.
+ * Params:	bt	Pointer to struct simple_bt object.
+ *		op	Opcode used to save the register through the given
+ *			frame pointer
+ *		fp	Value of frame pointer
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+static int read_saved_reg(struct simple_bt *bt, opcode_t op, reg_t fp)
+{
+	int			result = 0;		/* Assume success */
+	enum reg_num		rt;
+	reg_offset_t		offset;
+
+	rt = frame_save_rt(op);
+	offset = frame_save_offset(op);
+
+	/* Only worry about the first save. Subsequent saves in this
+	 * function would not be saves of the caller's values for this
+	 * register. */
+	switch (rt) {
+	case REG_S0:
+	case REG_S1:
+	case REG_S2:
+	case REG_S3:
+	case REG_S4:
+	case REG_S5:
+	case REG_S6:
+	case REG_S7:
+	case REG_GP:
+	case REG_S8:
+	case REG_RA: if (!bt->gpr_saved [rt]) {
+			reg_t	rp;
+			rp = fp + offset;
+			result = get_reg(bt, rp, &bt->gprs [rt]);
+			bt_dbg(3, "Read $r%d from 0x%lx+%d(0x%lx)=0x%lx\n",
+				rt, fp, offset, rp, bt->gprs [rt]);
+			bt->gpr_saved [rt] = 1;
+		}
+
+		else
+			bt_dbg(3, "$r%d already read\n", rt);
+	break;
+
+	default:		/* Ignore other registers */
+		break;
+	}
+
+	return result;
+}
+
+/*
+ * Find the beginning of the function in which the given address is found.
+ * Params:	bt	Points to the struct simple_bt object
+ *		addr	Address for which to locate the function start
+ * Returns:	Zero on success, otherwise:
+ *		-ESRCH	The given address is not in known code(inherited from
+ *			symbol_lookup)
+ */
+static int start_frame_abi(struct simple_bt *bt, reg_t addr)
+{
+	int		result;
+	reg_t		ip;
+	opcode_t	op;
+
+	/* Scan backwards until:
+	 * 1.	We can't read an instruction, which we take to indicate we
+	 *	went one instruction past the beginning of the function,
+	 * 2.	We found a "jr ra", which marks the end of the previous
+	 *	function, or
+	 * 3.	We found a decrement of the sp register, which is the stack
+	 *	frame allocation for this function.
+	 */
+	for (ip = ip_prev(addr); ; ip = ip_prev(ip)) {
+		result = get_op(bt, ip, &op);
+		if (result != 0 ||
+			is_return(op) ||
+			is_sp_decrement(op))
+			break;
+	}
+
+	switch (result) {
+	case -EFAULT: bt->func_start = ip_next(ip);
+		bt_dbg(2, "Found function start at 0x%lx by running out of "
+			"code\n", bt->func_start);
+		break;
+	case 0: if (is_return(op)) {
+			bt->func_start = ip_add(ip, 2 * OPCODE_SIZE);
+			bt_dbg(2, "Found function start at 0x%lx by "
+				"finding previous function end at 0x%lx\n",
+				bt->func_start, ip);
+		}
+
+		else
+			result = back_up_from_sp_decrement(bt, ip);
+		break;
+	default: 				/* Got some other error */
+		bt->func_start = NULL_REG;
+		break;
+	}
+
+	return result;
+}
+
+/*
+ * Matches the code fragment:
+ *	li	gp,<value>
+ *	addu	gp, gp, t9
+ * which is a short version of the code used to recover the GOT (global 
offset
+ * table) pointer from the address of the current function.
+ * Params:	op1	Possible match to: addu		gp, gp, t9
+ *		op2	Possible match to: li		gp,<value>
+ * Returns:	Non-zero if it matches, zero if it does not.
+ */
+static inline int match_short_get_got(opcode_t op1, opcode_t op2)
+{
+	return is_addu(op1, REG_GP, REG_GP, REG_T9) &&
+		is_li(op2, REG_GP);
+}
+
+/*
+ * Matches the code fragment:
+ *	lui	gp,%hi(<value>)
+ *	addiu	gp,gp,%lo(<value>)
+ *	addu	gp, gp, t9
+ * which is a long version of the code used to recover the GOT (global 
offset
+ * table) pointer from the address of the current function.
+ * Params:	op1	Possible match to: addu		gp, gp, t9
+ *		op2	Possible match to: addiu	gp,gp,%lo(<value>)
+ *		op3	Possible match to: lui		gp,%hi(<value>)
+ * Returns:	Non-zero if it matches, zero if it does not.
+ */
+static inline int match_long_get_got(opcode_t op1, opcode_t op2, 
opcode_t op3)
+{
+	return is_addu(op1, REG_GP, REG_GP, REG_T9) &&
+		is_addiu(op2, REG_GP, REG_GP) &&
+		is_lui(op2, REG_GP);
+}
+
+/*
+ * We are trying to find the beginning of a MIPS o32 ABI conformant 
function
+ * and found a stack pointer decrement at the given address. The means we
+ * must be in the first basic block of the current function. We want to
+ * keep backing up until we reach the beginning of the current function.
+ *
+ * The stack pointer decrement may be the first instruction of this
+ * function, but there is the possibility that we have code that
+ * is used to get the address of the GOT (global offset table) into
+ * the gp register. We look to see if we have such code and, if so,
+ * assume that the beginning of that code is the beginning of this
+ * function. This code will look like:
+ *	la	gp,<value>
+ *	addu	gp,gp,t9
+ * where la might expand into either:
+ *	lui	gp,%hi(<value>)
+ *	addiu	gp,gp,%lo(<value>)
+ * or, if <value> fits, as a signed value, in 16 bits:
+ *	li	gp,<value>	(implement as addiu gp,zero,<value>)
+ *
+ * Params:	bt	Pointer to struct simple_bt object.
+ *		sp_dec	Location of stack pointer decrement instruction
+ * Returns:	Zero if we found the start of the function and a negative
+ *		errno value if not.
+ */
+static int back_up_from_sp_decrement(struct simple_bt *bt, reg_t sp_dec)
+{
+	int		result = 0;
+	reg_t		ip;
+	unsigned	i;
+	opcode_t	op [3];
+
+	/* Start by trying to read the three previous instructions. */
+	for (i = 0, ip = ip_prev(sp_dec);
+		i < numberof(op);
+		i ++, ip = ip_prev(ip)) {
+		result = get_op(bt, ip, &op [i]);
+		if (result != 0)
+			break;
+	}
+
+	/* If we got an error other than -EFAULT, we have a problem we should
+	 * propagate. Otherwise, let's look at what we got. */
+	if (result == 0 || result == -EFAULT) {
+		switch (i) {
+		case 0:			/* Only read none or one instruction */
+		case 1: bt->func_start = sp_dec;
+			result = 0;
+			break;
+
+		case 2: if (match_short_get_got(op [0], op [1])) {
+				bt_dbg(3, "Matched short get GOT code\n");
+				bt->func_start = ip_add(sp_dec,
+					 -2 * OPCODE_SIZE);
+			} else
+				bt->func_start = sp_dec;
+
+			result = 0;
+			break;
+		case 3: if (match_short_get_got(op [0], op [1])) {
+				bt_dbg(3, "Matched short get GOT code\n");
+				bt->func_start = ip_add(sp_dec,
+					 -2 * OPCODE_SIZE);
+			} else if (match_long_get_got(op [0], op [1], op [2])) {
+				bt_dbg(3, "Matched long get GOT code\n");
+				bt->func_start = ip_add(sp_dec,
+					 -3 * OPCODE_SIZE);
+			} else
+				bt->func_start = sp_dec;
+
+			result = 0;
+			break;
+		default: result = -EINVAL;	/* Internal error */
+			break;
+		}
+	}
+
+	return result;
+}
+
+/*
+ * Find the end of the function by o32 ABI rules. If the function was 
not found,
+ * bt->fn_return must be set to NULL_REG.
+ * Params:	bt	Pointer to struct simple_bt object.
+ * Returns:	Zero if we found the end of the function, a negative errno 
value
+ *		if we could not.
+ */
+static int find_return_abi(struct simple_bt *bt)
+{
+	int		result;
+	reg_t		ip;
+	opcode_t	op;
+
+	/* Scan forward to find the "jr ra" that marks the end
+	 * of the current function */
+	for (ip = bt->pc; ; ip = ip_next(ip)) {
+		result = get_op(bt, ip, &op);
+		if (result != 0 || is_return(op))
+			break;
+	}
+
+	if (result == 0) {
+		bt_dbg(2, "Function return at 0x%lx\n", ip);
+		bt->fn_return = ip;
+	}
+
+	return result;
+}
+
+/*
+ * Find the beginning of the function in which the given address is found.
+ * Params:	bt	Points to the struct simple_bt object
+ *		addr	Address for which to locate the function start
+ * Returns:	Zero on success, otherwise:
+ *		-ESRCH	The given address is not in known code(inherited from
+ *			symbol_lookup)
+ */
+static int start_frame_lookup(struct simple_bt *bt, reg_t addr)
+{
+	int	result;
+
+	result = symbol_lookup(bt, addr, &bt->func_start,
+		&bt->data.lookup.func_size);
+
+	return result;
+}
+
+/*
+ * Find the return instruction starting at the current instruction, but if
+ * we don't find one by the end of the function, try again at the top.
+ * Params:	bt	Pointer to a struct simple_bt object
+ * Returns:	Zero if successful, otherwise a negative errno value.
+ */
+static int find_return_lookup(struct simple_bt *bt)
+{
+	int		result;
+	reg_t		end;
+
+	/* Start the search at the next instruction to be excuted and search to
+	 * the end */
+	end = bt->func_start + bt->data.lookup.func_size;
+	result = find_return_lookup_bounded(bt, bt->pc, end);
+
+	/* Start by scanning forward to find the "jr ra" that marks the end
+	 * of the current function. If we didn't get an error, but didn't
+	 * find the instruction, try again from the beginning. */
+
+	if (result == 0 && bt->fn_return == NULL_REG) {
+		/* We couldn't find a "jr ra" after the current
+		 * location, let's try for one before it. We know that
+		 * it can't be before the stack allocation and the
+		 * stack allocation isn't a return, so start right
+		 *  after that.*/
+		result = find_return_lookup_bounded(bt,
+			ip_next(bt->sf_allocation), bt->pc);
+
+		/* If we failed, return an error code */
+		if (result == 0 && bt->fn_return == NULL_REG) {
+			bt_dbg(1, "No function return found\n");
+			bt_dbg(2, "1st search: 0x%lx to 0x%lx, "
+				"2nd: 0x%lx to 0x%lx\n", bt->pc, end,
+				ip_next(bt->sf_allocation), bt->pc);
+
+			result = -ENOSYS;
+		}
+	}
+
+	return result;
+}
+
+/*
+ * This starts at the given address and looks for a function return. If
+ * it finds one, it sets the fn_return field to its address, otherwise it
+ * sets it to NULL_REG.
+ * Params:	bt	Points to the current struct simple_bt object
+ *		start	Starting address.
+ *		end	One instruction past the last instruction to check.
+ *			The address here should not be checked.
+ * Returns:	Zero if no error occurred during the scan, otherwise a
+ *		negative errno value.
+ */
+static int find_return_lookup_bounded(struct simple_bt *bt, reg_t start,
+	reg_t end)
+{
+	int		result = 0;	/* Assume success */
+	reg_t		ip;
+	opcode_t	op;
+
+	for (ip = start; ; ip = ip_next(ip)) {
+		if (ip == end)
+			break;
+		result = get_op(bt, ip, &op);
+		if (result != 0 || is_return(op))
+			break;
+	}
+
+	if (result == 0) {
+		if (ip == end)
+			bt->fn_return = NULL_REG;
+
+		else {
+			bt_dbg(2, "Function return at 0x%lx\n", ip);
+			bt->fn_return = ip;
+		}
+	}
+
+	return result;
+}
diff -urN linux-2.6.25.1/arch/mips/kernel/backtrace/thread-backtrace.c 
linux-t/arch/mips/kernel/backtrace/thread-backtrace.c
--- linux-2.6.25.1/arch/mips/kernel/backtrace/thread-backtrace.c 
1969-12-31 16:00:00.000000000 -0800
+++ linux-t/arch/mips/kernel/backtrace/thread-backtrace.c	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,388 @@
+/*
+ *			thread-backtrace.c
+ *
+ * Performs Linux-dependent MIPS processor stack backtracing for 
processes. It
+ * builds on the MIPS processor ABI-conformant stack backtracing code, but
+ * does the OS-dependent portions that handle signal frames, too. This 
allows
+ * it to do multi-frame backtracing.
+ *
+ * Copyright(C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#ifdef	__KERNEL__
+#include <linux/errno.h>
+#include <linux/module.h>
+#else
+#define	FAKE_KERNEL
+#endif
+
+#ifdef	FAKE_KERNEL
+#define	__KERNEL__
+#endif
+#include <asm/sigframe.h>
+#ifdef	FAKE_KERNEL
+#undef	__KERNEL__
+#endif
+
+#include <asm/thread-backtrace.h>
+
+#ifndef	numberof
+#define	numberof(a)	(sizeof(a) / sizeof ((a) [0]))
+#endif
+
+static int restore_sigcontext_regs(struct thread_bt *bt, reg_t ctx);
+static int set_sigargs(struct thread_bt *bt, reg_t sigframe_args,
+	reg_t sigargs [NUM_SIGARGS]);
+static int thread_backtrace_analyze_simple(struct thread_bt *bt);
+static int do_thread_backtrace (struct thread_bt *tbt,
+	process_thread_frame_t process, void *arg);
+
+void thread_backtrace_init(struct thread_bt *bt,
+	const struct thread_bt_config *config)
+{
+	bt->config = config;
+	simple_backtrace_init(&bt->sbt, &config->simple_config);
+	bt->pc_is_return_address = 0;
+}
+EXPORT_SYMBOL(thread_backtrace_init);
+
+/*
+ * Determine the program counter value of the caller.
+ * Returns:	Return address, which is the location at which the call
+ *		instruction is located.
+ */
+reg_t thread_backtrace_here(void)
+{
+	unsigned long ra;
+	__asm__ __volatile__(
+		"	.set	noat\n"
+		"	la	$at,%[ra]\n"
+		"	sw	$ra,0($at)\n"
+		:	[ra] "=m" (ra)
+		:
+		: "at"
+	);
+	return ra;
+}
+EXPORT_SYMBOL(thread_backtrace_here);
+
+/*
+ * thread_backtrace_pt_regs - Backtrace the current thread.
+ */
+int thread_backtrace_pt_regs (const struct pt_regs *regs,
+	process_thread_frame_t process, void *arg,
+	const struct thread_bt_config *config)
+{
+	panic ("TODO: thread_backtrace_pt_regs not implemented\n");
+	return -ENOSYS;
+}
+
+/*
+ * Backtrace for a process the current function, including handling of
+ * signal frames.
+ * Params:	process	Function that will process each stack frame.
+ *		arg	Argument to passed to the processing function.
+ * Returns:	Zero if successful, otherwise a negative number.
+ *		value if not.
+ */
+int thread_backtrace(process_thread_frame_t process, void *arg,
+	const struct thread_bt_config *config)
+{
+	struct thread_bt	bt;
+
+	thread_backtrace_init_here(&bt, config);
+	return do_thread_backtrace (&bt, process, arg);
+}
+
+/*
+ * do_thread_backtrace - Loop through the thread's stack
+ */
+static int do_thread_backtrace (struct thread_bt *bt,
+	process_thread_frame_t process, void *arg)
+{
+	int			result;
+
+	for (result = thread_backtrace_first(bt);
+		result == 0;
+		result = thread_backtrace_next(bt)) {
+
+		/* If $pc is a return address, i.e. an address stored in $ra
+		 * by a jalr instruction, adjust it to point to the jalr
+		 * because, in some sense, that instruction is not yet
+		 * complete. */
+		if (bt->pc_is_return_address) {
+			bt->sbt.pc -= 2 * OPCODE_SIZE;
+			bt_dbg(2, "$pc is return address, adjusted to 0x%lx\n",
+				bt->sbt.pc);
+		}
+
+		bt_dbg(1, "---\n");
+		result = process(arg, bt);
+
+		/* If we adjusted the pc to point to a jalr instruction,
+		 * restore it */
+		if (bt->pc_is_return_address)
+			bt->sbt.pc += 2 * OPCODE_SIZE;
+
+		if (result != 0)
+			break;
+	}
+
+	/* If we got a return value of -ENOSYS, the $pc and $sp values are
+	 * good, but we can't continue the backtrace. Call the function to
+	 * process the last frame. */
+
+	if (result == -ENOSYS) {
+		(void) process(arg, bt);
+		result = 0;
+	}
+
+	/* The result could be zero because we internally determined that
+	 * the stack backtrace is done, or because the process function
+	 * passed back THREAD_BACKTRACE_END to indicate that the backtrace
+	 * is done. Either case is normal, so adjust the result to indicate
+	 * a normal termination. */
+	if (result > 0) {
+		bt_dbg(2, "Adjusting positive return code %d to zero", result);
+		result = 0;
+	}
+
+	return result;
+}
+EXPORT_SYMBOL(thread_backtrace);
+
+/*
+ * Get information for the first stack frame in a backtrace.
+ * Params:	bt	Pointer to trace_backtrace_t object initialized with
+ *			thread_backtrace_init.
+ * Returns:	Zero on success, a negative errno otherwise.
+ */
+int thread_backtrace_first(struct thread_bt *bt)
+{
+	int	result;
+
+	result = thread_backtrace_analyze_frame(bt);
+
+	return result;
+}
+EXPORT_SYMBOL(thread_backtrace_first);
+
+/*
+ * Handle one stack backtrace frame, updating the register according to 
what
+ * is found.
+ * Params:	bt	Pointer to register and backtrace information.
+ * Returns:	Zero on success, a negative errno otherwise.
+ */
+int thread_backtrace_next(struct thread_bt *bt)
+{
+	int		result;
+
+	result = thread_backtrace_pop_frame(bt);
+
+	if (result == 0)
+		result = thread_backtrace_analyze_frame(bt);
+
+	return result;
+}
+EXPORT_SYMBOL(thread_backtrace_next);
+
+/*
+ * Analyzes the current stack frame to see whether we are executing in a
+ * signal trampoline. To do this, we look at the instructions at the
+ * return address. If we have a load of $v0 with one of a few special 
values,
+ * followed by a syscall, this frame is actually for a signal trampoline.
+ * If it is a signal trampoline, it will set the sigargs.
+ * Params:	bt		Pointer to backtrace register and other
+ *				information.
+ * Returns:	Zero if we were able to determine whether we were in a
+ *		signal trampoline and a negative errno value if not.
+ */
+int thread_backtrace_analyze_frame(struct thread_bt *bt)
+{
+	int			result;
+	opcode_t		op1, op2;
+	reg_t			ip;
+	reg_t			sigframe_args;
+
+	bt_dbg(1, "$pc 0x%lx $sp 0x%lx\n", bt->sbt.pc,
+		bt->sbt.gprs [REG_SP]);
+	/* Start by trying to read two instructions since that's how long the
+	 * signal trampoline is. */
+	ip = bt->sbt.pc;
+	result = bt->config->simple_config.get_op(ip, &op1);
+
+	if (result == 0)
+		result = bt->config->simple_config.get_op(ip_next(ip),
+			&op2);
+
+	if (result == 0) {
+		bt_dbg(3, "Possible signal trampoline ops: 0x%08x 0x%08x\n",
+			op1, op2);
+		/* If we could read the instructions, check to see whether
+		 * they are the right ones for the signal trampoline. */
+		if (!is_li(op1, REG_V0) || !is_syscall(op2))
+			result = thread_backtrace_analyze_simple(bt);
+
+		else {
+			struct u_format	*op_p;
+			/* Yes, we have an 'li v0,<value>' followed by a
+			 * syscall. Is the system call we are doing the right
+			 * kind? */
+			op_p = (struct u_format *) &op1;
+
+			switch (op_p->uimmediate) {
+			case __NR_O32_sigreturn: bt_dbg(2,
+					"Analyzing signal frame\n");
+				bt->type = THREAD_FRAME_SIGNAL;
+				bt->pc_is_return_address = 0;
+				sigframe_args = bt->sbt.gprs [REG_SP] +
+					offsetof(struct sigframe, sf_ass);
+				result = set_sigargs(bt, sigframe_args,
+					bt->sigargs);
+				break;
+			case __NR_O32_rt_sigreturn: bt_dbg(2,
+					"Analyzing realtime signal frame\n");
+				bt->type = THREAD_FRAME_RT_SIGNAL;
+				bt->pc_is_return_address = 0;
+				sigframe_args = bt->sbt.gprs [REG_SP] +
+					offsetof(struct rt_sigframe, rs_ass);
+				result = set_sigargs(bt, sigframe_args,
+					bt->sigargs);
+				break;
+			default: result = thread_backtrace_analyze_simple(bt);
+				break;
+			}
+		}
+	}
+
+	return result;
+}
+EXPORT_SYMBOL(thread_backtrace_analyze_frame);
+
+/*
+ * This is not a signal frame, so use the analyzer for simple stack frames.
+ * Params:	bt	Pointer to struct thread_bt object
+ * Returns:	Zero on success and a negative errno on failure.
+ */
+static int thread_backtrace_analyze_simple(struct thread_bt *bt)
+{
+	bt->type = THREAD_FRAME_SIMPLE;
+	bt->pc_is_return_address = 1;
+	return simple_backtrace_analyze_frame(&bt->sbt);
+}
+
+/*
+ * Advances to the next stack frame.
+ * Params:	bt	Pointer to a struct thread_bt object.
+ * Returns:	Zero on success and a negative errno on failure.
+ */
+int thread_backtrace_pop_frame(struct thread_bt *bt)
+{
+	int	result;
+	reg_t	sc;
+
+	switch (bt->type) {
+	case THREAD_FRAME_SIMPLE: result =
+			simple_backtrace_pop_frame(&bt->sbt);
+		break;
+
+	case THREAD_FRAME_SIGNAL: sc = bt->sbt.gprs [REG_SP] +
+			offsetof(struct sigframe, sf_sc);
+		result = restore_sigcontext_regs(bt, sc);
+		break;
+
+	case THREAD_FRAME_RT_SIGNAL: sc = bt->sbt.gprs [REG_SP] +
+			offsetof(struct rt_sigframe, rs_uc.uc_mcontext);
+		result = restore_sigcontext_regs(bt, sc);
+		break;
+
+	default: result = -EINVAL;	/* Internal failure: shouldn't happen */
+		bt_dbg(1, "Unexpected frame type: %d\n", bt->type);
+		break;
+	}
+
+	return result;
+}
+EXPORT_SYMBOL(thread_backtrace_pop_frame);
+
+/*
+ * Sets the backtrace information from the sigcontext object.
+ * Params:	ctx	Pointer to a sigcontext structure from which to take
+ *			the register values.
+ *		bt	Pointer to the struct thread_bt object into which to
+ *			place the register values.
+ * Returns:	Zero if able to successfully read the information, a negative
+ *		errno value otherwise.
+ */
+static int restore_sigcontext_regs(struct thread_bt *bt, reg_t ctx)
+{
+	int		result = 0;		/* Assume success */
+	reg_t		sc_reg;
+	enum reg_num	i;
+
+	bt_dbg(3, "sigcontext is at 0x%lx\n", ctx);
+
+	/* Restore all of the general purpose registers. */
+	simple_backtrace_clear_saved(&bt->sbt);
+
+	for (i = REG_AT; result == 0 && i < REG_ALL; i ++) {
+		sc_reg = ctx + offsetof(struct sigcontext, sc_regs [i]);
+		result = bt->config->get_sc_reg(sc_reg,
+			&bt->sbt.gprs [i]);
+		if (result == 0) {
+			bt_dbg(3, "Restored $r%d = 0x%lx\n", i,
+				bt->sbt.gprs [i]);
+			bt->sbt.gpr_saved [i] = 1;
+		}
+	}
+
+	/* We also have to get the $pc register because it is not a general
+	 * purpose register. */
+	if (result == 0) {
+		result = bt->config->get_sc_reg(ctx +
+				offsetof(struct sigcontext, sc_pc),
+			&bt->sbt.pc);
+		if (result == 0)
+			bt_dbg(1, "Restored $pc = 0x%lx\n", bt->sbt.pc);
+	}
+
+	return result;
+}
+
+/*
+ * Copy the signal arguments into the struct thread_bt object.
+ * Params:	args		Pointer to the four argument values
+ *		sigargs		Pointer to array in which to store the
+ *				argument values.
+ * Returns:	Zero on success, a negative errno value on failure.
+ */
+static int set_sigargs(struct thread_bt *bt, reg_t sigframe_args,
+	reg_t sigargs [NUM_SIGARGS])
+{
+	int		result = 0;	/* Assume success */
+	unsigned	i;
+
+	for (i = 0; result == 0 && i < NUM_SIGARGS; i ++) {
+		reg_t	p;
+		p = sigframe_args + i * sizeof(reg_t);
+		result = bt->config->simple_config.get_reg(p, &sigargs [i]);
+	}
+
+	return result;
+}
diff -urN linux-2.6.25.1/arch/mips/kernel/entry.S 
linux-t/arch/mips/kernel/entry.S
--- linux-2.6.25.1/arch/mips/kernel/entry.S	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/arch/mips/kernel/entry.S	2008-05-06 17:30:09.000000000 -0700
@@ -40,6 +40,7 @@
  	andi	t0, t0, KU_USER
  	beqz	t0, resume_kernel

+	.globl	resume_userspace
  resume_userspace:
  	local_irq_disable		# make sure we dont miss an
  					# interrupt setting need_resched
@@ -50,10 +51,12 @@
  	j	restore_all

  #ifdef CONFIG_PREEMPT
+	.globl	resume_kernel
  resume_kernel:
  	local_irq_disable
  	lw	t0, TI_PRE_COUNT($28)
  	bnez	t0, restore_all
+	.globl	need_resched
  need_resched:
  	LONG_L	t0, TI_FLAGS($28)
  	andi	t1, t0, _TIF_NEED_RESCHED
@@ -141,9 +144,11 @@
  	RESTORE_SP_AND_RET
  	.set	at

+	.globl	work_pending
  work_pending:
  	andi	t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
  	beqz	t0, work_notifysig
+	.globl	work_resched
  work_resched:
  	jal	schedule

@@ -157,6 +162,7 @@
  	andi	t0, a2, _TIF_NEED_RESCHED
  	bnez	t0, work_resched

+	.globl	work_notifysig
  work_notifysig:				# deal with pending signals and
  					# notify-resume requests
  	move	a0, sp
@@ -166,6 +172,7 @@

  FEXPORT(syscall_exit_work_partial)
  	SAVE_STATIC
+	.global	syscall_exit_work
  syscall_exit_work:
  	li	t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
  	and	t0, a2			# a2 is preloaded with TI_FLAGS
diff -urN linux-2.6.25.1/arch/mips/kernel/Makefile 
linux-t/arch/mips/kernel/Makefile
--- linux-2.6.25.1/arch/mips/kernel/Makefile	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/arch/mips/kernel/Makefile	2008-05-06 17:30:09.000000000 -0700
@@ -79,6 +79,7 @@

  obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
  obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
+obj-$(CONFIG_MIPS_ADVANCED_BACKTRACE) += backtrace/

  CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c 
-o /dev/null -xc /dev/null >/dev/null 2>&1; then echo 
"-DHAVE_AS_SET_DADDI"; fi)

diff -urN linux-2.6.25.1/arch/mips/kernel/scall32-o32.S 
linux-t/arch/mips/kernel/scall32-o32.S
--- linux-2.6.25.1/arch/mips/kernel/scall32-o32.S	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/arch/mips/kernel/scall32-o32.S	2008-05-06 17:30:09.000000000 
-0700
@@ -54,6 +54,7 @@
  	sw	a3, PT_R26(sp)		# save a3 for syscall restarting
  	bgez	t3, stackargs

+	.globl	stack_done
  stack_done:
  	lw	t0, TI_FLAGS($28)	# syscall tracing enabled?
  	li	t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
@@ -72,6 +73,7 @@
  					# restarting
  1:	sw	v0, PT_R2(sp)		# result

+	.globl	o32_syscall_exit
  o32_syscall_exit:
  	local_irq_disable		# make sure need_resched and
  					# signals dont change between
@@ -83,11 +85,13 @@

  	j	restore_partial

+	.globl	o32_syscall_exit_work
  o32_syscall_exit_work:
  	j	syscall_exit_work_partial

  /* 
------------------------------------------------------------------------ */

+	.globl	syscall_trace_entry
  syscall_trace_entry:
  	SAVE_STATIC
  	move	s0, t2
@@ -122,6 +126,7 @@
  	 * stack arguments from the user stack to the kernel stack.
  	 * This Sucks (TM).
  	 */
+	.globl	stackargs
  stackargs:
  	lw	t0, PT_R29(sp)		# get old user stack pointer

@@ -132,7 +137,7 @@
  	lw	t5, TI_ADDR_LIMIT($28)
  	addu	t4, t0, 32
  	and	t5, t4
-	bltz	t5, bad_stack		# -> sp is bad
+	bltz	t5, _bad_stack		# -> sp is bad

  	/* Ok, copy the args from the luser stack to the kernel stack.
  	 * t3 is the precomputed number of instruction bytes needed to
@@ -162,17 +167,18 @@
  	.set	pop

  	.section __ex_table,"a"
-	PTR	1b,bad_stack
-	PTR	2b,bad_stack
-	PTR	3b,bad_stack
-	PTR	4b,bad_stack
+	PTR	1b,_bad_stack
+	PTR	2b,_bad_stack
+	PTR	3b,_bad_stack
+	PTR	4b,_bad_stack
  	.previous

  	/*
  	 * The stackpointer for a call with more than 4 arguments is bad.
  	 * We probably should handle this case a bit more drastic.
  	 */
-bad_stack:
+	.globl	_bad_stack
+_bad_stack:
  	negu	v0				# error
  	sw	v0, PT_R0(sp)
  	sw	v0, PT_R2(sp)
@@ -183,6 +189,7 @@
  	/*
  	 * The system call does not exist in this kernel
  	 */
+	.globl	illegal_syscall
  illegal_syscall:
  	li	v0, -ENOSYS			# error
  	sw	v0, PT_R2(sp)
@@ -213,8 +220,8 @@
  #endif

  	.section __ex_table,"a"
-	PTR	1b, bad_stack
-	PTR	2b, bad_stack
+	PTR	1b, _bad_stack
+	PTR	2b, _bad_stack
  	.previous
  #else
  	sw	a1, 16(sp)
@@ -246,13 +253,16 @@

  	j	o32_syscall_exit	# continue like a normal syscall

+	.globl	no_mem
  no_mem:	li	v0, -ENOMEM
  	jr	ra

+	.globl	bad_address
  bad_address:
  	li	v0, -EFAULT
  	jr	ra

+	.globl	bad_alignment
  bad_alignment:
  	li	v0, -EINVAL
  	jr	ra
@@ -305,6 +315,7 @@
  	jr	t2
  	/* Unreached */

+	.globl	einval
  einval:	li	v0, -EINVAL
  	jr	ra
  	END(sys_syscall)
diff -urN linux-2.6.25.1/arch/mips/kernel/signal32.c 
linux-t/arch/mips/kernel/signal32.c
--- linux-2.6.25.1/arch/mips/kernel/signal32.c	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/arch/mips/kernel/signal32.c	2008-05-06 17:30:09.000000000 -0700
@@ -32,16 +32,10 @@
  #include <asm/system.h>
  #include <asm/fpu.h>
  #include <asm/war.h>
+#include <asm/sigframe.h>

  #include "signal-common.h"

-/*
- * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
- */
-#define __NR_O32_sigreturn		4119
-#define __NR_O32_rt_sigreturn		4193
-#define __NR_O32_restart_syscall        4253
-
  /* 32-bit compatibility types */

  typedef unsigned int __sighandler32_t;
diff -urN linux-2.6.25.1/arch/mips/kernel/signal.c 
linux-t/arch/mips/kernel/signal.c
--- linux-2.6.25.1/arch/mips/kernel/signal.c	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/arch/mips/kernel/signal.c	2008-05-06 17:30:09.000000000 -0700
@@ -30,51 +30,11 @@
  #include <asm/ucontext.h>
  #include <asm/cpu-features.h>
  #include <asm/war.h>
+#include <asm/sigframe.h>

  #include "signal-common.h"

  /*
- * Horribly complicated - with the bloody RM9000 workarounds enabled
- * the signal trampolines is moving to the end of the structure so we can
- * increase the alignment without breaking software compatibility.
- */
-#if ICACHE_REFILLS_WORKAROUND_WAR == 0
-
-struct sigframe {
-	u32 sf_ass[4];		/* argument save space for o32 */
-	u32 sf_code[2];		/* signal trampoline */
-	struct sigcontext sf_sc;
-	sigset_t sf_mask;
-};
-
-struct rt_sigframe {
-	u32 rs_ass[4];		/* argument save space for o32 */
-	u32 rs_code[2];		/* signal trampoline */
-	struct siginfo rs_info;
-	struct ucontext rs_uc;
-};
-
-#else
-
-struct sigframe {
-	u32 sf_ass[4];			/* argument save space for o32 */
-	u32 sf_pad[2];
-	struct sigcontext sf_sc;	/* hw context */
-	sigset_t sf_mask;
-	u32 sf_code[8] ____cacheline_aligned;	/* signal trampoline */
-};
-
-struct rt_sigframe {
-	u32 rs_ass[4];			/* argument save space for o32 */
-	u32 rs_pad[2];
-	struct siginfo rs_info;
-	struct ucontext rs_uc;
-	u32 rs_code[8] ____cacheline_aligned;	/* signal trampoline */
-};
-
-#endif
-
-/*
   * Helper routines
   */
  static int protected_save_fp_context(struct sigcontext __user *sc)
diff -urN linux-2.6.25.1/arch/mips/kernel/traps.c 
linux-t/arch/mips/kernel/traps.c
--- linux-2.6.25.1/arch/mips/kernel/traps.c	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/arch/mips/kernel/traps.c	2008-05-06 17:33:13.000000000 -0700
@@ -42,6 +42,7 @@
  #include <asm/mmu_context.h>
  #include <asm/types.h>
  #include <asm/stacktrace.h>
+#include <asm/kernel-backtrace.h>

  extern asmlinkage void handle_int(void);
  extern asmlinkage void handle_tlbm(void);
@@ -105,21 +106,83 @@
  __setup("raw_show_trace", set_raw_show_trace);
  #endif

-static void show_backtrace(struct task_struct *task, const struct 
pt_regs *regs)
+#ifdef	CONFIG_MIPS_ADVANCED_BACKTRACE
+/*
+ * print_bt_frame - Print one backtrace frame
+ * @arg:	Pointer to the frame count
+ * @bt:		Pointer to the kernel backtrace structure &kernel_bt.
+ * Returns: Zero if the backtrace is to continue, otherwise
+ *	KERNEL_BACKTRACE_END to indicate backtrace termination.
+ */
+static int print_bt_frame(void *arg, struct kernel_bt *bt)
+{
+	int		result = 0;	/* Assume a good outcome */
+	unsigned	*count = (unsigned *) arg;
+	unsigned long	pc, fp;
+	static const int max_stack_frames = 50;
+
+	pc = bt->tbt.sbt.pc;
+	fp = bt->tbt.sbt.gprs [bt->tbt.sbt.framepointer];
+	print_ip_sym(pc);
+
+	/* Don't print more than the maximum number of stack frames. */
+	*count = *count + 1;
+
+	if (*count >= max_stack_frames) {
+		printk(KERN_WARNING "Exceeded maximum number of frames (%u)\n",
+			max_stack_frames);
+		result = KERNEL_BACKTRACE_END;
+	}
+
+	return result;
+}
+
+/**
+ * show_unwinding_backtrace - Print the backtrace by unwinding stack frames
+ *	one at a time.
+ * @task:	Pointer to the task structure for the task to be unwound
+ * @regs:	Pointer to &pt_regs structure with the initial registers
+ */
+static void show_unwinding_backtrace(struct task_struct *task,
+	const struct pt_regs *regs)
+{
+	int	frame_count = 0;
+	int	rc;
+
+	rc = kernel_backtrace_pt_regs(regs, print_bt_frame, &frame_count);
+
+	if (rc != 0)
+		printk(KERN_WARNING "Backtrace terminated with error %d\n",
+			rc);
+}
+#else
+static void show_unwinding_backtrace(struct task_struct *task,
+	const struct pt_regs *regs)
  {
  	unsigned long sp = regs->regs[29];
  	unsigned long ra = regs->regs[31];
  	unsigned long pc = regs->cp0_epc;

-	if (raw_show_trace || !__kernel_text_address(pc)) {
-		show_raw_backtrace(sp);
-		return;
-	}
-	printk("Call Trace:\n");
  	do {
  		print_ip_sym(pc);
  		pc = unwind_stack(task, &sp, pc, &ra);
  	} while (pc);
+}
+#endif
+
+static void show_backtrace(struct task_struct *task, const struct 
pt_regs *regs)
+{
+	unsigned long sp = regs->regs[29];
+	unsigned long pc = regs->cp0_epc;
+
+	if (raw_show_trace
+		|| !__kernel_text_address(pc)
+		) {
+		show_raw_backtrace(sp);
+		return;
+	}
+	printk("Symbolic Call Trace:\n");
+	show_unwinding_backtrace(task, regs);
  	printk("\n");
  }

diff -urN linux-2.6.25.1/include/asm-mips/kernel-backtrace.h 
linux-t/include/asm-mips/kernel-backtrace.h
--- linux-2.6.25.1/include/asm-mips/kernel-backtrace.h	1969-12-31 
16:00:00.000000000 -0800
+++ linux-t/include/asm-mips/kernel-backtrace.h	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,81 @@
+/*
+ *				kernel-backtrace.h
+ *
+ * Definitions for stack backtracing in the kernel. In addition to handle
+ * process backtraces, because kernel threads can get signals, too, 
this has
+ * to handle interrupts and exceptions.
+ *
+ * Copyright (C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ */
+
+#ifndef	_KERNEL_BACKTRACE_H_
+#define	_KERNEL_BACKTRACE_H_
+#include <asm/types.h>
+#include <asm/thread-backtrace.h>
+
+/* Value to be returned by the function that processes each frame to 
indicate
+ * a non-error termination of the backtrace. */
+#define	KERNEL_BACKTRACE_END	1
+
+/* Value returned internally by functions called from 
do_kernel_backtrace to
+ * indicate that the backtrace should terminate. */
+#define KERNEL_BACKTRACE_DONE	2
+
+enum kernel_frame_type {
+	KERNEL_FRAME_SIMPLE = THREAD_FRAME_SIMPLE, /* Ordinary frame */
+	KERNEL_FRAME_SIGNAL = THREAD_FRAME_SIGNAL, /* Signal frame */
+	KERNEL_FRAME_RT_SIGNAL = THREAD_FRAME_RT_SIGNAL, /* Realtime signal */
+	KERNEL_FRAME_TLB_REFILL,	/* In the general exception vector */
+	KERNEL_FRAME_GENERAL_EXCEPTION,	/* In the general exception vector */
+	KERNEL_FRAME_INTERRUPT,		/* In the general exception vector */
+	KERNEL_FRAME_K0_K1_ONLY,	/* Code uses only $k0 & $k1 registers */
+	KERNEL_FRAME_SAVE_SOME,		/* Code uses SAVE_SOME macro */
+	KERNEL_FRAME_SAVE_STATIC,	/* Code uses SAVE_STATIC macro */
+	KERNEL_FRAME_SAVE_ALL,		/* Code uses SAVE_ALL macro */
+	KERNEL_FRAME_GLUE,		/* Registers saved in struct pt_regs */
+	KERNEL_FRAME_RESTORE_SOME,	/* Code uses RESTORE_SOME macro */
+	KERNEL_FRAME_UNEXPECTED		/* Never expect to be in this code */
+};
+
+struct kernel_bt {
+	struct thread_bt	tbt;
+	enum kernel_frame_type	type;
+	u32			cp0_status; /* CP0 Status register */
+	reg_t			cp0_epc; /* CP0 EPC register */
+	reg_t			start;	/* Start of current section of code */
+	reg_t			size;	/* Size of current section of code */
+};
+
+/**
+ * process_kernel_frame_t - Type of function called to do processing 
for each
+ *	frame of the stack backtrace.
+ * @arg:	Argument passed to kernel_backtrace/kernel_backtrace_pt_regs
+ * @bt:		Pointer to &kernel_bt structure
+ * Returns zero if the backtrace is to continue, non-zero otherwise. A 
negative
+ *	errno is used to signal an error, KERNEL_BACKTRACE_END is available for
+ *	a normal termination.
+ */
+typedef	int (*process_kernel_frame_t) (void *arg, struct kernel_bt *bt);
+
+extern int kernel_backtrace_pt_regs(const struct pt_regs *regs,
+	process_kernel_frame_t process, void *arg);
+extern int kernel_backtrace(process_kernel_frame_t process, void *arg);
+extern int kernel_backtrace_first(struct kernel_bt *bt);
+extern int kernel_backtrace_next(struct kernel_bt *bt);
+extern int kernel_backtrace_analyze_frame(struct kernel_bt *bt);
+extern int kernel_backtrace_pop_frame(struct kernel_bt *bt);
+#endif	/* _KERNEL_BACKTRACE_H_ */
diff -urN linux-2.6.25.1/include/asm-mips/kernel-backtrace-symbols.h 
linux-t/include/asm-mips/kernel-backtrace-symbols.h
--- linux-2.6.25.1/include/asm-mips/kernel-backtrace-symbols.h 
1969-12-31 16:00:00.000000000 -0800
+++ linux-t/include/asm-mips/kernel-backtrace-symbols.h	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,133 @@
+/*
+ *			kernel-backtrace-symbols.h
+ *
+ * This file contains symbols that need to be handled specially. The
+ * idea is that code will define a macro named SPECIAL_SYMBOL that
+ * appropriately generates code for an external reference, then redefines
+ * it to generate a table with the symbols.
+ *
+ * It should be mentioned that, though this is not especially pretty, 
having
+ * this list of symbols in only one place makes it impossible to define
+ * the external reference for the symbol and then forget to add it to the
+ * table of symbols, which is a big win on the maintenance front.
+ *
+ * To make this list easier to maintain, it is best to keep the symbols
+ * for a given file together and in the order in which they appear in that
+ * file.
+ *
+ * Copyright (C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ */
+
+/* The first part is protected against multiple inclusions, but the
+ * rest isn't */
+#ifndef	_KERNEL_BACKTRACE_SYMBOLS_H_
+#define	_KERNEL_BACKTRACE_SYMBOLS_H_
+#include <asm/kernel-backtrace.h>
+
+struct kern_special_sym {
+	const opcode_t		*start;
+	enum kernel_frame_type	type;
+};
+
+extern const struct kern_special_sym kernel_backtrace_symbols [];
+extern unsigned kernel_backtrace_symbols_size;
+#endif	/* _KERNEL_BACKTRACE_SYMBOLS_H_ */
+
+/* Only define the symbol list if someone has defined the macro we use
+ * to construct it. This allows the above symbols to be included even by
+ * things which only reference the list. */
+
+#ifdef	SPECIAL_SYMBOL
+/* arch/mips/kernel/entry.S */
+SPECIAL_SYMBOL(ret_from_exception, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(ret_from_irq, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(resume_userspace, KERNEL_FRAME_GLUE)
+#ifdef CONFIG_PREEMPT
+SPECIAL_SYMBOL(resume_kernel, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(need_resched, KERNEL_FRAME_GLUE)
+#endif
+SPECIAL_SYMBOL(ret_from_fork, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(syscall_exit, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(restore_all, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(restore_partial, KERNEL_FRAME_RESTORE_SOME)
+SPECIAL_SYMBOL(work_pending, KERNEL_FRAME_RESTORE_SOME)
+SPECIAL_SYMBOL(work_resched, KERNEL_FRAME_RESTORE_SOME)
+SPECIAL_SYMBOL(work_notifysig, KERNEL_FRAME_RESTORE_SOME)
+SPECIAL_SYMBOL(syscall_exit_work_partial, KERNEL_FRAME_SAVE_STATIC)
+SPECIAL_SYMBOL(syscall_exit_work, KERNEL_FRAME_GLUE)
+
+/* arch/mips/kernel/genex.S */
+SPECIAL_SYMBOL(except_vec_vi_end, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(except_vec_vi_handler, KERNEL_FRAME_SAVE_STATIC)
+SPECIAL_SYMBOL(handle_adel, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_adel_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_ades, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_ades_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_ibe, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_ibe_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_dbe, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_dbe_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_bp, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_bp_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_ri, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_ri_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_cpu, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_cpu_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_ov, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_ov_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_tr, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_tr_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_fpe, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_fpe_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_mdmx, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_mdmx_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_watch, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_watch_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_mcheck, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_mcheck_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_mt, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_mt_int, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(handle_dsp, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(handle_dsp_int, KERNEL_FRAME_GLUE)
+
+/* arch/mips/kernel/scall32-o32.S */
+SPECIAL_SYMBOL(handle_sys, KERNEL_FRAME_SAVE_SOME)
+SPECIAL_SYMBOL(stack_done, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(o32_syscall_exit, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(o32_syscall_exit_work, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(syscall_trace_entry, KERNEL_FRAME_SAVE_STATIC)
+SPECIAL_SYMBOL(stackargs, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(_bad_stack, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(illegal_syscall, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(mips_atomic_set, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(mips_atomic_set, KERNEL_FRAME_SAVE_STATIC)
+SPECIAL_SYMBOL(no_mem, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(bad_address, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(bad_alignment, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(sys_sysmips, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(sys_syscall, KERNEL_FRAME_GLUE)
+SPECIAL_SYMBOL(einval, KERNEL_FRAME_GLUE)
+
+/* arch/mips/mm/tlbex-fault.S */
+SPECIAL_SYMBOL(tlb_do_page_fault_0, KERNEL_FRAME_SAVE_ALL)
+SPECIAL_SYMBOL(tlb_do_page_fault_1, KERNEL_FRAME_SAVE_ALL)
+
+/* arch/mips/mm/tlbex.c (Code generated dynamically) */
+SPECIAL_SYMBOL(handle_tlbl, KERNEL_FRAME_K0_K1_ONLY)
+SPECIAL_SYMBOL(handle_tlbm, KERNEL_FRAME_K0_K1_ONLY)
+SPECIAL_SYMBOL(handle_tlbs, KERNEL_FRAME_K0_K1_ONLY)
+#endif	/* SPECIAL_SYMBOL */
diff -urN linux-2.6.25.1/include/asm-mips/ptrace.h 
linux-t/include/asm-mips/ptrace.h
--- linux-2.6.25.1/include/asm-mips/ptrace.h	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/include/asm-mips/ptrace.h	2008-05-06 18:27:15.000000000 -0700
@@ -23,6 +23,18 @@
  #define DSP_CONTROL	77
  #define ACX		78

+/* Register numbers */
+enum reg_num {
+	REG_ZERO,	REG_AT,	REG_V0,	REG_V1,
+	REG_A0,	REG_A1,	REG_A2,	REG_A3,
+	REG_T0,	REG_T1,	REG_T2,	REG_T3,
+	REG_T4,	REG_T5,	REG_T6,	REG_T7,
+	REG_S0,	REG_S1,	REG_S2,	REG_S3,
+	REG_S4,	REG_S5,	REG_S6,	REG_S7,
+	REG_T8,	REG_T9,	REG_K0,	REG_K1,
+	REG_GP,	REG_SP,	REG_S8,	REG_RA,
+	REG_ALL		/* This last one is the number of GPRs */
+};
  /*
   * This struct defines the way the registers are stored on the stack 
during a
   * system call/exception. As usual the registers k0/k1 aren't being saved.
@@ -34,7 +46,7 @@
  #endif

  	/* Saved main processor registers. */
-	unsigned long regs[32];
+	unsigned long regs[REG_ALL];

  	/* Saved special registers. */
  	unsigned long cp0_status;
diff -urN linux-2.6.25.1/include/asm-mips/sigframe.h 
linux-t/include/asm-mips/sigframe.h
--- linux-2.6.25.1/include/asm-mips/sigframe.h	1969-12-31 
16:00:00.000000000 -0800
+++ linux-t/include/asm-mips/sigframe.h	2008-05-06 17:30:09.000000000 -0700
@@ -0,0 +1,73 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General 
Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2007 Scientific-Atlanta, Inc.
+ * Copyright (C) 1991, 1992  Linus Torvalds
+ * Copyright (C) 1994 - 2000  Ralf Baechle
+ * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ */
+
+#ifndef	_SIGFRAME_H_
+#define	_SIGFRAME_H_
+#include <linux/signal.h>
+
+#include <asm/ucontext.h>
+#include <asm/war.h>
+
+/*
+ * Originally from arch/mips/kernel/signal.c...
+ */
+/*
+ * Horribly complicated - with the bloody RM9000 workarounds enabled
+ * the signal trampolines is moving to the end of the structure so we can
+ * increase the alignment without breaking software compatibility.
+ */
+#if ICACHE_REFILLS_WORKAROUND_WAR == 0
+
+struct sigframe {
+	u32 sf_ass[4];		/* argument save space for o32 */
+	u32 sf_code[2];		/* signal trampoline */
+	struct sigcontext sf_sc;
+	sigset_t sf_mask;
+};
+
+struct rt_sigframe {
+	u32 rs_ass[4];		/* argument save space for o32 */
+	u32 rs_code[2];		/* signal trampoline */
+	struct siginfo rs_info;
+	struct ucontext rs_uc;
+};
+
+#else
+
+struct sigframe {
+	u32 sf_ass[4];			/* argument save space for o32 */
+	u32 sf_pad[2];
+	struct sigcontext sf_sc;	/* hw context */
+	sigset_t sf_mask;
+	u32 sf_code[8] ____cacheline_aligned;	/* signal trampoline */
+};
+
+struct rt_sigframe {
+	u32 rs_ass[4];			/* argument save space for o32 */
+	u32 rs_pad[2];
+	struct siginfo rs_info;
+	struct ucontext rs_uc;
+	u32 rs_code[8] ____cacheline_aligned;	/* signal trampoline */
+};
+
+#endif
+
+/*
+ * Originally from arch/mips/kernel/signal32.c...
+ */
+
+/*
+ * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
+ */
+#define __NR_O32_sigreturn		4119
+#define __NR_O32_rt_sigreturn		4193
+#define __NR_O32_restart_syscall	4253
+#endif
diff -urN linux-2.6.25.1/include/asm-mips/simple-backtrace.h 
linux-t/include/asm-mips/simple-backtrace.h
--- linux-2.6.25.1/include/asm-mips/simple-backtrace.h	1969-12-31 
16:00:00.000000000 -0800
+++ linux-t/include/asm-mips/simple-backtrace.h	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,344 @@
+/*
+ *			simple-backtrace.h
+ *
+ * Definitions handling one simple stack frame's worth of stack backtrace.
+ *
+ * Copyright(C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ */
+
+#ifndef	_SIMPLE_BACKTRACE_H_
+#define	_SIMPLE_BACKTRACE_H_
+#include <linux/compiler.h>
+#include <asm/inst.h>
+#include <asm/ptrace.h>
+
+#ifdef	__KERNEL__
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#define	dbg_print	printk
+#define	PRIORITY	KERN_CRIT
+#else
+#include <errno.h>
+#include <stdio.h>
+#define	dbg_print	printf
+#define	EXPORT_SYMBOL(sym)
+#define	PRIORITY
+#endif
+
+#define	BACKTRACE_DEBUG	0
+
+#if	BACKTRACE_DEBUG != 0
+#define	bt_dbg(level, fmt, ...)	do {					\
+		if (level <= BACKTRACE_DEBUG)				\
+			dbg_print(PRIORITY "%s: " fmt, __FUNCTION__,	\
+			## __VA_ARGS__);				\
+	} while (0)
+#else
+#define	bt_dbg(level, fmt, ...)	do { } while (0)
+#endif
+
+#define	OPCODE_SIZE (sizeof(opcode_t))	/* MIPS processor has 4-byte 
opcodes */
+
+/* Additional instruction formats that really should have been defined in
+ * asm/inst.h */
+#ifdef	__MIPSEB__
+	struct	any_format {		/* Generic format */
+		unsigned int opcode : 6;
+		unsigned int remainder : 26;
+	};
+
+	struct	eret_format {
+		unsigned int opcode : 6;
+		unsigned int co : 1;
+		unsigned int zero: 19;
+		unsigned int func : 6;
+	};
+
+	struct syscall_format {
+		unsigned int opcode : 6;
+		unsigned int code : 20;
+		unsigned int func : 6;
+	};
+#else
+	struct	any_format {		/* Generic format */
+		unsigned int remainder : 26;
+		unsigned int opcode : 6;
+	};
+
+	struct	eret_format {
+		unsigned int func : 6;
+		unsigned int zero: 19;
+		unsigned int co : 1;
+		unsigned int opcode : 6;
+	};
+
+	struct syscall_format {
+		unsigned int func : 6;
+		unsigned int code : 20;
+		unsigned int opcode : 6;
+	};
+#endif
+
+/* NULL value, converted to a reg_t type */
+#define	NULL_REG	((reg_t) NULL)
+
+typedef	unsigned long reg_t;		/* Can hold a register value */
+typedef	mips_instruction opcode_t;	/* Holds a machine instruction */
+typedef	int reg_offset_t;		/* Offset from a register */
+typedef	reg_offset_t frame_size_t;	/* Stack frame size */
+typedef	long pc_offset_t;		/* Offset from $pc */
+
+/* Backtrace types */
+enum simple_bt_type {
+	SIMPLE_BACKTRACE_O32_ABI,	/* Backtrace using o32 ABI rules */
+	SIMPLE_BACKTRACE_LOOKUP_FUNC,	/* Look up function start and size */
+};
+
+/*
+ * Functions that are required by the simple-backtrace.c code but which 
must
+ * be supplied by users of that code.
+ */
+
+/*
+ * Get an opcode_t-sized object from memory.
+ * Params:	ip	Address of the opcode.
+ *		op	Location in which to store the opcode
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+typedef int(*get_op_t) (reg_t ip, opcode_t *op);
+
+/*
+ * Get a register-sized(reg_t-sized) object from memory.
+ * Params:	rp		Address of the value.
+ *		reg		Location in which to store the value.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+typedef int(*get_reg_t) (reg_t rp, reg_t *reg);
+
+/*
+ * Lookup a symbol's starting address and the size of the object, given an
+ * address within the symbol.
+ * Params:	addr		Address to look up
+ *		symbolstart	Starting address of the symbol
+ *		symbolsize	Number of bytes in the memory represented by
+ *				the symbol.
+ * Returns:	Zero on success, otherwise a negative errno value. If the 
symbol
+ *		couldn't be found, the value returned should be -ESRCH.
+ */
+typedef int(*symbol_lookup_t) (reg_t addr, reg_t *symbolstart,
+	reg_t *symbolsize);
+
+/*
+ * Configuration information for the backtrace.
+ */
+struct simple_bt_config {
+	enum simple_bt_type	type;
+	get_op_t		get_op;
+	get_reg_t		get_reg;
+	symbol_lookup_t		symbol_lookup;
+};
+
+/*
+ * Data type that holds the current values of the GPRS, along with other
+ * information required during the backtrace.
+ */
+struct simple_bt {
+	/* Public */
+	reg_t		gprs [REG_ALL];
+	int		gpr_saved [REG_ALL];
+	enum reg_num	framepointer;	/* Register number of frame pointer */
+	reg_t		pc;
+	frame_size_t	frame_size;	/* Stack frame size, in bytes */
+	/* Private */
+	const struct simple_bt_config *config;
+	reg_t		sf_allocation;	/* Address of stack frame allocation */
+	reg_t		fp_restore;	/* Addr frame ptr moved back to $sp*/
+	reg_t		sf_deallocation; /* Addr of stack frame deallocation */
+	reg_t		fn_return;	/* Address of return instruction */
+	enum reg_num	possible_framepointer;
+	reg_t		func_start;	/* Address of 1st opcode of function */
+	union {
+		struct {
+			reg_t	func_size;
+		} lookup;
+	} data;
+};
+
+/* Opcode: addiu rs, rt, imm */
+static inline int is_addiu(opcode_t inst, reg_t rs, reg_t rt)
+{
+	struct i_format *op_p = (struct i_format *) &inst;
+	return op_p->opcode == addiu_op &&
+		op_p->rs == rs &&  op_p->rt == rt;
+}
+
+/* Opcode: addu */
+static inline int is_addu_noreg(opcode_t inst)
+{
+	struct r_format	*op_p = (struct r_format *) &inst;
+	return op_p->opcode == spec_op && op_p->func == addu_op &&
+			op_p->re == 0;
+}
+
+/* Opcode: addu rd, rs, rt */
+static inline int is_addu(opcode_t inst, reg_t rd, reg_t rs, reg_t rt)
+{
+	struct r_format	*op_p = (struct r_format *) &inst;
+	return is_addu_noreg(inst) &&
+		op_p->rd == rd && op_p->rs == rs && op_p->rt == rt;
+}
+
+/* Opcode: eret */
+static inline int is_eret(opcode_t inst)
+{
+	struct eret_format	*op_p = (struct eret_format *) &inst;
+	return op_p->opcode == spec_op && op_p->func == eret_op &&
+		op_p->co == 1 && op_p->zero == 0;
+}
+
+/* Opcode: move rd, rs. Synonym for addu rd, rs, zero. */
+static inline int is_move(opcode_t inst, reg_t rd, reg_t rs)
+{
+	return is_addu(inst, rd, rs, REG_ZERO);
+}
+
+/* Opcode: jal addr */
+static inline int is_jal(opcode_t inst)
+{
+	struct j_format	*op_p = (struct j_format *) &inst;
+	return op_p->opcode == jal_op;
+}
+
+static inline int is_jalr(opcode_t inst)
+{
+	struct r_format	*op_p = (struct r_format *) &inst;
+	return op_p->opcode == spec_op && op_p->func == jalr_op &&
+		op_p->rt == 0;
+}
+
+static inline int is_jr(opcode_t inst, reg_t rs)
+{
+	struct r_format	*op_p = (struct r_format *) &inst;
+	return op_p->opcode == spec_op && op_p->func == jr_op &&
+		op_p->rs == rs && op_p->rt == 0 && op_p->rd == 0;
+}
+
+static inline int is_li(opcode_t inst, reg_t rt)
+{
+	return is_addiu(inst, REG_ZERO, rt);
+}
+
+static inline int is_lui(opcode_t inst, reg_t rt)
+{
+	struct u_format	*op_p = (struct u_format *) &inst;
+	return op_p->opcode == lui_op && op_p->rs == 0 &&
+		op_p->rt == rt;
+}
+
+static inline int is_sw(opcode_t inst, reg_t rt, reg_t base)
+{
+	struct i_format	*op_p = (struct i_format *) &inst;
+	return op_p->opcode == sw_op &&
+		op_p->rs == base && op_p->rt == rt;
+}
+
+static inline int is_syscall(opcode_t inst)
+{
+	struct syscall_format *op_p = (struct syscall_format *) &inst;
+	return op_p->opcode == spec_op &&
+		op_p->func == syscall_op;
+}
+
+/* Sign extension functions. */
+
+static inline reg_offset_t sign_extend_imm(opcode_t imm)
+{
+	struct i_format	*op_p = (struct i_format *) &imm;
+	return op_p->simmediate;
+}
+
+static inline reg_offset_t sign_extend_offset(opcode_t offset)
+{
+	struct i_format *op_p = (struct i_format *) &offset;
+	return op_p->simmediate;
+}
+
+/* Is this the save of a register with an offset from the given frame 
pointer
+ * register? */
+static inline int is_frame_save(opcode_t inst, enum reg_num framepointer)
+{
+	struct i_format	*op_p = (struct i_format *) &inst;
+	return op_p->opcode == sw_op &&
+		op_p->rs == framepointer;
+}
+
+/* Returns the number of the register being saved when the opcode is a 
frame
+ * save. */
+static inline enum reg_num frame_save_rt(opcode_t op)
+{
+	struct i_format	*op_p = (struct i_format *) &op;
+	return op_p->rt;
+}
+
+/* Returns the offset in the stack frame for a frame save */
+static inline reg_offset_t frame_save_offset(opcode_t op)
+{
+	struct i_format *op_p = (struct i_format *) &op;
+	return op_p->simmediate;
+}
+
+/*
+ * Add a number of bytes to the given instruction pointer
+ * Params:	ip	Instruction pointer
+ *		delta	Number of bytes to add
+ * Returns:	The sum of ip and delta, as an opcode_t *.
+ */
+static inline reg_t ip_add(reg_t ip, pc_offset_t delta)
+{
+	return ip + delta;
+}
+
+/*
+ * Compute the location of the next instruction.
+ * Params:	ip	Pointer to the current instruction
+ * Returns:	Pointer to the next instruction.
+ */
+static inline reg_t ip_next(reg_t ip)
+{
+	return ip_add(ip, OPCODE_SIZE);
+}
+
+/*
+ * Compute the location of the previous instruction.
+ * Params:	ip	Pointer to the current instruction
+ * Returns:	Pointer to the previous instruction.
+ */
+static inline reg_t ip_prev(reg_t ip)
+{
+	return ip_add(ip, -OPCODE_SIZE);
+}
+
+extern int is_basic_block_end(opcode_t op);
+extern void simple_backtrace_clear_saved(struct simple_bt *bt);
+extern void simple_backtrace_init(struct simple_bt *bt,
+	const struct simple_bt_config *config);
+extern int simple_backtrace_first(struct simple_bt *bt);
+extern int simple_backtrace_next(struct simple_bt *bt);
+extern int simple_backtrace_analyze_frame(struct simple_bt *bt);
+extern int simple_backtrace_pop_frame(struct simple_bt *bt);
+#endif	/* _SIMPLE_BACKTRACE_H_ */
diff -urN linux-2.6.25.1/include/asm-mips/stacktrace.h 
linux-t/include/asm-mips/stacktrace.h
--- linux-2.6.25.1/include/asm-mips/stacktrace.h	2008-05-01 
14:45:25.000000000 -0700
+++ linux-t/include/asm-mips/stacktrace.h	2008-05-06 17:30:09.000000000 
-0700
@@ -30,18 +30,49 @@
  		".set noat\n\t"
  #ifdef CONFIG_64BIT
  		"1: dla $1, 1b\n\t"
-		"sd $1, %0\n\t"
-		"sd $29, %1\n\t"
-		"sd $31, %2\n\t"
+		"sd $1, %[epc]\n\t"
+		"sd $16, %[s0]\n\t"
+		"sd $17, %[s1]\n\t"
+		"sd $18, %[s2]\n\t"
+		"sd $19, %[s3]\n\t"
+		"sd $20, %[s4]\n\t"
+		"sd $21, %[s5]\n\t"
+		"sd $22, %[s6]\n\t"
+		"sd $23, %[s7]\n\t"
+		"sd $28, %[gp]\n\t"
+		"sd $29, %[sp]\n\t"
+		"sd $30, %[fp]\n\t"
+		"sd $31, %[ra]\n\t"
  #else
  		"1: la $1, 1b\n\t"
-		"sw $1, %0\n\t"
-		"sw $29, %1\n\t"
-		"sw $31, %2\n\t"
+		"sw $1, %[epc]\n\t"
+		"sw $16, %[s0]\n\t"
+		"sw $17, %[s1]\n\t"
+		"sw $18, %[s2]\n\t"
+		"sw $19, %[s3]\n\t"
+		"sw $20, %[s4]\n\t"
+		"sw $21, %[s5]\n\t"
+		"sw $22, %[s6]\n\t"
+		"sw $23, %[s7]\n\t"
+		"sw $28, %[gp]\n\t"
+		"sw $29, %[sp]\n\t"
+		"sw $30, %[fp]\n\t"
+		"sw $31, %[ra]\n\t"
  #endif
  		".set pop\n\t"
-		: "=m" (regs->cp0_epc),
-		"=m" (regs->regs[29]), "=m" (regs->regs[31])
+		: [epc] "=m" (regs->cp0_epc),
+		  [s0] "=m" (regs->regs[16]),
+		  [s1] "=m" (regs->regs[17]),
+		  [s2] "=m" (regs->regs[18]),
+		  [s3] "=m" (regs->regs[19]),
+		  [s4] "=m" (regs->regs[20]),
+		  [s5] "=m" (regs->regs[21]),
+		  [s6] "=m" (regs->regs[22]),
+		  [s7] "=m" (regs->regs[23]),
+		  [gp] "=m" (regs->regs[28]),
+		  [sp] "=m" (regs->regs[29]),
+		  [fp] "=m" (regs->regs[30]),
+		  [ra] "=m" (regs->regs[31])
  		: : "memory");
  }

diff -urN linux-2.6.25.1/include/asm-mips/thread-backtrace.h 
linux-t/include/asm-mips/thread-backtrace.h
--- linux-2.6.25.1/include/asm-mips/thread-backtrace.h	1969-12-31 
16:00:00.000000000 -0800
+++ linux-t/include/asm-mips/thread-backtrace.h	2008-05-06 
17:30:09.000000000 -0700
@@ -0,0 +1,229 @@
+/*
+ *				thread-backtrace.h
+ *
+ * Backtrace code for Linux operating system processes. This means that, in
+ * addition to handling the normal ABI-conformant stack frames, it must 
also
+ * handle Linux-specific signal stack frames.
+ *
+ * Copyright (C) 2007  Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
02110-1301  USA
+ */
+
+#ifndef	_THREAD_BACKTRACE_H_
+#define	_THREAD_BACKTRACE_H_
+#include <asm/simple-backtrace.h>
+#include <asm/ptrace.h>
+
+/* Value to be returned by the function that processes each frame to 
indicate
+ * a non-error termination of the backtrace. */
+#define	THREAD_BACKTRACE_END	1
+
+/* Value returned internally by functions called from thread_backtrace to
+ * indicate that the backtrace should terminate. */
+#define THREAD_BACKTRACE_DONE	2
+
+#define	NUM_SIGARGS	4		/* # of signal function arguments */
+
+enum thread_frame_type {
+	THREAD_FRAME_SIMPLE, THREAD_FRAME_SIGNAL, THREAD_FRAME_RT_SIGNAL
+};
+
+/*
+ * This function must be supplied by the caller.
+ *
+ * Get a 64-bit object from memory. This is used by the register values
+ * in a sigframe structure.
+ * Params:	rp		Address of the value.
+ *		reg		Location in which to store the value.
+ * Returns:	Zero on success, otherwise a negative errno value.
+ */
+typedef int (*get_sc_reg_t) (reg_t rp, reg_t *sc_reg);
+
+/*
+ * Configuration information
+ */
+struct thread_bt_config {
+	struct simple_bt_config	simple_config;
+	get_sc_reg_t		get_sc_reg;
+};
+
+/*
+ * Contains register information (s0-s8, sp, pc), the stack frame type and,
+ * if the stack frame type is THREAD_FRAME_SIGNAL or 
THREAD_FRAME_RT_SIGNAL,
+ * the arguments to the signal handler.
+ */
+struct thread_bt {
+	struct simple_bt	sbt;
+	const struct thread_bt_config	*config;
+	enum thread_frame_type	type;
+	reg_t			sigargs [NUM_SIGARGS]; /* Arguments to */
+					/* the signal handler */
+	/* Protected */
+	int			pc_is_return_address; /* If non-zero, the */
+					/* $pc value is the address saved */
+					/* by a jalr instruction, and thus */
+					/* should be decremented by two times */
+					/* OPCODE_SIZE to point to the jalr */
+};
+
+/*
+ * This is the function that thread_backtrace will call for each frame that
+ * it finds. It can terminate the backtrace by returning 
THREAD_BACKTRACE_END,
+ * which be treated as a normal termination, or a negative errno value. 
Negative
+ * errno values will be, in turn, returned by thread_backtrace to its 
caller.
+ * then be returned by thread_backtrace.
+ * Params:	arg	Value passed to thread_backtrace.
+ *		bt	Pointer to the struct thread_bt object for the curent
+ *			stack frame.
+ * Returns:	Zero if the backtrace should continue, non-zero if the 
backtrace
+ *		should terminate. If the backtrace is terminating because an
+ *		error occurred, it should return a negative errno value. If the
+ *		backtrace is terminating because this function has reach the
+ *		end of the backtrace, it should return the positive value
+ *		THREAD_BACKTRACE_END.
+ */
+typedef	int (*process_thread_frame_t) (void *arg, struct thread_bt *bt);
+
+/* Store the given register. Assumes that $at points to the location
+ * for the store. This is the 32-bit version. */
+#define	STORE_REG(reg)	"sw	" #reg ",0($at)\n"
+
+/* Initialize the given struct thread_bt object that will be used in a call
+ * to thread_next_frame from the current function, or a function called 
by the
+ * current function. This should be the first thing in the function so that
+ * the values of the registers are not altered from their values on 
entry to
+ * the function. */
+#define	thread_backtrace_init_here(bt, config)	do {			\
+		/* First, store $sp. Note that we use $at to do this */	\
+		__asm__ __volatile__ (					\
+			"	.set	noat\n"				\
+			"	la	$at,%[sp]\n"	/* SP */	\
+				STORE_REG($sp)				\
+		:	[sp] "=m" ((bt)->sbt.gprs [REG_SP])		\
+		:							\
+		:	"at"						\
+		);							\
+		__asm__ __volatile__ (					\
+			"	la	$at,%[v0]\n"	/* V0 */	\
+				STORE_REG($2)				\
+			"	la	$at,%[v1]\n"	/* V1 */	\
+				STORE_REG($3)				\
+									\
+			"	la	$at,%[a0]\n"	/* A0 */	\
+				STORE_REG($4)				\
+			"	la	$at,%[a1]\n"	/* A1 */	\
+				STORE_REG($5)				\
+			"	la	$at,%[a2]\n"	/* A2 */	\
+				STORE_REG($6)				\
+			"	la	$at,%[a3]\n"	/* A3 */	\
+				STORE_REG($7)				\
+									\
+			"	la	$at,%[t0]\n"	/* T0 */	\
+				STORE_REG($8)				\
+			"	la	$at,%[t1]\n"	/* T1 */	\
+				STORE_REG($9)				\
+			"	la	$at,%[t2]\n"	/* T2 */	\
+				STORE_REG($10)				\
+			"	la	$at,%[t3]\n"	/* T3 */	\
+				STORE_REG($11)				\
+			"	la	$at,%[t4]\n"	/* T4 */	\
+				STORE_REG($12)				\
+			"	la	$at,%[t5]\n"	/* T5 */	\
+				STORE_REG($13)				\
+			"	la	$at,%[t6]\n"	/* T6 */	\
+				STORE_REG($14)				\
+			"	la	$at,%[t7]\n"	/* T7 */	\
+				STORE_REG($15)				\
+									\
+			"	la	$at,%[s0]\n"	/* S0 */	\
+				STORE_REG($16)				\
+			"	la	$at,%[s1]\n"	/* S1 */	\
+				STORE_REG($17)				\
+			"	la	$at,%[s2]\n"	/* S2 */	\
+				STORE_REG($18)				\
+			"	la	$at,%[s3]\n"	/* S3 */	\
+				STORE_REG($19)				\
+			"	la	$at,%[s4]\n"	/* S4 */	\
+				STORE_REG($20)				\
+			"	la	$at,%[s5]\n"	/* S5 */	\
+				STORE_REG($21)				\
+			"	la	$at,%[s6]\n"	/* S6 */	\
+				STORE_REG($22)				\
+			"	la	$at,%[s7]\n"	/* S7 */	\
+				STORE_REG($23)				\
+									\
+			"	la	$at,%[t8]\n"	/* T8 */	\
+				STORE_REG($24)				\
+			"	la	$at,%[t9]\n"	/* T9 */	\
+				STORE_REG($25)				\
+									\
+			"	la	$at,%[k0]\n"	/* K0 */	\
+				STORE_REG($26)				\
+			"	la	$at,%[k1]\n"	/* K1 */	\
+				STORE_REG($27)				\
+									\
+			"	la	$at,%[gp]\n"	/* GP */	\
+				STORE_REG($gp)				\
+			"	la	$at,%[s8]\n"	/* FP/S8 */	\
+				STORE_REG($fp)				\
+			"	la	$at,%[ra]\n"	/* RA */	\
+				STORE_REG($ra)				\
+		:	[v0] "=m" ((bt)->sbt.gprs [REG_V0]),		\
+			[v1] "=m" ((bt)->sbt.gprs [REG_V1]),		\
+			[a0] "=m" ((bt)->sbt.gprs [REG_A0]),		\
+			[a1] "=m" ((bt)->sbt.gprs [REG_A1]),		\
+			[a2] "=m" ((bt)->sbt.gprs [REG_A2]),		\
+			[a3] "=m" ((bt)->sbt.gprs [REG_A3]),		\
+			[t0] "=m" ((bt)->sbt.gprs [REG_T0]),		\
+			[t1] "=m" ((bt)->sbt.gprs [REG_T1]),		\
+			[t2] "=m" ((bt)->sbt.gprs [REG_T2]),		\
+			[t3] "=m" ((bt)->sbt.gprs [REG_T3]),		\
+			[t4] "=m" ((bt)->sbt.gprs [REG_T4]),		\
+			[t5] "=m" ((bt)->sbt.gprs [REG_T5]),		\
+			[t6] "=m" ((bt)->sbt.gprs [REG_T6]),		\
+			[t7] "=m" ((bt)->sbt.gprs [REG_T7]),		\
+			[s0] "=m" ((bt)->sbt.gprs [REG_S0]),		\
+			[s1] "=m" ((bt)->sbt.gprs [REG_S1]),		\
+			[s2] "=m" ((bt)->sbt.gprs [REG_S2]),		\
+			[s3] "=m" ((bt)->sbt.gprs [REG_S3]),		\
+			[s4] "=m" ((bt)->sbt.gprs [REG_S4]),		\
+			[s5] "=m" ((bt)->sbt.gprs [REG_S5]),		\
+			[s6] "=m" ((bt)->sbt.gprs [REG_S6]),		\
+			[s7] "=m" ((bt)->sbt.gprs [REG_S7]),		\
+			[t8] "=m" ((bt)->sbt.gprs [REG_T8]),		\
+			[t9] "=m" ((bt)->sbt.gprs [REG_T9]),		\
+			[k0] "=m" ((bt)->sbt.gprs [REG_K0]),		\
+			[k1] "=m" ((bt)->sbt.gprs [REG_K1]),		\
+			[gp] "=m" ((bt)->sbt.gprs [REG_GP]),		\
+			[s8] "=m" ((bt)->sbt.gprs [REG_S8]),		\
+			[ra] "=m" ((bt)->sbt.gprs [REG_RA])		\
+		:							\
+		: "at"							\
+		);							\
+		thread_backtrace_init(bt, config);			\
+		(bt)->sbt.pc = thread_backtrace_here();			\
+	} while (0)
+
+extern int thread_backtrace(process_thread_frame_t process, void *arg,
+	const struct thread_bt_config *config);
+extern void thread_backtrace_init(struct thread_bt *bt,
+	const struct thread_bt_config *config);
+extern reg_t thread_backtrace_here(void);
+extern int thread_backtrace_first(struct thread_bt *bt);
+extern int thread_backtrace_next(struct thread_bt *bt);
+extern int thread_backtrace_pop_frame(struct thread_bt *bt);
+extern int thread_backtrace_analyze_frame(struct thread_bt *bt);
+#endif	/* _THREAD_BACKTRACE_H_ */

From anemo@mba.ocn.ne.jp Thu May  8 05:39:08 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 05:39:10 +0100 (BST)
Received: from topsns2.toshiba-tops.co.jp ([202.230.225.126]:37706 "EHLO
	topsns2.toshiba-tops.co.jp") by ftp.linux-mips.org with ESMTP
	id S20022495AbYEHEjI (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 05:39:08 +0100
Received: from topsms.toshiba-tops.co.jp by topsns2.toshiba-tops.co.jp
          via smtpd (for ftp.linux-mips.org [213.58.128.207]) with ESMTP; Thu, 8 May 2008 13:39:06 +0900
Received: from topsms.toshiba-tops.co.jp (localhost.localdomain [127.0.0.1])
	by localhost.toshiba-tops.co.jp (Postfix) with ESMTP id 16D3D1EF46;
	Thu,  8 May 2008 13:39:00 +0900 (JST)
Received: from srd2sd.toshiba-tops.co.jp (srd2sd.toshiba-tops.co.jp [172.17.28.2])
	by topsms.toshiba-tops.co.jp (Postfix) with ESMTP id 0A9C71EF42;
	Thu,  8 May 2008 13:39:00 +0900 (JST)
Received: from localhost (fragile [172.17.28.65])
	by srd2sd.toshiba-tops.co.jp (8.12.10/8.12.10) with ESMTP id m484clAF080531;
	Thu, 8 May 2008 13:38:49 +0900 (JST)
	(envelope-from anemo@mba.ocn.ne.jp)
Date:	Thu, 08 May 2008 13:38:47 +0900 (JST)
Message-Id: <20080508.133847.74565891.nemoto@toshiba-tops.co.jp>
To:	macro@linux-mips.org
Cc:	a.zummo@towertech.it, khali@linux-fr.org, ralf@linux-mips.org,
	tglx@linutronix.de, akpm@linux-foundation.org,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	ab@mycable.de, mgreer@mvista.com
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80, etc. driver
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <Pine.LNX.4.55.0805070102460.16173@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070102460.16173@cliff.in.clinika.pl>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19145
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
Content-Length: 5698
Lines: 177

Added CC to authers of the driver.

On Wed, 7 May 2008 01:40:41 +0100 (BST), "Maciej W. Rozycki" <macro@linux-mips.org> wrote:
>  The BCM1250A SOC which is used on the SWARM board utilising an M41T81
> chip only supports pure I2C in the raw bit-banged mode.  Nobody sane
> really wants to use it unless absolutely necessary and the M41T80, etc.  
> chips work just fine with an SMBus controller which is what the standard
> mode of operation of the BCM1250A.  The only drawback of byte accesses
> with the M41T80 is the chip only latches clock data registers for the
> duration of an I2C transaction which works fine with a block transfers,
> but not byte-wise accesses.
> 
>  The driver currently requires an I2C controller providing both SMBus and
> pure I2C access.  This is a set of changes to make it work with either,
> with a preference to pure I2C.  The problem of unlatched clock data if
> SMBus transactions are used is resolved in the standard way.
> 
>  Whether a choice between SMBus and pure I2C access is possible is 
> obviously device dependent.  If the code proved useful for other I2C 
> devices, then it could be moved to a more generic place.  It is a code
> simplification regardless -- similar I2C packet definitions are not 
> scattered throughout the driver anymore.
> 
> Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
> ---
>  Please note I have no means to test these changes with a pure I2C 
> controller -- anybody interested, please help.

I tested this with i2c-gpio.  It needs some fix.  Detailed below.

> -static int m41t80_get_datetime(struct i2c_client *client,
> -			       struct rtc_time *tm)
> +
> +static int m41t80_i2c_transfer(struct i2c_client *client, int write,
> +			       u8 reg, u8 num, u8 *buf)
>  {
> -	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
>  	struct i2c_msg msgs[] = {
>  		{
>  			.addr	= client->addr,
>  			.flags	= 0,
>  			.len	= 1,
> -			.buf	= dt_addr,
> +			.buf	= &reg,
>  		},
>  		{
>  			.addr	= client->addr,
> -			.flags	= I2C_M_RD,
> -			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
> -			.buf	= buf + M41T80_REG_SEC,
> +			.flags	= write ? 0 : I2C_M_RD,
> +			.len	= num,
> +			.buf	= buf,
>  		},
>  	};
>  
> -	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
> -		dev_err(&client->dev, "read error\n");
> -		return -EIO;
> +	return i2c_transfer(client->adapter, msgs, 2);
> +}

For write transfer, you must use only one i2c_msg.  If two i2c_msg
were used, the slave address is inserted between register number and
first data.  This chip cannot accept such sequence.

> +static int m41t80_transfer(struct i2c_client *client, int write,
> +			   u8 reg, u8 num, u8 *buf)
> +{
> +	int i, rc;
> +
> +	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
> +		return m41t80_i2c_transfer(client, write, reg, num, buf);

On success, m41t80_i2c_transfer() returns positive value, but
m41t80_transfer() should return 0.


Here is a proposed fix on top of your patch.

--- drivers/rtc/rtc-m41t80.c.orig	2008-05-08 11:08:57.000000000 +0900
+++ drivers/rtc/rtc-m41t80.c	2008-05-08 12:30:49.000000000 +0900
@@ -83,8 +83,8 @@ struct m41t80_data {
 };
 
 
-static int m41t80_i2c_transfer(struct i2c_client *client, int write,
-			       u8 reg, u8 num, u8 *buf)
+static int m41t80_i2c_read_transfer(struct i2c_client *client,
+				    u8 reg, u8 num, u8 *buf)
 {
 	struct i2c_msg msgs[] = {
 		{
@@ -95,7 +95,7 @@ static int m41t80_i2c_transfer(struct i2
 		},
 		{
 			.addr	= client->addr,
-			.flags	= write ? 0 : I2C_M_RD,
+			.flags	= I2C_M_RD,
 			.len	= num,
 			.buf	= buf,
 		},
@@ -104,13 +104,29 @@ static int m41t80_i2c_transfer(struct i2
 	return i2c_transfer(client->adapter, msgs, 2);
 }
 
+static int m41t80_i2c_write_transfer(struct i2c_client *client,
+				     u8 reg, u8 num, u8 *buf)
+{
+	u8 wbuf[M41T80_DATETIME_REG_SIZE + 1];
+	struct i2c_msg msg = {
+		.addr	= client->addr,
+		.flags	= 0,
+		.len	= num + 1,
+		.buf	= wbuf,
+	};
+
+	wbuf[0] = reg;
+	memcpy(wbuf + 1, buf, num);
+	return i2c_transfer(client->adapter, &msg, 1);
+}
+
 static int m41t80_read_byte_data(struct i2c_client *client, u8 reg)
 {
 	int rc;
 	u8 val;
 
 	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		rc = m41t80_i2c_transfer(client, 0, reg, 1, &val);
+		rc = m41t80_i2c_read_transfer(client, reg, 1, &val);
 		if (rc < 0)
 			return rc;
 		else
@@ -122,7 +138,7 @@ static int m41t80_read_byte_data(struct 
 static int m41t80_write_byte_data(struct i2c_client *client, u8 reg, u8 val)
 {
 	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
-		return m41t80_i2c_transfer(client, 1, reg, 1, &val);
+		return m41t80_i2c_write_transfer(client, reg, 1, &val);
 	else
 		return i2c_smbus_write_byte_data(client, reg, val);
 }
@@ -132,16 +148,20 @@ static int m41t80_transfer(struct i2c_cl
 {
 	int i, rc;
 
-	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
-		return m41t80_i2c_transfer(client, write, reg, num, buf);
-	else if (write) {
+	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		if (write)
+			rc = m41t80_i2c_write_transfer(client, reg, num, buf);
+		else
+			rc = m41t80_i2c_read_transfer(client, reg, num, buf);
+		if (rc < 0)
+			return rc;
+	} else if (write) {
 		for (i = 0; i < num; i++) {
 			rc = i2c_smbus_write_byte_data(client, reg + i,
 						       buf[i]);
 			if (rc < 0)
 				return rc;
 		}
-		return 0;
 	} else {
 		for (i = 0; i < num; i++) {
 			rc = i2c_smbus_read_byte_data(client, reg + i);
@@ -149,8 +169,8 @@ static int m41t80_transfer(struct i2c_cl
 				return rc;
 			buf[i] = rc;
 		}
-		return 0;
 	}
+	return 0;
 }
 
 static int m41t80_get_datetime(struct i2c_client *client, struct rtc_time *tm)

From ralf@linux-mips.org Thu May  8 05:51:23 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 05:51:25 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:19421 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20022210AbYEHEvX (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 05:51:23 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m484p8cn001412;
	Thu, 8 May 2008 05:51:08 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m484p6Ob001399;
	Thu, 8 May 2008 05:51:06 +0100
Date:	Thu, 8 May 2008 05:51:06 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Jean Delvare <khali@linux-fr.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080508045106.GB25531@linux-mips.org>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl> <20080507085953.2c08b854@hyperion.delvare> <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19146
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 430
Lines: 10

On Wed, May 07, 2008 at 10:13:23PM +0100, Maciej W. Rozycki wrote:

>  Ralf -- what do you think about the Makefile changes?  I can send you a 
> separate patch which will reduce the span of this one.

I like it; we maybe should consider getting rid of most of the libs-* stuff
in arch/mips/Makefile.  Some of it might be causing subtle bugs such as
routines exported to modules not getting linked into the kernel proper.

  Ralf

From ralf@linux-mips.org Thu May  8 05:57:58 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 05:58:00 +0100 (BST)
Received: from [217.169.26.28] ([217.169.26.28]:58851 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20023055AbYEHE56 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 05:57:58 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m484vgnM003928;
	Thu, 8 May 2008 05:57:42 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m484vfdM003921;
	Thu, 8 May 2008 05:57:41 +0100
Date:	Thu, 8 May 2008 05:57:41 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Jean Delvare <khali@linux-fr.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080508045741.GC25531@linux-mips.org>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl> <20080507090514.3a86cf4b@hyperion.delvare> <Pine.LNX.4.64.0805070936060.6341@anakin> <20080507094343.25f279b9@hyperion.delvare> <Pine.LNX.4.55.0805072214090.25644@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.55.0805072214090.25644@cliff.in.clinika.pl>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19147
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1512
Lines: 30

On Wed, May 07, 2008 at 10:25:08PM +0100, Maciej W. Rozycki wrote:

> > > > i2c-foo.c is consistently used for i2c bus driver themselves so far.
> > > > It's somewhat confusing to see you name platform code that way. It's
> > > > also redundant, given that the file lives in the swarm platform
> > > > directory. May I suggest naming this file just
> > > > arch/mips/sibyte/swarm/i2c.c? Other architectures (cris, arm) are doing
> > > > this already.

>  I can do that and I have considered it while preparing the change.  What
> convinced me not to use a name that is already present elsewhere in the
> tree is the confusion that it sometimes causes.  For example during a
> debugging session GDB only reports the file name and not the leading
> pathname (and some people do run GDB over the kernel).  Of course the
> actual file can still be chased with some `find' and `grep' scriptery, but
> why to create a problem in the first place?
> 
>  I consider repeated file names throughout a tree of a single program a 
> namespace pollution similar to one with repeated static symbol names.  
> While syntactically valid and working, it asks for unnecessary confusion.
> 
>  This is my point of view, but I can see others may not necessarily follow
> it.  I am fine with changing the name to i2c.c as it is unlikely I will
> run GDB over it. ;-)

I've started using unique prefixes such as ip22- or ip27- a while ago.
And why not following that example with arch/mips/sibyte/swarm/swarm-i2c.c
or similar?

  Ralf

From abhiruchi.g@vaultinfo.com Thu May  8 08:11:20 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 08:11:22 +0100 (BST)
Received: from smtp177.iad.emailsrvr.com ([207.97.245.177]:468 "EHLO
	smtp177.iad.emailsrvr.com") by ftp.linux-mips.org with ESMTP
	id S20021379AbYEHHLU convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 08:11:20 +0100
Received: from relay7.relay.iad.mlsrvr.com (localhost [127.0.0.1])
	by relay7.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id 4D8EF1B4C8B;
	Thu,  8 May 2008 03:11:05 -0400 (EDT)
Received: from vaultinfo.com (webmail12.webmail.iad.mlsrvr.com [192.168.1.33])
	by relay7.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id 486D81B4A38;
	Thu,  8 May 2008 03:11:05 -0400 (EDT)
Received: by webmail.mailsin.net
    (Authenticated sender: abhiruchi.g@vaultinfo.com, from: abhiruchi.g@vaultinfo.com) 
    with HTTP; Thu, 8 May 2008 03:11:05 -0400 (EDT)
Date:	Thu, 8 May 2008 03:11:05 -0400 (EDT)
Subject: Alchemy DB1200 
From:	abhiruchi.g@vaultinfo.com
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Reply-To: abhiruchi.g@vaultinfo.com
MIME-Version: 1.0
Content-Type: text/plain;charset=UTF-8
Content-Transfer-Encoding: 8BIT
Importance: Normal
X-Priority: 3 (Normal)
X-Type:	1
Message-ID: <40369.192.168.1.71.1210230665.webmail@192.168.1.71>
X-Mailer: webmail6.6.1
Return-Path: <abhiruchi.g@vaultinfo.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19148
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: abhiruchi.g@vaultinfo.com
Precedence: bulk
X-list: linux-mips
Content-Length: 5734
Lines: 151

I am trying to build kernel for DB1200 board.
but kernel hangs after the following output:

Image Loaded Successfully.
---------------------------------------------
Program Entry Point: 80536000
Executing Application
Linux version 2.6.22 (abhi@linux-3s9p) (gcc version 4.2.1) #75 PREEMPT Mon Apr 8
CPU revision is: 04030201
AMD Alchemy Db1200 Board
(PRId 04030201) @ 396MHZ
Determined physical RAM map:
memory: 08000000 @ 00000000 (usable)
User-defined physical RAM map:
memory: 08000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
Built 1 zonelists.  Total pages: 32512
Kernel command line: rootdelay=10 rootfstype=ext2 mem=128M root=/dev/sda1   vid0
Primary instruction cache 16kB, physically tagged, 4-way, linesize 32 bytes.
Primary data cache 16kB, 4-way, linesize 32 bytes.
Synthesized TLB refill handler (17 instructions).
Synthesized TLB load handler fastpath (34 instructions).
Synthesized TLB store handler fastpath (34 instructions).
Synthesized TLB modify handler fastpath (33 instructions).
PID hash table entries: 512 (order: 9, 2048 bytes)
calculating r4koff... 00060ae0(396000)
CPU frequency 396.00 MHz
Console: colour dummy device 80x25
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 124032k/131072k available (3069k kernel code, 6904k reserved, 1238k dat)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Bluetooth: Core ver 2.11
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Time: MIPS clocksource has been installed.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
JFS: nTxBlock = 970, nTxLock = 7760
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
au1200fb: LCD controller driver for AU1200 processors
au1200fb: Panel 0 QVGA_320x240
au1200fb: Win 2 0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx
Panel(QVGA_320x240), 320x240




Console: switching to colour frame buffer device 40x30














Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250.9: ttyS0 at MMIO 0x11100000 (irq = 0) is a 16550A
serial8250.9: ttyS1 at MMIO 0x11200000 (irq = 8) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
nbd: registered device at major 43
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
Au1xxx IDE(builtin) configured for PIO+DDMA(offload)
au1xxx-ehci au1xxx-ehci.0: Au1xxx EHCI
au1xxx-ehci au1xxx-ehci.0: new USB bus registered, assigned bus number 1
au1xxx-ehci au1xxx-ehci.0: irq 29, io mem 0x14020200
au1xxx-ehci au1xxx-ehci.0: USB 0.0 started, EHCI 1.00, driver 10 Dec 2004
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
au1xxx-ohci au1xxx-ohci.0: Au1xxx OHCI
au1xxx-ohci au1xxx-ohci.0: new USB bus registered, assigned bus number 2
au1xxx-ohci au1xxx-ohci.0: irq 29, io mem 0x14020100
usb usb2: configuration #1 chosen from 1 choice
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usb 1-1: new high speed USB device using au1xxx-ehci and address 2
Initializing USB Mass Storage driver...
usb 1-1: configuration #1 chosen from 1 choice
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
usb 1-1.2: new high speed USB device using au1xxx-ehci and address 3
usb 1-1.2: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
Bluetooth: HCI USB driver ver 2.9
usbcore: registered new interface driver hci_usb
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
TCP cubic registered
NET: Registered protocol family 17
Bluetooth: L2CAP ver 2.8
Bluetooth: L2CAP socket layer initialized
Bluetooth: SCO (Voice Link) ver 0.5
Bluetooth: SCO socket layer initialized
Bluetooth: HIDP (Human Interface Emulation) ver 1.2
ieee80211: 802.11 data/management/control stack, git-1.1.13
ieee80211: Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
Waiting 10sec before mounting root device...
scsi 0:0:0:0: Direct-Access     Ut163    USB2FlashStorage 0.00 PQ: 0 ANSI: 2
sd 0:0:0:0: [sda] 983808 512-byte hardware sectors (504 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] 983808 512-byte hardware sectors (504 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda:<7>usb-storage: queuecommand called
sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk
sd 0:0:0:0: Attached scsi generic sg0 type 0
VFS: Mounted root (ext2 filesystem) readonly.
mount_block_root: name=/dev/root fs=ext2 flags=32769
Freeing unused kernel memory: 164k freed
Warning: unable to open an initial console.
Algorithmics/MIPS FPU Emulator v1.5




what could be the problem?
Is this creating any problem?
sda:<7>usb-storage: queuecommand called




From stehbrettsegeln@gmx.de Thu May  8 08:38:49 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 08:38:52 +0100 (BST)
Received: from mail.gmx.net ([213.165.64.20]:12490 "HELO mail.gmx.net")
	by ftp.linux-mips.org with SMTP id S20021650AbYEHHit convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 08:38:49 +0100
Received: (qmail invoked by alias); 08 May 2008 07:38:43 -0000
Received: from unknown (EHLO localhost) [86.56.122.148]
  by mail.gmx.net (mp023) with SMTP; 08 May 2008 09:38:43 +0200
X-Authenticated: #2913508
X-Provags-ID: V01U2FsdGVkX1/KproR/mPKll64QaAnAinpz/1cB9THNuTiq1PVQt
	N3YiqB7kQzHsbL
Date:	Thu, 08 May 2008 09:38:41 +0200
To:	abhiruchi.g@vaultinfo.com
Subject: Re: Alchemy DB1200
From:	"Thorsten Schulz" <stehbrettsegeln@gmx.de>
Cc:	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=utf-8
MIME-Version: 1.0
References: <40369.192.168.1.71.1210230665.webmail@192.168.1.71>
Content-Transfer-Encoding: 8BIT
Message-ID: <op.uatrirwg33s53m@localhost>
In-Reply-To: <40369.192.168.1.71.1210230665.webmail@192.168.1.71>
User-Agent: Opera Mail/9.27 (Linux)
X-Y-GMX-Trusted: 0
Return-Path: <stehbrettsegeln@gmx.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19149
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: stehbrettsegeln@gmx.de
Precedence: bulk
X-list: linux-mips
Content-Length: 1372
Lines: 33

Hi,

do you actually have that console device on your usb-stick?

mknod -m 0600 /path/to/stick/dev/console c 5 1
mknod -m 0777 /path/to/stick/mnt/dev/null c 1 3

Thorsten

PS btw. could you mail me your config/initramfslist/init how you got the kernel to boot the rootfs from usb, i never managed to. I am working on an au1550 system thats mtd-flash has problems with recent kernels.

On Thu, 08 May 2008 09:11:05 +0200, <abhiruchi.g@vaultinfo.com> wrote:

> I am trying to build kernel for DB1200 board.
> but kernel hangs after the following output:

> Waiting 10sec before mounting root device...
> scsi 0:0:0:0: Direct-Access     Ut163    USB2FlashStorage 0.00 PQ: 0 ANSI: 2
> sd 0:0:0:0: [sda] 983808 512-byte hardware sectors (504 MB)
> sd 0:0:0:0: [sda] Write Protect is off
> sd 0:0:0:0: [sda] Assuming drive cache: write through
> sd 0:0:0:0: [sda] 983808 512-byte hardware sectors (504 MB)
> sd 0:0:0:0: [sda] Write Protect is off
> sd 0:0:0:0: [sda] Assuming drive cache: write through
> sda:<7>usb-storage: queuecommand called
> sda1
> sd 0:0:0:0: [sda] Attached SCSI removable disk
> sd 0:0:0:0: Attached scsi generic sg0 type 0
> VFS: Mounted root (ext2 filesystem) readonly.
> mount_block_root: name=/dev/root fs=ext2 flags=32769
> Freeing unused kernel memory: 164k freed
> Warning: unable to open an initial console.
> Algorithmics/MIPS FPU Emulator v1.5

From khali@linux-fr.org Thu May  8 08:57:15 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 08:57:17 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:18297 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20022549AbYEHH5P (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 08:57:15 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Ju1wF-0005Rg-Ag
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Thu, 08 May 2008 10:57:19 +0200
Date:	Thu, 8 May 2008 09:56:58 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Geert Uytterhoeven <geert@linux-m68k.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080508095658.40eb74f4@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805072214090.25644@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
	<20080507090514.3a86cf4b@hyperion.delvare>
	<Pine.LNX.4.64.0805070936060.6341@anakin>
	<20080507094343.25f279b9@hyperion.delvare>
	<Pine.LNX.4.55.0805072214090.25644@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19150
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2370
Lines: 53

Hi Maciej,

On Wed, 7 May 2008 22:25:08 +0100 (BST), Maciej W. Rozycki wrote:
> > i2c-foo.c is consistently used for i2c bus driver themselves so far.
> > It's somewhat confusing to see you name platform code that way. It's
> > also redundant, given that the file lives in the swarm platform
> > directory. May I suggest naming this file just
> > arch/mips/sibyte/swarm/i2c.c? Other architectures (cris, arm) are doing
> > this already.
>
>  I can do that and I have considered it while preparing the change.  What
> convinced me not to use a name that is already present elsewhere in the
> tree is the confusion that it sometimes causes.  For example during a
> debugging session GDB only reports the file name and not the leading
> pathname (and some people do run GDB over the kernel).  Of course the
> actual file can still be chased with some `find' and `grep' scriptery, but
> why to create a problem in the first place?
>
>  I consider repeated file names throughout a tree of a single program a 
> namespace pollution similar to one with repeated static symbol names.  
> While syntactically valid and working, it asks for unnecessary confusion.

$ find linux-2.6.26-rc1 -name Kconfig | wc -l
455
$ find linux-2.6.26-rc1 -name Makefile | wc -l
1030
$

Not to mention the 102 setup.c, 87 irq.c, 62 time.c... It is very
common to have duplicated file names in the kernel tree because it
supports so many architectures and platforms. In general, when you work
on a given architecture or platform, names become unique again. Taking
GDB as an example again, you definitely know what architecture you are
debugging, so there should be relatively little ambiguity on what files
are involved.

(On top of that, I'd argue that we _should_ be able to display relative
paths to file names when debugging.)

Your point about the "single program namespace" is certainly valid for
small to medium-size programs, but in the case of something as big as
the kernel, it probably no longer holds.

>  This is my point of view, but I can see others may not necessarily follow
> it.  I am fine with changing the name to i2c.c as it is unlikely I will
> run GDB over it. ;-)

I don't have a strong opinion on this either, it is very unlikely that
I'll ever have to deal with this file personally. I'm only telling you
what the common practice is in the kernel tree.

-- 
Jean Delvare

From mano@roarinelk.homelinux.net Thu May  8 09:00:43 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:00:46 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:960 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022622AbYEHIAn (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:00:43 +0100
Received: (qmail 24467 invoked by uid 1000); 8 May 2008 10:00:40 +0200
Date:	Thu, 8 May 2008 10:00:40 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/7] au1xmmc updates, #2
Message-ID: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19151
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 1193
Lines: 29

Hello,

The following set of patches remove demoboard-specific code from the
au1xmmc.c driver and add new features.

My main motivation was to let boards implement other carddetect schemes,
since on one of my boards the driver-implemented poll timer doesn't work
for some unknown reason.  But this board does have a dedicated carddetect
IRQ and card-present/card-readonly indicators which are incompatible with
the Db1200 implementation.  I also took the opportunity to clean up the
drivers probe() and irq() handlers to make it a "proper" platform device
(patches #3 and #4).

Patch #1 is required to get the driver to build as a module.
Patch #2 is required to be able to load/unload the driver > 16 times.
Patches #5 and #6 implement new features.
Patch #7 does a little codingstyle cleanup, no functional changes.

Change since V1:
- fix a bug in patch #6: SDIO irq should be checked for independently
  from other irq events.
- more trivial cleanups

Db1200 users, please test!  I verified the poll timer works on one of
older boards, however since I don't have Db1200 and Pb1200 boards I'm
not sure whether the driver still works with both SD controllers enabled!

Thanks!
	Manuel Lauss

From mano@roarinelk.homelinux.net Thu May  8 09:01:31 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:01:34 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:17082 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022720AbYEHIBb (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:01:31 +0100
Received: (qmail 24494 invoked by uid 1000); 8 May 2008 10:01:30 +0200
Date:	Thu, 8 May 2008 10:01:30 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/7] Alchemy: export get_au1x00_speed for modules
Message-ID: <20080508080130.GB24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19152
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 9c59794676b21768624335cc21a7f455b4e69057 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 13:42:55 +0200
Subject: [PATCH] Alchemy: export get_au1x00_speed for modules
Content-Length: 546
Lines: 23

au1xmmc.c driver depends on it, so export it for modules.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/au1000/common/clocks.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mips/au1000/common/clocks.c b/arch/mips/au1000/common/clocks.c
index 3ce6cac..6dbc87a 100644
--- a/arch/mips/au1000/common/clocks.c
+++ b/arch/mips/au1000/common/clocks.c
@@ -46,7 +46,7 @@ unsigned int get_au1x00_speed(void)
 {
 	return au1x00_clock;
 }
-
+EXPORT_SYMBOL(get_au1x00_speed);
 
 
 /*
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Thu May  8 09:02:12 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:02:15 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:18565 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022749AbYEHICM (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:02:12 +0100
Received: (qmail 24516 invoked by uid 1000); 8 May 2008 10:02:11 +0200
Date:	Thu, 8 May 2008 10:02:11 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] Alchemy: dbdma: add API to delete custom DDMA device
	ids
Message-ID: <20080508080211.GC24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19153
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 41ebbbe49861a65f28947768db7945a5099673d3 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 13:45:23 +0200
Subject: [PATCH] Alchemy: dbdma: add API to delete custom DDMA device ids.
Content-Length: 1418
Lines: 45

Add API to delete custom DDMA device ids create with
au1xxx_ddma_device_add().

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/au1000/common/dbdma.c             |   10 ++++++++++
 include/asm-mips/mach-au1x00/au1xxx_dbdma.h |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/mips/au1000/common/dbdma.c b/arch/mips/au1000/common/dbdma.c
index 53377df..69171c6 100644
--- a/arch/mips/au1000/common/dbdma.c
+++ b/arch/mips/au1000/common/dbdma.c
@@ -220,6 +220,16 @@ au1xxx_ddma_add_device(dbdev_tab_t *dev)
 }
 EXPORT_SYMBOL(au1xxx_ddma_add_device);
 
+void au1xxx_ddma_del_device(u32 devid)
+{
+	dbdev_tab_t *p = find_dbdev_id(devid);
+	if (p != NULL) {
+		memset(p, 0, sizeof(dbdev_tab_t));
+		p->dev_id = ~0;
+	}
+}
+EXPORT_SYMBOL(au1xxx_ddma_del_device);
+
 /* Allocate a channel and return a non-zero descriptor if successful.
 */
 u32
diff --git a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
index 93d507c..5e33ff0 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
@@ -367,6 +367,7 @@ void au1xxx_dbdma_dump(u32 chanid);
 u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr );
 
 u32 au1xxx_ddma_add_device( dbdev_tab_t *dev );
+void au1xxx_ddma_del_device(u32 devid);
 void * au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp);
 
 /*
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Thu May  8 09:03:04 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:03:07 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:38099 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022795AbYEHIDE (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:03:04 +0100
Received: (qmail 24534 invoked by uid 1000); 8 May 2008 10:03:01 +0200
Date:	Thu, 8 May 2008 10:03:01 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] au1xmmc: remove db1x00 board-specific functions from
	driver
Message-ID: <20080508080301.GD24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19154
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 47ecf116465ed850d2202880f7795fcee4826184 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 14:57:01 +0200
Subject: [PATCH] au1xmmc: remove db1x00 board-specific functions from driver
Content-Length: 23186
Lines: 852

Remove the DB1200 board-specific functions (card present, read-only
methods) and instead add platform data which is passed to the driver.
This allows for platforms to implement other carddetect schemes
(e.g. dedicated irq) without having to pollute the driver code.
The poll timer (used for pb1200) is kept for compatibility.

With the board-specific stuff gone, the driver no longer needs to know
how many physical controllers the silicon actually has; every device
can be registered as needed, update the code to reflect that.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c                |  504 ++++++++++++++++++-----------
 drivers/mmc/host/au1xmmc.h                |   96 ------
 include/asm-mips/mach-au1x00/au1100_mmc.h |   43 +++-
 3 files changed, 346 insertions(+), 297 deletions(-)
 delete mode 100644 drivers/mmc/host/au1xmmc.h

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index cc5f7bc..8660f86 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -49,7 +49,6 @@
 #include <asm/mach-au1x00/au1100_mmc.h>
 
 #include <au1xxx.h>
-#include "au1xmmc.h"
 
 #define DRIVER_NAME "au1xxx-mmc"
 
@@ -61,31 +60,73 @@
 #define DBG(fmt, idx, args...)
 #endif
 
-const struct {
-	u32 iobase;
-	u32 tx_devid, rx_devid;
-	u16 bcsrpwr;
-	u16 bcsrstatus;
-	u16 wpstatus;
-} au1xmmc_card_table[] = {
-	{ SD0_BASE, DSCR_CMD0_SDMS_TX0, DSCR_CMD0_SDMS_RX0,
-	  BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
-#ifndef CONFIG_MIPS_DB1200
-	{ SD1_BASE, DSCR_CMD0_SDMS_TX1, DSCR_CMD0_SDMS_RX1,
-	  BCSR_BOARD_DS1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
-#endif
-};
+#define AU1XMMC_DESCRIPTOR_COUNT 1
+#define AU1XMMC_DESCRIPTOR_SIZE  4096
+
+#define AU1XMMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
+		     MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
+		     MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
+
+/* Easy access macros */
+
+#define HOST_STATUS(h)	((h)->iobase + SD_STATUS)
+#define HOST_CONFIG(h)	((h)->iobase + SD_CONFIG)
+#define HOST_ENABLE(h)	((h)->iobase + SD_ENABLE)
+#define HOST_TXPORT(h)	((h)->iobase + SD_TXPORT)
+#define HOST_RXPORT(h)	((h)->iobase + SD_RXPORT)
+#define HOST_CMDARG(h)	((h)->iobase + SD_CMDARG)
+#define HOST_BLKSIZE(h)	((h)->iobase + SD_BLKSIZE)
+#define HOST_CMD(h)	((h)->iobase + SD_CMD)
+#define HOST_CONFIG2(h)	((h)->iobase + SD_CONFIG2)
+#define HOST_TIMEOUT(h)	((h)->iobase + SD_TIMEOUT)
+#define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
+
+#define DMA_CHANNEL(h) \
+	(((h)->flags & HOST_F_XMIT) ? (h)->dma.tx_chan : (h)->dma.rx_chan)
+
+/* This gives us a hard value for the stop command that we can write directly
+ * to the command register
+ */
+
+#define STOP_CMD (SD_CMD_RT_1B | SD_CMD_CT_7 |		\
+		  (0xC << SD_CMD_CI_SHIFT) | SD_CMD_GO)
 
-#define AU1XMMC_CONTROLLER_COUNT (ARRAY_SIZE(au1xmmc_card_table))
+/* This is the set of interrupts that we configure by default */
+#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT |	\
+		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
+
+/* The poll event (looking for insert/remove events runs twice a second */
+#define AU1XMMC_DETECT_TIMEOUT (HZ/2)
+
+/* Status flags used by the host structure */
+#define HOST_F_XMIT   0x0001
+#define HOST_F_RECV   0x0002
+#define HOST_F_DMA    0x0010
+#define HOST_F_ACTIVE 0x0100
+#define HOST_F_STOP   0x1000
+
+#define HOST_S_IDLE   0x0001
+#define HOST_S_CMD    0x0002
+#define HOST_S_DATA   0x0003
+#define HOST_S_STOP   0x0004
 
-/* This array stores pointers for the hosts (used by the IRQ handler) */
-struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
 static int dma = 1;
 
-#ifdef MODULE
 module_param(dma, bool, 0);
 MODULE_PARM_DESC(dma, "Use DMA engine for data transfers (0 = disabled)");
-#endif
+
+/* 8bit memory device */
+static dbdev_tab_t au1xmmc_mem_dbdev = {
+	.dev_id		= DSCR_CMD0_ALWAYS,
+	.dev_flags	= DEV_FLAGS_ANYUSE,
+	.dev_tsize	= 0,
+	.dev_devwidth	= 8,
+	.dev_physaddr	= 0x00000000,
+	.dev_intlevel	= 0,
+	.dev_intpolarity = 0,
+};
+static int memid;
+
 
 static inline void IRQ_ON(struct au1xmmc_host *host, u32 mask)
 {
@@ -135,31 +176,37 @@ static inline void SEND_STOP(struct au1xmmc_host *host)
 
 static void au1xmmc_set_power(struct au1xmmc_host *host, int state)
 {
-
-	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
-
-	bcsr->board &= ~val;
-	if (state) bcsr->board |= val;
-
-	au_sync_delay(1);
+	if (host->platdata && host->platdata->set_power)
+		host->platdata->set_power(host->mmc, state);
 }
 
-static inline int au1xmmc_card_inserted(struct au1xmmc_host *host)
+static int au1xmmc_card_inserted(struct au1xmmc_host *host)
 {
-	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
-		? 1 : 0;
+	int ret;
+
+	if (host->platdata && host->platdata->card_inserted)
+		ret = host->platdata->card_inserted(host->mmc);
+	else
+		ret = 1;	/* assume there is a card */
+
+	return ret;
 }
 
 static int au1xmmc_card_readonly(struct mmc_host *mmc)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
-	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus)
-		? 1 : 0;
+	int ret;
+
+	if (host->platdata && host->platdata->card_readonly)
+		ret = host->platdata->card_readonly(mmc);
+	else
+		ret = 1;	/* assume card is read-only */
+
+	return ret;
 }
 
 static void au1xmmc_finish_request(struct au1xmmc_host *host)
 {
-
 	struct mmc_request *mrq = host->mrq;
 
 	host->mrq = NULL;
@@ -174,8 +221,6 @@ static void au1xmmc_finish_request(struct au1xmmc_host *host)
 
 	host->status = HOST_S_IDLE;
 
-	bcsr->disk_leds |= (1 << 8);
-
 	mmc_request_done(host->mmc, mrq);
 }
 
@@ -663,7 +708,9 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 	host->mrq = mrq;
 	host->status = HOST_S_CMD;
 
-	bcsr->disk_leds &= ~(1 << 8);
+	au_writel(0, HOST_STATUS(host));
+	au_sync();
+	FLUSH_FIFO(host);
 
 	if (mrq->data) {
 		FLUSH_FIFO(host);
@@ -749,118 +796,87 @@ static void au1xmmc_dma_callback(int irq, void *dev_id)
 
 static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 {
-
+	struct au1xmmc_host *host = dev_id;
 	u32 status;
-	int i, ret = 0;
 
-	disable_irq(AU1100_SD_IRQ);
+	status = au_readl(HOST_STATUS(host));
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct au1xmmc_host * host = au1xmmc_hosts[i];
-		u32 handled = 1;
+	if (!(status & (1 << 15)))
+		return IRQ_NONE;	/* not ours */
 
-		status = au_readl(HOST_STATUS(host));
+	if (host->mrq && (status & STATUS_TIMEOUT)) {
+		if (status & SD_STATUS_RAT)
+			host->mrq->cmd->error = -ETIMEDOUT;
+		else if (status & SD_STATUS_DT)
+			host->mrq->data->error = -ETIMEDOUT;
 
-		if (host->mrq && (status & STATUS_TIMEOUT)) {
-			if (status & SD_STATUS_RAT)
-				host->mrq->cmd->error = -ETIMEDOUT;
+		/* In PIO mode, interrupts might still be enabled */
+		IRQ_OFF(host, SD_CONFIG_NE | SD_CONFIG_TH);
 
-			else if (status & SD_STATUS_DT)
-				host->mrq->data->error = -ETIMEDOUT;
-
-			/* In PIO mode, interrupts might still be enabled */
-			IRQ_OFF(host, SD_CONFIG_NE | SD_CONFIG_TH);
-
-			//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
-			tasklet_schedule(&host->finish_task);
-		}
+		//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
+		tasklet_schedule(&host->finish_task);
+	}
 #if 0
-		else if (status & SD_STATUS_DD) {
-
-			/* Sometimes we get a DD before a NE in PIO mode */
-
-			if (!(host->flags & HOST_F_DMA) &&
-					(status & SD_STATUS_NE))
-				au1xmmc_receive_pio(host);
-			else {
-				au1xmmc_data_complete(host, status);
-				//tasklet_schedule(&host->data_task);
-			}
+	else if (status & SD_STATUS_DD) {
+		/* Sometimes we get a DD before a NE in PIO mode */
+		if (!(host->flags & HOST_F_DMA) && (status & SD_STATUS_NE))
+			au1xmmc_receive_pio(host);
+		else {
+			au1xmmc_data_complete(host, status);
+			//tasklet_schedule(&host->data_task);
 		}
-#endif
-		else if (status & (SD_STATUS_CR)) {
-			if (host->status == HOST_S_CMD)
-				au1xmmc_cmd_complete(host,status);
-		}
-		else if (!(host->flags & HOST_F_DMA)) {
-			if ((host->flags & HOST_F_XMIT) &&
-			    (status & STATUS_DATA_OUT))
-				au1xmmc_send_pio(host);
-			else if ((host->flags & HOST_F_RECV) &&
-			    (status & STATUS_DATA_IN))
-				au1xmmc_receive_pio(host);
-		}
-		else if (status & 0x203FBC70) {
-			DBG("Unhandled status %8.8x\n", host->id, status);
-			handled = 0;
-		}
-
-		au_writel(status, HOST_STATUS(host));
-		au_sync();
-
-		ret |= handled;
 	}
+#endif
+	else if (status & (SD_STATUS_CR)) {
+		if (host->status == HOST_S_CMD)
+			au1xmmc_cmd_complete(host,status);
 
-	enable_irq(AU1100_SD_IRQ);
-	return ret;
-}
-
-static void au1xmmc_poll_event(unsigned long arg)
-{
-	struct au1xmmc_host *host = (struct au1xmmc_host *) arg;
-
-	int card = au1xmmc_card_inserted(host);
-        int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
+	} else if (!(host->flags & HOST_F_DMA)) {
+		if ((host->flags & HOST_F_XMIT) && (status & STATUS_DATA_OUT))
+			au1xmmc_send_pio(host);
+		else if ((host->flags & HOST_F_RECV) && (status & STATUS_DATA_IN))
+			au1xmmc_receive_pio(host);
 
-	if (card != controller) {
-		host->flags &= ~HOST_F_ACTIVE;
-		if (card) host->flags |= HOST_F_ACTIVE;
-		mmc_detect_change(host->mmc, 0);
+	} else if (status & 0x203FBC70) {
+			DBG("Unhandled status %8.8x\n", host->id, status);
 	}
 
-	if (host->mrq != NULL) {
-		u32 status = au_readl(HOST_STATUS(host));
-		DBG("PENDING - %8.8x\n", host->id, status);
-	}
+	au_writel(status, HOST_STATUS(host));
+	au_sync();
 
-	mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT);
+	return IRQ_HANDLED;
 }
 
-static dbdev_tab_t au1xmmc_mem_dbdev =
-{
-	DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 8, 0x00000000, 0, 0
-};
-
-static void au1xmmc_init_dma(struct au1xmmc_host *host)
+static int au1xmmc_init_dma(struct au1xmmc_host *host)
 {
-
+	struct resource *res;
 	u32 rxchan, txchan;
+	int txid, rxid;
 
-	int txid = au1xmmc_card_table[host->id].tx_devid;
-	int rxid = au1xmmc_card_table[host->id].rx_devid;
-
-	/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
-	   of 8 bits.  And since devices are shared, we need to create
-	   our own to avoid freaking out other devices
-	*/
+	res = platform_get_resource(host->pdev, IORESOURCE_DMA, 0);
+	if (!res)
+		return -ENODEV;
+	txid = res->start;
 
-	int memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
+	res = platform_get_resource(host->pdev, IORESOURCE_DMA, 1);
+	if (!res)
+		return -ENODEV;
+	rxid = res->start;
 
 	txchan = au1xxx_dbdma_chan_alloc(memid, txid,
-					 au1xmmc_dma_callback, (void *) host);
+				au1xmmc_dma_callback, (void *)host);
+	if (!txchan) {
+		dev_err(&host->pdev->dev, "cannot allocate TX DMA\n");
+		return -ENODEV;
+	}
 
 	rxchan = au1xxx_dbdma_chan_alloc(rxid, memid,
-					 au1xmmc_dma_callback, (void *) host);
+				au1xmmc_dma_callback, (void *)host);
+	if (!rxchan) {
+		dev_err(&host->pdev->dev, "cannot allocate RX DMA\n");
+		au1xxx_dbdma_chan_free(txchan);
+		return -ENODEV;
+	}
 
 	au1xxx_dbdma_set_devwidth(txchan, 8);
 	au1xxx_dbdma_set_devwidth(rxchan, 8);
@@ -868,8 +884,10 @@ static void au1xmmc_init_dma(struct au1xmmc_host *host)
 	au1xxx_dbdma_ring_alloc(txchan, AU1XMMC_DESCRIPTOR_COUNT);
 	au1xxx_dbdma_ring_alloc(rxchan, AU1XMMC_DESCRIPTOR_COUNT);
 
-	host->tx_chan = txchan;
-	host->rx_chan = rxchan;
+	host->dma.tx_chan = txchan;
+	host->dma.rx_chan = rxchan;
+
+	return 0;
 }
 
 static const struct mmc_host_ops au1xmmc_ops = {
@@ -878,116 +896,201 @@ static const struct mmc_host_ops au1xmmc_ops = {
 	.get_ro		= au1xmmc_card_readonly,
 };
 
-static int __devinit au1xmmc_probe(struct platform_device *pdev)
+static void au1xmmc_poll_event(unsigned long arg)
 {
+	struct au1xmmc_host *host = (struct au1xmmc_host *)arg;
 
-	int i, ret = 0;
+	int card = au1xmmc_card_inserted(host);
+        int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
 
-	/* THe interrupt is shared among all controllers */
-	ret = request_irq(AU1100_SD_IRQ, au1xmmc_irq, IRQF_DISABLED, "MMC", 0);
+	if (card != controller) {
+		host->flags &= ~HOST_F_ACTIVE;
+		if (card)
+			host->flags |= HOST_F_ACTIVE;
+		mmc_detect_change(host->mmc, 0);
+	}
 
-	if (ret) {
-		printk(DRIVER_NAME "ERROR: Couldn't get int %d: %d\n",
-				AU1100_SD_IRQ, ret);
-		return -ENXIO;
+#ifdef DEBUG
+	if (host->mrq != NULL) {
+		u32 status = au_readl(HOST_STATUS(host));
+		DBG("PENDING - %8.8x\n", host->id, status);
 	}
+#endif
+	mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT);
+}
 
-	disable_irq(AU1100_SD_IRQ);
+static void au1xmmc_init_cd_poll_timer(struct au1xmmc_host *host)
+{
+	init_timer(&host->timer);
+	host->timer.function = au1xmmc_poll_event;
+	host->timer.data = (unsigned long)host;
+	host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT;
+}
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct mmc_host *mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
-		struct au1xmmc_host *host = 0;
+static int __devinit au1xmmc_probe(struct platform_device *pdev)
+{
+	struct mmc_host *mmc;
+	struct au1xmmc_host *host;
+	struct resource *r;
+	int ret;
+
+	mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
+	if (!mmc) {
+		dev_err(&pdev->dev, "no memory for mmc host\n");
+		ret = -ENOMEM;
+		goto out0;
+	}
 
-		if (!mmc) {
-			printk(DRIVER_NAME "ERROR: no mem for host %d\n", i);
-			au1xmmc_hosts[i] = 0;
-			continue;
-		}
+	host = mmc_priv(mmc);
+	host->mmc = mmc;
+	host->platdata = pdev->dev.platform_data;
+	host->pdev = pdev;
 
-		mmc->ops = &au1xmmc_ops;
+	ret = -ENODEV;
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "no mmio defined\n");
+		goto out1;
+	}
+	host->iobase = (unsigned long)ioremap(r->start, 0xff);
+	if (!host->iobase) {
+		dev_err(&pdev->dev, "cannot remap mmio\n");
+		goto out1;
+	}
 
-		mmc->f_min =   450000;
-		mmc->f_max = 24000000;
+	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!r) {
+		dev_err(&pdev->dev, "no IRQ defined\n");
+		goto out2;
+	}
 
-		mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
-		mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
+	host->irq = r->start;
+	/* IRQ is shared among both SD controllers */
+	ret = request_irq(host->irq, au1xmmc_irq, IRQF_SHARED,
+			  DRIVER_NAME, host);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot grab IRQ\n");
+		goto out2;
+	}
 
-		mmc->max_blk_size = 2048;
-		mmc->max_blk_count = 512;
+	mmc->ops = &au1xmmc_ops;
 
-		mmc->ocr_avail = AU1XMMC_OCR;
+	mmc->f_min =   450000;
+	mmc->f_max = 24000000;
 
-		host = mmc_priv(mmc);
-		host->mmc = mmc;
+	mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
+	mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
 
-		host->id = i;
-		host->iobase = au1xmmc_card_table[host->id].iobase;
-		host->clock = 0;
-		host->power_mode = MMC_POWER_OFF;
+	mmc->max_blk_size = 2048;
+	mmc->max_blk_count = 512;
 
-		host->flags = au1xmmc_card_inserted(host) ? HOST_F_ACTIVE : 0;
-		host->status = HOST_S_IDLE;
+	mmc->ocr_avail = AU1XMMC_OCR;
+	mmc->caps = 0;
 
-		init_timer(&host->timer);
+	host->id = pdev->id;
+	host->status = HOST_S_IDLE;
 
-		host->timer.function = au1xmmc_poll_event;
-		host->timer.data = (unsigned long) host;
-		host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT;
+	/* board-specific carddetect setup, if any */
+	if (host->platdata && host->platdata->cd_setup) {
+		ret = host->platdata->cd_setup(mmc, 1);
+		if (ret) {
+			dev_err(&pdev->dev, "board CD setup failed\n");
+			goto out3;
+		}
+	} else {
+		/* poll the board-specific card-is-in-socket method */
+		au1xmmc_init_cd_poll_timer(host);
+	}
 
-		tasklet_init(&host->data_task, au1xmmc_tasklet_data,
-				(unsigned long) host);
+	tasklet_init(&host->data_task, au1xmmc_tasklet_data,
+			(unsigned long)host);
 
-		tasklet_init(&host->finish_task, au1xmmc_tasklet_finish,
-				(unsigned long) host);
+	tasklet_init(&host->finish_task, au1xmmc_tasklet_finish,
+			(unsigned long)host);
 
-		spin_lock_init(&host->lock);
+	if (dma) {
+		ret = au1xmmc_init_dma(host);
+		if (ret)
+			goto out4;
+	}
 
-		if (dma != 0)
-			au1xmmc_init_dma(host);
+	au1xmmc_reset_controller(host);
 
-		au1xmmc_reset_controller(host);
+	ret = mmc_add_host(mmc);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot add mmc host\n");
+		goto out5;
+	}
 
-		mmc_add_host(mmc);
-		au1xmmc_hosts[i] = host;
+	platform_set_drvdata(pdev, mmc);
 
+	/* start the carddetect poll timer */
+	if (!(host->platdata && host->platdata->cd_setup))
 		add_timer(&host->timer);
 
-		printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X (mode=%s)\n",
-		       host->id, host->iobase, dma ? "dma" : "pio");
-	}
+	printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X (mode=%s)\n",
+		       pdev->id, host->iobase, dma ? "dma" : "pio");
 
-	enable_irq(AU1100_SD_IRQ);
+	return 0;	/* all ok */
 
-	return 0;
+out5:
+	au_writel(0, HOST_ENABLE(host));
+	au_writel(0, HOST_CONFIG(host));
+	au_sync();
+
+	if (dma) {
+		au1xxx_dbdma_chan_free(host->dma.tx_chan);
+		au1xxx_dbdma_chan_free(host->dma.rx_chan);
+	}
+out4:
+	tasklet_kill(&host->data_task);
+	tasklet_kill(&host->finish_task);
+
+	if (host->platdata && host->platdata->cd_setup)
+		host->platdata->cd_setup(mmc, 0);
+out3:
+	free_irq(host->irq, host);
+out2:
+	iounmap((void *)host->iobase);
+out1:
+	mmc_free_host(mmc);
+out0:
+	return ret;
 }
 
 static int __devexit au1xmmc_remove(struct platform_device *pdev)
 {
+	struct mmc_host *mmc = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host;
 
-	int i;
+	if (mmc) {
+		host  = mmc_priv(mmc);
 
-	disable_irq(AU1100_SD_IRQ);
+		mmc_remove_host(mmc);
 
-	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
-		struct au1xmmc_host *host = au1xmmc_hosts[i];
-		if (!host) continue;
+		if (host->platdata && host->platdata->cd_setup)
+			host->platdata->cd_setup(mmc, 0);
+		else
+			del_timer_sync(&host->timer);
+
+		au_writel(0, HOST_ENABLE(host));
+		au_writel(0, HOST_CONFIG(host));
+		au_sync();
 
 		tasklet_kill(&host->data_task);
 		tasklet_kill(&host->finish_task);
 
-		del_timer_sync(&host->timer);
-		au1xmmc_set_power(host, 0);
+		if (dma) {
+			au1xxx_dbdma_chan_free(host->dma.tx_chan);
+			au1xxx_dbdma_chan_free(host->dma.rx_chan);
+		}
 
-		mmc_remove_host(host->mmc);
+		au1xmmc_set_power(host, 0);
 
-		au1xxx_dbdma_chan_free(host->tx_chan);
-		au1xxx_dbdma_chan_free(host->rx_chan);
+		free_irq(host->irq, host);
 
-		au_writel(0x0, HOST_ENABLE(host));
-		au_sync();
+		mmc_free_host(mmc);
 	}
-
-	free_irq(AU1100_SD_IRQ, 0);
 	return 0;
 }
 
@@ -1004,21 +1107,32 @@ static struct platform_driver au1xmmc_driver = {
 
 static int __init au1xmmc_init(void)
 {
+	if (dma) {
+		/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
+		 * of 8 bits.  And since devices are shared, we need to create
+		 * our own to avoid freaking out other devices
+		 */
+		if (!memid)
+			memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
+		if (!memid) {
+			printk(KERN_ERR "au1xmmc: cannot add memory dma dev\n");
+			return -ENODEV;
+		}
+	}
 	return platform_driver_register(&au1xmmc_driver);
 }
 
 static void __exit au1xmmc_exit(void)
 {
+	if (dma && memid)
+		au1xxx_ddma_del_device(memid);
 	platform_driver_unregister(&au1xmmc_driver);
 }
 
 module_init(au1xmmc_init);
 module_exit(au1xmmc_exit);
 
-#ifdef MODULE
 MODULE_AUTHOR("Advanced Micro Devices, Inc");
 MODULE_DESCRIPTION("MMC/SD driver for the Alchemy Au1XXX");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:au1xxx-mmc");
-#endif
-
diff --git a/drivers/mmc/host/au1xmmc.h b/drivers/mmc/host/au1xmmc.h
deleted file mode 100644
index 341cbdf..0000000
--- a/drivers/mmc/host/au1xmmc.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef _AU1XMMC_H_
-#define _AU1XMMC_H_
-
-/* Hardware definitions */
-
-#define AU1XMMC_DESCRIPTOR_COUNT 1
-#define AU1XMMC_DESCRIPTOR_SIZE  2048
-
-#define AU1XMMC_OCR ( MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30  | \
-		      MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33  | \
-		      MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
-
-/* Easy access macros */
-
-#define HOST_STATUS(h)	((h)->iobase + SD_STATUS)
-#define HOST_CONFIG(h)	((h)->iobase + SD_CONFIG)
-#define HOST_ENABLE(h)	((h)->iobase + SD_ENABLE)
-#define HOST_TXPORT(h)	((h)->iobase + SD_TXPORT)
-#define HOST_RXPORT(h)	((h)->iobase + SD_RXPORT)
-#define HOST_CMDARG(h)	((h)->iobase + SD_CMDARG)
-#define HOST_BLKSIZE(h)	((h)->iobase + SD_BLKSIZE)
-#define HOST_CMD(h)	((h)->iobase + SD_CMD)
-#define HOST_CONFIG2(h)	((h)->iobase + SD_CONFIG2)
-#define HOST_TIMEOUT(h)	((h)->iobase + SD_TIMEOUT)
-#define HOST_DEBUG(h)	((h)->iobase + SD_DEBUG)
-
-#define DMA_CHANNEL(h) \
-	( ((h)->flags & HOST_F_XMIT) ? (h)->tx_chan : (h)->rx_chan)
-
-/* This gives us a hard value for the stop command that we can write directly
- * to the command register
- */
-
-#define STOP_CMD (SD_CMD_RT_1B|SD_CMD_CT_7|(0xC << SD_CMD_CI_SHIFT)|SD_CMD_GO)
-
-/* This is the set of interrupts that we configure by default */
-
-#if 0
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | SD_CONFIG_DD | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-#endif
-
-#define AU1XMMC_INTERRUPTS (SD_CONFIG_SC | SD_CONFIG_DT | \
-		SD_CONFIG_RAT | SD_CONFIG_CR | SD_CONFIG_I)
-/* The poll event (looking for insert/remove events runs twice a second */
-#define AU1XMMC_DETECT_TIMEOUT (HZ/2)
-
-struct au1xmmc_host {
-  struct mmc_host *mmc;
-  struct mmc_request *mrq;
-
-  u32 id;
-
-  u32 flags;
-  u32 iobase;
-  u32 clock;
-  u32 bus_width;
-  u32 power_mode;
-
-  int status;
-
-   struct {
-	   int len;
-	   int dir;
-  } dma;
-
-   struct {
-	   int index;
-	   int offset;
-	   int len;
-  } pio;
-
-  u32 tx_chan;
-  u32 rx_chan;
-
-  struct timer_list timer;
-  struct tasklet_struct finish_task;
-  struct tasklet_struct data_task;
-
-  spinlock_t lock;
-};
-
-/* Status flags used by the host structure */
-
-#define HOST_F_XMIT   0x0001
-#define HOST_F_RECV   0x0002
-#define HOST_F_DMA    0x0010
-#define HOST_F_ACTIVE 0x0100
-#define HOST_F_STOP   0x1000
-
-#define HOST_S_IDLE   0x0001
-#define HOST_S_CMD    0x0002
-#define HOST_S_DATA   0x0003
-#define HOST_S_STOP   0x0004
-
-#endif
diff --git a/include/asm-mips/mach-au1x00/au1100_mmc.h b/include/asm-mips/mach-au1x00/au1100_mmc.h
index 9e0028f..6474fac 100644
--- a/include/asm-mips/mach-au1x00/au1100_mmc.h
+++ b/include/asm-mips/mach-au1x00/au1100_mmc.h
@@ -38,15 +38,46 @@
 #ifndef __ASM_AU1100_MMC_H
 #define __ASM_AU1100_MMC_H
 
-
-#define NUM_AU1100_MMC_CONTROLLERS	2
-
-#if defined(CONFIG_SOC_AU1100)
-#define AU1100_SD_IRQ	AU1100_SD_INT
-#elif defined(CONFIG_SOC_AU1200)
-#define AU1100_SD_IRQ	AU1200_SD_INT
-#endif
-
+struct au1xmmc_platdata {
+	int(*cd_setup)(void *mmc_host, int on);
+	int(*card_inserted)(void *mmc_host);
+	int(*card_readonly)(void *mmc_host);
+	void(*set_power)(void *mmc_host, int state);
+};
+
+struct au1xmmc_host {
+	struct mmc_host *mmc;
+	struct mmc_request *mrq;
+
+	u32 id;
+
+	u32 flags;
+	u32 iobase;
+	u32 clock;
+
+	int status;
+
+	struct {
+		int len;
+		int dir;
+		u32 tx_chan;
+		u32 rx_chan;
+	} dma;
+
+	struct {
+		int index;
+		int offset;
+		int len;
+	} pio;
+
+	struct timer_list timer;
+	struct tasklet_struct finish_task;
+	struct tasklet_struct data_task;
+
+	struct platform_device *pdev;
+	struct au1xmmc_platdata *platdata;
+	int irq;
+};
 
 #define SD0_BASE	0xB0600000
 #define SD1_BASE	0xB0680000
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Thu May  8 09:03:41 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:03:44 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:44005 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022855AbYEHIDl (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:03:41 +0100
Received: (qmail 24544 invoked by uid 1000); 8 May 2008 10:03:39 +0200
Date:	Thu, 8 May 2008 10:03:39 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/7] Alchemy: register mmc platform device for
	db1200/pb1200 boards
Message-ID: <20080508080339.GE24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19155
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From a2ecbdb747a53792dd90c83d48235ae2fddfb95e Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 14:59:45 +0200
Subject: [PATCH] Alchemy: register mmc platform device for db1200/pb1200 boards
Content-Length: 5799
Lines: 219

register the mmc platform device for db1200/pb1200 boards, with
board-specific card detect/readonly facilities wrapped in platform data.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/au1000/common/platform.c |   32 ---------
 arch/mips/au1000/pb1200/platform.c |  128 +++++++++++++++++++++++++++++++++++-
 2 files changed, 127 insertions(+), 33 deletions(-)

diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
index 31d2a22..08a5900 100644
--- a/arch/mips/au1000/common/platform.c
+++ b/arch/mips/au1000/common/platform.c
@@ -162,24 +162,6 @@ static struct resource au1xxx_usb_gdt_resources[] = {
 	},
 };
 
-static struct resource au1xxx_mmc_resources[] = {
-	[0] = {
-		.start          = SD0_PHYS_ADDR,
-		.end            = SD0_PHYS_ADDR + 0x40,
-		.flags          = IORESOURCE_MEM,
-	},
-	[1] = {
-		.start		= SD1_PHYS_ADDR,
-		.end 		= SD1_PHYS_ADDR + 0x40,
-		.flags		= IORESOURCE_MEM,
-	},
-	[2] = {
-		.start          = AU1200_SD_INT,
-		.end            = AU1200_SD_INT,
-		.flags          = IORESOURCE_IRQ,
-	}
-};
-
 static u64 udc_dmamask = ~(u32)0;
 
 static struct platform_device au1xxx_usb_gdt_device = {
@@ -245,19 +227,6 @@ static struct platform_device au1200_lcd_device = {
 	.num_resources  = ARRAY_SIZE(au1200_lcd_resources),
 	.resource       = au1200_lcd_resources,
 };
-
-static u64 au1xxx_mmc_dmamask =  ~(u32)0;
-
-static struct platform_device au1xxx_mmc_device = {
-	.name = "au1xxx-mmc",
-	.id = 0,
-	.dev = {
-		.dma_mask               = &au1xxx_mmc_dmamask,
-		.coherent_dma_mask      = 0xffffffff,
-	},
-	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
-	.resource       = au1xxx_mmc_resources,
-};
 #endif /* #ifdef CONFIG_SOC_AU1200 */
 
 static struct platform_device au1x00_pcmcia_device = {
@@ -295,7 +264,6 @@ static struct platform_device *au1xxx_platform_devices[] __initdata = {
 	&au1xxx_usb_gdt_device,
 	&au1xxx_usb_otg_device,
 	&au1200_lcd_device,
-	&au1xxx_mmc_device,
 #endif
 #ifdef SMBUS_PSC_BASE
 	&pbdb_smbus_device,
diff --git a/arch/mips/au1000/pb1200/platform.c b/arch/mips/au1000/pb1200/platform.c
index 5930110..c87c173 100644
--- a/arch/mips/au1000/pb1200/platform.c
+++ b/arch/mips/au1000/pb1200/platform.c
@@ -20,8 +20,17 @@
 
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/mmc/host.h>
 
 #include <asm/mach-au1x00/au1xxx.h>
+#include <asm/mach-au1x00/au1xxx_dbdma.h>
+#include <asm/mach-au1x00/au1100_mmc.h>
+
+#if defined(CONFIG_MIPS_PB1200)
+#include <asm/mach-pb1x00/pb1200.h>
+#elif defined(CONFIG_MIPS_DB1200)
+#include <asm/mach-db1x00/db1200.h>
+#endif
 
 static struct resource ide_resources[] = {
 	[0] = {
@@ -70,9 +79,126 @@ static struct platform_device smc91c111_device = {
 	.resource	= smc91c111_resources
 };
 
+
+static const struct {
+	u16 bcsrpwr;
+	u16 bcsrstatus;
+	u16 wpstatus;
+} au1xmmc_card_table[] = {
+	{ BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
+#ifndef CONFIG_MIPS_DB1200
+	{ BCSR_BOARD_SD1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
+#endif
+};
+
+static void pb1200mmc_set_power(void *mmc_host, int state)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
+
+	if (state)
+		bcsr->board |= val;
+	else
+		bcsr->board &= ~val;
+
+	au_sync_delay(1);
+}
+
+static int pb1200mmc_card_readonly(void *mmc_host)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus) ? 1 : 0;
+}
+
+static int pb1200mmc_card_inserted(void *mmc_host)
+{
+	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
+	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
+		? 1 : 0;
+}
+
+static struct au1xmmc_platdata db1xmmcpd = {
+	.set_power	= pb1200mmc_set_power,
+	.card_inserted	= pb1200mmc_card_inserted,
+	.card_readonly	= pb1200mmc_card_readonly,
+	.cd_setup	= NULL,		/* use poll-timer in driver */
+};
+
+static u64 au1xxx_mmc_dmamask =  ~(u32)0;
+
+struct resource au1200_sd0_res[] = {
+	[0] = {
+		.start	= CPHYSADDR(SD0_BASE),
+		.end	= CPHYSADDR(SD0_BASE) + 0x40,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AU1200_SD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[3] = {
+		.start	= DSCR_CMD0_SDMS_TX0,
+		.flags	= IORESOURCE_DMA,
+	},
+	[4] = {
+		.start	= DSCR_CMD0_SDMS_RX0,
+		.flags	= IORESOURCE_DMA,
+	},
+};
+
+static struct platform_device au1xxx_sd0_device = {
+	.name = "au1xxx-mmc",
+	.id = 0,	/* index into au1xmmc_card_table[] */
+	.dev = {
+		.dma_mask               = &au1xxx_mmc_dmamask,
+		.coherent_dma_mask      = 0xffffffff,
+		.platform_data		= &db1xmmcpd,
+	},
+	.num_resources  = ARRAY_SIZE(au1200_sd0_res),
+	.resource       = au1200_sd0_res,
+};
+
+#ifndef CONFIG_MIPS_DB1200
+struct resource au1200_sd1_res[] = {
+	[0] = {
+		.start	= CPHYSADDR(SD1_BASE),
+		.end	= CPHYSADDR(SD1_BASE) + 0x40,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AU1200_SD_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[3] = {
+		.start	= DSCR_CMD0_SDMS_TX1,
+		.flags	= IORESOURCE_DMA,
+	},
+	[4] = {
+		.start	= DSCR_CMD0_SDMS_RX1,
+		.flags	= IORESOURCE_DMA,
+	},
+};
+
+static struct platform_device au1xxx_sd1_device = {
+	.name = "au1xxx-mmc",
+	.id = 1,	/* index into au1xmmc_card_table[] */
+	.dev = {
+		.dma_mask               = &au1xxx_mmc_dmamask,
+		.coherent_dma_mask      = 0xffffffff,
+		.platform_data		= &db1xmmcpd,
+	},
+	.num_resources  = ARRAY_SIZE(au1200_sd1_res),
+	.resource       = au1200_sd1_res,
+};
+#endif
+
 static struct platform_device *board_platform_devices[] __initdata = {
 	&ide_device,
-	&smc91c111_device
+	&smc91c111_device,
+	&au1xxx_sd0_device,
+#ifndef CONFIG_MIPS_DB1200
+	&au1xxx_sd1_device,
+#endif
 };
 
 static int __init board_register_devices(void)
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Thu May  8 09:04:17 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:04:19 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:19895 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022857AbYEHIER (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:04:17 +0100
Received: (qmail 24566 invoked by uid 1000); 8 May 2008 10:04:16 +0200
Date:	Thu, 8 May 2008 10:04:16 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] au1xmmc: 4 bit transfer mode
Message-ID: <20080508080416.GF24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19156
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From f850f29297156c673fe3453c4c1c4642c46567e2 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 15:04:51 +0200
Subject: [PATCH] au1xmmc: 4 bit transfer mode
Content-Length: 1933
Lines: 67

Add 4 Bit transfer mode support.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 8660f86..d9e334f 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -161,13 +161,13 @@ static inline void IRQ_OFF(struct au1xmmc_host *host, u32 mask)
 static inline void SEND_STOP(struct au1xmmc_host *host)
 {
 
-	/* We know the value of CONFIG2, so avoid a read we don't need */
-	u32 mask = SD_CONFIG2_EN;
+	u32 config2;
 
 	WARN_ON(host->status != HOST_S_DATA);
 	host->status = HOST_S_STOP;
 
-	au_writel(mask | SD_CONFIG2_DF, HOST_CONFIG2(host));
+	config2 = au_readl(HOST_CONFIG2(host));
+	au_writel(config2 | SD_CONFIG2_DF, HOST_CONFIG2(host));
 	au_sync();
 
 	/* Send the stop commmand */
@@ -762,6 +762,7 @@ static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
+	u32 config;
 
 	if (ios->power_mode == MMC_POWER_OFF)
 		au1xmmc_set_power(host, 0);
@@ -773,6 +774,18 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 		au1xmmc_set_clock(host, ios->clock);
 		host->clock = ios->clock;
 	}
+
+	config = au_readl(HOST_CONFIG2(host));
+	switch (ios->bus_width) {
+	case MMC_BUS_WIDTH_4:
+		config |= (1 << 8);
+		break;
+	case MMC_BUS_WIDTH_1:
+		config &= ~(1 << 8);
+		break;
+	}
+	au_writel(config, HOST_CONFIG2(host));
+	au_sync();
 }
 
 static void au1xmmc_dma_callback(int irq, void *dev_id)
@@ -985,7 +998,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
 	mmc->max_blk_count = 512;
 
 	mmc->ocr_avail = AU1XMMC_OCR;
-	mmc->caps = 0;
+	mmc->caps = MMC_CAP_4_BIT_DATA;
 
 	host->id = pdev->id;
 	host->status = HOST_S_IDLE;
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Thu May  8 09:04:56 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:04:59 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:3008 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20021870AbYEHIE4 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:04:56 +0100
Received: (qmail 24587 invoked by uid 1000); 8 May 2008 10:04:54 +0200
Date:	Thu, 8 May 2008 10:04:54 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] au1xmmc: wire up SDIO interrupt
Message-ID: <20080508080454.GG24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19157
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 53260bd4727f9d809c23578e7cbf0d1df47bc236 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 15:18:14 +0200
Subject: [PATCH] au1xmmc: wire up SDIO interrupt
Content-Length: 1509
Lines: 54


Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index d9e334f..8b60509 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -817,6 +817,9 @@ static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 	if (!(status & (1 << 15)))
 		return IRQ_NONE;	/* not ours */
 
+	if (status & 0x80000000)	/* SDIO */
+		mmc_signal_sdio_irq(host->mmc);
+
 	if (host->mrq && (status & STATUS_TIMEOUT)) {
 		if (status & SD_STATUS_RAT)
 			host->mrq->cmd->error = -ETIMEDOUT;
@@ -903,10 +906,21 @@ static int au1xmmc_init_dma(struct au1xmmc_host *host)
 	return 0;
 }
 
+static void au1xmmc_enable_sdio_irq(struct mmc_host *mmc, int en)
+{
+	struct au1xmmc_host *host = mmc_priv(mmc);
+
+	if (en)
+		IRQ_ON(host, (1 << 31));
+	else
+		IRQ_OFF(host, (1 << 31));
+}
+
 static const struct mmc_host_ops au1xmmc_ops = {
 	.request	= au1xmmc_request,
 	.set_ios	= au1xmmc_set_ios,
 	.get_ro		= au1xmmc_card_readonly,
+	.enable_sdio_irq = au1xmmc_enable_sdio_irq,
 };
 
 static void au1xmmc_poll_event(unsigned long arg)
@@ -998,7 +1012,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
 	mmc->max_blk_count = 512;
 
 	mmc->ocr_avail = AU1XMMC_OCR;
-	mmc->caps = MMC_CAP_4_BIT_DATA;
+	mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
 
 	host->id = pdev->id;
 	host->status = HOST_S_IDLE;
-- 
1.5.5.1


From mano@roarinelk.homelinux.net Thu May  8 09:05:52 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:05:55 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:14470 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022880AbYEHIFw (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 09:05:52 +0100
Received: (qmail 24614 invoked by uid 1000); 8 May 2008 10:05:50 +0200
Date:	Thu, 8 May 2008 10:05:50 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/7] au1xmmc: codingstyle tidying
Message-ID: <20080508080550.GH24383@roarinelk.homelinux.net>
References: <20080508080040.GA24383@roarinelk.homelinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080508080040.GA24383@roarinelk.homelinux.net>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19158
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 0
Lines: 0


From 4e439a8b70c5ab0ca36e7a653fbb1c19605e0ea6 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <mlau@msc-ge.com>
Date: Wed, 7 May 2008 15:30:14 +0200
Subject: [PATCH] au1xmmc: codingstyle tidying
Content-Length: 11808
Lines: 406

Make the driver source a bit easier on the eyes;
no functional changes.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 drivers/mmc/host/au1xmmc.c |  139 ++++++++++++++++---------------------------
 1 files changed, 52 insertions(+), 87 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 8b60509..3b9833f 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -160,7 +160,6 @@ static inline void IRQ_OFF(struct au1xmmc_host *host, u32 mask)
 
 static inline void SEND_STOP(struct au1xmmc_host *host)
 {
-
 	u32 config2;
 
 	WARN_ON(host->status != HOST_S_DATA);
@@ -280,18 +279,14 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
 	au_sync();
 
 	/* Wait for the command to go on the line */
-
-	while(1) {
-		if (!(au_readl(HOST_CMD(host)) & SD_CMD_GO))
-			break;
-	}
+	while (au_readl(HOST_CMD(host)) & SD_CMD_GO)
+		/* nop */;
 
 	/* Wait for the command to come back */
-
 	if (wait) {
 		u32 status = au_readl(HOST_STATUS(host));
 
-		while(!(status & SD_STATUS_CR))
+		while (!(status & SD_STATUS_CR))
 			status = au_readl(HOST_STATUS(host));
 
 		/* Clear the CR status */
@@ -305,12 +300,11 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
 
 static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 {
-
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_data *data;
 	u32 crc;
 
-	WARN_ON(host->status != HOST_S_DATA && host->status != HOST_S_STOP);
+	WARN_ON((host->status != HOST_S_DATA) && (host->status != HOST_S_STOP));
 
 	if (host->mrq == NULL)
 		return;
@@ -321,15 +315,13 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 		status = au_readl(HOST_STATUS(host));
 
 	/* The transaction is really over when the SD_STATUS_DB bit is clear */
-
-	while((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB))
+	while ((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB))
 		status = au_readl(HOST_STATUS(host));
 
 	data->error = 0;
 	dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma.dir);
 
         /* Process any errors */
-
 	crc = (status & (SD_STATUS_WC | SD_STATUS_RC));
 	if (host->flags & HOST_F_XMIT)
 		crc |= ((status & 0x07) == 0x02) ? 0 : 1;
@@ -346,11 +338,10 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 		if (host->flags & HOST_F_DMA) {
 			u32 chan = DMA_CHANNEL(host);
 
-			chan_tab_t *c = *((chan_tab_t **) chan);
+			chan_tab_t *c = *((chan_tab_t **)chan);
 			au1x_dma_chan_t *cp = c->chan_ptr;
 			data->bytes_xfered = cp->ddma_bytecnt;
-		}
-		else
+		} else
 			data->bytes_xfered =
 				(data->blocks * data->blksz) -
 				host->pio.len;
@@ -361,7 +352,7 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
 
 static void au1xmmc_tasklet_data(unsigned long param)
 {
-	struct au1xmmc_host *host = (struct au1xmmc_host *) param;
+	struct au1xmmc_host *host = (struct au1xmmc_host *)param;
 
 	u32 status = au_readl(HOST_STATUS(host));
 	au1xmmc_data_complete(host, status);
@@ -371,11 +362,10 @@ static void au1xmmc_tasklet_data(unsigned long param)
 
 static void au1xmmc_send_pio(struct au1xmmc_host *host)
 {
-
-	struct mmc_data *data = 0;
-	int sg_len, max, count = 0;
-	unsigned char *sg_ptr;
-	u32 status = 0;
+	struct mmc_data *data;
+	int sg_len, max, count;
+	unsigned char *sg_ptr, val;
+	u32 status;
 	struct scatterlist *sg;
 
 	data = host->mrq->data;
@@ -390,22 +380,19 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
 	/* This is the space left inside the buffer */
 	sg_len = data->sg[host->pio.index].length - host->pio.offset;
 
-	/* Check to if we need less then the size of the sg_buffer */
-
+	/* Check if we need less than the size of the sg_buffer */
 	max = (sg_len > host->pio.len) ? host->pio.len : sg_len;
-	if (max > AU1XMMC_MAX_TRANSFER) max = AU1XMMC_MAX_TRANSFER;
-
-	for(count = 0; count < max; count++ ) {
-		unsigned char val;
+	if (max > AU1XMMC_MAX_TRANSFER)
+		max = AU1XMMC_MAX_TRANSFER;
 
+	for (count = 0; count < max; count++) {
 		status = au_readl(HOST_STATUS(host));
-
 		if (!(status & SD_STATUS_TH))
 			break;
 
 		val = *sg_ptr++;
 
-		au_writel((unsigned long) val, HOST_TXPORT(host));
+		au_writel((unsigned long)val, HOST_TXPORT(host));
 		au_sync();
 	}
 
@@ -429,11 +416,10 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
 
 static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 {
-
-	struct mmc_data *data = 0;
-	int sg_len = 0, max = 0, count = 0;
-	unsigned char *sg_ptr = 0;
-	u32 status = 0;
+	struct mmc_data *data;
+	int sg_len = 0, max, count;
+	unsigned char *sg_ptr = NULL;
+	u32 status;
 	struct scatterlist *sg;
 
 	data = host->mrq->data;
@@ -451,13 +437,14 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 		sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset;
 
 		/* Check to if we need less then the size of the sg_buffer */
-		if (sg_len < max) max = sg_len;
+		if (sg_len < max)
+			max = sg_len;
 	}
 
 	if (max > AU1XMMC_MAX_TRANSFER)
 		max = AU1XMMC_MAX_TRANSFER;
 
-	for(count = 0; count < max; count++ ) {
+	for (count = 0; count < max; count++) {
 		u32 val;
 		status = au_readl(HOST_STATUS(host));
 
@@ -474,8 +461,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 			DBG("RX Overrun [%d + %d]\n", host->id,
 					host->pio.len, count);
 			break;
-		}
-		else if (status & SD_STATUS_RU) {
+		} else if (status & SD_STATUS_RU) {
 			DBG("RX Underrun [%d + %d]\n", host->id,
 					host->pio.len,	count);
 			break;
@@ -490,13 +476,13 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 	host->pio.len -= count;
 	host->pio.offset += count;
 
-	if (sg_len && count == sg_len) {
+	if (sg_len && (count == sg_len)) {
 		host->pio.index++;
 		host->pio.offset = 0;
 	}
 
 	if (host->pio.len == 0) {
-		//IRQ_OFF(host, SD_CONFIG_RA | SD_CONFIG_RF);
+		/* IRQ_OFF(host, SD_CONFIG_RA | SD_CONFIG_RF); */
 		IRQ_OFF(host, SD_CONFIG_NE);
 
 		if (host->flags & HOST_F_STOP)
@@ -506,14 +492,11 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
 	}
 }
 
-/* static void au1xmmc_cmd_complete
-   This is called when a command has been completed - grab the response
-   and check for errors.  Then start the data transfer if it is indicated.
-*/
-
+/* This is called when a command has been completed - grab the response
+ * and check for errors.  Then start the data transfer if it is indicated.
+ */
 static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 {
-
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_command *cmd;
 	int trans;
@@ -538,7 +521,6 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 			 * we only got 120 bytes, but the engine expects
 			 * 128 bits, so we have to shift things up
 			 */
-
 			for(i = 0; i < 4; i++) {
 				cmd->resp[i] = (r[i] & 0x00FFFFFF) << 8;
 				if (i != 3)
@@ -557,15 +539,13 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 	}
 
         /* Figure out errors */
-
 	if (status & (SD_STATUS_SC | SD_STATUS_WC | SD_STATUS_RC))
 		cmd->error = -EILSEQ;
 
 	trans = host->flags & (HOST_F_XMIT | HOST_F_RECV);
 
 	if (!trans || cmd->error) {
-
-		IRQ_OFF(host, SD_CONFIG_TH | SD_CONFIG_RA|SD_CONFIG_RF);
+		IRQ_OFF(host, SD_CONFIG_TH | SD_CONFIG_RA | SD_CONFIG_RF);
 		tasklet_schedule(&host->finish_task);
 		return;
 	}
@@ -576,29 +556,25 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
 		u32 channel = DMA_CHANNEL(host);
 
 		/* Start the DMA as soon as the buffer gets something in it */
-
 		if (host->flags & HOST_F_RECV) {
 			u32 mask = SD_STATUS_DB | SD_STATUS_NE;
 
-			while((status & mask) != mask)
+			while ((status & mask) != mask)
 				status = au_readl(HOST_STATUS(host));
 		}
-
 		au1xxx_dbdma_start(channel);
 	}
 }
 
 static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
 {
-
 	unsigned int pbus = get_au1x00_speed();
 	unsigned int divisor;
 	u32 config;
 
 	/* From databook:
-	   divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1
-	*/
-
+	 * divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1
+	 */
 	pbus /= ((au_readl(SYS_POWERCTRL) & 0x3) + 2);
 	pbus /= 2;
 
@@ -616,7 +592,6 @@ static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
 static int
 au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 {
-
 	int datalen = data->blocks * data->blksz;
 
 	if (dma != 0)
@@ -647,32 +622,31 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 		au1xxx_dbdma_stop(channel);
 
 		for(i = 0; i < host->dma.len; i++) {
-			u32 ret = 0, flags = DDMA_FLAGS_NOIE;
+			u32 ret, flags;
 			struct scatterlist *sg = &data->sg[i];
 			int sg_len = sg->length;
 
 			int len = (datalen > sg_len) ? sg_len : datalen;
 
-			if (i == host->dma.len - 1)
+			if (i == (host->dma.len - 1))
 				flags = DDMA_FLAGS_IE;
-
-    			if (host->flags & HOST_F_XMIT){
-      				ret = au1xxx_dbdma_put_source_flags(channel,
-					(void *) sg_virt(sg), len, flags);
-			}
-    			else {
-      				ret = au1xxx_dbdma_put_dest_flags(channel,
-					(void *) sg_virt(sg),
-					len, flags);
+			else
+				flags = DDMA_FLAGS_NOIE;
+
+			if (host->flags & HOST_F_XMIT){
+				ret = au1xxx_dbdma_put_source_flags(channel,
+					(void *)sg_virt(sg), len, flags);
+			} else {
+				ret = au1xxx_dbdma_put_dest_flags(channel,
+					(void *)sg_virt(sg), len, flags);
 			}
 
-    			if (!ret)
+			if (!ret)
 				goto dataerr;
 
 			datalen -= len;
 		}
-	}
-	else {
+	} else {
 		host->pio.index = 0;
 		host->pio.offset = 0;
 		host->pio.len = datalen;
@@ -681,25 +655,19 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
 			IRQ_ON(host, SD_CONFIG_TH);
 		else
 			IRQ_ON(host, SD_CONFIG_NE);
-			//IRQ_ON(host, SD_CONFIG_RA|SD_CONFIG_RF);
+			/* IRQ_ON(host, SD_CONFIG_RA|SD_CONFIG_RF); */
 	}
 
 	return 0;
 
- dataerr:
+dataerr:
 	dma_unmap_sg(mmc_dev(host->mmc),data->sg,data->sg_len,host->dma.dir);
 	return -ETIMEDOUT;
 }
 
-/* static void au1xmmc_request
-   This actually starts a command or data transaction
-*/
-
 static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 {
-
 	struct au1xmmc_host *host = mmc_priv(mmc);
-	unsigned int flags = 0;
 	int ret = 0;
 
 	WARN_ON(irqs_disabled());
@@ -714,7 +682,6 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 
 	if (mrq->data) {
 		FLUSH_FIFO(host);
-		flags = mrq->data->flags;
 		ret = au1xmmc_prepare_data(host, mrq->data);
 	}
 
@@ -729,7 +696,6 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
 
 static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 {
-
 	/* Apply the clock */
 	au_writel(SD_ENABLE_CE, HOST_ENABLE(host));
         au_sync_delay(1);
@@ -759,7 +725,7 @@ static void au1xmmc_reset_controller(struct au1xmmc_host *host)
 }
 
 
-static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
+static void au1xmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct au1xmmc_host *host = mmc_priv(mmc);
 	u32 config;
@@ -790,10 +756,9 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
 
 static void au1xmmc_dma_callback(int irq, void *dev_id)
 {
-	struct au1xmmc_host *host = (struct au1xmmc_host *) dev_id;
+	struct au1xmmc_host *host = (struct au1xmmc_host *)dev_id;
 
 	/* Avoid spurious interrupts */
-
 	if (!host->mrq)
 		return;
 
@@ -845,7 +810,7 @@ static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
 #endif
 	else if (status & (SD_STATUS_CR)) {
 		if (host->status == HOST_S_CMD)
-			au1xmmc_cmd_complete(host,status);
+			au1xmmc_cmd_complete(host, status);
 
 	} else if (!(host->flags & HOST_F_DMA)) {
 		if ((host->flags & HOST_F_XMIT) && (status & STATUS_DATA_OUT))
-- 
1.5.5.1


From abhiruchi.g@vaultinfo.com Thu May  8 09:38:33 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:38:35 +0100 (BST)
Received: from smtp137.iad.emailsrvr.com ([207.97.245.137]:36774 "EHLO
	smtp137.iad.emailsrvr.com") by ftp.linux-mips.org with ESMTP
	id S20024526AbYEHIid convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 09:38:33 +0100
Received: from relay3.r3.iad.emailsrvr.com (localhost [127.0.0.1])
	by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id 9B49E44C0D3;
	Thu,  8 May 2008 04:38:26 -0400 (EDT)
Received: from vaultinfo.com (webmail15.webmail.iad.mlsrvr.com [192.168.1.39])
	by relay3.r3.iad.emailsrvr.com (SMTP Server) with ESMTP id 8E1B344C099;
	Thu,  8 May 2008 04:38:26 -0400 (EDT)
Received: by webmail.mailsin.net
    (Authenticated sender: abhiruchi.g@vaultinfo.com, from: abhiruchi.g@vaultinfo.com) 
    with HTTP; Thu, 8 May 2008 04:38:26 -0400 (EDT)
Date:	Thu, 8 May 2008 04:38:26 -0400 (EDT)
Subject: Alchemy DB1200
From:	abhiruchi.g@vaultinfo.com
To:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Reply-To: abhiruchi.g@vaultinfo.com
MIME-Version: 1.0
Content-Type: text/plain;charset=UTF-8
Content-Transfer-Encoding: 8BIT
Importance: Normal
X-Priority: 3 (Normal)
X-Type:	1
Message-ID: <46742.192.168.1.35.1210235906.webmail@192.168.1.35>
X-Mailer: webmail6.6.1
Return-Path: <abhiruchi.g@vaultinfo.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19159
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: abhiruchi.g@vaultinfo.com
Precedence: bulk
X-list: linux-mips
Content-Length: 60
Lines: 5


what this meant:

sda:<7>usb-storage: queuecommand called


From abhiruchi.g@vaultinfo.com Thu May  8 09:57:40 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:57:43 +0100 (BST)
Received: from smtp197.iad.emailsrvr.com ([207.97.245.197]:56730 "EHLO
	smtp197.iad.emailsrvr.com") by ftp.linux-mips.org with ESMTP
	id S20025419AbYEHI5k convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 09:57:40 +0100
Received: from relay9.relay.iad.mlsrvr.com (localhost [127.0.0.1])
	by relay9.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id C60E31B40A8;
	Thu,  8 May 2008 04:57:31 -0400 (EDT)
Received: from vaultinfo.com (webmail14.webmail.iad.mlsrvr.com [192.168.1.37])
	by relay9.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id B81671B4052;
	Thu,  8 May 2008 04:57:31 -0400 (EDT)
Received: by webmail.mailsin.net
    (Authenticated sender: abhiruchi.g@vaultinfo.com, from: abhiruchi.g@vaultinfo.com) 
    with HTTP; Thu, 8 May 2008 04:57:31 -0400 (EDT)
Date:	Thu, 8 May 2008 04:57:31 -0400 (EDT)
Subject: =?UTF-8?Q?Alchemy=20DB1200:=20do=5Fcpu()?=
From:	abhiruchi.g@vaultinfo.com
To:	"linux-mips@linux-mips.org " <linux-mips@linux-mips.org>
Cc:	"linux-kernel@vger.kernel.org " <linux-kernel@vger.kernel.org>
Reply-To: abhiruchi.g@vaultinfo.com
MIME-Version: 1.0
Content-Type: text/plain;charset=UTF-8
Content-Transfer-Encoding: 8BIT
Importance: Normal
X-Priority: 3 (Normal)
X-Type:	1
Message-ID: <36930.192.168.1.71.1210237051.webmail@192.168.1.71>
X-Mailer: webmail6.6.1
Return-Path: <abhiruchi.g@vaultinfo.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19160
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: abhiruchi.g@vaultinfo.com
Precedence: bulk
X-list: linux-mips
Content-Length: 88
Lines: 4

I am not able to find out:

  From which function and which file "do_cpu()" is called?


From khali@linux-fr.org Thu May  8 09:59:26 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 09:59:31 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:11592 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20025578AbYEHI70 convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 09:59:26 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Ju2uN-0000VT-23
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Thu, 08 May 2008 11:59:27 +0200
Date:	Thu, 8 May 2008 10:59:05 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Ralf Baechle <ralf@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080508105905.3209c659@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
	<20080507085953.2c08b854@hyperion.delvare>
	<Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8BIT
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19161
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 5519
Lines: 113

Hi Maciej,

On Wed, 7 May 2008 22:13:23 +0100 (BST), Maciej W. Rozycki wrote:
> Hi Jean,
> 
> > Minor corrections which would ideally belong to a separate patch
> > (there's a whole lot more cleanups that could be done in that driver,
> > BTW...)
> 
>  Not suprising, as usually with most pieces of code for the SWARM and the 
> SiByte SOC.  That can be done gradually, but mixing a driver overhaul with 
> functional changes usually only results in confusion later on.

I fully agree.

> > I don't think that the minor changes below are enough for you to claim
> > copyright on that driver.
> 
>  Well, I decide whether or not to add one based on how important changes
> are from the piece's of code point of view.  In this case the change is
> essential for new-style client drivers to work at all, which I think is
> more important than e.g. a lot of cosmetical changes throughout would be.  
> But I do not insist on keeping it -- if you think I misjudged on this
> occasion, I see no problem with discarding it.

If you had to add a missing semicolon to a source file to get it to
build again, it would be an "essential" change (without it nothing
works) but still, you can't claim you added any intellectual value to
the source file. So, no copyright. The copyright is about how much
value you add, not how important the change is in the big picture.

> > Why do you double the space and the end of comments? Never seen that
> > before, and I can't see the idea.
> 
>  This is mostly habitual -- this is what the GNU Coding Standard specifies
> for comments and which is enforced for GNU software which I have dealt a
> lot with.

From Documentation/CodingStyle:

"First off, I'd suggest printing out a copy of the GNU coding standards,
and NOT read it.  Burn them, it's a great symbolic gesture."

I'm not going to tell how bad I think the GNU coding standards are, the
point here is that we don't follow them at all, so whatever they say is
totally irrelevant. Read Documentation/CodingStyle, it describes what
we do. Also make sure that you run your patches through
scripts/checkpatch.pl. The rest is up to you, but in general, when
modifying existing code, you want to stick to what the surrounding code
looks like.

>  I think the idea is it improves readability and I tend to
> agree.  The same goes for using a capital at the beginning and a full stop
> at the end of sentences in comments -- it improves readability and
> (together with a good style of code itself) makes the result look more
> professional.  Certainly well-formatted code is easier to comprehend for 
> someone looking at it for the first time.
> 
>  I do not insist on the extraneous space if you have a strong opinion 
> against though.

I do insist ;) Admittedly, double spaces at end of comments are used in
some places in the kernel tree (I had never seen that before), but they
are still outnumbered by single-space ending comments, 50 to 1. Do
what you want in the drivers your create or maintain, but please don't
change existing comments, especially not in the middle of functional
changes.

> > I'm not sure how you intend to push these changes upstream. I would
> > take a patch only touching drivers/i2c/busses/i2c-sibyte.c in my i2c
> > tree, however a patch also touching arch code, must be handled be the
> > maintainer for that architecture or platform.
> 
>  Andrew has spoken (thank you, Andrew) and I would only like to add an
> explanation why I have not split this change further.  Certainly it is
> functionally consistent.  Then adding i2c-swarm.c only breaks things as
> the onchip buses suddenly get the numbers 2 and 3.  On the other hand, if
> adding the i2c-sibyte.c change only, it will take a while until it
> propagates back to the MIPS tree and without that as it is there is no
> single way to use the whole set of changes as the clock device will not be
> seen.
> 
>  If you are scared off by the MIPS-specific Makefile (lib vs obj) changes,
> then I think they should be reasonably easy to sort out separately in a
> couple of days as functionally not changing anything.  The only other file
> in the affected subdirectory that depends on a config option uses
> CONFIG_KGDB which does not seem to rely on being pulled implicitly by the
> linker.  But such a mechanical change by itself would make little sense 
> (don't fix what isn't broken), so I have not pushed it without a 
> reasonable justification.
> 
>  Ralf -- what do you think about the Makefile changes?  I can send you a 
> separate patch which will reduce the span of this one.

That's not a matter of being scared, and I was also _not_ asking you to
split the patch. That's a matter of synchronizing merges between me and
the architecture maintainer. If I take a patch in my i2c tree which
touches architecture-specific files, and I only push it to Linus in 2
months, then chances are that the architecture-specific files in
question will change several times meanwhile, resulting in conflicts in
-next and -mm. I am only trying to prevent this from happening. I
simply think that it is easier to synchronize patches if all
architecture-specific patches go through the relevant architecture tree.

BTW, SWARM seems to be only one of the 4 SiByte platforms we support.
What about the other ones? Your changes to the i2c-sibyte driver could
cause the i2c bus registration to fail, as the other platforms do not
declare I2C devices, the bus numbers 0 and 1 won't be reserved by
i2c-core. Care to comment on this?

Thanks,
-- 
Jean Delvare

From sshtylyov@ru.mvista.com Thu May  8 13:14:34 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 13:14:37 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:53865 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20021380AbYEHMOe (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 13:14:34 +0100
Received: from [192.168.1.234] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id 28BF83ECD; Thu,  8 May 2008 05:14:29 -0700 (PDT)
Message-ID: <4822EE83.9000708@ru.mvista.com>
Date:	Thu, 08 May 2008 16:13:55 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH] Pb1000: bury the remnants of the PCI code (part 2)
References: <200804292333.47099.sshtylyov@ru.mvista.com>
In-Reply-To: <200804292333.47099.sshtylyov@ru.mvista.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19162
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1189
Lines: 34

Hello, I wrote:

> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

> ---
> Here's the fragment I missed in the initial patch. Combine them if possible...

    So, Ralf, will you apply this patch as is or I need to do something about 
it (like adding log message)?

>  arch/mips/au1000/pb1000/board_setup.c |    7 -------
>  1 files changed, 7 deletions(-)
> 
> Index: linux-2.6/arch/mips/au1000/pb1000/board_setup.c
> ===================================================================
> --- linux-2.6.orig/arch/mips/au1000/pb1000/board_setup.c
> +++ linux-2.6/arch/mips/au1000/pb1000/board_setup.c
> @@ -153,13 +153,6 @@ void __init board_setup(void)
>  	au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */
>  	au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */
>  
> -#ifdef CONFIG_PCI
> -	au_writel(0, PCI_BRIDGE_CONFIG); // set extend byte to 0
> -	au_writel(0, SDRAM_MBAR);        // set mbar to 0
> -	au_writel(0x2, SDRAM_CMD);       // enable memory accesses
> -	au_sync_delay(1);
> -#endif
> -
>  	/* Enable Au1000 BCLK switching - note: sed1356 must not use
>  	 * its BCLK (Au1000 LCLK) for any timings */
>  	switch (prid & 0x000000FF)
> 

WBR, Sergei

From sshtylyov@ru.mvista.com Thu May  8 13:42:13 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 13:42:16 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:45163 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20024991AbYEHMmN (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 13:42:13 +0100
Received: from [192.168.1.234] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id 9B79F3EC9; Thu,  8 May 2008 05:42:05 -0700 (PDT)
Message-ID: <4822F4FC.5040107@ru.mvista.com>
Date:	Thu, 08 May 2008 16:41:32 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	Manuel Lauss <mano@roarinelk.homelinux.net>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platform device
 and board specific functions
References: <20080507160154.GA17806@roarinelk.homelinux.net> <20080507160634.GE17806@roarinelk.homelinux.net>
In-Reply-To: <20080507160634.GE17806@roarinelk.homelinux.net>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19163
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 6235
Lines: 216

Hello.

Manuel Lauss wrote:

> Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>

> diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
> index 31d2a22..08a5900 100644
> --- a/arch/mips/au1000/common/platform.c
> +++ b/arch/mips/au1000/common/platform.c

    Hm, I don't see anything board-specific in
arch/mips/au1000/common/platform.c anymore -- after I removed IDE and SMC
91C111 from there (these were devices on the static bus).

> @@ -162,24 +162,6 @@ static struct resource au1xxx_usb_gdt_resources[] = {
>  	},
>  };
>  
> -static struct resource au1xxx_mmc_resources[] = {
> -	[0] = {
> -		.start          = SD0_PHYS_ADDR,
> -		.end            = SD0_PHYS_ADDR + 0x40,
> -		.flags          = IORESOURCE_MEM,
> -	},
> -	[1] = {
> -		.start		= SD1_PHYS_ADDR,
> -		.end 		= SD1_PHYS_ADDR + 0x40,

    Hm, I haven't noticed that these are off-by-one... :-/

> -		.flags		= IORESOURCE_MEM,
> -	},
> -	[2] = {
> -		.start          = AU1200_SD_INT,
> -		.end            = AU1200_SD_INT,
> -		.flags          = IORESOURCE_IRQ,
> -	}
> -};
> -
>  static u64 udc_dmamask = ~(u32)0;
>  
>  static struct platform_device au1xxx_usb_gdt_device = {
> @@ -245,19 +227,6 @@ static struct platform_device au1200_lcd_device = {
>  	.num_resources  = ARRAY_SIZE(au1200_lcd_resources),
>  	.resource       = au1200_lcd_resources,
>  };
> -
> -static u64 au1xxx_mmc_dmamask =  ~(u32)0;
> -
> -static struct platform_device au1xxx_mmc_device = {
> -	.name = "au1xxx-mmc",
> -	.id = 0,
> -	.dev = {
> -		.dma_mask               = &au1xxx_mmc_dmamask,
> -		.coherent_dma_mask      = 0xffffffff,
> -	},
> -	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
> -	.resource       = au1xxx_mmc_resources,
> -};
>  #endif /* #ifdef CONFIG_SOC_AU1200 */

    What board-specific was here?

>  static struct platform_device au1x00_pcmcia_device = {
> diff --git a/arch/mips/au1000/pb1200/platform.c b/arch/mips/au1000/pb1200/platform.c
> index 5930110..bee2bf7 100644
> --- a/arch/mips/au1000/pb1200/platform.c
> +++ b/arch/mips/au1000/pb1200/platform.c
> @@ -20,8 +20,17 @@
>  
>  #include <linux/init.h>
>  #include <linux/platform_device.h>
> +#include <linux/mmc/host.h>
>  
>  #include <asm/mach-au1x00/au1xxx.h>
> +#include <asm/mach-au1x00/au1xxx_dbdma.h>
> +#include <asm/mach-au1x00/au1100_mmc.h>
> +
> +#if defined(CONFIG_MIPS_PB1200)
> +#include <asm/mach-pb1x00/pb1200.h>
> +#elif defined(CONFIG_MIPS_DB1200)
> +#include <asm/mach-db1x00/db1200.h>
> +#endif

#include <asm/mach-au1x00/au1xxx.h> does all that already -- you don't need to
include the board specific headers one more time.  Drop this part please.

>  static struct resource ide_resources[] = {
>  	[0] = {
> @@ -70,9 +79,125 @@ static struct platform_device smc91c111_device = {
>  	.resource	= smc91c111_resources
>  };
>  
> +
> +static const struct {
> +	u16 bcsrpwr;
> +	u16 bcsrstatus;
> +	u16 wpstatus;
> +} au1xmmc_card_table[] = {
> +	{ BCSR_BOARD_SD0PWR, BCSR_INT_SD0INSERT, BCSR_STATUS_SD0WP },
> +#ifndef CONFIG_MIPS_DB1200
> +	{ BCSR_BOARD_SD1PWR, BCSR_INT_SD1INSERT, BCSR_STATUS_SD1WP }
> +#endif
> +};
> +
> +static void pb1200mmc_set_power(void *mmc_host, int state)
> +{
> +	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
> +	u32 val = au1xmmc_card_table[host->id].bcsrpwr;
> +
> +	bcsr->board &= ~val;
> +	if (state)
> +		bcsr->board |= val;
> +
> +	au_sync_delay(1);
> +}
> +
> +static int pb1200mmc_card_readonly(void *mmc_host)
> +{
> +	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);

    Insert new line after a declaration please.

> +	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus) ? 1 : 0;
> +}
> +
> +static int pb1200mmc_card_inserted(void *mmc_host)
> +{
> +	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);

    The same here.

> +	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
> +		? 1 : 0;
> +}
> +
> +static struct au1xmmc_platdata db1xmmcpd = {
> +	.set_power	= pb1200mmc_set_power,
> +	.card_inserted	= pb1200mmc_card_inserted,
> +	.card_readonly	= pb1200mmc_card_readonly,
> +	.cd_setup	= NULL,		/* use poll-timer in driver */

    Function ptrs in the platform data?  That's something new -- though why 
not? :-)

> +};
> +
> +static u64 au1xxx_mmc_dmamask =  ~(u32)0;
> +
> +struct resource au1200sd0_res[] = {
> +	[0] = {
> +		.start	= CPHYSADDR(SD0_BASE),

    Why not just use SD0_PHYS_ADDR?

> +		.end	= CPHYSADDR(SD0_BASE) + 0x40,

    You've missed "- 1" here. Though it's alos not clear why 0x40 and not 0x3c 
(there's not register at 0x3c) or 0x80000 -- the range used according to the 
memory map...

> +		.flags	= IORESOURCE_MEM,
> +	},
> +	[2] = {
> +		.start	= AU1200_SD_INT,
> +		.flags	= IORESOURCE_IRQ,
> +	},
> +	[3] = {
> +		.start	= DSCR_CMD0_SDMS_TX0,
> +		.flags	= IORESOURCE_DMA,
> +	},
> +	[4] = {
> +		.start	= DSCR_CMD0_SDMS_RX0,
> +		.flags	= IORESOURCE_DMA,
> +	},
> +};

    Humm. The other devices (like IDE) should also claim DMA resources...

> +
> +static struct platform_device au1200_sd0_device = {
> +	.name = "au1xxx-mmc",
> +	.id = 0,	/* index into au1xmmc_card_table[] */
> +	.dev = {
> +		.dma_mask               = &au1xxx_mmc_dmamask,
> +		.coherent_dma_mask      = 0xffffffff,
> +		.platform_data		= &db1xmmcpd,

    Can't we leave the MMC platform device where it is but define the platform 
data structure per board with some starndard name? Since IMO it doesn't make 
sense to move the platform device itself.

> +	},
> +	.num_resources  = ARRAY_SIZE(au1200sd0_res),
> +	.resource       = au1200sd0_res,
> +};
> +
> +#ifndef CONFIG_MIPS_DB1200

    Wait, SD controller 1 is there regardless of the board, so should be 
registerred regardless. If however the board doesn't have the necessary 
resources to support the driver functionality, I think it can be indicated by 
the board-level platform data, so that the driver could decide whether it 
wants to support that controller or not.

> +struct resource au1200sd1_res[] = {
> +	[0] = {
> +		.start	= CPHYSADDR(SD1_BASE),
> +		.end	= CPHYSADDR(SD1_BASE) + 0xff,

    Why not 0x40 if the controllers are symmetric I wonder? I'd say it should 
be 0x80000 even (and don't forget to sutract one ;-)...

WBR, Sergei


From mano@roarinelk.homelinux.net Thu May  8 14:08:40 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 14:08:44 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:19930 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20025772AbYEHNIk (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 14:08:40 +0100
Received: (qmail 26551 invoked by uid 1000); 8 May 2008 15:08:33 +0200
Date:	Thu, 8 May 2008 15:08:33 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platform
	device and board specific functions
Message-ID: <20080508130833.GA25971@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net> <20080507160634.GE17806@roarinelk.homelinux.net> <4822F4FC.5040107@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4822F4FC.5040107@ru.mvista.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19164
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 5541
Lines: 177

Hi Sergei,

On Thu, May 08, 2008 at 04:41:32PM +0400, Sergei Shtylyov wrote:
>> diff --git a/arch/mips/au1000/common/platform.c 
>> b/arch/mips/au1000/common/platform.c
>> index 31d2a22..08a5900 100644
>> --- a/arch/mips/au1000/common/platform.c
>> +++ b/arch/mips/au1000/common/platform.c
>> -
>> -static struct platform_device au1xxx_mmc_device = {
>> -	.name = "au1xxx-mmc",
>> -	.id = 0,
>> -	.dev = {
>> -		.dma_mask               = &au1xxx_mmc_dmamask,
>> -		.coherent_dma_mask      = 0xffffffff,
>> -	},
>> -	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
>> -	.resource       = au1xxx_mmc_resources,
>> -};
>>  #endif /* #ifdef CONFIG_SOC_AU1200 */
>
>    What board-specific was here?

Nothing in here per se, but a) I don't like this file, it registers
stuff some boards don't need/want,  b) this part is only interesting
for pb1200 board anyway. I moved it to the pb1200 platform.c because
of the function pointers for au1xmmc platdata.


>>  static struct platform_device au1x00_pcmcia_device = {
>> diff --git a/arch/mips/au1000/pb1200/platform.c 
>> b/arch/mips/au1000/pb1200/platform.c
>> index 5930110..bee2bf7 100644
>> --- a/arch/mips/au1000/pb1200/platform.c
>> +++ b/arch/mips/au1000/pb1200/platform.c
>> @@ -20,8 +20,17 @@
>>   #include <linux/init.h>
>>  #include <linux/platform_device.h>
>> +#include <linux/mmc/host.h>
>>   #include <asm/mach-au1x00/au1xxx.h>
>> +#include <asm/mach-au1x00/au1xxx_dbdma.h>
>> +#include <asm/mach-au1x00/au1100_mmc.h>
>> +
>> +#if defined(CONFIG_MIPS_PB1200)
>> +#include <asm/mach-pb1x00/pb1200.h>
>> +#elif defined(CONFIG_MIPS_DB1200)
>> +#include <asm/mach-db1x00/db1200.h>
>> +#endif
>
> #include <asm/mach-au1x00/au1xxx.h> does all that already -- you don't need 
> to
> include the board specific headers one more time.  Drop this part please.

Done.  I originally put it in because of compile errors wrt. BCSR register.


>> +static int pb1200mmc_card_readonly(void *mmc_host)
>> +{
>> +	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
>
>    Insert new line after a declaration please.
>
>> +	return (bcsr->status & au1xmmc_card_table[host->id].wpstatus) ? 1 : 0;
>> +}
>> +
>> +static int pb1200mmc_card_inserted(void *mmc_host)
>> +{
>> +	struct au1xmmc_host *host = mmc_priv((struct mmc_host *)mmc_host);
>
>    The same here.

Done and done,


>> +	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
>> +		? 1 : 0;
>> +}
>> +
>> +static struct au1xmmc_platdata db1xmmcpd = {
>> +	.set_power	= pb1200mmc_set_power,
>> +	.card_inserted	= pb1200mmc_card_inserted,
>> +	.card_readonly	= pb1200mmc_card_readonly,
>> +	.cd_setup	= NULL,		/* use poll-timer in driver */
>
>    Function ptrs in the platform data?  That's something new -- though why 
>  not? :-)

Is this an accepted way of doing things in the kernel?  If not, I'm open to
suggestions! (I prefer this to globally-visible methods called by the
driver.  I like it when related things are neatly grouped together).


>> +};
>> +
>> +static u64 au1xxx_mmc_dmamask =  ~(u32)0;
>> +
>> +struct resource au1200sd0_res[] = {
>> +	[0] = {
>> +		.start	= CPHYSADDR(SD0_BASE),
>
>    Why not just use SD0_PHYS_ADDR?
>
>> +		.end	= CPHYSADDR(SD0_BASE) + 0x40,
>
>    You've missed "- 1" here. Though it's alos not clear why 0x40 and not 
> 0x3c (there's not register at 0x3c) or 0x80000 -- the range used according 
> to the memory map...

I'll add the whole 0x80000 range ;-)


>> +	[3] = {
>> +		.start	= DSCR_CMD0_SDMS_TX0,
>> +		.flags	= IORESOURCE_DMA,
>> +	},
>> +	[4] = {
>> +		.start	= DSCR_CMD0_SDMS_RX0,
>> +		.flags	= IORESOURCE_DMA,
>> +	},
>> +};
>
>    Humm. The other devices (like IDE) should also claim DMA resources...

It was a convenient way to pass DDMA IDs without having to use 
a lookup table in the driver ;-)


>> +
>> +static struct platform_device au1200_sd0_device = {
>> +	.name = "au1xxx-mmc",
>> +	.id = 0,	/* index into au1xmmc_card_table[] */
>> +	.dev = {
>> +		.dma_mask               = &au1xxx_mmc_dmamask,
>> +		.coherent_dma_mask      = 0xffffffff,
>> +		.platform_data		= &db1xmmcpd,
>
>    Can't we leave the MMC platform device where it is but define the 
> platform data structure per board with some starndard name? Since IMO it 
> doesn't make sense to move the platform device itself.

I like my device setup data in one file (preferably living in the board
subdir), but for mainline inclusion I can move it back to its original
place if you and others prefer so.


>> +	},
>> +	.num_resources  = ARRAY_SIZE(au1200sd0_res),
>> +	.resource       = au1200sd0_res,
>> +};
>> +
>> +#ifndef CONFIG_MIPS_DB1200
>
>    Wait, SD controller 1 is there regardless of the board, so should be 
> registerred regardless. If however the board doesn't have the necessary 
> resources to support the driver functionality, I think it can be indicated 
> by the board-level platform data, so that the driver could decide whether 
> it wants to support that controller or not.

Won't this cause problems if e.g. you are using PCMCIA (since SD1 pins are
muxed with pcmcia signals)? 
In any case, I just followed the original code, which also disabled the 2nd
controller for the db1200.


>> +struct resource au1200sd1_res[] = {
>> +	[0] = {
>> +		.start	= CPHYSADDR(SD1_BASE),
>> +		.end	= CPHYSADDR(SD1_BASE) + 0xff,
>
>    Why not 0x40 if the controllers are symmetric I wonder? I'd say it 
> should be 0x80000 even (and don't forget to sutract one ;-)...

I corrected this (and wrong resource numbering) locally.


Thanks for looking at it!
	Manuel Lauss

From sshtylyov@ru.mvista.com Thu May  8 20:06:54 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 20:06:56 +0100 (BST)
Received: from rtsoft3.corbina.net ([85.21.88.6]:58929 "EHLO
	buildserver.ru.mvista.com") by ftp.linux-mips.org with ESMTP
	id S20023188AbYEHTGy (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 8 May 2008 20:06:54 +0100
Received: from wasted.dev.rtsoft.ru (unknown [10.150.0.9])
	by buildserver.ru.mvista.com (Postfix) with ESMTP
	id 1DA018815; Fri,  9 May 2008 00:06:51 +0500 (SAMST)
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
To:	ralf@linux-mips.org
Subject: [PATCH] Au1200: MMC resource size off by one
Date:	Thu, 8 May 2008 23:06:17 +0400
User-Agent: KMail/1.5
Cc:	linux-mips@linux-mips.org
MIME-Version: 1.0
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200805082306.17553.sshtylyov@ru.mvista.com>
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19165
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1107
Lines: 33

Au12x0 MMC platform device strangely claims 0x41 bytes for its memory-mapped
registers.  Make it claim the whole 0x80000 instead according to the memory
map given in the datasheets.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
Inspired by the patches posted by Manuel Lauss.
Should apply to the top of Linux/MIPS tree...

 arch/mips/au1000/common/platform.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/arch/mips/au1000/common/platform.c
===================================================================
--- linux-2.6.orig/arch/mips/au1000/common/platform.c
+++ linux-2.6/arch/mips/au1000/common/platform.c
@@ -165,12 +165,12 @@ static struct resource au1xxx_usb_gdt_re
 static struct resource au1xxx_mmc_resources[] = {
 	[0] = {
 		.start          = SD0_PHYS_ADDR,
-		.end            = SD0_PHYS_ADDR + 0x40,
+		.end            = SD0_PHYS_ADDR + 0x7ffff,
 		.flags          = IORESOURCE_MEM,
 	},
 	[1] = {
 		.start		= SD1_PHYS_ADDR,
-		.end 		= SD1_PHYS_ADDR + 0x40,
+		.end 		= SD1_PHYS_ADDR + 0x7ffff,
 		.flags		= IORESOURCE_MEM,
 	},
 	[2] = {


From sshtylyov@ru.mvista.com Thu May  8 20:31:02 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 20:31:05 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:18568 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20022744AbYEHTbC (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 20:31:02 +0100
Received: from [192.168.1.234] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id 9D6423EC9; Thu,  8 May 2008 12:30:57 -0700 (PDT)
Message-ID: <482354D0.9040304@ru.mvista.com>
Date:	Thu, 08 May 2008 23:30:24 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	Manuel Lauss <mano@roarinelk.homelinux.net>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platform	device
 and board specific functions
References: <20080507160154.GA17806@roarinelk.homelinux.net> <20080507160634.GE17806@roarinelk.homelinux.net> <4822F4FC.5040107@ru.mvista.com> <20080508130833.GA25971@roarinelk.homelinux.net>
In-Reply-To: <20080508130833.GA25971@roarinelk.homelinux.net>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19166
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 5759
Lines: 169

Manuel Lauss wrote:

>>>diff --git a/arch/mips/au1000/common/platform.c 
>>>b/arch/mips/au1000/common/platform.c
>>>index 31d2a22..08a5900 100644
>>>--- a/arch/mips/au1000/common/platform.c
>>>+++ b/arch/mips/au1000/common/platform.c
>>>-
>>>-static struct platform_device au1xxx_mmc_device = {
>>>-	.name = "au1xxx-mmc",
>>>-	.id = 0,
>>>-	.dev = {
>>>-		.dma_mask               = &au1xxx_mmc_dmamask,
>>>-		.coherent_dma_mask      = 0xffffffff,
>>>-	},
>>>-	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
>>>-	.resource       = au1xxx_mmc_resources,
>>>-};
>>> #endif /* #ifdef CONFIG_SOC_AU1200 */
>>
>>   What board-specific was here?

> Nothing in here per se, but a) I don't like this file, it registers
> stuff some boards don't need/want,  b) this part is only interesting
> for pb1200 board anyway.

    Sigh. Do you know that Au1100 also has the same MMC controllers? The 
platform device is not registered in this case though and the driver (however 
small it now actually uses the platform device per se) is therefore unable to 
control it (well, I'm not sure it can do that since it seems to be Au1200 
centered now (using DBDMA), however it was initially written for Au1100 as it 
seems.

> I moved it to the pb1200 platform.c because
> of the function pointers for au1xmmc platdata.

    I'm sure that can be handled without moving the device itself...

>>>diff --git a/arch/mips/au1000/pb1200/platform.c 
>>>b/arch/mips/au1000/pb1200/platform.c
>>>index 5930110..bee2bf7 100644
>>>--- a/arch/mips/au1000/pb1200/platform.c
>>>+++ b/arch/mips/au1000/pb1200/platform.c
>>>@@ -20,8 +20,17 @@
>>>  #include <linux/init.h>
>>> #include <linux/platform_device.h>
>>>+#include <linux/mmc/host.h>
>>>  #include <asm/mach-au1x00/au1xxx.h>
>>>+#include <asm/mach-au1x00/au1xxx_dbdma.h>
>>>+#include <asm/mach-au1x00/au1100_mmc.h>
>>>+
>>>+#if defined(CONFIG_MIPS_PB1200)
>>>+#include <asm/mach-pb1x00/pb1200.h>
>>>+#elif defined(CONFIG_MIPS_DB1200)
>>>+#include <asm/mach-db1x00/db1200.h>
>>>+#endif

>>#include <asm/mach-au1x00/au1xxx.h> does all that already -- you don't need 
>>to include the board specific headers one more time.  Drop this part please.

> Done.  I originally put it in because of compile errors wrt. BCSR register.

    Hm, why would there be any if au1xxx.h resolves the right board #include?

>>>+	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
>>>+		? 1 : 0;
>>>+}
>>>+
>>>+static struct au1xmmc_platdata db1xmmcpd = {
>>>+	.set_power	= pb1200mmc_set_power,
>>>+	.card_inserted	= pb1200mmc_card_inserted,
>>>+	.card_readonly	= pb1200mmc_card_readonly,
>>>+	.cd_setup	= NULL,		/* use poll-timer in driver */

>>   Function ptrs in the platform data?  That's something new -- though why 
>> not? :-)

> Is this an accepted way of doing things in the kernel?  If not, I'm open to
> suggestions!

    I really don't know -- never seen such trick before.

> (I prefer this to globally-visible methods called by the
> driver.  I like it when related things are neatly grouped together).

    Yes, this indeed looks better.

>>>+};
>>>+
>>>+static u64 au1xxx_mmc_dmamask =  ~(u32)0;
>>>+
>>>+struct resource au1200sd0_res[] = {
>>>+	[0] = {
>>>+		.start	= CPHYSADDR(SD0_BASE),

>>   Why not just use SD0_PHYS_ADDR?

>>>+		.end	= CPHYSADDR(SD0_BASE) + 0x40,

>>   You've missed "- 1" here. Though it's alos not clear why 0x40 and not 
>>0x3c (there's not register at 0x3c) or 0x80000 -- the range used according 
>>to the memory map...

> I'll add the whole 0x80000 range ;-)

    I've just posted a patch to fix this in the current code. Well, not that 
it matters much but I'm kind of pedantic. :-)

>>>+	[3] = {
>>>+		.start	= DSCR_CMD0_SDMS_TX0,
>>>+		.flags	= IORESOURCE_DMA,
>>>+	},
>>>+	[4] = {
>>>+		.start	= DSCR_CMD0_SDMS_RX0,
>>>+		.flags	= IORESOURCE_DMA,
>>>+	},
>>>+};

>>   Humm. The other devices (like IDE) should also claim DMA resources...

> It was a convenient way to pass DDMA IDs without having to use 
> a lookup table in the driver ;-)

    Humm, the DBDMA code seems to mean by "DMA channel" something different, 
see au1xxx_dbdma_chan_alloc()...

>>>+static struct platform_device au1200_sd0_device = {
>>>+	.name = "au1xxx-mmc",
>>>+	.id = 0,	/* index into au1xmmc_card_table[] */
>>>+	.dev = {
>>>+		.dma_mask               = &au1xxx_mmc_dmamask,
>>>+		.coherent_dma_mask      = 0xffffffff,
>>>+		.platform_data		= &db1xmmcpd,

>>   Can't we leave the MMC platform device where it is but define the 
>>platform data structure per board with some starndard name? Since IMO it 
>>doesn't make sense to move the platform device itself.

> I like my device setup data in one file (preferably living in the board
> subdir), but for mainline inclusion I can move it back to its original
> place if you and others prefer so.

    I'd definitely prefer to leave the SOC device where they were...

>>>+	},
>>>+	.num_resources  = ARRAY_SIZE(au1200sd0_res),
>>>+	.resource       = au1200sd0_res,
>>>+};
>>>+
>>>+#ifndef CONFIG_MIPS_DB1200

>>   Wait, SD controller 1 is there regardless of the board, so should be 
>>registerred regardless. If however the board doesn't have the necessary 
>>resources to support the driver functionality, I think it can be indicated 
>>by the board-level platform data, so that the driver could decide whether 
>>it wants to support that controller or not.

> Won't this cause problems if e.g. you are using PCMCIA (since SD1 pins are
> muxed with pcmcia signals)? 

    Good point.  I think that the code in arch/mips/au1000/common/platform.c 
should check the sys_pinfunc register, and not blindly register all devices.

> In any case, I just followed the original code, which also disabled the 2nd
> controller for the db1200.

    Indeed...

WBR, Sergei

From macro@linux-mips.org Thu May  8 23:44:23 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 08 May 2008 23:44:27 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:63225 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20023134AbYEHWoX (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 8 May 2008 23:44:23 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m48MhurR006072;
	Fri, 9 May 2008 00:43:56 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m48MhZOF006067;
	Thu, 8 May 2008 23:43:35 +0100
Date:	Thu, 8 May 2008 23:43:34 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Ralf Baechle <ralf@linux-mips.org>
cc:	Jean Delvare <khali@linux-fr.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080508045106.GB25531@linux-mips.org>
Message-ID: <Pine.LNX.4.55.0805082311410.5944@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507085953.2c08b854@hyperion.delvare> <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
 <20080508045106.GB25531@linux-mips.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19167
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 757
Lines: 17

On Thu, 8 May 2008, Ralf Baechle wrote:

> I like it; we maybe should consider getting rid of most of the libs-* stuff
> in arch/mips/Makefile.  Some of it might be causing subtle bugs such as
> routines exported to modules not getting linked into the kernel proper.

 Well, I think it should be reasonable to convert everything but lib/, the
latter being used for various implicit bits like strcpy() or whatever some
version of GCC may come up with.  Plus possibly generic code overridable
by boards for optimisation; I am not sure if we have got left any at the
moment though.

 With the much better configuration language of 2.6 and more and more 
stuff being done by magic sections bits built as libraries cause more 
hassle than convenience.

  Maciej

From macro@linux-mips.org Fri May  9 00:11:06 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 00:11:10 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:60922 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20023867AbYEHXLG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 00:11:06 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m48NAm8W006198;
	Fri, 9 May 2008 01:10:48 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m48NAld8006194;
	Fri, 9 May 2008 00:10:47 +0100
Date:	Fri, 9 May 2008 00:10:47 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	Ralf Baechle <ralf@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080508105905.3209c659@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805082344040.5944@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507085953.2c08b854@hyperion.delvare> <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
 <20080508105905.3209c659@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19168
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 4386
Lines: 87

Hi Jean,

> If you had to add a missing semicolon to a source file to get it to
> build again, it would be an "essential" change (without it nothing
> works) but still, you can't claim you added any intellectual value to

 Agreed about this example because the change is mechanical and can almost
be done by an automaton.

> the source file. So, no copyright. The copyright is about how much
> value you add, not how important the change is in the big picture.

 As I wrote, no big concern about it from my side and it looks I will be 
changing more of the file anyway. ;-)

> I'm not going to tell how bad I think the GNU coding standards are, the
> point here is that we don't follow them at all, so whatever they say is
> totally irrelevant. Read Documentation/CodingStyle, it describes what

 Oh come on -- that's just common sense.  If something is good, there is
no point in discarding it without thinking, just because it is a part of a
bigger entity that we consider bad.  I consider it good not because it is
a part of the GNU standard, but because I have concluded that it is and it
is pure coincidence ;-) I have taken it from the said standard.  But as I
said, this is a minor nit here and I can resist from adding extraneous
spaces in pieces of code you are interested in as long as I am able to
track which ones they actually are.

> we do. Also make sure that you run your patches through
> scripts/checkpatch.pl. The rest is up to you, but in general, when
> modifying existing code, you want to stick to what the surrounding code
> looks like.

 I had no problems with writing code checkpatch.pl would swallow without a
blink even before it existed.  It does not mean I should follow the
surrounding mess if this is what the state of code is.

> I do insist ;) Admittedly, double spaces at end of comments are used in
> some places in the kernel tree (I had never seen that before), but they
> are still outnumbered by single-space ending comments, 50 to 1. Do
> what you want in the drivers your create or maintain, but please don't
> change existing comments, especially not in the middle of functional
> changes.

 Fine with me, no problem.

> That's not a matter of being scared, and I was also _not_ asking you to
> split the patch. That's a matter of synchronizing merges between me and
> the architecture maintainer. If I take a patch in my i2c tree which
> touches architecture-specific files, and I only push it to Linus in 2
> months, then chances are that the architecture-specific files in
> question will change several times meanwhile, resulting in conflicts in
> -next and -mm. I am only trying to prevent this from happening. I
> simply think that it is easier to synchronize patches if all
> architecture-specific patches go through the relevant architecture tree.

 Your concern is valid and this is why I proposed the split.  My point
being, unlike the rest of the MIPS arch tree these days the Broadcom bits
are only touched from time to time by two or three people (myself
included), so it is much easier to coordinate changes if they are limited 
to this subarch.  Which means stripping out changes needed elsewhere from 
the i2c patch itself can only improve things.

> BTW, SWARM seems to be only one of the 4 SiByte platforms we support.

 I think nobody really knows for sure how many Broadcom/SiByte platforms 
we support at the moment. ;-)  I am fairly sure there is some interest in 
the BigSur, SWARM and Sentosa only.

> What about the other ones? Your changes to the i2c-sibyte driver could
> cause the i2c bus registration to fail, as the other platforms do not
> declare I2C devices, the bus numbers 0 and 1 won't be reserved by
> i2c-core. Care to comment on this?

 Well, arch/mips/sibyte/swarm/ is included for all the three above as well 
as a couple of other I may not necessarily be sure what they are even.  So 
this should be of no concern.

 BTW, do you mean i2c_add_numbered_adapter() will fail if no devices have
been declared to exist on the given bus with i2c_register_board_info()?  
That sounds strange...  Note in all cases there are EEPROMs (onboard ones
as well as optionally SPD ones) on both buses on Broadcom/SiByte boards
and they are handled by a legacy client driver.  The Broadcom SOC is
actually capable to bootstrap from one of these EEPROMs (rather than form
the usual system parallel Flash ROM).

  Maciej

From macro@linux-mips.org Fri May  9 01:18:06 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 01:18:08 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:60412 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20023576AbYEIASG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 01:18:06 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m490HbsK006475;
	Fri, 9 May 2008 02:17:37 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m490HMcN006468;
	Fri, 9 May 2008 01:17:23 +0100
Date:	Fri, 9 May 2008 01:17:21 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
cc:	a.zummo@towertech.it, khali@linux-fr.org, ralf@linux-mips.org,
	tglx@linutronix.de, akpm@linux-foundation.org,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	ab@mycable.de, mgreer@mvista.com
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80, etc. driver
In-Reply-To: <20080508.133847.74565891.nemoto@toshiba-tops.co.jp>
Message-ID: <Pine.LNX.4.55.0805090054300.5944@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070102460.16173@cliff.in.clinika.pl>
 <20080508.133847.74565891.nemoto@toshiba-tops.co.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19169
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 617
Lines: 17

On Thu, 8 May 2008, Atsushi Nemoto wrote:

> For write transfer, you must use only one i2c_msg.  If two i2c_msg
> were used, the slave address is inserted between register number and
> first data.  This chip cannot accept such sequence.

 Correct, thank you for pointing it out -- verified with the datasheet.  I 
will send an updated patch separately taking other suggestions into 
account as well.

> On success, m41t80_i2c_transfer() returns positive value, but
> m41t80_transfer() should return 0.

 I think the check should be for values below zero as originally instead.  
Thanks for the point again.

  Maciej

From vomlehn@texas.net Fri May  9 01:41:23 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 01:41:26 +0100 (BST)
Received: from smtp.sprintpcs.com ([68.28.27.84]:47236 "EHLO
	mta02.smtp.sprintpcs.com") by ftp.linux-mips.org with ESMTP
	id S20024779AbYEIAlX (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 01:41:23 +0100
Received: from [192.168.1.100] ([67.169.24.75])
 by lswsmta02.nmcc.sprintspectrum.com
 (iPlanet Messaging Server 5.2 HotFix 2.06 (built Mar 28 2005))
 with ESMTPA id <0K0K007QGSKCCS@lswsmta02.nmcc.sprintspectrum.com> for
 linux-mips@linux-mips.org; Thu, 08 May 2008 19:41:01 -0500 (CDT)
Date:	Thu, 08 May 2008 17:41:02 -0700
From:	David VomLehn <vomlehn@texas.net>
Subject: Re: Alchemy DB1200: do_cpu()
To:	abhiruchi.g@vaultinfo.com
Cc:	linux-mips@linux-mips.org
Message-id: <48239D9E.8040207@texas.net>
MIME-version: 1.0
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Content-transfer-encoding: 7BIT
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
Return-Path: <vomlehn@texas.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19170
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: vomlehn@texas.net
Precedence: bulk
X-list: linux-mips
Content-Length: 312
Lines: 12

>
> I am not able to find out:
>
>   From which function and which file "do_cpu()" is called?
Look in arch/mips/entry.S, line 414, or so. The assembler macro 
BUILD_HANDLER is used to create a function named handle_cpu, which does 
a jump to do_cpu.

-- 
David VomLehn         +1 512-297-7814
vomlehn@texas.net


From macro@linux-mips.org Fri May  9 01:43:53 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 01:43:56 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:2302 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20024936AbYEIAnx (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 01:43:53 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m490hfeF006607;
	Fri, 9 May 2008 02:43:41 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m490hWtF006603;
	Fri, 9 May 2008 01:43:37 +0100
Date:	Fri, 9 May 2008 01:43:32 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	David Brownell <david-b@pacbell.net>
cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, ab@mycable.de,
	mgreer@mvista.com, i2c@lm-sensors.org, rtc-linux@googlegroups.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
In-Reply-To: <200805071625.20430.david-b@pacbell.net>
Message-ID: <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
 <Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
 <200805071625.20430.david-b@pacbell.net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19171
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 19937
Lines: 619

Hi David,

 Please do not remove other lists cc-ed as there are people interested in 
this piece of hardware who are neither on i2c nor on rtc-linux (I am on 
neither of the lists too).

> >  Do you mean our generic I2C code emulates SMBus calls if the hardware
> > does not support them directly?  Well, it looks to me it indeed does and
> > you are right, but I have assumed, perhaps mistakenly, (but I generally
> > trust if a piece of code is there, it is for a reason), that this driver
> > checks for I2C_FUNC_SMBUS_BYTE_DATA for a purpose.
> 
> That purpose being:  it makes those SMBus calls explicitly.
> (And it makes i2c_transfer calls explicitly too...)

 Then, given the emulation, the client should be satisfied with either of
the flags instead of both at a time.  Exactly how I changed it.

> > The extensions are 16-bit commands 
> > (required by another RTC chip used on some of these boards) and an obscure
> > subset of the process call and block read/write commands (called an EEPROM
> > read and an extended write/read, respectively).
> 
> Subset of process call??  That's send-three-bytes, receive-two-bytes.
> Not possible to subset it ... anything else isn't a process call!!

 I misinterpreted the SMBus spec -- I have thought the receive part is
variable, sorry.  The controller implements a command which issues a write
byte transfer followed by a receive four bytes transfer.  Not quite a
process call although the idea is the same.

> Presumably those block read/write commands aren't quite enough
> for you to implement i2c_smbus_read_i2c_block_data() and friend?

 You can issue a block read of up to 5 bytes (6 if you add the PEC byte
which is not interpreted by the controller in any way).  And you can issue
a block write of up to 4 bytes (5 with PEC).  That's clearly not enough
for the m41t81 let alone a generic implementation.

 But as Atsushi-san pointed out, the block transfer transactions
implemented by the M41T81 do not quite follow the rules of SMBus block
transfers, so the call is out of question -- either i2c_transfer() or a
sequence of byte transactions have to be used.

> >  I feel a bit uneasy about unconditional emulation of SMBus block calls
> > with a series of corresponding byte read/write calls.  The reason is it
> > changes the semantics
> 
> No it doesn't.  The I2C signal transitions (SCL/SDA) will be
> exactly the same.  It's IMO very misleading to call it "emulation"
> since it's nothing more than a different software interface to
> the same functionality.

 It is not the same.  Assuming a write for a block transfer you have:

start:address:ack:command:ack:data:ack:data:ack:data:ack...stop

on the wire while for a series of byte calls you have:

start:address:ack:command:ack:data:ack:stop:start:address:ack:command:ack:data:ack:stop:start:address:ack:command:ack:data:ack...stop

This is what I mean here -- I gather you are thinking in the terms of raw 
I2C block vs SMBus block transfer.

> > Admittedly in this case the effect 
> > of the difference can be eliminated by rereading the least significant 
> > part of the timestamp considered, but it cannot be universally guaranteed.  
> > Which is why I would prefer not to hide these details behind an interface.
> 
> That would be internal to the m41t80 driver, not part of the
> i2c core.  (As your patch already does ...)

 It could be useful enough for other drivers to have the emulated calls 
available as a part of the API.  No need to rush adding that though 
obviously -- we can wait till we have a user (now that this driver has 
been ruled out).

> >  I think a pair of functions called i2c_smbus_read_i2c_byte_data() and
> > i2c_smbus_write_i2c_byte_data() could be added to the core though.
> 
> Too late.  Those calls have been in the I2C core for a long
> time now.  ;)

 A mental shortcut, sorry.  I meant these functions would perform block
transfers internally either by calling
i2c_smbus_xfer(I2C_SMBUS_I2C_BLOCK_DATA)/i2c_transfer() or, if neither
supported by a given controller, by performing an appropriate sequence of
i2c_smbus_xfer(I2C_SMBUS_BYTE_DATA) calls.

> > Their 
> > implementations might choose either byte or block transfers as available
> > within a given SMBus controller and they could be used by drivers known
> > for sure not to care about which kind of the transfers is uses (either
> > because the relevant piece of hardware does not care or because the driver
> > caters for either scenario).  What do you think?
> 
> You shouldn't think about changing the i2c core for that.

 It would not be a great idea to have the same piece of code duplicated in 
all the client drivers needing it, but we can certainly wait with that -- 
see above.

> >  BTW, as mentioned elsewhere the SMBus controller of the BCM1250A SOC can
> > be switched into a bit-banged raw I2C mode, where you can send whatever
> > you want over the bus and block tranfers would not be a problem at all,
> > but hopefully you agree this is not necessarily the best idea ever.
> 
> Between two drivers that both busy-wait and burn CPU cycles, I'd
> much rather have the one that provides the full functionality
> needed for the bus.  So I'd choose that bitbanger, no question.

 I suppose some care would have to be taken with the bit-banger so that 
the clock's frequency is not a complex function of time on its own.  Which 
means interrupts disabled, etc.

> If the SMBus driver were more functional, AND didn't busy-wait,
> then I'd consider using the native hardware.

 Oh, that can be rectified, no problem.  The controller does have
interrupt outputs that can be asserted on the busy-to-non-busy transition
as well as an error.  There is one per each of the two buses.  Plus the
silicon will retry aborted transfers itself up to 15 times before it gives
up with an error.  I can prepare a separate patch to address this issue --
I hate these devices operating in a polled manner unnecessarily too.

 BTW, the SOC has enough internal interrupt sources you can almost assume
if anything looks remotely like being able to make reasonable use of an
interrupt line it most likely has one.  It's somewhat worse outside the
SOC on this particular board -- to the best of my knowledge, the M41T81's
interrupt output is unfortunately not routed anywhere -- otherwise it's
alarm feature could be reasonably utilised; perhaps the periodic interrupt
as well.

 The reason is probably they did run out of external interrupt inputs --
of all the 16 allocatable GPIO lines, 10 are taken by a PCMCIA interface
and 2 are used for outputs.  The remaining four are actually used as
interrupts, but all taken by other devices.  There are some 16 (IIRC)  
unused interrupt inputs in the HT-PCI bridge, but that bridge was made by
some other company Broadcom might have not wanted to support too
aggresively. ;-)

 Here is a new version of the patch.  I hope I have addressed all your
concerns, but I am officially dead at the moment, so please do not disturb
me until this is no longer the case.

  Maciej

patch-2.6.26-rc1-20080505-m41t80-smbus-13
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-09 00:32:39.000000000 +0000
@@ -6,6 +6,8 @@
  * Based on m41t00.c by Mark A. Greer <mgreer@mvista.com>
  *
  * 2006 (c) mycable GmbH
+ * Copyright (c) 2008  Maciej W. Rozycki
+ * Copyright (c) 2008  Atsushi Nemoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -15,6 +17,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/i2c.h>
@@ -36,6 +39,8 @@
 #define M41T80_REG_DAY	5
 #define M41T80_REG_MON	6
 #define M41T80_REG_YEAR	7
+#define M41T80_REG_CONTROL	8
+#define M41T80_REG_WATCHDOG	9
 #define M41T80_REG_ALARM_MON	0xa
 #define M41T80_REG_ALARM_DAY	0xb
 #define M41T80_REG_ALARM_HOUR	0xc
@@ -58,7 +63,7 @@
 #define M41T80_FEATURE_HT	(1 << 0)
 #define M41T80_FEATURE_BL	(1 << 1)
 
-#define DRV_VERSION "0.05"
+#define DRV_VERSION "0.06"
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t80", 0 },
@@ -78,31 +83,104 @@ struct m41t80_data {
 	struct rtc_device *rtc;
 };
 
-static int m41t80_get_datetime(struct i2c_client *client,
-			       struct rtc_time *tm)
+
+static int m41t80_i2c_write(struct i2c_client *client, u8 reg, u8 num, u8 *buf)
+{
+	u8 wbuf[num + 1];
+	struct i2c_msg msgs[] = {
+		{
+			.addr	= client->addr,
+			.flags	= 0,
+			.len	= num + 1,
+			.buf	= wbuf,
+		},
+	};
+
+	wbuf[0] = reg;
+	memcpy(wbuf + 1, buf, num);
+	return i2c_transfer(client->adapter, msgs, 1);
+}
+
+static int m41t80_i2c_read(struct i2c_client *client, u8 reg, u8 num, u8 *buf)
 {
-	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
 	struct i2c_msg msgs[] = {
 		{
 			.addr	= client->addr,
 			.flags	= 0,
 			.len	= 1,
-			.buf	= dt_addr,
+			.buf	= &reg,
 		},
 		{
 			.addr	= client->addr,
 			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
+			.len	= num,
+			.buf	= buf,
 		},
 	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
-		dev_err(&client->dev, "read error\n");
-		return -EIO;
-	}
+	return i2c_transfer(client->adapter, msgs, 2);
+}
+
+static int m41t80_transfer(struct i2c_client *client, int write,
+			   u8 reg, u8 num, u8 *buf)
+{
+	int i, rc;
+
+	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+		if (write)
+			i = m41t80_i2c_write(client, reg, num, buf);
+		else
+			i = m41t80_i2c_read(client, reg, num, buf);
+	} else {
+		if (write)
+			for (i = 0; i < num; i++) {
+				rc = i2c_smbus_write_byte_data(client, reg + i,
+							       buf[i]);
+				if (rc < 0)
+					return rc;
+			}
+		else
+			for (i = 0; i < num; i++) {
+				rc = i2c_smbus_read_byte_data(client, reg + i);
+				if (rc < 0)
+					return rc;
+				buf[i] = rc;
+			}
+	}
+	return i;
+}
+
+static int m41t80_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+	u8 buf[M41T80_DATETIME_REG_SIZE];
+	int loops = 2;
+	int sec0, sec1;
+
+	/*
+	 * Time registers are latched by this chip if an I2C block
+	 * transfer is used, but with SMBus-style byte accesses
+	 * this is not the case, so check seconds for a wraparound.
+	 */
+	do {
+		if (m41t80_transfer(client, 0, M41T80_REG_SEC,
+				    M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+				    buf + M41T80_REG_SEC) < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+		sec0 = buf[M41T80_REG_SEC];
+
+		sec1 = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+		if (sec1 < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+
+		sec0 = BCD2BIN(sec0 & 0x7f);
+		sec1 = BCD2BIN(sec1 & 0x7f);
+	} while (sec1 < sec0 && --loops);
 
-	tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f);
+	tm->tm_sec = sec1;
 	tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f);
 	tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f);
 	tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f);
@@ -117,39 +195,16 @@ static int m41t80_get_datetime(struct i2
 /* Sets the given date and time to the real time clock. */
 static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-	u8 wbuf[1 + M41T80_DATETIME_REG_SIZE];
-	u8 *buf = &wbuf[1];
-	u8 dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_DATETIME_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
+	u8 buf[M41T80_DATETIME_REG_SIZE];
 
 	/* Read current reg values into buf[1..7] */
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_SEC,
+			    M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+			    buf + M41T80_REG_SEC) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
 
-	wbuf[0] = 0; /* offset into rtc's regs */
 	/* Merge time-data and register flags into buf[0..7] */
 	buf[M41T80_REG_SSEC] = 0;
 	buf[M41T80_REG_SEC] =
@@ -167,7 +222,8 @@ static int m41t80_set_datetime(struct i2
 	/* assume 20YY not 19YY */
 	buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_transfer(client, 1, M41T80_REG_SSEC,
+			    M41T80_DATETIME_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -241,34 +297,11 @@ err:
 static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 wbuf[1 + M41T80_ALARM_REG_SIZE];
-	u8 *buf = &wbuf[1];
+	u8 buf[M41T80_ALARM_REG_SIZE];
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE,
-			.buf	= buf,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_ALARM_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
 
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -278,7 +311,6 @@ static int m41t80_rtc_set_alarm(struct d
 	reg[M41T80_REG_ALARM_MIN] = 0;
 	reg[M41T80_REG_ALARM_SEC] = 0;
 
-	wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */
 	reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ?
 		BIN2BCD(t->time.tm_sec) : 0x80;
 	reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ?
@@ -292,7 +324,8 @@ static int m41t80_rtc_set_alarm(struct d
 	else
 		reg[M41T80_REG_ALARM_DAY] |= 0x40;
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_transfer(client, 1, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -311,25 +344,11 @@ static int m41t80_rtc_set_alarm(struct d
 static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 buf[M41T80_ALARM_REG_SIZE + 1]; /* all alarm regs and flags */
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
+	u8 buf[M41T80_ALARM_REG_SIZE + 1];	/* all alarm regs and flags */
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE + 1,
-			.buf	= buf,
-		},
-	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE + 1, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -488,26 +507,16 @@ static int boot_flag;
  */
 static void wdt_ping(void)
 {
-	unsigned char i2c_data[2];
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-	i2c_data[0] = 0x09;		/* watchdog register */
+	u8 wdt = 0x80;				/* WDS = 1 (0x80)  */
 
 	if (wdt_margin > 31)
-		i2c_data[1] = (wdt_margin & 0xFC) | 0x83; /* resolution = 4s */
+		/* mulitplier = WD_TIMO / 4, resolution = 4s (0x3)  */
+		wdt |= (wdt_margin & 0xfc) | 0x3;
 	else
-		/*
-		 * WDS = 1 (0x80), mulitplier = WD_TIMO, resolution = 1s (0x02)
-		 */
-		i2c_data[1] = wdt_margin<<2 | 0x82;
+		/* mulitplier = WD_TIMO, resolution = 1s (0x2)  */
+		wdt |= wdt_margin << 2 | 0x2;
 
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, wdt);
 }
 
 /**
@@ -517,36 +526,8 @@ static void wdt_ping(void)
  */
 static void wdt_disable(void)
 {
-	unsigned char i2c_data[2], i2c_buf[0x10];
-	struct i2c_msg msgs0[2] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= i2c_data,
-		},
-		{
-			.addr	= save_client->addr,
-			.flags	= I2C_M_RD,
-			.len	= 1,
-			.buf	= i2c_buf,
-		},
-	};
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-
-	i2c_data[0] = 0x09;
-	i2c_transfer(save_client->adapter, msgs0, 2);
-
-	i2c_data[0] = 0x09;
-	i2c_data[1] = 0x00;
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_read_byte_data(save_client, M41T80_REG_WATCHDOG);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, 0);
 }
 
 /**
@@ -629,14 +610,12 @@ static int wdt_ioctl(struct inode *inode
 			return -EFAULT;
 
 		if (rv & WDIOS_DISABLECARD) {
-			printk(KERN_INFO
-			       "rtc-m41t80: disable watchdog\n");
+			pr_info("rtc-m41t80: disable watchdog\n");
 			wdt_disable();
 		}
 
 		if (rv & WDIOS_ENABLECARD) {
-			printk(KERN_INFO
-			       "rtc-m41t80: enable watchdog\n");
+			pr_info("rtc-m41t80: enable watchdog\n");
 			wdt_ping();
 		}
 
@@ -732,19 +711,28 @@ static struct notifier_block wdt_notifie
 static int m41t80_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
-	int rc = 0;
 	struct rtc_device *rtc = NULL;
 	struct rtc_time tm;
 	struct m41t80_data *clientdata = NULL;
+	int rc = 0;
+	int reg;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
-				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
+	if ((i2c_get_functionality(client->adapter) &
+	     (I2C_FUNC_I2C | I2C_FUNC_SMBUS_BYTE_DATA)) == 0) {
 		rc = -ENODEV;
 		goto exit;
 	}
 
+	/* Trivially check it's there; keep the result for the HT check.  */
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
+	if (reg < 0) {
+		rc = -ENXIO;
+		goto exit;
+	}
+
 	dev_info(&client->dev,
-		 "chip found, driver version " DRV_VERSION "\n");
+		 "%s chip found, driver version " DRV_VERSION "\n",
+		 client->name);
 
 	clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL);
 	if (!clientdata) {
@@ -765,11 +753,7 @@ static int m41t80_probe(struct i2c_clien
 	i2c_set_clientdata(client, clientdata);
 
 	/* Make sure HT (Halt Update) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
-	if (rc < 0)
-		goto ht_err;
-
-	if (rc & M41T80_ALHOUR_HT) {
+	if (reg & M41T80_ALHOUR_HT) {
 		if (clientdata->features & M41T80_FEATURE_HT) {
 			m41t80_get_datetime(client, &tm);
 			dev_info(&client->dev, "HT bit was set!\n");
@@ -780,20 +764,19 @@ static int m41t80_probe(struct i2c_clien
 				 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
 				 tm.tm_min, tm.tm_sec);
 		}
-		if (i2c_smbus_write_byte_data(client,
-					      M41T80_REG_ALARM_HOUR,
-					      rc & ~M41T80_ALHOUR_HT) < 0)
+		if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR,
+					      reg & ~M41T80_ALHOUR_HT) < 0)
 			goto ht_err;
 	}
 
 	/* Make sure ST (stop) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
-	if (rc < 0)
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+	if (reg < 0)
 		goto st_err;
 
-	if (rc & M41T80_SEC_ST) {
+	if (reg & M41T80_SEC_ST) {
 		if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
-					      rc & ~M41T80_SEC_ST) < 0)
+					      reg & ~M41T80_SEC_ST) < 0)
 			goto st_err;
 	}
 
@@ -803,6 +786,7 @@ static int m41t80_probe(struct i2c_clien
 
 #ifdef CONFIG_RTC_DRV_M41T80_WDT
 	if (clientdata->features & M41T80_FEATURE_HT) {
+		save_client = client;
 		rc = misc_register(&wdt_dev);
 		if (rc)
 			goto exit;
@@ -811,7 +795,6 @@ static int m41t80_probe(struct i2c_clien
 			misc_deregister(&wdt_dev);
 			goto exit;
 		}
-		save_client = client;
 	}
 #endif
 	return 0;

From mano@roarinelk.homelinux.net Fri May  9 06:40:15 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 06:40:18 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:57037 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20022410AbYEIFkP (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 06:40:15 +0100
Received: (qmail 593 invoked by uid 1000); 9 May 2008 07:40:10 +0200
Date:	Fri, 9 May 2008 07:40:10 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platform
	device and board specific functions
Message-ID: <20080509054010.GA32719@roarinelk.homelinux.net>
References: <20080507160154.GA17806@roarinelk.homelinux.net> <20080507160634.GE17806@roarinelk.homelinux.net> <4822F4FC.5040107@ru.mvista.com> <20080508130833.GA25971@roarinelk.homelinux.net> <482354D0.9040304@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <482354D0.9040304@ru.mvista.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19172
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 4267
Lines: 123

On Thu, May 08, 2008 at 11:30:24PM +0400, Sergei Shtylyov wrote:
> Manuel Lauss wrote:
>
>>>> diff --git a/arch/mips/au1000/common/platform.c 
>>>> b/arch/mips/au1000/common/platform.c
>>>> index 31d2a22..08a5900 100644
>>>> --- a/arch/mips/au1000/common/platform.c
>>>> +++ b/arch/mips/au1000/common/platform.c
>>>> -
>>>> -static struct platform_device au1xxx_mmc_device = {
>>>> -	.name = "au1xxx-mmc",
>>>> -	.id = 0,
>>>> -	.dev = {
>>>> -		.dma_mask               = &au1xxx_mmc_dmamask,
>>>> -		.coherent_dma_mask      = 0xffffffff,
>>>> -	},
>>>> -	.num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
>>>> -	.resource       = au1xxx_mmc_resources,
>>>> -};
>>>> #endif /* #ifdef CONFIG_SOC_AU1200 */
>>>
>>>   What board-specific was here?
>
>> Nothing in here per se, but a) I don't like this file, it registers
>> stuff some boards don't need/want,  b) this part is only interesting
>> for pb1200 board anyway.
>
>    Sigh. Do you know that Au1100 also has the same MMC controllers? The 
> platform device is not registered in this case though and the driver 
> (however small it now actually uses the platform device per se) is 
> therefore unable to control it (well, I'm not sure it can do that since it 
> seems to be Au1200 centered now (using DBDMA), however it was initially 
> written for Au1100 as it seems.

I gathered that from the driver source...

I assume the PIO paths in the driver are intended for the Au1100, correct?
Should not be too hard to force PIO paths when no DDMA IDs are passed
through the platform device's resources.
Someone should test it on Au1100 though.


>> I moved it to the pb1200 platform.c because
>> of the function pointers for au1xmmc platdata.
>
>    I'm sure that can be handled without moving the device itself...

Okay...


>>>> +	return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
>>>> +		? 1 : 0;
>>>> +}
>>>> +
>>>> +static struct au1xmmc_platdata db1xmmcpd = {
>>>> +	.set_power	= pb1200mmc_set_power,
>>>> +	.card_inserted	= pb1200mmc_card_inserted,
>>>> +	.card_readonly	= pb1200mmc_card_readonly,
>>>> +	.cd_setup	= NULL,		/* use poll-timer in driver */
>
>>>   Function ptrs in the platform data?  That's something new -- though why 
>>> not? :-)
>
>> Is this an accepted way of doing things in the kernel?  If not, I'm open 
>> to
>> suggestions!
>
>    I really don't know -- never seen such trick before.
>
>> (I prefer this to globally-visible methods called by the
>> driver.  I like it when related things are neatly grouped together).
>
>    Yes, this indeed looks better.
>

Unless someone else speaks up against it, I'll leave it the way it is.


>>>> +static struct platform_device au1200_sd0_device = {
>>>> +	.name = "au1xxx-mmc",
>>>> +	.id = 0,	/* index into au1xmmc_card_table[] */
>>>> +	.dev = {
>>>> +		.dma_mask               = &au1xxx_mmc_dmamask,
>>>> +		.coherent_dma_mask      = 0xffffffff,
>>>> +		.platform_data		= &db1xmmcpd,
>
>>>   Can't we leave the MMC platform device where it is but define the 
>>> platform data structure per board with some starndard name? Since IMO it 
>>> doesn't make sense to move the platform device itself.
>
>> I like my device setup data in one file (preferably living in the board
>> subdir), but for mainline inclusion I can move it back to its original
>> place if you and others prefer so.
>
>    I'd definitely prefer to leave the SOC device where they were...

Okay.


>>>> +	},
>>>> +	.num_resources  = ARRAY_SIZE(au1200sd0_res),
>>>> +	.resource       = au1200sd0_res,
>>>> +};
>>>> +
>>>> +#ifndef CONFIG_MIPS_DB1200
>
>>>   Wait, SD controller 1 is there regardless of the board, so should be 
>>> registerred regardless. If however the board doesn't have the necessary 
>>> resources to support the driver functionality, I think it can be 
>>> indicated by the board-level platform data, so that the driver could 
>>> decide whether it wants to support that controller or not.
>
>> Won't this cause problems if e.g. you are using PCMCIA (since SD1 pins are
>> muxed with pcmcia signals)? 
>
>    Good point.  I think that the code in arch/mips/au1000/common/platform.c 
> should check the sys_pinfunc register, and not blindly register all 
> devices.

Hm, sounds ugly, but I'll add something.

Thanks!
	Manuel Lauss

From zzh.hust@gmail.com Fri May  9 07:54:35 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 07:54:37 +0100 (BST)
Received: from ti-out-0910.google.com ([209.85.142.187]:46870 "EHLO
	ti-out-0910.google.com") by ftp.linux-mips.org with ESMTP
	id S20023693AbYEIGyf (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 07:54:35 +0100
Received: by ti-out-0910.google.com with SMTP id i7so417092tid.20
        for <linux-mips@linux-mips.org>; Thu, 08 May 2008 23:54:29 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type;
        bh=IldOvj1Zno9+nqgRD3YU0CaROgbIIhfNRnj0IOnvv90=;
        b=lxONG9tKbS91iYCId1egijeSj8iXnua903X2hi+S8zznZQEEepv/52miiF6fPHttrwcSgAiAzTGX5ppU12nETLym2zTDt9/NDqBpbqXYVYvNO+zYVuEOHf9rNWOKCY/hs0sRH2TyqK5oIXfXdtJRShOUsMXL/wqBvBNsrjfacsQ=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:mime-version:content-type;
        b=w6itR6IfQIoJCV721KXFkmaL352vasDehQgfLj9YZYs7FA869ASRfsoPlr5YXj+6W0+GHf6LWLln5MtqET6tDtiStd8CXDQu/Nigk+8KZt05PODJE7MUFm5dGCQ7yszpXhzDA9p3MArgtUSQaS83YFBHHZbUqSyWtOqdNvIVTQI=
Received: by 10.110.15.9 with SMTP id 9mr399784tio.44.1210316069127;
        Thu, 08 May 2008 23:54:29 -0700 (PDT)
Received: by 10.110.42.3 with HTTP; Thu, 8 May 2008 23:54:29 -0700 (PDT)
Message-ID: <50c9a2250805082354x1edc1ecar89dcc3378b3bbe75@mail.gmail.com>
Date:	Fri, 9 May 2008 14:54:29 +0800
From:	zhuzhenhua <zzh.hust@gmail.com>
To:	linux-mips <linux-mips@linux-mips.org>
Subject: is remap_pfn_range should align to 2(n) * (page size) ?
MIME-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_3407_14612540.1210316069190"
Return-Path: <zzh.hust@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19173
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: zzh.hust@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1229
Lines: 27

------=_Part_3407_14612540.1210316069190
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hello all
           i have a sensor driver want to malloc 2.xM SDRAM to capture
data(using DMA),  so i used  remap_pfn_range to malloc 3M.
But in /proc/meminfo, it showes free memory reduce 4M. i also check the
/proc/buddyinfo, it seemes too.
(i am looking inside kernel code, but not get clear at now).

 is remap_pfn_range should align to  2(n) * (page size) ?

thanks for any hints

zzh

------=_Part_3407_14612540.1210316069190
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hello all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i have a sensor driver want to malloc 2.xM SDRAM to capture data(using DMA),&nbsp; so i used&nbsp; remap_pfn_range to malloc 3M.<br>But in /proc/meminfo, it showes free memory reduce 4M. i also check the /proc/buddyinfo, it seemes too.<br>
(i am looking inside kernel code, but not get clear at now).<br><br>&nbsp;is remap_pfn_range should align to&nbsp; 2(n) * (page size) ?&nbsp; <br><br>thanks for any hints<br><br>zzh<br>

------=_Part_3407_14612540.1210316069190--

From khali@linux-fr.org Fri May  9 08:28:51 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 08:28:54 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:34163 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20023171AbYEIH2v (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 08:28:51 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JuNyM-0003US-J9
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Fri, 09 May 2008 10:28:58 +0200
Date:	Fri, 9 May 2008 09:28:35 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Ralf Baechle <ralf@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080509092835.3bbf0f55@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805082344040.5944@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
	<20080507085953.2c08b854@hyperion.delvare>
	<Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
	<20080508105905.3209c659@hyperion.delvare>
	<Pine.LNX.4.55.0805082344040.5944@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19174
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3954
Lines: 80

Hi Maciej,

On Fri, 9 May 2008 00:10:47 +0100 (BST), Maciej W. Rozycki wrote:
> > I'm not going to tell how bad I think the GNU coding standards are, the
> > point here is that we don't follow them at all, so whatever they say is
> > totally irrelevant. Read Documentation/CodingStyle, it describes what
> 
>  Oh come on -- that's just common sense.  If something is good, there is
> no point in discarding it without thinking, just because it is a part of a
> bigger entity that we consider bad.  I consider it good not because it is
> a part of the GNU standard, but because I have concluded that it is and it
> is pure coincidence ;-) I have taken it from the said standard.

Let me just quote you:

"This is mostly habitual -- this is what the GNU Coding Standard specifies
for comments and which is enforced for GNU software which I have dealt a
lot with."

You didn't say it was common sense. You did say that it was what the
GNU Coding Standard specified, and as a consequence, what you were used
to. So please keep your "oh come on" for yourself, you pointed the
discussion in this direction yourself.

>                                                                   But as I
> said, this is a minor nit here and I can resist from adding extraneous
> spaces in pieces of code you are interested in as long as I am able to
> track which ones they actually are.

What matters is not "the pieces of code I am interested in", but the
pieces of code _you_ are the master of, or not. As explained somewhere
else in this thread, you are free to use whatever style you like (as
long as it complies with Documentation/CodingStyle, that is) in new
code you write and in code you maintain. For all the rest, you should
stick to the surrounding style. This is common sense, as you'd say.

> (...)
>  Well, arch/mips/sibyte/swarm/ is included for all the three above as well 
> as a couple of other I may not necessarily be sure what they are even.  So 
> this should be of no concern.
> 
>  BTW, do you mean i2c_add_numbered_adapter() will fail if no devices have
> been declared to exist on the given bus with i2c_register_board_info()?  
> That sounds strange...

i2c_add_numbered_adapter() _may_ fail if no I2C devices have been
declared _and_ other i2c adapters are registered using
i2c_add_adapter(). When you declare I2C devices, i2c-core reserves the
bus numbers in question for i2c_add_numbered_adapter() and they cannot
be used for i2c_add_adapter(). This is what guarantees that the calls
to i2c_add_numbered_adapter() (in i2c-sibyte for example) will succeed.
If no I2C devices are declared, bus numbers are not reserved, so if it
happens that another I2C bus driver registers itself before i2c-sibyte
does, when i2c-sibyte calls i2c_add_numbered_adapter(), the bus number
is already in use and the call fails.

I admit that this is unlikely to happen, but depending on what exact
hardware there is on the system and what drivers are built-in, it could
happen. I think it is a weakness of i2c-core, it should allow platform
code to reserve i2c bus numbers regardless of what devices are
registered. I seem to remember I said that when the code was added to
the kernel already. I guess we'll have to fix it the day it actually
breaks.

BTW, i2c-sibyte should be converted to a proper platform driver, so
that only platforms with such a device instantiate it.

>                         Note in all cases there are EEPROMs (onboard ones
> as well as optionally SPD ones) on both buses on Broadcom/SiByte boards
> and they are handled by a legacy client driver.  The Broadcom SOC is
> actually capable to bootstrap from one of these EEPROMs (rather than form
> the usual system parallel Flash ROM).

Which legacy driver, "eeprom"? You should probably look into David
Brownell's at24c driver:
http://lists.lm-sensors.org/pipermail/i2c/2008-April/003307.html
If it gets enough attention and testing, it could go upstream quickly.

-- 
Jean Delvare

From khali@linux-fr.org Fri May  9 09:09:00 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 09:09:03 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:15128 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20023433AbYEIIJA (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 09:09:00 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JuOb9-0003iq-VO
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Fri, 09 May 2008 11:09:04 +0200
Date:	Fri, 9 May 2008 10:08:41 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	David Brownell <david-b@pacbell.net>, linux-mips@linux-mips.org,
	mgreer@mvista.com, rtc-linux@googlegroups.com,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de,
	Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: [i2c] [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
Message-ID: <20080509100841.151eabcd@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
	<Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
	<200805071625.20430.david-b@pacbell.net>
	<Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19175
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 10195
Lines: 322

Hi Maciej,

On Fri, 9 May 2008 01:43:32 +0100 (BST), Maciej W. Rozycki wrote:
>  Please do not remove other lists cc-ed as there are people interested in 
> this piece of hardware who are neither on i2c nor on rtc-linux (I am on 
> neither of the lists too).

Maybe you shouldn't have included 4 different mailing lists to start
with, especially for a patch which is rather hardware-specific and not
overly important.

> > >  Do you mean our generic I2C code emulates SMBus calls if the hardware
> > > does not support them directly?  Well, it looks to me it indeed does and
> > > you are right, but I have assumed, perhaps mistakenly, (but I generally
> > > trust if a piece of code is there, it is for a reason), that this driver
> > > checks for I2C_FUNC_SMBUS_BYTE_DATA for a purpose.
> > 
> > That purpose being:  it makes those SMBus calls explicitly.
> > (And it makes i2c_transfer calls explicitly too...)
> 
>  Then, given the emulation, the client should be satisfied with either of
> the flags instead of both at a time.  Exactly how I changed it.

You're going in the right direction, but it's not yet correct.

>  But as Atsushi-san pointed out, the block transfer transactions
> implemented by the M41T81 do not quite follow the rules of SMBus block
> transfers, so the call is out of question -- either i2c_transfer() or a
> sequence of byte transactions have to be used.

As I already wrote, what the M41T81 wants is _I2C_ block transactions,
not _SMBus_ block transactions. Both are supported by i2c-core, it's
just a matter of checking the right functionality flag and calling the
right helper function.

> (...)
>  Here is a new version of the patch.  I hope I have addressed all your
> concerns, but I am officially dead at the moment, so please do not disturb
> me until this is no longer the case.
> 
>   Maciej
> 
> patch-2.6.26-rc1-20080505-m41t80-smbus-13
> diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
> --- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
> +++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-09 00:32:39.000000000 +0000
> @@ -6,6 +6,8 @@
>   * Based on m41t00.c by Mark A. Greer <mgreer@mvista.com>
>   *
>   * 2006 (c) mycable GmbH
> + * Copyright (c) 2008  Maciej W. Rozycki
> + * Copyright (c) 2008  Atsushi Nemoto
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License version 2 as
> @@ -15,6 +17,7 @@
>  
>  #include <linux/module.h>
>  #include <linux/init.h>
> +#include <linux/kernel.h>
>  #include <linux/slab.h>
>  #include <linux/string.h>
>  #include <linux/i2c.h>
> @@ -36,6 +39,8 @@
>  #define M41T80_REG_DAY	5
>  #define M41T80_REG_MON	6
>  #define M41T80_REG_YEAR	7
> +#define M41T80_REG_CONTROL	8
> +#define M41T80_REG_WATCHDOG	9
>  #define M41T80_REG_ALARM_MON	0xa
>  #define M41T80_REG_ALARM_DAY	0xb
>  #define M41T80_REG_ALARM_HOUR	0xc
> @@ -58,7 +63,7 @@
>  #define M41T80_FEATURE_HT	(1 << 0)
>  #define M41T80_FEATURE_BL	(1 << 1)
>  
> -#define DRV_VERSION "0.05"
> +#define DRV_VERSION "0.06"
>  
>  static const struct i2c_device_id m41t80_id[] = {
>  	{ "m41t80", 0 },
> @@ -78,31 +83,104 @@ struct m41t80_data {
>  	struct rtc_device *rtc;
>  };
>  
> -static int m41t80_get_datetime(struct i2c_client *client,
> -			       struct rtc_time *tm)
> +
> +static int m41t80_i2c_write(struct i2c_client *client, u8 reg, u8 num, u8 *buf)
> +{
> +	u8 wbuf[num + 1];
> +	struct i2c_msg msgs[] = {
> +		{
> +			.addr	= client->addr,
> +			.flags	= 0,
> +			.len	= num + 1,
> +			.buf	= wbuf,
> +		},
> +	};
> +
> +	wbuf[0] = reg;
> +	memcpy(wbuf + 1, buf, num);
> +	return i2c_transfer(client->adapter, msgs, 1);
> +}

This is reimplementing i2c_smbus_write_i2c_block_data().

> +
> +static int m41t80_i2c_read(struct i2c_client *client, u8 reg, u8 num, u8 *buf)
>  {
> -	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
>  	struct i2c_msg msgs[] = {
>  		{
>  			.addr	= client->addr,
>  			.flags	= 0,
>  			.len	= 1,
> -			.buf	= dt_addr,
> +			.buf	= &reg,
>  		},
>  		{
>  			.addr	= client->addr,
>  			.flags	= I2C_M_RD,
> -			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
> -			.buf	= buf + M41T80_REG_SEC,
> +			.len	= num,
> +			.buf	= buf,
>  		},
>  	};
>  
> -	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
> -		dev_err(&client->dev, "read error\n");
> -		return -EIO;
> -	}
> +	return i2c_transfer(client->adapter, msgs, 2);
> +}

And this is reimplementing i2c_smbus_read_i2c_block_data(). So please
just use these standard helpers, which have the advantage that they can
work on a number of adapters that cannot do full I2C (many SMBus
controllers support I2C block transactions as long as the length
doesn't exceed 32 bytes.)

> +
> +static int m41t80_transfer(struct i2c_client *client, int write,
> +			   u8 reg, u8 num, u8 *buf)
> +{
> +	int i, rc;
> +
> +	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {

And then here you want to check for I2C_FUNC_SMBUS_I2C_BLOCK. Or even
better, check for I2C_FUNC_SMBUS_READ_I2C_BLOCK on read and
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK on write, so you get the best of each
adapter in the unlikely event an adapter would support I2C block reads
but not writes or vice-versa.

> +		if (write)
> +			i = m41t80_i2c_write(client, reg, num, buf);
> +		else
> +			i = m41t80_i2c_read(client, reg, num, buf);
> +	} else {
> +		if (write)
> +			for (i = 0; i < num; i++) {
> +				rc = i2c_smbus_write_byte_data(client, reg + i,
> +							       buf[i]);
> +				if (rc < 0)
> +					return rc;
> +			}
> +		else
> +			for (i = 0; i < num; i++) {
> +				rc = i2c_smbus_read_byte_data(client, reg + i);
> +				if (rc < 0)
> +					return rc;
> +				buf[i] = rc;
> +			}
> +	}
> +	return i;
> +}

> (...)
> @@ -629,14 +610,12 @@ static int wdt_ioctl(struct inode *inode
>  			return -EFAULT;
>  
>  		if (rv & WDIOS_DISABLECARD) {
> -			printk(KERN_INFO
> -			       "rtc-m41t80: disable watchdog\n");
> +			pr_info("rtc-m41t80: disable watchdog\n");
>  			wdt_disable();
>  		}
>  
>  		if (rv & WDIOS_ENABLECARD) {
> -			printk(KERN_INFO
> -			       "rtc-m41t80: enable watchdog\n");
> +			pr_info("rtc-m41t80: enable watchdog\n");
>  			wdt_ping();
>  		}
>  

Mixing code cleanups with functional changes is a Bad Idea (TM).

> @@ -732,19 +711,28 @@ static struct notifier_block wdt_notifie
>  static int m41t80_probe(struct i2c_client *client,
>  			const struct i2c_device_id *id)
>  {
> -	int rc = 0;
>  	struct rtc_device *rtc = NULL;
>  	struct rtc_time tm;
>  	struct m41t80_data *clientdata = NULL;
> +	int rc = 0;
> +	int reg;
>  
> -	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
> -				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
> +	if ((i2c_get_functionality(client->adapter) &
> +	     (I2C_FUNC_I2C | I2C_FUNC_SMBUS_BYTE_DATA)) == 0) {
>  		rc = -ENODEV;
>  		goto exit;
>  	}

That's not correct. The driver is making unconditional calls to
i2c_smbus_write_byte_data() and i2c_smbus_read_byte_data() so the
underlying adapter _must_ implement I2C_FUNC_SMBUS_BYTE_DATA. If it
additionally implements I2C_FUNC_I2C (or actually
I2C_FUNC_SMBUS_I2C_BLOCK), see above, then you can optimize some
transactions, but you don't have to check it here, the check should be
done at run-time (as you already do.)

You really shouldn't worry about making the I2C_FUNC_SMBUS_BYTE_DATA
check unconditional. I don't think I've ever seen an i2c bus driver not
supporting it.


>  
> +	/* Trivially check it's there; keep the result for the HT check.  */
> +	reg = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
> +	if (reg < 0) {
> +		rc = -ENXIO;
> +		goto exit;
> +	}
> +
>  	dev_info(&client->dev,
> -		 "chip found, driver version " DRV_VERSION "\n");
> +		 "%s chip found, driver version " DRV_VERSION "\n",
> +		 client->name);

Incorrect change, dev_info() already includes the chip name.

>  
>  	clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL);
>  	if (!clientdata) {
> @@ -765,11 +753,7 @@ static int m41t80_probe(struct i2c_clien
>  	i2c_set_clientdata(client, clientdata);
>  
>  	/* Make sure HT (Halt Update) bit is cleared */
> -	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
> -	if (rc < 0)
> -		goto ht_err;
> -
> -	if (rc & M41T80_ALHOUR_HT) {
> +	if (reg & M41T80_ALHOUR_HT) {
>  		if (clientdata->features & M41T80_FEATURE_HT) {
>  			m41t80_get_datetime(client, &tm);
>  			dev_info(&client->dev, "HT bit was set!\n");
> @@ -780,20 +764,19 @@ static int m41t80_probe(struct i2c_clien
>  				 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
>  				 tm.tm_min, tm.tm_sec);
>  		}
> -		if (i2c_smbus_write_byte_data(client,
> -					      M41T80_REG_ALARM_HOUR,
> -					      rc & ~M41T80_ALHOUR_HT) < 0)
> +		if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR,
> +					      reg & ~M41T80_ALHOUR_HT) < 0)
>  			goto ht_err;
>  	}

Again coding style fixes...

>  
>  	/* Make sure ST (stop) bit is cleared */
> -	rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
> -	if (rc < 0)
> +	reg = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
> +	if (reg < 0)
>  		goto st_err;
>  
> -	if (rc & M41T80_SEC_ST) {
> +	if (reg & M41T80_SEC_ST) {
>  		if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
> -					      rc & ~M41T80_SEC_ST) < 0)
> +					      reg & ~M41T80_SEC_ST) < 0)
>  			goto st_err;
>  	}

And here again...

I'm not the one who will take your patch, I'll leave it to Alessandro
to tell you what he wants, but one thing for sure: it would be much
easier to review and validate your patches if you were not mixing
functional changes and code cleanups.

>  
> @@ -803,6 +786,7 @@ static int m41t80_probe(struct i2c_clien
>  
>  #ifdef CONFIG_RTC_DRV_M41T80_WDT
>  	if (clientdata->features & M41T80_FEATURE_HT) {
> +		save_client = client;
>  		rc = misc_register(&wdt_dev);
>  		if (rc)
>  			goto exit;
> @@ -811,7 +795,6 @@ static int m41t80_probe(struct i2c_clien
>  			misc_deregister(&wdt_dev);
>  			goto exit;
>  		}
> -		save_client = client;
>  	}
>  #endif
>  	return 0;

This one deserves a patch on its own IMHO.

-- 
Jean Delvare

From ralf@linux-mips.org Fri May  9 09:49:29 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 09:49:32 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:43705 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20023157AbYEIIt3 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 09:49:29 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m498nSiA019152;
	Fri, 9 May 2008 09:49:28 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m498nQib019129;
	Fri, 9 May 2008 09:49:26 +0100
Date:	Fri, 9 May 2008 09:49:26 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH][MIPS] fix divide by zero error in build_clear_page and
	build_copy_page
Message-ID: <20080509084926.GA14450@linux-mips.org>
References: <20080507233815.e6de28da.yoichi_yuasa@tripeaks.co.jp> <Pine.LNX.4.55.0805071712520.25644@cliff.in.clinika.pl> <200805072238.m47MbxbZ022160@po-mbox303.hop.2iij.net> <Pine.LNX.4.55.0805080003120.31409@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.55.0805080003120.31409@cliff.in.clinika.pl>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19176
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 633
Lines: 16

On Thu, May 08, 2008 at 12:04:54AM +0100, Maciej W. Rozycki wrote:

> > >  Why would ever cache_line_size be zero in this place?  Are you trying to 
> > > support a cacheless CPU?  If not, it should be a BUG_ON().
> > > 
> > 
> > When CPU has no prefetch, no cache cdex_s and no caache cdex_p, cache_line_size is zero.
> > I confirmed it with Nevada(Cobalt server) and VR41xx.
> 
>  Fair enough.  I confused the variable with some others used to store the
> actual line size of each of the caches.  Your change is correct, thank you
> and sorry about the noise.

And I guess that means the variable should get a better name.

  Ralf

From david-b@pacbell.net Fri May  9 10:21:33 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 10:21:35 +0100 (BST)
Received: from smtp117.sbc.mail.sp1.yahoo.com ([69.147.64.90]:47754 "HELO
	smtp117.sbc.mail.sp1.yahoo.com") by ftp.linux-mips.org with SMTP
	id S20024071AbYEIJVd (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 10:21:33 +0100
Received: (qmail 8052 invoked from network); 9 May 2008 09:21:25 -0000
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
  s=s1024; d=pacbell.net;
  h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:Cc:References:In-Reply-To:MIME-Version:Content-Disposition:Message-Id:Content-Type:Content-Transfer-Encoding;
  b=YEPc7+FLSmiwQKJceyR0A+ZTAJ52RPOt7VjJ/WHxIx0lYftB4rTDuQEyrgNTAKKJ1fhXlDZ+G4pPpLbRaXytZlGOcy9vvL3KHi3NZSEHRqfhLvsAtTZhrC5r6YiJzDNxFWuUuVrhs1GuSZP80CBHzQy5ujov6Q8mIkzxtTO/22o=  ;
Received: from unknown (HELO ascent) (david-b@pacbell.net@69.226.243.232 with plain)
  by smtp117.sbc.mail.sp1.yahoo.com with SMTP; 9 May 2008 09:21:25 -0000
X-YMail-OSG: skiNQTYVM1l5lRFHnFCOpDPTII9al93db0_GZ4I4XJepQJFm8Ojm1xVGEIEBx__7Qh67v2YvLhIpMTi9foLupCgXUjfFxSz8BbqIbk7BA6L.GyLATMH6OiWgVB3_MCMUTFo-
X-Yahoo-Newman-Property: ymail-3
From:	David Brownell <david-b@pacbell.net>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
Date:	Fri, 9 May 2008 02:18:51 -0700
User-Agent: KMail/1.9.6
Cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, ab@mycable.de,
	mgreer@mvista.com, i2c@lm-sensors.org, rtc-linux@googlegroups.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
References: <200805070120.03821.david-b@pacbell.net> <200805071625.20430.david-b@pacbell.net> <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
In-Reply-To: <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Disposition: inline
Message-Id: <200805090218.52570.david-b@pacbell.net>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Return-Path: <david-b@pacbell.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19177
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: david-b@pacbell.net
Precedence: bulk
X-list: linux-mips
Content-Length: 5590
Lines: 134

On Thursday 08 May 2008, Maciej W. Rozycki wrote:
> Hi David,
> 
>  Please do not remove other lists cc-ed as there are people interested in 
> this piece of hardware who are neither on i2c nor on rtc-linux (I am on 
> neither of the lists too).

I didn't.  I responded to a message from list archives, and could
not tell how many lists were copied ... "WAY too many", clearly.


> > >  Do you mean our generic I2C code emulates SMBus calls if the hardware
> > > does not support them directly?  Well, it looks to me it indeed does and
> > > you are right, but I have assumed, perhaps mistakenly, (but I generally
> > > trust if a piece of code is there, it is for a reason), that this driver
> > > checks for I2C_FUNC_SMBUS_BYTE_DATA for a purpose.
> > 
> > That purpose being:  it makes those SMBus calls explicitly.
> > (And it makes i2c_transfer calls explicitly too...)
> 
>  Then, given the emulation, the client should be satisfied with either of
> the flags instead of both at a time.  Exactly how I changed it.

No; as Jean also noted, since it makes some explicit calls,
it should test for the functionality of those calls.  It should
not call i2c_transfer() unless the underlying adapter accepts
those calls.

 
> > > The extensions are 16-bit commands 
> > > (required by another RTC chip used on some of these boards) and an obscure
> > > subset of the process call and block read/write commands (called an EEPROM
> > > read and an extended write/read, respectively).
> > 
> > Subset of process call??  That's send-three-bytes, receive-two-bytes.
> > Not possible to subset it ... anything else isn't a process call!!
> 
>  I misinterpreted the SMBus spec -- I have thought the receive part is
> variable, sorry.  The controller implements a command which issues a write
> byte transfer followed by a receive four bytes transfer.  Not quite a
> process call although the idea is the same.

That is, no STOP in between, just a repeated START?  In which
case that's a subset of i2c_smbus_read_i2c_block_data().

 
> > Presumably those block read/write commands aren't quite enough
> > for you to implement i2c_smbus_read_i2c_block_data() and friend?
> 
>  You can issue a block read of up to 5 bytes (6 if you add the PEC byte
> which is not interpreted by the controller in any way).  And you can issue
> a block write of up to 4 bytes (5 with PEC).  That's clearly not enough
> for the m41t81 let alone a generic implementation.

Right.  Possibly worth updating i2c-sibyte to be able to perform
those calls through the "smbus i2c_block" calls; but maybe not.
(Those calls aren't true SMBus calls, but many otherwise-SMBus-only
controllers can handle them, hence the i2c_smbus_* prefix.)

 
>  But as Atsushi-san pointed out, the block transfer transactions
> implemented by the M41T81 do not quite follow the rules of SMBus block
> transfers, so the call is out of question -- either i2c_transfer() or a
> sequence of byte transactions have to be used.

See above:  they sound like subsets of the Linux "smbus i2c block"
calls.  (Those calls allow up to 32 bytes, much more than what the
i2c-sibyte hardware allows.)


> > >  I feel a bit uneasy about unconditional emulation of SMBus block calls
> > > with a series of corresponding byte read/write calls.  The reason is it
> > > changes the semantics
> > 
> > No it doesn't.  The I2C signal transitions (SCL/SDA) will be
> > exactly the same.  It's IMO very misleading to call it "emulation"
> > since it's nothing more than a different software interface to
> > the same functionality.
> 
>  It is not the same.  Assuming a write for a block transfer you have:
> 
> start:address:ack:command:ack:data:ack:data:ack:data:ack...stop
> 
> on the wire

That's true using both native SMBus calls and the
SMBus "emulated" (by native I2C) implementation of
the i2c_smbus_write_i2c_block_data() interface.


You introduced something entirely different:

> while for a series of byte calls you have: 
> 
> start:address:ack:command:ack:data:ack:stop
> start:address:ack:command:ack:data:ack:stop
> start:address:ack:command:ack:data:ack...stop

(I broke each separate I2C message onto its own line for clarity.)

 
> This is what I mean here -- I gather you are thinking in the terms of raw 
> I2C block vs SMBus block transfer.

I was talking in terms of i2c_smbus_write_i2c_block_data()
and i2c_smbus_read_i2c_block_data() ... which m41t80 should
be happy with.  (But i2c-sibyte won't be.)

If that second protocol sequence (many messages) happens to
work for a given chip, it can be done *portably* too using
pure SMBus "write byte" calls:  i2c_smbus_write_byte_data().

And that knowledge is very chip-specific, so it's IMO more
appropriate to keep it out of infrastructure like i2c-core.


>  It could be useful enough for other drivers to have the emulated calls 
> available as a part of the API.  No need to rush adding that though 
> obviously -- we can wait till we have a user (now that this driver has 
> been ruled out).

I can't quite see the point though.  Any driver can write a loop
that calls i2c_smbus_write_byte_data(), if that's an alternative
way to achieve the task on that chip.

It can be rather annoying to try getting some I2C drivers to cope
with a variety of broken I2C adapters.  But that's exactly why
there's a way to ask adapters what they can do.  If they can't
execute the I2C_FUNC_SMBUS_I2C_BLOCK protocols, then M41T80 code
must provide less efficient substitutes ... like looping over
byte-at-a-time calls, and coping with various time roll-over cases
that such substitutes will surface.

- Dave

From ralf@linux-mips.org Fri May  9 10:56:14 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 10:56:16 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:64913 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20023396AbYEIJ4O (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 10:56:14 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m499u5B1016009;
	Fri, 9 May 2008 10:56:05 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m499u5Lo016002;
	Fri, 9 May 2008 10:56:05 +0100
Date:	Fri, 9 May 2008 10:56:05 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	zhuzhenhua <zzh.hust@gmail.com>
Cc:	linux-mips <linux-mips@linux-mips.org>
Subject: Re: is remap_pfn_range should align to 2(n) * (page size) ?
Message-ID: <20080509095605.GB14450@linux-mips.org>
References: <50c9a2250805082354x1edc1ecar89dcc3378b3bbe75@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <50c9a2250805082354x1edc1ecar89dcc3378b3bbe75@mail.gmail.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19178
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 780
Lines: 17

On Fri, May 09, 2008 at 02:54:29PM +0800, zhuzhenhua wrote:

>            i have a sensor driver want to malloc 2.xM SDRAM to capture
> data(using DMA),  so i used  remap_pfn_range to malloc 3M.
> But in /proc/meminfo, it showes free memory reduce 4M. i also check the
> /proc/buddyinfo, it seemes too.
> (i am looking inside kernel code, but not get clear at now).
> 
>  is remap_pfn_range should align to  2(n) * (page size) ?

This has nothing to do with remap_pfn_range but with the power of two
sized buckets used by the global free page pool.  Any allocation with
get_free_pages will be rounded up to the next power of two.  If that's a
real concern for you you could allocate a 4MB page then split the page
into a 2MB and two 1MB pages and free the 1MB page again.

  Ralf

From anemo@mba.ocn.ne.jp Fri May  9 15:16:18 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 15:16:22 +0100 (BST)
Received: from mba.ocn.ne.jp ([122.1.235.107]:39877 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S20023930AbYEIOQS (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 15:16:18 +0100
Received: from localhost (p6090-ipad302funabasi.chiba.ocn.ne.jp [123.217.144.90])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 4BEE3B9CC; Fri,  9 May 2008 23:16:09 +0900 (JST)
Date:	Fri, 09 May 2008 23:17:19 +0900 (JST)
Message-Id: <20080509.231719.93019066.anemo@mba.ocn.ne.jp>
To:	macro@linux-mips.org
Cc:	david-b@pacbell.net, ab@mycable.de, mgreer@mvista.com,
	i2c@lm-sensors.org, rtc-linux@googlegroups.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
	<200805071625.20430.david-b@pacbell.net>
	<Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19179
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
Content-Length: 463
Lines: 11

On Fri, 9 May 2008 01:43:32 +0100 (BST), "Maciej W. Rozycki" <macro@linux-mips.org> wrote:
>  Here is a new version of the patch.  I hope I have addressed all your
> concerns, but I am officially dead at the moment, so please do not disturb
> me until this is no longer the case.

This version works fine for me (with i2c-gpio).  And as Jean said,
using i2c_smbus_(write|read)_i2c_block_data instead of
m41t80_i2c_(write|read) works fine too.

---
Atsushi Nemoto

From ralf@linux-mips.org Fri May  9 17:37:33 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 17:37:36 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:41648 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20021919AbYEIQhd (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 17:37:33 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m49GbXFB002939;
	Fri, 9 May 2008 17:37:33 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m49GbVAO002921;
	Fri, 9 May 2008 17:37:31 +0100
Date:	Fri, 9 May 2008 17:37:31 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH] Au1200: MMC resource size off by one
Message-ID: <20080509163730.GB14170@linux-mips.org>
References: <200805082306.17553.sshtylyov@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200805082306.17553.sshtylyov@ru.mvista.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19180
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 280
Lines: 9

On Thu, May 08, 2008 at 11:06:17PM +0400, Sergei Shtylyov wrote:

> Au12x0 MMC platform device strangely claims 0x41 bytes for its memory-mapped
> registers.  Make it claim the whole 0x80000 instead according to the memory
> map given in the datasheets.

Thanks, applied.

  Ralf

From macro@linux-mips.org Fri May  9 20:37:37 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 20:37:39 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:61679 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20023796AbYEIThh (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 20:37:37 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m49JacxQ012312;
	Fri, 9 May 2008 21:36:38 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m49Ja1nr012302;
	Fri, 9 May 2008 20:36:01 +0100
Date:	Fri, 9 May 2008 20:36:00 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	Geert Uytterhoeven <geert@linux-m68k.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080508095658.40eb74f4@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805092019100.10552@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507090514.3a86cf4b@hyperion.delvare> <Pine.LNX.4.64.0805070936060.6341@anakin>
 <20080507094343.25f279b9@hyperion.delvare> <Pine.LNX.4.55.0805072214090.25644@cliff.in.clinika.pl>
 <20080508095658.40eb74f4@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19181
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2424
Lines: 56

Hi Jean,

> $ find linux-2.6.26-rc1 -name Kconfig | wc -l
> 455
> $ find linux-2.6.26-rc1 -name Makefile | wc -l
> 1030
> $

 Well, these are not pieces of code and serve a different purpose, don't
they?

> Not to mention the 102 setup.c, 87 irq.c, 62 time.c... It is very
> common to have duplicated file names in the kernel tree because it
> supports so many architectures and platforms. In general, when you work

 Well, that is not a technical argument.  It is a fact of life, sure, but
it does not necessarily mean it is right, but perhaps that nobody has
really thought about it.

> on a given architecture or platform, names become unique again. Taking
> GDB as an example again, you definitely know what architecture you are
> debugging, so there should be relatively little ambiguity on what files
> are involved.

 Hmm, why to have little ambiguity, when you can have none?  We do not
rely on crippled filesystems, so we do not have to save characters in file
names -- we keep them reasonably short anyway.  I say there is no
technical advantage in having duplicate file names throughout the tree
(please name one if I am wrong) and there are advantages -- however small,
but still -- in keeping file names unique.  Therefore the gain from
converting the existing file names may not justify the effort required,
but it does not mean new additions may not take the gain into account?

> (On top of that, I'd argue that we _should_ be able to display relative
> paths to file names when debugging.)

 Human's perception is limited -- GDB's `info frame' is probably already
overloaded with information, so adding the path to the source file in
question will not make it any better.

> Your point about the "single program namespace" is certainly valid for
> small to medium-size programs, but in the case of something as big as
> the kernel, it probably no longer holds.

 I think it is actually the reverse -- the bigger a project is, the easier
to get lost within. ;-)  With small programs it is easier to maintain,
while with bigger ones it is really where it pays off.

> I don't have a strong opinion on this either, it is very unlikely that
> I'll ever have to deal with this file personally. I'm only telling you
> what the common practice is in the kernel tree.

 I don't think this practice has been architected and see above for
justification why it may not necessarily be the cleverest idea. :-)

  Maciej

From macro@linux-mips.org Fri May  9 21:27:41 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 21:27:43 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:54769 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20025141AbYEIU1l (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 21:27:41 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m49KRHwZ012524;
	Fri, 9 May 2008 22:27:17 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m49KR4ks012520;
	Fri, 9 May 2008 21:27:13 +0100
Date:	Fri, 9 May 2008 21:27:04 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	Ralf Baechle <ralf@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080509092835.3bbf0f55@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805092054030.10552@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507085953.2c08b854@hyperion.delvare> <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
 <20080508105905.3209c659@hyperion.delvare> <Pine.LNX.4.55.0805082344040.5944@cliff.in.clinika.pl>
 <20080509092835.3bbf0f55@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19182
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2796
Lines: 57

Hi Jean,

> Let me just quote you:
> 
> "This is mostly habitual -- this is what the GNU Coding Standard specifies
> for comments and which is enforced for GNU software which I have dealt a
> lot with."
> 
> You didn't say it was common sense. You did say that it was what the
> GNU Coding Standard specified, and as a consequence, what you were used
> to. So please keep your "oh come on" for yourself, you pointed the
> discussion in this direction yourself.

 Well, I take no habits that make no sense in the first place.  And I have
gone into great lengths to explain and justify what drives me in this case
-- I got it from the GNU standard and got convinced it is good, so I got
to using it.  I can write comments according to a different style, no
problem (as long as there is any defined style for a given case), but I
have to put some explicit effort into it.

 Similarly, habitually I write code in the Linux indentation style because
I like it, but I can use your hated GNU style (or any other that follows
any recognisable rules) as well, except I have to put some brainpower into
it.

> What matters is not "the pieces of code I am interested in", but the
> pieces of code _you_ are the master of, or not. As explained somewhere
> else in this thread, you are free to use whatever style you like (as
> long as it complies with Documentation/CodingStyle, that is) in new
> code you write and in code you maintain. For all the rest, you should
> stick to the surrounding style. This is common sense, as you'd say.

 Well, sorry, but I could only sense the lack of style in this piece of
code, which is why I tried to apply some.  You are free to disagree and as
you have undertaken maintenance of this area I am going to respect it.

> BTW, i2c-sibyte should be converted to a proper platform driver, so
> that only platforms with such a device instantiate it.

 The whole of SiByte support should eventually get converted to implement
platform initialisation.  I started some of this with changes to the
sb1250-mac.c Ethernet driver sometime in 2006, but no further progress has 
been made since.  I have other priorities higher on the list, but I have 
not forgotten about it and will come back at some point unless someone 
else does it first.

> Which legacy driver, "eeprom"? You should probably look into David
> Brownell's at24c driver:
> http://lists.lm-sensors.org/pipermail/i2c/2008-April/003307.html
> If it gets enough attention and testing, it could go upstream quickly.

 I can see if I can find a couple of cycles to spare and give this piece
of code a shot with my SWARM.  There is a pair of 128kB EEPROM chips
onboard (one as a bootstrap option and one to store configuration) and I
have two SDRAM modules installed providing another pair of a smaller size.

  Maciej

From khali@linux-fr.org Fri May  9 21:39:00 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 21:39:03 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:47806 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20024876AbYEIUjA (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 21:39:00 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JuaJ2-0007ej-TW
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Fri, 09 May 2008 23:39:09 +0200
Date:	Fri, 9 May 2008 22:38:45 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	Ralf Baechle <ralf@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
Message-ID: <20080509223845.4a38d751@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805092054030.10552@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
	<20080507085953.2c08b854@hyperion.delvare>
	<Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
	<20080508105905.3209c659@hyperion.delvare>
	<Pine.LNX.4.55.0805082344040.5944@cliff.in.clinika.pl>
	<20080509092835.3bbf0f55@hyperion.delvare>
	<Pine.LNX.4.55.0805092054030.10552@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19183
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 728
Lines: 19

Hi Maciej,

On Fri, 9 May 2008 21:27:04 +0100 (BST), Maciej W. Rozycki wrote:
>  Well, sorry, but I could only sense the lack of style in this piece of
> code, which is why I tried to apply some.

I agree, i2c-sibyte is very old code, and unmaintained, coding style is
horrible. That's one more reason to not include random style cleanups
in a patch doing functional changes, the improvement will hardly be
visible. If you care about cleaning up the code of this driver - and I
would appreciate that - please make a separate patch.

>                                            You are free to disagree and as
> you have undertaken maintenance of this area I am going to respect it.

And I thank you for that.

-- 
Jean Delvare

From macro@linux-mips.org Fri May  9 21:55:57 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 21:55:59 +0100 (BST)
Received: from [213.77.9.205] ([213.77.9.205]:21747 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20024521AbYEIUz5 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 21:55:57 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m49KtmVx012640;
	Fri, 9 May 2008 22:55:48 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m49KtdOg012636;
	Fri, 9 May 2008 21:55:39 +0100
Date:	Fri, 9 May 2008 21:55:38 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	David Brownell <david-b@pacbell.net>, linux-mips@linux-mips.org,
	mgreer@mvista.com, rtc-linux@googlegroups.com,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de,
	Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: [i2c] [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
In-Reply-To: <20080509100841.151eabcd@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805092127410.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
 <Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
 <200805071625.20430.david-b@pacbell.net> <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
 <20080509100841.151eabcd@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19184
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3565
Lines: 107

Hi Jean,

> Maybe you shouldn't have included 4 different mailing lists to start
> with, especially for a patch which is rather hardware-specific and not
> overly important.

 Well, there is more interest in these changes on the linux-mips mailing
list than on any other one -- I seriously doubt there is any user of
hardware based around the BCM1250A SOC on either of the i2c and rtc-linux
lists.  And the LKML is to be cc-ed on all patch submissions.

> > @@ -78,31 +83,104 @@ struct m41t80_data {
> >  	struct rtc_device *rtc;
> >  };
> >  
> > -static int m41t80_get_datetime(struct i2c_client *client,
> > -			       struct rtc_time *tm)
> > +
> > +static int m41t80_i2c_write(struct i2c_client *client, u8 reg, u8 num, u8 *buf)
> > +{
> > +	u8 wbuf[num + 1];
> > +	struct i2c_msg msgs[] = {
> > +		{
> > +			.addr	= client->addr,
> > +			.flags	= 0,
> > +			.len	= num + 1,
> > +			.buf	= wbuf,
> > +		},
> > +	};
> > +
> > +	wbuf[0] = reg;
> > +	memcpy(wbuf + 1, buf, num);
> > +	return i2c_transfer(client->adapter, msgs, 1);
> > +}
> 
> This is reimplementing i2c_smbus_write_i2c_block_data().

 Where does it come from?  I fail to see this type of transfer being 
defined anywhere in the SMBus spec.  I checked the spec before I referred 
to the implementation in our I2C core and I hope you agree I may not have 
expected any extensions beyond what the SMBus spec defines.

 That written, you are of course correct WRT the reimplementation and I am 
eager to remove it -- thanks for the point.  I'll skip all your other 
comments related as obviously implied by this change.

 Given the function and friends make use of apparently a non-standard
SMBus transfer, I think they should be called differently, perhaps
i2c_smbusext_write_i2c_block_data(), etc. or suchlike.

> Mixing code cleanups with functional changes is a Bad Idea (TM).

 I am happy to bother you with a separate patch including style fixes.  I
can even create a handful of them, grouping functionally consistent
changes.

> >  	dev_info(&client->dev,
> > -		 "chip found, driver version " DRV_VERSION "\n");
> > +		 "%s chip found, driver version " DRV_VERSION "\n",
> > +		 client->name);
> 
> Incorrect change, dev_info() already includes the chip name.

 My system must be a notable exception then, as this change modifies 
output:

rtc-m41t80 1-0068: chip found, driver version 0.05

to:

rtc-m41t80 1-0068: m41t81 chip found, driver version 0.05

here.

> I'm not the one who will take your patch, I'll leave it to Alessandro
> to tell you what he wants, but one thing for sure: it would be much
> easier to review and validate your patches if you were not mixing
> functional changes and code cleanups.

 You seem to have your boundary set differently to me and a few other
people.  This is perfectly fine, as the line is thin here and each of the
subsystems follows slightly different rules.  You cannot always satisfy
everybody and if something makes your life easier and does not make mine
more difficult, I see no problem with adapting myself. :-)

> > @@ -803,6 +786,7 @@ static int m41t80_probe(struct i2c_clien
> >  
> >  #ifdef CONFIG_RTC_DRV_M41T80_WDT
> >  	if (clientdata->features & M41T80_FEATURE_HT) {
> > +		save_client = client;
> >  		rc = misc_register(&wdt_dev);
> >  		if (rc)
> >  			goto exit;
> > @@ -811,7 +795,6 @@ static int m41t80_probe(struct i2c_clien
> >  			misc_deregister(&wdt_dev);
> >  			goto exit;
> >  		}
> > -		save_client = client;
> >  	}
> >  #endif
> >  	return 0;
> 
> This one deserves a patch on its own IMHO.

 No problem.

  Maciej

From khali@linux-fr.org Fri May  9 22:22:03 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 22:22:06 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:47124 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20025074AbYEIVWD (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 9 May 2008 22:22:03 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Juayg-0003Em-6z
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Sat, 10 May 2008 00:22:10 +0200
Date:	Fri, 9 May 2008 23:21:46 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	David Brownell <david-b@pacbell.net>, linux-mips@linux-mips.org,
	mgreer@mvista.com, rtc-linux@googlegroups.com,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de,
	Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: [i2c] [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
Message-ID: <20080509232146.18638986@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805092127410.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
	<Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
	<200805071625.20430.david-b@pacbell.net>
	<Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
	<20080509100841.151eabcd@hyperion.delvare>
	<Pine.LNX.4.55.0805092127410.10552@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19185
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2713
Lines: 72

Hi Maciej,

On Fri, 9 May 2008 21:55:38 +0100 (BST), Maciej W. Rozycki wrote:
> > This is reimplementing i2c_smbus_write_i2c_block_data().
> 
>  Where does it come from?  I fail to see this type of transfer being 
> defined anywhere in the SMBus spec.

It is indeed not.

>                                      I checked the spec before I referred 
> to the implementation in our I2C core and I hope you agree I may not have 
> expected any extensions beyond what the SMBus spec defines.

The "smbus" in these function names are more about "what SMBus
controllers usually can do" than about the SMBus specification. But I
admit you couldn't guess.

>  That written, you are of course correct WRT the reimplementation and I am 
> eager to remove it -- thanks for the point.  I'll skip all your other 
> comments related as obviously implied by this change.
> 
>  Given the function and friends make use of apparently a non-standard
> SMBus transfer, I think they should be called differently, perhaps
> i2c_smbusext_write_i2c_block_data(), etc. or suchlike.

This was an option when the functions where introduced 9 years ago.
But now that it was done, renaming them would cause even more
confusion, I think. I would be fine with adding comments in i2c-core.c
or improving Documentation/i2c/smbus-protocol to make it more obious,
though.

On a related note, you will notice that the other i2c_smbus_* functions
do not follow the naming of SMBus transactions. Again that's something
I regret but I feel that changing the names now would cause a lot of
confusion amongst developers, so I'm not doing it.

> > Mixing code cleanups with functional changes is a Bad Idea (TM).
> 
>  I am happy to bother you with a separate patch including style fixes.  I
> can even create a handful of them, grouping functionally consistent
> changes.

Just one patch should be enough, if I agree with all the changes. You
might make a separate patch with the things I may not agree with, so
that you don't have to cherry-revert them if I indeed don't agree, and
we just merge them if I do agree.

> > >  	dev_info(&client->dev,
> > > -		 "chip found, driver version " DRV_VERSION "\n");
> > > +		 "%s chip found, driver version " DRV_VERSION "\n",
> > > +		 client->name);
> > 
> > Incorrect change, dev_info() already includes the chip name.
> 
>  My system must be a notable exception then, as this change modifies 
> output:
> 
> rtc-m41t80 1-0068: chip found, driver version 0.05
> 
> to:
> 
> rtc-m41t80 1-0068: m41t81 chip found, driver version 0.05
> 
> here.

My bad, for some reason I thought that dev_printk() included the device
name but it in fact includes the driver name. I was wrong, just ignore
me.

-- 
Jean Delvare

From macro@linux-mips.org Fri May  9 22:22:25 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 09 May 2008 22:22:28 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:65268 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20025108AbYEIVWX (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 9 May 2008 22:22:23 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m49LMKtT012784;
	Fri, 9 May 2008 23:22:20 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m49LMCuM012780;
	Fri, 9 May 2008 22:22:16 +0100
Date:	Fri, 9 May 2008 22:22:11 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	David Brownell <david-b@pacbell.net>
cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, ab@mycable.de,
	mgreer@mvista.com, i2c@lm-sensors.org, rtc-linux@googlegroups.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
In-Reply-To: <200805090218.52570.david-b@pacbell.net>
Message-ID: <Pine.LNX.4.55.0805092202380.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net> <200805071625.20430.david-b@pacbell.net>
 <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
 <200805090218.52570.david-b@pacbell.net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19186
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3971
Lines: 85

Hi David,

> >  Please do not remove other lists cc-ed as there are people interested in 
> > this piece of hardware who are neither on i2c nor on rtc-linux (I am on 
> > neither of the lists too).
> 
> I didn't.  I responded to a message from list archives, and could

 I just asked not to remove from now on -- no implied double meaning and 
thanks for respecting my request. :-)

> not tell how many lists were copied ... "WAY too many", clearly.

 Just enough plus the usual LKML everyone is free to ignore if they 
cannot stand the volume.  And I got responses from linux-mips, which means 
my choice was right.

> No; as Jean also noted, since it makes some explicit calls,
> it should test for the functionality of those calls.  It should
> not call i2c_transfer() unless the underlying adapter accepts
> those calls.

 As mentioned elsewhere I misunderstood the semantics of the flags in the 
API.

> >  I misinterpreted the SMBus spec -- I have thought the receive part is
> > variable, sorry.  The controller implements a command which issues a write
> > byte transfer followed by a receive four bytes transfer.  Not quite a
> > process call although the idea is the same.
> 
> That is, no STOP in between, just a repeated START?  In which
> case that's a subset of i2c_smbus_read_i2c_block_data().

 There is the usual second START in between to turn around the direction.  
There is no STOP in the process call either, which is what makes it
different from an ordinary write transaction followed by a read
transaction.

> >  You can issue a block read of up to 5 bytes (6 if you add the PEC byte
> > which is not interpreted by the controller in any way).  And you can issue
> > a block write of up to 4 bytes (5 with PEC).  That's clearly not enough
> > for the m41t81 let alone a generic implementation.
> 
> Right.  Possibly worth updating i2c-sibyte to be able to perform
> those calls through the "smbus i2c_block" calls; but maybe not.
> (Those calls aren't true SMBus calls, but many otherwise-SMBus-only
> controllers can handle them, hence the i2c_smbus_* prefix.)

 I am not sure such a limited functionality is worth the hassle of making 
it available to clients in a reasonably clean way.  How common an 
extension of this kind is among SMBus controllers?  I would say if there 
are other controllers providing it (perhaps for a different range of 
transfer lengths) and clients benefitting from it, it might be worth 
adding it for this controller as well.  Otherwise perhaps let's wait till 
somebody complains about the lack of this functionality?

> If that second protocol sequence (many messages) happens to
> work for a given chip, it can be done *portably* too using
> pure SMBus "write byte" calls:  i2c_smbus_write_byte_data().
> 
> And that knowledge is very chip-specific, so it's IMO more
> appropriate to keep it out of infrastructure like i2c-core.
[...]
> I can't quite see the point though.  Any driver can write a loop
> that calls i2c_smbus_write_byte_data(), if that's an alternative
> way to achieve the task on that chip.

 Well, it seems generic enough we may provide wrappers around loops using
i2c_smbus_read_byte_data() and i2c_smbus_write_byte_data() to perform
transactions involving consecutive values of commands for clients to pick.  
You may be right it may be too trivial to bother though -- I am not sure.  
In any case, as suggested elsewhere, the core does not seem the right
place indeed, but a header file or drivers/i2c/lib/ should be appropriate.

> It can be rather annoying to try getting some I2C drivers to cope
> with a variety of broken I2C adapters.  But that's exactly why
> there's a way to ask adapters what they can do.  If they can't
> execute the I2C_FUNC_SMBUS_I2C_BLOCK protocols, then M41T80 code
> must provide less efficient substitutes ... like looping over
> byte-at-a-time calls, and coping with various time roll-over cases
> that such substitutes will surface.

 Of course.

  Maciej

From macro@linux-mips.org Sat May 10 02:35:59 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 02:36:02 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:27118 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20025171AbYEJBf7 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 10 May 2008 02:35:59 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4A1ZiE7013704;
	Sat, 10 May 2008 03:35:45 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4A1ZJ6U013699;
	Sat, 10 May 2008 02:35:27 +0100
Date:	Sat, 10 May 2008 02:35:18 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	David Brownell <david-b@pacbell.net>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexander Bigga <ab@mycable.de>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, i2c@lm-sensors.org,
	rtc-linux@googlegroups.com, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80
In-Reply-To: <20080509222754.03de1c54@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805100116290.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
 <Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
 <20080508093456.340a42b0@hyperion.delvare> <Pine.LNX.4.55.0805091917370.10552@cliff.in.clinika.pl>
 <20080509222754.03de1c54@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19187
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 17192
Lines: 531

Hi Jean,

> Welcome back to the world of the living creatures then. How was the
> other world? :)

 I don't remember, sorry. ;-)

> Really? I don't remember any such rule, so this must have been before
> 2003.

 Could be -- my memory happily still extends back beyond that moment of
time.

> You're wrong in your assumption that adding coding style cleanups to a
> patch is "for free". It makes reviewing the patch more difficult, and it
> makes backporting the patch more difficult, too (cleanups increase the
> risks that the patch won't apply to an older kernel, and you have to
> filter out all cleanups for -stable.) Compared to this, the time spent
> to handle a separate, cleanup-only patch is very small by my maintainer
> experience.

 Now this is certainly a valid point.  But the concept of -stable is
recent enough this is only the second or third time I see it mentioned.

> >                                             I think anybody clever enough
> > to notice an obvious rule having been applied will follow it.
> 
> You're wrong again, sorry. Developers are always in a hurry, they often
> fail to follow the written rules, they just won't care about unwritten
> ones.

 Well, you have spotted one counter-example now who does not hurry enough
for it to spoil his work.  Besides, the time required to put a header
inclusion at the right place in an ordered sequence is the same as for an
insertion at a random position.

> Want an example? Look at MAINTAINERS. It is supposed to be sorted
> alphabetically, the header says so and pretty much everyone should be
> aware of it by now, still you can check by yourself that of the 600
> entries in that file, about 100 are not at the correct place.

 Well, some people do not read user manuals either -- perhaps they have 
missed the annotation too?

> I sure hope that they are all gone by now. Headers which need to
> included in a specific order are a bug.

 Well, this is the first time I hear it stated by someone else.  Good 
progress, I would say...

> I think we have a script to find duplicates. I admit that sorting the
> headers in alphabetical order solve the problem. But OTOH, if
> developers can't be bothered to make sure they don't add a duplicate
> header, I doubt that they can be bothered to keep the includes sorted
> alphabetically.

 Well, if developers cannot be bothered to produce quality results, then
perhaps they should be doing something else?  There is no obligation to be
a software developer, is it?

> >  Ah, I see -- I must have missed it from documentation or perhaps it is
> > somewhat unclear.  You mean our I2C API implies a driver for a
> 
> It's documented in Documentation/i2c/functionality. If something is
> unclear, please let me know and/or send a patch.

 Well, I had a look at this file while writing my changes and this is the 
very thing that is unclear.  The only place the description refers to 
emulation is the I2C_FUNC_SMBUS_EMUL flag and there is nothing said
about any other I2C_FUNC_SMBUS_* flag in the context of emulation.  The 
rest of the file refers to functionality provided by the adapter, which 
can be reasonably assumed to be such provided directly by hardware.

> More exactly: if there is anything to share _and the added cost of
> sharing is less than the benefit_ then it should be done. Additional
> kernel modules have a cost. Even just exporting additional functions,
> has a cost. Going through an interface often has a cost. The benefit on
> the maintenance front must overcome these, otherwise it's not worth
> doing it.

 Having improvements and bug fixes applied to some of the repeated code
sequences only has its cost as well.  If the piece of code is small then
it can go to an inline function and the interface cost is null.  If it is
big, then it can go to a library from which all the interested modules can
import it with no need for an additional module.  Even pieces of code as
small as the Ethernet CRC calculation have been decided worth being put
into a single place even though there is little room for improvement or
breakage there.

 Go chase all the copies of code to support the SCC or the LANCE scattered
throughout our tree and figure out which has the least bugs and/or the
most features if you have any doubts about how to classify code
duplication.

> You assume that there is roughly only one way to emulate reading or
> writing a block from/to an I2C or SMBus device, with only slight
> variations. I would love it the I2C world was that simple, but
> unfortunately it is not. Each device has its own constraints on how a
> block read/write can be emulated. For example on some devices you can
> use word reads as an alternative to block reads, but other devices will
> only accept byte reads as an alternative. Some devices will accept byte
> reads but not at the same address as the block read (see for example
> drivers/hwmon/lm93.c - actually this is mandatory for SMBus block
> reads), etc. So I am still skeptical that we can come up with one or
> more emulation functions that can be used by more than 2 drivers and
> still get the best of each device.

 I am not assuming anything here.  I have only stated that if this
approach to transfers involving a range of commands was useful elsewhere,
then code to do so should not be duplicated throughout all the interested
drivers.  I do not know if there are any other than this -- it is up to
the users and/or maintainers of code in question to determine.

> But well, if you want to give it a try, just go on, prepare a patch,
> and send it for review.

 Will see.  For now here is a new version of the change -- aside taking 
your and other people's comments into account I have improved the logic 
behind required bus adapter's feature determination.

 Everybody interested please give it a try.  It certainly works for me.  
Comments are welcome.  I will submit all the clean-up changes separately,
independently or when the whole set is ready as appropriate, based on
dependencies or the lack of.

  Maciej

patch-2.6.26-rc1-20080505-m41t80-smbus-15
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-10 00:57:13.000000000 +0000
@@ -6,6 +6,7 @@
  * Based on m41t00.c by Mark A. Greer <mgreer@mvista.com>
  *
  * 2006 (c) mycable GmbH
+ * Copyright (c) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -36,6 +37,8 @@
 #define M41T80_REG_DAY	5
 #define M41T80_REG_MON	6
 #define M41T80_REG_YEAR	7
+#define M41T80_REG_CONTROL	8
+#define M41T80_REG_WATCHDOG	9
 #define M41T80_REG_ALARM_MON	0xa
 #define M41T80_REG_ALARM_DAY	0xb
 #define M41T80_REG_ALARM_HOUR	0xc
@@ -58,7 +61,7 @@
 #define M41T80_FEATURE_HT	(1 << 0)
 #define M41T80_FEATURE_BL	(1 << 1)
 
-#define DRV_VERSION "0.05"
+#define DRV_VERSION "0.06"
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t80", 0 },
@@ -78,31 +81,78 @@ struct m41t80_data {
 	struct rtc_device *rtc;
 };
 
-static int m41t80_get_datetime(struct i2c_client *client,
-			       struct rtc_time *tm)
+
+static int m41t80_transfer(struct i2c_client *client, int write,
+			   u8 reg, u8 num, u8 *buf)
 {
-	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
+	int i, rc;
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
-		dev_err(&client->dev, "read error\n");
-		return -EIO;
+	if (write) {
+		if (i2c_check_functionality(client->adapter,
+					    I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
+			i = i2c_smbus_write_i2c_block_data(client,
+							   reg, num, buf);
+		} else {
+			for (i = 0; i < num; i++) {
+				rc = i2c_smbus_write_byte_data(client, reg + i,
+							       buf[i]);
+				if (rc < 0) {
+					i = rc;
+					goto out;
+				}
+			}
+		}
+	} else {
+		if (i2c_check_functionality(client->adapter,
+					    I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
+			i = i2c_smbus_read_i2c_block_data(client,
+							  reg, num, buf);
+		} else {
+			for (i = 0; i < num; i++) {
+				rc = i2c_smbus_read_byte_data(client, reg + i);
+				if (rc < 0) {
+					i = rc;
+					goto out;
+				}
+				buf[i] = rc;
+			}
+		}
 	}
+out:
+	return i;
+}
 
-	tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f);
+static int m41t80_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+	u8 buf[M41T80_DATETIME_REG_SIZE];
+	int loops = 2;
+	int sec0, sec1;
+
+	/*
+	 * Time registers are latched by this chip if an I2C block
+	 * transfer is used, but with SMBus-style byte accesses
+	 * this is not the case, so check seconds for a wraparound.
+	 */
+	do {
+		if (m41t80_transfer(client, 0, M41T80_REG_SEC,
+				    M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+				    buf + M41T80_REG_SEC) < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+		sec0 = buf[M41T80_REG_SEC];
+
+		sec1 = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+		if (sec1 < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+
+		sec0 = BCD2BIN(sec0 & 0x7f);
+		sec1 = BCD2BIN(sec1 & 0x7f);
+	} while (sec1 < sec0 && --loops);
+
+	tm->tm_sec = sec1;
 	tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f);
 	tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f);
 	tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f);
@@ -117,39 +167,16 @@ static int m41t80_get_datetime(struct i2
 /* Sets the given date and time to the real time clock. */
 static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-	u8 wbuf[1 + M41T80_DATETIME_REG_SIZE];
-	u8 *buf = &wbuf[1];
-	u8 dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_DATETIME_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
+	u8 buf[M41T80_DATETIME_REG_SIZE];
 
 	/* Read current reg values into buf[1..7] */
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_SEC,
+			    M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+			    buf + M41T80_REG_SEC) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
 
-	wbuf[0] = 0; /* offset into rtc's regs */
 	/* Merge time-data and register flags into buf[0..7] */
 	buf[M41T80_REG_SSEC] = 0;
 	buf[M41T80_REG_SEC] =
@@ -167,7 +194,8 @@ static int m41t80_set_datetime(struct i2
 	/* assume 20YY not 19YY */
 	buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_transfer(client, 1, M41T80_REG_SSEC,
+			    M41T80_DATETIME_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -241,34 +269,11 @@ err:
 static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 wbuf[1 + M41T80_ALARM_REG_SIZE];
-	u8 *buf = &wbuf[1];
+	u8 buf[M41T80_ALARM_REG_SIZE];
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE,
-			.buf	= buf,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_ALARM_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
 
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -278,7 +283,6 @@ static int m41t80_rtc_set_alarm(struct d
 	reg[M41T80_REG_ALARM_MIN] = 0;
 	reg[M41T80_REG_ALARM_SEC] = 0;
 
-	wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */
 	reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ?
 		BIN2BCD(t->time.tm_sec) : 0x80;
 	reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ?
@@ -292,7 +296,8 @@ static int m41t80_rtc_set_alarm(struct d
 	else
 		reg[M41T80_REG_ALARM_DAY] |= 0x40;
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_transfer(client, 1, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -312,24 +317,10 @@ static int m41t80_rtc_read_alarm(struct 
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	u8 buf[M41T80_ALARM_REG_SIZE + 1]; /* all alarm regs and flags */
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE + 1,
-			.buf	= buf,
-		},
-	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
+	if (m41t80_transfer(client, 0, M41T80_REG_ALARM_MON,
+			    M41T80_ALARM_REG_SIZE + 1, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -488,26 +479,16 @@ static int boot_flag;
  */
 static void wdt_ping(void)
 {
-	unsigned char i2c_data[2];
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-	i2c_data[0] = 0x09;		/* watchdog register */
+	u8 wdt = 0x80;				/* WDS = 1 (0x80)  */
 
 	if (wdt_margin > 31)
-		i2c_data[1] = (wdt_margin & 0xFC) | 0x83; /* resolution = 4s */
+		/* mulitplier = WD_TIMO / 4, resolution = 4s (0x3)  */
+		wdt |= (wdt_margin & 0xfc) | 0x3;
 	else
-		/*
-		 * WDS = 1 (0x80), mulitplier = WD_TIMO, resolution = 1s (0x02)
-		 */
-		i2c_data[1] = wdt_margin<<2 | 0x82;
+		/* mulitplier = WD_TIMO, resolution = 1s (0x2)  */
+		wdt |= wdt_margin << 2 | 0x2;
 
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, wdt);
 }
 
 /**
@@ -517,36 +498,8 @@ static void wdt_ping(void)
  */
 static void wdt_disable(void)
 {
-	unsigned char i2c_data[2], i2c_buf[0x10];
-	struct i2c_msg msgs0[2] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= i2c_data,
-		},
-		{
-			.addr	= save_client->addr,
-			.flags	= I2C_M_RD,
-			.len	= 1,
-			.buf	= i2c_buf,
-		},
-	};
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-
-	i2c_data[0] = 0x09;
-	i2c_transfer(save_client->adapter, msgs0, 2);
-
-	i2c_data[0] = 0x09;
-	i2c_data[1] = 0x00;
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_read_byte_data(save_client, M41T80_REG_WATCHDOG);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, 0);
 }
 
 /**
@@ -736,13 +689,25 @@ static int m41t80_probe(struct i2c_clien
 	struct rtc_device *rtc = NULL;
 	struct rtc_time tm;
 	struct m41t80_data *clientdata = NULL;
+	u32 func;
+	int reg;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
-				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
+	func = i2c_get_functionality(client->adapter);
+	if (!(func & (I2C_FUNC_SMBUS_READ_I2C_BLOCK |
+		      I2C_FUNC_SMBUS_READ_BYTE)) ||
+	    !(func & (I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
+		      I2C_FUNC_SMBUS_WRITE_BYTE))) {
 		rc = -ENODEV;
 		goto exit;
 	}
 
+	/* Trivially check it's there; keep the result for the HT check. */
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
+	if (reg < 0) {
+		rc = -ENXIO;
+		goto exit;
+	}
+
 	dev_info(&client->dev,
 		 "chip found, driver version " DRV_VERSION "\n");
 
@@ -765,11 +730,7 @@ static int m41t80_probe(struct i2c_clien
 	i2c_set_clientdata(client, clientdata);
 
 	/* Make sure HT (Halt Update) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
-	if (rc < 0)
-		goto ht_err;
-
-	if (rc & M41T80_ALHOUR_HT) {
+	if (reg & M41T80_ALHOUR_HT) {
 		if (clientdata->features & M41T80_FEATURE_HT) {
 			m41t80_get_datetime(client, &tm);
 			dev_info(&client->dev, "HT bit was set!\n");
@@ -782,18 +743,18 @@ static int m41t80_probe(struct i2c_clien
 		}
 		if (i2c_smbus_write_byte_data(client,
 					      M41T80_REG_ALARM_HOUR,
-					      rc & ~M41T80_ALHOUR_HT) < 0)
+					      reg & ~M41T80_ALHOUR_HT) < 0)
 			goto ht_err;
 	}
 
 	/* Make sure ST (stop) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
-	if (rc < 0)
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+	if (reg < 0)
 		goto st_err;
 
-	if (rc & M41T80_SEC_ST) {
+	if (reg & M41T80_SEC_ST) {
 		if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
-					      rc & ~M41T80_SEC_ST) < 0)
+					      reg & ~M41T80_SEC_ST) < 0)
 			goto st_err;
 	}
 

From macro@linux-mips.org Sat May 10 02:44:10 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 02:44:13 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:50670 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20025310AbYEJBoK (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 10 May 2008 02:44:10 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4A1hln8013727;
	Sat, 10 May 2008 03:43:47 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4A1hhfw013723;
	Sat, 10 May 2008 02:43:43 +0100
Date:	Sat, 10 May 2008 02:43:43 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	Ralf Baechle <ralf@linux-mips.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	David Brownell <david-b@pacbell.net>
Subject: Re: [RFC][PATCH 2/4] RTC: SWARM I2C board initialization
In-Reply-To: <20080509223845.4a38d751@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805100236410.10552@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805070031410.16173@cliff.in.clinika.pl>
 <20080507085953.2c08b854@hyperion.delvare> <Pine.LNX.4.55.0805072145040.25644@cliff.in.clinika.pl>
 <20080508105905.3209c659@hyperion.delvare> <Pine.LNX.4.55.0805082344040.5944@cliff.in.clinika.pl>
 <20080509092835.3bbf0f55@hyperion.delvare> <Pine.LNX.4.55.0805092054030.10552@cliff.in.clinika.pl>
 <20080509223845.4a38d751@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19188
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 957
Lines: 19

Hi Jean,

> I agree, i2c-sibyte is very old code, and unmaintained, coding style is
> horrible. That's one more reason to not include random style cleanups
> in a patch doing functional changes, the improvement will hardly be
> visible. If you care about cleaning up the code of this driver - and I
> would appreciate that - please make a separate patch.

 While I have not officially undertaken maintenance of code to support any
of the pieces of hardware relevant to the SWARM board, I have done a
considerable number of changes throughout all the bits and if you have any
concern related to this piece of code (or any other I am referring to
here), then you are certainly welcome to contact me directly, cc-ing
linux-mips, perhaps.  I do SWARM development solely in my free time and I
simply cannot afford chasing all the bits around, especially ones I do not
actively use.  I do try to care about bits other people have concerns
about though.

  Maciej

From macro@linux-mips.org Sat May 10 03:21:57 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 03:22:00 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:1520 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20025238AbYEJCV5 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 10 May 2008 03:21:57 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4A2LlqB014095;
	Sat, 10 May 2008 04:21:47 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4A2LaQv014091;
	Sat, 10 May 2008 03:21:37 +0100
Date:	Sat, 10 May 2008 03:21:35 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	David Brownell <david-b@pacbell.net>, linux-mips@linux-mips.org,
	mgreer@mvista.com, rtc-linux@googlegroups.com,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de,
	Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: [i2c] [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
In-Reply-To: <20080509232146.18638986@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805100301100.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
 <Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
 <200805071625.20430.david-b@pacbell.net> <Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
 <20080509100841.151eabcd@hyperion.delvare> <Pine.LNX.4.55.0805092127410.10552@cliff.in.clinika.pl>
 <20080509232146.18638986@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19189
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2021
Lines: 41

Hi Jean,

> This was an option when the functions where introduced 9 years ago.
> But now that it was done, renaming them would cause even more
> confusion, I think. I would be fine with adding comments in i2c-core.c
> or improving Documentation/i2c/smbus-protocol to make it more obious,
> though.
> 
> On a related note, you will notice that the other i2c_smbus_* functions
> do not follow the naming of SMBus transactions. Again that's something
> I regret but I feel that changing the names now would cause a lot of
> confusion amongst developers, so I'm not doing it.

 It may not be worth the effort, but if done in bulk for all the users in
the tree, there should be no problem with that.  I am fairly sure there
were changes of this kind from time to time, with occasional screams heard
in response from some dark corners, but no big pain.  We obviously
explicitly disregard out-of-tree users and for occasional contributors
asking: "Where the * has this function gone?" there is the Documentation/
tree to provide a greppable reference, so generally not a big deal.

> Just one patch should be enough, if I agree with all the changes. You
> might make a separate patch with the things I may not agree with, so
> that you don't have to cherry-revert them if I indeed don't agree, and
> we just merge them if I do agree.

 Hmm, technically you do not seem to be responsible to accept changes
under drivers/rtc/, so I will split them anyway for others to decide.  In
particular I do plan to submit a separate change for header ordering for
the driver, just out of curiosity to see how long it will stay unspoilt.  
Somehow most if not all changes of this kind that I ever made to files in
our tree have survived to the present day. :-)

> My bad, for some reason I thought that dev_printk() included the device
> name but it in fact includes the driver name. I was wrong, just ignore
> me.

 It will go separately though as not directly related to this
modification, now that I have started splitting it.

  Maciej

From khali@linux-fr.org Sat May 10 07:54:04 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 07:54:08 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:24464 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20022375AbYEJGyE (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 10 May 2008 07:54:04 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JujuC-0002lE-Ak
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Sat, 10 May 2008 09:54:08 +0200
Date:	Sat, 10 May 2008 08:53:40 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	David Brownell <david-b@pacbell.net>, linux-mips@linux-mips.org,
	mgreer@mvista.com, rtc-linux@googlegroups.com,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de,
	Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: [i2c] [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
Message-ID: <20080510085340.29c26aef@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805100301100.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
	<Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
	<200805071625.20430.david-b@pacbell.net>
	<Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
	<20080509100841.151eabcd@hyperion.delvare>
	<Pine.LNX.4.55.0805092127410.10552@cliff.in.clinika.pl>
	<20080509232146.18638986@hyperion.delvare>
	<Pine.LNX.4.55.0805100301100.10552@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19190
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2273
Lines: 44

On Sat, 10 May 2008 03:21:35 +0100 (BST), Maciej W. Rozycki wrote:
> > This was an option when the functions where introduced 9 years ago.
> > But now that it was done, renaming them would cause even more
> > confusion, I think. I would be fine with adding comments in i2c-core.c
> > or improving Documentation/i2c/smbus-protocol to make it more obious,
> > though.
> > 
> > On a related note, you will notice that the other i2c_smbus_* functions
> > do not follow the naming of SMBus transactions. Again that's something
> > I regret but I feel that changing the names now would cause a lot of
> > confusion amongst developers, so I'm not doing it.
> 
>  It may not be worth the effort, but if done in bulk for all the users in
> the tree, there should be no problem with that.  I am fairly sure there
> were changes of this kind from time to time, with occasional screams heard
> in response from some dark corners, but no big pain.  We obviously
> explicitly disregard out-of-tree users and for occasional contributors
> asking: "Where the * has this function gone?" there is the Documentation/
> tree to provide a greppable reference, so generally not a big deal.

It's not that easy. There are some drivers which are both in-tree and
out-of-tree, for which such a change means adding ifdefs. And there is
i2c-dev.h (the user-space one) which has similar functions, if we
rename only the kernel variants, there will be some confusion. But if
we rename also the user-space variants, then it's up to 2.4 kernel
users to have different names for kernel-space and user-space functions.

All in all I'd say it is not worth the effort. There are many other
tasks where our time will be better used.

> > Just one patch should be enough, if I agree with all the changes. You
> > might make a separate patch with the things I may not agree with, so
> > that you don't have to cherry-revert them if I indeed don't agree, and
> > we just merge them if I do agree.
> 
>  Hmm, technically you do not seem to be responsible to accept changes
> under drivers/rtc/, so I will split them anyway for others to decide.

Huu, sorry, for some reason I thought that we were still speaking about
i2c-sibyte. Of course I don't have my say about what happens in
drivers/rtc.

-- 
Jean Delvare

From khali@linux-fr.org Sat May 10 08:08:14 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 08:08:17 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:62844 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20021567AbYEJHIO (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 10 May 2008 08:08:14 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Juk81-0001W2-AP
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Sat, 10 May 2008 10:08:25 +0200
Date:	Sat, 10 May 2008 09:08:01 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	David Brownell <david-b@pacbell.net>, linux-mips@linux-mips.org,
	mgreer@mvista.com, rtc-linux@googlegroups.com,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
Message-ID: <20080510090801.74da049d@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805092202380.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
	<200805071625.20430.david-b@pacbell.net>
	<Pine.LNX.4.55.0805080306080.32613@cliff.in.clinika.pl>
	<200805090218.52570.david-b@pacbell.net>
	<Pine.LNX.4.55.0805092202380.10552@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19191
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1955
Lines: 36

On Fri, 9 May 2008 22:22:11 +0100 (BST), Maciej W. Rozycki wrote:
> > >  You can issue a block read of up to 5 bytes (6 if you add the PEC byte
> > > which is not interpreted by the controller in any way).  And you can issue
> > > a block write of up to 4 bytes (5 with PEC).  That's clearly not enough
> > > for the m41t81 let alone a generic implementation.
> > 
> > Right.  Possibly worth updating i2c-sibyte to be able to perform
> > those calls through the "smbus i2c_block" calls; but maybe not.
> > (Those calls aren't true SMBus calls, but many otherwise-SMBus-only
> > controllers can handle them, hence the i2c_smbus_* prefix.)
> 
>  I am not sure such a limited functionality is worth the hassle of making 
> it available to clients in a reasonably clean way.  How common an 
> extension of this kind is among SMBus controllers?  I would say if there 
> are other controllers providing it (perhaps for a different range of 
> transfer lengths) and clients benefitting from it, it might be worth 
> adding it for this controller as well.  Otherwise perhaps let's wait till 
> somebody complains about the lack of this functionality?

The problem is that the interface for client drivers to query the
adapters capabilities is rather limited. There's just one bit for I2C
block read, so if an adapter has limitations in the size of requests it
can accept (beyond the traditional 32-byte limit that comes from SMBus)
it can't express it. This means that client drivers should expect
transaction requests to fail even if they checked that the transaction
type in question was supported. Most client drivers don't actually
expect that.

My advice would be to only bother implementing restricted support for a
transaction type if there's a big benefit in doing so. And then, double
check that all the client drivers that are likely to be used with the
adapter in question, are robust enough to deal with the restrictions
gracefully.

-- 
Jean Delvare

From khali@linux-fr.org Sat May 10 09:36:02 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 09:36:06 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:5205 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20022623AbYEJIgC (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 10 May 2008 09:36:02 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1JulUv-0003ET-7G
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Sat, 10 May 2008 11:36:09 +0200
Date:	Sat, 10 May 2008 10:35:44 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	David Brownell <david-b@pacbell.net>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexander Bigga <ab@mycable.de>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, i2c@lm-sensors.org,
	rtc-linux@googlegroups.com, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80
Message-ID: <20080510103544.701c7b3f@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805100116290.10552@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
	<Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
	<20080508093456.340a42b0@hyperion.delvare>
	<Pine.LNX.4.55.0805091917370.10552@cliff.in.clinika.pl>
	<20080509222754.03de1c54@hyperion.delvare>
	<Pine.LNX.4.55.0805100116290.10552@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19192
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 4096
Lines: 124

Hi Maciej,

On Sat, 10 May 2008 02:35:18 +0100 (BST), Maciej W. Rozycki wrote:
> > >  Ah, I see -- I must have missed it from documentation or perhaps it is
> > > somewhat unclear.  You mean our I2C API implies a driver for a
> > 
> > It's documented in Documentation/i2c/functionality. If something is
> > unclear, please let me know and/or send a patch.
> 
>  Well, I had a look at this file while writing my changes and this is the 
> very thing that is unclear.  The only place the description refers to 
> emulation is the I2C_FUNC_SMBUS_EMUL flag and there is nothing said
> about any other I2C_FUNC_SMBUS_* flag in the context of emulation.  The 
> rest of the file refers to functionality provided by the adapter, which 
> can be reasonably assumed to be such provided directly by hardware.

OK, I've just spent some time trying to improve this piece of
documentation. I'll send it to you and the i2c list in a moment, to not
overload this thread. Please tell me if my proposed changes make the
document clearer.

> (...)
>  Will see.  For now here is a new version of the change -- aside taking 
> your and other people's comments into account I have improved the logic 
> behind required bus adapter's feature determination.

Only commenting on the i2c bits...

> -static int m41t80_get_datetime(struct i2c_client *client,
> -			       struct rtc_time *tm)
> +
> +static int m41t80_transfer(struct i2c_client *client, int write,
> +			   u8 reg, u8 num, u8 *buf)
>  {
> -	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
> -	struct i2c_msg msgs[] = {
> -		{
> -			.addr	= client->addr,
> -			.flags	= 0,
> -			.len	= 1,
> -			.buf	= dt_addr,
> -		},
> -		{
> -			.addr	= client->addr,
> -			.flags	= I2C_M_RD,
> -			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
> -			.buf	= buf + M41T80_REG_SEC,
> -		},
> -	};
> +	int i, rc;
>  
> -	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
> -		dev_err(&client->dev, "read error\n");
> -		return -EIO;
> +	if (write) {
> +		if (i2c_check_functionality(client->adapter,
> +					    I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
> +			i = i2c_smbus_write_i2c_block_data(client,
> +							   reg, num, buf);
> +		} else {
> +			for (i = 0; i < num; i++) {
> +				rc = i2c_smbus_write_byte_data(client, reg + i,
> +							       buf[i]);
> +				if (rc < 0) {
> +					i = rc;
> +					goto out;
> +				}
> +			}
> +		}
> +	} else {
> +		if (i2c_check_functionality(client->adapter,
> +					    I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
> +			i = i2c_smbus_read_i2c_block_data(client,
> +							  reg, num, buf);
> +		} else {
> +			for (i = 0; i < num; i++) {
> +				rc = i2c_smbus_read_byte_data(client, reg + i);
> +				if (rc < 0) {
> +					i = rc;
> +					goto out;
> +				}
> +				buf[i] = rc;
> +			}
> +		}
>  	}
> +out:
> +	return i;
> +}

I don't understand why you insist on having a single m41t80_transfer()
function for read and write transactions, when the read and write cases
share zero code. Separate functions would perform better.

> (...)
> -	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
> -				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
> +	func = i2c_get_functionality(client->adapter);
> +	if (!(func & (I2C_FUNC_SMBUS_READ_I2C_BLOCK |
> +		      I2C_FUNC_SMBUS_READ_BYTE)) ||
> +	    !(func & (I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
> +		      I2C_FUNC_SMBUS_WRITE_BYTE))) {
>  		rc = -ENODEV;
>  		goto exit;
>  	}

Still not correct, sorry. The driver is still making unconditional
calls to i2c_smbus_read_byte_data() and i2c_smbus_write_byte_data(), so
the underlying adapter _must_ support I2C_FUNC_SMBUS_READ_BYTE_DATA and
I2C_FUNC_SMBUS_WRITE_BYTE_DATA (i.e. I2C_FUNC_SMBUS_BYTE_DATA), even if
it also supports the block transactions. Also, you don't have to check
for the availability of these block transactions at this point, because
you test for them at run-time in m41t80_transfer(), and the driver will
work find without them.

So the proper test here would simply be:

	if (!i2c_check_functionality(client->adapter,
				     I2C_FUNC_SMBUS_BYTE_DATA)) {
 		rc = -ENODEV;
 		goto exit;
 	}

-- 
Jean Delvare

From sshtylyov@ru.mvista.com Sat May 10 11:00:56 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 11:00:58 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:4847 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20021509AbYEJKA4 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 10 May 2008 11:00:56 +0100
Received: from acerfa265979ef (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with SMTP
	id 295213ECB; Sat, 10 May 2008 03:00:51 -0700 (PDT)
Message-ID: <023101c8b284$b7f67a30$5205a8c0@acerfa265979ef>
From:	"Sergei Shtylyov" <sshtylyov@ru.mvista.com>
To:	"Manuel Lauss" <mano@roarinelk.homelinux.net>
Cc:	<linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
References: <20080507160154.GA17806@roarinelk.homelinux.net> <20080507160634.GE17806@roarinelk.homelinux.net> <4822F4FC.5040107@ru.mvista.com> <20080508130833.GA25971@roarinelk.homelinux.net> <482354D0.9040304@ru.mvista.com> <20080509054010.GA32719@roarinelk.homelinux.net>
Subject: Re: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platformdevice and board specific functions
Date:	Sat, 10 May 2008 14:00:45 +0400
MIME-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="ISO-8859-1";
	reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19193
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 4204
Lines: 118

----- Original Message ----- 
From: "Manuel Lauss" <mano@roarinelk.homelinux.net>
To: "Sergei Shtylyov" <sshtylyov@ru.mvista.com>
Cc: <linux-mips@linux-mips.org>; <linux-kernel@vger.kernel.org>
Sent: Friday, May 09, 2008 9:40 AM
Subject: Re: [PATCH 4/7] Alchemy: db1200/pb1200: register mmc platformdevice 
and board specific functions


> On Thu, May 08, 2008 at 11:30:24PM +0400, Sergei Shtylyov wrote:
>> Manuel Lauss wrote:

>>>>> diff --git a/arch/mips/au1000/common/platform.c
>>>>> b/arch/mips/au1000/common/platform.c
>>>>> index 31d2a22..08a5900 100644
>>>>> --- a/arch/mips/au1000/common/platform.c
>>>>> +++ b/arch/mips/au1000/common/platform.c
>>>>> -
>>>>> -static struct platform_device au1xxx_mmc_device = {
>>>>> - .name = "au1xxx-mmc",
>>>>> - .id = 0,
>>>>> - .dev = {
>>>>> - .dma_mask               = &au1xxx_mmc_dmamask,
>>>>> - .coherent_dma_mask      = 0xffffffff,
>>>>> - },
>>>>> - .num_resources  = ARRAY_SIZE(au1xxx_mmc_resources),
>>>>> - .resource       = au1xxx_mmc_resources,
>>>>> -};
>>>>> #endif /* #ifdef CONFIG_SOC_AU1200 */
>>>>
>>>>   What board-specific was here?

>>> Nothing in here per se, but a) I don't like this file, it registers
>>> stuff some boards don't need/want,  b) this part is only interesting
>>> for pb1200 board anyway.

>>    Sigh. Do you know that Au1100 also has the same MMC controllers? The
>> platform device is not registered in this case though and the driver
>> (however small it now actually uses the platform device per se) is
>> therefore unable to control it (well, I'm not sure it can do that since 
>> it
>> seems to be Au1200 centered now (using DBDMA), however it was initially
>> written for Au1100 as it seems.

> I gathered that from the driver source...

> I assume the PIO paths in the driver are intended for the Au1100, correct?
> Should not be too hard to force PIO paths when no DDMA IDs are passed
> through the platform device's resources.


   Yes but it should've probably also supported DMA via Au1100 DMA 
controller (not DBDMA).

>>>>> + return (bcsr->sig_status & au1xmmc_card_table[host->id].bcsrstatus)
>>>>> + ? 1 : 0;
>>>>> +}
>>>>> +
>>>>> +static struct au1xmmc_platdata db1xmmcpd = {
>>>>> + .set_power = pb1200mmc_set_power,
>>>>> + .card_inserted = pb1200mmc_card_inserted,
>>>>> + .card_readonly = pb1200mmc_card_readonly,
>>>>> + .cd_setup = NULL, /* use poll-timer in driver */

>>>>   Function ptrs in the platform data?  That's something new -- though 
>>>> why
>>>> not? :-)

>>> Is this an accepted way of doing things in the kernel?  If not, I'm open
>>> to suggestions!

>>    I really don't know -- never seen such trick before.

>>> (I prefer this to globally-visible methods called by the
>>> driver.  I like it when related things are neatly grouped together).

>>    Yes, this indeed looks better.

> Unless someone else speaks up against it, I'll leave it the way it is.

   I assume just parametrizing the board-level functions using the data 
about BCSR (like it was done in the driver before) just won't work?

>>>>> + },
>>>>> + .num_resources  = ARRAY_SIZE(au1200sd0_res),
>>>>> + .resource       = au1200sd0_res,
>>>>> +};
>>>>> +
>>>>> +#ifndef CONFIG_MIPS_DB1200

>>>>   Wait, SD controller 1 is there regardless of the board, so should be
>>>> registerred regardless. If however the board doesn't have the necessary
>>>> resources to support the driver functionality, I think it can be
>>>> indicated by the board-level platform data, so that the driver could
>>>> decide whether it wants to support that controller or not.

>>> Won't this cause problems if e.g. you are using PCMCIA (since SD1 pins 
>>> are
>>> muxed with pcmcia signals)?

>>    Good point.  I think that the code in 
>> arch/mips/au1000/common/platform.c
>> should check the sys_pinfunc register, and not blindly register all
>> devices.

> Hm, sounds ugly, but I'll add something.

   Why? I think it's smarter than register SoC devices in every instance of 
board setup code. This way, the board setup code has already programmed 
sys_pinfunc as it sees fit, and the common code accomodates to this need 
registering those devices that the coard code have selected.

> Thanks!
> Manuel Lauss

WBR, Sergei



From david-b@pacbell.net Sat May 10 17:40:12 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 10 May 2008 17:40:15 +0100 (BST)
Received: from smtp118.sbc.mail.sp1.yahoo.com ([69.147.64.91]:4486 "HELO
	smtp118.sbc.mail.sp1.yahoo.com") by ftp.linux-mips.org with SMTP
	id S20023159AbYEJQkM (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 10 May 2008 17:40:12 +0100
Received: (qmail 17736 invoked from network); 10 May 2008 16:40:03 -0000
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
  s=s1024; d=pacbell.net;
  h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:Cc:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id;
  b=N9kNP7Ejo3Q7bZZHCzJKLnOs3KonhjpO/s6VIp9c/Oas9JjgMQrHq15xIgYqasw540286oUdzymxAeuMAsYCLU4jBJpJxYY0qttTuC2ZbNR/NG8slGJh3nLrBbMNqC8rtG7gLFseOFyT11ZGnPQibBX6Reo8DR7dtwsOr3ewsYQ=  ;
Received: from unknown (HELO ascent) (david-b@pacbell.net@69.226.243.232 with plain)
  by smtp118.sbc.mail.sp1.yahoo.com with SMTP; 10 May 2008 16:40:02 -0000
X-YMail-OSG: otf8KZAVM1nvzFtQI6osUUpw9Xi5DpGth28ef.aytRA438dUlShuAlEK.6Ec50CxWVQTDr1r7EODEUl05lFZtoccpc9UDzNUivZYf3CVVWJD3sr_gu33ltuAtWOIhEZkEL0-
X-Yahoo-Newman-Property: ymail-3
From:	David Brownell <david-b@pacbell.net>
To:	Jean Delvare <khali@linux-fr.org>
Subject: Re: [i2c] [RFC][PATCH 4/4] RTC: SMBus support for the M41T80,
Date:	Sat, 10 May 2008 09:36:50 -0700
User-Agent: KMail/1.9.6
Cc:	"Maciej W. Rozycki" <macro@linux-mips.org>,
	linux-mips@linux-mips.org, mgreer@mvista.com,
	rtc-linux@googlegroups.com, Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	linux-kernel@vger.kernel.org, i2c@lm-sensors.org, ab@mycable.de,
	Alessandro Zummo <alessandro.zummo@towertech.it>
References: <200805070120.03821.david-b@pacbell.net> <Pine.LNX.4.55.0805100301100.10552@cliff.in.clinika.pl> <20080510085340.29c26aef@hyperion.delvare>
In-Reply-To: <20080510085340.29c26aef@hyperion.delvare>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Message-Id: <200805100936.52057.david-b@pacbell.net>
Return-Path: <david-b@pacbell.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19194
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: david-b@pacbell.net
Precedence: bulk
X-list: linux-mips
Content-Length: 22419
Lines: 585

On Friday 09 May 2008, Jean Delvare wrote:
> 
> > > On a related note, you will notice that the other i2c_smbus_* functions
> > > do not follow the naming of SMBus transactions. Again that's something
> > > I regret but I feel that changing the names now would cause a lot of
> > > confusion amongst developers, so I'm not doing it.
> > 
> > It may not be worth the effort, but if done in bulk for all the users in
> > the tree, there should be no problem with that.  ...
> 
> It's not that easy. There are some drivers which are both in-tree and
> out-of-tree, for which such a change means adding ifdefs.

Actually, I thought it *WAS* that easy.  See the appended patch,
which goes on top of the various doc and (mostly SMBus) fault
handling patches I've sent ... the old names are still available
(only needed by out-of-tree drivers), but marked as __deprecated.
So:  no #ifdefs required.

I agree it's not worth while for *all* the SMBus functions that
use names-made-up-for-Linux.  But for the two which are really
badly misnamed (after *different* SMBus operations), I suggest
fixing would be a reasonable thing.


> And there is 
> i2c-dev.h (the user-space one) which has similar functions,

That's problematic in its own right though.  Not only that
the *kernel* file Documentation/i2c/dev-interface referring
to those functions, which are unavailable from the header
provided by the kernel.  Or that there's no relationship
between the kernel and userspace files of the same name.
But also that those functions are actually a bit too large
to be appropriate as inlines, even once you manage to track
it down (as part of a "tools" package, not a "library").


> if we 
> rename only the kernel variants, there will be some confusion. But if
> we rename also the user-space variants, then it's up to 2.4 kernel
> users to have different names for kernel-space and user-space functions.

True, but that would be a question for a "libsmbus" or somesuch
to deal with.  Not a kernel issue.

- Dave


===========
Two of the SMBus operations are using confusingly inappropriate names:

  i2c_smbus_read_byte() does not execute the SMBus "Read Byte" protocol
  	... it implements the SMBus "Receive Byte" protocol instead!!

  i2c_smbus_write_byte() does not execute the SMBus "Write Byte" protocol
  	... it implements the SMBus "Send Byte" protocol instead!!

This patch changes the names of those functions, so they no longer
use names of different operations (which they do not implement).

---
 Documentation/i2c/chips/max6875   |    4 ++--
 Documentation/i2c/smbus-protocol  |   12 +++++-------
 Documentation/i2c/writing-clients |    4 ++--
 drivers/gpio/pcf857x.c            |    8 ++++----
 drivers/hwmon/ds1621.c            |    2 +-
 drivers/hwmon/lm90.c              |    2 +-
 drivers/i2c/chips/eeprom.c        |   10 +++++-----
 drivers/i2c/chips/max6875.c       |    2 +-
 drivers/i2c/chips/pcf8574.c       |    4 ++--
 drivers/i2c/chips/pcf8591.c       |   10 +++++-----
 drivers/i2c/chips/tsl2550.c       |   16 ++++++++--------
 drivers/i2c/i2c-core.c            |   12 ++++++------
 drivers/media/video/saa7110.c     |    2 +-
 drivers/media/video/saa7185.c     |    2 +-
 drivers/media/video/tda9840.c     |    8 ++++----
 drivers/media/video/tea6415c.c    |    4 ++--
 drivers/media/video/tea6420.c     |    4 ++--
 drivers/w1/masters/ds2482.c       |   10 +++++-----
 include/linux/i2c.h               |   20 ++++++++++++++++++--
 19 files changed, 75 insertions(+), 61 deletions(-)

--- g26.orig/include/linux/i2c.h	2008-05-07 16:32:18.000000000 -0700
+++ g26/include/linux/i2c.h	2008-05-10 00:13:48.000000000 -0700
@@ -73,8 +73,8 @@ extern s32 i2c_smbus_xfer (struct i2c_ad
    conventions of smbus_access. */
 
 extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
-extern s32 i2c_smbus_read_byte(struct i2c_client * client);
-extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
+extern s32 i2c_smbus_receive_byte(struct i2c_client *client);
+extern s32 i2c_smbus_send_byte(struct i2c_client *client, u8 value);
 extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
 extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
                                      u8 command, u8 value);
@@ -94,6 +94,22 @@ extern s32 i2c_smbus_write_i2c_block_dat
 					  u8 command, u8 length,
 					  const u8 *values);
 
+/* Stop using these legacy names in new code.
+ * - the SMBus "Read Byte" operation is i2c_smbus_read_byte_data()
+ * - the SMBus "Write Byte" operation is i2c_smbus_write_byte_data()
+ *
+ */
+static inline s32 __deprecated i2c_smbus_read_byte(struct i2c_client *client)
+{
+	return i2c_smbus_receive_byte(client);
+}
+
+static inline s32 __deprecated i2c_smbus_write_byte(struct i2c_client *client,
+		u8 value)
+{
+	return i2c_smbus_send_byte(client, value);
+}
+
 /*
  * A driver is capable of handling one or more physical devices present on
  * I2C adapters. This information is used to inform the driver of adapter
--- g26.orig/drivers/i2c/i2c-core.c	2008-05-07 16:32:18.000000000 -0700
+++ g26/drivers/i2c/i2c-core.c	2008-05-10 00:08:45.000000000 -0700
@@ -1529,13 +1529,13 @@ s32 i2c_smbus_write_quick(struct i2c_cli
 EXPORT_SYMBOL(i2c_smbus_write_quick);
 
 /**
- * i2c_smbus_read_byte - SMBus "receive byte" protocol
+ * i2c_smbus_receive_byte - SMBus "receive byte" protocol
  * @client: Handle to slave device
  *
  * This executes the SMBus "receive byte" protocol, returning negative errno
  * else the byte received from the device.
  */
-s32 i2c_smbus_read_byte(struct i2c_client *client)
+s32 i2c_smbus_receive_byte(struct i2c_client *client)
 {
 	union i2c_smbus_data data;
 	int status;
@@ -1545,22 +1545,22 @@ s32 i2c_smbus_read_byte(struct i2c_clien
 			I2C_SMBUS_BYTE, &data);
 	return (status < 0) ? status : data.byte;
 }
-EXPORT_SYMBOL(i2c_smbus_read_byte);
+EXPORT_SYMBOL(i2c_smbus_receive_byte);
 
 /**
- * i2c_smbus_write_byte - SMBus "send byte" protocol
+ * i2c_smbus_send_byte - SMBus "send byte" protocol
  * @client: Handle to slave device
  * @value: Byte to be sent
  *
  * This executes the SMBus "send byte" protocol, returning negative errno
  * else zero on success.
  */
-s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
+s32 i2c_smbus_send_byte(struct i2c_client *client, u8 value)
 {
 	return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
 	                      I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
 }
-EXPORT_SYMBOL(i2c_smbus_write_byte);
+EXPORT_SYMBOL(i2c_smbus_send_byte);
 
 /**
  * i2c_smbus_read_byte_data - SMBus "read byte" protocol
--- g26.orig/Documentation/i2c/chips/max6875	2007-07-12 16:32:15.000000000 -0700
+++ g26/Documentation/i2c/chips/max6875	2008-05-10 00:07:50.000000000 -0700
@@ -88,14 +88,14 @@ To write 0x5a to address 0x8003:
 
 Reading data from the EEPROM is a little more complicated.
 Use i2c_smbus_write_byte_data() to set the read address and then
-i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data.
+i2c_smbus_receive_byte() or i2c_smbus_read_i2c_block_data() to read the data.
 
 Example:
 To read data starting at offset 0x8100, first set the address:
   i2c_smbus_write_byte_data(fd, 0x81, 0x00);
 
 And then read the data
-  value = i2c_smbus_read_byte(fd);
+  value = i2c_smbus_receive_byte(fd);
 
   or
 
--- g26.orig/Documentation/i2c/smbus-protocol	2008-05-10 00:13:59.000000000 -0700
+++ g26/Documentation/i2c/smbus-protocol	2008-05-10 00:15:14.000000000 -0700
@@ -18,9 +18,7 @@ handled at all on most pure SMBus adapte
 
 Below is a list of SMBus protocol operations, and the functions executing
 them.  Note that the names used in the SMBus protocol specifications usually
-don't match these function names.  For some of the operations which pass a
-single data byte, the functions using SMBus protocol operation names execute
-a different protocol operation entirely.
+don't match these function names.
 
 
 Key to symbols
@@ -49,8 +47,8 @@ This sends a single bit to the device, a
 A Addr Rd/Wr [A] P
 
 
-SMBus Receive Byte:  i2c_smbus_read_byte()
-==========================================
+SMBus Receive Byte:  i2c_smbus_receive_byte()
+=============================================
 
 This reads a single byte from a device, without specifying a device
 register. Some devices are so simple that this interface is enough; for
@@ -60,8 +58,8 @@ the previous SMBus command.
 S Addr Rd [A] [Data] NA P
 
 
-SMBus Send Byte:  i2c_smbus_write_byte()
-========================================
+SMBus Send Byte:  i2c_smbus_send_byte()
+=======================================
 
 This operation is the reverse of Receive Byte: it sends a single byte
 to a device.  See Receive Byte for more information.
--- g26.orig/Documentation/i2c/writing-clients	2008-04-29 21:51:55.000000000 -0700
+++ g26/Documentation/i2c/writing-clients	2008-05-10 00:07:50.000000000 -0700
@@ -560,8 +560,8 @@ SMBus communication
 
 
   extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
-  extern s32 i2c_smbus_read_byte(struct i2c_client * client);
-  extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
+  extern s32 i2c_smbus_receive_byte(struct i2c_client * client);
+  extern s32 i2c_smbus_send_byte(struct i2c_client * client, u8 value);
   extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
   extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
                                        u8 command, u8 value);
--- g26.orig/drivers/gpio/pcf857x.c	2008-05-07 16:32:18.000000000 -0700
+++ g26/drivers/gpio/pcf857x.c	2008-05-10 00:07:50.000000000 -0700
@@ -68,7 +68,7 @@ static int pcf857x_input8(struct gpio_ch
 	struct pcf857x	*gpio = container_of(chip, struct pcf857x, chip);
 
 	gpio->out |= (1 << offset);
-	return i2c_smbus_write_byte(gpio->client, gpio->out);
+	return i2c_smbus_send_byte(gpio->client, gpio->out);
 }
 
 static int pcf857x_get8(struct gpio_chip *chip, unsigned offset)
@@ -76,7 +76,7 @@ static int pcf857x_get8(struct gpio_chip
 	struct pcf857x	*gpio = container_of(chip, struct pcf857x, chip);
 	s32		value;
 
-	value = i2c_smbus_read_byte(gpio->client);
+	value = i2c_smbus_receive_byte(gpio->client);
 	return (value < 0) ? 0 : (value & (1 << offset));
 }
 
@@ -89,7 +89,7 @@ static int pcf857x_output8(struct gpio_c
 		gpio->out |= bit;
 	else
 		gpio->out &= ~bit;
-	return i2c_smbus_write_byte(gpio->client, gpio->out);
+	return i2c_smbus_send_byte(gpio->client, gpio->out);
 }
 
 static void pcf857x_set8(struct gpio_chip *chip, unsigned offset, int value)
@@ -202,7 +202,7 @@ static int pcf857x_probe(struct i2c_clie
 
 		/* fail if there's no chip present */
 		else
-			status = i2c_smbus_read_byte(client);
+			status = i2c_smbus_receive_byte(client);
 
 	/* '75/'75c addresses are 0x20..0x27, just like the '74;
 	 * the '75c doesn't have a current source pulling high.
--- g26.orig/drivers/hwmon/ds1621.c	2008-03-28 11:08:28.000000000 -0700
+++ g26/drivers/hwmon/ds1621.c	2008-05-10 00:07:50.000000000 -0700
@@ -132,7 +132,7 @@ static void ds1621_init_client(struct i2
 	ds1621_write_value(client, DS1621_REG_CONF, reg);
 	
 	/* start conversion */
-	i2c_smbus_write_byte(client, DS1621_COM_START);
+	i2c_smbus_send_byte(client, DS1621_COM_START);
 }
 
 static ssize_t show_temp(struct device *dev, struct device_attribute *da,
--- g26.orig/drivers/hwmon/lm90.c	2008-03-28 11:08:29.000000000 -0700
+++ g26/drivers/hwmon/lm90.c	2008-05-10 00:07:50.000000000 -0700
@@ -463,7 +463,7 @@ static int lm90_read_reg(struct i2c_clie
  	if (client->flags & I2C_CLIENT_PEC) {
  		err = adm1032_write_byte(client, reg);
  		if (err >= 0)
- 			err = i2c_smbus_read_byte(client);
+			err = i2c_smbus_receive_byte(client);
  	} else
  		err = i2c_smbus_read_byte_data(client, reg);
 
--- g26.orig/drivers/i2c/chips/eeprom.c	2008-03-28 11:08:29.000000000 -0700
+++ g26/drivers/i2c/chips/eeprom.c	2008-05-10 00:07:50.000000000 -0700
@@ -93,12 +93,12 @@ static void eeprom_update_client(struct 
 							!= 32)
 					goto exit;
 		} else {
-			if (i2c_smbus_write_byte(client, slice << 5)) {
+			if (i2c_smbus_send_byte(client, slice << 5)) {
 				dev_dbg(&client->dev, "eeprom read start has failed!\n");
 				goto exit;
 			}
 			for (i = slice << 5; i < (slice + 1) << 5; i++) {
-				j = i2c_smbus_read_byte(client);
+				j = i2c_smbus_receive_byte(client);
 				if (j < 0)
 					goto exit;
 				data->data[i] = (u8) j;
@@ -208,9 +208,9 @@ static int eeprom_detect(struct i2c_adap
 		char name[4];
 
 		name[0] = i2c_smbus_read_byte_data(new_client, 0x80);
-		name[1] = i2c_smbus_read_byte(new_client);
-		name[2] = i2c_smbus_read_byte(new_client);
-		name[3] = i2c_smbus_read_byte(new_client);
+		name[1] = i2c_smbus_receive_byte(new_client);
+		name[2] = i2c_smbus_receive_byte(new_client);
+		name[3] = i2c_smbus_receive_byte(new_client);
 
 		if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) {
 			dev_info(&new_client->dev, "Vaio EEPROM detected, "
--- g26.orig/drivers/i2c/chips/max6875.c	2008-03-28 10:42:32.000000000 -0700
+++ g26/drivers/i2c/chips/max6875.c	2008-05-10 00:07:50.000000000 -0700
@@ -112,7 +112,7 @@ static void max6875_update_slice(struct 
 			}
 		} else {
 			for (i = 0; i < SLICE_SIZE; i++) {
-				j = i2c_smbus_read_byte(client);
+				j = i2c_smbus_receive_byte(client);
 				if (j < 0) {
 					goto exit_up;
 				}
--- g26.orig/drivers/i2c/chips/pcf8574.c	2008-03-28 11:08:29.000000000 -0700
+++ g26/drivers/i2c/chips/pcf8574.c	2008-05-10 00:07:50.000000000 -0700
@@ -75,7 +75,7 @@ static struct i2c_driver pcf8574_driver 
 static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	return sprintf(buf, "%u\n", i2c_smbus_read_byte(client));
+	return sprintf(buf, "%u\n", i2c_smbus_receive_byte(client));
 }
 
 static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
@@ -101,7 +101,7 @@ static ssize_t set_write(struct device *
 		return -EINVAL;
 
 	data->write = val;
-	i2c_smbus_write_byte(client, data->write);
+	i2c_smbus_send_byte(client, data->write);
 	return count;
 }
 
--- g26.orig/drivers/i2c/chips/pcf8591.c	2008-03-28 11:08:29.000000000 -0700
+++ g26/drivers/i2c/chips/pcf8591.c	2008-05-10 00:07:50.000000000 -0700
@@ -149,7 +149,7 @@ static ssize_t set_out0_enable(struct de
 		data->control |= PCF8591_CONTROL_AOEF;
 	else
 		data->control &= ~PCF8591_CONTROL_AOEF;
-	i2c_smbus_write_byte(client, data->control);
+	i2c_smbus_send_byte(client, data->control);
 	mutex_unlock(&data->update_lock);
 	return count;
 }
@@ -288,7 +288,7 @@ static void pcf8591_init_client(struct i
 	
 	/* The first byte transmitted contains the conversion code of the 
 	   previous read cycle. FLUSH IT! */
-	i2c_smbus_read_byte(client);
+	i2c_smbus_receive_byte(client);
 }
 
 static int pcf8591_read_channel(struct device *dev, int channel)
@@ -302,13 +302,13 @@ static int pcf8591_read_channel(struct d
 	if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) {
 		data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
 			      | channel;
-		i2c_smbus_write_byte(client, data->control);
+		i2c_smbus_send_byte(client, data->control);
 	
 		/* The first byte transmitted contains the conversion code of 
 		   the previous read cycle. FLUSH IT! */
-		i2c_smbus_read_byte(client);
+		i2c_smbus_receive_byte(client);
 	}
-	value = i2c_smbus_read_byte(client);
+	value = i2c_smbus_receive_byte(client);
 
 	mutex_unlock(&data->update_lock);
 
--- g26.orig/drivers/i2c/chips/tsl2550.c	2008-04-29 21:51:56.000000000 -0700
+++ g26/drivers/i2c/chips/tsl2550.c	2008-05-10 00:07:50.000000000 -0700
@@ -68,7 +68,7 @@ static int tsl2550_set_operating_mode(st
 {
 	struct tsl2550_data *data = i2c_get_clientdata(client);
 
-	int ret = i2c_smbus_write_byte(client, TSL2550_MODE_RANGE[mode]);
+	int ret = i2c_smbus_send_byte(client, TSL2550_MODE_RANGE[mode]);
 
 	data->operating_mode = mode;
 
@@ -81,9 +81,9 @@ static int tsl2550_set_power_state(struc
 	int ret;
 
 	if (state == 0)
-		ret = i2c_smbus_write_byte(client, TSL2550_POWER_DOWN);
+		ret = i2c_smbus_send_byte(client, TSL2550_POWER_DOWN);
 	else {
-		ret = i2c_smbus_write_byte(client, TSL2550_POWER_UP);
+		ret = i2c_smbus_send_byte(client, TSL2550_POWER_UP);
 
 		/* On power up we should reset operating mode also... */
 		tsl2550_set_operating_mode(client, data->operating_mode);
@@ -107,14 +107,14 @@ static int tsl2550_get_adc_value(struct 
 	 */
 	end = jiffies + msecs_to_jiffies(400);
 	while (time_before(jiffies, end)) {
-		i2c_smbus_write_byte(client, cmd);
+		i2c_smbus_send_byte(client, cmd);
 
 		if (loop++ < 5)
 			mdelay(1);
 		else
 			msleep(1);
 
-		ret = i2c_smbus_read_byte(client);
+		ret = i2c_smbus_receive_byte(client);
 		if (ret < 0)
 			return ret;
 		else if (ret & 0x0080)
@@ -342,16 +342,16 @@ static int tsl2550_init_client(struct i2
 	 * Probe the chip. To do so we try to power up the device and then to
 	 * read back the 0x03 code
 	 */
-	err = i2c_smbus_write_byte(client, TSL2550_POWER_UP);
+	err = i2c_smbus_send_byte(client, TSL2550_POWER_UP);
 	if (err < 0)
 		return err;
 	mdelay(1);
-	if (i2c_smbus_read_byte(client) != TSL2550_POWER_UP)
+	if (i2c_smbus_receive_byte(client) != TSL2550_POWER_UP)
 		return -ENODEV;
 	data->power_state = 1;
 
 	/* Set the default operating mode */
-	err = i2c_smbus_write_byte(client,
+	err = i2c_smbus_send_byte(client,
 				   TSL2550_MODE_RANGE[data->operating_mode]);
 	if (err < 0)
 		return err;
--- g26.orig/drivers/media/video/saa7110.c	2008-04-24 13:45:59.000000000 -0700
+++ g26/drivers/media/video/saa7110.c	2008-05-10 00:07:51.000000000 -0700
@@ -127,7 +127,7 @@ saa7110_write_block (struct i2c_client *
 static inline int
 saa7110_read (struct i2c_client *client)
 {
-	return i2c_smbus_read_byte(client);
+	return i2c_smbus_receive_byte(client);
 }
 
 /* ----------------------------------------------------------------------- */
--- g26.orig/drivers/media/video/saa7185.c	2008-04-24 13:45:59.000000000 -0700
+++ g26/drivers/media/video/saa7185.c	2008-05-10 00:07:51.000000000 -0700
@@ -82,7 +82,7 @@ struct saa7185 {
 static inline int
 saa7185_read (struct i2c_client *client)
 {
-	return i2c_smbus_read_byte(client);
+	return i2c_smbus_receive_byte(client);
 }
 
 static int
--- g26.orig/drivers/media/video/tda9840.c	2008-04-24 13:45:59.000000000 -0700
+++ g26/drivers/media/video/tda9840.c	2008-05-10 00:07:51.000000000 -0700
@@ -74,7 +74,7 @@ static int command(struct i2c_client *cl
 
 		result = i2c_smbus_write_byte_data(client, SWITCH, byte);
 		if (result)
-			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+			dprintk("i2c_smbus_write_byte_data() failed, ret:%d\n", result);
 		break;
 
 	case TDA9840_LEVEL_ADJUST:
@@ -94,7 +94,7 @@ static int command(struct i2c_client *cl
 
 		result = i2c_smbus_write_byte_data(client, LEVEL_ADJUST, byte);
 		if (result)
-			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+			dprintk("i2c_smbus_write_byte_data() failed, ret:%d\n", result);
 		break;
 
 	case TDA9840_STEREO_ADJUST:
@@ -114,7 +114,7 @@ static int command(struct i2c_client *cl
 
 		result = i2c_smbus_write_byte_data(client, STEREO_ADJUST, byte);
 		if (result)
-			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+			dprintk("i2c_smbus_write_byte_data() failed, ret:%d\n", result);
 		break;
 
 	case TDA9840_DETECT: {
@@ -144,7 +144,7 @@ static int command(struct i2c_client *cl
 
 		result = i2c_smbus_write_byte_data(client, TEST, byte);
 		if (result)
-			dprintk("i2c_smbus_write_byte() failed, ret:%d\n", result);
+			dprintk("i2c_smbus_write_byte_data() failed, ret:%d\n", result);
 		break;
 	default:
 		return -ENOIOCTLCMD;
--- g26.orig/drivers/media/video/tea6415c.c	2008-04-24 13:45:59.000000000 -0700
+++ g26/drivers/media/video/tea6415c.c	2008-05-10 00:07:51.000000000 -0700
@@ -165,9 +165,9 @@ static int switch_matrix(struct i2c_clie
 		break;
 	};
 
-	ret = i2c_smbus_write_byte(client, byte);
+	ret = i2c_smbus_send_byte(client, byte);
 	if (ret) {
-		dprintk("i2c_smbus_write_byte() failed, ret:%d\n", ret);
+		dprintk("i2c_smbus_send_byte() failed, ret:%d\n", ret);
 		return -EIO;
 	}
 
--- g26.orig/drivers/media/video/tea6420.c	2008-04-24 13:45:59.000000000 -0700
+++ g26/drivers/media/video/tea6420.c	2008-05-10 00:07:51.000000000 -0700
@@ -79,9 +79,9 @@ static int tea6420_switch(struct i2c_cli
 		break;
 	}
 
-	ret = i2c_smbus_write_byte(client, byte);
+	ret = i2c_smbus_send_byte(client, byte);
 	if (ret) {
-		dprintk("i2c_smbus_write_byte() failed, ret:%d\n", ret);
+		dprintk("i2c_smbus_send_byte() failed, ret:%d\n", ret);
 		return -EIO;
 	}
 
--- g26.orig/drivers/w1/masters/ds2482.c	2008-03-28 10:42:44.000000000 -0700
+++ g26/drivers/w1/masters/ds2482.c	2008-05-10 00:07:51.000000000 -0700
@@ -167,7 +167,7 @@ static inline int ds2482_select_register
  */
 static inline int ds2482_send_cmd(struct ds2482_data *pdev, u8 cmd)
 {
-	if (i2c_smbus_write_byte(&pdev->client, cmd) < 0)
+	if (i2c_smbus_send_byte(&pdev->client, cmd) < 0)
 		return -1;
 
 	pdev->read_prt = DS2482_PTR_CODE_STATUS;
@@ -216,7 +216,7 @@ static int ds2482_wait_1wire_idle(struct
 
 	if (!ds2482_select_register(pdev, DS2482_PTR_CODE_STATUS)) {
 		do {
-			temp = i2c_smbus_read_byte(&pdev->client);
+			temp = i2c_smbus_receive_byte(&pdev->client);
 		} while ((temp >= 0) && (temp & DS2482_REG_STS_1WB) &&
 			 (++retries < DS2482_WAIT_IDLE_TIMEOUT));
 	}
@@ -244,7 +244,7 @@ static int ds2482_set_channel(struct ds2
 
 	pdev->read_prt = DS2482_PTR_CODE_CHANNEL;
 	pdev->channel = -1;
-	if (i2c_smbus_read_byte(&pdev->client) == ds2482_chan_rd[channel]) {
+	if (i2c_smbus_receive_byte(&pdev->client) == ds2482_chan_rd[channel]) {
 		pdev->channel = channel;
 		return 0;
 	}
@@ -368,7 +368,7 @@ static u8 ds2482_w1_read_byte(void *data
 	ds2482_select_register(pdev, DS2482_PTR_CODE_DATA);
 
 	/* Read the data byte */
-	result = i2c_smbus_read_byte(&pdev->client);
+	result = i2c_smbus_receive_byte(&pdev->client);
 
 	mutex_unlock(&pdev->access_lock);
 
@@ -463,7 +463,7 @@ static int ds2482_detect(struct i2c_adap
 	ndelay(525);
 
 	/* Read the status byte - only reset bit and line should be set */
-	temp1 = i2c_smbus_read_byte(new_client);
+	temp1 = i2c_smbus_receive_byte(new_client);
 	if (temp1 != (DS2482_REG_STS_LL | DS2482_REG_STS_RST)) {
 		dev_dbg(&adapter->dev, "DS2482 (0x%02x) reset status "
 			"0x%02X - not a DS2482\n", address, temp1);


From macro@linux-mips.org Sun May 11 03:00:11 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 May 2008 03:00:14 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:59133 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20026598AbYEKCAL (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 11 May 2008 03:00:11 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4B2003b020596;
	Sun, 11 May 2008 04:00:00 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4B1xYBM020592;
	Sun, 11 May 2008 02:59:42 +0100
Date:	Sun, 11 May 2008 02:59:34 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>
cc:	David Brownell <david-b@pacbell.net>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexander Bigga <ab@mycable.de>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, i2c@lm-sensors.org,
	rtc-linux@googlegroups.com, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80
In-Reply-To: <20080510103544.701c7b3f@hyperion.delvare>
Message-ID: <Pine.LNX.4.55.0805110045010.18978@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
 <Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
 <20080508093456.340a42b0@hyperion.delvare> <Pine.LNX.4.55.0805091917370.10552@cliff.in.clinika.pl>
 <20080509222754.03de1c54@hyperion.delvare> <Pine.LNX.4.55.0805100116290.10552@cliff.in.clinika.pl>
 <20080510103544.701c7b3f@hyperion.delvare>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19195
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 12563
Lines: 440

Hi Jean,

> OK, I've just spent some time trying to improve this piece of
> documentation. I'll send it to you and the i2c list in a moment, to not
> overload this thread. Please tell me if my proposed changes make the
> document clearer.

 Certainly.

> I don't understand why you insist on having a single m41t80_transfer()
> function for read and write transactions, when the read and write cases
> share zero code. Separate functions would perform better.

 Nothing to understand here and I do not insist on anything.  You are
right of course -- I must have got too much influenced by i2c_transfer()  
and have not thought of splitting.

> Still not correct, sorry. The driver is still making unconditional
> calls to i2c_smbus_read_byte_data() and i2c_smbus_write_byte_data(), so
> the underlying adapter _must_ support I2C_FUNC_SMBUS_READ_BYTE_DATA and
> I2C_FUNC_SMBUS_WRITE_BYTE_DATA (i.e. I2C_FUNC_SMBUS_BYTE_DATA), even if

 Well, as I understand the support for I2C_FUNC_SMBUS_I2C_BLOCK
(read/write, as appropriate) implies I2C_FUNC_SMBUS_BYTE_DATA as the
latter is a special case of the former, where the length of the transfer
equals one.  But I agree -- in the light of what you wrote previously a
bus adapter that supports say I2C_FUNC_SMBUS_READ_I2C_BLOCK is meant to
have I2C_FUNC_SMBUS_READ_BYTE set as well, so no need to check for it
here.

 If we agree on this one, I will retest and submit the whole batch again,
updated as needed.

  Maciej

patch-2.6.26-rc1-20080505-m41t80-smbus-16
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-11 00:16:36.000000000 +0000
@@ -6,6 +6,7 @@
  * Based on m41t00.c by Mark A. Greer <mgreer@mvista.com>
  *
  * 2006 (c) mycable GmbH
+ * Copyright (c) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -36,6 +37,8 @@
 #define M41T80_REG_DAY	5
 #define M41T80_REG_MON	6
 #define M41T80_REG_YEAR	7
+#define M41T80_REG_CONTROL	8
+#define M41T80_REG_WATCHDOG	9
 #define M41T80_REG_ALARM_MON	0xa
 #define M41T80_REG_ALARM_DAY	0xb
 #define M41T80_REG_ALARM_HOUR	0xc
@@ -58,7 +61,7 @@
 #define M41T80_FEATURE_HT	(1 << 0)
 #define M41T80_FEATURE_BL	(1 << 1)
 
-#define DRV_VERSION "0.05"
+#define DRV_VERSION "0.06"
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t80", 0 },
@@ -78,31 +81,83 @@ struct m41t80_data {
 	struct rtc_device *rtc;
 };
 
-static int m41t80_get_datetime(struct i2c_client *client,
-			       struct rtc_time *tm)
+
+static int m41t80_write_block_data(struct i2c_client *client,
+				   u8 reg, u8 num, u8 *buf)
 {
-	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
+	int i, rc;
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
-		dev_err(&client->dev, "read error\n");
-		return -EIO;
+	if (i2c_check_functionality(client->adapter,
+				    I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
+		i = i2c_smbus_write_i2c_block_data(client, reg, num, buf);
+	} else {
+		for (i = 0; i < num; i++) {
+			rc = i2c_smbus_write_byte_data(client, reg + i,
+						       buf[i]);
+			if (rc < 0) {
+				i = rc;
+				goto out;
+			}
+		}
 	}
+out:
+	return i;
+}
+
+static int m41t80_read_block_data(struct i2c_client *client,
+				  u8 reg, u8 num, u8 *buf)
+{
+	int i, rc;
+
+	if (i2c_check_functionality(client->adapter,
+				    I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
+		i = i2c_smbus_read_i2c_block_data(client, reg, num, buf);
+	} else {
+		for (i = 0; i < num; i++) {
+			rc = i2c_smbus_read_byte_data(client, reg + i);
+			if (rc < 0) {
+				i = rc;
+				goto out;
+			}
+			buf[i] = rc;
+		}
+	}
+out:
+	return i;
+}
+
+static int m41t80_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+	u8 buf[M41T80_DATETIME_REG_SIZE];
+	int loops = 2;
+	int sec0, sec1;
+
+	/*
+	 * Time registers are latched by this chip if an I2C block
+	 * transfer is used, but with SMBus-style byte accesses
+	 * this is not the case, so check seconds for a wraparound.
+	 */
+	do {
+		if (m41t80_read_block_data(client, M41T80_REG_SEC,
+					   M41T80_DATETIME_REG_SIZE -
+					   M41T80_REG_SEC,
+					   buf + M41T80_REG_SEC) < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+		sec0 = buf[M41T80_REG_SEC];
+
+		sec1 = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+		if (sec1 < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
 
-	tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f);
+		sec0 = BCD2BIN(sec0 & 0x7f);
+		sec1 = BCD2BIN(sec1 & 0x7f);
+	} while (sec1 < sec0 && --loops);
+
+	tm->tm_sec = sec1;
 	tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f);
 	tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f);
 	tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f);
@@ -117,39 +172,16 @@ static int m41t80_get_datetime(struct i2
 /* Sets the given date and time to the real time clock. */
 static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-	u8 wbuf[1 + M41T80_DATETIME_REG_SIZE];
-	u8 *buf = &wbuf[1];
-	u8 dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_DATETIME_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
+	u8 buf[M41T80_DATETIME_REG_SIZE];
 
 	/* Read current reg values into buf[1..7] */
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_read_block_data(client, M41T80_REG_SEC,
+				   M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+				   buf + M41T80_REG_SEC) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
 
-	wbuf[0] = 0; /* offset into rtc's regs */
 	/* Merge time-data and register flags into buf[0..7] */
 	buf[M41T80_REG_SSEC] = 0;
 	buf[M41T80_REG_SEC] =
@@ -167,7 +199,8 @@ static int m41t80_set_datetime(struct i2
 	/* assume 20YY not 19YY */
 	buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_write_block_data(client, M41T80_REG_SSEC,
+				    M41T80_DATETIME_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -241,34 +274,11 @@ err:
 static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 wbuf[1 + M41T80_ALARM_REG_SIZE];
-	u8 *buf = &wbuf[1];
+	u8 buf[M41T80_ALARM_REG_SIZE];
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE,
-			.buf	= buf,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_ALARM_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
 
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_read_block_data(client, M41T80_REG_ALARM_MON,
+				   M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -278,7 +288,6 @@ static int m41t80_rtc_set_alarm(struct d
 	reg[M41T80_REG_ALARM_MIN] = 0;
 	reg[M41T80_REG_ALARM_SEC] = 0;
 
-	wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */
 	reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ?
 		BIN2BCD(t->time.tm_sec) : 0x80;
 	reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ?
@@ -292,7 +301,8 @@ static int m41t80_rtc_set_alarm(struct d
 	else
 		reg[M41T80_REG_ALARM_DAY] |= 0x40;
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_write_block_data(client, M41T80_REG_ALARM_MON,
+				    M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -312,24 +322,10 @@ static int m41t80_rtc_read_alarm(struct 
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	u8 buf[M41T80_ALARM_REG_SIZE + 1]; /* all alarm regs and flags */
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE + 1,
-			.buf	= buf,
-		},
-	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
+	if (m41t80_read_block_data(client, M41T80_REG_ALARM_MON,
+				   M41T80_ALARM_REG_SIZE + 1, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -488,26 +484,16 @@ static int boot_flag;
  */
 static void wdt_ping(void)
 {
-	unsigned char i2c_data[2];
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-	i2c_data[0] = 0x09;		/* watchdog register */
+	u8 wdt = 0x80;				/* WDS = 1 (0x80)  */
 
 	if (wdt_margin > 31)
-		i2c_data[1] = (wdt_margin & 0xFC) | 0x83; /* resolution = 4s */
+		/* mulitplier = WD_TIMO / 4, resolution = 4s (0x3)  */
+		wdt |= (wdt_margin & 0xfc) | 0x3;
 	else
-		/*
-		 * WDS = 1 (0x80), mulitplier = WD_TIMO, resolution = 1s (0x02)
-		 */
-		i2c_data[1] = wdt_margin<<2 | 0x82;
+		/* mulitplier = WD_TIMO, resolution = 1s (0x2)  */
+		wdt |= wdt_margin << 2 | 0x2;
 
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, wdt);
 }
 
 /**
@@ -517,36 +503,8 @@ static void wdt_ping(void)
  */
 static void wdt_disable(void)
 {
-	unsigned char i2c_data[2], i2c_buf[0x10];
-	struct i2c_msg msgs0[2] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= i2c_data,
-		},
-		{
-			.addr	= save_client->addr,
-			.flags	= I2C_M_RD,
-			.len	= 1,
-			.buf	= i2c_buf,
-		},
-	};
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-
-	i2c_data[0] = 0x09;
-	i2c_transfer(save_client->adapter, msgs0, 2);
-
-	i2c_data[0] = 0x09;
-	i2c_data[1] = 0x00;
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_read_byte_data(save_client, M41T80_REG_WATCHDOG);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, 0);
 }
 
 /**
@@ -736,13 +694,21 @@ static int m41t80_probe(struct i2c_clien
 	struct rtc_device *rtc = NULL;
 	struct rtc_time tm;
 	struct m41t80_data *clientdata = NULL;
+	int reg;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
-				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
+	if (!i2c_check_functionality(client->adapter,
+				     I2C_FUNC_SMBUS_BYTE_DATA)) {
 		rc = -ENODEV;
 		goto exit;
 	}
 
+	/* Trivially check it's there; keep the result for the HT check. */
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
+	if (reg < 0) {
+		rc = -ENXIO;
+		goto exit;
+	}
+
 	dev_info(&client->dev,
 		 "chip found, driver version " DRV_VERSION "\n");
 
@@ -765,11 +731,7 @@ static int m41t80_probe(struct i2c_clien
 	i2c_set_clientdata(client, clientdata);
 
 	/* Make sure HT (Halt Update) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
-	if (rc < 0)
-		goto ht_err;
-
-	if (rc & M41T80_ALHOUR_HT) {
+	if (reg & M41T80_ALHOUR_HT) {
 		if (clientdata->features & M41T80_FEATURE_HT) {
 			m41t80_get_datetime(client, &tm);
 			dev_info(&client->dev, "HT bit was set!\n");
@@ -782,18 +744,18 @@ static int m41t80_probe(struct i2c_clien
 		}
 		if (i2c_smbus_write_byte_data(client,
 					      M41T80_REG_ALARM_HOUR,
-					      rc & ~M41T80_ALHOUR_HT) < 0)
+					      reg & ~M41T80_ALHOUR_HT) < 0)
 			goto ht_err;
 	}
 
 	/* Make sure ST (stop) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
-	if (rc < 0)
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+	if (reg < 0)
 		goto st_err;
 
-	if (rc & M41T80_SEC_ST) {
+	if (reg & M41T80_SEC_ST) {
 		if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
-					      rc & ~M41T80_SEC_ST) < 0)
+					      reg & ~M41T80_SEC_ST) < 0)
 			goto st_err;
 	}
 

From hch@lst.de Sun May 11 07:31:57 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 May 2008 07:31:59 +0100 (BST)
Received: from verein.lst.de ([213.95.11.210]:44713 "EHLO verein.lst.de")
	by ftp.linux-mips.org with ESMTP id S20023592AbYEKGb5 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 11 May 2008 07:31:57 +0100
Received: from verein.lst.de (localhost [127.0.0.1])
	by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id m4B6VXF3013586
	(version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO);
	Sun, 11 May 2008 08:31:33 +0200
Received: (from hch@localhost)
	by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id m4B6VThI013582;
	Sun, 11 May 2008 08:31:29 +0200
Date:	Sun, 11 May 2008 08:31:29 +0200
From:	Christoph Hellwig <hch@lst.de>
To:	Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
Cc:	Christoph Hellwig <hch@lst.de>, linux-mips@linux-mips.org
Subject: Re: undefined reference to `copy_siginfo_from_user32'
Message-ID: <20080511063129.GA13451@lst.de>
References: <20080428212327.47c703b6.giuseppe@eppesuigoccas.homedns.org> <20080429090039.GA16616@lst.de> <1209665512.5605.0.camel@casa>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1209665512.5605.0.camel@casa>
User-Agent: Mutt/1.3.28i
X-Scanned-By: MIMEDefang 2.39
Return-Path: <hch@lst.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19196
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: hch@lst.de
Precedence: bulk
X-list: linux-mips
Content-Length: 314
Lines: 8

On Thu, May 01, 2008 at 08:11:52PM +0200, Giuseppe Sacco wrote:
> I cannot apply this patch to the latest kernel from git. Could you
> provide a new one?

It still applies against the latest Linus tree, I don't currently
have a mips tree at hand.  But Ralf promised to look into the
compat_sys_ptrace conversion.


From khali@linux-fr.org Sun May 11 08:41:05 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 May 2008 08:41:08 +0100 (BST)
Received: from zone0.gcu-squad.org ([212.85.147.21]:58205 "EHLO
	services.gcu-squad.org") by ftp.linux-mips.org with ESMTP
	id S20023240AbYEKHlF (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 11 May 2008 08:41:05 +0100
Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare)
	by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Jv77K-00010A-7f
	(TLSv1:AES256-SHA:256)
	(envelope-from <khali@linux-fr.org>)
	; Sun, 11 May 2008 10:41:14 +0200
Date:	Sun, 11 May 2008 09:40:48 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	"Maciej W. Rozycki" <macro@linux-mips.org>
Cc:	David Brownell <david-b@pacbell.net>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexander Bigga <ab@mycable.de>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, i2c@lm-sensors.org,
	rtc-linux@googlegroups.com, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80
Message-ID: <20080511094048.292c885d@hyperion.delvare>
In-Reply-To: <Pine.LNX.4.55.0805110045010.18978@cliff.in.clinika.pl>
References: <200805070120.03821.david-b@pacbell.net>
	<Pine.LNX.4.55.0805072226180.25644@cliff.in.clinika.pl>
	<20080508093456.340a42b0@hyperion.delvare>
	<Pine.LNX.4.55.0805091917370.10552@cliff.in.clinika.pl>
	<20080509222754.03de1c54@hyperion.delvare>
	<Pine.LNX.4.55.0805100116290.10552@cliff.in.clinika.pl>
	<20080510103544.701c7b3f@hyperion.delvare>
	<Pine.LNX.4.55.0805110045010.18978@cliff.in.clinika.pl>
X-Mailer: Claws Mail 3.4.0 (GTK+ 2.10.6; x86_64-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19197
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: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips
Content-Length: 1683
Lines: 37

Hi Maciej,

On Sun, 11 May 2008 02:59:34 +0100 (BST), Maciej W. Rozycki wrote:
> > Still not correct, sorry. The driver is still making unconditional
> > calls to i2c_smbus_read_byte_data() and i2c_smbus_write_byte_data(), so
> > the underlying adapter _must_ support I2C_FUNC_SMBUS_READ_BYTE_DATA and
> > I2C_FUNC_SMBUS_WRITE_BYTE_DATA (i.e. I2C_FUNC_SMBUS_BYTE_DATA), even if
> 
>  Well, as I understand the support for I2C_FUNC_SMBUS_I2C_BLOCK
> (read/write, as appropriate) implies I2C_FUNC_SMBUS_BYTE_DATA as the
> latter is a special case of the former, where the length of the transfer
> equals one.

In theory you are right, yes. But as I wrote before, functionality are
expressed in a boolean way, so adapters can't express their limitations
if there are any. Think of an adapter which could only transfer blocks
of even size, it would most certainly declare itself
I2C_FUNC_SMBUS_I2C_BLOCK capable (even though it can't do all of it)
but wouldn't declare I2C_FUNC_SMBUS_BYTE_DATA as it can't do it. This
is just an example of course, in practice I just can't remember of any
I2C or SMBus adapter not implementing I2C_FUNC_SMBUS_BYTE_DATA.

The bottom line is that you should never assume that support for a
given transaction type implies support for another transaction type.

>              But I agree -- in the light of what you wrote previously a
> bus adapter that supports say I2C_FUNC_SMBUS_READ_I2C_BLOCK is meant to
> have I2C_FUNC_SMBUS_READ_BYTE set as well, so no need to check for it
> here.
> 
>  If we agree on this one, I will retest and submit the whole batch again,
> updated as needed.

Yes, you code looks correct to me now, i2c-wise.

-- 
Jean Delvare

From sshtylyov@dev.rtsoft.ru Sun May 11 11:28:34 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 May 2008 11:28:37 +0100 (BST)
Received: from smtp02.mtu.ru ([62.5.255.49]:30962 "EHLO smtp02.mtu.ru")
	by ftp.linux-mips.org with ESMTP id S20026699AbYEKK2e (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 11 May 2008 11:28:34 +0100
Received: from smtp02.mtu.ru (localhost [127.0.0.1])
	by smtp02.mtu.ru (Postfix) with ESMTP id 51D474CD86;
	Sun, 11 May 2008 14:28:24 +0400 (MSD)
Received: from [127.0.0.1] (ppp83-237-119-243.pppoe.mtu-net.ru [83.237.119.243])
	(Authenticated sender: braindead@stream.ru)
	by smtp02.mtu.ru (Postfix) with ESMTP id 37B844CBAF;
	Sun, 11 May 2008 14:28:24 +0400 (MSD)
Message-ID: <4826CA3C.6090809@dev.rtsoft.ru>
Date:	Sun, 11 May 2008 14:28:12 +0400
From:	Sergei Shtylyov <sshtylyov@dev.rtsoft.ru>
User-Agent: Thunderbird 1.5.0.2 (Windows/20060308)
MIME-Version: 1.0
To:	ralf@linux-mips.org
CC:	linux-mips@linux-mips.org
Subject: Re: [MIPS] Alchemy: register mmc platform device for db1200/pb1200
 boards
References: <S20024685AbYEKJEz/20080511090455Z+641267@ftp.linux-mips.org>
In-Reply-To: <S20024685AbYEKJEz/20080511090455Z+641267@ftp.linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-DCC-STREAM-Metrics: smtp02.mtu.ru 10002; Body=0 Fuz1=0 Fuz2=0
Return-Path: <sshtylyov@dev.rtsoft.ru>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19198
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: sshtylyov@dev.rtsoft.ru
Precedence: bulk
X-list: linux-mips
Content-Length: 786
Lines: 22

Hello.

linux-mips@linux-mips.org wrote:
> Author: Manuel Lauss <mlau@msc-ge.com> Wed May 7 14:59:45 2008 +0200
> Comitter: Ralf Baechle <ralf@linux-mips.org> Sun May 11 09:26:01 2008 +0100
> Commit: f75a5c99879aa28a8f29fa08ed11395614f8311e
> Gitweb: http://www.linux-mips.org/g/linux/f75a5c99
> Branch: master
>
> Register the mmc platform device for db1200/pb1200 boards, with
> board-specific card detect/readonly facilities wrapped in platform data.
>
> Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
>   
   Gah, I had comments to this patch and expected Manuel to address 
them. Besides, the driver as it is now, is not quite prepared to handle 
two MMC controllers as two different platform devices.

WBR, Sergei



From ralf@linux-mips.org Sun May 11 17:08:52 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 May 2008 17:08:55 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:54250 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20027282AbYEKQIw (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 11 May 2008 17:08:52 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m4BG7XQm012144;
	Sun, 11 May 2008 17:07:33 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m4BG7WBC012137;
	Sun, 11 May 2008 17:07:32 +0100
Date:	Sun, 11 May 2008 17:07:32 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	David VomLehn <dvomlehn@cisco.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [RFC] [PATCH 1/1] [MIPS] Advanced Kernel Stack Backtrace
Message-ID: <20080511160732.GA10492@linux-mips.org>
References: <48224021.7050306@cisco.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <48224021.7050306@cisco.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19199
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2499
Lines: 53

On Wed, May 07, 2008 at 04:49:53PM -0700, David VomLehn wrote:

> This patch contains the kernel stack backtrace code we've been running for 
> about a year on our MIPS-based settop box. It is considerably larger than 
> the existing backtrace implementation and so is configurable in the Kernel 
> Hacking section.  It also requires that KALLSYMS be enabled. In return, I 
> think it offers some advantages over the existing backtrace code:
>
> o It will backtrace over nested interrupts and exceptions, allowing 
> detailed analysis of was going on when it was invoked.
> o It handles a number of corner cases involving instructions in branch 
> delay slots.
> o It is very careful to use __get_user when fetching stack data and 
> instructions, meaning that it will fail gracefully even in the presence of 
> stack corruption.
> o It identifies whether the $sp register or another register is being used 
> as the frame pointer. Assuming people are happy with this submission, there 
> is a small subsequent patch I'll submit that dumps the frame pointer value 
> as part of the backtrace.
> o It segregates the backtrace code into a subdirectory of arch/mips/kernel 
> rather than cluttering up traps.c or the kernel directory.
>
> The main reason I am submitting this as a request for comments rather than 
> as a normal patch is that, though I wrote it with 64-bit systems in mind, I 
> don't have access to a 64-bit system on which to test it. I am happy to 
> merge any 64-bit-specific changes. For 32-bit systems, I'll claim it's 
> ready to go.
>
> The other reason is that this is an RFC is that it is such a large, single 
> chunk of code that there are certainly lots of comments that people will 
> have. I'm not naive enough to think it's really ready without more review.
>
> [Note: for anyone who was at the MIPS backtrace session at the CELF 
> Conference, this is the code I was talking about.]

I wasn't even aware of the session.

> Signed-off-by: David VomLehn <dvomlehn@cisco.com>

> +#ifndef	numberof
> +#define	numberof(a)	(sizeof(a) / sizeof((a) [0]))
> +#endif

I really just glanced over the patch.  I think I like the promise of more
accurate backtraces because frequently one (1) backtrace is all information
which there ever will be available for debugging.

 o Use ARRAY_SIZE() from <linux/kernel.h> instead of numberof.
 o Please run the patch through scripts/checkpatch.pl and fix the resulting
   errors.
 o Your patch got linewrapped by your mail client.

  Ralf

From mano@roarinelk.homelinux.net Sun May 11 20:18:41 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 May 2008 20:18:43 +0100 (BST)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:29825 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP
	id S20029388AbYEKTSl (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 11 May 2008 20:18:41 +0100
Received: (qmail 21218 invoked from network); 11 May 2008 21:18:40 +0200
Received: from scarran.roarinelk.net (HELO ?192.168.0.242?) (192.168.0.242)
  by wormhole.roarinelk.net with SMTP; 11 May 2008 21:18:40 +0200
Message-ID: <4827468F.8030808@roarinelk.homelinux.net>
Date:	Sun, 11 May 2008 21:18:39 +0200
From:	Manuel Lauss <mano@roarinelk.homelinux.net>
Organization: Private
User-Agent: Thunderbird 2.0.0.14 (X11/20080510)
MIME-Version: 1.0
To:	Sergei Shtylyov <sshtylyov@dev.rtsoft.ru>
CC:	ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: [MIPS] Alchemy: register mmc platform device for db1200/pb1200
 boards
References: <S20024685AbYEKJEz/20080511090455Z+641267@ftp.linux-mips.org> <4826CA3C.6090809@dev.rtsoft.ru>
In-Reply-To: <4826CA3C.6090809@dev.rtsoft.ru>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <mano@roarinelk.homelinux.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19200
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: mano@roarinelk.homelinux.net
Precedence: bulk
X-list: linux-mips
Content-Length: 265
Lines: 10

Sergei Shtylyov wrote:

> Besides, the driver as it is now, is not quite prepared to handle two 
> MMC controllers as two different platform devices.

Care to elaborate? If it's about the shared SD IRQ, well, that's why I 
asked for PB1200 testers.

	Manuel Lauss


From zzh.hust@gmail.com Mon May 12 03:19:04 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 03:19:07 +0100 (BST)
Received: from ti-out-0910.google.com ([209.85.142.189]:22355 "EHLO
	ti-out-0910.google.com") by ftp.linux-mips.org with ESMTP
	id S20030229AbYELCTE (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 03:19:04 +0100
Received: by ti-out-0910.google.com with SMTP id i7so730560tid.20
        for <linux-mips@linux-mips.org>; Sun, 11 May 2008 19:18:27 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
        bh=7jQlHvHMFGW91el3y6cFu4sVsXexSrXt5C4jqAgQU+E=;
        b=KsTrIS4LEzhHrbszitWgeBJmPSEwTErDhPLdy2zsZINoYrl+wUfTHJgGOvliuh7Q8TBLclkze1gAfKa0+NyTOvom3NyaDA5VhapWIUj8Dg5IQjB+HPrrDdMS795ttEtDFpmRvmdkwQ0xyu98UZCbOIYKG+qSWJGhQgiH8YkUn4k=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
        b=UYmElo1XX9MN4dwLKiQQW5LG9/K5IDLEEGvL6L7iWwNefu46Dy/htsjP3wn/r1lUWfmWjf2KKRoBe8UnuYztiWX/SIjCOw0+VDnDFVbqvbHnMsTrcNGTpwDQUzm/pSfLU7UpwWGJC7fIY4Ddd2h/1EWSHhpVTXaHqYZ5W2qU6qM=
Received: by 10.110.57.6 with SMTP id f6mr722355tia.35.1210558707305;
        Sun, 11 May 2008 19:18:27 -0700 (PDT)
Received: by 10.110.42.3 with HTTP; Sun, 11 May 2008 19:18:27 -0700 (PDT)
Message-ID: <50c9a2250805111918r16913139obfc2982220636b3@mail.gmail.com>
Date:	Mon, 12 May 2008 10:18:27 +0800
From:	zhuzhenhua <zzh.hust@gmail.com>
To:	"Ralf Baechle" <ralf@linux-mips.org>
Subject: Re: is remap_pfn_range should align to 2(n) * (page size) ?
Cc:	linux-mips <linux-mips@linux-mips.org>
In-Reply-To: <20080509095605.GB14450@linux-mips.org>
MIME-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_470_27076401.1210558707284"
References: <50c9a2250805082354x1edc1ecar89dcc3378b3bbe75@mail.gmail.com>
	 <20080509095605.GB14450@linux-mips.org>
Return-Path: <zzh.hust@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19201
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: zzh.hust@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 3264
Lines: 71

------=_Part_470_27076401.1210558707284
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 5/9/08, Ralf Baechle <ralf@linux-mips.org> wrote:
>
> On Fri, May 09, 2008 at 02:54:29PM +0800, zhuzhenhua wrote:
>
> >            i have a sensor driver want to malloc 2.xM SDRAM to capture
> > data(using DMA),  so i used  remap_pfn_range to malloc 3M.
> > But in /proc/meminfo, it showes free memory reduce 4M. i also check the
> > /proc/buddyinfo, it seemes too.
> > (i am looking inside kernel code, but not get clear at now).
> >
> >  is remap_pfn_range should align to  2(n) * (page size) ?
>
>
> This has nothing to do with remap_pfn_range but with the power of two
> sized buckets used by the global free page pool.  Any allocation with
> get_free_pages will be rounded up to the next power of two.  If that's a
> real concern for you you could allocate a 4MB page then split the page
> into a 2MB and two 1MB pages and free the 1MB page again.
>
>
>   Ralf


thanks for your reply , i see in get_frree_pages and free_pages there is a
get_order(size).
but i don't understand  " allocate a 4MB page then split the page
into a 2MB and two 1MB pages and free the 1MB page again."
is there any function to split it?

thanks for any hints

Best Regards


zzh

------=_Part_470_27076401.1210558707284
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<br><br><div><span class="gmail_quote">On 5/9/08, <b class="gmail_sendername">Ralf Baechle</b> &lt;<a href="mailto:ralf@linux-mips.org">ralf@linux-mips.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Fri, May 09, 2008 at 02:54:29PM +0800, zhuzhenhua wrote:<br> <br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i
have a sensor driver want to malloc 2.xM SDRAM to capture<br> &gt; data(using DMA),&nbsp;&nbsp;so i used&nbsp;&nbsp;remap_pfn_range to malloc 3M.<br> &gt; But in /proc/meminfo, it showes free memory reduce 4M. i also check the<br> &gt; /proc/buddyinfo, it seemes too.<br>
 &gt; (i am looking inside kernel code, but not get clear at now).<br> &gt;<br> &gt;&nbsp;&nbsp;is remap_pfn_range should align to&nbsp;&nbsp;2(n) * (page size) ?<br> <br> <br>This has nothing to do with remap_pfn_range but with the power of two<br>
 sized buckets used by the global free page pool.&nbsp;&nbsp;Any allocation with<br> get_free_pages will be rounded up to the next power of two.&nbsp;&nbsp;If that&#39;s a<br> real concern for you you could allocate a 4MB page then split the page<br>
 into a 2MB and two 1MB pages and free the 1MB page again.<br> <br><br>&nbsp;&nbsp;Ralf</blockquote><div><br>
thanks for your reply , i see in get_frree_pages and free_pages there is a get_order(size).<br>
but i don&#39;t understand&nbsp; &quot; allocate a 4MB page then split the page<br>
 into a 2MB and two 1MB pages and free the 1MB page again.&quot;<br>
is there any function to split it? <br>
<br>
thanks for any hints<br>
<br>
Best Regards<br>
<br>
<br>
zzh<br>
<br>
<br>
<br>
&nbsp;</div><br><div><br>
&nbsp;</div><br></div><br>

------=_Part_470_27076401.1210558707284--

From anemo@mba.ocn.ne.jp Mon May 12 03:46:09 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 03:46:11 +0100 (BST)
Received: from topsns2.toshiba-tops.co.jp ([202.230.225.126]:50100 "EHLO
	topsns2.toshiba-tops.co.jp") by ftp.linux-mips.org with ESMTP
	id S20030198AbYELCqJ (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 03:46:09 +0100
Received: from topsms.toshiba-tops.co.jp by topsns2.toshiba-tops.co.jp
          via smtpd (for ftp.linux-mips.org [213.58.128.207]) with ESMTP; Mon, 12 May 2008 11:46:06 +0900
Received: from localhost (localhost.localdomain [127.0.0.1])
	by localhost.toshiba-tops.co.jp (Postfix) with SMTP id 7F6A91EF48;
	Mon, 12 May 2008 11:46:01 +0900 (JST)
Received: from srd2sd.toshiba-tops.co.jp (srd2sd.toshiba-tops.co.jp [172.17.28.2])
	by topsms.toshiba-tops.co.jp (Postfix) with ESMTP id 7FDC11EF48;
	Mon, 12 May 2008 11:45:53 +0900 (JST)
Received: from localhost (fragile [172.17.28.65])
	by srd2sd.toshiba-tops.co.jp (8.12.10/8.12.10) with ESMTP id m4C2jiAF099220;
	Mon, 12 May 2008 11:45:47 +0900 (JST)
	(envelope-from anemo@mba.ocn.ne.jp)
Date:	Mon, 12 May 2008 11:45:44 +0900 (JST)
Message-Id: <20080512.114544.41629483.nemoto@toshiba-tops.co.jp>
To:	macro@linux-mips.org
Cc:	khali@linux-fr.org, david-b@pacbell.net, a.zummo@towertech.it,
	ab@mycable.de, anemo@mba.ocn.ne.jp, i2c@lm-sensors.org,
	rtc-linux@googlegroups.com, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 4/4] RTC: SMBus support for the M41T80
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <Pine.LNX.4.55.0805110045010.18978@cliff.in.clinika.pl>
References: <Pine.LNX.4.55.0805100116290.10552@cliff.in.clinika.pl>
	<20080510103544.701c7b3f@hyperion.delvare>
	<Pine.LNX.4.55.0805110045010.18978@cliff.in.clinika.pl>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19202
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
Content-Length: 1052
Lines: 43

On Sun, 11 May 2008 02:59:34 +0100 (BST), "Maciej W. Rozycki" <macro@linux-mips.org> wrote:
>  If we agree on this one, I will retest and submit the whole batch again,
> updated as needed.

Works OK for me (m41t80 + i2c-gpio).

Tested-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

One minor style comment.

> +	if (i2c_check_functionality(client->adapter,
> +				    I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
> +		i = i2c_smbus_write_i2c_block_data(client, reg, num, buf);
> +	} else {
> +		for (i = 0; i < num; i++) {
> +			rc = i2c_smbus_write_byte_data(client, reg + i,
> +						       buf[i]);
> +			if (rc < 0) {
> +				i = rc;
> +				goto out;
> +			}
> +		}
>  	}
> +out:
> +	return i;

This part can be a bit shorter.

	if (i2c_check_functionality(client->adapter,
				    I2C_FUNC_SMBUS_WRITE_I2C_BLOCK))
		return i2c_smbus_write_i2c_block_data(client, reg, num, buf);
	for (i = 0; i < num; i++) {
		rc = i2c_smbus_write_byte_data(client, reg + i, buf[i]);
		if (rc < 0)
			return rc;
	}
	return i;

Saves 6 lines.  Not a big issue.

---
Atsushi Nemoto


From abhiruchi.g@vaultinfo.com Mon May 12 06:07:35 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 06:07:38 +0100 (BST)
Received: from smtp207.iad.emailsrvr.com ([207.97.245.207]:3508 "EHLO
	smtp207.iad.emailsrvr.com") by ftp.linux-mips.org with ESMTP
	id S20030601AbYELFHf convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 06:07:35 +0100
Received: from relay10.relay.iad.mlsrvr.com (localhost [127.0.0.1])
	by relay10.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id CC3D51B4082;
	Mon, 12 May 2008 01:07:28 -0400 (EDT)
Received: from vaultinfo.com (webmail19.webmail.iad.mlsrvr.com [192.168.1.17])
	by relay10.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id C54F41B4079;
	Mon, 12 May 2008 01:07:28 -0400 (EDT)
Received: by webmail.mailsin.net
    (Authenticated sender: abhiruchi.g@vaultinfo.com, from: abhiruchi.g@vaultinfo.com) 
    with HTTP; Mon, 12 May 2008 01:07:28 -0400 (EDT)
Date:	Mon, 12 May 2008 01:07:28 -0400 (EDT)
Subject: =?UTF-8?Q?WARNING:=20arch/mips/au1000/common/built-in.o(.text+0x15c0):?=
 =?UTF-8?Q?=20Section=20mismatch:=20reference=20to=20.init.data:=20(betwee?=
 =?UTF-8?Q?n=20'au1xxx=5Fplatform=5Finit'=20and=20'=5F=5Ffixup=5Fbigphys?=
 =?UTF-8?Q?=5Faddr')?=
From:	abhiruchi.g@vaultinfo.com
To:	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	kernel-testers@vger.kernel.org
Reply-To: abhiruchi.g@vaultinfo.com
MIME-Version: 1.0
Content-Type: text/plain;charset=UTF-8
Content-Transfer-Encoding: 8BIT
Importance: Normal
X-Priority: 3 (Normal)
X-Type:	1
Message-ID: <54350.192.168.1.71.1210568848.webmail@192.168.1.71>
X-Mailer: webmail6.6.1
Return-Path: <abhiruchi.g@vaultinfo.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19203
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: abhiruchi.g@vaultinfo.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1308
Lines: 32

Hi all,
  I am trying to configure the kernel for mips(DB1200 bosrd).I am getting this warning.
how to remove this warning?

WARNING: arch/mips/au1000/common/built-in.o(.text+0x15c0): Section mismatch: reference to .init.data: (between 'au1xxx_platform_init' and '__fixup_bigphys_addr')
WARNING: arch/mips/au1000/common/built-in.o(.text+0x15c4): Section mismatch: reference to .init.data: (between 'au1xxx_platform_init' and '__fixup_bigphys_addr


My kernel hangs after this:
===========================
Waiting 10sec before mounting root device...
scsi 0:0:0:0: Direct-Access     Ut163    USB2FlashStorage 0.00 PQ: 0 ANSI: 2
sd 0:0:0:0: [sda] 983808 512-byte hardware sectors (504 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] 983808 512-byte hardware sectors (504 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
 sda:<7>usb-storage: queuecommand called
 sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk
sd 0:0:0:0: Attached scsi generic sg0 type 0
VFS: Mounted root (ext2 filesystem) readonly.
mount_block_root: name=/dev/root fs=ext2 flags=32769
Freeing unused kernel memory: 164k freed
Warning: unable to open an initial console.
Algorithmics/MIPS FPU Emulator v1.5


Thanks,
Abhi


From abhiruchi.g@vaultinfo.com Mon May 12 06:54:10 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 06:54:12 +0100 (BST)
Received: from smtp167.iad.emailsrvr.com ([207.97.245.167]:43660 "EHLO
	smtp167.iad.emailsrvr.com") by ftp.linux-mips.org with ESMTP
	id S20030721AbYELFyK convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 06:54:10 +0100
Received: from relay6.relay.iad.emailsrvr.com (localhost [127.0.0.1])
	by relay6.relay.iad.emailsrvr.com (SMTP Server) with ESMTP id 14F3B75243C;
	Mon, 12 May 2008 01:54:03 -0400 (EDT)
Received: from vaultinfo.com (webmail20.webmail.iad.mlsrvr.com [192.168.1.41])
	by relay6.relay.iad.emailsrvr.com (SMTP Server) with ESMTP id 02DAA73A2B2;
	Mon, 12 May 2008 01:54:03 -0400 (EDT)
Received: by webmail.mailsin.net
    (Authenticated sender: abhiruchi.g@vaultinfo.com, from: abhiruchi.g@vaultinfo.com) 
    with HTTP; Mon, 12 May 2008 01:54:02 -0400 (EDT)
Date:	Mon, 12 May 2008 01:54:02 -0400 (EDT)
Subject: =?UTF-8?Q?mips:(Alchemy=20au1200)=20how=20to=20use=20kdb=20to=20debug=20?=
 =?UTF-8?Q?the=20kernel=3Fis=20kdb=20inbuilt=20or=20kdb=20patch=20is=20req?=
 =?UTF-8?Q?uired=3F?=
From:	abhiruchi.g@vaultinfo.com
To:	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	kernel-testers@vger.kernel.org
Reply-To: abhiruchi.g@vaultinfo.com
MIME-Version: 1.0
Content-Type: text/plain;charset=UTF-8
Content-Transfer-Encoding: 8BIT
Importance: Normal
X-Priority: 3 (Normal)
X-Type:	1
Message-ID: <54114.192.168.1.71.1210571642.webmail@192.168.1.71>
X-Mailer: webmail6.6.1
Return-Path: <abhiruchi.g@vaultinfo.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19204
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: abhiruchi.g@vaultinfo.com
Precedence: bulk
X-list: linux-mips
Content-Length: 105
Lines: 5

how to use kdb to debug the kernel.
I am using linux-2.6.22.

Is kdb inbuilt or kdb patch is required? 


From sshtylyov@ru.mvista.com Mon May 12 09:39:24 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 09:39:27 +0100 (BST)
Received: from smtp04.mtu.ru ([62.5.255.51]:31231 "EHLO smtp04.mtu.ru")
	by ftp.linux-mips.org with ESMTP id S20030494AbYELIjY (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 09:39:24 +0100
Received: from smtp04.mtu.ru (localhost [127.0.0.1])
	by smtp04.mtu.ru (Postfix) with ESMTP id B389D839011;
	Mon, 12 May 2008 12:39:17 +0400 (MSD)
Received: from [127.0.0.1] (ppp83-237-118-229.pppoe.mtu-net.ru [83.237.118.229])
	(Authenticated sender: braindead@stream.ru)
	by smtp04.mtu.ru (Postfix) with ESMTP id 8DF38838D8F;
	Mon, 12 May 2008 12:39:17 +0400 (MSD)
Message-ID: <48280221.9010206@ru.mvista.com>
Date:	Mon, 12 May 2008 12:38:57 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
User-Agent: Thunderbird 1.5.0.2 (Windows/20060308)
MIME-Version: 1.0
To:	Manuel Lauss <mano@roarinelk.homelinux.net>
CC:	Sergei Shtylyov <sshtylyov@dev.rtsoft.ru>, ralf@linux-mips.org,
	linux-mips@linux-mips.org
Subject: Re: [MIPS] Alchemy: register mmc platform device for db1200/pb1200
 boards
References: <S20024685AbYEKJEz/20080511090455Z+641267@ftp.linux-mips.org> <4826CA3C.6090809@dev.rtsoft.ru> <4827468F.8030808@roarinelk.homelinux.net>
In-Reply-To: <4827468F.8030808@roarinelk.homelinux.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-DCC-STREAM-Metrics: smtp04.mtu.ru 10002; Body=0 Fuz1=0 Fuz2=0
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19205
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 385
Lines: 15

Hello.

Manuel Lauss wrote:
>> Besides, the driver as it is now, is not quite prepared to handle two 
>> MMC controllers as two different platform devices.

> Care to elaborate? If it's about the shared SD IRQ, well, that's why I 
> asked for PB1200 testers.
    I meant the driver *before* your changes -- they're not yet merged 
if I don't mistake.

>     Manuel Lauss
WBR, Sergei



From ralf@linux-mips.org Mon May 12 12:22:37 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 12:22:39 +0100 (BST)
Received: from vigor.karmaclothing.net ([217.169.26.28]:43136 "EHLO
	dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP
	id S20030582AbYELLWh (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 12:22:37 +0100
Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1])
	by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m4CBMXPD010382;
	Mon, 12 May 2008 12:22:33 +0100
Received: (from ralf@localhost)
	by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m4CBMXFH010381;
	Mon, 12 May 2008 12:22:33 +0100
Date:	Mon, 12 May 2008 12:22:33 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	zhuzhenhua <zzh.hust@gmail.com>
Cc:	linux-mips <linux-mips@linux-mips.org>
Subject: Re: is remap_pfn_range should align to 2(n) * (page size) ?
Message-ID: <20080512112233.GA8843@linux-mips.org>
References: <50c9a2250805082354x1edc1ecar89dcc3378b3bbe75@mail.gmail.com> <20080509095605.GB14450@linux-mips.org> <50c9a2250805111918r16913139obfc2982220636b3@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <50c9a2250805111918r16913139obfc2982220636b3@mail.gmail.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19206
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: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 880
Lines: 19

On Mon, May 12, 2008 at 10:18:27AM +0800, zhuzhenhua wrote:

> > This has nothing to do with remap_pfn_range but with the power of two
> > sized buckets used by the global free page pool.  Any allocation with
> > get_free_pages will be rounded up to the next power of two.  If that's a
> > real concern for you you could allocate a 4MB page then split the page
> > into a 2MB and two 1MB pages and free the 1MB page again.

> thanks for your reply , i see in get_frree_pages and free_pages there is a
> get_order(size).
> but i don't understand  " allocate a 4MB page then split the page
> into a 2MB and two 1MB pages and free the 1MB page again."
> is there any function to split it?

No, you'd have to code that yourself.  Take a look at split_page() which
splits an order n page into order 0 pages.  You'd want something similar
but splitting for some non-zero order.

  Ralf

From sshtylyov@ru.mvista.com Mon May 12 12:36:43 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 12:36:45 +0100 (BST)
Received: from smtp04.mtu.ru ([62.5.255.51]:19155 "EHLO smtp04.mtu.ru")
	by ftp.linux-mips.org with ESMTP id S20029990AbYELLgn (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 12:36:43 +0100
Received: from smtp04.mtu.ru (localhost [127.0.0.1])
	by smtp04.mtu.ru (Postfix) with ESMTP id 08CB883B73D;
	Mon, 12 May 2008 15:36:36 +0400 (MSD)
Received: from [127.0.0.1] (ppp83-237-118-229.pppoe.mtu-net.ru [83.237.118.229])
	(Authenticated sender: braindead@stream.ru)
	by smtp04.mtu.ru (Postfix) with ESMTP id D13E683B730;
	Mon, 12 May 2008 15:36:35 +0400 (MSD)
Message-ID: <48282BBE.4090409@ru.mvista.com>
Date:	Mon, 12 May 2008 15:36:30 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
User-Agent: Thunderbird 1.5.0.14 (Windows/20071210)
MIME-Version: 1.0
To:	Manuel Lauss <mano@roarinelk.homelinux.net>
CC:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/7] au1xmmc: remove db1x00 board-specific functions from
 driver
References: <20080508080040.GA24383@roarinelk.homelinux.net> <20080508080301.GD24383@roarinelk.homelinux.net>
In-Reply-To: <20080508080301.GD24383@roarinelk.homelinux.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-DCC-STREAM-Metrics: smtp04.mtu.ru 10001; Body=0 Fuz1=0 Fuz2=0
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19207
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 5636
Lines: 189

Hello.

Manuel Lauss wrote:
> From 47ecf116465ed850d2202880f7795fcee4826184 Mon Sep 17 00:00:00 2001
> From: Manuel Lauss <mlau@msc-ge.com>
> Date: Wed, 7 May 2008 14:57:01 +0200
> Subject: [PATCH] au1xmmc: remove db1x00 board-specific functions from driver
>
> Remove the DB1200 board-specific functions (card present, read-only
> methods) and instead add platform data which is passed to the driver.
> This allows for platforms to implement other carddetect schemes
> (e.g. dedicated irq) without having to pollute the driver code.
> The poll timer (used for pb1200) is kept for compatibility.
>
> With the board-specific stuff gone, the driver no longer needs to know
> how many physical controllers the silicon actually has; every device
> can be registered as needed, update the code to reflect that.
>
> Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
>   
[...]
> diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
> index cc5f7bc..8660f86 100644
> --- a/drivers/mmc/host/au1xmmc.c
> +++ b/drivers/mmc/host/au1xmmc.c
> @@ -49,7 +49,6 @@
>  #include <asm/mach-au1x00/au1100_mmc.h>
>  
>  #include <au1xxx.h>
> -#include "au1xmmc.h"
>   
   I think you should merge the header to the driver in a separate patch.
> @@ -174,8 +221,6 @@ static void au1xmmc_finish_request(struct au1xmmc_host *host)
>  
>  	host->status = HOST_S_IDLE;
>  
> -	bcsr->disk_leds |= (1 << 8);
> -
>   
   So, the LED support is gone with your patch? You should at least 
document this...
>  	mmc_request_done(host->mmc, mrq);
>  }
>  
> @@ -663,7 +708,9 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq)
>  	host->mrq = mrq;
>  	host->status = HOST_S_CMD;
>  
> -	bcsr->disk_leds &= ~(1 << 8);
> +	au_writel(0, HOST_STATUS(host));
> +	au_sync();
> +	FLUSH_FIFO(host);
>   
   Hm, not an obvious change...
>  
>  	if (mrq->data) {
>  		FLUSH_FIFO(host);
> @@ -749,118 +796,87 @@ static void au1xmmc_dma_callback(int irq, void *dev_id)
>  
>  static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
>  {
> -
> +	struct au1xmmc_host *host = dev_id;
>  	u32 status;
> -	int i, ret = 0;
>  
> -	disable_irq(AU1100_SD_IRQ);
> +	status = au_readl(HOST_STATUS(host));
>  
> -	for(i = 0; i < AU1XMMC_CONTROLLER_COUNT; i++) {
> -		struct au1xmmc_host * host = au1xmmc_hosts[i];
> -		u32 handled = 1;
> +	if (!(status & (1 << 15)))
>   
   Why not SD_STATUS_I?
> +		//IRQ_OFF(host, SD_CONFIG_TH|SD_CONFIG_RA|SD_CONFIG_RF);
>   
   No C99 // comments please -- checkpatch.pl would have given you error 
about them...
> +	} else if (status & 0x203FBC70) {
>   
   I think the mask should be changed to 0x203F3C70 since you're 
handling SD_STATUS_I but maybe I'm wrong...
> -static void au1xmmc_init_dma(struct au1xmmc_host *host)
> +static int au1xmmc_init_dma(struct au1xmmc_host *host)
>   
   I'd have called it au1xmmc_init_dbdma() instead since in Au1100 the 
controller works with its "old-style" DMA... though maybe the difference 
could be handled within this function via #ifdef...
> @@ -878,116 +896,201 @@ static const struct mmc_host_ops au1xmmc_ops = {
>  	.get_ro		= au1xmmc_card_readonly,
>  };
>  
> -static int __devinit au1xmmc_probe(struct platform_device *pdev)
> +static void au1xmmc_poll_event(unsigned long arg)
>  {
> +	struct au1xmmc_host *host = (struct au1xmmc_host *)arg;
>   
   Don't need new line here...
>  
> -	int i, ret = 0;
> +	int card = au1xmmc_card_inserted(host);
> +        int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0;
>   
   Remove extra space please. And what does this variable actually mean?
> +	host->iobase = (unsigned long)ioremap(r->start, 0xff);
>   
   You have the r->end specifying the resource end, why 0xff (well, 
actually 0x3c is enough)
> @@ -1004,21 +1107,32 @@ static struct platform_driver au1xmmc_driver = {
>  
>  static int __init au1xmmc_init(void)
>  {
> +	if (dma) {
> +		/* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
> +		 * of 8 bits.  And since devices are shared, we need to create
> +		 * our own to avoid freaking out other devices
>   
   Missing period at end of statement.
> +		 */
> +		if (!memid)
>   
   Hm, is there a chance that it won't be NULL?
> +			memid = au1xxx_ddma_add_device(&au1xmmc_mem_dbdev);
> +		if (!memid) {
> +			printk(KERN_ERR "au1xmmc: cannot add memory dma dev\n");
> +			return -ENODEV;
> +		}
> +	}
>  	return platform_driver_register(&au1xmmc_driver);
>  }
[...]
> diff --git a/include/asm-mips/mach-au1x00/au1100_mmc.h b/include/asm-mips/mach-au1x00/au1100_mmc.h
> index 9e0028f..6474fac 100644
> --- a/include/asm-mips/mach-au1x00/au1100_mmc.h
> +++ b/include/asm-mips/mach-au1x00/au1100_mmc.h
> @@ -38,15 +38,46 @@
>  #ifndef __ASM_AU1100_MMC_H
>  #define __ASM_AU1100_MMC_H
>  
>   
[...]
> +struct au1xmmc_platdata {
>   
   I'd suggest au1xmmc_platform_data.
> +	int(*cd_setup)(void *mmc_host, int on);
> +	int(*card_inserted)(void *mmc_host);
> +	int(*card_readonly)(void *mmc_host);
> +	void(*set_power)(void *mmc_host, int state);
> +};
> +
> +struct au1xmmc_host {
> +	struct mmc_host *mmc;
> +	struct mmc_request *mrq;
> +
> +	u32 id;
> +
> +	u32 flags;
> +	u32 iobase;
> +	u32 clock;
> +
> +	int status;
> +
> +	struct {
> +		int len;
> +		int dir;
> +		u32 tx_chan;
> +		u32 rx_chan;
> +	} dma;
> +
> +	struct {
> +		int index;
> +		int offset;
> +		int len;
> +	} pio;
> +
> +	struct timer_list timer;
> +	struct tasklet_struct finish_task;
> +	struct tasklet_struct data_task;
> +
> +	struct platform_device *pdev;
> +	struct au1xmmc_platdata *platdata;
> +	int irq;
> +};
   Hm, do you need the above structure to be visible from the platform code?

WBR, Sergei



From tsbogend@alpha.franken.de Mon May 12 12:55:48 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 12:55:50 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:11459 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20029947AbYELLzs (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 12:55:48 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JvWd7-000650-00; Mon, 12 May 2008 13:55:45 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 60F0EDE534; Mon, 12 May 2008 13:55:42 +0200 (CEST)
From:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Subject: [PATCH] Fix build_tlb_probe_entry for R4700
To:	linux-mips@linux-mips.org
cc:	ralf@linux-mips.org
Message-Id: <20080512115542.60F0EDE534@solo.franken.de>
Date:	Mon, 12 May 2008 13:55:42 +0200 (CEST)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19208
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 763
Lines: 24

Treat R4700 like R4600 in build_tlb_probe_entry. Without this fix
kernel will lock up.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---

 arch/mips/mm/tlbex.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 382738c..76da73a 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -224,8 +224,9 @@ static u32 final_handler[64] __cpuinitdata;
 static void __cpuinit __maybe_unused build_tlb_probe_entry(u32 **p)
 {
 	switch (current_cpu_type()) {
-	/* Found by experiment: R4600 v2.0 needs this, too.  */
+	/* Found by experiment: R4600 v2.0/R4700 needs this, too.  */
 	case CPU_R4600:
+	case CPU_R4700:
 	case CPU_R5000:
 	case CPU_R5000A:
 	case CPU_NEVADA:

From tsbogend@alpha.franken.de Mon May 12 12:59:48 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 12:59:50 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:20931 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20030518AbYELL7s (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 12:59:48 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JvWh1-0006uq-00; Mon, 12 May 2008 13:59:47 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id CC704DE534; Mon, 12 May 2008 13:58:55 +0200 (CEST)
From:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Subject: [PATCH] Better load address for SNI RM
To:	linux-mips@linux-mips.org
cc:	ralf@linux-mips.org
Message-Id: <20080512115855.CC704DE534@solo.franken.de>
Date:	Mon, 12 May 2008 13:58:55 +0200 (CEST)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19209
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 655
Lines: 22

Use better load address for kernel to avoid clashes with PROM/SASH

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---


 arch/mips/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 69648d0..3f3815a 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -565,7 +565,7 @@ load-$(CONFIG_BCM47XX)		:= 0xffffffff80001000
 #
 core-$(CONFIG_SNI_RM)		+= arch/mips/sni/
 cflags-$(CONFIG_SNI_RM)		+= -Iinclude/asm-mips/mach-rm
-load-$(CONFIG_SNI_RM)		+= 0xffffffff80600000
+load-$(CONFIG_SNI_RM)		+= 0xffffffff80030000
 all-$(CONFIG_SNI_RM)		:= vmlinux.ecoff
 
 #

From tsbogend@alpha.franken.de Mon May 12 13:59:32 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 13:59:34 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:9158 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20031017AbYELM7c (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 13:59:32 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JvXck-0002ba-01; Mon, 12 May 2008 14:59:26 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 0C641DE534; Mon, 12 May 2008 14:59:23 +0200 (CEST)
From:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Subject: [PATCH] Fix check for valid stack pointer during backtrace
To:	linux-mips@linux-mips.org
cc:	ralf@linux-mips.org
Message-Id: <20080512125923.0C641DE534@solo.franken.de>
Date:	Mon, 12 May 2008 14:59:23 +0200 (CEST)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19210
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 1374
Lines: 47

The newly added check for valid stack pointer address breaks at least for
64bit kernels.  Use __get_user() for accessing stack content to avoid crashes,
when doing the backtrace.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---

 arch/mips/kernel/traps.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index cb8b0e2..063d9bf 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -81,22 +81,24 @@ void (*board_bind_eic_interrupt)(int irq, int regset);
 
 static void show_raw_backtrace(unsigned long reg29)
 {
-	unsigned long *sp = (unsigned long *)(reg29 & ~3);
+	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
 	unsigned long addr;
 
 	printk("Call Trace:");
 #ifdef CONFIG_KALLSYMS
 	printk("\n");
 #endif
-#define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
-	if (IS_KVA01(sp)) {
-		while (!kstack_end(sp)) {
-			addr = *sp++;
-			if (__kernel_text_address(addr))
-				print_ip_sym(addr);
+	while (!kstack_end(sp)) {
+		unsigned long __user *p =
+			(unsigned long __user *)(unsigned long)sp++;
+		if (__get_user(addr, p)) {
+			printk(" (Bad stack address)");
+			break;
 		}
-		printk("\n");
+		if (__kernel_text_address(addr))
+			print_ip_sym(addr);
 	}
+	printk("\n");
 }
 
 #ifdef CONFIG_KALLSYMS

From tbm@cyrius.com Mon May 12 14:06:28 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 14:06:31 +0100 (BST)
Received: from sorrow.cyrius.com ([65.19.161.204]:13583 "EHLO
	sorrow.cyrius.com") by ftp.linux-mips.org with ESMTP
	id S20031126AbYELNG2 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 14:06:28 +0100
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id D4856D8E3; Mon, 12 May 2008 13:06:25 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id E0151372609; Mon, 12 May 2008 15:06:04 +0200 (CEST)
Date:	Mon, 12 May 2008 15:06:04 +0200
From:	Martin Michlmayr <tbm@cyrius.com>
To:	linux-mips@linux-mips.org
Cc:	linux-ext4@vger.kernel.org
Subject: ext4dev build failure on mips: "empty_zero_page" undefined
Message-ID: <20080512130604.GA15008@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.16 (2007-06-11)
Return-Path: <tbm@cyrius.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19211
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: tbm@cyrius.com
Precedence: bulk
X-list: linux-mips
Content-Length: 220
Lines: 9

I get the following build failure on MIPS Malta with 2.6.26-rc1:

  MODPOST 1516 modules
ERROR: "empty_zero_page" [fs/ext4/ext4dev.ko] undefined!

Any idea?  A missing export?
-- 
Martin Michlmayr
http://www.cyrius.com/

From dmitri.vorobiev@gmail.com Mon May 12 14:54:29 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 14:54:32 +0100 (BST)
Received: from yw-out-1718.google.com ([74.125.46.153]:64623 "EHLO
	yw-out-1718.google.com") by ftp.linux-mips.org with ESMTP
	id S20031540AbYELNy3 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 14:54:29 +0100
Received: by yw-out-1718.google.com with SMTP id 9so1407276ywk.24
        for <linux-mips@linux-mips.org>; Mon, 12 May 2008 06:54:24 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
        bh=ei9Y7FZi7xnmwNXMLXJEw+Z0PxsDgD1rwSdQtyPGpCc=;
        b=sj7+EoazzUxQ6yF6VRO3lctwnc0NYn4s7QXkK6UU3MHuQZknBIljh0TXn/ARPq2HQMkxWgTLDXRzpU+uTFBdLZenp4u13yjl31c2n//4xPQmhLwS9YSfuZKI0yQ6s6EU5dD68n+sIykrnNVvIjkWXfior3exbcNxrfLDnwreROQ=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
        b=q1/zLreiHlC8+WZ6jLqA0a+ED/27z+n7fxguQnpVeaD2Am6tRtIOznGHodv6QMtaHqFK/6R4K6+Kqg+voeAaomx1BoBWdXZasFMiWiWFOobhjD4mJ9PVDUirjDvUkKpmRaGQ6Ht7h3lHthWzFt9tEZOSpd8n8vJVtSG9kNHExek=
Received: by 10.150.84.20 with SMTP id h20mr8186175ybb.205.1210600464623;
        Mon, 12 May 2008 06:54:24 -0700 (PDT)
Received: by 10.150.140.6 with HTTP; Mon, 12 May 2008 06:54:24 -0700 (PDT)
Message-ID: <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
Date:	Mon, 12 May 2008 17:54:24 +0400
From:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
To:	"Martin Michlmayr" <tbm@cyrius.com>
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Cc:	linux-mips@linux-mips.org, linux-ext4@vger.kernel.org
In-Reply-To: <20080512130604.GA15008@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1197_20411098.1210600464680"
References: <20080512130604.GA15008@deprecation.cyrius.com>
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19212
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: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 2465
Lines: 49

------=_Part_1197_20411098.1210600464680
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

2008/5/12 Martin Michlmayr <tbm@cyrius.com>:
> I get the following build failure on MIPS Malta with 2.6.26-rc1:
>
>   MODPOST 1516 modules
>  ERROR: "empty_zero_page" [fs/ext4/ext4dev.ko] undefined!
>
>  Any idea?  A missing export?

Yep. The export is missing. Attached patch was build-tested for a
Malta config with ext4 enabled as a module.

Dmitri

------=_Part_1197_20411098.1210600464680
Content-Type: text/x-patch;
 name=0001-MIPS-Export-empty_zero_page-as-a-GPL-symbol.patch
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fg54936a0
Content-Disposition: attachment;
 filename=0001-MIPS-Export-empty_zero_page-as-a-GPL-symbol.patch

RnJvbSBjYjU1ZWQ3ZDk1OGNmNGFiYjU4ZGQxZDZlNDZlMDk0NDdiNTY5NGIwIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBEbWl0cmkgVm9yb2JpZXYgPGRtaXRyaS52b3JvYmlldkBnbWFp
bC5jb20+CkRhdGU6IE1vbiwgMTIgTWF5IDIwMDggMTc6NDk6MTkgKzA0MDAKU3ViamVjdDogW1BB
VENIIDEvMV0gW01JUFNdIEV4cG9ydCBlbXB0eV96ZXJvX3BhZ2UgYXMgYSBHUEwgc3ltYm9sCgpU
aGUgZW1wdHlfemVyb19wYWdlIHN5bWJvbCBpcyBuZWVkZWQgZm9yIHRoZSBleHQ0IGRyaXZlciBh
bmQKc2hvdWxkIHRoZXJlZm9yZSBiZSBleHBvcnRlZC4gVGhpcyBmaXhlcyB0aGUgZm9sbG93aW5n
IGVycm9yCnJlcG9ydGVkIGJ5IE1hcnRpbiBNaWNobG1heXI6Cgo+Pj4+Pj4+CgpNT0RQT1NUIDE1
MTYgbW9kdWxlcwpFUlJPUjogImVtcHR5X3plcm9fcGFnZSIgW2ZzL2V4dDQvZXh0NGRldi5rb10g
dW5kZWZpbmVkIQoKPj4+Pj4+CgpTaWduZWQtb2ZmLWJ5OiBEbWl0cmkgVm9yb2JpZXYgPGRtaXRy
aS52b3JvYmlldkBnbWFpbC5jb20+Ci0tLQogYXJjaC9taXBzL21tL2luaXQuYyB8ICAgIDUgKysr
Ky0KIDEgZmlsZXMgY2hhbmdlZCwgNCBpbnNlcnRpb25zKCspLCAxIGRlbGV0aW9ucygtKQoKZGlm
ZiAtLWdpdCBhL2FyY2gvbWlwcy9tbS9pbml0LmMgYi9hcmNoL21pcHMvbW0vaW5pdC5jCmluZGV4
IGVjZDU2MmQuLjYxOGE0MTggMTAwNjQ0Ci0tLSBhL2FyY2gvbWlwcy9tbS9pbml0LmMKKysrIGIv
YXJjaC9taXBzL21tL2luaXQuYwpAQCAtNzAsNyArNzAsMTAgQEAgREVGSU5FX1BFUl9DUFUoc3Ry
dWN0IG1tdV9nYXRoZXIsIG1tdV9nYXRoZXJzKTsKICAqIGFueSBwcmljZS4gIFNpbmNlIHBhZ2Ug
aXMgbmV2ZXIgd3JpdHRlbiB0byBhZnRlciB0aGUgaW5pdGlhbGl6YXRpb24gd2UKICAqIGRvbid0
IGhhdmUgdG8gY2FyZSBhYm91dCBhbGlhc2VzIG9uIG90aGVyIENQVXMuCiAgKi8KLXVuc2lnbmVk
IGxvbmcgZW1wdHlfemVyb19wYWdlLCB6ZXJvX3BhZ2VfbWFzazsKK3Vuc2lnbmVkIGxvbmcgZW1w
dHlfemVyb19wYWdlOworRVhQT1JUX1NZTUJPTF9HUEwoZW1wdHlfemVyb19wYWdlKTsKKwordW5z
aWduZWQgbG9uZyB6ZXJvX3BhZ2VfbWFzazsKIAogLyoKICAqIE5vdCBzdGF0aWMgaW5saW5lIGJl
Y2F1c2UgdXNlZCBieSBJUDI3IHNwZWNpYWwgbWFnaWMgaW5pdGlhbGl6YXRpb24gY29kZQotLSAK
MS41LjMKCg==
------=_Part_1197_20411098.1210600464680--

From anemo@mba.ocn.ne.jp Mon May 12 15:23:16 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 15:23:20 +0100 (BST)
Received: from mba.ocn.ne.jp ([122.1.235.107]:59859 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S20030079AbYELOXQ (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 15:23:16 +0100
Received: from localhost (p3253-ipad304funabasi.chiba.ocn.ne.jp [123.217.157.253])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id AC834B05C; Mon, 12 May 2008 23:23:09 +0900 (JST)
Date:	Mon, 12 May 2008 23:24:21 +0900 (JST)
Message-Id: <20080512.232421.108306312.anemo@mba.ocn.ne.jp>
To:	tsbogend@alpha.franken.de
Cc:	linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: Re: [PATCH] Fix check for valid stack pointer during backtrace
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <20080512125923.0C641DE534@solo.franken.de>
References: <20080512125923.0C641DE534@solo.franken.de>
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
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19213
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
Content-Length: 597
Lines: 17

On Mon, 12 May 2008 14:59:23 +0200 (CEST), Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote:
> The newly added check for valid stack pointer address breaks at least for
> 64bit kernels.  Use __get_user() for accessing stack content to avoid crashes,
> when doing the backtrace.
> 
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---

Thank you for updating.

> -	unsigned long *sp = (unsigned long *)(reg29 & ~3);
> +	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);

Please drop this change, while kstack_end expect non __user pointer.

---
Atsushi Nemoto

From tytso@mit.edu Mon May 12 15:34:50 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 15:34:53 +0100 (BST)
Received: from www.church-of-our-saviour.org ([69.25.196.31]:47072 "EHLO
	thunker.thunk.org") by ftp.linux-mips.org with ESMTP
	id S20030699AbYELOeu (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 15:34:50 +0100
Received: from root (helo=closure.thunk.org)
	by thunker.thunk.org with local-esmtp   (Exim 4.50 #1 (Debian))
	id 1JvZ9E-0003cm-HT; Mon, 12 May 2008 10:37:04 -0400
Received: from tytso by closure.thunk.org with local (Exim 4.67)
	(envelope-from <tytso@mit.edu>)
	id 1JvZ6g-00067i-5p; Mon, 12 May 2008 10:34:26 -0400
Date:	Mon, 12 May 2008 10:34:26 -0400
From:	Theodore Tso <tytso@mit.edu>
To:	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
Cc:	Martin Michlmayr <tbm@cyrius.com>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Message-ID: <20080512143426.GB7029@mit.edu>
References: <20080512130604.GA15008@deprecation.cyrius.com> <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
User-Agent: Mutt/1.5.15+20070412 (2007-04-11)
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: tytso@mit.edu
X-SA-Exim-Scanned: No (on thunker.thunk.org); SAEximRunCond expanded to false
Return-Path: <tytso@mit.edu>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19214
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: tytso@mit.edu
Precedence: bulk
X-list: linux-mips
Content-Length: 1971
Lines: 59

On Mon, May 12, 2008 at 05:54:24PM +0400, Dmitri Vorobiev wrote:
> 
> Yep. The export is missing. Attached patch was build-tested for a
> Malta config with ext4 enabled as a module.

Thanks, Dmitri!  

What is the Linux-mips' team preference for feeding this patch to
Linus?  This technically isn't a regression, since it was broken in
2.6.25, but it would be nice to get this to Linus sooner rather than
later.  Should I push it with a batch of ext4 fixes, or do you want to
push it via the mips tree?  (Davem asked me to push the sparc export
via ext4, while the ppc arch, it went via the ppc tree.  So whichever
is your preference; I'm easy.  :-)

   	     	     		     	    - Ted


> From cb55ed7d958cf4abb58dd1d6e46e09447b5694b0 Mon Sep 17 00:00:00 2001
> From: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
> Date: Mon, 12 May 2008 17:49:19 +0400
> Subject: [PATCH 1/1] [MIPS] Export empty_zero_page as a GPL symbol
> 
> The empty_zero_page symbol is needed for the ext4 driver and
> should therefore be exported. This fixes the following error
> reported by Martin Michlmayr:
> 
> >>>>>>>
> 
> MODPOST 1516 modules
> ERROR: "empty_zero_page" [fs/ext4/ext4dev.ko] undefined!
> 
> >>>>>>
> 
> Signed-off-by: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
> ---
>  arch/mips/mm/init.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
> index ecd562d..618a418 100644
> --- a/arch/mips/mm/init.c
> +++ b/arch/mips/mm/init.c
> @@ -70,7 +70,10 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
>   * any price.  Since page is never written to after the initialization we
>   * don't have to care about aliases on other CPUs.
>   */
> -unsigned long empty_zero_page, zero_page_mask;
> +unsigned long empty_zero_page;
> +EXPORT_SYMBOL_GPL(empty_zero_page);
> +
> +unsigned long zero_page_mask;
>  
>  /*
>   * Not static inline because used by IP27 special magic initialization code
> -- 
> 1.5.3
> 


From sshtylyov@ru.mvista.com Mon May 12 15:37:33 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 15:37:39 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:54096 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20030869AbYELOhd (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 15:37:33 +0100
Received: from [192.168.1.234] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id 946953EC9; Mon, 12 May 2008 07:37:29 -0700 (PDT)
Message-ID: <48285610.1000709@ru.mvista.com>
Date:	Mon, 12 May 2008 18:37:04 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	abhiruchi.g@vaultinfo.com
Cc:	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	kernel-testers@vger.kernel.org
Subject: Re: mips:(Alchemy au1200) how to use kdb to debug the kernel?is kdb
 inbuilt or kdb patch is required?
References: <54114.192.168.1.71.1210571642.webmail@192.168.1.71>
In-Reply-To: <54114.192.168.1.71.1210571642.webmail@192.168.1.71>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19215
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 175
Lines: 11

abhiruchi.g@vaultinfo.com wrote:

> how to use kdb to debug the kernel.
> I am using linux-2.6.22.

> Is kdb inbuilt or kdb patch is required? 

    The latter.

WBR, Sergei


From sshtylyov@ru.mvista.com Mon May 12 15:39:54 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 15:40:01 +0100 (BST)
Received: from h155.mvista.com ([63.81.120.155]:16721 "EHLO imap.sh.mvista.com")
	by ftp.linux-mips.org with ESMTP id S20031072AbYELOjy (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 15:39:54 +0100
Received: from [192.168.1.234] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id 8BB923EC9; Mon, 12 May 2008 07:39:48 -0700 (PDT)
Message-ID: <48285699.5060700@ru.mvista.com>
Date:	Mon, 12 May 2008 18:39:21 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	abhiruchi.g@vaultinfo.com
Cc:	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	kernel-testers@vger.kernel.org
Subject: Re: WARNING: arch/mips/au1000/common/built-in.o(.text+0x15c0): Section
 mismatch: reference to .init.data: (between 'au1xxx_platform_init' and '__fixup_bigphys_addr')
References: <54350.192.168.1.71.1210568848.webmail@192.168.1.71>
In-Reply-To: <54350.192.168.1.71.1210568848.webmail@192.168.1.71>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19216
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: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips
Content-Length: 586
Lines: 14

Hello.

abhiruchi.g@vaultinfo.com wrote:

> Hi all,
>   I am trying to configure the kernel for mips(DB1200 bosrd).I am getting this warning.
> how to remove this warning?

> WARNING: arch/mips/au1000/common/built-in.o(.text+0x15c0): Section mismatch: reference to .init.data: (between 'au1xxx_platform_init' and '__fixup_bigphys_addr')
> WARNING: arch/mips/au1000/common/built-in.o(.text+0x15c4): Section mismatch: reference to .init.data: (between 'au1xxx_platform_init' and '__fixup_bigphys_addr

    Which kernel version are you building? I'mnot seeing anything alike.

WBR, Sergei

From dmitri.vorobiev@gmail.com Mon May 12 15:46:31 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 15:46:35 +0100 (BST)
Received: from gv-out-0910.google.com ([216.239.58.188]:39592 "EHLO
	gv-out-0910.google.com") by ftp.linux-mips.org with ESMTP
	id S20030619AbYELOqb (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 15:46:31 +0100
Received: by gv-out-0910.google.com with SMTP id e6so281362gvc.2
        for <linux-mips@linux-mips.org>; Mon, 12 May 2008 07:46:21 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        bh=DxzrahkwK/4OBU3eNSQlGsvIJ6MiGOoYUamxH6Qhm4Q=;
        b=A9MpM7x4BEZX1l72x17VBn81nPLfVN/IJw9M1mGO9SMizAq6Cu1r8uPnLhhwDpRUI6ZNyWx3hYUbcXSYSOXzsukFQEHKVo8hoCK8OMU/gXf5LI0NL1Pfne7Ww/+YdnM/eQWSq/+S5MixRA2B+kvWrxvI5ImZQPmIwzL26FtiI+8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        b=KpOMDTYt9vxR4rjWiXHfhO+em3CeMGX2pKF2BfYwqhsj0C4txZof5basggbxDWYypafqy7guwdtlJJri1r6dX+jH8WdMfhKTZ0teDi43xaVKGtygJT8BXuWOlNbblpcaaPWWZdX85wo4IBi/9A8OASLd3YlOQMFiTJIxKgusHQs=
Received: by 10.151.144.4 with SMTP id w4mr8253919ybn.235.1210603581064;
        Mon, 12 May 2008 07:46:21 -0700 (PDT)
Received: by 10.150.140.6 with HTTP; Mon, 12 May 2008 07:46:21 -0700 (PDT)
Message-ID: <90edad820805120746l61e67362vbd177d63e8b05dc8@mail.gmail.com>
Date:	Mon, 12 May 2008 18:46:21 +0400
From:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
To:	"Theodore Tso" <tytso@mit.edu>
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Cc:	"Martin Michlmayr" <tbm@cyrius.com>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org, ralf@linux-mips.org
In-Reply-To: <20080512143426.GB7029@mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <20080512130604.GA15008@deprecation.cyrius.com>
	 <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
	 <20080512143426.GB7029@mit.edu>
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19217
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: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 915
Lines: 25

2008/5/12 Theodore Tso <tytso@mit.edu>:
> On Mon, May 12, 2008 at 05:54:24PM +0400, Dmitri Vorobiev wrote:
>  >
>  > Yep. The export is missing. Attached patch was build-tested for a
>  > Malta config with ext4 enabled as a module.
>
>  Thanks, Dmitri!
>
>  What is the Linux-mips' team preference for feeding this patch to
>  Linus?  This technically isn't a regression, since it was broken in
>  2.6.25, but it would be nice to get this to Linus sooner rather than
>  later.  Should I push it with a batch of ext4 fixes, or do you want to
>  push it via the mips tree?  (Davem asked me to push the sparc export
>  via ext4, while the ppc arch, it went via the ppc tree.  So whichever
>  is your preference; I'm easy.  :-)
>
>                                             - Ted

Hi Ted,

Normally I push my patches via the mips tree, and now I'm Cc:ing Ralf for that.

Hopefully Ralf will react quickly. :)

Dmitri

From tbm@cyrius.com Mon May 12 15:58:47 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 15:58:51 +0100 (BST)
Received: from sorrow.cyrius.com ([65.19.161.204]:60932 "EHLO
	sorrow.cyrius.com") by ftp.linux-mips.org with ESMTP
	id S20031146AbYELO6r (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 15:58:47 +0100
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id D644ED8E3; Mon, 12 May 2008 14:58:39 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id 70BD6372609; Mon, 12 May 2008 16:58:36 +0200 (CEST)
Date:	Mon, 12 May 2008 16:58:36 +0200
From:	Martin Michlmayr <tbm@cyrius.com>
To:	Theodore Tso <tytso@mit.edu>
Cc:	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>,
	linux-mips@linux-mips.org, linux-ext4@vger.kernel.org
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Message-ID: <20080512145836.GE15866@deprecation.cyrius.com>
References: <20080512130604.GA15008@deprecation.cyrius.com> <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com> <20080512143426.GB7029@mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080512143426.GB7029@mit.edu>
User-Agent: Mutt/1.5.16 (2007-06-11)
Return-Path: <tbm@cyrius.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19218
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: tbm@cyrius.com
Precedence: bulk
X-list: linux-mips
Content-Length: 348
Lines: 10

* Theodore Tso <tytso@mit.edu> [2008-05-12 10:34]:
> What is the Linux-mips' team preference for feeding this patch to
> Linus?  This technically isn't a regression, since it was broken in
> 2.6.25, but it would be nice to get this to Linus sooner rather than

Actually, it built just fine with 2.6.25.

-- 
Martin Michlmayr
http://www.cyrius.com/

From dmitri.vorobiev@gmail.com Mon May 12 16:14:29 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 16:14:33 +0100 (BST)
Received: from gv-out-0910.google.com ([216.239.58.184]:18103 "EHLO
	gv-out-0910.google.com") by ftp.linux-mips.org with ESMTP
	id S20032444AbYELPO3 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 16:14:29 +0100
Received: by gv-out-0910.google.com with SMTP id e6so288535gvc.2
        for <linux-mips@linux-mips.org>; Mon, 12 May 2008 08:14:24 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        bh=RPIr8EPjhwNGg/d+3Z6c15JAA0vY1h5+Zj0fll9ZxT4=;
        b=aFKIfBk/3HMC4IepxN+ImvQC/3nblayZzpYQ8TaoleTgf4EHUz9ela588SrsvzsrYEzx9Oay7UC2IPbA+/cLekzRrAOWxwrl1ydCu6yTm2F0dLUDlt/OKQqfI8s5k4DhK/f0GVEVE9Eea+f+PmSa7hHRWljedc5vY6xNQH0nRvE=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        b=pMwPRegF6KYZgBVKdNXwHfgtzqs3B8VkRW8rDlMQnT/wLUKQX3jMK6KxAVVrSXctqhT3f9p7rk2z7zA3pKyMGa96cZP0TdzoGFr1NhDmAzHBuu3e7Ny479g6BNPFlp6P35NgRV4bknroTfQWcjPnZirX8BrumzT+Px6SyjfERyM=
Received: by 10.150.91.17 with SMTP id o17mr8291944ybb.223.1210605263017;
        Mon, 12 May 2008 08:14:23 -0700 (PDT)
Received: by 10.150.140.6 with HTTP; Mon, 12 May 2008 08:14:23 -0700 (PDT)
Message-ID: <90edad820805120814l7ee3f5d3h7f9939854bccf0@mail.gmail.com>
Date:	Mon, 12 May 2008 19:14:23 +0400
From:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
To:	"Martin Michlmayr" <tbm@cyrius.com>
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Cc:	"Theodore Tso" <tytso@mit.edu>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org
In-Reply-To: <20080512145836.GE15866@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <20080512130604.GA15008@deprecation.cyrius.com>
	 <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
	 <20080512143426.GB7029@mit.edu>
	 <20080512145836.GE15866@deprecation.cyrius.com>
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19219
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: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 797
Lines: 18

2008/5/12 Martin Michlmayr <tbm@cyrius.com>:
> * Theodore Tso <tytso@mit.edu> [2008-05-12 10:34]:
>
> > What is the Linux-mips' team preference for feeding this patch to
>  > Linus?  This technically isn't a regression, since it was broken in
>  > 2.6.25, but it would be nice to get this to Linus sooner rather than
>
>  Actually, it built just fine with 2.6.25.

It was April 29th 2008 when commit
093a088b76352e0a6fdca84eb78b3aa65fbe6dd1 where the ext4_ext_zeroout()
routine was introduced (it is this routine that makes use of the
ZERO_PAGE macro expanding to an expression that contains a reference
to the empty_zero_page global symbol). After this commit, the patches
similar to the one found in this thread were made for several
architectures. Apparently, MIPS has been overlooked.

Dmitri

From tsbogend@alpha.franken.de Mon May 12 16:59:00 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 16:59:03 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:6359 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20031638AbYELP7A (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 16:59:00 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JvaQO-0004fL-00; Mon, 12 May 2008 17:58:52 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 2B1EBDE534; Mon, 12 May 2008 17:56:35 +0200 (CEST)
Date:	Mon, 12 May 2008 17:56:35 +0200
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: Re: [PATCH] Fix check for valid stack pointer during backtrace
Message-ID: <20080512155635.GA27431@alpha.franken.de>
References: <20080512125923.0C641DE534@solo.franken.de> <20080512.232421.108306312.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080512.232421.108306312.anemo@mba.ocn.ne.jp>
User-Agent: Mutt/1.5.13 (2006-08-11)
From:	tsbogend@alpha.franken.de (Thomas Bogendoerfer)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19220
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 455
Lines: 13

On Mon, May 12, 2008 at 11:24:21PM +0900, Atsushi Nemoto wrote:
> > -	unsigned long *sp = (unsigned long *)(reg29 & ~3);
> > +	unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
> 
> Please drop this change, while kstack_end expect non __user pointer.

arg, of course. Thanks.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

From tsbogend@alpha.franken.de Mon May 12 16:59:18 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 16:59:22 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:4823 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20031639AbYELP7A (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 16:59:00 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JvaQO-0004fL-01; Mon, 12 May 2008 17:58:52 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 29DB4DE534; Mon, 12 May 2008 17:58:48 +0200 (CEST)
From:	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Subject: [UPDATED PATCH] Fix check for valid stack pointer during backtrace
To:	linux-mips@linux-mips.org
cc:	ralf@linux-mips.org
Message-Id: <20080512155849.29DB4DE534@solo.franken.de>
Date:	Mon, 12 May 2008 17:58:48 +0200 (CEST)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19221
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 1141
Lines: 39

The newly added check for valid stack pointer address breaks at least for
64bit kernels.  Use __get_user() for accessing stack content to avoid crashes,
when doing the backtrace.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---

 arch/mips/kernel/traps.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index cb8b0e2..f9165d1 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -88,15 +88,17 @@ static void show_raw_backtrace(unsigned long reg29)
 #ifdef CONFIG_KALLSYMS
 	printk("\n");
 #endif
-#define IS_KVA01(a) ((((unsigned int)a) & 0xc0000000) == 0x80000000)
-	if (IS_KVA01(sp)) {
-		while (!kstack_end(sp)) {
-			addr = *sp++;
-			if (__kernel_text_address(addr))
-				print_ip_sym(addr);
+	while (!kstack_end(sp)) {
+		unsigned long __user *p =
+			(unsigned long __user *)(unsigned long)sp++;
+		if (__get_user(addr, p)) {
+			printk(" (Bad stack address)");
+			break;
 		}
-		printk("\n");
+		if (__kernel_text_address(addr))
+			print_ip_sym(addr);
 	}
+	printk("\n");
 }
 
 #ifdef CONFIG_KALLSYMS

From tbm@cyrius.com Mon May 12 17:31:21 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 17:31:24 +0100 (BST)
Received: from sorrow.cyrius.com ([65.19.161.204]:36872 "EHLO
	sorrow.cyrius.com") by ftp.linux-mips.org with ESMTP
	id S20030855AbYELQbV (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 17:31:21 +0100
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id D354ED8E7; Mon, 12 May 2008 16:31:16 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id C2C33372609; Mon, 12 May 2008 18:31:07 +0200 (CEST)
Date:	Mon, 12 May 2008 18:31:07 +0200
From:	Martin Michlmayr <tbm@cyrius.com>
To:	linux-mips@linux-mips.org
Subject: Malta build errors with 2.6.26-rc1
Message-ID: <20080512163107.GA19052@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
User-Agent: Mutt/1.5.16 (2007-06-11)
Return-Path: <tbm@cyrius.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19222
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: tbm@cyrius.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1632
Lines: 28

Some Malta build errors:

cc1: warnings being treated as errors
arch/mips/mips-boards/malta/malta_int.c: In function â€˜gcmp_probeâ€™:
arch/mips/mips-boards/malta/malta_int.c:408: warning: cast to pointer from integer of different size
arch/mips/mips-boards/malta/malta_int.c: In function â€˜arch_init_irqâ€™:
arch/mips/mips-boards/malta/malta_int.c:437: warning: cast to pointer from integer of different size
arch/mips/mips-boards/malta/malta_int.c:441: warning: cast to pointer from integer of different size
arch/mips/mips-boards/malta/malta_int.c: In function â€˜malta_be_handlerâ€™:
arch/mips/mips-boards/malta/malta_int.c:656: warning: cast to pointer from integer of different size
arch/mips/mips-boards/malta/malta_int.c:657: warning: cast to pointer from integer of different size
arch/mips/mips-boards/malta/malta_int.c:658: warning: cast to pointer from integer of different size
arch/mips/mips-boards/malta/malta_int.c:704: warning: cast to pointer from integer of different size
make[5]: *** [arch/mips/mips-boards/malta/malta_int.o] Error 1

and:

arch/mips/mips-boards/generic/amon.c: In function â€˜amon_cpu_availâ€™:
arch/mips/mips-boards/generic/amon.c:31: error: implicit declaration of function â€˜KSEG0ADDRâ€™
cc1: warnings being treated as errors
arch/mips/mips-boards/generic/amon.c:31: warning: cast to pointer from integer of different size
arch/mips/mips-boards/generic/amon.c: In function â€˜amon_cpu_startâ€™:
arch/mips/mips-boards/generic/amon.c:56: warning: cast to pointer from integer of different size
make[4]: *** [arch/mips/mips-boards/malta] Error 2

-- 
Martin Michlmayr
http://www.cyrius.com/

From tbm@cyrius.com Mon May 12 17:32:09 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 17:32:13 +0100 (BST)
Received: from sorrow.cyrius.com ([65.19.161.204]:37384 "EHLO
	sorrow.cyrius.com") by ftp.linux-mips.org with ESMTP
	id S20030434AbYELQcJ (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 17:32:09 +0100
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id E6968D8E7; Mon, 12 May 2008 16:32:05 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id 283C6372609; Mon, 12 May 2008 18:32:01 +0200 (CEST)
Date:	Mon, 12 May 2008 18:32:01 +0200
From:	Martin Michlmayr <tbm@cyrius.com>
To:	linux-mips@linux-mips.org
Subject: Re: Malta build errors with 2.6.26-rc1
Message-ID: <20080512163200.GA19203@deprecation.cyrius.com>
References: <20080512163107.GA19052@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20080512163107.GA19052@deprecation.cyrius.com>
User-Agent: Mutt/1.5.16 (2007-06-11)
Return-Path: <tbm@cyrius.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19223
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: tbm@cyrius.com
Precedence: bulk
X-list: linux-mips
Content-Length: 321
Lines: 11

* Martin Michlmayr <tbm@cyrius.com> [2008-05-12 18:31]:
> Some Malta build errors:
> 
> cc1: warnings being treated as errors
> arch/mips/mips-boards/malta/malta_int.c: In function â€˜gcmp_probeâ€™:

Sorry, I forgot to mention that this is 64-bit Malta.  32-bit compiles
fine.
-- 
Martin Michlmayr
http://www.cyrius.com/

From tbm@cyrius.com Mon May 12 18:12:35 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 18:12:38 +0100 (BST)
Received: from sorrow.cyrius.com ([65.19.161.204]:56332 "EHLO
	sorrow.cyrius.com") by ftp.linux-mips.org with ESMTP
	id S20031365AbYELRMf (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 18:12:35 +0100
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id 74969D8E5; Mon, 12 May 2008 17:12:29 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id 612F0372609; Mon, 12 May 2008 19:12:16 +0200 (CEST)
Date:	Mon, 12 May 2008 19:12:16 +0200
From:	Martin Michlmayr <tbm@cyrius.com>
To:	linux-mips@linux-mips.org
Subject: Cobalt drivers/media build failure
Message-ID: <20080512171216.GA19598@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.16 (2007-06-11)
Return-Path: <tbm@cyrius.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19224
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: tbm@cyrius.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1932
Lines: 32

With the Debian config (that enables a lot of modules) I get the
following build error on Cobalt with 2.6.26-rc1:

  MODPOST 778 modules
ERROR: "i2c_master_send" [drivers/media/video/tuner.ko] undefined!
ERROR: "i2c_detach_client" [drivers/media/video/tuner.ko] undefined!
ERROR: "i2c_del_driver" [drivers/media/video/tuner.ko] undefined!
ERROR: "v4l2_i2c_attach" [drivers/media/video/tuner.ko] undefined!
ERROR: "i2c_register_driver" [drivers/media/video/tuner.ko] undefined!
ERROR: "i2c_master_recv" [drivers/media/video/tuner.ko] undefined!
ERROR: "i2c_probe" [drivers/media/video/tuner.ko] undefined!
ERROR: "i2c_register_driver" [drivers/media/video/mt9v022.ko] undefined!
ERROR: "i2c_smbus_write_word_data" [drivers/media/video/mt9v022.ko] undefined!
ERROR: "i2c_smbus_read_word_data" [drivers/media/video/mt9v022.ko] undefined!
ERROR: "i2c_del_driver" [drivers/media/video/mt9v022.ko] undefined!
ERROR: "i2c_register_driver" [drivers/media/video/mt9m001.ko] undefined!
ERROR: "i2c_smbus_write_word_data" [drivers/media/video/mt9m001.ko] undefined!
ERROR: "i2c_smbus_read_word_data" [drivers/media/video/mt9m001.ko] undefined!
ERROR: "i2c_del_driver" [drivers/media/video/mt9m001.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/xc5000.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/tuner-xc2028.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/tuner-simple.ko] undefined!
ERROR: "i2c_clients_command" [drivers/media/common/tuners/tuner-simple.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/tea5767.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/tea5761.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/tda9887.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/tda8290.ko] undefined!
ERROR: "i2c_transfer" [drivers/media/common/tuners/mt20xx.ko] undefined!

-- 
Martin Michlmayr
http://www.cyrius.com/

From dvomlehn@cisco.com Mon May 12 18:14:47 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 18:14:50 +0100 (BST)
Received: from sj-iport-3.cisco.com ([171.71.176.72]:36656 "EHLO
	sj-iport-3.cisco.com") by ftp.linux-mips.org with ESMTP
	id S20024551AbYELROr (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 18:14:47 +0100
Received: from sj-dkim-4.cisco.com ([171.71.179.196])
  by sj-iport-3.cisco.com with ESMTP; 12 May 2008 10:14:37 -0700
Received: from sj-core-2.cisco.com (sj-core-2.cisco.com [171.71.177.254])
	by sj-dkim-4.cisco.com (8.12.11/8.12.11) with ESMTP id m4CHEZXw027073;
	Mon, 12 May 2008 10:14:35 -0700
Received: from cliff.cisco.com (cliff.cisco.com [171.69.11.141])
	by sj-core-2.cisco.com (8.13.8/8.13.8) with ESMTP id m4CHEZmw027962;
	Mon, 12 May 2008 17:14:35 GMT
Received: from [127.0.0.1] ([64.101.20.200]) by cliff.cisco.com (8.6.12/8.6.5) with ESMTP id RAA13188; Mon, 12 May 2008 17:14:34 GMT
Message-ID: <48287AEC.6090300@cisco.com>
Date:	Mon, 12 May 2008 10:14:20 -0700
From:	David VomLehn <dvomlehn@cisco.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
To:	"Ralf Baechle [ralf"@linux-mips.org]
CC:	linux-mips@linux-mips.org
Subject: Re: [RFC] [PATCH 1/1] [MIPS] Advanced Kernel Stack Backtrace
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
DKIM-Signature:	v=1; a=rsa-sha256; q=dns/txt; l=549; t=1210612475; x=1211476475;
	c=relaxed/simple; s=sjdkim4002;
	h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version;
	d=cisco.com; i=dvomlehn@cisco.com;
	z=From:=20David=20VomLehn=20<dvomlehn@cisco.com>
	|Subject:=20Re=3A=20[RFC]=20[PATCH=201/1]=20[MIPS]=20Advanc
	ed=20Kernel=20Stack=20Backtrace
	|Sender:=20;
	bh=8OiEY+e8tXIW4lt0qnwUg2gK9fVczFbQ8M26giiSO9Y=;
	b=fJmG+y3nMRPkoNPb81wFk9u+LXakFjcrn4rGXvaxKNj+8IJyqmbhr4M5k1
	wxD3qQGdPNRn12ftiDWIlJAM97QxEsuDz9EGAzhJJpdET8LFXc70Vi6HAeLb
	fT+ErOHp7L;
Authentication-Results:	sj-dkim-4; header.From=dvomlehn@cisco.com; dkim=pass (
	sig from cisco.com/sjdkim4002 verified; ); 
Return-Path: <dvomlehn@cisco.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19225
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: dvomlehn@cisco.com
Precedence: bulk
X-list: linux-mips
Content-Length: 530
Lines: 23

> On Wed, May 07, 2008 at 04:49:53PM -0700, David VomLehn wrote:
> 
>> This patch contains the kernel stack backtrace code we've been running 
>> for about a year on our MIPS-based settop box. ...

>  o Use ARRAY_SIZE() from <linux/kernel.h> instead of numberof.

Oops, missed this one in the port from 2.6.14 to 2.6.24.

>  o Please run the patch through scripts/checkpatch.pl and fix the resulting
>    errors.

Will do.

>  o Your patch got linewrapped by your mail client.

Ouch. I'll fix that next time.

>   Ralf

Thanks!



From tytso@mit.edu Mon May 12 18:35:58 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 18:36:00 +0100 (BST)
Received: from www.church-of-our-saviour.org ([69.25.196.31]:59093 "EHLO
	thunker.thunk.org") by ftp.linux-mips.org with ESMTP
	id S20030609AbYELRf6 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 18:35:58 +0100
Received: from root (helo=closure.thunk.org)
	by thunker.thunk.org with local-esmtp   (Exim 4.50 #1 (Debian))
	id 1Jvbyb-00045P-Fx; Mon, 12 May 2008 13:38:17 -0400
Received: from tytso by closure.thunk.org with local (Exim 4.67)
	(envelope-from <tytso@mit.edu>)
	id 1Jvbw2-00053v-5I; Mon, 12 May 2008 13:35:38 -0400
Date:	Mon, 12 May 2008 13:35:38 -0400
From:	Theodore Tso <tytso@mit.edu>
To:	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
Cc:	Martin Michlmayr <tbm@cyrius.com>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Message-ID: <20080512173537.GG7029@mit.edu>
References: <20080512130604.GA15008@deprecation.cyrius.com> <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com> <20080512143426.GB7029@mit.edu> <20080512145836.GE15866@deprecation.cyrius.com> <90edad820805120814l7ee3f5d3h7f9939854bccf0@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <90edad820805120814l7ee3f5d3h7f9939854bccf0@mail.gmail.com>
User-Agent: Mutt/1.5.15+20070412 (2007-04-11)
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: tytso@mit.edu
X-SA-Exim-Scanned: No (on thunker.thunk.org); SAEximRunCond expanded to false
Return-Path: <tytso@mit.edu>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19226
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: tytso@mit.edu
Precedence: bulk
X-list: linux-mips
Content-Length: 781
Lines: 19

On Mon, May 12, 2008 at 07:14:23PM +0400, Dmitri Vorobiev wrote:
> 
> It was April 29th 2008 when commit
> 093a088b76352e0a6fdca84eb78b3aa65fbe6dd1 where the ext4_ext_zeroout()
> routine was introduced (it is this routine that makes use of the
> ZERO_PAGE macro expanding to an expression that contains a reference
> to the empty_zero_page global symbol). After this commit, the patches
> similar to the one found in this thread were made for several
> architectures. Apparently, MIPS has been overlooked.
> 

Yeah, I guess no one is currently doing test builds of linux-next on
the mips architecture.  It's likely Stephen Rothwell doesn't have
access to one.

(The patch itself has been around for a while, both in the -mm tree,
the ext4 patches, and in Linux-next.)

						- Ted

From tbm@cyrius.com Mon May 12 18:39:14 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 18:39:17 +0100 (BST)
Received: from sorrow.cyrius.com ([65.19.161.204]:49422 "EHLO
	sorrow.cyrius.com") by ftp.linux-mips.org with ESMTP
	id S20030644AbYELRjO (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 18:39:14 +0100
Received: by sorrow.cyrius.com (Postfix, from userid 10)
	id 8A8DDD8E7; Mon, 12 May 2008 17:39:10 +0000 (UTC)
Received: by deprecation.cyrius.com (Postfix, from userid 1000)
	id 653B6372609; Mon, 12 May 2008 19:39:07 +0200 (CEST)
Date:	Mon, 12 May 2008 19:39:07 +0200
From:	Martin Michlmayr <tbm@cyrius.com>
To:	linux-mips@linux-mips.org
Subject: sb1-bcm91250a build error
Message-ID: <20080512173907.GA20477@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
User-Agent: Mutt/1.5.16 (2007-06-11)
Return-Path: <tbm@cyrius.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19227
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: tbm@cyrius.com
Precedence: bulk
X-list: linux-mips
Content-Length: 409
Lines: 11

I get the following build error on sb1-bcm91250a with 2.6.26-rc1 (did
I mention that -Werror by default is a really bad idea?):

cc1: warnings being treated as errors
arch/mips/kernel/traps.c: In function â€˜show_raw_backtraceâ€™:
arch/mips/kernel/traps.c:92: warning: cast from pointer to integer of different size
make[5]: *** [arch/mips/kernel/traps.o] Error 1

-- 
Martin Michlmayr
http://www.cyrius.com/

From dmitri.vorobiev@gmail.com Mon May 12 20:37:55 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 20:37:57 +0100 (BST)
Received: from yw-out-1718.google.com ([74.125.46.158]:13511 "EHLO
	yw-out-1718.google.com") by ftp.linux-mips.org with ESMTP
	id S20032059AbYELThz (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 20:37:55 +0100
Received: by yw-out-1718.google.com with SMTP id 9so1486470ywk.24
        for <linux-mips@linux-mips.org>; Mon, 12 May 2008 12:37:47 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        bh=oDa4vgGdRqPPcz/IyZLxLDdYxRbtKEV0EB3KQlS2z3I=;
        b=sqZBNH9z57fRwv9qjbe/LZq7V5x6Z/4J3iEs+iltUbxJsEJOch1Yji77uSsG39Rw8qLTBXZroN4vcJOh4HFwxA4o+FOodfes4u6ha8eltZYw2NLS9OvpwF2/l6SLyrIhcvdw7WRXNXhFiwRStprJ5ZT0hfNbpjoC08vJ920YADc=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        b=bYRz2u+RSX6LiIU5SOIMe2xOMbtyeSSEQ7w5fgQO/p9ySjD9qolUq1gQ4GQJeCqluzs98EW4YEkPdIi+1zpHgGGnYDUKzM5WkT3NZHbgsRibM/Jq6nuTpApwBF8Di+RA8GIkRxO4XZm7Sdmd7xrUuhj918qoLbS/pC0B97x7jHY=
Received: by 10.150.52.2 with SMTP id z2mr8709747ybz.48.1210621066973;
        Mon, 12 May 2008 12:37:46 -0700 (PDT)
Received: by 10.150.140.6 with HTTP; Mon, 12 May 2008 12:37:46 -0700 (PDT)
Message-ID: <90edad820805121237r7f4b6e16g135df49cfe27499a@mail.gmail.com>
Date:	Mon, 12 May 2008 23:37:46 +0400
From:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
To:	"Theodore Tso" <tytso@mit.edu>
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Cc:	"Martin Michlmayr" <tbm@cyrius.com>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org, sfr@canb.auug.org.au
In-Reply-To: <20080512173537.GG7029@mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <20080512130604.GA15008@deprecation.cyrius.com>
	 <90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
	 <20080512143426.GB7029@mit.edu>
	 <20080512145836.GE15866@deprecation.cyrius.com>
	 <90edad820805120814l7ee3f5d3h7f9939854bccf0@mail.gmail.com>
	 <20080512173537.GG7029@mit.edu>
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19228
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: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 433
Lines: 13

>
>  Yeah, I guess no one is currently doing test builds of linux-next on
>  the mips architecture.  It's likely Stephen Rothwell doesn't have
>  access to one.
>

I do that sometimes. Obviously, not frequently enough. Sorry.

If Stephen wants, I, in principle, could set up a MIPS toolchain for
him, similar to the one I use myself in my small test farm. Or assist
in doing that somehow. Stephen, what do you think of that?

Dmitri

From dmitri.vorobiev@gmail.com Mon May 12 20:46:28 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 20:46:31 +0100 (BST)
Received: from yw-out-1718.google.com ([74.125.46.158]:55526 "EHLO
	yw-out-1718.google.com") by ftp.linux-mips.org with ESMTP
	id S20031765AbYELTq2 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 12 May 2008 20:46:28 +0100
Received: by yw-out-1718.google.com with SMTP id 9so1488071ywk.24
        for <linux-mips@linux-mips.org>; Mon, 12 May 2008 12:46:19 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        bh=UQqDpcOtQFCNjVPtdc9rushsIIrOj6S3GYr7hzVzK3w=;
        b=Vc3C9NQdLg7WeAVngrmPcHPz5kD2OwlmewWtcdUxLRsDpmaP5Qw6RyKEK3KdIG9rYtRhWVf6e09mme60hrQrcMdb0RmMmVCFNjWrR73/VltLEDFkM9Pj+wC70Nb0cEZwXpUhnP1AFWxesSbtDOa7ZucPfwFok/9vmeCA5D/iLhU=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        b=Q9NL9JCYbNkFsJNaCAT9nxEb1NshVMPUpAW3zO9lIzQEPzyLgWzk9qH8PdKV3tndEXUDi79QCYUSG/d6X/rnWcVLMzXzP48RpeQPl4996PN/WYwIeYV+E9PRjaJgJXafaMDmB6x65zPbw371tp2l2LfSEyQ6gwmixgups8sJbAg=
Received: by 10.150.57.4 with SMTP id f4mr8734733yba.71.1210621579653;
        Mon, 12 May 2008 12:46:19 -0700 (PDT)
Received: by 10.150.140.6 with HTTP; Mon, 12 May 2008 12:46:19 -0700 (PDT)
Message-ID: <90edad820805121246o328d1cdaide88594ce9d328b7@mail.gmail.com>
Date:	Mon, 12 May 2008 23:46:19 +0400
From:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
To:	"Martin Michlmayr" <tbm@cyrius.com>
Subject: Re: Malta build errors with 2.6.26-rc1
Cc:	linux-mips@linux-mips.org
In-Reply-To: <20080512163107.GA19052@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <20080512163107.GA19052@deprecation.cyrius.com>
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19229
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: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips
Content-Length: 1834
Lines: 33

2008/5/12 Martin Michlmayr <tbm@cyrius.com>:
> Some Malta build errors:
>
>  cc1: warnings being treated as errors
>  arch/mips/mips-boards/malta/malta_int.c: In function 'gcmp_probe':
>  arch/mips/mips-boards/malta/malta_int.c:408: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/malta/malta_int.c: In function 'arch_init_irq':
>  arch/mips/mips-boards/malta/malta_int.c:437: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/malta/malta_int.c:441: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/malta/malta_int.c: In function 'malta_be_handler':
>  arch/mips/mips-boards/malta/malta_int.c:656: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/malta/malta_int.c:657: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/malta/malta_int.c:658: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/malta/malta_int.c:704: warning: cast to pointer from integer of different size
>  make[5]: *** [arch/mips/mips-boards/malta/malta_int.o] Error 1
>
>  and:
>
>  arch/mips/mips-boards/generic/amon.c: In function 'amon_cpu_avail':
>  arch/mips/mips-boards/generic/amon.c:31: error: implicit declaration of function 'KSEG0ADDR'
>  cc1: warnings being treated as errors
>  arch/mips/mips-boards/generic/amon.c:31: warning: cast to pointer from integer of different size
>  arch/mips/mips-boards/generic/amon.c: In function 'amon_cpu_start':
>  arch/mips/mips-boards/generic/amon.c:56: warning: cast to pointer from integer of different size
>  make[4]: *** [arch/mips/mips-boards/malta] Error 2
>

Known error. Please see this thread for some suggestions (and be
warned that I did not try any of them):

http://marc.info/?t=120966332300004&r=1&w=2

Dmitri

From tsbogend@alpha.franken.de Mon May 12 22:14:16 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 12 May 2008 22:14:18 +0100 (BST)
Received: from elvis.franken.de ([193.175.24.41]:15253 "EHLO elvis.franken.de")
	by ftp.linux-mips.org with ESMTP id S20031696AbYELVOQ (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 12 May 2008 22:14:16 +0100
Received: from uucp (helo=solo.franken.de)
	by elvis.franken.de with local-bsmtp (Exim 3.36 #1)
	id 1JvfLW-00023Z-00; Mon, 12 May 2008 23:14:10 +0200
Received: by solo.franken.de (Postfix, from userid 1000)
	id 4E750DE534; Mon, 12 May 2008 23:12:09 +0200 (CEST)
Date:	Mon, 12 May 2008 23:12:09 +0200
To:	Martin Michlmayr <tbm@cyrius.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: sb1-bcm91250a build error
Message-ID: <20080512211209.GA30922@alpha.franken.de>
References: <20080512173907.GA20477@deprecation.cyrius.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080512173907.GA20477@deprecation.cyrius.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
From:	tsbogend@alpha.franken.de (Thomas Bogendoerfer)
Return-Path: <tsbogend@alpha.franken.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19230
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: tsbogend@alpha.franken.de
Precedence: bulk
X-list: linux-mips
Content-Length: 695
Lines: 17

On Mon, May 12, 2008 at 07:39:07PM +0200, Martin Michlmayr wrote:
> I get the following build error on sb1-bcm91250a with 2.6.26-rc1 (did
> I mention that -Werror by default is a really bad idea?):
> 
> cc1: warnings being treated as errors
> arch/mips/kernel/traps.c: In function ???show_raw_backtrace???:
> arch/mips/kernel/traps.c:92: warning: cast from pointer to integer of different size
> make[5]: *** [arch/mips/kernel/traps.o] Error 1

known issues for any 64bit kernel. I've posted a patch and updated patch
to fix that.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

From sfr@canb.auug.org.au Tue May 13 01:56:02 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 01:56:05 +0100 (BST)
Received: from chilli.pcug.org.au ([203.10.76.44]:30425 "EHLO smtps.tip.net.au")
	by ftp.linux-mips.org with ESMTP id S20032201AbYEMA4C (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 01:56:02 +0100
Received: from ash.ozlabs.ibm.com (bh02i525f01.au.ibm.com [202.81.18.30])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by smtps.tip.net.au (Postfix) with ESMTP id 09994368002;
	Tue, 13 May 2008 10:55:55 +1000 (EST)
Date:	Tue, 13 May 2008 10:55:49 +1000
From:	Stephen Rothwell <sfr@canb.auug.org.au>
To:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
Cc:	"Theodore Tso" <tytso@mit.edu>,
	"Martin Michlmayr" <tbm@cyrius.com>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org, ralf@linux-mips.org
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Message-Id: <20080513105549.bb1563f8.sfr@canb.auug.org.au>
In-Reply-To: <90edad820805121237r7f4b6e16g135df49cfe27499a@mail.gmail.com>
References: <20080512130604.GA15008@deprecation.cyrius.com>
	<90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
	<20080512143426.GB7029@mit.edu>
	<20080512145836.GE15866@deprecation.cyrius.com>
	<90edad820805120814l7ee3f5d3h7f9939854bccf0@mail.gmail.com>
	<20080512173537.GG7029@mit.edu>
	<90edad820805121237r7f4b6e16g135df49cfe27499a@mail.gmail.com>
X-Mailer: Sylpheed 2.5.0beta3 (GTK+ 2.12.9; i486-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: multipart/signed; protocol="application/pgp-signature";
 micalg="PGP-SHA1";
 boundary="Signature=_Tue__13_May_2008_10_55_49_+1000_HmwJAB2QRWSZWDug"
Return-Path: <sfr@canb.auug.org.au>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19231
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: sfr@canb.auug.org.au
Precedence: bulk
X-list: linux-mips
Content-Length: 1560
Lines: 45

--Signature=_Tue__13_May_2008_10_55_49_+1000_HmwJAB2QRWSZWDug
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi Dimitri,

On Mon, 12 May 2008 23:37:46 +0400 "Dmitri Vorobiev" <dmitri.vorobiev@gmail=
.com> wrote:
>
> >  Yeah, I guess no one is currently doing test builds of linux-next on
> >  the mips architecture.  It's likely Stephen Rothwell doesn't have
> >  access to one.
>=20
> I do that sometimes. Obviously, not frequently enough. Sorry.
>=20
> If Stephen wants, I, in principle, could set up a MIPS toolchain for
> him, similar to the one I use myself in my small test farm. Or assist
> in doing that somehow. Stephen, what do you think of that?

That would be great.  However, let us try with crosstool first. We
haven't actually tried using crosstool to build a mips cross compiler.
For a start, do we need mips or mipsel?  (My tame minion is trying to
build both now.  :-))  Our host arch is powerpc64.

Of course, we have much more incentive to do mips builds if the mips tree
is in linux-next.  HINT! HINT! :-)

--=20
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

--Signature=_Tue__13_May_2008_10_55_49_+1000_HmwJAB2QRWSZWDug
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIKOcZTgG2atn1QN8RAjXpAJ4zNisrnB3kmRb1AxHznIMQNAFDNwCfUv6z
aQd2/fAK9nQ3grKcMYdMVA8=
=IGW4
-----END PGP SIGNATURE-----

--Signature=_Tue__13_May_2008_10_55_49_+1000_HmwJAB2QRWSZWDug--

From sfr@canb.auug.org.au Tue May 13 02:43:04 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 02:43:06 +0100 (BST)
Received: from chilli.pcug.org.au ([203.10.76.44]:62095 "EHLO smtps.tip.net.au")
	by ftp.linux-mips.org with ESMTP id S20023287AbYEMBnE (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 02:43:04 +0100
Received: from ash.ozlabs.ibm.com (bh02i525f01.au.ibm.com [202.81.18.30])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by smtps.tip.net.au (Postfix) with ESMTP id 2695D368003;
	Tue, 13 May 2008 11:42:57 +1000 (EST)
Date:	Tue, 13 May 2008 11:42:44 +1000
From:	Stephen Rothwell <sfr@canb.auug.org.au>
To:	"Dmitri Vorobiev" <dmitri.vorobiev@gmail.com>
Cc:	"Theodore Tso" <tytso@mit.edu>,
	"Martin Michlmayr" <tbm@cyrius.com>, linux-mips@linux-mips.org,
	linux-ext4@vger.kernel.org, ralf@linux-mips.org
Subject: Re: ext4dev build failure on mips: "empty_zero_page" undefined
Message-Id: <20080513114244.736cf625.sfr@canb.auug.org.au>
In-Reply-To: <20080513105549.bb1563f8.sfr@canb.auug.org.au>
References: <20080512130604.GA15008@deprecation.cyrius.com>
	<90edad820805120654n50f7a00cm3c7b4a4f9346d5ea@mail.gmail.com>
	<20080512143426.GB7029@mit.edu>
	<20080512145836.GE15866@deprecation.cyrius.com>
	<90edad820805120814l7ee3f5d3h7f9939854bccf0@mail.gmail.com>
	<20080512173537.GG7029@mit.edu>
	<90edad820805121237r7f4b6e16g135df49cfe27499a@mail.gmail.com>
	<20080513105549.bb1563f8.sfr@canb.auug.org.au>
X-Mailer: Sylpheed 2.5.0beta3 (GTK+ 2.12.9; i486-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: multipart/signed; protocol="application/pgp-signature";
 micalg="PGP-SHA1";
 boundary="Signature=_Tue__13_May_2008_11_42_44_+1000_D4xdJbk8zH./C2Qr"
Return-Path: <sfr@canb.auug.org.au>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19232
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: sfr@canb.auug.org.au
Precedence: bulk
X-list: linux-mips
Content-Length: 1129
Lines: 33

--Signature=_Tue__13_May_2008_11_42_44_+1000_D4xdJbk8zH./C2Qr
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, 13 May 2008 10:55:49 +1000 Stephen Rothwell <sfr@canb.auug.org.au> =
wrote:
>
> That would be great.  However, let us try with crosstool first. We
> haven't actually tried using crosstool to build a mips cross compiler.
> For a start, do we need mips or mipsel?  (My tame minion is trying to
> build both now.  :-))  Our host arch is powerpc64.

Also, the only compiler version that crosstool seems to know about for
mips is 3.4.5.  Is this version ok for building mips kernels?

--=20
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

--Signature=_Tue__13_May_2008_11_42_44_+1000_D4xdJbk8zH./C2Qr
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIKPIgTgG2atn1QN8RAlbPAKCLH9Yh2Ofm9Jk0tDqpavAOTZTkowCfbqkn
whC5LVgC8CjZ8HhpONd0yEE=
=lbVq
-----END PGP SIGNATURE-----

--Signature=_Tue__13_May_2008_11_42_44_+1000_D4xdJbk8zH./C2Qr--

From macro@linux-mips.org Tue May 13 04:26:38 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:26:40 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:14323 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20031883AbYEMD0i (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:26:38 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3QGUF003655;
	Tue, 13 May 2008 05:26:16 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3PkaF003645;
	Tue, 13 May 2008 04:25:54 +0100
Date:	Tue, 13 May 2008 04:25:45 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/6] RTC: Use class devices as a persistent clock (#2)
Message-ID: <Pine.LNX.4.55.0805130214460.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19233
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2775
Lines: 52

Hello,

 This is the second stage of patch submission for this change.  Thanks
everybody for all the useful suggestions and testing.  As I understand the
changes are in line with the intent of everyone concerned.  At this
moment, unless anybody complains, I consider these patches ready to be
applied upstream.

 These patches provide means to switch to the RTC class devices for the
purpose of providing the backup clock for timekeeping.  The API in
question are the read_persistent_clock() and update_persistent_clock()  
functions used mostly by the NTP support code.

 The notable gain is the removal of the additional burden from platform
code -- all that has be implemented is support for the RTC chip the
platform has.  I have added the rtc_read_persistent_clock() and
rtc_update_persistent_clock() functions to the RTC suite that can serve as
the implementation of the API and work the same (hardware implementation
permitting) regardless of the exact RTC chip used.  There is even support
for the ubiquitous derivatives of the MC146818 available as a class device
already.  Additionally, if there is more than one RTC chip in a given
system, the user can select which of the chips to use.

 The drawback is some implementations behind these functions may sleep,
for example because hardware is slow to access.  The current calling
context of update_persistent_clock() (which is the softirq) does not
permit the function to sleep.  To rectify I have moved the call into the
process context, but it now means the latency between getnstimeofday() and
the writeback into the RTC will be yet less predictable and potentially
higher.  This should not matter in practice, because the RTC generally
cannot guarantee suitable precision to be a reliable sub-second resolution
device for providing time while the NTP daemon is not running and one who
cares about timekeeping will run NTP during normal system operation anyway
which will correct any inaccuracy gathered from the RTC.  I am mentioning
it though as I think it should be noted.

 Significant changes from the first iteration:

1. MIPS Makefile changes are now separate so that they can go straight
   into the MIPS tree without relying on I2C changes.

2. M41T80 driver changes have been simplified -- thanks, Jean and DavidB,
   for your feedback letting me understand the I2C core better.

 Individual patches follow, feedback is welcome.  All have been
successfully tested at the run time with a big-endian 64-bit MIPS
configuration (a Broadcom BCM91250A board), using the usual SMP vs non-SMP
and PREEMPT vs non-PREEMPT configurations, with spinlock, etc. debugging
on; no checkpatch.pl nor sparse problems either.  They have been
successfully built for a 32-bit x86 and Alpha configuration as well.

  Maciej

From macro@linux-mips.org Tue May 13 04:26:56 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:27:00 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:17395 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20031892AbYEMD0x (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:26:53 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3QVd1003663;
	Tue, 13 May 2008 05:26:31 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3QUga003659;
	Tue, 13 May 2008 04:26:30 +0100
Date:	Tue, 13 May 2008 04:26:30 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/6] RTC: Class device support for persistent clock (#2)
Message-ID: <Pine.LNX.4.55.0805130232030.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19234
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 10238
Lines: 288

 This is a generic implementation of rtc_read_persistent_clock() and
rtc_update_persistent_clock() suitable for platforms to be used for
read_persistent_clock() and update_persistent_clock() calls.  An RTC
device selected by the user with the RTC_HCTOSYS_DEVICE option is used.  

 As rtc_read_persistent_clock() is not available at the time
timekeeping_init() is called, it will now be disabled if the class device
is to be used as a reference.  In this case rtc_hctosys(), already
present, will be used to set up the system time at the late initcall time.  
This call has now been rewritten to make use of
rtc_read_persistent_clock().

 As rtc_set_mmss() used by rtc_update_persistent_clock() may sleep for
some hardware, the call is now made from a work queue scheduled by the
timer originally used for the entire function.  However, following
DavidW's suggestion, the mutex in rtc_set_mmss() is now obtained with
mutex_trylock() a failure of which makes the function terminate, so that
latency from the caller to the point where hardware is accessed is
minimised.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
patch-2.6.26-rc1-20080505-rtc-persistent-clock-14
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/Kconfig linux-2.6.26-rc1-20080505/drivers/rtc/Kconfig
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/Kconfig	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/Kconfig	2008-05-05 21:41:34.000000000 +0000
@@ -21,24 +21,30 @@ menuconfig RTC_CLASS
 if RTC_CLASS
 
 config RTC_HCTOSYS
-	bool "Set system time from RTC on startup and resume"
+	bool "Use time from RTC as a reference for the system time"
 	depends on RTC_CLASS = y
 	default y
 	help
-	  If you say yes here, the system time (wall clock) will be set using
-	  the value read from a specified RTC device. This is useful to avoid
-	  unnecessary fsck runs at boot time, and to network better.
+	  If you say yes here, the specified RTC device will be used
+	  as a reference to the system time (wall clock).  The device
+	  will be used to set the system time as required during
+	  startup, suspend and, for platforms that support such usage,
+	  for NTP timekeeping.
+
+	  This is useful to avoid unnecessary fsck runs at boot time,
+	  and to network better.
 
 config RTC_HCTOSYS_DEVICE
-	string "RTC used to set the system time"
+	string "RTC used as a reference for the system time"
 	depends on RTC_HCTOSYS = y
 	default "rtc0"
 	help
-	  The RTC device that will be used to (re)initialize the system
+	  The RTC device that will be used as a reference for the system
 	  clock, usually rtc0.  Initialization is done when the system
-	  starts up, and when it resumes from a low power state.  This
-	  device should record time in UTC, since the kernel won't do
-	  timezone correction.
+	  starts up, and when it resumes from a low power state.  Also,
+	  if supported by the platform, NTP timekeeping uses this device
+	  to record the system time periodically.  This device should
+	  record time in UTC, since the kernel won't do timezone correction.
 
 	  The driver for this RTC device must be loaded before late_initcall
 	  functions run, so it must usually be statically linked.
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/hctosys.c linux-2.6.26-rc1-20080505/drivers/rtc/hctosys.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/hctosys.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/hctosys.c	2008-05-11 19:18:19.000000000 +0000
@@ -1,8 +1,9 @@
 /*
- * RTC subsystem, initialize system time on startup
+ * RTC subsystem, persistent clock and startup initialization support
  *
  * Copyright (C) 2005 Tower Technologies
  * Author: Alessandro Zummo <a.zummo@towertech.it>
+ * Copyright (C) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -22,46 +23,86 @@
  * the best guess is to add 0.5s.
  */
 
-static int __init rtc_hctosys(void)
+/*
+ * Note the unusual API:
+ * zero returned means a failure, anything else is seconds from epoch.
+ */
+unsigned long rtc_read_persistent_clock(void)
 {
-	int err;
-	struct rtc_time tm;
 	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+	struct rtc_time tm;
+	unsigned long time = 0;
 
 	if (rtc == NULL) {
-		printk("%s: unable to open rtc device (%s)\n",
-			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
-		return -ENODEV;
+		printk(KERN_ERR "hctosys: unable to open rtc device (%s)\n",
+		       CONFIG_RTC_HCTOSYS_DEVICE);
+		goto out;
+	}
+	if (rtc_read_time(rtc, &tm) < 0) {
+		dev_err(rtc->dev.parent,
+			"hctosys: unable to read the hardware clock\n");
+		goto out_close;
 	}
+	if (rtc_valid_tm(&tm) < 0) {
+		dev_err(rtc->dev.parent, "hctosys: invalid date/time\n");
+		goto out_close;
+	}
+
+	rtc_tm_to_time(&tm, &time);
+
+out_close:
+	rtc_class_close(rtc);
+out:
+	return time;
+}
+
+int rtc_update_persistent_clock(struct timespec now)
+{
+	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+	int err;
 
-	err = rtc_read_time(rtc, &tm);
-	if (err == 0) {
-		err = rtc_valid_tm(&tm);
-		if (err == 0) {
-			struct timespec tv;
-
-			tv.tv_nsec = NSEC_PER_SEC >> 1;
-
-			rtc_tm_to_time(&tm, &tv.tv_sec);
-
-			do_settimeofday(&tv);
-
-			dev_info(rtc->dev.parent,
-				"setting system clock to "
-				"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
-				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-				tm.tm_hour, tm.tm_min, tm.tm_sec,
-				(unsigned int) tv.tv_sec);
-		}
-		else
+	if (rtc == NULL) {
+		printk(KERN_ERR "hctosys: unable to open rtc device (%s)\n",
+		       CONFIG_RTC_HCTOSYS_DEVICE);
+		err = -ENXIO;
+		goto out;
+	}
+	err = rtc_set_mmss(rtc, now.tv_sec);
+	if (err < 0) {
+		if (err != -EBUSY)
 			dev_err(rtc->dev.parent,
-				"hctosys: invalid date/time\n");
+				"hctosys: unable to set the hardware clock\n");
+		goto out_close;
 	}
-	else
-		dev_err(rtc->dev.parent,
-			"hctosys: unable to read the hardware clock\n");
 
+	err = 0;
+
+out_close:
 	rtc_class_close(rtc);
+out:
+	return err;
+}
+
+static int __init rtc_hctosys(void)
+{
+	struct rtc_time tm;
+	struct timespec tv;
+	unsigned long time;
+
+	time = rtc_read_persistent_clock();
+	if (!time)
+		return -ENODEV;
+
+	tv.tv_nsec = NSEC_PER_SEC >> 1;
+	tv.tv_sec = time;
+	do_settimeofday(&tv);
+
+	rtc_time_to_tm(time, &tm);
+	pr_info("%s: setting system clock to "
+		"%d-%02d-%02d %02d:%02d:%02d UTC (%lu)\n",
+		CONFIG_RTC_HCTOSYS_DEVICE,
+		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+		tm.tm_hour, tm.tm_min, tm.tm_sec, (unsigned long)tv.tv_sec);
 
 	return 0;
 }
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/interface.c linux-2.6.26-rc1-20080505/drivers/rtc/interface.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/interface.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/interface.c	2008-05-11 19:32:40.000000000 +0000
@@ -64,8 +64,7 @@ int rtc_set_mmss(struct rtc_device *rtc,
 {
 	int err;
 
-	err = mutex_lock_interruptible(&rtc->ops_lock);
-	if (err)
+	if (!mutex_trylock(&rtc->ops_lock))
 		return -EBUSY;
 
 	if (!rtc->ops)
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/include/linux/rtc.h linux-2.6.26-rc1-20080505/include/linux/rtc.h
--- linux-2.6.26-rc1-20080505.macro/include/linux/rtc.h	2008-05-05 02:55:59.000000000 +0000
+++ linux-2.6.26-rc1-20080505/include/linux/rtc.h	2008-05-05 21:10:50.000000000 +0000
@@ -200,6 +200,9 @@ extern int rtc_irq_set_state(struct rtc_
 extern int rtc_irq_set_freq(struct rtc_device *rtc,
 				struct rtc_task *task, int freq);
 
+extern unsigned long rtc_read_persistent_clock(void);
+extern int rtc_update_persistent_clock(struct timespec now);
+
 typedef struct rtc_task {
 	void (*func)(void *private_data);
 	void *private_data;
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/kernel/time/ntp.c linux-2.6.26-rc1-20080505/kernel/time/ntp.c
--- linux-2.6.26-rc1-20080505.macro/kernel/time/ntp.c	2008-05-05 02:56:03.000000000 +0000
+++ linux-2.6.26-rc1-20080505/kernel/time/ntp.c	2008-05-05 21:10:50.000000000 +0000
@@ -3,6 +3,8 @@
  *
  * NTP state machine interfaces and logic.
  *
+ * Copyright (c) 2008  Maciej W. Rozycki
+ *
  * This code was mainly moved from kernel/timer.c and kernel/time.c
  * Please see those files for relevant copyright info and historical
  * changelogs.
@@ -17,6 +19,7 @@
 #include <linux/capability.h>
 #include <linux/math64.h>
 #include <linux/clocksource.h>
+#include <linux/workqueue.h>
 #include <asm/timex.h>
 
 /*
@@ -218,11 +221,13 @@ void second_overflow(void)
 /* Disable the cmos update - used by virtualization and embedded */
 int no_sync_cmos_clock  __read_mostly;
 
-static void sync_cmos_clock(unsigned long dummy);
+static void sync_cmos_clock(unsigned long data);
+static void do_sync_cmos_clock(struct work_struct *work);
 
 static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0);
+static DECLARE_WORK(sync_cmos_work, do_sync_cmos_clock);
 
-static void sync_cmos_clock(unsigned long dummy)
+static void do_sync_cmos_clock(struct work_struct *work)
 {
 	struct timespec now, next;
 	int fail = 1;
@@ -261,6 +266,12 @@ static void sync_cmos_clock(unsigned lon
 	mod_timer(&sync_cmos_timer, jiffies + timespec_to_jiffies(&next));
 }
 
+static void sync_cmos_clock(unsigned long data)
+{
+	/* Some implementations of update_persistent_clock() may sleep.  */
+	schedule_work(&sync_cmos_work);
+}
+
 static void notify_cmos_timer(void)
 {
 	if (!no_sync_cmos_clock)
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/kernel/time/timekeeping.c linux-2.6.26-rc1-20080505/kernel/time/timekeeping.c
--- linux-2.6.26-rc1-20080505.macro/kernel/time/timekeeping.c	2008-05-05 02:56:03.000000000 +0000
+++ linux-2.6.26-rc1-20080505/kernel/time/timekeeping.c	2008-05-05 21:10:50.000000000 +0000
@@ -242,7 +242,11 @@ unsigned long __attribute__((weak)) read
 void __init timekeeping_init(void)
 {
 	unsigned long flags;
-	unsigned long sec = read_persistent_clock();
+	unsigned long sec = 0;
+
+#ifndef CONFIG_RTC_HCTOSYS
+	sec = read_persistent_clock();
+#endif
 
 	write_seqlock_irqsave(&xtime_lock, flags);
 

From macro@linux-mips.org Tue May 13 04:27:15 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:27:19 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:18675 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20031567AbYEMD07 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:26:59 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3QioF003671;
	Tue, 13 May 2008 05:26:44 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3QhHB003667;
	Tue, 13 May 2008 04:26:43 +0100
Date:	Tue, 13 May 2008 04:26:43 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] RTC: Build SWARM support as an object (#2)
Message-ID: <Pine.LNX.4.55.0805130238550.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19235
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2442
Lines: 46

 Build the SWARM platform library is as an object rather than an archive
so that files which only contain symbols used by initcalls and do not
provide any symbols that would pull them from an archive still work.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
patch-2.6.26-rc1-20080505-swarm-core-16
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/Makefile linux-2.6.26-rc1-20080505/arch/mips/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/Makefile	2008-05-05 02:55:23.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/Makefile	2008-05-05 21:10:50.000000000 +0000
@@ -538,19 +538,19 @@ cflags-$(CONFIG_SIBYTE_BCM1x80)	+= -Iinc
 # Sibyte SWARM board
 # Sibyte BCM91x80 (BigSur) board
 #
-libs-$(CONFIG_SIBYTE_CARMEL)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_CARMEL)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_CARMEL)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_CRHINE)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_CRHINE)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_CRHINE)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_CRHONE)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_CRHONE)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_CRHONE)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_RHONE)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_RHONE)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_RHONE)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_SENTOSA)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_SENTOSA)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_SENTOSA)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_SWARM)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_SWARM)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_SWARM)	:= 0xffffffff80100000
-libs-$(CONFIG_SIBYTE_BIGSUR)	+= arch/mips/sibyte/swarm/
+core-$(CONFIG_SIBYTE_BIGSUR)	+= arch/mips/sibyte/swarm/
 load-$(CONFIG_SIBYTE_BIGSUR)	:= 0xffffffff80100000
 
 #
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2004-01-29 04:57:05.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
@@ -1,3 +1,3 @@
-lib-y				= setup.o rtc_xicor1241.o rtc_m41t81.o
+obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
 
-lib-$(CONFIG_KGDB)		+= dbg_io.o
+obj-$(CONFIG_KGDB)		+= dbg_io.o

From macro@linux-mips.org Tue May 13 04:27:34 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:27:37 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:21235 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20031511AbYEMD10 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:27:26 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3RBUs003684;
	Tue, 13 May 2008 05:27:11 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3RA7h003680;
	Tue, 13 May 2008 04:27:10 +0100
Date:	Tue, 13 May 2008 04:27:10 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/6] RTC: SWARM I2C board initialization (#2)
Message-ID: <Pine.LNX.4.55.0805130249230.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19236
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 3742
Lines: 102

 The standard rtc-m41t80.c driver cannot be used with the SWARM as it is,
because the board does not provide setup information for the I2C core.  
As a result the bus and the address to probe for the M41T80 chip is not
known.

 Here is a set of changes that fix the problem:

1. swarm-i2c.c -- SWARM I2C board setup, currently for the M41T80 chip on 
   the bus #1 only (there is a MAX6654 temperature sensor on the bus #0 
   which may be added in the future if we have a driver for that chip).

2. The i2c-sibyte.c BCM1250A SMBus controller driver now registers its 
   buses as numbered so that board setup is correctly applied.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 I have renamed i2c-swarm.c to swarm-i2c.c for consistency with names 
of other files under arch/mips/.

 Please note this patch trivially depends on
patch-2.6.26-rc1-20080505-swarm-core-16 -- 2/6 of this set.

  Maciej

patch-2.6.26-rc1-20080505-swarm-i2c-17
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-13 03:11:43.000000000 +0000
@@ -1,3 +1,4 @@
 obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
 
+obj-$(CONFIG_I2C_BOARDINFO)	+= swarm-i2c.o
 obj-$(CONFIG_KGDB)		+= dbg_io.o
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/swarm-i2c.c linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/swarm-i2c.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/swarm-i2c.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/swarm-i2c.c	2008-05-13 03:11:26.000000000 +0000
@@ -0,0 +1,37 @@
+/*
+ *	arch/mips/sibyte/swarm/swarm-i2c.c
+ *
+ *	Broadcom BCM91250A (SWARM), etc. I2C platform setup.
+ *
+ *	Copyright (c) 2008  Maciej W. Rozycki
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License
+ *	as published by the Free Software Foundation; either version
+ *	2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+
+
+static struct i2c_board_info swarm_i2c_info1[] __initdata = {
+	{
+		I2C_BOARD_INFO("m41t81", 0x68),
+	},
+};
+
+static int __init swarm_i2c_init(void)
+{
+	int err;
+
+	err = i2c_register_board_info(1, swarm_i2c_info1,
+				      ARRAY_SIZE(swarm_i2c_info1));
+	if (err < 0)
+		printk(KERN_ERR
+		       "i2c-swarm: cannot register board I2C devices\n");
+	return err;
+}
+
+arch_initcall(swarm_i2c_init);
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c
--- linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c	2008-05-05 02:55:25.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c	2008-05-11 01:21:45.000000000 +0000
@@ -143,7 +143,7 @@ int __init i2c_sibyte_add_bus(struct i2c
 	csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
 	csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
 
-	return i2c_add_adapter(i2c_adap);
+	return i2c_add_numbered_adapter(i2c_adap);
 }
 
 
@@ -159,6 +159,7 @@ static struct i2c_adapter sibyte_board_a
 		.class		= I2C_CLASS_HWMON,
 		.algo		= NULL,
 		.algo_data	= &sibyte_board_data[0],
+		.nr		= 0,
 		.name		= "SiByte SMBus 0",
 	},
 	{
@@ -167,6 +168,7 @@ static struct i2c_adapter sibyte_board_a
 		.class		= I2C_CLASS_HWMON,
 		.algo		= NULL,
 		.algo_data	= &sibyte_board_data[1],
+		.nr		= 1,
 		.name		= "SiByte SMBus 1",
 	},
 };

From macro@linux-mips.org Tue May 13 04:27:52 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:27:55 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:28147 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022128AbYEMD1w (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:27:52 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3RY6N003703;
	Tue, 13 May 2008 05:27:34 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3RVVH003699;
	Tue, 13 May 2008 04:27:33 +0100
Date:	Tue, 13 May 2008 04:27:30 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] RTC: SMBus support for the M41T80, etc. driver (#2)
Message-ID: <Pine.LNX.4.55.0805130254420.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19237
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 10828
Lines: 376

 The BCM1250A SOC which is used on the SWARM board utilising an M41T81
chip only supports pure I2C in the raw bit-banged mode.  Nobody sane
really wants to use it unless absolutely necessary and the M41T80, etc.  
chips work just fine with an SMBus adapter which is what the standard mode
of operation of the BCM1250A.  The only drawback of byte accesses with the
M41T80 is the chip only latches clock data registers for the duration of
an I2C transaction which works fine with a block transfers, but not
byte-wise accesses.

 The driver currently requires an I2C adapter providing both SMBus and raw
I2C access.  This is a set of changes to make it work with any SMBus
adapter providing at least read byte and write byte protocols.  
Additionally, if a given SMBus adapter supports I2C block read and/or
write protocols (a common extension beyond the SMBus spec), they are used
as well.  The problem of unlatched clock data if SMBus byte transactions
are used is resolved in the standard way.  For raw I2C controllers this
functionality is provided by the I2C core as SMBus emulation in a
transparent way.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
patch-2.6.26-rc1-20080505-m41t80-smbus-17
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
@@ -6,6 +6,7 @@
  * Based on m41t00.c by Mark A. Greer <mgreer@mvista.com>
  *
  * 2006 (c) mycable GmbH
+ * Copyright (c) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -36,6 +37,8 @@
 #define M41T80_REG_DAY	5
 #define M41T80_REG_MON	6
 #define M41T80_REG_YEAR	7
+#define M41T80_REG_CONTROL	8
+#define M41T80_REG_WATCHDOG	9
 #define M41T80_REG_ALARM_MON	0xa
 #define M41T80_REG_ALARM_DAY	0xb
 #define M41T80_REG_ALARM_HOUR	0xc
@@ -58,7 +61,7 @@
 #define M41T80_FEATURE_HT	(1 << 0)
 #define M41T80_FEATURE_BL	(1 << 1)
 
-#define DRV_VERSION "0.05"
+#define DRV_VERSION "0.06"
 
 static const struct i2c_device_id m41t80_id[] = {
 	{ "m41t80", 0 },
@@ -78,31 +81,83 @@ struct m41t80_data {
 	struct rtc_device *rtc;
 };
 
-static int m41t80_get_datetime(struct i2c_client *client,
-			       struct rtc_time *tm)
+
+static int m41t80_write_block_data(struct i2c_client *client,
+				   u8 reg, u8 num, u8 *buf)
 {
-	u8 buf[M41T80_DATETIME_REG_SIZE], dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
+	int i, rc;
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
-		dev_err(&client->dev, "read error\n");
-		return -EIO;
+	if (i2c_check_functionality(client->adapter,
+				    I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
+		i = i2c_smbus_write_i2c_block_data(client, reg, num, buf);
+	} else {
+		for (i = 0; i < num; i++) {
+			rc = i2c_smbus_write_byte_data(client, reg + i,
+						       buf[i]);
+			if (rc < 0) {
+				i = rc;
+				goto out;
+			}
+		}
+	}
+out:
+	return i;
+}
+
+static int m41t80_read_block_data(struct i2c_client *client,
+				  u8 reg, u8 num, u8 *buf)
+{
+	int i, rc;
+
+	if (i2c_check_functionality(client->adapter,
+				    I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
+		i = i2c_smbus_read_i2c_block_data(client, reg, num, buf);
+	} else {
+		for (i = 0; i < num; i++) {
+			rc = i2c_smbus_read_byte_data(client, reg + i);
+			if (rc < 0) {
+				i = rc;
+				goto out;
+			}
+			buf[i] = rc;
+		}
 	}
+out:
+	return i;
+}
+
+static int m41t80_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+	u8 buf[M41T80_DATETIME_REG_SIZE];
+	int loops = 2;
+	int sec0, sec1;
+
+	/*
+	 * Time registers are latched by this chip if an I2C block
+	 * transfer is used, but with SMBus-style byte accesses
+	 * this is not the case, so check seconds for a wraparound.
+	 */
+	do {
+		if (m41t80_read_block_data(client, M41T80_REG_SEC,
+					   M41T80_DATETIME_REG_SIZE -
+					   M41T80_REG_SEC,
+					   buf + M41T80_REG_SEC) < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+		sec0 = buf[M41T80_REG_SEC];
 
-	tm->tm_sec = BCD2BIN(buf[M41T80_REG_SEC] & 0x7f);
+		sec1 = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+		if (sec1 < 0) {
+			dev_err(&client->dev, "read error\n");
+			return -EIO;
+		}
+
+		sec0 = BCD2BIN(sec0 & 0x7f);
+		sec1 = BCD2BIN(sec1 & 0x7f);
+	} while (sec1 < sec0 && --loops);
+
+	tm->tm_sec = sec1;
 	tm->tm_min = BCD2BIN(buf[M41T80_REG_MIN] & 0x7f);
 	tm->tm_hour = BCD2BIN(buf[M41T80_REG_HOUR] & 0x3f);
 	tm->tm_mday = BCD2BIN(buf[M41T80_REG_DAY] & 0x3f);
@@ -117,39 +172,16 @@ static int m41t80_get_datetime(struct i2
 /* Sets the given date and time to the real time clock. */
 static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm)
 {
-	u8 wbuf[1 + M41T80_DATETIME_REG_SIZE];
-	u8 *buf = &wbuf[1];
-	u8 dt_addr[1] = { M41T80_REG_SEC };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
-			.buf	= buf + M41T80_REG_SEC,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_DATETIME_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
+	u8 buf[M41T80_DATETIME_REG_SIZE];
 
 	/* Read current reg values into buf[1..7] */
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_read_block_data(client, M41T80_REG_SEC,
+				   M41T80_DATETIME_REG_SIZE - M41T80_REG_SEC,
+				   buf + M41T80_REG_SEC) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
 
-	wbuf[0] = 0; /* offset into rtc's regs */
 	/* Merge time-data and register flags into buf[0..7] */
 	buf[M41T80_REG_SSEC] = 0;
 	buf[M41T80_REG_SEC] =
@@ -167,7 +199,8 @@ static int m41t80_set_datetime(struct i2
 	/* assume 20YY not 19YY */
 	buf[M41T80_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_write_block_data(client, M41T80_REG_SSEC,
+				    M41T80_DATETIME_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -241,34 +274,11 @@ err:
 static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	u8 wbuf[1 + M41T80_ALARM_REG_SIZE];
-	u8 *buf = &wbuf[1];
+	u8 buf[M41T80_ALARM_REG_SIZE];
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
-	struct i2c_msg msgs_in[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE,
-			.buf	= buf,
-		},
-	};
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1 + M41T80_ALARM_REG_SIZE,
-			.buf	= wbuf,
-		 },
-	};
 
-	if (i2c_transfer(client->adapter, msgs_in, 2) < 0) {
+	if (m41t80_read_block_data(client, M41T80_REG_ALARM_MON,
+				   M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -278,7 +288,6 @@ static int m41t80_rtc_set_alarm(struct d
 	reg[M41T80_REG_ALARM_MIN] = 0;
 	reg[M41T80_REG_ALARM_SEC] = 0;
 
-	wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */
 	reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ?
 		BIN2BCD(t->time.tm_sec) : 0x80;
 	reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ?
@@ -292,7 +301,8 @@ static int m41t80_rtc_set_alarm(struct d
 	else
 		reg[M41T80_REG_ALARM_DAY] |= 0x40;
 
-	if (i2c_transfer(client->adapter, msgs, 1) != 1) {
+	if (m41t80_write_block_data(client, M41T80_REG_ALARM_MON,
+				    M41T80_ALARM_REG_SIZE, buf) < 0) {
 		dev_err(&client->dev, "write error\n");
 		return -EIO;
 	}
@@ -312,24 +322,10 @@ static int m41t80_rtc_read_alarm(struct 
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	u8 buf[M41T80_ALARM_REG_SIZE + 1]; /* all alarm regs and flags */
-	u8 dt_addr[1] = { M41T80_REG_ALARM_MON };
 	u8 *reg = buf - M41T80_REG_ALARM_MON;
-	struct i2c_msg msgs[] = {
-		{
-			.addr	= client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= dt_addr,
-		},
-		{
-			.addr	= client->addr,
-			.flags	= I2C_M_RD,
-			.len	= M41T80_ALARM_REG_SIZE + 1,
-			.buf	= buf,
-		},
-	};
 
-	if (i2c_transfer(client->adapter, msgs, 2) < 0) {
+	if (m41t80_read_block_data(client, M41T80_REG_ALARM_MON,
+				   M41T80_ALARM_REG_SIZE + 1, buf) < 0) {
 		dev_err(&client->dev, "read error\n");
 		return -EIO;
 	}
@@ -488,26 +484,16 @@ static int boot_flag;
  */
 static void wdt_ping(void)
 {
-	unsigned char i2c_data[2];
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-	i2c_data[0] = 0x09;		/* watchdog register */
+	u8 wdt = 0x80;				/* WDS = 1 (0x80)  */
 
 	if (wdt_margin > 31)
-		i2c_data[1] = (wdt_margin & 0xFC) | 0x83; /* resolution = 4s */
+		/* mulitplier = WD_TIMO / 4, resolution = 4s (0x3)  */
+		wdt |= (wdt_margin & 0xfc) | 0x3;
 	else
-		/*
-		 * WDS = 1 (0x80), mulitplier = WD_TIMO, resolution = 1s (0x02)
-		 */
-		i2c_data[1] = wdt_margin<<2 | 0x82;
+		/* mulitplier = WD_TIMO, resolution = 1s (0x2)  */
+		wdt |= wdt_margin << 2 | 0x2;
 
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, wdt);
 }
 
 /**
@@ -517,36 +503,8 @@ static void wdt_ping(void)
  */
 static void wdt_disable(void)
 {
-	unsigned char i2c_data[2], i2c_buf[0x10];
-	struct i2c_msg msgs0[2] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 1,
-			.buf	= i2c_data,
-		},
-		{
-			.addr	= save_client->addr,
-			.flags	= I2C_M_RD,
-			.len	= 1,
-			.buf	= i2c_buf,
-		},
-	};
-	struct i2c_msg msgs1[1] = {
-		{
-			.addr	= save_client->addr,
-			.flags	= 0,
-			.len	= 2,
-			.buf	= i2c_data,
-		},
-	};
-
-	i2c_data[0] = 0x09;
-	i2c_transfer(save_client->adapter, msgs0, 2);
-
-	i2c_data[0] = 0x09;
-	i2c_data[1] = 0x00;
-	i2c_transfer(save_client->adapter, msgs1, 1);
+	i2c_smbus_read_byte_data(save_client, M41T80_REG_WATCHDOG);
+	i2c_smbus_write_byte_data(save_client, M41T80_REG_WATCHDOG, 0);
 }
 
 /**
@@ -737,8 +695,8 @@ static int m41t80_probe(struct i2c_clien
 	struct rtc_time tm;
 	struct m41t80_data *clientdata = NULL;
 
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C
-				     | I2C_FUNC_SMBUS_BYTE_DATA)) {
+	if (!i2c_check_functionality(client->adapter,
+				     I2C_FUNC_SMBUS_BYTE_DATA)) {
 		rc = -ENODEV;
 		goto exit;
 	}

From macro@linux-mips.org Tue May 13 04:28:11 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:28:14 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:31731 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022203AbYEMD16 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:27:58 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3RhpN003714;
	Tue, 13 May 2008 05:27:43 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3Rgnk003710;
	Tue, 13 May 2008 04:27:42 +0100
Date:	Tue, 13 May 2008 04:27:42 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/6] RTC: Trivially probe for an M41T80 (#2)
Message-ID: <Pine.LNX.4.55.0805130303430.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19238
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 2719
Lines: 81

 When probing the driver try to access the device with a read to one of
its registers and exit silently if the read fails.  This is so that boards
may register this device unconditionally and do not trigger error messages
at the bootstrap, where there is no other way to determine if an
M41T80-class RTC is actually there.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 Please note this patch trivially depends on 
patch-2.6.26-rc1-20080505-m41t80-smbus-17 -- 5/6 of this set.

  Maciej

patch-2.6.26-rc1-20080505-m41t80-probe-18
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c
--- linux-2.6.26-rc1-20080505.macro/drivers/rtc/rtc-m41t80.c	2008-05-05 02:55:40.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/rtc/rtc-m41t80.c	2008-05-11 00:30:54.000000000 +0000
@@ -690,10 +690,11 @@ static struct notifier_block wdt_notifie
 static int m41t80_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
-	int rc = 0;
 	struct rtc_device *rtc = NULL;
 	struct rtc_time tm;
 	struct m41t80_data *clientdata = NULL;
+	int reg;
+	int rc;
 
 	if (!i2c_check_functionality(client->adapter,
 				     I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -701,6 +702,13 @@ static int m41t80_probe(struct i2c_clien
 		goto exit;
 	}
 
+	/* Trivially check it's there; keep the result for the HT check. */
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
+	if (reg < 0) {
+		rc = -ENXIO;
+		goto exit;
+	}
+
 	dev_info(&client->dev,
 		 "chip found, driver version " DRV_VERSION "\n");
 
@@ -723,11 +731,7 @@ static int m41t80_probe(struct i2c_clien
 	i2c_set_clientdata(client, clientdata);
 
 	/* Make sure HT (Halt Update) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
-	if (rc < 0)
-		goto ht_err;
-
-	if (rc & M41T80_ALHOUR_HT) {
+	if (reg & M41T80_ALHOUR_HT) {
 		if (clientdata->features & M41T80_FEATURE_HT) {
 			m41t80_get_datetime(client, &tm);
 			dev_info(&client->dev, "HT bit was set!\n");
@@ -740,18 +744,18 @@ static int m41t80_probe(struct i2c_clien
 		}
 		if (i2c_smbus_write_byte_data(client,
 					      M41T80_REG_ALARM_HOUR,
-					      rc & ~M41T80_ALHOUR_HT) < 0)
+					      reg & ~M41T80_ALHOUR_HT) < 0)
 			goto ht_err;
 	}
 
 	/* Make sure ST (stop) bit is cleared */
-	rc = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
-	if (rc < 0)
+	reg = i2c_smbus_read_byte_data(client, M41T80_REG_SEC);
+	if (reg < 0)
 		goto st_err;
 
-	if (rc & M41T80_SEC_ST) {
+	if (reg & M41T80_SEC_ST) {
 		if (i2c_smbus_write_byte_data(client, M41T80_REG_SEC,
-					      rc & ~M41T80_SEC_ST) < 0)
+					      reg & ~M41T80_SEC_ST) < 0)
 			goto st_err;
 	}
 

From macro@linux-mips.org Tue May 13 04:28:29 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:28:33 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:33779 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20022366AbYEMD2C (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:28:02 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3RMNI003693;
	Tue, 13 May 2008 05:27:22 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3RLTn003689;
	Tue, 13 May 2008 04:27:21 +0100
Date:	Tue, 13 May 2008 04:27:20 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Alessandro Zummo <a.zummo@towertech.it>,
	Andrew Morton <akpm@linux-foundation.org>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean Delvare <khali@linux-fr.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Thomas Gleixner <tglx@linutronix.de>
cc:	rtc-linux@googlegroups.com, i2c@lm-sensors.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] RTC: SWARM class device persistent clock support (#2)
Message-ID: <Pine.LNX.4.55.0805130251570.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19239
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 11685
Lines: 365

 This is a set of changes removing the SWARM platform driver for the
M41T81 and "wiring" the class RTC driver for the persistent clock instead.  
The Xicor clock is unaffected as we have no class driver for this device.
Weak variations of the rtc_read_persistent_clock() and 
rtc_update_persistent_clock() calls are provided as the default -- to be 
overridden by the RTC driver.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 Please note this patch trivially depends on
patch-2.6.26-rc1-20080505-swarm-core-16 -- 2/6 of this set.

  Maciej

patch-2.6.26-rc1-20080505-swarm-m41t80-11
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/kernel/time.c linux-2.6.26-rc1-20080505/arch/mips/kernel/time.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/kernel/time.c	2008-05-05 02:55:23.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/kernel/time.c	2008-05-05 21:10:50.000000000 +0000
@@ -44,7 +44,7 @@ int __weak rtc_mips_set_mmss(unsigned lo
 	return rtc_mips_set_time(nowtime);
 }
 
-int update_persistent_clock(struct timespec now)
+int __weak update_persistent_clock(struct timespec now)
 {
 	return rtc_mips_set_mmss(now.tv_sec);
 }
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:18:21.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/Makefile	2008-05-06 01:25:40.000000000 +0000
@@ -1,4 +1,4 @@
-obj-y				:= setup.o rtc_xicor1241.o rtc_m41t81.o
+obj-y				:= setup.o rtc_xicor1241.o
 
 obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-swarm.o
 obj-$(CONFIG_KGDB)		+= dbg_io.o
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/rtc_m41t81.c linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/rtc_m41t81.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/rtc_m41t81.c	2007-10-11 04:56:52.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/rtc_m41t81.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2000, 2001 Broadcom Corporation
- *
- * Copyright (C) 2002 MontaVista Software Inc.
- * Author: jsun@mvista.com or jsun@junsun.net
- *
- * This program is free software; you can redistribute	it and/or modify it
- * under  the terms of	the GNU General	 Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- *
- */
-#include <linux/bcd.h>
-#include <linux/types.h>
-#include <linux/time.h>
-
-#include <asm/time.h>
-#include <asm/addrspace.h>
-#include <asm/io.h>
-
-#include <asm/sibyte/sb1250.h>
-#include <asm/sibyte/sb1250_regs.h>
-#include <asm/sibyte/sb1250_smbus.h>
-
-
-/* M41T81 definitions */
-
-/*
- * Register bits
- */
-
-#define M41T81REG_SC_ST		0x80		/* stop bit */
-#define M41T81REG_HR_CB		0x40		/* century bit */
-#define M41T81REG_HR_CEB	0x80		/* century enable bit */
-#define M41T81REG_CTL_S		0x20		/* sign bit */
-#define M41T81REG_CTL_FT	0x40		/* frequency test bit */
-#define M41T81REG_CTL_OUT	0x80		/* output level */
-#define M41T81REG_WD_RB0	0x01		/* watchdog resolution bit 0 */
-#define M41T81REG_WD_RB1	0x02		/* watchdog resolution bit 1 */
-#define M41T81REG_WD_BMB0	0x04		/* watchdog multiplier bit 0 */
-#define M41T81REG_WD_BMB1	0x08		/* watchdog multiplier bit 1 */
-#define M41T81REG_WD_BMB2	0x10		/* watchdog multiplier bit 2 */
-#define M41T81REG_WD_BMB3	0x20		/* watchdog multiplier bit 3 */
-#define M41T81REG_WD_BMB4	0x40		/* watchdog multiplier bit 4 */
-#define M41T81REG_AMO_ABE	0x20		/* alarm in "battery back-up mode" enable bit */
-#define M41T81REG_AMO_SQWE	0x40		/* square wave enable */
-#define M41T81REG_AMO_AFE	0x80		/* alarm flag enable flag */
-#define M41T81REG_ADT_RPT5	0x40		/* alarm repeat mode bit 5 */
-#define M41T81REG_ADT_RPT4	0x80		/* alarm repeat mode bit 4 */
-#define M41T81REG_AHR_RPT3	0x80		/* alarm repeat mode bit 3 */
-#define M41T81REG_AHR_HT	0x40		/* halt update bit */
-#define M41T81REG_AMN_RPT2	0x80		/* alarm repeat mode bit 2 */
-#define M41T81REG_ASC_RPT1	0x80		/* alarm repeat mode bit 1 */
-#define M41T81REG_FLG_AF	0x40		/* alarm flag (read only) */
-#define M41T81REG_FLG_WDF	0x80		/* watchdog flag (read only) */
-#define M41T81REG_SQW_RS0	0x10		/* sqw frequency bit 0 */
-#define M41T81REG_SQW_RS1	0x20		/* sqw frequency bit 1 */
-#define M41T81REG_SQW_RS2	0x40		/* sqw frequency bit 2 */
-#define M41T81REG_SQW_RS3	0x80		/* sqw frequency bit 3 */
-
-
-/*
- * Register numbers
- */
-
-#define M41T81REG_TSC	0x00		/* tenths/hundredths of second */
-#define M41T81REG_SC	0x01		/* seconds */
-#define M41T81REG_MN	0x02		/* minute */
-#define M41T81REG_HR	0x03		/* hour/century */
-#define M41T81REG_DY	0x04		/* day of week */
-#define M41T81REG_DT	0x05		/* date of month */
-#define M41T81REG_MO	0x06		/* month */
-#define M41T81REG_YR	0x07		/* year */
-#define M41T81REG_CTL	0x08		/* control */
-#define M41T81REG_WD	0x09		/* watchdog */
-#define M41T81REG_AMO	0x0A		/* alarm: month */
-#define M41T81REG_ADT	0x0B		/* alarm: date */
-#define M41T81REG_AHR	0x0C		/* alarm: hour */
-#define M41T81REG_AMN	0x0D		/* alarm: minute */
-#define M41T81REG_ASC	0x0E		/* alarm: second */
-#define M41T81REG_FLG	0x0F		/* flags */
-#define M41T81REG_SQW	0x13		/* square wave register */
-
-#define M41T81_CCR_ADDRESS	0x68
-
-#define SMB_CSR(reg)	IOADDR(A_SMB_REGISTER(1, reg))
-
-static int m41t81_read(uint8_t addr)
-{
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	__raw_writeq(addr & 0xff, SMB_CSR(R_SMB_CMD));
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_WR1BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_RD1BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	if (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_ERROR) {
-		/* Clear error bit by writing a 1 */
-		__raw_writeq(M_SMB_ERROR, SMB_CSR(R_SMB_STATUS));
-		return -1;
-	}
-
-	return (__raw_readq(SMB_CSR(R_SMB_DATA)) & 0xff);
-}
-
-static int m41t81_write(uint8_t addr, int b)
-{
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	__raw_writeq(addr & 0xff, SMB_CSR(R_SMB_CMD));
-	__raw_writeq(b & 0xff, SMB_CSR(R_SMB_DATA));
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_WR2BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	if (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_ERROR) {
-		/* Clear error bit by writing a 1 */
-		__raw_writeq(M_SMB_ERROR, SMB_CSR(R_SMB_STATUS));
-		return -1;
-	}
-
-	/* read the same byte again to make sure it is written */
-	__raw_writeq(V_SMB_ADDR(M41T81_CCR_ADDRESS) | V_SMB_TT_RD1BYTE,
-		     SMB_CSR(R_SMB_START));
-
-	while (__raw_readq(SMB_CSR(R_SMB_STATUS)) & M_SMB_BUSY)
-		;
-
-	return 0;
-}
-
-int m41t81_set_time(unsigned long t)
-{
-	struct rtc_time tm;
-	unsigned long flags;
-
-	/* Note we don't care about the century */
-	rtc_time_to_tm(t, &tm);
-
-	/*
-	 * Note the write order matters as it ensures the correctness.
-	 * When we write sec, 10th sec is clear.  It is reasonable to
-	 * believe we should finish writing min within a second.
-	 */
-
-	spin_lock_irqsave(&rtc_lock, flags);
-	tm.tm_sec = BIN2BCD(tm.tm_sec);
-	m41t81_write(M41T81REG_SC, tm.tm_sec);
-
-	tm.tm_min = BIN2BCD(tm.tm_min);
-	m41t81_write(M41T81REG_MN, tm.tm_min);
-
-	tm.tm_hour = BIN2BCD(tm.tm_hour);
-	tm.tm_hour = (tm.tm_hour & 0x3f) | (m41t81_read(M41T81REG_HR) & 0xc0);
-	m41t81_write(M41T81REG_HR, tm.tm_hour);
-
-	/* tm_wday starts from 0 to 6 */
-	if (tm.tm_wday == 0) tm.tm_wday = 7;
-	tm.tm_wday = BIN2BCD(tm.tm_wday);
-	m41t81_write(M41T81REG_DY, tm.tm_wday);
-
-	tm.tm_mday = BIN2BCD(tm.tm_mday);
-	m41t81_write(M41T81REG_DT, tm.tm_mday);
-
-	/* tm_mon starts from 0, *ick* */
-	tm.tm_mon ++;
-	tm.tm_mon = BIN2BCD(tm.tm_mon);
-	m41t81_write(M41T81REG_MO, tm.tm_mon);
-
-	/* we don't do century, everything is beyond 2000 */
-	tm.tm_year %= 100;
-	tm.tm_year = BIN2BCD(tm.tm_year);
-	m41t81_write(M41T81REG_YR, tm.tm_year);
-	spin_unlock_irqrestore(&rtc_lock, flags);
-
-	return 0;
-}
-
-unsigned long m41t81_get_time(void)
-{
-	unsigned int year, mon, day, hour, min, sec;
-	unsigned long flags;
-
-	/*
-	 * min is valid if two reads of sec are the same.
-	 */
-	for (;;) {
-		spin_lock_irqsave(&rtc_lock, flags);
-		sec = m41t81_read(M41T81REG_SC);
-		min = m41t81_read(M41T81REG_MN);
-		if (sec == m41t81_read(M41T81REG_SC)) break;
-		spin_unlock_irqrestore(&rtc_lock, flags);
-	}
-	hour = m41t81_read(M41T81REG_HR) & 0x3f;
-	day = m41t81_read(M41T81REG_DT);
-	mon = m41t81_read(M41T81REG_MO);
-	year = m41t81_read(M41T81REG_YR);
-	spin_unlock_irqrestore(&rtc_lock, flags);
-
-	sec = BCD2BIN(sec);
-	min = BCD2BIN(min);
-	hour = BCD2BIN(hour);
-	day = BCD2BIN(day);
-	mon = BCD2BIN(mon);
-	year = BCD2BIN(year);
-
-	year += 2000;
-
-	return mktime(year, mon, day, hour, min, sec);
-}
-
-int m41t81_probe(void)
-{
-	unsigned int tmp;
-
-	/* enable chip if it is not enabled yet */
-	tmp = m41t81_read(M41T81REG_SC);
-	m41t81_write(M41T81REG_SC, tmp & 0x7f);
-
-	return (m41t81_read(M41T81REG_SC) != -1);
-}
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/setup.c linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/setup.c
--- linux-2.6.26-rc1-20080505.macro/arch/mips/sibyte/swarm/setup.c	2007-10-23 02:55:20.000000000 +0000
+++ linux-2.6.26-rc1-20080505/arch/mips/sibyte/swarm/setup.c	2008-05-05 21:10:50.000000000 +0000
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
  * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
+ * Copyright (C) 2008  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -29,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/screen_info.h>
 #include <linux/initrd.h>
+#include <linux/rtc.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
@@ -60,10 +62,6 @@ extern int xicor_probe(void);
 extern int xicor_set_time(unsigned long);
 extern unsigned long xicor_get_time(void);
 
-extern int m41t81_probe(void);
-extern int m41t81_set_time(unsigned long);
-extern unsigned long m41t81_get_time(void);
-
 const char *get_system_type(void)
 {
 	return "SiByte " SIBYTE_BOARD_NAME;
@@ -82,38 +80,41 @@ int swarm_be_handler(struct pt_regs *reg
 enum swarm_rtc_type {
 	RTC_NONE,
 	RTC_XICOR,
-	RTC_M4LT81
 };
 
 enum swarm_rtc_type swarm_rtc_type;
 
+unsigned long __weak rtc_read_persistent_clock(void)
+{
+	return mktime(2000, 1, 1, 0, 0, 0);
+}
+
+int __weak rtc_update_persistent_clock(struct timespec now)
+{
+	return 0;
+}
+
 unsigned long read_persistent_clock(void)
 {
 	switch (swarm_rtc_type) {
 	case RTC_XICOR:
 		return xicor_get_time();
 
-	case RTC_M4LT81:
-		return m41t81_get_time();
-
 	case RTC_NONE:
 	default:
-		return mktime(2000, 1, 1, 0, 0, 0);
+		return rtc_read_persistent_clock();
 	}
 }
 
-int rtc_mips_set_time(unsigned long sec)
+int update_persistent_clock(struct timespec now)
 {
 	switch (swarm_rtc_type) {
 	case RTC_XICOR:
-		return xicor_set_time(sec);
-
-	case RTC_M4LT81:
-		return m41t81_set_time(sec);
+		return xicor_set_time(now.tv_sec);
 
 	case RTC_NONE:
 	default:
-		return -1;
+		return rtc_update_persistent_clock(now);
 	}
 }
 
@@ -133,8 +134,6 @@ void __init plat_mem_setup(void)
 
 	if (xicor_probe())
 		swarm_rtc_type = RTC_XICOR;
-	if (m41t81_probe())
-		swarm_rtc_type = RTC_M4LT81;
 
 	printk("This kernel optimized for "
 #ifdef CONFIG_SIMULATION

From macro@linux-mips.org Tue May 13 04:28:48 2008
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 13 May 2008 04:28:53 +0100 (BST)
Received: from kirk.serum.com.pl ([213.77.9.205]:38899 "EHLO serum.com.pl")
	by ftp.linux-mips.org with ESMTP id S20025258AbYEMD2e (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 13 May 2008 04:28:34 +0100
Received: from serum.com.pl (IDENT:macro@localhost [127.0.0.1])
	by serum.com.pl (8.12.11/8.12.11) with ESMTP id m4D3SQIr003731;
	Tue, 13 May 2008 05:28:26 +0200
Received: from localhost (macro@localhost)
	by serum.com.pl (8.12.11/8.12.11/Submit) with ESMTP id m4D3SPeD003727;
	Tue, 13 May 2008 04:28:25 +0100
Date:	Tue, 13 May 2008 04:28:25 +0100 (BST)
From:	"Maciej W. Rozycki" <macro@linux-mips.org>
To:	Jean Delvare <khali@linux-fr.org>,
	Andrew Morton <akpm@linux-foundation.org>
cc:	i2c@lm-sensors.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] I2C: SiByte: Convert the driver to make use of interrupts
Message-ID: <Pine.LNX.4.55.0805130353250.535@cliff.in.clinika.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <macro@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 19240
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: macro@linux-mips.org
Precedence: bulk
X-list: linux-mips
Content-Length: 12533
Lines: 411

 This is a rewrite of large parts of the driver mainly so that it uses 
SMBus interrupts to offload the CPU from busy-waiting on status inputs.  
As a part of the overhaul of the init and exit calls, all accesses to the 
hardware got converted to use accessory functions via an ioremap() cookie.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 This patch depends on patch-2.6.26-rc1-20080505-swarm-i2c-16 -- submitted 
as a part of the recent set of M41T80 RTC changes.

 Jean, please let me know if you prefer the ioremap() changes separately.  
Similarly, how about the -EINVAL/-EIO error codes?  Also please note how I
hesitated from adding second space after final full stops within comments.

  Maciej

patch-2.6.26-rc1-20080505-sibyte-i2c-irq-5
diff -up --recursive --new-file linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c
--- linux-2.6.26-rc1-20080505.macro/drivers/i2c/busses/i2c-sibyte.c	2008-05-11 02:25:56.000000000 +0000
+++ linux-2.6.26-rc1-20080505/drivers/i2c/busses/i2c-sibyte.c	2008-05-12 06:00:16.000000000 +0000
@@ -2,6 +2,7 @@
  * Copyright (C) 2004 Steven J. Hill
  * Copyright (C) 2001,2002,2003 Broadcom Corporation
  * Copyright (C) 1995-2000 Simon G. Vogl
+ * Copyright (C) 2008 Maciej W. Rozycki
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -18,104 +19,159 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#include <linux/errno.h>
+#include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#includ