nvdimm/pmem: cleanup the disk if pmem_release_disk() is yet assigned
[linux-block.git] / drivers / nvdimm / pmem.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Persistent Memory Driver
4  *
5  * Copyright (c) 2014-2015, Intel Corporation.
6  * Copyright (c) 2015, Christoph Hellwig <hch@lst.de>.
7  * Copyright (c) 2015, Boaz Harrosh <boaz@plexistor.com>.
8  */
9
10 #include <linux/blkdev.h>
11 #include <linux/pagemap.h>
12 #include <linux/hdreg.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/set_memory.h>
16 #include <linux/module.h>
17 #include <linux/moduleparam.h>
18 #include <linux/badblocks.h>
19 #include <linux/memremap.h>
20 #include <linux/vmalloc.h>
21 #include <linux/blk-mq.h>
22 #include <linux/pfn_t.h>
23 #include <linux/slab.h>
24 #include <linux/uio.h>
25 #include <linux/dax.h>
26 #include <linux/nd.h>
27 #include <linux/mm.h>
28 #include <asm/cacheflush.h>
29 #include "pmem.h"
30 #include "btt.h"
31 #include "pfn.h"
32 #include "nd.h"
33
34 static struct device *to_dev(struct pmem_device *pmem)
35 {
36         /*
37          * nvdimm bus services need a 'dev' parameter, and we record the device
38          * at init in bb.dev.
39          */
40         return pmem->bb.dev;
41 }
42
43 static struct nd_region *to_region(struct pmem_device *pmem)
44 {
45         return to_nd_region(to_dev(pmem)->parent);
46 }
47
48 static void hwpoison_clear(struct pmem_device *pmem,
49                 phys_addr_t phys, unsigned int len)
50 {
51         unsigned long pfn_start, pfn_end, pfn;
52
53         /* only pmem in the linear map supports HWPoison */
54         if (is_vmalloc_addr(pmem->virt_addr))
55                 return;
56
57         pfn_start = PHYS_PFN(phys);
58         pfn_end = pfn_start + PHYS_PFN(len);
59         for (pfn = pfn_start; pfn < pfn_end; pfn++) {
60                 struct page *page = pfn_to_page(pfn);
61
62                 /*
63                  * Note, no need to hold a get_dev_pagemap() reference
64                  * here since we're in the driver I/O path and
65                  * outstanding I/O requests pin the dev_pagemap.
66                  */
67                 if (test_and_clear_pmem_poison(page))
68                         clear_mce_nospec(pfn);
69         }
70 }
71
72 static blk_status_t pmem_clear_poison(struct pmem_device *pmem,
73                 phys_addr_t offset, unsigned int len)
74 {
75         struct device *dev = to_dev(pmem);
76         sector_t sector;
77         long cleared;
78         blk_status_t rc = BLK_STS_OK;
79
80         sector = (offset - pmem->data_offset) / 512;
81
82         cleared = nvdimm_clear_poison(dev, pmem->phys_addr + offset, len);
83         if (cleared < len)
84                 rc = BLK_STS_IOERR;
85         if (cleared > 0 && cleared / 512) {
86                 hwpoison_clear(pmem, pmem->phys_addr + offset, cleared);
87                 cleared /= 512;
88                 dev_dbg(dev, "%#llx clear %ld sector%s\n",
89                                 (unsigned long long) sector, cleared,
90                                 cleared > 1 ? "s" : "");
91                 badblocks_clear(&pmem->bb, sector, cleared);
92                 if (pmem->bb_state)
93                         sysfs_notify_dirent(pmem->bb_state);
94         }
95
96         arch_invalidate_pmem(pmem->virt_addr + offset, len);
97
98         return rc;
99 }
100
101 static void write_pmem(void *pmem_addr, struct page *page,
102                 unsigned int off, unsigned int len)
103 {
104         unsigned int chunk;
105         void *mem;
106
107         while (len) {
108                 mem = kmap_atomic(page);
109                 chunk = min_t(unsigned int, len, PAGE_SIZE - off);
110                 memcpy_flushcache(pmem_addr, mem + off, chunk);
111                 kunmap_atomic(mem);
112                 len -= chunk;
113                 off = 0;
114                 page++;
115                 pmem_addr += chunk;
116         }
117 }
118
119 static blk_status_t read_pmem(struct page *page, unsigned int off,
120                 void *pmem_addr, unsigned int len)
121 {
122         unsigned int chunk;
123         unsigned long rem;
124         void *mem;
125
126         while (len) {
127                 mem = kmap_atomic(page);
128                 chunk = min_t(unsigned int, len, PAGE_SIZE - off);
129                 rem = copy_mc_to_kernel(mem + off, pmem_addr, chunk);
130                 kunmap_atomic(mem);
131                 if (rem)
132                         return BLK_STS_IOERR;
133                 len -= chunk;
134                 off = 0;
135                 page++;
136                 pmem_addr += chunk;
137         }
138         return BLK_STS_OK;
139 }
140
141 static blk_status_t pmem_do_read(struct pmem_device *pmem,
142                         struct page *page, unsigned int page_off,
143                         sector_t sector, unsigned int len)
144 {
145         blk_status_t rc;
146         phys_addr_t pmem_off = sector * 512 + pmem->data_offset;
147         void *pmem_addr = pmem->virt_addr + pmem_off;
148
149         if (unlikely(is_bad_pmem(&pmem->bb, sector, len)))
150                 return BLK_STS_IOERR;
151
152         rc = read_pmem(page, page_off, pmem_addr, len);
153         flush_dcache_page(page);
154         return rc;
155 }
156
157 static blk_status_t pmem_do_write(struct pmem_device *pmem,
158                         struct page *page, unsigned int page_off,
159                         sector_t sector, unsigned int len)
160 {
161         blk_status_t rc = BLK_STS_OK;
162         bool bad_pmem = false;
163         phys_addr_t pmem_off = sector * 512 + pmem->data_offset;
164         void *pmem_addr = pmem->virt_addr + pmem_off;
165
166         if (unlikely(is_bad_pmem(&pmem->bb, sector, len)))
167                 bad_pmem = true;
168
169         /*
170          * Note that we write the data both before and after
171          * clearing poison.  The write before clear poison
172          * handles situations where the latest written data is
173          * preserved and the clear poison operation simply marks
174          * the address range as valid without changing the data.
175          * In this case application software can assume that an
176          * interrupted write will either return the new good
177          * data or an error.
178          *
179          * However, if pmem_clear_poison() leaves the data in an
180          * indeterminate state we need to perform the write
181          * after clear poison.
182          */
183         flush_dcache_page(page);
184         write_pmem(pmem_addr, page, page_off, len);
185         if (unlikely(bad_pmem)) {
186                 rc = pmem_clear_poison(pmem, pmem_off, len);
187                 write_pmem(pmem_addr, page, page_off, len);
188         }
189
190         return rc;
191 }
192
193 static void pmem_submit_bio(struct bio *bio)
194 {
195         int ret = 0;
196         blk_status_t rc = 0;
197         bool do_acct;
198         unsigned long start;
199         struct bio_vec bvec;
200         struct bvec_iter iter;
201         struct pmem_device *pmem = bio->bi_bdev->bd_disk->private_data;
202         struct nd_region *nd_region = to_region(pmem);
203
204         if (bio->bi_opf & REQ_PREFLUSH)
205                 ret = nvdimm_flush(nd_region, bio);
206
207         do_acct = blk_queue_io_stat(bio->bi_bdev->bd_disk->queue);
208         if (do_acct)
209                 start = bio_start_io_acct(bio);
210         bio_for_each_segment(bvec, bio, iter) {
211                 if (op_is_write(bio_op(bio)))
212                         rc = pmem_do_write(pmem, bvec.bv_page, bvec.bv_offset,
213                                 iter.bi_sector, bvec.bv_len);
214                 else
215                         rc = pmem_do_read(pmem, bvec.bv_page, bvec.bv_offset,
216                                 iter.bi_sector, bvec.bv_len);
217                 if (rc) {
218                         bio->bi_status = rc;
219                         break;
220                 }
221         }
222         if (do_acct)
223                 bio_end_io_acct(bio, start);
224
225         if (bio->bi_opf & REQ_FUA)
226                 ret = nvdimm_flush(nd_region, bio);
227
228         if (ret)
229                 bio->bi_status = errno_to_blk_status(ret);
230
231         bio_endio(bio);
232 }
233
234 static int pmem_rw_page(struct block_device *bdev, sector_t sector,
235                        struct page *page, unsigned int op)
236 {
237         struct pmem_device *pmem = bdev->bd_disk->private_data;
238         blk_status_t rc;
239
240         if (op_is_write(op))
241                 rc = pmem_do_write(pmem, page, 0, sector, thp_size(page));
242         else
243                 rc = pmem_do_read(pmem, page, 0, sector, thp_size(page));
244         /*
245          * The ->rw_page interface is subtle and tricky.  The core
246          * retries on any error, so we can only invoke page_endio() in
247          * the successful completion case.  Otherwise, we'll see crashes
248          * caused by double completion.
249          */
250         if (rc == 0)
251                 page_endio(page, op_is_write(op), 0);
252
253         return blk_status_to_errno(rc);
254 }
255
256 /* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */
257 __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
258                 long nr_pages, void **kaddr, pfn_t *pfn)
259 {
260         resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset;
261
262         if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
263                                         PFN_PHYS(nr_pages))))
264                 return -EIO;
265
266         if (kaddr)
267                 *kaddr = pmem->virt_addr + offset;
268         if (pfn)
269                 *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags);
270
271         /*
272          * If badblocks are present, limit known good range to the
273          * requested range.
274          */
275         if (unlikely(pmem->bb.count))
276                 return nr_pages;
277         return PHYS_PFN(pmem->size - pmem->pfn_pad - offset);
278 }
279
280 static const struct block_device_operations pmem_fops = {
281         .owner =                THIS_MODULE,
282         .submit_bio =           pmem_submit_bio,
283         .rw_page =              pmem_rw_page,
284 };
285
286 static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
287                                     size_t nr_pages)
288 {
289         struct pmem_device *pmem = dax_get_private(dax_dev);
290
291         return blk_status_to_errno(pmem_do_write(pmem, ZERO_PAGE(0), 0,
292                                    PFN_PHYS(pgoff) >> SECTOR_SHIFT,
293                                    PAGE_SIZE));
294 }
295
296 static long pmem_dax_direct_access(struct dax_device *dax_dev,
297                 pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn)
298 {
299         struct pmem_device *pmem = dax_get_private(dax_dev);
300
301         return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn);
302 }
303
304 /*
305  * Use the 'no check' versions of copy_from_iter_flushcache() and
306  * copy_mc_to_iter() to bypass HARDENED_USERCOPY overhead. Bounds
307  * checking, both file offset and device offset, is handled by
308  * dax_iomap_actor()
309  */
310 static size_t pmem_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff,
311                 void *addr, size_t bytes, struct iov_iter *i)
312 {
313         return _copy_from_iter_flushcache(addr, bytes, i);
314 }
315
316 static size_t pmem_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff,
317                 void *addr, size_t bytes, struct iov_iter *i)
318 {
319         return _copy_mc_to_iter(addr, bytes, i);
320 }
321
322 static const struct dax_operations pmem_dax_ops = {
323         .direct_access = pmem_dax_direct_access,
324         .dax_supported = generic_fsdax_supported,
325         .copy_from_iter = pmem_copy_from_iter,
326         .copy_to_iter = pmem_copy_to_iter,
327         .zero_page_range = pmem_dax_zero_page_range,
328 };
329
330 static const struct attribute_group *pmem_attribute_groups[] = {
331         &dax_attribute_group,
332         NULL,
333 };
334
335 static void pmem_pagemap_cleanup(struct dev_pagemap *pgmap)
336 {
337         struct pmem_device *pmem = pgmap->owner;
338
339         blk_cleanup_disk(pmem->disk);
340 }
341
342 static void pmem_release_queue(void *pgmap)
343 {
344         pmem_pagemap_cleanup(pgmap);
345 }
346
347 static void pmem_pagemap_kill(struct dev_pagemap *pgmap)
348 {
349         struct request_queue *q =
350                 container_of(pgmap->ref, struct request_queue, q_usage_counter);
351
352         blk_freeze_queue_start(q);
353 }
354
355 static void pmem_release_disk(void *__pmem)
356 {
357         struct pmem_device *pmem = __pmem;
358
359         kill_dax(pmem->dax_dev);
360         put_dax(pmem->dax_dev);
361         del_gendisk(pmem->disk);
362 }
363
364 static const struct dev_pagemap_ops fsdax_pagemap_ops = {
365         .kill                   = pmem_pagemap_kill,
366         .cleanup                = pmem_pagemap_cleanup,
367 };
368
369 static int pmem_attach_disk(struct device *dev,
370                 struct nd_namespace_common *ndns)
371 {
372         struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
373         struct nd_region *nd_region = to_nd_region(dev->parent);
374         int nid = dev_to_node(dev), fua;
375         struct resource *res = &nsio->res;
376         struct range bb_range;
377         struct nd_pfn *nd_pfn = NULL;
378         struct dax_device *dax_dev;
379         struct nd_pfn_sb *pfn_sb;
380         struct pmem_device *pmem;
381         struct request_queue *q;
382         struct gendisk *disk;
383         void *addr;
384         int rc;
385         unsigned long flags = 0UL;
386
387         pmem = devm_kzalloc(dev, sizeof(*pmem), GFP_KERNEL);
388         if (!pmem)
389                 return -ENOMEM;
390
391         rc = devm_namespace_enable(dev, ndns, nd_info_block_reserve());
392         if (rc)
393                 return rc;
394
395         /* while nsio_rw_bytes is active, parse a pfn info block if present */
396         if (is_nd_pfn(dev)) {
397                 nd_pfn = to_nd_pfn(dev);
398                 rc = nvdimm_setup_pfn(nd_pfn, &pmem->pgmap);
399                 if (rc)
400                         return rc;
401         }
402
403         /* we're attaching a block device, disable raw namespace access */
404         devm_namespace_disable(dev, ndns);
405
406         dev_set_drvdata(dev, pmem);
407         pmem->phys_addr = res->start;
408         pmem->size = resource_size(res);
409         fua = nvdimm_has_flush(nd_region);
410         if (!IS_ENABLED(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) || fua < 0) {
411                 dev_warn(dev, "unable to guarantee persistence of writes\n");
412                 fua = 0;
413         }
414
415         if (!devm_request_mem_region(dev, res->start, resource_size(res),
416                                 dev_name(&ndns->dev))) {
417                 dev_warn(dev, "could not reserve region %pR\n", res);
418                 return -EBUSY;
419         }
420
421         disk = blk_alloc_disk(nid);
422         if (!disk)
423                 return -ENOMEM;
424         q = disk->queue;
425
426         pmem->disk = disk;
427         pmem->pgmap.owner = pmem;
428         pmem->pfn_flags = PFN_DEV;
429         pmem->pgmap.ref = &q->q_usage_counter;
430         if (is_nd_pfn(dev)) {
431                 pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
432                 pmem->pgmap.ops = &fsdax_pagemap_ops;
433                 addr = devm_memremap_pages(dev, &pmem->pgmap);
434                 pfn_sb = nd_pfn->pfn_sb;
435                 pmem->data_offset = le64_to_cpu(pfn_sb->dataoff);
436                 pmem->pfn_pad = resource_size(res) -
437                         range_len(&pmem->pgmap.range);
438                 pmem->pfn_flags |= PFN_MAP;
439                 bb_range = pmem->pgmap.range;
440                 bb_range.start += pmem->data_offset;
441         } else if (pmem_should_map_pages(dev)) {
442                 pmem->pgmap.range.start = res->start;
443                 pmem->pgmap.range.end = res->end;
444                 pmem->pgmap.nr_range = 1;
445                 pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
446                 pmem->pgmap.ops = &fsdax_pagemap_ops;
447                 addr = devm_memremap_pages(dev, &pmem->pgmap);
448                 pmem->pfn_flags |= PFN_MAP;
449                 bb_range = pmem->pgmap.range;
450         } else {
451                 addr = devm_memremap(dev, pmem->phys_addr,
452                                 pmem->size, ARCH_MEMREMAP_PMEM);
453                 if (devm_add_action_or_reset(dev, pmem_release_queue,
454                                         &pmem->pgmap))
455                         return -ENOMEM;
456                 bb_range.start =  res->start;
457                 bb_range.end = res->end;
458         }
459
460         if (IS_ERR(addr)) {
461                 rc = PTR_ERR(addr);
462                 goto out;
463         }
464         pmem->virt_addr = addr;
465
466         blk_queue_write_cache(q, true, fua);
467         blk_queue_physical_block_size(q, PAGE_SIZE);
468         blk_queue_logical_block_size(q, pmem_sector_size(ndns));
469         blk_queue_max_hw_sectors(q, UINT_MAX);
470         blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
471         if (pmem->pfn_flags & PFN_MAP)
472                 blk_queue_flag_set(QUEUE_FLAG_DAX, q);
473
474         disk->fops              = &pmem_fops;
475         disk->private_data      = pmem;
476         nvdimm_namespace_disk_name(ndns, disk->disk_name);
477         set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
478                         / 512);
479         if (devm_init_badblocks(dev, &pmem->bb))
480                 return -ENOMEM;
481         nvdimm_badblocks_populate(nd_region, &pmem->bb, &bb_range);
482         disk->bb = &pmem->bb;
483
484         if (is_nvdimm_sync(nd_region))
485                 flags = DAXDEV_F_SYNC;
486         dax_dev = alloc_dax(pmem, disk->disk_name, &pmem_dax_ops, flags);
487         if (IS_ERR(dax_dev)) {
488                 rc = PTR_ERR(dax_dev);
489                 goto out;
490         }
491         dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
492         pmem->dax_dev = dax_dev;
493
494         device_add_disk(dev, disk, pmem_attribute_groups);
495         if (devm_add_action_or_reset(dev, pmem_release_disk, pmem))
496                 return -ENOMEM;
497
498         nvdimm_check_and_set_ro(disk);
499
500         pmem->bb_state = sysfs_get_dirent(disk_to_dev(disk)->kobj.sd,
501                                           "badblocks");
502         if (!pmem->bb_state)
503                 dev_warn(dev, "'badblocks' notification disabled\n");
504         return 0;
505 out:
506         blk_cleanup_disk(pmem->disk);
507         return rc;
508 }
509
510 static int nd_pmem_probe(struct device *dev)
511 {
512         int ret;
513         struct nd_namespace_common *ndns;
514
515         ndns = nvdimm_namespace_common_probe(dev);
516         if (IS_ERR(ndns))
517                 return PTR_ERR(ndns);
518
519         if (is_nd_btt(dev))
520                 return nvdimm_namespace_attach_btt(ndns);
521
522         if (is_nd_pfn(dev))
523                 return pmem_attach_disk(dev, ndns);
524
525         ret = devm_namespace_enable(dev, ndns, nd_info_block_reserve());
526         if (ret)
527                 return ret;
528
529         ret = nd_btt_probe(dev, ndns);
530         if (ret == 0)
531                 return -ENXIO;
532
533         /*
534          * We have two failure conditions here, there is no
535          * info reserver block or we found a valid info reserve block
536          * but failed to initialize the pfn superblock.
537          *
538          * For the first case consider namespace as a raw pmem namespace
539          * and attach a disk.
540          *
541          * For the latter, consider this a success and advance the namespace
542          * seed.
543          */
544         ret = nd_pfn_probe(dev, ndns);
545         if (ret == 0)
546                 return -ENXIO;
547         else if (ret == -EOPNOTSUPP)
548                 return ret;
549
550         ret = nd_dax_probe(dev, ndns);
551         if (ret == 0)
552                 return -ENXIO;
553         else if (ret == -EOPNOTSUPP)
554                 return ret;
555
556         /* probe complete, attach handles namespace enabling */
557         devm_namespace_disable(dev, ndns);
558
559         return pmem_attach_disk(dev, ndns);
560 }
561
562 static void nd_pmem_remove(struct device *dev)
563 {
564         struct pmem_device *pmem = dev_get_drvdata(dev);
565
566         if (is_nd_btt(dev))
567                 nvdimm_namespace_detach_btt(to_nd_btt(dev));
568         else {
569                 /*
570                  * Note, this assumes nd_device_lock() context to not
571                  * race nd_pmem_notify()
572                  */
573                 sysfs_put(pmem->bb_state);
574                 pmem->bb_state = NULL;
575         }
576         nvdimm_flush(to_nd_region(dev->parent), NULL);
577 }
578
579 static void nd_pmem_shutdown(struct device *dev)
580 {
581         nvdimm_flush(to_nd_region(dev->parent), NULL);
582 }
583
584 static void pmem_revalidate_poison(struct device *dev)
585 {
586         struct nd_region *nd_region;
587         resource_size_t offset = 0, end_trunc = 0;
588         struct nd_namespace_common *ndns;
589         struct nd_namespace_io *nsio;
590         struct badblocks *bb;
591         struct range range;
592         struct kernfs_node *bb_state;
593
594         if (is_nd_btt(dev)) {
595                 struct nd_btt *nd_btt = to_nd_btt(dev);
596
597                 ndns = nd_btt->ndns;
598                 nd_region = to_nd_region(ndns->dev.parent);
599                 nsio = to_nd_namespace_io(&ndns->dev);
600                 bb = &nsio->bb;
601                 bb_state = NULL;
602         } else {
603                 struct pmem_device *pmem = dev_get_drvdata(dev);
604
605                 nd_region = to_region(pmem);
606                 bb = &pmem->bb;
607                 bb_state = pmem->bb_state;
608
609                 if (is_nd_pfn(dev)) {
610                         struct nd_pfn *nd_pfn = to_nd_pfn(dev);
611                         struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
612
613                         ndns = nd_pfn->ndns;
614                         offset = pmem->data_offset +
615                                         __le32_to_cpu(pfn_sb->start_pad);
616                         end_trunc = __le32_to_cpu(pfn_sb->end_trunc);
617                 } else {
618                         ndns = to_ndns(dev);
619                 }
620
621                 nsio = to_nd_namespace_io(&ndns->dev);
622         }
623
624         range.start = nsio->res.start + offset;
625         range.end = nsio->res.end - end_trunc;
626         nvdimm_badblocks_populate(nd_region, bb, &range);
627         if (bb_state)
628                 sysfs_notify_dirent(bb_state);
629 }
630
631 static void pmem_revalidate_region(struct device *dev)
632 {
633         struct pmem_device *pmem;
634
635         if (is_nd_btt(dev)) {
636                 struct nd_btt *nd_btt = to_nd_btt(dev);
637                 struct btt *btt = nd_btt->btt;
638
639                 nvdimm_check_and_set_ro(btt->btt_disk);
640                 return;
641         }
642
643         pmem = dev_get_drvdata(dev);
644         nvdimm_check_and_set_ro(pmem->disk);
645 }
646
647 static void nd_pmem_notify(struct device *dev, enum nvdimm_event event)
648 {
649         switch (event) {
650         case NVDIMM_REVALIDATE_POISON:
651                 pmem_revalidate_poison(dev);
652                 break;
653         case NVDIMM_REVALIDATE_REGION:
654                 pmem_revalidate_region(dev);
655                 break;
656         default:
657                 dev_WARN_ONCE(dev, 1, "notify: unknown event: %d\n", event);
658                 break;
659         }
660 }
661
662 MODULE_ALIAS("pmem");
663 MODULE_ALIAS_ND_DEVICE(ND_DEVICE_NAMESPACE_IO);
664 MODULE_ALIAS_ND_DEVICE(ND_DEVICE_NAMESPACE_PMEM);
665 static struct nd_device_driver nd_pmem_driver = {
666         .probe = nd_pmem_probe,
667         .remove = nd_pmem_remove,
668         .notify = nd_pmem_notify,
669         .shutdown = nd_pmem_shutdown,
670         .drv = {
671                 .name = "nd_pmem",
672         },
673         .type = ND_DRIVER_NAMESPACE_IO | ND_DRIVER_NAMESPACE_PMEM,
674 };
675
676 module_nd_driver(nd_pmem_driver);
677
678 MODULE_AUTHOR("Ross Zwisler <ross.zwisler@linux.intel.com>");
679 MODULE_LICENSE("GPL v2");