Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5411876imm; Tue, 12 Jun 2018 07:29:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIBnQ455rkn8DsKjA9d4TCfzSncweXenSUhXPSsMZfeGovPLXUZpqaB1QG+5/sBB/5hLuFn X-Received: by 2002:aa7:8510:: with SMTP id v16-v6mr644229pfn.77.1528813782709; Tue, 12 Jun 2018 07:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528813782; cv=none; d=google.com; s=arc-20160816; b=ct7221mjTbnfZrUZLkQW23ciCqy4wUDtlBXsmkvAQwil+ZhGbIzyxPX3rABUCpLqup Ut9r5QgSwmxN/jhLaUSHUWYConMe+EM6Gu0EqnQGZ0bBZUdHzpPpl5UlRCQFGLc6vwh3 g62Ey4teNaBIp9d/xzTuqinwqyerC/X4rjCf3k5MLokWSC5dfXvTvKO4Q1aOMmmBOkRS 540Cz4iYhhXc5M4/MuzqTbS9blrrf01I1uNCG5Pq0/3w/AqjVinlEUjVFWHW4O0gN7II KNgvcGsQMN0/z46P8TZoZ2Z5ag/XWaKBGnoWPRmxeqN5Azcms+HZ1GRezto58EvyB84S LZ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:arc-authentication-results; bh=5J/m0bHcOmQh2IQepEmzirLI38CjxoHdoHn38hFq3RU=; b=Az7rYwPTsl5SjcrAniDMzb/mDne4u3s0WSrlCjnd+zOP/7wBCX4dNVJt7eeCs8DElz gUb2kKWEP5LhAvXIn6OFcU+ggZrxnngxPbuV4AC3AP8hFLDG50ZwokDn2n9S31o7Tcsl zlQx6LuTNnfsbOSVNQ9kBitPdsATQp9f9YeE1gQcsyCLhZao1ZWAdFRKFR/+83z1KUDW ybqs5628kH5SdJpsjVv/is+JWCrzp377RN+S6i7po4f1DOQZ6VXwrOJbwkoo23RPRUrm hHlZYSL+XsQ9iuwXZF+9hSRfWXgpg1Uc9K3r27HYAGkZBUoE3dU40wyh0gfm1St31YPU KWJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12-v6si239586pfj.331.2018.06.12.07.29.28; Tue, 12 Jun 2018 07:29:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933640AbeFLO3G (ORCPT + 99 others); Tue, 12 Jun 2018 10:29:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37048 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754056AbeFLO3F (ORCPT ); Tue, 12 Jun 2018 10:29:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8370E401EF23; Tue, 12 Jun 2018 14:29:04 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7066C2017D10; Tue, 12 Jun 2018 14:29:04 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w5CET4lK012262; Tue, 12 Jun 2018 10:29:04 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w5CET4IG012258; Tue, 12 Jun 2018 10:29:04 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 12 Jun 2018 10:29:04 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Greg Kroah-Hartman , Alan Stern , Ming Lei cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: don't offload isochronous urb completions to ksoftirq Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 12 Jun 2018 14:29:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 12 Jun 2018 14:29:04 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I have a single-core machine with usb2 soundcard. When I increase mplayer priority (to real-time or high non-realtime priority), the sound is stuttering. The reason for the stuttering is that mplayer at high priority preempts the softirq thread, preventing URBs from being completed. It was caused by the patch 428aac8a81058 that offloads URB completion to softirq. This patch prevents offloading isochronous URBs to softirq to fix the stuttering. Fixes: c04ee4b1136e ("Revert "Revert "USB: EHCI: support running URB giveback in tasklet context""") Cc: stable@vger.kernel.org --- drivers/usb/core/hcd.c | 10 ++++++++++ drivers/usb/host/ehci-q.c | 11 ++++++++++- include/linux/usb/hcd.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) Index: linux-4.17/drivers/usb/core/hcd.c =================================================================== --- linux-4.17.orig/drivers/usb/core/hcd.c 2018-06-12 16:06:23.000000000 +0200 +++ linux-4.17/drivers/usb/core/hcd.c 2018-06-12 16:07:51.000000000 +0200 @@ -1858,6 +1858,16 @@ void usb_hcd_giveback_urb(struct usb_hcd } EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb); +void _usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) +{ + /* pass status to tasklet via unlinked */ + if (likely(!urb->unlinked)) + urb->unlinked = status; + + __usb_hcd_giveback_urb(urb); +} +EXPORT_SYMBOL_GPL(_usb_hcd_giveback_urb); + /*-------------------------------------------------------------------------*/ /* Cancel all URBs pending on this endpoint and wait for the endpoint's Index: linux-4.17/drivers/usb/host/ehci-q.c =================================================================== --- linux-4.17.orig/drivers/usb/host/ehci-q.c 2018-06-12 16:06:23.000000000 +0200 +++ linux-4.17/drivers/usb/host/ehci-q.c 2018-06-12 16:09:28.000000000 +0200 @@ -238,6 +238,8 @@ static int qtd_copy_status ( static void ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status) +__releases(ehci->lock) +__acquires(ehci->lock) { if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { /* ... update hc-wide periodic stats */ @@ -264,7 +266,14 @@ ehci_urb_done(struct ehci_hcd *ehci, str #endif usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); - usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); + if (usb_pipeisoc(urb->pipe)) { + /* complete() can reenter this HCD */ + spin_unlock(&ehci->lock); + _usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); + spin_lock(&ehci->lock); + } else { + usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); + } } static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh); Index: linux-4.17/include/linux/usb/hcd.h =================================================================== --- linux-4.17.orig/include/linux/usb/hcd.h 2018-06-05 21:07:27.000000000 +0200 +++ linux-4.17/include/linux/usb/hcd.h 2018-06-12 16:07:11.000000000 +0200 @@ -428,6 +428,8 @@ extern int usb_hcd_submit_urb(struct urb extern int usb_hcd_unlink_urb(struct urb *urb, int status); extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status); +extern void _usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, + int status); extern int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); extern void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *);