Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760961AbbKUOz2 (ORCPT ); Sat, 21 Nov 2015 09:55:28 -0500 Received: from mail-by2on0067.outbound.protection.outlook.com ([207.46.100.67]:54181 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1760186AbbKUOz0 (ORCPT ); Sat, 21 Nov 2015 09:55:26 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Subject: Re: [PATCH] drm/radeon: Retry DDC probing on DVI on failure if we got an HPD interrupt To: , Alex Deucher , David Airlie , , References: <1448034740-30193-1-git-send-email-cpaul@redhat.com> CC: Jerome Glisse , Benjamin Tissoires From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <56507E0F.7030009@amd.com> Date: Sat, 21 Nov 2015 15:22:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1448034740-30193-1-git-send-email-cpaul@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [2a02:908:f673:17e1:3543:c961:35cf:61cf] X-ClientProxiedBy: HE1PR02CA0078.eurprd02.prod.outlook.com (25.163.170.46) To DM2PR12MB0137.namprd12.prod.outlook.com (25.161.145.153) X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0137;2:5i8Gho31jg1uFardJmh5DAieuXaiNCLbMQaxUHHusFKfrnUpXuJi88LehxZFb9oAauo8PS9/VEPYw9UejEFpIFDrniPGYWciAR+Lx89hF1cx8CagfZcwagAHunILXQs8jdH0u3boIVlBmrBX8qQL/Q==;3:ANFcfUDzdNmUcnAk4Wd/T2Kh466N3AW4QzNdYzOtoibd0C8ImPgHuSolm6X+Eg/WcYGGl/qgnfrqA2gsOVWAZr0nJ9hQZg/TLEpN7vgg5V1dhG2+uMI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sKcm5dF8ElmgRuQVxV2xwRmwiU3OkN0y6J6vRSKmiko+UwLUhpN2NqpQmSBD2tgLR8i8poQ4IFSEHl4eyDcHYYdhg50l47zzhORglcsaB2UFL5BVlwFCjBAxUsVCw0HJOey0u0yMYcLWK0UWyNJ4CP+ZAMTisAfn6CxZ7p11cx/axWmxphjZA6tqVqVDkyBM0GtVnzEemJmElf3I32 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001);SRVR:DM2PR12MB0137;BCL:0;PCL:0;RULEID:;SRVR:DM2PR12MB0137; X-Forefront-PRVS: 076777155F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(24454002)(85664002)(52044002)(189002)(199003)(5001960100002)(65956001)(54356999)(189998001)(81156007)(4001350100001)(97736004)(50986999)(23746002)(5001920100001)(19580405001)(65816999)(92566002)(80316001)(19580395003)(122386002)(76176999)(59896002)(5007970100001)(101416001)(36756003)(5001770100001)(6116002)(33656002)(87266999)(5004730100002)(64126003)(47776003)(5008740100001)(575784001)(65806001)(105586002)(2950100001)(77096005)(40100003)(50466002)(83506001)(586003)(230700001)(2201001)(86362001)(42186005)(106356001)(87976001)(99136001)(3826002)(5001840100002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR12MB0137;H:[IPv6:2a02:908:f673:17e1:3543:c961:35cf:61cf];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DM2PR12MB0137;23:Yz1Wyz46H8XLs19RjFKaMM8RjrBbt09P0k10e?= =?Windows-1252?Q?VtRHhbr1JEc3xDevFxYdDrfgDMUjoR4JaC8XvzrG8BMv7N20FSlr/tvJ?= =?Windows-1252?Q?enc4IlM5mqcmuu59JJRJMBFzVu5StJufF+y13U29Lmx9vwsIfeD9o5KG?= =?Windows-1252?Q?uuJllK1R3uQriVH4BMm/RNNYXOEExHjqv8mFa6T6luDImdp9kVqFE30I?= =?Windows-1252?Q?qYCaJvVF3AJVb+e4k5k90t5LfSNh1SR+otJIZi84fs6GifQUvLQDAz2L?= =?Windows-1252?Q?VzNHraLAvj7D0jZyqft67VHIdb0TP8UWnADfNvxsPRrYoxcGEhDkg085?= =?Windows-1252?Q?wY+v5Tx02zWcBEQQVrYJFT+nNmg3nNx+9V3gZt4Dk2IZ9RqsOSwJW3zi?= =?Windows-1252?Q?u4pi5REqJoKFGUoDUSM9QIabICWiKhC1fgOlgrUTaiL2Eu3JSP+6lVjx?= =?Windows-1252?Q?B2g5DmotiysB+AFpEWilY/k8m1SGRc/j54wo/X8iySbyXUOW0tiL8VXD?= =?Windows-1252?Q?Efjo9qyNHQDU1PEXOm2SVk5WlmT8czAdBGlIIjEBwiB/S/4FYCfBcTUa?= =?Windows-1252?Q?n76TArc2AFnxLhq8iBrEeD037V/F4TqKrapL8fid8FbeD0f+7PlQGFOw?= =?Windows-1252?Q?ZkvDP2EFUsO/yFrq35YzX/Y2fvbzNnKpbuBPGozMMc8MG3a/urBlEP/o?= =?Windows-1252?Q?m7KoTT315wRTZZbuyy7nEb6iNawo+L5Sc7dNByk6KZuaDuz4iaela7Wf?= =?Windows-1252?Q?Klr2tZj1kNYnuOlC1Xy806uc9SKAq6zWoRwm/j6JgDxe+0ZPLFPQrLCA?= =?Windows-1252?Q?nc37qSd1tATwJzpHWYSuD3fIp7SxfrA2hLU9zomHWlJ0am2f32XA4vWD?= =?Windows-1252?Q?aiHg5ulYBCDp9TWnfcJy1Ef7cOPd8WXOsdFKyt6xD2Ax456yRKOFn8I5?= =?Windows-1252?Q?DJ4ieugrUhfWBmJWSmhQJx8RlX7KBEyhSeLxNWQ6Ge4zgjsY7LVaTrQ4?= =?Windows-1252?Q?FtpNPz3umHOiGxtQyUu/GfDUiysDaC6BE1tAuam1nioMQEcy9RL3uBvZ?= =?Windows-1252?Q?389iJoqlc6K38+EP2MT2/3NkZFYP2VR1QBcRYBMWxDFpQlcDFhhjKcXJ?= =?Windows-1252?Q?Y945MqPZnNG0VtkyVwwjC8DKPLMahsyuZSg5hHfmoDjL+E5YAJg1w0X7?= =?Windows-1252?Q?WxSx1NkdxwAYZX7UbeXMjhyG9a2F1TDneLGEW1ZhoKd6bfzaCM1+Fdzo?= =?Windows-1252?Q?jlYztspkhH8QMKAT+6zIjXvi2AUzyDJdMc3r6/ULUusSYvjIGjomn9sW?= =?Windows-1252?Q?QtYF3o/DOOwmZkZagS5mFCRLgC9ofbLZN3XyZq0yKs+h98qlCUtFzZJl?= =?Windows-1252?Q?Yqun//n7LNZs6H5albwrUXfiWkDdpO74McsgZxtdIgewGx7xyUqTBhdC?= =?Windows-1252?Q?JeiXMWX7yFepDdAAFBOsP+fB4PAj99cMqaEfFsAHb+JikErwJVJy5a18?= =?Windows-1252?Q?4jR+OMJGvefmMTEcVRCZUm6vA8k?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0137;5:BT37+6JGxtFWi5a62lEIUt+TxkJy1gO0QaOdrszs8LObXGusMvPpr8A68pPcx6rOfS0dyTN09gpLepJ8SRTugZlH2Zt+l3OlJavgX48+2KlgunZ44ZtNxYkPmDbcEdowQKy4yKMUyAdT6Lj2B0qNxg==;24:nOWLSTPOildooiODfjW/C26VF2djLmgtPshGCKXOP+M0lfoHxG6lMvThISnAPeJu9dr5/dXw1JHMRG81oMvZhGceaquO5y8Lp6aqLFeAyt8=;20:vuq6kcPcc3ahpOaXnEldPSA/7QyPAGIZVWzyNHjN58FEf3aM1G+fSPwg4wU2XB2E3u5716ZpKKGJuwgo7izXRODCM5skl5yuSn6jldhfOpm+wqhbf2rYnjhvoKBnbEyNzBpxL/KynlFnSVIQ88ftgkYf88pJfaiIPBMe/GDIMK5qC0ZQTc2ahaI69SDLO7vZrbybQp7jjhJYnvmRXJ5fhnO3GSyPhZpcWxTKLsGvfWMA3rAd+PyODwRq2fdqvdn5 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2015 14:22:24.0819 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0137 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5898 Lines: 135 On 20.11.2015 16:52, cpaul@redhat.com wrote: > From: Stephen Chandler Paul > > 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. > > This is somewhat rare on most cards (depending on what angle you plug > the DVI connector in), but on some cards it happens constantly. The > Radeon R5 on the machine used for testing this patch for instance, runs > into this issue just about every time I try to hotplug a DVI monitor and > as a result hotplugging almost never works. > > 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: Stephen Chandler Paul Yeah, that's something I always wondered a about bit as well. Debouncing is something very common done in electronics, but as far as I know the HPD pins don't necessary have an RC circuit so we might need to handle this case in software here. A delay of something between 10-30ms between the last HPD interrupt and further processing of the signal doesn't sounds like such a bad idea. Retrying on the other hand doesn't necessarily improve the situation cause the delay introduced by this might not be enough. So I would rather vote for a fixed delay between an HPD interrupt and actually starting to process anything. Regards, Christian. > --- > So this one has kind of been a tough sell with Jerome, mostly because it's > somewhat of a hack. Unfortunately however I've managed to find machines where > DVI hotplugging literally doesn't work without a patch like this. We've already > tried a couple of ways of handling the situation of retriggering ddc probes: > > * Trying the DDC probe in the radeon_dvi_detect() function multiple times. > * Trying to reschedule the hotplug_work task whenever DDC probing fails on DVI > but we got a hpd signal (this ended up being a much more complicated patch > then anticipated) > * Doing what we do right now, which is just triggering userspace to rescan all > the ports when the hpd signal is asserted by the DVI port but there's no DDC > probe, and repeating until at least a second passes. > > All of these actually work, but I guess it's a question of which one is less of > a hack. If anyone here can think of a cleaner way of handling this feel free to > let me know. > > drivers/gpu/drm/radeon/radeon.h | 3 +++ > drivers/gpu/drm/radeon/radeon_connectors.c | 20 +++++++++++++++++--- > drivers/gpu/drm/radeon/radeon_irq_kms.c | 2 ++ > 3 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h > index b6cbd81..d63f0fe 100644 > --- a/drivers/gpu/drm/radeon/radeon.h > +++ b/drivers/gpu/drm/radeon/radeon.h > @@ -2460,6 +2460,9 @@ struct radeon_device { > /* amdkfd interface */ > struct kfd_dev *kfd; > > + /* last time we received an hpd signal */ > + unsigned long hpd_time; > + > struct mutex mn_lock; > DECLARE_HASHTABLE(mn_hash, 7); > }; > diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c > index 5a2cafb..4ee9440 100644 > --- a/drivers/gpu/drm/radeon/radeon_connectors.c > +++ b/drivers/gpu/drm/radeon/radeon_connectors.c > @@ -1228,19 +1228,33 @@ radeon_dvi_detect(struct drm_connector *connector, bool force) > const struct drm_encoder_helper_funcs *encoder_funcs; > int i, r; > enum drm_connector_status ret = connector_status_disconnected; > - bool dret = false, broken_edid = false; > + bool dret = false, broken_edid = false, hpd_unchanged; > > r = pm_runtime_get_sync(connector->dev->dev); > if (r < 0) > return connector_status_disconnected; > > - if (!force && radeon_check_hpd_status_unchanged(connector)) { > + hpd_unchanged = radeon_check_hpd_status_unchanged(connector); > + if (!force && hpd_unchanged) { > ret = connector->status; > goto exit; > } > > - if (radeon_connector->ddc_bus) > + if (radeon_connector->ddc_bus) { > dret = radeon_ddc_probe(radeon_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, signal userspace to try again */ > + if (!dret && !hpd_unchanged && > + connector->status != connector_status_connected && > + time_before(jiffies, rdev->hpd_time + msecs_to_jiffies(1000))) { > + DRM_DEBUG_KMS("%s: hpd asserted but ddc probe failed, retrying\n", > + connector->name); > + drm_sysfs_hotplug_event(dev); > + } > + } > if (dret) { > radeon_connector->detected_by_load = false; > radeon_connector_free_edid(connector); > diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c > index 171d3e4..579c22c 100644 > --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c > +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c > @@ -79,6 +79,8 @@ static void radeon_hotplug_work_func(struct work_struct *work) > struct drm_mode_config *mode_config = &dev->mode_config; > struct drm_connector *connector; > > + rdev->hpd_time = jiffies; > + > /* we can race here at startup, some boards seem to trigger > * hotplug irqs when they shouldn't. */ > if (!rdev->mode_info.mode_config_initialized) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/