vcrtcm: change log message to debug

Now that the PIMs are doing frequent wait_fb() calls, these log messages
need to be changed to debug, to prevent tons of log messages.

Signed-off-by: Martin Carroll <martin.carroll@alcatel-lucent.com>
drm/radeon/kms: check if push fence exists before waiting

Push fence may not necessarily exist because CRTC can be attached
but userspace may decide not to associate the buffer with it.
If buffer does not exist, then the push buffer does not exist
and neither does the push-fence. Hence, we have to check before
we wait.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: do not start generating if we have no minor

video_drvdata can return NULL and should better not use
that pointer.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: no need to store minor pointer in private data

We are already getting it through video_drvdata() function.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: change signatures of xxx_generating functions

Instead of pushing the file descriptor, push the minor
pointer instead and presume the caller to check that
it's valid (i.e. not NULL).

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: remove spurious blank lines

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: always check the return value of video_drvdata

video_drvdata, can return NULL for a minor pointer, so always
check it and return the appropriate error.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: remove redundant call to videobuf_streamoff

v4l2pim_stop_generating already calls videobuf_stop,
which in turn calles videobuf_streamoff. Explicit
call from v4l2pim driver is redundant.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: add system call counter

We have a subtle race condition between v4l2pim_release
function and all other system calls that touch videobuf queue.
To resolve it, we will need an indicator whether we are in a
(videobuf-affecting) system call or not. So each time we enter
a system call that touches videobuf we increment an atomic
counter and decrement it before we leave. The value
of the counter tells us how many videobuf-affecting
system calls are in progress at any time.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: change the name of generating flag to status

We are about to add more status flags, so rather than adding
a new field for each one, we reuse the existing 'generating' field.
We rename it to 'status' and call bit 0 of that field a "GENERATING"
flag.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: eliminate some unecessary initializations

minor struct is kzalloc-ed, so there is no need to
initialize the fields to 0 or NULL.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: simplify some names of local symbols

We have a few local (declared as static) symbols that are
quite a low-level and that have somewhat long names. Simplify
them by removing v4l2pim prefix from them.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: remove module_get and module put from open and release

open and release system calls should not explicitly call
module_get and module_put. Module references are handled by
the kernel before the control reaches the driver-specific code.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: add active status bit

New status bit indicates that there is an opener on the
video device. We use it for two purposes: First is
to ensure that there is only one opener at the time. Second
is to bail out of the system call early if there is a
closing (which may occur asynchronously) in progress.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: make sure all system calls are done when releasing

When v4l2pim_release is called (which could be asynchronous),
we must make sure that all other system calls have finished
(some may be blocked waiting for queue) before cleaning up.
This prevents pulling the rug underneath the driver when
the process using the video device is killed.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: remove mlock

minor->mlock mutex is not used for anything. It is passed to
videobuf as an external lock, which (given that it's unused
in v4l2pim driver) renders all videbuf calls unlocked. Remove
it and let the videobuf use its internal lock for its own
business.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: do not vfree what we did not allocate

If we don't have the videobuf (which can happen in various
error cases), we should not attempt to free it.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: fix the error handling path in v4l2pim_create_minor

Quite a few things were not correctly cleaned up in case of
a failure.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: remove unused fields and related code

enabled_queue, xmit_sync_queue and workqueue fields in
the minor structure aren't used for anything.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: reset the buffer size if allocation fails

This way we don't lie about the buffer size. Also all
other fields, should not be populated until we are
sure that we have the buffer.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>