powerpc: Fix CMM page loaning on 64k page kernel with 4k hardware pages
authorBrian King <brking@linux.vnet.ibm.com>
Fri, 15 Aug 2008 19:09:33 +0000 (05:09 +1000)
committerPaul Mackerras <paulus@samba.org>
Mon, 18 Aug 2008 04:22:35 +0000 (14:22 +1000)
If the firmware page size used for collaborative memory overcommit
is 4k, but the kernel is using 64k pages, the page loaning is currently
broken as it only marks the first 4k page of each 64k page as loaned.
This fixes this to iterate through each 4k page and mark them all as
loaned/active.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/platforms/pseries/plpar_wrappers.h

index a437267c6bf86efb7443a44bfbf9ed693614371a..d967c1893ab5f1a8093f3fea1225ff240124ec12 100644 (file)
@@ -2,6 +2,7 @@
 #define _PSERIES_PLPAR_WRAPPERS_H
 
 #include <asm/hvcall.h>
+#include <asm/page.h>
 
 static inline long poll_pending(void)
 {
@@ -44,12 +45,34 @@ static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
 
 static inline long plpar_page_set_loaned(unsigned long vpa)
 {
-       return plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa, 0);
+       unsigned long cmo_page_sz = cmo_get_page_size();
+       long rc = 0;
+       int i;
+
+       for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
+               rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + i, 0);
+
+       for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
+               plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
+                                  vpa + i - cmo_page_sz, 0);
+
+       return rc;
 }
 
 static inline long plpar_page_set_active(unsigned long vpa)
 {
-       return plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa, 0);
+       unsigned long cmo_page_sz = cmo_get_page_size();
+       long rc = 0;
+       int i;
+
+       for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
+               rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + i, 0);
+
+       for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
+               plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
+                                  vpa + i - cmo_page_sz, 0);
+
+       return rc;
 }
 
 extern void vpa_init(int cpu);