mali-t6xx: Fix for BUG: Bad rss-counter state
authorJohn Einar Reitan <john.reitan@arm.com>
Fri, 14 Sep 2012 22:15:48 +0000 (15:15 -0700)
committerGerrit <chrome-bot@google.com>
Sat, 22 Sep 2012 00:26:06 +0000 (17:26 -0700)
This was causing a crash on halt if slub debugging was
turned on.

BUG=chrome-os-partner:14484
TEST=halt with slub debugging turned on works.

Change-Id: I3cc225f6aff5cb0e8d6b288e067763ce4f622e99
Signed-off-by: John Einar Reitan <john.reitan@arm.com>
(cherry picked from commit 41a74be06074efe3cec3e44f7876b43a983b4e7c)
(https://android.googlesource.com/kernel/exynos/android-exynos-3.4)
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33818

drivers/gpu/arm/t6xx/kbase/src/common/mali_kbase_context.c
drivers/gpu/arm/t6xx/kbase/src/common/mali_kbase_defs.h
drivers/gpu/arm/t6xx/kbase/src/common/mali_kbase_mem.c
drivers/gpu/arm/t6xx/kbase/src/common/mali_kbase_mem.h
drivers/gpu/arm/t6xx/kbase/src/common/mali_kbase_mmu.c
drivers/gpu/arm/t6xx/kbase/src/linux/mali_kbase_mem_linux.c

index 2887563..870ce48 100644 (file)
@@ -53,9 +53,6 @@ kbase_context *kbase_create_context(kbase_device *kbdev)
        atomic_set(&kctx->setup_in_progress, 0);
        kctx->keep_gpu_powered = MALI_FALSE;
 
-       /* keep a reference to the process' user side memory manager */
-       kbase_os_store_process_mm(kctx);
-
        if (kbase_mem_usage_init(&kctx->usage, kctx->kbdev->memdev.per_process_memory_limit >> PAGE_SHIFT))
        {
                goto free_kctx;
index aae03f3..8883d7a 100644 (file)
@@ -634,11 +634,6 @@ struct kbase_context
         * Mutable flags *must* be accessed under jctx.sched_info.ctx.jsctx_mutex
         *
         * All other flags must be added there */
-
-       /* Pointer to hold a reference to process memory manager of the context owner,
-        * must be set using kbase_os_store_process_mm().
-        */
-       void * process_mm;
 };
 
 typedef enum kbase_reg_access_type
index 8e967c0..8c579dd 100644 (file)
@@ -1137,12 +1137,6 @@ mali_error kbase_cpu_free_mapping(struct kbase_va_region *reg, const void *ptr)
                goto out;
        }
 
-       /* As the tmem is being unmapped we need to update the pages used by the process */
-       if ( (reg->flags & KBASE_REG_ZONE_MASK) == KBASE_REG_ZONE_TMEM )
-       {
-               kbase_process_page_usage_inc(reg->kctx, map->nr_pages);
-       }
-
        OSK_DLIST_REMOVE(&reg->map_list, map, link);
        kfree(map);
 
@@ -1529,11 +1523,6 @@ static void kbase_free_phy_pages_helper(kbase_va_region * reg, u32 nr_pages_to_f
                        nr_pages -= commit->nr_pages;
                        reg->nr_alloc_pages -= commit->nr_pages;
                        
-                       if ( (reg->flags & KBASE_REG_ZONE_MASK) == KBASE_REG_ZONE_TMEM )
-                       {
-                               kbase_process_page_usage_dec(reg->kctx, commit->nr_pages);
-                       }
-
                        /* free the node (unless it's the root node) */
                        if (commit != &reg->root_commit)
                        {
@@ -1556,10 +1545,6 @@ static void kbase_free_phy_pages_helper(kbase_va_region * reg, u32 nr_pages_to_f
                                        page_array + reg->nr_alloc_pages - nr_pages);
                        commit->nr_pages -= nr_pages;
                        reg->nr_alloc_pages -= nr_pages;
-                       if ( (reg->flags & KBASE_REG_ZONE_MASK) == KBASE_REG_ZONE_TMEM )
-                       {
-                               kbase_process_page_usage_dec(reg->kctx, nr_pages);
-                       }
                        break; /* end the loop */
                }
        }
@@ -1671,10 +1656,6 @@ mali_error kbase_alloc_phy_pages_helper(struct kbase_va_region *reg, u32 nr_page
 
                if (!nr_pages_left)
                {
-                       if ( (reg->flags & KBASE_REG_ZONE_MASK) == KBASE_REG_ZONE_TMEM)
-                       {
-                               kbase_process_page_usage_inc(reg->kctx, nr_pages_requested);
-                       }
                        return MALI_ERROR_NONE;
                }
        }
@@ -1754,10 +1735,6 @@ mali_error kbase_alloc_phy_pages_helper(struct kbase_va_region *reg, u32 nr_page
 
                if (nr_pages_left == 0)
                {
-                       if ( (reg->flags & KBASE_REG_ZONE_MASK) == KBASE_REG_ZONE_TMEM)
-                       {
-                               kbase_process_page_usage_inc(reg->kctx, nr_pages_requested);
-                       }
                        return MALI_ERROR_NONE;
                }
        }
