virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: KY Srinivasan <kys@microsoft.com>
Cc: "gregkh@suse.de" <gregkh@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"virtualization@lists.osdl.org" <virtualization@lists.osdl.org>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	"Abhishek Kane (Mindtree Consulting PVT LTD)"
	<v-abkane@microsoft.com>
Subject: Re: [PATCH 12/25] Staging: hv: Cleanup error handling in vmbus_child_device_register()
Date: Wed, 27 Apr 2011 17:25:52 -0700	[thread overview]
Message-ID: <20110428002552.GD14294@kroah.com> (raw)
In-Reply-To: <6E21E5352C11B742B20C142EB499E0481DD1AF@TK5EX14MBXC124.redmond.corp.microsoft.com>

On Wed, Apr 27, 2011 at 02:11:48AM +0000, KY Srinivasan wrote:
> 
> 
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com]
> > Sent: Tuesday, April 26, 2011 6:51 PM
> > To: KY Srinivasan
> > Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> > devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang;
> > Abhishek Kane (Mindtree Consulting PVT LTD)
> > Subject: Re: [PATCH 12/25] Staging: hv: Cleanup error handling in
> > vmbus_child_device_register()
> > 
> > On Tue, Apr 26, 2011 at 09:20:29AM -0700, K. Y. Srinivasan wrote:
> > > Cleanup error handling in vmbus_child_device_register().
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > > Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
> > > Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
> > > ---
> > >  drivers/staging/hv/vmbus_drv.c |    7 ++++++-
> > >  1 files changed, 6 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
> > > index d597dd4..4d569ad 100644
> > > --- a/drivers/staging/hv/vmbus_drv.c
> > > +++ b/drivers/staging/hv/vmbus_drv.c
> > > @@ -720,11 +720,16 @@ int vmbus_child_device_register(struct hv_device
> > *child_device_obj)
> > >  	 */
> > >  	ret = device_register(&child_device_obj->device);
> > >
> > > +	if (ret)
> > > +		return ret;
> > > +
> > >  	/* vmbus_probe() error does not get propergate to device_register(). */
> > >  	ret = child_device_obj->probe_error;
> > 
> > Wait, why not?  Why is the probe_error have to be saved off like this?
> > That seems like something is wrong here, this patch should not be
> > needed.
> > 
> > Well, you should check the return value of device_register, that is
> > needed, but this seems broken somehow.
> 
> The current code had comments claiming that the probe error was not
> correctly propagated. Looking at the kernel side of the code, it was not clear
> if device_register() could succeed while the probe might fail.

Of course it can, device_register() has nothing to do with the probe
callback of the device itself.  To think otherwise is to not understand
the driver model and assume things that you should never be caring
about.

Think about it, if you register a device, you don't know at that point
in time if a driver is currently loaded for it, and that it will be
bound to that device.  Nor do you care, as any needed notifications for
new drivers will be sent to userspace, and they will be loaded at some
random time in the future.  So a probe() call might never be called for
this device until some other time, running on some other processor, in
some other thread.

Drivers are allowed to return errors from their probe functions for
valid reasons (i.e. this driver shouldn't bind to this device for a
variety of good reasons.)  No one cares about this, as the driver core
handles it properly and will pass on to the next driver in the list that
might be able to be bound to this device.

So why do you care about the return value of the probe() call?  It gets
properly handled already by the driver core, why would your bus ever
care about it?  (Hint, no other bus does, as it makes no sense.)

> In any event, if you can guarantee that device_register() can return
> any probe related errors, I agree with you that saving the probe error
> is an overkill. The current code saved the probe error and with new
> check I added with regards to the return value of device_register,
> there is no correctness issue with this patch.

As explained above, no, it will not return a probe error, as that makes
no sense.  If the code is wanting to rely on this, it is broken and must
be fixed.

thanks,

