diff mbox series

[v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1 controller register access in reset state

Message ID 20230621141116.21631-1-jit.loon.lim@intel.com
State Needs Review / ACK, archived
Delegated to: Marek Vasut
Headers show
Series [v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1 controller register access in reset state | expand

Commit Message

Jit Loon Lim June 21, 2023, 2:11 p.m. UTC
From: Teik Heng Chong <teik.heng.chong@intel.com>

The controller registers should not be accessed while the controller's
vcc_reset_n is asserted.

Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
---
 drivers/usb/host/xhci-dwc3.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Marek Vasut June 21, 2023, 2:18 p.m. UTC | #1
On 6/21/23 16:11, Jit Loon Lim wrote:
> From: Teik Heng Chong <teik.heng.chong@intel.com>
> 
> The controller registers should not be accessed while the controller's
> vcc_reset_n is asserted.
> 
> Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>

Is this patch ported from Linux or is this custom development ?

Is there a matching patch/fix in Linux already ?
Jit Loon Lim June 22, 2023, 2:48 a.m. UTC | #2
> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: Wednesday, 21 June, 2023 10:19 PM
> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik Heng
> <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>
> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> controller register access in reset state
> 
> On 6/21/23 16:11, Jit Loon Lim wrote:
> > From: Teik Heng Chong <teik.heng.chong@intel.com>
> >
> > The controller registers should not be accessed while the controller's
> > vcc_reset_n is asserted.
> >
> > Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
> 
> Is this patch ported from Linux or is this custom development ?
> 
> Is there a matching patch/fix in Linux already ?

In xhci_dwc3_probe(), the program sequence is
vcc reset -> clk init -> phy setup -> xhci_register
therefore, when xhci_dwc3_remove is called, the proper usb stop sequence should be
xhci_register _> phy setup -> clk init -> vcc reset

if we look at linux driver  https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-of-simple.c#L33

dwc3_of_simple_probe: The sequence is reset -> clock
__dwc3_of_simple_teardown: Then, clock -> reset

So based on the above, we have made changes and the uboot fix is now aligned with linux driver.
Marek Vasut June 22, 2023, 9:35 a.m. UTC | #3
On 6/22/23 04:48, Lim, Jit Loon wrote:
>> -----Original Message-----
>> From: Marek Vasut <marex@denx.de>
>> Sent: Wednesday, 21 June, 2023 10:19 PM
>> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
>> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
>> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
>> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
>> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
>> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
>> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik Heng
>> <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
>> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
>> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>
>> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
>> controller register access in reset state
>>
>> On 6/21/23 16:11, Jit Loon Lim wrote:
>>> From: Teik Heng Chong <teik.heng.chong@intel.com>
>>>
>>> The controller registers should not be accessed while the controller's
>>> vcc_reset_n is asserted.
>>>
>>> Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
>>
>> Is this patch ported from Linux or is this custom development ?
>>
>> Is there a matching patch/fix in Linux already ?
> 
> In xhci_dwc3_probe(), the program sequence is
> vcc reset -> clk init -> phy setup -> xhci_register
> therefore, when xhci_dwc3_remove is called, the proper usb stop sequence should be
> xhci_register _> phy setup -> clk init -> vcc reset
> 
> if we look at linux driver  https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-of-simple.c#L33
> 
> dwc3_of_simple_probe: The sequence is reset -> clock
> __dwc3_of_simple_teardown: Then, clock -> reset
> 
> So based on the above, we have made changes and the uboot fix is now aligned with linux driver.

Instead of adding random patches to the U-Boot dwc3 driver, please just 
synchronize the driver with Linux. You should be able to add the missing 
patches to the DWC3 driver from Linux since the last synchronization 
point, the process should be largely mechanical. Make sure to include 
commit ID of each Linux commit in the new matching U-Boot patch.

It shouldn't be difficult, one approach I can think of is roughly this:
- figure out the original merge base from which the DWC3 driver was 
imported to U-Boot
- in U-Boot, revert all dwc3 patches on top of that import patch
- pick all Linux kernel dwc3 patches from that merge base and apply on 
top of this U-Boot with reverts
- Run rebase and drop the reverts, let git drop duplicate patches
Jit Loon Lim June 22, 2023, 2:08 p.m. UTC | #4
> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: Thursday, 22 June, 2023 5:35 PM
> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik Heng
> <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>; Michal Simek
> <monstr@monstr.eu>; Tom Rini <trini@konsulko.com>; Eugen Hristev
> <eugen.hristev@microchip.com>
> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> controller register access in reset state
> 
> On 6/22/23 04:48, Lim, Jit Loon wrote:
> >> -----Original Message-----
> >> From: Marek Vasut <marex@denx.de>
> >> Sent: Wednesday, 21 June, 2023 10:19 PM
> >> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> >> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> >> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> >> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> >> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
> >> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
> >> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik
> >> Heng <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> >> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> >> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>
> >> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> >> controller register access in reset state
> >>
> >> On 6/21/23 16:11, Jit Loon Lim wrote:
> >>> From: Teik Heng Chong <teik.heng.chong@intel.com>
> >>>
> >>> The controller registers should not be accessed while the
> >>> controller's vcc_reset_n is asserted.
> >>>
> >>> Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
> >>
> >> Is this patch ported from Linux or is this custom development ?
> >>
> >> Is there a matching patch/fix in Linux already ?
> >
> > In xhci_dwc3_probe(), the program sequence is vcc reset -> clk init ->
> > phy setup -> xhci_register therefore, when xhci_dwc3_remove is called,
> > the proper usb stop sequence should be xhci_register _> phy setup ->
> > clk init -> vcc reset
> >
> > if we look at linux driver
> > https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-o
> > f-simple.c#L33
> >
> > dwc3_of_simple_probe: The sequence is reset -> clock
> > __dwc3_of_simple_teardown: Then, clock -> reset
> >
> > So based on the above, we have made changes and the uboot fix is now
> aligned with linux driver.
> 
> Instead of adding random patches to the U-Boot dwc3 driver, please just
> synchronize the driver with Linux. You should be able to add the missing
> patches to the DWC3 driver from Linux since the last synchronization point, the
> process should be largely mechanical. Make sure to include commit ID of each
> Linux commit in the new matching U-Boot patch.
> 
> It shouldn't be difficult, one approach I can think of is roughly this:
> - figure out the original merge base from which the DWC3 driver was imported
> to U-Boot
> - in U-Boot, revert all dwc3 patches on top of that import patch
> - pick all Linux kernel dwc3 patches from that merge base and apply on top of
> this U-Boot with reverts
> - Run rebase and drop the reverts, let git drop duplicate patches

We believed the previous reply from us is a bit confusing. 
There is no exact same function/file for U-Boot to use in Linux. 
What we are doing is, we are referring to Linux sequence. 

Linux:  (dwc3_of_simple_probe)
https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-of-simple.c#L33 
U-Boot: (xhci_dwc3_probe)
https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-dwc3.c#L159 

Linux:  (__dwc3_of_simple_teardown)
https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-of-simple.c#L98 
U-Boot: (xhci_dwc3_remove)
https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-dwc3.c#L227

So we believed that we can't directly pickup all Linux kernel dwc3 patches and merge to U-Boot.
Marek Vasut July 6, 2023, 9:49 p.m. UTC | #5
On 6/22/23 16:08, Lim, Jit Loon wrote:
>> -----Original Message-----
>> From: Marek Vasut <marex@denx.de>
>> Sent: Thursday, 22 June, 2023 5:35 PM
>> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
>> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
>> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
>> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
>> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
>> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
>> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik Heng
>> <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
>> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
>> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>; Michal Simek
>> <monstr@monstr.eu>; Tom Rini <trini@konsulko.com>; Eugen Hristev
>> <eugen.hristev@microchip.com>
>> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
>> controller register access in reset state
>>
>> On 6/22/23 04:48, Lim, Jit Loon wrote:
>>>> -----Original Message-----
>>>> From: Marek Vasut <marex@denx.de>
>>>> Sent: Wednesday, 21 June, 2023 10:19 PM
>>>> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
>>>> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
>>>> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
>>>> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
>>>> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
>>>> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
>>>> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik
>>>> Heng <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
>>>> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
>>>> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>
>>>> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
>>>> controller register access in reset state
>>>>
>>>> On 6/21/23 16:11, Jit Loon Lim wrote:
>>>>> From: Teik Heng Chong <teik.heng.chong@intel.com>
>>>>>
>>>>> The controller registers should not be accessed while the
>>>>> controller's vcc_reset_n is asserted.
>>>>>
>>>>> Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
>>>>
>>>> Is this patch ported from Linux or is this custom development ?
>>>>
>>>> Is there a matching patch/fix in Linux already ?
>>>
>>> In xhci_dwc3_probe(), the program sequence is vcc reset -> clk init ->
>>> phy setup -> xhci_register therefore, when xhci_dwc3_remove is called,
>>> the proper usb stop sequence should be xhci_register _> phy setup ->
>>> clk init -> vcc reset
>>>
>>> if we look at linux driver
>>> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-o
>>> f-simple.c#L33
>>>
>>> dwc3_of_simple_probe: The sequence is reset -> clock
>>> __dwc3_of_simple_teardown: Then, clock -> reset
>>>
>>> So based on the above, we have made changes and the uboot fix is now
>> aligned with linux driver.
>>
>> Instead of adding random patches to the U-Boot dwc3 driver, please just
>> synchronize the driver with Linux. You should be able to add the missing
>> patches to the DWC3 driver from Linux since the last synchronization point, the
>> process should be largely mechanical. Make sure to include commit ID of each
>> Linux commit in the new matching U-Boot patch.
>>
>> It shouldn't be difficult, one approach I can think of is roughly this:
>> - figure out the original merge base from which the DWC3 driver was imported
>> to U-Boot
>> - in U-Boot, revert all dwc3 patches on top of that import patch
>> - pick all Linux kernel dwc3 patches from that merge base and apply on top of
>> this U-Boot with reverts
>> - Run rebase and drop the reverts, let git drop duplicate patches
> 
> We believed the previous reply from us is a bit confusing.
> There is no exact same function/file for U-Boot to use in Linux.
> What we are doing is, we are referring to Linux sequence.
> 
> Linux:  (dwc3_of_simple_probe)
> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-of-simple.c#L33
> U-Boot: (xhci_dwc3_probe)
> https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-dwc3.c#L159
> 
> Linux:  (__dwc3_of_simple_teardown)
> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-of-simple.c#L98
> U-Boot: (xhci_dwc3_remove)
> https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-dwc3.c#L227
> 
> So we believed that we can't directly pickup all Linux kernel dwc3 patches and merge to U-Boot.

If you were to sync the driver from Linux to U-Boot, then the same 
sequence as Linux uses would be automatically used too, right ?

Sorry for the abysmal delay in my reply.
Jit Loon Lim July 21, 2023, 3:26 a.m. UTC | #6
Hi

> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: Friday, 7 July, 2023 5:50 AM
> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
> <dinesh.maniyam@intel.com>; Ng, Boon Khai <boon.khai.ng@intel.com>;
> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik Heng
> <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>; Michal
> Simek <monstr@monstr.eu>; Tom Rini <trini@konsulko.com>; Eugen Hristev
> <eugen.hristev@microchip.com>
> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> controller register access in reset state
> 
> On 6/22/23 16:08, Lim, Jit Loon wrote:
> >> -----Original Message-----
> >> From: Marek Vasut <marex@denx.de>
> >> Sent: Thursday, 22 June, 2023 5:35 PM
> >> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> >> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> >> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> >> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> >> Lokanathan, Raaj <raaj.lokanathan@intel.com>; Maniyam, Dinesh
> >> <dinesh.maniyam@intel.com>; Ng, Boon Khai
> <boon.khai.ng@intel.com>;
> >> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik
> >> Heng <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> >> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> >> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>; Michal
> >> Simek <monstr@monstr.eu>; Tom Rini <trini@konsulko.com>; Eugen
> >> Hristev <eugen.hristev@microchip.com>
> >> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> >> controller register access in reset state
> >>
> >> On 6/22/23 04:48, Lim, Jit Loon wrote:
> >>>> -----Original Message-----
> >>>> From: Marek Vasut <marex@denx.de>
> >>>> Sent: Wednesday, 21 June, 2023 10:19 PM
> >>>> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> >>>> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> >>>> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> >>>> <tien.fong.chee@intel.com>; Hea, Kok Kiang
> >>>> <kok.kiang.hea@intel.com>; Lokanathan, Raaj
> >>>> <raaj.lokanathan@intel.com>; Maniyam, Dinesh
> >>>> <dinesh.maniyam@intel.com>; Ng, Boon Khai
> <boon.khai.ng@intel.com>;
> >>>> Yuslaimi, Alif Zakuan <alif.zakuan.yuslaimi@intel.com>; Chong, Teik
> >>>> Heng <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> >>>> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> >>>> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>
> >>>> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix
> >>>> USB3.1 controller register access in reset state
> >>>>
> >>>> On 6/21/23 16:11, Jit Loon Lim wrote:
> >>>>> From: Teik Heng Chong <teik.heng.chong@intel.com>
> >>>>>
> >>>>> The controller registers should not be accessed while the
> >>>>> controller's vcc_reset_n is asserted.
> >>>>>
> >>>>> Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
> >>>>
> >>>> Is this patch ported from Linux or is this custom development ?
> >>>>
> >>>> Is there a matching patch/fix in Linux already ?
> >>>
> >>> In xhci_dwc3_probe(), the program sequence is vcc reset -> clk init
> >>> -> phy setup -> xhci_register therefore, when xhci_dwc3_remove is
> >>> called, the proper usb stop sequence should be xhci_register _> phy
> >>> setup -> clk init -> vcc reset
> >>>
> >>> if we look at linux driver
> >>> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3
> >>> -o
> >>> f-simple.c#L33
> >>>
> >>> dwc3_of_simple_probe: The sequence is reset -> clock
> >>> __dwc3_of_simple_teardown: Then, clock -> reset
> >>>
> >>> So based on the above, we have made changes and the uboot fix is now
> >> aligned with linux driver.
> >>
> >> Instead of adding random patches to the U-Boot dwc3 driver, please
> >> just synchronize the driver with Linux. You should be able to add the
> >> missing patches to the DWC3 driver from Linux since the last
> >> synchronization point, the process should be largely mechanical. Make
> >> sure to include commit ID of each Linux commit in the new matching U-
> Boot patch.
> >>
> >> It shouldn't be difficult, one approach I can think of is roughly this:
> >> - figure out the original merge base from which the DWC3 driver was
> >> imported to U-Boot
> >> - in U-Boot, revert all dwc3 patches on top of that import patch
> >> - pick all Linux kernel dwc3 patches from that merge base and apply
> >> on top of this U-Boot with reverts
> >> - Run rebase and drop the reverts, let git drop duplicate patches
> >
> > We believed the previous reply from us is a bit confusing.
> > There is no exact same function/file for U-Boot to use in Linux.
> > What we are doing is, we are referring to Linux sequence.
> >
> > Linux:  (dwc3_of_simple_probe)
> > https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-o
> > f-simple.c#L33
> > U-Boot: (xhci_dwc3_probe)
> > https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-
> > dwc3.c#L159
> >
> > Linux:  (__dwc3_of_simple_teardown)
> > https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-o
> > f-simple.c#L98
> > U-Boot: (xhci_dwc3_remove)
> > https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-
> > dwc3.c#L227
> >
> > So we believed that we can't directly pickup all Linux kernel dwc3 patches
> and merge to U-Boot.
> 
> If you were to sync the driver from Linux to U-Boot, then the same sequence
> as Linux uses would be automatically used too, right ?
> 
> Sorry for the abysmal delay in my reply.

Are we saying that we shall port/use Linux driver in U-Boot and abandon the existing USB host driver in U-Boot?
Bin Meng July 21, 2023, 5:12 a.m. UTC | #7
On Wed, Jun 21, 2023 at 10:11 PM Jit Loon Lim <jit.loon.lim@intel.com> wrote:
>
> From: Teik Heng Chong <teik.heng.chong@intel.com>
>
> The controller registers should not be accessed while the controller's
> vcc_reset_n is asserted.
>
> Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
> ---
>  drivers/usb/host/xhci-dwc3.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
> index 1dbd65dfaa..3172956bd6 100644
> --- a/drivers/usb/host/xhci-dwc3.c
> +++ b/drivers/usb/host/xhci-dwc3.c
> @@ -227,6 +227,11 @@ static int xhci_dwc3_probe(struct udevice *dev)
>  static int xhci_dwc3_remove(struct udevice *dev)
>  {
>         struct xhci_dwc3_plat *plat = dev_get_plat(dev);
> +       int ret;
> +
> +       ret = xhci_deregister(dev);
> +       if (ret)
> +               return ret;
>
>         dwc3_shutdown_phy(dev, &plat->phys);
>
> @@ -234,7 +239,7 @@ static int xhci_dwc3_remove(struct udevice *dev)
>
>         reset_release_bulk(&plat->resets);
>
> -       return xhci_deregister(dev);
> +       return 0;
>  }
>
>  static const struct udevice_id xhci_dwc3_ids[] = {

Please remove the HSD tag in the commit summary.

Regards,
Bin
Marek Vasut July 21, 2023, 8:31 p.m. UTC | #8
On 7/21/23 05:26, Lim, Jit Loon wrote:

Hi,

>>> Linux:  (__dwc3_of_simple_teardown)
>>> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3-o
>>> f-simple.c#L98
>>> U-Boot: (xhci_dwc3_remove)
>>> https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhci-
>>> dwc3.c#L227
>>>
>>> So we believed that we can't directly pickup all Linux kernel dwc3 patches
>> and merge to U-Boot.
>>
>> If you were to sync the driver from Linux to U-Boot, then the same sequence
>> as Linux uses would be automatically used too, right ?
>>
>> Sorry for the abysmal delay in my reply.
> 
> Are we saying that we shall port/use Linux driver in U-Boot and abandon the existing USB host driver in U-Boot?

No, the existing driver in U-Boot is a port of the Linux driver, it is 
just outdated. I am saying, just pick the missing patches from Linux and 
add them to U-Boot, so the two drivers are in sync.
Chong, Teik Heng July 26, 2023, 4:04 a.m. UTC | #9
Hi

> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: Saturday, 22 July, 2023 4:31 AM
> To: Lim, Jit Loon <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> Maniyam, Dinesh <dinesh.maniyam@intel.com>; Ng, Boon Khai
> <boon.khai.ng@intel.com>; Yuslaimi, Alif Zakuan
> <alif.zakuan.yuslaimi@intel.com>; Chong, Teik Heng
> <teik.heng.chong@intel.com>; Zamri, Muhammad Hazim Izzat
> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>; Michal
> Simek <monstr@monstr.eu>; Tom Rini <trini@konsulko.com>; Eugen Hristev
> <eugen.hristev@microchip.com>
> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> controller register access in reset state
> 
> On 7/21/23 05:26, Lim, Jit Loon wrote:
> 
> Hi,
> 
> >>> Linux:  (__dwc3_of_simple_teardown)
> >>> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3
> >>> -o
> >>> f-simple.c#L98
> >>> U-Boot: (xhci_dwc3_remove)
> >>> https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhc
> >>> i-
> >>> dwc3.c#L227
> >>>
> >>> So we believed that we can't directly pickup all Linux kernel dwc3
> >>> patches
> >> and merge to U-Boot.
> >>
> >> If you were to sync the driver from Linux to U-Boot, then the same
> >> sequence as Linux uses would be automatically used too, right ?
> >>
> >> Sorry for the abysmal delay in my reply.
> >
> > Are we saying that we shall port/use Linux driver in U-Boot and abandon
> the existing USB host driver in U-Boot?
> 
> No, the existing driver in U-Boot is a port of the Linux driver, it is just
> outdated. I am saying, just pick the missing patches from Linux and add them
> to U-Boot, so the two drivers are in sync.

We do not see a DWC3 host driver under usb host folder in Linux https://elixir.bootlin.com/linux/latest/source/drivers/usb/host. Would you mind to tell us which DWC3 host driver we should use in usb host folder? Then, we can pick up the missing patches
Marek Vasut July 26, 2023, 10:29 a.m. UTC | #10
On 7/26/23 06:04, Chong, Teik Heng wrote:
[...]
>>>>> Linux:  (__dwc3_of_simple_teardown)
>>>>> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dwc3
>>>>> -o
>>>>> f-simple.c#L98
>>>>> U-Boot: (xhci_dwc3_remove)
>>>>> https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/xhc
>>>>> i-
>>>>> dwc3.c#L227
>>>>>
>>>>> So we believed that we can't directly pickup all Linux kernel dwc3
>>>>> patches
>>>> and merge to U-Boot.
>>>>
>>>> If you were to sync the driver from Linux to U-Boot, then the same
>>>> sequence as Linux uses would be automatically used too, right ?
>>>>
>>>> Sorry for the abysmal delay in my reply.
>>>
>>> Are we saying that we shall port/use Linux driver in U-Boot and abandon
>> the existing USB host driver in U-Boot?
>>
>> No, the existing driver in U-Boot is a port of the Linux driver, it is just
>> outdated. I am saying, just pick the missing patches from Linux and add them
>> to U-Boot, so the two drivers are in sync.
> 
> We do not see a DWC3 host driver under usb host folder in Linux https://elixir.bootlin.com/linux/latest/source/drivers/usb/host. Would you mind to tell us which DWC3 host driver we should use in usb host folder? Then, we can pick up the missing patches

drivers/usb/dwc3

Same as u-boot
Chong, Teik Heng July 27, 2023, 12:50 a.m. UTC | #11
Hi

> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: Wednesday, 26 July, 2023 6:30 PM
> To: Chong, Teik Heng <teik.heng.chong@intel.com>; Lim, Jit Loon
> <jit.loon.lim@intel.com>; u-boot@lists.denx.de
> Cc: Jagan Teki <jagan@amarulasolutions.com>; Simon
> <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> <tien.fong.chee@intel.com>; Hea, Kok Kiang <kok.kiang.hea@intel.com>;
> Maniyam, Dinesh <dinesh.maniyam@intel.com>; Ng, Boon Khai
> <boon.khai.ng@intel.com>; Yuslaimi, Alif Zakuan
> <alif.zakuan.yuslaimi@intel.com>; Zamri, Muhammad Hazim Izzat
> <muhammad.hazim.izzat.zamri@intel.com>; Tang, Sieu Mun
> <sieu.mun.tang@intel.com>; Bin Meng <bmeng.cn@gmail.com>; Michal
> Simek <monstr@monstr.eu>; Tom Rini <trini@konsulko.com>; Eugen Hristev
> <eugen.hristev@microchip.com>
> Subject: Re: [PATCH v1] HSD #18028953892: usb: xhci-dwc3: Fix USB3.1
> controller register access in reset state
> 
> On 7/26/23 06:04, Chong, Teik Heng wrote:
> [...]
> >>>>> Linux:  (__dwc3_of_simple_teardown)
> >>>>> https://elixir.bootlin.com/linux/latest/source/drivers/usb/dwc3/dw
> >>>>> c3
> >>>>> -o
> >>>>> f-simple.c#L98
> >>>>> U-Boot: (xhci_dwc3_remove)
> >>>>> https://elixir.bootlin.com/u-boot/latest/source/drivers/usb/host/x
> >>>>> hc
> >>>>> i-
> >>>>> dwc3.c#L227
> >>>>>
> >>>>> So we believed that we can't directly pickup all Linux kernel dwc3
> >>>>> patches
> >>>> and merge to U-Boot.
> >>>>
> >>>> If you were to sync the driver from Linux to U-Boot, then the same
> >>>> sequence as Linux uses would be automatically used too, right ?
> >>>>
> >>>> Sorry for the abysmal delay in my reply.
> >>>
> >>> Are we saying that we shall port/use Linux driver in U-Boot and
> >>> abandon
> >> the existing USB host driver in U-Boot?
> >>
> >> No, the existing driver in U-Boot is a port of the Linux driver, it
> >> is just outdated. I am saying, just pick the missing patches from
> >> Linux and add them to U-Boot, so the two drivers are in sync.
> >
> > We do not see a DWC3 host driver under usb host folder in Linux
> > https://elixir.bootlin.com/linux/latest/source/drivers/usb/host. Would
> > you mind to tell us which DWC3 host driver we should use in usb host
> > folder? Then, we can pick up the missing patches
> 
> drivers/usb/dwc3
> 
> Same as u-boot

Ok. We will use the driver from drivers/usb/dwc3. Thank you for the pointers
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index 1dbd65dfaa..3172956bd6 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -227,6 +227,11 @@  static int xhci_dwc3_probe(struct udevice *dev)
 static int xhci_dwc3_remove(struct udevice *dev)
 {
 	struct xhci_dwc3_plat *plat = dev_get_plat(dev);
+	int ret;
+
+	ret = xhci_deregister(dev);
+	if (ret)
+		return ret;
 
 	dwc3_shutdown_phy(dev, &plat->phys);
 
@@ -234,7 +239,7 @@  static int xhci_dwc3_remove(struct udevice *dev)
 
 	reset_release_bulk(&plat->resets);
 
-	return xhci_deregister(dev);
+	return 0;
 }
 
 static const struct udevice_id xhci_dwc3_ids[] = {