Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp673770imm; Fri, 3 Aug 2018 09:38:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdQouMFC3XZxfN0Iw9HFw6WM7GBJlOCgbQAw5uO6zqNeqNvJmLnkNOrRiw0VzCpE1Po3L9a X-Received: by 2002:a63:40c7:: with SMTP id n190-v6mr4555651pga.116.1533314316089; Fri, 03 Aug 2018 09:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533314316; cv=none; d=google.com; s=arc-20160816; b=ORgJ9Gy2zNk5yIdbhEVH36GDfXfb+9mH9VyRnomuXeB9ghKXLwh8QssezYrl6dvwLV 0Snpy8GTDABLBIZstlpoEuUiVdD6jtIZmrKu5Evo4PBg4+NCK8L5RX11fKUWNXbnTQVI /WYDMUGUudoU2I1IeG+3XnuPsTcqdQ/OMM5zOXxiwREQ1VGZhZVuK7w+q+EeKPutzOHB bcAcKrZfSPZ7Ip8gl9GNSnk/n74F7OJ6qrguTLdZosJAppVeg/FFUlQ/RWS8M64LcqpZ uGxZoz0zI0LzIMcecx0cGjsgrRiz+5Kldgiu9DGyIQQNwa9DtvAP3rSv0QO1+M3NU5pn XEwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dM0Q+XTcl+F3fRalaLHBSDLbGw4s0kKZ1xr/UHitFKk=; b=SW6TbHctyyvbH4/XQgVisFjEyrWk/JCAlPKDZJqJJnAYfXgfWNw+/oQ/kUX3XoexBA e60Ugw5OmSBDTdWCIkVRryed8z3XsNhaXNVrRpZmErJZtVMIJH2BLnLA8ZLgtWDoT8Cj XbdVv/UpfhhoAT9KVrpGJsu/RzwGkkidGoTsMXDHdMzFKRFQuSi6J0wgzc1ndKQOks82 9sj4FjakvqctVwSmdvA32Z6UTsiGRc7wiNbRALKksWy2eC9cK+f7/kDxrHQtK7xSlNjb ax9UdWZyIADdAv/ldfa5hOlgZRacVY2RCYdCMH7mmmBCVx8vjJiJt1FxvbtVACQWz1R/ bIRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e36-v6si5002810pge.507.2018.08.03.09.37.58; Fri, 03 Aug 2018 09:38:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728171AbeHCScd (ORCPT + 99 others); Fri, 3 Aug 2018 14:32:33 -0400 Received: from mga14.intel.com ([192.55.52.115]:11987 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbeHCScc (ORCPT ); Fri, 3 Aug 2018 14:32:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 09:35:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,439,1526367600"; d="scan'208";a="80296287" Received: from espoo.fi.intel.com ([10.237.66.147]) by orsmga002.jf.intel.com with ESMTP; 03 Aug 2018 09:34:54 -0700 From: Gwan-gyeong Mun To: linux-kernel@vger.kernel.org Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/i915: Add detection of changing of edid on between suspend and resume Date: Fri, 3 Aug 2018 19:34:53 +0300 Message-Id: <20180803163453.7760-1-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hotplug detection routine of i915 uses drm_helper_hpd_irq_event(). This helper can detect changing of status of connector, but it can not detect changing of edid. Following scenario requires detection of changing of edid. 1) plug display device to a connector 2) system suspend 3) unplug 1)'s display device and plug the other display device to a connector 4) system resume It adds edid check routine when a connector status still remains as "connector_status_connected". Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate Testcase: igt/kms_chamelium/dp-edid-change-during-suspend Signed-off-by: Gwan-gyeong Mun --- drivers/gpu/drm/i915/intel_hotplug.c | 80 +++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c index 648a13c6043c..b92b83d46ccc 100644 --- a/drivers/gpu/drm/i915/intel_hotplug.c +++ b/drivers/gpu/drm/i915/intel_hotplug.c @@ -507,6 +507,84 @@ void intel_hpd_init(struct drm_i915_private *dev_priv) } } +/** + * intel_hpd_irq_event - hotplug processing + * @dev: drm_device + * + * Drivers can use this function to run a detect cycle on all connectors which + * have the DRM_CONNECTOR_POLL_HPD flag set in their &polled member. All other + * connectors are ignored, which is useful to avoid reprobing fixed panels. + * + * This function is useful for drivers which can't or don't track hotplug interrupts + * for each connector. This function is based on drm_helper_hpd_irq_event() helper + * function and besides it adds edid check routine when a connector status still + * remains as "connector_status_connected". + * + * Following scenario requires detection of changing of edid. + * 1) plug display device to a connector + * 2) system suspend + * 3) unplug 1)'s display device and plug the other display device to a connector + * 4) system resume + + * This function must be called from process context with no mode + * setting locks held. + * + * Note that a connector can be both polled and probed from the hotplug handler, + * in case the hotplug interrupt is known to be unreliable. + */ +static bool intel_hpd_irq_event(struct drm_device *dev) +{ + struct drm_connector *connector; + struct drm_connector_list_iter conn_iter; + enum drm_connector_status old_status, cur_status; + struct edid *old_edid; + bool changed = false; + + if (!dev->mode_config.poll_enabled) + return false; + + mutex_lock(&dev->mode_config.mutex); + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + /* Only handle HPD capable connectors. */ + if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) + continue; + + old_status = connector->status; + old_edid = to_intel_connector(connector)->detect_edid; + + cur_status = drm_helper_probe_detect(connector, NULL, false); + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", + connector->base.id, connector->name, + drm_get_connector_status_name(old_status), + drm_get_connector_status_name(cur_status)); + + if (old_status != cur_status) + changed = true; + + /* Check changing of edid when a connector status still remains + * as "connector_status_connected". */ + if (old_status == cur_status && + cur_status == connector_status_connected) { + struct edid *cur_edid = to_intel_connector(connector)->detect_edid; + + if (memcmp(old_edid, cur_edid, sizeof(*cur_edid)) != 0) { + changed = true; + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] edid updated\n", + connector->base.id, + connector->name); + } + } + } + drm_connector_list_iter_end(&conn_iter); + mutex_unlock(&dev->mode_config.mutex); + + if (changed) + drm_kms_helper_hotplug_event(dev); + + return changed; +} + static void i915_hpd_poll_init_work(struct work_struct *work) { struct drm_i915_private *dev_priv = @@ -552,7 +630,7 @@ static void i915_hpd_poll_init_work(struct work_struct *work) * in the middle of disabling polling */ if (!enabled) - drm_helper_hpd_irq_event(dev); + intel_hpd_irq_event(dev); } /** -- 2.18.0