Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1206446ybi; Fri, 14 Jun 2019 10:23:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAoiXKrkQgIRKZa45ikWfygEhbmqZenKJMyFQqqJVronT2iTGe05cFWbz6cnefextVzHHe X-Received: by 2002:a62:5486:: with SMTP id i128mr99880457pfb.156.1560533036967; Fri, 14 Jun 2019 10:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533036; cv=none; d=google.com; s=arc-20160816; b=dvY2UMQGi7C44J8hEXctQDsISnsu8pyQ98eA+RGFYmuE75LMzmJgmarFq2sMKXYdHn fx+7p/f/70asH35QjLfkus4Pgqmzp3vghCOJ82FI0yFnLUk07+x40iblS5MEcYM6NRDc 7hMA2w0moBoLhsW1fd20NJhPd3BbJDgLnjExHC/ELkR9VUAxgqkel/7W8CNMoC5KrPIN H/eyHBN1tErLdH+jY1wWuz7yg41cCMlm5ir7rudeDvgOzl4I1s7QCaQnTE3YPqeWmBqE KBZMksScWjJrJsLNabx2tuY35kKgJ8zktnjIa4J3LPQsHk9p58IiAGniKkwonQmQroIh qdRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=ib7Pd2PHRMlDdRr4XFniDcuW+IDvHV4zUbd6Vgm+kSI=; b=N82VqcwvPjG/4ER+Yc7fQCd8z0Uf5FOgEEYyCOM1rsLc+cfL1FZMtCg2XbB6iltoo0 1OGEa5fImeK0JeE2EJWhUEBAZ/RByvVt2mmIAjHFp7N7n8VpMcypOWyfyzPmLbb4grMx eP2gN9ZJ528x3o9YW4wZaFfninqvbvTutBmR12k2ffRVbjidUsy+LiyNkRzFN3kGPSHe H7QgLcRcjZlns0T3sHjxRnOf4s+K+qFjZnZlLlP84wnIXX4gmYFPCm+TcltmN9tn7Xly pfjMf/0xS62wgczHm8KPpwaWfzb0JxK8N06upSnfI5HeflwriVKx6lo8EhNDGDHmPNwo b0LA== 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 v78si1289982pgb.187.2019.06.14.10.23.42; Fri, 14 Jun 2019 10:23:56 -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 S1726596AbfFNRXX (ORCPT + 99 others); Fri, 14 Jun 2019 13:23:23 -0400 Received: from lnfm1.sai.msu.ru ([93.180.26.255]:50801 "EHLO lnfm1.sai.msu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfFNRXU (ORCPT ); Fri, 14 Jun 2019 13:23:20 -0400 X-Greylist: delayed 2129 seconds by postgrey-1.27 at vger.kernel.org; Fri, 14 Jun 2019 13:23:05 EDT Received: from dragon.sai.msu.ru (dragon.sai.msu.ru [93.180.26.172]) by lnfm1.sai.msu.ru (8.14.1/8.12.8) with ESMTP id x5EGl5kL020143; Fri, 14 Jun 2019 19:47:10 +0300 Received: from oak.local (unknown [92.243.181.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by dragon.sai.msu.ru (Postfix) with ESMTPSA id 9152ABCE4; Fri, 14 Jun 2019 19:46:58 +0300 (MSK) From: "Matwey V. Kornilov" To: b-liu@ti.com, gregkh@linuxfoundation.org, stern@rowland.harvard.edu Cc: matwey.kornilov@gmail.com, "Matwey V. Kornilov" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/6] musb: Improve performance for hub-attached webcams Date: Fri, 14 Jun 2019 19:45:48 +0300 Message-Id: <20190614164554.27679-1-matwey@sai.msu.ru> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190403185310.8437-1-matwey@sai.msu.ru> References: <20190403185310.8437-1-matwey@sai.msu.ru> In-Reply-To: <20190403185310.8437-1-matwey@sai.msu.ru> References: <20190403185310.8437-1-matwey@sai.msu.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The series is concerned to issues with isochronous transfer while streaming the USB webcam data. I discovered the issue first time when attached PWC USB webcam to AM335x-based BeagleBone Black SBC. It appeared that the root issue was in numerous missed IN requests during isochronous transfer where each missing leaded to the frame drop. Since every IN request is triggered in MUSB driver individually, it is important to queue the send IN request as earlier as possible when the previous IN completed. At the same time the URB giveback handler of the device driver has also to be called there, that leads to arbitrarily delay depending on the device driver performance. The details with the references are described in [1]. The issue has two parts: 1) peripheral driver URB callback performance 2) MUSB host driver performance It appeared that the first part is related to the wrong memory allocation strategy in the most USB webcam drivers. Non-cached memory is used in assumption that coherent DMA memory leads to the better performance than non-coherent memory in conjunction with the proper synchronization. Yet the assumption might be valid for x86 platforms some time ago, the issue was fixed for PWC driver in: 1161db6776bd ("media: usb: pwc: Don't use coherent DMA buffers for ISO transfer") that leads to 3.5x performance gain. The more generic fix for this common issue are coming for the rest drivers [2]. The patch allowed successfully running full-speed USB PWC webcams attached directly to BeagleBone Black USB port. However, the second part of the issue is still present for peripheral device attached through the high-speed USB hub due to its 125us frame time. The patch series is intended to reorganize musb_advance_schedule() to allow host to send IN request quicker. The patch series is organized as the following. First three patches improve readability of the existing code in musb_advance_schedule(). Patches 4 and 5 introduce updated signature for musb_start_urb(). The last patch introduce new code-path in musb_advance_schedule() which allows for faster response. References: [1] https://www.spinics.net/lists/linux-usb/msg165735.html [2] https://www.spinics.net/lists/linux-media/msg144279.html Changes since v1: - Patch 6 was redone to keep URB giveback order and stop transmission at erroneous URB. Matwey V. Kornilov (6): usb: musb: Use USB_DIR_IN when calling musb_advance_schedule() usb: musb: Introduce musb_qh_empty() helper function usb: musb: Introduce musb_qh_free() helper function usb: musb: Rename musb_start_urb() to musb_start_next_urb() usb: musb: Introduce musb_start_urb() usb: musb: Decrease URB starting latency in musb_advance_schedule() drivers/usb/musb/musb_host.c | 132 ++++++++++++++++++++++++++++--------------- drivers/usb/musb/musb_host.h | 1 + 2 files changed, 86 insertions(+), 47 deletions(-) -- 2.16.4