Blame view

drivers/nvdimm/nd.h 11.1 KB
5b497af42   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
2
3
  /*
   * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
4
5
6
   */
  #ifndef __ND_H__
  #define __ND_H__
1f7df6f88   Dan Williams   libnvdimm, nfit: ...
7
  #include <linux/libnvdimm.h>
200c79da8   Dan Williams   libnvdimm, pmem, ...
8
  #include <linux/badblocks.h>
f0dc089ce   Dan Williams   libnvdimm: enable...
9
  #include <linux/blkdev.h>
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
10
11
12
  #include <linux/device.h>
  #include <linux/mutex.h>
  #include <linux/ndctl.h>
bf9bccc14   Dan Williams   libnvdimm: pmem l...
13
  #include <linux/types.h>
719994660   Dan Williams   libnvdimm: async ...
14
  #include <linux/nd.h>
4a826c83d   Dan Williams   libnvdimm: namesp...
15
  #include "label.h"
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
16

8c2f7e865   Dan Williams   libnvdimm: infras...
17
  enum {
5212e11fd   Vishal Verma   nd_btt: atomic se...
18
19
20
21
22
23
  	/*
  	 * Limits the maximum number of block apertures a dimm can
  	 * support and is an input to the geometry/on-disk-format of a
  	 * BTT instance
  	 */
  	ND_MAX_LANES = 256,
fcae69573   Vishal Verma   libnvdimm, blk: a...
24
  	INT_LBASIZE_ALIGNMENT = 64,
3ae3d67ba   Vishal Verma   libnvdimm: add an...
25
  	NVDIMM_IO_ATOMIC = 1,
8c2f7e865   Dan Williams   libnvdimm: infras...
26
  };
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
27
28
  struct nvdimm_drvdata {
  	struct device *dev;
028817686   Dan Williams   libnvdimm, label:...
29
  	int nslabel_size;
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
30
31
  	struct nd_cmd_get_config_size nsarea;
  	void *data;
4a826c83d   Dan Williams   libnvdimm: namesp...
32
33
  	int ns_current, ns_next;
  	struct resource dpa;
bf9bccc14   Dan Williams   libnvdimm: pmem l...
34
  	struct kref kref;
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
35
  };
e5ae3b252   Dan Williams   libnvdimm, nfit: ...
36
37
38
  struct nd_region_data {
  	int ns_count;
  	int ns_active;
595c73071   Dan Williams   libnvdimm, region...
39
  	unsigned int hints_shift;
9106137c6   Gustavo A. R. Silva   libnvdimm/region:...
40
  	void __iomem *flush_wpq[];
3d88002e4   Dan Williams   libnvdimm: suppor...
41
  };
595c73071   Dan Williams   libnvdimm, region...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd,
  		int dimm, int hint)
  {
  	unsigned int num = 1 << ndrd->hints_shift;
  	unsigned int mask = num - 1;
  
  	return ndrd->flush_wpq[dimm * num + (hint & mask)];
  }
  
  static inline void ndrd_set_flush_wpq(struct nd_region_data *ndrd, int dimm,
  		int hint, void __iomem *flush)
  {
  	unsigned int num = 1 << ndrd->hints_shift;
  	unsigned int mask = num - 1;
  
  	ndrd->flush_wpq[dimm * num + (hint & mask)] = flush;
  }
4a826c83d   Dan Williams   libnvdimm: namesp...
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  static inline struct nd_namespace_index *to_namespace_index(
  		struct nvdimm_drvdata *ndd, int i)
  {
  	if (i < 0)
  		return NULL;
  
  	return ndd->data + sizeof_namespace_index(ndd) * i;
  }
  
  static inline struct nd_namespace_index *to_current_namespace_index(
  		struct nvdimm_drvdata *ndd)
  {
  	return to_namespace_index(ndd, ndd->ns_current);
  }
  
  static inline struct nd_namespace_index *to_next_namespace_index(
  		struct nvdimm_drvdata *ndd)
  {
  	return to_namespace_index(ndd, ndd->ns_next);
  }
564e871aa   Dan Williams   libnvdimm, label:...
79
80
81
82
83
  unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd);
  
  #define namespace_label_has(ndd, field) \
  	(offsetof(struct nd_namespace_label, field) \
  		< sizeof_namespace_label(ndd))
