Re: [PATCH 0/3] Fix USB3.0 DRD PHY calibration issues (DWC3/XHCI) on Exynos542x SoCs

2019-07-15 Thread Anand Moon
Hi Marek,

On Mon, 15 Jul 2019 at 17:49, Marek Szyprowski  wrote:
>
> Hi Anand,
>
> On 2019-06-28 17:32, Anand Moon wrote:
> > Hi Marek,
> >
> > On Thu, 27 Jun 2019 at 12:47, Marek Szyprowski  
> > wrote:
> >> Dear All,
> >>
> >> Commit d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for
> >> exynos5420/5800") added support for Exynos5 USB3.0 DRD PHY calibration,
> >> what enabled proper Super-Speed enumeration of USB3.0 devices connected
> >> to various Exynos5 SoCs. After some time it turned out that the mentioned
> >> patch worked a bit by pure luck and covered only one use case (fresh
> >> boot with all drivers compiled into the kernel).
> >>
> >> If drivers were compiled as modules, due to timing issue, it worked only
> >> if XHCI-plat driver was loaded before the DWC3 driver:
> >> https://patchwork.kernel.org/patch/10773947/
> >>
> >> Also during the system suspend/resume cycle the calibration was not
> >> performed at the proper time and resulted in switching USB 3.0 devices to
> >> USB 2.0 high-speed compatibility mode.
> >>
> >> This patch addresses all those issues. Exynos5 USB3.0 DRD PHY calibration
> >> is moved to the Exynos5 specific variant of the XHCI-plat driver, which
> >> takes care of proper PHY calibration after XHCI core reset. This fixes
> >> all known use cases (XHCI driver compiled as module and loaded on demand
> >> as well as during system suspend/resume cycle).
> >>
> >> Here are the logs taken on Exynos5422-based Odroid HC1 board (with USB3.0
> >> RTL8153 LAN and USB3.0 JMicron SATA-USB bridge):
> >>
> > Thanks for these patch. I have tested on linux-next-20190626
> >
> > *But hotpluging of usb device is not working on usb ports.*
>
> Well, this is a bit poor report. I've checked various USB 3.0 devices
> with my XU4 board and didn't observe any issue with hotplug or
> enumeration. Could you describe a bit more how to trigger the issue?
>

Sorry for the noise one of my usb 3.0 port on XU4 is not working somehow.
I will re-test these patches again on current next and share my result.

> > These patches fix the suspend/resume for XU4.
> > But their is two issue.
> > 1> On warm boot fails to reset the usb hub
> > --
> > [7.019896] usb 4-1.1: new SuperSpeed Gen 1 USB device number 3
> > using xhci-hcd
> > [7.063032] usb 4-1.1: New USB device found, idVendor=152d,
> > idProduct=0578, bcdDevice=63.01
> > [7.070484] usb 4-1.1: New USB device strings: Mfr=1, Product=2,
> > SerialNumber=3
> > [7.077438] usb 4-1.1: Product: JMS567
> > [7.081749] usb 4-1.1: Manufacturer: JMicron
> > [7.086028] usb 4-1.1: SerialNumber: DB12345678A3
> > [7.151572] scsi host0: uas
> > [7.162765] scsi 0:0:0:0: Direct-Access KINGSTON  SA400S37120G
> >6301 PQ: 0 ANSI: 6
> > [7.176231] sd 0:0:0:0: [sda] 234441648 512-byte logical blocks:
> > (120 GB/112 GiB)
> > [7.177550] sd 0:0:0:0: Attached scsi generic sg0 type 0
> > [7.183547] sd 0:0:0:0: [sda] 4096-byte physical blocks
> > [7.201150] sd 0:0:0:0: [sda] Write Protect is off
> > [7.204977] sd 0:0:0:0: [sda] Disabling FUA
> > [7.209476] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
> > enabled, doesn't support DPO or FUA
> > [7.219411] sd 0:0:0:0: [sda] Optimal transfer size 33553920 bytes
> > not a multiple of physical block size (4096 bytes)
> > [7.713603]  sda: sda1
> > [7.736338] sd 0:0:0:0: [sda] Attached SCSI disk
> > [   11.372630] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
> > waiting for setup device command
> > [   16.650624] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
> > waiting for setup device command
> > [   16.870255] usb 6-1: device not accepting address 2, error -62
> > [   22.171093] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
> > waiting for setup device command
> > [   27.451021] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
> > waiting for setup device command
> > [   27.669956] usb 6-1: device not accepting address 3, error -62
> > [   27.711656] usb usb6-port1: attempt power cycle
> >
> > some how 1250.phy do not de-register when we perform reboot.
>
> Sorry, but this is not related to PHY at all. If I get your log right,
> you have external USB3->SATA bridge which fails to enumerate in your
> case. Does it work right with other boards or vendor kernels? You
> connect it to the XU4 onboard USB3.0 hub, which cannot be programmed or
> controlled in any way, so I doubt we can do anything to fix your issue.
>

