Thomas Gleixner | 5b497af | 2019-05-29 07:18:09 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright(c) 2016 Intel Corporation. All rights reserved. |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 4 | */ |
| 5 | #ifndef __DAX_PRIVATE_H__ |
| 6 | #define __DAX_PRIVATE_H__ |
| 7 | |
| 8 | #include <linux/device.h> |
| 9 | #include <linux/cdev.h> |
| 10 | |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 11 | /* private routines between core files */ |
| 12 | struct dax_device; |
| 13 | struct dax_device *inode_dax(struct inode *inode); |
| 14 | struct inode *dax_inode(struct dax_device *dax_dev); |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 15 | int dax_bus_init(void); |
| 16 | void dax_bus_exit(void); |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 17 | |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 18 | /** |
| 19 | * struct dax_region - mapping infrastructure for dax devices |
| 20 | * @id: kernel-wide unique region for a memory range |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 21 | * @target_node: effective numa node if this memory range is onlined |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 22 | * @kref: to pin while other agents have a need to do lookups |
| 23 | * @dev: parent device backing this region |
| 24 | * @align: allocation and mapping alignment for child dax devices |
| 25 | * @res: physical address range of the region |
| 26 | * @pfn_flags: identify whether the pfns are paged back or not |
| 27 | */ |
| 28 | struct dax_region { |
| 29 | int id; |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 30 | int target_node; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 31 | struct kref kref; |
| 32 | struct device *dev; |
| 33 | unsigned int align; |
| 34 | struct resource res; |
Dan Williams | 460370a | 2019-11-06 17:43:37 -0800 | [diff] [blame] | 35 | unsigned long long pfn_flags; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | /** |
Dan Williams | 89ec9f2 | 2018-10-29 15:52:42 -0700 | [diff] [blame] | 39 | * struct dev_dax - instance data for a subdivision of a dax region, and |
| 40 | * data while the device is activated in the driver. |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 41 | * @region - parent region |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 42 | * @dax_dev - core dax functionality |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 43 | * @target_node: effective numa node if dev_dax memory range is onlined |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 44 | * @dev - device core |
Dan Williams | 89ec9f2 | 2018-10-29 15:52:42 -0700 | [diff] [blame] | 45 | * @pgmap - pgmap for memmap setup / lifetime (driver owned) |
Pavel Tatashin | 9f960da | 2019-07-16 16:30:35 -0700 | [diff] [blame] | 46 | * @dax_mem_res: physical address range of hotadded DAX memory |
David Hildenbrand | 8a725e4 | 2020-06-04 16:48:48 -0700 | [diff] [blame] | 47 | * @dax_mem_name: name for hotadded DAX memory via add_memory_driver_managed() |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 48 | */ |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 49 | struct dev_dax { |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 50 | struct dax_region *region; |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 51 | struct dax_device *dax_dev; |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 52 | int target_node; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 53 | struct device dev; |
Dan Williams | 89ec9f2 | 2018-10-29 15:52:42 -0700 | [diff] [blame] | 54 | struct dev_pagemap pgmap; |
Pavel Tatashin | 9f960da | 2019-07-16 16:30:35 -0700 | [diff] [blame] | 55 | struct resource *dax_kmem_res; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 56 | }; |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 57 | |
| 58 | static inline struct dev_dax *to_dev_dax(struct device *dev) |
| 59 | { |
| 60 | return container_of(dev, struct dev_dax, dev); |
| 61 | } |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 62 | #endif |