Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp715090imm; Wed, 13 Jun 2018 07:14:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/JSyBOm3yPIL5yQJ+ZJ0SHxNhSk+0MNnY+87JYEtX5jxIf6Do8WNAIGnCsWhTKL1o+yEG X-Received: by 2002:a65:508d:: with SMTP id r13-v6mr4307053pgp.143.1528899261685; Wed, 13 Jun 2018 07:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528899261; cv=none; d=google.com; s=arc-20160816; b=Oe6BsZBY6CZ/D+Eo6+foMQc5XbOTMEAfCy2gq5R0+E5mYlq3ZrzZvAvD5diiyT9iX/ lbzOtxTQTbvgxp9unl5e1kM8w1I/A4V6/Rh01Ulr4RnOE6iVS5XoqRR/9FXgAJk56Ubz s7aXxNOm0fFa6mx0JClv78xnDDcMcAOaFmc20kI4WYAsQqhV9wyY6GSVjSxEM5AnKg7O 3HfZOwTxR/ltWHoSFVgK2Z3YPSjW2rWq4lUQHzn4L3XR3ir6JJ7Lu0SIP0o49B4YPhvz WbT5+oD7rKLA5ufSUCRScCdR6ZaTvJnCP1qqxIEP2NQNi/udV38Lb+CAIbbENBvNXypZ 10+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=mMjXmbbYwatkY0OHrTNyjYFh5xTHL80NjAjhEenmFKk=; b=Cr4sx7DnWp1fIwqAb3X+Uko56E1Kyi43cabknW6Qc/5UnmcjS/22KI62uL1X/xxOrO UPK/M8TxKuSCVhyIx6ttK5iaScDQB8F+BzuoHKexWZ410O04DIdb4UZf4cNe4NiEV7wD YiaaBVzkZJbI4zuVkGMlvNQF25A+p1XjveK5XWkpe6fWWQZu/nEX/w0KHZiUp33CF2a8 nG7WO+ztNL3uPi0uwwawrhjHnOyg1g7OBxWxDZNUk3t0fK6s5nxWoEOVVF6ElpQ/EPkL CScrSxedNCMIOYOgEarK9Mpl9akVf57smErbRHfg3DxuguD/7T1cSK29t1XLSiJA3cFX CmbQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si2336282pgr.318.2018.06.13.07.14.07; Wed, 13 Jun 2018 07:14:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935770AbeFMONM (ORCPT + 99 others); Wed, 13 Jun 2018 10:13:12 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:59796 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S935656AbeFMONK (ORCPT ); Wed, 13 Jun 2018 10:13:10 -0400 Received: (qmail 1608 invoked by uid 2102); 13 Jun 2018 10:13:09 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 13 Jun 2018 10:13:09 -0400 Date: Wed, 13 Jun 2018 10:13:09 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Mikulas Patocka cc: Thomas Gleixner , Ming Lei , Greg Kroah-Hartman , USB list , Kernel development list Subject: Re: [PATCH] usb: don't offload isochronous urb completions to ksoftirq In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jun 2018, Mikulas Patocka wrote: [Skipping lots of material...] > BTW I found this piece of code in sound/usb/usx2y/usbusx2yaudio.c: > urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); > if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { > snd_printk (KERN_ERR "cannot submit datapipe for urb %d, err = %d\n", i, err); > err = -EPIPE; > goto cleanup; > } else > if (i == 0) > usX2Y->wait_iso_frame = urb->start_frame; > urb->transfer_flags = 0; > It seems like a bug to modify transfer_flags after the urb is submitted. Yes, it is definitely a bug. > 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. > --- linux-4.17.orig/drivers/usb/host/ehci-q.c 2018-06-12 22:35:21.000000000 +0200 > +++ linux-4.17/drivers/usb/host/ehci-q.c 2018-06-12 22:44:09.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,17 @@ 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 (urb->transfer_flags & URB_FAST_COMPLETION) { > + /* > + * USB audio experiences skipping of we offload completion > + * to ksoftirq. > + */ This comment seems unnecessary. > + 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); > + } > } I'm not at all sure about this. Have you audited all of ehci-hcd to make sure the driver doesn't assume that ehci->lock remains held while an URB is given back? It's been so long since I worked on this area that I don't remember the answer offhand. Alan Stern