Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1353454 > unrolled thread

[PATCH] mm: fix 'size' alignment in devm_memremap_pages()

Started byDan Williams <dan.j.williams@intel.com>
First post2016-03-08 23:40 +0100
Last post2016-03-09 01:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm: fix 'size' alignment in devm_memremap_pages() Dan Williams <dan.j.williams@intel.com> - 2016-03-08 23:40 +0100
    Re: [PATCH] mm: fix 'size' alignment in devm_memremap_pages() Toshi Kani <toshi.kani@hpe.com> - 2016-03-09 01:30 +0100

#1353454 — [PATCH] mm: fix 'size' alignment in devm_memremap_pages()

FromDan Williams <dan.j.williams@intel.com>
Date2016-03-08 23:40 +0100
Subject[PATCH] mm: fix 'size' alignment in devm_memremap_pages()
Message-ID<raysi-7ex-21@gated-at.bofh.it>
We need to align the end address, not just the size.

Cc: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Hi Andrew, one more fixup to devm_memremap_pages().  I was discussing
patch "mm: fix mixed zone detection in devm_memremap_pages" with Toshi
and noticed that it was mishandling the end-of-range alignment.  Please
apply or fold this into the existing patch.

 kernel/memremap.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/memremap.c b/kernel/memremap.c
index c0f11a498a5a..60baf4d3401e 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -270,14 +270,16 @@ struct dev_pagemap *find_dev_pagemap(resource_size_t phys)
 void *devm_memremap_pages(struct device *dev, struct resource *res,
 		struct percpu_ref *ref, struct vmem_altmap *altmap)
 {
-	resource_size_t align_start = res->start & ~(SECTION_SIZE - 1);
-	resource_size_t align_size = ALIGN(resource_size(res), SECTION_SIZE);
-	int is_ram = region_intersects(align_start, align_size, "System RAM");
-	resource_size_t key, align_end;
+	resource_size_t key, align_start, align_size, align_end;
 	struct dev_pagemap *pgmap;
 	struct page_map *page_map;
+	int error, nid, is_ram;
 	unsigned long pfn;
-	int error, nid;
+
+	align_start = res->start & ~(SECTION_SIZE - 1);
+	align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
+		- align_start;
+	is_ram = region_intersects(align_start, align_size, "System RAM");
 
 	if (is_ram == REGION_MIXED) {
 		WARN_ONCE(1, "%s attempted on mixed region %pr\n",

[toc] | [next] | [standalone]


#1353502

FromToshi Kani <toshi.kani@hpe.com>
Date2016-03-09 01:30 +0100
Message-ID<raAaK-5R-7@gated-at.bofh.it>
In reply to#1353454
On Tue, 2016-03-08 at 14:32 -0800, Dan Williams wrote:
> We need to align the end address, not just the size.
> 
> Cc: Toshi Kani <toshi.kani@hpe.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

The change looks good.

Reviewed-by: Toshi Kani <toshi.kani@hpe.com>

Thanks,
-Toshi

> ---
> Hi Andrew, one more fixup to devm_memremap_pages().  I was discussing
> patch "mm: fix mixed zone detection in devm_memremap_pages" with Toshi
> and noticed that it was mishandling the end-of-range alignment.  Please
> apply or fold this into the existing patch.
> 
>  kernel/memremap.c |   12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/memremap.c b/kernel/memremap.c
> index c0f11a498a5a..60baf4d3401e 100644
> --- a/kernel/memremap.c
> +++ b/kernel/memremap.c
> @@ -270,14 +270,16 @@ struct dev_pagemap
> *find_dev_pagemap(resource_size_t phys)
>  void *devm_memremap_pages(struct device *dev, struct resource *res,
>  		struct percpu_ref *ref, struct vmem_altmap *altmap)
>  {
> -	resource_size_t align_start = res->start & ~(SECTION_SIZE - 1);
> -	resource_size_t align_size = ALIGN(resource_size(res),
> SECTION_SIZE);
> -	int is_ram = region_intersects(align_start, align_size, "System
> RAM");
> -	resource_size_t key, align_end;
> +	resource_size_t key, align_start, align_size, align_end;
>  	struct dev_pagemap *pgmap;
>  	struct page_map *page_map;
> +	int error, nid, is_ram;
>  	unsigned long pfn;
> -	int error, nid;
> +
> +	align_start = res->start & ~(SECTION_SIZE - 1);
> +	align_size = ALIGN(res->start + resource_size(res),
> SECTION_SIZE)
> +		- align_start;
> +	is_ram = region_intersects(align_start, align_size, "System
> RAM");
>  
>  	if (is_ram == REGION_MIXED) {
>  		WARN_ONCE(1, "%s attempted on mixed region %pr\n",
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web