GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / parisc / kernel / perf.c
blob1d4ad3d4e8ecef51a32b4e47097e3dfefe35ae6e
1 /*
2 * Parisc performance counters
3 * Copyright (C) 2001 Randolph Chung <tausq@debian.org>
5 * This code is derived, with permission, from HP/UX sources.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Edited comment from original sources:
25 * This driver programs the PCX-U/PCX-W performance counters
26 * on the PA-RISC 2.0 chips. The driver keeps all images now
27 * internally to the kernel to hopefully eliminate the possibility
28 * of a bad image halting the CPU. Also, there are different
29 * images for the PCX-W and later chips vs the PCX-U chips.
31 * Only 1 process is allowed to access the driver at any time,
32 * so the only protection that is needed is at open and close.
33 * A variable "perf_enabled" is used to hold the state of the
34 * driver. The spinlock "perf_lock" is used to protect the
35 * modification of the state during open/close operations so
36 * multiple processes don't get into the driver simultaneously.
38 * This driver accesses the processor directly vs going through
39 * the PDC INTRIGUE calls. This is done to eliminate bugs introduced
40 * in various PDC revisions. The code is much more maintainable
41 * and reliable this way vs having to debug on every version of PDC
42 * on every box.
45 #include <linux/capability.h>
46 #include <linux/init.h>
47 #include <linux/proc_fs.h>
48 #include <linux/miscdevice.h>
49 #include <linux/smp_lock.h>
50 #include <linux/spinlock.h>
52 #include <asm/uaccess.h>
53 #include <asm/perf.h>
54 #include <asm/parisc-device.h>
55 #include <asm/processor.h>
56 #include <asm/runway.h>
57 #include <asm/io.h> /* for __raw_read() */
59 #include "perf_images.h"
61 #define MAX_RDR_WORDS 24
62 #define PERF_VERSION 2 /* derived from hpux's PI v2 interface */
64 /* definition of RDR regs */
65 struct rdr_tbl_ent {
66 uint16_t width;
67 uint8_t num_words;
68 uint8_t write_control;
71 static int perf_processor_interface __read_mostly = UNKNOWN_INTF;
72 static int perf_enabled __read_mostly;
73 static spinlock_t perf_lock;
74 struct parisc_device *cpu_device __read_mostly;
76 /* RDRs to write for PCX-W */
77 static const int perf_rdrs_W[] =
78 { 0, 1, 4, 5, 6, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
80 /* RDRs to write for PCX-U */
81 static const int perf_rdrs_U[] =
82 { 0, 1, 4, 5, 6, 7, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
84 /* RDR register descriptions for PCX-W */
85 static const struct rdr_tbl_ent perf_rdr_tbl_W[] = {
86 { 19, 1, 8 }, /* RDR 0 */
87 { 16, 1, 16 }, /* RDR 1 */
88 { 72, 2, 0 }, /* RDR 2 */
89 { 81, 2, 0 }, /* RDR 3 */
90 { 328, 6, 0 }, /* RDR 4 */
91 { 160, 3, 0 }, /* RDR 5 */
92 { 336, 6, 0 }, /* RDR 6 */
93 { 164, 3, 0 }, /* RDR 7 */
94 { 0, 0, 0 }, /* RDR 8 */
95 { 35, 1, 0 }, /* RDR 9 */
96 { 6, 1, 0 }, /* RDR 10 */
97 { 18, 1, 0 }, /* RDR 11 */
98 { 13, 1, 0 }, /* RDR 12 */
99 { 8, 1, 0 }, /* RDR 13 */
100 { 8, 1, 0 }, /* RDR 14 */
101 { 8, 1, 0 }, /* RDR 15 */
102 { 1530, 24, 0 }, /* RDR 16 */
103 { 16, 1, 0 }, /* RDR 17 */
104 { 4, 1, 0 }, /* RDR 18 */
105 { 0, 0, 0 }, /* RDR 19 */
106 { 152, 3, 24 }, /* RDR 20 */
107 { 152, 3, 24 }, /* RDR 21 */
108 { 233, 4, 48 }, /* RDR 22 */
109 { 233, 4, 48 }, /* RDR 23 */
110 { 71, 2, 0 }, /* RDR 24 */
111 { 71, 2, 0 }, /* RDR 25 */
112 { 11, 1, 0 }, /* RDR 26 */
113 { 18, 1, 0 }, /* RDR 27 */
114 { 128, 2, 0 }, /* RDR 28 */
115 { 0, 0, 0 }, /* RDR 29 */
116 { 16, 1, 0 }, /* RDR 30 */
117 { 16, 1, 0 }, /* RDR 31 */
120 /* RDR register descriptions for PCX-U */
121 static const struct rdr_tbl_ent perf_rdr_tbl_U[] = {
122 { 19, 1, 8 }, /* RDR 0 */
123 { 32, 1, 16 }, /* RDR 1 */
124 { 20, 1, 0 }, /* RDR 2 */
125 { 0, 0, 0 }, /* RDR 3 */
126 { 344, 6, 0 }, /* RDR 4 */
127 { 176, 3, 0 }, /* RDR 5 */
128 { 336, 6, 0 }, /* RDR 6 */
129 { 0, 0, 0 }, /* RDR 7 */
130 { 0, 0, 0 }, /* RDR 8 */
131 { 0, 0, 0 }, /* RDR 9 */
132 { 28, 1, 0 }, /* RDR 10 */
133 { 33, 1, 0 }, /* RDR 11 */
134 { 0, 0, 0 }, /* RDR 12 */
135 { 230, 4, 0 }, /* RDR 13 */
136 { 32, 1, 0 }, /* RDR 14 */
137 { 128, 2, 0 }, /* RDR 15 */
138 { 1494, 24, 0 }, /* RDR 16 */
139 { 18, 1, 0 }, /* RDR 17 */
140 { 4, 1, 0 }, /* RDR 18 */
141 { 0, 0, 0 }, /* RDR 19 */
142 { 158, 3, 24 }, /* RDR 20 */
143 { 158, 3, 24 }, /* RDR 21 */
144 { 194, 4, 48 }, /* RDR 22 */
145 { 194, 4, 48 }, /* RDR 23 */
146 { 71, 2, 0 }, /* RDR 24 */
147 { 71, 2, 0 }, /* RDR 25 */
148 { 28, 1, 0 }, /* RDR 26 */
149 { 33, 1, 0 }, /* RDR 27 */
150 { 88, 2, 0 }, /* RDR 28 */
151 { 32, 1, 0 }, /* RDR 29 */
152 { 24, 1, 0 }, /* RDR 30 */
153 { 16, 1, 0 }, /* RDR 31 */
157 * A non-zero write_control in the above tables is a byte offset into
158 * this array.
160 static const uint64_t perf_bitmasks[] = {
161 0x0000000000000000ul, /* first dbl word must be zero */
162 0xfdffe00000000000ul, /* RDR0 bitmask */
163 0x003f000000000000ul, /* RDR1 bitmask */
164 0x00fffffffffffffful, /* RDR20-RDR21 bitmask (152 bits) */
165 0xfffffffffffffffful,
166 0xfffffffc00000000ul,
167 0xfffffffffffffffful, /* RDR22-RDR23 bitmask (233 bits) */
168 0xfffffffffffffffful,
169 0xfffffffffffffffcul,
170 0xff00000000000000ul
174 * Write control bitmasks for Pa-8700 processor given
175 * some things have changed slightly.
177 static const uint64_t perf_bitmasks_piranha[] = {
178 0x0000000000000000ul, /* first dbl word must be zero */
179 0xfdffe00000000000ul, /* RDR0 bitmask */
180 0x003f000000000000ul, /* RDR1 bitmask */
181 0x00fffffffffffffful, /* RDR20-RDR21 bitmask (158 bits) */
182 0xfffffffffffffffful,
183 0xfffffffc00000000ul,
184 0xfffffffffffffffful, /* RDR22-RDR23 bitmask (210 bits) */
185 0xfffffffffffffffful,
186 0xfffffffffffffffful,
187 0xfffc000000000000ul
190 static const uint64_t *bitmask_array; /* array of bitmasks to use */
192 /******************************************************************************
193 * Function Prototypes
194 *****************************************************************************/
195 static int perf_config(uint32_t *image_ptr);
196 static int perf_release(struct inode *inode, struct file *file);
197 static int perf_open(struct inode *inode, struct file *file);
198 static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos);
199 static ssize_t perf_write(struct file *file, const char __user *buf, size_t count,
200 loff_t *ppos);
201 static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
202 static void perf_start_counters(void);
203 static int perf_stop_counters(uint32_t *raddr);
204 static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num);
205 static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer);
206 static int perf_rdr_clear(uint32_t rdr_num);
207 static int perf_write_image(uint64_t *memaddr);
208 static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer);
210 /* External Assembly Routines */
211 extern uint64_t perf_rdr_shift_in_W (uint32_t rdr_num, uint16_t width);
212 extern uint64_t perf_rdr_shift_in_U (uint32_t rdr_num, uint16_t width);
213 extern void perf_rdr_shift_out_W (uint32_t rdr_num, uint64_t buffer);
214 extern void perf_rdr_shift_out_U (uint32_t rdr_num, uint64_t buffer);
215 extern void perf_intrigue_enable_perf_counters (void);
216 extern void perf_intrigue_disable_perf_counters (void);
218 /******************************************************************************
219 * Function Definitions
220 *****************************************************************************/
224 * configure:
226 * Configure the cpu with a given data image. First turn off the counters,
227 * then download the image, then turn the counters back on.
229 static int perf_config(uint32_t *image_ptr)
231 long error;
232 uint32_t raddr[4];
234 /* Stop the counters*/
235 error = perf_stop_counters(raddr);
236 if (error != 0) {
237 printk("perf_config: perf_stop_counters = %ld\n", error);
238 return -EINVAL;
241 printk("Preparing to write image\n");
242 /* Write the image to the chip */
243 error = perf_write_image((uint64_t *)image_ptr);
244 if (error != 0) {
245 printk("perf_config: DOWNLOAD = %ld\n", error);
246 return -EINVAL;
249 printk("Preparing to start counters\n");
251 /* Start the counters */
252 perf_start_counters();
254 return sizeof(uint32_t);
258 * Open the device and initialize all of its memory. The device is only
259 * opened once, but can be "queried" by multiple processes that know its
260 * file descriptor.
262 static int perf_open(struct inode *inode, struct file *file)
264 lock_kernel();
265 spin_lock(&perf_lock);
266 if (perf_enabled) {
267 spin_unlock(&perf_lock);
268 unlock_kernel();
269 return -EBUSY;
271 perf_enabled = 1;
272 spin_unlock(&perf_lock);
273 unlock_kernel();
275 return 0;
279 * Close the device.
281 static int perf_release(struct inode *inode, struct file *file)
283 spin_lock(&perf_lock);
284 perf_enabled = 0;
285 spin_unlock(&perf_lock);
287 return 0;
291 * Read does nothing for this driver
293 static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos)
295 return 0;
299 * write:
301 * This routine downloads the image to the chip. It must be
302 * called on the processor that the download should happen
303 * on.
305 static ssize_t perf_write(struct file *file, const char __user *buf, size_t count,
306 loff_t *ppos)
308 int err;
309 size_t image_size;
310 uint32_t image_type;
311 uint32_t interface_type;
312 uint32_t test;
314 if (perf_processor_interface == ONYX_INTF)
315 image_size = PCXU_IMAGE_SIZE;
316 else if (perf_processor_interface == CUDA_INTF)
317 image_size = PCXW_IMAGE_SIZE;
318 else
319 return -EFAULT;
321 if (!capable(CAP_SYS_ADMIN))
322 return -EACCES;
324 if (count != sizeof(uint32_t))
325 return -EIO;
327 if ((err = copy_from_user(&image_type, buf, sizeof(uint32_t))) != 0)
328 return err;
330 /* Get the interface type and test type */
331 interface_type = (image_type >> 16) & 0xffff;
332 test = (image_type & 0xffff);
334 /* Make sure everything makes sense */
336 /* First check the machine type is correct for
337 the requested image */
338 if (((perf_processor_interface == CUDA_INTF) &&
339 (interface_type != CUDA_INTF)) ||
340 ((perf_processor_interface == ONYX_INTF) &&
341 (interface_type != ONYX_INTF)))
342 return -EINVAL;
344 /* Next check to make sure the requested image
345 is valid */
346 if (((interface_type == CUDA_INTF) &&
347 (test >= MAX_CUDA_IMAGES)) ||
348 ((interface_type == ONYX_INTF) &&
349 (test >= MAX_ONYX_IMAGES)))
350 return -EINVAL;
352 /* Copy the image into the processor */
353 if (interface_type == CUDA_INTF)
354 return perf_config(cuda_images[test]);
355 else
356 return perf_config(onyx_images[test]);
358 return count;
362 * Patch the images that need to know the IVA addresses.
364 static void perf_patch_images(void)
370 * ioctl routine
371 * All routines effect the processor that they are executed on. Thus you
372 * must be running on the processor that you wish to change.
375 static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
377 long error_start;
378 uint32_t raddr[4];
379 int error = 0;
381 switch (cmd) {
383 case PA_PERF_ON:
384 /* Start the counters */
385 perf_start_counters();
386 break;
388 case PA_PERF_OFF:
389 error_start = perf_stop_counters(raddr);
390 if (error_start != 0) {
391 printk(KERN_ERR "perf_off: perf_stop_counters = %ld\n", error_start);
392 error = -EFAULT;
393 break;
396 /* copy out the Counters */
397 if (copy_to_user((void __user *)arg, raddr,
398 sizeof (raddr)) != 0) {
399 error = -EFAULT;
400 break;
402 break;
404 case PA_PERF_VERSION:
405 /* Return the version # */
406 error = put_user(PERF_VERSION, (int *)arg);
407 break;
409 default:
410 error = -ENOTTY;
413 return error;
416 static const struct file_operations perf_fops = {
417 .llseek = no_llseek,
418 .read = perf_read,
419 .write = perf_write,
420 .unlocked_ioctl = perf_ioctl,
421 .compat_ioctl = perf_ioctl,
422 .open = perf_open,
423 .release = perf_release
426 static struct miscdevice perf_dev = {
427 MISC_DYNAMIC_MINOR,
428 PA_PERF_DEV,
429 &perf_fops
433 * Initialize the module
435 static int __init perf_init(void)
437 int ret;
439 /* Determine correct processor interface to use */
440 bitmask_array = perf_bitmasks;
442 if (boot_cpu_data.cpu_type == pcxu ||
443 boot_cpu_data.cpu_type == pcxu_) {
444 perf_processor_interface = ONYX_INTF;
445 } else if (boot_cpu_data.cpu_type == pcxw ||
446 boot_cpu_data.cpu_type == pcxw_ ||
447 boot_cpu_data.cpu_type == pcxw2 ||
448 boot_cpu_data.cpu_type == mako ||
449 boot_cpu_data.cpu_type == mako2) {
450 perf_processor_interface = CUDA_INTF;
451 if (boot_cpu_data.cpu_type == pcxw2 ||
452 boot_cpu_data.cpu_type == mako ||
453 boot_cpu_data.cpu_type == mako2)
454 bitmask_array = perf_bitmasks_piranha;
455 } else {
456 perf_processor_interface = UNKNOWN_INTF;
457 printk("Performance monitoring counters not supported on this processor\n");
458 return -ENODEV;
461 ret = misc_register(&perf_dev);
462 if (ret) {
463 printk(KERN_ERR "Performance monitoring counters: "
464 "cannot register misc device.\n");
465 return ret;
468 /* Patch the images to match the system */
469 perf_patch_images();
471 spin_lock_init(&perf_lock);
473 /* TODO: this only lets us access the first cpu.. what to do for SMP? */
474 cpu_device = per_cpu(cpu_data, 0).dev;
475 printk("Performance monitoring counters enabled for %s\n",
476 per_cpu(cpu_data, 0).dev->name);
478 return 0;
482 * perf_start_counters(void)
484 * Start the counters.
486 static void perf_start_counters(void)
488 /* Enable performance monitor counters */
489 perf_intrigue_enable_perf_counters();
493 * perf_stop_counters
495 * Stop the performance counters and save counts
496 * in a per_processor array.
498 static int perf_stop_counters(uint32_t *raddr)
500 uint64_t userbuf[MAX_RDR_WORDS];
502 /* Disable performance counters */
503 perf_intrigue_disable_perf_counters();
505 if (perf_processor_interface == ONYX_INTF) {
506 uint64_t tmp64;
508 * Read the counters
510 if (!perf_rdr_read_ubuf(16, userbuf))
511 return -13;
513 /* Counter0 is bits 1398 to 1429 */
514 tmp64 = (userbuf[21] << 22) & 0x00000000ffc00000;
515 tmp64 |= (userbuf[22] >> 42) & 0x00000000003fffff;
516 /* OR sticky0 (bit 1430) to counter0 bit 32 */
517 tmp64 |= (userbuf[22] >> 10) & 0x0000000080000000;
518 raddr[0] = (uint32_t)tmp64;
520 /* Counter1 is bits 1431 to 1462 */
521 tmp64 = (userbuf[22] >> 9) & 0x00000000ffffffff;
522 /* OR sticky1 (bit 1463) to counter1 bit 32 */
523 tmp64 |= (userbuf[22] << 23) & 0x0000000080000000;
524 raddr[1] = (uint32_t)tmp64;
526 /* Counter2 is bits 1464 to 1495 */
527 tmp64 = (userbuf[22] << 24) & 0x00000000ff000000;
528 tmp64 |= (userbuf[23] >> 40) & 0x0000000000ffffff;
529 /* OR sticky2 (bit 1496) to counter2 bit 32 */
530 tmp64 |= (userbuf[23] >> 8) & 0x0000000080000000;
531 raddr[2] = (uint32_t)tmp64;
533 /* Counter3 is bits 1497 to 1528 */
534 tmp64 = (userbuf[23] >> 7) & 0x00000000ffffffff;
535 /* OR sticky3 (bit 1529) to counter3 bit 32 */
536 tmp64 |= (userbuf[23] << 25) & 0x0000000080000000;
537 raddr[3] = (uint32_t)tmp64;
540 * Zero out the counters
544 * The counters and sticky-bits comprise the last 132 bits
545 * (1398 - 1529) of RDR16 on a U chip. We'll zero these
546 * out the easy way: zero out last 10 bits of dword 21,
547 * all of dword 22 and 58 bits (plus 6 don't care bits) of
548 * dword 23.
550 userbuf[21] &= 0xfffffffffffffc00ul; /* 0 to last 10 bits */
551 userbuf[22] = 0;
552 userbuf[23] = 0;
555 * Write back the zeroed bytes + the image given
556 * the read was destructive.
558 perf_rdr_write(16, userbuf);
559 } else {
562 * Read RDR-15 which contains the counters and sticky bits
564 if (!perf_rdr_read_ubuf(15, userbuf)) {
565 return -13;
569 * Clear out the counters
571 perf_rdr_clear(15);
574 * Copy the counters
576 raddr[0] = (uint32_t)((userbuf[0] >> 32) & 0x00000000ffffffffUL);
577 raddr[1] = (uint32_t)(userbuf[0] & 0x00000000ffffffffUL);
578 raddr[2] = (uint32_t)((userbuf[1] >> 32) & 0x00000000ffffffffUL);
579 raddr[3] = (uint32_t)(userbuf[1] & 0x00000000ffffffffUL);
582 return 0;
586 * perf_rdr_get_entry
588 * Retrieve a pointer to the description of what this
589 * RDR contains.
591 static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num)
593 if (perf_processor_interface == ONYX_INTF) {
594 return &perf_rdr_tbl_U[rdr_num];
595 } else {
596 return &perf_rdr_tbl_W[rdr_num];
601 * perf_rdr_read_ubuf
603 * Read the RDR value into the buffer specified.
605 static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer)
607 uint64_t data, data_mask = 0;
608 uint32_t width, xbits, i;
609 const struct rdr_tbl_ent *tentry;
611 tentry = perf_rdr_get_entry(rdr_num);
612 if ((width = tentry->width) == 0)
613 return 0;
615 /* Clear out buffer */
616 i = tentry->num_words;
617 while (i--) {
618 buffer[i] = 0;
621 /* Check for bits an even number of 64 */
622 if ((xbits = width & 0x03f) != 0) {
623 data_mask = 1;
624 data_mask <<= (64 - xbits);
625 data_mask--;
628 /* Grab all of the data */
629 i = tentry->num_words;
630 while (i--) {
632 if (perf_processor_interface == ONYX_INTF) {
633 data = perf_rdr_shift_in_U(rdr_num, width);
634 } else {
635 data = perf_rdr_shift_in_W(rdr_num, width);
637 if (xbits) {
638 buffer[i] |= (data << (64 - xbits));
639 if (i) {
640 buffer[i-1] |= ((data >> xbits) & data_mask);
642 } else {
643 buffer[i] = data;
647 return 1;
651 * perf_rdr_clear
653 * Zero out the given RDR register
655 static int perf_rdr_clear(uint32_t rdr_num)
657 const struct rdr_tbl_ent *tentry;
658 int32_t i;
660 tentry = perf_rdr_get_entry(rdr_num);
662 if (tentry->width == 0) {
663 return -1;
666 i = tentry->num_words;
667 while (i--) {
668 if (perf_processor_interface == ONYX_INTF) {
669 perf_rdr_shift_out_U(rdr_num, 0UL);
670 } else {
671 perf_rdr_shift_out_W(rdr_num, 0UL);
675 return 0;
680 * perf_write_image
682 * Write the given image out to the processor
684 static int perf_write_image(uint64_t *memaddr)
686 uint64_t buffer[MAX_RDR_WORDS];
687 uint64_t *bptr;
688 uint32_t dwords;
689 const uint32_t *intrigue_rdr;
690 const uint64_t *intrigue_bitmask;
691 uint64_t tmp64;
692 void __iomem *runway;
693 const struct rdr_tbl_ent *tentry;
694 int i;
696 /* Clear out counters */
697 if (perf_processor_interface == ONYX_INTF) {
699 perf_rdr_clear(16);
701 /* Toggle performance monitor */
702 perf_intrigue_enable_perf_counters();
703 perf_intrigue_disable_perf_counters();
705 intrigue_rdr = perf_rdrs_U;
706 } else {
707 perf_rdr_clear(15);
708 intrigue_rdr = perf_rdrs_W;
711 /* Write all RDRs */
712 while (*intrigue_rdr != -1) {
713 tentry = perf_rdr_get_entry(*intrigue_rdr);
714 perf_rdr_read_ubuf(*intrigue_rdr, buffer);
715 bptr = &buffer[0];
716 dwords = tentry->num_words;
717 if (tentry->write_control) {
718 intrigue_bitmask = &bitmask_array[tentry->write_control >> 3];
719 while (dwords--) {
720 tmp64 = *intrigue_bitmask & *memaddr++;
721 tmp64 |= (~(*intrigue_bitmask++)) & *bptr;
722 *bptr++ = tmp64;
724 } else {
725 while (dwords--) {
726 *bptr++ = *memaddr++;
730 perf_rdr_write(*intrigue_rdr, buffer);
731 intrigue_rdr++;
735 * Now copy out the Runway stuff which is not in RDRs
738 if (cpu_device == NULL)
740 printk(KERN_ERR "write_image: cpu_device not yet initialized!\n");
741 return -1;
744 runway = ioremap_nocache(cpu_device->hpa.start, 4096);
746 /* Merge intrigue bits into Runway STATUS 0 */
747 tmp64 = __raw_readq(runway + RUNWAY_STATUS) & 0xffecfffffffffffful;
748 __raw_writeq(tmp64 | (*memaddr++ & 0x0013000000000000ul),
749 runway + RUNWAY_STATUS);
751 /* Write RUNWAY DEBUG registers */
752 for (i = 0; i < 8; i++) {
753 __raw_writeq(*memaddr++, runway + RUNWAY_DEBUG);
756 return 0;
760 * perf_rdr_write
762 * Write the given RDR register with the contents
763 * of the given buffer.
765 static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer)
767 const struct rdr_tbl_ent *tentry;
768 int32_t i;
770 printk("perf_rdr_write\n");
771 tentry = perf_rdr_get_entry(rdr_num);
772 if (tentry->width == 0) { return; }
774 i = tentry->num_words;
775 while (i--) {
776 if (perf_processor_interface == ONYX_INTF) {
777 perf_rdr_shift_out_U(rdr_num, buffer[i]);
778 } else {
779 perf_rdr_shift_out_W(rdr_num, buffer[i]);
782 printk("perf_rdr_write done\n");
785 module_init(perf_init);