From patchwork Wed Oct 3 05:12:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guang Bai X-Patchwork-Id: 10624305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA10513BB for ; Wed, 3 Oct 2018 05:23:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C47C620952 for ; Wed, 3 Oct 2018 05:23:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4C422239C; Wed, 3 Oct 2018 05:23:07 +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 5A50F20952 for ; Wed, 3 Oct 2018 05:23:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E30C46E18C; Wed, 3 Oct 2018 05:23:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 343856E18C for ; Wed, 3 Oct 2018 05:23:05 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2018 22:23:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,334,1534834800"; d="scan'208";a="74983627" Received: from gbai-ub1604-lts.fm.intel.com ([10.1.23.154]) by fmsmga007.fm.intel.com with ESMTP; 02 Oct 2018 22:23:02 -0700 From: Guang Bai To: intel-gfx@lists.freedesktop.org Date: Tue, 2 Oct 2018 22:12:36 -0700 Message-Id: <1538543556-31778-1-git-send-email-guang.bai@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [Intel-gfx] [PATCH] drm/i915: Fix the HDMI hot plug disconnection failure 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: Jani Nikula , Chris Chiu MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP On some platforms, slowly unplugging (wiggling) the HDMI cable makes the kernel to believe the HDMI display still connected. This is because the HDMI DDC lines are disconnected sometimes later after the hot-plug interrupt triggered. Use the hot plug live states to honor HDMI hot plug status in addtion to access the DDC channels. Cc: Jani Nikula Cc: Chris Chiu Signed-off-by: Guang Bai --- drivers/gpu/drm/i915/intel_hotplug.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c index 648a13c..db6288f 100644 --- a/drivers/gpu/drm/i915/intel_hotplug.c +++ b/drivers/gpu/drm/i915/intel_hotplug.c @@ -246,17 +246,42 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work) intel_runtime_pm_put(dev_priv); } +#define MAX_SHORT_PULSE_MS 100 +#define PORT_CHECK_LOOP_COUNT 3 + bool intel_encoder_hotplug(struct intel_encoder *encoder, struct intel_connector *connector) { struct drm_device *dev = connector->base.dev; - enum drm_connector_status old_status; + enum drm_connector_status old_status, new_status; + enum hpd_pin pin = encoder->hpd_pin; + struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); + u32 count = 0; WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); old_status = connector->base.status; - connector->base.status = - drm_helper_probe_detect(&connector->base, NULL, false); + /* + * Set HDMI connection status based on hot-plug live states and + * display probe results. + */ + if ((encoder->type == INTEL_OUTPUT_HDMI || + encoder->type == INTEL_OUTPUT_DDI) && + dev_priv->hotplug.stats[pin].state == HPD_ENABLED) { + do { + new_status = connector_status_disconnected; + msleep(MAX_SHORT_PULSE_MS); + + if (intel_digital_port_connected(encoder)) + new_status = drm_helper_probe_detect(&connector->base, + NULL, false); + if (new_status == connector_status_connected) + break; + } while (++count <= PORT_CHECK_LOOP_COUNT); + connector->base.status = new_status; + } else + connector->base.status = + drm_helper_probe_detect(&connector->base, NULL, false); if (old_status == connector->base.status) return false;