Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
  4 */
  5#ifndef __DAX_PRIVATE_H__
  6#define __DAX_PRIVATE_H__
  7
  8#include <linux/device.h>
  9#include <linux/cdev.h>
 10#include <linux/idr.h>
 11
 12/* private routines between core files */
 13struct dax_device;
 14struct dax_device *inode_dax(struct inode *inode);
 15struct inode *dax_inode(struct dax_device *dax_dev);
 16int dax_bus_init(void);
 17void dax_bus_exit(void);
 18
 19/**
 20 * struct dax_region - mapping infrastructure for dax devices
 21 * @id: kernel-wide unique region for a memory range
 22 * @target_node: effective numa node if this memory range is onlined
 23 * @kref: to pin while other agents have a need to do lookups
 24 * @dev: parent device backing this region
 25 * @align: allocation and mapping alignment for child dax devices
 26 * @ida: instance id allocator
 27 * @res: resource tree to track instance allocations
 28 * @seed: allow userspace to find the first unbound seed device
 29 * @youngest: allow userspace to find the most recently created device
 30 */
 31struct dax_region {
 32	int id;
 33	int target_node;
 34	struct kref kref;
 35	struct device *dev;
 36	unsigned int align;
 37	struct ida ida;
 38	struct resource res;
 39	struct device *seed;
 40	struct device *youngest;
 41};
 42
 43struct dax_mapping {
 44	struct device dev;
 45	int range_id;
 46	int id;
 47};
 48
 49/**
 50 * struct dev_dax - instance data for a subdivision of a dax region, and
 51 * data while the device is activated in the driver.
 52 * @region - parent region
 53 * @dax_dev - core dax functionality
 54 * @target_node: effective numa node if dev_dax memory range is onlined
 55 * @dyn_id: is this a dynamic or statically created instance
 56 * @id: ida allocated id when the dax_region is not static
 57 * @ida: mapping id allocator
 58 * @dev - device core
 59 * @pgmap - pgmap for memmap setup / lifetime (driver owned)
 60 * @nr_range: size of @ranges
 61 * @ranges: resource-span + pgoff tuples for the instance
 62 */
 63struct dev_dax {
 64	struct dax_region *region;
 65	struct dax_device *dax_dev;
 66	unsigned int align;
 67	int target_node;
 68	bool dyn_id;
 69	int id;
 70	struct ida ida;
 71	struct device dev;
 72	struct dev_pagemap *pgmap;
 73	bool memmap_on_memory;
 74	int nr_range;
 75	struct dev_dax_range {
 76		unsigned long pgoff;
 77		struct range range;
 78		struct dax_mapping *mapping;
 79	} *ranges;
 80};
 81
 82/*
 83 * While run_dax() is potentially a generic operation that could be
 84 * defined in include/linux/dax.h we don't want to grow any users
 85 * outside of drivers/dax/
 86 */
 87void run_dax(struct dax_device *dax_dev);
 88
 89static inline struct dev_dax *to_dev_dax(struct device *dev)
 90{
 91	return container_of(dev, struct dev_dax, dev);
 92}
 93
 94static inline struct dax_mapping *to_dax_mapping(struct device *dev)
 95{
 96	return container_of(dev, struct dax_mapping, dev);
 97}
 98
 99phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, unsigned long size);
100
101#ifdef CONFIG_TRANSPARENT_HUGEPAGE
102static inline bool dax_align_valid(unsigned long align)
103{
104	if (align == PUD_SIZE && IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD))
105		return true;
106	if (align == PMD_SIZE && has_transparent_hugepage())
107		return true;
108	if (align == PAGE_SIZE)
109		return true;
110	return false;
111}
112#else
113static inline bool dax_align_valid(unsigned long align)
114{
115	return align == PAGE_SIZE;
116}
117#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
118#endif
v5.9
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
 4 */
 5#ifndef __DAX_PRIVATE_H__
 6#define __DAX_PRIVATE_H__
 7
 8#include <linux/device.h>
 9#include <linux/cdev.h>
 
10
11/* 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
18/**
19 * struct dax_region - mapping infrastructure for dax devices
20 * @id: kernel-wide unique region for a memory range
21 * @target_node: effective numa node if this memory range is onlined
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 */
28struct dax_region {
29	int id;
30	int target_node;
31	struct kref kref;
32	struct device *dev;
33	unsigned int align;
 
34	struct resource res;
35	unsigned long long pfn_flags;
 
 
 
 
 
 
 
36};
37
38/**
39 * struct dev_dax - instance data for a subdivision of a dax region, and
40 * data while the device is activated in the driver.
41 * @region - parent region
42 * @dax_dev - core dax functionality
43 * @target_node: effective numa node if dev_dax memory range is onlined
 
 
 
44 * @dev - device core
45 * @pgmap - pgmap for memmap setup / lifetime (driver owned)
46 * @dax_mem_res: physical address range of hotadded DAX memory
47 * @dax_mem_name: name for hotadded DAX memory via add_memory_driver_managed()
48 */
49struct dev_dax {
50	struct dax_region *region;
51	struct dax_device *dax_dev;
 
52	int target_node;
 
 
 
53	struct device dev;
54	struct dev_pagemap pgmap;
55	struct resource *dax_kmem_res;
 
 
 
 
 
 
56};
57
 
 
 
 
 
 
 
58static inline struct dev_dax *to_dev_dax(struct device *dev)
59{
60	return container_of(dev, struct dev_dax, dev);
61}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62#endif