4a826c83d   Dan Williams   libnvdimm: namesp...
84
85
86
87
88
  #define nd_dbg_dpa(r, d, res, fmt, arg...) \
  	dev_dbg((r) ? &(r)->dev : (d)->dev, "%s: %.13s: %#llx @ %#llx " fmt, \
  		(r) ? dev_name((d)->dev) : "", res ? res->name : "null", \
  		(unsigned long long) (res ? resource_size(res) : 0), \
  		(unsigned long long) (res ? res->start : 0), ##arg)
bf9bccc14   Dan Williams   libnvdimm: pmem l...
89
90
  #define for_each_dpa_resource(ndd, res) \
  	for (res = (ndd)->dpa.child; res; res = res->sibling)
4a826c83d   Dan Williams   libnvdimm: namesp...
91
92
93
  #define for_each_dpa_resource_safe(ndd, res, next) \
  	for (res = (ndd)->dpa.child, next = res ? res->sibling : NULL; \
  			res; res = next, next = next ? next->sibling : NULL)
5212e11fd   Vishal Verma   nd_btt: atomic se...
94
95
96
97
  struct nd_percpu_lane {
  	int count;
  	spinlock_t lock;
  };
c4703ce11   Dan Williams   libnvdimm/namespa...
98
99
100
  enum nd_label_flags {
  	ND_LABEL_REAP,
  };
ae8219f18   Dan Williams   libnvdimm, label:...
101
102
  struct nd_label_ent {
  	struct list_head list;
c4703ce11   Dan Williams   libnvdimm/namespa...
103
  	unsigned long flags;
ae8219f18   Dan Williams   libnvdimm, label:...
104
105
106
107
108
109
110
  	struct nd_namespace_label *label;
  };
  
  enum nd_mapping_lock_class {
  	ND_MAPPING_CLASS0,
  	ND_MAPPING_UUID_SCAN,
  };
44c462eb9   Dan Williams   libnvdimm, region...
111
112
  struct nd_mapping {
  	struct nvdimm *nvdimm;
44c462eb9   Dan Williams   libnvdimm, region...
113
114
  	u64 start;
  	u64 size;
401c0a19c   Dan Williams   nfit, libnvdimm, ...
115
  	int position;
ae8219f18   Dan Williams   libnvdimm, label:...
116
117
  	struct list_head labels;
  	struct mutex lock;
44c462eb9   Dan Williams   libnvdimm, region...
118
119
120
121
122
123
124
125
  	/*
  	 * @ndd is for private use at region enable / disable time for
  	 * get_ndd() + put_ndd(), all other nd_mapping to ndd
  	 * conversions use to_ndd() which respects enabled state of the
  	 * nvdimm.
  	 */
  	struct nvdimm_drvdata *ndd;
  };
1f7df6f88   Dan Williams   libnvdimm, nfit: ...
126
127
  struct nd_region {
  	struct device dev;
1b40e09a1   Dan Williams   libnvdimm: blk la...
128
  	struct ida ns_ida;
8c2f7e865   Dan Williams   libnvdimm: infras...
129
  	struct ida btt_ida;
e1455744b   Dan Williams   libnvdimm, pfn: '...
130
  	struct ida pfn_ida;
cd03412a5   Dan Williams   libnvdimm, dax: i...
131
  	struct ida dax_ida;
004f1afbe   Dan Williams   libnvdimm, pmem: ...
132
  	unsigned long flags;
bf9bccc14   Dan Williams   libnvdimm: pmem l...
133
  	struct device *ns_seed;
8c2f7e865   Dan Williams   libnvdimm: infras...
134
  	struct device *btt_seed;
e1455744b   Dan Williams   libnvdimm, pfn: '...
135
  	struct device *pfn_seed;
cd03412a5   Dan Williams   libnvdimm, dax: i...
136
  	struct device *dax_seed;
2522afb86   Dan Williams   libnvdimm/region:...
137
  	unsigned long align;
1f7df6f88   Dan Williams   libnvdimm, nfit: ...
138
139
140
  	u16 ndr_mappings;
  	u64 ndr_size;
  	u64 ndr_start;
8fc5c7355   Dan Williams   acpi/nfit, device...
141
  	int id, num_lanes, ro, numa_node, target_node;
1f7df6f88   Dan Williams   libnvdimm, nfit: ...
142
  	void *provider_data;
975750a98   Toshi Kani   libnvdimm, pmem: ...
143
  	struct kernfs_node *bb_state;
6a6bef904   Dave Jiang   libnvdimm: add me...
144
  	struct badblocks bb;
eaf961536   Dan Williams   libnvdimm, nfit: ...
145
  	struct nd_interleave_set *nd_set;
5212e11fd   Vishal Verma   nd_btt: atomic se...
146
  	struct nd_percpu_lane __percpu *lane;
c5d4355d1   Pankaj Gupta   libnvdimm: nd_reg...
147
  	int (*flush)(struct nd_region *nd_region, struct bio *bio);
9106137c6   Gustavo A. R. Silva   libnvdimm/region:...
148
  	struct nd_mapping mapping[];
1f7df6f88   Dan Williams   libnvdimm, nfit: ...
149
  };
047fc8a1f   Ross Zwisler   libnvdimm, nfit, ...
150
151
  struct nd_blk_region {
  	int (*enable)(struct nvdimm_bus *nvdimm_bus, struct device *dev);
047fc8a1f   Ross Zwisler   libnvdimm, nfit, ...
152
153
154
155
156
  	int (*do_io)(struct nd_blk_region *ndbr, resource_size_t dpa,
  			void *iobuf, u64 len, int rw);
  	void *blk_provider_data;
  	struct nd_region nd_region;
  };
4a826c83d   Dan Williams   libnvdimm: namesp...
157
158
159
160
161
162
163
164
165
  /*
   * Lookup next in the repeating sequence of 01, 10, and 11.
   */
  static inline unsigned nd_inc_seq(unsigned seq)
  {
  	static const unsigned next[] = { 0, 2, 3, 1 };
  
  	return next[seq & 3];
  }
f524bf271   Dan Williams   libnvdimm: write ...
166

5212e11fd   Vishal Verma   nd_btt: atomic se...
167
  struct btt;
8c2f7e865   Dan Williams   libnvdimm: infras...
168
169
170
  struct nd_btt {
  	struct device dev;
  	struct nd_namespace_common *ndns;
5212e11fd   Vishal Verma   nd_btt: atomic se...
171
  	struct btt *btt;
8c2f7e865   Dan Williams   libnvdimm: infras...
172
  	unsigned long lbasize;
abe8b4e3c   Vishal Verma   nvdimm, btt: add ...
173
  	u64 size;
8c2f7e865   Dan Williams   libnvdimm: infras...
174
175
  	u8 *uuid;
  	int id;
14e494542   Vishal Verma   libnvdimm, btt: B...
176
177
178
  	int initial_offset;
  	u16 version_major;
  	u16 version_minor;
8c2f7e865   Dan Williams   libnvdimm: infras...
179
  };
e1455744b   Dan Williams   libnvdimm, pfn: '...
180
181
182
183
184
185
186
187
188
189
  enum nd_pfn_mode {
  	PFN_MODE_NONE,
  	PFN_MODE_RAM,
  	PFN_MODE_PMEM,
  };
  
  struct nd_pfn {
  	int id;
  	u8 *uuid;
  	struct device dev;
315c56253   Dan Williams   libnvdimm, pfn: a...
190
  	unsigned long align;
e1455744b   Dan Williams   libnvdimm, pfn: '...
191
192
193
194
195
  	unsigned long npfns;
  	enum nd_pfn_mode mode;
  	struct nd_pfn_sb *pfn_sb;
  	struct nd_namespace_common *ndns;
  };
cd03412a5   Dan Williams   libnvdimm, dax: i...
196
197
198
  struct nd_dax {
  	struct nd_pfn nd_pfn;
  };
8f4b01fcd   Aneesh Kumar K.V   libnvdimm/namespa...
199
200
201
202
  static inline u32 nd_info_block_reserve(void)
  {
  	return ALIGN(SZ_8K, PAGE_SIZE);
  }
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
203
204
205
206
  enum nd_async_mode {
  	ND_SYNC,
  	ND_ASYNC,
  };
41cd8b70c   Vishal Verma   libnvdimm, btt: a...
207
  int nd_integrity_init(struct gendisk *disk, unsigned long meta_size);
bf9bccc14   Dan Williams   libnvdimm: pmem l...
208
  void wait_nvdimm_bus_probe_idle(struct device *dev);
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
209
210
  void nd_device_register(struct device *dev);
  void nd_device_unregister(struct device *dev, enum nd_async_mode mode);
719994660   Dan Williams   libnvdimm: async ...
211
  void nd_device_notify(struct device *dev, enum nvdimm_event event);
bf9bccc14   Dan Williams   libnvdimm: pmem l...
212
213
  int nd_uuid_store(struct device *dev, u8 **uuid_out, const char *buf,
  		size_t len);
b2c48f9f9   Dan Williams   libnvdimm: rename...
214
  ssize_t nd_size_select_show(unsigned long current_size,
1b40e09a1   Dan Williams   libnvdimm: blk la...
215
  		const unsigned long *supported, char *buf);
b2c48f9f9   Dan Williams   libnvdimm: rename...
216
217
  ssize_t nd_size_select_store(struct device *dev, const char *buf,
  		unsigned long *current_size, const unsigned long *supported);
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
218
  int __init nvdimm_init(void);
3d88002e4   Dan Williams   libnvdimm: suppor...
219
  int __init nd_region_init(void);
b3fde74ea   Dan Williams   libnvdimm, label:...
220
  int __init nd_label_init(void);
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
221
  void nvdimm_exit(void);
3d88002e4   Dan Williams   libnvdimm: suppor...
222
  void nd_region_exit(void);
bf9bccc14   Dan Williams   libnvdimm: pmem l...
223
  struct nvdimm;
adbb68293   Dan Williams   libnvdimm: Move n...
224
  extern const struct attribute_group nd_device_attribute_group;
e2f6a0e34   Dan Williams   libnvdimm: Move n...
225
  extern const struct attribute_group nd_numa_attribute_group;
e755799ae   Dan Williams   libnvdimm: Move n...
226
  extern const struct attribute_group *nvdimm_bus_attribute_groups[];
bf9bccc14   Dan Williams   libnvdimm: pmem l...
227
  struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping);
