hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/gpu/arm/bifrost/mali_kbase_mem_lowlevel.h
....@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22 /*
33 *
4
- * (C) COPYRIGHT 2012-2014, 2016-2018, 2020-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2012-2014, 2016-2018, 2020-2022 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -47,6 +47,8 @@
4747 #define HUGE_PAGE (1u << 0)
4848 #define HUGE_HEAD (1u << 1)
4949 #define FROM_PARTIAL (1u << 2)
50
+
51
+#define NUM_4K_PAGES_IN_2MB_PAGE (SZ_2M / SZ_4K)
5052
5153 /*
5254 * Note: if macro for converting physical address to page is not defined
....@@ -158,4 +160,20 @@
158160 return t.tagged_addr & FROM_PARTIAL;
159161 }
160162
163
+/**
164
+ * index_in_large_page() - Get index of a 4KB page within a 2MB page which
165
+ * wasn't split to be used partially.
166
+ *
167
+ * @t: Tagged physical address of the physical 4KB page that lies within
168
+ * the large (or 2 MB) physical page.
169
+ *
170
+ * Return: Index of the 4KB page within a 2MB page
171
+ */
172
+static inline unsigned int index_in_large_page(struct tagged_addr t)
173
+{
174
+ WARN_ON(!is_huge(t));
175
+
176
+ return (PFN_DOWN(as_phys_addr_t(t)) & (NUM_4K_PAGES_IN_2MB_PAGE - 1));
177
+}
178
+
161179 #endif /* _KBASE_LOWLEVEL_H */