Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1187542ybf; Thu, 27 Feb 2020 06:31:36 -0800 (PST) X-Google-Smtp-Source: APXvYqw8LqhRDgkwAMA/5riidiTOvL3ADhGa5xpeLZ5TfW6NUmxS/Yjnjqyr1MV9giEEuuplttPr X-Received: by 2002:a9d:6e15:: with SMTP id e21mr3511610otr.289.1582813896721; Thu, 27 Feb 2020 06:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582813896; cv=none; d=google.com; s=arc-20160816; b=fmdPNFPSiKMAQkI9Ci78+OdzWYkL2qSLRW29/3KapuwWbcFGRMD6reekP7onMLeSfz vCV0CG9KftVQlqPfDkkYV986lwnMbLLzApEXveuoVztbV3RAZnedu3w5FYyXae5ucb2q BFIZN/lUCq0Z9QFIMJ+Dh69ndRSSg3g4NeTmRwFxTYVXOixllvUIuduejPg3ihuidHyC ztmBxvxCTKrtJicBn6rL8GVp7qUTS87ej8IhpUF1snKfBONxnujI8ibLu3GRbRypjen8 UBNzd7tY7uVQIH0x884S/kjlGaBD7HdZdKAlkMRdfkGyfeQHsPoAwqPfanal5l3mzPd9 ipDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x0zxBcIyllvptvVUdCdKO/Pzzw1yLKp4Atw2brp3T70=; b=PrRkDgOYOp4obJBN6oqMqtQQ7zLd+JN2BoC75FkMpAJg4vJOjMDnDnwrJdvdcznOFF AYg4zy4S/mvC+Krvhnn3hXC1jn8h1K8SvAlTnzrRi5Rs2waIL/SKqir75Kw0ubQFSnJX m30eaYgnDdwcx62q8lnfgsW+E9QHgnWw8MKVSZYz5wETshlPH4ao61NcAv8H8D2KEqmi 5xco8nRN8zIA+6CDUIn1TTYlsDQVYCNZjjsN5Y1qie2j5ISTuntVAIMU40osivbiwjOh 2pysA7MjrOyZ/1vYvCRL5KAGO6xAQyJvDJmIKcKroFu7hDm5CXIwFmvfJpg5dMu3HS/m 7wCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N4lr0BJE; 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 u13si1655696otg.56.2020.02.27.06.31.24; Thu, 27 Feb 2020 06:31:36 -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; dkim=pass header.i=@kernel.org header.s=default header.b=N4lr0BJE; 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 S2388257AbgB0OaW (ORCPT + 99 others); Thu, 27 Feb 2020 09:30:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:41820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387713AbgB0OFM (ORCPT ); Thu, 27 Feb 2020 09:05:12 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 25EFD20801; Thu, 27 Feb 2020 14:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812311; bh=IAbXsdKThfWp5kflFnf+H5CpkjsYJ220+iv2NJURT2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4lr0BJE9XiJlvkta5RjsVc3KQLKxa9uCM3AR8euAavaAYt5LGONU5Q8toyRODWw1 5q+P03hHX+1yOm/FLhBpHfdtU271PO90M+BLsIIssPHCtRK/88lrk1mR0dOsafMEit 33DnhhgcI48Q8Z7VgJ2K1D1hdx98cHTEJrK6srUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rene D Obermueller , Mathias Nyman Subject: [PATCH 4.19 19/97] xhci: Force Maximum Packet size for Full-speed bulk devices to valid range. Date: Thu, 27 Feb 2020 14:36:27 +0100 Message-Id: <20200227132217.754364763@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132214.553656188@linuxfoundation.org> References: <20200227132214.553656188@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman commit f148b9f402ef002b57bcff3964d45abc8ffb6c3f upstream. A Full-speed bulk USB audio device (DJ-Tech CTRL) with a invalid Maximum Packet Size of 4 causes a xHC "Parameter Error" at enumeration. This is because valid Maximum packet sizes for Full-speed bulk endpoints are 8, 16, 32 and 64 bytes. Hosts are not required to support other values than these. See usb 2 specs section 5.8.3 for details. The device starts working after forcing the maximum packet size to 8. This is most likely the case with other devices as well, so force the maximum packet size to a valid range. Cc: stable@vger.kernel.org Reported-by: Rene D Obermueller Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200210134553.9144-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-mem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1475,9 +1475,15 @@ int xhci_endpoint_init(struct xhci_hcd * /* Allow 3 retries for everything but isoc, set CErr = 3 */ if (!usb_endpoint_xfer_isoc(&ep->desc)) err_count = 3; - /* Some devices get this wrong */ - if (usb_endpoint_xfer_bulk(&ep->desc) && udev->speed == USB_SPEED_HIGH) - max_packet = 512; + /* HS bulk max packet should be 512, FS bulk supports 8, 16, 32 or 64 */ + if (usb_endpoint_xfer_bulk(&ep->desc)) { + if (udev->speed == USB_SPEED_HIGH) + max_packet = 512; + if (udev->speed == USB_SPEED_FULL) { + max_packet = rounddown_pow_of_two(max_packet); + max_packet = clamp_val(max_packet, 8, 64); + } + } /* xHCI 1.0 and 1.1 indicates that ctrl ep avg TRB Length should be 8 */ if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version >= 0x100) avg_trb_len = 8;