aee659874   Toshi Kani   libnvdimm: Fix nv...
228
  int nvdimm_check_config_data(struct device *dev);
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
229
230
  int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
  int nvdimm_init_config_data(struct nvdimm_drvdata *ndd);
2d657d17f   Alexander Duyck   nvdimm: Split lab...
231
232
  int nvdimm_get_config_data(struct nvdimm_drvdata *ndd, void *buf,
  			   size_t offset, size_t len);
f524bf271   Dan Williams   libnvdimm: write ...
233
234
  int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
  		void *buf, size_t len);
59e647398   Dan Williams   libnvdimm, pmem: ...
235
236
  long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
  		unsigned int len);
a0e374525   Dan Williams   libnvdimm/region:...
237
  void nvdimm_set_labeling(struct device *dev);
8f078b38d   Dan Williams   libnvdimm: conver...
238
  void nvdimm_set_locked(struct device *dev);
d34cb8084   Dan Williams   libnvdimm, dimm: ...
239
  void nvdimm_clear_locked(struct device *dev);
1cd738654   Dan Williams   libnvdimm/securit...
240
  int nvdimm_security_setup_events(struct device *dev);
4c6926a23   Dave Jiang   acpi/nfit, libnvd...
241
242
243
244
245
246
247
248
  #if IS_ENABLED(CONFIG_NVDIMM_KEYS)
  int nvdimm_security_unlock(struct device *dev);
  #else
  static inline int nvdimm_security_unlock(struct device *dev)
  {
  	return 0;
  }
  #endif
