Re: [PATCH 2/3] udc: net2280: Fix overrun of OUT messages

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

 



On Mon, 4 Feb 2019, Guido Kiener wrote:

> From: Guido Kiener <guido.kiener@xxxxxxxxxxxxxxxxx>
> 
> The OUT endpoint normally blocks (NAK) subsequent packets when a
> short packet is received and returns an incomplete queue entry to
> the gadget driver. Thereby the gadget driver can detect
> a short packet when reading queue entries with a length that is
> not equal to a multiple of packet size.
> 
> The start_queue() function enables receiving OUT packets regardless
> of the content of the OUT FIFO. This results in a problem:
> When receiving is enabled more OUT packets are appended to the last
> short packet and the gadget driver cannot determine the end of a
> short packet anymore. Furthermore the remaining data in the OUT FIFO
> is not delivered to the gadget driver immediately and can produce
> timeout errors.

How can that happen?  When the short packet is received, the endpoint 
immediately starts sending NAKs, so no more data can enter the FIFO.  
Furthermore, the incomplete transfer is returned to the gadget driver, 
which removes the short packet from the FIFO.  So the FIFO has to be 
empty when start_queue() is called.

Alan Stern

> This fix only stops OUT naking when all FIFO data is delivered
> to the gadget driver and the OUT FIFO is empty.
> 
> Signed-off-by: Guido Kiener <guido.kiener@xxxxxxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/udc/net2280.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
> index 7154f00dea40..1cb58fd5d1c6 100644
> --- a/drivers/usb/gadget/udc/net2280.c
> +++ b/drivers/usb/gadget/udc/net2280.c
> @@ -867,7 +867,7 @@ static void start_queue(struct net2280_ep *ep, u32 dmactl, u32 td_dma)
>  
>  	writel(BIT(DMA_START), &dma->dmastat);
>  
> -	if (!ep->is_in)
> +	if (!ep->is_in && readl(&ep->regs->ep_avail) == 0)
>  		stop_out_naking(ep);
>  }




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux