minigbm: add buffer invalidation function

We may need to invalidate a buffer before reading it. Some use
cases are:

	- DRM_IOCTL_I915_GEM_SET_DOMAIN
        - DMA_BUF_IOCTL_SYNC with the SYNC_START option
        - DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST

This patch adds the function hook.

BUG=chromium:764871
TEST=compiles

Change-Id: I85811407252b859a12294381c65ff3545424636b
Reviewed-on: https://chromium-review.googlesource.com/710322
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
diff --git a/drv.c b/drv.c
index 6094ad5..3ea46e6 100644
--- a/drv.c
+++ b/drv.c
@@ -423,6 +423,7 @@
 	drmHashInsert(bo->drv->map_table, bo->handles[plane].u32, (void *)data);
 
 success:
+	drv_bo_invalidate(bo, data);
 	*map_data = data;
 	offset = drv_bo_get_plane_stride(bo, plane) * y;
 	offset += drv_stride_from_format(bo->format, x, plane);
@@ -452,6 +453,18 @@
 	return ret;
 }
 
+int drv_bo_invalidate(struct bo *bo, struct map_info *data)
+{
+	int ret = 0;
+	assert(data);
+	assert(data->refcount >= 0);
+
+	if (bo->drv->backend->bo_invalidate)
+		ret = bo->drv->backend->bo_invalidate(bo, data);
+
+	return ret;
+}
+
 int drv_bo_flush(struct bo *bo, struct map_info *data)
 {
 	int ret = 0;