History

mm/hmm: define the pre-processor related parts of hmm.h even if disabled

Only the function calls are stubbed out with static inlines that always fail. This is the standard way to write a header for an optional component and makes it easier for drivers that only optionally need HMM_MIRROR.

Jason Gunthorpe committed 7 years ago

Commit 107e8991 parent 04ec32f2 files · +47 −13Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/hmm.h+47−12
@@ -62,8 +62,6 @@ · 61 unmodified lines
62#include <linux/kconfig.h>62#include <linux/kconfig.h>
63#include <asm/pgtable.h>63#include <asm/pgtable.h>
64 64
65#ifdef CONFIG_HMM_MIRROR
66
67#include <linux/device.h>65#include <linux/device.h>
68#include <linux/migrate.h>66#include <linux/migrate.h>
69#include <linux/memremap.h>67#include <linux/memremap.h>
@@ -374,6 +372,15 @@ struct hmm_mirror { · 304 unmodified lines
374 struct list_head list;372 struct list_head list;
375};373};
376 374
375/*
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
377int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm);384int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm);
378void hmm_mirror_unregister(struct hmm_mirror *mirror);385void hmm_mirror_unregister(struct hmm_mirror *mirror);
379 386
@@ -383,14 +390,6 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror); · 3 unmodified lines
383int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror);390int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror);
384void hmm_range_unregister(struct hmm_range *range);391void hmm_range_unregister(struct hmm_range *range);
385 392
386/*
387 * Retry fault if non-blocking, drop mmap_sem and return -EAGAIN in that case.
388 */
389#define HMM_FAULT_ALLOW_RETRY (1 << 0)
390
391/* Don't fault in missing PTEs, just snapshot the current state. */
392#define HMM_FAULT_SNAPSHOT (1 << 1)
393
394long hmm_range_fault(struct hmm_range *range, unsigned int flags);393long hmm_range_fault(struct hmm_range *range, unsigned int flags);
395 394
396long hmm_range_dma_map(struct hmm_range *range,395long hmm_range_dma_map(struct hmm_range *range,
@@ -401,6 +400,44 @@ long hmm_range_dma_unmap(struct hmm_range *range, · 4 unmodified lines
401 struct device *device,400 struct device *device,
402 dma_addr_t *daddrs,401 dma_addr_t *daddrs,
403 bool dirty);402 bool dirty);
403#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
404 441
405/*442/*
406 * HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range443 * HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range
@@ -411,6 +448,4 @@ long hmm_range_dma_unmap(struct hmm_range *range, · 4 unmodified lines
411 */448 */
412#define HMM_RANGE_DEFAULT_TIMEOUT 1000449#define HMM_RANGE_DEFAULT_TIMEOUT 1000
413 450
414#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
415
416#endif /* LINUX_HMM_H */451#endif /* LINUX_HMM_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t