From patchwork Thu Jan 7 13:30:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 59279 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp551242lbb; Thu, 7 Jan 2016 05:31:03 -0800 (PST) X-Received: by 10.66.156.106 with SMTP id wd10mr151162999pab.150.1452173463126; Thu, 07 Jan 2016 05:31:03 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id wl2si41802838pab.236.2016.01.07.05.31.02; Thu, 07 Jan 2016 05:31:03 -0800 (PST) Received-SPF: pass (google.com: 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: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D9196E66F; Thu, 7 Jan 2016 05:31:02 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 38DDF6E66D for ; Thu, 7 Jan 2016 05:31:00 -0800 (PST) Received: by mail-wm0-f46.google.com with SMTP id b14so123391693wmb.1 for ; Thu, 07 Jan 2016 05:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nlYwE14fSWWNNBv9dDm29b3H8F0qIuKAZ5duwFBs+z8=; b=PCPLlrh74kpDfLeEUpVO2Q0ZB3vnFTSekhpj5BMiTpSosPRZwMYJGJs/IzSEjm0En/ hOw1or1/vhYXENHysRb5r9BRHhg5Hbs4pL2OBDx3CKLB/R7lxFiy3lpGj40fePcy8+Ub xOHVFFA/PTFmgz95yRzpwjvCOuxmshuiEhymc= 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=nlYwE14fSWWNNBv9dDm29b3H8F0qIuKAZ5duwFBs+z8=; b=L/RCtV5gFi2k+VfUDpIYv3dvwmvzwUM8XRLQEUIl/CQzZnk/IqURoJV8fW7u4PrRfK now0v5fUybe9l9TtdOC64d7Xx9y7aCx6NYBK7H71LaXURbMvE/vTKtmC61cxJOl9jzK/ RmqYJIcyPAPxIxpSknqLEzgBwS386+6hIKjy94B/pshiTCUe8HNFnVUoD9pNqpqu2LvJ IAxb2CnZ3O9Y/zOrwnqpqEoOnAkzDnWjg4u7s0fpmA4iJ6QmUZ4ncjO5zL/vIhipEIZX mNvcmiQNtmUzkKcKPFVGiYdWVmicXNVyEEPvfgZo7urnEeFYcChlAn5kIVXv4v3BGa3y VQCg== X-Gm-Message-State: ALoCoQnHu0b10hwBPzeHevtI1aJ9ngkhuHykhLsaK27rvieYkFuLZ/VbBsZParTFVaCpIb1w7NarEuxSE0nc3hBMOkkBLDd+Bw== X-Received: by 10.194.87.170 with SMTP id az10mr112650368wjb.144.1452173458877; Thu, 07 Jan 2016 05:30:58 -0800 (PST) Received: from LMENX321.lme.st.com (LPuteaux-656-1-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by smtp.gmail.com with ESMTPSA id i2sm11863922wjx.42.2016.01.07.05.30.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jan 2016 05:30:57 -0800 (PST) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, vincent.abriou@st.com, fabien.dessenne@st.com Subject: [PATCH 1/5] drm: sti: fix potential crash in gdp Date: Thu, 7 Jan 2016 14:30:37 +0100 Message-Id: <1452173441-30033-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452173441-30033-1-git-send-email-benjamin.gaignard@linaro.org> References: <1452173441-30033-1-git-send-email-benjamin.gaignard@linaro.org> Cc: Benjamin Gaignard 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" In some cases last_close() could be called before sti_gdp_disable() and make kernel crash because mixer structure has been destroy. Let's gdp keep a reference on vtg to fix that (like it is already done in HQVDP) Signed-off-by: Benjamin Gaignard --- drivers/gpu/drm/sti/sti_gdp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c index f9a1d92..990b28e 100644 --- a/drivers/gpu/drm/sti/sti_gdp.c +++ b/drivers/gpu/drm/sti/sti_gdp.c @@ -97,6 +97,7 @@ struct sti_gdp_node_list { * @vtg_field_nb: callback for VTG FIELD (top or bottom) notification * @is_curr_top: true if the current node processed is the top field * @node_list: array of node list + * @vtg: registered vtg */ struct sti_gdp { struct sti_plane plane; @@ -108,6 +109,7 @@ struct sti_gdp { struct notifier_block vtg_field_nb; bool is_curr_top; struct sti_gdp_node_list node_list[GDP_NODE_NB_BANK]; + struct sti_vtg *vtg; }; #define to_sti_gdp(x) container_of(x, struct sti_gdp, plane) @@ -240,9 +242,6 @@ end: */ static void sti_gdp_disable(struct sti_gdp *gdp) { - struct drm_plane *drm_plane = &gdp->plane.drm_plane; - struct sti_mixer *mixer = to_sti_mixer(drm_plane->crtc); - struct sti_compositor *compo = dev_get_drvdata(gdp->dev); unsigned int i; DRM_DEBUG_DRIVER("%s\n", sti_plane_to_str(&gdp->plane)); @@ -253,8 +252,7 @@ static void sti_gdp_disable(struct sti_gdp *gdp) gdp->node_list[i].btm_field->gam_gdp_ppt |= GAM_GDP_PPT_IGNORE; } - if (sti_vtg_unregister_client(mixer->id == STI_MIXER_MAIN ? - compo->vtg_main : compo->vtg_aux, &gdp->vtg_field_nb)) + if (sti_vtg_unregister_client(gdp->vtg, &gdp->vtg_field_nb)) DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n"); if (gdp->clk_pix) @@ -490,7 +488,10 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane, if (first_prepare) { /* Register gdp callback */ - if (sti_vtg_register_client(mixer->id == STI_MIXER_MAIN ? + gdp->vtg = mixer->id == STI_MIXER_MAIN ? + compo->vtg_main : compo->vtg_aux; + + if (sti_vtg_register_client(gdp->vtg == STI_MIXER_MAIN ? compo->vtg_main : compo->vtg_aux, &gdp->vtg_field_nb, crtc)) { DRM_ERROR("Cannot register VTG notifier\n");