Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-09 Thread Peter Chen
On Thu, Feb 09, 2017 at 05:40:50PM +0530, Vivek Gautam wrote:
> On Thu, Feb 9, 2017 at 5:24 PM, Roger Quadros  wrote:
> >
> >
> > On 09/02/17 13:53, Roger Quadros wrote:
> >>
> >>
> >> On 08/02/17 22:43, Jack Pham wrote:
> >>> Hi Peter, Sriram, Arnd,
> >>>
> >>> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
>  From: Arnd Bergmann 
> 
>  For xhci-hcd platform device, all the DMA parameters are not
>  configured properly, notably dma ops for dwc3 devices. So, set
>  the dma for xhci from sysdev. sysdev is pointing to device that
>  is known to the system firmware or hardware.
> 
>  Signed-off-by: Arnd Bergmann 
>  Signed-off-by: Sriram Dash 
>  Tested-by: Baolin Wang 
>  Tested-by: Vivek Gautam 
>  Tested-by: Alexander Sverdlin 
>  Signed-off-by: Mathias Nyman 
>  ---
>  diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>  index 6d33b42..7a9c860 100644
>  --- a/drivers/usb/host/xhci-plat.c
>  +++ b/drivers/usb/host/xhci-plat.c
> >>>
>  -   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
>  +   hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>  +  dev_name(&pdev->dev), NULL);
> >>>
> >>> As mentioned already in [1], usb_create_shared_hcd() is called to create
> >>> the second bus, however it also needs to be converted.
> >>>
> >>> Not exactly as Roger's suggestion but this worked for me:
> >>>
> >>> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
> >>> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
> >>> dev_name(&pdev->dev), hcd);
> >>
> >> But we're creating a shared_hcd and there is an API for that so why not 
> >> use it
> >> instead of calling __usb_create_hcd()?
> >>
> >
> > Just realized after I pressed send that there is no sysdev parameter
> > for create_shared_hcd().

Roger, does this change also work for you? If it is, please add a
tested-by tag for my v13 patch set.

-- 

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


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-09 Thread Vivek Gautam
On Thu, Feb 9, 2017 at 5:24 PM, Roger Quadros  wrote:
>
>
> On 09/02/17 13:53, Roger Quadros wrote:
>>
>>
>> On 08/02/17 22:43, Jack Pham wrote:
>>> Hi Peter, Sriram, Arnd,
>>>
>>> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
 From: Arnd Bergmann 

 For xhci-hcd platform device, all the DMA parameters are not
 configured properly, notably dma ops for dwc3 devices. So, set
 the dma for xhci from sysdev. sysdev is pointing to device that
 is known to the system firmware or hardware.

 Signed-off-by: Arnd Bergmann 
 Signed-off-by: Sriram Dash 
 Tested-by: Baolin Wang 
 Tested-by: Vivek Gautam 
 Tested-by: Alexander Sverdlin 
 Signed-off-by: Mathias Nyman 
 ---
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 6d33b42..7a9c860 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
>>>
 -   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
 +   hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
 +  dev_name(&pdev->dev), NULL);
>>>
>>> As mentioned already in [1], usb_create_shared_hcd() is called to create
>>> the second bus, however it also needs to be converted.
>>>
>>> Not exactly as Roger's suggestion but this worked for me:
>>>
>>> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
>>> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>>> dev_name(&pdev->dev), hcd);
>>
>> But we're creating a shared_hcd and there is an API for that so why not use 
>> it
>> instead of calling __usb_create_hcd()?
>>
>
> Just realized after I pressed send that there is no sysdev parameter
> for create_shared_hcd().

That's right. The create_shared_hcd() makes use of only pdev->dev,
and we need to configure dma for shared_hcd as well though sysdev.

Sorry my mail client didn't show this mail in time. Please ignore my
earlier comment.

