From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96396C2D0DF for ; Wed, 1 Jan 2020 17:23:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79505206E6 for ; Wed, 1 Jan 2020 17:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727321AbgAARWv (ORCPT ); Wed, 1 Jan 2020 12:22:51 -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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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