8c2f7e865   Dan Williams   libnvdimm: infras...
249
  struct nd_btt *to_nd_btt(struct device *dev);
e1455744b   Dan Williams   libnvdimm, pfn: '...
250
251
252
253
254
255
256
  
  struct nd_gen_sb {
  	char reserved[SZ_4K - 8];
  	__le64 checksum;
  };
  
  u64 nd_sb_checksum(struct nd_gen_sb *sb);
8c2f7e865   Dan Williams   libnvdimm: infras...
257
  #if IS_ENABLED(CONFIG_BTT)
200c79da8   Dan Williams   libnvdimm, pmem, ...
258
  int nd_btt_probe(struct device *dev, struct nd_namespace_common *ndns);
8c2f7e865   Dan Williams   libnvdimm: infras...
259
260
261
  bool is_nd_btt(struct device *dev);
  struct device *nd_btt_create(struct nd_region *nd_region);
  #else
e32bc729a   Dan Williams   libnvdimm, btt, c...
262
  static inline int nd_btt_probe(struct device *dev,
200c79da8   Dan Williams   libnvdimm, pmem, ...
263
  		struct nd_namespace_common *ndns)
8c2f7e865   Dan Williams   libnvdimm: infras...
264
265
266
267
268
269
270
271
272
273
274
275
276
  {
  	return -ENODEV;
  }
  
  static inline bool is_nd_btt(struct device *dev)
  {
  	return false;
  }
  
  static inline struct device *nd_btt_create(struct nd_region *nd_region)
  {
  	return NULL;
  }
