Subversion Repositories Kolibri OS

Rev

Rev 4075 | Go to most recent revision | 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.  
  41.  
  42. int ttm_mem_global_init(struct ttm_mem_global *glob)
  43. {
  44.         int ret;
  45.         int i;
  46.  
  47.         spin_lock_init(&glob->lock);
  48.  
  49.  
  50.  
  51.         ttm_page_alloc_init(glob, 4*1024);
  52.  
  53.         return 0;
  54. out_no_zone:
  55.         ttm_mem_global_release(glob);
  56.         return ret;
  57. }
  58. EXPORT_SYMBOL(ttm_mem_global_init);
  59.  
  60. void ttm_mem_global_release(struct ttm_mem_global *glob)
  61. {
  62.         unsigned int i;
  63.  
  64.         /* let the page allocator first stop the shrink work. */
  65. //      ttm_page_alloc_fini();
  66. //      ttm_dma_page_alloc_fini();
  67.  
  68.  
  69. }
  70. EXPORT_SYMBOL(ttm_mem_global_release);
  71.  
  72.  
  73.  
  74. size_t ttm_round_pot(size_t size)
  75. {
  76.         if ((size & (size - 1)) == 0)
  77.                 return size;
  78.         else if (size > PAGE_SIZE)
  79.                 return PAGE_ALIGN(size);
  80.         else {
  81.                 size_t tmp_size = 4;
  82.  
  83.                 while (tmp_size < size)
  84.                         tmp_size <<= 1;
  85.  
  86.                 return tmp_size;
  87.         }
  88.         return 0;
  89. }
  90. EXPORT_SYMBOL(ttm_round_pot);
  91.