Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright(c) 2016 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 | */ |
| 13 | #ifndef __DAX_PRIVATE_H__ |
| 14 | #define __DAX_PRIVATE_H__ |
| 15 | |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/cdev.h> |
| 18 | |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 19 | /* private routines between core files */ |
| 20 | struct dax_device; |
| 21 | struct dax_device *inode_dax(struct inode *inode); |
| 22 | struct inode *dax_inode(struct dax_device *dax_dev); |
Dan Williams | 9567da0 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 23 | int dax_bus_init(void); |
| 24 | void dax_bus_exit(void); |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 25 | |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 26 | /** |
| 27 | * struct dax_region - mapping infrastructure for dax devices |
| 28 | * @id: kernel-wide unique region for a memory range |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 29 | * @target_node: effective numa node if this memory range is onlined |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 30 | * @kref: to pin while other agents have a need to do lookups |
| 31 | * @dev: parent device backing this region |
| 32 | * @align: allocation and mapping alignment for child dax devices |
| 33 | * @res: physical address range of the region |
| 34 | * @pfn_flags: identify whether the pfns are paged back or not |
| 35 | */ |
| 36 | struct dax_region { |
| 37 | int id; |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 38 | int target_node; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 39 | struct kref kref; |
| 40 | struct device *dev; |
| 41 | unsigned int align; |
| 42 | struct resource res; |
| 43 | unsigned long pfn_flags; |
| 44 | }; |
| 45 | |
| 46 | /** |
Dan Williams | 89ec9f2 | 2018-10-29 15:52:42 -0700 | [diff] [blame] | 47 | * struct dev_dax - instance data for a subdivision of a dax region, and |
| 48 | * data while the device is activated in the driver. |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 49 | * @region - parent region |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 50 | * @dax_dev - core dax functionality |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 51 | * @target_node: effective numa node if dev_dax memory range is onlined |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 52 | * @dev - device core |
Dan Williams | 89ec9f2 | 2018-10-29 15:52:42 -0700 | [diff] [blame] | 53 | * @pgmap - pgmap for memmap setup / lifetime (driver owned) |
| 54 | * @ref: pgmap reference count (driver owned) |
| 55 | * @cmp: @ref final put completion (driver owned) |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 56 | */ |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 57 | struct dev_dax { |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 58 | struct dax_region *region; |
Dan Williams | 7361636 | 2017-05-04 23:38:43 -0700 | [diff] [blame] | 59 | struct dax_device *dax_dev; |
Dan Williams | 8fc5c73 | 2018-11-09 12:43:07 -0800 | [diff] [blame] | 60 | int target_node; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 61 | struct device dev; |
Dan Williams | 89ec9f2 | 2018-10-29 15:52:42 -0700 | [diff] [blame] | 62 | struct dev_pagemap pgmap; |
| 63 | struct percpu_ref ref; |
| 64 | struct completion cmp; |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 65 | }; |
Dan Williams | 51cf784 | 2017-07-12 17:58:21 -0700 | [diff] [blame] | 66 | |
| 67 | static inline struct dev_dax *to_dev_dax(struct device *dev) |
| 68 | { |
| 69 | return container_of(dev, struct dev_dax, dev); |
| 70 | } |
Dave Jiang | efebc71 | 2017-04-07 15:33:36 -0700 | [diff] [blame] | 71 | #endif |