lkml.org 
[lkml]   [2022]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] USB: HCD: Fix URB giveback issue in tasklet function
On Mon, Jul 25, 2022 at 02:52:51PM +0800, Weitao Wang wrote:

This is basically okay. Just a couple of small comments...

> Usb core introduce the mechanism of giveback of URB in tasklet context to
> reduce hardware interrupt handling time. On some test situation(such as
> FIO with 4KB block size), when tasklet callback function called to
> giveback URB, interrupt handler add URB node to the bh->head list also.
> If check bh->head list again after finish all URB giveback of local_list,
> then it may introduce a "dynamic balance" between giveback URB and add URB
> to bh->head list. This tasklet callback function may not exit for a long
> time, which will cause other tasklet function calls to be delayed. Some
> real-time applications(such as KB and Mouse) will see noticeable lag.
>
> Fix this issue by taking new URBs giveback in next tasklet function call.
> Add a member high_prio for structure giveback_urb_bh and replace the local
> high_prio_bh variable with this structure member in usb_hcd_giveback_urb.

The patch description should do more than say what the new code _is_ --
we can see that easily enough by reading the patch. The description
should explain _why_ the code was changed.

> Fixes: 94dfd7edfd5c ("USB: HCD: support giveback of URB in tasklet context")
> Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
> ---
> v1->v2:
> - Fix compile warning by remove label "restart".
> - Modify the patch description info.
> - Change structure member from hi_priority to high_prio.
>
> drivers/usb/core/hcd.c | 25 ++++++++++++++-----------
> include/linux/usb/hcd.h | 1 +
> 2 files changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 06eea8848ccc..1feb9a604380 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1691,7 +1691,6 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
>
> spin_lock_irq(&bh->lock);
> bh->running = true;
> - restart:
> list_replace_init(&bh->head, &local_list);
> spin_unlock_irq(&bh->lock);
>
> @@ -1705,10 +1704,16 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
> bh->completing_ep = NULL;
> }
>
> - /* check if there are new URBs to giveback */
> + /* giveback new URBs next time to prevent this function from
> + * not exiting for a long time.
> + */

Minor stylistic issue: The currently accepted format for multi-line
comments is like this:

/*
* Blah blah blah
* Blah blah blah
*/

Alan Stern

\
 
 \ /
  Last update: 2022-07-25 15:58    [W:0.072 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site