15b497af4SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 24d88a97aSDan Williams /* 34d88a97aSDan Williams * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. 44d88a97aSDan Williams */ 54d88a97aSDan Williams #ifndef __ND_H__ 64d88a97aSDan Williams #define __ND_H__ 71f7df6f8SDan Williams #include <linux/libnvdimm.h> 8200c79daSDan Williams #include <linux/badblocks.h> 9f0dc089cSDan Williams #include <linux/blkdev.h> 104d88a97aSDan Williams #include <linux/device.h> 114d88a97aSDan Williams #include <linux/mutex.h> 124d88a97aSDan Williams #include <linux/ndctl.h> 13bf9bccc1SDan Williams #include <linux/types.h> 1471999466SDan Williams #include <linux/nd.h> 154a826c83SDan Williams #include "label.h" 164d88a97aSDan Williams 178c2f7e86SDan Williams enum { 185212e11fSVishal Verma /* 195212e11fSVishal Verma * Limits the maximum number of block apertures a dimm can 205212e11fSVishal Verma * support and is an input to the geometry/on-disk-format of a 215212e11fSVishal Verma * BTT instance 225212e11fSVishal Verma */ 235212e11fSVishal Verma ND_MAX_LANES = 256, 24fcae6957SVishal Verma INT_LBASIZE_ALIGNMENT = 64, 253ae3d67bSVishal Verma NVDIMM_IO_ATOMIC = 1, 268c2f7e86SDan Williams }; 278c2f7e86SDan Williams 284d88a97aSDan Williams struct nvdimm_drvdata { 294d88a97aSDan Williams struct device *dev; 3002881768SDan Williams int nslabel_size; 314d88a97aSDan Williams struct nd_cmd_get_config_size nsarea; 324d88a97aSDan Williams void *data; 334a826c83SDan Williams int ns_current, ns_next; 344a826c83SDan Williams struct resource dpa; 35bf9bccc1SDan Williams struct kref kref; 364d88a97aSDan Williams }; 374d88a97aSDan Williams 38e5ae3b25SDan Williams struct nd_region_data { 39e5ae3b25SDan Williams int ns_count; 40e5ae3b25SDan Williams int ns_active; 41595c7307SDan Williams unsigned int hints_shift; 42595c7307SDan Williams void __iomem *flush_wpq[0]; 433d88002eSDan Williams }; 443d88002eSDan Williams 45595c7307SDan Williams static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd, 46595c7307SDan Williams int dimm, int hint) 47595c7307SDan Williams { 48595c7307SDan Williams unsigned int num = 1 << ndrd->hints_shift; 49595c7307SDan Williams unsigned int mask = num - 1; 50595c7307SDan Williams 51595c7307SDan Williams return ndrd->flush_wpq[dimm * num + (hint & mask)]; 52595c7307SDan Williams } 53595c7307SDan Williams 54595c7307SDan Williams static inline void ndrd_set_flush_wpq(struct nd_region_data *ndrd, int dimm, 55595c7307SDan Williams int hint, void __iomem *flush) 56595c7307SDan Williams { 57595c7307SDan Williams unsigned int num = 1 << ndrd->hints_shift; 58595c7307SDan Williams unsigned int mask = num - 1; 59595c7307SDan Williams 60595c7307SDan Williams ndrd->flush_wpq[dimm * num + (hint & mask)] = flush; 61595c7307SDan Williams } 62595c7307SDan Williams 634a826c83SDan Williams static inline struct nd_namespace_index *to_namespace_index( 644a826c83SDan Williams struct nvdimm_drvdata *ndd, int i) 654a826c83SDan Williams { 664a826c83SDan Williams if (i < 0) 674a826c83SDan Williams return NULL; 684a826c83SDan Williams 694a826c83SDan Williams return ndd->data + sizeof_namespace_index(ndd) * i; 704a826c83SDan Williams } 714a826c83SDan Williams 724a826c83SDan Williams static inline struct nd_namespace_index *to_current_namespace_index( 734a826c83SDan Williams struct nvdimm_drvdata *ndd) 744a826c83SDan Williams { 754a826c83SDan Williams return to_namespace_index(ndd, ndd->ns_current); 764a826c83SDan Williams } 774a826c83SDan Williams 784a826c83SDan Williams static inline struct nd_namespace_index *to_next_namespace_index( 794a826c83SDan Williams struct nvdimm_drvdata *ndd) 804a826c83SDan Williams { 814a826c83SDan Williams return to_namespace_index(ndd, ndd->ns_next); 824a826c83SDan Williams } 834a826c83SDan Williams 84564e871aSDan Williams unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd); 85564e871aSDan Williams 86564e871aSDan Williams #define namespace_label_has(ndd, field) \ 87564e871aSDan Williams (offsetof(struct nd_namespace_label, field) \ 88564e871aSDan Williams < sizeof_namespace_label(ndd)) 89564e871aSDan Williams 904a826c83SDan Williams #define nd_dbg_dpa(r, d, res, fmt, arg...) \ 914a826c83SDan Williams dev_dbg((r) ? &(r)->dev : (d)->dev, "%s: %.13s: %#llx @ %#llx " fmt, \ 924a826c83SDan Williams (r) ? dev_name((d)->dev) : "", res ? res->name : "null", \ 934a826c83SDan Williams (unsigned long long) (res ? resource_size(res) : 0), \ 944a826c83SDan Williams (unsigned long long) (res ? res->start : 0), ##arg) 954a826c83SDan Williams 96bf9bccc1SDan Williams #define for_each_dpa_resource(ndd, res) \ 97bf9bccc1SDan Williams for (res = (ndd)->dpa.child; res; res = res->sibling) 98bf9bccc1SDan Williams 994a826c83SDan Williams #define for_each_dpa_resource_safe(ndd, res, next) \ 1004a826c83SDan Williams for (res = (ndd)->dpa.child, next = res ? res->sibling : NULL; \ 1014a826c83SDan Williams res; res = next, next = next ? next->sibling : NULL) 1024a826c83SDan Williams 1035212e11fSVishal Verma struct nd_percpu_lane { 1045212e11fSVishal Verma int count; 1055212e11fSVishal Verma spinlock_t lock; 1065212e11fSVishal Verma }; 1075212e11fSVishal Verma 108c4703ce1SDan Williams enum nd_label_flags { 109c4703ce1SDan Williams ND_LABEL_REAP, 110c4703ce1SDan Williams }; 111ae8219f1SDan Williams struct nd_label_ent { 112ae8219f1SDan Williams struct list_head list; 113c4703ce1SDan Williams unsigned long flags; 114ae8219f1SDan Williams struct nd_namespace_label *label; 115ae8219f1SDan Williams }; 116ae8219f1SDan Williams 117ae8219f1SDan Williams enum nd_mapping_lock_class { 118ae8219f1SDan Williams ND_MAPPING_CLASS0, 119ae8219f1SDan Williams ND_MAPPING_UUID_SCAN, 120ae8219f1SDan Williams }; 121ae8219f1SDan Williams 12244c462ebSDan Williams struct nd_mapping { 12344c462ebSDan Williams struct nvdimm *nvdimm; 12444c462ebSDan Williams u64 start; 12544c462ebSDan Williams u64 size; 126401c0a19SDan Williams int position; 127ae8219f1SDan Williams struct list_head labels; 128ae8219f1SDan Williams struct mutex lock; 12944c462ebSDan Williams /* 13044c462ebSDan Williams * @ndd is for private use at region enable / disable time for 13144c462ebSDan Williams * get_ndd() + put_ndd(), all other nd_mapping to ndd 13244c462ebSDan Williams * conversions use to_ndd() which respects enabled state of the 13344c462ebSDan Williams * nvdimm. 13444c462ebSDan Williams */ 13544c462ebSDan Williams struct nvdimm_drvdata *ndd; 13644c462ebSDan Williams }; 13744c462ebSDan Williams 1381f7df6f8SDan Williams struct nd_region { 1391f7df6f8SDan Williams struct device dev; 1401b40e09aSDan Williams struct ida ns_ida; 1418c2f7e86SDan Williams struct ida btt_ida; 142e1455744SDan Williams struct ida pfn_ida; 143cd03412aSDan Williams struct ida dax_ida; 144004f1afbSDan Williams unsigned long flags; 145bf9bccc1SDan Williams struct device *ns_seed; 1468c2f7e86SDan Williams struct device *btt_seed; 147e1455744SDan Williams struct device *pfn_seed; 148cd03412aSDan Williams struct device *dax_seed; 1491f7df6f8SDan Williams u16 ndr_mappings; 1501f7df6f8SDan Williams u64 ndr_size; 1511f7df6f8SDan Williams u64 ndr_start; 1528fc5c735SDan Williams int id, num_lanes, ro, numa_node, target_node; 1531f7df6f8SDan Williams void *provider_data; 154975750a9SToshi Kani struct kernfs_node *bb_state; 1556a6bef90SDave Jiang struct badblocks bb; 156eaf96153SDan Williams struct nd_interleave_set *nd_set; 1575212e11fSVishal Verma struct nd_percpu_lane __percpu *lane; 158c5d4355dSPankaj Gupta int (*flush)(struct nd_region *nd_region, struct bio *bio); 1591f7df6f8SDan Williams struct nd_mapping mapping[0]; 1601f7df6f8SDan Williams }; 1611f7df6f8SDan Williams 162047fc8a1SRoss Zwisler struct nd_blk_region { 163047fc8a1SRoss Zwisler int (*enable)(struct nvdimm_bus *nvdimm_bus, struct device *dev); 164047fc8a1SRoss Zwisler int (*do_io)(struct nd_blk_region *ndbr, resource_size_t dpa, 165047fc8a1SRoss Zwisler void *iobuf, u64 len, int rw); 166047fc8a1SRoss Zwisler void *blk_provider_data; 167047fc8a1SRoss Zwisler struct nd_region nd_region; 168047fc8a1SRoss Zwisler }; 169047fc8a1SRoss Zwisler 1704a826c83SDan Williams /* 1714a826c83SDan Williams * Lookup next in the repeating sequence of 01, 10, and 11. 1724a826c83SDan Williams */ 1734a826c83SDan Williams static inline unsigned nd_inc_seq(unsigned seq) 1744a826c83SDan Williams { 1754a826c83SDan Williams static const unsigned next[] = { 0, 2, 3, 1 }; 1764a826c83SDan Williams 1774a826c83SDan Williams return next[seq & 3]; 1784a826c83SDan Williams } 179f524bf27SDan Williams 1805212e11fSVishal Verma struct btt; 1818c2f7e86SDan Williams struct nd_btt { 1828c2f7e86SDan Williams struct device dev; 1838c2f7e86SDan Williams struct nd_namespace_common *ndns; 1845212e11fSVishal Verma struct btt *btt; 1858c2f7e86SDan Williams unsigned long lbasize; 186abe8b4e3SVishal Verma u64 size; 1878c2f7e86SDan Williams u8 *uuid; 1888c2f7e86SDan Williams int id; 18914e49454SVishal Verma int initial_offset; 19014e49454SVishal Verma u16 version_major; 19114e49454SVishal Verma u16 version_minor; 1928c2f7e86SDan Williams }; 1938c2f7e86SDan Williams 194e1455744SDan Williams enum nd_pfn_mode { 195e1455744SDan Williams PFN_MODE_NONE, 196e1455744SDan Williams PFN_MODE_RAM, 197e1455744SDan Williams PFN_MODE_PMEM, 198e1455744SDan Williams }; 199e1455744SDan Williams 200e1455744SDan Williams struct nd_pfn { 201e1455744SDan Williams int id; 202e1455744SDan Williams u8 *uuid; 203e1455744SDan Williams struct device dev; 204315c5625SDan Williams unsigned long align; 205e1455744SDan Williams unsigned long npfns; 206e1455744SDan Williams enum nd_pfn_mode mode; 207e1455744SDan Williams struct nd_pfn_sb *pfn_sb; 208e1455744SDan Williams struct nd_namespace_common *ndns; 209e1455744SDan Williams }; 210e1455744SDan Williams 211cd03412aSDan Williams struct nd_dax { 212cd03412aSDan Williams struct nd_pfn nd_pfn; 213cd03412aSDan Williams }; 214cd03412aSDan Williams 2158f4b01fcSAneesh Kumar K.V static inline u32 nd_info_block_reserve(void) 2168f4b01fcSAneesh Kumar K.V { 2178f4b01fcSAneesh Kumar K.V return ALIGN(SZ_8K, PAGE_SIZE); 2188f4b01fcSAneesh Kumar K.V } 2198f4b01fcSAneesh Kumar K.V 2204d88a97aSDan Williams enum nd_async_mode { 2214d88a97aSDan Williams ND_SYNC, 2224d88a97aSDan Williams ND_ASYNC, 2234d88a97aSDan Williams }; 2244d88a97aSDan Williams 22541cd8b70SVishal Verma int nd_integrity_init(struct gendisk *disk, unsigned long meta_size); 226bf9bccc1SDan Williams void wait_nvdimm_bus_probe_idle(struct device *dev); 2274d88a97aSDan Williams void nd_device_register(struct device *dev); 2284d88a97aSDan Williams void nd_device_unregister(struct device *dev, enum nd_async_mode mode); 22971999466SDan Williams void nd_device_notify(struct device *dev, enum nvdimm_event event); 230bf9bccc1SDan Williams int nd_uuid_store(struct device *dev, u8 **uuid_out, const char *buf, 231bf9bccc1SDan Williams size_t len); 232b2c48f9fSDan Williams ssize_t nd_size_select_show(unsigned long current_size, 2331b40e09aSDan Williams const unsigned long *supported, char *buf); 234b2c48f9fSDan Williams ssize_t nd_size_select_store(struct device *dev, const char *buf, 235b2c48f9fSDan Williams unsigned long *current_size, const unsigned long *supported); 2364d88a97aSDan Williams int __init nvdimm_init(void); 2373d88002eSDan Williams int __init nd_region_init(void); 238b3fde74eSDan Williams int __init nd_label_init(void); 2394d88a97aSDan Williams void nvdimm_exit(void); 2403d88002eSDan Williams void nd_region_exit(void); 241bf9bccc1SDan Williams struct nvdimm; 242adbb6829SDan Williams extern const struct attribute_group nd_device_attribute_group; 243e2f6a0e3SDan Williams extern const struct attribute_group nd_numa_attribute_group; 244e755799aSDan Williams extern const struct attribute_group *nvdimm_bus_attribute_groups[]; 245bf9bccc1SDan Williams struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping); 246aee65987SToshi Kani int nvdimm_check_config_data(struct device *dev); 2474d88a97aSDan Williams int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd); 2484d88a97aSDan Williams int nvdimm_init_config_data(struct nvdimm_drvdata *ndd); 2492d657d17SAlexander Duyck int nvdimm_get_config_data(struct nvdimm_drvdata *ndd, void *buf, 2502d657d17SAlexander Duyck size_t offset, size_t len); 251f524bf27SDan Williams int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, 252f524bf27SDan Williams void *buf, size_t len); 25359e64739SDan Williams long nvdimm_clear_poison(struct device *dev, phys_addr_t phys, 25459e64739SDan Williams unsigned int len); 255*a0e37452SDan Williams void nvdimm_set_labeling(struct device *dev); 2568f078b38SDan Williams void nvdimm_set_locked(struct device *dev); 257d34cb808SDan Williams void nvdimm_clear_locked(struct device *dev); 2581cd73865SDan Williams int nvdimm_security_setup_events(struct device *dev); 2594c6926a2SDave Jiang #if IS_ENABLED(CONFIG_NVDIMM_KEYS) 2604c6926a2SDave Jiang int nvdimm_security_unlock(struct device *dev); 2614c6926a2SDave Jiang #else 2624c6926a2SDave Jiang static inline int nvdimm_security_unlock(struct device *dev) 2634c6926a2SDave Jiang { 2644c6926a2SDave Jiang return 0; 2654c6926a2SDave Jiang } 2664c6926a2SDave Jiang #endif 2678c2f7e86SDan Williams struct nd_btt *to_nd_btt(struct device *dev); 268e1455744SDan Williams 269e1455744SDan Williams struct nd_gen_sb { 270e1455744SDan Williams char reserved[SZ_4K - 8]; 271e1455744SDan Williams __le64 checksum; 272e1455744SDan Williams }; 273e1455744SDan Williams 274e1455744SDan Williams u64 nd_sb_checksum(struct nd_gen_sb *sb); 2758c2f7e86SDan Williams #if IS_ENABLED(CONFIG_BTT) 276200c79daSDan Williams int nd_btt_probe(struct device *dev, struct nd_namespace_common *ndns); 2778c2f7e86SDan Williams bool is_nd_btt(struct device *dev); 2788c2f7e86SDan Williams struct device *nd_btt_create(struct nd_region *nd_region); 2798c2f7e86SDan Williams #else 280e32bc729SDan Williams static inline int nd_btt_probe(struct device *dev, 281200c79daSDan Williams struct nd_namespace_common *ndns) 2828c2f7e86SDan Williams { 2838c2f7e86SDan Williams return -ENODEV; 2848c2f7e86SDan Williams } 2858c2f7e86SDan Williams 2868c2f7e86SDan Williams static inline bool is_nd_btt(struct device *dev) 2878c2f7e86SDan Williams { 2888c2f7e86SDan Williams return false; 2898c2f7e86SDan Williams } 2908c2f7e86SDan Williams 2918c2f7e86SDan Williams static inline struct device *nd_btt_create(struct nd_region *nd_region) 2928c2f7e86SDan Williams { 2938c2f7e86SDan Williams return NULL; 2948c2f7e86SDan Williams } 2958c2f7e86SDan Williams #endif 296e1455744SDan Williams 297e1455744SDan Williams struct nd_pfn *to_nd_pfn(struct device *dev); 298e1455744SDan Williams #if IS_ENABLED(CONFIG_NVDIMM_PFN) 2990dd69643SOliver O'Halloran 300f5376699SAneesh Kumar K.V #define MAX_NVDIMM_ALIGN 4 3010dd69643SOliver O'Halloran 302200c79daSDan Williams int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns); 303e1455744SDan Williams bool is_nd_pfn(struct device *dev); 304e1455744SDan Williams struct device *nd_pfn_create(struct nd_region *nd_region); 305cd03412aSDan Williams struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn, 306cd03412aSDan Williams struct nd_namespace_common *ndns); 307c5ed9268SDan Williams int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig); 30878c81cc8SDan Williams extern const struct attribute_group *nd_pfn_attribute_groups[]; 309e1455744SDan Williams #else 310200c79daSDan Williams static inline int nd_pfn_probe(struct device *dev, 311200c79daSDan Williams struct nd_namespace_common *ndns) 312e1455744SDan Williams { 313e1455744SDan Williams return -ENODEV; 314e1455744SDan Williams } 315e1455744SDan Williams 316e1455744SDan Williams static inline bool is_nd_pfn(struct device *dev) 317e1455744SDan Williams { 318e1455744SDan Williams return false; 319e1455744SDan Williams } 320e1455744SDan Williams 321e1455744SDan Williams static inline struct device *nd_pfn_create(struct nd_region *nd_region) 322e1455744SDan Williams { 323e1455744SDan Williams return NULL; 324e1455744SDan Williams } 32532ab0a3fSDan Williams 326c5ed9268SDan Williams static inline int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) 32732ab0a3fSDan Williams { 32832ab0a3fSDan Williams return -ENODEV; 32932ab0a3fSDan Williams } 330e1455744SDan Williams #endif 331e1455744SDan Williams 332cd03412aSDan Williams struct nd_dax *to_nd_dax(struct device *dev); 333cd03412aSDan Williams #if IS_ENABLED(CONFIG_NVDIMM_DAX) 334c5ed9268SDan Williams int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns); 335cd03412aSDan Williams bool is_nd_dax(struct device *dev); 336cd03412aSDan Williams struct device *nd_dax_create(struct nd_region *nd_region); 337cd03412aSDan Williams #else 338c5ed9268SDan Williams static inline int nd_dax_probe(struct device *dev, 339c5ed9268SDan Williams struct nd_namespace_common *ndns) 340c5ed9268SDan Williams { 341c5ed9268SDan Williams return -ENODEV; 342c5ed9268SDan Williams } 343c5ed9268SDan Williams 344cd03412aSDan Williams static inline bool is_nd_dax(struct device *dev) 345cd03412aSDan Williams { 346cd03412aSDan Williams return false; 347cd03412aSDan Williams } 348cd03412aSDan Williams 349cd03412aSDan Williams static inline struct device *nd_dax_create(struct nd_region *nd_region) 350cd03412aSDan Williams { 351cd03412aSDan Williams return NULL; 352cd03412aSDan Williams } 353cd03412aSDan Williams #endif 354cd03412aSDan Williams 3553d88002eSDan Williams int nd_region_to_nstype(struct nd_region *nd_region); 3563d88002eSDan Williams int nd_region_register_namespaces(struct nd_region *nd_region, int *err); 357c12c48ceSDan Williams u64 nd_region_interleave_set_cookie(struct nd_region *nd_region, 358c12c48ceSDan Williams struct nd_namespace_index *nsindex); 35986ef58a4SDan Williams u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region); 3603d88002eSDan Williams void nvdimm_bus_lock(struct device *dev); 3613d88002eSDan Williams void nvdimm_bus_unlock(struct device *dev); 3623d88002eSDan Williams bool is_nvdimm_bus_locked(struct device *dev); 36358138820SDan Williams int nvdimm_revalidate_disk(struct gendisk *disk); 364bf9bccc1SDan Williams void nvdimm_drvdata_release(struct kref *kref); 365bf9bccc1SDan Williams void put_ndd(struct nvdimm_drvdata *ndd); 3664a826c83SDan Williams int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd); 3674a826c83SDan Williams void nvdimm_free_dpa(struct nvdimm_drvdata *ndd, struct resource *res); 3684a826c83SDan Williams struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd, 3694a826c83SDan Williams struct nd_label_id *label_id, resource_size_t start, 3704a826c83SDan Williams resource_size_t n); 3718c2f7e86SDan Williams resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns); 37208e6b3c6SDan Williams bool nvdimm_namespace_locked(struct nd_namespace_common *ndns); 3738c2f7e86SDan Williams struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev); 3745212e11fSVishal Verma int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns); 375298f2bc5SDan Williams int nvdimm_namespace_detach_btt(struct nd_btt *nd_btt); 3765212e11fSVishal Verma const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns, 3775212e11fSVishal Verma char *name); 378f979b13cSDan Williams unsigned int pmem_sector_size(struct nd_namespace_common *ndns); 379a3901802SDan Williams void nvdimm_badblocks_populate(struct nd_region *nd_region, 380a3901802SDan Williams struct badblocks *bb, const struct resource *res); 3818f4b01fcSAneesh Kumar K.V int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns, 3828f4b01fcSAneesh Kumar K.V resource_size_t size); 3838f4b01fcSAneesh Kumar K.V void devm_namespace_disable(struct device *dev, 3848f4b01fcSAneesh Kumar K.V struct nd_namespace_common *ndns); 385200c79daSDan Williams #if IS_ENABLED(CONFIG_ND_CLAIM) 386e96f0bf2SAneesh Kumar K.V /* max struct page size independent of kernel config */ 387e96f0bf2SAneesh Kumar K.V #define MAX_STRUCT_PAGE_SIZE 64 388e8d51348SChristoph Hellwig int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap); 389200c79daSDan Williams #else 390e8d51348SChristoph Hellwig static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, 391e8d51348SChristoph Hellwig struct dev_pagemap *pgmap) 392ac515c08SDan Williams { 393e8d51348SChristoph Hellwig return -ENXIO; 394ac515c08SDan Williams } 395200c79daSDan Williams #endif 396047fc8a1SRoss Zwisler int nd_blk_region_init(struct nd_region *nd_region); 397e5ae3b25SDan Williams int nd_region_activate(struct nd_region *nd_region); 398f0dc089cSDan Williams void __nd_iostat_start(struct bio *bio, unsigned long *start); 399f0dc089cSDan Williams static inline bool nd_iostat_start(struct bio *bio, unsigned long *start) 400f0dc089cSDan Williams { 40174d46992SChristoph Hellwig struct gendisk *disk = bio->bi_disk; 402f0dc089cSDan Williams 403f0dc089cSDan Williams if (!blk_queue_io_stat(disk->queue)) 404f0dc089cSDan Williams return false; 405f0dc089cSDan Williams 4068d7c22acSToshi Kani *start = jiffies; 407ddcf35d3SMichael Callahan generic_start_io_acct(disk->queue, bio_op(bio), bio_sectors(bio), 408ddcf35d3SMichael Callahan &disk->part0); 409f0dc089cSDan Williams return true; 410f0dc089cSDan Williams } 4118d7c22acSToshi Kani static inline void nd_iostat_end(struct bio *bio, unsigned long start) 4128d7c22acSToshi Kani { 41374d46992SChristoph Hellwig struct gendisk *disk = bio->bi_disk; 4148d7c22acSToshi Kani 415ddcf35d3SMichael Callahan generic_end_io_acct(disk->queue, bio_op(bio), &disk->part0, start); 4168d7c22acSToshi Kani } 417200c79daSDan Williams static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector, 418200c79daSDan Williams unsigned int len) 419200c79daSDan Williams { 420200c79daSDan Williams if (bb->count) { 421200c79daSDan Williams sector_t first_bad; 422200c79daSDan Williams int num_bad; 423200c79daSDan Williams 424200c79daSDan Williams return !!badblocks_check(bb, sector, len / 512, &first_bad, 425200c79daSDan Williams &num_bad); 426200c79daSDan Williams } 427200c79daSDan Williams 428200c79daSDan Williams return false; 429200c79daSDan Williams } 430047fc8a1SRoss Zwisler resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk); 4316ec68954SVishal Verma const u8 *nd_dev_to_uuid(struct device *dev); 432004f1afbSDan Williams bool pmem_should_map_pages(struct device *dev); 4334d88a97aSDan Williams #endif /* __ND_H__ */ 434