Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1014367imm; Wed, 13 Jun 2018 11:55:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL38foxpib3ktu+Eubagnho/suakqyGAqT8ickFKFSrRtAMzGrjF9aAJ63DU+pik9e1V6Ig X-Received: by 2002:a62:ea14:: with SMTP id t20-v6mr6107089pfh.117.1528916141444; Wed, 13 Jun 2018 11:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528916141; cv=none; d=google.com; s=arc-20160816; b=uGktcLYMzvFLRyiBDxigO0RX1JAYmq7vXz8ixHscnUdNwHEVbJGf3cDRF/aVN7IBs3 D2WsKOMezJLsJKk3IOwvpxRVEK2d9ZNrjkbq2GX1EPCWsyZEFlNbzfDg7UV+ThZZYE/W NBalE0tZenAmayABXMNJvqQg/G26SARsJ1GlCAr6lzIWDNjdtM97N81JkLsDAqHwyIw6 SEaJgKx701Mxmj65soZusIYUsZD7tUTATwKt4+mxc4nOEJ4ITmQmyn8ZQzup/jZBY9Nf mZ08PByVBhWd2H4eBR5H3lVh+MAGjB3wWoSkIr6BeLHGVgQ4wqRR5bk8Yk+aZIkcHAcw HHHg== 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=ku6g1fSlz0DbWmbMCqCxPW9eXY1W5Kpzdqi7ZPROJeg=; b=vWcz92/G1zYDrELwCDYHPaK7XWLQZ4Qmuri4SGEKxuCPQWo6H+EQUjJJFs9M7hBr0Q YdFjAXrWibo8DV2Bdy8h3KOa+ZAh6BxP7tuA1faF7Amf3i6ppuNcl+6ue5TxBX478xja ptbv+MuzUGY9mx55Wu5pnK2U5dN1tPAdrb7VUm2Prys+uHbhSr0CLra2lpHxmPqJ8X3j LkCK8eZJUn8EFDOvQgGLRMq7tBI+Ba/HBFp7QUJ12bYo+YrmrashHX8daiKFIdFkZ6bb m/gYCMAbPD0Ug/j76He+gJUpjltsKgtsXdUJ7PtPUIuK+dovYyynLAp5J7j8YrIUJTva OB1g== 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 u17-v6si2749774pgv.455.2018.06.13.11.55.27; Wed, 13 Jun 2018 11:55:41 -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 S935322AbeFMSy6 (ORCPT + 99 others); Wed, 13 Jun 2018 14:54:58 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:60462 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754484AbeFMSy5 (ORCPT ); Wed, 13 Jun 2018 14:54:57 -0400 Received: (qmail 5375 invoked by uid 2102); 13 Jun 2018 14:54:56 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 13 Jun 2018 14:54:56 -0400 Date: Wed, 13 Jun 2018 14:54:56 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Mikulas Patocka cc: Steven Rostedt , 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 [Steve: Sorry for dumping you into the middle of this discussion. Please see especially the last two paragraphs below. Mikulas is getting dropouts with USB audio because part of the processing uses a tasklet.] On Wed, 13 Jun 2018, Mikulas Patocka wrote: > > > + 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 > > I compared the current ehci code the code in the kernel 3.11 (that was the > last kernel that didn't offload callbacks) and it is very similar. So, we > can assume that if it was ok in the kernel 3.11, it is ok now. > > itd_complete and sitd_complete are the same except for small formatting > changes. > > itd_submit and sitd_submit newly call ehci_urb_done, but it drops the > spinlock after the call, therefore it tolerates that ehci_urb_done drops > the spinlock. > > qh_completions is almost the same in the kernel 3.11 and upstream, so if > it tolerated dropped spinlock and resubmission in 3.11, it should tolerate > it now. It's also necessary to check the places these routines get called from: scan_isoc, scan_intr, scan_async, and ehci_work. However, the comments in those routines say that they expect the lock might be dropped, so they're probably okay. ehci_work, in particular, is very careful about this -- it started out that way, and I decided not to remove the safeguards when the driver switched over to tasklets. > BTW - if you think that dropping the spinlock could cause trouble - should > we add the urbs to temporary list and call the callbacks just after the > spinlock is dropped? But that would just add a lot of junk code to the > ehci driver. I don't think this will be needed. > Another possibility is to hack the softirq subsystem so that tasklet_hi is > never offloaded - but I don't know if it makes sense to make this change > jsut because of ehci. I don't know. But it isn't just ehci-hcd; _anything_ that tries to use tasklets for bounded-latency applications will have the same problem. This sounds like the sort of thing the RT kernels must have addressed long ago. Alan Stern