drm/nouveau: Handle u32 wrapping in nouveau_fence_done

The naive comparison

  if (fctx->read(chan) < fence->sequence)

to determine whether a fence is expired or not will fail when the
sequence number wraps around. Fix this by using a wrapping-safe
comparison.

Also wrap fctx->read as nouveau_fence_current in the nouveau_fence
interface to allow other nouveau components to monitor progress
(intended to be used in debug prints).

Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com>
drm/nouveau: Add nouveau_fence_compare

Add a new function for comparing two fences. The comparison uses
nouveau_fence_current as a reference value to handle wrapping correctly.

Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com>
drm/nouveau: Support sync framework

Add support for sync framework that allows us to pass fences between
kernel and user space.

Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com>
drm/nouveau: Support explicit synchronization

Add a new NOUVEAU_GEM_PUSHBUF_2 ioctl that accepts and emits a sync
fence fd from/to user space if the user space requests it by passing
corresponding flags.

Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com>