From patchwork Tue Oct 17 15:27:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10012285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80555602B3 for ; Tue, 17 Oct 2017 15:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6989C28938 for ; Tue, 17 Oct 2017 15:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E5D328942; Tue, 17 Oct 2017 15:27:28 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 29E1528938 for ; Tue, 17 Oct 2017 15:27:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B34D88220; Tue, 17 Oct 2017 15:27:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AA1C6E6C8 for ; Tue, 17 Oct 2017 15:27:22 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u138so4768114wmu.4 for ; Tue, 17 Oct 2017 08:27:22 -0700 (PDT) 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=9RZnT7+AIG/QiSIN4nNYO2yLs70Uz+u/8+suldtNsq8=; b=dU/XAqtP4+x4Wl11EoDjezQQ7Bgu/m234Y92nowg9YQ7nu/5TpbZgChb/FcXq6bbmu sRKuVPk2+1atF/GlgTVoZDVQyQ5S8bihp1vs+nIFaLzWOI0TextvOTCI2pneLo3/laY6 ZEJtgxJEQCjnNQREpCDy8Z9XtXbuIgb9wgatw= 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=9RZnT7+AIG/QiSIN4nNYO2yLs70Uz+u/8+suldtNsq8=; b=kci+Wg9JdEW87TLlShHeQEAmSn55zwNfRCBlEjjvzzjYl7ViYLOzey6SfWnadbxe8d wqHymHFaue9miwKusFg5jIdFfxA89tcH4nG2nRi2xFIu7V046n4xutiCb5MW9orfioJ/ dkVcPI4GLdESnzCI12cGJp+FQSZZzcclezRZ3XPk4CgqSe07n6FyO2Egnp5FTVeomhOh nGsZzV0epYiN3Bw3ZAYfjMgt33KRWIbSLKJ3aICghnf940k0SdBju1a9wjTpHuGiwkah Y9M6v+4FKOEgvUVPqlOItLcJkgB1BAxKJL0Gab1CkiJb0K06i+pTba1ZxUwpTninJMv3 Ugww== X-Gm-Message-State: AMCzsaVlDkeqEaz/EkGV14Drjc6SZ+zZ8VT6RROIS7wEPUzPth0hF1BL IpjMIoGdqwXmT28r7wv4esoC+eGP X-Google-Smtp-Source: AOwi7QCD9Av1iuV+SD9kV4OugkM6S7T3YIfXNsnc4UZ2NyeoDLnjW0Sou2E2sdLBgqPVgKwHQbuQiQ== X-Received: by 10.80.240.2 with SMTP id r2mr17177957edl.57.1508254040613; Tue, 17 Oct 2017 08:27:20 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id m1sm7065543edd.76.2017.10.17.08.27.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:27:19 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/atomic-helper: check that drivers call drm_crtc_vblank_off Date: Tue, 17 Oct 2017 17:27:14 +0200 Message-Id: <20171017152714.6849-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171017145939.438-1-daniel.vetter@ffwll.ch> References: <20171017145939.438-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP At least when they have vblank support they need to call this, or the vblank core will happily call into their crtc->enable_vblank callback even when the crtc is off. Which leads to a boom when the clocks are off on most hardware (besides the inevitable confusion in the book-keeping). The consistency checks in drm_vblank.c will then make sure that vblank_off/on calls are balanced, and if drivers forget to re-enable it all the commits will stall, so I think we're covered. It'd be nice to be able to place this check outside of commit helpers, but tha's not really possible (due to nonblocking commits and all that). Placing it into atomic helpers should at least cover most drivers. Also note that vblank support is still optional (for virtual drivers, which tend to not have this), check for that. v2: Fixup the handling for vblank_put (Rob). Cc: Rob Clark Tested-by: Rob Clark Cc: Ville Syrjälä Signed-off-by: Daniel Vetter Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ae56d91433ff..029c8c1d97f6 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -860,6 +860,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) { const struct drm_crtc_helper_funcs *funcs; + int ret; /* Shut down everything that needs a full modeset. */ if (!drm_atomic_crtc_needs_modeset(new_crtc_state)) @@ -883,6 +884,14 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) funcs->disable(crtc); else funcs->dpms(crtc, DRM_MODE_DPMS_OFF); + + if (!(dev->irq_enabled && dev->num_crtcs)) + continue; + + ret = drm_crtc_vblank_get(crtc); + WARN_ONCE(ret != -EINVAL, "driver forgot to call drm_crtc_vblank_off()\n"); + if (ret == 0) + drm_crtc_vblank_put(crtc); } }