From patchwork Fri Oct 5 10:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 148171 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp253593lji; Fri, 5 Oct 2018 03:15:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV61gYIUOate+twXPuS6XHIpMg06VwoGn4aGZ2BG8ZwvMTQZ+Qmq2775EoRnc+hHXuivd4938 X-Received: by 2002:a17:902:28a2:: with SMTP id f31-v6mr10877242plb.312.1538734505187; Fri, 05 Oct 2018 03:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538734505; cv=none; d=google.com; s=arc-20160816; b=SdWENxS3FsYz8lJg5DuTfrAEKFj2WSXO+RjdXHePDVKU/eSze+2LYByOPBCk8uRrGK NIuzkoKfcM/zNHLUvkh8EBbCGhuhmt3hLX2eSWrbviG4RWD/OgbTX7IMy6sQqf6TZ8CG xGzv3YyDDuC3wcSzAOvdkaj+hLyswDK7iXRojAj0ChziH9Ku98SJ3jdpiuFRImte5Z5p k14iLsfCMU9VwmdK5gkLFhOgJXUKMeE1G376neCQ1o1PtTSupL1zP4q4mdTsomM4lMxI ZZqiPl6FKyrGPjSC3drTWIAa0t92zSVUZVAMV/0kwkHtqY3rtuD2zg/P+mQKEdUovF0R qchw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:to:from:delivered-to; bh=ygE5hQq2E2vy8gvHjzz4ABqVv09nrioMFcD708ZEJkc=; b=tjqcVhKE1LsGoIwYwlTPyf3ZK+0SaX/8rjxlSTKjQOgeNupkZyHBvNK1mIcKvZtyHk secn5CIcMQwHzbnlkkoM1RcpFYHo71CplDYr8OIdsANI1ARe0/OyE/SUy0HPnHr2MAJY bXd9Sryv58qrzYajXwhOZHF8au+SfsX/2Dgyvk/qy0Rnx1MROid5kjzRsRMR7QDLHB7m h8QBZJKcQZCgNf0YqvC8jCVPGWTvitnspMeDgbZO/uJEPCBSpfCSeaqe/YuraRKBjgF4 OAzRPDKaEVJEl68uLw2xhUAlGl2/w7v7V4crZQ1Ep/LUqn1mk2gZWGlBSr+yfZpQse0J sMqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id n23-v6si7987292plp.77.2018.10.05.03.15.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 03:15:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B15C86E796; Fri, 5 Oct 2018 10:14:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF7DE89CB3 for ; Fri, 5 Oct 2018 10:14:30 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id d2-v6so8522839wro.7 for ; Fri, 05 Oct 2018 03:14:30 -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:mime-version :content-transfer-encoding; bh=XT9lNPm0fqKWE3RHa7FS/l3Cumv3v0pIP0MTF7eKDJI=; b=Ttfhxnx0sEw12v7+NWIt3a6OmIfrNWgl8+Rf996CVkUBoA0okYrowtCFbHaSY4Bs52 8KVEI985NU+1qlRrMJg4OVdn0Ac5magfO4ZfSOyPAEuC6rYF8sL39JiG29H2kA2kzR/u 5qo+snuhyhhEDZmVap0XzZGvDvaOKPTVynY5xR4fZ+aMGl2ISH5QNMEn1mcml8Dgfoql 6bbfKnil29b/a0zAiHY7XlZEXslSU9PmHTPBXwI0I8WcJe5AN+dmccSLJKWPXzsDAgVP 8Zh1sxOKVVHtcic/ZfvbsfRCGQVo3OFIVdnqqHWJHZN4rSySZdaMXHJgccZ9FDRYZF7/ sTXQ== X-Gm-Message-State: ABuFfohjZeTEK80OJLdn5I92zYF0WCQKXm9D+seICACHmWdV1HSDHljf f3X1JBpgYTahpSNQNO6LrlRUqRRKd0DyRQ== X-Received: by 2002:a5d:4949:: with SMTP id r9-v6mr7407919wrs.114.1538734469054; Fri, 05 Oct 2018 03:14:29 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([2a04:cec0:1008:d071:dcae:aefd:9aca:ca7a]) by smtp.gmail.com with ESMTPSA id v6-v6sm4551062wrr.60.2018.10.05.03.14.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Oct 2018 03:14:28 -0700 (PDT) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, vincent.abriou@st.com, ville.syrjala@linux.intel.com Subject: [PATCH 12/21] drm/sti: Use drm_atomic_helper_shutdown Date: Fri, 5 Oct 2018 12:14:20 +0200 Message-Id: <20181005101420.31680-1-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.15.0 MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Daniel Vetter drm_plane_helper_disable is a non-atomic drivers only function, and will blow up (since no one passes the locking context it needs). Atomic drivers which want to quiescent their hw on unload should use drm_atomic_helper_shutdown() instead. The sti cleanup code seems supremely confused: - In the load error path it calls drm_mode_config_cleanup before it stops various kms services like poll worker or fbdev emulation. That's going to oops. - The actual unload code doesn't even bother with the cleanup and just leaks. Try to fix this while at it. Signed-off-by: Daniel Vetter Complements original patch after testing on board. Signed-off-by: Benjamin Gaignard Cc: Vincent Abriou Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/sti/sti_crtc.c | 2 ++ drivers/gpu/drm/sti/sti_cursor.c | 10 +--------- drivers/gpu/drm/sti/sti_drv.c | 6 +++--- drivers/gpu/drm/sti/sti_gdp.c | 10 +--------- drivers/gpu/drm/sti/sti_hqvdp.c | 10 +--------- drivers/gpu/drm/sti/sti_tvout.c | 24 ------------------------ 6 files changed, 8 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c index 5824e6aca8f4..61c2379fba87 100644 --- a/drivers/gpu/drm/sti/sti_crtc.c +++ b/drivers/gpu/drm/sti/sti_crtc.c @@ -40,6 +40,8 @@ static void sti_crtc_atomic_disable(struct drm_crtc *crtc, DRM_DEBUG_DRIVER("\n"); mixer->status = STI_MIXER_DISABLING; + + drm_crtc_wait_one_vblank(crtc); } static int diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c index 57b870e1e696..e1ba253055c7 100644 --- a/drivers/gpu/drm/sti/sti_cursor.c +++ b/drivers/gpu/drm/sti/sti_cursor.c @@ -328,14 +328,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { .atomic_disable = sti_cursor_atomic_disable, }; -static void sti_cursor_destroy(struct drm_plane *drm_plane) -{ - DRM_DEBUG_DRIVER("\n"); - - drm_plane_helper_disable(drm_plane, NULL); - drm_plane_cleanup(drm_plane); -} - static int sti_cursor_late_register(struct drm_plane *drm_plane) { struct sti_plane *plane = to_sti_plane(drm_plane); @@ -347,7 +339,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane) static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_cursor_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index 6dced8abcf16..ac54e0f9caea 100644 --- a/drivers/gpu/drm/sti/sti_drv.c +++ b/drivers/gpu/drm/sti/sti_drv.c @@ -206,6 +206,8 @@ static void sti_cleanup(struct drm_device *ddev) struct sti_private *private = ddev->dev_private; drm_kms_helper_poll_fini(ddev); + drm_atomic_helper_shutdown(ddev); + drm_mode_config_cleanup(ddev); component_unbind_all(ddev->dev, ddev); kfree(private); ddev->dev_private = NULL; @@ -230,7 +232,7 @@ static int sti_bind(struct device *dev) ret = drm_dev_register(ddev, 0); if (ret) - goto err_register; + goto err_cleanup; drm_mode_config_reset(ddev); @@ -238,8 +240,6 @@ static int sti_bind(struct device *dev) return 0; -err_register: - drm_mode_config_cleanup(ddev); err_cleanup: sti_cleanup(ddev); err_drm_dev_put: diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c index c32de6cbf061..87b50451afd7 100644 --- a/drivers/gpu/drm/sti/sti_gdp.c +++ b/drivers/gpu/drm/sti/sti_gdp.c @@ -879,14 +879,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { .atomic_disable = sti_gdp_atomic_disable, }; -static void sti_gdp_destroy(struct drm_plane *drm_plane) -{ - DRM_DEBUG_DRIVER("\n"); - - drm_plane_helper_disable(drm_plane, NULL); - drm_plane_cleanup(drm_plane); -} - static int sti_gdp_late_register(struct drm_plane *drm_plane) { struct sti_plane *plane = to_sti_plane(drm_plane); @@ -898,7 +890,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane) static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_gdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index 03ac3b4a4469..065a5b08a702 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -1256,14 +1256,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { .atomic_disable = sti_hqvdp_atomic_disable, }; -static void sti_hqvdp_destroy(struct drm_plane *drm_plane) -{ - DRM_DEBUG_DRIVER("\n"); - - drm_plane_helper_disable(drm_plane, NULL); - drm_plane_cleanup(drm_plane); -} - static int sti_hqvdp_late_register(struct drm_plane *drm_plane) { struct sti_plane *plane = to_sti_plane(drm_plane); @@ -1275,7 +1267,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane) static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = sti_hqvdp_destroy, + .destroy = drm_plane_cleanup, .reset = sti_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c index ea4a3b87fa55..4dc3b2ec40eb 100644 --- a/drivers/gpu/drm/sti/sti_tvout.c +++ b/drivers/gpu/drm/sti/sti_tvout.c @@ -788,21 +788,6 @@ static void sti_tvout_create_encoders(struct drm_device *dev, tvout->dvo = sti_tvout_create_dvo_encoder(dev, tvout); } -static void sti_tvout_destroy_encoders(struct sti_tvout *tvout) -{ - if (tvout->hdmi) - drm_encoder_cleanup(tvout->hdmi); - tvout->hdmi = NULL; - - if (tvout->hda) - drm_encoder_cleanup(tvout->hda); - tvout->hda = NULL; - - if (tvout->dvo) - drm_encoder_cleanup(tvout->dvo); - tvout->dvo = NULL; -} - static int sti_tvout_bind(struct device *dev, struct device *master, void *data) { struct sti_tvout *tvout = dev_get_drvdata(dev); @@ -815,17 +800,8 @@ static int sti_tvout_bind(struct device *dev, struct device *master, void *data) return 0; } -static void sti_tvout_unbind(struct device *dev, struct device *master, - void *data) -{ - struct sti_tvout *tvout = dev_get_drvdata(dev); - - sti_tvout_destroy_encoders(tvout); -} - static const struct component_ops sti_tvout_ops = { .bind = sti_tvout_bind, - .unbind = sti_tvout_unbind, }; static int sti_tvout_probe(struct platform_device *pdev)