drivers/nvdimm/nd-core.h
Source file repositories/reference/linux-study-clean/drivers/nvdimm/nd-core.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvdimm/nd-core.h- Extension
.h- Size
- 5338 bytes
- Lines
- 162
- Domain
- Driver Families
- Bucket
- drivers/nvdimm
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/libnvdimm.hlinux/device.hlinux/sizes.hlinux/mutex.hlinux/nd.hnd.h
Detected Declarations
struct nvdimm_busstruct nvdimmstruct nd_regionstruct nd_label_idstruct nd_regionstruct nvdimm_drvdatastruct nd_mappingfunction nvdimm_security_flagsfunction nvdimm_security_storefunction nvdimm_security_overwrite_queryfunction is_nd_regionfunction is_memoryfunction devm_nsio_enablefunction devm_nsio_disable
Annotated Snippet
struct nvdimm_bus {
struct nvdimm_bus_descriptor *nd_desc;
wait_queue_head_t wait;
struct list_head list;
struct device dev;
int id, probe_active;
atomic_t ioctl_active;
struct list_head mapping_list;
struct mutex reconfig_mutex;
struct badrange badrange;
};
struct nvdimm {
unsigned long flags;
void *provider_data;
unsigned long cmd_mask;
struct device dev;
atomic_t busy;
int id, num_flush;
struct resource *flush_wpq;
const char *dimm_id;
struct {
const struct nvdimm_security_ops *ops;
unsigned long flags;
unsigned long ext_flags;
unsigned int overwrite_tmo;
struct kernfs_node *overwrite_state;
} sec;
struct delayed_work dwork;
const struct nvdimm_fw_ops *fw_ops;
};
static inline unsigned long nvdimm_security_flags(
struct nvdimm *nvdimm, enum nvdimm_passphrase_type ptype)
{
u64 flags;
const u64 state_flags = 1UL << NVDIMM_SECURITY_DISABLED
| 1UL << NVDIMM_SECURITY_LOCKED
| 1UL << NVDIMM_SECURITY_UNLOCKED
| 1UL << NVDIMM_SECURITY_OVERWRITE;
if (!nvdimm->sec.ops)
return 0;
flags = nvdimm->sec.ops->get_flags(nvdimm, ptype);
/* disabled, locked, unlocked, and overwrite are mutually exclusive */
dev_WARN_ONCE(&nvdimm->dev, hweight64(flags & state_flags) > 1,
"reported invalid security state: %#llx\n",
(unsigned long long) flags);
return flags;
}
int nvdimm_security_freeze(struct nvdimm *nvdimm);
#if IS_ENABLED(CONFIG_NVDIMM_KEYS)
ssize_t nvdimm_security_store(struct device *dev, const char *buf, size_t len);
void nvdimm_security_overwrite_query(struct work_struct *work);
#else
static inline ssize_t nvdimm_security_store(struct device *dev,
const char *buf, size_t len)
{
return -EOPNOTSUPP;
}
static inline void nvdimm_security_overwrite_query(struct work_struct *work)
{
}
#endif
bool is_nvdimm(const struct device *dev);
bool is_nd_pmem(const struct device *dev);
bool is_nd_volatile(const struct device *dev);
static inline bool is_nd_region(const struct device *dev)
{
return is_nd_pmem(dev) || is_nd_volatile(dev);
}
static inline bool is_memory(const struct device *dev)
{
return is_nd_pmem(dev) || is_nd_volatile(dev);
}
struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev);
int __init nvdimm_bus_init(void);
void nvdimm_bus_exit(void);
void nvdimm_devs_exit(void);
struct nd_region;
void nd_region_advance_seeds(struct nd_region *nd_region, struct device *dev);
void nd_region_create_ns_seed(struct nd_region *nd_region);
void nd_region_create_btt_seed(struct nd_region *nd_region);
void nd_region_create_pfn_seed(struct nd_region *nd_region);
void nd_region_create_dax_seed(struct nd_region *nd_region);
int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus);
void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus);
void nd_synchronize(void);
Annotation
- Immediate include surface: `linux/libnvdimm.h`, `linux/device.h`, `linux/sizes.h`, `linux/mutex.h`, `linux/nd.h`, `nd.h`.
- Detected declarations: `struct nvdimm_bus`, `struct nvdimm`, `struct nd_region`, `struct nd_label_id`, `struct nd_region`, `struct nvdimm_drvdata`, `struct nd_mapping`, `function nvdimm_security_flags`, `function nvdimm_security_store`, `function nvdimm_security_overwrite_query`.
- Atlas domain: Driver Families / drivers/nvdimm.
- Implementation status: source 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.