From patchwork Tue Jan 5 10:50:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7953681 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C79CBEEE5 for ; Tue, 5 Jan 2016 10:50:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96A47203AB for ; Tue, 5 Jan 2016 10:50:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E363D20389 for ; Tue, 5 Jan 2016 10:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751539AbcAEKug (ORCPT ); Tue, 5 Jan 2016 05:50:36 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:56740 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751415AbcAEKuf (ORCPT ); Tue, 5 Jan 2016 05:50:35 -0500 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O0H018RW7G8J850@mailout2.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 05 Jan 2016 19:50:32 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.116]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 26.9F.04790.8FF9B865; Tue, 5 Jan 2016 19:50:32 +0900 (KST) X-AuditID: cbfee691-f79766d0000012b6-13-568b9ff8efbe Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 3C.CB.13906.8FF9B865; Tue, 5 Jan 2016 19:50:32 +0900 (KST) Received: from localhost.localdomain ([10.113.62.206]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O0H00AIL7G7X390@mmp1.samsung.com>; Tue, 05 Jan 2016 19:50:32 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Cc: linux-samsung-soc@vger.kernel.org, Inki Dae Subject: [PATCH v2] drm/exynos: fix kernel panic issue at drm releasing Date: Tue, 05 Jan 2016 19:50:31 +0900 Message-id: <1451991031-3961-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCLMWRmVeSWpSXmKPExsWyRsSkRPfH/O4wg7vXJC2ufH3PZjHp/gQW ixnn9zE5MHvc7z7O5NG3ZRWjx+dNcgHMUVw2Kak5mWWpRfp2CVwZ62+3MRb8kqjobtjM1sC4 QbSLkZNDQsBE4te9V0wQtpjEhXvr2boYuTiEBFYwStz695oZpmjtz1lQiaWMEq2HDjFBOD8Y JR4t+MgOUsUmoCoxccV9NhBbREBZ4u/EVYwgNrOAm8Ti08tZuhg5OIQF3CWWTXcGCbMAlS/6 fwishFfAWWLO0imMEMvkJE4em8wKYd9mk7gzTxuiXkDi2+RDYGMkBGQlNh2Auk1S4uCKGywT GAUXMDKsYhRNLUguKE5KLzLVK07MLS7NS9dLzs/dxAgMvNP/nk3cwXj/gPUhRgEORiUeXo6X XWFCrIllxZW5hxhNgTZMZJYSTc4HhndeSbyhsZmRhamJqbGRuaWZkjivjvTPYCGB9MSS1OzU 1ILUovii0pzU4kOMTBycUg2Mct7q9jeuvt25sHrdVvmQpx2hM7o35j++zay+iX/B5uvhfsvc nH2uzAhr/BNwdYr5r5xOU/FlS4pTl3jb3CzoMVnxqMloz9ZLnDWzfSW4tvTPDpx/r2TT6r5Q xuvtEw/+8JJV+XQ0YcnS5wYb24svBmeF1J1d9ZdlDfOtReleidV9cRJf+hdlKbEUZyQaajEX FScCABmHYVU3AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsVy+t9jAd0f87vDDBa1C1lc+fqezWLS/Qks FjPO72NyYPa4332cyaNvyypGj8+b5AKYoxoYbTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwM dQ0tLcyVFPISc1NtlVx8AnTdMnOANikplCXmlAKFAhKLi5X07TBNCA1x07WAaYzQ9Q0Jgusx MkADCWsYM9bfbmMs+CVR0d2wma2BcYNoFyMnh4SAicTan7PYIGwxiQv31gPZXBxCAksZJVoP HWKCcH4wSjxa8JEdpIpNQFVi4or7YB0iAsoSfyeuYgSxmQXcJBafXs7SxcjBISzgLrFsujNI mAWofNH/Q2AlvALOEnOWTmGEWCYncfLYZNYJjNwLGBlWMUqkFiQXFCel5xrmpZbrFSfmFpfm pesl5+duYgSH9zOpHYwHd7kfYhTgYFTi4eV42RUmxJpYVlyZe4hRgoNZSYRXsLA7TIg3JbGy KrUoP76oNCe1+BCjKdABE5mlRJPzgbGXVxJvaGxiZmRpZG5oYWRsriTOW3spMkxIID2xJDU7 NbUgtQimj4mDU6qB8ZiD/+usad/8DfY5vOAsP7vl7kHTr7MWrpX+0VWZ++fQvdDnKrNfvJz/ 6LzCx40759YwRjY/Sj19yGtBvn1Ik7+hVe7744+l8ktWFe5kib34uIp97vJV1hzl3NVLc70/ XFI9rvbu/9LPq1dff1Dfetgl1SBm6q5e4Szuj271a/P6+MP9WrdEhCmxFGckGmoxFxUnAgAI HKlShQIAAA== 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. Changelog v2: - free vblank event objects belonging to the request process, increment event space and decrease pending_update when cancelling the event Signed-off-by: Inki Dae Reviewed-by: Daniel Stone --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 18 ++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_crtc.h | 4 ++++ drivers/gpu/drm/exynos/exynos_drm_drv.c | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index f3589a3..a3c2c71 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -238,3 +238,21 @@ 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 drm_file *file) +{ + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); + struct drm_pending_vblank_event *e; + unsigned long flags; + + spin_lock_irqsave(&crtc->dev->event_lock, flags); + e = exynos_crtc->event; + if (e && e->base.file_priv == file) { + exynos_crtc->event = NULL; + e->base.destroy(&e->base); + file->event_space += sizeof(e->event); + atomic_dec(&exynos_crtc->pending_update); + } + 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..cfdcf3e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -40,4 +40,8 @@ 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, + struct drm_file *file); + #endif diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 2c6019d..b9a9fd6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -369,7 +369,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, file); } static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)