From patchwork Fri Mar 1 10:01:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwan-gyeong Mun X-Patchwork-Id: 10834893 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 F35E31669 for ; Fri, 1 Mar 2019 10:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE3282F13A for ; Fri, 1 Mar 2019 10:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CECA82F15F; Fri, 1 Mar 2019 10:01:06 +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 539172F13A for ; Fri, 1 Mar 2019 10:01:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 952776E2AD; Fri, 1 Mar 2019 10:01: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 E9E5E6E2AD for ; Fri, 1 Mar 2019 10:01:04 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 01 Mar 2019 02:01:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,427,1544515200"; d="scan'208";a="137252164" Received: from helsinki.fi.intel.com ([10.237.66.164]) by FMSMGA003.fm.intel.com with ESMTP; 01 Mar 2019 02:01:03 -0800 From: Gwan-gyeong Mun To: intel-gfx@lists.freedesktop.org Date: Fri, 1 Mar 2019 12:01:01 +0200 Message-Id: <20190301100102.18064-1-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] drm: move a detected edid member to drm_connector from intel_connector 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP In order to use a detected edid on drm helper functions, it moves a detected edid member to drm_connector structure from intel_connector structure. v2: Rebased. Signed-off-by: Gwan-gyeong Mun --- drivers/gpu/drm/i915/intel_connector.c | 2 +- drivers/gpu/drm/i915/intel_dp.c | 17 ++++++++--------- drivers/gpu/drm/i915/intel_drv.h | 1 - drivers/gpu/drm/i915/intel_hdmi.c | 8 ++++---- include/drm/drm_connector.h | 7 +++++++ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_connector.c b/drivers/gpu/drm/i915/intel_connector.c index 848dd9e728d8..175cdbcbdc4e 100644 --- a/drivers/gpu/drm/i915/intel_connector.c +++ b/drivers/gpu/drm/i915/intel_connector.c @@ -86,7 +86,7 @@ void intel_connector_destroy(struct drm_connector *connector) { struct intel_connector *intel_connector = to_intel_connector(connector); - kfree(intel_connector->detect_edid); + kfree(intel_connector->base.detect_edid); intel_hdcp_cleanup(intel_connector); diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index e1a051c0fbfe..bc493656e183 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -4479,7 +4479,7 @@ static u8 intel_dp_autotest_edid(struct intel_dp *intel_dp) struct intel_connector *intel_connector = intel_dp->attached_connector; struct drm_connector *connector = &intel_connector->base; - if (intel_connector->detect_edid == NULL || + if (connector->detect_edid == NULL || connector->edid_corrupt || intel_dp->aux.i2c_defer_count > 6) { /* Check EDID read for NACKs, DEFERs and corruption @@ -4496,12 +4496,12 @@ static u8 intel_dp_autotest_edid(struct intel_dp *intel_dp) intel_dp->aux.i2c_defer_count); intel_dp->compliance.test_data.edid = INTEL_DP_RESOLUTION_FAILSAFE; } else { - struct edid *block = intel_connector->detect_edid; + struct edid *block = connector->detect_edid; /* We have to write the checksum * of the last block read */ - block += intel_connector->detect_edid->extensions; + block += connector->detect_edid->extensions; if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_EDID_CHECKSUM, block->checksum) <= 0) @@ -5355,7 +5355,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp) intel_dp_unset_edid(intel_dp); edid = intel_dp_get_edid(intel_dp); - intel_connector->detect_edid = edid; + intel_connector->base.detect_edid = edid; intel_dp->has_audio = drm_detect_monitor_audio(edid); drm_dp_cec_set_edid(&intel_dp->aux, edid); @@ -5367,8 +5367,8 @@ intel_dp_unset_edid(struct intel_dp *intel_dp) struct intel_connector *intel_connector = intel_dp->attached_connector; drm_dp_cec_unset_edid(&intel_dp->aux); - kfree(intel_connector->detect_edid); - intel_connector->detect_edid = NULL; + kfree(intel_connector->base.detect_edid); + intel_connector->base.detect_edid = NULL; intel_dp->has_audio = false; } @@ -5471,8 +5471,7 @@ intel_dp_detect(struct drm_connector *connector, intel_dp->aux.i2c_defer_count = 0; intel_dp_set_edid(intel_dp); - if (intel_dp_is_edp(intel_dp) || - to_intel_connector(connector)->detect_edid) + if (intel_dp_is_edp(intel_dp) || connector->detect_edid) status = connector_status_connected; intel_dp_check_service_irq(intel_dp); @@ -5515,7 +5514,7 @@ static int intel_dp_get_modes(struct drm_connector *connector) struct intel_connector *intel_connector = to_intel_connector(connector); struct edid *edid; - edid = intel_connector->detect_edid; + edid = connector->detect_edid; if (edid) { int ret = intel_connector_update_modes(connector, edid); if (ret) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 5412373e2f98..6f641980a877 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -503,7 +503,6 @@ struct intel_connector { /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */ struct edid *edid; - struct edid *detect_edid; /* since POLL and HPD connectors may use the same HPD line keep the native state of connector->polled in case hotplug storm detection changes it */ diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index cd422a7b4da0..82fd4b535c45 100644 --- a/drivers/gpu/drm/i915/intel_hdmi.c +++ b/drivers/gpu/drm/i915/intel_hdmi.c @@ -2395,8 +2395,8 @@ intel_hdmi_unset_edid(struct drm_connector *connector) intel_hdmi->dp_dual_mode.type = DRM_DP_DUAL_MODE_NONE; intel_hdmi->dp_dual_mode.max_tmds_clock = 0; - kfree(to_intel_connector(connector)->detect_edid); - to_intel_connector(connector)->detect_edid = NULL; + kfree(connector->detect_edid); + connector->detect_edid = NULL; } static void @@ -2473,7 +2473,7 @@ intel_hdmi_set_edid(struct drm_connector *connector) intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS, wakeref); - to_intel_connector(connector)->detect_edid = edid; + connector->detect_edid = edid; if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) { intel_hdmi->has_audio = drm_detect_monitor_audio(edid); intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid); @@ -2536,7 +2536,7 @@ static int intel_hdmi_get_modes(struct drm_connector *connector) { struct edid *edid; - edid = to_intel_connector(connector)->detect_edid; + edid = connector->detect_edid; if (edid == NULL) return 0; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index c8061992d6cb..f1b4e39227e3 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1140,6 +1140,13 @@ struct drm_connector { */ bool edid_corrupt; + /** + * @detect_edid: indicates a cached EDID for a detection cycle + * As we may query the edid multiple times following a detect, record + * the EDID found during output discovery and reuse it. + */ + struct edid *detect_edid; + /** @debugfs_entry: debugfs directory for this connector */ struct dentry *debugfs_entry; From patchwork Fri Mar 1 10:01:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwan-gyeong Mun X-Patchwork-Id: 10834895 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 F3F6F1669 for ; Fri, 1 Mar 2019 10:01:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E294C2F13A for ; Fri, 1 Mar 2019 10:01:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D667F2F15F; Fri, 1 Mar 2019 10:01: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 8212C2F13A for ; Fri, 1 Mar 2019 10:01:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED64A6E2B0; Fri, 1 Mar 2019 10:01:06 +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 996126E2AE for ; Fri, 1 Mar 2019 10:01:05 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 01 Mar 2019 02:01:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,427,1544515200"; d="scan'208";a="137252230" Received: from helsinki.fi.intel.com ([10.237.66.164]) by FMSMGA003.fm.intel.com with ESMTP; 01 Mar 2019 02:01:04 -0800 From: Gwan-gyeong Mun To: intel-gfx@lists.freedesktop.org Date: Fri, 1 Mar 2019 12:01:02 +0200 Message-Id: <20190301100102.18064-2-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190301100102.18064-1-gwan-gyeong.mun@intel.com> References: <20190301100102.18064-1-gwan-gyeong.mun@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 2/2] drm: Add detection of changing of edid on between suspend and resume 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The hotplug detection routine of drm_helper_hpd_irq_event() 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". v2: Add NULL check before comparing of EDIDs. v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan, Mika) 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/drm_probe_helper.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 6fd08e04b323..036a57d2b29e 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -742,7 +742,16 @@ EXPORT_SYMBOL(drm_kms_helper_poll_fini); * panels. * * This helper function is useful for drivers which can't or don't track hotplug - * interrupts for each connector. + * interrupts for each connector. And it also supports a detection of changing + * of edid on between suspend and resume 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 * * Drivers which support hotplug interrupts for each connector individually and * which have a more fine-grained detect logic should bypass this code and @@ -760,6 +769,7 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev) struct drm_connector *connector; struct drm_connector_list_iter conn_iter; enum drm_connector_status old_status; + struct edid *old_edid; bool changed = false; if (!dev->mode_config.poll_enabled) @@ -773,6 +783,7 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev) continue; old_status = connector->status; + old_edid = connector->detect_edid; connector->status = drm_helper_probe_detect(connector, NULL, false); DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", @@ -782,6 +793,22 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev) drm_get_connector_status_name(connector->status)); if (old_status != connector->status) changed = true; + + /* Check changing of edid when a connector status still remains + * as "connector_status_connected". + */ + if (old_status == connector->status && + old_status == connector_status_connected) { + if (!old_edid || !connector->detect_edid) + continue; + + if (memcmp(old_edid, connector->detect_edid, sizeof(*old_edid))) { + 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);