Page MenuHomeFreeBSD

nvdimm(4): Add nvdimm_e820 pseudo-bus
ClosedPublic

Authored by cem on Oct 3 2019, 10:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 5 2024, 4:11 PM
Unknown Object (File)
Jan 2 2024, 11:25 PM
Unknown Object (File)
Dec 22 2023, 11:43 PM
Unknown Object (File)
Nov 10 2023, 8:55 AM
Unknown Object (File)
Nov 9 2023, 12:53 AM
Unknown Object (File)
Nov 8 2023, 8:57 AM
Unknown Object (File)
Nov 7 2023, 1:30 PM
Unknown Object (File)
Nov 4 2023, 10:35 PM
Subscribers

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 - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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.

Add BSD-2 license header for new file.

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.Oct 4 2019, 1:21 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 marked an inline comment as done.
  • Add braces around multi-line for loop
This revision now requires review to proceed.Oct 4 2019, 6:30 PM
This revision was not accepted when it landed; it landed in state Needs Review.Oct 4 2019, 6:38 PM
This revision was automatically updated to reflect the committed changes.