drivers/nvdimm/dimm_devs.c
Source file repositories/reference/linux-study-clean/drivers/nvdimm/dimm_devs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvdimm/dimm_devs.c- Extension
.c- Size
- 21686 bytes
- Lines
- 877
- Domain
- Driver Families
- Bucket
- drivers/nvdimm
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/moduleparam.hlinux/vmalloc.hlinux/device.hlinux/ndctl.hlinux/slab.hlinux/io.hlinux/fs.hlinux/mm.hnd-core.hlabel.hpmem.hnd.h
Detected Declarations
function nvdimm_check_config_datafunction validate_dimmfunction nvdimm_init_nsareafunction nvdimm_get_config_datafunction nvdimm_set_config_datafunction nvdimm_set_labelingfunction nvdimm_set_lockedfunction nvdimm_clear_lockedfunction nvdimm_releasefunction nvdimm_drvdata_releasefunction get_nddfunction put_nddfunction nvdimm_cmd_maskfunction commands_showfunction flags_showfunction state_showfunction __available_slots_showfunction available_slots_showfunction security_showfunction frozen_showfunction security_storefunction nvdimm_visiblefunction result_showfunction activate_showfunction activate_storefunction nvdimm_firmware_visiblefunction is_nvdimmfunction nvdimm_deletefunction shutdown_security_notifyfunction nvdimm_security_setup_eventsfunction nvdimm_in_overwritefunction nvdimm_security_freezefunction dpa_alignfunction nd_pmem_max_contiguous_dpafunction nd_pmem_available_dpafunction nvdimm_free_dpafunction nvdimm_allocated_dpafunction count_dimmsfunction nvdimm_bus_check_dimm_countfunction nvdimm_devs_exitexport to_nvdimmexport to_nddexport nvdimm_nameexport nvdimm_kobjexport nvdimm_cmd_maskexport nvdimm_provider_dataexport __nvdimm_createexport nvdimm_delete
Annotated Snippet
* Security state must be initialized before device_add() for
* attribute visibility.
*/
/* get security state and extended (master) state */
nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
nvdimm->sec.ext_flags = nvdimm_security_flags(nvdimm, NVDIMM_MASTER);
device_initialize(dev);
lockdep_set_class(&dev->mutex, &nvdimm_key);
if (test_bit(NDD_REGISTER_SYNC, &flags))
nd_device_register_sync(dev);
else
nd_device_register(dev);
return nvdimm;
}
EXPORT_SYMBOL_GPL(__nvdimm_create);
void nvdimm_delete(struct nvdimm *nvdimm)
{
struct device *dev = &nvdimm->dev;
bool dev_put = false;
/* We are shutting down. Make state frozen artificially. */
scoped_guard(nvdimm_bus, dev) {
set_bit(NVDIMM_SECURITY_FROZEN, &nvdimm->sec.flags);
dev_put = test_and_clear_bit(NDD_WORK_PENDING, &nvdimm->flags);
}
cancel_delayed_work_sync(&nvdimm->dwork);
if (dev_put)
put_device(dev);
nd_device_unregister(dev, ND_SYNC);
}
EXPORT_SYMBOL_GPL(nvdimm_delete);
static void shutdown_security_notify(void *data)
{
struct nvdimm *nvdimm = data;
sysfs_put(nvdimm->sec.overwrite_state);
}
int nvdimm_security_setup_events(struct device *dev)
{
struct nvdimm *nvdimm = to_nvdimm(dev);
if (!nvdimm->sec.flags || !nvdimm->sec.ops
|| !nvdimm->sec.ops->overwrite)
return 0;
nvdimm->sec.overwrite_state = sysfs_get_dirent(dev->kobj.sd, "security");
if (!nvdimm->sec.overwrite_state)
return -ENOMEM;
return devm_add_action_or_reset(dev, shutdown_security_notify, nvdimm);
}
EXPORT_SYMBOL_GPL(nvdimm_security_setup_events);
int nvdimm_in_overwrite(struct nvdimm *nvdimm)
{
return test_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags);
}
EXPORT_SYMBOL_GPL(nvdimm_in_overwrite);
int nvdimm_security_freeze(struct nvdimm *nvdimm)
{
int rc;
WARN_ON_ONCE(!is_nvdimm_bus_locked(&nvdimm->dev));
if (!nvdimm->sec.ops || !nvdimm->sec.ops->freeze)
return -EOPNOTSUPP;
if (!nvdimm->sec.flags)
return -EIO;
if (test_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags)) {
dev_warn(&nvdimm->dev, "Overwrite operation in progress.\n");
return -EBUSY;
}
rc = nvdimm->sec.ops->freeze(nvdimm);
nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
return rc;
}
static unsigned long dpa_align(struct nd_region *nd_region)
{
struct device *dev = &nd_region->dev;
if (dev_WARN_ONCE(dev, !is_nvdimm_bus_locked(dev),
Annotation
- Immediate include surface: `linux/moduleparam.h`, `linux/vmalloc.h`, `linux/device.h`, `linux/ndctl.h`, `linux/slab.h`, `linux/io.h`, `linux/fs.h`, `linux/mm.h`.
- Detected declarations: `function nvdimm_check_config_data`, `function validate_dimm`, `function nvdimm_init_nsarea`, `function nvdimm_get_config_data`, `function nvdimm_set_config_data`, `function nvdimm_set_labeling`, `function nvdimm_set_locked`, `function nvdimm_clear_locked`, `function nvdimm_release`, `function nvdimm_drvdata_release`.
- Atlas domain: Driver Families / drivers/nvdimm.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.