>
>>> if (!xhci->shared_hcd) {
>>> ret = -ENOMEM;
>>>
>>> Without this, SuperSpeed devices fail to enumerate:
>>>
>>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>>  usb 2-1: device descriptor read/8, error -11
>>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>>  usb 2-1: device descriptor read/8, error -11
>>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>>  usb 2-1: device descriptor read/8, error -11
>>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>>  usb 2-1: device descriptor read/8, error -11
>>>  
>>>
>>> Thanks,
>>> Jack
>>>
>>> [1] https://lkml.org/lkml/2016/12/9/240
>>>
>>
>
> --
> cheers,
> -roger
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-09 Thread Vivek Gautam
On Thu, Feb 9, 2017 at 5:23 PM, Roger Quadros  wrote:
>
>
> On 08/02/17 22:43, Jack Pham wrote:
>> Hi Peter, Sriram, Arnd,
>>
>> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
>>> From: Arnd Bergmann 
>>>
>>> For xhci-hcd platform device, all the DMA parameters are not
>>> configured properly, notably dma ops for dwc3 devices. So, set
>>> the dma for xhci from sysdev. sysdev is pointing to device that
>>> is known to the system firmware or hardware.
>>>
>>> Signed-off-by: Arnd Bergmann 
>>> Signed-off-by: Sriram Dash 
>>> Tested-by: Baolin Wang 
>>> Tested-by: Vivek Gautam 
>>> Tested-by: Alexander Sverdlin 
>>> Signed-off-by: Mathias Nyman 
>>> ---
>>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>>> index 6d33b42..7a9c860 100644
>>> --- a/drivers/usb/host/xhci-plat.c
>>> +++ b/drivers/usb/host/xhci-plat.c
>>
>>> -hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
>>> +hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>>> +   dev_name(&pdev->dev), NULL);
>>
>> As mentioned already in [1], usb_create_shared_hcd() is called to create
>> the second bus, however it also needs to be converted.
>>
>> Not exactly as Roger's suggestion but this worked for me:
>>
>> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
>> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>> dev_name(&pdev->dev), hcd);
>
> But we're creating a shared_hcd and there is an API for that so why not use it
> instead of calling __usb_create_hcd()?

Do we not want to pass on the DMA configuration from sysdev to
shared_hcd as well?

>
>> if (!xhci->shared_hcd) {
>> ret = -ENOMEM;
>>
>> Without this, SuperSpeed devices fail to enumerate:
>>
>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  
>>
>> Thanks,
>> Jack
>>
>> [1] https://lkml.org/lkml/2016/12/9/240
>>
>
> --
> cheers,
> -roger
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-09 Thread Roger Quadros


On 09/02/17 13:53, Roger Quadros wrote:
> 
> 
> On 08/02/17 22:43, Jack Pham wrote:
>> Hi Peter, Sriram, Arnd,
>>
>> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
>>> From: Arnd Bergmann 
>>>
>>> For xhci-hcd platform device, all the DMA parameters are not
>>> configured properly, notably dma ops for dwc3 devices. So, set
>>> the dma for xhci from sysdev. sysdev is pointing to device that
>>> is known to the system firmware or hardware.
>>>
>>> Signed-off-by: Arnd Bergmann 
>>> Signed-off-by: Sriram Dash 
>>> Tested-by: Baolin Wang 
>>> Tested-by: Vivek Gautam 
>>> Tested-by: Alexander Sverdlin 
>>> Signed-off-by: Mathias Nyman 
>>> ---
>>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>>> index 6d33b42..7a9c860 100644
>>> --- a/drivers/usb/host/xhci-plat.c
>>> +++ b/drivers/usb/host/xhci-plat.c
>>
>>> -   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
>>> +   hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>>> +  dev_name(&pdev->dev), NULL);
>>
>> As mentioned already in [1], usb_create_shared_hcd() is called to create
>> the second bus, however it also needs to be converted.
>>
>> Not exactly as Roger's suggestion but this worked for me:
>>
>> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
>> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>> dev_name(&pdev->dev), hcd);
> 
> But we're creating a shared_hcd and there is an API for that so why not use it
> instead of calling __usb_create_hcd()?
> 

Just realized after I pressed send that there is no sysdev parameter
for create_shared_hcd().

>> if (!xhci->shared_hcd) {
>> ret = -ENOMEM;
>>
>> Without this, SuperSpeed devices fail to enumerate:
>>
>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  
>>
>> Thanks,
>> Jack
>>
>> [1] https://lkml.org/lkml/2016/12/9/240
>>
> 

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


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-09 Thread Roger Quadros


On 08/02/17 22:43, Jack Pham wrote:
> Hi Peter, Sriram, Arnd,
> 
> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
>> From: Arnd Bergmann 
>>
>> For xhci-hcd platform device, all the DMA parameters are not
>> configured properly, notably dma ops for dwc3 devices. So, set
>> the dma for xhci from sysdev. sysdev is pointing to device that
>> is known to the system firmware or hardware.
>>
>> Signed-off-by: Arnd Bergmann 
>> Signed-off-by: Sriram Dash 
>> Tested-by: Baolin Wang 
>> Tested-by: Vivek Gautam 
>> Tested-by: Alexander Sverdlin 
>> Signed-off-by: Mathias Nyman 
>> ---
>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>> index 6d33b42..7a9c860 100644
>> --- a/drivers/usb/host/xhci-plat.c
>> +++ b/drivers/usb/host/xhci-plat.c
> 
>> -hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
>> +hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>> +   dev_name(&pdev->dev), NULL);
> 
> As mentioned already in [1], usb_create_shared_hcd() is called to create
> the second bus, however it also needs to be converted.
> 
> Not exactly as Roger's suggestion but this worked for me:
> 
> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
> dev_name(&pdev->dev), hcd);

