]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.19
authorSasha Levin <sashal@kernel.org>
Sun, 25 Sep 2022 14:30:26 +0000 (10:30 -0400)
committerSasha Levin <sashal@kernel.org>
Sun, 25 Sep 2022 14:30:26 +0000 (10:30 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.19/drivers-hv-never-allocate-anything-besides-framebuff.patch [new file with mode: 0644]
queue-4.19/drm-amd-display-limit-user-regamma-to-a-valid-value.patch [new file with mode: 0644]
queue-4.19/drm-rockchip-fix-return-type-of-cdn_dp_connector_mod.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/drivers-hv-never-allocate-anything-besides-framebuff.patch b/queue-4.19/drivers-hv-never-allocate-anything-besides-framebuff.patch
new file mode 100644 (file)
index 0000000..6d5eef3
--- /dev/null
@@ -0,0 +1,101 @@
+From c686cba12386bdcc9ed74cd0cf8cdf8c0f64564c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 Aug 2022 15:03:45 +0200
+Subject: Drivers: hv: Never allocate anything besides framebuffer from
+ framebuffer memory region
+
+From: Vitaly Kuznetsov <vkuznets@redhat.com>
+
+[ Upstream commit f0880e2cb7e1f8039a048fdd01ce45ab77247221 ]
+
+Passed through PCI device sometimes misbehave on Gen1 VMs when Hyper-V
+DRM driver is also loaded. Looking at IOMEM assignment, we can see e.g.
+
+$ cat /proc/iomem
+...
+f8000000-fffbffff : PCI Bus 0000:00
+  f8000000-fbffffff : 0000:00:08.0
+    f8000000-f8001fff : bb8c4f33-2ba2-4808-9f7f-02f3b4da22fe
+...
+fe0000000-fffffffff : PCI Bus 0000:00
+  fe0000000-fe07fffff : bb8c4f33-2ba2-4808-9f7f-02f3b4da22fe
+    fe0000000-fe07fffff : 2ba2:00:02.0
+      fe0000000-fe07fffff : mlx4_core
+
+the interesting part is the 'f8000000' region as it is actually the
+VM's framebuffer:
+
+$ lspci -v
+...
+0000:00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA (prog-if 00 [VGA controller])
+       Flags: bus master, fast devsel, latency 0, IRQ 11
+       Memory at f8000000 (32-bit, non-prefetchable) [size=64M]
+...
+
+ hv_vmbus: registering driver hyperv_drm
+ hyperv_drm 5620e0c7-8062-4dce-aeb7-520c7ef76171: [drm] Synthvid Version major 3, minor 5
+ hyperv_drm 0000:00:08.0: vgaarb: deactivate vga console
+ hyperv_drm 0000:00:08.0: BAR 0: can't reserve [mem 0xf8000000-0xfbffffff]
+ hyperv_drm 5620e0c7-8062-4dce-aeb7-520c7ef76171: [drm] Cannot request framebuffer, boot fb still active?
+
+Note: "Cannot request framebuffer" is not a fatal error in
+hyperv_setup_gen1() as the code assumes there's some other framebuffer
+device there but we actually have some other PCI device (mlx4 in this
+case) config space there!
+
+The problem appears to be that vmbus_allocate_mmio() can use dedicated
+framebuffer region to serve any MMIO request from any device. The
+semantics one might assume of a parameter named "fb_overlap_ok"
+aren't implemented because !fb_overlap_ok essentially has no effect.
+The existing semantics are really "prefer_fb_overlap". This patch
+implements the expected and needed semantics, which is to not allocate
+from the frame buffer space when !fb_overlap_ok.
+
+Note, Gen2 VMs are usually unaffected by the issue because
+framebuffer region is already taken by EFI fb (in case kernel supports
+it) but Gen1 VMs may have this region unclaimed by the time Hyper-V PCI
+pass-through driver tries allocating MMIO space if Hyper-V DRM/FB drivers
+load after it. Devices can be brought up in any sequence so let's
+resolve the issue by always ignoring 'fb_mmio' region for non-FB
+requests, even if the region is unclaimed.
+
+Reviewed-by: Michael Kelley <mikelley@microsoft.com>
+Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
+Link: https://lore.kernel.org/r/20220827130345.1320254-4-vkuznets@redhat.com
+Signed-off-by: Wei Liu <wei.liu@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hv/vmbus_drv.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
+index fca092cfe200..9cbe0b00ebf7 100644
+--- a/drivers/hv/vmbus_drv.c
++++ b/drivers/hv/vmbus_drv.c
+@@ -1846,7 +1846,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
+                       bool fb_overlap_ok)
+ {
+       struct resource *iter, *shadow;
+-      resource_size_t range_min, range_max, start;
++      resource_size_t range_min, range_max, start, end;
+       const char *dev_n = dev_name(&device_obj->device);
+       int retval;
+@@ -1881,6 +1881,14 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
+               range_max = iter->end;
+               start = (range_min + align - 1) & ~(align - 1);
+               for (; start + size - 1 <= range_max; start += align) {
++                      end = start + size - 1;
++
++                      /* Skip the whole fb_mmio region if not fb_overlap_ok */
++                      if (!fb_overlap_ok && fb_mmio &&
++                          (((start >= fb_mmio->start) && (start <= fb_mmio->end)) ||
++                           ((end >= fb_mmio->start) && (end <= fb_mmio->end))))
++                              continue;
++
+                       shadow = __request_region(iter, start, size, NULL,
+                                                 IORESOURCE_BUSY);
+                       if (!shadow)
+-- 
+2.35.1
+
diff --git a/queue-4.19/drm-amd-display-limit-user-regamma-to-a-valid-value.patch b/queue-4.19/drm-amd-display-limit-user-regamma-to-a-valid-value.patch
new file mode 100644 (file)
index 0000000..03faf86
--- /dev/null
@@ -0,0 +1,55 @@
+From 692d5c83e8db0d714083d508a62a92648ed8c1d5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Aug 2022 18:30:31 +0800
+Subject: drm/amd/display: Limit user regamma to a valid value
+
+From: Yao Wang1 <Yao.Wang1@amd.com>
+
+[ Upstream commit 3601d620f22e37740cf73f8278eabf9f2aa19eb7 ]
+
+[Why]
+For HDR mode, we get total 512 tf_point and after switching to SDR mode
+we actually get 400 tf_point and the rest of points(401~512) still use
+dirty value from HDR mode. We should limit the rest of the points to max
+value.
+
+[How]
+Limit the value when coordinates_x.x > 1, just like what we do in
+translate_from_linear_space for other re-gamma build paths.
+
+Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
+Reviewed-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com>
+Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
+Acked-by: Pavle Kotarac <Pavle.Kotarac@amd.com>
+Signed-off-by: Yao Wang1 <Yao.Wang1@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
+index 11ea1a0e629b..4e866317ec25 100644
+--- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
++++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
+@@ -1206,6 +1206,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
+       struct fixed31_32 lut2;
+       struct fixed31_32 delta_lut;
+       struct fixed31_32 delta_index;
++      const struct fixed31_32 one = dc_fixpt_from_int(1);
+       i = 0;
+       /* fixed_pt library has problems handling too small values */
+@@ -1234,6 +1235,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
+                       } else
+                               hw_x = coordinates_x[i].x;
++                      if (dc_fixpt_le(one, hw_x))
++                              hw_x = one;
++
+                       norm_x = dc_fixpt_mul(norm_factor, hw_x);
+                       index = dc_fixpt_floor(norm_x);
+                       if (index < 0 || index > 255)
+-- 
+2.35.1
+
diff --git a/queue-4.19/drm-rockchip-fix-return-type-of-cdn_dp_connector_mod.patch b/queue-4.19/drm-rockchip-fix-return-type-of-cdn_dp_connector_mod.patch
new file mode 100644 (file)
index 0000000..1a9945a
--- /dev/null
@@ -0,0 +1,51 @@
+From a808b03a23b6d0f11bd03b133a866d9a77300713 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 13 Sep 2022 13:55:55 -0700
+Subject: drm/rockchip: Fix return type of cdn_dp_connector_mode_valid
+
+From: Nathan Huckleberry <nhuck@google.com>
+
+[ Upstream commit b0b9408f132623dc88e78adb5282f74e4b64bb57 ]
+
+The mode_valid field in drm_connector_helper_funcs is expected to be of
+type:
+enum drm_mode_status (* mode_valid) (struct drm_connector *connector,
+                                    struct drm_display_mode *mode);
+
+The mismatched return type breaks forward edge kCFI since the underlying
+function definition does not match the function hook definition.
+
+The return type of cdn_dp_connector_mode_valid should be changed from
+int to enum drm_mode_status.
+
+Reported-by: Dan Carpenter <error27@gmail.com>
+Link: https://github.com/ClangBuiltLinux/linux/issues/1703
+Cc: llvm@lists.linux.dev
+Signed-off-by: Nathan Huckleberry <nhuck@google.com>
+Reviewed-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Link: https://patchwork.freedesktop.org/patch/msgid/20220913205555.155149-1-nhuck@google.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/rockchip/cdn-dp-core.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
+index 3feab563e50a..3f992e5a75c9 100644
+--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
++++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
+@@ -284,8 +284,9 @@ static int cdn_dp_connector_get_modes(struct drm_connector *connector)
+       return ret;
+ }
+-static int cdn_dp_connector_mode_valid(struct drm_connector *connector,
+-                                     struct drm_display_mode *mode)
++static enum drm_mode_status
++cdn_dp_connector_mode_valid(struct drm_connector *connector,
++                          struct drm_display_mode *mode)
+ {
+       struct cdn_dp_device *dp = connector_to_dp(connector);
+       struct drm_display_info *display_info = &dp->connector.display_info;
+-- 
+2.35.1
+
index 43198b50e55afaf6d7d1e3aded504c47ece83cdd..2078928288775782a453ffa253c53d41298d1f59 100644 (file)
@@ -50,3 +50,6 @@ net-sunhme-fix-packet-reception-for-len-rx_copy_thre.patch
 serial-create-uart_xmit_advance.patch
 serial-tegra-use-uart_xmit_advance-fixes-icount.tx-accounting.patch
 s390-dasd-fix-oops-in-dasd_alias_get_start_dev-due-to-missing-pavgroup.patch
+drivers-hv-never-allocate-anything-besides-framebuff.patch
+drm-amd-display-limit-user-regamma-to-a-valid-value.patch
+drm-rockchip-fix-return-type-of-cdn_dp_connector_mod.patch