Commit 21318a63 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

panwrap: Include enough for a trivial Dvalin capture

Thank you Ryan for the reference code here.
Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa@rosenzweig.io>
parent 729f80eb
/*
* © Copyright 2017-2018 The Panfrost Community
*
* 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
* Foundation, and any use by you of this program is subject to the terms
* of such GNU license.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __MALI_IOCTL_DVALIN_H__
#define __MALI_IOCTL_DVALIN_H__
union mali_ioctl_mem_alloc {
union mali_ioctl_header header;
/* [in] */
struct {
u64 va_pages;
u64 commit_pages;
u64 extent;
u64 flags;
} in;
struct {
u64 flags;
u64 gpu_va;
} out;
} __attribute__((packed));
#define MALI_IOCTL_TYPE_BASE 0x80
#define MALI_IOCTL_TYPE_MAX 0x81
#define MALI_IOCTL_TYPE_COUNT (MALI_IOCTL_TYPE_MAX - MALI_IOCTL_TYPE_BASE + 1)
#define MALI_IOCTL_GET_VERSION (_IOWR(0x80, 0, struct mali_ioctl_get_version))
#define MALI_IOCTL_SET_FLAGS ( _IOW(0x80, 1, struct mali_ioctl_set_flags))
#define MALI_IOCTL_JOB_SUBMIT ( _IOW(0x80, 2, struct mali_ioctl_job_submit))
#define MALI_IOCTL_GET_GPUPROPS ( _IOW(0x80, 3, struct mali_ioctl_get_gpuprops))
#define MALI_IOCTL_POST_TERM ( _IO(0x80, 4))
#define MALI_IOCTL_MEM_ALLOC (_IOWR(0x80, 5, union mali_ioctl_mem_alloc))
#define MALI_IOCTL_MEM_QUERY (_IOWR(0x80, 6, struct mali_ioctl_mem_query))
#define MALI_IOCTL_MEM_FREE ( _IOW(0x80, 7, struct mali_ioctl_mem_free))
#define MALI_IOCTL_HWCNT_SETUP ( _IOW(0x80, 8, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_ENABLE ( _IOW(0x80, 9, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_DUMP ( _IO(0x80, 10))
#define MALI_IOCTL_HWCNT_CLEAR ( _IO(0x80, 11))
#define MALI_IOCTL_DISJOINT_QUERY ( _IOR(0x80, 12, __ioctl_placeholder))
// Get DDK version
// mem jit init
#define MALI_IOCTL_SYNC ( _IOW(0x80, 15, struct mali_ioctl_sync))
#define MALI_IOCTL_FIND_CPU_OFFSET (_IOWR(0x80, 16, __ioctl_placeholder))
#define MALI_IOCTL_GET_CONTEXT_ID ( _IOR(0x80, 17, struct mali_ioctl_get_context_id))
// TLStream acquire
// TLStream Flush
#define MALI_IOCTL_MEM_COMMIT ( _IOW(0x80, 20, struct mali_ioctl_mem_commit))
#define MALI_IOCTL_MEM_ALIAS (_IOWR(0x80, 21, struct mali_ioctl_mem_alias))
#define MALI_IOCTL_MEM_IMPORT (_IOWR(0x80, 22, struct mali_ioctl_mem_import))
#define MALI_IOCTL_MEM_FLAGS_CHANGE ( _IOW(0x80, 23, struct mali_ioctl_mem_flags_change))
#define MALI_IOCTL_STREAM_CREATE ( _IOW(0x80, 24, struct mali_ioctl_stream_create))
#define MALI_IOCTL_FENCE_VALIDATE ( _IOW(0x80, 25, __ioctl_placeholder))
#define MALI_IOCTL_GET_PROFILING_CONTROLS ( _IOW(0x80, 26, __ioctl_placeholder))
#define MALI_IOCTL_DEBUGFS_MEM_PROFILE_ADD ( _IOW(0x80, 27, __ioctl_placeholder))
// Soft event update
// sticky resource map
// sticky resource unmap
// Find gpu start and offset
#define MALI_IOCTL_HWCNT_SET ( _IOW(0x80, 32, __ioctl_placeholder))
// gwt start
// gwt stop
// gwt dump
/// Begin TEST type region
/// End TEST type region
#endif /* __MALI_IOCTL_DVALIN_H__ */
/*
* © Copyright 2017-2018 The Panfrost Community
*
* 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
* Foundation, and any use by you of this program is subject to the terms
* of such GNU license.
*
* A copy of the licence is included with the program, and can also be obtained
* from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __MALI_IOCTL_MIDGARD_H__
#define __MALI_IOCTL_MIDGARD_H__
#define MALI_IOCTL_TYPE_BASE 0x80
#define MALI_IOCTL_TYPE_MAX 0x82
union mali_ioctl_mem_alloc {
union mali_ioctl_header header;
struct {
/* [in] */
u64 va_pages;
u64 commit_pages;
u64 extent;
/* [in/out] */
u64 flags;
/* [out] */
mali_ptr gpu_va;
u16 va_alignment;
u32 :32;
u16 :16;
} inout;
} __attribute__((packed));
#define MALI_IOCTL_TYPE_COUNT (MALI_IOCTL_TYPE_MAX - MALI_IOCTL_TYPE_BASE + 1)
#define MALI_IOCTL_GET_VERSION (_IOWR(0x80, 0, struct mali_ioctl_get_version))
#define MALI_IOCTL_MEM_ALLOC (_IOWR(0x82, 0, union mali_ioctl_mem_alloc))
#define MALI_IOCTL_MEM_IMPORT (_IOWR(0x82, 1, struct mali_ioctl_mem_import))
#define MALI_IOCTL_MEM_COMMIT (_IOWR(0x82, 2, struct mali_ioctl_mem_commit))
#define MALI_IOCTL_MEM_QUERY (_IOWR(0x82, 3, struct mali_ioctl_mem_query))
#define MALI_IOCTL_MEM_FREE (_IOWR(0x82, 4, struct mali_ioctl_mem_free))
#define MALI_IOCTL_MEM_FLAGS_CHANGE (_IOWR(0x82, 5, struct mali_ioctl_mem_flags_change))
#define MALI_IOCTL_MEM_ALIAS (_IOWR(0x82, 6, struct mali_ioctl_mem_alias))
#define MALI_IOCTL_SYNC (_IOWR(0x82, 8, struct mali_ioctl_sync))
#define MALI_IOCTL_POST_TERM (_IOWR(0x82, 9, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_SETUP (_IOWR(0x82, 10, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_DUMP (_IOWR(0x82, 11, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_CLEAR (_IOWR(0x82, 12, __ioctl_placeholder))
#define MALI_IOCTL_GPU_PROPS_REG_DUMP (_IOWR(0x82, 14, struct mali_ioctl_gpu_props_reg_dump))
#define MALI_IOCTL_FIND_CPU_OFFSET (_IOWR(0x82, 15, __ioctl_placeholder))
#define MALI_IOCTL_GET_VERSION_NEW (_IOWR(0x82, 16, struct mali_ioctl_get_version))
#define MALI_IOCTL_SET_FLAGS (_IOWR(0x82, 18, struct mali_ioctl_set_flags))
#define MALI_IOCTL_SET_TEST_DATA (_IOWR(0x82, 19, __ioctl_placeholder))
#define MALI_IOCTL_INJECT_ERROR (_IOWR(0x82, 20, __ioctl_placeholder))
#define MALI_IOCTL_MODEL_CONTROL (_IOWR(0x82, 21, __ioctl_placeholder))
#define MALI_IOCTL_KEEP_GPU_POWERED (_IOWR(0x82, 22, __ioctl_placeholder))
#define MALI_IOCTL_FENCE_VALIDATE (_IOWR(0x82, 23, __ioctl_placeholder))
#define MALI_IOCTL_STREAM_CREATE (_IOWR(0x82, 24, struct mali_ioctl_stream_create))
#define MALI_IOCTL_GET_PROFILING_CONTROLS (_IOWR(0x82, 25, __ioctl_placeholder))
#define MALI_IOCTL_SET_PROFILING_CONTROLS (_IOWR(0x82, 26, __ioctl_placeholder))
#define MALI_IOCTL_DEBUGFS_MEM_PROFILE_ADD (_IOWR(0x82, 27, __ioctl_placeholder))
#define MALI_IOCTL_JOB_SUBMIT (_IOWR(0x82, 28, struct mali_ioctl_job_submit))
#define MALI_IOCTL_DISJOINT_QUERY (_IOWR(0x82, 29, __ioctl_placeholder))
#define MALI_IOCTL_GET_CONTEXT_ID (_IOWR(0x82, 31, struct mali_ioctl_get_context_id))
#define MALI_IOCTL_TLSTREAM_ACQUIRE_V10_4 (_IOWR(0x82, 32, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_TEST (_IOWR(0x82, 33, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_STATS (_IOWR(0x82, 34, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_FLUSH (_IOWR(0x82, 35, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_READER_SETUP (_IOWR(0x82, 36, __ioctl_placeholder))
#define MALI_IOCTL_SET_PRFCNT_VALUES (_IOWR(0x82, 37, __ioctl_placeholder))
#define MALI_IOCTL_SOFT_EVENT_UPDATE (_IOWR(0x82, 38, __ioctl_placeholder))
#define MALI_IOCTL_MEM_JIT_INIT (_IOWR(0x82, 39, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_ACQUIRE (_IOWR(0x82, 40, __ioctl_placeholder))
#endif /* __MALI_IOCTL_MIDGARD_H__ */
......@@ -20,6 +20,8 @@
#ifndef __MALI_IOCTL_H__
#define __MALI_IOCTL_H__
//#define dvalin
#include <panloader-util.h>
typedef u8 mali_atom_id;
......@@ -572,12 +574,16 @@ enum mali_error {
* Header used by all ioctls
*/
union mali_ioctl_header {
#ifdef dvalin
u32 pad[0];
#else
/* [in] The ID of the UK function being called */
u32 id :32;
/* [out] The return value of the UK function that was called */
enum mali_error rc :32;
u64 :64;
#endif
} __attribute__((packed));
struct mali_ioctl_get_version {
......@@ -587,22 +593,6 @@ struct mali_ioctl_get_version {
u32 :32;
} __attribute__((packed));
struct mali_ioctl_mem_alloc {
union mali_ioctl_header header;
/* [in] */
u64 va_pages;
u64 commit_pages;
u64 extent;
/* [in/out] */
u64 flags;
/* [out] */
mali_ptr gpu_va;
u16 va_alignment;
u32 :32;
u16 :16;
} __attribute__((packed));
struct mali_mem_import_user_buffer {
u64 ptr;
u64 length;
......@@ -731,47 +721,10 @@ typedef struct {
union mali_ioctl_header header;
} __ioctl_placeholder;
#define MALI_IOCTL_TYPE_BASE 0x80
#define MALI_IOCTL_TYPE_MAX 0x82
#define MALI_IOCTL_TYPE_COUNT (MALI_IOCTL_TYPE_MAX - MALI_IOCTL_TYPE_BASE + 1)
#define MALI_IOCTL_GET_VERSION (_IOWR(0x80, 0, struct mali_ioctl_get_version))
#define MALI_IOCTL_MEM_ALLOC (_IOWR(0x82, 0, struct mali_ioctl_mem_alloc))
#define MALI_IOCTL_MEM_IMPORT (_IOWR(0x82, 1, struct mali_ioctl_mem_import))
#define MALI_IOCTL_MEM_COMMIT (_IOWR(0x82, 2, struct mali_ioctl_mem_commit))
#define MALI_IOCTL_MEM_QUERY (_IOWR(0x82, 3, struct mali_ioctl_mem_query))
#define MALI_IOCTL_MEM_FREE (_IOWR(0x82, 4, struct mali_ioctl_mem_free))
#define MALI_IOCTL_MEM_FLAGS_CHANGE (_IOWR(0x82, 5, struct mali_ioctl_mem_flags_change))
#define MALI_IOCTL_MEM_ALIAS (_IOWR(0x82, 6, struct mali_ioctl_mem_alias))
#define MALI_IOCTL_SYNC (_IOWR(0x82, 8, struct mali_ioctl_sync))
#define MALI_IOCTL_POST_TERM (_IOWR(0x82, 9, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_SETUP (_IOWR(0x82, 10, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_DUMP (_IOWR(0x82, 11, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_CLEAR (_IOWR(0x82, 12, __ioctl_placeholder))
#define MALI_IOCTL_GPU_PROPS_REG_DUMP (_IOWR(0x82, 14, struct mali_ioctl_gpu_props_reg_dump))
#define MALI_IOCTL_FIND_CPU_OFFSET (_IOWR(0x82, 15, __ioctl_placeholder))
#define MALI_IOCTL_GET_VERSION_NEW (_IOWR(0x82, 16, struct mali_ioctl_get_version))
#define MALI_IOCTL_SET_FLAGS (_IOWR(0x82, 18, struct mali_ioctl_set_flags))
#define MALI_IOCTL_SET_TEST_DATA (_IOWR(0x82, 19, __ioctl_placeholder))
#define MALI_IOCTL_INJECT_ERROR (_IOWR(0x82, 20, __ioctl_placeholder))
#define MALI_IOCTL_MODEL_CONTROL (_IOWR(0x82, 21, __ioctl_placeholder))
#define MALI_IOCTL_KEEP_GPU_POWERED (_IOWR(0x82, 22, __ioctl_placeholder))
#define MALI_IOCTL_FENCE_VALIDATE (_IOWR(0x82, 23, __ioctl_placeholder))
#define MALI_IOCTL_STREAM_CREATE (_IOWR(0x82, 24, struct mali_ioctl_stream_create))
#define MALI_IOCTL_GET_PROFILING_CONTROLS (_IOWR(0x82, 25, __ioctl_placeholder))
#define MALI_IOCTL_SET_PROFILING_CONTROLS (_IOWR(0x82, 26, __ioctl_placeholder))
#define MALI_IOCTL_DEBUGFS_MEM_PROFILE_ADD (_IOWR(0x82, 27, __ioctl_placeholder))
#define MALI_IOCTL_JOB_SUBMIT (_IOWR(0x82, 28, struct mali_ioctl_job_submit))
#define MALI_IOCTL_DISJOINT_QUERY (_IOWR(0x82, 29, __ioctl_placeholder))
#define MALI_IOCTL_GET_CONTEXT_ID (_IOWR(0x82, 31, struct mali_ioctl_get_context_id))
#define MALI_IOCTL_TLSTREAM_ACQUIRE_V10_4 (_IOWR(0x82, 32, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_TEST (_IOWR(0x82, 33, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_STATS (_IOWR(0x82, 34, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_FLUSH (_IOWR(0x82, 35, __ioctl_placeholder))
#define MALI_IOCTL_HWCNT_READER_SETUP (_IOWR(0x82, 36, __ioctl_placeholder))
#define MALI_IOCTL_SET_PRFCNT_VALUES (_IOWR(0x82, 37, __ioctl_placeholder))
#define MALI_IOCTL_SOFT_EVENT_UPDATE (_IOWR(0x82, 38, __ioctl_placeholder))
#define MALI_IOCTL_MEM_JIT_INIT (_IOWR(0x82, 39, __ioctl_placeholder))
#define MALI_IOCTL_TLSTREAM_ACQUIRE (_IOWR(0x82, 40, __ioctl_placeholder))
#ifdef dvalin
#include <mali-ioctl-dvalin.h>
#else
#include <mali-ioctl-midgard.h>
#endif
#endif /* __MALI_IOCTL_H__ */
......@@ -259,6 +259,4 @@ struct mali_ioctl_gpu_props_reg_dump {
struct mali_gpu_coherent_group_info coherency_info;
} __attribute__((packed));
#define MALI_IOCTL_GPU_PROPS_REG_DUMP (_IOWR(0x82, 14, struct mali_ioctl_gpu_props_reg_dump))
#endif
......@@ -66,8 +66,10 @@ static struct device_info mali_info = {
.info = {
IOCTL_TYPE(0x80) {
IOCTL_INFO(GET_VERSION),
#ifndef dvalin
},
IOCTL_TYPE(0x82) {
#endif
IOCTL_INFO(MEM_ALLOC),
IOCTL_INFO(MEM_IMPORT),
IOCTL_INFO(MEM_COMMIT),
......@@ -76,35 +78,11 @@ static struct device_info mali_info = {
IOCTL_INFO(MEM_FLAGS_CHANGE),
IOCTL_INFO(MEM_ALIAS),
IOCTL_INFO(SYNC),
IOCTL_INFO(POST_TERM),
IOCTL_INFO(HWCNT_SETUP),
IOCTL_INFO(HWCNT_DUMP),
IOCTL_INFO(HWCNT_CLEAR),
#ifndef dvalin
IOCTL_INFO(GPU_PROPS_REG_DUMP),
IOCTL_INFO(FIND_CPU_OFFSET),
IOCTL_INFO(GET_VERSION_NEW),
IOCTL_INFO(SET_FLAGS),
IOCTL_INFO(SET_TEST_DATA),
IOCTL_INFO(INJECT_ERROR),
IOCTL_INFO(MODEL_CONTROL),
IOCTL_INFO(KEEP_GPU_POWERED),
IOCTL_INFO(FENCE_VALIDATE),
IOCTL_INFO(STREAM_CREATE),
IOCTL_INFO(GET_PROFILING_CONTROLS),
IOCTL_INFO(SET_PROFILING_CONTROLS),
IOCTL_INFO(DEBUGFS_MEM_PROFILE_ADD),
#endif
IOCTL_INFO(JOB_SUBMIT),
IOCTL_INFO(DISJOINT_QUERY),
IOCTL_INFO(GET_CONTEXT_ID),
IOCTL_INFO(TLSTREAM_ACQUIRE_V10_4),
IOCTL_INFO(TLSTREAM_TEST),
IOCTL_INFO(TLSTREAM_STATS),
IOCTL_INFO(TLSTREAM_FLUSH),
IOCTL_INFO(HWCNT_READER_SETUP),
IOCTL_INFO(SET_PRFCNT_VALUES),
IOCTL_INFO(SOFT_EVENT_UPDATE),
IOCTL_INFO(MEM_JIT_INIT),
IOCTL_INFO(TLSTREAM_ACQUIRE),
},
},
};
......@@ -206,6 +184,11 @@ int ioctl(int fd, int _request, ...)
int ret;
void *ptr;
#ifdef dvalin
if (request & 0x0F00)
ioc_size = 1;
#endif
if (ioc_size) {
va_list args;
......@@ -233,15 +216,36 @@ int ioctl(int fd, int _request, ...)
replay_memory();
}
mali_ptr alloc_va_pages = 0;
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_MEM_ALLOC)) {
const union mali_ioctl_mem_alloc *args = ptr;
#ifdef dvalin
alloc_va_pages = args->in.va_pages;
#else
alloc_va_pages = args->inout.va_pages;
#endif
}
ret = orig_ioctl(fd, request, ptr);
/* Track memory allocation if needed */
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_MEM_ALLOC)) {
const struct mali_ioctl_mem_alloc *args = ptr;
const union mali_ioctl_mem_alloc *args = ptr;
#ifdef dvalin
mali_ptr va = args->out.gpu_va;
u64 flags = args->out.flags;
#else
mali_ptr va = args->inout.gpu_va;
u64 flags = args->inout.flags;
#endif
panwrap_track_allocation(args->gpu_va, args->flags, allocation_number++, args->va_pages * 4096);
panwrap_track_allocation(va, flags, allocation_number++, alloc_va_pages * 4096);
}
#ifndef dvalin
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_GPU_PROPS_REG_DUMP)) {
const struct mali_ioctl_gpu_props_reg_dump *dump = ptr;
unsigned product_id = dump->core.product_id;
......@@ -249,6 +253,9 @@ int ioctl(int fd, int _request, ...)
if (product_id >> 12 == 6 && product_id != 0x6956 /* T60x */)
bifrost = true;
}
#else
bifrost = true;
#endif
UNLOCK();
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment