Patch "usb: dwc2: Do not update data length if it is 0 on inbound transfers" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: dwc2: Do not update data length if it is 0 on inbound transfers

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-dwc2-do-not-update-data-length-if-it-is-0-on-inb.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit fff7e68637eb62e5fbac6b11655adfb102be8e22
Author: Guenter Roeck <linux@xxxxxxxxxxxx>
Date:   Wed Jan 13 12:20:49 2021 +0100

    usb: dwc2: Do not update data length if it is 0 on inbound transfers
    
    [ 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 <nsaenzjulienne@xxxxxxx>
    Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
    Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@xxxxxxx>
    Link: https://lore.kernel.org/r/20210113112052.17063-2-nsaenzjulienne@xxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

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)
 			/*



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux