blob: 1ae96a8ed7e21f080327d71764589ec00feeaf2b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * PowerPC64 LPAR Configuration Information Driver
3 *
4 * Dave Engebretsen engebret@us.ibm.com
5 * Copyright (c) 2003 Dave Engebretsen
6 * Will Schmidt willschm@us.ibm.com
7 * SPLPAR updates, Copyright (c) 2003 Will Schmidt IBM Corporation.
8 * seq_file updates, Copyright (c) 2004 Will Schmidt IBM Corporation.
9 * Nathan Lynch nathanl@austin.ibm.com
10 * Added lparcfg_write, Copyright (C) 2004 Nathan Lynch IBM Corporation.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 *
17 * This driver creates a proc file at /proc/ppc64/lparcfg which contains
18 * keyword - value pairs that specify the configuration of the partition.
19 */
20
21#include <linux/config.h>
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/errno.h>
25#include <linux/proc_fs.h>
26#include <linux/init.h>
27#include <linux/seq_file.h>
28#include <asm/uaccess.h>
Kelly Daly15b17182005-11-02 11:55:28 +110029#include <asm/iseries/hv_lp_config.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/lppaca.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/hvcall.h>
Stephen Rothwell1ababe12005-08-03 14:35:25 +100032#include <asm/firmware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/rtas.h>
34#include <asm/system.h>
35#include <asm/time.h>
Kelly Daly7b487bb2005-11-02 13:48:25 +110036#include <asm/iseries/it_exp_vpd_panel.h>
Michael Ellerman856509d2005-06-25 14:54:42 -070037#include <asm/prom.h>
Paul Mackerras271c3f32005-11-11 23:04:40 +110038#include <asm/vdso_datapage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40#define MODULE_VERS "1.6"
41#define MODULE_NAME "lparcfg"
42
43/* #define LPARCFG_DEBUG */
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045static struct proc_dir_entry *proc_ppc64_lparcfg;
46#define LPARCFG_BUFF_SIZE 4096
47
48#ifdef CONFIG_PPC_ISERIES
49
50/*
51 * For iSeries legacy systems, the PPA purr function is available from the
52 * emulated_time_base field in the paca.
53 */
54static unsigned long get_purr(void)
55{
56 unsigned long sum_purr = 0;
57 int cpu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59 for_each_cpu(cpu) {
David Gibson3356bb9f72006-01-13 10:26:42 +110060 sum_purr += lppaca[cpu].emulated_time_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#ifdef PURR_DEBUG
63 printk(KERN_INFO "get_purr for cpu (%d) has value (%ld) \n",
David Gibson3356bb9f72006-01-13 10:26:42 +110064 cpu, lppaca[cpu].emulated_time_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#endif
66 }
67 return sum_purr;
68}
69
70#define lparcfg_write NULL
71
David Gibsond3d21762005-11-10 15:26:20 +110072/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 * Methods used to fetch LPAR data when running on an iSeries platform.
74 */
75static int lparcfg_data(struct seq_file *m, void *v)
76{
77 unsigned long pool_id, lp_index;
78 int shared, entitled_capacity, max_entitled_capacity;
79 int processors, max_processors;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 unsigned long purr = get_purr();
81
82 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
83
David Gibson3356bb9f72006-01-13 10:26:42 +110084 shared = (int)(get_lppaca()->shared_proc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 seq_printf(m, "serial_number=%c%c%c%c%c%c%c\n",
86 e2a(xItExtVpdPanel.mfgID[2]),
87 e2a(xItExtVpdPanel.mfgID[3]),
88 e2a(xItExtVpdPanel.systemSerial[1]),
89 e2a(xItExtVpdPanel.systemSerial[2]),
90 e2a(xItExtVpdPanel.systemSerial[3]),
91 e2a(xItExtVpdPanel.systemSerial[4]),
92 e2a(xItExtVpdPanel.systemSerial[5]));
93
94 seq_printf(m, "system_type=%c%c%c%c\n",
95 e2a(xItExtVpdPanel.machineType[0]),
96 e2a(xItExtVpdPanel.machineType[1]),
97 e2a(xItExtVpdPanel.machineType[2]),
98 e2a(xItExtVpdPanel.machineType[3]));
99
100 lp_index = HvLpConfig_getLpIndex();
101 seq_printf(m, "partition_id=%d\n", (int)lp_index);
102
103 seq_printf(m, "system_active_processors=%d\n",
104 (int)HvLpConfig_getSystemPhysicalProcessors());
105
106 seq_printf(m, "system_potential_processors=%d\n",
107 (int)HvLpConfig_getSystemPhysicalProcessors());
108
109 processors = (int)HvLpConfig_getPhysicalProcessors();
110 seq_printf(m, "partition_active_processors=%d\n", processors);
111
112 max_processors = (int)HvLpConfig_getMaxPhysicalProcessors();
113 seq_printf(m, "partition_potential_processors=%d\n", max_processors);
114
115 if (shared) {
116 entitled_capacity = HvLpConfig_getSharedProcUnits();
117 max_entitled_capacity = HvLpConfig_getMaxSharedProcUnits();
118 } else {
119 entitled_capacity = processors * 100;
120 max_entitled_capacity = max_processors * 100;
121 }
122 seq_printf(m, "partition_entitled_capacity=%d\n", entitled_capacity);
123
124 seq_printf(m, "partition_max_entitled_capacity=%d\n",
125 max_entitled_capacity);
126
127 if (shared) {
128 pool_id = HvLpConfig_getSharedPoolIndex();
129 seq_printf(m, "pool=%d\n", (int)pool_id);
130 seq_printf(m, "pool_capacity=%d\n",
131 (int)(HvLpConfig_getNumProcsInSharedPool(pool_id) *
132 100));
133 seq_printf(m, "purr=%ld\n", purr);
134 }
135
136 seq_printf(m, "shared_processor_mode=%d\n", shared);
137
138 return 0;
139}
140#endif /* CONFIG_PPC_ISERIES */
141
142#ifdef CONFIG_PPC_PSERIES
David Gibsond3d21762005-11-10 15:26:20 +1100143/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 * Methods used to fetch LPAR data when running on a pSeries platform.
145 */
Stephen Rothwelld7867952005-11-14 17:14:51 +1100146/* find a better place for this function... */
147static void log_plpar_hcall_return(unsigned long rc, char *tag)
148{
149 if (rc == 0) /* success, return */
150 return;
151/* check for null tag ? */
152 if (rc == H_Hardware)
153 printk(KERN_INFO
154 "plpar-hcall (%s) failed with hardware fault\n", tag);
155 else if (rc == H_Function)
156 printk(KERN_INFO
157 "plpar-hcall (%s) failed; function not allowed\n", tag);
158 else if (rc == H_Authority)
159 printk(KERN_INFO
160 "plpar-hcall (%s) failed; not authorized to this function\n",
161 tag);
162 else if (rc == H_Parameter)
163 printk(KERN_INFO "plpar-hcall (%s) failed; Bad parameter(s)\n",
164 tag);
165 else
166 printk(KERN_INFO
167 "plpar-hcall (%s) failed with unexpected rc(0x%lx)\n",
168 tag, rc);
169
170}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172/*
173 * H_GET_PPP hcall returns info in 4 parms.
174 * entitled_capacity,unallocated_capacity,
175 * aggregation, resource_capability).
176 *
David Gibsond3d21762005-11-10 15:26:20 +1100177 * R4 = Entitled Processor Capacity Percentage.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 * R5 = Unallocated Processor Capacity Percentage.
179 * R6 (AABBCCDDEEFFGGHH).
180 * XXXX - reserved (0)
181 * XXXX - reserved (0)
182 * XXXX - Group Number
183 * XXXX - Pool Number.
184 * R7 (IIJJKKLLMMNNOOPP).
185 * XX - reserved. (0)
186 * XX - bit 0-6 reserved (0). bit 7 is Capped indicator.
187 * XX - variable processor Capacity Weight
188 * XX - Unallocated Variable Processor Capacity Weight.
189 * XXXX - Active processors in Physical Processor Pool.
David Gibsond3d21762005-11-10 15:26:20 +1100190 * XXXX - Processors active on platform.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 */
192static unsigned int h_get_ppp(unsigned long *entitled,
193 unsigned long *unallocated,
194 unsigned long *aggregation,
195 unsigned long *resource)
196{
197 unsigned long rc;
198 rc = plpar_hcall_4out(H_GET_PPP, 0, 0, 0, 0, entitled, unallocated,
199 aggregation, resource);
200
201 log_plpar_hcall_return(rc, "H_GET_PPP");
202
203 return rc;
204}
205
206static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs)
207{
208 unsigned long rc;
209 unsigned long dummy;
210 rc = plpar_hcall(H_PIC, 0, 0, 0, 0, pool_idle_time, num_procs, &dummy);
211
Anton Blanchard8acb8882005-11-11 13:53:11 +1100212 if (rc != H_Authority)
213 log_plpar_hcall_return(rc, "H_PIC");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214}
215
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216/* Track sum of all purrs across all processors. This is used to further */
217/* calculate usage values by different applications */
218
219static unsigned long get_purr(void)
220{
221 unsigned long sum_purr = 0;
222 int cpu;
223 struct cpu_usage *cu;
224
225 for_each_cpu(cpu) {
226 cu = &per_cpu(cpu_usage_array, cpu);
227 sum_purr += cu->current_tb;
228 }
229 return sum_purr;
230}
231
232#define SPLPAR_CHARACTERISTICS_TOKEN 20
233#define SPLPAR_MAXLENGTH 1026*(sizeof(char))
234
235/*
236 * parse_system_parameter_string()
237 * Retrieve the potential_processors, max_entitled_capacity and friends
238 * through the get-system-parameter rtas call. Replace keyword strings as
239 * necessary.
240 */
241static void parse_system_parameter_string(struct seq_file *m)
242{
243 int call_status;
244
245 char *local_buffer = kmalloc(SPLPAR_MAXLENGTH, GFP_KERNEL);
246 if (!local_buffer) {
247 printk(KERN_ERR "%s %s kmalloc failure at line %d \n",
248 __FILE__, __FUNCTION__, __LINE__);
249 return;
250 }
251
252 spin_lock(&rtas_data_buf_lock);
253 memset(rtas_data_buf, 0, SPLPAR_MAXLENGTH);
254 call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
255 NULL,
256 SPLPAR_CHARACTERISTICS_TOKEN,
257 __pa(rtas_data_buf));
258 memcpy(local_buffer, rtas_data_buf, SPLPAR_MAXLENGTH);
259 spin_unlock(&rtas_data_buf_lock);
260
261 if (call_status != 0) {
262 printk(KERN_INFO
263 "%s %s Error calling get-system-parameter (0x%x)\n",
264 __FILE__, __FUNCTION__, call_status);
265 } else {
266 int splpar_strlen;
267 int idx, w_idx;
268 char *workbuffer = kmalloc(SPLPAR_MAXLENGTH, GFP_KERNEL);
269 if (!workbuffer) {
270 printk(KERN_ERR "%s %s kmalloc failure at line %d \n",
271 __FILE__, __FUNCTION__, __LINE__);
David Gibsond3d21762005-11-10 15:26:20 +1100272 kfree(local_buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 return;
274 }
275#ifdef LPARCFG_DEBUG
276 printk(KERN_INFO "success calling get-system-parameter \n");
277#endif
278 splpar_strlen = local_buffer[0] * 16 + local_buffer[1];
279 local_buffer += 2; /* step over strlen value */
280
281 memset(workbuffer, 0, SPLPAR_MAXLENGTH);
282 w_idx = 0;
283 idx = 0;
284 while ((*local_buffer) && (idx < splpar_strlen)) {
285 workbuffer[w_idx++] = local_buffer[idx++];
286 if ((local_buffer[idx] == ',')
287 || (local_buffer[idx] == '\0')) {
288 workbuffer[w_idx] = '\0';
289 if (w_idx) {
290 /* avoid the empty string */
291 seq_printf(m, "%s\n", workbuffer);
292 }
293 memset(workbuffer, 0, SPLPAR_MAXLENGTH);
294 idx++; /* skip the comma */
295 w_idx = 0;
296 } else if (local_buffer[idx] == '=') {
297 /* code here to replace workbuffer contents
298 with different keyword strings */
299 if (0 == strcmp(workbuffer, "MaxEntCap")) {
300 strcpy(workbuffer,
301 "partition_max_entitled_capacity");
302 w_idx = strlen(workbuffer);
303 }
304 if (0 == strcmp(workbuffer, "MaxPlatProcs")) {
305 strcpy(workbuffer,
306 "system_potential_processors");
307 w_idx = strlen(workbuffer);
308 }
309 }
310 }
311 kfree(workbuffer);
312 local_buffer -= 2; /* back up over strlen value */
313 }
314 kfree(local_buffer);
315}
316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317/* Return the number of processors in the system.
318 * This function reads through the device tree and counts
319 * the virtual processors, this does not include threads.
320 */
321static int lparcfg_count_active_processors(void)
322{
323 struct device_node *cpus_dn = NULL;
324 int count = 0;
325
326 while ((cpus_dn = of_find_node_by_type(cpus_dn, "cpu"))) {
327#ifdef LPARCFG_DEBUG
328 printk(KERN_ERR "cpus_dn %p \n", cpus_dn);
329#endif
330 count++;
331 }
332 return count;
333}
334
335static int lparcfg_data(struct seq_file *m, void *v)
336{
337 int partition_potential_processors;
338 int partition_active_processors;
339 struct device_node *rootdn;
340 const char *model = "";
341 const char *system_id = "";
342 unsigned int *lp_index_ptr, lp_index = 0;
343 struct device_node *rtas_node;
344 int *lrdrp;
345
346 rootdn = find_path_device("/");
347 if (rootdn) {
348 model = get_property(rootdn, "model", NULL);
349 system_id = get_property(rootdn, "system-id", NULL);
350 lp_index_ptr = (unsigned int *)
351 get_property(rootdn, "ibm,partition-no", NULL);
352 if (lp_index_ptr)
353 lp_index = *lp_index_ptr;
354 }
355
356 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
357
358 seq_printf(m, "serial_number=%s\n", system_id);
359
360 seq_printf(m, "system_type=%s\n", model);
361
362 seq_printf(m, "partition_id=%d\n", (int)lp_index);
363
364 rtas_node = find_path_device("/rtas");
365 lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity", NULL);
366
367 if (lrdrp == NULL) {
Paul Mackerras271c3f32005-11-11 23:04:40 +1100368 partition_potential_processors = vdso_data->processorCount;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 } else {
370 partition_potential_processors = *(lrdrp + 4);
371 }
372
373 partition_active_processors = lparcfg_count_active_processors();
374
Stephen Rothwell1ababe12005-08-03 14:35:25 +1000375 if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 unsigned long h_entitled, h_unallocated;
377 unsigned long h_aggregation, h_resource;
378 unsigned long pool_idle_time, pool_procs;
379 unsigned long purr;
380
381 h_get_ppp(&h_entitled, &h_unallocated, &h_aggregation,
382 &h_resource);
383
384 seq_printf(m, "R4=0x%lx\n", h_entitled);
385 seq_printf(m, "R5=0x%lx\n", h_unallocated);
386 seq_printf(m, "R6=0x%lx\n", h_aggregation);
387 seq_printf(m, "R7=0x%lx\n", h_resource);
388
389 purr = get_purr();
390
391 /* this call handles the ibm,get-system-parameter contents */
392 parse_system_parameter_string(m);
393
394 seq_printf(m, "partition_entitled_capacity=%ld\n", h_entitled);
395
396 seq_printf(m, "group=%ld\n", (h_aggregation >> 2 * 8) & 0xffff);
397
398 seq_printf(m, "system_active_processors=%ld\n",
399 (h_resource >> 0 * 8) & 0xffff);
400
401 /* pool related entries are apropriate for shared configs */
David Gibson3356bb9f72006-01-13 10:26:42 +1100402 if (lppaca[0].shared_proc) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
404 h_pic(&pool_idle_time, &pool_procs);
405
406 seq_printf(m, "pool=%ld\n",
407 (h_aggregation >> 0 * 8) & 0xffff);
408
409 /* report pool_capacity in percentage */
410 seq_printf(m, "pool_capacity=%ld\n",
411 ((h_resource >> 2 * 8) & 0xffff) * 100);
412
413 seq_printf(m, "pool_idle_time=%ld\n", pool_idle_time);
414
415 seq_printf(m, "pool_num_procs=%ld\n", pool_procs);
416 }
417
418 seq_printf(m, "unallocated_capacity_weight=%ld\n",
419 (h_resource >> 4 * 8) & 0xFF);
420
421 seq_printf(m, "capacity_weight=%ld\n",
422 (h_resource >> 5 * 8) & 0xFF);
423
424 seq_printf(m, "capped=%ld\n", (h_resource >> 6 * 8) & 0x01);
425
426 seq_printf(m, "unallocated_capacity=%ld\n", h_unallocated);
427
428 seq_printf(m, "purr=%ld\n", purr);
429
430 } else { /* non SPLPAR case */
431
432 seq_printf(m, "system_active_processors=%d\n",
433 partition_potential_processors);
434
435 seq_printf(m, "system_potential_processors=%d\n",
436 partition_potential_processors);
437
438 seq_printf(m, "partition_max_entitled_capacity=%d\n",
439 partition_potential_processors * 100);
440
441 seq_printf(m, "partition_entitled_capacity=%d\n",
442 partition_active_processors * 100);
443 }
444
445 seq_printf(m, "partition_active_processors=%d\n",
446 partition_active_processors);
447
448 seq_printf(m, "partition_potential_processors=%d\n",
449 partition_potential_processors);
450
David Gibson3356bb9f72006-01-13 10:26:42 +1100451 seq_printf(m, "shared_processor_mode=%d\n", lppaca[0].shared_proc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
453 return 0;
454}
455
456/*
457 * Interface for changing system parameters (variable capacity weight
458 * and entitled capacity). Format of input is "param_name=value";
459 * anything after value is ignored. Valid parameters at this time are
460 * "partition_entitled_capacity" and "capacity_weight". We use
461 * H_SET_PPP to alter parameters.
462 *
463 * This function should be invoked only on systems with
464 * FW_FEATURE_SPLPAR.
465 */
466static ssize_t lparcfg_write(struct file *file, const char __user * buf,
467 size_t count, loff_t * off)
468{
469 char *kbuf;
470 char *tmp;
471 u64 new_entitled, *new_entitled_ptr = &new_entitled;
472 u8 new_weight, *new_weight_ptr = &new_weight;
473
474 unsigned long current_entitled; /* parameters for h_get_ppp */
475 unsigned long dummy;
476 unsigned long resource;
477 u8 current_weight;
478
479 ssize_t retval = -ENOMEM;
480
481 kbuf = kmalloc(count, GFP_KERNEL);
482 if (!kbuf)
483 goto out;
484
485 retval = -EFAULT;
486 if (copy_from_user(kbuf, buf, count))
487 goto out;
488
489 retval = -EINVAL;
490 kbuf[count - 1] = '\0';
491 tmp = strchr(kbuf, '=');
492 if (!tmp)
493 goto out;
494
495 *tmp++ = '\0';
496
497 if (!strcmp(kbuf, "partition_entitled_capacity")) {
498 char *endp;
499 *new_entitled_ptr = (u64) simple_strtoul(tmp, &endp, 10);
500 if (endp == tmp)
501 goto out;
502 new_weight_ptr = &current_weight;
503 } else if (!strcmp(kbuf, "capacity_weight")) {
504 char *endp;
505 *new_weight_ptr = (u8) simple_strtoul(tmp, &endp, 10);
506 if (endp == tmp)
507 goto out;
508 new_entitled_ptr = &current_entitled;
509 } else
510 goto out;
511
512 /* Get our current parameters */
513 retval = h_get_ppp(&current_entitled, &dummy, &dummy, &resource);
514 if (retval) {
515 retval = -EIO;
516 goto out;
517 }
518
519 current_weight = (resource >> 5 * 8) & 0xFF;
520
521 pr_debug("%s: current_entitled = %lu, current_weight = %lu\n",
522 __FUNCTION__, current_entitled, current_weight);
523
524 pr_debug("%s: new_entitled = %lu, new_weight = %lu\n",
525 __FUNCTION__, *new_entitled_ptr, *new_weight_ptr);
526
527 retval = plpar_hcall_norets(H_SET_PPP, *new_entitled_ptr,
528 *new_weight_ptr);
529
530 if (retval == H_Success || retval == H_Constrained) {
531 retval = count;
532 } else if (retval == H_Busy) {
533 retval = -EBUSY;
534 } else if (retval == H_Hardware) {
535 retval = -EIO;
536 } else if (retval == H_Parameter) {
537 retval = -EINVAL;
538 } else {
539 printk(KERN_WARNING "%s: received unknown hv return code %ld",
540 __FUNCTION__, retval);
541 retval = -EIO;
542 }
543
Anton Blanchard8acb8882005-11-11 13:53:11 +1100544out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 kfree(kbuf);
546 return retval;
547}
548
549#endif /* CONFIG_PPC_PSERIES */
550
551static int lparcfg_open(struct inode *inode, struct file *file)
552{
553 return single_open(file, lparcfg_data, NULL);
554}
555
556struct file_operations lparcfg_fops = {
Anton Blanchard8acb8882005-11-11 13:53:11 +1100557 .owner = THIS_MODULE,
558 .read = seq_read,
559 .open = lparcfg_open,
560 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561};
562
563int __init lparcfg_init(void)
564{
565 struct proc_dir_entry *ent;
Wim Coekaerts71839262005-09-05 20:22:47 -0700566 mode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567
568 /* Allow writing if we have FW_FEATURE_SPLPAR */
Stephen Rothwell1ababe12005-08-03 14:35:25 +1000569 if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 lparcfg_fops.write = lparcfg_write;
571 mode |= S_IWUSR;
572 }
573
574 ent = create_proc_entry("ppc64/lparcfg", mode, NULL);
575 if (ent) {
576 ent->proc_fops = &lparcfg_fops;
577 ent->data = kmalloc(LPARCFG_BUFF_SIZE, GFP_KERNEL);
578 if (!ent->data) {
579 printk(KERN_ERR
580 "Failed to allocate buffer for lparcfg\n");
581 remove_proc_entry("lparcfg", ent->parent);
582 return -ENOMEM;
583 }
584 } else {
585 printk(KERN_ERR "Failed to create ppc64/lparcfg\n");
586 return -EIO;
587 }
588
589 proc_ppc64_lparcfg = ent;
590 return 0;
591}
592
593void __exit lparcfg_cleanup(void)
594{
595 if (proc_ppc64_lparcfg) {
Jesper Juhlb2325fe2005-11-07 01:01:35 -0800596 kfree(proc_ppc64_lparcfg->data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 remove_proc_entry("lparcfg", proc_ppc64_lparcfg->parent);
598 }
599}
600
601module_init(lparcfg_init);
602module_exit(lparcfg_cleanup);
603MODULE_DESCRIPTION("Interface for LPAR configuration data");
604MODULE_AUTHOR("Dave Engebretsen");
605MODULE_LICENSE("GPL");