From patchwork Thu Jun 6 22:27:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10980529 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 CAD2714B6 for ; Thu, 6 Jun 2019 22:28:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9DA0200E5 for ; Thu, 6 Jun 2019 22:28:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE1E528942; Thu, 6 Jun 2019 22:28:20 +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,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 5F7C6200E5 for ; Thu, 6 Jun 2019 22:28:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5CACC89A34; Thu, 6 Jun 2019 22:28:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BCF4899E8 for ; Thu, 6 Jun 2019 22:28:09 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id r18so5537422edo.7 for ; Thu, 06 Jun 2019 15:28:09 -0700 (PDT) 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=mdVHhUEPyQ3YdnuuaIrRM+1lqOhVXRdBLWwFQABWNbM=; b=at7JMbS8vsnTGDqRaEs7mMNhyHbI7STHe8t/EUNQjNgCvBdt8YV51sMtiVXm2BSR4Y GL1rnKxDOtRETPNjRQ1p/5WMxHmRjWNIVJR9HFYgZQ7eJzws90uoynLX4op9SzokOklo wxaFBukIbRmDDhLl2x3KstZlamHuEBG5t+7Vn3JkhAFVQKLt24I12flNjzgbYc+UVsD1 iKQ8LhvMCYLY6NpN7UsPIVcLZT7t5hQlkJO99qpdguNO5j6cLlm4oDTA+9P2pYRhyJYb OC5tPbWbu8OyZ+vFoaUHG4rQXt//espkKpW1l3VzsNEdk9gsWjVRUnVzhcv+KRISm7iu 1yhg== X-Gm-Message-State: APjAAAVvWpH+jblpBguh7zCOzJtoSeSDHkjcnLpKF8EWd6uVQ49PazD8 0l4zfHPwudOjP7U+aYFPN5zghKNgOGg= X-Google-Smtp-Source: APXvYqwxZ0Rl/42tVCOCz3MdpjTDestlIY3cHmMG+jrJD6I8PhxJobTwdOz4B02m/CzeV3airKQQww== X-Received: by 2002:a05:6402:150c:: with SMTP id f12mr51244807edw.234.1559860087744; Thu, 06 Jun 2019 15:28:07 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id z10sm54228edl.35.2019.06.06.15.28.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 06 Jun 2019 15:28:07 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 06/10] drm/vkms: flush crc workers earlier in commit flow Date: Fri, 7 Jun 2019 00:27:47 +0200 Message-Id: <20190606222751.32567-7-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190606222751.32567-1-daniel.vetter@ffwll.ch> References: <20190606222751.32567-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mdVHhUEPyQ3YdnuuaIrRM+1lqOhVXRdBLWwFQABWNbM=; b=BMN8rgqvpGhXpEHZY6vKA/51RBWX6x7t+aEHgdzMCZrvkWN9Hetl/UiKVZ+JLJOCQY aT56iqwocVufQWVy2+V22ljvYT2JLSJ+OWEWCoFIMMa7PGysillX0Qzc2gfCeu3pbHxP k3rkQDavg+kv5tL7XxUK5HDwWB3YYohhh14jE= 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: Daniel Vetter , Haneen Mohammed , Rodrigo Siqueira , Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently we flush pending crc workers very late in the commit flow, when we destry all the old crtc states. Unfortunately at that point the framebuffers are already unpinned (and our vaddr possible gone), so this isn't good. Also, the plane_states we need might also already be cleaned up, since cleanup order of state structures isn't well defined. Fix this by waiting for all crc workers of the old state to complete before we start any of the cleanup work. Note that this is not yet race-free, because the hrtimer and crc worker look at the wrong state pointers, but that will be fixed in subsequent patches. Signed-off-by: Daniel Vetter Cc: Rodrigo Siqueira Cc: Haneen Mohammed Cc: Daniel Vetter --- drivers/gpu/drm/vkms/vkms_crtc.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 55b16d545fe7..b6987d90805f 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -125,7 +125,7 @@ static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc, __drm_atomic_helper_crtc_destroy_state(state); if (vkms_state) { - flush_work(&vkms_state->crc_work); + WARN_ON(work_pending(&vkms_state->crc_work)); kfree(vkms_state); } } diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index f677ab1d0094..cc53ef88a331 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -62,6 +62,9 @@ static void vkms_release(struct drm_device *dev) static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) { struct drm_device *dev = old_state->dev; + struct drm_crtc *crtc; + struct drm_crtc_state *old_crtc_state; + int i; drm_atomic_helper_commit_modeset_disables(dev, old_state); @@ -75,6 +78,13 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) drm_atomic_helper_wait_for_vblanks(dev, old_state); + for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) { + struct vkms_crtc_state *vkms_state = + to_vkms_crtc_state(old_crtc_state); + + flush_work(&vkms_state->crc_work); + } + drm_atomic_helper_cleanup_planes(dev, old_state); }