Commit 107e8998 authored by Jason Gunthorpe's avatar Jason Gunthorpe

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.

Link: https://lore.kernel.org/r/20191112202231.3856-5-jgg@ziepe.caReviewed-by: default avatarJérôme Glisse <jglisse@redhat.com>
Tested-by: default avatarRalph Campbell <rcampbell@nvidia.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 04ec32fb
...@@ -62,8 +62,6 @@ ...@@ -62,8 +62,6 @@
#include <linux/kconfig.h> #include <linux/kconfig.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#ifdef CONFIG_HMM_MIRROR
#include <linux/device.h> #include <linux/device.h>
#include <linux/migrate.h> #include <linux/migrate.h>
#include <linux/memremap.h> #include <linux/memremap.h>
...@@ -374,6 +372,15 @@ struct hmm_mirror { ...@@ -374,6 +372,15 @@ struct hmm_mirror {
struct list_head list; struct list_head list;
}; };
/*
* Retry fault if non-blocking, drop mmap_sem and return -EAGAIN in that case.
*/
#define HMM_FAULT_ALLOW_RETRY (1 << 0)
/* Don't fault in missing PTEs, just snapshot the current state. */
#define HMM_FAULT_SNAPSHOT (1 << 1)
#ifdef CONFIG_HMM_MIRROR
int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm); int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm);
void hmm_mirror_unregister(struct hmm_mirror *mirror); void hmm_mirror_unregister(struct hmm_mirror *mirror);
...@@ -383,14 +390,6 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror); ...@@ -383,14 +390,6 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror);
int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror); int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror);
void hmm_range_unregister(struct hmm_range *range); void hmm_range_unregister(struct hmm_range *range);
/*
* Retry fault if non-blocking, drop mmap_sem and return -EAGAIN in that case.
*/
#define HMM_FAULT_ALLOW_RETRY (1 << 0)
/* Don't fault in missing PTEs, just snapshot the current state. */
#define HMM_FAULT_SNAPSHOT (1 << 1)
long hmm_range_fault(struct hmm_range *range, unsigned int flags); long hmm_range_fault(struct hmm_range *range, unsigned int flags);
long hmm_range_dma_map(struct hmm_range *range, long hmm_range_dma_map(struct hmm_range *range,
...@@ -401,6 +400,44 @@ long hmm_range_dma_unmap(struct hmm_range *range, ...@@ -401,6 +400,44 @@ long hmm_range_dma_unmap(struct hmm_range *range,
struct device *device, struct device *device,
dma_addr_t *daddrs, dma_addr_t *daddrs,
bool dirty); bool dirty);
#else
int hmm_mirror_register(struct hmm_mirror *mirror, struct mm_struct *mm)
{
return -EOPNOTSUPP;
}
void hmm_mirror_unregister(struct hmm_mirror *mirror)
{
}
int hmm_range_register(struct hmm_range *range, struct hmm_mirror *mirror)
{
return -EOPNOTSUPP;
}
void hmm_range_unregister(struct hmm_range *range)
{
}
static inline long hmm_range_fault(struct hmm_range *range, unsigned int flags)
{
return -EOPNOTSUPP;
}
static inline long hmm_range_dma_map(struct hmm_range *range,
struct device *device, dma_addr_t *daddrs,
unsigned int flags)
{
return -EOPNOTSUPP;
}
static inline long hmm_range_dma_unmap(struct hmm_range *range,
struct device *device,
dma_addr_t *daddrs, bool dirty)
{
return -EOPNOTSUPP;
}
#endif
/* /*
* HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range * 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, ...@@ -411,6 +448,4 @@ long hmm_range_dma_unmap(struct hmm_range *range,
*/ */
#define HMM_RANGE_DEFAULT_TIMEOUT 1000 #define HMM_RANGE_DEFAULT_TIMEOUT 1000
#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
#endif /* LINUX_HMM_H */ #endif /* LINUX_HMM_H */
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include <linux/binfmts.h> #include <linux/binfmts.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/mmu_notifier.h> #include <linux/mmu_notifier.h>
#include <linux/hmm.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/vmacache.h> #include <linux/vmacache.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment