Thread (2 messages) 2 messages, 2 authors, 2013-03-05

Re: [PATCH 4/7] usbnet: cdc_mbim: don't recover device if suspend fails in system sleep

From: Ming Lei <hidden>
Date: 2013-03-05 15:29:15
Also in: netdev

Possibly related (same subject, not in this thread)

On Tue, Mar 5, 2013 at 11:03 PM, Bjørn Mork [off-list ref] wrote:
Ming Lei [off-list ref] writes:
quoted
On Tue, Mar 5, 2013 at 9:46 PM, Bjørn Mork [off-list ref] wrote:
quoted
Now, after inspecting wdm_suspend() which hides behind
info->subdriver->suspend(), I see that this is a completely theoretical
discussion as it always will return 0 if PMSG_IS_AUTO(msg) is true...

Which means that your change really is a noop().  I still don't like it,
because it gives the impression that errors from info->subdriver->suspend()
isn't dealt with.
Yes, it needn't dealt with in system sleep, so it has the document benefit.
The document that the return code is ignored by forcing it to 0 and
always return success.

But am still not convinced this is correct in any way.  AFAICS there is
no documentation stating that the drivers should care about what the USB
We have source code, :-)
core use the return value for. Drivers are allowed to fail and the core
will ignore and clean up if necessary.

I still find any partial failures horrendous.  If we are not going to
fail on errors, then we'll return success and pretend to be suspended.
quoted
No, USB core does not handle it, and will always ignore the return
failure from driver's suspend, see usb_suspend_both() for non-autosuspend
case.
Right you are.  Somehow I read the inverse.  Sorry about that.

In any case, it ends up here and everythin will be OK, which I assume is
why it can ignore the errors:

        /* If the suspend succeeded then prevent any more URB submissions
         * and flush any outstanding URBs.
         */
        } else {
                udev->can_submit = 0;
                for (i = 0; i < 16; ++i) {
                        usb_hcd_flush_endpoint(udev, udev->ep_out[i]);
                        usb_hcd_flush_endpoint(udev, udev->ep_in[i]);
                }
        }
Yes, USB core will flush any outstanding URBs, but the driver still need
to deal with suspend failure carefully, for example, suppose usb_resume()
is called in suspend failure path, and the submitted URBs are killed
by USB core later. But after the device is wakeup, and the resume() will
do nothing since the suspend count is leaked. So it is what the patches
are fixing, and it is better to not depend on the default flushing URBs of
USB core.

Thanks,
--
Ming Lei
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help