hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/arm/bifrost/mali_kbase_defs.h
....@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22 /*
33 *
4
- * (C) COPYRIGHT 2011-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2011-2023 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
....@@ -35,11 +35,15 @@
3535 #include <backend/gpu/mali_kbase_instr_defs.h>
3636 #include <mali_kbase_pm.h>
3737 #include <mali_kbase_gpuprops_types.h>
38
+#include <hwcnt/mali_kbase_hwcnt_watchdog_if.h>
39
+
3840 #if MALI_USE_CSF
39
-#include <mali_kbase_hwcnt_backend_csf.h>
41
+#include <hwcnt/backend/mali_kbase_hwcnt_backend_csf.h>
4042 #else
41
-#include <mali_kbase_hwcnt_backend_jm.h>
43
+#include <hwcnt/backend/mali_kbase_hwcnt_backend_jm.h>
44
+#include <hwcnt/backend/mali_kbase_hwcnt_backend_jm_watchdog.h>
4245 #endif
46
+
4347 #include <protected_mode_switcher.h>
4448
4549 #include <linux/atomic.h>
....@@ -49,11 +53,7 @@
4953 #include <linux/sizes.h>
5054
5155
52
-#if defined(CONFIG_SYNC)
53
-#include <sync.h>
54
-#else
5556 #include "mali_kbase_fence_defs.h"
56
-#endif
5757
5858 #if IS_ENABLED(CONFIG_DEBUG_FS)
5959 #include <linux/debugfs.h>
....@@ -63,6 +63,10 @@
6363 #include <linux/devfreq.h>
6464 #endif /* CONFIG_MALI_BIFROST_DEVFREQ */
6565
66
+#if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
67
+#include <linux/devfreq_cooling.h>
68
+#endif
69
+
6670 #ifdef CONFIG_MALI_ARBITER_SUPPORT
6771 #include <arbiter/mali_kbase_arbiter_defs.h>
6872 #endif /* CONFIG_MALI_ARBITER_SUPPORT */
....@@ -70,10 +74,7 @@
7074 #include <linux/clk.h>
7175 #include <linux/regulator/consumer.h>
7276 #include <linux/memory_group_manager.h>
73
-
74
-#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM)
75
-#define KBASE_PM_RUNTIME 1
76
-#endif
77
+#include <soc/rockchip/rockchip_opp_select.h>
7778
7879 #include "debug/mali_kbase_debug_ktrace_defs.h"
7980
....@@ -81,7 +82,7 @@
8182 #define RESET_TIMEOUT 500
8283
8384 /**
84
- * The maximum number of Job Slots to support in the Hardware.
85
+ * BASE_JM_MAX_NR_SLOTS - The maximum number of Job Slots to support in the Hardware.
8586 *
8687 * You can optimize this down if your target devices will only ever support a
8788 * small number of job slots.
....@@ -89,7 +90,7 @@
8990 #define BASE_JM_MAX_NR_SLOTS 3
9091
9192 /**
92
- * The maximum number of Address Spaces to support in the Hardware.
93
+ * BASE_MAX_NR_AS - The maximum number of Address Spaces to support in the Hardware.
9394 *
9495 * You can optimize this down if your target devices will only ever support a
9596 * small number of Address Spaces
....@@ -109,27 +110,26 @@
109110 #define KBASEP_AS_NR_INVALID (-1)
110111
111112 /**
112
- * Maximum size in bytes of a MMU lock region, as a logarithm
113
+ * KBASE_LOCK_REGION_MAX_SIZE_LOG2 - Maximum size in bytes of a MMU lock region,
114
+ * as a logarithm
113115 */
114
-#define KBASE_LOCK_REGION_MAX_SIZE_LOG2 (64)
116
+#define KBASE_LOCK_REGION_MAX_SIZE_LOG2 (48) /* 256 TB */
115117
116118 /**
117
- * Minimum size in bytes of a MMU lock region, as a logarithm
119
+ * KBASE_REG_ZONE_MAX - Maximum number of GPU memory region zones
118120 */
119
-#define KBASE_LOCK_REGION_MIN_SIZE_LOG2 (15)
120
-
121
-/**
122
- * Maximum number of GPU memory region zones
123
- */
121
+#if MALI_USE_CSF
122
+#define KBASE_REG_ZONE_MAX 6ul
123
+#else
124124 #define KBASE_REG_ZONE_MAX 4ul
125
+#endif
125126
126127 #include "mali_kbase_hwaccess_defs.h"
127128
128129 /* Maximum number of pages of memory that require a permanent mapping, per
129130 * kbase_context
130131 */
131
-#define KBASE_PERMANENTLY_MAPPED_MEM_LIMIT_PAGES ((32 * 1024ul * 1024ul) >> \
132
- PAGE_SHIFT)
132
+#define KBASE_PERMANENTLY_MAPPED_MEM_LIMIT_PAGES ((64 * 1024ul * 1024ul) >> PAGE_SHIFT)
133133 /* Minimum threshold period for hwcnt dumps between different hwcnt virtualizer
134134 * clients, to reduce undesired system load.
135135 * If a virtualizer client requests a dump within this threshold period after
....@@ -152,8 +152,10 @@
152152 * the device node.
153153 * This is dependent on support for of_property_read_u64_array() in the
154154 * kernel.
155
+ * While, the number of clocks could be more than regulators,
156
+ * as mentioned in power_control_init().
155157 */
156
-#define BASE_MAX_NR_CLOCKS_REGULATORS (2)
158
+#define BASE_MAX_NR_CLOCKS_REGULATORS (4)
157159
158160 /* Forward declarations */
159161 struct kbase_context;
....@@ -243,11 +245,25 @@
243245 bool protected_mode;
244246 };
245247
248
+/** Maximum number of memory pages that should be allocated for the array
249
+ * of pointers to free PGDs.
250
+ *
251
+ * This number has been pre-calculated to deal with the maximum allocation
252
+ * size expressed by the default value of KBASE_MEM_ALLOC_MAX_SIZE.
253
+ * This is supposed to be enough for almost the entirety of MMU operations.
254
+ * Any size greater than KBASE_MEM_ALLOC_MAX_SIZE requires being broken down
255
+ * into multiple iterations, each dealing with at most KBASE_MEM_ALLOC_MAX_SIZE
256
+ * bytes.
257
+ *
258
+ * Please update this value if KBASE_MEM_ALLOC_MAX_SIZE changes.
259
+ */
260
+#define MAX_PAGES_FOR_FREE_PGDS ((size_t)9)
261
+
262
+/* Maximum number of pointers to free PGDs */
263
+#define MAX_FREE_PGDS ((PAGE_SIZE / sizeof(struct page *)) * MAX_PAGES_FOR_FREE_PGDS)
264
+
246265 /**
247266 * struct kbase_mmu_table - object representing a set of GPU page tables
248
- * @mmu_teardown_pages: Buffer of 4 Pages in size, used to cache the entries
249
- * of top & intermediate level page tables to avoid
250
- * repeated calls to kmap_atomic during the MMU teardown.
251267 * @mmu_lock: Lock to serialize the accesses made to multi level GPU
252268 * page tables
253269 * @pgd: Physical address of the page allocated for the top
....@@ -259,14 +275,55 @@
259275 * Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
260276 * @kctx: If this set of MMU tables belongs to a context then
261277 * this is a back-reference to the context, otherwise
262
- * it is NULL
278
+ * it is NULL.
279
+ * @scratch_mem: Scratch memory used for MMU operations, which are
280
+ * serialized by the @mmu_lock.
263281 */
264282 struct kbase_mmu_table {
265
- u64 *mmu_teardown_pages;
266283 struct mutex mmu_lock;
267284 phys_addr_t pgd;
268285 u8 group_id;
269286 struct kbase_context *kctx;
287
+ union {
288
+ /**
289
+ * @teardown_pages: Scratch memory used for backup copies of whole
290
+ * PGD pages when tearing down levels upon
291
+ * termination of the MMU table.
292
+ */
293
+ struct {
294
+ /**
295
+ * @levels: Array of PGD pages, large enough to copy one PGD
296
+ * for each level of the MMU table.
297
+ */
298
+ u64 levels[MIDGARD_MMU_BOTTOMLEVEL][PAGE_SIZE / sizeof(u64)];
299
+ } teardown_pages;
300
+ /**
301
+ * @free_pgds: Scratch memory user for insertion, update and teardown
302
+ * operations to store a temporary list of PGDs to be freed
303
+ * at the end of the operation.
304
+ */
305
+ struct {
306
+ /** @pgds: Array of pointers to PGDs to free. */
307
+ struct page *pgds[MAX_FREE_PGDS];
308
+ /** @head_index: Index of first free element in the PGDs array. */
309
+ size_t head_index;
310
+ } free_pgds;
311
+ } scratch_mem;
312
+};
313
+
314
+/**
315
+ * struct kbase_reg_zone - Information about GPU memory region zones
316
+ * @base_pfn: Page Frame Number in GPU virtual address space for the start of
317
+ * the Zone
318
+ * @va_size_pages: Size of the Zone in pages
319
+ *
320
+ * Track information about a zone KBASE_REG_ZONE() and related macros.
321
+ * In future, this could also store the &rb_root that are currently in
322
+ * &kbase_context and &kbase_csf_device.
323
+ */
324
+struct kbase_reg_zone {
325
+ u64 base_pfn;
326
+ u64 va_size_pages;
270327 };
271328
272329 #if MALI_USE_CSF
....@@ -274,6 +331,8 @@
274331 #else
275332 #include "jm/mali_kbase_jm_defs.h"
276333 #endif
334
+
335
+#include "mali_kbase_hwaccess_time.h"
277336
278337 static inline int kbase_as_has_bus_fault(struct kbase_as *as,
279338 struct kbase_fault *fault)
....@@ -339,8 +398,6 @@
339398 * enumerated GPU clock.
340399 * @clk_rate_trace_ops: Pointer to the platform specific GPU clock rate trace
341400 * operations.
342
- * @gpu_clk_rate_trace_write: Pointer to the function that would emit the
343
- * tracepoint for the clock rate change.
344401 * @listeners: List of listener attached.
345402 * @lock: Lock to serialize the actions of GPU clock rate trace
346403 * manager.
....@@ -355,39 +412,49 @@
355412
356413 /**
357414 * struct kbase_pm_device_data - Data stored per device for power management.
358
- * @lock: The lock protecting Power Management structures accessed outside of
359
- * IRQ.
360
- * This lock must also be held whenever the GPU is being powered on or
361
- * off.
362
- * @active_count: The reference count of active contexts on this device. Note
363
- * that some code paths keep shaders/the tiler powered whilst this is 0.
364
- * Use kbase_pm_is_active() instead to check for such cases.
415
+ * @lock: The lock protecting Power Management structures accessed
416
+ * outside of IRQ.
417
+ * This lock must also be held whenever the GPU is being
418
+ * powered on or off.
419
+ * @active_count: The reference count of active contexts on this device.
420
+ * Note that some code paths keep shaders/the tiler
421
+ * powered whilst this is 0.
422
+ * Use kbase_pm_is_active() instead to check for such cases.
365423 * @suspending: Flag indicating suspending/suspended
424
+ * @runtime_active: Flag to track if the GPU is in runtime suspended or active
425
+ * state. This ensures that runtime_put and runtime_get
426
+ * functions are called in pairs. For example if runtime_get
427
+ * has already been called from the power_on callback, then
428
+ * the call to it from runtime_gpu_active callback can be
429
+ * skipped.
366430 * @gpu_lost: Flag indicating gpu lost
367
- * This structure contains data for the power management framework. There
368
- * is one instance of this structure per device in the system.
431
+ * This structure contains data for the power management framework.
432
+ * There is one instance of this structure per device in the system.
369433 * @zero_active_count_wait: Wait queue set when active_count == 0
370434 * @resume_wait: system resume of GPU device.
371435 * @debug_core_mask: Bit masks identifying the available shader cores that are
372
- * specified via sysfs. One mask per job slot.
436
+ * specified via sysfs. One mask per job slot.
373437 * @debug_core_mask_all: Bit masks identifying the available shader cores that
374
- * are specified via sysfs.
438
+ * are specified via sysfs.
375439 * @callback_power_runtime_init: Callback for initializing the runtime power
376
- * management. Return 0 on success, else error code
440
+ * management. Return 0 on success, else error code
377441 * @callback_power_runtime_term: Callback for terminating the runtime power
378
- * management.
442
+ * management.
379443 * @dvfs_period: Time in milliseconds between each dvfs sample
380444 * @backend: KBase PM backend data
381445 * @arb_vm_state: The state of the arbiter VM machine
382446 * @gpu_users_waiting: Used by virtualization to notify the arbiter that there
383
- * are users waiting for the GPU so that it can request and resume the
384
- * driver.
447
+ * are users waiting for the GPU so that it can request
448
+ * and resume the driver.
385449 * @clk_rtm: The state of the GPU clock rate trace manager
386450 */
387451 struct kbase_pm_device_data {
388452 struct mutex lock;
389453 int active_count;
390454 bool suspending;
455
+#if MALI_USE_CSF
456
+ bool runtime_active;
457
+#endif
391458 #ifdef CONFIG_MALI_ARBITER_SUPPORT
392459 atomic_t gpu_lost;
393460 #endif /* CONFIG_MALI_ARBITER_SUPPORT */
....@@ -415,36 +482,40 @@
415482
416483 /**
417484 * struct kbase_mem_pool - Page based memory pool for kctx/kbdev
418
- * @kbdev: Kbase device where memory is used
419
- * @cur_size: Number of free pages currently in the pool (may exceed
420
- * @max_size in some corner cases)
421
- * @max_size: Maximum number of free pages in the pool
422
- * @order: order = 0 refers to a pool of 4 KB pages
423
- * order = 9 refers to a pool of 2 MB pages (2^9 * 4KB = 2 MB)
424
- * @group_id: A memory group ID to be passed to a platform-specific
425
- * memory group manager, if present. Immutable.
426
- * Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
427
- * @pool_lock: Lock protecting the pool - must be held when modifying
428
- * @cur_size and @page_list
429
- * @page_list: List of free pages in the pool
430
- * @reclaim: Shrinker for kernel reclaim of free pages
431
- * @next_pool: Pointer to next pool where pages can be allocated when this
432
- * pool is empty. Pages will spill over to the next pool when
433
- * this pool is full. Can be NULL if there is no next pool.
434
- * @dying: true if the pool is being terminated, and any ongoing
435
- * operations should be abandoned
436
- * @dont_reclaim: true if the shrinker is forbidden from reclaiming memory from
437
- * this pool, eg during a grow operation
485
+ * @kbdev: Kbase device where memory is used
486
+ * @cur_size: Number of free pages currently in the pool (may exceed
487
+ * @max_size in some corner cases)
488
+ * @max_size: Maximum number of free pages in the pool
489
+ * @order: order = 0 refers to a pool of 4 KB pages
490
+ * order = 9 refers to a pool of 2 MB pages (2^9 * 4KB = 2 MB)
491
+ * @group_id: A memory group ID to be passed to a platform-specific
492
+ * memory group manager, if present. Immutable.
493
+ * Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
494
+ * @pool_lock: Lock protecting the pool - must be held when modifying
495
+ * @cur_size and @page_list
496
+ * @page_list: List of free pages in the pool
497
+ * @reclaim: Shrinker for kernel reclaim of free pages
498
+ * @isolation_in_progress_cnt: Number of pages in pool undergoing page isolation.
499
+ * This is used to avoid race condition between pool termination
500
+ * and page isolation for page migration.
501
+ * @next_pool: Pointer to next pool where pages can be allocated when this
502
+ * pool is empty. Pages will spill over to the next pool when
503
+ * this pool is full. Can be NULL if there is no next pool.
504
+ * @dying: true if the pool is being terminated, and any ongoing
505
+ * operations should be abandoned
506
+ * @dont_reclaim: true if the shrinker is forbidden from reclaiming memory from
507
+ * this pool, eg during a grow operation
438508 */
439509 struct kbase_mem_pool {
440510 struct kbase_device *kbdev;
441
- size_t cur_size;
442
- size_t max_size;
443
- u8 order;
444
- u8 group_id;
445
- spinlock_t pool_lock;
446
- struct list_head page_list;
447
- struct shrinker reclaim;
511
+ size_t cur_size;
512
+ size_t max_size;
513
+ u8 order;
514
+ u8 group_id;
515
+ spinlock_t pool_lock;
516
+ struct list_head page_list;
517
+ struct shrinker reclaim;
518
+ atomic_t isolation_in_progress_cnt;
448519
449520 struct kbase_mem_pool *next_pool;
450521
....@@ -455,16 +526,16 @@
455526 /**
456527 * struct kbase_mem_pool_group - a complete set of physical memory pools.
457528 *
529
+ * @small: Array of objects containing the state for pools of 4 KiB size
530
+ * physical pages.
531
+ * @large: Array of objects containing the state for pools of 2 MiB size
532
+ * physical pages.
533
+ *
458534 * Memory pools are used to allow efficient reallocation of previously-freed
459535 * physical pages. A pair of memory pools is initialized for each physical
460536 * memory group: one for 4 KiB pages and one for 2 MiB pages. These arrays
461537 * should be indexed by physical memory group ID, the meaning of which is
462538 * defined by the systems integrator.
463
- *
464
- * @small: Array of objects containing the state for pools of 4 KiB size
465
- * physical pages.
466
- * @large: Array of objects containing the state for pools of 2 MiB size
467
- * physical pages.
468539 */
469540 struct kbase_mem_pool_group {
470541 struct kbase_mem_pool small[MEMORY_GROUP_MANAGER_NR_GROUPS];
....@@ -485,11 +556,11 @@
485556 * struct kbase_mem_pool_group_config - Initial configuration for a complete
486557 * set of physical memory pools
487558 *
488
- * This array should be indexed by physical memory group ID, the meaning
489
- * of which is defined by the systems integrator.
490
- *
491559 * @small: Array of initial configuration for pools of 4 KiB pages.
492560 * @large: Array of initial configuration for pools of 2 MiB pages.
561
+ *
562
+ * This array should be indexed by physical memory group ID, the meaning
563
+ * of which is defined by the systems integrator.
493564 */
494565 struct kbase_mem_pool_group_config {
495566 struct kbase_mem_pool_config small[MEMORY_GROUP_MANAGER_NR_GROUPS];
....@@ -529,8 +600,11 @@
529600 * @entry_set_ate: program the pte to be a valid address translation entry to
530601 * encode the physical address of the actual page being mapped.
531602 * @entry_set_pte: program the pte to be a valid entry to encode the physical
532
- * address of the next lower level page table.
533
- * @entry_invalidate: clear out or invalidate the pte.
603
+ * address of the next lower level page table and also update
604
+ * the number of valid entries.
605
+ * @entries_invalidate: clear out or invalidate a range of ptes.
606
+ * @get_num_valid_entries: returns the number of valid entries for a specific pgd.
607
+ * @set_num_valid_entries: sets the number of valid entries for a specific pgd
534608 * @flags: bitmask of MMU mode flags. Refer to KBASE_MMU_MODE_ constants.
535609 */
536610 struct kbase_mmu_mode {
....@@ -546,7 +620,10 @@
546620 void (*entry_set_ate)(u64 *entry, struct tagged_addr phy,
547621 unsigned long flags, int level);
548622 void (*entry_set_pte)(u64 *entry, phys_addr_t phy);
549
- void (*entry_invalidate)(u64 *entry);
623
+ void (*entries_invalidate)(u64 *entry, u32 count);
624
+ unsigned int (*get_num_valid_entries)(u64 *pgd);
625
+ void (*set_num_valid_entries)(u64 *pgd,
626
+ unsigned int num_of_valid_entries);
550627 unsigned long flags;
551628 };
552629
....@@ -611,6 +688,33 @@
611688 };
612689
613690 /**
691
+ * struct kbase_mem_migrate - Object representing an instance for managing
692
+ * page migration.
693
+ *
694
+ * @free_pages_list: List of deferred pages to free. Mostly used when page migration
695
+ * is enabled. Pages in memory pool that require migrating
696
+ * will be freed instead. However page cannot be freed
697
+ * right away as Linux will need to release the page lock.
698
+ * Therefore page will be added to this list and freed later.
699
+ * @free_pages_lock: This lock should be held when adding or removing pages
700
+ * from @free_pages_list.
701
+ * @free_pages_workq: Work queue to process the work items queued to free
702
+ * pages in @free_pages_list.
703
+ * @free_pages_work: Work item to free pages in @free_pages_list.
704
+ * @inode: Pointer to inode whose address space operations are used
705
+ * for page migration purposes.
706
+ */
707
+struct kbase_mem_migrate {
708
+ struct list_head free_pages_list;
709
+ spinlock_t free_pages_lock;
710
+ struct workqueue_struct *free_pages_workq;
711
+ struct work_struct free_pages_work;
712
+#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
713
+ struct inode *inode;
714
+#endif
715
+};
716
+
717
+/**
614718 * struct kbase_device - Object representing an instance of GPU platform device,
615719 * allocated from the probe method of mali driver.
616720 * @hw_quirks_sc: Configuration to be used for the shader cores as per
....@@ -641,6 +745,7 @@
641745 * @irqs.flags: irq flags
642746 * @clocks: Pointer to the input clock resources referenced by
643747 * the GPU device node.
748
+ * @scmi_clk: Pointer to the input scmi clock resources
644749 * @nr_clocks: Number of clocks set in the clocks array.
645750 * @regulators: Pointer to the structs corresponding to the
646751 * regulators referenced by the GPU device node.
....@@ -648,6 +753,10 @@
648753 * @opp_table: Pointer to the device OPP structure maintaining the
649754 * link to OPPs attached to a device. This is obtained
650755 * after setting regulator names for the device.
756
+ * @token: Integer replacement for opp_table in kernel versions
757
+ * 6 and greater. Value is a token id number when 0 or greater,
758
+ * and a linux errno when negative. Must be initialised
759
+ * to an non-zero value as 0 is valid token id.
651760 * @devname: string containing the name used for GPU device instance,
652761 * miscellaneous device is registered using the same name.
653762 * @id: Unique identifier for the device, indicates the number of
....@@ -694,6 +803,8 @@
694803 * GPU adrress spaces assigned to them.
695804 * @mmu_mask_change: Lock to serialize the access to MMU interrupt mask
696805 * register used in the handling of Bus & Page faults.
806
+ * @pagesize_2mb: Boolean to determine whether 2MiB page sizes are
807
+ * supported and used where possible.
697808 * @gpu_props: Object containing complete information about the
698809 * configuration/properties of GPU HW device in use.
699810 * @hw_issues_mask: List of SW workarounds for HW issues
....@@ -716,33 +827,35 @@
716827 * @hwcnt.addr: HW counter address
717828 * @hwcnt.addr_bytes: HW counter size in bytes
718829 * @hwcnt.backend: Kbase instrumentation backend
830
+ * @hwcnt_gpu_jm_backend: Job manager GPU backend interface, used as superclass reference
831
+ * pointer by hwcnt_gpu_iface, which wraps this implementation in
832
+ * order to extend it with periodic dumping functionality.
719833 * @hwcnt_gpu_iface: Backend interface for GPU hardware counter access.
834
+ * @hwcnt_watchdog_timer: Watchdog interface, used by the GPU backend hwcnt_gpu_iface to
835
+ * perform periodic dumps in order to prevent hardware counter value
836
+ * overflow or saturation.
720837 * @hwcnt_gpu_ctx: Context for GPU hardware counter access.
721838 * @hwaccess_lock must be held when calling
722839 * kbase_hwcnt_context_enable() with @hwcnt_gpu_ctx.
723840 * @hwcnt_gpu_virt: Virtualizer for GPU hardware counters.
724841 * @vinstr_ctx: vinstr context created per device.
842
+ * @kinstr_prfcnt_ctx: kinstr_prfcnt context created per device.
725843 * @timeline_flags: Bitmask defining which sets of timeline tracepoints
726844 * are enabled. If zero, there is no timeline client and
727845 * therefore timeline is disabled.
728846 * @timeline: Timeline context created per device.
729847 * @ktrace: kbase device's ktrace
730
- * @trace_lock: Lock to serialize the access to trace buffer.
731
- * @trace_first_out: Index/offset in the trace buffer at which the first
732
- * unread message is present.
733
- * @trace_next_in: Index/offset in the trace buffer at which the new
734
- * message will be written.
735
- * @trace_rbuf: Pointer to the buffer storing debug messages/prints
736
- * tracing the various events in Driver.
737
- * The buffer is filled in circular fashion.
738848 * @reset_timeout_ms: Number of milliseconds to wait for the soft stop to
739849 * complete for the GPU jobs before proceeding with the
740850 * GPU reset.
851
+ * @lowest_gpu_freq_khz: Lowest frequency in KHz that the GPU can run at. Used
852
+ * to calculate suitable timeouts for wait operations.
853
+ * @backend_time: Kbase backend time related attributes.
741854 * @cache_clean_in_progress: Set when a cache clean has been started, and
742855 * cleared when it has finished. This prevents multiple
743856 * cache cleans being done simultaneously.
744
- * @cache_clean_queued: Set if a cache clean is invoked while another is in
745
- * progress. If this happens, another cache clean needs
857
+ * @cache_clean_queued: Pended cache clean operations invoked while another is
858
+ * in progress. If this is not 0, another cache clean needs
746859 * to be triggered immediately after completion of the
747860 * current one.
748861 * @cache_clean_wait: Signalled when a cache clean has finished.
....@@ -752,8 +865,6 @@
752865 * including any contexts that might be created for
753866 * hardware counters.
754867 * @kctx_list_lock: Lock protecting concurrent accesses to @kctx_list.
755
- * @group_max_uid_in_devices: Max value of any queue group UID in any kernel
756
- * context in the kbase device.
757868 * @devfreq_profile: Describes devfreq profile for the Mali GPU device, passed
758869 * to devfreq_add_device() to add devfreq feature to Mali
759870 * GPU device.
....@@ -839,6 +950,17 @@
839950 * backend specific data for HW access layer.
840951 * @faults_pending: Count of page/bus faults waiting for bottom half processing
841952 * via workqueues.
953
+ * @mmu_hw_operation_in_progress: Set before sending the MMU command and is
954
+ * cleared after the command is complete. Whilst this
955
+ * flag is set, the write to L2_PWROFF register will be
956
+ * skipped which is needed to workaround the HW issue
957
+ * GPU2019-3878. PM state machine is invoked after
958
+ * clearing this flag and @hwaccess_lock is used to
959
+ * serialize the access.
960
+ * @mmu_page_migrate_in_progress: Set before starting a MMU page migration transaction
961
+ * and cleared after the transaction completes. PM L2 state is
962
+ * prevented from entering powering up/down transitions when the
963
+ * flag is set, @hwaccess_lock is used to serialize the access.
842964 * @poweroff_pending: Set when power off operation for GPU is started, reset when
843965 * power on for GPU is started.
844966 * @infinite_cache_active_default: Set to enable using infinite cache for all the
....@@ -868,9 +990,6 @@
868990 * enabled.
869991 * @protected_mode_hwcnt_disable_work: Work item to disable GPU hardware
870992 * counters, used if atomic disable is not possible.
871
- * @buslogger: Pointer to the structure required for interfacing
872
- * with the bus logger module to set the size of buffer
873
- * used by the module for capturing bus logs.
874993 * @irq_reset_flush: Flag to indicate that GPU reset is in-flight and flush of
875994 * IRQ + bottom half is being done, to prevent the writes
876995 * to MMU_IRQ_CLEAR & MMU_IRQ_MASK registers.
....@@ -891,6 +1010,10 @@
8911010 * @l2_hash_override: Used to set L2 cache hash via device tree blob
8921011 * @l2_hash_values_override: true if @l2_hash_values is valid.
8931012 * @l2_hash_values: Used to set L2 asn_hash via device tree blob
1013
+ * @sysc_alloc: Array containing values to be programmed into
1014
+ * SYSC_ALLOC[0..7] GPU registers on L2 cache
1015
+ * power down. These come from either DTB or
1016
+ * via DebugFS (if it is available in kernel).
8941017 * @process_root: rb_tree root node for maintaining a rb_tree of
8951018 * kbase_process based on key tgid(thread group ID).
8961019 * @dma_buf_root: rb_tree root node for maintaining a rb_tree of
....@@ -917,6 +1040,14 @@
9171040 * @pcm_dev: The priority control manager device.
9181041 * @oom_notifier_block: notifier_block containing kernel-registered out-of-
9191042 * memory handler.
1043
+ * @mem_migrate: Per device object for managing page migration.
1044
+ * @live_fence_metadata: Count of live fence metadata structures created by
1045
+ * KCPU queue. These structures may outlive kbase module
1046
+ * itself. Therefore, in such a case, a warning should be
1047
+ * be produced.
1048
+ * @mmu_as_inactive_wait_time_ms: Maximum waiting time in ms for the completion of
1049
+ * a MMU operation
1050
+ * @va_region_slab: kmem_cache (slab) for allocated kbase_va_region structures.
9201051 */
9211052 struct kbase_device {
9221053 u32 hw_quirks_sc;
....@@ -941,13 +1072,24 @@
9411072 #if IS_ENABLED(CONFIG_REGULATOR)
9421073 struct regulator *regulators[BASE_MAX_NR_CLOCKS_REGULATORS];
9431074 unsigned int nr_regulators;
944
-#if (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE)
1075
+#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
1076
+ int token;
1077
+#elif (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE)
9451078 struct opp_table *opp_table;
946
-#endif /* (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE */
1079
+#endif /* (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE) */
9471080 #endif /* CONFIG_REGULATOR */
9481081 char devname[DEVNAME_SIZE];
9491082 u32 id;
9501083
1084
+#if !IS_ENABLED(CONFIG_MALI_REAL_HW)
1085
+ void *model;
1086
+ struct kmem_cache *irq_slab;
1087
+ struct workqueue_struct *irq_workq;
1088
+ atomic_t serving_job_irq;
1089
+ atomic_t serving_gpu_irq;
1090
+ atomic_t serving_mmu_irq;
1091
+ spinlock_t reg_op_lock;
1092
+#endif /* !IS_ENABLED(CONFIG_MALI_REAL_HW) */
9511093 struct kbase_pm_device_data pm;
9521094
9531095 struct kbase_mem_pool_group mem_pools;
....@@ -957,10 +1099,12 @@
9571099 struct memory_group_manager_device *mgm_dev;
9581100
9591101 struct kbase_as as[BASE_MAX_NR_AS];
960
- u16 as_free; /* Bitpattern of free Address Spaces */
1102
+ u16 as_free;
9611103 struct kbase_context *as_to_kctx[BASE_MAX_NR_AS];
9621104
9631105 spinlock_t mmu_mask_change;
1106
+
1107
+ bool pagesize_2mb;
9641108
9651109 struct kbase_gpu_props gpu_props;
9661110
....@@ -975,6 +1119,12 @@
9751119 s8 nr_hw_address_spaces;
9761120 s8 nr_user_address_spaces;
9771121
1122
+ /**
1123
+ * @pbha_propagate_bits: Record of Page-Based Hardware Attribute Propagate bits to
1124
+ * restore to L2_CONFIG upon GPU reset.
1125
+ */
1126
+ u8 pbha_propagate_bits;
1127
+
9781128 #if MALI_USE_CSF
9791129 struct kbase_hwcnt_backend_csf_if hwcnt_backend_csf_if_fw;
9801130 #else
....@@ -987,12 +1137,17 @@
9871137
9881138 struct kbase_instr_backend backend;
9891139 } hwcnt;
1140
+
1141
+ struct kbase_hwcnt_backend_interface hwcnt_gpu_jm_backend;
9901142 #endif
9911143
9921144 struct kbase_hwcnt_backend_interface hwcnt_gpu_iface;
1145
+ struct kbase_hwcnt_watchdog_interface hwcnt_watchdog_timer;
1146
+
9931147 struct kbase_hwcnt_context *hwcnt_gpu_ctx;
9941148 struct kbase_hwcnt_virtualizer *hwcnt_gpu_virt;
9951149 struct kbase_vinstr_context *vinstr_ctx;
1150
+ struct kbase_kinstr_prfcnt_context *kinstr_prfcnt_ctx;
9961151
9971152 atomic_t timeline_flags;
9981153 struct kbase_timeline *timeline;
....@@ -1002,31 +1157,39 @@
10021157 #endif
10031158 u32 reset_timeout_ms;
10041159
1160
+ u64 lowest_gpu_freq_khz;
1161
+
1162
+#if MALI_USE_CSF
1163
+ struct kbase_backend_time backend_time;
1164
+#endif
1165
+
10051166 bool cache_clean_in_progress;
1006
- bool cache_clean_queued;
1167
+ u32 cache_clean_queued;
10071168 wait_queue_head_t cache_clean_wait;
10081169
10091170 void *platform_context;
10101171
10111172 struct list_head kctx_list;
10121173 struct mutex kctx_list_lock;
1013
- atomic_t group_max_uid_in_devices;
10141174
1175
+ struct rockchip_opp_info opp_info;
1176
+ bool is_runtime_resumed;
1177
+ unsigned long current_nominal_freq;
1178
+ struct monitor_dev_info *mdev_info;
10151179 #ifdef CONFIG_MALI_BIFROST_DEVFREQ
10161180 struct devfreq_dev_profile devfreq_profile;
10171181 struct devfreq *devfreq;
10181182 unsigned long current_freqs[BASE_MAX_NR_CLOCKS_REGULATORS];
1019
- unsigned long current_nominal_freq;
10201183 unsigned long current_voltages[BASE_MAX_NR_CLOCKS_REGULATORS];
10211184 u64 current_core_mask;
10221185 struct kbase_devfreq_opp *devfreq_table;
10231186 int num_opps;
10241187 struct kbasep_pm_metrics last_devfreq_metrics;
1025
- struct monitor_dev_info *mdev_info;
10261188 struct ipa_power_model_data *model_data;
10271189 struct kbase_devfreq_queue_info devfreq_queue;
10281190
10291191 #if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
1192
+ struct devfreq_cooling_power dfc_power;
10301193 struct thermal_cooling_device *devfreq_cooling;
10311194 bool ipa_protection_mode_switched;
10321195 struct {
....@@ -1052,7 +1215,9 @@
10521215 #endif /* CONFIG_MALI_BIFROST_DEVFREQ */
10531216 unsigned long previous_frequency;
10541217
1218
+#if !MALI_USE_CSF
10551219 atomic_t job_fault_debug;
1220
+#endif /* !MALI_USE_CSF */
10561221
10571222 #if IS_ENABLED(CONFIG_DEBUG_FS)
10581223 struct dentry *mali_debugfs_directory;
....@@ -1063,11 +1228,13 @@
10631228 u64 debugfs_as_read_bitmap;
10641229 #endif /* CONFIG_MALI_BIFROST_DEBUG */
10651230
1231
+#if !MALI_USE_CSF
10661232 wait_queue_head_t job_fault_wq;
10671233 wait_queue_head_t job_fault_resume_wq;
10681234 struct workqueue_struct *job_fault_resume_workq;
10691235 struct list_head job_fault_event_list;
10701236 spinlock_t job_fault_event_lock;
1237
+#endif /* !MALI_USE_CSF */
10711238
10721239 #if !MALI_CUSTOMER_RELEASE
10731240 struct {
....@@ -1086,13 +1253,14 @@
10861253
10871254 atomic_t faults_pending;
10881255
1256
+#if MALI_USE_CSF
1257
+ bool mmu_hw_operation_in_progress;
1258
+#endif
1259
+ bool mmu_page_migrate_in_progress;
10891260 bool poweroff_pending;
10901261
1091
-#if (KERNEL_VERSION(4, 4, 0) <= LINUX_VERSION_CODE)
10921262 bool infinite_cache_active_default;
1093
-#else
1094
- u32 infinite_cache_active_default;
1095
-#endif
1263
+
10961264 struct kbase_mem_pool_group_config mem_pool_defaults;
10971265
10981266 u32 current_gpu_coherency_mode;
....@@ -1130,6 +1298,8 @@
11301298 u8 l2_hash_override;
11311299 bool l2_hash_values_override;
11321300 u32 l2_hash_values[ASN_HASH_COUNT];
1301
+
1302
+ u32 sysc_alloc[SYSC_ALLOC_COUNT];
11331303
11341304 struct mutex fw_load_lock;
11351305 #if MALI_USE_CSF
....@@ -1172,6 +1342,27 @@
11721342 struct priority_control_manager_device *pcm_dev;
11731343
11741344 struct notifier_block oom_notifier_block;
1345
+
1346
+#if !MALI_USE_CSF
1347
+ spinlock_t quick_reset_lock;
1348
+ bool quick_reset_enabled;
1349
+ /*
1350
+ * 进入 quck_reset_mode 后 (quick_reset_enabled 为 true),
1351
+ * 对已经进入 KBASE_JD_ATOM_STATE_HW_COMPLETED 状态的 atom 的计数.
1352
+ *
1353
+ * 若 num_of_atoms_hw_completed 达到一定值, 将退出 quck_reset_mode.
1354
+ * 见 kbase_js_complete_atom() 对 num_of_atoms_hw_completed 的引用.
1355
+ */
1356
+ u32 num_of_atoms_hw_completed;
1357
+#endif
1358
+
1359
+ struct kbase_mem_migrate mem_migrate;
1360
+
1361
+#if MALI_USE_CSF && IS_ENABLED(CONFIG_SYNC_FILE)
1362
+ atomic_t live_fence_metadata;
1363
+#endif
1364
+ u32 mmu_as_inactive_wait_time_ms;
1365
+ struct kmem_cache *va_region_slab;
11751366 };
11761367
11771368 /**
....@@ -1254,10 +1445,6 @@
12541445 *
12551446 * @KCTX_DYING: Set when the context process is in the process of being evicted.
12561447 *
1257
- * @KCTX_NO_IMPLICIT_SYNC: Set when explicit Android fences are in use on this
1258
- * context, to disable use of implicit dma-buf fences. This is used to avoid
1259
- * potential synchronization deadlocks.
1260
- *
12611448 * @KCTX_FORCE_SAME_VA: Set when BASE_MEM_SAME_VA should be forced on memory
12621449 * allocations. For 64-bit clients it is enabled by default, and disabled by
12631450 * default on 32-bit clients. Being able to clear this flag is only used for
....@@ -1300,7 +1487,6 @@
13001487 KCTX_PRIVILEGED = 1U << 7,
13011488 KCTX_SCHEDULED = 1U << 8,
13021489 KCTX_DYING = 1U << 9,
1303
- KCTX_NO_IMPLICIT_SYNC = 1U << 10,
13041490 KCTX_FORCE_SAME_VA = 1U << 11,
13051491 KCTX_PULLED_SINCE_ACTIVE_JS0 = 1U << 12,
13061492 KCTX_PULLED_SINCE_ACTIVE_JS1 = 1U << 13,
....@@ -1339,9 +1525,6 @@
13391525 *
13401526 * @KCTX_DYING: Set when the context process is in the process of being evicted.
13411527 *
1342
- * @KCTX_NO_IMPLICIT_SYNC: Set when explicit Android fences are in use on this
1343
- * context, to disable use of implicit dma-buf fences. This is used to avoid
1344
- * potential synchronization deadlocks.
13451528 *
13461529 * @KCTX_FORCE_SAME_VA: Set when BASE_MEM_SAME_VA should be forced on memory
13471530 * allocations. For 64-bit clients it is enabled by default, and disabled by
....@@ -1382,7 +1565,6 @@
13821565 KCTX_PRIVILEGED = 1U << 7,
13831566 KCTX_SCHEDULED = 1U << 8,
13841567 KCTX_DYING = 1U << 9,
1385
- KCTX_NO_IMPLICIT_SYNC = 1U << 10,
13861568 KCTX_FORCE_SAME_VA = 1U << 11,
13871569 KCTX_PULLED_SINCE_ACTIVE_JS0 = 1U << 12,
13881570 KCTX_PULLED_SINCE_ACTIVE_JS1 = 1U << 13,
....@@ -1395,21 +1577,6 @@
13951577 struct list_head link;
13961578 struct page *page;
13971579 DECLARE_BITMAP(sub_pages, SZ_2M / SZ_4K);
1398
-};
1399
-
1400
-/**
1401
- * struct kbase_reg_zone - Information about GPU memory region zones
1402
- * @base_pfn: Page Frame Number in GPU virtual address space for the start of
1403
- * the Zone
1404
- * @va_size_pages: Size of the Zone in pages
1405
- *
1406
- * Track information about a zone KBASE_REG_ZONE() and related macros.
1407
- * In future, this could also store the &rb_root that are currently in
1408
- * &kbase_context
1409
- */
1410
-struct kbase_reg_zone {
1411
- u64 base_pfn;
1412
- u64 va_size_pages;
14131580 };
14141581
14151582 /**
....@@ -1449,8 +1616,8 @@
14491616 * @mem_partials_lock: Lock for protecting the operations done on the elements
14501617 * added to @mem_partials list.
14511618 * @mem_partials: List head for the list of large pages, 2MB in size, which
1452
- * which have been split into 4 KB pages and are used
1453
- * partially for the allocations >= 2 MB in size.
1619
+ * have been split into 4 KB pages and are used partially
1620
+ * for the allocations >= 2 MB in size.
14541621 * @reg_lock: Lock used for GPU virtual address space management operations,
14551622 * like adding/freeing a memory region in the address space.
14561623 * Can be converted to a rwlock ?.
....@@ -1462,6 +1629,17 @@
14621629 * @reg_rbtree_exec: RB tree of the memory regions allocated from the EXEC_VA
14631630 * zone of the GPU virtual address space. Used for GPU-executable
14641631 * allocations which don't need the SAME_VA property.
1632
+ * @reg_rbtree_exec_fixed: RB tree of the memory regions allocated from the
1633
+ * EXEC_FIXED_VA zone of the GPU virtual address space. Used for
1634
+ * GPU-executable allocations with FIXED/FIXABLE GPU virtual
1635
+ * addresses.
1636
+ * @reg_rbtree_fixed: RB tree of the memory regions allocated from the FIXED_VA zone
1637
+ * of the GPU virtual address space. Used for allocations with
1638
+ * FIXED/FIXABLE GPU virtual addresses.
1639
+ * @num_fixable_allocs: A count for the number of memory allocations with the
1640
+ * BASE_MEM_FIXABLE property.
1641
+ * @num_fixed_allocs: A count for the number of memory allocations with the
1642
+ * BASE_MEM_FIXED property.
14651643 * @reg_zone: Zone information for the reg_rbtree_<...> members.
14661644 * @cookies: Bitmask containing of BITS_PER_LONG bits, used mainly for
14671645 * SAME_VA allocations to defer the reservation of memory region
....@@ -1538,12 +1716,20 @@
15381716 * is scheduled in and an atom is pulled from the context's per
15391717 * slot runnable tree in JM GPU or GPU command queue
15401718 * group is programmed on CSG slot in CSF GPU.
1541
- * @mm_update_lock: lock used for handling of special tracking page.
15421719 * @process_mm: Pointer to the memory descriptor of the process which
15431720 * created the context. Used for accounting the physical
15441721 * pages used for GPU allocations, done for the context,
1545
- * to the memory consumed by the process.
1722
+ * to the memory consumed by the process. A reference is taken
1723
+ * on this descriptor for the Userspace created contexts so that
1724
+ * Kbase can safely access it to update the memory usage counters.
1725
+ * The reference is dropped on context termination.
15461726 * @gpu_va_end: End address of the GPU va space (in 4KB page units)
1727
+ * @running_total_tiler_heap_nr_chunks: Running total of number of chunks in all
1728
+ * tiler heaps of the kbase context.
1729
+ * @running_total_tiler_heap_memory: Running total of the tiler heap memory in the
1730
+ * kbase context.
1731
+ * @peak_total_tiler_heap_memory: Peak value of the total tiler heap memory in the
1732
+ * kbase context.
15471733 * @jit_va: Indicates if a JIT_VA zone has been created.
15481734 * @mem_profile_data: Buffer containing the profiling information provided by
15491735 * Userspace, can be read through the mem_profile debugfs file.
....@@ -1559,29 +1745,19 @@
15591745 * dumping of its debug info is in progress.
15601746 * @job_fault_resume_event_list: List containing atoms completed after the faulty
15611747 * atom but before the debug data for faulty atom was dumped.
1748
+ * @mem_view_column_width: Controls the number of bytes shown in every column of the
1749
+ * output of "mem_view" debugfs file.
15621750 * @jsctx_queue: Per slot & priority arrays of object containing the root
15631751 * of RB-tree holding currently runnable atoms on the job slot
15641752 * and the head item of the linked list of atoms blocked on
15651753 * cross-slot dependencies.
1566
- * @atoms_pulled: Total number of atoms currently pulled from the context.
1567
- * @atoms_pulled_slot: Per slot count of the number of atoms currently pulled
1568
- * from the context.
1569
- * @atoms_pulled_slot_pri: Per slot & priority count of the number of atoms currently
1570
- * pulled from the context. hwaccess_lock shall be held when
1571
- * accessing it.
1572
- * @blocked_js: Indicates if the context is blocked from submitting atoms
1573
- * on a slot at a given priority. This is set to true, when
1574
- * the atom corresponding to context is soft/hard stopped or
1575
- * removed from the HEAD_NEXT register in response to
1576
- * soft/hard stop.
1754
+ * @slot_tracking: Tracking and control of this context's use of all job
1755
+ * slots
1756
+ * @atoms_pulled_all_slots: Total number of atoms currently pulled from the
1757
+ * context, across all slots.
15771758 * @slots_pullable: Bitmask of slots, indicating the slots for which the
15781759 * context has pullable atoms in the runnable tree.
15791760 * @work: Work structure used for deferred ASID assignment.
1580
- * @legacy_hwcnt_cli: Pointer to the legacy userspace hardware counters
1581
- * client, there can be only such client per kbase
1582
- * context.
1583
- * @legacy_hwcnt_lock: Lock used to prevent concurrent access to
1584
- * @legacy_hwcnt_cli.
15851761 * @completed_jobs: List containing completed atoms for which base_jd_event is
15861762 * to be posted.
15871763 * @work_count: Number of work items, corresponding to atoms, currently
....@@ -1597,12 +1773,6 @@
15971773 * memory allocations.
15981774 * @jit_current_allocations_per_bin: Current number of in-flight just-in-time
15991775 * memory allocations per bin.
1600
- * @jit_version: Version number indicating whether userspace is using
1601
- * old or new version of interface for just-in-time
1602
- * memory allocations.
1603
- * 1 -> client used KBASE_IOCTL_MEM_JIT_INIT_10_2
1604
- * 2 -> client used KBASE_IOCTL_MEM_JIT_INIT_11_5
1605
- * 3 -> client used KBASE_IOCTL_MEM_JIT_INIT
16061776 * @jit_group_id: A memory group ID to be passed to a platform-specific
16071777 * memory group manager.
16081778 * Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
....@@ -1674,6 +1844,10 @@
16741844 * @limited_core_mask: The mask that is applied to the affinity in case of atoms
16751845 * marked with BASE_JD_REQ_LIMITED_CORE_MASK.
16761846 * @platform_data: Pointer to platform specific per-context data.
1847
+ * @task: Pointer to the task structure of the main thread of the process
1848
+ * that created the Kbase context. It would be set only for the
1849
+ * contexts created by the Userspace and not for the contexts
1850
+ * created internally by the Kbase.
16771851 *
16781852 * A kernel base context is an entity among which the GPU is scheduled.
16791853 * Each context has its own GPU address space.
....@@ -1711,6 +1885,12 @@
17111885 struct rb_root reg_rbtree_same;
17121886 struct rb_root reg_rbtree_custom;
17131887 struct rb_root reg_rbtree_exec;
1888
+#if MALI_USE_CSF
1889
+ struct rb_root reg_rbtree_exec_fixed;
1890
+ struct rb_root reg_rbtree_fixed;
1891
+ atomic64_t num_fixable_allocs;
1892
+ atomic64_t num_fixed_allocs;
1893
+#endif
17141894 struct kbase_reg_zone reg_zone[KBASE_REG_ZONE_MAX];
17151895
17161896 #if MALI_USE_CSF
....@@ -1719,17 +1899,14 @@
17191899 struct kbase_jd_context jctx;
17201900 struct jsctx_queue jsctx_queue
17211901 [KBASE_JS_ATOM_SCHED_PRIO_COUNT][BASE_JM_MAX_NR_SLOTS];
1902
+ struct kbase_jsctx_slot_tracking slot_tracking[BASE_JM_MAX_NR_SLOTS];
1903
+ atomic_t atoms_pulled_all_slots;
17221904
17231905 struct list_head completed_jobs;
17241906 atomic_t work_count;
17251907 struct timer_list soft_job_timeout;
17261908
1727
- atomic_t atoms_pulled;
1728
- atomic_t atoms_pulled_slot[BASE_JM_MAX_NR_SLOTS];
1729
- int atoms_pulled_slot_pri[BASE_JM_MAX_NR_SLOTS][
1730
- KBASE_JS_ATOM_SCHED_PRIO_COUNT];
17311909 int priority;
1732
- bool blocked_js[BASE_JM_MAX_NR_SLOTS][KBASE_JS_ATOM_SCHED_PRIO_COUNT];
17331910 s16 atoms_count[KBASE_JS_ATOM_SCHED_PRIO_COUNT];
17341911 u32 slots_pullable;
17351912 u32 age_count;
....@@ -1753,20 +1930,18 @@
17531930
17541931 struct list_head waiting_soft_jobs;
17551932 spinlock_t waiting_soft_jobs_lock;
1756
-#ifdef CONFIG_MALI_BIFROST_DMA_FENCE
1757
- struct {
1758
- struct list_head waiting_resource;
1759
- struct workqueue_struct *wq;
1760
- } dma_fence;
1761
-#endif /* CONFIG_MALI_BIFROST_DMA_FENCE */
17621933
17631934 int as_nr;
17641935
17651936 atomic_t refcount;
17661937
1767
- spinlock_t mm_update_lock;
1768
- struct mm_struct __rcu *process_mm;
1938
+ struct mm_struct *process_mm;
17691939 u64 gpu_va_end;
1940
+#if MALI_USE_CSF
1941
+ u32 running_total_tiler_heap_nr_chunks;
1942
+ u64 running_total_tiler_heap_memory;
1943
+ u64 peak_total_tiler_heap_memory;
1944
+#endif
17701945 bool jit_va;
17711946
17721947 #if IS_ENABLED(CONFIG_DEBUG_FS)
....@@ -1778,17 +1953,13 @@
17781953 unsigned int *reg_dump;
17791954 atomic_t job_fault_count;
17801955 struct list_head job_fault_resume_event_list;
1956
+ unsigned int mem_view_column_width;
17811957
17821958 #endif /* CONFIG_DEBUG_FS */
1783
-
1784
- struct kbase_hwcnt_legacy_client *legacy_hwcnt_cli;
1785
- struct mutex legacy_hwcnt_lock;
1786
-
17871959 struct kbase_va_region *jit_alloc[1 + BASE_JIT_ALLOC_COUNT];
17881960 u8 jit_max_allocations;
17891961 u8 jit_current_allocations;
17901962 u8 jit_current_allocations_per_bin[256];
1791
- u8 jit_version;
17921963 u8 jit_group_id;
17931964 #if MALI_JIT_PRESSURE_LIMIT_BASE
17941965 u64 jit_phys_pages_limit;
....@@ -1827,6 +1998,8 @@
18271998 #if !MALI_USE_CSF
18281999 void *platform_data;
18292000 #endif
2001
+
2002
+ struct task_struct *task;
18302003 };
18312004
18322005 #ifdef CONFIG_MALI_CINSTR_GWT
....@@ -1855,17 +2028,15 @@
18552028 * to a @kbase_context.
18562029 * @ext_res_node: List head for adding the metadata to a
18572030 * @kbase_context.
1858
- * @alloc: The physical memory allocation structure
1859
- * which is mapped.
1860
- * @gpu_addr: The GPU virtual address the resource is
1861
- * mapped to.
2031
+ * @reg: External resource information, containing
2032
+ * the corresponding VA region
18622033 * @ref: Reference count.
18632034 *
18642035 * External resources can be mapped into multiple contexts as well as the same
18652036 * context multiple times.
1866
- * As kbase_va_region itself isn't refcounted we can't attach our extra
1867
- * information to it as it could be removed under our feet leaving external
1868
- * resources pinned.
2037
+ * As kbase_va_region is refcounted, we guarantee that it will be available
2038
+ * for the duration of the external resource, meaning it is sufficient to use
2039
+ * it to rederive any additional data, like the GPU address.
18692040 * This metadata structure binds a single external resource to a single
18702041 * context, ensuring that per context mapping is tracked separately so it can
18712042 * be overridden when needed and abuses by the application (freeing the resource
....@@ -1873,8 +2044,7 @@
18732044 */
18742045 struct kbase_ctx_ext_res_meta {
18752046 struct list_head ext_res_node;
1876
- struct kbase_mem_phy_alloc *alloc;
1877
- u64 gpu_addr;
2047
+ struct kbase_va_region *reg;
18782048 u32 ref;
18792049 };
18802050
....@@ -1904,6 +2074,24 @@
19042074 return false;
19052075 }
19062076
2077
+/**
2078
+ * kbase_get_lock_region_min_size_log2 - Returns the minimum size of the MMU lock
2079
+ * region, as a logarithm
2080
+ *
2081
+ * @gpu_props: GPU properties
2082
+ *
2083
+ * Return: the minimum size of the MMU lock region as dictated by the corresponding
2084
+ * arch spec.
2085
+ */
2086
+static inline u64 kbase_get_lock_region_min_size_log2(struct kbase_gpu_props const *gpu_props)
2087
+{
2088
+ if (GPU_ID2_MODEL_MATCH_VALUE(gpu_props->props.core_props.product_id) >=
2089
+ GPU_ID2_MODEL_MAKE(12, 0))
2090
+ return 12; /* 4 kB */
2091
+
2092
+ return 15; /* 32 kB */
2093
+}
2094
+
19072095 /* Conversion helpers for setting up high resolution timers */
19082096 #define HR_TIMER_DELAY_MSEC(x) (ns_to_ktime(((u64)(x))*1000000U))
19092097 #define HR_TIMER_DELAY_NSEC(x) (ns_to_ktime(x))
....@@ -1912,5 +2100,6 @@
19122100 #define KBASE_CLEAN_CACHE_MAX_LOOPS 100000
19132101 /* Maximum number of loops polling the GPU for an AS command to complete before we assume the GPU has hung */
19142102 #define KBASE_AS_INACTIVE_MAX_LOOPS 100000000
1915
-
1916
-#endif /* _KBASE_DEFS_H_ */
2103
+/* Maximum number of loops polling the GPU PRFCNT_ACTIVE bit before we assume the GPU has hung */
2104
+#define KBASE_PRFCNT_ACTIVE_MAX_LOOPS 100000000
2105
+#endif /* _KBASE_DEFS_H_ */