Commit e12cb796 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Merge branch 'tomeu-rebased' into 'master'

Lyude+tomeu's changes: new kernel ABI, no more slowfb, actual winsys

See merge request !12
parents 6f9a6e4b ab68601c
......@@ -1879,6 +1879,8 @@ typedef struct __DRIDriverVtableExtensionRec {
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)
#define __DRI2_RENDERER_EXPOSE_BUFFER_AGE 0x000e
typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
struct __DRI2rendererQueryExtensionRec {
__DRIextension base;
......
......@@ -692,6 +692,9 @@ dri2_setup_screen(_EGLDisplay *disp)
if (dri2_dpy->flush_control)
disp->Extensions.KHR_context_flush_control = EGL_TRUE;
disp->Extensions.EXT_buffer_age =
dri2_renderer_query_integer(dri2_dpy, __DRI2_RENDERER_EXPOSE_BUFFER_AGE);
}
void
......
......@@ -1583,7 +1583,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
disp->Extensions.ANDROID_framebuffer_target = EGL_TRUE;
disp->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
disp->Extensions.ANDROID_recordable = EGL_TRUE;
disp->Extensions.EXT_buffer_age = EGL_TRUE;
#if ANDROID_API_LEVEL >= 23
disp->Extensions.KHR_partial_update = EGL_TRUE;
#endif
......
......@@ -780,8 +780,8 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
}
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
if (dri2_dpy->dri2)
disp->Extensions.EXT_buffer_age = EGL_TRUE;
if (!dri2_dpy->dri2)
disp->Extensions.EXT_buffer_age = EGL_FALSE;
#ifdef HAVE_WAYLAND_PLATFORM
dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
......
......@@ -1478,8 +1478,6 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
if (!dri2_dpy->is_different_gpu)
disp->Extensions.WL_create_wayland_buffer_from_image = EGL_TRUE;
disp->Extensions.EXT_buffer_age = EGL_TRUE;
disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
/* Fill vtbl last to prevent accidentally calling virtual function during
......
......@@ -1402,7 +1402,6 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay *disp)
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
disp->Extensions.EXT_buffer_age = EGL_TRUE;
dri2_set_WL_bind_wayland_display(drv, disp);
......
......@@ -520,7 +520,12 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
*value = surface->PostSubBufferSupportedNV;
break;
case EGL_BUFFER_AGE_EXT:
if (!dpy->Extensions.EXT_buffer_age)
/* EGL_BUFFER_AGE_EXT belong to EGL_EXT_buffer_age
* EGL_BUFFER_AGE_KHR belong to EGL_KHR_partial_update
* but EGL_BUFFER_AGE_EXT == EGL_BUFFER_AGE_KHR by value
*/
if (!dpy->Extensions.EXT_buffer_age &&
!dpy->Extensions.KHR_partial_update)
return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
_EGLContext *ctx = _eglGetCurrentContext();
......
......@@ -379,7 +379,7 @@ pipe_etna_create_screen(int fd, const struct pipe_screen_config *config)
#endif
#if 0
#ifdef GALLIUM_PANFROST
#include "panfrost/drm/panfrost_drm_public.h"
struct pipe_screen *
......
......@@ -327,6 +327,9 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
case PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET:
return 2047;
case PIPE_CAP_BUFFER_AGE:
return 1;
case PIPE_CAP_SURFACE_SAMPLE_COUNT:
return 0;
......
......@@ -477,6 +477,7 @@ subpixel precision bias in bits during conservative rasterization.
0 means no limit.
* ``PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET``: The maximum supported value for
of pipe_vertex_element::src_offset.
* ``PIPE_CAP_BUFFER_AGE``: True if the driver wants to expose EGL/GLX_EXT_buffer_age.
* ``PIPE_CAP_SURFACE_SAMPLE_COUNT_TEXTURE``: Whether the driver
supports pipe_surface overrides of resource nr_samples. If set, will
enable EXT_multisampled_render_to_texture.
......
This diff is collapsed.
This diff is collapsed.
/*
*
* (C) COPYRIGHT 2010-2014 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
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can access it online at
* http://www.gnu.org/licenses/gpl-2.0.html.
*
* SPDX-License-Identifier: GPL-2.0
*
*/
#ifndef _BASE_MEM_PRIV_H_
#define _BASE_MEM_PRIV_H_
#define BASE_SYNCSET_OP_MSYNC (1U << 0)
#define BASE_SYNCSET_OP_CSYNC (1U << 1)
/*
* This structure describe a basic memory coherency operation.
* It can either be:
* @li a sync from CPU to Memory:
* - type = ::BASE_SYNCSET_OP_MSYNC
* - mem_handle = a handle to the memory object on which the operation
* is taking place
* - user_addr = the address of the range to be synced
* - size = the amount of data to be synced, in bytes
* - offset is ignored.
* @li a sync from Memory to CPU:
* - type = ::BASE_SYNCSET_OP_CSYNC
* - mem_handle = a handle to the memory object on which the operation
* is taking place
* - user_addr = the address of the range to be synced
* - size = the amount of data to be synced, in bytes.
* - offset is ignored.
*/
struct basep_syncset {
base_mem_handle mem_handle;
u64 user_addr;
u64 size;
u8 type;
u8 padding[7];
};
#endif
/*
*
* (C) COPYRIGHT 2015-2018 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
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can access it online at
* http://www.gnu.org/licenses/gpl-2.0.html.
*
* SPDX-License-Identifier: GPL-2.0
*
*/
#ifndef _KBASE_GPU_ID_H_
#define _KBASE_GPU_ID_H_
/* GPU_ID register */
#define GPU_ID_VERSION_STATUS_SHIFT 0
#define GPU_ID_VERSION_MINOR_SHIFT 4
#define GPU_ID_VERSION_MAJOR_SHIFT 12
#define GPU_ID_VERSION_PRODUCT_ID_SHIFT 16
#define GPU_ID_VERSION_STATUS (0xFu << GPU_ID_VERSION_STATUS_SHIFT)
#define GPU_ID_VERSION_MINOR (0xFFu << GPU_ID_VERSION_MINOR_SHIFT)
#define GPU_ID_VERSION_MAJOR (0xFu << GPU_ID_VERSION_MAJOR_SHIFT)
#define GPU_ID_VERSION_PRODUCT_ID (0xFFFFu << GPU_ID_VERSION_PRODUCT_ID_SHIFT)
/* Values for GPU_ID_VERSION_PRODUCT_ID bitfield */
#define GPU_ID_PI_T60X 0x6956u
#define GPU_ID_PI_T62X 0x0620u
#define GPU_ID_PI_T76X 0x0750u
#define GPU_ID_PI_T72X 0x0720u
#define GPU_ID_PI_TFRX 0x0880u
#define GPU_ID_PI_T86X 0x0860u
#define GPU_ID_PI_T82X 0x0820u
#define GPU_ID_PI_T83X 0x0830u
/* New GPU ID format when PRODUCT_ID is >= 0x1000 (and not 0x6956) */
#define GPU_ID_PI_NEW_FORMAT_START 0x1000
#define GPU_ID_IS_NEW_FORMAT(product_id) ((product_id) != GPU_ID_PI_T60X && \
(product_id) >= \
GPU_ID_PI_NEW_FORMAT_START)
#define GPU_ID2_VERSION_STATUS_SHIFT 0
#define GPU_ID2_VERSION_MINOR_SHIFT 4
#define GPU_ID2_VERSION_MAJOR_SHIFT 12
#define GPU_ID2_PRODUCT_MAJOR_SHIFT 16
#define GPU_ID2_ARCH_REV_SHIFT 20
#define GPU_ID2_ARCH_MINOR_SHIFT 24
#define GPU_ID2_ARCH_MAJOR_SHIFT 28
#define GPU_ID2_VERSION_STATUS (0xFu << GPU_ID2_VERSION_STATUS_SHIFT)
#define GPU_ID2_VERSION_MINOR (0xFFu << GPU_ID2_VERSION_MINOR_SHIFT)
#define GPU_ID2_VERSION_MAJOR (0xFu << GPU_ID2_VERSION_MAJOR_SHIFT)
#define GPU_ID2_PRODUCT_MAJOR (0xFu << GPU_ID2_PRODUCT_MAJOR_SHIFT)
#define GPU_ID2_ARCH_REV (0xFu << GPU_ID2_ARCH_REV_SHIFT)
#define GPU_ID2_ARCH_MINOR (0xFu << GPU_ID2_ARCH_MINOR_SHIFT)
#define GPU_ID2_ARCH_MAJOR (0xFu << GPU_ID2_ARCH_MAJOR_SHIFT)
#define GPU_ID2_PRODUCT_MODEL (GPU_ID2_ARCH_MAJOR | GPU_ID2_PRODUCT_MAJOR)
#define GPU_ID2_VERSION (GPU_ID2_VERSION_MAJOR | \
GPU_ID2_VERSION_MINOR | \
GPU_ID2_VERSION_STATUS)
/* Helper macro to create a partial GPU_ID (new format) that defines
a product ignoring its version. */
#define GPU_ID2_PRODUCT_MAKE(arch_major, arch_minor, arch_rev, product_major) \
((((u32)arch_major) << GPU_ID2_ARCH_MAJOR_SHIFT) | \
(((u32)arch_minor) << GPU_ID2_ARCH_MINOR_SHIFT) | \
(((u32)arch_rev) << GPU_ID2_ARCH_REV_SHIFT) | \
(((u32)product_major) << GPU_ID2_PRODUCT_MAJOR_SHIFT))
/* Helper macro to create a partial GPU_ID (new format) that specifies the
revision (major, minor, status) of a product */
#define GPU_ID2_VERSION_MAKE(version_major, version_minor, version_status) \
((((u32)version_major) << GPU_ID2_VERSION_MAJOR_SHIFT) | \
(((u32)version_minor) << GPU_ID2_VERSION_MINOR_SHIFT) | \
(((u32)version_status) << GPU_ID2_VERSION_STATUS_SHIFT))
/* Helper macro to create a complete GPU_ID (new format) */
#define GPU_ID2_MAKE(arch_major, arch_minor, arch_rev, product_major, \
version_major, version_minor, version_status) \
(GPU_ID2_PRODUCT_MAKE(arch_major, arch_minor, arch_rev, \
product_major) | \
GPU_ID2_VERSION_MAKE(version_major, version_minor, \
version_status))
/* Helper macro to create a partial GPU_ID (new format) that identifies
a particular GPU model by its arch_major and product_major. */
#define GPU_ID2_MODEL_MAKE(arch_major, product_major) \
((((u32)arch_major) << GPU_ID2_ARCH_MAJOR_SHIFT) | \
(((u32)product_major) << GPU_ID2_PRODUCT_MAJOR_SHIFT))
/* Strip off the non-relevant bits from a product_id value and make it suitable
for comparison against the GPU_ID2_PRODUCT_xxx values which identify a GPU
model. */
#define GPU_ID2_MODEL_MATCH_VALUE(product_id) \
((((u32)product_id) << GPU_ID2_PRODUCT_MAJOR_SHIFT) & \
GPU_ID2_PRODUCT_MODEL)
#define GPU_ID2_PRODUCT_TMIX GPU_ID2_MODEL_MAKE(6, 0)
#define GPU_ID2_PRODUCT_THEX GPU_ID2_MODEL_MAKE(6, 1)
#define GPU_ID2_PRODUCT_TSIX GPU_ID2_MODEL_MAKE(7, 0)
#define GPU_ID2_PRODUCT_TDVX GPU_ID2_MODEL_MAKE(7, 3)
#define GPU_ID2_PRODUCT_TNOX GPU_ID2_MODEL_MAKE(7, 1)
#define GPU_ID2_PRODUCT_TGOX GPU_ID2_MODEL_MAKE(7, 2)
#define GPU_ID2_PRODUCT_TKAX GPU_ID2_MODEL_MAKE(8, 0)
#define GPU_ID2_PRODUCT_TBOX GPU_ID2_MODEL_MAKE(8, 2)
#define GPU_ID2_PRODUCT_TEGX GPU_ID2_MODEL_MAKE(8, 3)
#define GPU_ID2_PRODUCT_TTRX GPU_ID2_MODEL_MAKE(9, 0)
#define GPU_ID2_PRODUCT_TNAX GPU_ID2_MODEL_MAKE(9, 1)
#define GPU_ID2_PRODUCT_TULX GPU_ID2_MODEL_MAKE(10, 0)
#define GPU_ID2_PRODUCT_TDUX GPU_ID2_MODEL_MAKE(10, 1)
#define GPU_ID2_PRODUCT_TIDX GPU_ID2_MODEL_MAKE(10, 3)
#define GPU_ID2_PRODUCT_TVAX GPU_ID2_MODEL_MAKE(10, 4)
/* Values for GPU_ID_VERSION_STATUS field for PRODUCT_ID GPU_ID_PI_T60X */
#define GPU_ID_S_15DEV0 0x1
#define GPU_ID_S_EAC 0x2
/* Helper macro to create a GPU_ID assuming valid values for id, major,
minor, status */
#define GPU_ID_MAKE(id, major, minor, status) \
((((u32)id) << GPU_ID_VERSION_PRODUCT_ID_SHIFT) | \
(((u32)major) << GPU_ID_VERSION_MAJOR_SHIFT) | \
(((u32)minor) << GPU_ID_VERSION_MINOR_SHIFT) | \
(((u32)status) << GPU_ID_VERSION_STATUS_SHIFT))
#endif /* _KBASE_GPU_ID_H_ */
/*
*
* (C) COPYRIGHT 2015 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
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can access it online at
* http://www.gnu.org/licenses/gpl-2.0.html.
*
* SPDX-License-Identifier: GPL-2.0
*
*/
#ifndef _MIDG_COHERENCY_H_
#define _MIDG_COHERENCY_H_
#define COHERENCY_ACE_LITE 0
#define COHERENCY_ACE 1
#define COHERENCY_NONE 31
#define COHERENCY_FEATURE_BIT(x) (1 << (x))
#endif /* _MIDG_COHERENCY_H_ */
kbase_conf_data = configuration_data()
kbase_conf_data.set('PAGE_SHIFT', cc.run('''
#include <unistd.h>
#include <stdio.h>
#include <math.h>
int main() {
printf("%.0f", log2f(sysconf(_SC_PAGESIZE)));
return 0;
}''', dependencies : dep_m).stdout(),
name : 'PAGE_SHIFT')
configure_file(output : 'panfrost-mali-base.h',
input : 'panfrost-mali-base.h.meson.in',
configuration : kbase_conf_data)
This diff is collapsed.
......@@ -27,7 +27,8 @@
#ifndef __PANFROST_JOB_H__
#define __PANFROST_JOB_H__
#include <panfrost-ioctl.h>
#include <stdint.h>
#include <panfrost-misc.h>
#define T8XX
......@@ -37,6 +38,18 @@
#define MALI_PAYLOAD_SIZE 256
/**
* @brief Job chain hardware requirements.
*
* A job chain must specify what GPU features it needs to allow the
* driver to schedule the job correctly. By not specifying the
* correct settings can/will cause an early job termination. Multiple
* values can be ORed together to specify multiple requirements.
* Special case is ::MALI_JD_REQ_DEP, which is used to express complex
* dependencies, and that doesn't execute anything on the hardware.
*/
typedef u32 mali_jd_core_req;
enum mali_job_type {
JOB_NOT_STARTED = 0,
JOB_TYPE_NULL = 1,
......
/*
* © Copyright 2018 Alyssa Rosenzweig
* © Copyright 2017-2018 The Panfrost Community
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......@@ -20,17 +20,25 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* The bridge between our world, and ARM's. For the *_base_* headers, anyway.
*
*/
#ifndef __SLOW_FRAMEBUFFER_H__
#define __SLOW_FRAMEBUFFER_H__
#ifndef PANFROST_MALI_BASE_H
#define PANFROST_MALI_BASE_H
#include <assert.h>
#include <stddef.h>
#include <util/macros.h>
#include <panfrost-misc.h>
#define KBASE_DEBUG_ASSERT assert
struct slowfb_info {
uint8_t *framebuffer;
int stride;
};
#mesondefine PAGE_SHIFT
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
struct slowfb_info slowfb_init(uint8_t *framebuffer, int width, int height);
void slowfb_update(uint8_t *framebuffer, int width, int height);
#include <mali_base_kernel.h>
#endif /* __SLOW_FRAMEBUFFER_H__ */
#endif /* !PANFROST_MALI_BASE_H */
......@@ -22,8 +22,8 @@
*
*/
#ifndef __PANFROST_INT_H__
#define __PANFROST_INT_H__
#ifndef __PANFROST_MISC_H__
#define __PANFROST_MISC_H__
#include <inttypes.h>
......@@ -37,4 +37,11 @@ typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef uintptr_t mali_ptr;
#define MALI_PTR_FMT "0x%" PRIx64
/* FIXME: put this somewhere more fitting */
#define MALI_MEM_MAP_TRACKING_HANDLE (3ull << 12)
#endif
......@@ -36,13 +36,24 @@ files_panfrost = files(
'pan_nondrm.c',
'pan_allocate.c',
'pan_assemble.c',
'pan_slowfb.c',
'pan_swizzle.c',
'pan_blending.c',
'pan_blend_shaders.c',
'pan_wallpaper.c',
)
inc_panfrost = [
inc_common,
inc_gallium,
inc_gallium_aux,
inc_drm_uapi,
inc_include,
inc_src,
include_directories('midgard'),
include_directories('bifrost'),
include_directories('include')
]
midgard_nir_algebraic_c = custom_target(
'midgard_nir_algebraic.c',
input : 'midgard/midgard_nir_algebraic.py',
......@@ -64,16 +75,7 @@ libpanfrost = static_library(
dep_thread,
idep_nir
],
include_directories : [
inc_common,
inc_gallium_aux,
inc_gallium,
inc_include,
inc_src,
include_directories('midgard'),
include_directories('bifrost'),
include_directories('include')
],
include_directories : inc_panfrost,
c_args : [c_vis_args, c_msvc_compat_args],
)
......@@ -98,14 +100,7 @@ files_bifrost = files(
midgard_compiler = executable(
'midgard_compiler',
[files_midgard, midgard_nir_algebraic_c],
include_directories : [
inc_common,
inc_src,
inc_include,
inc_gallium,
inc_gallium_aux,
include_directories('midgard')
],
include_directories : inc_panfrost,
dependencies : [
dep_thread,
idep_nir
......@@ -141,4 +136,5 @@ bifrost_compiler = executable(
build_by_default : true
)
subdir('include')
subdir('panwrap')
......@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <panfrost-misc.h>
#include <panfrost-job.h>
#include "pan_context.h"
#include "pan_nondrm.h"
......
This diff is collapsed.
......@@ -98,8 +98,6 @@ struct panfrost_context {
/* Gallium context */
struct pipe_context base;
/* TODO: DRM driver? */
int fd;
struct pipe_framebuffer_state pipe_framebuffer;
/* The number of concurrent FBOs allowed depends on the number of pools
......@@ -113,7 +111,6 @@ struct panfrost_context {
struct panfrost_memory scratchpad;
struct panfrost_memory tiler_heap;
struct panfrost_memory varying_mem;
struct panfrost_memory framebuffer;
struct panfrost_memory misc_0;
struct panfrost_memory misc_1;
struct panfrost_memory depth_stencil_buffer;
......@@ -125,8 +122,6 @@ struct panfrost_context {
unsigned stencil;
} last_clear;
int scanout_stride;
/* Each render job has multiple framebuffer descriptors associated with
* it, used for various purposes with more or less the same format. The
* most obvious is the fragment framebuffer descriptor, which carries
......@@ -303,9 +298,32 @@ struct panfrost_sampler_view {
struct sw_displaytarget;
struct panfrost_bo {
//struct panfrost_device *dev;
uint32_t size;
uint32_t handle;
uint32_t name;
int32_t refcnt;
uint64_t iova;
void *map;
//const struct fd_bo_funcs *funcs;
enum {
NO_CACHE = 0,
BO_CACHE = 1,
RING_CACHE = 2,
} bo_reuse;
//struct list_head list; /* bucket-list entry */
time_t free_time; /* time when added to bucket-list */
};
struct panfrost_resource {
struct pipe_resource base;
struct panfrost_bo *bo;
struct renderonly_scanout *scanout;
/* Address to the resource in question */
uint8_t *cpu[MAX_MIP_LEVELS];
......@@ -322,12 +340,6 @@ struct panfrost_resource {
/* Is something other than level 0 ever written? */
bool is_mipmap;
/* Valid for textures; 1 otherwise */
int bytes_per_pixel;
/* bytes_per_pixel*width + padding */
int stride;
struct sw_displaytarget *dt;
/* Set for tiled, clear for linear. For linear, set if directly mapped and clear for memcpy */
......@@ -354,6 +366,18 @@ panfrost_context(struct pipe_context *pcontext)
return (struct panfrost_context *) pcontext;
}
static inline struct panfrost_resource *
pan_resource(struct pipe_resource *p)
{
return (struct panfrost_resource *)p;
}
static inline struct panfrost_screen *
pan_screen(struct pipe_screen *p)
{
return (struct panfrost_screen *)p;
}
struct pipe_context *
panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
......
......@@ -29,77 +29,93 @@
#include <sys/mman.h>
#include <assert.h>
#include <panfrost-ioctl.h>
#include <mali-kbase-ioctl.h>
#include <panfrost-misc.h>
#include "pan_nondrm.h"
/* From the kernel module */
#define USE_LEGACY_KERNEL
#define MALI_MEM_MAP_TRACKING_HANDLE (3ull << 12)
#define BASE_MEM_MAP_TRACKING_HANDLE (3ull << 12)
int
pandev_ioctl(int fd, unsigned long request, void *args)
{
union mali_ioctl_header *h = args;
h->id = ((_IOC_TYPE(request) & 0xF) << 8) | _IOC_NR(request);
return ioctl(fd, request, args);
}
int
pandev_general_allocate(int fd, int va_pages, int commit_pages, int extent, int flags, u64 *out)
pandev_general_allocate(int fd, int va_pages, int commit_pages,
int extent, int flags,
u64 *out, int *out_flags)
{
struct mali_ioctl_mem_alloc args = {
.va_pages = va_pages,
.commit_pages = commit_pages,
.extent = extent,
.flags = flags
int ret;
union kbase_ioctl_mem_alloc args = {
.in.va_pages = va_pages,
.in.commit_pages = commit_pages,
.in.extent = extent,
.in.flags = flags,
};
if (pandev_ioctl(fd, MALI_IOCTL_MEM_ALLOC, &args) != 0) {
perror("pandev_ioctl MALI_IOCTL_MEM_ALLOC");
ret = ioctl(fd, KBASE_IOCTL_MEM_ALLOC, &args);
if (ret) {
fprintf(stderr, "panfrost: Failed to allocate memory, va_pages=%d commit_pages=%d extent=%d flags=0x%x rc=%d\n",
va_pages, commit_pages, extent, flags, ret);
abort();
}
*out = args.gpu_va;
*out = args.out.gpu_va;
*out_flags = args.out.flags;
return 0;
}
int
pandev_standard_allocate(int fd, int va_pages, int flags, u64 *out)
pandev_standard_allocate(int fd, int va_pages, int flags,
u64 *out, int *out_flags)
{
return pandev_general_allocate(fd, va_pages, va_pages, 0, flags, out);
return pandev_general_allocate(fd, va_pages, va_pages, 0, flags, out,
out_flags);
}
/* XXX: This is kind of a hack, but pandev_open can be called more than
* once (e.g. in glmark2-es2-drm), which messes up the kernel. So, do some
* basic state tracking */
bool fd_already_opened = false;
int
pandev_open()
pandev_open(int fd)
{
int fd = open("/dev/mali0", O_RDWR | O_CLOEXEC);
assert(fd != -1);
if (fd_already_opened) {
/* Spurious */
return fd;
}
#ifdef USE_LEGACY_KERNEL
struct mali_ioctl_get_version version = { .major = 10, .minor = 4 };
struct mali_ioctl_set_flags args = {};
if (pandev_ioctl(fd, MALI_IOCTL_GET_VERSION, &version) != 0) {
perror("pandev_ioctl: MALI_IOCTL_GET_VERSION");
struct kbase_ioctl_version_check version = { .major = 11, .minor = 11 };
struct kbase_ioctl_set_flags set_flags = {};
int ret;
ret = ioctl(fd, KBASE_IOCTL_VERSION_CHECK, &version);
if (ret != 0) {
fprintf(stderr, "Version check failed with %d (reporting UK %d.%d)\n",
ret, version.major, version.minor);
abort();
}
printf("panfrost: Using kbase UK version %d.%d, fd %d\n", version.major, version.minor, fd);
printf("(%d, %d)\n", version.major, version.minor);
if (mmap(NULL, 4096, PROT_NONE, MAP_SHARED, fd, MALI_MEM_MAP_TRACKING_HANDLE) == MAP_FAILED) {
if (mmap(NULL, 4096, PROT_NONE, MAP_SHARED, fd,