Hi!

For those drivers that for whatever reason will not be using GEM but interface directly to the TTM code, I've made a suggestion for
a new user-space interface. The header files are attached to the mail.

The idea here is that a driver wanting to use this interface includes
one or more of these header files in the <driver>_drm.h file, and
implements the IOCTLS as driver-specific code.
The ioctl numbers are given as offsets, and the user-space code needs to
query the driver for the base numbers.

User-space fencing is completely decoupled from buffer management.

mapping write and read will be done using the standard fs calls,
each buffer object will, as before, occupy a part of the linear drm fd
address space which (even on 32-bit systems) is 48 bits wide.
The create- and reference ioctls return the address space offsets for the buffers.

Execbuf and similar ioctls will be completely driver specific.

I anticipate no code for this to live in drm core. The vm code will use
the driver vm hooks and detect legacy drm maps and forward those calls
to the drm vm subsystem.

/Thomas


/**************************************************************************
 *
 * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 **************************************************************************/
/*
 * Authors
 * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
 */

#ifndef TTM_FENCE_USER_H
#define TTM_FENCE_USER_H

#if !defined(__KERNEL__) && !defined(_KERNEL)
#include <stdint.h>
#endif

#define TTM_FENCE_MAJOR 0
#define TTM_FENCE_MINOR 1
#define TTM_FENCE_PL    0
#define TTM_FENCE_DATE  "080819"

/**
 * union ttm_fence_signaled_arg
 * 
 * @handle: Handle to the fence object. Input.
 *
 * @fence_type: Fence types we want to flush. Input.
 *
 * @flush: Boolean. Flush the indicated fence_types. Input.
 *
 * @signaled_types: Fence type that has signaled. Output.
 *
 * Argument to the TTM_FENCE_SIGNALED ioctl.
 */

union ttm_fence_signaled_arg {
        struct {
                uint32_t handle;
                uint32_t fence_type;
                int32_t  flush;
                uint32_t pad64;
        } req;
        uint32_t signaled_types;
};

/*
 * Waiting mode flags for the TTM_FENCE_FINISH ioctl.
 * 
 * TTM_FENCE_FINISH_MODE_LAZY: Allow for sleeps during polling
 * wait.
 *
 * TTM_FENCE_FINISH_MODE_NO_BLOCK: Don't block waiting for GPU, 
 * but return -EBUSY if the buffer is busy.
 */


#define TTM_FENCE_FINISH_MODE_LAZY     (1 << 0)
#define TTM_FENCE_FINISH_MODE_NO_BLOCK (1 << 1)

/**
 * struct ttm_fence_finish_arg
 * 
 * @handle: Handle to the fence object. Input.
 *
 * @fence_type: Fence types we want to finish.
 *
 * @mode: Wait mode.
 *
 * Argument to the TTM_FENCE_FINISH ioctl.
 */

struct ttm_fence_finish_arg {
        uint32_t handle;
        uint32_t fence_type;
        uint32_t mode;
        uint32_t pad64;
};

/**
 * struct ttm_fence_unref_arg
 * 
 * @handle: Handle to the fence object.
 *
 * Argument to the TTM_FENCE_UNREF ioctl.
 */

struct ttm_fence_unref_arg {
        uint32_t handle;
        uint32_t pad64;
};

/*
 * Ioctl offsets frome extenstion start.
 */

#define TTM_FENCE_SIGNALED 0x01
#define TTM_FENCE_FINISH   0x02
#define TTM_FENCE_UNREF    0x03

#endif
/**************************************************************************
 *
 * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 **************************************************************************/
/*
 * Authors
 * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
 */

#ifndef _TTM_PLACEMENT_USER_H_
#define _TTM_PLACEMENT_USER_H_

#if !defined(__KERNEL__) && !defined(_KERNEL)
#include <stdint.h>
#endif

#define TTM_PLACEMENT_MAJOR 0
#define TTM_PLACEMENT_MINOR 1
#define TTM_PLACEMENT_PL    0
#define TTM_PLACEMENT_DATE  "080819"

/*
 * Memory regions for data placement.
 */

#define TTM_PL_FLAG_SYSTEM      (1 << 0)
#define TTM_PL_FLAG_TT          (1 << 1)
#define TTM_PL_FLAG_VRAM        (1 << 2)
#define TTM_PL_FLAG_PRIV0       (1 << 3)
#define TTM_PL_FLAG_SWAPPED     (1 << 15)
#define TTM_PL_MASK_MEM         0x0000FFFF

/*
 * Other flags that affects data placement.
 * TTM_PL_FLAG_CACHED indicates cache-coherent mappings 
 * if available.
 * TTM_PL_FLAG_SHARED means that another application may 
 * reference the buffer.
 * TTM_PL_FLAG_NO_EVICT means that the buffer may never
 * be evicted to make room for other buffers. 
 */

#define TTM_PL_FLAG_CACHED      (1 << 16)
#define TTM_PL_FLAG_SHARED      (1 << 17)
#define TTM_PL_FLAG_NO_EVICT    (1 << 18)

/*
 * Access flags to be used for CPU- and GPU- mappings.
 * The idea is that the TTM synchronization mechanism will
 * allow concurrent READ access and exclusive write access.
 * Currently GPU- and CPU accesses are exclusive.
 */

#define TTM_ACCESS_READ         (1 << 0)
#define TTM_ACCESS_WRITE        (1 << 1)

