From patchwork Mon Jan 28 20:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10784715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EA33922 for ; Mon, 28 Jan 2019 20:43:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B7D42C378 for ; Mon, 28 Jan 2019 20:43:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C8862C388; Mon, 28 Jan 2019 20:43:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52C8A2C378 for ; Mon, 28 Jan 2019 20:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfA1UnJ (ORCPT ); Mon, 28 Jan 2019 15:43:09 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:42618 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfA1UnJ (ORCPT ); Mon, 28 Jan 2019 15:43:09 -0500 Received: by mail-yw1-f68.google.com with SMTP id x2so7289153ywc.9 for ; Mon, 28 Jan 2019 12:43:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FXT6WEzh/1Xt96j/UR3E4vDv/EmUAOGGdldTO7ZrroY=; b=R1BkPeQG200S6E2C1M1Fd1XqPc12hVI96tMinxM4i69vt1voL2BNTKARkMyzCE+NuC 8OEQdSj3sdWKDZkvXt9mLsNJA2IUEMSYMPIwR49axTYcyBju0zxPyhFU1ssjJrItyY7K SmWf6FH4vgQoRGkGCYoSDfOguvQb1NqdSn582r3OEVaSe+htRYSRR30X3JeCtJisdHbP tOdbNfCd1IdDevv+PtaG3Tyaam0ygnSZv+KVVMMMxxQH5+viU83g309BGCbittIBfZvn UQi4jMI5tN9zmKEtJkIE1U3uhwSGXNtTp6H0WWnYQHJthgLJLsdWJCEnDQ0p661lNEtR rL/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FXT6WEzh/1Xt96j/UR3E4vDv/EmUAOGGdldTO7ZrroY=; b=H3ERhpdM7E8aIbvIP0jM7RA3ax8EV8yeVM5lYaDF7SWL1Nq03UCV+gw/Xb+kR8UJHX EfIXblI7tm44BNA1awiRx0LiZBw15cyUMbho2xfN6rlEM/uaTOKG5G+nxeuorxlsCwux Xf//cgxQlIVb7S6YpNhy33WWPK9GIpIruvVHeJVBugVcLROKZnHGRcD9OFiPjTh6j3+l w8Ywa20xCJqKIBVgkOcs21Whi5cjYBXcdV+vI++Gcslml0nrdKpOl4soOzDEg3E9xGv9 CyXeRHeh7ieMXdRYScRzDu3KRgR+mRMTWLhTfw7nUQYxfPhiTGz61dRFcwGG0nmtH4Ks 1r7w== X-Gm-Message-State: AJcUukcO4xRI2Q/d6iHNithOrmX4PWRSPNWVgybZ1UyqHnBQpsTGZHWa hg2C2h2o0rOSLiaeSRFddyhgnOZ5zqQzJA== X-Google-Smtp-Source: ALg8bN6tN1MaZDKd4SglCYbp84dbxPk63zY26qyLhx1HWc0dlDsxdLn73JzCKGtB25ALJLrxV3J7HQ== X-Received: by 2002:a81:b243:: with SMTP id q64mr22274005ywh.351.1548708188181; Mon, 28 Jan 2019 12:43:08 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id a7sm24119760ywb.18.2019.01.28.12.43.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 12:43:07 -0800 (PST) From: Sean Paul To: freedreno@lists.freedesktop.org Cc: robdclark@gmail.com, Sean Paul , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] drm/msm: Use drm_mode_vrefresh instead of mode->vrefresh Date: Mon, 28 Jan 2019 15:42:48 -0500 Message-Id: <20190128204306.95076-1-sean@poorly.run> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul Use the drm_mode_vrefresh helper where we need refresh rate in case vrefresh is empty. Signed-off-by: Sean Paul Reviewed-by: Abhinav Kumar Reviewed-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 6 +++--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 5 +++-- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +- drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 941ac25d2a023..dd71cb6ba4f5c 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -522,8 +522,8 @@ static void _dpu_encoder_adjust_mode(struct drm_connector *connector, list_for_each_entry(cur_mode, &connector->modes, head) { if (cur_mode->vdisplay == adj_mode->vdisplay && - cur_mode->hdisplay == adj_mode->hdisplay && - cur_mode->vrefresh == adj_mode->vrefresh) { + cur_mode->hdisplay == adj_mode->hdisplay && + drm_mode_vrefresh(cur_mode) == drm_mode_vrefresh(adj_mode)) { adj_mode->private = cur_mode->private; adj_mode->private_flags |= cur_mode->private_flags; } @@ -1805,7 +1805,7 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc, bool async) atomic_set(&dpu_enc->frame_done_timeout, DPU_FRAME_DONE_TIMEOUT * 1000 / - drm_enc->crtc->state->adjusted_mode.vrefresh); + drm_mode_vrefresh(&drm_enc->crtc->state->adjusted_mode)); mod_timer(&dpu_enc->frame_done_timer, jiffies + ((atomic_read(&dpu_enc->frame_done_timeout) * HZ) / 1000)); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c index 99ab5ca9bed3b..f21163313d635 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c @@ -404,7 +404,8 @@ static void dpu_encoder_phys_cmd_tearcheck_config( return; } - tc_cfg.vsync_count = vsync_hz / (mode->vtotal * mode->vrefresh); + tc_cfg.vsync_count = vsync_hz / + (mode->vtotal * drm_mode_vrefresh(mode)); /* enable external TE after kickoff to avoid premature autorefresh */ tc_cfg.hw_vsync_mode = 0; @@ -424,7 +425,7 @@ static void dpu_encoder_phys_cmd_tearcheck_config( DPU_DEBUG_CMDENC(cmd_enc, "tc %d vsync_clk_speed_hz %u vtotal %u vrefresh %u\n", phys_enc->hw_pp->idx - PINGPONG_0, vsync_hz, - mode->vtotal, mode->vrefresh); + mode->vtotal, drm_mode_vrefresh(mode)); DPU_DEBUG_CMDENC(cmd_enc, "tc %d enable %u start_pos %u rd_ptr_irq %u\n", phys_enc->hw_pp->idx - PINGPONG_0, tc_enable, tc_cfg.start_pos, diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c index b01183b309b9e..da1f727d74957 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c @@ -387,7 +387,7 @@ static void _dpu_plane_set_ot_limit(struct drm_plane *plane, ot_params.width = drm_rect_width(&pdpu->pipe_cfg.src_rect); ot_params.height = drm_rect_height(&pdpu->pipe_cfg.src_rect); ot_params.is_wfd = !pdpu->is_rt_pipe; - ot_params.frame_rate = crtc->mode.vrefresh; + ot_params.frame_rate = drm_mode_vrefresh(&crtc->mode); ot_params.vbif_idx = VBIF_RT; ot_params.clk_ctrl = pdpu->pipe_hw->cap->clk_ctrl; ot_params.rd = true; diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c index c1962f29ec7d6..6341ac010f7de 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c @@ -59,10 +59,10 @@ static int pingpong_tearcheck_setup(struct drm_encoder *encoder, return -EINVAL; } - total_lines_x100 = mode->vtotal * mode->vrefresh; + total_lines_x100 = mode->vtotal * drm_mode_vrefresh(mode); if (!total_lines_x100) { DRM_DEV_ERROR(dev, "%s: vtotal(%d) or vrefresh(%d) is 0\n", - __func__, mode->vtotal, mode->vrefresh); + __func__, mode->vtotal, drm_mode_vrefresh(mode)); return -EINVAL; } From patchwork Mon Jan 28 20:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10784717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45BDC922 for ; Mon, 28 Jan 2019 20:43:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28CE22C378 for ; Mon, 28 Jan 2019 20:43:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CA992C388; Mon, 28 Jan 2019 20:43:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA3B02C378 for ; Mon, 28 Jan 2019 20:43:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbfA1UnM (ORCPT ); Mon, 28 Jan 2019 15:43:12 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:40042 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfA1UnM (ORCPT ); Mon, 28 Jan 2019 15:43:12 -0500 Received: by mail-yw1-f67.google.com with SMTP id g194so7297433ywe.7 for ; Mon, 28 Jan 2019 12:43:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9LEeFc4h44UE10UMeYOxbhRx47PBnxwQW01uNVsby5o=; b=XKgJ11xcPhG3/cwNa24gL8lCOkjgjlR738MIGMLQQ4Gc8GpPcr45Cg7Yl0YR8y99cw C6im5NnmF0CmQDPgSBIOYq5x9t66d6SGl7GrzvZHN5zasTUEnLeT7RCFPUIRvwV9P1bX ZKA9RbiK/Evr4CpSBeAWVIOyuXSBr6uu9+hbjjyeO9I5o9+sQKIh+SeHyfPgR3iswXDf j3LZLreTNYnLsdimDX3Fhbra8wvNxUyLDQnkADVP3W76eTkmNbK1kzjxnsEiz+wx4/pg geOsxNtVKTUtzXa+7lxQaA2jb7c9HCo4lqlYEGpCkoZ7efAzbq8gof4618NviJpwGXLX CSBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9LEeFc4h44UE10UMeYOxbhRx47PBnxwQW01uNVsby5o=; b=DiaiUX9j8HQyhiqcX9d6lkYPyqlKt1R7Xfftup8YGHUYMoe9NBNlVBtV46n4z2Xqe3 j59fZeatEruumBo0tSt2xL4M48EOgSpy/SO6ZwWaQRxq7GTZxd3Lxp+RbjiSMqLLquPC 4jSCh9jWFBo+HpsQI9Tsb3tUNNcVctkhq8R5yDN9h67Gp57YZf9Sd35ZHyON6pGX/VaZ fCtquwwH1fIlGL+8VwgaU5z5s1qzeMlveamacalofp002rpXJF4oIQ+g/ovkwr61pI9V it8Tiq4BJsnVt7lrYyZtinImzobL9OCknUdxGWGUYlPlRZ1TV2WO2S/JAtU+xmUQ4yjU /VEg== X-Gm-Message-State: AJcUukfOLBsD4YTyQardDA2mc7oxAVcT7K3IEQeS+VWD8Ik/bvE5ZdxC H6d3CGUG7bzfAA710riAW/PCYQ== X-Google-Smtp-Source: ALg8bN5Y4GI6MZbXgSs6JqsvnpUyDH1ce0UJvAb1YgHFM+GaadXmJV4qSH5pbvqWlCCXz+MXIjxnXA== X-Received: by 2002:a81:e40b:: with SMTP id r11mr22135215ywl.56.1548708191001; Mon, 28 Jan 2019 12:43:11 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id a7sm24119760ywb.18.2019.01.28.12.43.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 12:43:10 -0800 (PST) From: Sean Paul To: freedreno@lists.freedesktop.org Cc: robdclark@gmail.com, Sean Paul , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/msm: dpu: Simplify frame_done watchdog timeout calculation Date: Mon, 28 Jan 2019 15:42:49 -0500 Message-Id: <20190128204306.95076-2-sean@poorly.run> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190128204306.95076-1-sean@poorly.run> References: <20190128204306.95076-1-sean@poorly.run> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul Instead of setting the timeout and then immediately reading it back (along with the hand-rolled msecs_to_jiffies calculation), just calculate it once and set it in both places at the same time. Signed-off-by: Sean Paul Reviewed-by: Abhinav Kumar Reviewed-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index dd71cb6ba4f5c..83a4c47dbed2d 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -1791,6 +1791,7 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc, bool async) { struct dpu_encoder_virt *dpu_enc; struct dpu_encoder_phys *phys; + unsigned long timeout_ms; ktime_t wakeup_time; unsigned int i; @@ -1803,11 +1804,12 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc, bool async) trace_dpu_enc_kickoff(DRMID(drm_enc)); - atomic_set(&dpu_enc->frame_done_timeout, - DPU_FRAME_DONE_TIMEOUT * 1000 / - drm_mode_vrefresh(&drm_enc->crtc->state->adjusted_mode)); - mod_timer(&dpu_enc->frame_done_timer, jiffies + - ((atomic_read(&dpu_enc->frame_done_timeout) * HZ) / 1000)); + timeout_ms = DPU_FRAME_DONE_TIMEOUT * 1000 / + drm_mode_vrefresh(&drm_enc->crtc->state->adjusted_mode); + + atomic_set(&dpu_enc->frame_done_timeout, timeout_ms); + mod_timer(&dpu_enc->frame_done_timer, + jiffies + msecs_to_jiffies(timeout_ms)); /* All phys encs are ready to go, trigger the kickoff */ _dpu_encoder_kickoff_phys(dpu_enc, async); From patchwork Mon Jan 28 20:42:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10784721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7901184E for ; Mon, 28 Jan 2019 20:43:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9722A2C378 for ; Mon, 28 Jan 2019 20:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B7482C385; Mon, 28 Jan 2019 20:43:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEA1D2C38A for ; Mon, 28 Jan 2019 20:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726862AbfA1UnN (ORCPT ); Mon, 28 Jan 2019 15:43:13 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:43330 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfA1UnN (ORCPT ); Mon, 28 Jan 2019 15:43:13 -0500 Received: by mail-yb1-f195.google.com with SMTP id e12so7267629ybn.10 for ; Mon, 28 Jan 2019 12:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nL91TD/n5Q7mbgBCnCuiK9ud+S1WniAfFRg70hEwI8A=; b=QjErT7XmVAodFHUNcPBv9/ezhtQnjjEnthxfPzd1tUhA//dCKcAK62NbWjpYc18aKt oAHk+U1nkUMXGen7Dtf8k7/RBIvgxibh42X16JaMyMhRwcNzE8bjg0ZaA4zFB935DHa3 C28ldbpkwvMNsJqZAN17B+mssnZZfMzWsnV7ijlpF9ko9o6d1KFKZslcLvVpeBbQ+9HJ iOydNDJh8uyHFYAwU2xDXFmKKxUgnc8jNb22BhHKGAMmEey6C1av5P00J+MJxnJ+9WJV lEhQd45heQzjwyfKsdPEZa3SXSf/GB7Z72BfA5NixJXCdK316BcDgB1qYUj+jdz7jeGa G5Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nL91TD/n5Q7mbgBCnCuiK9ud+S1WniAfFRg70hEwI8A=; b=VUey9z/FKMbuHZ+Ks9c9tSKXNJ98nx6LUT4xgVWYqI304mtka9lWeB0xxazkLXSUJy Xdxwoz2Xyeu2KRvIOBbIkZUPNij3/kXiO4yVgYzTP0jEDRdppHkdGNhapJGEZxDfNkWu lq4fTE7KfSYQ9vd5OtUzK7aATJuFACpLOhqA8ZsPl/6wzY2ISVDMMVAlCRJ/Q7ytwDxJ ABhzRRPKvTJasBY3azKKSoSTisdnjlW3DhcYBtH3M5BwsmFvoHjTvYx2i7gvuqx223ZZ pZqydugwGuEmGMrB0cw7/QFs4VKPUz5AdO/egCqkwjo8PtRmDHvzg7ZXrMw3CW1Fhy2B hJpQ== X-Gm-Message-State: AJcUukfC966fBt4+7F3SIwQdTsPoTjwl1p667dPZ+3aMIuIz5rNTZnko lq7Q9d/CEk3dEhhaO76oq6vQPw== X-Google-Smtp-Source: ALg8bN4UAJ7U0cqPmoYfhXlacmrOmqyBNnKqTwq9/wtv8/0DUv50dF919fDC2AuiWtf8LAgxORadOA== X-Received: by 2002:a25:b98c:: with SMTP id r12mr22780991ybg.432.1548708192356; Mon, 28 Jan 2019 12:43:12 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id a7sm24119760ywb.18.2019.01.28.12.43.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 12:43:11 -0800 (PST) From: Sean Paul To: freedreno@lists.freedesktop.org Cc: robdclark@gmail.com, Sean Paul , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/msm: dpu: Untangle frame_done timeout units Date: Mon, 28 Jan 2019 15:42:50 -0500 Message-Id: <20190128204306.95076-3-sean@poorly.run> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190128204306.95076-1-sean@poorly.run> References: <20190128204306.95076-1-sean@poorly.run> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul There exists a bunch of confusion as to what the actual units of frame_done is: - The definition states it's in # of frames - CRTC treats it like it's ms - frame_done_timeout comment thinks it's Hz, but it stores ms - frame_done timer is setup such that it _should_ be in frames, but the timeout is super long So this patch tries to interpret what the driver really wants. I've de-centralized the #define since the consumers are expecting different units. For crtc, we just use 60ms since that's what it was doing before. Perhaps we could get fancy and scale with vrefresh, but that's for another time. For encoder, fix the comments and rename frame_done_timeout so it's obvious what the units are. In practice, frame_done_timeout is really just checked against 0 || !0, which I guess is why the units being wrong didn't matter. I've also dropped the timeout from the previous 60 frames to 5. That seems like more than enough time to give up on a frame, and my guess is that no one intended for the timeout to _actually_ be 60 frames. Signed-off-by: Sean Paul Reviewed-by: Fritz Koenig Reviewed-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 5 ++++- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 19 +++++++++++-------- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 3 --- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index 4e4b64821c9e8..b0b394af2a7ef 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -46,6 +46,9 @@ #define LEFT_MIXER 0 #define RIGHT_MIXER 1 +/* timeout in ms waiting for frame done */ +#define DPU_CRTC_FRAME_DONE_TIMEOUT_MS 60 + static struct dpu_kms *_dpu_crtc_get_kms(struct drm_crtc *crtc) { struct msm_drm_private *priv = crtc->dev->dev_private; @@ -683,7 +686,7 @@ static int _dpu_crtc_wait_for_frame_done(struct drm_crtc *crtc) DPU_ATRACE_BEGIN("frame done completion wait"); ret = wait_for_completion_timeout(&dpu_crtc->frame_done_comp, - msecs_to_jiffies(DPU_FRAME_DONE_TIMEOUT)); + msecs_to_jiffies(DPU_CRTC_FRAME_DONE_TIMEOUT_MS)); if (!ret) { DRM_ERROR("frame done wait timed out, ret:%d\n", ret); rc = -ETIMEDOUT; diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 83a4c47dbed2d..51e46b206c73e 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -69,6 +69,9 @@ #define MAX_VDISPLAY_SPLIT 1080 +/* timeout in frames waiting for frame done */ +#define DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES 5 + /** * enum dpu_enc_rc_events - events for resource control state machine * @DPU_ENC_RC_EVENT_KICKOFF: @@ -158,7 +161,7 @@ enum dpu_enc_rc_states { * Bit0 = phys_encs[0] etc. * @crtc_frame_event_cb: callback handler for frame event * @crtc_frame_event_cb_data: callback handler private data - * @frame_done_timeout: frame done timeout in Hz + * @frame_done_timeout_ms: frame done timeout in ms * @frame_done_timer: watchdog timer for frame done event * @vsync_event_timer: vsync timer * @disp_info: local copy of msm_display_info struct @@ -196,7 +199,7 @@ struct dpu_encoder_virt { void (*crtc_frame_event_cb)(void *, u32 event); void *crtc_frame_event_cb_data; - atomic_t frame_done_timeout; + atomic_t frame_done_timeout_ms; struct timer_list frame_done_timer; struct timer_list vsync_event_timer; @@ -1184,7 +1187,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) } /* after phys waits for frame-done, should be no more frames pending */ - if (atomic_xchg(&dpu_enc->frame_done_timeout, 0)) { + if (atomic_xchg(&dpu_enc->frame_done_timeout_ms, 0)) { DPU_ERROR("enc%d timeout pending\n", drm_enc->base.id); del_timer_sync(&dpu_enc->frame_done_timer); } @@ -1341,7 +1344,7 @@ static void dpu_encoder_frame_done_callback( } if (!dpu_enc->frame_busy_mask[0]) { - atomic_set(&dpu_enc->frame_done_timeout, 0); + atomic_set(&dpu_enc->frame_done_timeout_ms, 0); del_timer(&dpu_enc->frame_done_timer); dpu_encoder_resource_control(drm_enc, @@ -1804,10 +1807,10 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc, bool async) trace_dpu_enc_kickoff(DRMID(drm_enc)); - timeout_ms = DPU_FRAME_DONE_TIMEOUT * 1000 / + timeout_ms = DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES * 1000 / drm_mode_vrefresh(&drm_enc->crtc->state->adjusted_mode); - atomic_set(&dpu_enc->frame_done_timeout, timeout_ms); + atomic_set(&dpu_enc->frame_done_timeout_ms, timeout_ms); mod_timer(&dpu_enc->frame_done_timer, jiffies + msecs_to_jiffies(timeout_ms)); @@ -2129,7 +2132,7 @@ static void dpu_encoder_frame_done_timeout(struct timer_list *t) DRM_DEBUG_KMS("id:%u invalid timeout frame_busy_mask=%lu\n", DRMID(drm_enc), dpu_enc->frame_busy_mask[0]); return; - } else if (!atomic_xchg(&dpu_enc->frame_done_timeout, 0)) { + } else if (!atomic_xchg(&dpu_enc->frame_done_timeout_ms, 0)) { DRM_DEBUG_KMS("id:%u invalid timeout\n", DRMID(drm_enc)); return; } @@ -2175,7 +2178,7 @@ int dpu_encoder_setup(struct drm_device *dev, struct drm_encoder *enc, spin_lock_init(&dpu_enc->enc_spinlock); - atomic_set(&dpu_enc->frame_done_timeout, 0); + atomic_set(&dpu_enc->frame_done_timeout_ms, 0); timer_setup(&dpu_enc->frame_done_timer, dpu_encoder_frame_done_timeout, 0); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h index ac75cfc267f40..31e9ef96ca5dc 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h @@ -73,9 +73,6 @@ #define DPU_NAME_SIZE 12 -/* timeout in frames waiting for frame done */ -#define DPU_FRAME_DONE_TIMEOUT 60 - /* * struct dpu_irq_callback - IRQ callback handlers * @list: list to callback From patchwork Mon Jan 28 20:42:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10784723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F711922 for ; Mon, 28 Jan 2019 20:43:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2A52C378 for ; Mon, 28 Jan 2019 20:43:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41ABE2C388; Mon, 28 Jan 2019 20:43:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D973C2C378 for ; Mon, 28 Jan 2019 20:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfA1UnP (ORCPT ); Mon, 28 Jan 2019 15:43:15 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:44409 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfA1UnP (ORCPT ); Mon, 28 Jan 2019 15:43:15 -0500 Received: by mail-yb1-f193.google.com with SMTP id k189so7257473yba.11 for ; Mon, 28 Jan 2019 12:43:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=or+Cf96R5/0Rfr5iTinESdAFMcjNohnw5mvFKvf15js=; b=AdbSA8I4n9GGJ+TF1HOWeLvcPxaQqn+Lj3RfyHiG+Tsu5KBauc/CUlouWYE/Sk/Pzp jiN4AVKzcjx+KvG/2w+j+1PSVeJbhl+LrLpAkAh1tyu2xYxCiCpRtPt9KmTX59dYiY/P 3M2fL4QiNHVjrzclqnW2kKygiW39UqFkSR+IbYn7oQindeF8oxO+xYCS4f5eUsfnxTQy tmq3xIUTquYi9q9wNnLm58NcOtn4xIFGlMzdXoW8D/YuetOYOoUMf25YuuS6ir57EU4D /ISjF//iAbjAQRNMixoajluXgqMtENiq/QOH6emKmkJ1D+QrkHBoL+9YuKjhGGUjhHAO gIiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=or+Cf96R5/0Rfr5iTinESdAFMcjNohnw5mvFKvf15js=; b=YBVlZNA90Nc6v8dTbvFlAW+aNLfJKoA0R3An290Zzi/q+ri0VpMSvmkx+K1EwY2UYw foACRfvoIv751afVPijcTDRi730fi5drZ82ibyaX5lMmIh5OTuZ7ow7NW7w3tJLuZiqY CRRRhWVta7GdNd7lgZtdwxuqmYRJ4xLsZUaZ3KdgvmDrczMg4JogSkUWB4LA20PPdSaP Ef7wkWDx+7jU4xl1ljguZG5jrvyveU41T8ZqPZU8mvWYsKhgNBey12BSwVf+WMnY2Z/z L5HoBLnqd97RYN2HbJ7YXGeNtY5ZyKSXSarCKjMoNTkopsGJ5ZL4AktMfO+SLnhiz44D JrHg== X-Gm-Message-State: AHQUAuY+rt+XWD9kt4x1YBaClqa/v3I62vpq0nRvc3sd957MOjjhFJjW v52FBI/rC5sT9gWfLJOX5jeu+Q== X-Google-Smtp-Source: AHgI3IY81RWGV8xW/W2tKiYEtUFiji/E4PcodiK/JCvzNRowH9besQuSGCTGLUVWPJMzPfnyRxVb/g== X-Received: by 2002:a25:505:: with SMTP id 5mr6046403ybf.389.1548708194457; Mon, 28 Jan 2019 12:43:14 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id a7sm24119760ywb.18.2019.01.28.12.43.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 12:43:14 -0800 (PST) From: Sean Paul To: freedreno@lists.freedesktop.org Cc: robdclark@gmail.com, Sean Paul , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/msm: dpu: Don't queue the frame_done watchdog for cursor Date: Mon, 28 Jan 2019 15:42:51 -0500 Message-Id: <20190128204306.95076-4-sean@poorly.run> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190128204306.95076-1-sean@poorly.run> References: <20190128204306.95076-1-sean@poorly.run> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul In the case of an async/cursor update, we don't wait for the frame_done event, which means handle_frame_done is never called, and the frame_done watchdog isn't canceled. Currently, this results in a frame_done timeout every time the cursor moves without a synchronous frame following it up before the timeout expires. Since we don't wait for frame_done, and don't handle it, we shouldn't modify the watchdog. Signed-off-by: Sean Paul Reviewed-by: Fritz Koenig Reviewed-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 51e46b206c73e..05145cf9fb408 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -1794,7 +1794,6 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc, bool async) { struct dpu_encoder_virt *dpu_enc; struct dpu_encoder_phys *phys; - unsigned long timeout_ms; ktime_t wakeup_time; unsigned int i; @@ -1807,12 +1806,20 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc, bool async) trace_dpu_enc_kickoff(DRMID(drm_enc)); - timeout_ms = DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES * 1000 / - drm_mode_vrefresh(&drm_enc->crtc->state->adjusted_mode); + /* + * Asynchronous frames don't handle FRAME_DONE events. As such, they + * shouldn't enable the frame_done watchdog since it will always time + * out. + */ + if (!async) { + unsigned long timeout_ms; + timeout_ms = DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES * 1000 / + drm_mode_vrefresh(&drm_enc->crtc->state->adjusted_mode); - atomic_set(&dpu_enc->frame_done_timeout_ms, timeout_ms); - mod_timer(&dpu_enc->frame_done_timer, - jiffies + msecs_to_jiffies(timeout_ms)); + atomic_set(&dpu_enc->frame_done_timeout_ms, timeout_ms); + mod_timer(&dpu_enc->frame_done_timer, + jiffies + msecs_to_jiffies(timeout_ms)); + } /* All phys encs are ready to go, trigger the kickoff */ _dpu_encoder_kickoff_phys(dpu_enc, async);