Skip to contentSkip to conversation

Netfront accelerator bug fix

PATCH New Kieran Mansley 1 participant 1 message Nov 23, 2007 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Netfront accelerator bug fix

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.

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

drivers/xen/netfront/accel.c +13 -9
diff -r fced90d566f1 drivers/xen/netfront/accel.c
@@ -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;
 }

Ensure remove works properly if plugin hasn't called netfront_accelerator_ready

drivers/xen/netfront/accel.c +13 -9
diff -r fced90d566f1 drivers/xen/netfront/accel.c
@@ -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;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel