diff options
author | Jerome Glisse <jglisse@redhat.com> | 2009-06-05 08:42:42 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-06-14 22:01:53 -0400 |
commit | 771fe6b912fca54f03e8a72eb63058b582775362 (patch) | |
tree | 58aa5469ba8058c2b564d50807395ad6cd7bd7e4 /drivers/gpu/drm/radeon/radeon_benchmark.c | |
parent | ba4e7d973dd09b66912ac4c0856add8b0703a997 (diff) |
drm/radeon: introduce kernel modesetting for radeon hardware
Add kernel modesetting support to radeon driver, use the ttm memory
manager to manage memory and DRM/GEM to provide userspace API.
In order to avoid backward compatibility issue and to allow clean
design and code the radeon kernel modesetting use different code path
than old radeon/drm driver.
When kernel modesetting is enabled the IOCTL of radeon/drm
driver are considered as invalid and an error message is printed
in the log and they return failure.
KMS enabled userspace will use new API to talk with the radeon/drm
driver. The new API provide functions to create/destroy/share/mmap
buffer object which are then managed by the kernel memory manager
(here TTM). In order to submit command to the GPU the userspace
provide a buffer holding the command stream, along this buffer
userspace have to provide a list of buffer object used by the
command stream. The kernel radeon driver will then place buffer
in GPU accessible memory and will update command stream to reflect
the position of the different buffers.
The kernel will also perform security check on command stream
provided by the user, we want to catch and forbid any illegal use
of the GPU such as DMA into random system memory or into memory
not owned by the process supplying the command stream. This part
of the code is still incomplete and this why we propose that patch
as a staging driver addition, future security might forbid current
experimental userspace to run.
This code support the following hardware : R1XX,R2XX,R3XX,R4XX,R5XX
(radeon up to X1950). Works is underway to provide support for R6XX,
R7XX and newer hardware (radeon from HD2XXX to HD4XXX).
Authors:
Jerome Glisse <jglisse@redhat.com>
Dave Airlie <airlied@redhat.com>
Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_benchmark.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_benchmark.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_benchmark.c b/drivers/gpu/drm/radeon/radeon_benchmark.c new file mode 100644 index 000000000000..c44403a2ca76 --- /dev/null +++ b/drivers/gpu/drm/radeon/radeon_benchmark.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * Copyright 2009 Jerome Glisse. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
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 NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Jerome Glisse | ||
23 | */ | ||
24 | #include <drm/drmP.h> | ||
25 | #include <drm/radeon_drm.h> | ||
26 | #include "radeon_reg.h" | ||
27 | #include "radeon.h" | ||
28 | |||
29 | void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize, | ||
30 | unsigned sdomain, unsigned ddomain) | ||
31 | { | ||
32 | struct radeon_object *dobj = NULL; | ||
33 | struct radeon_object *sobj = NULL; | ||
34 | struct radeon_fence *fence = NULL; | ||
35 | uint64_t saddr, daddr; | ||
36 | unsigned long start_jiffies; | ||
37 | unsigned long end_jiffies; | ||
38 | unsigned long time; | ||
39 | unsigned i, n, size; | ||
40 | int r; | ||
41 | |||
42 | size = bsize; | ||
43 | n = 1024; | ||
44 | r = radeon_object_create(rdev, NULL, size, true, sdomain, false, &sobj); | ||
45 | if (r) { | ||
46 | goto out_cleanup; | ||
47 | } | ||
48 | r = radeon_object_pin(sobj, sdomain, &saddr); | ||
49 | if (r) { | ||
50 | goto out_cleanup; | ||
51 | } | ||
52 | r = radeon_object_create(rdev, NULL, size, true, ddomain, false, &dobj); | ||
53 | if (r) { | ||
54 | goto out_cleanup; | ||
55 | } | ||
56 | r = radeon_object_pin(dobj, ddomain, &daddr); | ||
57 | if (r) { | ||
58 | goto out_cleanup; | ||
59 | } | ||
60 | start_jiffies = jiffies; | ||
61 | for (i = 0; i < n; i++) { | ||
62 | r = radeon_fence_create(rdev, &fence); | ||
63 | if (r) { | ||
64 | goto out_cleanup; | ||
65 | } | ||
66 | r = radeon_copy_dma(rdev, saddr, daddr, size >> 14, fence); | ||
67 | if (r) { | ||
68 | goto out_cleanup; | ||
69 | } | ||
70 | r = radeon_fence_wait(fence, false); | ||
71 | if (r) { | ||
72 | goto out_cleanup; | ||
73 | } | ||
74 | radeon_fence_unref(&fence); | ||
75 | } | ||
76 | end_jiffies = jiffies; | ||
77 | time = end_jiffies - start_jiffies; | ||
78 | time = jiffies_to_msecs(time); | ||
79 | if (time > 0) { | ||
80 | i = ((n * size) >> 10) / time; | ||
81 | printk(KERN_INFO "radeon: dma %u bo moves of %ukb from %d to %d" | ||
82 | " in %lums (%ukb/ms %ukb/s %uM/s)\n", n, size >> 10, | ||
83 | sdomain, ddomain, time, i, i * 1000, (i * 1000) / 1024); | ||
84 | } | ||
85 | start_jiffies = jiffies; | ||
86 | for (i = 0; i < n; i++) { | ||
87 | r = radeon_fence_create(rdev, &fence); | ||
88 | if (r) { | ||
89 | goto out_cleanup; | ||
90 | } | ||
91 | r = radeon_copy_blit(rdev, saddr, daddr, size >> 14, fence); | ||
92 | if (r) { | ||
93 | goto out_cleanup; | ||
94 | } | ||
95 | r = radeon_fence_wait(fence, false); | ||
96 | if (r) { | ||
97 | goto out_cleanup; | ||
98 | } | ||
99 | radeon_fence_unref(&fence); | ||
100 | } | ||
101 | end_jiffies = jiffies; | ||
102 | time = end_jiffies - start_jiffies; | ||
103 | time = jiffies_to_msecs(time); | ||
104 | if (time > 0) { | ||
105 | i = ((n * size) >> 10) / time; | ||
106 | printk(KERN_INFO "radeon: blit %u bo moves of %ukb from %d to %d" | ||
107 | " in %lums (%ukb/ms %ukb/s %uM/s)\n", n, size >> 10, | ||
108 | sdomain, ddomain, time, i, i * 1000, (i * 1000) / 1024); | ||
109 | } | ||
110 | out_cleanup: | ||
111 | if (sobj) { | ||
112 | radeon_object_unpin(sobj); | ||
113 | radeon_object_unref(&sobj); | ||
114 | } | ||
115 | if (dobj) { | ||
116 | radeon_object_unpin(dobj); | ||
117 | radeon_object_unref(&dobj); | ||
118 | } | ||
119 | if (fence) { | ||
120 | radeon_fence_unref(&fence); | ||
121 | } | ||
122 | if (r) { | ||
123 | printk(KERN_WARNING "Error while benchmarking BO move.\n"); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | void radeon_benchmark(struct radeon_device *rdev) | ||
128 | { | ||
129 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_GTT, | ||
130 | RADEON_GEM_DOMAIN_VRAM); | ||
131 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_VRAM, | ||
132 | RADEON_GEM_DOMAIN_GTT); | ||
133 | } | ||