From 62768e28d606c10ba54217f908123de34dad9374 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 12 Nov 2007 18:09:25 -0800 Subject: [SUNGEM]: Fix suspend regression due to NAPI changes. Commit bea3348e (the NAPI changes) made sungem unconditionally enable NAPI when resuming and unconditionally disable when suspending, this, however, makes napi_disable() hang when suspending when the interface was taken down before suspend because taking the interface down also disables NAPI. This patch makes touching the napi struct in suspend/resume code paths depend on having the interface up, thereby fixing the hang on suspend. The patch also moves the napi_disable() in gem_close() under the lock so that the NAPI state is always modified atomically together with the "opened" variable. Signed-off-by: Johannes Berg Acked-by: Benjamin Herrenschmidt Signed-off-by: David S. Miller --- drivers/net/sungem.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/net/sungem.c') diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 53b8344a68e..f6fedcc32de 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -2333,10 +2333,10 @@ static int gem_close(struct net_device *dev) { struct gem *gp = dev->priv; - napi_disable(&gp->napi); - mutex_lock(&gp->pm_mutex); + napi_disable(&gp->napi); + gp->opened = 0; if (!gp->asleep) gem_do_stop(dev, 0); @@ -2355,8 +2355,6 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state) mutex_lock(&gp->pm_mutex); - napi_disable(&gp->napi); - printk(KERN_INFO "%s: suspending, WakeOnLan %s\n", dev->name, (gp->wake_on_lan && gp->opened) ? "enabled" : "disabled"); @@ -2370,6 +2368,8 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state) /* If the driver is opened, we stop the MAC */ if (gp->opened) { + napi_disable(&gp->napi); + /* Stop traffic, mark us closed */ netif_device_detach(dev); @@ -2460,6 +2460,7 @@ static int gem_resume(struct pci_dev *pdev) /* Re-attach net device */ netif_device_attach(dev); + napi_enable(&gp->napi); } spin_lock_irqsave(&gp->lock, flags); @@ -2479,8 +2480,6 @@ static int gem_resume(struct pci_dev *pdev) spin_unlock(&gp->tx_lock); spin_unlock_irqrestore(&gp->lock, flags); - napi_enable(&gp->napi); - mutex_unlock(&gp->pm_mutex); return 0; -- cgit v1.2.3 From dde655c9df02ee07ed090dfdb7ae8741bf299e14 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 29 Nov 2007 21:51:36 +1100 Subject: [SUNGEM]: Fix NAPI regression with reset work sungem's gem_reset_task() will unconditionally try to disable NAPI even when it's called while the interface is not operating and hence the NAPI struct isn't enabled. Make napi_disable() depend on gp->running. Also removes a superfluous test of gp->running in the same function. Signed-off-by: Johannes Berg Signed-off-by: Herbert Xu --- drivers/net/sungem.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/net/sungem.c') diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index f6fedcc32de..68872142530 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -2281,14 +2281,12 @@ static void gem_reset_task(struct work_struct *work) mutex_lock(&gp->pm_mutex); - napi_disable(&gp->napi); + if (gp->opened) + napi_disable(&gp->napi); spin_lock_irq(&gp->lock); spin_lock(&gp->tx_lock); - if (gp->running == 0) - goto not_running; - if (gp->running) { netif_stop_queue(gp->dev); @@ -2298,13 +2296,14 @@ static void gem_reset_task(struct work_struct *work) gem_set_link_modes(gp); netif_wake_queue(gp->dev); } - not_running: + gp->reset_task_pending = 0; spin_unlock(&gp->tx_lock); spin_unlock_irq(&gp->lock); - napi_enable(&gp->napi); + if (gp->opened) + napi_enable(&gp->napi); mutex_unlock(&gp->pm_mutex); } -- cgit v1.2.3 From 439104b3a39b2f576daa229d783eb2cefac8b7df Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 17 Dec 2007 06:48:04 +0000 Subject: =?UTF-8?q?sungem=20endianness=20annotations=1B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- drivers/net/sungem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/net/sungem.c') diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 68872142530..467d80dc3b3 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -758,6 +758,7 @@ static int gem_rx(struct gem *gp, int work_to_do) { int entry, drops, work_done = 0; u32 done; + __sum16 csum; if (netif_msg_rx_status(gp)) printk(KERN_DEBUG "%s: rx interrupt, done: %d, rx_new: %d\n", @@ -769,7 +770,7 @@ static int gem_rx(struct gem *gp, int work_to_do) for (;;) { struct gem_rxd *rxd = &gp->init_block->rxd[entry]; struct sk_buff *skb; - u64 status = cpu_to_le64(rxd->status_word); + u64 status = le64_to_cpu(rxd->status_word); dma_addr_t dma_addr; int len; @@ -811,7 +812,7 @@ static int gem_rx(struct gem *gp, int work_to_do) goto next; } - dma_addr = cpu_to_le64(rxd->buffer); + dma_addr = le64_to_cpu(rxd->buffer); if (len > RX_COPY_THRESHOLD) { struct sk_buff *new_skb; @@ -853,7 +854,8 @@ static int gem_rx(struct gem *gp, int work_to_do) skb = copy_skb; } - skb->csum = ntohs((status & RXDCTRL_TCPCSUM) ^ 0xffff); + csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 0xffff); + skb->csum = csum_unfold(csum); skb->ip_summed = CHECKSUM_COMPLETE; skb->protocol = eth_type_trans(skb, gp->dev); -- cgit v1.2.3 From 79ea13ce07c951bb4d95471e7300baa0f1be9e78 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Jan 2008 02:06:46 -0800 Subject: NULL noise in drivers/net Signed-off-by: Al Viro Signed-off-by: Jeff Garzik Signed-off-by: David S. Miller --- drivers/net/sungem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/sungem.c') diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 467d80dc3b3..97212799c51 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -3056,7 +3056,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev, netif_carrier_off(dev); gp->regs = ioremap(gemreg_base, gemreg_len); - if (gp->regs == 0UL) { + if (!gp->regs) { printk(KERN_ERR PFX "Cannot map device registers, " "aborting.\n"); err = -EIO; -- cgit v1.2.3