netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Francois Romieu <romieu@fr.zoreil.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] 8139too: fix improper usage of workqueue
Date: Wed, 27 Aug 2008 13:16:49 -0700	[thread overview]
Message-ID: <20080827131649.409acf91@extreme> (raw)
In-Reply-To: <20080827192656.GA27499@electric-eye.fr.zoreil.com>


> The driver uses flush_scheduled_work() when the pci device is removed.
> 
> Where would the workqueue be scheduled after / during the removal ?

The timer can fire after removal causing workqueue to be scheduled.
flush_scheduled_work only impacts work already scheduled not delayed.

How about this (simpler) version.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/8139too.c	2008-08-27 08:30:11.000000000 -0700
+++ b/drivers/net/8139too.c	2008-08-27 13:15:06.000000000 -0700
@@ -592,9 +592,9 @@ struct rtl8139_private {
 				/* Twister tune state. */
 	char			twistie, twist_row, twist_col;
 
-	unsigned int		watchdog_fired : 1;
-	unsigned int		default_port : 4; /* Last dev->if_port value. */
-	unsigned int		have_thread : 1;
+	bool			watchdog_fired;
+	bool			have_thread;
+	u8			default_port; /* Last dev->if_port value. */
 
 	spinlock_t		lock;
 	spinlock_t		rx_lock;
@@ -1692,10 +1692,9 @@ static void rtl8139_tx_timeout (struct n
 	struct rtl8139_private *tp = netdev_priv(dev);
 
 	tp->watchdog_fired = 1;
-	if (!tp->have_thread) {
-		INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
+
+	if (!tp->have_thread)
 		schedule_delayed_work(&tp->thread, next_tick);
-	}
 }
 
 static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
@@ -2217,6 +2216,8 @@ static int rtl8139_close (struct net_dev
 	void __iomem *ioaddr = tp->mmio_addr;
 	unsigned long flags;
 
+	cancel_delayed_work(&tp->thread);
+
 	netif_stop_queue(dev);
 	napi_disable(&tp->napi);
 


  reply	other threads:[~2008-08-27 20:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 15:51 [PATCH] 8139too: fix improper usage of workqueue Stephen Hemminger
2008-08-27 19:26 ` Francois Romieu
2008-08-27 20:16   ` Stephen Hemminger [this message]
2008-08-28 20:48     ` Francois Romieu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080827131649.409acf91@extreme \
    --to=shemminger@vyatta.com \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).