blob: 3107ce80e8090ee4f9dec4eb290471c0f7958b32 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001/* SPDX-License-Identifier: GPL-2.0-only */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00004 */
5#ifndef __DAX_PRIVATE_H__
6#define __DAX_PRIVATE_H__
7
8#include <linux/device.h>
9#include <linux/cdev.h>
10
David Brazdil0f672f62019-12-10 10:32:29 +000011/* 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);
15int dax_bus_init(void);
16void dax_bus_exit(void);
17
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000018/**
19 * struct dax_region - mapping infrastructure for dax devices
20 * @id: kernel-wide unique region for a memory range
David Brazdil0f672f62019-12-10 10:32:29 +000021 * @target_node: effective numa node if this memory range is onlined
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000022 * @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;
David Brazdil0f672f62019-12-10 10:32:29 +000030 int target_node;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031 struct kref kref;
32 struct device *dev;
33 unsigned int align;
34 struct resource res;
Olivier Deprez0e641232021-09-23 10:07:05 +020035 unsigned long long pfn_flags;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000036};
37
38/**
David Brazdil0f672f62019-12-10 10:32:29 +000039 * struct dev_dax - instance data for a subdivision of a dax region, and
40 * data while the device is activated in the driver.
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000041 * @region - parent region
42 * @dax_dev - core dax functionality
David Brazdil0f672f62019-12-10 10:32:29 +000043 * @target_node: effective numa node if dev_dax memory range is onlined
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000044 * @dev - device core
David Brazdil0f672f62019-12-10 10:32:29 +000045 * @pgmap - pgmap for memmap setup / lifetime (driver owned)
46 * @dax_mem_res: physical address range of hotadded DAX memory
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000047 */
48struct dev_dax {
49 struct dax_region *region;
50 struct dax_device *dax_dev;
David Brazdil0f672f62019-12-10 10:32:29 +000051 int target_node;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000052 struct device dev;
David Brazdil0f672f62019-12-10 10:32:29 +000053 struct dev_pagemap pgmap;
54 struct resource *dax_kmem_res;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000055};
David Brazdil0f672f62019-12-10 10:32:29 +000056
57static inline struct dev_dax *to_dev_dax(struct device *dev)
58{
59 return container_of(dev, struct dev_dax, dev);
60}
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000061#endif