xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Jan Beulich <JBeulich@novell.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] xen/pci: make bus notifier handler return sane values
Date: Wed, 17 Aug 2011 11:31:30 -0400	[thread overview]
Message-ID: <20110817153130.GA10185@dumpdata.com> (raw)
In-Reply-To: <4E4BF7EB0200007800051B77@nat28.tlf.novell.com>

On Wed, Aug 17, 2011 at 04:18:35PM +0100, Jan Beulich wrote:
> >>> On 17.08.11 at 16:57, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> wrote:
> > On Wed, Aug 17, 2011 at 09:32:32AM +0100, Jan Beulich wrote:
> >> Notifier functions are expected to return NOTIFY_* codes, not -E...
> >> ones. In particular, since the respective hypercalls failing is not
> >> fatal to the operation of the Dom0 kernel, it must be avoided to
> > 
> > So if we fail adding a PCI device, won't we be unable to actually
> > setup its MSI?
> 
> Sure (and you also can't pass through such a device), but that's no
> reason to fail the notification chain. For one, you don't know whether
> the driver is actually going to use MSI. And even if you knew, it would
> be bad behavior imo. Plus even if you want to fail the notifier chain,
> just returning a -E... value here is wrong; notifier_from_errno() ought
> to be used then.

Oh, I am not disputing that. I am just wondering whether we should add
some extra printk's if we fail, and still reutrn either NOTIFY_OK
oir NOTIFY_DONE.

That way at least in the field we will have a good inkling of what
went wrong.
> 
> Jan
> 
> >> return negative values here as those would make it appear as if
> >> NOTIFY_STOP_MASK wa set, suppressing further notification calls to
> >> other interested parties (which is also why we don't want to use
> >> notifier_from_errno() here).
> >> 
> >> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> >> 
> >> ---
> >>  drivers/xen/pci.c |   11 +++++------
> >>  1 file changed, 5 insertions(+), 6 deletions(-)
> >> 
> >> --- 3.1-rc2/drivers/xen/pci.c
> >> +++ 3.1-rc2-xen-pci-bus-notifier/drivers/xen/pci.c
> >> @@ -86,23 +86,22 @@ static int xen_pci_notifier(struct notif
> >>  			    unsigned long action, void *data)
> >>  {
> >>  	struct device *dev = data;
> >> -	int r = 0;
> >>  
> >>  	switch (action) {
> >>  	case BUS_NOTIFY_ADD_DEVICE:
> >> -		r = xen_add_device(dev);
> >> +		xen_add_device(dev);
> >>  		break;
> >>  	case BUS_NOTIFY_DEL_DEVICE:
> >> -		r = xen_remove_device(dev);
> >> +		xen_remove_device(dev);
> >>  		break;
> >>  	default:
> >> -		break;
> >> +		return NOTIFY_DONE;
> >>  	}
> >>  
> >> -	return r;
> >> +	return NOTIFY_OK;
> >>  }
> >>  
> >> -struct notifier_block device_nb = {
> >> +static struct notifier_block device_nb = {
> >>  	.notifier_call = xen_pci_notifier,
> >>  };
> >>  
> >> 
> >> 
> >> 
> > 
> >> Notifier functions are expected to return NOTIFY_* codes, not -E...
> >> ones. In particular, since the respective hypercalls failing is not
> >> fatal to the operation of the Dom0 kernel, it must be avoided to
> >> return negative values here as those would make it appear as if
> >> NOTIFY_STOP_MASK wa set, suppressing further notification calls to
> >> other interested parties (which is also why we don't want to use
> >> notifier_from_errno() here).
> >> 
> >> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> >> 
> >> ---
> >>  drivers/xen/pci.c |   11 +++++------
> >>  1 file changed, 5 insertions(+), 6 deletions(-)
> >> 
> >> --- 3.1-rc2/drivers/xen/pci.c
> >> +++ 3.1-rc2-xen-pci-bus-notifier/drivers/xen/pci.c
> >> @@ -86,23 +86,22 @@ static int xen_pci_notifier(struct notif
> >>  			    unsigned long action, void *data)
> >>  {
> >>  	struct device *dev = data;
> >> -	int r = 0;
> >>  
> >>  	switch (action) {
> >>  	case BUS_NOTIFY_ADD_DEVICE:
> >> -		r = xen_add_device(dev);
> >> +		xen_add_device(dev);
> >>  		break;
> >>  	case BUS_NOTIFY_DEL_DEVICE:
> >> -		r = xen_remove_device(dev);
> >> +		xen_remove_device(dev);
> >>  		break;
> >>  	default:
> >> -		break;
> >> +		return NOTIFY_DONE;
> >>  	}
> >>  
> >> -	return r;
> >> +	return NOTIFY_OK;
> >>  }
> >>  
> >> -struct notifier_block device_nb = {
> >> +static struct notifier_block device_nb = {
> >>  	.notifier_call = xen_pci_notifier,
> >>  };
> >>  
> > 
> >> _______________________________________________
> >> Xen-devel mailing list
> >> Xen-devel@lists.xensource.com 
> >> http://lists.xensource.com/xen-devel 
> 
> 

  reply	other threads:[~2011-08-17 15:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-17  8:32 [PATCH] xen/pci: make bus notifier handler return sane values Jan Beulich
2011-08-17 14:57 ` Konrad Rzeszutek Wilk
2011-08-17 15:18   ` Jan Beulich
2011-08-17 15:31     ` Konrad Rzeszutek Wilk [this message]
2011-08-17 15:37       ` Jan Beulich
2011-08-22 16:20 ` Konrad Rzeszutek Wilk
2011-08-23  8:19   ` Jan Beulich
2011-08-24 20:42     ` Konrad Rzeszutek Wilk
2011-08-25  9:14       ` George Dunlap
2011-08-25 10:07         ` Jan Beulich
2011-08-25 10:15           ` George Dunlap

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=20110817153130.GA10185@dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=JBeulich@novell.com \
    --cc=jeremy@goop.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;
as well as URLs for NNTP newsgroup(s).