Sorry this issue is related to realtek ethernet driver r-8153 failed
to register again
after reboot. It's a know issue for long time as far as I know,
I will double check this again.

>
> > [  120.260813] shutdown[1]: All loop devices detached.
> > [  120.308592] sd 0:0:0:0: [sda] Synchronizing SCSI cache
> > [  120.425890] usb 4-1.1: reset SuperSpeed Gen 1 USB device number 3
> > using xhci-hcd
> > [  120.500085] wake enabled for irq 155
> > [  120.592335] 

Re: [PATCH 0/3] Fix USB3.0 DRD PHY calibration issues (DWC3/XHCI) on Exynos542x SoCs

2019-06-28 Thread Anand Moon
Hi Marek,

On Thu, 27 Jun 2019 at 12:47, Marek Szyprowski  wrote:
>
> Dear All,
>
> Commit d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for
> exynos5420/5800") added support for Exynos5 USB3.0 DRD PHY calibration,
> what enabled proper Super-Speed enumeration of USB3.0 devices connected
> to various Exynos5 SoCs. After some time it turned out that the mentioned
> patch worked a bit by pure luck and covered only one use case (fresh
> boot with all drivers compiled into the kernel).
>
> If drivers were compiled as modules, due to timing issue, it worked only
> if XHCI-plat driver was loaded before the DWC3 driver:
> https://patchwork.kernel.org/patch/10773947/
>
> Also during the system suspend/resume cycle the calibration was not
> performed at the proper time and resulted in switching USB 3.0 devices to
> USB 2.0 high-speed compatibility mode.
>
> This patch addresses all those issues. Exynos5 USB3.0 DRD PHY calibration
> is moved to the Exynos5 specific variant of the XHCI-plat driver, which
> takes care of proper PHY calibration after XHCI core reset. This fixes
> all known use cases (XHCI driver compiled as module and loaded on demand
> as well as during system suspend/resume cycle).
>
> Here are the logs taken on Exynos5422-based Odroid HC1 board (with USB3.0
> RTL8153 LAN and USB3.0 JMicron SATA-USB bridge):
>

Thanks for these patch. I have tested on linux-next-20190626

*But hotpluging of usb device is not working on usb ports.*


These patches fix the suspend/resume for XU4.
But their is two issue.
1> On warm boot fails to reset the usb hub
--
[7.019896] usb 4-1.1: new SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[7.063032] usb 4-1.1: New USB device found, idVendor=152d,
idProduct=0578, bcdDevice=63.01
[7.070484] usb 4-1.1: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[7.077438] usb 4-1.1: Product: JMS567
[7.081749] usb 4-1.1: Manufacturer: JMicron
[7.086028] usb 4-1.1: SerialNumber: DB12345678A3
[7.151572] scsi host0: uas
[7.162765] scsi 0:0:0:0: Direct-Access KINGSTON  SA400S37120G
  6301 PQ: 0 ANSI: 6
