138136Sdfr/* 238136Sdfr * Copyright (c) Red Hat Inc. 338136Sdfr 438136Sdfr * Permission is hereby granted, free of charge, to any person obtaining a 538136Sdfr * copy of this software and associated documentation files (the "Software"), 638136Sdfr * to deal in the Software without restriction, including without limitation 738136Sdfr * the rights to use, copy, modify, merge, publish, distribute, sub license, 838136Sdfr * and/or sell copies of the Software, and to permit persons to whom the 938136Sdfr * Software is furnished to do so, subject to the following conditions: 1038136Sdfr * 1138136Sdfr * The above copyright notice and this permission notice (including the 1238136Sdfr * next paragraph) shall be included in all copies or substantial portions 1338136Sdfr * of the Software. 1438136Sdfr * 1538136Sdfr * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1638136Sdfr * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1738136Sdfr * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 1838136Sdfr * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1938136Sdfr * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2038136Sdfr * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2138136Sdfr * DEALINGS IN THE SOFTWARE. 2238136Sdfr * 2338136Sdfr * Authors: Dave Airlie <airlied@redhat.com> 2438136Sdfr * Jerome Glisse <jglisse@redhat.com> 2538136Sdfr */ 2650477Speter/* $FreeBSD$ */ 2738136Sdfr#ifndef TTM_PAGE_ALLOC 2838136Sdfr#define TTM_PAGE_ALLOC 2947613Sdfr 3047613Sdfr#include <dev/drm2/ttm/ttm_bo_driver.h> 3147613Sdfr#include <dev/drm2/ttm/ttm_memory.h> 3250769Sdfr 3350769Sdfr/** 3450769Sdfr * Initialize pool allocator. 3550769Sdfr */ 3647398Sdfrint ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages); 3750769Sdfr/** 3847398Sdfr * Free pool allocator. 3955206Speter */ 4047613Sdfrvoid ttm_page_alloc_fini(void); 4147578Sdfr 4247578Sdfr/** 4347578Sdfr * ttm_pool_populate: 4447578Sdfr * 4547578Sdfr * @ttm: The struct ttm_tt to contain the backing pages. 4647578Sdfr * 4747578Sdfr * Add backing pages to all of @ttm 4847578Sdfr */ 4947578Sdfrextern int ttm_pool_populate(struct ttm_tt *ttm); 5047578Sdfr 5147578Sdfr/** 5266840Smsmith * ttm_pool_unpopulate: 5366840Smsmith * 5466840Smsmith * @ttm: The struct ttm_tt which to free backing pages. 5557368Sgj * 5666840Smsmith * Free all pages of @ttm 5766840Smsmith */ 5866840Smsmithextern void ttm_pool_unpopulate(struct ttm_tt *ttm); 5941181Sdfr 6066840Smsmith/** 6166840Smsmith * Output the state of pools to debugfs file 6266840Smsmith */ 6366840Smsmith/* XXXKIB 6466840Smsmithextern int ttm_page_alloc_debugfs(struct seq_file *m, void *data); 6566840Smsmith*/ 6666840Smsmith 6766840Smsmith#ifdef CONFIG_SWIOTLB 6857973Sphk/** 6957973Sphk * Initialize pool allocator. 7057973Sphk */ 7150769Sdfrint ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages); 7250769Sdfr 7350769Sdfr/** 7450769Sdfr * Free pool allocator. 7550769Sdfr */ 7650769Sdfrvoid ttm_dma_page_alloc_fini(void); 7750769Sdfr 7850769Sdfr/** 7950769Sdfr * Output the state of pools to debugfs file 8050769Sdfr */ 8150769Sdfrextern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data); 8250769Sdfr 8350769Sdfrextern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev); 8450769Sdfrextern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev); 8550769Sdfr 8650769Sdfr#else 8750769Sdfrstatic inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, 8850769Sdfr unsigned max_pages) 8950769Sdfr{ 9050769Sdfr return -ENODEV; 9150769Sdfr} 9250769Sdfr 9350769Sdfrstatic inline void ttm_dma_page_alloc_fini(void) { return; } 9450769Sdfr 9550769Sdfr/* XXXKIB 9650769Sdfrstatic inline int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data) 9750769Sdfr{ 9850769Sdfr return 0; 9950769Sdfr} 10050769Sdfr*/ 10150769Sdfr#endif 10250769Sdfr 10350769Sdfr#endif 10438136Sdfr