Re: [PATCH] lockdep: Include all lock classes in all_lock_classes

2008-02-03 Thread Dale Farnsworth
On Sun, Feb 03, 2008 at 04:21:02PM +0100, Peter Zijlstra wrote:
> On Fri, 2008-02-01 at 08:21 -0700, Dale Farnsworth wrote:
> > Add each lock class to the all_lock_classes list when it is
> > first registered.
> > 
> > Previously, lock classes were added to all_lock_classes when
> > the lock class was first used. 
> 
> > Since one of the uses of the list is to find unused locks, this didn't
> > work well.
> 
> You mean in lockdep_proc.c to generate the statistics?

Yes, that's where I noticed it.  On my platform, there was one
unused lock which was missed.
> 
> Another potential issue might be count_matching_names() generating a
> wrong class version.

I haven't looked into that issue yet.

-Dale
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] lockdep: Include all lock classes in all_lock_classes

2008-02-01 Thread Dale Farnsworth
Add each lock class to the all_lock_classes list when it is
first registered.

Previously, lock classes were added to all_lock_classes when
the lock class was first used.  Since one of the uses of the
list is to find unused locks, this didn't work well.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 kernel/lockdep.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 723bd9f..e630127 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -779,6 +779,10 @@ register_lock_class(struct lockdep_map *lock, unsigned int 
subclass, int force)
 * parallel walking of the hash-list safe:
 */
list_add_tail_rcu(&class->hash_entry, hash_head);
+   /*
+* Add it to the global list of classes:
+*/
+   list_add_tail_rcu(&class->lock_entry, &all_lock_classes);
 
if (verbose(class)) {
graph_unlock();
@@ -2282,10 +2286,6 @@ static int mark_lock(struct task_struct *curr, struct 
held_lock *this,
return 0;
break;
case LOCK_USED:
-   /*
-* Add it to the global list of classes:
-*/
-   list_add_tail_rcu(&this->class->lock_entry, &all_lock_classes);
debug_atomic_dec(&nr_unused_locks);
break;
default:
-- 
1.5.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [POWERPC] Fix fallout from sg_page changes

2007-10-23 Thread Dale Farnsworth
On Tue, Oct 23, 2007 at 08:44:48PM +0200, Jens Axboe wrote:
> On Tue, Oct 23 2007, Dale Farnsworth wrote:
> > 
> > Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
> > ---
> >  include/asm-powerpc/dma-mapping.h |   10 +-
> >  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> Should already be merged in Linus' current tree.

Yes, it is.  Thank you.

-Dale
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] [POWERPC] Fix fallout from sg_page changes

2007-10-23 Thread Dale Farnsworth

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 include/asm-powerpc/dma-mapping.h |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/asm-powerpc/dma-mapping.h 
b/include/asm-powerpc/dma-mapping.h
index 65be95d..43b4f3b 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -285,9 +285,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sgl, int 
nents,
BUG_ON(direction == DMA_NONE);
 
for_each_sg(sgl, sg, nents, i) {
-   BUG_ON(!sg->page);
-   __dma_sync_page(sg->page, sg->offset, sg->length, direction);
-   sg->dma_address = page_to_bus(sg->page) + sg->offset;
+   BUG_ON(!sg_page(sg));
+   __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
+   sg->dma_address = virt_to_bus(sg_virt(sg));
}
 
return nents;
@@ -328,7 +328,7 @@ static inline void dma_sync_sg_for_cpu(struct device *dev,
BUG_ON(direction == DMA_NONE);
 
for_each_sg(sgl, sg, nents, i)
-   __dma_sync_page(sg->page, sg->offset, sg->length, direction);
+   __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
 }
 
 static inline void dma_sync_sg_for_device(struct device *dev,
@@ -341,7 +341,7 @@ static inline void dma_sync_sg_for_device(struct device 
*dev,
BUG_ON(direction == DMA_NONE);
 
for_each_sg(sgl, sg, nents, i)
-   __dma_sync_page(sg->page, sg->offset, sg->length, direction);
+   __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
 }
 
 static inline int dma_mapping_error(dma_addr_t dma_addr)
-- 
1.5.3.4

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel crashes inside MV643xx driver

2007-09-05 Thread Dale Farnsworth
On Wed, Sep 05, 2007 at 08:24:52AM -0700, Andrew Morton wrote:
> > On Mon, 20 Aug 2007 14:38:57 +0800 gshan <[EMAIL PROTECTED]> wrote:
> > Hi All,
> > 
> > After I started the NFS server, it crashed:
> > 
> > <3>Badness in local_bh_enable at 
> > /home/cli4/sandbox/main/TelicaRoot/components/mvlinux/cge/devkit/lsp/7xx/linux/kernel/softirq.c:195
> > Badness in local_bh_enable at 
> > /home/cli4/sandbox/main/TelicaRoot/components/mvlinux/cge/devkit/lsp/7xx/linux/kernel/softirq.c:195
> > Call trace:
> >  [c0005340] check_bug_trap+0xbc/0x11c
> >  [c0005604] ProgramCheckException+0x264/0x2bc
> >  [c0004ac4] ret_from_except_full+0x0/0x4c
> >  [c0022ae4] local_bh_enable+0x18/0x80
> >  [c024648c] skb_copy_bits+0x168/0x3b8
> >  [c024db44] __skb_linearize+0x90/0x150
> >  [c020e8a4] mv643xx_eth_start_xmit+0x4c0/0x5bc
> >  [c025c934] qdisc_restart+0xac/0x2bc
> >  [c024de9c] dev_queue_xmit+0x298/0x34c
> >  [c0269814] ip_finish_output+0x140/0x2b8
> >  [c026a3ac] ip_fragment+0x3cc/0x6e0
> >  [c026bac8] ip_push_pending_frames+0x3dc/0x46c
> >  [c0289ec4] udp_push_pending_frames+0x10c/0x1cc
> >  [c028a7c4] udp_sendpage+0x104/0x188
> >  [c0292fc8] inet_sendpage+0x90/0xb8
> > 
> > I searched the webs and found the similar problems:
> > http://www.mail-archive.com/[EMAIL PROTECTED]/msg05199.html
> > http://oss.sgi.com/archives/netdev/2005-09/msg00025.html
> > 
> > Who knew there are fixes for the problem?
> > 
> 
> Well that got a tremendous response, didn't it?
> 
> What do you mean by "crashed"?  The above is a warning and the system
> should have survived.
> 
> Which kernel version is being used?

That is the key question.  From the pathnames, I suspect that gshan is
using a MontaVista version.  I'm still (especially) interested, since
MontaVista pays me.

BTW, I never received the original message on netdev or linux-kernel.
Hmm.  Thanks to Andrew for replying.

-Dale
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/11, corrected] mv64x60_wdt: Rework the timeout register manipulation

2007-07-24 Thread Dale Farnsworth
mv64x60_wdt: Rework the timeout register manipulation

Consolidate the timeout config register modification into a single
function.  Also, use the enabled flag in the config register to
determine whether the timer is enabled instead of a separately
maintained flag, MV64x60_WDOG_FLAG_ENABLED.

Add spinlock protection around enabling/disabling the watchdog timer.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
Oops!  I mistakenly sent an earlier version of this patch.  Please
disregard it and replace it with this one.

 drivers/char/watchdog/mv64x60_wdt.c |   90 +++---
 1 file changed, 54 insertions(+), 36 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 20:05:04.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-24 
18:28:58.0 +
@@ -29,75 +29,95 @@
 
 #define MV64x60_WDT_WDC_OFFSET 0
 
-/* MV64x60 WDC (config) register access definitions */
-#define MV64x60_WDC_CTL1_MASK  (3 << 24)
-#define MV64x60_WDC_CTL1(val)  ((val & 3) << 24)
-#define MV64x60_WDC_CTL2_MASK  (3 << 26)
-#define MV64x60_WDC_CTL2(val)  ((val & 3) << 26)
+/*
+ * The watchdog configuration register contains a pair of 2-bit fields,
+ *   1.  a reload field, bits 27-26, which triggers a reload of
+ *   the countdown register, and
+ *   2.  an enable field, bits 25-24, which toggles between
+ *   enabling and disabling the watchdog timer.
+ * Bit 31 is a read-only field which indicates whether the
+ * watchdog timer is currently enabled.
+ *
+ * The low 24 bits contain the timer reload value.
+ */
+#define MV64x60_WDC_ENABLE_SHIFT   24
+#define MV64x60_WDC_SERVICE_SHIFT  26
+#define MV64x60_WDC_ENABLED_SHIFT  31
+
+#define MV64x60_WDC_ENABLED_TRUE   1
+#define MV64x60_WDC_ENABLED_FALSE  0
 
 /* Flags bits */
 #define MV64x60_WDOG_FLAG_OPENED   0
-#define MV64x60_WDOG_FLAG_ENABLED  1
 
 static unsigned long wdt_flags;
 static int wdt_status;
 static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
+static int mv64x60_wdt_count;
 static unsigned int bus_clk;
 static char expect_close;
+static DEFINE_SPINLOCK(mv64x60_wdt_spinlock);
 
 static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
-static void mv64x60_wdt_reg_write(u32 val)
+static int mv64x60_wdt_toggle_wdc(int enabled_predicate, int field_shift)
 {
-   /* Allow write only to CTL1 / CTL2 fields, retaining values in
-* other fields.
-*/
-   u32 data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
-   data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK);
-   data |= val;
-   writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+   u32 data;
+   u32 enabled;
+   int ret = 0;
+
+   spin_lock(&mv64x60_wdt_spinlock);
+   data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+   enabled = (data >> MV64x60_WDC_ENABLED_SHIFT) & 1;
+
+   /* only toggle the requested field if enabled state matches predicate */
+   if ((enabled ^ enabled_predicate) == 0) {
+   /* We write a 1, then a 2 -- to the appropriate field */
+   data = (1 << field_shift) | mv64x60_wdt_count;
+   writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+
+   data = (2 << field_shift) | mv64x60_wdt_count;
+   writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+   ret = 1;
+   }
+   spin_unlock(&mv64x60_wdt_spinlock);
+
+   return ret;
 }
 
 static void mv64x60_wdt_service(void)
 {
-   /* Write 01 followed by 10 to CTL2 */
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x01));
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x02));
+   mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE,
+  MV64x60_WDC_SERVICE_SHIFT);
 }
 
-static void mv64x60_wdt_handler_disable(void)
+static void mv64x60_wdt_handler_enable(void)
 {
-   if (test_and_clear_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) {
-   /* Write 01 followed by 10 to CTL1 */
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01));
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02));
-   printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n");
+   if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_FALSE,
+  MV64x60_WDC_ENABLE_SHIFT)) {
+   mv64x60_wdt_service();
+   printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n");
}
 }
 
-static void mv64x60_wdt_handler_enable(void)
+static void mv64x60_wdt_handler_

[PATCH 10/11] mv64x60_wdt: disable watchdog timer when driver is probed

2007-07-24 Thread Dale Farnsworth
Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 19:33:30.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
19:34:23.0 +
@@ -262,6 +262,8 @@ static int __devinit mv64x60_wdt_probe(s
 
mv64x60_wdt_set_timeout(timeout);
 
+   mv64x60_wdt_handler_disable();  /* in case timer was already running */
+
return misc_register(&mv64x60_wdt_miscdev);
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/11] mv64x60_wdt_cleanup_low_level_wdt_code.patch

2007-07-24 Thread Dale Farnsworth
Consolidate the timeout config register modification into a single
function.  Also, use the enabled flag in the config register to
determine whether the timer is enabled instead of a separately
maintained flag, MV64x60_WDOG_FLAG_ENABLED.

Add spinlock protection around enabling/disabling the watchdog timer.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |   85 +++---
 1 file changed, 51 insertions(+), 34 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 20:05:04.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-21 
12:51:59.0 +
@@ -26,78 +26,97 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MV64x60_WDT_WDC_OFFSET 0
 
-/* MV64x60 WDC (config) register access definitions */
-#define MV64x60_WDC_CTL1_MASK  (3 << 24)
-#define MV64x60_WDC_CTL1(val)  ((val & 3) << 24)
-#define MV64x60_WDC_CTL2_MASK  (3 << 26)
-#define MV64x60_WDC_CTL2(val)  ((val & 3) << 26)
+/*
+ * The watchdog configuration register contains a pair of 2-bit fields,
+ *   1.  a reload field, bits 27-26, which triggers a reload of
+ *   the countdown register, and
+ *   2.  an enable field, bits 25-24, which toggles between
+ *   enabling and disabling the watchdog timer.
+ * Bit 31 is a read-only field which indicates whether the
+ * watchdog timer is currently enabled.
+ *
+ * The low 24 bits contain the timer reload value.
+ */
+#define MV64x60_WDC_ENABLE_SHIFT   24
+#define MV64x60_WDC_LOAD_SHIFT 26
+#define MV64x60_WDC_ENABLED_SHIFT  31
 
 /* Flags bits */
 #define MV64x60_WDOG_FLAG_OPENED   0
-#define MV64x60_WDOG_FLAG_ENABLED  1
 
 static unsigned long wdt_flags;
 static int wdt_status;
 static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
+static int mv64x60_wdt_count;
 static unsigned int bus_clk;
 static char expect_close;
+static DEFINE_SPINLOCK(mv64x60_wdt_spinlock);
 
 static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
-static void mv64x60_wdt_reg_write(u32 val)
+static void mv64x60_wdt_update_wdc(int field_shift)
 {
-   /* Allow write only to CTL1 / CTL2 fields, retaining values in
-* other fields.
-*/
-   u32 data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
-   data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK);
-   data |= val;
+   u32 data;
+
+   /* We write a 1, then a 2 -- to the appropriate field */
+   data = (1 << field_shift) | mv64x60_wdt_count;
+   writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+
+   data = (2 << field_shift) | mv64x60_wdt_count;
writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
 }
 
 static void mv64x60_wdt_service(void)
 {
-   /* Write 01 followed by 10 to CTL2 */
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x01));
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x02));
+   spin_lock(&mv64x60_wdt_spinlock);
+   mv64x60_wdt_update_wdc(MV64x60_WDC_LOAD_SHIFT);
+   spin_unlock(&mv64x60_wdt_spinlock);
 }
 
-static void mv64x60_wdt_handler_disable(void)
+static void mv64x60_wdt_handler_enable(void)
 {
-   if (test_and_clear_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) {
-   /* Write 01 followed by 10 to CTL1 */
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01));
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02));
-   printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n");
+   u32 data;
+
+   spin_lock(&mv64x60_wdt_spinlock);
+   data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+
+   if (!(data & (1 << MV64x60_WDC_ENABLED_SHIFT))) {
+   mv64x60_wdt_update_wdc(MV64x60_WDC_ENABLE_SHIFT);
+   mv64x60_wdt_service();
+   printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n");
}
+   spin_unlock(&mv64x60_wdt_spinlock);
 }
 
