Skip to content

Commit 5f1251a

Browse files
dcuiliuw
authored andcommitted
video: hyperv_fb: Fix the cache type when mapping the VRAM
x86 Hyper-V used to essentially always overwrite the effective cache type of guest memory accesses to WB. This was problematic in cases where there is a physical device assigned to the VM, since that often requires that the VM should have control over cache types. Thus, on newer Hyper-V since 2018, Hyper-V always honors the VM's cache type, but unexpectedly Linux VM users start to complain that Linux VM's VRAM becomes very slow, and it turns out that Linux VM should not map the VRAM uncacheable by ioremap(). Fix this slowness issue by using ioremap_cache(). On ARM64, ioremap_cache() is also required as the host also maps the VRAM cacheable, otherwise VM Connect can't display properly with ioremap() or ioremap_wc(). With this change, the VRAM on new Hyper-V is as fast as regular RAM, so it's no longer necessary to use the hacks we added to mitigate the slowness, i.e. we no longer need to allocate physical memory and use it to back up the VRAM in Generation-1 VM, and we also no longer need to allocate physical memory to back up the framebuffer in a Generation-2 VM and copy the framebuffer to the real VRAM. A further big change will address these for v5.11. Fixes: 68a2d20 ("drivers/video: add Hyper-V Synthetic Video Frame Buffer Driver") Tested-by: Boqun Feng <[email protected]> Signed-off-by: Dexuan Cui <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Reviewed-by: Haiyang Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 92e4dc8 commit 5f1251a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/video/fbdev/hyperv_fb.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,12 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
10921092
goto err1;
10931093
}
10941094

1095-
fb_virt = ioremap(par->mem->start, screen_fb_size);
1095+
/*
1096+
* Map the VRAM cacheable for performance. This is also required for
1097+
* VM Connect to display properly for ARM64 Linux VM, as the host also
1098+
* maps the VRAM cacheable.
1099+
*/
1100+
fb_virt = ioremap_cache(par->mem->start, screen_fb_size);
10961101
if (!fb_virt)
10971102
goto err2;
10981103

0 commit comments

Comments
 (0)