serial: msm_geni_serial: Add checks against autosuspend

The framework functions implemented in the driver checks if the runtime
status of the device is active before attempting to access the core's
register space.
But if there is a pending autosuspend, then the runtime status will still
be active and it is possible for the core resources to be pulled away
while a framework function is attempting to access the core's registers.
This can crash the device.

In any control path pertaining to Rx or Tx detect a pending autosuspend
and bail out. This shouldn't cause any side-effects, if the function is
needed for a port close/cleanup the driver will call it after putting in
the correct runtime vote. So a framework call to do the same can be
ignored if there is a pending suspend.

In data path however, things are different, as a userspace write doesn't
block but an ioctl to vote clocks off will. So there is no guarantee of
order between a transmit (write from userspace) and a clock off request.
In such cases, add an additional check in the ioctl call to query the
framework buffer and any inflight transactions and delay before actually
removing the runtime vote.
Also when there is a framework call to transmit data, immediately put a
runtime vote in which is removed only when that transaction has completed.

Change-Id: I43bdc1ecb234e406bcd31c1296dec2ae379ef83b
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
1 file changed