|
|
@@ -779,6 +779,97 @@ static int dlpar_memory_add_by_index(u32 drc_index, struct property *prop)
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
+static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index,
|
|
|
+ struct property *prop)
|
|
|
+{
|
|
|
+ struct of_drconf_cell *lmbs;
|
|
|
+ u32 num_lmbs, *p;
|
|
|
+ int i, rc, start_lmb_found;
|
|
|
+ int lmbs_available = 0, start_index = 0, end_index;
|
|
|
+
|
|
|
+ pr_info("Attempting to hot-add %u LMB(s) at index %x\n",
|
|
|
+ lmbs_to_add, drc_index);
|
|
|
+
|
|
|
+ if (lmbs_to_add == 0)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ p = prop->value;
|
|
|
+ num_lmbs = *p++;
|
|
|
+ lmbs = (struct of_drconf_cell *)p;
|
|
|
+ start_lmb_found = 0;
|
|
|
+
|
|
|
+ /* Navigate to drc_index */
|
|
|
+ while (start_index < num_lmbs) {
|
|
|
+ if (lmbs[start_index].drc_index == drc_index) {
|
|
|
+ start_lmb_found = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ start_index++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!start_lmb_found)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ end_index = start_index + lmbs_to_add;
|
|
|
+
|
|
|
+ /* Validate that the LMBs in this range are not reserved */
|
|
|
+ for (i = start_index; i < end_index; i++) {
|
|
|
+ if (lmbs[i].flags & DRCONF_MEM_RESERVED)
|
|
|
+ break;
|
|
|
+
|
|
|
+ lmbs_available++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (lmbs_available < lmbs_to_add)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ for (i = start_index; i < end_index; i++) {
|
|
|
+ if (lmbs[i].flags & DRCONF_MEM_ASSIGNED)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ rc = dlpar_acquire_drc(lmbs[i].drc_index);
|
|
|
+ if (rc)
|
|
|
+ break;
|
|
|
+
|
|
|
+ rc = dlpar_add_lmb(&lmbs[i]);
|
|
|
+ if (rc) {
|
|
|
+ dlpar_release_drc(lmbs[i].drc_index);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ lmbs[i].reserved = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (rc) {
|
|
|
+ pr_err("Memory indexed-count-add failed, removing any added LMBs\n");
|
|
|
+
|
|
|
+ for (i = start_index; i < end_index; i++) {
|
|
|
+ if (!lmbs[i].reserved)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ rc = dlpar_remove_lmb(&lmbs[i]);
|
|
|
+ if (rc)
|
|
|
+ pr_err("Failed to remove LMB, drc index %x\n",
|
|
|
+ be32_to_cpu(lmbs[i].drc_index));
|
|
|
+ else
|
|
|
+ dlpar_release_drc(lmbs[i].drc_index);
|
|
|
+ }
|
|
|
+ rc = -EINVAL;
|
|
|
+ } else {
|
|
|
+ for (i = start_index; i < end_index; i++) {
|
|
|
+ if (!lmbs[i].reserved)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ pr_info("Memory at %llx (drc index %x) was hot-added\n",
|
|
|
+ lmbs[i].base_addr, lmbs[i].drc_index);
|
|
|
+ lmbs[i].reserved = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return rc;
|
|
|
+}
|
|
|
+
|
|
|
int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
|
|
|
{
|
|
|
struct device_node *dn;
|
|
|
@@ -786,9 +877,6 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
|
|
|
u32 count, drc_index;
|
|
|
int rc;
|
|
|
|
|
|
- count = hp_elog->_drc_u.drc_count;
|
|
|
- drc_index = hp_elog->_drc_u.drc_index;
|
|
|
-
|
|
|
lock_device_hotplug();
|
|
|
|
|
|
dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
|
|
|
@@ -805,22 +893,35 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
|
|
|
|
|
|
switch (hp_elog->action) {
|
|
|
case PSERIES_HP_ELOG_ACTION_ADD:
|
|
|
- if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)
|
|
|
+ if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
|
|
|
+ count = hp_elog->_drc_u.drc_count;
|
|
|
rc = dlpar_memory_add_by_count(count, prop);
|
|
|
- else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX)
|
|
|
+ } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
|
|
|
+ drc_index = hp_elog->_drc_u.drc_index;
|
|
|
rc = dlpar_memory_add_by_index(drc_index, prop);
|
|
|
- else
|
|
|
+ } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
|
|
|
+ count = hp_elog->_drc_u.ic.count;
|
|
|
+ drc_index = hp_elog->_drc_u.ic.index;
|
|
|
+ rc = dlpar_memory_add_by_ic(count, drc_index, prop);
|
|
|
+ } else {
|
|
|
rc = -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case PSERIES_HP_ELOG_ACTION_REMOVE:
|
|
|
- if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)
|
|
|
+ if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
|
|
|
+ count = hp_elog->_drc_u.drc_count;
|
|
|
rc = dlpar_memory_remove_by_count(count, prop);
|
|
|
- else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX)
|
|
|
+ } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
|
|
|
+ drc_index = hp_elog->_drc_u.drc_index;
|
|
|
rc = dlpar_memory_remove_by_index(drc_index, prop);
|
|
|
- else
|
|
|
+ } else {
|
|
|
rc = -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case PSERIES_HP_ELOG_ACTION_READD:
|
|
|
+ drc_index = hp_elog->_drc_u.drc_index;
|
|
|
rc = dlpar_memory_readd_by_index(drc_index, prop);
|
|
|
break;
|
|
|
default:
|