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.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -62,8 +62,6 @@ · 61 unmodified lines | ||
| 62 | 62 | #include <linux/kconfig.h> |
| 63 | 63 | #include <asm/pgtable.h> |
| 64 | 64 | |
| 65 | −#ifdef CONFIG_HMM_MIRROR | |
| 66 | − | |
| 67 | 65 | #include <linux/device.h> |
| 68 | 66 | #include <linux/migrate.h> |
| 69 | 67 | #include <linux/memremap.h> |
| @@ -374,6 +372,15 @@ struct hmm_mirror { · 304 unmodified lines | ||
| 374 | 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 | |
| 377 | 384 | int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm); |
| 378 | 385 | void hmm_mirror_unregister(struct hmm_mirror *mirror); |
| 379 | 386 | |
| @@ -383,14 +390,6 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror); · 3 unmodified lines | ||
| 383 | 390 | int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror); |
| 384 | 391 | void 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 | − | |
| 394 | 393 | long hmm_range_fault(struct hmm_range *range, unsigned int flags); |
| 395 | 394 | |
| 396 | 395 | 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 | ||
| 401 | 400 | struct device *device, |
| 402 | 401 | dma_addr_t *daddrs, |
| 403 | 402 | 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 | |
| 404 | 441 | |
| 405 | 442 | /* |
| 406 | 443 | * 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 | 449 | #define HMM_RANGE_DEFAULT_TIMEOUT 1000 |
| 413 | 450 | |
| 414 | −#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ | |
| 415 | − | |
| 416 | 451 | #endif /* LINUX_HMM_H */ |