ttm: Introduce a placeholder for DMA (bus) addresses.
This is right now limited to only non-pool constructs. [v2: Fixed indentation issues, add review-by tag] Reviewed-by: Thomas Hellstrom <thomas@shipmail.org> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Tested-by: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/seq_file.h> /* for seq_printf */
|
#include <linux/seq_file.h> /* for seq_printf */
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/dma-mapping.h>
|
||||||
|
|
||||||
#include <asm/atomic.h>
|
#include <asm/atomic.h>
|
||||||
|
|
||||||
@@ -662,7 +663,8 @@ out:
|
|||||||
* cached pages.
|
* cached pages.
|
||||||
*/
|
*/
|
||||||
int ttm_get_pages(struct list_head *pages, int flags,
|
int ttm_get_pages(struct list_head *pages, int flags,
|
||||||
enum ttm_caching_state cstate, unsigned count)
|
enum ttm_caching_state cstate, unsigned count,
|
||||||
|
dma_addr_t *dma_address)
|
||||||
{
|
{
|
||||||
struct ttm_page_pool *pool = ttm_get_pool(flags, cstate);
|
struct ttm_page_pool *pool = ttm_get_pool(flags, cstate);
|
||||||
struct page *p = NULL;
|
struct page *p = NULL;
|
||||||
@@ -720,7 +722,7 @@ int ttm_get_pages(struct list_head *pages, int flags,
|
|||||||
printk(KERN_ERR TTM_PFX
|
printk(KERN_ERR TTM_PFX
|
||||||
"Failed to allocate extra pages "
|
"Failed to allocate extra pages "
|
||||||
"for large request.");
|
"for large request.");
|
||||||
ttm_put_pages(pages, 0, flags, cstate);
|
ttm_put_pages(pages, 0, flags, cstate, NULL);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -731,7 +733,7 @@ int ttm_get_pages(struct list_head *pages, int flags,
|
|||||||
|
|
||||||
/* Put all pages in pages list to correct pool to wait for reuse */
|
/* Put all pages in pages list to correct pool to wait for reuse */
|
||||||
void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags,
|
void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags,
|
||||||
enum ttm_caching_state cstate)
|
enum ttm_caching_state cstate, dma_addr_t *dma_address)
|
||||||
{
|
{
|
||||||
unsigned long irq_flags;
|
unsigned long irq_flags;
|
||||||
struct ttm_page_pool *pool = ttm_get_pool(flags, cstate);
|
struct ttm_page_pool *pool = ttm_get_pool(flags, cstate);
|
||||||
|
@@ -49,12 +49,16 @@ static int ttm_tt_swapin(struct ttm_tt *ttm);
|
|||||||
static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
|
static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
|
||||||
{
|
{
|
||||||
ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages));
|
ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages));
|
||||||
|
ttm->dma_address = drm_calloc_large(ttm->num_pages,
|
||||||
|
sizeof(*ttm->dma_address));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
|
static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
|
||||||
{
|
{
|
||||||
drm_free_large(ttm->pages);
|
drm_free_large(ttm->pages);
|
||||||
ttm->pages = NULL;
|
ttm->pages = NULL;
|
||||||
|
drm_free_large(ttm->dma_address);
|
||||||
|
ttm->dma_address = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ttm_tt_free_user_pages(struct ttm_tt *ttm)
|
static void ttm_tt_free_user_pages(struct ttm_tt *ttm)
|
||||||
@@ -105,7 +109,8 @@ static struct page *__ttm_tt_get_page(struct ttm_tt *ttm, int index)
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&h);
|
INIT_LIST_HEAD(&h);
|
||||||
|
|
||||||
ret = ttm_get_pages(&h, ttm->page_flags, ttm->caching_state, 1);
|
ret = ttm_get_pages(&h, ttm->page_flags, ttm->caching_state, 1,
|
||||||
|
&ttm->dma_address[index]);
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -298,7 +303,8 @@ static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ttm_put_pages(&h, count, ttm->page_flags, ttm->caching_state);
|
ttm_put_pages(&h, count, ttm->page_flags, ttm->caching_state,
|
||||||
|
ttm->dma_address);
|
||||||
ttm->state = tt_unpopulated;
|
ttm->state = tt_unpopulated;
|
||||||
ttm->first_himem_page = ttm->num_pages;
|
ttm->first_himem_page = ttm->num_pages;
|
||||||
ttm->last_lomem_page = -1;
|
ttm->last_lomem_page = -1;
|
||||||
|
@@ -149,6 +149,7 @@ enum ttm_caching_state {
|
|||||||
* @swap_storage: Pointer to shmem struct file for swap storage.
|
* @swap_storage: Pointer to shmem struct file for swap storage.
|
||||||
* @caching_state: The current caching state of the pages.
|
* @caching_state: The current caching state of the pages.
|
||||||
* @state: The current binding state of the pages.
|
* @state: The current binding state of the pages.
|
||||||
|
* @dma_address: The DMA (bus) addresses of the pages (if TTM_PAGE_FLAG_DMA32)
|
||||||
*
|
*
|
||||||
* This is a structure holding the pages, caching- and aperture binding
|
* This is a structure holding the pages, caching- and aperture binding
|
||||||
* status for a buffer object that isn't backed by fixed (VRAM / AGP)
|
* status for a buffer object that isn't backed by fixed (VRAM / AGP)
|
||||||
@@ -173,6 +174,7 @@ struct ttm_tt {
|
|||||||
tt_unbound,
|
tt_unbound,
|
||||||
tt_unpopulated,
|
tt_unpopulated,
|
||||||
} state;
|
} state;
|
||||||
|
dma_addr_t *dma_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */
|
#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */
|
||||||
|
@@ -36,11 +36,13 @@
|
|||||||
* @flags: ttm flags for page allocation.
|
* @flags: ttm flags for page allocation.
|
||||||
* @cstate: ttm caching state for the page.
|
* @cstate: ttm caching state for the page.
|
||||||
* @count: number of pages to allocate.
|
* @count: number of pages to allocate.
|
||||||
|
* @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set).
|
||||||
*/
|
*/
|
||||||
int ttm_get_pages(struct list_head *pages,
|
int ttm_get_pages(struct list_head *pages,
|
||||||
int flags,
|
int flags,
|
||||||
enum ttm_caching_state cstate,
|
enum ttm_caching_state cstate,
|
||||||
unsigned count);
|
unsigned count,
|
||||||
|
dma_addr_t *dma_address);
|
||||||
/**
|
/**
|
||||||
* Put linked list of pages to pool.
|
* Put linked list of pages to pool.
|
||||||
*
|
*
|
||||||
@@ -49,11 +51,13 @@ int ttm_get_pages(struct list_head *pages,
|
|||||||
* count.
|
* count.
|
||||||
* @flags: ttm flags for page allocation.
|
* @flags: ttm flags for page allocation.
|
||||||
* @cstate: ttm caching state.
|
* @cstate: ttm caching state.
|
||||||
|
* @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set).
|
||||||
*/
|
*/
|
||||||
void ttm_put_pages(struct list_head *pages,
|
void ttm_put_pages(struct list_head *pages,
|
||||||
unsigned page_count,
|
unsigned page_count,
|
||||||
int flags,
|
int flags,
|
||||||
enum ttm_caching_state cstate);
|
enum ttm_caching_state cstate,
|
||||||
|
dma_addr_t *dma_address);
|
||||||
/**
|
/**
|
||||||
* Initialize pool allocator.
|
* Initialize pool allocator.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user