But we're creating a shared_hcd and there is an API for that so why not use it
instead of calling __usb_create_hcd()?

> if (!xhci->shared_hcd) {
> ret = -ENOMEM;
> 
> Without this, SuperSpeed devices fail to enumerate:
> 
>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  
> 
> Thanks,
> Jack
> 
> [1] https://lkml.org/lkml/2016/12/9/240
> 

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


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-08 Thread Vivek Gautam
On Thu, Feb 9, 2017 at 7:11 AM, Peter Chen  wrote:
> On Wed, Feb 08, 2017 at 12:43:00PM -0800, Jack Pham wrote:
>> Hi Peter, Sriram, Arnd,
>>
>> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
>> > From: Arnd Bergmann 
>> >
>> > For xhci-hcd platform device, all the DMA parameters are not
>> > configured properly, notably dma ops for dwc3 devices. So, set
>> > the dma for xhci from sysdev. sysdev is pointing to device that
>> > is known to the system firmware or hardware.
>> >
>> > Signed-off-by: Arnd Bergmann 
>> > Signed-off-by: Sriram Dash 
>> > Tested-by: Baolin Wang 
>> > Tested-by: Vivek Gautam 
>> > Tested-by: Alexander Sverdlin 
>> > Signed-off-by: Mathias Nyman 
>> > ---
>> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>> > index 6d33b42..7a9c860 100644
>> > --- a/drivers/usb/host/xhci-plat.c
>> > +++ b/drivers/usb/host/xhci-plat.c
>>
>> > -   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
>> > +   hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>> > +  dev_name(&pdev->dev), NULL);
>>
>> As mentioned already in [1], usb_create_shared_hcd() is called to create
>> the second bus, however it also needs to be converted.
>>
>> Not exactly as Roger's suggestion but this worked for me:
>>
>> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
>> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
>> dev_name(&pdev->dev), hcd);
>> if (!xhci->shared_hcd) {
>> ret = -ENOMEM;
>>
>> Without this, SuperSpeed devices fail to enumerate:
>>
>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>>  usb 2-1: device descriptor read/8, error -11
>>  
>>
>> Thanks,
>> Jack
>>
>
> Do you work at same platform with Vivek Gautam? I see his tested-by
> tag in this patch.

The patches [1] had worked for me on 4.9-rc4.
But with
(a) usb-next merged on 4.10-rc7
(b) this patch and [PATCH 3/9] in this series:
  [PATCH v12 3/9] usb: separate out sysdev pointer from usb_bus
and,
(c) phy patches for msm8996 [2] along with necessary device tree patches
I get a hang when SuperSpeed device is being enumerated on db820c.

The change above suggested by Jack works for me too, and i hope that's
the right way to do things.

I can give a Tested-by again with the changes for shared_hcd in the
next version.

[1] https://lkml.org/lkml/2016/11/17/339
[2] https://lkml.org/lkml/2017/1/10/225

>
> I have no dwc3 platform to test, I only got patches from [1], and rebase to
> Greg's usb-next, the rebase has a conflict, and I made a
> change which is similar to revert below patch, but it is definitely
> not your problem.
>
> commit 488dc164914ff5ce5e913abd32048d28fc0d06b8
> Author: Mathias Nyman 
> Date:   Fri Jan 20 15:38:24 2017 +0200
>
> xhci: remove WARN_ON if dma mask is not set for platform devices
>
>
> [1] http://www.spinics.net/lists/linux-usb/msg152375.html
>
> --
>
> Best Regards,
> Peter Chen
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-08 Thread Peter Chen
On Wed, Feb 08, 2017 at 05:27:31PM +0530, Vivek Gautam wrote:
> Hi,
> 
> 
> On Mon, Feb 6, 2017 at 2:43 PM, Peter Chen  wrote:
> > From: Arnd Bergmann 
> >
> > For xhci-hcd platform device, all the DMA parameters are not
> > configured properly, notably dma ops for dwc3 devices. So, set
> > the dma for xhci from sysdev. sysdev is pointing to device that
> > is known to the system firmware or hardware.
> >
> > Signed-off-by: Arnd Bergmann 
> > Signed-off-by: Sriram Dash 
> > Tested-by: Baolin Wang 
> > Tested-by: Vivek Gautam 
> > Tested-by: Alexander Sverdlin 
> > Signed-off-by: Mathias Nyman 
> > ---
> 
> This patch doesn't work for me anymore on db820c target [1].
> While the same kernel with reverts of patches [2] [3] and an older
> patch [4] by Grygorii Strashko works [5].
> 
> [1] 
> https://github.com/vivekgautam1/linux/tree/linux-v4.10-rc7-usb-db820c-nonworking
> [2] 8c9f2de459c7 usb: dwc3: Do not set dma coherent mask
> [3] d64ff406e51e usb: dwc3: use bus->sysdev for DMA configuration
> [4] https://lkml.org/lkml/2016/4/25/813
> [5] https://github.com/vivekgautam1/linux/tree/linux-v4.10-rc7-usb-db820c
> 
> 

The [2] and [3] have already at mainline, you may talk with Felipe about
it.

-- 

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


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-08 Thread Peter Chen
On Wed, Feb 08, 2017 at 12:43:00PM -0800, Jack Pham wrote:
> Hi Peter, Sriram, Arnd,
> 
> On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
> > From: Arnd Bergmann 
> > 
> > For xhci-hcd platform device, all the DMA parameters are not
> > configured properly, notably dma ops for dwc3 devices. So, set
> > the dma for xhci from sysdev. sysdev is pointing to device that
> > is known to the system firmware or hardware.
> > 
> > Signed-off-by: Arnd Bergmann 
> > Signed-off-by: Sriram Dash 
> > Tested-by: Baolin Wang 
> > Tested-by: Vivek Gautam 
> > Tested-by: Alexander Sverdlin 
> > Signed-off-by: Mathias Nyman 
> > ---
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 6d33b42..7a9c860 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> 
> > -   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
> > +   hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
> > +  dev_name(&pdev->dev), NULL);
> 
> As mentioned already in [1], usb_create_shared_hcd() is called to create
> the second bus, however it also needs to be converted.
> 
> Not exactly as Roger's suggestion but this worked for me:
> 
> -   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
> dev_name(&pdev->dev), hcd);
> if (!xhci->shared_hcd) {
> ret = -ENOMEM;
> 
> Without this, SuperSpeed devices fail to enumerate:
> 
>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
>  usb 2-1: device descriptor read/8, error -11
>  
> 
> Thanks,
> Jack
> 

Do you work at same platform with Vivek Gautam? I see his tested-by
tag in this patch.

I have no dwc3 platform to test, I only got patches from [1], and rebase to
Greg's usb-next, the rebase has a conflict, and I made a 
change which is similar to revert below patch, but it is definitely
not your problem.

commit 488dc164914ff5ce5e913abd32048d28fc0d06b8
Author: Mathias Nyman 
Date:   Fri Jan 20 15:38:24 2017 +0200

xhci: remove WARN_ON if dma mask is not set for platform devices


[1] http://www.spinics.net/lists/linux-usb/msg152375.html

-- 

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


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-08 Thread Jack Pham
Hi Peter, Sriram, Arnd,

On Mon, Feb 06, 2017 at 05:13:38PM +0800, Peter Chen wrote:
> From: Arnd Bergmann 
> 
> For xhci-hcd platform device, all the DMA parameters are not
> configured properly, notably dma ops for dwc3 devices. So, set
> the dma for xhci from sysdev. sysdev is pointing to device that
> is known to the system firmware or hardware.
> 
> Signed-off-by: Arnd Bergmann 
> Signed-off-by: Sriram Dash 
> Tested-by: Baolin Wang 
> Tested-by: Vivek Gautam 
> Tested-by: Alexander Sverdlin 
> Signed-off-by: Mathias Nyman 
> ---
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 6d33b42..7a9c860 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c

> - hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
> + hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
> +dev_name(&pdev->dev), NULL);

