lkml.org 
[lkml]   [2016]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[HMM v13 05/18] mm/ZONE_DEVICE/devmem_pages_remove: allow early removal of device memory
Date
HMM wants to remove device memory early before device tear down so add an
helper to do that.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
---
include/linux/memremap.h | 7 +++++++
kernel/memremap.c | 14 ++++++++++++++
2 files changed, 21 insertions(+)

diff --git a/include/linux/memremap.h b/include/linux/memremap.h
index 469c88d..b6f03e9 100644
--- a/include/linux/memremap.h
+++ b/include/linux/memremap.h
@@ -60,6 +60,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
struct percpu_ref *ref, struct vmem_altmap *altmap,
struct dev_pagemap **ppgmap, int flags);
struct dev_pagemap *find_dev_pagemap(resource_size_t phys);
+int devm_memremap_pages_remove(struct device *dev, struct dev_pagemap *pgmap);

static inline bool is_addressable_page(const struct page *page)
{
@@ -88,6 +89,12 @@ static inline struct dev_pagemap *find_dev_pagemap(resource_size_t phys)
return NULL;
}

+static inline int devm_memremap_pages_remove(struct device *dev,
+ struct dev_pagemap *pgmap)
+{
+ return -EINVAL;
+}
+
static inline bool is_addressable_page(const struct page *page)
{
return true;
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 3d28048..cf83928 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -401,6 +401,20 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
}
EXPORT_SYMBOL(devm_memremap_pages);

+static int devm_page_map_match(struct device *dev, void *data, void *match_data)
+{
+ struct page_map *page_map = data;
+
+ return &page_map->pgmap == match_data;
+}
+
+int devm_memremap_pages_remove(struct device *dev, struct dev_pagemap *pgmap)
+{
+ return devres_release(dev, &devm_memremap_pages_release,
+ &devm_page_map_match, pgmap);
+}
+EXPORT_SYMBOL(devm_memremap_pages_remove);
+
unsigned long vmem_altmap_offset(struct vmem_altmap *altmap)
{
/* number of pfns from base where pfn_to_page() is valid */
--
2.4.3
\
 
 \ /
  Last update: 2016-11-18 18:21    [W:0.262 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site