drm/msm/dpu: Increment vsync_cnt before waking up userspace
Subsystems (2)
PATCH 1/1 drm/msm/dpu: Increment vsync_cnt before waking up userspace
The 'vsync_cnt' is used to count the number of frames for a crtc. Unfortunately, we increment the count after waking up userspace via dpu_crtc_vblank_callback() calling drm_crtc_handle_vblank(). drm_crtc_handle_vblank() wakes up userspace processes that have called drm_wait_vblank_ioctl(), and if that ioctl is expecting the count to increase it won't.
Increment the count before calling into the drm APIs so that we don't have to worry about ordering the increment with anything else in drm. This fixes a software video decode test that fails to see frame counts increase on Trogdor boards.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -1
@@ -1251,12 +1251,13 @@ static void dpu_encoder_vblank_callback(struct drm_encoder *drm_enc,DPU_ATRACE_BEGIN ("encoder_vblank_callback" ); dpu_enc =to_dpu_encoder_virt (drm_enc); +atomic_inc (&phy_enc->vsync_cnt); +spin_lock_irqsave (&dpu_enc->enc_spinlock, lock_flags);if (dpu_enc->crtc)dpu_crtc_vblank_callback (dpu_enc->crtc);spin_unlock_irqrestore (&dpu_enc->enc_spinlock, lock_flags); -atomic_inc (&phy_enc->vsync_cnt);DPU_ATRACE_END ("encoder_vblank_callback" ); }
base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
Signature · 1 line
https://chromeos.dev
Quoted 12 lines · Stephen Boyd
The '
vsync_cnt' is used to count the number of frames for a crtc. Unfortunately, we increment the count after waking up userspace viadpu_crtc_vblank_callback()callingdrm_crtc_handle_vblank().drm_crtc_handle_vblank()wakes up userspace processes that have calleddrm_wait_vblank_ioctl(), and if that ioctl is expecting the count to increase it won't.Increment the count before calling into the drm APIs so that we don't have to worry about ordering the increment with anything else in drm. This fixes a software video decode test that fails to see frame counts increase on Trogdor boards.
Quoted 4 lines
Cc Mark Yacoub <[email protected]>Cc Jessica Zhang <[email protected]>Fixes 885455d6bf82 ("drm/msm: Change dpu_crtc_get_vblank_counter to use vsync count.")Signed-off-by Stephen Boyd <[email protected]>
This is right, we should increment before drm_crtc_handle_vblank() as that will query the vblank counter. This also matches what we do downstream, hence
One small nit though, shouldnt the fixes tag be
25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
This code has been this way since that commit itself.
Quoted 25 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2
-1@@ -1251,12 +1251,13 @@ static void dpu_encoder_vblank_callback(struct drm_encoder *drm_enc,DPU_ATRACE_BEGIN ("encoder_vblank_callback" ); dpu_enc =to_dpu_encoder_virt (drm_enc); +atomic_inc (&phy_enc->vsync_cnt); +spin_lock_irqsave (&dpu_enc->enc_spinlock, lock_flags);if (dpu_enc->crtc)dpu_crtc_vblank_callback (dpu_enc->crtc);spin_unlock_irqrestore (&dpu_enc->enc_spinlock, lock_flags); -atomic_inc (&phy_enc->vsync_cnt);DPU_ATRACE_END ("encoder_vblank_callback" ); }base-commit:
f2906aa863381afb0015a9eb7fefad885d4e5a56
Quoted 25 lines · Abhinav Kumar
Quoted 12 lines · Stephen Boyd
The '
vsync_cnt' is used to count the number of frames for a crtc. Unfortunately, we increment the count after waking up userspace viadpu_crtc_vblank_callback()callingdrm_crtc_handle_vblank().drm_crtc_handle_vblank()wakes up userspace processes that have calleddrm_wait_vblank_ioctl(), and if that ioctl is expecting the count to increase it won't.Increment the count before calling into the drm APIs so that we don't have to worry about ordering the increment with anything else in drm. This fixes a software video decode test that fails to see frame counts increase on Trogdor boards.
Quoted 4 lines
Cc Mark Yacoub <[email protected]>Cc Jessica Zhang <[email protected]>Fixes 885455d6bf82 ("drm/msm: Change dpu_crtc_get_vblank_counter to use vsync count.")Signed-off-by Stephen Boyd <[email protected]>This is right, we should increment before
drm_crtc_handle_vblank()as that will query the vblank counter. This also matches what we do downstream, hence
Quoted 5 lines
Reviewed-by Abhinav Kumar <[email protected]>One small nit though, shouldnt the fixes tag be
25fdd5933e4c("drm/msm: Add SDM845 DPU support")
*Kinda*.. but the sw vblank counter wasn't used for reporting frame nr to userspace until 885455d6bf82. You could possibly list both, perhaps, but 885455d6bf82 is the important one for folks backporting to stable kernels to be aware of
BR,
-R
Quoted 28 lines
This code has been this way since that commit itself.
Quoted 25 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2
-1@@ -1251,12 +1251,13 @@ static void dpu_encoder_vblank_callback(struct drm_encoder *drm_enc,DPU_ATRACE_BEGIN ("encoder_vblank_callback" ); dpu_enc =to_dpu_encoder_virt (drm_enc); +atomic_inc (&phy_enc->vsync_cnt); +spin_lock_irqsave (&dpu_enc->enc_spinlock, lock_flags);if (dpu_enc->crtc)dpu_crtc_vblank_callback (dpu_enc->crtc);spin_unlock_irqrestore (&dpu_enc->enc_spinlock, lock_flags); -atomic_inc (&phy_enc->vsync_cnt);DPU_ATRACE_END ("encoder_vblank_callback" ); }base-commit:
f2906aa863381afb0015a9eb7fefad885d4e5a56
Dmitry Baryshkov
Reviewed-byQuoted 29 lines · Rob Clark
Quoted 27 lines · Abhinav Kumar
Quoted 12 lines · Stephen Boyd
The '
vsync_cnt' is used to count the number of frames for a crtc. Unfortunately, we increment the count after waking up userspace viadpu_crtc_vblank_callback()callingdrm_crtc_handle_vblank().drm_crtc_handle_vblank()wakes up userspace processes that have calleddrm_wait_vblank_ioctl(), and if that ioctl is expecting the count to increase it won't.Increment the count before calling into the drm APIs so that we don't have to worry about ordering the increment with anything else in drm. This fixes a software video decode test that fails to see frame counts increase on Trogdor boards.
Quoted 4 lines
Cc Mark Yacoub <[email protected]>Cc Jessica Zhang <[email protected]>Fixes 885455d6bf82 ("drm/msm: Change dpu_crtc_get_vblank_counter to use vsync count.")Signed-off-by Stephen Boyd <[email protected]>This is right, we should increment before
drm_crtc_handle_vblank()as that will query the vblank counter. This also matches what we do downstream, henceReviewed-by Abhinav Kumar <[email protected]>
Quoted 8 lines
Quoted 3 lines
One small nit though, shouldnt the fixes tag be
25fdd5933e4c("drm/msm: Add SDM845 DPU support")*Kinda*.. but the sw vblank counter wasn't used for reporting frame nr to userspace until
885455d6bf82. You could possibly list both, perhaps, but885455d6bf82is the important one for folks backporting to stable kernels to be aware of
I'd agree, the original Fixes tag seems good to me.
Signature · 2 lines
With best wishes Dmitry
Quoted 12 lines · Stephen Boyd
The '
vsync_cnt' is used to count the number of frames for a crtc. Unfortunately, we increment the count after waking up userspace viadpu_crtc_vblank_callback()callingdrm_crtc_handle_vblank().drm_crtc_handle_vblank()wakes up userspace processes that have calleddrm_wait_vblank_ioctl(), and if that ioctl is expecting the count to increase it won't.Increment the count before calling into the drm APIs so that we don't have to worry about ordering the increment with anything else in drm. This fixes a software video decode test that fails to see frame counts increase on Trogdor boards.
Quoted 4 lines
Cc Mark Yacoub <[email protected]>Cc Jessica Zhang <[email protected]>Fixes 885455d6bf82 ("drm/msm: Change dpu_crtc_get_vblank_counter to use vsync count.")Signed-off-by Stephen Boyd <[email protected]>
Quoted 28 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2
-1@@ -1251,12 +1251,13 @@ static void dpu_encoder_vblank_callback(struct drm_encoder *drm_enc,DPU_ATRACE_BEGIN ("encoder_vblank_callback" ); dpu_enc =to_dpu_encoder_virt (drm_enc); +atomic_inc (&phy_enc->vsync_cnt); +spin_lock_irqsave (&dpu_enc->enc_spinlock, lock_flags);if (dpu_enc->crtc)dpu_crtc_vblank_callback (dpu_enc->crtc);spin_unlock_irqrestore (&dpu_enc->enc_spinlock, lock_flags); -atomic_inc (&phy_enc->vsync_cnt);DPU_ATRACE_END ("encoder_vblank_callback" ); }base-commit:
f2906aa863381afb0015a9eb7fefad885d4e5a56Signature · 1 line
https://chromeos.dev