ASoC: Fix Blackfin I2S _pointer() implementation return in bounds values
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / gma500 / psb_fence.c
bloba70aa64f2cadb686930e4bbcddbc14f712ae5e40
1 /*
2 * Copyright (c) 2007, Intel Corporation.
3 * All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
22 #include <drm/drmP.h>
23 #include "psb_drv.h"
26 static void psb_fence_poll(struct ttm_fence_device *fdev,
27 uint32_t fence_class, uint32_t waiting_types)
29 struct drm_psb_private *dev_priv =
30 container_of(fdev, struct drm_psb_private, fdev);
33 if (unlikely(!dev_priv))
34 return;
36 if (waiting_types == 0)
37 return;
39 /* DRM_ERROR("Polling fence sequence, got 0x%08x\n", sequence); */
40 ttm_fence_handler(fdev, fence_class, 0 /* Sequence */,
41 _PSB_FENCE_TYPE_EXE, 0);
44 void psb_fence_error(struct drm_device *dev,
45 uint32_t fence_class,
46 uint32_t sequence, uint32_t type, int error)
48 struct drm_psb_private *dev_priv = psb_priv(dev);
49 struct ttm_fence_device *fdev = &dev_priv->fdev;
50 unsigned long irq_flags;
51 struct ttm_fence_class_manager *fc =
52 &fdev->fence_class[fence_class];
54 BUG_ON(fence_class >= PSB_NUM_ENGINES);
55 write_lock_irqsave(&fc->lock, irq_flags);
56 ttm_fence_handler(fdev, fence_class, sequence, type, error);
57 write_unlock_irqrestore(&fc->lock, irq_flags);
60 int psb_fence_emit_sequence(struct ttm_fence_device *fdev,
61 uint32_t fence_class,
62 uint32_t flags, uint32_t *sequence,
63 unsigned long *timeout_jiffies)
65 struct drm_psb_private *dev_priv =
66 container_of(fdev, struct drm_psb_private, fdev);
68 if (!dev_priv)
69 return -EINVAL;
71 if (fence_class >= PSB_NUM_ENGINES)
72 return -EINVAL;
74 DRM_ERROR("Unexpected fence class\n");
75 return -EINVAL;
78 static void psb_fence_lockup(struct ttm_fence_object *fence,
79 uint32_t fence_types)
81 DRM_ERROR("Unsupported fence class\n");
84 void psb_fence_handler(struct drm_device *dev, uint32_t fence_class)
86 struct drm_psb_private *dev_priv = psb_priv(dev);
87 struct ttm_fence_device *fdev = &dev_priv->fdev;
88 struct ttm_fence_class_manager *fc =
89 &fdev->fence_class[fence_class];
90 unsigned long irq_flags;
92 write_lock_irqsave(&fc->lock, irq_flags);
93 psb_fence_poll(fdev, fence_class, fc->waiting_types);
94 write_unlock_irqrestore(&fc->lock, irq_flags);
98 static struct ttm_fence_driver psb_ttm_fence_driver = {
99 .has_irq = NULL,
100 .emit = psb_fence_emit_sequence,
101 .flush = NULL,
102 .poll = psb_fence_poll,
103 .needed_flush = NULL,
104 .wait = NULL,
105 .signaled = NULL,
106 .lockup = psb_fence_lockup,
109 int psb_ttm_fence_device_init(struct ttm_fence_device *fdev)
111 struct drm_psb_private *dev_priv =
112 container_of(fdev, struct drm_psb_private, fdev);
113 struct ttm_fence_class_init fci = {.wrap_diff = (1 << 30),
114 .flush_diff = (1 << 29),
115 .sequence_mask = 0xFFFFFFFF
118 return ttm_fence_device_init(PSB_NUM_ENGINES,
119 dev_priv->mem_global_ref.object,
120 fdev, &fci, 1,
121 &psb_ttm_fence_driver);