Subversion Repositories Kolibri OS

Rev

Rev 5078 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20.  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21.  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24.  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #define pr_fmt(fmt) "[TTM] " fmt
  29.  
  30. #include <drm/ttm/ttm_memory.h>
  31. #include <drm/ttm/ttm_module.h>
  32. #include <drm/ttm/ttm_page_alloc.h>
  33. #include <linux/spinlock.h>
  34. #include <linux/sched.h>
  35. #include <linux/wait.h>
  36. #include <linux/mm.h>
  37. #include <linux/module.h>
  38. #include <linux/slab.h>
  39.  
  40. #define TTM_MEMORY_ALLOC_RETRIES 4
  41.  
  42.  
  43. int ttm_mem_global_init(struct ttm_mem_global *glob)
  44. {
  45.         int ret;
  46.         int i;
  47.  
  48.         spin_lock_init(&glob->lock);
  49.  
  50.  
  51.  
  52.         ttm_page_alloc_init(glob, 4*1024);
  53.  
  54.         return 0;
  55. out_no_zone:
  56.         ttm_mem_global_release(glob);
  57.         return ret;
  58. }
  59. EXPORT_SYMBOL(ttm_mem_global_init);
  60.  
  61. void ttm_mem_global_release(struct ttm_mem_global *glob)
  62. {
  63.         unsigned int i;
  64.  
  65.         /* let the page allocator first stop the shrink work. */
  66. //      ttm_page_alloc_fini();
  67. //      ttm_dma_page_alloc_fini();
  68.  
  69.  
  70. }
  71.  
  72. void ttm_mem_global_free(struct ttm_mem_global *glob,
  73.                          uint64_t amount)
  74. {
  75.  
  76. }
  77. EXPORT_SYMBOL(ttm_mem_global_free);
  78.  
  79. int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
  80.                          bool no_wait, bool interruptible)
  81. {
  82.         /**
  83.          * Normal allocations of kernel memory are registered in
  84.          * all zones.
  85.          */
  86.  
  87.         return 0;
  88. }
  89. EXPORT_SYMBOL(ttm_mem_global_alloc);
  90.  
  91. size_t ttm_round_pot(size_t size)
  92. {
  93.         if ((size & (size - 1)) == 0)
  94.                 return size;
  95.         else if (size > PAGE_SIZE)
  96.                 return PAGE_ALIGN(size);
  97.         else {
  98.                 size_t tmp_size = 4;
  99.  
  100.                 while (tmp_size < size)
  101.                         tmp_size <<= 1;
  102.  
  103.                 return tmp_size;
  104.         }
  105.         return 0;
  106. }
  107. EXPORT_SYMBOL(ttm_round_pot);
  108.