drivers/nvdimm/region_devs.c
Source file repositories/reference/linux-study-clean/drivers/nvdimm/region_devs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvdimm/region_devs.c- Extension
.c- Size
- 30712 bytes
- Lines
- 1192
- 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/scatterlist.hlinux/memregion.hlinux/highmem.hlinux/kstrtox.hlinux/sched.hlinux/slab.hlinux/hash.hlinux/sort.hlinux/io.hlinux/nd.hnd-core.hnd.hlinux/io-64-nonatomic-hi-lo.h
Detected Declarations
function nvdimm_map_flushfunction nd_region_invalidate_memregionfunction get_flush_datafunction nd_region_activatefunction nd_region_releasefunction nd_region_to_nstypefunction region_sizefunction size_showfunction deep_flush_showfunction deep_flush_storefunction mappings_showfunction nstype_showfunction set_cookie_showfunction nd_region_available_dpafunction nd_region_allocatable_dpafunction available_size_showfunction max_available_extent_showfunction init_namespaces_showfunction namespace_seed_showfunction btt_seed_showfunction pfn_seed_showfunction dax_seed_showfunction read_only_showfunction revalidate_read_onlyfunction read_only_storefunction align_showfunction align_storefunction region_badblocks_showfunction resource_showfunction persistence_domain_showfunction region_visiblefunction mappingNfunction mapping_visiblefunction is_nd_pmemfunction is_nd_volatilefunction nd_region_interleave_set_cookiefunction nd_region_interleave_set_altcookiefunction nd_mapping_free_labelsfunction nd_region_advance_seedsfunction nd_region_acquire_lanefunction nd_region_release_lanefunction memremap_pagesfunction nvdimm_region_deletefunction nvdimm_flushfunction generic_nvdimm_flushfunction nvdimm_has_flushfunction nvdimm_has_cachefunction is_nvdimm_sync
Annotated Snippet
if (test_bit(NDD_INCOHERENT, &nvdimm->flags)) {
incoherent++;
break;
}
}
if (!incoherent)
return 0;
if (!cpu_cache_has_invalidate_memregion()) {
if (IS_ENABLED(CONFIG_NVDIMM_SECURITY_TEST)) {
dev_warn(
&nd_region->dev,
"Bypassing cpu_cache_invalidate_memergion() for testing!\n");
goto out;
} else {
dev_err(&nd_region->dev,
"Failed to synchronize CPU cache state\n");
return -ENXIO;
}
}
cpu_cache_invalidate_all();
out:
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
struct nvdimm *nvdimm = nd_mapping->nvdimm;
clear_bit(NDD_INCOHERENT, &nvdimm->flags);
}
return 0;
}
static int get_flush_data(struct nd_region *nd_region, size_t *size, int *num_flush)
{
size_t flush_data_size = sizeof(void *);
int _num_flush = 0;
int i;
guard(nvdimm_bus)(&nd_region->dev);
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
struct nvdimm *nvdimm = nd_mapping->nvdimm;
if (test_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags))
return -EBUSY;
/* at least one null hint slot per-dimm for the "no-hint" case */
flush_data_size += sizeof(void *);
_num_flush = min_not_zero(_num_flush, nvdimm->num_flush);
if (!nvdimm->num_flush)
continue;
flush_data_size += nvdimm->num_flush * sizeof(void *);
}
*size = flush_data_size;
*num_flush = _num_flush;
return 0;
}
int nd_region_activate(struct nd_region *nd_region)
{
int i, j, rc, num_flush;
struct nd_region_data *ndrd;
struct device *dev = &nd_region->dev;
size_t flush_data_size;
rc = get_flush_data(nd_region, &flush_data_size, &num_flush);
if (rc)
return rc;
rc = nd_region_invalidate_memregion(nd_region);
if (rc)
return rc;
ndrd = devm_kzalloc(dev, sizeof(*ndrd) + flush_data_size, GFP_KERNEL);
if (!ndrd)
return -ENOMEM;
dev_set_drvdata(dev, ndrd);
if (!num_flush)
return 0;
ndrd->hints_shift = ilog2(num_flush);
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
struct nvdimm *nvdimm = nd_mapping->nvdimm;
int rc = nvdimm_map_flush(&nd_region->dev, nvdimm, i, ndrd);
Annotation
- Immediate include surface: `linux/scatterlist.h`, `linux/memregion.h`, `linux/highmem.h`, `linux/kstrtox.h`, `linux/sched.h`, `linux/slab.h`, `linux/hash.h`, `linux/sort.h`.
- Detected declarations: `function nvdimm_map_flush`, `function nd_region_invalidate_memregion`, `function get_flush_data`, `function nd_region_activate`, `function nd_region_release`, `function nd_region_to_nstype`, `function region_size`, `function size_show`, `function deep_flush_show`, `function deep_flush_store`.
- 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.