From patchwork Thu Dec 24 09:10:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7915821 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 AE3679F318 for ; Thu, 24 Dec 2015 09:10:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18C1820601 for ; Thu, 24 Dec 2015 09:10:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EBAA205FE for ; Thu, 24 Dec 2015 09:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbbLXJKp (ORCPT ); Thu, 24 Dec 2015 04:10:45 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:39392 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753384AbbLXJKW (ORCPT ); Thu, 24 Dec 2015 04:10:22 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZU01GKSUT9LF40@mailout3.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 24 Dec 2015 18:10:21 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 27.EB.04972.D76BB765; Thu, 24 Dec 2015 18:10:21 +0900 (KST) X-AuditID: cbfee68e-f793c6d00000136c-51-567bb67d4263 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id AB.DE.13906.D76BB765; Thu, 24 Dec 2015 18:10:21 +0900 (KST) Received: from localhost.localdomain ([10.113.62.206]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NZU008CAUT3RX30@mmp2.samsung.com>; Thu, 24 Dec 2015 18:10:21 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Cc: linux-samsung-soc@vger.kernel.org, Inki Dae Subject: [PATCH] drm/exynos: fix kernel panic issue at drm releasing Date: Thu, 24 Dec 2015 18:10:14 +0900 Message-id: <1450948214-14688-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsWyRsSkULd2W3WYweLpEhZXvr5ns5h0fwKL xYzz+5gcmD3udx9n8ujbsorR4/MmuQDmKC6blNSczLLUIn27BK6Myd1/mAo+iVTs7LjC3MDY KtTFyMkhIWAi8ezUZmYIW0ziwr31bF2MXBxCAisYJSb1f2CDKXo3YTIrRGIWo8SMeUuhqn4w Sny60s8EUsUmoCoxccV9sA4RAWWJvxNXMYLYzAJuEotPL2cBsYUFXCQm/zkGVs8CVH9h1Wd2 EJsXKL5xxVWoM+QkTh6D2CYhcJ1N4uHzv8wQDQIS3yYfAhrEAZSQldh0AKpeUuLgihssExgF FzAyrGIUTS1ILihOSi8y0itOzC0uzUvXS87P3cQIDL7T/5717WC8ecD6EKMAB6MSD6/Eraow IdbEsuLK3EOMpkAbJjJLiSbnA0M8ryTe0NjMyMLUxNTYyNzSTEmcN0HqZ7CQQHpiSWp2ampB alF8UWlOavEhRiYOTqkGxmmSbXyrqpTDVGL+CVySDmxn3/dK7e8nda3Fd1Tz++q/mD23dZm5 9m+yKwdj0ZK/ur9fxqhPe73wBW9v1zSrP74fX1Ran8kLyHQWlv+pfGSuV4vHGQMZLXFLu+PM 2z6pn+jbzn8r7Met1fcv3X7pKF59ND/BeWWNgrcI54poYX09tnkeWfq/lViKMxINtZiLihMB DbGDXzkCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t9jQd3abdVhBm/vCltc+fqezWLS/Qks FjPO72NyYPa4332cyaNvyypGj8+b5AKYoxoYbTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwM dQ0tLcyVFPISc1NtlVx8AnTdMnOANikplCXmlAKFAhKLi5X07TBNCA1x07WAaYzQ9Q0Jgusx MkADCWsYMyZ3/2Eq+CRSsbPjCnMDY6tQFyMnh4SAicS7CZNZIWwxiQv31rN1MXJxCAnMYpSY MW8plPODUeLTlX4mkCo2AVWJiSvus4HYIgLKEn8nrmIEsZkF3CQWn17OAmILC7hITP5zDKye Baj+wqrP7CA2L1B844qrzBDb5CROHpvMOoGRewEjwypGidSC5ILipPRcw7zUcr3ixNzi0rx0 veT83E2M4AB/JrWD8eAu90OMAhyMSjy8EreqwoRYE8uKK3MPMUpwMCuJ8P7YVB0mxJuSWFmV WpQfX1Sak1p8iNEU6ICJzFKiyfnA6MsriTc0NjEzsjQyN7QwMjZXEuetvRQZJiSQnliSmp2a WpBaBNPHxMEp1cDo/XnVlT0HeLcEbJfSMern38S1I2iDzKUX3Ot+mrk5pv2odGhm3d6l/eTL rP3ZWrp+U7TFOcXjfr/MSmTdGN12vvPxZIUt5WUzLR9Zl3hXv17zzSjycaQM77NTH9+mJa2I euB2xPhoukNP35NE4+74yW+WbvzM5tKZEdJl8kdo0gprR76tAruUWIozEg21mIuKEwEHDUKo hgIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 patch fixes a kernel panic issue which happened when drm driver is closed while modetest. This issue could be reproduced easily by launching modetest with page flip repeatedly. The reason is that invalid drm_file object could be accessed by send_vblank_event function when finishing page flip if the drm_file object was removed by drm_release and there was a pended page flip event which was already committed to hardware. So this patch makes the pended page flip event to be cancelled by preclose callback which is called at front of drm_release function. Signed-off-by: Inki Dae Reviewed-by: Daniel Stone --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 10 ++++++++++ drivers/gpu/drm/exynos/exynos_drm_crtc.h | 3 +++ drivers/gpu/drm/exynos/exynos_drm_drv.c | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 81cfff5..57619b8 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -235,3 +235,13 @@ void exynos_drm_crtc_te_handler(struct drm_crtc *crtc) if (exynos_crtc->ops->te_handler) exynos_crtc->ops->te_handler(exynos_crtc); } + +void exynos_drm_crtc_cancel_page_flip(struct drm_crtc *crtc) +{ + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); + unsigned long flags; + + spin_lock_irqsave(&crtc->dev->event_lock, flags); + exynos_crtc->event = NULL; + spin_unlock_irqrestore(&crtc->dev->event_lock, flags); +} diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h index 6a581a8..b4def6e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -40,4 +40,7 @@ int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev, */ void exynos_drm_crtc_te_handler(struct drm_crtc *crtc); +/* This function cancels a page flip request. */ +void exynos_drm_crtc_cancel_page_flip(struct drm_crtc *crtc); + #endif diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 9756797a..57c0e7d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -330,7 +330,12 @@ err_file_priv_free: static void exynos_drm_preclose(struct drm_device *dev, struct drm_file *file) { + struct drm_crtc *crtc; + exynos_drm_subdrv_close(dev, file); + + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) + exynos_drm_crtc_cancel_page_flip(crtc); } static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)