vcrtcm: allow detach PIM function to fail

Some PIMs can fail on detach and the failure should be communicated
back to the user space application trying to detach. Specific example
is v4l2pim that attaches to a CRTC and creates a new v4l2 device
that an application can open. If a detach request comes in while
the video device is open, it is very hard (almost impossible) to
properly cleanup the state. In this situation, detach should fail
(typically returning -EBUSY).

To support this use case, modify detach method to allow failure
and pass the error code. PIMs that cannot fail on detach, should
simply return 0.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: return 0 in detach function

Detach function is allowed to fail now. UDLPIM detach doesn't
fail, so just return 0 to reconcile the function signature.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: return 0 in detach function

Detach function can fail now. V4L2PIM can fail if there is an
open file descriptor on the associated video device (should
return -EBUSY), but that will be added in follow-up
patches. For now, this only reconciles the function signature
(i.e., silences out a warning) without changing the
functionality.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
vcrtcm: add functions to export push buffers to PRIME

In the new scheme of things, VCRTCM will no longer ask the GPU
to create a push buffer for it (i.e., the pb_alloc call in GPU
will no longer be used) but instead PCON will create its backing
store and map it such that it can access its data (which is
PCON-dependent). Then PCON would call a VCRTCM function to export
the buffer using DMA-BUF sharing infrastructure, followed by
calling DRM/PRIME function to turn the buffer into a GEM object
to which the GPU's push function can copy the pixels.

This patch adds two new GPU methods (and a bunch of supporting code)
that PCONs will call to register and unregister the push buffers with
PRIME.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
drm/radeon: rename HAL to PCON at few places

When we switched to new naming there were still a few printk
statements and a few comments in which HAL remained HAL instead
of being renamed to PCON. Fix it.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
vcrtcm: make kernel logging macros universal

Eliminate vcrtcm-specific code from VCRTCM kernel logging macros
(i.e., VCRTCM_INFO and friends), universal and move the containing
.h file (vcrtcm_utils.h) into the system-wide include directory.

This will allow us to eliminate private kernel logging macros
from all PIMs and use VCRTCM_XXX macros instead. It will also unify
the message format across all PIMs.

Macros are "smart" enough to know which module invoked them and
properly log the module name.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
vcrtcm: add memory manipulation utilities

All PIMs do mostly the same thing when it comes to allocating
memory. They either want a page, a group of pages, a chunk of
continuous memory in vmalloc region or a chunk of continuous
memory for kernel's use (kmalloc).

While doing that they also use their own counters that come
handy when debugging memory leaks. Rather than repeating all
this code in each PIM, we factor out common functions into
VCRTCM and export them to PIMs.

This patch is a prep for eliminating a bunch of repeated
code from PIMs.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: use common utilities from vcrtcm module

Eliminated PIM-sepcific logging macros and memory manipulation
functions and switched to using the ones exported by VCRTCM module.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: remove a spurious warning

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: use common utilities from vcrtcm module

Eliminated PIM-sepcific logging macros and memory manipulation
functions and switched to using the ones exported by VCRTCM module.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: fix an annoying line break

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: rework buffer alloc functions to use PRIME

Allocate and map backing store for push buffers (pages in main
memory to which pixels are pushed) and call vcrtcm function to
export the push buffer to PRIME infrastructure.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: factor out repeated push buffer alloc code

The code that determined whether to allocate a new
buffer or reuse the old one in udlpim_set_fb and
udlpim_set_cursor was repeated.

Factor it out into a new function udlpim_realloc_pb
and call it from the aforementioned functions.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: no not utter function names in debug log

Debug log macros already put in the function names from which
they were called, so there is no need to utter them explicitly
in the log string.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
udlpim: cleanup some ugly line breaks

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

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: rework buffer alloc functions to use PRIME

Allocate and map backing store for push buffers (pages in main
memory to which pixels are pushed) and call vcrtcm function to
export the push buffer to PRIME infrastructure.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: cleanup some ugly line breaks

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: factor out repeated push buffer alloc code

The code that determined whether to allocate a new
buffer or reuse the old one in v4l2pim_set_fb and
v4l2pim_set_cursor was repeated.

Factor it out into a new function v4l2pim_realloc_pb
and call it from the aforementioned functions.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
v4l2pim: no not utter function names in debug log

Debug log macros already put in the function names from which
they were called, so there is no need to utter them explicitly
in the log string.

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