Commit aea74b65 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

staging: gma500: kill off TTM

We are not using TTM, we are not going to use TTM either
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0b35c063
......@@ -16,15 +16,8 @@ psb_gfx-y += psb_bl.o \
psb_intel_modes.o \
psb_intel_sdvo.o \
psb_reset.o \
psb_sgx.o \
psb_pvr_glue.o \
psb_buffer.o \
psb_fence.o \
psb_mmu.o \
psb_ttm_glue.o \
psb_ttm_fence.o \
psb_ttm_fence_user.o \
psb_ttm_placement_user.o \
psb_powermgmt.o \
psb_irq.o \
mrst_crtc.o \
......
......@@ -40,7 +40,6 @@
#include "psb_reg.h"
#include "psb_drv.h"
#include "psb_fb.h"
#include "psb_sgx.h"
void psb_spank(struct drm_psb_private *dev_priv)
{
......
This diff is collapsed.
......@@ -28,9 +28,6 @@
#include "drm_mode.h"
#endif
#include "psb_ttm_fence_user.h"
#include "psb_ttm_placement_user.h"
#define DRM_PSB_SAREA_MAJOR 0
#define DRM_PSB_SAREA_MINOR 2
#define PSB_FIXED_SHIFT 16
......@@ -41,15 +38,6 @@
* Public memory types.
*/
#define DRM_PSB_MEM_MMU TTM_PL_PRIV1
#define DRM_PSB_FLAG_MEM_MMU TTM_PL_FLAG_PRIV1
#define TTM_PL_CI TTM_PL_PRIV0
#define TTM_PL_FLAG_CI TTM_PL_FLAG_PRIV0
#define TTM_PL_RAR TTM_PL_PRIV2
#define TTM_PL_FLAG_RAR TTM_PL_FLAG_PRIV2
typedef s32 psb_fixed;
typedef u32 psb_ufixed;
......@@ -112,111 +100,12 @@ struct drm_psb_sarea {
u32 num_active_scanouts;
};
#define PSB_RELOC_MAGIC 0x67676767
#define PSB_RELOC_SHIFT_MASK 0x0000FFFF
#define PSB_RELOC_SHIFT_SHIFT 0
#define PSB_RELOC_ALSHIFT_MASK 0xFFFF0000
#define PSB_RELOC_ALSHIFT_SHIFT 16
#define PSB_RELOC_OP_OFFSET 0 /* Offset of the indicated
* buffer
*/
struct drm_psb_reloc {
u32 reloc_op;
u32 where; /* offset in destination buffer */
u32 buffer; /* Buffer reloc applies to */
u32 mask; /* Destination format: */
u32 shift; /* Destination format: */
u32 pre_add; /* Destination format: */
u32 background; /* Destination add */
u32 dst_buffer; /* Destination buffer. Index into buffer_list */
u32 arg0; /* Reloc-op dependant */
u32 arg1;
};
#define PSB_GPU_ACCESS_READ (1ULL << 32)
#define PSB_GPU_ACCESS_WRITE (1ULL << 33)
#define PSB_GPU_ACCESS_MASK (PSB_GPU_ACCESS_READ | PSB_GPU_ACCESS_WRITE)
#define PSB_BO_FLAG_COMMAND (1ULL << 52)
#define PSB_ENGINE_2D 0
#define PSB_ENGINE_VIDEO 1
#define LNC_ENGINE_ENCODE 5
/*
* For this fence class we have a couple of
* fence types.
*/
#define _PSB_FENCE_EXE_SHIFT 0
#define _PSB_FENCE_FEEDBACK_SHIFT 4
#define _PSB_FENCE_TYPE_EXE (1 << _PSB_FENCE_EXE_SHIFT)
#define _PSB_FENCE_TYPE_FEEDBACK (1 << _PSB_FENCE_FEEDBACK_SHIFT)
#define PSB_NUM_ENGINES 6
#define PSB_FEEDBACK_OP_VISTEST (1 << 0)
struct drm_psb_extension_rep {
s32 exists;
u32 driver_ioctl_offset;
u32 sarea_offset;
u32 major;
u32 minor;
u32 pl;
};
#define DRM_PSB_EXT_NAME_LEN 128
union drm_psb_extension_arg {
char extension[DRM_PSB_EXT_NAME_LEN];
struct drm_psb_extension_rep rep;
};
struct psb_validate_req {
u64 set_flags;
u64 clear_flags;
u64 next;
u64 presumed_gpu_offset;
u32 buffer_handle;
u32 presumed_flags;
u32 group;
u32 pad64;
};
struct psb_validate_rep {
u64 gpu_offset;
u32 placement;
u32 fence_type_mask;
};
#define PSB_USE_PRESUMED (1 << 0)
struct psb_validate_arg {
int handled;
int ret;
union {
struct psb_validate_req req;
struct psb_validate_rep rep;
} d;
};
#define DRM_PSB_FENCE_NO_USER (1 << 0)
struct psb_ttm_fence_rep {
u32 handle;
u32 fence_class;
u32 fence_type;
u32 signaled_types;
u32 error;
};
/*
* Feedback components:
*/
......
This diff is collapsed.
......@@ -30,11 +30,6 @@
#include "psb_gtt.h"
#include "psb_powermgmt.h"
#include "mrst.h"
#include "ttm/ttm_object.h"
#include "psb_ttm_fence_driver.h"
#include "psb_ttm_userobj_api.h"
#include "ttm/ttm_bo_driver.h"
#include "ttm/ttm_lock.h"
/*Append new drm mode definition here, align with libdrm definition*/
#define DRM_MODE_SCALE_NO_SCALE 2
......@@ -92,9 +87,6 @@ enum {
#define PSB_TT_PRIV0_PLIMIT (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
#define PSB_NUM_VALIDATE_BUFFERS 2048
#define PSB_MEM_MMU_START 0x00000000
#define PSB_MEM_TT_START 0xE0000000
/*
*Flags for external memory type field.
*/
......@@ -251,22 +243,8 @@ struct drm_psb_private {
void * dbi_dsr_info;
void * dsi_configs[2];
/*
*TTM Glue.
*/
struct drm_global_reference mem_global_ref;
struct ttm_bo_global_ref bo_global_ref;
int has_global;
struct drm_device *dev;
struct ttm_object_device *tdev;
struct ttm_fence_device fdev;
struct ttm_bo_device bdev;
struct ttm_lock ttm_lock;
struct vm_operations_struct *ttm_vm_ops;
int has_fence_device;
int has_bo_device;
unsigned long chipset;
......@@ -276,11 +254,7 @@ struct drm_psb_private {
/*GTT Memory manager*/
struct psb_gtt_mm *gtt_mm;
struct page *scratch_page;
uint32_t sequence[PSB_NUM_ENGINES];
uint32_t last_sequence[PSB_NUM_ENGINES];
uint32_t last_submitted_seq[PSB_NUM_ENGINES];
struct psb_mmu_driver *mmu;
struct psb_mmu_pd *pf_pd;
......@@ -299,7 +273,6 @@ struct drm_psb_private {
bool vblanksEnabledForFlips;
spinlock_t irqmask_lock;
spinlock_t sequence_lock;
/*
*Modesetting
......@@ -636,46 +609,6 @@ static inline struct drm_psb_private *psb_priv(struct drm_device *dev)
return (struct drm_psb_private *) dev->dev_private;
}
/*
*TTM glue. psb_ttm_glue.c
*/
extern int psb_open(struct inode *inode, struct file *filp);
extern int psb_release(struct inode *inode, struct file *filp);
extern int psb_mmap(struct file *filp, struct vm_area_struct *vma);
extern int psb_fence_signaled_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_verify_access(struct ttm_buffer_object *bo,
struct file *filp);
extern ssize_t psb_ttm_read(struct file *filp, char __user *buf,
size_t count, loff_t *f_pos);
extern ssize_t psb_ttm_write(struct file *filp, const char __user *buf,
size_t count, loff_t *f_pos);
extern int psb_fence_finish_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_fence_unref_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_waitidle_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_setstatus_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_synccpu_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_unref_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_reference_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_pl_ub_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_extension_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_ttm_global_init(struct drm_psb_private *dev_priv);
extern void psb_ttm_global_release(struct drm_psb_private *dev_priv);
extern int psb_getpageaddrs_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/*
*MMU stuff.
*/
......@@ -718,26 +651,6 @@ extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd,
unsigned long address, uint32_t num_pages,
uint32_t desired_tile_stride,
uint32_t hw_tile_stride);
/*
*psb_sgx.c
*/
extern int psb_cmdbuf_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int psb_reg_submit(struct drm_psb_private *dev_priv,
uint32_t *regs, unsigned int cmds);
extern void psb_fence_or_sync(struct drm_file *file_priv,
uint32_t engine,
uint32_t fence_types,
uint32_t fence_flags,
struct list_head *list,
struct psb_ttm_fence_rep *fence_arg,
struct ttm_fence_object **fence_p);
/*
*psb_irq.c
*/
......@@ -766,29 +679,6 @@ psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc);
/*
*psb_fence.c
*/
extern void psb_fence_handler(struct drm_device *dev, uint32_t class);
extern int psb_fence_emit_sequence(struct ttm_fence_device *fdev,
uint32_t fence_class,
uint32_t flags, uint32_t *sequence,
unsigned long *timeout_jiffies);
extern void psb_fence_error(struct drm_device *dev,
uint32_t class,
uint32_t sequence, uint32_t type, int error);
extern int psb_ttm_fence_device_init(struct ttm_fence_device *fdev);
/* MSVDX/Topaz stuff */
extern int psb_remove_videoctx(struct drm_psb_private *dev_priv, struct file *filp);
extern int lnc_video_frameskip(struct drm_device *dev,
uint64_t user_pointer);
extern int lnc_video_getparam(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/*
* psb_opregion.c
*/
......
......@@ -36,9 +36,7 @@
#include "psb_drv.h"
#include "psb_intel_reg.h"
#include "psb_intel_drv.h"
#include "psb_ttm_userobj_api.h"
#include "psb_fb.h"
#include "psb_sgx.h"
#include "psb_pvr_glue.h"
static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
......@@ -317,6 +315,8 @@ static struct drm_framebuffer *psb_user_framebuffer_create
(struct drm_device *dev, struct drm_file *filp,
struct drm_mode_fb_cmd *r)
{
return NULL;
#if 0
struct ttm_buffer_object *bo = NULL;
uint64_t size;
......@@ -332,7 +332,6 @@ static struct drm_framebuffer *psb_user_framebuffer_create
/* JB: TODO not drop, refcount buffer */
return psb_framebuffer_create(dev, r, bo);
#if 0
struct psb_framebuffer *psbfb;
struct drm_framebuffer *fb;
struct fb_info *info;
......
/*
* Copyright (c) 2007, Intel Corporation.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
*/
#include <drm/drmP.h>
#include "psb_drv.h"
static void psb_fence_poll(struct ttm_fence_device *fdev,
uint32_t fence_class, uint32_t waiting_types)
{
struct drm_psb_private *dev_priv =
container_of(fdev, struct drm_psb_private, fdev);
if (unlikely(!dev_priv))
return;
if (waiting_types == 0)
return;
/* DRM_ERROR("Polling fence sequence, got 0x%08x\n", sequence); */
ttm_fence_handler(fdev, fence_class, 0 /* Sequence */,
_PSB_FENCE_TYPE_EXE, 0);
}
void psb_fence_error(struct drm_device *dev,
uint32_t fence_class,
uint32_t sequence, uint32_t type, int error)
{
struct drm_psb_private *dev_priv = psb_priv(dev);
struct ttm_fence_device *fdev = &dev_priv->fdev;
unsigned long irq_flags;
struct ttm_fence_class_manager *fc =
&fdev->fence_class[fence_class];
BUG_ON(fence_class >= PSB_NUM_ENGINES);
write_lock_irqsave(&fc->lock, irq_flags);
ttm_fence_handler(fdev, fence_class, sequence, type, error);
write_unlock_irqrestore(&fc->lock, irq_flags);
}
int psb_fence_emit_sequence(struct ttm_fence_device *fdev,
uint32_t fence_class,
uint32_t flags, uint32_t *sequence,
unsigned long *timeout_jiffies)
{
struct drm_psb_private *dev_priv =
container_of(fdev, struct drm_psb_private, fdev);
if (!dev_priv)
return -EINVAL;
if (fence_class >= PSB_NUM_ENGINES)
return -EINVAL;
DRM_ERROR("Unexpected fence class\n");
return -EINVAL;
}
static void psb_fence_lockup(struct ttm_fence_object *fence,
uint32_t fence_types)
{
DRM_ERROR("Unsupported fence class\n");
}
void psb_fence_handler(struct drm_device *dev, uint32_t fence_class)
{
struct drm_psb_private *dev_priv = psb_priv(dev);
struct ttm_fence_device *fdev = &dev_priv->fdev;
struct ttm_fence_class_manager *fc =
&fdev->fence_class[fence_class];
unsigned long irq_flags;
write_lock_irqsave(&fc->lock, irq_flags);
psb_fence_poll(fdev, fence_class, fc->waiting_types);
write_unlock_irqrestore(&fc->lock, irq_flags);
}
static struct ttm_fence_driver psb_ttm_fence_driver = {
.has_irq = NULL,
.emit = psb_fence_emit_sequence,
.flush = NULL,
.poll = psb_fence_poll,
.needed_flush = NULL,
.wait = NULL,
.signaled = NULL,
.lockup = psb_fence_lockup,
};
int psb_ttm_fence_device_init(struct ttm_fence_device *fdev)
{
struct drm_psb_private *dev_priv =
container_of(fdev, struct drm_psb_private, fdev);
struct ttm_fence_class_init fci = {.wrap_diff = (1 << 30),
.flush_diff = (1 << 29),
.sequence_mask = 0xFFFFFFFF
};
return ttm_fence_device_init(PSB_NUM_ENGINES,
dev_priv->mem_global_ref.object,
fdev, &fci, 1,
&psb_ttm_fence_driver);
}
......@@ -101,7 +101,7 @@ int psb_gtt_init(struct psb_gtt *pg, int resume)
pg->gatt_start = pci_resource_start(dev->pdev, PSB_GATT_RESOURCE);
/* fix me: video mmu has hw bug to access 0x0D0000000,
* then make gatt start at 0x0e000,0000 */
pg->mmu_gatt_start = PSB_MEM_TT_START;
pg->mmu_gatt_start = 0xE0000000;
pg->gtt_start = pci_resource_start(dev->pdev, PSB_GTT_RESOURCE);
gtt_pages =
pci_resource_len(dev->pdev, PSB_GTT_RESOURCE) >> PAGE_SHIFT;
......
/**************************************************************************
* Copyright (c) 2007, Intel Corporation.
* All Rights Reserved.
* Copyright (c) 2008, Tungsten Graphics, Inc. Cedar Park, TX. USA.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
**************************************************************************/
#include <drm/drmP.h>
#include "psb_drv.h"
#include "psb_drm.h"
#include "psb_reg.h"
#include "ttm/ttm_bo_api.h"
#include "ttm/ttm_execbuf_util.h"
#include "psb_ttm_userobj_api.h"
#include "ttm/ttm_placement.h"
#include "psb_sgx.h"
#include "psb_intel_reg.h"
#include "psb_powermgmt.h"
static inline int psb_same_page(unsigned long offset,
unsigned long offset2)
{
return (offset & PAGE_MASK) == (offset2 & PAGE_MASK);
}
static inline unsigned long psb_offset_end(unsigned long offset,
unsigned long end)
{
offset = (offset + PAGE_SIZE) & PAGE_MASK;
return (end < offset) ? end : offset;
}
struct psb_dstbuf_cache {
unsigned int dst;
struct ttm_buffer_object *dst_buf;
unsigned long dst_offset;
uint32_t *dst_page;
unsigned int dst_page_offset;
struct ttm_bo_kmap_obj dst_kmap;
bool dst_is_iomem;
};
struct psb_validate_buffer {
struct ttm_validate_buffer base;
struct psb_validate_req req;
int ret;
struct psb_validate_arg __user *user_val_arg;
uint32_t flags;
uint32_t offset;
int po_correct;
};
void psb_fence_or_sync(struct drm_file *file_priv,
uint32_t engine,
uint32_t fence_types,
uint32_t fence_flags,
struct list_head *list,
struct psb_ttm_fence_rep *fence_arg,
struct ttm_fence_object **fence_p)
{
struct drm_device *dev = file_priv->minor->dev;
struct drm_psb_private *dev_priv = psb_priv(dev);
struct ttm_fence_device *fdev = &dev_priv->fdev;
int ret;
struct ttm_fence_object *fence;
struct ttm_object_file *tfile = psb_fpriv(file_priv)->tfile;
uint32_t handle;
ret = ttm_fence_user_create(fdev, tfile,
engine, fence_types,
TTM_FENCE_FLAG_EMIT, &fence, &handle);
if (ret) {
/*
* Fence creation failed.
* Fall back to synchronous operation and idle the engine.
*/
if (!(fence_flags & DRM_PSB_FENCE_NO_USER)) {
/*
* Communicate to user-space that
* fence creation has failed and that
* the engine is idle.
*/
fence_arg->handle = ~0;
fence_arg->error = ret;
}
ttm_eu_backoff_reservation(list);
if (fence_p)
*fence_p = NULL;
return;
}
ttm_eu_fence_buffer_objects(list, fence);
if (!(fence_flags & DRM_PSB_FENCE_NO_USER)) {
struct ttm_fence_info info = ttm_fence_get_info(fence);
fence_arg->handle = handle;
fence_arg->fence_class = ttm_fence_class(fence);
fence_arg->fence_type = ttm_fence_types(fence);
fence_arg->signaled_types = info.signaled_types;
fence_arg->error = 0;
} else {
ret =
ttm_ref_object_base_unref(tfile, handle,
ttm_fence_type);
BUG_ON(ret);
}
if (fence_p)
*fence_p = fence;
else if (fence)
ttm_fence_object_unref(&fence);
}
/*
* Copyright (c) 2008, Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* Authors:
* Eric Anholt <eric@anholt.net>
*
**/
#ifndef _PSB_SGX_H_
#define _PSB_SGX_H_
extern int psb_submit_video_cmdbuf(struct drm_device *dev,
struct ttm_buffer_object *cmd_buffer,
unsigned long cmd_offset,
unsigned long cmd_size,
struct ttm_fence_object *fence);
extern int drm_idle_check_interval;
#endif
This diff is collapsed.
/**************************************************************************
*
* Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
* All Rights Reserved.
* Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
**************************************************************************/
/*
* Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
*/
#ifndef _TTM_FENCE_API_H_
#define _TTM_FENCE_API_H_
#include <linux/list.h>
#include <linux/kref.h>
#define TTM_FENCE_FLAG_EMIT (1 << 0)
#define TTM_FENCE_TYPE_EXE (1 << 0)
struct ttm_fence_device;
/**
* struct ttm_fence_info
*
* @fence_class: The fence class.
* @fence_type: Bitfield indicating types for this fence.
* @signaled_types: Bitfield indicating which types are signaled.
* @error: Last error reported from the device.
*
* Used as output from the ttm_fence_get_info
*/
struct ttm_fence_info {
uint32_t signaled_types;
uint32_t error;
};
/**
* struct ttm_fence_object
*
* @fdev: Pointer to the fence device struct.
* @kref: Holds the reference count of this fence object.
* @ring: List head used for the circular list of not-completely
* signaled fences.
* @info: Data for fast retrieval using the ttm_fence_get_info()
* function.
* @timeout_jiffies: Absolute jiffies value indicating when this fence
* object times out and, if waited on, calls ttm_fence_lockup
* to check for and resolve a GPU lockup.
* @sequence: Fence sequence number.
* @waiting_types: Types currently waited on.
* @destroy: Called to free the fence object, when its refcount has
* reached zero. If NULL, kfree is used.
*
* This struct is provided in the driver interface so that drivers can
* derive from it and create their own fence implementation. All members
* are private to the fence implementation and the fence driver callbacks.
* Otherwise a driver may access the derived object using container_of().
*/
struct ttm_fence_object {
struct ttm_fence_device *fdev;
struct kref kref;
uint32_t fence_class;
uint32_t fence_type;
/*
* The below fields are protected by the fence class
* manager spinlock.
*/
struct list_head ring;
struct ttm_fence_info info;
unsigned long timeout_jiffies;
uint32_t sequence;
uint32_t waiting_types;
void (*destroy) (struct ttm_fence_object *);
};
/**
* ttm_fence_object_init
*
* @fdev: Pointer to a struct ttm_fence_device.
* @fence_class: Fence class for this fence.
* @type: Fence type for this fence.
* @create_flags: Flags indicating varios actions at init time. At this point
* there's only TTM_FENCE_FLAG_EMIT, which triggers a sequence emission to
* the command stream.
* @destroy: Destroy function. If NULL, kfree() is used.
* @fence: The struct ttm_fence_object to initialize.
*
* Initialize a pre-allocated fence object. This function, together with the
* destroy function makes it possible to derive driver-specific fence objects.
*/
extern int
ttm_fence_object_init(struct ttm_fence_device *fdev,
uint32_t fence_class,
uint32_t type,
uint32_t create_flags,
void (*destroy) (struct ttm_fence_object *fence),
struct ttm_fence_object *fence);
/**
* ttm_fence_object_create
*
* @fdev: Pointer to a struct ttm_fence_device.
* @fence_class: Fence class for this fence.
* @type: Fence type for this fence.
* @create_flags: Flags indicating varios actions at init time. At this point
* there's only TTM_FENCE_FLAG_EMIT, which triggers a sequence emission to
* the command stream.
* @c_fence: On successful termination, *(@c_fence) will point to the created
* fence object.
*
* Create and initialize a struct ttm_fence_object. The destroy function will
* be set to kfree().
*/
extern int
ttm_fence_object_create(struct ttm_fence_device *fdev,
uint32_t fence_class,
uint32_t type,
uint32_t create_flags,
struct ttm_fence_object **c_fence);
/**
* ttm_fence_object_wait
*
* @fence: The fence object to wait on.
* @lazy: Allow sleeps to reduce the cpu-usage if polling.
* @interruptible: Sleep interruptible when waiting.
* @type_mask: Wait for the given type_mask to signal.
*
* Wait for a fence to signal the given type_mask. The function will
* perform a fence_flush using type_mask. (See ttm_fence_object_flush).
*
* Returns
* -ERESTART if interrupted by a signal.
* May return driver-specific error codes if timed-out.
*/
extern int
ttm_fence_object_wait(struct ttm_fence_object *fence,
bool lazy, bool interruptible, uint32_t type_mask);
/**
* ttm_fence_object_flush
*
* @fence: The fence object to flush.
* @flush_mask: Fence types to flush.
*
* Make sure that the given fence eventually signals the
* types indicated by @flush_mask. Note that this may or may not
* map to a CPU or GPU flush.
*/
extern int
ttm_fence_object_flush(struct ttm_fence_object *fence, uint32_t flush_mask);
/**
* ttm_fence_get_info
*
* @fence: The fence object.
*
* Copy the info block from the fence while holding relevant locks.
*/
struct ttm_fence_info ttm_fence_get_info(struct ttm_fence_object *fence);
/**
* ttm_fence_object_ref
*
* @fence: The fence object.
*
* Return a ref-counted pointer to the fence object indicated by @fence.
*/
static inline struct ttm_fence_object *ttm_fence_object_ref(struct
ttm_fence_object
*fence)
{
kref_get(&fence->kref);
return fence;
}
/**
* ttm_fence_object_unref
*
* @p_fence: Pointer to a ref-counted pinter to a struct ttm_fence_object.
*
* Unreference the fence object pointed to by *(@p_fence), clearing
* *(p_fence).
*/
extern void ttm_fence_object_unref(struct ttm_fence_object **p_fence);
/**
* ttm_fence_object_signaled
*
* @fence: Pointer to the struct ttm_fence_object.
* @mask: Type mask to check whether signaled.
*
* This function checks (without waiting) whether the fence object
* pointed to by @fence has signaled the types indicated by @mask,
* and returns 1 if true, 0 if false. This function does NOT perform
* an implicit fence flush.
*/
extern bool
ttm_fence_object_signaled(struct ttm_fence_object *fence, uint32_t mask);
/**
* ttm_fence_class
*
* @fence: Pointer to the struct ttm_fence_object.
*
* Convenience function that returns the fence class of a
* struct ttm_fence_object.
*/
static inline uint32_t ttm_fence_class(const struct ttm_fence_object *fence)
{
return fence->fence_class;
}
/**
* ttm_fence_types
*
* @fence: Pointer to the struct ttm_fence_object.
*
* Convenience function that returns the fence types of a
* struct ttm_fence_object.
*/
static inline uint32_t ttm_fence_types(const struct ttm_fence_object *fence)
{
return fence->fence_type;
}
/*
* The functions below are wrappers to the above functions, with
* similar names but with sync_obj omitted. These wrappers are intended
* to be plugged directly into the buffer object driver's sync object
* API, if the driver chooses to use ttm_fence_objects as buffer object
* sync objects. In the prototypes below, a sync_obj is cast to a
* struct ttm_fence_object, whereas a sync_arg is cast to an
* uint32_t representing a fence_type argument.
*/
extern bool ttm_fence_sync_obj_signaled(void *sync_obj, void *sync_arg);
extern int ttm_fence_sync_obj_wait(void *sync_obj, void *sync_arg,
bool lazy, bool interruptible);
extern int ttm_fence_sync_obj_flush(void *sync_obj, void *sync_arg);
extern void ttm_fence_sync_obj_unref(void **sync_obj);
extern void *ttm_fence_sync_obj_ref(void *sync_obj);
#endif
This diff is collapsed.
/**************************************************************************
*
* Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
* All Rights Reserved.
* Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
**************************************************************************/
/*
* Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
*/
#include <drm/drmP.h>
#include "psb_ttm_fence_user.h"
#include "ttm/ttm_object.h"
#include "psb_ttm_fence_driver.h"
#include "psb_ttm_userobj_api.h"
/**
* struct ttm_fence_user_object
*
* @base: The base object used for user-space visibility and refcounting.
*
* @fence: The fence object itself.
*
*/
struct ttm_fence_user_object {
struct ttm_base_object base;
struct ttm_fence_object fence;
};
static struct ttm_fence_user_object *ttm_fence_user_object_lookup(
struct ttm_object_file *tfile,
uint32_t handle)
{
struct ttm_base_object *base;
base = ttm_base_object_lookup(tfile, handle);
if (unlikely(base == NULL)) {
printk(KERN_ERR "Invalid fence handle 0x%08lx\n",
(unsigned long)handle);
return NULL;
}
if (unlikely(base->object_type != ttm_fence_type)) {
ttm_base_object_unref(&base);
printk(KERN_ERR "Invalid fence handle 0x%08lx\n",
(unsigned long)handle);
return NULL;
}
return container_of(base, struct ttm_fence_user_object, base);
}
/*
* The fence object destructor.
*/
static void ttm_fence_user_destroy(struct ttm_fence_object *fence)
{
struct ttm_fence_user_object *ufence =
container_of(fence, struct ttm_fence_user_object, fence);
ttm_mem_global_free(fence->fdev->mem_glob, sizeof(*ufence));
kfree(ufence);
}
/*
* The base object destructor. We basically unly unreference the
* attached fence object.
*/
static void ttm_fence_user_release(struct ttm_base_object **p_base)
{
struct ttm_fence_user_object *ufence;
struct ttm_base_object *base = *p_base;
struct ttm_fence_object *fence;
*p_base = NULL;
if (unlikely(base == NULL))
return;
ufence = container_of(base, struct ttm_fence_user_object, base);
fence = &ufence->fence;
ttm_fence_object_unref(&fence);
}
int
ttm_fence_user_create(struct ttm_fence_device *fdev,
struct ttm_object_file *tfile,
uint32_t fence_class,
uint32_t fence_types,
uint32_t create_flags,
struct ttm_fence_object **fence,
uint32_t *user_handle)
{
int ret;
struct ttm_fence_object *tmp;
struct ttm_fence_user_object *ufence;
ret = ttm_mem_global_alloc(fdev->mem_glob,
sizeof(*ufence),
false,
false);
if (unlikely(ret != 0))
return -ENOMEM;
ufence = kmalloc(sizeof(*ufence), GFP_KERNEL);
if (unlikely(ufence == NULL)) {
ttm_mem_global_free(fdev->mem_glob, sizeof(*ufence));
return -ENOMEM;
}
ret = ttm_fence_object_init(fdev,
fence_class,
fence_types, create_flags,
&ttm_fence_user_destroy, &ufence->fence);
if (unlikely(ret != 0))
goto out_err0;
/*
* One fence ref is held by the fence ptr we return.
* The other one by the base object. Need to up the
* fence refcount before we publish this object to
* user-space.
*/
tmp = ttm_fence_object_ref(&ufence->fence);
ret = ttm_base_object_init(tfile, &ufence->base,
false, ttm_fence_type,
&ttm_fence_user_release, NULL);
if (unlikely(ret != 0))
goto out_err1;
*fence = &ufence->fence;
*user_handle = ufence->base.hash.key;
return 0;
out_err1:
ttm_fence_object_unref(&tmp);
tmp = &ufence->fence;
ttm_fence_object_unref(&tmp);
return ret;
out_err0:
ttm_mem_global_free(fdev->mem_glob, sizeof(*ufence));
kfree(ufence);
return ret;
}
int ttm_fence_signaled_ioctl(struct ttm_object_file *tfile, void *data)
{
int ret;
union ttm_fence_signaled_arg *arg = data;
struct ttm_fence_object *fence;
struct ttm_fence_info info;
struct ttm_fence_user_object *ufence;
struct ttm_base_object *base;
ret = 0;
ufence = ttm_fence_user_object_lookup(tfile, arg->req.handle);
if (unlikely(ufence == NULL))
return -EINVAL;
fence = &ufence->fence;
if (arg->req.flush) {
ret = ttm_fence_object_flush(fence, arg->req.fence_type);
if (unlikely(ret != 0))
goto out;
}
info = ttm_fence_get_info(fence);
arg->rep.signaled_types = info.signaled_types;
arg->rep.fence_error = info.error;
out:
base = &ufence->base;
ttm_base_object_unref(&base);
return ret;
}
int ttm_fence_finish_ioctl(struct ttm_object_file *tfile, void *data)
{
int ret;
union ttm_fence_finish_arg *arg = data;
struct ttm_fence_user_object *ufence;
struct ttm_base_object *base;
struct ttm_fence_object *fence;
ret = 0;
ufence = ttm_fence_user_object_lookup(tfile, arg->req.handle);
if (unlikely(ufence == NULL))
return -EINVAL;
fence = &ufence->fence;
ret = ttm_fence_object_wait(fence,
arg->req.mode & TTM_FENCE_FINISH_MODE_LAZY,
true, arg->req.fence_type);
if (likely(ret == 0)) {
struct ttm_fence_info info = ttm_fence_get_info(fence);
arg->rep.signaled_types = info.signaled_types;
arg->rep.fence_error = info.error;
}
base = &ufence->base;
ttm_base_object_unref(&base);
return ret;
}
int ttm_fence_unref_ioctl(struct ttm_object_file *tfile, void *data)
{
struct ttm_fence_unref_arg *arg = data;
int ret = 0;
ret = ttm_ref_object_base_unref(tfile, arg->handle, ttm_fence_type);
return ret;
}
/**************************************************************************
*
* Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
* All Rights Reserved.
* Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
**************************************************************************/
/*
* 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"
/**
* struct ttm_fence_signaled_req
*
* @handle: Handle to the fence object. Input.
*
* @fence_type: Fence types we want to flush. Input.
*
* @flush: Boolean. Flush the indicated fence_types. Input.
*
* Argument to the TTM_FENCE_SIGNALED ioctl.
*/
struct ttm_fence_signaled_req {
uint32_t handle;
uint32_t fence_type;
int32_t flush;
uint32_t pad64;
};
/**
* struct ttm_fence_rep
*
* @signaled_types: Fence type that has signaled.
*
* @fence_error: Command execution error.
* Hardware errors that are consequences of the execution
* of the command stream preceding the fence are reported
* here.
*
* Output argument to the TTM_FENCE_SIGNALED and
* TTM_FENCE_FINISH ioctls.
*/
struct ttm_fence_rep {
uint32_t signaled_types;
uint32_t fence_error;
};
union ttm_fence_signaled_arg {
struct ttm_fence_signaled_req req;
struct ttm_fence_rep rep;
};
/*
* 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_req
*
* @handle: Handle to the fence object. Input.
*
* @fence_type: Fence types we want to finish.
*
* @mode: Wait mode.
*
* Input to the TTM_FENCE_FINISH ioctl.
*/
struct ttm_fence_finish_req {
uint32_t handle;
uint32_t fence_type;
uint32_t mode;
uint32_t pad64;
};
union ttm_fence_finish_arg {
struct ttm_fence_finish_req req;
struct ttm_fence_rep rep;
};
/**
* 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 (c) 2008, Intel Corporation.
* All Rights Reserved.
* Copyright (c) 2008, Tungsten Graphics Inc. Cedar Park, TX., USA.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
**************************************************************************/
#include <drm/drmP.h>
#include "psb_drv.h"
#include "psb_ttm_userobj_api.h"
#include <linux/io.h>
static struct vm_operations_struct psb_ttm_vm_ops;
/**
* NOTE: driver_private of drm_file is now a struct psb_file_data struct
* pPriv in struct psb_file_data contains the original psb_fpriv;
*/
int psb_open(struct inode *inode, struct file *filp)
{
struct drm_file *file_priv;
struct drm_psb_private *dev_priv;
struct psb_fpriv *psb_fp;
struct psb_file_data *pvr_file_priv;
int ret;
DRM_DEBUG("\n");
ret = drm_open(inode, filp);
if (unlikely(ret))
return ret;
psb_fp = kzalloc(sizeof(*psb_fp), GFP_KERNEL);
if (unlikely(psb_fp == NULL))
goto out_err0;
file_priv = (struct drm_file *) filp->private_data;
dev_priv = psb_priv(file_priv->minor->dev);
DRM_DEBUG("is_master %d\n", file_priv->is_master ? 1 : 0);
psb_fp->tfile = ttm_object_file_init(dev_priv->tdev,
PSB_FILE_OBJECT_HASH_ORDER);
if (unlikely(psb_fp->tfile == NULL))
goto out_err1;
pvr_file_priv = (struct psb_file_data *)file_priv->driver_priv;
if (!pvr_file_priv) {
DRM_ERROR("drm file private is NULL\n");
goto out_err1;
}
pvr_file_priv->priv = psb_fp;
if (unlikely(dev_priv->bdev.dev_mapping == NULL))
dev_priv->bdev.dev_mapping = dev_priv->dev->dev_mapping;
return 0;
out_err1:
kfree(psb_fp);
out_err0:
(void) drm_release(inode, filp);
return ret;
}
int psb_release(struct inode *inode, struct file *filp)
{
struct drm_file *file_priv;
struct psb_fpriv *psb_fp;
struct drm_psb_private *dev_priv;
int ret;
file_priv = (struct drm_file *) filp->private_data;
psb_fp = psb_fpriv(file_priv);
dev_priv = psb_priv(file_priv->minor->dev);
ttm_object_file_release(&psb_fp->tfile);
kfree(psb_fp);
ret = drm_release(inode, filp);
return ret;
}
int psb_fence_signaled_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_fence_signaled_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_fence_finish_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_fence_finish_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_fence_unref_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_fence_unref_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_pl_waitidle_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_pl_waitidle_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_pl_setstatus_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_pl_setstatus_ioctl(psb_fpriv(file_priv)->tfile,
&psb_priv(dev)->ttm_lock, data);
}
int psb_pl_synccpu_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_pl_synccpu_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_pl_unref_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_pl_unref_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_pl_reference_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return ttm_pl_reference_ioctl(psb_fpriv(file_priv)->tfile, data);
}
int psb_pl_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_psb_private *dev_priv = psb_priv(dev);
return ttm_pl_create_ioctl(psb_fpriv(file_priv)->tfile,
&dev_priv->bdev, &dev_priv->ttm_lock, data);
}
int psb_pl_ub_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_psb_private *dev_priv = psb_priv(dev);
return ttm_pl_ub_create_ioctl(psb_fpriv(file_priv)->tfile,
&dev_priv->bdev, &dev_priv->ttm_lock, data);
}
/**
* psb_ttm_fault - Wrapper around the ttm fault method.
*
* @vma: The struct vm_area_struct as in the vm fault() method.
* @vmf: The struct vm_fault as in the vm fault() method.
*
* Since ttm_fault() will reserve buffers while faulting,
* we need to take the ttm read lock around it, as this driver
* relies on the ttm_lock in write mode to exclude all threads from
* reserving and thus validating buffers in aperture- and memory shortage
* situations.
*/
static int psb_ttm_fault(struct vm_area_struct *vma,
struct vm_fault *vmf)
{
struct ttm_buffer_object *bo = (struct ttm_buffer_object *)
vma->vm_private_data;
struct drm_psb_private *dev_priv =
container_of(bo->bdev, struct drm_psb_private, bdev);
int ret;
ret = ttm_read_lock(&dev_priv->ttm_lock, true);
if (unlikely(ret != 0))
return VM_FAULT_NOPAGE;
ret = dev_priv->ttm_vm_ops->fault(vma, vmf);
ttm_read_unlock(&dev_priv->ttm_lock);
return ret;
}
/**
* if vm_pgoff < DRM_PSB_FILE_PAGE_OFFSET call directly to
* PVRMMap
*/
int psb_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct drm_file *file_priv;
struct drm_psb_private *dev_priv;
int ret;
if (vma->vm_pgoff < DRM_PSB_FILE_PAGE_OFFSET ||
vma->vm_pgoff > 2 * DRM_PSB_FILE_PAGE_OFFSET)
#if 0 /* FIXMEAC */
return PVRMMap(filp, vma);
#else
return -EINVAL;
#endif
file_priv = (struct drm_file *) filp->private_data;
dev_priv = psb_priv(file_priv->minor->dev);
ret = ttm_bo_mmap(filp, vma, &dev_priv->bdev);
if (unlikely(ret != 0))
return ret;
if (unlikely(dev_priv->ttm_vm_ops == NULL)) {
dev_priv->ttm_vm_ops = (struct vm_operations_struct *)
vma->vm_ops;
psb_ttm_vm_ops = *vma->vm_ops;
psb_ttm_vm_ops.fault = &psb_ttm_fault;
}
vma->vm_ops = &psb_ttm_vm_ops;
return 0;
}
/*
ssize_t psb_ttm_write(struct file *filp, const char __user *buf,
size_t count, loff_t *f_pos)
{
struct drm_file *file_priv = (struct drm_file *)filp->private_data;
struct drm_psb_private *dev_priv = psb_priv(file_priv->minor->dev);
return ttm_bo_io(&dev_priv->bdev, filp, buf, NULL, count, f_pos, 1);
}
ssize_t psb_ttm_read(struct file *filp, char __user *buf,
size_t count, loff_t *f_pos)
{
struct drm_file *file_priv = (struct drm_file *)filp->private_data;
struct drm_psb_private *dev_priv = psb_priv(file_priv->minor->dev);
return ttm_bo_io(&dev_priv->bdev, filp, NULL, buf, count, f_pos, 1);
}
*/
int psb_verify_access(struct ttm_buffer_object *bo,
struct file *filp)
{
struct drm_file *file_priv = (struct drm_file *)filp->private_data;
if (capable(CAP_SYS_ADMIN))
return 0;
if (unlikely(!file_priv->authenticated))
return -EPERM;
return ttm_pl_verify_access(bo, psb_fpriv(file_priv)->tfile);
}
static int psb_ttm_mem_global_init(struct drm_global_reference *ref)
{
return ttm_mem_global_init(ref->object);
}
static void psb_ttm_mem_global_release(struct drm_global_reference *ref)
{
ttm_mem_global_release(ref->object);
}
int psb_ttm_global_init(struct drm_psb_private *dev_priv)
{
struct drm_global_reference *global_ref;
int ret;
global_ref = &dev_priv->mem_global_ref;
global_ref->global_type = DRM_GLOBAL_TTM_MEM;
global_ref->size = sizeof(struct ttm_mem_global);
global_ref->init = &psb_ttm_mem_global_init;
global_ref->release = &psb_ttm_mem_global_release;
ret = drm_global_item_ref(global_ref);
if (unlikely(ret != 0)) {
DRM_ERROR("Failed referencing a global TTM memory object.\n");
return ret;
}
dev_priv->bo_global_ref.mem_glob = dev_priv->mem_global_ref.object;
global_ref = &dev_priv->bo_global_ref.ref;
global_ref->global_type = DRM_GLOBAL_TTM_BO;
global_ref->size = sizeof(struct ttm_bo_global);
global_ref->init = &ttm_bo_global_init;
global_ref->release = &ttm_bo_global_release;
ret = drm_global_item_ref(global_ref);
if (ret != 0) {
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
drm_global_item_unref(global_ref);
return ret;
}
return 0;
}
void psb_ttm_global_release(struct drm_psb_private *dev_priv)
{
drm_global_item_unref(&dev_priv->mem_global_ref);
}
int psb_getpageaddrs_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_psb_getpageaddrs_arg *arg = data;
struct ttm_buffer_object *bo;
struct ttm_tt *ttm;
struct page **tt_pages;
unsigned long i, num_pages;
unsigned long *p = arg->page_addrs;
int ret = 0;
bo = ttm_buffer_object_lookup(psb_fpriv(file_priv)->tfile,
arg->handle);
if (unlikely(bo == NULL)) {
printk(KERN_ERR
"Could not find buffer object for getpageaddrs.\n");
return -EINVAL;
}
arg->gtt_offset = bo->offset;
ttm = bo->ttm;
num_pages = ttm->num_pages;
tt_pages = ttm->pages;
for (i = 0; i < num_pages; i++)
p[i] = (unsigned long)page_to_phys(tt_pages[i]);
return ret;
}
This diff is collapsed.
/**************************************************************************
*
* Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
* All Rights Reserved.
* Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
**************************************************************************/
/*
* Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
*/
#ifndef _TTM_USEROBJ_API_H_
#define _TTM_USEROBJ_API_H_
#include "psb_ttm_placement_user.h"
#include "psb_ttm_fence_user.h"
#include "ttm/ttm_object.h"
#include "psb_ttm_fence_api.h"
#include "ttm/ttm_bo_api.h"
struct ttm_lock;
/*
* User ioctls.
*/
extern int ttm_pl_create_ioctl(struct ttm_object_file *tfile,
struct ttm_bo_device *bdev,
struct ttm_lock *lock, void *data);
extern int ttm_pl_ub_create_ioctl(struct ttm_object_file *tfile,
struct ttm_bo_device *bdev,
struct ttm_lock *lock, void *data);
extern int ttm_pl_reference_ioctl(struct ttm_object_file *tfile, void *data);
extern int ttm_pl_unref_ioctl(struct ttm_object_file *tfile, void *data);
extern int ttm_pl_synccpu_ioctl(struct ttm_object_file *tfile, void *data);
extern int ttm_pl_setstatus_ioctl(struct ttm_object_file *tfile,
struct ttm_lock *lock, void *data);
extern int ttm_pl_waitidle_ioctl(struct ttm_object_file *tfile, void *data);
extern int ttm_fence_signaled_ioctl(struct ttm_object_file *tfile, void *data);
extern int ttm_fence_finish_ioctl(struct ttm_object_file *tfile, void *data);
extern int ttm_fence_unref_ioctl(struct ttm_object_file *tfile, void *data);
extern int
ttm_fence_user_create(struct ttm_fence_device *fdev,
struct ttm_object_file *tfile,
uint32_t fence_class,
uint32_t fence_types,
uint32_t create_flags,
struct ttm_fence_object **fence, uint32_t * user_handle);
extern struct ttm_buffer_object *ttm_buffer_object_lookup(struct ttm_object_file
*tfile,
uint32_t handle);
extern int
ttm_pl_verify_access(struct ttm_buffer_object *bo,
struct ttm_object_file *tfile);
extern int ttm_buffer_object_create(struct ttm_bo_device *bdev,
unsigned long size,
enum ttm_bo_type type,
uint32_t flags,
uint32_t page_alignment,
unsigned long buffer_start,
bool interruptible,
struct file *persistant_swap_storage,
struct ttm_buffer_object **p_bo);
extern int psb_ttm_bo_check_placement(struct ttm_buffer_object *bo,
struct ttm_placement *placement);
#endif
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