As mentioned already in [1], usb_create_shared_hcd() is called to create
the second bus, however it also needs to be converted.

Not exactly as Roger's suggestion but this worked for me:

-   xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
+   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
dev_name(&pdev->dev), hcd);
if (!xhci->shared_hcd) {
ret = -ENOMEM;

Without this, SuperSpeed devices fail to enumerate:

 usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
 usb 2-1: device descriptor read/8, error -11
 usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
 usb 2-1: device descriptor read/8, error -11
 usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
 usb 2-1: device descriptor read/8, error -11
 usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd
 usb 2-1: device descriptor read/8, error -11
 

Thanks,
Jack

[1] https://lkml.org/lkml/2016/12/9/240
-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-08 Thread Vivek Gautam
Hi,


On Mon, Feb 6, 2017 at 2:43 PM, Peter Chen  wrote:
> From: Arnd Bergmann 
>
> For xhci-hcd platform device, all the DMA parameters are not
> configured properly, notably dma ops for dwc3 devices. So, set
> the dma for xhci from sysdev. sysdev is pointing to device that
> is known to the system firmware or hardware.
>
> Signed-off-by: Arnd Bergmann 
> Signed-off-by: Sriram Dash 
> Tested-by: Baolin Wang 
> Tested-by: Vivek Gautam 
> Tested-by: Alexander Sverdlin 
> Signed-off-by: Mathias Nyman 
> ---

This patch doesn't work for me anymore on db820c target [1].
While the same kernel with reverts of patches [2] [3] and an older
patch [4] by Grygorii Strashko works [5].

[1] 
https://github.com/vivekgautam1/linux/tree/linux-v4.10-rc7-usb-db820c-nonworking
[2] 8c9f2de459c7 usb: dwc3: Do not set dma coherent mask
[3] d64ff406e51e usb: dwc3: use bus->sysdev for DMA configuration
[4] https://lkml.org/lkml/2016/4/25/813
[5] https://github.com/vivekgautam1/linux/tree/linux-v4.10-rc7-usb-db820c


regards
Vivek

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v12 6/9] usb: xhci: use bus->sysdev for DMA configuration

