Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1632340yba; Thu, 4 Apr 2019 14:57:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvbUsxVZdcfwiDa2adOlMr2+4aDEnPXfDncXFeJ/sDQqY4PTgjoDlYivoOHMHw7paEY59k X-Received: by 2002:a17:902:8c97:: with SMTP id t23mr8937296plo.110.1554415054034; Thu, 04 Apr 2019 14:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554415054; cv=none; d=google.com; s=arc-20160816; b=Smeo1DuJCtVXVyH4j+DD7bEH3hptS4nSPlmUiQtzTz262Niv+Lx/MqTm17EqflTsAp 2cYfbigAfzvkqaqQxViL46PFEsY/jnfPaYW6/mBMYGoLEAYofpcp89v7KGjBwPE9J8aB J7Jdw62efHSmkPc/bEHjF8wpjSvpeekQLWzFzR0fnRoTBd5Ps1AHwYQND5WcePLzESVJ pNYi/K8FtBxqLfQRhhr8PoyIaUbdL6kssz7j0zDJ/Exh8U1QxQsY73vs6+xMC8iXSDFT o+CXyamvsKEQh2i5kVknaeyagFVknuMxBD6G1QjtjkgMn3S8acyQn7ycBwhb4+nMe9fu BqFQ== 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; bh=4swT1ifl+e1Rda8FWKiykUpupgp2h5NnhwBztnGflsA=; b=KyjJU9ea4ZgH1k2gAwR6OykuQqxB8tyEtvt1ZbVHmwpgY3aJHDh6iTwwakRpjDgPFP US5fvudZMzwZn02vRdzIdIsg6RGLnGHaIDz5VEg+JtOVB0N9kLWTDjKtUSFfbro0oUgV e7exV07Vf+7cXnttfZoTdXmrcyKgWjJH8NwGjwmv/FdttYGiGTRg13R0VtnBa7BywGOu WMjD8Vya6xokAFprKls9XK4MnOFNyQbqGQ1cRdZ85yxTRwvcvnMURhOwB0ltMbvjLTw1 zhfNwXq7v2zNDJD2RtLwo4pEkiQbMQKp8tumvcHowzqc62s4iwSZsE2UgiuNDhEW1Mig of0A== 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 r17si16606874pgv.328.2019.04.04.14.57.19; Thu, 04 Apr 2019 14:57:34 -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 S1731281AbfDDUy1 (ORCPT + 99 others); Thu, 4 Apr 2019 16:54:27 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:41708 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730021AbfDDUy1 (ORCPT ); Thu, 4 Apr 2019 16:54:27 -0400 Received: (qmail 27564 invoked by uid 2102); 4 Apr 2019 16:54:26 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 4 Apr 2019 16:54:26 -0400 Date: Thu, 4 Apr 2019 16:54:26 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Suwan Kim cc: mathias.nyman@linux.intel.com, , , Subject: Re: [PATCH v2] usb: host: xhci: Support running urb giveback in tasklet context In-Reply-To: <20190404121823.GA3793@localhost.localdomain> 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 Thu, 4 Apr 2019, Suwan Kim wrote: > Hi Alan, > > On Mon, Apr 01, 2019 at 10:43:24AM -0400, Alan Stern wrote: > > On Mon, 1 Apr 2019, Suwan Kim wrote: > > > > > Patch "USB: HCD: support giveback of URB in tasklet context"[1] > > > introduced giveback of urb in tasklet context. [1] This patch was > > > applied to ehci but not xhci. [2] This patch significantly reduces > > > the hard irq time of xhci. Especially for uvc driver, the hard irq > > > including the uvc completion function runs quite long but applying > > > this patch reduces the hard irq time of xhci. > > > > Please read the kerneldoc for usb_submit_urb() and usb_kill_urb(), in > > particular, the parts that describe how isochronous URBs are treated. > > Can you guarantee that with this patch applied, xhci-hcd will continue > > to work as the kerneldoc describes? > > > > I read the description of usb_submit_urb() and usb_kill_urb() and i > think that xhci-hcd with which this patch is applied works as the > description of usb_submit_urb() and usb_kill_urb(). > > In the case of usb_submit_urb(), xhci spec 4.10.3.1 "Ring Overrun and > Underrun" describes the behavior of xhci when an isochronous ring is > empty due to the late URB submission in driver. (In this patch, empty > isochronous ring can happen due to tasklet scheduling delay in URB > complete function which calls the next usb_submit_urb()) > > According to the xhci spec, xHC deals with a late isochronous URB > according to the SIA(Start Isoch ASAP) flag of TRB and SIA flag is > set according to URB_ISO_ASAP flag in xhci_queue_isoc_tx(). > > If the SIA flag is set, xHC will schedule the late isochronous URB in > the next "Endpoint Service Interval Time" (next available frame) and > transmits ischronous URB in that frame. > > If the SIA flag is cleared (URB_ISO_ASAP flag is cleared), xHC generates > "Missed Service Error" event and skips the late isochronous URB and > doen't transmit it. When the interrupt handler (xhci_irq) receives > "Missed Service Error" event, it returns the late isochronous URB to > the driver calling usb_hcd_giveback_urb() with -EXDEV error code in > usb_iso_packet_descriptor->status at skip_isoc_td(). So xhci behavior > about the late isochronous URB in spec and implementation is same > with the description of usb_submit_urb(). > > In the case of usb_kill_urb(), description says that it waits until > the URB complete function finishes and the important point is that > whether the USB complete function is called early or late doesn't > affect the behavior of usb_kill_urb() because __usb_hcd_giveback_urb() > wakes up usb_kill_urb() after calling URB complete function. > So, pending a URB complete function in tasklet doesn't affect the > behavior of xhci in usb_kill_urb(). Okay, good. I just wanted to make sure you were aware of the issues and had checked that using tasklets wouldn't cause any problems. Alan Stern