From patchwork Mon Feb 21 04:42:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 576671 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1L4hjqf032125 for ; Mon, 21 Feb 2011 04:44:05 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 363F69E9E8 for ; Sun, 20 Feb 2011 20:43:45 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx3.gwdg.de (mx3.gwdg.de [134.76.10.16]) by gabe.freedesktop.org (Postfix) with ESMTP id 767869E838 for ; Sun, 20 Feb 2011 20:43:09 -0800 (PST) X-IronPort-Reputation-Score: None X-IronPort-AV: E=McAfee;i="5400,1158,6263"; a="24227159" X-IronPort-AV: E=Sophos;i="4.62,198,1297033200"; d="scan'208";a="24227159" Received: from smtp-out.tuebingen.mpg.de (HELO tuebingen.mpg.de) ([192.124.26.249]) by mailer1.mpg.de with ESMTP; 21 Feb 2011 05:43:07 +0100 Received: from [10.38.138.43] (account mario.kleiner@tuebingen.mpg.de HELO funky.kyb.local) by tuebingen.mpg.de (CommuniGate Pro SMTP 5.3.10) with ESMTPA id 14367920; Mon, 21 Feb 2011 05:43:08 +0100 From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/vblank: Use memory barriers optimized for atomic_t instead of generics. Date: Mon, 21 Feb 2011 05:42:01 +0100 Message-Id: <1298263322-28605-3-git-send-email-mario.kleiner@tuebingen.mpg.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1298263322-28605-1-git-send-email-mario.kleiner@tuebingen.mpg.de> References: <1298263322-28605-1-git-send-email-mario.kleiner@tuebingen.mpg.de> Cc: airlied@redhat.com, Mario Kleiner X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 21 Feb 2011 04:44:05 +0000 (UTC) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 149805a..891bf6d 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -164,8 +164,10 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc) * available. In that case we can't account for this and just * hope for the best. */ - if ((vblrc > 0) && (abs64(diff_ns) > 1000000)) + if ((vblrc > 0) && (abs64(diff_ns) > 1000000)) { atomic_inc(&dev->_vblank_count[crtc]); + smp_mb__after_atomic_inc(); + } /* Invalidate all timestamps while vblank irq's are off. */ clear_vblank_timestamps(dev, crtc); @@ -858,10 +860,11 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc) if (rc) { tslot = atomic_read(&dev->_vblank_count[crtc]) + diff; vblanktimestamp(dev, crtc, tslot) = t_vblank; - smp_wmb(); } + smp_mb__before_atomic_inc(); atomic_add(diff, &dev->_vblank_count[crtc]); + smp_mb__after_atomic_inc(); } /** @@ -1296,12 +1299,13 @@ void drm_handle_vblank(struct drm_device *dev, int crtc) if (abs64(diff_ns) > DRM_REDUNDANT_VBLIRQ_THRESH_NS) { /* Store new timestamp in ringbuffer. */ vblanktimestamp(dev, crtc, vblcount + 1) = tvblank; - smp_wmb(); /* Increment cooked vblank count. This also atomically commits * the timestamp computed above. */ + smp_mb__before_atomic_inc(); atomic_inc(&dev->_vblank_count[crtc]); + smp_mb__after_atomic_inc(); } else { DRM_DEBUG("crtc %d: Redundant vblirq ignored. diff_ns = %d\n", crtc, (int) diff_ns);