drm_mm.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /**************************************************************************
  2. *
  3. * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., 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. /*
  29. * Generic simple memory manager implementation. Intended to be used as a base
  30. * class implementation for more advanced memory managers.
  31. *
  32. * Note that the algorithm used is quite simple and there might be substantial
  33. * performance gains if a smarter free list is implemented. Currently it is just an
  34. * unordered stack of free regions. This could easily be improved if an RB-tree
  35. * is used instead. At least if we expect heavy fragmentation.
  36. *
  37. * Aligned allocations can also see improvement.
  38. *
  39. * Authors:
  40. * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
  41. */
  42. #include <drm/drmP.h>
  43. #include <drm/drm_mm.h>
  44. #include <linux/slab.h>
  45. #include <linux/seq_file.h>
  46. #include <linux/export.h>
  47. #define MM_UNUSED_TARGET 4
  48. static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
  49. unsigned long size,
  50. unsigned alignment,
  51. unsigned long color,
  52. enum drm_mm_search_flags flags);
  53. static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm,
  54. unsigned long size,
  55. unsigned alignment,
  56. unsigned long color,
  57. unsigned long start,
  58. unsigned long end,
  59. enum drm_mm_search_flags flags);
  60. static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
  61. struct drm_mm_node *node,
  62. unsigned long size, unsigned alignment,
  63. unsigned long color)
  64. {
  65. struct drm_mm *mm = hole_node->mm;
  66. unsigned long hole_start = drm_mm_hole_node_start(hole_node);
  67. unsigned long hole_end = drm_mm_hole_node_end(hole_node);
  68. unsigned long adj_start = hole_start;
  69. unsigned long adj_end = hole_end;
  70. BUG_ON(node->allocated);
  71. if (mm->color_adjust)
  72. mm->color_adjust(hole_node, color, &adj_start, &adj_end);
  73. if (alignment) {
  74. unsigned tmp = adj_start % alignment;
  75. if (tmp)
  76. adj_start += alignment - tmp;
  77. }
  78. if (adj_start == hole_start) {
  79. hole_node->hole_follows = 0;
  80. list_del(&hole_node->hole_stack);
  81. }
  82. node->start = adj_start;
  83. node->size = size;
  84. node->mm = mm;
  85. node->color = color;
  86. node->allocated = 1;
  87. INIT_LIST_HEAD(&node->hole_stack);
  88. list_add(&node->node_list, &hole_node->node_list);
  89. BUG_ON(node->start + node->size > adj_end);
  90. node->hole_follows = 0;
  91. if (__drm_mm_hole_node_start(node) < hole_end) {
  92. list_add(&node->hole_stack, &mm->hole_stack);
  93. node->hole_follows = 1;
  94. }
  95. }
  96. int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)
  97. {
  98. struct drm_mm_node *hole;
  99. unsigned long end = node->start + node->size;
  100. unsigned long hole_start;
  101. unsigned long hole_end;
  102. BUG_ON(node == NULL);
  103. /* Find the relevant hole to add our node to */
  104. drm_mm_for_each_hole(hole, mm, hole_start, hole_end) {
  105. if (hole_start > node->start || hole_end < end)
  106. continue;
  107. node->mm = mm;
  108. node->allocated = 1;
  109. INIT_LIST_HEAD(&node->hole_stack);
  110. list_add(&node->node_list, &hole->node_list);
  111. if (node->start == hole_start) {
  112. hole->hole_follows = 0;
  113. list_del_init(&hole->hole_stack);
  114. }
  115. node->hole_follows = 0;
  116. if (end != hole_end) {
  117. list_add(&node->hole_stack, &mm->hole_stack);
  118. node->hole_follows = 1;
  119. }
  120. return 0;
  121. }
  122. WARN(1, "no hole found for node 0x%lx + 0x%lx\n",
  123. node->start, node->size);
  124. return -ENOSPC;
  125. }
  126. EXPORT_SYMBOL(drm_mm_reserve_node);
  127. /**
  128. * Search for free space and insert a preallocated memory node. Returns
  129. * -ENOSPC if no suitable free area is available. The preallocated memory node
  130. * must be cleared.
  131. */
  132. int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node,
  133. unsigned long size, unsigned alignment,
  134. unsigned long color,
  135. enum drm_mm_search_flags flags)
  136. {
  137. struct drm_mm_node *hole_node;
  138. hole_node = drm_mm_search_free_generic(mm, size, alignment,
  139. color, flags);
  140. if (!hole_node)
  141. return -ENOSPC;
  142. drm_mm_insert_helper(hole_node, node, size, alignment, color);
  143. return 0;
  144. }
  145. EXPORT_SYMBOL(drm_mm_insert_node_generic);
  146. static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,
  147. struct drm_mm_node *node,
  148. unsigned long size, unsigned alignment,
  149. unsigned long color,
  150. unsigned long start, unsigned long end)
  151. {
  152. struct drm_mm *mm = hole_node->mm;
  153. unsigned long hole_start = drm_mm_hole_node_start(hole_node);
  154. unsigned long hole_end = drm_mm_hole_node_end(hole_node);
  155. unsigned long adj_start = hole_start;
  156. unsigned long adj_end = hole_end;
  157. BUG_ON(!hole_node->hole_follows || node->allocated);
  158. if (adj_start < start)
  159. adj_start = start;
  160. if (adj_end > end)
  161. adj_end = end;
  162. if (mm->color_adjust)
  163. mm->color_adjust(hole_node, color, &adj_start, &adj_end);
  164. if (alignment) {
  165. unsigned tmp = adj_start % alignment;
  166. if (tmp)
  167. adj_start += alignment - tmp;
  168. }
  169. if (adj_start == hole_start) {
  170. hole_node->hole_follows = 0;
  171. list_del(&hole_node->hole_stack);
  172. }
  173. node->start = adj_start;
  174. node->size = size;
  175. node->mm = mm;
  176. node->color = color;
  177. node->allocated = 1;
  178. INIT_LIST_HEAD(&node->hole_stack);
  179. list_add(&node->node_list, &hole_node->node_list);
  180. BUG_ON(node->start + node->size > adj_end);
  181. BUG_ON(node->start + node->size > end);
  182. node->hole_follows = 0;
  183. if (__drm_mm_hole_node_start(node) < hole_end) {
  184. list_add(&node->hole_stack, &mm->hole_stack);
  185. node->hole_follows = 1;
  186. }
  187. }
  188. /**
  189. * Search for free space and insert a preallocated memory node. Returns
  190. * -ENOSPC if no suitable free area is available. This is for range
  191. * restricted allocations. The preallocated memory node must be cleared.
  192. */
  193. int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *node,
  194. unsigned long size, unsigned alignment, unsigned long color,
  195. unsigned long start, unsigned long end,
  196. enum drm_mm_search_flags flags)
  197. {
  198. struct drm_mm_node *hole_node;
  199. hole_node = drm_mm_search_free_in_range_generic(mm,
  200. size, alignment, color,
  201. start, end, flags);
  202. if (!hole_node)
  203. return -ENOSPC;
  204. drm_mm_insert_helper_range(hole_node, node,
  205. size, alignment, color,
  206. start, end);
  207. return 0;
  208. }
  209. EXPORT_SYMBOL(drm_mm_insert_node_in_range_generic);
  210. /**
  211. * Remove a memory node from the allocator.
  212. */
  213. void drm_mm_remove_node(struct drm_mm_node *node)
  214. {
  215. struct drm_mm *mm = node->mm;
  216. struct drm_mm_node *prev_node;
  217. if (WARN_ON(!node->allocated))
  218. return;
  219. BUG_ON(node->scanned_block || node->scanned_prev_free
  220. || node->scanned_next_free);
  221. prev_node =
  222. list_entry(node->node_list.prev, struct drm_mm_node, node_list);
  223. if (node->hole_follows) {
  224. BUG_ON(__drm_mm_hole_node_start(node) ==
  225. __drm_mm_hole_node_end(node));
  226. list_del(&node->hole_stack);
  227. } else
  228. BUG_ON(__drm_mm_hole_node_start(node) !=
  229. __drm_mm_hole_node_end(node));
  230. if (!prev_node->hole_follows) {
  231. prev_node->hole_follows = 1;
  232. list_add(&prev_node->hole_stack, &mm->hole_stack);
  233. } else
  234. list_move(&prev_node->hole_stack, &mm->hole_stack);
  235. list_del(&node->node_list);
  236. node->allocated = 0;
  237. }
  238. EXPORT_SYMBOL(drm_mm_remove_node);
  239. static int check_free_hole(unsigned long start, unsigned long end,
  240. unsigned long size, unsigned alignment)
  241. {
  242. if (end - start < size)
  243. return 0;
  244. if (alignment) {
  245. unsigned tmp = start % alignment;
  246. if (tmp)
  247. start += alignment - tmp;
  248. }
  249. return end >= start + size;
  250. }
  251. static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
  252. unsigned long size,
  253. unsigned alignment,
  254. unsigned long color,
  255. enum drm_mm_search_flags flags)
  256. {
  257. struct drm_mm_node *entry;
  258. struct drm_mm_node *best;
  259. unsigned long adj_start;
  260. unsigned long adj_end;
  261. unsigned long best_size;
  262. BUG_ON(mm->scanned_blocks);
  263. best = NULL;
  264. best_size = ~0UL;
  265. drm_mm_for_each_hole(entry, mm, adj_start, adj_end) {
  266. if (mm->color_adjust) {
  267. mm->color_adjust(entry, color, &adj_start, &adj_end);
  268. if (adj_end <= adj_start)
  269. continue;
  270. }
  271. if (!check_free_hole(adj_start, adj_end, size, alignment))
  272. continue;
  273. if (!(flags & DRM_MM_SEARCH_BEST))
  274. return entry;
  275. if (entry->size < best_size) {
  276. best = entry;
  277. best_size = entry->size;
  278. }
  279. }
  280. return best;
  281. }
  282. static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm,
  283. unsigned long size,
  284. unsigned alignment,
  285. unsigned long color,
  286. unsigned long start,
  287. unsigned long end,
  288. enum drm_mm_search_flags flags)
  289. {
  290. struct drm_mm_node *entry;
  291. struct drm_mm_node *best;
  292. unsigned long adj_start;
  293. unsigned long adj_end;
  294. unsigned long best_size;
  295. BUG_ON(mm->scanned_blocks);
  296. best = NULL;
  297. best_size = ~0UL;
  298. drm_mm_for_each_hole(entry, mm, adj_start, adj_end) {
  299. if (adj_start < start)
  300. adj_start = start;
  301. if (adj_end > end)
  302. adj_end = end;
  303. if (mm->color_adjust) {
  304. mm->color_adjust(entry, color, &adj_start, &adj_end);
  305. if (adj_end <= adj_start)
  306. continue;
  307. }
  308. if (!check_free_hole(adj_start, adj_end, size, alignment))
  309. continue;
  310. if (!(flags & DRM_MM_SEARCH_BEST))
  311. return entry;
  312. if (entry->size < best_size) {
  313. best = entry;
  314. best_size = entry->size;
  315. }
  316. }
  317. return best;
  318. }
  319. /**
  320. * Moves an allocation. To be used with embedded struct drm_mm_node.
  321. */
  322. void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
  323. {
  324. list_replace(&old->node_list, &new->node_list);
  325. list_replace(&old->hole_stack, &new->hole_stack);
  326. new->hole_follows = old->hole_follows;
  327. new->mm = old->mm;
  328. new->start = old->start;
  329. new->size = old->size;
  330. new->color = old->color;
  331. old->allocated = 0;
  332. new->allocated = 1;
  333. }
  334. EXPORT_SYMBOL(drm_mm_replace_node);
  335. /**
  336. * Initializa lru scanning.
  337. *
  338. * This simply sets up the scanning routines with the parameters for the desired
  339. * hole.
  340. *
  341. * Warning: As long as the scan list is non-empty, no other operations than
  342. * adding/removing nodes to/from the scan list are allowed.
  343. */
  344. void drm_mm_init_scan(struct drm_mm *mm,
  345. unsigned long size,
  346. unsigned alignment,
  347. unsigned long color)
  348. {
  349. mm->scan_color = color;
  350. mm->scan_alignment = alignment;
  351. mm->scan_size = size;
  352. mm->scanned_blocks = 0;
  353. mm->scan_hit_start = 0;
  354. mm->scan_hit_end = 0;
  355. mm->scan_check_range = 0;
  356. mm->prev_scanned_node = NULL;
  357. }
  358. EXPORT_SYMBOL(drm_mm_init_scan);
  359. /**
  360. * Initializa lru scanning.
  361. *
  362. * This simply sets up the scanning routines with the parameters for the desired
  363. * hole. This version is for range-restricted scans.
  364. *
  365. * Warning: As long as the scan list is non-empty, no other operations than
  366. * adding/removing nodes to/from the scan list are allowed.
  367. */
  368. void drm_mm_init_scan_with_range(struct drm_mm *mm,
  369. unsigned long size,
  370. unsigned alignment,
  371. unsigned long color,
  372. unsigned long start,
  373. unsigned long end)
  374. {
  375. mm->scan_color = color;
  376. mm->scan_alignment = alignment;
  377. mm->scan_size = size;
  378. mm->scanned_blocks = 0;
  379. mm->scan_hit_start = 0;
  380. mm->scan_hit_end = 0;
  381. mm->scan_start = start;
  382. mm->scan_end = end;
  383. mm->scan_check_range = 1;
  384. mm->prev_scanned_node = NULL;
  385. }
  386. EXPORT_SYMBOL(drm_mm_init_scan_with_range);
  387. /**
  388. * Add a node to the scan list that might be freed to make space for the desired
  389. * hole.
  390. *
  391. * Returns non-zero, if a hole has been found, zero otherwise.
  392. */
  393. int drm_mm_scan_add_block(struct drm_mm_node *node)
  394. {
  395. struct drm_mm *mm = node->mm;
  396. struct drm_mm_node *prev_node;
  397. unsigned long hole_start, hole_end;
  398. unsigned long adj_start, adj_end;
  399. mm->scanned_blocks++;
  400. BUG_ON(node->scanned_block);
  401. node->scanned_block = 1;
  402. prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
  403. node_list);
  404. node->scanned_preceeds_hole = prev_node->hole_follows;
  405. prev_node->hole_follows = 1;
  406. list_del(&node->node_list);
  407. node->node_list.prev = &prev_node->node_list;
  408. node->node_list.next = &mm->prev_scanned_node->node_list;
  409. mm->prev_scanned_node = node;
  410. adj_start = hole_start = drm_mm_hole_node_start(prev_node);
  411. adj_end = hole_end = drm_mm_hole_node_end(prev_node);
  412. if (mm->scan_check_range) {
  413. if (adj_start < mm->scan_start)
  414. adj_start = mm->scan_start;
  415. if (adj_end > mm->scan_end)
  416. adj_end = mm->scan_end;
  417. }
  418. if (mm->color_adjust)
  419. mm->color_adjust(prev_node, mm->scan_color,
  420. &adj_start, &adj_end);
  421. if (check_free_hole(adj_start, adj_end,
  422. mm->scan_size, mm->scan_alignment)) {
  423. mm->scan_hit_start = hole_start;
  424. mm->scan_hit_end = hole_end;
  425. return 1;
  426. }
  427. return 0;
  428. }
  429. EXPORT_SYMBOL(drm_mm_scan_add_block);
  430. /**
  431. * Remove a node from the scan list.
  432. *
  433. * Nodes _must_ be removed in the exact same order from the scan list as they
  434. * have been added, otherwise the internal state of the memory manager will be
  435. * corrupted.
  436. *
  437. * When the scan list is empty, the selected memory nodes can be freed. An
  438. * immediately following drm_mm_search_free with !DRM_MM_SEARCH_BEST will then
  439. * return the just freed block (because its at the top of the free_stack list).
  440. *
  441. * Returns one if this block should be evicted, zero otherwise. Will always
  442. * return zero when no hole has been found.
  443. */
  444. int drm_mm_scan_remove_block(struct drm_mm_node *node)
  445. {
  446. struct drm_mm *mm = node->mm;
  447. struct drm_mm_node *prev_node;
  448. mm->scanned_blocks--;
  449. BUG_ON(!node->scanned_block);
  450. node->scanned_block = 0;
  451. prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
  452. node_list);
  453. prev_node->hole_follows = node->scanned_preceeds_hole;
  454. list_add(&node->node_list, &prev_node->node_list);
  455. return (drm_mm_hole_node_end(node) > mm->scan_hit_start &&
  456. node->start < mm->scan_hit_end);
  457. }
  458. EXPORT_SYMBOL(drm_mm_scan_remove_block);
  459. int drm_mm_clean(struct drm_mm * mm)
  460. {
  461. struct list_head *head = &mm->head_node.node_list;
  462. return (head->next->next == head);
  463. }
  464. EXPORT_SYMBOL(drm_mm_clean);
  465. void drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
  466. {
  467. INIT_LIST_HEAD(&mm->hole_stack);
  468. mm->scanned_blocks = 0;
  469. /* Clever trick to avoid a special case in the free hole tracking. */
  470. INIT_LIST_HEAD(&mm->head_node.node_list);
  471. INIT_LIST_HEAD(&mm->head_node.hole_stack);
  472. mm->head_node.hole_follows = 1;
  473. mm->head_node.scanned_block = 0;
  474. mm->head_node.scanned_prev_free = 0;
  475. mm->head_node.scanned_next_free = 0;
  476. mm->head_node.mm = mm;
  477. mm->head_node.start = start + size;
  478. mm->head_node.size = start - mm->head_node.start;
  479. list_add_tail(&mm->head_node.hole_stack, &mm->hole_stack);
  480. mm->color_adjust = NULL;
  481. }
  482. EXPORT_SYMBOL(drm_mm_init);
  483. void drm_mm_takedown(struct drm_mm * mm)
  484. {
  485. WARN(!list_empty(&mm->head_node.node_list),
  486. "Memory manager not clean during takedown.\n");
  487. }
  488. EXPORT_SYMBOL(drm_mm_takedown);
  489. static unsigned long drm_mm_debug_hole(struct drm_mm_node *entry,
  490. const char *prefix)
  491. {
  492. unsigned long hole_start, hole_end, hole_size;
  493. if (entry->hole_follows) {
  494. hole_start = drm_mm_hole_node_start(entry);
  495. hole_end = drm_mm_hole_node_end(entry);
  496. hole_size = hole_end - hole_start;
  497. printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8lu: free\n",
  498. prefix, hole_start, hole_end,
  499. hole_size);
  500. return hole_size;
  501. }
  502. return 0;
  503. }
  504. void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)
  505. {
  506. struct drm_mm_node *entry;
  507. unsigned long total_used = 0, total_free = 0, total = 0;
  508. total_free += drm_mm_debug_hole(&mm->head_node, prefix);
  509. drm_mm_for_each_node(entry, mm) {
  510. printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8lu: used\n",
  511. prefix, entry->start, entry->start + entry->size,
  512. entry->size);
  513. total_used += entry->size;
  514. total_free += drm_mm_debug_hole(entry, prefix);
  515. }
  516. total = total_free + total_used;
  517. printk(KERN_DEBUG "%s total: %lu, used %lu free %lu\n", prefix, total,
  518. total_used, total_free);
  519. }
  520. EXPORT_SYMBOL(drm_mm_debug_table);
  521. #if defined(CONFIG_DEBUG_FS)
  522. static unsigned long drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry)
  523. {
  524. unsigned long hole_start, hole_end, hole_size;
  525. if (entry->hole_follows) {
  526. hole_start = drm_mm_hole_node_start(entry);
  527. hole_end = drm_mm_hole_node_end(entry);
  528. hole_size = hole_end - hole_start;
  529. seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n",
  530. hole_start, hole_end, hole_size);
  531. return hole_size;
  532. }
  533. return 0;
  534. }
  535. int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
  536. {
  537. struct drm_mm_node *entry;
  538. unsigned long total_used = 0, total_free = 0, total = 0;
  539. total_free += drm_mm_dump_hole(m, &mm->head_node);
  540. drm_mm_for_each_node(entry, mm) {
  541. seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: used\n",
  542. entry->start, entry->start + entry->size,
  543. entry->size);
  544. total_used += entry->size;
  545. total_free += drm_mm_dump_hole(m, entry);
  546. }
  547. total = total_free + total_used;
  548. seq_printf(m, "total: %lu, used %lu free %lu\n", total, total_used, total_free);
  549. return 0;
  550. }
  551. EXPORT_SYMBOL(drm_mm_dump_table);
  552. #endif