Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
i915_gem.c File Reference
#include <drm/drmP.h>
#include <drm/i915_drm.h>
#include "i915_drv.h"
#include "i915_trace.h"
#include "intel_drv.h"
#include <linux/shmem_fs.h>
#include <linux/slab.h>
#include <linux/swap.h>
#include <linux/pci.h>
#include <linux/dma-buf.h>

Go to the source code of this file.

Macros

#define EXIT_COND
 

Functions

int i915_mutex_lock_interruptible (struct drm_device *dev)
 
int i915_gem_init_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_get_aperture_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_dumb_create (struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args)
 
int i915_gem_dumb_destroy (struct drm_file *file, struct drm_device *dev, uint32_t handle)
 
int i915_gem_create_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_pread_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_pwrite_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_check_wedge (struct drm_i915_private *dev_priv, bool interruptible)
 
int i915_wait_seqno (struct intel_ring_buffer *ring, uint32_t seqno)
 
int i915_gem_set_domain_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_sw_finish_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_mmap_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_fault (struct vm_area_struct *vma, struct vm_fault *vmf)
 
void i915_gem_release_mmap (struct drm_i915_gem_object *obj)
 
uint32_t i915_gem_get_unfenced_gtt_alignment (struct drm_device *dev, uint32_t size, int tiling_mode)
 
int i915_gem_mmap_gtt (struct drm_file *file, struct drm_device *dev, uint32_t handle, uint64_t *offset)
 
int i915_gem_mmap_gtt_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_object_get_pages (struct drm_i915_gem_object *obj)
 
void i915_gem_object_move_to_active (struct drm_i915_gem_object *obj, struct intel_ring_buffer *ring, u32 seqno)
 
u32 i915_gem_next_request_seqno (struct intel_ring_buffer *ring)
 
int i915_add_request (struct intel_ring_buffer *ring, struct drm_file *file, u32 *out_seqno)
 
void i915_gem_reset (struct drm_device *dev)
 
void i915_gem_retire_requests_ring (struct intel_ring_buffer *ring)
 
void i915_gem_retire_requests (struct drm_device *dev)
 
int i915_gem_wait_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_object_sync (struct drm_i915_gem_object *obj, struct intel_ring_buffer *to)
 
int i915_gem_object_unbind (struct drm_i915_gem_object *obj)
 
int i915_gpu_idle (struct drm_device *dev)
 
int i915_gem_object_put_fence (struct drm_i915_gem_object *obj)
 
int i915_gem_object_get_fence (struct drm_i915_gem_object *obj)
 
void i915_gem_clflush_object (struct drm_i915_gem_object *obj)
 
int i915_gem_object_set_to_gtt_domain (struct drm_i915_gem_object *obj, bool write)
 
int i915_gem_object_set_cache_level (struct drm_i915_gem_object *obj, enum i915_cache_level cache_level)
 
int i915_gem_get_caching_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_set_caching_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_object_pin_to_display_plane (struct drm_i915_gem_object *obj, u32 alignment, struct intel_ring_buffer *pipelined)
 
int i915_gem_object_finish_gpu (struct drm_i915_gem_object *obj)
 
int i915_gem_object_set_to_cpu_domain (struct drm_i915_gem_object *obj, bool write)
 
int i915_gem_object_pin (struct drm_i915_gem_object *obj, uint32_t alignment, bool map_and_fenceable, bool nonblocking)
 
void i915_gem_object_unpin (struct drm_i915_gem_object *obj)
 
int i915_gem_pin_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_unpin_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_busy_ioctl (struct drm_device *dev, void *data, struct drm_file *file)
 
