Skip to content
  • Andy Shevchenko's avatar
    serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485() · ddd80608
    Andy Shevchenko authored
    commit b3965767d86cf4534dfe1affbde0453d3224ed7f upstream.
    
    There are calls to serial8250_rpm_{get|put}() in __do_stop_tx_rs485() that are
    certainly placed in a wrong location. I dunno how it had been tested with
    runtime PM enabled because it is obvious "sleep in atomic context" error.
    
    Besides that serial8250_rpm_get() is called immediately after an IO just
    happened. It implies that the device is already powered on, see implementation
    of serial8250_em485_rts_after_send() and serial8250_clear_fifos() for the
    details.
    
    There is no bug have been seen due to, as I can guess, use of auto suspend mode
    when scheduled transaction to suspend is invoked quite lately than it's needed
    for a few writes to the port. It might be possible to trigger a warning if
    stop_tx_timer fires when device is suspended.
    
    Refactor the code to use runtime PM only in case of timer function.
    
    Fixes: 0c66940d
    
     ("tty/serial/8250: fix RS485 half-duplex RX")
    Cc: "Matwey V. Kornilov" <matwey@sai.msu.ru>
    Tested-by: default avatarYegor Yefremov <yegorslists@googlemail.com>
    Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    ddd80608