From patchwork Mon May 20 00:12:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10949775 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 7DA231395 for ; Mon, 20 May 2019 00:12:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52A89284DC for ; Mon, 20 May 2019 00:12:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E06F284F1; Mon, 20 May 2019 00:12:19 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEC68284DC for ; Mon, 20 May 2019 00:12:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A7E489175; Mon, 20 May 2019 00:12:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4448989175 for ; Mon, 20 May 2019 00:12:14 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id j53so14357955qta.9 for ; Sun, 19 May 2019 17:12:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=00rc2d7E6nzGfdw+dxGhcOctOgwdvAnLnh4F/f6DG1Y=; b=OHMVnyb6mX5lM4eKShc/IuprOSD5Did2vWOct+uJM9m8XjLjooAqleMZmIZgLGImB6 v9OKMw91KJ8vt7d49A/NeIx+tDlAETDIavQQs9y4C69ObwGdVoo2dywWvBctVlbo/CEa BmrvV4l/C1DXwO8f0gjEJCabPhoAUGsG8bBoQYb1a52oRwlUWC/u5ImwqX2CEDWZYmJH 5FKZzPwFtFrW3HCu8qE5iA2GUtRvrSWMf9IOU6zEHk9vhiuHQlwP0PkTv+Sai9mKDphH dcxJ3C/O7XrkysnGhoa+QKpFo0W5xvsbGdi9Tw8x37iBlk/J+HbyTpV4+wUxxf/XPKO2 NZTg== X-Gm-Message-State: APjAAAUWIuDcNqG+L/5ylEWeZqy26QOf/IfXmafLe+3ChAh7Ozes0nqv fcvHmA+iQHu9BLjUaowC6LY= X-Google-Smtp-Source: APXvYqzgLOvsYJSAD0VDyr7qts88R4GClEpaw1oY+Pb2nHzsR+1REe2dneYjVeBCrO/pm3H68LXqkg== X-Received: by 2002:a0c:fd48:: with SMTP id j8mr12492987qvs.10.1558311133311; Sun, 19 May 2019 17:12:13 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.151]) by smtp.gmail.com with ESMTPSA id a1sm8434424qth.69.2019.05.19.17.12.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 19 May 2019 17:12:12 -0700 (PDT) Date: Sun, 19 May 2019 21:12:08 -0300 From: Rodrigo Siqueira To: Ville Syrjala , Shayenne Moura , Haneen Mohammed , Daniel Vetter , David Airlie Subject: [PATCH] drm/vkms: Avoid extra discount in the timestamp value Message-ID: <20190520001208.yh4jivl5lcc7iarh@smtp.gmail.com> MIME-Version: 1.0 User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=00rc2d7E6nzGfdw+dxGhcOctOgwdvAnLnh4F/f6DG1Y=; b=XbaawZMQlOtg2W/z5EP1ea9DzNoPEgXu+OcYPUvy/W2j5C3qAScMieXBbMBUPMWcd+ tHBmko4ZVNRTch44/1yXyhCg46dUVcubbxt3+cVsLgOr7bmSWwANPqw2n89GnvEBBBP4 v34lIe9TOsaXGJG9OjJtuPOuDS+ZSlro0ySrvXwrtPG12ZGPxyo4745FDIuncLDBJ+w9 TbYhl2rGnGOe2uvT88YE/tii/biDQoUZ31TZTGEeCFrEd5dm0FN4CR6gy8iBk9B3TBC5 IqGFUzJ8YNfpX6lZqafnZWyEXNbd+TZhdDB4p5SCG/NLrb8iaQD5dJFpB9hyj2xQuxFH yXBQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP After the commit def35e7c5926 ("drm/vkms: Bugfix extra vblank frame") some of the crc tests (IGT) start to fail in the vkms with the following error: [drm:drm_crtc_add_crc_entry [drm]] *ERROR* Overflow of CRC buffer, userspace reads too slow. [drm] failed to queue vkms_crc_work_handle ... The commit def35e7c5926 ("drm/vkms: Bugfix extra vblank frame") added an operation for decrement the timestamp value returned by `get_vblank_timestamp()` which solved the problems related to kms_flip tests. However, each call to `get_vblank_timestamp()` reduces the timestamp even when it is not required. Such decrement generates a negative number in the following calculation within `drm_update_vblank_count()`: u64 diff_ns = ktime_to_ns(ktime_sub(t_vblank, vblank->time)); Next, the DIV_ROUND_CLOSEST_ULL macro is invoked using the diff_ns value, which generates an undefined result. Therefore, the returned frame is incorrect, which assign a huge number to the variable frame_end. In this case, causing the loop (`vkms_crc_work_handle()`) below to take a long time: frame_end = drm_crtc_accurate_vblank_count(crtc); while (frame_start <= frame_end) drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32); This commit fixes this issue by adding a check that validates whether the current vblank timestamp is still the same, thus avoiding excessive timestamp decrement of the timestamp value. Signed-off-by: Rodrigo Siqueira Signed-off-by: Shayenne Moura --- drivers/gpu/drm/vkms/vkms_crtc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 7508815fac11..3ce60e66673e 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -74,9 +74,13 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, { struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); struct vkms_output *output = &vkmsdev->output; + struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; *vblank_time = output->vblank_hrtimer.node.expires; + if (*vblank_time == vblank->time) + return true; + if (!in_vblank_irq) *vblank_time -= output->period_ns;