Re: [PATCH 1/2] usb: dwc3: gadget: update DCFG.NumP to max burst size

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

 



On 4/28/2016 11:05 PM, Felipe Balbi wrote:
> 
> Hi,
> 
> John Youn <John.Youn@xxxxxxxxxxxx> writes:
>> On 4/28/2016 1:01 AM, Felipe Balbi wrote:
>>> NumP field of DCFG register is used on NumP field of
>>> ACK TP header and it tells the host how many packets
>>> an endpoint can receive before waiting for
>>> synchronization.
>>>
>>> Documentation says it should be set to anything
>>> <=bMaxBurst. Interestingly, however, this setting is
>>> not per-endpoint how it should be (different
>>> endpoints could have different burst sizes), but
>>> things seem to work okay right now.
>>>
>>> Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
>>> ---
>>>  drivers/usb/dwc3/core.h   |  3 +++
>>>  drivers/usb/dwc3/gadget.c | 14 ++++++++++++--
>>>  2 files changed, 15 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
>>> index 87df6dd20d23..c5f576aa1903 100644
>>> --- a/drivers/usb/dwc3/core.h
>>> +++ b/drivers/usb/dwc3/core.h
>>> @@ -271,6 +271,9 @@
>>>  #define DWC3_DCFG_LOWSPEED	(2 << 0)
>>>  #define DWC3_DCFG_FULLSPEED1	(3 << 0)
>>>  
>>> +#define DWC3_DCFG_NUMP_SHIFT	17
>>> +#define DWC3_DCFG_NUMP(n)	(((n) & 0x1f) >> DWC3_DCFG_NUMP_SHIFT)
>>> +#define DWC3_DCFG_NUMP_MASK	(0x1f << DWC3_DCFG_NUMP_SHIFT)
>>>  #define DWC3_DCFG_LPM_CAP	(1 << 22)
>>>  
>>>  /* Device Control Register */
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>> index 43efb627d1cf..4b681b0d420f 100644
>>> --- a/drivers/usb/dwc3/gadget.c
>>> +++ b/drivers/usb/dwc3/gadget.c
>>> @@ -464,9 +464,19 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
>>>  
>>>  	/* Burst size is only needed in SuperSpeed mode */
>>>  	if (dwc->gadget.speed >= USB_SPEED_SUPER) {
>>> -		u32 burst = dep->endpoint.maxburst - 1;
>>> +		u32 burst = dep->endpoint.maxburst;
>>> +		u32 nump;
>>> +		u32 reg;
>>>  
>>> -		params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst);
>>> +		/* update NumP */
>>> +		reg = dwc3_readl(dwc->regs, DWC3_DCFG);
>>> +		nump = DWC3_DCFG_NUMP(reg);
>>> +		nump = max(nump, burst);
>>> +		reg &= ~DWC3_DCFG_NUMP_MASK;
>>> +		reg |= nump << DWC3_DCFG_NUMP_SHIFT;
>>> +		dwc3_writel(dwc->regs, DWC3_DCFG, reg);
>>> +
>>> +		params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst - 1);
>>
>> Hi Felipe,
>>
>> The controller already takes care not to send a NUMP greater than the
>> configured maxburst for the endpoint. So there is no need to do
>> this. You can just set it globally in core init.
> 
> iow, we just set this to the maximum value and forget about it ? That

You can do that and it will always work, but it might not be optimal
for every system. You may want to tweak this value in that case, or
set it to calculate based on the rx fifo space.

> doesn't appear to be documented. We can patch this up for v4.8, then
> since $subject has no negative side-effect and Greg has already merged
> this to his tree :-)
> 

Sure.

Regards,
John
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

  Powered by Linux