hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/nvdimm/nd.h
....@@ -1,14 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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.
124 */
135 #ifndef __ND_H__
146 #define __ND_H__
....@@ -47,7 +39,7 @@
4739 int ns_count;
4840 int ns_active;
4941 unsigned int hints_shift;
50
- void __iomem *flush_wpq[0];
42
+ void __iomem *flush_wpq[];
5143 };
5244
5345 static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd,
....@@ -154,17 +146,18 @@
154146 struct device *btt_seed;
155147 struct device *pfn_seed;
156148 struct device *dax_seed;
149
+ unsigned long align;
157150 u16 ndr_mappings;
158151 u64 ndr_size;
159152 u64 ndr_start;
160
- int id, num_lanes, ro, numa_node;
153
+ int id, num_lanes, ro, numa_node, target_node;
161154 void *provider_data;
162155 struct kernfs_node *bb_state;
163156 struct badblocks bb;
164157 struct nd_interleave_set *nd_set;
165158 struct nd_percpu_lane __percpu *lane;
166159 int (*flush)(struct nd_region *nd_region, struct bio *bio);
167
- struct nd_mapping mapping[0];
160
+ struct nd_mapping mapping[];
168161 };
169162
170163 struct nd_blk_region {
....@@ -220,6 +213,11 @@
220213 struct nd_pfn nd_pfn;
221214 };
222215
216
+static inline u32 nd_info_block_reserve(void)
217
+{
218
+ return ALIGN(SZ_8K, PAGE_SIZE);
219
+}
220
+
223221 enum nd_async_mode {
224222 ND_SYNC,
225223 ND_ASYNC,
....@@ -242,17 +240,31 @@
242240 void nvdimm_exit(void);
243241 void nd_region_exit(void);
244242 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[];
245246 struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping);
246247 int nvdimm_check_config_data(struct device *dev);
247248 int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
248249 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);
249252 int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
250253 void *buf, size_t len);
251254 long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
252255 unsigned int len);
253
-void nvdimm_set_aliasing(struct device *dev);
256
+void nvdimm_set_labeling(struct device *dev);
254257 void nvdimm_set_locked(struct device *dev);
255258 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
256268 struct nd_btt *to_nd_btt(struct device *dev);
257269
258270 struct nd_gen_sb {
....@@ -286,11 +298,7 @@
286298 struct nd_pfn *to_nd_pfn(struct device *dev);
287299 #if IS_ENABLED(CONFIG_NVDIMM_PFN)
288300
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
294302
295303 int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns);
296304 bool is_nd_pfn(struct device *dev);
....@@ -298,7 +306,7 @@
298306 struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
299307 struct nd_namespace_common *ndns);
300308 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[];
302310 #else
303311 static inline int nd_pfn_probe(struct device *dev,
304312 struct nd_namespace_common *ndns)
....@@ -353,7 +361,7 @@
353361 void nvdimm_bus_lock(struct device *dev);
354362 void nvdimm_bus_unlock(struct device *dev);
355363 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);
357365 void nvdimm_drvdata_release(struct kref *kref);
358366 void put_ndd(struct nvdimm_drvdata *ndd);
359367 int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd);
....@@ -369,49 +377,26 @@
369377 const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
370378 char *name);
371379 unsigned int pmem_sector_size(struct nd_namespace_common *ndns);
380
+struct range;
372381 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);
374387 #if IS_ENABLED(CONFIG_ND_CLAIM)
388
+/* max struct page size independent of kernel config */
389
+#define MAX_STRUCT_PAGE_SIZE 64
375390 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);
378391 #else
379392 static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn,
380393 struct dev_pagemap *pgmap)
381394 {
382395 return -ENXIO;
383396 }
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
-}
393397 #endif
394398 int nd_blk_region_init(struct nd_region *nd_region);
395399 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
-}
415400 static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector,
416401 unsigned int len)
417402 {