]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.19
authorSasha Levin <sashal@kernel.org>
Sun, 10 Jan 2021 13:18:38 +0000 (08:18 -0500)
committerSasha Levin <sashal@kernel.org>
Sun, 10 Jan 2021 13:18:38 +0000 (08:18 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.19/series
queue-4.19/video-hyperv_fb-fix-the-mmap-regression-for-v5.4.y-a.patch [new file with mode: 0644]

index 69e0e0114c40bd9900cb9e78530f7f30fb12900f..6e73da5c41d9dae89f20dd6c5e4ed9b67385baa1 100644 (file)
@@ -37,3 +37,4 @@ net-sysfs-take-the-rtnl-lock-when-storing-xps_rxqs.patch
 net-sysfs-take-the-rtnl-lock-when-accessing-xps_rxqs_map-and-num_tc.patch
 net-systemport-set-dev-max_mtu-to-umac_max_mtu_size.patch
 bluetooth-revert-hci_h5-close-serdev-device-and-free-hu-in-h5_close.patch
+video-hyperv_fb-fix-the-mmap-regression-for-v5.4.y-a.patch
diff --git a/queue-4.19/video-hyperv_fb-fix-the-mmap-regression-for-v5.4.y-a.patch b/queue-4.19/video-hyperv_fb-fix-the-mmap-regression-for-v5.4.y-a.patch
new file mode 100644 (file)
index 0000000..a6b8e46
--- /dev/null
@@ -0,0 +1,76 @@
+From fbefb883ba6614b1cff5b19960b4efe54276d722 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 9 Jan 2021 14:53:58 -0800
+Subject: video: hyperv_fb: Fix the mmap() regression for v5.4.y and older
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Dexuan Cui <decui@microsoft.com>
+
+db49200b1dad is backported from the mainline commit
+5f1251a48c17 ("video: hyperv_fb: Fix the cache type when mapping the VRAM"),
+to v5.4.y and older stable branches, but unluckily db49200b1dad causes
+mmap() to fail for /dev/fb0 due to EINVAL:
+
+[ 5797.049560] x86/PAT: a.out:1910 map pfn expected mapping type
+  uncached-minus for [mem 0xf8200000-0xf85cbfff], got write-back
+
+This means the v5.4.y kernel detects an incompatibility issue about the
+mapping type of the VRAM: db49200b1dad changes to use Write-Back when
+mapping the VRAM, while the mmap() syscall tries to use Uncached-minus.
+That’s to say, the kernel thinks Uncached-minus is incompatible with
+Write-Back: see drivers/video/fbdev/core/fbmem.c: fb_mmap() ->
+vm_iomap_memory() -> io_remap_pfn_range() -> ... -> track_pfn_remap() ->
+reserve_pfn_range().
+
+Note: any v5.5 and newer kernel doesn't have the issue, because they
+have commit
+d21987d709e8 ("video: hyperv: hyperv_fb: Support deferred IO for Hyper-V frame buffer driver")
+, and when the hyperv_fb driver has the deferred_io support,
+fb_deferred_io_init() overrides info->fbops->fb_mmap with
+fb_deferred_io_mmap(), which doesn’t check the mapping type
+incompatibility. Note: since it's VRAM here, the checking is not really
+necessary.
+
+Fix the regression by ioremap_wc(), which uses Write-combining. The kernel
+thinks it's compatible with Uncached-minus. The VRAM mappped by
+ioremap_wc() is slightly slower than mapped by ioremap_cache(), but is
+still significantly faster than by ioremap().
+
+Change the comment accordingly. Linux VM on ARM64 Hyper-V is still not
+working in the latest mainline yet, and when it works in future, the ARM64
+support is unlikely to be backported to v5.4 and older, so using
+ioremap_wc() in v5.4 and older should be ok.
+
+Note: this fix is only targeted at the stable branches:
+v5.4.y, v4.19.y, v4.14.y, v4.9.y and v4.4.y.
+
+Fixes: db49200b1dad ("video: hyperv_fb: Fix the cache type when mapping the VRAM")
+Signed-off-by: Dexuan Cui <decui@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/video/fbdev/hyperv_fb.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
+index 56e70f12c9960..c907f96d6890c 100644
+--- a/drivers/video/fbdev/hyperv_fb.c
++++ b/drivers/video/fbdev/hyperv_fb.c
+@@ -713,11 +713,9 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
+       }
+       /*
+-       * Map the VRAM cacheable for performance. This is also required for
+-       * VM Connect to display properly for ARM64 Linux VM, as the host also
+-       * maps the VRAM cacheable.
++       * Map the VRAM cacheable for performance.
+        */
+-      fb_virt = ioremap_cache(par->mem->start, screen_fb_size);
++      fb_virt = ioremap_wc(par->mem->start, screen_fb_size);
+       if (!fb_virt)
+               goto err2;
+-- 
+2.27.0
+