2017-06-01 13:17:53

by Mathias Nyman

[permalink] [raw]
Subject: Re: [LINUX PATCH] usb: xhci: Add toggle cycle bit for the last seg trb when cached ring is used

On 31.05.2017 16:41, Anurag Kumar Vulisha wrote:
> At present USB 2.0 cameras fail to play when run for 2nd time or greater.
> This issue occurs only when previous endpoint cached ring is used instead
> of allocating a new endpoint ring. The root cause of the problem narrows
> down to the Toggle bit, which is not getting set on the last trb of the
> cached ring last segment. When the controller fetches the last link trb
> with no toggle bit set, abnormal behaviour is generated.
> This patch solves that problem by adding the TOGGLE bit for the last trb
> of the last segment of the cached ring.
>
> Signed-off-by: Anurag Kumar Vulisha <[email protected]>

Thanks, nice catch.

I'm thinking about removing the whole endpoint ring caching instead.

We are using more memory by caching the rings instead of freeing them,
especially as we always try to allocate a new ring and only use the cached
ones when we fail to allocate a new ring.

Would you be willing to test a patch that removes the ring cache completely
with your setup?

Thanks
Mathias



2017-06-01 16:04:01

by Anurag Kumar Vulisha

[permalink] [raw]
Subject: RE: [LINUX PATCH] usb: xhci: Add toggle cycle bit for the last seg trb when cached ring is used

HI Mathias,

>-----Original Message-----
>From: Mathias Nyman [mailto:[email protected]]
>Sent: Thursday, June 01, 2017 6:51 PM
>To: Anurag Kumar Vulisha <[email protected]>; [email protected];
>[email protected]
>Cc: [email protected]; [email protected]; Anirudha Sarangi
><[email protected]>; Anurag Kumar Vulisha <[email protected]>
>Subject: Re: [LINUX PATCH] usb: xhci: Add toggle cycle bit for the last seg trb
>when cached ring is used
>
>On 31.05.2017 16:41, Anurag Kumar Vulisha wrote:
>> At present USB 2.0 cameras fail to play when run for 2nd time or greater.
>> This issue occurs only when previous endpoint cached ring is used
>> instead of allocating a new endpoint ring. The root cause of the
>> problem narrows down to the Toggle bit, which is not getting set on
>> the last trb of the cached ring last segment. When the controller
>> fetches the last link trb with no toggle bit set, abnormal behaviour is generated.
>> This patch solves that problem by adding the TOGGLE bit for the last
>> trb of the last segment of the cached ring.
>>
>> Signed-off-by: Anurag Kumar Vulisha <[email protected]>
>
>Thanks, nice catch.
>
>I'm thinking about removing the whole endpoint ring caching instead.
>
>We are using more memory by caching the rings instead of freeing them,
>especially as we always try to allocate a new ring and only use the cached ones
>when we fail to allocate a new ring.
>
>Would you be willing to test a patch that removes the ring cache completely with
>your setup?
>

Thanks for reviewing the patch. I completely agree with you. But I think instead of
completely removing the cached ring , can we modify the code to use cached ring
and try to allocate new ep ring on failure to get cached ring. I have previously sent
the patch for doing this https://lkml.org/lkml/2017/2/22/336
But anyways I am ready to test the changes with my platform. Please correct me
if I am wrong

Thanks,
Anurag Kumar Vulisha

>Thanks
>Mathias
>