Skip to contentSkip to conversation

mm/hmm/devmem: dummy HMM device for ZONE_DEVICE memory

PATCH New [email protected] 1 participant 1 message Sep 8, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 22/126 mm/hmm/devmem: dummy HMM device for ZONE_DEVICE memory

From: Jérôme Glisse <[email protected]>
Subject: mm/hmm/devmem: dummy HMM device for ZONE_DEVICE memory

This introduce a dummy HMM device class so device driver can use it to create hmm_device for the sole purpose of registering device memory. It is useful to device driver that want to manage multiple physical device memory under same struct device umbrella.

Cc Aneesh Kumar <[email protected]>
Cc Balbir Singh <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Dan Williams <[email protected]>
Cc David Nellans <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Ross Zwisler <[email protected]>
Cc Vladimir Davydov <[email protected]>
Cc Bob Liu <[email protected]>

---

 include/linux/hmm.h |   22 ++++++++++-
 mm/hmm.c            |   81 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 1 deletion(-)
include/linux/hmm.h renamed from include/linux/hmm.h~mm-hmm-devmem-dummy-hmm-device-for-zone_device-memory-v3 +21 -1
diff -puN include/linux/hmm.h~mm-hmm-devmem-dummy-hmm-device-for-zone_device-memory-v3 include/linux/hmm.h
@@ -72,11 +72,11 @@
 
 #if IS_ENABLED(CONFIG_HMM)
 
+#include <linux/device.h>
 #include <linux/migrate.h>
 #include <linux/memremap.h>
 #include <linux/completion.h>
 
-
 struct hmm;
 
 /*
@@ -474,6 +474,26 @@ static inline unsigned long hmm_devmem_p
 
 	return drvdata[1];
 }
+
+
+/*
+ * struct hmm_device - fake device to hang device memory onto
+ *
+ * @device: device struct
+ * @minor: device minor number
+ */
+struct hmm_device {
+	struct device		device;
+	unsigned int		minor;
+};
+
+/*
+ * A device driver that wants to handle multiple devices memory through a
+ * single fake device can use hmm_device to do so. This is purely a helper and
+ * it is not strictly needed, in order to make use of any HMM functionality.
+ */
+struct hmm_device *hmm_device_new(void *drvdata);
+void hmm_device_put(struct hmm_device *hmm_device);
 #endif /* IS_ENABLED(CONFIG_DEVICE_PRIVATE) */
 
 
mm/hmm.c renamed from mm/hmm.c~mm-hmm-devmem-dummy-hmm-device-for-zone_device-memory-v3 +81 -0

91 lines not on this page · raw message

_