From 7d0513e9f6197aa429dfcb29e5ee19edb5478c92 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 28 Feb 2013 11:35:11 +0000 Subject: [PATCH] i915: trace memory allocation/deallocation git-svn-id: svn://kolibrios.org@3290 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/video/drm/drm_gem.c | 3 +++ drivers/video/drm/i915/i915_gem.c | 18 +++++++++++++++--- drivers/video/drm/i915/kms_display.c | 15 ++++++++------- drivers/video/drm/i915/main.c | 6 ++++++ drivers/video/drm/i915/utils.c | 11 +++++++++-- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/drivers/video/drm/drm_gem.c b/drivers/video/drm/drm_gem.c index 5cb8e3024b..b50b3c392d 100644 --- a/drivers/video/drm/drm_gem.c +++ b/drivers/video/drm/drm_gem.c @@ -217,6 +217,7 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle) * we may want to use ida for number allocation and a hash table * for the pointers, anyway. */ + spin_lock(&filp->table_lock); /* Check if we currently have a reference on the object */ @@ -227,6 +228,8 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle) } dev = obj->dev; + printf("%s handle %d obj %p\n", __FUNCTION__, handle, obj); + /* Release reference and decrement refcount. */ idr_remove(&filp->object_idr, handle); spin_unlock(&filp->table_lock); diff --git a/drivers/video/drm/i915/i915_gem.c b/drivers/video/drm/i915/i915_gem.c index 597eebc1c0..ab7c4c09ff 100644 --- a/drivers/video/drm/i915/i915_gem.c +++ b/drivers/video/drm/i915/i915_gem.c @@ -237,6 +237,8 @@ i915_gem_create(struct drm_file *file, int ret; u32 handle; + ENTER(); + size = roundup(size, PAGE_SIZE); if (size == 0) return -EINVAL; @@ -259,6 +261,9 @@ i915_gem_create(struct drm_file *file, trace_i915_gem_object_create(obj); *handle_p = handle; + + printf("%s obj %p handle %d\n", __FUNCTION__, obj, handle); + return 0; } @@ -1491,11 +1496,11 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj) for_each_sg(obj->pages->sgl, sg, page_count, i) { struct page *page = sg_page(sg); - - -// page_cache_release(page); + page_cache_release(page); } //DRM_DEBUG_KMS("%s release %d pages\n", __FUNCTION__, page_count); + printf("%s release %d pages\n", __FUNCTION__, page_count); + obj->dirty = 0; sg_free_table(obj->pages); @@ -3506,6 +3511,7 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj) // if (obj->phys_obj) // i915_gem_detach_phys_object(dev, obj); + printf("%s obj %p\n", __FUNCTION__, obj); obj->pin_count = 0; if (WARN_ON(i915_gem_object_unbind(obj) == -ERESTARTSYS)) { @@ -3528,6 +3534,12 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj) // if (obj->base.import_attach) // drm_prime_gem_destroy(&obj->base, NULL); + if(obj->base.filp != NULL) + { + printf("filp %p\n", obj->base.filp); + shmem_file_delete(obj->base.filp); + } + drm_gem_object_release(&obj->base); i915_gem_info_remove_obj(dev_priv, obj->base.size); diff --git a/drivers/video/drm/i915/kms_display.c b/drivers/video/drm/i915/kms_display.c index 98aaeea361..e414f5cb7b 100644 --- a/drivers/video/drm/i915/kms_display.c +++ b/drivers/video/drm/i915/kms_display.c @@ -652,6 +652,8 @@ typedef struct struct drm_i915_mask { __u32 handle; + __u32 width; + __u32 height; __u32 bo_size; __u32 bo_pitch; __u32 bo_map; @@ -693,6 +695,10 @@ int i915_mask_update(struct drm_device *dev, void *data, { static warn_count; + mask->width = winrc.right - winrc.left + 1; + mask->height = winrc.bottom - winrc.top + 1; + mask->bo_pitch = (mask->width+15) & ~15; + if(warn_count < 1) { printf("left %d top %d right %d bottom %d\n", @@ -702,6 +708,7 @@ int i915_mask_update(struct drm_device *dev, void *data, }; }; + slot = *((u8*)CURRENT_TASK); if( mask_seqno[slot] != os_display->mask_seqno) @@ -730,7 +737,7 @@ int i915_mask_update(struct drm_device *dev, void *data, src_offset+= get_display_map(); dst_offset = (u8*)mask->bo_map; - u32_t tmp_h = winrc.bottom - winrc.top; + u32_t tmp_h = mask->height; ifl = safe_cli(); { @@ -755,12 +762,6 @@ int i915_mask_update(struct drm_device *dev, void *data, src_offset+= os_display->width; dst_offset+= mask->bo_pitch; -// while( tmp_w--) -// { -// *(tmp_src) = (*tmp_dst==slot)?0x1:0x00; -// tmp_src++; -// tmp_dst++; -// }; while(tmp_w >= 64) { __asm__ __volatile__ ( diff --git a/drivers/video/drm/i915/main.c b/drivers/video/drm/i915/main.c index 61a6ce8bb5..5b61fc66d1 100644 --- a/drivers/video/drm/i915/main.c +++ b/drivers/video/drm/i915/main.c @@ -125,6 +125,7 @@ u32_t drvEntry(int action, char *cmdline) #define SRV_BLIT_TEXTURE 16 #define SRV_BLIT_VIDEO 17 + #define SRV_GET_PCI_INFO 20 #define SRV_GET_PARAM 21 #define SRV_I915_GEM_CREATE 22 @@ -140,6 +141,7 @@ u32_t drvEntry(int action, char *cmdline) #define SRV_I915_GEM_THROTTLE 32 #define SRV_FBINFO 33 #define SRV_I915_GEM_EXECBUFFER2 34 +#define SRV_MASK_UPDATE 35 @@ -272,6 +274,10 @@ int _stdcall display_handler(ioctl_t *io) retval = i915_gem_execbuffer2(main_device, inp, file); break; + case SRV_MASK_UPDATE: + retval = i915_mask_update(main_device, inp, file); + break; + }; return retval; diff --git a/drivers/video/drm/i915/utils.c b/drivers/video/drm/i915/utils.c index 77d7890779..837735bf92 100644 --- a/drivers/video/drm/i915/utils.c +++ b/drivers/video/drm/i915/utils.c @@ -29,8 +29,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags filep->allocated = 0; filep->vma = NULL; -// dbgprintf("%s file %p pages %p count %d\n", -// __FUNCTION__,filep, filep->pages, filep->pages); + printf("%s file %p pages %p count %d\n", + __FUNCTION__,filep, filep->pages, count); return filep; } @@ -94,4 +94,11 @@ err: return -ENOMEM; }; +void shmem_file_delete(struct file *filep) +{ + printf("%s file %p pages %p count %d\n", + __FUNCTION__, filep, filep->pages, filep->count); + if(filep->pages) + kfree(filep->pages); +}