From patchwork Mon Mar 7 22:00:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8523291 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 AB5A79F2B4 for ; Mon, 7 Mar 2016 22:01:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BB892022D for ; Mon, 7 Mar 2016 22:01:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B24102020F for ; Mon, 7 Mar 2016 22:01:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A7216E430; Mon, 7 Mar 2016 22:01:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-x233.google.com (mail-pa0-x233.google.com [IPv6:2607:f8b0:400e:c03::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id 122876E42D for ; Mon, 7 Mar 2016 22:01:23 +0000 (UTC) Received: by mail-pa0-x233.google.com with SMTP id fy10so85328990pac.1 for ; Mon, 07 Mar 2016 14:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KLLU+ddyc7axaruYHTVryEuBSsAA48p03GmhjZCwFBQ=; b=QQkipmtc18GoNfpHEnBhIU5sdImOruEsUI30DJ7yaCW4vKdRs1bMa5AwQvxXV21VGk dmP2iNEXfuEHL3PSoTpKZDgpLF8F9RQnIQ+ZkxJngr6I0OVu5xFRuEZEdf9tSYn2I1pw 8OapzA0OaY4vUUyWqE0L238shAKPSel2pBnZk= 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=KLLU+ddyc7axaruYHTVryEuBSsAA48p03GmhjZCwFBQ=; b=SNm4X13E/8sdBu9n152BG/F8UCCjY+i9GjryzWq+u66FEaTStlhVe6u6AoqNEn3c9Q sKks1bF/J84VgHHBTMHCGAvX0LRJSHS6KotAXK35t4rJyu+uoz07/MPN+BeZoO/E+uOm WaJ1zMxqZ+836ORESE3D1bJ+NN0m5QAZoMeE9Mzeu2C0U9dsZw3+mhmm2LhAVok1kmpj Bj5Qocg6sx+duPKj5PrWdYO5GlPXSOg7JxcvXV/O4viyZz7zXcNfdR7R2t7MQs/xglGy 9iFUroihNRTghqp2irbkURyC7hSSPtWsXrOo7sqxQrgSRmsAnl0hQT9v+zVm7rB44eDl lpZg== X-Gm-Message-State: AD7BkJJU6COaj1eadPKeT1y3j+C/Stux16MR3pGBwPf2g64UOnVP8YWks4agEe1c2AGUdQ== X-Received: by 10.66.144.4 with SMTP id si4mr37013397pab.0.1457388082212; Mon, 07 Mar 2016 14:01:22 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id p26sm19964195pfi.84.2016.03.07.14.01.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Mar 2016 14:01:21 -0800 (PST) From: Douglas Anderson To: Mark Yao , David Airlie , linux@arm.linux.org.uk, Heiko Stuebner Subject: [PATCH v2 3/5] drm/rockchip: vop: Fix vop crtc cleanup Date: Mon, 7 Mar 2016 14:00:52 -0800 Message-Id: <1457388054-23077-3-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1457388054-23077-1-git-send-email-dianders@chromium.org> References: <1457388054-23077-1-git-send-email-dianders@chromium.org> Cc: john@keeping.me.uk, Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org 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.1 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 This fixes a few problems in the vop crtc cleanup (handling error paths and cleanup upon exit): * The vop_create_crtc() error path had an unsafe version of the iterator used for iterating over all planes (though it was destroying planes in the iterator so should have used the safe version) * vop_destroy_crtc() - wasn't calling vop_plane_destroy(), which made slub_debug unhappy, at least if we ended up running this due to a deferred probe. * In vop_create_crtc() if we were missing the "port" device tree node we would fail but not return an error (found by code inspection). Fix these problems. Signed-off-by: Douglas Anderson --- Changes in v2: None drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index fd370548d7d7..f86f797f10fd 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1108,7 +1108,7 @@ static int vop_create_crtc(struct vop *vop) const struct vop_data *vop_data = vop->data; struct device *dev = vop->dev; struct drm_device *drm_dev = vop->drm_dev; - struct drm_plane *primary = NULL, *cursor = NULL, *plane; + struct drm_plane *primary = NULL, *cursor = NULL, *plane, *tmp; struct drm_crtc *crtc = &vop->crtc; struct device_node *port; int ret; @@ -1148,7 +1148,7 @@ static int vop_create_crtc(struct vop *vop) ret = drm_crtc_init_with_planes(drm_dev, crtc, primary, cursor, &vop_crtc_funcs, NULL); if (ret) - return ret; + goto err_cleanup_planes; drm_crtc_helper_add(crtc, &vop_crtc_helper_funcs); @@ -1181,6 +1181,7 @@ static int vop_create_crtc(struct vop *vop) if (!port) { DRM_ERROR("no port node found in %s\n", dev->of_node->full_name); + ret = -ENOENT; goto err_cleanup_crtc; } @@ -1194,7 +1195,8 @@ static int vop_create_crtc(struct vop *vop) err_cleanup_crtc: drm_crtc_cleanup(crtc); err_cleanup_planes: - list_for_each_entry(plane, &drm_dev->mode_config.plane_list, head) + list_for_each_entry_safe(plane, tmp, &drm_dev->mode_config.plane_list, + head) drm_plane_cleanup(plane); return ret; } @@ -1202,9 +1204,28 @@ err_cleanup_planes: static void vop_destroy_crtc(struct vop *vop) { struct drm_crtc *crtc = &vop->crtc; + struct drm_device *drm_dev = vop->drm_dev; + struct drm_plane *plane, *tmp; rockchip_unregister_crtc_funcs(crtc); of_node_put(crtc->port); + + /* + * We need to cleanup the planes now. Why? + * + * The planes are "&vop->win[i].base". That means the memory is + * all part of the big "struct vop" chunk of memory. That memory + * was devm allocated and associated with this component. We need to + * free it ourselves before vop_unbind() finishes. + */ + list_for_each_entry_safe(plane, tmp, &drm_dev->mode_config.plane_list, + head) + vop_plane_destroy(plane); + + /* + * Destroy CRTC after vop_plane_destroy() since vop_disable_plane() + * references the CRTC. + */ drm_crtc_cleanup(crtc); }