All of lore.kernel.org
 help / color / mirror / Atom feed
* usb: cdns3: Onchip memory reservation for built-in gadgets
@ 2023-06-27 10:26 Ravi Gunasekaran
  2023-06-27 10:41 ` Roger Quadros
  0 siblings, 1 reply; 5+ messages in thread
From: Ravi Gunasekaran @ 2023-06-27 10:26 UTC (permalink / raw)
  To: Frank.Li; +Cc: linux-usb, peter.chen, pawell, rogerq

Hi,

Firstly, I'm not sure if it is alright to post queries this way. 
If it is wrong, I apologize for it. Please let me know the right path/forum to ask the questions.

This is regarding the commit
dce49449e04f usb: cdns3: allocate TX FIFO size according to composite EP number

This commit introduced cdns3_gadget_check_config() which is invoked while binding gadget created via configfs and
also a logic to calculate ep_buf_size (which was CDNS3_EP_BUF_SIZE = 4).

But for gadgets such as g_ether, g_cdc, the checks are not performed. And also for these legacy gadget drivers,
memory needs to be reserved for multiple IN end points and shared memory for OUT end points. So when ep_buf_size = 15,
the memory reservation fails, as it exceeds total onchip memory.

So I was wondering if additional checks need to done in the cadence gadget driver or am I doing something wrong while
loading gadgets such as g_ether. 

-- 
Regards,
Ravi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: usb: cdns3: Onchip memory reservation for built-in gadgets
  2023-06-27 10:26 usb: cdns3: Onchip memory reservation for built-in gadgets Ravi Gunasekaran
@ 2023-06-27 10:41 ` Roger Quadros
  2023-06-27 14:56   ` [EXT] " Frank Li
  0 siblings, 1 reply; 5+ messages in thread
From: Roger Quadros @ 2023-06-27 10:41 UTC (permalink / raw)
  To: Ravi Gunasekaran, Frank.Li; +Cc: linux-usb, peter.chen, pawell

Hi,

On 27/06/2023 15:56, Ravi Gunasekaran wrote:
> Hi,
> 
> Firstly, I'm not sure if it is alright to post queries this way. 
> If it is wrong, I apologize for it. Please let me know the right path/forum to ask the questions.
> 
> This is regarding the commit
> dce49449e04f usb: cdns3: allocate TX FIFO size according to composite EP number
> 
> This commit introduced cdns3_gadget_check_config() which is invoked while binding gadget created via configfs and
> also a logic to calculate ep_buf_size (which was CDNS3_EP_BUF_SIZE = 4).
> 
> But for gadgets such as g_ether, g_cdc, the checks are not performed. And also for these legacy gadget drivers,
> memory needs to be reserved for multiple IN end points and shared memory for OUT end points. So when ep_buf_size = 15,
> the memory reservation fails, as it exceeds total onchip memory.
> 
> So I was wondering if additional checks need to done in the cadence gadget driver or am I doing something wrong while
> loading gadgets such as g_ether. 
> 

I think Ravi's concern is that.

prior to commit dce49449e04f, priv_dev->ep_buf_size was fixed at 4.
After commit dce49449e04f, it is at 0 if check_config() is not called e.g.
in the legacy gadget cases (e.g. g_ether).
So cdns3_ep_config() fails with dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n").

A potential fix might be to start with priv_dev->ep_buf_size = 4
instead of 0 so it works for legacy gadgets as well where check_config() is not invoked.

-- 
cheers,
-roger

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [EXT] Re: usb: cdns3: Onchip memory reservation for built-in gadgets
  2023-06-27 10:41 ` Roger Quadros
@ 2023-06-27 14:56   ` Frank Li
  2023-06-28 13:45     ` Roger Quadros
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2023-06-27 14:56 UTC (permalink / raw)
  To: Roger Quadros, Ravi Gunasekaran; +Cc: linux-usb, peter.chen, pawell



