Skip to content

Commit d72a3d3

Browse files
committed
drm/msm/dpu: split dpu_encoder_wait_for_event into two functions
Stop multiplexing several events via the dpu_encoder_wait_for_event() function. Split it into two distinct functions two allow separate handling of those events. Reviewed-by: Abhinav Kumar <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/579848/ Link: https://lore.kernel.org/r/[email protected]
1 parent f1d0b19 commit d72a3d3

File tree

4 files changed

+55
-49
lines changed

4 files changed

+55
-49
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static void dpu_encoder_virt_atomic_disable(struct drm_encoder *drm_enc,
13261326
trace_dpu_enc_disable(DRMID(drm_enc));
13271327

13281328
/* wait for idle */
1329-
dpu_encoder_wait_for_event(drm_enc, MSM_ENC_TX_COMPLETE);
1329+
dpu_encoder_wait_for_tx_complete(drm_enc);
13301330

13311331
dpu_encoder_resource_control(drm_enc, DPU_ENC_RC_EVENT_PRE_STOP);
13321332

@@ -2524,10 +2524,18 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev,
25242524
return &dpu_enc->base;
25252525
}
25262526

2527-
int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc,
2528-
enum msm_event_wait event)
2527+
/**
2528+
* dpu_encoder_wait_for_commit_done() - Wait for encoder to flush pending state
2529+
* @drm_enc: encoder pointer
2530+
*
2531+
* Wait for hardware to have flushed the current pending changes to hardware at
2532+
* a vblank or CTL_START. Physical encoders will map this differently depending
2533+
* on the type: vid mode -> vsync_irq, cmd mode -> CTL_START.
2534+
*
2535+
* Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
2536+
*/
2537+
int dpu_encoder_wait_for_commit_done(struct drm_encoder *drm_enc)
25292538
{
2530-
int (*fn_wait)(struct dpu_encoder_phys *phys_enc) = NULL;
25312539
struct dpu_encoder_virt *dpu_enc = NULL;
25322540
int i, ret = 0;
25332541

@@ -2541,23 +2549,47 @@ int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc,
25412549
for (i = 0; i < dpu_enc->num_phys_encs; i++) {
25422550
struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
25432551

2544-
switch (event) {
2545-
case MSM_ENC_COMMIT_DONE:
2546-
fn_wait = phys->ops.wait_for_commit_done;
2547-
break;
2548-
case MSM_ENC_TX_COMPLETE:
2549-
fn_wait = phys->ops.wait_for_tx_complete;
2550-
break;
2551-
default:
2552-
DPU_ERROR_ENC(dpu_enc, "unknown wait event %d\n",
2553-
event);
2554-
return -EINVAL;
2552+
if (phys->ops.wait_for_commit_done) {
2553+
DPU_ATRACE_BEGIN("wait_for_commit_done");
2554+
ret = phys->ops.wait_for_commit_done(phys);
2555+
DPU_ATRACE_END("wait_for_commit_done");
2556+
if (ret)
2557+
return ret;
25552558
}
2559+
}
2560+
2561+
return ret;
2562+
}
2563+
2564+
/**
2565+
* dpu_encoder_wait_for_tx_complete() - Wait for encoder to transfer pixels to panel
2566+
* @drm_enc: encoder pointer
2567+
*
2568+
* Wait for the hardware to transfer all the pixels to the panel. Physical
2569+
* encoders will map this differently depending on the type: vid mode -> vsync_irq,
2570+
* cmd mode -> pp_done.
2571+
*
2572+
* Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
2573+
*/
2574+
int dpu_encoder_wait_for_tx_complete(struct drm_encoder *drm_enc)
2575+
{
2576+
struct dpu_encoder_virt *dpu_enc = NULL;
2577+
int i, ret = 0;
2578+
2579+
if (!drm_enc) {
2580+
DPU_ERROR("invalid encoder\n");
2581+
return -EINVAL;
2582+
}
2583+
dpu_enc = to_dpu_encoder_virt(drm_enc);
2584+
DPU_DEBUG_ENC(dpu_enc, "\n");
2585+
2586+
for (i = 0; i < dpu_enc->num_phys_encs; i++) {
2587+
struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
25562588

2557-
if (fn_wait) {
2558-
DPU_ATRACE_BEGIN("wait_for_completion_event");
2559-
ret = fn_wait(phys);
2560-
DPU_ATRACE_END("wait_for_completion_event");
2589+
if (phys->ops.wait_for_tx_complete) {
2590+
DPU_ATRACE_BEGIN("wait_for_tx_complete");
2591+
ret = phys->ops.wait_for_tx_complete(phys);
2592+
DPU_ATRACE_END("wait_for_tx_complete");
25612593
if (ret)
25622594
return ret;
25632595
}

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,9 @@ void dpu_encoder_kickoff(struct drm_encoder *encoder);
9393
*/
9494
int dpu_encoder_vsync_time(struct drm_encoder *drm_enc, ktime_t *wakeup_time);
9595

96-
/**
97-
* dpu_encoder_wait_for_event - Waits for encoder events
98-
* @encoder: encoder pointer
99-
* @event: event to wait for
100-
* MSM_ENC_COMMIT_DONE - Wait for hardware to have flushed the current pending
101-
* frames to hardware at a vblank or ctl_start
102-
* Encoders will map this differently depending on the
103-
* panel type.
104-
* vid mode -> vsync_irq
105-
* cmd mode -> ctl_start
106-
* MSM_ENC_TX_COMPLETE - Wait for the hardware to transfer all the pixels to
107-
* the panel. Encoders will map this differently
108-
* depending on the panel type.
109-
* vid mode -> vsync_irq
110-
* cmd mode -> pp_done
111-
* Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
112-
*/
113-
int dpu_encoder_wait_for_event(struct drm_encoder *drm_encoder,
114-
enum msm_event_wait event);
96+
int dpu_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
97+
98+
int dpu_encoder_wait_for_tx_complete(struct drm_encoder *drm_encoder);
11599

116100
/*
117101
* dpu_encoder_get_intf_mode - get interface mode of the given encoder

drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static void dpu_kms_wait_for_commit_done(struct msm_kms *kms,
476476
* mode panels. This may be a no-op for command mode panels.
477477
*/
478478
trace_dpu_kms_wait_for_commit_done(DRMID(crtc));
479-
ret = dpu_encoder_wait_for_event(encoder, MSM_ENC_COMMIT_DONE);
479+
ret = dpu_encoder_wait_for_commit_done(encoder);
480480
if (ret && ret != -EWOULDBLOCK) {
481481
DPU_ERROR("wait for commit done returned %d\n", ret);
482482
break;

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ enum msm_dsi_controller {
7474
#define MSM_GPU_MAX_RINGS 4
7575
#define MAX_H_TILES_PER_DISPLAY 2
7676

77-
/**
78-
* enum msm_event_wait - type of HW events to wait for
79-
* @MSM_ENC_COMMIT_DONE - wait for the driver to flush the registers to HW
80-
* @MSM_ENC_TX_COMPLETE - wait for the HW to transfer the frame to panel
81-
*/
82-
enum msm_event_wait {
83-
MSM_ENC_COMMIT_DONE = 0,
84-
MSM_ENC_TX_COMPLETE,
85-
};
86-
8777
/**
8878
* struct msm_display_topology - defines a display topology pipeline
8979
* @num_lm: number of layer mixers used

0 commit comments

Comments
 (0)