mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] hvc_xen: implement multiconsole support
Date: Mon, 30 Jan 2012 15:33:48 +0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1201301510240.3196@kaball-desktop> (raw)
In-Reply-To: <20120127184538.GA18321@phenom.dumpdata.com>

On Fri, 27 Jan 2012, Konrad Rzeszutek Wilk wrote:
> > +static void xencons_disconnect_backend(struct xencons_info *info)
> > +{
> > +	if (info->irq > 0)
> > +		unbind_from_irqhandler(info->irq, NULL);
> > +	info->irq = 0;
> > +	if (info->evtchn > 0)
> > +		xenbus_free_evtchn(info->xbdev, info->evtchn);
> > +	info->evtchn = 0;
> > +	if (info->gntref > 0)
> > +		gnttab_free_grant_references(info->gntref);
> > +	info->gntref = 0;
> > +	if (info->hvc != NULL)
> > +		hvc_remove(info->hvc);
> > +	info->hvc = NULL;
> > +}
> > +
> > +static void xencons_free(struct xencons_info *info)
> > +{
> > +	xencons_disconnect_backend(info);
> > +	free_page((unsigned long)info->intf);
> > +	info->intf = NULL;
> > +	info->vtermno = 0;
> > +	kfree(info);
> > +}
> > +
> > +static int xencons_remove(struct xenbus_device *dev)
> > +{
> > +	struct xencons_info *info = dev_get_drvdata(&dev->dev);
> > +
> 
> I would say put
> 	xencons_disconnect_backend(info)
> 
> here, that way it calls hvc_remove first, and then this would
> delete an "not-called" anymore structure.
> 
> > +	spin_lock(&xencons_lock);
> > +	list_del(&info->list);
> > +	spin_unlock(&xencons_lock);
> > +	xencons_free(info);
> 
> >  	return 0;
> >  }
> >
> 
> .. snip..
> > +
> > +static const struct xenbus_device_id xencons_ids[] = {
> > +	{ "console" },
> > +	{ "" }
> > +};
> > +
> > +
> >  static void __exit xen_hvc_fini(void)
> >  {
> > -	if (hvc)
> > -		hvc_remove(hvc);
> > +	struct xencons_info *entry, *next;
> > +
> > +	if (list_empty(&xenconsoles))
> > +			return;
> > +
> > +	spin_lock(&xencons_lock);
> 
> Take that spin-lock out.
> 
> > +	list_for_each_entry_safe(entry, next, &xenconsoles, list) {
> > +		list_del(&entry->list);
> > +		if (entry->xbdev)
> > +			xencons_remove(entry->xbdev);
> 
> This guy deletes itself from the list..
> > +		else {
> > +			if (entry->irq > 0)
> > +				unbind_from_irqhandler(entry->irq, NULL);
> > +			if (entry->hvc);
> > +				hvc_remove(entry->hvc);
> > +			kfree(entry);
> 
> ..but this one does not.  You could make xencons_remove just remove
> itself from the list and nothing else. Then rename it to 'xencons_remove_itself' perhaps?
> 
> After that, introduce a new function 'xencons_delete' that would call
> xecons_disconnect_backend, xencons_remove_itself, and xencons_free?

Thanks for spotting the deadlock and the useful suggestions.
I have reworked the shutdown path a bit, making sure that we don't take
any locks twice and that we call hvc_remove before list_del (see next
version of the patch, to be posted soon).



> >  
> > +static struct xenbus_driver xencons_driver = {
> 
> This needs to be wrapped in the new macro that Jan prepared.
> DEFINE_XENBUS_DRIVER (73db144b58a32fc39733db6a7e1fe582072ad26a)

OK

      reply	other threads:[~2012-01-30 15:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27 18:30 [PATCH v2 0/2] Xen (PV and HVM) multiple PV consoles Stefano Stabellini
2012-01-27 18:31 ` [PATCH v2 1/2] hvc_xen: support PV on HVM consoles Stefano Stabellini
2012-01-27 18:45   ` Konrad Rzeszutek Wilk
2012-01-27 18:31 ` [PATCH v2 2/2] hvc_xen: implement multiconsole support Stefano Stabellini
2012-01-27 18:45   ` Konrad Rzeszutek Wilk
2012-01-30 15:33     ` Stefano Stabellini [this message]

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=alpine.DEB.2.00.1201301510240.3196@kaball-desktop \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®