Skip to contentSkip to conversation

s390x: fixing I/O memory allocation

PATCH In review Pierre Morel 1 participant 2 messages Nov 16, 2021 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s390x: fixing I/O memory allocation

The allocator allocate pages it follows the size must be rounded to pages before the allocation.

Fixes b0fe3988 "s390x: define UV compatible I/O allocation"
---
 lib/s390x/malloc_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/s390x/malloc_io.c +2 -2
index 78582eac..080fc694 100644
@@ -41,7 +41,7 @@ static void unshare_pages(void *p, int count)
 
 void *alloc_io_mem(int size, int flags)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 	void *p;
 	int n;
 
@@ -62,7 +62,7 @@ void *alloc_io_mem(int size, int flags)
 
 void free_io_mem(void *p, int size)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 
 	assert(IS_ALIGNED((uintptr_t)p, PAGE_SIZE));
 
Signature · 1 line
2.25.1
#1 lore raw

Sorry ... manipulation error

Quoted 34 lines · Pierre Morel

The allocator allocate pages it follows the size must be rounded to pages before the allocation.

Fixes b0fe3988 "s390x: define UV compatible I/O allocation"
---
  lib/s390x/malloc_io.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/s390x/malloc_io.c +2 -2
index 78582eac..080fc694 100644
@@ -41,7 +41,7 @@ static void unshare_pages(void *p, int count)
 
  void *alloc_io_mem(int size, int flags)
  {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
  	void *p;
  	int n;
 
@@ -62,7 +62,7 @@ void *alloc_io_mem(int size, int flags)
 
  void free_io_mem(void *p, int size)
  {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 
  	assert(IS_ALIGNED((uintptr_t)p, PAGE_SIZE));
 
Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen