From nobody Tue Nov 26 22:14:20 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 242EE1D175F for ; Wed, 16 Oct 2024 07:54:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065253; cv=none; b=BHvAbxNcO8bemfVwrw5JfoItyma4PaNNcePGJTeDTfpCjG011f6q9sdWG0LucmQnJgJV4UKcRfz/xcUNmCZDwGMKqFz//uzz4SraW2OV8YHtKKKfA1tdXk06U0ILaNCmHDGk2/CILiqjnaPF8Bsjbo+TG77mTqGUkT9nvLwoLWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729065253; c=relaxed/simple; bh=40jFRzyCuak9rdF0lRbTymXhl036JNQc0hKEdgqQU6g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a5cpzelimg4uHhr/H8tTS3J/fsfvjj5FVqFwov2BXZlIIH2G104BSHmLPlvpT4KXDaa9bDk8IKuD89MDl/QcuffYX+z4/Xxn4zYV77mhJeJMQhkLEyTML70c22MN0XWUYieFjGdxlJC+2BEBdUXNCXaRhv1jdJomaEeU1Wg315Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e1bhhl3c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e1bhhl3c" Received: by smtp.kernel.org (Postfix) with ESMTPS id F2DE0C4CEDE; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729065253; bh=40jFRzyCuak9rdF0lRbTymXhl036JNQc0hKEdgqQU6g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=e1bhhl3cbP9gG7qPwu/jU0/mlwc+kg1xWBfiMMUjPJ45ZzQJzJJFiXzerPtzcc0Sz +sYpzmHn6xDWOFYkpNBLIcUo0OT4tWaO+Gl74eO5DrjkkKtSwT49iJ6syigvFldJKS GA2laiJOZ46iF7iSDfT/0VNai9i8FAE3SqsQGvasuq/Jg9UUWY54IBBNNlGD3qhZnH JrhlzVJLPOEmjA+YNADajPICI5Frk8JGdx3K6+ylbSo5/+YaQmaf0CemK/1AsC+ehq fPso0Ugx15nz65qnmC/Svmeh7gPJcbZoRu6KS6Q54rrUBYbUH+FJG6SghuwPnKkl0X HxB6giad59Ahg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF1DD206B3; Wed, 16 Oct 2024 07:54:12 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Wed, 16 Oct 2024 15:54:21 +0800 Subject: [PATCH v6 09/10] drm/bridge: it6505: fix HDCP CTS KSV list wait timer Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241016-upstream-v6-v6-9-4d93a0c46de1@ite.com.tw> References: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> In-Reply-To: <20241016-upstream-v6-v6-0-4d93a0c46de1@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Pin-yen Lin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kenneth Hung , Pet Weng , Hermes Wu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1729065263; l=1723; i=Hermes.wu@ite.com.tw; s=20241016; h=from:subject:message-id; bh=yH/tB2UOyeGhezoE5wVSTIRUshi6Pg5ZgPiTxoFH1OM=; b=fQMddfSAdSKAS/tH+eQ/ekgbcJ+FvTts96lgvvhymX4BlfjOlJG0AuvTraZiYE7fxCXrgFuqA OSv0rIq2zwyBjw/OwBPV7fxQEffvkhw6VIZ4orUhjTxjSURg4OorcJo X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=kV18uQEXox+1WccdQceCbMlJKN+BBNUk3N8VsoULcQ0= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241016 with auth_id=250 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu HDCP must disabled encryption and restart authentication after waiting KSV for 5s. The original method uses a counter in a waitting loop that may wait much longer than it is supposed to. Use time_after() for KSV wait timeout. Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 439cca455ecf91b5f83b0add416db7f099f9a34d..4fc2147e9788501f0161180fc86= 5072ab965ecbf 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -2095,12 +2095,13 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) struct it6505 *it6505 =3D container_of(work, struct it6505, hdcp_wait_ksv_list); struct device *dev =3D it6505->dev; - unsigned int timeout =3D 5000; - u8 bstatus =3D 0; + u8 bstatus; bool ksv_list_check; + /* 1B-04 wait ksv list for 5s */ + unsigned long timeout =3D jiffies + + msecs_to_jiffies(5000) + 1; =20 - timeout /=3D 20; - while (timeout > 0) { + for (;;) { if (!it6505_get_sink_hpd_status(it6505)) return; =20 @@ -2109,13 +2110,12 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) if (bstatus & DP_BSTATUS_READY) break; =20 - msleep(20); - timeout--; - } + if (time_after(jiffies, timeout)) { + DRM_DEV_DEBUG_DRIVER(dev, "KSV list wait timeout"); + goto timeout; + } =20 - if (timeout =3D=3D 0) { - DRM_DEV_DEBUG_DRIVER(dev, "timeout and ksv list wait failed"); - goto timeout; + msleep(20); } =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); --=20 2.34.1