e1455744b   Dan Williams   libnvdimm, pfn: '...
277
  #endif
8c2f7e865   Dan Williams   libnvdimm: infras...
278

e1455744b   Dan Williams   libnvdimm, pfn: '...
279
280
  struct nd_pfn *to_nd_pfn(struct device *dev);
  #if IS_ENABLED(CONFIG_NVDIMM_PFN)
0dd696430   Oliver O'Halloran   libnvdimm: Stop u...
281

f53766997   Aneesh Kumar K.V   libnvdimm/dax: Pi...
282
  #define MAX_NVDIMM_ALIGN	4
0dd696430   Oliver O'Halloran   libnvdimm: Stop u...
283

200c79da8   Dan Williams   libnvdimm, pmem, ...
284
  int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns);
e1455744b   Dan Williams   libnvdimm, pfn: '...
285
286
  bool is_nd_pfn(struct device *dev);
  struct device *nd_pfn_create(struct nd_region *nd_region);
cd03412a5   Dan Williams   libnvdimm, dax: i...
287
288
  struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
  		struct nd_namespace_common *ndns);
c5ed92686   Dan Williams   libnvdimm, dax: a...
289
  int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig);
78c81cc89   Dan Williams   libnvdimm: Move a...
290
  extern const struct attribute_group *nd_pfn_attribute_groups[];
e1455744b   Dan Williams   libnvdimm, pfn: '...
291
  #else
200c79da8   Dan Williams   libnvdimm, pmem, ...
292
293
  static inline int nd_pfn_probe(struct device *dev,
  		struct nd_namespace_common *ndns)
e1455744b   Dan Williams   libnvdimm, pfn: '...
294
295
296
297
298
299
300
301
302
303
304
305
306
  {
  	return -ENODEV;
  }
  
  static inline bool is_nd_pfn(struct device *dev)
  {
  	return false;
  }
  
  static inline struct device *nd_pfn_create(struct nd_region *nd_region)
  {
  	return NULL;
  }
32ab0a3f5   Dan Williams   libnvdimm, pmem: ...
307

c5ed92686   Dan Williams   libnvdimm, dax: a...
308
  static inline int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
32ab0a3f5   Dan Williams   libnvdimm, pmem: ...
309
310
311
  {
  	return -ENODEV;
  }
8c2f7e865   Dan Williams   libnvdimm: infras...
312
  #endif
e1455744b   Dan Williams   libnvdimm, pfn: '...
313

cd03412a5   Dan Williams   libnvdimm, dax: i...
314
315
  struct nd_dax *to_nd_dax(struct device *dev);
  #if IS_ENABLED(CONFIG_NVDIMM_DAX)
c5ed92686   Dan Williams   libnvdimm, dax: a...
316
  int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns);
cd03412a5   Dan Williams   libnvdimm, dax: i...
317
318
319
  bool is_nd_dax(struct device *dev);
  struct device *nd_dax_create(struct nd_region *nd_region);
  #else
c5ed92686   Dan Williams   libnvdimm, dax: a...
320
321
322
323
324
  static inline int nd_dax_probe(struct device *dev,
  		struct nd_namespace_common *ndns)
  {
  	return -ENODEV;
  }
cd03412a5   Dan Williams   libnvdimm, dax: i...
325
326
327
328
329
330
331
332
333
334
  static inline bool is_nd_dax(struct device *dev)
  {
  	return false;
  }
  
  static inline struct device *nd_dax_create(struct nd_region *nd_region)
  {
  	return NULL;
  }
  #endif
3d88002e4   Dan Williams   libnvdimm: suppor...
335
336
  int nd_region_to_nstype(struct nd_region *nd_region);
  int nd_region_register_namespaces(struct nd_region *nd_region, int *err);
c12c48ce8   Dan Williams   libnvdimm, label:...
337
338
  u64 nd_region_interleave_set_cookie(struct nd_region *nd_region,
  		struct nd_namespace_index *nsindex);
86ef58a4e   Dan Williams   nfit, libnvdimm: ...
339
  u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region);
