From patchwork Thu Nov 26 00:04:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 7703641 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E1FC69F2E9 for ; Thu, 26 Nov 2015 00:04:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D126208CC for ; Thu, 26 Nov 2015 00:04:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 37BCA208C8 for ; Thu, 26 Nov 2015 00:04:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0872B6E0C0; Wed, 25 Nov 2015 16:04:13 -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 D7E506E0C5; Wed, 25 Nov 2015 16:04:11 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 25 Nov 2015 16:04:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,344,1444719600"; d="scan'208";a="859509035" Received: from rdvivi-dublin.jf.intel.com ([10.7.196.164]) by orsmga002.jf.intel.com with ESMTP; 25 Nov 2015 16:04:10 -0800 From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Subject: [PATCH 5/9] drm: Wait 1ms before retrying aux transactions on EBUSY. Date: Wed, 25 Nov 2015 16:04:01 -0800 Message-Id: <1448496245-1495-6-git-send-email-rodrigo.vivi@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1448496245-1495-1-git-send-email-rodrigo.vivi@intel.com> References: <1448496245-1495-1-git-send-email-rodrigo.vivi@intel.com> Cc: Jani Nikula , Dave Airlie , dri-devel@lists.freedesktop.org, Rodrigo Vivi 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-Spam-Status: No, score=-4.8 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 DP Specs isn't really clear about the amount of retries, but for cases it mentions retries it also mention times that vary from 300us to 1ms. For many cases hardware can handled the timeouts before retry is possible and allowed, but for many other cases it is better to wait and give time so the aux channels can recover. For instance one general case there is when downstream device is waking up from sleep states generating HPD so it might take up to 1ms before getting responsive. I believe with this msleep we could minimize the 32 times retries and still let Dell monitors happy, but I don't have this monitor to test here so let's just add the sleep for now and still retry 32 times. v2: Include doc comment. Also apply the 1ms to i2c helper. Use usleep_range for better precision as suggested by Jani. Cc: Jani Nikula Cc: Dave Airlie Signed-off-by: Rodrigo Vivi Tested-by: Daniel Stone # v1 on SKL --- drivers/gpu/drm/drm_dp_helper.c | 10 +++++++--- include/drm/drm_dp_helper.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 2e26097..e328715 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -202,9 +202,11 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, if (err == -EAGAIN) continue; - /* FIXME: On BUSY we could wait before retrying */ - if (err == -EBUSY) + /* Give a time for aux channels to recover */ + if (err == -EBUSY) { + usleep_range(1000, 1000); continue; + } return err; } @@ -557,8 +559,10 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) * -EAGAIN retries are handled by i2c layer with * timeouts for repeated -EAGAINs */ - if (ret == -EBUSY) + if (ret == -EBUSY) { + usleep_range(1000, 1000); continue; + } DRM_DEBUG_KMS("transaction failed: %d\n", ret); return ret; diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 518fc1b..ac9de5e 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -757,7 +757,8 @@ struct drm_dp_aux { * - -EPROTO: On a short, helpers will return -EPROTO to make it simpler * to check for failure. * - -EBUSY: When BUSY helpers will attempt retries before propagating - * this error. + * this error, with 1ms between attempts to give a time for downstream + * devices to recover. * - -EAGAIN: DPCD helper will attempt immediatelly retries before * propagating this error. i2c helper will only propagate directly * since i2c layer already perform retries with timeouts for repeated