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
6262 #include <linux/kconfig.h>
6363 #include <asm/pgtable.h>
6464
65−#ifdef CONFIG_HMM_MIRROR
66−
6765 #include <linux/device.h>
6866 #include <linux/migrate.h>
6967 #include <linux/memremap.h>
@@ -374,6 +372,15 @@ struct hmm_mirror { · 304 unmodified lines
374372 struct list_head list;
375373 };
376374
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
377384 int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm);
378385 void hmm_mirror_unregister(struct hmm_mirror *mirror);
379386
@@ -383,14 +390,6 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror); · 3 unmodified lines
383390 int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror);
384391 void hmm_range_unregister(struct hmm_range *range);
385392
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−
394393 long hmm_range_fault(struct hmm_range *range, unsigned int flags);
395394
396395 long hmm_range_dma_map(struct hmm_range *range,
@@ -401,6 +400,44 @@ long hmm_range_dma_unmap(struct hmm_range *range, · 4 unmodified lines
401400 struct device *device,
402401 dma_addr_t *daddrs,
403402 bool dirty);
403+#else
404+int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm)
405+{
406+ return -EOPNOTSUPP;
407+}
408+
409+void hmm_mirror_unregister(struct hmm_mirror *mirror)
410+{
411+}
412+
413+int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror)
414+{
415+ return -EOPNOTSUPP;
416+}
417+
418+void hmm_range_unregister(struct hmm_range *range)
419+{
420+}
421+
422+static inline long hmm_range_fault(struct hmm_range *range, unsigned int flags)
423+{
424+ return -EOPNOTSUPP;
425+}
426+
427+static 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+
434+static 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
404441
405442 /*
406443 * 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
411448 */
412449 #define HMM_RANGE_DEFAULT_TIMEOUT 1000
413450
414−#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
415−
416451 #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