]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xen/grant-table: Refactor gnttab_init
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 31 Dec 2013 21:33:31 +0000 (16:33 -0500)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 3 Jan 2014 19:57:33 +0000 (14:57 -0500)
We have this odd scenario of where for PV paths we take a shortcut
but for the HVM paths we first ioremap xen_hvm_resume_frames, then
assign it to gnttab_shared.addr. This is needed because gnttab_map
uses gnttab_shared.addr.

Instead of having:
if (pv)
return gnttab_map
if (hvm)
...

gnttab_map

Lets move the HVM part before the gnttab_map and remove the
first call to gnttab_map.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
drivers/xen/grant-table.c

index 2d271605bf638a43504479ec29db8de903d7f44c..b023d9e8c0d32f86b31a8f59e90d6eb50cf2e629 100644 (file)
@@ -1171,22 +1171,17 @@ static int gnttab_setup(void)
        if (max_nr_gframes < nr_grant_frames)
                return -ENOSYS;
 
-       if (xen_pv_domain())
-               return gnttab_map(0, nr_grant_frames - 1);
-
-       if (gnttab_shared.addr == NULL) {
+       if (xen_feature(XENFEAT_auto_translated_physmap) && gnttab_shared.addr == NULL)
+       {
                gnttab_shared.addr = xen_remap(xen_hvm_resume_frames,
-                                               PAGE_SIZE * max_nr_gframes);
+                                              PAGE_SIZE * max_nr_gframes);
                if (gnttab_shared.addr == NULL) {
                        pr_warn("Failed to ioremap gnttab share frames (addr=0x%08lx)!\n",
                                        xen_hvm_resume_frames);
                        return -ENOMEM;
                }
        }
-
-       gnttab_map(0, nr_grant_frames - 1);
-
-       return 0;
+       return gnttab_map(0, nr_grant_frames - 1);
 }
 
 int gnttab_resume(void)