From e636c8d336489bf3eed5878299e6cc045bbad077 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Tue, 20 Feb 2024 01:17:29 +0000
Subject: [PATCH] debug lk
---
kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_js_defs.h | 131 ++++++++++++++++++++++++++++++-------------
1 files changed, 91 insertions(+), 40 deletions(-)
diff --git a/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_js_defs.h b/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_js_defs.h
index 405f346..465cf7e 100644
--- a/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_js_defs.h
+++ b/kernel/drivers/gpu/arm/bifrost/jm/mali_kbase_js_defs.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
*
- * (C) COPYRIGHT 2011-2018, 2020-2021 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2011-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
@@ -55,10 +55,11 @@
* @KBASEP_JS_CTX_ATTR_COMPUTE: Attribute indicating a context that contains
* Compute jobs.
* @KBASEP_JS_CTX_ATTR_NON_COMPUTE: Attribute indicating a context that contains
- * Non-Compute jobs.
+ * Non-Compute jobs.
* @KBASEP_JS_CTX_ATTR_COMPUTE_ALL_CORES: Attribute indicating that a context
- * contains compute-job atoms that aren't restricted to a coherent group,
- * and can run on all cores.
+ * contains compute-job atoms that aren't
+ * restricted to a coherent group,
+ * and can run on all cores.
* @KBASEP_JS_CTX_ATTR_COUNT: Must be the last in the enum
*
* Each context attribute can be thought of as a boolean value that caches some
@@ -114,7 +115,6 @@
* BASE_JD_REQ_COHERENT_GROUP, it is possible to send such atoms without
* BASE_JD_REQ_COHERENT_GROUP set. This is an unlikely case, but it's easy
* enough to handle anyway.
- *
*
*/
enum kbasep_js_ctx_attr {
@@ -187,47 +187,76 @@
*/
#define KBASE_JS_ATOM_SCHED_PRIO_DEFAULT KBASE_JS_ATOM_SCHED_PRIO_MED
+/* Atom priority bitmaps, where bit 0 is the highest priority, and higher bits
+ * indicate successively lower KBASE_JS_ATOM_SCHED_PRIO_<...> levels.
+ *
+ * Must be strictly larger than the number of bits to represent a bitmap of
+ * priorities, so that we can do calculations such as:
+ * (1 << KBASE_JS_ATOM_SCHED_PRIO_COUNT) - 1
+ * ...without causing undefined behavior due to a shift beyond the width of the
+ * type
+ *
+ * If KBASE_JS_ATOM_SCHED_PRIO_COUNT starts requiring 32 bits, then it's worth
+ * moving to DECLARE_BITMAP()
+ */
+typedef u8 kbase_js_prio_bitmap_t;
+
+/* Ordering modification for kbase_js_atom_runs_before() */
+typedef u32 kbase_atom_ordering_flag_t;
+
+/* Atoms of the same context and priority should have their ordering decided by
+ * their seq_nr instead of their age.
+ *
+ * seq_nr is used as a more slowly changing variant of age - it increases once
+ * per group of related atoms, as determined by user-space. Hence, it can be
+ * used to limit re-ordering decisions (such as pre-emption) to only re-order
+ * between such groups, rather than re-order within those groups of atoms.
+ */
+#define KBASE_ATOM_ORDERING_FLAG_SEQNR (((kbase_atom_ordering_flag_t)1) << 0)
+
/**
* struct kbasep_js_device_data - KBase Device Data Job Scheduler sub-structure
* @runpool_irq: Sub-structure to collect together Job Scheduling data used in
- * IRQ context. The hwaccess_lock must be held when accessing.
+ * IRQ context. The hwaccess_lock must be held when accessing.
* @runpool_irq.submit_allowed: Bitvector indicating whether a currently
- * scheduled context is allowed to submit jobs. When bit 'N' is set in
- * this, it indicates whether the context bound to address space 'N' is
- * allowed to submit jobs.
+ * scheduled context is allowed to submit jobs.
+ * When bit 'N' is set in this, it indicates whether
+ * the context bound to address space 'N' is
+ * allowed to submit jobs.
* @runpool_irq.ctx_attr_ref_count: Array of Context Attributes Ref_counters:
- * Each is large enough to hold a refcount of the number of contexts
- * that can fit into the runpool. This is currently BASE_MAX_NR_AS.
- * Note that when BASE_MAX_NR_AS==16 we need 5 bits (not 4) to store
- * the refcount. Hence, it's not worthwhile reducing this to
- * bit-manipulation on u32s to save space (where in contrast, 4 bit
- * sub-fields would be easy to do and would save space).
- * Whilst this must not become negative, the sign bit is used for:
- * - error detection in debug builds
- * - Optimization: it is undefined for a signed int to overflow, and so
- * the compiler can optimize for that never happening (thus, no masking
- * is required on updating the variable)
+ * Each is large enough to hold a refcount of the number of contexts
+ * that can fit into the runpool. This is currently BASE_MAX_NR_AS.
+ * Note that when BASE_MAX_NR_AS==16 we need 5 bits (not 4) to store
+ * the refcount. Hence, it's not worthwhile reducing this to
+ * bit-manipulation on u32s to save space (where in contrast, 4 bit
+ * sub-fields would be easy to do and would save space).
+ * Whilst this must not become negative, the sign bit is used for:
+ * - error detection in debug builds
+ * - Optimization: it is undefined for a signed int to overflow, and so
+ * the compiler can optimize for that never happening (thus, no masking
+ * is required on updating the variable)
* @runpool_irq.slot_affinities: Affinity management and tracking. Bitvector
- * to aid affinity checking. Element 'n' bit 'i' indicates that slot 'n'
- * is using core i (i.e. slot_affinity_refcount[n][i] > 0)
+ * to aid affinity checking.
+ * Element 'n' bit 'i' indicates that slot 'n'
+ * is using core i (i.e. slot_affinity_refcount[n][i] > 0)
* @runpool_irq.slot_affinity_refcount: Array of fefcount for each core owned
- * by each slot. Used to generate the slot_affinities array of bitvectors.
- * The value of the refcount will not exceed BASE_JM_SUBMIT_SLOTS,
- * because it is refcounted only when a job is definitely about to be
- * submitted to a slot, and is de-refcounted immediately after a job
- * finishes
+ * by each slot. Used to generate the slot_affinities array of bitvectors.
+ * The value of the refcount will not exceed BASE_JM_SUBMIT_SLOTS,
+ * because it is refcounted only when a job is definitely about to be
+ * submitted to a slot, and is de-refcounted immediately after a job
+ * finishes
* @schedule_sem: Scheduling semaphore. This must be held when calling
- * kbase_jm_kick()
+ * kbase_jm_kick()
* @ctx_list_pullable: List of contexts that can currently be pulled from
* @ctx_list_unpullable: List of contexts that can not currently be pulled
- * from, but have jobs currently running.
+ * from, but have jobs currently running.
* @nr_user_contexts_running: Number of currently scheduled user contexts
- * (excluding ones that are not submitting jobs)
+ * (excluding ones that are not submitting jobs)
* @nr_all_contexts_running: Number of currently scheduled contexts (including
- * ones that are not submitting jobs)
+ * ones that are not submitting jobs)
* @js_reqs: Core Requirements to match up with base_js_atom's core_req memeber
- * @note This is a write-once member, and so no locking is required to
- * read
+ * @note This is a write-once member, and so no locking is required to
+ * read
* @scheduling_period_ns: Value for JS_SCHEDULING_PERIOD_NS
* @soft_stop_ticks: Value for JS_SOFT_STOP_TICKS
* @soft_stop_ticks_cl: Value for JS_SOFT_STOP_TICKS_CL
@@ -241,16 +270,17 @@
* @suspended_soft_jobs_list: List of suspended soft jobs
* @softstop_always: Support soft-stop on a single context
* @init_status:The initialized-flag is placed at the end, to avoid
- * cache-pollution (we should only be using this during init/term paths).
- * @note This is a write-once member, and so no locking is required to
- * read
+ * cache-pollution (we should only be using this during init/term paths).
+ * @note This is a write-once member, and so no locking is required to
+ * read
* @nr_contexts_pullable:Number of contexts that can currently be pulled from
* @nr_contexts_runnable:Number of contexts that can either be pulled from or
- * arecurrently running
+ * arecurrently running
* @soft_job_timeout_ms:Value for JS_SOFT_JOB_TIMEOUT
+ * @js_free_wait_time_ms: Maximum waiting time in ms for a Job Slot to be seen free.
* @queue_mutex: Queue Lock, used to access the Policy's queue of contexts
- * independently of the Run Pool.
- * Of course, you don't need the Run Pool lock to access this.
+ * independently of the Run Pool.
+ * Of course, you don't need the Run Pool lock to access this.
* @runpool_mutex: Run Pool mutex, for managing contexts within the runpool.
*
* This encapsulates the current context of the Job Scheduler on a particular
@@ -300,6 +330,8 @@
u32 nr_contexts_pullable;
atomic_t nr_contexts_runnable;
atomic_t soft_job_timeout_ms;
+ u32 js_free_wait_time_ms;
+
struct mutex queue_mutex;
/*
* Run Pool mutex, for managing contexts within the runpool.
@@ -358,7 +390,7 @@
* @sched_priority: priority
* @device_nr: Core group atom was executed on
*
- * Subset of atom state that can be available after jd_done_nolock() is called
+ * Subset of atom state that can be available after kbase_jd_done_nolock() is called
* on that atom. A copy must be taken via kbasep_js_atom_retained_state_copy(),
* because the original atom could disappear.
*/
@@ -393,4 +425,23 @@
*/
#define KBASEP_JS_TICK_RESOLUTION_US 1
+/**
+ * struct kbase_jsctx_slot_tracking - Job Scheduling tracking of a context's
+ * use of a job slot
+ * @blocked: bitmap of priorities that this slot is blocked at
+ * @atoms_pulled: counts of atoms that have been pulled from this slot,
+ * across all priority levels
+ * @atoms_pulled_pri: counts of atoms that have been pulled from this slot, per
+ * priority level
+ *
+ * Controls how a slot from the &struct kbase_context's jsctx_queue is managed,
+ * for example to ensure correct ordering of atoms when atoms of different
+ * priorities are unpulled.
+ */
+struct kbase_jsctx_slot_tracking {
+ kbase_js_prio_bitmap_t blocked;
+ atomic_t atoms_pulled;
+ int atoms_pulled_pri[KBASE_JS_ATOM_SCHED_PRIO_COUNT];
+};
+
#endif /* _KBASE_JS_DEFS_H_ */
--
Gitblit v1.6.2