From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 21CB8C7EE31 for ; Fri, 27 Jun 2025 14:15:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B44F710E328; Fri, 27 Jun 2025 14:15:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="FGli0VpG"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D86A10E0F0; Fri, 27 Jun 2025 14:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751033735; x=1782569735; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MP+fCJiYSsIALgpmOa8nxaTxBavy54/Qb7sEAQvFI5Q=; b=FGli0VpGoQeef2vorRprpEEh9VI8A+0GArpMW2BRKREFO8xS6t1YYoZ2 v98tK8aDtP4Ftdt+V3ZG2SynP5DxWnKSFfwvD/09N1/f3ELFJZuNvlej5 3UqsQ4G5lFQfBb13Bi7kwuEhevueDhH4eOfoFZUsRnssHocXalmNxy9Cy 6PN5vfHegU4YTIjyscM3ViIZWG8Qhht1k2YdTOnx7FTS2EvHxA1Ejwt+I yiAotzlDThzFLaI8fjxvcM0TfCtEV0SrrzqoUO2Ef8uJAb21fSmyuyA1e ns3wDXpI4Mjz5UJSZ+ek9lPZGAip6DjHb5PutzEvLfIiKeBQYtjy9fHrL A==; X-CSE-ConnectionGUID: 6jEK28ibTv+XUdoPSlATmQ== X-CSE-MsgGUID: xZiqH/lgT/6YpsSx4IslFA== X-IronPort-AV: E=McAfee;i="6800,10657,11477"; a="53499549" X-IronPort-AV: E=Sophos;i="6.16,270,1744095600"; d="scan'208";a="53499549" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2025 07:15:35 -0700 X-CSE-ConnectionGUID: 3Yw1U+WrRi6vNVDUtZtYig== X-CSE-MsgGUID: DHOYwYeJSS6mU8AjtYx63w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,270,1744095600"; d="scan'208";a="152431699" Received: from klitkey1-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.146]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2025 07:15:33 -0700 From: Jani Nikula To: Jani Nikula , intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: Imre Deak Subject: [PATCH v2] drm/i915/ddi: prefer read_poll_timeout() over readx_poll_timeout() Date: Fri, 27 Jun 2025 17:15:29 +0300 Message-Id: <20250627141529.2811884-1-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <59bcc15dd4debf00ee0c7b430a3b701462ac9de7.1751023767.git.jani.nikula@intel.com> References: <59bcc15dd4debf00ee0c7b430a3b701462ac9de7.1751023767.git.jani.nikula@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Transfer-Encoding: 8bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Unify on using read_poll_timeout() throughout instead of mixing with readx_poll_timeout(). While the latter can be ever so slightly simpler, they are both complicated enough that it's better to unify on one approach only. While at it, better separate the handling of error returns from drm_dp_dpcd_readb() and the actual status byte. This is best achieved by inlining the read_fec_detected_status() function, and switching to drm_dp_dpcd_read_byte(). v2: Use drm_dp_dpcd_read_byte() (Imre) Cc: Imre Deak Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_ddi.c | 33 +++++++++--------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c index 0405396c7750..f2ac37159a28 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -2339,34 +2339,25 @@ static void intel_dp_sink_set_fec_ready(struct intel_dp *intel_dp, drm_dbg_kms(display->drm, "Failed to clear FEC detected flags\n"); } -static int read_fec_detected_status(struct drm_dp_aux *aux) -{ - int ret; - u8 status; - - ret = drm_dp_dpcd_readb(aux, DP_FEC_STATUS, &status); - if (ret < 0) - return ret; - - return status; -} - static int wait_for_fec_detected(struct drm_dp_aux *aux, bool enabled) { struct intel_display *display = to_intel_display(aux->drm_dev); int mask = enabled ? DP_FEC_DECODE_EN_DETECTED : DP_FEC_DECODE_DIS_DETECTED; - int status; - int err; + u8 status = 0; + int ret, err; - err = readx_poll_timeout(read_fec_detected_status, aux, status, - status & mask || status < 0, - 10000, 200000); + ret = read_poll_timeout(drm_dp_dpcd_read_byte, err, + err || (status & mask), + 10 * 1000, 200 * 1000, false, + aux, DP_FEC_STATUS, &status); - if (err || status < 0) { + /* Either can be non-zero, but not both */ + ret = ret ?: err; + if (ret) { drm_dbg_kms(display->drm, - "Failed waiting for FEC %s to get detected: %d (status %d)\n", - str_enabled_disabled(enabled), err, status); - return err ? err : status; + "Failed waiting for FEC %s to get detected: %d (status 0x%02x)\n", + str_enabled_disabled(enabled), ret, status); + return ret; } return 0; -- 2.39.5