From patchwork Thu Jul 2 13:16:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 6709081 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7864D9F380 for ; Thu, 2 Jul 2015 13:14:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 857E220644 for ; Thu, 2 Jul 2015 13:14:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B37E02063B for ; Thu, 2 Jul 2015 13:13:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F01726E4B9; Thu, 2 Jul 2015 06:13:56 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id DBAB26E229 for ; Thu, 2 Jul 2015 06:13:55 -0700 (PDT) Received: by wiga1 with SMTP id a1so152524973wig.0 for ; Thu, 02 Jul 2015 06:13:54 -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; bh=3d2N9qECVBi+HRVbO45Kk83/NvWy+AqWp5ivrp4yG0Q=; b=UknZv3+R+BUFYRa7vgPzMnS2/RoLSA5hAmH9IwbMkSXByFxYhBRcWufy49miauBoHF GNVAEVsylPabe0Q6TQczmxi1f7Frp0wh4kmOsL845U4I//G2eujIdC4diaq9XxalaYqR LN7rPWmaRWmD1CIHY5KpaiMSfsXjl1l/jQhtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3d2N9qECVBi+HRVbO45Kk83/NvWy+AqWp5ivrp4yG0Q=; b=M6dQ7Yrg92BeBjUw1OJNs/ZBs/KR/npCJ/v44vyaqJCmwao394q+iBlhASDn6LCAFS vCJ/obvb599Ii3o1bNkw6aOgBZGdY6aORAand7+NJS1seX3Oml2Z2ZzEMzgfipHF3fVf 7m1heYSh65bGdOWmE5fVmBuPfQymYq6XBz0Poebh+fpUVrkm2qJ+jUmoWf1CRM/ctv2l vA5cSuyPTJ8fACARpPNH7IjjhjCwUhfkq6RJNEId8vTFwWJ68QpO9izQZKBhY5OvfW3a bF+G9/o7L0tBK9vwSSi9tapWYeSufw2umjNDbfNbUCKT+MXV90LL9FXWH3uxh77DwWO7 wTew== X-Gm-Message-State: ALoCoQkKDBPS8N67nI8G8Pi1saKHgqN7/12MIaeKoT39M8OpBqallCum5020PgaMFeAfMXVjTa4o X-Received: by 10.194.2.228 with SMTP id 4mr1031292wjx.146.1435842834131; Thu, 02 Jul 2015 06:13:54 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by mx.google.com with ESMTPSA id ej5sm8141380wjd.22.2015.07.02.06.13.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Jul 2015 06:13:52 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/crtc-helper: Fixup error handling in drm_helper_crtc_mode_set Date: Thu, 2 Jul 2015 15:16:39 +0200 Message-Id: <1435842999-25699-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435821829-11107-1-git-send-email-daniel.vetter@ffwll.ch> References: <1435821829-11107-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Stone , Daniel Vetter , Intel Graphics Development , Daniel Vetter , John Hunter 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 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 In commit 9f658b7b62e7aefc1ee067136126eca3f58cabfd Author: Daniel Stone Date: Fri May 22 13:34:45 2015 +0100 drm/crtc_helper: Replace open-coded CRTC state helpers error handling code was broken, resulting in the first path not being checked correctly. Fix this by using the same pattern as in the transitional plane helper function drm_plane_helper_update. v2: Simplify the cleanup code while at it too. v3: After some debugging with John we realized that the above patch from Daniel also accidentally removed the if (crtc_state) check. This is legal when transitioning to atomic, when the initial state reset isn't all wired up yet properly. Reinstate that check to fix the bug John has hit. Cc: Daniel Stone CC: Sean Paul Cc: John Hunter Reported-by: John Hunter Signed-off-by: Daniel Vetter Tested-by: Zhao Junwang --- drivers/gpu/drm/drm_crtc_helper.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 393114df88a3..93104f3555f5 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -927,15 +927,13 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod if (crtc->funcs->atomic_duplicate_state) crtc_state = crtc->funcs->atomic_duplicate_state(crtc); - else { + else if (crtc->state) + crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc); + else crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL); - if (!crtc_state) - return -ENOMEM; - if (crtc->state) - __drm_atomic_helper_crtc_duplicate_state(crtc, crtc_state); - else - crtc_state->crtc = crtc; - } + + if (!crtc_state) + return -ENOMEM; crtc_state->planes_changed = true; crtc_state->mode_changed = true; @@ -957,11 +955,11 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod ret = drm_helper_crtc_mode_set_base(crtc, x, y, old_fb); out: - if (crtc->funcs->atomic_destroy_state) - crtc->funcs->atomic_destroy_state(crtc, crtc_state); - else { - __drm_atomic_helper_crtc_destroy_state(crtc, crtc_state); - kfree(crtc_state); + if (crtc_state) { + if (crtc->funcs->atomic_destroy_state) + crtc->funcs->atomic_destroy_state(crtc, crtc_state); + else + drm_atomic_helper_crtc_destroy_state(crtc, crtc_state); } return ret;