lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b2ecd22a-63b2-1da7-3ab9-5a3eb423c07a@synopsys.com>
Date:   Mon, 23 Dec 2019 09:10:51 +0000
From:   Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
To:     John Keeping <john@...anate.com>
CC:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-rockchip@...ts.infradead.org" 
        <linux-rockchip@...ts.infradead.org>
Subject: Re: [PATCH 1/2] usb: dwc2: Fix IN FIFO allocation



On 12/19/2019 3:34 PM, John Keeping wrote:
> On chips with fewer FIFOs than endpoints (for example RK3288 which has 9
> endpoints, but only 6 which are cabable of input), the DPTXFSIZN
> registers above the FIFO count may return invalid values.
> 
> With logging added on startup, I see:
> 
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=1 sz=256
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=2 sz=128
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=3 sz=128
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=4 sz=64
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=5 sz=64
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=6 sz=32
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=7 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=8 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=9 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=10 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=11 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=12 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=13 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=14 sz=0
> 	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=15 sz=0
> 
> but:
> 
> 	# cat /sys/kernel/debug/ff580000.usb/fifo
> 	Non-periodic FIFOs:
> 	RXFIFO: Size 275
> 	NPTXFIFO: Size 16, Start 0x00000113
> 
> 	Periodic TXFIFOs:
> 		DPTXFIFO 1: Size 256, Start 0x00000123
> 		DPTXFIFO 2: Size 128, Start 0x00000223
> 		DPTXFIFO 3: Size 128, Start 0x000002a3
> 		DPTXFIFO 4: Size 64, Start 0x00000323
> 		DPTXFIFO 5: Size 64, Start 0x00000363
> 		DPTXFIFO 6: Size 32, Start 0x000003a3
> 		DPTXFIFO 7: Size 0, Start 0x000003e3
> 		DPTXFIFO 8: Size 0, Start 0x000003a3
> 		DPTXFIFO 9: Size 256, Start 0x00000123
> 
> so it seems that FIFO 9 is mirroring FIFO 1.
> 
> Fix the allocation by using the FIFO count instead of the endpoint count
> when selecting a FIFO for an endpoint.
> 
> Signed-off-by: John Keeping <john@...anate.com>
> ---

Acked-by: Minas Harutyunyan <hminas@...opsys.com>

>   drivers/usb/dwc2/gadget.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 92e8de9cb45c..911b950ef25e 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -4059,11 +4059,12 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
>   	 * a unique tx-fifo even if it is non-periodic.
>   	 */
>   	if (dir_in && hsotg->dedicated_fifos) {
> +		unsigned fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
>   		u32 fifo_index = 0;
>   		u32 fifo_size = UINT_MAX;
>   
>   		size = hs_ep->ep.maxpacket * hs_ep->mc;
> -		for (i = 1; i < hsotg->num_of_eps; ++i) {
> +		for (i = 1; i <= fifo_count; ++i) {
>   			if (hsotg->fifo_map & (1 << i))
>   				continue;
>   			val = dwc2_readl(hsotg, DPTXFSIZN(i));
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