Files
linux-nvgpu/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h
Deepak Nibade c845b21012 gpu: nvgpu: support GMMU mappings for vidmem page allocator
Switch to use page allocator for vidmem

Support GMMU mappings for page (non-contiguous page allocator)
in update_gmmu_ptes_locked()
If aperture is VIDMEM, traverse each chunk in an allocation
and map it to GPU VA separately

Fix CE page clearing to support page allocator

Fix gk20a_pramin_enter() to get base address from new
allocator
Define API gk20a_mem_get_vidmem_addr() to get base address
of allocation. Note that this API should not be used if we
have more than 1 chunk

Jira DNVGPU-96

Change-Id: I725422f3538aeb477ca4220ba57ef8b3c53db703
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1199177
(cherry picked from commit 1afae6ee6529ab88cedd5bcbe458fbdc0d4b1fd8)
Reviewed-on: http://git-master/r/1197647
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2016-09-01 09:10:00 -07:00

102 lines
2.3 KiB
C

/*
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PAGE_ALLOCATOR_PRIV_H
#define PAGE_ALLOCATOR_PRIV_H
#include <linux/list.h>
#include <linux/rbtree.h>
#include <gk20a/gk20a_allocator.h>
#include "gk20a_allocator.h"
struct gk20a_allocator;
struct page_alloc_chunk {
struct list_head list_entry;
u64 base;
u64 length;
};
/*
* Struct to handle internal management of page allocation. It holds a list
* of the chunks of page that make up the overall allocation - much like a
* scatter gather table.
*/
struct gk20a_page_alloc {
struct list_head alloc_chunks;
int nr_chunks;
u64 length;
/*
* Only useful for the RB tree - since the alloc will have discontiguous
* pages the base is essentially irrelevant except for the fact that it
* is guarenteed to be unique.
*/
u64 base;
struct rb_node tree_entry;
};
struct gk20a_page_allocator {
struct gk20a_allocator *owner; /* Owner of this allocator. */
/*
* Use a buddy allocator to manage the allocation of the underlying
* pages. This lets us abstract the discontiguous allocation handling
* out of the annoyingly complicated buddy allocator.
*/
struct gk20a_allocator source_allocator;
/*
* Page params.
*/
u64 base;
u64 length;
u64 page_size;
u32 page_shift;
struct rb_root allocs; /* Outstanding allocations. */
u64 flags;
/*
* Stat tracking.
*/
u64 nr_allocs;
u64 nr_frees;
u64 nr_fixed_allocs;
u64 nr_fixed_frees;
u64 pages_alloced;
u64 pages_freed;
};
static inline struct gk20a_page_allocator *page_allocator(
struct gk20a_allocator *a)
{
return (struct gk20a_page_allocator *)(a)->priv;
}
static inline struct gk20a_allocator *palloc_owner(
struct gk20a_page_allocator *a)
{
return a->owner;
}
#endif