usb: cdns3: allocate TX FIFO size according to composite EP number
authorFrank Li <Frank.Li@nxp.com>
Mon, 9 May 2022 16:40:55 +0000 (11:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 May 2022 16:14:29 +0000 (18:14 +0200)
commitdce49449e04ff150838a31386ee65917beb9ebb5
tree5b55a57f555eb07593c48bd771755b506036ee10
parent9d778f0c5f95ca5aa2ff628ea281978697e8d89b
usb: cdns3: allocate TX FIFO size according to composite EP number

Some devices have USB compositions which may require multiple endpoints.
To get better performance, need bigger CDNS3_EP_BUF_SIZE.

But bigger CDNS3_EP_BUF_SIZE may exceed total hardware FIFO size when
multiple endpoints.

By introducing the check_config() callback, calculate CDNS3_EP_BUF_SIZE.

Move CDNS3_EP_BUF_SIZE into cnds3_device: ep_buf_size
Combine CDNS3_EP_ISO_SS_BURST and CDNS3_EP_ISO_HS_MULT into
cnds3_device:ep_iso_burst

Using a simple algorithm to calculate ep_buf_size.
ep_buf_size = ep_iso_burst = (onchip_buffers - 2k) / (number of IN EP +
1).

Test at 8qxp:

Gadget ep_buf_size

RNDIS: 5
RNDIS+ACM: 3
Mass Storage + NCM + ACM 2

Previous CDNS3_EP_BUF_SIZE is 4, RNDIS + ACM will be failure because
exceed FIFO memory.

Acked-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20220509164055.1815081-1-Frank.Li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/cdns3/cdns3-gadget.c
drivers/usb/cdns3/cdns3-gadget.h