int i915_gem_throttle_ioctl (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
int i915_gem_madvise_ioctl (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
void i915_gem_object_init (struct drm_i915_gem_object *obj, const struct drm_i915_gem_object_ops *ops)
 
struct drm_i915_gem_objecti915_gem_alloc_object (struct drm_device *dev, size_t size)
 
int i915_gem_init_object (struct drm_gem_object *obj)
 
void i915_gem_free_object (struct drm_gem_object *gem_obj)
 
int i915_gem_idle (struct drm_device *dev)
 
void i915_gem_l3_remap (struct drm_device *dev)
 
void i915_gem_init_swizzling (struct drm_device *dev)
 
void i915_gem_init_ppgtt (struct drm_device *dev)
 
int i915_gem_init_hw (struct drm_device *dev)
 
int i915_gem_init (struct drm_device *dev)
 
void i915_gem_cleanup_ringbuffer (struct drm_device *dev)
 
int i915_gem_entervt_ioctl (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
int i915_gem_leavevt_ioctl (struct drm_device *dev, void *data, struct drm_file *file_priv)
 
void i915_gem_lastclose (struct drm_device *dev)
 
void i915_gem_load (struct drm_device *dev)
 
void i915_gem_free_all_phys_object (struct drm_device *dev)
 
void i915_gem_detach_phys_object (struct drm_device *dev, struct drm_i915_gem_object *obj)
 
int i915_gem_attach_phys_object (struct drm_device *dev, struct drm_i915_gem_object *obj, int id, int align)
 
void i915_gem_release (struct drm_device *dev, struct drm_file *file)
 

Macro Definition Documentation

#define EXIT_COND
Value:
(i915_seqno_passed(ring->get_seqno(ring, false), seqno) || \
atomic_read(&dev_priv->mm.wedged))

Function Documentation

int i915_add_request ( struct intel_ring_buffer ring,
struct drm_file *  file,
u32 out_seqno 
)

Definition at line 1959 of file i915_gem.c.

struct drm_i915_gem_object* i915_gem_alloc_object ( struct drm_device dev,
size_t  size 
)
read

Definition at line 3685 of file i915_gem.c.

int i915_gem_attach_phys_object ( struct drm_device dev,
struct drm_i915_gem_object obj,
int  id,
int  align 
)

Definition at line 4305 of file i915_gem.c.

int i915_gem_busy_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 3572 of file i915_gem.c.

int i915_gem_check_wedge ( struct drm_i915_private dev_priv,
bool  interruptible 
)

Definition at line 943 of file i915_gem.c.

void i915_gem_cleanup_ringbuffer ( struct drm_device dev)

Definition at line 4073 of file i915_gem.c.

void i915_gem_clflush_object ( struct drm_i915_gem_object obj)

Definition at line 3000 of file i915_gem.c.

int i915_gem_create_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Creates a new mm object and returns a handle to it.

Definition at line 253 of file i915_gem.c.

void i915_gem_detach_phys_object ( struct drm_device dev,
struct drm_i915_gem_object obj 
)

Definition at line 4271 of file i915_gem.c.

int i915_gem_dumb_create ( struct drm_file *  file,
struct drm_device dev,
struct drm_mode_create_dumb args 
)

Definition at line 231 of file i915_gem.c.

int i915_gem_dumb_destroy ( struct drm_file *  file,
struct drm_device dev,
uint32_t  handle 
)

Definition at line 242 of file i915_gem.c.

int i915_gem_entervt_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

Definition at line 4084 of file i915_gem.c.

int i915_gem_fault ( struct vm_area_struct vma,
struct vm_fault *  vmf 
)

i915_gem_fault - fault a page into the GTT vma: VMA in question vmf: fault info

The fault handler is set up by drm_gem_mmap() when a object is GTT mapped from userspace. The fault handler takes care of binding the object to the GTT (if needed), allocating and programming a fence register (again, only if needed based on whether the old reg is still valid or the object is tiled) and inserting a new PTE into the faulting process.

Note that the faulting process may involve evicting existing objects from the GTT and/or fence registers to make room. So performance may suffer if the GTT working set is large or there are few fence registers left.

Definition at line 1327 of file i915_gem.c.

void i915_gem_free_all_phys_object ( struct drm_device dev)

Definition at line 4263 of file i915_gem.c.

void i915_gem_free_object ( struct drm_gem_object *  gem_obj)

Definition at line 3743 of file i915_gem.c.

int i915_gem_get_aperture_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 174 of file i915_gem.c.

int i915_gem_get_caching_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 3197 of file i915_gem.c.

uint32_t i915_gem_get_unfenced_gtt_alignment ( struct drm_device dev,
uint32_t  size,
int  tiling_mode 
)

i915_gem_get_unfenced_gtt_alignment - return required GTT alignment for an unfenced object : the device : size of the object : tiling mode of the object

Return the required GTT alignment for an object, only taking into account unfenced tiled surface requirements.

Definition at line 1505 of file i915_gem.c.

int i915_gem_idle ( struct drm_device dev)

Definition at line 3783 of file i915_gem.c.

int i915_gem_init ( struct drm_device dev)

Definition at line 4022 of file i915_gem.c.

int i915_gem_init_hw ( struct drm_device dev)

Definition at line 3958 of file i915_gem.c.

int i915_gem_init_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 149 of file i915_gem.c.

int i915_gem_init_object ( struct drm_gem_object *  obj)

Definition at line 3736 of file i915_gem.c.

void i915_gem_init_ppgtt ( struct drm_device dev)

Definition at line 3879 of file i915_gem.c.

void i915_gem_init_swizzling ( struct drm_device dev)

Definition at line 3858 of file i915_gem.c.

void i915_gem_l3_remap ( struct drm_device dev)

Definition at line 3826 of file i915_gem.c.

void i915_gem_lastclose ( struct drm_device dev)

Definition at line 4137 of file i915_gem.c.

int i915_gem_leavevt_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

Definition at line 4126 of file i915_gem.c.

void i915_gem_load ( struct drm_device dev)

Definition at line 4157 of file i915_gem.c.

int i915_gem_madvise_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

Definition at line 3616 of file i915_gem.c.

int i915_gem_mmap_gtt ( struct drm_file *  file,
struct drm_device dev,
uint32_t  handle,
uint64_t offset 
)

Definition at line 1560 of file i915_gem.c.

int i915_gem_mmap_gtt_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 1619 of file i915_gem.c.

int i915_gem_mmap_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Maps the contents of an object, returning the address it is mapped into.

While the mapping holds a reference on the contents of the object, it doesn't imply a ref on the object itself.

Definition at line 1280 of file i915_gem.c.

u32 i915_gem_next_request_seqno ( struct intel_ring_buffer ring)

Definition at line 1950 of file i915_gem.c.

int i915_gem_object_finish_gpu ( struct drm_i915_gem_object obj)

Definition at line 3318 of file i915_gem.c.

int i915_gem_object_get_fence ( struct drm_i915_gem_object obj)

i915_gem_object_get_fence - set up fencing for an object : object to map through a fence reg

When mapping objects through the GTT, userspace wants to be able to write to them without having to worry about swizzling if the object is tiled. This function walks the fence regs looking for a free one for , stealing one if it can't find any.

It then sets up the reg based on the object's properties: address, pitch and tiling format.

For an untiled surface, this removes any existing fence.

Definition at line 2753 of file i915_gem.c.

int i915_gem_object_get_pages ( struct drm_i915_gem_object obj)

Definition at line 1850 of file i915_gem.c.

void i915_gem_object_init ( struct drm_i915_gem_object obj,
const struct drm_i915_gem_object_ops ops 
)

Definition at line 3662 of file i915_gem.c.

void i915_gem_object_move_to_active ( struct drm_i915_gem_object obj,
struct intel_ring_buffer ring,
u32  seqno 
)

Definition at line 1870 of file i915_gem.c.

int i915_gem_object_pin ( struct drm_i915_gem_object obj,
uint32_t  alignment,
bool  map_and_fenceable,
bool  nonblocking 
)

Definition at line 3430 of file i915_gem.c.

int i915_gem_object_pin_to_display_plane ( struct drm_i915_gem_object obj,
u32  alignment,
struct intel_ring_buffer pipelined 
)

Definition at line 3265 of file i915_gem.c.

int i915_gem_object_put_fence ( struct drm_i915_gem_object obj)

Definition at line 2686 of file i915_gem.c.

int i915_gem_object_set_cache_level ( struct drm_i915_gem_object obj,
enum i915_cache_level  cache_level 
)

Definition at line 3122 of file i915_gem.c.

int i915_gem_object_set_to_cpu_domain ( struct drm_i915_gem_object obj,
bool  write 
)

Moves a single object to the CPU read, and possibly write domain.

This function returns when the move is complete, including waiting on flushes to occur.

Definition at line 3341 of file i915_gem.c.

int i915_gem_object_set_to_gtt_domain ( struct drm_i915_gem_object obj,
bool  write 
)

Moves a single object to the GTT read, and possibly write domain.

This function returns when the move is complete, including waiting on flushes to occur.

Definition at line 3078 of file i915_gem.c.

int i915_gem_object_sync ( struct drm_i915_gem_object obj,
struct intel_ring_buffer to 
)

i915_gem_object_sync - sync an object to a ring.

: object which may be in use on another ring. : ring we wish to use the object on. May be NULL.

This code is meant to abstract object synchronization with the GPU. Calling with NULL implies synchronizing the object with the CPU rather than a particular GPU ring.

Returns 0 if successful, else propagates up the lower layer error.

Definition at line 2364 of file i915_gem.c.

int i915_gem_object_unbind ( struct drm_i915_gem_object obj)

Unbinds an object from the GTT aperture.

Definition at line 2422 of file i915_gem.c.

void i915_gem_object_unpin ( struct drm_i915_gem_object obj)

Definition at line 3474 of file i915_gem.c.

int i915_gem_pin_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 3484 of file i915_gem.c.

int i915_gem_pread_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Reads data from the object referenced by handle.

On error, the contents of *data are undefined.

Definition at line 520 of file i915_gem.c.

int i915_gem_pwrite_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Writes data to the object referenced by handle.

On error, the contents of the buffer that were to be modified are undefined.

Definition at line 864 of file i915_gem.c.

void i915_gem_release ( struct drm_device dev,
struct drm_file *  file 
)

Definition at line 4389 of file i915_gem.c.

void i915_gem_release_mmap ( struct drm_i915_gem_object obj)

i915_gem_release_mmap - remove physical page mappings : obj in question

Preserve the reservation of the mmapping with the DRM core code, but relinquish ownership of the pages back to the system.

It is vital that we remove the page mapping if we have mapped a tiled object through the GTT and then lose the fence register due to resource pressure. Similarly if the object has been moved out of the aperture, than pages mapped into userspace must be revoked. Removing the mapping will then trigger a page fault on the next user access, allowing fixup by i915_gem_fault().

Definition at line 1433 of file i915_gem.c.

void i915_gem_reset ( struct drm_device dev)

Definition at line 2103 of file i915_gem.c.

void i915_gem_retire_requests ( struct drm_device dev)

Definition at line 2196 of file i915_gem.c.

void i915_gem_retire_requests_ring ( struct intel_ring_buffer ring)

This function clears the request list as sequence numbers are passed.

Definition at line 2131 of file i915_gem.c.

int i915_gem_set_caching_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 3222 of file i915_gem.c.

int i915_gem_set_domain_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Called when user space prepares to use an object with the CPU, either through the mmap ioctl's mapping or a GTT mapping.

Definition at line 1181 of file i915_gem.c.

int i915_gem_sw_finish_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Called when user space has done writes to this buffer

Definition at line 1245 of file i915_gem.c.

int i915_gem_throttle_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file_priv 
)

Definition at line 3609 of file i915_gem.c.

int i915_gem_unpin_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

Definition at line 3535 of file i915_gem.c.

int i915_gem_wait_ioctl ( struct drm_device dev,
void data,
struct drm_file *  file 
)

i915_gem_wait_ioctl - implements DRM_IOCTL_I915_GEM_WAIT : standard ioctl arguments

Returns 0 if successful, else an error is returned with the remaining time in the timeout parameter. -ETIME: object is still busy after timeout -ERESTARTSYS: signal interrupted the wait -ENONENT: object doesn't exist Also possible, but rare: -EAGAIN: GPU wedged -ENOMEM: damn -ENODEV: Internal IRQ fail -E?: The add request failed

The wait ioctl with a timeout of 0 reimplements the busy ioctl. With any non-zero timeout parameter the wait ioctl will wait for the given number of nanoseconds on an object becoming unbusy. Since the wait itself does so without holding struct_mutex the object may become re-busied before this function completes. A similar but shorter * race condition exists in the busy ioctl

Definition at line 2290 of file i915_gem.c.

int i915_gpu_idle ( struct drm_device dev)

Definition at line 2480 of file i915_gem.c.

int i915_mutex_lock_interruptible ( struct drm_device dev)

Definition at line 126 of file i915_gem.c.

int i915_wait_seqno ( struct intel_ring_buffer ring,
uint32_t  seqno 
)

Waits for a sequence number to be signaled, and cleans up the request and object lists appropriately for that event.

Definition at line 1075 of file i915_gem.c.