Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3520818pxb; Mon, 1 Mar 2021 12:09:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7qYHggZ2HeNu2A2d41URiD4iwrfx68X/hF3K0cEzYV2q4dsOZvjp+nMLMMhfAWxxzJcva X-Received: by 2002:a17:906:c181:: with SMTP id g1mr17090127ejz.96.1614629378820; Mon, 01 Mar 2021 12:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614629378; cv=none; d=google.com; s=arc-20160816; b=HexfapL3uePyFJ2mk8R/fWZJD52/MIfI8uESHBSWrFlPtY4W7C3p3wVBo3MKE7y9m/ DNCd10tP92A0dAiAYDr+QgTMpmu8mNXrOEZOyrGaXp0/5MJPH9dX0AbboAlCdkChBOF5 NsU5auvlE0Kh1awC9umL+CQ20vSdwqkTmNJut+p9llGbsIzPJVdqdF1QoQptc31KfUMa N7Pf3LKktj7wTN1VF1NnMX2OZ0MLF8sYWUFa6A/juB330zK010EUdonxVWzC9dlogq01 UW/rqt9QU8w11lfZ72QEWzT4htbfFgkF6kCYyBIL+vm2Q32ivte6DCBgvpkkLESuTMtX u9OA== 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=ZLiAa8foYb8bVxuI8HP1SMyFUb8jz+EGXribEDQbZJo=; b=Z2EjSaMHrA+A/73F5QSboTIvtNKZikentWKxTj4OwLPZ0yAPKC3PoEGB9+2ruBR1FX W+BlOzgBkMa0FyZ+IRoacpm0HPJiTIMN5aAJqCIOyBNUHqQbHzcBkKJIjrvwwh25/2zE QRTRmxEKW/HIQ0XNAmNKrQSq+GJA6l8NynGH9qpQn2QD7W3JpxzCGB6M75a2R70mk/hb zbu9hWVjwBWGUnABagdUoo1gu53UJ6+63p/kwj9kesSbiD/X83d4OCrcWy135gRevBz5 xmRajIY8BZCyhFu8kCLtYipLBoL+U+BD766hJ0ZOd4hMje0zcvo+9xIDXRPZQcyHdyTk YG7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="h/8kq7Fi"; 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 x9si12298013ejc.196.2021.03.01.12.09.15; Mon, 01 Mar 2021 12:09:38 -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="h/8kq7Fi"; 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 S241524AbhCAUGB (ORCPT + 99 others); Mon, 1 Mar 2021 15:06:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:59056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236171AbhCAQ7I (ORCPT ); Mon, 1 Mar 2021 11:59:08 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD9D064F6E; Mon, 1 Mar 2021 16:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616649; bh=oRub4xv8W0NZ8tF5cce6iXtDLegYB2MBSzu+W8EFiVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/8kq7FigFKU/8/n30l30i8aRYpN6z0Kw5rLGXtEAowDKh676PivuvvTJbIwU5gvL D2NF018zDakIdkQ5ajWn2WC3vLq1g31Ls3cS+EmNI6irI4dZQQkpB7Bp7xQE0MhnFO aPZ1jUXzFA9bJW6Hj9WKk6bGtsG9sQmGTd3yWnQ0= 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 4.19 047/247] usb: dwc2: Do not update data length if it is 0 on inbound transfers Date: Mon, 1 Mar 2021 17:11:07 +0100 Message-Id: <20210301161033.979931976@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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 a5c8329fd4625..56a35e0160392 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -1512,19 +1512,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