Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2955676pxa; Sat, 8 Aug 2020 05:12:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymb+EuMoNvnhUst8i9F6Kc+SkmA9/YXUGhcFEFDs+lCn8pCTLj921JRcKc/e4DnOGjoslu X-Received: by 2002:a17:906:2784:: with SMTP id j4mr13968805ejc.96.1596888743640; Sat, 08 Aug 2020 05:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596888743; cv=none; d=google.com; s=arc-20160816; b=wRFudN4yf6GaT7ixy4poUWJPDMGxOYpExHudrFNqdsC/dJqQDFNplnrMT8rhasxzKu VabsQEwMGIT7rZY/Nk6lEp1oEFk50V45grWGvnnpXzoxJGj8bayXFkHqSntP8dAWwyri 8FoayRLp1j7kOn+E9GSnWh44gqXLr6YXv0vXcWg6R7nkef0Na+kmtpc9XpyvUfvMWRNu W3evrrarSbWTk22ljDUnQBPtltJAm4VZ/mhkzYFVQVm7oCeK2/U7kKB0tT/DK3xs6Ud8 GBt+yiu/ZulOiVpceN2wkesmFzA4El0tHz3sLMHtfjewLSsprJZ7Di4QTmOnekee/8/i YUpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=aFE2vApEsxGQPxJ2aaE7mn5V0vaQd/4mHqKbbWgPqtI=; b=XL/+UNTEedR4nf2St8sUaEbJp60QJGHd/9/Su7XMxSX3ESdSc8h0ZMyMFpjMGltv5s 356Yd/S32RQiqb/2hQXQRCIlLDIPtRNpzo9B8syO0MhJuITu/OenHIebhZf9uUrxSOHY AHk2JSAzoqWOu2tgvYumvuKkR26PB/hXnIALX2he0fF9w5mlzO02mcH7OmWa2CjHN492 3zcrR8EQxXg39NWbYpQlyv47zWz+lXXjR83i1Vtss7IUT1IthXxBuDLCWVPBTtBTJT/C vrKZXAVMPLuORV5oDVvvDrivDqA1G0qteCZGLPjpGzr0n59So1D0pGcoyy72/0xmZYNX S3kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UKSq1rTl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f8si7070431edy.251.2020.08.08.05.11.24; Sat, 08 Aug 2020 05:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UKSq1rTl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726195AbgHHMJK (ORCPT + 99 others); Sat, 8 Aug 2020 08:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbgHHMJJ (ORCPT ); Sat, 8 Aug 2020 08:09:09 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70C08C061756 for ; Sat, 8 Aug 2020 05:09:09 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id r4so3966608wrx.9 for ; Sat, 08 Aug 2020 05:09:09 -0700 (PDT) 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; bh=aFE2vApEsxGQPxJ2aaE7mn5V0vaQd/4mHqKbbWgPqtI=; b=UKSq1rTl+v6j+60J1gtJbhNyrGzjwlgfuv7WmJujW6i/buxfIA8hgC+uIBSzb/7wUJ b9YH/41e3teu0+udooD+ijZr9c5DwzWZd+ohCxkoslP9GAgpXhKAsRIf4lklitSK4h/R zVZPT7xzV2e7pJezmLpO3C54cyjZ8MkSZ0I6jiZAjKiQNaPGMMvkuyIeNGxvuC2AhLpS ZDCFRY0ylhGCNsmigBd+xEEfUwSdIo3Ni12NHNWas09317QcvVvAXB2bgl8WAHQXe1HG e9++bxO/i1tMDWoLwTTuKBCAs7pK0WiusPa/4sE+Os+KbV30QR+YjgVxmsvkqhOMxSZT nIkA== 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; bh=aFE2vApEsxGQPxJ2aaE7mn5V0vaQd/4mHqKbbWgPqtI=; b=q8HW6QReU8oTv/VFCLj3cfwmOOyGEhsLeZOExEbG8HoCJuTdXq3wXWO7q4DwPSi8Uv xmpImTdgFLVHiuj5vJUF9KP/J1ICxPZL+J0aNyQzlDcT6zlDStPatu4FC+GxuehJl7HK N/CPEIJFv8wzViw6a90Igi06yDJRomSQymp4RJSJ9RYUF/yIwiAdt2AtVw+KmgmtR2MK o/jPQ9DEe8xEb3hprxvMFNgprm/jYFLWAKeG+k16GRwQSRIJVaUQp+0PVMTZIYwTGSSf V8jaR6VvdYPp/Snf8mEzrFXPuo5aDHLTDfcDrDS5p5BIvBxe5CIxLRbkrnJgkZPvROw1 tvOg== X-Gm-Message-State: AOAM530CU7RV4OTGVoocaRH2b6Q0okXBz9GQqY2FcymPBrPDjaR2cGhg VJJMA8/j08vEQMIQBfpbZDoa4Fjk8l8= X-Received: by 2002:a5d:5273:: with SMTP id l19mr16023674wrc.257.1596888547801; Sat, 08 Aug 2020 05:09:07 -0700 (PDT) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id v15sm14328847wrm.23.2020.08.08.05.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2020 05:09:07 -0700 (PDT) Date: Sat, 8 Aug 2020 09:09:00 -0300 From: Melissa Wen To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , David Airlie , Rodrigo Siqueira , Sidong Yang Cc: twoerner@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3] drm/vkms: guarantee vblank when capturing crc Message-ID: <20200808120900.pudwwrfz44g3rqx7@smtp.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org VKMS needs vblank interrupts enabled to capture CRC. When vblank is disabled, tests like kms_cursor_crc and kms_pipe_crc_basic getting stuck waiting for a capture that will not occur until vkms wakes up. This patch adds a helper to set composer and ensure that vblank remains enabled as long as the CRC capture is needed. It clears the execution of the following kms_cursor_crc subtests: 1. pipe-A-cursor-[size,alpha-opaque, NxN-(on-screen, off-screen, sliding, random, fast-moving])] - successful when running individually. 2. pipe-A-cursor-dpms passes again 3. pipe-A-cursor-suspend also passes The issue was initially tracked in the sequential execution of IGT kms_cursor_crc subtests: when running the test sequence or one of its subtests twice, the odd execs complete and the pairs get stuck in an endless wait. In the IGT code, calling a wait_for_vblank on preparing for CRC capture prevented the busy-wait. But the problem persisted in the pipe-A-cursor-dpms and -suspend subtests. Checking the history, the pipe-A-cursor-dpms subtest was successful when, in vkms_atomic_commit_tail, instead of using the flip_done op, it used wait_for_vblanks. Another way to prevent blocking was wait_one_vblank when enabling crtc. However, in both cases, pipe-A-cursor-suspend persisted blocking in the 2nd start of CRC capture, which may indicate that something got stuck in the step of CRC setup. Indeed, wait_one_vblank in the crc setup was able to sync things and free all kms_cursor_crc subtests. Besides, other alternatives to force enabling vblanks or prevent disabling them such as calling drm_crtc_put_vblank or modeset_enables before commit_planes + offdelay = 0, also unlock all subtests executions. Finally, due to vkms's dependence on vblank interruptions to perform tasks, this patch uses refcount to ensure that vblanks happen when enabling composer and while crc capture is needed. Cc: Rodrigo Siqueira Cc: Haneen Mohammed Co-debugged-by: Sidong Yang Signed-off-by: Sidong Yang Signed-off-by: Melissa Wen Reviewed-by: Daniel Vetter --- v2: - extract a vkms_set_composer helper - fix vblank refcounting for the disabling case v3: - make the vkms_set_composer helper static - review the credit tags --- drivers/gpu/drm/vkms/vkms_composer.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index b8b060354667..4f3b07a32b60 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -233,6 +233,22 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *src_name, return 0; } +static void vkms_set_composer(struct vkms_output *out, bool enabled) +{ + bool old_enabled; + + if (enabled) + drm_crtc_vblank_get(&out->crtc); + + spin_lock_irq(&out->lock); + old_enabled = out->composer_enabled; + out->composer_enabled = enabled; + spin_unlock_irq(&out->lock); + + if (old_enabled) + drm_crtc_vblank_put(&out->crtc); +} + int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) { struct vkms_output *out = drm_crtc_to_vkms_output(crtc); @@ -241,9 +257,7 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) ret = vkms_crc_parse_source(src_name, &enabled); - spin_lock_irq(&out->lock); - out->composer_enabled = enabled; - spin_unlock_irq(&out->lock); + vkms_set_composer(out, enabled); return ret; } -- 2.27.0