From patchwork Mon Sep 7 17:04:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11761619 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 544D392C for ; Mon, 7 Sep 2020 17:03:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 366AC21897 for ; Mon, 7 Sep 2020 17:03:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rIDLXekW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730574AbgIGRDy (ORCPT ); Mon, 7 Sep 2020 13:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729868AbgIGRDv (ORCPT ); Mon, 7 Sep 2020 13:03:51 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7566BC061573; Mon, 7 Sep 2020 10:03:51 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 67so8253472pgd.12; Mon, 07 Sep 2020 10:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cBoeCpJIsgMagxrNvwqBCO9DZhUD6cpLapF30icLvGY=; b=rIDLXekWW5zsnDsZr9rwwnGh7AcQsXpJmtxOGLnaYEaXJ/7Sz6Ets68fQu6vR6NDRT bwJ03F4A8BzzUQbMMGeTQxqkNxfwrAgutSh4utFVl1D1DE9A/ODV+mnBppSqgNlzb+FR XZ8eLkzwbRQ6piUSbAQELVuV5vVJ43hENOahvDVxXil873iSxkXI0UgDW4XNZEF2SHo8 LTC2bYDGLqTqPy1+T1ebpGf4nMO1sUv2+QHOBzQV+PtBW6eOBk4FMgGOm1sFnlmbKhvr hwD0P3TADu3J7n7WZ4MP+3cmlYiqrgsUaiFdWTmDuiIU8Bl9dAuJTGcfZi/0u7J8FYXE F3EA== 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=cBoeCpJIsgMagxrNvwqBCO9DZhUD6cpLapF30icLvGY=; b=JTuDFue2MZ00VWM2ZRzhTQ8BGFAaE0gjJ4rWP3v/ojekCS2SXzfQYRdTrLe+LAO5h2 +0Dnd66yiE4PEV+pxfXQrh8+agbeU1KmNDNDno3p6+SCleYTFVA7O40MoGzEZkLXE1kN ygQfTQg760OfwOh/boT9xGIi0RO699huB1fNrygiDmctqRO0z7TuDfUroeEss3xrFN05 efHzbO4yXEQhMTc4om08zhPaC16SIQyLZVXMIRXPWFaQ6pa1tAqRyWgS17/Bd3j+BMNa 2IcpP2jNxUWDKyENyQ/nOrl0Eo89hGUwUnIJTaFVEWSXVt5ZriMuoEjqzjZIXDN4X+8E LR3Q== X-Gm-Message-State: AOAM533mA6d+i+kanquUvr4qo42amfqi6pmmN7LpsGYm/YLxUg4j3uQA 2MeGOqDq+RzZ15RKqjjl8yw= X-Google-Smtp-Source: ABdhPJxYfflcUtF+3SNgySp6Wk6HAI2DtYQFui4BIRaT7wEocOLQuuQWImDHVlvC2fujq7/dzSgg9Q== X-Received: by 2002:a63:6e01:: with SMTP id j1mr17237015pgc.147.1599498230690; Mon, 07 Sep 2020 10:03:50 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id j18sm13027030pgm.30.2020.09.07.10.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 10:03:49 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Rob Clark , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Drew Davenport , Kalyan Thota , Hongbo Yao , Bernard , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] drm/msm/dpu: move vblank events to complete_commit() Date: Mon, 7 Sep 2020 10:04:47 -0700 Message-Id: <20200907170450.370122-1-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 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 From: Rob Clark We could get a vblank event racing with the current atomic commit, resulting in sending the pageflip event to userspace early, causing tearing. On the other hand, complete_commit() ensures that the pending flush is complete. Signed-off-by: Rob Clark Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index c2729f71e2fa..89c0245b5de5 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -297,7 +297,6 @@ void dpu_crtc_vblank_callback(struct drm_crtc *crtc) dpu_crtc->vblank_cb_time = ktime_get(); else dpu_crtc->vblank_cb_count++; - _dpu_crtc_complete_flip(crtc); drm_crtc_handle_vblank(crtc); trace_dpu_crtc_vblank_cb(DRMID(crtc)); } @@ -402,6 +401,7 @@ static void dpu_crtc_frame_event_cb(void *data, u32 event) void dpu_crtc_complete_commit(struct drm_crtc *crtc) { trace_dpu_crtc_complete_commit(DRMID(crtc)); + _dpu_crtc_complete_flip(crtc); } static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc, From patchwork Mon Sep 7 17:04:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11761625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C46592C for ; Mon, 7 Sep 2020 17:04:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05A6021532 for ; Mon, 7 Sep 2020 17:04:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nh4IZq0a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730701AbgIGREJ (ORCPT ); Mon, 7 Sep 2020 13:04:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730394AbgIGRD6 (ORCPT ); Mon, 7 Sep 2020 13:03:58 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887F3C061573; Mon, 7 Sep 2020 10:03:58 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id v15so8277619pgh.6; Mon, 07 Sep 2020 10:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TqcpdSDPs0LRIseaVhQGu6lq6otZWIdGFe5nmwipIPY=; b=nh4IZq0a7cB1grKRk0BQOjqiQdJevhCjPIE3Oy6x4m6BbVWLFoq9yhe8gcIdyQ+7lP L/ARBz4ee8hPFMVgcd6jyHh5ZfZ/Dj44nfJpJHIh5mjtp17CcTtMVH18DHpw5OvJb5Cb mep0jPyaO4Gl8sZGlvBTmQot8x/DCEkaI4jQWZqaXYzl2pQ/ErTjq3AYqwIjxOLwsXsB 1e/b+4Bi4jsxW5+AODtnFMmLTT2LHHWKpfz/zlRbjS2MTSIQ0wK7l3XoOdf0oR5PR9Mc EiAkStykT6uUsa15ttcLY70EvLYXZOET/EEdKgqlFkZ/18UM9G1LZwTiODpcmVH9JGYM dVnw== 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=TqcpdSDPs0LRIseaVhQGu6lq6otZWIdGFe5nmwipIPY=; b=rIxiQBiD8IWxGu4pFup6Q99NIeH+QRnWHKMZdCpREI8Z5+YN2r0OOmB/iHQoh9JUGV 8Jmufqae7WXlrUS/c72G/mZ8kigkW11uNGiwzixgPpi2bvBksF9OFsvfbv+eUV159a95 lli9p61yfqSVTH6Vxjh/krCmOGqDbwHh3cJH5fwi+7AK53CK68srpceOjrOYX1BPvFzh 9IVx9tYLmCD/wNo7lgNK6CDI8qR0nHBJu40LHYuZe1DQjoLhnvZTfqoOZ6v28+OvAyRH sZCLgSA9C+f2dgR4WxLdrZbYxVUN//7W8+2A9uGqL4myE5BN1BVEPP8k5lbaxE3aZcxX 1Apw== X-Gm-Message-State: AOAM530sPQxiIIBhSOGbihzRbYaIj52K14yNT1PSqwdvn5pVPUpiRZ3r 4lv0g2tgABbvDq4yqEeHRO5+mHCgUMJrcQ== X-Google-Smtp-Source: ABdhPJw3IiW7lQ4CJE9PK3gspPmWTcTtJzvH3rq+m+ZOuCjZ76vbaISC0I/9xcIgB2sB9xvdcANNaA== X-Received: by 2002:a62:5cc4:: with SMTP id q187mr21209157pfb.95.1599498238018; Mon, 07 Sep 2020 10:03:58 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id l12sm12705425pjq.31.2020.09.07.10.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 10:03:56 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Rob Clark , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Drew Davenport , Kalyan Thota , Thomas Zimmermann , Hongbo Yao , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] drm/msm/dpu: clean up some impossibilities Date: Mon, 7 Sep 2020 10:04:48 -0700 Message-Id: <20200907170450.370122-2-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200907170450.370122-1-robdclark@gmail.com> References: <20200907170450.370122-1-robdclark@gmail.com> 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 From: Rob Clark Signed-off-by: Rob Clark Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 81 ++++-------------------- 1 file changed, 12 insertions(+), 69 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index 89c0245b5de5..ad49b0e17fcb 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -265,11 +265,6 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc) { struct drm_encoder *encoder; - if (!crtc) { - DPU_ERROR("invalid crtc\n"); - return INTF_MODE_NONE; - } - /* * TODO: This function is called from dpu debugfs and as part of atomic * check. When called from debugfs, the crtc->mutex must be held to @@ -500,12 +495,6 @@ static void dpu_crtc_atomic_begin(struct drm_crtc *crtc, struct dpu_crtc_state *cstate; struct drm_encoder *encoder; struct drm_device *dev; - unsigned long flags; - - if (!crtc) { - DPU_ERROR("invalid crtc\n"); - return; - } if (!crtc->state->enable) { DPU_DEBUG("crtc%d -> enable %d, skip atomic_begin\n", @@ -521,15 +510,6 @@ static void dpu_crtc_atomic_begin(struct drm_crtc *crtc, _dpu_crtc_setup_lm_bounds(crtc, crtc->state); - if (dpu_crtc->event) { - WARN_ON(dpu_crtc->event); - } else { - spin_lock_irqsave(&dev->event_lock, flags); - dpu_crtc->event = crtc->state->event; - crtc->state->event = NULL; - spin_unlock_irqrestore(&dev->event_lock, flags); - } - /* encoder will trigger pending mask now */ drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) dpu_encoder_trigger_kickoff_pending(encoder); @@ -583,14 +563,11 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc, return; } - if (dpu_crtc->event) { - DPU_DEBUG("already received dpu_crtc->event\n"); - } else { - spin_lock_irqsave(&dev->event_lock, flags); - dpu_crtc->event = crtc->state->event; - crtc->state->event = NULL; - spin_unlock_irqrestore(&dev->event_lock, flags); - } + WARN_ON(dpu_crtc->event); + spin_lock_irqsave(&dev->event_lock, flags); + dpu_crtc->event = crtc->state->event; + crtc->state->event = NULL; + spin_unlock_irqrestore(&dev->event_lock, flags); /* * If no mixers has been allocated in dpu_crtc_atomic_check(), @@ -635,14 +612,7 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc, static void dpu_crtc_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *state) { - struct dpu_crtc_state *cstate; - - if (!crtc || !state) { - DPU_ERROR("invalid argument(s)\n"); - return; - } - - cstate = to_dpu_crtc_state(state); + struct dpu_crtc_state *cstate = to_dpu_crtc_state(state); DPU_DEBUG("crtc%d\n", crtc->base.id); @@ -731,14 +701,8 @@ static void dpu_crtc_reset(struct drm_crtc *crtc) */ static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc *crtc) { - struct dpu_crtc_state *cstate, *old_cstate; - - if (!crtc || !crtc->state) { - DPU_ERROR("invalid argument(s)\n"); - return NULL; - } + struct dpu_crtc_state *cstate, *old_cstate = to_dpu_crtc_state(crtc->state); - old_cstate = to_dpu_crtc_state(crtc->state); cstate = kmemdup(old_cstate, sizeof(*old_cstate), GFP_KERNEL); if (!cstate) { DPU_ERROR("failed to allocate state\n"); @@ -754,19 +718,12 @@ static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc *crtc) static void dpu_crtc_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { - struct dpu_crtc *dpu_crtc; - struct dpu_crtc_state *cstate; + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc); + struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc->state); struct drm_encoder *encoder; unsigned long flags; bool release_bandwidth = false; - if (!crtc || !crtc->state) { - DPU_ERROR("invalid crtc\n"); - return; - } - dpu_crtc = to_dpu_crtc(crtc); - cstate = to_dpu_crtc_state(crtc->state); - DRM_DEBUG_KMS("crtc%d\n", crtc->base.id); /* Disable/save vblank irq handling */ @@ -825,19 +782,13 @@ static void dpu_crtc_disable(struct drm_crtc *crtc, static void dpu_crtc_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { - struct dpu_crtc *dpu_crtc; + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc); struct drm_encoder *encoder; bool request_bandwidth = false; - if (!crtc) { - DPU_ERROR("invalid crtc\n"); - return; - } - pm_runtime_get_sync(crtc->dev->dev); DRM_DEBUG_KMS("crtc%d\n", crtc->base.id); - dpu_crtc = to_dpu_crtc(crtc); drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) { /* in video mode, we hold an extra bandwidth reference @@ -873,9 +824,9 @@ struct plane_state { static int dpu_crtc_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { - struct dpu_crtc *dpu_crtc; + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc); + struct dpu_crtc_state *cstate = to_dpu_crtc_state(state); struct plane_state *pstates; - struct dpu_crtc_state *cstate; const struct drm_plane_state *pstate; struct drm_plane *plane; @@ -889,16 +840,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc, int left_zpos_cnt = 0, right_zpos_cnt = 0; struct drm_rect crtc_rect = { 0 }; - if (!crtc) { - DPU_ERROR("invalid crtc\n"); - return -EINVAL; - } - pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL); - dpu_crtc = to_dpu_crtc(crtc); - cstate = to_dpu_crtc_state(state); - if (!state->enable || !state->active) { DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n", crtc->base.id, state->enable, state->active);