From c127e2f649cac861aaab45c6c5275c837adb456f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 17 Jun 2019 13:58:38 +0200 Subject: [PATCH] 5.1-stable patches added patches: drm-add-fallback-override-firmware-edid-modes-workaround.patch drm-edid-abstract-override-firmware-edid-retrieval.patch --- ...rride-firmware-edid-modes-workaround.patch | 144 ++++++++++++++++++ ...act-override-firmware-edid-retrieval.patch | 66 ++++++++ queue-5.1/series | 2 + 3 files changed, 212 insertions(+) create mode 100644 queue-5.1/drm-add-fallback-override-firmware-edid-modes-workaround.patch create mode 100644 queue-5.1/drm-edid-abstract-override-firmware-edid-retrieval.patch diff --git a/queue-5.1/drm-add-fallback-override-firmware-edid-modes-workaround.patch b/queue-5.1/drm-add-fallback-override-firmware-edid-modes-workaround.patch new file mode 100644 index 00000000000..6bcfa3b66c2 --- /dev/null +++ b/queue-5.1/drm-add-fallback-override-firmware-edid-modes-workaround.patch @@ -0,0 +1,144 @@ +From 48eaeb7664c76139438724d520a1ea4a84a3ed92 Mon Sep 17 00:00:00 2001 +From: Jani Nikula +Date: Mon, 10 Jun 2019 12:30:54 +0300 +Subject: drm: add fallback override/firmware EDID modes workaround +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Jani Nikula + +commit 48eaeb7664c76139438724d520a1ea4a84a3ed92 upstream. + +We've moved the override and firmware EDID (simply "override EDID" from +now on) handling to the low level drm_do_get_edid() function in order to +transparently use the override throughout the stack. The idea is that +you get the override EDID via the ->get_modes() hook. + +Unfortunately, there are scenarios where the DDC probe in drm_get_edid() +called via ->get_modes() fails, although the preceding ->detect() +succeeds. + +In the case reported by Paul Wise, the ->detect() hook, +intel_crt_detect(), relies on hotplug detect, bypassing the DDC. In the +case reported by Ilpo Järvinen, there is no ->detect() hook, which is +interpreted as connected. The subsequent DDC probe reached via +->get_modes() fails, and we don't even look at the override EDID, +resulting in no modes being added. + +Because drm_get_edid() is used via ->detect() all over the place, we +can't trivially remove the DDC probe, as it leads to override EDID +effectively meaning connector forcing. The goal is that connector +forcing and override EDID remain orthogonal. + +Generally, the underlying problem here is the conflation of ->detect() +and ->get_modes() via drm_get_edid(). The former should just detect, and +the latter should just get the modes, typically via reading the EDID. As +long as drm_get_edid() is used in ->detect(), it needs to retain the DDC +probe. Or such users need to have a separate DDC probe step first. + +The EDID caching between ->detect() and ->get_modes() done by some +drivers is a further complication that prevents us from making +drm_do_get_edid() adapt to the two cases. + +Work around the regression by falling back to a separate attempt at +getting the override EDID at drm_helper_probe_single_connector_modes() +level. With a working DDC and override EDID, it'll never be called; the +override EDID will come via ->get_modes(). There will still be a failing +DDC probe attempt in the cases that require the fallback. + +v2: +- Call drm_connector_update_edid_property (Paul) +- Update commit message about EDID caching (Daniel) + +Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107583 +Reported-by: Paul Wise +Cc: Paul Wise +References: http://mid.mail-archive.com/alpine.DEB.2.20.1905262211270.24390@whs-18.cs.helsinki.fi +Reported-by: Ilpo Järvinen +Cc: Ilpo Järvinen +Suggested-by: Daniel Vetter +References: 15f080f08d48 ("drm/edid: respect connector force for drm_get_edid ddc probe") +Fixes: 53fd40a90f3c ("drm: handle override and firmware EDID at drm_do_get_edid() level") +Cc: # v4.15+ 56a2b7f2a39a drm/edid: abstract override/firmware EDID retrieval +Cc: # v4.15+ +Cc: Daniel Vetter +Cc: Ville Syrjälä +Cc: Harish Chegondi +Tested-by: Paul Wise +Reviewed-by: Daniel Vetter +Signed-off-by: Jani Nikula +Link: https://patchwork.freedesktop.org/patch/msgid/20190610093054.28445-1-jani.nikula@intel.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/drm_edid.c | 30 ++++++++++++++++++++++++++++++ + drivers/gpu/drm/drm_probe_helper.c | 7 +++++++ + include/drm/drm_edid.h | 1 + + 3 files changed, 38 insertions(+) + +--- a/drivers/gpu/drm/drm_edid.c ++++ b/drivers/gpu/drm/drm_edid.c +@@ -1595,6 +1595,36 @@ static struct edid *drm_get_override_edi + } + + /** ++ * drm_add_override_edid_modes - add modes from override/firmware EDID ++ * @connector: connector we're probing ++ * ++ * Add modes from the override/firmware EDID, if available. Only to be used from ++ * drm_helper_probe_single_connector_modes() as a fallback for when DDC probe ++ * failed during drm_get_edid() and caused the override/firmware EDID to be ++ * skipped. ++ * ++ * Return: The number of modes added or 0 if we couldn't find any. ++ */ ++int drm_add_override_edid_modes(struct drm_connector *connector) ++{ ++ struct edid *override; ++ int num_modes = 0; ++ ++ override = drm_get_override_edid(connector); ++ if (override) { ++ drm_connector_update_edid_property(connector, override); ++ num_modes = drm_add_edid_modes(connector, override); ++ kfree(override); ++ ++ DRM_DEBUG_KMS("[CONNECTOR:%d:%s] adding %d modes via fallback override/firmware EDID\n", ++ connector->base.id, connector->name, num_modes); ++ } ++ ++ return num_modes; ++} ++EXPORT_SYMBOL(drm_add_override_edid_modes); ++ ++/** + * drm_do_get_edid - get EDID data using a custom EDID block read function + * @connector: connector we're probing + * @get_edid_block: EDID block read function +--- a/drivers/gpu/drm/drm_probe_helper.c ++++ b/drivers/gpu/drm/drm_probe_helper.c +@@ -479,6 +479,13 @@ retry: + + count = (*connector_funcs->get_modes)(connector); + ++ /* ++ * Fallback for when DDC probe failed in drm_get_edid() and thus skipped ++ * override/firmware EDID. ++ */ ++ if (count == 0 && connector->status == connector_status_connected) ++ count = drm_add_override_edid_modes(connector); ++ + if (count == 0 && connector->status == connector_status_connected) + count = drm_add_modes_noedid(connector, 1024, 768); + count += drm_helper_probe_add_cmdline_mode(connector); +--- a/include/drm/drm_edid.h ++++ b/include/drm/drm_edid.h +@@ -465,6 +465,7 @@ struct edid *drm_get_edid_switcheroo(str + struct i2c_adapter *adapter); + struct edid *drm_edid_duplicate(const struct edid *edid); + int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); ++int drm_add_override_edid_modes(struct drm_connector *connector); + + u8 drm_match_cea_mode(const struct drm_display_mode *to_match); + enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); diff --git a/queue-5.1/drm-edid-abstract-override-firmware-edid-retrieval.patch b/queue-5.1/drm-edid-abstract-override-firmware-edid-retrieval.patch new file mode 100644 index 00000000000..661f3765c3f --- /dev/null +++ b/queue-5.1/drm-edid-abstract-override-firmware-edid-retrieval.patch @@ -0,0 +1,66 @@ +From 56a2b7f2a39a8d4b16a628e113decde3d7400879 Mon Sep 17 00:00:00 2001 +From: Jani Nikula +Date: Fri, 7 Jun 2019 14:05:12 +0300 +Subject: drm/edid: abstract override/firmware EDID retrieval + +From: Jani Nikula + +commit 56a2b7f2a39a8d4b16a628e113decde3d7400879 upstream. + +Abstract the debugfs override and the firmware EDID retrieval +function. We'll be needing it in the follow-up. No functional changes. + +Cc: Daniel Vetter +Cc: Harish Chegondi +Reviewed-by: Daniel Vetter +Tested-by: Tested-by: Paul Wise +Signed-off-by: Jani Nikula +Link: https://patchwork.freedesktop.org/patch/msgid/20190607110513.12072-1-jani.nikula@intel.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/drm_edid.c | 25 +++++++++++++++++-------- + 1 file changed, 17 insertions(+), 8 deletions(-) + +--- a/drivers/gpu/drm/drm_edid.c ++++ b/drivers/gpu/drm/drm_edid.c +@@ -1580,6 +1580,20 @@ static void connector_bad_edid(struct dr + } + } + ++/* Get override or firmware EDID */ ++static struct edid *drm_get_override_edid(struct drm_connector *connector) ++{ ++ struct edid *override = NULL; ++ ++ if (connector->override_edid) ++ override = drm_edid_duplicate(connector->edid_blob_ptr->data); ++ ++ if (!override) ++ override = drm_load_edid_firmware(connector); ++ ++ return IS_ERR(override) ? NULL : override; ++} ++ + /** + * drm_do_get_edid - get EDID data using a custom EDID block read function + * @connector: connector we're probing +@@ -1607,15 +1621,10 @@ struct edid *drm_do_get_edid(struct drm_ + { + int i, j = 0, valid_extensions = 0; + u8 *edid, *new; +- struct edid *override = NULL; +- +- if (connector->override_edid) +- override = drm_edid_duplicate(connector->edid_blob_ptr->data); +- +- if (!override) +- override = drm_load_edid_firmware(connector); ++ struct edid *override; + +- if (!IS_ERR_OR_NULL(override)) ++ override = drm_get_override_edid(connector); ++ if (override) + return override; + + if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) diff --git a/queue-5.1/series b/queue-5.1/series index a4c2e7e4ea0..bc599bb2c1b 100644 --- a/queue-5.1/series +++ b/queue-5.1/series @@ -109,3 +109,5 @@ x86-microcode-cpuhotplug-add-a-microcode-loader-cpu-hotplug-callback.patch x86-kasan-fix-boot-with-5-level-paging-and-kasan.patch x86-mm-kaslr-compute-the-size-of-the-vmemmap-section-properly.patch x86-resctrl-prevent-null-pointer-dereference-when-local-mbm-is-disabled.patch +drm-edid-abstract-override-firmware-edid-retrieval.patch +drm-add-fallback-override-firmware-edid-modes-workaround.patch -- 2.47.2