From patchwork Mon Sep 2 11:31:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11126453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E10314F7 for ; Mon, 2 Sep 2019 11:31:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 266DF217D7 for ; Mon, 2 Sep 2019 11:31:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 266DF217D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF34189C14; Mon, 2 Sep 2019 11:31:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6289B89C14 for ; Mon, 2 Sep 2019 11:31:52 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id c3so13648530wrd.7 for ; Mon, 02 Sep 2019 04:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=srBm4Ktgq0cSVneUfh1AFH6P8a+ZVsFKSo7DHCjJP98=; b=mBfDgHa5DOs7+Ew8ovJt8kanjhnilywcJbkxAcumWzGWVS4KiOo9X9wnklWcijAI+y rtCslLHQbCQA1uvPdE4HNjzUhyDQef+rOTvxDeWjkcCFsV5vSNK5f0tpY0aihwsmfN+7 7JOWp/yH2Q+dqHWkuePFZi1g5MZwqKseW+vIHKcl8bwmmVVkmhkDn2Q9ZLmaqWK3LZA2 O5hZh7zXxFPbAJvPNScu6U5RMd2qbkiKq869e3XT0qAlxGFOov2Q6WkGaJ0+CLatu+mS x3PV9WvkOwx9odSiDo9KtQi+v6Vwrtsy0B+JB4Yjy4z7Zs88FF1J6UNkT5+Mz7mh7GBO 0dGg== X-Gm-Message-State: APjAAAUngR6wVbfkaYmY7dZ/gLndUIaKOV0aRRGN/UlPgqvZ4Syxpkki 037mAZv1/bQkN0T/II91MC4SUoPp X-Google-Smtp-Source: APXvYqyFb5J6REviV0856UT1/10jUrih7nXTlNVYeuiLIkDY0NJT/zBIc9u+M2orLOebv4wX83kv/A== X-Received: by 2002:adf:f1c4:: with SMTP id z4mr5628133wro.319.1567423910634; Mon, 02 Sep 2019 04:31:50 -0700 (PDT) Received: from localhost (pD9E51890.dip0.t-ipconnect.de. [217.229.24.144]) by smtp.gmail.com with ESMTPSA id s26sm2451060wrs.63.2019.09.02.04.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 04:31:49 -0700 (PDT) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 13/21] drm/dp: Do not busy-loop during link training Date: Mon, 2 Sep 2019 13:31:13 +0200 Message-Id: <20190902113121.31323-14-thierry.reding@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190902113121.31323-1-thierry.reding@gmail.com> References: <20190902113121.31323-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=srBm4Ktgq0cSVneUfh1AFH6P8a+ZVsFKSo7DHCjJP98=; b=nzHi/GxT5/ePnSwlgdwg5Va5pE4LyBlxarwHq4CSBmlo2AeiAq2Wj39hYZVY2hZ+SQ x4MLwhPd2ua9ggE8JPcwGXP0v+w7a+jP42dUwu3qVzcBVp2ZfaOtELHgB4UWw17GPmY8 5AumQL7C0Va315qKXmYUE9/9VRVGMeprPJsHuldD7XDh0g5HzbiufV92vQYCxrYnIbu5 mla1XtlvtgmTmn6Hxd2l+k/L507fMUmQ15yFtu1k+J0IwEitTY1Nu76TD087cBcvD/2k Liyz2cRyy+wo23WrWr4HLLYUOs4/VjgYVZ69WPkQ9dbo5/4A+STqZ9/5uIv/bvD87Cjg ECww== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding Use microsecond sleeps for the clock recovery and channel equalization delays during link training. The duration of these delays can be from 100 us up to 16 ms. It is rude to busy-loop for that amount of time. While at it, also convert to standard coding style by putting the opening braces in a function definition on a new line. v2: use correct multiplier for training delays (Philipp Zabel) Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_dp_helper.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 4112570dbe67..681d28988776 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -120,33 +120,39 @@ u8 drm_dp_get_adjust_request_pre_emphasis(const u8 link_status[DP_LINK_STATUS_SI } EXPORT_SYMBOL(drm_dp_get_adjust_request_pre_emphasis); -void drm_dp_link_train_clock_recovery_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) { - int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & - DP_TRAINING_AUX_RD_MASK; +void drm_dp_link_train_clock_recovery_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) +{ + unsigned int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & + DP_TRAINING_AUX_RD_MASK; if (rd_interval > 4) - DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)\n", + DRM_DEBUG_KMS("AUX interval %u, out of range (max 4)\n", rd_interval); if (rd_interval == 0 || dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14) - udelay(100); + rd_interval = 100; else - mdelay(rd_interval * 4); + rd_interval *= 4 * USEC_PER_MSEC; + + usleep_range(rd_interval, rd_interval * 2); } EXPORT_SYMBOL(drm_dp_link_train_clock_recovery_delay); -void drm_dp_link_train_channel_eq_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) { - int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & - DP_TRAINING_AUX_RD_MASK; +void drm_dp_link_train_channel_eq_delay(const u8 dpcd[DP_RECEIVER_CAP_SIZE]) +{ + unsigned int rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] & + DP_TRAINING_AUX_RD_MASK; if (rd_interval > 4) - DRM_DEBUG_KMS("AUX interval %d, out of range (max 4)\n", + DRM_DEBUG_KMS("AUX interval %u, out of range (max 4)\n", rd_interval); if (rd_interval == 0) - udelay(400); + rd_interval = 400; else - mdelay(rd_interval * 4); + rd_interval *= 4 * USEC_PER_MSEC; + + usleep_range(rd_interval, rd_interval * 2); } EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);