Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Virtual Processor Dispatch Trace Log |
| 3 | * |
| 4 | * (C) Copyright IBM Corporation 2009 |
| 5 | * |
| 6 | * Author: Jeremy Kerr <jk@ozlabs.org> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | */ |
| 22 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 23 | #include <linux/slab.h> |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 24 | #include <linux/debugfs.h> |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 25 | #include <linux/spinlock.h> |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 26 | #include <asm/smp.h> |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 27 | #include <asm/uaccess.h> |
Sachin Sant | b71a0c2 | 2009-04-14 14:35:55 +0000 | [diff] [blame] | 28 | #include <asm/firmware.h> |
Paul Mackerras | cf9efce | 2010-08-26 19:56:43 +0000 | [diff] [blame] | 29 | #include <asm/lppaca.h> |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 30 | #include <asm/debug.h> |
Deepthi Dharwar | 212bebb | 2013-08-22 15:23:52 +0530 | [diff] [blame] | 31 | #include <asm/plpar_wrappers.h> |
Michael Ellerman | 8e83e90 | 2014-07-16 12:02:43 +1000 | [diff] [blame] | 32 | #include <asm/machdep.h> |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 33 | |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 34 | struct dtl { |
| 35 | struct dtl_entry *buf; |
| 36 | struct dentry *file; |
| 37 | int cpu; |
| 38 | int buf_entries; |
| 39 | u64 last_idx; |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 40 | spinlock_t lock; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 41 | }; |
Tejun Heo | 6b7487f | 2009-10-29 22:34:14 +0900 | [diff] [blame] | 42 | static DEFINE_PER_CPU(struct dtl, cpu_dtl); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 43 | |
| 44 | /* |
| 45 | * Dispatch trace log event mask: |
| 46 | * 0x7: 0x1: voluntary virtual processor waits |
| 47 | * 0x2: time-slice preempts |
| 48 | * 0x4: virtual partition memory page faults |
| 49 | */ |
| 50 | static u8 dtl_event_mask = 0x7; |
| 51 | |
| 52 | |
| 53 | /* |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 54 | * Size of per-cpu log buffers. Firmware requires that the buffer does |
| 55 | * not cross a 4k boundary. |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 56 | */ |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 57 | static int dtl_buf_entries = N_DISPATCH_LOG; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 58 | |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 59 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 60 | struct dtl_ring { |
| 61 | u64 write_index; |
| 62 | struct dtl_entry *write_ptr; |
| 63 | struct dtl_entry *buf; |
| 64 | struct dtl_entry *buf_end; |
| 65 | u8 saved_dtl_mask; |
| 66 | }; |
| 67 | |
| 68 | static DEFINE_PER_CPU(struct dtl_ring, dtl_rings); |
| 69 | |
| 70 | static atomic_t dtl_count; |
| 71 | |
| 72 | /* |
| 73 | * The cpu accounting code controls the DTL ring buffer, and we get |
| 74 | * given entries as they are processed. |
| 75 | */ |
| 76 | static void consume_dtle(struct dtl_entry *dtle, u64 index) |
| 77 | { |
Christoph Lameter | 69111ba | 2014-10-21 15:23:25 -0500 | [diff] [blame] | 78 | struct dtl_ring *dtlr = this_cpu_ptr(&dtl_rings); |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 79 | struct dtl_entry *wp = dtlr->write_ptr; |
| 80 | struct lppaca *vpa = local_paca->lppaca_ptr; |
| 81 | |
| 82 | if (!wp) |
| 83 | return; |
| 84 | |
| 85 | *wp = *dtle; |
| 86 | barrier(); |
| 87 | |
| 88 | /* check for hypervisor ring buffer overflow, ignore this entry if so */ |
Anton Blanchard | 7ffcf8e | 2013-08-07 02:01:46 +1000 | [diff] [blame] | 89 | if (index + N_DISPATCH_LOG < be64_to_cpu(vpa->dtl_idx)) |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 90 | return; |
| 91 | |
| 92 | ++wp; |
| 93 | if (wp == dtlr->buf_end) |
| 94 | wp = dtlr->buf; |
| 95 | dtlr->write_ptr = wp; |
| 96 | |
| 97 | /* incrementing write_index makes the new entry visible */ |
| 98 | smp_wmb(); |
| 99 | ++dtlr->write_index; |
| 100 | } |
| 101 | |
| 102 | static int dtl_start(struct dtl *dtl) |
| 103 | { |
| 104 | struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu); |
| 105 | |
| 106 | dtlr->buf = dtl->buf; |
| 107 | dtlr->buf_end = dtl->buf + dtl->buf_entries; |
| 108 | dtlr->write_index = 0; |
| 109 | |
| 110 | /* setting write_ptr enables logging into our buffer */ |
| 111 | smp_wmb(); |
| 112 | dtlr->write_ptr = dtl->buf; |
| 113 | |
| 114 | /* enable event logging */ |
| 115 | dtlr->saved_dtl_mask = lppaca_of(dtl->cpu).dtl_enable_mask; |
| 116 | lppaca_of(dtl->cpu).dtl_enable_mask |= dtl_event_mask; |
| 117 | |
| 118 | dtl_consumer = consume_dtle; |
| 119 | atomic_inc(&dtl_count); |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | static void dtl_stop(struct dtl *dtl) |
| 124 | { |
| 125 | struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu); |
| 126 | |
| 127 | dtlr->write_ptr = NULL; |
| 128 | smp_wmb(); |
| 129 | |
| 130 | dtlr->buf = NULL; |
| 131 | |
| 132 | /* restore dtl_enable_mask */ |
| 133 | lppaca_of(dtl->cpu).dtl_enable_mask = dtlr->saved_dtl_mask; |
| 134 | |
| 135 | if (atomic_dec_and_test(&dtl_count)) |
| 136 | dtl_consumer = NULL; |
| 137 | } |
| 138 | |
| 139 | static u64 dtl_current_index(struct dtl *dtl) |
| 140 | { |
| 141 | return per_cpu(dtl_rings, dtl->cpu).write_index; |
| 142 | } |
| 143 | |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 144 | #else /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 145 | |
| 146 | static int dtl_start(struct dtl *dtl) |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 147 | { |
| 148 | unsigned long addr; |
| 149 | int ret, hwcpu; |
| 150 | |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 151 | /* Register our dtl buffer with the hypervisor. The HV expects the |
| 152 | * buffer size to be passed in the second word of the buffer */ |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 153 | ((u32 *)dtl->buf)[1] = DISPATCH_LOG_BYTES; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 154 | |
| 155 | hwcpu = get_hard_smp_processor_id(dtl->cpu); |
| 156 | addr = __pa(dtl->buf); |
| 157 | ret = register_dtl(hwcpu, addr); |
| 158 | if (ret) { |
| 159 | printk(KERN_WARNING "%s: DTL registration for cpu %d (hw %d) " |
| 160 | "failed with %d\n", __func__, dtl->cpu, hwcpu, ret); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 161 | return -EIO; |
| 162 | } |
| 163 | |
| 164 | /* set our initial buffer indices */ |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 165 | lppaca_of(dtl->cpu).dtl_idx = 0; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 166 | |
Jeremy Kerr | 82631f5 | 2009-03-23 16:55:08 +0000 | [diff] [blame] | 167 | /* ensure that our updates to the lppaca fields have occurred before |
| 168 | * we actually enable the logging */ |
| 169 | smp_wmb(); |
| 170 | |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 171 | /* enable event logging */ |
Paul Mackerras | 8154c5d | 2010-08-12 20:18:15 +0000 | [diff] [blame] | 172 | lppaca_of(dtl->cpu).dtl_enable_mask = dtl_event_mask; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 173 | |
| 174 | return 0; |
| 175 | } |
| 176 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 177 | static void dtl_stop(struct dtl *dtl) |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 178 | { |
| 179 | int hwcpu = get_hard_smp_processor_id(dtl->cpu); |
| 180 | |
Paul Mackerras | 8154c5d | 2010-08-12 20:18:15 +0000 | [diff] [blame] | 181 | lppaca_of(dtl->cpu).dtl_enable_mask = 0x0; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 182 | |
Anton Blanchard | b130179 | 2011-07-25 01:46:32 +0000 | [diff] [blame] | 183 | unregister_dtl(hwcpu); |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 184 | } |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 185 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 186 | static u64 dtl_current_index(struct dtl *dtl) |
| 187 | { |
| 188 | return lppaca_of(dtl->cpu).dtl_idx; |
| 189 | } |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 190 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 191 | |
| 192 | static int dtl_enable(struct dtl *dtl) |
| 193 | { |
| 194 | long int n_entries; |
| 195 | long int rc; |
| 196 | struct dtl_entry *buf = NULL; |
| 197 | |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 198 | if (!dtl_cache) |
| 199 | return -ENOMEM; |
| 200 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 201 | /* only allow one reader */ |
| 202 | if (dtl->buf) |
| 203 | return -EBUSY; |
| 204 | |
| 205 | n_entries = dtl_buf_entries; |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 206 | buf = kmem_cache_alloc_node(dtl_cache, GFP_KERNEL, cpu_to_node(dtl->cpu)); |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 207 | if (!buf) { |
| 208 | printk(KERN_WARNING "%s: buffer alloc failed for cpu %d\n", |
| 209 | __func__, dtl->cpu); |
| 210 | return -ENOMEM; |
| 211 | } |
| 212 | |
| 213 | spin_lock(&dtl->lock); |
| 214 | rc = -EBUSY; |
| 215 | if (!dtl->buf) { |
| 216 | /* store the original allocation size for use during read */ |
| 217 | dtl->buf_entries = n_entries; |
| 218 | dtl->buf = buf; |
| 219 | dtl->last_idx = 0; |
| 220 | rc = dtl_start(dtl); |
| 221 | if (rc) |
| 222 | dtl->buf = NULL; |
| 223 | } |
| 224 | spin_unlock(&dtl->lock); |
| 225 | |
| 226 | if (rc) |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 227 | kmem_cache_free(dtl_cache, buf); |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 228 | return rc; |
| 229 | } |
| 230 | |
| 231 | static void dtl_disable(struct dtl *dtl) |
| 232 | { |
| 233 | spin_lock(&dtl->lock); |
| 234 | dtl_stop(dtl); |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 235 | kmem_cache_free(dtl_cache, dtl->buf); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 236 | dtl->buf = NULL; |
| 237 | dtl->buf_entries = 0; |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 238 | spin_unlock(&dtl->lock); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* file interface */ |
| 242 | |
| 243 | static int dtl_file_open(struct inode *inode, struct file *filp) |
| 244 | { |
| 245 | struct dtl *dtl = inode->i_private; |
| 246 | int rc; |
| 247 | |
| 248 | rc = dtl_enable(dtl); |
| 249 | if (rc) |
| 250 | return rc; |
| 251 | |
| 252 | filp->private_data = dtl; |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | static int dtl_file_release(struct inode *inode, struct file *filp) |
| 257 | { |
| 258 | struct dtl *dtl = inode->i_private; |
| 259 | dtl_disable(dtl); |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len, |
| 264 | loff_t *pos) |
| 265 | { |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 266 | long int rc, n_read, n_req, read_size; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 267 | struct dtl *dtl; |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 268 | u64 cur_idx, last_idx, i; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 269 | |
| 270 | if ((len % sizeof(struct dtl_entry)) != 0) |
| 271 | return -EINVAL; |
| 272 | |
| 273 | dtl = filp->private_data; |
| 274 | |
| 275 | /* requested number of entries to read */ |
| 276 | n_req = len / sizeof(struct dtl_entry); |
| 277 | |
| 278 | /* actual number of entries read */ |
| 279 | n_read = 0; |
| 280 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 281 | spin_lock(&dtl->lock); |
| 282 | |
| 283 | cur_idx = dtl_current_index(dtl); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 284 | last_idx = dtl->last_idx; |
| 285 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 286 | if (last_idx + dtl->buf_entries <= cur_idx) |
| 287 | last_idx = cur_idx - dtl->buf_entries + 1; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 288 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 289 | if (last_idx + n_req > cur_idx) |
| 290 | n_req = cur_idx - last_idx; |
| 291 | |
| 292 | if (n_req > 0) |
| 293 | dtl->last_idx = last_idx + n_req; |
| 294 | |
| 295 | spin_unlock(&dtl->lock); |
| 296 | |
| 297 | if (n_req <= 0) |
| 298 | return 0; |
| 299 | |
| 300 | i = last_idx % dtl->buf_entries; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 301 | |
| 302 | /* read the tail of the buffer if we've wrapped */ |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 303 | if (i + n_req > dtl->buf_entries) { |
| 304 | read_size = dtl->buf_entries - i; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 305 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 306 | rc = copy_to_user(buf, &dtl->buf[i], |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 307 | read_size * sizeof(struct dtl_entry)); |
| 308 | if (rc) |
| 309 | return -EFAULT; |
| 310 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 311 | i = 0; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 312 | n_req -= read_size; |
| 313 | n_read += read_size; |
| 314 | buf += read_size * sizeof(struct dtl_entry); |
| 315 | } |
| 316 | |
| 317 | /* .. and now the head */ |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 318 | rc = copy_to_user(buf, &dtl->buf[i], n_req * sizeof(struct dtl_entry)); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 319 | if (rc) |
| 320 | return -EFAULT; |
| 321 | |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 322 | n_read += n_req; |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 323 | |
| 324 | return n_read * sizeof(struct dtl_entry); |
| 325 | } |
| 326 | |
Alexey Dobriyan | 828c095 | 2009-10-01 15:43:56 -0700 | [diff] [blame] | 327 | static const struct file_operations dtl_fops = { |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 328 | .open = dtl_file_open, |
| 329 | .release = dtl_file_release, |
| 330 | .read = dtl_file_read, |
| 331 | .llseek = no_llseek, |
| 332 | }; |
| 333 | |
| 334 | static struct dentry *dtl_dir; |
| 335 | |
| 336 | static int dtl_setup_file(struct dtl *dtl) |
| 337 | { |
| 338 | char name[10]; |
| 339 | |
| 340 | sprintf(name, "cpu-%d", dtl->cpu); |
| 341 | |
| 342 | dtl->file = debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops); |
| 343 | if (!dtl->file) |
| 344 | return -ENOMEM; |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | static int dtl_init(void) |
| 350 | { |
| 351 | struct dentry *event_mask_file, *buf_entries_file; |
| 352 | int rc, i; |
| 353 | |
| 354 | if (!firmware_has_feature(FW_FEATURE_SPLPAR)) |
| 355 | return -ENODEV; |
| 356 | |
| 357 | /* set up common debugfs structure */ |
| 358 | |
| 359 | rc = -ENOMEM; |
| 360 | dtl_dir = debugfs_create_dir("dtl", powerpc_debugfs_root); |
| 361 | if (!dtl_dir) { |
| 362 | printk(KERN_WARNING "%s: can't create dtl root dir\n", |
| 363 | __func__); |
| 364 | goto err; |
| 365 | } |
| 366 | |
| 367 | event_mask_file = debugfs_create_x8("dtl_event_mask", 0600, |
| 368 | dtl_dir, &dtl_event_mask); |
Nishanth Aravamudan | af442a1 | 2011-05-04 12:54:16 +0000 | [diff] [blame] | 369 | buf_entries_file = debugfs_create_u32("dtl_buf_entries", 0400, |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 370 | dtl_dir, &dtl_buf_entries); |
| 371 | |
| 372 | if (!event_mask_file || !buf_entries_file) { |
| 373 | printk(KERN_WARNING "%s: can't create dtl files\n", __func__); |
| 374 | goto err_remove_dir; |
| 375 | } |
| 376 | |
| 377 | /* set up the per-cpu log structures */ |
| 378 | for_each_possible_cpu(i) { |
Tejun Heo | 6b7487f | 2009-10-29 22:34:14 +0900 | [diff] [blame] | 379 | struct dtl *dtl = &per_cpu(cpu_dtl, i); |
Paul Mackerras | 872e439 | 2010-08-31 01:59:53 +0000 | [diff] [blame] | 380 | spin_lock_init(&dtl->lock); |
Jeremy Kerr | fc59a3f | 2009-03-11 17:55:52 +0000 | [diff] [blame] | 381 | dtl->cpu = i; |
| 382 | |
| 383 | rc = dtl_setup_file(dtl); |
| 384 | if (rc) |
| 385 | goto err_remove_dir; |
| 386 | } |
| 387 | |
| 388 | return 0; |
| 389 | |
| 390 | err_remove_dir: |
| 391 | debugfs_remove_recursive(dtl_dir); |
| 392 | err: |
| 393 | return rc; |
| 394 | } |
Michael Ellerman | 8e83e90 | 2014-07-16 12:02:43 +1000 | [diff] [blame] | 395 | machine_arch_initcall(pseries, dtl_init); |