From patchwork Tue Mar 8 16:39:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 8539911 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 461FAC0553 for ; Wed, 9 Mar 2016 00:50:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62E3F20211 for ; Wed, 9 Mar 2016 00:50:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7D76D201D3 for ; Wed, 9 Mar 2016 00:50:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7ED316E7BB; Wed, 9 Mar 2016 00:49:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from ring0.de (ring0.de [IPv6:2a03:4000:6:1a1::1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2953C6E744 for ; Tue, 8 Mar 2016 16:50:05 +0000 (UTC) Received: by ring0.de (Postfix, from userid 110) id 83880A4A841; Tue, 8 Mar 2016 17:40:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from sre.ring0.de (host-091-097-051-039.ewe-ip-backbone.de [91.97.51.39]) by ring0.de (Postfix) with ESMTPSA id C5DB6A4A817; Tue, 8 Mar 2016 17:40:17 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Tony Lindgren , Aaro Koskinen , Tomi Valkeinen Subject: [PATCH 07/23] drm: omapdrm: crtc: switch pending variable to atomic bitset Date: Tue, 8 Mar 2016 17:39:39 +0100 Message-Id: <1457455195-1938-8-git-send-email-sre@kernel.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457455195-1938-1-git-send-email-sre@kernel.org> References: <1457455195-1938-1-git-send-email-sre@kernel.org> X-Mailman-Approved-At: Wed, 09 Mar 2016 00:49:40 +0000 Cc: linux-omap@vger.kernel.org, Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org 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-Virus-Scanned: ClamAV using ClamSMTP Having the pending variable available as atomic bit helps with the later addition of manually updated display support. Signed-off-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/omap_crtc.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 2ed0754ed19e..5ef27664bcfa 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -28,6 +28,11 @@ #define to_omap_crtc(x) container_of(x, struct omap_crtc, base) +enum omap_crtc_state { + crtc_enabled = 0, + crtc_pending = 1 +}; + struct omap_crtc { struct drm_crtc base; @@ -49,7 +54,7 @@ struct omap_crtc { bool ignore_digit_sync_lost; - bool pending; + unsigned long state; wait_queue_head_t pending_wait; }; @@ -81,7 +86,7 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc) struct omap_crtc *omap_crtc = to_omap_crtc(crtc); return wait_event_timeout(omap_crtc->pending_wait, - !omap_crtc->pending, + !test_bit(crtc_pending, &omap_crtc->state), msecs_to_jiffies(50)); } @@ -311,10 +316,8 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus) __omap_irq_unregister(dev, &omap_crtc->vblank_irq); - rmb(); - WARN_ON(!omap_crtc->pending); - omap_crtc->pending = false; - wmb(); + if (!test_and_clear_bit(crtc_pending, &omap_crtc->state)) + dev_warn(dev->dev, "pending bit was not set in vblank irq"); /* wake up userspace */ omap_crtc_complete_page_flip(&omap_crtc->base); @@ -351,13 +354,12 @@ static bool omap_crtc_mode_fixup(struct drm_crtc *crtc, static void omap_crtc_enable(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + struct drm_device *dev = crtc->dev; DBG("%s", omap_crtc->name); - rmb(); - WARN_ON(omap_crtc->pending); - omap_crtc->pending = true; - wmb(); + if (test_and_set_bit(crtc_pending, &omap_crtc->state)) + dev_warn(dev->dev, "crtc enable while pending bit set!"); omap_irq_register(crtc->dev, &omap_crtc->vblank_irq); @@ -397,6 +399,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + struct drm_device *dev = crtc->dev; WARN_ON(omap_crtc->vblank_irq.registered); @@ -404,10 +407,8 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, DBG("%s: GO", omap_crtc->name); - rmb(); - WARN_ON(omap_crtc->pending); - omap_crtc->pending = true; - wmb(); + if (test_and_set_bit(crtc_pending, &omap_crtc->state)) + dev_warn(dev->dev, "atomic flush while pending bit set!"); dispc_mgr_go(omap_crtc->channel); omap_irq_register(crtc->dev, &omap_crtc->vblank_irq); @@ -509,6 +510,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, init_waitqueue_head(&omap_crtc->pending_wait); + omap_crtc->state = 0; + omap_crtc->channel = channel; omap_crtc->name = channel_names[channel];