serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 31 Aug 2016 16:46:55 +0000 (19:46 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Sep 2016 13:03:35 +0000 (15:03 +0200)
commitb3965767d86cf4534dfe1affbde0453d3224ed7f
tree64d94878500dd9fa8755ade0016a9ed78c2a29f6
parent1c06bde643d0a0b17f117539e961300cad69aad3
serial: 8250_port: fix runtime PM use in __do_stop_tx_rs485()

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: 0c66940d584d ("tty/serial/8250: fix RS485 half-duplex RX")
Cc: "Matwey V. Kornilov" <matwey@sai.msu.ru>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_port.c