Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6058367imu; Wed, 30 Jan 2019 08:07:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5+19O+9vNCYOR/G/0iz5iHLbgZ6CkSczaUwcAffd183Avbio7eMlRGjn8+KQHeMfe/bpH6 X-Received: by 2002:a62:a1a:: with SMTP id s26mr31335683pfi.31.1548864428034; Wed, 30 Jan 2019 08:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548864428; cv=none; d=google.com; s=arc-20160816; b=YZZ6gbUt3vec1wkjHBMrsWW7pOtCBOqvtyFojqZyyBGYvUEvEu1tjQNVP4uZ4KcuSB n1V221jMI4u0KYXN5cJe1sfdoFnnzrJFM1l2t0YBBpR480qqyQ9ekFxvRX0VAEyyIshx qkM9SfyLyDzyslBjMn9rYK/eGbRbwJbKSs4zOimAwqOeyr826NoPUD0c4rvCvlzjmsCy RGa83X8Bo6QdKbbiuoA1/0y3rRprGR0yOOocv67xRVULNzZB3HmclOokBAJPkh/UbwFk Vc9WOXeRIlxoPCMqYe/6yKT61zcBpjauLltAbytv6JAFLl+U6ViWDyZEIydo5g0bJzd4 tGGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hH3U0WFHZZpNJH6bCOhEbZsbYJbx6ZUSf+ECUNlMvDg=; b=de3S+Hun1kJkoX0xTt0Pa51UECZpMN3Lw/AukzKJe2V6t9aKR2CKjIAmHxN8R9Dcae 9usEl0IwOHVffVpEk5fv2zAC0QQ2Yd3mQBVH3aqITm3WYwQL0FvCXdFjSvfn8TQ7BgW1 x8qrswoOD9QwNsXj7RXpkk7ETZiLeQaJrvv4BMMdb8ALc3cjM5UIwyVI1Ehc0N218cKi mVx00sCX1KUhFK7vLAPxTY73LkvwXLWtfbIb+YbEQk/fdG4SZAcHbs0FuvOzYYjUeIa9 SfsKM60tINDDJOdosNjUqbP4THayGA5sLn5VhQSbBiNQPZy59SyOawbxxri2LmaxYVhq HH5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SMKu9+qd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si1619689pge.515.2019.01.30.08.06.52; Wed, 30 Jan 2019 08:07:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SMKu9+qd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731782AbfA3QGn (ORCPT + 99 others); Wed, 30 Jan 2019 11:06:43 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:35732 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731526AbfA3QGm (ORCPT ); Wed, 30 Jan 2019 11:06:42 -0500 Received: by mail-qt1-f193.google.com with SMTP id v11so81757qtc.2 for ; Wed, 30 Jan 2019 08:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hH3U0WFHZZpNJH6bCOhEbZsbYJbx6ZUSf+ECUNlMvDg=; b=SMKu9+qdc5uZQIyxvfsVyQRrY05OjXhY6bdqnnQj7jimS17eQdeLPAGXSQ7dQKHItq 9FXeI5Y10+WYR9KObYouo0OM+KFlNfg2eJDYGQtWV/Uua1QHJ7JCmcshNjwP1SJmR5a2 FnkyLFFEd1bYgmSEFiOCZaZ60kTXZ19DKdl6eQ+lll0GWBRLCa2U2eHyDPBKABYc6hPw Iqqwgc83k7XGITFeRB1QBGY/ew4ogGfnjo4SFmEKoJnuyckFUtJ5sA8CHEbCWdidoMYy 2JPOEdbi6RnEv66Vwvv+gdDHRuNk5Cbwx9R9KiYIkHKo1KTr7w+DEqkvSxBJEsfac3/q r1YQ== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hH3U0WFHZZpNJH6bCOhEbZsbYJbx6ZUSf+ECUNlMvDg=; b=nVY5CBDSnaTjDYayvzPiZ/Zm7N6YehSdHyqoQpWM9SARKS7DleSdee4OyxlR6WVrLe UMN8Rlb0w+CpjSgu3SaPl3BYWhu9vlKL9C6Wrr6V8I3zI2aCR2h6gqt+6BnTJ06hAZx+ 1t8FzeHxZ8oAWKPU4QGoEZGC3wXHYL4lepG7QZeacbJ6l3hoS3dSogJ4mb4nvH5qbS75 +wmGMFSiB5k+Ehe+Iv+QZE96/U/UYAtW/5LbxHUzYdHQaV8WitWYK9hseFmFZuHXY0cN Alcg1kt1HkDeMwV7Dc1E/TfMCX820JLVMB1kDN3z0jCRd5dCRSPCt2ZL0ySfDWSZ1duu uucA== X-Gm-Message-State: AJcUukd8wFoNAxX2hKhAHg3dRHgnlnapWBOWaU1eoCI+hZy6r+p32V1Z +uDupQArK2pkzsVbnmpHoY8= X-Received: by 2002:ac8:543:: with SMTP id c3mr30900897qth.34.1548864400728; Wed, 30 Jan 2019 08:06:40 -0800 (PST) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id u4sm1547948qkk.51.2019.01.30.08.06.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 08:06:40 -0800 (PST) Date: Wed, 30 Jan 2019 14:06:36 -0200 From: Shayenne Moura To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , David Airlie Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] drm/vkms: Bugfix extra vblank frame Message-ID: <171e6e1c239cbca0c3df7183ed8acdfeeace9cf4.1548856186.git.shayenneluzmoura@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kms_flip tests are breaking on vkms when simulate vblank because vblank event sequence count returns one extra frame after arm vblank event to make a page flip. When vblank interrupt happens, userspace processes the vblank event and issues the next page flip command. Kernel calls queue_work to call commit_planes and arm the new page flip. The next vblank picks up the newly armed vblank event and vblank interrupt happens again. The arm and vblank event are asynchronous, then, on the next vblank, we receive x+2 from `get_vblank_timestamp`, instead x+1, although timestamp and vblank seqno matches. Function `get_vblank_timestamp` is reached by 2 ways: - from `drm_mode_page_flip_ioctl`: driver is doing one atomic operation to synchronize planes in the same output. There is no vblank simulation, the `drm_crtc_arm_vblank_event` function adds 1 on vblank count, and the variable in_vblank_irq is false - from `vkms_vblank_simulate`: since the driver is doing a vblank simulation, the variable in_vblank_irq is true. Fix this problem subtracting one vblank period from vblank_time when `get_vblank_timestamp` is called from trace `drm_mode_page_flip_ioctl`, i.e., is not a real vblank interrupt, and getting the timestamp and vblank seqno when it is a real vblank interrupt. The reason for all this is that get_vblank_timestamp always supplies the timestamp for the next vblank event. The hrtimer is the vblank simulator, and it needs the correct previous value to present the next vblank. Since this is how hw timestamp registers work and what the vblank core expects. Signed-off-by: Shayenne Moura Signed-off-by: Daniel Vetter --- drivers/gpu/drm/vkms/vkms_crtc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index d44bfc392491..23146ff2a25b 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -87,6 +87,9 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, *vblank_time = output->vblank_hrtimer.node.expires; + if (!in_vblank_irq) + *vblank_time -= output->period_ns; + return true; } -- 2.17.1