2010-09-10 17:42:36 +08:00
|
|
|
/*
|
|
|
|
* Support for Partition Mobility/Migration
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Nathan Fontenot
|
|
|
|
* Copyright (C) 2010 IBM Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version
|
|
|
|
* 2 as published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kobject.h>
|
|
|
|
#include <linux/smp.h>
|
2011-05-28 01:27:45 +08:00
|
|
|
#include <linux/stat.h>
|
2010-09-10 17:42:36 +08:00
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/slab.h>
|
2018-07-06 00:24:59 +08:00
|
|
|
#include <linux/stringify.h>
|
2010-09-10 17:42:36 +08:00
|
|
|
|
2014-07-16 10:02:43 +08:00
|
|
|
#include <asm/machdep.h>
|
2010-09-10 17:42:36 +08:00
|
|
|
#include <asm/rtas.h>
|
|
|
|
#include "pseries.h"
|
|
|
|
|
|
|
|
static struct kobject *mobility_kobj;
|
|
|
|
|
|
|
|
struct update_props_workarea {
|
2015-03-05 03:59:33 +08:00
|
|
|
__be32 phandle;
|
|
|
|
__be32 state;
|
|
|
|
__be64 reserved;
|
|
|
|
__be32 nprops;
|
2013-08-15 13:23:47 +08:00
|
|
|
} __packed;
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
#define NODE_ACTION_MASK 0xff000000
|
|
|
|
#define NODE_COUNT_MASK 0x00ffffff
|
|
|
|
|
|
|
|
#define DELETE_DT_NODE 0x01000000
|
|
|
|
#define UPDATE_DT_NODE 0x02000000
|
|
|
|
#define ADD_DT_NODE 0x03000000
|
|
|
|
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
#define MIGRATION_SCOPE (1)
|
2017-01-07 03:28:54 +08:00
|
|
|
#define PRRN_SCOPE -2
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
|
|
|
|
static int mobility_rtas_call(int token, char *buf, s32 scope)
|
2010-09-10 17:42:36 +08:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
spin_lock(&rtas_data_buf_lock);
|
|
|
|
|
|
|
|
memcpy(rtas_data_buf, buf, RTAS_DATA_BUF_SIZE);
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
rc = rtas_call(token, 2, 1, NULL, rtas_data_buf, scope);
|
2010-09-10 17:42:36 +08:00
|
|
|
memcpy(buf, rtas_data_buf, RTAS_DATA_BUF_SIZE);
|
|
|
|
|
|
|
|
spin_unlock(&rtas_data_buf_lock);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
static int delete_dt_node(__be32 phandle)
|
2010-09-10 17:42:36 +08:00
|
|
|
{
|
|
|
|
struct device_node *dn;
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
dn = of_find_node_by_phandle(be32_to_cpu(phandle));
|
2010-09-10 17:42:36 +08:00
|
|
|
if (!dn)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
dlpar_detach_node(dn);
|
2013-08-15 13:23:51 +08:00
|
|
|
of_node_put(dn);
|
2010-09-10 17:42:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int update_dt_property(struct device_node *dn, struct property **prop,
|
|
|
|
const char *name, u32 vd, char *value)
|
|
|
|
{
|
|
|
|
struct property *new_prop = *prop;
|
|
|
|
int more = 0;
|
|
|
|
|
|
|
|
/* A negative 'vd' value indicates that only part of the new property
|
|
|
|
* value is contained in the buffer and we need to call
|
|
|
|
* ibm,update-properties again to get the rest of the value.
|
|
|
|
*
|
|
|
|
* A negative value is also the two's compliment of the actual value.
|
|
|
|
*/
|
|
|
|
if (vd & 0x80000000) {
|
|
|
|
vd = ~vd + 1;
|
|
|
|
more = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_prop) {
|
|
|
|
/* partial property fixup */
|
|
|
|
char *new_data = kzalloc(new_prop->length + vd, GFP_KERNEL);
|
|
|
|
if (!new_data)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memcpy(new_data, new_prop->value, new_prop->length);
|
|
|
|
memcpy(new_data + new_prop->length, value, vd);
|
|
|
|
|
|
|
|
kfree(new_prop->value);
|
|
|
|
new_prop->value = new_data;
|
|
|
|
new_prop->length += vd;
|
|
|
|
} else {
|
|
|
|
new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
|
|
|
|
if (!new_prop)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
new_prop->name = kstrdup(name, GFP_KERNEL);
|
|
|
|
if (!new_prop->name) {
|
|
|
|
kfree(new_prop);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_prop->length = vd;
|
|
|
|
new_prop->value = kzalloc(new_prop->length, GFP_KERNEL);
|
|
|
|
if (!new_prop->value) {
|
|
|
|
kfree(new_prop->name);
|
|
|
|
kfree(new_prop);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(new_prop->value, value, vd);
|
|
|
|
*prop = new_prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!more) {
|
2012-10-03 00:58:46 +08:00
|
|
|
of_update_property(dn, new_prop);
|
2013-08-15 13:23:45 +08:00
|
|
|
*prop = NULL;
|
2010-09-10 17:42:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
static int update_dt_node(__be32 phandle, s32 scope)
|
2010-09-10 17:42:36 +08:00
|
|
|
{
|
|
|
|
struct update_props_workarea *upwa;
|
|
|
|
struct device_node *dn;
|
|
|
|
struct property *prop = NULL;
|
2013-08-15 13:23:46 +08:00
|
|
|
int i, rc, rtas_rc;
|
2010-09-10 17:42:36 +08:00
|
|
|
char *prop_data;
|
|
|
|
char *rtas_buf;
|
|
|
|
int update_properties_token;
|
2015-03-05 03:59:33 +08:00
|
|
|
u32 nprops;
|
2013-04-24 13:49:36 +08:00
|
|
|
u32 vd;
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
update_properties_token = rtas_token("ibm,update-properties");
|
|
|
|
if (update_properties_token == RTAS_UNKNOWN_SERVICE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rtas_buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
|
|
|
|
if (!rtas_buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
dn = of_find_node_by_phandle(be32_to_cpu(phandle));
|
2010-09-10 17:42:36 +08:00
|
|
|
if (!dn) {
|
|
|
|
kfree(rtas_buf);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
upwa = (struct update_props_workarea *)&rtas_buf[0];
|
|
|
|
upwa->phandle = phandle;
|
|
|
|
|
|
|
|
do {
|
2013-08-15 13:23:46 +08:00
|
|
|
rtas_rc = mobility_rtas_call(update_properties_token, rtas_buf,
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
scope);
|
2013-08-15 13:23:46 +08:00
|
|
|
if (rtas_rc < 0)
|
2010-09-10 17:42:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
prop_data = rtas_buf + sizeof(*upwa);
|
2015-03-05 03:59:33 +08:00
|
|
|
nprops = be32_to_cpu(upwa->nprops);
|
2010-09-10 17:42:36 +08:00
|
|
|
|
2013-08-15 13:23:48 +08:00
|
|
|
/* On the first call to ibm,update-properties for a node the
|
|
|
|
* the first property value descriptor contains an empty
|
|
|
|
* property name, the property value length encoded as u32,
|
|
|
|
* and the property value is the node path being updated.
|
2013-04-24 13:49:36 +08:00
|
|
|
*/
|
2013-08-15 13:23:48 +08:00
|
|
|
if (*prop_data == 0) {
|
|
|
|
prop_data++;
|
2015-03-05 03:59:33 +08:00
|
|
|
vd = be32_to_cpu(*(__be32 *)prop_data);
|
2013-08-15 13:23:48 +08:00
|
|
|
prop_data += vd + sizeof(vd);
|
2015-03-05 03:59:33 +08:00
|
|
|
nprops--;
|
2013-08-15 13:23:48 +08:00
|
|
|
}
|
2013-04-24 13:49:36 +08:00
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
for (i = 0; i < nprops; i++) {
|
2010-09-10 17:42:36 +08:00
|
|
|
char *prop_name;
|
|
|
|
|
2013-04-24 13:49:36 +08:00
|
|
|
prop_name = prop_data;
|
2010-09-10 17:42:36 +08:00
|
|
|
prop_data += strlen(prop_name) + 1;
|
2015-03-05 03:59:33 +08:00
|
|
|
vd = be32_to_cpu(*(__be32 *)prop_data);
|
2013-04-24 13:49:36 +08:00
|
|
|
prop_data += sizeof(vd);
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
switch (vd) {
|
|
|
|
case 0x00000000:
|
|
|
|
/* name only property, nothing to do */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x80000000:
|
2016-04-28 13:34:55 +08:00
|
|
|
of_remove_property(dn, of_find_property(dn,
|
|
|
|
prop_name, NULL));
|
2010-09-10 17:42:36 +08:00
|
|
|
prop = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rc = update_dt_property(dn, &prop, prop_name,
|
|
|
|
vd, prop_data);
|
|
|
|
if (rc) {
|
|
|
|
printk(KERN_ERR "Could not update %s"
|
|
|
|
" property\n", prop_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
prop_data += vd;
|
|
|
|
}
|
|
|
|
}
|
2013-08-15 13:23:46 +08:00
|
|
|
} while (rtas_rc == 1);
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
of_node_put(dn);
|
|
|
|
kfree(rtas_buf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
static int add_dt_node(__be32 parent_phandle, __be32 drc_index)
|
2010-09-10 17:42:36 +08:00
|
|
|
{
|
|
|
|
struct device_node *dn;
|
|
|
|
struct device_node *parent_dn;
|
|
|
|
int rc;
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
parent_dn = of_find_node_by_phandle(be32_to_cpu(parent_phandle));
|
2013-08-15 13:23:50 +08:00
|
|
|
if (!parent_dn)
|
2010-09-10 17:42:36 +08:00
|
|
|
return -ENOENT;
|
|
|
|
|
2013-08-15 13:23:50 +08:00
|
|
|
dn = dlpar_configure_connector(drc_index, parent_dn);
|
2017-09-21 05:02:52 +08:00
|
|
|
if (!dn) {
|
|
|
|
of_node_put(parent_dn);
|
2010-09-10 17:42:36 +08:00
|
|
|
return -ENOENT;
|
2017-09-21 05:02:52 +08:00
|
|
|
}
|
2010-09-10 17:42:36 +08:00
|
|
|
|
2017-08-21 23:16:49 +08:00
|
|
|
rc = dlpar_attach_node(dn, parent_dn);
|
2010-09-10 17:42:36 +08:00
|
|
|
if (rc)
|
|
|
|
dlpar_free_cc_nodes(dn);
|
|
|
|
|
|
|
|
of_node_put(parent_dn);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-01-07 03:28:54 +08:00
|
|
|
static void prrn_update_node(__be32 phandle)
|
|
|
|
{
|
2018-09-10 22:57:07 +08:00
|
|
|
struct pseries_hp_errorlog hp_elog;
|
2017-01-07 03:28:54 +08:00
|
|
|
struct device_node *dn;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a node is found from a the given phandle, the phandle does not
|
|
|
|
* represent the drc index of an LMB and we can ignore.
|
|
|
|
*/
|
|
|
|
dn = of_find_node_by_phandle(be32_to_cpu(phandle));
|
|
|
|
if (dn) {
|
|
|
|
of_node_put(dn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-10 22:57:07 +08:00
|
|
|
hp_elog.resource = PSERIES_HP_ELOG_RESOURCE_MEM;
|
|
|
|
hp_elog.action = PSERIES_HP_ELOG_ACTION_READD;
|
|
|
|
hp_elog.id_type = PSERIES_HP_ELOG_ID_DRC_INDEX;
|
|
|
|
hp_elog._drc_u.drc_index = phandle;
|
2017-01-07 03:28:54 +08:00
|
|
|
|
2018-09-10 22:57:07 +08:00
|
|
|
handle_dlpar_errorlog(&hp_elog);
|
2017-01-07 03:28:54 +08:00
|
|
|
}
|
|
|
|
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
int pseries_devicetree_update(s32 scope)
|
2010-09-10 17:42:36 +08:00
|
|
|
{
|
|
|
|
char *rtas_buf;
|
2015-03-05 03:59:33 +08:00
|
|
|
__be32 *data;
|
2010-09-10 17:42:36 +08:00
|
|
|
int update_nodes_token;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
update_nodes_token = rtas_token("ibm,update-nodes");
|
|
|
|
if (update_nodes_token == RTAS_UNKNOWN_SERVICE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rtas_buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
|
|
|
|
if (!rtas_buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
do {
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
rc = mobility_rtas_call(update_nodes_token, rtas_buf, scope);
|
2010-09-10 17:42:36 +08:00
|
|
|
if (rc && rc != 1)
|
|
|
|
break;
|
|
|
|
|
2015-03-05 03:59:33 +08:00
|
|
|
data = (__be32 *)rtas_buf + 4;
|
|
|
|
while (be32_to_cpu(*data) & NODE_ACTION_MASK) {
|
2010-09-10 17:42:36 +08:00
|
|
|
int i;
|
2015-03-05 03:59:33 +08:00
|
|
|
u32 action = be32_to_cpu(*data) & NODE_ACTION_MASK;
|
|
|
|
u32 node_count = be32_to_cpu(*data) & NODE_COUNT_MASK;
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
data++;
|
|
|
|
|
|
|
|
for (i = 0; i < node_count; i++) {
|
2015-03-05 03:59:33 +08:00
|
|
|
__be32 phandle = *data++;
|
|
|
|
__be32 drc_index;
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case DELETE_DT_NODE:
|
|
|
|
delete_dt_node(phandle);
|
|
|
|
break;
|
|
|
|
case UPDATE_DT_NODE:
|
powerpc/pseries: Expose pseries devicetree_update()
Newer firmware on Power systems can transparently reassign platform resources
(CPU and Memory) in use. For instance, if a processor or memory unit is
predicted to fail, the platform may transparently move the processing to an
equivalent unused processor or the memory state to an equivalent unused
memory unit. However, reassigning resources across NUMA boundaries may alter
the performance of the partition. When such reassignment is necessary, the
Platform Resource Reassignment Notification (PRRN) option provides a
mechanism to inform the Linux kernel of changes to the NUMA affinity of
its platform resources.
When rtasd receives a PRRN event, it needs to make a series of RTAS
calls (ibm,update-nodes and ibm,update-properties) to retrieve the
updated device tree information. These calls are already handled in the
pseries_devicetree_update() routine used in partition migration.
This patch exposes pseries_devicetree_update() to make it accessible
to other pseries routines, this patch also updates pseries_devicetree_update()
to take a 32-bit scope parameter. The scope value, which was previously hard
coded to 1 for partition migration, is used for the RTAS calls
ibm,update-nodes/properties to update the device tree.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2013-04-24 13:47:11 +08:00
|
|
|
update_dt_node(phandle, scope);
|
2017-01-07 03:28:54 +08:00
|
|
|
|
|
|
|
if (scope == PRRN_SCOPE)
|
|
|
|
prrn_update_node(phandle);
|
|
|
|
|
2010-09-10 17:42:36 +08:00
|
|
|
break;
|
|
|
|
case ADD_DT_NODE:
|
|
|
|
drc_index = *data++;
|
|
|
|
add_dt_node(phandle, drc_index);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (rc == 1);
|
|
|
|
|
|
|
|
kfree(rtas_buf);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void post_mobility_fixup(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
int activate_fw_token;
|
|
|
|
|
|
|
|
activate_fw_token = rtas_token("ibm,activate-firmware");
|
|
|
|
if (activate_fw_token == RTAS_UNKNOWN_SERVICE) {
|
|
|
|
printk(KERN_ERR "Could not make post-mobility "
|
|
|
|
"activate-fw call.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-20 04:56:52 +08:00
|
|
|
do {
|
|
|
|
rc = rtas_call(activate_fw_token, 0, 1, NULL);
|
|
|
|
} while (rtas_busy_delay(rc));
|
|
|
|
|
|
|
|
if (rc)
|
2010-09-10 17:42:36 +08:00
|
|
|
printk(KERN_ERR "Post-mobility activate-fw failed: %d\n", rc);
|
2014-02-20 04:56:52 +08:00
|
|
|
|
|
|
|
rc = pseries_devicetree_update(MIGRATION_SCOPE);
|
|
|
|
if (rc)
|
|
|
|
printk(KERN_ERR "Post-mobility device tree update "
|
|
|
|
"failed: %d\n", rc);
|
2010-09-10 17:42:36 +08:00
|
|
|
|
2018-03-15 06:40:42 +08:00
|
|
|
/* Possibly switch to a new RFI flush type */
|
|
|
|
pseries_setup_rfi_flush();
|
|
|
|
|
2010-09-10 17:42:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-06 21:32:03 +08:00
|
|
|
static ssize_t migration_store(struct class *class,
|
|
|
|
struct class_attribute *attr, const char *buf,
|
|
|
|
size_t count)
|
2010-09-10 17:42:36 +08:00
|
|
|
{
|
|
|
|
u64 streamid;
|
|
|
|
int rc;
|
|
|
|
|
2014-08-09 05:24:01 +08:00
|
|
|
rc = kstrtou64(buf, 0, &streamid);
|
2010-09-10 17:42:36 +08:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2018-10-10 04:12:14 +08:00
|
|
|
stop_topology_update();
|
|
|
|
|
2010-09-10 17:42:36 +08:00
|
|
|
do {
|
2015-03-28 03:47:25 +08:00
|
|
|
rc = rtas_ibm_suspend_me(streamid);
|
|
|
|
if (rc == -EAGAIN)
|
2010-09-10 17:42:36 +08:00
|
|
|
ssleep(1);
|
2015-03-28 03:47:25 +08:00
|
|
|
} while (rc == -EAGAIN);
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
post_mobility_fixup();
|
2018-10-10 04:12:14 +08:00
|
|
|
|
|
|
|
start_topology_update();
|
|
|
|
|
2010-09-10 17:42:36 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2015-03-05 10:25:38 +08:00
|
|
|
/*
|
|
|
|
* Used by drmgr to determine the kernel behavior of the migration interface.
|
|
|
|
*
|
|
|
|
* Version 1: Performs all PAPR requirements for migration including
|
|
|
|
* firmware activation and device tree update.
|
|
|
|
*/
|
|
|
|
#define MIGRATION_API_VERSION 1
|
|
|
|
|
2017-06-06 21:32:03 +08:00
|
|
|
static CLASS_ATTR_WO(migration);
|
2017-01-12 11:54:13 +08:00
|
|
|
static CLASS_ATTR_STRING(api_version, 0444, __stringify(MIGRATION_API_VERSION));
|
2010-09-10 17:42:36 +08:00
|
|
|
|
|
|
|
static int __init mobility_sysfs_init(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
mobility_kobj = kobject_create_and_add("mobility", kernel_kobj);
|
|
|
|
if (!mobility_kobj)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
rc = sysfs_create_file(mobility_kobj, &class_attr_migration.attr);
|
2015-03-05 10:25:38 +08:00
|
|
|
if (rc)
|
|
|
|
pr_err("mobility: unable to create migration sysfs file (%d)\n", rc);
|
2010-09-10 17:42:36 +08:00
|
|
|
|
2015-03-05 10:25:38 +08:00
|
|
|
rc = sysfs_create_file(mobility_kobj, &class_attr_api_version.attr.attr);
|
|
|
|
if (rc)
|
|
|
|
pr_err("mobility: unable to create api_version sysfs file (%d)\n", rc);
|
|
|
|
|
|
|
|
return 0;
|
2010-09-10 17:42:36 +08:00
|
|
|
}
|
2014-07-16 10:02:43 +08:00
|
|
|
machine_device_initcall(pseries, mobility_sysfs_init);
|