memalloc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  3. * Takashi Iwai <tiwai@suse.de>
  4. *
  5. * Generic memory allocators
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/module.h>
  24. #include <linux/proc_fs.h>
  25. #include <linux/init.h>
  26. #include <linux/pci.h>
  27. #include <linux/slab.h>
  28. #include <linux/mm.h>
  29. #include <asm/uaccess.h>
  30. #include <linux/dma-mapping.h>
  31. #include <linux/moduleparam.h>
  32. #include <linux/mutex.h>
  33. #include <sound/memalloc.h>
  34. #ifdef CONFIG_SBUS
  35. #include <asm/sbus.h>
  36. #endif
  37. MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@suse.cz>");
  38. MODULE_DESCRIPTION("Memory allocator for ALSA system.");
  39. MODULE_LICENSE("GPL");
  40. /*
  41. */
  42. void *snd_malloc_sgbuf_pages(struct device *device,
  43. size_t size, struct snd_dma_buffer *dmab,
  44. size_t *res_size);
  45. int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab);
  46. /*
  47. */
  48. static DEFINE_MUTEX(list_mutex);
  49. static LIST_HEAD(mem_list_head);
  50. /* buffer preservation list */
  51. struct snd_mem_list {
  52. struct snd_dma_buffer buffer;
  53. unsigned int id;
  54. struct list_head list;
  55. };
  56. /* id for pre-allocated buffers */
  57. #define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1
  58. #ifdef CONFIG_SND_DEBUG
  59. #define __ASTRING__(x) #x
  60. #define snd_assert(expr, args...) do {\
  61. if (!(expr)) {\
  62. printk(KERN_ERR "snd-malloc: BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
  63. args;\
  64. }\
  65. } while (0)
  66. #else
  67. #define snd_assert(expr, args...) /**/
  68. #endif
  69. /*
  70. * Hacks
  71. */
  72. #if defined(__i386__)
  73. /*
  74. * A hack to allocate large buffers via dma_alloc_coherent()
  75. *
  76. * since dma_alloc_coherent always tries GFP_DMA when the requested
  77. * pci memory region is below 32bit, it happens quite often that even
  78. * 2 order of pages cannot be allocated.
  79. *
  80. * so in the following, we allocate at first without dma_mask, so that
  81. * allocation will be done without GFP_DMA. if the area doesn't match
  82. * with the requested region, then realloate with the original dma_mask
  83. * again.
  84. *
  85. * Really, we want to move this type of thing into dma_alloc_coherent()
  86. * so dma_mask doesn't have to be messed with.
  87. */
  88. static void *snd_dma_hack_alloc_coherent(struct device *dev, size_t size,
  89. dma_addr_t *dma_handle,
  90. gfp_t flags)
  91. {
  92. void *ret;
  93. u64 dma_mask, coherent_dma_mask;
  94. if (dev == NULL || !dev->dma_mask)
  95. return dma_alloc_coherent(dev, size, dma_handle, flags);
  96. dma_mask = *dev->dma_mask;
  97. coherent_dma_mask = dev->coherent_dma_mask;
  98. *dev->dma_mask = 0xffffffff; /* do without masking */
  99. dev->coherent_dma_mask = 0xffffffff; /* do without masking */
  100. ret = dma_alloc_coherent(dev, size, dma_handle, flags);
  101. *dev->dma_mask = dma_mask; /* restore */
  102. dev->coherent_dma_mask = coherent_dma_mask; /* restore */
  103. if (ret) {
  104. /* obtained address is out of range? */
  105. if (((unsigned long)*dma_handle + size - 1) & ~dma_mask) {
  106. /* reallocate with the proper mask */
  107. dma_free_coherent(dev, size, ret, *dma_handle);
  108. ret = dma_alloc_coherent(dev, size, dma_handle, flags);
  109. }
  110. } else {
  111. /* wish to success now with the proper mask... */
  112. if (dma_mask != 0xffffffffUL) {
  113. /* allocation with GFP_ATOMIC to avoid the long stall */
  114. flags &= ~GFP_KERNEL;
  115. flags |= GFP_ATOMIC;
  116. ret = dma_alloc_coherent(dev, size, dma_handle, flags);
  117. }
  118. }
  119. return ret;
  120. }
  121. /* redefine dma_alloc_coherent for some architectures */
  122. #undef dma_alloc_coherent
  123. #define dma_alloc_coherent snd_dma_hack_alloc_coherent
  124. #endif /* arch */
  125. /*
  126. *
  127. * Generic memory allocators
  128. *
  129. */
  130. static long snd_allocated_pages; /* holding the number of allocated pages */
  131. static inline void inc_snd_pages(int order)
  132. {
  133. snd_allocated_pages += 1 << order;
  134. }
  135. static inline void dec_snd_pages(int order)
  136. {
  137. snd_allocated_pages -= 1 << order;
  138. }
  139. /**
  140. * snd_malloc_pages - allocate pages with the given size
  141. * @size: the size to allocate in bytes
  142. * @gfp_flags: the allocation conditions, GFP_XXX
  143. *
  144. * Allocates the physically contiguous pages with the given size.
  145. *
  146. * Returns the pointer of the buffer, or NULL if no enoguh memory.
  147. */
  148. void *snd_malloc_pages(size_t size, gfp_t gfp_flags)
  149. {
  150. int pg;
  151. void *res;
  152. snd_assert(size > 0, return NULL);
  153. snd_assert(gfp_flags != 0, return NULL);
  154. gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */
  155. pg = get_order(size);
  156. if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL)
  157. inc_snd_pages(pg);
  158. return res;
  159. }
  160. /**
  161. * snd_free_pages - release the pages
  162. * @ptr: the buffer pointer to release
  163. * @size: the allocated buffer size
  164. *
  165. * Releases the buffer allocated via snd_malloc_pages().
  166. */
  167. void snd_free_pages(void *ptr, size_t size)
  168. {
  169. int pg;
  170. if (ptr == NULL)
  171. return;
  172. pg = get_order(size);
  173. dec_snd_pages(pg);
  174. free_pages((unsigned long) ptr, pg);
  175. }
  176. /*
  177. *
  178. * Bus-specific memory allocators
  179. *
  180. */
  181. /* allocate the coherent DMA pages */
  182. static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma)
  183. {
  184. int pg;
  185. void *res;
  186. gfp_t gfp_flags;
  187. snd_assert(size > 0, return NULL);
  188. snd_assert(dma != NULL, return NULL);
  189. pg = get_order(size);
  190. gfp_flags = GFP_KERNEL
  191. | __GFP_COMP /* compound page lets parts be mapped */
  192. | __GFP_NORETRY /* don't trigger OOM-killer */
  193. | __GFP_NOWARN; /* no stack trace print - this call is non-critical */
  194. res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
  195. if (res != NULL)
  196. inc_snd_pages(pg);
  197. return res;
  198. }
  199. /* free the coherent DMA pages */
  200. static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr,
  201. dma_addr_t dma)
  202. {
  203. int pg;
  204. if (ptr == NULL)
  205. return;
  206. pg = get_order(size);
  207. dec_snd_pages(pg);
  208. dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
  209. }
  210. #ifdef CONFIG_SBUS
  211. static void *snd_malloc_sbus_pages(struct device *dev, size_t size,
  212. dma_addr_t *dma_addr)
  213. {
  214. struct sbus_dev *sdev = (struct sbus_dev *)dev;
  215. int pg;
  216. void *res;
  217. snd_assert(size > 0, return NULL);
  218. snd_assert(dma_addr != NULL, return NULL);
  219. pg = get_order(size);
  220. res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr);
  221. if (res != NULL)
  222. inc_snd_pages(pg);
  223. return res;
  224. }
  225. static void snd_free_sbus_pages(struct device *dev, size_t size,
  226. void *ptr, dma_addr_t dma_addr)
  227. {
  228. struct sbus_dev *sdev = (struct sbus_dev *)dev;
  229. int pg;
  230. if (ptr == NULL)
  231. return;
  232. pg = get_order(size);
  233. dec_snd_pages(pg);
  234. sbus_free_consistent(sdev, PAGE_SIZE * (1 << pg), ptr, dma_addr);
  235. }
  236. #endif /* CONFIG_SBUS */
  237. /*
  238. *
  239. * ALSA generic memory management
  240. *
  241. */
  242. /**
  243. * snd_dma_alloc_pages - allocate the buffer area according to the given type
  244. * @type: the DMA buffer type
  245. * @device: the device pointer
  246. * @size: the buffer size to allocate
  247. * @dmab: buffer allocation record to store the allocated data
  248. *
  249. * Calls the memory-allocator function for the corresponding
  250. * buffer type.
  251. *
  252. * Returns zero if the buffer with the given size is allocated successfuly,
  253. * other a negative value at error.
  254. */
  255. int snd_dma_alloc_pages(int type, struct device *device, size_t size,
  256. struct snd_dma_buffer *dmab)
  257. {
  258. snd_assert(size > 0, return -ENXIO);
  259. snd_assert(dmab != NULL, return -ENXIO);
  260. dmab->dev.type = type;
  261. dmab->dev.dev = device;
  262. dmab->bytes = 0;
  263. switch (type) {
  264. case SNDRV_DMA_TYPE_CONTINUOUS:
  265. dmab->area = snd_malloc_pages(size, (unsigned long)device);
  266. dmab->addr = 0;
  267. break;
  268. #ifdef CONFIG_SBUS
  269. case SNDRV_DMA_TYPE_SBUS:
  270. dmab->area = snd_malloc_sbus_pages(device, size, &dmab->addr);
  271. break;
  272. #endif
  273. case SNDRV_DMA_TYPE_DEV:
  274. dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr);
  275. break;
  276. case SNDRV_DMA_TYPE_DEV_SG:
  277. snd_malloc_sgbuf_pages(device, size, dmab, NULL);
  278. break;
  279. default:
  280. printk(KERN_ERR "snd-malloc: invalid device type %d\n", type);
  281. dmab->area = NULL;
  282. dmab->addr = 0;
  283. return -ENXIO;
  284. }
  285. if (! dmab->area)
  286. return -ENOMEM;
  287. dmab->bytes = size;
  288. return 0;
  289. }
  290. /**
  291. * snd_dma_alloc_pages_fallback - allocate the buffer area according to the given type with fallback
  292. * @type: the DMA buffer type
  293. * @device: the device pointer
  294. * @size: the buffer size to allocate
  295. * @dmab: buffer allocation record to store the allocated data
  296. *
  297. * Calls the memory-allocator function for the corresponding
  298. * buffer type. When no space is left, this function reduces the size and
  299. * tries to allocate again. The size actually allocated is stored in
  300. * res_size argument.
  301. *
  302. * Returns zero if the buffer with the given size is allocated successfuly,
  303. * other a negative value at error.
  304. */
  305. int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size,
  306. struct snd_dma_buffer *dmab)
  307. {
  308. int err;
  309. snd_assert(size > 0, return -ENXIO);
  310. snd_assert(dmab != NULL, return -ENXIO);
  311. while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {
  312. if (err != -ENOMEM)
  313. return err;
  314. size >>= 1;
  315. if (size <= PAGE_SIZE)
  316. return -ENOMEM;
  317. }
  318. if (! dmab->area)
  319. return -ENOMEM;
  320. return 0;
  321. }
  322. /**
  323. * snd_dma_free_pages - release the allocated buffer
  324. * @dmab: the buffer allocation record to release
  325. *
  326. * Releases the allocated buffer via snd_dma_alloc_pages().
  327. */
  328. void snd_dma_free_pages(struct snd_dma_buffer *dmab)
  329. {
  330. switch (dmab->dev.type) {
  331. case SNDRV_DMA_TYPE_CONTINUOUS:
  332. snd_free_pages(dmab->area, dmab->bytes);
  333. break;
  334. #ifdef CONFIG_SBUS
  335. case SNDRV_DMA_TYPE_SBUS:
  336. snd_free_sbus_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
  337. break;
  338. #endif
  339. case SNDRV_DMA_TYPE_DEV:
  340. snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
  341. break;
  342. case SNDRV_DMA_TYPE_DEV_SG:
  343. snd_free_sgbuf_pages(dmab);
  344. break;
  345. default:
  346. printk(KERN_ERR "snd-malloc: invalid device type %d\n", dmab->dev.type);
  347. }
  348. }
  349. /**
  350. * snd_dma_get_reserved - get the reserved buffer for the given device
  351. * @dmab: the buffer allocation record to store
  352. * @id: the buffer id
  353. *
  354. * Looks for the reserved-buffer list and re-uses if the same buffer
  355. * is found in the list. When the buffer is found, it's removed from the free list.
  356. *
  357. * Returns the size of buffer if the buffer is found, or zero if not found.
  358. */
  359. size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
  360. {
  361. struct snd_mem_list *mem;
  362. snd_assert(dmab, return 0);
  363. mutex_lock(&list_mutex);
  364. list_for_each_entry(mem, &mem_list_head, list) {
  365. if (mem->id == id &&
  366. (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL ||
  367. ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) {
  368. struct device *dev = dmab->dev.dev;
  369. list_del(&mem->list);
  370. *dmab = mem->buffer;
  371. if (dmab->dev.dev == NULL)
  372. dmab->dev.dev = dev;
  373. kfree(mem);
  374. mutex_unlock(&list_mutex);
  375. return dmab->bytes;
  376. }
  377. }
  378. mutex_unlock(&list_mutex);
  379. return 0;
  380. }
  381. /**
  382. * snd_dma_reserve_buf - reserve the buffer
  383. * @dmab: the buffer to reserve
  384. * @id: the buffer id
  385. *
  386. * Reserves the given buffer as a reserved buffer.
  387. *
  388. * Returns zero if successful, or a negative code at error.
  389. */
  390. int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id)
  391. {
  392. struct snd_mem_list *mem;
  393. snd_assert(dmab, return -EINVAL);
  394. mem = kmalloc(sizeof(*mem), GFP_KERNEL);
  395. if (! mem)
  396. return -ENOMEM;
  397. mutex_lock(&list_mutex);
  398. mem->buffer = *dmab;
  399. mem->id = id;
  400. list_add_tail(&mem->list, &mem_list_head);
  401. mutex_unlock(&list_mutex);
  402. return 0;
  403. }
  404. /*
  405. * purge all reserved buffers
  406. */
  407. static void free_all_reserved_pages(void)
  408. {
  409. struct list_head *p;
  410. struct snd_mem_list *mem;
  411. mutex_lock(&list_mutex);
  412. while (! list_empty(&mem_list_head)) {
  413. p = mem_list_head.next;
  414. mem = list_entry(p, struct snd_mem_list, list);
  415. list_del(p);
  416. snd_dma_free_pages(&mem->buffer);
  417. kfree(mem);
  418. }
  419. mutex_unlock(&list_mutex);
  420. }
  421. #ifdef CONFIG_PROC_FS
  422. /*
  423. * proc file interface
  424. */
  425. #define SND_MEM_PROC_FILE "driver/snd-page-alloc"
  426. static struct proc_dir_entry *snd_mem_proc;
  427. static int snd_mem_proc_read(char *page, char **start, off_t off,
  428. int count, int *eof, void *data)
  429. {
  430. int len = 0;
  431. long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
  432. struct snd_mem_list *mem;
  433. int devno;
  434. static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
  435. mutex_lock(&list_mutex);
  436. len += snprintf(page + len, count - len,
  437. "pages : %li bytes (%li pages per %likB)\n",
  438. pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
  439. devno = 0;
  440. list_for_each_entry(mem, &mem_list_head, list) {
  441. devno++;
  442. len += snprintf(page + len, count - len,
  443. "buffer %d : ID %08x : type %s\n",
  444. devno, mem->id, types[mem->buffer.dev.type]);
  445. len += snprintf(page + len, count - len,
  446. " addr = 0x%lx, size = %d bytes\n",
  447. (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes);
  448. }
  449. mutex_unlock(&list_mutex);
  450. return len;
  451. }
  452. /* FIXME: for pci only - other bus? */
  453. #ifdef CONFIG_PCI
  454. #define gettoken(bufp) strsep(bufp, " \t\n")
  455. static int snd_mem_proc_write(struct file *file, const char __user *buffer,
  456. unsigned long count, void *data)
  457. {
  458. char buf[128];
  459. char *token, *p;
  460. if (count > ARRAY_SIZE(buf) - 1)
  461. count = ARRAY_SIZE(buf) - 1;
  462. if (copy_from_user(buf, buffer, count))
  463. return -EFAULT;
  464. buf[ARRAY_SIZE(buf) - 1] = '\0';
  465. p = buf;
  466. token = gettoken(&p);
  467. if (! token || *token == '#')
  468. return (int)count;
  469. if (strcmp(token, "add") == 0) {
  470. char *endp;
  471. int vendor, device, size, buffers;
  472. long mask;
  473. int i, alloced;
  474. struct pci_dev *pci;
  475. if ((token = gettoken(&p)) == NULL ||
  476. (vendor = simple_strtol(token, NULL, 0)) <= 0 ||
  477. (token = gettoken(&p)) == NULL ||
  478. (device = simple_strtol(token, NULL, 0)) <= 0 ||
  479. (token = gettoken(&p)) == NULL ||
  480. (mask = simple_strtol(token, NULL, 0)) < 0 ||
  481. (token = gettoken(&p)) == NULL ||
  482. (size = memparse(token, &endp)) < 64*1024 ||
  483. size > 16*1024*1024 /* too big */ ||
  484. (token = gettoken(&p)) == NULL ||
  485. (buffers = simple_strtol(token, NULL, 0)) <= 0 ||
  486. buffers > 4) {
  487. printk(KERN_ERR "snd-page-alloc: invalid proc write format\n");
  488. return (int)count;
  489. }
  490. vendor &= 0xffff;
  491. device &= 0xffff;
  492. alloced = 0;
  493. pci = NULL;
  494. while ((pci = pci_get_device(vendor, device, pci)) != NULL) {
  495. if (mask > 0 && mask < 0xffffffff) {
  496. if (pci_set_dma_mask(pci, mask) < 0 ||
  497. pci_set_consistent_dma_mask(pci, mask) < 0) {
  498. printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", mask, vendor, device);
  499. return (int)count;
  500. }
  501. }
  502. for (i = 0; i < buffers; i++) {
  503. struct snd_dma_buffer dmab;
  504. memset(&dmab, 0, sizeof(dmab));
  505. if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
  506. size, &dmab) < 0) {
  507. printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size);
  508. pci_dev_put(pci);
  509. return (int)count;
  510. }
  511. snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci));
  512. }
  513. alloced++;
  514. }
  515. if (! alloced) {
  516. for (i = 0; i < buffers; i++) {
  517. struct snd_dma_buffer dmab;
  518. memset(&dmab, 0, sizeof(dmab));
  519. /* FIXME: We can allocate only in ZONE_DMA
  520. * without a device pointer!
  521. */
  522. if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, NULL,
  523. size, &dmab) < 0) {
  524. printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size);
  525. break;
  526. }
  527. snd_dma_reserve_buf(&dmab, (unsigned int)((vendor << 16) | device));
  528. }
  529. }
  530. } else if (strcmp(token, "erase") == 0)
  531. /* FIXME: need for releasing each buffer chunk? */
  532. free_all_reserved_pages();
  533. else
  534. printk(KERN_ERR "snd-page-alloc: invalid proc cmd\n");
  535. return (int)count;
  536. }
  537. #endif /* CONFIG_PCI */
  538. #endif /* CONFIG_PROC_FS */
  539. /*
  540. * module entry
  541. */
  542. static int __init snd_mem_init(void)
  543. {
  544. #ifdef CONFIG_PROC_FS
  545. snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL);
  546. if (snd_mem_proc) {
  547. snd_mem_proc->read_proc = snd_mem_proc_read;
  548. #ifdef CONFIG_PCI
  549. snd_mem_proc->write_proc = snd_mem_proc_write;
  550. #endif
  551. }
  552. #endif
  553. return 0;
  554. }
  555. static void __exit snd_mem_exit(void)
  556. {
  557. remove_proc_entry(SND_MEM_PROC_FILE, NULL);
  558. free_all_reserved_pages();
  559. if (snd_allocated_pages > 0)
  560. printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages);
  561. }
  562. module_init(snd_mem_init)
  563. module_exit(snd_mem_exit)
  564. /*
  565. * exports
  566. */
  567. EXPORT_SYMBOL(snd_dma_alloc_pages);
  568. EXPORT_SYMBOL(snd_dma_alloc_pages_fallback);
  569. EXPORT_SYMBOL(snd_dma_free_pages);
  570. EXPORT_SYMBOL(snd_dma_get_reserved_buf);
  571. EXPORT_SYMBOL(snd_dma_reserve_buf);
  572. EXPORT_SYMBOL(snd_malloc_pages);
  573. EXPORT_SYMBOL(snd_free_pages);