greg k-h

  reply	other threads:[~2011-04-28  0:25 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 16:19 [PATCH 00/25] Staging: hv: Cleanup vmbus driver code K. Y. Srinivasan
2011-04-26 16:20 ` [PATCH 01/25] Staging: hv: Introduce a function to map a generic driver pointer to a pointer to storvsc_driver_object K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 02/25] Staging: hv: Get rid of the references to the priv element of struct hv_driver in block driver K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 03/25] Staging: hv: Get rid of the references to the priv element of struct hv_driver in hv_mouse.c K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 04/25] Staging: hv: Introduce a function to map a generic driver pointer to a pointer to struct netvsc_driver K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 05/25] Staging: hv: Get rid of the references to the priv element of struct hv_driver in net driver K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 06/25] Staging: hv: Get rid of the references to the priv element of struct hv_driver in storvsc_drv.c K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 07/25] Staging: hv: Cleanup vmbus_match() K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 08/25] Staging: hv: vmbus_driver cannot be unloaded; cleanup accordingly K. Y. Srinivasan
2011-04-26 22:45     ` Greg KH
2011-04-27  2:31       ` KY Srinivasan
2011-04-27  4:55         ` uabuntsu
2011-04-28  0:20         ` Greg KH
2011-04-29 13:49           ` KY Srinivasan
2011-04-29 15:10             ` Greg KH
2011-04-29 17:40               ` KY Srinivasan
2011-04-29 22:02               ` KY Srinivasan
2011-04-29 23:14                 ` Greg KH
2011-04-29 23:22                   ` KY Srinivasan
2011-04-26 16:20   ` [PATCH 09/25] Staging: hv: Get rid of vmbus_release_unattached_channels() as it is not used K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 10/25] Staging: hv: Get rid of the priv pointer in struct hv_driver K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 11/25] Staging: hv: Get rid of the drv field in struct hv_device K. Y. Srinivasan
2011-04-26 22:56     ` Greg KH
2011-04-27  1:55       ` KY Srinivasan
2011-04-26 16:20   ` [PATCH 12/25] Staging: hv: Cleanup error handling in vmbus_child_device_register() K. Y. Srinivasan
2011-04-26 22:50     ` Greg KH
2011-04-27  2:11       ` KY Srinivasan
2011-04-28  0:25         ` Greg KH [this message]
2011-04-29 15:45           ` KY Srinivasan
2011-04-26 16:20   ` [PATCH 13/25] Staging: hv: Cleanup vmbus_probe() function K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 14/25] Staging: hv: Properly handle errors in hv_pci_probe() K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 15/25] Staging: hv: Make hv_pci_dev a static variable K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 16/25] Staging: hv: Make msg_dpc a global variable K. Y. Srinivasan
2011-04-26 22:43     ` Greg KH
2011-04-26 16:20   ` [PATCH 17/25] Staging: hv: Make event_dpc " K. Y. Srinivasan
2011-04-26 22:43     ` Greg KH
2011-04-26 16:20   ` [PATCH 18/25] Staging: hv: Get rid of struct hv_bus K. Y. Srinivasan
2011-04-26 19:40     ` Greg KH
2011-04-26 20:23       ` KY Srinivasan
2011-04-26 20:58         ` Greg KH
2011-04-26 22:12           ` KY Srinivasan
2011-04-26 16:20   ` [PATCH 19/25] Staging: hv: Add probe function to struct hv_driver K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 20/25] Staging: hv: Use the probe function in " K. Y. Srinivasan
2011-04-26 16:51     ` Christoph Hellwig
2011-04-26 16:20   ` [PATCH 21/25] Staging: hv: Add remove() function to " K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 22/25] Staging: hv: Use the remove() function in " K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 23/25] Staging: hv: Add shutdown() function to " K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 24/25] Staging: hv: Use the shutdown() function in " K. Y. Srinivasan
2011-04-26 16:20   ` [PATCH 25/25] Staging: hv: VMBUS is a acpi enumerated device; get irq value from bios K. Y. Srinivasan
2011-04-26 16:57 ` [PATCH 00/25] Staging: hv: Cleanup vmbus driver code Christoph Hellwig
2011-04-26 17:04   ` KY Srinivasan
2011-04-26 19:39     ` Greg KH
2011-04-26 23:28 ` Greg KH
2011-04-27  1:54   ` KY Srinivasan
2011-04-27  6:45     ` Christoph Hellwig
2011-04-27 11:47       ` KY Srinivasan
2011-04-27 12:18         ` Christoph Hellwig
2011-04-29 16:32           ` KY Srinivasan
2011-04-29 16:40             ` Greg KH
2011-04-29 17:32               ` KY Srinivasan
2011-05-01 15:40               ` Christoph Hellwig
2011-05-01 15:46                 ` KY Srinivasan
2011-05-01 16:07                   ` Christoph Hellwig
2011-05-01 18:08                     ` KY Srinivasan
2011-05-01 20:53                       ` Christoph Hellwig
2011-05-02 19:48                         ` KY Srinivasan
2011-05-02 20:00                           ` Christoph Hellwig
2011-05-02 21:16                             ` KY Srinivasan
2011-05-02 21:35                               ` Christoph Hellwig
2011-05-02 22:11                                 ` KY Srinivasan
2011-05-01 15:39             ` Christoph Hellwig
2011-05-01 15:47               ` Greg KH
2011-05-01 18:56                 ` KY Srinivasan
2011-05-01 20:47                   ` Christoph Hellwig
2011-04-28  0:28     ` Greg KH
2011-04-29 14:26       ` KY Srinivasan
2011-04-29 15:08         ` Greg KH

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=20110428002552.GD14294@kroah.com \
    --to=greg@kroah.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@suse.de \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=v-abkane@microsoft.com \
    --cc=virtualization@lists.osdl.org \
    /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).