blob: 16850d5388ab9fb66125f88c9bda4a443f81bf57 [file] [log] [blame]
Thomas Gleixner5b497af2019-05-29 07:18:09 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Dave Jiangefebc712017-04-07 15:33:36 -07002/*
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
Dave Jiangefebc712017-04-07 15:33:36 -07004 */
5#ifndef __DAX_PRIVATE_H__
6#define __DAX_PRIVATE_H__
7
8#include <linux/device.h>
9#include <linux/cdev.h>
10
Dan Williams51cf7842017-07-12 17:58:21 -070011/* private routines between core files */
12struct dax_device;
13struct dax_device *inode_dax(struct inode *inode);
14struct inode *dax_inode(struct dax_device *dax_dev);
Dan Williams9567da02017-07-12 17:58:21 -070015int dax_bus_init(void);
16void dax_bus_exit(void);
Dan Williams51cf7842017-07-12 17:58:21 -070017
Dave Jiangefebc712017-04-07 15:33:36 -070018/**
19 * struct dax_region - mapping infrastructure for dax devices
20 * @id: kernel-wide unique region for a memory range
Dan Williams8fc5c732018-11-09 12:43:07 -080021 * @target_node: effective numa node if this memory range is onlined
Dave Jiangefebc712017-04-07 15:33:36 -070022 * @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 */
28struct dax_region {
29 int id;
Dan Williams8fc5c732018-11-09 12:43:07 -080030 int target_node;
Dave Jiangefebc712017-04-07 15:33:36 -070031 struct kref kref;
32 struct device *dev;
33 unsigned int align;
34 struct resource res;
Dan Williams460370a2019-11-06 17:43:37 -080035 unsigned long long pfn_flags;
Dave Jiangefebc712017-04-07 15:33:36 -070036};
37
38/**
Dan Williams89ec9f22018-10-29 15:52:42 -070039 * struct dev_dax - instance data for a subdivision of a dax region, and
40 * data while the device is activated in the driver.
Dave Jiangefebc712017-04-07 15:33:36 -070041 * @region - parent region
Dan Williams73616362017-05-04 23:38:43 -070042 * @dax_dev - core dax functionality
Dan Williams8fc5c732018-11-09 12:43:07 -080043 * @target_node: effective numa node if dev_dax memory range is onlined
Dan Williams73616362017-05-04 23:38:43 -070044 * @dev - device core
Dan Williams89ec9f22018-10-29 15:52:42 -070045 * @pgmap - pgmap for memmap setup / lifetime (driver owned)
Pavel Tatashin9f960da2019-07-16 16:30:35 -070046 * @dax_mem_res: physical address range of hotadded DAX memory
David Hildenbrand8a725e42020-06-04 16:48:48 -070047 * @dax_mem_name: name for hotadded DAX memory via add_memory_driver_managed()
Dave Jiangefebc712017-04-07 15:33:36 -070048 */
Dan Williams73616362017-05-04 23:38:43 -070049struct dev_dax {
Dave Jiangefebc712017-04-07 15:33:36 -070050 struct dax_region *region;
Dan Williams73616362017-05-04 23:38:43 -070051 struct dax_device *dax_dev;
Dan Williams8fc5c732018-11-09 12:43:07 -080052 int target_node;
Dave Jiangefebc712017-04-07 15:33:36 -070053 struct device dev;
Dan Williams89ec9f22018-10-29 15:52:42 -070054 struct dev_pagemap pgmap;
Pavel Tatashin9f960da2019-07-16 16:30:35 -070055 struct resource *dax_kmem_res;
Dave Jiangefebc712017-04-07 15:33:36 -070056};
Dan Williams51cf7842017-07-12 17:58:21 -070057
58static inline struct dev_dax *to_dev_dax(struct device *dev)
59{
60 return container_of(dev, struct dev_dax, dev);
61}
Dave Jiangefebc712017-04-07 15:33:36 -070062#endif