.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of version 2 of the GNU General Public License as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, but |
---|
9 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | | - * General Public License for more details. |
---|
12 | 4 | */ |
---|
13 | 5 | #ifndef __ND_H__ |
---|
14 | 6 | #define __ND_H__ |
---|
.. | .. |
---|
47 | 39 | int ns_count; |
---|
48 | 40 | int ns_active; |
---|
49 | 41 | unsigned int hints_shift; |
---|
50 | | - void __iomem *flush_wpq[0]; |
---|
| 42 | + void __iomem *flush_wpq[]; |
---|
51 | 43 | }; |
---|
52 | 44 | |
---|
53 | 45 | static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd, |
---|
.. | .. |
---|
154 | 146 | struct device *btt_seed; |
---|
155 | 147 | struct device *pfn_seed; |
---|
156 | 148 | struct device *dax_seed; |
---|
| 149 | + unsigned long align; |
---|
157 | 150 | u16 ndr_mappings; |
---|
158 | 151 | u64 ndr_size; |
---|
159 | 152 | u64 ndr_start; |
---|
160 | | - int id, num_lanes, ro, numa_node; |
---|
| 153 | + int id, num_lanes, ro, numa_node, target_node; |
---|
161 | 154 | void *provider_data; |
---|
162 | 155 | struct kernfs_node *bb_state; |
---|
163 | 156 | struct badblocks bb; |
---|
164 | 157 | struct nd_interleave_set *nd_set; |
---|
165 | 158 | struct nd_percpu_lane __percpu *lane; |
---|
166 | 159 | int (*flush)(struct nd_region *nd_region, struct bio *bio); |
---|
167 | | - struct nd_mapping mapping[0]; |
---|
| 160 | + struct nd_mapping mapping[]; |
---|
168 | 161 | }; |
---|
169 | 162 | |
---|
170 | 163 | struct nd_blk_region { |
---|
.. | .. |
---|
220 | 213 | struct nd_pfn nd_pfn; |
---|
221 | 214 | }; |
---|
222 | 215 | |
---|
| 216 | +static inline u32 nd_info_block_reserve(void) |
---|
| 217 | +{ |
---|
| 218 | + return ALIGN(SZ_8K, PAGE_SIZE); |
---|
| 219 | +} |
---|
| 220 | + |
---|
223 | 221 | enum nd_async_mode { |
---|
224 | 222 | ND_SYNC, |
---|
225 | 223 | ND_ASYNC, |
---|
.. | .. |
---|
242 | 240 | void nvdimm_exit(void); |
---|
243 | 241 | void nd_region_exit(void); |
---|
244 | 242 | struct nvdimm; |
---|
| 243 | +extern const struct attribute_group nd_device_attribute_group; |
---|
| 244 | +extern const struct attribute_group nd_numa_attribute_group; |
---|
| 245 | +extern const struct attribute_group *nvdimm_bus_attribute_groups[]; |
---|
245 | 246 | struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping); |
---|
246 | 247 | int nvdimm_check_config_data(struct device *dev); |
---|
247 | 248 | int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd); |
---|
248 | 249 | int nvdimm_init_config_data(struct nvdimm_drvdata *ndd); |
---|
| 250 | +int nvdimm_get_config_data(struct nvdimm_drvdata *ndd, void *buf, |
---|
| 251 | + size_t offset, size_t len); |
---|
249 | 252 | int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, |
---|
250 | 253 | void *buf, size_t len); |
---|
251 | 254 | long nvdimm_clear_poison(struct device *dev, phys_addr_t phys, |
---|
252 | 255 | unsigned int len); |
---|
253 | | -void nvdimm_set_aliasing(struct device *dev); |
---|
| 256 | +void nvdimm_set_labeling(struct device *dev); |
---|
254 | 257 | void nvdimm_set_locked(struct device *dev); |
---|
255 | 258 | void nvdimm_clear_locked(struct device *dev); |
---|
| 259 | +int nvdimm_security_setup_events(struct device *dev); |
---|
| 260 | +#if IS_ENABLED(CONFIG_NVDIMM_KEYS) |
---|
| 261 | +int nvdimm_security_unlock(struct device *dev); |
---|
| 262 | +#else |
---|
| 263 | +static inline int nvdimm_security_unlock(struct device *dev) |
---|
| 264 | +{ |
---|
| 265 | + return 0; |
---|
| 266 | +} |
---|
| 267 | +#endif |
---|
256 | 268 | struct nd_btt *to_nd_btt(struct device *dev); |
---|
257 | 269 | |
---|
258 | 270 | struct nd_gen_sb { |
---|
.. | .. |
---|
286 | 298 | struct nd_pfn *to_nd_pfn(struct device *dev); |
---|
287 | 299 | #if IS_ENABLED(CONFIG_NVDIMM_PFN) |
---|
288 | 300 | |
---|
289 | | -#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
---|
290 | | -#define PFN_DEFAULT_ALIGNMENT HPAGE_PMD_SIZE |
---|
291 | | -#else |
---|
292 | | -#define PFN_DEFAULT_ALIGNMENT PAGE_SIZE |
---|
293 | | -#endif |
---|
| 301 | +#define MAX_NVDIMM_ALIGN 4 |
---|
294 | 302 | |
---|
295 | 303 | int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns); |
---|
296 | 304 | bool is_nd_pfn(struct device *dev); |
---|
.. | .. |
---|
298 | 306 | struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn, |
---|
299 | 307 | struct nd_namespace_common *ndns); |
---|
300 | 308 | int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig); |
---|
301 | | -extern struct attribute_group nd_pfn_attribute_group; |
---|
| 309 | +extern const struct attribute_group *nd_pfn_attribute_groups[]; |
---|
302 | 310 | #else |
---|
303 | 311 | static inline int nd_pfn_probe(struct device *dev, |
---|
304 | 312 | struct nd_namespace_common *ndns) |
---|
.. | .. |
---|
353 | 361 | void nvdimm_bus_lock(struct device *dev); |
---|
354 | 362 | void nvdimm_bus_unlock(struct device *dev); |
---|
355 | 363 | bool is_nvdimm_bus_locked(struct device *dev); |
---|
356 | | -int nvdimm_revalidate_disk(struct gendisk *disk); |
---|
| 364 | +void nvdimm_check_and_set_ro(struct gendisk *disk); |
---|
357 | 365 | void nvdimm_drvdata_release(struct kref *kref); |
---|
358 | 366 | void put_ndd(struct nvdimm_drvdata *ndd); |
---|
359 | 367 | int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd); |
---|
.. | .. |
---|
369 | 377 | const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns, |
---|
370 | 378 | char *name); |
---|
371 | 379 | unsigned int pmem_sector_size(struct nd_namespace_common *ndns); |
---|
| 380 | +struct range; |
---|
372 | 381 | void nvdimm_badblocks_populate(struct nd_region *nd_region, |
---|
373 | | - struct badblocks *bb, const struct resource *res); |
---|
| 382 | + struct badblocks *bb, const struct range *range); |
---|
| 383 | +int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns, |
---|
| 384 | + resource_size_t size); |
---|
| 385 | +void devm_namespace_disable(struct device *dev, |
---|
| 386 | + struct nd_namespace_common *ndns); |
---|
374 | 387 | #if IS_ENABLED(CONFIG_ND_CLAIM) |
---|
| 388 | +/* max struct page size independent of kernel config */ |
---|
| 389 | +#define MAX_STRUCT_PAGE_SIZE 64 |
---|
375 | 390 | int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap); |
---|
376 | | -int devm_nsio_enable(struct device *dev, struct nd_namespace_io *nsio); |
---|
377 | | -void devm_nsio_disable(struct device *dev, struct nd_namespace_io *nsio); |
---|
378 | 391 | #else |
---|
379 | 392 | static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, |
---|
380 | 393 | struct dev_pagemap *pgmap) |
---|
381 | 394 | { |
---|
382 | 395 | return -ENXIO; |
---|
383 | 396 | } |
---|
384 | | -static inline int devm_nsio_enable(struct device *dev, |
---|
385 | | - struct nd_namespace_io *nsio) |
---|
386 | | -{ |
---|
387 | | - return -ENXIO; |
---|
388 | | -} |
---|
389 | | -static inline void devm_nsio_disable(struct device *dev, |
---|
390 | | - struct nd_namespace_io *nsio) |
---|
391 | | -{ |
---|
392 | | -} |
---|
393 | 397 | #endif |
---|
394 | 398 | int nd_blk_region_init(struct nd_region *nd_region); |
---|
395 | 399 | int nd_region_activate(struct nd_region *nd_region); |
---|
396 | | -void __nd_iostat_start(struct bio *bio, unsigned long *start); |
---|
397 | | -static inline bool nd_iostat_start(struct bio *bio, unsigned long *start) |
---|
398 | | -{ |
---|
399 | | - struct gendisk *disk = bio->bi_disk; |
---|
400 | | - |
---|
401 | | - if (!blk_queue_io_stat(disk->queue)) |
---|
402 | | - return false; |
---|
403 | | - |
---|
404 | | - *start = jiffies; |
---|
405 | | - generic_start_io_acct(disk->queue, bio_op(bio), bio_sectors(bio), |
---|
406 | | - &disk->part0); |
---|
407 | | - return true; |
---|
408 | | -} |
---|
409 | | -static inline void nd_iostat_end(struct bio *bio, unsigned long start) |
---|
410 | | -{ |
---|
411 | | - struct gendisk *disk = bio->bi_disk; |
---|
412 | | - |
---|
413 | | - generic_end_io_acct(disk->queue, bio_op(bio), &disk->part0, start); |
---|
414 | | -} |
---|
415 | 400 | static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector, |
---|
416 | 401 | unsigned int len) |
---|
417 | 402 | { |
---|