blob: cb69bf10dc788c58d866940c3dcc9a252a656512 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Jérôme Glisse133ff0e2017-09-08 16:11:23 -07002/*
3 * Copyright 2013 Red Hat Inc.
4 *
Jérôme Glissef813f212018-10-30 15:04:06 -07005 * Authors: Jérôme Glisse <jglisse@redhat.com>
Jérôme Glisse133ff0e2017-09-08 16:11:23 -07006 */
7/*
8 * Heterogeneous Memory Management (HMM)
9 *
Mike Rapoportad56b732018-03-21 21:22:47 +020010 * See Documentation/vm/hmm.rst for reasons and overview of what HMM is and it
Jérôme Glisse133ff0e2017-09-08 16:11:23 -070011 * is for. Here we focus on the HMM API description, with some explanation of
12 * the underlying implementation.
13 *
14 * Short description: HMM provides a set of helpers to share a virtual address
15 * space between CPU and a device, so that the device can access any valid
16 * address of the process (while still obeying memory protection). HMM also
17 * provides helpers to migrate process memory to device memory, and back. Each
18 * set of functionality (address space mirroring, and migration to and from
19 * device memory) can be used independently of the other.
20 *
21 *
22 * HMM address space mirroring API:
23 *
Ralph Campbell085ea252019-05-06 16:29:39 -070024 * Use HMM address space mirroring if you want to mirror a range of the CPU
25 * page tables of a process into a device page table. Here, "mirror" means "keep
Jérôme Glisse133ff0e2017-09-08 16:11:23 -070026 * synchronized". Prerequisites: the device must provide the ability to write-
27 * protect its page tables (at PAGE_SIZE granularity), and must be able to
28 * recover from the resulting potential page faults.
29 *
30 * HMM guarantees that at any point in time, a given virtual address points to
31 * either the same memory in both CPU and device page tables (that is: CPU and
32 * device page tables each point to the same pages), or that one page table (CPU
33 * or device) points to no entry, while the other still points to the old page
34 * for the address. The latter case happens when the CPU page table update
35 * happens first, and then the update is mirrored over to the device page table.
36 * This does not cause any issue, because the CPU page table cannot start
37 * pointing to a new page until the device page table is invalidated.
38 *
39 * HMM uses mmu_notifiers to monitor the CPU page tables, and forwards any
40 * updates to each device driver that has registered a mirror. It also provides
41 * some API calls to help with taking a snapshot of the CPU page table, and to
42 * synchronize with any updates that might happen concurrently.
43 *
44 *
45 * HMM migration to and from device memory:
46 *
47 * HMM provides a set of helpers to hotplug device memory as ZONE_DEVICE, with
48 * a new MEMORY_DEVICE_PRIVATE type. This provides a struct page for each page
49 * of the device memory, and allows the device driver to manage its memory
50 * using those struct pages. Having struct pages for device memory makes
51 * migration easier. Because that memory is not addressable by the CPU it must
52 * never be pinned to the device; in other words, any CPU page fault can always
53 * cause the device memory to be migrated (copied/moved) back to regular memory.
54 *
55 * A new migrate helper (migrate_vma()) has been added (see mm/migrate.c) that
56 * allows use of a device DMA engine to perform the copy operation between
57 * regular system memory and device memory.
58 */
59#ifndef LINUX_HMM_H
60#define LINUX_HMM_H
61
62#include <linux/kconfig.h>
Dan Williams063a7d12018-12-28 00:39:46 -080063#include <asm/pgtable.h>
Jérôme Glisse133ff0e2017-09-08 16:11:23 -070064
Jérôme Glisse858b54d2017-09-08 16:12:02 -070065#include <linux/device.h>
Jérôme Glisse4ef589d2017-09-08 16:11:58 -070066#include <linux/migrate.h>
67#include <linux/memremap.h>
68#include <linux/completion.h>
Jérôme Glissea3e0d412019-05-13 17:20:01 -070069#include <linux/mmu_notifier.h>
Jérôme Glisse4ef589d2017-09-08 16:11:58 -070070
Jérôme Glissea3e0d412019-05-13 17:20:01 -070071
72/*
73 * struct hmm - HMM per mm struct
74 *
75 * @mm: mm struct this HMM struct is bound to
76 * @lock: lock protecting ranges list
77 * @ranges: list of range being snapshotted
78 * @mirrors: list of mirrors for this mm
79 * @mmu_notifier: mmu notifier to track updates to CPU page table
80 * @mirrors_sem: read/write semaphore protecting the mirrors list
81 * @wq: wait queue for user waiting on a range invalidation
82 * @notifiers: count of active mmu notifiers
Jérôme Glissea3e0d412019-05-13 17:20:01 -070083 */
84struct hmm {
Jason Gunthorpec7d8b782019-08-06 20:15:42 -030085 struct mmu_notifier mmu_notifier;
Jason Gunthorpe5a136b42019-06-07 12:10:33 -030086 spinlock_t ranges_lock;
Jérôme Glissea3e0d412019-05-13 17:20:01 -070087 struct list_head ranges;
88 struct list_head mirrors;
Jérôme Glissea3e0d412019-05-13 17:20:01 -070089 struct rw_semaphore mirrors_sem;
90 wait_queue_head_t wq;
91 long notifiers;
Jérôme Glissea3e0d412019-05-13 17:20:01 -070092};
Jérôme Glisse133ff0e2017-09-08 16:11:23 -070093
94/*
Jérôme Glissef88a1e92018-04-10 16:29:06 -070095 * hmm_pfn_flag_e - HMM flag enums
96 *
Jérôme Glisse133ff0e2017-09-08 16:11:23 -070097 * Flags:
Jérôme Glisse86586a42018-04-10 16:28:34 -070098 * HMM_PFN_VALID: pfn is valid. It has, at least, read permission.
Jérôme Glisse133ff0e2017-09-08 16:11:23 -070099 * HMM_PFN_WRITE: CPU page table has write permission set
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700100 * HMM_PFN_DEVICE_PRIVATE: private device memory (ZONE_DEVICE)
101 *
Ralph Campbell085ea252019-05-06 16:29:39 -0700102 * The driver provides a flags array for mapping page protections to device
103 * PTE bits. If the driver valid bit for an entry is bit 3,
104 * i.e., (entry & (1 << 3)), then the driver must provide
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700105 * an array in hmm_range.flags with hmm_range.flags[HMM_PFN_VALID] == 1 << 3.
Ralph Campbell085ea252019-05-06 16:29:39 -0700106 * Same logic apply to all flags. This is the same idea as vm_page_prot in vma
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700107 * except that this is per device driver rather than per architecture.
108 */
109enum hmm_pfn_flag_e {
110 HMM_PFN_VALID = 0,
111 HMM_PFN_WRITE,
112 HMM_PFN_DEVICE_PRIVATE,
113 HMM_PFN_FLAG_MAX
114};
115
116/*
117 * hmm_pfn_value_e - HMM pfn special value
118 *
119 * Flags:
Jérôme Glisseda4c3c72017-09-08 16:11:31 -0700120 * HMM_PFN_ERROR: corresponding CPU page table entry points to poisoned memory
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700121 * HMM_PFN_NONE: corresponding CPU page table entry is pte_none()
Jérôme Glisseda4c3c72017-09-08 16:11:31 -0700122 * HMM_PFN_SPECIAL: corresponding CPU page table entry is special; i.e., the
Matthew Wilcox67fa1662018-10-26 15:04:26 -0700123 * result of vmf_insert_pfn() or vm_insert_page(). Therefore, it should not
Jérôme Glisseda4c3c72017-09-08 16:11:31 -0700124 * be mirrored by a device, because the entry will never have HMM_PFN_VALID
125 * set and the pfn value is undefined.
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700126 *
Ralph Campbell085ea252019-05-06 16:29:39 -0700127 * Driver provides values for none entry, error entry, and special entry.
128 * Driver can alias (i.e., use same value) error and special, but
129 * it should not alias none with error or special.
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700130 *
131 * HMM pfn value returned by hmm_vma_get_pfns() or hmm_vma_fault() will be:
132 * hmm_range.values[HMM_PFN_ERROR] if CPU page table entry is poisonous,
Ralph Campbell085ea252019-05-06 16:29:39 -0700133 * hmm_range.values[HMM_PFN_NONE] if there is no CPU page table entry,
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700134 * hmm_range.values[HMM_PFN_SPECIAL] if CPU page table entry is a special one
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700135 */
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700136enum hmm_pfn_value_e {
137 HMM_PFN_ERROR,
138 HMM_PFN_NONE,
139 HMM_PFN_SPECIAL,
140 HMM_PFN_VALUE_MAX
141};
142
143/*
144 * struct hmm_range - track invalidation lock on virtual address range
145 *
Jason Gunthorpe04ec32f2019-11-12 16:22:20 -0400146 * @notifier: an optional mmu_interval_notifier
147 * @notifier_seq: when notifier is used this is the result of
148 * mmu_interval_read_begin()
Jérôme Glisse704f3f22019-05-13 17:19:48 -0700149 * @hmm: the core HMM structure this range is active against
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700150 * @vma: the vm area struct for the range
151 * @list: all range lock are on a list
152 * @start: range virtual start address (inclusive)
153 * @end: range virtual end address (exclusive)
154 * @pfns: array of pfns (big enough for the range)
155 * @flags: pfn flags to match device driver page table
156 * @values: pfn value for some special case (none, special, error, ...)
Jérôme Glisse023a0192019-05-13 17:20:05 -0700157 * @default_flags: default flags for the range (write, read, ... see hmm doc)
158 * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700159 * @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT)
160 * @valid: pfns array did not change since it has been fill by an HMM function
161 */
162struct hmm_range {
Jason Gunthorpe04ec32f2019-11-12 16:22:20 -0400163 struct mmu_interval_notifier *notifier;
164 unsigned long notifier_seq;
Jérôme Glisse704f3f22019-05-13 17:19:48 -0700165 struct hmm *hmm;
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700166 struct list_head list;
167 unsigned long start;
168 unsigned long end;
169 uint64_t *pfns;
170 const uint64_t *flags;
171 const uint64_t *values;
Jérôme Glisse023a0192019-05-13 17:20:05 -0700172 uint64_t default_flags;
173 uint64_t pfn_flags_mask;
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700174 uint8_t pfn_shift;
175 bool valid;
176};
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700177
178/*
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700179 * hmm_range_wait_until_valid() - wait for range to be valid
180 * @range: range affected by invalidation to wait on
181 * @timeout: time out for wait in ms (ie abort wait after that period of time)
Ralph Campbell085ea252019-05-06 16:29:39 -0700182 * Return: true if the range is valid, false otherwise.
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700183 */
184static inline bool hmm_range_wait_until_valid(struct hmm_range *range,
185 unsigned long timeout)
186{
Jason Gunthorpe378a6042019-05-23 11:17:22 -0300187 return wait_event_timeout(range->hmm->wq, range->valid,
188 msecs_to_jiffies(timeout)) != 0;
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700189}
190
191/*
192 * hmm_range_valid() - test if a range is valid or not
193 * @range: range
Ralph Campbell085ea252019-05-06 16:29:39 -0700194 * Return: true if the range is valid, false otherwise.
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700195 */
196static inline bool hmm_range_valid(struct hmm_range *range)
197{
198 return range->valid;
199}
200
201/*
Jérôme Glisse391aab12019-05-13 17:20:31 -0700202 * hmm_device_entry_to_page() - return struct page pointed to by a device entry
203 * @range: range use to decode device entry value
204 * @entry: device entry value to get corresponding struct page from
Ralph Campbell085ea252019-05-06 16:29:39 -0700205 * Return: struct page pointer if entry is a valid, NULL otherwise
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700206 *
Jérôme Glisse391aab12019-05-13 17:20:31 -0700207 * If the device entry is valid (ie valid flag set) then return the struct page
208 * matching the entry value. Otherwise return NULL.
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700209 */
Jérôme Glisse391aab12019-05-13 17:20:31 -0700210static inline struct page *hmm_device_entry_to_page(const struct hmm_range *range,
211 uint64_t entry)
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700212{
Jérôme Glisse391aab12019-05-13 17:20:31 -0700213 if (entry == range->values[HMM_PFN_NONE])
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700214 return NULL;
Jérôme Glisse391aab12019-05-13 17:20:31 -0700215 if (entry == range->values[HMM_PFN_ERROR])
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700216 return NULL;
Jérôme Glisse391aab12019-05-13 17:20:31 -0700217 if (entry == range->values[HMM_PFN_SPECIAL])
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700218 return NULL;
Jérôme Glisse391aab12019-05-13 17:20:31 -0700219 if (!(entry & range->flags[HMM_PFN_VALID]))
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700220 return NULL;
Jérôme Glisse391aab12019-05-13 17:20:31 -0700221 return pfn_to_page(entry >> range->pfn_shift);
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700222}
223
224/*
Jérôme Glisse391aab12019-05-13 17:20:31 -0700225 * hmm_device_entry_to_pfn() - return pfn value store in a device entry
226 * @range: range use to decode device entry value
227 * @entry: device entry to extract pfn from
Ralph Campbell085ea252019-05-06 16:29:39 -0700228 * Return: pfn value if device entry is valid, -1UL otherwise
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700229 */
Jérôme Glisse391aab12019-05-13 17:20:31 -0700230static inline unsigned long
231hmm_device_entry_to_pfn(const struct hmm_range *range, uint64_t pfn)
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700232{
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700233 if (pfn == range->values[HMM_PFN_NONE])
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700234 return -1UL;
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700235 if (pfn == range->values[HMM_PFN_ERROR])
236 return -1UL;
237 if (pfn == range->values[HMM_PFN_SPECIAL])
238 return -1UL;
239 if (!(pfn & range->flags[HMM_PFN_VALID]))
240 return -1UL;
241 return (pfn >> range->pfn_shift);
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700242}
243
244/*
Jérôme Glisse391aab12019-05-13 17:20:31 -0700245 * hmm_device_entry_from_page() - create a valid device entry for a page
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700246 * @range: range use to encode HMM pfn value
Jérôme Glisse391aab12019-05-13 17:20:31 -0700247 * @page: page for which to create the device entry
Ralph Campbell085ea252019-05-06 16:29:39 -0700248 * Return: valid device entry for the page
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700249 */
Jérôme Glisse391aab12019-05-13 17:20:31 -0700250static inline uint64_t hmm_device_entry_from_page(const struct hmm_range *range,
251 struct page *page)
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700252{
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700253 return (page_to_pfn(page) << range->pfn_shift) |
254 range->flags[HMM_PFN_VALID];
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700255}
256
257/*
Jérôme Glisse391aab12019-05-13 17:20:31 -0700258 * hmm_device_entry_from_pfn() - create a valid device entry value from pfn
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700259 * @range: range use to encode HMM pfn value
Jérôme Glisse391aab12019-05-13 17:20:31 -0700260 * @pfn: pfn value for which to create the device entry
Ralph Campbell085ea252019-05-06 16:29:39 -0700261 * Return: valid device entry for the pfn
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700262 */
Jérôme Glisse391aab12019-05-13 17:20:31 -0700263static inline uint64_t hmm_device_entry_from_pfn(const struct hmm_range *range,
264 unsigned long pfn)
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700265{
Jérôme Glissef88a1e92018-04-10 16:29:06 -0700266 return (pfn << range->pfn_shift) |
267 range->flags[HMM_PFN_VALID];
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700268}
269
Jérôme Glisse391aab12019-05-13 17:20:31 -0700270/*
Jérôme Glissec0b12402017-09-08 16:11:27 -0700271 * Mirroring: how to synchronize device page table with CPU page table.
272 *
273 * A device driver that is participating in HMM mirroring must always
274 * synchronize with CPU page table updates. For this, device drivers can either
275 * directly use mmu_notifier APIs or they can use the hmm_mirror API. Device
276 * drivers can decide to register one mirror per device per process, or just
277 * one mirror per process for a group of devices. The pattern is:
278 *
279 * int device_bind_address_space(..., struct mm_struct *mm, ...)
280 * {
281 * struct device_address_space *das;
282 *
283 * // Device driver specific initialization, and allocation of das
284 * // which contains an hmm_mirror struct as one of its fields.
285 * ...
286 *
287 * ret = hmm_mirror_register(&das->mirror, mm, &device_mirror_ops);
288 * if (ret) {
289 * // Cleanup on error
290 * return ret;
291 * }
292 *
293 * // Other device driver specific initialization
294 * ...
295 * }
296 *
297 * Once an hmm_mirror is registered for an address space, the device driver
298 * will get callbacks through sync_cpu_device_pagetables() operation (see
299 * hmm_mirror_ops struct).
300 *
301 * Device driver must not free the struct containing the hmm_mirror struct
302 * before calling hmm_mirror_unregister(). The expected usage is to do that when
303 * the device driver is unbinding from an address space.
304 *
305 *
306 * void device_unbind_address_space(struct device_address_space *das)
307 * {
308 * // Device driver specific cleanup
309 * ...
310 *
311 * hmm_mirror_unregister(&das->mirror);
312 *
313 * // Other device driver specific cleanup, and now das can be freed
314 * ...
315 * }
316 */
317
318struct hmm_mirror;
319
320/*
Jérôme Glissec0b12402017-09-08 16:11:27 -0700321 * struct hmm_mirror_ops - HMM mirror device operations callback
322 *
323 * @update: callback to update range on a device
324 */
325struct hmm_mirror_ops {
Ralph Campbelle1401512018-04-10 16:28:19 -0700326 /* release() - release hmm_mirror
327 *
328 * @mirror: pointer to struct hmm_mirror
329 *
Ralph Campbell2076e5c2019-05-06 16:29:38 -0700330 * This is called when the mm_struct is being released. The callback
331 * must ensure that all access to any pages obtained from this mirror
332 * is halted before the callback returns. All future access should
333 * fault.
Ralph Campbelle1401512018-04-10 16:28:19 -0700334 */
335 void (*release)(struct hmm_mirror *mirror);
336
Jérôme Glissec0b12402017-09-08 16:11:27 -0700337 /* sync_cpu_device_pagetables() - synchronize page tables
338 *
339 * @mirror: pointer to struct hmm_mirror
Ralph Campbell1f961802019-07-25 17:56:44 -0700340 * @update: update information (see struct mmu_notifier_range)
341 * Return: -EAGAIN if mmu_notifier_range_blockable(update) is false
342 * and callback needs to block, 0 otherwise.
Jérôme Glissec0b12402017-09-08 16:11:27 -0700343 *
344 * This callback ultimately originates from mmu_notifiers when the CPU
345 * page table is updated. The device driver must update its page table
346 * in response to this callback. The update argument tells what action
347 * to perform.
348 *
349 * The device driver must not return from this callback until the device
350 * page tables are completely updated (TLBs flushed, etc); this is a
351 * synchronous call.
352 */
Ralph Campbell1f961802019-07-25 17:56:44 -0700353 int (*sync_cpu_device_pagetables)(
354 struct hmm_mirror *mirror,
355 const struct mmu_notifier_range *update);
Jérôme Glissec0b12402017-09-08 16:11:27 -0700356};
357
358/*
359 * struct hmm_mirror - mirror struct for a device driver
360 *
361 * @hmm: pointer to struct hmm (which is unique per mm_struct)
362 * @ops: device driver callback for HMM mirror operations
363 * @list: for list of mirrors of a given mm
364 *
365 * Each address space (mm_struct) being mirrored by a device must register one
366 * instance of an hmm_mirror struct with HMM. HMM will track the list of all
367 * mirrors for each mm_struct.
368 */
369struct hmm_mirror {
370 struct hmm *hmm;
371 const struct hmm_mirror_ops *ops;
372 struct list_head list;
373};
374
Jason Gunthorpe107e8992019-11-12 16:22:21 -0400375/*
376 * Retry fault if non-blocking, drop mmap_sem and return -EAGAIN in that case.
377 */
378#define HMM_FAULT_ALLOW_RETRY (1 << 0)
379
380/* Don't fault in missing PTEs, just snapshot the current state. */
381#define HMM_FAULT_SNAPSHOT (1 << 1)
382
383#ifdef CONFIG_HMM_MIRROR
Jérôme Glissec0b12402017-09-08 16:11:27 -0700384int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm);
385void hmm_mirror_unregister(struct hmm_mirror *mirror);
Jérôme Glisseda4c3c72017-09-08 16:11:31 -0700386
Jérôme Glisse20239412019-05-13 17:20:24 -0700387/*
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700388 * Please see Documentation/vm/hmm.rst for how to use the range API.
Jérôme Glisseda4c3c72017-09-08 16:11:31 -0700389 */
Christoph Hellwigfac555a2019-08-06 19:05:44 +0300390int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror);
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700391void hmm_range_unregister(struct hmm_range *range);
Christoph Hellwig9a4903e2019-07-25 17:56:46 -0700392
Christoph Hellwig9a4903e2019-07-25 17:56:46 -0700393long hmm_range_fault(struct hmm_range *range, unsigned int flags);
394
Jérôme Glisse55c0ece2019-05-13 17:20:28 -0700395long hmm_range_dma_map(struct hmm_range *range,
396 struct device *device,
397 dma_addr_t *daddrs,
Christoph Hellwig9a4903e2019-07-25 17:56:46 -0700398 unsigned int flags);
Jérôme Glisse55c0ece2019-05-13 17:20:28 -0700399long hmm_range_dma_unmap(struct hmm_range *range,
Jérôme Glisse55c0ece2019-05-13 17:20:28 -0700400 struct device *device,
401 dma_addr_t *daddrs,
402 bool dirty);
Jason Gunthorpe107e8992019-11-12 16:22:21 -0400403#else
404int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm)
405{
406 return -EOPNOTSUPP;
407}
408
409void hmm_mirror_unregister(struct hmm_mirror *mirror)
410{
411}
412
413int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror)
414{
415 return -EOPNOTSUPP;
416}
417
418void hmm_range_unregister(struct hmm_range *range)
419{
420}
421
422static inline long hmm_range_fault(struct hmm_range *range, unsigned int flags)
423{
424 return -EOPNOTSUPP;
425}
426
427static inline long hmm_range_dma_map(struct hmm_range *range,
428 struct device *device, dma_addr_t *daddrs,
429 unsigned int flags)
430{
431 return -EOPNOTSUPP;
432}
433
434static inline long hmm_range_dma_unmap(struct hmm_range *range,
435 struct device *device,
436 dma_addr_t *daddrs, bool dirty)
437{
438 return -EOPNOTSUPP;
439}
440#endif
Jérôme Glisse74eee182017-09-08 16:11:35 -0700441
442/*
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700443 * HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range
Jérôme Glisse74eee182017-09-08 16:11:35 -0700444 *
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700445 * When waiting for mmu notifiers we need some kind of time out otherwise we
446 * could potentialy wait for ever, 1000ms ie 1s sounds like a long time to
447 * wait already.
Jérôme Glisse74eee182017-09-08 16:11:35 -0700448 */
Jérôme Glissea3e0d412019-05-13 17:20:01 -0700449#define HMM_RANGE_DEFAULT_TIMEOUT 1000
450
Jérôme Glisse133ff0e2017-09-08 16:11:23 -0700451#endif /* LINUX_HMM_H */