[7.176231] sd 0:0:0:0: [sda] 234441648 512-byte logical blocks:
(120 GB/112 GiB)
[7.177550] sd 0:0:0:0: Attached scsi generic sg0 type 0
[7.183547] sd 0:0:0:0: [sda] 4096-byte physical blocks
[7.201150] sd 0:0:0:0: [sda] Write Protect is off
[7.204977] sd 0:0:0:0: [sda] Disabling FUA
[7.209476] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[7.219411] sd 0:0:0:0: [sda] Optimal transfer size 33553920 bytes
not a multiple of physical block size (4096 bytes)
[7.713603]  sda: sda1
[7.736338] sd 0:0:0:0: [sda] Attached SCSI disk
[   11.372630] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
waiting for setup device command
[   16.650624] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
waiting for setup device command
[   16.870255] usb 6-1: device not accepting address 2, error -62
[   22.171093] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
waiting for setup device command
[   27.451021] xhci-hcd exynos5-dwc3-xhci.5.auto: Timeout while
waiting for setup device command
[   27.669956] usb 6-1: device not accepting address 3, error -62
[   27.711656] usb usb6-port1: attempt power cycle

some how 1250.phy do not de-register when we perform reboot.

[  120.260813] shutdown[1]: All loop devices detached.
[  120.308592] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  120.425890] usb 4-1.1: reset SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[  120.500085] wake enabled for irq 155
[  120.592335] reboot: Restartin

Attach are the reboot logs.
[0] https://pastebin.com/a3d712q4

Second issue is the unbind on usb dwc3 fails.

[root@archl-xu4m ~]# cd /sys/bus/platform/drivers/exynos5_usb3drd_phy/
[root@archl-xu4m exynos5_usb3drd_phy]# ls -la
total 0
drwxr-xr-x   2 root root0 Jun 28 14:08 .
drwxr-xr-x 131 root root0 Jun 28 14:08 ..
lrwxrwxrwx   1 root root0 Jun 28 14:11 1210.phy ->
../../../../devices/platform/soc/1210.phy
lrwxrwxrwx   1 root root0 Jun 28 14:11 1250.phy ->
../../../../devices/platform/soc/1250.phy
--w---   1 root root 4096 Jun 28 14:11 bind
--w---   1 root root 4096 Jun 28 14:08 uevent
--w---   1 root root 4096 Jun 28 14:11 unbind
[root@archl-xu4m exynos5_usb3drd_phy]#
[root@archl-xu4m exynos5_usb3drd_phy]#
[root@archl-xu4m exynos5_usb3drd_phy]# echo 1250.phy > unbind
[  194.138492] [ cut here ]
[  194.142104] WARNING: CPU: 6 PID: 292 at
drivers/regulator/core.c:2036 _regulator_put.part.4+0x110/0x118
[  194.156913] Modules linked in: s5p_mfc s5p_jpeg exynos_gsc
v4l2_mem2mem v4l2_common videobuf2_dma_contig videobuf2_memops
videobuf2_v4l2 videobuf2_common videodev mc s5p_cec
[  194.171542] CPU: 6 PID: 292 Comm: bash Not tainted
5.2.0-rc6-next-20190626-xu4ml #21
[  194.178963] Hardware name: SAMSUNG EXYNOS 

[PATCH 0/3] Fix USB3.0 DRD PHY calibration issues (DWC3/XHCI) on Exynos542x SoCs

2019-06-27 Thread Marek Szyprowski
Dear All,

Commit d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for
exynos5420/5800") added support for Exynos5 USB3.0 DRD PHY calibration,
what enabled proper Super-Speed enumeration of USB3.0 devices connected
to various Exynos5 SoCs. After some time it turned out that the mentioned
patch worked a bit by pure luck and covered only one use case (fresh
boot with all drivers compiled into the kernel).

If drivers were compiled as modules, due to timing issue, it worked only
if XHCI-plat driver was loaded before the DWC3 driver:
https://patchwork.kernel.org/patch/10773947/

Also during the system suspend/resume cycle the calibration was not
performed at the proper time and resulted in switching USB 3.0 devices to
USB 2.0 high-speed compatibility mode.

