summaryrefslogtreecommitdiff
path: root/mali_kbase/mali_kbase_native_mgm.c
diff options
context:
space:
mode:
authorSidath Senanayake <sidaths@google.com>2019-04-10 14:37:00 +0200
committerSidath Senanayake <sidaths@google.com>2019-04-10 14:37:00 +0200
commite972f6531ef8c9d01eae567f52db4f0fd37d1428 (patch)
tree52df0c2e2665e00e4fe5822ddb50df1a72e24cd0 /mali_kbase/mali_kbase_native_mgm.c
parenta970431fa55f99aba31ea4263fdc8e70019a9ccd (diff)
downloadgpu-e972f6531ef8c9d01eae567f52db4f0fd37d1428.tar.gz
Mali Bifrost DDK r17p0 KMD
Provenance: 789dfe7c7 (collaborate/EAC/b_r17p0) BX304L01B-BU-00000-r17p0-01rel0 BX304L06A-BU-00000-r17p0-01rel0 BX304X07X-BU-00000-r17p0-01rel0 Signed-off-by: Sidath Senanayake <sidaths@google.com> Change-Id: Iff5bea2d96207a6e72d5e533e772c24a7adbdc31
Diffstat (limited to 'mali_kbase/mali_kbase_native_mgm.c')
-rw-r--r--mali_kbase/mali_kbase_native_mgm.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/mali_kbase/mali_kbase_native_mgm.c b/mali_kbase/mali_kbase_native_mgm.c
new file mode 100644
index 0000000..8c4a7fd
--- /dev/null
+++ b/mali_kbase/mali_kbase_native_mgm.c
@@ -0,0 +1,85 @@
+/*
+ *
+ * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation, and any use by you of this program is subject to the terms
+ * of such GNU licence.
+ *
+ * This program is distributed in the hope that 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, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ */
+
+#include <linux/gfp.h>
+#include <linux/memory_group_manager.h>
+
+#include <mali_kbase.h>
+#include <mali_kbase_native_mgm.h>
+
+/**
+ * kbase_native_mgm_alloc - Native physical memory allocation method
+ *
+ * Delegates all memory allocation requests to the kernel's alloc_pages
+ * function.
+ *
+ * @mgm_dev: The memory group manager the request is being made through.
+ * @group_id: A physical memory group ID, which must be valid but is not used.
+ * Its valid range is 0 .. MEMORY_GROUP_MANAGER_NR_GROUPS-1.
+ * @gfp_mask: Bitmask of Get Free Page flags affecting allocator behavior.
+ * @order: Page order for physical page size (order=0 means 4 KiB,
+ * order=9 means 2 MiB).
+ *
+ * Return: Pointer to allocated page, or NULL if allocation failed.
+ */
+static struct page *kbase_native_mgm_alloc(
+ struct memory_group_manager_device *mgm_dev, int group_id,
+ gfp_t gfp_mask, unsigned int order)
+{
+ CSTD_UNUSED(mgm_dev);
+ WARN_ON(group_id < 0);
+ WARN_ON(group_id >= MEMORY_GROUP_MANAGER_NR_GROUPS);
+
+ return alloc_pages(gfp_mask, order);
+}
+
+/**
+ * kbase_native_mgm_free - Native physical memory freeing method
+ *
+ * Delegates all memory freeing requests to the kernel's __free_pages function.
+ *
+ * @mgm_dev: The memory group manager the request is being made through.
+ * @group_id: A physical memory group ID, which must be valid but is not used.
+ * Its valid range is 0 .. MEMORY_GROUP_MANAGER_NR_GROUPS-1.
+ * @page: Address of the struct associated with a page of physical
+ * memory that was allocated by calling the alloc method of
+ * the same memory pool with the same argument values.
+ * @order: Page order for physical page size (order=0 means 4 KiB,
+ * order=9 means 2 MiB).
+ */
+static void kbase_native_mgm_free(struct memory_group_manager_device *mgm_dev,
+ int group_id, struct page *page, unsigned int order)
+{
+ CSTD_UNUSED(mgm_dev);
+ WARN_ON(group_id < 0);
+ WARN_ON(group_id >= MEMORY_GROUP_MANAGER_NR_GROUPS);
+
+ __free_pages(page, order);
+}
+
+struct memory_group_manager_device kbase_native_mgm_dev = {
+ .ops = {
+ .mgm_alloc_page = kbase_native_mgm_alloc,
+ .mgm_free_page = kbase_native_mgm_free
+ },
+ .data = NULL
+};