powerpc/pseries: PAPR persistent memory support
Subsystems (2)
PATCH v3 1/2 powerpc/pseries: PAPR persistent memory support
This patch implements support for discovering storage class memory devices at boot and for handling hotplug of new regions via RTAS hotplug events.
---
v2: Added missing pmem.c
v3: no changes
--- arch/powerpc/include/asm/firmware.h | 3 +- arch/powerpc/include/asm/hvcall.h | 10 +- arch/powerpc/include/asm/rtas.h | 2 + arch/powerpc/kernel/rtasd.c | 2 + arch/powerpc/platforms/pseries/Makefile | 2 +- arch/powerpc/platforms/pseries/dlpar.c | 4 + arch/powerpc/platforms/pseries/firmware.c | 1 + arch/powerpc/platforms/pseries/pmem.c | 164 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/pseries/pseries.h | 5 + arch/powerpc/platforms/pseries/ras.c | 3 +- 10 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 arch/powerpc/platforms/pseries/pmem.c
arch/powerpc/include/asm/firmware.h +2 -1
@@ -52,6 +52,7 @@#define FW_FEATURE_PRRN ASM_CONST(0x0000000200000000)#define FW_FEATURE_DRMEM_V2 ASM_CONST(0x0000000400000000)#define FW_FEATURE_DRC_INFO ASM_CONST(0x0000000800000000) +#define FW_FEATURE_PAPR_SCM ASM_CONST(0x0000001000000000)#ifndef __ASSEMBLY__
@@ -69,7 +70,7 @@ enum {FW_FEATURE_SET_MODE |FW_FEATURE_BEST_ENERGY |FW_FEATURE_TYPE1_AFFINITY |FW_FEATURE_PRRN |FW_FEATURE_HPT_RESIZE |FW_FEATURE_DRMEM_V2 | -FW_FEATURE_DRC_INFO , +FW_FEATURE_DRC_INFO |FW_FEATURE_PAPR_SCM ,FW_FEATURE_PSERIES_ALWAYS =0 ,FW_FEATURE_POWERNV_POSSIBLE =FW_FEATURE_OPAL , FW_FEATURE_POWERNV_ALWAYS = 0,
arch/powerpc/include/asm/hvcall.h +9 -1
@@ -295,7 +295,15 @@#define H_INT_ESB 0x3C8#define H_INT_SYNC 0x3CC#define H_INT_RESET 0x3D0 -#define MAX_HCALL_OPCODE H_INT_RESET +#define H_SCM_READ_METADATA 0x3E4 +#define H_SCM_WRITE_METADATA 0x3E8 +#define H_SCM_BIND_MEM 0x3EC +#define H_SCM_UNBIND_MEM 0x3F0 +#define H_SCM_QUERY_BLOCK_MEM_BINDING 0x3F4 +#define H_SCM_QUERY_LOGICAL_MEM_BINDING 0x3F8 +#define H_SCM_MEM_QUERY 0x3FC +#define H_SCM_BLOCK_CLEAR 0x400 +#define MAX_HCALL_OPCODE H_SCM_BLOCK_CLEAR/* H_VIOCTL functions */ #define H_GET_VIOA_DUMP_SIZE 0x01
arch/powerpc/include/asm/rtas.h +2 -0
@@ -125,6 +125,7 @@ struct rtas_suspend_me_data {#define RTAS_TYPE_INFO 0xE2#define RTAS_TYPE_DEALLOC 0xE3#define RTAS_TYPE_DUMP 0xE4 +#define RTAS_TYPE_HOTPLUG 0xE5/* I don't add PowerMGM events right now, this is a different topic */ #define RTAS_TYPE_PMGM_POWER_SW_ON 0x60#define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61
@@ -316,6 +317,7 @@ struct pseries_hp_errorlog {#define PSERIES_HP_ELOG_RESOURCE_MEM 2#define PSERIES_HP_ELOG_RESOURCE_SLOT 3#define PSERIES_HP_ELOG_RESOURCE_PHB 4 +#define PSERIES_HP_ELOG_RESOURCE_PMEM 6#define PSERIES_HP_ELOG_ACTION_ADD 1#define PSERIES_HP_ELOG_ACTION_REMOVE 2
arch/powerpc/kernel/rtasd.c +2 -0
@@ -91,6 +91,8 @@ static char *rtas_event_type(int type)return "Dump Notification Event" ;case RTAS_TYPE_PRRN :return "Platform Resource Reassignment Event" ; +case RTAS_TYPE_HOTPLUG : +return "Hotplug Event" ; }return rtas_type[0 ];
arch/powerpc/platforms/pseries/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-$(CONFIG_KEXEC_CORE) += kexec.o obj-$(CONFIG_PSERIES_ENERGY) += pseries_energy.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o -obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o +obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o pmem.o obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o obj-$(CONFIG_HVCS) += hvcserver.o
arch/powerpc/platforms/pseries/dlpar.c +4 -0
@@ -357,6 +357,10 @@ static int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog)case PSERIES_HP_ELOG_RESOURCE_CPU : rc =dlpar_cpu (hp_elog);break ; +case PSERIES_HP_ELOG_RESOURCE_PMEM : + rc =dlpar_hp_pmem (hp_elog); +break ; +default :pr_warn_ratelimited ("Invalid resource (%d) specified\n" , hp_elog->resource);
arch/powerpc/platforms/pseries/firmware.c +1 -0
@@ -65,6 +65,7 @@ hypertas_fw_features_table[] = { {FW_FEATURE_SET_MODE, "hcall-set-mode"}, {FW_FEATURE_BEST_ENERGY, "hcall-best-energy-1*"}, {FW_FEATURE_HPT_RESIZE, "hcall-hpt-resize"}, + {FW_FEATURE_PAPR_SCM, "hcall-scm"}, };/* Build up the firmware features bitmask using the contents of
arch/powerpc/platforms/pseries/pmem.c new file +164 -0
164 lines not on this page · raw message
arch/powerpc/platforms/pseries/pseries.h +5 -0
@@ -63,11 +63,16 @@ void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog, struct completion *hotplug_done, int *rc);#ifdef CONFIG_MEMORY_HOTPLUG int dlpar_memory (struct pseries_hp_errorlog *hp_elog); +int dlpar_hp_pmem (struct pseries_hp_errorlog *hp_elog);#else static inline int dlpar_memory (struct pseries_hp_errorlog *hp_elog) {return -EOPNOTSUPP ; } +int dlpar_hp_pmem (struct pseries_hp_errorlog *hp_elog) +{ +return -EOPNOTSUPP ; +};#endif #ifdef CONFIG_HOTPLUG_CPU
arch/powerpc/platforms/pseries/ras.c +2 -1
@@ -237,7 +237,8 @@ static irqreturn_t ras_hotplug_interrupt(int irq, void *dev_id)* hotplug events on the ras_log_buf to be handled by rtas_errd. */ if (hp_elog->resource ==PSERIES_HP_ELOG_RESOURCE_MEM || - hp_elog->resource ==PSERIES_HP_ELOG_RESOURCE_CPU ) + hp_elog->resource ==PSERIES_HP_ELOG_RESOURCE_CPU || + hp_elog->resource ==PSERIES_HP_ELOG_RESOURCE_PMEM )queue_hotplug_event (hp_elog,NULL ,NULL );else log_error (ras_log_buf,ERR_TYPE_RTAS_LOG ,0 );
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v3 2/2 powerpc/pseries: Add driver for PAPR SCM regions
Adds a driver that implements support for enabling and accessing PAPR SCM regions. Unfortunately due to how the PAPR interface works we can't use the existing of_pmem driver (yet) because:
a) The guest is required to use the H_SCM_BIND_MEM h-call to add add the SCM region to it's physical address space, and
b) There is currently no mechanism for relating a bare of_pmem region to the backing DIMM (or not-a-DIMM for our case).
Both of these are easily handled by rolling the functionality into a seperate driver so here we are...
---
The alternative implementation here is that we have the pseries code do the h-calls and craft a pmem-region@<addr> node based on that. However, that doesn't solve b) and mpe has expressed his dislike of adding new stuff to the DT at runtime so i'd say that's a non-starter.
---
v2: no change
v3: Corrected the mapping to use a DPA start address of zero
Added cond_resched() calls in the bind/unbind loops
--- arch/powerpc/platforms/pseries/Kconfig | 7 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/papr_scm.c | 345 ++++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 arch/powerpc/platforms/pseries/papr_scm.c
arch/powerpc/platforms/pseries/Kconfig +7 -0
@@ -140,3 +140,10 @@ config IBMEBUS bool "Support for GX bus based adapters" help Bus device driver for GX bus based adapters. + +config PAPR_SCM + depends on PPC_PSERIES && MEMORY_HOTPLUG + select LIBNVDIMM + tristate "Support for the PAPR Storage Class Memory interface" + help + Enable access to hypervisor provided storage class memory.
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o obj-$(CONFIG_LPARCFG) += lparcfg.o obj-$(CONFIG_IBMVIO) += vio.o obj-$(CONFIG_IBMEBUS) += ibmebus.o +obj-$(CONFIG_PAPR_SCM) += papr_scm.o ifdef CONFIG_PPC_PSERIES obj-$(CONFIG_SUSPEND) += suspend.o
arch/powerpc/platforms/pseries/papr_scm.c new file +345 -0
345 lines not on this page · raw message
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v3 2/2] powerpc/pseries: Add driver for PAPR SCM regions
Quoted 15 lines · Oliver O'Halloran
Adds a driver that implements support for enabling and accessing PAPR SCM regions. Unfortunately due to how the PAPR interface works we can't use the existing
of_pmemdriver (yet) because:a) The guest is required to use the
H_SCM_BIND_MEMh-call to add add the SCM region to it's physical address space, and
b) There is currently no mechanism for relating a bareof_pmemregion to the backing DIMM (or not-a-DIMM for our case).Both of these are easily handled by rolling the functionality into a seperate driver so here we are...
Acked-by Dan Williams <[email protected]>Signed-off-by Oliver O'Halloran <[email protected]>
Quoted 9 lines
---
The alternative implementation here is that we have the pseries code do the h-calls and craft a pmem-region@<addr> node based on that. However, that doesn't solve b) and mpe has expressed his dislike of adding new stuff to the DT at runtime so i'd say that's a non-starter.
---
v2: no change
v3: Corrected the mapping to use a DPA start address of zero
Addedcond_resched()calls in the bind/unbind loops
Looks good, could I trouble you for an ack on the build / merge fix?
https://patchwork.kernel.org/patch/10640385/
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v3 2/2] powerpc/pseries: Add driver for PAPR SCM regions
Quoted 27 lines · Dan Williams
Quoted 15 lines · Oliver O'Halloran
Adds a driver that implements support for enabling and accessing PAPR SCM regions. Unfortunately due to how the PAPR interface works we can't use the existing
of_pmemdriver (yet) because:a) The guest is required to use the
H_SCM_BIND_MEMh-call to add add the SCM region to it's physical address space, and
b) There is currently no mechanism for relating a bareof_pmemregion to the backing DIMM (or not-a-DIMM for our case).Both of these are easily handled by rolling the functionality into a seperate driver so here we are...
Acked-by Dan Williams <[email protected]>Signed-off-by Oliver O'Halloran <[email protected]>Quoted 9 lines
---
The alternative implementation here is that we have the pseries code do the h-calls and craft a pmem-region@<addr> node based on that. However, that doesn't solve b) and mpe has expressed his dislike of adding new stuff to the DT at runtime so i'd say that's a non-starter.
---
v2: no change
v3: Corrected the mapping to use a DPA start address of zero
Addedcond_resched()calls in the bind/unbind loops
Quoted 3 lines
Looks good, could I trouble you for an ack on the build / merge fix?
Sure thing. I checked that it built when rebased on top of your pending branch before posting.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 5 lines · Oliver O'Halloran
This patch implements support for discovering storage class memory devices at boot and for handling hotplug of new regions via RTAS hotplug events.
Signed-off-by Oliver O'Halloran <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/4c5d87db497832c493ed296157bd17
cheers
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm