Message ID | 20180426062755.25018-1-mikey@neuling.org |
---|---|
State | Accepted |
Headers | show |
Series | mambo: Add persistent memory disk support | expand |
Michael Neuling <mikey@neuling.org> writes: > This adds support to for mapping disks images using persistent > memory. Disks can be added by setting this ENV variable: > > PMEM_DISK="/mydisks/disk1.img,/mydisks/disk2.img" > > These will show up in Linux as /dev/pmem0 and /dev/pmem1. > > This uses a new feature in mambo "mysim memory mmap .." which is only > available since mambo commit 0131f0fc08 (from 24/4/2018). > > This also needs the of_pmem.c driver in Linux which is only available > since v4.17. It works with powernv_defconfig + CONFIG_OF_PMEM. ie > > --- a/arch/powerpc/configs/powernv_defconfig > +++ b/arch/powerpc/configs/powernv_defconfig > @@ -238,6 +238,8 @@ CONFIG_RTC_CLASS=y > CONFIG_RTC_DRV_GENERIC=y > CONFIG_VIRTIO_PCI=m > CONFIG_VIRTIO_BALLOON=m > +CONFIG_LIBNVDIMM=y > +# CONFIG_ND_BLK is not set > CONFIG_EXT2_FS=y > CONFIG_EXT2_FS_XATTR=y > CONFIG_EXT2_FS_POSIX_ACL=y > > Signed-off-by: Michael Neuling <mikey@neuling.org> > --- > external/mambo/skiboot.tcl | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) Sweeeeeet. Merged to master as of 0a6a2ff30c9ed47824af455207d1f268feb1ef63
diff --git a/external/mambo/skiboot.tcl b/external/mambo/skiboot.tcl index 6c40289f56..9dbcd902fb 100644 --- a/external/mambo/skiboot.tcl +++ b/external/mambo/skiboot.tcl @@ -227,6 +227,35 @@ if { [info exists env(SKIBOOT_INITRD)] } { mysim of addprop $chosen_node int "linux,initrd-end" $cpio_end } +# Map persistent memory disks +if { [info exists env(PMEM_DISK)] } { + + set pmem_files [split $env(PMEM_DISK) ","] + + set pmem_root [mysim of addchild $root_node "pmem" ""] + mysim of addprop $pmem_root int "#address-cells" 2 + mysim of addprop $pmem_root int "#size-cells" 2 + mysim of addprop $pmem_root empty "ranges" "" + + # Start above where XICS normally is at 0x1A0000000000 + set pmem_start [expr 0x20000000000] + foreach pmem_file $pmem_files { + set pmem_file [string trim $pmem_file] + set pmem_size [file size $pmem_file] + set pmem_start_hex [format %x $pmem_start] + set pmem_node [mysim of addchild $pmem_root "pmem@$pmem_start_hex" ""] + set reg [list [expr $pmem_start >> 32] [expr $pmem_start & 0xffffffff] [expr $pmem_size >> 32] [expr $pmem_size & 0xffffffff] ] + mysim of addprop $pmem_node array "reg" reg + mysim of addprop $pmem_node string "compatible" "pmem-region" + mysim of addprop $pmem_root empty "volatile" "" + if {[catch {mysim memory mmap $pmem_start $pmem_size $pmem_file rw}]} { + puts "ERROR: pmem: 'mysim mmap' command needs newer mambo" + exit + } + set pmem_start [expr $pmem_start + $pmem_size] + } +} + # Default NVRAM is blank and will be formatted by Skiboot if no file is provided set fake_nvram_start $cpio_end set fake_nvram_size 0x40000
This adds support to for mapping disks images using persistent memory. Disks can be added by setting this ENV variable: PMEM_DISK="/mydisks/disk1.img,/mydisks/disk2.img" These will show up in Linux as /dev/pmem0 and /dev/pmem1. This uses a new feature in mambo "mysim memory mmap .." which is only available since mambo commit 0131f0fc08 (from 24/4/2018). This also needs the of_pmem.c driver in Linux which is only available since v4.17. It works with powernv_defconfig + CONFIG_OF_PMEM. ie --- a/arch/powerpc/configs/powernv_defconfig +++ b/arch/powerpc/configs/powernv_defconfig @@ -238,6 +238,8 @@ CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_GENERIC=y CONFIG_VIRTIO_PCI=m CONFIG_VIRTIO_BALLOON=m +CONFIG_LIBNVDIMM=y +# CONFIG_ND_BLK is not set CONFIG_EXT2_FS=y CONFIG_EXT2_FS_XATTR=y CONFIG_EXT2_FS_POSIX_ACL=y Signed-off-by: Michael Neuling <mikey@neuling.org> --- external/mambo/skiboot.tcl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)