-static void mv64x60_wdt_handler_enable(void)
+static void mv64x60_wdt_handler_disable(void)
 {
-   if (!test_and_set_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) {
-   /* Write 01 followed by 10 to CTL1 */
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01));
-   mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02));
-   printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n");
+   u32 data;
+
+   spin_lock(&mv64x60_wdt_spinlock);
+   data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+
+   if (data & (1 << MV64x60_WDC_ENABLED_SHIFT)) {
+   mv

[PATCH 09/11] mv64x60_wdt: Support the WDIOF_MAGICCLOSE feature

2007-07-24 Thread Dale Farnsworth
Disallow disabling of the watchdog timer unless a particular
character ('V') was recently written to the watchdog device.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |   28 ++
 1 file changed, 24 insertions(+), 4 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 19:32:41.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
19:33:30.0 +
@@ -44,6 +44,7 @@ static int wdt_status;
 static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
 static unsigned int bus_clk;
+static char expect_close;
 
 static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
@@ -115,10 +116,14 @@ static int mv64x60_wdt_open(struct inode
 
 static int mv64x60_wdt_release(struct inode *inode, struct file *file)
 {
-   mv64x60_wdt_service();
-
-   if (!nowayout)
+   if (expect_close == 42)
mv64x60_wdt_handler_disable();
+   else {
+   printk(KERN_CRIT
+  "mv64x60_wdt: unexpected close, not stopping timer!\n");
+   mv64x60_wdt_service();
+   }
+   expect_close = 0;
 
clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags);
 
@@ -128,8 +133,22 @@ static int mv64x60_wdt_release(struct in
 static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data,
 size_t len, loff_t * ppos)
 {
-   if (len)
+   if (len) {
+   if (!nowayout) {
+   size_t i;
+
+   expect_close = 0;
+
+   for (i = 0; i != len; i++) {
+   char c;
+   if(get_user(c, data + i))
+   return -EFAULT;
+   if (c == 'V')
+   expect_close = 42;
+   }
+   }
mv64x60_wdt_service();
+   }
 
return len;
 }
@@ -142,6 +161,7 @@ static int mv64x60_wdt_ioctl(struct inod
void __user *argp = (void __user *)arg;
static struct watchdog_info info = {
.options =  WDIOF_SETTIMEOUT|
+   WDIOF_MAGICCLOSE|
WDIOF_KEEPALIVEPING,
.firmware_version = 0,
.identity = "MV64x60 watchdog",

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/11] mv64x60_wdt: Support for WDIOC_SETTIMEOUT ioctl

2007-07-24 Thread Dale Farnsworth
Add the ability to modify the watchdog timer timeout interval.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |   38 +-
 1 file changed, 31 insertions(+), 7 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 19:32:08.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
19:42:01.0 +
@@ -43,6 +43,7 @@ static unsigned long wdt_flags;
 static int wdt_status;
 static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
+static unsigned int bus_clk;
 
 static void mv64x60_wdt_reg_write(u32 val)
 {
@@ -82,6 +83,18 @@ static void mv64x60_wdt_handler_enable(v
}
 }
 
+static void mv64x60_wdt_set_timeout(int timeout)
+{
+   /* maximum bus cycle count is 0x */
+   if (timeout > 0x / bus_clk)
+   timeout = 0x / bus_clk;
+
+   mv64x60_wdt_timeout = timeout;
+   writel((timeout * bus_clk) >> 8,
+  mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+   mv64x60_wdt_service();
+}
+
 static int mv64x60_wdt_open(struct inode *inode, struct file *file)
 {
if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags))
@@ -118,9 +131,11 @@ static ssize_t mv64x60_wdt_write(struct 
 static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
 unsigned int cmd, unsigned long arg)
 {
+   int timeout;
void __user *argp = (void __user *)arg;
static struct watchdog_info info = {
-   .options = WDIOF_KEEPALIVEPING,
+   .options =  WDIOF_SETTIMEOUT|
+   WDIOF_KEEPALIVEPING,
.firmware_version = 0,
.identity = "MV64x60 watchdog",
};
@@ -150,7 +165,10 @@ static int mv64x60_wdt_ioctl(struct inod
break;
 
case WDIOC_SETTIMEOUT:
-   return -EOPNOTSUPP;
+   if (get_user(timeout, (int __user *)argp))
+   return -EFAULT;
+   mv64x60_wdt_set_timeout(timeout);
+   /* Fall through */
 
case WDIOC_GETTIMEOUT:
if (put_user(mv64x60_wdt_timeout, (int __user *)argp))
@@ -182,15 +200,22 @@ static struct miscdevice mv64x60_wdt_mis
 static int __devinit mv64x60_wdt_probe(struct platform_device *dev)
 {
struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data;
-   int bus_clk = 133;
struct resource *r;
+   int timeout = 10;
 
-   mv64x60_wdt_timeout = 10;
+   bus_clk = 133;  /* in MHz */
if (pdata) {
-   mv64x60_wdt_timeout = pdata->timeout;
+   timeout = pdata->timeout;
bus_clk = pdata->bus_clk;
}
 
+   /* Since bus_clk is truncated MHz, actual frequency could be
+* up to 1MHz higher.  Round up, since it's better to time out
+* too late than too soon.
+*/
+   bus_clk++;
+   bus_clk *= 100; /* convert to Hz */
+
r = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!r)
return -ENODEV;
@@ -199,8 +224,7 @@ static int __devinit mv64x60_wdt_probe(s
if (mv64x60_wdt_regs == NULL)
return -ENOMEM;
 
-   writel((mv64x60_wdt_timeout * (bus_clk * 100)) >> 8,
-  mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
+   mv64x60_wdt_set_timeout(timeout);
 
return misc_register(&mv64x60_wdt_miscdev);
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/11] mv64x60_wdt: Add WDIOC_SETOPTIONS ioctl support

2007-07-24 Thread Dale Farnsworth
Allow the watchdog timer to be enabled or disabled via the
WDIOC_SETOPTIONS ioctl.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 19:29:15.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
19:29:34.0 +
@@ -132,6 +132,7 @@ static int mv64x60_wdt_ioctl(struct inod
 unsigned int cmd, unsigned long arg)
 {
int timeout;
+   int options;
void __user *argp = (void __user *)arg;
static struct watchdog_info info = {
.options =  WDIOF_SETTIMEOUT|
@@ -157,7 +158,15 @@ static int mv64x60_wdt_ioctl(struct inod
return -EOPNOTSUPP;
 
case WDIOC_SETOPTIONS:
-   return -EOPNOTSUPP;
+   if (get_user(options, (int __user *)argp))
+   return -EFAULT;
+
+   if (options & WDIOS_DISABLECARD)
+   mv64x60_wdt_handler_disable();
+
+   if (options & WDIOS_ENABLECARD)
+   mv64x60_wdt_handler_enable();
+   break;
 
case WDIOC_KEEPALIVE:
mv64x60_wdt_service();

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/11] mv64x60_wdt: Add a module parameter to change nowayout setting

2007-07-24 Thread Dale Farnsworth
Also, use the WATCHDOG_NOWAYOUT macro, rather than #ifdefs,
and use __module_get to prevent module unloading if WATCHDOG_NOWAYOUT
is set.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-19 22:11:42.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-19 
22:34:01.0 +
@@ -45,6 +45,10 @@ static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
 static unsigned int bus_clk;
 
+static int nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, int, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
 static void mv64x60_wdt_reg_write(u32 val)
 {
/* Allow write only to CTL1 / CTL2 fields, retaining values in
@@ -99,6 +103,9 @@ static int mv64x60_wdt_open(struct inode
if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags))
return -EBUSY;
 
+   if (nowayout)
+   __module_get(THIS_MODULE);
+
mv64x60_wdt_service();
mv64x60_wdt_handler_enable();
 
@@ -109,9 +116,8 @@ static int mv64x60_wdt_release(struct in
 {
mv64x60_wdt_service();
 
-#if !defined(CONFIG_WATCHDOG_NOWAYOUT)
-   mv64x60_wdt_handler_disable();
-#endif
+   if (!nowayout)
+   mv64x60_wdt_handler_disable();
 
clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags);
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/11] mv64x60_wdt: Fix WDIOC_GETTIMEOUT return value

2007-07-24 Thread Dale Farnsworth
WDIOC_GETTIMEOUT returns seconds, not jiffies.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 19:17:17.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
19:23:23.0 +
@@ -118,7 +118,6 @@ static ssize_t mv64x60_wdt_write(struct 
 static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
 unsigned int cmd, unsigned long arg)
 {
-   int timeout;
void __user *argp = (void __user *)arg;
static struct watchdog_info info = {
.options = WDIOF_KEEPALIVEPING,
@@ -154,8 +153,7 @@ static int mv64x60_wdt_ioctl(struct inod
return -EOPNOTSUPP;
 
case WDIOC_GETTIMEOUT:
-   timeout = mv64x60_wdt_timeout * HZ;
-   if (put_user(timeout, (int __user *)argp))
+   if (put_user(mv64x60_wdt_timeout, (int __user *)argp))
return -EFAULT;
break;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/11] mv64x60_wdt: Check return value of nonseekable_open

2007-07-24 Thread Dale Farnsworth
Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-19 21:39:15.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-19 
21:40:13.0 +
@@ -90,9 +90,7 @@ static int mv64x60_wdt_open(struct inode
mv64x60_wdt_service();
mv64x60_wdt_handler_enable();
 
-   nonseekable_open(inode, file);
-
-   return 0;
+   return nonseekable_open(inode, file);
 }
 
 static int mv64x60_wdt_release(struct inode *inode, struct file *file)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/11] mv64x60_wdt: Add arch/powerpc platform support

2007-07-24 Thread Dale Farnsworth
Add support for arch/powerpc, specifically for  the prpmc2800 platform.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 arch/powerpc/boot/dts/prpmc2800.dts |6 ++
 arch/powerpc/sysdev/mv64x60_dev.c   |   64 ++
 drivers/char/watchdog/mv64x60_wdt.c |2 
 include/asm-ppc/mv64x60.h   |8 ---
 include/linux/mv643xx.h |8 +++
 5 files changed, 79 insertions(+), 9 deletions(-)

Index: linux-2.6-powerpc-wdt/arch/powerpc/boot/dts/prpmc2800.dts
===
--- linux-2.6-powerpc-wdt.orig/arch/powerpc/boot/dts/prpmc2800.dts  
2007-07-20 16:41:08.0 +
+++ linux-2.6-powerpc-wdt/arch/powerpc/boot/dts/prpmc2800.dts   2007-07-20 
16:42:09.0 +
@@ -207,6 +207,12 @@
interrupt-parent = <&/mv64x60/pic>;
};
 
+   [EMAIL PROTECTED] { /* watchdog timer */
+   compatible = "marvell,mv64x60-wdt";
+   reg = ;
+   timeout = ;  /* wdt timeout in seconds */
+   };
+
[EMAIL PROTECTED] {
device_type = "i2c";
compatible = "marvell,mv64x60-i2c";
Index: linux-2.6-powerpc-wdt/arch/powerpc/sysdev/mv64x60_dev.c
===
--- linux-2.6-powerpc-wdt.orig/arch/powerpc/sysdev/mv64x60_dev.c
2007-07-20 16:41:08.0 +
+++ linux-2.6-powerpc-wdt/arch/powerpc/sysdev/mv64x60_dev.c 2007-07-20 
16:45:26.0 +
@@ -390,6 +390,61 @@ error:
return err;
 }
 
+/*
+ * Create mv64x60_wdt platform devices
+ */
+static int __init mv64x60_wdt_device_setup(struct device_node *np, int id)
+{
+   struct resource r;
+   struct platform_device *pdev;
+   struct mv64x60_wdt_pdata pdata;
+   const unsigned int *prop;
+   int err;
+
+   err = of_address_to_resource(np, 0, &r);
+   if (err)
+   return err;
+
+   memset(&pdata, 0, sizeof(pdata));
+
+   prop = of_get_property(np, "timeout", NULL);
+   if (!prop)
+   return -ENODEV;
+   pdata.timeout = *prop;
+
+   np = of_get_parent(np);
+   if (!np)
+   return -ENODEV;
+
+   prop = of_get_property(np, "clock-frequency", NULL);
+   of_node_put(np);
+   if (!prop)
+   return -ENODEV;
+   pdata.bus_clk = *prop / 100; /* wdt driver wants freq in MHz */
+
+   pdev = platform_device_alloc(MV64x60_WDT_NAME, id);
+   if (!pdev)
+   return -ENOMEM;
+
+   err = platform_device_add_resources(pdev, &r, 1);
+   if (err)
+   goto error;
+
+   err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+   if (err)
+   goto error;
+
+   err = platform_device_add(pdev);
+   if (err)
+   goto error;
+
+   return 0;
+
+error:
+   platform_device_put(pdev);
+   return err;
+}
+
 static int __init mv64x60_device_setup(void)
 {
struct device_node *np = NULL;
@@ -414,6 +469,15 @@ static int __init mv64x60_device_setup(v
if ((err = mv64x60_i2c_device_setup(np, id)))
goto error;
 
+   /* support up to one watchdog timer */
+   np = of_find_compatible_node(np, NULL, "marvell,mv64x60-wdt");
+   if (np) {
+   if ((err = mv64x60_wdt_device_setup(np, id)))
+   goto error;
+   of_node_put(np);
+   }
+
+
return 0;
 
 error:
Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 16:41:37.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
16:48:00.0 +
@@ -23,7 +23,7 @@
 #include 
 #include 
 
-#include 
+#include 
 #include 
 #include 
 
Index: linux-2.6-powerpc-wdt/include/asm-ppc/mv64x60.h
===
--- linux-2.6-powerpc-wdt.orig/include/asm-ppc/mv64x60.h2007-07-20 
16:41:11.0 +
+++ linux-2.6-powerpc-wdt/include/asm-ppc/mv64x60.h 2007-07-20 
16:42:09.0 +
@@ -120,14 +120,6 @@ extern spinlock_t mv64x60_lock;
 
 #defineMV64x60_64BIT_WIN_COUNT 24
 
-/* Watchdog Platform Device, Driver Data */
-#defineMV64x60_WDT_NAME"mv64x60_wdt"
-
-struct mv64x60_wdt_pdata {
-   int timeout;/* watchdog expiry in seconds, default 10 */
-   int bus_clk;/* bus clock in MHz, default 133 */
-};
-
 /*
  * Define a structure that's used to pass in config information to the
  * core routines.
Index: linux-2.6-powerp

[PATCH 02/11] mv64x60_wdt: Get register address from platform data

2007-07-24 Thread Dale Farnsworth
Previously, the address of the watchdog timer registers was
retrieved by calling a global function, mv64x60_get_bridge_vbase().
That function doesn't exist in arch/powerpc.  Instead, we now get
the register address from a platform data resource and ioremap
the registers within the driver.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/char/watchdog/mv64x60_wdt.c |   21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-18 23:12:48.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-19 
00:05:37.0 +
@@ -27,6 +27,8 @@
 #include 
 #include 
 
+#define MV64x60_WDT_WDC_OFFSET 0
+
 /* MV64x60 WDC (config) register access definitions */
 #define MV64x60_WDC_CTL1_MASK  (3 << 24)
 #define MV64x60_WDC_CTL1(val)  ((val & 3) << 24)
@@ -39,7 +41,7 @@
 
 static unsigned long wdt_flags;
 static int wdt_status;
-static void __iomem *mv64x60_regs;
+static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
 
 static void mv64x60_wdt_reg_write(u32 val)
@@ -47,10 +49,10 @@ static void mv64x60_wdt_reg_write(u32 va
/* Allow write only to CTL1 / CTL2 fields, retaining values in
 * other fields.
 */
-   u32 data = readl(mv64x60_regs + MV64x60_WDT_WDC);
+   u32 data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK);
data |= val;
-   writel(data, mv64x60_regs + MV64x60_WDT_WDC);
+   writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
 }
 
 static void mv64x60_wdt_service(void)
@@ -185,6 +187,7 @@ static int __devinit mv64x60_wdt_probe(s
 {
struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data;
int bus_clk = 133;
+   struct resource *r;
 
mv64x60_wdt_timeout = 10;
if (pdata) {
@@ -192,10 +195,16 @@ static int __devinit mv64x60_wdt_probe(s
bus_clk = pdata->bus_clk;
}
 
-   mv64x60_regs = mv64x60_get_bridge_vbase();
+   r = platform_get_resource(dev, IORESOURCE_MEM, 0);
+   if (!r)
+   return -ENODEV;
+
+   mv64x60_wdt_regs = ioremap(r->start, r->end - r->start + 1);
+   if (mv64x60_wdt_regs == NULL)
+   return -ENOMEM;
 
writel((mv64x60_wdt_timeout * (bus_clk * 100)) >> 8,
-  mv64x60_regs + MV64x60_WDT_WDC);
+  mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
 
return misc_register(&mv64x60_wdt_miscdev);
 }
@@ -207,6 +216,8 @@ static int __devexit mv64x60_wdt_remove(
mv64x60_wdt_service();
mv64x60_wdt_handler_disable();
 
+   iounmap(mv64x60_wdt_regs);
+
return 0;
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/11] mv64x60_wdt: set up platform_device in platform code

2007-07-24 Thread Dale Farnsworth
The driver previously registered its platform device data in its own
init function--that's bogus.  Move that code to platform-specific
code in arch/ppc.  This is being done so that the platform code can
decide at runtime whether to initialize this driver or not.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 arch/ppc/syslib/mv64x60.c   |   29 ++
 drivers/char/watchdog/mv64x60_wdt.c |   26 ---
 include/asm-ppc/mv64x60.h   |2 -
 3 files changed, 31 insertions(+), 26 deletions(-)

Index: linux-2.6-powerpc-wdt/arch/ppc/syslib/mv64x60.c
===
--- linux-2.6-powerpc-wdt.orig/arch/ppc/syslib/mv64x60.c2007-07-20 
00:49:16.0 +
+++ linux-2.6-powerpc-wdt/arch/ppc/syslib/mv64x60.c 2007-07-20 
00:52:19.0 +
@@ -440,6 +440,32 @@ static struct platform_device i2c_device
 };
 #endif
 
+#ifdef CONFIG_WATCHDOG
+static struct mv64x60_wdt_pdata mv64x60_wdt_pdata = {
+   .timeout= 10,  /* default watchdog expiry in seconds */
+   .bus_clk= 133, /* default bus clock in MHz */
+};
+
+static struct resource mv64x60_wdt_resources[] = {
+   [0] = {
+   .name   = "mv64x60 wdt base",
+   .start  = MV64x60_WDT_WDC,
+   .end= MV64x60_WDT_WDC + 8 - 1, /* two 32-bit registers */
+   .flags  = IORESOURCE_MEM,
+   },
+};
+
+static struct platform_device wdt_device = {
+   .name   = MV64x60_WDT_NAME,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(mv64x60_wdt_resources),
+   .resource   = mv64x60_wdt_resources,
+   .dev = {
+   .platform_data = &mv64x60_wdt_pdata,
+   },
+};
+#endif
+
 #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
 static struct mv64xxx_pdata mv64xxx_pdata = {
.hs_reg_valid   = 0,
@@ -475,6 +501,9 @@ static struct platform_device *mv64x60_p
 #ifdef CONFIG_I2C_MV64XXX
&i2c_device,
 #endif
+#ifdef CONFIG_MV64X60_WDT
+   &wdt_device,
+#endif
 #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
&mv64xxx_device,
 #endif
Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c  
2007-07-20 00:49:16.0 +
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c   2007-07-20 
00:49:18.0 +
@@ -219,40 +219,16 @@ static struct platform_driver mv64x60_wd
},
 };
 
-static struct platform_device *mv64x60_wdt_dev;
-
 static int __init mv64x60_wdt_init(void)
 {
-   int ret;
-
printk(KERN_INFO "MV64x60 watchdog driver\n");
 
-   mv64x60_wdt_dev = platform_device_alloc(MV64x60_WDT_NAME, -1);
-   if (!mv64x60_wdt_dev) {
-   ret = -ENOMEM;
-   goto out;
-   }
-
-   ret = platform_device_add(mv64x60_wdt_dev);
-   if (ret) {
-   platform_device_put(mv64x60_wdt_dev);
-   goto out;
-   }
-
-   ret = platform_driver_register(&mv64x60_wdt_driver);
-   if (ret) {
-   platform_device_unregister(mv64x60_wdt_dev);
-   goto out;
-   }
-
- out:
-   return ret;
+   return platform_driver_register(&mv64x60_wdt_driver);
 }
 
 static void __exit mv64x60_wdt_exit(void)
 {
platform_driver_unregister(&mv64x60_wdt_driver);
-   platform_device_unregister(mv64x60_wdt_dev);
 }
 
 module_init(mv64x60_wdt_init);
Index: linux-2.6-powerpc-wdt/include/asm-ppc/mv64x60.h
===
--- linux-2.6-powerpc-wdt.orig/include/asm-ppc/mv64x60.h2007-07-20 
00:49:16.0 +
+++ linux-2.6-powerpc-wdt/include/asm-ppc/mv64x60.h 2007-07-20 
00:49:18.0 +
@@ -121,7 +121,7 @@ extern spinlock_t mv64x60_lock;
 #defineMV64x60_64BIT_WIN_COUNT 24
 
 /* Watchdog Platform Device, Driver Data */
-#defineMV64x60_WDT_NAME"wdt"
+#defineMV64x60_WDT_NAME"mv64x60_wdt"
 
 struct mv64x60_wdt_pdata {
int timeout;/* watchdog expiry in seconds, default 10 */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: update and use the MAX6900 century byte

2007-07-18 Thread Dale Farnsworth
We now read and write the century byte in the max6900 chip.
We probably don't need to do so on Linux-only system, but it's
necessary when the chip is shared by another OS that uses the
century byte.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
---
 drivers/rtc/rtc-max6900.c |   96 +++-
 1 file changed, 72 insertions(+), 24 deletions(-)

diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c
index eee4ee5..a1cd448 100644
--- a/drivers/rtc/rtc-max6900.c
+++ b/drivers/rtc/rtc-max6900.c
@@ -31,17 +31,24 @@
 #define MAX6900_REG_DW 5   /* day of week   1-7  */
 #define MAX6900_REG_YR 6   /* year 00-99 */
 #define MAX6900_REG_CT 7   /* control */
-#define MAX6900_REG_LEN8
+   /* register 8 is undocumented */
+#define MAX6900_REG_CENTURY9   /* century */
+#define MAX6900_REG_LEN10
+
+#define MAX6900_BURST_LEN  8   /* can burst r/w first 8 regs */
 
 #define MAX6900_REG_CT_WP  (1 << 7)/* Write Protect */
 
+
 /*
  * register read/write commands
  */
 #define MAX6900_REG_CONTROL_WRITE  0x8e
-#define MAX6900_REG_BURST_READ 0xbf
-#define MAX6900_REG_BURST_WRITE0xbe
+#define MAX6900_REG_CENTURY_WRITE  0x92
+#define MAX6900_REG_CENTURY_READ   0x93
 #define MAX6900_REG_RESERVED_READ  0x96
+#define MAX6900_REG_BURST_WRITE0xbe
+#define MAX6900_REG_BURST_READ 0xbf
 
 #define MAX6900_IDLE_TIME_AFTER_WRITE  3   /* specification says 2.5 mS */
 
@@ -58,19 +65,32 @@ static int max6900_probe(struct i2c_adapter *adapter, int 
addr, int kind);
 
 static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
 {
-   u8 reg_addr[1] = { MAX6900_REG_BURST_READ };
-   struct i2c_msg msgs[2] = {
+   u8 reg_burst_read[1] = { MAX6900_REG_BURST_READ };
+   u8 reg_century_read[1] = { MAX6900_REG_CENTURY_READ };
+   struct i2c_msg msgs[4] = {
{
.addr   = client->addr,
.flags  = 0, /* write */
-   .len= sizeof(reg_addr),
-   .buf= reg_addr
+   .len= sizeof(reg_burst_read),
+   .buf= reg_burst_read
},
{
.addr   = client->addr,
.flags  = I2C_M_RD,
-   .len= MAX6900_REG_LEN,
+   .len= MAX6900_BURST_LEN,
.buf= buf
+   },
+   {
+   .addr   = client->addr,
+   .flags  = 0, /* write */
+   .len= sizeof(reg_century_read),
+   .buf= reg_century_read
+   },
+   {
+   .addr   = client->addr,
+   .flags  = I2C_M_RD,
+   .len= sizeof(buf[MAX6900_REG_CENTURY]),
+   .buf= &buf[MAX6900_REG_CENTURY]
}
};
int rc;
@@ -86,33 +106,58 @@ static int max6900_i2c_read_regs(struct i2c_client 
*client, u8 *buf)
 
 static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
 {
-   u8 i2c_buf[MAX6900_REG_LEN + 1] = { MAX6900_REG_BURST_WRITE };
-   struct i2c_msg msgs[1] = {
+   u8 i2c_century_buf[1 + 1] = { MAX6900_REG_CENTURY_WRITE };
+   struct i2c_msg century_msgs[1] = {
{
.addr   = client->addr,
.flags  = 0, /* write */
-   .len= MAX6900_REG_LEN + 1,
-   .buf= i2c_buf
+   .len= sizeof(i2c_century_buf),
+   .buf= i2c_century_buf
+   }
+   };
+   u8 i2c_burst_buf[MAX6900_BURST_LEN + 1] = { MAX6900_REG_BURST_WRITE };
+   struct i2c_msg burst_msgs[1] = {
+   {
+   .addr   = client->addr,
+   .flags  = 0, /* write */
+   .len= sizeof(i2c_burst_buf),
+   .buf= i2c_burst_buf
}
};
int rc;
 
-   memcpy(&i2c_buf[1], buf, MAX6900_REG_LEN);
+   /*
+* We have to make separate calls to i2c_transfer because of
+* the need to delay after each write to the chip.  Also,
+* we write the century byte first, since we set the write-protect
+* bit as part of the burst write.
+*/
+   i2c_century_buf[1] = buf[MAX6900_REG_CENTURY];
+   rc = i2c_transfer(client->adapter, century_msgs,
+ ARRAY_SIZE(century_msgs));
+   if (rc != ARRAY_SIZE(century_msgs))
+   goto write_failed;
+   

[PATCH] mv643xx_eth: add mv643xx_eth_shutdown function

2007-03-20 Thread Dale Farnsworth
From: Dale Farnsworth <[EMAIL PROTECTED]>

mv643xx_eth_shutdown is needed for kexec.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---
 drivers/net/mv643xx_eth.c |   14 ++
 1 file changed, 14 insertions(+)

Index: linux-2.6-powerpc-df/drivers/net/mv643xx_eth.c
===
--- linux-2.6-powerpc-df.orig/drivers/net/mv643xx_eth.c
+++ linux-2.6-powerpc-df/drivers/net/mv643xx_eth.c
@@ -1516,9 +1516,23 @@ static int mv643xx_eth_shared_remove(str
return 0;
 }
 
+static void mv643xx_eth_shutdown(struct platform_device *pdev)
+{
+   struct net_device *dev = platform_get_drvdata(pdev);
+   struct mv643xx_private *mp = netdev_priv(dev);
+   unsigned int port_num = mp->port_num;
+
+   /* Mask all interrupts on ethernet port */
+   mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0);
+   mv_read (MV643XX_ETH_INTERRUPT_MASK_REG(port_num));
+
+   eth_port_reset(port_num);
+}
+
 static struct platform_driver mv643xx_eth_driver = {
.probe = mv643xx_eth_probe,
.remove = mv643xx_eth_remove,
+   .shutdown = mv643xx_eth_shutdown,
.driver = {
.name = MV643XX_ETH_NAME,
},
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: Add RTC class driver for the Maxim MAX6900

2007-03-10 Thread Dale Farnsworth
From: Dale Farnsworth <[EMAIL PROTECTED]>

Signed-off-by: Dale Farnsworth.org <[EMAIL PROTECTED]

---
 drivers/rtc/Kconfig   |   10 +
 drivers/rtc/Makefile  |1 
 drivers/rtc/rtc-max6900.c |  312 
 3 files changed, 323 insertions(+)

Index: linux-2.6-powerpc-df/drivers/rtc/Kconfig
===
--- linux-2.6-powerpc-df.orig/drivers/rtc/Kconfig
+++ linux-2.6-powerpc-df/drivers/rtc/Kconfig
@@ -334,6 +334,16 @@ config RTC_DRV_TEST
  This driver can also be built as a module. If so, the module
  will be called rtc-test.
 
+config RTC_DRV_MAX6900
+   tristate "Maxim 6900"
+   depends on RTC_CLASS && I2C
+   help
+ If you say yes here you will get support for the
+ Maxim MAX6900 I2C RTC chip.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-max6900.
+
 config RTC_DRV_MAX6902
tristate "Maxim 6902"
depends on RTC_CLASS && SPI
Index: linux-2.6-powerpc-df/drivers/rtc/Makefile
===
--- linux-2.6-powerpc-df.orig/drivers/rtc/Makefile
+++ linux-2.6-powerpc-df/drivers/rtc/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_RTC_DRV_EP93XX)  += rtc-ep93
 obj-$(CONFIG_RTC_DRV_SA1100)   += rtc-sa1100.o
 obj-$(CONFIG_RTC_DRV_VR41XX)   += rtc-vr41xx.o
 obj-$(CONFIG_RTC_DRV_PL031)+= rtc-pl031.o
+obj-$(CONFIG_RTC_DRV_MAX6900)  += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)  += rtc-max6902.o
 obj-$(CONFIG_RTC_DRV_V3020)+= rtc-v3020.o
 obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
Index: linux-2.6-powerpc-df/drivers/rtc/rtc-max6900.c
===
--- /dev/null
+++ linux-2.6-powerpc-df/drivers/rtc/rtc-max6900.c
@@ -0,0 +1,312 @@
+/*
+ * rtc class driver for the Maxim MAX6900 chip
+ *
+ * Author: Dale Farnsworth <[EMAIL PROTECTED]>
+ *
+ * based on previously existing rtc class drivers
+ *
+ * 2007 (c) MontaVista, Software, Inc.  This file is licensed under
+ * the terms of the GNU General Public License version 2.  This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_NAME "max6900"
+#define DRV_VERSION "0.1"
+
+/*
+ * register indices
+ */
+#define MAX6900_REG_SC 0   /* seconds  00-59 */
+#define MAX6900_REG_MN 1   /* minutes  00-59 */
+#define MAX6900_REG_HR 2   /* hours00-23 */
+#define MAX6900_REG_DT 3   /* day of month 00-31 */
+#define MAX6900_REG_MO 4   /* month01-12 */
+#define MAX6900_REG_DW 5   /* day of week   1-7  */
+#define MAX6900_REG_YR 6   /* year 00-99 */
+#define MAX6900_REG_CT 7   /* control */
+#define MAX6900_REG_LEN8
+
+#define MAX6900_REG_CT_WP  (1 << 7)/* Write Protect */
+
+/*
+ * register read/write commands
+ */
+#define MAX6900_REG_CONTROL_WRITE  0x8e
+#define MAX6900_REG_BURST_READ 0xbf
+#define MAX6900_REG_BURST_WRITE0xbe
+#define MAX6900_REG_RESERVED_READ  0x96
+
+#define MAX6900_IDLE_TIME_AFTER_WRITE  3   /* specification says 2.5 mS */
+
+#define MAX6900_I2C_ADDR   0xa0
+
+static unsigned short normal_i2c[] = {
+   MAX6900_I2C_ADDR >> 1,
+   I2C_CLIENT_END
+};
+
+I2C_CLIENT_INSMOD; /* defines addr_data */
+
+static int max6900_probe(struct i2c_adapter *adapter, int addr, int kind);
+
+static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
+{
+   u8 reg_addr[1] = { MAX6900_REG_BURST_READ };
+   struct i2c_msg msgs[2] = {
+   {
+   client->addr,
+   0, /* write */
+   sizeof(reg_addr),
+   reg_addr
+   },
+   {
+   client->addr,
+   I2C_M_RD,
+   MAX6900_REG_LEN,
+   buf
+   }
+   };
+   int rc;
+
+   rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
+   if (rc != ARRAY_SIZE(msgs)) {
+   dev_err(&client->dev, "%s: register read failed\n",
+   __FUNCTION__);
+   return -EIO;
+   }
+   return 0;
+}
+
+static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
+{
+   u8 i2c_buf[MAX6900_REG_LEN + 1] = { MAX6900_REG_BURST_WRITE };
+   struct i2c_msg msgs[1] = {
+   {
+   client->addr,
+   0, /* write */
+   MAX6900_R

[PATCH 2/2] mv643xx_eth: Place explicit port number in mv643xx_eth_platform_data

2007-03-01 Thread Dale Farnsworth
We were using the platform_device.id field to identify which ethernet
port is used for mv643xx_eth device.  This is not generally correct.
It will be incorrect, for example, if a hardware platform uses a single
port but not the first port.  Here, we add an explicit port_number field
to struct mv643xx_eth_platform_data.

This makes the mv643xx_eth_platform_data structure required, but that
isn't an issue since all users currently provide it already.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---

 arch/mips/momentum/jaguar_atx/platform.c  |8 ++
 arch/mips/momentum/ocelot_3/platform.c|8 ++
 arch/mips/momentum/ocelot_c/platform.c|4 +
 arch/powerpc/platforms/chrp/pegasos_eth.c |2 
 arch/ppc/syslib/mv64x60.c |   12 +++-
 drivers/net/mv643xx_eth.c |   59 ++--
 include/linux/mv643xx.h   |1 
 7 files changed, 62 insertions(+), 32 deletions(-)

diff --git a/arch/mips/momentum/jaguar_atx/platform.c 
b/arch/mips/momentum/jaguar_atx/platform.c
index 035ea51..003d3ee 100644
Index: b/arch/mips/momentum/jaguar_atx/platform.c
===
--- a/arch/mips/momentum/jaguar_atx/platform.c
+++ b/arch/mips/momentum/jaguar_atx/platform.c
@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_reso
 };
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static struct mv643xx_eth_platform_data eth2_pd;
+static struct mv643xx_eth_platform_data eth2_pd = {
+   .port_number= 2,
+};
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
Index: b/arch/mips/momentum/ocelot_3/platform.c
===
--- a/arch/mips/momentum/ocelot_3/platform.c
+++ b/arch/mips/momentum/ocelot_3/platform.c
@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_reso
 };
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static struct mv643xx_eth_platform_data eth2_pd;
+static struct mv643xx_eth_platform_data eth2_pd = {
+   .port_number= 2,
+};
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
Index: b/arch/mips/momentum/ocelot_c/platform.c
===
--- a/arch/mips/momentum/ocelot_c/platform.c
+++ b/arch/mips/momentum/ocelot_c/platform.c
@@ -47,6 +47,8 @@ static struct resource mv64x60_eth0_reso
 };
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -76,6 +78,8 @@ static struct resource mv64x60_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
Index: b/arch/powerpc/platforms/chrp/pegasos_eth.c
===
--- a/arch/powerpc/platforms/chrp/pegasos_eth.c
+++ b/arch/powerpc/platforms/chrp/pegasos_eth.c
@@ -58,6 +58,7 @@ static struct resource mv643xx_eth0_reso
 
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
.tx_sram_addr = PEGASOS2_SRAM_BASE_ETH0,
.tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
.tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
@@ -87,6 +88,7 @@ static struct resource mv643xx_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
.tx_sram_addr = PEGASOS2_SRAM_BASE_ETH1,
.tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
.tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
Index: b/arch/ppc/sysli

[PATCH 1/2] mv643xx_eth: move mac_addr inside mv643xx_eth_platform_data

2007-03-01 Thread Dale Farnsworth
The information contained within platform_data should be self-contained.
Replace the pointer to a MAC address with the actual MAC address in
struct mv643xx_eth_platform_data.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---

Replaced explicit mac address comparison with a call to is_valid_ether_addr(),
as suggested by Stephen Hemminger <[EMAIL PROTECTED]>.

 arch/mips/momentum/jaguar_atx/platform.c |   20 
 arch/mips/momentum/ocelot_3/platform.c   |   20 
 arch/mips/momentum/ocelot_c/platform.c   |   12 ++--
 drivers/net/mv643xx_eth.c|2 +-
 include/linux/mv643xx.h  |2 +-
 5 files changed, 12 insertions(+), 44 deletions(-)

Index: b/drivers/net/mv643xx_eth.c
===
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1380,7 +1380,7 @@ static int mv643xx_eth_probe(struct plat
 
pd = pdev->dev.platform_data;
if (pd) {
-   if (pd->mac_addr)
+   if (is_valid_ether_addr(pd->mac_addr))
memcpy(dev->dev_addr, pd->mac_addr, 6);
 
if (pd->phy_addr || pd->force_phy_addr)
Index: b/include/linux/mv643xx.h
===
--- a/include/linux/mv643xx.h
+++ b/include/linux/mv643xx.h
@@ -1289,7 +1289,6 @@ struct mv64xxx_i2c_pdata {
 #define MV643XX_ETH_NAME   "mv643xx_eth"
 
 struct mv643xx_eth_platform_data {
-   char*mac_addr;  /* pointer to mac address */
u16 force_phy_addr; /* force override if phy_addr == 0 */
u16 phy_addr;
 
@@ -1304,6 +1303,7 @@ struct mv643xx_eth_platform_data {
u32 tx_sram_size;
u32 rx_sram_addr;
u32 rx_sram_size;
+   u8  mac_addr[6];/* mac address if non-zero*/
 };
 
 #endif /* __ASM_MV643XX_H */
Index: b/arch/mips/momentum/jaguar_atx/platform.c
===
--- a/arch/mips/momentum/jaguar_atx/platform.c
+++ b/arch/mips/momentum/jaguar_atx/platform.c
@@ -47,11 +47,7 @@ static struct resource mv64x60_eth0_reso
},
 };
 
-static char eth0_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth0_pd = {
-   .mac_addr   = eth0_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -80,11 +76,7 @@ static struct resource mv64x60_eth1_reso
},
 };
 
-static char eth1_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth1_pd = {
-   .mac_addr   = eth1_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -113,11 +105,7 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static char eth2_mac_addr[ETH_ALEN];
-
-static struct mv643xx_eth_platform_data eth2_pd = {
-   .mac_addr   = eth2_mac_addr,
-};
+static struct mv643xx_eth_platform_data eth2_pd;
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
@@ -200,9 +188,9 @@ static int __init mv643xx_eth_add_pds(vo
int ret;
 
get_mac(mac);
-   eth_mac_add(eth0_mac_addr, mac, 0);
-   eth_mac_add(eth1_mac_addr, mac, 1);
-   eth_mac_add(eth2_mac_addr, mac, 2);
+   eth_mac_add(eth0_pd.mac_addr, mac, 0);
+   eth_mac_add(eth1_pd.mac_addr, mac, 1);
+   eth_mac_add(eth2_pd.mac_addr, mac, 2);
ret = platform_add_devices(mv643xx_eth_pd_devs,
ARRAY_SIZE(mv643xx_eth_pd_devs));
 
Index: b/arch/mips/momentum/ocelot_3/platform.c
===
--- a/arch/mips/momentum/ocelot_3/platform.c
+++ b/arch/mips/momentum/ocelot_3/platform.c
@@ -47,11 +47,7 @@ static struct resource mv64x60_eth0_reso
},
 };
 
-static char eth0_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth0_pd = {
-   .mac_addr   = eth0_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -80,11 +76,7 @@ static struct resource mv64x60_eth1_reso
},
 };
 
-static char eth1_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth1_pd = {
-   .mac_addr   = eth1_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -113,11 +105,7 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static char eth2_mac_addr[ETH_ALEN];
-
-static struct mv643xx_eth_platform_data eth2_pd = {
-   .mac_addr   = eth2_mac_addr,
-};
+static struct mv643xx_eth_platform_data eth2_pd;
 

Re: [PATCH 1/2] mv643xx_eth: move mac_addr inside of mv643xx_eth_platform_data

2007-02-28 Thread Dale Farnsworth
On Wed, Feb 28, 2007 at 03:11:03PM -0800, Stephen Hemminger wrote:
> On Wed, 28 Feb 2007 15:40:31 -0700
> "Dale Farnsworth" <[EMAIL PROTECTED]> wrote:
> 
> > The information contained within platform_data should be self-contained.
> > Replace the pointer to a MAC address with the actual MAC address in
> > struct mv643xx_eth_platform_data.
> > 
> > Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
> > 
> > Index: b/drivers/net/mv643xx_eth.c
> > ===
> > --- a/drivers/net/mv643xx_eth.c
> > +++ b/drivers/net/mv643xx_eth.c
> > @@ -1380,7 +1380,9 @@ static int mv643xx_eth_probe(struct plat
> >  
> > pd = pdev->dev.platform_data;
> > if (pd) {
> > -   if (pd->mac_addr)
> > +   static u8 zero_mac_addr[6] = { 0 };
> > +
> > +   if (memcmp(pd->mac_addr, zero_mac_addr, 6) != 0)
> > memcpy(dev->dev_addr, pd->mac_addr, 6);
> 
> 
> is_zero_ether_addr() is faster/cleaner for this

Thanks.  I follow up with a modified patch in a day or two.

-Dale
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] mv643xx_eth: Place explicit port number in mv643xx_eth_platform_data

2007-02-28 Thread Dale Farnsworth
We had been using the platform_device.id field to identify which ethernet
port is used for mv643xx_eth device.  This is not correct in general.
It will be incorrect, for example, if a hardware platform uses a single
port but not the first port.  Here, we add an explicit port_number field
to struct mv643xx_eth_platform_data.

This makes the mv643xx_eth_platform_data structure required, but that
isn't an issue since all users currently provide it already.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

diff --git a/arch/mips/momentum/jaguar_atx/platform.c 
b/arch/mips/momentum/jaguar_atx/platform.c
Index: b/arch/mips/momentum/jaguar_atx/platform.c
===
--- a/arch/mips/momentum/jaguar_atx/platform.c
+++ b/arch/mips/momentum/jaguar_atx/platform.c
@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_reso
 };
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static struct mv643xx_eth_platform_data eth2_pd;
+static struct mv643xx_eth_platform_data eth2_pd = {
+   .port_number= 2,
+};
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
Index: b/arch/mips/momentum/ocelot_3/platform.c
===
--- a/arch/mips/momentum/ocelot_3/platform.c
+++ b/arch/mips/momentum/ocelot_3/platform.c
@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_reso
 };
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static struct mv643xx_eth_platform_data eth2_pd;
+static struct mv643xx_eth_platform_data eth2_pd = {
+   .port_number= 2,
+};
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
Index: b/arch/mips/momentum/ocelot_c/platform.c
===
--- a/arch/mips/momentum/ocelot_c/platform.c
+++ b/arch/mips/momentum/ocelot_c/platform.c
@@ -47,6 +47,8 @@ static struct resource mv64x60_eth0_reso
 };
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -76,6 +78,8 @@ static struct resource mv64x60_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
+
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
Index: b/arch/powerpc/platforms/chrp/pegasos_eth.c
===
--- a/arch/powerpc/platforms/chrp/pegasos_eth.c
+++ b/arch/powerpc/platforms/chrp/pegasos_eth.c
@@ -58,6 +58,7 @@ static struct resource mv643xx_eth0_reso
 
 
 static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
.tx_sram_addr = PEGASOS2_SRAM_BASE_ETH0,
.tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
.tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
@@ -87,6 +88,7 @@ static struct resource mv643xx_eth1_reso
 };
 
 static struct mv643xx_eth_platform_data eth1_pd = {
+   .port_number= 1,
.tx_sram_addr = PEGASOS2_SRAM_BASE_ETH1,
.tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
.tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
Index: b/arch/ppc/syslib/mv64x60.c
===
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -339,7 +339,9 @@ static struct resource mv64x60_eth0_reso
},
 };
 
-static struct mv643xx_eth_platform_data eth0_pd;
+static struct mv643xx_eth_platform_data eth0_pd = {
+   .port_number= 0,
+};
 
 static struct platform_device eth0_device = {
.name   = MV643XX_ETH_NAME,
@@ -362,7 +364,9 @@ static struct resource mv64x60_eth1_reso
},
 };
 
-st

[PATCH 1/2] mv643xx_eth: move mac_addr inside of mv643xx_eth_platform_data

2007-02-28 Thread Dale Farnsworth
The information contained within platform_data should be self-contained.
Replace the pointer to a MAC address with the actual MAC address in
struct mv643xx_eth_platform_data.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

Index: b/drivers/net/mv643xx_eth.c
===
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1380,7 +1380,9 @@ static int mv643xx_eth_probe(struct plat
 
pd = pdev->dev.platform_data;
if (pd) {
-   if (pd->mac_addr)
+   static u8 zero_mac_addr[6] = { 0 };
+
+   if (memcmp(pd->mac_addr, zero_mac_addr, 6) != 0)
memcpy(dev->dev_addr, pd->mac_addr, 6);
 
if (pd->phy_addr || pd->force_phy_addr)
Index: b/include/linux/mv643xx.h
===
--- a/include/linux/mv643xx.h
+++ b/include/linux/mv643xx.h
@@ -1289,7 +1289,6 @@ struct mv64xxx_i2c_pdata {
 #define MV643XX_ETH_NAME   "mv643xx_eth"
 
 struct mv643xx_eth_platform_data {
-   char*mac_addr;  /* pointer to mac address */
u16 force_phy_addr; /* force override if phy_addr == 0 */
u16 phy_addr;
 
@@ -1304,6 +1303,7 @@ struct mv643xx_eth_platform_data {
u32 tx_sram_size;
u32 rx_sram_addr;
u32 rx_sram_size;
+   u8  mac_addr[6];/* mac address if non-zero*/
 };
 
 #endif /* __ASM_MV643XX_H */
Index: b/arch/mips/momentum/jaguar_atx/platform.c
===
--- a/arch/mips/momentum/jaguar_atx/platform.c
+++ b/arch/mips/momentum/jaguar_atx/platform.c
@@ -47,11 +47,7 @@ static struct resource mv64x60_eth0_reso
},
 };
 
-static char eth0_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth0_pd = {
-   .mac_addr   = eth0_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -80,11 +76,7 @@ static struct resource mv64x60_eth1_reso
},
 };
 
-static char eth1_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth1_pd = {
-   .mac_addr   = eth1_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -113,11 +105,7 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static char eth2_mac_addr[ETH_ALEN];
-
-static struct mv643xx_eth_platform_data eth2_pd = {
-   .mac_addr   = eth2_mac_addr,
-};
+static struct mv643xx_eth_platform_data eth2_pd;
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
@@ -200,9 +188,9 @@ static int __init mv643xx_eth_add_pds(vo
int ret;
 
get_mac(mac);
-   eth_mac_add(eth0_mac_addr, mac, 0);
-   eth_mac_add(eth1_mac_addr, mac, 1);
-   eth_mac_add(eth2_mac_addr, mac, 2);
+   eth_mac_add(eth0_pd.mac_addr, mac, 0);
+   eth_mac_add(eth1_pd.mac_addr, mac, 1);
+   eth_mac_add(eth2_pd.mac_addr, mac, 2);
ret = platform_add_devices(mv643xx_eth_pd_devs,
ARRAY_SIZE(mv643xx_eth_pd_devs));
 
Index: b/arch/mips/momentum/ocelot_3/platform.c
===
--- a/arch/mips/momentum/ocelot_3/platform.c
+++ b/arch/mips/momentum/ocelot_3/platform.c
@@ -47,11 +47,7 @@ static struct resource mv64x60_eth0_reso
},
 };
 
-static char eth0_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth0_pd = {
-   .mac_addr   = eth0_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH0,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -80,11 +76,7 @@ static struct resource mv64x60_eth1_reso
},
 };
 
-static char eth1_mac_addr[ETH_ALEN];
-
 static struct mv643xx_eth_platform_data eth1_pd = {
-   .mac_addr   = eth1_mac_addr,
-
.tx_sram_addr   = MV_SRAM_BASE_ETH1,
.tx_sram_size   = MV_SRAM_TXRING_SIZE,
.tx_queue_size  = MV_SRAM_TXRING_SIZE / 16,
@@ -113,11 +105,7 @@ static struct resource mv64x60_eth2_reso
},
 };
 
-static char eth2_mac_addr[ETH_ALEN];
-
-static struct mv643xx_eth_platform_data eth2_pd = {
-   .mac_addr   = eth2_mac_addr,
-};
+static struct mv643xx_eth_platform_data eth2_pd;
 
 static struct platform_device eth2_device = {
.name   = MV643XX_ETH_NAME,
@@ -200,9 +188,9 @@ static int __init mv643xx_eth_add_pds(vo
int ret;
 
get_mac(mac);
-   eth_mac_add(eth0_mac_addr, mac, 0);
-   eth_mac_add(eth1_mac_addr, mac, 1);
-   eth_mac_add(eth2_mac_addr, mac, 2);
+   eth_mac_add(eth0_pd.mac_addr, mac, 0);
+   eth_mac_add(eth1_pd.mac_addr, mac, 1);
+   eth_mac_add(e

[PATCH] Eliminate user-selectable CONFIG_MV643XX_ETH_[012]

2007-02-20 Thread Dale Farnsworth
From: Dale Farnsworth <[EMAIL PROTECTED]>

Remove the use of CONFIG_MV643XX_ETH_[012] variables on most
platforms.  Instead, platform-specific code enables the ports
supported by the hardware.  After this patch, these config
variables are only used in arch/ppc, so also move them from
drivers/net/Kconfig to arch/ppc/Kconfig.

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---
It was a mis-feature that the supported ports were ever user-selectable.
Which ports the hardware supports should be specified by platform-specific
code, not by the user.

 arch/mips/momentum/jaguar_atx/platform.c |   21 -
 arch/mips/momentum/ocelot_3/platform.c   |   21 -
 arch/mips/momentum/ocelot_c/platform.c   |   14 --
 arch/ppc/Kconfig |   15 +++
 drivers/net/Kconfig  |   21 -
 5 files changed, 15 insertions(+), 77 deletions(-)

Index: b/arch/mips/momentum/jaguar_atx/platform.c
===
--- a/arch/mips/momentum/jaguar_atx/platform.c
+++ b/arch/mips/momentum/jaguar_atx/platform.c
@@ -38,8 +38,6 @@ static struct platform_device mv643xx_et
 #define MV64x60_IRQ_ETH_1 49
 #define MV64x60_IRQ_ETH_2 50
 
-#ifdef CONFIG_MV643XX_ETH_0
-
 static struct resource mv64x60_eth0_resources[] = {
[0] = {
.name   = "eth0 irq",
@@ -72,9 +70,6 @@ static struct platform_device eth0_devic
.platform_data = ð0_pd,
},
 };
-#endif /* CONFIG_MV643XX_ETH_0 */
-
-#ifdef CONFIG_MV643XX_ETH_1
 
 static struct resource mv64x60_eth1_resources[] = {
[0] = {
@@ -108,9 +103,6 @@ static struct platform_device eth1_devic
.platform_data = ð1_pd,
},
 };
-#endif /* CONFIG_MV643XX_ETH_1 */
-
-#ifdef CONFIG_MV643XX_ETH_2
 
 static struct resource mv64x60_eth2_resources[] = {
[0] = {
@@ -136,19 +128,12 @@ static struct platform_device eth2_devic
.platform_data = ð2_pd,
},
 };
-#endif /* CONFIG_MV643XX_ETH_2 */
 
 static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
&mv643xx_eth_shared_device,
-#ifdef CONFIG_MV643XX_ETH_0
ð0_device,
-#endif
-#ifdef CONFIG_MV643XX_ETH_1
ð1_device,
-#endif
-#ifdef CONFIG_MV643XX_ETH_2
ð2_device,
-#endif
 };
 
 static u8 __init exchange_bit(u8 val, u8 cs)
@@ -215,15 +200,9 @@ static int __init mv643xx_eth_add_pds(vo
int ret;
 
get_mac(mac);
-#ifdef CONFIG_MV643XX_ETH_0
eth_mac_add(eth1_mac_addr, mac, 0);
-#endif
-#ifdef CONFIG_MV643XX_ETH_1
eth_mac_add(eth1_mac_addr, mac, 1);
-#endif
-#ifdef CONFIG_MV643XX_ETH_2
eth_mac_add(eth2_mac_addr, mac, 2);
-#endif
ret = platform_add_devices(mv643xx_eth_pd_devs,
ARRAY_SIZE(mv643xx_eth_pd_devs));
 
Index: b/arch/mips/momentum/ocelot_3/platform.c
===
--- a/arch/mips/momentum/ocelot_3/platform.c
+++ b/arch/mips/momentum/ocelot_3/platform.c
@@ -38,8 +38,6 @@ static struct platform_device mv643xx_et
 #define MV64x60_IRQ_ETH_1 49
 #define MV64x60_IRQ_ETH_2 50
 
-#ifdef CONFIG_MV643XX_ETH_0
-
 static struct resource mv64x60_eth0_resources[] = {
[0] = {
.name   = "eth0 irq",
@@ -72,9 +70,6 @@ static struct platform_device eth0_devic
.platform_data = ð0_pd,
},
 };
-#endif /* CONFIG_MV643XX_ETH_0 */
-
-#ifdef CONFIG_MV643XX_ETH_1
 
 static struct resource mv64x60_eth1_resources[] = {
[0] = {
@@ -108,9 +103,6 @@ static struct platform_device eth1_devic
.platform_data = ð1_pd,
},
 };
-#endif /* CONFIG_MV643XX_ETH_1 */
-
-#ifdef CONFIG_MV643XX_ETH_2
 
 static struct resource mv64x60_eth2_resources[] = {
[0] = {
@@ -136,19 +128,12 @@ static struct platform_device eth2_devic
.platform_data = ð2_pd,
},
 };
-#endif /* CONFIG_MV643XX_ETH_2 */
 
 static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
&mv643xx_eth_shared_device,
-#ifdef CONFIG_MV643XX_ETH_0
ð0_device,
-#endif
-#ifdef CONFIG_MV643XX_ETH_1
ð1_device,
-#endif
-#ifdef CONFIG_MV643XX_ETH_2
ð2_device,
-#endif
 };
 
 static u8 __init exchange_bit(u8 val, u8 cs)
@@ -215,15 +200,9 @@ static int __init mv643xx_eth_add_pds(vo
int ret;
 
get_mac(mac);
-#ifdef CONFIG_MV643XX_ETH_0
eth_mac_add(eth1_mac_addr, mac, 0);
-#endif
-#ifdef CONFIG_MV643XX_ETH_1
eth_mac_add(eth1_mac_addr, mac, 1);
-#endif
-#ifdef CONFIG_MV643XX_ETH_2
eth_mac_add(eth2_mac_addr, mac, 2);
-#endif
ret = platform_add_devices(mv643xx_eth_pd_devs,
ARRAY_SIZE(mv643xx_eth_pd_devs));
 
Index: b/arch/mips/momentum/ocelot_c/platform.c
===
--- a/arch/mips/momentum/ocelot_c/platform.c
+++ b/arch/mips/mom

[PATCH] mv643xx_eth: Fix race condition in mv643xx_eth_free_tx_descs

2007-01-23 Thread Dale Farnsworth
>From Dale Farnsworth <[EMAIL PROTECTED]>

mv643xx_eth: Fix race condition in mv643xx_eth_free_tx_descs

This bug was found and isolated by Thibaut VARENE <[EMAIL PROTECTED]>
and Jarek Poplawski <[EMAIL PROTECTED]>.  This patch is a modification of their
fixes.  We acquire and release the lock for each descriptor that is freed
to minimize the time the lock is held.

---

 drivers/net/mv643xx_eth.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index c41ae42..b3bf864 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -314,6 +314,13 @@ int mv643xx_eth_free_tx_descs(struct net
 
while (mp->tx_desc_count > 0) {
spin_lock_irqsave(&mp->lock, flags);
+
+   /* tx_desc_count might have changed before acquiring the lock */
+   if (mp->tx_desc_count <= 0) {
+   spin_unlock_irqrestore(&mp->lock, flags);
+   return released;
+   }
+
tx_index = mp->tx_used_desc_q;
desc = &mp->p_tx_desc_area[tx_index];
cmd_sts = desc->cmd_sts;
@@ -332,13 +339,13 @@ int mv643xx_eth_free_tx_descs(struct net
if (skb)
mp->tx_skb[tx_index] = NULL;
 
-   spin_unlock_irqrestore(&mp->lock, flags);
-
if (cmd_sts & ETH_ERROR_SUMMARY) {
printk("%s: Error in TX\n", dev->name);
mp->stats.tx_errors++;
}
 
+   spin_unlock_irqrestore(&mp->lock, flags);
+
if (cmd_sts & ETH_TX_FIRST_DESC)
dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE);
else
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mv643xx_eth: fix unbalanced parentheses in macros

2006-11-30 Thread Dale Farnsworth
From: Mariusz Kozlowski <[EMAIL PROTECTED]>

Signed-off-by: Mariusz Kozlowski <[EMAIL PROTECTED]>
Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

---
 include/linux/mv643xx.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.19-rc6-mm2-a/include/linux/mv643xx.h  2006-11-16 
05:03:40.0 +0100
+++ linux-2.6.19-rc6-mm2-b/include/linux/mv643xx.h  2006-11-30 
11:30:14.0 +0100
@@ -724,7 +724,7 @@
 #define MV643XX_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + 
(port<<10))
 #define MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + 
(port<<10))
 #define MV643XX_ETH_RX_MINIMAL_FRAME_SIZE_REG(port)(0x247c + 
(port<<10))
-#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port)  (0x2484 + 
(port<<10)
+#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port)  (0x2484 + 
(port<<10))
 #define MV643XX_ETH_PORT_DEBUG_0_REG(port) (0x248c + 
(port<<10))
 #define MV643XX_ETH_PORT_DEBUG_1_REG(port) (0x2490 + 
(port<<10))
 #define MV643XX_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + 
(port<<10))
@@ -1135,7 +1135,7 @@ struct mv64xxx_i2c_pdata {
 #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19)
 #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20)
 #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19))
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 ((1<<21)
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 (1<<21)
 #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19))
 #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20))
 #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mv643xx add missing brackets

2006-11-30 Thread Dale Farnsworth
On Thu, Nov 30, 2006 at 10:35:37AM +0100, Mariusz Kozlowski wrote:
> Hello,
> 
>   This patch adds missing brackets.
> 
> Signed-off-by: Mariusz Kozlowski <[EMAIL PROTECTED]>
> 
>  include/linux/mv643xx.h |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- linux-2.6.19-rc6-mm2-a/include/linux/mv643xx.h2006-11-16 
> 05:03:40.0 +0100
> +++ linux-2.6.19-rc6-mm2-b/include/linux/mv643xx.h2006-11-30 
> 01:10:53.0 +0100
> @@ -724,7 +724,7 @@
>  #define MV643XX_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + 
> (port<<10))
>  #define MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + 
> (port<<10))
>  #define MV643XX_ETH_RX_MINIMAL_FRAME_SIZE_REG(port)(0x247c + 
> (port<<10))
> -#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port)  (0x2484 + 
> (port<<10)
> +#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port)  (0x2484 + 
> (port<<10))

Good.  Thanks.

>  #define MV643XX_ETH_PORT_DEBUG_0_REG(port) (0x248c + 
> (port<<10))
>  #define MV643XX_ETH_PORT_DEBUG_1_REG(port) (0x2490 + 
> (port<<10))
>  #define MV643XX_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + 
> (port<<10))
> @@ -1135,7 +1135,7 @@ struct mv64xxx_i2c_pdata {
>  #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1   (1<<19)
>  #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2   (1<<20)
>  #define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3   ((1<<20) | (1<<19))
> -#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4   ((1<<21)
> +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4   ((1<<21))

Mariusz, please remove the extra parenthesis instead of adding
an extra one, like:
#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4  (1<<21)
and resubmit.

Thanks,
-Dale
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ppc32: MV643XX ethernet is an option for Pegasos

2005-04-12 Thread Dale Farnsworth
On Tue, Apr 12, 2005 at 10:44:24AM +, Fabio Massimo Di Nitto wrote:
> Dale Farnsworth wrote:
> > This looks identical to the patch I posted to netdev two weeks ago
> > as the first of 20 patches for the MV643xx ethernet driver.
> > 
> > See <http://oss.sgi.com/archives/netdev/2005-03/msg01644.html> and
> > <http://oss.sgi.com/archives/netdev/2005-03/msg01642.html>.
> 
> It is possible. I received an old patch from Sven Luther and bounced to
> Benjamin rediffed against 2.6.12rc2, but the bits ended to be exactly
> the same.
> 
> PS feel free to claim credits on it. I don't want for sure take over
> your work :)

