All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rajesh Bhagat <rajesh.bhagat@nxp.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"mathias.nyman@intel.com" <mathias.nyman@intel.com>,
	Sriram Dash <sriram.dash@nxp.com>
Subject: RE: [PATCH] usb: xhci: Fix incomplete PM resume operation due to XHCI commmand timeout
Date: Mon, 21 Mar 2016 04:22:54 +0000	[thread overview]
Message-ID: <HE1PR0401MB2028724EAC68D97679A79B74E38F0@HE1PR0401MB2028.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1603181016140.1866-100000@iolanthe.rowland.org>



> -----Original Message-----
> From: Alan Stern [mailto:stern@rowland.harvard.edu]
> Sent: Friday, March 18, 2016 7:51 PM
> To: Rajesh Bhagat <rajesh.bhagat@nxp.com>
> Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org;
> gregkh@linuxfoundation.org; mathias.nyman@intel.com; Sriram Dash
> <sriram.dash@nxp.com>
> Subject: Re: [PATCH] usb: xhci: Fix incomplete PM resume operation due to XHCI
> commmand timeout
> 
> On Fri, 18 Mar 2016, Rajesh Bhagat wrote:
> 
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -2897,10 +2897,14 @@ done:
> >  			/* The xHC may think the device is already reset,
> >  			 * so ignore the status.
> >  			 */
> > -			if (hcd->driver->reset_device)
> > -				hcd->driver->reset_device(hcd, udev);
> > -
> > -			usb_set_device_state(udev, USB_STATE_DEFAULT);
> > +			if (hcd->driver->reset_device) {
> > +				status = hcd->driver->reset_device(hcd, udev);
> > +				if (status == 0)
> > +					usb_set_device_state(udev, USB_STATE_DEFAULT);
> > +				else
> > +					usb_set_device_state(udev,
> USB_STATE_NOTATTACHED);
> > +			} else
> > +				usb_set_device_state(udev, USB_STATE_DEFAULT);
> 
> This is a really bad patch:
> 
> You left in the comment about ignoring the status, but then you changed the code so
> that it doesn't ignore the status!
> 

My Apologies, I completely missed the above comment which was added before. 

> You also called usb_set_device_state() more times than necessary.  You could have
> done it like this:
> 
> 			if (hcd->driver->reset_device)
> 				status = hcd->driver->reset_device(hcd, udev);
> 			if (status == 0)
> 				usb_set_device_state(udev, USB_STATE_DEFAULT);
> 			else
> 				usb_set_device_state(udev, USB_STATE_NOTATTACHED);
> 
> (Even that could be simplified further, by combining it with the code that follows.)
> 
> Finally, you violated the 80-column limit.
> 

I agree to your point. Actually the intent was to check the return status of reset_device which 
is currently being ignored. I encountered the reset_device failure case in resume operation (STR) 
which is increasing the time of resume and causing unexpected crashes if return value is not checked. 

Do you agree it should be checked here? If yes, I can rework this patch. 

> Alan Stern

  reply	other threads:[~2016-03-21  4:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18  7:01 [PATCH] usb: xhci: Fix incomplete PM resume operation due to XHCI commmand timeout Rajesh Bhagat
2016-03-18 11:20 ` Mathias Nyman
2016-03-21  4:18   ` Rajesh Bhagat
2016-03-21  9:16     ` Mathias Nyman
2016-03-22  5:19       ` Rajesh Bhagat
2016-03-22 12:05         ` Mathias Nyman
2016-03-23  3:53           ` Rajesh Bhagat
2016-03-23 14:22             ` Mathias Nyman
2016-03-28  6:13               ` Rajesh Bhagat
2016-03-29 17:21                 ` Mathias Nyman
2016-03-31  3:51                   ` Rajesh Bhagat
2016-03-31 14:36                     ` Mathias Nyman
2016-04-01  3:55                       ` Rajesh Bhagat
2016-04-01 10:49                         ` Mathias Nyman
2016-04-11  3:46                           ` Rajesh Bhagat
2016-03-18 14:21 ` Alan Stern
2016-03-21  4:22   ` Rajesh Bhagat [this message]
2016-03-21 15:02     ` Alan Stern

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=HE1PR0401MB2028724EAC68D97679A79B74E38F0@HE1PR0401MB2028.eurprd04.prod.outlook.com \
    --to=rajesh.bhagat@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=sriram.dash@nxp.com \
    --cc=stern@rowland.harvard.edu \
    /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.