drm/amdgpu: Retry DDC probing on DVI on failure if we got an HPD interrupt
authorxurui <xurui@kylinos.cn>
Fri, 23 Dec 2022 09:28:58 +0000 (17:28 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 5 Jan 2023 16:42:09 +0000 (11:42 -0500)
HPD signals on DVI ports can be fired off before the pins required for
DDC probing actually make contact, due to the pins for HPD making
contact first. This results in a HPD signal being asserted but DDC
probing failing, resulting in hotplugging occasionally failing.

Rescheduling the hotplug work for a second when we run into an HPD
signal with a failing DDC probe usually gives enough time for the rest
of the connector's pins to make contact, and fixes this issue.

Signed-off-by: xurui <xurui@kylinos.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c

index 366aa1506d7e4b7edbbfc5feaf7d3d475eeb3cdb..872450a3a164c17b451493f095327abdcf386799 100644 (file)
@@ -876,7 +876,7 @@ struct amdgpu_device {
        struct amdgpu_vkms_output       *amdgpu_vkms_output;
        struct amdgpu_mode_info         mode_info;
        /* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
-       struct work_struct              hotplug_work;
+       struct delayed_work         hotplug_work;
        struct amdgpu_irq_src           crtc_irq;
        struct amdgpu_irq_src           vline0_irq;
        struct amdgpu_irq_src           vupdate_irq;
index 2ebbc6382a0613057c8bef29cc892c8101ac0e1c..d2abd334b1b5ea2318bc91e910c5813e8e428df1 100644 (file)
@@ -996,13 +996,33 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
                }
        }
 
+       if (amdgpu_connector->detected_hpd_without_ddc) {
+               force = true;
+               amdgpu_connector->detected_hpd_without_ddc = false;
+       }
+
        if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
                ret = connector->status;
                goto exit;
        }
 
-       if (amdgpu_connector->ddc_bus)
+       if (amdgpu_connector->ddc_bus) {
                dret = amdgpu_display_ddc_probe(amdgpu_connector, false);
+
+               /* Sometimes the pins required for the DDC probe on DVI
+                * connectors don't make contact at the same time that the ones
+                * for HPD do. If the DDC probe fails even though we had an HPD
+                * signal, try again later
+                */
+               if (!dret && !force &&
+                   amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd)) {
+                       DRM_DEBUG_KMS("hpd detected without ddc, retrying in 1 second\n");
+                       amdgpu_connector->detected_hpd_without_ddc = true;
+                       schedule_delayed_work(&adev->hotplug_work,
+                                             msecs_to_jiffies(1000));
+                       goto exit;
+               }
+       }
        if (dret) {
                amdgpu_connector->detected_by_load = false;
                amdgpu_connector_free_edid(connector);
index b22471b3bd63f4e4c8d87f079b5108bffa609cbc..a876648e3d7a612fe4079223292772b90e8d5697 100644 (file)
@@ -63,7 +63,7 @@
 void amdgpu_display_hotplug_work_func(struct work_struct *work)
 {
        struct amdgpu_device *adev = container_of(work, struct amdgpu_device,
-                                                 hotplug_work);
+                                                 hotplug_work.work);
        struct drm_device *dev = adev_to_drm(adev);
        struct drm_mode_config *mode_config = &dev->mode_config;
        struct drm_connector *connector;
index 8a39300b1a845c34d89154c5fa98dec996d94734..93c73faa5714abdfb9ae95a80e77989c2d819003 100644 (file)
@@ -534,6 +534,7 @@ struct amdgpu_connector {
        void *con_priv;
        bool dac_load_detect;
        bool detected_by_load; /* if the connection status was determined by load */
+       bool detected_hpd_without_ddc; /* if an HPD signal was detected on DVI, but ddc probing failed */
        uint16_t connector_object_id;
        struct amdgpu_hpd hpd;
        struct amdgpu_router router;
index 248f1a4e915f7c897019468b60207210dc338ae3..e85e57933cc45f4d1d22041de559b9122f8ada21 100644 (file)
@@ -2837,7 +2837,7 @@ static int dce_v10_0_sw_init(void *handle)
        if (r)
                return r;
 
-       INIT_WORK(&adev->hotplug_work,
+       INIT_DELAYED_WORK(&adev->hotplug_work,
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
@@ -2902,7 +2902,7 @@ static int dce_v10_0_hw_fini(void *handle)
 
        dce_v10_0_pageflip_interrupt_fini(adev);
 
-       flush_work(&adev->hotplug_work);
+       flush_delayed_work(&adev->hotplug_work);
 
        return 0;
 }
@@ -3302,7 +3302,7 @@ static int dce_v10_0_hpd_irq(struct amdgpu_device *adev,
 
        if (disp_int & mask) {
                dce_v10_0_hpd_int_ack(adev, hpd);
-               schedule_work(&adev->hotplug_work);
+               schedule_delayed_work(&adev->hotplug_work, 0);
                DRM_DEBUG("IH: HPD%d\n", hpd + 1);
        }
 
index cd9c19060d89883bb16a09601010273aa4fdc8dd..6b406bb7f3f366ef8f963603ce5893ce6f4030ee 100644 (file)
@@ -2956,7 +2956,7 @@ static int dce_v11_0_sw_init(void *handle)
        if (r)
                return r;
 
-       INIT_WORK(&adev->hotplug_work,
+       INIT_DELAYED_WORK(&adev->hotplug_work,
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
@@ -3032,7 +3032,7 @@ static int dce_v11_0_hw_fini(void *handle)
 
        dce_v11_0_pageflip_interrupt_fini(adev);
 
-       flush_work(&adev->hotplug_work);
+       flush_delayed_work(&adev->hotplug_work);
 
        return 0;
 }
@@ -3426,7 +3426,7 @@ static int dce_v11_0_hpd_irq(struct amdgpu_device *adev,
 
        if (disp_int & mask) {
                dce_v11_0_hpd_int_ack(adev, hpd);
-               schedule_work(&adev->hotplug_work);
+               schedule_delayed_work(&adev->hotplug_work, 0);
                DRM_DEBUG("IH: HPD%d\n", hpd + 1);
        }
 
index 76323deecc589e92eb2902c08234522e378ca9f5..2aa21eec0e063a91ff6585d83551eeb602a8f51b 100644 (file)
@@ -2715,7 +2715,7 @@ static int dce_v6_0_sw_init(void *handle)
                return r;
 
        /* Pre-DCE11 */
-       INIT_WORK(&adev->hotplug_work,
+       INIT_DELAYED_WORK(&adev->hotplug_work,
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
@@ -2776,7 +2776,7 @@ static int dce_v6_0_hw_fini(void *handle)
 
        dce_v6_0_pageflip_interrupt_fini(adev);
 
-       flush_work(&adev->hotplug_work);
+       flush_delayed_work(&adev->hotplug_work);
 
        return 0;
 }
@@ -3103,7 +3103,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,
                tmp = RREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd]);
                tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK;
                WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp);
-               schedule_work(&adev->hotplug_work);
+               schedule_delayed_work(&adev->hotplug_work, 0);
                DRM_DEBUG("IH: HPD%d\n", hpd + 1);
        }
 
index 01cf3ab111cbefbf59ff0a3f4e379851c530010a..9da338889d363df7bc67cc1bf47f43e991738dbd 100644 (file)
@@ -2739,7 +2739,7 @@ static int dce_v8_0_sw_init(void *handle)
                return r;
 
        /* Pre-DCE11 */
-       INIT_WORK(&adev->hotplug_work,
+       INIT_DELAYED_WORK(&adev->hotplug_work,
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
@@ -2802,7 +2802,7 @@ static int dce_v8_0_hw_fini(void *handle)
 
        dce_v8_0_pageflip_interrupt_fini(adev);
 
-       flush_work(&adev->hotplug_work);
+       flush_delayed_work(&adev->hotplug_work);
 
        return 0;
 }
@@ -3195,7 +3195,7 @@ static int dce_v8_0_hpd_irq(struct amdgpu_device *adev,
                tmp = RREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd]);
                tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK;
                WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp);
-               schedule_work(&adev->hotplug_work);
+               schedule_delayed_work(&adev->hotplug_work, 0);
                DRM_DEBUG("IH: HPD%d\n", hpd + 1);
        }