powerpc/pseries: Introduce memory hotplug READD operation
authorJohn Allen <jallen@linux.vnet.ibm.com>
Fri, 6 Jan 2017 19:27:26 +0000 (13:27 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 2 Feb 2017 05:57:39 +0000 (16:57 +1100)
Currently, memory must be hot removed and subsequently re-added in order
to dynamically update the affinity of LMBs specified by a PRRN event.
Earlier implementations of the PRRN event handler ran into issues in which
the hot remove would occur successfully, but a hotplug event would be
initiated from another source and grab the hotplug lock preventing the hot
add from occurring. To prevent this situation, this patch introduces the
notion of a hot "readd" action for memory which atomizes a hot remove and
a hot add into a single, serialized operation on the hotplug queue.

Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/rtas.h
arch/powerpc/platforms/pseries/hotplug-memory.c

index 9c23baa10b81b7ae4540efb0bc94445585998b32..076b89247ab58f2f10a534773c560c086b0bd1a0 100644 (file)
@@ -318,6 +318,7 @@ struct pseries_hp_errorlog {
 
 #define PSERIES_HP_ELOG_ACTION_ADD     1
 #define PSERIES_HP_ELOG_ACTION_REMOVE  2
+#define PSERIES_HP_ELOG_ACTION_READD   3
 
 #define PSERIES_HP_ELOG_ID_DRC_NAME    1
 #define PSERIES_HP_ELOG_ID_DRC_INDEX   2
index be11fc3cdeb063ff044f613ec3b4eec6e37f19e0..3381c20edbc0af692fefae655e1bc196b8e484b8 100644 (file)
@@ -563,6 +563,44 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
        return rc;
 }
 
+static int dlpar_memory_readd_by_index(u32 drc_index, struct property *prop)
+{
+       struct of_drconf_cell *lmbs;
+       u32 num_lmbs, *p;
+       int lmb_found;
+       int i, rc;
+
+       pr_info("Attempting to update LMB, drc index %x\n", drc_index);
+
+       p = prop->value;
+       num_lmbs = *p++;
+       lmbs = (struct of_drconf_cell *)p;
+
+       lmb_found = 0;
+       for (i = 0; i < num_lmbs; i++) {
+               if (lmbs[i].drc_index == drc_index) {
+                       lmb_found = 1;
+                       rc = dlpar_remove_lmb(&lmbs[i]);
+                       if (!rc) {
+                               rc = dlpar_add_lmb(&lmbs[i]);
+                               if (rc)
+                                       dlpar_release_drc(lmbs[i].drc_index);
+                       }
+                       break;
+               }
+       }
+
+       if (!lmb_found)
+               rc = -EINVAL;
+
+       if (rc)
+               pr_info("Failed to update memory at %llx\n",
+                       lmbs[i].base_addr);
+       else
+               pr_info("Memory at %llx was updated\n", lmbs[i].base_addr);
+
+       return rc;
+}
 #else
 static inline int pseries_remove_memblock(unsigned long base,
                                          unsigned int memblock_size)
@@ -779,6 +817,9 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
                else
                        rc = -EINVAL;
                break;
+       case PSERIES_HP_ELOG_ACTION_READD:
+               rc = dlpar_memory_readd_by_index(drc_index, prop);
+               break;
        default:
                pr_err("Invalid action (%d) specified\n", hp_elog->action);
                rc = -EINVAL;