.. | .. |
---|
1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
---|
2 | 2 | /* |
---|
3 | 3 | * |
---|
4 | | - * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved. |
---|
| 4 | + * (C) COPYRIGHT 2019-2023 ARM Limited. All rights reserved. |
---|
5 | 5 | * |
---|
6 | 6 | * This program is free software and is provided to you under the terms of the |
---|
7 | 7 | * GNU General Public License version 2 as published by the Free Software |
---|
.. | .. |
---|
87 | 87 | #define KBASE_KATOM_FLAG_FAIL_BLOCKER (1<<8) |
---|
88 | 88 | /* Atom is currently in the list of atoms blocked on cross-slot dependencies */ |
---|
89 | 89 | #define KBASE_KATOM_FLAG_JSCTX_IN_X_DEP_LIST (1<<9) |
---|
90 | | -/* Atom is currently holding a context reference */ |
---|
91 | | -#define KBASE_KATOM_FLAG_HOLDING_CTX_REF (1<<10) |
---|
92 | 90 | /* Atom requires GPU to be in protected mode */ |
---|
93 | 91 | #define KBASE_KATOM_FLAG_PROTECTED (1<<11) |
---|
94 | 92 | /* Atom has been stored in runnable_tree */ |
---|
.. | .. |
---|
125 | 123 | #define KBASE_SERIALIZE_INTER_SLOT (1 << 1) |
---|
126 | 124 | /* Reset the GPU after each atom completion */ |
---|
127 | 125 | #define KBASE_SERIALIZE_RESET (1 << 2) |
---|
| 126 | + |
---|
| 127 | +/** |
---|
| 128 | + * enum kbase_timeout_selector - The choice of which timeout to get scaled |
---|
| 129 | + * using the lowest GPU frequency. |
---|
| 130 | + * @MMU_AS_INACTIVE_WAIT_TIMEOUT: Maximum waiting time in ms for the completion |
---|
| 131 | + * of a MMU operation |
---|
| 132 | + * @JM_DEFAULT_JS_FREE_TIMEOUT: Maximum timeout to wait for JS_COMMAND_NEXT |
---|
| 133 | + * to be updated on HW side so a Job Slot is |
---|
| 134 | + * considered free. |
---|
| 135 | + * @KBASE_TIMEOUT_SELECTOR_COUNT: Number of timeout selectors. Must be last in |
---|
| 136 | + * the enum. |
---|
| 137 | + */ |
---|
| 138 | +enum kbase_timeout_selector { |
---|
| 139 | + MMU_AS_INACTIVE_WAIT_TIMEOUT, |
---|
| 140 | + JM_DEFAULT_JS_FREE_TIMEOUT, |
---|
| 141 | + |
---|
| 142 | + /* Must be the last in the enum */ |
---|
| 143 | + KBASE_TIMEOUT_SELECTOR_COUNT |
---|
| 144 | +}; |
---|
128 | 145 | |
---|
129 | 146 | #if IS_ENABLED(CONFIG_DEBUG_FS) |
---|
130 | 147 | /** |
---|
.. | .. |
---|
176 | 193 | static inline const struct kbase_jd_atom * |
---|
177 | 194 | kbase_jd_katom_dep_atom(const struct kbase_jd_atom_dependency *dep) |
---|
178 | 195 | { |
---|
179 | | - LOCAL_ASSERT(dep != NULL); |
---|
180 | | - |
---|
181 | 196 | return (const struct kbase_jd_atom *)(dep->atom); |
---|
182 | 197 | } |
---|
183 | 198 | |
---|
.. | .. |
---|
191 | 206 | static inline u8 kbase_jd_katom_dep_type( |
---|
192 | 207 | const struct kbase_jd_atom_dependency *dep) |
---|
193 | 208 | { |
---|
194 | | - LOCAL_ASSERT(dep != NULL); |
---|
195 | | - |
---|
196 | 209 | return dep->dep_type; |
---|
197 | 210 | } |
---|
198 | 211 | |
---|
.. | .. |
---|
209 | 222 | { |
---|
210 | 223 | struct kbase_jd_atom_dependency *dep; |
---|
211 | 224 | |
---|
212 | | - LOCAL_ASSERT(const_dep != NULL); |
---|
213 | | - |
---|
214 | 225 | dep = (struct kbase_jd_atom_dependency *)const_dep; |
---|
215 | 226 | |
---|
216 | 227 | dep->atom = a; |
---|
.. | .. |
---|
226 | 237 | const struct kbase_jd_atom_dependency *const_dep) |
---|
227 | 238 | { |
---|
228 | 239 | struct kbase_jd_atom_dependency *dep; |
---|
229 | | - |
---|
230 | | - LOCAL_ASSERT(const_dep != NULL); |
---|
231 | 240 | |
---|
232 | 241 | dep = (struct kbase_jd_atom_dependency *)const_dep; |
---|
233 | 242 | |
---|
.. | .. |
---|
343 | 352 | }; |
---|
344 | 353 | |
---|
345 | 354 | /** |
---|
346 | | - * struct kbase_ext_res - Contains the info for external resources referred |
---|
347 | | - * by an atom, which have been mapped on GPU side. |
---|
348 | | - * @gpu_address: Start address of the memory region allocated for |
---|
349 | | - * the resource from GPU virtual address space. |
---|
350 | | - * @alloc: pointer to physical pages tracking object, set on |
---|
351 | | - * mapping the external resource on GPU side. |
---|
352 | | - */ |
---|
353 | | -struct kbase_ext_res { |
---|
354 | | - u64 gpu_address; |
---|
355 | | - struct kbase_mem_phy_alloc *alloc; |
---|
356 | | -}; |
---|
357 | | - |
---|
358 | | -/** |
---|
359 | 355 | * struct kbase_jd_atom - object representing the atom, containing the complete |
---|
360 | 356 | * state and attributes of an atom. |
---|
361 | 357 | * @work: work item for the bottom half processing of the atom, |
---|
.. | .. |
---|
388 | 384 | * each allocation is read in order to enforce an |
---|
389 | 385 | * overall physical memory usage limit. |
---|
390 | 386 | * @nr_extres: number of external resources referenced by the atom. |
---|
391 | | - * @extres: pointer to the location containing info about |
---|
| 387 | + * @extres: Pointer to @nr_extres VA regions containing the external |
---|
| 388 | + * resource allocation and other information. |
---|
392 | 389 | * @nr_extres external resources referenced by the atom. |
---|
393 | 390 | * @device_nr: indicates the coregroup with which the atom is |
---|
394 | 391 | * associated, when |
---|
.. | .. |
---|
406 | 403 | * sync through soft jobs and for the implicit |
---|
407 | 404 | * synchronization required on access to external |
---|
408 | 405 | * resources. |
---|
409 | | - * @dma_fence.fence_in: Input fence |
---|
| 406 | + * @dma_fence.fence_in: Points to the dma-buf input fence for this atom. |
---|
| 407 | + * The atom would complete only after the fence is |
---|
| 408 | + * signaled. |
---|
410 | 409 | * @dma_fence.fence: Points to the dma-buf output fence for this atom. |
---|
| 410 | + * @dma_fence.fence_cb: The object that is passed at the time of adding the |
---|
| 411 | + * callback that gets invoked when @dma_fence.fence_in |
---|
| 412 | + * is signaled. |
---|
| 413 | + * @dma_fence.fence_cb_added: Flag to keep a track if the callback was successfully |
---|
| 414 | + * added for @dma_fence.fence_in, which is supposed to be |
---|
| 415 | + * invoked on the signaling of fence. |
---|
411 | 416 | * @dma_fence.context: The dma-buf fence context number for this atom. A |
---|
412 | 417 | * unique context number is allocated to each katom in |
---|
413 | 418 | * the context on context creation. |
---|
414 | 419 | * @dma_fence.seqno: The dma-buf fence sequence number for this atom. This |
---|
415 | 420 | * is increased every time this katom uses dma-buf fence |
---|
416 | | - * @dma_fence.callbacks: List of all callbacks set up to wait on other fences |
---|
417 | | - * @dma_fence.dep_count: Atomic counter of number of outstandind dma-buf fence |
---|
418 | | - * dependencies for this atom. |
---|
419 | 421 | * @event_code: Event code for the job chain represented by the atom, |
---|
420 | 422 | * both HW and low-level SW events are represented by |
---|
421 | 423 | * event codes. |
---|
.. | .. |
---|
498 | 500 | * BASE_JD_REQ_START_RENDERPASS set in its core requirements |
---|
499 | 501 | * with an atom that has BASE_JD_REQ_END_RENDERPASS set. |
---|
500 | 502 | * @jc_fragment: Set of GPU fragment job chains |
---|
501 | | - * @retry_count: TODO: Not used,to be removed |
---|
502 | 503 | */ |
---|
503 | 504 | struct kbase_jd_atom { |
---|
504 | 505 | struct work_struct work; |
---|
.. | .. |
---|
518 | 519 | #endif /* MALI_JIT_PRESSURE_LIMIT_BASE */ |
---|
519 | 520 | |
---|
520 | 521 | u16 nr_extres; |
---|
521 | | - struct kbase_ext_res *extres; |
---|
| 522 | + struct kbase_va_region **extres; |
---|
522 | 523 | |
---|
523 | 524 | u32 device_nr; |
---|
524 | 525 | u64 jc; |
---|
525 | 526 | void *softjob_data; |
---|
526 | | -#if defined(CONFIG_SYNC) |
---|
527 | | - struct sync_fence *fence; |
---|
528 | | - struct sync_fence_waiter sync_waiter; |
---|
529 | | -#endif /* CONFIG_SYNC */ |
---|
530 | | -#if defined(CONFIG_MALI_BIFROST_DMA_FENCE) || defined(CONFIG_SYNC_FILE) |
---|
| 527 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
---|
531 | 528 | struct { |
---|
532 | 529 | /* Use the functions/API defined in mali_kbase_fence.h to |
---|
533 | 530 | * when working with this sub struct |
---|
534 | 531 | */ |
---|
535 | | -#if defined(CONFIG_SYNC_FILE) |
---|
| 532 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
---|
536 | 533 | #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) |
---|
537 | 534 | struct fence *fence_in; |
---|
538 | 535 | #else |
---|
.. | .. |
---|
555 | 552 | #else |
---|
556 | 553 | struct dma_fence *fence; |
---|
557 | 554 | #endif |
---|
| 555 | + |
---|
| 556 | + /* This is the callback object that is registered for the fence_in. |
---|
| 557 | + * The callback is invoked when the fence_in is signaled. |
---|
| 558 | + */ |
---|
| 559 | +#if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) |
---|
| 560 | + struct fence_cb fence_cb; |
---|
| 561 | +#else |
---|
| 562 | + struct dma_fence_cb fence_cb; |
---|
| 563 | +#endif |
---|
| 564 | + bool fence_cb_added; |
---|
| 565 | + |
---|
558 | 566 | unsigned int context; |
---|
559 | 567 | atomic_t seqno; |
---|
560 | | - /* This contains a list of all callbacks set up to wait on |
---|
561 | | - * other fences. This atom must be held back from JS until all |
---|
562 | | - * these callbacks have been called and dep_count have reached |
---|
563 | | - * 0. The initial value of dep_count must be equal to the |
---|
564 | | - * number of callbacks on this list. |
---|
565 | | - * |
---|
566 | | - * This list is protected by jctx.lock. Callbacks are added to |
---|
567 | | - * this list when the atom is built and the wait are set up. |
---|
568 | | - * All the callbacks then stay on the list until all callbacks |
---|
569 | | - * have been called and the atom is queued, or cancelled, and |
---|
570 | | - * then all callbacks are taken off the list and freed. |
---|
571 | | - */ |
---|
572 | | - struct list_head callbacks; |
---|
573 | | - /* Atomic counter of number of outstandind dma-buf fence |
---|
574 | | - * dependencies for this atom. When dep_count reaches 0 the |
---|
575 | | - * atom may be queued. |
---|
576 | | - * |
---|
577 | | - * The special value "-1" may only be set after the count |
---|
578 | | - * reaches 0, while holding jctx.lock. This indicates that the |
---|
579 | | - * atom has been handled, either queued in JS or cancelled. |
---|
580 | | - * |
---|
581 | | - * If anyone but the dma-fence worker sets this to -1 they must |
---|
582 | | - * ensure that any potentially queued worker must have |
---|
583 | | - * completed before allowing the atom to be marked as unused. |
---|
584 | | - * This can be done by flushing the fence work queue: |
---|
585 | | - * kctx->dma_fence.wq. |
---|
586 | | - */ |
---|
587 | | - atomic_t dep_count; |
---|
588 | 568 | } dma_fence; |
---|
589 | | -#endif /* CONFIG_MALI_BIFROST_DMA_FENCE || CONFIG_SYNC_FILE */ |
---|
| 569 | +#endif /* CONFIG_SYNC_FILE */ |
---|
590 | 570 | |
---|
591 | 571 | /* Note: refer to kbasep_js_atom_retained_state, which will take a copy |
---|
592 | 572 | * of some of the following members |
---|
.. | .. |
---|
605 | 585 | #if IS_ENABLED(CONFIG_GPU_TRACEPOINTS) |
---|
606 | 586 | int work_id; |
---|
607 | 587 | #endif |
---|
608 | | - int slot_nr; |
---|
| 588 | + unsigned int slot_nr; |
---|
609 | 589 | |
---|
610 | 590 | u32 atom_flags; |
---|
611 | | - |
---|
612 | | - int retry_count; |
---|
613 | 591 | |
---|
614 | 592 | enum kbase_atom_gpu_rb_state gpu_rb_state; |
---|
615 | 593 | |
---|
.. | .. |
---|
653 | 631 | return (bool)(katom->atom_flags & KBASE_KATOM_FLAG_PROTECTED); |
---|
654 | 632 | } |
---|
655 | 633 | |
---|
| 634 | +/** |
---|
| 635 | + * kbase_jd_atom_is_younger - query if one atom is younger by age than another |
---|
| 636 | + * |
---|
| 637 | + * @katom_a: the first atom |
---|
| 638 | + * @katom_b: the second atom |
---|
| 639 | + * |
---|
| 640 | + * Return: true if the first atom is strictly younger than the second, |
---|
| 641 | + * false otherwise. |
---|
| 642 | + */ |
---|
| 643 | +static inline bool kbase_jd_atom_is_younger(const struct kbase_jd_atom *katom_a, |
---|
| 644 | + const struct kbase_jd_atom *katom_b) |
---|
| 645 | +{ |
---|
| 646 | + return ((s32)(katom_a->age - katom_b->age) < 0); |
---|
| 647 | +} |
---|
| 648 | + |
---|
| 649 | +/** |
---|
| 650 | + * kbase_jd_atom_is_earlier - Check whether the first atom has been submitted |
---|
| 651 | + * earlier than the second one |
---|
| 652 | + * |
---|
| 653 | + * @katom_a: the first atom |
---|
| 654 | + * @katom_b: the second atom |
---|
| 655 | + * |
---|
| 656 | + * Return: true if the first atom has been submitted earlier than the |
---|
| 657 | + * second atom. It is used to understand if an atom that is ready has been |
---|
| 658 | + * submitted earlier than the currently running atom, so that the currently |
---|
| 659 | + * running atom should be preempted to allow the ready atom to run. |
---|
| 660 | + */ |
---|
| 661 | +static inline bool kbase_jd_atom_is_earlier(const struct kbase_jd_atom *katom_a, |
---|
| 662 | + const struct kbase_jd_atom *katom_b) |
---|
| 663 | +{ |
---|
| 664 | + /* No seq_nr set? */ |
---|
| 665 | + if (!katom_a->seq_nr || !katom_b->seq_nr) |
---|
| 666 | + return false; |
---|
| 667 | + |
---|
| 668 | + /* Efficiently handle the unlikely case of wrapping. |
---|
| 669 | + * The following code assumes that the delta between the sequence number |
---|
| 670 | + * of the two atoms is less than INT64_MAX. |
---|
| 671 | + * In the extremely unlikely case where the delta is higher, the comparison |
---|
| 672 | + * defaults for no preemption. |
---|
| 673 | + * The code also assumes that the conversion from unsigned to signed types |
---|
| 674 | + * works because the signed integers are 2's complement. |
---|
| 675 | + */ |
---|
| 676 | + return (s64)(katom_a->seq_nr - katom_b->seq_nr) < 0; |
---|
| 677 | +} |
---|
| 678 | + |
---|
656 | 679 | /* |
---|
657 | 680 | * Theory of operations: |
---|
658 | 681 | * |
---|
.. | .. |
---|
690 | 713 | * A state machine is used to control incremental rendering. |
---|
691 | 714 | */ |
---|
692 | 715 | enum kbase_jd_renderpass_state { |
---|
693 | | - KBASE_JD_RP_COMPLETE, /* COMPLETE => START */ |
---|
694 | | - KBASE_JD_RP_START, /* START => PEND_OOM or COMPLETE */ |
---|
695 | | - KBASE_JD_RP_PEND_OOM, /* PEND_OOM => OOM or COMPLETE */ |
---|
696 | | - KBASE_JD_RP_OOM, /* OOM => RETRY */ |
---|
697 | | - KBASE_JD_RP_RETRY, /* RETRY => RETRY_PEND_OOM or |
---|
698 | | - * COMPLETE |
---|
699 | | - */ |
---|
700 | | - KBASE_JD_RP_RETRY_PEND_OOM, /* RETRY_PEND_OOM => RETRY_OOM or |
---|
701 | | - * COMPLETE |
---|
702 | | - */ |
---|
703 | | - KBASE_JD_RP_RETRY_OOM, /* RETRY_OOM => RETRY */ |
---|
| 716 | + KBASE_JD_RP_COMPLETE, /* COMPLETE => START */ |
---|
| 717 | + KBASE_JD_RP_START, /* START => PEND_OOM or COMPLETE */ |
---|
| 718 | + KBASE_JD_RP_PEND_OOM, /* PEND_OOM => OOM or COMPLETE */ |
---|
| 719 | + KBASE_JD_RP_OOM, /* OOM => RETRY */ |
---|
| 720 | + KBASE_JD_RP_RETRY, /* RETRY => RETRY_PEND_OOM or COMPLETE */ |
---|
| 721 | + KBASE_JD_RP_RETRY_PEND_OOM, /* RETRY_PEND_OOM => RETRY_OOM or COMPLETE */ |
---|
| 722 | + KBASE_JD_RP_RETRY_OOM /* RETRY_OOM => RETRY */ |
---|
704 | 723 | }; |
---|
705 | 724 | |
---|
706 | 725 | /** |
---|
.. | .. |
---|
773 | 792 | * atom completes |
---|
774 | 793 | * execution on GPU or the input fence get signaled. |
---|
775 | 794 | * @tb_lock: Lock to serialize the write access made to @tb to |
---|
776 | | - * to store the register access trace messages. |
---|
| 795 | + * store the register access trace messages. |
---|
777 | 796 | * @tb: Pointer to the Userspace accessible buffer storing |
---|
778 | 797 | * the trace messages for register read/write |
---|
779 | 798 | * accesses made by the Kbase. The buffer is filled |
---|
.. | .. |
---|
840 | 859 | * @pf_data: Data relating to Page fault. |
---|
841 | 860 | * @bf_data: Data relating to Bus fault. |
---|
842 | 861 | * @current_setup: Stores the MMU configuration for this address space. |
---|
| 862 | + * @is_unresponsive: Flag to indicate MMU is not responding. |
---|
| 863 | + * Set if a MMU command isn't completed within |
---|
| 864 | + * &kbase_device:mmu_as_inactive_wait_time_ms. |
---|
| 865 | + * Clear by kbase_ctx_sched_restore_all_as() after GPU reset completes. |
---|
843 | 866 | */ |
---|
844 | 867 | struct kbase_as { |
---|
845 | 868 | int number; |
---|
.. | .. |
---|
849 | 872 | struct kbase_fault pf_data; |
---|
850 | 873 | struct kbase_fault bf_data; |
---|
851 | 874 | struct kbase_mmu_setup current_setup; |
---|
| 875 | + bool is_unresponsive; |
---|
852 | 876 | }; |
---|
853 | 877 | |
---|
854 | 878 | #endif /* _KBASE_JM_DEFS_H_ */ |
---|