Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp914638pxb; Wed, 3 Mar 2021 20:53:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhGsE32P7p6vBzaz9IpxkEk+kJw3Ca34Bay63woyGgF/Z4RikCtdH8JaE6IIe2ZVMrfzHO X-Received: by 2002:a17:906:b747:: with SMTP id fx7mr2310781ejb.474.1614833628524; Wed, 03 Mar 2021 20:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614833628; cv=none; d=google.com; s=arc-20160816; b=YHJ2jj9NAD3AgAZQG5FtEHQXveUW9EPaFtz6OU32E3GySOh8e0IQsGPXgbPhGtOJN0 iR3m/stCkphnco/bASNWahWYyFb2TRGkc4MnEb12coQJDHyVu9PP7qCkol55Kcq+Xn06 P8sQBplRbeuuFqd9IJ2a4XgezeyynvFWI1YOi35aV8rs83cg13wXMfmxbhVWDFxx3vQ0 BnTQ0fajp/2nlL7ctigHDDTp+ThoLPDOLggqdIa4IUI/h6Li6gFpIEttrT6nGUm4sTg+ C5e/IZ4ylx7R0/5cIW0jq/HCZtt3YhK3OL+vM4iicMGOrpNbEVISeJ+/n+Z9Ey14+6MP UZhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i64LulHgd+rz9qGE4p/9lvH+2cr6ydGopZ8upj8reUg=; b=OIBvqlx10tgv+i+0a23TwuO+W6u7CzLGIUmHaF0q0jr6GbAZpgoX8C/0ZwvO4iAXsg viT9+kHsUQkeojHjSiAy09rXwHRIncnJIrsBbnLgosCJ7r5N3R54qB7O4UYlO1mPfVYP 9TDXc7uvs9fpD0krZ4MhIuId9lIdGwvr77RwgrnrIxxGGDArzWizaaPZa1B/kOkYr+nP WjI7g5JqQXf1LrYVIVT8HY8uoEfyeUXnty24SYnPIVEEznN37RfycdZFxZLNaMzcMcfD ycl0a0kUtk55hAFXTviCK/hfLbpe294pZ7NkTR+ei5aydlKa1RuxnUuGfbIUN0agzI47 1cuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Hgtc/MLJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr15si13517289ejb.275.2021.03.03.20.53.26; Wed, 03 Mar 2021 20:53:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Hgtc/MLJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442482AbhCBCNt (ORCPT + 99 others); Mon, 1 Mar 2021 21:13:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:53652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238933AbhCATki (ORCPT ); Mon, 1 Mar 2021 14:40:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D79364F78; Mon, 1 Mar 2021 17:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618392; bh=hOj6PA14MgtAAOUvgJ31EdxYQHfBjZK2vHdy+2EvO/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hgtc/MLJQ43dqtAMXdKO6QYTqQQdT+YE2VdEtHZfavGB2n6U+DTJEx8G5LfkVH1bX r/S5hcTdnNLgG8epD6pMBTR9WvmCSgH39JbEgx+5RjcIlUJGPB38o5/4QjMtjPUk6e b8fqZwlD6nM8YZ6jALvRDRHYY8D1hcFKallTjKJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Douglas Anderson , Guenter Roeck , Sasha Levin Subject: [PATCH 5.10 063/663] usb: dwc2: Do not update data length if it is 0 on inbound transfers Date: Mon, 1 Mar 2021 17:05:11 +0100 Message-Id: <20210301161144.854117241@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guenter Roeck [ Upstream commit 415fa1c7305dedbb345e2cc8ac91769bc1c83f1a ] The DWC2 documentation states that transfers with zero data length should set the number of packets to 1 and the transfer length to 0. This is not currently the case for inbound transfers: the transfer length is set to the maximum packet length. This can have adverse effects if the chip actually does transfer data as it is programmed to do. Follow chip documentation and keep the transfer length set to 0 in that situation. Fixes: 56f5b1cff22a1 ("staging: Core files for the DWC2 driver") Tested-by: Nicolas Saenz Julienne Reviewed-by: Douglas Anderson Signed-off-by: Guenter Roeck Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20210113112052.17063-2-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc2/hcd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index e9ac215b96633..fc3269f5faf19 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -1313,19 +1313,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, if (num_packets > max_hc_pkt_count) { num_packets = max_hc_pkt_count; chan->xfer_len = num_packets * chan->max_packet; + } else if (chan->ep_is_in) { + /* + * Always program an integral # of max packets + * for IN transfers. + * Note: This assumes that the input buffer is + * aligned and sized accordingly. + */ + chan->xfer_len = num_packets * chan->max_packet; } } else { /* Need 1 packet for transfer length of 0 */ num_packets = 1; } - if (chan->ep_is_in) - /* - * Always program an integral # of max packets for IN - * transfers - */ - chan->xfer_len = num_packets * chan->max_packet; - if (chan->ep_type == USB_ENDPOINT_XFER_INT || chan->ep_type == USB_ENDPOINT_XFER_ISOC) /* -- 2.27.0