From patchwork Fri Oct 31 22:54:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207291 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3797C11AC for ; Fri, 31 Oct 2014 23:56:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA15320158 for ; Fri, 31 Oct 2014 23:56:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7475920173 for ; Fri, 31 Oct 2014 23:56:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BF676E84B; Fri, 31 Oct 2014 16:56:38 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 8CA476E849 for ; Fri, 31 Oct 2014 15:57:46 -0700 (PDT) Received: by mail-pa0-f43.google.com with SMTP id eu11so8581078pac.16 for ; Fri, 31 Oct 2014 15:57:46 -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:in-reply-to:references; bh=j0KvIQDcq2nduG70Ef6yLJzYxjpXzfXNkUILLtA9eE4=; b=B59ki3VToQituMLVwNaUrIcu8wCOcCZW5j3lNDXLx6VBJWnDsSXW7G/JL/oUl6DbGd rJ7yw6ldeOogAi1ETnADBi1UjKQwo6jRS5kqJ00e2sQgv19WNxuEMESIzsnenQ6C8uH6 xYZsQoIJWQA35UCeiBht+Tk43KWkFcj8Nf3ta1h+VjZHRiyeTmlS0vzBodJuBFDEDQof WIWwa4cbkSVsQAkYWYMZlGUSRzcKWsmVSf18eigBhyD9hu1RV0Y7gXuoYWN6+uvMzRnp FFrhyDlic4/XyIP9n+jlfE4xgzkWnjZ7mVzvtSXu9PvzSl4nKTH4S5fVsMnPPp9cm5/q SMgg== X-Received: by 10.68.69.76 with SMTP id c12mr27108211pbu.59.1414796266454; Fri, 31 Oct 2014 15:57:46 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id ev8sm10870656pdb.28.2014.10.31.15.57.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:57:46 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 70/72] imx-drm: Cancel pending page flip events at preclose Date: Fri, 31 Oct 2014 15:54:53 -0700 Message-Id: <1414796095-10107-71-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> References: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 31 Oct 2014 16:56:32 -0700 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-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 At preclose, destroy page flip events that are pending on every plane. Signed-off-by: Steve Longerbeam --- drivers/staging/imx-drm/imx-drm-core.c | 15 +++++++++++++-- drivers/staging/imx-drm/imx-drm.h | 2 ++ drivers/staging/imx-drm/ipuv3-crtc.c | 13 +++++++++++++ drivers/staging/imx-drm/ipuv3-plane.c | 22 ++++++++++++++++++++++ drivers/staging/imx-drm/ipuv3-plane.h | 2 ++ 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index b31d291..b2cc77b 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -213,13 +213,24 @@ static void imx_drm_disable_vblank(struct drm_device *drm, int pipe) static void imx_drm_driver_preclose(struct drm_device *drm, struct drm_file *file) { + struct imx_drm_device *imxdrm = drm->dev_private; + struct imx_drm_crtc_helper_funcs *helpers; + struct imx_drm_crtc *imx_drm_crtc; int pipe; if (!file->is_master) return; - for (pipe = 0; pipe < MAX_PIPES; pipe++) - imx_drm_disable_vblank(drm, pipe); + for (pipe = 0; pipe < MAX_PIPES; pipe++) { + imx_drm_crtc = imxdrm->crtc[pipe_to_crtc_id(pipe)]; + if (!imx_drm_crtc) + continue; + helpers = &imx_drm_crtc->imx_drm_helper_funcs; + if (!helpers->cancel_page_flip) + continue; + + helpers->cancel_page_flip(imx_drm_crtc->crtc, file, pipe); + } } static const struct file_operations imx_drm_driver_fops = { diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index 24b889a..8ffcc0a 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -21,6 +21,8 @@ int imx_drm_overlay_plane_pipe(struct imx_drm_crtc *crtc); struct imx_drm_crtc_helper_funcs { int (*enable_vblank)(struct drm_crtc *crtc, int pipe); void (*disable_vblank)(struct drm_crtc *crtc, int pipe); + void (*cancel_page_flip)(struct drm_crtc *crtc, struct drm_file *file, + int pipe); int (*set_interface_pix_fmt)(struct drm_crtc *crtc, u32 encoder_type, u32 pix_fmt, struct ipu_dc_if_map *pix_map, int hsync_pin, int vsync_pin); diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 179b764..7d5b691 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -398,6 +398,18 @@ static void ipu_disable_vblank(struct drm_crtc *crtc, int pipe) ipu_plane_disable_vblank(ipu_plane); } +static void ipu_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file, + int pipe) +{ + struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); + struct ipu_plane *ipu_plane = pipe_to_plane(ipu_crtc, pipe); + + if (!ipu_plane) + return; + + ipu_plane_cancel_page_flip(ipu_plane, file); +} + static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc, u32 encoder_type, u32 pixfmt, struct ipu_dc_if_map *pixmap, int hsync_pin, int vsync_pin) @@ -435,6 +447,7 @@ static int ipu_gamma_set(struct drm_crtc *crtc, bool enable, u32 *m, u32 *b) static const struct imx_drm_crtc_helper_funcs ipu_crtc_helper_funcs = { .enable_vblank = ipu_enable_vblank, .disable_vblank = ipu_disable_vblank, + .cancel_page_flip = ipu_cancel_page_flip, .set_interface_pix_fmt = ipu_set_interface_pix_fmt, .gamma_set = ipu_gamma_set, .crtc_funcs = &ipu_crtc_funcs, diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index aa10ae7..c012c4e 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -150,6 +150,28 @@ void ipu_plane_disable_vblank(struct ipu_plane *ipu_plane) ipu_plane->newfb = NULL; } +void ipu_plane_cancel_page_flip(struct ipu_plane *ipu_plane, + struct drm_file *file) +{ + struct drm_device *drm = ipu_plane->base.dev; + struct drm_pending_vblank_event *event; + unsigned long flags; + + /* + * Destroy the pending vertical blanking event associated with the + * pending page flip, if any, and disable vertical blanking interrupts. + */ + spin_lock_irqsave(&drm->event_lock, flags); + event = ipu_plane->page_flip_event; + if (event && event->base.file_priv == file) { + ipu_plane->page_flip_event = NULL; + ipu_plane->newfb = NULL; + event->base.destroy(&event->base); + drm_vblank_put(drm, ipu_plane->pipe); + } + spin_unlock_irqrestore(&drm->event_lock, flags); +} + int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_framebuffer *fb, int crtc_x, int crtc_y, diff --git a/drivers/staging/imx-drm/ipuv3-plane.h b/drivers/staging/imx-drm/ipuv3-plane.h index 912902a..c584a6a 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.h +++ b/drivers/staging/imx-drm/ipuv3-plane.h @@ -63,6 +63,8 @@ int ipu_plane_page_flip(struct drm_plane *plane, int ipu_plane_enable_vblank(struct ipu_plane *ipu_plane); void ipu_plane_disable_vblank(struct ipu_plane *ipu_plane); +void ipu_plane_cancel_page_flip(struct ipu_plane *ipu_plane, + struct drm_file *file); void ipu_plane_enable(struct ipu_plane *plane); void ipu_plane_disable(struct ipu_plane *plane);