diff options
author | Sidath Senanayake <sidaths@google.com> | 2019-06-27 14:37:54 +0200 |
---|---|---|
committer | Sidath Senanayake <sidaths@google.com> | 2019-06-27 14:37:54 +0200 |
commit | 228451ed83f4840e863beff27b33ca9a460f820b (patch) | |
tree | dd7cbcae7ac302e9d381d95251ad5a0298bec5ae /common | |
parent | ac90f0dd5fbae0b94e9720203a8bb2e81fd4b679 (diff) | |
download | gpu-228451ed83f4840e863beff27b33ca9a460f820b.tar.gz |
Mali Valhall DDK r19p0 KMD
Provenance:
95928c7e8 (collaborate/EAC/v_r19p0)
VX504X08X-BU-00000-r19p0-01rel0 - Android DDK
NOTE: This is identical to the Bifrost r19p0 KMD as the
only differences between b_r19p0 and v_r19p0 are outside
of the KMD. So as far as the KMD goes, 95928c7e8 and
d441d721a in Collaborate are identical.
Signed-off-by: Sidath Senanayake <sidaths@google.com>
Change-Id: I261cba9d04daaf8c5ca55e4cb319cf47402dc5f4
Diffstat (limited to 'common')
-rw-r--r-- | common/include/linux/memory_group_manager.h | 106 |
1 files changed, 104 insertions, 2 deletions
diff --git a/common/include/linux/memory_group_manager.h b/common/include/linux/memory_group_manager.h index 8b19786..b1ac253 100644 --- a/common/include/linux/memory_group_manager.h +++ b/common/include/linux/memory_group_manager.h @@ -23,16 +23,28 @@ #ifndef _MEMORY_GROUP_MANAGER_H_ #define _MEMORY_GROUP_MANAGER_H_ +#include <linux/mm.h> +#include <linux/of.h> +#include <linux/version.h> + +#if (KERNEL_VERSION(4, 17, 0) > LINUX_VERSION_CODE) +typedef int vm_fault_t; +#endif + #define MEMORY_GROUP_MANAGER_NR_GROUPS (16) struct memory_group_manager_device; +struct memory_group_manager_import_data; /** * struct memory_group_manager_ops - Callbacks for memory group manager * operations * - * @mgm_alloc_page: Callback to allocate physical memory in a group - * @mgm_free_page: Callback to free physical memory in a group + * @mgm_alloc_page: Callback to allocate physical memory in a group + * @mgm_free_page: Callback to free physical memory in a group + * @mgm_get_import_memory_id: Callback to get the group ID for imported memory + * @mgm_update_gpu_pte: Callback to modify a GPU page table entry + * @mgm_vmf_insert_pfn_prot: Callback to map a physical memory page for the CPU */ struct memory_group_manager_ops { /** @@ -72,6 +84,75 @@ struct memory_group_manager_ops { void (*mgm_free_page)( struct memory_group_manager_device *mgm_dev, int group_id, struct page *page, unsigned int order); + + /** + * mgm_get_import_memory_id - Get the physical memory group ID for the + * imported memory + * + * @mgm_dev: The memory group manager through which the request + * is being made. + * @import_data: Pointer to the data which describes imported memory. + * + * Note that provision of this call back is optional, where it is not + * provided this call back pointer must be set to NULL to indicate it + * is not in use. + * + * Return: The memory group ID to use when mapping pages from this + * imported memory. + */ + int (*mgm_get_import_memory_id)( + struct memory_group_manager_device *mgm_dev, + struct memory_group_manager_import_data *import_data); + + /** + * mgm_update_gpu_pte - Modify a GPU page table entry for a memory group + * + * @mgm_dev: The memory group manager through which the request + * is being made. + * @group_id: A physical memory group ID. The meaning of this is + * defined by the systems integrator. Its valid range is + * 0 .. MEMORY_GROUP_MANAGER_NR_GROUPS-1. + * @mmu_level: The level of the page table entry in @ate. + * @pte: The page table entry to modify, in LPAE or AArch64 format + * (depending on the driver's configuration). This should be + * decoded to determine the physical address and any other + * properties of the mapping the manager requires. + * + * This function allows the memory group manager to modify a GPU page + * table entry before it is stored by the kbase module (controller + * driver). It may set certain bits in the page table entry attributes + * or in the physical address, based on the physical memory group ID. + * + * Return: A modified GPU page table entry to be stored in a page table. + */ + u64 (*mgm_update_gpu_pte)(struct memory_group_manager_device *mgm_dev, + int group_id, int mmu_level, u64 pte); + + /** + * mgm_vmf_insert_pfn_prot - Map a physical page in a group for the CPU + * + * @mgm_dev: The memory group manager through which the request + * is being made. + * @group_id: A physical memory group ID. The meaning of this is + * defined by the systems integrator. Its valid range is + * 0 .. MEMORY_GROUP_MANAGER_NR_GROUPS-1. + * @vma: The virtual memory area to insert the page into. + * @addr: A virtual address (in @vma) to assign to the page. + * @pfn: The kernel Page Frame Number to insert at @addr in @vma. + * @pgprot: Protection flags for the inserted page. + * + * Called from a CPU virtual memory page fault handler. This function + * creates a page table entry from the given parameter values and stores + * it at the appropriate location (unlike mgm_update_gpu_pte, which + * returns a modified entry). + * + * Return: Type of fault that occurred or VM_FAULT_NOPAGE if the page + * table entry was successfully installed. + */ + vm_fault_t (*mgm_vmf_insert_pfn_prot)( + struct memory_group_manager_device *mgm_dev, int group_id, + struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t pgprot); }; /** @@ -91,6 +172,27 @@ struct memory_group_manager_ops { struct memory_group_manager_device { struct memory_group_manager_ops ops; void *data; + struct module *owner; +}; + + +enum memory_group_manager_import_type { + MEMORY_GROUP_MANAGER_IMPORT_TYPE_DMA_BUF +}; + +/** + * struct memory_group_manager_import_data - Structure describing the imported + * memory + * + * @type - type of imported memory + * @u - Union describing the imported memory + * + */ +struct memory_group_manager_import_data { + enum memory_group_manager_import_type type; + union { + struct dma_buf *dma_buf; + } u; }; #endif /* _MEMORY_GROUP_MANAGER_H_ */ |