All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: Ming Lei <tom.leiming@gmail.com>
Cc: "Bjørn Mork" <bjorn@mork.no>,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	"Marius Bjørnstad Kotsbak" <marius.kotsbak@gmail.com>
Subject: Re: [PATCH net] net: qmi_wwan: fix Oops while disconnecting
Date: Mon, 25 Jun 2012 08:15:39 +0200	[thread overview]
Message-ID: <201206250815.39466.oliver@neukum.org> (raw)
In-Reply-To: <CACVXFVN3wJ3NWxSGj-yWCgtDE_sgJT5CZYHwYUWk1MxkphcsTg@mail.gmail.com>

Am Montag, 25. Juni 2012, 05:37:20 schrieb Ming Lei:
> On Mon, Jun 25, 2012 at 1:47 AM, Bjørn Mork <bjorn@mork.no> wrote:
> > Oliver Neukum <oliver@neukum.org> wrote:
> >>Am Sonntag, 24. Juni 2012, 11:34:19 schrieb Bjørn Mork:
> >>
> >>> Sorry, I did not understand what you meant we should do here.  The
> >>extra
> >>> usb_set_intfdata(, NULL) in usbnet_disconnect() won't make any
> >>> difference for that piece of code, will it?
> >>
> >>The point is that if it may be set to NULL, we always want it to be set
> >>to
> >>NULL, so we catch bugs.
> >>
> >>> And the USB core ensures that intfdata is set to NULL before any
> >>> reprobing, so that will never be a problem.  That's the reason why it
> >>> seems redundant setting it in usbnet_disconnect().
> >>
> >>The point is that if there is a problem because intfdata is set to
> >>NULL,
> >>there is very likely a problem in form of a race condition, if intfdata
> >>were not set to NULL in usbnet's disconnect handler.
> 
> I don't agree on the assumption.
> 
> The current problem is caused by the set to NULL without any
> protection or sync mechanism on it, and it is really a bug.

Minidrivers can test for NULL.
That may not be enough and locking may be needed.

> Also we didn't say the set to NULL will be cancelled, just delay
> the clear until it is safe to do it, eg. after complete of unregister_netdev()
> and driver_info->unbind, when the previous .open/.close has been
> completed already or the later ones will notice the disconnection
> early and won't touch usb_get_intfdata() any more.

We can move to after unregister_netdev()
I am unhappy with it going after unbind.

> > Thanks for explaining. Yes, that makes sense to me as well.
> >
> > So then the original patch against qmi_wwan should go in, and we should leave usbnet as it is. Are everyone comfortable with that?
> 
> I don't see any races caused by just removing usb_set_intfdata(, NULL)
> or moving it after driver_info->unbind simply in usbnet_disconnect.

They are not caused. They are harder to detect.

> In fact, suppose that .open/.close and .disconnect are run on different CPUs,
> there are no any guarantee that .open/.close can always see the clear action
> immediately. Also, the clear of intfdata may not be observed in .manage_power
> since usb_set_intfdata(, NULL) may be completed after the lock wdm_mutex
> operation.

Sure, it is a debugging aid. It has the drawback that minidrivers have
to be able to deal with intfdata being NULL. That is not hard to do.

	Regards
		Oliver

  reply	other threads:[~2012-06-25  6:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-22  9:11 [PATCH net] net: qmi_wwan: fix Oops while disconnecting Bjørn Mork
     [not found] ` <1340356279-3124-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2012-06-22 12:45   ` Ming Lei
2012-06-22 13:42     ` Bjørn Mork
2012-06-22 15:09       ` Ming Lei
     [not found]         ` <CACVXFVOQ3Uh50iJxboD-7=+J55MAW8Wjt3iY0WahauO2PrxT4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-22 16:18           ` Bjørn Mork
     [not found]             ` <877guzl3qz.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-06-22 16:52               ` Ming Lei
     [not found]                 ` <CACVXFVNCAsM5NihpAFLU5rGo5ynr3=XU5gw7nM5Fi2mrrX+hKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-22 17:31                   ` Bjørn Mork
2012-06-23  3:32   ` Ming Lei
2012-06-23  3:39     ` Ming Lei
     [not found]       ` <CACVXFVMJSrLjOyKUnZWr3CY2HJT6Wfm6AugZOhSCRUubV0hNMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-23  8:45         ` Bjørn Mork
2012-06-23 14:55           ` Ming Lei
2012-06-23 15:32             ` Bjørn Mork
     [not found]               ` <87hau2hwna.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-06-23 20:55                 ` Oliver Neukum
     [not found]                   ` <201206232255.08319.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2012-06-24  9:34                     ` Bjørn Mork
2012-06-24 12:13                       ` Oliver Neukum
2012-06-24 17:47                         ` Bjørn Mork
2012-06-25  3:37                           ` Ming Lei
2012-06-25  6:15                             ` Oliver Neukum [this message]
2012-06-25  7:15                               ` Ming Lei
     [not found]                                 ` <CACVXFVNUv6w5OjSZdQDbcLEPpDU5vO_Nmarm+fAfh0RkkL_hdg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25 12:10                                   ` Oliver Neukum
2012-06-26  7:23                                     ` Ming Lei
2012-06-28  8:35                                       ` Oliver Neukum
     [not found]                                         ` <201206281035.19964.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-06-28  8:55                                           ` Bjørn Mork
2012-06-28  9:11                                         ` Ming Lei
     [not found]                             ` <CACVXFVN3wJ3NWxSGj-yWCgtDE_sgJT5CZYHwYUWk1MxkphcsTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25  7:24                               ` Bjørn Mork
2012-06-25  8:08                                 ` Ming Lei
     [not found]                                   ` <CACVXFVOPjFSS6Sv6AUCSAs4nywR045QhjYAbN8g6U3adsUbujw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25  8:27                                     ` Bjørn Mork
2012-06-28  8:36   ` Bjørn Mork
     [not found]     ` <87lij7de8u.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-06-28  8:40       ` Oliver Neukum
     [not found]         ` <201206281040.55402.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2012-06-28 23:54           ` David Miller

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=201206250815.39466.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=bjorn@mork.no \
    --cc=linux-usb@vger.kernel.org \
    --cc=marius.kotsbak@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=tom.leiming@gmail.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.