• Tony Lindgren's avatar
    serial: core: Fix checks for tx runtime PM state · 81a61051
    Tony Lindgren authored
    Maximilian reported that surface_serial_hub serdev tx does not work during
    system suspend. During system suspend, runtime PM gets disabled in
    __device_suspend_late(), and tx is unable to wake-up the serial core port
    device that we use to check if tx is safe to start. Johan summarized the
    regression noting that serdev tx no longer always works as earlier when the
    serdev device is runtime PM active.
    
    The serdev device and the serial core controller devices are siblings of
    the serial port hardware device. The runtime PM usage count from serdev
    device does not propagate to the serial core device siblings, it only
    propagates to the parent.
    
    In addition to the tx issue for suspend, testing for the serial core port
    device can cause an unnecessary delay in enabling tx while waiting for the
    serial core port device to wake-up. The serial core port device wake-up is
    only needed to flush pending tx when the serial port hardware device was
    in runtime PM suspended state.
    
    To fix the regression, we need to check the runtime PM state of the parent
    serial port hardware device for tx instead of the serial core port device.
    
    As the serial port device drivers may or may not implement runtime PM, we
    need to also add a check for pm_runtime_enabled().
    Reported-by: default avatarMaximilian Luz <luzmaximilian@gmail.com>
    Cc: stable <stable@kernel.org>
    Fixes: 84a9582f ("serial: core: Start managing serial controllers to enable runtime PM")
    Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
    Tested-by: default avatarMaximilian Luz <luzmaximilian@gmail.com>
    Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20231005075644.25936-1-tony@atomide.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    81a61051
serial_core.c 91.4 KB