* [PATCH] ks8842: Do the TX timeout work in workqueue context.
@ 2010-07-06 15:20 Richard Röjfors
2010-07-09 4:43 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Richard Röjfors @ 2010-07-06 15:20 UTC (permalink / raw)
To: netdev; +Cc: davem
Currently all code that needs to be run at TX timeout is done in the
calling context, where bottom halves are disabled. Some of the code
blocks, so it needs to be done in a different context. This patch
adds in a work struct which is scheduled at TX timeout. Then the
timeout code is executed within work queue context.
Signed-off-by: Richard Röjfors <richard.rojfors@pelagicore.com>
---
diff --git a/drivers/net/ks8842.c b/drivers/net/ks8842.c
index d47bba9..0be9261 100644
--- a/drivers/net/ks8842.c
+++ b/drivers/net/ks8842.c
@@ -119,6 +119,8 @@ struct ks8842_adapter {
int irq;
struct tasklet_struct tasklet;
spinlock_t lock; /* spinlock to be interrupt safe */
+ struct work_struct timeout_work;
+ struct net_device *netdev;
};
static inline void ks8842_select_bank(struct ks8842_adapter *adapter,
u16 bank)
@@ -197,7 +199,6 @@ static void ks8842_reset(struct ks8842_adapter
*adapter)
msleep(10);
iowrite16(0, adapter->hw_addr + REG_GRR);
*/
- iowrite16(32, adapter->hw_addr + REG_SELECT_BANK);
iowrite32(0x1, adapter->hw_addr + REG_TIMB_RST);
msleep(20);
}
@@ -553,6 +554,8 @@ static int ks8842_close(struct net_device *netdev)
netdev_dbg(netdev, "%s - entry\n", __func__);
+ cancel_work_sync(&adapter->timeout_work);
+
/* free the irq */
free_irq(adapter->irq, netdev);
@@ -595,9 +598,11 @@ static int ks8842_set_mac(struct net_device
*netdev, void *p)
return 0;
}
-static void ks8842_tx_timeout(struct net_device *netdev)
+static void ks8842_tx_timeout_work(struct work_struct *work)
{
- struct ks8842_adapter *adapter = netdev_priv(netdev);
+ struct ks8842_adapter *adapter =
+ container_of(work, struct ks8842_adapter, timeout_work);
+ struct net_device *netdev = adapter->netdev;
unsigned long flags;
netdev_dbg(netdev, "%s: entry\n", __func__);
@@ -606,6 +611,9 @@ static void ks8842_tx_timeout(struct net_device
*netdev)
/* disable interrupts */
ks8842_write16(adapter, 18, 0, REG_IER);
ks8842_write16(adapter, 18, 0xFFFF, REG_ISR);
+
+ netif_stop_queue(netdev);
+
spin_unlock_irqrestore(&adapter->lock, flags);
ks8842_reset_hw(adapter);
@@ -615,6 +623,15 @@ static void ks8842_tx_timeout(struct net_device
*netdev)
ks8842_update_link_status(netdev, adapter);
}
+static void ks8842_tx_timeout(struct net_device *netdev)
+{
+ struct ks8842_adapter *adapter = netdev_priv(netdev);
+
+ netdev_dbg(netdev, "%s: entry\n", __func__);
+
+ schedule_work(&adapter->timeout_work);
+}
+
static const struct net_device_ops ks8842_netdev_ops = {
.ndo_open = ks8842_open,
.ndo_stop = ks8842_close,
@@ -649,6 +666,8 @@ static int __devinit ks8842_probe(struct
platform_device *pdev)
SET_NETDEV_DEV(netdev, &pdev->dev);
adapter = netdev_priv(netdev);
+ adapter->netdev = netdev;
+ INIT_WORK(&adapter->timeout_work, ks8842_tx_timeout_work);
adapter->hw_addr = ioremap(iomem->start, resource_size(iomem));
if (!adapter->hw_addr)
goto err_ioremap;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ks8842: Do the TX timeout work in workqueue context.
2010-07-06 15:20 [PATCH] ks8842: Do the TX timeout work in workqueue context Richard Röjfors
@ 2010-07-09 4:43 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-07-09 4:43 UTC (permalink / raw)
To: richard.rojfors; +Cc: netdev
From: Richard Röjfors <richard.rojfors@pelagicore.com>
Date: Tue, 06 Jul 2010 17:20:25 +0200
> Currently all code that needs to be run at TX timeout is done in the
> calling context, where bottom halves are disabled. Some of the code
> blocks, so it needs to be done in a different context. This patch
> adds in a work struct which is scheduled at TX timeout. Then the
> timeout code is executed within work queue context.
>
> Signed-off-by: Richard Röjfors <richard.rojfors@pelagicore.com>
Your patch is corrupted by your email client, and it does more than
you say it does in this commit message:
> static inline void ks8842_select_bank(struct ks8842_adapter *adapter,
> u16 bank)
> @@ -197,7 +199,6 @@ static void ks8842_reset(struct ks8842_adapter
> *adapter)
Your email client is wrapping long lines in the patch, corrupting it
and making it unusable. Please fix your email client to not molest
the patch in any way.
> msleep(10);
> iowrite16(0, adapter->hw_addr + REG_GRR);
> */
> - iowrite16(32, adapter->hw_addr + REG_SELECT_BANK);
> iowrite32(0x1, adapter->hw_addr + REG_TIMB_RST);
> msleep(20);
> }
Your commit message fails to describe what this REG_SELECT_BANK write
removal is needed for. It must be accounted for in your log message
otherwise other developers won't understand why this line gets
removed in your change.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-09 4:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-06 15:20 [PATCH] ks8842: Do the TX timeout work in workqueue context Richard Röjfors
2010-07-09 4:43 ` David Miller
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).