From patchwork Thu May 2 09:00:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 2510651 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 645313FD85 for ; Thu, 2 May 2013 09:00:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D82CE6219 for ; Thu, 2 May 2013 02:00:32 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E1F7E5E04 for ; Thu, 2 May 2013 02:00:21 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 May 2013 02:00:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,595,1363158000"; d="scan'208";a="330145221" Received: from unknown (HELO localhost) ([10.252.121.68]) by orsmga002.jf.intel.com with ESMTP; 02 May 2013 02:00:18 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 2 May 2013 12:00:03 +0300 Message-Id: <1367485203-4533-1-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.10.4 Subject: [Intel-gfx] [PATCH] drm/i915: fix DP AUX errors due to false timeouts when using wait_event_timeout X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Due to possible scheduling latencies wait_event_timeout doesn't guarantee a non-zero return value, even if the condition becomes true before the specified timeout expires. Thus we can incorrectly signal a timeout and abort a DP AUX transaction. If wait_event_timeout returns 0, it's guaranteed that at least the specified timeout (minus one jiffies, see below) had passed, so we can fix this by checking the condition explicitly in this case. Also the timeout that wait_event_timeout() is guaranteed to wait if the condition doesn't become true is one less jiffies than what is passed to it as a parameter. This is because the absolute expiration time in schedule_timeout() may be calculated at a moment close to the next scheduling tick, when jiffies is incremented. So make sure we pass always a jiffies value of 2 or greater. Here this makes a difference only for HZ=100. This fixes DP AUX errors I saw during booting on an ILK. This should ideally be fixed in wait_event_timeout(), but that can take a while. Until that's done use this fix as a band-aid. Signed-off-by: Imre Deak --- drivers/gpu/drm/i915/intel_dp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 8759fb1..7ce96c5 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -303,10 +303,10 @@ intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq) #define C (((status = I915_READ_NOTRACE(ch_ctl)) & DP_AUX_CH_CTL_SEND_BUSY) == 0) if (has_aux_irq) done = wait_event_timeout(dev_priv->gmbus_wait_queue, C, - msecs_to_jiffies(10)); + msecs_to_jiffies(10) + 1); else done = wait_for_atomic(C, 10) == 0; - if (!done) + if (!done && !(C)) DRM_ERROR("dp aux hw did not signal timeout (has irq: %i)!\n", has_aux_irq); #undef C