From patchwork Sun Oct 2 21:06:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 9359791 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 7E94B601C0 for ; Sun, 2 Oct 2016 21:07:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F84328994 for ; Sun, 2 Oct 2016 21:07:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6451D289A1; Sun, 2 Oct 2016 21:07:03 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham 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 1CAE528994 for ; Sun, 2 Oct 2016 21:07:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5DB0389CF1; Sun, 2 Oct 2016 21:06:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 24B4989BF1; Sun, 2 Oct 2016 21:06:54 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id p138so11814008wmb.0; Sun, 02 Oct 2016 14:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=G3as1P2Tp8sZsCuEfqAICkpMprMVJfmKR4THb3k7CH0=; b=f5h9ycG8P/tbxP8Wu2KYkxczIQfniDMARtokf2Vfoix9N5eF7GiDWkyDS2+HRPQR+v 3AxkgvbrD7fqgJ2Ik+TVHvhZXG+0dzLVI4fKk/LbIllFP2Pjk+1bjGwBfc3Id5Hn9Dnb mCPnyjyBCto/446x6T4oFmD74nEhJXI4lxelMAWwtUdT4qP4jeVrHsJov1Fa4vzCRjBo sq4vMTwjahXKySPnUXUXpUacY9ZH9DkWKZqXdVq1WX3USkjR+hfYKGhFH/gMP5eAK+GU 85YFiIm5lA0cGAWMmpn7QtQsbrYs3jF60qm3UT0K3hVQ5B5Z/OnoNW15sd0iVghY6IlD D7Ww== 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; bh=G3as1P2Tp8sZsCuEfqAICkpMprMVJfmKR4THb3k7CH0=; b=iC78gWwLw5k4HL6uDsvjOq0835qxN8iWUOG0CkEWNuKx3RzeM73dU7dd7TEkeRsvH+ WFkCkd/D6yEo+uPVzdSWgKrFppBJEsO8YOG04sE+zc7DS2LqsoAWSXErnmvlqx1O2pee 2opFv16etn1GGWKgXUVUkMFy/JwdsubrZ5AGJGlrKkT8RvjGpkwcSefzxeZG8Q1R8VtR FhL/nRHVSBCa2lHCfhnk693Sr1v3Y078KRj/ziWCuXZOHYw6RHGO4b1W3UV2vAi1tQMH unfz3BBwtacacooNOBEpqD/HsUDGFHQJntKzomC8hlMPPjrHU6i4smWepEWF0x5S9Hxk MgnA== X-Gm-Message-State: AA6/9RmLJJIS/y9GlbIIkuOUSAv5ZPMgsw/3LvY4U5FsgzR/pmslKIdlUp8+nynqg/ZZNQ== X-Received: by 10.28.216.202 with SMTP id p193mr7137773wmg.82.1475442412681; Sun, 02 Oct 2016 14:06:52 -0700 (PDT) Received: from localhost.localdomain ([5.20.238.37]) by smtp.gmail.com with ESMTPSA id m140sm744716wma.21.2016.10.02.14.06.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Oct 2016 14:06:52 -0700 (PDT) From: Grazvydas Ignotas To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH] drm/amdgpu: warn if dp aux is still attached on free Date: Mon, 3 Oct 2016 00:06:46 +0300 Message-Id: <1475442406-2096-3-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 2.7.4 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-Virus-Scanned: ClamAV using ClamSMTP If this happens (and it recently did), we free a structure while part of it is still in use, which results in non-obvious crashes. The way it's detached is not trivial (DRM core has to call the connector .destroy callback and things must be torn down in the right order), so better detect it and warn early. Signed-off-by: Grazvydas Ignotas --- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c index ff0b55a..76a7830 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c @@ -769,8 +769,10 @@ static void amdgpu_connector_destroy(struct drm_connector *connector) { struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); - if (amdgpu_connector->ddc_bus->has_aux) + if (amdgpu_connector->ddc_bus->has_aux) { drm_dp_aux_unregister(&amdgpu_connector->ddc_bus->aux); + amdgpu_connector->ddc_bus->has_aux = false; + } amdgpu_connector_free_edid(connector); kfree(amdgpu_connector->con_priv); drm_connector_unregister(connector); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c index 34bab61..91d3673 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c @@ -220,6 +220,7 @@ void amdgpu_i2c_destroy(struct amdgpu_i2c_chan *i2c) { if (!i2c) return; + WARN_ON(i2c->has_aux); i2c_del_adapter(&i2c->adapter); kfree(i2c); }