* [patch 00/22] DM9000 updates for 2.6.25
@ 2007-11-19 20:39 Ben Dooks
2007-11-19 20:39 ` [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output Ben Dooks
` (23 more replies)
0 siblings, 24 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince
This is my current proposed patch series to the DM9000
driver for both general cleanups, support for ethtool
and to make the code better.
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output.
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:35 ` Jeff Garzik
2007-11-19 20:39 ` [patch 02/22] NET: DM9000 update debugging macros to use debug level Ben Dooks
` (22 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-devmacros.patch --]
[-- Type: text/plain, Size: 6378 bytes --]
Move to using dev_dbg() and friends for the output of
information to the user.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.22-quilt4/drivers/net/dm9000.c
===================================================================
--- linux-2.6.22-quilt4.orig/drivers/net/dm9000.c
+++ linux-2.6.22-quilt4/drivers/net/dm9000.c
@@ -142,6 +142,8 @@ typedef struct board_info {
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
+ struct device *dev; /* parent device */
+
struct resource *addr_res; /* resources found */
struct resource *data_res;
struct resource *addr_req; /* resources requested */
@@ -187,7 +189,8 @@ static void program_eeprom(board_info_t
static void
dm9000_reset(board_info_t * db)
{
- PRINTK1("dm9000x: resetting\n");
+ dev_dbg(db->dev, "resetting device\n");
+
/* RESET device */
writeb(DM9000_NCR, db->io_addr);
udelay(200);
@@ -303,14 +306,10 @@ static void dm9000_set_io(struct board_i
db->inblk = dm9000_inblk_8bit;
break;
- case 2:
- db->dumpblk = dm9000_dumpblk_16bit;
- db->outblk = dm9000_outblk_16bit;
- db->inblk = dm9000_inblk_16bit;
- break;
case 3:
- printk(KERN_ERR PFX ": 3 byte IO, falling back to 16bit\n");
+ dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
+ case 2:
db->dumpblk = dm9000_dumpblk_16bit;
db->outblk = dm9000_outblk_16bit;
db->inblk = dm9000_inblk_16bit;
@@ -413,19 +412,21 @@ dm9000_probe(struct platform_device *pde
/* Init network device */
ndev = alloc_etherdev(sizeof (struct board_info));
if (!ndev) {
- printk("%s: could not allocate device.\n", CARDNAME);
+ dev_err(&pdev->dev, "could not allocate device.\n");
return -ENOMEM;
}
SET_MODULE_OWNER(ndev);
SET_NETDEV_DEV(ndev, &pdev->dev);
- PRINTK2("dm9000_probe()");
+ dev_dbg(&pdev->dev, "probing device\n");
/* setup board info structure */
db = (struct board_info *) ndev->priv;
memset(db, 0, sizeof (*db));
+ db->dev = &pdev->dev;
+
spin_lock_init(&db->lock);
if (pdev->num_resources < 2) {
@@ -454,7 +455,7 @@ dm9000_probe(struct platform_device *pde
if (db->addr_res == NULL || db->data_res == NULL ||
db->irq_res == NULL) {
- printk(KERN_ERR PFX "insufficient resources\n");
+ dev_err(db->dev, "insufficient resources\n");
ret = -ENOENT;
goto out;
}
@@ -464,7 +465,7 @@ dm9000_probe(struct platform_device *pde
pdev->name);
if (db->addr_req == NULL) {
- printk(KERN_ERR PFX "cannot claim address reg area\n");
+ dev_err(db->dev, "cannot claim address reg area\n");
ret = -EIO;
goto out;
}
@@ -472,7 +473,7 @@ dm9000_probe(struct platform_device *pde
db->io_addr = ioremap(db->addr_res->start, i);
if (db->io_addr == NULL) {
- printk(KERN_ERR "failed to ioremap address reg\n");
+ dev_err(db->dev, "failed to ioremap address reg\n");
ret = -EINVAL;
goto out;
}
@@ -482,7 +483,7 @@ dm9000_probe(struct platform_device *pde
pdev->name);
if (db->data_req == NULL) {
- printk(KERN_ERR PFX "cannot claim data reg area\n");
+ dev_err(db->dev, "cannot claim data reg area\n");
ret = -EIO;
goto out;
}
@@ -490,7 +491,7 @@ dm9000_probe(struct platform_device *pde
db->io_data = ioremap(db->data_res->start, iosize);
if (db->io_data == NULL) {
- printk(KERN_ERR "failed to ioremap data reg\n");
+ dev_err(db->dev,"failed to ioremap data reg\n");
ret = -EINVAL;
goto out;
}
@@ -544,11 +545,11 @@ dm9000_probe(struct platform_device *pde
if (id_val == DM9000_ID)
break;
- printk("%s: read wrong id 0x%08x\n", CARDNAME, id_val);
+ dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
}
if (id_val != DM9000_ID) {
- printk("%s: wrong id: 0x%08x\n", CARDNAME, id_val);
+ dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
goto release;
}
@@ -596,8 +597,8 @@ dm9000_probe(struct platform_device *pde
}
if (!is_valid_ether_addr(ndev->dev_addr))
- printk("%s: Invalid ethernet MAC address. Please "
- "set using ifconfig\n", ndev->name);
+ dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
+ "set using ifconfig\n", ndev->name);
platform_set_drvdata(pdev, ndev);
ret = register_netdev(ndev);
@@ -613,7 +614,7 @@ dm9000_probe(struct platform_device *pde
release:
out:
- printk("%s: not found (%d).\n", CARDNAME, ret);
+ dev_err(db->dev, "not found (%d).\n", ret);
dm9000_release_board(pdev, db);
free_netdev(ndev);
@@ -630,7 +631,7 @@ dm9000_open(struct net_device *dev)
{
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK2("entering dm9000_open\n");
+ dev_dbg(db->dev, "entering %s\n", __func__);
if (request_irq(dev->irq, &dm9000_interrupt, DM9000_IRQ_FLAGS, dev->name, dev))
return -EAGAIN;
@@ -916,7 +917,7 @@ dm9000_rx(struct net_device *dev)
/* Status check: this byte must be 0 or 1 */
if (rxbyte > DM9000_PKT_RDY) {
- printk("status check failed: %d\n", rxbyte);
+ dev_warn(db->dev, "status check fail: %d\n", rxbyte);
iow(db, DM9000_RCR, 0x00); /* Stop Device */
iow(db, DM9000_ISR, IMR_PAR); /* Stop INT request */
return;
@@ -936,25 +937,25 @@ dm9000_rx(struct net_device *dev)
/* Packet Status check */
if (RxLen < 0x40) {
GoodPacket = false;
- PRINTK1("Bad Packet received (runt)\n");
+ dev_dbg(db->dev, "Bad Packet received (runt)\n");
}
if (RxLen > DM9000_PKT_MAX) {
- PRINTK1("RST: RX Len:%x\n", RxLen);
+ dev_dbg(db->dev, "RST: RX Len:%x\n", RxLen);
}
if (rxhdr.RxStatus & 0xbf) {
GoodPacket = false;
if (rxhdr.RxStatus & 0x01) {
- PRINTK1("fifo error\n");
+ dev_dbg(db->dev, "fifo error\n");
db->stats.rx_fifo_errors++;
}
if (rxhdr.RxStatus & 0x02) {
- PRINTK1("crc error\n");
+ dev_dbg(db->dev, "crc error\n");
db->stats.rx_crc_errors++;
}
if (rxhdr.RxStatus & 0x80) {
- PRINTK1("length error\n");
+ dev_dbg(db->dev, "length error\n");
db->stats.rx_length_errors++;
}
}
@@ -1203,8 +1204,7 @@ dm9000_drv_remove(struct platform_device
dm9000_release_board(pdev, (board_info_t *) ndev->priv);
free_netdev(ndev); /* free device structure */
- PRINTK1("clean_module() exit\n");
-
+ dev_dbg(&pdev->dev, "released and freed device\n");
return 0;
}
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 02/22] NET: DM9000 update debugging macros to use debug level
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
2007-11-19 20:39 ` [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:36 ` Jeff Garzik
2007-11-19 20:39 ` [patch 03/22] NET: DM9000: Pass IRQ flags via platform data Ben Dooks
` (21 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-debugupdate.patch --]
[-- Type: text/plain, Size: 4378 bytes --]
Change the debug macros to use the compiler to elide any
unnecessary debug level, and to allow device configurable
debug control.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt1/drivers/net/Kconfig
===================================================================
--- linux-2.6.23-quilt1.orig/drivers/net/Kconfig
+++ linux-2.6.23-quilt1/drivers/net/Kconfig
@@ -940,6 +940,14 @@ config DM9000
<file:Documentation/networking/net-modules.txt>. The module will be
called dm9000.
+config DM9000_DEBUGLEVEL
+ int "DM9000 maximum debug level"
+ depends on DM9000
+ default 4
+ help
+ The maximum level of debugging code compiled into the DM9000
+ driver.
+
config SMC911X
tristate "SMSC LAN911[5678] support"
select CRC32
Index: linux-2.6.23-quilt1/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt1.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt1/drivers/net/dm9000.c
@@ -82,28 +82,6 @@
#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */
-#define DM9000_DEBUG 0
-
-#if DM9000_DEBUG > 2
-#define PRINTK3(args...) printk(CARDNAME ": " args)
-#else
-#define PRINTK3(args...) do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 1
-#define PRINTK2(args...) printk(CARDNAME ": " args)
-#else
-#define PRINTK2(args...) do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 0
-#define PRINTK1(args...) printk(CARDNAME ": " args)
-#define PRINTK(args...) printk(CARDNAME ": " args)
-#else
-#define PRINTK1(args...) do { } while(0)
-#define PRINTK(args...) printk(KERN_DEBUG args)
-#endif
-
#ifdef CONFIG_BLACKFIN
#define readsb insb
#define readsw insw
@@ -138,6 +116,8 @@ typedef struct board_info {
u8 phy_addr;
unsigned int flags;
+ int debug_level;
+
void (*inblk)(void __iomem *port, void *data, int length);
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
@@ -159,6 +139,15 @@ typedef struct board_info {
u32 msg_enable;
} board_info_t;
+/* debug code */
+
+#define dm9000_dbg(db, lev, msg...) do { \
+ if ((lev) < CONFIG_DM9000_DEBUGLEVEL && \
+ (lev) < db->debug_level) { \
+ dev_dbg(db->dev, msg); \
+ } \
+} while (0)
+
/* function declaration ------------------------------------- */
static int dm9000_probe(struct platform_device *);
static int dm9000_open(struct net_device *);
@@ -664,7 +653,7 @@ dm9000_init_dm9000(struct net_device *de
{
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK1("entering %s\n",__FUNCTION__);
+ dm9000_dbg(db, 1, "entering %s\n", __func__);
/* I/O mode */
db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
@@ -710,7 +699,7 @@ dm9000_start_xmit(struct sk_buff *skb, s
unsigned long flags;
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK3("dm9000_start_xmit\n");
+ dm9000_dbg(db, 3, "%s:\n", __func__);
if (db->tx_pkt_cnt > 1)
return 1;
@@ -769,7 +758,7 @@ dm9000_stop(struct net_device *ndev)
{
board_info_t *db = (board_info_t *) ndev->priv;
- PRINTK1("entering %s\n",__FUNCTION__);
+ dm9000_dbg(db, 1, "entering %s\n", __func__);
/* deleted timer */
del_timer(&db->timer);
@@ -815,19 +804,14 @@ static irqreturn_t
dm9000_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
- board_info_t *db;
+ board_info_t *db = (board_info_t *) dev->priv;
int int_status;
u8 reg_save;
- PRINTK3("entering %s\n",__FUNCTION__);
-
- if (!dev) {
- PRINTK1("dm9000_interrupt() without DEVICE arg\n");
- return IRQ_HANDLED;
- }
+ dm9000_dbg(db, 3, "entering %s\n", __func__);
/* A real interrupt coming */
- db = (board_info_t *) dev->priv;
+
spin_lock(&db->lock);
/* Save previous register address */
@@ -880,7 +864,7 @@ dm9000_timer(unsigned long data)
struct net_device *dev = (struct net_device *) data;
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK3("dm9000_timer()\n");
+ dm9000_dbg(db, 3, "entering %s\n", __func__);
mii_check_media(&db->mii, netif_msg_link(db), 0);
@@ -1065,7 +1049,7 @@ dm9000_hash_table(struct net_device *dev
u16 i, oft, hash_table[4];
unsigned long flags;
- PRINTK2("dm9000_hash_table()\n");
+ dm9000_dbg(db, 1, "entering %s\n", __func__);
spin_lock_irqsave(&db->lock,flags);
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 03/22] NET: DM9000: Pass IRQ flags via platform data
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
2007-11-19 20:39 ` [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output Ben Dooks
2007-11-19 20:39 ` [patch 02/22] NET: DM9000 update debugging macros to use debug level Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:36 ` Jeff Garzik
2007-11-19 20:39 ` [patch 04/22] NET: DM9000: Add initial ethtool support Ben Dooks
` (20 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-platdata-irq.patch --]
[-- Type: text/plain, Size: 2369 bytes --]
Use the platform data to pass modifications to the flags
passed to request_irq() to alter the behaviour of the IRQ.
This can be used to specify IRQ type for the platform the
DM9000 is connected to.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.22-quilt6/drivers/net/dm9000.c
===================================================================
--- linux-2.6.22-quilt6.orig/drivers/net/dm9000.c 2007-08-20 18:26:22.000000000 +0100
+++ linux-2.6.22-quilt6/drivers/net/dm9000.c 2007-08-20 18:37:54.000000000 +0100
@@ -89,9 +89,6 @@
#define writesb outsb
#define writesw outsw
#define writesl outsl
-#define DM9000_IRQ_FLAGS (IRQF_SHARED | IRQF_TRIGGER_HIGH)
-#else
-#define DM9000_IRQ_FLAGS IRQF_SHARED
#endif
/*
@@ -124,6 +121,8 @@ typedef struct board_info {
struct device *dev; /* parent device */
+ struct dm9000_plat_data *platdata;
+
struct resource *addr_res; /* resources found */
struct resource *data_res;
struct resource *addr_req; /* resources requested */
@@ -496,9 +495,11 @@ dm9000_probe(struct platform_device *pde
/* check to see if anything is being over-ridden */
if (pdata != NULL) {
+ db->platdata = pdata;
+
/* check to see if the driver wants to over-ride the
* default IO width */
-
+
if (pdata->flags & DM9000_PLATF_8BITONLY)
dm9000_set_io(db, 1);
@@ -619,10 +620,14 @@ static int
dm9000_open(struct net_device *dev)
{
board_info_t *db = (board_info_t *) dev->priv;
+ unsigned long irqflags = IRQF_SHARED;
dev_dbg(db->dev, "entering %s\n", __func__);
- if (request_irq(dev->irq, &dm9000_interrupt, DM9000_IRQ_FLAGS, dev->name, dev))
+ if (db->platdata)
+ irqflags |= db->platdata->irqflags;
+
+ if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
return -EAGAIN;
/* Initialize DM9000 board */
Index: linux-2.6.22-quilt6/include/linux/dm9000.h
===================================================================
--- linux-2.6.22-quilt6.orig/include/linux/dm9000.h 2007-08-20 18:19:04.000000000 +0100
+++ linux-2.6.22-quilt6/include/linux/dm9000.h 2007-08-20 18:28:37.000000000 +0100
@@ -25,6 +25,7 @@
struct dm9000_plat_data {
unsigned int flags;
+ unsigned long irqflags; /* to pass to request_irq() */
/* allow replacement IO routines */
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 04/22] NET: DM9000: Add initial ethtool support
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (2 preceding siblings ...)
2007-11-19 20:39 ` [patch 03/22] NET: DM9000: Pass IRQ flags via platform data Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:38 ` Jeff Garzik
2007-11-19 20:39 ` [patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held Ben Dooks
` (19 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-ethtool.patch --]
[-- Type: text/plain, Size: 3331 bytes --]
Add support for ethtool operations for the DM9000.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -63,6 +63,7 @@
#include <linux/spinlock.h>
#include <linux/crc32.h>
#include <linux/mii.h>
+#include <linux/ethtool.h>
#include <linux/dm9000.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
@@ -79,6 +80,7 @@
#define CARDNAME "dm9000"
#define PFX CARDNAME ": "
+#define DRV_VERSION "1.30"
#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */
@@ -147,6 +149,11 @@ typedef struct board_info {
} \
} while (0)
+static inline board_info_t *to_dm9000_board(struct net_device *dev)
+{
+ return dev->priv;
+}
+
/* function declaration ------------------------------------- */
static int dm9000_probe(struct platform_device *);
static int dm9000_open(struct net_device *);
@@ -348,6 +355,64 @@ static void dm9000_poll_controller(struc
}
#endif
+/* ethtool ops */
+
+static void dm9000_get_drvinfo(struct net_device *dev,
+ struct ethtool_drvinfo *info)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+
+ strcpy(info->driver, CARDNAME);
+ strcpy(info->version, DRV_VERSION);
+ strcpy(info->bus_info, to_platform_device(dm->dev)->name);
+}
+
+static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+ unsigned long flags;
+
+ spin_lock_irqsave(&dm->lock, flags);
+ mii_ethtool_gset(&dm->mii, cmd);
+ spin_lock_irqsave(&dm->lock, flags);
+
+ return 0;
+}
+
+static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave(&dm->lock, flags);
+ rc = mii_ethtool_sset(&dm->mii, cmd);
+ spin_lock_irqsave(&dm->lock, flags);
+
+ return rc;
+}
+
+static int dm9000_nway_reset(struct net_device *dev)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+ return mii_nway_restart(&dm->mii);
+}
+
+static u32 dm9000_get_link(struct net_device *dev)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+ return mii_link_ok(&dm->mii);
+}
+
+static const struct ethtool_ops dm9000_ethtool_ops = {
+ .get_drvinfo = dm9000_get_drvinfo,
+ .get_settings = dm9000_get_settings,
+ .set_settings = dm9000_set_settings,
+ .nway_reset = dm9000_nway_reset,
+ .get_link = dm9000_get_link,
+};
+
+
/* dm9000_release_board
*
* release a board, and any mapped resources
@@ -555,6 +620,8 @@ dm9000_probe(struct platform_device *pde
ndev->stop = &dm9000_stop;
ndev->get_stats = &dm9000_get_stats;
ndev->set_multicast_list = &dm9000_hash_table;
+ ndev->ethtool_ops = &dm9000_ethtool_ops;
+
#ifdef CONFIG_NET_POLL_CONTROLLER
ndev->poll_controller = &dm9000_poll_controller;
#endif
@@ -1211,7 +1278,7 @@ static struct platform_driver dm9000_dri
static int __init
dm9000_init(void)
{
- printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
+ printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
return platform_driver_register(&dm9000_driver); /* search board and register */
}
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (3 preceding siblings ...)
2007-11-19 20:39 ` [patch 04/22] NET: DM9000: Add initial ethtool support Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:38 ` Jeff Garzik
2007-11-19 20:39 ` [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open Ben Dooks
` (18 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-phy-unlocksleep.patch --]
[-- Type: text/plain, Size: 1886 bytes --]
The phy read and write routines call udelay() with the board
lock held, and with the posibility of IRQs being disabled. Since
these delays can be up to 500usec, and are only required as we
have to save the chip's address register.
To improve the behaviour, hold the lock whilst we are writing
and then restore the state before the delay and then repeat
the process once the delay has happened.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1171,7 +1171,15 @@ dm9000_phy_read(struct net_device *dev,
iow(db, DM9000_EPAR, DM9000_PHY | reg);
iow(db, DM9000_EPCR, 0xc); /* Issue phyxcer read command */
+
+ writeb(reg_save, db->io_addr);
+ spin_unlock_irqrestore(&db->lock,flags);
+
udelay(100); /* Wait read complete */
+
+ spin_lock_irqsave(&db->lock,flags);
+ reg_save = readb(db->io_addr);
+
iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer read command */
/* The read data keeps on REG_0D & REG_0E */
@@ -1179,7 +1187,6 @@ dm9000_phy_read(struct net_device *dev,
/* restore the previous address */
writeb(reg_save, db->io_addr);
-
spin_unlock_irqrestore(&db->lock,flags);
return ret;
@@ -1208,7 +1215,15 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
iow(db, DM9000_EPCR, 0xa); /* Issue phyxcer write command */
+
+ writeb(reg_save, db->io_addr);
+ spin_unlock_irqrestore(&db->lock,flags);
+
udelay(500); /* Wait write complete */
+
+ spin_lock_irqsave(&db->lock,flags);
+ reg_save = readb(db->io_addr);
+
iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */
/* restore the previous address */
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (4 preceding siblings ...)
2007-11-19 20:39 ` [patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-20 7:46 ` Christoph Hellwig
2007-11-24 1:38 ` Jeff Garzik
2007-11-19 20:39 ` [patch 07/22] NET: DM9000: Use msleep() instead of udelay() Ben Dooks
` (17 subsequent siblings)
23 siblings, 2 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-phy-usekthread.patch --]
[-- Type: text/plain, Size: 4327 bytes --]
When the device is open, we have to probe the PHY's MII status
periodically as there is no status change interrupt. As the
phy code is going to change to using calls which might sleep
we move to using a kthread instead of a timer.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -66,6 +66,8 @@
#include <linux/ethtool.h>
#include <linux/dm9000.h>
#include <linux/delay.h>
+#include <linux/kthread.h>
+#include <linux/freezer.h>
#include <linux/platform_device.h>
#include <asm/delay.h>
@@ -82,8 +84,6 @@
#define PFX CARDNAME ": "
#define DRV_VERSION "1.30"
-#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */
-
#ifdef CONFIG_BLACKFIN
#define readsb insb
#define readsw insw
@@ -131,7 +131,7 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
- struct timer_list timer;
+ struct task_struct *thread;
struct net_device_stats stats;
unsigned char srom[128];
spinlock_t lock;
@@ -159,9 +159,8 @@ static int dm9000_probe(struct platform_
static int dm9000_open(struct net_device *);
static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
static int dm9000_stop(struct net_device *);
+static int dm9000_mii_thread(void *data);
-
-static void dm9000_timer(unsigned long);
static void dm9000_init_dm9000(struct net_device *);
static struct net_device_stats *dm9000_get_stats(struct net_device *);
@@ -679,6 +678,27 @@ dm9000_probe(struct platform_device *pde
return ret;
}
+static void dm9000_start_thread(struct net_device *dev)
+{
+ board_info_t *db = (board_info_t *) dev->priv;
+
+ /* Create a thread to keep track of the state of the phy
+ * as we do not get an interrupt when the PHY state changes.
+ *
+ * Note, we do not abort the open if we fail to create the
+ * thread, as this is mainly to ensure the user is kept up to
+ * date with the device's state. PHY accesses will still work
+ * via the MII read and write methods.
+ */
+
+ db->thread = kthread_create(dm9000_mii_thread, db, dev->name);
+ if (IS_ERR(db->thread)) {
+ dev_err(db->dev, "failed to create MII thread\n");
+ db->thread = NULL;
+ } else
+ wake_up_process(db->thread);
+}
+
/*
* Open the interface.
* The interface is opened whenever "ifconfig" actives it.
@@ -704,12 +724,7 @@ dm9000_open(struct net_device *dev)
/* Init driver variable */
db->dbug_cnt = 0;
- /* set and active a timer process */
- init_timer(&db->timer);
- db->timer.expires = DM9000_TIMER_WUT;
- db->timer.data = (unsigned long) dev;
- db->timer.function = &dm9000_timer;
- add_timer(&db->timer);
+ dm9000_start_thread(dev);
mii_check_media(&db->mii, netif_msg_link(db), 1);
netif_start_queue(dev);
@@ -833,7 +848,7 @@ dm9000_stop(struct net_device *ndev)
dm9000_dbg(db, 1, "entering %s\n", __func__);
/* deleted timer */
- del_timer(&db->timer);
+ kthread_stop(db->thread);
netif_stop_queue(ndev);
netif_carrier_off(ndev);
@@ -925,24 +940,31 @@ dm9000_get_stats(struct net_device *dev)
return &db->stats;
}
+#define DM9000_MII_POLLFREQ (2000)
-/*
- * A periodic timer routine
- * Dynamic media sense, allocated Rx buffer...
- */
-static void
-dm9000_timer(unsigned long data)
+static int
+dm9000_mii_thread(void *pw)
{
- struct net_device *dev = (struct net_device *) data;
- board_info_t *db = (board_info_t *) dev->priv;
+ board_info_t *db = pw;
+ unsigned long next = jiffies + msecs_to_jiffies(DM9000_MII_POLLFREQ);
dm9000_dbg(db, 3, "entering %s\n", __func__);
- mii_check_media(&db->mii, netif_msg_link(db), 0);
+ while (!kthread_should_stop()) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ try_to_freeze();
+
+ if (time_after(jiffies, next)) {
+ mii_check_media(&db->mii, netif_msg_link(db), 0);
+ next = jiffies;
+ next += msecs_to_jiffies(DM9000_MII_POLLFREQ);
+ }
+
+ msleep_interruptible(DM9000_MII_POLLFREQ);
+ }
- /* Set timer again */
- db->timer.expires = DM9000_TIMER_WUT;
- add_timer(&db->timer);
+ dm9000_dbg(db, 3, "leaving %s\n", __func__);
+ return 0;
}
struct dm9000_rxhdr {
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 07/22] NET: DM9000: Use msleep() instead of udelay()
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (5 preceding siblings ...)
2007-11-19 20:39 ` [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:39 ` Jeff Garzik
2007-11-19 20:39 ` [patch 08/22] NET: DM9000: Remove barely used SROM array read Ben Dooks
` (16 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-phy-msleep.patch --]
[-- Type: text/plain, Size: 2191 bytes --]
We can use sleeping functions when reading and writing the
PHY registers, so let us sleep instead of busy waiting for
the PHY.
Note, this also fixes a bug reading the PHY where only 100uS
was being used instead of 150uS
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -114,6 +114,7 @@ typedef struct board_info {
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
unsigned int flags;
+ unsigned int in_suspend :1;
int debug_level;
@@ -1174,6 +1175,18 @@ dm9000_hash_table(struct net_device *dev
/*
+ * Sleep, either by using msleep() or if we are suspending, then
+ * use mdelay() to sleep.
+ */
+static void dm9000_msleep(board_info_t *db, unsigned int ms)
+{
+ if (db->in_suspend)
+ mdelay(ms);
+ else
+ msleep(ms);
+}
+
+/*
* Read a word from phyxcer
*/
static int
@@ -1197,7 +1210,7 @@ dm9000_phy_read(struct net_device *dev,
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
- udelay(100); /* Wait read complete */
+ dm9000_msleep(db, 1); /* Wait read complete */
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
@@ -1241,7 +1254,7 @@ dm9000_phy_write(struct net_device *dev,
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
- udelay(500); /* Wait write complete */
+ dm9000_msleep(db, 1); /* Wait write complete */
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
@@ -1258,8 +1271,12 @@ static int
dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
{
struct net_device *ndev = platform_get_drvdata(dev);
+ board_info_t *db;
if (ndev) {
+ db = (board_info_t *) ndev->priv;
+ db->in_suspend = 1;
+
if (netif_running(ndev)) {
netif_device_detach(ndev);
dm9000_shutdown(ndev);
@@ -1282,6 +1299,8 @@ dm9000_drv_resume(struct platform_device
netif_device_attach(ndev);
}
+
+ db->in_suspend = 0;
}
return 0;
}
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 08/22] NET: DM9000: Remove barely used SROM array read.
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (6 preceding siblings ...)
2007-11-19 20:39 ` [patch 07/22] NET: DM9000: Use msleep() instead of udelay() Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 09/22] NET: DM9000: Add mutex to protect access Ben Dooks
` (15 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-remove-srom-read.patch --]
[-- Type: text/plain, Size: 2673 bytes --]
The srom array in the board data is only being used in the device probe
routines. The probe also only uses the first 6 bytes of an array
we spend 512ms reading 128 bytes from. Change to reading the
MAC area directly to the MAC address structure.
As a side product, we rename the read_srom_word to dm9000_read_eeprom
to bring it into line with the rest of the driver. No change is made
to the delay in this function, which will be dealt with in a later
patch.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt5/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt5.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt5/drivers/net/dm9000.c
@@ -134,7 +134,6 @@ typedef struct board_info {
struct task_struct *thread;
struct net_device_stats stats;
- unsigned char srom[128];
spinlock_t lock;
struct mii_if_info mii;
@@ -171,7 +170,8 @@ static irqreturn_t dm9000_interrupt(int,
static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg);
static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg,
int value);
-static u16 read_srom_word(board_info_t *, int);
+
+static void dm9000_read_eeprom(board_info_t *, int addr, unsigned char *to);
static void dm9000_rx(struct net_device *);
static void dm9000_hash_table(struct net_device *);
@@ -638,13 +638,9 @@ dm9000_probe(struct platform_device *pde
db->mii.mdio_read = dm9000_phy_read;
db->mii.mdio_write = dm9000_phy_write;
- /* Read SROM content */
- for (i = 0; i < 64; i++)
- ((u16 *) db->srom)[i] = read_srom_word(db, i);
-
- /* Set Node Address */
- for (i = 0; i < 6; i++)
- ndev->dev_addr[i] = db->srom[i];
+ /* try reading the node address from the attached EEPROM */
+ for (i = 0; i < 6; i += 2)
+ dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
@@ -1064,17 +1060,19 @@ dm9000_rx(struct net_device *dev)
}
/*
- * Read a word data from SROM
+ * Read a word data from EEPROM
*/
-static u16
-read_srom_word(board_info_t * db, int offset)
+static void
+dm9000_read_eeprom(board_info_t * db, int offset, unsigned char *to)
{
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
mdelay(8); /* according to the datasheet 200us should be enough,
but it doesn't work */
iow(db, DM9000_EPCR, 0x0);
- return (ior(db, DM9000_EPDRL) + (ior(db, DM9000_EPDRH) << 8));
+
+ to[0] = ior(db, DM9000_EPDRL);
+ to[1] = ior(db, DM9000_EPDRH);
}
#ifdef DM9000_PROGRAM_EEPROM
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 09/22] NET: DM9000: Add mutex to protect access
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (7 preceding siblings ...)
2007-11-19 20:39 ` [patch 08/22] NET: DM9000: Remove barely used SROM array read Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 10/22] NET: DM9000: Add ethtool support for reading and writing EEPROM Ben Dooks
` (14 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-lock-eeprom.patch --]
[-- Type: text/plain, Size: 5010 bytes --]
Add a mutex to serialise access to the chip functions from
entries such as the ethtool and the MII code. This should
reduce the amount of time the spinlock is held to protect
the address register.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -100,6 +100,24 @@ static int watchdog = 5000;
module_param(watchdog, int, 0400);
MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
+/* DM9000 register address locking.
+ *
+ * The DM9000 uses an address register to control where data written
+ * to the data register goes. This means that the address register
+ * must be preserved over interrupts or similar calls.
+ *
+ * During interrupt and other critical calls, a spinlock is used to
+ * protect the system, but the calls themselves save the address
+ * in the address register in case they are interrupting another
+ * access to the device.
+ *
+ * For general accesses a lock is provided so that calls which are
+ * allowed to sleep are serialised so that the address register does
+ * not need to be saved. This lock also serves to serialise access
+ * to the EEPROM and PHY access registers which are shared between
+ * these two devices.
+ */
+
/* Structure/enum declaration ------------------------------- */
typedef struct board_info {
@@ -132,6 +150,8 @@ typedef struct board_info {
struct resource *data_req;
struct resource *irq_res;
+ struct mutex addr_lock; /* phy and eeprom access lock */
+
struct task_struct *thread;
struct net_device_stats stats;
spinlock_t lock;
@@ -370,26 +390,16 @@ static void dm9000_get_drvinfo(struct ne
static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
board_info_t *dm = to_dm9000_board(dev);
- unsigned long flags;
- spin_lock_irqsave(&dm->lock, flags);
mii_ethtool_gset(&dm->mii, cmd);
- spin_lock_irqsave(&dm->lock, flags);
-
return 0;
}
static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
board_info_t *dm = to_dm9000_board(dev);
- unsigned long flags;
- int rc;
-
- spin_lock_irqsave(&dm->lock, flags);
- rc = mii_ethtool_sset(&dm->mii, cmd);
- spin_lock_irqsave(&dm->lock, flags);
- return rc;
+ return mii_ethtool_sset(&dm->mii, cmd);
}
static int dm9000_nway_reset(struct net_device *dev)
@@ -481,6 +491,7 @@ dm9000_probe(struct platform_device *pde
db->dev = &pdev->dev;
spin_lock_init(&db->lock);
+ mutex_init(&db->addr_lock);
if (pdev->num_resources < 2) {
ret = -ENODEV;
@@ -1063,8 +1074,10 @@ dm9000_rx(struct net_device *dev)
* Read a word data from EEPROM
*/
static void
-dm9000_read_eeprom(board_info_t * db, int offset, unsigned char *to)
+dm9000_read_eeprom(board_info_t *db, int offset, unsigned char *to)
{
+ mutex_lock(&db->addr_lock);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
mdelay(8); /* according to the datasheet 200us should be enough,
@@ -1073,6 +1086,8 @@ dm9000_read_eeprom(board_info_t * db, in
to[0] = ior(db, DM9000_EPDRL);
to[1] = ior(db, DM9000_EPDRH);
+
+ mutex_unlock(&db->addr_lock);
}
#ifdef DM9000_PROGRAM_EEPROM
@@ -1082,12 +1097,16 @@ dm9000_read_eeprom(board_info_t * db, in
static void
write_srom_word(board_info_t * db, int offset, u16 val)
{
+ mutex_lock(&db->addr_lock);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPDRH, ((val >> 8) & 0xff));
iow(db, DM9000_EPDRL, (val & 0xff));
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
mdelay(8); /* same shit */
iow(db, DM9000_EPCR, 0);
+
+ mutex_unlock(&db->addr_lock);
}
/*
@@ -1195,6 +1214,8 @@ dm9000_phy_read(struct net_device *dev,
unsigned int reg_save;
int ret;
+ mutex_lock(&db->addr_lock);
+
spin_lock_irqsave(&db->lock,flags);
/* Save previous register address */
@@ -1222,6 +1243,7 @@ dm9000_phy_read(struct net_device *dev,
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
+ mutex_unlock(&db->addr_lock);
return ret;
}
@@ -1235,6 +1257,8 @@ dm9000_phy_write(struct net_device *dev,
unsigned long flags;
unsigned long reg_save;
+ mutex_lock(&db->addr_lock);
+
spin_lock_irqsave(&db->lock,flags);
/* Save previous register address */
@@ -1250,7 +1274,7 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPCR, 0xa); /* Issue phyxcer write command */
writeb(reg_save, db->io_addr);
- spin_unlock_irqrestore(&db->lock,flags);
+ spin_unlock_irqrestore(&db->lock, flags);
dm9000_msleep(db, 1); /* Wait write complete */
@@ -1262,7 +1286,8 @@ dm9000_phy_write(struct net_device *dev,
/* restore the previous address */
writeb(reg_save, db->io_addr);
- spin_unlock_irqrestore(&db->lock,flags);
+ spin_unlock_irqrestore(&db->lock, flags);
+ mutex_unlock(&db->addr_lock);
}
static int
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 10/22] NET: DM9000: Add ethtool support for reading and writing EEPROM
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (8 preceding siblings ...)
2007-11-19 20:39 ` [patch 09/22] NET: DM9000: Add mutex to protect access Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 11/22] NET: DM9000: Add ethtool control of msg_enable value Ben Dooks
` (13 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-ethtool-eeprom.patch --]
[-- Type: text/plain, Size: 3532 bytes --]
Add ethtool support to access the configuration EEPROM
connected to the DM9000.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -191,7 +191,8 @@ static int dm9000_phy_read(struct net_de
static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg,
int value);
-static void dm9000_read_eeprom(board_info_t *, int addr, unsigned char *to);
+static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
+static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
static void dm9000_rx(struct net_device *);
static void dm9000_hash_table(struct net_device *);
@@ -414,12 +415,65 @@ static u32 dm9000_get_link(struct net_de
return mii_link_ok(&dm->mii);
}
+#define DM_EEPROM_MAGIC (0x444D394B)
+
+static int dm9000_get_eeprom_len(struct net_device *dev)
+{
+ return 128;
+}
+
+static int dm9000_get_eeprom(struct net_device *dev,
+ struct ethtool_eeprom *ee, u8 *data)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+ int offset = ee->offset;
+ int len = ee->len;
+ int i;
+
+ /* EEPROM access is aligned to two bytes */
+
+ if ((len & 1) != 0 || (offset & 1) != 0)
+ return -EINVAL;
+
+ ee->magic = DM_EEPROM_MAGIC;
+
+ for (i = 0; i < len; i += 2)
+ dm9000_read_eeprom(dm, (offset + i) / 2, data + i);
+
+ return 0;
+}
+
+static int dm9000_set_eeprom(struct net_device *dev,
+ struct ethtool_eeprom *ee, u8 *data)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+ int offset = ee->offset;
+ int len = ee->len;
+ int i;
+
+ /* EEPROM access is aligned to two bytes */
+
+ if ((len & 1) != 0 || (offset & 1) != 0)
+ return -EINVAL;
+
+ if (ee->magic != DM_EEPROM_MAGIC)
+ return -EINVAL;
+
+ for (i = 0; i < len; i += 2)
+ dm9000_write_eeprom(dm, (offset + i) / 2, data + i);
+
+ return 0;
+}
+
static const struct ethtool_ops dm9000_ethtool_ops = {
.get_drvinfo = dm9000_get_drvinfo,
.get_settings = dm9000_get_settings,
.set_settings = dm9000_set_settings,
.nway_reset = dm9000_nway_reset,
.get_link = dm9000_get_link,
+ .get_eeprom_len = dm9000_get_eeprom_len,
+ .get_eeprom = dm9000_get_eeprom,
+ .set_eeprom = dm9000_set_eeprom,
};
@@ -1074,7 +1128,7 @@ dm9000_rx(struct net_device *dev)
* Read a word data from EEPROM
*/
static void
-dm9000_read_eeprom(board_info_t *db, int offset, unsigned char *to)
+dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
{
mutex_lock(&db->addr_lock);
@@ -1090,18 +1144,17 @@ dm9000_read_eeprom(board_info_t *db, int
mutex_unlock(&db->addr_lock);
}
-#ifdef DM9000_PROGRAM_EEPROM
/*
* Write a word data to SROM
*/
static void
-write_srom_word(board_info_t * db, int offset, u16 val)
+dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
{
mutex_lock(&db->addr_lock);
iow(db, DM9000_EPAR, offset);
- iow(db, DM9000_EPDRH, ((val >> 8) & 0xff));
- iow(db, DM9000_EPDRL, (val & 0xff));
+ iow(db, DM9000_EPDRH, data[1]);
+ iow(db, DM9000_EPDRL, data[0]);
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
mdelay(8); /* same shit */
iow(db, DM9000_EPCR, 0);
@@ -1109,6 +1162,7 @@ write_srom_word(board_info_t * db, int o
mutex_unlock(&db->addr_lock);
}
+#ifdef DM9000_PROGRAM_EEPROM
/*
* Only for development:
* Here we write static data to the eeprom in case
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 11/22] NET: DM9000: Add ethtool control of msg_enable value
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (9 preceding siblings ...)
2007-11-19 20:39 ` [patch 10/22] NET: DM9000: Add ethtool support for reading and writing EEPROM Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 12/22] NET: DM9000: Remove EEPROM initialisation code Ben Dooks
` (12 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-ethtool-msglevel.patch --]
[-- Type: text/plain, Size: 1325 bytes --]
Allow the msg_enable value to be read and written by
the ethtool interface.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -388,6 +388,20 @@ static void dm9000_get_drvinfo(struct ne
strcpy(info->bus_info, to_platform_device(dm->dev)->name);
}
+static u32 dm9000_get_msglevel(struct net_device *dev)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+
+ return dm->msg_enable;
+}
+
+static void dm9000_set_msglevel(struct net_device *dev, u32 value)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+
+ dm->msg_enable = value;
+}
+
static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
board_info_t *dm = to_dm9000_board(dev);
@@ -469,6 +483,8 @@ static const struct ethtool_ops dm9000_e
.get_drvinfo = dm9000_get_drvinfo,
.get_settings = dm9000_get_settings,
.set_settings = dm9000_set_settings,
+ .get_msglevel = dm9000_get_msglevel,
+ .set_msglevel = dm9000_set_msglevel,
.nway_reset = dm9000_nway_reset,
.get_link = dm9000_get_link,
.get_eeprom_len = dm9000_get_eeprom_len,
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 12/22] NET: DM9000: Remove EEPROM initialisation code.
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (10 preceding siblings ...)
2007-11-19 20:39 ` [patch 11/22] NET: DM9000: Add ethtool control of msg_enable value Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 13/22] NET: DM9000: Ensure spinlock held whilst accessing EEPROM registers Ben Dooks
` (11 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-remove-eeprom-program.patch --]
[-- Type: text/plain, Size: 1876 bytes --]
Remove the old hack to program an initial EEPROM setting
into the DM9000 as we now have ethtool support for reading
and writing the EEPROM.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -196,10 +196,6 @@ static void dm9000_write_eeprom(board_in
static void dm9000_rx(struct net_device *);
static void dm9000_hash_table(struct net_device *);
-//#define DM9000_PROGRAM_EEPROM
-#ifdef DM9000_PROGRAM_EEPROM
-static void program_eeprom(board_info_t * db);
-#endif
/* DM9000 network board routine ---------------------------- */
static void
@@ -707,9 +703,6 @@ dm9000_probe(struct platform_device *pde
ndev->poll_controller = &dm9000_poll_controller;
#endif
-#ifdef DM9000_PROGRAM_EEPROM
- program_eeprom(db);
-#endif
db->msg_enable = NETIF_MSG_LINK;
db->mii.phy_id_mask = 0x1f;
db->mii.reg_num_mask = 0x1f;
@@ -1178,28 +1171,6 @@ dm9000_write_eeprom(board_info_t *db, in
mutex_unlock(&db->addr_lock);
}
-#ifdef DM9000_PROGRAM_EEPROM
-/*
- * Only for development:
- * Here we write static data to the eeprom in case
- * we don't have valid content on a new board
- */
-static void
-program_eeprom(board_info_t * db)
-{
- u16 eeprom[] = { 0x0c00, 0x007f, 0x1300, /* MAC Address */
- 0x0000, /* Autoload: accept nothing */
- 0x0a46, 0x9000, /* Vendor / Product ID */
- 0x0000, /* pin control */
- 0x0000,
- }; /* Wake-up mode control */
- int i;
- for (i = 0; i < 8; i++)
- write_srom_word(db, i, eeprom[i]);
-}
-#endif
-
-
/*
* Calculate the CRC valude of the Rx packet
* flag = 1 : return the reverse CRC (for the received packet CRC)
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 13/22] NET: DM9000: Ensure spinlock held whilst accessing EEPROM registers
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (11 preceding siblings ...)
2007-11-19 20:39 ` [patch 12/22] NET: DM9000: Remove EEPROM initialisation code Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment Ben Dooks
` (10 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-spinlock-eeprom.patch --]
[-- Type: text/plain, Size: 1810 bytes --]
Ensure we hold the spinlock whilst the registers and being
modified even though we hold the overall lock. This should
protect against an interrupt happening whilst we are using
the device.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1139,17 +1139,29 @@ dm9000_rx(struct net_device *dev)
static void
dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
{
+ unsigned long flags;
+
mutex_lock(&db->addr_lock);
+ spin_lock_irqsave(&db->lock, flags);
+
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPCR, EPCR_ERPRR);
+
+ spin_unlock_irqrestore(&db->lock, flags);
+
mdelay(8); /* according to the datasheet 200us should be enough,
but it doesn't work */
+
+ spin_lock_irqsave(&db->lock, flags);
+
iow(db, DM9000_EPCR, 0x0);
to[0] = ior(db, DM9000_EPDRL);
to[1] = ior(db, DM9000_EPDRH);
+ spin_unlock_irqrestore(&db->lock, flags);
+
mutex_unlock(&db->addr_lock);
}
@@ -1159,14 +1171,22 @@ dm9000_read_eeprom(board_info_t *db, int
static void
dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
{
+ unsigned long flags;
+
mutex_lock(&db->addr_lock);
+ spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPAR, offset);
iow(db, DM9000_EPDRH, data[1]);
iow(db, DM9000_EPDRL, data[0]);
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
+ spin_unlock_irqrestore(&db->lock, flags);
+
mdelay(8); /* same shit */
+
+ spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPCR, 0);
+ spin_unlock_irqrestore(&db->lock, flags);
mutex_unlock(&db->addr_lock);
}
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (12 preceding siblings ...)
2007-11-19 20:39 ` [patch 13/22] NET: DM9000: Ensure spinlock held whilst accessing EEPROM registers Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:41 ` Jeff Garzik
2007-11-19 20:39 ` [patch 15/22] NET: DM9000: Use netif_msg to enable debugging options Ben Dooks
` (9 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-tidy-remove-changelog.patch --]
[-- Type: text/plain, Size: 2654 bytes --]
We have a perfectly good version control system, so we do not
need to duplicate change comments in the header for this code.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt2/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt2.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt2/drivers/net/dm9000.c
@@ -1,7 +1,5 @@
/*
- * dm9000.c: Version 1.2 03/18/2003
- *
- * A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
+ * Davicom DM9000 Fast Ethernet driver for Linux.
* Copyright (C) 1997 Sten Wang
*
* This program is free software; you can redistribute it and/or
@@ -14,44 +12,11 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
- *
- * V0.11 06/20/2001 REG_0A bit3=1, default enable BP with DA match
- * 06/22/2001 Support DM9801 progrmming
- * E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
- * E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
- * R17 = (R17 & 0xfff0) | NF + 3
- * E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
- * R17 = (R17 & 0xfff0) | NF
- *
- * v1.00 modify by simon 2001.9.5
- * change for kernel 2.4.x
- *
- * v1.1 11/09/2001 fix force mode bug
- *
- * v1.2 03/18/2003 Weilun Huang <weilun_huang@davicom.com.tw>:
- * Fixed phy reset.
- * Added tx/rx 32 bit mode.
- * Cleaned up for kernel merge.
- *
- * 03/03/2004 Sascha Hauer <s.hauer@pengutronix.de>
- * Port to 2.6 kernel
- *
- * 24-Sep-2004 Ben Dooks <ben@simtec.co.uk>
- * Cleanup of code to remove ifdefs
- * Allowed platform device data to influence access width
- * Reformatting areas of code
- *
- * 17-Mar-2005 Sascha Hauer <s.hauer@pengutronix.de>
- * * removed 2.4 style module parameters
- * * removed removed unused stat counter and fixed
- * net_device_stats
- * * introduced tx_timeout function
- * * reworked locking
+ * (C) Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
*
- * 01-Jul-2005 Ben Dooks <ben@simtec.co.uk>
- * * fixed spinlock call without pointer
- * * ensure spinlock is initialised
+ * Additional updates, Copyright:
+ * Ben Dooks <ben@simtec.co.uk>
+ * Sascha Hauer <s.hauer@pengutronix.de>
*/
#include <linux/module.h>
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 15/22] NET: DM9000: Use netif_msg to enable debugging options
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (13 preceding siblings ...)
2007-11-19 20:39 ` [patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:42 ` Jeff Garzik
2007-11-19 20:39 ` [patch 16/22] NET: DM9000: Fix delays used by EEPROM read and write Ben Dooks
` (8 subsequent siblings)
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-debug-msglevel.patch --]
[-- Type: text/plain, Size: 2943 bytes --]
Use the netif_msg_*() macros to enable the debugging based
on the board's msg_enable field. The output still goes via
the dev_dbg() macros, so will be tagged and output as
appropriate.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt4/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt4.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt4/drivers/net/dm9000.c
@@ -745,7 +745,8 @@ dm9000_open(struct net_device *dev)
board_info_t *db = (board_info_t *) dev->priv;
unsigned long irqflags = IRQF_SHARED;
- dev_dbg(db->dev, "entering %s\n", __func__);
+ if (netif_msg_ifup(db))
+ dev_dbg(db->dev, "enabling %s\n", dev->name);
if (db->platdata)
irqflags |= db->platdata->irqflags;
@@ -881,7 +882,8 @@ dm9000_stop(struct net_device *ndev)
{
board_info_t *db = (board_info_t *) ndev->priv;
- dm9000_dbg(db, 1, "entering %s\n", __func__);
+ if (netif_msg_ifdown(db))
+ dev_dbg(db->dev, "shutting down %s\n", ndev->name);
/* deleted timer */
kthread_stop(db->thread);
@@ -912,6 +914,9 @@ dm9000_tx_done(struct net_device *dev, b
db->tx_pkt_cnt--;
db->stats.tx_packets++;
+ if (netif_msg_tx_done(db))
+ dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status);
+
/* Queue packet check & send */
if (db->tx_pkt_cnt > 0) {
iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff);
@@ -947,6 +952,9 @@ dm9000_interrupt(int irq, void *dev_id)
int_status = ior(db, DM9000_ISR); /* Got ISR */
iow(db, DM9000_ISR, int_status); /* Clear ISR status */
+ if (netif_msg_intr(db))
+ dev_dbg(db->dev, "interrupt status %02x\n", int_status);
+
/* Received the coming packet */
if (int_status & ISR_PRS)
dm9000_rx(dev);
@@ -1048,10 +1056,15 @@ dm9000_rx(struct net_device *dev)
RxLen = le16_to_cpu(rxhdr.RxLen);
+ if (netif_msg_rx_status(db))
+ dev_dbg(db->dev, "RX: status %02x, length %04x\n",
+ rxhdr.RxStatus, RxLen);
+
/* Packet Status check */
if (RxLen < 0x40) {
GoodPacket = false;
- dev_dbg(db->dev, "Bad Packet received (runt)\n");
+ if (netif_msg_rx_err(db))
+ dev_dbg(db->dev, "RX: Bad Packet (runt)\n");
}
if (RxLen > DM9000_PKT_MAX) {
@@ -1061,15 +1074,18 @@ dm9000_rx(struct net_device *dev)
if (rxhdr.RxStatus & 0xbf) {
GoodPacket = false;
if (rxhdr.RxStatus & 0x01) {
- dev_dbg(db->dev, "fifo error\n");
+ if (netif_msg_rx_err(db))
+ dev_dbg(db->dev, "fifo error\n");
db->stats.rx_fifo_errors++;
}
if (rxhdr.RxStatus & 0x02) {
- dev_dbg(db->dev, "crc error\n");
+ if (netif_msg_rx_err(db))
+ dev_dbg(db->dev, "crc error\n");
db->stats.rx_crc_errors++;
}
if (rxhdr.RxStatus & 0x80) {
- dev_dbg(db->dev, "length error\n");
+ if (netif_msg_rx_err(db))
+ dev_dbg(db->dev, "length error\n");
db->stats.rx_length_errors++;
}
}
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 16/22] NET: DM9000: Fix delays used by EEPROM read and write
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (14 preceding siblings ...)
2007-11-19 20:39 ` [patch 15/22] NET: DM9000: Use netif_msg to enable debugging options Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 17/22] NET: DM9000: Remove cal_CRC() and use ether_crc_le instead Ben Dooks
` (7 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-eeprom-rwfix.patch --]
[-- Type: text/plain, Size: 2257 bytes --]
The code was using a delay of 8ms, when it should have been
using the EEPROM status flag from the device to indicate the
EEPROM transaction had finished.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1114,6 +1114,50 @@ dm9000_rx(struct net_device *dev)
} while (rxbyte == DM9000_PKT_RDY);
}
+static unsigned int
+dm9000_read_locked(board_info_t *db, int reg)
+{
+ unsigned long flags;
+ unsigned int ret;
+
+ spin_lock_irqsave(&db->lock, flags);
+ ret = ior(db, reg);
+ spin_unlock_irqrestore(&db->lock, flags);
+
+ return ret;
+}
+
+static int dm9000_wait_eeprom(board_info_t *db)
+{
+ unsigned int status;
+ int timeout = 8; /* wait max 8msec */
+
+ /* The DM9000 data sheets say we should be able to
+ * poll the ERRE bit in EPCR to wait for the EEPROM
+ * operation. From testing several chips, this bit
+ * does not seem to work.
+ *
+ * We attempt to use the bit, but fall back to the
+ * timeout (which is why we do not return an error
+ * on expiry) to say that the EEPROM operation has
+ * completed.
+ */
+
+ while (1) {
+ status = dm9000_read_locked(db, DM9000_EPCR);
+
+ if ((status & EPCR_ERRE) == 0)
+ break;
+
+ if (timeout-- < 0) {
+ dev_dbg(db->dev, "timeout waiting EEPROM\n");
+ break;
+ }
+ }
+
+ return 0;
+}
+
/*
* Read a word data from EEPROM
*/
@@ -1131,8 +1175,10 @@ dm9000_read_eeprom(board_info_t *db, int
spin_unlock_irqrestore(&db->lock, flags);
- mdelay(8); /* according to the datasheet 200us should be enough,
- but it doesn't work */
+ dm9000_wait_eeprom(db);
+
+ /* delay for at-least 150uS */
+ msleep(1);
spin_lock_irqsave(&db->lock, flags);
@@ -1163,7 +1209,9 @@ dm9000_write_eeprom(board_info_t *db, in
iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
spin_unlock_irqrestore(&db->lock, flags);
- mdelay(8); /* same shit */
+ dm9000_wait_eeprom(db);
+
+ mdelay(1); /* wait at least 150uS to clear */
spin_lock_irqsave(&db->lock, flags);
iow(db, DM9000_EPCR, 0);
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 17/22] NET: DM9000: Remove cal_CRC() and use ether_crc_le instead
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (15 preceding siblings ...)
2007-11-19 20:39 ` [patch 16/22] NET: DM9000: Fix delays used by EEPROM read and write Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 18/22] NET: DM9000: Remove redudant use of "& 0xff" Ben Dooks
` (6 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-cleanup-removecrc.patch --]
[-- Type: text/plain, Size: 2328 bytes --]
Remove the cal_CRC as this is basically wrappering the
ether_crc_le function, and is only being used by the
multicast hash table functions.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -1221,24 +1221,6 @@ dm9000_write_eeprom(board_info_t *db, in
}
/*
- * Calculate the CRC valude of the Rx packet
- * flag = 1 : return the reverse CRC (for the received packet CRC)
- * 0 : return the normal CRC (for Hash Table index)
- */
-
-static unsigned long
-cal_CRC(unsigned char *Data, unsigned int Len, u8 flag)
-{
-
- u32 crc = ether_crc_le(Len, Data);
-
- if (flag)
- return ~crc;
-
- return crc;
-}
-
-/*
* Set DM9000 multicast address
*/
static void
@@ -1247,15 +1229,16 @@ dm9000_hash_table(struct net_device *dev
board_info_t *db = (board_info_t *) dev->priv;
struct dev_mc_list *mcptr = dev->mc_list;
int mc_cnt = dev->mc_count;
+ int i, oft;
u32 hash_val;
- u16 i, oft, hash_table[4];
+ u16 hash_table[4];
unsigned long flags;
dm9000_dbg(db, 1, "entering %s\n", __func__);
- spin_lock_irqsave(&db->lock,flags);
+ spin_lock_irqsave(&db->lock, flags);
- for (i = 0, oft = 0x10; i < 6; i++, oft++)
+ for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
iow(db, oft, dev->dev_addr[i]);
/* Clear Hash Table */
@@ -1267,17 +1250,17 @@ dm9000_hash_table(struct net_device *dev
/* the multicast address in Hash Table : 64 bits */
for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
- hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f;
+ hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
}
/* Write the hash table to MAC MD table */
- for (i = 0, oft = 0x16; i < 4; i++) {
- iow(db, oft++, hash_table[i] & 0xff);
- iow(db, oft++, (hash_table[i] >> 8) & 0xff);
+ for (i = 0, oft = DM9000_MAR; i < 4; i++) {
+ iow(db, oft++, hash_table[i]);
+ iow(db, oft++, hash_table[i] >> 8);
}
- spin_unlock_irqrestore(&db->lock,flags);
+ spin_unlock_irqrestore(&db->lock, flags);
}
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 18/22] NET: DM9000: Remove redudant use of "& 0xff"
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (16 preceding siblings ...)
2007-11-19 20:39 ` [patch 17/22] NET: DM9000: Remove cal_CRC() and use ether_crc_le instead Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 19/22] NET: DM9000: Add platform flag for no attached EEPROM Ben Dooks
` (5 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-cleanup-remove-ands.patch --]
[-- Type: text/plain, Size: 1715 bytes --]
The writing of the data should implicitly truncate
the data to 8bits, so do not bother with the ands
in the code.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -840,8 +840,8 @@ dm9000_start_xmit(struct sk_buff *skb, s
/* TX control: First packet immediately send, second packet queue */
if (db->tx_pkt_cnt == 1) {
/* Set TX length to DM9000 */
- iow(db, DM9000_TXPLL, skb->len & 0xff);
- iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff);
+ iow(db, DM9000_TXPLL, skb->len);
+ iow(db, DM9000_TXPLH, skb->len >> 8);
/* Issue TX polling command */
iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
@@ -919,8 +919,8 @@ dm9000_tx_done(struct net_device *dev, b
/* Queue packet check & send */
if (db->tx_pkt_cnt > 0) {
- iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff);
- iow(db, DM9000_TXPLH, (db->queue_pkt_len >> 8) & 0xff);
+ iow(db, DM9000_TXPLL, db->queue_pkt_len);
+ iow(db, DM9000_TXPLH, db->queue_pkt_len >> 8);
iow(db, DM9000_TCR, TCR_TXREQ);
dev->trans_start = jiffies;
}
@@ -1341,8 +1341,8 @@ dm9000_phy_write(struct net_device *dev,
iow(db, DM9000_EPAR, DM9000_PHY | reg);
/* Fill the written data into REG_0D & REG_0E */
- iow(db, DM9000_EPDRL, (value & 0xff));
- iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
+ iow(db, DM9000_EPDRL, value);
+ iow(db, DM9000_EPDRH, value >> 8);
iow(db, DM9000_EPCR, 0xa); /* Issue phyxcer write command */
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 19/22] NET: DM9000: Add platform flag for no attached EEPROM
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (17 preceding siblings ...)
2007-11-19 20:39 ` [patch 18/22] NET: DM9000: Remove redudant use of "& 0xff" Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 20/22] NET: DM9000: Add support for MII ioctl() calls Ben Dooks
` (4 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-no-eeprom-flag.patch --]
[-- Type: text/plain, Size: 1970 bytes --]
Allow the platform data to specify to the DM9000 driver
that there is no posibility of an attached EEPROM on the
device, so default all reads to 0xff and ignore any
write operations.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -410,6 +410,9 @@ static int dm9000_get_eeprom(struct net_
if ((len & 1) != 0 || (offset & 1) != 0)
return -EINVAL;
+ if (dm->flags & DM9000_PLATF_NO_EEPROM)
+ return -ENOENT;
+
ee->magic = DM_EEPROM_MAGIC;
for (i = 0; i < len; i += 2)
@@ -431,6 +434,9 @@ static int dm9000_set_eeprom(struct net_
if ((len & 1) != 0 || (offset & 1) != 0)
return -EINVAL;
+ if (dm->flags & DM9000_PLATF_NO_EEPROM)
+ return -ENOENT;
+
if (ee->magic != DM_EEPROM_MAGIC)
return -EINVAL;
@@ -1166,6 +1172,12 @@ dm9000_read_eeprom(board_info_t *db, int
{
unsigned long flags;
+ if (db->flags & DM9000_PLATF_NO_EEPROM) {
+ to[0] = 0xff;
+ to[1] = 0xff;
+ return;
+ }
+
mutex_lock(&db->addr_lock);
spin_lock_irqsave(&db->lock, flags);
@@ -1200,6 +1212,9 @@ dm9000_write_eeprom(board_info_t *db, in
{
unsigned long flags;
+ if (db->flags & DM9000_PLATF_NO_EEPROM)
+ return;
+
mutex_lock(&db->addr_lock);
spin_lock_irqsave(&db->lock, flags);
Index: linux-2.6.23-quilt3/include/linux/dm9000.h
===================================================================
--- linux-2.6.23-quilt3.orig/include/linux/dm9000.h
+++ linux-2.6.23-quilt3/include/linux/dm9000.h
@@ -20,6 +20,7 @@
#define DM9000_PLATF_16BITONLY (0x0002)
#define DM9000_PLATF_32BITONLY (0x0004)
#define DM9000_PLATF_EXT_PHY (0x0008)
+#define DM9000_PLATF_NO_EEPROM (0x0010)
/* platfrom data for platfrom device structure's platfrom_data field */
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 20/22] NET: DM9000: Add support for MII ioctl() calls
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (18 preceding siblings ...)
2007-11-19 20:39 ` [patch 19/22] NET: DM9000: Add platform flag for no attached EEPROM Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 21/22] NET: DM9000: Update retry count whilst identifying chip Ben Dooks
` (3 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-mii-ioctl.patch --]
[-- Type: text/plain, Size: 1451 bytes --]
Add entry to handle the MII ioctl() calls via the
generic_mii_ioctl call.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -148,6 +148,8 @@ static int dm9000_mii_thread(void *data)
static void dm9000_init_dm9000(struct net_device *);
+static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
+
static struct net_device_stats *dm9000_get_stats(struct net_device *);
static irqreturn_t dm9000_interrupt(int, void *);
@@ -337,6 +339,16 @@ static void dm9000_poll_controller(struc
}
#endif
+static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
+{
+ board_info_t *dm = to_dm9000_board(dev);
+
+ if (!netif_running(dev))
+ return -EINVAL;
+
+ return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
+}
+
/* ethtool ops */
static void dm9000_get_drvinfo(struct net_device *dev,
@@ -669,6 +681,7 @@ dm9000_probe(struct platform_device *pde
ndev->get_stats = &dm9000_get_stats;
ndev->set_multicast_list = &dm9000_hash_table;
ndev->ethtool_ops = &dm9000_ethtool_ops;
+ ndev->do_ioctl = &dm9000_ioctl;
#ifdef CONFIG_NET_POLL_CONTROLLER
ndev->poll_controller = &dm9000_poll_controller;
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 21/22] NET: DM9000: Update retry count whilst identifying chip
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (19 preceding siblings ...)
2007-11-19 20:39 ` [patch 20/22] NET: DM9000: Add support for MII ioctl() calls Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-19 20:39 ` [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC Ben Dooks
` (2 subsequent siblings)
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/simtec-drivers-net-dm9000-id-retry.patch --]
[-- Type: text/plain, Size: 959 bytes --]
Reading the ID register does not always return the correct ID
from the device, so we retry several times to see if we get
a correct value.
These failures seem to be excaserbated by the speed of the
access to the chip (possibly time between issuing the address
and then the data cycle).
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -652,7 +652,7 @@ dm9000_probe(struct platform_device *pde
dm9000_reset(db);
/* try two times, DM9000 sometimes gets the first read wrong */
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < 8; i++) {
id_val = ior(db, DM9000_VIDL);
id_val |= (u32)ior(db, DM9000_VIDH) << 8;
id_val |= (u32)ior(db, DM9000_PIDL) << 16;
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (20 preceding siblings ...)
2007-11-19 20:39 ` [patch 21/22] NET: DM9000: Update retry count whilst identifying chip Ben Dooks
@ 2007-11-19 20:39 ` Ben Dooks
2007-11-24 1:43 ` Jeff Garzik
2007-11-19 23:04 ` [patch 00/22] DM9000 updates for 2.6.25 Stephen Hemminger
2007-11-20 17:33 ` Ben Dooks
23 siblings, 1 reply; 41+ messages in thread
From: Ben Dooks @ 2007-11-19 20:39 UTC (permalink / raw)
To: netdev; +Cc: vince, Ben Dooks
[-- Attachment #1: simtec/drivers-net-dm9000-showmacsource.patch --]
[-- Type: text/plain, Size: 1524 bytes --]
Show whether the MAC address was read from the EEPROM or
the onboard PAR registers.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux-2.6.23-quilt5/drivers/net/dm9000.c
===================================================================
--- linux-2.6.23-quilt5.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt5/drivers/net/dm9000.c
@@ -515,6 +515,7 @@ dm9000_probe(struct platform_device *pde
struct dm9000_plat_data *pdata = pdev->dev.platform_data;
struct board_info *db; /* Point a board information structure */
struct net_device *ndev;
+ const unsigned char *mac_src;
unsigned long base;
int ret = 0;
int iosize;
@@ -696,13 +697,16 @@ dm9000_probe(struct platform_device *pde
db->mii.mdio_read = dm9000_phy_read;
db->mii.mdio_write = dm9000_phy_write;
+ mac_src = "eeprom";
+
/* try reading the node address from the attached EEPROM */
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
-
+
+ mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
@@ -719,7 +723,7 @@ dm9000_probe(struct platform_device *pde
ndev->name, db->io_addr, db->io_data, ndev->irq);
for (i = 0; i < 5; i++)
printk("%02x:", ndev->dev_addr[i]);
- printk("%02x\n", ndev->dev_addr[5]);
+ printk("%02x (%s)\n", ndev->dev_addr[5], mac_src);
}
return 0;
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 00/22] DM9000 updates for 2.6.25
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (21 preceding siblings ...)
2007-11-19 20:39 ` [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC Ben Dooks
@ 2007-11-19 23:04 ` Stephen Hemminger
2007-11-20 10:13 ` Ben Dooks
2007-11-20 17:33 ` Ben Dooks
23 siblings, 1 reply; 41+ messages in thread
From: Stephen Hemminger @ 2007-11-19 23:04 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
On Mon, 19 Nov 2007 20:39:10 +0000
Ben Dooks <ben-linux@fluff.org> wrote:
> This is my current proposed patch series to the DM9000
> driver for both general cleanups, support for ethtool
> and to make the code better.
>
You could also change all instances of dev->priv with netdev_priv(dev).
--
Stephen Hemminger <shemminger@linux-foundation.org>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open
2007-11-19 20:39 ` [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open Ben Dooks
@ 2007-11-20 7:46 ` Christoph Hellwig
2007-11-20 10:13 ` Ben Dooks
2007-11-24 1:38 ` Jeff Garzik
1 sibling, 1 reply; 41+ messages in thread
From: Christoph Hellwig @ 2007-11-20 7:46 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
> +static void dm9000_start_thread(struct net_device *dev)
> +{
> + board_info_t *db = (board_info_t *) dev->priv;
> +
> + /* Create a thread to keep track of the state of the phy
> + * as we do not get an interrupt when the PHY state changes.
> + *
> + * Note, we do not abort the open if we fail to create the
> + * thread, as this is mainly to ensure the user is kept up to
> + * date with the device's state. PHY accesses will still work
> + * via the MII read and write methods.
> + */
> +
> + db->thread = kthread_create(dm9000_mii_thread, db, dev->name);
> + if (IS_ERR(db->thread)) {
> + dev_err(db->dev, "failed to create MII thread\n");
> + db->thread = NULL;
> + } else
> + wake_up_process(db->thread);
> +}
> +
> /*
> * Open the interface.
> * The interface is opened whenever "ifconfig" actives it.
> @@ -704,12 +724,7 @@ dm9000_open(struct net_device *dev)
> /* Init driver variable */
> db->dbug_cnt = 0;
>
> - /* set and active a timer process */
> - init_timer(&db->timer);
> - db->timer.expires = DM9000_TIMER_WUT;
> - db->timer.data = (unsigned long) dev;
> - db->timer.function = &dm9000_timer;
> - add_timer(&db->timer);
> + dm9000_start_thread(dev);
Please don't just ignore the error. Just inline the content of
dm9000_start_thread into the caller and use proper goto-based
unwinding.
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open
2007-11-20 7:46 ` Christoph Hellwig
@ 2007-11-20 10:13 ` Ben Dooks
0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-20 10:13 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Ben Dooks, netdev, vince
On Tue, Nov 20, 2007 at 07:46:27AM +0000, Christoph Hellwig wrote:
> > +static void dm9000_start_thread(struct net_device *dev)
> > +{
> > + board_info_t *db = (board_info_t *) dev->priv;
> > +
> > + /* Create a thread to keep track of the state of the phy
> > + * as we do not get an interrupt when the PHY state changes.
> > + *
> > + * Note, we do not abort the open if we fail to create the
> > + * thread, as this is mainly to ensure the user is kept up to
> > + * date with the device's state. PHY accesses will still work
> > + * via the MII read and write methods.
> > + */
> > +
> > + db->thread = kthread_create(dm9000_mii_thread, db, dev->name);
> > + if (IS_ERR(db->thread)) {
> > + dev_err(db->dev, "failed to create MII thread\n");
> > + db->thread = NULL;
> > + } else
> > + wake_up_process(db->thread);
> > +}
> > +
> > /*
> > * Open the interface.
> > * The interface is opened whenever "ifconfig" actives it.
> > @@ -704,12 +724,7 @@ dm9000_open(struct net_device *dev)
> > /* Init driver variable */
> > db->dbug_cnt = 0;
> >
> > - /* set and active a timer process */
> > - init_timer(&db->timer);
> > - db->timer.expires = DM9000_TIMER_WUT;
> > - db->timer.data = (unsigned long) dev;
> > - db->timer.function = &dm9000_timer;
> > - add_timer(&db->timer);
> > + dm9000_start_thread(dev);
>
> Please don't just ignore the error. Just inline the content of
> dm9000_start_thread into the caller and use proper goto-based
> unwinding.
The error is not important, I would be happy with adding an
error print in there, but not having the MII system print
an message if the link status changes is not an driver threatening
error.
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 00/22] DM9000 updates for 2.6.25
2007-11-19 23:04 ` [patch 00/22] DM9000 updates for 2.6.25 Stephen Hemminger
@ 2007-11-20 10:13 ` Ben Dooks
0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-20 10:13 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Ben Dooks, netdev, vince
On Mon, Nov 19, 2007 at 03:04:31PM -0800, Stephen Hemminger wrote:
> On Mon, 19 Nov 2007 20:39:10 +0000
> Ben Dooks <ben-linux@fluff.org> wrote:
>
> > This is my current proposed patch series to the DM9000
> > driver for both general cleanups, support for ethtool
> > and to make the code better.
> >
>
> You could also change all instances of dev->priv with netdev_priv(dev).
Ok, will add that to the patch set.
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 00/22] DM9000 updates for 2.6.25
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
` (22 preceding siblings ...)
2007-11-19 23:04 ` [patch 00/22] DM9000 updates for 2.6.25 Stephen Hemminger
@ 2007-11-20 17:33 ` Ben Dooks
23 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-11-20 17:33 UTC (permalink / raw)
To: netdev
On Mon, Nov 19, 2007 at 08:39:10PM +0000, Ben Dooks wrote:
> This is my current proposed patch series to the DM9000
> driver for both general cleanups, support for ethtool
> and to make the code better.
Apologies, it seems that when I updated it to 2.6.24-rc3
it turns out I applied it without first upgrading the
underlying kernel source to that version. I will post
a new series to the list once i've fixed up all the
changes.
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output.
2007-11-19 20:39 ` [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output Ben Dooks
@ 2007-11-24 1:35 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:35 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
ACK
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 02/22] NET: DM9000 update debugging macros to use debug level
2007-11-19 20:39 ` [patch 02/22] NET: DM9000 update debugging macros to use debug level Ben Dooks
@ 2007-11-24 1:36 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:36 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
you really should consider adding msg_enable support (grep for that in
other net drivers, and for netif_msg in netdevice.h)
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 03/22] NET: DM9000: Pass IRQ flags via platform data
2007-11-19 20:39 ` [patch 03/22] NET: DM9000: Pass IRQ flags via platform data Ben Dooks
@ 2007-11-24 1:36 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:36 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
ACK
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 04/22] NET: DM9000: Add initial ethtool support
2007-11-19 20:39 ` [patch 04/22] NET: DM9000: Add initial ethtool support Ben Dooks
@ 2007-11-24 1:38 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:38 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
if ETHTOOL_GDRVINFO bus info is not PCI, you must add a prefix a la
3c59x.c or eepro.c
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held
2007-11-19 20:39 ` [patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held Ben Dooks
@ 2007-11-24 1:38 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:38 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
ACK
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open
2007-11-19 20:39 ` [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open Ben Dooks
2007-11-20 7:46 ` Christoph Hellwig
@ 2007-11-24 1:38 ` Jeff Garzik
2007-12-07 18:33 ` Ben Dooks
1 sibling, 1 reply; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:38 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
seems like a delayed workqueue would be most appropriate for this.
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 07/22] NET: DM9000: Use msleep() instead of udelay()
2007-11-19 20:39 ` [patch 07/22] NET: DM9000: Use msleep() instead of udelay() Ben Dooks
@ 2007-11-24 1:39 ` Jeff Garzik
2007-12-07 15:42 ` Ben Dooks
0 siblings, 1 reply; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:39 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
are you sure you cannot sleep during suspend?
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment
2007-11-19 20:39 ` [patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment Ben Dooks
@ 2007-11-24 1:41 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:41 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
ACK patches 8-14
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 15/22] NET: DM9000: Use netif_msg to enable debugging options
2007-11-19 20:39 ` [patch 15/22] NET: DM9000: Use netif_msg to enable debugging options Ben Dooks
@ 2007-11-24 1:42 ` Jeff Garzik
0 siblings, 0 replies; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:42 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
ah, you took care of my comment regarding an earlier patch.
consider that comment rescinded
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC
2007-11-19 20:39 ` [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC Ben Dooks
@ 2007-11-24 1:43 ` Jeff Garzik
2007-12-07 18:30 ` Ben Dooks
0 siblings, 1 reply; 41+ messages in thread
From: Jeff Garzik @ 2007-11-24 1:43 UTC (permalink / raw)
To: Ben Dooks; +Cc: netdev, vince
ACK patches 16-22
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 07/22] NET: DM9000: Use msleep() instead of udelay()
2007-11-24 1:39 ` Jeff Garzik
@ 2007-12-07 15:42 ` Ben Dooks
0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-12-07 15:42 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Dooks, netdev, vince
On Fri, Nov 23, 2007 at 08:39:45PM -0500, Jeff Garzik wrote:
> are you sure you cannot sleep during suspend?
Yes. This is not the first driver that has had this problem,
see the sm501 as another example.
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC
2007-11-24 1:43 ` Jeff Garzik
@ 2007-12-07 18:30 ` Ben Dooks
0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-12-07 18:30 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Dooks, netdev, vince
On Fri, Nov 23, 2007 at 08:43:04PM -0500, Jeff Garzik wrote:
> ACK patches 16-22
Is reposting here ok to get these queued for the next kernel
release, or are there people to CC: for this?
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open
2007-11-24 1:38 ` Jeff Garzik
@ 2007-12-07 18:33 ` Ben Dooks
0 siblings, 0 replies; 41+ messages in thread
From: Ben Dooks @ 2007-12-07 18:33 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Dooks, netdev, vince
On Fri, Nov 23, 2007 at 08:38:51PM -0500, Jeff Garzik wrote:
> seems like a delayed workqueue would be most appropriate for this.
I like the fact that the use of kthread shows the user how much
cpu time is being used by the execution of monitoring the phy. How
badly do people object to using a kthread?
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2007-12-07 18:33 UTC | newest]
Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-19 20:39 [patch 00/22] DM9000 updates for 2.6.25 Ben Dooks
2007-11-19 20:39 ` [patch 01/22] NET: DM9000 use dev_xxx() instead of printk for output Ben Dooks
2007-11-24 1:35 ` Jeff Garzik
2007-11-19 20:39 ` [patch 02/22] NET: DM9000 update debugging macros to use debug level Ben Dooks
2007-11-24 1:36 ` Jeff Garzik
2007-11-19 20:39 ` [patch 03/22] NET: DM9000: Pass IRQ flags via platform data Ben Dooks
2007-11-24 1:36 ` Jeff Garzik
2007-11-19 20:39 ` [patch 04/22] NET: DM9000: Add initial ethtool support Ben Dooks
2007-11-24 1:38 ` Jeff Garzik
2007-11-19 20:39 ` [patch 05/22] NET: DM9000: Do not sleep with spinlock and IRQs held Ben Dooks
2007-11-24 1:38 ` Jeff Garzik
2007-11-19 20:39 ` [patch 06/22] NET: DM9000: Use kthread to probe MII status when device open Ben Dooks
2007-11-20 7:46 ` Christoph Hellwig
2007-11-20 10:13 ` Ben Dooks
2007-11-24 1:38 ` Jeff Garzik
2007-12-07 18:33 ` Ben Dooks
2007-11-19 20:39 ` [patch 07/22] NET: DM9000: Use msleep() instead of udelay() Ben Dooks
2007-11-24 1:39 ` Jeff Garzik
2007-12-07 15:42 ` Ben Dooks
2007-11-19 20:39 ` [patch 08/22] NET: DM9000: Remove barely used SROM array read Ben Dooks
2007-11-19 20:39 ` [patch 09/22] NET: DM9000: Add mutex to protect access Ben Dooks
2007-11-19 20:39 ` [patch 10/22] NET: DM9000: Add ethtool support for reading and writing EEPROM Ben Dooks
2007-11-19 20:39 ` [patch 11/22] NET: DM9000: Add ethtool control of msg_enable value Ben Dooks
2007-11-19 20:39 ` [patch 12/22] NET: DM9000: Remove EEPROM initialisation code Ben Dooks
2007-11-19 20:39 ` [patch 13/22] NET: DM9000: Ensure spinlock held whilst accessing EEPROM registers Ben Dooks
2007-11-19 20:39 ` [patch 14/22] NET: DM9000: Remove unnecessary changelog in header comment Ben Dooks
2007-11-24 1:41 ` Jeff Garzik
2007-11-19 20:39 ` [patch 15/22] NET: DM9000: Use netif_msg to enable debugging options Ben Dooks
2007-11-24 1:42 ` Jeff Garzik
2007-11-19 20:39 ` [patch 16/22] NET: DM9000: Fix delays used by EEPROM read and write Ben Dooks
2007-11-19 20:39 ` [patch 17/22] NET: DM9000: Remove cal_CRC() and use ether_crc_le instead Ben Dooks
2007-11-19 20:39 ` [patch 18/22] NET: DM9000: Remove redudant use of "& 0xff" Ben Dooks
2007-11-19 20:39 ` [patch 19/22] NET: DM9000: Add platform flag for no attached EEPROM Ben Dooks
2007-11-19 20:39 ` [patch 20/22] NET: DM9000: Add support for MII ioctl() calls Ben Dooks
2007-11-19 20:39 ` [patch 21/22] NET: DM9000: Update retry count whilst identifying chip Ben Dooks
2007-11-19 20:39 ` [patch 22/22] NET: DM9000: Show the MAC address source after printing MAC Ben Dooks
2007-11-24 1:43 ` Jeff Garzik
2007-12-07 18:30 ` Ben Dooks
2007-11-19 23:04 ` [patch 00/22] DM9000 updates for 2.6.25 Stephen Hemminger
2007-11-20 10:13 ` Ben Dooks
2007-11-20 17:33 ` Ben Dooks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).