summaryrefslogtreecommitdiff
path: root/drivers/gpu/arm/midgard/mali_kbase_defs.h
diff options
context:
space:
mode:
authorchenzhen <chenzhen@rock-chips.com>2016-04-05 16:53:38 +0800
committerHuang, Tao <huangtao@rock-chips.com>2016-05-31 09:11:11 +0800
commit3adc6eb16b2bdfb47fa83e8608ee11b25b6c2908 (patch)
treeddecc1c5a66391824bfc866c19fd6037ebd662dd /drivers/gpu/arm/midgard/mali_kbase_defs.h
parent206f372edef1825b246043ee114097e28130739c (diff)
MALI: rockchip: upgrade midgard DDK to r11p0-00rel0
Conflicts: drivers/gpu/arm/midgard/mali_kbase_core_linux.c drivers/gpu/arm/midgard/mali_kbase_jd.c Change-Id: I9c910f2b08ffd2e9101fbe85958030ac7bca1642 Signed-off-by: chenzhen <chenzhen@rock-chips.com>
Diffstat (limited to 'drivers/gpu/arm/midgard/mali_kbase_defs.h')
-rw-r--r--drivers/gpu/arm/midgard/mali_kbase_defs.h193
1 files changed, 167 insertions, 26 deletions
diff --git a/drivers/gpu/arm/midgard/mali_kbase_defs.h b/drivers/gpu/arm/midgard/mali_kbase_defs.h
index 0fc5ff95234e..c6008dbbc03c 100644
--- a/drivers/gpu/arm/midgard/mali_kbase_defs.h
+++ b/drivers/gpu/arm/midgard/mali_kbase_defs.h
@@ -1,6 +1,6 @@
/*
*
- * (C) COPYRIGHT 2011-2015 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2011-2016 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
@@ -187,6 +187,8 @@
#define KBASE_KATOM_FLAG_HOLDING_CTX_REF (1<<10)
/* Atom requires GPU to be in secure mode */
#define KBASE_KATOM_FLAG_SECURE (1<<11)
+/* Atom has been stored in linked list */
+#define KBASE_KATOM_FLAG_JSCTX_IN_LL (1<<12)
/* SW related flags about types of JS_COMMAND action
* NOTE: These must be masked off by JS_COMMAND_MASK */
@@ -396,6 +398,14 @@ struct kbase_jd_atom {
#ifdef CONFIG_DEBUG_FS
struct base_job_fault_event fault_event;
#endif
+
+ struct list_head queue;
+
+ struct kbase_va_region *jit_addr_reg;
+
+ /* If non-zero, this indicates that the atom will fail with the set
+ * event_code when the atom is processed. */
+ enum base_jd_event_code will_fail_event_code;
};
static inline bool kbase_jd_katom_is_secure(const struct kbase_jd_atom *katom)
@@ -476,6 +486,7 @@ typedef u32 kbase_as_poke_state;
struct kbase_mmu_setup {
u64 transtab;
u64 memattr;
+ u64 transcfg;
};
/**
@@ -494,6 +505,7 @@ struct kbase_as {
enum kbase_mmu_fault_type fault_type;
u32 fault_status;
u64 fault_addr;
+ u64 fault_extra_addr;
struct mutex transaction_mutex;
struct kbase_mmu_setup current_setup;
@@ -791,9 +803,7 @@ struct kbase_device {
int irq;
int flags;
} irqs[3];
-#ifdef CONFIG_HAVE_CLK
struct clk *clock;
-#endif
#ifdef CONFIG_REGULATOR
struct regulator *regulator;
#endif
@@ -879,7 +889,7 @@ struct kbase_device {
s8 nr_user_address_spaces; /**< Number of address spaces available to user contexts */
/* Structure used for instrumentation and HW counters dumping */
- struct {
+ struct kbase_hwcnt {
/* The lock should be used when accessing any of the following members */
spinlock_t lock;
@@ -1017,11 +1027,23 @@ struct kbase_device {
/* defaults for new context created for this device */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+ bool infinite_cache_active_default;
+#else
u32 infinite_cache_active_default;
+#endif
size_t mem_pool_max_size_default;
/* system coherency mode */
u32 system_coherency;
+ /* Flag to track when cci snoops have been enabled on the interface */
+ bool cci_snoop_enabled;
+
+ /* SMC function IDs to call into Trusted firmware to enable/disable
+ * cache snooping. Value of 0 indicates that they are not used
+ */
+ u32 snoop_enable_smc;
+ u32 snoop_disable_smc;
/* Secure operations */
struct kbase_secure_ops *secure_ops;
@@ -1050,14 +1072,31 @@ struct kbase_device {
#endif
/* Boolean indicating if an IRQ flush during reset is in progress. */
bool irq_reset_flush;
+
+ /* list of inited sub systems. Used during terminate/error recovery */
+ u32 inited_subsys;
};
-/* JSCTX ringbuffer size must always be a power of 2 */
-#define JSCTX_RB_SIZE 256
-#define JSCTX_RB_MASK (JSCTX_RB_SIZE-1)
+/* JSCTX ringbuffer size will always be a power of 2. The idx shift must be:
+ - >=2 (buffer size -> 4)
+ - <= 9 (buffer size 2^(9-1)=256) (technically, 10 works for the ringbuffer
+ but this is unnecessary as max atoms is 256)
+ */
+#define JSCTX_RB_IDX_SHIFT (8U)
+#if ((JSCTX_RB_IDX_SHIFT < 2) || ((3 * JSCTX_RB_IDX_SHIFT) >= 32))
+#error "Invalid ring buffer size for 32bit atomic."
+#endif
+#define JSCTX_RB_SIZE (1U << (JSCTX_RB_IDX_SHIFT - 1U)) /* 1 bit for overflow */
+#define JSCTX_RB_SIZE_STORE (1U << JSCTX_RB_IDX_SHIFT)
+#define JSCTX_RB_MASK (JSCTX_RB_SIZE - 1U)
+#define JSCTX_RB_MASK_STORE (JSCTX_RB_SIZE_STORE - 1U)
+
+#define JSCTX_WR_OFFSET (0U)
+#define JSCTX_RN_OFFSET (JSCTX_WR_OFFSET + JSCTX_RB_IDX_SHIFT)
+#define JSCTX_RD_OFFSET (JSCTX_RN_OFFSET + JSCTX_RB_IDX_SHIFT)
/**
- * struct jsctx_rb_entry - Entry in &struct jsctx_rb ring buffer
+ * struct jsctx_rb_entry - Ringbuffer entry in &struct jsctx_queue.
* @atom_id: Atom ID
*/
struct jsctx_rb_entry {
@@ -1065,32 +1104,52 @@ struct jsctx_rb_entry {
};
/**
- * struct jsctx_rb - JS context atom ring buffer
+ * struct jsctx_queue - JS context atom queue, containing both ring buffer and linked list.
* @entries: Array of size %JSCTX_RB_SIZE which holds the &struct
* kbase_jd_atom pointers which make up the contents of the ring
* buffer.
- * @read_idx: Index into @entries. Indicates the next entry in @entries to
- * read, and is incremented when pulling an atom, and decremented
- * when unpulling.
- * HW access lock must be held when accessing.
- * @write_idx: Index into @entries. Indicates the next entry to use when
- * adding atoms into the ring buffer, and is incremented when
- * adding a new atom.
- * jctx->lock must be held when accessing.
- * @running_idx: Index into @entries. Indicates the last valid entry, and is
- * incremented when remving atoms from the ring buffer.
- * HW access lock must be held when accessing.
+ * @indicies: An atomic variable containing indicies for the ring buffer.
+ * Indicies are of size JSCTX_RB_IDX_SHIFT.
+ * The following are contained:
+ * - WR_IDX - Write index. Index of the NEXT slot to be written.
+ * - RN_IDX - Running index. Index of the tail of the list.
+ * This is the atom that has been running the longest.
+ * - RD_IDX - Read index. Index of the next atom to be pulled.
+ * @queue_head: Head item of the linked list queue.
*
- * &struct jsctx_rb is a ring buffer of &struct kbase_jd_atom.
+ * Locking:
+ * The linked list assumes jctx.lock is held.
+ * The ringbuffer serves as an intermediary between irq context and non-irq
+ * context, without the need for the two to share any lock. irq context can
+ * pull (and unpull) and only requires the runpool_irq.lock. While non-irq
+ * context can add and remove and only requires holding only jctx.lock.
+ * Error handling affecting both, or the whole ringbuffer in general, must
+ * hold both locks or otherwise ensure (f.ex deschedule/kill) only that thread
+ * is accessing the buffer.
+ * This means that RD_IDX is updated by irq-context (pull and unpull) and must
+ * hold runpool_irq.lock. While WR_IDX (add) and RN_IDX (remove) is updated by
+ * non-irq context and must hold jctx.lock.
+ * Note that pull (or sister function peek) must also access WR_IDX to ensure
+ * there is free space in the buffer, this is ok as WR_IDX is only increased.
+ * A similar situation is apparent with unpull and RN_IDX, but only one atom
+ * (already pulled) can cause either remove or unpull, so this will never
+ * conflict.
+ *
+ * &struct jsctx_queue is a queue of &struct kbase_jd_atom,
+ * part ringbuffer and part linked list.
*/
-struct jsctx_rb {
+struct jsctx_queue {
struct jsctx_rb_entry entries[JSCTX_RB_SIZE];
- u16 read_idx; /* HW access lock must be held when accessing */
- u16 write_idx; /* jctx->lock must be held when accessing */
- u16 running_idx; /* HW access lock must be held when accessing */
+ atomic_t indicies;
+
+ struct list_head queue_head;
};
+
+
+
+
#define KBASE_API_VERSION(major, minor) ((((major) & 0xFFF) << 20) | \
(((minor) & 0xFFF) << 8) | \
((0 & 0xFF) << 0))
@@ -1102,10 +1161,12 @@ struct kbase_context {
unsigned long api_version;
phys_addr_t pgd;
struct list_head event_list;
+ struct list_head event_coalesce_list;
struct mutex event_mutex;
atomic_t event_closed;
struct workqueue_struct *event_workq;
atomic_t event_count;
+ int event_coalesce_count;
bool is_compat;
@@ -1116,6 +1177,7 @@ struct kbase_context {
struct page *aliasing_sink_page;
+ struct mutex mmu_lock;
struct mutex reg_lock; /* To be converted to a rwlock? */
struct rb_root reg_rbtree; /* Red-Black tree of GPU regions (live regions) */
@@ -1132,7 +1194,12 @@ struct kbase_context {
struct kbase_mem_pool mem_pool;
+ struct shrinker reclaim;
+ struct list_head evict_list;
+ struct mutex evict_lock;
+
struct list_head waiting_soft_jobs;
+ spinlock_t waiting_soft_jobs_lock;
#ifdef CONFIG_KDS
struct list_head waiting_kds_resource;
#endif
@@ -1157,6 +1224,8 @@ struct kbase_context {
* All other flags must be added there */
spinlock_t mm_update_lock;
struct mm_struct *process_mm;
+ /* End of the SAME_VA zone */
+ u64 same_va_end;
#ifdef CONFIG_MALI_TRACE_TIMELINE
struct kbase_trace_kctx_timeline timeline;
@@ -1182,7 +1251,7 @@ struct kbase_context {
#endif /* CONFIG_DEBUG_FS */
- struct jsctx_rb jsctx_rb
+ struct jsctx_queue jsctx_queue
[KBASE_JS_ATOM_SCHED_PRIO_COUNT][BASE_JM_MAX_NR_SLOTS];
/* Number of atoms currently pulled from this context */
@@ -1193,7 +1262,11 @@ struct kbase_context {
bool pulled;
/* true if infinite cache is to be enabled for new allocations. Existing
* allocations will not change. bool stored as a u32 per Linux API */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+ bool infinite_cache_active;
+#else
u32 infinite_cache_active;
+#endif
/* Bitmask of slots that can be pulled from */
u32 slots_pullable;
@@ -1220,6 +1293,49 @@ struct kbase_context {
/* true if context is counted in kbdev->js_data.nr_contexts_runnable */
bool ctx_runnable_ref;
+
+ /* Waiting soft-jobs will fail when this timer expires */
+ struct hrtimer soft_event_timeout;
+
+ /* JIT allocation management */
+ struct kbase_va_region *jit_alloc[255];
+ struct list_head jit_active_head;
+ struct list_head jit_pool_head;
+ struct list_head jit_destroy_head;
+ struct mutex jit_lock;
+ struct work_struct jit_work;
+
+ /* External sticky resource management */
+ struct list_head ext_res_meta_head;
+};
+
+/**
+ * struct kbase_ctx_ext_res_meta - Structure which binds an external resource
+ * to a @kbase_context.
+ * @ext_res_node: List head for adding the metadata to a
+ * @kbase_context.
+ * @alloc: The physical memory allocation structure
+ * which is mapped.
+ * @gpu_addr: The GPU virtual address the resource is
+ * mapped to.
+ * @refcount: Refcount to keep track of the number of
+ * active mappings.
+ *
+ * External resources can be mapped into multiple contexts as well as the same
+ * context multiple times.
+ * As kbase_va_region itself isn't refcounted we can't attach our extra
+ * information to it as it could be removed under our feet leaving external
+ * resources pinned.
+ * This metadata structure binds a single external resource to a single
+ * context, ensuring that per context refcount is tracked separately so it can
+ * be overridden when needed and abuses by the application (freeing the resource
+ * multiple times) don't effect the refcount of the physical allocation.
+ */
+struct kbase_ctx_ext_res_meta {
+ struct list_head ext_res_node;
+ struct kbase_mem_phy_alloc *alloc;
+ u64 gpu_addr;
+ u64 refcount;
};
enum kbase_reg_access_type {
@@ -1260,4 +1376,29 @@ static inline bool kbase_device_is_cpu_coherent(struct kbase_device *kbdev)
/* Maximum number of times a job can be replayed */
#define BASEP_JD_REPLAY_LIMIT 15
+/* JobDescriptorHeader - taken from the architecture specifications, the layout
+ * is currently identical for all GPU archs. */
+struct job_descriptor_header {
+ u32 exception_status;
+ u32 first_incomplete_task;
+ u64 fault_pointer;
+ u8 job_descriptor_size : 1;
+ u8 job_type : 7;
+ u8 job_barrier : 1;
+ u8 _reserved_01 : 1;
+ u8 _reserved_1 : 1;
+ u8 _reserved_02 : 1;
+ u8 _reserved_03 : 1;
+ u8 _reserved_2 : 1;
+ u8 _reserved_04 : 1;
+ u8 _reserved_05 : 1;
+ u16 job_index;
+ u16 job_dependency_index_1;
+ u16 job_dependency_index_2;
+ union {
+ u64 _64;
+ u32 _32;
+ } next_job;
+};
+
#endif /* _KBASE_DEFS_H_ */