From patchwork Fri Feb 21 19:03:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 3699461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EB6DA9F370 for ; Fri, 21 Feb 2014 19:04:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22B0E2017D for ; Fri, 21 Feb 2014 19:04:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A773E20179 for ; Fri, 21 Feb 2014 19:04:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0932AFB627; Fri, 21 Feb 2014 11:03:59 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 8993BFB62D; Fri, 21 Feb 2014 11:03:55 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 21 Feb 2014 10:59:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,520,1389772800"; d="scan'208";a="487340969" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.65]) by orsmga002.jf.intel.com with SMTP; 21 Feb 2014 11:03:53 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 21 Feb 2014 21:03:52 +0200 From: ville.syrjala@linux.intel.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/5] drm: Allow reenabling of vblank interrupts even if refcount>0 Date: Fri, 21 Feb 2014 21:03:34 +0200 Message-Id: <1393009415-27651-5-git-send-email-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393009415-27651-1-git-send-email-ville.syrjala@linux.intel.com> References: <1393009415-27651-1-git-send-email-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Cc: intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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: Ville Syrjälä If someone holds a vblank reference across the modeset, and after/during the modeset someone tries to grab a vblank reference, the current code won't re-enable the vblank interrupts. That's not good, so instead allow the driver to choose whether drm_vblank_get() should always enable the interrupts regardless of the refcount. Combined with the drm_vblank_off/drm_vblank_on reject mechanism, this can also be used to allow drivers to use vblank interrupts during modeset, whether or not someone is currently holding a vblank reference. Signed-off-by: Ville Syrjälä Reviewed-by: Jesse Barnes --- drivers/gpu/drm/drm_irq.c | 3 ++- include/drm/drmP.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 6e5d820..d613b6f 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -897,7 +897,8 @@ int drm_vblank_get(struct drm_device *dev, int crtc) } /* Going from 0->1 means we have to enable interrupts again */ - if (atomic_add_return(1, &dev->vblank[crtc].refcount) == 1) { + if (atomic_add_return(1, &dev->vblank[crtc].refcount) == 1 || + dev->vblank_always_enable_on_get) { spin_lock(&dev->vblank_time_lock); if (!dev->vblank[crtc].enabled) { /* Enable vblank irqs under vblank_time_lock protection. diff --git a/include/drm/drmP.h b/include/drm/drmP.h index ee40483..3eca0ee 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1156,6 +1156,12 @@ struct drm_device { */ bool vblank_disable_allowed; + /* + * Should a non-rejected drm_vblank_get() always enable the + * vblank interrupt regardless of the current refcount? + */ + bool vblank_always_enable_on_get; + /* array of size num_crtcs */ struct drm_vblank_crtc *vblank;