This patch addresses all those issues. Exynos5 USB3.0 DRD PHY calibration
is moved to the Exynos5 specific variant of the XHCI-plat driver, which
takes care of proper PHY calibration after XHCI core reset. This fixes
all known use cases (XHCI driver compiled as module and loaded on demand
as well as during system suspend/resume cycle).

Here are the logs taken on Exynos5422-based Odroid HC1 board (with USB3.0
RTL8153 LAN and USB3.0 JMicron SATA-USB bridge):

Vanilla Linux next-20190620:
->8-
root@target:~# lsusb -t
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
|__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
|__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=exynos-ohci/3p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=exynos-ehci/3p, 480M
root@target:~# time rtcwake -s 10 -m mem
rtcwake: wakeup from "mem" using /dev/rtc0 at Tue Jan  1 01:03:40 2019
[   31.372801] PM: suspend entry (deep)
[   31.376555] Filesystems sync: 0.001 seconds
[   31.396437] Freezing user space processes ... (elapsed 0.006 seconds) done.
[   31.408300] OOM killer disabled.
[   31.411329] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) 
done.
[   31.419336] printk: Suspending console(s) (use no_console_suspend to debug)
[   31.508432] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   31.586243] wake enabled for irq 145
[   31.748908] samsung-pinctrl 1340.pinctrl: Setting external wakeup 
interrupt mask: 0xffef
[   31.758671] Disabling non-boot CPUs ...
[   31.772117] IRQ 51: no longer affine to CPU1
[   31.782147] IRQ 52: no longer affine to CPU2
[   31.789290] IRQ 53: no longer affine to CPU3
[   31.792439] IRQ 54: no longer affine to CPU4
[   31.794942] IRQ 55: no longer affine to CPU5
[   31.797365] IRQ 56: no longer affine to CPU6
[   31.801387] IRQ 57: no longer affine to CPU7
[   31.811149] Enabling non-boot CPUs ...
[   31.815607] CPU1 is up
[   31.818790] CPU2 is up
[   31.821709] CPU3 is up
[   31.826095] CPU4 is up
[   31.828672] CPU5 is up
[   31.831215] CPU6 is up
[   31.834158] CPU7 is up
[   31.859900] s3c2410-wdt 101d.watchdog: watchdog disabled
[   31.860158] usb usb1: root hub lost power or was reset
[   31.931175] usb usb2: root hub lost power or was reset
[   31.940717] wake disabled for irq 145
[   31.949146] usb usb3: root hub lost power or was reset
[   31.949235] usb usb4: root hub lost power or was reset
[   31.949329] s3c-rtc 101e.rtc: rtc disabled, re-enabling
[   31.950751] usb usb5: root hub lost power or was reset
[   31.950773] usb usb6: root hub lost power or was reset
[   36.201351] OOM killer enabled.
[   36.204381] Restarting tasks ...
[   36.206110] usb 4-1: USB disconnect, device number 2
[   36.206529] usb 6-1: USB disconnect, device number 2
[   36.210588] done.
[   36.220679] PM: suspend exit

real0m15.613s
user0m0.000s
sys 0m0.329s
[   36.237525] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[   36.254403] mmc_host mmc0: Bus speed (slot 0) = 5000Hz (slot req 
40Hz, actual 396825HZ div = 63)
root@target:~# [   36.341609] mmc_host mmc0: Bus speed (slot 0) = 2Hz 
(slot req 2Hz, actual 2HZ div = 0)
[   36.597244] usb 5-1: new high-speed USB device number 3 using xhci-hcd
[   36.837573] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: 
hostbyte=0x07 driverbyte=0x00
[   37.099089] usb 5-1: New USB device found, idVendor=0bda, idProduct=8153, 
bcdDevice=30.00
[   37.105793] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
[   37.112962] usb 5-1: Product: USB 10/100/1000 LAN
[   37.117629] usb 5-1: Manufacturer: Realtek
[   37.121645] usb 5-1: SerialNumber: 0100
[   37.373152] usb 5-1: reset high-speed USB device number 3 using xhci-hcd
[   37.407459] usb usb3-port1: Cannot enable. Maybe the USB cable is bad?
[   37.664128] r8152 5-1:1.0 eth0: v1.09.9
[