All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Felipe Balbi <felipe.balbi@linux.intel.com>, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 2/3] xhci: Set URB actual length for stopped control transfers
Date: Mon, 27 Mar 2017 18:52:46 +0300	[thread overview]
Message-ID: <58D9354E.3020508@linux.intel.com> (raw)
In-Reply-To: <877f3akc81.fsf@linux.intel.com>

On 27.03.2017 17:47, Felipe Balbi wrote:
>
> Hi,
>
> Mathias Nyman <mathias.nyman@linux.intel.com> writes:
>> A control transfer that stopped at the status stage incorrectly
>> warned about a "unexpected TRB Type 4", and did not set the
>> transferred actual_length for the URB.
>>
>> The transferred actual_length should be set the same way for
>> COMP_STOPPED control transfers as in the generic cases.
>>
>> generic case if we get an event at:
>>
>> TRB_SETUP stage:
>>    length = 0;
>>
>> TRB_DATA/TRB_NORMAL state:
>>    length = requested - remaining;
>>
>> TRB_STATUS stage:
>>    length = requested
>>
>> The URB actual_length for control transfers doesn't care about sent
>> bytes of the SETUP stage, or remaining bytes of the  STATUS stage.
>>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
>> ---
>>   drivers/usb/host/xhci-ring.c | 20 +++++---------------
>>   1 file changed, 5 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
>> index d9936c7..584b6fe 100644
>> --- a/drivers/usb/host/xhci-ring.c
>> +++ b/drivers/usb/host/xhci-ring.c
>> @@ -1975,25 +1975,15 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
>>   		*status = 0;
>>   		break;
>>   	case COMP_STOPPED_SHORT_PACKET:
>> -		if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
>> +		if (trb_type == TRB_DATA || trb_type == TRB_NORMAL) {
>> +			td->urb_length_set = true;
>>   			td->urb->actual_length = remaining;
>> -		else
>> +		} else {
>>   			xhci_warn(xhci, "WARN: Stopped Short Packet on ctrl setup or status TRB\n");
>> +		}
>>   		goto finish_td;
>>   	case COMP_STOPPED:
>> -		switch (trb_type) {
>> -		case TRB_SETUP:
>> -			td->urb->actual_length = 0;
>> -			goto finish_td;
>> -		case TRB_DATA:
>> -		case TRB_NORMAL:
>> -			td->urb->actual_length = requested - remaining;
>> -			goto finish_td;
>> -		default:
>> -			xhci_warn(xhci, "WARN: unexpected TRB Type %d\n",
>> -				  trb_type);
>> -			goto finish_td;
>> -		}
>> +		break;
>
> instead of this giant patch, why didn't you just add case TRB_STATUS to
> the switch statement above? It would've been a single line that would
> solve your problem.

giant ?
1 file changed, 5 insertions(+), 15 deletions(-)

why add an extra case when it can be handled with the generic case?
This is almost code duplication already.

>
> Not to mention that we loose the xhci_warn() for unexpected TRB types
> which might help finding valid issues (such as $subject).

That warning was added recently and turned out to be more harmful than useful.
The type can be seen from traces instead.

We're not warning about TRB types in other cases. And we would need to
worry about link, noop, event-data types as well.

>
> Note that now we do nothing on COMP_STOPPED, this means that we're
> relying on some generic case that, arguably, could be removed
> altogether. $subject is just re-adding part of obfuscation we had and
> took so much work to clean up.

?

It's the other way around.
We want the generic way to handle as much as it can, like the successful cases,
the short packets etc. we only want to mess with it when absolutely necessary

-Mathias  

  reply	other threads:[~2017-03-27 15:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1490624830-9761-1-git-send-email-mathias.nyman@linux.intel.com>
2017-03-27 14:27 ` [PATCH v2 2/3] xhci: Set URB actual length for stopped control transfers Mathias Nyman
2017-03-27 14:47   ` Felipe Balbi
2017-03-27 15:52     ` Mathias Nyman [this message]
2017-03-27 14:27 ` [PATCH v2 3/3] xhci: Manually give back cancelled URB if queuing it for cancel fails Mathias Nyman
2017-03-27 14:54   ` Felipe Balbi
2017-03-27 14:57     ` Felipe Balbi
2017-03-27 15:20     ` Mathias Nyman
2017-03-28  6:49       ` Felipe Balbi
2017-03-28 10:30         ` Mathias Nyman

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=58D9354E.3020508@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.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 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.