BACKPORT: drm: Simplify fb refcounting rules around ->update_plane

The introduction of primary planes has apparently caused a bit of fb
refcounting fun for people. That makes it a good time to clean up the
arcane rules and slight differences between ->update_plane and
->set_config. The new rules are:

- The core holds a reference for both the new and the old fb (if
  they're non-NULL of course) while calling into the driver through
  either ->update_plane or ->set_config.

- Drivers may not clobber plane->fb if their callback fails. If they
  do that, they need to store a pointer to the old fb in it again.
  When calling into the driver plane->fb still points at the current
  (old) framebuffer.

- The core will update the plane->fb pointer on success. Drivers can
  do that themselves too, but aren't required to any more for the
  primary plane.

- The core will update fb refcounts for the plane->fb pointer,
  presuming the drivers hold up their end of the bargain.

v2: Remove now unused tmpfb (Thierry)

v3: Drop broken changes from drm_mode_setplane (Ville). Also polish
the commit message a bit.

v4: Also fix up the handling of ->disable_plane in
drm_plane_force_disable. The issue was that we didn't save plane->fb
over the ->disable_plane call. Just paranoia, nothing relies on this.

v5: Keep still useful comments about directly calling ->set_config,
which I should have done for v4 already. Requested by Matt.

Cc: Thierry Reding <treding@nvidia.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 0fe27f063fcef920a0be93ad5e89d9c8ef5c5858)
Signed-off-by: David Sodman <dsodman@chromium.org>

Change-Id: I93c1259e4b1449e7f2b07359e3088374771c0a43
Reviewed-on: https://chromium-review.googlesource.com/222370
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Tested-by: David Sodman <dsodman@chromium.org>
Commit-Queue: David Sodman <dsodman@chromium.org>
BACKPORT: drm: convert plane to properties/state

Break the mutable state of a plane out into a separate structure
and use atomic properties mechanism to set plane attributes.  This
makes it easier to have some helpers for plane->set_property()
and for checking for invalid params.  The idea is that individual
drivers can wrap the state struct in their own struct which adds
driver specific parameters, for easy build-up of state across
multiple set_property() calls and for easy atomic commit or roll-
back.

The same should be done for CRTC, encoder, and connector, but this
patch only includes the first part (plane).

Signed-off-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit 05b7bd3c1c747f6f1de6729c73d76b8029e420f5)
Signed-off-by: David Sodman <dsodman@chromium.org>

[This change is an update to a9384e9d968613c4f313c71c483a59fd45c6507e
as a result of backporting 0fe27f063fcef920a0be93ad5e89d9c8ef5c5858]

Conflicts:
	drivers/gpu/drm/armada/armada_overlay.c
	drivers/gpu/drm/drm_crtc.c
	drivers/gpu/drm/drm_plane_helper.c
	drivers/gpu/drm/exynos/exynos_drm_plane.c
	drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
	drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
	drivers/gpu/drm/nouveau/dispnv04/overlay.c
	drivers/gpu/drm/omapdrm/omap_drv.c
	drivers/gpu/drm/omapdrm/omap_plane.c
	drivers/gpu/drm/rcar-du/rcar_du_plane.c
	include/drm/drm_crtc.h

Change-Id: I5ca79cd838311537345ddddc56a90bf3b1d5a89f
Reviewed-on: https://chromium-review.googlesource.com/212744
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Tested-by: David Sodman <dsodman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222372
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Commit-Queue: David Sodman <dsodman@chromium.org>
BACKPORT: drm: convert crtc to properties/state

Break the mutable state of a crtc out into a separate structure
and use atomic properties mechanism to set crtc attributes.  This
makes it easier to have some helpers for crtc->set_property()
and for checking for invalid params.  The idea is that individual
drivers can wrap the state struct in their own struct which adds
driver specific parameters, for easy build-up of state across
multiple set_property() calls and for easy atomic commit or roll-
back.

BUG=chromium:344930
TEST=test modeset, external monitor, general operation on daisy and
panther, ran bvt-inline on link & wolf, pass 100%

