Page MenuHomeFreeBSD

nvdimm: only enumerate present nvdimm devices
ClosedPublic

Authored by scottph on Dec 5 2018, 5:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 4, 8:07 PM
Unknown Object (File)
Mon, Dec 2, 2:37 AM
Unknown Object (File)
Sat, Nov 30, 3:22 AM
Unknown Object (File)
Nov 24 2024, 10:05 AM
Unknown Object (File)
Nov 23 2024, 4:15 AM
Unknown Object (File)
Nov 19 2024, 5:09 AM
Unknown Object (File)
Nov 8 2024, 6:35 AM
Unknown Object (File)
Nov 7 2024, 1:47 AM
Subscribers

Details

Summary

Not all child devices of the NVDIMM root device represent DIMM
devices which are present in the system. The spec says (ACPI 6.2,
sec 9.20.2):

For each NVDIMM present or intended to be supported by platform,
platform firmware also exposes an NVDIMM device ... under the
NVDIMM root device.

Present NVDIMM devices are found by walking all of the NFIT
table's SPA ranges, then walking the NVDIMM regions mentioned by
those SPA ranges.

A set of NFIT walking helper functions are introduced to avoid the
need to splat the enumeration logic across several disparate
callbacks.

Submitted by: D Scott Phillips <d.scott.phillips@intel.com>
Sponsored by: Intel Corporation
MFC after: 1 week

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

scottph edited the summary of this revision. (Show Details)

rebase diff so that it is no longer against D18346

sys/dev/nvdimm/nvdimm.c
240

Here we also need AcpiAttachData(handle, acpi_fake_objhandler, child); so that acpi_get_device() can work in nvdimm_find_by_handle()

scottph retitled this revision from nvdimm: factor out NFIT table walking to nvdimm: only enumerate present nvdimm devices.
scottph edited the summary of this revision. (Show Details)
scottph edited the test plan for this revision. (Show Details)
sys/dev/nvdimm/nvdimm.c
179

see note below about the loop variable name.

182

Do we need to flush already created children ?

186

Why -1 ?

206

Please do not name non-integer loop variable 'i'.

217

Do we need to clear other already created spa's ?

sys/dev/nvdimm/nvdimm_nfit.c
42

This '{' should be on the new line, alone.

_* are C-std reserved names, better not use them at all.

47

return (*a - *b);

65

You want to mask the value after dereferencing the pointer, right ? I would write it as

val &= mask;

on the next line.

More important, this code potentially accesses unaligned types, esp. when you do the trick with fetching uint16_t and passing UINT16_MAX for the mask. This only works on x86, and even there it works by chance.

74

There is no need in {} around single-line block, usually.

115

And there the body block is multi-line, so {} are warranted by style.

Several more {} vs. no-{} below, I did not marked them.

scottph edited the summary of this revision. (Show Details)
  • rebase patch
  • add commit message tags
  • Don't use i for non-int loop variables
  • Fix some style(9) issues with braces
  • Don't use variable names prefixed with underscore
  • Handle unaligned accesses in find_matches()
  • Fix an off-by-one error in the allocation of ivars
scottph added inline comments.
sys/dev/nvdimm/nvdimm.c
182

the child devices and spas get destroyed on detach, which I think covers the case you mention.

186

You're right, I think the -1 was wrong.

240

This comment is obsoleted by the nvdimm root device's own ivars.

sys/dev/nvdimm/nvdimm_nfit.c
47

oops, messed up a space here.

65

changed this to bcopy to handle the unaligned access.

115

Think I got them all, sorry for the simple mistakes.

scottph marked 3 inline comments as done.
  • fix one more style(9) problem
This revision is now accepted and ready to land.Jan 31 2019, 10:32 PM
This revision was automatically updated to reflect the committed changes.