From: Kieran Mansley Subject: [PATCH] Netfront accelerator bug fix Date: Fri, 23 Nov 2007 14:15:43 +0000 Message-ID: <1195827343.4110.19.camel@moonstone.uk.level5networks.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-T4+MnvjXhb3fgddzQ865" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-T4+MnvjXhb3fgddzQ865 Content-Type: text/plain Content-Transfer-Encoding: 7bit In testing Xen for the upcoming 3.2.0 release, we've found a bug in the netfront accelerator support where if an accelerator was removed before it had properly initialised it wasn't handled correctly. Attached is a patch to fix it. Signed-off-by: Kieran Mansley Also, we're currently testing the xen-unstable tree, but I presume there will be a xen-3.2-testing tree in due course that we should take a look at. Thanks Kieran Ensure remove works properly if plugin hasn't called netfront_accelerator_ready diff -r fced90d566f1 drivers/xen/netfront/accel.c --- a/drivers/xen/netfront/accel.c Sat Nov 10 10:18:28 2007 +0000 +++ b/drivers/xen/netfront/accel.c Thu Nov 22 10:14:11 2007 +0000 @@ -465,15 +465,18 @@ static void accelerator_remove_hooks(str link) { spin_lock_irqsave(&accelerator->vif_states_lock, flags); - BUG_ON(vif_state->hooks == NULL); - hooks = vif_state->hooks; - accelerator_remove_single_hook(accelerator, vif_state); + if(vif_state->hooks) { + hooks = vif_state->hooks; + accelerator_remove_single_hook(accelerator, vif_state); + + /* Last chance to get statistics from the accelerator */ + hooks->get_stats(vif_state->np->netdev, + &vif_state->np->stats); + } spin_unlock_irqrestore(&accelerator->vif_states_lock, flags); - /* Last chance to get statistics from the accelerator */ - hooks->get_stats(vif_state->np->netdev, &vif_state->np->stats); - hooks->remove(vif_state->dev); + accelerator->hooks->remove(vif_state->dev); } accelerator->hooks = NULL; @@ -530,15 +533,16 @@ static int do_remove(struct netfront_inf /* Last chance to get statistics from the accelerator */ hooks->get_stats(np->netdev, &np->stats); - + } + + if (accelerator->hooks) { spin_unlock_irqrestore(&accelerator->vif_states_lock, *lock_flags); - rc = hooks->remove(dev); + rc = accelerator->hooks->remove(dev); spin_lock_irqsave(&accelerator->vif_states_lock, *lock_flags); } - return rc; } --=-T4+MnvjXhb3fgddzQ865 Content-Disposition: attachment; filename=netfront_accel_remove Content-Type: text/plain; name=netfront_accel_remove; charset=UTF-8 Content-Transfer-Encoding: 7bit Ensure remove works properly if plugin hasn't called netfront_accelerator_ready diff -r fced90d566f1 drivers/xen/netfront/accel.c --- a/drivers/xen/netfront/accel.c Sat Nov 10 10:18:28 2007 +0000 +++ b/drivers/xen/netfront/accel.c Thu Nov 22 10:14:11 2007 +0000 @@ -465,15 +465,18 @@ static void accelerator_remove_hooks(str link) { spin_lock_irqsave(&accelerator->vif_states_lock, flags); - BUG_ON(vif_state->hooks == NULL); - hooks = vif_state->hooks; - accelerator_remove_single_hook(accelerator, vif_state); + if(vif_state->hooks) { + hooks = vif_state->hooks; + accelerator_remove_single_hook(accelerator, vif_state); + + /* Last chance to get statistics from the accelerator */ + hooks->get_stats(vif_state->np->netdev, + &vif_state->np->stats); + } spin_unlock_irqrestore(&accelerator->vif_states_lock, flags); - /* Last chance to get statistics from the accelerator */ - hooks->get_stats(vif_state->np->netdev, &vif_state->np->stats); - hooks->remove(vif_state->dev); + accelerator->hooks->remove(vif_state->dev); } accelerator->hooks = NULL; @@ -530,15 +533,16 @@ static int do_remove(struct netfront_inf /* Last chance to get statistics from the accelerator */ hooks->get_stats(np->netdev, &np->stats); - + } + + if (accelerator->hooks) { spin_unlock_irqrestore(&accelerator->vif_states_lock, *lock_flags); - rc = hooks->remove(dev); + rc = accelerator->hooks->remove(dev); spin_lock_irqsave(&accelerator->vif_states_lock, *lock_flags); } - return rc; } --=-T4+MnvjXhb3fgddzQ865 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-T4+MnvjXhb3fgddzQ865--