3d88002e4   Dan Williams   libnvdimm: suppor...
340
341
342
  void nvdimm_bus_lock(struct device *dev);
  void nvdimm_bus_unlock(struct device *dev);
  bool is_nvdimm_bus_locked(struct device *dev);
32f61d675   Christoph Hellwig   nvdimm: simplify ...
343
  void nvdimm_check_and_set_ro(struct gendisk *disk);
bf9bccc14   Dan Williams   libnvdimm: pmem l...
344
345
  void nvdimm_drvdata_release(struct kref *kref);
  void put_ndd(struct nvdimm_drvdata *ndd);
4a826c83d   Dan Williams   libnvdimm: namesp...
346
347
348
349
350
  int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd);
  void nvdimm_free_dpa(struct nvdimm_drvdata *ndd, struct resource *res);
  struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd,
  		struct nd_label_id *label_id, resource_size_t start,
  		resource_size_t n);
8c2f7e865   Dan Williams   libnvdimm: infras...
351
  resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns);
08e6b3c6e   Dan Williams   libnvdimm: Introd...
352
  bool nvdimm_namespace_locked(struct nd_namespace_common *ndns);
8c2f7e865   Dan Williams   libnvdimm: infras...
353
  struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev);
5212e11fd   Vishal Verma   nd_btt: atomic se...
354
  int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns);
298f2bc5d   Dan Williams   libnvdimm, pmem: ...
355
  int nvdimm_namespace_detach_btt(struct nd_btt *nd_btt);
5212e11fd   Vishal Verma   nd_btt: atomic se...
356
357
  const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
  		char *name);
f979b13c3   Dan Williams   libnvdimm, label:...
358
  unsigned int pmem_sector_size(struct nd_namespace_common *ndns);
a4574f63e   Dan Williams   mm/memremap_pages...
359
  struct range;
a39018029   Dan Williams   libnvdimm, pfn: f...
360
  void nvdimm_badblocks_populate(struct nd_region *nd_region,
a4574f63e   Dan Williams   mm/memremap_pages...
361
  		struct badblocks *bb, const struct range *range);
8f4b01fcd   Aneesh Kumar K.V   libnvdimm/namespa...
362
363
364
365
  int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns,
  		resource_size_t size);
  void devm_namespace_disable(struct device *dev,
  		struct nd_namespace_common *ndns);
200c79da8   Dan Williams   libnvdimm, pmem, ...
366
  #if IS_ENABLED(CONFIG_ND_CLAIM)
e96f0bf2e   Aneesh Kumar K.V   libnvdimm/pfn_dev...
367
368
  /* max struct page size independent of kernel config */
  #define MAX_STRUCT_PAGE_SIZE 64
e8d513483   Christoph Hellwig   memremap: change ...
369
  int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap);
200c79da8   Dan Williams   libnvdimm, pmem, ...
370
  #else
e8d513483   Christoph Hellwig   memremap: change ...
371
372
  static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn,
  				   struct dev_pagemap *pgmap)
ac515c084   Dan Williams   libnvdimm, pmem, ...
373
  {
e8d513483   Christoph Hellwig   memremap: change ...
374
  	return -ENXIO;
ac515c084   Dan Williams   libnvdimm, pmem, ...
375
  }
200c79da8   Dan Williams   libnvdimm, pmem, ...
376
  #endif
047fc8a1f   Ross Zwisler   libnvdimm, nfit, ...
377
  int nd_blk_region_init(struct nd_region *nd_region);
e5ae3b252   Dan Williams   libnvdimm, nfit: ...
378
  int nd_region_activate(struct nd_region *nd_region);
200c79da8   Dan Williams   libnvdimm, pmem, ...
379
380
381
382
383
384
385
386
387
388
389
390
391
  static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector,
  		unsigned int len)
  {
  	if (bb->count) {
  		sector_t first_bad;
  		int num_bad;
  
  		return !!badblocks_check(bb, sector, len / 512, &first_bad,
  				&num_bad);
  	}
  
  	return false;
  }
047fc8a1f   Ross Zwisler   libnvdimm, nfit, ...
392
  resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk);
6ec689542   Vishal Verma   libnvdimm, btt: w...
393
  const u8 *nd_dev_to_uuid(struct device *dev);
004f1afbe   Dan Williams   libnvdimm, pmem: ...
394
  bool pmem_should_map_pages(struct device *dev);
4d88a97aa   Dan Williams   libnvdimm, nvdimm...
395
  #endif /* __ND_H__ */