> -----Original Message-----
> From: Roger Quadros <rogerq@kernel.org>
> Sent: Tuesday, June 27, 2023 5:41 AM
> To: Ravi Gunasekaran <r-gunasekaran@ti.com>; Frank Li <frank.li@nxp.com>
> Cc: linux-usb@vger.kernel.org; peter.chen@kernel.org;
> pawell@cadence.com
> Subject: [EXT] Re: usb: cdns3: Onchip memory reservation for built-in
> gadgets
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
> 
> 
> Hi,
> 
> On 27/06/2023 15:56, Ravi Gunasekaran wrote:
> > Hi,
> >
> > Firstly, I'm not sure if it is alright to post queries this way.
> > If it is wrong, I apologize for it. Please let me know the right path/forum to
> ask the questions.
> >
> > This is regarding the commit
> > dce49449e04f usb: cdns3: allocate TX FIFO size according to composite EP
> number
> >
> > This commit introduced cdns3_gadget_check_config() which is invoked
> while binding gadget created via configfs and
> > also a logic to calculate ep_buf_size (which was CDNS3_EP_BUF_SIZE = 4).
> >
> > But for gadgets such as g_ether, g_cdc, the checks are not performed. And
> also for these legacy gadget drivers,
> > memory needs to be reserved for multiple IN end points and shared
> memory for OUT end points. So when ep_buf_size = 15,
> > the memory reservation fails, as it exceeds total onchip memory.
> >
> > So I was wondering if additional checks need to done in the cadence gadget
> driver or am I doing something wrong while
> > loading gadgets such as g_ether.
> >
> 
> I think Ravi's concern is that.
> 
> prior to commit dce49449e04f, priv_dev->ep_buf_size was fixed at 4.
> After commit dce49449e04f, it is at 0 if check_config() is not called e.g.
> in the legacy gadget cases (e.g. g_ether).
> So cdns3_ep_config() fails with dev_err(priv_dev->dev, "onchip mem is full,
> ep is invalid\n").
> 
> A potential fix might be to start with priv_dev->ep_buf_size = 4
> instead of 0 so it works for legacy gadgets as well where check_config() is not
> invoked.

I think it should fix at legacy driver by call usb_gadget_check_config. 
Assume there are a UDC controller, which only 2 endpoint.  g_cdc should
get failure.

Best regards
Frank Li

> 
> --
> cheers,
> -roger

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [EXT] Re: usb: cdns3: Onchip memory reservation for built-in gadgets
  2023-06-27 14:56   ` [EXT] " Frank Li
@ 2023-06-28 13:45     ` Roger Quadros
  2023-06-28 15:02       ` Frank Li
  0 siblings, 1 reply; 5+ messages in thread
From: Roger Quadros @ 2023-06-28 13:45 UTC (permalink / raw)
  To: Frank Li, Ravi Gunasekaran
  Cc: linux-usb, peter.chen, pawell, Alan Stern, gregkh

On 27/06/2023 20:26, Frank Li wrote:
> 
> 
>> -----Original Message-----
>> From: Roger Quadros <rogerq@kernel.org>
>> Sent: Tuesday, June 27, 2023 5:41 AM
>> To: Ravi Gunasekaran <r-gunasekaran@ti.com>; Frank Li <frank.li@nxp.com>
>> Cc: linux-usb@vger.kernel.org; peter.chen@kernel.org;
>> pawell@cadence.com
>> Subject: [EXT] Re: usb: cdns3: Onchip memory reservation for built-in
>> gadgets
>>
>> Caution: This is an external email. Please take care when clicking links or
>> opening attachments. When in doubt, report the message using the 'Report
>> this email' button
>>
>>
>> Hi,
>>
>> On 27/06/2023 15:56, Ravi Gunasekaran wrote:
>>> Hi,
>>>
>>> Firstly, I'm not sure if it is alright to post queries this way.
>>> If it is wrong, I apologize for it. Please let me know the right path/forum to
>> ask the questions.
>>>
>>> This is regarding the commit
>>> dce49449e04f usb: cdns3: allocate TX FIFO size according to composite EP
>> number
>>>
>>> This commit introduced cdns3_gadget_check_config() which is invoked
>> while binding gadget created via configfs and
>>> also a logic to calculate ep_buf_size (which was CDNS3_EP_BUF_SIZE = 4).
>>>
>>> But for gadgets such as g_ether, g_cdc, the checks are not performed. And
>> also for these legacy gadget drivers,
>>> memory needs to be reserved for multiple IN end points and shared
>> memory for OUT end points. So when ep_buf_size = 15,
>>> the memory reservation fails, as it exceeds total onchip memory.
>>>
>>> So I was wondering if additional checks need to done in the cadence gadget
>> driver or am I doing something wrong while
>>> loading gadgets such as g_ether.
>>>
>>
>> I think Ravi's concern is that.
>>
>> prior to commit dce49449e04f, priv_dev->ep_buf_size was fixed at 4.
>> After commit dce49449e04f, it is at 0 if check_config() is not called e.g.
>> in the legacy gadget cases (e.g. g_ether).
>> So cdns3_ep_config() fails with dev_err(priv_dev->dev, "onchip mem is full,
>> ep is invalid\n").
>>
>> A potential fix might be to start with priv_dev->ep_buf_size = 4
>> instead of 0 so it works for legacy gadgets as well where check_config() is not
>> invoked.
> 
> I think it should fix at legacy driver by call usb_gadget_check_config. 
> Assume there are a UDC controller, which only 2 endpoint.  g_cdc should
> get failure.
> 

commit dce49449e04f has broken legacy gadget drivers for CDNS3 UDC
and that should be fixed first.

No other UDC drivers implement .check_config() yet.

UDC driver should start with a default sane configuration and work even if
usb_gadget_check_config() is not called by gadget driver.

-- 
cheers,
-roger

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [EXT] Re: usb: cdns3: Onchip memory reservation for built-in gadgets
  2023-06-28 13:45     ` Roger Quadros
@ 2023-06-28 15:02       ` Frank Li
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2023-06-28 15:02 UTC (permalink / raw)
  To: Roger Quadros, Ravi Gunasekaran
  Cc: linux-usb, peter.chen, pawell, Alan Stern, gregkh

> >
> > I think it should fix at legacy driver by call usb_gadget_check_config.
> > Assume there are a UDC controller, which only 2 endpoint.  g_cdc should
> > get failure.
> >
> 
> commit dce49449e04f has broken legacy gadget drivers for CDNS3 UDC
> and that should be fixed first.
> 
> No other UDC drivers implement .check_config() yet.

No implement is not explicit correct.  CDNS3 just trigger this problem. 
 
> 
> UDC driver should start with a default sane configuration and work even if
> usb_gadget_check_config() is not called by gadget driver. 

I am preparing a patches add usb_gadget_check_config() in legacy gadget driver.


> 
> --
> cheers,
> -roger

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-28 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 10:26 usb: cdns3: Onchip memory reservation for built-in gadgets Ravi Gunasekaran
2023-06-27 10:41 ` Roger Quadros
2023-06-27 14:56   ` [EXT] " Frank Li
2023-06-28 13:45     ` Roger Quadros
2023-06-28 15:02       ` Frank Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.