No problem.  It was Nicolas' and Sven's patch and Like Sven said
this one is trivial.  Mainly, I wanted to mention the other 19 patches
I've sent that I hope get accepted soon.

-Dale
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ppc32: MV643XX ethernet is an option for Pegasos

2005-04-12 Thread Dale Farnsworth
On Tue, Apr 12, 2005 at 07:13:04AM +, Benjamin Herrenschmidt wrote:
> This patch allows Kconfig to build the MV643xx ethernet driver on
> Pegasos (CONFIG_PPC_MULTIPLATFORM) and adds what I think is a missing
> fix from Dale's batch, that is remove SA_INTERRUPT and add SA_SHIRQ in
> there as the interrupt is shared if I understand things correctly.
> 
> Signed-off-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
> Signed-off-by: Fabio Massimo Di Nitto <[EMAIL PROTECTED]>

This looks identical to the patch I posted to netdev two weeks ago
as the first of 20 patches for the MV643xx ethernet driver.

See  and
.

Thanks,
-Dale

> #! /bin/sh -e
> 
> . $(dirname $0)/DPATCH
> 
> @DPATCH@
> diff -urNad linux-source-2.6.12-2.6.11.90/drivers/net/Kconfig 
> /usr/src/dpatchtemp/dpep.nYRoKc/linux-source-2.6.12-2.6.11.90/drivers/net/Kconfig
> --- linux-source-2.6.12-2.6.11.90/drivers/net/Kconfig 2005-04-11 
> 16:13:06.0 +0200
> +++ 
> /usr/src/dpatchtemp/dpep.nYRoKc/linux-source-2.6.12-2.6.11.90/drivers/net/Kconfig
>  2005-04-12 08:05:33.535955920 +0200
> @@ -2044,7 +2044,7 @@
>  
>  config MV643XX_ETH
>   tristate "MV-643XX Ethernet support"
> - depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || 
> MOMENCO_OCELOT_3
> + depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || 
> MOMENCO_OCELOT_3 || PPC_MULTIPLATFORM
>   help
> This driver supports the gigabit Ethernet on the Marvell MV643XX
> chipset which is used in the Momenco Ocelot C and Jaguar ATX and
> diff -urNad linux-source-2.6.12-2.6.11.90/drivers/net/mv643xx_eth.c 
> /usr/src/dpatchtemp/dpep.nYRoKc/linux-source-2.6.12-2.6.11.90/drivers/net/mv643xx_eth.c
> --- linux-source-2.6.12-2.6.11.90/drivers/net/mv643xx_eth.c   2005-04-07 
> 14:57:16.0 +0200
> +++ 
> /usr/src/dpatchtemp/dpep.nYRoKc/linux-source-2.6.12-2.6.11.90/drivers/net/mv643xx_eth.c
>2005-04-12 08:07:36.246301112 +0200
> @@ -668,7 +668,7 @@
>   spin_lock_irq(&mp->lock);
>  
>   err = request_irq(dev->irq, mv643xx_eth_int_handler,
> - SA_INTERRUPT | SA_SAMPLE_RANDOM, dev->name, dev);
> + SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
>  
>   if (err) {
>   printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n",
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Patch for IDE hang after resetting quirk drive

2001-07-03 Thread Dale Farnsworth

I have a Promise PDC20265 ide controller with one of the "quirk" drives,
a Quantum Fireballp LM30.  That drive has a bad sector and accessing
it would result in a DMA timeout.  Unfortunately, after the IDE driver
resets the controller, the drive never responded.

The following patch appears to correct the problem.  It duplicates
the workaround for "quirky" drives found in ide-features.c

-Dale

Dale Farnsworth [EMAIL PROTECTED]

--- oldlinux-2.4.5/drivers/ide/ide.cTue Jul  3 09:35:57 2001
+++ linux-2.4.5/drivers/ide/ide.c   Tue Jul  3 09:23:58 2001
@@ -758,7 +758,10 @@
 */
OUT_BYTE(drive->ctl|6,IDE_CONTROL_REG); /* set SRST and nIEN */
udelay(10); /* more than enough time */
-   OUT_BYTE(drive->ctl|2,IDE_CONTROL_REG); /* clear SRST, leave nIEN */
+   if (drive->quirk_list == 2)
+   OUT_BYTE(drive->ctl, IDE_CONTROL_REG); /* clear SRST and nIEN */
+   else
+   OUT_BYTE(drive->ctl|2,IDE_CONTROL_REG); /* clear SRST only */
udelay(10); /* more than enough time */
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
ide_set_handler (drive, &reset_pollfunc, HZ/20, NULL);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: VIA silent disk corruption - patch

2001-02-06 Thread Dale Farnsworth


In article <[EMAIL PROTECTED]>,
Peter Horton <[EMAIL PROTECTED]> wrote:
> +  *  VIA VT8363 host bridge has broken feature 'PCI Master Read
> +  *  Caching'. It caches more than is good for it, sometimes
> +  *  serving the bus master with stale data. Some BIOSes enable
> +  *  it by default, so we disable it.

Another data point:

I have an ASUS A7V motherboard with via vt82c686a and Promise pdc20265
IDE controllers.  I noticed disk data corruption when I enabled DMA. 
The corrupted data was 4K bytes long on 4K byte boundaries and occurred
about once for every couple of gigabytes copied via cpio.
I saw this corruption when the disks were connected to the pdc20265
as well as to the 686a.

I also noticed that turning off read caching eliminated the corruption.

However, if I enable the BIOS parameter "I/O Recovery Time", I can still
enable read caching without seeing any data corruption.
The lastest BIOS revision (1005C) enables "I/O Recovery Time" by default
where the previous revision I had (1004D) did not.

-Dale

-- 

Dale Farnsworth [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/