Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp54670pxy; Wed, 21 Apr 2021 18:18:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN5ExapENrz/IkCZmNIwwKjLCH/tV0qnP41m+JcFjcXoDG0mhmtMDE5uu2oUGC+EUrBKmZ X-Received: by 2002:a17:90a:b794:: with SMTP id m20mr1082830pjr.152.1619054332112; Wed, 21 Apr 2021 18:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619054332; cv=none; d=google.com; s=arc-20160816; b=ZZlB/87GBla6l1cZ0bhNt6CrS7QGig6fMTcbhuzEr24ZiNCDJLEC/JaXkOEJkMt9Rh bz0uDSW0ZfKj4XDadWtAC5eBguIYXvU9LDnx+ygPRh6668Tnxcs0UmcC0EqNzPgUau5n 4UIuTCKZub/C88XM7B1rbLIAZqA9UvNmD8TAeW4p+KZ9JcnDgzLMJ1EfoY/57n1w0Ch5 D65PSIhZs9kBQCB1hrWqsBbZMo3myTOuBCWTspbmjOelQ9utcpQdaRvW+ChjjQi/1rvI mKEkAiGMbplEKMMG3hpjvFHdvNc3bGGBPBsq902b2Tj+WKdeEdlObKrwINoDYoPLVCrp 3ETw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=y7qK94xUWLx6N7TlAKwTp7gAjHIxqzroU6QKac5T3Ag=; b=Hq7Mh9/AzhYrrS60IiKWdpn5tpZBxVajRjJMklZlREUoorc2nMqSJSsPSTwnORqfU1 PQ408n7CMunPhsSbo7fJWGwSMnHZj8PFIBMo12BeJTaK+GjgP+NHwJr9xCDKfJf4K7HM YbCqPLt/3KA5oCJKbJjUcPI/buqFjE2F5nCp7RoFux/jhbfOQ8A3yLI+L3b8gNWEtfw0 aULEmQzPZhFmR8aHSNOLo6kfLADZVkv12DwkvKHPtdekN+7MUn+w8iPU8VwFFwIqYK5G k3WTDWG2OzTHx5jQD6bxOnVAmI2PlK0qmbvh6QERmoSKsDB8dvTOgrFV87ID1oN4RFKZ f43A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=UoBGF4JG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si1221802pjt.9.2021.04.21.18.18.40; Wed, 21 Apr 2021 18:18:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=UoBGF4JG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245318AbhDUS4T (ORCPT + 99 others); Wed, 21 Apr 2021 14:56:19 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:21772 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244944AbhDUS4R (ORCPT ); Wed, 21 Apr 2021 14:56:17 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1619031343; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=y7qK94xUWLx6N7TlAKwTp7gAjHIxqzroU6QKac5T3Ag=; b=UoBGF4JGAbTa2AUYMMlRfPS8rZ9ZdO15/F88nLgrsJn11pFrozgQocdJnzwB6JRzHvaT16v2 w6PUQEtiohXGJvnUH0IaBzzPnVJKtmUwR+baSoQSLR6UZqL0kJYD58FIJQ4CfAOMJvwOzCFf 68vFYHgMXlnahcO57C+k3PV7MFc= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 6080751ba817abd39afe6b40 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 21 Apr 2021 18:55:23 GMT Sender: aravindh=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8E74DC43217; Wed, 21 Apr 2021 18:55:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: aravindh) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5FDBBC433F1; Wed, 21 Apr 2021 18:55:21 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 21 Apr 2021 11:55:21 -0700 From: aravindh@codeaurora.org To: khsieh@codeaurora.org Cc: Stephen Boyd , robdclark@gmail.com, sean@poorly.run, abhinavk@codeaurora.org, airlied@linux.ie, daniel@ffwll.ch, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] drm/msm/dp: service only one irq_hpd if there are multiple irq_hpd pending In-Reply-To: References: <1618604877-28297-1-git-send-email-khsieh@codeaurora.org> <161895606268.46595.2841353121480638642@swboyd.mtv.corp.google.com> Message-ID: X-Sender: aravindh@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-04-21 10:26, khsieh@codeaurora.org wrote: > On 2021-04-20 15:01, Stephen Boyd wrote: >> Quoting Kuogee Hsieh (2021-04-16 13:27:57) >>> Some dongle may generate more than one irq_hpd events in a short >>> period of >>> time. This patch will treat those irq_hpd events as single one and >>> service >>> only one irq_hpd event. >> >> Why is it bad to get multiple irq_hpd events in a short period of >> time? >> Please tell us here in the commit text. >> >>> >>> Signed-off-by: Kuogee Hsieh >>> --- >>> drivers/gpu/drm/msm/dp/dp_display.c | 9 +++++++++ >>> 1 file changed, 9 insertions(+) >>> >>> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c >>> b/drivers/gpu/drm/msm/dp/dp_display.c >>> index 5a39da6..0a7d383 100644 >>> --- a/drivers/gpu/drm/msm/dp/dp_display.c >>> +++ b/drivers/gpu/drm/msm/dp/dp_display.c >>> @@ -707,6 +707,9 @@ static int dp_irq_hpd_handle(struct >>> dp_display_private *dp, u32 data) >>> return 0; >>> } >>> >>> + /* only handle first irq_hpd in case of multiple irs_hpd >>> pending */ >>> + dp_del_event(dp, EV_IRQ_HPD_INT); >>> + >>> ret = dp_display_usbpd_attention_cb(&dp->pdev->dev); >>> if (ret == -ECONNRESET) { /* cable unplugged */ >>> dp->core_initialized = false; >>> @@ -1300,6 +1303,9 @@ static int dp_pm_suspend(struct device *dev) >>> /* host_init will be called at pm_resume */ >>> dp->core_initialized = false; >>> >>> + /* system suspended, delete pending irq_hdps */ >>> + dp_del_event(dp, EV_IRQ_HPD_INT); >> >> What happens if I suspend my device and when this function is running >> I >> toggle my monitor to use the HDMI input that is connected instead of >> some >> other input, maybe the second HDMI input? Wouldn't that generate an >> HPD >> interrupt to grab the attention of this device? > no, > At this time display is off. this mean dp controller is off and > mainlink has teared down. > it will start with plug in interrupt to bring dp controller up and > start link training. > irq_hpd can be generated only panel is at run time of operation mode > and need attention from host. > If host is shutting down, then no need to service pending irq_hpd. > >> >>> + >>> mutex_unlock(&dp->event_mutex); >>> >>> return 0; >>> @@ -1496,6 +1502,9 @@ int msm_dp_display_disable(struct msm_dp *dp, >>> struct drm_encoder *encoder) >>> /* stop sentinel checking */ >>> dp_del_event(dp_display, EV_DISCONNECT_PENDING_TIMEOUT); >>> >>> + /* link is down, delete pending irq_hdps */ >>> + dp_del_event(dp_display, EV_IRQ_HPD_INT); >>> + >> >> I'm becoming convinced that the whole kthread design and event queue >> is >> broken. These sorts of patches are working around the larger problem >> that the kthread is running independently of the driver and irqs can >> come in at any time but the event queue is not checked from the irq >> handler to debounce the irq event. Is the event queue necessary at >> all? >> I wonder if it would be simpler to just use an irq thread and process >> the hpd signal from there. Then we're guaranteed to not get an irq >> again >> until the irq thread is done processing the event. This would >> naturally >> debounce the irq hpd event that way. > event q just like bottom half of irq handler. it turns irq into event > and handle them sequentially. > irq_hpd is asynchronous event from panel to bring up attention of hsot > during run time of operation. > Here, the dongle is unplugged and main link had teared down so that no > need to service pending irq_hpd if any. > As Kuogee mentioned, IRQ_HPD is a message received from the panel and is not like your typical HW generated IRQ. There is no guarantee that we will not receive an IRQ_HPD until we are finished with processing of an earlier HPD message or an IRQ_HPD message. For example - when you run the protocol compliance, when we get a HPD from the sink, we are expected to start reading DPCD, EDID and proceed with link training. As soon as link training is finished (which is marked by a specific DPCD register write), the sink is going to issue an IRQ_HPD. At this point, we may not done with processing the HPD high as after link training we would typically notify the user mode of the newly connected display, etc. > >> >>> dp_display_disable(dp_display, 0); >>> >>> rc = dp_display_unprepare(dp);