The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/drm_memory.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
    2  * Created: Thu Feb  4 14:00:34 1999 by faith@valinux.com
    3  *
    4  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
    5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
    6  * All Rights Reserved.
    7  *
    8  * Permission is hereby granted, free of charge, to any person obtaining a
    9  * copy of this software and associated documentation files (the "Software"),
   10  * to deal in the Software without restriction, including without limitation
   11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   12  * and/or sell copies of the Software, and to permit persons to whom the
   13  * Software is furnished to do so, subject to the following conditions:
   14  *
   15  * The above copyright notice and this permission notice (including the next
   16  * paragraph) shall be included in all copies or substantial portions of the
   17  * Software.
   18  *
   19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   22  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   25  * OTHER DEALINGS IN THE SOFTWARE.
   26  *
   27  * Authors:
   28  *    Rickard E. (Rik) Faith <faith@valinux.com>
   29  *    Gareth Hughes <gareth@valinux.com>
   30  *
   31  * $FreeBSD: releng/5.0/sys/dev/drm/drm_memory.h 107625 2002-12-04 23:39:05Z anholt $
   32  */
   33 
   34 #define __NO_VERSION__
   35 #ifdef __linux__
   36 #include <linux/config.h>
   37 #endif /* __linux__ */
   38 #include "dev/drm/drmP.h"
   39 #ifdef __linux__
   40 #include <linux/wrapper.h>
   41 #endif /* __linux__ */
   42 #ifdef __FreeBSD__
   43 #include <vm/vm.h>
   44 #include <vm/pmap.h>
   45 #if __REALLY_HAVE_AGP
   46 #include <sys/agpio.h>
   47 #endif
   48 
   49 #define malloctype DRM(M_DRM)
   50 /* The macros confliced in the MALLOC_DEFINE */
   51 
   52 MALLOC_DEFINE(malloctype, "drm", "DRM Data Structures");
   53 
   54 #undef malloctype
   55 #endif /* __FreeBSD__ */
   56 
   57 typedef struct drm_mem_stats {
   58         const char        *name;
   59         int               succeed_count;
   60         int               free_count;
   61         int               fail_count;
   62         unsigned long     bytes_allocated;
   63         unsigned long     bytes_freed;
   64 } drm_mem_stats_t;
   65 
   66 #ifdef __linux__
   67 static spinlock_t         DRM(mem_lock)      = SPIN_LOCK_UNLOCKED;
   68 #endif /* __linux__ */
   69 #ifdef __FreeBSD__
   70 static DRM_OS_SPINTYPE    DRM(mem_lock);
   71 #endif /* __FreeBSD__ */
   72 static unsigned long      DRM(ram_available) = 0; /* In pages */
   73 static unsigned long      DRM(ram_used)      = 0;
   74 static drm_mem_stats_t    DRM(mem_stats)[]   = {
   75         [DRM_MEM_DMA]       = { "dmabufs"  },
   76         [DRM_MEM_SAREA]     = { "sareas"   },
   77         [DRM_MEM_DRIVER]    = { "driver"   },
   78         [DRM_MEM_MAGIC]     = { "magic"    },
   79         [DRM_MEM_IOCTLS]    = { "ioctltab" },
   80         [DRM_MEM_MAPS]      = { "maplist"  },
   81         [DRM_MEM_VMAS]      = { "vmalist"  },
   82         [DRM_MEM_BUFS]      = { "buflist"  },
   83         [DRM_MEM_SEGS]      = { "seglist"  },
   84         [DRM_MEM_PAGES]     = { "pagelist" },
   85         [DRM_MEM_FILES]     = { "files"    },
   86         [DRM_MEM_QUEUES]    = { "queues"   },
   87         [DRM_MEM_CMDS]      = { "commands" },
   88         [DRM_MEM_MAPPINGS]  = { "mappings" },
   89         [DRM_MEM_BUFLISTS]  = { "buflists" },
   90         [DRM_MEM_AGPLISTS]  = { "agplist"  },
   91         [DRM_MEM_SGLISTS]   = { "sglist"   },
   92         [DRM_MEM_TOTALAGP]  = { "totalagp" },
   93         [DRM_MEM_BOUNDAGP]  = { "boundagp" },
   94         [DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
   95         [DRM_MEM_STUB]      = { "stub"     },
   96         { NULL, 0, }            /* Last entry must be null */
   97 };
   98 
   99 void DRM(mem_init)(void)
  100 {
  101         drm_mem_stats_t *mem;
  102 #ifdef __linux__
  103         struct sysinfo  si;
  104 #endif /* __linux__ */
  105 
  106 #ifdef __FreeBSD__
  107         DRM_OS_SPININIT(DRM(mem_lock), "drm memory");
  108 #endif /* __FreeBSD__ */
  109 
  110         for (mem = DRM(mem_stats); mem->name; ++mem) {
  111                 mem->succeed_count   = 0;
  112                 mem->free_count      = 0;
  113                 mem->fail_count      = 0;
  114                 mem->bytes_allocated = 0;
  115                 mem->bytes_freed     = 0;
  116         }
  117 
  118 #ifdef __linux__
  119         si_meminfo(&si);
  120         DRM(ram_available) = si.totalram;
  121 #endif /* __linux__ */
  122 #ifdef __FreeBSD__
  123         DRM(ram_available) = 0; /* si.totalram */
  124 #endif /* __FreeBSD__ */
  125         DRM(ram_used)      = 0;
  126 }
  127 
  128 #ifdef __FreeBSD__
  129 static int 
  130 DRM(_mem_info)(drm_mem_stats_t *stats, struct sysctl_oid *oidp, void *arg1, 
  131     int arg2, struct sysctl_req *req)
  132 {
  133         drm_mem_stats_t *pt;
  134         char buf[128];
  135         int error;
  136 
  137         DRM_SYSCTL_PRINT("                total counts                  "
  138                        " |    outstanding  \n");
  139         DRM_SYSCTL_PRINT("type     alloc freed fail     bytes      freed"
  140                        " | allocs      bytes\n\n");
  141         DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu          |\n",
  142                        "system", 0, 0, 0, DRM(ram_available));
  143         DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu          |\n",
  144                        "locked", 0, 0, 0, DRM(ram_used));
  145         DRM_SYSCTL_PRINT("\n");
  146         for (pt = stats; pt->name; pt++) {
  147                 DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
  148                                pt->name,
  149                                pt->succeed_count,
  150                                pt->free_count,
  151                                pt->fail_count,
  152                                pt->bytes_allocated,
  153                                pt->bytes_freed,
  154                                pt->succeed_count - pt->free_count,
  155                                (long)pt->bytes_allocated
  156                                - (long)pt->bytes_freed);
  157         }
  158         SYSCTL_OUT(req, "", 1);
  159         
  160         return 0;
  161 }
  162 
  163 int DRM(mem_info) DRM_SYSCTL_HANDLER_ARGS
  164 {
  165         int ret;
  166         drm_mem_stats_t *stats;
  167         
  168         stats = malloc(sizeof(DRM(mem_stats)), DRM(M_DRM), M_NOWAIT);
  169         if (stats == NULL)
  170                 return ENOMEM;
  171         
  172         DRM_OS_SPINLOCK(&DRM(mem_lock));
  173         bcopy(DRM(mem_stats), stats, sizeof(DRM(mem_stats)));
  174         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  175         
  176         ret = DRM(_mem_info)(stats, oidp, arg1, arg2, req);
  177         
  178         free(stats, DRM(M_DRM));
  179         return ret;
  180 }
  181 #endif /* __FreeBSD__ */
  182 
  183 void *DRM(alloc)(size_t size, int area)
  184 {
  185         void *pt;
  186 
  187         if (!size) {
  188                 DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
  189                 return NULL;
  190         }
  191 
  192 #ifdef __linux__
  193         if (!(pt = kmalloc(size, GFP_KERNEL))) {
  194 #endif /* __linux__ */
  195 #ifdef __FreeBSD__
  196         if (!(pt = malloc(size, DRM(M_DRM), M_NOWAIT))) {
  197 #endif /* __FreeBSD__ */
  198                 DRM_OS_SPINLOCK(&DRM(mem_lock));
  199                 ++DRM(mem_stats)[area].fail_count;
  200                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  201                 return NULL;
  202         }
  203         DRM_OS_SPINLOCK(&DRM(mem_lock));
  204         ++DRM(mem_stats)[area].succeed_count;
  205         DRM(mem_stats)[area].bytes_allocated += size;
  206         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  207         return pt;
  208 }
  209 
  210 void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
  211 {
  212         void *pt;
  213 
  214         if (!(pt = DRM(alloc)(size, area))) return NULL;
  215         if (oldpt && oldsize) {
  216                 memcpy(pt, oldpt, oldsize);
  217                 DRM(free)(oldpt, oldsize, area);
  218         }
  219         return pt;
  220 }
  221 
  222 char *DRM(strdup)(const char *s, int area)
  223 {
  224         char *pt;
  225         int      length = s ? strlen(s) : 0;
  226 
  227         if (!(pt = DRM(alloc)(length+1, area))) return NULL;
  228         strcpy(pt, s);
  229         return pt;
  230 }
  231 
  232 void DRM(strfree)(char *s, int area)
  233 {
  234         unsigned int size;
  235 
  236         if (!s) return;
  237 
  238         size = 1 + strlen(s);
  239         DRM(free)((void *)s, size, area);
  240 }
  241 
  242 void DRM(free)(void *pt, size_t size, int area)
  243 {
  244         int alloc_count;
  245         int free_count;
  246 
  247         if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
  248 #ifdef __linux__
  249         else     kfree(pt);
  250 #endif /* __linux__ */
  251 #ifdef __FreeBSD__
  252         else     free(pt, DRM(M_DRM));
  253 #endif /* __FreeBSD__ */
  254         DRM_OS_SPINLOCK(&DRM(mem_lock));
  255         DRM(mem_stats)[area].bytes_freed += size;
  256         free_count  = ++DRM(mem_stats)[area].free_count;
  257         alloc_count =   DRM(mem_stats)[area].succeed_count;
  258         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  259         if (free_count > alloc_count) {
  260                 DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
  261                               free_count, alloc_count);
  262         }
  263 }
  264 
  265 unsigned long DRM(alloc_pages)(int order, int area)
  266 {
  267 #ifdef __linux__
  268         unsigned long address;
  269         unsigned long addr;
  270         unsigned int  sz;
  271 #endif /* __linux__ */
  272 #ifdef __FreeBSD__
  273         vm_offset_t address;
  274 #endif /* __FreeBSD__ */
  275         unsigned long bytes       = PAGE_SIZE << order;
  276 
  277 #ifdef __linux__
  278         DRM_OS_SPINLOCK(&DRM(mem_lock));
  279         if ((DRM(ram_used) >> PAGE_SHIFT)
  280             > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
  281                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  282                 return 0;
  283         }
  284         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  285 #endif /* __linux__ */
  286 
  287 #ifdef __linux__
  288         address = __get_free_pages(GFP_KERNEL, order);
  289 #endif /* __linux__ */
  290 #ifdef __FreeBSD__
  291         address = (vm_offset_t) contigmalloc(bytes, DRM(M_DRM), M_WAITOK, 0, ~0, 1, 0);
  292 #endif /* __FreeBSD__ */
  293         if (!address) {
  294                 DRM_OS_SPINLOCK(&DRM(mem_lock));
  295                 ++DRM(mem_stats)[area].fail_count;
  296                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  297                 return 0;
  298         }
  299         DRM_OS_SPINLOCK(&DRM(mem_lock));
  300         ++DRM(mem_stats)[area].succeed_count;
  301         DRM(mem_stats)[area].bytes_allocated += bytes;
  302         DRM(ram_used)                        += bytes;
  303         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  304 
  305 
  306                                 /* Zero outside the lock */
  307         memset((void *)address, 0, bytes);
  308 
  309 #ifdef __linux__
  310                                 /* Reserve */
  311         for (addr = address, sz = bytes;
  312              sz > 0;
  313              addr += PAGE_SIZE, sz -= PAGE_SIZE) {
  314                 mem_map_reserve(virt_to_page(addr));
  315         }
  316 #endif /* __linux__ */
  317 
  318         return address;
  319 }
  320 
  321 void DRM(free_pages)(unsigned long address, int order, int area)
  322 {
  323         unsigned long bytes = PAGE_SIZE << order;
  324         int               alloc_count;
  325         int               free_count;
  326 
  327         if (!address) {
  328                 DRM_MEM_ERROR(area, "Attempt to free address 0\n");
  329         } else {
  330 #ifdef __linux__
  331                 unsigned long addr;
  332                 unsigned int  sz;
  333                                 /* Unreserve */
  334                 for (addr = address, sz = bytes;
  335                      sz > 0;
  336                      addr += PAGE_SIZE, sz -= PAGE_SIZE) {
  337                         mem_map_unreserve(virt_to_page(addr));
  338                 }
  339                 free_pages(address, order);
  340 #endif /* __linux__ */
  341 #ifdef __FreeBSD__
  342                 contigfree((void *) address, bytes, DRM(M_DRM));
  343 #endif /* __FreeBSD__ */
  344         }
  345 
  346         DRM_OS_SPINLOCK(&DRM(mem_lock));
  347         free_count  = ++DRM(mem_stats)[area].free_count;
  348         alloc_count =   DRM(mem_stats)[area].succeed_count;
  349         DRM(mem_stats)[area].bytes_freed += bytes;
  350         DRM(ram_used)                    -= bytes;
  351         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  352         if (free_count > alloc_count) {
  353                 DRM_MEM_ERROR(area,
  354                               "Excess frees: %d frees, %d allocs\n",
  355                               free_count, alloc_count);
  356         }
  357 }
  358 
  359 void *DRM(ioremap)(unsigned long offset, unsigned long size)
  360 {
  361         void *pt;
  362 
  363         if (!size) {
  364                 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
  365                               "Mapping 0 bytes at 0x%08lx\n", offset);
  366                 return NULL;
  367         }
  368 
  369 #ifdef __linux__
  370         if (!(pt = ioremap(offset, size))) {
  371 #endif /* __linux__ */
  372 #ifdef __FreeBSD__
  373         if (!(pt = pmap_mapdev(offset, size))) {
  374 #endif /* __FreeBSD__ */
  375                 DRM_OS_SPINLOCK(&DRM(mem_lock));
  376                 ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
  377                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  378                 return NULL;
  379         }
  380         DRM_OS_SPINLOCK(&DRM(mem_lock));
  381         ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
  382         DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
  383         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  384         return pt;
  385 }
  386 
  387 void DRM(ioremapfree)(void *pt, unsigned long size)
  388 {
  389         int alloc_count;
  390         int free_count;
  391 
  392         if (!pt)
  393                 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
  394                               "Attempt to free NULL pointer\n");
  395         else
  396 #ifdef __linux__
  397                 iounmap(pt);
  398 #endif /* __linux__ */
  399 #ifdef __FreeBSD__
  400                 pmap_unmapdev((vm_offset_t) pt, size);
  401 #endif /* __FreeBSD__ */
  402 
  403         DRM_OS_SPINLOCK(&DRM(mem_lock));
  404         DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
  405         free_count  = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
  406         alloc_count =   DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
  407         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  408         if (free_count > alloc_count) {
  409                 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
  410                               "Excess frees: %d frees, %d allocs\n",
  411                               free_count, alloc_count);
  412         }
  413 }
  414 
  415 #if __REALLY_HAVE_AGP
  416 agp_memory *DRM(alloc_agp)(int pages, u32 type)
  417 {
  418         agp_memory *handle;
  419 
  420         if (!pages) {
  421                 DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
  422                 return NULL;
  423         }
  424 
  425         if ((handle = DRM(agp_allocate_memory)(pages, type))) {
  426                 DRM_OS_SPINLOCK(&DRM(mem_lock));
  427                 ++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
  428                 DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
  429                         += pages << PAGE_SHIFT;
  430                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  431                 return handle;
  432         }
  433         DRM_OS_SPINLOCK(&DRM(mem_lock));
  434         ++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
  435         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  436         return NULL;
  437 }
  438 
  439 int DRM(free_agp)(agp_memory *handle, int pages)
  440 {
  441         int           alloc_count;
  442         int           free_count;
  443 
  444         if (!handle) {
  445                 DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
  446                               "Attempt to free NULL AGP handle\n");
  447                 return DRM_OS_ERR(EINVAL);
  448         }
  449 
  450         if (DRM(agp_free_memory)(handle)) {
  451                 DRM_OS_SPINLOCK(&DRM(mem_lock));
  452                 free_count  = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
  453                 alloc_count =   DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
  454                 DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
  455                         += pages << PAGE_SHIFT;
  456                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  457                 if (free_count > alloc_count) {
  458                         DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
  459                                       "Excess frees: %d frees, %d allocs\n",
  460                                       free_count, alloc_count);
  461                 }
  462                 return 0;
  463         }
  464         return DRM_OS_ERR(EINVAL);
  465 }
  466 
  467 int DRM(bind_agp)(agp_memory *handle, unsigned int start)
  468 {
  469         int retcode;
  470 #ifdef __FreeBSD__
  471         device_t dev = agp_find_device();
  472         struct agp_memory_info info;
  473 
  474         if (!dev)
  475                 return DRM_OS_ERR(EINVAL);
  476 #endif /* __FreeBSD__ */
  477 
  478         if (!handle) {
  479                 DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
  480                               "Attempt to bind NULL AGP handle\n");
  481                 return DRM_OS_ERR(EINVAL);
  482         }
  483 
  484         if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
  485                 DRM_OS_SPINLOCK(&DRM(mem_lock));
  486                 ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
  487 #ifdef __linux__
  488                 DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
  489                         += handle->page_count << PAGE_SHIFT;
  490 #endif /* __linux__ */
  491 #ifdef __FreeBSD__
  492                 agp_memory_info(dev, handle, &info);
  493                 DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
  494                         += info.ami_size;
  495 #endif /* __FreeBSD__ */
  496                 DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  497                 return 0;
  498         }
  499         DRM_OS_SPINLOCK(&DRM(mem_lock));
  500         ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
  501         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  502         return retcode;
  503 }
  504 
  505 int DRM(unbind_agp)(agp_memory *handle)
  506 {
  507         int alloc_count;
  508         int free_count;
  509         int retcode = DRM_OS_ERR(EINVAL);
  510 #ifdef __FreeBSD__
  511         device_t dev = agp_find_device();
  512         struct agp_memory_info info;
  513 
  514         if (!dev)
  515                 return DRM_OS_ERR(EINVAL);
  516 #endif /* __FreeBSD__ */
  517 
  518         if (!handle) {
  519                 DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
  520                               "Attempt to unbind NULL AGP handle\n");
  521                 return retcode;
  522         }
  523 
  524 #ifdef __FreeBSD__
  525         agp_memory_info(dev, handle, &info);
  526 #endif /* __FreeBSD__ */
  527 
  528         if ((retcode = DRM(agp_unbind_memory)(handle))) 
  529                 return retcode;
  530 
  531         DRM_OS_SPINLOCK(&DRM(mem_lock));
  532         free_count  = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
  533         alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
  534 #ifdef __linux__
  535         DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
  536                 += handle->page_count << PAGE_SHIFT;
  537 #endif /* __linux__ */
  538 #ifdef __FreeBSD__
  539         DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
  540                 += info.ami_size;
  541 #endif /* __FreeBSD__ */
  542         DRM_OS_SPINUNLOCK(&DRM(mem_lock));
  543         if (free_count > alloc_count) {
  544                 DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
  545                               "Excess frees: %d frees, %d allocs\n",
  546                               free_count, alloc_count);
  547         }
  548         return retcode;
  549 }
  550 #endif

Cache object: 820c74cdb823f95cecd6b5763d78d05b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.