Skip to content

Commit

Permalink
xen/grant-table: Refactor gnttab_init
Browse files Browse the repository at this point in the history
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>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
  • Loading branch information
Konrad Rzeszutek Wilk committed Jan 6, 2014
1 parent 7f25602 commit 4568475
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/xen/grant-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,7 @@ 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);
if (gnttab_shared.addr == NULL) {
Expand All @@ -1185,10 +1182,7 @@ static int gnttab_setup(void)
return -ENOMEM;
}
}

gnttab_map(0, nr_grant_frames - 1);

return 0;
return gnttab_map(0, nr_grant_frames - 1);
}

int gnttab_resume(void)
Expand Down

0 comments on commit 4568475

Please sign in to comment.