diff mbox

drm/radeon: on hotplug force link training to happen

Message ID 1342558491-6985-1-git-send-email-j.glisse@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jerome Glisse July 17, 2012, 8:54 p.m. UTC
From: Jerome Glisse <jglisse@redhat.com>

To have kernel behave like VGA/DVI we need to retrain link
on hotplug. For this to happen with need to report that
we need to link training to happen if we fail to get link
status and we need to force link training to happen by
setting connector dpms to off before asking it on.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
---
 drivers/gpu/drm/radeon/atombios_dp.c       |    2 +-
 drivers/gpu/drm/radeon/radeon_connectors.c |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Alex Deucher July 17, 2012, 10:25 p.m. UTC | #1
On Tue, Jul 17, 2012 at 4:54 PM,  <j.glisse@gmail.com> wrote:
> From: Jerome Glisse <jglisse@redhat.com>
>
> To have kernel behave like VGA/DVI we need to retrain link
> on hotplug. For this to happen with need to report that
> we need to link training to happen if we fail to get link
> status and we need to force link training to happen by
> setting connector dpms to off before asking it on.
>
> Signed-off-by: Jerome Glisse <jglisse@redhat.com>
> ---
>  drivers/gpu/drm/radeon/atombios_dp.c       |    2 +-
>  drivers/gpu/drm/radeon/radeon_connectors.c |    7 +++++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
> index 5131b3b..7bb5d7e 100644
> --- a/drivers/gpu/drm/radeon/atombios_dp.c
> +++ b/drivers/gpu/drm/radeon/atombios_dp.c
> @@ -670,7 +670,7 @@ bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector)
>         struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
>
>         if (!radeon_dp_get_link_status(radeon_connector, link_status))
> -               return false;
> +               return true;

I'm not sure we want to change the logic here.  The idea was that if
we failed to get the link status, the monitor is most likely not
attached so there's no need to retrain the link.

Alex

>         if (dp_channel_eq_ok(link_status, dig->dp_lane_count))
>                 return false;
>         return true;
> diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
> index 2914c57..4b42c9f 100644
> --- a/drivers/gpu/drm/radeon/radeon_connectors.c
> +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
> @@ -67,10 +67,13 @@ void radeon_connector_hotplug(struct drm_connector *connector)
>                 int saved_dpms = connector->dpms;
>
>                 /* Only turn off the display it it's physically disconnected */
> -               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
> +               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
>                         drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
> -               else if (radeon_dp_needs_link_train(radeon_connector))
> +               } else if (radeon_dp_needs_link_train(radeon_connector)) {
> +                       /* force a mode on to trigger dp link training */
> +                       connector->dpms = DRM_MODE_DPMS_OFF;
>                         drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
> +               }
>                 connector->dpms = saved_dpms;
>         }
>  }
> --
> 1.7.10.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Jerome Glisse July 18, 2012, 12:28 a.m. UTC | #2
On Tue, Jul 17, 2012 at 6:25 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Tue, Jul 17, 2012 at 4:54 PM,  <j.glisse@gmail.com> wrote:
>> From: Jerome Glisse <jglisse@redhat.com>
>>
>> To have kernel behave like VGA/DVI we need to retrain link
>> on hotplug. For this to happen with need to report that
>> we need to link training to happen if we fail to get link
>> status and we need to force link training to happen by
>> setting connector dpms to off before asking it on.
>>
>> Signed-off-by: Jerome Glisse <jglisse@redhat.com>
>> ---
>>  drivers/gpu/drm/radeon/atombios_dp.c       |    2 +-
>>  drivers/gpu/drm/radeon/radeon_connectors.c |    7 +++++--
>>  2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
>> index 5131b3b..7bb5d7e 100644
>> --- a/drivers/gpu/drm/radeon/atombios_dp.c
>> +++ b/drivers/gpu/drm/radeon/atombios_dp.c
>> @@ -670,7 +670,7 @@ bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector)
>>         struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
>>
>>         if (!radeon_dp_get_link_status(radeon_connector, link_status))
>> -               return false;
>> +               return true;
>
> I'm not sure we want to change the logic here.  The idea was that if
> we failed to get the link status, the monitor is most likely not
> attached so there's no need to retrain the link.
>
> Alex

Well not if you disconnect reconnect, the link goes down and link
status fails even with something connected. At least this is what i
get with couple different dp monitor

Cheers,
Jerome

>>         if (dp_channel_eq_ok(link_status, dig->dp_lane_count))
>>                 return false;
>>         return true;
>> diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
>> index 2914c57..4b42c9f 100644
>> --- a/drivers/gpu/drm/radeon/radeon_connectors.c
>> +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
>> @@ -67,10 +67,13 @@ void radeon_connector_hotplug(struct drm_connector *connector)
>>                 int saved_dpms = connector->dpms;
>>
>>                 /* Only turn off the display it it's physically disconnected */
>> -               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
>> +               if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
>>                         drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
>> -               else if (radeon_dp_needs_link_train(radeon_connector))
>> +               } else if (radeon_dp_needs_link_train(radeon_connector)) {
>> +                       /* force a mode on to trigger dp link training */
>> +                       connector->dpms = DRM_MODE_DPMS_OFF;
>>                         drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
>> +               }
>>                 connector->dpms = saved_dpms;
>>         }
>>  }
>> --
>> 1.7.10.4
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 5131b3b..7bb5d7e 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -670,7 +670,7 @@  bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector)
 	struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
 
 	if (!radeon_dp_get_link_status(radeon_connector, link_status))
-		return false;
+		return true;
 	if (dp_channel_eq_ok(link_status, dig->dp_lane_count))
 		return false;
 	return true;
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 2914c57..4b42c9f 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -67,10 +67,13 @@  void radeon_connector_hotplug(struct drm_connector *connector)
 		int saved_dpms = connector->dpms;
 
 		/* Only turn off the display it it's physically disconnected */
-		if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+		if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
 			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-		else if (radeon_dp_needs_link_train(radeon_connector))
+		} else if (radeon_dp_needs_link_train(radeon_connector)) {
+			/* force a mode on to trigger dp link training */
+			connector->dpms = DRM_MODE_DPMS_OFF;
 			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
+		}
 		connector->dpms = saved_dpms;
 	}
 }