From f70575805708cabdedea7498aaa3f710fde4d920 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Wed, 31 Jan 2024 03:29:01 +0000 Subject: [PATCH] add lvds1024*800 --- kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_jm_defs.h | 186 ++++++++++++++++++++++++++-------------------- 1 files changed, 105 insertions(+), 81 deletions(-) diff --git a/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_jm_defs.h b/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_jm_defs.h index a44b4b7..debc3ad 100644 --- a/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_jm_defs.h +++ b/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_jm_defs.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * - * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2019-2023 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 @@ -87,8 +87,6 @@ #define KBASE_KATOM_FLAG_FAIL_BLOCKER (1<<8) /* Atom is currently in the list of atoms blocked on cross-slot dependencies */ #define KBASE_KATOM_FLAG_JSCTX_IN_X_DEP_LIST (1<<9) -/* Atom is currently holding a context reference */ -#define KBASE_KATOM_FLAG_HOLDING_CTX_REF (1<<10) /* Atom requires GPU to be in protected mode */ #define KBASE_KATOM_FLAG_PROTECTED (1<<11) /* Atom has been stored in runnable_tree */ @@ -125,6 +123,25 @@ #define KBASE_SERIALIZE_INTER_SLOT (1 << 1) /* Reset the GPU after each atom completion */ #define KBASE_SERIALIZE_RESET (1 << 2) + +/** + * enum kbase_timeout_selector - The choice of which timeout to get scaled + * using the lowest GPU frequency. + * @MMU_AS_INACTIVE_WAIT_TIMEOUT: Maximum waiting time in ms for the completion + * of a MMU operation + * @JM_DEFAULT_JS_FREE_TIMEOUT: Maximum timeout to wait for JS_COMMAND_NEXT + * to be updated on HW side so a Job Slot is + * considered free. + * @KBASE_TIMEOUT_SELECTOR_COUNT: Number of timeout selectors. Must be last in + * the enum. + */ +enum kbase_timeout_selector { + MMU_AS_INACTIVE_WAIT_TIMEOUT, + JM_DEFAULT_JS_FREE_TIMEOUT, + + /* Must be the last in the enum */ + KBASE_TIMEOUT_SELECTOR_COUNT +}; #if IS_ENABLED(CONFIG_DEBUG_FS) /** @@ -176,8 +193,6 @@ static inline const struct kbase_jd_atom * kbase_jd_katom_dep_atom(const struct kbase_jd_atom_dependency *dep) { - LOCAL_ASSERT(dep != NULL); - return (const struct kbase_jd_atom *)(dep->atom); } @@ -191,8 +206,6 @@ static inline u8 kbase_jd_katom_dep_type( const struct kbase_jd_atom_dependency *dep) { - LOCAL_ASSERT(dep != NULL); - return dep->dep_type; } @@ -209,8 +222,6 @@ { struct kbase_jd_atom_dependency *dep; - LOCAL_ASSERT(const_dep != NULL); - dep = (struct kbase_jd_atom_dependency *)const_dep; dep->atom = a; @@ -226,8 +237,6 @@ const struct kbase_jd_atom_dependency *const_dep) { struct kbase_jd_atom_dependency *dep; - - LOCAL_ASSERT(const_dep != NULL); dep = (struct kbase_jd_atom_dependency *)const_dep; @@ -343,19 +352,6 @@ }; /** - * struct kbase_ext_res - Contains the info for external resources referred - * by an atom, which have been mapped on GPU side. - * @gpu_address: Start address of the memory region allocated for - * the resource from GPU virtual address space. - * @alloc: pointer to physical pages tracking object, set on - * mapping the external resource on GPU side. - */ -struct kbase_ext_res { - u64 gpu_address; - struct kbase_mem_phy_alloc *alloc; -}; - -/** * struct kbase_jd_atom - object representing the atom, containing the complete * state and attributes of an atom. * @work: work item for the bottom half processing of the atom, @@ -388,7 +384,8 @@ * each allocation is read in order to enforce an * overall physical memory usage limit. * @nr_extres: number of external resources referenced by the atom. - * @extres: pointer to the location containing info about + * @extres: Pointer to @nr_extres VA regions containing the external + * resource allocation and other information. * @nr_extres external resources referenced by the atom. * @device_nr: indicates the coregroup with which the atom is * associated, when @@ -406,16 +403,21 @@ * sync through soft jobs and for the implicit * synchronization required on access to external * resources. - * @dma_fence.fence_in: Input fence + * @dma_fence.fence_in: Points to the dma-buf input fence for this atom. + * The atom would complete only after the fence is + * signaled. * @dma_fence.fence: Points to the dma-buf output fence for this atom. + * @dma_fence.fence_cb: The object that is passed at the time of adding the + * callback that gets invoked when @dma_fence.fence_in + * is signaled. + * @dma_fence.fence_cb_added: Flag to keep a track if the callback was successfully + * added for @dma_fence.fence_in, which is supposed to be + * invoked on the signaling of fence. * @dma_fence.context: The dma-buf fence context number for this atom. A * unique context number is allocated to each katom in * the context on context creation. * @dma_fence.seqno: The dma-buf fence sequence number for this atom. This * is increased every time this katom uses dma-buf fence - * @dma_fence.callbacks: List of all callbacks set up to wait on other fences - * @dma_fence.dep_count: Atomic counter of number of outstandind dma-buf fence - * dependencies for this atom. * @event_code: Event code for the job chain represented by the atom, * both HW and low-level SW events are represented by * event codes. @@ -498,7 +500,6 @@ * BASE_JD_REQ_START_RENDERPASS set in its core requirements * with an atom that has BASE_JD_REQ_END_RENDERPASS set. * @jc_fragment: Set of GPU fragment job chains - * @retry_count: TODO: Not used,to be removed */ struct kbase_jd_atom { struct work_struct work; @@ -518,21 +519,17 @@ #endif /* MALI_JIT_PRESSURE_LIMIT_BASE */ u16 nr_extres; - struct kbase_ext_res *extres; + struct kbase_va_region **extres; u32 device_nr; u64 jc; void *softjob_data; -#if defined(CONFIG_SYNC) - struct sync_fence *fence; - struct sync_fence_waiter sync_waiter; -#endif /* CONFIG_SYNC */ -#if defined(CONFIG_MALI_BIFROST_DMA_FENCE) || defined(CONFIG_SYNC_FILE) +#if IS_ENABLED(CONFIG_SYNC_FILE) struct { /* Use the functions/API defined in mali_kbase_fence.h to * when working with this sub struct */ -#if defined(CONFIG_SYNC_FILE) +#if IS_ENABLED(CONFIG_SYNC_FILE) #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) struct fence *fence_in; #else @@ -555,38 +552,21 @@ #else struct dma_fence *fence; #endif + + /* This is the callback object that is registered for the fence_in. + * The callback is invoked when the fence_in is signaled. + */ +#if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) + struct fence_cb fence_cb; +#else + struct dma_fence_cb fence_cb; +#endif + bool fence_cb_added; + unsigned int context; atomic_t seqno; - /* This contains a list of all callbacks set up to wait on - * other fences. This atom must be held back from JS until all - * these callbacks have been called and dep_count have reached - * 0. The initial value of dep_count must be equal to the - * number of callbacks on this list. - * - * This list is protected by jctx.lock. Callbacks are added to - * this list when the atom is built and the wait are set up. - * All the callbacks then stay on the list until all callbacks - * have been called and the atom is queued, or cancelled, and - * then all callbacks are taken off the list and freed. - */ - struct list_head callbacks; - /* Atomic counter of number of outstandind dma-buf fence - * dependencies for this atom. When dep_count reaches 0 the - * atom may be queued. - * - * The special value "-1" may only be set after the count - * reaches 0, while holding jctx.lock. This indicates that the - * atom has been handled, either queued in JS or cancelled. - * - * If anyone but the dma-fence worker sets this to -1 they must - * ensure that any potentially queued worker must have - * completed before allowing the atom to be marked as unused. - * This can be done by flushing the fence work queue: - * kctx->dma_fence.wq. - */ - atomic_t dep_count; } dma_fence; -#endif /* CONFIG_MALI_BIFROST_DMA_FENCE || CONFIG_SYNC_FILE */ +#endif /* CONFIG_SYNC_FILE */ /* Note: refer to kbasep_js_atom_retained_state, which will take a copy * of some of the following members @@ -605,11 +585,9 @@ #if IS_ENABLED(CONFIG_GPU_TRACEPOINTS) int work_id; #endif - int slot_nr; + unsigned int slot_nr; u32 atom_flags; - - int retry_count; enum kbase_atom_gpu_rb_state gpu_rb_state; @@ -653,6 +631,51 @@ return (bool)(katom->atom_flags & KBASE_KATOM_FLAG_PROTECTED); } +/** + * kbase_jd_atom_is_younger - query if one atom is younger by age than another + * + * @katom_a: the first atom + * @katom_b: the second atom + * + * Return: true if the first atom is strictly younger than the second, + * false otherwise. + */ +static inline bool kbase_jd_atom_is_younger(const struct kbase_jd_atom *katom_a, + const struct kbase_jd_atom *katom_b) +{ + return ((s32)(katom_a->age - katom_b->age) < 0); +} + +/** + * kbase_jd_atom_is_earlier - Check whether the first atom has been submitted + * earlier than the second one + * + * @katom_a: the first atom + * @katom_b: the second atom + * + * Return: true if the first atom has been submitted earlier than the + * second atom. It is used to understand if an atom that is ready has been + * submitted earlier than the currently running atom, so that the currently + * running atom should be preempted to allow the ready atom to run. + */ +static inline bool kbase_jd_atom_is_earlier(const struct kbase_jd_atom *katom_a, + const struct kbase_jd_atom *katom_b) +{ + /* No seq_nr set? */ + if (!katom_a->seq_nr || !katom_b->seq_nr) + return false; + + /* Efficiently handle the unlikely case of wrapping. + * The following code assumes that the delta between the sequence number + * of the two atoms is less than INT64_MAX. + * In the extremely unlikely case where the delta is higher, the comparison + * defaults for no preemption. + * The code also assumes that the conversion from unsigned to signed types + * works because the signed integers are 2's complement. + */ + return (s64)(katom_a->seq_nr - katom_b->seq_nr) < 0; +} + /* * Theory of operations: * @@ -690,17 +713,13 @@ * A state machine is used to control incremental rendering. */ enum kbase_jd_renderpass_state { - KBASE_JD_RP_COMPLETE, /* COMPLETE => START */ - KBASE_JD_RP_START, /* START => PEND_OOM or COMPLETE */ - KBASE_JD_RP_PEND_OOM, /* PEND_OOM => OOM or COMPLETE */ - KBASE_JD_RP_OOM, /* OOM => RETRY */ - KBASE_JD_RP_RETRY, /* RETRY => RETRY_PEND_OOM or - * COMPLETE - */ - KBASE_JD_RP_RETRY_PEND_OOM, /* RETRY_PEND_OOM => RETRY_OOM or - * COMPLETE - */ - KBASE_JD_RP_RETRY_OOM, /* RETRY_OOM => RETRY */ + KBASE_JD_RP_COMPLETE, /* COMPLETE => START */ + KBASE_JD_RP_START, /* START => PEND_OOM or COMPLETE */ + KBASE_JD_RP_PEND_OOM, /* PEND_OOM => OOM or COMPLETE */ + KBASE_JD_RP_OOM, /* OOM => RETRY */ + KBASE_JD_RP_RETRY, /* RETRY => RETRY_PEND_OOM or COMPLETE */ + KBASE_JD_RP_RETRY_PEND_OOM, /* RETRY_PEND_OOM => RETRY_OOM or COMPLETE */ + KBASE_JD_RP_RETRY_OOM /* RETRY_OOM => RETRY */ }; /** @@ -773,7 +792,7 @@ * atom completes * execution on GPU or the input fence get signaled. * @tb_lock: Lock to serialize the write access made to @tb to - * to store the register access trace messages. + * store the register access trace messages. * @tb: Pointer to the Userspace accessible buffer storing * the trace messages for register read/write * accesses made by the Kbase. The buffer is filled @@ -840,6 +859,10 @@ * @pf_data: Data relating to Page fault. * @bf_data: Data relating to Bus fault. * @current_setup: Stores the MMU configuration for this address space. + * @is_unresponsive: Flag to indicate MMU is not responding. + * Set if a MMU command isn't completed within + * &kbase_device:mmu_as_inactive_wait_time_ms. + * Clear by kbase_ctx_sched_restore_all_as() after GPU reset completes. */ struct kbase_as { int number; @@ -849,6 +872,7 @@ struct kbase_fault pf_data; struct kbase_fault bf_data; struct kbase_mmu_setup current_setup; + bool is_unresponsive; }; #endif /* _KBASE_JM_DEFS_H_ */ -- Gitblit v1.6.2