BACKPORT: drm: Add reference counting to drm_atomic_state

drm_atomic_state has a complicated single owner model that tracks the
single reference from allocation through to destruction on another
thread - or perhaps on a local error path. We can simplify this tracking
by using reference counting (at a cost of a few more atomics). This is
even more beneficial when the lifetime of the state becomes more
convoluted than being passed to a single worker thread for the commit.

v2: Double check !intel atomic_commit functions for missing gets
v3: Update kerneldocs

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161014121833.439-27-chris@chris-wilson.co.uk
(cherry picked from commit 0853695c3ba46f97dfc0b5885f7b7e640ca212dd)
from topic/drm-misc-2016-10-24
Signed-off-by: Tarun <tarun.vyas@intel.com>

BUG=b:36446508
TEST=kmscube and relevant IGT tests along with no regressions

 Conflicts: [Tarun]

	[Retain HEAD for all of these drivers. The patch is trying to
	add atomic support for them.]
	drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
	drivers/gpu/drm/exynos/exynos_drm_drv.c
	drivers/gpu/drm/mediatek/mtk_drm_drv.c
	drivers/gpu/drm/msm/msm_atomic.c
	drivers/gpu/drm/omapdrm/omap_drv.c
	drivers/gpu/drm/rcar-du/rcar_du_kms.c
	drivers/gpu/drm/sti/sti_drv.c
	drivers/gpu/drm/tegra/drm.c
	drivers/gpu/drm/tilcdc/tilcdc_drv.c
	drivers/gpu/drm/vc4/vc4_kms.c

 Modified: [Tarun: Switch to using drm_atomic_state_get/put to prevent
		build breakage]
	drivers/gpu/drm/rockchip/rockchip_drm_fb.c

Change-Id: I3d287e8e3e24bc23297148b0d7064f472e5567d2
16 files changed