msm: vidc: Validate session_id in video hardware response

Validate session_id present in video hardware response
packet before processing it. This will avoid system reset
resulting from invalid session_id returned from video hardware.

Change-Id: I37525a3d10b5efe00734c5533931e2700f3c7513
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm: vidc: Skip session id validation for HFI_EVENT_SYS_ERROR

When SSR is triggered from driver, firmware is responding with session id
as 0X0000dead. Hence, firmware response is being discarded due to such
invalid session id. Skip session id validation for HFI_EVENT_SYS_ERROR
event type.

Change-Id: I750a7332baab4ebeb7702b49ffb744aae9803a36
CRs-Fixed: 539080
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
msm: vidc: fix corruption of registered buffer list

The buffer list for output buffers is accessed from
different threads leading to race conditions. Consider
the case of firmware throwing up a fatal error, which gets
propagated to v4l2 client. The v4l2 client closes the
driver fd, which will trigger msm_vidc_release_buffers
to release all output buffers and free node from
the registered buffer list. During this time, if
firmware sends a release reference event, the buffer
node being accessed in msm_vidc_release_buffers could
be freed, triggering kernel panic.

Change-Id: I522edff06a62dbc2ab60d6cca5990babb18d5c6c
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: Send ABORT in FLUSH command from the Client

When session error is sent to the client, client issues FLUSH
and release buffers commands. But as instance state is INVALID,
these commands are never sent to the firmware, instead FLUSH
DONE and Release buffer done are sent back to client even
though firmware might be working on these buffers which may
result into page faults.
This change fixes the issue by sending ABORT command to the
firmware at the time when driver receives FLUSH command. Then
firmware will release all buffers, clean up session and send
ABORT_DONE back to the driver.

Change-Id: Ie4c79a312d2336c68b858f5f5e2a85331cf55f7b
CRs-fixed: 592920
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
msm: vidc: reduce clk frquency before disable

The change ensures that the clock frequency is reduced to min
before we disable it.
With just clk_disable, rpm still votes for high voltage on CX
as venus vote is not removed.
To unvote, the frequency is set to min.

CRs-Fixed: 574365
Change-Id: I8e0515b9816f8c451d545443573afaba611aafe7
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
msm: vidc: avoid re-initialize of v4l2 spin lock

The fh_lock and fh_list variables are initialized
during probe in video_register_device. This was
re-initialized again when a new video instance was
opened. Since all video instances shared the same
fh_lock and fh_list variable, this gave rise to a race
condition in the v4l2 video driver. Consider the
case of multiple video instances being opened simultaneously.
One video instance has acquired the fh_lock and
calls a v4l2 function which calls v4l2_event_subscribe.
During this time another video instance is opened
and it re-intializes the fh_lock, so the first
instance no longer holds the spin lock and hits
ASSERT in v4l2_event_subscribed. This change
fixes the race condition.

Change-Id: I7af98c8f091cb94e6118c9e2ea1ba5d5d44c6833
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Merge branch 'cm-11.0' into kk_mkt