2017-02-06 Thread Peter Chen
From: Arnd Bergmann 

For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices. So, set
the dma for xhci from sysdev. sysdev is pointing to device that
is known to the system firmware or hardware.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Tested-by: Baolin Wang 
Tested-by: Vivek Gautam 
Tested-by: Alexander Sverdlin 
Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-mem.c  | 12 ++--
 drivers/usb/host/xhci-plat.c | 33 ++---
 drivers/usb/host/xhci.c  | 15 +++
 3 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index ba1853f4..032a702 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
unsigned int num_stream_ctxs,
struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
 {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
 
if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct 
xhci_hcd *xhci,
unsigned int num_stream_ctxs, dma_addr_t *dma,
gfp_t mem_flags)
 {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
 
if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -1686,7 +1686,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci,
 static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 {
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
 
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -1758,7 +1758,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 {
int num_sp;
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
 
if (!xhci->scratchpad)
return;
@@ -1831,7 +1831,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
 
 void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
int size;
int i, j, num_ports;
 
@@ -2373,7 +2373,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, 
gfp_t flags)
 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 {
dma_addr_t  dma;
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
unsigned intval, val2;
u64 val_64;
struct xhci_segment *seg;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6d33b42..7a9c860 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -148,6 +149,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 {
const struct of_device_id *match;
const struct hc_driver  *driver;
+   struct device   *sysdev;
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd  *hcd;
@@ -164,22 +166,39 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq < 0)
return -ENODEV;
 
+   /*
+* sysdev must point to a device that is known to the system firmware
+* or PCI hardware. We handle these three cases here:
+* 1. xhci_plat comes from firmware
+* 2. xhci_plat is child of a device from firmware (dwc3-plat)
+* 3. xhci_plat is grandchild of a pci device (dwc3-pci)
+*/
+   sysdev = &pdev->dev;
+   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   sysdev = sysdev->parent;
+#ifdef CONFIG_PCI
+   else if (sysdev->parent && sysdev->parent->parent &&
+sysdev->parent->parent->bus == &pci_bus_type)
+   sysdev = sysdev->parent->parent;
+#endif
+
/* Try to set 64-bit DMA first */
-   if (!pdev->dev.dma_mask)
+   if (WARN_ON(!sysdev->dma_mask))
/* Platform did not initialize dma_mask */
-   ret = dma_coerce_mask_and_coherent(&pdev->dev,
+   ret = dma_coerce_mask_and_coherent(sysdev,
   DMA_BIT_MASK(64));
else
-   ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+   ret = dma_set_mask_and_