Loading...
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2020 HiSilicon Limited.
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/debugfs.h>
9#include <linux/delay.h>
10#include <linux/device.h>
11#include <linux/dma-mapping.h>
12#include <linux/kernel.h>
13#include <linux/kthread.h>
14#include <linux/map_benchmark.h>
15#include <linux/math64.h>
16#include <linux/module.h>
17#include <linux/pci.h>
18#include <linux/platform_device.h>
19#include <linux/slab.h>
20#include <linux/timekeeping.h>
21
22struct map_benchmark_data {
23 struct map_benchmark bparam;
24 struct device *dev;
25 struct dentry *debugfs;
26 enum dma_data_direction dir;
27 atomic64_t sum_map_100ns;
28 atomic64_t sum_unmap_100ns;
29 atomic64_t sum_sq_map;
30 atomic64_t sum_sq_unmap;
31 atomic64_t loops;
32};
33
34static int map_benchmark_thread(void *data)
35{
36 void *buf;
37 dma_addr_t dma_addr;
38 struct map_benchmark_data *map = data;
39 int npages = map->bparam.granule;
40 u64 size = npages * PAGE_SIZE;
41 int ret = 0;
42
43 buf = alloc_pages_exact(size, GFP_KERNEL);
44 if (!buf)
45 return -ENOMEM;
46
47 while (!kthread_should_stop()) {
48 u64 map_100ns, unmap_100ns, map_sq, unmap_sq;
49 ktime_t map_stime, map_etime, unmap_stime, unmap_etime;
50 ktime_t map_delta, unmap_delta;
51
52 /*
53 * for a non-coherent device, if we don't stain them in the
54 * cache, this will give an underestimate of the real-world
55 * overhead of BIDIRECTIONAL or TO_DEVICE mappings;
56 * 66 means evertything goes well! 66 is lucky.
57 */
58 if (map->dir != DMA_FROM_DEVICE)
59 memset(buf, 0x66, size);
60
61 map_stime = ktime_get();
62 dma_addr = dma_map_single(map->dev, buf, size, map->dir);
63 if (unlikely(dma_mapping_error(map->dev, dma_addr))) {
64 pr_err("dma_map_single failed on %s\n",
65 dev_name(map->dev));
66 ret = -ENOMEM;
67 goto out;
68 }
69 map_etime = ktime_get();
70 map_delta = ktime_sub(map_etime, map_stime);
71
72 /* Pretend DMA is transmitting */
73 ndelay(map->bparam.dma_trans_ns);
74
75 unmap_stime = ktime_get();
76 dma_unmap_single(map->dev, dma_addr, size, map->dir);
77 unmap_etime = ktime_get();
78 unmap_delta = ktime_sub(unmap_etime, unmap_stime);
79
80 /* calculate sum and sum of squares */
81
82 map_100ns = div64_ul(map_delta, 100);
83 unmap_100ns = div64_ul(unmap_delta, 100);
84 map_sq = map_100ns * map_100ns;
85 unmap_sq = unmap_100ns * unmap_100ns;
86
87 atomic64_add(map_100ns, &map->sum_map_100ns);
88 atomic64_add(unmap_100ns, &map->sum_unmap_100ns);
89 atomic64_add(map_sq, &map->sum_sq_map);
90 atomic64_add(unmap_sq, &map->sum_sq_unmap);
91 atomic64_inc(&map->loops);
92 }
93
94out:
95 free_pages_exact(buf, size);
96 return ret;
97}
98
99static int do_map_benchmark(struct map_benchmark_data *map)
100{
101 struct task_struct **tsk;
102 int threads = map->bparam.threads;
103 int node = map->bparam.node;
104 const cpumask_t *cpu_mask = cpumask_of_node(node);
105 u64 loops;
106 int ret = 0;
107 int i;
108
109 tsk = kmalloc_array(threads, sizeof(*tsk), GFP_KERNEL);
110 if (!tsk)
111 return -ENOMEM;
112
113 get_device(map->dev);
114
115 for (i = 0; i < threads; i++) {
116 tsk[i] = kthread_create_on_node(map_benchmark_thread, map,
117 map->bparam.node, "dma-map-benchmark/%d", i);
118 if (IS_ERR(tsk[i])) {
119 pr_err("create dma_map thread failed\n");
120 ret = PTR_ERR(tsk[i]);
121 goto out;
122 }
123
124 if (node != NUMA_NO_NODE)
125 kthread_bind_mask(tsk[i], cpu_mask);
126 }
127
128 /* clear the old value in the previous benchmark */
129 atomic64_set(&map->sum_map_100ns, 0);
130 atomic64_set(&map->sum_unmap_100ns, 0);
131 atomic64_set(&map->sum_sq_map, 0);
132 atomic64_set(&map->sum_sq_unmap, 0);
133 atomic64_set(&map->loops, 0);
134
135 for (i = 0; i < threads; i++) {
136 get_task_struct(tsk[i]);
137 wake_up_process(tsk[i]);
138 }
139
140 msleep_interruptible(map->bparam.seconds * 1000);
141
142 /* wait for the completion of benchmark threads */
143 for (i = 0; i < threads; i++) {
144 ret = kthread_stop(tsk[i]);
145 if (ret)
146 goto out;
147 }
148
149 loops = atomic64_read(&map->loops);
150 if (likely(loops > 0)) {
151 u64 map_variance, unmap_variance;
152 u64 sum_map = atomic64_read(&map->sum_map_100ns);
153 u64 sum_unmap = atomic64_read(&map->sum_unmap_100ns);
154 u64 sum_sq_map = atomic64_read(&map->sum_sq_map);
155 u64 sum_sq_unmap = atomic64_read(&map->sum_sq_unmap);
156
157 /* average latency */
158 map->bparam.avg_map_100ns = div64_u64(sum_map, loops);
159 map->bparam.avg_unmap_100ns = div64_u64(sum_unmap, loops);
160
161 /* standard deviation of latency */
162 map_variance = div64_u64(sum_sq_map, loops) -
163 map->bparam.avg_map_100ns *
164 map->bparam.avg_map_100ns;
165 unmap_variance = div64_u64(sum_sq_unmap, loops) -
166 map->bparam.avg_unmap_100ns *
167 map->bparam.avg_unmap_100ns;
168 map->bparam.map_stddev = int_sqrt64(map_variance);
169 map->bparam.unmap_stddev = int_sqrt64(unmap_variance);
170 }
171
172out:
173 for (i = 0; i < threads; i++)
174 put_task_struct(tsk[i]);
175 put_device(map->dev);
176 kfree(tsk);
177 return ret;
178}
179
180static long map_benchmark_ioctl(struct file *file, unsigned int cmd,
181 unsigned long arg)
182{
183 struct map_benchmark_data *map = file->private_data;
184 void __user *argp = (void __user *)arg;
185 u64 old_dma_mask;
186 int ret;
187
188 if (copy_from_user(&map->bparam, argp, sizeof(map->bparam)))
189 return -EFAULT;
190
191 switch (cmd) {
192 case DMA_MAP_BENCHMARK:
193 if (map->bparam.threads == 0 ||
194 map->bparam.threads > DMA_MAP_MAX_THREADS) {
195 pr_err("invalid thread number\n");
196 return -EINVAL;
197 }
198
199 if (map->bparam.seconds == 0 ||
200 map->bparam.seconds > DMA_MAP_MAX_SECONDS) {
201 pr_err("invalid duration seconds\n");
202 return -EINVAL;
203 }
204
205 if (map->bparam.dma_trans_ns > DMA_MAP_MAX_TRANS_DELAY) {
206 pr_err("invalid transmission delay\n");
207 return -EINVAL;
208 }
209
210 if (map->bparam.node != NUMA_NO_NODE &&
211 !node_possible(map->bparam.node)) {
212 pr_err("invalid numa node\n");
213 return -EINVAL;
214 }
215
216 if (map->bparam.granule < 1 || map->bparam.granule > 1024) {
217 pr_err("invalid granule size\n");
218 return -EINVAL;
219 }
220
221 switch (map->bparam.dma_dir) {
222 case DMA_MAP_BIDIRECTIONAL:
223 map->dir = DMA_BIDIRECTIONAL;
224 break;
225 case DMA_MAP_FROM_DEVICE:
226 map->dir = DMA_FROM_DEVICE;
227 break;
228 case DMA_MAP_TO_DEVICE:
229 map->dir = DMA_TO_DEVICE;
230 break;
231 default:
232 pr_err("invalid DMA direction\n");
233 return -EINVAL;
234 }
235
236 old_dma_mask = dma_get_mask(map->dev);
237
238 ret = dma_set_mask(map->dev,
239 DMA_BIT_MASK(map->bparam.dma_bits));
240 if (ret) {
241 pr_err("failed to set dma_mask on device %s\n",
242 dev_name(map->dev));
243 return -EINVAL;
244 }
245
246 ret = do_map_benchmark(map);
247
248 /*
249 * restore the original dma_mask as many devices' dma_mask are
250 * set by architectures, acpi, busses. When we bind them back
251 * to their original drivers, those drivers shouldn't see
252 * dma_mask changed by benchmark
253 */
254 dma_set_mask(map->dev, old_dma_mask);
255 break;
256 default:
257 return -EINVAL;
258 }
259
260 if (copy_to_user(argp, &map->bparam, sizeof(map->bparam)))
261 return -EFAULT;
262
263 return ret;
264}
265
266static const struct file_operations map_benchmark_fops = {
267 .open = simple_open,
268 .unlocked_ioctl = map_benchmark_ioctl,
269};
270
271static void map_benchmark_remove_debugfs(void *data)
272{
273 struct map_benchmark_data *map = (struct map_benchmark_data *)data;
274
275 debugfs_remove(map->debugfs);
276}
277
278static int __map_benchmark_probe(struct device *dev)
279{
280 struct dentry *entry;
281 struct map_benchmark_data *map;
282 int ret;
283
284 map = devm_kzalloc(dev, sizeof(*map), GFP_KERNEL);
285 if (!map)
286 return -ENOMEM;
287 map->dev = dev;
288
289 ret = devm_add_action(dev, map_benchmark_remove_debugfs, map);
290 if (ret) {
291 pr_err("Can't add debugfs remove action\n");
292 return ret;
293 }
294
295 /*
296 * we only permit a device bound with this driver, 2nd probe
297 * will fail
298 */
299 entry = debugfs_create_file("dma_map_benchmark", 0600, NULL, map,
300 &map_benchmark_fops);
301 if (IS_ERR(entry))
302 return PTR_ERR(entry);
303 map->debugfs = entry;
304
305 return 0;
306}
307
308static int map_benchmark_platform_probe(struct platform_device *pdev)
309{
310 return __map_benchmark_probe(&pdev->dev);
311}
312
313static struct platform_driver map_benchmark_platform_driver = {
314 .driver = {
315 .name = "dma_map_benchmark",
316 },
317 .probe = map_benchmark_platform_probe,
318};
319
320static int
321map_benchmark_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
322{
323 return __map_benchmark_probe(&pdev->dev);
324}
325
326static struct pci_driver map_benchmark_pci_driver = {
327 .name = "dma_map_benchmark",
328 .probe = map_benchmark_pci_probe,
329};
330
331static int __init map_benchmark_init(void)
332{
333 int ret;
334
335 ret = pci_register_driver(&map_benchmark_pci_driver);
336 if (ret)
337 return ret;
338
339 ret = platform_driver_register(&map_benchmark_platform_driver);
340 if (ret) {
341 pci_unregister_driver(&map_benchmark_pci_driver);
342 return ret;
343 }
344
345 return 0;
346}
347
348static void __exit map_benchmark_cleanup(void)
349{
350 platform_driver_unregister(&map_benchmark_platform_driver);
351 pci_unregister_driver(&map_benchmark_pci_driver);
352}
353
354module_init(map_benchmark_init);
355module_exit(map_benchmark_cleanup);
356
357MODULE_AUTHOR("Barry Song <song.bao.hua@hisilicon.com>");
358MODULE_DESCRIPTION("dma_map benchmark driver");
359MODULE_LICENSE("GPL");
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2020 HiSilicon Limited.
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/debugfs.h>
9#include <linux/delay.h>
10#include <linux/device.h>
11#include <linux/dma-mapping.h>
12#include <linux/kernel.h>
13#include <linux/kthread.h>
14#include <linux/math64.h>
15#include <linux/module.h>
16#include <linux/pci.h>
17#include <linux/platform_device.h>
18#include <linux/slab.h>
19#include <linux/timekeeping.h>
20
21#define DMA_MAP_BENCHMARK _IOWR('d', 1, struct map_benchmark)
22#define DMA_MAP_MAX_THREADS 1024
23#define DMA_MAP_MAX_SECONDS 300
24#define DMA_MAP_MAX_TRANS_DELAY (10 * NSEC_PER_MSEC)
25
26#define DMA_MAP_BIDIRECTIONAL 0
27#define DMA_MAP_TO_DEVICE 1
28#define DMA_MAP_FROM_DEVICE 2
29
30struct map_benchmark {
31 __u64 avg_map_100ns; /* average map latency in 100ns */
32 __u64 map_stddev; /* standard deviation of map latency */
33 __u64 avg_unmap_100ns; /* as above */
34 __u64 unmap_stddev;
35 __u32 threads; /* how many threads will do map/unmap in parallel */
36 __u32 seconds; /* how long the test will last */
37 __s32 node; /* which numa node this benchmark will run on */
38 __u32 dma_bits; /* DMA addressing capability */
39 __u32 dma_dir; /* DMA data direction */
40 __u32 dma_trans_ns; /* time for DMA transmission in ns */
41 __u32 granule; /* how many PAGE_SIZE will do map/unmap once a time */
42 __u8 expansion[76]; /* For future use */
43};
44
45struct map_benchmark_data {
46 struct map_benchmark bparam;
47 struct device *dev;
48 struct dentry *debugfs;
49 enum dma_data_direction dir;
50 atomic64_t sum_map_100ns;
51 atomic64_t sum_unmap_100ns;
52 atomic64_t sum_sq_map;
53 atomic64_t sum_sq_unmap;
54 atomic64_t loops;
55};
56
57static int map_benchmark_thread(void *data)
58{
59 void *buf;
60 dma_addr_t dma_addr;
61 struct map_benchmark_data *map = data;
62 int npages = map->bparam.granule;
63 u64 size = npages * PAGE_SIZE;
64 int ret = 0;
65
66 buf = alloc_pages_exact(size, GFP_KERNEL);
67 if (!buf)
68 return -ENOMEM;
69
70 while (!kthread_should_stop()) {
71 u64 map_100ns, unmap_100ns, map_sq, unmap_sq;
72 ktime_t map_stime, map_etime, unmap_stime, unmap_etime;
73 ktime_t map_delta, unmap_delta;
74
75 /*
76 * for a non-coherent device, if we don't stain them in the
77 * cache, this will give an underestimate of the real-world
78 * overhead of BIDIRECTIONAL or TO_DEVICE mappings;
79 * 66 means evertything goes well! 66 is lucky.
80 */
81 if (map->dir != DMA_FROM_DEVICE)
82 memset(buf, 0x66, size);
83
84 map_stime = ktime_get();
85 dma_addr = dma_map_single(map->dev, buf, size, map->dir);
86 if (unlikely(dma_mapping_error(map->dev, dma_addr))) {
87 pr_err("dma_map_single failed on %s\n",
88 dev_name(map->dev));
89 ret = -ENOMEM;
90 goto out;
91 }
92 map_etime = ktime_get();
93 map_delta = ktime_sub(map_etime, map_stime);
94
95 /* Pretend DMA is transmitting */
96 ndelay(map->bparam.dma_trans_ns);
97
98 unmap_stime = ktime_get();
99 dma_unmap_single(map->dev, dma_addr, size, map->dir);
100 unmap_etime = ktime_get();
101 unmap_delta = ktime_sub(unmap_etime, unmap_stime);
102
103 /* calculate sum and sum of squares */
104
105 map_100ns = div64_ul(map_delta, 100);
106 unmap_100ns = div64_ul(unmap_delta, 100);
107 map_sq = map_100ns * map_100ns;
108 unmap_sq = unmap_100ns * unmap_100ns;
109
110 atomic64_add(map_100ns, &map->sum_map_100ns);
111 atomic64_add(unmap_100ns, &map->sum_unmap_100ns);
112 atomic64_add(map_sq, &map->sum_sq_map);
113 atomic64_add(unmap_sq, &map->sum_sq_unmap);
114 atomic64_inc(&map->loops);
115 }
116
117out:
118 free_pages_exact(buf, size);
119 return ret;
120}
121
122static int do_map_benchmark(struct map_benchmark_data *map)
123{
124 struct task_struct **tsk;
125 int threads = map->bparam.threads;
126 int node = map->bparam.node;
127 const cpumask_t *cpu_mask = cpumask_of_node(node);
128 u64 loops;
129 int ret = 0;
130 int i;
131
132 tsk = kmalloc_array(threads, sizeof(*tsk), GFP_KERNEL);
133 if (!tsk)
134 return -ENOMEM;
135
136 get_device(map->dev);
137
138 for (i = 0; i < threads; i++) {
139 tsk[i] = kthread_create_on_node(map_benchmark_thread, map,
140 map->bparam.node, "dma-map-benchmark/%d", i);
141 if (IS_ERR(tsk[i])) {
142 pr_err("create dma_map thread failed\n");
143 ret = PTR_ERR(tsk[i]);
144 goto out;
145 }
146
147 if (node != NUMA_NO_NODE)
148 kthread_bind_mask(tsk[i], cpu_mask);
149 }
150
151 /* clear the old value in the previous benchmark */
152 atomic64_set(&map->sum_map_100ns, 0);
153 atomic64_set(&map->sum_unmap_100ns, 0);
154 atomic64_set(&map->sum_sq_map, 0);
155 atomic64_set(&map->sum_sq_unmap, 0);
156 atomic64_set(&map->loops, 0);
157
158 for (i = 0; i < threads; i++) {
159 get_task_struct(tsk[i]);
160 wake_up_process(tsk[i]);
161 }
162
163 msleep_interruptible(map->bparam.seconds * 1000);
164
165 /* wait for the completion of benchmark threads */
166 for (i = 0; i < threads; i++) {
167 ret = kthread_stop(tsk[i]);
168 if (ret)
169 goto out;
170 }
171
172 loops = atomic64_read(&map->loops);
173 if (likely(loops > 0)) {
174 u64 map_variance, unmap_variance;
175 u64 sum_map = atomic64_read(&map->sum_map_100ns);
176 u64 sum_unmap = atomic64_read(&map->sum_unmap_100ns);
177 u64 sum_sq_map = atomic64_read(&map->sum_sq_map);
178 u64 sum_sq_unmap = atomic64_read(&map->sum_sq_unmap);
179
180 /* average latency */
181 map->bparam.avg_map_100ns = div64_u64(sum_map, loops);
182 map->bparam.avg_unmap_100ns = div64_u64(sum_unmap, loops);
183
184 /* standard deviation of latency */
185 map_variance = div64_u64(sum_sq_map, loops) -
186 map->bparam.avg_map_100ns *
187 map->bparam.avg_map_100ns;
188 unmap_variance = div64_u64(sum_sq_unmap, loops) -
189 map->bparam.avg_unmap_100ns *
190 map->bparam.avg_unmap_100ns;
191 map->bparam.map_stddev = int_sqrt64(map_variance);
192 map->bparam.unmap_stddev = int_sqrt64(unmap_variance);
193 }
194
195out:
196 for (i = 0; i < threads; i++)
197 put_task_struct(tsk[i]);
198 put_device(map->dev);
199 kfree(tsk);
200 return ret;
201}
202
203static long map_benchmark_ioctl(struct file *file, unsigned int cmd,
204 unsigned long arg)
205{
206 struct map_benchmark_data *map = file->private_data;
207 void __user *argp = (void __user *)arg;
208 u64 old_dma_mask;
209 int ret;
210
211 if (copy_from_user(&map->bparam, argp, sizeof(map->bparam)))
212 return -EFAULT;
213
214 switch (cmd) {
215 case DMA_MAP_BENCHMARK:
216 if (map->bparam.threads == 0 ||
217 map->bparam.threads > DMA_MAP_MAX_THREADS) {
218 pr_err("invalid thread number\n");
219 return -EINVAL;
220 }
221
222 if (map->bparam.seconds == 0 ||
223 map->bparam.seconds > DMA_MAP_MAX_SECONDS) {
224 pr_err("invalid duration seconds\n");
225 return -EINVAL;
226 }
227
228 if (map->bparam.dma_trans_ns > DMA_MAP_MAX_TRANS_DELAY) {
229 pr_err("invalid transmission delay\n");
230 return -EINVAL;
231 }
232
233 if (map->bparam.node != NUMA_NO_NODE &&
234 !node_possible(map->bparam.node)) {
235 pr_err("invalid numa node\n");
236 return -EINVAL;
237 }
238
239 if (map->bparam.granule < 1 || map->bparam.granule > 1024) {
240 pr_err("invalid granule size\n");
241 return -EINVAL;
242 }
243
244 switch (map->bparam.dma_dir) {
245 case DMA_MAP_BIDIRECTIONAL:
246 map->dir = DMA_BIDIRECTIONAL;
247 break;
248 case DMA_MAP_FROM_DEVICE:
249 map->dir = DMA_FROM_DEVICE;
250 break;
251 case DMA_MAP_TO_DEVICE:
252 map->dir = DMA_TO_DEVICE;
253 break;
254 default:
255 pr_err("invalid DMA direction\n");
256 return -EINVAL;
257 }
258
259 old_dma_mask = dma_get_mask(map->dev);
260
261 ret = dma_set_mask(map->dev,
262 DMA_BIT_MASK(map->bparam.dma_bits));
263 if (ret) {
264 pr_err("failed to set dma_mask on device %s\n",
265 dev_name(map->dev));
266 return -EINVAL;
267 }
268
269 ret = do_map_benchmark(map);
270
271 /*
272 * restore the original dma_mask as many devices' dma_mask are
273 * set by architectures, acpi, busses. When we bind them back
274 * to their original drivers, those drivers shouldn't see
275 * dma_mask changed by benchmark
276 */
277 dma_set_mask(map->dev, old_dma_mask);
278 break;
279 default:
280 return -EINVAL;
281 }
282
283 if (copy_to_user(argp, &map->bparam, sizeof(map->bparam)))
284 return -EFAULT;
285
286 return ret;
287}
288
289static const struct file_operations map_benchmark_fops = {
290 .open = simple_open,
291 .unlocked_ioctl = map_benchmark_ioctl,
292};
293
294static void map_benchmark_remove_debugfs(void *data)
295{
296 struct map_benchmark_data *map = (struct map_benchmark_data *)data;
297
298 debugfs_remove(map->debugfs);
299}
300
301static int __map_benchmark_probe(struct device *dev)
302{
303 struct dentry *entry;
304 struct map_benchmark_data *map;
305 int ret;
306
307 map = devm_kzalloc(dev, sizeof(*map), GFP_KERNEL);
308 if (!map)
309 return -ENOMEM;
310 map->dev = dev;
311
312 ret = devm_add_action(dev, map_benchmark_remove_debugfs, map);
313 if (ret) {
314 pr_err("Can't add debugfs remove action\n");
315 return ret;
316 }
317
318 /*
319 * we only permit a device bound with this driver, 2nd probe
320 * will fail
321 */
322 entry = debugfs_create_file("dma_map_benchmark", 0600, NULL, map,
323 &map_benchmark_fops);
324 if (IS_ERR(entry))
325 return PTR_ERR(entry);
326 map->debugfs = entry;
327
328 return 0;
329}
330
331static int map_benchmark_platform_probe(struct platform_device *pdev)
332{
333 return __map_benchmark_probe(&pdev->dev);
334}
335
336static struct platform_driver map_benchmark_platform_driver = {
337 .driver = {
338 .name = "dma_map_benchmark",
339 },
340 .probe = map_benchmark_platform_probe,
341};
342
343static int
344map_benchmark_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
345{
346 return __map_benchmark_probe(&pdev->dev);
347}
348
349static struct pci_driver map_benchmark_pci_driver = {
350 .name = "dma_map_benchmark",
351 .probe = map_benchmark_pci_probe,
352};
353
354static int __init map_benchmark_init(void)
355{
356 int ret;
357
358 ret = pci_register_driver(&map_benchmark_pci_driver);
359 if (ret)
360 return ret;
361
362 ret = platform_driver_register(&map_benchmark_platform_driver);
363 if (ret) {
364 pci_unregister_driver(&map_benchmark_pci_driver);
365 return ret;
366 }
367
368 return 0;
369}
370
371static void __exit map_benchmark_cleanup(void)
372{
373 platform_driver_unregister(&map_benchmark_platform_driver);
374 pci_unregister_driver(&map_benchmark_pci_driver);
375}
376
377module_init(map_benchmark_init);
378module_exit(map_benchmark_cleanup);
379
380MODULE_AUTHOR("Barry Song <song.bao.hua@hisilicon.com>");
381MODULE_DESCRIPTION("dma_map benchmark driver");
382MODULE_LICENSE("GPL");