1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
29 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
34 #include "radeon_drm.h"
35 #include "radeon_drv.h"
37 int radeon_fence_emit_sequence(struct drm_device *dev, uint32_t class,
38 uint32_t flags, uint32_t *sequence,
39 uint32_t *native_type)
41 struct drm_radeon_private *dev_priv = (struct drm_radeon_private *) dev->dev_private;
48 *sequence = (uint32_t) dev_priv->counter;
49 *native_type = DRM_FENCE_TYPE_EXE;
54 static void radeon_fence_poll(struct drm_device *dev, uint32_t fence_class,
55 uint32_t waiting_types)
57 struct drm_radeon_private *dev_priv = (struct drm_radeon_private *) dev->dev_private;
59 if (waiting_types & DRM_FENCE_TYPE_EXE) {
61 sequence = READ_BREADCRUMB(dev_priv);
63 drm_fence_handler(dev, 0, sequence,
64 DRM_FENCE_TYPE_EXE, 0);
68 void radeon_fence_handler(struct drm_device * dev)
70 struct drm_fence_manager *fm = &dev->fm;
71 struct drm_fence_class_manager *fc = &fm->fence_class[0];
73 write_lock(&fm->lock);
74 radeon_fence_poll(dev, 0, fc->waiting_types);
75 write_unlock(&fm->lock);
78 int radeon_fence_has_irq(struct drm_device *dev, uint32_t class, uint32_t flags)
81 * We have an irq that tells us when we have a new breadcrumb.
87 struct drm_fence_driver radeon_fence_driver = {
89 .wrap_diff = (1U << (BREADCRUMB_BITS -1)),
90 .flush_diff = (1U << (BREADCRUMB_BITS - 2)),
91 .sequence_mask = BREADCRUMB_MASK,
92 .emit = radeon_fence_emit_sequence,
93 .has_irq = radeon_fence_has_irq,
94 .poll = radeon_fence_poll,