[Openchrome-devel] drm-openchrome: 2 commits - drivers/gpu/drm
Kevin Brace
kevinbrace at kemper.freedesktop.org
Fri Jan 20 04:23:09 UTC 2017
drivers/gpu/drm/via/init_ttm.c | 137 -----------------------------------------
drivers/gpu/drm/via/via_drv.h | 4 -
drivers/gpu/drm/via/via_mem.h | 36 +++++-----
drivers/gpu/drm/via/via_ttm.c | 137 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 157 insertions(+), 157 deletions(-)
New commits:
commit ad98a5a420743050d37d886942ceaada39cdf8ed
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Thu Jan 19 22:22:07 2017 -0600
Version bumped to 3.0.15
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index dd7f03f..0ac0c2c 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -27,11 +27,11 @@
#define DRIVER_AUTHOR "The OpenChrome Project"
#define DRIVER_NAME "via"
#define DRIVER_DESC "OpenChrome DRM for VIA Technologies Chrome IGP"
-#define DRIVER_DATE "20170117"
+#define DRIVER_DATE "20170118"
#define DRIVER_MAJOR 3
#define DRIVER_MINOR 0
-#define DRIVER_PATCHLEVEL 14
+#define DRIVER_PATCHLEVEL 15
#include <linux/module.h>
commit 05e74009d66f1feed2e2e0f7af282110693c94c2
Author: Kevin Brace <kevinbrace at gmx.com>
Date: Thu Jan 19 22:20:33 2017 -0600
Moved most functions out of init_ttm.c
Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
diff --git a/drivers/gpu/drm/via/init_ttm.c b/drivers/gpu/drm/via/init_ttm.c
index b574765..0fe0565 100644
--- a/drivers/gpu/drm/via/init_ttm.c
+++ b/drivers/gpu/drm/via/init_ttm.c
@@ -24,143 +24,6 @@
#include "drmP.h"
#include "via_mem.h"
-static void
-ttm_buffer_object_destroy(struct ttm_buffer_object *bo)
-{
- struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
-
- kfree(heap);
- heap = NULL;
-}
-
-/*
- * the buffer object domain
- */
-void
-ttm_placement_from_domain(struct ttm_buffer_object *bo, struct ttm_placement *placement, u32 domains,
- struct ttm_bo_device *bdev)
-{
- struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
- int cnt = 0, i = 0;
-
- if (!(domains & TTM_PL_MASK_MEM))
- domains = TTM_PL_FLAG_SYSTEM;
-
- do {
- int domain = (domains & (1 << i));
-
- if (domain) {
- heap->busy_placements[cnt].flags = (domain | bdev->man[i].default_caching);
- heap->busy_placements[cnt].fpfn = heap->busy_placements[cnt].lpfn = 0;
- heap->placements[cnt].flags = (domain | bdev->man[i].available_caching);
- heap->placements[cnt].fpfn = heap->placements[cnt].lpfn = 0;
- cnt++;
- }
- } while (i++ < TTM_NUM_MEM_TYPES);
-
- placement->num_busy_placement = placement->num_placement = cnt;
- placement->busy_placement = heap->busy_placements;
- placement->placement = heap->placements;
-}
-
-int
-via_bo_create(struct ttm_bo_device *bdev,
- unsigned long size,
- enum ttm_bo_type origin,
- uint32_t domains,
- uint32_t byte_align,
- uint32_t page_align,
- bool interruptible,
- struct sg_table *sg,
- struct reservation_object *resv,
- struct ttm_buffer_object **p_bo)
-{
- struct ttm_buffer_object *bo = NULL;
- struct ttm_placement placement;
- struct ttm_heap *heap;
- size_t acc_size;
- int ret = -ENOMEM;
-
- DRM_DEBUG("Entered via_bo_create.\n");
-
- size = round_up(size, byte_align);
- size = ALIGN(size, page_align);
-
- heap = kzalloc(sizeof(struct ttm_heap), GFP_KERNEL);
- if (unlikely(!heap)) {
- DRM_ERROR("Failed to allocate kernel memory.");
- goto exit;
- }
-
- bo = &heap->pbo;
-
- ttm_placement_from_domain(bo, &placement, domains, bdev);
-
- acc_size = ttm_bo_dma_acc_size(bdev, size,
- sizeof(struct ttm_heap));
-
- ret = ttm_bo_init(bdev, bo, size, origin, &placement,
- page_align >> PAGE_SHIFT,
- interruptible, NULL, acc_size,
- sg, NULL, ttm_buffer_object_destroy);
-
- if (unlikely(ret)) {
- DRM_ERROR("Failed to initialize a TTM Buffer Object.");
- goto error;
- }
-
- *p_bo = bo;
- goto exit;
-error:
- kfree(heap);
-exit:
- DRM_DEBUG("Exiting via_bo_create.\n");
- return ret;
-}
-
-int
-via_bo_pin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap)
-{
- struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
- struct ttm_placement placement;
- int ret;
-
- ret = ttm_bo_reserve(bo, true, false, false, 0);
- if (!ret) {
- placement.placement = heap->placements;
- placement.num_placement = 1;
-
- heap->placements[0].flags = (bo->mem.placement | TTM_PL_FLAG_NO_EVICT);
- ret = ttm_bo_validate(bo, &placement, false, false);
- if (!ret && kmap)
- ret = ttm_bo_kmap(bo, 0, bo->num_pages, kmap);
- ttm_bo_unreserve(bo);
- }
- return ret;
-}
-
-int
-ttm_bo_unpin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap)
-{
- struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
- struct ttm_placement placement;
- int ret;
-
- ret = ttm_bo_reserve(bo, true, false, false, 0);
- if (!ret) {
- if (kmap)
- ttm_bo_kunmap(kmap);
-
- placement.placement = heap->placements;
- placement.num_placement = 1;
-
- heap->placements[0].flags = (bo->mem.placement & ~TTM_PL_FLAG_NO_EVICT);
- ret = ttm_bo_validate(bo, &placement, false, false);
- ttm_bo_unreserve(bo);
- }
- return ret;
-}
-
int
ttm_allocate_kernel_buffer(struct ttm_bo_device *bdev, unsigned long size,
uint32_t alignment, uint32_t domain,
diff --git a/drivers/gpu/drm/via/via_mem.h b/drivers/gpu/drm/via/via_mem.h
index 350d622..d2b64e8 100644
--- a/drivers/gpu/drm/via/via_mem.h
+++ b/drivers/gpu/drm/via/via_mem.h
@@ -35,6 +35,10 @@ struct ttm_heap {
struct ttm_buffer_object pbo;
};
+extern int ttm_allocate_kernel_buffer(struct ttm_bo_device *bdev, unsigned long size,
+ uint32_t alignment, uint32_t domain,
+ struct ttm_bo_kmap_obj *kmap);
+
extern void via_ttm_global_release(struct drm_global_reference *global_ref,
struct ttm_bo_global_ref *global_bo,
struct ttm_bo_device *bdev);
@@ -45,26 +49,18 @@ extern int via_ttm_global_init(struct drm_global_reference *global_ref,
struct drm_device *dev,
bool dma32);
extern int via_ttm_init(struct drm_device *dev);
-extern struct ttm_tt *
-via_sgdma_backend_init(struct ttm_bo_device *bdev, unsigned long size,
- uint32_t page_flags, struct page *dummy_read_page);
-
-
-extern int via_bo_create(struct ttm_bo_device *bdev, unsigned long size,
- enum ttm_bo_type origin, uint32_t domains,
- uint32_t byte_align, uint32_t page_align,
- bool interruptible, struct sg_table *sg,
- struct reservation_object *resv,
- struct ttm_buffer_object **p_bo);
+void via_mm_fini(struct drm_device *dev);
extern void ttm_placement_from_domain(struct ttm_buffer_object *bo,
- struct ttm_placement *placement,
- u32 domains, struct ttm_bo_device *bdev);
-extern int ttm_bo_unpin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap);
+ struct ttm_placement *placement,
+ u32 domains, struct ttm_bo_device *bdev);
+extern int via_bo_create(struct ttm_bo_device *bdev, unsigned long size,
+ enum ttm_bo_type origin, uint32_t domains,
+ uint32_t byte_align, uint32_t page_align,
+ bool interruptible, struct sg_table *sg,
+ struct reservation_object *resv,
+ struct ttm_buffer_object **p_bo);
extern int via_bo_pin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap);
-extern int ttm_allocate_kernel_buffer(struct ttm_bo_device *bdev, unsigned long size,
- uint32_t alignment, uint32_t domain,
- struct ttm_bo_kmap_obj *kmap);
-void via_mm_fini(struct drm_device *dev);
+extern int ttm_bo_unpin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap);
extern int ttm_mmap(struct file *filp, struct vm_area_struct *vma);
@@ -78,4 +74,8 @@ extern struct drm_gem_object *ttm_gem_create(struct drm_device *dev,
unsigned long size);
extern struct ttm_buffer_object *ttm_gem_mapping(struct drm_gem_object *obj);
+extern struct ttm_tt *
+via_sgdma_backend_init(struct ttm_bo_device *bdev, unsigned long size,
+ uint32_t page_flags, struct page *dummy_read_page);
+
#endif /* _VIA_MEM_H_ */
diff --git a/drivers/gpu/drm/via/via_ttm.c b/drivers/gpu/drm/via/via_ttm.c
index 5357849..6d55ae3 100644
--- a/drivers/gpu/drm/via/via_ttm.c
+++ b/drivers/gpu/drm/via/via_ttm.c
@@ -106,6 +106,15 @@ via_ttm_global_init(struct drm_global_reference *global_ref,
return rc;
}
+static void
+ttm_buffer_object_destroy(struct ttm_buffer_object *bo)
+{
+ struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
+
+ kfree(heap);
+ heap = NULL;
+}
+
static struct ttm_tt *
via_ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
uint32_t page_flags, struct page *dummy_read_page)
@@ -589,3 +598,131 @@ void via_mm_fini(struct drm_device *dev)
DRM_DEBUG("Exiting via_mm_fini.\n");
}
+
+/*
+ * the buffer object domain
+ */
+void
+ttm_placement_from_domain(struct ttm_buffer_object *bo, struct ttm_placement *placement, u32 domains,
+ struct ttm_bo_device *bdev)
+{
+ struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
+ int cnt = 0, i = 0;
+
+ if (!(domains & TTM_PL_MASK_MEM))
+ domains = TTM_PL_FLAG_SYSTEM;
+
+ do {
+ int domain = (domains & (1 << i));
+
+ if (domain) {
+ heap->busy_placements[cnt].flags = (domain | bdev->man[i].default_caching);
+ heap->busy_placements[cnt].fpfn = heap->busy_placements[cnt].lpfn = 0;
+ heap->placements[cnt].flags = (domain | bdev->man[i].available_caching);
+ heap->placements[cnt].fpfn = heap->placements[cnt].lpfn = 0;
+ cnt++;
+ }
+ } while (i++ < TTM_NUM_MEM_TYPES);
+
+ placement->num_busy_placement = placement->num_placement = cnt;
+ placement->busy_placement = heap->busy_placements;
+ placement->placement = heap->placements;
+}
+
+int
+via_bo_create(struct ttm_bo_device *bdev,
+ unsigned long size,
+ enum ttm_bo_type origin,
+ uint32_t domains,
+ uint32_t byte_align,
+ uint32_t page_align,
+ bool interruptible,
+ struct sg_table *sg,
+ struct reservation_object *resv,
+ struct ttm_buffer_object **p_bo)
+{
+ struct ttm_buffer_object *bo = NULL;
+ struct ttm_placement placement;
+ struct ttm_heap *heap;
+ size_t acc_size;
+ int ret = -ENOMEM;
+
+ DRM_DEBUG("Entered via_bo_create.\n");
+
+ size = round_up(size, byte_align);
+ size = ALIGN(size, page_align);
+
+ heap = kzalloc(sizeof(struct ttm_heap), GFP_KERNEL);
+ if (unlikely(!heap)) {
+ DRM_ERROR("Failed to allocate kernel memory.");
+ goto exit;
+ }
+
+ bo = &heap->pbo;
+
+ ttm_placement_from_domain(bo, &placement, domains, bdev);
+
+ acc_size = ttm_bo_dma_acc_size(bdev, size,
+ sizeof(struct ttm_heap));
+
+ ret = ttm_bo_init(bdev, bo, size, origin, &placement,
+ page_align >> PAGE_SHIFT,
+ interruptible, NULL, acc_size,
+ sg, NULL, ttm_buffer_object_destroy);
+
+ if (unlikely(ret)) {
+ DRM_ERROR("Failed to initialize a TTM Buffer Object.");
+ goto error;
+ }
+
+ *p_bo = bo;
+ goto exit;
+error:
+ kfree(heap);
+exit:
+ DRM_DEBUG("Exiting via_bo_create.\n");
+ return ret;
+}
+
+int
+via_bo_pin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap)
+{
+ struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
+ struct ttm_placement placement;
+ int ret;
+
+ ret = ttm_bo_reserve(bo, true, false, false, 0);
+ if (!ret) {
+ placement.placement = heap->placements;
+ placement.num_placement = 1;
+
+ heap->placements[0].flags = (bo->mem.placement | TTM_PL_FLAG_NO_EVICT);
+ ret = ttm_bo_validate(bo, &placement, false, false);
+ if (!ret && kmap)
+ ret = ttm_bo_kmap(bo, 0, bo->num_pages, kmap);
+ ttm_bo_unreserve(bo);
+ }
+ return ret;
+}
+
+int
+ttm_bo_unpin(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *kmap)
+{
+ struct ttm_heap *heap = container_of(bo, struct ttm_heap, pbo);
+ struct ttm_placement placement;
+ int ret;
+
+ ret = ttm_bo_reserve(bo, true, false, false, 0);
+ if (!ret) {
+ if (kmap)
+ ttm_bo_kunmap(kmap);
+
+ placement.placement = heap->placements;
+ placement.num_placement = 1;
+
+ heap->placements[0].flags = (bo->mem.placement & ~TTM_PL_FLAG_NO_EVICT);
+ ret = ttm_bo_validate(bo, &placement, false, false);
+ ttm_bo_unreserve(bo);
+ }
+ return ret;
+}
More information about the Openchrome-devel
mailing list