From patchwork Mon Jul 6 14:20:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 6724751 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 4EDCF9F319 for ; Mon, 6 Jul 2015 14:20:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57D5C206D5 for ; Mon, 6 Jul 2015 14:20:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67EF920591 for ; Mon, 6 Jul 2015 14:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047AbbGFOUs (ORCPT ); Mon, 6 Jul 2015 10:20:48 -0400 Received: from mail-qk0-f178.google.com ([209.85.220.178]:34859 "EHLO mail-qk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752725AbbGFOUr (ORCPT ); Mon, 6 Jul 2015 10:20:47 -0400 Received: by qkbp125 with SMTP id p125so117827975qkb.2 for ; Mon, 06 Jul 2015 07:20:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jim2JrL5D/eCvrvOdlFRxg9ClCUHXsQBfUN+hBENeY8=; b=EaVOXjcUSLg+GlpDFa6tYeY9rcfXcSd9zwFVCw8Hla3pmVwJ7iyAUWNnlz5VuPGOo4 sSgApGLuOGbwCb1EmUHBqAmGhJ88WzcBOInTOW+uhJsIGSqXZ5lB/3FQsSqmqzxdXNTq EKTn/88prDl1pTbjdFOjJr3bDZpdo5B/En+/sjJyb2nyYQbAAjpdcjElxXybgeNjHuz6 a4CeOGZF931Lnc8JX3+oXFqKVeFVhsdYarD2Wj29VW7Sb1IlxKET+WqayXOIp9mwxB3N MhxQ2grfmL5ShfMhT4FQK/yyvCk74ffQQ3p6fjiFRvKOPN3U9GqHZqa9jWGEIXygbPSZ EFhg== X-Received: by 10.55.18.158 with SMTP id 30mr94087169qks.17.1436192446715; Mon, 06 Jul 2015 07:20:46 -0700 (PDT) Received: from jade.localdomain ([191.255.48.48]) by mx.google.com with ESMTPSA id f207sm1707424qhc.41.2015.07.06.07.20.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 07:20:46 -0700 (PDT) From: Gustavo Padovan To: linux-samsung-soc@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, inki.dae@samsung.com, jy0922.shim@samsung.com, tjakobi@math.uni-bielefeld.de, Gustavo Padovan Subject: [PATCH v2 05/23] drm/exynos: add atomic asynchronous commit Date: Mon, 6 Jul 2015 11:20:06 -0300 Message-Id: <1436192424-18194-6-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1436192424-18194-1-git-send-email-gustavo@padovan.org> References: <1436192424-18194-1-git-send-email-gustavo@padovan.org> 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=-7.6 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 From: Gustavo Padovan The atomic modesetting interfaces supports async commits that should be implemented by the drivers. If drm core requests an async commit exynos_atomic_commit() will schedule a work task to run the update later. It also waits an update to finish before schedule a new one. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 ++++ drivers/gpu/drm/exynos/exynos_drm_drv.h | 6 ++++ drivers/gpu/drm/exynos/exynos_drm_fb.c | 51 ++++++++++++++++++++++++++------- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 63a68c6..3542f2c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -47,6 +47,9 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags) if (!private) return -ENOMEM; + INIT_WORK(&private->work, exynos_drm_atomic_work); + private->dev = dev; + dev_set_drvdata(dev->dev, dev); dev->dev_private = (void *)private; @@ -127,6 +130,8 @@ err_free_private: static int exynos_drm_unload(struct drm_device *dev) { + struct exynos_drm_private *private = dev->dev_private; + exynos_drm_device_subdrv_remove(dev); exynos_drm_fbdev_fini(dev); @@ -137,6 +142,7 @@ static int exynos_drm_unload(struct drm_device *dev) drm_mode_config_cleanup(dev); drm_release_iommu_mapping(dev); + flush_work(&private->work); kfree(dev->dev_private); dev->dev_private = NULL; diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index dd00f16..d9fd8e1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -244,6 +244,10 @@ struct exynos_drm_private { unsigned long da_space_size; unsigned int pipe; + + struct drm_device *dev; + struct work_struct work; + struct drm_atomic_state *state; }; /* @@ -296,6 +300,8 @@ static inline int exynos_dpi_remove(struct exynos_drm_display *display) } #endif +void exynos_drm_atomic_work(struct work_struct *work); + /* This function creates a encoder and a connector, and initializes them. */ int exynos_drm_create_enc_conn(struct drm_device *dev, struct exynos_drm_display *display); diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index 2b6320e..ad6b8ac 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -267,20 +267,18 @@ static void exynos_drm_output_poll_changed(struct drm_device *dev) exynos_drm_fbdev_init(dev); } -static int exynos_atomic_commit(struct drm_device *dev, - struct drm_atomic_state *state, - bool async) +static void exynos_atomic_commit_schedule(struct drm_device *dev, + struct drm_atomic_state *state) { - int ret; - - ret = drm_atomic_helper_prepare_planes(dev, state); - if (ret) - return ret; - - /* This is the point of no return */ + struct exynos_drm_private *private = dev->dev_private; - drm_atomic_helper_swap_state(dev, state); + private->state = state; + schedule_work(&private->work); +} +static void exynos_atomic_commit_complete(struct drm_device *dev, + struct drm_atomic_state *state) +{ drm_atomic_helper_commit_modeset_disables(dev, state); drm_atomic_helper_commit_modeset_enables(dev, state); @@ -298,6 +296,37 @@ static int exynos_atomic_commit(struct drm_device *dev, drm_atomic_helper_cleanup_planes(dev, state); drm_atomic_state_free(state); +} + +void exynos_drm_atomic_work(struct work_struct *work) +{ + struct exynos_drm_private *private = container_of(work, + struct exynos_drm_private, work); + + exynos_atomic_commit_complete(private->dev, private->state); +} + +static int exynos_atomic_commit(struct drm_device *dev, + struct drm_atomic_state *state, + bool async) +{ + struct exynos_drm_private *private = dev->dev_private; + int ret; + + ret = drm_atomic_helper_prepare_planes(dev, state); + if (ret) + return ret; + + /* This is the point of no return */ + + flush_work(&private->work); + + drm_atomic_helper_swap_state(dev, state); + + if (async) + exynos_atomic_commit_schedule(dev, state); + else + exynos_atomic_commit_complete(dev, state); return 0; }