index 5800cdb..95b7d10 100644 (file)
@@ -511,57 +511,6 @@ mali_error kbase_mem_free_region(kbase_context *kctx,
 void kbase_os_mem_map_lock(kbase_context * kctx);
 void kbase_os_mem_map_unlock(kbase_context * kctx);
 
-/**
- * @brief Update the memory allocation counters for the current process
- *
- * OS specific call to updates the current memory allocation counters for the current process with
- * the supplied delta.
- *
- * @param[in] pages The desired delta to apply to the memory usage counters.
- */
-
-void kbasep_os_process_page_usage_update( struct kbase_context * kctx, long pages );
-
-/**
- * @brief Add to the memory allocation counters for the current process
- *
- * OS specific call to add to the current memory allocation counters for the current process by
- * the supplied amount.
- *
- * @param[in] kctx  The kernel base context used for the allocation.
- * @param[in] pages The desired delta to apply to the memory usage counters.
- */
-
-static INLINE void kbase_process_page_usage_inc( struct kbase_context *kctx, unsigned long pages )
-{
-       kbasep_os_process_page_usage_update( kctx, pages );
-}
-
-/**
- * @brief Subtract from the memory allocation counters for the current process
- *
- * OS specific call to subtract from the current memory allocation counters for the current process by
- * the supplied amount.
- *
- * @param[in] kctx  The kernel base context used for the allocation.
- * @param[in] pages The desired delta to apply to the memory usage counters.
- */
-
-static INLINE void kbase_process_page_usage_dec( struct kbase_context *kctx, unsigned long pages )
-{
-       kbasep_os_process_page_usage_update( kctx, 0 - pages );
-}
-
-/**
- * @brief Store the memory manager for the process associated with this context
- *
- * OS specific call to store a pointer to the memory manager for this process.
- *
- * @param[in,out] kctx      The kernel base context used for the allocation.
- */
-
-void kbase_os_store_process_mm(kbase_context *kctx);
-
 /**
  * @brief Find a CPU mapping of a memory allocation containing a given address range
  *
index fc0031a..bc60e52 100644 (file)
@@ -283,7 +283,7 @@ osk_phy_addr kbase_mmu_alloc_pgd(kbase_context *kctx)
                kbase_mem_usage_release_pages(&kctx->usage, 1);
                return 0;
        }
-       kbase_process_page_usage_inc(kctx, 1);
+
        for (i = 0; i < KBASE_MMU_PAGE_ENTRIES; i++)
                page[i] = ENTRY_IS_INVAL;
 
@@ -743,7 +743,6 @@ static void mmu_teardown_level(kbase_context *kctx, osk_phy_addr pgd, int level,
                        if (zap)
                        {
                                kbase_phy_pages_free(kctx->kbdev, &kctx->pgd_allocator, 1, &target_pgd);
-                               kbase_process_page_usage_dec(kctx, 1 );
                                kbase_mem_usage_release_pages(&kctx->usage, 1);
                        }
                }
@@ -790,7 +789,6 @@ void kbase_mmu_free_pgd(kbase_context *kctx)
 
        beenthere("pgd %lx", (unsigned long)kctx->pgd);
        kbase_phy_pages_free(kctx->kbdev, &kctx->pgd_allocator, 1, &kctx->pgd);
-       kbase_process_page_usage_dec(kctx, 1 );
        kbase_mem_usage_release_pages(&kctx->usage, 1);
 }
 KBASE_EXPORT_TEST_API(kbase_mmu_free_pgd)
index db0ff06..c9f796e 100644 (file)
@@ -200,11 +200,6 @@ static int kbase_cpu_mmap(struct kbase_va_region *reg, struct vm_area_struct *vm
        map->page_off = start_off;
        map->private = vma;
 
-       if ( (reg->flags & KBASE_REG_ZONE_MASK) == KBASE_REG_ZONE_TMEM)
-       {
-               kbase_process_page_usage_dec(reg->kctx, nr_pages);
-       }
-
        OSK_DLIST_PUSH_FRONT(&reg->map_list, map,
                                struct kbase_cpu_mapping, link);
 
@@ -658,28 +653,6 @@ err:
 }
 KBASE_EXPORT_SYMBOL(kbase_va_alloc)
 
-void kbasep_os_process_page_usage_update( kbase_context *kctx, long pages )
-{
-       struct mm_struct *mm = ( struct mm_struct *)kctx->process_mm;
-       if ( NULL != mm )
-       {
-#ifdef SPLIT_RSS_COUNTING
-               add_mm_counter(mm, MM_FILEPAGES, pages);
-#else
-               spin_lock(&mm->page_table_lock);
-               add_mm_counter(mm, MM_FILEPAGES, pages);
-               spin_unlock(&mm->page_table_lock);
-#endif
-       }
-}
-
-void kbase_os_store_process_mm(kbase_context *kctx)
-{
-       struct mm_struct *mm = current->mm;
-
-       kctx->process_mm = mm;
-}
-
 void kbase_va_free(kbase_context *kctx, void *va)
 {
        struct kbase_va_region *reg;