/**
 * struct ttm_bo_create_req 
 *
 * @size: The buffer object size.
 * @placement: Flags that indicate initial acceptable 
 *  placement.
 * @page_alignment: Required alignment in pages.
 *
 * Input to the TTM_BO_CREATE ioctl.
 */


struct ttm_bo_create_req {
        uint64_t size;
        uint32_t placement;
        uint32_t page_alignment;
};

/**
 * struct ttm_bo_rep
 *
 * @gpu_offset: The current offset into the memory region used. 
 * This can be used directly by the GPU if there are no 
 * additional GPU mapping procedures used by the driver.
 *
 * @bo_size: Actual buffer object size.
 *
 * @map_handle: Offset into the device address space. 
 * Used for map, seek, read, write. This will never change
 * during the lifetime of an object.
 *
 * @placement: Flag indicating the placement status of
 * the buffer object using the TTM_PL flags above.
 *
 * @sync_object_arg: Used for user-space synchronization and
 * depends on the synchronization model used. If fences are
 * used, this is the buffer_object::fence_type_mask
 *
 * Output from the TTM_BO_CREATE and TTM_BO_REFERENCE, and
 * TTM_BO_SETSTATUS ioctls.
 */ 
 
struct ttm_bo_rep {
        uint64_t gpu_offset;
        uint64_t bo_size;
        uint64_t map_handle;
        uint32_t placement;
        uint32_t handle;
        uint32_t sync_object_arg;
        uint32_t pad64;
};

/**
 * struct ttm_setstatus_req
 *
 * @set_placement: Placement flags to set.
 *
 * @clr_placement: Placement flags to clear.
 *
 * @handle: The object handle
 *
 * Input to the TTM_BO_SETSTATUS ioctl.
 */ 

struct ttm_setstatus_req {
        uint32_t set_placement;
        uint32_t clr_placement;
        uint32_t handle;
        uint32_t pad64;
};

/**
 * struct ttm_bo_reference_req
 *
 * @handle: The object to put a reference on.
 *
 * Input to the TTM_BO_REFERENCE and the TTM_BO_UNREFERENCE ioctls.
 */ 

struct ttm_bo_reference_req {
        uint32_t handle;
        uint32_t pad64;
};


/*
 * ACCESS mode flags for SYNCCPU.
 *
 * TTM_SYNCCPU_MODE_READ will guarantee that the GPU is not
 * writing to the buffer.
 *
 * TTM_SYNCCPU_MODE_WRITE will guarantee that the GPU is not
 * accessing the buffer.
 *
 * TTM_SYNCCPU_MODE_NO_BLOCK makes sure the call does not wait
 * for GPU accesses to finish but return -EBUSY.
 *
 * TTM_SYNCCPU_MODE_TRYCACHED Try to place the buffer in cacheable
 * memory while synchronized for CPU.
 */

#define TTM_SYNCCPU_MODE_READ      TTM_ACCESS_READ
#define TTM_SYNCCPU_MODE_WRITE     TTM_ACCESS_WRITE
#define TTM_SYNCCPU_MODE_NO_BLOCK  (1 << 2)
#define TTM_SYNCCPU_MODE_TRYCACHED (1 << 3)

/**
 * struct ttm_synccpu_arg
 *
 * @handle: The object to synchronize.
 *
 * @access_mode: access mode indicated by the 
 * TTM_SYNCCPU_MODE flags.
 * 
 * @op: indicates whether to grab or release the
 * buffer for cpu usage.
 * 
 * Input to the TTM_BO_SYNCCPU ioctl.
 */ 

struct ttm_synccpu_arg {
        uint32_t handle;
        uint32_t access_mode;
        enum {
                TTM_SYNCCPU_OP_GRAB,
                TTM_SYNCCPU_OP_RELEASE
        } op;
        uint32_t pad64;
};

/*
 * Waiting mode flags for the TTM_BO_WAITIDLE ioctl.
 * 
 * TTM_WAITIDLE_MODE_LAZY: Allow for sleeps during polling
 * wait.
 *
 * TTM_WAITIDLE_MODE_NO_BLOCK: Don't block waiting for GPU, 
 * but return -EBUSY if the buffer is busy.
 */

#define TTM_WAITIDLE_MODE_LAZY     (1 << 0)
#define TTM_WAITIDLE_MODE_NO_BLOCK (1 << 1)

/**
 * struct ttm_waitidle_arg
 *
 * @handle: The object to synchronize.
 *
 * @mode: wait mode indicated by the 
 * TTM_SYNCCPU_MODE flags.
 * 
 * Argument to the TTM_BO_WAITIDLE ioctl.
 */ 

struct ttm_waitidle_arg {
        uint32_t handle;
        uint32_t mode;
};

union ttm_bo_create_arg {
        struct ttm_bo_create_req req;
        struct ttm_bo_rep rep;
};

union ttm_bo_reference_arg {
        struct ttm_bo_reference_req req;
        struct ttm_bo_rep rep;
};

union ttm_bo_setstatus_arg {
        struct ttm_setstatus_req req;
        struct ttm_bo_rep rep;
};

/*
 * Ioctl offsets.
 */

#define TTM_BO_CREATE      0x00
#define TTM_BO_REFERENCE   0x01
#define TTM_BO_UNREF       0x02
#define TTM_BO_SYNCCPU     0x03
#define TTM_BO_WAITIDLE    0x04
#define TTM_BO_SETSTATUS   0x05

#endif
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to