Page MenuHomeFreeBSD

nvdimm(4): Add nvdimm_e820 pseudo-bus
ClosedPublic

Authored by cem on Thu, Oct 3, 10:32 AM.

Details

Summary

nvdimm_e820 is a newbus pseudo driver that looks for "legacy" e820 PRAM
spans and creates ordinary-looking SPA devfs nodes for them
(/dev/nvdimm_spaN).

As these legacy regions lack real NFIT SPA regions and namespace
definitions, they must be administratively sliced up externally using
device.hints. This is similar in purpose to the Linux memmap= mechanism.

It is assumed that systems with working NFIT tables will not have any use
for this driver, and that that will be the prevailing style going forward,
so if there are no explicit hints provided, this driver does not
automatically create any devices.

Test Plan
$ sysctl machdep.smap
...
SMAP type=0c, xattr=00, base=0000008ec0000000, len=000002d500000000

$ tail /boot/device.hints
hint.nvdimm_spa.0.maddr="0x08ec0000000"
hint.nvdimm_spa.0.msize="0x00800000000" # Carve off 32 GB region
hint.nvdimm_spa.0.type="PERS MEM"

# Present a portion of the NVDIMM region as a "disk" (maybe useful for /obj or /tmp or something)
hint.nvdimm_spa.1.maddr="0x1f940000000" # Just start at the 2nd SRAT region, 1.4TB; giant gap between first "SPA" region and this one.
hint.nvdimm_spa.1.msize="0x00800000000" # also bound to 32 GB
hint.nvdimm_spa.1.type="VIRT DSK"       # ("Volatile virtual disk." May experience sector tearing;
                                        # volatile's not quite right but it's not exactly a real disk either.)

# Test 2nd carving case, end of memory segment
hint.nvdimm_spa.2.maddr="0x363be000000"
hint.nvdimm_spa.2.msize="0x00002000000" # Last 32MB.
#hint.nvdimm_spa.2.msize="0xffffffffffffffff"   # Alternatively, carve off the rest of the segment (-1 means "the rest")
hint.nvdimm_spa.2.type="PERS MEM"

$ kldload nvdimm

# Bootverbose=1
$ dmesg | tail
...
nvdimm_e8200: Found PRAM 0x8ec0000000 +0x2d500000000
nvdimm_e8200: nvdimm_e820_create_spas: Found BIOS PRAM regions: 0x8ec0000000-0x363bfffffff
nvdimm_e8200: nvdimm_e820_create_spas: Remaining unallocated PRAM regions after hint 0: 0x96c0000000-0x363bfffffff
NVDIMM SPA0 base 0x00008ec0000000 len 0x00000800000000 PERS MEM fl 0xd
nvdimm_e8200: nvdimm_e820_create_spas: Remaining unallocated PRAM regions after hint 1: 0x96c0000000-0x1f93fffffff,0x20140000000-0x363bfffffff
NVDIMM SPA1 base 0x0001f940000000 len 0x00000800000000 VIRT DSK fl 0xd
nvdimm_e8200: nvdimm_e820_create_spas: Remaining unallocated PRAM regions after hint 2: 0x96c0000000-0x1f93fffffff,0x20140000000-0x363bdffffff
NVDIMM SPA2 base 0x000363be000000 len 0x00000002000000 PERS MEM fl 0xd

$ geom dev list -a |grep spa -A10
Geom name: spa0
Consumers:
1. Name: spa0
   Mediasize: 34359738368 (32G)   <<<
   Sectorsize: 512
   Mode: r0w0e0

Geom name: spa1
Consumers:
1. Name: spa1
   Mediasize: 34359738368 (32G)   <<<
   Sectorsize: 512
   Mode: r0w0e0

Geom name: spa2
Consumers:
1. Name: spa2
   Mediasize: 33554432 (32M)      <<<
   Sectorsize: 512
   Mode: r0w0e0

$ ls -l /dev/nvdimm_spa*
crw-rw---- 1 root operator 0, 119 Oct  3 01:01 /dev/nvdimm_spa0
crw-rw---- 1 root operator 0, 121 Oct  3 01:01 /dev/nvdimm_spa1
crw-rw---- 1 root operator 0, 123 Oct  3 01:01 /dev/nvdimm_spa2

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

cem created this revision.Thu, Oct 3, 10:32 AM
cem added inline comments.Thu, Oct 3, 7:26 PM
sys/dev/nvdimm/nvdimm_e820.c
1 ↗(On Diff #62863)

I know I'm missing a licence header; I intend to put in the preferred 2-clause BSDL one.

cem updated this revision to Diff 62881.Thu, Oct 3, 7:29 PM

Add BSD-2 license header for new file.

kib accepted this revision.Fri, Oct 4, 1:21 PM
kib added inline comments.
sys/dev/nvdimm/nvdimm_e820.c
142 ↗(On Diff #62881)

'{' should be on the prev line

161 ↗(On Diff #62881)

I would put {} around multi-line body.

This revision is now accepted and ready to land.Fri, Oct 4, 1:21 PM
cem added inline comments.Fri, Oct 4, 6:25 PM
sys/dev/nvdimm/nvdimm_e820.c
142 ↗(On Diff #62881)

It runs into the 80 column threshold on the previous line.

161 ↗(On Diff #62881)

Will do

cem updated this revision to Diff 62915.Fri, Oct 4, 6:30 PM
cem marked an inline comment as done.
  • Add braces around multi-line for loop
This revision now requires review to proceed.Fri, Oct 4, 6:30 PM
This revision was not accepted when it landed; it landed in state Needs Review.Fri, Oct 4, 6:38 PM
This revision was automatically updated to reflect the committed changes.