From f521752f43194429ddbba47a0cfb69e5b423ff59 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 21 Jul 2023 09:21:15 +0200 Subject: [PATCH] 5.4-stable patches added patches: drm-atomic-allow-vblank-enabled-self-refresh-disable.patch drm-rockchip-vop-leave-vblank-enabled-in-self-refresh.patch --- ...-vblank-enabled-self-refresh-disable.patch | 83 ++++++++++++++++ ...leave-vblank-enabled-in-self-refresh.patch | 94 +++++++++++++++++++ queue-5.4/series | 2 + 3 files changed, 179 insertions(+) create mode 100644 queue-5.4/drm-atomic-allow-vblank-enabled-self-refresh-disable.patch create mode 100644 queue-5.4/drm-rockchip-vop-leave-vblank-enabled-in-self-refresh.patch diff --git a/queue-5.4/drm-atomic-allow-vblank-enabled-self-refresh-disable.patch b/queue-5.4/drm-atomic-allow-vblank-enabled-self-refresh-disable.patch new file mode 100644 index 00000000000..6735c1b4049 --- /dev/null +++ b/queue-5.4/drm-atomic-allow-vblank-enabled-self-refresh-disable.patch @@ -0,0 +1,83 @@ +From 9d0e3cac3517942a6e00eeecfe583a98715edb16 Mon Sep 17 00:00:00 2001 +From: Brian Norris +Date: Mon, 9 Jan 2023 17:18:16 -0800 +Subject: drm/atomic: Allow vblank-enabled + self-refresh "disable" + +From: Brian Norris + +commit 9d0e3cac3517942a6e00eeecfe583a98715edb16 upstream. + +The self-refresh helper framework overloads "disable" to sometimes mean +"go into self-refresh mode," and this mode activates automatically +(e.g., after some period of unchanging display output). In such cases, +the display pipe is still considered "on", and user-space is not aware +that we went into self-refresh mode. Thus, users may expect that +vblank-related features (such as DRM_IOCTL_WAIT_VBLANK) still work +properly. + +However, we trigger the WARN_ONCE() here if a CRTC driver tries to leave +vblank enabled. + +Add a different expectation: that CRTCs *should* leave vblank enabled +when going into self-refresh. + +This patch is preparation for another patch -- "drm/rockchip: vop: Leave +vblank enabled in self-refresh" -- which resolves conflicts between the +above self-refresh behavior and the API tests in IGT's kms_vblank test +module. + +== Some alternatives discussed: == + +It's likely that on many display controllers, vblank interrupts will +turn off when the CRTC is disabled, and so in some cases, self-refresh +may not support vblank. To support such cases, we might consider +additions to the generic helpers such that we fire vblank events based +on a timer. + +However, there is currently only one driver using the common +self-refresh helpers (i.e., rockchip), and at least as of commit +bed030a49f3e ("drm/rockchip: Don't fully disable vop on self refresh"), +the CRTC hardware is powered enough to continue to generate vblank +interrupts. + +So we chose the simpler option of leaving vblank interrupts enabled. We +can reevaluate this decision and perhaps augment the helpers if/when we +gain a second driver that has different requirements. + +v3: + * include discussion summary + +v2: + * add 'ret != 0' warning case for self-refresh + * describe failing test case and relation to drm/rockchip patch better + +Cc: # dependency for "drm/rockchip: vop: Leave + # vblank enabled in self-refresh" +Signed-off-by: Brian Norris +Signed-off-by: Sean Paul +Link: https://patchwork.freedesktop.org/patch/msgid/20230109171809.v3.1.I3904f697863649eb1be540ecca147a66e42bfad7@changeid +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/drm_atomic_helper.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/drm_atomic_helper.c ++++ b/drivers/gpu/drm/drm_atomic_helper.c +@@ -1086,7 +1086,16 @@ disable_outputs(struct drm_device *dev, + continue; + + ret = drm_crtc_vblank_get(crtc); +- WARN_ONCE(ret != -EINVAL, "driver forgot to call drm_crtc_vblank_off()\n"); ++ /* ++ * Self-refresh is not a true "disable"; ensure vblank remains ++ * enabled. ++ */ ++ if (new_crtc_state->self_refresh_active) ++ WARN_ONCE(ret != 0, ++ "driver disabled vblank in self-refresh\n"); ++ else ++ WARN_ONCE(ret != -EINVAL, ++ "driver forgot to call drm_crtc_vblank_off()\n"); + if (ret == 0) + drm_crtc_vblank_put(crtc); + } diff --git a/queue-5.4/drm-rockchip-vop-leave-vblank-enabled-in-self-refresh.patch b/queue-5.4/drm-rockchip-vop-leave-vblank-enabled-in-self-refresh.patch new file mode 100644 index 00000000000..d2887b99c39 --- /dev/null +++ b/queue-5.4/drm-rockchip-vop-leave-vblank-enabled-in-self-refresh.patch @@ -0,0 +1,94 @@ +From 2bdba9d4a3baa758c2ca7f5b37b35c7b3391dc42 Mon Sep 17 00:00:00 2001 +From: Brian Norris +Date: Mon, 9 Jan 2023 17:18:17 -0800 +Subject: drm/rockchip: vop: Leave vblank enabled in self-refresh + +From: Brian Norris + +commit 2bdba9d4a3baa758c2ca7f5b37b35c7b3391dc42 upstream. + +If we disable vblank when entering self-refresh, vblank APIs (like +DRM_IOCTL_WAIT_VBLANK) no longer work. But user space is not aware when +we enter self-refresh, so this appears to be an API violation -- that +DRM_IOCTL_WAIT_VBLANK fails with EINVAL whenever the display is idle and +enters self-refresh. + +The downstream driver used by many of these systems never used to +disable vblank for PSR, and in fact, even upstream, we didn't do that +until radically redesigning the state machine in commit 6c836d965bad +("drm/rockchip: Use the helpers for PSR"). + +Thus, it seems like a reasonable API fix to simply restore that +behavior, and leave vblank enabled. + +Note that this appears to potentially unbalance the +drm_crtc_vblank_{off,on}() calls in some cases, but: +(a) drm_crtc_vblank_on() documents this as OK and +(b) if I do the naive balancing, I find state machine issues such that + we're not in sync properly; so it's easier to take advantage of (a). + +This issue was exposed by IGT's kms_vblank tests, and reported by +KernelCI. The bug has been around a while (longer than KernelCI +noticed), but was only exposed once self-refresh was bugfixed more +recently, and so KernelCI could properly test it. Some other notes in: + + https://lore.kernel.org/dri-devel/Y6OCg9BPnJvimQLT@google.com/ + Re: renesas/master bisection: igt-kms-rockchip.kms_vblank.pipe-A-wait-forked on rk3399-gru-kevin + +== Backporting notes: == + +Marking as 'Fixes' commit 6c836d965bad ("drm/rockchip: Use the helpers +for PSR"), but it probably depends on commit bed030a49f3e +("drm/rockchip: Don't fully disable vop on self refresh") as well. + +We also need the previous patch ("drm/atomic: Allow vblank-enabled + +self-refresh "disable""), of course. + +v3: + * no update + +v2: + * skip unnecessary lock/unlock + +Fixes: 6c836d965bad ("drm/rockchip: Use the helpers for PSR") +Cc: +Reported-by: "kernelci.org bot" +Link: https://lore.kernel.org/dri-devel/Y5itf0+yNIQa6fU4@sirena.org.uk/ +Signed-off-by: Brian Norris +Signed-off-by: Sean Paul +Link: https://patchwork.freedesktop.org/patch/msgid/20230109171809.v3.2.Ic07cba4ab9a7bd3618a9e4258b8f92ea7d10ae5a@changeid +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c ++++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +@@ -654,13 +654,13 @@ static void vop_crtc_atomic_disable(stru + if (crtc->state->self_refresh_active) + rockchip_drm_set_win_enabled(crtc, false); + ++ if (crtc->state->self_refresh_active) ++ goto out; ++ + mutex_lock(&vop->vop_lock); + + drm_crtc_vblank_off(crtc); + +- if (crtc->state->self_refresh_active) +- goto out; +- + /* + * Vop standby will take effect at end of current frame, + * if dsp hold valid irq happen, it means standby complete. +@@ -692,9 +692,9 @@ static void vop_crtc_atomic_disable(stru + vop_core_clks_disable(vop); + pm_runtime_put(vop->dev); + +-out: + mutex_unlock(&vop->vop_lock); + ++out: + if (crtc->state->event && !crtc->state->active) { + spin_lock_irq(&crtc->dev->event_lock); + drm_crtc_send_vblank_event(crtc, crtc->state->event); diff --git a/queue-5.4/series b/queue-5.4/series index 51cd56285dc..0e49d42b517 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -254,3 +254,5 @@ misc-pci_endpoint_test-free-irqs-before-removing-the-device.patch misc-pci_endpoint_test-re-init-completion-for-every-test.patch md-raid0-add-discard-support-for-the-original-layout.patch fs-dlm-return-positive-pid-value-for-f_getlk.patch +drm-atomic-allow-vblank-enabled-self-refresh-disable.patch +drm-rockchip-vop-leave-vblank-enabled-in-self-refresh.patch -- 2.47.3