hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/powerpc/platforms/pseries/dlpar.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Support for dynamic reconfiguration for PCI, Memory, and CPU
34 * Hotplug and Dynamic Logical Partitioning on RPA platforms.
45 *
56 * Copyright (C) 2009 Nathan Fontenot
67 * Copyright (C) 2009 IBM Corporation
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License version
10
- * 2 as published by the Free Software Foundation.
118 */
129
1310 #define pr_fmt(fmt) "dlpar: " fmt
....@@ -32,8 +29,6 @@
3229 struct pseries_hp_work {
3330 struct work_struct work;
3431 struct pseries_hp_errorlog *errlog;
35
- struct completion *hp_completion;
36
- int *rc;
3732 };
3833
3934 struct cc_workarea {
....@@ -334,7 +329,7 @@
334329 return 0;
335330 }
336331
337
-static int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog)
332
+int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog)
338333 {
339334 int rc;
340335
....@@ -362,6 +357,10 @@
362357 case PSERIES_HP_ELOG_RESOURCE_CPU:
363358 rc = dlpar_cpu(hp_elog);
364359 break;
360
+ case PSERIES_HP_ELOG_RESOURCE_PMEM:
361
+ rc = dlpar_hp_pmem(hp_elog);
362
+ break;
363
+
365364 default:
366365 pr_warn_ratelimited("Invalid resource (%d) specified\n",
367366 hp_elog->resource);
....@@ -376,39 +375,28 @@
376375 struct pseries_hp_work *hp_work =
377376 container_of(work, struct pseries_hp_work, work);
378377
379
- if (hp_work->rc)
380
- *(hp_work->rc) = handle_dlpar_errorlog(hp_work->errlog);
381
- else
382
- handle_dlpar_errorlog(hp_work->errlog);
383
-
384
- if (hp_work->hp_completion)
385
- complete(hp_work->hp_completion);
378
+ handle_dlpar_errorlog(hp_work->errlog);
386379
387380 kfree(hp_work->errlog);
388381 kfree((void *)work);
389382 }
390383
391
-void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog,
392
- struct completion *hotplug_done, int *rc)
384
+void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog)
393385 {
394386 struct pseries_hp_work *work;
395387 struct pseries_hp_errorlog *hp_errlog_copy;
396388
397
- hp_errlog_copy = kmalloc(sizeof(struct pseries_hp_errorlog),
398
- GFP_KERNEL);
399
- memcpy(hp_errlog_copy, hp_errlog, sizeof(struct pseries_hp_errorlog));
389
+ hp_errlog_copy = kmemdup(hp_errlog, sizeof(*hp_errlog), GFP_ATOMIC);
390
+ if (!hp_errlog_copy)
391
+ return;
400392
401
- work = kmalloc(sizeof(struct pseries_hp_work), GFP_KERNEL);
393
+ work = kmalloc(sizeof(struct pseries_hp_work), GFP_ATOMIC);
402394 if (work) {
403395 INIT_WORK((struct work_struct *)work, pseries_hp_work_fn);
404396 work->errlog = hp_errlog_copy;
405
- work->hp_completion = hotplug_done;
406
- work->rc = rc;
407397 queue_work(pseries_hp_wq, (struct work_struct *)work);
408398 } else {
409
- *rc = -ENOMEM;
410399 kfree(hp_errlog_copy);
411
- complete(hotplug_done);
412400 }
413401 }
414402
....@@ -526,18 +514,15 @@
526514 static ssize_t dlpar_store(struct class *class, struct class_attribute *attr,
527515 const char *buf, size_t count)
528516 {
529
- struct pseries_hp_errorlog *hp_elog;
530
- struct completion hotplug_done;
517
+ struct pseries_hp_errorlog hp_elog;
531518 char *argbuf;
532519 char *args;
533520 int rc;
534521
535522 args = argbuf = kstrdup(buf, GFP_KERNEL);
536
- hp_elog = kzalloc(sizeof(*hp_elog), GFP_KERNEL);
537
- if (!hp_elog || !argbuf) {
523
+ if (!argbuf) {
538524 pr_info("Could not allocate resources for DLPAR operation\n");
539525 kfree(argbuf);
540
- kfree(hp_elog);
541526 return -ENOMEM;
542527 }
543528
....@@ -545,25 +530,22 @@
545530 * Parse out the request from the user, this will be in the form:
546531 * <resource> <action> <id_type> <id>
547532 */
548
- rc = dlpar_parse_resource(&args, hp_elog);
533
+ rc = dlpar_parse_resource(&args, &hp_elog);
549534 if (rc)
550535 goto dlpar_store_out;
551536
552
- rc = dlpar_parse_action(&args, hp_elog);
537
+ rc = dlpar_parse_action(&args, &hp_elog);
553538 if (rc)
554539 goto dlpar_store_out;
555540
556
- rc = dlpar_parse_id_type(&args, hp_elog);
541
+ rc = dlpar_parse_id_type(&args, &hp_elog);
557542 if (rc)
558543 goto dlpar_store_out;
559544
560
- init_completion(&hotplug_done);
561
- queue_hotplug_event(hp_elog, &hotplug_done, &rc);
562
- wait_for_completion(&hotplug_done);
545
+ rc = handle_dlpar_errorlog(&hp_elog);
563546
564547 dlpar_store_out:
565548 kfree(argbuf);
566
- kfree(hp_elog);
567549
568550 if (rc)
569551 pr_err("Could not handle DLPAR request \"%s\"\n", buf);