From: Kieran Mansley Subject: Re: [PATCH] Skip vcpu_hotplug for VCPU 0 in smp_resume Date: Tue, 07 Apr 2009 10:26:58 +0100 Message-ID: <1239096418.4273.13.camel@moonstone.uk.level5networks.com> References: <1238663621.4271.13.camel@moonstone.uk.level5networks.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-2L33LZxxTSzPFYXBW3Z+" Return-path: In-Reply-To: <1238663621.4271.13.camel@moonstone.uk.level5networks.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: "andy@cs.ubc.ca" , Brendan Cully , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-2L33LZxxTSzPFYXBW3Z+ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2009-04-02 at 10:13 +0100, Kieran Mansley wrote: > OK, I'll try and produce a patch based on the assumptions that (i) > watches won't fire between suspend and either resume or suspend-cancel; > (ii) any that would have fired are triggered after a suspend-cancel; and > (iii) the watch must be refreshed on a resume (with no guarantees about > lost watches). OK, here's the patch. Signed-off-by: Kieran Mansley Keir: I'll leave it up to you as to whether this is a bug fix (and so should be included in 3.4) or just queued for unstable after 3.4 is released. Either is fine with us. Thanks Kieran --=-2L33LZxxTSzPFYXBW3Z+ Content-Disposition: attachment; filename=suspend_watch Content-Type: text/plain; name=suspend_watch; charset=utf-8 Content-Transfer-Encoding: 7bit Avoid removing watch across suspend/suspend_cancel cycle diff -r b358ebf1c416 drivers/xen/netfront/accel.c --- a/drivers/xen/netfront/accel.c +++ b/drivers/xen/netfront/accel.c @@ -50,6 +50,8 @@ static int netfront_load_accelerator(str static int netfront_load_accelerator(struct netfront_info *np, struct xenbus_device *dev, const char *frontend); + +static void netfront_accelerator_remove_watch(struct netfront_info *np); /* * List of all netfront accelerator plugin modules available. Each @@ -164,8 +166,11 @@ void netfront_accelerator_add_watch(stru { int err; - /* Check we're not trying to overwrite an existing watch */ - BUG_ON(np->accel_vif_state.accel_watch.node != NULL); + /* + * If old watch exists, e.g. from before suspend/resume, + * remove it now + */ + netfront_accelerator_remove_watch(np); /* Get a watch on the accelerator plugin */ err = xenbus_watch_path2(np->xbdev, np->xbdev->otherend, @@ -180,6 +185,19 @@ void netfront_accelerator_add_watch(stru } +static void +netfront_accelerator_purge_watch(struct netfront_accel_vif_state *vif_state) +{ + flush_workqueue(accel_watch_workqueue); + + /* Clean up any state left from watch */ + if (vif_state->accel_frontend != NULL) { + kfree(vif_state->accel_frontend); + vif_state->accel_frontend = NULL; + } +} + + static void netfront_accelerator_remove_watch(struct netfront_info *np) { @@ -191,13 +209,7 @@ void netfront_accelerator_remove_watch(s kfree(vif_state->accel_watch.node); vif_state->accel_watch.node = NULL; - flush_workqueue(accel_watch_workqueue); - - /* Clean up any state left from watch */ - if (vif_state->accel_frontend != NULL) { - kfree(vif_state->accel_frontend); - vif_state->accel_frontend = NULL; - } + netfront_accelerator_purge_watch(vif_state); } } @@ -670,8 +682,6 @@ int netfront_accelerator_suspend(struct { int rc = 0; - netfront_accelerator_remove_watch(np); - mutex_lock(&accelerator_mutex); /* Check that we've got a device that was accelerated */ @@ -692,13 +702,16 @@ int netfront_accelerator_suspend_cancel( int netfront_accelerator_suspend_cancel(struct netfront_info *np, struct xenbus_device *dev) { + netfront_accelerator_purge_watch(&np->accel_vif_state); + /* - * Setting the watch will cause it to fire and probe the - * accelerator, so no need to call accelerator_probe_new_vif() - * directly here + * Gratuitously fire the watch handler to reinstate the + * configured accelerator */ if (dev->state == XenbusStateConnected) - netfront_accelerator_add_watch(np); + queue_work(accel_watch_workqueue, + &np->accel_vif_state.accel_work); + return 0; } --=-2L33LZxxTSzPFYXBW3Z+ 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 --=-2L33LZxxTSzPFYXBW3Z+--