Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16621462ybl; Wed, 1 Jan 2020 09:27:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzRbq+1Fxg99J7sU35g+8P9+LHV+uAPk/zkg9Dt4ftjTZsa7QBNAuLx98Tuts413bnBZYBe X-Received: by 2002:a9d:674f:: with SMTP id w15mr89179153otm.243.1577899621781; Wed, 01 Jan 2020 09:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577899621; cv=none; d=google.com; s=arc-20160816; b=PKzV65orAfCOGWAmzMKXXviBH5Mpb0DzFt3e0JMmgT8rEXlTvidqkPswcKX1sv1TdR klBl1pvk5x9B8jPzjBwBT/15v1zQEySFjrS3ZOf4yqO7Tlmg7Ok0vssa8FV+zpiNeRV3 WGvpmqMaWh76xrSDGCys24Gh7lfGCqmP3f/kt9QOlfGS/hcrvVxB/6Bjy+6Jzdr7MK6T 3xutlzIyLN4ORhYpqM2E/3PuF71O/e1mnK60JY1Hc1xYLNY6UmEZ/fTRqqjow1NHY6qZ WD6EvXpACsoTaP7zEbAQlk1TJ4IWbL5tDHKcEOI4zv/3XEWThp1TSV9IQZbeQo26X6TK 6B4Q== 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:message-id:date :subject:cc:to:from; bh=ib7Pd2PHRMlDdRr4XFniDcuW+IDvHV4zUbd6Vgm+kSI=; b=jJ47nnZptooS9HqsWKLFb09/uObDRO0bMx4VIaC4uFYFJtF4PhsPe/TXUIE4Ki89TD 5QmF/FXpXmePnZOPXv/d/FoFj7cicU+KNAg1YfIzASqOKjBbk8I9+sEI+Lag6U54q0p3 LXegbOYHPhXXJQ6ARXtPsJrt8fOZ7DgbofKhomgtYMIblQt3FyBdf+YiImDUrZQfUUg4 10IEGzy2u5nNmIuVei0gnnNHmfJWFdxYSwHJU1NvfMEtXGYNM98X8zOrVlV62PjTWcgS GfAxQ3REvhvFD0TcPgCUMLDgy+E/keDBeFUSLoLXO0Bn1fBmZyRE58+xXRUuad57AObq 7vGQ== 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 p5si26469549otg.230.2020.01.01.09.26.49; Wed, 01 Jan 2020 09:27:01 -0800 (PST) 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 S1727326AbgAARWw (ORCPT + 99 others); Wed, 1 Jan 2020 12:22:52 -0500 Received: from lnfm1.sai.msu.ru ([93.180.26.255]:35309 "EHLO lnfm1.sai.msu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727311AbgAARWt (ORCPT ); Wed, 1 Jan 2020 12:22:49 -0500 X-Greylist: delayed 3350 seconds by postgrey-1.27 at vger.kernel.org; Wed, 01 Jan 2020 12:22:39 EST 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 001GQHHw001778; Wed, 1 Jan 2020 19:26:22 +0300 Received: from oak.local (unknown [188.123.231.178]) (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 4ED412CBEE; Wed, 1 Jan 2020 19:26:19 +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 RESEND v2 0/6] musb: Improve performance for hub-attached webcams Date: Wed, 1 Jan 2020 19:26:04 +0300 Message-Id: <20200101162610.15819-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> 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