summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/drm/i915_mem.c116
1 files changed, 59 insertions, 57 deletions
diff --git a/sys/dev/pci/drm/i915_mem.c b/sys/dev/pci/drm/i915_mem.c
index 536e969da0d..ff806cc0df9 100644
--- a/sys/dev/pci/drm/i915_mem.c
+++ b/sys/dev/pci/drm/i915_mem.c
@@ -49,14 +49,11 @@ void intel_mark_block(struct drm_device *, struct drm_mem *, int);
void
intel_mark_block(struct drm_device * dev, struct drm_mem *p, int in_use)
{
- drm_i915_private_t *dev_priv = dev->dev_private;
- drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv;
- struct drm_tex_region *list;
- unsigned shift, nr;
- unsigned start;
- unsigned end;
- unsigned i;
- int age;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ struct drm_tex_region *list;
+ unsigned shift, nr, start, end, i;
+ int age;
shift = dev_priv->tex_lru_log_granularity;
nr = I915_NR_TEX_REGIONS;
@@ -90,10 +87,11 @@ intel_mark_block(struct drm_device * dev, struct drm_mem *p, int in_use)
/* Free all blocks associated with the releasing file.
*/
-void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
- struct drm_heap *heap)
+void
+i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
+ struct drm_heap *heap)
{
- struct drm_mem *p, *q;
+ struct drm_mem *p, *q;
if (heap == NULL || TAILQ_EMPTY(heap))
return;
@@ -120,9 +118,10 @@ void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
/* Shutdown.
*/
-void i915_mem_takedown(struct drm_heap *heap)
+void
+i915_mem_takedown(struct drm_heap *heap)
{
- struct drm_mem *p;
+ struct drm_mem *p;
if (heap == NULL)
return;
@@ -138,9 +137,9 @@ intel_get_heap(drm_i915_private_t * dev_priv, int region)
{
switch (region) {
case I915_MEM_REGION_AGP:
- return &dev_priv->agp_heap;
+ return (&dev_priv->agp_heap);
default:
- return NULL;
+ return (NULL);
}
}
@@ -149,19 +148,19 @@ intel_get_heap(drm_i915_private_t * dev_priv, int region)
int i915_mem_alloc(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
- drm_i915_private_t *dev_priv = dev->dev_private;
- drm_i915_mem_alloc_t *alloc = data;
- struct drm_heap *heap;
- struct drm_mem *block;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ drm_i915_mem_alloc_t *alloc = data;
+ struct drm_heap *heap;
+ struct drm_mem *block;
- if (!dev_priv) {
+ if (dev_priv == NULL) {
DRM_ERROR("called with no initialization\n");
- return EINVAL;
+ return (EINVAL);
}
heap = intel_get_heap(dev_priv, alloc->region);
if (heap == NULL)
- return EFAULT;
+ return (EFAULT);
/* Make things easier on ourselves: all allocations at least
* 4k aligned.
@@ -172,91 +171,94 @@ int i915_mem_alloc(struct drm_device *dev, void *data,
block = drm_alloc_block(heap, alloc->size, alloc->alignment, file_priv);
if (block == NULL)
- return ENOMEM;
+ return (ENOMEM);
intel_mark_block(dev, block, 1);
if (DRM_COPY_TO_USER(alloc->region_offset, &block->start,
sizeof(int))) {
DRM_ERROR("copy_to_user\n");
- return EFAULT;
+ return (EFAULT);
}
- return 0;
+ return (0);
}
-int i915_mem_free(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+int
+i915_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
- drm_i915_private_t *dev_priv = dev->dev_private;
- drm_i915_mem_free_t *memfree = data;
- struct drm_heap *heap;
- struct drm_mem *block;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ drm_i915_mem_free_t *memfree = data;
+ struct drm_heap *heap;
+ struct drm_mem *block;
- if (!dev_priv) {
+ if (dev_priv == NULL) {
DRM_ERROR("called with no initialization\n");
- return EINVAL;
+ return (EINVAL);
}
heap = intel_get_heap(dev_priv, memfree->region);
if (heap == NULL)
- return EFAULT;
+ return (EFAULT);
block = drm_find_block(heap, memfree->region_offset);
if (block == NULL)
- return EFAULT;
+ return (EFAULT);
if (block->file_priv != file_priv)
- return EPERM;
+ return (EPERM);
intel_mark_block(dev, block, 0);
drm_free_block(heap, block);
- return 0;
+
+ return (0);
}
-int i915_mem_init_heap(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+int
+i915_mem_init_heap(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
- drm_i915_private_t *dev_priv = dev->dev_private;
- drm_i915_mem_init_heap_t *initheap = data;
- struct drm_heap *heap;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ drm_i915_mem_init_heap_t *initheap = data;
+ struct drm_heap *heap;
- if (!dev_priv) {
+ if (dev_priv == NULL) {
DRM_ERROR("called with no initialization\n");
- return EINVAL;
+ return (EINVAL);
}
/* Make sure it's valid and initialised */
heap = intel_get_heap(dev_priv, initheap->region);
if (heap == NULL || !TAILQ_EMPTY(heap))
- return EFAULT;
+ return (EFAULT);
- return drm_init_heap(heap, initheap->start, initheap->size);
+ return (drm_init_heap(heap, initheap->start, initheap->size));
}
-int i915_mem_destroy_heap( struct drm_device *dev, void *data,
- struct drm_file *file_priv )
+int
+i915_mem_destroy_heap( struct drm_device *dev, void *data,
+ struct drm_file *file_priv )
{
- drm_i915_private_t *dev_priv = dev->dev_private;
- drm_i915_mem_destroy_heap_t *destroyheap = data;
- struct drm_heap *heap;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ drm_i915_mem_destroy_heap_t *destroyheap = data;
+ struct drm_heap *heap;
- if (!dev_priv) {
+ if (dev_priv == NULL) {
DRM_ERROR( "called with no initialization\n" );
- return EINVAL;
+ return (EINVAL);
}
heap = intel_get_heap( dev_priv, destroyheap->region );
- if (!heap) {
+ if (heap == NULL) {
DRM_ERROR("intel_get_heap failed");
- return EFAULT;
+ return (EFAULT);
}
if (TAILQ_EMPTY(heap)) {
DRM_ERROR("heap not initialized?");
- return EFAULT;
+ return (EFAULT);
}
i915_mem_takedown(heap);
- return 0;
+ return (0);
}