[PATCH v4] Fix divide-by-zero regression on DP MST unplug with nouveau

2024-03-16 Thread Chris Bainbridge
ore drm nvme nvme_core mxm_wmi 
xhci_pci xhci_pci_renesas video wmi pinctrl_cannonlake mac_hid
 ---[ end trace  ]---

Fix this by avoiding the divide if bpp is 0.

Fixes: c1d6a22b7219 ("drm/dp: Add helpers to calculate the link BW overhead")
Cc: sta...@vger.kernel.org
Acked-by: Imre Deak 
Signed-off-by: Chris Bainbridge 
---
 drivers/gpu/drm/display/drm_dp_helper.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/display/drm_dp_helper.c 
b/drivers/gpu/drm/display/drm_dp_helper.c
index b1ca3a1100da..26c188ce5f1c 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -3982,6 +3982,13 @@ int drm_dp_bw_overhead(int lane_count, int hactive,
u32 overhead = 100;
int symbol_cycles;
 
+   if (lane_count == 0 || hactive == 0 || bpp_x16 == 0) {
+   DRM_DEBUG_KMS("Invalid BW overhead params: lane_count %d, 
hactive %d, bpp_x16 %d.%04d\n",
+ lane_count, hactive,
+ bpp_x16 >> 4, (bpp_x16 & 0xf) * 625);
+   return 0;
+   }
+
/*
 * DP Standard v2.1 2.6.4.1
 * SSC downspread and ref clock variation margin:
-- 
2.39.2



[PATCH v3] Fix divide-by-zero regression on DP MST unplug with nouveau

2024-03-13 Thread Chris Bainbridge
ore drm nvme nvme_core mxm_wmi 
xhci_pci xhci_pci_renesas video wmi pinctrl_cannonlake mac_hid
 ---[ end trace  ]---

Fix this by avoiding the divide if bpp is 0.

Fixes: c1d6a22b7219 ("drm/dp: Add helpers to calculate the link BW overhead")
Cc: sta...@vger.kernel.org
Acked-by: Imre Deak 
Signed-off-by: Chris Bainbridge 
---
 drivers/gpu/drm/display/drm_dp_helper.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/display/drm_dp_helper.c 
b/drivers/gpu/drm/display/drm_dp_helper.c
index b1ca3a1100da..d51c1bcee258 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -3982,6 +3982,12 @@ int drm_dp_bw_overhead(int lane_count, int hactive,
u32 overhead = 100;
int symbol_cycles;
 
+   if (lane_count == 0 || hactive == 0 || bpp_x16 == 0) {
+   DRM_DEBUG_KMS("Invalid BW overhead params: lane_count %d, 
hactive %d, bpp_x16 %.04d\n",
+ lane_count, hactive, bpp_x16);
+   return 0;
+   }
+
/*
 * DP Standard v2.1 2.6.4.1
 * SSC downspread and ref clock variation margin:
-- 
2.39.2



[PATCH v2] Fix divide-by-zero regression on DP MST unplug with nouveau

2024-03-11 Thread Chris Bainbridge
ore drm nvme nvme_core mxm_wmi 
xhci_pci xhci_pci_renesas video wmi pinctrl_cannonlake mac_hid
 ---[ end trace  ]---

Fix this by avoiding the divide if bpp is 0.

Fixes: c1d6a22b7219 ("drm/dp: Add helpers to calculate the link BW overhead")
Signed-off-by: Chris Bainbridge 
Acked-by: Imre Deak 
---
 drivers/gpu/drm/display/drm_dp_helper.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/display/drm_dp_helper.c 
b/drivers/gpu/drm/display/drm_dp_helper.c
index b1ca3a1100da..9f0e7142f174 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -3982,6 +3982,13 @@ int drm_dp_bw_overhead(int lane_count, int hactive,
u32 overhead = 100;
int symbol_cycles;
 
+   if (bpp_x16 == 0) {
+   DRM_DEBUG("drm_dp_bw_overhead called with bpp 0\n");
+   }
+   if (lane_count == 0 || hactive == 0 || bpp_x16 == 0) {
+   return 0;
+   }
+
/*
 * DP Standard v2.1 2.6.4.1
 * SSC downspread and ref clock variation margin:
-- 
2.39.2



Re: [Intel-gfx] [v4.6-10530-g28165ec7a99b] i915: *ERROR* "CPU pipe/PCH transcoder" A FIFO underrun

2016-05-27 Thread Chris Bainbridge
On 25 May 2016 at 08:31, Sedat Dilek  wrote:
> Hi Daniel,
>
> with latest Linus Git I see this with my Intel SandyBridge GPU...
>
> [   17.629014] [drm:intel_cpu_fifo_underrun_irq_handler [i915]]
> *ERROR* CPU pipe A FIFO underrun
> [   17.630652] [drm:intel_set_pch_fifo_underrun_reporting [i915]]
> *ERROR* uncleared pch fifo underrun on pch transcoder A
> [   17.630685] [drm:intel_pch_fifo_underrun_irq_handler [i915]]
> *ERROR* PCH transcoder A FIFO underrun

Guessing this is https://bugs.freedesktop.org/show_bug.cgi?id=95736
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] i915 corrupting memory on shutdown since 4.4?

2016-02-04 Thread Chris Bainbridge
I eventually traced the filesystem corruption to a bug in the Apple
firmware which can cause memory corruption after Linux is booted:
https://bugzilla.kernel.org/show_bug.cgi?id=111781

On 29 January 2016 at 12:37, Chris Wilson  wrote:
> The timer error is definitely interesting

The timer error bisected to a recent ACPI change. It causes visual
glitches in Firefox. https://lkml.org/lkml/2016/2/3/273
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] i915 corrupting memory on shutdown since 4.4?

2016-01-28 Thread Chris Bainbridge
Hi,

I'm using 4.5-rc1 and before that 4.4. Twice in the past month I've
rebooted and the root btrfs partition has become corrupted and
unbootable. I was wondering if the cause could be i915 and if so is
there any better way to track it down?

In test 200 reboots gave only 3 errors, but the third error did corrupt
the btrfs partition and it became unbootable. But I still don't have a
reliable way to automatically reproduce this. I'm not sure, but it may
be related to use of Chrome or Iceweasel (Debian Firefox) with many open
tabs. The type of display does not seem to matter - this testing was
with external displays, but the fs corruption previously happened with
laptop display only.

While searching I came across some links which sound similar:
http://lists.freedesktop.org/archives/intel-gfx/2014-June/046476.html 
(i915_gem_shrink oom)
http://codemonkey.org.uk/tag/i915 (i915/hibernate memory corruption)

Relevant log extracts (from beginning of problems) follow. The reason I
suspect i915 is that in two of the cases the first trace included
i915_gem_shrinker_oom, and after turning on debugging I got odebug
warnings about a timer error between underrun errors from the gpu code.


Log 1
-

Note the fifo underrun errors that appear at the start of the errors
were previously reported as
https://bugs.freedesktop.org/show_bug.cgi?id=93802 - they could be
relevant, but these errors did not appear in 4.4 when the first
filesystem crash occurred, so perhaps not relevant.

[   40.320560] [drm:intel_set_cpu_fifo_underrun_reporting] *ERROR* uncleared 
fifo underrun on pipe A
[   40.320568] [drm:intel_cpu_fifo_underrun_irq_handler] *ERROR* CPU pipe A 
FIFO underrun
[   40.320580] [drm:intel_set_pch_fifo_underrun_reporting] *ERROR* uncleared 
pch fifo underrun on pch transcoder A
[   40.320584] [drm:intel_pch_fifo_underrun_irq_handler] *ERROR* PCH transcoder 
A FIFO underrun
[   40.436126] [drm:intel_check_cpu_fifo_underruns] *ERROR* fifo underrun on 
pipe B
[   40.436129] [drm:intel_check_cpu_fifo_underruns] *ERROR* fifo underrun on 
pipe C
[   40.436137] [drm:intel_check_pch_fifo_underruns] *ERROR* pch fifo underrun 
on pch transcoder B
[   40.436142] [drm:intel_check_pch_fifo_underruns] *ERROR* pch fifo underrun 
on pch transcoder C
[   40.450241] [drm:intel_check_cpu_fifo_underruns] *ERROR* fifo underrun on 
pipe B
[   40.450244] [drm:intel_check_cpu_fifo_underruns] *ERROR* fifo underrun on 
pipe C
[   40.450252] [drm:intel_check_pch_fifo_underruns] *ERROR* pch fifo underrun 
on pch transcoder B
[   40.450257] [drm:intel_check_pch_fifo_underruns] *ERROR* pch fifo underrun 
on pch transcoder C
[   40.461442] [drm:intel_check_cpu_fifo_underruns] *ERROR* fifo underrun on 
pipe C
[   40.461448] [drm:intel_check_pch_fifo_underruns] *ERROR* pch fifo underrun 
on pch transcoder C
[   41.097074] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[   41.104637] systemd-journald[2272]: Received SIGTERM from PID 1 
(systemd-shutdow).
[   51.105768] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[   51.112110] systemd-shutdown[1]: Sending SIGKILL to PID 4060 (ps).
[   51.114556] BUG: Bad page map in process ps  pte:535f535025 pmd:85220067
[   51.117035] addr:7f54b0b15000 vm_flags:0075 anon_vma:  
(null) mapping:880254e596d0 index:3a
[   51.122201] file:libc-2.19.so fault:filemap_fault mmap:btrfs_file_mmap 
readpage:btrfs_readpage
[   51.125038] CPU: 1 PID: 4060 Comm: ps Not tainted 4.5.0-rc1 #273
[   51.127896] Hardware name: Apple Inc. MacBookPro10,2/Mac-AFD8A9D944EA4843, 
BIOS MBP102.88Z.0106.B0A.1509130955 09/13/2015
[   51.134056]  81661cc0 88024acc79e8 8181d866 
0001
[   51.137420]  880087fba730 88024acc7a38 812f88e2 
ea00020f7340
[   51.140837]  0008  0535f535 
880087fba730
[   51.144355] Call Trace:
[   51.147713]  [] ? inode_tree_add+0x3b0/0x3b0
[   51.151115]  [] dump_stack+0x45/0x5f
[   51.154498]  [] print_bad_pte+0x1d2/0x2f0
[   51.157898]  [] vm_normal_page+0x6b/0xc0
[   51.161314]  [] unmap_single_vma+0x52d/0xfd0
[   51.164790]  [] unmap_vmas+0x4c/0xc0
[   51.168287]  [] exit_mmap+0x8a/0x180
[   51.171829]  [] mmput+0x36/0x180
[   51.175359]  [] do_exit+0x2d5/0xad0
[   51.17]  [] do_group_exit+0x52/0x160
[   51.182410]  [] get_signal+0x359/0xc80
[   51.185942]  [] ? set_next_entity+0xd2/0xe10
[   51.189470]  [] do_signal+0x23/0xd20
[   51.192958]  [] ? handle_mm_fault+0x28f/0x20e0
[   51.196443]  [] ? __set_current_blocked+0x3a/0x80
[   51.199912]  [] exit_to_usermode_loop+0x81/0xf0
[   51.203375]  [] prepare_exit_to_usermode+0x2a/0x40
[   51.206789]  [] retint_user+0x8/0x10
[   51.210134] Disabling lock debugging due to kernel taint
[   51.213456] swap_free: Bad swap file entry 472eff20380
[   51.216828] BUG: Bad page map in process ps  pte:e5dfe4070004 
pmd:85220067
... "swap_free: Bad" and "BUG: Bad page map" errors repeat a few times
[   52.545819] BUG: Bad 

[Intel-gfx] [PATCH] drm/i915: disable non-sequential pfits on ivb/hsw

2016-01-13 Thread Chris Bainbridge
The existing code assumes a sequential mapping of panel fitters to pipes
(pfit0-pipeA, pfit1-pipeB, pfit2-pipeC), but boot firmware can
arbitrarily assign any pipe to a pfit on IVB hardware e.g. Macbook UEFI
uses pfit 0 and pipe C for eDP1 when the firmware boots in a non-16:10
resolution (the last-used resolution is stored in NVRAM by OS X so the
firmware can immediately restore it at boot). When this happens, the
display will appear letterboxed due to incorrect aspect ratio and
attempting to switch to alternative resolutions will fail. Fix this by
disabling any panel fitters which have been non-sequentially assigned at
boot time.

Link: https://bugs.freedesktop.org/show_bug.cgi?id=93523
Signed-off-by: Chris Bainbridge <chris.bainbri...@gmail.com>
---
 drivers/gpu/drm/i915/intel_display.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 32cf97346978..9e588139a2dd 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9170,6 +9170,24 @@ static void ironlake_get_pfit_config(struct intel_crtc 
*crtc,
struct drm_device *dev = crtc->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
uint32_t tmp;
+   int pipe;
+
+   /*
+* PF_CTL assumes panel fitter 0 is on pipe A, panel fitter 1 is on
+* pipe B, and panel fitter 2 is on pipe C, but firmware can init IVB
+* panel fitters to any arbitrary pipe (Macbook UEFI uses pfit 0 for
+* pipe C), so find and disable any other mappings.
+*/
+   for (pipe = 0; pipe < INTEL_INFO(dev)->num_pipes; pipe++) {
+   tmp = I915_READ(PF_CTL(pipe));
+   if (IS_GEN7(dev) && (tmp & PF_ENABLE) &&
+   PF_PIPE_SEL_IVB(pipe) != (tmp & PF_PIPE_SEL_MASK_IVB)) {
+   DRM_DEBUG_KMS("disabling initial panel fitter\n");
+   I915_WRITE(PF_CTL(pipe), 0);
+   I915_WRITE(PF_WIN_POS(pipe), 0);
+   I915_WRITE(PF_WIN_SZ(pipe), 0);
+   }
+   }
 
tmp = I915_READ(PF_CTL(crtc->pipe));
 
@@ -9177,14 +9195,6 @@ static void ironlake_get_pfit_config(struct intel_crtc 
*crtc,
pipe_config->pch_pfit.enabled = true;
pipe_config->pch_pfit.pos = I915_READ(PF_WIN_POS(crtc->pipe));
pipe_config->pch_pfit.size = I915_READ(PF_WIN_SZ(crtc->pipe));
-
-   /* We currently do not free assignements of panel fitters on
-* ivb/hsw (since we don't use the higher upscaling modes which
-* differentiates them) so just WARN about this case for now. */
-   if (IS_GEN7(dev)) {
-   WARN_ON((tmp & PF_PIPE_SEL_MASK_IVB) !=
-   PF_PIPE_SEL_IVB(crtc->pipe));
-   }
}
 }
 
-- 
2.1.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx