Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp393415lqi; Wed, 6 Mar 2024 23:37:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXus8gfQyvohL1/mjSy8Ub3hnu5p6arhKc1Vx5FApmKufx0mW795y09pYzCf8qA7iE9WQJHPKAlt8KhA5T14mcoyHl3w8tuhMoSEFmoMw== X-Google-Smtp-Source: AGHT+IFWEBx/byblIf87er4+Kk+rXeFxIGq1NAa9glw7cnf4bv7RUc0Xah5/6eT5oowKJFs4IMom X-Received: by 2002:a17:902:f685:b0:1db:ff7b:d202 with SMTP id l5-20020a170902f68500b001dbff7bd202mr9861839plg.11.1709797028398; Wed, 06 Mar 2024 23:37:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709797028; cv=pass; d=google.com; s=arc-20160816; b=Y9nyJDoCVzIbqMD49IJAs9XxCWPVMp+V96fKjVBGZaZ0XAodlS57zFyEOrHqmo8JnP ixnyXEDnKu6IxephXTp3QXDlRvd8+x9zhIK6B33eq0FTBd7bQSBG1vTuerdsXiJPBXeM X41Ihe6cLoNmntv8630J9JgWa0GcYXuSxOBrHks5eOaIe9bO1qvOQQHfFXV6tjmxOYKd Mmg9PZ2e10MKgRkwQUcHJSKvzUKBVhKX+FXGCz4y3IoxZEW4rVe/SoJ/El0iOrQf6tlH G8gZ3kbGgMbIwB45tlRpzh/isuXDTxFbkE86KLXqCwdnoc+SlKxkAxJzn8GG7NakTW09 sxbA== 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=w+MN4ptFkwcB+XZr/cs1zSULQpGzvYmR0JQ9D+CN+vc=; fh=CmE1ZqktT0ecNu/Nr6A4vqeoy4t9o5r5+xgnYqWQ444=; b=A3ZV7bg4VTN52ATLLNAVWblvNB+uyyCflggBHiKcUTUPvEUb9I13Z5l2ns+vFzLXGx TTN69yZY3tsTdTaV41VEKnMEpU2xU6fd1tiOgKmd5D7IAxjvAMwnJAHBo+OGRQ7UQc4+ au57jEEBoCG70+VcqeVs8BH+gnArXvWCkemwSR2Grr4ClF7vf1nKQlgBxhX+SXMM8Mag P+iSql94gOI+C6FyiWt2HI0MJ7fzSM9W+XT/wgAITOKGrs2nEUMQ0OpuEDvigwg0vlve unXxMnfuj3jVjsA4KXWpTK8MwTgrTfUM35qS/q2yFm90mio/QQOo5Co8d9Or63v6WKo1 U3TQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HIZCkuBj; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-95065-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95065-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2-20020a170903230200b001dca2801b86si14054502plh.353.2024.03.06.23.37.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 23:37:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95065-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HIZCkuBj; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-95065-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95065-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 14ACA282997 for ; Thu, 7 Mar 2024 07:37:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B849A63121; Thu, 7 Mar 2024 07:36:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HIZCkuBj" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 153654A31 for ; Thu, 7 Mar 2024 07:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709797008; cv=none; b=NwMknCEun3U6Pi176xjSEEaNKChyjWZfGXc2iLDeZkOtdL/7hFvnruH3AePrd2g21kcw/MvR4PgEVHBCdBl1Zc/HCpVjZQ3dbpHyyUPpoH2wt+lN9VGgvazIFvmGcWoEt8gxmqDB26SA22fhNAF0ORNx49XQWf6ZC39A3+yPrxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709797008; c=relaxed/simple; bh=E6S2dpyLsGYi8c5IEhuIzH3T3SPBzMU/IkeOrhc3E2s=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WLgweUsrmarxRqvCefdOQ+VckYjRXEXAttsxe5+P6XLgf7P6mtNWeQghPhbO92YPXMJuRiLlF3YNBbv9FNCoNeIEd+KqLZwkBIzh3/SZXeakR4gjYTxdRd0PkSBMLyFV/YWiRStiFRdcNogoHzXeTwd8eCkDgLXzOk2JtcwwHzk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HIZCkuBj; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1dcd6a3da83so3937945ad.3 for ; Wed, 06 Mar 2024 23:36:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709797006; x=1710401806; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w+MN4ptFkwcB+XZr/cs1zSULQpGzvYmR0JQ9D+CN+vc=; b=HIZCkuBjVVHbKEyi/YwfHoAmj8OHCp7KItXhG3CaUqUPYEBN+wYXMrPw3/bpfTOh2p GVsNDOX9aQxzl5+IdOHo8EcH3/daW5BvW2q2VehSkt/O41LuZPwFJwu3lZPVNrq7fSeU rHAHxha9R40AGNK5DOcE9H5B8/0MvZYGNVYCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709797006; x=1710401806; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w+MN4ptFkwcB+XZr/cs1zSULQpGzvYmR0JQ9D+CN+vc=; b=RzzGCtgwrEAo62EAwt79eD8VSdc3vksvN1qQOq632K9bZzJu+j9VbYLUcCcPsXiVr/ hMjMsQZZf4sh5eCpk2Aqf3++1W92Qf3e3iImSjAQxUS5zzc32Bd0d504rAz+H4kqVvbC n4QtsX9+J+LD+lkVSRHcA8oq3nosDR4s0YjtkfehM98BOqxkOuk+nm8j0X1EydC9SIQw PBNTxMX2OVvykg9L2TvrG8XabXPbbDvQInAZLyVKAIgH5BZQXRw8h3ftGQiHrArSkOGR L2SOJ1Xiot2fm9tYP47OVfQFcKoIH7zIZmq1C56Oj0j2ey7kvjQIclwHPRtkjNRRr3WU C6NQ== X-Forwarded-Encrypted: i=1; AJvYcCXUpGF6Q2PH87TbRZ6QN+Kavmgtq9FesKwuJX3VuqQKK+/ctSj7vk1QH8aBmMClnk8tYw9wwFC3ddtvROksHy9EUfS/rT5dTPi599Cq X-Gm-Message-State: AOJu0YzWxT0+SCRVgt94J25Mt8v5yiESi6ZSQr3QtqhwXpK4yqKVVxT4 TJl1QBodrS9L+L7yi2A/8QqAaRasv0YkREeOR2jopS0WYrSAgkUtgzK0pKLL5R7mX87T6s60qa6 n2i1eeTfBvAuGrcMchku+qvZ7pPdKBmEj/ueL X-Received: by 2002:a17:902:a389:b0:1dd:1c6f:af4f with SMTP id x9-20020a170902a38900b001dd1c6faf4fmr6633144pla.55.1709797006410; Wed, 06 Mar 2024 23:36:46 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306022003.259245-1-kuro.chung@ite.com.tw> <20240306022003.259245-2-kuro.chung@ite.com.tw> In-Reply-To: <20240306022003.259245-2-kuro.chung@ite.com.tw> From: Pin-yen Lin Date: Thu, 7 Mar 2024 15:36:35 +0800 Message-ID: Subject: Re: [PATCH v3 1/1] UPSTREAM: drm/bridge: it6505: fix hibernate to resume no display issue To: kuro Cc: Allen Chen , Kenneth Haung , Allen Chen , Andrzej Hajda , Neil Armstrong , Robert Foss , 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 Hi Kuro, Following up my comments from v2 [1]: On Wed, Mar 6, 2024 at 10:09=E2=80=AFAM kuro wrote: > > From: kuro chung > > 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: Allen Chen IIUC you need to sign this off with your name as well. See [2] for more det= ails. > --- > drivers/gpu/drm/bridge/ite-it6505.c | 54 ++++++++++++++++++++++++----- > 1 file changed, 45 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge= /ite-it6505.c > index b53da9bb65a16..e592e14a48578 100644 > --- a/drivers/gpu/drm/bridge/ite-it6505.c > +++ b/drivers/gpu/drm/bridge/ite-it6505.c > @@ -1318,6 +1318,8 @@ static void it6505_video_reset(struct it6505 *it650= 5) > 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, 0x02); > + 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, 0x00); > @@ -2480,10 +2482,6 @@ static void it6505_irq_video_fifo_error(struct it6= 505 *it6505) > 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); > } > > static void it6505_irq_io_latch_fifo_overflow(struct it6505 *it6505) > @@ -2491,10 +2489,6 @@ static void it6505_irq_io_latch_fifo_overflow(stru= ct it6505 *it6505) > struct device *dev =3D &it6505->client->dev; > > 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); > } I don't really like functions that only print one line of debug log, but I'm not sure what other reviewers think about this. > > static bool it6505_test_bit(unsigned int bit, const unsigned int *addr) > @@ -2502,6 +2496,46 @@ static bool it6505_test_bit(unsigned int bit, cons= t unsigned int *addr) > return 1 & (addr[bit / BITS_PER_BYTE] >> (bit % BITS_PER_BYTE)); > } > > +static bool it6505_is_video_error_int(const int *int_status) > +{ > + if ((it6505_test_bit(BIT_INT_VID_FIFO_ERROR, (unsigned int *)int_= status)) || (it6505_test_bit(BIT_INT_IO_FIFO_OVERFLOW, (unsigned int *)int_= status))) > + return 1; > + return 0; > +} > + > +static void it6505_irq_video_error_handler(struct it6505 *it6505) > +{ > + struct device *dev =3D &it6505->client->dev; > + int int_status[3] =3D {0}; > + int reg_0d; > + int i; > + > + it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; > + flush_work(&it6505->link_works); > + it6505_stop_hdcp(it6505); > + it6505_video_reset(it6505); > + > + DRM_DEV_DEBUG_DRIVER(dev, "Video Error reset wait video..."); > + > + for (i =3D 0; i < 10; i++) { > + usleep_range(10000, 11000); > + int_status[2] =3D it6505_read(it6505, INT_STATUS_03); > + reg_0d =3D it6505_read(it6505, REG_SYSTEM_STS); > + it6505_write(it6505, INT_STATUS_03, int_status[2]); > + > + DRM_DEV_DEBUG_DRIVER(dev, "reg08 =3D 0x%02x", int_status[= 2]); > + DRM_DEV_DEBUG_DRIVER(dev, "reg0D =3D 0x%02x", reg_0d); > + > + if ((reg_0d & VIDEO_STB) && (reg_0d >=3D 0)) > + break; > + > + if (it6505_is_video_error_int(int_status)) { > + it6505_video_reset(it6505); > + DRM_DEV_DEBUG_DRIVER(dev, "Video Error reset wait= video (%d)", i); > + } > + } Again, I think we need some code comments for this section, and some of your replies should be included there. And can you elaborate more about how this speeds up the video stabilization? What would happen if we only clear the interrupts once instead of doing a loop? > +} > + > static irqreturn_t it6505_int_threaded_handler(int unused, void *data) > { > struct it6505 *it6505 =3D data; > @@ -2522,7 +2556,7 @@ static irqreturn_t it6505_int_threaded_handler(int = unused, void *data) > { 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; > + int int_status[3], i, reg_0d; > > if (it6505->enable_drv_hold || !it6505->powered) > return IRQ_HANDLED; > @@ -2550,6 +2584,8 @@ 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); > } > + if (it6505_is_video_error_int(int_status)) > + it6505_irq_video_error_handler(it6505); > } > > pm_runtime_put_sync(dev); > -- > 2.25.1 > [1]: https://lore.kernel.org/all/CAEXTbpc6084rcmhFABw51SibU7FVyTWo=3DteQsET= q5vCujGKWng@mail.gmail.com/ [2]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html= #sign-your-work-the-developer-s-certificate-of-origin Regards, Pin-yen