forked from Minki/linux
drm/ttm: Add a parameter to add extra pages into ttm_tt
Add a parameter called "extra_pages" for ttm_tt_init, to indicate that driver needs extra pages in ttm_tt. v2: Used imperative wording [Thomas and Christian] Signed-off-by: Ramalingam C <ramalingam.c@intel.com> cc: Christian Koenig <christian.koenig@amd.com> cc: Hellstrom Thomas <thomas.hellstrom@intel.com> Reviewed-by: Thomas Hellstrom <thomas.hellstrom@linux.intel.com> Reviewed-by: Christian Konig <christian.koenig@amd.com> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220401123751.27771-8-ramalingam.c@intel.com
This commit is contained in:
parent
ab0609a5fb
commit
e36764ecf8
@ -864,7 +864,7 @@ static struct ttm_tt *bo_driver_ttm_tt_create(struct ttm_buffer_object *bo,
|
||||
if (!tt)
|
||||
return NULL;
|
||||
|
||||
ret = ttm_tt_init(tt, bo, page_flags, ttm_cached);
|
||||
ret = ttm_tt_init(tt, bo, page_flags, ttm_cached, 0);
|
||||
if (ret < 0)
|
||||
goto err_ttm_tt_init;
|
||||
|
||||
|
@ -270,7 +270,7 @@ static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo,
|
||||
i915_tt->is_shmem = true;
|
||||
}
|
||||
|
||||
ret = ttm_tt_init(&i915_tt->ttm, bo, page_flags, caching);
|
||||
ret = ttm_tt_init(&i915_tt->ttm, bo, page_flags, caching, 0);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
|
@ -113,7 +113,7 @@ static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo,
|
||||
ttm = kzalloc(sizeof(struct ttm_tt), GFP_KERNEL);
|
||||
if (ttm == NULL)
|
||||
return NULL;
|
||||
if (ttm_tt_init(ttm, bo, page_flags, ttm_cached)) {
|
||||
if (ttm_tt_init(ttm, bo, page_flags, ttm_cached, 0)) {
|
||||
kfree(ttm);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo,
|
||||
agp_be->mem = NULL;
|
||||
agp_be->bridge = bridge;
|
||||
|
||||
if (ttm_tt_init(&agp_be->ttm, bo, page_flags, ttm_write_combined)) {
|
||||
if (ttm_tt_init(&agp_be->ttm, bo, page_flags, ttm_write_combined, 0)) {
|
||||
kfree(agp_be);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -134,9 +134,10 @@ void ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
|
||||
static void ttm_tt_init_fields(struct ttm_tt *ttm,
|
||||
struct ttm_buffer_object *bo,
|
||||
uint32_t page_flags,
|
||||
enum ttm_caching caching)
|
||||
enum ttm_caching caching,
|
||||
unsigned long extra_pages)
|
||||
{
|
||||
ttm->num_pages = PAGE_ALIGN(bo->base.size) >> PAGE_SHIFT;
|
||||
ttm->num_pages = (PAGE_ALIGN(bo->base.size) >> PAGE_SHIFT) + extra_pages;
|
||||
ttm->caching = ttm_cached;
|
||||
ttm->page_flags = page_flags;
|
||||
ttm->dma_address = NULL;
|
||||
@ -146,9 +147,10 @@ static void ttm_tt_init_fields(struct ttm_tt *ttm,
|
||||
}
|
||||
|
||||
int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
|
||||
uint32_t page_flags, enum ttm_caching caching)
|
||||
uint32_t page_flags, enum ttm_caching caching,
|
||||
unsigned long extra_pages)
|
||||
{
|
||||
ttm_tt_init_fields(ttm, bo, page_flags, caching);
|
||||
ttm_tt_init_fields(ttm, bo, page_flags, caching, extra_pages);
|
||||
|
||||
if (ttm_tt_alloc_page_directory(ttm)) {
|
||||
pr_err("Failed allocating page table\n");
|
||||
@ -180,7 +182,7 @@ int ttm_sg_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
|
||||
{
|
||||
int ret;
|
||||
|
||||
ttm_tt_init_fields(ttm, bo, page_flags, caching);
|
||||
ttm_tt_init_fields(ttm, bo, page_flags, caching, 0);
|
||||
|
||||
if (page_flags & TTM_TT_FLAG_EXTERNAL)
|
||||
ret = ttm_sg_tt_alloc_page_directory(ttm);
|
||||
|
@ -517,7 +517,7 @@ static struct ttm_tt *vmw_ttm_tt_create(struct ttm_buffer_object *bo,
|
||||
ttm_cached);
|
||||
else
|
||||
ret = ttm_tt_init(&vmw_be->dma_ttm, bo, page_flags,
|
||||
ttm_cached);
|
||||
ttm_cached, 0);
|
||||
if (unlikely(ret != 0))
|
||||
goto out_no_init;
|
||||
|
||||
|
@ -140,6 +140,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc);
|
||||
* @bo: The buffer object we create the ttm for.
|
||||
* @page_flags: Page flags as identified by TTM_TT_FLAG_XX flags.
|
||||
* @caching: the desired caching state of the pages
|
||||
* @extra_pages: Extra pages needed for the driver.
|
||||
*
|
||||
* Create a struct ttm_tt to back data with system memory pages.
|
||||
* No pages are actually allocated.
|
||||
@ -147,7 +148,8 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc);
|
||||
* NULL: Out of memory.
|
||||
*/
|
||||
int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
|
||||
uint32_t page_flags, enum ttm_caching caching);
|
||||
uint32_t page_flags, enum ttm_caching caching,
|
||||
unsigned long extra_pages);
|
||||
int ttm_sg_tt_init(struct ttm_tt *ttm_dma, struct ttm_buffer_object *bo,
|
||||
uint32_t page_flags, enum ttm_caching caching);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user