This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux: AM335x kernel crash on USB suspend

Tool/software: Linux

Hello TI E2E experts,

I am using Linux 4.9.xx on Am335x. Kernel crashes while entering to low power mode (deepsleep/suspend) in CPPI41 driver.

steps to reproduce

  • modprobe -r musb_dsps
  • echo mem > /sys/power/state

This line of the code which crashes due to USBSS is disabled. however it works in older kernel version such as 4.1.

cdd->dma_tdfdq = cppi_readl(cdd->ctrl_mem + DMA_TDFDQ); 

Any comments /? 

Thanks  

  • Ravikiran,

    Linux kernel v4.9 added runtime power management in musb/cppi drivers, there might be a bug which causes the crash you saw. Let me first try to reproduce it on my side and understand why the crash happens.

    Can you please explain why you want to remove musb_dsps driver before entering low power mode?
  • Bin,

    Thanks for the quick reply.

    I have disabled the runtime power-management as described in your other post by setting auto suspend delay to -1.
    pm_runtime_set_autosuspend_delay(dev, -1);

    Can you please explain why you want to remove musb_dsps driver before entering low power mode?
    1. This is required for me because, I don't want my device to wakeup from deep-sleep on USB insertion.
    2. I don't want any USB devices to draw power from my USB port during deepsleep. 

    I have noticed that USB port is powered within 10 seconds if device connected during deepsleep. Also I noticed few musb crashes if my AM335 sleeps when USB device connected.


    Below approach seems to work for me. But I know this is not clean code.
    static int __maybe_unused cppi41_suspend(struct device *dev)
    {
    struct cppi41_dd *cdd = dev_get_drvdata(dev);
    void __iomem *regs;
    u32 clk_rate;

    /*** added this ***/
    clkp = clk_get(NULL,"usbotg_fck");
    clk_enable(clkp);
    clk_rate = clk_get_rate(clkp);
    regs = ioremap_nocache(0x44E0001C, 4);
    *(unsigned int *)regs = 0x02;//enable
    /*** done with add ***/

    cdd->dma_tdfdq = cppi_readl(cdd->ctrl_mem + DMA_TDFDQ);
    disable_sched(cdd);

    /*** added this ***/
    *(unsigned int *)regs = 0x70000;
    clk_disable(clkp);
    clk_put(clkp);
    iounmap(regs);
    /*** done with add ***/
    return 0;
    }

    Please can you suggest where to fix this correctly.

    Thanks

  • Ravikiran,

    Please use the following command before "modprobe -r musb-dsps" to keep cppi clock on.

    # echo on > /sys/devices/platform/ocp/47400000.usb/47400000.dma-controller/power/control

    Please let me if this solves the issue.

  • HI Bin Liu,

    It works only once !

    i.e. I can suspend and resume once. If I try to sleep second time (without re-inserting musb_dsps) kernel crashes. Please fidn the crash logs below.

    I have noticed that for the first time when musb_dsps is removed, register 0x44E0001C value is 0x02. (since I did echo on > /sys/devices/platform/ocp/47400000.usb/47400000.dma-controller/power/control )

    But, on wakeyou this regiser value changes to 0x7000 and kernel crashes again on next suspend !

    (cppi41_suspend [cppi41]) from [<c04b4130>] (dpm_run_callback+0x34/0xc8)
    [  194.413373] [<c04b40fc>] (dpm_run_callback) from [<c04b4d64>] (__device_suspend_late+0xe8/0x22c)
    [  194.422240]  r9:c0a2a39c r8:dde4427c r6:c0a6c20c r5:dde44210 r4:00000000
    [  194.429000] [<c04b4c7c>] (__device_suspend_late) from [<c04b6060>] (dpm_suspend_late+0x118/0x24c)
    [  194.437953]  r7:c0a2a378 r6:c0a6c20c r5:c0a2a378 r4:dde44210
    [  194.443673] [<c04b5f48>] (dpm_suspend_late) from [<c015f6e8>] (suspend_devices_and_enter+0x1c0/0x554)
    [  194.452978]  r10:c0a028c0 r9:c0a3e5c0 r8:c0a3e5d4 r7:c0a3e5e8 r6:c0a3e5d4 r5:00000003
    [  194.460878]  r4:00000000
    [  194.463443] [<c015f528>] (suspend_devices_and_enter) from [<c015fce0>] (pm_suspend+0x264/0x300)
    [  194.472222]  r10:dc49118c r9:dc491200 r8:00000004 r7:c0a3e5e8 r6:00000000 r5:c0a3e5e0
    [  194.480122]  r4:00000003
    [  194.482687] [<c015fa7c>] (pm_suspend) from [<c015e74c>] (state_store+0x6c/0xc0)
    [  194.490065]  r6:00000003 r5:c086be8c r4:00000003
    [  194.494730] [<c015e6e0>] (state_store) from [<c03ed518>] (kobj_attr_store+0x1c/0x28)
    [  194.502548]  r9:00000000 r8:00000000 r7:dc491200 r6:ddf0bf80 r5:00000004 r4:c03ed4fc
    [  194.510374] [<c03ed4fc>] (kobj_attr_store) from [<c0299f0c>] (sysfs_kf_write+0x48/0x4c)
    [  194.518456] [<c0299ec4>] (sysfs_kf_write) from [<c0299690>] (kernfs_fop_write+0xf8/0x200)
    [  194.526707]  r5:00000004 r4:dc491180
    [  194.530323] [<c0299598>] (kernfs_fop_write) from [<c021ddc8>] (__vfs_write+0x30/0x120)
    [  194.538317]  r10:00000000 r9:ddf0a000 r8:00000004 r7:ddf0bf80 r6:b6fcb000 r5:ddf0bf80

    Steps to reproduce:

    echo on > /sys/devices/platform/ocp/47400000.usb/47400000.dma-controller/power/control
    modprobe -r musb_dsps

    0x44E0001C  value is 0x02
    rtcwake -m 'mem' -s 5          --> worked here
    0x44E0001C  value is 0x02
    rtcwake -m 'mem' -s 5          --> worked here
    0x44E0001C  value is 0x70000
    rtcwake -m 'mem' -s 5         --> crashes on suspend

    Thanks

  • HI Bin Liu,

    Some one marked it as resolved !
    but, issue still exists. Kindly look at this,

    Thanks
  • Hi Bin Liu.,
    Any suggestions ?
  • Ravikiran,

    I don't see the problem on my side, I can do rtcwake many times without such kernel crash.

    Everytime before you put the system into suspend mode, please check the following sysfs entries

    - /sys/devices/platform/ocp/47400000.usb/47400000.dma-controller/power/runtime_status

    if it is "suspended", ensure the following entry is "on", not "auto".

    - /sys/devices/platform/ocp/47400000.usb/47400000.dma-controller/power/control