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)
Jan 14 2024, 10:49 AM
Unknown Object (File)
Dec 23 2023, 5:18 PM
Unknown Object (File)
Dec 21 2023, 5:16 AM
Unknown Object (File)
Dec 20 2023, 6:25 AM
Unknown Object (File)
Dec 15 2023, 6:01 PM
Unknown Object (File)
Dec 10 2023, 12:34 PM
Unknown Object (File)
Dec 9 2023, 6:52 AM
Unknown Object (File)
Nov 27 2023, 8:17 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
170

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
141

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

146

see note below about the loop variable name.

149

Do we need to flush already created children ?

152

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

153

Why -1 ?

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
149

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

153

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

170

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.