From patchwork Fri Jun 14 22:13:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2725241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F3D0DC0AB1 for ; Fri, 14 Jun 2013 22:17:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2328F2018C for ; Fri, 14 Jun 2013 22:17:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 36C052014D for ; Fri, 14 Jun 2013 22:17:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47F38E5C8A for ; Fri, 14 Jun 2013 15:17:29 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id D28E9E5E11 for ; Fri, 14 Jun 2013 15:13:30 -0700 (PDT) Received: by mail-ee0-f49.google.com with SMTP id b57so624211eek.22 for ; Fri, 14 Jun 2013 15:13:29 -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:x-mailer:in-reply-to:references; bh=7nrI6Su7bvhvvtDMK/S6J9ZGm3+ZvERBoW7+6itg5Qo=; b=RyJr7Lo/6sYlOn5XBDx+VHdTutM8qsxY5xWd2RK1e5ddeljApxvva6PwM+epcSRNF+ x5f4Rqrpe0HIPPXq1PdWr/GZX9vNAHzdZFo9NbqeBWi0No0gjj2j58/TEelcGhKHz6Mk i2vyrgbbZepHGgy4YBKQbyf69arBo/An+VDzg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=7nrI6Su7bvhvvtDMK/S6J9ZGm3+ZvERBoW7+6itg5Qo=; b=BsZa/bt6Cfo+4x5rfO6XIS6Ex8yXdL+NNzg6lak62sToxyLlcOp1Bn7UtaySEmywLz jz0SMHTm8p6m2FC4M5dxXvwCvT0iBSnSXZwhdr2c2+nJbaecsor04eQT0pHQJjbAwUca 5cM6VnyGchWyUXG2M5ihtrkywaVAquLOmO9rYNWn2NB07L+tAU2PuFql6rkJ3R5kM5eY +Pkm9G0Mrb1fOFhYVB+qAS3wT8952/rx8GmDO8eMQNYjwtIOadES8WQHopfKs/pKIF6R 9zJzHJTHSh6iAcPPpFpaMexJB8oWpohIZZ2fcTfLfAVLbRFnz5P05vCheAKlO82DJsQy gJ1w== X-Received: by 10.14.213.135 with SMTP id a7mr4040830eep.152.1371248009744; Fri, 14 Jun 2013 15:13:29 -0700 (PDT) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id m1sm6258301eex.17.2013.06.14.15.13.28 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Jun 2013 15:13:29 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 5/6] drm: check that ->set_config properly updates the fb Date: Sat, 15 Jun 2013 00:13:15 +0200 Message-Id: <1371247996-6052-6-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371247996-6052-1-git-send-email-daniel.vetter@ffwll.ch> References: <1371247996-6052-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQmvqTNFAZS+erVmjq/T4BPklaMIv1k/GE3mVAzFV7eJCmHdHjfZ5tGU7Aw6PjHCp/h2TdwJ Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Historically drm lacked fb refcounting, so the updating of crtc->fb was done by the lower levels at a point convenient to get their own refcounting (e.g. refcounts for the underlying gem bo, pinning refcounts) right. With the introduction of refcounted fbs the drm core handled the fb refcounts, but still relied on drivers to update the crtc->fb pointer (this approach required the least invasive changes in drivers). Enforce this contract with a WARN_ON. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_crtc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index baee575..bcee25a 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1939,6 +1939,9 @@ int drm_mode_set_config_internal(struct drm_mode_set *set) ret = crtc->funcs->set_config(set); if (ret == 0) { + /* crtc->fb must be updated by ->set_config, enforces this. */ + WARN_ON(fb != crtc->fb); + if (old_fb) drm_framebuffer_unreference(old_fb); if (fb)