@@ -46,6 +46,8 @@ static int to_nd_device_type(struct devi
return ND_DEVICE_REGION_BLK;
else if (is_nd_dax(dev))
return ND_DEVICE_DAX_PMEM;
+ else if (is_nd_dax_kmem(dev))
+ return ND_DEVICE_DAX_KMEM;
else if (is_nd_region(dev->parent))
return nd_region_to_nstype(to_nd_region(dev->parent));
@@ -51,6 +51,41 @@ struct nd_dax *to_nd_dax(struct device *
}
EXPORT_SYMBOL(to_nd_dax);
+/* nd_dax_kmem */
+static void nd_dax_kmem_release(struct device *dev)
+{
+ struct nd_region *nd_region = to_nd_region(dev->parent);
+ struct nd_dax_kmem *nd_dax_kmem = to_nd_dax_kmem(dev);
+ struct nd_pfn *nd_pfn = &nd_dax_kmem->nd_pfn;
+
+ dev_dbg(dev, "trace\n");
+ nd_detach_ndns(dev, &nd_pfn->ndns);
+ ida_simple_remove(&nd_region->dax_ida, nd_pfn->id);
+ kfree(nd_pfn->uuid);
+ kfree(nd_dax_kmem);
+}
+
+static struct device_type nd_dax_kmem_device_type = {
+ .name = "nd_dax_kmem",
+ .release = nd_dax_kmem_release,
+};
+
+bool is_nd_dax_kmem(struct device *dev)
+{
+ return dev ? dev->type == &nd_dax_kmem_device_type : false;
+}
+EXPORT_SYMBOL(is_nd_dax_kmem);
+
+struct nd_dax_kmem *to_nd_dax_kmem(struct device *dev)
+{
+ struct nd_dax_kmem *nd_dax_kmem = container_of(dev, struct nd_dax_kmem, nd_pfn.dev);
+
+ WARN_ON(!is_nd_dax_kmem(dev));
+ return nd_dax_kmem;
+}
+EXPORT_SYMBOL(to_nd_dax_kmem);
+/* end nd_dax_kmem */
+
static const struct attribute_group *nd_dax_attribute_groups[] = {
&nd_pfn_attribute_group,
&nd_device_attribute_group,
@@ -215,6 +215,10 @@ struct nd_dax {
struct nd_pfn nd_pfn;
};
+struct nd_dax_kmem {
+ struct nd_pfn nd_pfn;
+};
+
enum nd_async_mode {
ND_SYNC,
ND_ASYNC,
@@ -318,9 +322,11 @@ static inline int nd_pfn_validate(struct
#endif
struct nd_dax *to_nd_dax(struct device *dev);
+struct nd_dax_kmem *to_nd_dax_kmem(struct device *dev);
#if IS_ENABLED(CONFIG_NVDIMM_DAX)
int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns);
bool is_nd_dax(struct device *dev);
+bool is_nd_dax_kmem(struct device *dev);
struct device *nd_dax_create(struct nd_region *nd_region);
#else
static inline int nd_dax_probe(struct device *dev,