Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2208039lqo; Mon, 13 May 2024 10:51:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9alV6xYnN4pP7rICCTsrfFOOu1sW8fEIL7ts3GmuU8+lz8ccu354V3HuWhxbHwR6yWT5Qf3TXCNZhgEGVIcR5E0WFt6pCC2PWT7YYWg== X-Google-Smtp-Source: AGHT+IFiBBqlDjeDA+d1cFU+YqM2GgZKcc82XiUYRGv86r0TRWTBo7a5fmTN9oLlytHaDjo90S+t X-Received: by 2002:a05:6871:588:b0:23d:5285:5dc6 with SMTP id 586e51a60fabf-24172c4db06mr12880361fac.52.1715622694056; Mon, 13 May 2024 10:51:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715622694; cv=pass; d=google.com; s=arc-20160816; b=n9q5VD1GiNhsyI8lcuiv+BINbzSKcj2HRqNQetXBAKWV66lCHDScoY819Z/h4HN1a3 YfCdlkqG2Z2038p7NtBXd5fAW90gZvbj8EGxwQSYOUhV3b/NDBIfVeNX3ozAMRVt1CwR YBoPNyaT20zSGPm71/fOHtoHZT3lEASa8PDBZcs2dfbwa6ZwZSX7W4pUK7kUymnTXFLS s3krvObzLI0pgJnAaaz22aKNxf/UcGtCJKTAifg4KJjQjHiupte+CcsjYWrCU8YnY7mZ c3sHDgabWQ5ABFMrvftEHici0fKrQC0AQlD9LlwdsAcO2P8jsgUZHe70FYjVFHnfZXXc Xjew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=NAGcvMiRyXnBtCVzw3tHDUSeJO1jagdXmI4eygT/XKI=; fh=/I9eWa+xhsnc0SPsv27nUyK5z4sU5tU8eDuxcG82GoA=; b=uzlrb7N32f9T3uiMUIq5s+ffFCjoeqYhnU+xhiMfrBKQmriVUILSOMxBHmHIhkQvew Wjt/VfN2tkvWn0S6gfH9rmITdv+Lidj8wEgbzRbQQU5OatXD46tOxX4Pv0EQZUrMHncQ ILI8KRz/fjh9rAdUFBhJM1qwwx37qHzUVhRljJ72Lbe8vIAjxvy9M1YAQ+KIDRPl/yu5 gSyU9E3M70raszmo6D5jkhh01VllRil/Z+BojYuco1Q1M+ymwSpLS+Y+KKwuUP7d4KzO SNbuOz5zlyEwk+JeUhTFZdjXEC9cwQ5QVe1dNrEpCyDgsANwVybaypsMeb7yaAD/+di7 BHNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gl9OmBcJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177930-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63410301209si9611706a12.308.2024.05.13.10.51.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 10:51:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177930-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gl9OmBcJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177930-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C85B72898FD for ; Mon, 13 May 2024 17:43:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C6B7249F5; Mon, 13 May 2024 17:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gl9OmBcJ" 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 2007A22331 for ; Mon, 13 May 2024 17:43:04 +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=1715622185; cv=none; b=T4xag9Q3TIDzAGAUHfa7MSA/vrqBqOt8ZQuI9I+jl7EP2PjoQ2K1KPwYzv6U3mNBqSQgPYRhstWfcR9aX8IIXgRDBecVcwYq3t8qi8YRP85vWUMeLPmPfY5j5XMn3nbaCk2I1WEu5gHpph9cNJJQ6KSVcifCZsTeJkr9fDPdzUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715622185; c=relaxed/simple; bh=6y/khTp1r7XDGxmGw9NhsdPOo3cmIfSNWaVHHpRYWao=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lmRkSM47D87JGIHnuDIwi3O5tR2xpPnY8ZbzvNHz1Y78iyaYNiqR+ShV5TEYjV/ZdrxcdndHfteLxf8OXvyqBJGxH79VYXXy3nzjHLqBpRLhe1Giu3re9csDs05uG9/0j0tu6z/H9nY1aaKNUp1I6DkMSdN/qybRUtPDc1UHz8Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gl9OmBcJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB6B1C4AF0A for ; Mon, 13 May 2024 17:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715622184; bh=6y/khTp1r7XDGxmGw9NhsdPOo3cmIfSNWaVHHpRYWao=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gl9OmBcJiGiiS+LTmPC9Hk6B9A4OhDqBelFUrPxkU7jGKgJKPkHiQUeIKRH8CX4ie +kVv7xiOqsazMtbjY/18na65zoFOB4kBrIpdtmRUPeHWMOSskpTkLVJXsPM58Y189G eqQoIs2tm0Ytq7EtpB7CLgr6Xje0yghVtnvUAppC1wqeX9z5A6Cl3ImsJSXp296G2c 3QFWwS3hrB5iU0QU/s2yoniPLCTIUGNVT8inO7g3fbep5Bpd5tnTmAJ5bdw5sJDMH5 Gnwk1vlrFrrCJfS9RMll74GnugtV5M7ZJghGgZNZXaErhFmkj97xroUHpLCgDqotdb 09VXnZLYPbjPQ== Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-dee8627669bso1238744276.3 for ; Mon, 13 May 2024 10:43:04 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUEiQGMuvQO5XJeiQVjGi4zgwFBsPhT25uDNibzSnppkBNGR3tJHe8DtLEsnwpL34pruZQGcTyFhk6G7yOUdwG/+8qCv1cCR4XcHRr+ X-Gm-Message-State: AOJu0YxnyZpaS3erHk/N3axnitg4zmhdslrTVHemBk59UIcO8af3HVQV ramAFxPOuGdzh+QQKsT2cy3caR4nnbTJVd/8dtAxbnyETiXtBLc8hLv/wf5oHxwv/5CpyuN93Up orFiQdUluJd2g8oXKe8EhOKOntV1W/sW8s9soyw== X-Received: by 2002:a25:d64d:0:b0:deb:877c:5377 with SMTP id 3f1490d57ef6-dee4f4b99efmr9309745276.51.1715622183882; Mon, 13 May 2024 10:43:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240506094644.887842-1-kuro.chung@ite.com.tw> <20240506094644.887842-2-kuro.chung@ite.com.tw> In-Reply-To: <20240506094644.887842-2-kuro.chung@ite.com.tw> From: Robert Foss Date: Mon, 13 May 2024 19:42:52 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 1/1] drm/bridge: it6505: fix hibernate to resume no display issue To: kuro Cc: Allen Chen , Pin-yen Lin , Kenneth Haung , Kuro Chung , Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 6, 2024 at 11:36=E2=80=AFAM kuro wrote: > > From: Kuro > > ITE added a FIFO reset bit for input video. When system power resume, > the TTL input of it6505 may get some noise before video signal stable > and the hardware function reset is required. > But the input FIFO reset will also trigger error interrupts of output mod= ule rising. > Thus, it6505 have to wait a period can clear those expected error interru= pts > caused by manual hardware reset in one interrupt handler calling to avoid= interrupt looping. > > Signed-off-by: Kuro Chung > > --- > drivers/gpu/drm/bridge/ite-it6505.c | 73 +++++++++++++++++++---------- > 1 file changed, 49 insertions(+), 24 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge= /ite-it6505.c > index b53da9bb65a16..64e2706e3d0c3 100644 > --- a/drivers/gpu/drm/bridge/ite-it6505.c > +++ b/drivers/gpu/drm/bridge/ite-it6505.c > @@ -1317,9 +1317,15 @@ static void it6505_video_reset(struct it6505 *it65= 05) > it6505_link_reset_step_train(it6505); > it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, EN_VID_M= UTE); > it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_VID_CTRL_PKT, 0x00= ); > - it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, VIDEO_RESET)= ; > + > + it6505_set_bits(it6505, REG_VID_BUS_CTRL1, TX_FIFO_RESET, TX_FIFO= _RESET); > + it6505_set_bits(it6505, REG_VID_BUS_CTRL1, TX_FIFO_RESET, 0x00); > + > it6505_set_bits(it6505, REG_501_FIFO_CTRL, RST_501_FIFO, RST_501_= FIFO); > it6505_set_bits(it6505, REG_501_FIFO_CTRL, RST_501_FIFO, 0x00); > + > + it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, VIDEO_RESET)= ; > + usleep_range(1000, 2000); > it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, 0x00); > } > > @@ -2249,12 +2255,11 @@ static void it6505_link_training_work(struct work= _struct *work) > if (ret) { > it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; > it6505_link_train_ok(it6505); > - return; > } else { > it6505->auto_train_retry--; > + it6505_dump(it6505); > } > > - it6505_dump(it6505); > } > > static void it6505_plugged_status_to_codec(struct it6505 *it6505) > @@ -2475,31 +2480,53 @@ static void it6505_irq_link_train_fail(struct it6= 505 *it6505) > schedule_work(&it6505->link_works); > } > > -static void it6505_irq_video_fifo_error(struct it6505 *it6505) > +static bool it6505_test_bit(unsigned int bit, const unsigned int *addr) > { > - struct device *dev =3D &it6505->client->dev; > - > - DRM_DEV_DEBUG_DRIVER(dev, "video fifo overflow interrupt"); > - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; > - flush_work(&it6505->link_works); > - it6505_stop_hdcp(it6505); > - it6505_video_reset(it6505); > + return 1 & (addr[bit / BITS_PER_BYTE] >> (bit % BITS_PER_BYTE)); > } > > -static void it6505_irq_io_latch_fifo_overflow(struct it6505 *it6505) > +static void it6505_irq_video_handler(struct it6505 *it6505, const int *i= nt_status) > { > struct device *dev =3D &it6505->client->dev; > + int reg_0d, reg_int03; > > - DRM_DEV_DEBUG_DRIVER(dev, "IO latch fifo overflow interrupt"); > - it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; > - flush_work(&it6505->link_works); > - it6505_stop_hdcp(it6505); > - it6505_video_reset(it6505); > -} > + /* > + * When video SCDT change with video not stable, > + * Or video FIFO error, need video reset > + */ > > -static bool it6505_test_bit(unsigned int bit, const unsigned int *addr) > -{ > - return 1 & (addr[bit / BITS_PER_BYTE] >> (bit % BITS_PER_BYTE)); > + if ((!it6505_get_video_status(it6505) && > + (it6505_test_bit(INT_SCDT_CHANGE, (unsigned int *) int_st= atus))) || > + (it6505_test_bit(BIT_INT_IO_FIFO_OVERFLOW, (unsigned int = *) int_status)) || > + (it6505_test_bit(BIT_INT_VID_FIFO_ERROR, (unsigned int *)= int_status))) { > + > + it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; > + flush_work(&it6505->link_works); > + it6505_stop_hdcp(it6505); > + it6505_video_reset(it6505); > + > + usleep_range(10000, 11000); > + > + /* > + * Clear FIFO error IRQ to prevent fifo error -> reset lo= op > + * HW will trigger SCDT change IRQ again when video stabl= e > + */ > + > + reg_int03 =3D it6505_read(it6505, INT_STATUS_03); > + reg_0d =3D it6505_read(it6505, REG_SYSTEM_STS); > + > + reg_int03 &=3D (BIT(INT_VID_FIFO_ERROR) | BIT(INT_IO_LATC= H_FIFO_OVERFLOW)); > + it6505_write(it6505, INT_STATUS_03, reg_int03); > + > + DRM_DEV_DEBUG_DRIVER(dev, "reg08 =3D 0x%02x", reg_int03); > + DRM_DEV_DEBUG_DRIVER(dev, "reg0D =3D 0x%02x", reg_0d); > + > + return; > + } > + > + > + if (it6505_test_bit(INT_SCDT_CHANGE, (unsigned int *) int_status)= ) > + it6505_irq_scdt(it6505); > } > > static irqreturn_t it6505_int_threaded_handler(int unused, void *data) > @@ -2512,15 +2539,12 @@ static irqreturn_t it6505_int_threaded_handler(in= t unused, void *data) > } irq_vec[] =3D { > { BIT_INT_HPD, it6505_irq_hpd }, > { BIT_INT_HPD_IRQ, it6505_irq_hpd_irq }, > - { BIT_INT_SCDT, it6505_irq_scdt }, > { BIT_INT_HDCP_FAIL, it6505_irq_hdcp_fail }, > { BIT_INT_HDCP_DONE, it6505_irq_hdcp_done }, > { BIT_INT_AUX_CMD_FAIL, it6505_irq_aux_cmd_fail }, > { BIT_INT_HDCP_KSV_CHECK, it6505_irq_hdcp_ksv_check }, > { BIT_INT_AUDIO_FIFO_ERROR, it6505_irq_audio_fifo_error }= , > { BIT_INT_LINK_TRAIN_FAIL, it6505_irq_link_train_fail }, > - { BIT_INT_VID_FIFO_ERROR, it6505_irq_video_fifo_error }, > - { BIT_INT_IO_FIFO_OVERFLOW, it6505_irq_io_latch_fifo_over= flow }, > }; > int int_status[3], i; > > @@ -2550,6 +2574,7 @@ static irqreturn_t it6505_int_threaded_handler(int = unused, void *data) > if (it6505_test_bit(irq_vec[i].bit, (unsigned int= *)int_status)) > irq_vec[i].handler(it6505); > } > + it6505_irq_video_handler(it6505, (unsigned int *) int_sta= tus); > } > > pm_runtime_put_sync(dev); > -- > 2.25.1 > Reviewed-by: Robert Foss