From patchwork Sat Jul 7 00:03:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guang Bai X-Patchwork-Id: 10512619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 955416024A for ; Sat, 7 Jul 2018 00:08:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D9A2881E for ; Sat, 7 Jul 2018 00:08:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78F9728837; Sat, 7 Jul 2018 00:08:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A37C92881E for ; Sat, 7 Jul 2018 00:08:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 476886E14E; Sat, 7 Jul 2018 00:08:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F6C96E14E for ; Sat, 7 Jul 2018 00:08:40 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2018 17:08:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,318,1526367600"; d="scan'208";a="243662753" Received: from gbai-ub1604-lts.fm.intel.com (HELO gbai-ub1604-LTS) ([10.1.23.150]) by fmsmga006.fm.intel.com with ESMTP; 06 Jul 2018 17:08:35 -0700 Date: Fri, 6 Jul 2018 17:03:49 -0700 From: Guang Bai To: Rodrigo Vivi Message-ID: <20180706170349.79ae08d0@gbai-ub1604-LTS> In-Reply-To: <20180706203803.GE23473@intel.com> References: <20180705144009.GC5565@intel.com> <20180706104118.7e36c435@gbai-ub1604-LTS> <20180706203803.GE23473@intel.com> Organization: Intel Corporation X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Subject: Re: [Intel-gfx] [BUG] i915 HDMI connector status is connected after disconnection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 6 Jul 2018 13:38:06 -0700 Rodrigo Vivi wrote: > On Fri, Jul 06, 2018 at 10:41:18AM -0700, Guang Bai wrote: > > On Fri, 6 Jul 2018 14:44:58 +0800 > > Chris Chiu wrote: > > > > > On Thu, Jul 5, 2018 at 10:40 PM, Ville Syrjälä > > > wrote: > > > > On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote: > > > >> Hi, > > > >> We have few ASUS laptops X705FD (The new WiskyLake), X560UD > > > >> (intel i5-8250U), X530UN (intel i7-8550U) share the same > > > >> problem, which is the HDMI connector status stays connected > > > >> even the HDMI cable has been unplugged. Look into the > > > >> "/sys/class/drm/card0-HDMI-A-1/status" for checking the status > > > >> while plug/unplug the HDMI, it shows "disconnected" before > > > >> plug in HDMI cable, then switch to "connected" after plugin, > > > >> and still stay "connected" after unplug. This would cause the > > > >> audio output path cannot correctly switch from HDMI to > > > >> internal speaker after unplugging the HDMI. > > > >> > > > >> I then try to verify with the latest kernel 4.18.0-rc3+, the > > > >> bug still present. The full "dmesg" log is here. > > > >> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1 > > > >> > > > >> The HDMI cable is plugged in at ~26th second. > > > >> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has > > > >> basic audio support" > > > >> then unplug the HDMI at ~73th second. > > > >> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has > > > >> basic audio support" > > > >> > > > >> Please advise what I can do to fix this. Thanks > > > > > > > > Pull the cable out faster? > > > > > > > > I presume this is the same old case of hpd disconnecting > > > > slightly before ddc and we still manage to read the EDID when > > > > processing the hpd irq. We kinda tried to fix that with the > > > > live status check but that thing failed spectacularly. > > > > > > > > -- > > > > Ville Syrjälä > > > > Intel > > > > > > Thanks for the suggestion. I tried pulling the cable out faster, > > > the status shows correctly. I also tried branch drm-tip of > > > https://cgit.freedesktop.org/drm/drm-tip > > > but the symptom persists. > > > > > > Anything I can help here? Or any old commit/patch I can try to do > > > some experiments? > > > > > > Chris > > > _______________________________________________ > > > Intel-gfx mailing list > > > Intel-gfx@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx > > > > I'm working on a same issue with HP KBL ThinPro laptop where both > > > > kernel 4.9.79 & 4.15.7 are failing the same way: > > - Unplug the HDMI cable slowly the connector status is still > > "connected" > > > > Debugging shows from kernel 4.9 and up to 4.18 drim/i915 behaves the > > same way: > > - When the HDMI calbe is unplugged, there is a transition time when > > the DDC lines are still connected and i915 can read back the EDID > > and honors "connected" state > > > > This problem does not happen on Windows7 & Windows 10 on the same > > failing platform - Windows KMD does *not* read the DDC when seeing > > the corresponding PCH/HPD pins indicating "disconnected" within > > 300ms-400ms period - This checking is done during bottom-half > > interrupt routines > > > > I worked patches with both 4.15.7 and 4.17.1 intercepting this > > Windows KMD logics; It seems these patches work for HP KBL ThinPro > > laptop - My patches are being tested by HP team - I was just about > > to post the open discussion on this topic to collect inputs from > > our community > > please send them out anyways ;) > > > - Do we have to refactor the HDMI hot-plug handling codes to cope > > with this long standing issue? > > What is your proposal for re-work? > > > - Is that OK to add 300ms-500ms delay "msleep(100)" in a loop in the > > bottom half of interrupt routines? > > Well, We fight to add the delays only when they are required by specs, > rather than experimental on single display/configuration... > but/however/nevertheless we have cases that we retry aux > communications 32 times because a specific monitor... > > please show your patch and we discuss on top of it... > > > > > Regards, > > -Guang > > _______________________________________________ > > Intel-gfx mailing list > > Intel-gfx@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx Following is my temp/test patch evaluated by customers per this HDMI hot-plut issue: From 1b5a3c32bd50c88c22cb375f7815c9462f29eae5 Mon Sep 17 00:00:00 2001 From: Guang Bai Date: Fri, 6 Jul 2018 16:46:55 -0700 Subject: [PATCH] drm/i915: Temp/testing codes to address HDMI hot-plug issue When slowly unplugging the HDMI cable, some platforms still show the HDMI "connected" status - This issue happens from kernel 4.9 and up to 4.17.1 and drm-tip --- drivers/gpu/drm/i915/intel_hotplug.c | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) if (old_status == connector->status) @@ -285,6 +287,45 @@ static bool intel_hpd_irq_event(struct drm_device *dev, return true; } +static bool intel_hpd_irq_event2(struct drm_i915_private *dev_priv, + struct drm_connector *connector) +{ + struct drm_device *dev = &dev_priv->drm; + struct intel_connector *intel_connector = to_intel_connector(connector); + struct intel_encoder *intel_encoder = intel_connector->encoder; + enum hpd_pin pin = intel_encoder->hpd_pin; + bool changed = false; + bool check_connect = false; + u32 count = 0; + + DRM_DEBUG_KMS(">>> HP-TEST: Enter %s ...\n", __FUNCTION__); + + if (HAS_PCH_SPT(dev_priv) && + dev_priv->hotplug.stats[pin].state == HPD_ENABLED) { + do { + msleep(100); + /* + * Hard-code CPT PORT-B hot-plug status bit checking. + * Runtime checking based on port & pin TBD + */ + if (I915_READ(SDEISR) & SDE_PORTB_HOTPLUG_CPT) { + check_connect = true; + break; + } + } while (++count <= 4); + } else + check_connect = true; + + if (check_connect) { + changed |= intel_hpd_irq_event(dev, connector); + } else { + changed = (intel_connector->base.status != + connector_status_disconnected); + intel_connector->base.status = connector_status_disconnected; + } + return changed; +} + static void i915_digport_work_func(struct work_struct *work) { struct drm_i915_private *dev_priv = @@ -370,9 +411,11 @@ static void i915_hotplug_work_func(struct work_struct *work) if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) { DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n", connector->name, intel_encoder->hpd_pin); + DRM_DEBUG_KMS(">>> HP-TEST: intel_encoder->hot_plug = %llx...\n", + (unsigned long long)(intel_encoder->hot_plug)); if (intel_encoder->hot_plug) intel_encoder->hot_plug(intel_encoder); - if (intel_hpd_irq_event(dev, connector)) + if (intel_hpd_irq_event2(dev_priv, connector)) changed = true; } } diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c index 875d5d2..fafa9a7 100644 --- a/drivers/gpu/drm/i915/intel_hotplug.c +++ b/drivers/gpu/drm/i915/intel_hotplug.c @@ -271,6 +271,8 @@ static bool intel_hpd_irq_event(struct drm_device *dev, WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); old_status = connector->status; + DRM_DEBUG_KMS(">>> HP-TEST: Enter %s ...\n", __FUNCTION__); + connector->status = drm_helper_probe_detect(connector, NULL, false);