Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1624248lkv; Wed, 19 May 2021 14:19:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDUm9kAtZdrAzDIw/QU0WLQyH6uRftKJhSOFA2urYz4BA7MvHuQyeDvPNdRqIhq5nNMFvC X-Received: by 2002:a02:7a5b:: with SMTP id z27mr1398695jad.118.1621459198388; Wed, 19 May 2021 14:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621459198; cv=none; d=google.com; s=arc-20160816; b=bnpurXsEmFyjed8m6QfqtbtRHS3vfQMG4bhk2EpUOuQJZLfk6zkHrGA4IklumYYZHB s83MAe6FazvHkf1aSI702HTiqoQhUP9pyN10UmCFGSGpkdYqru6j3RGhtNNeNuIUL++D tmlxfwQuMLalm8vulNRpbdwWAvDGQOSBxCiaCYPg0Dvv0d+pw6aQ9SxouUcTKSn8JQog +orstVr+NskX7hB3RqKhfB7TcDlPnlmO2YsojJfyR25k2cFdRb72YM8AjvW24b/0ksZ0 zK13AzKTPhjRjyQsl8LuppD4IvLmir3J1iLdiU5+NC+trs+5d8kuucFsamylxt7vSi21 T9wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=kDU30zLEXE6xwILXMY7R1qs5dorqVFtA3XmZROhbl1M=; b=bcVfxoXsRMLwJxRQPHaHnTcy4R7+nBfRDrq/FGAXBXv1Gz8bVTD4XYnpGLYHLJ8VRC jVJl+kpo7ArzJmhPxpEw1bS124gdgr3uaKeOPoseNOzqq7Adg2oeG5F7bpwvAY9GlesN OdUtme3Kvnu1KpdrQOQfPxhQ3W63/zZNUVyjEPHNGn93QIchwqUljx43FBKAeeQmE78i S1/bPdACRebx8HZuXMeda6xpWyUxbmwifQw73K8nLtwVK8ILCP0d3rrouQzXYI8WO7qS Ce/vp90Zi5Kc8EOacIGR4hax9zrODbt3nVGBwX5xrLy9EJjeOzDZGSDCgtngD15b10vc WsjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JbtscaLB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si387906ioo.79.2021.05.19.14.19.44; Wed, 19 May 2021 14:19:58 -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=@chromium.org header.s=google header.b=JbtscaLB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhESVHz (ORCPT + 99 others); Wed, 19 May 2021 17:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbhESVHy (ORCPT ); Wed, 19 May 2021 17:07:54 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8548CC06175F for ; Wed, 19 May 2021 14:06:34 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id d3-20020a9d29030000b029027e8019067fso12956483otb.13 for ; Wed, 19 May 2021 14:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to:cc; bh=kDU30zLEXE6xwILXMY7R1qs5dorqVFtA3XmZROhbl1M=; b=JbtscaLB3JiwU4cKlJn71Bh7UUnQpW7ZCfcpuS6B+AJ+jHiFtZ285O3ALsivlM4ILz I0qDFcz6M9/gRMMeQfiVX8Z9x4VMU6zaSQLXRfStXCXV1f7ji6U3h+ehxfzeDvfrI4X8 11feTu+ykEtPAwrbhEjXYxtTuDQfv6LtKEO5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to:cc; bh=kDU30zLEXE6xwILXMY7R1qs5dorqVFtA3XmZROhbl1M=; b=fI5+I3YNMmUXZBy60JNdOa7g1/Ync6xY3mCiq9GKq3CHyk9rJYRsfxo62eHLxcHqli XWiiUeIINKKFZT2P9cSaw3l6+jSyS2zo+l+MegDdFtUXbL8QA/q2ouEwUfZa3/AlCP4j lFMSosptTCMQj8MH9Oby5Lewo/x3HRBFGbcylvSSUetHiFWkegZBrZCFf3QWYuCS21fG KZRALVZ2zXuH3JJ54Pkx/4E/tBtqWy9shGxc+m5FEUAFTiQHdV1A1KSAUhKYQDC2Fe/m QmPQgOyB7UTiaVd9QM6WcwYfGxxr//9mI0vQwMWVLIHwUM6+w+fOvZPbGZ3gYg1XKiMY 7KpQ== X-Gm-Message-State: AOAM531Xs0ZUINDsBjkWnkN7InBN7S05o6359mFWsEu4x7Vy/2MkBVyv EXHWTjyrAHdufqjKMiahKXedF86h9M0mQxtU838WCQ== X-Received: by 2002:a05:6830:1556:: with SMTP id l22mr1217157otp.34.1621458393963; Wed, 19 May 2021 14:06:33 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 19 May 2021 17:06:32 -0400 MIME-Version: 1.0 In-Reply-To: References: <1621013713-6860-1-git-send-email-khsieh@codeaurora.org> From: Stephen Boyd User-Agent: alot/0.9.1 Date: Wed, 19 May 2021 17:06:32 -0400 Message-ID: Subject: Re: [PATCH v4 1/2] drm/msm/dp: handle irq_hpd with sink_count = 0 correctly To: khsieh@codeaurora.org Cc: agross@kernel.org, bjorn.andersson@linaro.org, robdclark@gmail.com, sean@poorly.run, vkoul@kernel.org, abhinavk@codeaurora.org, aravindh@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting khsieh@codeaurora.org (2021-05-19 09:01:02) > On 2021-05-18 14:42, Stephen Boyd wrote: > > Quoting Kuogee Hsieh (2021-05-14 10:35:13) > >> irq_hpd interrupt should be handled after dongle plugged in and > >> before dongle unplugged. Hence irq_hpd interrupt is enabled at > >> the end of the plugin handle and disabled at the beginning of > >> unplugged handle. Current irq_hpd with sink_count = 0 is wrongly > >> handled same as the dongle unplugged which tears down the mainlink > >> and disables the phy. This patch fixes this problem by only tearing > >> down the mainlink but keeping phy enabled at irq_hpd with > >> sink_count = 0 handle so that next irq_hpd with sink_count =1 can be > >> handled by setup mainlink only. > >> > >> Changes in v2: > >> -- add ctrl->phy_Power_count > >> > >> Changes in v3: > >> -- del ctrl->phy_Power_count > >> -- add phy_power_off to dp_ctrl_off_link_stream() > >> > >> Changes in v4: > >> -- return immediately if clock disable failed at > >> dp_ctrl_off_link_stream() > >> > >> Signed-off-by: Kuogee Hsieh > > > > I think we want some Fixes tag. Not sure what it would be though. > > > > I also noticed that if I plug and unplug the HDMI cable from my apple > > dongle that I see this error message > > > > [drm:dp_display_usbpd_attention_cb] *ERROR* Disconnected, no > > DP_LINK_STATUS_UPDATED > > > *ERROR* Disconnected, no DP_LINK_STATUS_UPDATED <== this is caused by > > dongle generate the second > irq_hpd with sink_count = 0 after first first irq_hpd with sink_count = > 0. The fix is you have > set dongle to D3 (power off) state after first irq_pd with sink_count = > 0 handled. > I have a patch fix this problem. I will merge and re submit for review. That's good. I still don't understand how the kthread can't race with irq_hpd and hpd going low though. Userspace will have to disable the display and that could happen far later than the time that the hpd low interrupt fires and is processed. Can't hpd go high during that time and then blip before userspace notices and disables the display? Put another way, putting the dongle into D3 state may make the race window smaller, but it's not fixing the root cause of the problem which is that the kthread is running later and userspace is involved in the state of the dongle while irqs are firing. The three different contexts have to coordinate work, so it feels like a better approach would be to shut off the irq_hpd interrupt once hpd goes low for an unplug in hardirq context so that we don't have to consider the cable state or userspace changing the state after we notify it.