diff options
| -rw-r--r-- | drivers/gpu/drm/armada/armada_gem.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/ast/ast_drv.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/bochs/bochs.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/cirrus/cirrus_drv.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_gem.c | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_info.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_prime.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/gma500/gtt.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/mgag200/mgag200_drv.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/msm/msm_drv.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_drv.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/qxl/qxl_drv.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_drv.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/tegra/gem.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/udl/udl_drv.h | 1 | ||||
| -rw-r--r-- | include/drm/drmP.h | 148 | ||||
| -rw-r--r-- | include/drm/drm_gem.h | 183 | ||||
| -rw-r--r-- | include/drm/drm_gem_cma_helper.h | 1 |
22 files changed, 216 insertions, 147 deletions
diff --git a/drivers/gpu/drm/armada/armada_gem.h b/drivers/gpu/drm/armada/armada_gem.h index 00b6cd461a03..b000ea3a829a 100644 --- a/drivers/gpu/drm/armada/armada_gem.h +++ b/drivers/gpu/drm/armada/armada_gem.h | |||
| @@ -8,6 +8,8 @@ | |||
| 8 | #ifndef ARMADA_GEM_H | 8 | #ifndef ARMADA_GEM_H |
| 9 | #define ARMADA_GEM_H | 9 | #define ARMADA_GEM_H |
| 10 | 10 | ||
| 11 | #include <drm/drm_gem.h> | ||
| 12 | |||
| 11 | /* GEM */ | 13 | /* GEM */ |
| 12 | struct armada_gem_object { | 14 | struct armada_gem_object { |
| 13 | struct drm_gem_object obj; | 15 | struct drm_gem_object obj; |
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 7485ff945ca9..86205a28e56b 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h | |||
| @@ -36,6 +36,8 @@ | |||
| 36 | #include <drm/ttm/ttm_memory.h> | 36 | #include <drm/ttm/ttm_memory.h> |
| 37 | #include <drm/ttm/ttm_module.h> | 37 | #include <drm/ttm/ttm_module.h> |
| 38 | 38 | ||
| 39 | #include <drm/drm_gem.h> | ||
| 40 | |||
| 39 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
| 40 | #include <linux/i2c-algo-bit.h> | 42 | #include <linux/i2c-algo-bit.h> |
| 41 | 43 | ||
diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h index 4f6e7b3a3635..71f2687fc3cc 100644 --- a/drivers/gpu/drm/bochs/bochs.h +++ b/drivers/gpu/drm/bochs/bochs.h | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #include <drm/drm_crtc_helper.h> | 7 | #include <drm/drm_crtc_helper.h> |
| 8 | #include <drm/drm_fb_helper.h> | 8 | #include <drm/drm_fb_helper.h> |
| 9 | 9 | ||
| 10 | #include <drm/drm_gem.h> | ||
| 11 | |||
| 10 | #include <ttm/ttm_bo_driver.h> | 12 | #include <ttm/ttm_bo_driver.h> |
| 11 | #include <ttm/ttm_page_alloc.h> | 13 | #include <ttm/ttm_page_alloc.h> |
| 12 | 14 | ||
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h index dd2cfc9024aa..d44e69daa239 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.h +++ b/drivers/gpu/drm/cirrus/cirrus_drv.h | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | #include <drm/ttm/ttm_memory.h> | 21 | #include <drm/ttm/ttm_memory.h> |
| 22 | #include <drm/ttm/ttm_module.h> | 22 | #include <drm/ttm/ttm_module.h> |
| 23 | 23 | ||
| 24 | #include <drm/drm_gem.h> | ||
| 25 | |||
| 24 | #define DRIVER_AUTHOR "Matthew Garrett" | 26 | #define DRIVER_AUTHOR "Matthew Garrett" |
| 25 | 27 | ||
| 26 | #define DRIVER_NAME "cirrus" | 28 | #define DRIVER_NAME "cirrus" |
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index f9af78541505..cd45e45e2cce 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <linux/dma-buf.h> | 38 | #include <linux/dma-buf.h> |
| 39 | #include <drm/drmP.h> | 39 | #include <drm/drmP.h> |
| 40 | #include <drm/drm_vma_manager.h> | 40 | #include <drm/drm_vma_manager.h> |
| 41 | #include <drm/drm_gem.h> | ||
| 41 | #include "drm_internal.h" | 42 | #include "drm_internal.h" |
| 42 | 43 | ||
| 43 | /** @file drm_gem.c | 44 | /** @file drm_gem.c |
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c index 0780541f7935..51efebd434f3 100644 --- a/drivers/gpu/drm/drm_info.c +++ b/drivers/gpu/drm/drm_info.c | |||
| @@ -35,6 +35,8 @@ | |||
| 35 | 35 | ||
| 36 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
| 37 | #include <drm/drmP.h> | 37 | #include <drm/drmP.h> |
| 38 | #include <drm/drm_gem.h> | ||
| 39 | |||
| 38 | #include "drm_legacy.h" | 40 | #include "drm_legacy.h" |
| 39 | 41 | ||
| 40 | /** | 42 | /** |
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 2807a771f505..7826de9da276 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | #include <linux/export.h> | 29 | #include <linux/export.h> |
| 30 | #include <linux/dma-buf.h> | 30 | #include <linux/dma-buf.h> |
| 31 | #include <drm/drmP.h> | 31 | #include <drm/drmP.h> |
| 32 | #include <drm/drm_gem.h> | ||
| 33 | |||
| 32 | #include "drm_internal.h" | 34 | #include "drm_internal.h" |
| 33 | 35 | ||
| 34 | /* | 36 | /* |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h index 09d021bbccf5..ec58fe9c40df 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #ifndef _EXYNOS_DRM_GEM_H_ | 12 | #ifndef _EXYNOS_DRM_GEM_H_ |
| 13 | #define _EXYNOS_DRM_GEM_H_ | 13 | #define _EXYNOS_DRM_GEM_H_ |
| 14 | 14 | ||
| 15 | #include <drm/drm_gem.h> | ||
| 16 | |||
| 15 | #define to_exynos_gem_obj(x) container_of(x,\ | 17 | #define to_exynos_gem_obj(x) container_of(x,\ |
| 16 | struct exynos_drm_gem_obj, base) | 18 | struct exynos_drm_gem_obj, base) |
| 17 | 19 | ||
diff --git a/drivers/gpu/drm/gma500/gtt.h b/drivers/gpu/drm/gma500/gtt.h index f5860a739bd8..cdbb350c9d5d 100644 --- a/drivers/gpu/drm/gma500/gtt.h +++ b/drivers/gpu/drm/gma500/gtt.h | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #define _PSB_GTT_H_ | 21 | #define _PSB_GTT_H_ |
| 22 | 22 | ||
| 23 | #include <drm/drmP.h> | 23 | #include <drm/drmP.h> |
| 24 | #include <drm/drm_gem.h> | ||
| 24 | 25 | ||
| 25 | /* This wants cleaning up with respect to the psb_dev and un-needed stuff */ | 26 | /* This wants cleaning up with respect to the psb_dev and un-needed stuff */ |
| 26 | struct psb_gtt { | 27 | struct psb_gtt { |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 88a8b72b553e..19c0dd8e255e 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | #include <linux/i2c-algo-bit.h> | 43 | #include <linux/i2c-algo-bit.h> |
| 44 | #include <drm/intel-gtt.h> | 44 | #include <drm/intel-gtt.h> |
| 45 | #include <drm/drm_legacy.h> /* for struct drm_dma_handle */ | 45 | #include <drm/drm_legacy.h> /* for struct drm_dma_handle */ |
| 46 | #include <drm/drm_gem.h> | ||
| 46 | #include <linux/backlight.h> | 47 | #include <linux/backlight.h> |
| 47 | #include <linux/hashtable.h> | 48 | #include <linux/hashtable.h> |
| 48 | #include <linux/intel-iommu.h> | 49 | #include <linux/intel-iommu.h> |
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index c03e347f3ffd..e9eea1d4e7c3 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h | |||
| @@ -22,6 +22,8 @@ | |||
| 22 | #include <drm/ttm/ttm_memory.h> | 22 | #include <drm/ttm/ttm_memory.h> |
| 23 | #include <drm/ttm/ttm_module.h> | 23 | #include <drm/ttm/ttm_module.h> |
| 24 | 24 | ||
| 25 | #include <drm/drm_gem.h> | ||
| 26 | |||
| 25 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
| 26 | #include <linux/i2c-algo-bit.h> | 28 | #include <linux/i2c-algo-bit.h> |
| 27 | 29 | ||
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 8a2c5fd0893e..afaafd42dee7 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h | |||
| @@ -51,6 +51,7 @@ static inline struct device *msm_iommu_get_ctx(const char *ctx_name) | |||
| 51 | #include <drm/drm_crtc_helper.h> | 51 | #include <drm/drm_crtc_helper.h> |
| 52 | #include <drm/drm_fb_helper.h> | 52 | #include <drm/drm_fb_helper.h> |
| 53 | #include <drm/msm_drm.h> | 53 | #include <drm/msm_drm.h> |
| 54 | #include <drm/drm_gem.h> | ||
| 54 | 55 | ||
| 55 | struct msm_kms; | 56 | struct msm_kms; |
| 56 | struct msm_gpu; | 57 | struct msm_gpu; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h index ae95b2d43b36..f238def41a92 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.h +++ b/drivers/gpu/drm/nouveau/nouveau_bo.h | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #ifndef __NOUVEAU_BO_H__ | 1 | #ifndef __NOUVEAU_BO_H__ |
| 2 | #define __NOUVEAU_BO_H__ | 2 | #define __NOUVEAU_BO_H__ |
| 3 | 3 | ||
| 4 | #include <drm/drm_gem.h> | ||
| 5 | |||
| 4 | struct nouveau_channel; | 6 | struct nouveau_channel; |
| 5 | struct nouveau_fence; | 7 | struct nouveau_fence; |
| 6 | struct nouveau_vma; | 8 | struct nouveau_vma; |
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 84d73a61b34b..60e47b33c801 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <drm/drmP.h> | 26 | #include <drm/drmP.h> |
| 27 | #include <drm/drm_crtc_helper.h> | 27 | #include <drm/drm_crtc_helper.h> |
| 28 | #include <drm/omap_drm.h> | 28 | #include <drm/omap_drm.h> |
| 29 | #include <drm/drm_gem.h> | ||
| 29 | #include <linux/platform_data/omap_drm.h> | 30 | #include <linux/platform_data/omap_drm.h> |
| 30 | 31 | ||
| 31 | 32 | ||
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index d75c0a9f674f..ff0772728eb0 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h | |||
| @@ -43,6 +43,8 @@ | |||
| 43 | #include <ttm/ttm_placement.h> | 43 | #include <ttm/ttm_placement.h> |
| 44 | #include <ttm/ttm_module.h> | 44 | #include <ttm/ttm_module.h> |
| 45 | 45 | ||
| 46 | #include <drm/drm_gem.h> | ||
| 47 | |||
| 46 | /* just for ttm_validate_buffer */ | 48 | /* just for ttm_validate_buffer */ |
| 47 | #include <ttm/ttm_execbuf_util.h> | 49 | #include <ttm/ttm_execbuf_util.h> |
| 48 | 50 | ||
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 82b0e11ade89..ef91ebb7c671 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
| @@ -74,6 +74,8 @@ | |||
| 74 | #include <ttm/ttm_module.h> | 74 | #include <ttm/ttm_module.h> |
| 75 | #include <ttm/ttm_execbuf_util.h> | 75 | #include <ttm/ttm_execbuf_util.h> |
| 76 | 76 | ||
| 77 | #include <drm/drm_gem.h> | ||
| 78 | |||
| 77 | #include "radeon_family.h" | 79 | #include "radeon_family.h" |
| 78 | #include "radeon_mode.h" | 80 | #include "radeon_mode.h" |
| 79 | #include "radeon_reg.h" | 81 | #include "radeon_reg.h" |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index dd082049fd5b..de108427a197 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
| @@ -38,6 +38,8 @@ | |||
| 38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
| 39 | #include <linux/pm_runtime.h> | 39 | #include <linux/pm_runtime.h> |
| 40 | #include <linux/vga_switcheroo.h> | 40 | #include <linux/vga_switcheroo.h> |
| 41 | #include <drm/drm_gem.h> | ||
| 42 | |||
| 41 | #include "drm_crtc_helper.h" | 43 | #include "drm_crtc_helper.h" |
| 42 | /* | 44 | /* |
| 43 | * KMS wrapper. | 45 | * KMS wrapper. |
diff --git a/drivers/gpu/drm/tegra/gem.h b/drivers/gpu/drm/tegra/gem.h index 43a25c853357..6538b56780c2 100644 --- a/drivers/gpu/drm/tegra/gem.h +++ b/drivers/gpu/drm/tegra/gem.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | #include <drm/drm.h> | 16 | #include <drm/drm.h> |
| 17 | #include <drm/drmP.h> | 17 | #include <drm/drmP.h> |
| 18 | #include <drm/drm_gem.h> | ||
| 18 | 19 | ||
| 19 | #define TEGRA_BO_BOTTOM_UP (1 << 0) | 20 | #define TEGRA_BO_BOTTOM_UP (1 << 0) |
| 20 | 21 | ||
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index 51e10ee77f39..c7490a2489a7 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #define UDL_DRV_H | 15 | #define UDL_DRV_H |
| 16 | 16 | ||
| 17 | #include <linux/usb.h> | 17 | #include <linux/usb.h> |
| 18 | #include <drm/drm_gem.h> | ||
| 18 | 19 | ||
| 19 | #define DRIVER_NAME "udl" | 20 | #define DRIVER_NAME "udl" |
| 20 | #define DRIVER_DESC "DisplayLink" | 21 | #define DRIVER_DESC "DisplayLink" |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 6656fd7d64d4..d2c2b7f3a4e2 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
| @@ -82,6 +82,7 @@ struct drm_agp_head; | |||
| 82 | struct drm_local_map; | 82 | struct drm_local_map; |
| 83 | struct drm_device_dma; | 83 | struct drm_device_dma; |
| 84 | struct drm_dma_handle; | 84 | struct drm_dma_handle; |
| 85 | struct drm_gem_object; | ||
| 85 | 86 | ||
| 86 | struct device_node; | 87 | struct device_node; |
| 87 | struct videomode; | 88 | struct videomode; |
| @@ -331,93 +332,6 @@ struct drm_lock_data { | |||
| 331 | }; | 332 | }; |
| 332 | 333 | ||
| 333 | /** | 334 | /** |
| 334 | * This structure defines the drm_mm memory object, which will be used by the | ||
| 335 | * DRM for its buffer objects. | ||
| 336 | */ | ||
| 337 | struct drm_gem_object { | ||
| 338 | /** Reference count of this object */ | ||
| 339 | struct kref refcount; | ||
| 340 | |||
| 341 | /** | ||
| 342 | * handle_count - gem file_priv handle count of this object | ||
| 343 | * | ||
| 344 | * Each handle also holds a reference. Note that when the handle_count | ||
| 345 | * drops to 0 any global names (e.g. the id in the flink namespace) will | ||
| 346 | * be cleared. | ||
| 347 | * | ||
| 348 | * Protected by dev->object_name_lock. | ||
| 349 | * */ | ||
| 350 | unsigned handle_count; | ||
| 351 | |||
| 352 | /** Related drm device */ | ||
| 353 | struct drm_device *dev; | ||
| 354 | |||
| 355 | /** File representing the shmem storage */ | ||
| 356 | struct file *filp; | ||
| 357 | |||
| 358 | /* Mapping info for this object */ | ||
| 359 | struct drm_vma_offset_node vma_node; | ||
| 360 | |||
| 361 | /** | ||
| 362 | * Size of the object, in bytes. Immutable over the object's | ||
| 363 | * lifetime. | ||
| 364 | */ | ||
| 365 | size_t size; | ||
| 366 | |||
| 367 | /** | ||
| 368 | * Global name for this object, starts at 1. 0 means unnamed. | ||
| 369 | * Access is covered by the object_name_lock in the related drm_device | ||
| 370 | */ | ||
| 371 | int name; | ||
| 372 | |||
| 373 | /** | ||
| 374 | * Memory domains. These monitor which caches contain read/write data | ||
| 375 | * related to the object. When transitioning from one set of domains | ||
| 376 | * to another, the driver is called to ensure that caches are suitably | ||
| 377 | * flushed and invalidated | ||
| 378 | */ | ||
| 379 | uint32_t read_domains; | ||
| 380 | uint32_t write_domain; | ||
| 381 | |||
| 382 | /** | ||
| 383 | * While validating an exec operation, the | ||
| 384 | * new read/write domain values are computed here. | ||
| 385 | * They will be transferred to the above values | ||
| 386 | * at the point that any cache flushing occurs | ||
| 387 | */ | ||
| 388 | uint32_t pending_read_domains; | ||
| 389 | uint32_t pending_write_domain; | ||
| 390 | |||
| 391 | /** | ||
| 392 | * dma_buf - dma buf associated with this GEM object | ||
| 393 | * | ||
| 394 | * Pointer to the dma-buf associated with this gem object (either | ||
| 395 | * through importing or exporting). We break the resulting reference | ||
| 396 | * loop when the last gem handle for this object is released. | ||
| 397 | * | ||
| 398 | * Protected by obj->object_name_lock | ||
| 399 | */ | ||
| 400 | struct dma_buf *dma_buf; | ||
| 401 | |||
| 402 | /** | ||
| 403 | * import_attach - dma buf attachment backing this object | ||
| 404 | * | ||
| 405 | * Any foreign dma_buf imported as a gem object has this set to the | ||
| 406 | * attachment point for the device. This is invariant over the lifetime | ||
| 407 | * of a gem object. | ||
| 408 | * | ||
| 409 | * The driver's ->gem_free_object callback is responsible for cleaning | ||
| 410 | * up the dma_buf attachment and references acquired at import time. | ||
| 411 | * | ||
| 412 | * Note that the drm gem/prime core does not depend upon drivers setting | ||
| 413 | * this field any more. So for drivers where this doesn't make sense | ||
| 414 | * (e.g. virtual devices or a displaylink behind an usb bus) they can | ||
| 415 | * simply leave it as NULL. | ||
| 416 | */ | ||
| 417 | struct dma_buf_attachment *import_attach; | ||
| 418 | }; | ||
| 419 | |||
| 420 | /** | ||
| 421 | * struct drm_master - drm master structure | 335 | * struct drm_master - drm master structure |
| 422 | * | 336 | * |
| 423 | * @refcount: Refcount for this master object. | 337 | * @refcount: Refcount for this master object. |
| @@ -1073,10 +987,6 @@ extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page ** | |||
| 1073 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); | 987 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); |
| 1074 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); | 988 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); |
| 1075 | 989 | ||
| 1076 | int drm_gem_dumb_destroy(struct drm_file *file, | ||
| 1077 | struct drm_device *dev, | ||
| 1078 | uint32_t handle); | ||
| 1079 | |||
| 1080 | 990 | ||
| 1081 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, | 991 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, |
| 1082 | size_t align); | 992 | size_t align); |
| @@ -1085,62 +995,6 @@ extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); | |||
| 1085 | /* sysfs support (drm_sysfs.c) */ | 995 | /* sysfs support (drm_sysfs.c) */ |
| 1086 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | 996 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
| 1087 | 997 | ||
| 1088 | /* Graphics Execution Manager library functions (drm_gem.c) */ | ||
| 1089 | void drm_gem_object_release(struct drm_gem_object *obj); | ||
| 1090 | void drm_gem_object_free(struct kref *kref); | ||
| 1091 | int drm_gem_object_init(struct drm_device *dev, | ||
| 1092 | struct drm_gem_object *obj, size_t size); | ||
| 1093 | void drm_gem_private_object_init(struct drm_device *dev, | ||
| 1094 | struct drm_gem_object *obj, size_t size); | ||
| 1095 | void drm_gem_vm_open(struct vm_area_struct *vma); | ||
| 1096 | void drm_gem_vm_close(struct vm_area_struct *vma); | ||
| 1097 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, | ||
| 1098 | struct vm_area_struct *vma); | ||
| 1099 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | ||
| 1100 | |||
| 1101 | static inline void | ||
| 1102 | drm_gem_object_reference(struct drm_gem_object *obj) | ||
| 1103 | { | ||
| 1104 | kref_get(&obj->refcount); | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | static inline void | ||
| 1108 | drm_gem_object_unreference(struct drm_gem_object *obj) | ||
| 1109 | { | ||
| 1110 | if (obj != NULL) | ||
| 1111 | kref_put(&obj->refcount, drm_gem_object_free); | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | static inline void | ||
| 1115 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | ||
| 1116 | { | ||
| 1117 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { | ||
| 1118 | struct drm_device *dev = obj->dev; | ||
| 1119 | |||
| 1120 | mutex_lock(&dev->struct_mutex); | ||
| 1121 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) | ||
| 1122 | drm_gem_object_free(&obj->refcount); | ||
| 1123 | mutex_unlock(&dev->struct_mutex); | ||
| 1124 | } | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | int drm_gem_handle_create(struct drm_file *file_priv, | ||
| 1128 | struct drm_gem_object *obj, | ||
| 1129 | u32 *handlep); | ||
| 1130 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); | ||
| 1131 | |||
| 1132 | |||
| 1133 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); | ||
| 1134 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); | ||
| 1135 | int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); | ||
| 1136 | |||
| 1137 | struct page **drm_gem_get_pages(struct drm_gem_object *obj); | ||
| 1138 | void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, | ||
| 1139 | bool dirty, bool accessed); | ||
| 1140 | |||
| 1141 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, | ||
| 1142 | struct drm_file *filp, | ||
| 1143 | u32 handle); | ||
| 1144 | 998 | ||
| 1145 | struct drm_device *drm_dev_alloc(struct drm_driver *driver, | 999 | struct drm_device *drm_dev_alloc(struct drm_driver *driver, |
| 1146 | struct device *parent); | 1000 | struct device *parent); |
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h new file mode 100644 index 000000000000..1e6ae1458f7a --- /dev/null +++ b/include/drm/drm_gem.h | |||
| @@ -0,0 +1,183 @@ | |||
| 1 | #ifndef __DRM_GEM_H__ | ||
| 2 | #define __DRM_GEM_H__ | ||
| 3 | |||
| 4 | /* | ||
| 5 | * GEM Graphics Execution Manager Driver Interfaces | ||
| 6 | * | ||
| 7 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | ||
| 8 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | ||
| 9 | * Copyright (c) 2009-2010, Code Aurora Forum. | ||
| 10 | * All rights reserved. | ||
| 11 | * Copyright © 2014 Intel Corporation | ||
| 12 | * Daniel Vetter <daniel.vetter@ffwll.ch> | ||
| 13 | * | ||
| 14 | * Author: Rickard E. (Rik) Faith <faith@valinux.com> | ||
| 15 | * Author: Gareth Hughes <gareth@valinux.com> | ||
| 16 | * | ||
| 17 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 18 | * copy of this software and associated documentation files (the "Software"), | ||
| 19 | * to deal in the Software without restriction, including without limitation | ||
| 20 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 21 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 22 | * Software is furnished to do so, subject to the following conditions: | ||
| 23 | * | ||
| 24 | * The above copyright notice and this permission notice (including the next | ||
| 25 | * paragraph) shall be included in all copies or substantial portions of the | ||
| 26 | * Software. | ||
| 27 | * | ||
| 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 31 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
| 32 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
| 33 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 34 | * OTHER DEALINGS IN THE SOFTWARE. | ||
| 35 | */ | ||
| 36 | |||
| 37 | /** | ||
| 38 | * This structure defines the drm_mm memory object, which will be used by the | ||
| 39 | * DRM for its buffer objects. | ||
| 40 | */ | ||
| 41 | struct drm_gem_object { | ||
| 42 | /** Reference count of this object */ | ||
| 43 | struct kref refcount; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * handle_count - gem file_priv handle count of this object | ||
| 47 | * | ||
| 48 | * Each handle also holds a reference. Note that when the handle_count | ||
| 49 | * drops to 0 any global names (e.g. the id in the flink namespace) will | ||
| 50 | * be cleared. | ||
| 51 | * | ||
| 52 | * Protected by dev->object_name_lock. | ||
| 53 | * */ | ||
| 54 | unsigned handle_count; | ||
| 55 | |||
| 56 | /** Related drm device */ | ||
| 57 | struct drm_device *dev; | ||
| 58 | |||
| 59 | /** File representing the shmem storage */ | ||
| 60 | struct file *filp; | ||
| 61 | |||
| 62 | /* Mapping info for this object */ | ||
| 63 | struct drm_vma_offset_node vma_node; | ||
| 64 | |||
| 65 | /** | ||
| 66 | * Size of the object, in bytes. Immutable over the object's | ||
| 67 | * lifetime. | ||
| 68 | */ | ||
| 69 | size_t size; | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Global name for this object, starts at 1. 0 means unnamed. | ||
| 73 | * Access is covered by the object_name_lock in the related drm_device | ||
| 74 | */ | ||
| 75 | int name; | ||
| 76 | |||
| 77 | /** | ||
| 78 | * Memory domains. These monitor which caches contain read/write data | ||
| 79 | * related to the object. When transitioning from one set of domains | ||
| 80 | * to another, the driver is called to ensure that caches are suitably | ||
| 81 | * flushed and invalidated | ||
| 82 | */ | ||
| 83 | uint32_t read_domains; | ||
| 84 | uint32_t write_domain; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * While validating an exec operation, the | ||
| 88 | * new read/write domain values are computed here. | ||
| 89 | * They will be transferred to the above values | ||
| 90 | * at the point that any cache flushing occurs | ||
| 91 | */ | ||
| 92 | uint32_t pending_read_domains; | ||
| 93 | uint32_t pending_write_domain; | ||
| 94 | |||
| 95 | /** | ||
| 96 | * dma_buf - dma buf associated with this GEM object | ||
| 97 | * | ||
| 98 | * Pointer to the dma-buf associated with this gem object (either | ||
| 99 | * through importing or exporting). We break the resulting reference | ||
| 100 | * loop when the last gem handle for this object is released. | ||
| 101 | * | ||
| 102 | * Protected by obj->object_name_lock | ||
| 103 | */ | ||
| 104 | struct dma_buf *dma_buf; | ||
| 105 | |||
| 106 | /** | ||
| 107 | * import_attach - dma buf attachment backing this object | ||
| 108 | * | ||
| 109 | * Any foreign dma_buf imported as a gem object has this set to the | ||
| 110 | * attachment point for the device. This is invariant over the lifetime | ||
| 111 | * of a gem object. | ||
| 112 | * | ||
| 113 | * The driver's ->gem_free_object callback is responsible for cleaning | ||
| 114 | * up the dma_buf attachment and references acquired at import time. | ||
| 115 | * | ||
| 116 | * Note that the drm gem/prime core does not depend upon drivers setting | ||
| 117 | * this field any more. So for drivers where this doesn't make sense | ||
| 118 | * (e.g. virtual devices or a displaylink behind an usb bus) they can | ||
| 119 | * simply leave it as NULL. | ||
| 120 | */ | ||
| 121 | struct dma_buf_attachment *import_attach; | ||
| 122 | }; | ||
| 123 | |||
| 124 | void drm_gem_object_release(struct drm_gem_object *obj); | ||
| 125 | void drm_gem_object_free(struct kref *kref); | ||
| 126 | int drm_gem_object_init(struct drm_device *dev, | ||
| 127 | struct drm_gem_object *obj, size_t size); | ||
| 128 | void drm_gem_private_object_init(struct drm_device *dev, | ||
| 129 | struct drm_gem_object *obj, size_t size); | ||
| 130 | void drm_gem_vm_open(struct vm_area_struct *vma); | ||
| 131 | void drm_gem_vm_close(struct vm_area_struct *vma); | ||
| 132 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, | ||
| 133 | struct vm_area_struct *vma); | ||
| 134 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | ||
| 135 | |||
| 136 | static inline void | ||
| 137 | drm_gem_object_reference(struct drm_gem_object *obj) | ||
| 138 | { | ||
| 139 | kref_get(&obj->refcount); | ||
| 140 | } | ||
| 141 | |||
| 142 | static inline void | ||
| 143 | drm_gem_object_unreference(struct drm_gem_object *obj) | ||
| 144 | { | ||
| 145 | if (obj != NULL) | ||
| 146 | kref_put(&obj->refcount, drm_gem_object_free); | ||
| 147 | } | ||
| 148 | |||
| 149 | static inline void | ||
| 150 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | ||
| 151 | { | ||
| 152 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { | ||
| 153 | struct drm_device *dev = obj->dev; | ||
| 154 | |||
| 155 | mutex_lock(&dev->struct_mutex); | ||
| 156 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) | ||
| 157 | drm_gem_object_free(&obj->refcount); | ||
| 158 | mutex_unlock(&dev->struct_mutex); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | int drm_gem_handle_create(struct drm_file *file_priv, | ||
| 163 | struct drm_gem_object *obj, | ||
| 164 | u32 *handlep); | ||
| 165 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); | ||
| 166 | |||
| 167 | |||
| 168 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); | ||
| 169 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); | ||
| 170 | int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); | ||
| 171 | |||
| 172 | struct page **drm_gem_get_pages(struct drm_gem_object *obj); | ||
| 173 | void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, | ||
| 174 | bool dirty, bool accessed); | ||
| 175 | |||
| 176 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, | ||
| 177 | struct drm_file *filp, | ||
| 178 | u32 handle); | ||
| 179 | int drm_gem_dumb_destroy(struct drm_file *file, | ||
| 180 | struct drm_device *dev, | ||
| 181 | uint32_t handle); | ||
| 182 | |||
| 183 | #endif /* __DRM_GEM_H__ */ | ||
diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h index 2a3cea91606d..42f11f3a8d39 100644 --- a/include/drm/drm_gem_cma_helper.h +++ b/include/drm/drm_gem_cma_helper.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define __DRM_GEM_CMA_HELPER_H__ | 2 | #define __DRM_GEM_CMA_HELPER_H__ |
| 3 | 3 | ||
| 4 | #include <drm/drmP.h> | 4 | #include <drm/drmP.h> |
| 5 | #include <drm/drm_gem.h> | ||
| 5 | 6 | ||
| 6 | struct drm_gem_cma_object { | 7 | struct drm_gem_cma_object { |
| 7 | struct drm_gem_object base; | 8 | struct drm_gem_object base; |