Signed-off-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit d07e1dbecfa44943d595add6ecd8d3bbda188f69)
Signed-off-by: David Sodman <dsodman@chromium.org>

dsodman: fixed fb reference counting in commit_plane_state( the case
of disabling the primary fb.

Conflicts:
	drivers/gpu/drm/armada/armada_crtc.c
	drivers/gpu/drm/drm_crtc.c
	drivers/gpu/drm/drm_irq.c
	drivers/gpu/drm/exynos/exynos_drm_crtc.c
	drivers/gpu/drm/gma500/cdv_intel_display.c
	drivers/gpu/drm/gma500/psb_intel_display.c
	drivers/gpu/drm/i915/intel_display.c
	drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
	drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
	drivers/gpu/drm/nouveau/dispnv04/crtc.c
	drivers/gpu/drm/nouveau/nv50_display.c
	drivers/gpu/drm/omapdrm/omap_crtc.c
	drivers/gpu/drm/omapdrm/omap_drv.c
	drivers/gpu/drm/qxl/qxl_display.c
	drivers/gpu/drm/radeon/radeon_display.c
	drivers/gpu/drm/rcar-du/rcar_du_crtc.c
	drivers/gpu/drm/tilcdc/tilcdc_crtc.c
	include/drm/drm_crtc.h

(cherry picked from commit 39fe18a2bf4c3d644b93533e335fdf64a05c68b5)
Signed-off-by: David Sodman <dsodman@chromium.org>

Conflicts:
	drivers/gpu/drm/omapdrm/omap_crtc.c

BACKPORT: drm: Fix up the atomic legacy paths so they work

BUG=chromium:336809
TEST=Tested on snow & peppy

BUG=chromium:344930
TEST=test modeset, external monitor, general operation on daisy and
panther

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit 271b0ca6bf73b379094f091ace0957ee91443e89)
Signed-off-by: David Sodman <dsodman@chromium.org>

(cherry picked from commit a575776575e2b5230f97935cb2864cdb20b53469)
Signed-off-by: David Sodman <dsodman@chromium.org>

Change-Id: I4c8cf98a64031ee486bd4ea5b24793e81260b217
Reviewed-on: https://chromium-review.googlesource.com/212745
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Tested-by: David Sodman <dsodman@chromium.org>
Commit-Queue: David Sodman <dsodman@chromium.org>
UPSTREAM: Revert "USBNET: ax88179_178a: enable tso if usb host supports sg dma"

This reverts commit 3804fad45411b48233b48003e33a78f290d227c8.

This commit, together with commit 247bf557273dd775505fb9240d2d152f4f20d304
"xhci 1.0: Limit arbitrarily-aligned scatter gather." were
origially added to get xHCI 1.0 hosts and usb ethernet ax88179_178a devices
working together with scatter gather. xHCI 1.0 hosts pose some requirement on how transfer
buffers are aligned, setting this requirement for 1.0 hosts caused USB 3.0 mass
storage devices to fail more frequently.

USB 3.0 mass storage devices used to work before 3.14-rc1.  Theoretically,
the TD fragment rules could have caused an occasional disk glitch.
Now the devices *will* fail, instead of theoretically failing.
>From a user perspective, this looks like a regression; the USB device obviously
fails on 3.14-rc1, and may sometimes silently fail on prior kernels.

The proper soluition is to implement the TD fragment rules for xHCI 1.0 hosts,
but for now, revert this patch until scatter gather can be properly supported.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 469d417b68958a064c09e7875646c97c6e783dfc)
Cherry-picked from torvalds/linux.git/master with no conflicts.

BUG=None
TEST=None

Change-Id: Icb7b01993febabb24241c875ba028b848f2dc151
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222641
Reviewed-by: Grant Grundler <grundler@chromium.org>
Merge branch 'chromeos-3.8' of https://chromium.googlesource.com/chromiumos/third_party/kernel into chromeos-3.8