All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Chartier <aurelien.chartier@citrix.com>
To: Aurelien Chartier <aurelien.chartier@citrix.com>
Cc: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	"JBeulich@suse.com" <JBeulich@suse.com>,
	"konrad.wilk@oracle.com" <konrad.wilk@oracle.com>
Subject: Re: [PATCH V2 2/2] xenbus: defer xenbus frontend resume if xenstored is not running
Date: Wed, 8 May 2013 15:40:19 +0100	[thread overview]
Message-ID: <518A63D3.5080002@citrix.com> (raw)
In-Reply-To: <1368023557-21538-3-git-send-email-aurelien.chartier@citrix.com>

On 08/05/13 15:32, Aurelien Chartier wrote:
> If the xenbus frontend is running in a domain running xenstored, the device
> resume is hanging because it is happening before the process resume. This
> patch adds extra logic to the resume code to check if we are the domain
> running xenstored and delay the resume if needed.
>
> Signed-off-by: Aurelien Chartier <aurelien.chartier@citrix.com>
>
> Changes in v2:
> - Instead of bypassing the resume, process it in a workqueue
> ---
>  drivers/xen/xenbus/xenbus_probe.h          |    5 ++++
>  drivers/xen/xenbus/xenbus_probe_frontend.c |   34 +++++++++++++++++++++++++++-
>  2 files changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/xen/xenbus/xenbus_probe.h b/drivers/xen/xenbus/xenbus_probe.h
> index 146f857..46b384c 100644
> --- a/drivers/xen/xenbus/xenbus_probe.h
> +++ b/drivers/xen/xenbus/xenbus_probe.h
> @@ -47,6 +47,11 @@ struct xen_bus_type {
>  	struct bus_type bus;
>  };
>  
> +struct xenbus_resume_work {
> +	struct work_struct w;
> +	struct device *dev;
> +};
> +
>  enum xenstore_init {
>  	XS_UNKNOWN,
>  	XS_PV,
> diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
> index 3159a37..83b83d0 100644
> --- a/drivers/xen/xenbus/xenbus_probe_frontend.c
> +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
> @@ -28,6 +28,7 @@
>  #include "xenbus_comms.h"
>  #include "xenbus_probe.h"
>  
> +static struct workqueue_struct *xenbus_frontend_resume_wq;
>  
>  /* device/<type>/<id> => <type>-<id> */
>  static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
> @@ -89,9 +90,38 @@ static void backend_changed(struct xenbus_watch *watch,
>  	xenbus_otherend_changed(watch, vec, len, 1);
>  }
>  
> +static void xenbus_frontend_delayed_resume(struct work_struct *w)
> +{
> +	struct xenbus_resume_work *resume_work = (struct xenbus_resume_work *) w;
> +
> +	xenbus_dev_resume(dev);
> +
> +	kfree(w);
> +}
> +
> +static int xenbus_frontend_dev_resume(struct device *dev)
> +{
> +	/* 
> +	 * If xenstored is running in that domain, we cannot access the backend
> +	 * state at the moment, so we need to defer xenbus_dev_resume
> +	 */
> +	if (xen_store_domain == XS_LOCAL) {
> +		struct xenbus_resume_work *work =
> +			kmalloc(sizeof(struct xenbus_resume), GFP_KERNEL);
> +
> +		INIT_WORK((struct work_struct *) work, xenbus_frontend_delayed_resume);
> +		resume_work->dev = dev;
> +		queue_work(xenbus_frontend_resume_wq, (struct work_struct *) work)
Missing a semicolon here.

I should have read that patch once more, apologies for that.

> +
> +		return 0;
> +	}
> +
> +	return xenbus_dev_resume(dev);
> +}
> +
>  static const struct dev_pm_ops xenbus_pm_ops = {
>  	.suspend	= xenbus_dev_suspend,
> -	.resume		= xenbus_dev_resume,
> +	.resume		= xenbus_frontend_dev_resume,
>  	.freeze		= xenbus_dev_suspend,
>  	.thaw		= xenbus_dev_cancel,
>  	.restore	= xenbus_dev_resume,
> @@ -440,6 +470,8 @@ static int __init xenbus_probe_frontend_init(void)
>  
>  	register_xenstore_notifier(&xenstore_notifier);
>  
> +	xenbus_frontend_resume_wq = create_workqueue("xenbus_frontend_resume");
> +
>  	return 0;
>  }
>  subsys_initcall(xenbus_probe_frontend_init);

  reply	other threads:[~2013-05-08 14:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-08 14:32 [PATCH V2 0/2] xenbus: Fix S3 frontend resume when xenstored is not running Aurelien Chartier
2013-05-08 14:32 ` [PATCH V2 1/2] xenbus: save xenstore local status for later use Aurelien Chartier
2013-05-08 14:32 ` [PATCH V2 2/2] xenbus: defer xenbus frontend resume if xenstored is not running Aurelien Chartier
2013-05-08 14:40   ` Aurelien Chartier [this message]
2013-05-08 14:50   ` Jan Beulich
2013-05-08 16:23     ` Aurelien Chartier

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=518A63D3.5080002@citrix.com \
    --to=aurelien.chartier@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.